diff --git a/.github/workflows/zip-maplibs.yml b/.github/workflows/zip-maplibs.yml new file mode 100644 index 00000000..d6146002 --- /dev/null +++ b/.github/workflows/zip-maplibs.yml @@ -0,0 +1,39 @@ +name: Create Release with Library Zips + +on: + release: + types: + - created + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # If PHP dependencies are not relevant, you can remove the steps related to Composer + - name: Install PHP dependencies + run: composer install --no-dev + + - name: Zip mapbox-gl library + run: cd web/libraries/mapbox-gl && zip -r mapbox-gl.zip . -x "*.git*" + + - name: Zip maplibre-gl library + run: cd web/libraries/maplibre-gl && zip -r maplibre-gl.zip . -x "*.git*" + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' # Specify the Node.js version + # Release with the zipped libraries + - name: Create Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + mapbox-gl.zip + maplibre-gl.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.gitignore b/.gitignore index 98963588..fd9bcde2 100755 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,8 @@ web/modules/contrib web/themes/contrib web/profiles/contrib web/libraries - +!web/libraries/mapbox-gl +!web/libraries/maplibre-gl # Ignore Drupal's file directory web/sites/*/files @@ -32,4 +33,4 @@ web/sites/*/settings.local.php /index.php /robots.txt /update.php -/web.config \ No newline at end of file +/web.config diff --git a/web/libraries/maplibre-gl/LICENSE.txt b/web/libraries/maplibre-gl/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/web/libraries/maplibre-gl/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/web/libraries/maplibre-gl/README.md b/web/libraries/maplibre-gl/README.md new file mode 100644 index 00000000..7022fd53 --- /dev/null +++ b/web/libraries/maplibre-gl/README.md @@ -0,0 +1,157 @@ +![MapLibre Logo](https://maplibre.org/img/maplibre-logo-big.svg) + +# MapLibre GL JS + +[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=flat)](LICENSE.txt) [![Version](https://img.shields.io/npm/v/maplibre-gl?style=flat)](https://www.npmjs.com/package/maplibre-gl) [![CI](https://github.com/maplibre/maplibre-gl-js/actions/workflows/test-all.yml/badge.svg)](https://github.com/maplibre/maplibre-gl-js/actions/workflows/test-all.yml) [![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://opensource.org/licenses/BSD-3-Clause) [![codecov](https://codecov.io/gh/maplibre/maplibre-gl-js/branch/main/graph/badge.svg)](https://codecov.io/gh/maplibre/maplibre-gl-js) + +**[MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/API/)** is an open-source library for publishing maps on your websites or webview based apps. Fast displaying of maps is possible thanks to GPU-accelerated vector tile rendering. + +It originated as an open-source fork of [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js), before their switch to a non-OSS license in December 2020. The library's initial versions (1.x) were intended to be a drop-in replacement for the Mapbox’s OSS version (1.x) with additional functionality, but have evolved a lot since then. + +## Getting Started + +Include the JavaScript and CSS files in the `` of your HTML file. + +``` html + + +``` + +Include the following code in the `` of your HTML file. + +``` html +
+ +``` + +Enjoy the map! + +
+ +## Documentation + +Full documentation for this library [is available here](https://maplibre.org/maplibre-gl-js/docs/API/). + +Check out the features through [examples](https://maplibre.org/maplibre-gl-js/docs/examples/). + +| Showcases | | +| ---- | ---- | +|![Display a map](https://maplibre.org/maplibre-gl-js/docs/assets/examples/simple-map.png) |![Third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/assets/examples/3d-terrain.png) | +|![Animate a series of images](https://maplibre.org/maplibre-gl-js/docs/assets/examples/animate-images.png) |![Create a heatmap layer](https://maplibre.org/maplibre-gl-js/docs/assets/examples/heatmap-layer.png) | +|![3D buildings](https://maplibre.org/maplibre-gl-js/docs/assets/examples/3d-buildings.png) |![Visualize population density](https://maplibre.org/maplibre-gl-js/docs/assets/examples/visualize-population-density.png) | + +
+ + +Want an example? Have a look at the official [MapLibre GL JS Documentation](https://maplibre.org/maplibre-gl-js/docs/examples/). + +Use MapLibre GL JS bindings for React (https://visgl.github.io/react-map-gl/docs/get-started/get-started#using-with-a-mapbox-gl-fork) and Angular (https://github.com/maplibre/ngx-maplibre-gl). Find more at [awesome-maplibre](https://github.com/maplibre/awesome-maplibre). + +
+ +## Contribution + +### Getting Involved + +Join the #maplibre slack channel at OSMUS: get an invite at https://slack.openstreetmap.us/ +Read the [CONTRIBUTING.md](CONTRIBUTING.md) guide in order to get familiar with how we do things around here. + +### Community Leadership + +You can find the official status of the backing community and steering committee in the [COMMUNITY.md](COMMUNITY.md) document. + +### Avoid Fragmentation + +If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL JS already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here. + + +> **MapLibre GL JS** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html). + +### Bounties + +We offer Bounties for some tasks in the MapLibre GL JS repo. Read more about the Bounties in our step-by-step guide: + +https://maplibre.org/roadmap/step-by-step-bounties-guide/ + +And find all currently published Bounties in MapLibre GL JS [here](https://github.com/maplibre/maplibre-gl-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22%F0%9F%92%B0+bounty+L%22%2C%22%F0%9F%92%B0+bounty+S%22%2C%22%F0%9F%92%B0+bounty+M%22%2C%22%F0%9F%92%B0+bounty+XL%22%2C%22%F0%9F%92%B0+bounty+XXL%22+). + +
+ +## Sponsors + +We thank everyone who supported us financially in the past and special thanks to the people and organizations who support us with recurring donations! + +Read more about the MapLibre Sponsorship Program at [https://maplibre.org/sponsors/](https://maplibre.org/sponsors/). + +Platinum: + +Logo AWS + +Gold: + +Logo Meta + +Silver: + +Logo MIERUNE + +Logo komoot + +Logo JawgMaps + +Logo Radar + +Backers and Supporters: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +## Thank you Mapbox 🙏🏽 + +We'd like to acknowledge the amazing work Mapbox has contributed to open source. The open source community is sad to part ways with them, but we simultaneously feel grateful for everything they already contributed. `mapbox-gl-js` 1.x is an open source achievement that now lives on as `maplibre-gl`. We're proud to develop on the shoulders of giants, thank you Mapbox 🙇🏽‍♀️. + +Please keep in mind: Unauthorized backports are the biggest threat to the MapLibre project. It is unacceptable to backport code from mapbox-gl-js, which is not covered by the former BSD-3 license. If you are unsure about this issue, [please ask](https://github.com/maplibre/maplibre-gl-js/discussions)! + +
+ +## License + +**MapLibre GL JS** is licensed under the [3-Clause BSD license](./LICENSE.txt). diff --git a/web/libraries/maplibre-gl/build/banner.ts b/web/libraries/maplibre-gl/build/banner.ts new file mode 100644 index 00000000..02cccd0c --- /dev/null +++ b/web/libraries/maplibre-gl/build/banner.ts @@ -0,0 +1,3 @@ +import packageJSON from '../package.json' assert {type: 'json'}; + +export default `/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v${packageJSON.version}/LICENSE.txt */`; diff --git a/web/libraries/maplibre-gl/build/bump-version-changelog.js b/web/libraries/maplibre-gl/build/bump-version-changelog.js new file mode 100755 index 00000000..8263b585 --- /dev/null +++ b/web/libraries/maplibre-gl/build/bump-version-changelog.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +/** + * This script updates the changelog.md file with the version given in the arguments + * It replaces ## main with ## + * Removes _...Add new stuff here..._ + * And adds on top a ## main with add stuff here. + */ + +import * as fs from 'fs'; + +const changelogPath = 'CHANGELOG.md'; +let changelog = fs.readFileSync(changelogPath, 'utf8'); +changelog = changelog.replace('## main', `## ${process.argv[2]}`); +changelog = changelog.replaceAll('- _...Add new stuff here..._\n', ''); +changelog = `## main + +### ✨ Features and improvements +- _...Add new stuff here..._ + +### 🐞 Bug fixes +- _...Add new stuff here..._ + +` + changelog; + +fs.writeFileSync(changelogPath, changelog, 'utf8'); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/build/check-bundle-size.js b/web/libraries/maplibre-gl/build/check-bundle-size.js new file mode 100755 index 00000000..10a8edfd --- /dev/null +++ b/web/libraries/maplibre-gl/build/check-bundle-size.js @@ -0,0 +1,77 @@ +#!/usr/bin/env node + +import fs from "fs"; +import zlib from "zlib"; +import prettyBytes from "pretty-bytes"; +const beforeSourcemap = JSON.parse(fs.readFileSync('./before.json').toString()); +const afterSourcemap = JSON.parse(fs.readFileSync('./after.json').toString()); + +function fileSize(file) { + const {size} = fs.statSync(file); + const gzipped = zlib.gzipSync(fs.readFileSync(file)).length + return { + size, + gzipped + }; +} + +const beforejs = fileSize('./before/maplibre-gl.js'); +const beforecss = fileSize('./before/maplibre-gl.css'); +const afterjs = fileSize('./after/maplibre-gl.js'); +const aftercss = fileSize('./after/maplibre-gl.css'); + +console.log('Bundle size report:\n'); +console.log(`**Size Change:** ${prettyBytes(afterjs.gzipped + aftercss.gzipped - (beforejs.gzipped + beforecss.gzipped), { signed: true })}`); +console.log(`**Total Size Before:** ${prettyBytes(beforejs.gzipped + beforecss.gzipped)}`); +console.log(`**Total Size After:** ${prettyBytes(afterjs.gzipped + aftercss.gzipped)}`); +console.log(` +| Output file | Before | After | Change | +| :--- | :---: | :---: | :---: | +| maplibre-gl.js | ${prettyBytes(beforejs.gzipped)} | ${prettyBytes(afterjs.gzipped)} | ${prettyBytes(afterjs.gzipped - beforejs.gzipped, { signed: true })} | +| maplibre-gl.css | ${prettyBytes(beforecss.gzipped)} | ${prettyBytes(aftercss.gzipped)} | ${prettyBytes(aftercss.gzipped - beforecss.gzipped, { signed: true })} |`); + +const before = {}; +beforeSourcemap.results.forEach(result => { + Object.keys(result.files).forEach(filename => { + const {size} = result.files[filename]; + before[filename] = size; + }); +}); + +const after = {}; +afterSourcemap.results.forEach(result => { + Object.keys(result.files).forEach(filename => { + const {size} = result.files[filename]; + after[filename] = size; + }); +}); + +const diffs = []; +Object.keys(Object.assign({}, before, after)).forEach(filename => { + const beforeSize = before[filename] || 0; + const afterSize = after[filename] || 0; + if (Math.abs(afterSize - beforeSize) > 0) { + diffs.push([ + afterSize - beforeSize, // for sorting + filename.replace(/^[\./]+/, ''), // omit ../ + prettyBytes(beforeSize), + prettyBytes(afterSize), + prettyBytes(afterSize - beforeSize, { signed: true }) + ]); + } +}); + +diffs.sort((a, b) => b[0] - a[0]); + +console.log(` +
ℹ️ View Details`); +if (diffs.length) { + console.log(` +| Source file | Before | After | Change | +| :--- | :---: | :---: | :---: | +${diffs.map(diff => '| ' + diff.slice(1).join(' | ') + ' |').join('\n')} +`); +} else { + console.log('No major changes'); +} +console.log(`
`); diff --git a/web/libraries/maplibre-gl/build/generate-dist-package.js b/web/libraries/maplibre-gl/build/generate-dist-package.js new file mode 100644 index 00000000..7a4fe1b5 --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-dist-package.js @@ -0,0 +1,26 @@ +'use strict'; +/// js files in this project are esm. +/// This package.json ensures that node imports from outside see them as such +// https://nodejs.org/api/packages.html#type + +import { writeFile, mkdir, copyFile } from "node:fs/promises" + +async function ensureDist() { + const dist = new URL("../dist/", import.meta.url); + await mkdir(dist, { recursive: true }) + return dist +} + +await writeFile( + new URL("package.json", await ensureDist()), + JSON.stringify({ + name: "maplibre-gl", + type: "commonjs", + deprecated: "Please install maplibre-gl from parent directory instead", + }) +) + +await copyFile( + "./LICENSE.txt", + new URL("LICENSE.txt", await ensureDist()) +) \ No newline at end of file diff --git a/web/libraries/maplibre-gl/build/generate-doc-images.ts b/web/libraries/maplibre-gl/build/generate-doc-images.ts new file mode 100644 index 00000000..50ce85bb --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-doc-images.ts @@ -0,0 +1,73 @@ +import path from 'path'; +import fs from 'fs'; +import puppeteer from 'puppeteer'; +import packageJson from '../package.json' assert { type: 'json' }; + +const exampleName = process.argv[2]; +const examplePath = path.resolve('test', 'examples'); + +const browser = await puppeteer.launch({headless: exampleName === 'all'}); + +const page = await browser.newPage(); +// set viewport and double deviceScaleFactor to get a closer shot of the map +await page.setViewport({ + width: 600, + height: 250, + deviceScaleFactor: 2 +}); + +async function createImage(exampleName) { + // get the example contents + const html = fs.readFileSync(path.resolve(examplePath, `${exampleName}.html`), 'utf-8'); + + await page.setContent(html.replaceAll('../../dist', `https://unpkg.com/maplibre-gl@${packageJson.version}/dist`)); + + // Wait for map to load, then wait two more seconds for images, etc. to load. + await page + .waitForFunction('map.loaded()') + .then(async () => { + // Wait for 5 seconds on 3d model examples, since this takes longer to load. + const waitTime = exampleName.includes('3d-model') ? 5000 : 1500; + await new Promise((resolve) => { + console.log(`waiting for ${waitTime} ms`); + setTimeout(resolve, waitTime); + }); + }) + // map.loaded() does not evaluate to true within 3 seconds, it's probably an animated example. + // In this case we take the screenshot immediately. + .catch(() => { + console.log(`Timed out waiting for map load on ${exampleName}.`); + }); + + await page + .screenshot({ + path: `./docs/assets/examples/${exampleName}.png`, + type: 'png', + clip: { + x: 0, + y: 0, + width: 600, + height: 250 + } + }) + .then(() => console.log(`Created ./docs/assets/examples/${exampleName}.png`)) + .catch((err) => { + console.log(err); + }); +} + +if (exampleName === 'all') { + const allFiles = fs.readdirSync(examplePath).filter(f => f.endsWith('html')); + console.log(`Generating ${allFiles.length} images.`); + for (const file of allFiles) { + await createImage(file); + } +} else if (exampleName) { + await createImage(exampleName); +} else { + throw new Error( + '\n Usage: npm run generate-images \nExample: npm run generate-images 3d-buildings' + ); +} + +await browser.close(); diff --git a/web/libraries/maplibre-gl/build/generate-docs.ts b/web/libraries/maplibre-gl/build/generate-docs.ts new file mode 100644 index 00000000..8b71d8e5 --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-docs.ts @@ -0,0 +1,100 @@ +import fs from 'fs'; +import path from 'path'; +import typedocConfig from '../typedoc.json' assert {type: 'json'}; +import packageJson from '../package.json' assert {type: 'json'}; + +type HtmlDoc = { + title: string; + description: string; + mdFileName: string; +} + +function generateAPIIntroMarkdown(lines: string[]): string { + let intro = `# Intro + +This file is intended as a reference for the important and public classes of this API. +We recommend looking at the [examples](../examples/index.md) as they will help you the most to start with MapLibre. + +Most of the classes wirtten here have an "Options" object for initialization, it is recommended to check which options exist. + +`; + intro += lines.map(l => l.replace('../', './')).join('\n'); + return intro; +} + +function generateMarkdownForExample(title: string, description: string, file: string, htmlContent: string): string { + return ` +# ${title} + +${description} + + + +\`\`\`html +${htmlContent} +\`\`\` +`; +} + +function generateMarkdownIndexFileOfAllExamples(indexArray: HtmlDoc[]): string { + let indexMarkdown = '# Overview \n\n'; + for (const indexArrayItem of indexArray) { + indexMarkdown += ` +## [${indexArrayItem.title}](./${indexArrayItem.mdFileName}) + +![${indexArrayItem.description}](../assets/examples/${indexArrayItem.mdFileName!.replace('.md', '.png')}) + +${indexArrayItem.description} +`; + } + return indexMarkdown; +} + +if (!fs.existsSync(typedocConfig.out)) { + throw new Error('Please run typedoc generation first!'); +} + +fs.rmSync(path.join(typedocConfig.out, 'README.md')); +fs.rmSync(path.join(typedocConfig.out, 'modules.md')); +// Intro file for the API +const modulesFolder = path.join(typedocConfig.out, 'modules'); +const content = fs.readFileSync(path.join(modulesFolder, `${typedocConfig.internalModule}.md`), 'utf-8'); +let lines = content.split('\n'); +const classesLineIndex = lines.indexOf(lines.find(l => l.endsWith('Classes')) as string); +lines = lines.splice(2, classesLineIndex - 2); +const contentString = generateAPIIntroMarkdown(lines); +fs.writeFileSync(path.join(typedocConfig.out, 'README.md'), contentString); + +// Examples manupilation +const examplesDocsFolder = path.join('docs', 'examples'); +if (fs.existsSync(examplesDocsFolder)) { + fs.rmSync(examplesDocsFolder, {recursive: true, force: true}); +} +fs.mkdirSync(examplesDocsFolder); +const examplesFolder = path.join('test', 'examples'); +const files = fs.readdirSync(examplesFolder).filter(f => f.endsWith('html')); +const maplibreUnpgk = `https://unpkg.com/maplibre-gl@${packageJson.version}/`; +const indexArray = [] as HtmlDoc[]; +for (const file of files) { + const htmlFile = path.join(examplesFolder, file); + let htmlContent = fs.readFileSync(htmlFile, 'utf-8'); + htmlContent = htmlContent.replace(/\.\.\/\.\.\//g, maplibreUnpgk); + htmlContent = htmlContent.replace(/-dev.js/g, '.js'); + const htmlContentLines = htmlContent.split('\n'); + const title = htmlContentLines.find(l => l.includes('', '').replace('', '').trim(); + const description = htmlContentLines.find(l => l.includes('og:description'))?.replace(/.*content=\"(.*)\".*/, '$1'); + fs.writeFileSync(path.join(examplesDocsFolder, file), htmlContent); + const mdFileName = file.replace('.html', '.md'); + indexArray.push({ + title: title!, + description: description!, + mdFileName + }); + const exampleMarkdown = generateMarkdownForExample(title, description, file, htmlContent); + fs.writeFileSync(path.join(examplesDocsFolder, mdFileName), exampleMarkdown); +} + +const indexMarkdown = generateMarkdownIndexFileOfAllExamples(indexArray); +fs.writeFileSync(path.join(examplesDocsFolder, 'index.md'), indexMarkdown); + +console.log('Docs generation completed, to see it in action run\n docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material'); diff --git a/web/libraries/maplibre-gl/build/generate-shaders.ts b/web/libraries/maplibre-gl/build/generate-shaders.ts new file mode 100644 index 00000000..5f3e2409 --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-shaders.ts @@ -0,0 +1,68 @@ +import fs from 'fs'; +import {globSync} from 'glob'; +import path from 'path'; + +console.log('Generating shaders'); + +/** + * This script is intended to copy the glsl file to the compilation output folder, + * change their extension to .js and export the shaders as strings in javascript. + * It will also minify them a bit if needed and change the extension to .js + * After that it will create a combined typescript definition file and manipulate it a bit + * It will also create a simple package.json file to allow importing this package in webpack + */ + +const vertex = globSync('./src/shaders/*.vertex.glsl'); +for (const file of vertex) { + const code = fs.readFileSync(file, 'utf8'); + const content = glslToTs(code, 'vertex'); + const fileName = path.join('.', 'src', 'shaders', `${file.split(path.sep).splice(-1)}.g.ts`); + fs.writeFileSync(fileName, content); +} + +console.log(`Finished converting ${vertex.length} vertex shaders`); + +const fragment = globSync('./src/shaders/*.fragment.glsl'); +for (const file of fragment) { + const code = fs.readFileSync(file, 'utf8'); + const content = glslToTs(code, 'fragment'); + const fileName = path.join('.', 'src', 'shaders', `${file.split(path.sep).splice(-1)}.g.ts`); + fs.writeFileSync(fileName, content); +} + +console.log(`Finished converting ${fragment.length} fragment shaders`); + +function glslToTs(code: string, type: 'fragment'|'vertex'): string { + code = code + .trim(); // strip whitespace at the start/end + + // WebGL1 Compat -- Start + + if (type === 'fragment') { + code = code + .replace(/\bin\s/g, 'varying ') // For fragment shaders, replace "in " with "varying " + .replace('out highp vec4 fragColor;', ''); + } + + if (type === 'vertex') { + code = code + .replace(/\bin\s/g, 'attribute ') // For vertex shaders, replace "in " with "attribute " + .replace(/\bout\s/g, 'varying '); // For vertex shaders, replace "out " with "varying " + } + + code = code + .replace(/fragColor/g, 'gl_FragColor') + .replace(/texture\(/g, 'texture2D('); + + // WebGL1 Compat -- End + + code = code + .replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments + .replace(/\n+/g, '\n') // collapse multi line breaks + .replace(/\n\s+/g, '\n') // strip indentation + .replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators + .replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks + + return `// This file is generated. Edit build/generate-shaders.ts, then run \`npm run codegen\`. +export default ${JSON.stringify(code).replaceAll('"', '\'')};\n`; +} diff --git a/web/libraries/maplibre-gl/build/generate-struct-arrays.ts b/web/libraries/maplibre-gl/build/generate-struct-arrays.ts new file mode 100644 index 00000000..06562fa7 --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-struct-arrays.ts @@ -0,0 +1,439 @@ +/* + * Generates the following: + * - data/array_types.js, which consists of: + * - StructArrayLayout_* subclasses, one for each underlying memory layout we need + * - Named exports mapping each conceptual array type (e.g., CircleLayoutArray) to its corresponding StructArrayLayout class + * - Particular, named StructArray subclasses, when fancy struct accessors are needed (e.g. CollisionBoxArray) + */ + +'use strict'; + +import * as fs from 'fs'; +import * as util from '../src/util/util'; +import {createLayout, viewTypes} from '../src/util/struct_array'; +import type {ViewType, StructArrayLayout} from '../src/util/struct_array'; + +import posAttributes from '../src/data/pos_attributes'; +import pos3dAttributes from '../src/data/pos3d_attributes'; +import rasterBoundsAttributes from '../src/data/raster_bounds_attributes'; +import circleAttributes from '../src/data/bucket/circle_attributes'; +import fillAttributes from '../src/data/bucket/fill_attributes'; +import fillExtrusionAttributes from '../src/data/bucket/fill_extrusion_attributes'; +import {lineLayoutAttributes} from '../src/data/bucket/line_attributes'; +import {lineLayoutAttributesExt} from '../src/data/bucket/line_attributes_ext'; +import {patternAttributes} from '../src/data/bucket/pattern_attributes'; +// symbol layer specific arrays +import { + symbolLayoutAttributes, + dynamicLayoutAttributes, + placementOpacityAttributes, + collisionBox, + collisionBoxLayout, + collisionCircleLayout, + collisionVertexAttributes, + quadTriangle, + placement, + symbolInstance, + glyphOffset, + lineVertex, + textAnchorOffset +} from '../src/data/bucket/symbol_attributes'; + +const typeAbbreviations = { + 'Int8': 'b', + 'Uint8': 'ub', + 'Int16': 'i', + 'Uint16': 'ui', + 'Int32': 'l', + 'Uint32': 'ul', + 'Float32': 'f' +}; + +const arraysWithStructAccessors = []; +const arrayTypeEntries = new Set(); +const layoutCache = {}; + +function normalizeMembers(members, usedTypes) { + return members.map((member) => { + if (usedTypes && !usedTypes.has(member.type)) { + usedTypes.add(member.type); + } + + return util.extend(member, { + size: sizeOf(member.type), + view: member.type.toLowerCase() + }); + }); +} + +// - If necessary, write the StructArrayLayout_* class for the given layout +// - If `includeStructAccessors`, write the fancy subclass +// - Add an entry for `name` in the array type registry +function createStructArrayType(name: string, layout: StructArrayLayout, includeStructAccessors: boolean = false) { + const hasAnchorPoint = layout.members.some(m => m.name === 'anchorPointX'); + + // create the underlying StructArrayLayout class exists + const layoutClass = createStructArrayLayoutType(layout); + const arrayClass = `${camelize(name)}Array`; + + if (includeStructAccessors) { + const usedTypes = new Set(['Uint8']); + const members = normalizeMembers(layout.members, usedTypes); + arraysWithStructAccessors.push({ + arrayClass, + members, + size: layout.size, + usedTypes, + hasAnchorPoint, + layoutClass, + includeStructAccessors + }); + } else { + arrayTypeEntries.add(`export class ${arrayClass} extends ${layoutClass} {}`); + } +} + +function createStructArrayLayoutType({members, size, alignment}) { + const usedTypes = new Set(['Uint8']); + members = normalizeMembers(members, usedTypes); + + // combine consecutive 'members' with same underlying type, summing their + // component counts + if (!alignment || alignment === 1) members = members.reduce((memo, member) => { + if (memo.length > 0 && memo[memo.length - 1].type === member.type) { + const last = memo[memo.length - 1]; + return memo.slice(0, -1).concat(util.extend({}, last, { + components: last.components + member.components, + })); + } + return memo.concat(member); + }, []); + + const key = `${members.map(m => `${m.components}${typeAbbreviations[m.type]}`).join('')}${size}`; + const className = `StructArrayLayout${key}`; + // Layout alignment to 4 bytes boundaries can be an issue on some set of graphics cards. Particularly AMD. + if (size % 4 !== 0) { console.warn(`Warning: The layout ${className} is not aligned to 4-bytes boundaries.`); } + if (!layoutCache[key]) { + layoutCache[key] = { + className, + members, + size, + usedTypes + }; + } + + return className; +} + +function sizeOf(type: ViewType): number { + return viewTypes[type].BYTES_PER_ELEMENT; +} + +function camelize (str) { + return str.replace(/(?:^|[-_])(.)/g, (_, x) => { + return /^[0-9]$/.test(x) ? _ : x.toUpperCase(); + }); +} + +createStructArrayType('pos', posAttributes); +createStructArrayType('pos3d', pos3dAttributes); +createStructArrayType('raster_bounds', rasterBoundsAttributes); + +// layout vertex arrays +const layoutAttributes = { + circle: circleAttributes, + fill: fillAttributes, + 'fill-extrusion': fillExtrusionAttributes, + heatmap: circleAttributes, + line: lineLayoutAttributes, + lineExt: lineLayoutAttributesExt, + pattern: patternAttributes +}; +for (const name in layoutAttributes) { + createStructArrayType(`${name.replace(/-/g, '_')}_layout`, layoutAttributes[name]); +} + +createStructArrayType('symbol_layout', symbolLayoutAttributes); +createStructArrayType('symbol_dynamic_layout', dynamicLayoutAttributes); +createStructArrayType('symbol_opacity', placementOpacityAttributes); +createStructArrayType('collision_box', collisionBox, true); +createStructArrayType('collision_box_layout', collisionBoxLayout); +createStructArrayType('collision_circle_layout', collisionCircleLayout); +createStructArrayType('collision_vertex', collisionVertexAttributes); +createStructArrayType('quad_triangle', quadTriangle); +createStructArrayType('placed_symbol', placement, true); +createStructArrayType('symbol_instance', symbolInstance, true); +createStructArrayType('glyph_offset', glyphOffset, true); +createStructArrayType('symbol_line_vertex', lineVertex, true); +createStructArrayType('text_anchor_offset', textAnchorOffset, true); + +// feature index array +createStructArrayType('feature_index', createLayout([ + // the index of the feature in the original vectortile + {type: 'Uint32', name: 'featureIndex'}, + // the source layer the feature appears in + {type: 'Uint16', name: 'sourceLayerIndex'}, + // the bucket the feature appears in + {type: 'Uint16', name: 'bucketIndex'} +]), true); + +// triangle index array +createStructArrayType('triangle_index', createLayout([ + {type: 'Uint16', name: 'vertices', components: 3} +])); + +// line index array +createStructArrayType('line_index', createLayout([ + {type: 'Uint16', name: 'vertices', components: 2} +])); + +// line strip index array +createStructArrayType('line_strip_index', createLayout([ + {type: 'Uint16', name: 'vertices', components: 1} +])); + +// paint vertex arrays + +// used by SourceBinder for float properties +createStructArrayLayoutType(createLayout([{ + name: 'dummy name (unused for StructArrayLayout)', + type: 'Float32', + components: 1 +}], 4)); + +// used by SourceBinder for color properties and CompositeBinder for float properties +createStructArrayLayoutType(createLayout([{ + name: 'dummy name (unused for StructArrayLayout)', + type: 'Float32', + components: 2 +}], 4)); + +// used by CompositeBinder for color properties +createStructArrayLayoutType(createLayout([{ + name: 'dummy name (unused for StructArrayLayout)', + type: 'Float32', + components: 4 +}], 4)); + +const layouts = Object.keys(layoutCache).map(k => layoutCache[k]); + +function emitStructArrayLayout(locals) { + const output = []; + const { + className, + members, + size, + usedTypes + } = locals; + const structArrayLayoutClass = className; + + output.push( + `/** + * @internal + * Implementation of the StructArray layout:`); + + for (const member of members) { + output.push( + ` * [${member.offset}]: ${member.type}[${member.components}]`); + } + + output.push( + ` * + */ +class ${structArrayLayoutClass} extends StructArray {`); + + for (const type of usedTypes) { + output.push( + ` ${type.toLowerCase()}: ${type}Array;`); + } + + output.push(` + _refreshViews() {`); + + for (const type of usedTypes) { + output.push( + ` this.${type.toLowerCase()} = new ${type}Array(this.arrayBuffer);`); + } + + output.push( + ' }'); + + // prep for emplaceBack: collect type sizes and count the number of arguments + // we'll need + const bytesPerElement = size; + const usedTypeSizes = []; + const argNames = []; + const argNamesTyped = []; + + for (const member of members) { + if (usedTypeSizes.indexOf(member.size) < 0) { + usedTypeSizes.push(member.size); + } + for (let c = 0; c < member.components; c++) { + // arguments v0, v1, v2, ... are, in order, the components of + // member 0, then the components of member 1, etc. + const name = `v${argNames.length}`; + argNames.push(name); + argNamesTyped.push(`${name}: number`); + } + } + + output.push( + ` + public emplaceBack(${argNamesTyped.join(', ')}) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, ${argNames.join(', ')}); + } + + public emplace(i: number, ${argNamesTyped.join(', ')}) {`); + + for (const size of usedTypeSizes) { + output.push( + ` const o${size.toFixed(0)} = i * ${(bytesPerElement / size).toFixed(0)};`); + } + + let argIndex = 0; + for (const member of members) { + for (let c = 0; c < member.components; c++) { + // The index for `member` component `c` into the appropriate type array is: + // this.{TYPE}[o{SIZE} + MEMBER_OFFSET + {c}] = v{X} + // where MEMBER_OFFSET = ROUND(member.offset / size) is the per-element + // offset of this member into the array + const index = `o${member.size.toFixed(0)} + ${(member.offset / member.size + c).toFixed(0)}`; + + output.push( + ` this.${member.view}[${index}] = v${argIndex++};`); + } + } + + output.push( + ` return i; + } +} + +${structArrayLayoutClass}.prototype.bytesPerElement = ${size}; +register('${structArrayLayoutClass}', ${structArrayLayoutClass}); +`); + + return output.join('\n'); +} + +function emitStructArray(locals) { + const output = []; + const { + arrayClass, + members, + size, + hasAnchorPoint, + layoutClass, + includeStructAccessors + } = locals; + + const structTypeClass = arrayClass.replace('Array', 'Struct'); + const structArrayClass = arrayClass; + const structArrayLayoutClass = layoutClass; + + // collect components + const components = []; + for (const member of members) { + for (let c = 0; c < member.components; c++) { + let name = member.name; + if (member.components > 1) { + name += c; + } + components.push({name, member, component: c}); + } + } + + // exceptions for which we generate accessors on the array rather than a separate struct for performance + const useComponentGetters = structArrayClass === 'GlyphOffsetArray' || structArrayClass === 'SymbolLineVertexArray'; + + if (includeStructAccessors && !useComponentGetters) { + output.push( + `/** @internal */ +class ${structTypeClass} extends Struct { + _structArray: ${structArrayClass};`); + + for (const {name, member, component} of components) { + const elementOffset = `this._pos${member.size.toFixed(0)}`; + const componentOffset = (member.offset / member.size + component).toFixed(0); + const index = `${elementOffset} + ${componentOffset}`; + const componentAccess = `this._structArray.${member.view}[${index}]`; + + output.push( + ` get ${name}() { return ${componentAccess}; }`); + + // generate setters for properties that are updated during runtime symbol placement; others are read-only + if (name === 'crossTileID' || name === 'placedOrientation' || name === 'hidden') { + output.push( + ` set ${name}(x: number) { ${componentAccess} = x; }`); + } + } + + // Special case used for the CollisionBoxArray type + if (hasAnchorPoint) { + output.push( + ' get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); }'); + } + + output.push( + `} + +${structTypeClass}.prototype.size = ${size}; + +export type ${structTypeClass.replace('Struct', '')} = ${structTypeClass}; +`); + } // end 'if (includeStructAccessors)' + + output.push( + `/** @internal */ +export class ${structArrayClass} extends ${structArrayLayoutClass} {`); + + if (useComponentGetters) { + for (const member of members) { + for (let c = 0; c < member.components; c++) { + if (!includeStructAccessors) continue; + let name = `get${member.name}`; + if (member.components > 1) { + name += c; + } + const componentOffset = (member.offset / member.size + c).toFixed(0); + const componentStride = size / member.size; + output.push( + ` ${name}(index: number) { return this.${member.view}[index * ${componentStride} + ${componentOffset}]; }`); + } + } + } else if (includeStructAccessors) { // get(i) + output.push( + ` /** + * Return the ${structTypeClass} at the given location in the array. + * @param index The index of the element. + */ + get(index: number): ${structTypeClass} { + return new ${structTypeClass}(this, index); + }`); + } + output.push( + `} + +register('${structArrayClass}', ${structArrayClass}); +`); + + return output.join('\n'); +} + +fs.writeFileSync('src/data/array_types.g.ts', + `// This file is generated. Edit build/generate-struct-arrays.ts, then run \`npm run codegen\`. + +import {Struct, StructArray} from '../util/struct_array'; +import {register} from '../util/web_worker_transfer'; +import Point from '@mapbox/point-geometry'; + +${layouts.map(emitStructArrayLayout).join('\n')} +${arraysWithStructAccessors.map(emitStructArray).join('\n')} +${[...arrayTypeEntries].join('\n')} +export { + ${layouts.map(layout => layout.className).join(',\n ')} +}; +`); diff --git a/web/libraries/maplibre-gl/build/generate-style-code.ts b/web/libraries/maplibre-gl/build/generate-style-code.ts new file mode 100644 index 00000000..a78fb416 --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-style-code.ts @@ -0,0 +1,284 @@ +'use strict'; + +import * as fs from 'fs'; + +import {v8} from '@maplibre/maplibre-gl-style-spec'; + +function camelCase(str: string): string { + return str.replace(/-(.)/g, (_, x) => { + return x.toUpperCase(); + }); +} + +function pascalCase(str: string): string { + const almostCamelized = camelCase(str); + return almostCamelized[0].toUpperCase() + almostCamelized.slice(1); +} + +function nativeType(property) { + switch (property.type) { + case 'boolean': + return 'boolean'; + case 'number': + return 'number'; + case 'string': + return 'string'; + case 'enum': + return Object.keys(property.values).map(v => JSON.stringify(v)).join(' | '); + case 'color': + return 'Color'; + case 'padding': + return 'Padding'; + case 'variableAnchorOffsetCollection': + return 'VariableAnchorOffsetCollection'; + case 'sprite': + return 'Sprite'; + case 'formatted': + return 'Formatted'; + case 'resolvedImage': + return 'ResolvedImage'; + case 'array': + if (property.length) { + return `[${new Array(property.length).fill(nativeType({type: property.value})).join(', ')}]`; + } else { + return `Array<${nativeType({type: property.value, values: property.values})}>`; + } + default: throw new Error(`unknown type "${property.type}" for "${property.name}"`); + } +} + +function possiblyEvaluatedType(property) { + const propType = nativeType(property); + + switch (property['property-type']) { + case 'color-ramp': + return 'ColorRampProperty'; + case 'cross-faded': + return `CrossFaded<${propType}>`; + case 'cross-faded-data-driven': + return `PossiblyEvaluatedPropertyValue>`; + case 'data-driven': + return `PossiblyEvaluatedPropertyValue<${propType}>`; + } + + return propType; +} + +function propertyType(property) { + switch (property['property-type']) { + case 'data-driven': + return `DataDrivenProperty<${nativeType(property)}>`; + case 'cross-faded': + return `CrossFadedProperty<${nativeType(property)}>`; + case 'cross-faded-data-driven': + return `CrossFadedDataDrivenProperty<${nativeType(property)}>`; + case 'color-ramp': + return 'ColorRampProperty'; + case 'data-constant': + case 'constant': + return `DataConstantProperty<${nativeType(property)}>`; + default: + throw new Error(`unknown property-type "${property['property-type']}" for ${property.name}`); + } +} + +function runtimeType(property) { + switch (property.type) { + case 'boolean': + return 'BooleanType'; + case 'number': + return 'NumberType'; + case 'string': + case 'enum': + return 'StringType'; + case 'color': + return 'ColorType'; + case 'padding': + return 'PaddingType'; + case 'variableAnchorOffsetCollection': + return 'VariableAnchorOffsetCollectionType'; + case 'sprite': + return 'SpriteType'; + case 'formatted': + return 'FormattedType'; + case 'Image': + return 'ImageType'; + case 'array': + if (property.length) { + return `array(${runtimeType({type: property.value})}, ${property.length})`; + } else { + return `array(${runtimeType({type: property.value})})`; + } + default: throw new Error(`unknown type "${property.type}" for "${property.name}"`); + } +} + +function overrides(property) { + return `{ runtimeType: ${runtimeType(property)}, getOverride: (o) => o.${camelCase(property.name)}, hasOverride: (o) => !!o.${camelCase(property.name)} }`; +} + +function propertyValue(property, type) { + const propertyAsSpec = `styleSpec["${type}_${property.layerType}"]["${property.name}"] as any as StylePropertySpecification`; + + switch (property['property-type']) { + case 'data-driven': + if (property.overridable) { + return `new DataDrivenProperty(${propertyAsSpec}, ${overrides(property)})`; + } else { + return `new DataDrivenProperty(${propertyAsSpec})`; + } + case 'cross-faded': + return `new CrossFadedProperty(${propertyAsSpec})`; + case 'cross-faded-data-driven': + return `new CrossFadedDataDrivenProperty(${propertyAsSpec})`; + case 'color-ramp': + return `new ColorRampProperty(${propertyAsSpec})`; + case 'data-constant': + case 'constant': + return `new DataConstantProperty(${propertyAsSpec})`; + default: + throw new Error(`unknown property-type "${property['property-type']}" for ${property.name}`); + } +} + +const layers = Object.keys(v8.layer.type.values).map((type) => { + const layoutProperties = Object.keys(v8[`layout_${type}`]).reduce((memo, name) => { + if (name !== 'visibility') { + v8[`layout_${type}`][name].name = name; + v8[`layout_${type}`][name].layerType = type; + memo.push(v8[`layout_${type}`][name]); + } + return memo; + }, []); + + const paintProperties = Object.keys(v8[`paint_${type}`]).reduce((memo, name) => { + v8[`paint_${type}`][name].name = name; + v8[`paint_${type}`][name].layerType = type; + memo.push(v8[`paint_${type}`][name]); + return memo; + }, []); + + return {type, layoutProperties, paintProperties}; +}); + +function emitlayerProperties(locals) { + const output = []; + const layerType = pascalCase(locals.type); + const { + layoutProperties, + paintProperties + } = locals; + + output.push( + `// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; +`); + + const overridables = paintProperties.filter(p => p.overridable); + if (overridables.length) { + const overridesArray = `import { + ${overridables.reduce((imports, prop) => { imports.push(runtimeType(prop)); return imports; }, []).join(',\n ')} + } from '@maplibre/maplibre-gl-style-spec'; + `; + console.log(overridesArray); + output.push(overridesArray); + } + + if (layoutProperties.length) { + output.push( + `export type ${layerType}LayoutProps = {`); + + for (const property of layoutProperties) { + output.push( + ` "${property.name}": ${propertyType(property)},`); + } + + output.push( + `}; + +export type ${layerType}LayoutPropsPossiblyEvaluated = {`); + + for (const property of layoutProperties) { + output.push( + ` "${property.name}": ${possiblyEvaluatedType(property)},`); + } + + output.push( + `}; + +let layout: Properties<${layerType}LayoutProps>; +const getLayout = () => layout = layout || new Properties({`); + + for (const property of layoutProperties) { + output.push( + ` "${property.name}": ${propertyValue(property, 'layout')},`); + } + + output.push( + '});'); + } + + if (paintProperties.length) { + output.push( + ` +export type ${layerType}PaintProps = {`); + + for (const property of paintProperties) { + output.push( + ` "${property.name}": ${propertyType(property)},`); + } + + output.push( + `}; + +export type ${layerType}PaintPropsPossiblyEvaluated = {`); + + for (const property of paintProperties) { + output.push( + ` "${property.name}": ${possiblyEvaluatedType(property)},`); + } + + output.push( + '};'); + } else { + output.push( + `export type ${layerType}PaintProps = {};`); + } + + output.push( + ` +let paint: Properties<${layerType}PaintProps>; +const getPaint = () => paint = paint || new Properties({`); + + for (const property of paintProperties) { + output.push( + ` "${property.name}": ${propertyValue(property, 'paint')},`); + } + + output.push( + `}); + +export default ({ get paint() { return getPaint() }${layoutProperties.length ? ', get layout() { return getLayout() }' : ''} });`); + + return output.join('\n'); +} + +for (const layer of layers) { + fs.writeFileSync(`src/style/style_layer/${layer.type.replace('-', '_')}_style_layer_properties.g.ts`, emitlayerProperties(layer)); +} diff --git a/web/libraries/maplibre-gl/build/generate-typings.ts b/web/libraries/maplibre-gl/build/generate-typings.ts new file mode 100644 index 00000000..737520d2 --- /dev/null +++ b/web/libraries/maplibre-gl/build/generate-typings.ts @@ -0,0 +1,18 @@ + +import fs from 'fs'; +import childProcess from 'child_process'; + +if (!fs.existsSync('dist')) { + fs.mkdirSync('dist'); +} + +console.log('Starting bundling types'); +const outputFile = './dist/maplibre-gl.d.ts'; +childProcess.execSync(`dts-bundle-generator --umd-module-name=maplibregl -o ${outputFile} ./src/index.ts`); +let types = fs.readFileSync(outputFile, 'utf8'); +// Classes are not exported but should be since this is exported as UMD - fixing... +types = types.replace(/declare class/g, 'export declare class'); +fs.writeFileSync(outputFile, types); + +console.log('Finished bundling types for MapLibre GL JS'); + diff --git a/web/libraries/maplibre-gl/build/readme.md b/web/libraries/maplibre-gl/build/readme.md new file mode 100644 index 00000000..ba673fa5 --- /dev/null +++ b/web/libraries/maplibre-gl/build/readme.md @@ -0,0 +1,47 @@ +# Build Scripts +This folder holds common build scripts accessed via the various `npm run` commands. +Codegen is executed when calling `npm install` in order to generate all artifacts needed for the build to pass +## Bundeling all the code + +The bundeling process can be split into several steps: + +`npm run build-css` +This command will compile the css code and create the css file. + +`npm run build-prod` and `npm run build-dev` +These commands will use rollup to bundle the code. This is where the magic happens and uses some files in this folder. + +`banner.ts` is used to create a banner at the beginning of the output file + +`rollup_plugins.ts` is used to define common plugins for rollup configurations + +`rollup_plugin_minify_style_spec.ts` is used to specify the plugin used in style spec bundeling + +In the `rollup` folder there are some files that are used as linking files as they link to other files for rollup to pick when bundling. + +Rollup is generating 3 files throughout the process of bundling: + +`index.ts` a file containing all the code that will run in the main thread. + +`shared.ts` a file containing all the code shared between the main and worker code. + +`worker.ts` a file containing all the code the will run in the worker threads. + +These 3 files are then referenced and used by the `bundle_prelude.js` file. It allows loading the web wroker code automatically in web workers without any extra effort from someone who would like to use the library, i.e. it simply works. + +
+ +### `npm run codegen` +The `codegen` command runs the following three scripts, to update the corresponding code files based on the `v8.json` style source, and other data files. Contributors should run this command manually when the underlying style data is modified. The generated code files are then committed to the repo. +#### generate-struct-arrays.ts +Generates `data/array_types.ts`, which consists of: + - `StructArrayLayout_*` subclasses, one for each underlying memory layout + - Named exports mapping each conceptual array type (e.g., `CircleLayoutArray`) to its corresponding `StructArrayLayout` class + - Specific named `StructArray` subclasses, when type-specific struct accessors are needed (e.g., `CollisionBoxArray`) +#### generate-style-code.ts +Generates the various `style/style_layer/[layer type]_style_layer_properties.ts` code files based on the content of `v8.json`. These files provide the type signatures for the paint and layout properties for each type of style layer. +
+ +### Generate Release Nodes + +`release-notes.js` Used to generate release notes when releasing a new version \ No newline at end of file diff --git a/web/libraries/maplibre-gl/build/release-notes.js b/web/libraries/maplibre-gl/build/release-notes.js new file mode 100755 index 00000000..35c3edfb --- /dev/null +++ b/web/libraries/maplibre-gl/build/release-notes.js @@ -0,0 +1,45 @@ +#!/usr/bin/env node + +import * as fs from 'fs'; +import semver from 'semver'; + +const changelogPath = 'CHANGELOG.md'; +const changelog = fs.readFileSync(changelogPath, 'utf8'); + +/* + Parse the raw changelog text and split it into individual releases. + + This regular expression: + - Matches lines starting with "## x.x.x". + - Groups the version number. + - Skips the (optional) release date. + - Groups the changelog content. + - Ends when another "## x.x.x" is found. +*/ +const regex = /^## (\d+\.\d+\.\d+.*?)\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms; + +let releaseNotes = []; +let match; +// eslint-disable-next-line no-cond-assign +while (match = regex.exec(changelog)) { + releaseNotes.push({ + 'version': match[1], + 'changelog': match[2].trim(), + }); +} + +const latest = releaseNotes[0]; +const previous = releaseNotes[1]; + + +// Print the release notes template. + +const templatedReleaseNotes = `https://github.com/maplibre/maplibre-gl-js +[Changes](https://github.com/maplibre/maplibre-gl-js/compare/v${previous.version}...v${latest.version}) since [MapLibre GL JS v${previous.version}](https://github.com/maplibre/releases/tag/v${previous.version}): + +${latest.changelog} + +${semver.prerelease(latest.version) ? 'Pre-release version' : ''}`; + +// eslint-disable-next-line eol-last +process.stdout.write(templatedReleaseNotes.trimEnd()); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/build/rollup/bundle_prelude.js b/web/libraries/maplibre-gl/build/rollup/bundle_prelude.js new file mode 100644 index 00000000..715ecb53 --- /dev/null +++ b/web/libraries/maplibre-gl/build/rollup/bundle_prelude.js @@ -0,0 +1,21 @@ +/* eslint-disable */ + +var shared, worker, maplibregl; +// define gets called three times: one for each chunk. we rely on the order +// they're imported to know which is which +function define(_, chunk) { + if (!shared) { + shared = chunk; + } else if (!worker) { + worker = chunk; + } else { + var workerBundleString = 'var sharedChunk = {}; (' + shared + ')(sharedChunk); (' + worker + ')(sharedChunk);' + + var sharedChunk = {}; + shared(sharedChunk); + maplibregl = chunk(sharedChunk); + if (typeof window !== 'undefined') { + maplibregl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); + } + } +} diff --git a/web/libraries/maplibre-gl/build/rollup/maplibregl.js b/web/libraries/maplibre-gl/build/rollup/maplibregl.js new file mode 100644 index 00000000..b5913a83 --- /dev/null +++ b/web/libraries/maplibre-gl/build/rollup/maplibregl.js @@ -0,0 +1,47 @@ +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + +// The three "chunks" imported here are produced by a first Rollup pass, +// which outputs them as AMD modules. + +// Shared dependencies, i.e.: +/* +define(['exports'], function (exports) { + // Code for all common dependencies + // Each module's exports are attached attached to 'exports' (with + // names rewritten to avoid collisions, etc.) +}) +*/ +import '../../staging/maplibregl/shared'; + +// Worker and its unique dependencies, i.e.: +/* +define(['./shared.js'], function (__shared__js) { + // Code for worker script and its unique dependencies. + // Expects the output of 'shared' module to be passed in as an argument, + // since all references to common deps look like, e.g., + // __shared__js.shapeText(). +}); +*/ +// When this wrapper function is passed to our custom define() above, +// it gets stringified, together with the shared wrapper (using +// Function.toString()), and the resulting string of code is made into a +// Blob URL that gets used by the main module to create the web workers. +import '../../staging/maplibregl/worker'; + +// Main module and its unique dependencies +/* +define(['./shared.js'], function (__shared__js) { + // Code for main GL JS module and its unique dependencies. + // Expects the output of 'shared' module to be passed in as an argument, + // since all references to common deps look like, e.g., + // __shared__js.shapeText(). + // + // Returns the actual maplibregl (i.e. src/index.js) +}); +*/ +import '../../staging/maplibregl/index'; + +export default maplibregl; diff --git a/web/libraries/maplibre-gl/build/rollup_plugins.ts b/web/libraries/maplibre-gl/build/rollup_plugins.ts new file mode 100644 index 00000000..6221e023 --- /dev/null +++ b/web/libraries/maplibre-gl/build/rollup_plugins.ts @@ -0,0 +1,58 @@ + +import typescript from '@rollup/plugin-typescript'; +import resolve from '@rollup/plugin-node-resolve'; +import replace from '@rollup/plugin-replace'; +import commonjs from '@rollup/plugin-commonjs'; +import terser from '@rollup/plugin-terser'; +import strip from '@rollup/plugin-strip'; +import {Plugin} from 'rollup'; +import json from '@rollup/plugin-json'; + +// Common set of plugins/transformations shared across different rollup +// builds (main maplibre bundle, style-spec package, benchmarks bundle) + +export const nodeResolve = resolve({ + browser: true, + preferBuiltins: false +}); + +export const plugins = (production: boolean): Plugin[] => [ + json(), + // https://github.com/zaach/jison/issues/351 + replace({ + preventAssignment: true, + include: /\/jsonlint-lines-primitives\/lib\/jsonlint.js/, + delimiters: ['', ''], + values: { + '_token_stack:': '' + } + }), + production && strip({ + sourceMap: true, + functions: ['PerformanceUtils.*', 'Debug.*'] + }), + production && terser({ + compress: { + // eslint-disable-next-line camelcase + pure_getters: true, + passes: 3 + }, + sourceMap: true + }), + nodeResolve, + typescript(), + commonjs({ + // global keyword handling causes Webpack compatibility issues, so we disabled it: + // https://github.com/mapbox/mapbox-gl-js/pull/6956 + ignoreGlobal: true + }) +].filter(Boolean); + +export const watchStagingPlugin: Plugin = { + name: 'watch-external', + buildStart() { + this.addWatchFile('staging/maplibregl/index.js'); + this.addWatchFile('staging/maplibregl/shared.js'); + this.addWatchFile('staging/maplibregl/worker.js'); + } +}; diff --git a/web/libraries/maplibre-gl/dist/LICENSE.txt b/web/libraries/maplibre-gl/dist/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/web/libraries/maplibre-gl/dist/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl-csp-worker.js b/web/libraries/maplibre-gl/dist/maplibre-gl-csp-worker.js new file mode 100644 index 00000000..0dc3598f --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl-csp-worker.js @@ -0,0 +1,2 @@ +var maplibregl=function(){"use strict";function t(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function o(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,o)}l((n=n.apply(t,e||[])).next())}))}function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var r=n;function n(t,e){this.x=t,this.y=e}n.prototype={clone:function(){return new n(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(t){return t instanceof n?t:Array.isArray(t)?new n(t[0],t[1]):t};var i=e(r),s=a;function a(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n}a.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var o=e(s);let l,u;function c(t,e,r){return Math.min(r,Math.max(e,t))}function h(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}function p(t,e,r){const n={};for(const i in t)n[i]=e.call(r||this,t[i],i,t);return n}function f(t){return Array.isArray(t)?t.map(f):"object"==typeof t&&t?p(t,f):t}new o(.25,.1,.25,1);const d={};function y(t){d[t]||("undefined"!=typeof console&&console.warn(t),d[t]=!0)}function m(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function g(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const k=["type","source","source-layer","minzoom","maxzoom","filter","layout"];class A{constructor(t,e,r,n){this.message=(t?`${t}: `:"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function I(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class z extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class M{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r}concat(t){return new M(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const P={kind:"null"},C={kind:"number"},B={kind:"string"},V={kind:"boolean"},E={kind:"color"},F={kind:"object"},T={kind:"value"},D={kind:"collator"},$={kind:"formatted"},L={kind:"padding"},O={kind:"resolvedImage"},U={kind:"variableAnchorOffsetCollection"};function q(t,e){return{kind:"array",itemType:t,N:e}}function j(t){if("array"===t.kind){const e=j(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const R=[P,C,B,V,E,$,F,q(T),L,O,U];function N(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!N(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of R)if(!N(t,e))return null}return`Expected ${j(t)} but found ${j(e)} instead.`}function Z(t,e){return e.some((e=>e.kind===t.kind))}function G(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function J(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const K=.96422,X=.82521,Y=4/29,H=6/29,W=3*H*H,Q=H*H*H,tt=Math.PI/180,et=180/Math.PI;function rt(t){return(t%=360)<0&&(t+=360),t}function nt([t,e,r,n]){let i,s;const a=st((.2225045*(t=it(t))+.7168786*(e=it(e))+.0606169*(r=it(r)))/1);t===e&&e===r?i=s=a:(i=st((.4360747*t+.3850649*e+.1430804*r)/K),s=st((.0139322*t+.0971045*e+.7141733*r)/X));const o=116*a-16;return[o<0?0:o,500*(i-a),200*(a-s),n]}function it(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function st(t){return t>Q?Math.pow(t,1/3):t/W+Y}function at([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*lt(i),s=K*lt(s),a=X*lt(a),[ot(3.1338561*s-1.6168667*i-.4906146*a),ot(-.9787684*s+1.9161415*i+.033454*a),ot(.0719453*s-.2289914*i+1.4052427*a),n]}function ot(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function lt(t){return t>H?t*t*t:W*(t-Y)}function ut(t){return parseInt(t.padEnd(2,t),16)/255}function ct(t,e){return ht(e?t/100:t,0,1)}function ht(t,e,r){return Math.min(Math.max(e,t),r)}function pt(t){return!t.some(Number.isNaN)}const ft={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class dt{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]))}static parse(t){if(t instanceof dt)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=ft[t];if(e){const[t,r,n]=e;return[t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return[ut(t.slice(r,r+=e)),ut(t.slice(r,r+=e)),ut(t.slice(r,r+=e)),ut(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[ht(+r/e,0,1),ht(+s/e,0,1),ht(+l/e,0,1),h?ct(+h,p):1];if(pt(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,ht(+i,0,100),ht(+a,0,100),l?ct(+l,u):1];if(pt(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=rt(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new dt(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=nt(t),s=Math.sqrt(r*r+n*n);return[Math.round(1e4*s)?rt(Math.atan2(n,r)*et):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",nt(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return`rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}}dt.black=new dt(0,0,0,1),dt.white=new dt(1,1,1,1),dt.transparent=new dt(0,0,0,0),dt.red=new dt(1,0,0,1);class yt{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class mt{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i}}class gt{constructor(t){this.sections=t}static fromString(t){return new gt([new mt(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof gt?t:gt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class xt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof xt)return t;if("number"==typeof t)return new xt([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new xt(t)}}toString(){return JSON.stringify(this.values)}}const vt=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class bt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof bt)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function St(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof dt||t instanceof yt||t instanceof gt||t instanceof xt||t instanceof bt||t instanceof wt)return!0;if(Array.isArray(t)){for(const e of t)if(!St(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!St(t[e]))return!1;return!0}return!1}function kt(t){if(null===t)return P;if("string"==typeof t)return B;if("boolean"==typeof t)return V;if("number"==typeof t)return C;if(t instanceof dt)return E;if(t instanceof yt)return D;if(t instanceof gt)return $;if(t instanceof xt)return L;if(t instanceof bt)return U;if(t instanceof wt)return O;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=kt(e);if(r){if(r===t)continue;r=T;break}r=t}return q(r||T,e)}return F}function At(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof dt||t instanceof gt||t instanceof xt||t instanceof bt||t instanceof wt?t.toString():JSON.stringify(t)}class It{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!St(t[1]))return e.error("invalid value");const r=t[1];let n=kt(r);const i=e.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new It(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class zt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const Mt={string:B,number:C,boolean:V,object:F};class Pt{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Mt)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Mt[r],n++}else i=T;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++}r=q(i,s)}else{if(!Mt[i])throw new Error(`Types doesn't contain name = ${i}`);r=Mt[i]}const s=[];for(;nt.outputDefined()))}}const Ct={"to-boolean":V,"to-color":E,"to-number":C,"to-string":B};class Bt{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!Ct[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=Ct[r],i=[];for(let r=1;r4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:_t(e[0],e[1],e[2],e[3]),!r))return new dt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new zt(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=xt.parse(e);if(n)return n}throw new zt(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=bt.parse(e);if(n)return n}throw new zt(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new zt(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return gt.fromString(At(this.args[0].evaluate(t)));case"resolvedImage":return wt.fromString(At(this.args[0].evaluate(t)));default:return At(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Vt=["Unknown","Point","LineString","Polygon"];class Et{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Vt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=dt.parse(t)),e}}class Ft{constructor(t,e,r=[],n,i=new M,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return"assert"===r?new Pt(e,[t]):"coerce"===r?new Bt(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert")}if(!(n instanceof It)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Et;try{n=new It(n.type,n.evaluate(t))}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Ft(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new z(r,t))}checkSubtype(t,e){const r=N(t,e);return r&&this.error(r),r}}class Tt{constructor(t,e,r){this.type=D,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,V);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,V);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,B),!s)?null:new Tt(n,i,s)}evaluate(t){return new yt(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}const Dt=8192;function $t(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Lt(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Ot(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(r*i*Dt),Math.round(n*i*Dt)]}function Ut(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function qt(t,e){let r=!1;for(let a=0,o=e.length;a(n=t)[1]!=(s=o[e+1])[1]>n[1]&&n[0]<(s[0]-i[0])*(n[1]-i[1])/(s[1]-i[1])+i[0]&&(r=!r)}}var n,i,s;return r}function jt(t,e){for(let r=0;r0&&o<0||a<0&&o>0}function Nt(t,e,r){for(const u of r)for(let r=0;rr[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i}$t(e,t)}function Yt(t,e,r,n){const i=Math.pow(2,n.z)*Dt,s=[n.x*Dt,n.y*Dt],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Xt(n,e,r,i),a.push(n)}return a}function Ht(t,e,r,n){const i=Math.pow(2,n.z)*Dt,s=[n.x*Dt,n.y*Dt],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];$t(e,r),t.push(r)}a.push(t)}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Xt(n,e,r,i)}var o;return a}class Wt{constructor(t,e){this.type=V,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(St(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new Ft(e.registry,ee,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(j).join(", ")})`:`(${j(e.type)}...)`;var e})).join(" | "),n=[];for(let r=1;r{r=e?r&&ee(t):r&&t instanceof It})),!!r&&re(t)&&ie(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function re(t){if(t instanceof te){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Wt)return!1;let e=!0;return t.eachChild((t=>{e&&!re(t)&&(e=!1)})),e}function ne(t){if(t instanceof te&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!ne(t)&&(e=!1)})),e}function ie(t,e){if(t instanceof te&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild((t=>{r&&!ie(t,e)&&(r=!1)})),r}function se(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new zt("Input is not a number.");a=o-1}return 0}class ae{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,C);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u])}return new ae(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[se(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function oe(t,e,r){return t+r*(e-t)}function le(t,e,r){return t.map(((t,n)=>oe(t,e[n],r)))}const ue={number:oe,color:function(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,s,a]=le(t.rgb,e.rgb,r);return new dt(n,i,s,a,!1)}case"hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else{let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*tt,at([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:oe(i,l,r),oe(s,u,r),oe(a,c,r)]);return new dt(f,d,y,m,!1)}case"lab":{const[n,i,s,a]=at(le(t.lab,e.lab,r));return new dt(n,i,s,a,!1)}}},array:le,padding:function(t,e,r){return new xt(le(t.values,e.values,r))},variableAnchorOffsetCollection:function(t,e,r){const n=t.values,i=e.values;if(n.length!==i.length)throw new zt(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const s=[];for(let t=0;t"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,C),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=E:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u])}return J(o,C)||J(o,E)||J(o,L)||J(o,U)||J(o,q(C))?new ce(o,r,n,i,a):e.error(`Type ${j(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=se(e,n),a=ce.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case"interpolate":return ue[this.type.kind](o,l,a);case"interpolate-hcl":return ue.color(o,l,a,"hcl");case"interpolate-lab":return ue.color(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function he(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}class pe{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t)}if(!r)throw new Error("No output type");const s=n&&i.some((t=>N(n,t.type)));return new pe(s?T:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof wt&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}class fe{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new zt(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new zt(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ye{constructor(t,e){this.type=V,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,T),n=e.parse(t[2],2,T);return r&&n?Z(r.type,[V,B,C,P,T])?new ye(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${j(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!G(e,["boolean","string","number","null"]))throw new zt(`Expected first argument to be of type boolean, string, number or null, but found ${j(kt(e))} instead.`);if(!G(r,["string","array"]))throw new zt(`Expected second argument to be of type array or string, but found ${j(kt(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class me{constructor(t,e,r){this.type=C,this.needle=t,this.haystack=e,this.fromIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,T),n=e.parse(t[2],2,T);if(!r||!n)return null;if(!Z(r.type,[V,B,C,P,T]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${j(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,C);return i?new me(r,n,i):null}return new me(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!G(e,["boolean","string","number","null"]))throw new zt(`Expected first argument to be of type boolean, string, number or null, but found ${j(kt(e))} instead.`);if(!G(r,["string","array"]))throw new zt(`Expected second argument to be of type array or string, but found ${j(kt(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class ge{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,kt(t)))return null}else r=kt(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c)}const a=e.parse(t[1],1,T);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new ge(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return(kt(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class xe{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class ve{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,T),n=e.parse(t[2],2,C);if(!r||!n)return null;if(!Z(r.type,[q(T),B,T]))return e.error(`Expected first argument to be of type array or string, but found ${j(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,C);return i?new ve(r.type,r,n,i):null}return new ve(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!G(e,["string","array"]))throw new zt(`Expected first argument to be of type array or string, but found ${j(kt(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function be(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function we(t,e,r,n){return 0===n.compare(e,r)}function _e(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=V,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,T);if(!s)return null;if(!be(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${j(s.type)}'.`);let a=e.parse(t[2],2,T);if(!a)return null;if(!be(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${j(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${j(s.type)}' and '${j(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Pt(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Pt(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,D),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=kt(s),r=kt(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new zt(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=kt(s),r=kt(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const Se=_e("==",(function(t,e,r){return e===r}),we),ke=_e("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return!we(0,e,r,n)})),Ae=_e("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),ze=_e("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Me=_e(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Pe{constructor(t,e,r,n,i){this.type=B,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,C);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,B),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,B),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,C),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,C),!o)?null:new Pe(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ce{constructor(t){this.type=$,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,C),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,q(B)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,E),!a))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=a}else{const s=e.parse(t[r],1,T);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null})}}return new Ce(n)}evaluate(t){return new gt(this.sections.map((e=>{const r=e.content.evaluate(t);return kt(r)===O?new mt("",r,null,null,null):new mt(At(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}}class Be{constructor(t){this.type=O,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,B);return r?new Be(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=wt.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}}class Ve{constructor(t){this.type=C,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${j(r.type)} instead.`):new Ve(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new zt(`Expected value to be of type string or array, but found ${j(kt(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Ee={"==":Se,"!=":ke,">":Ie,"<":Ae,">=":Me,"<=":ze,array:Pt,at:de,boolean:Pt,case:xe,coalesce:pe,collator:Tt,format:Ce,image:Be,in:ye,"index-of":me,interpolate:ce,"interpolate-hcl":ce,"interpolate-lab":ce,length:Ve,let:fe,literal:It,match:ge,number:Pt,"number-format":Pe,object:Pt,slice:ve,step:ae,string:Pt,"to-boolean":Bt,"to-color":Bt,"to-number":Bt,"to-string":Bt,var:Qt,within:Wt};function Fe(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const s=i?i.evaluate(t):1,a=_t(e,r,n,s);if(a)throw new zt(a);return new dt(e/255,r/255,n/255,s,!1)}function Te(t,e){return t in e}function De(t,e){const r=e[t];return void 0===r?null:r}function $e(t){return{type:t}}function Le(t){return{result:"success",value:t}}function Oe(t){return{result:"error",value:t}}function Ue(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function qe(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function je(t){return!!t.expression&&t.expression.interpolated}function Re(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Ne(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ze(t){return t}function Ge(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(je(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?dt.parse:xt.parse;(t=I({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,u;if("exponential"===s)o=Ye;else if("interval"===s)o=Xe;else if("categorical"===s){o=Ke,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0]}else{if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=He}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Ye({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:ce.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return{kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Je(t.default,e.default):o(t,e,i,l,u)}}}function Je(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Ke(t,e,r,n,i){return Je(typeof r===i?n[r]:void 0,t.default,e.default)}function Xe(t,e,r){if("number"!==Re(r))return Je(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=se(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Ye(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Re(r))return Je(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=se(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=ue[e.type]||Ze;return"function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function He(t,e,r){switch(e.type){case"color":r=dt.parse(r);break;case"formatted":r=gt.fromString(r.toString());break;case"resolvedImage":r=wt.fromString(r.toString());break;case"padding":r=xt.parse(r);break;default:Re(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0)}return Je(r,t.default,e.default)}te.register(Ee,{error:[{kind:"error"},[B],(t,[e])=>{throw new zt(e.evaluate(t))}],typeof:[B,[T],(t,[e])=>j(kt(e.evaluate(t)))],"to-rgba":[q(C,4),[E],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return[255*r,255*n,255*i,s]}],rgb:[E,[C,C,C],Fe],rgba:[E,[C,C,C,C],Fe],has:{type:V,overloads:[[[B],(t,[e])=>Te(e.evaluate(t),t.properties())],[[B,F],(t,[e,r])=>Te(e.evaluate(t),r.evaluate(t))]]},get:{type:T,overloads:[[[B],(t,[e])=>De(e.evaluate(t),t.properties())],[[B,F],(t,[e,r])=>De(e.evaluate(t),r.evaluate(t))]]},"feature-state":[T,[B],(t,[e])=>De(e.evaluate(t),t.featureState||{})],properties:[F,[],t=>t.properties()],"geometry-type":[B,[],t=>t.geometryType()],id:[T,[],t=>t.id()],zoom:[C,[],t=>t.globals.zoom],"heatmap-density":[C,[],t=>t.globals.heatmapDensity||0],"line-progress":[C,[],t=>t.globals.lineProgress||0],accumulated:[T,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[C,$e(C),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[C,$e(C),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:C,overloads:[[[C,C],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[C],(t,[e])=>-e.evaluate(t)]]},"/":[C,[C,C],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[C,[C,C],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[C,[],()=>Math.LN2],pi:[C,[],()=>Math.PI],e:[C,[],()=>Math.E],"^":[C,[C,C],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[C,[C],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[C,[C],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[C,[C],(t,[e])=>Math.log(e.evaluate(t))],log2:[C,[C],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[C,[C],(t,[e])=>Math.sin(e.evaluate(t))],cos:[C,[C],(t,[e])=>Math.cos(e.evaluate(t))],tan:[C,[C],(t,[e])=>Math.tan(e.evaluate(t))],asin:[C,[C],(t,[e])=>Math.asin(e.evaluate(t))],acos:[C,[C],(t,[e])=>Math.acos(e.evaluate(t))],atan:[C,[C],(t,[e])=>Math.atan(e.evaluate(t))],min:[C,$e(C),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[C,$e(C),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[C,[C],(t,[e])=>Math.abs(e.evaluate(t))],round:[C,[C],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[C,[C],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[C,[C],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[V,[B,T],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[V,[T],(t,[e])=>t.id()===e.value],"filter-type-==":[V,[B],(t,[e])=>t.geometryType()===e.value],"filter-<":[V,[B,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[V,[B,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[V,[T],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[V,[B,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[V,[T],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[V,[B,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[V,[T],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[V,[T],(t,[e])=>e.value in t.properties()],"filter-has-id":[V,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[V,[q(B)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[V,[q(T)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[V,[B,q(T)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[V,[B,q(T)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:V,overloads:[[[V,V],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[$e(V),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:V,overloads:[[[V,V],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[$e(V),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[V,[V],(t,[e])=>!e.evaluate(t)],"is-supported-script":[V,[B],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[B,[B],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[B,[B],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[B,$e(T),(t,e)=>e.map((e=>At(e.evaluate(t)))).join("")],"resolved-locale":[B,[D],(t,[e])=>e.evaluate(t).resolvedLocale()]});class We{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new Et,this._defaultValue=e?"color"===(r=e).type&&Ne(r.default)?new dt(0,0,0,0):"color"===r.type?dt.parse(r.default)||null:"padding"===r.type?xt.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?bt.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new zt(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Qe(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Ee}function tr(t,e){const r=new Ft(Ee,ee,[],e?function(t){const e={color:E,string:B,number:C,enum:B,boolean:V,formatted:$,padding:L,resolvedImage:O,variableAnchorOffsetCollection:U};return"array"===t.type?q(e[t.value]||T,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Le(new We(n,e)):Oe(r.errors)}class er{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!ne(e.expression)}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class rr{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!ne(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?ce.interpolationFactor(this.interpolationType,t,e,r):0}}function nr(t,e){const r=tr(t,e);if("error"===r.result)return r;const n=r.value.expression,i=re(n);if(!i&&!Ue(e))return Oe([new z("","data expressions not supported")]);const s=ie(n,["zoom"]);if(!s&&!qe(e))return Oe([new z("","zoom expressions not supported")]);const a=sr(n);return a||s?a instanceof z?Oe([a]):a instanceof ce&&!je(e)?Oe([new z("",'"interpolate" expressions cannot be used with this property')]):Le(a?new rr(i?"camera":"composite",r.value,a.labels,a instanceof ce?a.interpolation:void 0):new er(i?"constant":"source",r.value)):Oe([new z("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ir{constructor(t,e){this._parameters=t,this._specification=e,I(this,Ge(this._parameters,this._specification))}static deserialize(t){return new ir(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function sr(t){let e=null;if(t instanceof fe)e=sr(t.result);else if(t instanceof pe){for(const r of t.args)if(e=sr(r),e)break}else(t instanceof ae||t instanceof ce)&&t.input instanceof te&&"zoom"===t.input.name&&(e=t);return e instanceof z||t.eachChild((t=>{const r=sr(t);r instanceof z?e=r:!e&&r?e=new z("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new z("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function ar(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!ar(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const or={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function lr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};ar(t)||(t=hr(t));const e=tr(t,or);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:cr(t)}}function ur(t,e){return te?1:0}function cr(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?pr(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(hr))):"all"===e?["all"].concat(t.slice(1).map(hr)):"none"===e?["all"].concat(t.slice(1).map(hr).map(yr)):"in"===e?fr(t[1],t.slice(2)):"!in"===e?yr(fr(t[1],t.slice(2))):"has"===e?dr(t[1]):"!has"===e?yr(dr(t[1])):"within"!==e||t;var r}function pr(t,e,r){switch(t){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,t,e]}}function fr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ur)]]:["filter-in-small",t,["literal",e]]}}function dr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function yr(t){return["!",t]}function mr(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${mr(r)},`;return`${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new A(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function kr(t){const e=t.valueSpec,r=vr(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===Re(t.value.stops)&&"array"===Re(t.value.stops[0])&&"object"===Re(t.value.stops[0][0]),c=wr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return[new A(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(_r({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Re(n)&&0===n.length&&e.push(new A(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===r&&o&&c.push(new A(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new A(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!je(t.valueSpec)&&c.push(new A(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Ue(t.valueSpec)?c.push(new A(t.key,t.value,"property functions not supported")):o&&!qe(t.valueSpec)&&c.push(new A(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new A(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==Re(n))return[new A(o,n,`array expected, ${Re(n)} found`)];if(2!==n.length)return[new A(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Re(n[0]))return[new A(o,n,`object expected, ${Re(n[0])} found`)];if(void 0===n[0].zoom)return[new A(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new A(o,n,"object stop key must have value")];if(s&&s>vr(n[0].zoom))return[new A(o,n[0].zoom,"stop zoom values must appear in ascending order")];vr(n[0].zoom)!==s&&(s=vr(n[0].zoom),i=void 0,a={}),r=r.concat(wr({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Sr,value:p}}))}else r=r.concat(p({key:`${o}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return Qe(br(n[1]))?r.concat([new A(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=Re(t.value),l=vr(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return[new A(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return[new A(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return Ue(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new A(t.key,u,n)]}return"categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew A(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new A(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!ne(r))return[new A(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!ne(r))return[new A(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!ie(r,["zoom","feature-state"]))return[new A(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!re(r))return[new A(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ir(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(vr(r))&&i.push(new A(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(vr(r))&&i.push(new A(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function zr(t){return ar(br(t.value))?Ar(I({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Mr(t)}function Mr(t){const e=t.value,r=t.key;if("array"!==Re(e))return[new A(r,e,`array expected, ${Re(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return[new A(r,e,"filter array must have at least 1 element")];switch(s=s.concat(Ir({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),vr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===vr(e[1])&&s.push(new A(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new A(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=Re(e[1]),"string"!==i&&s.push(new A(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new A(n,r[t],`"${t}" is prohibited for ref layers`))})),i.layers.forEach((e=>{vr(e.id)===o&&(t=e)})),t?t.ref?e.push(new A(n,r.ref,"ref cannot reference another ref layer")):a=vr(t.type):e.push(new A(n,r.ref,`ref layer "${o}" not found`))}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&vr(t.type);t?"vector"===s&&"raster"===a?e.push(new A(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new A(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new A(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new A(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new A(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new A(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new A(n,r.source,`source "${r.source}" not found`))}else e.push(new A(n,r,'missing required property "source"'));return e=e.concat(wr({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:zr,layout:t=>wr({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Br(I({layerType:a},t))}}),paint:t=>wr({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Cr(I({layerType:a},t))}})}})),e}function Er(t){const e=t.value,r=t.key,n=Re(e);return"string"!==n?[new A(r,e,`string expected, ${n} found`)]:[]}const Fr={promoteId:function({key:t,value:e}){if("string"===Re(e))return Er({key:t,value:e});{const r=[];for(const n in e)r.push(...Er({key:`${t}.${n}`,value:e[n]}));return r}}};function Tr(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return[new A(r,e,'"type" is required')];const a=vr(e.type);let o;switch(a){case"vector":case"raster":return o=wr({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Fr,validateSpec:s}),o;case"raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=Re(n);if(void 0===n)return o;if("object"!==l)return o.push(new A("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===vr(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new A(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new A(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case"geojson":if(o=wr({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:Fr}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],a="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...Ar({key:`${r}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),o.push(...Ar({key:`${r}.${t}.reduce`,value:a,validateSpec:s,expressionContext:"cluster-reduce"}))}return o;case"video":return wr({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case"image":return wr({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case"canvas":return[new A(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ir({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:n})}}function Dr(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=Re(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new A("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new A(a,e[a],`unknown property "${a}"`)])}return s}function $r(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=Re(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new A("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new A(a,e[a],`unknown property "${a}"`)]);return s}function Lr(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new A(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new A(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(wr({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Er({key:n,value:r})}const Or={"*":()=>[],array:_r,boolean:function(t){const e=t.value,r=t.key,n=Re(e);return"boolean"!==n?[new A(r,e,`boolean expected, ${n} found`)]:[]},number:Sr,color:function(t){const e=t.key,r=t.value,n=Re(r);return"string"!==n?[new A(e,r,`color expected, ${n} found`)]:dt.parse(String(r))?[]:[new A(e,r,`color expected, "${r}" found`)]},constants:xr,enum:Ir,filter:zr,function:kr,layer:Vr,object:wr,source:Tr,light:Dr,terrain:$r,string:Er,formatted:function(t){return 0===Er(t).length?[]:Ar(t)},resolvedImage:function(t){return 0===Er(t).length?[]:Ar(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Re(r)){if(r.length<1||r.length>4)return[new A(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(xr({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:Ur}))),Nr(r)}function Rr(t){return function(e){return t({...e,validateSpec:Ur})}}function Nr(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Zr(t){return function(...e){return Nr(t.apply(this,e))}}jr.source=Zr(Rr(Tr)),jr.sprite=Zr(Rr(Lr)),jr.glyphs=Zr(Rr(qr)),jr.light=Zr(Rr(Dr)),jr.terrain=Zr(Rr($r)),jr.layer=Zr(Rr(Vr)),jr.filter=Zr(Rr(zr)),jr.paintProperty=Zr(Rr(Cr)),jr.layoutProperty=Zr(Rr(Br));const Gr={};class Jr extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n}}const Kr=x()?()=>self.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href;function Xr(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:Kr(),signal:r.signal});let i=!1,s=!1;"json"===t.type&&n.headers.set("Accept","application/json");return s||fetch(n).then((r=>r.ok?(r=>{("arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{s||(i=!0,e(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((t=>{s||e(new Error(t.message))}))})(r):r.blob().then((n=>e(new Jr(r.status,r.statusText,t.url,n)))))).catch((t=>{20!==t.code&&e(new Error(t.message))})),{cancel:()=>{s=!0,i||r.abort()}}}const Yr=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(x()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!x())return(Gr[(r=t.url).substring(0,r.indexOf("://"))]||Xr)(t,e)}var r;if(!(t=>/^file:/.test(t)||/^file:/.test(Kr())&&!/^\w+:/.test(t))(t.url)){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return Xr(t,e);if(x()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===t.type)try{n=JSON.parse(r.response)}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else{const n=new Blob([r.response],{type:r.getResponseHeader("Content-Type")});e(new Jr(r.status,r.statusText,t.url,n))}},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},Hr={};function Wr(t,e,r={}){if(Hr[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Hr[t]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}Wr("Object",Object),Wr("TransferableGridIndex",_),Wr("Color",dt),Wr("Error",Error),Wr("AJAXError",Jr),Wr("ResolvedImage",wt),Wr("StylePropertyFunction",ir),Wr("StyleExpression",We,{omit:["_evaluator"]}),Wr("ZoomDependentExpression",rr),Wr("ZoomConstantExpression",er),Wr("CompoundExpression",te,{omit:["_evaluate"]});for(const t in Ee)Ee[t]._classRegistryKey||Wr(`Expression_${t}`,Ee[t]);function Qr(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function tn(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob)return t;if(Qr(t))return e&&e.push(t),t;if(v(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const r=t;return e&&e.push(r.buffer),r}if(t instanceof ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const n of t)r.push(tn(n,e));return r}if("object"==typeof t){const r=t.constructor,n=r._classRegistryKey;if(!n)throw new Error("can't serialize object of unregistered class");if(!Hr[n])throw new Error(`${n} is not registered.`);const i=r.serialize?r.serialize(t,e):{};if(r.serialize){if(e&&i===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in t){if(!t.hasOwnProperty(r))continue;if(Hr[n].omit.indexOf(r)>=0)continue;const s=t[r];i[r]=Hr[n].shallow.indexOf(r)>=0?s:tn(s,e)}t instanceof Error&&(i.message=t.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof t)}function en(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||Qr(t)||v(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(en);if("object"==typeof t){const e=t.$name||"Object";if(!Hr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Hr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=Hr[e].shallow.indexOf(r)>=0?i:en(i)}return n}throw new Error("can't deserialize object of type "+typeof t)}class rn{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){delete this._channel,this._callback=()=>{}}}class nn{constructor(t,e,r){this.receive=t=>{const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[r];const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t()}else x()||e.mustQueue?(this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger()):this.processTask(r,e)},this.process=()=>{if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)},this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new rn(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=x()?t:window}send(t,e,r,n,i=!1){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[s]=r);const a=[],o={id:s,type:t,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:tn(e,a)};return this.target.postMessage(o,{transfer:a}),{cancel:()=>{r&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}processTask(t,e){if(""===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(en(e.error)):r(null,en(e.data)))}else{let r=!1;const n=[],i=e.hasCallback?(e,i)=>{r=!0,delete this.cancelCallbacks[t];const s={id:t,type:"",sourceMapId:this.mapId,error:e?tn(e):null,data:tn(i,n)};this.target.postMessage(s,{transfer:n})}:t=>{r=!0};let s=null;const a=en(e.data);if(this.parent[e.type])s=this.parent[e.type](e.sourceMapId,a,i);else if("getWorkerSource"in this.parent){const t=e.type.split(".");s=this.parent.getWorkerSource(e.sourceMapId,t[0],a.source)[t[1]](a,i)}else i(new Error(`Could not find function ${e.type}`));!r&&s&&s.cancel&&(this.cancelCallbacks[t]=s.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}}function sn(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e))}function an(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}class on{constructor(t,e={}){h(this,e),this.type=t}}class ln extends on{constructor(t,e={}){super("error",h({error:t},e))}}class un{on(t,e){return this._listeners=this._listeners||{},sn(t,e,this._listeners),this}off(t,e){return an(t,e,this._listeners),an(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},sn(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new on(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)an(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(h(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t))}else t instanceof ln&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}const cn=jr,hn=cn.paintProperty,pn=cn.layoutProperty;class fn{constructor(){this.first=!0}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function yn(t){for(const e of t)if(xn(e.charCodeAt(0)))return!0;return!1}function mn(t){for(const e of t)if(!gn(e.charCodeAt(0)))return!1;return!0}function gn(t){return!(dn.Arabic(t)||dn["Arabic Supplement"](t)||dn["Arabic Extended-A"](t)||dn["Arabic Presentation Forms-A"](t)||dn["Arabic Presentation Forms-B"](t))}function xn(t){return!(746!==t&&747!==t&&(t<4352||!(dn["Bopomofo Extended"](t)||dn.Bopomofo(t)||dn["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||dn["CJK Compatibility Ideographs"](t)||dn["CJK Compatibility"](t)||dn["CJK Radicals Supplement"](t)||dn["CJK Strokes"](t)||!(!dn["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||dn["CJK Unified Ideographs Extension A"](t)||dn["CJK Unified Ideographs"](t)||dn["Enclosed CJK Letters and Months"](t)||dn["Hangul Compatibility Jamo"](t)||dn["Hangul Jamo Extended-A"](t)||dn["Hangul Jamo Extended-B"](t)||dn["Hangul Jamo"](t)||dn["Hangul Syllables"](t)||dn.Hiragana(t)||dn["Ideographic Description Characters"](t)||dn.Kanbun(t)||dn["Kangxi Radicals"](t)||dn["Katakana Phonetic Extensions"](t)||dn.Katakana(t)&&12540!==t||!(!dn["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!dn["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||dn["Unified Canadian Aboriginal Syllabics"](t)||dn["Unified Canadian Aboriginal Syllabics Extended"](t)||dn["Vertical Forms"](t)||dn["Yijing Hexagram Symbols"](t)||dn["Yi Syllables"](t)||dn["Yi Radicals"](t))))}function vn(t){return!(xn(t)||function(t){return!!(dn["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||dn["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||dn["Letterlike Symbols"](t)||dn["Number Forms"](t)||dn["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||dn["Control Pictures"](t)&&9251!==t||dn["Optical Character Recognition"](t)||dn["Enclosed Alphanumerics"](t)||dn["Geometric Shapes"](t)||dn["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||dn["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||dn["CJK Symbols and Punctuation"](t)||dn.Katakana(t)||dn["Private Use Area"](t)||dn["CJK Compatibility Forms"](t)||dn["Small Form Variants"](t)||dn["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function bn(t){return t>=1424&&t<=2303||dn["Arabic Presentation Forms-A"](t)||dn["Arabic Presentation Forms-B"](t)}function wn(t,e){return!(!e&&bn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||dn.Khmer(t))}function _n(t){for(const e of t)if(bn(e.charCodeAt(0)))return!0;return!1}"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date);let Sn="unavailable",kn=null;const An={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>"loaded"===Sn||null!=An.applyArabicShaping,isLoading:()=>"loading"===Sn,setState(t){if(!x())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Sn=t.pluginStatus,kn=t.pluginURL},isParsed(){if(!x())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return null!=An.applyArabicShaping&&null!=An.processBidirectionalText&&null!=An.processStyledBidirectionalText},getPluginURL(){if(!x())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return kn}};class In{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new fn,this.transition={})}isSupportedScript(t){return function(t,e){for(const r of t)if(!wn(r.charCodeAt(0),e))return!1;return!0}(t,An.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class zn{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Ne(t))return new ir(t,e);if(Qe(t)){const r=nr(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return"color"===e.type&&"string"==typeof t?r=dt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(r=bt.parse(t)):r=xt.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Mn{constructor(t){this.property=t,this.value=new zn(t,void 0)}transitioned(t,e){return new Cn(this.property,this.value,e,h({},t.transition,this.transition),t.now)}untransitioned(){return new Cn(this.property,this.value,null,{},0)}}class Pn{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return f(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Mn(this._values[t].property)),this._values[t].value=new zn(this._values[t].property,null===e?void 0:f(e))}getTransition(t){return f(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Mn(this._values[t].property)),this._values[t].transition=f(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const r=new Bn(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Bn(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Cn{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r)}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(a))}}return i}}class Bn{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,r){const n=new Fn(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Vn{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return void 0!==this._values[t].value}getValue(t){return f(this._values[t].value)}setValue(t,e){this._values[t]=new zn(this._values[t].property,null===e?void 0:f(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r)}return t}possiblyEvaluate(t,e,r){const n=new Fn(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}}class En{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n)}}class Fn{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Tn{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,r){const n=ue[this.specification.type];return n?n(t,e,r):t}}class Dn{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,r,n){return new En(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},r,n)}:t.expression,e)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new En(this,{kind:"constant",value:void 0},t.parameters);const n=ue[this.specification.type];if(n){const i=n(t.value.value,e.value.value,r);return new En(this,{kind:"constant",value:i},t.parameters)}return t}evaluate(t,e,r,n,i,s){return"constant"===t.kind?t.value:t.evaluate(e,r,n,i,s)}}class $n extends Dn{possiblyEvaluate(t,e,r,n){if(void 0===t.value)return new En(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n),s="resolvedImage"===t.property.specification.type&&"string"!=typeof i?i.name:i,a=this._calculate(s,s,s,e);return new En(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const r=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new En(this,{kind:"constant",value:r},e)}return new En(this,t.expression,e)}evaluate(t,e,r,n,i,s){if("source"===t.kind){const a=t.evaluate(e,r,n,i,s);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},r,n),t.evaluate({zoom:Math.floor(e.zoom)},r,n),t.evaluate({zoom:Math.floor(e.zoom)+1},r,n),e):t.value}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ln{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new In(Math.floor(e.zoom-1),e)),t.expression.evaluate(new In(Math.floor(e.zoom),e)),t.expression.evaluate(new In(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class On{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){return!!t.expression.evaluate(e,null,{},r,n)}interpolate(){return!1}}class Un{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new zn(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Mn(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}}}Wr("DataDrivenProperty",Dn),Wr("DataConstantProperty",Tn),Wr("CrossFadedDataDrivenProperty",$n),Wr("CrossFadedProperty",Ln),Wr("ColorRampProperty",On);const qn="-transition";class jn extends un{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Vn(e.layout)),e.paint)){this._transitionablePaint=new Pn(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Fn(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(pn,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(qn)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(hn,`layers.${this.id}.paint.${t}`,t,e,r))return!1;if(t.endsWith(qn))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),function(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return(!i||!1!==i.validate)&&function(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new ln(new Error(n.message))),r=!0;return r}(this,t.call(cn,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:S,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof En&&Ue(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Rn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Nn{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Zn{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Gn(t,e=1){let r=0,n=0;return{members:t.map((t=>{const i=Rn[t.type].BYTES_PER_ELEMENT,s=r=Jn(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Jn(r,Math.max(n,e)),alignment:e}}function Jn(t,e){return Math.ceil(t/e)*e}class Kn extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Kn.prototype.bytesPerElement=4,Wr("StructArrayLayout2i4",Kn);class Xn extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Xn.prototype.bytesPerElement=6,Wr("StructArrayLayout3i6",Xn);class Yn extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Yn.prototype.bytesPerElement=8,Wr("StructArrayLayout4i8",Yn);class Hn extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Hn.prototype.bytesPerElement=12,Wr("StructArrayLayout2i4i12",Hn);class Wn extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}Wn.prototype.bytesPerElement=8,Wr("StructArrayLayout2i4ub8",Wn);class Qn extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Qn.prototype.bytesPerElement=8,Wr("StructArrayLayout2f8",Qn);class ti extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}ti.prototype.bytesPerElement=20,Wr("StructArrayLayout10ui20",ti);class ei extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}ei.prototype.bytesPerElement=24,Wr("StructArrayLayout4i4ui4i24",ei);class ri extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ri.prototype.bytesPerElement=12,Wr("StructArrayLayout3f12",ri);class ni extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ni.prototype.bytesPerElement=4,Wr("StructArrayLayout1ul4",ni);class ii extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}ii.prototype.bytesPerElement=20,Wr("StructArrayLayout6i1ul2ui20",ii);class si extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}si.prototype.bytesPerElement=12,Wr("StructArrayLayout2i2i2i12",si);class ai extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}ai.prototype.bytesPerElement=16,Wr("StructArrayLayout2f1f2i16",ai);class oi extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=12*t,a=3*t;return this.uint8[s+0]=e,this.uint8[s+1]=r,this.float32[a+1]=n,this.float32[a+2]=i,t}}oi.prototype.bytesPerElement=12,Wr("StructArrayLayout2ub2f12",oi);class li extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}li.prototype.bytesPerElement=6,Wr("StructArrayLayout3ui6",li);class ui extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}ui.prototype.bytesPerElement=48,Wr("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ui);class ci extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,A,I,z){const M=this.length;return this.resize(M+1),this.emplace(M,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,A,I,z)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,A,I,z,M){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=S,this.uint32[C+12]=k,this.float32[C+13]=A,this.float32[C+14]=I,this.uint16[P+30]=z,this.uint16[P+31]=M,t}}ci.prototype.bytesPerElement=64,Wr("StructArrayLayout8i15ui1ul2f2ui64",ci);class hi extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}hi.prototype.bytesPerElement=4,Wr("StructArrayLayout1f4",hi);class pi extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}pi.prototype.bytesPerElement=12,Wr("StructArrayLayout1ui2f12",pi);class fi extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}fi.prototype.bytesPerElement=8,Wr("StructArrayLayout1ul2ui8",fi);class di extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}di.prototype.bytesPerElement=4,Wr("StructArrayLayout2ui4",di);class yi extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}yi.prototype.bytesPerElement=2,Wr("StructArrayLayout1ui2",yi);class mi extends Zn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}mi.prototype.bytesPerElement=16,Wr("StructArrayLayout4f16",mi);class gi extends Nn{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}gi.prototype.size=20;class xi extends ii{get(t){return new gi(this,t)}}Wr("CollisionBoxArray",xi);class vi extends Nn{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}vi.prototype.size=48;class bi extends ui{get(t){return new vi(this,t)}}Wr("PlacedSymbolArray",bi);class wi extends Nn{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}wi.prototype.size=64;class _i extends ci{get(t){return new wi(this,t)}}Wr("SymbolInstanceArray",_i);class Si extends hi{getoffsetX(t){return this.float32[1*t+0]}}Wr("GlyphOffsetArray",Si);class ki extends Xn{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Wr("SymbolLineVertexArray",ki);class Ai extends Nn{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Ai.prototype.size=12;class Ii extends pi{get(t){return new Ai(this,t)}}Wr("TextAnchorOffsetArray",Ii);class zi extends Nn{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}zi.prototype.size=8;class Mi extends fi{get(t){return new zi(this,t)}}Wr("FeatureIndexArray",Mi);class Pi extends Kn{}class Ci extends Kn{}class Bi extends Kn{}class Vi extends Hn{}class Ei extends Wn{}class Fi extends Qn{}class Ti extends ti{}class Di extends ei{}class $i extends ri{}class Li extends ni{}class Oi extends si{}class Ui extends oi{}class qi extends li{}class ji extends di{}const Ri=Gn([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ni}=Ri;class Zi{constructor(t=[]){this.segments=t}prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>Zi.MAX_VERTEX_ARRAY_LENGTH&&y(`Max vertices per segment is ${Zi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>Zi.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,r,n){return new Zi([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Gi(t,e){return 256*(t=c(Math.floor(t),0,255))+c(Math.floor(e),0,255)}Zi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Wr("SegmentVector",Zi);const Ji=Gn([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ki={exports:{}},Xi={exports:{}};Xi.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var Yi=Xi.exports,Hi={exports:{}};Hi.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var Wi=Yi,Qi=Hi.exports;Ki.exports=Wi,Ki.exports.murmur3=Wi,Ki.exports.murmur2=Qi;var ts=e(Ki.exports);class es{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,r,n){this.ids.push(rs(t)),this.positions.push(e,r,n)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=rs(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return ns(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new es;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function rs(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ts(String(t))}function ns(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++}while(t[s]i);if(s>=a)break;is(t,s,a),is(e,3*s,3*a),is(e,3*s+1,3*a+1),is(e,3*s+2,3*a+2)}a-r`u_${t}`)),this.type=r}setUniform(t,e,r){t.set(r.constantOr(this.value))}getBinding(t,e,r){return"color"===this.type?new ls(t,e):new as(t,e)}}class hs{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i)}getBinding(t,e,r){return"u_pattern"===r.substr(0,9)?new os(t,e):new as(t,e)}}class ps{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new In(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a)}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i)}_setPaintValue(t,e,r){if("color"===this.type){const n=us(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new In(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new In(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a)}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s)}_setPaintValue(t,e,r,n){if("color"===this.type){const i=us(r),s=us(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof ps||r instanceof fs)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new ys(n,e,r);this.needsUpload=!1,this._featureMap=new es,this._bufferOffset=0}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function gs(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function xs(t,e,r){const n={color:{source:Qn,composite:mi},number:{source:hi,composite:Qn}},i=function(t){return{"line-pattern":{source:Ti,composite:Ti},"fill-pattern":{source:Ti,composite:Ti},"fill-extrusion-pattern":{source:Ti,composite:Ti}}[t]}(t);return i&&i[r]||n[e][r]}Wr("ConstantBinder",cs),Wr("CrossFadedConstantBinder",hs),Wr("SourceExpressionBinder",ps),Wr("CrossFadedCompositeBinder",ds),Wr("CompositeExpressionBinder",fs),Wr("ProgramConfiguration",ys,{omit:["_buffers"]}),Wr("ProgramConfigurationSet",ms);const vs=8192,bs=Math.pow(2,14)-1,ws=-bs-1;function _s(t){const e=vs/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&y("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Ss(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?_s(t):[]}}function ks(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)}class As{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ci,this.indexArray=new qi,this.segments=new Zi,this.programConfigurations=new ms(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1;"circle"===n.type&&(s=n.layout.get("circle-sort-key"),a=!s.isConstant());for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Ss(e,t);if(!this.layers[0]._featureFilter.filter(new In(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:_s(e),patterns:{},sortKey:c};i.push(h)}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r),e.featureIndex.insert(o,i,s,a,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ni),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,r,n){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=vs||n<0||n>=vs)continue;const i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),s=i.vertexLength;ks(this.layoutVertexArray,r,n,-1,-1),ks(this.layoutVertexArray,r,n,1,-1),ks(this.layoutVertexArray,r,n,1,1),ks(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+3,s+2),i.vertexLength+=4,i.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n)}}function Is(t,e){for(let r=0;r1){if(Cs(t,e))return!0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function Fs(t,e){let r,n,i,s=!1;for(let a=0;ae.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s)}return s}function Ts(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function Ds(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return!1;const s=m(t,e,r[0]);return s!==m(t,e,r[1])||s!==m(t,e,r[2])||s!==m(t,e,r[3])}function $s(t,e,r){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function Ls(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Os(t,e,r,n,s){if(!e[0]&&!e[1])return t;const a=i.convert(e)._mult(s);"viewport"===r&&a._rotate(-n);const o=[];for(let e=0;eKs(t,e)))}(l,o),p=c?u*a:u;for(const t of n)for(const e of t){const t=c?e:Ks(e,o);let r=p;const n=Gs([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/s.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=s.cameraToCenterDistance/n[3]),zs(h,t,r))return!0}return!1}}function Ks(t,e){const r=Gs([],[t.x,t.y,0,1],e);return new i(r[0]/r[3],r[1]/r[3])}class Xs extends As{}let Ys;Wr("HeatmapBucket",Xs,{omit:["layers"]});var Hs={get paint(){return Ys=Ys||new Un({"heatmap-radius":new Dn(S.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Dn(S.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Tn(S.paint_heatmap["heatmap-intensity"]),"heatmap-color":new On(S.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Tn(S.paint_heatmap["heatmap-opacity"])})}};function Ws(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Qs(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Ws({},{width:e,height:r},n);ta(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data}function ta(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a)};if(t.clips)for(let e=0,i=0;e80*r){n=s=t[0],i=a=t[1];for(var d=r;ds&&(s=o),l>a&&(a=l);u=0!==(u=Math.max(s-n,a-i))?32767/u:0}return fa(p,f,r,n,i,u,0),f}function ha(t,e,r,n,i){var s,a;if(i===Ta(t,e,r,n)>0)for(s=e;s=e;s-=n)a=Va(s,t[s],t[s+1],a);return a&&Ia(a,a.next)&&(Ea(a),a=a.next),a}function pa(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!Ia(n,n.next)&&0!==Aa(n.prev,n,n.next))n=n.next;else{if(Ea(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function fa(t,e,r,n,i,s,a){if(t){!a&&s&&function(t,e,r,n){var i=t;do{0===i.z&&(i.z=wa(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,s,a,o,l,u=1;do{for(r=t,t=null,s=null,a=0;r;){for(a++,n=r,o=0,e=0;e0||l>0&&n;)0!==o&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:t=i,i.prevZ=s,s=i;r=n}s.nextZ=null,u*=2}while(a>1)}(i)}(t,n,i,s);for(var o,l,u=t;t.prev!==t.next;)if(o=t.prev,l=t.next,s?ya(t,n,i,s):da(t))e.push(o.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Ea(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?fa(t=ma(pa(t),e,r),e,r,n,i,s,2):2===a&&ga(t,e,r,n,i,s):fa(pa(t),e,r,n,i,s,1);break}}}function da(t){var e=t.prev,r=t,n=t.next;if(Aa(e,r,n)>=0)return!1;for(var i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=is?i>a?i:a:s>a?s:a,f=o>l?o>u?o:u:l>u?l:u,d=n.next;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Sa(i,o,s,l,a,u,d.x,d.y)&&Aa(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function ya(t,e,r,n){var i=t.prev,s=t,a=t.next;if(Aa(i,s,a)>=0)return!1;for(var o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=ol?o>u?o:u:l>u?l:u,m=c>h?c>p?c:p:h>p?h:p,g=wa(f,d,e,r,n),x=wa(y,m,e,r,n),v=t.prevZ,b=t.nextZ;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sa(o,c,l,h,u,p,v.x,v.y)&&Aa(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sa(o,c,l,h,u,p,b.x,b.y)&&Aa(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sa(o,c,l,h,u,p,v.x,v.y)&&Aa(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sa(o,c,l,h,u,p,b.x,b.y)&&Aa(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ma(t,e,r){var n=t;do{var i=n.prev,s=n.next.next;!Ia(i,s)&&za(i,n,n.next,s)&&Ca(i,s)&&Ca(s,i)&&(e.push(i.i/r|0),e.push(n.i/r|0),e.push(s.i/r|0),Ea(n),Ea(n.next),n=t=s),n=n.next}while(n!==t);return pa(n)}function ga(t,e,r,n,i,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&ka(a,o)){var l=Ba(a,o);return a=pa(a,a.next),l=pa(l,l.next),fa(a,e,r,n,i,s,0),void fa(l,e,r,n,i,s,0)}o=o.next}a=a.next}while(a!==t)}function xa(t,e){return t.x-e.x}function va(t,e){var r=function(t,e){var r,n=e,i=t.x,s=t.y,a=-1/0;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){var o=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=i&&o>a&&(a=o,r=n.x=n.x&&n.x>=c&&i!==n.x&&Sa(sr.x||n.x===r.x&&ba(r,n)))&&(r=n,p=l)),n=n.next}while(n!==u);return r}(t,e);if(!r)return e;var n=Ba(r,t);return pa(n,n.next),pa(r,r.next)}function ba(t,e){return Aa(t.prev,t,e.prev)<0&&Aa(e.next,t,t.next)<0}function wa(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function _a(t){var e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function ka(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&za(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(Ca(t,e)&&Ca(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(Aa(t.prev,t,e.prev)||Aa(t,e.prev,e))||Ia(t,e)&&Aa(t.prev,t,t.next)>0&&Aa(e.prev,e,e.next)>0)}function Aa(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Ia(t,e){return t.x===e.x&&t.y===e.y}function za(t,e,r,n){var i=Pa(Aa(t,e,r)),s=Pa(Aa(t,e,n)),a=Pa(Aa(r,n,t)),o=Pa(Aa(r,n,e));return i!==s&&a!==o||!(0!==i||!Ma(t,r,e))||!(0!==s||!Ma(t,n,e))||!(0!==a||!Ma(r,t,n))||!(0!==o||!Ma(r,e,n))}function Ma(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Pa(t){return t>0?1:t<0?-1:0}function Ca(t,e){return Aa(t.prev,t,t.next)<0?Aa(t,e,t.next)>=0&&Aa(t,t.prev,e)>=0:Aa(t,e,t.prev)<0||Aa(t,t.next,e)<0}function Ba(t,e){var r=new Fa(t.i,t.x,t.y),n=new Fa(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function Va(t,e,r,n){var i=new Fa(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ea(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Fa(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ta(t,e,r,n){for(var i=0,s=e,a=r-n;s0&&r.holes.push(n+=t[i-1].length)}return r};var Da=e(ua.exports);function $a(t,e,r,n,i){La(t,e,r||0,n||t.length-1,i||Ua)}function La(t,e,r,n,i){for(;n>r;){if(n-r>600){var s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);La(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i)}var c=t[e],h=r,p=n;for(Oa(t,r,e),i(t[n],c)>0&&Oa(t,r,n);h0;)p--}0===i(t[r],c)?Oa(t,r,p):Oa(t,++p,n),p<=e&&(r=p+1),e<=p&&(n=p-1)}}function Oa(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Ua(t,e){return te?1:0}function qa(t,e){const r=t.length;if(r<=1)return[t];const n=[];let i,s;for(let e=0;e1)for(let t=0;tt.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Bi,this.indexArray=new qi,this.indexArray2=new ji,this.programConfigurations=new ms(t.layers,t.zoom),this.segments=new Zi,this.segments2=new Zi,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Ra("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ss(a,t);if(!this.layers[0]._featureFilter.filter(new In(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:_s(a),patterns:{},sortKey:h};s.push(p)}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Na("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,i,s,r,{});e.featureIndex.insert(t[s].feature,i,s,a,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,la),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,r,n,i){for(const t of qa(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t>3}if(i--,1===n||2===n)s+=t.readSVarint(),a+=t.readSVarint(),1===n&&(e&&o.push(e),e=[]),e.push(new to(s,a));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&o.push(e),o},ro.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return[a,l,o,u]},ro.prototype.toGeoJSON=function(t,e,r){var n,i,s=this.extent*Math.pow(2,r),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),u=ro.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}oo.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new so(this._pbf,e,this.extent,this._keys,this._values)};var uo=ao;function co(t,e,r){if(3===t){var n=new uo(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}Qa.VectorTile=function(t,e){this.layers=t.readFields(co,{},e)},Qa.VectorTileFeature=eo,Qa.VectorTileLayer=ao;const ho=Qa.VectorTileFeature.types,po=Math.pow(2,13);function fo(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*po)+a,i*po*2,s*po*2,Math.round(o))}class yo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Vi,this.centroidVertexArray=new Pi,this.indexArray=new qi,this.programConfigurations=new ms(t.layers,t.zoom),this.segments=new Zi,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.features=[],this.hasPattern=Ra("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=Ss(n,t);if(!this.layers[0]._featureFilter.filter(new In(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:_s(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Na("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{}),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0)}}addFeatures(t,e,r){for(const t of this.features){const{geometry:n}=t;this.addFeature(t,n,t.index,e,r)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Wa),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ha.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,r,n,i){const s={x:0,y:0,vertexCount:0};for(const r of qa(e,500)){let e=0;for(const t of r)e+=t.length;let n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of r){if(0===t.length)continue;if(go(t))continue;let e=0;for(let r=0;r=1){const a=t[r-1];if(!mo(i,a)){n.vertexLength+4>Zi.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(a)._perp()._unit(),r=a.dist(i);e+r>32768&&(e=0),fo(this.layoutVertexArray,i.x,i.y,t.x,t.y,0,0,e),fo(this.layoutVertexArray,i.x,i.y,t.x,t.y,0,1,e),s.x+=2*i.x,s.y+=2*i.y,s.vertexCount+=2,e+=r,fo(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,e),fo(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,e),s.x+=2*a.x,s.y+=2*a.y,s.vertexCount+=2;const o=n.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),n.vertexLength+=4,n.primitiveLength+=2}}}}if(n.vertexLength+e>Zi.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==ho[t.type])continue;const i=[],a=[],o=n.vertexLength;for(const t of r)if(0!==t.length){t!==r[0]&&a.push(i.length/2);for(let e=0;evs)||t.y===e.y&&(t.y<0||t.y>vs)}function go(t){return t.every((t=>t.x<0))||t.every((t=>t.x>vs))||t.every((t=>t.y<0))||t.every((t=>t.y>vs))}let xo;Wr("FillExtrusionBucket",yo,{omit:["layers","features"]});var vo={get paint(){return xo=xo||new Un({"fill-extrusion-opacity":new Tn(S["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Dn(S["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Tn(S["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Tn(S["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new $n(S["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Dn(S["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Dn(S["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Tn(S["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class bo extends jn{constructor(t){super(t,vo)}createBucket(t){return new yo(t)}queryRadius(){return Ls(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,r,n,s,a,o,l){const u=Os(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,o),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),p=function(t,e,r,n){const s=[];for(const r of t){const t=[r.x,r.y,0,1];Gs(t,t,e),s.push(new i(t[0]/t[3],t[1]/t[3]))}return s}(u,l),f=function(t,e,r,n){const s=[],a=[],o=n[8]*e,l=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x,a=s.y,y=n[0]*e+n[4]*a+n[12],m=n[1]*e+n[5]*a+n[13],g=n[2]*e+n[6]*a+n[14],x=n[3]*e+n[7]*a+n[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,k=x+d,A=new i((y+o)/b,(m+l)/b);A.z=v/b,t.push(A);const I=new i(w/k,_/k);I.z=S/k,r.push(I)}s.push(t),a.push(r)}return[s,a]}(n,h,c,l);return function(t,e,r){let n=1/0;Ms(r,e)&&(n=_o(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Ei,this.layoutVertexArray2=new Fi,this.indexArray=new qi,this.programConfigurations=new ms(t.layers,t.zoom),this.segments=new Zi,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Ra("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Ss(e,t);if(!this.layers[0]._featureFilter.filter(new In(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:_s(e),patterns:{},sortKey:c};s.push(h)}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Na("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,i,s,r,{});e.featureIndex.insert(t[s].feature,i,s,a,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Io)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ko),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),o=s.get("line-cap"),l=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,a,o,l,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n)}addLine(t,e,r,n,i,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(w&&e>l){const t=h.dist(p);if(t>2*u){const e=h.sub(h.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,d,0,0,c),p=e}}const S=p&&f;let k=S?r:a?"butt":n;if(S&&"round"===k&&(vi&&(k="bevel"),"bevel"===k&&(v>2&&(k="flipbevel"),v100)m=y.mult(-1);else{const t=v*d.add(y).mag()/d.sub(y).mag();m._perp()._mult(t*(_?-1:1))}this.addCurrentVertex(h,m,0,0,c),this.addCurrentVertex(h,m.mult(-1),0,0,c)}else if("bevel"===k||"fakeround"===k){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(p&&this.addCurrentVertex(h,d,e,r,c),"fakeround"===k){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*u){const e=h.add(f.sub(h)._mult(u/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,y,0,0,c),h=e}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>Po/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s))}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Po-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let Bo,Vo;Wr("LineBucket",Co,{omit:["layers","patternFeatures"]});var Eo={get paint(){return Vo=Vo||new Un({"line-opacity":new Dn(S.paint_line["line-opacity"]),"line-color":new Dn(S.paint_line["line-color"]),"line-translate":new Tn(S.paint_line["line-translate"]),"line-translate-anchor":new Tn(S.paint_line["line-translate-anchor"]),"line-width":new Dn(S.paint_line["line-width"]),"line-gap-width":new Dn(S.paint_line["line-gap-width"]),"line-offset":new Dn(S.paint_line["line-offset"]),"line-blur":new Dn(S.paint_line["line-blur"]),"line-dasharray":new Ln(S.paint_line["line-dasharray"]),"line-pattern":new $n(S.paint_line["line-pattern"]),"line-gradient":new On(S.paint_line["line-gradient"])})},get layout(){return Bo=Bo||new Un({"line-cap":new Tn(S.layout_line["line-cap"]),"line-join":new Dn(S.layout_line["line-join"]),"line-miter-limit":new Tn(S.layout_line["line-miter-limit"]),"line-round-limit":new Tn(S.layout_line["line-round-limit"]),"line-sort-key":new Dn(S.layout_line["line-sort-key"])})}};class Fo extends Dn{possiblyEvaluate(t,e){return e=new In(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=h({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let To;class Do extends jn{constructor(t){super(t,Eo),this.gradientVersion=0,To||(To=new Fo(Eo.paint.properties["line-width"].specification),To.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof ae,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=To.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Co(t)}queryRadius(t){const e=t,r=$o($s("line-width",this,e),$s("line-gap-width",this,e)),n=$s("line-offset",this,e);return r/2+Math.abs(n)+Ls(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,s,a,o){const l=Os(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,o),u=o/2*$o(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),c=this.paint.get("line-offset").evaluate(e,r);return c&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Lo=Gn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Oo=Gn([{name:"a_projected_pos",components:3,type:"Float32"}],4);Gn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Uo=Gn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Gn([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const qo=Gn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function jo(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),An.applyArabicShaping&&(t=An.applyArabicShaping(t)),t}(t.text,e,r)})),t}Gn([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4),Gn([{name:"triangle",components:3,type:"Uint16"}]),Gn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Gn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Gn([{type:"Float32",name:"offsetX"}]),Gn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Gn([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Ro={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var No=24,Zo=Ko,Go=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else{if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u}return(f?-1:1)*a*Math.pow(2,s-n)},Jo=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y};function Ko(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ko.Varint=0,Ko.Fixed64=1,Ko.Bytes=2,Ko.Fixed32=5;var Xo=4294967296,Yo=1/Xo,Ho="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Wo(t){return t.type===Ko.Bytes?t.readVarint()+t.pos:t.pos+1}function Qo(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function tl(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function el(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function pl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Ko.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=cl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=pl(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=cl(this.buf,this.pos)+cl(this.buf,this.pos+4)*Xo;return this.pos+=8,t},readSFixed64:function(){var t=cl(this.buf,this.pos)+pl(this.buf,this.pos+4)*Xo;return this.pos+=8,t},readFloat:function(){var t=Go(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Go(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return Qo(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return Qo(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return Qo(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return Qo(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return Qo(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return Qo(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Ho?function(t,e,r){return Ho.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Ko.Bytes)return t.push(this.readVarint(e));var r=Wo(this);for(t=t||[];this.pos127;);else if(e===Ko.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ko.Fixed32)this.pos+=4;else{if(e!==Ko.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7)}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&tl(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Jo(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Jo(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&tl(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,Ko.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,el,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,rl,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,sl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,nl,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,il,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,al,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,ol,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,ll,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,ul,e)},writeBytesField:function(t,e){this.writeTag(t,Ko.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ko.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ko.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ko.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ko.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ko.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ko.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ko.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ko.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ko.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var fl=e(Zo);const dl=3;function yl(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&kl[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const r=new _l;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(wl.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Sl(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=_l.fromFeature(t,i);let g;h===vl.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=An;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),Bl(m,u,s,e,n,f,d));for(const e of t){const t=new _l;t.text=e,t.sections=m.sections;for(let r=0;r0&&s>w&&(w=s)}else{const t=r[d.fontStack],n=t&&t[m];if(n&&n.rect)_=n.rect,v=n.metrics;else{const t=e[d.fontStack],r=t&&t[m];if(!r)continue;v=r.metrics}g=(i-d.scale)*No}A?(t.verticalizable=!0,b.push({glyph:m,imageName:S,x:p,y:f+g,vertical:A,scale:d.scale,fontStack:d.fontStack,sectionIndex:y,metrics:v,rect:_}),p+=k*d.scale+u):(b.push({glyph:m,imageName:S,x:p,y:f+g,vertical:A,scale:d.scale,fontStack:d.fontStack,sectionIndex:y,metrics:v,rect:_}),p+=v.advance*d.scale+u)}0!==b.length&&(d=Math.max(p-u,d),El(b,0,b.length-1,m,w)),p=0;const _=s*i+w;v.lineOffset=Math.max(w,o),f+=_,y=Math.max(_,y),++g}var x;const v=f-bl,{horizontalAlign:b,verticalAlign:w}=Vl(a);(function(t,e,r,n,i,s,a,o,l){const u=(e-r)*i;let c=0;c=s!==a?-o*n-bl:(-n*l+.5)*a;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c})(t.positionedLines,m,b,w,d,y,s,v,i.length),t.top+=-w*v,t.bottom=t.top+v,t.left+=-b*d,t.right=t.left+d}(w,e,r,n,g,a,o,l,h,u,p,y),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(b)&&w}const kl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Al={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Il(t,e,r,n,i,s){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*No/s+i:0}{const n=r[e.fontStack],s=n&&n[t];return s?s.metrics.advance*e.scale+i:0}}function zl(t,e,r,n){const i=Math.pow(t-e,2);return n?t=0;let c=0;for(let r=0;rt.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Zs([]),this.placementViewportMatrix=Zs([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ol(this.zoom,e["text-size"]),this.iconSizeData=Ol(this.zoom,e["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.canOverlap="never"!==Ul(r,"text-overlap","text-allow-overlap")||"never"!==Ul(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((t=>vl[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Gl(new ms(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Gl(new ms(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Si,this.lineVertexArray=new ki,this.symbolInstances=new _i,this.textAnchorOffsets=new Ii}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==o.value.kind||!!o.value.value||Object.keys(o.parameters).length>0,c=i.get("symbol-sort-key");if(this.features=[],!l&&!u)return;const h=e.iconDependencies,p=e.glyphDependencies,f=e.availableImages,d=new In(this.zoom);for(const{feature:e,id:a,index:o,sourceLayerIndex:y}of t){const t=n._featureFilter.needGeometry,m=Ss(e,t);if(!n._featureFilter.filter(d,m,r))continue;let g,x;if(t||(m.geometry=_s(e)),l){const t=n.getValueAndResolveTokens("text-field",m,r,f),e=gt.factory(t);Zl(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Sn||this.hasRTLText&&An.isParsed())&&(g=jo(e,n,m))}if(u){const t=n.getValueAndResolveTokens("icon-image",m,r,f);x=t instanceof wt?t:wt.fromString(t)}if(!g&&!x)continue;const v=this.sortFeaturesByKey?c.evaluate(m,{},r):void 0;if(this.features.push({id:a,text:g,icon:x,index:o,sourceLayerIndex:y,geometry:m.geometry,properties:e.properties,type:ql[e.type],sortKey:v}),x&&(h[x.name]=!0),g){const t=s.evaluate(m,{},r).join(","),e="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(vl.vertical)>=0;for(const r of g.sections)if(r.image)h[r.image.name]=!0;else{const n=yn(g.toString()),i=r.fontStack||t,s=p[i]=p[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n)}}}"line"===i.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Xl,Yl;Wr("SymbolBucket",Kl,{omit:["layers","collisionBoxArray","features","compareText"]}),Kl.MAX_GLYPHS=65535,Kl.addDynamicAttributes=Nl;var Hl={get paint(){return Yl=Yl||new Un({"icon-opacity":new Dn(S.paint_symbol["icon-opacity"]),"icon-color":new Dn(S.paint_symbol["icon-color"]),"icon-halo-color":new Dn(S.paint_symbol["icon-halo-color"]),"icon-halo-width":new Dn(S.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Dn(S.paint_symbol["icon-halo-blur"]),"icon-translate":new Tn(S.paint_symbol["icon-translate"]),"icon-translate-anchor":new Tn(S.paint_symbol["icon-translate-anchor"]),"text-opacity":new Dn(S.paint_symbol["text-opacity"]),"text-color":new Dn(S.paint_symbol["text-color"],{runtimeType:E,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Dn(S.paint_symbol["text-halo-color"]),"text-halo-width":new Dn(S.paint_symbol["text-halo-width"]),"text-halo-blur":new Dn(S.paint_symbol["text-halo-blur"]),"text-translate":new Tn(S.paint_symbol["text-translate"]),"text-translate-anchor":new Tn(S.paint_symbol["text-translate-anchor"])})},get layout(){return Xl=Xl||new Un({"symbol-placement":new Tn(S.layout_symbol["symbol-placement"]),"symbol-spacing":new Tn(S.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Tn(S.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Dn(S.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Tn(S.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Tn(S.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Tn(S.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Tn(S.layout_symbol["icon-ignore-placement"]),"icon-optional":new Tn(S.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Tn(S.layout_symbol["icon-rotation-alignment"]),"icon-size":new Dn(S.layout_symbol["icon-size"]),"icon-text-fit":new Tn(S.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Tn(S.layout_symbol["icon-text-fit-padding"]),"icon-image":new Dn(S.layout_symbol["icon-image"]),"icon-rotate":new Dn(S.layout_symbol["icon-rotate"]),"icon-padding":new Dn(S.layout_symbol["icon-padding"]),"icon-keep-upright":new Tn(S.layout_symbol["icon-keep-upright"]),"icon-offset":new Dn(S.layout_symbol["icon-offset"]),"icon-anchor":new Dn(S.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Tn(S.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Tn(S.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Tn(S.layout_symbol["text-rotation-alignment"]),"text-field":new Dn(S.layout_symbol["text-field"]),"text-font":new Dn(S.layout_symbol["text-font"]),"text-size":new Dn(S.layout_symbol["text-size"]),"text-max-width":new Dn(S.layout_symbol["text-max-width"]),"text-line-height":new Tn(S.layout_symbol["text-line-height"]),"text-letter-spacing":new Dn(S.layout_symbol["text-letter-spacing"]),"text-justify":new Dn(S.layout_symbol["text-justify"]),"text-radial-offset":new Dn(S.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Tn(S.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Dn(S.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Dn(S.layout_symbol["text-anchor"]),"text-max-angle":new Tn(S.layout_symbol["text-max-angle"]),"text-writing-mode":new Tn(S.layout_symbol["text-writing-mode"]),"text-rotate":new Dn(S.layout_symbol["text-rotate"]),"text-padding":new Tn(S.layout_symbol["text-padding"]),"text-keep-upright":new Tn(S.layout_symbol["text-keep-upright"]),"text-transform":new Dn(S.layout_symbol["text-transform"]),"text-offset":new Dn(S.layout_symbol["text-offset"]),"text-allow-overlap":new Tn(S.layout_symbol["text-allow-overlap"]),"text-overlap":new Tn(S.layout_symbol["text-overlap"]),"text-ignore-placement":new Tn(S.layout_symbol["text-ignore-placement"]),"text-optional":new Tn(S.layout_symbol["text-optional"])})}};class Wl{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:P,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Wr("FormatSectionOverride",Wl,{omit:["defaultValue"]});class Ql extends jn{constructor(t){super(t,Hl)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||Qe(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Kl(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Hl.paint.overridableProperties){if(!Ql.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Wl(e),n=new We(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new er("source",n):new rr("composite",n,e.value.zoomStops),this.paint._values[t]=new En(e.property,i,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven())&&Ql.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Hl.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof gt)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof It&&kt(e.value)===$?s(e.value.sections):e instanceof Ce?s(e.sections):e.eachChild(t))},e=r.value;e._styleExpression&&t(e._styleExpression.expression)}return i}}let tu;var eu={get paint(){return tu=tu||new Un({"background-color":new Tn(S.paint_background["background-color"]),"background-pattern":new Ln(S.paint_background["background-pattern"]),"background-opacity":new Tn(S.paint_background["background-opacity"])})}};class ru extends jn{constructor(t){super(t,eu)}}let nu;var iu={get paint(){return nu=nu||new Un({"raster-opacity":new Tn(S.paint_raster["raster-opacity"]),"raster-hue-rotate":new Tn(S.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Tn(S.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Tn(S.paint_raster["raster-brightness-max"]),"raster-saturation":new Tn(S.paint_raster["raster-saturation"]),"raster-contrast":new Tn(S.paint_raster["raster-contrast"]),"raster-resampling":new Tn(S.paint_raster["raster-resampling"]),"raster-fade-duration":new Tn(S.paint_raster["raster-fade-duration"])})}};class su extends jn{constructor(t){super(t,iu)}}class au extends jn{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}function ou(t){if("custom"===t.type)return new au(t);switch(t.type){case"background":return new ru(t);case"circle":return new Js(t);case"fill":return new Xa(t);case"fill-extrusion":return new bo(t);case"heatmap":return new na(t);case"hillshade":return new aa(t);case"line":return new Do(t);case"raster":return new su(t);case"symbol":return new Ql(t)}}class lu{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(t,e){for(const e of t){this._layerConfigs[e.id]=e;const t=this._layers[e.id]=ou(e);t._featureFilter=lr(t.filter),this.keyCache[e.id]&&delete this.keyCache[e.id]}for(const t of e)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=function(t,e){const r={};for(let n=0;nthis._layers[t.id])),r=e[0];if("none"===r.visibility)continue;const n=r.source||"";let i=this.familiesBySource[n];i||(i=this.familiesBySource[n]={});const s=r.sourceLayer||"_geojsonTileLayer";let a=i[s];a||(a=i[s]=[]),a.push(e)}}}class uu{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class cu{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class hu{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new _(vs,16,0),this.grid3D=new _(vs,16,0),this.featureIndexArray=new Mi,this.promoteId=e}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Qa.VectorTile(new fl(this.rawTileData)).layers,this.sourceLayerCoder=new uu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const s=t.params||{},a=vs/t.tileSize/t.scale,o=lr(s.filter),l=t.queryGeometry,u=t.queryPadding*a,c=fu(l),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=fu(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,s)=>function(t,e,r,n,s){for(const i of t)if(e<=i.x&&r<=i.y&&n>=i.x&&s>=i.y)return!0;const a=[new i(e,r),new i(e,s),new i(n,s),new i(n,r)];if(t.length>2)for(const e of a)if(Ts(t,e))return!0;for(let e=0;e(p||(p=_s(e)),r.queryIntersectsFeature(l,e,n,p,this.z,t.transform,a,t.pixelPosMatrix))))}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const p=this.bucketLayerIDs[e];if(s&&!function(t,e){for(let r=0;r=0)return!0;return!1}(s,p))return;const f=this.sourceLayerCoder.decode(r),d=this.vtLayers[f].feature(n);if(i.needGeometry){const t=Ss(d,!0);if(!i.filter(new In(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new In(this.tileID.overscaledZ),d))return;const y=this.getId(d,f);for(let e=0;e{const a=e instanceof Fn?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function fu(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return{minX:e,minY:r,maxX:n,maxY:i}}function du(t,e){return e-t}Wr("FeatureIndex",hu,{omit:["rawTileData","sourceLayerCoder"]});class yu extends i{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n)}clone(){return new yu(this.x,this.y,this.angle,this.segment)}}function mu(t,e,r,n,i){if(void 0===e.segment||0===r)return!0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return!1;o-=t[a].dist(s),s=t[a]}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return!1;a++,o+=e.dist(r)}return!0}function gu(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=ue.number(n.x,i.x,c),p=ue.number(n.y,i.y,c),f=new yu(h,p,i.angleTo(n),r);return f._round(),!a||mu(t,f,o,a,e)?f:void 0}l+=s}}function wu(t,e,r,n,i,s,a,o,l){const u=xu(n,s,a),c=vu(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new yu(g,x,y,e);r._round(),n&&!mu(t,r,s,n,i)||f.push(r)}}h+=d}return o||f.length||a||(f=_u(t,h/2,r,n,i,s,a,!0,l)),f}Wr("Anchor",yu);const Su=ml;function ku(t,e,r,n){const s=[],a=t.image,o=a.pixelRatio,l=a.paddedRect.w-2*Su,u=a.paddedRect.h-2*Su,c=t.right-t.left,h=t.bottom-t.top,p=a.stretchX||[[0,l]],f=a.stretchY||[[0,u]],d=(t,e)=>t+e[1]-e[0],y=p.reduce(d,0),m=f.reduce(d,0),g=l-y,x=u-m;let v=0,b=y,w=0,_=m,S=0,k=g,A=0,I=x;if(a.content&&n){const t=a.content;v=Au(p,0,t[0]),w=Au(f,0,t[1]),b=Au(p,t[0],t[2]),_=Au(f,t[1],t[3]),S=t[0]-v,A=t[1]-w,k=t[2]-t[0]-b,I=t[3]-t[1]-_}const z=(n,s,l,u)=>{const p=zu(n.stretch-v,b,c,t.left),f=Mu(n.fixed-S,k,n.stretch,y),d=zu(s.stretch-w,_,h,t.top),g=Mu(s.fixed-A,I,s.stretch,m),x=zu(l.stretch-v,b,c,t.left),z=Mu(l.fixed-S,k,l.stretch,y),M=zu(u.stretch-w,_,h,t.top),P=Mu(u.fixed-A,I,u.stretch,m),C=new i(p,d),B=new i(x,d),V=new i(x,M),E=new i(p,M),F=new i(f/o,g/o),T=new i(z/o,P/o),D=e*Math.PI/180;if(D){const t=Math.sin(D),e=Math.cos(D),r=[e,-t,t,e];C._matMult(r),B._matMult(r),E._matMult(r),V._matMult(r)}const $=n.stretch+n.fixed,L=s.stretch+s.fixed;return{tl:C,tr:B,bl:E,br:V,tex:{x:a.paddedRect.x+Su+$,y:a.paddedRect.y+Su+L,w:l.stretch+l.fixed-$,h:u.stretch+u.fixed-L},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:T,minFontScaleX:k/o/c,minFontScaleY:I/o/h,isSDF:r}};if(n&&(a.stretchX||a.stretchY)){const t=Iu(p,g,y),e=Iu(f,x,m);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n)}else{let u=a.top*o-l[0],h=a.bottom*o+l[2],p=a.left*o-l[3],f=a.right*o+l[1];const d=a.collisionPadding;if(d&&(p-=d[0]*o,u-=d[1]*o,f+=d[2]*o,h+=d[3]*o),c){const t=new i(p,u),e=new i(f,u),r=new i(p,h),n=new i(f,h),s=c*Math.PI/180;t._rotate(s),e._rotate(s),r._rotate(s),n._rotate(s),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),u=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y)}t.emplaceBack(e.x,e.y,p,u,f,h,r,n,s)}this.boxEndIndex=t.length}}class Cu{constructor(t=[],e=Bu){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i}e[t]=n}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=s,t=n}e[t]=i}}function Bu(t,e){return te?1:0}function Vu(t,e=1,r=!1){let n=1/0,s=1/0,a=-1/0,o=-1/0;const l=t[0];for(let t=0;ta)&&(a=e.x),(!t||e.y>o)&&(o=e.y)}const u=Math.min(a-n,o-s);let c=u/2;const h=new Cu([],Eu);if(0===u)return new i(n,s);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Fu(n.p.x-c,n.p.y-c,c,t)),h.push(new Fu(n.p.x+c,n.p.y-c,c,t)),h.push(new Fu(n.p.x-c,n.p.y+c,c,t)),h.push(new Fu(n.p.x+c,n.p.y+c,c,t)),f+=4)}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Eu(t,e){return e.max-t.max}function Fu(t,e,r,n){this.p=new i(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Es(t,i,o))}}return(r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}var Tu;!function(t){t[t.center=1]="center",t[t.left=2]="left",t[t.right=3]="right",t[t.top=4]="top",t[t.bottom=5]="bottom",t[t["top-left"]=6]="top-left",t[t["top-right"]=7]="top-right",t[t["bottom-left"]=8]="bottom-left",t[t["bottom-right"]=9]="bottom-right"}(Tu||(Tu={}));const Du=7,$u=Number.POSITIVE_INFINITY;function Lu(t,e){return e[1]!==$u?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-Du;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+Du}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}return[n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=i-Du;break;case"bottom-right":case"bottom-left":n=-i+Du;break;case"bottom":n=-e+Du;break;case"top":n=e-Du}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e}return[r,n]}(t,e[0])}function Ou(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*No));n.startsWith("top")?i[1]-=Du:n.startsWith("bottom")&&(i[1]+=Du),e[r+1]=i}return new bt(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*No,$u]:i.get("text-offset").evaluate(e,{},r).map((t=>t*No));const s=[];for(const t of a)s.push(t,Lu(t,n));return new bt(s)}return null}function Uu(t){t.bucket.createArrays(),t.bucket.tilePixelRatio=vs/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;const e=t.bucket.layers[0],r=e.layout,n=e._unevaluatedLayout._values,i={layoutIconSize:n["icon-size"].possiblyEvaluate(new In(t.bucket.zoom+1),t.canonical),layoutTextSize:n["text-size"].possiblyEvaluate(new In(t.bucket.zoom+1),t.canonical),textMaxSize:n["text-size"].possiblyEvaluate(new In(18))};if("composite"===t.bucket.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.bucket.textSizeData;i.compositeTextSizes=[n["text-size"].possiblyEvaluate(new In(e),t.canonical),n["text-size"].possiblyEvaluate(new In(r),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.bucket.iconSizeData;i.compositeIconSizes=[n["icon-size"].possiblyEvaluate(new In(e),t.canonical),n["icon-size"].possiblyEvaluate(new In(r),t.canonical)]}const s=r.get("text-line-height")*No,a="viewport"!==r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),o=r.get("text-keep-upright"),l=r.get("text-size");for(const n of t.bucket.features){const u=r.get("text-font").evaluate(n,{},t.canonical).join(","),c=l.evaluate(n,{},t.canonical),h=i.layoutTextSize.evaluate(n,{},t.canonical),p=i.layoutIconSize.evaluate(n,{},t.canonical),f={horizontal:{},vertical:void 0},d=n.text;let m,g=[0,0];if(d){const i=d.toString(),l=r.get("text-letter-spacing").evaluate(n,{},t.canonical)*No,p=mn(i)?l:0,y=r.get("text-anchor").evaluate(n,{},t.canonical),m=Ou(e,n,t.canonical);if(!m){const e=r.get("text-radial-offset").evaluate(n,{},t.canonical);g=e?Lu(y,[e*No,$u]):r.get("text-offset").evaluate(n,{},t.canonical).map((t=>t*No))}let x=a?"center":r.get("text-justify").evaluate(n,{},t.canonical);const v=r.get("symbol-placement"),b="point"===v?r.get("text-max-width").evaluate(n,{},t.canonical)*No:0,w=()=>{t.bucket.allowVerticalPlacement&&yn(i)&&(f.vertical=Sl(d,t.glyphMap,t.glyphPositions,t.imagePositions,u,b,s,y,"left",p,g,vl.vertical,!0,v,h,c))};if(!a&&m){const e=new Set;if("auto"===x)for(let t=0;t{l.x<0||l.x>=vs||l.y<0||l.y>=vs||function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,g,x,v,b,w,_,S,k,A){const I=t.addToLineVertexArray(e,r);let z,M,P,C,B=0,V=0,E=0,F=0,T=-1,D=-1;const $={};let L=ts("");if(t.allowVerticalPlacement&&n.vertical){const t=o.layout.get("text-rotate").evaluate(w,{},k)+90;P=new Pu(l,e,u,c,h,n.vertical,p,f,d,t),a&&(C=new Pu(l,e,u,c,h,a,g,x,d,t))}if(i){const r=o.layout.get("icon-rotate").evaluate(w,{}),n="none"!==o.layout.get("icon-text-fit"),s=ku(i,r,S,n),p=a?ku(a,r,S,n):void 0;M=new Pu(l,e,u,c,h,i,g,x,!1,r),B=4*s.length;const f=t.iconSizeData;let d=null;"source"===f.kind?(d=[$l*o.layout.get("icon-size").evaluate(w,{})],d[0]>Ll&&y(`${t.layerIds[0]}: Value for "icon-size" is >= ${Dl}. Reduce your "icon-size".`)):"composite"===f.kind&&(d=[$l*_.compositeIconSizes[0].evaluate(w,{},k),$l*_.compositeIconSizes[1].evaluate(w,{},k)],(d[0]>Ll||d[1]>Ll)&&y(`${t.layerIds[0]}: Value for "icon-size" is >= ${Dl}. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,d,b,v,w,vl.none,e,I.lineStartIndex,I.lineLength,-1,k),T=t.icon.placedSymbolArray.length-1,p&&(V=4*p.length,t.addSymbols(t.icon,p,d,b,v,w,vl.vertical,e,I.lineStartIndex,I.lineLength,-1,k),D=t.icon.placedSymbolArray.length-1)}const O=Object.keys(n.horizontal);for(const r of O){const i=n.horizontal[r];if(!z){L=ts(i.text);const t=o.layout.get("text-rotate").evaluate(w,{},k);z=new Pu(l,e,u,c,h,i,p,f,d,t)}const a=1===i.positionedLines.length;if(E+=Ru(t,e,i,s,o,d,w,m,I,n.vertical?vl.horizontal:vl.horizontalOnly,a?O:[r],$,T,_,k),a)break}n.vertical&&(F+=Ru(t,e,n.vertical,s,o,d,w,m,I,vl.vertical,["vertical"],$,D,_,k));const U=z?z.boxStartIndex:t.collisionBoxArray.length,q=z?z.boxEndIndex:t.collisionBoxArray.length,j=P?P.boxStartIndex:t.collisionBoxArray.length,R=P?P.boxEndIndex:t.collisionBoxArray.length,N=M?M.boxStartIndex:t.collisionBoxArray.length,Z=M?M.boxEndIndex:t.collisionBoxArray.length,G=C?C.boxStartIndex:t.collisionBoxArray.length,J=C?C.boxEndIndex:t.collisionBoxArray.length;let K=-1;const X=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;K=X(z,K),K=X(P,K),K=X(M,K),K=X(C,K);const Y=K>-1?1:0;Y&&(K*=A/No),t.glyphOffsetArray.length>=Kl.MAX_GLYPHS&&y("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,w.sortKey);const H=Ou(o,w,k),[W,Q]=function(t,e){const r=t.length,n=null==e?void 0:e.values;if((null==n?void 0:n.length)>0)for(let e=0;e=0?$.right:-1,$.center>=0?$.center:-1,$.left>=0?$.left:-1,$.vertical||-1,T,D,L,U,q,j,R,N,Z,G,J,u,E,F,B,V,Y,0,p,K,W,Q)}(t,l,i,r,n,s,C,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,x,[_,_,_,_],A,u,b,S,I,d,e,a,c,h,o)};if("line"===z)for(const s of function(t,e,r,n,s){const a=[];for(let e=0;e=n&&l.x>=n||(e.x>=n?e=new i(n,e.y+(n-e.x)/(l.x-e.x)*(l.y-e.y))._round():l.x>=n&&(l=new i(n,e.y+(n-e.x)/(l.x-e.x)*(l.y-e.y))._round()),e.y>=s&&l.y>=s||(e.y>=s?e=new i(e.x+(s-e.y)/(l.y-e.y)*(l.x-e.x),s)._round():l.y>=s&&(l=new i(e.x+(s-e.y)/(l.y-e.y)*(l.x-e.x),s)._round()),o&&e.equals(o[o.length-1])||(o=[e],a.push(o)),o.push(l)))))}}return a}(e.geometry,0,0,vs,vs)){const e=wu(s,w,k,r.vertical||m,n,24,v,t.overscaling,vs);for(const r of e)m&&Zu(t,m.text,M,r)||B(s,r)}else if("line-center"===z){for(const t of e.geometry)if(t.length>1){const e=bu(t,k,r.vertical||m,n,24,v);e&&B(t,e)}}else if("Polygon"===e.type)for(const t of qa(e.geometry,0)){const e=Vu(t,16);B(t[0],new yu(e.x,e.y,0))}else if("LineString"===e.type)for(const t of e.geometry)B(t,new yu(t[0].x,t[0].y,0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)B([e],new yu(e.x,e.y,0))}function Ru(t,e,r,n,s,a,o,l,u,c,h,p,f,d,m){const g=function(t,e,r,n,s,a,o,l){const u=n.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const a=n.rect||{};let h=dl+1,p=!0,f=1,d=0;const y=(s||l)&&n.vertical,m=n.metrics.advance*n.scale/2;if(l&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(No-n.metrics.width*n.scale)/2:(n.scale-1)*No)),n.imageName){const t=o[n.imageName];p=t.sdf,f=t.pixelRatio,h=ml/f}const g=s?[n.x+m,n.y]:[0,0];let x=s?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],S=w+a.w/b*n.scale/f,k=_+a.h/b*n.scale/f,A=new i(w,_),I=new i(S,_),z=new i(w,k),M=new i(S,k);if(y){const t=new i(-m,m-bl),e=-Math.PI/2,r=No/2-m,s=new i(5-bl-r,-(n.imageName?r:0)),a=new i(...v);A._rotateAround(e,t)._add(s)._add(a),I._rotateAround(e,t)._add(s)._add(a),z._rotateAround(e,t)._add(s)._add(a),M._rotateAround(e,t)._add(s)._add(a)}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];A._matMult(r),I._matMult(r),z._matMult(r),M._matMult(r)}const P=new i(0,0),C=new i(0,0);c.push({tl:A,tr:I,bl:z,br:M,tex:a,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0})}return c}(0,r,l,s,a,o,n,t.allowVerticalPlacement),x=t.textSizeData;let v=null;"source"===x.kind?(v=[$l*s.layout.get("text-size").evaluate(o,{})],v[0]>Ll&&y(`${t.layerIds[0]}: Value for "text-size" is >= ${Dl}. Reduce your "text-size".`)):"composite"===x.kind&&(v=[$l*d.compositeTextSizes[0].evaluate(o,{},m),$l*d.compositeTextSizes[1].evaluate(o,{},m)],(v[0]>Ll||v[1]>Ll)&&y(`${t.layerIds[0]}: Value for "text-size" is >= ${Dl}. Reduce your "text-size".`)),t.addSymbols(t.text,g,v,l,a,o,c,e,u.lineStartIndex,u.lineLength,f,m);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*g.length}function Nu(t){for(const e in t)return t[e];return null}function Zu(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Xu(function(t,e,r){const n=((t-e)%360+360)%360+e;return n===e?180:n}(this.lng,-180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Ku*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Xu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Xu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Xu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Yu=2*Math.PI*Ku;function Hu(t){return Yu*Math.cos(t*Math.PI/180)}function Wu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class Qu{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r}static fromLngLat(t,e=0){const r=Xu.convert(t);return new Qu((180+r.lng)/360,(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r.lat*Math.PI/360)))/360,function(t,e){return t/Hu(e)}(e,r.lat))}toLngLat(){return new Xu(360*this.x-180,Wu(this.y))}toAltitude(){return this.z*Hu(Wu(this.y))}meterInMercatorCoordinateUnits(){return 1/Yu*(t=Wu(this.y),1/Math.cos(t*Math.PI/180));var t}}class tc{constructor(t,e,r){if(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=nc(0,t,t,e,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=Ju(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=Ju(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new i((t.x*e-this.x)*vs,(t.y*e-this.y)*vs)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ec{constructor(t,e){this.wrap=t,this.canonical=e,this.key=nc(t,e.z,e.z,e.x,e.y)}}class rc{constructor(t,e,r,n,i){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new tc(r,+n,+i),this.key=nc(e,t,r,n,i)}clone(){return new rc(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new rc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new rc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?nc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):nc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new rc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new rc(e,this.wrap,e,r,n),new rc(e,this.wrap,e,r+1,n),new rc(e,this.wrap,e,r,n+1),new rc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=e.maxzoom||"none"!==e.visibility&&(sc(t,this.zoom,r),(o[e.id]=e.createBucket({index:a.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:i,sourceID:this.source})).populate(c,l,this.tileID.canonical),a.bucketLayerIDs.push(t.map((t=>t.id))))}}let c,h,f,d;const m=p(l.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.cancel())),this.inFlightDependencies=[];const g=++this.dependencySentinel;Object.keys(m).length?this.inFlightDependencies.push(n.send("getGlyphs",{uid:this.uid,stacks:m,source:this.source,tileID:this.tileID,type:"glyphs"},((t,e)=>{g===this.dependencySentinel&&(c||(c=t,h=e,b.call(this)))}))):h={};const x=Object.keys(l.iconDependencies);x.length?this.inFlightDependencies.push(n.send("getImages",{icons:x,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{g===this.dependencySentinel&&(c||(c=t,f=e,b.call(this)))}))):f={};const v=Object.keys(l.patternDependencies);function b(){if(c)return i(c);if(h&&f&&d){const t=new Gu(h),e=new xl(f,d);for(const n in o){const i=o[n];i instanceof Kl?(sc(i.layers,this.zoom,r),Uu({bucket:i,glyphMap:h,glyphPositions:t.positions,imageMap:f,imagePositions:e.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):i.hasPattern&&(i instanceof Co||i instanceof Za||i instanceof yo)&&(sc(i.layers,this.zoom,r),i.addFeatures(l,this.tileID.canonical,e.patternPositions))}this.status="done",i(null,{buckets:Object.values(o).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,imageAtlas:e,glyphMap:this.returnDependencies?h:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?t.positions:null})}}v.length?this.inFlightDependencies.push(n.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{g===this.dependencySentinel&&(c||(c=t,d=e,b.call(this)))}))):d={},b.call(this)}}function sc(t,e,r){const n=new In(e);for(const e of t)e.recalculate(n,r)}var ac;!function(t){t.create="create",t.load="load",t.fullLoad="fullLoad"}(ac||(ac={}));class oc{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}}function lc(t,e){const r=function(t,e){return Yr(h(t,{type:"arrayBuffer"}),e)}(t.request,((r,n,i,s)=>{if(r)e(r);else if(n)try{const t=new Qa.VectorTile(new fl(n));e(null,{vectorTile:t,rawData:n,cacheControl:i,expires:s})}catch(r){const i=new Uint8Array(n);let s=`Unable to parse the tile at ${t.request.url}, `;s+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${r.messge}`,e(new Error(s))}}));return()=>{r.cancel(),e()}}class uc{constructor(t,e,r,n){this.actor=t,this.layerIndex=e,this.availableImages=r,this.loadVectorData=n||lc,this.fetching={},this.loading={},this.loaded={}}loadTile(t,e){const r=t.uid;this.loading||(this.loading={});const n=!!(t&&t.request&&t.request.collectResourceTiming)&&new oc(t.request),i=this.loading[r]=new ic(t);i.abort=this.loadVectorData(t,((t,s)=>{if(delete this.loading[r],t||!s)return i.status="done",this.loaded[r]=i,e(t);const a=s.rawData,o={};s.expires&&(o.expires=s.expires),s.cacheControl&&(o.cacheControl=s.cacheControl);const l={};if(n){const t=n.finish();t&&(l.resourceTiming=JSON.parse(JSON.stringify(t)))}i.vectorTile=s.vectorTile,i.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,n)=>{if(delete this.fetching[r],t||!n)return e(t);e(null,h({rawTileData:a.slice(0)},n,o,l))})),this.loaded=this.loaded||{},this.loaded[r]=i,this.fetching[r]={rawTileData:a,cacheControl:o,resourceTiming:l}}))}reloadTile(t,e){const r=this.loaded,n=t.uid;if(r&&r[n]){const i=r[n];i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status?i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,r)=>{if(t||!r)return e(t,r);let i;if(this.fetching[n]){const{rawTileData:t,cacheControl:e,resourceTiming:s}=this.fetching[n];delete this.fetching[n],i=h({rawTileData:t.slice(0)},r,e,s)}else i=r;e(null,i)})):"done"===i.status&&(i.vectorTile?i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,e):e())}}abortTile(t,e){const r=this.loading,n=t.uid;r&&r[n]&&r[n].abort&&(r[n].abort(),delete r[n]),e()}removeTile(t,e){const r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()}}class cc{constructor(t,e,r,n=1,i=1,s=1,a=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r))return void y(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const o=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),r){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=n,this.greenFactor=i,this.blueFactor=s,this.baseShift=a;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;tthis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new ra({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1}switch(r){case-1:s=a-1;break;case 1:a=s+1}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=Math.abs(o)?r-l+o:o-l+r,r=l}r+n>=0!=!!e&&t.reverse()}var dc=e((function t(e,r){var n,i=e&&e.type;if("FeatureCollection"===i)for(n=0;n>31}function Cc(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,s=0,a=r.length,o=0;o>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Ec[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Fc(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Ec.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Tc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a])}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u))}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Oc(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Oc(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u))}return o}}function Tc(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;Dc(t,e,a,n,i,s),Tc(t,e,r,n,a-1,1-s),Tc(t,e,r,a+1,i,1-s)}function Dc(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);Dc(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s)}const a=e[2*r+s];let o=n,l=i;for($c(t,e,n,r),e[2*i+s]>a&&$c(t,e,n,i);oa;)l--}e[2*n+s]===a?$c(t,e,n,l):(l++,$c(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1)}}function $c(t,e,r,n){Lc(t,r,n),Lc(e,2*r,2*n),Lc(e,2*r+1,2*n+1)}function Lc(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function Oc(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}const Uc={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},qc=Math.fround||(jc=new Float32Array(1),t=>(jc[0]=+t,jc[0]));var jc;const Rc=3,Nc=5,Zc=6;class Gc{constructor(t){this.options=Object.assign(Object.create(Uc),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:r,maxZoom:n}=this.options;e&&console.time("total time");const i=`prepare ${t.length} points`;e&&console.time(i),this.points=t;const s=[];for(let e=0;e=r;t--){const r=+Date.now();a=this.trees[t]=this._createTree(this._cluster(a,t)),e&&console.log("z%d: %d clusters in %dms",t,a.numItems,+Date.now()-r)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let r=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let i=180===t[2]?180:((t[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,i=180;else if(r>i){const t=this.getClusters([r,n,180,s],e),a=this.getClusters([-180,n,i,s],e);return t.concat(a)}const a=this.trees[this._limitZoom(e)],o=a.range(Xc(r),Yc(s),Xc(i),Yc(n)),l=a.data,u=[];for(const t of o){const e=this.stride*t;u.push(l[e+Nc]>1?Jc(l,e,this.clusterProps):this.points[l[e+Rc]])}return u}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),n="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(n);const s=i.data;if(e*this.stride>=s.length)throw new Error(n);const a=this.options.radius/(this.options.extent*Math.pow(2,r-1)),o=i.within(s[e*this.stride],s[e*this.stride+1],a),l=[];for(const e of o){const r=e*this.stride;s[r+4]===t&&l.push(s[r+Nc]>1?Jc(s,r,this.clusterProps):this.points[s[r+Rc]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,r){const n=[];return this._appendLeaves(n,t,e=e||10,r=r||0,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],i=Math.pow(2,t),{extent:s,radius:a}=this.options,o=a/s,l=(r-o)/i,u=(r+1+o)/i,c={features:[]};return this._addTileFeatures(n.range((e-o)/i,l,(e+1+o)/i,u),n.data,e,r,i,c),0===e&&this._addTileFeatures(n.range(1-o/i,l,1,u),n.data,i,r,i,c),e===i-1&&this._addTileFeatures(n.range(0,l,o/i,u),n.data,-1,r,i,c),c.features.length?c:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const r=this.getChildren(t);if(e++,1!==r.length)break;t=r[0].properties.cluster_id}return e}_appendLeaves(t,e,r,n,i){const s=this.getChildren(e);for(const e of s){const s=e.properties;if(s&&s.cluster?i+s.point_count<=n?i+=s.point_count:i=this._appendLeaves(t,s.cluster_id,r,n,i):i1;let l,u,c;if(o)l=Kc(e,t,this.clusterProps),u=e[t],c=e[t+1];else{const r=this.points[e[t+Rc]];l=r.properties;const[n,i]=r.geometry.coordinates;u=Xc(n),c=Yc(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-r)),Math.round(this.options.extent*(c*i-n))]],tags:l};let p;p=o||this.options.generateId?e[t+Rc]:this.points[e[t+Rc]].id,void 0!==p&&(h.id=p),s.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:r,extent:n,reduce:i,minPoints:s}=this.options,a=r/(n*Math.pow(2,e)),o=t.data,l=[],u=this.stride;for(let r=0;re&&(f+=o[r+Nc])}if(f>p&&f>=s){let t,s=n*p,a=c*p,d=-1;const y=((r/u|0)<<5)+(e+1)+this.points.length;for(const n of h){const l=n*u;if(o[l+2]<=e)continue;o[l+2]=e;const c=o[l+Nc];s+=o[l]*c,a+=o[l+1]*c,o[l+4]=y,i&&(t||(t=this._map(o,r,!0),d=this.clusterProps.length,this.clusterProps.push(t)),i(t,this._map(o,l)))}o[r+4]=y,l.push(s/f,a/f,1/0,y,-1,f),i&&l.push(d)}else{for(let t=0;t1)for(const t of h){const r=t*u;if(!(o[r+2]<=e)){o[r+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+Nc]>1){const n=this.clusterProps[t[e+Zc]];return r?Object.assign({},n):n}const n=this.points[t[e+Rc]].properties,i=this.options.map(n);return r&&i===n?Object.assign({},i):i}}function Jc(t,e,r){return{type:"Feature",id:t[e+Rc],properties:Kc(t,e,r),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Hc(t[e+1])]}};var n}function Kc(t,e,r){const n=t[e+Nc],i=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,s=t[e+Zc],a=-1===s?{}:Object.assign({},r[s]);return Object.assign(a,{cluster:!0,cluster_id:t[e+Rc],point_count:n,point_count_abbreviated:i})}function Xc(t){return t/360+.5}function Yc(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function Hc(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function Wc(t,e,r,n){for(var i,s=n,a=r-e>>1,o=r-e,l=t[e],u=t[e+1],c=t[r],h=t[r+1],p=e+3;ps)i=p,s=f;else if(f===s){var d=Math.abs(p-a);dn&&(i-e>3&&Wc(t,e,i,n),t[i+2]=s,r-i>3&&Wc(t,i,r,n))}function Qc(t,e,r,n,i,s){var a=i-r,o=s-n;if(0!==a||0!==o){var l=((t-r)*a+(e-n)*o)/(a*a+o*o);l>1?(r=i,n=s):l>0&&(r+=a*l,n+=o*l)}return(a=t-r)*a+(o=e-n)*o}function th(t,e,r,n){var i={id:void 0===t?null:t,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)eh(t,e);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n0&&(a+=n?(i*u-l*s)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-s,2))),i=l,s=u}var c=e.length-3;e[2]=1,Wc(e,0,c,r),e[c+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function sh(t,e,r,n){for(var i=0;i1?1:r}function lh(t,e,r,n,i,s,a,o){if(n/=e,s>=(r/=e)&&a=n)return null;for(var l=[],u=0;u=r&&d=n)){var y=[];if("Point"===p||"MultiPoint"===p)uh(h,y,r,n,i);else if("LineString"===p)ch(h,y,r,n,i,!1,o.lineMetrics);else if("MultiLineString"===p)ph(h,y,r,n,i,!1);else if("Polygon"===p)ph(h,y,r,n,i,!0);else if("MultiPolygon"===p)for(var m=0;m=r&&a<=n&&(e.push(t[s]),e.push(t[s+1]),e.push(t[s+2]))}}function ch(t,e,r,n,i,s,a){for(var o,l,u=hh(t),c=0===i?dh:yh,h=t.start,p=0;pr&&(l=c(u,f,d,m,g,r),a&&(u.start=h+o*l)):x>n?v=r&&(l=c(u,f,d,m,g,r),b=!0),v>n&&x<=n&&(l=c(u,f,d,m,g,n),b=!0),!s&&b&&(a&&(u.end=h+o*l),e.push(u),u=hh(t)),a&&(h+=o)}var w=t.length-3;f=t[w],d=t[w+1],y=t[w+2],(x=0===i?f:d)>=r&&x<=n&&fh(u,f,d,y),w=u.length-3,s&&w>=3&&(u[w]!==u[0]||u[w+1]!==u[1])&&fh(u,u[0],u[1],u[2]),u.length&&e.push(u)}function hh(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function ph(t,e,r,n,i,s){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function wh(t,e,r,n){var i=e.geometry,s=e.type,a=[];if("Point"===s||"MultiPoint"===s)for(var o=0;o0&&e.size<(i?a:n))r.numPoints+=e.length/3;else{for(var o=[],l=0;la)&&(r.numSimplified++,o.push(e[l]),o.push(e[l+1])),r.numPoints++;i&&function(t,e){for(var r=0,n=0,i=t.length,s=i-2;n0===e)for(n=0,i=t.length;n24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=function(t,e){var r=[];if("FeatureCollection"===t.type)for(var n=0;n1&&console.time("creation"),p=this.tiles[h]=bh(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+e;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(p.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var y,m,g,x,v,b,w=.5*l.buffer/l.extent,_=.5-w,S=.5+w,k=1+w;y=m=g=x=null,v=lh(t,c,r-w,r+S,0,p.minX,p.maxX,l),b=lh(t,c,r+_,r+k,0,p.minX,p.maxX,l),t=null,v&&(y=lh(v,c,n-w,n+S,1,p.minY,p.maxY,l),m=lh(v,c,n+_,n+k,1,p.minY,p.maxY,l),v=null),b&&(g=lh(b,c,n-w,n+S,1,p.minY,p.maxY,l),x=lh(b,c,n+_,n+k,1,p.minY,p.maxY,l),b=null),u>1&&console.timeEnd("clipping"),o.push(y||[],e+1,2*r,2*n),o.push(m||[],e+1,2*r,2*n+1),o.push(g||[],e+1,2*r+1,2*n),o.push(x||[],e+1,2*r+1,2*n+1)}}},Sh.prototype.getTile=function(t,e,r){var n=this.options,i=n.extent,s=n.debug;if(t<0||t>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);for(var l,u=t,c=e,h=r;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[kh(u,c,h)];return l&&l.source?(s>1&&console.log("found parent tile z%d-%d-%d",u,c,h),s>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,t,e,r),s>1&&console.timeEnd("drilling down"),this.tiles[o]?xh(this.tiles[o],i):null):null};class Mh extends uc{constructor(t,e,r,n){super(t,e,r),this._dataUpdateable=new Map,this.loadGeoJSON=(t,e)=>{const{promoteId:r}=t;if(t.request)return function(t,e){return Yr(h(t,{type:"json"}),e)}(t.request,((t,n,i,s)=>{this._dataUpdateable=Ih(n,r)?zh(n,r):void 0,e(t,n,i,s)}));if("string"==typeof t.data)try{const n=JSON.parse(t.data);this._dataUpdateable=Ih(n,r)?zh(n,r):void 0,e(null,n)}catch(r){e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}else t.dataDiff?this._dataUpdateable?(function(t,e,r){var n,i,s,a;if(e.removeAll&&t.clear(),e.remove)for(const r of e.remove)t.delete(r);if(e.add)for(const n of e.add){const e=Ah(n,r);null!=e&&t.set(e,n)}if(e.update)for(const r of e.update){let e=t.get(r.id);if(null==e)continue;const o=!r.removeAllProperties&&((null===(n=r.removeProperties)||void 0===n?void 0:n.length)>0||(null===(i=r.addOrUpdateProperties)||void 0===i?void 0:i.length)>0);if((r.newGeometry||r.removeAllProperties||o)&&(e=Object.assign({},e),t.set(r.id,e),o&&(e.properties=Object.assign({},e.properties))),r.newGeometry&&(e.geometry=r.newGeometry),r.removeAllProperties)e.properties={};else if((null===(s=r.removeProperties)||void 0===s?void 0:s.length)>0)for(const t of r.removeProperties)Object.prototype.hasOwnProperty.call(e.properties,t)&&delete e.properties[t];if((null===(a=r.addOrUpdateProperties)||void 0===a?void 0:a.length)>0)for(const{key:t,value:n}of r.addOrUpdateProperties)e.properties[t]=n}}(this._dataUpdateable,t.dataDiff,r),e(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):e(new Error(`Cannot update existing geojson data in ${t.source}`)):e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},this.loadVectorData=this.loadGeoJSONTile,n&&(this.loadGeoJSON=n)}loadGeoJSONTile(t,e){const r=t.tileID.canonical;if(!this._geoJSONIndex)return e(null,null);const n=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!n)return e(null,null);const s=new class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=vs,this.length=t.length,this._features=t}feature(t){return new class{constructor(t){this._feature=t,this.extent=vs,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const e of this._feature.geometry)t.push([new i(e[0],e[1])]);return t}{const t=[];for(const e of this._feature.geometry){const r=[];for(const t of e)r.push(new i(t[0],t[1]));t.push(r)}return t}}toGeoJSON(t,e,r){return yc.call(this,t,e,r)}}(this._features[t])}}(n.features);let a=Vc(s);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),e(null,{vectorTile:s,rawData:a.buffer})}loadData(t,e){var r;null===(r=this._pendingRequest)||void 0===r||r.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const n=!!(t&&t.request&&t.request.collectResourceTiming)&&new oc(t.request);this._pendingCallback=e,this._pendingRequest=this.loadGeoJSON(t,((r,i)=>{if(delete this._pendingCallback,delete this._pendingRequest,r||!i)return e(r);if("object"!=typeof i)return e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{dc(i,!0);try{if(t.filter){const e=tr(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=i.features.filter((t=>e.value.evaluate({zoom:0},t)));i={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new Gc(function({superclusterOptions:t,clusterProperties:e}){if(!e||!t)return t;const r={},n={},i={accumulated:null,zoom:0},s={properties:null},a=Object.keys(e);for(const t of a){const[i,s]=e[t],a=tr(s),o=tr("string"==typeof i?[i,["accumulated"],["get",t]]:i);r[t]=a.value,n[t]=o.value}return t.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(i,s);return e},t.reduce=(t,e)=>{s.properties=e;for(const e of a)i.accumulated=t[e],t[e]=n[e].evaluate(i,s)},t}(t)).load(i.features):function(t,e){return new Sh(t,e)}(i,t.geojsonVtOptions)}catch(r){return e(r)}this.loaded={};const s={};if(n){const e=n.finish();e&&(s.resourceTiming={},s.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)))}e(null,s)}}))}reloadTile(t,e){const r=this.loaded;return r&&r[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}removeSource(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class Ph{constructor(t){this.self=t,this.actor=new nn(t,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:uc,geojson:Mh},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=t=>{if(An.isParsed())throw new Error("RTL text plugin already registered.");An.applyArabicShaping=t.applyArabicShaping,An.processBidirectionalText=t.processBidirectionalText,An.processStyledBidirectionalText=t.processStyledBidirectionalText}}setReferrer(t,e){this.referrer=e}setImages(t,e,r){this.availableImages[t]=e;for(const r in this.workerSources[t]){const n=this.workerSources[t][r];for(const t in n)n[t].availableImages=e}r()}setLayers(t,e,r){this.getLayerIndex(t).replace(e),r()}updateLayers(t,e,r){this.getLayerIndex(t).update(e.layers,e.removedIds),r()}loadTile(t,e,r){this.getWorkerSource(t,e.type,e.source).loadTile(e,r)}loadDEMTile(t,e,r){this.getDEMWorkerSource(t,e.source).loadTile(e,r)}reloadTile(t,e,r){this.getWorkerSource(t,e.type,e.source).reloadTile(e,r)}abortTile(t,e,r){this.getWorkerSource(t,e.type,e.source).abortTile(e,r)}removeTile(t,e,r){this.getWorkerSource(t,e.type,e.source).removeTile(e,r)}removeDEMTile(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)}removeSource(t,e,r){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const n=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==n.removeSource?n.removeSource(e,r):r()}loadWorkerSource(t,e,r){try{this.self.importScripts(e.url),r()}catch(t){r(t.toString())}}syncRTLPluginState(t,e,r){try{An.setState(e);const t=An.getPluginURL();if(An.isLoaded()&&!An.isParsed()&&null!=t){this.self.importScripts(t);const e=An.isParsed();r(e?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),e)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new lu),e}getWorkerSource(t,e,r){return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][r]||(this.workerSources[t][e][r]=new this.workerSourceTypes[e]({send:(e,r,n)=>{this.actor.send(e,r,n,t)}},this.getLayerIndex(t),this.getAvailableImages(t))),this.workerSources[t][e][r]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new hc),this.demWorkerSources[t][e]}}return x()&&(self.worker=new Ph(self)),Ph}(); +//# sourceMappingURL=maplibre-gl-csp-worker.js.map diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl-csp-worker.js.map b/web/libraries/maplibre-gl/dist/maplibre-gl-csp-worker.js.map new file mode 100644 index 00000000..36580b5c --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl-csp-worker.js.map @@ -0,0 +1 @@ +{"version":3,"file":"maplibre-gl-csp-worker.js","sources":["../node_modules/tslib/tslib.es6.js","../node_modules/@mapbox/point-geometry/index.js","../node_modules/@mapbox/unitbezier/index.js","../src/util/offscreen_canvas_supported.ts","../src/util/offscreen_canvas_distorted.ts","../src/util/util.ts","../src/util/transferable_grid_index.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.mjs","../src/util/config.ts","../src/util/ajax.ts","../src/util/web_worker_transfer.ts","../src/util/throttled_invoker.ts","../src/util/actor.ts","../src/util/evented.ts","../src/style/validate_style.ts","../src/style/zoom_history.ts","../src/util/is_char_in_unicode_block.ts","../src/util/script_detection.ts","../src/util/browser.ts","../src/source/rtl_text_plugin.ts","../src/style/evaluation_parameters.ts","../src/style/properties.ts","../src/style/style_layer.ts","../src/util/struct_array.ts","../src/data/array_types.g.ts","../src/data/bucket/circle_attributes.ts","../src/data/segment.ts","../src/shaders/encode_attribute.ts","../src/data/bucket/pattern_attributes.ts","../node_modules/murmurhash-js/murmurhash3_gc.js","../node_modules/murmurhash-js/murmurhash2_gc.js","../node_modules/murmurhash-js/index.js","../src/data/feature_position_map.ts","../src/render/uniform_binding.ts","../src/data/program_configuration.ts","../src/data/extent.ts","../src/data/load_geometry.ts","../src/data/evaluation_feature.ts","../src/data/bucket/circle_bucket.ts","../src/util/intersection_tests.ts","../src/style/query_utils.ts","../src/style/style_layer/circle_style_layer_properties.g.ts","../node_modules/gl-matrix/esm/vec4.js","../node_modules/gl-matrix/esm/common.js","../node_modules/gl-matrix/esm/mat4.js","../src/style/style_layer/circle_style_layer.ts","../src/data/bucket/heatmap_bucket.ts","../src/style/style_layer/heatmap_style_layer_properties.g.ts","../src/util/image.ts","../src/style/style_layer/heatmap_style_layer.ts","../src/util/color_ramp.ts","../src/style/style_layer/hillshade_style_layer_properties.g.ts","../src/style/style_layer/hillshade_style_layer.ts","../src/data/bucket/fill_attributes.ts","../node_modules/earcut/src/earcut.js","../node_modules/quickselect/index.js","../src/util/classify_rings.ts","../src/data/bucket/pattern_bucket_features.ts","../src/data/bucket/fill_bucket.ts","../src/style/style_layer/fill_style_layer_properties.g.ts","../src/style/style_layer/fill_style_layer.ts","../src/data/bucket/fill_extrusion_attributes.ts","../node_modules/@mapbox/vector-tile/lib/vectortilefeature.js","../node_modules/@mapbox/vector-tile/lib/vectortilelayer.js","../node_modules/@mapbox/vector-tile/lib/vectortile.js","../node_modules/@mapbox/vector-tile/index.js","../src/data/bucket/fill_extrusion_bucket.ts","../src/style/style_layer/fill_extrusion_style_layer_properties.g.ts","../src/style/style_layer/fill_extrusion_style_layer.ts","../src/data/bucket/line_attributes.ts","../src/data/bucket/line_attributes_ext.ts","../src/data/bucket/line_bucket.ts","../src/style/style_layer/line_style_layer_properties.g.ts","../src/style/style_layer/line_style_layer.ts","../src/data/bucket/symbol_attributes.ts","../src/symbol/transform_text.ts","../src/util/verticalize_punctuation.ts","../src/symbol/one_em.ts","../node_modules/pbf/index.js","../node_modules/ieee754/index.js","../src/style/parse_glyph_pbf.ts","../node_modules/potpack/index.js","../src/render/image_atlas.ts","../src/symbol/shaping.ts","../src/symbol/symbol_size.ts","../src/style/style_layer/overlap_mode.ts","../src/data/bucket/symbol_bucket.ts","../src/symbol/merge_lines.ts","../src/style/style_layer/symbol_style_layer_properties.g.ts","../src/style/format_section_override.ts","../src/style/style_layer/symbol_style_layer.ts","../src/util/resolve_tokens.ts","../src/style/style_layer/background_style_layer_properties.g.ts","../src/style/style_layer/background_style_layer.ts","../src/style/style_layer/raster_style_layer_properties.g.ts","../src/style/style_layer/raster_style_layer.ts","../src/style/style_layer/custom_style_layer.ts","../src/style/create_style_layer.ts","../src/style/style_layer_index.ts","../src/util/dictionary_coder.ts","../src/util/vectortile_to_geojson.ts","../src/data/feature_index.ts","../src/symbol/anchor.ts","../src/symbol/check_max_angle.ts","../src/symbol/get_anchors.ts","../src/symbol/quads.ts","../src/symbol/collision_feature.ts","../node_modules/tinyqueue/index.js","../src/util/find_pole_of_inaccessibility.ts","../src/style/style_layer/variable_text_anchor.ts","../src/symbol/symbol_layout.ts","../src/symbol/clip_line.ts","../src/render/glyph_atlas.ts","../node_modules/@mapbox/whoots-js/index.mjs","../src/geo/lng_lat.ts","../src/geo/mercator_coordinate.ts","../src/source/tile_id.ts","../src/source/worker_tile.ts","../src/util/performance.ts","../src/source/vector_tile_worker_source.ts","../src/data/dem_data.ts","../src/source/raster_dem_tile_worker_source.ts","../node_modules/@mapbox/geojson-rewind/index.js","../src/source/geojson_wrapper.ts","../node_modules/vt-pbf/lib/geojson_wrapper.js","../node_modules/vt-pbf/index.js","../node_modules/kdbush/index.js","../node_modules/supercluster/index.js","../node_modules/geojson-vt/src/simplify.js","../node_modules/geojson-vt/src/feature.js","../node_modules/geojson-vt/src/convert.js","../node_modules/geojson-vt/src/clip.js","../node_modules/geojson-vt/src/wrap.js","../node_modules/geojson-vt/src/transform.js","../node_modules/geojson-vt/src/tile.js","../node_modules/geojson-vt/src/index.js","../src/source/geojson_source_diff.ts","../src/source/geojson_worker_source.ts","../src/source/worker.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","'use strict';\n\nmodule.exports = Point;\n\n/**\n * A standalone point geometry with useful accessor, comparison, and\n * modification methods.\n *\n * @class Point\n * @param {Number} x the x-coordinate. this could be longitude or screen\n * pixels, or any other sort of unit.\n * @param {Number} y the y-coordinate. this could be latitude or screen\n * pixels, or any other sort of unit.\n * @example\n * var point = new Point(-77, 38);\n */\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n}\n\nPoint.prototype = {\n\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone: function() { return new Point(this.x, this.y); },\n\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add: function(p) { return this.clone()._add(p); },\n\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub: function(p) { return this.clone()._sub(p); },\n\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint: function(p) { return this.clone()._multByPoint(p); },\n\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint: function(p) { return this.clone()._divByPoint(p); },\n\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n mult: function(k) { return this.clone()._mult(k); },\n\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n div: function(k) { return this.clone()._div(k); },\n\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate: function(a) { return this.clone()._rotate(a); },\n\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); },\n\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {Array} m transformation matrix\n * @return {Point} output point\n */\n matMult: function(m) { return this.clone()._matMult(m); },\n\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit: function() { return this.clone()._unit(); },\n\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp: function() { return this.clone()._perp(); },\n\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round: function() { return this.clone()._round(); },\n\n /**\n * Return the magitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {Number} magnitude\n */\n mag: function() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals: function(other) {\n return this.x === other.x &&\n this.y === other.y;\n },\n\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {Number} distance\n */\n dist: function(p) {\n return Math.sqrt(this.distSqr(p));\n },\n\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {Number} distance\n */\n distSqr: function(p) {\n var dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {Number} angle\n */\n angle: function() {\n return Math.atan2(this.y, this.x);\n },\n\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleTo: function(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleWith: function(b) {\n return this.angleWithSep(b.x, b.y);\n },\n\n /*\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(θ) for θ.\n * @param {Number} x the x-coordinate\n * @param {Number} y the y-coordinate\n * @return {Number} the angle in radians\n */\n angleWithSep: function(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y);\n },\n\n _matMult: function(m) {\n var x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _add: function(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n\n _sub: function(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n\n _mult: function(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n\n _div: function(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n\n _multByPoint: function(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n\n _divByPoint: function(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n\n _unit: function() {\n this._div(this.mag());\n return this;\n },\n\n _perp: function() {\n var y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n\n _rotate: function(angle) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _rotateAround: function(angle, p) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n\n _round: function() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n }\n};\n\n/**\n * Construct a point from an array if necessary, otherwise if the input\n * is already a Point, or an unknown type, return it unchanged\n * @param {Array|Point|*} a any kind of input value\n * @return {Point} constructed point, or passed-through value.\n * @example\n * // this\n * var point = Point.convert([0, 1]);\n * // is equivalent to\n * var point = new Point(0, 1);\n */\nPoint.convert = function (a) {\n if (a instanceof Point) {\n return a;\n }\n if (Array.isArray(a)) {\n return new Point(a[0], a[1]);\n }\n return a;\n};\n","'use strict';\n\nmodule.exports = UnitBezier;\n\nfunction UnitBezier(p1x, p1y, p2x, p2y) {\n // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n this.cx = 3.0 * p1x;\n this.bx = 3.0 * (p2x - p1x) - this.cx;\n this.ax = 1.0 - this.cx - this.bx;\n\n this.cy = 3.0 * p1y;\n this.by = 3.0 * (p2y - p1y) - this.cy;\n this.ay = 1.0 - this.cy - this.by;\n\n this.p1x = p1x;\n this.p1y = p1y;\n this.p2x = p2x;\n this.p2y = p2y;\n}\n\nUnitBezier.prototype = {\n sampleCurveX: function (t) {\n // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n return ((this.ax * t + this.bx) * t + this.cx) * t;\n },\n\n sampleCurveY: function (t) {\n return ((this.ay * t + this.by) * t + this.cy) * t;\n },\n\n sampleCurveDerivativeX: function (t) {\n return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n },\n\n solveCurveX: function (x, epsilon) {\n if (epsilon === undefined) epsilon = 1e-6;\n\n if (x < 0.0) return 0.0;\n if (x > 1.0) return 1.0;\n\n var t = x;\n\n // First try a few iterations of Newton's method - normally very fast.\n for (var i = 0; i < 8; i++) {\n var x2 = this.sampleCurveX(t) - x;\n if (Math.abs(x2) < epsilon) return t;\n\n var d2 = this.sampleCurveDerivativeX(t);\n if (Math.abs(d2) < 1e-6) break;\n\n t = t - x2 / d2;\n }\n\n // Fall back to the bisection method for reliability.\n var t0 = 0.0;\n var t1 = 1.0;\n t = x;\n\n for (i = 0; i < 20; i++) {\n x2 = this.sampleCurveX(t);\n if (Math.abs(x2 - x) < epsilon) break;\n\n if (x > x2) {\n t0 = t;\n } else {\n t1 = t;\n }\n\n t = (t1 - t0) * 0.5 + t0;\n }\n\n return t;\n },\n\n solve: function (x, epsilon) {\n return this.sampleCurveY(this.solveCurveX(x, epsilon));\n }\n};\n","let supportsOffscreenCanvas: boolean;\n\nexport function offscreenCanvasSupported(): boolean {\n if (supportsOffscreenCanvas == null) {\n supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&\n new OffscreenCanvas(1, 1).getContext('2d') &&\n typeof createImageBitmap === 'function';\n }\n\n return supportsOffscreenCanvas;\n}\n","import {offscreenCanvasSupported} from './offscreen_canvas_supported';\n\nlet offscreenCanvasDistorted: boolean;\n\n/**\n * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185).\n * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false\n * if they don't match.\n *\n * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise.\n */\nexport function isOffscreenCanvasDistorted(): boolean {\n if (offscreenCanvasDistorted == null) {\n offscreenCanvasDistorted = false;\n if (offscreenCanvasSupported()) {\n const size = 5;\n const canvas = new OffscreenCanvas(size, size);\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (context) {\n // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel):\n // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...]\n for (let i = 0; i < size * size; i++) {\n const base = i * 4;\n context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;\n context.fillRect(i % size, Math.floor(i / size), 1, 1);\n }\n const data = context.getImageData(0, 0, size, size).data;\n for (let i = 0; i < size * size * 4; i++) {\n if (i % 4 !== 3 && data[i] !== i) {\n offscreenCanvasDistorted = true;\n break;\n }\n }\n }\n }\n }\n\n return offscreenCanvasDistorted || false;\n}\n","import Point from '@mapbox/point-geometry';\nimport UnitBezier from '@mapbox/unitbezier';\nimport type {Callback} from '../types/callback';\nimport {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted';\nimport type {Size} from './image';\n\n/**\n * Given a value `t` that varies between 0 and 1, return\n * an interpolation function that eases between 0 and 1 in a pleasing\n * cubic in-out fashion.\n */\nexport function easeCubicInOut(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n const t2 = t * t,\n t3 = t2 * t;\n return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75);\n}\n\n/**\n * Given given (x, y), (x1, y1) control points for a bezier curve,\n * return a function that interpolates along that curve.\n *\n * @param p1x - control point 1 x coordinate\n * @param p1y - control point 1 y coordinate\n * @param p2x - control point 2 x coordinate\n * @param p2y - control point 2 y coordinate\n */\nexport function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {\n const bezier = new UnitBezier(p1x, p1y, p2x, p2y);\n return function(t: number) {\n return bezier.solve(t);\n };\n}\n\n/**\n * A default bezier-curve powered easing function with\n * control points (0.25, 0.1) and (0.25, 1)\n */\nexport const defaultEasing = bezier(0.25, 0.1, 0.25, 1);\n\n/**\n * constrain n to the given range via min + max\n *\n * @param n - value\n * @param min - the minimum value to be returned\n * @param max - the maximum value to be returned\n * @returns the clamped value\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/**\n * constrain n to the given range, excluding the minimum, via modular arithmetic\n *\n * @param n - value\n * @param min - the minimum value to be returned, exclusive\n * @param max - the maximum value to be returned, inclusive\n * @returns constrained number\n */\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((n - min) % d + d) % d + min;\n return (w === min) ? max : w;\n}\n\n/**\n * Call an asynchronous function on an array of arguments,\n * calling `callback` with the completed results of all calls.\n *\n * @param array - input to each call of the async function.\n * @param fn - an async function with signature (data, callback)\n * @param callback - a callback run after all async work is done.\n * called with an array, containing the results of each async call.\n */\nexport function asyncAll(\n array: Array,\n fn: (item: Item, fnCallback: Callback) => void,\n callback: Callback>\n) {\n if (!array.length) { return callback(null, []); }\n let remaining = array.length;\n const results = new Array(array.length);\n let error = null;\n array.forEach((item, i) => {\n fn(item, (err, result) => {\n if (err) error = err;\n results[i] = (result as any as Result); // https://github.com/facebook/flow/issues/2123\n if (--remaining === 0) callback(error, results);\n });\n });\n}\n\n/**\n * Compute the difference between the keys in one object and the keys\n * in another object.\n *\n * @returns keys difference\n */\nexport function keysDifference(\n obj: {[key: string]: S},\n other: {[key: string]: T}\n): Array {\n const difference = [];\n for (const i in obj) {\n if (!(i in other)) {\n difference.push(i);\n }\n }\n return difference;\n}\n\n/**\n * Given a destination object and optionally many source objects,\n * copy all properties from the source objects into the destination.\n * The last source object given overrides properties from previous\n * source objects.\n *\n * @param dest - destination object\n * @param sources - sources from which properties are pulled\n */\nexport function extend(dest: any, ...sources: Array): any {\n for (const src of sources) {\n for (const k in src) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n/**\n * Given an object and a number of properties as strings, return version\n * of that object with only those properties.\n *\n * @param src - the object\n * @param properties - an array of property names chosen\n * to appear on the resulting object.\n * @returns object with limited properties.\n * @example\n * ```ts\n * let foo = { name: 'Charlie', age: 10 };\n * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' }\n * ```\n */\nexport function pick(src: any, properties: Array): any {\n const result = {};\n for (let i = 0; i < properties.length; i++) {\n const k = properties[i];\n if (k in src) {\n result[k] = src[k];\n }\n }\n return result;\n}\n\nlet id = 1;\n\n/**\n * Return a unique numeric id, starting at 1 and incrementing with\n * each call.\n *\n * @returns unique numeric id.\n */\nexport function uniqueId(): number {\n return id++;\n}\n\n/**\n * Return whether a given value is a power of two\n */\nexport function isPowerOfTwo(value: number): boolean {\n return (Math.log(value) / Math.LN2) % 1 === 0;\n}\n\n/**\n * Return the next power of two, or the input value if already a power of two\n */\nexport function nextPowerOfTwo(value: number): number {\n if (value <= 1) return 1;\n return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/**\n * Create an object by mapping all the values of an existing object while\n * preserving their keys.\n */\nexport function mapObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n output[key] = iterator.call(context || this, input[key], key, input);\n }\n return output;\n}\n\n/**\n * Create an object by filtering out values of an existing object.\n */\nexport function filterObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n if (iterator.call(context || this, input[key], key, input)) {\n output[key] = input[key];\n }\n }\n return output;\n}\n\n/**\n * Deeply compares two object literals.\n * @param a - first object literal to be compared\n * @param b - second object literal to be compared\n * @returns true if the two object literals are deeply equal, false otherwise\n */\nexport function deepEqual(a?: unknown | null, b?: unknown | null): boolean {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object')) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key])) return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * Deeply clones two objects.\n */\nexport function clone(input: T): T {\n if (Array.isArray(input)) {\n return input.map(clone) as any as T;\n } else if (typeof input === 'object' && input) {\n return mapObject(input, clone) as any as T;\n } else {\n return input;\n }\n}\n\n/**\n * Check if two arrays have at least one common element.\n */\nexport function arraysIntersect(a: Array, b: Array): boolean {\n for (let l = 0; l < a.length; l++) {\n if (b.indexOf(a[l]) >= 0) return true;\n }\n return false;\n}\n\n/**\n * Print a warning message to the console and ensure duplicate warning messages\n * are not printed.\n */\nconst warnOnceHistory: {[key: string]: boolean} = {};\n\nexport function warnOnce(message: string): void {\n if (!warnOnceHistory[message]) {\n // console isn't defined in some WebWorkers, see #2558\n if (typeof console !== 'undefined') console.warn(message);\n warnOnceHistory[message] = true;\n }\n}\n\n/**\n * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order\n *\n * @returns true for a counter clockwise set of points\n */\n// http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/\nexport function isCounterClockwise(a: Point, b: Point, c: Point): boolean {\n return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x);\n}\n\n/**\n * For two lines a and b in 2d space, defined by any two points along the lines,\n * find the intersection point, or return null if the lines are parallel\n *\n * @param a1 - First point on line a\n * @param a2 - Second point on line a\n * @param b1 - First point on line b\n * @param b2 - Second point on line b\n *\n * @returns the intersection point of the two lines or null if they are parallel\n */\nexport function findLineIntersection(a1: Point, a2: Point, b1: Point, b2: Point): Point | null {\n const aDeltaY = a2.y - a1.y;\n const aDeltaX = a2.x - a1.x;\n const bDeltaY = b2.y - b1.y;\n const bDeltaX = b2.x - b1.x;\n\n const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY);\n\n if (denominator === 0) {\n // Lines are parallel\n return null;\n }\n\n const originDeltaY = a1.y - b1.y;\n const originDeltaX = a1.x - b1.x;\n const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator;\n\n // Find intersection by projecting out from origin of first segment\n return new Point(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY));\n}\n\n/**\n * Returns the signed area for the polygon ring. Positive areas are exterior rings and\n * have a clockwise winding. Negative areas are interior rings and have a counter clockwise\n * ordering.\n *\n * @param ring - Exterior or interior ring\n */\nexport function calculateSignedArea(ring: Array): number {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\n/**\n * Detects closed polygons, first + last point are equal\n *\n * @param points - array of points\n * @returns `true` if the points are a closed polygon\n */\nexport function isClosedPolygon(points: Array): boolean {\n // If it is 2 points that are the same then it is a point\n // If it is 3 points with start and end the same then it is a line\n if (points.length < 4)\n return false;\n\n const p1 = points[0];\n const p2 = points[points.length - 1];\n\n if (Math.abs(p1.x - p2.x) > 0 ||\n Math.abs(p1.y - p2.y) > 0) {\n return false;\n }\n\n // polygon simplification can produce polygons with zero area and more than 3 points\n return Math.abs(calculateSignedArea(points)) > 0.01;\n}\n\n/**\n * Converts spherical coordinates to cartesian coordinates.\n *\n * @param spherical - Spherical coordinates, in [radial, azimuthal, polar]\n * @returns cartesian coordinates in [x, y, z]\n */\n\nexport function sphericalToCartesian([r, azimuthal, polar]: [number, number, number]): {\n x: number;\n y: number;\n z: number;\n} {\n // We abstract \"north\"/\"up\" (compass-wise) to be 0° when really this is 90° (π/2):\n // correct for that here\n azimuthal += 90;\n\n // Convert azimuthal and polar angles to radians\n azimuthal *= Math.PI / 180;\n polar *= Math.PI / 180;\n\n return {\n x: r * Math.cos(azimuthal) * Math.sin(polar),\n y: r * Math.sin(azimuthal) * Math.sin(polar),\n z: r * Math.cos(polar)\n };\n}\n\n/**\n * Returns true if the when run in the web-worker context.\n *\n * @returns `true` if the when run in the web-worker context.\n */\nexport function isWorker(): boolean {\n // @ts-ignore\n return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;\n}\n\n/**\n * Parses data from 'Cache-Control' headers.\n *\n * @param cacheControl - Value of 'Cache-Control' header\n * @returns object containing parsed header info.\n */\n\nexport function parseCacheControl(cacheControl: string): any {\n // Taken from [Wreck](https://github.com/hapijs/wreck)\n const re = /(?:^|(?:\\s*\\,\\s*))([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)(?:\\=(?:([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)|(?:\\\"((?:[^\"\\\\]|\\\\.)*)\\\")))?/g;\n\n const header = {};\n cacheControl.replace(re, ($0, $1, $2, $3) => {\n const value = $2 || $3;\n header[$1] = value ? value.toLowerCase() : true;\n return '';\n });\n\n if (header['max-age']) {\n const maxAge = parseInt(header['max-age'], 10);\n if (isNaN(maxAge)) delete header['max-age'];\n else header['max-age'] = maxAge;\n }\n\n return header;\n}\n\nlet _isSafari = null;\n\n/**\n * Returns true when run in WebKit derived browsers.\n * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to\n * transfer data between WebWorkers and the main thread.\n * https://github.com/mapbox/mapbox-gl-js/issues/8771\n *\n * This should be removed once the underlying Safari issue is fixed.\n *\n * @param scope - Since this function is used both on the main thread and WebWorker context,\n * let the calling scope pass in the global scope object.\n * @returns `true` when run in WebKit derived browsers.\n */\nexport function isSafari(scope: any): boolean {\n if (_isSafari == null) {\n const userAgent = scope.navigator ? scope.navigator.userAgent : null;\n _isSafari = !!scope.safari ||\n !!(userAgent && (/\\b(iPad|iPhone|iPod)\\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome'))));\n }\n return _isSafari;\n}\n\nexport function storageAvailable(type: string): boolean {\n try {\n const storage = window[type];\n storage.setItem('_mapbox_test_', 1);\n storage.removeItem('_mapbox_test_');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n//Unicode compliant base64 encoder for strings\nexport function b64EncodeUnicode(str: string) {\n return btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,\n (match, p1) => {\n return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line\n }\n )\n );\n}\n\n// Unicode compliant decoder for base64-encoded strings\nexport function b64DecodeUnicode(str: string) {\n return decodeURIComponent(atob(str).split('').map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line\n }).join(''));\n}\n\nexport function isImageBitmap(image: any): image is ImageBitmap {\n return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;\n}\n\n/**\n * Converts an ArrayBuffer to an ImageBitmap.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image bitmap (when no error) as the second\n */\nexport function arrayBufferToImageBitmap(data: ArrayBuffer, callback: (err?: Error | null, image?: ImageBitmap | null) => void) {\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n createImageBitmap(blob).then((imgBitmap) => {\n callback(null, imgBitmap);\n }).catch((e) => {\n callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));\n });\n}\n\nconst transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';\n\n/**\n * Converts an ArrayBuffer to an HTMLImageElement.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image element (when no error) as the second\n */\nexport function arrayBufferToImage(data: ArrayBuffer, callback: (err?: Error | null, image?: HTMLImageElement | null) => void) {\n const img: HTMLImageElement = new Image();\n img.onload = () => {\n callback(null, img);\n URL.revokeObjectURL(img.src);\n // prevent image dataURI memory leak in Safari;\n // but don't free the image immediately because it might be uploaded in the next frame\n // https://github.com/mapbox/mapbox-gl-js/issues/10226\n img.onload = null;\n window.requestAnimationFrame(() => { img.src = transparentPngUrl; });\n };\n img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;\n}\n\n/**\n * Computes the webcodecs VideoFrame API options to select a rectangle out of\n * an image and write it into the destination rectangle.\n *\n * Rect (x/y/width/height) select the overlapping rectangle from the source image\n * and layout (offset/stride) write that overlapping rectangle to the correct place\n * in the destination image.\n *\n * Offset is the byte offset in the dest image that the first pixel appears at\n * and stride is the number of bytes to the start of the next row:\n * ┌───────────┐\n * │ dest │\n * │ ┌───┼───────┐\n * │offset→│▓▓▓│ source│\n * │ │▓▓▓│ │\n * │ └───┼───────┘\n * │stride ⇠╌╌╌│\n * │╌╌╌╌╌╌→ │\n * └───────────┘\n *\n * @param image - source image containing a width and height attribute\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns the layout and rect options to pass into VideoFrame API\n */\nfunction computeVideoFrameParameters(image: Size, x: number, y: number, width: number, height: number): VideoFrameCopyToOptions {\n const destRowOffset = Math.max(-x, 0) * 4;\n const firstSourceRow = Math.max(0, y);\n const firstDestRow = firstSourceRow - y;\n const offset = firstDestRow * width * 4 + destRowOffset;\n const stride = width * 4;\n\n const sourceLeft = Math.max(0, x);\n const sourceTop = Math.max(0, y);\n const sourceRight = Math.min(image.width, x + width);\n const sourceBottom = Math.min(image.height, y + height);\n return {\n rect: {\n x: sourceLeft,\n y: sourceTop,\n width: sourceRight - sourceLeft,\n height: sourceBottom - sourceTop\n },\n layout: [{offset, stride}]\n };\n}\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport async function readImageUsingVideoFrame(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (typeof VideoFrame === 'undefined') {\n throw new Error('VideoFrame not supported');\n }\n const frame = new VideoFrame(image, {timestamp: 0});\n try {\n const format = frame?.format;\n if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {\n throw new Error(`Unrecognized format ${format}`);\n }\n const swapBR = format.startsWith('BGR');\n const result = new Uint8ClampedArray(width * height * 4);\n await frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));\n if (swapBR) {\n for (let i = 0; i < result.length; i += 4) {\n const tmp = result[i];\n result[i] = result[i + 2];\n result[i + 2] = tmp;\n }\n }\n return result;\n } finally {\n frame.close();\n }\n}\n\nlet offscreenCanvas: OffscreenCanvas;\nlet offscreenCanvasContext: OffscreenCanvasRenderingContext2D;\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport function readImageDataUsingOffscreenCanvas(\n imgBitmap: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Uint8ClampedArray {\n const origWidth = imgBitmap.width;\n const origHeight = imgBitmap.height;\n // Lazily initialize OffscreenCanvas\n if (!offscreenCanvas || !offscreenCanvasContext) {\n // Dem tiles are typically 256x256\n offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);\n offscreenCanvasContext = offscreenCanvas.getContext('2d', {willReadFrequently: true});\n }\n\n offscreenCanvas.width = origWidth;\n offscreenCanvas.height = origHeight;\n\n offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);\n const imgData = offscreenCanvasContext.getImageData(x, y, width, height);\n offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);\n return imgData.data;\n}\n\n/**\n * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and\n * the browser is mangling OffscreenCanvas getImageData results.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image\n */\nexport async function getImageData(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (isOffscreenCanvasDistorted()) {\n try {\n return await readImageUsingVideoFrame(image, x, y, width, height);\n } catch (e) {\n // fall back to OffscreenCanvas\n }\n }\n return readImageDataUsingOffscreenCanvas(image, x, y, width, height);\n}\n","/*\nThis file was copied from https://github.com/mapbox/grid-index and was\nmigrated from JavaScript to TypeScript.\n\nCopyright (c) 2016, Mapbox\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n*/\n\nconst NUM_PARAMS = 3;\n\nexport type SerializedGrid = {\n buffer: ArrayBuffer;\n};\n\nexport class TransferableGridIndex {\n cells: number[][];\n arrayBuffer: ArrayBuffer;\n d: number;\n keys: number[];\n bboxes: number[];\n n: number;\n extent: number;\n padding: number;\n scale: any;\n uid: number;\n min: number;\n max: number;\n\n constructor(extent: number | ArrayBuffer, n?: number, padding?: number) {\n const cells = this.cells = [];\n\n if (extent instanceof ArrayBuffer) {\n this.arrayBuffer = extent;\n const array = new Int32Array(this.arrayBuffer);\n extent = array[0];\n n = array[1];\n padding = array[2];\n\n this.d = n + 2 * padding;\n for (let k = 0; k < this.d * this.d; k++) {\n const start = array[NUM_PARAMS + k];\n const end = array[NUM_PARAMS + k + 1];\n cells.push(start === end ? null : array.subarray(start, end));\n }\n const keysOffset = array[NUM_PARAMS + cells.length];\n const bboxesOffset = array[NUM_PARAMS + cells.length + 1];\n this.keys = array.subarray(keysOffset, bboxesOffset) as any as number[];\n this.bboxes = array.subarray(bboxesOffset) as any as number[];\n\n this.insert = this._insertReadonly;\n\n } else {\n this.d = n + 2 * padding;\n for (let i = 0; i < this.d * this.d; i++) {\n cells.push([]);\n }\n this.keys = [];\n this.bboxes = [];\n }\n\n this.n = n;\n this.extent = extent;\n this.padding = padding;\n this.scale = n / extent;\n this.uid = 0;\n\n const p = (padding / n) * extent;\n this.min = -p;\n this.max = extent + p;\n }\n\n insert(key: number, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined);\n this.keys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n _insertReadonly() {\n throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.');\n }\n\n _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.cells[cellIndex].push(uid);\n }\n\n query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[] {\n const min = this.min;\n const max = this.max;\n if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) {\n // We use `Array#slice` because `this.keys` may be a `Int32Array` and\n // some browsers (Safari and IE) do not support `TypedArray#slice`\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility\n return Array.prototype.slice.call(this.keys);\n\n } else {\n const result = [];\n const seenUids = {};\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest);\n return result;\n }\n }\n\n _queryCell(x1: number, y1: number, x2: number, y2:number, cellIndex:number, result, seenUids, intersectionTest: Function) {\n const cell = this.cells[cellIndex];\n if (cell !== null) {\n const keys = this.keys;\n const bboxes = this.bboxes;\n for (let u = 0; u < cell.length; u++) {\n const uid = cell[u];\n if (seenUids[uid] === undefined) {\n const offset = uid * 4;\n if (intersectionTest ?\n intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) :\n ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]))) {\n seenUids[uid] = true;\n result.push(keys[uid]);\n } else {\n seenUids[uid] = false;\n }\n }\n }\n }\n }\n\n _forEachCell(x1: number, y1: number, x2:number, y2:number, fn: Function, arg1, arg2, intersectionTest) {\n const cx1 = this._convertToCellCoord(x1);\n const cy1 = this._convertToCellCoord(y1);\n const cx2 = this._convertToCellCoord(x2);\n const cy2 = this._convertToCellCoord(y2);\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.d * y + x;\n if (intersectionTest && !intersectionTest(\n this._convertFromCellCoord(x),\n this._convertFromCellCoord(y),\n this._convertFromCellCoord(x + 1),\n this._convertFromCellCoord(y + 1))) continue;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) return;\n }\n }\n }\n\n _convertFromCellCoord (x) {\n return (x - this.padding) / this.scale;\n }\n\n _convertToCellCoord(x) {\n return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding));\n }\n\n toArrayBuffer(): ArrayBuffer {\n if (this.arrayBuffer) return this.arrayBuffer;\n\n const cells = this.cells;\n\n const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1;\n let totalCellLength = 0;\n for (let i = 0; i < this.cells.length; i++) {\n totalCellLength += this.cells[i].length;\n }\n\n const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length);\n array[0] = this.extent;\n array[1] = this.n;\n array[2] = this.padding;\n\n let offset = metadataLength;\n for (let k = 0; k < cells.length; k++) {\n const cell = cells[k];\n array[NUM_PARAMS + k] = offset;\n array.set(cell, offset);\n offset += cell.length;\n }\n\n array[NUM_PARAMS + cells.length] = offset;\n array.set(this.keys, offset);\n offset += this.keys.length;\n\n array[NUM_PARAMS + cells.length + 1] = offset;\n array.set(this.bboxes, offset);\n offset += this.bboxes.length;\n\n return array.buffer;\n }\n\n public static serialize(grid: TransferableGridIndex, transferables?: Array): SerializedGrid {\n const buffer = grid.toArrayBuffer();\n if (transferables) {\n transferables.push(buffer);\n }\n return {buffer};\n }\n\n public static deserialize(serialized: SerializedGrid): TransferableGridIndex {\n return new TransferableGridIndex(serialized.buffer);\n }\n}\n","import UnitBezier from '@mapbox/unitbezier';\n\nvar $version = 8;\nvar $root = {\n\tversion: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: [\n\t\t\t8\n\t\t]\n\t},\n\tname: {\n\t\ttype: \"string\"\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tcenter: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\"\n\t},\n\tzoom: {\n\t\ttype: \"number\"\n\t},\n\tbearing: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\"\n\t},\n\tpitch: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"degrees\"\n\t},\n\tlight: {\n\t\ttype: \"light\"\n\t},\n\tterrain: {\n\t\ttype: \"terrain\"\n\t},\n\tsources: {\n\t\trequired: true,\n\t\ttype: \"sources\"\n\t},\n\tsprite: {\n\t\ttype: \"sprite\"\n\t},\n\tglyphs: {\n\t\ttype: \"string\"\n\t},\n\ttransition: {\n\t\ttype: \"transition\"\n\t},\n\tlayers: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"layer\"\n\t}\n};\nvar sources = {\n\t\"*\": {\n\t\ttype: \"source\"\n\t}\n};\nvar source = [\n\t\"source_vector\",\n\t\"source_raster\",\n\t\"source_raster_dem\",\n\t\"source_geojson\",\n\t\"source_video\",\n\t\"source_image\"\n];\nvar source_vector = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvector: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\traster: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster_dem = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\t\"raster-dem\": {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tencoding: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tterrarium: {\n\t\t\t},\n\t\t\tmapbox: {\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"mapbox\"\n\t},\n\tredFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tblueFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tgreenFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tbaseShift: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_geojson = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tgeojson: {\n\t\t\t}\n\t\t}\n\t},\n\tdata: {\n\t\trequired: true,\n\t\ttype: \"*\"\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 18\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tbuffer: {\n\t\ttype: \"number\",\n\t\t\"default\": 128,\n\t\tmaximum: 512,\n\t\tminimum: 0\n\t},\n\tfilter: {\n\t\ttype: \"*\"\n\t},\n\ttolerance: {\n\t\ttype: \"number\",\n\t\t\"default\": 0.375\n\t},\n\tcluster: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tclusterRadius: {\n\t\ttype: \"number\",\n\t\t\"default\": 50,\n\t\tminimum: 0\n\t},\n\tclusterMaxZoom: {\n\t\ttype: \"number\"\n\t},\n\tclusterMinPoints: {\n\t\ttype: \"number\"\n\t},\n\tclusterProperties: {\n\t\ttype: \"*\"\n\t},\n\tlineMetrics: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tgenerateId: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t}\n};\nvar source_video = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvideo: {\n\t\t\t}\n\t\t}\n\t},\n\turls: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar source_image = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\timage: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\trequired: true,\n\t\ttype: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar layer = {\n\tid: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tfill: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\tsymbol: {\n\t\t\t},\n\t\t\tcircle: {\n\t\t\t},\n\t\t\theatmap: {\n\t\t\t},\n\t\t\t\"fill-extrusion\": {\n\t\t\t},\n\t\t\traster: {\n\t\t\t},\n\t\t\thillshade: {\n\t\t\t},\n\t\t\tbackground: {\n\t\t\t}\n\t\t},\n\t\trequired: true\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tsource: {\n\t\ttype: \"string\"\n\t},\n\t\"source-layer\": {\n\t\ttype: \"string\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tfilter: {\n\t\ttype: \"filter\"\n\t},\n\tlayout: {\n\t\ttype: \"layout\"\n\t},\n\tpaint: {\n\t\ttype: \"paint\"\n\t}\n};\nvar layout = [\n\t\"layout_fill\",\n\t\"layout_line\",\n\t\"layout_circle\",\n\t\"layout_heatmap\",\n\t\"layout_fill-extrusion\",\n\t\"layout_symbol\",\n\t\"layout_raster\",\n\t\"layout_hillshade\",\n\t\"layout_background\"\n];\nvar layout_background = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_fill = {\n\t\"fill-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_circle = {\n\t\"circle-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_heatmap = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_line = {\n\t\"line-cap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbutt: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tsquare: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"butt\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-join\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbevel: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tmiter: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"miter\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-miter-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"miter\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-round-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.05,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"round\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_symbol = {\n\t\"symbol-placement\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tpoint: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\t\"line-center\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"point\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 250,\n\t\tminimum: 1,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"symbol-placement\": \"line\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-avoid-edges\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"symbol-z-order\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\t\"viewport-y\": {\n\t\t\t},\n\t\t\tsource: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"!\": \"icon-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tunits: \"factor of the original icon size\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-text-fit\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\twidth: {\n\t\t\t},\n\t\t\theight: {\n\t\t\t},\n\t\t\tboth: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-text-fit-padding\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"icon-text-fit\": [\n\t\t\t\t\t\"both\",\n\t\t\t\t\t\"width\",\n\t\t\t\t\t\"height\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-image\": {\n\t\ttype: \"resolvedImage\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-padding\": {\n\t\ttype: \"padding\",\n\t\t\"default\": [\n\t\t\t2\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"icon-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\t\"viewport-glyph\": {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-field\": {\n\t\ttype: \"formatted\",\n\t\t\"default\": \"\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-font\": {\n\t\ttype: \"array\",\n\t\tvalue: \"string\",\n\t\t\"default\": [\n\t\t\t\"Open Sans Regular\",\n\t\t\t\"Arial Unicode MS Regular\"\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 16,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 10,\n\t\tminimum: 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-line-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.2,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-letter-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-justify\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-radial-offset\": {\n\t\ttype: \"number\",\n\t\tunits: \"ems\",\n\t\t\"default\": 0,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\t\"property-type\": \"data-driven\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t}\n\t},\n\t\"text-variable-anchor\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-variable-anchor-offset\": {\n\t\ttype: \"variableAnchorOffsetCollection\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-variable-anchor\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-angle\": {\n\t\ttype: \"number\",\n\t\t\"default\": 45,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-writing-mode\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\thorizontal: {\n\t\t\t},\n\t\t\tvertical: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-padding\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"text-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-transform\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\tuppercase: {\n\t\t\t},\n\t\t\tlowercase: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tunits: \"ems\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-radial-offset\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_raster = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_hillshade = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar filter = {\n\ttype: \"array\",\n\tvalue: \"*\"\n};\nvar filter_operator = {\n\ttype: \"enum\",\n\tvalues: {\n\t\t\"==\": {\n\t\t},\n\t\t\"!=\": {\n\t\t},\n\t\t\">\": {\n\t\t},\n\t\t\">=\": {\n\t\t},\n\t\t\"<\": {\n\t\t},\n\t\t\"<=\": {\n\t\t},\n\t\t\"in\": {\n\t\t},\n\t\t\"!in\": {\n\t\t},\n\t\tall: {\n\t\t},\n\t\tany: {\n\t\t},\n\t\tnone: {\n\t\t},\n\t\thas: {\n\t\t},\n\t\t\"!has\": {\n\t\t},\n\t\twithin: {\n\t\t}\n\t}\n};\nvar geometry_type = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tPoint: {\n\t\t},\n\t\tLineString: {\n\t\t},\n\t\tPolygon: {\n\t\t}\n\t}\n};\nvar function_stop = {\n\ttype: \"array\",\n\tminimum: 0,\n\tmaximum: 24,\n\tvalue: [\n\t\t\"number\",\n\t\t\"color\"\n\t],\n\tlength: 2\n};\nvar expression$1 = {\n\ttype: \"array\",\n\tvalue: \"*\",\n\tminimum: 1\n};\nvar light = {\n\tanchor: {\n\t\ttype: \"enum\",\n\t\t\"default\": \"viewport\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tposition: {\n\t\ttype: \"array\",\n\t\t\"default\": [\n\t\t\t1.15,\n\t\t\t210,\n\t\t\t30\n\t\t],\n\t\tlength: 3,\n\t\tvalue: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tcolor: {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\tintensity: {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar terrain = {\n\tsource: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\texaggeration: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\t\"default\": 1\n\t}\n};\nvar paint = [\n\t\"paint_fill\",\n\t\"paint_line\",\n\t\"paint_circle\",\n\t\"paint_heatmap\",\n\t\"paint_fill-extrusion\",\n\t\"paint_symbol\",\n\t\"paint_raster\",\n\t\"paint_hillshade\",\n\t\"paint_background\"\n];\nvar paint_fill = {\n\t\"fill-antialias\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-outline-color\": {\n\t\ttype: \"color\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fill-antialias\": true\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t}\n};\nvar paint_line = {\n\t\"line-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"line-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-gap-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-offset\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-dasharray\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"line widths\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"line-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-gradient\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-dasharray\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"geojson\",\n\t\t\t\thas: {\n\t\t\t\t\tlineMetrics: true\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"line-progress\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n};\nvar paint_circle = {\n\t\"circle-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 5,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"circle-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-scale\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-stroke-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t}\n};\nvar paint_heatmap = {\n\t\"heatmap-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 30,\n\t\tminimum: 1,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-weight\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-intensity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"heatmap-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": [\n\t\t\t\"interpolate\",\n\t\t\t[\n\t\t\t\t\"linear\"\n\t\t\t],\n\t\t\t[\n\t\t\t\t\"heatmap-density\"\n\t\t\t],\n\t\t\t0,\n\t\t\t\"rgba(0, 0, 255, 0)\",\n\t\t\t0.1,\n\t\t\t\"royalblue\",\n\t\t\t0.3,\n\t\t\t\"cyan\",\n\t\t\t0.5,\n\t\t\t\"lime\",\n\t\t\t0.7,\n\t\t\t\"yellow\",\n\t\t\t1,\n\t\t\t\"red\"\n\t\t],\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"heatmap-density\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t},\n\t\"heatmap-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_symbol = {\n\t\"icon-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"icon-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\toverridable: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"text-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_raster = {\n\t\"raster-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-hue-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\ttransition: true,\n\t\tunits: \"degrees\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-min\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-max\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-saturation\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-contrast\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-resampling\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tlinear: {\n\t\t\t},\n\t\t\tnearest: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"linear\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-fade-duration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\tunits: \"milliseconds\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_hillshade = {\n\t\"hillshade-illumination-direction\": {\n\t\ttype: \"number\",\n\t\t\"default\": 335,\n\t\tminimum: 0,\n\t\tmaximum: 359,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-exaggeration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-shadow-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-highlight-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#FFFFFF\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-accent-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_background = {\n\t\"background-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"background-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"background-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"background-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar transition = {\n\tduration: {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t},\n\tdelay: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t}\n};\nvar promoteId = {\n\t\"*\": {\n\t\ttype: \"string\"\n\t}\n};\nvar v8Spec = {\n\t$version: $version,\n\t$root: $root,\n\tsources: sources,\n\tsource: source,\n\tsource_vector: source_vector,\n\tsource_raster: source_raster,\n\tsource_raster_dem: source_raster_dem,\n\tsource_geojson: source_geojson,\n\tsource_video: source_video,\n\tsource_image: source_image,\n\tlayer: layer,\n\tlayout: layout,\n\tlayout_background: layout_background,\n\tlayout_fill: layout_fill,\n\tlayout_circle: layout_circle,\n\tlayout_heatmap: layout_heatmap,\n\t\"layout_fill-extrusion\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n},\n\tlayout_line: layout_line,\n\tlayout_symbol: layout_symbol,\n\tlayout_raster: layout_raster,\n\tlayout_hillshade: layout_hillshade,\n\tfilter: filter,\n\tfilter_operator: filter_operator,\n\tgeometry_type: geometry_type,\n\t\"function\": {\n\texpression: {\n\t\ttype: \"expression\"\n\t},\n\tstops: {\n\t\ttype: \"array\",\n\t\tvalue: \"function_stop\"\n\t},\n\tbase: {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0\n\t},\n\tproperty: {\n\t\ttype: \"string\",\n\t\t\"default\": \"$zoom\"\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tidentity: {\n\t\t\t},\n\t\t\texponential: {\n\t\t\t},\n\t\t\tinterval: {\n\t\t\t},\n\t\t\tcategorical: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"exponential\"\n\t},\n\tcolorSpace: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\trgb: {\n\t\t\t},\n\t\t\tlab: {\n\t\t\t},\n\t\t\thcl: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"rgb\"\n\t},\n\t\"default\": {\n\t\ttype: \"*\",\n\t\trequired: false\n\t}\n},\n\tfunction_stop: function_stop,\n\texpression: expression$1,\n\tlight: light,\n\tterrain: terrain,\n\tpaint: paint,\n\tpaint_fill: paint_fill,\n\t\"paint_fill-extrusion\": {\n\t\"fill-extrusion-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-extrusion-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-extrusion-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"fill-extrusion-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-base\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"fill-extrusion-height\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-vertical-gradient\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tpaint_line: paint_line,\n\tpaint_circle: paint_circle,\n\tpaint_heatmap: paint_heatmap,\n\tpaint_symbol: paint_symbol,\n\tpaint_raster: paint_raster,\n\tpaint_hillshade: paint_hillshade,\n\tpaint_background: paint_background,\n\ttransition: transition,\n\t\"property-type\": {\n\t\"data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded-data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"color-ramp\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"data-constant\": {\n\t\ttype: \"property-type\"\n\t},\n\tconstant: {\n\t\ttype: \"property-type\"\n\t}\n},\n\tpromoteId: promoteId\n};\n\nconst refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\n\nfunction deref(layer, parent) {\n const result = {};\n for (const k in layer) {\n if (k !== 'ref') {\n result[k] = layer[k];\n }\n }\n refProperties.forEach((k) => {\n if (k in parent) {\n result[k] = parent[k];\n }\n });\n return result;\n}\n/**\n * Given an array of layers, some of which may contain `ref` properties\n * whose value is the `id` of another property, return a new array where\n * such layers have been augmented with the 'type', 'source', etc. properties\n * from the parent layer, and the `ref` property has been removed.\n *\n * The input is not modified. The output may contain references to portions\n * of the input.\n *\n * @private\n * @param {Array} layers\n * @returns {Array}\n */\nfunction derefLayers(layers) {\n layers = layers.slice();\n const map = Object.create(null);\n for (let i = 0; i < layers.length; i++) {\n map[layers[i].id] = layers[i];\n }\n for (let i = 0; i < layers.length; i++) {\n if ('ref' in layers[i]) {\n layers[i] = deref(layers[i], map[layers[i].ref]);\n }\n }\n return layers;\n}\n\n/**\n * Deeply compares two object literals.\n *\n * @private\n */\nfunction deepEqual(a, b) {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object'))\n return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length)\n return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a === b;\n}\n\nconst operations = {\n /*\n * { command: 'setStyle', args: [stylesheet] }\n */\n setStyle: 'setStyle',\n /*\n * { command: 'addLayer', args: [layer, 'beforeLayerId'] }\n */\n addLayer: 'addLayer',\n /*\n * { command: 'removeLayer', args: ['layerId'] }\n */\n removeLayer: 'removeLayer',\n /*\n * { command: 'setPaintProperty', args: ['layerId', 'prop', value] }\n */\n setPaintProperty: 'setPaintProperty',\n /*\n * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }\n */\n setLayoutProperty: 'setLayoutProperty',\n /*\n * { command: 'setFilter', args: ['layerId', filter] }\n */\n setFilter: 'setFilter',\n /*\n * { command: 'addSource', args: ['sourceId', source] }\n */\n addSource: 'addSource',\n /*\n * { command: 'removeSource', args: ['sourceId'] }\n */\n removeSource: 'removeSource',\n /*\n * { command: 'setGeoJSONSourceData', args: ['sourceId', data] }\n */\n setGeoJSONSourceData: 'setGeoJSONSourceData',\n /*\n * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }\n */\n setLayerZoomRange: 'setLayerZoomRange',\n /*\n * { command: 'setLayerProperty', args: ['layerId', 'prop', value] }\n */\n setLayerProperty: 'setLayerProperty',\n /*\n * { command: 'setCenter', args: [[lon, lat]] }\n */\n setCenter: 'setCenter',\n /*\n * { command: 'setZoom', args: [zoom] }\n */\n setZoom: 'setZoom',\n /*\n * { command: 'setBearing', args: [bearing] }\n */\n setBearing: 'setBearing',\n /*\n * { command: 'setPitch', args: [pitch] }\n */\n setPitch: 'setPitch',\n /*\n * { command: 'setSprite', args: ['spriteUrl'] }\n */\n setSprite: 'setSprite',\n /*\n * { command: 'setGlyphs', args: ['glyphsUrl'] }\n */\n setGlyphs: 'setGlyphs',\n /*\n * { command: 'setTransition', args: [transition] }\n */\n setTransition: 'setTransition',\n /*\n * { command: 'setLighting', args: [lightProperties] }\n */\n setLight: 'setLight'\n};\nfunction addSource(sourceId, after, commands) {\n commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] });\n}\nfunction removeSource(sourceId, commands, sourcesRemoved) {\n commands.push({ command: operations.removeSource, args: [sourceId] });\n sourcesRemoved[sourceId] = true;\n}\nfunction updateSource(sourceId, after, commands, sourcesRemoved) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\nfunction canUpdateGeoJSON(before, after, sourceId) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\nfunction diffSources(before, after, commands, sourcesRemoved) {\n before = before || {};\n after = after || {};\n let sourceId;\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n }\n else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {\n commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] });\n }\n else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\nfunction diffLayerPropertyChanges(before, after, commands, layerId, klass, command) {\n before = before || {};\n after = after || {};\n let prop;\n for (prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n for (prop in after) {\n if (!Object.prototype.hasOwnProperty.call(after, prop) || Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n}\nfunction pluckId(layer) {\n return layer.id;\n}\nfunction indexById(group, layer) {\n group[layer.id] = layer;\n return group;\n}\nfunction diffLayers(before, after, commands) {\n before = before || [];\n after = after || [];\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;\n // remove layers\n for (i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.indexOf(layerId, d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n // add/reorder layers\n for (i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n if (tracker[tracker.length - 1 - i] === layerId)\n continue;\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n commands.push({ command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId] });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n // update layers\n for (i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer))\n continue;\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n commands.push({ command: operations.addLayer, args: [afterLayer, insertBeforeLayerId] });\n continue;\n }\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);\n diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n commands.push({ command: operations.setFilter, args: [layerId, afterLayer.filter] });\n }\n if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) || !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) {\n commands.push({ command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] });\n }\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n for (prop in afterLayer) {\n if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) || Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n }\n}\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nfunction diffStyles(before, after) {\n if (!before)\n return [{ command: operations.setStyle, args: [after] }];\n let commands = [];\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{ command: operations.setStyle, args: [after] }];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({ command: operations.setCenter, args: [after.center] });\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({ command: operations.setZoom, args: [after.zoom] });\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({ command: operations.setBearing, args: [after.bearing] });\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({ command: operations.setPitch, args: [after.pitch] });\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({ command: operations.setSprite, args: [after.sprite] });\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({ command: operations.setGlyphs, args: [after.glyphs] });\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({ command: operations.setTransition, args: [after.transition] });\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({ command: operations.setLight, args: [after.light] });\n }\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if (sourcesRemoved[layer.source]) {\n commands.push({ command: operations.removeLayer, args: [layer.id] });\n }\n else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n }\n catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{ command: operations.setStyle, args: [after] }];\n }\n return commands;\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ValidationError {\n constructor(key, value, message, identifier) {\n this.message = (key ? `${key}: ` : '') + message;\n if (identifier)\n this.identifier = identifier;\n if (value !== null && value !== undefined && value.__line__) {\n this.line = value.__line__;\n }\n }\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ParsingError {\n constructor(error) {\n this.error = error;\n this.message = error.message;\n const match = error.message.match(/line (\\d+)/);\n this.line = match ? parseInt(match[1], 10) : 0;\n }\n}\n\nfunction extendBy(output, ...inputs) {\n for (const input of inputs) {\n for (const k in input) {\n output[k] = input[k];\n }\n }\n return output;\n}\n\nclass ExpressionParsingError extends Error {\n constructor(key, message) {\n super(message);\n this.message = message;\n this.key = key;\n }\n}\n\n/**\n * Tracks `let` bindings during expression parsing.\n * @private\n */\nclass Scope {\n constructor(parent, bindings = []) {\n this.parent = parent;\n this.bindings = {};\n for (const [name, expression] of bindings) {\n this.bindings[name] = expression;\n }\n }\n concat(bindings) {\n return new Scope(this, bindings);\n }\n get(name) {\n if (this.bindings[name]) {\n return this.bindings[name];\n }\n if (this.parent) {\n return this.parent.get(name);\n }\n throw new Error(`${name} not found in scope.`);\n }\n has(name) {\n if (this.bindings[name])\n return true;\n return this.parent ? this.parent.has(name) : false;\n }\n}\n\nconst NullType = { kind: 'null' };\nconst NumberType = { kind: 'number' };\nconst StringType = { kind: 'string' };\nconst BooleanType = { kind: 'boolean' };\nconst ColorType = { kind: 'color' };\nconst ObjectType = { kind: 'object' };\nconst ValueType = { kind: 'value' };\nconst ErrorType = { kind: 'error' };\nconst CollatorType = { kind: 'collator' };\nconst FormattedType = { kind: 'formatted' };\nconst PaddingType = { kind: 'padding' };\nconst ResolvedImageType = { kind: 'resolvedImage' };\nconst VariableAnchorOffsetCollectionType = { kind: 'variableAnchorOffsetCollection' };\nfunction array$1(itemType, N) {\n return {\n kind: 'array',\n itemType,\n N\n };\n}\nfunction toString$1(type) {\n if (type.kind === 'array') {\n const itemType = toString$1(type.itemType);\n return typeof type.N === 'number' ?\n `array<${itemType}, ${type.N}>` :\n type.itemType.kind === 'value' ? 'array' : `array<${itemType}>`;\n }\n else {\n return type.kind;\n }\n}\nconst valueMemberTypes = [\n NullType,\n NumberType,\n StringType,\n BooleanType,\n ColorType,\n FormattedType,\n ObjectType,\n array$1(ValueType),\n PaddingType,\n ResolvedImageType,\n VariableAnchorOffsetCollectionType\n];\n/**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message.\n * @private\n */\nfunction checkSubtype(expected, t) {\n if (t.kind === 'error') {\n // Error is a subtype of every type\n return null;\n }\n else if (expected.kind === 'array') {\n if (t.kind === 'array' &&\n ((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) &&\n (typeof expected.N !== 'number' || expected.N === t.N)) {\n return null;\n }\n }\n else if (expected.kind === t.kind) {\n return null;\n }\n else if (expected.kind === 'value') {\n for (const memberType of valueMemberTypes) {\n if (!checkSubtype(memberType, t)) {\n return null;\n }\n }\n }\n return `Expected ${toString$1(expected)} but found ${toString$1(t)} instead.`;\n}\nfunction isValidType(provided, allowedTypes) {\n return allowedTypes.some(t => t.kind === provided.kind);\n}\nfunction isValidNativeType(provided, allowedTypes) {\n return allowedTypes.some(t => {\n if (t === 'null') {\n return provided === null;\n }\n else if (t === 'array') {\n return Array.isArray(provided);\n }\n else if (t === 'object') {\n return provided && !Array.isArray(provided) && typeof provided === 'object';\n }\n else {\n return t === typeof provided;\n }\n });\n}\n/**\n * Verify whether the specified type is of the same type as the specified sample.\n *\n * @param provided Type to verify\n * @param sample Sample type to reference\n * @returns `true` if both objects are of the same type, `false` otherwise\n * @example basic types\n * if (verifyType(outputType, ValueType)) {\n * // type narrowed to:\n * outputType.kind; // 'value'\n * }\n * @example array types\n * if (verifyType(outputType, array(NumberType))) {\n * // type narrowed to:\n * outputType.kind; // 'array'\n * outputType.itemType; // NumberTypeT\n * outputType.itemType.kind; // 'number'\n * }\n */\nfunction verifyType(provided, sample) {\n if (provided.kind === 'array' && sample.kind === 'array') {\n return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number';\n }\n return provided.kind === sample.kind;\n}\n\n// See https://observablehq.com/@mbostock/lab-and-rgb\nconst Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;\nfunction constrainAngle(angle) {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\nfunction rgbToLab([r, g, b, alpha]) {\n r = rgb2xyz(r);\n g = rgb2xyz(g);\n b = rgb2xyz(b);\n let x, z;\n const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn);\n if (r === g && g === b) {\n x = z = y;\n }\n else {\n x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);\n z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);\n }\n const l = 116 * y - 16;\n return [(l < 0) ? 0 : l, 500 * (x - y), 200 * (y - z), alpha];\n}\nfunction rgb2xyz(x) {\n return (x <= 0.04045) ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);\n}\nfunction xyz2lab(t) {\n return (t > t3) ? Math.pow(t, 1 / 3) : t / t2 + t0;\n}\nfunction labToRgb([l, a, b, alpha]) {\n let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200;\n y = Yn * lab2xyz(y);\n x = Xn * lab2xyz(x);\n z = Zn * lab2xyz(z);\n return [\n xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z),\n xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),\n xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),\n alpha,\n ];\n}\nfunction xyz2rgb(x) {\n x = (x <= 0.00304) ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;\n return (x < 0) ? 0 : (x > 1) ? 1 : x; // clip to 0..1 range\n}\nfunction lab2xyz(t) {\n return (t > t1) ? t * t * t : t2 * (t - t0);\n}\nfunction rgbToHcl(rgbColor) {\n const [l, a, b, alpha] = rgbToLab(rgbColor);\n const c = Math.sqrt(a * a + b * b);\n const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN;\n return [h, c, l, alpha];\n}\nfunction hclToRgb([h, c, l, alpha]) {\n h = isNaN(h) ? 0 : h * deg2rad;\n return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]);\n}\n// https://drafts.csswg.org/css-color-4/#hsl-to-rgb\nfunction hslToRgb([h, s, l, alpha]) {\n h = constrainAngle(h);\n s /= 100;\n l /= 100;\n function f(n) {\n const k = (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n return [f(0), f(8), f(4), alpha];\n}\n\n/**\n * CSS color parser compliant with CSS Color 4 Specification.\n * Supports: named colors, `transparent` keyword, all rgb hex notations,\n * rgb(), rgba(), hsl() and hsla() functions.\n * Does not round the parsed values to integers from the range 0..255.\n *\n * Syntax:\n *\n * = | \n * = | \n *\n * rgb() = rgb( {3} [ / ]? ) | rgb( {3} [ / ]? )\n * rgb() = rgb( #{3} , ? ) | rgb( #{3} , ? )\n *\n * hsl() = hsl( [ / ]? )\n * hsl() = hsl( , , , ? )\n *\n * Caveats:\n * - - with optional `deg` suffix; `grad`, `rad`, `turn` are not supported\n * - `none` keyword is not supported\n * - comments inside rgb()/hsl() are not supported\n * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb()\n * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl()\n *\n * @param input CSS color string to parse.\n * @returns Color in sRGB color space, with `red`, `green`, `blue`\n * and `alpha` channels normalized to the range 0..1,\n * or `undefined` if the input is not a valid color string.\n */\nfunction parseCssColor(input) {\n input = input.toLowerCase().trim();\n if (input === 'transparent') {\n return [0, 0, 0, 0];\n }\n // 'white', 'black', 'blue'\n const namedColorsMatch = namedColors[input];\n if (namedColorsMatch) {\n const [r, g, b] = namedColorsMatch;\n return [r / 255, g / 255, b / 255, 1];\n }\n // #f0c, #f0cf, #ff00cc, #ff00ccff\n if (input.startsWith('#')) {\n const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n if (hexRegexp.test(input)) {\n const step = input.length < 6 ? 1 : 2;\n let i = 1;\n return [\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i + step) || 'ff'),\n ];\n }\n }\n // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6)\n if (input.startsWith('rgb')) {\n const rgbRegExp = /^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const rgbMatch = input.match(rgbRegExp);\n if (rgbMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n r, // \n rp, // % (optional)\n f1, // , (optional)\n g, // \n gp, // % (optional)\n f2, // , (optional)\n b, // \n bp, // % (optional)\n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = rgbMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const valFormat = [rp, gp, bp].join('');\n const maxValue = (valFormat === '%%%') ? 100 :\n (valFormat === '') ? 255 : 0;\n if (maxValue) {\n const rgba = [\n clamp(+r / maxValue, 0, 1),\n clamp(+g / maxValue, 0, 1),\n clamp(+b / maxValue, 0, 1),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(rgba)) {\n return rgba;\n }\n // invalid numbers\n }\n // values must be all numbers or all percentages\n }\n return; // comma optional syntax requires no commas at all\n }\n }\n // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%)\n const hslRegExp = /^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const hslMatch = input.match(hslRegExp);\n if (hslMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n h, // \n f1, // , (optional)\n s, // \n f2, // , (optional)\n l, // \n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = hslMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const hsla = [\n +h,\n clamp(+s, 0, 100),\n clamp(+l, 0, 100),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(hsla)) {\n return hslToRgb(hsla);\n }\n // invalid numbers\n }\n // comma optional syntax requires no commas at all\n }\n}\nfunction parseHex(hex) {\n return parseInt(hex.padEnd(2, hex), 16) / 255;\n}\nfunction parseAlpha(a, asPercentage) {\n return clamp(asPercentage ? (a / 100) : a, 0, 1);\n}\nfunction clamp(n, min, max) {\n return Math.min(Math.max(min, n), max);\n}\n/**\n * The regular expression for numeric values is not super specific, and it may\n * happen that it will accept a value that is not a valid number. In order to\n * detect and eliminate such values this function exists.\n *\n * @param array Array of uncertain numbers.\n * @returns `true` if the specified array contains only valid numbers, `false` otherwise.\n */\nfunction validateNumbers(array) {\n return !array.some(Number.isNaN);\n}\n/**\n * To generate:\n * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors}\n * - run in the console:\n * @example\n * copy(`{\\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\\s+/).join(', ')}],`).join('\\n')}\\n}`);\n */\nconst namedColors = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n\n/**\n * Color representation used by WebGL.\n * Defined in sRGB color space and pre-blended with alpha.\n * @private\n */\nclass Color {\n /**\n * @param r Red component premultiplied by `alpha` 0..1\n * @param g Green component premultiplied by `alpha` 0..1\n * @param b Blue component premultiplied by `alpha` 0..1\n * @param [alpha=1] Alpha component 0..1\n * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already\n * been multiplied by alpha. If `true` nothing happens if `false` then they will\n * be multiplied automatically.\n */\n constructor(r, g, b, alpha = 1, premultiplied = true) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = alpha;\n if (!premultiplied) {\n this.r *= alpha;\n this.g *= alpha;\n this.b *= alpha;\n if (!alpha) {\n // alpha = 0 erases completely rgb channels. This behavior is not desirable\n // if this particular color is later used in color interpolation.\n // Because of that, a reference to original color is saved.\n this.overwriteGetter('rgb', [r, g, b, alpha]);\n }\n }\n }\n /**\n * Parses CSS color strings and converts colors to sRGB color space if needed.\n * Officially supported color formats:\n * - keyword, e.g. 'aquamarine' or 'steelblue'\n * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'\n * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'\n * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'\n *\n * @param input CSS color string to parse.\n * @returns A `Color` instance, or `undefined` if the input is not a valid color string.\n */\n static parse(input) {\n // in zoom-and-property function input could be an instance of Color class\n if (input instanceof Color) {\n return input;\n }\n if (typeof input !== 'string') {\n return;\n }\n const rgba = parseCssColor(input);\n if (rgba) {\n return new Color(...rgba, false);\n }\n }\n /**\n * Used in color interpolation and by 'to-rgba' expression.\n *\n * @returns Gien color, with reversed alpha blending, in sRGB color space.\n */\n get rgb() {\n const { r, g, b, a } = this;\n const f = a || Infinity; // reverse alpha blending factor\n return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]);\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in HCL color space.\n */\n get hcl() {\n return this.overwriteGetter('hcl', rgbToHcl(this.rgb));\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in LAB color space.\n */\n get lab() {\n return this.overwriteGetter('lab', rgbToLab(this.rgb));\n }\n /**\n * Lazy getter pattern. When getter is called for the first time lazy value\n * is calculated and then overwrites getter function in given object instance.\n *\n * @example:\n * const redColor = Color.parse('red');\n * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate\n * // the value of red in HCL space and invoke this `overwriteGetter` function\n * // which in turn will set a field with a key 'hcl' in the `redColor` object.\n * // In other words it will override `get hcl()` from its `Color` prototype\n * // with its own property: hcl = [calculated red value in hcl].\n * let y = redColor.hcl; // next call will no longer invoke getter but simply\n * // return the previously calculated value\n * x === y; // true - `x` is exactly the same object as `y`\n *\n * @param getterKey Getter key\n * @param lazyValue Lazily calculated value to be memoized by current instance\n * @private\n */\n overwriteGetter(getterKey, lazyValue) {\n Object.defineProperty(this, getterKey, { value: lazyValue });\n return lazyValue;\n }\n /**\n * Used by 'to-string' expression.\n *\n * @returns Serialized color in format `rgba(r,g,b,a)`\n * where r,g,b are numbers within 0..255 and alpha is number within 1..0\n *\n * @example\n * var purple = new Color.parse('purple');\n * purple.toString; // = \"rgba(128,0,128,1)\"\n * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');\n * translucentGreen.toString(); // = \"rgba(26,207,26,0.73)\"\n */\n toString() {\n const [r, g, b, a] = this.rgb;\n return `rgba(${[r, g, b].map(n => Math.round(n * 255)).join(',')},${a})`;\n }\n}\nColor.black = new Color(0, 0, 0, 1);\nColor.white = new Color(1, 1, 1, 1);\nColor.transparent = new Color(0, 0, 0, 0);\nColor.red = new Color(1, 0, 0, 1);\n\n// Flow type declarations for Intl cribbed from\n// https://github.com/facebook/flow/issues/1270\nclass Collator {\n constructor(caseSensitive, diacriticSensitive, locale) {\n if (caseSensitive)\n this.sensitivity = diacriticSensitive ? 'variant' : 'case';\n else\n this.sensitivity = diacriticSensitive ? 'accent' : 'base';\n this.locale = locale;\n this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: 'search' });\n }\n compare(lhs, rhs) {\n return this.collator.compare(lhs, rhs);\n }\n resolvedLocale() {\n // We create a Collator without \"usage: search\" because we don't want\n // the search options encoded in our result (e.g. \"en-u-co-search\")\n return new Intl.Collator(this.locale ? this.locale : [])\n .resolvedOptions().locale;\n }\n}\n\nclass FormattedSection {\n constructor(text, image, scale, fontStack, textColor) {\n this.text = text;\n this.image = image;\n this.scale = scale;\n this.fontStack = fontStack;\n this.textColor = textColor;\n }\n}\nclass Formatted {\n constructor(sections) {\n this.sections = sections;\n }\n static fromString(unformatted) {\n return new Formatted([new FormattedSection(unformatted, null, null, null, null)]);\n }\n isEmpty() {\n if (this.sections.length === 0)\n return true;\n return !this.sections.some(section => section.text.length !== 0 ||\n (section.image && section.image.name.length !== 0));\n }\n static factory(text) {\n if (text instanceof Formatted) {\n return text;\n }\n else {\n return Formatted.fromString(text);\n }\n }\n toString() {\n if (this.sections.length === 0)\n return '';\n return this.sections.map(section => section.text).join('');\n }\n}\n\n/**\n * A set of four numbers representing padding around a box. Create instances from\n * bare arrays or numeric values using the static method `Padding.parse`.\n * @private\n */\nclass Padding {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric padding values\n * @param input A padding value\n * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value.\n */\n static parse(input) {\n if (input instanceof Padding) {\n return input;\n }\n // Backwards compatibility: bare number is treated the same as array with single value.\n // Padding applies to all four sides.\n if (typeof input === 'number') {\n return new Padding([input, input, input, input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n if (input.length < 1 || input.length > 4) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n // Expand shortcut properties into explicit 4-sided values\n switch (input.length) {\n case 1:\n input = [input[0], input[0], input[0], input[0]];\n break;\n case 2:\n input = [input[0], input[1], input[0], input[1]];\n break;\n case 3:\n input = [input[0], input[1], input[2], input[1]];\n break;\n }\n return new Padding(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\n/** Set of valid anchor positions, as a set for validation */\nconst anchors = new Set(['center', 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right']);\n/**\n * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from\n * bare arrays using the static method `VariableAnchorOffsetCollection.parse`.\n * @private\n */\nclass VariableAnchorOffsetCollection {\n constructor(values) {\n this.values = values.slice();\n }\n static parse(input) {\n if (input instanceof VariableAnchorOffsetCollection) {\n return input;\n }\n if (!Array.isArray(input) ||\n input.length < 1 ||\n input.length % 2 !== 0) {\n return undefined;\n }\n for (let i = 0; i < input.length; i += 2) {\n // Elements in even positions should be anchor positions; Elements in odd positions should be offset values\n const anchorValue = input[i];\n const offsetValue = input[i + 1];\n if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) {\n return undefined;\n }\n if (!Array.isArray(offsetValue) || offsetValue.length !== 2 || typeof offsetValue[0] !== 'number' || typeof offsetValue[1] !== 'number') {\n return undefined;\n }\n }\n return new VariableAnchorOffsetCollection(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\nclass ResolvedImage {\n constructor(options) {\n this.name = options.name;\n this.available = options.available;\n }\n toString() {\n return this.name;\n }\n static fromString(name) {\n if (!name)\n return null; // treat empty values as no image\n return new ResolvedImage({ name, available: false });\n }\n}\n\nfunction validateRGBA(r, g, b, a) {\n if (!(typeof r === 'number' && r >= 0 && r <= 255 &&\n typeof g === 'number' && g >= 0 && g <= 255 &&\n typeof b === 'number' && b >= 0 && b <= 255)) {\n const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];\n return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;\n }\n if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) {\n return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;\n }\n return null;\n}\nfunction isValue(mixed) {\n if (mixed === null ||\n typeof mixed === 'string' ||\n typeof mixed === 'boolean' ||\n typeof mixed === 'number' ||\n mixed instanceof Color ||\n mixed instanceof Collator ||\n mixed instanceof Formatted ||\n mixed instanceof Padding ||\n mixed instanceof VariableAnchorOffsetCollection ||\n mixed instanceof ResolvedImage) {\n return true;\n }\n else if (Array.isArray(mixed)) {\n for (const item of mixed) {\n if (!isValue(item)) {\n return false;\n }\n }\n return true;\n }\n else if (typeof mixed === 'object') {\n for (const key in mixed) {\n if (!isValue(mixed[key])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\nfunction typeOf(value) {\n if (value === null) {\n return NullType;\n }\n else if (typeof value === 'string') {\n return StringType;\n }\n else if (typeof value === 'boolean') {\n return BooleanType;\n }\n else if (typeof value === 'number') {\n return NumberType;\n }\n else if (value instanceof Color) {\n return ColorType;\n }\n else if (value instanceof Collator) {\n return CollatorType;\n }\n else if (value instanceof Formatted) {\n return FormattedType;\n }\n else if (value instanceof Padding) {\n return PaddingType;\n }\n else if (value instanceof VariableAnchorOffsetCollection) {\n return VariableAnchorOffsetCollectionType;\n }\n else if (value instanceof ResolvedImage) {\n return ResolvedImageType;\n }\n else if (Array.isArray(value)) {\n const length = value.length;\n let itemType;\n for (const item of value) {\n const t = typeOf(item);\n if (!itemType) {\n itemType = t;\n }\n else if (itemType === t) {\n continue;\n }\n else {\n itemType = ValueType;\n break;\n }\n }\n return array$1(itemType || ValueType, length);\n }\n else {\n return ObjectType;\n }\n}\nfunction toString(value) {\n const type = typeof value;\n if (value === null) {\n return '';\n }\n else if (type === 'string' || type === 'number' || type === 'boolean') {\n return String(value);\n }\n else if (value instanceof Color || value instanceof Formatted || value instanceof Padding || value instanceof VariableAnchorOffsetCollection || value instanceof ResolvedImage) {\n return value.toString();\n }\n else {\n return JSON.stringify(value);\n }\n}\n\nclass Literal {\n constructor(type, value) {\n this.type = type;\n this.value = value;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (!isValue(args[1]))\n return context.error('invalid value');\n const value = args[1];\n let type = typeOf(value);\n // special case: infer the item type if possible for zero-length arrays\n const expected = context.expectedType;\n if (type.kind === 'array' &&\n type.N === 0 &&\n expected &&\n expected.kind === 'array' &&\n (typeof expected.N !== 'number' || expected.N === 0)) {\n type = expected;\n }\n return new Literal(type, value);\n }\n evaluate() {\n return this.value;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass RuntimeError {\n constructor(message) {\n this.name = 'ExpressionEvaluationError';\n this.message = message;\n }\n toJSON() {\n return this.message;\n }\n}\n\nconst types$1 = {\n string: StringType,\n number: NumberType,\n boolean: BooleanType,\n object: ObjectType\n};\nclass Assertion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n let i = 1;\n let type;\n const name = args[0];\n if (name === 'array') {\n let itemType;\n if (args.length > 2) {\n const type = args[1];\n if (typeof type !== 'string' || !(type in types$1) || type === 'object')\n return context.error('The item type argument of \"array\" must be one of string, number, boolean', 1);\n itemType = types$1[type];\n i++;\n }\n else {\n itemType = ValueType;\n }\n let N;\n if (args.length > 3) {\n if (args[2] !== null &&\n (typeof args[2] !== 'number' ||\n args[2] < 0 ||\n args[2] !== Math.floor(args[2]))) {\n return context.error('The length argument to \"array\" must be a positive integer literal', 2);\n }\n N = args[2];\n i++;\n }\n type = array$1(itemType, N);\n }\n else {\n if (!types$1[name])\n throw new Error(`Types doesn't contain name = ${name}`);\n type = types$1[name];\n }\n const parsed = [];\n for (; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Assertion(type, parsed);\n }\n evaluate(ctx) {\n for (let i = 0; i < this.args.length; i++) {\n const value = this.args[i].evaluate(ctx);\n const error = checkSubtype(this.type, typeOf(value));\n if (!error) {\n return value;\n }\n else if (i === this.args.length - 1) {\n throw new RuntimeError(`Expected value to be of type ${toString$1(this.type)}, but found ${toString$1(typeOf(value))} instead.`);\n }\n }\n throw new Error();\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst types = {\n 'to-boolean': BooleanType,\n 'to-color': ColorType,\n 'to-number': NumberType,\n 'to-string': StringType\n};\n/**\n * Special form for error-coalescing coercion expressions \"to-number\",\n * \"to-color\". Since these coercions can fail at runtime, they accept multiple\n * arguments, only evaluating one at a time until one succeeds.\n *\n * @private\n */\nclass Coercion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n const name = args[0];\n if (!types[name])\n throw new Error(`Can't parse ${name} as it is not part of the known types`);\n if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2)\n return context.error('Expected one argument.');\n const type = types[name];\n const parsed = [];\n for (let i = 1; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Coercion(type, parsed);\n }\n evaluate(ctx) {\n switch (this.type.kind) {\n case 'boolean':\n return Boolean(this.args[0].evaluate(ctx));\n case 'color': {\n let input;\n let error;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n error = null;\n if (input instanceof Color) {\n return input;\n }\n else if (typeof input === 'string') {\n const c = ctx.parseColor(input);\n if (c)\n return c;\n }\n else if (Array.isArray(input)) {\n if (input.length < 3 || input.length > 4) {\n error = `Invalid rbga value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`;\n }\n else {\n error = validateRGBA(input[0], input[1], input[2], input[3]);\n }\n if (!error) {\n return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);\n }\n }\n }\n throw new RuntimeError(error || `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'padding': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const pad = Padding.parse(input);\n if (pad) {\n return pad;\n }\n }\n throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'variableAnchorOffsetCollection': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const coll = VariableAnchorOffsetCollection.parse(input);\n if (coll) {\n return coll;\n }\n }\n throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'number': {\n let value = null;\n for (const arg of this.args) {\n value = arg.evaluate(ctx);\n if (value === null)\n return 0;\n const num = Number(value);\n if (isNaN(num))\n continue;\n return num;\n }\n throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`);\n }\n case 'formatted':\n // There is no explicit 'to-formatted' but this coercion can be implicitly\n // created by properties that expect the 'formatted' type.\n return Formatted.fromString(toString(this.args[0].evaluate(ctx)));\n case 'resolvedImage':\n return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx)));\n default:\n return toString(this.args[0].evaluate(ctx));\n }\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\nclass EvaluationContext {\n constructor() {\n this.globals = null;\n this.feature = null;\n this.featureState = null;\n this.formattedSection = null;\n this._parseColorCache = {};\n this.availableImages = null;\n this.canonical = null;\n }\n id() {\n return this.feature && 'id' in this.feature ? this.feature.id : null;\n }\n geometryType() {\n return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;\n }\n geometry() {\n return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n }\n canonicalID() {\n return this.canonical;\n }\n properties() {\n return this.feature && this.feature.properties || {};\n }\n parseColor(input) {\n let cached = this._parseColorCache[input];\n if (!cached) {\n cached = this._parseColorCache[input] = Color.parse(input);\n }\n return cached;\n }\n}\n\n/**\n * State associated parsing at a given point in an expression tree.\n * @private\n */\nclass ParsingContext {\n constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) {\n this.registry = registry;\n this.path = path;\n this.key = path.map(part => `[${part}]`).join('');\n this.scope = scope;\n this.errors = errors;\n this.expectedType = expectedType;\n this._isConstant = isConstantFunc;\n }\n /**\n * @param expr the JSON expression to parse\n * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed\n * @param options\n * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.\n * @private\n */\n parse(expr, index, expectedType, bindings, options = {}) {\n if (index) {\n return this.concat(index, expectedType, bindings)._parse(expr, options);\n }\n return this._parse(expr, options);\n }\n _parse(expr, options) {\n if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {\n expr = ['literal', expr];\n }\n function annotate(parsed, type, typeAnnotation) {\n if (typeAnnotation === 'assert') {\n return new Assertion(type, [parsed]);\n }\n else if (typeAnnotation === 'coerce') {\n return new Coercion(type, [parsed]);\n }\n else {\n return parsed;\n }\n }\n if (Array.isArray(expr)) {\n if (expr.length === 0) {\n return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');\n }\n const op = expr[0];\n if (typeof op !== 'string') {\n this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use [\"literal\", [...]].`, 0);\n return null;\n }\n const Expr = this.registry[op];\n if (Expr) {\n let parsed = Expr.parse(expr, this);\n if (!parsed)\n return null;\n if (this.expectedType) {\n const expected = this.expectedType;\n const actual = parsed.type;\n // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.\n // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.\n // Otherwise, we do static type-checking.\n //\n // These behaviors are overridable for:\n // * The \"coalesce\" operator, which needs to omit type annotations.\n // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.\n //\n if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');\n }\n else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'padding' && (actual.kind === 'value' || actual.kind === 'number' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'variableAnchorOffsetCollection' && (actual.kind === 'value' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (this.checkSubtype(expected, actual)) {\n return null;\n }\n }\n // If an expression's arguments are all literals, we can evaluate\n // it immediately and replace it with a literal value in the\n // parsed/compiled result. Expressions that expect an image should\n // not be resolved here so we can later get the available images.\n if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && this._isConstant(parsed)) {\n const ec = new EvaluationContext();\n try {\n parsed = new Literal(parsed.type, parsed.evaluate(ec));\n }\n catch (e) {\n this.error(e.message);\n return null;\n }\n }\n return parsed;\n }\n return this.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n else if (typeof expr === 'undefined') {\n return this.error('\\'undefined\\' value invalid. Use null instead.');\n }\n else if (typeof expr === 'object') {\n return this.error('Bare objects invalid. Use [\"literal\", {...}] instead.');\n }\n else {\n return this.error(`Expected an array, but found ${typeof expr} instead.`);\n }\n }\n /**\n * Returns a copy of this context suitable for parsing the subexpression at\n * index `index`, optionally appending to 'let' binding map.\n *\n * Note that `errors` property, intended for collecting errors while\n * parsing, is copied by reference rather than cloned.\n * @private\n */\n concat(index, expectedType, bindings) {\n const path = typeof index === 'number' ? this.path.concat(index) : this.path;\n const scope = bindings ? this.scope.concat(bindings) : this.scope;\n return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors);\n }\n /**\n * Push a parsing (or type checking) error into the `this.errors`\n * @param error The message\n * @param keys Optionally specify the source of the error at a child\n * of the current expression at `this.key`.\n * @private\n */\n error(error, ...keys) {\n const key = `${this.key}${keys.map(k => `[${k}]`).join('')}`;\n this.errors.push(new ExpressionParsingError(key, error));\n }\n /**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message and also pushes it to `this.errors`.\n * @param expected The expected type\n * @param t The actual type\n * @returns null if `t` is a subtype of `expected`; otherwise returns an error message\n */\n checkSubtype(expected, t) {\n const error = checkSubtype(expected, t);\n if (error)\n this.error(error);\n return error;\n }\n}\n\nclass CollatorExpression {\n constructor(caseSensitive, diacriticSensitive, locale) {\n this.type = CollatorType;\n this.locale = locale;\n this.caseSensitive = caseSensitive;\n this.diacriticSensitive = diacriticSensitive;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error('Expected one argument.');\n const options = args[1];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('Collator options argument must be an object.');\n const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);\n if (!caseSensitive)\n return null;\n const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);\n if (!diacriticSensitive)\n return null;\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n return new CollatorExpression(caseSensitive, diacriticSensitive, locale);\n }\n evaluate(ctx) {\n return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);\n }\n eachChild(fn) {\n fn(this.caseSensitive);\n fn(this.diacriticSensitive);\n if (this.locale) {\n fn(this.locale);\n }\n }\n outputDefined() {\n // Technically the set of possible outputs is the combinatoric set of Collators produced\n // by all possible outputs of locale/caseSensitive/diacriticSensitive\n // But for the primary use of Collators in comparison operators, we ignore the Collator's\n // possible outputs anyway, so we can get away with leaving this false for now.\n return false;\n }\n}\n\nconst EXTENT = 8192;\nfunction updateBBox(bbox, coord) {\n bbox[0] = Math.min(bbox[0], coord[0]);\n bbox[1] = Math.min(bbox[1], coord[1]);\n bbox[2] = Math.max(bbox[2], coord[0]);\n bbox[3] = Math.max(bbox[3], coord[1]);\n}\nfunction mercatorXfromLng(lng) {\n return (180 + lng) / 360;\n}\nfunction mercatorYfromLat(lat) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\nfunction boxWithinBox(bbox1, bbox2) {\n if (bbox1[0] <= bbox2[0])\n return false;\n if (bbox1[2] >= bbox2[2])\n return false;\n if (bbox1[1] <= bbox2[1])\n return false;\n if (bbox1[3] >= bbox2[3])\n return false;\n return true;\n}\nfunction getTileCoordinates(p, canonical) {\n const x = mercatorXfromLng(p[0]);\n const y = mercatorYfromLat(p[1]);\n const tilesAtZoom = Math.pow(2, canonical.z);\n return [Math.round(x * tilesAtZoom * EXTENT), Math.round(y * tilesAtZoom * EXTENT)];\n}\nfunction onBoundary(p, p1, p2) {\n const x1 = p[0] - p1[0];\n const y1 = p[1] - p1[1];\n const x2 = p[0] - p2[0];\n const y2 = p[1] - p2[1];\n return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);\n}\nfunction rayIntersect(p, p1, p2) {\n return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]);\n}\n// ray casting algorithm for detecting if point is in polygon\nfunction pointWithinPolygon(point, rings) {\n let inside = false;\n for (let i = 0, len = rings.length; i < len; i++) {\n const ring = rings[i];\n for (let j = 0, len2 = ring.length; j < len2 - 1; j++) {\n if (onBoundary(point, ring[j], ring[j + 1]))\n return false;\n if (rayIntersect(point, ring[j], ring[j + 1]))\n inside = !inside;\n }\n }\n return inside;\n}\nfunction pointWithinPolygons(point, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (pointWithinPolygon(point, polygons[i]))\n return true;\n }\n return false;\n}\nfunction perp(v1, v2) {\n return (v1[0] * v2[1] - v1[1] * v2[0]);\n}\n// check if p1 and p2 are in different sides of line segment q1->q2\nfunction twoSided(p1, p2, q1, q2) {\n // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)\n const x1 = p1[0] - q1[0];\n const y1 = p1[1] - q1[1];\n const x2 = p2[0] - q1[0];\n const y2 = p2[1] - q1[1];\n const x3 = q2[0] - q1[0];\n const y3 = q2[1] - q1[1];\n const det1 = (x1 * y3 - x3 * y1);\n const det2 = (x2 * y3 - x3 * y2);\n if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0))\n return true;\n return false;\n}\n// a, b are end points for line segment1, c and d are end points for line segment2\nfunction lineIntersectLine(a, b, c, d) {\n // check if two segments are parallel or not\n // precondition is end point a, b is inside polygon, if line a->b is\n // parallel to polygon edge c->d, then a->b won't intersect with c->d\n const vectorP = [b[0] - a[0], b[1] - a[1]];\n const vectorQ = [d[0] - c[0], d[1] - c[1]];\n if (perp(vectorQ, vectorP) === 0)\n return false;\n // If lines are intersecting with each other, the relative location should be:\n // a and b lie in different sides of segment c->d\n // c and d lie in different sides of segment a->b\n if (twoSided(a, b, c, d) && twoSided(c, d, a, b))\n return true;\n return false;\n}\nfunction lineIntersectPolygon(p1, p2, polygon) {\n for (const ring of polygon) {\n // loop through every edge of the ring\n for (let j = 0; j < ring.length - 1; ++j) {\n if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) {\n return true;\n }\n }\n }\n return false;\n}\nfunction lineStringWithinPolygon(line, polygon) {\n // First, check if geometry points of line segments are all inside polygon\n for (let i = 0; i < line.length; ++i) {\n if (!pointWithinPolygon(line[i], polygon)) {\n return false;\n }\n }\n // Second, check if there is line segment intersecting polygon edge\n for (let i = 0; i < line.length - 1; ++i) {\n if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {\n return false;\n }\n }\n return true;\n}\nfunction lineStringWithinPolygons(line, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (lineStringWithinPolygon(line, polygons[i]))\n return true;\n }\n return false;\n}\nfunction getTilePolygon(coordinates, bbox, canonical) {\n const polygon = [];\n for (let i = 0; i < coordinates.length; i++) {\n const ring = [];\n for (let j = 0; j < coordinates[i].length; j++) {\n const coord = getTileCoordinates(coordinates[i][j], canonical);\n updateBBox(bbox, coord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n return polygon;\n}\nfunction getTilePolygons(coordinates, bbox, canonical) {\n const polygons = [];\n for (let i = 0; i < coordinates.length; i++) {\n const polygon = getTilePolygon(coordinates[i], bbox, canonical);\n polygons.push(polygon);\n }\n return polygons;\n}\nfunction updatePoint(p, bbox, polyBBox, worldSize) {\n if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {\n const halfWorldSize = worldSize * 0.5;\n let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0;\n if (shift === 0) {\n shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0;\n }\n p[0] += shift;\n }\n updateBBox(bbox, p);\n}\nfunction resetBBox(bbox) {\n bbox[0] = bbox[1] = Infinity;\n bbox[2] = bbox[3] = -Infinity;\n}\nfunction getTilePoints(geometry, pointBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tilePoints = [];\n for (const points of geometry) {\n for (const point of points) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updatePoint(p, pointBBox, polyBBox, worldSize);\n tilePoints.push(p);\n }\n }\n return tilePoints;\n}\nfunction getTileLines(geometry, lineBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tileLines = [];\n for (const line of geometry) {\n const tileLine = [];\n for (const point of line) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updateBBox(lineBBox, p);\n tileLine.push(p);\n }\n tileLines.push(tileLine);\n }\n if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {\n resetBBox(lineBBox);\n for (const line of tileLines) {\n for (const p of line) {\n updatePoint(p, lineBBox, polyBBox, worldSize);\n }\n }\n }\n return tileLines;\n}\nfunction pointsWithinPolygons(ctx, polygonGeometry) {\n const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygon(point, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygons(point, tilePolygons))\n return false;\n }\n }\n return true;\n}\nfunction linesWithinPolygons(ctx, polygonGeometry) {\n const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygon(line, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygons(line, tilePolygons))\n return false;\n }\n }\n return true;\n}\nclass Within {\n constructor(geojson, geometries) {\n this.type = BooleanType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n for (let i = 0; i < geojson.features.length; ++i) {\n const type = geojson.features[i].geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.features[i].geometry);\n }\n }\n }\n else if (geojson.type === 'Feature') {\n const type = geojson.geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.geometry);\n }\n }\n else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {\n return new Within(geojson, geojson);\n }\n }\n return context.error('\\'within\\' expression requires valid geojson object that contains polygon geometry type.');\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointsWithinPolygons(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return linesWithinPolygons(ctx, this.geometries);\n }\n }\n return false;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass Var {\n constructor(name, boundExpression) {\n this.type = boundExpression.type;\n this.name = name;\n this.boundExpression = boundExpression;\n }\n static parse(args, context) {\n if (args.length !== 2 || typeof args[1] !== 'string')\n return context.error('\\'var\\' expression requires exactly one string literal argument.');\n const name = args[1];\n if (!context.scope.has(name)) {\n return context.error(`Unknown variable \"${name}\". Make sure \"${name}\" has been bound in an enclosing \"let\" expression before using it.`, 1);\n }\n return new Var(name, context.scope.get(name));\n }\n evaluate(ctx) {\n return this.boundExpression.evaluate(ctx);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nclass CompoundExpression {\n constructor(name, type, evaluate, args) {\n this.name = name;\n this.type = type;\n this._evaluate = evaluate;\n this.args = args;\n }\n evaluate(ctx) {\n return this._evaluate(ctx, this.args);\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return false;\n }\n static parse(args, context) {\n const op = args[0];\n const definition = CompoundExpression.definitions[op];\n if (!definition) {\n return context.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n // Now check argument types against each signature\n const type = Array.isArray(definition) ?\n definition[0] : definition.type;\n const availableOverloads = Array.isArray(definition) ?\n [[definition[1], definition[2]]] :\n definition.overloads;\n const overloads = availableOverloads.filter(([signature]) => (!Array.isArray(signature) || // varags\n signature.length === args.length - 1 // correct param count\n ));\n let signatureContext = null;\n for (const [params, evaluate] of overloads) {\n // Use a fresh context for each attempted signature so that, if\n // we eventually succeed, we haven't polluted `context.errors`.\n signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope);\n // First parse all the args, potentially coercing to the\n // types expected by this overload.\n const parsedArgs = [];\n let argParseFailed = false;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n const expectedType = Array.isArray(params) ?\n params[i - 1] :\n params.type;\n const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);\n if (!parsed) {\n argParseFailed = true;\n break;\n }\n parsedArgs.push(parsed);\n }\n if (argParseFailed) {\n // Couldn't coerce args of this overload to expected type, move\n // on to next one.\n continue;\n }\n if (Array.isArray(params)) {\n if (params.length !== parsedArgs.length) {\n signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);\n continue;\n }\n }\n for (let i = 0; i < parsedArgs.length; i++) {\n const expected = Array.isArray(params) ? params[i] : params.type;\n const arg = parsedArgs[i];\n signatureContext.concat(i + 1).checkSubtype(expected, arg.type);\n }\n if (signatureContext.errors.length === 0) {\n return new CompoundExpression(op, type, evaluate, parsedArgs);\n }\n }\n if (overloads.length === 1) {\n context.errors.push(...signatureContext.errors);\n }\n else {\n const expected = overloads.length ? overloads : availableOverloads;\n const signatures = expected\n .map(([params]) => stringifySignature(params))\n .join(' | ');\n const actualTypes = [];\n // For error message, re-parse arguments without trying to\n // apply any coercions\n for (let i = 1; i < args.length; i++) {\n const parsed = context.parse(args[i], 1 + actualTypes.length);\n if (!parsed)\n return null;\n actualTypes.push(toString$1(parsed.type));\n }\n context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);\n }\n return null;\n }\n static register(registry, definitions) {\n CompoundExpression.definitions = definitions;\n for (const name in definitions) {\n registry[name] = CompoundExpression;\n }\n }\n}\nfunction stringifySignature(signature) {\n if (Array.isArray(signature)) {\n return `(${signature.map(toString$1).join(', ')})`;\n }\n else {\n return `(${toString$1(signature.type)}...)`;\n }\n}\nfunction isExpressionConstant(expression) {\n if (expression instanceof Var) {\n return isExpressionConstant(expression.boundExpression);\n }\n else if (expression instanceof CompoundExpression && expression.name === 'error') {\n return false;\n }\n else if (expression instanceof CollatorExpression) {\n // Although the results of a Collator expression with fixed arguments\n // generally shouldn't change between executions, we can't serialize them\n // as constant expressions because results change based on environment.\n return false;\n }\n else if (expression instanceof Within) {\n return false;\n }\n const isTypeAnnotation = expression instanceof Coercion ||\n expression instanceof Assertion;\n let childrenConstant = true;\n expression.eachChild(child => {\n // We can _almost_ assume that if `expressions` children are constant,\n // they would already have been evaluated to Literal values when they\n // were parsed. Type annotations are the exception, because they might\n // have been inferred and added after a child was parsed.\n // So we recurse into isConstant() for the children of type annotations,\n // but otherwise simply check whether they are Literals.\n if (isTypeAnnotation) {\n childrenConstant = childrenConstant && isExpressionConstant(child);\n }\n else {\n childrenConstant = childrenConstant && child instanceof Literal;\n }\n });\n if (!childrenConstant) {\n return false;\n }\n return isFeatureConstant(expression) &&\n isGlobalPropertyConstant(expression, ['zoom', 'heatmap-density', 'line-progress', 'accumulated', 'is-supported-script']);\n}\nfunction isFeatureConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'get' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'feature-state') {\n return false;\n }\n else if (e.name === 'has' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'properties' ||\n e.name === 'geometry-type' ||\n e.name === 'id') {\n return false;\n }\n else if (/^filter-/.test(e.name)) {\n return false;\n }\n }\n if (e instanceof Within) {\n return false;\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isFeatureConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isStateConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'feature-state') {\n return false;\n }\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isStateConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isGlobalPropertyConstant(e, properties) {\n if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isGlobalPropertyConstant(arg, properties)) {\n result = false;\n }\n });\n return result;\n}\n\n/**\n * Returns the index of the last stop <= input, or 0 if it doesn't exist.\n * @private\n */\nfunction findStopLessThanOrEqualTo(stops, input) {\n const lastIndex = stops.length - 1;\n let lowerIndex = 0;\n let upperIndex = lastIndex;\n let currentIndex = 0;\n let currentValue, nextValue;\n while (lowerIndex <= upperIndex) {\n currentIndex = Math.floor((lowerIndex + upperIndex) / 2);\n currentValue = stops[currentIndex];\n nextValue = stops[currentIndex + 1];\n if (currentValue <= input) {\n if (currentIndex === lastIndex || input < nextValue) { // Search complete\n return currentIndex;\n }\n lowerIndex = currentIndex + 1;\n }\n else if (currentValue > input) {\n upperIndex = currentIndex - 1;\n }\n else {\n throw new RuntimeError('Input is not a number.');\n }\n }\n return 0;\n}\n\nclass Step {\n constructor(type, input, stops) {\n this.type = type;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static parse(args, context) {\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n const input = context.parse(args[1], 1, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 1; i < args.length; i += 2) {\n const label = i === 1 ? -Infinity : args[i];\n const value = args[i + 1];\n const labelKey = i;\n const valueKey = i + 1;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"step\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n return new Step(outputType, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n return outputs[index].evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n\n/**\n * Checks whether the specified color space is one of the supported interpolation color spaces.\n *\n * @param colorSpace Color space key to verify.\n * @returns `true` if the specified color space is one of the supported\n * interpolation color spaces, `false` otherwise\n */\nfunction isSupportedInterpolationColorSpace(colorSpace) {\n return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab';\n}\n/**\n * @param interpolationType Interpolation type\n * @returns interpolation fn\n * @deprecated use `interpolate[type]` instead\n */\nconst interpolateFactory = (interpolationType) => {\n switch (interpolationType) {\n case 'number': return number;\n case 'color': return color;\n case 'array': return array;\n case 'padding': return padding;\n case 'variableAnchorOffsetCollection': return variableAnchorOffsetCollection;\n }\n};\nfunction number(from, to, t) {\n return from + t * (to - from);\n}\nfunction color(from, to, t, spaceKey = 'rgb') {\n switch (spaceKey) {\n case 'rgb': {\n const [r, g, b, alpha] = array(from.rgb, to.rgb, t);\n return new Color(r, g, b, alpha, false);\n }\n case 'hcl': {\n const [hue0, chroma0, light0, alphaF] = from.hcl;\n const [hue1, chroma1, light1, alphaT] = to.hcl;\n // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js\n let hue, chroma;\n if (!isNaN(hue0) && !isNaN(hue1)) {\n let dh = hue1 - hue0;\n if (hue1 > hue0 && dh > 180) {\n dh -= 360;\n }\n else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh += 360;\n }\n hue = hue0 + t * dh;\n }\n else if (!isNaN(hue0)) {\n hue = hue0;\n if (light1 === 1 || light1 === 0)\n chroma = chroma0;\n }\n else if (!isNaN(hue1)) {\n hue = hue1;\n if (light0 === 1 || light0 === 0)\n chroma = chroma1;\n }\n else {\n hue = NaN;\n }\n const [r, g, b, alpha] = hclToRgb([\n hue,\n chroma !== null && chroma !== void 0 ? chroma : number(chroma0, chroma1, t),\n number(light0, light1, t),\n number(alphaF, alphaT, t),\n ]);\n return new Color(r, g, b, alpha, false);\n }\n case 'lab': {\n const [r, g, b, alpha] = labToRgb(array(from.lab, to.lab, t));\n return new Color(r, g, b, alpha, false);\n }\n }\n}\nfunction array(from, to, t) {\n return from.map((d, i) => {\n return number(d, to[i], t);\n });\n}\nfunction padding(from, to, t) {\n return new Padding(array(from.values, to.values, t));\n}\nfunction variableAnchorOffsetCollection(from, to, t) {\n const fromValues = from.values;\n const toValues = to.values;\n if (fromValues.length !== toValues.length) {\n throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`);\n }\n const output = [];\n for (let i = 0; i < fromValues.length; i += 2) {\n // Anchor entries must match\n if (fromValues[i] !== toValues[i]) {\n throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`);\n }\n output.push(fromValues[i]);\n // Interpolate the offset values for each anchor\n const [fx, fy] = fromValues[i + 1];\n const [tx, ty] = toValues[i + 1];\n output.push([number(fx, tx, t), number(fy, ty, t)]);\n }\n return new VariableAnchorOffsetCollection(output);\n}\nconst interpolate = {\n number,\n color,\n array,\n padding,\n variableAnchorOffsetCollection\n};\n\nclass Interpolate {\n constructor(type, operator, interpolation, input, stops) {\n this.type = type;\n this.operator = operator;\n this.interpolation = interpolation;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static interpolationFactor(interpolation, input, lower, upper) {\n let t = 0;\n if (interpolation.name === 'exponential') {\n t = exponentialInterpolation(input, interpolation.base, lower, upper);\n }\n else if (interpolation.name === 'linear') {\n t = exponentialInterpolation(input, 1, lower, upper);\n }\n else if (interpolation.name === 'cubic-bezier') {\n const c = interpolation.controlPoints;\n const ub = new UnitBezier(c[0], c[1], c[2], c[3]);\n t = ub.solve(exponentialInterpolation(input, 1, lower, upper));\n }\n return t;\n }\n static parse(args, context) {\n let [operator, interpolation, input, ...rest] = args;\n if (!Array.isArray(interpolation) || interpolation.length === 0) {\n return context.error('Expected an interpolation type expression.', 1);\n }\n if (interpolation[0] === 'linear') {\n interpolation = { name: 'linear' };\n }\n else if (interpolation[0] === 'exponential') {\n const base = interpolation[1];\n if (typeof base !== 'number')\n return context.error('Exponential interpolation requires a numeric base.', 1, 1);\n interpolation = {\n name: 'exponential',\n base\n };\n }\n else if (interpolation[0] === 'cubic-bezier') {\n const controlPoints = interpolation.slice(1);\n if (controlPoints.length !== 4 ||\n controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)) {\n return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);\n }\n interpolation = {\n name: 'cubic-bezier',\n controlPoints: controlPoints\n };\n }\n else {\n return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);\n }\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n input = context.parse(input, 2, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {\n outputType = ColorType;\n }\n else if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 0; i < rest.length; i += 2) {\n const label = rest[i];\n const value = rest[i + 1];\n const labelKey = i + 3;\n const valueKey = i + 4;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"interpolate\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n if (!verifyType(outputType, NumberType) &&\n !verifyType(outputType, ColorType) &&\n !verifyType(outputType, PaddingType) &&\n !verifyType(outputType, VariableAnchorOffsetCollectionType) &&\n !verifyType(outputType, array$1(NumberType))) {\n return context.error(`Type ${toString$1(outputType)} is not interpolatable.`);\n }\n return new Interpolate(outputType, operator, interpolation, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n const lower = labels[index];\n const upper = labels[index + 1];\n const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);\n const outputLower = outputs[index].evaluate(ctx);\n const outputUpper = outputs[index + 1].evaluate(ctx);\n switch (this.operator) {\n case 'interpolate':\n return interpolate[this.type.kind](outputLower, outputUpper, t);\n case 'interpolate-hcl':\n return interpolate.color(outputLower, outputUpper, t, 'hcl');\n case 'interpolate-lab':\n return interpolate.color(outputLower, outputUpper, t, 'lab');\n }\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n*/\nfunction exponentialInterpolation(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass Coalesce {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expectected at least one argument.');\n }\n let outputType = null;\n const expectedType = context.expectedType;\n if (expectedType && expectedType.kind !== 'value') {\n outputType = expectedType;\n }\n const parsedArgs = [];\n for (const arg of args.slice(1)) {\n const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' });\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n parsedArgs.push(parsed);\n }\n if (!outputType)\n throw new Error('No output type');\n // Above, we parse arguments without inferred type annotation so that\n // they don't produce a runtime error for `null` input, which would\n // preempt the desired null-coalescing behavior.\n // Thus, if any of our arguments would have needed an annotation, we\n // need to wrap the enclosing coalesce expression with it instead.\n const needsAnnotation = expectedType &&\n parsedArgs.some(arg => checkSubtype(expectedType, arg.type));\n return needsAnnotation ?\n new Coalesce(ValueType, parsedArgs) :\n new Coalesce(outputType, parsedArgs);\n }\n evaluate(ctx) {\n let result = null;\n let argCount = 0;\n let requestedImageName;\n for (const arg of this.args) {\n argCount++;\n result = arg.evaluate(ctx);\n // we need to keep track of the first requested image in a coalesce statement\n // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire\n if (result && result instanceof ResolvedImage && !result.available) {\n if (!requestedImageName) {\n requestedImageName = result.name;\n }\n result = null;\n if (argCount === this.args.length) {\n result = requestedImageName;\n }\n }\n if (result !== null)\n break;\n }\n return result;\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nclass Let {\n constructor(bindings, result) {\n this.type = result.type;\n this.bindings = [].concat(bindings);\n this.result = result;\n }\n evaluate(ctx) {\n return this.result.evaluate(ctx);\n }\n eachChild(fn) {\n for (const binding of this.bindings) {\n fn(binding[1]);\n }\n fn(this.result);\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);\n const bindings = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const name = args[i];\n if (typeof name !== 'string') {\n return context.error(`Expected string, but found ${typeof name} instead.`, i);\n }\n if (/[^a-zA-Z0-9_]/.test(name)) {\n return context.error('Variable names must contain only alphanumeric characters or \\'_\\'.', i);\n }\n const value = context.parse(args[i + 1], i + 1);\n if (!value)\n return null;\n bindings.push([name, value]);\n }\n const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);\n if (!result)\n return null;\n return new Let(bindings, result);\n }\n outputDefined() {\n return this.result.outputDefined();\n }\n}\n\nclass At {\n constructor(type, index, input) {\n this.type = type;\n this.index = index;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n const index = context.parse(args[1], 1, NumberType);\n const input = context.parse(args[2], 2, array$1(context.expectedType || ValueType));\n if (!index || !input)\n return null;\n const t = input.type;\n return new At(t.itemType, index, input);\n }\n evaluate(ctx) {\n const index = this.index.evaluate(ctx);\n const array = this.input.evaluate(ctx);\n if (index < 0) {\n throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);\n }\n if (index >= array.length) {\n throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);\n }\n if (index !== Math.floor(index)) {\n throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);\n }\n return array[index];\n }\n eachChild(fn) {\n fn(this.index);\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nclass In {\n constructor(needle, haystack) {\n this.type = BooleanType;\n this.needle = needle;\n this.haystack = haystack;\n }\n static parse(args, context) {\n if (args.length !== 3) {\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n return new In(needle, haystack);\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!haystack)\n return false;\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n return haystack.indexOf(needle) >= 0;\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n }\n outputDefined() {\n return true;\n }\n}\n\nclass IndexOf {\n constructor(needle, haystack, fromIndex) {\n this.type = NumberType;\n this.needle = needle;\n this.haystack = haystack;\n this.fromIndex = fromIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n if (args.length === 4) {\n const fromIndex = context.parse(args[3], 3, NumberType);\n if (!fromIndex)\n return null;\n return new IndexOf(needle, haystack, fromIndex);\n }\n else {\n return new IndexOf(needle, haystack);\n }\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n if (this.fromIndex) {\n const fromIndex = this.fromIndex.evaluate(ctx);\n return haystack.indexOf(needle, fromIndex);\n }\n return haystack.indexOf(needle);\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n if (this.fromIndex) {\n fn(this.fromIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass Match {\n constructor(inputType, outputType, input, cases, outputs, otherwise) {\n this.inputType = inputType;\n this.type = outputType;\n this.input = input;\n this.cases = cases;\n this.outputs = outputs;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 5)\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 1)\n return context.error('Expected an even number of arguments.');\n let inputType;\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const cases = {};\n const outputs = [];\n for (let i = 2; i < args.length - 1; i += 2) {\n let labels = args[i];\n const value = args[i + 1];\n if (!Array.isArray(labels)) {\n labels = [labels];\n }\n const labelContext = context.concat(i);\n if (labels.length === 0) {\n return labelContext.error('Expected at least one branch label.');\n }\n for (const label of labels) {\n if (typeof label !== 'number' && typeof label !== 'string') {\n return labelContext.error('Branch labels must be numbers or strings.');\n }\n else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {\n return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);\n }\n else if (typeof label === 'number' && Math.floor(label) !== label) {\n return labelContext.error('Numeric branch labels must be integer values.');\n }\n else if (!inputType) {\n inputType = typeOf(label);\n }\n else if (labelContext.checkSubtype(inputType, typeOf(label))) {\n return null;\n }\n if (typeof cases[String(label)] !== 'undefined') {\n return labelContext.error('Branch labels must be unique.');\n }\n cases[String(label)] = outputs.length;\n }\n const result = context.parse(value, i, outputType);\n if (!result)\n return null;\n outputType = outputType || result.type;\n outputs.push(result);\n }\n const input = context.parse(args[1], 1, ValueType);\n if (!input)\n return null;\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {\n return null;\n }\n return new Match(inputType, outputType, input, cases, outputs, otherwise);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;\n return output.evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n this.outputs.forEach(fn);\n fn(this.otherwise);\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Case {\n constructor(type, branches, otherwise) {\n this.type = type;\n this.branches = branches;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 0)\n return context.error('Expected an odd number of arguments.');\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const branches = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const test = context.parse(args[i], i, BooleanType);\n if (!test)\n return null;\n const result = context.parse(args[i + 1], i + 1, outputType);\n if (!result)\n return null;\n branches.push([test, result]);\n outputType = outputType || result.type;\n }\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (!outputType)\n throw new Error('Can\\'t infer output type');\n return new Case(outputType, branches, otherwise);\n }\n evaluate(ctx) {\n for (const [test, expression] of this.branches) {\n if (test.evaluate(ctx)) {\n return expression.evaluate(ctx);\n }\n }\n return this.otherwise.evaluate(ctx);\n }\n eachChild(fn) {\n for (const [test, expression] of this.branches) {\n fn(test);\n fn(expression);\n }\n fn(this.otherwise);\n }\n outputDefined() {\n return this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Slice {\n constructor(type, input, beginIndex, endIndex) {\n this.type = type;\n this.input = input;\n this.beginIndex = beginIndex;\n this.endIndex = endIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const input = context.parse(args[1], 1, ValueType);\n const beginIndex = context.parse(args[2], 2, NumberType);\n if (!input || !beginIndex)\n return null;\n if (!isValidType(input.type, [array$1(ValueType), StringType, ValueType])) {\n return context.error(`Expected first argument to be of type array or string, but found ${toString$1(input.type)} instead`);\n }\n if (args.length === 4) {\n const endIndex = context.parse(args[3], 3, NumberType);\n if (!endIndex)\n return null;\n return new Slice(input.type, input, beginIndex, endIndex);\n }\n else {\n return new Slice(input.type, input, beginIndex);\n }\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const beginIndex = this.beginIndex.evaluate(ctx);\n if (!isValidNativeType(input, ['string', 'array'])) {\n throw new RuntimeError(`Expected first argument to be of type array or string, but found ${toString$1(typeOf(input))} instead.`);\n }\n if (this.endIndex) {\n const endIndex = this.endIndex.evaluate(ctx);\n return input.slice(beginIndex, endIndex);\n }\n return input.slice(beginIndex);\n }\n eachChild(fn) {\n fn(this.input);\n fn(this.beginIndex);\n if (this.endIndex) {\n fn(this.endIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nfunction isComparableType(op, type) {\n if (op === '==' || op === '!=') {\n // equality operator\n return type.kind === 'boolean' ||\n type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'null' ||\n type.kind === 'value';\n }\n else {\n // ordering operator\n return type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'value';\n }\n}\nfunction eq(ctx, a, b) { return a === b; }\nfunction neq(ctx, a, b) { return a !== b; }\nfunction lt(ctx, a, b) { return a < b; }\nfunction gt(ctx, a, b) { return a > b; }\nfunction lteq(ctx, a, b) { return a <= b; }\nfunction gteq(ctx, a, b) { return a >= b; }\nfunction eqCollate(ctx, a, b, c) { return c.compare(a, b) === 0; }\nfunction neqCollate(ctx, a, b, c) { return !eqCollate(ctx, a, b, c); }\nfunction ltCollate(ctx, a, b, c) { return c.compare(a, b) < 0; }\nfunction gtCollate(ctx, a, b, c) { return c.compare(a, b) > 0; }\nfunction lteqCollate(ctx, a, b, c) { return c.compare(a, b) <= 0; }\nfunction gteqCollate(ctx, a, b, c) { return c.compare(a, b) >= 0; }\n/**\n * Special form for comparison operators, implementing the signatures:\n * - (T, T, ?Collator) => boolean\n * - (T, value, ?Collator) => boolean\n * - (value, T, ?Collator) => boolean\n *\n * For inequalities, T must be either value, string, or number. For ==/!=, it\n * can also be boolean or null.\n *\n * Equality semantics are equivalent to Javascript's strict equality (===/!==)\n * -- i.e., when the arguments' types don't match, == evaluates to false, != to\n * true.\n *\n * When types don't match in an ordering comparison, a runtime error is thrown.\n *\n * @private\n */\nfunction makeComparison(op, compareBasic, compareWithCollator) {\n const isOrderComparison = op !== '==' && op !== '!=';\n return class Comparison {\n constructor(lhs, rhs, collator) {\n this.type = BooleanType;\n this.lhs = lhs;\n this.rhs = rhs;\n this.collator = collator;\n this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';\n }\n static parse(args, context) {\n if (args.length !== 3 && args.length !== 4)\n return context.error('Expected two or three arguments.');\n const op = args[0];\n let lhs = context.parse(args[1], 1, ValueType);\n if (!lhs)\n return null;\n if (!isComparableType(op, lhs.type)) {\n return context.concat(1).error(`\"${op}\" comparisons are not supported for type '${toString$1(lhs.type)}'.`);\n }\n let rhs = context.parse(args[2], 2, ValueType);\n if (!rhs)\n return null;\n if (!isComparableType(op, rhs.type)) {\n return context.concat(2).error(`\"${op}\" comparisons are not supported for type '${toString$1(rhs.type)}'.`);\n }\n if (lhs.type.kind !== rhs.type.kind &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`);\n }\n if (isOrderComparison) {\n // typing rules specific to less/greater than operators\n if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {\n // (value, T)\n lhs = new Assertion(rhs.type, [lhs]);\n }\n else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {\n // (T, value)\n rhs = new Assertion(lhs.type, [rhs]);\n }\n }\n let collator = null;\n if (args.length === 4) {\n if (lhs.type.kind !== 'string' &&\n rhs.type.kind !== 'string' &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error('Cannot use collator to compare non-string types.');\n }\n collator = context.parse(args[3], 3, CollatorType);\n if (!collator)\n return null;\n }\n return new Comparison(lhs, rhs, collator);\n }\n evaluate(ctx) {\n const lhs = this.lhs.evaluate(ctx);\n const rhs = this.rhs.evaluate(ctx);\n if (isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n // check that type is string or number, and equal\n if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {\n throw new RuntimeError(`Expected arguments for \"${op}\" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`);\n }\n }\n if (this.collator && !isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n if (lt.kind !== 'string' || rt.kind !== 'string') {\n return compareBasic(ctx, lhs, rhs);\n }\n }\n return this.collator ?\n compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) :\n compareBasic(ctx, lhs, rhs);\n }\n eachChild(fn) {\n fn(this.lhs);\n fn(this.rhs);\n if (this.collator) {\n fn(this.collator);\n }\n }\n outputDefined() {\n return true;\n }\n };\n}\nconst Equals = makeComparison('==', eq, eqCollate);\nconst NotEquals = makeComparison('!=', neq, neqCollate);\nconst LessThan = makeComparison('<', lt, ltCollate);\nconst GreaterThan = makeComparison('>', gt, gtCollate);\nconst LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);\nconst GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);\n\nclass NumberFormat {\n constructor(number, locale, currency, minFractionDigits, maxFractionDigits) {\n this.type = StringType;\n this.number = number;\n this.locale = locale;\n this.currency = currency;\n this.minFractionDigits = minFractionDigits;\n this.maxFractionDigits = maxFractionDigits;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error('Expected two arguments.');\n const number = context.parse(args[1], 1, NumberType);\n if (!number)\n return null;\n const options = args[2];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('NumberFormat options argument must be an object.');\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n let currency = null;\n if (options['currency']) {\n currency = context.parse(options['currency'], 1, StringType);\n if (!currency)\n return null;\n }\n let minFractionDigits = null;\n if (options['min-fraction-digits']) {\n minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);\n if (!minFractionDigits)\n return null;\n }\n let maxFractionDigits = null;\n if (options['max-fraction-digits']) {\n maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);\n if (!maxFractionDigits)\n return null;\n }\n return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);\n }\n evaluate(ctx) {\n return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {\n style: this.currency ? 'currency' : 'decimal',\n currency: this.currency ? this.currency.evaluate(ctx) : undefined,\n minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,\n maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,\n }).format(this.number.evaluate(ctx));\n }\n eachChild(fn) {\n fn(this.number);\n if (this.locale) {\n fn(this.locale);\n }\n if (this.currency) {\n fn(this.currency);\n }\n if (this.minFractionDigits) {\n fn(this.minFractionDigits);\n }\n if (this.maxFractionDigits) {\n fn(this.maxFractionDigits);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass FormatExpression {\n constructor(sections) {\n this.type = FormattedType;\n this.sections = sections;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n const firstArg = args[1];\n if (!Array.isArray(firstArg) && typeof firstArg === 'object') {\n return context.error('First argument must be an image or text section.');\n }\n const sections = [];\n let nextTokenMayBeObject = false;\n for (let i = 1; i <= args.length - 1; ++i) {\n const arg = args[i];\n if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) {\n nextTokenMayBeObject = false;\n let scale = null;\n if (arg['font-scale']) {\n scale = context.parse(arg['font-scale'], 1, NumberType);\n if (!scale)\n return null;\n }\n let font = null;\n if (arg['text-font']) {\n font = context.parse(arg['text-font'], 1, array$1(StringType));\n if (!font)\n return null;\n }\n let textColor = null;\n if (arg['text-color']) {\n textColor = context.parse(arg['text-color'], 1, ColorType);\n if (!textColor)\n return null;\n }\n const lastExpression = sections[sections.length - 1];\n lastExpression.scale = scale;\n lastExpression.font = font;\n lastExpression.textColor = textColor;\n }\n else {\n const content = context.parse(args[i], 1, ValueType);\n if (!content)\n return null;\n const kind = content.type.kind;\n if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage')\n return context.error('Formatted text type must be \\'string\\', \\'value\\', \\'image\\' or \\'null\\'.');\n nextTokenMayBeObject = true;\n sections.push({ content, scale: null, font: null, textColor: null });\n }\n }\n return new FormatExpression(sections);\n }\n evaluate(ctx) {\n const evaluateSection = section => {\n const evaluatedContent = section.content.evaluate(ctx);\n if (typeOf(evaluatedContent) === ResolvedImageType) {\n return new FormattedSection('', evaluatedContent, null, null, null);\n }\n return new FormattedSection(toString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null);\n };\n return new Formatted(this.sections.map(evaluateSection));\n }\n eachChild(fn) {\n for (const section of this.sections) {\n fn(section.content);\n if (section.scale) {\n fn(section.scale);\n }\n if (section.font) {\n fn(section.font);\n }\n if (section.textColor) {\n fn(section.textColor);\n }\n }\n }\n outputDefined() {\n // Technically the combinatoric set of all children\n // Usually, this.text will be undefined anyway\n return false;\n }\n}\n\nclass ImageExpression {\n constructor(input) {\n this.type = ResolvedImageType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error('Expected two arguments.');\n }\n const name = context.parse(args[1], 1, StringType);\n if (!name)\n return context.error('No image name provided.');\n return new ImageExpression(name);\n }\n evaluate(ctx) {\n const evaluatedImageName = this.input.evaluate(ctx);\n const value = ResolvedImage.fromString(evaluatedImageName);\n if (value && ctx.availableImages)\n value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;\n return value;\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n // The output of image is determined by the list of available images in the evaluation context\n return false;\n }\n}\n\nclass Length {\n constructor(input) {\n this.type = NumberType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n const input = context.parse(args[1], 1);\n if (!input)\n return null;\n if (input.type.kind !== 'array' && input.type.kind !== 'string' && input.type.kind !== 'value')\n return context.error(`Expected argument of type string or array, but found ${toString$1(input.type)} instead.`);\n return new Length(input);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n if (typeof input === 'string') {\n return input.length;\n }\n else if (Array.isArray(input)) {\n return input.length;\n }\n else {\n throw new RuntimeError(`Expected value to be of type string or array, but found ${toString$1(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nconst expressions = {\n // special forms\n '==': Equals,\n '!=': NotEquals,\n '>': GreaterThan,\n '<': LessThan,\n '>=': GreaterThanOrEqual,\n '<=': LessThanOrEqual,\n 'array': Assertion,\n 'at': At,\n 'boolean': Assertion,\n 'case': Case,\n 'coalesce': Coalesce,\n 'collator': CollatorExpression,\n 'format': FormatExpression,\n 'image': ImageExpression,\n 'in': In,\n 'index-of': IndexOf,\n 'interpolate': Interpolate,\n 'interpolate-hcl': Interpolate,\n 'interpolate-lab': Interpolate,\n 'length': Length,\n 'let': Let,\n 'literal': Literal,\n 'match': Match,\n 'number': Assertion,\n 'number-format': NumberFormat,\n 'object': Assertion,\n 'slice': Slice,\n 'step': Step,\n 'string': Assertion,\n 'to-boolean': Coercion,\n 'to-color': Coercion,\n 'to-number': Coercion,\n 'to-string': Coercion,\n 'var': Var,\n 'within': Within\n};\nfunction rgba(ctx, [r, g, b, a]) {\n r = r.evaluate(ctx);\n g = g.evaluate(ctx);\n b = b.evaluate(ctx);\n const alpha = a ? a.evaluate(ctx) : 1;\n const error = validateRGBA(r, g, b, alpha);\n if (error)\n throw new RuntimeError(error);\n return new Color(r / 255, g / 255, b / 255, alpha, false);\n}\nfunction has(key, obj) {\n return key in obj;\n}\nfunction get(key, obj) {\n const v = obj[key];\n return typeof v === 'undefined' ? null : v;\n}\nfunction binarySearch(v, a, i, j) {\n while (i <= j) {\n const m = (i + j) >> 1;\n if (a[m] === v)\n return true;\n if (a[m] > v)\n j = m - 1;\n else\n i = m + 1;\n }\n return false;\n}\nfunction varargs(type) {\n return { type };\n}\nCompoundExpression.register(expressions, {\n 'error': [\n ErrorType,\n [StringType],\n (ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); }\n ],\n 'typeof': [\n StringType,\n [ValueType],\n (ctx, [v]) => toString$1(typeOf(v.evaluate(ctx)))\n ],\n 'to-rgba': [\n array$1(NumberType, 4),\n [ColorType],\n (ctx, [v]) => {\n const [r, g, b, a] = v.evaluate(ctx).rgb;\n return [r * 255, g * 255, b * 255, a];\n },\n ],\n 'rgb': [\n ColorType,\n [NumberType, NumberType, NumberType],\n rgba\n ],\n 'rgba': [\n ColorType,\n [NumberType, NumberType, NumberType, NumberType],\n rgba\n ],\n 'has': {\n type: BooleanType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'get': {\n type: ValueType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'feature-state': [\n ValueType,\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})\n ],\n 'properties': [\n ObjectType,\n [],\n (ctx) => ctx.properties()\n ],\n 'geometry-type': [\n StringType,\n [],\n (ctx) => ctx.geometryType()\n ],\n 'id': [\n ValueType,\n [],\n (ctx) => ctx.id()\n ],\n 'zoom': [\n NumberType,\n [],\n (ctx) => ctx.globals.zoom\n ],\n 'heatmap-density': [\n NumberType,\n [],\n (ctx) => ctx.globals.heatmapDensity || 0\n ],\n 'line-progress': [\n NumberType,\n [],\n (ctx) => ctx.globals.lineProgress || 0\n ],\n 'accumulated': [\n ValueType,\n [],\n (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated\n ],\n '+': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 0;\n for (const arg of args) {\n result += arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '*': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 1;\n for (const arg of args) {\n result *= arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '-': {\n type: NumberType,\n overloads: [\n [\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)\n ], [\n [NumberType],\n (ctx, [a]) => -a.evaluate(ctx)\n ]\n ]\n },\n '/': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)\n ],\n '%': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)\n ],\n 'ln2': [\n NumberType,\n [],\n () => Math.LN2\n ],\n 'pi': [\n NumberType,\n [],\n () => Math.PI\n ],\n 'e': [\n NumberType,\n [],\n () => Math.E\n ],\n '^': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))\n ],\n 'sqrt': [\n NumberType,\n [NumberType],\n (ctx, [x]) => Math.sqrt(x.evaluate(ctx))\n ],\n 'log10': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10\n ],\n 'ln': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx))\n ],\n 'log2': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2\n ],\n 'sin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.sin(n.evaluate(ctx))\n ],\n 'cos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.cos(n.evaluate(ctx))\n ],\n 'tan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.tan(n.evaluate(ctx))\n ],\n 'asin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.asin(n.evaluate(ctx))\n ],\n 'acos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.acos(n.evaluate(ctx))\n ],\n 'atan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.atan(n.evaluate(ctx))\n ],\n 'min': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'max': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'abs': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.abs(n.evaluate(ctx))\n ],\n 'round': [\n NumberType,\n [NumberType],\n (ctx, [n]) => {\n const v = n.evaluate(ctx);\n // Javascript's Math.round() rounds towards +Infinity for halfway\n // values, even when they're negative. It's more common to round\n // away from 0 (e.g., this is what python and C++ do)\n return v < 0 ? -Math.round(-v) : Math.round(v);\n }\n ],\n 'floor': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.floor(n.evaluate(ctx))\n ],\n 'ceil': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.ceil(n.evaluate(ctx))\n ],\n 'filter-==': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => ctx.properties()[k.value] === v.value\n ],\n 'filter-id-==': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => ctx.id() === v.value\n ],\n 'filter-type-==': [\n BooleanType,\n [StringType],\n (ctx, [v]) => ctx.geometryType() === v.value\n ],\n 'filter-<': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter-id-<': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter->': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-id->': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-<=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter-id-<=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter->=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-id->=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-has': [\n BooleanType,\n [ValueType],\n (ctx, [k]) => k.value in ctx.properties()\n ],\n 'filter-has-id': [\n BooleanType,\n [],\n (ctx) => (ctx.id() !== null && ctx.id() !== undefined)\n ],\n 'filter-type-in': [\n BooleanType,\n [array$1(StringType)],\n (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0\n ],\n 'filter-id-in': [\n BooleanType,\n [array$1(ValueType)],\n (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0\n ],\n 'filter-in-small': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is an array literal\n (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0\n ],\n 'filter-in-large': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is a array literal with values sorted in ascending order and of a single type\n (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)\n ],\n 'all': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (!arg.evaluate(ctx))\n return false;\n }\n return true;\n }\n ]\n ]\n },\n 'any': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (arg.evaluate(ctx))\n return true;\n }\n return false;\n }\n ]\n ]\n },\n '!': [\n BooleanType,\n [BooleanType],\n (ctx, [b]) => !b.evaluate(ctx)\n ],\n 'is-supported-script': [\n BooleanType,\n [StringType],\n // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant\n (ctx, [s]) => {\n const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;\n if (isSupportedScript) {\n return isSupportedScript(s.evaluate(ctx));\n }\n return true;\n }\n ],\n 'upcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toUpperCase()\n ],\n 'downcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toLowerCase()\n ],\n 'concat': [\n StringType,\n varargs(ValueType),\n (ctx, args) => args.map(arg => toString(arg.evaluate(ctx))).join('')\n ],\n 'resolved-locale': [\n StringType,\n [CollatorType],\n (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()\n ]\n});\n\nfunction success(value) {\n return { result: 'success', value };\n}\nfunction error(value) {\n return { result: 'error', value };\n}\n\nfunction supportsPropertyExpression(spec) {\n return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven';\n}\nfunction supportsZoomExpression(spec) {\n return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;\n}\nfunction supportsInterpolation(spec) {\n return !!spec.expression && spec.expression.interpolated;\n}\n\nfunction getType(val) {\n if (val instanceof Number) {\n return 'number';\n }\n else if (val instanceof String) {\n return 'string';\n }\n else if (val instanceof Boolean) {\n return 'boolean';\n }\n else if (Array.isArray(val)) {\n return 'array';\n }\n else if (val === null) {\n return 'null';\n }\n else {\n return typeof val;\n }\n}\n\nfunction isFunction(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\nfunction identityFunction(x) {\n return x;\n}\nfunction createFunction(parameters, propertySpec) {\n const isColor = propertySpec.type === 'color';\n const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');\n if (isColor || propertySpec.type === 'padding') {\n const parseFn = isColor ? Color.parse : Padding.parse;\n parameters = extendBy({}, parameters);\n if (parameters.stops) {\n parameters.stops = parameters.stops.map((stop) => {\n return [stop[0], parseFn(stop[1])];\n });\n }\n if (parameters.default) {\n parameters.default = parseFn(parameters.default);\n }\n else {\n parameters.default = parseFn(propertySpec.default);\n }\n }\n if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) {\n throw new Error(`Unknown color space: \"${parameters.colorSpace}\"`);\n }\n let innerFun;\n let hashedStops;\n let categoricalKeyType;\n if (type === 'exponential') {\n innerFun = evaluateExponentialFunction;\n }\n else if (type === 'interval') {\n innerFun = evaluateIntervalFunction;\n }\n else if (type === 'categorical') {\n innerFun = evaluateCategoricalFunction;\n // For categorical functions, generate an Object as a hashmap of the stops for fast searching\n hashedStops = Object.create(null);\n for (const stop of parameters.stops) {\n hashedStops[stop[0]] = stop[1];\n }\n // Infer key type based on first stop key-- used to encforce strict type checking later\n categoricalKeyType = typeof parameters.stops[0][0];\n }\n else if (type === 'identity') {\n innerFun = evaluateIdentityFunction;\n }\n else {\n throw new Error(`Unknown function type \"${type}\"`);\n }\n if (zoomAndFeatureDependent) {\n const featureFunctions = {};\n const zoomStops = [];\n for (let s = 0; s < parameters.stops.length; s++) {\n const stop = parameters.stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctions[zoom] === undefined) {\n featureFunctions[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n stops: []\n };\n zoomStops.push(zoom);\n }\n featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);\n }\n const featureFunctionStops = [];\n for (const z of zoomStops) {\n featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);\n }\n const interpolationType = { name: 'linear' };\n return {\n kind: 'composite',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: featureFunctionStops.map(s => s[0]),\n evaluate({ zoom }, properties) {\n return evaluateExponentialFunction({\n stops: featureFunctionStops,\n base: parameters.base\n }, propertySpec, zoom).evaluate(zoom, properties);\n }\n };\n }\n else if (zoomDependent) {\n const interpolationType = type === 'exponential' ?\n { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 } : null;\n return {\n kind: 'camera',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: parameters.stops.map(s => s[0]),\n evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)\n };\n }\n else {\n return {\n kind: 'source',\n evaluate(_, feature) {\n const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;\n if (value === undefined) {\n return coalesce$1(parameters.default, propertySpec.default);\n }\n return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);\n }\n };\n }\n}\nfunction coalesce$1(a, b, c) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n if (c !== undefined)\n return c;\n}\nfunction evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {\n const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input\n return coalesce$1(evaluated, parameters.default, propertySpec.default);\n}\nfunction evaluateIntervalFunction(parameters, propertySpec, input) {\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n return parameters.stops[index][1];\n}\nfunction evaluateExponentialFunction(parameters, propertySpec, input) {\n const base = parameters.base !== undefined ? parameters.base : 1;\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);\n const outputLower = parameters.stops[index][1];\n const outputUpper = parameters.stops[index + 1][1];\n const interp = interpolate[propertySpec.type] || identityFunction;\n if (typeof outputLower.evaluate === 'function') {\n return {\n evaluate(...args) {\n const evaluatedLower = outputLower.evaluate.apply(undefined, args);\n const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);\n // Special case for fill-outline-color, which has no spec default.\n if (evaluatedLower === undefined || evaluatedUpper === undefined) {\n return undefined;\n }\n return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace);\n }\n };\n }\n return interp(outputLower, outputUpper, t, parameters.colorSpace);\n}\nfunction evaluateIdentityFunction(parameters, propertySpec, input) {\n switch (propertySpec.type) {\n case 'color':\n input = Color.parse(input);\n break;\n case 'formatted':\n input = Formatted.fromString(input.toString());\n break;\n case 'resolvedImage':\n input = ResolvedImage.fromString(input.toString());\n break;\n case 'padding':\n input = Padding.parse(input);\n break;\n default:\n if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {\n input = undefined;\n }\n }\n return coalesce$1(input, parameters.default, propertySpec.default);\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n *\n * How it works:\n * Two consecutive stop values define a (scaled and shifted) exponential\n * function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction interpolationFactor(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass StyleExpression {\n constructor(expression, propertySpec) {\n this.expression = expression;\n this._warningHistory = {};\n this._evaluator = new EvaluationContext();\n this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;\n this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature;\n this._evaluator.featureState = featureState;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection;\n return this.expression.evaluate(this._evaluator);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature || null;\n this._evaluator.featureState = featureState || null;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection || null;\n try {\n const val = this.expression.evaluate(this._evaluator);\n // eslint-disable-next-line no-self-compare\n if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {\n return this._defaultValue;\n }\n if (this._enumValues && !(val in this._enumValues)) {\n throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);\n }\n return val;\n }\n catch (e) {\n if (!this._warningHistory[e.message]) {\n this._warningHistory[e.message] = true;\n if (typeof console !== 'undefined') {\n console.warn(e.message);\n }\n }\n return this._defaultValue;\n }\n }\n}\nfunction isExpression(expression) {\n return Array.isArray(expression) && expression.length > 0 &&\n typeof expression[0] === 'string' && expression[0] in expressions;\n}\n/**\n * Parse and typecheck the given style spec JSON expression. If\n * options.defaultValue is provided, then the resulting StyleExpression's\n * `evaluate()` method will handle errors by logging a warning (once per\n * message) and returning the default value. Otherwise, it will throw\n * evaluation errors.\n *\n * @private\n */\nfunction createExpression(expression, propertySpec) {\n const parser = new ParsingContext(expressions, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined);\n // For string-valued properties, coerce to string at the top level rather than asserting.\n const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);\n if (!parsed) {\n return error(parser.errors);\n }\n return success(new StyleExpression(parsed, propertySpec));\n}\nclass ZoomConstantExpression {\n constructor(kind, expression) {\n this.kind = kind;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'constant' && !isStateConstant(expression.expression);\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n}\nclass ZoomDependentExpression {\n constructor(kind, expression, zoomStops, interpolationType) {\n this.kind = kind;\n this.zoomStops = zoomStops;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'camera' && !isStateConstant(expression.expression);\n this.interpolationType = interpolationType;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n interpolationFactor(input, lower, upper) {\n if (this.interpolationType) {\n return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);\n }\n else {\n return 0;\n }\n }\n}\nfunction isZoomExpression(expression) {\n return expression._styleExpression !== undefined;\n}\nfunction createPropertyExpression(expressionInput, propertySpec) {\n const expression = createExpression(expressionInput, propertySpec);\n if (expression.result === 'error') {\n return expression;\n }\n const parsed = expression.value.expression;\n const isFeatureConstantResult = isFeatureConstant(parsed);\n if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'data expressions not supported')]);\n }\n const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']);\n if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'zoom expressions not supported')]);\n }\n const zoomCurve = findZoomCurve(parsed);\n if (!zoomCurve && !isZoomConstant) {\n return error([new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.')]);\n }\n else if (zoomCurve instanceof ExpressionParsingError) {\n return error([zoomCurve]);\n }\n else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {\n return error([new ExpressionParsingError('', '\"interpolate\" expressions cannot be used with this property')]);\n }\n if (!zoomCurve) {\n return success(isFeatureConstantResult ?\n new ZoomConstantExpression('constant', expression.value) :\n new ZoomConstantExpression('source', expression.value));\n }\n const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;\n return success(isFeatureConstantResult ?\n new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType) :\n new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType));\n}\n// serialization wrapper for old-style stop functions normalized to the\n// expression interface\nclass StylePropertyFunction {\n constructor(parameters, specification) {\n this._parameters = parameters;\n this._specification = specification;\n extendBy(this, createFunction(this._parameters, this._specification));\n }\n static deserialize(serialized) {\n return new StylePropertyFunction(serialized._parameters, serialized._specification);\n }\n static serialize(input) {\n return {\n _parameters: input._parameters,\n _specification: input._specification\n };\n }\n}\nfunction normalizePropertyExpression(value, specification) {\n if (isFunction(value)) {\n return new StylePropertyFunction(value, specification);\n }\n else if (isExpression(value)) {\n const expression = createPropertyExpression(value, specification);\n if (expression.result === 'error') {\n // this should have been caught in validation\n throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n return expression.value;\n }\n else {\n let constant = value;\n if (specification.type === 'color' && typeof value === 'string') {\n constant = Color.parse(value);\n }\n else if (specification.type === 'padding' && (typeof value === 'number' || Array.isArray(value))) {\n constant = Padding.parse(value);\n }\n else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) {\n constant = VariableAnchorOffsetCollection.parse(value);\n }\n return {\n kind: 'constant',\n evaluate: () => constant\n };\n }\n}\n// Zoom-dependent expressions may only use [\"zoom\"] as the input to a top-level \"step\" or \"interpolate\"\n// expression (collectively referred to as a \"curve\"). The curve may be wrapped in one or more \"let\" or\n// \"coalesce\" expressions.\nfunction findZoomCurve(expression) {\n let result = null;\n if (expression instanceof Let) {\n result = findZoomCurve(expression.result);\n }\n else if (expression instanceof Coalesce) {\n for (const arg of expression.args) {\n result = findZoomCurve(arg);\n if (result) {\n break;\n }\n }\n }\n else if ((expression instanceof Step || expression instanceof Interpolate) &&\n expression.input instanceof CompoundExpression &&\n expression.input.name === 'zoom') {\n result = expression;\n }\n if (result instanceof ExpressionParsingError) {\n return result;\n }\n expression.eachChild((child) => {\n const childResult = findZoomCurve(child);\n if (childResult instanceof ExpressionParsingError) {\n result = childResult;\n }\n else if (!result && childResult) {\n result = new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.');\n }\n else if (result && childResult && result !== childResult) {\n result = new ExpressionParsingError('', 'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.');\n }\n });\n return result;\n}\nfunction getExpectedType(spec) {\n const types = {\n color: ColorType,\n string: StringType,\n number: NumberType,\n enum: StringType,\n boolean: BooleanType,\n formatted: FormattedType,\n padding: PaddingType,\n resolvedImage: ResolvedImageType,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType\n };\n if (spec.type === 'array') {\n return array$1(types[spec.value] || ValueType, spec.length);\n }\n return types[spec.type];\n}\nfunction getDefaultValue(spec) {\n if (spec.type === 'color' && isFunction(spec.default)) {\n // Special case for heatmap-color: it uses the 'default:' to define a\n // default color ramp, but createExpression expects a simple value to fall\n // back to in case of runtime errors\n return new Color(0, 0, 0, 0);\n }\n else if (spec.type === 'color') {\n return Color.parse(spec.default) || null;\n }\n else if (spec.type === 'padding') {\n return Padding.parse(spec.default) || null;\n }\n else if (spec.type === 'variableAnchorOffsetCollection') {\n return VariableAnchorOffsetCollection.parse(spec.default) || null;\n }\n else if (spec.default === undefined) {\n return null;\n }\n else {\n return spec.default;\n }\n}\n\nfunction isExpressionFilter(filter) {\n if (filter === true || filter === false) {\n return true;\n }\n if (!Array.isArray(filter) || filter.length === 0) {\n return false;\n }\n switch (filter[0]) {\n case 'has':\n return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';\n case 'in':\n return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2]));\n case '!in':\n case '!has':\n case 'none':\n return false;\n case '==':\n case '!=':\n case '>':\n case '>=':\n case '<':\n case '<=':\n return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2]));\n case 'any':\n case 'all':\n for (const f of filter.slice(1)) {\n if (!isExpressionFilter(f) && typeof f !== 'boolean') {\n return false;\n }\n }\n return true;\n default:\n return true;\n }\n}\nconst filterSpec = {\n 'type': 'boolean',\n 'default': false,\n 'transition': false,\n 'property-type': 'data-driven',\n 'expression': {\n 'interpolated': false,\n 'parameters': ['zoom', 'feature']\n }\n};\n/**\n * Given a filter expressed as nested arrays, return a new function\n * that evaluates whether a given feature (with a .properties or .tags property)\n * passes its test.\n *\n * @private\n * @param {Array} filter MapLibre filter\n * @returns {Function} filter-evaluating function\n */\nfunction createFilter(filter) {\n if (filter === null || filter === undefined) {\n return { filter: () => true, needGeometry: false };\n }\n if (!isExpressionFilter(filter)) {\n filter = convertFilter$1(filter);\n }\n const compiled = createExpression(filter, filterSpec);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n else {\n const needGeometry = geometryNeeded(filter);\n return { filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical),\n needGeometry };\n }\n}\n// Comparison function to sort numbers and strings\nfunction compare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\nfunction geometryNeeded(filter) {\n if (!Array.isArray(filter))\n return false;\n if (filter[0] === 'within')\n return true;\n for (let index = 1; index < filter.length; index++) {\n if (geometryNeeded(filter[index]))\n return true;\n }\n return false;\n}\nfunction convertFilter$1(filter) {\n if (!filter)\n return true;\n const op = filter[0];\n if (filter.length <= 1)\n return (op !== 'any');\n const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') :\n op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) :\n op === '<' ||\n op === '>' ||\n op === '<=' ||\n op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) :\n op === 'any' ? convertDisjunctionOp(filter.slice(1)) :\n op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) :\n op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) :\n op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) :\n op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) :\n op === 'has' ? convertHasOp$1(filter[1]) :\n op === '!has' ? convertNegation(convertHasOp$1(filter[1])) :\n op === 'within' ? filter :\n true;\n return converted;\n}\nfunction convertComparisonOp$1(property, value, op) {\n switch (property) {\n case '$type':\n return [`filter-type-${op}`, value];\n case '$id':\n return [`filter-id-${op}`, value];\n default:\n return [`filter-${op}`, property, value];\n }\n}\nfunction convertDisjunctionOp(filters) {\n return ['any'].concat(filters.map(convertFilter$1));\n}\nfunction convertInOp$1(property, values) {\n if (values.length === 0) {\n return false;\n }\n switch (property) {\n case '$type':\n return ['filter-type-in', ['literal', values]];\n case '$id':\n return ['filter-id-in', ['literal', values]];\n default:\n if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) {\n return ['filter-in-large', property, ['literal', values.sort(compare)]];\n }\n else {\n return ['filter-in-small', property, ['literal', values]];\n }\n }\n}\nfunction convertHasOp$1(property) {\n switch (property) {\n case '$type':\n return true;\n case '$id':\n return ['filter-has-id'];\n default:\n return ['filter-has', property];\n }\n}\nfunction convertNegation(filter) {\n return ['!', filter];\n}\n\n/*\n * Convert the given filter to an expression, storing the expected types for\n * any feature properties referenced in expectedTypes.\n *\n * These expected types are needed in order to construct preflight type checks\n * needed for handling 'any' filters. A preflight type check is necessary in\n * order to mimic legacy filters' semantics around expected type mismatches.\n * For example, consider the legacy filter:\n *\n * [\"any\", [\"all\", [\">\", \"y\", 0], [\">\", \"y\", 0]], [\">\", \"x\", 0]]\n *\n * Naively, we might convert this to the expression:\n *\n * [\"any\", [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]], [\">\", [\"get\", \"x\"], 0]]\n *\n * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the\n * [\">\", [\"get\", \"y\"], 0] would cause an evaluation error, leading to the\n * entire filter returning false. Legacy filter semantics, though, ask for\n * [\">\", \"y\", 0] to simply return `false` when `y` is of the wrong type,\n * allowing the subsequent terms of the outer \"any\" expression to be evaluated\n * (resulting, in this case, in a `true` value, because x > 0).\n *\n * We account for this by inserting a preflight type-checking expression before\n * each \"any\" term, allowing us to avoid evaluating the actual converted filter\n * if any type mismatches would cause it to produce an evalaution error:\n *\n * [\"any\",\n * [\"case\",\n * [\"all\", [\"==\", [\"typeof\", [\"get\", \"y\"]], \"number\"], [\"==\", [\"typeof\", [\"get\", \"z\"], \"number]],\n * [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]],\n * false\n * ],\n * [\"case\",\n * [\"==\", [\"typeof\", [\"get\", \"x\"], \"number\"]],\n * [\">\", [\"get\", \"x\"], 0],\n * false\n * ]\n * ]\n *\n * An alternative, possibly more direct approach would be to use type checks\n * in the conversion of each comparison operator, so that the converted version\n * of each individual ==, >=, etc. would mimic the legacy filter semantics. The\n * downside of this approach is that it can lead to many more type checks than\n * would otherwise be necessary: outside the context of an \"any\" expression,\n * bailing out due to a runtime type error (expression semantics) and returning\n * false (legacy filter semantics) are equivalent: they cause the filter to\n * produce a `false` result.\n */\nfunction convertFilter(filter, expectedTypes = {}) {\n if (isExpressionFilter(filter))\n return filter;\n if (!filter)\n return true;\n const legacyFilter = filter;\n const legacyOp = legacyFilter[0];\n if (filter.length <= 1)\n return (legacyOp !== 'any');\n switch (legacyOp) {\n case '==':\n case '!=':\n case '<':\n case '>':\n case '<=':\n case '>=': {\n const [, property, value] = filter;\n return convertComparisonOp(property, value, legacyOp, expectedTypes);\n }\n case 'any': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => {\n const types = {};\n const child = convertFilter(f, types);\n const typechecks = runtimeTypeChecks(types);\n return typechecks === true ? child : ['case', typechecks, child, false];\n });\n return ['any', ...children];\n }\n case 'all': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map(f => convertFilter(f, expectedTypes));\n return children.length > 1 ? ['all', ...children] : children[0];\n }\n case 'none': {\n const [, ...conditions] = legacyFilter;\n return ['!', convertFilter(['any', ...conditions], {})];\n }\n case 'in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values);\n }\n case '!in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values, true);\n }\n case 'has':\n return convertHasOp(legacyFilter[1]);\n case '!has':\n return ['!', convertHasOp(legacyFilter[1])];\n default:\n return true;\n }\n}\n// Given a set of feature properties and an expected type for each one,\n// construct an boolean expression that tests whether each property has the\n// right type.\n// E.g.: for {name: 'string', population: 'number'}, return\n// [ 'all',\n// ['==', ['typeof', ['get', 'name'], 'string']],\n// ['==', ['typeof', ['get', 'population'], 'number]]\n// ]\nfunction runtimeTypeChecks(expectedTypes) {\n const conditions = [];\n for (const property in expectedTypes) {\n const get = property === '$id' ? ['id'] : ['get', property];\n conditions.push(['==', ['typeof', get], expectedTypes[property]]);\n }\n if (conditions.length === 0)\n return true;\n if (conditions.length === 1)\n return conditions[0];\n return ['all', ...conditions];\n}\nfunction convertComparisonOp(property, value, op, expectedTypes) {\n let get;\n if (property === '$type') {\n return [op, ['geometry-type'], value];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n if (expectedTypes && value !== null) {\n const type = typeof value;\n expectedTypes[property] = type;\n }\n if (op === '==' && property !== '$id' && value === null) {\n return [\n 'all',\n ['has', property],\n ['==', get, null]\n ];\n }\n else if (op === '!=' && property !== '$id' && value === null) {\n return [\n 'any',\n ['!', ['has', property]],\n ['!=', get, null]\n ];\n }\n return [op, get, value];\n}\nfunction convertInOp(property, values, negate = false) {\n if (values.length === 0)\n return negate;\n let get;\n if (property === '$type') {\n get = ['geometry-type'];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n // Determine if the list of values to be searched is homogenously typed.\n // If so (and if the type is string or number), then we can use a\n // [match, input, [...values], true, false] construction rather than a\n // bunch of `==` tests.\n let uniformTypes = true;\n const type = typeof values[0];\n for (const value of values) {\n if (typeof value !== type) {\n uniformTypes = false;\n break;\n }\n }\n if (uniformTypes && (type === 'string' || type === 'number')) {\n // Match expressions must have unique values.\n const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);\n return ['match', get, uniqueValues, !negate, negate];\n }\n if (negate) {\n return ['all', ...values.map(v => ['!=', get, v])];\n }\n else {\n return ['any', ...values.map(v => ['==', get, v])];\n }\n}\nfunction convertHasOp(property) {\n if (property === '$type') {\n return true;\n }\n else if (property === '$id') {\n return ['!=', ['id'], null];\n }\n else {\n return ['has', property];\n }\n}\n\nfunction convertLiteral(value) {\n return typeof value === 'object' ? ['literal', value] : value;\n}\nfunction convertFunction(parameters, propertySpec) {\n let stops = parameters.stops;\n if (!stops) {\n // identity function\n return convertIdentityFunction(parameters, propertySpec);\n }\n const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n stops = stops.map((stop) => {\n if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {\n return [stop[0], convertTokenString(stop[1])];\n }\n return [stop[0], convertLiteral(stop[1])];\n });\n if (zoomAndFeatureDependent) {\n return convertZoomAndPropertyFunction(parameters, propertySpec, stops);\n }\n else if (zoomDependent) {\n return convertZoomFunction(parameters, propertySpec, stops);\n }\n else {\n return convertPropertyFunction(parameters, propertySpec, stops);\n }\n}\nfunction convertIdentityFunction(parameters, propertySpec) {\n const get = ['get', parameters.property];\n if (parameters.default === undefined) {\n // By default, expressions for string-valued properties get coerced. To preserve\n // legacy function semantics, insert an explicit assertion instead.\n return propertySpec.type === 'string' ? ['string', get] : get;\n }\n else if (propertySpec.type === 'enum') {\n return [\n 'match',\n get,\n Object.keys(propertySpec.values),\n get,\n parameters.default\n ];\n }\n else {\n const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];\n if (propertySpec.type === 'array') {\n expression.splice(1, 0, propertySpec.value, propertySpec.length || null);\n }\n return expression;\n }\n}\nfunction getInterpolateOperator(parameters) {\n switch (parameters.colorSpace) {\n case 'hcl': return 'interpolate-hcl';\n case 'lab': return 'interpolate-lab';\n default: return 'interpolate';\n }\n}\nfunction convertZoomAndPropertyFunction(parameters, propertySpec, stops) {\n const featureFunctionParameters = {};\n const featureFunctionStops = {};\n const zoomStops = [];\n for (let s = 0; s < stops.length; s++) {\n const stop = stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctionParameters[zoom] === undefined) {\n featureFunctionParameters[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n };\n featureFunctionStops[zoom] = [];\n zoomStops.push(zoom);\n }\n featureFunctionStops[zoom].push([stop[0].value, stop[1]]);\n }\n // the interpolation type for the zoom dimension of a zoom-and-property\n // function is determined directly from the style property specification\n // for which it's being used: linear for interpolatable properties, step\n // otherwise.\n const functionType = getFunctionType({}, propertySpec);\n if (functionType === 'exponential') {\n const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, false);\n }\n return expression;\n }\n else {\n const expression = ['step', ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, true);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n }\n}\nfunction coalesce(a, b) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n}\nfunction getFallback(parameters, propertySpec) {\n const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));\n /*\n * Some fields with type: resolvedImage have an undefined default.\n * Because undefined is an invalid value for resolvedImage, set fallback to\n * an empty string instead of undefined to ensure output\n * passes validation.\n */\n if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {\n return '';\n }\n return defaultValue;\n}\nfunction convertPropertyFunction(parameters, propertySpec, stops) {\n const type = getFunctionType(parameters, propertySpec);\n const get = ['get', parameters.property];\n if (type === 'categorical' && typeof stops[0][0] === 'boolean') {\n const expression = ['case'];\n for (const stop of stops) {\n expression.push(['==', get, stop[0]], stop[1]);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'categorical') {\n const expression = ['match', get];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'interval') {\n const expression = ['step', ['number', get]];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], true);\n }\n fixupDegenerateStepCurve(expression);\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n const expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n ['number', get]\n ];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else {\n throw new Error(`Unknown property function type ${type}`);\n }\n}\nfunction convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) {\n const type = getFunctionType(parameters, propertySpec);\n let expression;\n let isStep = false;\n if (type === 'interval') {\n expression = ['step', input];\n isStep = true;\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n expression = [getInterpolateOperator(parameters), base === 1 ? ['linear'] : ['exponential', base], input];\n }\n else {\n throw new Error(`Unknown zoom function type \"${type}\"`);\n }\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], isStep);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n}\nfunction fixupDegenerateStepCurve(expression) {\n // degenerate step curve (i.e. a constant function): add a noop stop\n if (expression[0] === 'step' && expression.length === 3) {\n expression.push(0);\n expression.push(expression[3]);\n }\n}\nfunction appendStopPair(curve, input, output, isStep) {\n // Skip duplicate stop values. They were not validated for functions, but they are for expressions.\n // https://github.com/mapbox/mapbox-gl-js/issues/4107\n if (curve.length > 3 && input === curve[curve.length - 2]) {\n return;\n }\n // step curves don't get the first input value, as it is redundant.\n if (!(isStep && curve.length === 2)) {\n curve.push(input);\n }\n curve.push(output);\n}\nfunction getFunctionType(parameters, propertySpec) {\n if (parameters.type) {\n return parameters.type;\n }\n else {\n return propertySpec.expression.interpolated ? 'exponential' : 'interval';\n }\n}\n// \"String with {name} token\" => [\"concat\", \"String with \", [\"get\", \"name\"], \" token\"]\nfunction convertTokenString(s) {\n const result = ['concat'];\n const re = /{([^{}]+)}/g;\n let pos = 0;\n for (let match = re.exec(s); match !== null; match = re.exec(s)) {\n const literal = s.slice(pos, re.lastIndex - match[0].length);\n pos = re.lastIndex;\n if (literal.length > 0)\n result.push(literal);\n result.push(['get', match[1]]);\n }\n if (result.length === 1) {\n return s;\n }\n if (pos < s.length) {\n result.push(s.slice(pos));\n }\n else if (result.length === 2) {\n return ['to-string', result[1]];\n }\n return result;\n}\n\nfunction getPropertyReference(propertyName) {\n for (let i = 0; i < v8Spec.layout.length; i++) {\n for (const key in v8Spec[v8Spec.layout[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.layout[i]][key];\n }\n }\n for (let i = 0; i < v8Spec.paint.length; i++) {\n for (const key in v8Spec[v8Spec.paint[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.paint[i]][key];\n }\n }\n return null;\n}\nfunction eachSource(style, callback) {\n for (const k in style.sources) {\n callback(style.sources[k]);\n }\n}\nfunction eachLayer(style, callback) {\n for (const layer of style.layers) {\n callback(layer);\n }\n}\nfunction eachProperty(style, options, callback) {\n function inner(layer, propertyType) {\n const properties = layer[propertyType];\n if (!properties)\n return;\n Object.keys(properties).forEach((key) => {\n callback({\n path: [layer.id, propertyType, key],\n key,\n value: properties[key],\n reference: getPropertyReference(key),\n set(x) {\n properties[key] = x;\n }\n });\n });\n }\n eachLayer(style, (layer) => {\n if (options.paint) {\n inner(layer, 'paint');\n }\n if (options.layout) {\n inner(layer, 'layout');\n }\n });\n}\n\nfunction stringify(obj) {\n const type = typeof obj;\n if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null)\n return JSON.stringify(obj);\n if (Array.isArray(obj)) {\n let str = '[';\n for (const val of obj) {\n str += `${stringify(val)},`;\n }\n return `${str}]`;\n }\n const keys = Object.keys(obj).sort();\n let str = '{';\n for (let i = 0; i < keys.length; i++) {\n str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`;\n }\n return `${str}}`;\n}\nfunction getKey(layer) {\n let key = '';\n for (const k of refProperties) {\n key += `/${stringify(layer[k])}`;\n }\n return key;\n}\n/**\n * Given an array of layers, return an array of arrays of layers where all\n * layers in each group have identical layout-affecting properties. These\n * are the properties that were formerly used by explicit `ref` mechanism\n * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n * 'filter', and 'layout'.\n *\n * The input is not modified. The output layers are references to the\n * input layers.\n *\n * @private\n * @param {Array} layers\n * @param {Object} [cachedKeys] - an object to keep already calculated keys.\n * @returns {Array>}\n */\nfunction groupByLayout(layers, cachedKeys) {\n const groups = {};\n for (let i = 0; i < layers.length; i++) {\n const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);\n // update the cache if there is one\n if (cachedKeys)\n cachedKeys[layers[i].id] = k;\n let group = groups[k];\n if (!group) {\n group = groups[k] = [];\n }\n group.push(layers[i]);\n }\n const result = [];\n for (const k in groups) {\n result.push(groups[k]);\n }\n return result;\n}\n\nfunction emptyStyle() {\n const style = {};\n const version = v8Spec['$version'];\n for (const styleKey in v8Spec['$root']) {\n const spec = v8Spec['$root'][styleKey];\n if (spec.required) {\n let value = null;\n if (styleKey === 'version') {\n value = version;\n }\n else {\n if (spec.type === 'array') {\n value = [];\n }\n else {\n value = {};\n }\n }\n if (value != null) {\n style[styleKey] = value;\n }\n }\n }\n return style;\n}\n\nfunction validateConstants(options) {\n const key = options.key;\n const constants = options.value;\n if (constants) {\n return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];\n }\n else {\n return [];\n }\n}\n\n// Turn jsonlint-lines-primitives objects into primitive objects\nfunction unbundle(value) {\n if (value instanceof Number || value instanceof String || value instanceof Boolean) {\n return value.valueOf();\n }\n else {\n return value;\n }\n}\nfunction deepUnbundle(value) {\n if (Array.isArray(value)) {\n return value.map(deepUnbundle);\n }\n else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {\n const unbundledValue = {};\n for (const key in value) {\n unbundledValue[key] = deepUnbundle(value[key]);\n }\n return unbundledValue;\n }\n return unbundle(value);\n}\n\nfunction validateObject(options) {\n const key = options.key;\n const object = options.value;\n const elementSpecs = options.valueSpec || {};\n const elementValidators = options.objectElementValidators || {};\n const style = options.style;\n const styleSpec = options.styleSpec;\n const validateSpec = options.validateSpec;\n let errors = [];\n const type = getType(object);\n if (type !== 'object') {\n return [new ValidationError(key, object, `object expected, ${type} found`)];\n }\n for (const objectKey in object) {\n const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'\n const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];\n let validateElement;\n if (elementValidators[elementSpecKey]) {\n validateElement = elementValidators[elementSpecKey];\n }\n else if (elementSpecs[elementSpecKey]) {\n validateElement = validateSpec;\n }\n else if (elementValidators['*']) {\n validateElement = elementValidators['*'];\n }\n else if (elementSpecs['*']) {\n validateElement = validateSpec;\n }\n else {\n errors.push(new ValidationError(key, object[objectKey], `unknown property \"${objectKey}\"`));\n continue;\n }\n errors = errors.concat(validateElement({\n key: (key ? `${key}.` : key) + objectKey,\n value: object[objectKey],\n valueSpec: elementSpec,\n style,\n styleSpec,\n object,\n objectKey,\n validateSpec,\n }, object));\n }\n for (const elementSpecKey in elementSpecs) {\n // Don't check `required` when there's a custom validator for that property.\n if (elementValidators[elementSpecKey]) {\n continue;\n }\n if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {\n errors.push(new ValidationError(key, object, `missing required property \"${elementSpecKey}\"`));\n }\n }\n return errors;\n}\n\nfunction validateArray(options) {\n const array = options.value;\n const arraySpec = options.valueSpec;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const key = options.key;\n const validateArrayElement = options.arrayElementValidator || validateSpec;\n if (getType(array) !== 'array') {\n return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];\n }\n if (arraySpec.length && array.length !== arraySpec.length) {\n return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)];\n }\n if (arraySpec['min-length'] && array.length < arraySpec['min-length']) {\n return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)];\n }\n let arrayElementSpec = {\n 'type': arraySpec.value,\n 'values': arraySpec.values\n };\n if (styleSpec.$version < 7) {\n arrayElementSpec['function'] = arraySpec.function;\n }\n if (getType(arraySpec.value) === 'object') {\n arrayElementSpec = arraySpec.value;\n }\n let errors = [];\n for (let i = 0; i < array.length; i++) {\n errors = errors.concat(validateArrayElement({\n array,\n arrayIndex: i,\n value: array[i],\n valueSpec: arrayElementSpec,\n validateSpec: options.validateSpec,\n style,\n styleSpec,\n key: `${key}[${i}]`\n }));\n }\n return errors;\n}\n\nfunction validateNumber(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n let type = getType(value);\n // eslint-disable-next-line no-self-compare\n if (type === 'number' && value !== value) {\n type = 'NaN';\n }\n if (type !== 'number') {\n return [new ValidationError(key, value, `number expected, ${type} found`)];\n }\n if ('minimum' in valueSpec && value < valueSpec.minimum) {\n return [new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)];\n }\n if ('maximum' in valueSpec && value > valueSpec.maximum) {\n return [new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)];\n }\n return [];\n}\n\nfunction validateFunction(options) {\n const functionValueSpec = options.valueSpec;\n const functionType = unbundle(options.value.type);\n let stopKeyType;\n let stopDomainValues = {};\n let previousStopDomainValue;\n let previousStopDomainZoom;\n const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;\n const isPropertyFunction = !isZoomFunction;\n const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' &&\n getType(options.value.stops[0]) === 'array' &&\n getType(options.value.stops[0][0]) === 'object';\n const errors = validateObject({\n key: options.key,\n value: options.value,\n valueSpec: options.styleSpec.function,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n stops: validateFunctionStops,\n default: validateFunctionDefault\n }\n });\n if (functionType === 'identity' && isZoomFunction) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"property\"'));\n }\n if (functionType !== 'identity' && !options.value.stops) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"stops\"'));\n }\n if (functionType === 'exponential' && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported'));\n }\n if (options.styleSpec.$version >= 8) {\n if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'property functions not supported'));\n }\n else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));\n }\n }\n if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) {\n errors.push(new ValidationError(options.key, options.value, '\"property\" property is required'));\n }\n return errors;\n function validateFunctionStops(options) {\n if (functionType === 'identity') {\n return [new ValidationError(options.key, options.value, 'identity function may not have a \"stops\" property')];\n }\n let errors = [];\n const value = options.value;\n errors = errors.concat(validateArray({\n key: options.key,\n value,\n valueSpec: options.valueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n arrayElementValidator: validateFunctionStop\n }));\n if (getType(value) === 'array' && value.length === 0) {\n errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));\n }\n return errors;\n }\n function validateFunctionStop(options) {\n let errors = [];\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n if (value.length !== 2) {\n return [new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)];\n }\n if (isZoomAndPropertyFunction) {\n if (getType(value[0]) !== 'object') {\n return [new ValidationError(key, value, `object expected, ${getType(value[0])} found`)];\n }\n if (value[0].zoom === undefined) {\n return [new ValidationError(key, value, 'object stop key must have zoom')];\n }\n if (value[0].value === undefined) {\n return [new ValidationError(key, value, 'object stop key must have value')];\n }\n if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {\n return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')];\n }\n if (unbundle(value[0].zoom) !== previousStopDomainZoom) {\n previousStopDomainZoom = unbundle(value[0].zoom);\n previousStopDomainValue = undefined;\n stopDomainValues = {};\n }\n errors = errors.concat(validateObject({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: { zoom: {} },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue }\n }));\n }\n else {\n errors = errors.concat(validateStopDomainValue({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: {},\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }, value));\n }\n if (isExpression(deepUnbundle(value[1]))) {\n return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]);\n }\n return errors.concat(options.validateSpec({\n key: `${key}[1]`,\n value: value[1],\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n function validateStopDomainValue(options, stop) {\n const type = getType(options.value);\n const value = unbundle(options.value);\n const reportValue = options.value !== null ? options.value : stop;\n if (!stopKeyType) {\n stopKeyType = type;\n }\n else if (type !== stopKeyType) {\n return [new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)];\n }\n if (type !== 'number' && type !== 'string' && type !== 'boolean') {\n return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];\n }\n if (type !== 'number' && functionType !== 'categorical') {\n let message = `number expected, ${type} found`;\n if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {\n message += '\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.';\n }\n return [new ValidationError(options.key, reportValue, message)];\n }\n if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) {\n return [new ValidationError(options.key, reportValue, `integer expected, found ${value}`)];\n }\n if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];\n }\n else {\n previousStopDomainValue = value;\n }\n if (functionType === 'categorical' && value in stopDomainValues) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];\n }\n else {\n stopDomainValues[value] = true;\n }\n return [];\n }\n function validateFunctionDefault(options) {\n return options.validateSpec({\n key: options.key,\n value: options.value,\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n });\n }\n}\n\nfunction validateExpression(options) {\n const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);\n if (expression.result === 'error') {\n return expression.value.map((error) => {\n return new ValidationError(`${options.key}${error.key}`, options.value, error.message);\n });\n }\n const expressionObj = expression.value.expression || expression.value._styleExpression.expression;\n if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&\n !expressionObj.outputDefined()) {\n return [new ValidationError(options.key, options.value, `Invalid data expression for \"${options.propertyKey}\". Output values must be contained as literals within the expression.`)];\n }\n if (options.expressionContext === 'property' && options.propertyType === 'layout' &&\n (!isStateConstant(expressionObj))) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with layout properties.')];\n }\n if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with filters.')];\n }\n if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {\n if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {\n return [new ValidationError(options.key, options.value, '\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.')];\n }\n if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')];\n }\n }\n return [];\n}\n\nfunction validateBoolean(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'boolean') {\n return [new ValidationError(key, value, `boolean expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateColor(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `color expected, ${type} found`)];\n }\n if (!Color.parse(String(value))) { // cast String object to string primitive\n return [new ValidationError(key, value, `color expected, \"${value}\" found`)];\n }\n return [];\n}\n\nfunction validateEnum(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n const errors = [];\n if (Array.isArray(valueSpec.values)) { // <=v7\n if (valueSpec.values.indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n else { // >=v8\n if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n return errors;\n}\n\nfunction validateFilter(options) {\n if (isExpressionFilter(deepUnbundle(options.value))) {\n return validateExpression(extendBy({}, options, {\n expressionContext: 'filter',\n valueSpec: { value: 'boolean' }\n }));\n }\n else {\n return validateNonExpressionFilter(options);\n }\n}\nfunction validateNonExpressionFilter(options) {\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n const styleSpec = options.styleSpec;\n let type;\n let errors = [];\n if (value.length < 1) {\n return [new ValidationError(key, value, 'filter array must have at least 1 element')];\n }\n errors = errors.concat(validateEnum({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: styleSpec.filter_operator,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n switch (unbundle(value[0])) {\n case '<':\n case '<=':\n case '>':\n case '>=':\n if (value.length >= 2 && unbundle(value[1]) === '$type') {\n errors.push(new ValidationError(key, value, `\"$type\" cannot be use with operator \"${value[0]}\"`));\n }\n /* falls through */\n case '==':\n case '!=':\n if (value.length !== 3) {\n errors.push(new ValidationError(key, value, `filter array for operator \"${value[0]}\" must have 3 elements`));\n }\n /* falls through */\n case 'in':\n case '!in':\n if (value.length >= 2) {\n type = getType(value[1]);\n if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n }\n for (let i = 2; i < value.length; i++) {\n type = getType(value[i]);\n if (unbundle(value[1]) === '$type') {\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec.geometry_type,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));\n }\n }\n break;\n case 'any':\n case 'all':\n case 'none':\n for (let i = 1; i < value.length; i++) {\n errors = errors.concat(validateNonExpressionFilter({\n key: `${key}[${i}]`,\n value: value[i],\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n break;\n case 'has':\n case '!has':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n break;\n case 'within':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'object') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`));\n }\n break;\n }\n return errors;\n}\n\nfunction validateProperty(options, propertyType) {\n const key = options.key;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const value = options.value;\n const propertyKey = options.objectKey;\n const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];\n if (!layerSpec)\n return [];\n const transitionMatch = propertyKey.match(/^(.*)-transition$/);\n if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {\n return validateSpec({\n key,\n value,\n valueSpec: styleSpec.transition,\n style,\n styleSpec\n });\n }\n const valueSpec = options.valueSpec || layerSpec[propertyKey];\n if (!valueSpec) {\n return [new ValidationError(key, value, `unknown property \"${propertyKey}\"`)];\n }\n let tokenMatch;\n if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {\n return [new ValidationError(key, value, `\"${propertyKey}\" does not support interpolation syntax\\n` +\n `Use an identity property function instead: \\`{ \"type\": \"identity\", \"property\": ${JSON.stringify(tokenMatch[1])} }\\`.`)];\n }\n const errors = [];\n if (options.layerType === 'symbol') {\n if (propertyKey === 'text-field' && style && !style.glyphs) {\n errors.push(new ValidationError(key, value, 'use of \"text-field\" requires a style \"glyphs\" property'));\n }\n if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') {\n errors.push(new ValidationError(key, value, '\"text-font\" does not support identity functions'));\n }\n }\n return errors.concat(validateSpec({\n key: options.key,\n value,\n valueSpec,\n style,\n styleSpec,\n expressionContext: 'property',\n propertyType,\n propertyKey\n }));\n}\n\nfunction validatePaintProperty(options) {\n return validateProperty(options, 'paint');\n}\n\nfunction validateLayoutProperty(options) {\n return validateProperty(options, 'layout');\n}\n\nfunction validateLayer(options) {\n let errors = [];\n const layer = options.value;\n const key = options.key;\n const style = options.style;\n const styleSpec = options.styleSpec;\n if (!layer.type && !layer.ref) {\n errors.push(new ValidationError(key, layer, 'either \"type\" or \"ref\" is required'));\n }\n let type = unbundle(layer.type);\n const ref = unbundle(layer.ref);\n if (layer.id) {\n const layerId = unbundle(layer.id);\n for (let i = 0; i < options.arrayIndex; i++) {\n const otherLayer = style.layers[i];\n if (unbundle(otherLayer.id) === layerId) {\n errors.push(new ValidationError(key, layer.id, `duplicate layer id \"${layer.id}\", previously used at line ${otherLayer.id.__line__}`));\n }\n }\n }\n if ('ref' in layer) {\n ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => {\n if (p in layer) {\n errors.push(new ValidationError(key, layer[p], `\"${p}\" is prohibited for ref layers`));\n }\n });\n let parent;\n style.layers.forEach((layer) => {\n if (unbundle(layer.id) === ref)\n parent = layer;\n });\n if (!parent) {\n errors.push(new ValidationError(key, layer.ref, `ref layer \"${ref}\" not found`));\n }\n else if (parent.ref) {\n errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));\n }\n else {\n type = unbundle(parent.type);\n }\n }\n else if (type !== 'background') {\n if (!layer.source) {\n errors.push(new ValidationError(key, layer, 'missing required property \"source\"'));\n }\n else {\n const source = style.sources && style.sources[layer.source];\n const sourceType = source && unbundle(source.type);\n if (!source) {\n errors.push(new ValidationError(key, layer.source, `source \"${layer.source}\" not found`));\n }\n else if (sourceType === 'vector' && type === 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'hillshade') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType === 'raster' && type !== 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a vector source`));\n }\n else if (sourceType === 'vector' && !layer['source-layer']) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" must specify a \"source-layer\"`));\n }\n else if (sourceType === 'raster-dem' && type !== 'hillshade') {\n errors.push(new ValidationError(key, layer.source, 'raster-dem source can only be used with layer type \\'hillshade\\'.'));\n }\n else if (type === 'line' && layer.paint && layer.paint['line-gradient'] &&\n (sourceType !== 'geojson' || !source.lineMetrics)) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`));\n }\n }\n }\n errors = errors.concat(validateObject({\n key,\n value: layer,\n valueSpec: styleSpec.layer,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'() {\n return [];\n },\n // We don't want to enforce the spec's `\"requires\": true` for backward compatibility with refs;\n // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772.\n type() {\n return options.validateSpec({\n key: `${key}.type`,\n value: layer.type,\n valueSpec: styleSpec.layer.type,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n object: layer,\n objectKey: 'type'\n });\n },\n filter: validateFilter,\n layout(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validateLayoutProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n },\n paint(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validatePaintProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n }\n }\n }));\n return errors;\n}\n\nfunction validateString(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `string expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateRasterDEMSource(options) {\n var _a;\n const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';\n const rasterDEM = options.value;\n const styleSpec = options.styleSpec;\n const rasterDEMSpec = styleSpec.source_raster_dem;\n const style = options.style;\n let errors = [];\n const rootType = getType(rasterDEM);\n if (rasterDEM === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));\n return errors;\n }\n const encoding = unbundle(rasterDEM.encoding);\n const isCustomEncoding = encoding === 'custom';\n const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];\n const encodingName = options.value.encoding ? `\"${options.value.encoding}\"` : 'Default';\n for (const key in rasterDEM) {\n if (!isCustomEncoding && customEncodingKeys.includes(key)) {\n errors.push(new ValidationError(key, rasterDEM[key], `In \"${sourceName}\": \"${key}\" is only valid when \"encoding\" is set to \"custom\". ${encodingName} encoding found`));\n }\n else if (rasterDEMSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: rasterDEM[key],\n valueSpec: rasterDEMSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors.push(new ValidationError(key, rasterDEM[key], `unknown property \"${key}\"`));\n }\n }\n return errors;\n}\n\nconst objectElementValidators = {\n promoteId: validatePromoteId\n};\nfunction validateSource(options) {\n const value = options.value;\n const key = options.key;\n const styleSpec = options.styleSpec;\n const style = options.style;\n const validateSpec = options.validateSpec;\n if (!value.type) {\n return [new ValidationError(key, value, '\"type\" is required')];\n }\n const type = unbundle(value.type);\n let errors;\n switch (type) {\n case 'vector':\n case 'raster':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec[`source_${type.replace('-', '_')}`],\n style: options.style,\n styleSpec,\n objectElementValidators,\n validateSpec,\n });\n return errors;\n case 'raster-dem':\n errors = validateRasterDEMSource({\n sourceName: key,\n value,\n style: options.style,\n styleSpec,\n validateSpec,\n });\n return errors;\n case 'geojson':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec.source_geojson,\n style,\n styleSpec,\n validateSpec,\n objectElementValidators\n });\n if (value.cluster) {\n for (const prop in value.clusterProperties) {\n const [operator, mapExpr] = value.clusterProperties[prop];\n const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator;\n errors.push(...validateExpression({\n key: `${key}.${prop}.map`,\n value: mapExpr,\n validateSpec,\n expressionContext: 'cluster-map'\n }));\n errors.push(...validateExpression({\n key: `${key}.${prop}.reduce`,\n value: reduceExpr,\n validateSpec,\n expressionContext: 'cluster-reduce'\n }));\n }\n }\n return errors;\n case 'video':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_video,\n style,\n validateSpec,\n styleSpec\n });\n case 'image':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_image,\n style,\n validateSpec,\n styleSpec\n });\n case 'canvas':\n return [new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')];\n default:\n return validateEnum({\n key: `${key}.type`,\n value: value.type,\n valueSpec: { values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image'] },\n style,\n validateSpec,\n styleSpec\n });\n }\n}\nfunction validatePromoteId({ key, value }) {\n if (getType(value) === 'string') {\n return validateString({ key, value });\n }\n else {\n const errors = [];\n for (const prop in value) {\n errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] }));\n }\n return errors;\n }\n}\n\nfunction validateLight(options) {\n const light = options.value;\n const styleSpec = options.styleSpec;\n const lightSpec = styleSpec.light;\n const style = options.style;\n let errors = [];\n const rootType = getType(light);\n if (light === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in light) {\n const transitionMatch = key.match(/^(.*)-transition$/);\n if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: styleSpec.transition,\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else if (lightSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: lightSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, light[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateTerrain(options) {\n const terrain = options.value;\n const styleSpec = options.styleSpec;\n const terrainSpec = styleSpec.terrain;\n const style = options.style;\n let errors = [];\n const rootType = getType(terrain);\n if (terrain === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in terrain) {\n if (terrainSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: terrain[key],\n valueSpec: terrainSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, terrain[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateFormatted(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validateImage(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validatePadding(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1 || value.length > 4) {\n return [new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)];\n }\n const arrayElementSpec = {\n type: 'number'\n };\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateVariableAnchorOffsetCollection(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n const styleSpec = options.styleSpec;\n if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) {\n return [new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')];\n }\n let errors = [];\n for (let i = 0; i < value.length; i += 2) {\n // Elements in even positions should be values from text-anchor enum\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec['layout_symbol']['text-anchor']\n }));\n // Elements in odd positions should be points (2-element numeric arrays)\n errors = errors.concat(validateArray({\n key: `${key}[${i + 1}]`,\n value: value[i + 1],\n valueSpec: {\n length: 2,\n value: 'number'\n },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec\n }));\n }\n return errors;\n}\n\nfunction validateSprite(options) {\n let errors = [];\n const sprite = options.value;\n const key = options.key;\n if (!Array.isArray(sprite)) {\n return validateString({\n key,\n value: sprite\n });\n }\n else {\n const allSpriteIds = [];\n const allSpriteURLs = [];\n for (const i in sprite) {\n if (sprite[i].id && allSpriteIds.includes(sprite[i].id))\n errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`));\n allSpriteIds.push(sprite[i].id);\n if (sprite[i].url && allSpriteURLs.includes(sprite[i].url))\n errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`));\n allSpriteURLs.push(sprite[i].url);\n const pairSpec = {\n id: {\n type: 'string',\n required: true,\n },\n url: {\n type: 'string',\n required: true,\n }\n };\n errors = errors.concat(validateObject({\n key: `${key}[${i}]`,\n value: sprite[i],\n valueSpec: pairSpec,\n validateSpec: options.validateSpec,\n }));\n }\n return errors;\n }\n}\n\nconst VALIDATORS = {\n '*'() {\n return [];\n },\n 'array': validateArray,\n 'boolean': validateBoolean,\n 'number': validateNumber,\n 'color': validateColor,\n 'constants': validateConstants,\n 'enum': validateEnum,\n 'filter': validateFilter,\n 'function': validateFunction,\n 'layer': validateLayer,\n 'object': validateObject,\n 'source': validateSource,\n 'light': validateLight,\n 'terrain': validateTerrain,\n 'string': validateString,\n 'formatted': validateFormatted,\n 'resolvedImage': validateImage,\n 'padding': validatePadding,\n 'variableAnchorOffsetCollection': validateVariableAnchorOffsetCollection,\n 'sprite': validateSprite,\n};\n// Main recursive validation function. Tracks:\n//\n// - key: string representing location of validation in style tree. Used only\n// for more informative error reporting.\n// - value: current value from style being evaluated. May be anything from a\n// high level object that needs to be descended into deeper or a simple\n// scalar value.\n// - valueSpec: current spec being evaluated. Tracks value.\n// - styleSpec: current full spec being evaluated.\nfunction validate(options) {\n const value = options.value;\n const valueSpec = options.valueSpec;\n const styleSpec = options.styleSpec;\n options.validateSpec = validate;\n if (valueSpec.expression && isFunction(unbundle(value))) {\n return validateFunction(options);\n }\n else if (valueSpec.expression && isExpression(deepUnbundle(value))) {\n return validateExpression(options);\n }\n else if (valueSpec.type && VALIDATORS[valueSpec.type]) {\n return VALIDATORS[valueSpec.type](options);\n }\n else {\n const valid = validateObject(extendBy({}, options, {\n valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec\n }));\n return valid;\n }\n}\n\nfunction validateGlyphsUrl(options) {\n const value = options.value;\n const key = options.key;\n const errors = validateString(options);\n if (errors.length)\n return errors;\n if (value.indexOf('{fontstack}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{fontstack}\" token'));\n }\n if (value.indexOf('{range}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{range}\" token'));\n }\n return errors;\n}\n\n/**\n * Validate a MapLibre style against the style specification. This entrypoint,\n * `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as\n * small a browserify bundle as possible by omitting unnecessary functionality\n * and legacy style specifications.\n *\n * @private\n * @param {Object} style The style to be validated.\n * @param {Object} [styleSpec] The style specification to validate against.\n * If omitted, the latest style spec is used.\n * @returns {Array}\n * @example\n * var validate = require('maplibre-gl-style-spec/lib/validate_style.min');\n * var errors = validate(style);\n */\nfunction validateStyleMin(style, styleSpec = v8Spec) {\n let errors = [];\n errors = errors.concat(validate({\n key: '',\n value: style,\n valueSpec: styleSpec.$root,\n styleSpec,\n style,\n validateSpec: validate,\n objectElementValidators: {\n glyphs: validateGlyphsUrl,\n '*'() {\n return [];\n }\n }\n }));\n if (style['constants']) {\n errors = errors.concat(validateConstants({\n key: 'constants',\n value: style['constants'],\n style,\n styleSpec,\n validateSpec: validate,\n }));\n }\n return sortErrors(errors);\n}\nvalidateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource));\nvalidateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite));\nvalidateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl));\nvalidateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight));\nvalidateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain));\nvalidateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer));\nvalidateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter));\nvalidateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty));\nvalidateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty));\nfunction injectValidateSpec(validator) {\n return function (options) {\n return validator({\n ...options,\n validateSpec: validate,\n });\n };\n}\nfunction sortErrors(errors) {\n return [].concat(errors).sort((a, b) => {\n return a.line - b.line;\n });\n}\nfunction wrapCleanErrors(inner) {\n return function (...args) {\n return sortErrors(inner.apply(this, args));\n };\n}\n\nconst v8 = v8Spec;\nconst expression = {\n StyleExpression,\n StylePropertyFunction,\n ZoomConstantExpression,\n ZoomDependentExpression,\n createExpression,\n createPropertyExpression,\n isExpression,\n isExpressionFilter,\n isZoomExpression,\n normalizePropertyExpression,\n};\nconst styleFunction = {\n convertFunction,\n createFunction,\n isFunction\n};\nconst visit = { eachLayer, eachProperty, eachSource };\n\nexport { Color, ColorType, CompoundExpression, EvaluationContext, FormatExpression, Formatted, FormattedSection, FormattedType, Interpolate, Literal, NullType, Padding, ParsingError, ResolvedImage, Step, StyleExpression, StylePropertyFunction, ValidationError, VariableAnchorOffsetCollection, ZoomConstantExpression, ZoomDependentExpression, convertFilter, convertFunction, createExpression, createFunction, createPropertyExpression, derefLayers, diffStyles as diff, emptyStyle, expression, expressions, createFilter as featureFilter, styleFunction as function, groupByLayout, interpolateFactory, interpolate as interpolates, isExpression, isFunction, isZoomExpression, v8Spec as latest, normalizePropertyExpression, operations, supportsPropertyExpression, toString$1 as toString, typeOf, v8, validateStyleMin, visit };\n//# sourceMappingURL=index.mjs.map\n","import type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from './ajax';\n\n/**\n * This is a global config object used to store the configuration\n * It is available in the workers as well.\n * Only serializable data should be stored in it.\n */\ntype Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: number;\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number;\n MAX_TILE_CACHE_ZOOM_LEVELS: number;\n REGISTERED_PROTOCOLS: {[x: string]: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable};\n WORKER_URL: string;\n};\n\nexport const config: Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: 16,\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8,\n MAX_TILE_CACHE_ZOOM_LEVELS: 5,\n REGISTERED_PROTOCOLS: {},\n WORKER_URL: ''\n};\n","import {extend, warnOnce, isWorker} from './util';\nimport {config} from './config';\n\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\n/**\n * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks.\n * @example\n * ```ts\n * // use transformRequest to modify requests that begin with `http://myHost`\n * transformRequest: function(url, resourceType) {\n * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true },\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * ```\n */\nexport type RequestParameters = {\n /**\n * The URL to be requested.\n */\n url: string;\n /**\n * The headers to be sent with the request.\n */\n headers?: any;\n /**\n * Request method `'GET' | 'POST' | 'PUT'`.\n */\n method?: 'GET' | 'POST' | 'PUT';\n /**\n * Request body.\n */\n body?: string;\n /**\n * Response body type to be returned `'string' | 'json' | 'arrayBuffer'`.\n */\n type?: 'string' | 'json' | 'arrayBuffer' | 'image';\n /**\n * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests.\n */\n credentials?: 'same-origin' | 'include';\n /**\n * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events.\n */\n collectResourceTiming?: boolean;\n /**\n * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)\n */\n cache?: RequestCache;\n};\n\n/**\n * The response callback used in various places\n */\nexport type ResponseCallback = (\n error?: Error | null,\n data?: T | null,\n cacheControl?: string | null,\n expires?: string | null\n) => void;\n\n/**\n * An error thrown when a HTTP request results in an error response.\n */\nexport class AJAXError extends Error {\n /**\n * The response's HTTP status code.\n */\n status: number;\n\n /**\n * The response's HTTP status text.\n */\n statusText: string;\n\n /**\n * The request's URL.\n */\n url: string;\n\n /**\n * The response's body.\n */\n body: Blob;\n\n /**\n * @param status - The response's HTTP status code.\n * @param statusText - The response's HTTP status text.\n * @param url - The request's URL.\n * @param body - The response's body.\n */\n constructor(status: number, statusText: string, url: string, body: Blob) {\n super(`AJAXError: ${statusText} (${status}): ${url}`);\n this.status = status;\n this.statusText = statusText;\n this.url = url;\n this.body = body;\n }\n}\n\n// Ensure that we're sending the correct referrer from blob URL worker bundles.\n// For files loaded from the local file system, `location.origin` will be set\n// to the string(!) \"null\" (Firefox), or \"file://\" (Chrome, Safari, Edge, IE),\n// and we will set an empty referrer. Otherwise, we're using the document's URL.\n/* global self */\nexport const getReferrer = isWorker() ?\n () => (self as any).worker && (self as any).worker.referrer :\n () => (window.location.protocol === 'blob:' ? window.parent : window).location.href;\n\nexport const getProtocolAction = url => config.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))];\n\n// Determines whether a URL is a file:// URL. This is obviously the case if it begins\n// with file://. Relative URLs are also file:// URLs iff the original document was loaded\n// via a file:// URL.\nconst isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\\w+:/.test(url));\n\nfunction makeFetchRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const controller = new AbortController();\n const request = new Request(requestParameters.url, {\n method: requestParameters.method || 'GET',\n body: requestParameters.body,\n credentials: requestParameters.credentials,\n headers: requestParameters.headers,\n cache: requestParameters.cache,\n referrer: getReferrer(),\n signal: controller.signal\n });\n let complete = false;\n let aborted = false;\n\n if (requestParameters.type === 'json') {\n request.headers.set('Accept', 'application/json');\n }\n\n const validateOrFetch = (err, cachedResponse?, responseIsFresh?) => {\n if (aborted) return;\n\n if (err) {\n // Do fetch in case of cache error.\n // HTTP pages in Edge trigger a security error that can be ignored.\n if (err.message !== 'SecurityError') {\n warnOnce(err);\n }\n }\n\n if (cachedResponse && responseIsFresh) {\n return finishRequest(cachedResponse);\n }\n\n if (cachedResponse) {\n // We can't do revalidation with 'If-None-Match' because then the\n // request doesn't have simple cors headers.\n }\n\n fetch(request).then(response => {\n if (response.ok) {\n return finishRequest(response);\n\n } else {\n return response.blob().then(body => callback(new AJAXError(response.status, response.statusText, requestParameters.url, body)));\n }\n }).catch(error => {\n if (error.code === 20) {\n // silence expected AbortError\n return;\n }\n callback(new Error(error.message));\n });\n };\n\n const finishRequest = (response) => {\n (\n (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') ? response.arrayBuffer() :\n requestParameters.type === 'json' ? response.json() :\n response.text()\n ).then(result => {\n if (aborted) return;\n complete = true;\n callback(null, result, response.headers.get('Cache-Control'), response.headers.get('Expires'));\n }).catch(err => {\n if (!aborted) callback(new Error(err.message));\n });\n };\n\n validateOrFetch(null, null);\n\n return {cancel: () => {\n aborted = true;\n if (!complete) controller.abort();\n }};\n}\n\nfunction makeXMLHttpRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const xhr: XMLHttpRequest = new XMLHttpRequest();\n\n xhr.open(requestParameters.method || 'GET', requestParameters.url, true);\n if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') {\n xhr.responseType = 'arraybuffer';\n }\n for (const k in requestParameters.headers) {\n xhr.setRequestHeader(k, requestParameters.headers[k]);\n }\n if (requestParameters.type === 'json') {\n xhr.responseType = 'text';\n xhr.setRequestHeader('Accept', 'application/json');\n }\n xhr.withCredentials = requestParameters.credentials === 'include';\n xhr.onerror = () => {\n callback(new Error(xhr.statusText));\n };\n xhr.onload = () => {\n if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) {\n let data: unknown = xhr.response;\n if (requestParameters.type === 'json') {\n // We're manually parsing JSON here to get better error messages.\n try {\n data = JSON.parse(xhr.response);\n } catch (err) {\n return callback(err);\n }\n }\n callback(null, data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires'));\n } else {\n const body = new Blob([xhr.response], {type: xhr.getResponseHeader('Content-Type')});\n callback(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body));\n }\n };\n xhr.send(requestParameters.body);\n return {cancel: () => xhr.abort()};\n}\n\nexport const makeRequest = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n // We're trying to use the Fetch API if possible. However, in some situations we can't use it:\n // - IE11 doesn't support it at all. In this case, we dispatch the request to the main thread so\n // that we can get an accruate referrer header.\n // - Safari exposes window.AbortController, but it doesn't work actually abort any requests in\n // some versions (see https://bugs.webkit.org/show_bug.cgi?id=174980#c2)\n // - Requests for resources with the file:// URI scheme don't work with the Fetch API either. In\n // this case we unconditionally use XHR on the current thread since referrers don't matter.\n if (/:\\/\\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) {\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n return (self as any).worker.actor.send('getResource', requestParameters, callback);\n }\n if (!isWorker()) {\n const action = getProtocolAction(requestParameters.url) || makeFetchRequest;\n return action(requestParameters, callback);\n }\n }\n if (!isFileURL(requestParameters.url)) {\n if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) {\n return makeFetchRequest(requestParameters, callback);\n }\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n const queueOnMainThread = true;\n return (self as any).worker.actor.send('getResource', requestParameters, callback, undefined, queueOnMainThread);\n }\n }\n return makeXMLHttpRequest(requestParameters, callback);\n};\n\nexport const getJSON = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'json'}), callback);\n};\n\nexport const getArrayBuffer = function(\n requestParameters: RequestParameters,\n callback: ResponseCallback\n): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), callback);\n};\n\nexport const postData = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {method: 'POST'}), callback);\n};\n\nexport function sameOrigin(inComingUrl: string) {\n // URL class should be available everywhere\n // https://developer.mozilla.org/en-US/docs/Web/API/URL\n // In addtion, a relative URL \"/foo\" or \"./foo\" will throw exception in its ctor,\n // try-catch is expansive so just use a heuristic check to avoid it\n // also check data URL\n if (!inComingUrl ||\n inComingUrl.indexOf('://') <= 0 || // relative URL\n inComingUrl.indexOf('data:image/') === 0 || // data image URL\n inComingUrl.indexOf('blob:') === 0) { // blob\n return true;\n }\n const urlObj = new URL(inComingUrl);\n const locationObj = window.location;\n return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host;\n}\n/**\n * A type used to store the tile's expiration date and cache control definition\n */\nexport type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null};\nexport const getVideo = function(urls: Array, callback: Callback): Cancelable {\n const video: HTMLVideoElement = window.document.createElement('video');\n video.muted = true;\n video.onloadstart = function() {\n callback(null, video);\n };\n for (let i = 0; i < urls.length; i++) {\n const s: HTMLSourceElement = window.document.createElement('source');\n if (!sameOrigin(urls[i])) {\n video.crossOrigin = 'Anonymous';\n }\n s.src = urls[i];\n video.appendChild(s);\n }\n return {cancel: () => {}};\n};\n","import {TransferableGridIndex} from './transferable_grid_index';\nimport {Color, CompoundExpression, expressions, ResolvedImage, StylePropertyFunction,\n StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport {AJAXError} from './ajax';\n\nimport type {Transferable} from '../types/transferable';\nimport {isImageBitmap} from './util';\n\ntype SerializedObject = {\n [_: string]: S;\n};\n\nexport type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array | SerializedObject;\n\ntype Registry = {\n [_: string]: {\n klass: {\n new (...args: any): any;\n deserialize?: (input: Serialized) => unknown;\n };\n omit: ReadonlyArray;\n shallow: ReadonlyArray;\n };\n};\n\n/**\n * Register options\n */\ntype RegisterOptions = {\n /**\n * List of properties to omit from serialization (e.g., cached/computed properties)\n */\n omit?: ReadonlyArray;\n /**\n * List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize().\n */\n shallow?: ReadonlyArray;\n};\n\nconst registry: Registry = {};\n\n/**\n * Register the given class as serializable.\n *\n * @param options - the registration options\n */\nexport function register(\n name: string,\n klass: {\n new (...args: any): T;\n },\n options: RegisterOptions = {}\n) {\n if (registry[name]) throw new Error(`${name} is already registered.`);\n ((Object.defineProperty as any))(klass, '_classRegistryKey', {\n value: name,\n writeable: false\n });\n registry[name] = {\n klass,\n omit: options.omit as ReadonlyArray || [],\n shallow: options.shallow as ReadonlyArray || []\n };\n}\n\nregister('Object', Object);\nregister('TransferableGridIndex', TransferableGridIndex);\n\nregister('Color', Color);\nregister('Error', Error);\nregister('AJAXError', AJAXError);\nregister('ResolvedImage', ResolvedImage);\n\nregister('StylePropertyFunction', StylePropertyFunction);\nregister('StyleExpression', StyleExpression, {omit: ['_evaluator']});\n\nregister('ZoomDependentExpression', ZoomDependentExpression);\nregister('ZoomConstantExpression', ZoomConstantExpression);\nregister('CompoundExpression', CompoundExpression, {omit: ['_evaluate']});\nfor (const name in expressions) {\n if ((expressions[name] as any)._classRegistryKey) continue;\n register(`Expression_${name}`, expressions[name]);\n}\n\nfunction isArrayBuffer(value: any): value is ArrayBuffer {\n return value && typeof ArrayBuffer !== 'undefined' &&\n (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer'));\n}\n\n/**\n * Serialize the given object for transfer to or from a web worker.\n *\n * For non-builtin types, recursively serialize each property (possibly\n * omitting certain properties - see register()), and package the result along\n * with the constructor's `name` so that the appropriate constructor can be\n * looked up in `deserialize()`.\n *\n * If a `transferables` array is provided, add any transferable objects (i.e.,\n * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed,\n * this should happen in the client code, before using serialize().)\n */\nexport function serialize(input: unknown, transferables?: Array | null): Serialized {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob) {\n return input;\n }\n\n if (isArrayBuffer(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (isImageBitmap(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (ArrayBuffer.isView(input)) {\n const view = input;\n if (transferables) {\n transferables.push(view.buffer);\n }\n return view;\n }\n\n if (input instanceof ImageData) {\n if (transferables) {\n transferables.push(input.data.buffer);\n }\n return input;\n }\n\n if (Array.isArray(input)) {\n const serialized: Array = [];\n for (const item of input) {\n serialized.push(serialize(item, transferables));\n }\n return serialized;\n }\n\n if (typeof input === 'object') {\n const klass = (input.constructor as any);\n const name = klass._classRegistryKey;\n if (!name) {\n throw new Error('can\\'t serialize object of unregistered class');\n }\n if (!registry[name]) throw new Error(`${name} is not registered.`);\n\n const properties: SerializedObject = klass.serialize ?\n // (Temporary workaround) allow a class to provide static\n // `serialize()` and `deserialize()` methods to bypass the generic\n // approach.\n // This temporary workaround lets us use the generic serialization\n // approach for objects whose members include instances of dynamic\n // StructArray types. Once we refactor StructArray to be static,\n // we can remove this complexity.\n (klass.serialize(input, transferables) as SerializedObject) : {};\n\n if (!klass.serialize) {\n for (const key in input) {\n if (!input.hasOwnProperty(key)) continue; // eslint-disable-line no-prototype-builtins\n if (registry[name].omit.indexOf(key) >= 0) continue;\n const property = input[key];\n properties[key] = registry[name].shallow.indexOf(key) >= 0 ?\n property :\n serialize(property, transferables);\n }\n if (input instanceof Error) {\n properties.message = input.message;\n }\n } else {\n if (transferables && properties === transferables[transferables.length - 1]) {\n throw new Error('statically serialized object won\\'t survive transfer of $name property');\n }\n }\n\n if (properties.$name) {\n throw new Error('$name property is reserved for worker serialization logic.');\n }\n if (name !== 'Object') {\n properties.$name = name;\n }\n\n return properties;\n }\n\n throw new Error(`can't serialize object of type ${typeof input}`);\n}\n\nexport function deserialize(input: Serialized): unknown {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob ||\n isArrayBuffer(input) ||\n isImageBitmap(input) ||\n ArrayBuffer.isView(input) ||\n input instanceof ImageData) {\n return input;\n }\n\n if (Array.isArray(input)) {\n return input.map(deserialize);\n }\n\n if (typeof input === 'object') {\n const name = input.$name || 'Object';\n if (!registry[name]) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n const {klass} = registry[name];\n if (!klass) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n\n if (klass.deserialize) {\n return klass.deserialize(input);\n }\n\n const result = Object.create(klass.prototype);\n\n for (const key of Object.keys(input)) {\n if (key === '$name') continue;\n const value = (input as SerializedObject)[key];\n result[key] = registry[name].shallow.indexOf(key) >= 0 ? value : deserialize(value);\n }\n\n return result;\n }\n\n throw new Error(`can't deserialize object of type ${typeof input}`);\n}\n","/**\n * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests\n * are ignored until the function was actually invoked.\n */\nexport class ThrottledInvoker {\n _channel: MessageChannel;\n _triggered: boolean;\n _callback: Function;\n\n constructor(callback: Function) {\n this._callback = callback;\n this._triggered = false;\n if (typeof MessageChannel !== 'undefined') {\n this._channel = new MessageChannel();\n this._channel.port2.onmessage = () => {\n this._triggered = false;\n this._callback();\n };\n }\n }\n\n trigger() {\n if (!this._triggered) {\n this._triggered = true;\n if (this._channel) {\n this._channel.port1.postMessage(true);\n } else {\n setTimeout(() => {\n this._triggered = false;\n this._callback();\n }, 0);\n }\n }\n }\n\n remove() {\n delete this._channel;\n this._callback = () => {};\n }\n}\n","import {isWorker} from './util';\nimport {serialize, deserialize, Serialized} from './web_worker_transfer';\nimport {ThrottledInvoker} from './throttled_invoker';\n\nimport type {Transferable} from '../types/transferable';\nimport type {Cancelable} from '../types/cancelable';\nimport type {WorkerSource} from '../source/worker_source';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {Callback} from '../types/callback';\nimport type {StyleGlyph} from '../style/style_glyph';\n\nexport interface ActorTarget {\n addEventListener: typeof window.addEventListener;\n removeEventListener: typeof window.removeEventListener;\n postMessage: typeof window.postMessage;\n terminate?: () => void;\n}\n\nexport interface WorkerSourceProvider {\n getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource;\n}\n\nexport interface GlyphsProvider {\n getGlyphs(mapId: string, params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n );\n}\n\nexport type MessageType = '' | '' |\n'geojson.getClusterExpansionZoom' | 'geojson.getClusterChildren' | 'geojson.getClusterLeaves' | 'geojson.loadData' |\n'removeSource' | 'loadWorkerSource' | 'loadDEMTile' | 'removeDEMTile' |\n'removeTile' | 'reloadTile' | 'abortTile' | 'loadTile' | 'getTile' |\n'getGlyphs' | 'getImages' | 'setImages' |\n'syncRTLPluginState' | 'setReferrer' | 'setLayers' | 'updateLayers';\n\nexport type MessageData = {\n id: string;\n type: MessageType;\n data?: Serialized;\n targetMapId?: string | number | null;\n mustQueue?: boolean;\n error?: Serialized | null;\n hasCallback?: boolean;\n sourceMapId: string | number | null;\n}\n\nexport type Message = {\n data: MessageData;\n}\n\n/**\n * An implementation of the [Actor design pattern](http://en.wikipedia.org/wiki/Actor_model)\n * that maintains the relationship between asynchronous tasks and the objects\n * that spin them off - in this case, tasks like parsing parts of styles,\n * owned by the styles\n */\nexport class Actor {\n target: ActorTarget;\n parent: WorkerSourceProvider | GlyphsProvider;\n mapId: string | number | null;\n callbacks: { [x: number]: Function};\n name: string;\n tasks: { [x: number]: MessageData };\n taskQueue: Array;\n cancelCallbacks: { [x: number]: () => void };\n invoker: ThrottledInvoker;\n globalScope: ActorTarget;\n\n /**\n * @param target - The target\n * @param parent - The parent\n * @param mapId - A unique identifier for the Map instance using this Actor.\n */\n constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number) {\n this.target = target;\n this.parent = parent;\n this.mapId = mapId;\n this.callbacks = {};\n this.tasks = {};\n this.taskQueue = [];\n this.cancelCallbacks = {};\n this.invoker = new ThrottledInvoker(this.process);\n this.target.addEventListener('message', this.receive, false);\n this.globalScope = isWorker() ? target : window;\n }\n\n /**\n * Sends a message from a main-thread map to a Worker or from a Worker back to\n * a main-thread map instance.\n *\n * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource.\n * @param targetMapId - A particular mapId to which to send this message.\n */\n send(\n type: MessageType,\n data: unknown,\n callback?: Function | null,\n targetMapId?: string | null,\n mustQueue: boolean = false\n ): Cancelable {\n // We're using a string ID instead of numbers because they are being used as object keys\n // anyway, and thus stringified implicitly. We use random IDs because an actor may receive\n // message from multiple other actors which could run in different execution context. A\n // linearly increasing ID could produce collisions.\n const id = Math.round((Math.random() * 1e18)).toString(36).substring(0, 10);\n if (callback) {\n this.callbacks[id] = callback;\n }\n const buffers: Array = [];\n const message: MessageData = {\n id,\n type,\n hasCallback: !!callback,\n targetMapId,\n mustQueue,\n sourceMapId: this.mapId,\n data: serialize(data, buffers)\n };\n\n this.target.postMessage(message, {transfer: buffers});\n return {\n cancel: () => {\n if (callback) {\n // Set the callback to null so that it never fires after the request is aborted.\n delete this.callbacks[id];\n }\n const cancelMessage: MessageData = {\n id,\n type: '',\n targetMapId,\n sourceMapId: this.mapId\n };\n this.target.postMessage(cancelMessage);\n }\n };\n }\n\n receive = (message: Message) => {\n const data = message.data;\n const id = data.id;\n\n if (!id) {\n return;\n }\n\n if (data.targetMapId && this.mapId !== data.targetMapId) {\n return;\n }\n\n if (data.type === '') {\n // Remove the original request from the queue. This is only possible if it\n // hasn't been kicked off yet. The id will remain in the queue, but because\n // there is no associated task, it will be dropped once it's time to execute it.\n delete this.tasks[id];\n const cancel = this.cancelCallbacks[id];\n delete this.cancelCallbacks[id];\n if (cancel) {\n cancel();\n }\n } else {\n if (isWorker() || data.mustQueue) {\n // In workers, store the tasks that we need to process before actually processing them. This\n // is necessary because we want to keep receiving messages, and in particular,\n // messages. Some tasks may take a while in the worker thread, so before\n // executing the next task in our queue, postMessage preempts this and \n // messages can be processed. We're using a MessageChannel object to get throttle the\n // process() flow to one at a time.\n this.tasks[id] = data;\n this.taskQueue.push(id);\n this.invoker.trigger();\n } else {\n // In the main thread, process messages immediately so that other work does not slip in\n // between getting partial data back from workers.\n this.processTask(id, data);\n }\n }\n };\n\n process = () => {\n if (!this.taskQueue.length) {\n return;\n }\n const id = this.taskQueue.shift();\n const task = this.tasks[id];\n delete this.tasks[id];\n // Schedule another process call if we know there's more to process _before_ invoking the\n // current task. This is necessary so that processing continues even if the current task\n // doesn't execute successfully.\n if (this.taskQueue.length) {\n this.invoker.trigger();\n }\n if (!task) {\n // If the task ID doesn't have associated task data anymore, it was canceled.\n return;\n }\n\n this.processTask(id, task);\n };\n\n processTask(id: string, task: MessageData) {\n if (task.type === '') {\n // The done() function in the counterpart has been called, and we are now\n // firing the callback in the originating actor, if there is one.\n const callback = this.callbacks[id];\n delete this.callbacks[id];\n if (callback) {\n // If we get a response, but don't have a callback, the request was canceled.\n if (task.error) {\n callback(deserialize(task.error));\n } else {\n callback(null, deserialize(task.data));\n }\n }\n } else {\n let completed = false;\n const buffers: Array = [];\n const done = task.hasCallback ? (err: Error, data?: any) => {\n completed = true;\n delete this.cancelCallbacks[id];\n const responseMessage: MessageData = {\n id,\n type: '',\n sourceMapId: this.mapId,\n error: err ? serialize(err) : null,\n data: serialize(data, buffers)\n };\n this.target.postMessage(responseMessage, {transfer: buffers});\n } : (_) => {\n completed = true;\n };\n\n let callback: Cancelable = null;\n const params = deserialize(task.data);\n if (this.parent[task.type]) {\n // task.type == 'loadTile', 'removeTile', etc.\n callback = this.parent[task.type](task.sourceMapId, params, done);\n } else if ('getWorkerSource' in this.parent) {\n // task.type == sourcetype.method\n const keys = task.type.split('.');\n const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], (params as any).source);\n callback = scope[keys[1]](params, done);\n } else {\n // No function was found.\n done(new Error(`Could not find function ${task.type}`));\n }\n\n if (!completed && callback && callback.cancel) {\n // Allows canceling the task as long as it hasn't been completed yet.\n this.cancelCallbacks[id] = callback.cancel;\n }\n }\n }\n\n remove() {\n this.invoker.remove();\n this.target.removeEventListener('message', this.receive, false);\n }\n}\n","import {extend} from './util';\n\n/**\n * A listener method used as a callback to events\n */\nexport type Listener = (a: any) => any;\n\ntype Listeners = {[_: string]: Array};\n\nfunction _addEventListener(type: string, listener: Listener, listenerList: Listeners) {\n const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;\n if (!listenerExists) {\n listenerList[type] = listenerList[type] || [];\n listenerList[type].push(listener);\n }\n}\n\nfunction _removeEventListener(type: string, listener: Listener, listenerList: Listeners) {\n if (listenerList && listenerList[type]) {\n const index = listenerList[type].indexOf(listener);\n if (index !== -1) {\n listenerList[type].splice(index, 1);\n }\n }\n}\n\n/**\n * The event class\n */\nexport class Event {\n readonly type: string;\n\n constructor(type: string, data: any = {}) {\n extend(this, data);\n this.type = type;\n }\n}\n\ninterface ErrorLike {\n message: string;\n}\n\n/**\n * An error event\n */\nexport class ErrorEvent extends Event {\n error: ErrorLike;\n\n constructor(error: ErrorLike, data: any = {}) {\n super('error', extend({error}, data));\n }\n}\n\n/**\n * Methods mixed in to other classes for event capabilities.\n *\n * @group Event Related\n */\nexport class Evented {\n _listeners: Listeners;\n _oneTimeListeners: Listeners;\n _eventedParent: Evented;\n _eventedParentData: any | (() => any);\n\n /**\n * Adds a listener to a specified event type.\n *\n * @param type - The event type to add a listen for.\n * @param listener - The function to be called when the event is fired.\n * The listener function is called with the data object passed to `fire`,\n * extended with `target` and `type` properties.\n * @returns `this`\n */\n on(type: string, listener: Listener): this {\n this._listeners = this._listeners || {};\n _addEventListener(type, listener, this._listeners);\n\n return this;\n }\n\n /**\n * Removes a previously registered event listener.\n *\n * @param type - The event type to remove listeners for.\n * @param listener - The listener function to remove.\n * @returns `this`\n */\n off(type: string, listener: Listener) {\n _removeEventListener(type, listener, this._listeners);\n _removeEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type.\n *\n * The listener will be called first time the event fires after the listener is registered.\n *\n * @param type - The event type to listen for.\n * @param listener - The function to be called when the event is fired the first time.\n * @returns `this` or a promise if a listener is not provided\n */\n once(type: string, listener?: Listener): this | Promise {\n if (!listener) {\n return new Promise((resolve) => this.once(type, resolve));\n }\n this._oneTimeListeners = this._oneTimeListeners || {};\n _addEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n fire(event: Event | string, properties?: any) {\n // Compatibility with (type: string, properties: Object) signature from previous versions.\n // See https://github.com/mapbox/mapbox-gl-js/issues/6522,\n // https://github.com/mapbox/mapbox-gl-draw/issues/766\n if (typeof event === 'string') {\n event = new Event(event, properties || {});\n }\n\n const type = event.type;\n\n if (this.listens(type)) {\n (event as any).target = this;\n\n // make sure adding or removing listeners inside other listeners won't cause an infinite loop\n const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];\n for (const listener of listeners) {\n listener.call(this, event);\n }\n\n const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];\n for (const listener of oneTimeListeners) {\n _removeEventListener(type, listener, this._oneTimeListeners);\n listener.call(this, event);\n }\n\n const parent = this._eventedParent;\n if (parent) {\n extend(\n event,\n typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData\n );\n parent.fire(event);\n }\n\n // To ensure that no error events are dropped, print them to the\n // console if they have no listeners.\n } else if (event instanceof ErrorEvent) {\n console.error(event.error);\n }\n\n return this;\n }\n\n /**\n * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.\n *\n * @param type - The event type\n * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise\n */\n listens(type: string): boolean {\n return (\n (this._listeners && this._listeners[type] && this._listeners[type].length > 0) ||\n (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) ||\n (this._eventedParent && this._eventedParent.listens(type))\n );\n }\n\n /**\n * Bubble all events fired by this instance of Evented to this parent instance of Evented.\n * @returns `this`\n */\n setEventedParent(parent?: Evented | null, data?: any | (() => any)) {\n this._eventedParent = parent;\n this._eventedParentData = data;\n\n return this;\n }\n}\n","import {validateStyleMin} from '@maplibre/maplibre-gl-style-spec';\nimport {ErrorEvent} from '../util/evented';\n\nimport type {Evented} from '../util/evented';\n\ntype ValidationError = {\n message: string;\n line: number;\n identifier?: string;\n};\n\nexport type Validator = (a: any) => ReadonlyArray;\n\ntype ValidateStyle = {\n source: Validator;\n sprite: Validator;\n glyphs: Validator;\n layer: Validator;\n light: Validator;\n terrain: Validator;\n filter: Validator;\n paintProperty: Validator;\n layoutProperty: Validator;\n (b: any, a?: any | null): ReadonlyArray;\n};\n\nexport const validateStyle = (validateStyleMin as unknown as ValidateStyle);\n\nexport const validateSource = validateStyle.source;\nexport const validateLight = validateStyle.light;\nexport const validateTerrain = validateStyle.terrain;\nexport const validateFilter = validateStyle.filter;\nexport const validatePaintProperty = validateStyle.paintProperty;\nexport const validateLayoutProperty = validateStyle.layoutProperty;\n\nexport function emitValidationErrors(\n emitter: Evented,\n errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n }> | null\n): boolean {\n let hasErrors = false;\n if (errors && errors.length) {\n for (const error of errors) {\n emitter.fire(new ErrorEvent(new Error(error.message)));\n hasErrors = true;\n }\n }\n return hasErrors;\n}\n","export class ZoomHistory {\n lastZoom: number;\n lastFloorZoom: number;\n lastIntegerZoom: number;\n lastIntegerZoomTime: number;\n first: boolean;\n\n constructor() {\n this.first = true;\n }\n\n update(z: number, now: number) {\n const floorZ = Math.floor(z);\n\n if (this.first) {\n this.first = false;\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = 0;\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n if (this.lastFloorZoom > floorZ) {\n this.lastIntegerZoom = floorZ + 1;\n this.lastIntegerZoomTime = now;\n } else if (this.lastFloorZoom < floorZ) {\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = now;\n }\n\n if (z !== this.lastZoom) {\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n return false;\n }\n}\n","// The following table comes from .\n// Keep it synchronized with .\n\ntype UnicodeBlockLookup = {[key: string]: (char: number) => boolean};\n\nexport const unicodeBlockLookup: UnicodeBlockLookup = {\n // 'Basic Latin': (char) => char >= 0x0000 && char <= 0x007F,\n 'Latin-1 Supplement': (char) => char >= 0x0080 && char <= 0x00FF,\n // 'Latin Extended-A': (char) => char >= 0x0100 && char <= 0x017F,\n // 'Latin Extended-B': (char) => char >= 0x0180 && char <= 0x024F,\n // 'IPA Extensions': (char) => char >= 0x0250 && char <= 0x02AF,\n // 'Spacing Modifier Letters': (char) => char >= 0x02B0 && char <= 0x02FF,\n // 'Combining Diacritical Marks': (char) => char >= 0x0300 && char <= 0x036F,\n // 'Greek and Coptic': (char) => char >= 0x0370 && char <= 0x03FF,\n // 'Cyrillic': (char) => char >= 0x0400 && char <= 0x04FF,\n // 'Cyrillic Supplement': (char) => char >= 0x0500 && char <= 0x052F,\n // 'Armenian': (char) => char >= 0x0530 && char <= 0x058F,\n //'Hebrew': (char) => char >= 0x0590 && char <= 0x05FF,\n 'Arabic': (char) => char >= 0x0600 && char <= 0x06FF,\n //'Syriac': (char) => char >= 0x0700 && char <= 0x074F,\n 'Arabic Supplement': (char) => char >= 0x0750 && char <= 0x077F,\n // 'Thaana': (char) => char >= 0x0780 && char <= 0x07BF,\n // 'NKo': (char) => char >= 0x07C0 && char <= 0x07FF,\n // 'Samaritan': (char) => char >= 0x0800 && char <= 0x083F,\n // 'Mandaic': (char) => char >= 0x0840 && char <= 0x085F,\n // 'Syriac Supplement': (char) => char >= 0x0860 && char <= 0x086F,\n 'Arabic Extended-A': (char) => char >= 0x08A0 && char <= 0x08FF,\n // 'Devanagari': (char) => char >= 0x0900 && char <= 0x097F,\n // 'Bengali': (char) => char >= 0x0980 && char <= 0x09FF,\n // 'Gurmukhi': (char) => char >= 0x0A00 && char <= 0x0A7F,\n // 'Gujarati': (char) => char >= 0x0A80 && char <= 0x0AFF,\n // 'Oriya': (char) => char >= 0x0B00 && char <= 0x0B7F,\n // 'Tamil': (char) => char >= 0x0B80 && char <= 0x0BFF,\n // 'Telugu': (char) => char >= 0x0C00 && char <= 0x0C7F,\n // 'Kannada': (char) => char >= 0x0C80 && char <= 0x0CFF,\n // 'Malayalam': (char) => char >= 0x0D00 && char <= 0x0D7F,\n // 'Sinhala': (char) => char >= 0x0D80 && char <= 0x0DFF,\n // 'Thai': (char) => char >= 0x0E00 && char <= 0x0E7F,\n // 'Lao': (char) => char >= 0x0E80 && char <= 0x0EFF,\n // 'Tibetan': (char) => char >= 0x0F00 && char <= 0x0FFF,\n // 'Myanmar': (char) => char >= 0x1000 && char <= 0x109F,\n // 'Georgian': (char) => char >= 0x10A0 && char <= 0x10FF,\n 'Hangul Jamo': (char) => char >= 0x1100 && char <= 0x11FF,\n // 'Ethiopic': (char) => char >= 0x1200 && char <= 0x137F,\n // 'Ethiopic Supplement': (char) => char >= 0x1380 && char <= 0x139F,\n // 'Cherokee': (char) => char >= 0x13A0 && char <= 0x13FF,\n 'Unified Canadian Aboriginal Syllabics': (char) => char >= 0x1400 && char <= 0x167F,\n // 'Ogham': (char) => char >= 0x1680 && char <= 0x169F,\n // 'Runic': (char) => char >= 0x16A0 && char <= 0x16FF,\n // 'Tagalog': (char) => char >= 0x1700 && char <= 0x171F,\n // 'Hanunoo': (char) => char >= 0x1720 && char <= 0x173F,\n // 'Buhid': (char) => char >= 0x1740 && char <= 0x175F,\n // 'Tagbanwa': (char) => char >= 0x1760 && char <= 0x177F,\n 'Khmer': (char) => char >= 0x1780 && char <= 0x17FF,\n // 'Mongolian': (char) => char >= 0x1800 && char <= 0x18AF,\n 'Unified Canadian Aboriginal Syllabics Extended': (char) => char >= 0x18B0 && char <= 0x18FF,\n // 'Limbu': (char) => char >= 0x1900 && char <= 0x194F,\n // 'Tai Le': (char) => char >= 0x1950 && char <= 0x197F,\n // 'New Tai Lue': (char) => char >= 0x1980 && char <= 0x19DF,\n // 'Khmer Symbols': (char) => char >= 0x19E0 && char <= 0x19FF,\n // 'Buginese': (char) => char >= 0x1A00 && char <= 0x1A1F,\n // 'Tai Tham': (char) => char >= 0x1A20 && char <= 0x1AAF,\n // 'Combining Diacritical Marks Extended': (char) => char >= 0x1AB0 && char <= 0x1AFF,\n // 'Balinese': (char) => char >= 0x1B00 && char <= 0x1B7F,\n // 'Sundanese': (char) => char >= 0x1B80 && char <= 0x1BBF,\n // 'Batak': (char) => char >= 0x1BC0 && char <= 0x1BFF,\n // 'Lepcha': (char) => char >= 0x1C00 && char <= 0x1C4F,\n // 'Ol Chiki': (char) => char >= 0x1C50 && char <= 0x1C7F,\n // 'Cyrillic Extended-C': (char) => char >= 0x1C80 && char <= 0x1C8F,\n // 'Georgian Extended': (char) => char >= 0x1C90 && char <= 0x1CBF,\n // 'Sundanese Supplement': (char) => char >= 0x1CC0 && char <= 0x1CCF,\n // 'Vedic Extensions': (char) => char >= 0x1CD0 && char <= 0x1CFF,\n // 'Phonetic Extensions': (char) => char >= 0x1D00 && char <= 0x1D7F,\n // 'Phonetic Extensions Supplement': (char) => char >= 0x1D80 && char <= 0x1DBF,\n // 'Combining Diacritical Marks Supplement': (char) => char >= 0x1DC0 && char <= 0x1DFF,\n // 'Latin Extended Additional': (char) => char >= 0x1E00 && char <= 0x1EFF,\n // 'Greek Extended': (char) => char >= 0x1F00 && char <= 0x1FFF,\n 'General Punctuation': (char) => char >= 0x2000 && char <= 0x206F,\n // 'Superscripts and Subscripts': (char) => char >= 0x2070 && char <= 0x209F,\n // 'Currency Symbols': (char) => char >= 0x20A0 && char <= 0x20CF,\n // 'Combining Diacritical Marks for Symbols': (char) => char >= 0x20D0 && char <= 0x20FF,\n 'Letterlike Symbols': (char) => char >= 0x2100 && char <= 0x214F,\n 'Number Forms': (char) => char >= 0x2150 && char <= 0x218F,\n // 'Arrows': (char) => char >= 0x2190 && char <= 0x21FF,\n // 'Mathematical Operators': (char) => char >= 0x2200 && char <= 0x22FF,\n 'Miscellaneous Technical': (char) => char >= 0x2300 && char <= 0x23FF,\n 'Control Pictures': (char) => char >= 0x2400 && char <= 0x243F,\n 'Optical Character Recognition': (char) => char >= 0x2440 && char <= 0x245F,\n 'Enclosed Alphanumerics': (char) => char >= 0x2460 && char <= 0x24FF,\n // 'Box Drawing': (char) => char >= 0x2500 && char <= 0x257F,\n // 'Block Elements': (char) => char >= 0x2580 && char <= 0x259F,\n 'Geometric Shapes': (char) => char >= 0x25A0 && char <= 0x25FF,\n 'Miscellaneous Symbols': (char) => char >= 0x2600 && char <= 0x26FF,\n // 'Dingbats': (char) => char >= 0x2700 && char <= 0x27BF,\n // 'Miscellaneous Mathematical Symbols-A': (char) => char >= 0x27C0 && char <= 0x27EF,\n // 'Supplemental Arrows-A': (char) => char >= 0x27F0 && char <= 0x27FF,\n // 'Braille Patterns': (char) => char >= 0x2800 && char <= 0x28FF,\n // 'Supplemental Arrows-B': (char) => char >= 0x2900 && char <= 0x297F,\n // 'Miscellaneous Mathematical Symbols-B': (char) => char >= 0x2980 && char <= 0x29FF,\n // 'Supplemental Mathematical Operators': (char) => char >= 0x2A00 && char <= 0x2AFF,\n 'Miscellaneous Symbols and Arrows': (char) => char >= 0x2B00 && char <= 0x2BFF,\n // 'Glagolitic': (char) => char >= 0x2C00 && char <= 0x2C5F,\n // 'Latin Extended-C': (char) => char >= 0x2C60 && char <= 0x2C7F,\n // 'Coptic': (char) => char >= 0x2C80 && char <= 0x2CFF,\n // 'Georgian Supplement': (char) => char >= 0x2D00 && char <= 0x2D2F,\n // 'Tifinagh': (char) => char >= 0x2D30 && char <= 0x2D7F,\n // 'Ethiopic Extended': (char) => char >= 0x2D80 && char <= 0x2DDF,\n // 'Cyrillic Extended-A': (char) => char >= 0x2DE0 && char <= 0x2DFF,\n // 'Supplemental Punctuation': (char) => char >= 0x2E00 && char <= 0x2E7F,\n 'CJK Radicals Supplement': (char) => char >= 0x2E80 && char <= 0x2EFF,\n 'Kangxi Radicals': (char) => char >= 0x2F00 && char <= 0x2FDF,\n 'Ideographic Description Characters': (char) => char >= 0x2FF0 && char <= 0x2FFF,\n 'CJK Symbols and Punctuation': (char) => char >= 0x3000 && char <= 0x303F,\n 'Hiragana': (char) => char >= 0x3040 && char <= 0x309F,\n 'Katakana': (char) => char >= 0x30A0 && char <= 0x30FF,\n 'Bopomofo': (char) => char >= 0x3100 && char <= 0x312F,\n 'Hangul Compatibility Jamo': (char) => char >= 0x3130 && char <= 0x318F,\n 'Kanbun': (char) => char >= 0x3190 && char <= 0x319F,\n 'Bopomofo Extended': (char) => char >= 0x31A0 && char <= 0x31BF,\n 'CJK Strokes': (char) => char >= 0x31C0 && char <= 0x31EF,\n 'Katakana Phonetic Extensions': (char) => char >= 0x31F0 && char <= 0x31FF,\n 'Enclosed CJK Letters and Months': (char) => char >= 0x3200 && char <= 0x32FF,\n 'CJK Compatibility': (char) => char >= 0x3300 && char <= 0x33FF,\n 'CJK Unified Ideographs Extension A': (char) => char >= 0x3400 && char <= 0x4DBF,\n 'Yijing Hexagram Symbols': (char) => char >= 0x4DC0 && char <= 0x4DFF,\n 'CJK Unified Ideographs': (char) => char >= 0x4E00 && char <= 0x9FFF,\n 'Yi Syllables': (char) => char >= 0xA000 && char <= 0xA48F,\n 'Yi Radicals': (char) => char >= 0xA490 && char <= 0xA4CF,\n // 'Lisu': (char) => char >= 0xA4D0 && char <= 0xA4FF,\n // 'Vai': (char) => char >= 0xA500 && char <= 0xA63F,\n // 'Cyrillic Extended-B': (char) => char >= 0xA640 && char <= 0xA69F,\n // 'Bamum': (char) => char >= 0xA6A0 && char <= 0xA6FF,\n // 'Modifier Tone Letters': (char) => char >= 0xA700 && char <= 0xA71F,\n // 'Latin Extended-D': (char) => char >= 0xA720 && char <= 0xA7FF,\n // 'Syloti Nagri': (char) => char >= 0xA800 && char <= 0xA82F,\n // 'Common Indic Number Forms': (char) => char >= 0xA830 && char <= 0xA83F,\n // 'Phags-pa': (char) => char >= 0xA840 && char <= 0xA87F,\n // 'Saurashtra': (char) => char >= 0xA880 && char <= 0xA8DF,\n // 'Devanagari Extended': (char) => char >= 0xA8E0 && char <= 0xA8FF,\n // 'Kayah Li': (char) => char >= 0xA900 && char <= 0xA92F,\n // 'Rejang': (char) => char >= 0xA930 && char <= 0xA95F,\n 'Hangul Jamo Extended-A': (char) => char >= 0xA960 && char <= 0xA97F,\n // 'Javanese': (char) => char >= 0xA980 && char <= 0xA9DF,\n // 'Myanmar Extended-B': (char) => char >= 0xA9E0 && char <= 0xA9FF,\n // 'Cham': (char) => char >= 0xAA00 && char <= 0xAA5F,\n // 'Myanmar Extended-A': (char) => char >= 0xAA60 && char <= 0xAA7F,\n // 'Tai Viet': (char) => char >= 0xAA80 && char <= 0xAADF,\n // 'Meetei Mayek Extensions': (char) => char >= 0xAAE0 && char <= 0xAAFF,\n // 'Ethiopic Extended-A': (char) => char >= 0xAB00 && char <= 0xAB2F,\n // 'Latin Extended-E': (char) => char >= 0xAB30 && char <= 0xAB6F,\n // 'Cherokee Supplement': (char) => char >= 0xAB70 && char <= 0xABBF,\n // 'Meetei Mayek': (char) => char >= 0xABC0 && char <= 0xABFF,\n 'Hangul Syllables': (char) => char >= 0xAC00 && char <= 0xD7AF,\n 'Hangul Jamo Extended-B': (char) => char >= 0xD7B0 && char <= 0xD7FF,\n // 'High Surrogates': (char) => char >= 0xD800 && char <= 0xDB7F,\n // 'High Private Use Surrogates': (char) => char >= 0xDB80 && char <= 0xDBFF,\n // 'Low Surrogates': (char) => char >= 0xDC00 && char <= 0xDFFF,\n 'Private Use Area': (char) => char >= 0xE000 && char <= 0xF8FF,\n 'CJK Compatibility Ideographs': (char) => char >= 0xF900 && char <= 0xFAFF,\n // 'Alphabetic Presentation Forms': (char) => char >= 0xFB00 && char <= 0xFB4F,\n 'Arabic Presentation Forms-A': (char) => char >= 0xFB50 && char <= 0xFDFF,\n // 'Variation Selectors': (char) => char >= 0xFE00 && char <= 0xFE0F,\n 'Vertical Forms': (char) => char >= 0xFE10 && char <= 0xFE1F,\n // 'Combining Half Marks': (char) => char >= 0xFE20 && char <= 0xFE2F,\n 'CJK Compatibility Forms': (char) => char >= 0xFE30 && char <= 0xFE4F,\n 'Small Form Variants': (char) => char >= 0xFE50 && char <= 0xFE6F,\n 'Arabic Presentation Forms-B': (char) => char >= 0xFE70 && char <= 0xFEFF,\n 'Halfwidth and Fullwidth Forms': (char) => char >= 0xFF00 && char <= 0xFFEF\n // 'Specials': (char) => char >= 0xFFF0 && char <= 0xFFFF,\n // 'Linear B Syllabary': (char) => char >= 0x10000 && char <= 0x1007F,\n // 'Linear B Ideograms': (char) => char >= 0x10080 && char <= 0x100FF,\n // 'Aegean Numbers': (char) => char >= 0x10100 && char <= 0x1013F,\n // 'Ancient Greek Numbers': (char) => char >= 0x10140 && char <= 0x1018F,\n // 'Ancient Symbols': (char) => char >= 0x10190 && char <= 0x101CF,\n // 'Phaistos Disc': (char) => char >= 0x101D0 && char <= 0x101FF,\n // 'Lycian': (char) => char >= 0x10280 && char <= 0x1029F,\n // 'Carian': (char) => char >= 0x102A0 && char <= 0x102DF,\n // 'Coptic Epact Numbers': (char) => char >= 0x102E0 && char <= 0x102FF,\n // 'Old Italic': (char) => char >= 0x10300 && char <= 0x1032F,\n // 'Gothic': (char) => char >= 0x10330 && char <= 0x1034F,\n // 'Old Permic': (char) => char >= 0x10350 && char <= 0x1037F,\n // 'Ugaritic': (char) => char >= 0x10380 && char <= 0x1039F,\n // 'Old Persian': (char) => char >= 0x103A0 && char <= 0x103DF,\n // 'Deseret': (char) => char >= 0x10400 && char <= 0x1044F,\n // 'Shavian': (char) => char >= 0x10450 && char <= 0x1047F,\n // 'Osmanya': (char) => char >= 0x10480 && char <= 0x104AF,\n // 'Osage': (char) => char >= 0x104B0 && char <= 0x104FF,\n // 'Elbasan': (char) => char >= 0x10500 && char <= 0x1052F,\n // 'Caucasian Albanian': (char) => char >= 0x10530 && char <= 0x1056F,\n // 'Linear A': (char) => char >= 0x10600 && char <= 0x1077F,\n // 'Cypriot Syllabary': (char) => char >= 0x10800 && char <= 0x1083F,\n // 'Imperial Aramaic': (char) => char >= 0x10840 && char <= 0x1085F,\n // 'Palmyrene': (char) => char >= 0x10860 && char <= 0x1087F,\n // 'Nabataean': (char) => char >= 0x10880 && char <= 0x108AF,\n // 'Hatran': (char) => char >= 0x108E0 && char <= 0x108FF,\n // 'Phoenician': (char) => char >= 0x10900 && char <= 0x1091F,\n // 'Lydian': (char) => char >= 0x10920 && char <= 0x1093F,\n // 'Meroitic Hieroglyphs': (char) => char >= 0x10980 && char <= 0x1099F,\n // 'Meroitic Cursive': (char) => char >= 0x109A0 && char <= 0x109FF,\n // 'Kharoshthi': (char) => char >= 0x10A00 && char <= 0x10A5F,\n // 'Old South Arabian': (char) => char >= 0x10A60 && char <= 0x10A7F,\n // 'Old North Arabian': (char) => char >= 0x10A80 && char <= 0x10A9F,\n // 'Manichaean': (char) => char >= 0x10AC0 && char <= 0x10AFF,\n // 'Avestan': (char) => char >= 0x10B00 && char <= 0x10B3F,\n // 'Inscriptional Parthian': (char) => char >= 0x10B40 && char <= 0x10B5F,\n // 'Inscriptional Pahlavi': (char) => char >= 0x10B60 && char <= 0x10B7F,\n // 'Psalter Pahlavi': (char) => char >= 0x10B80 && char <= 0x10BAF,\n // 'Old Turkic': (char) => char >= 0x10C00 && char <= 0x10C4F,\n // 'Old Hungarian': (char) => char >= 0x10C80 && char <= 0x10CFF,\n // 'Hanifi Rohingya': (char) => char >= 0x10D00 && char <= 0x10D3F,\n // 'Rumi Numeral Symbols': (char) => char >= 0x10E60 && char <= 0x10E7F,\n // 'Old Sogdian': (char) => char >= 0x10F00 && char <= 0x10F2F,\n // 'Sogdian': (char) => char >= 0x10F30 && char <= 0x10F6F,\n // 'Elymaic': (char) => char >= 0x10FE0 && char <= 0x10FFF,\n // 'Brahmi': (char) => char >= 0x11000 && char <= 0x1107F,\n // 'Kaithi': (char) => char >= 0x11080 && char <= 0x110CF,\n // 'Sora Sompeng': (char) => char >= 0x110D0 && char <= 0x110FF,\n // 'Chakma': (char) => char >= 0x11100 && char <= 0x1114F,\n // 'Mahajani': (char) => char >= 0x11150 && char <= 0x1117F,\n // 'Sharada': (char) => char >= 0x11180 && char <= 0x111DF,\n // 'Sinhala Archaic Numbers': (char) => char >= 0x111E0 && char <= 0x111FF,\n // 'Khojki': (char) => char >= 0x11200 && char <= 0x1124F,\n // 'Multani': (char) => char >= 0x11280 && char <= 0x112AF,\n // 'Khudawadi': (char) => char >= 0x112B0 && char <= 0x112FF,\n // 'Grantha': (char) => char >= 0x11300 && char <= 0x1137F,\n // 'Newa': (char) => char >= 0x11400 && char <= 0x1147F,\n // 'Tirhuta': (char) => char >= 0x11480 && char <= 0x114DF,\n // 'Siddham': (char) => char >= 0x11580 && char <= 0x115FF,\n // 'Modi': (char) => char >= 0x11600 && char <= 0x1165F,\n // 'Mongolian Supplement': (char) => char >= 0x11660 && char <= 0x1167F,\n // 'Takri': (char) => char >= 0x11680 && char <= 0x116CF,\n // 'Ahom': (char) => char >= 0x11700 && char <= 0x1173F,\n // 'Dogra': (char) => char >= 0x11800 && char <= 0x1184F,\n // 'Warang Citi': (char) => char >= 0x118A0 && char <= 0x118FF,\n // 'Nandinagari': (char) => char >= 0x119A0 && char <= 0x119FF,\n // 'Zanabazar Square': (char) => char >= 0x11A00 && char <= 0x11A4F,\n // 'Soyombo': (char) => char >= 0x11A50 && char <= 0x11AAF,\n // 'Pau Cin Hau': (char) => char >= 0x11AC0 && char <= 0x11AFF,\n // 'Bhaiksuki': (char) => char >= 0x11C00 && char <= 0x11C6F,\n // 'Marchen': (char) => char >= 0x11C70 && char <= 0x11CBF,\n // 'Masaram Gondi': (char) => char >= 0x11D00 && char <= 0x11D5F,\n // 'Gunjala Gondi': (char) => char >= 0x11D60 && char <= 0x11DAF,\n // 'Makasar': (char) => char >= 0x11EE0 && char <= 0x11EFF,\n // 'Tamil Supplement': (char) => char >= 0x11FC0 && char <= 0x11FFF,\n // 'Cuneiform': (char) => char >= 0x12000 && char <= 0x123FF,\n // 'Cuneiform Numbers and Punctuation': (char) => char >= 0x12400 && char <= 0x1247F,\n // 'Early Dynastic Cuneiform': (char) => char >= 0x12480 && char <= 0x1254F,\n // 'Egyptian Hieroglyphs': (char) => char >= 0x13000 && char <= 0x1342F,\n // 'Egyptian Hieroglyph Format Controls': (char) => char >= 0x13430 && char <= 0x1343F,\n // 'Anatolian Hieroglyphs': (char) => char >= 0x14400 && char <= 0x1467F,\n // 'Bamum Supplement': (char) => char >= 0x16800 && char <= 0x16A3F,\n // 'Mro': (char) => char >= 0x16A40 && char <= 0x16A6F,\n // 'Bassa Vah': (char) => char >= 0x16AD0 && char <= 0x16AFF,\n // 'Pahawh Hmong': (char) => char >= 0x16B00 && char <= 0x16B8F,\n // 'Medefaidrin': (char) => char >= 0x16E40 && char <= 0x16E9F,\n // 'Miao': (char) => char >= 0x16F00 && char <= 0x16F9F,\n // 'Ideographic Symbols and Punctuation': (char) => char >= 0x16FE0 && char <= 0x16FFF,\n // 'Tangut': (char) => char >= 0x17000 && char <= 0x187FF,\n // 'Tangut Components': (char) => char >= 0x18800 && char <= 0x18AFF,\n // 'Kana Supplement': (char) => char >= 0x1B000 && char <= 0x1B0FF,\n // 'Kana Extended-A': (char) => char >= 0x1B100 && char <= 0x1B12F,\n // 'Small Kana Extension': (char) => char >= 0x1B130 && char <= 0x1B16F,\n // 'Nushu': (char) => char >= 0x1B170 && char <= 0x1B2FF,\n // 'Duployan': (char) => char >= 0x1BC00 && char <= 0x1BC9F,\n // 'Shorthand Format Controls': (char) => char >= 0x1BCA0 && char <= 0x1BCAF,\n // 'Byzantine Musical Symbols': (char) => char >= 0x1D000 && char <= 0x1D0FF,\n // 'Musical Symbols': (char) => char >= 0x1D100 && char <= 0x1D1FF,\n // 'Ancient Greek Musical Notation': (char) => char >= 0x1D200 && char <= 0x1D24F,\n // 'Mayan Numerals': (char) => char >= 0x1D2E0 && char <= 0x1D2FF,\n // 'Tai Xuan Jing Symbols': (char) => char >= 0x1D300 && char <= 0x1D35F,\n // 'Counting Rod Numerals': (char) => char >= 0x1D360 && char <= 0x1D37F,\n // 'Mathematical Alphanumeric Symbols': (char) => char >= 0x1D400 && char <= 0x1D7FF,\n // 'Sutton SignWriting': (char) => char >= 0x1D800 && char <= 0x1DAAF,\n // 'Glagolitic Supplement': (char) => char >= 0x1E000 && char <= 0x1E02F,\n // 'Nyiakeng Puachue Hmong': (char) => char >= 0x1E100 && char <= 0x1E14F,\n // 'Wancho': (char) => char >= 0x1E2C0 && char <= 0x1E2FF,\n // 'Mende Kikakui': (char) => char >= 0x1E800 && char <= 0x1E8DF,\n // 'Adlam': (char) => char >= 0x1E900 && char <= 0x1E95F,\n // 'Indic Siyaq Numbers': (char) => char >= 0x1EC70 && char <= 0x1ECBF,\n // 'Ottoman Siyaq Numbers': (char) => char >= 0x1ED00 && char <= 0x1ED4F,\n // 'Arabic Mathematical Alphabetic Symbols': (char) => char >= 0x1EE00 && char <= 0x1EEFF,\n // 'Mahjong Tiles': (char) => char >= 0x1F000 && char <= 0x1F02F,\n // 'Domino Tiles': (char) => char >= 0x1F030 && char <= 0x1F09F,\n // 'Playing Cards': (char) => char >= 0x1F0A0 && char <= 0x1F0FF,\n // 'Enclosed Alphanumeric Supplement': (char) => char >= 0x1F100 && char <= 0x1F1FF,\n // 'Enclosed Ideographic Supplement': (char) => char >= 0x1F200 && char <= 0x1F2FF,\n // 'Miscellaneous Symbols and Pictographs': (char) => char >= 0x1F300 && char <= 0x1F5FF,\n // 'Emoticons': (char) => char >= 0x1F600 && char <= 0x1F64F,\n // 'Ornamental Dingbats': (char) => char >= 0x1F650 && char <= 0x1F67F,\n // 'Transport and Map Symbols': (char) => char >= 0x1F680 && char <= 0x1F6FF,\n // 'Alchemical Symbols': (char) => char >= 0x1F700 && char <= 0x1F77F,\n // 'Geometric Shapes Extended': (char) => char >= 0x1F780 && char <= 0x1F7FF,\n // 'Supplemental Arrows-C': (char) => char >= 0x1F800 && char <= 0x1F8FF,\n // 'Supplemental Symbols and Pictographs': (char) => char >= 0x1F900 && char <= 0x1F9FF,\n // 'Chess Symbols': (char) => char >= 0x1FA00 && char <= 0x1FA6F,\n // 'Symbols and Pictographs Extended-A': (char) => char >= 0x1FA70 && char <= 0x1FAFF,\n // 'CJK Unified Ideographs Extension B': (char) => char >= 0x20000 && char <= 0x2A6DF,\n // 'CJK Unified Ideographs Extension C': (char) => char >= 0x2A700 && char <= 0x2B73F,\n // 'CJK Unified Ideographs Extension D': (char) => char >= 0x2B740 && char <= 0x2B81F,\n // 'CJK Unified Ideographs Extension E': (char) => char >= 0x2B820 && char <= 0x2CEAF,\n // 'CJK Unified Ideographs Extension F': (char) => char >= 0x2CEB0 && char <= 0x2EBEF,\n // 'CJK Compatibility Ideographs Supplement': (char) => char >= 0x2F800 && char <= 0x2FA1F,\n // 'Tags': (char) => char >= 0xE0000 && char <= 0xE007F,\n // 'Variation Selectors Supplement': (char) => char >= 0xE0100 && char <= 0xE01EF,\n // 'Supplementary Private Use Area-A': (char) => char >= 0xF0000 && char <= 0xFFFFF,\n // 'Supplementary Private Use Area-B': (char) => char >= 0x100000 && char <= 0x10FFFF,\n};\n","/* eslint-disable new-cap */\n\nimport {unicodeBlockLookup as isChar} from './is_char_in_unicode_block';\n\nexport function allowsIdeographicBreaking(chars: string) {\n for (const char of chars) {\n if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function allowsVerticalWritingMode(chars: string) {\n for (const char of chars) {\n if (charHasUprightVerticalOrientation(char.charCodeAt(0))) return true;\n }\n return false;\n}\n\nexport function allowsLetterSpacing(chars: string) {\n for (const char of chars) {\n if (!charAllowsLetterSpacing(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function charAllowsLetterSpacing(char: number) {\n if (isChar['Arabic'](char)) return false;\n if (isChar['Arabic Supplement'](char)) return false;\n if (isChar['Arabic Extended-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-B'](char)) return false;\n\n return true;\n}\n\nexport function charAllowsIdeographicBreaking(char: number) {\n // Return early for characters outside all ideographic ranges.\n if (char < 0x2E80) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n\n return false;\n}\n\n// The following logic comes from\n// .\n// Keep it synchronized with\n// .\n// The data file denotes with “U” or “Tu” any codepoint that may be drawn\n// upright in vertical text but does not distinguish between upright and\n// “neutral” characters.\n\n// Blocks in the Unicode supplementary planes are excluded from this module due\n// to .\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * upright orientation.\n *\n * A character has upright orientation if it is drawn upright (unrotated)\n * whether the line is oriented horizontally or vertically, even if both\n * adjacent characters can be rotated. For example, a Chinese character is\n * always drawn upright. An uprightly oriented character causes an adjacent\n * “neutral” character to be drawn upright as well.\n */\nexport function charHasUprightVerticalOrientation(char: number) {\n if (char === 0x02EA /* modifier letter yin departing tone mark */ ||\n char === 0x02EB /* modifier letter yang departing tone mark */) {\n return true;\n }\n\n // Return early for characters outside all ranges whose characters remain\n // upright in vertical writing mode.\n if (char < 0x1100) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) {\n if (!((char >= 0xFE49 /* dashed overline */ && char <= 0xFE4F) /* wavy low line */)) {\n return true;\n }\n }\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) {\n if (!((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) &&\n !((char >= 0x3014 /* left tortoise shell bracket */ && char <= 0x301F) /* low double prime quotation mark */) &&\n char !== 0x3030 /* wavy dash */) {\n return true;\n }\n }\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Hangul Compatibility Jamo'](char)) return true;\n if (isChar['Hangul Jamo Extended-A'](char)) return true;\n if (isChar['Hangul Jamo Extended-B'](char)) return true;\n if (isChar['Hangul Jamo'](char)) return true;\n if (isChar['Hangul Syllables'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kanbun'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) {\n if (char !== 0x30FC /* katakana-hiragana prolonged sound mark */) {\n return true;\n }\n }\n if (isChar['Halfwidth and Fullwidth Forms'](char)) {\n if (char !== 0xFF08 /* fullwidth left parenthesis */ &&\n char !== 0xFF09 /* fullwidth right parenthesis */ &&\n char !== 0xFF0D /* fullwidth hyphen-minus */ &&\n !((char >= 0xFF1A /* fullwidth colon */ && char <= 0xFF1E) /* fullwidth greater-than sign */) &&\n char !== 0xFF3B /* fullwidth left square bracket */ &&\n char !== 0xFF3D /* fullwidth right square bracket */ &&\n char !== 0xFF3F /* fullwidth low line */ &&\n !(char >= 0xFF5B /* fullwidth left curly bracket */ && char <= 0xFFDF) &&\n char !== 0xFFE3 /* fullwidth macron */ &&\n !(char >= 0xFFE8 /* halfwidth forms light vertical */ && char <= 0xFFEF)) {\n return true;\n }\n }\n if (isChar['Small Form Variants'](char)) {\n if (!((char >= 0xFE58 /* small em dash */ && char <= 0xFE5E) /* small right tortoise shell bracket */) &&\n !((char >= 0xFE63 /* small hyphen-minus */ && char <= 0xFE66) /* small equals sign */)) {\n return true;\n }\n }\n if (isChar['Unified Canadian Aboriginal Syllabics'](char)) return true;\n if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yijing Hexagram Symbols'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * neutral orientation.\n *\n * A character has neutral orientation if it may be drawn rotated or unrotated\n * when the line is oriented vertically, depending on the orientation of the\n * adjacent characters. For example, along a verticlly oriented line, the vulgar\n * fraction ½ is drawn upright among Chinese characters but rotated among Latin\n * letters. A neutrally oriented character does not influence whether an\n * adjacent character is drawn upright or rotated.\n */\nexport function charHasNeutralVerticalOrientation(char: number) {\n if (isChar['Latin-1 Supplement'](char)) {\n if (char === 0x00A7 /* section sign */ ||\n char === 0x00A9 /* copyright sign */ ||\n char === 0x00AE /* registered sign */ ||\n char === 0x00B1 /* plus-minus sign */ ||\n char === 0x00BC /* vulgar fraction one quarter */ ||\n char === 0x00BD /* vulgar fraction one half */ ||\n char === 0x00BE /* vulgar fraction three quarters */ ||\n char === 0x00D7 /* multiplication sign */ ||\n char === 0x00F7 /* division sign */) {\n return true;\n }\n }\n if (isChar['General Punctuation'](char)) {\n if (char === 0x2016 /* double vertical line */ ||\n char === 0x2020 /* dagger */ ||\n char === 0x2021 /* double dagger */ ||\n char === 0x2030 /* per mille sign */ ||\n char === 0x2031 /* per ten thousand sign */ ||\n char === 0x203B /* reference mark */ ||\n char === 0x203C /* double exclamation mark */ ||\n char === 0x2042 /* asterism */ ||\n char === 0x2047 /* double question mark */ ||\n char === 0x2048 /* question exclamation mark */ ||\n char === 0x2049 /* exclamation question mark */ ||\n char === 0x2051 /* two asterisks aligned vertically */) {\n return true;\n }\n }\n if (isChar['Letterlike Symbols'](char)) return true;\n if (isChar['Number Forms'](char)) return true;\n if (isChar['Miscellaneous Technical'](char)) {\n if ((char >= 0x2300 /* diameter sign */ && char <= 0x2307 /* wavy line */) ||\n (char >= 0x230C /* bottom right crop */ && char <= 0x231F /* bottom right corner */) ||\n (char >= 0x2324 /* up arrowhead between two horizontal bars */ && char <= 0x2328 /* keyboard */) ||\n char === 0x232B /* erase to the left */ ||\n (char >= 0x237D /* shouldered open box */ && char <= 0x239A /* clear screen symbol */) ||\n (char >= 0x23BE /* dentistry symbol light vertical and top right */ && char <= 0x23CD /* square foot */) ||\n char === 0x23CF /* eject symbol */ ||\n (char >= 0x23D1 /* metrical breve */ && char <= 0x23DB /* fuse */) ||\n (char >= 0x23E2 /* white trapezium */ && char <= 0x23FF)) {\n return true;\n }\n }\n if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) return true;\n if (isChar['Optical Character Recognition'](char)) return true;\n if (isChar['Enclosed Alphanumerics'](char)) return true;\n if (isChar['Geometric Shapes'](char)) return true;\n if (isChar['Miscellaneous Symbols'](char)) {\n if (!((char >= 0x261A /* black left pointing index */ && char <= 0x261F) /* white down pointing index */)) {\n return true;\n }\n }\n if (isChar['Miscellaneous Symbols and Arrows'](char)) {\n if ((char >= 0x2B12 /* square with top half black */ && char <= 0x2B2F /* white vertical ellipse */) ||\n (char >= 0x2B50 /* white medium star */ && char <= 0x2B59 /* heavy circled saltire */) ||\n (char >= 0x2BB8 /* upwards white arrow from bar with horizontal bar */ && char <= 0x2BEB)) {\n return true;\n }\n }\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Private Use Area'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['Small Form Variants'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n\n if (char === 0x221E /* infinity */ ||\n char === 0x2234 /* therefore */ ||\n char === 0x2235 /* because */ ||\n (char >= 0x2700 /* black safety scissors */ && char <= 0x2767 /* rotated floral heart bullet */) ||\n (char >= 0x2776 /* dingbat negative circled digit one */ && char <= 0x2793 /* dingbat negative circled sans-serif number ten */) ||\n char === 0xFFFC /* object replacement character */ ||\n char === 0xFFFD /* replacement character */) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * rotated orientation.\n *\n * A character has rotated orientation if it is drawn rotated when the line is\n * oriented vertically, even if both adjacent characters are upright. For\n * example, a Latin letter is drawn rotated along a vertical line. A rotated\n * character causes an adjacent “neutral” character to be drawn rotated as well.\n */\nexport function charHasRotatedVerticalOrientation(char: number) {\n return !(charHasUprightVerticalOrientation(char) ||\n charHasNeutralVerticalOrientation(char));\n}\n\nexport function charInComplexShapingScript(char: number) {\n return isChar['Arabic'](char) ||\n isChar['Arabic Supplement'](char) ||\n isChar['Arabic Extended-A'](char) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInRTLScript(char: number) {\n // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts\n return (char >= 0x0590 && char <= 0x08FF) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInSupportedScript(char: number, canRenderRTL: boolean) {\n // This is a rough heuristic: whether we \"can render\" a script\n // actually depends on the properties of the font being used\n // and whether differences from the ideal rendering are considered\n // semantically significant.\n\n // Even in Latin script, we \"can't render\" combinations such as the fi\n // ligature, but we don't consider that semantically significant.\n if (!canRenderRTL && charInRTLScript(char)) {\n return false;\n }\n if ((char >= 0x0900 && char <= 0x0DFF) ||\n // Main blocks for Indic scripts and Sinhala\n (char >= 0x0F00 && char <= 0x109F) ||\n // Main blocks for Tibetan and Myanmar\n isChar['Khmer'](char)) {\n // These blocks cover common scripts that require\n // complex text shaping, based on unicode script metadata:\n // http://www.unicode.org/repos/cldr/trunk/common/properties/scriptMetadata.txt\n // where \"Web Rank <= 32\" \"Shaping Required = YES\"\n return false;\n }\n return true;\n}\n\nexport function stringContainsRTLText(chars: string): boolean {\n for (const char of chars) {\n if (charInRTLScript(char.charCodeAt(0))) {\n return true;\n }\n }\n return false;\n}\n\nexport function isStringInSupportedScript(chars: string, canRenderRTL: boolean) {\n for (const char of chars) {\n if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {\n return false;\n }\n }\n return true;\n}\n","import type {Cancelable} from '../types/cancelable';\n\nconst now = typeof performance !== 'undefined' && performance && performance.now ?\n performance.now.bind(performance) :\n Date.now.bind(Date);\n\nlet linkEl;\n\nlet reducedMotionQuery: MediaQueryList;\n\n/** */\nexport const browser = {\n /**\n * Provides a function that outputs milliseconds: either performance.now()\n * or a fallback to Date.now()\n */\n now,\n\n frame(fn: (paintStartTimestamp: number) => void): Cancelable {\n const frame = requestAnimationFrame(fn);\n return {cancel: () => cancelAnimationFrame(frame)};\n },\n\n getImageData(img: HTMLImageElement | ImageBitmap, padding: number = 0): ImageData {\n const context = this.getImageCanvasContext(img);\n return context.getImageData(-padding, -padding, img.width as number + 2 * padding, img.height as number + 2 * padding);\n },\n\n getImageCanvasContext(img: HTMLImageElement | ImageBitmap): CanvasRenderingContext2D {\n const canvas = window.document.createElement('canvas') as HTMLCanvasElement;\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (!context) {\n throw new Error('failed to create canvas 2d context');\n }\n canvas.width = img.width as number;\n canvas.height = img.height as number;\n context.drawImage(img, 0, 0, img.width as number, img.height as number);\n return context;\n },\n\n resolveURL(path: string) {\n if (!linkEl) linkEl = document.createElement('a');\n linkEl.href = path;\n return linkEl.href;\n },\n\n hardwareConcurrency: typeof navigator !== 'undefined' && navigator.hardwareConcurrency || 4,\n\n get prefersReducedMotion(): boolean {\n // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util'\n if (!matchMedia) return false;\n //Lazily initialize media query\n if (reducedMotionQuery == null) {\n reducedMotionQuery = matchMedia('(prefers-reduced-motion: reduce)');\n }\n return reducedMotionQuery.matches;\n },\n};\n","import {getArrayBuffer} from '../util/ajax';\nimport {browser} from '../util/browser';\nimport {Event, Evented} from '../util/evented';\nimport {isWorker} from '../util/util';\n\nconst status = {\n unavailable: 'unavailable', // Not loaded\n deferred: 'deferred', // The plugin URL has been specified, but loading has been deferred\n loading: 'loading', // request in-flight\n loaded: 'loaded',\n error: 'error'\n};\n\nexport type PluginState = {\n pluginStatus: typeof status[keyof typeof status];\n pluginURL: string;\n};\n\n/**\n * An error callback\n */\ntype ErrorCallback = (error?: Error | null) => void;\ntype PluginStateSyncCallback = (state: PluginState) => void;\nlet _completionCallback = null;\n\n//Variables defining the current state of the plugin\nlet pluginStatus = status.unavailable;\nlet pluginURL = null;\n\nexport const triggerPluginCompletionEvent = function(error: Error | string) {\n // NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin\n if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) {\n pluginStatus = status.error;\n }\n\n if (_completionCallback) {\n _completionCallback(error);\n }\n};\n\nfunction sendPluginStateToWorker() {\n evented.fire(new Event('pluginStateChange', {pluginStatus, pluginURL}));\n}\n\nexport const evented = new Evented();\n\nexport const getRTLTextPluginStatus = function () {\n return pluginStatus;\n};\n\nexport const registerForPluginStateChange = function(callback: PluginStateSyncCallback) {\n // Do an initial sync of the state\n callback({pluginStatus, pluginURL});\n // Listen for all future state changes\n evented.on('pluginStateChange', callback);\n return callback;\n};\n\nexport const clearRTLTextPlugin = function() {\n pluginStatus = status.unavailable;\n pluginURL = null;\n _completionCallback = null;\n};\n\nexport const setRTLTextPlugin = function(url: string, callback: ErrorCallback, deferred: boolean = false) {\n if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) {\n throw new Error('setRTLTextPlugin cannot be called multiple times.');\n }\n pluginURL = browser.resolveURL(url);\n pluginStatus = status.deferred;\n _completionCallback = callback;\n sendPluginStateToWorker();\n\n //Start downloading the plugin immediately if not intending to lazy-load\n if (!deferred) {\n downloadRTLTextPlugin();\n }\n};\n\nexport const downloadRTLTextPlugin = function() {\n if (pluginStatus !== status.deferred || !pluginURL) {\n throw new Error('rtl-text-plugin cannot be downloaded unless a pluginURL is specified');\n }\n pluginStatus = status.loading;\n sendPluginStateToWorker();\n if (pluginURL) {\n getArrayBuffer({url: pluginURL}, (error) => {\n if (error) {\n triggerPluginCompletionEvent(error);\n } else {\n pluginStatus = status.loaded;\n sendPluginStateToWorker();\n }\n });\n }\n};\n\nexport const plugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n isLoaded: () => boolean;\n isLoading: () => boolean;\n setState: (state: PluginState) => void;\n isParsed: () => boolean;\n getPluginURL: () => string;\n} = {\n applyArabicShaping: null,\n processBidirectionalText: null,\n processStyledBidirectionalText: null,\n isLoaded() {\n return pluginStatus === status.loaded || // Main Thread: loaded if the completion callback returned successfully\n plugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled\n },\n isLoading() { // Main Thread Only: query the loading status, this function does not return the correct value in the worker context.\n return pluginStatus === status.loading;\n },\n setState(state: PluginState) { // Worker thread only: this tells the worker threads that the plugin is available on the Main thread\n if (!isWorker()) throw new Error('Cannot set the state of the rtl-text-plugin when not in the web-worker context');\n\n pluginStatus = state.pluginStatus;\n pluginURL = state.pluginURL;\n },\n isParsed(): boolean {\n if (!isWorker()) throw new Error('rtl-text-plugin is only parsed on the worker-threads');\n\n return plugin.applyArabicShaping != null &&\n plugin.processBidirectionalText != null &&\n plugin.processStyledBidirectionalText != null;\n },\n getPluginURL(): string {\n if (!isWorker()) throw new Error('rtl-text-plugin url can only be queried from the worker threads');\n return pluginURL;\n }\n};\n\nexport const lazyLoadRTLTextPlugin = function() {\n if (!plugin.isLoading() &&\n !plugin.isLoaded() &&\n getRTLTextPluginStatus() === 'deferred'\n ) {\n downloadRTLTextPlugin();\n }\n};\n","import {ZoomHistory} from './zoom_history';\nimport {isStringInSupportedScript} from '../util/script_detection';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {TransitionSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CrossfadeParameters = {\n fromScale: number;\n toScale: number;\n t: number;\n};\n\n/**\n * @internal\n * A parameter that can be evaluated to a value\n */\nexport class EvaluationParameters {\n zoom: number;\n now: number;\n fadeDuration: number;\n zoomHistory: ZoomHistory;\n transition: TransitionSpecification;\n\n // \"options\" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate\n constructor(zoom: number, options?: any) {\n this.zoom = zoom;\n\n if (options) {\n this.now = options.now;\n this.fadeDuration = options.fadeDuration;\n this.zoomHistory = options.zoomHistory;\n this.transition = options.transition;\n } else {\n this.now = 0;\n this.fadeDuration = 0;\n this.zoomHistory = new ZoomHistory();\n this.transition = {};\n }\n }\n\n isSupportedScript(str: string): boolean {\n return isStringInSupportedScript(str, rtlTextPlugin.isLoaded());\n }\n\n crossFadingFactor() {\n if (this.fadeDuration === 0) {\n return 1;\n } else {\n return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);\n }\n }\n\n getCrossfadeParameters(): CrossfadeParameters {\n const z = this.zoom;\n const fraction = z - Math.floor(z);\n const t = this.crossFadingFactor();\n\n return z > this.zoomHistory.lastIntegerZoom ?\n {fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t} :\n {fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction};\n }\n}\n","import {clone, extend, easeCubicInOut} from '../util/util';\nimport {interpolates, Color, StylePropertySpecification, normalizePropertyExpression,\n Feature,\n FeatureState,\n StylePropertyExpression,\n SourceExpression,\n CompositeExpression, TransitionSpecification,\n PropertyValueSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from './evaluation_parameters';\n\nimport {CanonicalTileID} from '../source/tile_id';\n\ntype TimePoint = number;\n\n/**\n * A from-to type\n */\nexport type CrossFaded = {\n to: T;\n from: T;\n};\n\n/**\n * @internal\n * Implementations of the `Property` interface:\n *\n * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value,\n * the default value, etc. This comes from the style specification JSON.\n * * Define behavior that needs to be polymorphic across different properties: \"possibly evaluating\"\n * an input value (see below), and interpolating between two possibly-evaluted values.\n *\n * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`).\n * The type `R` is the intermediate \"possibly evaluated\" value type. See below.\n *\n * There are two main implementations of the interface -- one for properties that allow data-driven values,\n * and one for properties that don't. There are a few \"special case\" implementations as well: one for properties\n * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`,\n * and one for `light-position`.\n */\nexport interface Property {\n specification: StylePropertySpecification;\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R;\n interpolate(a: R, b: R, t: number): R;\n}\n\n/**\n * @internal\n * `PropertyValue` represents the value part of a property key-value unit. It's used to represent both\n * paint and layout property values, and regardless of whether or not their property supports data-driven\n * expressions.\n *\n * `PropertyValue` stores the raw input value as seen in a style or a runtime styling API call, i.e. one of the\n * following:\n *\n * * A constant value of the type appropriate for the property\n * * A function which produces a value of that type (but functions are quasi-deprecated in favor of expressions)\n * * An expression which produces a value of that type\n * * \"undefined\"/\"not present\", in which case the property is assumed to take on its default value.\n *\n * In addition to storing the original input value, `PropertyValue` also stores a normalized representation,\n * effectively treating functions as if they are expressions, and constant or default values as if they are\n * (constant) expressions.\n */\nexport class PropertyValue {\n property: Property;\n value: PropertyValueSpecification | void;\n expression: StylePropertyExpression;\n\n constructor(property: Property, value: PropertyValueSpecification | void) {\n this.property = property;\n this.value = value;\n this.expression = normalizePropertyExpression(value === undefined ? property.specification.default : value, property.specification);\n }\n\n isDataDriven(): boolean {\n return this.expression.kind === 'source' || this.expression.kind === 'composite';\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R {\n return this.property.possiblyEvaluate(this, parameters, canonical, availableImages);\n }\n}\n\nexport type TransitionParameters = {\n now: TimePoint;\n transition: TransitionSpecification;\n};\n\n/**\n * @internal\n * Paint properties are _transitionable_: they can change in a fluid manner, interpolating or cross-fading between\n * old and new value. The duration of the transition, and the delay before it begins, is configurable.\n *\n * `TransitionablePropertyValue` is a compositional class that stores both the property value and that transition\n * configuration.\n *\n * A `TransitionablePropertyValue` can calculate the next step in the evaluation chain for paint property values:\n * `TransitioningPropertyValue`.\n */\nclass TransitionablePropertyValue {\n property: Property;\n value: PropertyValue;\n transition: TransitionSpecification | void;\n\n constructor(property: Property) {\n this.property = property;\n this.value = new PropertyValue(property, undefined);\n }\n\n transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, prior,\n extend({}, parameters.transition, this.transition), parameters.now);\n }\n\n untransitioned(): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, null, {}, 0);\n }\n}\n\n/**\n * @internal\n * `Transitionable` stores a map of all (property name, `TransitionablePropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the `TransitioningPropertyValue`s for all of them at once, producing a\n * `Transitioning` instance for the same set of properties.\n */\nexport class Transitionable {\n _properties: Properties;\n _values: {[K in keyof Props]: TransitionablePropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitionablePropertyValues) as any);\n }\n\n getValue(name: S): PropertyValueSpecification | void {\n return clone(this._values[name].value.value);\n }\n\n setValue(name: S, value: PropertyValueSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n // Note that we do not _remove_ an own property in the case where a value is being reset\n // to the default: the transition might still be non-default.\n this._values[name].value = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value));\n }\n\n getTransition(name: S): TransitionSpecification | void {\n return clone(this._values[name].transition);\n }\n\n setTransition(name: S, value: TransitionSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n this._values[name].transition = clone(value) || undefined;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n\n const transition = this.getTransition(property as keyof Props);\n if (transition !== undefined) {\n result[`${property}-transition`] = transition;\n }\n }\n return result;\n }\n\n transitioned(parameters: TransitionParameters, prior: Transitioning): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].transitioned(parameters, prior._values[property]);\n }\n return result;\n }\n\n untransitioned(): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].untransitioned();\n }\n return result;\n }\n}\n\n/**\n * @internal\n * `TransitioningPropertyValue` implements the first of two intermediate steps in the evaluation chain of a paint\n * property value. In this step, transitions between old and new values are handled: as long as the transition is in\n * progress, `TransitioningPropertyValue` maintains a reference to the prior value, and interpolates between it and\n * the new value based on the current time and the configured transition duration and delay. The product is the next\n * step in the evaluation chain: the \"possibly evaluated\" result type `R`. See below for more on this concept.\n */\nclass TransitioningPropertyValue {\n property: Property;\n value: PropertyValue;\n prior: TransitioningPropertyValue;\n begin: TimePoint;\n end: TimePoint;\n\n constructor(property: Property,\n value: PropertyValue,\n prior: TransitioningPropertyValue,\n transition: TransitionSpecification,\n now: TimePoint) {\n this.property = property;\n this.value = value;\n this.begin = now + transition.delay || 0;\n this.end = this.begin + transition.duration || 0;\n if (property.specification.transition && (transition.delay || transition.duration)) {\n this.prior = prior;\n }\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical: CanonicalTileID,\n availableImages: Array\n ): R {\n const now = parameters.now || 0;\n const finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages);\n const prior = this.prior;\n if (!prior) {\n // No prior value.\n return finalValue;\n } else if (now > this.end) {\n // Transition from prior value is now complete.\n this.prior = null;\n return finalValue;\n } else if (this.value.isDataDriven()) {\n // Transitions to data-driven properties are not supported.\n // We snap immediately to the data-driven value so that, when we perform layout,\n // we see the data-driven function and can use it to populate vertex buffers.\n this.prior = null;\n return finalValue;\n } else if (now < this.begin) {\n // Transition hasn't started yet.\n return prior.possiblyEvaluate(parameters, canonical, availableImages);\n } else {\n // Interpolate between recursively-calculated prior value and final.\n const t = (now - this.begin) / (this.end - this.begin);\n return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t));\n }\n }\n}\n\n/**\n * @internal\n * `Transitioning` stores a map of all (property name, `TransitioningPropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Transitioning {\n _properties: Properties;\n _values: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitioningPropertyValues) as any);\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n\n hasTransition() {\n for (const property of Object.keys(this._values)) {\n if (this._values[property].prior) {\n return true;\n }\n }\n return false;\n }\n}\n\n// ------- Layout -------\n\n/**\n * Because layout properties are not transitionable, they have a simpler representation and evaluation chain than\n * paint properties: `PropertyValue`s are possibly evaluated, producing possibly evaluated values, which are then\n * fully evaluated.\n *\n * `Layout` stores a map of all (property name, `PropertyValue`) pairs for layout properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Layout {\n _properties: Properties;\n _values: {[K in keyof Props]: PropertyValue>};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultPropertyValues) as any);\n }\n\n hasValue(name: S) {\n return this._values[name].value !== undefined;\n }\n\n getValue(name: S) {\n return clone(this._values[name].value);\n }\n\n setValue(name: S, value: any) {\n this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value)) as any;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n }\n return result;\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n}\n\n// ------- PossiblyEvaluated -------\n\n/**\n * \"Possibly evaluated value\" is an intermediate stage in the evaluation chain for both paint and layout property\n * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code\n * which uses data-driven property values must assume that the value is dependent on feature data, and request that it\n * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation\n * will not actually depend on the feature, and we can benefit from returning the prior result of having done the\n * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and \"global\" parameters\n * such as current zoom level.\n *\n * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or\n * camera expression, then the \"possibly evaluated\" result is a constant value. Otherwise, the input value was either\n * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate\n * the source and composite cases because they are handled differently when generating GL attributes, buffers, and\n * uniforms.\n *\n * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that\n * do not allow data-driven values. For such properties, we know that the \"possibly evaluated\" result is always a constant\n * scalar value. See below.\n */\ntype PossiblyEvaluatedValue = {\n kind: 'constant';\n value: T;\n} | SourceExpression | CompositeExpression;\n\n/**\n * @internal\n * `PossiblyEvaluatedPropertyValue` is used for data-driven paint and layout property values. It holds a\n * `PossiblyEvaluatedValue` and the `GlobalProperties` that were used to generate it. You're not allowed to supply\n * a different set of `GlobalProperties` when performing the final evaluation because they would be ignored in the\n * case where the input value was a constant or camera function.\n */\nexport class PossiblyEvaluatedPropertyValue {\n property: DataDrivenProperty;\n value: PossiblyEvaluatedValue;\n parameters: EvaluationParameters;\n\n constructor(property: DataDrivenProperty, value: PossiblyEvaluatedValue, parameters: EvaluationParameters) {\n this.property = property;\n this.value = value;\n this.parameters = parameters;\n }\n\n isConstant(): boolean {\n return this.value.kind === 'constant';\n }\n\n constantOr(value: T): T {\n if (this.value.kind === 'constant') {\n return this.value.value;\n } else {\n return value;\n }\n }\n\n evaluate(\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages);\n }\n}\n\n/**\n * @internal\n * `PossiblyEvaluated` stores a map of all (property name, `R`) pairs for paint or layout properties of a\n * given layer type.\n */\nexport class PossiblyEvaluated {\n _properties: Properties;\n _values: PossibleEvaluatedProps;\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = Object.create(properties.defaultPossiblyEvaluatedValues);\n }\n\n get(name: S): PossibleEvaluatedProps[S] {\n return this._values[name];\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that do not permit data-driven (source or composite) expressions.\n * This restriction allows us to declare statically that the result of possibly evaluating this kind of property\n * is in fact always the scalar type `T`, and can be used without further evaluating the value on a per-feature basis.\n */\nexport class DataConstantProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters): T {\n if (value.isDataDriven()) throw new Error('Value should not be data driven');\n return value.expression.evaluate(parameters);\n }\n\n interpolate(a: T, b: T, t: number): T {\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n return interpolationFn(a, b, t);\n } else {\n return a;\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that permit data-driven (source or composite) expressions.\n * The result of possibly evaluating this kind of property is `PossiblyEvaluatedPropertyValue`; obtaining\n * a scalar value `T` requires further evaluation on a per-feature basis.\n */\nexport class DataDrivenProperty implements Property> {\n specification: StylePropertySpecification;\n overrides: any;\n\n constructor(specification: StylePropertySpecification, overrides?: any) {\n this.specification = specification;\n this.overrides = overrides;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue {\n if (value.expression.kind === 'constant' || value.expression.kind === 'camera') {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: value.expression.evaluate(parameters, null, {}, canonical, availableImages)}, parameters);\n } else {\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n interpolate(\n a: PossiblyEvaluatedPropertyValue,\n b: PossiblyEvaluatedPropertyValue,\n t: number\n ): PossiblyEvaluatedPropertyValue {\n // If either possibly-evaluated value is non-constant, give up: we aren't able to interpolate data-driven values.\n if (a.value.kind !== 'constant' || b.value.kind !== 'constant') {\n return a;\n }\n\n // Special case hack solely for fill-outline-color. The undefined value is subsequently handled in\n // FillStyleLayer#recalculate, which sets fill-outline-color to the fill-color value if the former\n // is a PossiblyEvaluatedPropertyValue containing a constant undefined value. In addition to the\n // return value here, the other source of a PossiblyEvaluatedPropertyValue containing a constant\n // undefined value is the \"default value\" for fill-outline-color held in\n // `Properties#defaultPossiblyEvaluatedValues`, which serves as the prototype of\n // `PossiblyEvaluated#_values`.\n if (a.value.value === undefined || b.value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, a.parameters);\n }\n\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n const interpolatedValue = interpolationFn(a.value.value, b.value.value, t);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: interpolatedValue}, a.parameters);\n } else {\n return a;\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue,\n parameters: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return value.evaluate(parameters, feature, featureState, canonical, availableImages);\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for data driven `line-pattern` which are transitioned by cross-fading\n * rather than interpolation.\n */\n\nexport class CrossFadedDataDrivenProperty extends DataDrivenProperty> {\n\n possiblyEvaluate(\n value: PropertyValue, PossiblyEvaluatedPropertyValue>>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue> {\n if (value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, parameters);\n } else if (value.expression.kind === 'constant') {\n const evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n const isImageExpression = value.property.specification.type as any === 'resolvedImage';\n const constantValue = isImageExpression && typeof evaluatedValue !== 'string' ? evaluatedValue.name : evaluatedValue;\n const constant = this._calculate(constantValue, constantValue, constantValue, parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: constant}, parameters);\n } else if (value.expression.kind === 'camera') {\n const cameraVal = this._calculate(\n value.expression.evaluate({zoom: parameters.zoom - 1.0}),\n value.expression.evaluate({zoom: parameters.zoom}),\n value.expression.evaluate({zoom: parameters.zoom + 1.0}),\n parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: cameraVal}, parameters);\n } else {\n // source or composite expression\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue>,\n globals: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.kind === 'source') {\n const constant = value.evaluate(globals, feature, featureState, canonical, availableImages);\n return this._calculate(constant, constant, constant, globals);\n } else if (value.kind === 'composite') {\n return this._calculate(\n value.evaluate({zoom: Math.floor(globals.zoom) - 1.0}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom)}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom) + 1.0}, feature, featureState),\n globals);\n } else {\n return value.value;\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue> {\n return a;\n }\n}\n/**\n * @internal\n * An implementation of `Property` for `*-pattern` and `line-dasharray`, which are transitioned by cross-fading\n * rather than interpolation.\n */\nexport class CrossFadedProperty implements Property> {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.value === undefined) {\n return undefined;\n } else if (value.expression.kind === 'constant') {\n const constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n return this._calculate(constant, constant, constant, parameters);\n } else {\n return this._calculate(\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1.0), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1.0), parameters)),\n parameters);\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a?: CrossFaded | null): CrossFaded {\n return a;\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for `heatmap-color` and `line-gradient`. Interpolation is a no-op, and\n * evaluation returns a boolean value in order to indicate its presence, but the real\n * evaluation happens in StyleLayer classes.\n */\n\nexport class ColorRampProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): boolean {\n return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n }\n\n interpolate(): boolean { return false; }\n}\n\n/**\n * @internal\n * `Properties` holds objects containing default values for the layout or paint property set of a given\n * layer type. These objects are immutable, and they are used as the prototypes for the `_values` members of\n * `Transitionable`, `Transitioning`, `Layout`, and `PossiblyEvaluated`. This allows these classes to avoid\n * doing work in the common case where a property has no explicit value set and should be considered to take\n * on the default value: using `for (const property of Object.keys(this._values))`, they can iterate over\n * only the _own_ properties of `_values`, skipping repeated calculation of transitions and possible/final\n * evaluations for defaults, the result of which will always be the same.\n */\nexport class Properties {\n properties: Props;\n defaultPropertyValues: {[K in keyof Props]: PropertyValue};\n defaultTransitionablePropertyValues: {[K in keyof Props]: TransitionablePropertyValue};\n defaultTransitioningPropertyValues: {[K in keyof Props]: TransitioningPropertyValue};\n defaultPossiblyEvaluatedValues: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n overridableProperties: Array;\n\n constructor(properties: Props) {\n this.properties = properties;\n this.defaultPropertyValues = ({} as any);\n this.defaultTransitionablePropertyValues = ({} as any);\n this.defaultTransitioningPropertyValues = ({} as any);\n this.defaultPossiblyEvaluatedValues = ({} as any);\n this.overridableProperties = ([] as any);\n\n for (const property in properties) {\n const prop = properties[property] as any;\n if (prop.specification.overridable) {\n this.overridableProperties.push(property);\n }\n const defaultPropertyValue = this.defaultPropertyValues[property] =\n new PropertyValue(prop, undefined);\n const defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] =\n new TransitionablePropertyValue(prop);\n this.defaultTransitioningPropertyValues[property] =\n defaultTransitionablePropertyValue.untransitioned();\n this.defaultPossiblyEvaluatedValues[property] =\n defaultPropertyValue.possiblyEvaluate({} as any);\n }\n }\n}\n\nregister('DataDrivenProperty', DataDrivenProperty);\nregister('DataConstantProperty', DataConstantProperty);\nregister('CrossFadedDataDrivenProperty', CrossFadedDataDrivenProperty);\nregister('CrossFadedProperty', CrossFadedProperty);\nregister('ColorRampProperty', ColorRampProperty);\n","import {filterObject} from '../util/util';\n\nimport {latest as styleSpec, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {\n validateStyle,\n validateLayoutProperty,\n validatePaintProperty,\n emitValidationErrors\n} from './validate_style';\nimport {Evented} from '../util/evented';\nimport {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties';\n\nimport type {Bucket} from '../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureFilter, FeatureState,\n LayerSpecification,\n FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {TransitionParameters, PropertyValue} from './properties';\nimport {EvaluationParameters} from './evaluation_parameters';\nimport type {CrossfadeParameters} from './evaluation_parameters';\n\nimport type {Transform} from '../geo/transform';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Map} from '../ui/map';\nimport type {StyleSetterOptions} from './style';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nconst TRANSITION_SUFFIX = '-transition';\n\n/**\n * A base class for style layers\n */\nexport abstract class StyleLayer extends Evented {\n id: string;\n metadata: unknown;\n type: LayerSpecification['type'] | CustomLayerInterface['type'];\n source: string;\n sourceLayer: string;\n minzoom: number;\n maxzoom: number;\n filter: FilterSpecification | void;\n visibility: 'visible' | 'none' | void;\n _crossfadeParameters: CrossfadeParameters;\n\n _unevaluatedLayout: Layout;\n readonly layout: unknown;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n readonly paint: unknown;\n\n _featureFilter: FeatureFilter;\n\n readonly onAdd: ((map: Map) => void);\n readonly onRemove: ((map: Map) => void);\n\n queryRadius?(bucket: Bucket): number;\n queryIntersectsFeature?(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number;\n\n constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{\n layout?: Properties;\n paint?: Properties;\n }>) {\n super();\n\n this.id = layer.id;\n this.type = layer.type;\n this._featureFilter = {filter: () => true, needGeometry: false};\n\n if (layer.type === 'custom') return;\n\n layer = (layer as any as LayerSpecification);\n\n this.metadata = layer.metadata;\n this.minzoom = layer.minzoom;\n this.maxzoom = layer.maxzoom;\n\n if (layer.type !== 'background') {\n this.source = layer.source;\n this.sourceLayer = layer['source-layer'];\n this.filter = layer.filter;\n }\n\n if (properties.layout) {\n this._unevaluatedLayout = new Layout(properties.layout);\n }\n\n if (properties.paint) {\n this._transitionablePaint = new Transitionable(properties.paint);\n\n for (const property in layer.paint) {\n this.setPaintProperty(property, layer.paint[property], {validate: false});\n }\n for (const property in layer.layout) {\n this.setLayoutProperty(property, layer.layout[property], {validate: false});\n }\n\n this._transitioningPaint = this._transitionablePaint.untransitioned();\n //$FlowFixMe\n this.paint = new PossiblyEvaluated(properties.paint);\n }\n }\n\n getCrossfadeParameters() {\n return this._crossfadeParameters;\n }\n\n getLayoutProperty(name: string) {\n if (name === 'visibility') {\n return this.visibility;\n }\n\n return this._unevaluatedLayout.getValue(name);\n }\n\n setLayoutProperty(name: string, value: any, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.layout.${name}`;\n if (this._validate(validateLayoutProperty, key, name, value, options)) {\n return;\n }\n }\n\n if (name === 'visibility') {\n this.visibility = value;\n return;\n }\n\n this._unevaluatedLayout.setValue(name, value);\n }\n\n getPaintProperty(name: string) {\n if (name.endsWith(TRANSITION_SUFFIX)) {\n return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length));\n } else {\n return this._transitionablePaint.getValue(name);\n }\n }\n\n setPaintProperty(name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.paint.${name}`;\n if (this._validate(validatePaintProperty, key, name, value, options)) {\n return false;\n }\n }\n\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), (value as any) || undefined);\n return false;\n } else {\n const transitionable = this._transitionablePaint._values[name];\n const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven';\n const wasDataDriven = transitionable.value.isDataDriven();\n const oldValue = transitionable.value;\n\n this._transitionablePaint.setValue(name, value);\n this._handleSpecialPaintPropertyUpdate(name);\n\n const newValue = this._transitionablePaint._values[name].value;\n const isDataDriven = newValue.isDataDriven();\n\n // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas\n // so a call to _updateLayer is necessary, and we return true from this function so it gets called in\n // Style#setPaintProperty\n return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name, oldValue, newValue);\n }\n }\n\n _handleSpecialPaintPropertyUpdate(_: string) {\n // No-op; can be overridden by derived classes.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n // No-op; can be overridden by derived classes.\n return false;\n }\n\n isHidden(zoom: number) {\n if (this.minzoom && zoom < this.minzoom) return true;\n if (this.maxzoom && zoom >= this.maxzoom) return true;\n return this.visibility === 'none';\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint);\n }\n\n hasTransition() {\n return this._transitioningPaint.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n if (parameters.getCrossfadeParameters) {\n this._crossfadeParameters = parameters.getCrossfadeParameters();\n }\n\n if (this._unevaluatedLayout) {\n (this as any).layout = this._unevaluatedLayout.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n (this as any).paint = this._transitioningPaint.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n serialize(): LayerSpecification {\n const output: LayerSpecification = {\n 'id': this.id,\n 'type': this.type as LayerSpecification['type'],\n 'source': this.source,\n 'source-layer': this.sourceLayer,\n 'metadata': this.metadata,\n 'minzoom': this.minzoom,\n 'maxzoom': this.maxzoom,\n 'filter': this.filter as FilterSpecification,\n 'layout': this._unevaluatedLayout && this._unevaluatedLayout.serialize(),\n 'paint': this._transitionablePaint && this._transitionablePaint.serialize()\n };\n\n if (this.visibility) {\n output.layout = output.layout || {};\n output.layout.visibility = this.visibility;\n }\n\n return filterObject(output, (value, key) => {\n return value !== undefined &&\n !(key === 'layout' && !Object.keys(value).length) &&\n !(key === 'paint' && !Object.keys(value).length);\n });\n }\n\n _validate(validate: Function, key: string, name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, {\n key,\n layerType: this.type,\n objectKey: name,\n value,\n styleSpec,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true}\n }));\n }\n\n is3D() {\n return false;\n }\n\n isTileClipped() {\n return false;\n }\n\n hasOffscreenPass() {\n return false;\n }\n\n resize() {\n // noop\n }\n\n isStateDependent() {\n for (const property in (this as any).paint._values) {\n const value = (this as any).paint.get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n\n if ((value.value.kind === 'source' || value.value.kind === 'composite') &&\n value.value.isStateDependent) {\n return true;\n }\n }\n return false;\n }\n}\n","// Note: all \"sizes\" are measured in bytes\n\nimport type {Transferable} from '../types/transferable';\n\n/**\n * @internal\n * A view type size\n */\nconst viewTypes = {\n 'Int8': Int8Array,\n 'Uint8': Uint8Array,\n 'Int16': Int16Array,\n 'Uint16': Uint16Array,\n 'Int32': Int32Array,\n 'Uint32': Uint32Array,\n 'Float32': Float32Array\n};\n\n/**\n * @internal\n * A view type size\n */\nexport type ViewType = keyof typeof viewTypes;\n\n/** @internal */\nclass Struct {\n _pos1: number;\n _pos2: number;\n _pos4: number;\n _pos8: number;\n readonly _structArray: StructArray;\n\n // The following properties are defined on the prototype of sub classes.\n size: number;\n\n /**\n * @param structArray - The StructArray the struct is stored in\n * @param index - The index of the struct in the StructArray.\n */\n constructor(structArray: StructArray, index: number) {\n (this as any)._structArray = structArray;\n this._pos1 = index * this.size;\n this._pos2 = this._pos1 / 2;\n this._pos4 = this._pos1 / 4;\n this._pos8 = this._pos1 / 8;\n }\n}\n\nconst DEFAULT_CAPACITY = 128;\nconst RESIZE_MULTIPLIER = 5;\n\n/**\n * @internal\n * A struct array memeber\n */\nexport type StructArrayMember = {\n name: string;\n type: ViewType;\n components: number;\n offset: number;\n};\n\nexport type StructArrayLayout = {\n members: Array;\n size: number;\n alignment: number;\n};\n\n/**\n * An array that can be desialized\n */\nexport type SerializedStructArray = {\n length: number;\n arrayBuffer: ArrayBuffer;\n};\n\n/**\n * @internal\n * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray`\n * making it behave like an array of typed structs.\n *\n * Conceptually, a StructArray is comprised of elements, i.e., instances of its\n * associated struct type. Each particular struct type, together with an\n * alignment size, determines the memory layout of a StructArray whose elements\n * are of that type. Thus, for each such layout that we need, we have\n * a corresponding StructArrayLayout class, inheriting from StructArray and\n * implementing `emplaceBack()` and `_refreshViews()`.\n *\n * In some cases, where we need to access particular elements of a StructArray,\n * we implement a more specific subclass that inherits from one of the\n * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured\n * object whose properties are proxies into the underlying memory space for the\n * i-th element. This affords the convience of working with (seemingly) plain\n * Javascript objects without the overhead of serializing/deserializing them\n * into ArrayBuffers for efficient web worker transfer.\n */\nabstract class StructArray {\n capacity: number;\n length: number;\n isTransferred: boolean;\n arrayBuffer: ArrayBuffer;\n uint8: Uint8Array;\n\n // The following properties are defined on the prototype.\n members: Array;\n bytesPerElement: number;\n abstract emplaceBack(...v: number[]);\n abstract emplace(i: number, ...v: number[]);\n\n constructor() {\n this.isTransferred = false;\n this.capacity = -1;\n this.resize(0);\n }\n\n /**\n * Serialize a StructArray instance. Serializes both the raw data and the\n * metadata needed to reconstruct the StructArray base class during\n * deserialization.\n */\n static serialize(array: StructArray, transferables?: Array): SerializedStructArray {\n\n array._trim();\n\n if (transferables) {\n array.isTransferred = true;\n transferables.push(array.arrayBuffer);\n }\n\n return {\n length: array.length,\n arrayBuffer: array.arrayBuffer,\n };\n }\n\n static deserialize(input: SerializedStructArray) {\n const structArray = Object.create(this.prototype);\n structArray.arrayBuffer = input.arrayBuffer;\n structArray.length = input.length;\n structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;\n structArray._refreshViews();\n return structArray;\n }\n\n /**\n * Resize the array to discard unused capacity.\n */\n _trim() {\n if (this.length !== this.capacity) {\n this.capacity = this.length;\n this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement);\n this._refreshViews();\n }\n }\n\n /**\n * Resets the length of the array to 0 without de-allocating capcacity.\n */\n clear() {\n this.length = 0;\n }\n\n /**\n * Resize the array.\n * If `n` is greater than the current length then additional elements with undefined values are added.\n * If `n` is less than the current length then the array will be reduced to the first `n` elements.\n * @param n - The new size of the array.\n */\n resize(n: number) {\n this.reserve(n);\n this.length = n;\n }\n\n /**\n * Indicate a planned increase in size, so that any necessary allocation may\n * be done once, ahead of time.\n * @param n - The expected size of the array.\n */\n reserve(n: number) {\n if (n > this.capacity) {\n this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY);\n this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);\n\n const oldUint8Array = this.uint8;\n this._refreshViews();\n if (oldUint8Array) this.uint8.set(oldUint8Array);\n }\n }\n\n /**\n * Create TypedArray views for the current ArrayBuffer.\n */\n _refreshViews() {\n throw new Error('_refreshViews() must be implemented by each concrete StructArray layout');\n }\n}\n\n/**\n * Given a list of member fields, create a full StructArrayLayout, in\n * particular calculating the correct byte offset for each field. This data\n * is used at build time to generate StructArrayLayout_*#emplaceBack() and\n * other accessors, and at runtime for binding vertex buffer attributes.\n */\nfunction createLayout(\n members: Array<{\n name: string;\n type: ViewType;\n readonly components?: number;\n }>,\n alignment: number = 1\n): StructArrayLayout {\n\n let offset = 0;\n let maxSize = 0;\n const layoutMembers = members.map((member) => {\n const typeSize = sizeOf(member.type);\n const memberOffset = offset = align(offset, Math.max(alignment, typeSize));\n const components = member.components || 1;\n\n maxSize = Math.max(maxSize, typeSize);\n offset += typeSize * components;\n\n return {\n name: member.name,\n type: member.type,\n components,\n offset: memberOffset,\n };\n });\n\n const size = align(offset, Math.max(maxSize, alignment));\n\n return {\n members: layoutMembers,\n size,\n alignment\n };\n}\n\nfunction sizeOf(type: ViewType): number {\n return viewTypes[type].BYTES_PER_ELEMENT;\n}\n\nfunction align(offset: number, size: number): number {\n return Math.ceil(offset / size) * size;\n}\n\nexport {StructArray, Struct, viewTypes, createLayout};\n","// This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`.\n\nimport {Struct, StructArray} from '../util/struct_array';\nimport {register} from '../util/web_worker_transfer';\nimport Point from '@mapbox/point-geometry';\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n *\n */\nclass StructArrayLayout2i4 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2i4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2i4', StructArrayLayout2i4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[3]\n *\n */\nclass StructArrayLayout3i6 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3i6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3i6', StructArrayLayout3i6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n *\n */\nclass StructArrayLayout4i8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o2 = i * 4;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4i8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout4i8', StructArrayLayout4i8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[4]\n *\n */\nclass StructArrayLayout2i4i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i4i12', StructArrayLayout2i4i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint8[4]\n *\n */\nclass StructArrayLayout2i4ub8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 4;\n const o1 = i * 8;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint8[o1 + 4] = v2;\n this.uint8[o1 + 5] = v3;\n this.uint8[o1 + 6] = v4;\n this.uint8[o1 + 7] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4ub8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n *\n */\nclass StructArrayLayout2f8 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o4 = i * 2;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2f8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2f8', StructArrayLayout2f8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[10]\n *\n */\nclass StructArrayLayout10ui20 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const o2 = i * 10;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n return i;\n }\n}\n\nStructArrayLayout10ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout10ui20', StructArrayLayout10ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n * [8]: Uint16[4]\n * [16]: Int16[4]\n *\n */\nclass StructArrayLayout4i4ui4i24 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const o2 = i * 12;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.int16[o2 + 8] = v8;\n this.int16[o2 + 9] = v9;\n this.int16[o2 + 10] = v10;\n this.int16[o2 + 11] = v11;\n return i;\n }\n}\n\nStructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24;\nregister('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[3]\n *\n */\nclass StructArrayLayout3f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 3;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout3f12', StructArrayLayout3f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n *\n */\nclass StructArrayLayout1ul4 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.uint32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ul4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1ul4', StructArrayLayout1ul4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[6]\n * [12]: Uint32[1]\n * [16]: Uint16[2]\n *\n */\nclass StructArrayLayout6i1ul2ui20 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const o2 = i * 10;\n const o4 = i * 5;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.uint32[o4 + 3] = v6;\n this.uint16[o2 + 8] = v7;\n this.uint16[o2 + 9] = v8;\n return i;\n }\n}\n\nStructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[2]\n * [8]: Int16[2]\n *\n */\nclass StructArrayLayout2i2i2i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i2i2i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n * [8]: Float32[1]\n * [12]: Int16[2]\n *\n */\nclass StructArrayLayout2f1f2i16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number) {\n const o4 = i * 4;\n const o2 = i * 8;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.int16[o2 + 6] = v3;\n this.int16[o2 + 7] = v4;\n return i;\n }\n}\n\nStructArrayLayout2f1f2i16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint8[2]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout2ub2f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o1 = i * 12;\n const o4 = i * 3;\n this.uint8[o1 + 0] = v0;\n this.uint8[o1 + 1] = v1;\n this.float32[o4 + 1] = v2;\n this.float32[o4 + 2] = v3;\n return i;\n }\n}\n\nStructArrayLayout2ub2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[3]\n *\n */\nclass StructArrayLayout3ui6 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3ui6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3ui6', StructArrayLayout3ui6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint16[2]\n * [8]: Uint32[3]\n * [20]: Uint16[3]\n * [28]: Float32[2]\n * [36]: Uint8[3]\n * [40]: Uint32[1]\n * [44]: Int16[1]\n *\n */\nclass StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const o2 = i * 24;\n const o4 = i * 12;\n const o1 = i * 48;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint32[o4 + 2] = v4;\n this.uint32[o4 + 3] = v5;\n this.uint32[o4 + 4] = v6;\n this.uint16[o2 + 10] = v7;\n this.uint16[o2 + 11] = v8;\n this.uint16[o2 + 12] = v9;\n this.float32[o4 + 7] = v10;\n this.float32[o4 + 8] = v11;\n this.uint8[o1 + 36] = v12;\n this.uint8[o1 + 37] = v13;\n this.uint8[o1 + 38] = v14;\n this.uint32[o4 + 10] = v15;\n this.int16[o2 + 22] = v16;\n return i;\n }\n}\n\nStructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48;\nregister('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[8]\n * [16]: Uint16[15]\n * [48]: Uint32[1]\n * [52]: Float32[2]\n * [60]: Uint16[2]\n *\n */\nclass StructArrayLayout8i15ui1ul2f2ui64 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const o2 = i * 32;\n const o4 = i * 16;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.int16[o2 + 6] = v6;\n this.int16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n this.uint16[o2 + 10] = v10;\n this.uint16[o2 + 11] = v11;\n this.uint16[o2 + 12] = v12;\n this.uint16[o2 + 13] = v13;\n this.uint16[o2 + 14] = v14;\n this.uint16[o2 + 15] = v15;\n this.uint16[o2 + 16] = v16;\n this.uint16[o2 + 17] = v17;\n this.uint16[o2 + 18] = v18;\n this.uint16[o2 + 19] = v19;\n this.uint16[o2 + 20] = v20;\n this.uint16[o2 + 21] = v21;\n this.uint16[o2 + 22] = v22;\n this.uint32[o4 + 12] = v23;\n this.float32[o4 + 13] = v24;\n this.float32[o4 + 14] = v25;\n this.uint16[o2 + 30] = v26;\n this.uint16[o2 + 31] = v27;\n return i;\n }\n}\n\nStructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64;\nregister('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[1]\n *\n */\nclass StructArrayLayout1f4 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.float32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1f4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1f4', StructArrayLayout1f4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout1ui2f12 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 6;\n const o4 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ui2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n * [4]: Uint16[2]\n *\n */\nclass StructArrayLayout1ul2ui8 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 2;\n const o2 = i * 4;\n this.uint32[o4 + 0] = v0;\n this.uint16[o2 + 2] = v1;\n this.uint16[o2 + 3] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ul2ui8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[2]\n *\n */\nclass StructArrayLayout2ui4 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2ui4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2ui4', StructArrayLayout2ui4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n *\n */\nclass StructArrayLayout1ui2 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o2 = i * 1;\n this.uint16[o2 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ui2.prototype.bytesPerElement = 2;\nregister('StructArrayLayout1ui2', StructArrayLayout1ui2);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[4]\n *\n */\nclass StructArrayLayout4f16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o4 = i * 4;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.float32[o4 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4f16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout4f16', StructArrayLayout4f16);\n\n/** @internal */\nclass CollisionBoxStruct extends Struct {\n _structArray: CollisionBoxArray;\n get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorPointY() { return this._structArray.int16[this._pos2 + 1]; }\n get x1() { return this._structArray.int16[this._pos2 + 2]; }\n get y1() { return this._structArray.int16[this._pos2 + 3]; }\n get x2() { return this._structArray.int16[this._pos2 + 4]; }\n get y2() { return this._structArray.int16[this._pos2 + 5]; }\n get featureIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 8]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); }\n}\n\nCollisionBoxStruct.prototype.size = 20;\n\nexport type CollisionBox = CollisionBoxStruct;\n\n/** @internal */\nexport class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {\n /**\n * Return the CollisionBoxStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): CollisionBoxStruct {\n return new CollisionBoxStruct(this, index);\n }\n}\n\nregister('CollisionBoxArray', CollisionBoxArray);\n\n/** @internal */\nclass PlacedSymbolStruct extends Struct {\n _structArray: PlacedSymbolArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get glyphStartIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get numGlyphs() { return this._structArray.uint16[this._pos2 + 3]; }\n get vertexStartIndex() { return this._structArray.uint32[this._pos4 + 2]; }\n get lineStartIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get lineLength() { return this._structArray.uint32[this._pos4 + 4]; }\n get segment() { return this._structArray.uint16[this._pos2 + 10]; }\n get lowerSize() { return this._structArray.uint16[this._pos2 + 11]; }\n get upperSize() { return this._structArray.uint16[this._pos2 + 12]; }\n get lineOffsetX() { return this._structArray.float32[this._pos4 + 7]; }\n get lineOffsetY() { return this._structArray.float32[this._pos4 + 8]; }\n get writingMode() { return this._structArray.uint8[this._pos1 + 36]; }\n get placedOrientation() { return this._structArray.uint8[this._pos1 + 37]; }\n set placedOrientation(x: number) { this._structArray.uint8[this._pos1 + 37] = x; }\n get hidden() { return this._structArray.uint8[this._pos1 + 38]; }\n set hidden(x: number) { this._structArray.uint8[this._pos1 + 38] = x; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 10]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 10] = x; }\n get associatedIconIndex() { return this._structArray.int16[this._pos2 + 22]; }\n}\n\nPlacedSymbolStruct.prototype.size = 48;\n\nexport type PlacedSymbol = PlacedSymbolStruct;\n\n/** @internal */\nexport class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 {\n /**\n * Return the PlacedSymbolStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): PlacedSymbolStruct {\n return new PlacedSymbolStruct(this, index);\n }\n}\n\nregister('PlacedSymbolArray', PlacedSymbolArray);\n\n/** @internal */\nclass SymbolInstanceStruct extends Struct {\n _structArray: SymbolInstanceArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get rightJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 2]; }\n get centerJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 3]; }\n get leftJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 4]; }\n get verticalPlacedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 5]; }\n get placedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 6]; }\n get verticalPlacedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 7]; }\n get key() { return this._structArray.uint16[this._pos2 + 8]; }\n get textBoxStartIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get textBoxEndIndex() { return this._structArray.uint16[this._pos2 + 10]; }\n get verticalTextBoxStartIndex() { return this._structArray.uint16[this._pos2 + 11]; }\n get verticalTextBoxEndIndex() { return this._structArray.uint16[this._pos2 + 12]; }\n get iconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 13]; }\n get iconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 14]; }\n get verticalIconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 15]; }\n get verticalIconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 16]; }\n get featureIndex() { return this._structArray.uint16[this._pos2 + 17]; }\n get numHorizontalGlyphVertices() { return this._structArray.uint16[this._pos2 + 18]; }\n get numVerticalGlyphVertices() { return this._structArray.uint16[this._pos2 + 19]; }\n get numIconVertices() { return this._structArray.uint16[this._pos2 + 20]; }\n get numVerticalIconVertices() { return this._structArray.uint16[this._pos2 + 21]; }\n get useRuntimeCollisionCircles() { return this._structArray.uint16[this._pos2 + 22]; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 12] = x; }\n get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; }\n get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; }\n get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; }\n get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; }\n}\n\nSymbolInstanceStruct.prototype.size = 64;\n\nexport type SymbolInstance = SymbolInstanceStruct;\n\n/** @internal */\nexport class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 {\n /**\n * Return the SymbolInstanceStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): SymbolInstanceStruct {\n return new SymbolInstanceStruct(this, index);\n }\n}\n\nregister('SymbolInstanceArray', SymbolInstanceArray);\n\n/** @internal */\nexport class GlyphOffsetArray extends StructArrayLayout1f4 {\n getoffsetX(index: number) { return this.float32[index * 1 + 0]; }\n}\n\nregister('GlyphOffsetArray', GlyphOffsetArray);\n\n/** @internal */\nexport class SymbolLineVertexArray extends StructArrayLayout3i6 {\n getx(index: number) { return this.int16[index * 3 + 0]; }\n gety(index: number) { return this.int16[index * 3 + 1]; }\n gettileUnitDistanceFromAnchor(index: number) { return this.int16[index * 3 + 2]; }\n}\n\nregister('SymbolLineVertexArray', SymbolLineVertexArray);\n\n/** @internal */\nclass TextAnchorOffsetStruct extends Struct {\n _structArray: TextAnchorOffsetArray;\n get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; }\n get textOffset0() { return this._structArray.float32[this._pos4 + 1]; }\n get textOffset1() { return this._structArray.float32[this._pos4 + 2]; }\n}\n\nTextAnchorOffsetStruct.prototype.size = 12;\n\nexport type TextAnchorOffset = TextAnchorOffsetStruct;\n\n/** @internal */\nexport class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 {\n /**\n * Return the TextAnchorOffsetStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): TextAnchorOffsetStruct {\n return new TextAnchorOffsetStruct(this, index);\n }\n}\n\nregister('TextAnchorOffsetArray', TextAnchorOffsetArray);\n\n/** @internal */\nclass FeatureIndexStruct extends Struct {\n _structArray: FeatureIndexArray;\n get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 3]; }\n}\n\nFeatureIndexStruct.prototype.size = 8;\n\nexport type FeatureIndex = FeatureIndexStruct;\n\n/** @internal */\nexport class FeatureIndexArray extends StructArrayLayout1ul2ui8 {\n /**\n * Return the FeatureIndexStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): FeatureIndexStruct {\n return new FeatureIndexStruct(this, index);\n }\n}\n\nregister('FeatureIndexArray', FeatureIndexArray);\n\nexport class PosArray extends StructArrayLayout2i4 {}\nexport class Pos3dArray extends StructArrayLayout3i6 {}\nexport class RasterBoundsArray extends StructArrayLayout4i8 {}\nexport class CircleLayoutArray extends StructArrayLayout2i4 {}\nexport class FillLayoutArray extends StructArrayLayout2i4 {}\nexport class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 {}\nexport class HeatmapLayoutArray extends StructArrayLayout2i4 {}\nexport class LineLayoutArray extends StructArrayLayout2i4ub8 {}\nexport class LineExtLayoutArray extends StructArrayLayout2f8 {}\nexport class PatternLayoutArray extends StructArrayLayout10ui20 {}\nexport class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 {}\nexport class SymbolDynamicLayoutArray extends StructArrayLayout3f12 {}\nexport class SymbolOpacityArray extends StructArrayLayout1ul4 {}\nexport class CollisionBoxLayoutArray extends StructArrayLayout2i2i2i12 {}\nexport class CollisionCircleLayoutArray extends StructArrayLayout2f1f2i16 {}\nexport class CollisionVertexArray extends StructArrayLayout2ub2f12 {}\nexport class QuadTriangleArray extends StructArrayLayout3ui6 {}\nexport class TriangleIndexArray extends StructArrayLayout3ui6 {}\nexport class LineIndexArray extends StructArrayLayout2ui4 {}\nexport class LineStripIndexArray extends StructArrayLayout1ui2 {}\nexport {\n StructArrayLayout2i4,\n StructArrayLayout3i6,\n StructArrayLayout4i8,\n StructArrayLayout2i4i12,\n StructArrayLayout2i4ub8,\n StructArrayLayout2f8,\n StructArrayLayout10ui20,\n StructArrayLayout4i4ui4i24,\n StructArrayLayout3f12,\n StructArrayLayout1ul4,\n StructArrayLayout6i1ul2ui20,\n StructArrayLayout2i2i2i12,\n StructArrayLayout2f1f2i16,\n StructArrayLayout2ub2f12,\n StructArrayLayout3ui6,\n StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48,\n StructArrayLayout8i15ui1ul2f2ui64,\n StructArrayLayout1f4,\n StructArrayLayout1ui2f12,\n StructArrayLayout1ul2ui8,\n StructArrayLayout2ui4,\n StructArrayLayout1ui2,\n StructArrayLayout4f16\n};\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","import {warnOnce} from '../util/util';\n\nimport {register} from '../util/web_worker_transfer';\n\nimport type {VertexArrayObject} from '../render/vertex_array_object';\nimport type {StructArray} from '../util/struct_array';\n\n/**\n * @internal\n * A single segment of a vector\n */\nexport type Segment = {\n sortKey?: number;\n vertexOffset: number;\n primitiveOffset: number;\n vertexLength: number;\n primitiveLength: number;\n vaos: {[_: string]: VertexArrayObject};\n};\n\n/**\n * @internal\n * Used for calculations on vector segments\n */\nexport class SegmentVector {\n static MAX_VERTEX_ARRAY_LENGTH: number;\n segments: Array;\n\n constructor(segments: Array = []) {\n this.segments = segments;\n }\n\n prepareSegment(\n numVertices: number,\n layoutVertexArray: StructArray,\n indexArray: StructArray,\n sortKey?: number\n ): Segment {\n let segment: Segment = this.segments[this.segments.length - 1];\n if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`);\n if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) {\n segment = ({\n vertexOffset: layoutVertexArray.length,\n primitiveOffset: indexArray.length,\n vertexLength: 0,\n primitiveLength: 0\n } as any);\n if (sortKey !== undefined) segment.sortKey = sortKey;\n this.segments.push(segment);\n }\n return segment;\n }\n\n get() {\n return this.segments;\n }\n\n destroy() {\n for (const segment of this.segments) {\n for (const k in segment.vaos) {\n segment.vaos[k].destroy();\n }\n }\n }\n\n static simpleSegment(\n vertexOffset: number,\n primitiveOffset: number,\n vertexLength: number,\n primitiveLength: number\n ): SegmentVector {\n return new SegmentVector([{\n vertexOffset,\n primitiveOffset,\n vertexLength,\n primitiveLength,\n vaos: {},\n sortKey: 0\n }]);\n }\n}\n\n/**\n * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit\n * addressing of vertex buffers.\n */\nSegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1;\n\nregister('SegmentVector', SegmentVector);\n","import {clamp} from '../util/util';\n\n/**\n * Packs two numbers, interpreted as 8-bit unsigned integers, into a single\n * float. Unpack them in the shader using the `unpack_float()` function,\n * defined in _prelude.vertex.glsl\n */\nexport function packUint8ToFloat(a: number, b: number) {\n // coerce a and b to 8-bit ints\n a = clamp(Math.floor(a), 0, 255);\n b = clamp(Math.floor(b), 0, 255);\n return 256 * a + b;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const patternAttributes = createLayout([\n // [tl.x, tl.y, br.x, br.y]\n {name: 'a_pattern_from', components: 4, type: 'Uint16'},\n {name: 'a_pattern_to', components: 4, type: 'Uint16'},\n {name: 'a_pixel_ratio_from', components: 1, type: 'Uint16'},\n {name: 'a_pixel_ratio_to', components: 1, type: 'Uint16'},\n]);\n","/**\n * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} key ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash \n */\n\nfunction murmurhash3_32_gc(key, seed) {\n\tvar remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;\n\t\n\tremainder = key.length & 3; // key.length % 4\n\tbytes = key.length - remainder;\n\th1 = seed;\n\tc1 = 0xcc9e2d51;\n\tc2 = 0x1b873593;\n\ti = 0;\n\t\n\twhile (i < bytes) {\n\t \tk1 = \n\t \t ((key.charCodeAt(i) & 0xff)) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 8) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 16) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 24);\n\t\t++i;\n\t\t\n\t\tk1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;\n\n\t\th1 ^= k1;\n h1 = (h1 << 13) | (h1 >>> 19);\n\t\th1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;\n\t\th1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));\n\t}\n\t\n\tk1 = 0;\n\t\n\tswitch (remainder) {\n\t\tcase 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;\n\t\tcase 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;\n\t\tcase 1: k1 ^= (key.charCodeAt(i) & 0xff);\n\t\t\n\t\tk1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;\n\t\th1 ^= k1;\n\t}\n\t\n\th1 ^= key.length;\n\n\th1 ^= h1 >>> 16;\n\th1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;\n\th1 ^= h1 >>> 13;\n\th1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;\n\th1 ^= h1 >>> 16;\n\n\treturn h1 >>> 0;\n}\n\nif(typeof module !== \"undefined\") {\n module.exports = murmurhash3_32_gc\n}","/**\n * JS Implementation of MurmurHash2\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} str ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash\n */\n\nfunction murmurhash2_32_gc(str, seed) {\n var\n l = str.length,\n h = seed ^ l,\n i = 0,\n k;\n \n while (l >= 4) {\n \tk = \n \t ((str.charCodeAt(i) & 0xff)) |\n \t ((str.charCodeAt(++i) & 0xff) << 8) |\n \t ((str.charCodeAt(++i) & 0xff) << 16) |\n \t ((str.charCodeAt(++i) & 0xff) << 24);\n \n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n k ^= k >>> 24;\n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\n\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;\n\n l -= 4;\n ++i;\n }\n \n switch (l) {\n case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n case 1: h ^= (str.charCodeAt(i) & 0xff);\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n }\n\n h ^= h >>> 13;\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n h ^= h >>> 15;\n\n return h >>> 0;\n}\n\nif(typeof module !== undefined) {\n module.exports = murmurhash2_32_gc\n}\n","var murmur3 = require(\"./murmurhash3_gc.js\")\nvar murmur2 = require(\"./murmurhash2_gc.js\")\n\nmodule.exports = murmur3\nmodule.exports.murmur3 = murmur3\nmodule.exports.murmur2 = murmur2\n","import murmur3 from 'murmurhash-js';\nimport {register} from '../util/web_worker_transfer';\n\ntype SerializedFeaturePositionMap = {\n ids: Float64Array;\n positions: Uint32Array;\n};\n\ntype FeaturePosition = {\n index: number;\n start: number;\n end: number;\n};\n\n// A transferable data structure that maps feature ids to their indices and buffer offsets\nexport class FeaturePositionMap {\n ids: Array;\n positions: Array;\n indexed: boolean;\n\n constructor() {\n this.ids = [];\n this.positions = [];\n this.indexed = false;\n }\n\n add(id: unknown, index: number, start: number, end: number) {\n this.ids.push(getNumericId(id));\n this.positions.push(index, start, end);\n }\n\n getPositions(id: unknown): Array {\n if (!this.indexed) throw new Error('Trying to get index, but feature positions are not indexed');\n\n const intId = getNumericId(id);\n\n // binary search for the first occurrence of id in this.ids;\n // relies on ids/positions being sorted by id, which happens in serialization\n let i = 0;\n let j = this.ids.length - 1;\n while (i < j) {\n const m = (i + j) >> 1;\n if (this.ids[m] >= intId) {\n j = m;\n } else {\n i = m + 1;\n }\n }\n const positions = [];\n while (this.ids[i] === intId) {\n const index = this.positions[3 * i];\n const start = this.positions[3 * i + 1];\n const end = this.positions[3 * i + 2];\n positions.push({index, start, end});\n i++;\n }\n return positions;\n }\n\n static serialize(map: FeaturePositionMap, transferables: Array): SerializedFeaturePositionMap {\n const ids = new Float64Array(map.ids);\n const positions = new Uint32Array(map.positions);\n\n sort(ids, positions, 0, ids.length - 1);\n\n if (transferables) {\n transferables.push(ids.buffer, positions.buffer);\n }\n\n return {ids, positions};\n }\n\n static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap {\n const map = new FeaturePositionMap();\n // after transferring, we only use these arrays statically (no pushes),\n // so TypedArray vs Array distinction that flow points out doesn't matter\n map.ids = (obj.ids as any);\n map.positions = (obj.positions as any);\n map.indexed = true;\n return map;\n }\n}\n\nfunction getNumericId(value: unknown) {\n const numValue = +value;\n if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) {\n return numValue;\n }\n return murmur3(String(value));\n}\n\n// custom quicksort that sorts ids, indices and offsets together (by ids)\n// uses Hoare partitioning & manual tail call optimization to avoid worst case scenarios\nfunction sort(ids, positions, left, right) {\n while (left < right) {\n const pivot = ids[(left + right) >> 1];\n let i = left - 1;\n let j = right + 1;\n\n while (true) {\n do i++; while (ids[i] < pivot);\n do j--; while (ids[j] > pivot);\n if (i >= j) break;\n swap(ids, i, j);\n swap(positions, 3 * i, 3 * j);\n swap(positions, 3 * i + 1, 3 * j + 1);\n swap(positions, 3 * i + 2, 3 * j + 2);\n }\n\n if (j - left < right - j) {\n sort(ids, positions, left, j);\n left = j + 1;\n } else {\n sort(ids, positions, j + 1, right);\n right = j;\n }\n }\n}\n\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nregister('FeaturePositionMap', FeaturePositionMap);\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Context} from '../gl/context';\nimport {mat4, vec2, vec3, vec4} from 'gl-matrix';\n\ntype $ObjMap any> = {\n [K in keyof T]: F extends (v: T[K]) => infer R ? R : never;\n};\n\nexport type UniformValues = $ObjMap(u: Uniform) => V>;\nexport type UniformLocations = {[_: string]: WebGLUniformLocation};\n\n/**\n * @internal\n * A base uniform abstract class\n */\nabstract class Uniform {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n location: WebGLUniformLocation;\n current: T;\n\n constructor(context: Context, location: WebGLUniformLocation) {\n this.gl = context.gl;\n this.location = location;\n }\n\n abstract set(v: T): void;\n}\n\nclass Uniform1i extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1i(this.location, v);\n }\n }\n}\n\nclass Uniform1f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1f(this.location, v);\n }\n }\n}\n\nclass Uniform2f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0];\n }\n\n set(v: vec2): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1]) {\n this.current = v;\n this.gl.uniform2f(this.location, v[0], v[1]);\n }\n }\n}\n\nclass Uniform3f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0];\n }\n\n set(v: vec3): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) {\n this.current = v;\n this.gl.uniform3f(this.location, v[0], v[1], v[2]);\n }\n }\n}\n\nclass Uniform4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0, 0];\n }\n\n set(v: vec4): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] ||\n v[2] !== this.current[2] || v[3] !== this.current[3]) {\n this.current = v;\n this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]);\n }\n }\n}\n\nclass UniformColor extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = Color.transparent;\n }\n\n set(v: Color): void {\n if (v.r !== this.current.r || v.g !== this.current.g ||\n v.b !== this.current.b || v.a !== this.current.a) {\n this.current = v;\n this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a);\n }\n }\n}\n\nconst emptyMat4 = new Float32Array(16) as mat4;\nclass UniformMatrix4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = emptyMat4;\n }\n\n set(v: mat4): void {\n // The vast majority of matrix comparisons that will trip this set\n // happen at i=12 or i=0, so we check those first to avoid lots of\n // unnecessary iteration:\n if (v[12] !== this.current[12] || v[0] !== this.current[0]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n return;\n }\n for (let i = 1; i < 16; i++) {\n if (v[i] !== this.current[i]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n break;\n }\n }\n }\n}\n\nexport {\n Uniform,\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n Uniform4f,\n UniformColor,\n UniformMatrix4f\n};\n\n/**\n * @internal\n * A uniform bindings\n */\nexport type UniformBindings = {[_: string]: Uniform};\n","import {packUint8ToFloat} from '../shaders/encode_attribute';\nimport {Color, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types.g';\nimport {clamp} from '../util/util';\nimport {patternAttributes} from './bucket/pattern_attributes';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {FeaturePositionMap} from './feature_position_map';\nimport {Uniform, Uniform1f, UniformColor, Uniform4f} from '../render/uniform_binding';\n\nimport type {UniformLocations} from '../render/uniform_binding';\n\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Context} from '../gl/context';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {CrossfadeParameters} from '../style/evaluation_parameters';\nimport type {StructArray, StructArrayMember} from '../util/struct_array';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {\n Feature,\n FeatureState,\n GlobalProperties,\n SourceExpression,\n CompositeExpression,\n FormattedSection\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureStates} from '../source/source_state';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type BinderUniform = {\n name: string;\n property: string;\n binding: Uniform;\n};\n\nfunction packColor(color: Color): [number, number] {\n return [\n packUint8ToFloat(255 * color.r, 255 * color.g),\n packUint8ToFloat(255 * color.b, 255 * color.a)\n ];\n}\n\n/**\n * `Binder` is the interface definition for the strategies for constructing,\n * uploading, and binding paint property data as GLSL attributes. Most style-\n * spec properties have a 1:1 relationship to shader attribute/uniforms, but\n * some require multiple values per feature to be passed to the GPU, and in\n * those cases we bind multiple attributes/uniforms.\n *\n * It has three implementations, one for each of the three strategies we use:\n *\n * * For _constant_ properties -- those whose value is a constant, or the constant\n * result of evaluating a camera expression at a particular camera position -- we\n * don't need a vertex attribute buffer, and instead use a uniform.\n * * For data expressions, we use a vertex buffer with a single attribute value,\n * the evaluated result of the source function for the given feature.\n * * For composite expressions, we use a vertex buffer with two attributes: min and\n * max values covering the range of zooms at which we expect the tile to be\n * displayed. These values are calculated by evaluating the composite expression for\n * the given feature at strategically chosen zoom levels. In addition to this\n * attribute data, we also use a uniform value which the shader uses to interpolate\n * between the min and max value at the final displayed zoom level. The use of a\n * uniform allows us to cheaply update the value on every frame.\n *\n * Note that the shader source varies depending on whether we're using a uniform or\n * attribute. We dynamically compile shaders at runtime to accommodate this.\n */\ninterface AttributeBinder {\n populatePaintArray(\n length: number,\n feature: Feature,\n imagePositions: {[_: string]: ImagePosition},\n canonical?: CanonicalTileID,\n formattedSection?: FormattedSection\n ): void;\n updatePaintArray(\n start: number,\n length: number,\n feature: Feature,\n featureState: FeatureState,\n imagePositions: {[_: string]: ImagePosition}\n ): void;\n upload(a: Context): void;\n destroy(): void;\n}\n\ninterface UniformBinder {\n uniformNames: Array;\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue,\n uniformName: string\n ): void;\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial>;\n}\n\nclass ConstantBinder implements UniformBinder {\n value: unknown;\n type: string;\n uniformNames: Array;\n\n constructor(value: unknown, names: Array, type: string) {\n this.value = value;\n this.uniformNames = names.map(name => `u_${name}`);\n this.type = type;\n }\n\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue\n ): void {\n uniform.set(currentValue.constantOr(this.value));\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Partial> {\n return (this.type === 'color') ?\n new UniformColor(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedConstantBinder implements UniformBinder {\n uniformNames: Array;\n patternFrom: Array;\n patternTo: Array;\n pixelRatioFrom: number;\n pixelRatioTo: number;\n\n constructor(value: unknown, names: Array) {\n this.uniformNames = names.map(name => `u_${name}`);\n this.patternFrom = null;\n this.patternTo = null;\n this.pixelRatioFrom = 1.0;\n this.pixelRatioTo = 1.0;\n }\n\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n this.pixelRatioFrom = posFrom.pixelRatio;\n this.pixelRatioTo = posTo.pixelRatio;\n this.patternFrom = posFrom.tlbr;\n this.patternTo = posTo.tlbr;\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties, currentValue: PossiblyEvaluatedPropertyValue, uniformName: string) {\n const pos =\n uniformName === 'u_pattern_to' ? this.patternTo :\n uniformName === 'u_pattern_from' ? this.patternFrom :\n uniformName === 'u_pixel_ratio_to' ? this.pixelRatioTo :\n uniformName === 'u_pixel_ratio_from' ? this.pixelRatioFrom : null;\n if (pos) uniform.set(pos);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial> {\n return name.substr(0, 9) === 'u_pattern' ?\n new Uniform4f(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass SourceExpressionBinder implements AttributeBinder {\n expression: SourceExpression;\n type: string;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: SourceExpression, names: Array, type: string, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.type = type;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 2 : 1,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const start = this.paintVertexArray.length;\n const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection);\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, value);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const value = this.expression.evaluate({zoom: 0}, feature, featureState);\n this._setPaintValue(start, end, value);\n }\n\n _setPaintValue(start, end, value) {\n if (this.type === 'color') {\n const color = packColor(value);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, color[0], color[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, value);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(value));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n}\n\nclass CompositeExpressionBinder implements AttributeBinder, UniformBinder {\n expression: CompositeExpression;\n uniformNames: Array;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: CompositeExpression, names: Array, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.uniformNames = names.map(name => `u_${name}_t`);\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 4 : 2,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection);\n const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection);\n const start = this.paintVertexArray.length;\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, min, max);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const min = this.expression.evaluate({zoom: this.zoom}, feature, featureState);\n const max = this.expression.evaluate({zoom: this.zoom + 1}, feature, featureState);\n this._setPaintValue(start, end, min, max);\n }\n\n _setPaintValue(start, end, min, max) {\n if (this.type === 'color') {\n const minColor = packColor(min);\n const maxColor = packColor(max);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, min, max);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties): void {\n const currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom;\n const factor = clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1);\n uniform.set(factor);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Uniform1f {\n return new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedCompositeBinder implements AttributeBinder {\n expression: CompositeExpression;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n layerId: string;\n\n zoomInPaintVertexArray: StructArray;\n zoomOutPaintVertexArray: StructArray;\n zoomInPaintVertexBuffer: VertexBuffer;\n zoomOutPaintVertexBuffer: VertexBuffer;\n paintVertexAttributes: Array;\n\n constructor(expression: CompositeExpression, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }, layerId: string) {\n this.expression = expression;\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.layerId = layerId;\n\n this.zoomInPaintVertexArray = new PaintVertexArray();\n this.zoomOutPaintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}) {\n const start = this.zoomInPaintVertexArray.length;\n this.zoomInPaintVertexArray.resize(length);\n this.zoomOutPaintVertexArray.resize(length);\n this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}) {\n this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n _setPaintValues(start, end, patterns, positions) {\n if (!positions || !patterns) return;\n\n const {min, mid, max} = patterns;\n const imageMin = positions[min];\n const imageMid = positions[mid];\n const imageMax = positions[max];\n if (!imageMin || !imageMid || !imageMax) return;\n\n // We populate two paint arrays because, for cross-faded properties, we don't know which direction\n // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass\n // unnecessary vertex data to the shaders, we determine which to upload at draw time.\n for (let i = start; i < end; i++) {\n this.zoomInPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1],\n imageMid.pixelRatio,\n imageMin.pixelRatio,\n );\n this.zoomOutPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1],\n imageMid.pixelRatio,\n imageMax.pixelRatio,\n );\n }\n }\n\n upload(context: Context) {\n if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) {\n this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n }\n }\n\n destroy() {\n if (this.zoomOutPaintVertexBuffer) this.zoomOutPaintVertexBuffer.destroy();\n if (this.zoomInPaintVertexBuffer) this.zoomInPaintVertexBuffer.destroy();\n }\n}\n\n/**\n * @internal\n * ProgramConfiguration contains the logic for binding style layer properties and tile\n * layer feature data into GL program uniforms and vertex attributes.\n *\n * Non-data-driven property values are bound to shader uniforms. Data-driven property\n * values are bound to vertex attributes. In order to support a uniform GLSL syntax over\n * both, [Mapbox GL Shaders](https://github.com/mapbox/mapbox-gl-shaders) defines a `#pragma`\n * abstraction, which ProgramConfiguration is responsible for implementing. At runtime,\n * it examines the attributes of a particular layer, combines this with fixed knowledge\n * about how layers of the particular type are implemented, and determines which uniforms\n * and vertex attributes will be required. It can then substitute the appropriate text\n * into the shader source code, create and link a program, and bind the uniforms and\n * vertex attributes in preparation for drawing.\n *\n * When a vector tile is parsed, this same configuration information is used to\n * populate the attribute buffers needed for data-driven styling using the zoom\n * level and feature property data.\n */\nexport class ProgramConfiguration {\n binders: {[_: string]: AttributeBinder | UniformBinder};\n cacheKey: string;\n\n _buffers: Array;\n\n constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean) {\n this.binders = {};\n this._buffers = [];\n\n const keys = [];\n\n for (const property in layer.paint._values) {\n if (!filterProperties(property)) continue;\n const value = (layer.paint as any).get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n const names = paintAttributeNames(property, layer.type);\n const expression = value.value;\n const type = value.property.specification.type;\n const useIntegerZoom = (value.property as any).useIntegerZoom;\n const propType = value.property.specification['property-type'];\n const isCrossFaded = propType === 'cross-faded' || propType === 'cross-faded-data-driven';\n\n if (expression.kind === 'constant') {\n this.binders[property] = isCrossFaded ?\n new CrossFadedConstantBinder(expression.value, names) :\n new ConstantBinder(expression.value, names, type);\n keys.push(`/u_${property}`);\n\n } else if (expression.kind === 'source' || isCrossFaded) {\n const StructArrayLayout = layoutType(property, type, 'source');\n this.binders[property] = isCrossFaded ?\n new CrossFadedCompositeBinder(expression as CompositeExpression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) :\n new SourceExpressionBinder(expression as SourceExpression, names, type, StructArrayLayout);\n keys.push(`/a_${property}`);\n\n } else {\n const StructArrayLayout = layoutType(property, type, 'composite');\n this.binders[property] = new CompositeExpressionBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout);\n keys.push(`/z_${property}`);\n }\n }\n\n this.cacheKey = keys.sort().join('');\n }\n\n getMaxValue(property: string): number {\n const binder = this.binders[property];\n return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0;\n }\n\n populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n (binder as AttributeBinder).populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection);\n }\n }\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof CrossFadedConstantBinder)\n binder.setConstantPatternPositions(posTo, posFrom);\n }\n }\n\n updatePaintArrays(\n featureStates: FeatureStates,\n featureMap: FeaturePositionMap,\n vtLayer: VectorTileLayer,\n layer: TypedStyleLayer,\n imagePositions: {[_: string]: ImagePosition}\n ): boolean {\n let dirty: boolean = false;\n for (const id in featureStates) {\n const positions = featureMap.getPositions(id);\n\n for (const pos of positions) {\n const feature = vtLayer.feature(pos.index);\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ||\n binder instanceof CrossFadedCompositeBinder) && (binder as any).expression.isStateDependent === true) {\n //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255\n const value = (layer.paint as any).get(property);\n (binder as any).expression = value.value;\n (binder as AttributeBinder).updatePaintArray(pos.start, pos.end, feature, featureStates[id], imagePositions);\n dirty = true;\n }\n }\n }\n }\n return dirty;\n }\n\n defines(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {\n result.push(...binder.uniformNames.map(name => `#define HAS_UNIFORM_${name}`));\n }\n }\n return result;\n }\n\n getBinderAttributes(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) {\n for (let i = 0; i < binder.paintVertexAttributes.length; i++) {\n result.push(binder.paintVertexAttributes[i].name);\n }\n } else if (binder instanceof CrossFadedCompositeBinder) {\n for (let i = 0; i < patternAttributes.members.length; i++) {\n result.push(patternAttributes.members[i].name);\n }\n }\n }\n return result;\n }\n\n getBinderUniforms(): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const uniformName of binder.uniformNames) {\n uniforms.push(uniformName);\n }\n }\n }\n return uniforms;\n }\n\n getPaintVertexBuffers(): Array {\n return this._buffers;\n }\n\n getUniforms(context: Context, locations: UniformLocations): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const name of binder.uniformNames) {\n if (locations[name]) {\n const binding = binder.getBinding(context, locations[name], name);\n uniforms.push({name, property, binding});\n }\n }\n }\n }\n return uniforms;\n }\n\n setUniforms(\n context: Context,\n binderUniforms: Array,\n properties: any,\n globals: GlobalProperties\n ) {\n // Uniform state bindings are owned by the Program, but we set them\n // from within the ProgramConfiguraton's binder members.\n for (const {name, property, binding} of binderUniforms) {\n (this.binders[property] as any).setUniform(binding, globals, properties.get(property), name);\n }\n }\n\n updatePaintBuffers(crossfade?: CrossfadeParameters) {\n this._buffers = [];\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (crossfade && binder instanceof CrossFadedCompositeBinder) {\n const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;\n if (patternVertexBuffer) this._buffers.push(patternVertexBuffer);\n\n } else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) {\n this._buffers.push(binder.paintVertexBuffer);\n }\n }\n }\n\n upload(context: Context) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.upload(context);\n }\n this.updatePaintBuffers();\n }\n\n destroy() {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.destroy();\n }\n }\n}\n\nexport class ProgramConfigurationSet {\n programConfigurations: {[_: string]: ProgramConfiguration};\n needsUpload: boolean;\n _featureMap: FeaturePositionMap;\n _bufferOffset: number;\n\n constructor(layers: ReadonlyArray, zoom: number, filterProperties: (_: string) => boolean = () => true) {\n this.programConfigurations = {};\n for (const layer of layers) {\n this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties);\n }\n this.needsUpload = false;\n this._featureMap = new FeaturePositionMap();\n this._bufferOffset = 0;\n }\n\n populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[_: string]: ImagePosition}, canonical: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const key in this.programConfigurations) {\n this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection);\n }\n\n if (feature.id !== undefined) {\n this._featureMap.add(feature.id, index, this._bufferOffset, length);\n }\n this._bufferOffset = length;\n\n this.needsUpload = true;\n }\n\n updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: ReadonlyArray, imagePositions: {[_: string]: ImagePosition}) {\n for (const layer of layers) {\n this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload;\n }\n }\n\n get(layerId: string) {\n return this.programConfigurations[layerId];\n }\n\n upload(context: Context) {\n if (!this.needsUpload) return;\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].upload(context);\n }\n this.needsUpload = false;\n }\n\n destroy() {\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].destroy();\n }\n }\n}\n\nfunction paintAttributeNames(property, type) {\n const attributeNameExceptions = {\n 'text-opacity': ['opacity'],\n 'icon-opacity': ['opacity'],\n 'text-color': ['fill_color'],\n 'icon-color': ['fill_color'],\n 'text-halo-color': ['halo_color'],\n 'icon-halo-color': ['halo_color'],\n 'text-halo-blur': ['halo_blur'],\n 'icon-halo-blur': ['halo_blur'],\n 'text-halo-width': ['halo_width'],\n 'icon-halo-width': ['halo_width'],\n 'line-gap-width': ['gapwidth'],\n 'line-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-extrusion-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n };\n\n return attributeNameExceptions[property] || [property.replace(`${type}-`, '').replace(/-/g, '_')];\n}\n\nfunction getLayoutException(property) {\n const propertyExceptions = {\n 'line-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-extrusion-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n }\n };\n\n return propertyExceptions[property];\n}\n\nfunction layoutType(property, type, binderType) {\n const defaultLayouts = {\n 'color': {\n 'source': StructArrayLayout2f8,\n 'composite': StructArrayLayout4f16\n },\n 'number': {\n 'source': StructArrayLayout1f4,\n 'composite': StructArrayLayout2f8\n }\n };\n\n const layoutException = getLayoutException(property);\n return layoutException && layoutException[binderType] || defaultLayouts[type][binderType];\n}\n\nregister('ConstantBinder', ConstantBinder);\nregister('CrossFadedConstantBinder', CrossFadedConstantBinder);\nregister('SourceExpressionBinder', SourceExpressionBinder);\nregister('CrossFadedCompositeBinder', CrossFadedCompositeBinder);\nregister('CompositeExpressionBinder', CompositeExpressionBinder);\nregister('ProgramConfiguration', ProgramConfiguration, {omit: ['_buffers']});\nregister('ProgramConfigurationSet', ProgramConfigurationSet);\n","/**\n * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of\n * all source features normalized to this extent upon load.\n *\n * The value is a consequence of the following:\n *\n * * Vertex buffer store positions as signed 16 bit integers.\n * * One bit is lost for signedness to support tile buffers.\n * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.\n * * One bit is lost to support features extending past the extent on the right edge of the tile.\n * * This leaves us with 2^13 = 8192\n */\nexport const EXTENT = 8192;\n","import {warnOnce, clamp} from '../util/util';\n\nimport {EXTENT} from './extent';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n// These bounds define the minimum and maximum supported coordinate values.\n// While visible coordinates are within [0, EXTENT], tiles may theoretically\n// contain coordinates within [-Infinity, Infinity]. Our range is limited by the\n// number of bits used to represent the coordinate.\nconst BITS = 15;\nconst MAX = Math.pow(2, BITS - 1) - 1;\nconst MIN = -MAX - 1;\n\n/**\n * Loads a geometry from a VectorTileFeature and scales it to the common extent\n * used internally.\n * @param feature - the vector tile feature to load\n */\nexport function loadGeometry(feature: VectorTileFeature): Array> {\n const scale = EXTENT / feature.extent;\n const geometry = feature.loadGeometry();\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n for (let p = 0; p < ring.length; p++) {\n const point = ring[p];\n // round here because mapbox-gl-native uses integers to represent\n // points and we need to do the same to avoid renering differences.\n const x = Math.round(point.x * scale);\n const y = Math.round(point.y * scale);\n\n point.x = clamp(x, MIN, MAX);\n point.y = clamp(y, MIN, MAX);\n\n if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) {\n // warn when exceeding allowed extent except for the 1-px-off case\n // https://github.com/mapbox/mapbox-gl-js/issues/8992\n warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size');\n }\n }\n }\n return geometry;\n}\n","import {loadGeometry} from './load_geometry';\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\n\ntype EvaluationFeature = Feature & { geometry: Array> };\n/**\n * Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which\n * will be loaded based on necessity.\n * @param feature - the feature to evaluate\n * @param needGeometry - if set to true this will load the geometry\n */\nexport function toEvaluationFeature(feature: VectorTileFeature, needGeometry: boolean): EvaluationFeature {\n return {type: feature.type,\n id: feature.id,\n properties: feature.properties,\n geometry: needGeometry ? loadGeometry(feature) : []};\n}\n","import {CircleLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './circle_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EXTENT} from '../extent';\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nfunction addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {\n layoutVertexArray.emplaceBack(\n (x * 2) + ((extrudeX + 1) / 2),\n (y * 2) + ((extrudeY + 1) / 2));\n}\n\n/**\n * @internal\n * Circles are represented by two triangles.\n *\n * Each corner has a pos that is the center of the circle and an extrusion\n * vector that is where it points.\n */\nexport class CircleBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layerIds: Array;\n layers: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: CircleLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new CircleLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.segments = new SegmentVector();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const styleLayer = this.layers[0];\n const bucketFeatures: BucketFeature[] = [];\n let circleSortKey = null;\n let sortFeaturesByKey = false;\n\n // Heatmap layers are handled in this bucket and have no evaluated properties, so we check our access\n if (styleLayer.type === 'circle') {\n circleSortKey = (styleLayer as CircleStyleLayer).layout.get('circle-sort-key');\n sortFeaturesByKey = !circleSortKey.isConstant();\n }\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n circleSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n const feature = features[index].feature;\n\n this.addFeature(bucketFeature, geometry, index, canonical);\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID) {\n for (const ring of geometry) {\n for (const point of ring) {\n const x = point.x;\n const y = point.y;\n\n // Do not include points that are outside the tile boundaries.\n if (x < 0 || x >= EXTENT || y < 0 || y >= EXTENT) continue;\n\n // this geometry will be of the Point type, and we'll derive\n // two triangles from it.\n //\n // ┌─────────┐\n // │ 3 2 │\n // │ │\n // │ 0 1 │\n // └─────────┘\n\n const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey);\n const index = segment.vertexLength;\n\n addCircleVertex(this.layoutVertexArray, x, y, -1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, 1);\n addCircleVertex(this.layoutVertexArray, x, y, -1, 1);\n\n this.indexArray.emplaceBack(index, index + 1, index + 2);\n this.indexArray.emplaceBack(index, index + 3, index + 2);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical);\n }\n}\n\nregister('CircleBucket', CircleBucket, {omit: ['layers']});\n","import {isCounterClockwise} from './util';\n\nimport Point from '@mapbox/point-geometry';\n\nexport {polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox};\n\ntype Line = Array;\ntype MultiLine = Array;\ntype Ring = Array;\ntype Polygon = Array;\ntype MultiPolygon = Array;\n\nfunction polygonIntersectsPolygon(polygonA: Polygon, polygonB: Polygon) {\n for (let i = 0; i < polygonA.length; i++) {\n if (polygonContainsPoint(polygonB, polygonA[i])) return true;\n }\n\n for (let i = 0; i < polygonB.length; i++) {\n if (polygonContainsPoint(polygonA, polygonB[i])) return true;\n }\n\n if (lineIntersectsLine(polygonA, polygonB)) return true;\n\n return false;\n}\n\nfunction polygonIntersectsBufferedPoint(polygon: Polygon, point: Point, radius: number) {\n if (polygonContainsPoint(polygon, point)) return true;\n if (pointIntersectsBufferedLine(point, polygon, radius)) return true;\n return false;\n}\n\nfunction polygonIntersectsMultiPolygon(polygon: Polygon, multiPolygon: MultiPolygon) {\n\n if (polygon.length === 1) {\n return multiPolygonContainsPoint(multiPolygon, polygon[0]);\n }\n\n for (let m = 0; m < multiPolygon.length; m++) {\n const ring = multiPolygon[m];\n for (let n = 0; n < ring.length; n++) {\n if (polygonContainsPoint(polygon, ring[n])) return true;\n }\n }\n\n for (let i = 0; i < polygon.length; i++) {\n if (multiPolygonContainsPoint(multiPolygon, polygon[i])) return true;\n }\n\n for (let k = 0; k < multiPolygon.length; k++) {\n if (lineIntersectsLine(polygon, multiPolygon[k])) return true;\n }\n\n return false;\n}\n\nfunction polygonIntersectsBufferedMultiLine(polygon: Polygon, multiLine: MultiLine, radius: number) {\n for (let i = 0; i < multiLine.length; i++) {\n const line = multiLine[i];\n\n if (polygon.length >= 3) {\n for (let k = 0; k < line.length; k++) {\n if (polygonContainsPoint(polygon, line[k])) return true;\n }\n }\n\n if (lineIntersectsBufferedLine(polygon, line, radius)) return true;\n }\n return false;\n}\n\nfunction lineIntersectsBufferedLine(lineA: Line, lineB: Line, radius: number) {\n\n if (lineA.length > 1) {\n if (lineIntersectsLine(lineA, lineB)) return true;\n\n // Check whether any point in either line is within radius of the other line\n for (let j = 0; j < lineB.length; j++) {\n if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) return true;\n }\n }\n\n for (let k = 0; k < lineA.length; k++) {\n if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) return true;\n }\n\n return false;\n}\n\nfunction lineIntersectsLine(lineA: Line, lineB: Line) {\n if (lineA.length === 0 || lineB.length === 0) return false;\n for (let i = 0; i < lineA.length - 1; i++) {\n const a0 = lineA[i];\n const a1 = lineA[i + 1];\n for (let j = 0; j < lineB.length - 1; j++) {\n const b0 = lineB[j];\n const b1 = lineB[j + 1];\n if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) return true;\n }\n }\n return false;\n}\n\nfunction lineSegmentIntersectsLineSegment(a0: Point, a1: Point, b0: Point, b1: Point) {\n return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) &&\n isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1);\n}\n\nfunction pointIntersectsBufferedLine(p: Point, line: Line, radius: number) {\n const radiusSquared = radius * radius;\n\n if (line.length === 1) return p.distSqr(line[0]) < radiusSquared;\n\n for (let i = 1; i < line.length; i++) {\n // Find line segments that have a distance <= radius^2 to p\n // In that case, we treat the line as \"containing point p\".\n const v = line[i - 1], w = line[i];\n if (distToSegmentSquared(p, v, w) < radiusSquared) return true;\n }\n return false;\n}\n\n// Code from http://stackoverflow.com/a/1501725/331379.\nfunction distToSegmentSquared(p: Point, v: Point, w: Point) {\n const l2 = v.distSqr(w);\n if (l2 === 0) return p.distSqr(v);\n const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;\n if (t < 0) return p.distSqr(v);\n if (t > 1) return p.distSqr(w);\n return p.distSqr(w.sub(v)._mult(t)._add(v));\n}\n\n// point in polygon ray casting algorithm\nfunction multiPolygonContainsPoint(rings: Array, p: Point) {\n let c = false,\n ring, p1, p2;\n\n for (let k = 0; k < rings.length; k++) {\n ring = rings[k];\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n }\n return c;\n}\n\nfunction polygonContainsPoint(ring: Ring, p: Point) {\n let c = false;\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const p1 = ring[i];\n const p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n return c;\n}\n\nfunction polygonIntersectsBox(ring: Ring, boxX1: number, boxY1: number, boxX2: number, boxY2: number) {\n for (const p of ring) {\n if (boxX1 <= p.x &&\n boxY1 <= p.y &&\n boxX2 >= p.x &&\n boxY2 >= p.y) return true;\n }\n\n const corners = [\n new Point(boxX1, boxY1),\n new Point(boxX1, boxY2),\n new Point(boxX2, boxY2),\n new Point(boxX2, boxY1)];\n\n if (ring.length > 2) {\n for (const corner of corners) {\n if (polygonContainsPoint(ring, corner)) return true;\n }\n }\n\n for (let i = 0; i < ring.length - 1; i++) {\n const p1 = ring[i];\n const p2 = ring[i + 1];\n if (edgeIntersectsBox(p1, p2, corners)) return true;\n }\n\n return false;\n}\n\nfunction edgeIntersectsBox(e1: Point, e2: Point, corners: Array) {\n const tl = corners[0];\n const br = corners[2];\n // the edge and box do not intersect in either the x or y dimensions\n if (((e1.x < tl.x) && (e2.x < tl.x)) ||\n ((e1.x > br.x) && (e2.x > br.x)) ||\n ((e1.y < tl.y) && (e2.y < tl.y)) ||\n ((e1.y > br.y) && (e2.y > br.y))) return false;\n\n // check if all corners of the box are on the same side of the edge\n const dir = isCounterClockwise(e1, e2, corners[0]);\n return dir !== isCounterClockwise(e1, e2, corners[1]) ||\n dir !== isCounterClockwise(e1, e2, corners[2]) ||\n dir !== isCounterClockwise(e1, e2, corners[3]);\n}\n","import Point from '@mapbox/point-geometry';\n\nimport type {PossiblyEvaluatedPropertyValue} from './properties';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {LineBucket} from '../data/bucket/line_bucket';\n\nexport function getMaximumPaintValue(\n property: string,\n layer: StyleLayer,\n bucket: CircleBucket | LineBucket\n): number {\n const value = ((layer.paint as any).get(property) as PossiblyEvaluatedPropertyValue).value;\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return bucket.programConfigurations.get(layer.id).getMaxValue(property);\n }\n}\n\nexport function translateDistance(translate: [number, number]) {\n return Math.sqrt(translate[0] * translate[0] + translate[1] * translate[1]);\n}\n\nexport function translate(queryGeometry: Array,\n translate: [number, number],\n translateAnchor: 'viewport' | 'map',\n bearing: number,\n pixelsToTileUnits: number) {\n if (!translate[0] && !translate[1]) {\n return queryGeometry;\n }\n const pt = Point.convert(translate)._mult(pixelsToTileUnits);\n\n if (translateAnchor === 'viewport') {\n pt._rotate(-bearing);\n }\n\n const translated = [];\n for (let i = 0; i < queryGeometry.length; i++) {\n const point = queryGeometry[i];\n translated.push(point.sub(pt));\n }\n return translated;\n}\n\nexport function offsetLine(rings: Array>, offset: number) {\n const newRings: Array> = [];\n for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {\n const ring = rings[ringIndex];\n const newRing: Array = [];\n for (let index = 0; index < ring.length; index++) {\n const a = ring[index - 1];\n const b = ring[index];\n const c = ring[index + 1];\n const aToB = index === 0 ? new Point(0, 0) : b.sub(a)._unit()._perp();\n const bToC = index === ring.length - 1 ? new Point(0, 0) : c.sub(b)._unit()._perp();\n const extrude = aToB._add(bToC)._unit();\n\n const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;\n if (cosHalfAngle !== 0) {\n extrude._mult(1 / cosHalfAngle);\n }\n\n newRing.push(extrude._mult(offset)._add(b));\n }\n newRings.push(newRing);\n }\n return newRings;\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CircleLayoutProps = {\n \"circle-sort-key\": DataDrivenProperty,\n};\n\nexport type CircleLayoutPropsPossiblyEvaluated = {\n \"circle-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"circle-sort-key\": new DataDrivenProperty(styleSpec[\"layout_circle\"][\"circle-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type CirclePaintProps = {\n \"circle-radius\": DataDrivenProperty,\n \"circle-color\": DataDrivenProperty,\n \"circle-blur\": DataDrivenProperty,\n \"circle-opacity\": DataDrivenProperty,\n \"circle-translate\": DataConstantProperty<[number, number]>,\n \"circle-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-scale\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-stroke-width\": DataDrivenProperty,\n \"circle-stroke-color\": DataDrivenProperty,\n \"circle-stroke-opacity\": DataDrivenProperty,\n};\n\nexport type CirclePaintPropsPossiblyEvaluated = {\n \"circle-radius\": PossiblyEvaluatedPropertyValue,\n \"circle-color\": PossiblyEvaluatedPropertyValue,\n \"circle-blur\": PossiblyEvaluatedPropertyValue,\n \"circle-opacity\": PossiblyEvaluatedPropertyValue,\n \"circle-translate\": [number, number],\n \"circle-translate-anchor\": \"map\" | \"viewport\",\n \"circle-pitch-scale\": \"map\" | \"viewport\",\n \"circle-pitch-alignment\": \"map\" | \"viewport\",\n \"circle-stroke-width\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-color\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-opacity\": PossiblyEvaluatedPropertyValue,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"circle-radius\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-radius\"] as any as StylePropertySpecification),\n \"circle-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-color\"] as any as StylePropertySpecification),\n \"circle-blur\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-blur\"] as any as StylePropertySpecification),\n \"circle-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-opacity\"] as any as StylePropertySpecification),\n \"circle-translate\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate\"] as any as StylePropertySpecification),\n \"circle-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate-anchor\"] as any as StylePropertySpecification),\n \"circle-pitch-scale\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-scale\"] as any as StylePropertySpecification),\n \"circle-pitch-alignment\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-alignment\"] as any as StylePropertySpecification),\n \"circle-stroke-width\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-width\"] as any as StylePropertySpecification),\n \"circle-stroke-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-color\"] as any as StylePropertySpecification),\n \"circle-stroke-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import * as glMatrix from \"./common.js\";\n/**\n * 4 Dimensional Vector\n * @module vec4\n */\n\n/**\n * Creates a new, empty vec4\n *\n * @returns {vec4} a new 4D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec4 initialized with values from an existing vector\n *\n * @param {ReadonlyVec4} a vector to clone\n * @returns {vec4} a new 4D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Creates a new vec4 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} a new 4D vector\n */\n\nexport function fromValues(x, y, z, w) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Copy the values from one vec4 to another\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the source vector\n * @returns {vec4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to the given values\n *\n * @param {vec4} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} out\n */\n\nexport function set(out, x, y, z, w) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Adds two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Multiplies two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n out[3] = a[3] * b[3];\n return out;\n}\n/**\n * Divides two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n out[3] = a[3] / b[3];\n return out;\n}\n/**\n * Math.ceil the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to ceil\n * @returns {vec4} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n out[3] = Math.ceil(a[3]);\n return out;\n}\n/**\n * Math.floor the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to floor\n * @returns {vec4} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n out[3] = Math.floor(a[3]);\n return out;\n}\n/**\n * Returns the minimum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n out[3] = Math.min(a[3], b[3]);\n return out;\n}\n/**\n * Returns the maximum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n out[3] = Math.max(a[3], b[3]);\n return out;\n}\n/**\n * Math.round the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to round\n * @returns {vec4} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n out[3] = Math.round(a[3]);\n return out;\n}\n/**\n * Scales a vec4 by a scalar number\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec4} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two vec4's after scaling the second operand by a scalar value\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec4} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Calculates the length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Negates the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to negate\n * @returns {vec4} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = -a[3];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to invert\n * @returns {vec4} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n out[3] = 1.0 / a[3];\n return out;\n}\n/**\n * Normalize a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to normalize\n * @returns {vec4} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n var len = x * x + y * y + z * z + w * w;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = x * len;\n out[1] = y * len;\n out[2] = z * len;\n out[3] = w * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n/**\n * Returns the cross-product of three vectors in a 4-dimensional space\n *\n * @param {ReadonlyVec4} result the receiving vector\n * @param {ReadonlyVec4} U the first vector\n * @param {ReadonlyVec4} V the second vector\n * @param {ReadonlyVec4} W the third vector\n * @returns {vec4} result\n */\n\nexport function cross(out, u, v, w) {\n var A = v[0] * w[1] - v[1] * w[0],\n B = v[0] * w[2] - v[2] * w[0],\n C = v[0] * w[3] - v[3] * w[0],\n D = v[1] * w[2] - v[2] * w[1],\n E = v[1] * w[3] - v[3] * w[1],\n F = v[2] * w[3] - v[3] * w[2];\n var G = u[0];\n var H = u[1];\n var I = u[2];\n var J = u[3];\n out[0] = H * F - I * E + J * D;\n out[1] = -(G * F) + I * C - J * B;\n out[2] = G * E - H * C + J * A;\n out[3] = -(G * D) + H * B - I * A;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec4} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n var aw = a[3];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n out[3] = aw + t * (b[3] - aw);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec4} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec4} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a\n // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.\n // http://projecteuclid.org/euclid.aoms/1177692644;\n\n var v1, v2, v3, v4;\n var s1, s2;\n\n do {\n v1 = glMatrix.RANDOM() * 2 - 1;\n v2 = glMatrix.RANDOM() * 2 - 1;\n s1 = v1 * v1 + v2 * v2;\n } while (s1 >= 1);\n\n do {\n v3 = glMatrix.RANDOM() * 2 - 1;\n v4 = glMatrix.RANDOM() * 2 - 1;\n s2 = v3 * v3 + v4 * v4;\n } while (s2 >= 1);\n\n var d = Math.sqrt((1 - s1) / s2);\n out[0] = scale * v1;\n out[1] = scale * v2;\n out[2] = scale * v3 * d;\n out[3] = scale * v4 * d;\n return out;\n}\n/**\n * Transforms the vec4 with a mat4.\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec4} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2],\n w = a[3];\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n return out;\n}\n/**\n * Transforms the vec4 with a quat\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec4} out\n */\n\nexport function transformQuat(out, a, q) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3]; // calculate quat * vec\n\n var ix = qw * x + qy * z - qz * y;\n var iy = qw * y + qz * x - qx * z;\n var iz = qw * z + qx * y - qy * x;\n var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat\n\n out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to zero\n *\n * @param {vec4} out the receiving vector\n * @returns {vec4} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec4} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Alias for {@link vec4.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec4.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec4.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec4.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec4.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec4.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec4s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 4;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n vec[3] = a[i + 3];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n a[i + 3] = vec[3];\n }\n\n return a;\n };\n}();","/**\n * Common utilities\n * @module glMatrix\n */\n// Configuration Constants\nexport var EPSILON = 0.000001;\nexport var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;\nexport var RANDOM = Math.random;\n/**\n * Sets the type of array used when creating new vectors and matrices\n *\n * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array\n */\n\nexport function setMatrixArrayType(type) {\n ARRAY_TYPE = type;\n}\nvar degree = Math.PI / 180;\n/**\n * Convert Degree To Radian\n *\n * @param {Number} a Angle in Degrees\n */\n\nexport function toRadian(a) {\n return a * degree;\n}\n/**\n * Tests whether or not the arguments have approximately the same value, within an absolute\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\n * than or equal to 1.0, and a relative tolerance is used for larger values)\n *\n * @param {Number} a The first number to test.\n * @param {Number} b The second number to test.\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\n */\n\nexport function equals(a, b) {\n return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));\n}\nif (!Math.hypot) Math.hypot = function () {\n var y = 0,\n i = arguments.length;\n\n while (i--) {\n y += arguments[i] * arguments[i];\n }\n\n return Math.sqrt(y);\n};","import * as glMatrix from \"./common.js\";\n/**\n * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.\n * @module mat4\n */\n\n/**\n * Creates a new identity mat4\n *\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(16);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n }\n\n out[0] = 1;\n out[5] = 1;\n out[10] = 1;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat4} a matrix to clone\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Copy the values from one mat4 to another\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Create a new mat4 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} A new mat4\n */\n\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set the components of a mat4 to the given values\n *\n * @param {mat4} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} out\n */\n\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set a mat4 to the identity matrix\n *\n * @param {mat4} out the receiving matrix\n * @returns {mat4} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a12 = a[6],\n a13 = a[7];\n var a23 = a[11];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a01;\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a02;\n out[9] = a12;\n out[11] = a[14];\n out[12] = a03;\n out[13] = a13;\n out[14] = a23;\n } else {\n out[0] = a[0];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a[1];\n out[5] = a[5];\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a[2];\n out[9] = a[6];\n out[10] = a[10];\n out[11] = a[14];\n out[12] = a[3];\n out[13] = a[7];\n out[14] = a[11];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Inverts a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22);\n out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\n out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12);\n out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\n out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\n out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22);\n out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\n out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12);\n out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21);\n out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\n out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11);\n out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\n out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\n out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21);\n out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\n out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11);\n return out;\n}\n/**\n * Calculates the determinant of a mat4\n *\n * @param {ReadonlyMat4} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n}\n/**\n * Multiplies two mat4s\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15]; // Cache only the current line of the second matrix\n\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[4];\n b1 = b[5];\n b2 = b[6];\n b3 = b[7];\n out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[8];\n b1 = b[9];\n b2 = b[10];\n b3 = b[11];\n out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[12];\n b1 = b[13];\n b2 = b[14];\n b3 = b[15];\n out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n return out;\n}\n/**\n * Translate a mat4 by the given vector\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to translate\n * @param {ReadonlyVec3} v vector to translate by\n * @returns {mat4} out\n */\n\nexport function translate(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n\n if (a === out) {\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n } else {\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a03;\n out[4] = a10;\n out[5] = a11;\n out[6] = a12;\n out[7] = a13;\n out[8] = a20;\n out[9] = a21;\n out[10] = a22;\n out[11] = a23;\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\n }\n\n return out;\n}\n/**\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {ReadonlyVec3} v the vec3 to scale the matrix by\n * @returns {mat4} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n out[0] = a[0] * x;\n out[1] = a[1] * x;\n out[2] = a[2] * x;\n out[3] = a[3] * x;\n out[4] = a[4] * y;\n out[5] = a[5] * y;\n out[6] = a[6] * y;\n out[7] = a[7] * y;\n out[8] = a[8] * z;\n out[9] = a[9] * z;\n out[10] = a[10] * z;\n out[11] = a[11] * z;\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Rotates a mat4 by the given angle around the given axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function rotate(out, a, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n var b00, b01, b02;\n var b10, b11, b12;\n var b20, b21, b22;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c;\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11]; // Construct the elements of the rotation matrix\n\n b00 = x * x * t + c;\n b01 = y * x * t + z * s;\n b02 = z * x * t - y * s;\n b10 = x * y * t - z * s;\n b11 = y * y * t + c;\n b12 = z * y * t + x * s;\n b20 = x * z * t + y * s;\n b21 = y * z * t - x * s;\n b22 = z * z * t + c; // Perform rotation-specific matrix multiplication\n\n out[0] = a00 * b00 + a10 * b01 + a20 * b02;\n out[1] = a01 * b00 + a11 * b01 + a21 * b02;\n out[2] = a02 * b00 + a12 * b01 + a22 * b02;\n out[3] = a03 * b00 + a13 * b01 + a23 * b02;\n out[4] = a00 * b10 + a10 * b11 + a20 * b12;\n out[5] = a01 * b10 + a11 * b11 + a21 * b12;\n out[6] = a02 * b10 + a12 * b11 + a22 * b12;\n out[7] = a03 * b10 + a13 * b11 + a23 * b12;\n out[8] = a00 * b20 + a10 * b21 + a20 * b22;\n out[9] = a01 * b20 + a11 * b21 + a21 * b22;\n out[10] = a02 * b20 + a12 * b21 + a22 * b22;\n out[11] = a03 * b20 + a13 * b21 + a23 * b22;\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the X axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateX(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[4] = a10 * c + a20 * s;\n out[5] = a11 * c + a21 * s;\n out[6] = a12 * c + a22 * s;\n out[7] = a13 * c + a23 * s;\n out[8] = a20 * c - a10 * s;\n out[9] = a21 * c - a11 * s;\n out[10] = a22 * c - a12 * s;\n out[11] = a23 * c - a13 * s;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Y axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateY(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c - a20 * s;\n out[1] = a01 * c - a21 * s;\n out[2] = a02 * c - a22 * s;\n out[3] = a03 * c - a23 * s;\n out[8] = a00 * s + a20 * c;\n out[9] = a01 * s + a21 * c;\n out[10] = a02 * s + a22 * c;\n out[11] = a03 * s + a23 * c;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Z axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateZ(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c + a10 * s;\n out[1] = a01 * c + a11 * s;\n out[2] = a02 * c + a12 * s;\n out[3] = a03 * c + a13 * s;\n out[4] = a10 * c - a00 * s;\n out[5] = a11 * c - a01 * s;\n out[6] = a12 * c - a02 * s;\n out[7] = a13 * c - a03 * s;\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.scale(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = v[1];\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = v[2];\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle around a given axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotate(dest, dest, rad, axis);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function fromRotation(out, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c; // Perform rotation-specific matrix multiplication\n\n out[0] = x * x * t + c;\n out[1] = y * x * t + z * s;\n out[2] = z * x * t - y * s;\n out[3] = 0;\n out[4] = x * y * t - z * s;\n out[5] = y * y * t + c;\n out[6] = z * y * t + x * s;\n out[7] = 0;\n out[8] = x * z * t + y * s;\n out[9] = y * z * t - x * s;\n out[10] = z * z * t + c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the X axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateX(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromXRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = c;\n out[6] = s;\n out[7] = 0;\n out[8] = 0;\n out[9] = -s;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Y axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateY(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromYRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = 0;\n out[2] = -s;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = s;\n out[9] = 0;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Z axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateZ(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromZRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = 0;\n out[4] = -s;\n out[5] = c;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation and vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslation(out, q, v) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 from a dual quat.\n *\n * @param {mat4} out Matrix\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @returns {mat4} mat4 receiving operation result\n */\n\nexport function fromQuat2(out, a) {\n var translation = new glMatrix.ARRAY_TYPE(3);\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7];\n var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense\n\n if (magnitude > 0) {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\n } else {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n }\n\n fromRotationTranslation(out, a, translation);\n return out;\n}\n/**\n * Returns the translation vector component of a transformation\n * matrix. If a matrix is built with fromRotationTranslation,\n * the returned vector will be the same as the translation vector\n * originally supplied.\n * @param {vec3} out Vector to receive translation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getTranslation(out, mat) {\n out[0] = mat[12];\n out[1] = mat[13];\n out[2] = mat[14];\n return out;\n}\n/**\n * Returns the scaling factor component of a transformation\n * matrix. If a matrix is built with fromRotationTranslationScale\n * with a normalized Quaternion paramter, the returned vector will be\n * the same as the scaling vector\n * originally supplied.\n * @param {vec3} out Vector to receive scaling factor component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getScaling(out, mat) {\n var m11 = mat[0];\n var m12 = mat[1];\n var m13 = mat[2];\n var m21 = mat[4];\n var m22 = mat[5];\n var m23 = mat[6];\n var m31 = mat[8];\n var m32 = mat[9];\n var m33 = mat[10];\n out[0] = Math.hypot(m11, m12, m13);\n out[1] = Math.hypot(m21, m22, m23);\n out[2] = Math.hypot(m31, m32, m33);\n return out;\n}\n/**\n * Returns a quaternion representing the rotational component\n * of a transformation matrix. If a matrix is built with\n * fromRotationTranslation, the returned quaternion will be the\n * same as the quaternion originally supplied.\n * @param {quat} out Quaternion to receive the rotation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {quat} out\n */\n\nexport function getRotation(out, mat) {\n var scaling = new glMatrix.ARRAY_TYPE(3);\n getScaling(scaling, mat);\n var is1 = 1 / scaling[0];\n var is2 = 1 / scaling[1];\n var is3 = 1 / scaling[2];\n var sm11 = mat[0] * is1;\n var sm12 = mat[1] * is2;\n var sm13 = mat[2] * is3;\n var sm21 = mat[4] * is1;\n var sm22 = mat[5] * is2;\n var sm23 = mat[6] * is3;\n var sm31 = mat[8] * is1;\n var sm32 = mat[9] * is2;\n var sm33 = mat[10] * is3;\n var trace = sm11 + sm22 + sm33;\n var S = 0;\n\n if (trace > 0) {\n S = Math.sqrt(trace + 1.0) * 2;\n out[3] = 0.25 * S;\n out[0] = (sm23 - sm32) / S;\n out[1] = (sm31 - sm13) / S;\n out[2] = (sm12 - sm21) / S;\n } else if (sm11 > sm22 && sm11 > sm33) {\n S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n out[3] = (sm23 - sm32) / S;\n out[0] = 0.25 * S;\n out[1] = (sm12 + sm21) / S;\n out[2] = (sm31 + sm13) / S;\n } else if (sm22 > sm33) {\n S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n out[3] = (sm31 - sm13) / S;\n out[0] = (sm12 + sm21) / S;\n out[1] = 0.25 * S;\n out[2] = (sm23 + sm32) / S;\n } else {\n S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n out[3] = (sm12 - sm21) / S;\n out[0] = (sm31 + sm13) / S;\n out[1] = (sm23 + sm32) / S;\n out[2] = 0.25 * S;\n }\n\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScale(out, q, v, s) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n out[0] = (1 - (yy + zz)) * sx;\n out[1] = (xy + wz) * sx;\n out[2] = (xz - wy) * sx;\n out[3] = 0;\n out[4] = (xy - wz) * sy;\n out[5] = (1 - (xx + zz)) * sy;\n out[6] = (yz + wx) * sy;\n out[7] = 0;\n out[8] = (xz + wy) * sz;\n out[9] = (yz - wx) * sz;\n out[10] = (1 - (xx + yy)) * sz;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * mat4.translate(dest, origin);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n * mat4.translate(dest, negativeOrigin);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @param {ReadonlyVec3} o The origin vector around which to scale and rotate\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n var ox = o[0];\n var oy = o[1];\n var oz = o[2];\n var out0 = (1 - (yy + zz)) * sx;\n var out1 = (xy + wz) * sx;\n var out2 = (xz - wy) * sx;\n var out4 = (xy - wz) * sy;\n var out5 = (1 - (xx + zz)) * sy;\n var out6 = (yz + wx) * sy;\n var out8 = (xz + wy) * sz;\n var out9 = (yz - wx) * sz;\n var out10 = (1 - (xx + yy)) * sz;\n out[0] = out0;\n out[1] = out1;\n out[2] = out2;\n out[3] = 0;\n out[4] = out4;\n out[5] = out5;\n out[6] = out6;\n out[7] = 0;\n out[8] = out8;\n out[9] = out9;\n out[10] = out10;\n out[11] = 0;\n out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\n out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\n out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\n out[15] = 1;\n return out;\n}\n/**\n * Calculates a 4x4 matrix from the given quaternion\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat4} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[1] = yx + wz;\n out[2] = zx - wy;\n out[3] = 0;\n out[4] = yx - wz;\n out[5] = 1 - xx - zz;\n out[6] = zy + wx;\n out[7] = 0;\n out[8] = zx + wy;\n out[9] = zy - wx;\n out[10] = 1 - xx - yy;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a frustum matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Number} left Left bound of the frustum\n * @param {Number} right Right bound of the frustum\n * @param {Number} bottom Bottom bound of the frustum\n * @param {Number} top Top bound of the frustum\n * @param {Number} near Near bound of the frustum\n * @param {Number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function frustum(out, left, right, bottom, top, near, far) {\n var rl = 1 / (right - left);\n var tb = 1 / (top - bottom);\n var nf = 1 / (near - far);\n out[0] = near * 2 * rl;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = near * 2 * tb;\n out[6] = 0;\n out[7] = 0;\n out[8] = (right + left) * rl;\n out[9] = (top + bottom) * tb;\n out[10] = (far + near) * nf;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[14] = far * near * 2 * nf;\n out[15] = 0;\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveNO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = (far + near) * nf;\n out[14] = 2 * far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -2 * near;\n }\n\n return out;\n}\n/**\n * Alias for {@link mat4.perspectiveNO}\n * @function\n */\n\nexport var perspective = perspectiveNO;\n/**\n * Generates a perspective projection matrix suitable for WebGPU with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveZO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = far * nf;\n out[14] = far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -near;\n }\n\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given field of view.\n * This is primarily useful for generating projection matrices to be used\n * with the still experiemental WebVR API.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\n var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);\n var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);\n var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);\n var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);\n var xScale = 2.0 / (leftTan + rightTan);\n var yScale = 2.0 / (upTan + downTan);\n out[0] = xScale;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n out[4] = 0.0;\n out[5] = yScale;\n out[6] = 0.0;\n out[7] = 0.0;\n out[8] = -((leftTan - rightTan) * xScale * 0.5);\n out[9] = (upTan - downTan) * yScale * 0.5;\n out[10] = far / (near - far);\n out[11] = -1.0;\n out[12] = 0.0;\n out[13] = 0.0;\n out[14] = far * near / (near - far);\n out[15] = 0.0;\n return out;\n}\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoNO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 2 * nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = (far + near) * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Alias for {@link mat4.orthoNO}\n * @function\n */\n\nexport var ortho = orthoNO;\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoZO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = near * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a look-at matrix with the given eye position, focal point, and up axis.\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function lookAt(out, eye, center, up) {\n var x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\n var eyex = eye[0];\n var eyey = eye[1];\n var eyez = eye[2];\n var upx = up[0];\n var upy = up[1];\n var upz = up[2];\n var centerx = center[0];\n var centery = center[1];\n var centerz = center[2];\n\n if (Math.abs(eyex - centerx) < glMatrix.EPSILON && Math.abs(eyey - centery) < glMatrix.EPSILON && Math.abs(eyez - centerz) < glMatrix.EPSILON) {\n return identity(out);\n }\n\n z0 = eyex - centerx;\n z1 = eyey - centery;\n z2 = eyez - centerz;\n len = 1 / Math.hypot(z0, z1, z2);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n x0 = upy * z2 - upz * z1;\n x1 = upz * z0 - upx * z2;\n x2 = upx * z1 - upy * z0;\n len = Math.hypot(x0, x1, x2);\n\n if (!len) {\n x0 = 0;\n x1 = 0;\n x2 = 0;\n } else {\n len = 1 / len;\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n y0 = z1 * x2 - z2 * x1;\n y1 = z2 * x0 - z0 * x2;\n y2 = z0 * x1 - z1 * x0;\n len = Math.hypot(y0, y1, y2);\n\n if (!len) {\n y0 = 0;\n y1 = 0;\n y2 = 0;\n } else {\n len = 1 / len;\n y0 *= len;\n y1 *= len;\n y2 *= len;\n }\n\n out[0] = x0;\n out[1] = y0;\n out[2] = z0;\n out[3] = 0;\n out[4] = x1;\n out[5] = y1;\n out[6] = z1;\n out[7] = 0;\n out[8] = x2;\n out[9] = y2;\n out[10] = z2;\n out[11] = 0;\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n out[15] = 1;\n return out;\n}\n/**\n * Generates a matrix that makes something look at something else.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function targetTo(out, eye, target, up) {\n var eyex = eye[0],\n eyey = eye[1],\n eyez = eye[2],\n upx = up[0],\n upy = up[1],\n upz = up[2];\n var z0 = eyex - target[0],\n z1 = eyey - target[1],\n z2 = eyez - target[2];\n var len = z0 * z0 + z1 * z1 + z2 * z2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n }\n\n var x0 = upy * z2 - upz * z1,\n x1 = upz * z0 - upx * z2,\n x2 = upx * z1 - upy * z0;\n len = x0 * x0 + x1 * x1 + x2 * x2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n out[0] = x0;\n out[1] = x1;\n out[2] = x2;\n out[3] = 0;\n out[4] = z1 * x2 - z2 * x1;\n out[5] = z2 * x0 - z0 * x2;\n out[6] = z0 * x1 - z1 * x0;\n out[7] = 0;\n out[8] = z0;\n out[9] = z1;\n out[10] = z2;\n out[11] = 0;\n out[12] = eyex;\n out[13] = eyey;\n out[14] = eyez;\n out[15] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat4\n *\n * @param {ReadonlyMat4} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \", \" + a[9] + \", \" + a[10] + \", \" + a[11] + \", \" + a[12] + \", \" + a[13] + \", \" + a[14] + \", \" + a[15] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat4\n *\n * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);\n}\n/**\n * Adds two mat4's\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n out[9] = a[9] + b[9];\n out[10] = a[10] + b[10];\n out[11] = a[11] + b[11];\n out[12] = a[12] + b[12];\n out[13] = a[13] + b[13];\n out[14] = a[14] + b[14];\n out[15] = a[15] + b[15];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n out[9] = a[9] - b[9];\n out[10] = a[10] - b[10];\n out[11] = a[11] - b[11];\n out[12] = a[12] - b[12];\n out[13] = a[13] - b[13];\n out[14] = a[14] - b[14];\n out[15] = a[15] - b[15];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat4} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n out[9] = a[9] * b;\n out[10] = a[10] * b;\n out[11] = a[11] * b;\n out[12] = a[12] * b;\n out[13] = a[13] * b;\n out[14] = a[14] * b;\n out[15] = a[15] * b;\n return out;\n}\n/**\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat4} out the receiving vector\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat4} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n out[9] = a[9] + b[9] * scale;\n out[10] = a[10] + b[10] * scale;\n out[11] = a[11] + b[11] * scale;\n out[12] = a[12] + b[12] * scale;\n out[13] = a[13] + b[13] * scale;\n out[14] = a[14] + b[14] * scale;\n out[15] = a[15] + b[15] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7];\n var a8 = a[8],\n a9 = a[9],\n a10 = a[10],\n a11 = a[11];\n var a12 = a[12],\n a13 = a[13],\n a14 = a[14],\n a15 = a[15];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n var b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7];\n var b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11];\n var b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15));\n}\n/**\n * Alias for {@link mat4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat4.subtract}\n * @function\n */\n\nexport var sub = subtract;","import {StyleLayer} from '../style_layer';\n\nimport {CircleBucket} from '../../data/bucket/circle_bucket';\nimport {polygonIntersectsBufferedPoint} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate} from '../query_utils';\nimport properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../../geo/transform';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties.g';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n/**\n * A style layer that defines a circle\n */\nexport class CircleStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new CircleBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const circleBucket: CircleBucket = (bucket as any);\n return getMaximumPaintValue('circle-radius', this, circleBucket) +\n getMaximumPaintValue('circle-stroke-width', this, circleBucket) +\n translateDistance(this.paint.get('circle-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('circle-translate'),\n this.paint.get('circle-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const radius = this.paint.get('circle-radius').evaluate(feature, featureState);\n const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState);\n const size = radius + stroke;\n\n // For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile\n // // Otherwise, compare geometry in the plane of the viewport\n // // A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance\n // // A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance\n const alignWithMap = this.paint.get('circle-pitch-alignment') === 'map';\n const transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry(translatedPolygon, pixelPosMatrix);\n const transformedSize = alignWithMap ? size * pixelsToTileUnits : size;\n\n for (const ring of geometry) {\n for (const point of ring) {\n\n const transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix);\n\n let adjustedSize = transformedSize;\n const projectedCenter = vec4.transformMat4([] as any, [point.x, point.y, 0, 1], pixelPosMatrix);\n if (this.paint.get('circle-pitch-scale') === 'viewport' && this.paint.get('circle-pitch-alignment') === 'map') {\n adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance;\n } else if (this.paint.get('circle-pitch-scale') === 'map' && this.paint.get('circle-pitch-alignment') === 'viewport') {\n adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3];\n }\n\n if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) return true;\n }\n }\n\n return false;\n }\n}\n\nfunction projectPoint(p: Point, pixelPosMatrix: mat4) {\n const point = vec4.transformMat4([] as any, [p.x, p.y, 0, 1], pixelPosMatrix);\n return new Point(point[0] / point[3], point[1] / point[3]);\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4) {\n return queryGeometry.map((p) => {\n return projectPoint(p, pixelPosMatrix);\n });\n}\n","import {CircleBucket} from './circle_bucket';\nimport {register} from '../../util/web_worker_transfer';\n\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport class HeatmapBucket extends CircleBucket {\n // Needed for flow to accept omit: ['layers'] below, due to\n // https://github.com/facebook/flow/issues/4262\n layers: Array;\n}\n\nregister('HeatmapBucket', HeatmapBucket, {omit: ['layers']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HeatmapPaintProps = {\n \"heatmap-radius\": DataDrivenProperty,\n \"heatmap-weight\": DataDrivenProperty,\n \"heatmap-intensity\": DataConstantProperty,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": DataConstantProperty,\n};\n\nexport type HeatmapPaintPropsPossiblyEvaluated = {\n \"heatmap-radius\": PossiblyEvaluatedPropertyValue,\n \"heatmap-weight\": PossiblyEvaluatedPropertyValue,\n \"heatmap-intensity\": number,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"heatmap-radius\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-radius\"] as any as StylePropertySpecification),\n \"heatmap-weight\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-weight\"] as any as StylePropertySpecification),\n \"heatmap-intensity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-intensity\"] as any as StylePropertySpecification),\n \"heatmap-color\": new ColorRampProperty(styleSpec[\"paint_heatmap\"][\"heatmap-color\"] as any as StylePropertySpecification),\n \"heatmap-opacity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {register} from './web_worker_transfer';\n\nexport type Size = {\n width: number;\n height: number;\n};\n\ntype Point2D = {\n x: number;\n y: number;\n};\n\nfunction createImage(image: any, {\n width,\n height\n}: Size, channels: number, data?: Uint8Array | Uint8ClampedArray) {\n if (!data) {\n data = new Uint8Array(width * height * channels);\n } else if (data instanceof Uint8ClampedArray) {\n data = new Uint8Array(data.buffer);\n } else if (data.length !== width * height * channels) {\n throw new RangeError(`mismatched image size. expected: ${data.length} but got: ${width * height * channels}`);\n }\n image.width = width;\n image.height = height;\n image.data = data;\n return image;\n}\n\nfunction resizeImage(image: any, {\n width,\n height\n}: Size, channels: number) {\n if (width === image.width && height === image.height) {\n return;\n }\n\n const newImage = createImage({}, {width, height}, channels);\n\n copyImage(image, newImage, {x: 0, y: 0}, {x: 0, y: 0}, {\n width: Math.min(image.width, width),\n height: Math.min(image.height, height)\n }, channels);\n\n image.width = width;\n image.height = height;\n image.data = newImage.data;\n}\n\nfunction copyImage(srcImg: any, dstImg: any, srcPt: Point2D, dstPt: Point2D, size: Size, channels: number) {\n if (size.width === 0 || size.height === 0) {\n return dstImg;\n }\n\n if (size.width > srcImg.width ||\n size.height > srcImg.height ||\n srcPt.x > srcImg.width - size.width ||\n srcPt.y > srcImg.height - size.height) {\n throw new RangeError('out of range source coordinates for image copy');\n }\n\n if (size.width > dstImg.width ||\n size.height > dstImg.height ||\n dstPt.x > dstImg.width - size.width ||\n dstPt.y > dstImg.height - size.height) {\n throw new RangeError('out of range destination coordinates for image copy');\n }\n\n const srcData = srcImg.data;\n const dstData = dstImg.data;\n\n if (srcData === dstData) throw new Error('srcData equals dstData, so image is already copied');\n\n for (let y = 0; y < size.height; y++) {\n const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels;\n const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels;\n for (let i = 0; i < size.width * channels; i++) {\n dstData[dstOffset + i] = srcData[srcOffset + i];\n }\n }\n return dstImg;\n}\n\n/**\n * @internal\n * An image with alpha color value\n */\nexport class AlphaImage {\n width: number;\n height: number;\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 1, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 1);\n }\n\n clone() {\n return new AlphaImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 1);\n }\n}\n\n/**\n * An object to store image data not premultiplied, because ImageData is not premultiplied.\n * UNPACK_PREMULTIPLY_ALPHA_WEBGL must be used when uploading to a texture.\n */\nexport class RGBAImage {\n width: number;\n height: number;\n\n /**\n * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers.\n */\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 4, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 4);\n }\n\n replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean) {\n if (copy) {\n this.data.set(data);\n } else if (data instanceof Uint8ClampedArray) {\n this.data = new Uint8Array(data.buffer);\n } else {\n this.data = data;\n }\n }\n\n clone() {\n return new RGBAImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 4);\n }\n}\n\nregister('AlphaImage', AlphaImage);\nregister('RGBAImage', RGBAImage);\n","import {StyleLayer} from '../style_layer';\n\nimport {HeatmapBucket} from '../../data/bucket/heatmap_bucket';\nimport {RGBAImage} from '../../util/image';\nimport properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties.g';\nimport {renderColorRamp} from '../../util/color_ramp';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {Texture} from '../../render/texture';\nimport type {Framebuffer} from '../../gl/framebuffer';\nimport type {HeatmapPaintProps} from './heatmap_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A style layer that defines a heatmap\n */\nexport class HeatmapStyleLayer extends StyleLayer {\n\n heatmapFbo: Framebuffer;\n colorRamp: RGBAImage;\n colorRampTexture: Texture;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n createBucket(options: any) {\n return new HeatmapBucket(options);\n }\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n\n // make sure color ramp texture is generated for default heatmap color too\n this._updateColorRamp();\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'heatmap-color') {\n this._updateColorRamp();\n }\n }\n\n _updateColorRamp() {\n const expression = this._transitionablePaint._values['heatmap-color'].value.expression;\n this.colorRamp = renderColorRamp({\n expression,\n evaluationKey: 'heatmapDensity',\n image: this.colorRamp\n });\n this.colorRampTexture = null;\n }\n\n resize() {\n if (this.heatmapFbo) {\n this.heatmapFbo.destroy();\n this.heatmapFbo = null;\n }\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n return false;\n }\n\n hasOffscreenPass() {\n return this.paint.get('heatmap-opacity') !== 0 && this.visibility !== 'none';\n }\n}\n","import {RGBAImage} from './image';\nimport {isPowerOfTwo} from './util';\n\nimport type {StylePropertyExpression} from '@maplibre/maplibre-gl-style-spec';\n\nexport type ColorRampParams = {\n expression: StylePropertyExpression;\n evaluationKey: string;\n resolution?: number;\n image?: RGBAImage;\n clips?: Array;\n};\n\n/**\n * Given an expression that should evaluate to a color ramp,\n * return a RGBA image representing that ramp expression.\n */\nexport function renderColorRamp(params: ColorRampParams): RGBAImage {\n const evaluationGlobals = {};\n const width = params.resolution || 256;\n const height = params.clips ? params.clips.length : 1;\n const image = params.image || new RGBAImage({width, height});\n\n if (!isPowerOfTwo(width)) throw new Error(`width is not a power of 2 - ${width}`);\n\n const renderPixel = (stride, index, progress) => {\n evaluationGlobals[params.evaluationKey] = progress;\n const pxColor = params.expression.evaluate(evaluationGlobals as any);\n // the colors are being unpremultiplied because Color uses\n // premultiplied values, and the Texture class expects unpremultiplied ones\n image.data[stride + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a);\n image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a);\n image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a);\n image.data[stride + index + 3] = Math.floor(pxColor.a * 255);\n };\n\n if (!params.clips) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n const progress = i / (width - 1);\n\n renderPixel(0, j, progress);\n }\n } else {\n for (let clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n // Remap progress between clips\n const progress = i / (width - 1);\n const {start, end} = params.clips[clip];\n const evaluationProgress = start * (1 - progress) + end * progress;\n renderPixel(stride, j, evaluationProgress);\n }\n }\n }\n\n return image;\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HillshadePaintProps = {\n \"hillshade-illumination-direction\": DataConstantProperty,\n \"hillshade-illumination-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"hillshade-exaggeration\": DataConstantProperty,\n \"hillshade-shadow-color\": DataConstantProperty,\n \"hillshade-highlight-color\": DataConstantProperty,\n \"hillshade-accent-color\": DataConstantProperty,\n};\n\nexport type HillshadePaintPropsPossiblyEvaluated = {\n \"hillshade-illumination-direction\": number,\n \"hillshade-illumination-anchor\": \"map\" | \"viewport\",\n \"hillshade-exaggeration\": number,\n \"hillshade-shadow-color\": Color,\n \"hillshade-highlight-color\": Color,\n \"hillshade-accent-color\": Color,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"hillshade-illumination-direction\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-direction\"] as any as StylePropertySpecification),\n \"hillshade-illumination-anchor\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-anchor\"] as any as StylePropertySpecification),\n \"hillshade-exaggeration\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-exaggeration\"] as any as StylePropertySpecification),\n \"hillshade-shadow-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-shadow-color\"] as any as StylePropertySpecification),\n \"hillshade-highlight-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-highlight-color\"] as any as StylePropertySpecification),\n \"hillshade-accent-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-accent-color\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {HillshadePaintPropsPossiblyEvaluated} from './hillshade_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {HillshadePaintProps} from './hillshade_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class HillshadeStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n hasOffscreenPass() {\n return this.paint.get('hillshade-exaggeration') !== 0 && this.visibility !== 'none';\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nmodule.exports = earcut;\nmodule.exports.default = earcut;\n\nfunction earcut(data, holeIndices, dim) {\n\n dim = dim || 2;\n\n var hasHoles = holeIndices && holeIndices.length,\n outerLen = hasHoles ? holeIndices[0] * dim : data.length,\n outerNode = linkedList(data, 0, outerLen, dim, true),\n triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n var minX, minY, maxX, maxY, x, y, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = maxX = data[0];\n minY = maxY = data[1];\n\n for (var i = dim; i < outerLen; i += dim) {\n x = data[i];\n y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n var i, last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n } else {\n for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n var p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n var stop = ear,\n prev, next;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n prev = ear.prev;\n next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n // cut off the triangle\n triangles.push(prev.i / dim | 0);\n triangles.push(ear.i / dim | 0);\n triangles.push(next.i / dim | 0);\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n var p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n // z-order range for the current triangle bbox;\n var minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n var p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles, dim) {\n var p = start;\n do {\n var a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i / dim | 0);\n triangles.push(p.i / dim | 0);\n triangles.push(b.i / dim | 0);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n var a = start;\n do {\n var b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n var c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n var queue = [],\n i, len, start, end, list;\n\n for (i = 0, len = holeIndices.length; i < len; i++) {\n start = holeIndices[i] * dim;\n end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareX);\n\n // process holes from left to right\n for (i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareX(a, b) {\n return a.x - b.x;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and and link it\nfunction eliminateHole(hole, outerNode) {\n var bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n var bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n var p = outerNode,\n hx = hole.x,\n hy = hole.y,\n qx = -Infinity,\n m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n do {\n if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n var stop = m,\n mx = m.x,\n my = m.y,\n tanMin = Infinity,\n tan;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n var p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n var i, p, q, e, tail, numMerges, pSize, qSize,\n inSize = 1;\n\n do {\n p = list;\n list = null;\n tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n q = p;\n pSize = 0;\n for (i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n var p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n var o1 = sign(area(p1, q1, p2));\n var o2 = sign(area(p1, q1, q2));\n var o3 = sign(area(p2, q2, p1));\n var o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n var p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n var p = a,\n inside = false,\n px = (a.x + b.x) / 2,\n py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n var a2 = new Node(a.i, a.x, a.y),\n b2 = new Node(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n var p = new Node(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n // vertex index in coordinates array\n this.i = i;\n\n // vertex coordinates\n this.x = x;\n this.y = y;\n\n // previous and next vertex nodes in a polygon ring\n this.prev = null;\n this.next = null;\n\n // z-order curve value\n this.z = 0;\n\n // previous and next nodes in z-order\n this.prevZ = null;\n this.nextZ = null;\n\n // indicates whether this is a steiner point\n this.steiner = false;\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nearcut.deviation = function (data, holeIndices, dim, triangles) {\n var hasHoles = holeIndices && holeIndices.length;\n var outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (var i = 0, len = holeIndices.length; i < len; i++) {\n var start = holeIndices[i] * dim;\n var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n var trianglesArea = 0;\n for (i = 0; i < triangles.length; i += 3) {\n var a = triangles[i] * dim;\n var b = triangles[i + 1] * dim;\n var c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n};\n\nfunction signedArea(data, start, end, dim) {\n var sum = 0;\n for (var i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nearcut.flatten = function (data) {\n var dim = data[0][0].length,\n result = {vertices: [], holes: [], dimensions: dim},\n holeIndex = 0;\n\n for (var i = 0; i < data.length; i++) {\n for (var j = 0; j < data[i].length; j++) {\n for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);\n }\n if (i > 0) {\n holeIndex += data[i - 1].length;\n result.holes.push(holeIndex);\n }\n }\n return result;\n};\n","\nexport default function quickselect(arr, k, left, right, compare) {\n quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);\n}\n\nfunction quickselectStep(arr, k, left, right, compare) {\n\n while (right > left) {\n if (right - left > 600) {\n var n = right - left + 1;\n var m = k - left + 1;\n var z = Math.log(n);\n var s = 0.5 * Math.exp(2 * z / 3);\n var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselectStep(arr, k, newLeft, newRight, compare);\n }\n\n var t = arr[k];\n var i = left;\n var j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\nfunction swap(arr, i, j) {\n var tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import quickselect from 'quickselect';\n\nimport {calculateSignedArea} from './util';\n\nimport type Point from '@mapbox/point-geometry';\n\n// classifies an array of rings into polygons with outer rings and holes\nexport function classifyRings(rings: Array>, maxRings: number) {\n const len = rings.length;\n\n if (len <= 1) return [rings];\n\n const polygons = [];\n let polygon,\n ccw;\n\n for (let i = 0; i < len; i++) {\n const area = calculateSignedArea(rings[i]);\n if (area === 0) continue;\n\n (rings[i] as any).area = Math.abs(area);\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n (polygon as any).push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n // Earcut performance degrades with the # of rings in a polygon. For this\n // reason, we limit strip out all but the `maxRings` largest rings.\n if (maxRings > 1) {\n for (let j = 0; j < polygons.length; j++) {\n if (polygons[j].length <= maxRings) continue;\n quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);\n polygons[j] = polygons[j].slice(0, maxRings);\n }\n }\n\n return polygons;\n}\n\nfunction compareAreas(a, b) {\n return b.area - a.area;\n}\n","import type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\n\nimport type {\n BucketFeature,\n PopulateParameters\n} from '../bucket';\nimport {PossiblyEvaluated} from '../../style/properties';\n\ntype PatternStyleLayers = Array | Array | Array;\n\nexport function hasPattern(type: string, layers: PatternStyleLayers, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n let hasPattern = false;\n\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n if (!patternProperty.isConstant()) {\n hasPattern = true;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern) {\n hasPattern = true;\n patterns[constantPattern.to] = true;\n patterns[constantPattern.from] = true;\n }\n }\n\n return hasPattern;\n}\n\nexport function addPatternDependencies(type: string, layers: PatternStyleLayers, patternFeature: BucketFeature, zoom: number, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n\n const patternPropertyValue = patternProperty.value;\n if (patternPropertyValue.kind !== 'constant') {\n let min = patternPropertyValue.evaluate({zoom: zoom - 1}, patternFeature, {}, options.availableImages);\n let mid = patternPropertyValue.evaluate({zoom}, patternFeature, {}, options.availableImages);\n let max = patternPropertyValue.evaluate({zoom: zoom + 1}, patternFeature, {}, options.availableImages);\n min = min && min.name ? min.name : min;\n mid = mid && mid.name ? mid.name : mid;\n max = max && max.name ? max.name : max;\n // add to patternDependencies\n patterns[min] = true;\n patterns[mid] = true;\n patterns[max] = true;\n\n // save for layout\n patternFeature.patterns[layer.id] = {min, mid, max};\n }\n }\n return patternFeature;\n}\n","import {FillLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './fill_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {LineIndexArray, TriangleIndexArray} from '../index_array_type';\nimport earcut from 'earcut';\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport class FillBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n\n layoutVertexArray: FillLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n indexArray2: LineIndexArray;\n indexBuffer2: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n segments2: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n\n this.layoutVertexArray = new FillLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.indexArray2 = new LineIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.segments2 = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('fill', this.layers, options);\n const fillSortKey = this.layers[0].layout.get('fill-sort-key');\n const sortFeaturesByKey = !fillSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternFeature = addPatternDependencies('fill', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending(): boolean {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.indexBuffer2 = context.createIndexBuffer(this.indexArray2);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.indexBuffer2.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.segments2.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n\n const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n const triangleIndex = triangleSegment.vertexLength;\n\n const flattened = [];\n const holeIndices = [];\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2);\n const lineIndex = lineSegment.vertexLength;\n\n this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y);\n this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex);\n flattened.push(ring[0].x);\n flattened.push(ring[0].y);\n\n for (let i = 1; i < ring.length; i++) {\n this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y);\n this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);\n flattened.push(ring[i].x);\n flattened.push(ring[i].y);\n }\n\n lineSegment.vertexLength += ring.length;\n lineSegment.primitiveLength += ring.length;\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let i = 0; i < indices.length; i += 3) {\n this.indexArray.emplaceBack(\n triangleIndex + indices[i],\n triangleIndex + indices[i + 1],\n triangleIndex + indices[i + 2]);\n }\n\n triangleSegment.vertexLength += numVertices;\n triangleSegment.primitiveLength += indices.length / 3;\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillBucket', FillBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FillLayoutProps = {\n \"fill-sort-key\": DataDrivenProperty,\n};\n\nexport type FillLayoutPropsPossiblyEvaluated = {\n \"fill-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"fill-sort-key\": new DataDrivenProperty(styleSpec[\"layout_fill\"][\"fill-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type FillPaintProps = {\n \"fill-antialias\": DataConstantProperty,\n \"fill-opacity\": DataDrivenProperty,\n \"fill-color\": DataDrivenProperty,\n \"fill-outline-color\": DataDrivenProperty,\n \"fill-translate\": DataConstantProperty<[number, number]>,\n \"fill-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-pattern\": CrossFadedDataDrivenProperty,\n};\n\nexport type FillPaintPropsPossiblyEvaluated = {\n \"fill-antialias\": boolean,\n \"fill-opacity\": PossiblyEvaluatedPropertyValue,\n \"fill-color\": PossiblyEvaluatedPropertyValue,\n \"fill-outline-color\": PossiblyEvaluatedPropertyValue,\n \"fill-translate\": [number, number],\n \"fill-translate-anchor\": \"map\" | \"viewport\",\n \"fill-pattern\": PossiblyEvaluatedPropertyValue>,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-antialias\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-antialias\"] as any as StylePropertySpecification),\n \"fill-opacity\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-opacity\"] as any as StylePropertySpecification),\n \"fill-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-color\"] as any as StylePropertySpecification),\n \"fill-outline-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-outline-color\"] as any as StylePropertySpecification),\n \"fill-translate\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate\"] as any as StylePropertySpecification),\n \"fill-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-pattern\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillBucket} from '../../data/bucket/fill_bucket';\nimport {polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\n\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class FillStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n const outlineColor = this.paint._values['fill-outline-color'];\n if (outlineColor.value.kind === 'constant' && outlineColor.value.value === undefined) {\n this.paint._values['fill-outline-color'] = this.paint._values['fill-color'];\n }\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-translate'),\n this.paint.get('fill-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n return polygonIntersectsMultiPolygon(translatedPolygon, geometry);\n }\n\n isTileClipped() {\n return true;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_normal_ed', components: 4, type: 'Int16'},\n], 4);\n\nexport const centroidAttributes = createLayout([\n {name: 'a_centroid', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nvar Point = require('@mapbox/point-geometry');\n\nmodule.exports = VectorTileFeature;\n\nfunction VectorTileFeature(pbf, end, extent, keys, values) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n\n pbf.readFields(readFeature, this, end);\n}\n\nfunction readFeature(tag, feature, pbf) {\n if (tag == 1) feature.id = pbf.readVarint();\n else if (tag == 2) readTag(pbf, feature);\n else if (tag == 3) feature.type = pbf.readVarint();\n else if (tag == 4) feature._geometry = pbf.pos;\n}\n\nfunction readTag(pbf, feature) {\n var end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var key = feature._keys[pbf.readVarint()],\n value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n\nVectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\nVectorTileFeature.prototype.loadGeometry = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n lines = [],\n line;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) { // moveTo\n if (line) lines.push(line);\n line = [];\n }\n\n line.push(new Point(x, y));\n\n } else if (cmd === 7) {\n\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].clone()); // closePolygon\n }\n\n } else {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n if (line) lines.push(line);\n\n return lines;\n};\n\nVectorTileFeature.prototype.bbox = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n x1 = Infinity,\n x2 = -Infinity,\n y1 = Infinity,\n y2 = -Infinity;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n\n } else if (cmd !== 7) {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n return [x1, y1, x2, y2];\n};\n\nVectorTileFeature.prototype.toGeoJSON = function(x, y, z) {\n var size = this.extent * Math.pow(2, z),\n x0 = this.extent * x,\n y0 = this.extent * y,\n coords = this.loadGeometry(),\n type = VectorTileFeature.types[this.type],\n i, j;\n\n function project(line) {\n for (var j = 0; j < line.length; j++) {\n var p = line[j], y2 = 180 - (p.y + y0) * 360 / size;\n line[j] = [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90\n ];\n }\n }\n\n switch (this.type) {\n case 1:\n var points = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n project(coords);\n break;\n\n case 2:\n for (i = 0; i < coords.length; i++) {\n project(coords[i]);\n }\n break;\n\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n project(coords[i][j]);\n }\n }\n break;\n }\n\n if (coords.length === 1) {\n coords = coords[0];\n } else {\n type = 'Multi' + type;\n }\n\n var result = {\n type: \"Feature\",\n geometry: {\n type: type,\n coordinates: coords\n },\n properties: this.properties\n };\n\n if ('id' in this) {\n result.id = this.id;\n }\n\n return result;\n};\n\n// classifies an array of rings into polygons with outer rings and holes\n\nfunction classifyRings(rings) {\n var len = rings.length;\n\n if (len <= 1) return [rings];\n\n var polygons = [],\n polygon,\n ccw;\n\n for (var i = 0; i < len; i++) {\n var area = signedArea(rings[i]);\n if (area === 0) continue;\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n return polygons;\n}\n\nfunction signedArea(ring) {\n var sum = 0;\n for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n","'use strict';\n\nvar VectorTileFeature = require('./vectortilefeature.js');\n\nmodule.exports = VectorTileLayer;\n\nfunction VectorTileLayer(pbf, end) {\n // Public\n this.version = 1;\n this.name = null;\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n}\n\nfunction readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n}\n\nfunction readValueMessage(pbf) {\n var value = null,\n end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var tag = pbf.readVarint() >> 3;\n\n value = tag === 1 ? pbf.readString() :\n tag === 2 ? pbf.readFloat() :\n tag === 3 ? pbf.readDouble() :\n tag === 4 ? pbf.readVarint64() :\n tag === 5 ? pbf.readVarint() :\n tag === 6 ? pbf.readSVarint() :\n tag === 7 ? pbf.readBoolean() : null;\n }\n\n return value;\n}\n\n// return feature `i` from this layer as a `VectorTileFeature`\nVectorTileLayer.prototype.feature = function(i) {\n if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');\n\n this._pbf.pos = this._features[i];\n\n var end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n};\n","'use strict';\n\nvar VectorTileLayer = require('./vectortilelayer');\n\nmodule.exports = VectorTile;\n\nfunction VectorTile(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n}\n\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n}\n\n","module.exports.VectorTile = require('./lib/vectortile.js');\nmodule.exports.VectorTileFeature = require('./lib/vectortilefeature.js');\nmodule.exports.VectorTileLayer = require('./lib/vectortilelayer.js');\n","import {FillExtrusionLayoutArray, PosArray} from '../array_types.g';\n\nimport {members as layoutAttributes, centroidAttributes} from './fill_extrusion_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport earcut from 'earcut';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\n\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nconst FACTOR = Math.pow(2, 13);\n\nfunction addVertex(vertexArray, x, y, nx, ny, nz, t, e) {\n vertexArray.emplaceBack(\n // a_pos\n x,\n y,\n // a_normal_ed: 3-component normal and 1-component edgedistance\n Math.floor(nx * FACTOR) * 2 + t,\n ny * FACTOR * 2,\n nz * FACTOR * 2,\n // edgedistance (used for wrapping patterns around extrusion sides)\n Math.round(e)\n );\n}\n\nexport class FillExtrusionBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: FillExtrusionLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n centroidVertexArray: PosArray;\n centroidVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n features: Array;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new FillExtrusionLayoutArray();\n this.centroidVertexArray = new PosArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.features = [];\n this.hasPattern = hasPattern('fill-extrusion', this.layers, options);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const bucketFeature: BucketFeature = {\n id,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n properties: feature.properties,\n type: feature.type,\n patterns: {}\n };\n\n if (this.hasPattern) {\n this.features.push(addPatternDependencies('fill-extrusion', this.layers, bucketFeature, this.zoom, options));\n } else {\n this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {});\n }\n\n options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);\n }\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.features) {\n const {geometry} = feature;\n this.addFeature(feature, geometry, feature.index, canonical, imagePositions);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.centroidVertexBuffer.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const centroid = {x: 0, y: 0, vertexCount: 0};\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n let segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (isEntirelyOutside(ring)) {\n continue;\n }\n\n let edgeDistance = 0;\n\n for (let p = 0; p < ring.length; p++) {\n const p1 = ring[p];\n\n if (p >= 1) {\n const p2 = ring[p - 1];\n\n if (!isBoundaryEdge(p1, p2)) {\n if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n }\n\n const perp = p1.sub(p2)._perp()._unit();\n const dist = p2.dist(p1);\n if (edgeDistance + dist > 32768) edgeDistance = 0;\n\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p1.x;\n centroid.y += 2 * p1.y;\n centroid.vertexCount += 2;\n\n edgeDistance += dist;\n\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p2.x;\n centroid.y += 2 * p2.y;\n centroid.vertexCount += 2;\n\n const bottomRight = segment.vertexLength;\n\n // ┌──────┐\n // │ 0 1 │ Counter-clockwise winding order.\n // │ │ Triangle 1: 0 => 2 => 1\n // │ 2 3 │ Triangle 2: 1 => 2 => 3\n // └──────┘\n this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);\n this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n }\n\n }\n\n if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n }\n\n //Only triangulate and draw the area of the feature if it is a polygon\n //Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined\n if (vectorTileFeatureTypes[feature.type] !== 'Polygon')\n continue;\n\n const flattened = [];\n const holeIndices = [];\n const triangleIndex = segment.vertexLength;\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n\n addVertex(this.layoutVertexArray, p.x, p.y, 0, 0, 1, 1, 0);\n centroid.x += p.x;\n centroid.y += p.y;\n centroid.vertexCount += 1;\n\n flattened.push(p.x);\n flattened.push(p.y);\n }\n\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let j = 0; j < indices.length; j += 3) {\n // Counter-clockwise winding order.\n this.indexArray.emplaceBack(\n triangleIndex + indices[j],\n triangleIndex + indices[j + 2],\n triangleIndex + indices[j + 1]);\n }\n\n segment.primitiveLength += indices.length / 3;\n segment.vertexLength += numVertices;\n }\n\n // remember polygon centroid to calculate elevation in GPU\n for (let i = 0; i < centroid.vertexCount; i++) {\n this.centroidVertexArray.emplaceBack(\n Math.floor(centroid.x / centroid.vertexCount),\n Math.floor(centroid.y / centroid.vertexCount)\n );\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillExtrusionBucket', FillExtrusionBucket, {omit: ['layers', 'features']});\n\nfunction isBoundaryEdge(p1, p2) {\n return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) ||\n (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT));\n}\n\nfunction isEntirelyOutside(ring) {\n return ring.every(p => p.x < 0) ||\n ring.every(p => p.x > EXTENT) ||\n ring.every(p => p.y < 0) ||\n ring.every(p => p.y > EXTENT);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type FillExtrusionPaintProps = {\n \"fill-extrusion-opacity\": DataConstantProperty,\n \"fill-extrusion-color\": DataDrivenProperty,\n \"fill-extrusion-translate\": DataConstantProperty<[number, number]>,\n \"fill-extrusion-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-extrusion-pattern\": CrossFadedDataDrivenProperty,\n \"fill-extrusion-height\": DataDrivenProperty,\n \"fill-extrusion-base\": DataDrivenProperty,\n \"fill-extrusion-vertical-gradient\": DataConstantProperty,\n};\n\nexport type FillExtrusionPaintPropsPossiblyEvaluated = {\n \"fill-extrusion-opacity\": number,\n \"fill-extrusion-color\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-translate\": [number, number],\n \"fill-extrusion-translate-anchor\": \"map\" | \"viewport\",\n \"fill-extrusion-pattern\": PossiblyEvaluatedPropertyValue>,\n \"fill-extrusion-height\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-base\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-vertical-gradient\": boolean,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-extrusion-opacity\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-opacity\"] as any as StylePropertySpecification),\n \"fill-extrusion-color\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-color\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-extrusion-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-pattern\"] as any as StylePropertySpecification),\n \"fill-extrusion-height\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-height\"] as any as StylePropertySpecification),\n \"fill-extrusion-base\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-base\"] as any as StylePropertySpecification),\n \"fill-extrusion-vertical-gradient\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-vertical-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillExtrusionBucket} from '../../data/bucket/fill_extrusion_bucket';\nimport {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class Point3D extends Point {\n z: number;\n}\n\nexport class FillExtrusionStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillExtrusionBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-extrusion-translate'));\n }\n\n is3D(): boolean {\n return true;\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number {\n\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-extrusion-translate'),\n this.paint.get('fill-extrusion-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n\n const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState);\n const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState);\n\n const projectedQueryGeometry = projectQueryGeometry(translatedPolygon, pixelPosMatrix, transform, 0);\n\n const projected = projectExtrusion(geometry, base, height, pixelPosMatrix);\n const projectedBase = projected[0];\n const projectedTop = projected[1];\n return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry);\n }\n}\n\nfunction dot(a, b) {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function getIntersectionDistance(projectedQueryGeometry: Array, projectedFace: Array) {\n\n if (projectedQueryGeometry.length === 1) {\n // For point queries calculate the z at which the point intersects the face\n // using barycentric coordinates.\n\n // Find the barycentric coordinates of the projected point within the first\n // triangle of the face, using only the xy plane. It doesn't matter if the\n // point is outside the first triangle because all the triangles in the face\n // are in the same plane.\n //\n // Check whether points are coincident and use other points if they are.\n let i = 0;\n const a = projectedFace[i++];\n let b;\n while (!b || a.equals(b)) {\n b = projectedFace[i++];\n if (!b) return Infinity;\n }\n\n // Loop until point `c` is not colinear with points `a` and `b`.\n for (; i < projectedFace.length; i++) {\n const c = projectedFace[i];\n\n const p = projectedQueryGeometry[0];\n\n const ab = b.sub(a);\n const ac = c.sub(a);\n const ap = p.sub(a);\n\n const dotABAB = dot(ab, ab);\n const dotABAC = dot(ab, ac);\n const dotACAC = dot(ac, ac);\n const dotAPAB = dot(ap, ab);\n const dotAPAC = dot(ap, ac);\n const denom = dotABAB * dotACAC - dotABAC * dotABAC;\n\n const v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom;\n const w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom;\n const u = 1 - v - w;\n\n // Use the barycentric weighting along with the original triangle z coordinates to get the point of intersection.\n const distance = a.z * u + b.z * v + c.z * w;\n\n if (isFinite(distance)) return distance;\n }\n\n return Infinity;\n\n } else {\n // The counts as closest is less clear when the query is a box. This\n // returns the distance to the nearest point on the face, whether it is\n // within the query or not. It could be more correct to return the\n // distance to the closest point within the query box but this would be\n // more complicated and expensive to calculate with little benefit.\n let closestDistance = Infinity;\n for (const p of projectedFace) {\n closestDistance = Math.min(closestDistance, p.z);\n }\n return closestDistance;\n }\n}\n\nfunction checkIntersection(projectedBase: Array>, projectedTop: Array>, projectedQueryGeometry: Array) {\n let closestDistance = Infinity;\n\n if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) {\n closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]);\n }\n\n for (let r = 0; r < projectedTop.length; r++) {\n const ringTop = projectedTop[r];\n const ringBase = projectedBase[r];\n for (let p = 0; p < ringTop.length - 1; p++) {\n const topA = ringTop[p];\n const topB = ringTop[p + 1];\n const baseA = ringBase[p];\n const baseB = ringBase[p + 1];\n const face = [topA, topB, baseB, baseA, topA];\n if (polygonIntersectsPolygon(projectedQueryGeometry, face)) {\n closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face));\n }\n }\n }\n\n return closestDistance === Infinity ? false : closestDistance;\n}\n\n/*\n * Project the geometry using matrix `m`. This is essentially doing\n * `vec4.transformMat4([], [p.x, p.y, z, 1], m)` but the multiplication\n * is inlined so that parts of the projection that are the same across\n * different points can only be done once. This produced a measurable\n * performance improvement.\n */\nfunction projectExtrusion(geometry: Array>, zBase: number, zTop: number, m: mat4): [Array>, Array>] {\n const projectedBase = [] as Array>;\n const projectedTop = [] as Array>;\n const baseXZ = m[8] * zBase;\n const baseYZ = m[9] * zBase;\n const baseZZ = m[10] * zBase;\n const baseWZ = m[11] * zBase;\n const topXZ = m[8] * zTop;\n const topYZ = m[9] * zTop;\n const topZZ = m[10] * zTop;\n const topWZ = m[11] * zTop;\n\n for (const r of geometry) {\n const ringBase = [] as Array;\n const ringTop = [] as Array;\n for (const p of r) {\n const x = p.x;\n const y = p.y;\n\n const sX = m[0] * x + m[4] * y + m[12];\n const sY = m[1] * x + m[5] * y + m[13];\n const sZ = m[2] * x + m[6] * y + m[14];\n const sW = m[3] * x + m[7] * y + m[15];\n\n const baseX = sX + baseXZ;\n const baseY = sY + baseYZ;\n const baseZ = sZ + baseZZ;\n const baseW = sW + baseWZ;\n\n const topX = sX + topXZ;\n const topY = sY + topYZ;\n const topZ = sZ + topZZ;\n const topW = sW + topWZ;\n\n const b = new Point(baseX / baseW, baseY / baseW) as Point3D;\n b.z = baseZ / baseW;\n ringBase.push(b);\n\n const t = new Point(topX / topW, topY / topW) as Point3D;\n t.z = topZ / topW;\n ringTop.push(t);\n }\n projectedBase.push(ringBase);\n projectedTop.push(ringTop);\n }\n return [projectedBase, projectedTop];\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4, transform: Transform, z: number) {\n const projectedQueryGeometry = [];\n for (const p of queryGeometry) {\n const v = [p.x, p.y, z, 1] as vec4;\n vec4.transformMat4(v, v, pixelPosMatrix);\n projectedQueryGeometry.push(new Point(v[0] / v[3], v[1] / v[3]));\n }\n return projectedQueryGeometry;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributes = createLayout([\n {name: 'a_pos_normal', components: 2, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint8'}\n], 4);\n\nexport const {members, size, alignment} = lineLayoutAttributes;\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributesExt = createLayout([\n {name: 'a_uv_x', components: 1, type: 'Float32'},\n {name: 'a_split_index', components: 1, type: 'Float32'},\n]);\n\nexport const {members, size, alignment} = lineLayoutAttributesExt;\n","import {LineLayoutArray, LineExtLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './line_attributes';\nimport {members as layoutAttributesExt} from './line_attributes_ext';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Segment} from '../segment';\nimport {RGBAImage} from '../../util/image';\nimport type {Context} from '../../gl/context';\nimport type {Texture} from '../../render/texture';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\n// NOTE ON EXTRUDE SCALE:\n// scale the extrusion vector so that the normal length is this value.\n// contains the \"texture\" normals (-1..1). this is distinct from the extrude\n// normals for line joins, because the x-value remains 0 for the texture\n// normal array, while the extrude normal actually moves the vertex to create\n// the acute/bevelled line join.\nconst EXTRUDE_SCALE = 63;\n\n/*\n * Sharp corners cause dashed lines to tilt because the distance along the line\n * is the same at both the inner and outer corners. To improve the appearance of\n * dashed lines we add extra points near sharp corners so that a smaller part\n * of the line is tilted.\n *\n * COS_HALF_SHARP_CORNER controls how sharp a corner has to be for us to add an\n * extra vertex. The default is 75 degrees.\n *\n * The newly created vertices are placed SHARP_CORNER_OFFSET pixels from the corner.\n */\nconst COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180));\nconst SHARP_CORNER_OFFSET = 15;\n\n// Angle per triangle for approximating round line joins.\nconst DEG_PER_TRIANGLE = 20;\n\n// The number of bits that is used to store the line distance in the buffer.\nconst LINE_DISTANCE_BUFFER_BITS = 15;\n\n// We don't have enough bits for the line distance as we'd like to have, so\n// use this value to scale the line distance (in tile units) down to a smaller\n// value. This lets us store longer distances while sacrificing precision.\nconst LINE_DISTANCE_SCALE = 1 / 2;\n\n// The maximum line distance, in tile units, that fits in the buffer.\nconst MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE;\n\ntype LineClips = {\n start: number;\n end: number;\n};\n\ntype GradientTexture = {\n texture?: Texture;\n gradient?: RGBAImage;\n version?: number;\n};\n\n/**\n * @internal\n * Line bucket class\n */\nexport class LineBucket implements Bucket {\n distance: number;\n totalDistance: number;\n maxLineLength: number;\n scaledDistance: number;\n lineClips?: LineClips;\n\n e1: number;\n e2: number;\n\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n gradients: {[x: string]: GradientTexture};\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n lineClipsArray: Array;\n\n layoutVertexArray: LineLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n layoutVertexArray2: LineExtLayoutArray;\n layoutVertexBuffer2: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n this.lineClipsArray = [];\n this.gradients = {};\n this.layers.forEach(layer => {\n this.gradients[layer.id] = {};\n });\n\n this.layoutVertexArray = new LineLayoutArray();\n this.layoutVertexArray2 = new LineExtLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.maxLineLength = 0;\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('line', this.layers, options);\n const lineSortKey = this.layers[0].layout.get('line-sort-key');\n const sortFeaturesByKey = !lineSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n lineSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => {\n return (a.sortKey) - (b.sortKey);\n });\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternBucketFeature = addPatternDependencies('line', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternBucketFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n if (this.layoutVertexArray2.length !== 0) {\n this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, layoutAttributesExt);\n }\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n lineFeatureClips(feature: BucketFeature): LineClips | undefined {\n if (!!feature.properties && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_start') && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_end')) {\n const start = +feature.properties['mapbox_clip_start'];\n const end = +feature.properties['mapbox_clip_end'];\n return {start, end};\n }\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const layout = this.layers[0].layout;\n const join = layout.get('line-join').evaluate(feature, {});\n const cap = layout.get('line-cap');\n const miterLimit = layout.get('line-miter-limit');\n const roundLimit = layout.get('line-round-limit');\n this.lineClips = this.lineFeatureClips(feature);\n\n for (const line of geometry) {\n this.addLine(line, feature, join, cap, miterLimit, roundLimit);\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n\n addLine(vertices: Array, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number) {\n this.distance = 0;\n this.scaledDistance = 0;\n this.totalDistance = 0;\n\n if (this.lineClips) {\n this.lineClipsArray.push(this.lineClips);\n // Calculate the total distance, in tile units, of this tiled line feature\n for (let i = 0; i < vertices.length - 1; i++) {\n this.totalDistance += vertices[i].dist(vertices[i + 1]);\n }\n this.updateScaledDistance();\n this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);\n }\n\n const isPolygon = vectorTileFeatureTypes[feature.type] === 'Polygon';\n\n // If the line has duplicate vertices at the ends, adjust start/length to remove them.\n let len = vertices.length;\n while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) {\n len--;\n }\n let first = 0;\n while (first < len - 1 && vertices[first].equals(vertices[first + 1])) {\n first++;\n }\n\n // Ignore invalid geometry.\n if (len < (isPolygon ? 3 : 2)) return;\n\n if (join === 'bevel') miterLimit = 1.05;\n\n const sharpCornerOffset = this.overscaling <= 16 ?\n SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) :\n 0;\n\n // we could be more precise, but it would only save a negligible amount of space\n const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray);\n\n let currentVertex: Point;\n let prevVertex: Point;\n let nextVertex: Point;\n let prevNormal: Point;\n let nextNormal: Point;\n\n // the last two vertices added\n this.e1 = this.e2 = -1;\n\n if (isPolygon) {\n currentVertex = vertices[len - 2];\n nextNormal = vertices[first].sub(currentVertex)._unit()._perp();\n }\n\n for (let i = first; i < len; i++) {\n\n nextVertex = i === len - 1 ?\n (isPolygon ? vertices[first + 1] : undefined) : // if it's a polygon, treat the last vertex like the first\n vertices[i + 1]; // just the next vertex\n\n // if two consecutive vertices exist, skip the current one\n if (nextVertex && vertices[i].equals(nextVertex)) continue;\n\n if (nextNormal) prevNormal = nextNormal;\n if (currentVertex) prevVertex = currentVertex;\n\n currentVertex = vertices[i];\n\n // Calculate the normal towards the next vertex in this line. In case\n // there is no next vertex, pretend that the line is continuing straight,\n // meaning that we are just using the previous normal.\n nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal;\n\n // If we still don't have a previous normal, this is the beginning of a\n // non-closed line, so we're doing a straight \"join\".\n prevNormal = prevNormal || nextNormal;\n\n // Determine the normal of the join extrusion. It is the angle bisector\n // of the segments between the previous line and the next line.\n // In the case of 180° angles, the prev and next normals cancel each other out:\n // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be\n // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle\n // below will also become 0 and miterLength will become Infinity.\n let joinNormal = prevNormal.add(nextNormal);\n if (joinNormal.x !== 0 || joinNormal.y !== 0) {\n joinNormal._unit();\n }\n /* joinNormal prevNormal\n * ↖ ↑\n * .________. prevVertex\n * |\n * nextNormal ← | currentVertex\n * |\n * nextVertex !\n *\n */\n\n // calculate cosines of the angle (and its half) using dot product\n const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y;\n const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y;\n\n // Calculate the length of the miter (the ratio of the miter to the width)\n // as the inverse of cosine of the angle between next and join normals\n const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity;\n\n // approximate angle from cosine\n const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle);\n\n const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex;\n const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0;\n\n if (isSharpCorner && i > first) {\n const prevSegmentLength = currentVertex.dist(prevVertex);\n if (prevSegmentLength > 2 * sharpCornerOffset) {\n const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round());\n this.updateDistance(prevVertex, newPrevVertex);\n this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment);\n prevVertex = newPrevVertex;\n }\n }\n\n // The join if a middle vertex, otherwise the cap.\n const middleVertex = prevVertex && nextVertex;\n let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap;\n\n if (middleVertex && currentJoin === 'round') {\n if (miterLength < roundLimit) {\n currentJoin = 'miter';\n } else if (miterLength <= 2) {\n currentJoin = 'fakeround';\n }\n }\n\n if (currentJoin === 'miter' && miterLength > miterLimit) {\n currentJoin = 'bevel';\n }\n\n if (currentJoin === 'bevel') {\n // The maximum extrude length is 128 / 63 = 2 times the width of the line\n // so if miterLength >= 2 we need to draw a different type of bevel here.\n if (miterLength > 2) currentJoin = 'flipbevel';\n\n // If the miterLength is really small and the line bevel wouldn't be visible,\n // just draw a miter join to save a triangle.\n if (miterLength < miterLimit) currentJoin = 'miter';\n }\n\n // Calculate how far along the line the currentVertex is\n if (prevVertex) this.updateDistance(prevVertex, currentVertex);\n\n if (currentJoin === 'miter') {\n\n joinNormal._mult(miterLength);\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n\n } else if (currentJoin === 'flipbevel') {\n // miter is too big, flip the direction to make a beveled join\n\n if (miterLength > 100) {\n // Almost parallel lines\n joinNormal = nextNormal.mult(-1);\n\n } else {\n const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag();\n joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1));\n }\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment);\n\n } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') {\n const offset = -Math.sqrt(miterLength * miterLength - 1);\n const offsetA = lineTurnsLeft ? offset : 0;\n const offsetB = lineTurnsLeft ? 0 : offset;\n\n // Close previous segment with a bevel\n if (prevVertex) {\n this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment);\n }\n\n if (currentJoin === 'fakeround') {\n // The join angle is sharp enough that a round join would be visible.\n // Bevel joins fill the gap between segments with a single pie slice triangle.\n // Create a round join by adding multiple pie slices. The join isn't actually round, but\n // it looks like it is at the sizes we render lines at.\n\n // pick the number of triangles for approximating round join by based on the angle between normals\n const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE);\n\n for (let m = 1; m < n; m++) {\n let t = m / n;\n if (t !== 0.5) {\n // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp\n const t2 = t - 0.5;\n const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519));\n const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638);\n t = t + t * t2 * (t - 1) * (A * t2 * t2 + B);\n }\n const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1);\n this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment);\n }\n }\n\n if (nextVertex) {\n // Start next segment\n this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment);\n }\n\n } else if (currentJoin === 'butt') {\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap\n\n } else if (currentJoin === 'square') {\n const offset = prevVertex ? 1 : -1; // closing or starting square cap\n this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment);\n\n } else if (currentJoin === 'round') {\n\n if (prevVertex) {\n // Close previous segment with butt\n this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment);\n\n // Add round cap or linejoin at end of segment\n this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true);\n }\n if (nextVertex) {\n // Add round cap before first segment\n this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true);\n\n // Start next segment with a butt\n this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment);\n }\n }\n\n if (isSharpCorner && i < len - 1) {\n const nextSegmentLength = currentVertex.dist(nextVertex);\n if (nextSegmentLength > 2 * sharpCornerOffset) {\n const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round());\n this.updateDistance(currentVertex, newCurrentVertex);\n this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment);\n currentVertex = newCurrentVertex;\n }\n }\n }\n }\n\n /**\n * Add two vertices to the buffers.\n *\n * @param p - the line vertex to add buffer vertices for\n * @param normal - vertex normal\n * @param endLeft - extrude to shift the left vertex along the line\n * @param endRight - extrude to shift the left vertex along the line\n * @param segment - the segment object to add the vertex to\n * @param round - whether this is a round cap\n */\n addCurrentVertex(p: Point, normal: Point, endLeft: number, endRight: number, segment: Segment, round: boolean = false) {\n // left and right extrude vectors, perpendicularly shifted by endLeft/endRight\n const leftX = normal.x + normal.y * endLeft;\n const leftY = normal.y - normal.x * endLeft;\n const rightX = -normal.x + normal.y * endRight;\n const rightY = -normal.y - normal.x * endRight;\n\n this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment);\n this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment);\n\n // There is a maximum \"distance along the line\" that we can store in the buffers.\n // When we get close to the distance, reset it to zero and add the vertex again with\n // a distance of zero. The max distance is determined by the number of bits we allocate\n // to `linesofar`.\n if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) {\n this.distance = 0;\n this.updateScaledDistance();\n this.addCurrentVertex(p, normal, endLeft, endRight, segment, round);\n }\n }\n\n addHalfVertex({x, y}: Point, extrudeX: number, extrudeY: number, round: boolean, up: boolean, dir: number, segment: Segment) {\n const totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance;\n // scale down so that we can store longer distances while sacrificing precision.\n const linesofarScaled = totalDistance * LINE_DISTANCE_SCALE;\n\n this.layoutVertexArray.emplaceBack(\n // a_pos_normal\n // Encode round/up the least significant bits\n (x << 1) + (round ? 1 : 0),\n (y << 1) + (up ? 1 : 0),\n // a_data\n // add 128 to store a byte in an unsigned byte\n Math.round(EXTRUDE_SCALE * extrudeX) + 128,\n Math.round(EXTRUDE_SCALE * extrudeY) + 128,\n // Encode the -1/0/1 direction value into the first two bits of .z of a_data.\n // Combine it with the lower 6 bits of `linesofarScaled` (shifted by 2 bits to make\n // room for the direction value). The upper 8 bits of `linesofarScaled` are placed in\n // the `w` component.\n ((dir === 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofarScaled & 0x3F) << 2),\n linesofarScaled >> 6);\n\n // Constructs a second vertex buffer with higher precision line progress\n if (this.lineClips) {\n const progressRealigned = this.scaledDistance - this.lineClips.start;\n const endClipRealigned = this.lineClips.end - this.lineClips.start;\n const uvX = progressRealigned / endClipRealigned;\n this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length);\n }\n\n const e = segment.vertexLength++;\n if (this.e1 >= 0 && this.e2 >= 0) {\n this.indexArray.emplaceBack(this.e1, this.e2, e);\n segment.primitiveLength++;\n }\n if (up) {\n this.e2 = e;\n } else {\n this.e1 = e;\n }\n }\n\n updateScaledDistance() {\n // Knowing the ratio of the full linestring covered by this tiled feature, as well\n // as the total distance (in tile units) of this tiled feature, and the distance\n // (in tile units) of the current vertex, we can determine the relative distance\n // of this vertex along the full linestring feature and scale it to [0, 2^15)\n this.scaledDistance = this.lineClips ?\n this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance :\n this.distance;\n }\n\n updateDistance(prev: Point, next: Point) {\n this.distance += prev.dist(next);\n this.updateScaledDistance();\n }\n}\n\nregister('LineBucket', LineBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LineLayoutProps = {\n \"line-cap\": DataConstantProperty<\"butt\" | \"round\" | \"square\">,\n \"line-join\": DataDrivenProperty<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": DataConstantProperty,\n \"line-round-limit\": DataConstantProperty,\n \"line-sort-key\": DataDrivenProperty,\n};\n\nexport type LineLayoutPropsPossiblyEvaluated = {\n \"line-cap\": \"butt\" | \"round\" | \"square\",\n \"line-join\": PossiblyEvaluatedPropertyValue<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": number,\n \"line-round-limit\": number,\n \"line-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"line-cap\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-cap\"] as any as StylePropertySpecification),\n \"line-join\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-join\"] as any as StylePropertySpecification),\n \"line-miter-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-miter-limit\"] as any as StylePropertySpecification),\n \"line-round-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-round-limit\"] as any as StylePropertySpecification),\n \"line-sort-key\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type LinePaintProps = {\n \"line-opacity\": DataDrivenProperty,\n \"line-color\": DataDrivenProperty,\n \"line-translate\": DataConstantProperty<[number, number]>,\n \"line-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"line-width\": DataDrivenProperty,\n \"line-gap-width\": DataDrivenProperty,\n \"line-offset\": DataDrivenProperty,\n \"line-blur\": DataDrivenProperty,\n \"line-dasharray\": CrossFadedProperty>,\n \"line-pattern\": CrossFadedDataDrivenProperty,\n \"line-gradient\": ColorRampProperty,\n};\n\nexport type LinePaintPropsPossiblyEvaluated = {\n \"line-opacity\": PossiblyEvaluatedPropertyValue,\n \"line-color\": PossiblyEvaluatedPropertyValue,\n \"line-translate\": [number, number],\n \"line-translate-anchor\": \"map\" | \"viewport\",\n \"line-width\": PossiblyEvaluatedPropertyValue,\n \"line-gap-width\": PossiblyEvaluatedPropertyValue,\n \"line-offset\": PossiblyEvaluatedPropertyValue,\n \"line-blur\": PossiblyEvaluatedPropertyValue,\n \"line-dasharray\": CrossFaded>,\n \"line-pattern\": PossiblyEvaluatedPropertyValue>,\n \"line-gradient\": ColorRampProperty,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"line-opacity\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-opacity\"] as any as StylePropertySpecification),\n \"line-color\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-color\"] as any as StylePropertySpecification),\n \"line-translate\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate\"] as any as StylePropertySpecification),\n \"line-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate-anchor\"] as any as StylePropertySpecification),\n \"line-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-width\"] as any as StylePropertySpecification),\n \"line-gap-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-gap-width\"] as any as StylePropertySpecification),\n \"line-offset\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-offset\"] as any as StylePropertySpecification),\n \"line-blur\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-blur\"] as any as StylePropertySpecification),\n \"line-dasharray\": new CrossFadedProperty(styleSpec[\"paint_line\"][\"line-dasharray\"] as any as StylePropertySpecification),\n \"line-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_line\"][\"line-pattern\"] as any as StylePropertySpecification),\n \"line-gradient\": new ColorRampProperty(styleSpec[\"paint_line\"][\"line-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import Point from '@mapbox/point-geometry';\n\nimport {StyleLayer} from '../style_layer';\nimport {LineBucket} from '../../data/bucket/line_bucket';\nimport {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate, offsetLine} from '../query_utils';\nimport properties, {LineLayoutPropsPossiblyEvaluated, LinePaintPropsPossiblyEvaluated} from './line_style_layer_properties.g';\nimport {extend} from '../../util/util';\nimport {EvaluationParameters} from '../evaluation_parameters';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties';\n\nimport {isZoomExpression, Step} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {LineLayoutProps, LinePaintProps} from './line_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class LineFloorwidthProperty extends DataDrivenProperty {\n useIntegerZoom: true;\n\n possiblyEvaluate(value, parameters) {\n parameters = new EvaluationParameters(Math.floor(parameters.zoom), {\n now: parameters.now,\n fadeDuration: parameters.fadeDuration,\n zoomHistory: parameters.zoomHistory,\n transition: parameters.transition\n });\n return super.possiblyEvaluate(value, parameters);\n }\n\n evaluate(value, globals, feature, featureState) {\n globals = extend({}, globals, {zoom: Math.floor(globals.zoom)});\n return super.evaluate(value, globals, feature, featureState);\n }\n}\n\nlet lineFloorwidthProperty: LineFloorwidthProperty;\n\nexport class LineStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n gradientVersion: number;\n stepInterpolant: boolean;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n this.gradientVersion = 0;\n if (!lineFloorwidthProperty) {\n lineFloorwidthProperty =\n new LineFloorwidthProperty(properties.paint.properties['line-width'].specification);\n lineFloorwidthProperty.useIntegerZoom = true;\n }\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'line-gradient') {\n const expression = this.gradientExpression();\n if (isZoomExpression(expression)) {\n this.stepInterpolant = expression._styleExpression.expression instanceof Step;\n } else {\n this.stepInterpolant = false;\n }\n this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;\n }\n }\n\n gradientExpression() {\n return this._transitionablePaint._values['line-gradient'].value.expression;\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n (this.paint._values as any)['line-floorwidth'] =\n lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values['line-width'].value, parameters);\n }\n\n createBucket(parameters: BucketParameters) {\n return new LineBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const lineBucket: LineBucket = (bucket as any);\n const width = getLineWidth(\n getMaximumPaintValue('line-width', this, lineBucket),\n getMaximumPaintValue('line-gap-width', this, lineBucket));\n const offset = getMaximumPaintValue('line-offset', this, lineBucket);\n return width / 2 + Math.abs(offset) + translateDistance(this.paint.get('line-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('line-translate'),\n this.paint.get('line-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const halfWidth = pixelsToTileUnits / 2 * getLineWidth(\n this.paint.get('line-width').evaluate(feature, featureState),\n this.paint.get('line-gap-width').evaluate(feature, featureState));\n const lineOffset = this.paint.get('line-offset').evaluate(feature, featureState);\n if (lineOffset) {\n geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits);\n }\n\n return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth);\n }\n\n isTileClipped() {\n return true;\n }\n}\n\nfunction getLineWidth(lineWidth, lineGapWidth) {\n if (lineGapWidth > 0) {\n return lineGapWidth + 2 * lineWidth;\n } else {\n return lineWidth;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const symbolLayoutAttributes = createLayout([\n {name: 'a_pos_offset', components: 4, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint16'},\n {name: 'a_pixeloffset', components: 4, type: 'Int16'}\n], 4);\n\nexport const dynamicLayoutAttributes = createLayout([\n {name: 'a_projected_pos', components: 3, type: 'Float32'}\n], 4);\n\nexport const placementOpacityAttributes = createLayout([\n {name: 'a_fade_opacity', components: 1, type: 'Uint32'}\n], 4);\n\nexport const collisionVertexAttributes = createLayout([\n {name: 'a_placed', components: 2, type: 'Uint8'},\n {name: 'a_shift', components: 2, type: 'Float32'}\n]);\n\nexport const collisionBox = createLayout([\n // the box is centered around the anchor point\n {type: 'Int16', name: 'anchorPointX'},\n {type: 'Int16', name: 'anchorPointY'},\n\n // distances to the edges from the anchor\n {type: 'Int16', name: 'x1'},\n {type: 'Int16', name: 'y1'},\n {type: 'Int16', name: 'x2'},\n {type: 'Int16', name: 'y2'},\n\n // the index of the feature in the original vectortile\n {type: 'Uint32', name: 'featureIndex'},\n // the source layer the feature appears in\n {type: 'Uint16', name: 'sourceLayerIndex'},\n // the bucket the feature appears in\n {type: 'Uint16', name: 'bucketIndex'},\n]);\n\nexport const collisionBoxLayout = createLayout([ // used to render collision boxes for debugging purposes\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_anchor_pos', components: 2, type: 'Int16'},\n {name: 'a_extrude', components: 2, type: 'Int16'}\n], 4);\n\nexport const collisionCircleLayout = createLayout([ // used to render collision circles for debugging purposes\n {name: 'a_pos', components: 2, type: 'Float32'},\n {name: 'a_radius', components: 1, type: 'Float32'},\n {name: 'a_flags', components: 2, type: 'Int16'}\n], 4);\n\nexport const quadTriangle = createLayout([\n {name: 'triangle', components: 3, type: 'Uint16'},\n]);\n\nexport const placement = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Uint16', name: 'glyphStartIndex'},\n {type: 'Uint16', name: 'numGlyphs'},\n {type: 'Uint32', name: 'vertexStartIndex'},\n {type: 'Uint32', name: 'lineStartIndex'},\n {type: 'Uint32', name: 'lineLength'},\n {type: 'Uint16', name: 'segment'},\n {type: 'Uint16', name: 'lowerSize'},\n {type: 'Uint16', name: 'upperSize'},\n {type: 'Float32', name: 'lineOffsetX'},\n {type: 'Float32', name: 'lineOffsetY'},\n {type: 'Uint8', name: 'writingMode'},\n {type: 'Uint8', name: 'placedOrientation'},\n {type: 'Uint8', name: 'hidden'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Int16', name: 'associatedIconIndex'}\n]);\n\nexport const symbolInstance = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Int16', name: 'rightJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'centerJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'leftJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedTextSymbolIndex'},\n {type: 'Int16', name: 'placedIconSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedIconSymbolIndex'},\n {type: 'Uint16', name: 'key'},\n {type: 'Uint16', name: 'textBoxStartIndex'},\n {type: 'Uint16', name: 'textBoxEndIndex'},\n {type: 'Uint16', name: 'verticalTextBoxStartIndex'},\n {type: 'Uint16', name: 'verticalTextBoxEndIndex'},\n {type: 'Uint16', name: 'iconBoxStartIndex'},\n {type: 'Uint16', name: 'iconBoxEndIndex'},\n {type: 'Uint16', name: 'verticalIconBoxStartIndex'},\n {type: 'Uint16', name: 'verticalIconBoxEndIndex'},\n {type: 'Uint16', name: 'featureIndex'},\n {type: 'Uint16', name: 'numHorizontalGlyphVertices'},\n {type: 'Uint16', name: 'numVerticalGlyphVertices'},\n {type: 'Uint16', name: 'numIconVertices'},\n {type: 'Uint16', name: 'numVerticalIconVertices'},\n {type: 'Uint16', name: 'useRuntimeCollisionCircles'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Float32', name: 'textBoxScale'},\n {type: 'Float32', name: 'collisionCircleDiameter'},\n {type: 'Uint16', name: 'textAnchorOffsetStartIndex'},\n {type: 'Uint16', name: 'textAnchorOffsetEndIndex'}\n]);\n\nexport const glyphOffset = createLayout([\n {type: 'Float32', name: 'offsetX'}\n]);\n\nexport const lineVertex = createLayout([\n {type: 'Int16', name: 'x'},\n {type: 'Int16', name: 'y'},\n {type: 'Int16', name: 'tileUnitDistanceFromAnchor'}\n]);\n\nexport const textAnchorOffset = createLayout([\n {type: 'Uint16', name: 'textAnchor'},\n {type: 'Float32', components: 2, name: 'textOffset'}\n]);\n","import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport {Formatted} from '@maplibre/maplibre-gl-style-spec';\n\nfunction transformTextInternal(text: string, layer: SymbolStyleLayer, feature: Feature) {\n const transform = layer.layout.get('text-transform').evaluate(feature, {});\n if (transform === 'uppercase') {\n text = text.toLocaleUpperCase();\n } else if (transform === 'lowercase') {\n text = text.toLocaleLowerCase();\n }\n\n if (rtlTextPlugin.applyArabicShaping) {\n text = rtlTextPlugin.applyArabicShaping(text);\n }\n\n return text;\n}\n\nexport function transformText(text: Formatted, layer: SymbolStyleLayer, feature: Feature): Formatted {\n text.sections.forEach(section => {\n section.text = transformTextInternal(section.text, layer, feature);\n });\n return text;\n}\n","import {charHasRotatedVerticalOrientation} from './script_detection';\n\nexport const verticalizedCharacterMap = {\n '!': '︕',\n '#': '#',\n '$': '$',\n '%': '%',\n '&': '&',\n '(': '︵',\n ')': '︶',\n '*': '*',\n '+': '+',\n ',': '︐',\n '-': '︲',\n '.': '・',\n '/': '/',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '=': '=',\n '>': '﹀',\n '?': '︖',\n '@': '@',\n '[': '﹇',\n '\\\\': '\',\n ']': '﹈',\n '^': '^',\n '_': '︳',\n '`': '`',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '~': '~',\n '¢': '¢',\n '£': '£',\n '¥': '¥',\n '¦': '¦',\n '¬': '¬',\n '¯': ' ̄',\n '–': '︲',\n '—': '︱',\n '‘': '﹃',\n '’': '﹄',\n '“': '﹁',\n '”': '﹂',\n '…': '︙',\n '‧': '・',\n '₩': '₩',\n '、': '︑',\n '。': '︒',\n '〈': '︿',\n '〉': '﹀',\n '《': '︽',\n '》': '︾',\n '「': '﹁',\n '」': '﹂',\n '『': '﹃',\n '』': '﹄',\n '【': '︻',\n '】': '︼',\n '〔': '︹',\n '〕': '︺',\n '〖': '︗',\n '〗': '︘',\n '!': '︕',\n '(': '︵',\n ')': '︶',\n ',': '︐',\n '-': '︲',\n '.': '・',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '>': '﹀',\n '?': '︖',\n '[': '﹇',\n ']': '﹈',\n '_': '︳',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '⦅': '︵',\n '⦆': '︶',\n '。': '︒',\n '「': '﹁',\n '」': '﹂'\n};\n\nexport function verticalizePunctuation(input: string) {\n let output = '';\n\n for (let i = 0; i < input.length; i++) {\n const nextCharCode = input.charCodeAt(i + 1) || null;\n const prevCharCode = input.charCodeAt(i - 1) || null;\n\n const canReplacePunctuation = (\n (!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) &&\n (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]])\n );\n\n if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) {\n output += verticalizedCharacterMap[input[i]];\n } else {\n output += input[i];\n }\n }\n\n return output;\n}\n\n","// ONE_EM constant used to go between \"em\" units used in style spec and \"points\" used internally for layout\n\nexport default 24;\n","'use strict';\n\nmodule.exports = Pbf;\n\nvar ieee754 = require('ieee754');\n\nfunction Pbf(buf) {\n this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n}\n\nPbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum\nPbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64\nPbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields\nPbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32\n\nvar SHIFT_LEFT_32 = (1 << 16) * (1 << 16),\n SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n\n// Threshold chosen based on both benchmarking and knowledge about browser string\n// data structures (which currently switch structure types at 12 bytes or more)\nvar TEXT_DECODER_MIN_LENGTH = 12;\nvar utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');\n\nPbf.prototype = {\n\n destroy: function() {\n this.buf = null;\n },\n\n // === READING =================================================================\n\n readFields: function(readField, result, end) {\n end = end || this.length;\n\n while (this.pos < end) {\n var val = this.readVarint(),\n tag = val >> 3,\n startPos = this.pos;\n\n this.type = val & 0x7;\n readField(tag, result, this);\n\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n },\n\n readMessage: function(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n },\n\n readFixed32: function() {\n var val = readUInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n readSFixed32: function() {\n var val = readInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n\n readFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readSFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readFloat: function() {\n var val = ieee754.read(this.buf, this.pos, true, 23, 4);\n this.pos += 4;\n return val;\n },\n\n readDouble: function() {\n var val = ieee754.read(this.buf, this.pos, true, 52, 8);\n this.pos += 8;\n return val;\n },\n\n readVarint: function(isSigned) {\n var buf = this.buf,\n val, b;\n\n b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;\n b = buf[this.pos]; val |= (b & 0x0f) << 28;\n\n return readVarintRemainder(val, isSigned, this);\n },\n\n readVarint64: function() { // for compatibility with v2.0.1\n return this.readVarint(true);\n },\n\n readSVarint: function() {\n var num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding\n },\n\n readBoolean: function() {\n return Boolean(this.readVarint());\n },\n\n readString: function() {\n var end = this.readVarint() + this.pos;\n var pos = this.pos;\n this.pos = end;\n\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n // longer strings are fast with the built-in browser TextDecoder API\n return readUtf8TextDecoder(this.buf, pos, end);\n }\n // short strings are fast with our custom implementation\n return readUtf8(this.buf, pos, end);\n },\n\n readBytes: function() {\n var end = this.readVarint() + this.pos,\n buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n },\n\n // verbose for performance reasons; doesn't affect gzipped size\n\n readPackedVarint: function(arr, isSigned) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n },\n readPackedSVarint: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n },\n readPackedBoolean: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n },\n readPackedFloat: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n },\n readPackedDouble: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n },\n readPackedFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n },\n readPackedSFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n },\n readPackedFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n },\n readPackedSFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n },\n\n skip: function(val) {\n var type = val & 0x7;\n if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}\n else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;\n else if (type === Pbf.Fixed32) this.pos += 4;\n else if (type === Pbf.Fixed64) this.pos += 8;\n else throw new Error('Unimplemented type: ' + type);\n },\n\n // === WRITING =================================================================\n\n writeTag: function(tag, type) {\n this.writeVarint((tag << 3) | type);\n },\n\n realloc: function(min) {\n var length = this.length || 16;\n\n while (length < this.pos + min) length *= 2;\n\n if (length !== this.length) {\n var buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.length = length;\n }\n },\n\n finish: function() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n },\n\n writeFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeSFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeSFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeVarint: function(val) {\n val = +val || 0;\n\n if (val > 0xfffffff || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n\n this.realloc(4);\n\n this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = (val >>> 7) & 0x7f;\n },\n\n writeSVarint: function(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n },\n\n writeBoolean: function(val) {\n this.writeVarint(Boolean(val));\n },\n\n writeString: function(str) {\n str = String(str);\n this.realloc(str.length * 4);\n\n this.pos++; // reserve 1 byte for short string length\n\n var startPos = this.pos;\n // write the string directly to the buffer and see how much was written\n this.pos = writeUtf8(this.buf, str, this.pos);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeFloat: function(val) {\n this.realloc(4);\n ieee754.write(this.buf, val, this.pos, true, 23, 4);\n this.pos += 4;\n },\n\n writeDouble: function(val) {\n this.realloc(8);\n ieee754.write(this.buf, val, this.pos, true, 52, 8);\n this.pos += 8;\n },\n\n writeBytes: function(buffer) {\n var len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n },\n\n writeRawMessage: function(fn, obj) {\n this.pos++; // reserve 1 byte for short message length\n\n // write the message directly to the buffer and see how much was written\n var startPos = this.pos;\n fn(obj, this);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeMessage: function(tag, fn, obj) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeRawMessage(fn, obj);\n },\n\n writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },\n writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },\n writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },\n writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },\n writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },\n writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },\n writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },\n writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },\n writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },\n\n writeBytesField: function(tag, buffer) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeBytes(buffer);\n },\n writeFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFixed32(val);\n },\n writeSFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeSFixed32(val);\n },\n writeFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeFixed64(val);\n },\n writeSFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeSFixed64(val);\n },\n writeVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeVarint(val);\n },\n writeSVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeSVarint(val);\n },\n writeStringField: function(tag, str) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeString(str);\n },\n writeFloatField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFloat(val);\n },\n writeDoubleField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeDouble(val);\n },\n writeBooleanField: function(tag, val) {\n this.writeVarintField(tag, Boolean(val));\n }\n};\n\nfunction readVarintRemainder(l, s, p) {\n var buf = p.buf,\n h, b;\n\n b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);\n\n throw new Error('Expected varint not more than 10 bytes');\n}\n\nfunction readPackedEnd(pbf) {\n return pbf.type === Pbf.Bytes ?\n pbf.readVarint() + pbf.pos : pbf.pos + 1;\n}\n\nfunction toNum(low, high, isSigned) {\n if (isSigned) {\n return high * 0x100000000 + (low >>> 0);\n }\n\n return ((high >>> 0) * 0x100000000) + (low >>> 0);\n}\n\nfunction writeBigVarint(val, pbf) {\n var low, high;\n\n if (val >= 0) {\n low = (val % 0x100000000) | 0;\n high = (val / 0x100000000) | 0;\n } else {\n low = ~(-val % 0x100000000);\n high = ~(-val / 0x100000000);\n\n if (low ^ 0xffffffff) {\n low = (low + 1) | 0;\n } else {\n low = 0;\n high = (high + 1) | 0;\n }\n }\n\n if (val >= 0x10000000000000000 || val < -0x10000000000000000) {\n throw new Error('Given varint doesn\\'t fit into 10 bytes');\n }\n\n pbf.realloc(10);\n\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n}\n\nfunction writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos] = low & 0x7f;\n}\n\nfunction writeBigVarintHigh(high, pbf) {\n var lsb = (high & 0x07) << 4;\n\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f;\n}\n\nfunction makeRoomForExtraLength(startPos, len, pbf) {\n var extraLen =\n len <= 0x3fff ? 1 :\n len <= 0x1fffff ? 2 :\n len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n\n // if 1 byte isn't enough for encoding message length, shift the data to the right\n pbf.realloc(extraLen);\n for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n}\n\nfunction writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }\nfunction writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }\nfunction writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }\nfunction writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }\nfunction writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }\nfunction writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }\nfunction writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }\nfunction writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }\nfunction writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }\n\n// Buffer code below from https://github.com/feross/buffer, MIT-licensed\n\nfunction readUInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] * 0x1000000);\n}\n\nfunction writeInt32(buf, val, pos) {\n buf[pos] = val;\n buf[pos + 1] = (val >>> 8);\n buf[pos + 2] = (val >>> 16);\n buf[pos + 3] = (val >>> 24);\n}\n\nfunction readInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] << 24);\n}\n\nfunction readUtf8(buf, pos, end) {\n var str = '';\n var i = pos;\n\n while (i < end) {\n var b0 = buf[i];\n var c = null; // codepoint\n var bytesPerSequence =\n b0 > 0xEF ? 4 :\n b0 > 0xDF ? 3 :\n b0 > 0xBF ? 2 : 1;\n\n if (i + bytesPerSequence > end) break;\n\n var b1, b2, b3;\n\n if (bytesPerSequence === 1) {\n if (b0 < 0x80) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 0xC0) === 0x80) {\n c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);\n if (c <= 0x7F) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);\n if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);\n if (c <= 0xFFFF || c >= 0x110000) {\n c = null;\n }\n }\n }\n\n if (c === null) {\n c = 0xFFFD;\n bytesPerSequence = 1;\n\n } else if (c > 0xFFFF) {\n c -= 0x10000;\n str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);\n c = 0xDC00 | c & 0x3FF;\n }\n\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n\n return str;\n}\n\nfunction readUtf8TextDecoder(buf, pos, end) {\n return utf8TextDecoder.decode(buf.subarray(pos, end));\n}\n\nfunction writeUtf8(buf, str, pos) {\n for (var i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i); // code point\n\n if (c > 0xD7FF && c < 0xE000) {\n if (lead) {\n if (c < 0xDC00) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = c;\n continue;\n } else {\n c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;\n lead = null;\n }\n } else {\n if (c > 0xDBFF || (i + 1 === str.length)) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = null;\n }\n\n if (c < 0x80) {\n buf[pos++] = c;\n } else {\n if (c < 0x800) {\n buf[pos++] = c >> 0x6 | 0xC0;\n } else {\n if (c < 0x10000) {\n buf[pos++] = c >> 0xC | 0xE0;\n } else {\n buf[pos++] = c >> 0x12 | 0xF0;\n buf[pos++] = c >> 0xC & 0x3F | 0x80;\n }\n buf[pos++] = c >> 0x6 & 0x3F | 0x80;\n }\n buf[pos++] = c & 0x3F | 0x80;\n }\n }\n return pos;\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","import {AlphaImage} from '../util/image';\n\nimport Protobuf from 'pbf';\nconst border = 3;\n\nimport type {StyleGlyph} from './style_glyph';\n\nfunction readFontstacks(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 1) {\n pbf.readMessage(readFontstack, glyphs);\n }\n}\n\nfunction readFontstack(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 3) {\n const {id, bitmap, width, height, left, top, advance} = pbf.readMessage(readGlyph, {});\n glyphs.push({\n id,\n bitmap: new AlphaImage({\n width: width + 2 * border,\n height: height + 2 * border\n }, bitmap),\n metrics: {width, height, left, top, advance}\n });\n }\n}\n\nfunction readGlyph(tag: number, glyph: any, pbf: Protobuf) {\n if (tag === 1) glyph.id = pbf.readVarint();\n else if (tag === 2) glyph.bitmap = pbf.readBytes();\n else if (tag === 3) glyph.width = pbf.readVarint();\n else if (tag === 4) glyph.height = pbf.readVarint();\n else if (tag === 5) glyph.left = pbf.readSVarint();\n else if (tag === 6) glyph.top = pbf.readSVarint();\n else if (tag === 7) glyph.advance = pbf.readVarint();\n}\n\nexport function parseGlyphPbf(data: ArrayBuffer | Uint8Array): Array {\n return new Protobuf(data).readFields(readFontstacks, []);\n}\n\nexport const GLYPH_PBF_BORDER = border;\n","\nexport default function potpack(boxes) {\n\n // calculate total box area and maximum box width\n let area = 0;\n let maxWidth = 0;\n\n for (const box of boxes) {\n area += box.w * box.h;\n maxWidth = Math.max(maxWidth, box.w);\n }\n\n // sort the boxes for insertion by height, descending\n boxes.sort((a, b) => b.h - a.h);\n\n // aim for a squarish resulting container,\n // slightly adjusted for sub-100% space utilization\n const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth);\n\n // start with a single empty space, unbounded at the bottom\n const spaces = [{x: 0, y: 0, w: startWidth, h: Infinity}];\n\n let width = 0;\n let height = 0;\n\n for (const box of boxes) {\n // look through spaces backwards so that we check smaller spaces first\n for (let i = spaces.length - 1; i >= 0; i--) {\n const space = spaces[i];\n\n // look for empty spaces that can accommodate the current box\n if (box.w > space.w || box.h > space.h) continue;\n\n // found the space; add the box to its top-left corner\n // |-------|-------|\n // | box | |\n // |_______| |\n // | space |\n // |_______________|\n box.x = space.x;\n box.y = space.y;\n\n height = Math.max(height, box.y + box.h);\n width = Math.max(width, box.x + box.w);\n\n if (box.w === space.w && box.h === space.h) {\n // space matches the box exactly; remove it\n const last = spaces.pop();\n if (i < spaces.length) spaces[i] = last;\n\n } else if (box.h === space.h) {\n // space matches the box height; update it accordingly\n // |-------|---------------|\n // | box | updated space |\n // |_______|_______________|\n space.x += box.w;\n space.w -= box.w;\n\n } else if (box.w === space.w) {\n // space matches the box width; update it accordingly\n // |---------------|\n // | box |\n // |_______________|\n // | updated space |\n // |_______________|\n space.y += box.h;\n space.h -= box.h;\n\n } else {\n // otherwise the box splits the space into two spaces\n // |-------|-----------|\n // | box | new space |\n // |_______|___________|\n // | updated space |\n // |___________________|\n spaces.push({\n x: space.x + box.w,\n y: space.y,\n w: space.w - box.w,\n h: box.h\n });\n space.y += box.h;\n space.h -= box.h;\n }\n break;\n }\n }\n\n return {\n w: width, // container width\n h: height, // container height\n fill: (area / (width * height)) || 0 // space utilization\n };\n}\n","/* eslint-disable key-spacing */\nimport {RGBAImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {ImageManager} from './image_manager';\nimport type {Texture} from './texture';\nimport type {Rect} from './glyph_atlas';\n\nconst IMAGE_PADDING: number = 1;\nexport {IMAGE_PADDING};\n\nexport class ImagePosition {\n paddedRect: Rect;\n pixelRatio: number;\n version: number;\n stretchY: Array<[number, number]>;\n stretchX: Array<[number, number]>;\n content: [number, number, number, number];\n\n constructor(paddedRect: Rect, {\n pixelRatio,\n version,\n stretchX,\n stretchY,\n content\n }: StyleImage) {\n this.paddedRect = paddedRect;\n this.pixelRatio = pixelRatio;\n this.stretchX = stretchX;\n this.stretchY = stretchY;\n this.content = content;\n this.version = version;\n }\n\n get tl(): [number, number] {\n return [\n this.paddedRect.x + IMAGE_PADDING,\n this.paddedRect.y + IMAGE_PADDING\n ];\n }\n\n get br(): [number, number] {\n return [\n this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING,\n this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING\n ];\n }\n\n get tlbr(): Array {\n return this.tl.concat(this.br);\n }\n\n get displaySize(): [number, number] {\n return [\n (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio,\n (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio\n ];\n }\n}\n\n/**\n * @internal\n * A class holding all the images\n */\nexport class ImageAtlas {\n image: RGBAImage;\n iconPositions: {[_: string]: ImagePosition};\n patternPositions: {[_: string]: ImagePosition};\n haveRenderCallbacks: Array;\n uploaded: boolean;\n\n constructor(icons: {[_: string]: StyleImage}, patterns: {[_: string]: StyleImage}) {\n const iconPositions = {}, patternPositions = {};\n this.haveRenderCallbacks = [];\n\n const bins = [];\n\n this.addImages(icons, iconPositions, bins);\n this.addImages(patterns, patternPositions, bins);\n\n const {w, h} = potpack(bins);\n const image = new RGBAImage({width: w || 1, height: h || 1});\n\n for (const id in icons) {\n const src = icons[id];\n const bin = iconPositions[id].paddedRect;\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: bin.x + IMAGE_PADDING, y: bin.y + IMAGE_PADDING}, src.data);\n }\n\n for (const id in patterns) {\n const src = patterns[id];\n const bin = patternPositions[id].paddedRect;\n const x = bin.x + IMAGE_PADDING,\n y = bin.y + IMAGE_PADDING,\n w = src.data.width,\n h = src.data.height;\n\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y}, src.data);\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src.data, image, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src.data, image, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.image = image;\n this.iconPositions = iconPositions;\n this.patternPositions = patternPositions;\n }\n\n addImages(images: {[_: string]: StyleImage}, positions: {[_: string]: ImagePosition}, bins: Array) {\n for (const id in images) {\n const src = images[id];\n const bin = {\n x: 0,\n y: 0,\n w: src.data.width + 2 * IMAGE_PADDING,\n h: src.data.height + 2 * IMAGE_PADDING,\n };\n bins.push(bin);\n positions[id] = new ImagePosition(bin, src);\n\n if (src.hasRenderCallback) {\n this.haveRenderCallbacks.push(id);\n }\n }\n }\n\n patchUpdatedImages(imageManager: ImageManager, texture: Texture) {\n imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks);\n for (const name in imageManager.updatedImages) {\n this.patchUpdatedImage(this.iconPositions[name], imageManager.getImage(name), texture);\n this.patchUpdatedImage(this.patternPositions[name], imageManager.getImage(name), texture);\n }\n }\n\n patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture) {\n if (!position || !image) return;\n\n if (position.version === image.version) return;\n\n position.version = image.version;\n const [x, y] = position.tl;\n texture.update(image.data, undefined, {x, y});\n }\n\n}\n\nregister('ImagePosition', ImagePosition);\nregister('ImageAtlas', ImageAtlas);\n","import {\n charHasUprightVerticalOrientation,\n charAllowsIdeographicBreaking,\n charInComplexShapingScript\n} from '../util/script_detection';\nimport {verticalizePunctuation} from '../util/verticalize_punctuation';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\nimport ONE_EM from './one_em';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleGlyph, GlyphMetrics} from '../style/style_glyph';\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\nimport type {ImagePosition} from '../render/image_atlas';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {Rect, GlyphPosition} from '../render/glyph_atlas';\nimport {Formatted, FormattedSection} from '@maplibre/maplibre-gl-style-spec';\n\nenum WritingMode {\n none = 0,\n horizontal = 1,\n vertical = 2,\n horizontalOnly = 3\n}\n\nconst SHAPING_DEFAULT_OFFSET = -17;\nexport {shapeText, shapeIcon, fitIconToText, getAnchorAlignment, WritingMode, SHAPING_DEFAULT_OFFSET};\n\n// The position of a glyph relative to the text's anchor point.\nexport type PositionedGlyph = {\n glyph: number;\n imageName: string | null;\n x: number;\n y: number;\n vertical: boolean;\n scale: number;\n fontStack: string;\n sectionIndex: number;\n metrics: GlyphMetrics;\n rect: Rect | null;\n};\n\nexport type PositionedLine = {\n positionedGlyphs: Array;\n lineOffset: number;\n};\n\n// A collection of positioned glyphs and some metadata\nexport type Shaping = {\n positionedLines: Array;\n top: number;\n bottom: number;\n left: number;\n right: number;\n writingMode: WritingMode.horizontal | WritingMode.vertical;\n text: string;\n iconsInText: boolean;\n verticalizable: boolean;\n};\n\nfunction isEmpty(positionedLines: Array) {\n for (const line of positionedLines) {\n if (line.positionedGlyphs.length !== 0) {\n return false;\n }\n }\n return true;\n}\n\nexport type SymbolAnchor = 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\nexport type TextJustify = 'left' | 'center' | 'right';\n\n// Max number of images in label is 6401 U+E000–U+F8FF that covers\n// Basic Multilingual Plane Unicode Private Use Area (PUA).\nconst PUAbegin = 0xE000;\nconst PUAend = 0xF8FF;\n\nclass SectionOptions {\n // Text options\n scale: number;\n fontStack: string;\n // Image options\n imageName: string | null;\n\n constructor() {\n this.scale = 1.0;\n this.fontStack = '';\n this.imageName = null;\n }\n\n static forText(scale: number | null, fontStack: string) {\n const textOptions = new SectionOptions();\n textOptions.scale = scale || 1;\n textOptions.fontStack = fontStack;\n return textOptions;\n }\n\n static forImage(imageName: string) {\n const imageOptions = new SectionOptions();\n imageOptions.imageName = imageName;\n return imageOptions;\n }\n\n}\n\nclass TaggedString {\n text: string;\n sectionIndex: Array; // maps each character in 'text' to its corresponding entry in 'sections'\n sections: Array;\n imageSectionID: number | null;\n\n constructor() {\n this.text = '';\n this.sectionIndex = [];\n this.sections = [];\n this.imageSectionID = null;\n }\n\n static fromFeature(text: Formatted, defaultFontStack: string) {\n const result = new TaggedString();\n for (let i = 0; i < text.sections.length; i++) {\n const section = text.sections[i];\n if (!section.image) {\n result.addTextSection(section, defaultFontStack);\n } else {\n result.addImageSection(section);\n }\n }\n return result;\n }\n\n length(): number {\n return this.text.length;\n }\n\n getSection(index: number): SectionOptions {\n return this.sections[this.sectionIndex[index]];\n }\n\n getSectionIndex(index: number): number {\n return this.sectionIndex[index];\n }\n\n getCharCode(index: number): number {\n return this.text.charCodeAt(index);\n }\n\n verticalizePunctuation() {\n this.text = verticalizePunctuation(this.text);\n }\n\n trim() {\n let beginningWhitespace = 0;\n for (let i = 0;\n i < this.text.length && whitespace[this.text.charCodeAt(i)];\n i++) {\n beginningWhitespace++;\n }\n let trailingWhitespace = this.text.length;\n for (let i = this.text.length - 1;\n i >= 0 && i >= beginningWhitespace && whitespace[this.text.charCodeAt(i)];\n i--) {\n trailingWhitespace--;\n }\n this.text = this.text.substring(beginningWhitespace, trailingWhitespace);\n this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace);\n }\n\n substring(start: number, end: number): TaggedString {\n const substring = new TaggedString();\n substring.text = this.text.substring(start, end);\n substring.sectionIndex = this.sectionIndex.slice(start, end);\n substring.sections = this.sections;\n return substring;\n }\n\n toString(): string {\n return this.text;\n }\n\n getMaxScale() {\n return this.sectionIndex.reduce((max, index) => Math.max(max, this.sections[index].scale), 0);\n }\n\n addTextSection(section: FormattedSection, defaultFontStack: string) {\n this.text += section.text;\n this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack));\n const index = this.sections.length - 1;\n for (let i = 0; i < section.text.length; ++i) {\n this.sectionIndex.push(index);\n }\n }\n\n addImageSection(section: FormattedSection) {\n const imageName = section.image ? section.image.name : '';\n if (imageName.length === 0) {\n warnOnce('Can\\'t add FormattedSection with an empty image.');\n return;\n }\n\n const nextImageSectionCharCode = this.getNextImageSectionCharCode();\n if (!nextImageSectionCharCode) {\n warnOnce(`Reached maximum number of images ${PUAend - PUAbegin + 2}`);\n return;\n }\n\n this.text += String.fromCharCode(nextImageSectionCharCode);\n this.sections.push(SectionOptions.forImage(imageName));\n this.sectionIndex.push(this.sections.length - 1);\n }\n\n getNextImageSectionCharCode(): number | null {\n if (!this.imageSectionID) {\n this.imageSectionID = PUAbegin;\n return this.imageSectionID;\n }\n\n if (this.imageSectionID >= PUAend) return null;\n return ++this.imageSectionID;\n }\n}\n\nfunction breakLines(input: TaggedString, lineBreakPoints: Array): Array {\n const lines = [];\n const text = input.text;\n let start = 0;\n for (const lineBreak of lineBreakPoints) {\n lines.push(input.substring(start, lineBreak));\n start = lineBreak;\n }\n\n if (start < text.length) {\n lines.push(input.substring(start, text.length));\n }\n return lines;\n}\n\nfunction shapeText(\n text: Formatted,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n defaultFontStack: string,\n maxWidth: number,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n spacing: number,\n translate: [number, number],\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n allowVerticalPlacement: boolean,\n symbolPlacement: string,\n layoutTextSize: number,\n layoutTextSizeThisZoom: number\n): Shaping | false {\n const logicalInput = TaggedString.fromFeature(text, defaultFontStack);\n\n if (writingMode === WritingMode.vertical) {\n logicalInput.verticalizePunctuation();\n }\n\n let lines: Array;\n\n const {processBidirectionalText, processStyledBidirectionalText} = rtlTextPlugin;\n if (processBidirectionalText && logicalInput.sections.length === 1) {\n // Bidi doesn't have to be style-aware\n lines = [];\n const untaggedLines =\n processBidirectionalText(logicalInput.toString(),\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of untaggedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line;\n taggedLine.sections = logicalInput.sections;\n for (let i = 0; i < line.length; i++) {\n taggedLine.sectionIndex.push(0);\n }\n lines.push(taggedLine);\n }\n } else if (processStyledBidirectionalText) {\n // Need version of mapbox-gl-rtl-text with style support for combining RTL text\n // with formatting\n lines = [];\n const processedLines =\n processStyledBidirectionalText(logicalInput.text,\n logicalInput.sectionIndex,\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of processedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line[0];\n taggedLine.sectionIndex = line[1];\n taggedLine.sections = logicalInput.sections;\n lines.push(taggedLine);\n }\n } else {\n lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n }\n\n const positionedLines = [];\n const shaping = {\n positionedLines,\n text: logicalInput.toString(),\n top: translate[1],\n bottom: translate[1],\n left: translate[0],\n right: translate[0],\n writingMode,\n iconsInText: false,\n verticalizable: false\n };\n\n shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom);\n if (isEmpty(positionedLines)) return false;\n\n return shaping;\n}\n\n// using computed properties due to https://github.com/facebook/flow/issues/380\n/* eslint no-useless-computed-key: 0 */\n\nconst whitespace: {\n [_: number]: boolean;\n} = {\n [0x09]: true, // tab\n [0x0a]: true, // newline\n [0x0b]: true, // vertical tab\n [0x0c]: true, // form feed\n [0x0d]: true, // carriage return\n [0x20]: true, // space\n};\n\nconst breakable: {\n [_: number]: boolean;\n} = {\n [0x0a]: true, // newline\n [0x20]: true, // space\n [0x26]: true, // ampersand\n [0x28]: true, // left parenthesis\n [0x29]: true, // right parenthesis\n [0x2b]: true, // plus sign\n [0x2d]: true, // hyphen-minus\n [0x2f]: true, // solidus\n [0xad]: true, // soft hyphen\n [0xb7]: true, // middle dot\n [0x200b]: true, // zero-width space\n [0x2010]: true, // hyphen\n [0x2013]: true, // en dash\n [0x2027]: true // interpunct\n // Many other characters may be reasonable breakpoints\n // Consider \"neutral orientation\" characters at scriptDetection.charHasNeutralVerticalOrientation\n // See https://github.com/mapbox/mapbox-gl-js/issues/3658\n};\n\nfunction getGlyphAdvance(\n codePoint: number,\n section: SectionOptions,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n spacing: number,\n layoutTextSize: number\n): number {\n if (!section.imageName) {\n const positions = glyphMap[section.fontStack];\n const glyph = positions && positions[codePoint];\n if (!glyph) return 0;\n return glyph.metrics.advance * section.scale + spacing;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) return 0;\n return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing;\n }\n}\n\nfunction determineAverageLineWidth(logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n layoutTextSize: number) {\n let totalWidth = 0;\n\n for (let index = 0; index < logicalInput.length(); index++) {\n const section = logicalInput.getSection(index);\n totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize);\n }\n\n const lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth));\n return totalWidth / lineCount;\n}\n\nfunction calculateBadness(lineWidth: number,\n targetWidth: number,\n penalty: number,\n isLastBreak: boolean) {\n const raggedness = Math.pow(lineWidth - targetWidth, 2);\n if (isLastBreak) {\n // Favor finals lines shorter than average over longer than average\n if (lineWidth < targetWidth) {\n return raggedness / 2;\n } else {\n return raggedness * 2;\n }\n }\n\n return raggedness + Math.abs(penalty) * penalty;\n}\n\nfunction calculatePenalty(codePoint: number, nextCodePoint: number, penalizableIdeographicBreak: boolean) {\n let penalty = 0;\n // Force break on newline\n if (codePoint === 0x0a) {\n penalty -= 10000;\n }\n // Penalize breaks between characters that allow ideographic breaking because\n // they are less preferable than breaks at spaces (or zero width spaces).\n if (penalizableIdeographicBreak) {\n penalty += 150;\n }\n\n // Penalize open parenthesis at end of line\n if (codePoint === 0x28 || codePoint === 0xff08) {\n penalty += 50;\n }\n\n // Penalize close parenthesis at beginning of line\n if (nextCodePoint === 0x29 || nextCodePoint === 0xff09) {\n penalty += 50;\n }\n return penalty;\n}\n\ntype Break = {\n index: number;\n x: number;\n priorBreak: Break;\n badness: number;\n};\n\nfunction evaluateBreak(\n breakIndex: number,\n breakX: number,\n targetWidth: number,\n potentialBreaks: Array,\n penalty: number,\n isLastBreak: boolean\n): Break {\n // We could skip evaluating breaks where the line length (breakX - priorBreak.x) > maxWidth\n // ...but in fact we allow lines longer than maxWidth (if there's no break points)\n // ...and when targetWidth and maxWidth are close, strictly enforcing maxWidth can give\n // more lopsided results.\n\n let bestPriorBreak: Break = null;\n let bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak);\n\n for (const potentialBreak of potentialBreaks) {\n const lineWidth = breakX - potentialBreak.x;\n const breakBadness =\n calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness;\n if (breakBadness <= bestBreakBadness) {\n bestPriorBreak = potentialBreak;\n bestBreakBadness = breakBadness;\n }\n }\n\n return {\n index: breakIndex,\n x: breakX,\n priorBreak: bestPriorBreak,\n badness: bestBreakBadness\n };\n}\n\nfunction leastBadBreaks(lastLineBreak?: Break | null): Array {\n if (!lastLineBreak) {\n return [];\n }\n return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index);\n}\n\nfunction determineLineBreaks(\n logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n symbolPlacement: string,\n layoutTextSize: number\n): Array {\n if (symbolPlacement !== 'point')\n return [];\n\n if (!logicalInput)\n return [];\n\n const potentialLineBreaks = [];\n const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize);\n\n const hasServerSuggestedBreakpoints = logicalInput.text.indexOf('\\u200b') >= 0;\n\n let currentX = 0;\n\n for (let i = 0; i < logicalInput.length(); i++) {\n const section = logicalInput.getSection(i);\n const codePoint = logicalInput.getCharCode(i);\n if (!whitespace[codePoint]) currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize);\n\n // Ideographic characters, spaces, and word-breaking punctuation that often appear without\n // surrounding spaces.\n if ((i < logicalInput.length() - 1)) {\n const ideographicBreak = charAllowsIdeographicBreaking(codePoint);\n if (breakable[codePoint] || ideographicBreak || section.imageName) {\n\n potentialLineBreaks.push(\n evaluateBreak(\n i + 1,\n currentX,\n targetWidth,\n potentialLineBreaks,\n calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints),\n false));\n }\n }\n }\n\n return leastBadBreaks(\n evaluateBreak(\n logicalInput.length(),\n currentX,\n targetWidth,\n potentialLineBreaks,\n 0,\n true));\n}\n\nfunction getAnchorAlignment(anchor: SymbolAnchor) {\n let horizontalAlign = 0.5, verticalAlign = 0.5;\n\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n horizontalAlign = 1;\n break;\n case 'left':\n case 'top-left':\n case 'bottom-left':\n horizontalAlign = 0;\n break;\n }\n\n switch (anchor) {\n case 'bottom':\n case 'bottom-right':\n case 'bottom-left':\n verticalAlign = 1;\n break;\n case 'top':\n case 'top-right':\n case 'top-left':\n verticalAlign = 0;\n break;\n }\n\n return {horizontalAlign, verticalAlign};\n}\n\nfunction shapeLines(shaping: Shaping,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n lines: Array,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n spacing: number,\n allowVerticalPlacement: boolean,\n layoutTextSizeThisZoom: number) {\n\n let x = 0;\n let y = SHAPING_DEFAULT_OFFSET;\n\n let maxLineLength = 0;\n let maxLineHeight = 0;\n\n const justify =\n textJustify === 'right' ? 1 :\n textJustify === 'left' ? 0 : 0.5;\n\n let lineIndex = 0;\n for (const line of lines) {\n line.trim();\n\n const lineMaxScale = line.getMaxScale();\n const maxLineOffset = (lineMaxScale - 1) * ONE_EM;\n const positionedLine = {positionedGlyphs: [], lineOffset: 0};\n shaping.positionedLines[lineIndex] = positionedLine;\n const positionedGlyphs = positionedLine.positionedGlyphs;\n let lineOffset = 0.0;\n\n if (!line.length()) {\n y += lineHeight; // Still need a line feed after empty line\n ++lineIndex;\n continue;\n }\n\n for (let i = 0; i < line.length(); i++) {\n const section = line.getSection(i);\n const sectionIndex = line.getSectionIndex(i);\n const codePoint = line.getCharCode(i);\n let baselineOffset = 0.0;\n let metrics = null;\n let rect = null;\n let imageName = null;\n let verticalAdvance = ONE_EM;\n const vertical = !(writingMode === WritingMode.horizontal ||\n // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled.\n (!allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint)) ||\n // If vertical placement is enabled, don't verticalize glyphs that\n // are from complex text layout script, or whitespaces.\n (allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint))));\n\n if (!section.imageName) {\n const positions = glyphPositions[section.fontStack];\n const glyphPosition = positions && positions[codePoint];\n if (glyphPosition && glyphPosition.rect) {\n rect = glyphPosition.rect;\n metrics = glyphPosition.metrics;\n } else {\n const glyphs = glyphMap[section.fontStack];\n const glyph = glyphs && glyphs[codePoint];\n if (!glyph) continue;\n metrics = glyph.metrics;\n }\n\n // We don't know the baseline, but since we're laying out\n // at 24 points, we can calculate how much it will move when\n // we scale up or down.\n baselineOffset = (lineMaxScale - section.scale) * ONE_EM;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) continue;\n imageName = section.imageName;\n shaping.iconsInText = shaping.iconsInText || true;\n rect = imagePosition.paddedRect;\n const size = imagePosition.displaySize;\n // If needed, allow to set scale factor for an image using\n // alias \"image-scale\" that could be alias for \"font-scale\"\n // when FormattedSection is an image section.\n section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom;\n\n metrics = {width: size[0],\n height: size[1],\n left: IMAGE_PADDING,\n top: -GLYPH_PBF_BORDER,\n advance: vertical ? size[1] : size[0]};\n\n // Difference between one EM and an image size.\n // Aligns bottom of an image to a baseline level.\n const imageOffset = ONE_EM - size[1] * section.scale;\n baselineOffset = maxLineOffset + imageOffset;\n verticalAdvance = metrics.advance;\n\n // Difference between height of an image and one EM at max line scale.\n // Pushes current line down if an image size is over 1 EM at max line scale.\n const offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale :\n size[1] * section.scale - ONE_EM * lineMaxScale;\n if (offset > 0 && offset > lineOffset) {\n lineOffset = offset;\n }\n }\n\n if (!vertical) {\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += metrics.advance * section.scale + spacing;\n } else {\n shaping.verticalizable = true;\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += verticalAdvance * section.scale + spacing;\n }\n }\n\n // Only justify if we placed at least one glyph\n if (positionedGlyphs.length !== 0) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset);\n }\n\n x = 0;\n const currentLineHeight = lineHeight * lineMaxScale + lineOffset;\n positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset);\n y += currentLineHeight;\n maxLineHeight = Math.max(currentLineHeight, maxLineHeight);\n ++lineIndex;\n }\n\n // Calculate the bounding box and justify / align text block.\n const height = y - SHAPING_DEFAULT_OFFSET;\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(textAnchor);\n align(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length);\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top + height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\n// justify right = 1, left = 0, center = 0.5\nfunction justifyLine(positionedGlyphs: Array,\n start: number,\n end: number,\n justify: 1 | 0 | 0.5,\n lineOffset: number) {\n if (!justify && !lineOffset)\n return;\n\n const lastPositionedGlyph = positionedGlyphs[end];\n const lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale;\n const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;\n\n for (let j = start; j <= end; j++) {\n positionedGlyphs[j].x -= lineIndent;\n positionedGlyphs[j].y += lineOffset;\n }\n}\n\nfunction align(positionedLines: Array,\n justify: number,\n horizontalAlign: number,\n verticalAlign: number,\n maxLineLength: number,\n maxLineHeight: number,\n lineHeight: number,\n blockHeight: number,\n lineCount: number) {\n const shiftX = (justify - horizontalAlign) * maxLineLength;\n let shiftY = 0;\n\n if (maxLineHeight !== lineHeight) {\n shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET;\n } else {\n shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;\n }\n\n for (const line of positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n positionedGlyph.x += shiftX;\n positionedGlyph.y += shiftY;\n }\n }\n}\n\nexport type PositionedIcon = {\n image: ImagePosition;\n top: number;\n bottom: number;\n left: number;\n right: number;\n collisionPadding?: [number, number, number, number];\n};\n\nfunction shapeIcon(\n image: ImagePosition,\n iconOffset: [number, number],\n iconAnchor: SymbolAnchor\n): PositionedIcon {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(iconAnchor);\n const dx = iconOffset[0];\n const dy = iconOffset[1];\n const x1 = dx - image.displaySize[0] * horizontalAlign;\n const x2 = x1 + image.displaySize[0];\n const y1 = dy - image.displaySize[1] * verticalAlign;\n const y2 = y1 + image.displaySize[1];\n return {image, top: y1, bottom: y2, left: x1, right: x2};\n}\n\nfunction fitIconToText(\n shapedIcon: PositionedIcon,\n shapedText: Shaping,\n textFit: string,\n padding: [number, number, number, number],\n iconOffset: [number, number],\n fontScale: number\n): PositionedIcon {\n\n const image = shapedIcon.image;\n\n let collisionPadding;\n if (image.content) {\n const content = image.content;\n const pixelRatio = image.pixelRatio || 1;\n collisionPadding = [\n content[0] / pixelRatio,\n content[1] / pixelRatio,\n image.displaySize[0] - content[2] / pixelRatio,\n image.displaySize[1] - content[3] / pixelRatio\n ];\n }\n\n // We don't respect the icon-anchor, because icon-text-fit is set. Instead,\n // the icon will be centered on the text, then stretched in the given\n // dimensions.\n\n const textLeft = shapedText.left * fontScale;\n const textRight = shapedText.right * fontScale;\n\n let top, right, bottom, left;\n if (textFit === 'width' || textFit === 'both') {\n // Stretched horizontally to the text width\n left = iconOffset[0] + textLeft - padding[3];\n right = iconOffset[0] + textRight + padding[1];\n } else {\n // Centered on the text\n left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2;\n right = left + image.displaySize[0];\n }\n\n const textTop = shapedText.top * fontScale;\n const textBottom = shapedText.bottom * fontScale;\n if (textFit === 'height' || textFit === 'both') {\n // Stretched vertically to the text height\n top = iconOffset[1] + textTop - padding[0];\n bottom = iconOffset[1] + textBottom + padding[2];\n } else {\n // Centered on the text\n top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2;\n bottom = top + image.displaySize[1];\n }\n\n return {image, top, right, bottom, left, collisionPadding};\n}\n","import {Interpolate, interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {clamp} from '../util/util';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\n\nimport type {PropertyValue, PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport type {InterpolationType} from '@maplibre/maplibre-gl-style-spec';\n\nconst MAX_GLYPH_ICON_SIZE = 255;\nconst SIZE_PACK_FACTOR = 128;\nconst MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;\n\nexport {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR, MAX_GLYPH_ICON_SIZE, MAX_PACKED_SIZE};\n\nexport type SizeData = {\n kind: 'constant';\n layoutSize: number;\n} | {\n kind: 'source';\n} | {\n kind: 'camera';\n minZoom: number;\n maxZoom: number;\n minSize: number;\n maxSize: number;\n interpolationType: InterpolationType;\n} | {\n kind: 'composite';\n minZoom: number;\n maxZoom: number;\n interpolationType: InterpolationType;\n};\n\nexport type EvaluatedZoomSize = {uSizeT: number; uSize: number};\n\n// For {text,icon}-size, get the bucket-level data that will be needed by\n// the painter to set symbol-size-related uniforms\nfunction getSizeData(\n tileZoom: number,\n value: PropertyValue>\n): SizeData {\n const {expression} = value;\n\n if (expression.kind === 'constant') {\n const layoutSize = expression.evaluate(new EvaluationParameters(tileZoom + 1));\n return {kind: 'constant', layoutSize};\n\n } else if (expression.kind === 'source') {\n return {kind: 'source'};\n\n } else {\n const {zoomStops, interpolationType} = expression;\n\n // calculate covering zoom stops for zoom-dependent values\n let lower = 0;\n while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) lower++;\n lower = Math.max(0, lower - 1);\n let upper = lower;\n while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) upper++;\n upper = Math.min(zoomStops.length - 1, upper);\n\n const minZoom = zoomStops[lower];\n const maxZoom = zoomStops[upper];\n\n // We'd like to be able to use CameraExpression or CompositeExpression in these\n // return types rather than ExpressionSpecification, but the former are not\n // transferrable across Web Worker boundaries.\n if (expression.kind === 'composite') {\n return {kind: 'composite', minZoom, maxZoom, interpolationType};\n }\n\n // for camera functions, also save off the function values\n // evaluated at the covering zoom levels\n const minSize = expression.evaluate(new EvaluationParameters(minZoom));\n const maxSize = expression.evaluate(new EvaluationParameters(maxZoom));\n\n return {kind: 'camera', minZoom, maxZoom, minSize, maxSize, interpolationType};\n }\n}\n\nfunction evaluateSizeForFeature(sizeData: SizeData,\n {\n uSize,\n uSizeT\n }: {\n uSize: number;\n uSizeT: number;\n },\n {\n lowerSize,\n upperSize\n }: {\n lowerSize: number;\n upperSize: number;\n }): number {\n if (sizeData.kind === 'source') {\n return lowerSize / SIZE_PACK_FACTOR;\n } else if (sizeData.kind === 'composite') {\n return interpolates.number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT);\n }\n return uSize;\n}\n\nfunction evaluateSizeForZoom(sizeData: SizeData, zoom: number): EvaluatedZoomSize {\n let uSizeT = 0;\n let uSize = 0;\n\n if (sizeData.kind === 'constant') {\n uSize = sizeData.layoutSize;\n\n } else if (sizeData.kind !== 'source') {\n const {interpolationType, minZoom, maxZoom} = sizeData;\n\n // Even though we could get the exact value of the camera function\n // at z = tr.zoom, we intentionally do not: instead, we interpolate\n // between the camera function values at a pair of zoom stops covering\n // [tileZoom, tileZoom + 1] in order to be consistent with this\n // restriction on composite functions\n const t = !interpolationType ? 0 : clamp(\n Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1);\n\n if (sizeData.kind === 'camera') {\n uSize = interpolates.number(sizeData.minSize, sizeData.maxSize, t);\n } else {\n uSizeT = t;\n }\n }\n\n return {uSizeT, uSize};\n}\n","import {SymbolLayoutPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\nimport type {SymbolLayoutProps} from './symbol_style_layer_properties.g';\nimport {PossiblyEvaluated} from '../properties';\n\n/**\n * The overlap mode for properties like `icon-overlap`and `text-overlap`\n */\nexport type OverlapMode = 'never' | 'always' | 'cooperative';\n\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap', allowOverlapProp: 'icon-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'text-overlap', allowOverlapProp: 'text-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap' | 'text-overlap', allowOverlapProp: 'icon-allow-overlap' | 'text-allow-overlap'): OverlapMode {\n let result: OverlapMode = 'never';\n const overlap = layout.get(overlapProp);\n\n if (overlap) {\n // if -overlap is set, use it\n result = overlap;\n } else if (layout.get(allowOverlapProp)) {\n // fall back to -allow-overlap, with false='never', true='always'\n result = 'always';\n }\n\n return result;\n}\n","import {\n symbolLayoutAttributes,\n collisionVertexAttributes,\n collisionBoxLayout,\n dynamicLayoutAttributes,\n} from './symbol_attributes';\n\nimport {SymbolLayoutArray,\n SymbolDynamicLayoutArray,\n SymbolOpacityArray,\n CollisionBoxLayoutArray,\n CollisionVertexArray,\n PlacedSymbolArray,\n SymbolInstanceArray,\n GlyphOffsetArray,\n SymbolLineVertexArray,\n TextAnchorOffsetArray\n} from '../array_types.g';\n\nimport Point from '@mapbox/point-geometry';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray, LineIndexArray} from '../index_array_type';\nimport {transformText} from '../../symbol/transform_text';\nimport {mergeLines} from '../../symbol/merge_lines';\nimport {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';\nimport {WritingMode} from '../../symbol/shaping';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {verticalizedCharacterMap} from '../../util/verticalize_punctuation';\nimport {Anchor} from '../../symbol/anchor';\nimport {getSizeData, MAX_PACKED_SIZE} from '../../symbol/symbol_size';\n\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\nimport {Formatted, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';\nimport {mat4} from 'gl-matrix';\nimport {getOverlapMode} from '../../style/style_layer/overlap_mode';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types.g';\nimport type {StructArray, StructArrayMember, ViewType} from '../../util/struct_array';\nimport type {SymbolStyleLayer} from '../../style/style_layer/symbol_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {SymbolQuad} from '../../symbol/quads';\nimport type {SizeData} from '../../symbol/symbol_size';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type SingleCollisionBox = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n anchorPointX: number;\n anchorPointY: number;\n};\n\nexport type CollisionArrays = {\n textBox?: SingleCollisionBox;\n verticalTextBox?: SingleCollisionBox;\n iconBox?: SingleCollisionBox;\n verticalIconBox?: SingleCollisionBox;\n textFeatureIndex?: number;\n verticalTextFeatureIndex?: number;\n iconFeatureIndex?: number;\n verticalIconFeatureIndex?: number;\n};\n\nexport type SymbolFeature = {\n sortKey: number | void;\n text: Formatted | void;\n icon: ResolvedImage;\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 'Unknown' | 'Point' | 'LineString' | 'Polygon';\n id?: any;\n};\n\nexport type SortKeyRange = {\n sortKey: number;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n};\n\n// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them\n// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph\n// 7 bits are for the current opacity, and the lowest bit is the target opacity\n\n// actually defined in symbol_attributes.js\n// const placementOpacityAttributes = [\n// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }\n// ];\nconst shaderOpacityAttributes = [\n {name: 'a_fade_opacity', components: 1, type: 'Uint8' as ViewType, offset: 0}\n];\n\nfunction addVertex(\n array: StructArray,\n anchorX: number,\n anchorY: number,\n ox: number,\n oy: number,\n tx: number,\n ty: number,\n sizeVertex: number,\n isSDF: boolean,\n pixelOffsetX: number,\n pixelOffsetY: number,\n minFontScaleX: number,\n minFontScaleY: number\n) {\n const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;\n const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;\n array.emplaceBack(\n // a_pos_offset\n anchorX,\n anchorY,\n Math.round(ox * 32),\n Math.round(oy * 32),\n\n // a_data\n tx, // x coordinate of symbol on glyph atlas texture\n ty, // y coordinate of symbol on glyph atlas texture\n (aSizeX << 1) + (isSDF ? 1 : 0),\n aSizeY,\n pixelOffsetX * 16,\n pixelOffsetY * 16,\n minFontScaleX * 256,\n minFontScaleY * 256\n );\n}\n\nfunction addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) {\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n}\n\nfunction containsRTLText(formattedText: Formatted): boolean {\n for (const section of formattedText.sections) {\n if (stringContainsRTLText(section.text)) {\n return true;\n }\n }\n return false;\n}\n\nexport class SymbolBuffers {\n layoutVertexArray: SymbolLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n\n dynamicLayoutVertexArray: SymbolDynamicLayoutArray;\n dynamicLayoutVertexBuffer: VertexBuffer;\n\n opacityVertexArray: SymbolOpacityArray;\n opacityVertexBuffer: VertexBuffer;\n hasVisibleVertices: boolean;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n placedSymbolArray: PlacedSymbolArray;\n\n constructor(programConfigurations: ProgramConfigurationSet) {\n this.layoutVertexArray = new SymbolLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = programConfigurations;\n this.segments = new SegmentVector();\n this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();\n this.opacityVertexArray = new SymbolOpacityArray();\n this.hasVisibleVertices = false;\n this.placedSymbolArray = new PlacedSymbolArray();\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 &&\n this.indexArray.length === 0 &&\n this.dynamicLayoutVertexArray.length === 0 &&\n this.opacityVertexArray.length === 0;\n }\n\n upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) {\n if (this.isEmpty()) {\n return;\n }\n\n if (upload) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);\n this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);\n this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);\n this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);\n // This is a performance hack so that we can write to opacityVertexArray with uint32s\n // even though the shaders read uint8s\n this.opacityVertexBuffer.itemSize = 1;\n }\n if (upload || update) {\n this.programConfigurations.upload(context);\n }\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.dynamicLayoutVertexBuffer.destroy();\n this.opacityVertexBuffer.destroy();\n }\n}\n\nregister('SymbolBuffers', SymbolBuffers);\n\nclass CollisionBuffers {\n layoutVertexArray: StructArray;\n layoutAttributes: Array;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray | LineIndexArray;\n indexBuffer: IndexBuffer;\n\n segments: SegmentVector;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n constructor(LayoutArray: {\n new (...args: any): StructArray;\n },\n layoutAttributes: Array,\n IndexArray: {\n new (...args: any): TriangleIndexArray | LineIndexArray;\n }) {\n this.layoutVertexArray = new LayoutArray();\n this.layoutAttributes = layoutAttributes;\n this.indexArray = new IndexArray();\n this.segments = new SegmentVector();\n this.collisionVertexArray = new CollisionVertexArray();\n }\n\n upload(context: Context) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.segments.destroy();\n this.collisionVertexBuffer.destroy();\n }\n}\n\nregister('CollisionBuffers', CollisionBuffers);\n\n/**\n * @internal\n * Unlike other buckets, which simply implement #addFeature with type-specific\n * logic for (essentially) triangulating feature geometries, SymbolBucket\n * requires specialized behavior:\n *\n * 1. WorkerTile#parse(), the logical owner of the bucket creation process,\n * calls SymbolBucket#populate(), which resolves text and icon tokens on\n * each feature, adds each glyphs and symbols needed to the passed-in\n * collections options.glyphDependencies and options.iconDependencies, and\n * stores the feature data for use in subsequent step (this.features).\n *\n * 2. WorkerTile asynchronously requests from the main thread all of the glyphs\n * and icons needed (by this bucket and any others). When glyphs and icons\n * have been received, the WorkerTile creates a CollisionIndex and invokes:\n *\n * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and\n * layout on a Symbol Bucket. This step populates:\n * `this.symbolInstances`: metadata on generated symbols\n * `this.collisionBoxArray`: collision data for use by foreground\n * `this.text`: SymbolBuffers for text symbols\n * `this.icons`: SymbolBuffers for icons\n * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes\n * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes\n * The results are sent to the foreground for rendering\n *\n * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,\n * and uses the CollisionIndex along with current camera settings to determine\n * which symbols can actually show on the map. Collided symbols are hidden\n * using a dynamic \"OpacityVertexArray\".\n */\nexport class SymbolBucket implements Bucket {\n static MAX_GLYPHS: number;\n static addDynamicAttributes: typeof addDynamicAttributes;\n\n collisionBoxArray: CollisionBoxArray;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n index: number;\n sdfIcons: boolean;\n iconsInText: boolean;\n iconsNeedLinear: boolean;\n bucketInstanceId: number;\n justReloaded: boolean;\n hasPattern: boolean;\n\n textSizeData: SizeData;\n iconSizeData: SizeData;\n\n glyphOffsetArray: GlyphOffsetArray;\n lineVertexArray: SymbolLineVertexArray;\n features: Array;\n symbolInstances: SymbolInstanceArray;\n textAnchorOffsets: TextAnchorOffsetArray;\n collisionArrays: Array;\n sortKeyRanges: Array;\n pixelRatio: number;\n tilePixelRatio: number;\n compareText: {[_: string]: Array};\n fadeStartTime: number;\n sortFeaturesByKey: boolean;\n sortFeaturesByY: boolean;\n canOverlap: boolean;\n sortedAngle: number;\n featureSortOrder: Array;\n\n collisionCircleArray: Array;\n placementInvProjMatrix: mat4;\n placementViewportMatrix: mat4;\n\n text: SymbolBuffers;\n icon: SymbolBuffers;\n textCollisionBox: CollisionBuffers;\n iconCollisionBox: CollisionBuffers;\n uploaded: boolean;\n sourceLayerIndex: number;\n sourceID: string;\n symbolInstanceIndexes: Array;\n writingModes: WritingMode[];\n allowVerticalPlacement: boolean;\n hasRTLText: boolean;\n\n constructor(options: BucketParameters) {\n this.collisionBoxArray = options.collisionBoxArray;\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.pixelRatio = options.pixelRatio;\n this.sourceLayerIndex = options.sourceLayerIndex;\n this.hasPattern = false;\n this.hasRTLText = false;\n this.sortKeyRanges = [];\n\n this.collisionCircleArray = [];\n this.placementInvProjMatrix = mat4.identity([] as any);\n this.placementViewportMatrix = mat4.identity([] as any);\n\n const layer = this.layers[0];\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);\n this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);\n\n const layout = this.layers[0].layout;\n const sortKey = layout.get('symbol-sort-key');\n const zOrder = layout.get('symbol-z-order');\n this.canOverlap =\n getOverlapMode(layout, 'text-overlap', 'text-allow-overlap') !== 'never' ||\n getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap') !== 'never' ||\n layout.get('text-ignore-placement') ||\n layout.get('icon-ignore-placement');\n this.sortFeaturesByKey = zOrder !== 'viewport-y' && !sortKey.isConstant();\n const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey);\n this.sortFeaturesByY = zOrderByViewportY && this.canOverlap;\n\n if (layout.get('symbol-placement') === 'point') {\n this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]);\n }\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n\n this.sourceID = options.sourceID;\n }\n\n createArrays() {\n this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property)));\n this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property)));\n\n this.glyphOffsetArray = new GlyphOffsetArray();\n this.lineVertexArray = new SymbolLineVertexArray();\n this.symbolInstances = new SymbolInstanceArray();\n this.textAnchorOffsets = new TextAnchorOffsetArray();\n }\n\n calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {\n for (let i = 0; i < text.length; i++) {\n stack[text.charCodeAt(i)] = true;\n if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {\n const verticalChar = verticalizedCharacterMap[text.charAt(i)];\n if (verticalChar) {\n stack[verticalChar.charCodeAt(0)] = true;\n }\n }\n }\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const layer = this.layers[0];\n const layout = layer.layout;\n\n const textFont = layout.get('text-font');\n const textField = layout.get('text-field');\n const iconImage = layout.get('icon-image');\n const hasText =\n (textField.value.kind !== 'constant' ||\n (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) ||\n textField.value.value.toString().length > 0) &&\n (textFont.value.kind !== 'constant' || textFont.value.value.length > 0);\n // we should always resolve the icon-image value if the property was defined in the style\n // this allows us to fire the styleimagemissing event if image evaluation returns null\n // the only way to distinguish between null returned from a coalesce statement with no valid images\n // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object\n const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;\n const symbolSortKey = layout.get('symbol-sort-key');\n\n this.features = [];\n\n if (!hasText && !hasIcon) {\n return;\n }\n\n const icons = options.iconDependencies;\n const stacks = options.glyphDependencies;\n const availableImages = options.availableImages;\n const globalProperties = new EvaluationParameters(this.zoom);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n\n const needGeometry = layer._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {\n continue;\n }\n\n if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature);\n\n let text: Formatted | void;\n if (hasText) {\n // Expression evaluation will automatically coerce to Formatted\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages);\n const formattedText = Formatted.factory(resolvedTokens);\n if (containsRTLText(formattedText)) {\n this.hasRTLText = true;\n }\n if (\n !this.hasRTLText || // non-rtl text so can proceed safely\n getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping\n this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text\n ) {\n text = transformText(formattedText, layer, evaluationFeature);\n }\n }\n\n let icon: ResolvedImage;\n if (hasIcon) {\n // Expression evaluation will automatically coerce to Image\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages);\n if (resolvedTokens instanceof ResolvedImage) {\n icon = resolvedTokens;\n } else {\n icon = ResolvedImage.fromString(resolvedTokens);\n }\n }\n\n if (!text && !icon) {\n continue;\n }\n const sortKey = this.sortFeaturesByKey ?\n symbolSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const symbolFeature: SymbolFeature = {\n id,\n text,\n icon,\n index,\n sourceLayerIndex,\n geometry: evaluationFeature.geometry,\n properties: feature.properties,\n type: vectorTileFeatureTypes[feature.type],\n sortKey\n };\n this.features.push(symbolFeature);\n\n if (icon) {\n icons[icon.name] = true;\n }\n\n if (text) {\n const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;\n for (const section of text.sections) {\n if (!section.image) {\n const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());\n const sectionFont = section.fontStack || fontStack;\n const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};\n this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);\n } else {\n // Add section image to the list of dependencies.\n icons[section.image.name] = true;\n }\n }\n }\n }\n\n if (layout.get('symbol-placement') === 'line') {\n // Merge adjacent lines with the same text to improve labelling.\n // It's better to place labels on one long line than on many short segments.\n this.features = mergeLines(this.features);\n }\n\n if (this.sortFeaturesByKey) {\n this.features.sort((a, b) => {\n // a.sortKey is always a number when sortFeaturesByKey is true\n return (a.sortKey as number) - (b.sortKey as number);\n });\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n }\n\n isEmpty() {\n // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created.\n // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary.\n return this.symbolInstances.length === 0 && !this.hasRTLText;\n }\n\n uploadPending() {\n return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded && this.hasDebugData()) {\n this.textCollisionBox.upload(context);\n this.iconCollisionBox.upload(context);\n }\n this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);\n this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);\n this.uploaded = true;\n }\n\n destroyDebugData() {\n this.textCollisionBox.destroy();\n this.iconCollisionBox.destroy();\n }\n\n destroy() {\n this.text.destroy();\n this.icon.destroy();\n\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n }\n\n addToLineVertexArray(anchor: Anchor, line: any) {\n const lineStartIndex = this.lineVertexArray.length;\n if (anchor.segment !== undefined) {\n let sumForwardLength = anchor.dist(line[anchor.segment + 1]);\n let sumBackwardLength = anchor.dist(line[anchor.segment]);\n const vertices = {};\n for (let i = anchor.segment + 1; i < line.length; i++) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};\n if (i < line.length - 1) {\n sumForwardLength += line[i + 1].dist(line[i]);\n }\n }\n for (let i = anchor.segment || 0; i >= 0; i--) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};\n if (i > 0) {\n sumBackwardLength += line[i - 1].dist(line[i]);\n }\n }\n for (let i = 0; i < line.length; i++) {\n const vertex = vertices[i];\n this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);\n }\n }\n return {\n lineStartIndex,\n lineLength: this.lineVertexArray.length - lineStartIndex\n };\n }\n\n addSymbols(arrays: SymbolBuffers,\n quads: Array,\n sizeVertex: any,\n lineOffset: [number, number],\n alongLine: boolean,\n feature: SymbolFeature,\n writingMode: WritingMode,\n labelAnchor: Anchor,\n lineStartIndex: number,\n lineLength: number,\n associatedIconIndex: number,\n canonical: CanonicalTileID) {\n const indexArray = arrays.indexArray;\n const layoutVertexArray = arrays.layoutVertexArray;\n\n const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey as number : undefined);\n const glyphOffsetArrayStart = this.glyphOffsetArray.length;\n const vertexStartIndex = segment.vertexLength;\n\n const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0;\n\n const sections = feature.text && feature.text.sections;\n\n for (let i = 0; i < quads.length; i++) {\n const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i];\n const index = segment.vertexLength;\n\n const y = glyphOffset[1];\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n\n addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);\n\n indexArray.emplaceBack(index, index + 1, index + 2);\n indexArray.emplaceBack(index + 1, index + 2, index + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n\n this.glyphOffsetArray.emplaceBack(glyphOffset[0]);\n\n if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {\n arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);\n }\n }\n\n arrays.placedSymbolArray.emplaceBack(\n labelAnchor.x, labelAnchor.y,\n glyphOffsetArrayStart,\n this.glyphOffsetArray.length - glyphOffsetArrayStart,\n vertexStartIndex,\n lineStartIndex,\n lineLength,\n labelAnchor.segment,\n sizeVertex ? sizeVertex[0] : 0,\n sizeVertex ? sizeVertex[1] : 0,\n lineOffset[0], lineOffset[1],\n writingMode,\n // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed\n 0,\n false as unknown as number,\n // The crossTileID is only filled/used on the foreground for dynamic text anchors\n 0,\n associatedIconIndex\n );\n }\n\n _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) {\n collisionVertexArray.emplaceBack(0, 0);\n return layoutVertexArray.emplaceBack(\n // pos\n point.x,\n point.y,\n // a_anchor_pos\n anchorX,\n anchorY,\n // extrude\n Math.round(extrude.x),\n Math.round(extrude.y));\n }\n\n addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance) {\n const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);\n const index = segment.vertexLength;\n\n const layoutVertexArray = arrays.layoutVertexArray;\n const collisionVertexArray = arrays.collisionVertexArray;\n\n const anchorX = symbolInstance.anchorX;\n const anchorY = symbolInstance.anchorY;\n\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2));\n\n segment.vertexLength += 4;\n\n const indexArray = arrays.indexArray as LineIndexArray;\n indexArray.emplaceBack(index, index + 1);\n indexArray.emplaceBack(index + 1, index + 2);\n indexArray.emplaceBack(index + 2, index + 3);\n indexArray.emplaceBack(index + 3, index);\n\n segment.primitiveLength += 4;\n }\n\n addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {\n for (let b = startIndex; b < endIndex; b++) {\n const box: CollisionBox = this.collisionBoxArray.get(b);\n const x1 = box.x1;\n const y1 = box.y1;\n const x2 = box.x2;\n const y2 = box.y2;\n\n this.addCollisionDebugVertices(x1, y1, x2, y2,\n isText ? this.textCollisionBox : this.iconCollisionBox,\n box.anchorPoint, symbolInstance);\n }\n }\n\n generateCollisionDebugBuffers() {\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n\n this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false);\n this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false);\n }\n }\n\n // These flat arrays are meant to be quicker to iterate over than the source\n // CollisionBoxArray\n _deserializeCollisionBoxesForSymbol(\n collisionBoxArray: CollisionBoxArray,\n textStartIndex: number,\n textEndIndex: number,\n verticalTextStartIndex: number,\n verticalTextEndIndex: number,\n iconStartIndex: number,\n iconEndIndex: number,\n verticalIconStartIndex: number,\n verticalIconEndIndex: number\n ): CollisionArrays {\n\n const collisionArrays = {} as CollisionArrays;\n for (let k = textStartIndex; k < textEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.textFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalTextFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = iconStartIndex; k < iconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.iconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalIconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n return collisionArrays;\n }\n\n deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) {\n this.collisionArrays = [];\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(\n collisionBoxArray,\n symbolInstance.textBoxStartIndex,\n symbolInstance.textBoxEndIndex,\n symbolInstance.verticalTextBoxStartIndex,\n symbolInstance.verticalTextBoxEndIndex,\n symbolInstance.iconBoxStartIndex,\n symbolInstance.iconBoxEndIndex,\n symbolInstance.verticalIconBoxStartIndex,\n symbolInstance.verticalIconBoxEndIndex\n ));\n }\n }\n\n hasTextData() {\n return this.text.segments.get().length > 0;\n }\n\n hasIconData() {\n return this.icon.segments.get().length > 0;\n }\n\n hasDebugData() {\n return this.textCollisionBox && this.iconCollisionBox;\n }\n\n hasTextCollisionBoxData() {\n return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;\n }\n\n hasIconCollisionBoxData() {\n return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;\n }\n\n addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) {\n const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);\n\n const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;\n for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {\n iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);\n iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);\n }\n }\n\n getSortedSymbolIndexes(angle: number) {\n if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) {\n return this.symbolInstanceIndexes;\n }\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n const rotatedYs = [];\n const featureIndexes = [];\n const result = [];\n\n for (let i = 0; i < this.symbolInstances.length; ++i) {\n result.push(i);\n const symbolInstance = this.symbolInstances.get(i);\n rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);\n featureIndexes.push(symbolInstance.featureIndex);\n }\n\n result.sort((aIndex, bIndex) => {\n return (rotatedYs[aIndex] - rotatedYs[bIndex]) ||\n (featureIndexes[bIndex] - featureIndexes[aIndex]);\n });\n\n return result;\n }\n\n addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) {\n const last = this.sortKeyRanges[this.sortKeyRanges.length - 1];\n if (last && last.sortKey === sortKey) {\n last.symbolInstanceEnd = symbolInstanceIndex + 1;\n } else {\n this.sortKeyRanges.push({\n sortKey,\n symbolInstanceStart: symbolInstanceIndex,\n symbolInstanceEnd: symbolInstanceIndex + 1\n });\n }\n }\n\n sortFeatures(angle: number) {\n if (!this.sortFeaturesByY) return;\n if (this.sortedAngle === angle) return;\n\n // The current approach to sorting doesn't sort across segments so don't try.\n // Sorting within segments separately seemed not to be worth the complexity.\n if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return;\n\n // If the symbols are allowed to overlap sort them by their vertical screen position.\n // The index array buffer is rewritten to reference the (unchanged) vertices in the\n // sorted order.\n\n // To avoid sorting the actual symbolInstance array we sort an array of indexes.\n this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);\n this.sortedAngle = angle;\n\n this.text.indexArray.clear();\n this.icon.indexArray.clear();\n\n this.featureSortOrder = [];\n\n for (const i of this.symbolInstanceIndexes) {\n const symbolInstance = this.symbolInstances.get(i);\n this.featureSortOrder.push(symbolInstance.featureIndex);\n\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach((index, i, array) => {\n // Only add a given index the first time it shows up,\n // to avoid duplicate opacity entries when multiple justifications\n // share the same glyphs.\n if (index >= 0 && array.indexOf(index) === i) {\n this.addIndicesForPlacedSymbol(this.text, index);\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex);\n }\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex);\n }\n }\n\n if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray);\n if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray);\n }\n}\n\nregister('SymbolBucket', SymbolBucket, {\n omit: ['layers', 'collisionBoxArray', 'features', 'compareText']\n});\n\n// this constant is based on the size of StructArray indexes used in a symbol\n// bucket--namely, glyphOffsetArrayStart\n// eg the max valid UInt16 is 65,535\n// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation\n// lineStartIndex and textBoxStartIndex could potentially be concerns\n// but we expect there to be many fewer boxes/lines than glyphs\nSymbolBucket.MAX_GLYPHS = 65535;\n\nSymbolBucket.addDynamicAttributes = addDynamicAttributes;\n\nexport {addDynamicAttributes};\n","import type {SymbolFeature} from '../data/bucket/symbol_bucket';\n\nexport function mergeLines(features: Array): Array {\n const leftIndex: {[_: string]: number} = {};\n const rightIndex: {[_: string]: number} = {};\n const mergedFeatures = [];\n let mergedIndex = 0;\n\n function add(k) {\n mergedFeatures.push(features[k]);\n mergedIndex++;\n }\n\n function mergeFromRight(leftKey: string, rightKey: string, geom) {\n const i = rightIndex[leftKey];\n delete rightIndex[leftKey];\n rightIndex[rightKey] = i;\n\n mergedFeatures[i].geometry[0].pop();\n mergedFeatures[i].geometry[0] = mergedFeatures[i].geometry[0].concat(geom[0]);\n return i;\n }\n\n function mergeFromLeft(leftKey: string, rightKey: string, geom) {\n const i = leftIndex[rightKey];\n delete leftIndex[rightKey];\n leftIndex[leftKey] = i;\n\n mergedFeatures[i].geometry[0].shift();\n mergedFeatures[i].geometry[0] = geom[0].concat(mergedFeatures[i].geometry[0]);\n return i;\n }\n\n function getKey(text, geom, onRight?) {\n const point = onRight ? geom[0][geom[0].length - 1] : geom[0][0];\n return `${text}:${point.x}:${point.y}`;\n }\n\n for (let k = 0; k < features.length; k++) {\n const feature = features[k];\n const geom = feature.geometry;\n const text = feature.text ? feature.text.toString() : null;\n\n if (!text) {\n add(k);\n continue;\n }\n\n const leftKey = getKey(text, geom),\n rightKey = getKey(text, geom, true);\n\n if ((leftKey in rightIndex) && (rightKey in leftIndex) && (rightIndex[leftKey] !== leftIndex[rightKey])) {\n // found lines with the same text adjacent to both ends of the current line, merge all three\n const j = mergeFromLeft(leftKey, rightKey, geom);\n const i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry);\n\n delete leftIndex[leftKey];\n delete rightIndex[rightKey];\n\n rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i;\n mergedFeatures[j].geometry = null;\n\n } else if (leftKey in rightIndex) {\n // found mergeable line adjacent to the start of the current line, merge\n mergeFromRight(leftKey, rightKey, geom);\n\n } else if (rightKey in leftIndex) {\n // found mergeable line adjacent to the end of the current line, merge\n mergeFromLeft(leftKey, rightKey, geom);\n\n } else {\n // no adjacent lines, add as a new item\n add(k);\n leftIndex[leftKey] = mergedIndex - 1;\n rightIndex[rightKey] = mergedIndex - 1;\n }\n }\n\n return mergedFeatures.filter((f) => f.geometry);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n ColorType\n } from '@maplibre/maplibre-gl-style-spec';\n \nexport type SymbolLayoutProps = {\n \"symbol-placement\": DataConstantProperty<\"point\" | \"line\" | \"line-center\">,\n \"symbol-spacing\": DataConstantProperty,\n \"symbol-avoid-edges\": DataConstantProperty,\n \"symbol-sort-key\": DataDrivenProperty,\n \"symbol-z-order\": DataConstantProperty<\"auto\" | \"viewport-y\" | \"source\">,\n \"icon-allow-overlap\": DataConstantProperty,\n \"icon-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"icon-ignore-placement\": DataConstantProperty,\n \"icon-optional\": DataConstantProperty,\n \"icon-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"icon-size\": DataDrivenProperty,\n \"icon-text-fit\": DataConstantProperty<\"none\" | \"width\" | \"height\" | \"both\">,\n \"icon-text-fit-padding\": DataConstantProperty<[number, number, number, number]>,\n \"icon-image\": DataDrivenProperty,\n \"icon-rotate\": DataDrivenProperty,\n \"icon-padding\": DataDrivenProperty,\n \"icon-keep-upright\": DataConstantProperty,\n \"icon-offset\": DataDrivenProperty<[number, number]>,\n \"icon-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\">,\n \"text-field\": DataDrivenProperty,\n \"text-font\": DataDrivenProperty>,\n \"text-size\": DataDrivenProperty,\n \"text-max-width\": DataDrivenProperty,\n \"text-line-height\": DataConstantProperty,\n \"text-letter-spacing\": DataDrivenProperty,\n \"text-justify\": DataDrivenProperty<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": DataDrivenProperty,\n \"text-variable-anchor\": DataConstantProperty>,\n \"text-variable-anchor-offset\": DataDrivenProperty,\n \"text-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": DataConstantProperty,\n \"text-writing-mode\": DataConstantProperty>,\n \"text-rotate\": DataDrivenProperty,\n \"text-padding\": DataConstantProperty,\n \"text-keep-upright\": DataConstantProperty,\n \"text-transform\": DataDrivenProperty<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": DataDrivenProperty<[number, number]>,\n \"text-allow-overlap\": DataConstantProperty,\n \"text-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"text-ignore-placement\": DataConstantProperty,\n \"text-optional\": DataConstantProperty,\n};\n\nexport type SymbolLayoutPropsPossiblyEvaluated = {\n \"symbol-placement\": \"point\" | \"line\" | \"line-center\",\n \"symbol-spacing\": number,\n \"symbol-avoid-edges\": boolean,\n \"symbol-sort-key\": PossiblyEvaluatedPropertyValue,\n \"symbol-z-order\": \"auto\" | \"viewport-y\" | \"source\",\n \"icon-allow-overlap\": boolean,\n \"icon-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"icon-ignore-placement\": boolean,\n \"icon-optional\": boolean,\n \"icon-rotation-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"icon-size\": PossiblyEvaluatedPropertyValue,\n \"icon-text-fit\": \"none\" | \"width\" | \"height\" | \"both\",\n \"icon-text-fit-padding\": [number, number, number, number],\n \"icon-image\": PossiblyEvaluatedPropertyValue,\n \"icon-rotate\": PossiblyEvaluatedPropertyValue,\n \"icon-padding\": PossiblyEvaluatedPropertyValue,\n \"icon-keep-upright\": boolean,\n \"icon-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"icon-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-rotation-alignment\": \"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\",\n \"text-field\": PossiblyEvaluatedPropertyValue,\n \"text-font\": PossiblyEvaluatedPropertyValue>,\n \"text-size\": PossiblyEvaluatedPropertyValue,\n \"text-max-width\": PossiblyEvaluatedPropertyValue,\n \"text-line-height\": number,\n \"text-letter-spacing\": PossiblyEvaluatedPropertyValue,\n \"text-justify\": PossiblyEvaluatedPropertyValue<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": PossiblyEvaluatedPropertyValue,\n \"text-variable-anchor\": Array<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-variable-anchor-offset\": PossiblyEvaluatedPropertyValue,\n \"text-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": number,\n \"text-writing-mode\": Array<\"horizontal\" | \"vertical\">,\n \"text-rotate\": PossiblyEvaluatedPropertyValue,\n \"text-padding\": number,\n \"text-keep-upright\": boolean,\n \"text-transform\": PossiblyEvaluatedPropertyValue<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"text-allow-overlap\": boolean,\n \"text-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"text-ignore-placement\": boolean,\n \"text-optional\": boolean,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"symbol-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-placement\"] as any as StylePropertySpecification),\n \"symbol-spacing\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-spacing\"] as any as StylePropertySpecification),\n \"symbol-avoid-edges\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-avoid-edges\"] as any as StylePropertySpecification),\n \"symbol-sort-key\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"symbol-sort-key\"] as any as StylePropertySpecification),\n \"symbol-z-order\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-z-order\"] as any as StylePropertySpecification),\n \"icon-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-allow-overlap\"] as any as StylePropertySpecification),\n \"icon-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-overlap\"] as any as StylePropertySpecification),\n \"icon-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-ignore-placement\"] as any as StylePropertySpecification),\n \"icon-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-optional\"] as any as StylePropertySpecification),\n \"icon-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-rotation-alignment\"] as any as StylePropertySpecification),\n \"icon-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-size\"] as any as StylePropertySpecification),\n \"icon-text-fit\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit\"] as any as StylePropertySpecification),\n \"icon-text-fit-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit-padding\"] as any as StylePropertySpecification),\n \"icon-image\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-image\"] as any as StylePropertySpecification),\n \"icon-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-rotate\"] as any as StylePropertySpecification),\n \"icon-padding\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-padding\"] as any as StylePropertySpecification),\n \"icon-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-keep-upright\"] as any as StylePropertySpecification),\n \"icon-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-offset\"] as any as StylePropertySpecification),\n \"icon-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-anchor\"] as any as StylePropertySpecification),\n \"icon-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-rotation-alignment\"] as any as StylePropertySpecification),\n \"text-field\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-field\"] as any as StylePropertySpecification),\n \"text-font\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-font\"] as any as StylePropertySpecification),\n \"text-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-size\"] as any as StylePropertySpecification),\n \"text-max-width\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-max-width\"] as any as StylePropertySpecification),\n \"text-line-height\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-line-height\"] as any as StylePropertySpecification),\n \"text-letter-spacing\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-letter-spacing\"] as any as StylePropertySpecification),\n \"text-justify\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-justify\"] as any as StylePropertySpecification),\n \"text-radial-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-radial-offset\"] as any as StylePropertySpecification),\n \"text-variable-anchor\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor\"] as any as StylePropertySpecification),\n \"text-variable-anchor-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor-offset\"] as any as StylePropertySpecification),\n \"text-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-anchor\"] as any as StylePropertySpecification),\n \"text-max-angle\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-max-angle\"] as any as StylePropertySpecification),\n \"text-writing-mode\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-writing-mode\"] as any as StylePropertySpecification),\n \"text-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-rotate\"] as any as StylePropertySpecification),\n \"text-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-padding\"] as any as StylePropertySpecification),\n \"text-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-keep-upright\"] as any as StylePropertySpecification),\n \"text-transform\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-transform\"] as any as StylePropertySpecification),\n \"text-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-offset\"] as any as StylePropertySpecification),\n \"text-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-allow-overlap\"] as any as StylePropertySpecification),\n \"text-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-overlap\"] as any as StylePropertySpecification),\n \"text-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-ignore-placement\"] as any as StylePropertySpecification),\n \"text-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-optional\"] as any as StylePropertySpecification),\n});\n\nexport type SymbolPaintProps = {\n \"icon-opacity\": DataDrivenProperty,\n \"icon-color\": DataDrivenProperty,\n \"icon-halo-color\": DataDrivenProperty,\n \"icon-halo-width\": DataDrivenProperty,\n \"icon-halo-blur\": DataDrivenProperty,\n \"icon-translate\": DataConstantProperty<[number, number]>,\n \"icon-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"text-opacity\": DataDrivenProperty,\n \"text-color\": DataDrivenProperty,\n \"text-halo-color\": DataDrivenProperty,\n \"text-halo-width\": DataDrivenProperty,\n \"text-halo-blur\": DataDrivenProperty,\n \"text-translate\": DataConstantProperty<[number, number]>,\n \"text-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n};\n\nexport type SymbolPaintPropsPossiblyEvaluated = {\n \"icon-opacity\": PossiblyEvaluatedPropertyValue,\n \"icon-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-width\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"icon-translate\": [number, number],\n \"icon-translate-anchor\": \"map\" | \"viewport\",\n \"text-opacity\": PossiblyEvaluatedPropertyValue,\n \"text-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-width\": PossiblyEvaluatedPropertyValue,\n \"text-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"text-translate\": [number, number],\n \"text-translate-anchor\": \"map\" | \"viewport\",\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"icon-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-opacity\"] as any as StylePropertySpecification),\n \"icon-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-color\"] as any as StylePropertySpecification),\n \"icon-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-color\"] as any as StylePropertySpecification),\n \"icon-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-width\"] as any as StylePropertySpecification),\n \"icon-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-blur\"] as any as StylePropertySpecification),\n \"icon-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate\"] as any as StylePropertySpecification),\n \"icon-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate-anchor\"] as any as StylePropertySpecification),\n \"text-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-opacity\"] as any as StylePropertySpecification),\n \"text-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-color\"] as any as StylePropertySpecification, { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }),\n \"text-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-color\"] as any as StylePropertySpecification),\n \"text-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-width\"] as any as StylePropertySpecification),\n \"text-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-blur\"] as any as StylePropertySpecification),\n \"text-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate\"] as any as StylePropertySpecification),\n \"text-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate-anchor\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import type {Expression, EvaluationContext, Type, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {NullType} from '@maplibre/maplibre-gl-style-spec';\nimport {PossiblyEvaluatedPropertyValue} from './properties';\nimport {register} from '../util/web_worker_transfer';\n\n// This is an internal expression class. It is only used in GL JS and\n// has GL JS dependencies which can break the standalone style-spec module\nexport class FormatSectionOverride implements Expression {\n type: Type;\n defaultValue: PossiblyEvaluatedPropertyValue;\n\n constructor(defaultValue: PossiblyEvaluatedPropertyValue) {\n if (defaultValue.property.overrides === undefined) throw new Error('overrides must be provided to instantiate FormatSectionOverride class');\n this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType;\n this.defaultValue = defaultValue;\n }\n\n evaluate(ctx: EvaluationContext) {\n if (ctx.formattedSection) {\n const overrides = this.defaultValue.property.overrides;\n if (overrides && overrides.hasOverride(ctx.formattedSection)) {\n return overrides.getOverride(ctx.formattedSection);\n }\n }\n\n if (ctx.feature && ctx.featureState) {\n return this.defaultValue.evaluate(ctx.feature, ctx.featureState);\n }\n\n return this.defaultValue.property.specification.default;\n }\n\n eachChild(fn: (_: Expression) => void) {\n if (!this.defaultValue.isConstant()) {\n const expr: ZoomConstantExpression<'source'> = (this.defaultValue.value as any);\n fn(expr._styleExpression.expression);\n }\n }\n\n // Cannot be statically evaluated, as the output depends on the evaluation context.\n outputDefined() {\n return false;\n }\n\n serialize() {\n return null;\n }\n}\n\nregister('FormatSectionOverride', FormatSectionOverride, {omit: ['defaultValue']});\n","import {StyleLayer} from '../style_layer';\n\nimport {SymbolBucket, SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {resolveTokens} from '../../util/resolve_tokens';\nimport properties, {SymbolLayoutPropsPossiblyEvaluated, SymbolPaintPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\n\nimport {\n Transitionable,\n Transitioning,\n Layout,\n PossiblyEvaluated,\n PossiblyEvaluatedPropertyValue,\n PropertyValue\n} from '../properties';\n\nimport {\n isExpression,\n StyleExpression,\n ZoomConstantExpression,\n ZoomDependentExpression,\n FormattedType,\n typeOf,\n Formatted,\n FormatExpression,\n Literal} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BucketParameters} from '../../data/bucket';\nimport type {SymbolLayoutProps, SymbolPaintProps} from './symbol_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Expression, Feature, SourceExpression, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport {FormatSectionOverride} from '../format_section_override';\n\nexport class SymbolStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n if (this.layout.get('icon-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['icon-rotation-alignment'] = 'map';\n } else {\n this.layout._values['icon-rotation-alignment'] = 'viewport';\n }\n }\n\n if (this.layout.get('text-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['text-rotation-alignment'] = 'map';\n } else {\n this.layout._values['text-rotation-alignment'] = 'viewport';\n }\n }\n\n // If unspecified, `*-pitch-alignment` inherits `*-rotation-alignment`\n if (this.layout.get('text-pitch-alignment') === 'auto') {\n this.layout._values['text-pitch-alignment'] = this.layout.get('text-rotation-alignment') === 'map' ? 'map' : 'viewport';\n }\n if (this.layout.get('icon-pitch-alignment') === 'auto') {\n this.layout._values['icon-pitch-alignment'] = this.layout.get('icon-rotation-alignment');\n }\n\n if (this.layout.get('symbol-placement') === 'point') {\n const writingModes = this.layout.get('text-writing-mode');\n if (writingModes) {\n // remove duplicates, preserving order\n const deduped = [];\n for (const m of writingModes) {\n if (deduped.indexOf(m) < 0) deduped.push(m);\n }\n this.layout._values['text-writing-mode'] = deduped;\n } else {\n this.layout._values['text-writing-mode'] = ['horizontal'];\n }\n }\n\n this._setPaintOverrides();\n }\n\n getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array) {\n const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages);\n const unevaluated = this._unevaluatedLayout._values[name];\n if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) {\n return resolveTokens(feature.properties, value);\n }\n\n return value;\n }\n\n createBucket(parameters: BucketParameters) {\n return new SymbolBucket(parameters);\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n throw new Error('Should take a different path in FeatureIndex');\n }\n\n _setPaintOverrides() {\n for (const overridable of properties.paint.overridableProperties) {\n if (!SymbolStyleLayer.hasPaintOverride(this.layout, overridable)) {\n continue;\n }\n const overriden = this.paint.get(overridable as keyof SymbolPaintPropsPossiblyEvaluated) as PossiblyEvaluatedPropertyValue;\n const override = new FormatSectionOverride(overriden);\n const styleExpression = new StyleExpression(override, overriden.property.specification);\n let expression = null;\n if (overriden.value.kind === 'constant' || overriden.value.kind === 'source') {\n expression = new ZoomConstantExpression('source', styleExpression) as SourceExpression;\n } else {\n expression = new ZoomDependentExpression('composite',\n styleExpression,\n overriden.value.zoomStops);\n }\n this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property,\n expression,\n overriden.parameters);\n }\n }\n\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) {\n return false;\n }\n return SymbolStyleLayer.hasPaintOverride(this.layout, name);\n }\n\n static hasPaintOverride(layout: PossiblyEvaluated, propertyName: string): boolean {\n const textField = layout.get('text-field');\n const property = properties.paint.properties[propertyName];\n let hasOverrides = false;\n\n const checkSections = (sections) => {\n for (const section of sections) {\n if (property.overrides && property.overrides.hasOverride(section)) {\n hasOverrides = true;\n return;\n }\n }\n };\n\n if (textField.value.kind === 'constant' && textField.value.value instanceof Formatted) {\n checkSections(textField.value.value.sections);\n } else if (textField.value.kind === 'source') {\n\n const checkExpression = (expression: Expression) => {\n if (hasOverrides) return;\n\n if (expression instanceof Literal && typeOf(expression.value) === FormattedType) {\n const formatted: Formatted = (expression.value as any);\n checkSections(formatted.sections);\n } else if (expression instanceof FormatExpression) {\n checkSections(expression.sections);\n } else {\n expression.eachChild(checkExpression);\n }\n };\n\n const expr: ZoomConstantExpression<'source'> = (textField.value as any);\n if (expr._styleExpression) {\n checkExpression(expr._styleExpression.expression);\n }\n }\n\n return hasOverrides;\n }\n}\n\nexport type SymbolPadding = [number, number, number, number];\n\nexport function getIconPadding(layout: PossiblyEvaluated, feature: SymbolFeature, canonical: CanonicalTileID, pixelRatio = 1): SymbolPadding {\n // Support text-padding in addition to icon-padding? Unclear how to apply asymmetric text-padding to the radius for collision circles.\n const result = layout.get('icon-padding').evaluate(feature, {}, canonical);\n const values = result && result.values;\n\n return [\n values[0] * pixelRatio,\n values[1] * pixelRatio,\n values[2] * pixelRatio,\n values[3] * pixelRatio,\n ];\n}\n","/**\n * Replace tokens in a string template with values in an object\n *\n * @param properties - a key/value relationship between tokens and replacements\n * @param text - the template string\n * @returns the template with tokens replaced\n */\nexport function resolveTokens(\n properties: {\n readonly [x: string]: unknown;\n } | null,\n text: string\n): string {\n return text.replace(/{([^{}]+)}/g, (match, key: string) => {\n return properties && key in properties ? String(properties[key]) : '';\n });\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type BackgroundPaintProps = {\n \"background-color\": DataConstantProperty,\n \"background-pattern\": CrossFadedProperty,\n \"background-opacity\": DataConstantProperty,\n};\n\nexport type BackgroundPaintPropsPossiblyEvaluated = {\n \"background-color\": Color,\n \"background-pattern\": CrossFaded,\n \"background-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"background-color\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-color\"] as any as StylePropertySpecification),\n \"background-pattern\": new CrossFadedProperty(styleSpec[\"paint_background\"][\"background-pattern\"] as any as StylePropertySpecification),\n \"background-opacity\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {BackgroundPaintProps} from './background_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class BackgroundStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type RasterPaintProps = {\n \"raster-opacity\": DataConstantProperty,\n \"raster-hue-rotate\": DataConstantProperty,\n \"raster-brightness-min\": DataConstantProperty,\n \"raster-brightness-max\": DataConstantProperty,\n \"raster-saturation\": DataConstantProperty,\n \"raster-contrast\": DataConstantProperty,\n \"raster-resampling\": DataConstantProperty<\"linear\" | \"nearest\">,\n \"raster-fade-duration\": DataConstantProperty,\n};\n\nexport type RasterPaintPropsPossiblyEvaluated = {\n \"raster-opacity\": number,\n \"raster-hue-rotate\": number,\n \"raster-brightness-min\": number,\n \"raster-brightness-max\": number,\n \"raster-saturation\": number,\n \"raster-contrast\": number,\n \"raster-resampling\": \"linear\" | \"nearest\",\n \"raster-fade-duration\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"raster-opacity\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-opacity\"] as any as StylePropertySpecification),\n \"raster-hue-rotate\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-hue-rotate\"] as any as StylePropertySpecification),\n \"raster-brightness-min\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-min\"] as any as StylePropertySpecification),\n \"raster-brightness-max\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-max\"] as any as StylePropertySpecification),\n \"raster-saturation\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-saturation\"] as any as StylePropertySpecification),\n \"raster-contrast\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-contrast\"] as any as StylePropertySpecification),\n \"raster-resampling\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-resampling\"] as any as StylePropertySpecification),\n \"raster-fade-duration\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-fade-duration\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {RasterPaintPropsPossiblyEvaluated} from './raster_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {RasterPaintProps} from './raster_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class RasterStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","import {StyleLayer} from '../style_layer';\nimport type {Map} from '../../ui/map';\nimport {mat4} from 'gl-matrix';\nimport {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * @param gl - The map's gl context.\n * @param matrix - The map's camera matrix. It projects spherical mercator\n * coordinates to gl coordinates. The spherical mercator coordinate `[0, 0]` represents the\n * top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When\n * the `renderingMode` is `\"3d\"`, the z coordinate is conformal. A box with identical x, y, and z\n * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate.fromLngLat}\n * can be used to project a `LngLat` to a mercator coordinate.\n */\ntype CustomRenderMethod = (gl: WebGLRenderingContext|WebGL2RenderingContext, matrix: mat4) => void;\n\n/**\n * Interface for custom style layers. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Custom layers allow a user to render directly into the map's GL context using the map's camera.\n * These layers can be added between any regular layers using {@link Map#addLayer}.\n *\n * Custom layers must have a unique `id` and must have the `type` of `\"custom\"`.\n * They must implement `render` and may implement `prerender`, `onAdd` and `onRemove`.\n * They can trigger rendering using {@link Map#triggerRepaint}\n * and they should appropriately handle {@link MapContextEvent} with `webglcontextlost` and `webglcontextrestored`.\n *\n * The `renderingMode` property controls whether the layer is treated as a `\"2d\"` or `\"3d\"` map layer. Use:\n * - `\"renderingMode\": \"3d\"` to use the depth buffer and share it with other layers\n * - `\"renderingMode\": \"2d\"` to add a layer with no depth. If you need to use the depth buffer for a `\"2d\"` layer you must use an offscreen\n * framebuffer and {@link CustomLayerInterface#prerender}\n *\n * @example\n * Custom layer implemented as ES6 class\n * ```ts\n * class NullIslandLayer {\n * constructor() {\n * this.id = 'null-island';\n * this.type = 'custom';\n * this.renderingMode = '2d';\n * }\n *\n * onAdd(map, gl) {\n * const vertexSource = `\n * uniform mat4 u_matrix;\n * void main() {\n * gl_Position = u_matrix * vec4(0.5, 0.5, 0.0, 1.0);\n * gl_PointSize = 20.0;\n * }`;\n *\n * const fragmentSource = `\n * void main() {\n * fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n * }`;\n *\n * const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n * gl.shaderSource(vertexShader, vertexSource);\n * gl.compileShader(vertexShader);\n * const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n * gl.shaderSource(fragmentShader, fragmentSource);\n * gl.compileShader(fragmentShader);\n *\n * this.program = gl.createProgram();\n * gl.attachShader(this.program, vertexShader);\n * gl.attachShader(this.program, fragmentShader);\n * gl.linkProgram(this.program);\n * }\n *\n * render(gl, matrix) {\n * gl.useProgram(this.program);\n * gl.uniformMatrix4fv(gl.getUniformLocation(this.program, \"u_matrix\"), false, matrix);\n * gl.drawArrays(gl.POINTS, 0, 1);\n * }\n * }\n *\n * map.on('load', function() {\n * map.addLayer(new NullIslandLayer());\n * });\n * ```\n */\nexport interface CustomLayerInterface {\n /**\n * A unique layer id.\n */\n id: string;\n /**\n * The layer's type. Must be `\"custom\"`.\n */\n type: 'custom';\n /**\n * Either `\"2d\"` or `\"3d\"`. Defaults to `\"2d\"`.\n */\n renderingMode?: '2d' | '3d';\n /**\n * Called during a render frame allowing the layer to draw into the GL context.\n *\n * The layer can assume blending and depth state is set to allow the layer to properly\n * blend and clip other layers. The layer cannot make any other assumptions about the\n * current GL state.\n *\n * If the layer needs to render to a texture, it should implement the `prerender` method\n * to do this and only use the `render` method for drawing directly into the main framebuffer.\n *\n * The blend function is set to `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. This expects\n * colors to be provided in premultiplied alpha form where the `r`, `g` and `b` values are already\n * multiplied by the `a` value. If you are unable to provide colors in premultiplied form you\n * may want to change the blend function to\n * `gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`.\n */\n render: CustomRenderMethod;\n /**\n * Optional method called during a render frame to allow a layer to prepare resources or render into a texture.\n *\n * The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering.\n */\n prerender?: CustomRenderMethod;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This\n * gives the layer a chance to initialize gl resources and register event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onAdd?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n /**\n * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This\n * gives the layer a chance to clean up gl resources and event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onRemove?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n}\n\nexport function validateCustomStyleLayer(layerObject: CustomLayerInterface) {\n const errors = [];\n const id = layerObject.id;\n\n if (id === undefined) {\n errors.push({\n message: `layers.${id}: missing required property \"id\"`\n });\n }\n\n if (layerObject.render === undefined) {\n errors.push({\n message: `layers.${id}: missing required method \"render\"`\n });\n }\n\n if (layerObject.renderingMode &&\n layerObject.renderingMode !== '2d' &&\n layerObject.renderingMode !== '3d') {\n errors.push({\n message: `layers.${id}: property \"renderingMode\" must be either \"2d\" or \"3d\"`\n });\n }\n\n return errors;\n}\n\nexport class CustomStyleLayer extends StyleLayer {\n\n implementation: CustomLayerInterface;\n\n constructor(implementation: CustomLayerInterface) {\n super(implementation, {});\n this.implementation = implementation;\n }\n\n is3D() {\n return this.implementation.renderingMode === '3d';\n }\n\n hasOffscreenPass() {\n return this.implementation.prerender !== undefined;\n }\n\n recalculate() {}\n updateTransitions() {}\n hasTransition() { return false; }\n\n serialize(): LayerSpecification {\n throw new Error('Custom layers cannot be serialized');\n }\n\n onAdd = (map: Map) => {\n if (this.implementation.onAdd) {\n this.implementation.onAdd(map, map.painter.context.gl);\n }\n };\n\n onRemove = (map: Map) => {\n if (this.implementation.onRemove) {\n this.implementation.onRemove(map, map.painter.context.gl);\n }\n };\n}\n","import {CircleStyleLayer} from './style_layer/circle_style_layer';\nimport {HeatmapStyleLayer} from './style_layer/heatmap_style_layer';\nimport {HillshadeStyleLayer} from './style_layer/hillshade_style_layer';\nimport {FillStyleLayer} from './style_layer/fill_style_layer';\nimport {FillExtrusionStyleLayer} from './style_layer/fill_extrusion_style_layer';\nimport {LineStyleLayer} from './style_layer/line_style_layer';\nimport {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport {BackgroundStyleLayer} from './style_layer/background_style_layer';\nimport {RasterStyleLayer} from './style_layer/raster_style_layer';\nimport {CustomStyleLayer, type CustomLayerInterface} from './style_layer/custom_style_layer';\n\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) {\n if (layer.type === 'custom') {\n return new CustomStyleLayer(layer);\n }\n switch (layer.type) {\n case 'background':\n return new BackgroundStyleLayer(layer);\n case 'circle':\n return new CircleStyleLayer(layer);\n case 'fill':\n return new FillStyleLayer(layer);\n case 'fill-extrusion':\n return new FillExtrusionStyleLayer(layer);\n case 'heatmap':\n return new HeatmapStyleLayer(layer);\n case 'hillshade':\n return new HillshadeStyleLayer(layer);\n case 'line':\n return new LineStyleLayer(layer);\n case 'raster':\n return new RasterStyleLayer(layer);\n case 'symbol':\n return new SymbolStyleLayer(layer);\n }\n}\n\n","import {StyleLayer} from './style_layer';\nimport {createStyleLayer} from './create_style_layer';\n\nimport {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {TypedStyleLayer} from './style_layer/typed_style_layer';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LayerConfigs = {[_: string]: LayerSpecification};\nexport type Family = Array;\n\nexport class StyleLayerIndex {\n familiesBySource: {\n [source: string]: {\n [sourceLayer: string]: Array>;\n };\n };\n keyCache: {[source: string]: string};\n\n _layerConfigs: LayerConfigs;\n _layers: {[_: string]: StyleLayer};\n\n constructor(layerConfigs?: Array | null) {\n this.keyCache = {};\n if (layerConfigs) {\n this.replace(layerConfigs);\n }\n }\n\n replace(layerConfigs: Array) {\n this._layerConfigs = {};\n this._layers = {};\n this.update(layerConfigs, []);\n }\n\n update(layerConfigs: Array, removedIds: Array) {\n for (const layerConfig of layerConfigs) {\n this._layerConfigs[layerConfig.id] = layerConfig;\n\n const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig);\n layer._featureFilter = featureFilter(layer.filter);\n if (this.keyCache[layerConfig.id])\n delete this.keyCache[layerConfig.id];\n }\n for (const id of removedIds) {\n delete this.keyCache[id];\n delete this._layerConfigs[id];\n delete this._layers[id];\n }\n\n this.familiesBySource = {};\n\n const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache);\n\n for (const layerConfigs of groups) {\n const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]);\n\n const layer = layers[0];\n if (layer.visibility === 'none') {\n continue;\n }\n\n const sourceId = layer.source || '';\n let sourceGroup = this.familiesBySource[sourceId];\n if (!sourceGroup) {\n sourceGroup = this.familiesBySource[sourceId] = {};\n }\n\n const sourceLayerId = layer.sourceLayer || '_geojsonTileLayer';\n let sourceLayerFamilies = sourceGroup[sourceLayerId];\n if (!sourceLayerFamilies) {\n sourceLayerFamilies = sourceGroup[sourceLayerId] = [];\n }\n\n sourceLayerFamilies.push(layers);\n }\n }\n}\n","export class DictionaryCoder {\n _stringToNumber: {[_: string]: number};\n _numberToString: Array;\n\n constructor(strings: Array) {\n this._stringToNumber = {};\n this._numberToString = [];\n for (let i = 0; i < strings.length; i++) {\n const string = strings[i];\n this._stringToNumber[string] = i;\n this._numberToString[i] = string;\n }\n }\n\n encode(string: string) {\n return this._stringToNumber[string];\n }\n\n decode(n: number) {\n if (n >= this._numberToString.length) throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`);\n return this._numberToString[n];\n }\n}\n","import type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveKeys = T extends T ? keyof T : never;\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveOmit> = T extends unknown\n ? Omit\n : never;\n\n/**\n * An extended geojson feature used by the events to return data to the listener\n */\nexport type MapGeoJSONFeature = GeoJSONFeature & {\n layer: DistributiveOmit & {source: string};\n source: string;\n sourceLayer?: string;\n state: { [key: string]: any };\n}\n\n/**\n * A geojson feature\n */\nexport class GeoJSONFeature {\n type: 'Feature';\n _geometry: GeoJSON.Geometry;\n properties: { [name: string]: any };\n id: number | string | undefined;\n\n _vectorTileFeature: VectorTileFeature;\n\n constructor(vectorTileFeature: VectorTileFeature, z: number, x: number, y: number, id: string | number | undefined) {\n this.type = 'Feature';\n\n this._vectorTileFeature = vectorTileFeature;\n (vectorTileFeature as any)._z = z;\n (vectorTileFeature as any)._x = x;\n (vectorTileFeature as any)._y = y;\n\n this.properties = vectorTileFeature.properties;\n this.id = id;\n }\n\n get geometry(): GeoJSON.Geometry {\n if (this._geometry === undefined) {\n this._geometry = this._vectorTileFeature.toGeoJSON(\n (this._vectorTileFeature as any)._x,\n (this._vectorTileFeature as any)._y,\n (this._vectorTileFeature as any)._z).geometry;\n }\n return this._geometry;\n }\n\n set geometry(g: GeoJSON.Geometry) {\n this._geometry = g;\n }\n\n toJSON() {\n const json: any = {\n geometry: this.geometry\n };\n for (const i in this) {\n if (i === '_geometry' || i === '_vectorTileFeature') continue;\n json[i] = (this)[i];\n }\n return json;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {loadGeometry} from './load_geometry';\nimport {toEvaluationFeature} from './evaluation_feature';\nimport {EXTENT} from './extent';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {TransferableGridIndex} from '../util/transferable_grid_index';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {arraysIntersect, mapObject, extend} from '../util/util';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {polygonIntersectsBox} from '../util/intersection_tests';\nimport {PossiblyEvaluated} from '../style/properties';\nimport {FeatureIndexArray} from './array_types.g';\nimport {mat4} from 'gl-matrix';\n\nimport type {StyleLayer} from '../style/style_layer';\nimport type {FeatureFilter, FeatureState, FilterSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\n\ntype QueryParameters = {\n scale: number;\n pixelPosMatrix: mat4;\n transform: Transform;\n tileSize: number;\n queryGeometry: Array;\n cameraQueryGeometry: Array;\n queryPadding: number;\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n };\n};\n\n/**\n * @internal\n * An in memory index class to allow fast interaction with features\n */\nexport class FeatureIndex {\n tileID: OverscaledTileID;\n x: number;\n y: number;\n z: number;\n grid: TransferableGridIndex;\n grid3D: TransferableGridIndex;\n featureIndexArray: FeatureIndexArray;\n promoteId?: PromoteIdSpecification;\n\n rawTileData: ArrayBuffer;\n bucketLayerIDs: Array>;\n\n vtLayers: {[_: string]: VectorTileLayer};\n sourceLayerCoder: DictionaryCoder;\n\n constructor(tileID: OverscaledTileID, promoteId?: PromoteIdSpecification | null) {\n this.tileID = tileID;\n this.x = tileID.canonical.x;\n this.y = tileID.canonical.y;\n this.z = tileID.canonical.z;\n this.grid = new TransferableGridIndex(EXTENT, 16, 0);\n this.grid3D = new TransferableGridIndex(EXTENT, 16, 0);\n this.featureIndexArray = new FeatureIndexArray();\n this.promoteId = promoteId;\n }\n\n insert(feature: VectorTileFeature, geometry: Array>, featureIndex: number, sourceLayerIndex: number, bucketIndex: number, is3D?: boolean) {\n const key = this.featureIndexArray.length;\n this.featureIndexArray.emplaceBack(featureIndex, sourceLayerIndex, bucketIndex);\n\n const grid = is3D ? this.grid3D : this.grid;\n\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n bbox[0] = Math.min(bbox[0], p.x);\n bbox[1] = Math.min(bbox[1], p.y);\n bbox[2] = Math.max(bbox[2], p.x);\n bbox[3] = Math.max(bbox[3], p.y);\n }\n\n if (bbox[0] < EXTENT &&\n bbox[1] < EXTENT &&\n bbox[2] >= 0 &&\n bbox[3] >= 0) {\n grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]);\n }\n }\n }\n\n loadVTLayers(): {[_: string]: VectorTileLayer} {\n if (!this.vtLayers) {\n this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers;\n this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']);\n }\n return this.vtLayers;\n }\n\n // Finds non-symbol features in this tile at a particular position.\n query(\n args: QueryParameters,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n this.loadVTLayers();\n\n const params = args.params || {} as { filter: any; layers: string[]; availableImages: string[] },\n pixelsToTileUnits = EXTENT / args.tileSize / args.scale,\n filter = featureFilter(params.filter);\n\n const queryGeometry = args.queryGeometry;\n const queryPadding = args.queryPadding * pixelsToTileUnits;\n\n const bounds = getBounds(queryGeometry);\n const matching = this.grid.query(bounds.minX - queryPadding, bounds.minY - queryPadding, bounds.maxX + queryPadding, bounds.maxY + queryPadding);\n\n const cameraBounds = getBounds(args.cameraQueryGeometry);\n const matching3D = this.grid3D.query(\n cameraBounds.minX - queryPadding, cameraBounds.minY - queryPadding, cameraBounds.maxX + queryPadding, cameraBounds.maxY + queryPadding,\n (bx1, by1, bx2, by2) => {\n return polygonIntersectsBox(args.cameraQueryGeometry, bx1 - queryPadding, by1 - queryPadding, bx2 + queryPadding, by2 + queryPadding);\n });\n\n for (const key of matching3D) {\n matching.push(key);\n }\n\n matching.sort(topDownFeatureComparator);\n\n const result = {};\n let previousIndex;\n for (let k = 0; k < matching.length; k++) {\n const index = matching[k];\n\n // don't check the same feature more than once\n if (index === previousIndex) continue;\n previousIndex = index;\n\n const match = this.featureIndexArray.get(index);\n let featureGeometry = null;\n this.loadMatchingFeature(\n result,\n match.bucketIndex,\n match.sourceLayerIndex,\n match.featureIndex,\n filter,\n params.layers,\n params.availableImages,\n styleLayers,\n serializedLayers,\n sourceFeatureState,\n (feature: VectorTileFeature, styleLayer: StyleLayer, featureState: FeatureState) => {\n if (!featureGeometry) {\n featureGeometry = loadGeometry(feature);\n }\n\n return styleLayer.queryIntersectsFeature(queryGeometry, feature, featureState, featureGeometry, this.z, args.transform, pixelsToTileUnits, args.pixelPosMatrix);\n }\n );\n }\n\n return result;\n }\n\n loadMatchingFeature(\n result: {\n [_: string]: Array<{\n featureIndex: number;\n feature: GeoJSONFeature;\n intersectionZ?: boolean | number;\n }>;\n },\n bucketIndex: number,\n sourceLayerIndex: number,\n featureIndex: number,\n filter: FeatureFilter,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState?: SourceFeatureState,\n intersectionTest?: (\n feature: VectorTileFeature,\n styleLayer: StyleLayer,\n featureState: any,\n id: string | number | void\n ) => boolean | number) {\n\n const layerIDs = this.bucketLayerIDs[bucketIndex];\n if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs))\n return;\n\n const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);\n const sourceLayer = this.vtLayers[sourceLayerName];\n const feature = sourceLayer.feature(featureIndex);\n\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) {\n return;\n }\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n return;\n }\n\n const id = this.getId(feature, sourceLayerName);\n\n for (let l = 0; l < layerIDs.length; l++) {\n const layerID = layerIDs[l];\n\n if (filterLayerIDs && filterLayerIDs.indexOf(layerID) < 0) {\n continue;\n }\n\n const styleLayer = styleLayers[layerID];\n\n if (!styleLayer) continue;\n\n let featureState = {};\n if (id && sourceFeatureState) {\n // `feature-state` expression evaluation requires feature state to be available\n featureState = sourceFeatureState.getState(styleLayer.sourceLayer || '_geojsonTileLayer', id);\n }\n\n const serializedLayer = extend({}, serializedLayers[layerID]);\n\n serializedLayer.paint = evaluateProperties(serializedLayer.paint, styleLayer.paint, feature, featureState, availableImages);\n serializedLayer.layout = evaluateProperties(serializedLayer.layout, styleLayer.layout, feature, featureState, availableImages);\n\n const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer, featureState);\n if (!intersectionZ) {\n // Only applied for non-symbol features\n continue;\n }\n\n const geojsonFeature = new GeoJSONFeature(feature, this.z, this.x, this.y, id) as MapGeoJSONFeature;\n geojsonFeature.layer = serializedLayer;\n let layerResult = result[layerID];\n if (layerResult === undefined) {\n layerResult = result[layerID] = [];\n }\n layerResult.push({featureIndex, feature: geojsonFeature, intersectionZ});\n }\n }\n\n // Given a set of symbol indexes that have already been looked up,\n // return a matching set of GeoJSONFeatures\n lookupSymbolFeatures(symbolFeatureIndexes: Array,\n serializedLayers: {[_: string]: StyleLayer},\n bucketIndex: number,\n sourceLayerIndex: number,\n filterSpec: FilterSpecification,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer}) {\n const result = {};\n this.loadVTLayers();\n\n const filter = featureFilter(filterSpec);\n\n for (const symbolFeatureIndex of symbolFeatureIndexes) {\n this.loadMatchingFeature(\n result,\n bucketIndex,\n sourceLayerIndex,\n symbolFeatureIndex,\n filter,\n filterLayerIDs,\n availableImages,\n styleLayers,\n serializedLayers\n );\n\n }\n return result;\n }\n\n hasLayer(id: string) {\n for (const layerIDs of this.bucketLayerIDs) {\n for (const layerID of layerIDs) {\n if (id === layerID) return true;\n }\n }\n\n return false;\n }\n\n getId(feature: VectorTileFeature, sourceLayerId: string): string | number {\n let id: string | number = feature.id;\n if (this.promoteId) {\n const propName = typeof this.promoteId === 'string' ? this.promoteId : this.promoteId[sourceLayerId];\n id = feature.properties[propName] as string | number;\n if (typeof id === 'boolean') id = Number(id);\n }\n return id;\n }\n}\n\nregister(\n 'FeatureIndex',\n FeatureIndex,\n {omit: ['rawTileData', 'sourceLayerCoder']}\n);\n\nfunction evaluateProperties(serializedProperties, styleLayerProperties, feature, featureState, availableImages) {\n return mapObject(serializedProperties, (property, key) => {\n const prop = styleLayerProperties instanceof PossiblyEvaluated ? styleLayerProperties.get(key) : null;\n return prop && prop.evaluate ? prop.evaluate(feature, featureState, availableImages) : prop;\n });\n}\n\nfunction getBounds(geometry: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const p of geometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return {minX, minY, maxX, maxY};\n}\n\nfunction topDownFeatureComparator(a, b) {\n return b - a;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {register} from '../util/web_worker_transfer';\n\nexport class Anchor extends Point {\n angle: any;\n segment?: number;\n\n constructor(x: number, y: number, angle: number, segment?: number) {\n super(x, y);\n this.angle = angle;\n if (segment !== undefined) {\n this.segment = segment;\n }\n }\n\n clone() {\n return new Anchor(this.x, this.y, this.angle, this.segment);\n }\n}\n\nregister('Anchor', Anchor);\n","import type Point from '@mapbox/point-geometry';\nimport type {Anchor} from './anchor';\n\n/**\n * Labels placed around really sharp angles aren't readable. Check if any\n * part of the potential label has a combined angle that is too big.\n *\n * @param line - The line to check\n * @param anchor - The point on the line around which the label is anchored.\n * @param labelLength - The length of the label in geometry units.\n * @param windowSize - The check fails if the combined angles within a part of the line that is `windowSize` long is too big.\n * @param maxAngle - The maximum combined angle that any window along the label is allowed to have.\n *\n * @returns whether the label should be placed\n */\nexport function checkMaxAngle(line: Array, anchor: Anchor, labelLength: number, windowSize: number, maxAngle: number) {\n\n // horizontal labels and labels with length 0 always pass\n if (anchor.segment === undefined || labelLength === 0) return true;\n\n let p = anchor;\n let index = anchor.segment + 1;\n let anchorDistance = 0;\n\n // move backwards along the line to the first segment the label appears on\n while (anchorDistance > -labelLength / 2) {\n index--;\n\n // there isn't enough room for the label after the beginning of the line\n if (index < 0) return false;\n\n anchorDistance -= line[index].dist(p);\n p = line[index];\n }\n\n anchorDistance += line[index].dist(line[index + 1]);\n index++;\n\n // store recent corners and their total angle difference\n const recentCorners = [];\n let recentAngleDelta = 0;\n\n // move forwards by the length of the label and check angles along the way\n while (anchorDistance < labelLength / 2) {\n const prev = line[index - 1];\n const current = line[index];\n const next = line[index + 1];\n\n // there isn't enough room for the label before the end of the line\n if (!next) return false;\n\n let angleDelta = prev.angleTo(current) - current.angleTo(next);\n // restrict angle to -pi..pi range\n angleDelta = Math.abs(((angleDelta + 3 * Math.PI) % (Math.PI * 2)) - Math.PI);\n\n recentCorners.push({\n distance: anchorDistance,\n angleDelta\n });\n recentAngleDelta += angleDelta;\n\n // remove corners that are far enough away from the list of recent anchors\n while (anchorDistance - recentCorners[0].distance > windowSize) {\n recentAngleDelta -= recentCorners.shift().angleDelta;\n }\n\n // the sum of angles within the window area exceeds the maximum allowed value. check fails.\n if (recentAngleDelta > maxAngle) return false;\n\n index++;\n anchorDistance += current.dist(next);\n }\n\n // no part of the line had an angle greater than the maximum allowed. check passes.\n return true;\n}\n","import {interpolates} from '@maplibre/maplibre-gl-style-spec';\n\nimport {Anchor} from '../symbol/anchor';\nimport {checkMaxAngle} from './check_max_angle';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {Shaping, PositionedIcon} from './shaping';\n\nexport {getAnchors, getCenterAnchor};\n\nfunction getLineLength(line: Array): number {\n let lineLength = 0;\n for (let k = 0; k < line.length - 1; k++) {\n lineLength += line[k].dist(line[k + 1]);\n }\n return lineLength;\n}\n\nfunction getAngleWindowSize(\n shapedText: Shaping,\n glyphSize: number,\n boxScale: number\n): number {\n return shapedText ?\n 3 / 5 * glyphSize * boxScale :\n 0;\n}\n\nfunction getShapedLabelLength(shapedText?: Shaping | null, shapedIcon?: PositionedIcon | null): number {\n return Math.max(\n shapedText ? shapedText.right - shapedText.left : 0,\n shapedIcon ? shapedIcon.right - shapedIcon.left : 0);\n}\n\nfunction getCenterAnchor(line: Array,\n maxAngle: number,\n shapedText: Shaping,\n shapedIcon: PositionedIcon,\n glyphSize: number,\n boxScale: number) {\n const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);\n const labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale;\n\n let prevDistance = 0;\n const centerDistance = getLineLength(line) / 2;\n\n for (let i = 0; i < line.length - 1; i++) {\n\n const a = line[i],\n b = line[i + 1];\n\n const segmentDistance = a.dist(b);\n\n if (prevDistance + segmentDistance > centerDistance) {\n // The center is on this segment\n const t = (centerDistance - prevDistance) / segmentDistance,\n x = interpolates.number(a.x, b.x, t),\n y = interpolates.number(a.y, b.y, t);\n\n const anchor = new Anchor(x, y, b.angleTo(a), i);\n anchor._round();\n if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {\n return anchor;\n } else {\n return;\n }\n }\n\n prevDistance += segmentDistance;\n }\n}\n\nfunction getAnchors(line: Array,\n spacing: number,\n maxAngle: number,\n shapedText: Shaping,\n shapedIcon: PositionedIcon,\n glyphSize: number,\n boxScale: number,\n overscaling: number,\n tileExtent: number) {\n\n // Resample a line to get anchor points for labels and check that each\n // potential label passes text-max-angle check and has enough froom to fit\n // on the line.\n\n const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);\n const shapedLabelLength = getShapedLabelLength(shapedText, shapedIcon);\n const labelLength = shapedLabelLength * boxScale;\n\n // Is the line continued from outside the tile boundary?\n const isLineContinued = line[0].x === 0 || line[0].x === tileExtent || line[0].y === 0 || line[0].y === tileExtent;\n\n // Is the label long, relative to the spacing?\n // If so, adjust the spacing so there is always a minimum space of `spacing / 4` between label edges.\n if (spacing - labelLength < spacing / 4) {\n spacing = labelLength + spacing / 4;\n }\n\n // Offset the first anchor by:\n // Either half the label length plus a fixed extra offset if the line is not continued\n // Or half the spacing if the line is continued.\n\n // For non-continued lines, add a bit of fixed extra offset to avoid collisions at T intersections.\n const fixedExtraOffset = glyphSize * 2;\n\n const offset = !isLineContinued ?\n ((shapedLabelLength / 2 + fixedExtraOffset) * boxScale * overscaling) % spacing :\n (spacing / 2 * overscaling) % spacing;\n\n return resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, false, tileExtent);\n}\n\nfunction resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, placeAtMiddle, tileExtent) {\n\n const halfLabelLength = labelLength / 2;\n const lineLength = getLineLength(line);\n\n let distance = 0,\n markedDistance = offset - spacing;\n\n let anchors = [];\n\n for (let i = 0; i < line.length - 1; i++) {\n\n const a = line[i],\n b = line[i + 1];\n\n const segmentDist = a.dist(b),\n angle = b.angleTo(a);\n\n while (markedDistance + spacing < distance + segmentDist) {\n markedDistance += spacing;\n\n const t = (markedDistance - distance) / segmentDist,\n x = interpolates.number(a.x, b.x, t),\n y = interpolates.number(a.y, b.y, t);\n\n // Check that the point is within the tile boundaries and that\n // the label would fit before the beginning and end of the line\n // if placed at this point.\n if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent &&\n markedDistance - halfLabelLength >= 0 &&\n markedDistance + halfLabelLength <= lineLength) {\n const anchor = new Anchor(x, y, angle, i);\n anchor._round();\n\n if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {\n anchors.push(anchor);\n }\n }\n }\n\n distance += segmentDist;\n }\n\n if (!placeAtMiddle && !anchors.length && !isLineContinued) {\n // The first attempt at finding anchors at which labels can be placed failed.\n // Try again, but this time just try placing one anchor at the middle of the line.\n // This has the most effect for short lines in overscaled tiles, since the\n // initial offset used in overscaled tiles is calculated to align labels with positions in\n // parent tiles instead of placing the label as close to the beginning as possible.\n anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, true, tileExtent);\n }\n\n return anchors;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\n\nimport type {Anchor} from './anchor';\nimport type {PositionedIcon, Shaping} from './shaping';\nimport {SHAPING_DEFAULT_OFFSET} from './shaping';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport type {StyleImage} from '../style/style_image';\nimport ONE_EM from './one_em';\nimport {Rect} from '../render/glyph_atlas';\n\n/**\n * A textured quad for rendering a single icon or glyph.\n *\n * The zoom range the glyph can be shown is defined by minScale and maxScale.\n *\n * @param tl - The offset of the top left corner from the anchor.\n * @param tr - The offset of the top right corner from the anchor.\n * @param bl - The offset of the bottom left corner from the anchor.\n * @param br - The offset of the bottom right corner from the anchor.\n * @param tex - The texture coordinates.\n */\nexport type SymbolQuad = {\n tl: Point;\n tr: Point;\n bl: Point;\n br: Point;\n tex: {\n x: number;\n y: number;\n w: number;\n h: number;\n };\n pixelOffsetTL: Point;\n pixelOffsetBR: Point;\n writingMode: any | void;\n glyphOffset: [number, number];\n sectionIndex: number;\n isSDF: boolean;\n minFontScaleX: number;\n minFontScaleY: number;\n};\n\n// If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual\n// pixels. The quad needs to be padded to account for this, otherwise they'll look slightly clipped\n// on one edge in some cases.\nconst border = IMAGE_PADDING;\n\n/**\n * Create the quads used for rendering an icon.\n */\nexport function getIconQuads(\n shapedIcon: PositionedIcon,\n iconRotate: number,\n isSDFIcon: boolean,\n hasIconTextFit: boolean\n): Array {\n const quads = [];\n\n const image = shapedIcon.image;\n const pixelRatio = image.pixelRatio;\n const imageWidth = image.paddedRect.w - 2 * border;\n const imageHeight = image.paddedRect.h - 2 * border;\n\n const iconWidth = shapedIcon.right - shapedIcon.left;\n const iconHeight = shapedIcon.bottom - shapedIcon.top;\n\n const stretchX = image.stretchX || [[0, imageWidth]];\n const stretchY = image.stretchY || [[0, imageHeight]];\n\n const reduceRanges = (sum, range) => sum + range[1] - range[0];\n const stretchWidth = stretchX.reduce(reduceRanges, 0);\n const stretchHeight = stretchY.reduce(reduceRanges, 0);\n const fixedWidth = imageWidth - stretchWidth;\n const fixedHeight = imageHeight - stretchHeight;\n\n let stretchOffsetX = 0;\n let stretchContentWidth = stretchWidth;\n let stretchOffsetY = 0;\n let stretchContentHeight = stretchHeight;\n let fixedOffsetX = 0;\n let fixedContentWidth = fixedWidth;\n let fixedOffsetY = 0;\n let fixedContentHeight = fixedHeight;\n\n if (image.content && hasIconTextFit) {\n const content = image.content;\n stretchOffsetX = sumWithinRange(stretchX, 0, content[0]);\n stretchOffsetY = sumWithinRange(stretchY, 0, content[1]);\n stretchContentWidth = sumWithinRange(stretchX, content[0], content[2]);\n stretchContentHeight = sumWithinRange(stretchY, content[1], content[3]);\n fixedOffsetX = content[0] - stretchOffsetX;\n fixedOffsetY = content[1] - stretchOffsetY;\n fixedContentWidth = content[2] - content[0] - stretchContentWidth;\n fixedContentHeight = content[3] - content[1] - stretchContentHeight;\n }\n\n const makeBox = (left, top, right, bottom) => {\n\n const leftEm = getEmOffset(left.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);\n const leftPx = getPxOffset(left.fixed - fixedOffsetX, fixedContentWidth, left.stretch, stretchWidth);\n\n const topEm = getEmOffset(top.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);\n const topPx = getPxOffset(top.fixed - fixedOffsetY, fixedContentHeight, top.stretch, stretchHeight);\n\n const rightEm = getEmOffset(right.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);\n const rightPx = getPxOffset(right.fixed - fixedOffsetX, fixedContentWidth, right.stretch, stretchWidth);\n\n const bottomEm = getEmOffset(bottom.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);\n const bottomPx = getPxOffset(bottom.fixed - fixedOffsetY, fixedContentHeight, bottom.stretch, stretchHeight);\n\n const tl = new Point(leftEm, topEm);\n const tr = new Point(rightEm, topEm);\n const br = new Point(rightEm, bottomEm);\n const bl = new Point(leftEm, bottomEm);\n const pixelOffsetTL = new Point(leftPx / pixelRatio, topPx / pixelRatio);\n const pixelOffsetBR = new Point(rightPx / pixelRatio, bottomPx / pixelRatio);\n\n const angle = iconRotate * Math.PI / 180;\n\n if (angle) {\n const sin = Math.sin(angle),\n cos = Math.cos(angle),\n matrix = [cos, -sin, sin, cos];\n\n tl._matMult(matrix);\n tr._matMult(matrix);\n bl._matMult(matrix);\n br._matMult(matrix);\n }\n\n const x1 = left.stretch + left.fixed;\n const x2 = right.stretch + right.fixed;\n const y1 = top.stretch + top.fixed;\n const y2 = bottom.stretch + bottom.fixed;\n\n const subRect = {\n x: image.paddedRect.x + border + x1,\n y: image.paddedRect.y + border + y1,\n w: x2 - x1,\n h: y2 - y1\n };\n\n const minFontScaleX = fixedContentWidth / pixelRatio / iconWidth;\n const minFontScaleY = fixedContentHeight / pixelRatio / iconHeight;\n\n // Icon quad is padded, so texture coordinates also need to be padded.\n return {tl, tr, bl, br, tex: subRect, writingMode: undefined, glyphOffset: [0, 0], sectionIndex: 0, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, isSDF: isSDFIcon};\n };\n\n if (!hasIconTextFit || (!image.stretchX && !image.stretchY)) {\n quads.push(makeBox(\n {fixed: 0, stretch: -1},\n {fixed: 0, stretch: -1},\n {fixed: 0, stretch: imageWidth + 1},\n {fixed: 0, stretch: imageHeight + 1}));\n } else {\n const xCuts = stretchZonesToCuts(stretchX, fixedWidth, stretchWidth);\n const yCuts = stretchZonesToCuts(stretchY, fixedHeight, stretchHeight);\n\n for (let xi = 0; xi < xCuts.length - 1; xi++) {\n const x1 = xCuts[xi];\n const x2 = xCuts[xi + 1];\n for (let yi = 0; yi < yCuts.length - 1; yi++) {\n const y1 = yCuts[yi];\n const y2 = yCuts[yi + 1];\n quads.push(makeBox(x1, y1, x2, y2));\n }\n }\n }\n\n return quads;\n}\n\nfunction sumWithinRange(ranges, min, max) {\n let sum = 0;\n for (const range of ranges) {\n sum += Math.max(min, Math.min(max, range[1])) - Math.max(min, Math.min(max, range[0]));\n }\n return sum;\n}\n\nfunction stretchZonesToCuts(stretchZones, fixedSize, stretchSize) {\n const cuts = [{fixed: -border, stretch: 0}];\n\n for (const [c1, c2] of stretchZones) {\n const last = cuts[cuts.length - 1];\n cuts.push({\n fixed: c1 - last.stretch,\n stretch: last.stretch\n });\n cuts.push({\n fixed: c1 - last.stretch,\n stretch: last.stretch + (c2 - c1)\n });\n }\n cuts.push({\n fixed: fixedSize + border,\n stretch: stretchSize\n });\n return cuts;\n}\n\nfunction getEmOffset(stretchOffset, stretchSize, iconSize, iconOffset) {\n return stretchOffset / stretchSize * iconSize + iconOffset;\n}\n\nfunction getPxOffset(fixedOffset, fixedSize, stretchOffset, stretchSize) {\n return fixedOffset - fixedSize * stretchOffset / stretchSize;\n}\n\n/**\n * Create the quads used for rendering a text label.\n */\nexport function getGlyphQuads(\n anchor: Anchor,\n shaping: Shaping,\n textOffset: [number, number],\n layer: SymbolStyleLayer,\n alongLine: boolean,\n feature: Feature,\n imageMap: {[_: string]: StyleImage},\n allowVerticalPlacement: boolean\n): Array {\n\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}) * Math.PI / 180;\n const quads = [];\n\n for (const line of shaping.positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n if (!positionedGlyph.rect) continue;\n const textureRect: Rect = positionedGlyph.rect || {} as Rect;\n\n // The rects have an additional buffer that is not included in their size.\n const glyphPadding = 1.0;\n let rectBuffer = GLYPH_PBF_BORDER + glyphPadding;\n let isSDF = true;\n let pixelRatio = 1.0;\n let lineOffset = 0.0;\n\n const rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical;\n const halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2;\n\n // Align images and scaled glyphs in the middle of a vertical line.\n if (allowVerticalPlacement && shaping.verticalizable) {\n const scaledGlyphOffset = (positionedGlyph.scale - 1) * ONE_EM;\n const imageOffset = (ONE_EM - positionedGlyph.metrics.width * positionedGlyph.scale) / 2;\n lineOffset = line.lineOffset / 2 - (positionedGlyph.imageName ? -imageOffset : scaledGlyphOffset);\n }\n\n if (positionedGlyph.imageName) {\n const image = imageMap[positionedGlyph.imageName];\n isSDF = image.sdf;\n pixelRatio = image.pixelRatio;\n rectBuffer = IMAGE_PADDING / pixelRatio;\n }\n\n const glyphOffset = alongLine ?\n [positionedGlyph.x + halfAdvance, positionedGlyph.y] :\n [0, 0];\n\n let builtInOffset: [number, number] = alongLine ?\n [0, 0] :\n [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1] - lineOffset];\n\n let verticalizedLabelOffset = [0, 0] as [number, number];\n if (rotateVerticalGlyph) {\n // Vertical POI labels that are rotated 90deg CW and whose glyphs must preserve upright orientation\n // need to be rotated 90deg CCW. After a quad is rotated, it is translated to the original built-in offset.\n verticalizedLabelOffset = builtInOffset;\n builtInOffset = [0, 0];\n }\n\n const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1;\n\n const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];\n const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1];\n const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio;\n const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio;\n\n const tl = new Point(x1, y1);\n const tr = new Point(x2, y1);\n const bl = new Point(x1, y2);\n const br = new Point(x2, y2);\n\n if (rotateVerticalGlyph) {\n // Vertical-supporting glyphs are laid out in 24x24 point boxes (1 square em)\n // In horizontal orientation, the y values for glyphs are below the midline\n // and we use a \"yOffset\" of -17 to pull them up to the middle.\n // By rotating counter-clockwise around the point at the center of the left\n // edge of a 24x24 layout box centered below the midline, we align the center\n // of the glyphs with the horizontal midline, so the yOffset is no longer\n // necessary, but we also pull the glyph to the left along the x axis.\n // The y coordinate includes baseline yOffset, thus needs to be accounted\n // for when glyph is rotated and translated.\n const center = new Point(-halfAdvance, halfAdvance - SHAPING_DEFAULT_OFFSET);\n const verticalRotation = -Math.PI / 2;\n\n // xHalfWidthOffsetCorrection is a difference between full-width and half-width\n // advance, should be 0 for full-width glyphs and will pull up half-width glyphs.\n const xHalfWidthOffsetCorrection = ONE_EM / 2 - halfAdvance;\n const yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0.0;\n const halfWidthOffsetCorrection = new Point(5 - SHAPING_DEFAULT_OFFSET - xHalfWidthOffsetCorrection, -yImageOffsetCorrection);\n const verticalOffsetCorrection = new Point(...verticalizedLabelOffset);\n tl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n tr._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n bl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n br._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n }\n\n if (textRotate) {\n const sin = Math.sin(textRotate),\n cos = Math.cos(textRotate),\n matrix = [cos, -sin, sin, cos];\n\n tl._matMult(matrix);\n tr._matMult(matrix);\n bl._matMult(matrix);\n br._matMult(matrix);\n }\n\n const pixelOffsetTL = new Point(0, 0);\n const pixelOffsetBR = new Point(0, 0);\n const minFontScaleX = 0;\n const minFontScaleY = 0;\n quads.push({tl, tr, bl, br, tex: textureRect, writingMode: shaping.writingMode, glyphOffset, sectionIndex: positionedGlyph.sectionIndex, isSDF, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY});\n }\n }\n\n return quads;\n}\n","import type {CollisionBoxArray} from '../data/array_types.g';\nimport Point from '@mapbox/point-geometry';\nimport type {Anchor} from './anchor';\nimport {SymbolPadding} from '../style/style_layer/symbol_style_layer';\n\n/**\n * A CollisionFeature represents the area of the tile covered by a single label.\n * It is used with CollisionIndex to check if the label overlaps with any\n * previous labels. A CollisionFeature is mostly just a set of CollisionBox\n * objects.\n */\nexport class CollisionFeature {\n boxStartIndex: number;\n boxEndIndex: number;\n circleDiameter: number;\n\n /**\n * Create a CollisionFeature, adding its collision box data to the given collisionBoxArray in the process.\n * For line aligned labels a collision circle diameter is computed instead.\n *\n * @param anchor - The point along the line around which the label is anchored.\n * @param shaped - The text or icon shaping results.\n * @param boxScale - A magic number used to convert from glyph metrics units to geometry units.\n * @param padding - The amount of padding to add around the label edges.\n * @param alignLine - Whether the label is aligned with the line or the viewport.\n */\n constructor(collisionBoxArray: CollisionBoxArray,\n anchor: Anchor,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n shaped: any,\n boxScale: number,\n padding: SymbolPadding,\n alignLine: boolean,\n rotate: number) {\n\n this.boxStartIndex = collisionBoxArray.length;\n\n if (alignLine) {\n // Compute height of the shape in glyph metrics and apply collision padding.\n // Note that the pixel based 'text-padding' is applied at runtime\n let top = shaped.top;\n let bottom = shaped.bottom;\n const collisionPadding = shaped.collisionPadding;\n\n if (collisionPadding) {\n top -= collisionPadding[1];\n bottom += collisionPadding[3];\n }\n\n let height = bottom - top;\n\n if (height > 0) {\n // set minimum box height to avoid very many small labels\n height = Math.max(10, height);\n this.circleDiameter = height;\n }\n } else {\n // margin is in CSS order: [top, right, bottom, left]\n let y1 = shaped.top * boxScale - padding[0];\n let y2 = shaped.bottom * boxScale + padding[2];\n let x1 = shaped.left * boxScale - padding[3];\n let x2 = shaped.right * boxScale + padding[1];\n\n const collisionPadding = shaped.collisionPadding;\n if (collisionPadding) {\n x1 -= collisionPadding[0] * boxScale;\n y1 -= collisionPadding[1] * boxScale;\n x2 += collisionPadding[2] * boxScale;\n y2 += collisionPadding[3] * boxScale;\n }\n\n if (rotate) {\n // Account for *-rotate in point collision boxes\n // See https://github.com/mapbox/mapbox-gl-js/issues/6075\n // Doesn't account for icon-text-fit\n\n const tl = new Point(x1, y1);\n const tr = new Point(x2, y1);\n const bl = new Point(x1, y2);\n const br = new Point(x2, y2);\n\n const rotateRadians = rotate * Math.PI / 180;\n\n tl._rotate(rotateRadians);\n tr._rotate(rotateRadians);\n bl._rotate(rotateRadians);\n br._rotate(rotateRadians);\n\n // Collision features require an \"on-axis\" geometry,\n // so take the envelope of the rotated geometry\n // (may be quite large for wide labels rotated 45 degrees)\n x1 = Math.min(tl.x, tr.x, bl.x, br.x);\n x2 = Math.max(tl.x, tr.x, bl.x, br.x);\n y1 = Math.min(tl.y, tr.y, bl.y, br.y);\n y2 = Math.max(tl.y, tr.y, bl.y, br.y);\n }\n collisionBoxArray.emplaceBack(anchor.x, anchor.y, x1, y1, x2, y2, featureIndex, sourceLayerIndex, bucketIndex);\n }\n\n this.boxEndIndex = collisionBoxArray.length;\n }\n}\n","\nexport default class TinyQueue {\n constructor(data = [], compare = defaultCompare) {\n this.data = data;\n this.length = this.data.length;\n this.compare = compare;\n\n if (this.length > 0) {\n for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);\n }\n }\n\n push(item) {\n this.data.push(item);\n this.length++;\n this._up(this.length - 1);\n }\n\n pop() {\n if (this.length === 0) return undefined;\n\n const top = this.data[0];\n const bottom = this.data.pop();\n this.length--;\n\n if (this.length > 0) {\n this.data[0] = bottom;\n this._down(0);\n }\n\n return top;\n }\n\n peek() {\n return this.data[0];\n }\n\n _up(pos) {\n const {data, compare} = this;\n const item = data[pos];\n\n while (pos > 0) {\n const parent = (pos - 1) >> 1;\n const current = data[parent];\n if (compare(item, current) >= 0) break;\n data[pos] = current;\n pos = parent;\n }\n\n data[pos] = item;\n }\n\n _down(pos) {\n const {data, compare} = this;\n const halfLength = this.length >> 1;\n const item = data[pos];\n\n while (pos < halfLength) {\n let left = (pos << 1) + 1;\n let best = data[left];\n const right = left + 1;\n\n if (right < this.length && compare(data[right], best) < 0) {\n left = right;\n best = data[right];\n }\n if (compare(best, item) >= 0) break;\n\n data[pos] = best;\n pos = left;\n }\n\n data[pos] = item;\n }\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import Queue from 'tinyqueue';\n\nimport Point from '@mapbox/point-geometry';\nimport {distToSegmentSquared} from './intersection_tests';\n\n/**\n * Finds an approximation of a polygon's Pole Of Inaccessibiliy https://en.wikipedia.org/wiki/Pole_of_inaccessibility\n * This is a copy of http://github.com/mapbox/polylabel adapted to use Points\n *\n * @param polygonRings - first item in array is the outer ring followed optionally by the list of holes, should be an element of the result of util/classify_rings\n * @param precision - Specified in input coordinate units. If 0 returns after first run, if `> 0` repeatedly narrows the search space until the radius of the area searched for the best pole is less than precision\n * @param debug - Print some statistics to the console during execution\n * @returns Pole of Inaccessibiliy.\n */\nexport function findPoleOfInaccessibility(\n polygonRings: Array>,\n precision: number = 1,\n debug: boolean = false\n): Point {\n // find the bounding box of the outer ring\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n const outerRing = polygonRings[0];\n for (let i = 0; i < outerRing.length; i++) {\n const p = outerRing[i];\n if (!i || p.x < minX) minX = p.x;\n if (!i || p.y < minY) minY = p.y;\n if (!i || p.x > maxX) maxX = p.x;\n if (!i || p.y > maxY) maxY = p.y;\n }\n\n const width = maxX - minX;\n const height = maxY - minY;\n const cellSize = Math.min(width, height);\n let h = cellSize / 2;\n\n // a priority queue of cells in order of their \"potential\" (max distance to polygon)\n const cellQueue = new Queue([], compareMax);\n\n if (cellSize === 0) return new Point(minX, minY);\n\n // cover polygon with initial cells\n for (let x = minX; x < maxX; x += cellSize) {\n for (let y = minY; y < maxY; y += cellSize) {\n cellQueue.push(new Cell(x + h, y + h, h, polygonRings));\n }\n }\n\n // take centroid as the first best guess\n let bestCell = getCentroidCell(polygonRings);\n let numProbes = cellQueue.length;\n\n while (cellQueue.length) {\n // pick the most promising cell from the queue\n const cell = cellQueue.pop();\n\n // update the best cell if we found a better one\n if (cell.d > bestCell.d || !bestCell.d) {\n bestCell = cell;\n if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes);\n }\n\n // do not drill down further if there's no chance of a better solution\n if (cell.max - bestCell.d <= precision) continue;\n\n // split the cell into four cells\n h = cell.h / 2;\n cellQueue.push(new Cell(cell.p.x - h, cell.p.y - h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x + h, cell.p.y - h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x - h, cell.p.y + h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x + h, cell.p.y + h, h, polygonRings));\n numProbes += 4;\n }\n\n if (debug) {\n console.log(`num probes: ${numProbes}`);\n console.log(`best distance: ${bestCell.d}`);\n }\n\n return bestCell.p;\n}\n\nfunction compareMax(a, b) {\n return b.max - a.max;\n}\n\nfunction Cell(x, y, h, polygon) {\n this.p = new Point(x, y);\n this.h = h; // half the cell size\n this.d = pointToPolygonDist(this.p, polygon); // distance from cell center to polygon\n this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell\n}\n\n// signed distance from point to polygon outline (negative if point is outside)\nfunction pointToPolygonDist(p, polygon) {\n let inside = false;\n let minDistSq = Infinity;\n\n for (let k = 0; k < polygon.length; k++) {\n const ring = polygon[k];\n\n for (let i = 0, len = ring.length, j = len - 1; i < len; j = i++) {\n const a = ring[i];\n const b = ring[j];\n\n if ((a.y > p.y !== b.y > p.y) &&\n (p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x)) inside = !inside;\n\n minDistSq = Math.min(minDistSq, distToSegmentSquared(p, a, b));\n }\n }\n\n return (inside ? 1 : -1) * Math.sqrt(minDistSq);\n}\n\n// get polygon centroid\nfunction getCentroidCell(polygon) {\n let area = 0;\n let x = 0;\n let y = 0;\n const points = polygon[0];\n for (let i = 0, len = points.length, j = len - 1; i < len; j = i++) {\n const a = points[i];\n const b = points[j];\n const f = a.x * b.y - b.x * a.y;\n x += (a.x + b.x) * f;\n y += (a.y + b.y) * f;\n area += f * 3;\n }\n return new Cell(x / area, y / area, 0, polygon);\n}\n","import {VariableAnchorOffsetCollection, VariableAnchorOffsetCollectionSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {CanonicalTileID} from '../../source/tile_id';\nimport ONE_EM from '../../symbol/one_em';\nimport {SymbolStyleLayer} from './symbol_style_layer';\n\nexport enum TextAnchorEnum {\n 'center' = 1,\n 'left' = 2,\n 'right' = 3,\n 'top' = 4,\n 'bottom' = 5,\n 'top-left' = 6,\n 'top-right' = 7,\n 'bottom-left' = 8,\n 'bottom-right' = 9\n}\n\nexport type TextAnchor = keyof typeof TextAnchorEnum;\n\n// The radial offset is to the edge of the text box\n// In the horizontal direction, the edge of the text box is where glyphs start\n// But in the vertical direction, the glyphs appear to \"start\" at the baseline\n// We don't actually load baseline data, but we assume an offset of ONE_EM - 17\n// (see \"yOffset\" in shaping.js)\nconst baselineOffset = 7;\nexport const INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY;\n\nexport function evaluateVariableOffset(anchor: TextAnchor, offset: [number, number]): [number, number] {\n\n function fromRadialOffset(anchor: TextAnchor, radialOffset: number): [number, number] {\n let x = 0, y = 0;\n if (radialOffset < 0) radialOffset = 0; // Ignore negative offset.\n // solve for r where r^2 + r^2 = radialOffset^2\n const hypotenuse = radialOffset / Math.SQRT2;\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n y = hypotenuse - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n y = -hypotenuse + baselineOffset;\n break;\n case 'bottom':\n y = -radialOffset + baselineOffset;\n break;\n case 'top':\n y = radialOffset - baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n x = -hypotenuse;\n break;\n case 'top-left':\n case 'bottom-left':\n x = hypotenuse;\n break;\n case 'left':\n x = radialOffset;\n break;\n case 'right':\n x = -radialOffset;\n break;\n }\n\n return [x, y];\n }\n\n function fromTextOffset(anchor: TextAnchor, offsetX: number, offsetY: number): [number, number] {\n let x = 0, y = 0;\n // Use absolute offset values.\n offsetX = Math.abs(offsetX);\n offsetY = Math.abs(offsetY);\n\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n case 'top':\n y = offsetY - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n case 'bottom':\n y = -offsetY + baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n case 'right':\n x = -offsetX;\n break;\n case 'top-left':\n case 'bottom-left':\n case 'left':\n x = offsetX;\n break;\n }\n\n return [x, y];\n }\n\n return (offset[1] !== INVALID_TEXT_OFFSET) ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]);\n}\n\n// Helper to support both text-variable-anchor and text-variable-anchor-offset. Offset values converted from EMs to PXs\nexport function getTextVariableAnchorOffset(layer: SymbolStyleLayer, feature: SymbolFeature, canonical: CanonicalTileID): VariableAnchorOffsetCollection | null {\n const layout = layer.layout;\n // If style specifies text-variable-anchor-offset, just return it\n const variableAnchorOffset = layout.get('text-variable-anchor-offset')?.evaluate(feature, {}, canonical);\n\n if (variableAnchorOffset) {\n const sourceValues = variableAnchorOffset.values;\n const destValues: VariableAnchorOffsetCollectionSpecification = [];\n\n // Convert offsets from EM to PX, and apply baseline shift\n for (let i = 0; i < sourceValues.length; i += 2) {\n const anchor = destValues[i] = sourceValues[i] as TextAnchor;\n const offset = (sourceValues[i + 1] as [number, number]).map(t => t * ONE_EM) as [number, number];\n\n if (anchor.startsWith('top')) {\n offset[1] -= baselineOffset;\n } else if (anchor.startsWith('bottom')) {\n offset[1] += baselineOffset;\n }\n\n destValues[i + 1] = offset;\n }\n\n return new VariableAnchorOffsetCollection(destValues);\n }\n\n // If style specifies text-variable-anchor, convert to the new format\n const variableAnchor = layout.get('text-variable-anchor');\n\n if (variableAnchor) {\n let textOffset: [number, number];\n const unevaluatedLayout = layer._unevaluatedLayout;\n\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n if (unevaluatedLayout.getValue('text-radial-offset') !== undefined) {\n textOffset = [layout.get('text-radial-offset').evaluate(feature, {}, canonical) * ONE_EM, INVALID_TEXT_OFFSET];\n } else {\n textOffset = layout.get('text-offset').evaluate(feature, {}, canonical).map(t => t * ONE_EM) as [number, number];\n }\n\n const anchorOffsets: VariableAnchorOffsetCollectionSpecification = [];\n\n for (const anchor of variableAnchor) {\n anchorOffsets.push(anchor, evaluateVariableOffset(anchor, textOffset));\n }\n\n return new VariableAnchorOffsetCollection(anchorOffsets);\n }\n\n return null;\n}\n","import {Anchor} from './anchor';\n\nimport {getAnchors, getCenterAnchor} from './get_anchors';\nimport {clipLine} from './clip_line';\nimport {shapeText, shapeIcon, WritingMode, fitIconToText} from './shaping';\nimport {getGlyphQuads, getIconQuads} from './quads';\nimport {CollisionFeature} from './collision_feature';\nimport {warnOnce} from '../util/util';\nimport {\n allowsVerticalWritingMode,\n allowsLetterSpacing\n} from '../util/script_detection';\nimport {findPoleOfInaccessibility} from '../util/find_pole_of_inaccessibility';\nimport {classifyRings} from '../util/classify_rings';\nimport {EXTENT} from '../data/extent';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SIZE_PACK_FACTOR, MAX_PACKED_SIZE, MAX_GLYPH_ICON_SIZE} from './symbol_size';\nimport ONE_EM from './one_em';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Shaping, PositionedIcon, TextJustify} from './shaping';\nimport type {CollisionBoxArray, TextAnchorOffsetArray} from '../data/array_types.g';\nimport type {SymbolFeature} from '../data/bucket/symbol_bucket';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {GlyphPosition} from '../render/glyph_atlas';\nimport type {PossiblyEvaluatedPropertyValue} from '../style/properties';\n\nimport Point from '@mapbox/point-geometry';\nimport murmur3 from 'murmurhash-js';\nimport {getIconPadding, SymbolPadding} from '../style/style_layer/symbol_style_layer';\nimport {VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {getTextVariableAnchorOffset, evaluateVariableOffset, INVALID_TEXT_OFFSET, TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\n// The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and\n// `icon-size` at up to three:\n//\n// 1. `text-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `text-size`\n// expressions, and to calculate the box dimensions for icon-text-fit.\n// 2. `icon-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `icon-size`\n// expressions.\n// 3. `text-size` and `icon-size` at the zoom level of the bucket, plus one. Used to calculate collision boxes.\n// 4. `text-size` at zoom level 18. Used for something line-symbol-placement-related.\n// 5. For composite `*-size` expressions: two zoom levels of curve stops that \"cover\" the zoom level of the\n// bucket. These go into a vertex buffer and are used by the shader to interpolate the size at render time.\n//\n// (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below.\n//\ntype Sizes = {\n layoutTextSize: PossiblyEvaluatedPropertyValue; // (3),\n layoutIconSize: PossiblyEvaluatedPropertyValue; // (3),\n textMaxSize: PossiblyEvaluatedPropertyValue; // (4),\n compositeTextSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5),\n compositeIconSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5)\n};\n\ntype ShapedTextOrientations = {\n vertical: Shaping | false;\n horizontal: Record;\n};\n\nexport function performSymbolLayout(args: {\n bucket: SymbolBucket;\n glyphMap: {\n [_: string]: {\n [x: number]: StyleGlyph;\n };\n };\n glyphPositions: {\n [_: string]: {\n [x: number]: GlyphPosition;\n };\n };\n imageMap: {[_: string]: StyleImage};\n imagePositions: {[_: string]: ImagePosition};\n showCollisionBoxes: boolean;\n canonical: CanonicalTileID;\n}) {\n args.bucket.createArrays();\n\n const tileSize = 512 * args.bucket.overscaling;\n args.bucket.tilePixelRatio = EXTENT / tileSize;\n args.bucket.compareText = {};\n args.bucket.iconsNeedLinear = false;\n\n const layer = args.bucket.layers[0];\n const layout = layer.layout;\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n const sizes: Sizes = {\n // Filled in below, if *SizeData.kind is 'composite'\n // compositeIconSizes: undefined,\n // compositeTextSizes: undefined,\n layoutIconSize: unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n layoutTextSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n textMaxSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18))\n } as Sizes;\n\n if (args.bucket.textSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.textSizeData;\n sizes.compositeTextSizes = [\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n if (args.bucket.iconSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.iconSizeData;\n sizes.compositeIconSizes = [\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n const lineHeight = layout.get('text-line-height') * ONE_EM;\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n const keepUpright = layout.get('text-keep-upright');\n const textSize = layout.get('text-size');\n\n for (const feature of args.bucket.features) {\n const fontstack = layout.get('text-font').evaluate(feature, {}, args.canonical).join(',');\n const layoutTextSizeThisZoom = textSize.evaluate(feature, {}, args.canonical);\n const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, args.canonical);\n const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, args.canonical);\n\n const shapedTextOrientations: ShapedTextOrientations = {\n horizontal: {} as Record,\n vertical: undefined\n };\n const text = feature.text;\n let textOffset: [number, number] = [0, 0];\n if (text) {\n const unformattedText = text.toString();\n const spacing = layout.get('text-letter-spacing').evaluate(feature, {}, args.canonical) * ONE_EM;\n const spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0;\n\n const textAnchor = layout.get('text-anchor').evaluate(feature, {}, args.canonical);\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, args.canonical);\n\n if (!variableAnchorOffset) {\n const radialOffset = layout.get('text-radial-offset').evaluate(feature, {}, args.canonical);\n // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector\n // is calculated at placement time instead of layout time\n if (radialOffset) {\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n textOffset = evaluateVariableOffset(textAnchor, [radialOffset * ONE_EM, INVALID_TEXT_OFFSET]);\n } else {\n textOffset = (layout.get('text-offset').evaluate(feature, {}, args.canonical).map(t => t * ONE_EM) as [number, number]);\n }\n }\n\n let textJustify = textAlongLine ?\n 'center' :\n layout.get('text-justify').evaluate(feature, {}, args.canonical);\n\n const symbolPlacement = layout.get('symbol-placement');\n const maxWidth = symbolPlacement === 'point' ?\n layout.get('text-max-width').evaluate(feature, {}, args.canonical) * ONE_EM :\n 0;\n\n const addVerticalShapingForPointLabelIfNeeded = () => {\n if (args.bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) {\n // Vertical POI label placement is meant to be used for scripts that support vertical\n // writing mode, thus, default left justification is used. If Latin\n // scripts would need to be supported, this should take into account other justifications.\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor,\n 'left', spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n };\n\n // If this layer uses text-variable-anchor, generate shapings for all justification possibilities.\n if (!textAlongLine && variableAnchorOffset) {\n const justifications = new Set();\n\n if (textJustify === 'auto') {\n for (let i = 0; i < variableAnchorOffset.values.length; i += 2) {\n justifications.add(getAnchorJustification(variableAnchorOffset.values[i] as TextAnchor));\n }\n } else {\n justifications.add(textJustify);\n }\n\n let singleLine = false;\n for (const justification of justifications) {\n if (shapedTextOrientations.horizontal[justification]) continue;\n if (singleLine) {\n // If the shaping for the first justification was only a single line, we\n // can re-use it for the other justifications\n shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0];\n } else {\n // If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply\n // the offsets for the anchor in the placement step.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, 'center',\n justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) {\n shapedTextOrientations.horizontal[justification] = shaping;\n singleLine = shaping.positionedLines.length === 1;\n }\n }\n }\n\n addVerticalShapingForPointLabelIfNeeded();\n } else {\n if (textJustify === 'auto') {\n textJustify = getAnchorJustification(textAnchor);\n }\n\n // Horizontal point or line label.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed,\n textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) shapedTextOrientations.horizontal[textJustify] = shaping;\n\n // Vertical point label (if allowVerticalPlacement is enabled).\n addVerticalShapingForPointLabelIfNeeded();\n\n // Verticalized line label.\n if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) {\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify,\n spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n }\n }\n\n let shapedIcon;\n let isSDFIcon = false;\n if (feature.icon && feature.icon.name) {\n const image = args.imageMap[feature.icon.name];\n if (image) {\n shapedIcon = shapeIcon(\n args.imagePositions[feature.icon.name],\n layout.get('icon-offset').evaluate(feature, {}, args.canonical),\n layout.get('icon-anchor').evaluate(feature, {}, args.canonical));\n // null/undefined SDF property treated same as default (false)\n isSDFIcon = !!image.sdf;\n if (args.bucket.sdfIcons === undefined) {\n args.bucket.sdfIcons = isSDFIcon;\n } else if (args.bucket.sdfIcons !== isSDFIcon) {\n warnOnce('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer');\n }\n if (image.pixelRatio !== args.bucket.pixelRatio) {\n args.bucket.iconsNeedLinear = true;\n } else if (layout.get('icon-rotate').constantOr(1) !== 0) {\n args.bucket.iconsNeedLinear = true;\n }\n }\n }\n\n const shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical;\n args.bucket.iconsInText = shapedText ? shapedText.iconsInText : false;\n if (shapedText || shapedIcon) {\n addFeature(args.bucket, feature, shapedTextOrientations, shapedIcon, args.imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, args.canonical);\n }\n }\n\n if (args.showCollisionBoxes) {\n args.bucket.generateCollisionDebugBuffers();\n }\n}\n\n// Choose the justification that matches the direction of the TextAnchor\nexport function getAnchorJustification(anchor: TextAnchor): TextJustify {\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n return 'right';\n case 'left':\n case 'top-left':\n case 'bottom-left':\n return 'left';\n }\n return 'center';\n}\n\n/**\n * Given a feature and its shaped text and icon data, add a 'symbol\n * instance' for each _possible_ placement of the symbol feature.\n * (At render timePlaceSymbols#place() selects which of these instances to\n * show or hide based on collisions with symbols in other layers.)\n */\nfunction addFeature(bucket: SymbolBucket,\n feature: SymbolFeature,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon,\n imageMap: {[_: string]: StyleImage},\n sizes: Sizes,\n layoutTextSize: number,\n layoutIconSize: number,\n textOffset: [number, number],\n isSDFIcon: boolean, canonical: CanonicalTileID) {\n // To reduce the number of labels that jump around when zooming we need\n // to use a text-size value that is the same for all zoom levels.\n // bucket calculates text-size at a high zoom level so that all tiles can\n // use the same value when calculating anchor positions.\n let textMaxSize = sizes.textMaxSize.evaluate(feature, {});\n if (textMaxSize === undefined) {\n textMaxSize = layoutTextSize;\n }\n const layout = bucket.layers[0].layout;\n const iconOffset = layout.get('icon-offset').evaluate(feature, {}, canonical);\n const defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal);\n const glyphSize = 24,\n fontScale = layoutTextSize / glyphSize,\n textBoxScale = bucket.tilePixelRatio * fontScale,\n textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize,\n iconBoxScale = bucket.tilePixelRatio * layoutIconSize,\n symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing'),\n textPadding = layout.get('text-padding') * bucket.tilePixelRatio,\n iconPadding = getIconPadding(layout, feature, canonical, bucket.tilePixelRatio),\n textMaxAngle = layout.get('text-max-angle') / 180 * Math.PI,\n textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point',\n iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point',\n symbolPlacement = layout.get('symbol-placement'),\n textRepeatDistance = symbolMinDistance / 2;\n\n const iconTextFit = layout.get('icon-text-fit');\n let verticallyShapedIcon;\n // Adjust shaped icon size when icon-text-fit is used.\n if (shapedIcon && iconTextFit !== 'none') {\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n if (defaultHorizontalShaping) {\n shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n }\n\n const addSymbolAtAnchor = (line, anchor) => {\n if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) {\n // Symbol layers are drawn across tile boundaries, We filter out symbols\n // outside our tile boundaries (which may be included in vector tile buffers)\n // to prevent double-drawing symbols.\n return;\n }\n\n addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0],\n bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index,\n textBoxScale, [textPadding, textPadding, textPadding, textPadding], textAlongLine, textOffset,\n iconBoxScale, iconPadding, iconAlongLine, iconOffset,\n feature, sizes, isSDFIcon, canonical, layoutTextSize);\n };\n\n if (symbolPlacement === 'line') {\n for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) {\n const anchors = getAnchors(\n line,\n symbolMinDistance,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale,\n bucket.overscaling,\n EXTENT\n );\n for (const anchor of anchors) {\n const shapedText = defaultHorizontalShaping;\n if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (symbolPlacement === 'line-center') {\n // No clipping, multiple lines per feature are allowed\n // \"lines\" with only one point are ignored as in clipLines\n for (const line of feature.geometry) {\n if (line.length > 1) {\n const anchor = getCenterAnchor(\n line,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale);\n if (anchor) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (feature.type === 'Polygon') {\n for (const polygon of classifyRings(feature.geometry, 0)) {\n // 16 here represents 2 pixels\n const poi = findPoleOfInaccessibility(polygon, 16);\n addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0));\n }\n } else if (feature.type === 'LineString') {\n // https://github.com/mapbox/mapbox-gl-js/issues/3808\n for (const line of feature.geometry) {\n addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0));\n }\n } else if (feature.type === 'Point') {\n for (const points of feature.geometry) {\n for (const point of points) {\n addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0));\n }\n }\n }\n}\n\nfunction addTextVariableAnchorOffsets(textAnchorOffsets: TextAnchorOffsetArray, variableAnchorOffset: VariableAnchorOffsetCollection): [number, number] {\n const startIndex = textAnchorOffsets.length;\n const values = variableAnchorOffset?.values;\n\n if (values?.length > 0) {\n for (let i = 0; i < values.length; i += 2) {\n const anchor = TextAnchorEnum[values[i] as TextAnchor];\n const offset = values[i + 1] as [number, number];\n\n textAnchorOffsets.emplaceBack(anchor, offset[0], offset[1]);\n }\n }\n\n return [startIndex, textAnchorOffsets.length];\n}\n\nfunction addTextVertices(bucket: SymbolBucket,\n anchor: Point,\n shapedText: Shaping,\n imageMap: {[_: string]: StyleImage},\n layer: SymbolStyleLayer,\n textAlongLine: boolean,\n feature: SymbolFeature,\n textOffset: [number, number],\n lineArray: {\n lineStartIndex: number;\n lineLength: number;\n },\n writingMode: WritingMode,\n placementTypes: Array<'vertical' | 'center' | 'left' | 'right'>,\n placedTextSymbolIndices: {[_: string]: number},\n placedIconIndex: number,\n sizes: Sizes,\n canonical: CanonicalTileID) {\n const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset,\n layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement);\n\n const sizeData = bucket.textSizeData;\n let textSizeData = null;\n\n if (sizeData.kind === 'source') {\n textSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {})\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n textSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical)\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.text,\n glyphQuads,\n textSizeData,\n textOffset,\n textAlongLine,\n feature,\n writingMode,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n placedIconIndex,\n canonical);\n\n // The placedSymbolArray is used at render time in drawTileSymbols\n // These indices allow access to the array at collision detection time\n for (const placementType of placementTypes) {\n placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1;\n }\n\n return glyphQuads.length * 4;\n}\n\nfunction getDefaultHorizontalShaping(\n horizontalShaping: Record\n): Shaping | null {\n // We don't care which shaping we get because this is used for collision purposes\n // and all the justifications have the same collision box\n for (const justification in horizontalShaping) {\n return horizontalShaping[justification];\n }\n return null;\n}\n\n/**\n * Add a single label & icon placement.\n */\nfunction addSymbol(bucket: SymbolBucket,\n anchor: Anchor,\n line: Array,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon | void,\n imageMap: {[_: string]: StyleImage},\n verticallyShapedIcon: PositionedIcon | void,\n layer: SymbolStyleLayer,\n collisionBoxArray: CollisionBoxArray,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n textBoxScale: number,\n textPadding: SymbolPadding,\n textAlongLine: boolean,\n textOffset: [number, number],\n iconBoxScale: number,\n iconPadding: SymbolPadding,\n iconAlongLine: boolean,\n iconOffset: [number, number],\n feature: SymbolFeature,\n sizes: Sizes,\n isSDFIcon: boolean,\n canonical: CanonicalTileID,\n layoutTextSize: number) {\n const lineArray = bucket.addToLineVertexArray(anchor, line);\n\n let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature;\n\n let numIconVertices = 0;\n let numVerticalIconVertices = 0;\n let numHorizontalGlyphVertices = 0;\n let numVerticalGlyphVertices = 0;\n let placedIconSymbolIndex = -1;\n let verticalPlacedIconSymbolIndex = -1;\n const placedTextSymbolIndices: {[k: string]: number} = {};\n let key = murmur3('');\n\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n const textRotation = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n const verticalTextRotation = textRotation + 90.0;\n const verticalShaping = shapedTextOrientations.vertical;\n verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation);\n\n if (verticallyShapedIcon) {\n verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation);\n }\n }\n\n //Place icon first, so text can have a reference to its index in the placed symbol array.\n //Text symbols can lazily shift at render-time because of variable anchor placement.\n //If the style specifies an `icon-text-fit` then the icon would have to shift along with it.\n // For more info check `updateVariableAnchors` in `draw_symbol.js` .\n if (shapedIcon) {\n const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {});\n const hasIconTextFit = layer.layout.get('icon-text-fit') !== 'none';\n const iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit);\n const verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : undefined;\n iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/false, iconRotate);\n\n numIconVertices = iconQuads.length * 4;\n\n const sizeData = bucket.iconSizeData;\n let iconSizeData = null;\n\n if (sizeData.kind === 'source') {\n iconSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {})\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n iconSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical)\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.icon,\n iconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.none,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n\n if (verticalIconQuads) {\n numVerticalIconVertices = verticalIconQuads.length * 4;\n\n bucket.addSymbols(\n bucket.icon,\n verticalIconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.vertical,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n }\n }\n\n const justifications = Object.keys(shapedTextOrientations.horizontal) as TextJustify[];\n for (const justification of justifications) {\n const shaping = shapedTextOrientations.horizontal[justification];\n\n if (!textCollisionFeature) {\n key = murmur3(shaping.text);\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature\n // We're counting on all versions having similar dimensions\n textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate);\n }\n\n const singleLine = shaping.positionedLines.length === 1;\n numHorizontalGlyphVertices += addTextVertices(\n bucket, anchor, shaping, imageMap, layer, textAlongLine, feature, textOffset, lineArray,\n shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly,\n singleLine ? justifications : [justification],\n placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical);\n\n if (singleLine) {\n break;\n }\n }\n\n if (shapedTextOrientations.vertical) {\n numVerticalGlyphVertices += addTextVertices(\n bucket, anchor, shapedTextOrientations.vertical, imageMap, layer, textAlongLine, feature,\n textOffset, lineArray, WritingMode.vertical, ['vertical'], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical);\n }\n\n const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n // Check if runtime collision circles should be used for any of the collision features.\n // It is enough to choose the tallest feature shape as circles are always placed on a line.\n // All measurements are in glyph metrics and later converted into pixels using proper font size \"layoutTextSize\"\n let collisionCircleDiameter = -1;\n\n const getCollisionCircleHeight = (feature: CollisionFeature, prevHeight: number): number => {\n if (feature && feature.circleDiameter)\n return Math.max(feature.circleDiameter, prevHeight);\n return prevHeight;\n };\n\n collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter);\n const useRuntimeCollisionCircles = (collisionCircleDiameter > -1) ? 1 : 0;\n\n // Convert circle collision height into pixels\n if (useRuntimeCollisionCircles)\n collisionCircleDiameter *= layoutTextSize / ONE_EM;\n\n if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) warnOnce(\n 'Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907'\n );\n\n if (feature.sortKey !== undefined) {\n bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey as number);\n }\n\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, canonical);\n const [textAnchorOffsetStartIndex, textAnchorOffsetEndIndex] = addTextVariableAnchorOffsets(bucket.textAnchorOffsets, variableAnchorOffset);\n\n bucket.symbolInstances.emplaceBack(\n anchor.x,\n anchor.y,\n placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1,\n placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1,\n placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1,\n placedTextSymbolIndices.vertical || -1,\n placedIconSymbolIndex,\n verticalPlacedIconSymbolIndex,\n key,\n textBoxStartIndex,\n textBoxEndIndex,\n verticalTextBoxStartIndex,\n verticalTextBoxEndIndex,\n iconBoxStartIndex,\n iconBoxEndIndex,\n verticalIconBoxStartIndex,\n verticalIconBoxEndIndex,\n featureIndex,\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n numIconVertices,\n numVerticalIconVertices,\n useRuntimeCollisionCircles,\n 0,\n textBoxScale,\n collisionCircleDiameter,\n textAnchorOffsetStartIndex,\n textAnchorOffsetEndIndex);\n}\n\nfunction anchorIsTooClose(bucket: SymbolBucket, text: string, repeatDistance: number, anchor: Point) {\n const compareText = bucket.compareText;\n if (!(text in compareText)) {\n compareText[text] = [];\n } else {\n const otherAnchors = compareText[text];\n for (let k = otherAnchors.length - 1; k >= 0; k--) {\n if (anchor.dist(otherAnchors[k]) < repeatDistance) {\n // If it's within repeatDistance of one anchor, stop looking\n return true;\n }\n }\n }\n // If anchor is not within repeatDistance of any other anchor, add to array\n compareText[text].push(anchor);\n return false;\n}\n","import Point from '@mapbox/point-geometry';\n\n/**\n * Returns the part of a multiline that intersects with the provided rectangular box.\n *\n * @param lines - the lines to check\n * @param x1 - the left edge of the box\n * @param y1 - the top edge of the box\n * @param x2 - the right edge of the box\n * @param y2 - the bottom edge of the box\n * @returns lines\n */\nexport function clipLine(lines: Array>, x1: number, y1: number, x2: number, y2: number): Array> {\n const clippedLines = [];\n\n for (let l = 0; l < lines.length; l++) {\n const line = lines[l];\n let clippedLine;\n\n for (let i = 0; i < line.length - 1; i++) {\n let p0 = line[i];\n let p1 = line[i + 1];\n\n if (p0.x < x1 && p1.x < x1) {\n continue;\n } else if (p0.x < x1) {\n p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x < x1) {\n p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y < y1 && p1.y < y1) {\n continue;\n } else if (p0.y < y1) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n } else if (p1.y < y1) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n }\n\n if (p0.x >= x2 && p1.x >= x2) {\n continue;\n } else if (p0.x >= x2) {\n p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x >= x2) {\n p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y >= y2 && p1.y >= y2) {\n continue;\n } else if (p0.y >= y2) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n } else if (p1.y >= y2) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n }\n\n if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) {\n clippedLine = [p0];\n clippedLines.push(clippedLine);\n }\n\n clippedLine.push(p1);\n }\n }\n\n return clippedLines;\n}\n","import {AlphaImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {GlyphMetrics, StyleGlyph} from '../style/style_glyph';\n\nconst padding = 1;\n\n/**\n * A rectangle type with postion, width and height.\n */\nexport type Rect = {\n x: number;\n y: number;\n w: number;\n h: number;\n};\n\n/**\n * The glyph's position\n */\nexport type GlyphPosition = {\n rect: Rect;\n metrics: GlyphMetrics;\n};\n\n/**\n * The glyphs' positions\n */\nexport type GlyphPositions = {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n};\n\nexport class GlyphAtlas {\n image: AlphaImage;\n positions: GlyphPositions;\n\n constructor(stacks: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n }) {\n const positions = {};\n const bins = [];\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n const stackPositions = positions[stack] = {};\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n\n const bin = {\n x: 0,\n y: 0,\n w: src.bitmap.width + 2 * padding,\n h: src.bitmap.height + 2 * padding\n };\n bins.push(bin);\n stackPositions[id] = {rect: bin, metrics: src.metrics};\n }\n }\n\n const {w, h} = potpack(bins);\n const image = new AlphaImage({width: w || 1, height: h || 1});\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n const bin = positions[stack][id].rect;\n AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);\n }\n }\n\n this.image = image;\n this.positions = positions;\n }\n}\n\nregister('GlyphAtlas', GlyphAtlas);\n","export { getURL, getTileBBox, getMercCoords };\n\n\n/**\n * getURL\n *\n * @param {String} baseUrl Base url of the WMS server\n * @param {String} layer Layer name\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @param {Object} [options]\n * @param {String} [options.format='image/png']\n * @param {String} [options.service='WMS']\n * @param {String} [options.version='1.1.1']\n * @param {String} [options.request='GetMap']\n * @param {String} [options.srs='EPSG:3857']\n * @param {Number} [options.width='256']\n * @param {Number} [options.height='256']\n * @returns {String} url\n * @example\n * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';\n * var layer = 'Natural2015';\n * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19);\n */\nfunction getURL(baseUrl, layer, x, y, z, options) {\n options = options || {};\n\n var url = baseUrl + '?' + [\n 'bbox=' + getTileBBox(x, y, z),\n 'format=' + (options.format || 'image/png'),\n 'service=' + (options.service || 'WMS'),\n 'version=' + (options.version || '1.1.1'),\n 'request=' + (options.request || 'GetMap'),\n 'srs=' + (options.srs || 'EPSG:3857'),\n 'width=' + (options.width || 256),\n 'height=' + (options.height || 256),\n 'layers=' + layer\n ].join('&');\n\n return url;\n}\n\n\n/**\n * getTileBBox\n *\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @returns {String} String of the bounding box\n */\nfunction getTileBBox(x, y, z) {\n // for Google/OSM tile scheme we need to alter the y\n y = (Math.pow(2, z) - y - 1);\n\n var min = getMercCoords(x * 256, y * 256, z),\n max = getMercCoords((x + 1) * 256, (y + 1) * 256, z);\n\n return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1];\n}\n\n\n/**\n * getMercCoords\n *\n * @param {Number} x Pixel coordinate x\n * @param {Number} y Pixel coordinate y\n * @param {Number} z Tile zoom\n * @returns {Array} [x, y]\n */\nfunction getMercCoords(x, y, z) {\n var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z),\n merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0),\n merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0);\n\n return [merc_x, merc_y];\n}\n","import {wrap} from '../util/util';\n\n/*\n* Approximate radius of the earth in meters.\n* Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84\n* 6371008.8 is one published \"average radius\" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4\n*/\nexport const earthRadius = 6371008.8;\n\n/**\n * A {@link LngLat} object, an array of two numbers representing longitude and latitude,\n * or an object with `lng` and `lat` or `lon` and `lat` properties.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLat(-122.420679, 37.772537);\n * let v2 = [-122.420679, 37.772537];\n * let v3 = {lon: -122.420679, lat: 37.772537};\n * ```\n */\nexport type LngLatLike = LngLat | {\n lng: number;\n lat: number;\n} | {\n lon: number;\n lat: number;\n} | [number, number];\n\n/**\n * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.\n * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).\n *\n * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the\n * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).\n *\n * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option\n * can also accept an `Array` of two numbers and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-123.9749, 40.7736);\n * ll.lng; // = -123.9749\n * ```\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\nexport class LngLat {\n lng: number;\n lat: number;\n\n /**\n * @param lng - Longitude, measured in degrees.\n * @param lat - Latitude, measured in degrees.\n */\n constructor(lng: number, lat: number) {\n if (isNaN(lng) || isNaN(lat)) {\n throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);\n }\n this.lng = +lng;\n this.lat = +lat;\n if (this.lat > 90 || this.lat < -90) {\n throw new Error('Invalid LngLat latitude value: must be between -90 and 90');\n }\n }\n\n /**\n * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).\n *\n * @returns The wrapped `LngLat` object.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(286.0251, 40.7736);\n * let wrapped = ll.wrap();\n * wrapped.lng; // = -73.9749\n * ```\n */\n wrap() {\n return new LngLat(wrap(this.lng, -180, 180), this.lat);\n }\n\n /**\n * Returns the coordinates represented as an array of two numbers.\n *\n * @returns The coordinates represented as an array of longitude and latitude.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toArray(); // = [-73.9749, 40.7736]\n * ```\n */\n toArray(): [number, number] {\n return [this.lng, this.lat];\n }\n\n /**\n * Returns the coordinates represent as a string.\n *\n * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toString(); // = \"LngLat(-73.9749, 40.7736)\"\n * ```\n */\n toString(): string {\n return `LngLat(${this.lng}, ${this.lat})`;\n }\n\n /**\n * Returns the approximate distance between a pair of coordinates in meters\n * Uses the Haversine Formula (from R.W. Sinnott, \"Virtues of the Haversine\", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)\n *\n * @param lngLat - coordinates to compute the distance to\n * @returns Distance in meters between the two coordinates.\n * @example\n * ```ts\n * let new_york = new maplibregl.LngLat(-74.0060, 40.7128);\n * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522);\n * new_york.distanceTo(los_angeles); // = 3935751.690893987, \"true distance\" using a non-spherical approximation is ~3966km\n * ```\n */\n distanceTo(lngLat: LngLat): number {\n const rad = Math.PI / 180;\n const lat1 = this.lat * rad;\n const lat2 = lngLat.lat * rad;\n const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);\n\n const maxMeters = earthRadius * Math.acos(Math.min(a, 1));\n return maxMeters;\n }\n\n /**\n * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties\n * to a `LngLat` object.\n *\n * If a `LngLat` object is passed in, the function returns it unchanged.\n *\n * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.\n * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.\n * @example\n * ```ts\n * let arr = [-73.9749, 40.7736];\n * let ll = maplibregl.LngLat.convert(arr);\n * ll; // = LngLat {lng: -73.9749, lat: 40.7736}\n * ```\n */\n static convert(input: LngLatLike): LngLat {\n if (input instanceof LngLat) {\n return input;\n }\n if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {\n return new LngLat(Number(input[0]), Number(input[1]));\n }\n if (!Array.isArray(input) && typeof input === 'object' && input !== null) {\n return new LngLat(\n // flow can't refine this to have one of lng or lat, so we have to cast to any\n Number('lng' in input ? (input as any).lng : (input as any).lon),\n Number(input.lat)\n );\n }\n throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]');\n }\n}\n","import {LngLat, earthRadius} from '../geo/lng_lat';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport {IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/*\n * The average circumference of the world in meters.\n */\nconst earthCircumfrence = 2 * Math.PI * earthRadius; // meters\n\n/*\n * The circumference at a line of latitude in meters.\n */\nfunction circumferenceAtLatitude(latitude: number) {\n return earthCircumfrence * Math.cos(latitude * Math.PI / 180);\n}\n\nexport function mercatorXfromLng(lng: number) {\n return (180 + lng) / 360;\n}\n\nexport function mercatorYfromLat(lat: number) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\n\nexport function mercatorZfromAltitude(altitude: number, lat: number) {\n return altitude / circumferenceAtLatitude(lat);\n}\n\nexport function lngFromMercatorX(x: number) {\n return x * 360 - 180;\n}\n\nexport function latFromMercatorY(y: number) {\n const y2 = 180 - y * 360;\n return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;\n}\n\nexport function altitudeFromMercatorZ(z: number, y: number) {\n return z * circumferenceAtLatitude(latFromMercatorY(y));\n}\n\n/**\n * Determine the Mercator scale factor for a given latitude, see\n * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor\n *\n * At the equator the scale factor will be 1, which increases at higher latitudes.\n *\n * @param lat - Latitude\n * @returns scale factor\n */\nexport function mercatorScale(lat: number) {\n return 1 / Math.cos(lat * Math.PI / 180);\n}\n\n/**\n * A `MercatorCoordinate` object represents a projected three dimensional position.\n *\n * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:\n * - the size of 1 unit is the width of the projected world instead of the \"mercator meter\"\n * - the origin of the coordinate space is at the north-west corner instead of the middle\n *\n * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and\n * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with\n * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think\n * of the coordinate space as the `0/0/0` tile with an extent of `1`.\n *\n * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let nullIsland = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * ```\n * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/)\n */\nexport class MercatorCoordinate implements IMercatorCoordinate {\n x: number;\n y: number;\n z: number;\n\n /**\n * @param x - The x component of the position.\n * @param y - The y component of the position.\n * @param z - The z component of the position.\n */\n constructor(x: number, y: number, z: number = 0) {\n this.x = +x;\n this.y = +y;\n this.z = +z;\n }\n\n /**\n * Project a `LngLat` to a `MercatorCoordinate`.\n *\n * @param lngLatLike - The location to project.\n * @param altitude - The altitude in meters of the position.\n * @returns The projected mercator coordinate.\n * @example\n * ```ts\n * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);\n * coord; // MercatorCoordinate(0.5, 0.5, 0)\n * ```\n */\n static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0): MercatorCoordinate {\n const lngLat = LngLat.convert(lngLatLike);\n\n return new MercatorCoordinate(\n mercatorXfromLng(lngLat.lng),\n mercatorYfromLat(lngLat.lat),\n mercatorZfromAltitude(altitude, lngLat.lat));\n }\n\n /**\n * Returns the `LngLat` for the coordinate.\n *\n * @returns The `LngLat` object.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * let lngLat = coord.toLngLat(); // LngLat(0, 0)\n * ```\n */\n toLngLat() {\n return new LngLat(\n lngFromMercatorX(this.x),\n latFromMercatorY(this.y));\n }\n\n /**\n * Returns the altitude in meters of the coordinate.\n *\n * @returns The altitude in meters.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02);\n * coord.toAltitude(); // 6914.281956295339\n * ```\n */\n toAltitude(): number {\n return altitudeFromMercatorZ(this.z, this.y);\n }\n\n /**\n * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.\n *\n * For coordinates in real world units using meters, this naturally provides the scale\n * to transform into `MercatorCoordinate`s.\n *\n * @returns Distance of 1 meter in `MercatorCoordinate` units.\n */\n meterInMercatorCoordinateUnits(): number {\n // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude\n return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));\n }\n}\n","import {getTileBBox} from '@mapbox/whoots-js';\nimport {EXTENT} from '../data/extent';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {register} from '../util/web_worker_transfer';\nimport {mat4} from 'gl-matrix';\nimport {ICanonicalTileID, IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A canonical way to define a tile ID\n */\nexport class CanonicalTileID implements ICanonicalTileID {\n z: number;\n x: number;\n y: number;\n key: string;\n\n constructor(z: number, x: number, y: number) {\n\n if (z < 0 || z > 25 || y < 0 || y >= Math.pow(2, z) || x < 0 || x >= Math.pow(2, z)) {\n throw new Error(`x=${x}, y=${y}, z=${z} outside of bounds. 0<=x<${Math.pow(2, z)}, 0<=y<${Math.pow(2, z)} 0<=z<=25 `);\n }\n\n this.z = z;\n this.x = x;\n this.y = y;\n this.key = calculateKey(0, z, z, x, y);\n }\n\n equals(id: ICanonicalTileID) {\n return this.z === id.z && this.x === id.x && this.y === id.y;\n }\n\n // given a list of urls, choose a url template and return a tile URL\n url(urls: Array, pixelRatio: number, scheme?: string | null) {\n const bbox = getTileBBox(this.x, this.y, this.z);\n const quadkey = getQuadkey(this.z, this.x, this.y);\n\n return urls[(this.x + this.y) % urls.length]\n .replace(/{prefix}/g, (this.x % 16).toString(16) + (this.y % 16).toString(16))\n .replace(/{z}/g, String(this.z))\n .replace(/{x}/g, String(this.x))\n .replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))\n .replace(/{ratio}/g, pixelRatio > 1 ? '@2x' : '')\n .replace(/{quadkey}/g, quadkey)\n .replace(/{bbox-epsg-3857}/g, bbox);\n }\n\n isChildOf(parent: ICanonicalTileID) {\n const dz = this.z - parent.z;\n return dz > 0 && parent.x === (this.x >> dz) && parent.y === (this.y >> dz);\n }\n\n getTilePoint(coord: IMercatorCoordinate) {\n const tilesAtZoom = Math.pow(2, this.z);\n return new Point(\n (coord.x * tilesAtZoom - this.x) * EXTENT,\n (coord.y * tilesAtZoom - this.y) * EXTENT);\n }\n\n toString() {\n return `${this.z}/${this.x}/${this.y}`;\n }\n}\n\n/**\n * @internal\n * An unwrapped tile identifier\n */\nexport class UnwrappedTileID {\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n\n constructor(wrap: number, canonical: CanonicalTileID) {\n this.wrap = wrap;\n this.canonical = canonical;\n this.key = calculateKey(wrap, canonical.z, canonical.z, canonical.x, canonical.y);\n }\n}\n\n/**\n * An overscaled tile identifier\n */\nexport class OverscaledTileID {\n overscaledZ: number;\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n posMatrix: mat4;\n\n constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number) {\n if (overscaledZ < z) throw new Error(`overscaledZ should be >= z; overscaledZ = ${overscaledZ}; z = ${z}`);\n this.overscaledZ = overscaledZ;\n this.wrap = wrap;\n this.canonical = new CanonicalTileID(z, +x, +y);\n this.key = calculateKey(wrap, overscaledZ, z, x, y);\n }\n\n clone() {\n return new OverscaledTileID(this.overscaledZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n equals(id: OverscaledTileID) {\n return this.overscaledZ === id.overscaledZ && this.wrap === id.wrap && this.canonical.equals(id.canonical);\n }\n\n scaledTo(targetZ: number) {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return new OverscaledTileID(targetZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return new OverscaledTileID(targetZ, this.wrap, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n /*\n * calculateScaledKey is an optimization:\n * when withWrap == true, implements the same as this.scaledTo(z).key,\n * when withWrap == false, implements the same as this.scaledTo(z).wrapped().key.\n */\n calculateScaledKey(targetZ: number, withWrap: boolean): string {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return calculateKey(this.wrap * +withWrap, targetZ, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return calculateKey(this.wrap * +withWrap, targetZ, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n isChildOf(parent: OverscaledTileID) {\n if (parent.wrap !== this.wrap) {\n // We can't be a child if we're in a different world copy\n return false;\n }\n const zDifference = this.canonical.z - parent.canonical.z;\n // We're first testing for z == 0, to avoid a 32 bit shift, which is undefined.\n return parent.overscaledZ === 0 || (\n parent.overscaledZ < this.overscaledZ &&\n parent.canonical.x === (this.canonical.x >> zDifference) &&\n parent.canonical.y === (this.canonical.y >> zDifference));\n }\n\n children(sourceMaxZoom: number) {\n if (this.overscaledZ >= sourceMaxZoom) {\n // return a single tile coord representing a an overscaled tile\n return [new OverscaledTileID(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)];\n }\n\n const z = this.canonical.z + 1;\n const x = this.canonical.x * 2;\n const y = this.canonical.y * 2;\n return [\n new OverscaledTileID(z, this.wrap, z, x, y),\n new OverscaledTileID(z, this.wrap, z, x + 1, y),\n new OverscaledTileID(z, this.wrap, z, x, y + 1),\n new OverscaledTileID(z, this.wrap, z, x + 1, y + 1)\n ];\n }\n\n isLessThan(rhs: OverscaledTileID) {\n if (this.wrap < rhs.wrap) return true;\n if (this.wrap > rhs.wrap) return false;\n\n if (this.overscaledZ < rhs.overscaledZ) return true;\n if (this.overscaledZ > rhs.overscaledZ) return false;\n\n if (this.canonical.x < rhs.canonical.x) return true;\n if (this.canonical.x > rhs.canonical.x) return false;\n\n if (this.canonical.y < rhs.canonical.y) return true;\n return false;\n }\n\n wrapped() {\n return new OverscaledTileID(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n unwrapTo(wrap: number) {\n return new OverscaledTileID(this.overscaledZ, wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n overscaleFactor() {\n return Math.pow(2, this.overscaledZ - this.canonical.z);\n }\n\n toUnwrapped() {\n return new UnwrappedTileID(this.wrap, this.canonical);\n }\n\n toString() {\n return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`;\n }\n\n getTilePoint(coord: MercatorCoordinate) {\n return this.canonical.getTilePoint(new MercatorCoordinate(coord.x - this.wrap, coord.y));\n }\n}\n\nfunction calculateKey(wrap: number, overscaledZ: number, z: number, x: number, y: number): string {\n wrap *= 2;\n if (wrap < 0) wrap = wrap * -1 - 1;\n const dim = 1 << z;\n return (dim * dim * wrap + dim * y + x).toString(36) + z.toString(36) + overscaledZ.toString(36);\n}\n\nfunction getQuadkey(z, x, y) {\n let quadkey = '', mask;\n for (let i = z; i > 0; i--) {\n mask = 1 << (i - 1);\n quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0));\n }\n return quadkey;\n}\n\nregister('CanonicalTileID', CanonicalTileID);\nregister('OverscaledTileID', OverscaledTileID, {omit: ['posMatrix']});\n","import {FeatureIndex} from '../data/feature_index';\nimport {performSymbolLayout} from '../symbol/symbol_layout';\nimport {CollisionBoxArray} from '../data/array_types.g';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {LineBucket} from '../data/bucket/line_bucket';\nimport {FillBucket} from '../data/bucket/fill_bucket';\nimport {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';\nimport {warnOnce, mapObject} from '../util/util';\nimport {ImageAtlas} from '../render/image_atlas';\nimport {GlyphAtlas} from '../render/glyph_atlas';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {OverscaledTileID} from './tile_id';\n\nimport type {Bucket} from '../data/bucket';\nimport type {Actor} from '../util/actor';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {\n WorkerTileParameters,\n WorkerTileCallback,\n} from '../source/worker_source';\nimport type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {VectorTile} from '@mapbox/vector-tile';\nimport {Cancelable} from '../types/cancelable';\n\nexport class WorkerTile {\n tileID: OverscaledTileID;\n uid: string;\n zoom: number;\n pixelRatio: number;\n tileSize: number;\n source: string;\n promoteId: PromoteIdSpecification;\n overscaling: number;\n showCollisionBoxes: boolean;\n collectResourceTiming: boolean;\n returnDependencies: boolean;\n\n status: 'parsing' | 'done';\n data: VectorTile;\n collisionBoxArray: CollisionBoxArray;\n\n abort: (() => void);\n vectorTile: VectorTile;\n inFlightDependencies: Cancelable[];\n dependencySentinel: number;\n\n constructor(params: WorkerTileParameters) {\n this.tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y);\n this.uid = params.uid;\n this.zoom = params.zoom;\n this.pixelRatio = params.pixelRatio;\n this.tileSize = params.tileSize;\n this.source = params.source;\n this.overscaling = this.tileID.overscaleFactor();\n this.showCollisionBoxes = params.showCollisionBoxes;\n this.collectResourceTiming = !!params.collectResourceTiming;\n this.returnDependencies = !!params.returnDependencies;\n this.promoteId = params.promoteId;\n this.inFlightDependencies = [];\n this.dependencySentinel = -1;\n }\n\n parse(data: VectorTile, layerIndex: StyleLayerIndex, availableImages: Array, actor: Actor, callback: WorkerTileCallback) {\n this.status = 'parsing';\n this.data = data;\n\n this.collisionBoxArray = new CollisionBoxArray();\n const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort());\n\n const featureIndex = new FeatureIndex(this.tileID, this.promoteId);\n featureIndex.bucketLayerIDs = [];\n\n const buckets: {[_: string]: Bucket} = {};\n\n const options = {\n featureIndex,\n iconDependencies: {},\n patternDependencies: {},\n glyphDependencies: {},\n availableImages\n };\n\n const layerFamilies = layerIndex.familiesBySource[this.source];\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer = data.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n if (sourceLayer.version === 1) {\n warnOnce(`Vector tile source \"${this.source}\" layer \"${sourceLayerId}\" ` +\n 'does not use vector tile spec v2 and therefore may have some rendering errors.');\n }\n\n const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId);\n const features = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature = sourceLayer.feature(index);\n const id = featureIndex.getId(feature, sourceLayerId);\n features.push({feature, id, index, sourceLayerIndex});\n }\n\n for (const family of layerFamilies[sourceLayerId]) {\n const layer = family[0];\n\n if (layer.source !== this.source) {\n warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`);\n }\n if (layer.minzoom && this.zoom < Math.floor(layer.minzoom)) continue;\n if (layer.maxzoom && this.zoom >= layer.maxzoom) continue;\n if (layer.visibility === 'none') continue;\n\n recalculateLayers(family, this.zoom, availableImages);\n\n const bucket = buckets[layer.id] = layer.createBucket({\n index: featureIndex.bucketLayerIDs.length,\n layers: family,\n zoom: this.zoom,\n pixelRatio: this.pixelRatio,\n overscaling: this.overscaling,\n collisionBoxArray: this.collisionBoxArray,\n sourceLayerIndex,\n sourceID: this.source\n });\n\n bucket.populate(features, options, this.tileID.canonical);\n featureIndex.bucketLayerIDs.push(family.map((l) => l.id));\n }\n }\n\n let error: Error;\n let glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n };\n let iconMap: {[_: string]: StyleImage};\n let patternMap: {[_: string]: StyleImage};\n\n const stacks = mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number));\n\n this.inFlightDependencies.forEach((request) => request?.cancel());\n this.inFlightDependencies = [];\n\n // cancelling seems to be not sufficient, we seems to still manage to get a callback hit, so use a sentinel to drop stale results\n const dependencySentinel = ++this.dependencySentinel;\n if (Object.keys(stacks).length) {\n this.inFlightDependencies.push(actor.send('getGlyphs', {uid: this.uid, stacks, source: this.source, tileID: this.tileID, type: 'glyphs'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n glyphMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n glyphMap = {};\n }\n\n const icons = Object.keys(options.iconDependencies);\n if (icons.length) {\n this.inFlightDependencies.push(actor.send('getImages', {icons, source: this.source, tileID: this.tileID, type: 'icons'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n iconMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n iconMap = {};\n }\n\n const patterns = Object.keys(options.patternDependencies);\n if (patterns.length) {\n this.inFlightDependencies.push(actor.send('getImages', {icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n patternMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n patternMap = {};\n }\n\n maybePrepare.call(this);\n\n function maybePrepare() {\n if (error) {\n return callback(error);\n } else if (glyphMap && iconMap && patternMap) {\n const glyphAtlas = new GlyphAtlas(glyphMap);\n const imageAtlas = new ImageAtlas(iconMap, patternMap);\n\n for (const key in buckets) {\n const bucket = buckets[key];\n if (bucket instanceof SymbolBucket) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n performSymbolLayout({\n bucket,\n glyphMap,\n glyphPositions: glyphAtlas.positions,\n imageMap: iconMap,\n imagePositions: imageAtlas.iconPositions,\n showCollisionBoxes: this.showCollisionBoxes,\n canonical: this.tileID.canonical\n });\n } else if (bucket.hasPattern &&\n (bucket instanceof LineBucket ||\n bucket instanceof FillBucket ||\n bucket instanceof FillExtrusionBucket)) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions);\n }\n }\n\n this.status = 'done';\n callback(null, {\n buckets: Object.values(buckets).filter(b => !b.isEmpty()),\n featureIndex,\n collisionBoxArray: this.collisionBoxArray,\n glyphAtlasImage: glyphAtlas.image,\n imageAtlas,\n // Only used for benchmarking:\n glyphMap: this.returnDependencies ? glyphMap : null,\n iconMap: this.returnDependencies ? iconMap : null,\n glyphPositions: this.returnDependencies ? glyphAtlas.positions : null\n });\n }\n }\n }\n}\n\nfunction recalculateLayers(layers: ReadonlyArray, zoom: number, availableImages: Array) {\n // Layers are shared and may have been used by a WorkerTile with a different zoom.\n const parameters = new EvaluationParameters(zoom);\n for (const layer of layers) {\n layer.recalculate(parameters, availableImages);\n }\n}\n","import type {RequestParameters} from '../util/ajax';\n\nexport type PerformanceMetrics = {\n loadTime: number;\n fullLoadTime: number;\n fps: number;\n percentDroppedFrames: number;\n totalFrames: number;\n};\n\nexport enum PerformanceMarkers {\n create = 'create',\n load = 'load',\n fullLoad = 'fullLoad'\n}\n\nlet lastFrameTime = null;\nlet frameTimes = [];\n\nconst minFramerateTarget = 60;\nconst frameTimeTarget = 1000 / minFramerateTarget;\n\nconst loadTimeKey = 'loadTime';\nconst fullLoadTimeKey = 'fullLoadTime';\n\nexport const PerformanceUtils = {\n mark(marker: PerformanceMarkers) {\n performance.mark(marker);\n },\n frame(timestamp: number) {\n const currTimestamp = timestamp;\n if (lastFrameTime != null) {\n const frameTime = currTimestamp - lastFrameTime;\n frameTimes.push(frameTime);\n }\n lastFrameTime = currTimestamp;\n },\n clearMetrics() {\n lastFrameTime = null;\n frameTimes = [];\n performance.clearMeasures(loadTimeKey);\n performance.clearMeasures(fullLoadTimeKey);\n\n for (const marker in PerformanceMarkers) {\n performance.clearMarks(PerformanceMarkers[marker]);\n }\n },\n\n getPerformanceMetrics(): PerformanceMetrics {\n performance.measure(loadTimeKey, PerformanceMarkers.create, PerformanceMarkers.load);\n performance.measure(fullLoadTimeKey, PerformanceMarkers.create, PerformanceMarkers.fullLoad);\n const loadTime = performance.getEntriesByName(loadTimeKey)[0].duration;\n const fullLoadTime = performance.getEntriesByName(fullLoadTimeKey)[0].duration;\n const totalFrames = frameTimes.length;\n\n const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;\n const fps = 1 / avgFrameTime;\n\n // count frames that missed our framerate target\n const droppedFrames = frameTimes\n .filter((frameTime) => frameTime > frameTimeTarget)\n .reduce((acc, curr) => {\n return acc + (curr - frameTimeTarget) / frameTimeTarget;\n }, 0);\n const percentDroppedFrames = (droppedFrames / (totalFrames + droppedFrames)) * 100;\n\n return {\n loadTime,\n fullLoadTime,\n fps,\n percentDroppedFrames,\n totalFrames\n };\n }\n};\n\n/**\n * @internal\n * Safe wrapper for the performance resource timing API in web workers with graceful degradation\n */\nexport class RequestPerformance {\n _marks: {\n start: string;\n end: string;\n measure: string;\n };\n\n constructor (request: RequestParameters) {\n this._marks = {\n start: [request.url, 'start'].join('#'),\n end: [request.url, 'end'].join('#'),\n measure: request.url.toString()\n };\n\n performance.mark(this._marks.start);\n }\n\n finish() {\n performance.mark(this._marks.end);\n let resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // fallback if web worker implementation of perf.getEntriesByName returns empty\n if (resourceTimingData.length === 0) {\n performance.measure(this._marks.measure, this._marks.start, this._marks.end);\n resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // cleanup\n performance.clearMarks(this._marks.start);\n performance.clearMarks(this._marks.end);\n performance.clearMeasures(this._marks.measure);\n }\n\n return resourceTimingData;\n }\n}\n\nexport default performance;\n","import {ExpiryData, getArrayBuffer} from '../util/ajax';\n\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {WorkerTile} from './worker_tile';\nimport {extend} from '../util/util';\nimport {RequestPerformance} from '../util/performance';\n\nimport type {\n WorkerSource,\n WorkerTileParameters,\n WorkerTileCallback,\n TileParameters\n} from '../source/worker_source';\n\nimport type {Actor} from '../util/actor';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\nimport type {Callback} from '../types/callback';\nimport type {VectorTile} from '@mapbox/vector-tile';\n\nexport type LoadVectorTileResult = {\n vectorTile: VectorTile;\n rawData: ArrayBuffer;\n resourceTiming?: Array;\n} & ExpiryData;\n\ntype FetchingState = {\n rawTileData: ArrayBuffer;\n cacheControl: ExpiryData;\n resourceTiming: any;\n}\n\n/**\n * The callback when finished loading vector data\n */\nexport type LoadVectorDataCallback = Callback;\n\nexport type AbortVectorData = () => void;\nexport type LoadVectorData = (params: WorkerTileParameters, callback: LoadVectorDataCallback) => AbortVectorData | void;\n\n/**\n * Loads a vector tile\n */\nfunction loadVectorTile(params: WorkerTileParameters, callback: LoadVectorDataCallback) {\n const request = getArrayBuffer(params.request, (err?: Error | null, data?: ArrayBuffer | null, cacheControl?: string | null, expires?: string | null) => {\n if (err) {\n callback(err);\n } else if (data) {\n try {\n const vectorTile = new vt.VectorTile(new Protobuf(data));\n callback(null, {\n vectorTile,\n rawData: data,\n cacheControl,\n expires\n });\n } catch (ex) {\n const bytes = new Uint8Array(data);\n const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;\n let errorMessage = `Unable to parse the tile at ${params.request.url}, `;\n if (isGzipped) {\n errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';\n } else {\n errorMessage += `got error: ${ex.messge}`;\n }\n callback(new Error(errorMessage));\n }\n }\n });\n return () => {\n request.cancel();\n callback();\n };\n}\n\n/**\n * The {@link WorkerSource} implementation that supports {@link VectorTileSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory VectorTile\n * representation. To do so, create it with\n * `new VectorTileWorkerSource(actor, styleLayers, customLoadVectorDataFunction)`.\n */\nexport class VectorTileWorkerSource implements WorkerSource {\n actor: Actor;\n layerIndex: StyleLayerIndex;\n availableImages: Array;\n loadVectorData: LoadVectorData;\n fetching: {[_: string]: FetchingState };\n loading: {[_: string]: WorkerTile};\n loaded: {[_: string]: WorkerTile};\n\n /**\n * @param loadVectorData - Optional method for custom loading of a VectorTile\n * object based on parameters passed from the main-thread Source. See\n * {@link VectorTileWorkerSource#loadTile}. The default implementation simply\n * loads the pbf at `params.url`.\n */\n constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadVectorData?: LoadVectorData | null) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.loadVectorData = loadVectorData || loadVectorTile;\n this.fetching = {};\n this.loading = {};\n this.loaded = {};\n }\n\n /**\n * Implements {@link WorkerSource#loadTile}. Delegates to\n * {@link VectorTileWorkerSource#loadVectorData} (which by default expects\n * a `params.url` property) for fetching and producing a VectorTile object.\n */\n loadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const uid = params.uid;\n\n if (!this.loading)\n this.loading = {};\n\n const perf = (params && params.request && params.request.collectResourceTiming) ?\n new RequestPerformance(params.request) : false;\n\n const workerTile = this.loading[uid] = new WorkerTile(params);\n workerTile.abort = this.loadVectorData(params, (err, response) => {\n delete this.loading[uid];\n\n if (err || !response) {\n workerTile.status = 'done';\n this.loaded[uid] = workerTile;\n return callback(err);\n }\n\n const rawTileData = response.rawData;\n const cacheControl = {} as ExpiryData;\n if (response.expires) cacheControl.expires = response.expires;\n if (response.cacheControl) cacheControl.cacheControl = response.cacheControl;\n\n const resourceTiming = {} as {resourceTiming: any};\n if (perf) {\n const resourceTimingData = perf.finish();\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n if (resourceTimingData)\n resourceTiming.resourceTiming = JSON.parse(JSON.stringify(resourceTimingData));\n }\n\n workerTile.vectorTile = response.vectorTile;\n workerTile.parse(response.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => {\n delete this.fetching[uid];\n if (err || !result) return callback(err);\n\n // Transferring a copy of rawTileData because the worker needs to retain its copy.\n callback(null, extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming));\n });\n\n this.loaded = this.loaded || {};\n this.loaded[uid] = workerTile;\n // keep the original fetching state so that reload tile can pick it up if the original parse is cancelled by reloads' parse\n this.fetching[uid] = {rawTileData, cacheControl, resourceTiming};\n }) as AbortVectorData;\n }\n\n /**\n * Implements {@link WorkerSource#reloadTile}.\n */\n reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded;\n const uid = params.uid;\n if (loaded && loaded[uid]) {\n const workerTile = loaded[uid];\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n if (workerTile.status === 'parsing') {\n workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => {\n if (err || !result) return callback(err, result);\n\n // if we have cancelled the original parse, make sure to pass the rawTileData from the original fetch\n let parseResult;\n if (this.fetching[uid]) {\n const {rawTileData, cacheControl, resourceTiming} = this.fetching[uid];\n delete this.fetching[uid];\n parseResult = extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming);\n } else {\n parseResult = result;\n }\n\n callback(null, parseResult);\n });\n } else if (workerTile.status === 'done') {\n // if there was no vector tile data on the initial load, don't try and re-parse tile\n if (workerTile.vectorTile) {\n workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, callback);\n } else {\n callback();\n }\n }\n }\n }\n\n /**\n * Implements {@link WorkerSource#abortTile}.\n *\n * @param params - The tile parameters\n * @param callback - The callback\n */\n abortTile(params: TileParameters, callback: WorkerTileCallback) {\n const loading = this.loading,\n uid = params.uid;\n if (loading && loading[uid] && loading[uid].abort) {\n loading[uid].abort();\n delete loading[uid];\n }\n callback();\n }\n\n /**\n * Implements {@link WorkerSource#removeTile}.\n *\n * @param params - The tile parameters\n * @param callback - The callback\n */\n removeTile(params: TileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded && loaded[uid]) {\n delete loaded[uid];\n }\n callback();\n }\n}\n","import {RGBAImage} from '../util/image';\n\nimport {warnOnce} from '../util/util';\nimport {register} from '../util/web_worker_transfer';\n\n// DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders\n// data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially\n// loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the\n// elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of\n// integer overflow when creating the texture used in the hillshadePrepare step.\n\n// DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8\n// surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a\n// tile's edge without backfilling from neighboring tiles.\n\nexport type DEMEncoding = 'mapbox' | 'terrarium' | 'custom'\n\nexport class DEMData {\n uid: string;\n data: Uint32Array;\n stride: number;\n dim: number;\n min: number;\n max: number;\n redFactor: number;\n greenFactor: number;\n blueFactor: number;\n baseShift: number;\n\n // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride\n // and dim is calculated as stride - 2.\n constructor(uid: string, data: RGBAImage, encoding: DEMEncoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {\n this.uid = uid;\n if (data.height !== data.width) throw new RangeError('DEM tiles must be square');\n if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {\n warnOnce(`\"${encoding}\" is not a valid encoding type. Valid types include \"mapbox\", \"terrarium\" and \"custom\".`);\n return;\n }\n this.stride = data.height;\n const dim = this.dim = data.height - 2;\n this.data = new Uint32Array(data.data.buffer);\n switch (encoding) {\n case 'terrarium':\n // unpacking formula for mapzen terrarium:\n // https://aws.amazon.com/public-datasets/terrain/\n this.redFactor = 256.0;\n this.greenFactor = 1.0;\n this.blueFactor = 1.0 / 256.0;\n this.baseShift = 32768.0;\n break;\n case 'custom':\n this.redFactor = redFactor;\n this.greenFactor = greenFactor;\n this.blueFactor = blueFactor;\n this.baseShift = baseShift;\n break;\n case 'mapbox':\n default:\n // unpacking formula for mapbox.terrain-rgb:\n // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb\n this.redFactor = 6553.6;\n this.greenFactor = 25.6;\n this.blueFactor = 0.1;\n this.baseShift = 10000.0;\n break;\n }\n\n // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image\n // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring\n // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder\n for (let x = 0; x < dim; x++) {\n // left vertical border\n this.data[this._idx(-1, x)] = this.data[this._idx(0, x)];\n // right vertical border\n this.data[this._idx(dim, x)] = this.data[this._idx(dim - 1, x)];\n // left horizontal border\n this.data[this._idx(x, -1)] = this.data[this._idx(x, 0)];\n // right horizontal border\n this.data[this._idx(x, dim)] = this.data[this._idx(x, dim - 1)];\n }\n // corners\n this.data[this._idx(-1, -1)] = this.data[this._idx(0, 0)];\n this.data[this._idx(dim, -1)] = this.data[this._idx(dim - 1, 0)];\n this.data[this._idx(-1, dim)] = this.data[this._idx(0, dim - 1)];\n this.data[this._idx(dim, dim)] = this.data[this._idx(dim - 1, dim - 1)];\n\n // calculate min/max values\n this.min = Number.MAX_SAFE_INTEGER;\n this.max = Number.MIN_SAFE_INTEGER;\n for (let x = 0; x < dim; x++) {\n for (let y = 0; y < dim; y++) {\n const ele = this.get(x, y);\n if (ele > this.max) this.max = ele;\n if (ele < this.min) this.min = ele;\n }\n }\n }\n\n get(x: number, y: number) {\n const pixels = new Uint8Array(this.data.buffer);\n const index = this._idx(x, y) * 4;\n return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);\n }\n\n getUnpackVector() {\n return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];\n }\n\n _idx(x: number, y: number) {\n if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) throw new RangeError('out of range source coordinates for DEM data');\n return (y + 1) * this.stride + (x + 1);\n }\n\n unpack(r: number, g: number, b: number) {\n return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);\n }\n\n getPixels() {\n return new RGBAImage({width: this.stride, height: this.stride}, new Uint8Array(this.data.buffer));\n }\n\n backfillBorder(borderTile: DEMData, dx: number, dy: number) {\n if (this.dim !== borderTile.dim) throw new Error('dem dimension mismatch');\n\n let xMin = dx * this.dim,\n xMax = dx * this.dim + this.dim,\n yMin = dy * this.dim,\n yMax = dy * this.dim + this.dim;\n\n switch (dx) {\n case -1:\n xMin = xMax - 1;\n break;\n case 1:\n xMax = xMin + 1;\n break;\n }\n\n switch (dy) {\n case -1:\n yMin = yMax - 1;\n break;\n case 1:\n yMax = yMin + 1;\n break;\n }\n\n const ox = -dx * this.dim;\n const oy = -dy * this.dim;\n for (let y = yMin; y < yMax; y++) {\n for (let x = xMin; x < xMax; x++) {\n this.data[this._idx(x, y)] = borderTile.data[this._idx(x + ox, y + oy)];\n }\n }\n }\n}\n\nregister('DEMData', DEMData);\n","import {DEMData} from '../data/dem_data';\nimport {RGBAImage} from '../util/image';\nimport type {Actor} from '../util/actor';\nimport type {\n WorkerDEMTileParameters,\n WorkerDEMTileCallback,\n TileParameters\n} from './worker_source';\nimport {getImageData, isImageBitmap} from '../util/util';\n\nexport class RasterDEMTileWorkerSource {\n actor: Actor;\n loaded: {[_: string]: DEMData};\n\n constructor() {\n this.loaded = {};\n }\n\n async loadTile(params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) {\n const {uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift} = params;\n const width = rawImageData.width + 2;\n const height = rawImageData.height + 2;\n const imagePixels: RGBAImage = isImageBitmap(rawImageData) ?\n new RGBAImage({width, height}, await getImageData(rawImageData, -1, -1, width, height)) :\n rawImageData;\n const dem = new DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);\n this.loaded = this.loaded || {};\n this.loaded[uid] = dem;\n callback(null, dem);\n }\n\n removeTile(params: TileParameters) {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded && loaded[uid]) {\n delete loaded[uid];\n }\n }\n}\n","\nmodule.exports = rewind;\n\nfunction rewind(gj, outer) {\n var type = gj && gj.type, i;\n\n if (type === 'FeatureCollection') {\n for (i = 0; i < gj.features.length; i++) rewind(gj.features[i], outer);\n\n } else if (type === 'GeometryCollection') {\n for (i = 0; i < gj.geometries.length; i++) rewind(gj.geometries[i], outer);\n\n } else if (type === 'Feature') {\n rewind(gj.geometry, outer);\n\n } else if (type === 'Polygon') {\n rewindRings(gj.coordinates, outer);\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < gj.coordinates.length; i++) rewindRings(gj.coordinates[i], outer);\n }\n\n return gj;\n}\n\nfunction rewindRings(rings, outer) {\n if (rings.length === 0) return;\n\n rewindRing(rings[0], outer);\n for (var i = 1; i < rings.length; i++) {\n rewindRing(rings[i], !outer);\n }\n}\n\nfunction rewindRing(ring, dir) {\n var area = 0, err = 0;\n for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {\n var k = (ring[i][0] - ring[j][0]) * (ring[j][1] + ring[i][1]);\n var m = area + k;\n err += Math.abs(area) >= Math.abs(k) ? area - m + k : k - m + area;\n area = m;\n }\n if (area + err >= 0 !== !!dir) ring.reverse();\n}\n","import Point from '@mapbox/point-geometry';\n\nimport mvt from '@mapbox/vector-tile';\nimport type {VectorTileFeature, VectorTileLayer, VectorTile} from '@mapbox/vector-tile';\nconst toGeoJSON = mvt.VectorTileFeature.prototype.toGeoJSON;\nimport {EXTENT} from '../data/extent';\nimport type {TileFeature, AnyProps} from 'supercluster';\nimport type {Feature as GeoJSONVTFeature} from 'geojson-vt';\n\nexport type Feature = TileFeature | GeoJSONVTFeature;\n\nclass FeatureWrapper implements VectorTileFeature {\n _feature: Feature;\n\n extent: number;\n type: Feature['type'];\n id: number;\n properties: {[_: string]: string | number | boolean};\n\n constructor(feature: Feature) {\n this._feature = feature;\n\n this.extent = EXTENT;\n this.type = feature.type;\n this.properties = feature.tags;\n\n // If the feature has a top-level `id` property, copy it over, but only\n // if it can be coerced to an integer, because this wrapper is used for\n // serializing geojson feature data into vector tile PBF data, and the\n // vector tile spec only supports integer values for feature ids --\n // allowing non-integer values here results in a non-compliant PBF\n // that causes an exception when it is parsed with vector-tile-js\n if ('id' in feature && !isNaN(feature.id as any)) {\n this.id = parseInt(feature.id, 10);\n }\n }\n\n loadGeometry() {\n if (this._feature.type === 1) {\n const geometry = [];\n for (const point of this._feature.geometry) {\n geometry.push([new Point(point[0], point[1])]);\n }\n return geometry;\n } else {\n const geometry = [];\n for (const ring of this._feature.geometry) {\n const newRing = [];\n for (const point of ring) {\n newRing.push(new Point(point[0], point[1]));\n }\n geometry.push(newRing);\n }\n return geometry;\n }\n }\n\n toGeoJSON(x: number, y: number, z: number) {\n return toGeoJSON.call(this, x, y, z);\n }\n}\n\nexport class GeoJSONWrapper implements VectorTile, VectorTileLayer {\n layers: {[_: string]: VectorTileLayer};\n name: string;\n extent: number;\n length: number;\n _features: Array;\n\n constructor(features: Array) {\n this.layers = {'_geojsonTileLayer': this};\n this.name = '_geojsonTileLayer';\n this.extent = EXTENT;\n this.length = features.length;\n this._features = features;\n }\n\n feature(i: number): VectorTileFeature {\n return new FeatureWrapper(this._features[i]);\n }\n}\n","'use strict'\n\nvar Point = require('@mapbox/point-geometry')\nvar VectorTileFeature = require('@mapbox/vector-tile').VectorTileFeature\n\nmodule.exports = GeoJSONWrapper\n\n// conform to vectortile api\nfunction GeoJSONWrapper (features, options) {\n this.options = options || {}\n this.features = features\n this.length = features.length\n}\n\nGeoJSONWrapper.prototype.feature = function (i) {\n return new FeatureWrapper(this.features[i], this.options.extent)\n}\n\nfunction FeatureWrapper (feature, extent) {\n this.id = typeof feature.id === 'number' ? feature.id : undefined\n this.type = feature.type\n this.rawGeometry = feature.type === 1 ? [feature.geometry] : feature.geometry\n this.properties = feature.tags\n this.extent = extent || 4096\n}\n\nFeatureWrapper.prototype.loadGeometry = function () {\n var rings = this.rawGeometry\n this.geometry = []\n\n for (var i = 0; i < rings.length; i++) {\n var ring = rings[i]\n var newRing = []\n for (var j = 0; j < ring.length; j++) {\n newRing.push(new Point(ring[j][0], ring[j][1]))\n }\n this.geometry.push(newRing)\n }\n return this.geometry\n}\n\nFeatureWrapper.prototype.bbox = function () {\n if (!this.geometry) this.loadGeometry()\n\n var rings = this.geometry\n var x1 = Infinity\n var x2 = -Infinity\n var y1 = Infinity\n var y2 = -Infinity\n\n for (var i = 0; i < rings.length; i++) {\n var ring = rings[i]\n\n for (var j = 0; j < ring.length; j++) {\n var coord = ring[j]\n\n x1 = Math.min(x1, coord.x)\n x2 = Math.max(x2, coord.x)\n y1 = Math.min(y1, coord.y)\n y2 = Math.max(y2, coord.y)\n }\n }\n\n return [x1, y1, x2, y2]\n}\n\nFeatureWrapper.prototype.toGeoJSON = VectorTileFeature.prototype.toGeoJSON\n","var Pbf = require('pbf')\nvar GeoJSONWrapper = require('./lib/geojson_wrapper')\n\nmodule.exports = fromVectorTileJs\nmodule.exports.fromVectorTileJs = fromVectorTileJs\nmodule.exports.fromGeojsonVt = fromGeojsonVt\nmodule.exports.GeoJSONWrapper = GeoJSONWrapper\n\n/**\n * Serialize a vector-tile-js-created tile to pbf\n *\n * @param {Object} tile\n * @return {Buffer} uncompressed, pbf-serialized tile data\n */\nfunction fromVectorTileJs (tile) {\n var out = new Pbf()\n writeTile(tile, out)\n return out.finish()\n}\n\n/**\n * Serialized a geojson-vt-created tile to pbf.\n *\n * @param {Object} layers - An object mapping layer names to geojson-vt-created vector tile objects\n * @param {Object} [options] - An object specifying the vector-tile specification version and extent that were used to create `layers`.\n * @param {Number} [options.version=1] - Version of vector-tile spec used\n * @param {Number} [options.extent=4096] - Extent of the vector tile\n * @return {Buffer} uncompressed, pbf-serialized tile data\n */\nfunction fromGeojsonVt (layers, options) {\n options = options || {}\n var l = {}\n for (var k in layers) {\n l[k] = new GeoJSONWrapper(layers[k].features, options)\n l[k].name = k\n l[k].version = options.version\n l[k].extent = options.extent\n }\n return fromVectorTileJs({ layers: l })\n}\n\nfunction writeTile (tile, pbf) {\n for (var key in tile.layers) {\n pbf.writeMessage(3, writeLayer, tile.layers[key])\n }\n}\n\nfunction writeLayer (layer, pbf) {\n pbf.writeVarintField(15, layer.version || 1)\n pbf.writeStringField(1, layer.name || '')\n pbf.writeVarintField(5, layer.extent || 4096)\n\n var i\n var context = {\n keys: [],\n values: [],\n keycache: {},\n valuecache: {}\n }\n\n for (i = 0; i < layer.length; i++) {\n context.feature = layer.feature(i)\n pbf.writeMessage(2, writeFeature, context)\n }\n\n var keys = context.keys\n for (i = 0; i < keys.length; i++) {\n pbf.writeStringField(3, keys[i])\n }\n\n var values = context.values\n for (i = 0; i < values.length; i++) {\n pbf.writeMessage(4, writeValue, values[i])\n }\n}\n\nfunction writeFeature (context, pbf) {\n var feature = context.feature\n\n if (feature.id !== undefined) {\n pbf.writeVarintField(1, feature.id)\n }\n\n pbf.writeMessage(2, writeProperties, context)\n pbf.writeVarintField(3, feature.type)\n pbf.writeMessage(4, writeGeometry, feature)\n}\n\nfunction writeProperties (context, pbf) {\n var feature = context.feature\n var keys = context.keys\n var values = context.values\n var keycache = context.keycache\n var valuecache = context.valuecache\n\n for (var key in feature.properties) {\n var value = feature.properties[key]\n\n var keyIndex = keycache[key]\n if (value === null) continue // don't encode null value properties\n\n if (typeof keyIndex === 'undefined') {\n keys.push(key)\n keyIndex = keys.length - 1\n keycache[key] = keyIndex\n }\n pbf.writeVarint(keyIndex)\n\n var type = typeof value\n if (type !== 'string' && type !== 'boolean' && type !== 'number') {\n value = JSON.stringify(value)\n }\n var valueKey = type + ':' + value\n var valueIndex = valuecache[valueKey]\n if (typeof valueIndex === 'undefined') {\n values.push(value)\n valueIndex = values.length - 1\n valuecache[valueKey] = valueIndex\n }\n pbf.writeVarint(valueIndex)\n }\n}\n\nfunction command (cmd, length) {\n return (length << 3) + (cmd & 0x7)\n}\n\nfunction zigzag (num) {\n return (num << 1) ^ (num >> 31)\n}\n\nfunction writeGeometry (feature, pbf) {\n var geometry = feature.loadGeometry()\n var type = feature.type\n var x = 0\n var y = 0\n var rings = geometry.length\n for (var r = 0; r < rings; r++) {\n var ring = geometry[r]\n var count = 1\n if (type === 1) {\n count = ring.length\n }\n pbf.writeVarint(command(1, count)) // moveto\n // do not write polygon closing path as lineto\n var lineCount = type === 3 ? ring.length - 1 : ring.length\n for (var i = 0; i < lineCount; i++) {\n if (i === 1 && type !== 1) {\n pbf.writeVarint(command(2, lineCount - 1)) // lineto\n }\n var dx = ring[i].x - x\n var dy = ring[i].y - y\n pbf.writeVarint(zigzag(dx))\n pbf.writeVarint(zigzag(dy))\n x += dx\n y += dy\n }\n if (type === 3) {\n pbf.writeVarint(command(7, 1)) // closepath\n }\n }\n}\n\nfunction writeValue (value, pbf) {\n var type = typeof value\n if (type === 'string') {\n pbf.writeStringField(1, value)\n } else if (type === 'boolean') {\n pbf.writeBooleanField(7, value)\n } else if (type === 'number') {\n if (value % 1 !== 0) {\n pbf.writeDoubleField(3, value)\n } else if (value < 0) {\n pbf.writeSVarintField(6, value)\n } else {\n pbf.writeVarintField(5, value)\n }\n }\n}\n","\nconst ARRAY_TYPES = [\n Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n];\n\n/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */\n\nconst VERSION = 1; // serialized format version\nconst HEADER_SIZE = 8;\n\nexport default class KDBush {\n\n /**\n * Creates an index from raw `ArrayBuffer` data.\n * @param {ArrayBuffer} data\n */\n static from(data) {\n if (!(data instanceof ArrayBuffer)) {\n throw new Error('Data must be an instance of ArrayBuffer.');\n }\n const [magic, versionAndType] = new Uint8Array(data, 0, 2);\n if (magic !== 0xdb) {\n throw new Error('Data does not appear to be in a KDBush format.');\n }\n const version = versionAndType >> 4;\n if (version !== VERSION) {\n throw new Error(`Got v${version} data when expected v${VERSION}.`);\n }\n const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];\n if (!ArrayType) {\n throw new Error('Unrecognized array type.');\n }\n const [nodeSize] = new Uint16Array(data, 2, 1);\n const [numItems] = new Uint32Array(data, 4, 1);\n\n return new KDBush(numItems, nodeSize, ArrayType, data);\n }\n\n /**\n * Creates an index that will hold a given number of items.\n * @param {number} numItems\n * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).\n * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).\n * @param {ArrayBuffer} [data] (For internal use only)\n */\n constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) {\n if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`);\n\n this.numItems = +numItems;\n this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);\n this.ArrayType = ArrayType;\n this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;\n\n const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);\n const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;\n const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;\n const padCoords = (8 - idsByteSize % 8) % 8;\n\n if (arrayTypeIndex < 0) {\n throw new Error(`Unexpected typed array class: ${ArrayType}.`);\n }\n\n if (data && (data instanceof ArrayBuffer)) { // reconstruct an index from a buffer\n this.data = data;\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = numItems * 2;\n this._finished = true;\n } else { // initialize a new index\n this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = 0;\n this._finished = false;\n\n // set header\n new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);\n new Uint16Array(this.data, 2, 1)[0] = nodeSize;\n new Uint32Array(this.data, 4, 1)[0] = numItems;\n }\n }\n\n /**\n * Add a point to the index.\n * @param {number} x\n * @param {number} y\n * @returns {number} An incremental index associated with the added item (starting from `0`).\n */\n add(x, y) {\n const index = this._pos >> 1;\n this.ids[index] = index;\n this.coords[this._pos++] = x;\n this.coords[this._pos++] = y;\n return index;\n }\n\n /**\n * Perform indexing of the added points.\n */\n finish() {\n const numAdded = this._pos >> 1;\n if (numAdded !== this.numItems) {\n throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);\n }\n // kd-sort both arrays for efficient search\n sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);\n\n this._finished = true;\n return this;\n }\n\n /**\n * Search the index for items within a given bounding box.\n * @param {number} minX\n * @param {number} minY\n * @param {number} maxX\n * @param {number} maxY\n * @returns {number[]} An array of indices correponding to the found items.\n */\n range(minX, minY, maxX, maxY) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n\n // recursively search for items in range in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n const x = coords[2 * i];\n const y = coords[2 * i + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? minX <= x : minY <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? maxX >= x : maxY >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n\n /**\n * Search the index for items within a given radius.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @returns {number[]} An array of indices correponding to the found items.\n */\n within(qx, qy, r) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n const r2 = r * r;\n\n // recursively search for items within radius in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? qx - r <= x : qy - r <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? qx + r >= x : qy + r >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} nodeSize\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction sort(ids, coords, nodeSize, left, right, axis) {\n if (right - left <= nodeSize) return;\n\n const m = (left + right) >> 1; // middle index\n\n // sort ids and coords around the middle index so that the halves lie\n // either left/right or top/bottom correspondingly (taking turns)\n select(ids, coords, m, left, right, axis);\n\n // recursively kd-sort first half and second half on the opposite axis\n sort(ids, coords, nodeSize, left, m - 1, 1 - axis);\n sort(ids, coords, nodeSize, m + 1, right, 1 - axis);\n}\n\n/**\n * Custom Floyd-Rivest selection algorithm: sort ids and coords so that\n * [left..k-1] items are smaller than k-th item (on either x or y axis)\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} k\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction select(ids, coords, k, left, right, axis) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n select(ids, coords, k, newLeft, newRight, axis);\n }\n\n const t = coords[2 * k + axis];\n let i = left;\n let j = right;\n\n swapItem(ids, coords, left, k);\n if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);\n\n while (i < j) {\n swapItem(ids, coords, i, j);\n i++;\n j--;\n while (coords[2 * i + axis] < t) i++;\n while (coords[2 * j + axis] > t) j--;\n }\n\n if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);\n else {\n j++;\n swapItem(ids, coords, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} i\n * @param {number} j\n */\nfunction swapItem(ids, coords, i, j) {\n swap(ids, i, j);\n swap(coords, 2 * i, 2 * j);\n swap(coords, 2 * i + 1, 2 * j + 1);\n}\n\n/**\n * @param {InstanceType} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @param {number} ax\n * @param {number} ay\n * @param {number} bx\n * @param {number} by\n */\nfunction sqDist(ax, ay, bx, by) {\n const dx = ax - bx;\n const dy = ay - by;\n return dx * dx + dy * dy;\n}\n","\nimport KDBush from 'kdbush';\n\nconst defaultOptions = {\n minZoom: 0, // min zoom to generate clusters on\n maxZoom: 16, // max zoom level to cluster the points on\n minPoints: 2, // minimum points to form a cluster\n radius: 40, // cluster radius in pixels\n extent: 512, // tile extent (radius is calculated relative to it)\n nodeSize: 64, // size of the KD-tree leaf node, affects performance\n log: false, // whether to log timing info\n\n // whether to generate numeric ids for input features (in vector tiles)\n generateId: false,\n\n // a reduce function for calculating custom cluster properties\n reduce: null, // (accumulated, props) => { accumulated.sum += props.sum; }\n\n // properties to use for individual points when running the reducer\n map: props => props // props => ({sum: props.my_value})\n};\n\nconst fround = Math.fround || (tmp => ((x) => { tmp[0] = +x; return tmp[0]; }))(new Float32Array(1));\n\nconst OFFSET_ZOOM = 2;\nconst OFFSET_ID = 3;\nconst OFFSET_PARENT = 4;\nconst OFFSET_NUM = 5;\nconst OFFSET_PROP = 6;\n\nexport default class Supercluster {\n constructor(options) {\n this.options = Object.assign(Object.create(defaultOptions), options);\n this.trees = new Array(this.options.maxZoom + 1);\n this.stride = this.options.reduce ? 7 : 6;\n this.clusterProps = [];\n }\n\n load(points) {\n const {log, minZoom, maxZoom} = this.options;\n\n if (log) console.time('total time');\n\n const timerId = `prepare ${ points.length } points`;\n if (log) console.time(timerId);\n\n this.points = points;\n\n // generate a cluster object for each point and index input points into a KD-tree\n const data = [];\n\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n if (!p.geometry) continue;\n\n const [lng, lat] = p.geometry.coordinates;\n const x = fround(lngX(lng));\n const y = fround(latY(lat));\n // store internal point/cluster data in flat numeric arrays for performance\n data.push(\n x, y, // projected point coordinates\n Infinity, // the last zoom the point was processed at\n i, // index of the source feature in the original input array\n -1, // parent cluster id\n 1 // number of points in a cluster\n );\n if (this.options.reduce) data.push(0); // noop\n }\n let tree = this.trees[maxZoom + 1] = this._createTree(data);\n\n if (log) console.timeEnd(timerId);\n\n // cluster points on max zoom, then cluster the results on previous zoom, etc.;\n // results in a cluster hierarchy across zoom levels\n for (let z = maxZoom; z >= minZoom; z--) {\n const now = +Date.now();\n\n // create a new set of clusters for the zoom and index them with a KD-tree\n tree = this.trees[z] = this._createTree(this._cluster(tree, z));\n\n if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, +Date.now() - now);\n }\n\n if (log) console.timeEnd('total time');\n\n return this;\n }\n\n getClusters(bbox, zoom) {\n let minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180;\n const minLat = Math.max(-90, Math.min(90, bbox[1]));\n let maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180;\n const maxLat = Math.max(-90, Math.min(90, bbox[3]));\n\n if (bbox[2] - bbox[0] >= 360) {\n minLng = -180;\n maxLng = 180;\n } else if (minLng > maxLng) {\n const easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom);\n const westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom);\n return easternHem.concat(westernHem);\n }\n\n const tree = this.trees[this._limitZoom(zoom)];\n const ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat));\n const data = tree.data;\n const clusters = [];\n for (const id of ids) {\n const k = this.stride * id;\n clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n return clusters;\n }\n\n getChildren(clusterId) {\n const originId = this._getOriginId(clusterId);\n const originZoom = this._getOriginZoom(clusterId);\n const errorMsg = 'No cluster with the specified id.';\n\n const tree = this.trees[originZoom];\n if (!tree) throw new Error(errorMsg);\n\n const data = tree.data;\n if (originId * this.stride >= data.length) throw new Error(errorMsg);\n\n const r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1));\n const x = data[originId * this.stride];\n const y = data[originId * this.stride + 1];\n const ids = tree.within(x, y, r);\n const children = [];\n for (const id of ids) {\n const k = id * this.stride;\n if (data[k + OFFSET_PARENT] === clusterId) {\n children.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n }\n\n if (children.length === 0) throw new Error(errorMsg);\n\n return children;\n }\n\n getLeaves(clusterId, limit, offset) {\n limit = limit || 10;\n offset = offset || 0;\n\n const leaves = [];\n this._appendLeaves(leaves, clusterId, limit, offset, 0);\n\n return leaves;\n }\n\n getTile(z, x, y) {\n const tree = this.trees[this._limitZoom(z)];\n const z2 = Math.pow(2, z);\n const {extent, radius} = this.options;\n const p = radius / extent;\n const top = (y - p) / z2;\n const bottom = (y + 1 + p) / z2;\n\n const tile = {\n features: []\n };\n\n this._addTileFeatures(\n tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom),\n tree.data, x, y, z2, tile);\n\n if (x === 0) {\n this._addTileFeatures(\n tree.range(1 - p / z2, top, 1, bottom),\n tree.data, z2, y, z2, tile);\n }\n if (x === z2 - 1) {\n this._addTileFeatures(\n tree.range(0, top, p / z2, bottom),\n tree.data, -1, y, z2, tile);\n }\n\n return tile.features.length ? tile : null;\n }\n\n getClusterExpansionZoom(clusterId) {\n let expansionZoom = this._getOriginZoom(clusterId) - 1;\n while (expansionZoom <= this.options.maxZoom) {\n const children = this.getChildren(clusterId);\n expansionZoom++;\n if (children.length !== 1) break;\n clusterId = children[0].properties.cluster_id;\n }\n return expansionZoom;\n }\n\n _appendLeaves(result, clusterId, limit, offset, skipped) {\n const children = this.getChildren(clusterId);\n\n for (const child of children) {\n const props = child.properties;\n\n if (props && props.cluster) {\n if (skipped + props.point_count <= offset) {\n // skip the whole cluster\n skipped += props.point_count;\n } else {\n // enter the cluster\n skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped);\n // exit the cluster\n }\n } else if (skipped < offset) {\n // skip a single point\n skipped++;\n } else {\n // add a single point\n result.push(child);\n }\n if (result.length === limit) break;\n }\n\n return skipped;\n }\n\n _createTree(data) {\n const tree = new KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array);\n for (let i = 0; i < data.length; i += this.stride) tree.add(data[i], data[i + 1]);\n tree.finish();\n tree.data = data;\n return tree;\n }\n\n _addTileFeatures(ids, data, x, y, z2, tile) {\n for (const i of ids) {\n const k = i * this.stride;\n const isCluster = data[k + OFFSET_NUM] > 1;\n\n let tags, px, py;\n if (isCluster) {\n tags = getClusterProperties(data, k, this.clusterProps);\n px = data[k];\n py = data[k + 1];\n } else {\n const p = this.points[data[k + OFFSET_ID]];\n tags = p.properties;\n const [lng, lat] = p.geometry.coordinates;\n px = lngX(lng);\n py = latY(lat);\n }\n\n const f = {\n type: 1,\n geometry: [[\n Math.round(this.options.extent * (px * z2 - x)),\n Math.round(this.options.extent * (py * z2 - y))\n ]],\n tags\n };\n\n // assign id\n let id;\n if (isCluster || this.options.generateId) {\n // optionally generate id for points\n id = data[k + OFFSET_ID];\n } else {\n // keep id if already assigned\n id = this.points[data[k + OFFSET_ID]].id;\n }\n\n if (id !== undefined) f.id = id;\n\n tile.features.push(f);\n }\n }\n\n _limitZoom(z) {\n return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1));\n }\n\n _cluster(tree, zoom) {\n const {radius, extent, reduce, minPoints} = this.options;\n const r = radius / (extent * Math.pow(2, zoom));\n const data = tree.data;\n const nextData = [];\n const stride = this.stride;\n\n // loop through each point\n for (let i = 0; i < data.length; i += stride) {\n // if we've already visited the point at this zoom level, skip it\n if (data[i + OFFSET_ZOOM] <= zoom) continue;\n data[i + OFFSET_ZOOM] = zoom;\n\n // find all nearby points\n const x = data[i];\n const y = data[i + 1];\n const neighborIds = tree.within(data[i], data[i + 1], r);\n\n const numPointsOrigin = data[i + OFFSET_NUM];\n let numPoints = numPointsOrigin;\n\n // count the number of points in a potential cluster\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n // filter out neighbors that are already processed\n if (data[k + OFFSET_ZOOM] > zoom) numPoints += data[k + OFFSET_NUM];\n }\n\n // if there were neighbors to merge, and there are enough points to form a cluster\n if (numPoints > numPointsOrigin && numPoints >= minPoints) {\n let wx = x * numPointsOrigin;\n let wy = y * numPointsOrigin;\n\n let clusterProperties;\n let clusterPropIndex = -1;\n\n // encode both zoom and point index on which the cluster originated -- offset by total length of features\n const id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length;\n\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice)\n\n const numPoints2 = data[k + OFFSET_NUM];\n wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center\n wy += data[k + 1] * numPoints2;\n\n data[k + OFFSET_PARENT] = id;\n\n if (reduce) {\n if (!clusterProperties) {\n clusterProperties = this._map(data, i, true);\n clusterPropIndex = this.clusterProps.length;\n this.clusterProps.push(clusterProperties);\n }\n reduce(clusterProperties, this._map(data, k));\n }\n }\n\n data[i + OFFSET_PARENT] = id;\n nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints);\n if (reduce) nextData.push(clusterPropIndex);\n\n } else { // left points as unclustered\n for (let j = 0; j < stride; j++) nextData.push(data[i + j]);\n\n if (numPoints > 1) {\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom;\n for (let j = 0; j < stride; j++) nextData.push(data[k + j]);\n }\n }\n }\n }\n\n return nextData;\n }\n\n // get index of the point from which the cluster originated\n _getOriginId(clusterId) {\n return (clusterId - this.points.length) >> 5;\n }\n\n // get zoom of the point from which the cluster originated\n _getOriginZoom(clusterId) {\n return (clusterId - this.points.length) % 32;\n }\n\n _map(data, i, clone) {\n if (data[i + OFFSET_NUM] > 1) {\n const props = this.clusterProps[data[i + OFFSET_PROP]];\n return clone ? Object.assign({}, props) : props;\n }\n const original = this.points[data[i + OFFSET_ID]].properties;\n const result = this.options.map(original);\n return clone && result === original ? Object.assign({}, result) : result;\n }\n}\n\nfunction getClusterJSON(data, i, clusterProps) {\n return {\n type: 'Feature',\n id: data[i + OFFSET_ID],\n properties: getClusterProperties(data, i, clusterProps),\n geometry: {\n type: 'Point',\n coordinates: [xLng(data[i]), yLat(data[i + 1])]\n }\n };\n}\n\nfunction getClusterProperties(data, i, clusterProps) {\n const count = data[i + OFFSET_NUM];\n const abbrev =\n count >= 10000 ? `${Math.round(count / 1000) }k` :\n count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count;\n const propIndex = data[i + OFFSET_PROP];\n const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]);\n return Object.assign(properties, {\n cluster: true,\n cluster_id: data[i + OFFSET_ID],\n point_count: count,\n point_count_abbreviated: abbrev\n });\n}\n\n// longitude/latitude to spherical mercator in [0..1] range\nfunction lngX(lng) {\n return lng / 360 + 0.5;\n}\nfunction latY(lat) {\n const sin = Math.sin(lat * Math.PI / 180);\n const y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);\n return y < 0 ? 0 : y > 1 ? 1 : y;\n}\n\n// spherical mercator to longitude/latitude\nfunction xLng(x) {\n return (x - 0.5) * 360;\n}\nfunction yLat(y) {\n const y2 = (180 - y * 360) * Math.PI / 180;\n return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90;\n}\n","\n// calculate simplification data using optimized Douglas-Peucker algorithm\n\nexport default function simplify(coords, first, last, sqTolerance) {\n var maxSqDist = sqTolerance;\n var mid = (last - first) >> 1;\n var minPosToMid = last - first;\n var index;\n\n var ax = coords[first];\n var ay = coords[first + 1];\n var bx = coords[last];\n var by = coords[last + 1];\n\n for (var i = first + 3; i < last; i += 3) {\n var d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n\n } else if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n var posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n\n if (maxSqDist > sqTolerance) {\n if (index - first > 3) simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3) simplify(coords, index, last, sqTolerance);\n }\n}\n\n// square distance from a point to a segment\nfunction getSqSegDist(px, py, x, y, bx, by) {\n\n var dx = bx - x;\n var dy = by - y;\n\n if (dx !== 0 || dy !== 0) {\n\n var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n\n if (t > 1) {\n x = bx;\n y = by;\n\n } else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n\n dx = px - x;\n dy = py - y;\n\n return dx * dx + dy * dy;\n}\n","\nexport default function createFeature(id, type, geom, tags) {\n var feature = {\n id: typeof id === 'undefined' ? null : id,\n type: type,\n geometry: geom,\n tags: tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n calcBBox(feature);\n return feature;\n}\n\nfunction calcBBox(feature) {\n var geom = feature.geometry;\n var type = feature.type;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n\n } else if (type === 'Polygon' || type === 'MultiLineString') {\n for (var i = 0; i < geom.length; i++) {\n calcLineBBox(feature, geom[i]);\n }\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < geom.length; i++) {\n for (var j = 0; j < geom[i].length; j++) {\n calcLineBBox(feature, geom[i][j]);\n }\n }\n }\n}\n\nfunction calcLineBBox(feature, geom) {\n for (var i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n","\nimport simplify from './simplify';\nimport createFeature from './feature';\n\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\n\nexport default function convert(data, options) {\n var features = [];\n if (data.type === 'FeatureCollection') {\n for (var i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n\n } else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n\n } else {\n // single geometry or a geometry collection\n convertFeature(features, {geometry: data}, options);\n }\n\n return features;\n}\n\nfunction convertFeature(features, geojson, options, index) {\n if (!geojson.geometry) return;\n\n var coords = geojson.geometry.coordinates;\n var type = geojson.geometry.type;\n var tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n var geometry = [];\n var id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n } else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n\n } else if (type === 'MultiPoint') {\n for (var i = 0; i < coords.length; i++) {\n convertPoint(coords[i], geometry);\n }\n\n } else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n\n } else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (i = 0; i < coords.length; i++) {\n geometry = [];\n convertLine(coords[i], geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n } else {\n convertLines(coords, geometry, tolerance, false);\n }\n\n } else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < coords.length; i++) {\n var polygon = [];\n convertLines(coords[i], polygon, tolerance, true);\n geometry.push(polygon);\n }\n } else if (type === 'GeometryCollection') {\n for (i = 0; i < geojson.geometry.geometries.length; i++) {\n convertFeature(features, {\n id: id,\n geometry: geojson.geometry.geometries[i],\n properties: geojson.properties\n }, options, index);\n }\n return;\n } else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\n\nfunction convertPoint(coords, out) {\n out.push(projectX(coords[0]));\n out.push(projectY(coords[1]));\n out.push(0);\n}\n\nfunction convertLine(ring, out, tolerance, isPolygon) {\n var x0, y0;\n var size = 0;\n\n for (var j = 0; j < ring.length; j++) {\n var x = projectX(ring[j][0]);\n var y = projectY(ring[j][1]);\n\n out.push(x);\n out.push(y);\n out.push(0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n var last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings, out, tolerance, isPolygon) {\n for (var i = 0; i < rings.length; i++) {\n var geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\nfunction projectX(x) {\n return x / 360 + 0.5;\n}\n\nfunction projectY(y) {\n var sin = Math.sin(y * Math.PI / 180);\n var y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n","\nimport createFeature from './feature';\n\n/* clip features between two axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n */\n\nexport default function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {\n\n k1 /= scale;\n k2 /= scale;\n\n if (minAll >= k1 && maxAll < k2) return features; // trivial accept\n else if (maxAll < k1 || minAll >= k2) return null; // trivial reject\n\n var clipped = [];\n\n for (var i = 0; i < features.length; i++) {\n\n var feature = features[i];\n var geometry = feature.geometry;\n var type = feature.type;\n\n var min = axis === 0 ? feature.minX : feature.minY;\n var max = axis === 0 ? feature.maxX : feature.maxY;\n\n if (min >= k1 && max < k2) { // trivial accept\n clipped.push(feature);\n continue;\n } else if (max < k1 || min >= k2) { // trivial reject\n continue;\n }\n\n var newGeometry = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n clipPoints(geometry, newGeometry, k1, k2, axis);\n\n } else if (type === 'LineString') {\n clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);\n\n } else if (type === 'MultiLineString') {\n clipLines(geometry, newGeometry, k1, k2, axis, false);\n\n } else if (type === 'Polygon') {\n clipLines(geometry, newGeometry, k1, k2, axis, true);\n\n } else if (type === 'MultiPolygon') {\n for (var j = 0; j < geometry.length; j++) {\n var polygon = [];\n clipLines(geometry[j], polygon, k1, k2, axis, true);\n if (polygon.length) {\n newGeometry.push(polygon);\n }\n }\n }\n\n if (newGeometry.length) {\n if (options.lineMetrics && type === 'LineString') {\n for (j = 0; j < newGeometry.length; j++) {\n clipped.push(createFeature(feature.id, type, newGeometry[j], feature.tags));\n }\n continue;\n }\n\n if (type === 'LineString' || type === 'MultiLineString') {\n if (newGeometry.length === 1) {\n type = 'LineString';\n newGeometry = newGeometry[0];\n } else {\n type = 'MultiLineString';\n }\n }\n if (type === 'Point' || type === 'MultiPoint') {\n type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';\n }\n\n clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n }\n\n return clipped.length ? clipped : null;\n}\n\nfunction clipPoints(geom, newGeom, k1, k2, axis) {\n for (var i = 0; i < geom.length; i += 3) {\n var a = geom[i + axis];\n\n if (a >= k1 && a <= k2) {\n newGeom.push(geom[i]);\n newGeom.push(geom[i + 1]);\n newGeom.push(geom[i + 2]);\n }\n }\n}\n\nfunction clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {\n\n var slice = newSlice(geom);\n var intersect = axis === 0 ? intersectX : intersectY;\n var len = geom.start;\n var segLen, t;\n\n for (var i = 0; i < geom.length - 3; i += 3) {\n var ax = geom[i];\n var ay = geom[i + 1];\n var az = geom[i + 2];\n var bx = geom[i + 3];\n var by = geom[i + 4];\n var a = axis === 0 ? ax : ay;\n var b = axis === 0 ? bx : by;\n var exited = false;\n\n if (trackMetrics) segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n\n if (a < k1) {\n // ---|--> | (line enters the clip region from the left)\n if (b > k1) {\n t = intersect(slice, ax, ay, bx, by, k1);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else if (a > k2) {\n // | <--|--- (line enters the clip region from the right)\n if (b < k2) {\n t = intersect(slice, ax, ay, bx, by, k2);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else {\n addPoint(slice, ax, ay, az);\n }\n if (b < k1 && a >= k1) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, k1);\n exited = true;\n }\n if (b > k2 && a <= k2) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, k2);\n exited = true;\n }\n\n if (!isPolygon && exited) {\n if (trackMetrics) slice.end = len + segLen * t;\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n\n if (trackMetrics) len += segLen;\n }\n\n // add the last point\n var last = geom.length - 3;\n ax = geom[last];\n ay = geom[last + 1];\n az = geom[last + 2];\n a = axis === 0 ? ax : ay;\n if (a >= k1 && a <= k2) addPoint(slice, ax, ay, az);\n\n // close the polygon if its endpoints are not the same after clipping\n last = slice.length - 3;\n if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {\n addPoint(slice, slice[0], slice[1], slice[2]);\n }\n\n // add the final slice\n if (slice.length) {\n newGeom.push(slice);\n }\n}\n\nfunction newSlice(line) {\n var slice = [];\n slice.size = line.size;\n slice.start = line.start;\n slice.end = line.end;\n return slice;\n}\n\nfunction clipLines(geom, newGeom, k1, k2, axis, isPolygon) {\n for (var i = 0; i < geom.length; i++) {\n clipLine(geom[i], newGeom, k1, k2, axis, isPolygon, false);\n }\n}\n\nfunction addPoint(out, x, y, z) {\n out.push(x);\n out.push(y);\n out.push(z);\n}\n\nfunction intersectX(out, ax, ay, bx, by, x) {\n var t = (x - ax) / (bx - ax);\n out.push(x);\n out.push(ay + (by - ay) * t);\n out.push(1);\n return t;\n}\n\nfunction intersectY(out, ax, ay, bx, by, y) {\n var t = (y - ay) / (by - ay);\n out.push(ax + (bx - ax) * t);\n out.push(y);\n out.push(1);\n return t;\n}\n","\nimport clip from './clip';\nimport createFeature from './feature';\n\nexport default function wrap(features, options) {\n var buffer = options.buffer / options.extent;\n var merged = features;\n var left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy\n var right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy\n\n if (left || right) {\n merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy\n\n if (left) merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n if (right) merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n }\n\n return merged;\n}\n\nfunction shiftFeatureCoords(features, offset) {\n var newFeatures = [];\n\n for (var i = 0; i < features.length; i++) {\n var feature = features[i],\n type = feature.type;\n\n var newGeometry;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n newGeometry = shiftCoords(feature.geometry, offset);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n newGeometry = [];\n for (var j = 0; j < feature.geometry.length; j++) {\n newGeometry.push(shiftCoords(feature.geometry[j], offset));\n }\n } else if (type === 'MultiPolygon') {\n newGeometry = [];\n for (j = 0; j < feature.geometry.length; j++) {\n var newPolygon = [];\n for (var k = 0; k < feature.geometry[j].length; k++) {\n newPolygon.push(shiftCoords(feature.geometry[j][k], offset));\n }\n newGeometry.push(newPolygon);\n }\n }\n\n newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n\n return newFeatures;\n}\n\nfunction shiftCoords(points, offset) {\n var newPoints = [];\n newPoints.size = points.size;\n\n if (points.start !== undefined) {\n newPoints.start = points.start;\n newPoints.end = points.end;\n }\n\n for (var i = 0; i < points.length; i += 3) {\n newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);\n }\n return newPoints;\n}\n","\n// Transforms the coordinates of each feature in the given tile from\n// mercator-projected space into (extent x extent) tile space.\nexport default function transformTile(tile, extent) {\n if (tile.transformed) return tile;\n\n var z2 = 1 << tile.z,\n tx = tile.x,\n ty = tile.y,\n i, j, k;\n\n for (i = 0; i < tile.features.length; i++) {\n var feature = tile.features[i],\n geom = feature.geometry,\n type = feature.type;\n\n feature.geometry = [];\n\n if (type === 1) {\n for (j = 0; j < geom.length; j += 2) {\n feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));\n }\n } else {\n for (j = 0; j < geom.length; j++) {\n var ring = [];\n for (k = 0; k < geom[j].length; k += 2) {\n ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));\n }\n feature.geometry.push(ring);\n }\n }\n }\n\n tile.transformed = true;\n\n return tile;\n}\n\nfunction transformPoint(x, y, extent, z2, tx, ty) {\n return [\n Math.round(extent * (x * z2 - tx)),\n Math.round(extent * (y * z2 - ty))];\n}\n","\nexport default function createTile(features, z, tx, ty, options) {\n var tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n var tile = {\n features: [],\n numPoints: 0,\n numSimplified: 0,\n numFeatures: 0,\n source: null,\n x: tx,\n y: ty,\n z: z,\n transformed: false,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0\n };\n for (var i = 0; i < features.length; i++) {\n tile.numFeatures++;\n addFeature(tile, features[i], tolerance, options);\n\n var minX = features[i].minX;\n var minY = features[i].minY;\n var maxX = features[i].maxX;\n var maxY = features[i].maxY;\n\n if (minX < tile.minX) tile.minX = minX;\n if (minY < tile.minY) tile.minY = minY;\n if (maxX > tile.maxX) tile.maxX = maxX;\n if (maxY > tile.maxY) tile.maxY = maxY;\n }\n return tile;\n}\n\nfunction addFeature(tile, feature, tolerance, options) {\n\n var geom = feature.geometry,\n type = feature.type,\n simplified = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n for (var i = 0; i < geom.length; i += 3) {\n simplified.push(geom[i]);\n simplified.push(geom[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n\n } else if (type === 'LineString') {\n addLine(simplified, geom, tile, tolerance, false, false);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n for (i = 0; i < geom.length; i++) {\n addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);\n }\n\n } else if (type === 'MultiPolygon') {\n\n for (var k = 0; k < geom.length; k++) {\n var polygon = geom[k];\n for (i = 0; i < polygon.length; i++) {\n addLine(simplified, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n }\n\n if (simplified.length) {\n var tags = feature.tags || null;\n if (type === 'LineString' && options.lineMetrics) {\n tags = {};\n for (var key in feature.tags) tags[key] = feature.tags[key];\n tags['mapbox_clip_start'] = geom.start / geom.size;\n tags['mapbox_clip_end'] = geom.end / geom.size;\n }\n var tileFeature = {\n geometry: simplified,\n type: type === 'Polygon' || type === 'MultiPolygon' ? 3 :\n type === 'LineString' || type === 'MultiLineString' ? 2 : 1,\n tags: tags\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n }\n}\n\nfunction addLine(result, geom, tile, tolerance, isPolygon, isOuter) {\n var sqTolerance = tolerance * tolerance;\n\n if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) {\n tile.numPoints += geom.length / 3;\n return;\n }\n\n var ring = [];\n\n for (var i = 0; i < geom.length; i += 3) {\n if (tolerance === 0 || geom[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom[i]);\n ring.push(geom[i + 1]);\n }\n tile.numPoints++;\n }\n\n if (isPolygon) rewind(ring, isOuter);\n\n result.push(ring);\n}\n\nfunction rewind(ring, clockwise) {\n var area = 0;\n for (var i = 0, len = ring.length, j = len - 2; i < len; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n if (area > 0 === clockwise) {\n for (i = 0, len = ring.length; i < len / 2; i += 2) {\n var x = ring[i];\n var y = ring[i + 1];\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n }\n}\n","\nimport convert from './convert'; // GeoJSON conversion and preprocessing\nimport clip from './clip'; // stripe clipping algorithm\nimport wrap from './wrap'; // date line processing\nimport transform from './transform'; // coordinate transformation\nimport createTile from './tile'; // final simplified tile generation\n\nexport default function geojsonvt(data, options) {\n return new GeoJSONVT(data, options);\n}\n\nfunction GeoJSONVT(data, options) {\n options = this.options = extend(Object.create(this.options), options);\n\n var debug = options.debug;\n\n if (debug) console.time('preprocess data');\n\n if (options.maxZoom < 0 || options.maxZoom > 24) throw new Error('maxZoom should be in the 0-24 range');\n if (options.promoteId && options.generateId) throw new Error('promoteId and generateId cannot be used together.');\n\n var features = convert(data, options);\n\n this.tiles = {};\n this.tileCoords = [];\n\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n this.stats = {};\n this.total = 0;\n }\n\n features = wrap(features, options);\n\n // start slicing from the top tile down\n if (features.length) this.splitTile(features, 0, 0, 0);\n\n if (debug) {\n if (features.length) console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n}\n\nGeoJSONVT.prototype.options = {\n maxZoom: 14, // max zoom to preserve detail on\n indexMaxZoom: 5, // max zoom in the tile index\n indexMaxPoints: 100000, // max number of points per tile in the tile index\n tolerance: 3, // simplification tolerance (higher means simpler)\n extent: 4096, // tile extent\n buffer: 64, // tile buffer on each side\n lineMetrics: false, // whether to calculate line metrics\n promoteId: null, // name of a feature property to be promoted to feature.id\n generateId: false, // whether to generate feature ids. Cannot be used with promoteId\n debug: 0 // logging level (0, 1 or 2)\n};\n\nGeoJSONVT.prototype.splitTile = function (features, z, x, y, cz, cx, cy) {\n\n var stack = [features, z, x, y],\n options = this.options,\n debug = options.debug;\n\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop();\n x = stack.pop();\n z = stack.pop();\n features = stack.pop();\n\n var z2 = 1 << z,\n id = toID(z, x, y),\n tile = this.tiles[id];\n\n if (!tile) {\n if (debug > 1) console.time('creation');\n\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({z: z, x: x, y: y});\n\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)',\n z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n var key = 'z' + z;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n\n // if it's the first-pass tiling\n if (!cz) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;\n\n // if a drilldown to a specific tile\n } else {\n // stop tiling if we reached base zoom or our target tile zoom\n if (z === options.maxZoom || z === cz) continue;\n\n // stop tiling if it's not an ancestor of the target tile\n var m = 1 << (cz - z);\n if (x !== Math.floor(cx / m) || y !== Math.floor(cy / m)) continue;\n }\n\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n\n if (features.length === 0) continue;\n\n if (debug > 1) console.time('clipping');\n\n // values we'll use for clipping\n var k1 = 0.5 * options.buffer / options.extent,\n k2 = 0.5 - k1,\n k3 = 0.5 + k1,\n k4 = 1 + k1,\n tl, bl, tr, br, left, right;\n\n tl = bl = tr = br = null;\n\n left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);\n right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);\n features = null;\n\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n left = null;\n }\n\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n right = null;\n }\n\n if (debug > 1) console.timeEnd('clipping');\n\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n};\n\nGeoJSONVT.prototype.getTile = function (z, x, y) {\n var options = this.options,\n extent = options.extent,\n debug = options.debug;\n\n if (z < 0 || z > 24) return null;\n\n var z2 = 1 << z;\n x = ((x % z2) + z2) % z2; // wrap tile x coordinate\n\n var id = toID(z, x, y);\n if (this.tiles[id]) return transform(this.tiles[id], extent);\n\n if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y);\n\n var z0 = z,\n x0 = x,\n y0 = y,\n parent;\n\n while (!parent && z0 > 0) {\n z0--;\n x0 = Math.floor(x0 / 2);\n y0 = Math.floor(y0 / 2);\n parent = this.tiles[toID(z0, x0, y0)];\n }\n\n if (!parent || !parent.source) return null;\n\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n\n if (debug > 1) console.time('drilling down');\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) console.timeEnd('drilling down');\n\n return this.tiles[id] ? transform(this.tiles[id], extent) : null;\n};\n\nfunction toID(z, x, y) {\n return (((1 << z) * y + x) * 32) + z;\n}\n\nfunction extend(dest, src) {\n for (var i in src) dest[i] = src[i];\n return dest;\n}\n","/**\n * A way to indentify a feature, either by string or by number\n */\nexport type GeoJSONFeatureId = number | string;\n\n/**\n * The geojson source diff object\n */\nexport type GeoJSONSourceDiff = {\n /**\n * When set to `true` it will remove all features\n */\n removeAll?: boolean;\n /**\n * An array of features IDs to remove\n */\n remove?: Array;\n /**\n * An array of features to add\n */\n add?: Array;\n /**\n * An array of update objects\n */\n update?: Array;\n}\n\n/**\n * A geojson feature diff object\n */\nexport type GeoJSONFeatureDiff = {\n /**\n * The feature ID\n */\n id: GeoJSONFeatureId;\n /**\n * If it's a new geometry, place it here\n */\n newGeometry?: GeoJSON.Geometry;\n /**\n * Setting to `true` will remove all preperties\n */\n removeAllProperties?: boolean;\n /**\n * The properties keys to remove\n */\n removeProperties?: Array;\n /**\n * The properties to add or update along side their values\n */\n addOrUpdateProperties?: Array<{key: string; value: any}>;\n}\n\nexport type UpdateableGeoJSON = GeoJSON.Feature | GeoJSON.FeatureCollection | undefined;\n\nfunction getFeatureId(feature: GeoJSON.Feature, promoteId?: string): GeoJSONFeatureId | undefined {\n return promoteId ? feature.properties[promoteId] : feature.id;\n}\n\nexport function isUpdateableGeoJSON(data: GeoJSON.GeoJSON | undefined, promoteId?: string): data is UpdateableGeoJSON {\n // null can be updated\n if (data == null) {\n return true;\n }\n\n // a single feature with an id can be updated, need to explicitly check against null because 0 is a valid feature id that is falsy\n if (data.type === 'Feature') {\n return getFeatureId(data, promoteId) != null;\n }\n\n // a feature collection can be updated if every feature has an id, and the ids are all unique\n // this prevents us from silently dropping features if ids get reused\n if (data.type === 'FeatureCollection') {\n const seenIds = new Set();\n for (const feature of data.features) {\n const id = getFeatureId(feature, promoteId);\n if (id == null) {\n return false;\n }\n\n if (seenIds.has(id)) {\n return false;\n }\n\n seenIds.add(id);\n }\n\n return true;\n }\n\n return false;\n}\n\nexport function toUpdateable(data: UpdateableGeoJSON, promoteId?: string) {\n const result = new Map();\n if (data == null) {\n // empty result\n } else if (data.type === 'Feature') {\n result.set(getFeatureId(data, promoteId)!, data);\n } else {\n for (const feature of data.features) {\n result.set(getFeatureId(feature, promoteId)!, feature);\n }\n }\n\n return result;\n}\n\n// mutates updateable\nexport function applySourceDiff(updateable: Map, diff: GeoJSONSourceDiff, promoteId?: string): void {\n if (diff.removeAll) {\n updateable.clear();\n }\n\n if (diff.remove) {\n for (const id of diff.remove) {\n updateable.delete(id);\n }\n }\n\n if (diff.add) {\n for (const feature of diff.add) {\n const id = getFeatureId(feature, promoteId);\n\n if (id != null) {\n updateable.set(id, feature);\n }\n }\n }\n\n if (diff.update) {\n for (const update of diff.update) {\n let feature = updateable.get(update.id);\n\n if (feature == null) {\n continue;\n }\n\n // be careful to clone the feature and/or properties objects to avoid mutating our input\n const cloneFeature = update.newGeometry || update.removeAllProperties;\n // note: removeAllProperties gives us a new properties object, so we can skip the clone step\n const cloneProperties = !update.removeAllProperties && (update.removeProperties?.length > 0 || update.addOrUpdateProperties?.length > 0);\n if (cloneFeature || cloneProperties) {\n feature = {...feature};\n updateable.set(update.id, feature);\n if (cloneProperties) {\n feature.properties = {...feature.properties};\n }\n }\n\n if (update.newGeometry) {\n feature.geometry = update.newGeometry;\n }\n\n if (update.removeAllProperties) {\n feature.properties = {};\n } else if (update.removeProperties?.length > 0) {\n for (const prop of update.removeProperties) {\n if (Object.prototype.hasOwnProperty.call(feature.properties, prop)) {\n delete feature.properties[prop];\n }\n }\n }\n\n if (update.addOrUpdateProperties?.length > 0) {\n for (const {key, value} of update.addOrUpdateProperties) {\n feature.properties[key] = value;\n }\n }\n }\n }\n}\n","import {getJSON} from '../util/ajax';\n\nimport {RequestPerformance} from '../util/performance';\nimport rewind from '@mapbox/geojson-rewind';\nimport {GeoJSONWrapper} from './geojson_wrapper';\nimport vtpbf from 'vt-pbf';\nimport Supercluster, {type Options as SuperclusterOptions, type ClusterProperties} from 'supercluster';\nimport geojsonvt, {type Options as GeoJSONVTOptions} from 'geojson-vt';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source';\nimport {createExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {\n WorkerTileParameters,\n WorkerTileCallback,\n} from '../source/worker_source';\n\nimport type {Actor} from '../util/actor';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\n\nimport type {LoadVectorDataCallback} from './vector_tile_worker_source';\nimport type {RequestParameters, ResponseCallback} from '../util/ajax';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport {isUpdateableGeoJSON, type GeoJSONSourceDiff, applySourceDiff, toUpdateable, GeoJSONFeatureId} from './geojson_source_diff';\n\nexport type LoadGeoJSONParameters = {\n request?: RequestParameters;\n /**\n * Literal GeoJSON data. Must be provided if `request.url` is not.\n */\n data?: string;\n dataDiff?: GeoJSONSourceDiff;\n source: string;\n cluster: boolean;\n superclusterOptions?: SuperclusterOptions;\n geojsonVtOptions?: GeoJSONVTOptions;\n clusterProperties?: ClusterProperties;\n filter?: Array;\n promoteId?: string;\n};\n\nexport type LoadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback) => Cancelable;\n\ntype GeoJSONIndex = ReturnType | Supercluster;\n\n/**\n * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory GeoJSON\n * representation. To do so, create it with\n * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.\n * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).\n */\nexport class GeoJSONWorkerSource extends VectorTileWorkerSource {\n _pendingCallback: Callback<{\n resourceTiming?: {[_: string]: Array};\n abandoned?: boolean;\n }>;\n _pendingRequest: Cancelable;\n _geoJSONIndex: GeoJSONIndex;\n _dataUpdateable = new Map();\n\n /**\n * @param loadGeoJSON - Optional method for custom loading/parsing of\n * GeoJSON based on parameters passed from the main-thread Source.\n * See {@link GeoJSONWorkerSource#loadGeoJSON}.\n */\n constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadGeoJSON?: LoadGeoJSON | null) {\n super(actor, layerIndex, availableImages);\n this.loadVectorData = this.loadGeoJSONTile;\n if (loadGeoJSON) {\n this.loadGeoJSON = loadGeoJSON;\n }\n }\n\n loadGeoJSONTile(params: WorkerTileParameters, callback: LoadVectorDataCallback): (() => void) | void {\n const canonical = params.tileID.canonical;\n\n if (!this._geoJSONIndex) {\n return callback(null, null); // we couldn't load the file\n }\n\n const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);\n if (!geoJSONTile) {\n return callback(null, null); // nothing in the given tile\n }\n\n const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features);\n // Encode the geojson-vt tile into binary vector tile form. This\n // is a convenience that allows `FeatureIndex` to operate the same way\n // across `VectorTileSource` and `GeoJSONSource` data.\n let pbf = vtpbf(geojsonWrapper);\n if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {\n // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)\n pbf = new Uint8Array(pbf);\n }\n\n callback(null, {\n vectorTile: geojsonWrapper,\n rawData: pbf.buffer\n });\n }\n\n /**\n * Fetches (if appropriate), parses, and index geojson data into tiles. This\n * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}\n * can correctly serve up tiles.\n *\n * Defers to {@link GeoJSONWorkerSource#loadGeoJSON} for the fetching/parsing,\n * expecting `callback(error, data)` to be called with either an error or a\n * parsed GeoJSON object.\n *\n * When a `loadData` request comes in while a previous one is being processed,\n * the previous one is aborted.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n */\n loadData(params: LoadGeoJSONParameters, callback: Callback<{\n resourceTiming?: {[_: string]: Array};\n abandoned?: boolean;\n }>) {\n this._pendingRequest?.cancel();\n if (this._pendingCallback) {\n // Tell the foreground the previous call has been abandoned\n this._pendingCallback(null, {abandoned: true});\n }\n\n const perf = (params && params.request && params.request.collectResourceTiming) ?\n new RequestPerformance(params.request) : false;\n\n this._pendingCallback = callback;\n this._pendingRequest = this.loadGeoJSON(params, (err?: Error | null, data?: any | null) => {\n delete this._pendingCallback;\n delete this._pendingRequest;\n\n if (err || !data) {\n return callback(err);\n } else if (typeof data !== 'object') {\n return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n } else {\n rewind(data, true);\n\n try {\n if (params.filter) {\n const compiled = createExpression(params.filter, {type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false} as any);\n if (compiled.result === 'error')\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n\n const features = data.features.filter(feature => compiled.value.evaluate({zoom: 0}, feature));\n data = {type: 'FeatureCollection', features};\n }\n\n this._geoJSONIndex = params.cluster ?\n new Supercluster(getSuperclusterOptions(params)).load(data.features) :\n geojsonvt(data, params.geojsonVtOptions);\n } catch (err) {\n return callback(err);\n }\n\n this.loaded = {};\n\n const result = {} as { resourceTiming: any };\n if (perf) {\n const resourceTimingData = perf.finish();\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n if (resourceTimingData) {\n result.resourceTiming = {};\n result.resourceTiming[params.source] = JSON.parse(JSON.stringify(resourceTimingData));\n }\n }\n callback(null, result);\n }\n });\n }\n\n /**\n * Implements {@link WorkerSource#reloadTile}.\n *\n * If the tile is loaded, uses the implementation in VectorTileWorkerSource.\n * Otherwise, such as after a setData() call, we load the tile fresh.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n */\n reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded,\n uid = params.uid;\n\n if (loaded && loaded[uid]) {\n return super.reloadTile(params, callback);\n } else {\n return this.loadTile(params, callback);\n }\n }\n\n /**\n * Fetch and parse GeoJSON according to the given params. Calls `callback`\n * with `(err, data)`, where `data` is a parsed GeoJSON object.\n *\n * GeoJSON is loaded and parsed from `params.url` if it exists, or else\n * expected as a literal (string or object) `params.data`.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n * @returns A Cancelable object.\n */\n loadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback): Cancelable => {\n const {promoteId} = params;\n // Because of same origin issues, urls must either include an explicit\n // origin or absolute path.\n // ie: /foo/bar.json or http://example.com/bar.json\n // but not ../foo/bar.json\n if (params.request) {\n return getJSON(params.request, (\n error?: Error,\n data?: any,\n cacheControl?: string,\n expires?: string\n ) => {\n this._dataUpdateable = isUpdateableGeoJSON(data, promoteId) ? toUpdateable(data, promoteId) : undefined;\n callback(error, data, cacheControl, expires);\n });\n } else if (typeof params.data === 'string') {\n try {\n const parsed = JSON.parse(params.data);\n this._dataUpdateable = isUpdateableGeoJSON(parsed, promoteId) ? toUpdateable(parsed, promoteId) : undefined;\n callback(null, parsed);\n } catch (e) {\n callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n }\n } else if (params.dataDiff) {\n if (this._dataUpdateable) {\n applySourceDiff(this._dataUpdateable, params.dataDiff, promoteId);\n callback(null, {type: 'FeatureCollection', features: Array.from(this._dataUpdateable.values())});\n } else {\n callback(new Error(`Cannot update existing geojson data in ${params.source}`));\n }\n } else {\n callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n }\n\n return {cancel: () => {}};\n };\n\n removeSource(params: {\n source: string;\n }, callback: WorkerTileCallback) {\n if (this._pendingCallback) {\n // Don't leak callbacks\n this._pendingCallback(null, {abandoned: true});\n }\n callback();\n }\n\n getClusterExpansionZoom(params: {\n clusterId: number;\n }, callback: Callback) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getClusterExpansionZoom(params.clusterId));\n } catch (e) {\n callback(e);\n }\n }\n\n getClusterChildren(params: {\n clusterId: number;\n }, callback: Callback>) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getChildren(params.clusterId));\n } catch (e) {\n callback(e);\n }\n }\n\n getClusterLeaves(params: {\n clusterId: number;\n limit: number;\n offset: number;\n }, callback: Callback>) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getLeaves(params.clusterId, params.limit, params.offset));\n } catch (e) {\n callback(e);\n }\n }\n}\n\nfunction getSuperclusterOptions({superclusterOptions, clusterProperties}: LoadGeoJSONParameters) {\n if (!clusterProperties || !superclusterOptions) return superclusterOptions;\n\n const mapExpressions = {};\n const reduceExpressions = {};\n const globals = {accumulated: null, zoom: 0};\n const feature = {properties: null};\n const propertyNames = Object.keys(clusterProperties);\n\n for (const key of propertyNames) {\n const [operator, mapExpression] = clusterProperties[key];\n\n const mapExpressionParsed = createExpression(mapExpression);\n const reduceExpressionParsed = createExpression(\n typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator);\n\n mapExpressions[key] = mapExpressionParsed.value;\n reduceExpressions[key] = reduceExpressionParsed.value;\n }\n\n superclusterOptions.map = (pointProperties) => {\n feature.properties = pointProperties;\n const properties = {};\n for (const key of propertyNames) {\n properties[key] = mapExpressions[key].evaluate(globals, feature);\n }\n return properties;\n };\n superclusterOptions.reduce = (accumulated, clusterProperties) => {\n feature.properties = clusterProperties;\n for (const key of propertyNames) {\n globals.accumulated = accumulated[key];\n accumulated[key] = reduceExpressions[key].evaluate(globals, feature);\n }\n };\n\n return superclusterOptions;\n}\n","import {Actor, ActorTarget} from '../util/actor';\nimport {StyleLayerIndex} from '../style/style_layer_index';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source';\nimport {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source';\nimport {GeoJSONWorkerSource} from './geojson_worker_source';\nimport {plugin as globalRTLTextPlugin} from './rtl_text_plugin';\nimport {isWorker} from '../util/util';\n\nimport type {\n WorkerSource,\n WorkerTileParameters,\n WorkerDEMTileParameters,\n WorkerTileCallback,\n WorkerDEMTileCallback,\n TileParameters\n} from '../source/worker_source';\n\nimport type {WorkerGlobalScopeInterface} from '../util/web_worker';\nimport type {Callback} from '../types/callback';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {PluginState} from './rtl_text_plugin';\n\n/**\n * The Worker class responsidble for background thread related execution\n */\nexport default class Worker {\n self: WorkerGlobalScopeInterface & ActorTarget;\n actor: Actor;\n layerIndexes: {[_: string]: StyleLayerIndex};\n availableImages: {[_: string]: Array};\n workerSourceTypes: {\n [_: string]: {\n new (...args: any): WorkerSource;\n };\n };\n workerSources: {\n [_: string]: {\n [_: string]: {\n [_: string]: WorkerSource;\n };\n };\n };\n demWorkerSources: {\n [_: string]: {\n [_: string]: RasterDEMTileWorkerSource;\n };\n };\n referrer: string;\n\n constructor(self: WorkerGlobalScopeInterface & ActorTarget) {\n this.self = self;\n this.actor = new Actor(self, this);\n\n this.layerIndexes = {};\n this.availableImages = {};\n\n this.workerSourceTypes = {\n vector: VectorTileWorkerSource,\n geojson: GeoJSONWorkerSource\n };\n\n // [mapId][sourceType][sourceName] => worker source instance\n this.workerSources = {};\n this.demWorkerSources = {};\n\n this.self.registerWorkerSource = (name: string, WorkerSource: {\n new (...args: any): WorkerSource;\n }) => {\n if (this.workerSourceTypes[name]) {\n throw new Error(`Worker source with name \"${name}\" already registered.`);\n }\n this.workerSourceTypes[name] = WorkerSource;\n };\n\n // This is invoked by the RTL text plugin when the download via the `importScripts` call has finished, and the code has been parsed.\n this.self.registerRTLTextPlugin = (rtlTextPlugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText?: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n }) => {\n if (globalRTLTextPlugin.isParsed()) {\n throw new Error('RTL text plugin already registered.');\n }\n globalRTLTextPlugin['applyArabicShaping'] = rtlTextPlugin.applyArabicShaping;\n globalRTLTextPlugin['processBidirectionalText'] = rtlTextPlugin.processBidirectionalText;\n globalRTLTextPlugin['processStyledBidirectionalText'] = rtlTextPlugin.processStyledBidirectionalText;\n };\n }\n\n setReferrer(mapID: string, referrer: string) {\n this.referrer = referrer;\n }\n\n setImages(mapId: string, images: Array, callback: WorkerTileCallback) {\n this.availableImages[mapId] = images;\n for (const workerSource in this.workerSources[mapId]) {\n const ws = this.workerSources[mapId][workerSource];\n for (const source in ws) {\n ws[source].availableImages = images;\n }\n }\n callback();\n }\n\n setLayers(mapId: string, layers: Array, callback: WorkerTileCallback) {\n this.getLayerIndex(mapId).replace(layers);\n callback();\n }\n\n updateLayers(mapId: string, params: {\n layers: Array;\n removedIds: Array;\n }, callback: WorkerTileCallback) {\n this.getLayerIndex(mapId).update(params.layers, params.removedIds);\n callback();\n }\n\n loadTile(mapId: string, params: WorkerTileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).loadTile(params, callback);\n }\n\n loadDEMTile(mapId: string, params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) {\n this.getDEMWorkerSource(mapId, params.source).loadTile(params, callback);\n }\n\n reloadTile(mapId: string, params: WorkerTileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).reloadTile(params, callback);\n }\n\n abortTile(mapId: string, params: TileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).abortTile(params, callback);\n }\n\n removeTile(mapId: string, params: TileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).removeTile(params, callback);\n }\n\n removeDEMTile(mapId: string, params: TileParameters) {\n this.getDEMWorkerSource(mapId, params.source).removeTile(params);\n }\n\n removeSource(mapId: string, params: {\n source: string;\n } & {\n type: string;\n }, callback: WorkerTileCallback) {\n\n if (!this.workerSources[mapId] ||\n !this.workerSources[mapId][params.type] ||\n !this.workerSources[mapId][params.type][params.source]) {\n return;\n }\n\n const worker = this.workerSources[mapId][params.type][params.source];\n delete this.workerSources[mapId][params.type][params.source];\n\n if (worker.removeSource !== undefined) {\n worker.removeSource(params, callback);\n } else {\n callback();\n }\n }\n\n /**\n * Load a {@link WorkerSource} script at params.url. The script is run\n * (using importScripts) with `registerWorkerSource` in scope, which is a\n * function taking `(name, workerSourceObject)`.\n */\n loadWorkerSource(map: string, params: {\n url: string;\n }, callback: Callback) {\n try {\n this.self.importScripts(params.url);\n callback();\n } catch (e) {\n callback(e.toString());\n }\n }\n\n syncRTLPluginState(map: string, state: PluginState, callback: Callback) {\n try {\n globalRTLTextPlugin.setState(state);\n const pluginURL = globalRTLTextPlugin.getPluginURL();\n if (\n globalRTLTextPlugin.isLoaded() &&\n !globalRTLTextPlugin.isParsed() &&\n pluginURL != null // Not possible when `isLoaded` is true, but keeps flow happy\n ) {\n this.self.importScripts(pluginURL);\n const complete = globalRTLTextPlugin.isParsed();\n const error = complete ? undefined : new Error(`RTL Text Plugin failed to import scripts from ${pluginURL}`);\n callback(error, complete);\n }\n } catch (e) {\n callback(e.toString());\n }\n }\n\n getAvailableImages(mapId: string) {\n let availableImages = this.availableImages[mapId];\n\n if (!availableImages) {\n availableImages = [];\n }\n\n return availableImages;\n }\n\n getLayerIndex(mapId: string) {\n let layerIndexes = this.layerIndexes[mapId];\n if (!layerIndexes) {\n layerIndexes = this.layerIndexes[mapId] = new StyleLayerIndex();\n }\n return layerIndexes;\n }\n\n getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource {\n if (!this.workerSources[mapId])\n this.workerSources[mapId] = {};\n if (!this.workerSources[mapId][sourceType])\n this.workerSources[mapId][sourceType] = {};\n\n if (!this.workerSources[mapId][sourceType][sourceName]) {\n // use a wrapped actor so that we can attach a target mapId param\n // to any messages invoked by the WorkerSource\n const actor = {\n send: (type, data, callback) => {\n this.actor.send(type, data, callback, mapId);\n }\n };\n this.workerSources[mapId][sourceType][sourceName] = new (this.workerSourceTypes[sourceType] as any)((actor as any), this.getLayerIndex(mapId), this.getAvailableImages(mapId));\n }\n\n return this.workerSources[mapId][sourceType][sourceName];\n }\n\n getDEMWorkerSource(mapId: string, source: string) {\n if (!this.demWorkerSources[mapId])\n this.demWorkerSources[mapId] = {};\n\n if (!this.demWorkerSources[mapId][source]) {\n this.demWorkerSources[mapId][source] = new RasterDEMTileWorkerSource();\n }\n\n return this.demWorkerSources[mapId][source];\n }\n}\n\nif (isWorker()) {\n (self as any).worker = new Worker(self as any);\n}\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","pointGeometry","Point","x","y","this","prototype","clone","add","p","_add","sub","_sub","multByPoint","_multByPoint","divByPoint","_divByPoint","mult","k","_mult","div","_div","rotate","a","_rotate","rotateAround","_rotateAround","matMult","m","_matMult","unit","_unit","perp","_perp","round","_round","mag","Math","sqrt","equals","other","dist","distSqr","dx","dy","angle","atan2","angleTo","b","angleWith","angleWithSep","cos","sin","convert","Array","isArray","unitbezier","UnitBezier","p1x","p1y","p2x","p2y","cx","bx","ax","cy","by","ay","sampleCurveX","t","sampleCurveY","sampleCurveDerivativeX","solveCurveX","epsilon","undefined","i","x2","abs","d2","t0","t1","solve","supportsOffscreenCanvas","offscreenCanvasDistorted","clamp","n","min","max","extend","dest","sources","src","mapObject","input","iterator","context","output","key","call","map","warnOnceHistory","warnOnce","message","console","warn","isCounterClockwise","c","calculateSignedArea","ring","sum","p1","p2","len","length","j","isWorker","WorkerGlobalScope","self","isImageBitmap","image","ImageBitmap","offscreenCanvas","offscreenCanvasContext","TransferableGridIndex","constructor","extent","padding","cells","ArrayBuffer","arrayBuffer","array","Int32Array","d","start","end","push","subarray","bboxesOffset","keys","bboxes","insert","_insertReadonly","scale","uid","x1","y1","y2","_forEachCell","_insertCell","Error","cellIndex","query","intersectionTest","slice","_queryCell","seenUids","cell","u","offset","fn","arg1","arg2","cx1","_convertToCellCoord","cy1","cx2","cy2","_convertFromCellCoord","floor","toArrayBuffer","metadataLength","totalCellLength","set","buffer","static","grid","transferables","serialized","v8Spec","$version","$root","version","required","type","values","name","metadata","center","zoom","bearing","default","period","units","pitch","light","terrain","sprite","glyphs","transition","layers","source","source_vector","vector","url","tiles","bounds","scheme","xyz","tms","minzoom","maxzoom","attribution","promoteId","volatile","source_raster","raster","tileSize","source_raster_dem","encoding","terrarium","mapbox","custom","redFactor","blueFactor","greenFactor","baseShift","source_geojson","geojson","data","maximum","minimum","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","source_video","video","urls","coordinates","source_image","layer","id","fill","line","symbol","circle","heatmap","hillshade","background","layout","paint","layout_background","visibility","visible","none","layout_fill","expression","interpolated","parameters","layout_circle","layout_heatmap","layout_line","butt","square","bevel","miter","requires","layout_symbol","point","auto","never","always","cooperative","viewport","width","height","both","tokens","left","right","top","bottom","horizontal","vertical","uppercase","lowercase","layout_raster","layout_hillshade","filter_operator","in","all","any","has","within","geometry_type","LineString","Polygon","function","stops","base","property","identity","exponential","interval","categorical","colorSpace","rgb","lab","hcl","function_stop","anchor","position","color","intensity","exaggeration","paint_fill","paint_line","paint_circle","paint_heatmap","paint_symbol","overridable","paint_raster","linear","nearest","paint_hillshade","paint_background","duration","delay","constant","refProperties","ValidationError","identifier","__line__","extendBy","inputs","ExpressionParsingError","super","Scope","parent","bindings","concat","get","NullType","kind","NumberType","StringType","BooleanType","ColorType","ObjectType","ValueType","CollatorType","FormattedType","PaddingType","ResolvedImageType","VariableAnchorOffsetCollectionType","array$1","itemType","N","toString$1","valueMemberTypes","checkSubtype","expected","memberType","isValidType","provided","allowedTypes","some","isValidNativeType","verifyType","sample","Xn","Zn","t2","t3","deg2rad","PI","rad2deg","constrainAngle","rgbToLab","r","g","alpha","z","xyz2lab","rgb2xyz","l","pow","labToRgb","isNaN","lab2xyz","xyz2rgb","parseHex","hex","parseInt","padEnd","parseAlpha","asPercentage","validateNumbers","Number","namedColors","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","Color","premultiplied","overwriteGetter","rgba","toLowerCase","trim","namedColorsMatch","startsWith","test","rgbMatch","match","_","rp","f1","gp","f2","bp","f3","ap","argFormat","join","valFormat","maxValue","hslMatch","h","s","hsla","f","hslToRgb","parseCssColor","Infinity","rgbColor","NaN","rgbToHcl","getterKey","lazyValue","Object","defineProperty","toString","transparent","Collator","caseSensitive","diacriticSensitive","locale","sensitivity","collator","Intl","usage","compare","lhs","rhs","resolvedLocale","resolvedOptions","FormattedSection","text","fontStack","textColor","Formatted","sections","unformatted","isEmpty","section","fromString","Padding","val","JSON","stringify","anchors","Set","VariableAnchorOffsetCollection","anchorValue","offsetValue","ResolvedImage","options","available","validateRGBA","isValue","mixed","item","typeOf","String","Literal","args","error","expectedType","evaluate","eachChild","outputDefined","RuntimeError","toJSON","types$1","string","number","boolean","object","Assertion","parsed","parse","ctx","forEach","every","arg","types","Coercion","Boolean","parseColor","pad","coll","num","geometryTypes","EvaluationContext","globals","feature","featureState","formattedSection","_parseColorCache","availableImages","canonical","geometryType","geometry","canonicalID","properties","cached","ParsingContext","registry","isConstantFunc","path","scope","errors","part","_isConstant","expr","index","_parse","annotate","typeAnnotation","op","Expr","actual","ec","CollatorExpression","EXTENT","updateBBox","bbox","coord","boxWithinBox","bbox1","bbox2","getTileCoordinates","log","tilesAtZoom","onBoundary","pointWithinPolygon","rings","inside","len2","pointWithinPolygons","polygons","twoSided","q1","q2","x3","y3","det1","det2","lineIntersectPolygon","polygon","v1","v2","lineStringWithinPolygon","lineStringWithinPolygons","getTilePolygon","getTilePolygons","updatePoint","polyBBox","worldSize","halfWorldSize","shift","getTilePoints","pointBBox","shifts","tilePoints","points","getTileLines","lineBBox","tileLines","tileLine","Within","geometries","features","polygonGeometry","tilePolygon","tilePolygons","pointsWithinPolygons","linesWithinPolygons","Var","boundExpression","CompoundExpression","_evaluate","definition","definitions","availableOverloads","overloads","signature","signatureContext","params","isExpressionConstant","parsedArgs","argParseFailed","signatures","stringifySignature","actualTypes","isTypeAnnotation","childrenConstant","child","isFeatureConstant","isGlobalPropertyConstant","isStateConstant","indexOf","findStopLessThanOrEqualTo","lastIndex","currentValue","nextValue","lowerIndex","upperIndex","currentIndex","Step","labels","outputs","label","outputType","labelKey","valueKey","stopCount","out","from","to","interpolate","spaceKey","hue0","chroma0","light0","alphaF","hue1","chroma1","light1","alphaT","hue","chroma","dh","hclToRgb","variableAnchorOffsetCollection","fromValues","toValues","fx","fy","tx","ty","Interpolate","operator","interpolation","lower","upper","exponentialInterpolation","controlPoints","rest","interpolationFactor","outputLower","outputUpper","lowerValue","upperValue","difference","progress","Coalesce","needsAnnotation","requestedImageName","argCount","Let","binding","At","In","needle","haystack","IndexOf","fromIndex","Match","inputType","cases","otherwise","labelContext","MAX_SAFE_INTEGER","Case","branches","Slice","beginIndex","endIndex","isComparableType","eqCollate","makeComparison","compareBasic","compareWithCollator","isOrderComparison","Comparison","hasUntypedArgument","lt","rt","Equals","NotEquals","LessThan","GreaterThan","LessThanOrEqual","GreaterThanOrEqual","NumberFormat","currency","minFractionDigits","maxFractionDigits","style","minimumFractionDigits","maximumFractionDigits","format","FormatExpression","firstArg","nextTokenMayBeObject","font","lastExpression","content","evaluatedContent","ImageExpression","evaluatedImageName","Length","expressions","at","case","coalesce","let","literal","var","obj","v","varargs","success","supportsPropertyExpression","spec","supportsZoomExpression","supportsInterpolation","getType","isFunction","identityFunction","createFunction","propertySpec","isColor","zoomAndFeatureDependent","zoomDependent","parseFn","stop","innerFun","hashedStops","categoricalKeyType","evaluateExponentialFunction","evaluateIntervalFunction","evaluateCategoricalFunction","create","evaluateIdentityFunction","featureFunctions","zoomStops","featureFunctionStops","interpolationType","bind","coalesce$1","keyType","interp","evaluatedLower","evaluatedUpper","register","typeof","heatmapDensity","lineProgress","accumulated","ln2","LN2","pi","E","log10","LN10","ln","log2","asin","acos","atan","ceil","binarySearch","isSupportedScript","upcase","toUpperCase","downcase","StyleExpression","_warningHistory","_evaluator","_defaultValue","_enumValues","evaluateWithoutErrorHandling","isExpression","createExpression","parser","enum","formatted","resolvedImage","getExpectedType","ZoomConstantExpression","_styleExpression","isStateDependent","ZoomDependentExpression","createPropertyExpression","expressionInput","isFeatureConstantResult","isZoomConstant","zoomCurve","findZoomCurve","StylePropertyFunction","specification","_parameters","_specification","childResult","isExpressionFilter","filterSpec","createFilter","needGeometry","convertFilter$1","compiled","err","globalProperties","geometryNeeded","convertComparisonOp$1","convertNegation","filters","convertInOp$1","convertHasOp$1","sort","str","getKey","validateConstants","constants","unbundle","valueOf","deepUnbundle","unbundledValue","validateObject","elementSpecs","valueSpec","elementValidators","objectElementValidators","styleSpec","validateSpec","objectKey","elementSpecKey","split","elementSpec","validateElement","validateArray","arraySpec","validateArrayElement","arrayElementValidator","arrayElementSpec","arrayIndex","validateNumber","validateFunction","functionValueSpec","functionType","stopKeyType","previousStopDomainValue","previousStopDomainZoom","stopDomainValues","isZoomFunction","isPropertyFunction","isZoomAndPropertyFunction","validateFunctionStop","validateStopDomainValue","reportValue","isFinite","validateExpression","expressionContext","expressionObj","propertyKey","propertyType","validateEnum","validateFilter","validateNonExpressionFilter","validateProperty","layerSpec","layerType","transitionMatch","tokenMatch","exec","validatePaintProperty","validateLayoutProperty","validateLayer","ref","layerId","otherLayer","sourceType","validateString","prop","validateSource","replace","_a","sourceName","rasterDEM","rasterDEMSpec","rootType","isCustomEncoding","customEncodingKeys","encodingName","includes","validateRasterDEMSource","mapExpr","reduceExpr","validateLight","lightSpec","validateTerrain","terrainSpec","validateSprite","allSpriteIds","allSpriteURLs","VALIDATORS","validate","validateGlyphsUrl","validateStyleMin","sortErrors","injectValidateSpec","validator","wrapCleanErrors","inner","paintProperty","layoutProperty","config","AJAXError","status","statusText","body","getReferrer","worker","referrer","window","location","protocol","href","makeFetchRequest","requestParameters","callback","controller","AbortController","request","Request","method","credentials","headers","cache","signal","complete","aborted","fetch","response","ok","json","catch","finishRequest","blob","code","cancel","abort","makeRequest","actor","send","substring","isFileURL","hasOwnProperty","xhr","XMLHttpRequest","open","responseType","setRequestHeader","withCredentials","onerror","onload","getResponseHeader","Blob","makeXMLHttpRequest","klass","writeable","omit","shallow","_classRegistryKey","isArrayBuffer","serialize","Date","RegExp","isView","view","ImageData","$name","deserialize","ThrottledInvoker","_callback","_triggered","MessageChannel","_channel","port2","onmessage","trigger","port1","postMessage","setTimeout","remove","Actor","target","mapId","receive","targetMapId","tasks","cancelCallbacks","mustQueue","taskQueue","invoker","processTask","process","task","callbacks","addEventListener","globalScope","random","buffers","hasCallback","sourceMapId","transfer","completed","responseMessage","getWorkerSource","removeEventListener","_addEventListener","listener","listenerList","_removeEventListener","splice","Event","ErrorEvent","Evented","on","_listeners","off","_oneTimeListeners","once","fire","event","listens","listeners","oneTimeListeners","_eventedParent","_eventedParentData","setEventedParent","validateStyle","ZoomHistory","first","update","now","floorZ","lastIntegerZoom","lastIntegerZoomTime","lastZoom","lastFloorZoom","unicodeBlockLookup","char","Arabic","Khmer","Hiragana","Katakana","Bopomofo","Kanbun","allowsVerticalWritingMode","chars","charHasUprightVerticalOrientation","charCodeAt","allowsLetterSpacing","charAllowsLetterSpacing","isChar","charHasRotatedVerticalOrientation","charHasNeutralVerticalOrientation","charInRTLScript","charInSupportedScript","canRenderRTL","stringContainsRTLText","performance","pluginStatus","pluginURL","plugin","applyArabicShaping","processBidirectionalText","processStyledBidirectionalText","isLoaded","isLoading","setState","state","isParsed","getPluginURL","EvaluationParameters","fadeDuration","zoomHistory","isStringInSupportedScript","rtlTextPlugin","crossFadingFactor","getCrossfadeParameters","fraction","fromScale","toScale","PropertyValue","normalizePropertyExpression","isDataDriven","possiblyEvaluate","TransitionablePropertyValue","transitioned","prior","TransitioningPropertyValue","untransitioned","Transitionable","_properties","_values","defaultTransitionablePropertyValues","getValue","setValue","getTransition","setTransition","Transitioning","begin","finalValue","easeCubicInOut","defaultTransitioningPropertyValues","PossiblyEvaluated","hasTransition","Layout","defaultPropertyValues","hasValue","PossiblyEvaluatedPropertyValue","isConstant","constantOr","defaultPossiblyEvaluatedValues","DataConstantProperty","interpolationFn","interpolates","DataDrivenProperty","overrides","interpolatedValue","CrossFadedDataDrivenProperty","evaluatedValue","constantValue","_calculate","cameraVal","mid","CrossFadedProperty","ColorRampProperty","Properties","overridableProperties","defaultPropertyValue","defaultTransitionablePropertyValue","TRANSITION_SUFFIX","StyleLayer","_featureFilter","sourceLayer","_unevaluatedLayout","_transitionablePaint","setPaintProperty","setLayoutProperty","_transitioningPaint","_crossfadeParameters","getLayoutProperty","_validate","getPaintProperty","endsWith","transitionable","isCrossFadedProperty","wasDataDriven","oldValue","_handleSpecialPaintPropertyUpdate","newValue","_handleOverridablePaintPropertyUpdate","isHidden","updateTransitions","recalculate","filterObject","emitter","hasErrors","emitValidationErrors","is3D","isTileClipped","hasOffscreenPass","resize","viewTypes","Int8","Int8Array","Uint8","Uint8Array","Int16","Int16Array","Uint16","Uint16Array","Int32","Uint32","Uint32Array","Float32","Float32Array","Struct","structArray","_structArray","_pos1","size","_pos2","_pos4","_pos8","StructArray","isTransferred","capacity","_trim","byteLength","bytesPerElement","_refreshViews","clear","reserve","oldUint8Array","uint8","createLayout","members","alignment","maxSize","member","typeSize","BYTES_PER_ELEMENT","memberOffset","align","components","StructArrayLayout2i4","int16","emplaceBack","v0","emplace","o2","StructArrayLayout3i6","StructArrayLayout4i8","v3","StructArrayLayout2i4i12","v4","v5","StructArrayLayout2i4ub8","o1","StructArrayLayout2f8","float32","o4","StructArrayLayout10ui20","uint16","v6","v7","v8","v9","StructArrayLayout4i4ui4i24","v10","v11","StructArrayLayout3f12","StructArrayLayout1ul4","uint32","StructArrayLayout6i1ul2ui20","StructArrayLayout2i2i2i12","StructArrayLayout2f1f2i16","StructArrayLayout2ub2f12","StructArrayLayout3ui6","StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48","v12","v13","v14","v15","v16","StructArrayLayout8i15ui1ul2f2ui64","v17","v18","v19","v20","v21","v22","v23","v24","v25","v26","v27","StructArrayLayout1f4","StructArrayLayout1ui2f12","StructArrayLayout1ul2ui8","StructArrayLayout2ui4","StructArrayLayout1ui2","StructArrayLayout4f16","CollisionBoxStruct","anchorPointX","anchorPointY","featureIndex","sourceLayerIndex","bucketIndex","anchorPoint","CollisionBoxArray","PlacedSymbolStruct","anchorX","anchorY","glyphStartIndex","numGlyphs","vertexStartIndex","lineStartIndex","lineLength","segment","lowerSize","upperSize","lineOffsetX","lineOffsetY","writingMode","placedOrientation","hidden","crossTileID","associatedIconIndex","PlacedSymbolArray","SymbolInstanceStruct","rightJustifiedTextSymbolIndex","centerJustifiedTextSymbolIndex","leftJustifiedTextSymbolIndex","verticalPlacedTextSymbolIndex","placedIconSymbolIndex","verticalPlacedIconSymbolIndex","textBoxStartIndex","textBoxEndIndex","verticalTextBoxStartIndex","verticalTextBoxEndIndex","iconBoxStartIndex","iconBoxEndIndex","verticalIconBoxStartIndex","verticalIconBoxEndIndex","numHorizontalGlyphVertices","numVerticalGlyphVertices","numIconVertices","numVerticalIconVertices","useRuntimeCollisionCircles","textBoxScale","collisionCircleDiameter","textAnchorOffsetStartIndex","textAnchorOffsetEndIndex","SymbolInstanceArray","GlyphOffsetArray","getoffsetX","SymbolLineVertexArray","getx","gety","gettileUnitDistanceFromAnchor","TextAnchorOffsetStruct","textAnchor","textOffset0","textOffset1","TextAnchorOffsetArray","FeatureIndexStruct","FeatureIndexArray","PosArray","CircleLayoutArray","FillLayoutArray","FillExtrusionLayoutArray","LineLayoutArray","LineExtLayoutArray","PatternLayoutArray","SymbolLayoutArray","SymbolDynamicLayoutArray","SymbolOpacityArray","CollisionBoxLayoutArray","CollisionVertexArray","TriangleIndexArray","LineIndexArray","SegmentVector","segments","prepareSegment","numVertices","layoutVertexArray","indexArray","sortKey","MAX_VERTEX_ARRAY_LENGTH","vertexLength","vertexOffset","primitiveOffset","primitiveLength","destroy","vaos","packUint8ToFloat","patternAttributes","seed","remainder","bytes","h1","h1b","c1","c2","k1","murmur3","require$$0","murmur2","murmurhashJsModule","exports","FeaturePositionMap","ids","positions","indexed","getNumericId","getPositions","intId","Float64Array","numValue","pivot","swap","arr","tmp","Uniform","gl","Uniform1f","current","uniform1f","Uniform4f","uniform4f","UniformColor","packColor","ConstantBinder","names","uniformNames","setUniform","uniform","getBinding","CrossFadedConstantBinder","patternFrom","patternTo","pixelRatioFrom","pixelRatioTo","setConstantPatternPositions","posTo","posFrom","pixelRatio","tlbr","uniformName","pos","substr","SourceExpressionBinder","PaintVertexArray","paintVertexAttributes","paintVertexArray","populatePaintArray","newLength","imagePositions","_setPaintValue","updatePaintArray","upload","paintVertexBuffer","updateData","createVertexBuffer","CompositeExpressionBinder","useIntegerZoom","minColor","maxColor","currentZoom","factor","CrossFadedCompositeBinder","zoomInPaintVertexArray","zoomOutPaintVertexArray","_setPaintValues","patterns","imageMin","imageMid","imageMax","tl","br","zoomInPaintVertexBuffer","zoomOutPaintVertexBuffer","ProgramConfiguration","filterProperties","binders","_buffers","paintAttributeNames","propType","isCrossFaded","StructArrayLayout","layoutType","cacheKey","getMaxValue","binder","populatePaintArrays","updatePaintArrays","featureStates","featureMap","vtLayer","dirty","defines","getBinderAttributes","getBinderUniforms","uniforms","getPaintVertexBuffers","getUniforms","locations","setUniforms","binderUniforms","updatePaintBuffers","crossfade","patternVertexBuffer","ProgramConfigurationSet","programConfigurations","needsUpload","_featureMap","_bufferOffset","binderType","defaultLayouts","composite","layoutException","getLayoutException","MAX","BITS","MIN","loadGeometry","toEvaluationFeature","addCircleVertex","extrudeX","extrudeY","CircleBucket","overscaling","layerIds","hasPattern","stateDependentLayerIds","populate","styleLayer","bucketFeatures","circleSortKey","sortFeaturesByKey","evaluationFeature","bucketFeature","addFeature","states","stateDependentLayers","uploadPending","uploaded","layoutVertexBuffer","layoutAttributes","indexBuffer","createIndexBuffer","polygonIntersectsPolygon","polygonA","polygonB","polygonContainsPoint","lineIntersectsLine","polygonIntersectsBufferedPoint","radius","pointIntersectsBufferedLine","polygonIntersectsMultiPolygon","multiPolygon","multiPolygonContainsPoint","lineIntersectsBufferedLine","lineA","lineB","a0","a1","lineSegmentIntersectsLineSegment","b0","b1","radiusSquared","distToSegmentSquared","w","l2","edgeIntersectsBox","e1","e2","corners","dir","getMaximumPaintValue","bucket","translateDistance","translate","queryGeometry","translateAnchor","pixelsToTileUnits","pt","translated","properties$8","ARRAY_TYPE","transformMat4","hypot","arguments","glMatrix.ARRAY_TYPE","CircleStyleLayer","createBucket","queryRadius","circleBucket","queryIntersectsFeature","transform","pixelPosMatrix","translatedPolygon","alignWithMap","transformedPolygon","projectPoint","projectQueryGeometry","transformedSize","transformedPoint","adjustedSize","projectedCenter","vec4.transformMat4","cameraToCenterDistance","HeatmapBucket","properties$7","createImage","channels","Uint8ClampedArray","RangeError","resizeImage","newImage","copyImage","srcImg","dstImg","srcPt","dstPt","srcData","dstData","srcOffset","dstOffset","AlphaImage","RGBAImage","copy","HeatmapStyleLayer","_updateColorRamp","colorRamp","evaluationGlobals","resolution","clips","renderPixel","stride","evaluationKey","pxColor","clip","renderColorRamp","colorRampTexture","heatmapFbo","properties$6","HillshadeStyleLayer","earcut","holeIndices","dim","minX","minY","maxX","maxY","invSize","hasHoles","outerLen","outerNode","linkedList","triangles","prev","list","queue","steiner","getLeftmost","compareX","eliminateHole","eliminateHoles","earcutLinked","clockwise","last","signedArea","insertNode","removeNode","filterPoints","again","area","ear","pass","zOrder","prevZ","nextZ","q","tail","numMerges","pSize","qSize","inSize","sortLinked","indexCurve","isEarHashed","isEar","cureLocalIntersections","splitEarcut","x0","y0","pointInTriangle","minZ","maxZ","intersects","locallyInside","isValidDiagonal","splitPolygon","hole","bridge","hx","hy","qx","mx","my","tanMin","sectorContainsSector","findHoleBridge","bridgeReverse","leftmost","px","py","intersectsPolygon","middleInside","sign","o3","onSegment","a2","Node","b2","an","earcutModule","deviation","polygonArea","trianglesArea","flatten","vertices","holes","dimensions","holeIndex","quickselect","quickselectStep","defaultCompare","exp","sd","classifyRings","maxRings","ccw","compareAreas","patternDependencies","patternProperty","constantPattern","addPatternDependencies","patternFeature","patternPropertyValue","FillBucket","patternFeatures","indexArray2","segments2","fillSortKey","addFeatures","indexBuffer2","triangleSegment","triangleIndex","flattened","lineSegment","lineIndex","indices","properties$5","FillStyleLayer","outlineColor","centroidAttributes","vectortilefeature","VectorTileFeature","pbf","_pbf","_geometry","_keys","readFields","readFeature","tag","readVarint","readTag","cmd","lines","cmdLen","readSVarint","toGeoJSON","coords","project","vectortilelayer","VectorTileLayer","_features","readLayer","readString","readFloat","readDouble","readVarint64","readBoolean","readValueMessage","readTile","vectorTile","VectorTile","require$$1","require$$2","vectorTileFeatureTypes","mvt","FACTOR","addVertex","vertexArray","nx","ny","nz","FillExtrusionBucket","centroidVertexArray","centroidVertexBuffer","centroid","vertexCount","isEntirelyOutside","edgeDistance","isBoundaryEdge","bottomRight","properties$4","FillExtrusionStyleLayer","projectedQueryGeometry","projected","zBase","zTop","projectedBase","projectedTop","baseXZ","baseYZ","baseZZ","baseWZ","topXZ","topYZ","topZZ","topWZ","ringBase","ringTop","sX","sY","sZ","sW","baseZ","baseW","topX","topY","topZ","topW","projectExtrusion","closestDistance","getIntersectionDistance","topA","face","checkIntersection","dot","projectedFace","ab","ac","dotABAB","dotABAC","dotACAC","dotAPAB","dotAPAC","denom","distance","lineLayoutAttributes","lineLayoutAttributesExt","COS_HALF_SHARP_CORNER","MAX_LINE_DISTANCE","LINE_DISTANCE_BUFFER_BITS","LineBucket","lineClipsArray","gradients","layoutVertexArray2","maxLineLength","lineSortKey","patternBucketFeature","layoutVertexBuffer2","layoutAttributesExt","lineFeatureClips","cap","miterLimit","roundLimit","lineClips","addLine","scaledDistance","totalDistance","updateScaledDistance","isPolygon","sharpCornerOffset","currentVertex","prevVertex","nextVertex","prevNormal","nextNormal","joinNormal","cosAngle","cosHalfAngle","miterLength","approxAngle","isSharpCorner","lineTurnsLeft","prevSegmentLength","newPrevVertex","updateDistance","addCurrentVertex","middleVertex","currentJoin","bevelLength","offsetA","offsetB","extrude","addHalfVertex","nextSegmentLength","newCurrentVertex","normal","endLeft","endRight","rightX","rightY","up","linesofarScaled","properties$3","LineFloorwidthProperty","lineFloorwidthProperty","LineStyleLayer","gradientVersion","gradientExpression","stepInterpolant","isZoomExpression","lineBucket","getLineWidth","halfWidth","lineOffset","newRings","ringIndex","newRing","aToB","bToC","offsetLine","multiLine","polygonIntersectsBufferedMultiLine","lineWidth","lineGapWidth","symbolLayoutAttributes","dynamicLayoutAttributes","collisionVertexAttributes","collisionBoxLayout","transformText","toLocaleUpperCase","toLocaleLowerCase","transformTextInternal","verticalizedCharacterMap","$","ONE_EM","Pbf","ieee754","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","buf","Varint","Fixed64","Bytes","Fixed32","SHIFT_LEFT_32","SHIFT_RIGHT_32","utf8TextDecoder","TextDecoder","readPackedEnd","toNum","low","high","isSigned","makeRoomForExtraLength","startPos","extraLen","realloc","writePackedVarint","writeVarint","writePackedSVarint","writeSVarint","writePackedFloat","writeFloat","writePackedDouble","writeDouble","writePackedBoolean","writeBoolean","writePackedFixed32","writeFixed32","writePackedSFixed32","writeSFixed32","writePackedFixed64","writeFixed64","writePackedSFixed64","writeSFixed64","readUInt32","writeInt32","readInt32","readField","skip","readMessage","readFixed32","readSFixed32","readFixed64","readSFixed64","readVarintRemainder","decode","readUtf8TextDecoder","b3","bytesPerSequence","fromCharCode","readUtf8","readBytes","readPackedVarint","readPackedSVarint","readPackedBoolean","readPackedFloat","readPackedDouble","readPackedFixed32","readPackedSFixed32","readPackedFixed64","readPackedSFixed64","writeTag","finish","writeBigVarintLow","lsb","writeBigVarintHigh","writeBigVarint","writeString","lead","writeUtf8","writeBytes","writeRawMessage","writeMessage","writeBytesField","writeFixed32Field","writeSFixed32Field","writeFixed64Field","writeSFixed64Field","writeVarintField","writeSVarintField","writeStringField","writeFloatField","writeDoubleField","writeBooleanField","GLYPH_PBF_BORDER","potpack","boxes","maxWidth","box","spaces","space","pop","IMAGE_PADDING","ImagePosition","paddedRect","stretchX","stretchY","displaySize","ImageAtlas","icons","iconPositions","patternPositions","haveRenderCallbacks","bins","addImages","bin","images","hasRenderCallback","patchUpdatedImages","imageManager","texture","dispatchRenderCallbacks","updatedImages","patchUpdatedImage","getImage","WritingMode","SHAPING_DEFAULT_OFFSET","SectionOptions","imageName","textOptions","imageOptions","TaggedString","sectionIndex","imageSectionID","defaultFontStack","addImageSection","addTextSection","getSection","getSectionIndex","getCharCode","verticalizePunctuation","nextCharCode","prevCharCode","beginningWhitespace","whitespace","trailingWhitespace","getMaxScale","reduce","forText","nextImageSectionCharCode","getNextImageSectionCharCode","forImage","shapeText","glyphMap","glyphPositions","lineHeight","textJustify","spacing","allowVerticalPlacement","symbolPlacement","layoutTextSize","layoutTextSizeThisZoom","logicalInput","fromFeature","untaggedLines","determineLineBreaks","taggedLine","processedLines","lineBreakPoints","lineBreak","breakLines","positionedLines","shaping","iconsInText","verticalizable","maxLineHeight","justify","lineMaxScale","maxLineOffset","positionedLine","positionedGlyphs","codePoint","baselineOffset","metrics","rect","verticalAdvance","imagePosition","advance","glyphPosition","glyph","justifyLine","currentLineHeight","horizontalAlign","verticalAlign","getAnchorAlignment","blockHeight","lineCount","shiftX","shiftY","positionedGlyph","shapeLines","breakable","getGlyphAdvance","calculateBadness","targetWidth","penalty","isLastBreak","raggedness","calculatePenalty","nextCodePoint","penalizableIdeographicBreak","evaluateBreak","breakIndex","breakX","potentialBreaks","bestPriorBreak","bestBreakBadness","potentialBreak","breakBadness","badness","priorBreak","leastBadBreaks","lastLineBreak","potentialLineBreaks","totalWidth","determineAverageLineWidth","hasServerSuggestedBreakpoints","currentX","ideographicBreak","lastPositionedGlyph","lineIndent","shapeIcon","iconOffset","iconAnchor","fitIconToText","shapedIcon","shapedText","textFit","fontScale","collisionPadding","textLeft","textRight","textTop","textBottom","MAX_GLYPH_ICON_SIZE","SIZE_PACK_FACTOR","MAX_PACKED_SIZE","getSizeData","tileZoom","layoutSize","minZoom","maxZoom","minSize","getOverlapMode","overlapProp","allowOverlapProp","overlap","shaderOpacityAttributes","ox","oy","sizeVertex","isSDF","pixelOffsetX","pixelOffsetY","minFontScaleX","minFontScaleY","aSizeX","aSizeY","addDynamicAttributes","dynamicLayoutVertexArray","containsRTLText","formattedText","SymbolBuffers","opacityVertexArray","hasVisibleVertices","placedSymbolArray","dynamicIndexBuffer","dynamicLayoutVertexBuffer","opacityVertexBuffer","itemSize","CollisionBuffers","LayoutArray","IndexArray","collisionVertexArray","collisionVertexBuffer","SymbolBucket","collisionBoxArray","hasRTLText","sortKeyRanges","collisionCircleArray","placementInvProjMatrix","mat4.identity","placementViewportMatrix","unevaluatedLayoutValues","textSizeData","iconSizeData","canOverlap","sortFeaturesByY","writingModes","wm","sourceID","createArrays","icon","glyphOffsetArray","lineVertexArray","symbolInstances","textAnchorOffsets","calculateGlyphDependencies","stack","textAlongLine","doesAllowVerticalWritingMode","verticalChar","charAt","textFont","textField","iconImage","hasText","hasIcon","symbolSortKey","iconDependencies","stacks","glyphDependencies","resolvedTokens","getValueAndResolveTokens","factory","globalRTLTextPlugin","sectionFont","sectionStack","leftIndex","rightIndex","mergedFeatures","mergedIndex","mergeFromRight","leftKey","rightKey","geom","mergeFromLeft","onRight","mergeLines","hasDebugData","textCollisionBox","iconCollisionBox","destroyDebugData","addToLineVertexArray","sumForwardLength","sumBackwardLength","tileUnitDistanceFromAnchor","vertex","addSymbols","arrays","quads","alongLine","labelAnchor","glyphOffsetArrayStart","tr","bl","tex","pixelOffsetTL","pixelOffsetBR","glyphOffset","_addCollisionDebugVertex","addCollisionDebugVertices","boxAnchorPoint","symbolInstance","addDebugCollisionBoxes","startIndex","isText","generateCollisionDebugBuffers","_deserializeCollisionBoxesForSymbol","textStartIndex","textEndIndex","verticalTextStartIndex","verticalTextEndIndex","iconStartIndex","iconEndIndex","verticalIconStartIndex","verticalIconEndIndex","collisionArrays","textBox","textFeatureIndex","verticalTextBox","verticalTextFeatureIndex","iconBox","iconFeatureIndex","verticalIconBox","verticalIconFeatureIndex","deserializeCollisionBoxes","hasTextData","hasIconData","hasTextCollisionBoxData","hasIconCollisionBoxData","addIndicesForPlacedSymbol","iconOrText","placedSymbolIndex","placedSymbol","vertexIndex","getSortedSymbolIndexes","sortedAngle","symbolInstanceIndexes","rotatedYs","featureIndexes","aIndex","bIndex","addToSortKeyRanges","symbolInstanceIndex","symbolInstanceEnd","symbolInstanceStart","sortFeatures","featureSortOrder","MAX_GLYPHS","properties$2","runtimeType","getOverride","o","hasOverride","FormatSectionOverride","defaultValue","SymbolStyleLayer","deduped","_setPaintOverrides","unevaluated","resolveTokens","hasPaintOverride","overriden","override","styleExpression","propertyName","hasOverrides","checkSections","checkExpression","properties$1","BackgroundStyleLayer","RasterStyleLayer","CustomStyleLayer","implementation","onAdd","painter","onRemove","renderingMode","prerender","createStyleLayer","StyleLayerIndex","layerConfigs","keyCache","_layerConfigs","_layers","removedIds","layerConfig","featureFilter","familiesBySource","groups","cachedKeys","group","groupByLayout","sourceId","sourceGroup","sourceLayerId","sourceLayerFamilies","DictionaryCoder","strings","_stringToNumber","_numberToString","encode","GeoJSONFeature","vectorTileFeature","_vectorTileFeature","_z","_x","_y","FeatureIndex","tileID","grid3D","featureIndexArray","loadVTLayers","vtLayers","vt","Protobuf","rawTileData","sourceLayerCoder","styleLayers","serializedLayers","sourceFeatureState","queryPadding","getBounds","matching","cameraBounds","cameraQueryGeometry","matching3D","bx1","by1","bx2","by2","boxX1","boxY1","boxX2","boxY2","corner","polygonIntersectsBox","topDownFeatureComparator","previousIndex","featureGeometry","loadMatchingFeature","filterLayerIDs","layerIDs","bucketLayerIDs","arraysIntersect","sourceLayerName","overscaledZ","getId","layerID","getState","serializedLayer","evaluateProperties","intersectionZ","geojsonFeature","layerResult","lookupSymbolFeatures","symbolFeatureIndexes","symbolFeatureIndex","hasLayer","serializedProperties","styleLayerProperties","Anchor","checkMaxAngle","labelLength","windowSize","maxAngle","anchorDistance","recentCorners","recentAngleDelta","angleDelta","getLineLength","getAngleWindowSize","glyphSize","boxScale","getShapedLabelLength","getCenterAnchor","angleWindowSize","prevDistance","centerDistance","segmentDistance","getAnchors","tileExtent","shapedLabelLength","isLineContinued","resample","placeAtMiddle","halfLabelLength","markedDistance","segmentDist","border","getIconQuads","iconRotate","isSDFIcon","hasIconTextFit","imageWidth","imageHeight","iconWidth","iconHeight","reduceRanges","range","stretchWidth","stretchHeight","fixedWidth","fixedHeight","stretchOffsetX","stretchContentWidth","stretchOffsetY","stretchContentHeight","fixedOffsetX","fixedContentWidth","fixedOffsetY","fixedContentHeight","sumWithinRange","makeBox","leftEm","getEmOffset","stretch","leftPx","getPxOffset","fixed","topEm","topPx","rightEm","rightPx","bottomEm","bottomPx","matrix","xCuts","stretchZonesToCuts","yCuts","xi","yi","ranges","stretchZones","fixedSize","stretchSize","cuts","stretchOffset","iconSize","fixedOffset","CollisionFeature","shaped","alignLine","boxStartIndex","circleDiameter","rotateRadians","boxEndIndex","TinyQueue","_down","_up","peek","halfLength","best","findPoleOfInaccessibility","polygonRings","precision","debug","outerRing","cellSize","cellQueue","Queue","compareMax","Cell","bestCell","getCentroidCell","numProbes","minDistSq","pointToPolygonDist","SQRT2","TextAnchorEnum","INVALID_TEXT_OFFSET","POSITIVE_INFINITY","evaluateVariableOffset","offsetX","offsetY","fromTextOffset","radialOffset","hypotenuse","fromRadialOffset","getTextVariableAnchorOffset","variableAnchorOffset","sourceValues","destValues","variableAnchor","textOffset","anchorOffsets","performSymbolLayout","tilePixelRatio","compareText","iconsNeedLinear","sizes","layoutIconSize","textMaxSize","compositeTextSizes","compositeIconSizes","keepUpright","textSize","fontstack","shapedTextOrientations","unformattedText","spacingIfAllowed","addVerticalShapingForPointLabelIfNeeded","justifications","getAnchorJustification","singleLine","justification","imageMap","sdf","sdfIcons","getDefaultHorizontalShaping","showCollisionBoxes","defaultHorizontalShaping","textMaxBoxScale","iconBoxScale","symbolMinDistance","textPadding","iconPadding","getIconPadding","textMaxAngle","iconAlongLine","textRepeatDistance","iconTextFit","verticallyShapedIcon","addSymbolAtAnchor","lineArray","textCollisionFeature","iconCollisionFeature","verticalTextCollisionFeature","verticalIconCollisionFeature","placedTextSymbolIndices","verticalTextRotation","iconQuads","verticalIconQuads","sizeData","textRotate","addTextVertices","horizontalOnly","getCollisionCircleHeight","prevHeight","addTextVariableAnchorOffsets","addSymbol","clippedLines","clippedLine","p0","clipLine","anchorIsTooClose","poi","placementTypes","placedIconIndex","glyphQuads","textureRect","rectBuffer","rotateVerticalGlyph","halfAdvance","builtInOffset","verticalizedLabelOffset","textureScale","isDoubleResolution","verticalRotation","xHalfWidthOffsetCorrection","halfWidthOffsetCorrection","verticalOffsetCorrection","getGlyphQuads","placementType","horizontalShaping","repeatDistance","otherAnchors","GlyphAtlas","stackPositions","bitmap","getMercCoords","earthRadius","LngLat","lng","lat","wrap","toArray","distanceTo","lngLat","rad","lat1","lat2","lon","earthCircumfrence","circumferenceAtLatitude","latitude","latFromMercatorY","MercatorCoordinate","lngLatLike","altitude","mercatorZfromAltitude","toLngLat","toAltitude","meterInMercatorCoordinateUnits","CanonicalTileID","calculateKey","quadkey","mask","getQuadkey","isChildOf","dz","getTilePoint","UnwrappedTileID","OverscaledTileID","scaledTo","targetZ","zDifference","calculateScaledKey","withWrap","children","sourceMaxZoom","isLessThan","wrapped","unwrapTo","overscaleFactor","toUnwrapped","WorkerTile","collectResourceTiming","returnDependencies","inFlightDependencies","dependencySentinel","layerIndex","buckets","layerFamilies","family","recalculateLayers","iconMap","patternMap","maybePrepare","glyphAtlas","imageAtlas","glyphAtlasImage","PerformanceMarkers","RequestPerformance","_marks","measure","mark","resourceTimingData","getEntriesByName","clearMarks","clearMeasures","loadVectorTile","getArrayBuffer","cacheControl","expires","rawData","ex","errorMessage","messge","VectorTileWorkerSource","loadVectorData","fetching","loading","loaded","loadTile","perf","workerTile","resourceTiming","reloadTile","parseResult","abortTile","removeTile","DEMData","_idx","MIN_SAFE_INTEGER","ele","pixels","unpack","getUnpackVector","getPixels","backfillBorder","borderTile","xMin","xMax","yMin","yMax","RasterDEMTileWorkerSource","rawImageData","imagePixels","OffscreenCanvas","getContext","createImageBitmap","willReadFrequently","fillStyle","fillRect","getImageData","isOffscreenCanvasDistorted","VideoFrame","frame","timestamp","swapBR","copyTo","destRowOffset","sourceLeft","sourceTop","computeVideoFrameParameters","close","readImageUsingVideoFrame","imgBitmap","origWidth","origHeight","drawImage","imgData","clearRect","readImageDataUsingOffscreenCanvas","dem","rewindRings","outer","rewindRing","reverse","rewind","gj","geojson_wrapper","GeoJSONWrapper","FeatureWrapper","rawGeometry","tags","fromVectorTileJs","tile","writeLayer","writeTile","keycache","valuecache","writeFeature","writeValue","writeProperties","writeGeometry","keyIndex","valueIndex","command","zigzag","count","vtPbfModule","fromGeojsonVt","ARRAY_TYPES","KDBush","magic","versionAndType","ArrayType","nodeSize","numItems","IndexArrayType","arrayTypeIndex","coordsByteSize","idsByteSize","padCoords","_pos","_finished","numAdded","axis","qy","r2","sqDist","select","swapItem","defaultOptions","minPoints","props","fround","OFFSET_ID","OFFSET_NUM","OFFSET_PROP","Supercluster","assign","trees","clusterProps","load","time","timerId","lngX","latY","tree","_createTree","timeEnd","_cluster","getClusters","minLng","minLat","maxLng","maxLat","easternHem","westernHem","_limitZoom","clusters","getClusterJSON","getChildren","clusterId","originId","_getOriginId","originZoom","_getOriginZoom","errorMsg","getLeaves","limit","leaves","_appendLeaves","getTile","z2","_addTileFeatures","getClusterExpansionZoom","expansionZoom","cluster_id","skipped","point_count","isCluster","getClusterProperties","nextData","neighborIds","numPointsOrigin","numPoints","neighborId","wx","wy","clusterPropIndex","numPoints2","_map","original","yLat","abbrev","propIndex","point_count_abbreviated","simplify","sqTolerance","maxSqDist","minPosToMid","getSqSegDist","posToMid","createFeature","calcLineBBox","calcBBox","convertFeature","convertPoint","convertLine","convertLines","projectX","projectY","k2","minAll","maxAll","clipped","newGeometry","clipPoints","clipLines","newGeom","trackMetrics","segLen","newSlice","intersect","intersectX","intersectY","az","exited","addPoint","shiftFeatureCoords","newFeatures","shiftCoords","newPolygon","newPoints","transformTile","transformed","transformPoint","createTile","numSimplified","numFeatures","simplified","tileFeature","isOuter","GeoJSONVT","tileCoords","indexMaxZoom","indexMaxPoints","stats","total","merged","splitTile","toID","getFeatureId","isUpdateableGeoJSON","seenIds","toUpdateable","Map","cz","k3","k4","z0","GeoJSONWorkerSource","loadGeoJSON","_dataUpdateable","getJSON","dataDiff","updateable","diff","removeAll","delete","cloneProperties","removeAllProperties","removeProperties","_b","addOrUpdateProperties","_c","_d","applySourceDiff","loadGeoJSONTile","_geoJSONIndex","geoJSONTile","geojsonWrapper","_geojsonTileLayer","_feature","vtpbf","byteOffset","loadData","_pendingRequest","_pendingCallback","abandoned","superclusterOptions","mapExpressions","reduceExpressions","propertyNames","mapExpression","mapExpressionParsed","reduceExpressionParsed","pointProperties","getSuperclusterOptions","geojsonvt","geojsonVtOptions","removeSource","getClusterChildren","getClusterLeaves","Worker","layerIndexes","workerSourceTypes","workerSources","demWorkerSources","registerWorkerSource","WorkerSource","registerRTLTextPlugin","setReferrer","mapID","setImages","workerSource","ws","setLayers","getLayerIndex","updateLayers","loadDEMTile","getDEMWorkerSource","removeDEMTile","loadWorkerSource","importScripts","syncRTLPluginState","getAvailableImages"],"mappings":"uCAkHO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,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B,CACV,CAEDj9D,gBAAgBrB,EAAepH,EAAoBM,GAiB/C,OAhBK7hC,KAAKmnG,cAAcx+D,KACpB3oC,KAAKmnG,cAAcx+D,GAAS,IAC3B3oC,KAAKmnG,cAAcx+D,GAAOpH,KAC3BvhC,KAAKmnG,cAAcx+D,GAAOpH,GAAc,CAAA,GAEvCvhC,KAAKmnG,cAAcx+D,GAAOpH,GAAYM,KAQvC7hC,KAAKmnG,cAAcx+D,GAAOpH,GAAYM,GAAc,IAAK7hC,KAAKknG,kBAAkB3lE,GALlE,CACVyE,KAAM,CAAC96B,EAAM6C,EAAMy2B,KACfxkC,KAAK+lC,MAAMC,KAAK96B,EAAM6C,EAAMy2B,EAAUmE,EAAM,GAGgE3oC,KAAK8nG,cAAcn/D,GAAQ3oC,KAAKsoG,mBAAmB3/D,KAGpK3oC,KAAKmnG,cAAcx+D,GAAOpH,GAAYM,EAChD,CAEDomE,mBAAmBt/D,EAAex8B,GAQ9B,OAPKnM,KAAKonG,iBAAiBz+D,KACvB3oC,KAAKonG,iBAAiBz+D,GAAS,IAE9B3oC,KAAKonG,iBAAiBz+D,GAAOx8B,KAC9BnM,KAAKonG,iBAAiBz+D,GAAOx8B,GAAU,IAAIirF,IAGxCp3F,KAAKonG,iBAAiBz+D,GAAOx8B,EACvC,SAGDrF,MACCE,KAAag9B,OAAS,IAAIgjE,GAAOhgG","x_google_ignoreList":[0,1,2,7,29,30,31,42,43,44,54,55,62,63,64,65,78,79,81,107,113,122,124,125,126,127,128,129,130,131,132,133,134,135]} \ No newline at end of file diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl-csp.js b/web/libraries/maplibre-gl/dist/maplibre-gl-csp.js new file mode 100644 index 00000000..cddc9f31 --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl-csp.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).maplibregl=e()}(this,(function(){"use strict";var t="3.6.2";function e(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{l(r.next(t))}catch(t){n(t)}}function o(t){try{l(r.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))}function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var r=s;function s(t,e){this.x=t,this.y=e}s.prototype={clone:function(){return new s(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},s.convert=function(t){return t instanceof s?t:Array.isArray(t)?new s(t[0],t[1]):t};var n=i(r),a=o;function o(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}o.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)s?a=i:o=i,i=.5*(o-a)+a;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var l=i(a);let c,h;function u(){return null==c&&(c="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),c}function p(t,e,i,r){const s=new l(t,e,i,r);return function(t){return s.solve(t)}}const d=p(.25,.1,.25,1);function m(t,e,i){return Math.min(i,Math.max(e,t))}function f(t,e,i){const r=i-e,s=((t-e)%r+r)%r+e;return s===e?i:s}function _(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const s=new Array(t.length);let n=null;t.forEach(((t,a)=>{e(t,((t,e)=>{t&&(n=t),s[a]=e,0==--r&&i(n,s)}))}))}function g(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function y(t,e){const i={};for(let r=0;r(e.y-t.y)*(i.x-t.x)}function C(t){let e=0;for(let i,r,s=0,n=t.length,a=n-1;scancelAnimationFrame(e)}},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(L||(L=document.createElement("a")),L.href=t,L.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==R&&(R=matchMedia("(prefers-reduced-motion: reduce)")),R.matches)}};class F{static testProp(t){if(!F.docStyle)return t[0];for(let e=0;e{window.removeEventListener("click",F.suppressClickInternal,!0)}),0)}static mousePos(t,e){const i=t.getBoundingClientRect();return new n(e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop)}static touchPos(t,e){const i=t.getBoundingClientRect(),r=[];for(let s=0;sself.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href,N=t=>O.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))];function $(t,e){const i=new AbortController,r=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:U(),signal:i.signal});let s=!1,n=!1;"json"===t.type&&r.headers.set("Accept","application/json");return n||fetch(r).then((i=>i.ok?(i=>{("arrayBuffer"===t.type||"image"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{n||(s=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{n||e(new Error(t.message))}))})(i):i.blob().then((r=>e(new V(i.status,i.statusText,t.url,r)))))).catch((t=>{20!==t.code&&e(new Error(t.message))})),{cancel:()=>{n=!0,s||i.abort()}}}const q=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(z()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!z())return(N(t.url)||$)(t,e)}if(!(/^file:/.test(i=t.url)||/^file:/.test(U())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return $(t,e);if(z()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else{const r=new Blob([i.response],{type:i.getResponseHeader("Content-Type")});e(new V(i.status,i.statusText,t.url,r))}},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},Z=function(t,e){return q(g(t,{type:"json"}),e)},j=function(t,e){return q(g(t,{type:"arrayBuffer"}),e)};function G(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return!0;const e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}const H={supported:!1,testSupport:function(t){!K&&X&&(Y?J(t):W=t)}};let W,X,K=!1,Y=!1;function J(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,X),t.isContextLost())return;H.supported=!0}catch(t){}t.deleteTexture(e),K=!0}var Q,tt;"undefined"!=typeof document&&(X=document.createElement("img"),X.onload=function(){W&&J(W),W=null,Y=!0},X.onerror=function(){K=!0,W=null},X.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let e,i,r,s;t.resetRequestQueue=()=>{e=[],i=0,r=0,s={}},t.addThrottleControl=t=>{const e=r++;return s[e]=t,e},t.removeThrottleControl=t=>{delete s[t],o()},t.getImage=(t,r,s=!0)=>{H.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*");const n={requestParameters:t,supportImageRefresh:s,callback:r,cancelled:!1,completed:!1,cancel:()=>{n.completed||n.cancelled||(n.cancelled=!0,n.innerRequest&&(n.innerRequest.cancel(),i--),o())}};return e.push(n),o(),n};const n=t=>{const{requestParameters:e,supportImageRefresh:i,callback:r}=t;return g(e,{type:"image"}),(!1!==i||z()||N(e.url)||e.headers&&!Object.keys(e.headers).reduce(((t,e)=>t&&"accept"===e),!0)?q:l)(e,((e,i,s,n)=>{a(t,r,e,i,s,n)}))},a=(t,e,r,s,n,a)=>{r?e(r):s instanceof HTMLImageElement||k(s)?e(null,s):s&&((t,e)=>{"function"==typeof createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(t,e):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame((()=>{i.src=D}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(r):D}(t,e)})(s,((t,i)=>{null!=t?e(t):null!=i&&e(null,i,{cacheControl:n,expires:a})})),t.cancelled||(t.completed=!0,i--,o())},o=()=>{const t=(()=>{const t=Object.keys(s);let e=!1;if(t.length>0)for(const i of t)if(e=s[i](),e)break;return e})()?O.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:O.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r0;r++){const t=e.shift();if(t.cancelled){r--;continue}const s=n(t);i++,t.innerRequest=s}},l=(t,e)=>{const i=new Image,r=t.url;let s=!1;const n=t.credentials;return n&&"include"===n?i.crossOrigin="use-credentials":(n&&"same-origin"===n||!G(r))&&(i.crossOrigin="anonymous"),i.fetchPriority="high",i.onload=()=>{e(null,i),i.onerror=i.onload=null},i.onerror=()=>{s||e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.")),i.onerror=i.onload=null},i.src=r,{cancel:()=>{s=!0,i.src=""}}}}(Q||(Q={})),Q.resetRequestQueue(),function(t){t.Glyphs="Glyphs",t.Image="Image",t.Source="Source",t.SpriteImage="SpriteImage",t.SpriteJSON="SpriteJSON",t.Style="Style",t.Tile="Tile",t.Unknown="Unknown"}(tt||(tt={}));class et{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeSpriteURL(t,e,i){const r=function(t){const e=t.match(it);if(!e)throw new Error(`Unable to parse URL "${t}"`);return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}(t);return r.path+=`${e}${i}`,function(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}(r)}setTransformRequest(t){this._transformRequestFn=t}}const it=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function rt(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function st(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class nt{constructor(t,e={}){g(this,e),this.type=t}}class at extends nt{constructor(t,e={}){super("error",g({error:t},e))}}class ot{on(t,e){return this._listeners=this._listeners||{},rt(t,e,this._listeners),this}off(t,e){return st(t,e,this._listeners),st(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},rt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new nt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)st(i,e,this._oneTimeListeners),e.call(this,t);const s=this._eventedParent;s&&(g(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof at&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var lt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ct=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ht(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return ct.forEach((t=>{t in e&&(i[t]=e[t])})),i}function ut(t){t=t.slice();const e=Object.create(null);for(let i=0;i`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Vt=[It,At,Et,Ct,zt,Dt,Mt,Ft(Pt),Lt,Rt,Bt];function Ut(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ut(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Vt)if(!Ut(t,e))return null}return`Expected ${Ot(t)} but found ${Ot(e)} instead.`}function Nt(t,e){return e.some((e=>e.kind===t.kind))}function $t(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function qt(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Zt=.96422,jt=.82521,Gt=4/29,Ht=6/29,Wt=3*Ht*Ht,Xt=Ht*Ht*Ht,Kt=Math.PI/180,Yt=180/Math.PI;function Jt(t){return(t%=360)<0&&(t+=360),t}function Qt([t,e,i,r]){let s,n;const a=ee((.2225045*(t=te(t))+.7168786*(e=te(e))+.0606169*(i=te(i)))/1);t===e&&e===i?s=n=a:(s=ee((.4360747*t+.3850649*e+.1430804*i)/Zt),n=ee((.0139322*t+.0971045*e+.7141733*i)/jt));const o=116*a-16;return[o<0?0:o,500*(s-a),200*(a-n),r]}function te(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ee(t){return t>Xt?Math.pow(t,1/3):t/Wt+Gt}function ie([t,e,i,r]){let s=(t+16)/116,n=isNaN(e)?s:s+e/500,a=isNaN(i)?s:s-i/200;return s=1*se(s),n=Zt*se(n),a=jt*se(a),[re(3.1338561*n-1.6168667*s-.4906146*a),re(-.9787684*n+1.9161415*s+.033454*a),re(.0719453*n-.2289914*s+1.4052427*a),r]}function re(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function se(t){return t>Ht?t*t*t:Wt*(t-Gt)}function ne(t){return parseInt(t.padEnd(2,t),16)/255}function ae(t,e){return oe(e?t/100:t,0,1)}function oe(t,e,i){return Math.min(Math.max(e,t),i)}function le(t){return!t.some(Number.isNaN)}const ce={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class he{constructor(t,e,i,r=1,s=!0){this.r=t,this.g=e,this.b=i,this.a=r,s||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static parse(t){if(t instanceof he)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=ce[t];if(e){const[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let i=1;return[ne(t.slice(i,i+=e)),ne(t.slice(i,i+=e)),ne(t.slice(i,i+=e)),ne(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,i,r,s,n,a,o,l,c,h,u,p]=e,d=[s||" ",o||" ",h].join("");if(" "===d||" /"===d||",,"===d||",,,"===d){const t=[r,a,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[oe(+i/e,0,1),oe(+n/e,0,1),oe(+l/e,0,1),u?ae(+u,p):1];if(le(t))return t}}return}}const i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[t,e,r,s,n,a,o,l,c]=i,h=[r||" ",n||" ",o].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const t=[+e,oe(+s,0,100),oe(+a,0,100),l?ae(+l,c):1];if(le(t))return function([t,e,i,r]){function s(r){const s=(r+t/30)%12,n=e*Math.min(i,1-i);return i-n*Math.max(-1,Math.min(s-3,9-s,1))}return t=Jt(t),e/=100,i/=100,[s(0),s(8),s(4),r]}(t)}}}(t);return e?new he(...e,!1):void 0}get rgb(){const{r:t,g:e,b:i,a:r}=this,s=r||1/0;return this.overwriteGetter("rgb",[t/s,e/s,i/s,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,i,r,s]=Qt(t),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?Jt(Math.atan2(r,i)*Yt):NaN,n,e,s]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Qt(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${r})`}}he.black=new he(0,0,0,1),he.white=new he(1,1,1,1),he.transparent=new he(0,0,0,0),he.red=new he(1,0,0,1);class ue{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class pe{constructor(t,e,i,r,s){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=s}}class de{constructor(t){this.sections=t}static fromString(t){return new de([new pe(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof de?t:de.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class me{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof me)return t;if("number"==typeof t)return new me([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new me(t)}}toString(){return JSON.stringify(this.values)}}const fe=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class _e{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof _e)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function xe(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof he||t instanceof ue||t instanceof de||t instanceof me||t instanceof _e||t instanceof ge)return!0;if(Array.isArray(t)){for(const e of t)if(!xe(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!xe(t[e]))return!1;return!0}return!1}function ve(t){if(null===t)return It;if("string"==typeof t)return Et;if("boolean"==typeof t)return Ct;if("number"==typeof t)return At;if(t instanceof he)return zt;if(t instanceof ue)return kt;if(t instanceof de)return Dt;if(t instanceof me)return Lt;if(t instanceof _e)return Bt;if(t instanceof ge)return Rt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=ve(e);if(i){if(i===t)continue;i=Pt;break}i=t}return Ft(i||Pt,e)}return Mt}function be(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof he||t instanceof de||t instanceof me||t instanceof _e||t instanceof ge?t.toString():JSON.stringify(t)}class we{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!xe(t[1]))return e.error("invalid value");const i=t[1];let r=ve(i);const s=e.expectedType;return"array"!==r.kind||0!==r.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(r=s),new we(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Te{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const Se={string:Et,number:At,boolean:Ct,object:Mt};class Ie{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const s=t[0];if("array"===s){let s,n;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in Se)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);s=Se[i],r++}else s=Pt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);n=t[2],r++}i=Ft(s,n)}else{if(!Se[s])throw new Error(`Types doesn't contain name = ${s}`);i=Se[s]}const n=[];for(;rt.outputDefined()))}}const Ae={"to-boolean":Ct,"to-color":zt,"to-number":At,"to-string":Et};class Ee{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(!Ae[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Ae[i],s=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ye(e[0],e[1],e[2],e[3]),!i))return new he(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Te(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const i of this.args){e=i.evaluate(t);const r=me.parse(e);if(r)return r}throw new Te(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const i of this.args){e=i.evaluate(t);const r=_e.parse(e);if(r)return r}throw new Te(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Te(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return de.fromString(be(this.args[0].evaluate(t)));case"resolvedImage":return ge.fromString(be(this.args[0].evaluate(t)));default:return be(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ce=["Unknown","Point","LineString","Polygon"];class ze{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ce[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=he.parse(t)),e}}class Me{constructor(t,e,i=[],r,s=new St,n=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=s,this.errors=n,this.expectedType=r,this._isConstant=e}parse(t,e,i,r,s={}){return e?this.concat(e,i,r)._parse(t,s):this._parse(t,s)}_parse(t,e){function i(t,e,i){return"assert"===i?new Ie(e,[t]):"coerce"===i?new Ee(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[r];if(s){let r=s.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,s=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==s.kind&&"string"!==s.kind)if("padding"!==t.kind||"value"!==s.kind&&"number"!==s.kind&&"array"!==s.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==s.kind&&"array"!==s.kind){if(this.checkSubtype(t,s))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof we)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const t=new ze;try{r=new we(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,s=i?this.scope.concat(i):this.scope;return new Me(this.registry,this._isConstant,r,e||null,s,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Tt(i,t))}checkSubtype(t,e){const i=Ut(t,e);return i&&this.error(i),i}}class Pe{constructor(t,e,i){this.type=kt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Ct);if(!r)return null;const s=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Ct);if(!s)return null;let n=null;return i.locale&&(n=e.parse(i.locale,1,Et),!n)?null:new Pe(r,s,n)}evaluate(t){return new ue(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}const ke=8192;function De(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Le(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Re(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*ke),Math.round(r*s*ke)]}function Be(t,e,i){const r=t[0]-e[0],s=t[1]-e[1],n=t[0]-i[0],a=t[1]-i[1];return r*a-n*s==0&&r*n<=0&&s*a<=0}function Fe(t,e){let i=!1;for(let a=0,o=e.length;a(r=t)[1]!=(n=o[e+1])[1]>r[1]&&r[0]<(n[0]-s[0])*(r[1]-s[1])/(n[1]-s[1])+s[0]&&(i=!i)}}var r,s,n;return i}function Oe(t,e){for(let i=0;i0&&o<0||a<0&&o>0}function Ue(t,e,i){for(const c of i)for(let i=0;ii[2]){const e=.5*r;let s=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===s&&(s=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=s}De(e,t)}function Ge(t,e,i,r){const s=Math.pow(2,r.z)*ke,n=[r.x*ke,r.y*ke],a=[];for(const r of t)for(const t of r){const r=[t.x+n[0],t.y+n[1]];je(r,e,i,s),a.push(r)}return a}function He(t,e,i,r){const s=Math.pow(2,r.z)*ke,n=[r.x*ke,r.y*ke],a=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+n[0],r.y+n[1]];De(e,i),t.push(i)}a.push(t)}if(e[2]-e[0]<=s/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const r of t)je(r,e,i,s)}var o;return a}class We{constructor(t,e){this.type=Ct,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(xe(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[r,n]of a){o=new Me(e.registry,Ye,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(Ot).join(", ")})`:`(${Ot(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i{i=e?i&&Ye(t):i&&t instanceof we})),!!i&&Je(t)&&ti(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Je(t){if(t instanceof Ke){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof We)return!1;let e=!0;return t.eachChild((t=>{e&&!Je(t)&&(e=!1)})),e}function Qe(t){if(t instanceof Ke&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Qe(t)&&(e=!1)})),e}function ti(t,e){if(t instanceof Ke&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!ti(t,e)&&(i=!1)})),i}function ei(t,e){const i=t.length-1;let r,s,n=0,a=i,o=0;for(;n<=a;)if(o=Math.floor((n+a)/2),r=t[o],s=t[o+1],r<=e){if(o===i||ee))throw new Te("Input is not a number.");a=o-1}return 0}class ii{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,At);if(!i)return null;const r=[];let s=null;e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let i=1;i=n)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const c=e.parse(a,l,s);if(!c)return null;s=s||c.type,r.push([n,c])}return new ii(s,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;return r>=e[s-1]?i[s-1].evaluate(t):i[ei(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ri(t,e,i){return t+i*(e-t)}function si(t,e,i){return t.map(((t,r)=>ri(t,e[r],i)))}const ni={number:ri,color:function(t,e,i,r="rgb"){switch(r){case"rgb":{const[r,s,n,a]=si(t.rgb,e.rgb,i);return new he(r,s,n,a,!1)}case"hcl":{const[r,s,n,a]=t.hcl,[o,l,c,h]=e.hcl;let u,p;if(isNaN(r)||isNaN(o))isNaN(r)?isNaN(o)?u=NaN:(u=o,1!==n&&0!==n||(p=l)):(u=r,1!==c&&0!==c||(p=s));else{let t=o-r;o>r&&t>180?t-=360:o180&&(t+=360),u=r+i*t}const[d,m,f,_]=function([t,e,i,r]){return t=isNaN(t)?0:t*Kt,ie([i,Math.cos(t)*e,Math.sin(t)*e,r])}([u,null!=p?p:ri(s,l,i),ri(n,c,i),ri(a,h,i)]);return new he(d,m,f,_,!1)}case"lab":{const[r,s,n,a]=ie(si(t.lab,e.lab,i));return new he(r,s,n,a,!1)}}},array:si,padding:function(t,e,i){return new me(si(t.values,e.values,i))},variableAnchorOffsetCollection:function(t,e,i){const r=t.values,s=e.values;if(r.length!==s.length)throw new Te(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const n=[];for(let t=0;t"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(s=e.parse(s,2,At),!s)return null;const a=[];let o=null;"interpolate-hcl"===i||"interpolate-lab"===i?o=zt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(r,l,o);if(!c)return null;o=o||c.type,a.push([i,c])}return qt(o,At)||qt(o,zt)||qt(o,Lt)||qt(o,Bt)||qt(o,Ft(At))?new ai(o,i,r,s,a):e.error(`Type ${Ot(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;if(r>=e[s-1])return i[s-1].evaluate(t);const n=ei(e,r),a=ai.interpolationFactor(this.interpolation,r,e[n],e[n+1]),o=i[n].evaluate(t),l=i[n+1].evaluate(t);switch(this.operator){case"interpolate":return ni[this.type.kind](o,l,a);case"interpolate-hcl":return ni.color(o,l,a,"hcl");case"interpolate-lab":return ni.color(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function oi(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}class li{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const s=[];for(const r of t.slice(1)){const t=e.parse(r,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,s.push(t)}if(!i)throw new Error("No output type");const n=r&&s.some((t=>Ut(r,t.type)));return new li(n?Pt:i,s)}evaluate(t){let e,i=null,r=0;for(const s of this.args)if(r++,i=s.evaluate(t),i&&i instanceof ge&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}class ci{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new Te(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Te(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ui{constructor(t,e){this.type=Ct,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Pt),r=e.parse(t[2],2,Pt);return i&&r?Nt(i.type,[Ct,Et,At,It,Pt])?new ui(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ot(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!$t(e,["boolean","string","number","null"]))throw new Te(`Expected first argument to be of type boolean, string, number or null, but found ${Ot(ve(e))} instead.`);if(!$t(i,["string","array"]))throw new Te(`Expected second argument to be of type array or string, but found ${Ot(ve(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class pi{constructor(t,e,i){this.type=At,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Pt),r=e.parse(t[2],2,Pt);if(!i||!r)return null;if(!Nt(i.type,[Ct,Et,At,It,Pt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ot(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,At);return s?new pi(i,r,s):null}return new pi(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!$t(e,["boolean","string","number","null"]))throw new Te(`Expected first argument to be of type boolean, string, number or null, but found ${Ot(ve(e))} instead.`);if(!$t(i,["string","array"]))throw new Te(`Expected second argument to be of type array or string, but found ${Ot(ve(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class di{constructor(t,e,i,r,s,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=s,this.otherwise=n}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const s={},n=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ve(t)))return null}else i=ve(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=n.length}const h=e.parse(l,a,r);if(!h)return null;r=r||h.type,n.push(h)}const a=e.parse(t[1],1,Pt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,r);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(i,a.type)?null:new di(i,r,a,s,n,o):null}evaluate(t){const e=this.input.evaluate(t);return(ve(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class mi{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let s=1;se.outputDefined()))&&this.otherwise.outputDefined()}}class fi{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Pt),r=e.parse(t[2],2,At);if(!i||!r)return null;if(!Nt(i.type,[Ft(Pt),Et,Pt]))return e.error(`Expected first argument to be of type array or string, but found ${Ot(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,At);return s?new fi(i.type,i,r,s):null}return new fi(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!$t(e,["string","array"]))throw new Te(`Expected first argument to be of type array or string, but found ${Ot(ve(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function _i(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function gi(t,e,i,r){return 0===r.compare(e,i)}function yi(t,e,i){const r="=="!==t&&"!="!==t;return class s{constructor(t,e,i){this.type=Ct,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let n=e.parse(t[1],1,Pt);if(!n)return null;if(!_i(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ot(n.type)}'.`);let a=e.parse(t[2],2,Pt);if(!a)return null;if(!_i(i,a.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ot(a.type)}'.`);if(n.type.kind!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Ot(n.type)}' and '${Ot(a.type)}'.`);r&&("value"===n.type.kind&&"value"!==a.type.kind?n=new Ie(a.type,[n]):"value"!==n.type.kind&&"value"===a.type.kind&&(a=new Ie(n.type,[a])));let o=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,kt),!o)return null}return new s(n,a,o)}evaluate(s){const n=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(r&&this.hasUntypedArgument){const e=ve(n),i=ve(a);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Te(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=ve(n),i=ve(a);if("string"!==t.kind||"string"!==i.kind)return e(s,n,a)}return this.collator?i(s,n,a,this.collator.evaluate(s)):e(s,n,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const xi=yi("==",(function(t,e,i){return e===i}),gi),vi=yi("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!gi(0,e,i,r)})),bi=yi("<",(function(t,e,i){return e",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),Ti=yi("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),Si=yi(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class Ii{constructor(t,e,i,r,s){this.type=Et,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,At);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let s=null;if(r.locale&&(s=e.parse(r.locale,1,Et),!s))return null;let n=null;if(r.currency&&(n=e.parse(r.currency,1,Et),!n))return null;let a=null;if(r["min-fraction-digits"]&&(a=e.parse(r["min-fraction-digits"],1,At),!a))return null;let o=null;return r["max-fraction-digits"]&&(o=e.parse(r["max-fraction-digits"],1,At),!o)?null:new Ii(i,s,n,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ai{constructor(t){this.type=Dt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let s=!1;for(let i=1;i<=t.length-1;++i){const n=t[i];if(s&&"object"==typeof n&&!Array.isArray(n)){s=!1;let t=null;if(n["font-scale"]&&(t=e.parse(n["font-scale"],1,At),!t))return null;let i=null;if(n["text-font"]&&(i=e.parse(n["text-font"],1,Ft(Et)),!i))return null;let a=null;if(n["text-color"]&&(a=e.parse(n["text-color"],1,zt),!a))return null;const o=r[r.length-1];o.scale=t,o.font=i,o.textColor=a}else{const n=e.parse(t[i],1,Pt);if(!n)return null;const a=n.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new Ai(r)}evaluate(t){return new de(this.sections.map((e=>{const i=e.content.evaluate(t);return ve(i)===Rt?new pe("",i,null,null,null):new pe(be(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}}class Ei{constructor(t){this.type=Rt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Et);return i?new Ei(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=ge.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class Ci{constructor(t){this.type=At,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Ot(i.type)} instead.`):new Ci(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Te(`Expected value to be of type string or array, but found ${Ot(ve(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const zi={"==":xi,"!=":vi,">":wi,"<":bi,">=":Si,"<=":Ti,array:Ie,at:hi,boolean:Ie,case:mi,coalesce:li,collator:Pe,format:Ai,image:Ei,in:ui,"index-of":pi,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:Ci,let:ci,literal:we,match:di,number:Ie,"number-format":Ii,object:Ie,slice:fi,step:ii,string:Ie,"to-boolean":Ee,"to-color":Ee,"to-number":Ee,"to-string":Ee,var:Xe,within:We};function Mi(t,[e,i,r,s]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const n=s?s.evaluate(t):1,a=ye(e,i,r,n);if(a)throw new Te(a);return new he(e/255,i/255,r/255,n,!1)}function Pi(t,e){return t in e}function ki(t,e){const i=e[t];return void 0===i?null:i}function Di(t){return{type:t}}function Li(t){return{result:"success",value:t}}function Ri(t){return{result:"error",value:t}}function Bi(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Fi(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Oi(t){return!!t.expression&&t.expression.interpolated}function Vi(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Ui(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ni(t){return t}function $i(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],s=r||!(r||void 0!==t.property),n=t.type||(Oi(e)?"exponential":"interval");if(i||"padding"===e.type){const r=i?he.parse:me.parse;(t=wt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,c;if("exponential"===n)o=Gi;else if("interval"===n)o=ji;else if("categorical"===n){o=Zi,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];c=typeof t.stops[0][0]}else{if("identity"!==n)throw new Error(`Unknown function type "${n}"`);o=Hi}if(r){const i={},r=[];for(let e=0;et[0])),evaluate:({zoom:i},r)=>Gi({stops:s,base:t.base},e,i).evaluate(i,r)}}if(s){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ai.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>o(t,e,i,l,c)}}return{kind:"source",evaluate(i,r){const s=r&&r.properties?r.properties[t.property]:void 0;return void 0===s?qi(t.default,e.default):o(t,e,s,l,c)}}}function qi(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Zi(t,e,i,r,s){return qi(typeof i===s?r[i]:void 0,t.default,e.default)}function ji(t,e,i){if("number"!==Vi(i))return qi(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const s=ei(t.stops.map((t=>t[0])),i);return t.stops[s][1]}function Gi(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Vi(i))return qi(t.default,e.default);const s=t.stops.length;if(1===s)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const n=ei(t.stops.map((t=>t[0])),i),a=function(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),o=t.stops[n][1],l=t.stops[n+1][1],c=ni[e.type]||Ni;return"function"==typeof o.evaluate?{evaluate(...e){const i=o.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return c(i,r,a,t.colorSpace)}}:c(o,l,a,t.colorSpace)}function Hi(t,e,i){switch(e.type){case"color":i=he.parse(i);break;case"formatted":i=de.fromString(i.toString());break;case"resolvedImage":i=ge.fromString(i.toString());break;case"padding":i=me.parse(i);break;default:Vi(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return qi(i,t.default,e.default)}Ke.register(zi,{error:[{kind:"error"},[Et],(t,[e])=>{throw new Te(e.evaluate(t))}],typeof:[Et,[Pt],(t,[e])=>Ot(ve(e.evaluate(t)))],"to-rgba":[Ft(At,4),[zt],(t,[e])=>{const[i,r,s,n]=e.evaluate(t).rgb;return[255*i,255*r,255*s,n]}],rgb:[zt,[At,At,At],Mi],rgba:[zt,[At,At,At,At],Mi],has:{type:Ct,overloads:[[[Et],(t,[e])=>Pi(e.evaluate(t),t.properties())],[[Et,Mt],(t,[e,i])=>Pi(e.evaluate(t),i.evaluate(t))]]},get:{type:Pt,overloads:[[[Et],(t,[e])=>ki(e.evaluate(t),t.properties())],[[Et,Mt],(t,[e,i])=>ki(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Pt,[Et],(t,[e])=>ki(e.evaluate(t),t.featureState||{})],properties:[Mt,[],t=>t.properties()],"geometry-type":[Et,[],t=>t.geometryType()],id:[Pt,[],t=>t.id()],zoom:[At,[],t=>t.globals.zoom],"heatmap-density":[At,[],t=>t.globals.heatmapDensity||0],"line-progress":[At,[],t=>t.globals.lineProgress||0],accumulated:[Pt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[At,Di(At),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[At,Di(At),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:At,overloads:[[[At,At],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[At],(t,[e])=>-e.evaluate(t)]]},"/":[At,[At,At],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[At,[At,At],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[At,[],()=>Math.LN2],pi:[At,[],()=>Math.PI],e:[At,[],()=>Math.E],"^":[At,[At,At],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[At,[At],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[At,[At],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[At,[At],(t,[e])=>Math.log(e.evaluate(t))],log2:[At,[At],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[At,[At],(t,[e])=>Math.sin(e.evaluate(t))],cos:[At,[At],(t,[e])=>Math.cos(e.evaluate(t))],tan:[At,[At],(t,[e])=>Math.tan(e.evaluate(t))],asin:[At,[At],(t,[e])=>Math.asin(e.evaluate(t))],acos:[At,[At],(t,[e])=>Math.acos(e.evaluate(t))],atan:[At,[At],(t,[e])=>Math.atan(e.evaluate(t))],min:[At,Di(At),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[At,Di(At),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[At,[At],(t,[e])=>Math.abs(e.evaluate(t))],round:[At,[At],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[At,[At],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[At,[At],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Ct,[Et,Pt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Ct,[Pt],(t,[e])=>t.id()===e.value],"filter-type-==":[Ct,[Et],(t,[e])=>t.geometryType()===e.value],"filter-<":[Ct,[Et,Pt],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r{const i=t.id(),r=e.value;return typeof i==typeof r&&i":[Ct,[Et,Pt],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[Ct,[Pt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Ct,[Et,Pt],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[Ct,[Pt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Ct,[Et,Pt],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[Ct,[Pt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Ct,[Pt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Ct,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Ct,[Ft(Et)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Ct,[Ft(Pt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Ct,[Et,Ft(Pt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Ct,[Et,Ft(Pt)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const s=i+r>>1;if(e[s]===t)return!0;e[s]>t?r=s-1:i=s+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Ct,overloads:[[[Ct,Ct],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Di(Ct),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Ct,overloads:[[[Ct,Ct],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Di(Ct),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Ct,[Ct],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Ct,[Et],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Et,[Et],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Et,[Et],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Et,Di(Pt),(t,e)=>e.map((e=>be(e.evaluate(t)))).join("")],"resolved-locale":[Et,[kt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Wi{constructor(t,e){var i;this.expression=t,this._warningHistory={},this._evaluator=new ze,this._defaultValue=e?"color"===(i=e).type&&Ui(i.default)?new he(0,0,0,0):"color"===i.type?he.parse(i.default)||null:"padding"===i.type?me.parse(i.default)||null:"variableAnchorOffsetCollection"===i.type?_e.parse(i.default)||null:void 0===i.default?null:i.default:null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,s,n){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Te(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Xi(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in zi}function Ki(t,e){const i=new Me(zi,Ye,[],e?function(t){const e={color:zt,string:Et,number:At,enum:Et,boolean:Ct,formatted:Dt,padding:Lt,resolvedImage:Rt,variableAnchorOffsetCollection:Bt};return"array"===t.type?Ft(e[t.value]||Pt,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Li(new Wi(r,e)):Ri(i.errors)}class Yi{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Qe(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}}class Ji{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Qe(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}interpolationFactor(t,e,i){return this.interpolationType?ai.interpolationFactor(this.interpolationType,t,e,i):0}}function Qi(t,e){const i=Ki(t,e);if("error"===i.result)return i;const r=i.value.expression,s=Je(r);if(!s&&!Bi(e))return Ri([new Tt("","data expressions not supported")]);const n=ti(r,["zoom"]);if(!n&&!Fi(e))return Ri([new Tt("","zoom expressions not supported")]);const a=er(r);return a||n?a instanceof Tt?Ri([a]):a instanceof ai&&!Oi(e)?Ri([new Tt("",'"interpolate" expressions cannot be used with this property')]):Li(a?new Ji(s?"camera":"composite",i.value,a.labels,a instanceof ai?a.interpolation:void 0):new Yi(s?"constant":"source",i.value)):Ri([new Tt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class tr{constructor(t,e){this._parameters=t,this._specification=e,wt(this,$i(this._parameters,this._specification))}static deserialize(t){return new tr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function er(t){let e=null;if(t instanceof ci)e=er(t.result);else if(t instanceof li){for(const i of t.args)if(e=er(i),e)break}else(t instanceof ii||t instanceof ai)&&t.input instanceof Ke&&"zoom"===t.input.name&&(e=t);return e instanceof Tt||t.eachChild((t=>{const i=er(t);i instanceof Tt?e=i:!e&&i?e=new Tt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Tt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function ir(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!ir(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const rr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function sr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};ir(t)||(t=or(t));const e=Ki(t,rr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:ar(t)}}function nr(t,e){return te?1:0}function ar(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?lr(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(or))):"all"===e?["all"].concat(t.slice(1).map(or)):"none"===e?["all"].concat(t.slice(1).map(or).map(ur)):"in"===e?cr(t[1],t.slice(2)):"!in"===e?ur(cr(t[1],t.slice(2))):"has"===e?hr(t[1]):"!has"===e?ur(hr(t[1])):"within"!==e||t;var i}function lr(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function cr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(nr)]]:["filter-in-small",t,["literal",e]]}}function hr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ur(t){return["!",t]}function pr(t){const e=t.value;return e?[new bt(t.key,e,"constants have been deprecated as of v8")]:[]}function dr(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function mr(t){if(Array.isArray(t))return t.map(mr);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=mr(t[i]);return e}return dr(t)}function fr(t){const e=t.key,i=t.value,r=t.valueSpec||{},s=t.objectElementValidators||{},n=t.style,a=t.styleSpec,o=t.validateSpec;let l=[];const c=Vi(i);if("object"!==c)return[new bt(e,i,`object expected, ${c} found`)];for(const t in i){const c=t.split(".")[0],h=r[c]||r["*"];let u;if(s[c])u=s[c];else if(r[c])u=o;else if(s["*"])u=s["*"];else{if(!r["*"]){l.push(new bt(e,i[t],`unknown property "${t}"`));continue}u=o}l=l.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:h,style:n,styleSpec:a,object:i,objectKey:t,validateSpec:o},i))}for(const t in r)s[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&l.push(new bt(e,i,`missing required property "${t}"`));return l}function _r(t){const e=t.value,i=t.valueSpec,r=t.style,s=t.styleSpec,n=t.key,a=t.arrayElementValidator||t.validateSpec;if("array"!==Vi(e))return[new bt(n,e,`array expected, ${Vi(e)} found`)];if(i.length&&e.length!==i.length)return[new bt(n,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.lengthr.maximum?[new bt(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function yr(t){const e=t.valueSpec,i=dr(t.value.type);let r,s,n,a={};const o="categorical"!==i&&void 0===t.value.property,l=!o,c="array"===Vi(t.value.stops)&&"array"===Vi(t.value.stops[0])&&"object"===Vi(t.value.stops[0][0]),h=fr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new bt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(_r({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Vi(r)&&0===r.length&&e.push(new bt(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&o&&h.push(new bt(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new bt(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Oi(t.valueSpec)&&h.push(new bt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Bi(t.valueSpec)?h.push(new bt(t.key,t.value,"property functions not supported")):o&&!Fi(t.valueSpec)&&h.push(new bt(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new bt(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,o=t.key;if("array"!==Vi(r))return[new bt(o,r,`array expected, ${Vi(r)} found`)];if(2!==r.length)return[new bt(o,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Vi(r[0]))return[new bt(o,r,`object expected, ${Vi(r[0])} found`)];if(void 0===r[0].zoom)return[new bt(o,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new bt(o,r,"object stop key must have value")];if(n&&n>dr(r[0].zoom))return[new bt(o,r[0].zoom,"stop zoom values must appear in ascending order")];dr(r[0].zoom)!==n&&(n=dr(r[0].zoom),s=void 0,a={}),i=i.concat(fr({key:`${o}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:gr,value:p}}))}else i=i.concat(p({key:`${o}[0]`,value:r[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return Xi(mr(r[1]))?i.concat([new bt(`${o}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(t.validateSpec({key:`${o}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,n){const o=Vi(t.value),l=dr(t.value),c=null!==t.value?t.value:n;if(r){if(o!==r)return[new bt(t.key,c,`${o} stop domain type must match previous stop domain type ${r}`)]}else r=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return[new bt(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==i){let r=`number expected, ${o} found`;return Bi(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new bt(t.key,c,r)]}return"categorical"!==i||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===o&&void 0!==s&&lnew bt(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new bt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Qe(i))return[new bt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Qe(i))return[new bt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!ti(i,["zoom","feature-state"]))return[new bt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Je(i))return[new bt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function vr(t){const e=t.key,i=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(dr(i))&&s.push(new bt(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(dr(i))&&s.push(new bt(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function br(t){return ir(mr(t.value))?xr(wt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):wr(t)}function wr(t){const e=t.value,i=t.key;if("array"!==Vi(e))return[new bt(i,e,`array expected, ${Vi(e)} found`)];const r=t.styleSpec;let s,n=[];if(e.length<1)return[new bt(i,e,"filter array must have at least 1 element")];switch(n=n.concat(vr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),dr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===dr(e[1])&&n.push(new bt(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new bt(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=Vi(e[1]),"string"!==s&&n.push(new bt(`${i}[1]`,e[1],`string expected, ${s} found`)));for(let a=2;a{t in i&&e.push(new bt(r,i[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{dr(e.id)===o&&(t=e)})),t?t.ref?e.push(new bt(r,i.ref,"ref cannot reference another ref layer")):a=dr(t.type):e.push(new bt(r,i.ref,`ref layer "${o}" not found`))}else if("background"!==a)if(i.source){const t=s.sources&&s.sources[i.source],n=t&&dr(t.type);t?"vector"===n&&"raster"===a?e.push(new bt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===a?e.push(new bt(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==a?e.push(new bt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==a?e.push(new bt(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]||"geojson"===n&&t.lineMetrics||e.push(new bt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new bt(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new bt(r,i.source,`source "${i.source}" not found`))}else e.push(new bt(r,i,'missing required property "source"'));return e=e.concat(fr({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:br,layout:t=>fr({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Ir(wt({layerType:a},t))}}),paint:t=>fr({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Sr(wt({layerType:a},t))}})}})),e}function Er(t){const e=t.value,i=t.key,r=Vi(e);return"string"!==r?[new bt(i,e,`string expected, ${r} found`)]:[]}const Cr={promoteId:function({key:t,value:e}){if("string"===Vi(e))return Er({key:t,value:e});{const i=[];for(const r in e)i.push(...Er({key:`${t}.${r}`,value:e[r]}));return i}}};function zr(t){const e=t.value,i=t.key,r=t.styleSpec,s=t.style,n=t.validateSpec;if(!e.type)return[new bt(i,e,'"type" is required')];const a=dr(e.type);let o;switch(a){case"vector":case"raster":return o=fr({key:i,value:e,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Cr,validateSpec:n}),o;case"raster-dem":return o=function(t){var e;const i=null!==(e=t.sourceName)&&void 0!==e?e:"",r=t.value,s=t.styleSpec,n=s.source_raster_dem,a=t.style;let o=[];const l=Vi(r);if(void 0===r)return o;if("object"!==l)return o.push(new bt("source_raster_dem",r,`object expected, ${l} found`)),o;const c="custom"===dr(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in r)!c&&h.includes(e)?o.push(new bt(e,r[e],`In "${i}": "${e}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):n[e]?o=o.concat(t.validateSpec({key:e,value:r[e],valueSpec:n[e],validateSpec:t.validateSpec,style:a,styleSpec:s})):o.push(new bt(e,r[e],`unknown property "${e}"`));return o}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=fr({key:i,value:e,valueSpec:r.source_geojson,style:s,styleSpec:r,validateSpec:n,objectElementValidators:Cr}),e.cluster)for(const t in e.clusterProperties){const[r,s]=e.clusterProperties[t],a="string"==typeof r?[r,["accumulated"],["get",t]]:r;o.push(...xr({key:`${i}.${t}.map`,value:s,validateSpec:n,expressionContext:"cluster-map"})),o.push(...xr({key:`${i}.${t}.reduce`,value:a,validateSpec:n,expressionContext:"cluster-reduce"}))}return o;case"video":return fr({key:i,value:e,valueSpec:r.source_video,style:s,validateSpec:n,styleSpec:r});case"image":return fr({key:i,value:e,valueSpec:r.source_image,style:s,validateSpec:n,styleSpec:r});case"canvas":return[new bt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return vr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,validateSpec:n,styleSpec:r})}}function Mr(t){const e=t.value,i=t.styleSpec,r=i.light,s=t.style;let n=[];const a=Vi(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new bt("light",e,`object expected, ${a} found`)]),n;for(const a in e){const o=a.match(/^(.*)-transition$/);n=n.concat(o&&r[o[1]]&&r[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:i.transition,validateSpec:t.validateSpec,style:s,styleSpec:i}):r[a]?t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new bt(a,e[a],`unknown property "${a}"`)])}return n}function Pr(t){const e=t.value,i=t.styleSpec,r=i.terrain,s=t.style;let n=[];const a=Vi(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new bt("terrain",e,`object expected, ${a} found`)]),n;for(const a in e)n=n.concat(r[a]?t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new bt(a,e[a],`unknown property "${a}"`)]);return n}function kr(t){let e=[];const i=t.value,r=t.key;if(Array.isArray(i)){const s=[],n=[];for(const a in i)i[a].id&&s.includes(i[a].id)&&e.push(new bt(r,i,`all the sprites' ids must be unique, but ${i[a].id} is duplicated`)),s.push(i[a].id),i[a].url&&n.includes(i[a].url)&&e.push(new bt(r,i,`all the sprites' URLs must be unique, but ${i[a].url} is duplicated`)),n.push(i[a].url),e=e.concat(fr({key:`${r}[${a}]`,value:i[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Er({key:r,value:i})}const Dr={"*":()=>[],array:_r,boolean:function(t){const e=t.value,i=t.key,r=Vi(e);return"boolean"!==r?[new bt(i,e,`boolean expected, ${r} found`)]:[]},number:gr,color:function(t){const e=t.key,i=t.value,r=Vi(i);return"string"!==r?[new bt(e,i,`color expected, ${r} found`)]:he.parse(String(i))?[]:[new bt(e,i,`color expected, "${i}" found`)]},constants:pr,enum:vr,filter:br,function:yr,layer:Ar,object:fr,source:zr,light:Mr,terrain:Pr,string:Er,formatted:function(t){return 0===Er(t).length?[]:xr(t)},resolvedImage:function(t){return 0===Er(t).length?[]:xr(t)},padding:function(t){const e=t.key,i=t.value;if("array"===Vi(i)){if(i.length<1||i.length>4)return[new bt(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let s=[];for(let n=0;n[]}})),t.constants&&(i=i.concat(pr({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:Lr}))),Or(i)}function Fr(t){return function(e){return t({...e,validateSpec:Lr})}}function Or(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Vr(t){return function(...e){return Or(t.apply(this,e))}}Br.source=Vr(Fr(zr)),Br.sprite=Vr(Fr(kr)),Br.glyphs=Vr(Fr(Rr)),Br.light=Vr(Fr(Mr)),Br.terrain=Vr(Fr(Pr)),Br.layer=Vr(Fr(Ar)),Br.filter=Vr(Fr(br)),Br.paintProperty=Vr(Fr(Sr)),Br.layoutProperty=Vr(Fr(Ir));const Ur=Br,Nr=Ur.light,$r=Ur.paintProperty,qr=Ur.layoutProperty;function Zr(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new at(new Error(r.message))),i=!0;return i}class jr{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(let t=0;t=c[l+0]&&r>=c[l+1])?(a[u]=!0,n.push(s[u])):a[u]=!1}}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++){const c=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&s.call(this,t,e,i,r,c,n,a,o))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t=0)continue;const n=t[i];s[i]=Gr[r].shallow.indexOf(i)>=0?n:Xr(n,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(s.$name=r),s}throw new Error("can't serialize object of type "+typeof t)}function Kr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||Wr(t)||k(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Kr);if("object"==typeof t){const e=t.$name||"Object";if(!Gr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Gr[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const s=t[i];r[i]=Gr[e].shallow.indexOf(i)>=0?s:Kr(s)}return r}throw new Error("can't deserialize object of type "+typeof t)}class Yr{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function Qr(t){for(const e of t)if(ts(e.charCodeAt(0)))return!0;return!1}function ts(t){return!(746!==t&&747!==t&&(t<4352||!(Jr["Bopomofo Extended"](t)||Jr.Bopomofo(t)||Jr["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Jr["CJK Compatibility Ideographs"](t)||Jr["CJK Compatibility"](t)||Jr["CJK Radicals Supplement"](t)||Jr["CJK Strokes"](t)||!(!Jr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Jr["CJK Unified Ideographs Extension A"](t)||Jr["CJK Unified Ideographs"](t)||Jr["Enclosed CJK Letters and Months"](t)||Jr["Hangul Compatibility Jamo"](t)||Jr["Hangul Jamo Extended-A"](t)||Jr["Hangul Jamo Extended-B"](t)||Jr["Hangul Jamo"](t)||Jr["Hangul Syllables"](t)||Jr.Hiragana(t)||Jr["Ideographic Description Characters"](t)||Jr.Kanbun(t)||Jr["Kangxi Radicals"](t)||Jr["Katakana Phonetic Extensions"](t)||Jr.Katakana(t)&&12540!==t||!(!Jr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Jr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Jr["Unified Canadian Aboriginal Syllabics"](t)||Jr["Unified Canadian Aboriginal Syllabics Extended"](t)||Jr["Vertical Forms"](t)||Jr["Yijing Hexagram Symbols"](t)||Jr["Yi Syllables"](t)||Jr["Yi Radicals"](t))))}function es(t){return t>=1424&&t<=2303||Jr["Arabic Presentation Forms-A"](t)||Jr["Arabic Presentation Forms-B"](t)}function is(t,e){return!(!e&&es(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Jr.Khmer(t))}function rs(t){for(const e of t)if(es(e.charCodeAt(0)))return!0;return!1}const ss="deferred",ns="loading",as="loaded";let os=null,ls="unavailable",cs=null;const hs=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(ls="error"),os&&os(t)};function us(){ps.fire(new nt("pluginStateChange",{pluginStatus:ls,pluginURL:cs}))}const ps=new ot,ds=function(){return ls},ms=function(){if(ls!==ss||!cs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");ls=ns,us(),cs&&j({url:cs},(t=>{t?hs(t):(ls=as,us())}))},fs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>ls===as||null!=fs.applyArabicShaping,isLoading:()=>ls===ns,setState(t){if(!z())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");ls=t.pluginStatus,cs=t.pluginURL},isParsed(){if(!z())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return null!=fs.applyArabicShaping},getPluginURL(){if(!z())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return cs}};class _s{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Yr,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!is(i.charCodeAt(0),e))return!1;return!0}(t,fs.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class gs{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Ui(t))return new tr(t,e);if(Xi(t)){const i=Qi(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=he.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(i=_e.parse(t)):i=me.parse(t),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class ys{constructor(t){this.property=t,this.value=new gs(t,void 0)}transitioned(t,e){return new vs(this.property,this.value,e,g({},t.transition,this.transition),t.now)}untransitioned(){return new vs(this.property,this.value,null,{},0)}}class xs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return S(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ys(this._values[t].property)),this._values[t].value=new gs(this._values[t].property,null===e?void 0:S(e))}getTransition(t){return S(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ys(this._values[t].property)),this._values[t].transition=S(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new bs(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new bs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class vs{constructor(t,e,i,r,s){this.property=t,this.value=e,this.begin=s+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,s=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(n){if(r>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(r=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(a))}}return s}}class bs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new Ss(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class ws{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return void 0!==this._values[t].value}getValue(t){return S(this._values[t].value)}setValue(t,e){this._values[t]=new gs(this._values[t].property,null===e?void 0:S(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new Ss(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}}class Ts{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class Ss{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Is{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const r=ni[this.specification.type];return r?r(t,e,i):t}}class As{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new Ts(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Ts(this,{kind:"constant",value:void 0},t.parameters);const r=ni[this.specification.type];if(r){const s=r(t.value.value,e.value.value,i);return new Ts(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,e,i,r,s,n){return"constant"===t.kind?t.value:t.evaluate(e,i,r,s,n)}}class Es extends As{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new Ts(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r),n="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,a=this._calculate(n,n,n,e);return new Ts(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Ts(this,{kind:"constant",value:i},e)}return new Ts(this,t.expression,e)}evaluate(t,e,i,r,s,n){if("source"===t.kind){const a=t.evaluate(e,i,r,s,n);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Cs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new _s(Math.floor(e.zoom-1),e)),t.expression.evaluate(new _s(Math.floor(e.zoom),e)),t.expression.evaluate(new _s(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class zs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Ms{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new gs(i,void 0),s=this.defaultTransitionablePropertyValues[e]=new ys(i);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}Hr("DataDrivenProperty",As),Hr("DataConstantProperty",Is),Hr("CrossFadedDataDrivenProperty",Es),Hr("CrossFadedProperty",Cs),Hr("ColorRampProperty",zs);const Ps="-transition";class ks extends ot{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new ws(e.layout)),e.paint)){this._transitionablePaint=new xs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ss(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(qr,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(Ps)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate($r,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(Ps))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],s=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||s||r||this._handleOverridablePaintPropertyUpdate(t,n,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),w(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&Zr(this,t.call(Ur,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:lt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Ts&&Bi(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Ds={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ls{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Rs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Bs(t,e=1){let i=0,r=0;return{members:t.map((t=>{const s=Ds[t.type].BYTES_PER_ELEMENT,n=i=Fs(i,Math.max(e,s)),a=t.components||1;return r=Math.max(r,s),i+=s*a,{name:t.name,type:t.type,components:a,offset:n}})),size:Fs(i,Math.max(r,e)),alignment:e}}function Fs(t,e){return Math.ceil(t/e)*e}class Os extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Os.prototype.bytesPerElement=4,Hr("StructArrayLayout2i4",Os);class Vs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,t}}Vs.prototype.bytesPerElement=6,Hr("StructArrayLayout3i6",Vs);class Us extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=s,t}}Us.prototype.bytesPerElement=8,Hr("StructArrayLayout4i8",Us);class Ns extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}Ns.prototype.bytesPerElement=12,Hr("StructArrayLayout2i4i12",Ns);class $s extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=s,this.uint8[l+6]=n,this.uint8[l+7]=a,t}}$s.prototype.bytesPerElement=8,Hr("StructArrayLayout2i4ub8",$s);class qs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}qs.prototype.bytesPerElement=8,Hr("StructArrayLayout2f8",qs);class Zs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,s,n,a,o,l,c)}emplace(t,e,i,r,s,n,a,o,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=s,this.uint16[u+4]=n,this.uint16[u+5]=a,this.uint16[u+6]=o,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}Zs.prototype.bytesPerElement=20,Hr("StructArrayLayout10ui20",Zs);class js extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,s,n,a,o,l,c,h,u)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=s,this.uint16[d+4]=n,this.uint16[d+5]=a,this.uint16[d+6]=o,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=h,this.int16[d+10]=u,this.int16[d+11]=p,t}}js.prototype.bytesPerElement=24,Hr("StructArrayLayout4i4ui4i24",js);class Gs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}}Gs.prototype.bytesPerElement=12,Hr("StructArrayLayout3f12",Gs);class Hs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Hs.prototype.bytesPerElement=4,Hr("StructArrayLayout1ul4",Hs);class Ws extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,s,n,a,o,l)}emplace(t,e,i,r,s,n,a,o,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=s,this.int16[h+4]=n,this.int16[h+5]=a,this.uint32[u+3]=o,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}Ws.prototype.bytesPerElement=20,Hr("StructArrayLayout6i1ul2ui20",Ws);class Xs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}Xs.prototype.bytesPerElement=12,Hr("StructArrayLayout2i2i2i12",Xs);class Ks extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,s)}emplace(t,e,i,r,s,n){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[o+6]=s,this.int16[o+7]=n,t}}Ks.prototype.bytesPerElement=16,Hr("StructArrayLayout2f1f2i16",Ks);class Ys extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=12*t,a=3*t;return this.uint8[n+0]=e,this.uint8[n+1]=i,this.float32[a+1]=r,this.float32[a+2]=s,t}}Ys.prototype.bytesPerElement=12,Hr("StructArrayLayout2ub2f12",Ys);class Js extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=r,t}}Js.prototype.bytesPerElement=6,Hr("StructArrayLayout3ui6",Js);class Qs extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g){const y=24*t,x=12*t,v=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=s,this.uint32[x+2]=n,this.uint32[x+3]=a,this.uint32[x+4]=o,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=p,this.uint8[v+36]=d,this.uint8[v+37]=m,this.uint8[v+38]=f,this.uint32[x+10]=_,this.int16[y+22]=g,t}}Qs.prototype.bytesPerElement=48,Hr("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Qs);class tn extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,S,I,A,E){const C=this.length;return this.resize(C+1),this.emplace(C,t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,S,I,A,E)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,S,I,A,E,C){const z=32*t,M=16*t;return this.int16[z+0]=e,this.int16[z+1]=i,this.int16[z+2]=r,this.int16[z+3]=s,this.int16[z+4]=n,this.int16[z+5]=a,this.int16[z+6]=o,this.int16[z+7]=l,this.uint16[z+8]=c,this.uint16[z+9]=h,this.uint16[z+10]=u,this.uint16[z+11]=p,this.uint16[z+12]=d,this.uint16[z+13]=m,this.uint16[z+14]=f,this.uint16[z+15]=_,this.uint16[z+16]=g,this.uint16[z+17]=y,this.uint16[z+18]=x,this.uint16[z+19]=v,this.uint16[z+20]=b,this.uint16[z+21]=w,this.uint16[z+22]=T,this.uint32[M+12]=S,this.float32[M+13]=I,this.float32[M+14]=A,this.uint16[z+30]=E,this.uint16[z+31]=C,t}}tn.prototype.bytesPerElement=64,Hr("StructArrayLayout8i15ui1ul2f2ui64",tn);class en extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}en.prototype.bytesPerElement=4,Hr("StructArrayLayout1f4",en);class rn extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.uint16[6*t+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}}rn.prototype.bytesPerElement=12,Hr("StructArrayLayout1ui2f12",rn);class sn extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,t}}sn.prototype.bytesPerElement=8,Hr("StructArrayLayout1ul2ui8",sn);class nn extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}nn.prototype.bytesPerElement=4,Hr("StructArrayLayout2ui4",nn);class an extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}an.prototype.bytesPerElement=2,Hr("StructArrayLayout1ui2",an);class on extends Rs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=s,t}}on.prototype.bytesPerElement=16,Hr("StructArrayLayout4f16",on);class ln extends Ls{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}ln.prototype.size=20;class cn extends Ws{get(t){return new ln(this,t)}}Hr("CollisionBoxArray",cn);class hn extends Ls{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}hn.prototype.size=48;class un extends Qs{get(t){return new hn(this,t)}}Hr("PlacedSymbolArray",un);class pn extends Ls{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}pn.prototype.size=64;class dn extends tn{get(t){return new pn(this,t)}}Hr("SymbolInstanceArray",dn);class mn extends en{getoffsetX(t){return this.float32[1*t+0]}}Hr("GlyphOffsetArray",mn);class fn extends Vs{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Hr("SymbolLineVertexArray",fn);class _n extends Ls{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}_n.prototype.size=12;class gn extends rn{get(t){return new _n(this,t)}}Hr("TextAnchorOffsetArray",gn);class yn extends Ls{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}yn.prototype.size=8;class xn extends sn{get(t){return new yn(this,t)}}Hr("FeatureIndexArray",xn);class vn extends Os{}class bn extends Vs{}class wn extends Us{}class Tn extends Os{}class Sn extends Os{}class In extends Ns{}class An extends $s{}class En extends qs{}class Cn extends Zs{}class zn extends js{}class Mn extends Gs{}class Pn extends Hs{}class kn extends Xs{}class Dn extends Ks{}class Ln extends Ys{}class Rn extends Js{}class Bn extends Js{}class Fn extends nn{}class On extends an{}const Vn=Bs([{name:"a_pos",components:2,type:"Int16"}],4),{members:Un}=Vn;class Nn{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let s=this.segments[this.segments.length-1];return t>Nn.MAX_VERTEX_ARRAY_LENGTH&&A(`Max vertices per segment is ${Nn.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!s||s.vertexLength+t>Nn.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==r)&&(s={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(s.sortKey=r),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new Nn([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function $n(t,e){return 256*(t=m(Math.floor(t),0,255))+m(Math.floor(e),0,255)}Nn.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Hr("SegmentVector",Nn);const qn=Bs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Zn={exports:{}},jn={exports:{}};!function(t){t.exports=function(t,e){var i,r,s,n,a,o,l,c;for(r=t.length-(i=3&t.length),s=e,a=3432918353,o=461845907,c=0;c>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295}return s^=t.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}(jn);var Gn=jn.exports,Hn={exports:{}};!function(t){t.exports=function(t,e){for(var i,r=t.length,s=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:s^=(255&t.charCodeAt(n+2))<<16;case 2:s^=(255&t.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}(Hn);var Wn=Gn,Xn=Hn.exports;Zn.exports=Wn,Zn.exports.murmur3=Wn,Zn.exports.murmur2=Xn;var Kn=i(Zn.exports);class Yn{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Jn(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=Jn(t);let i=0,r=this.ids.length-1;for(;i>1;this.ids[t]>=e?r=t:i=t+1}const s=[];for(;this.ids[i]===e;)s.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return s}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Qn(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Yn;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Jn(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Kn(String(t))}function Qn(t,e,i,r){for(;i>1];let n=i-1,a=r+1;for(;;){do{n++}while(t[n]s);if(n>=a)break;ta(t,n,a),ta(e,3*n,3*a),ta(e,3*n+1,3*a+1),ta(e,3*n+2,3*a+2)}a-i`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new oa(t,e):new ra(t,e)}}class pa{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,i,r){const s="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;s&&t.set(s)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)?new aa(t,e):new ra(t,e)}}class da{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,s){const n=this.paintVertexArray.length,a=this.expression.evaluate(new _s(0),e,{},r,[],s);this.paintVertexArray.resize(t),this._setPaintValue(n,t,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=ha(i);for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,r,s){const n=this.expression.evaluate(new _s(this.zoom),e,{},r,[],s),a=this.expression.evaluate(new _s(this.zoom+1),e,{},r,[],s),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,n,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:this.zoom},i,r),n=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,s,n)}_setPaintValue(t,e,i,r){if("color"===this.type){const s=ha(i),n=ha(r);for(let i=t;i`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof da||i instanceof ma)for(let e=0;e!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new _a(r,e,i);this.needsUpload=!1,this._featureMap=new Yn,this._bufferOffset=0}populatePaintArrays(t,e,i,r,s,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,s,n);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function ya(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function xa(t,e,i){const r={color:{source:qs,composite:on},number:{source:en,composite:qs}},s=function(t){return{"line-pattern":{source:Cn,composite:Cn},"fill-pattern":{source:Cn,composite:Cn},"fill-extrusion-pattern":{source:Cn,composite:Cn}}[t]}(t);return s&&s[i]||r[e][i]}Hr("ConstantBinder",ua),Hr("CrossFadedConstantBinder",pa),Hr("SourceExpressionBinder",da),Hr("CrossFadedCompositeBinder",fa),Hr("CompositeExpressionBinder",ma),Hr("ProgramConfiguration",_a,{omit:["_buffers"]}),Hr("ProgramConfigurationSet",ga);const va=8192,ba=Math.pow(2,14)-1,wa=-ba-1;function Ta(t){const e=va/t.extent,i=t.loadGeometry();for(let t=0;ti.x+1||ni.y+1)&&A("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Sa(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Ta(t):[]}}function Ia(t,e,i,r,s){t.emplaceBack(2*e+(r+1)/2,2*i+(s+1)/2)}class Aa{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Tn,this.indexArray=new Bn,this.segments=new Nn,this.programConfigurations=new ga(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],s=[];let n=null,a=!1;"circle"===r.type&&(n=r.layout.get("circle-sort-key"),a=!n.isConstant());for(const{feature:e,id:r,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Sa(e,t);if(!this.layers[0]._featureFilter.filter(new _s(this.zoom),c,i))continue;const h=a?n.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:Ta(e),patterns:{},sortKey:h};s.push(u)}a&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:s,index:n,sourceLayerIndex:a}=r,o=t[n].feature;this.addFeature(r,s,n,i),e.featureIndex.insert(o,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Un),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=va||r<0||r>=va)continue;const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),n=s.vertexLength;Ia(this.layoutVertexArray,i,r,-1,-1),Ia(this.layoutVertexArray,i,r,1,-1),Ia(this.layoutVertexArray,i,r,1,1),Ia(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(n,n+1,n+2),this.indexArray.emplaceBack(n,n+3,n+2),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function Ea(t,e){for(let i=0;i1){if(Pa(t,e))return!0;for(let r=0;r1?i:i.sub(e)._mult(s)._add(e))}function Ra(t,e){let i,r,s,n=!1;for(let a=0;ae.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n}function Ba(t,e){let i=!1;for(let r=0,s=t.length-1;re.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i)}return i}function Fa(t,e,i){const r=i[0],s=i[2];if(t.xs.x&&e.x>s.x||t.ys.y&&e.y>s.y)return!1;const n=E(t,e,i[0]);return n!==E(t,e,i[1])||n!==E(t,e,i[2])||n!==E(t,e,i[3])}function Oa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Va(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ua(t,e,i,r,s){if(!e[0]&&!e[1])return t;const a=n.convert(e)._mult(s);"viewport"===i&&a._rotate(-r);const o=[];for(let e=0;eoo(t,e)))}(l,o),p=h?c*a:c;for(const t of r)for(const e of t){const t=h?e:oo(e,o);let i=p;const r=so([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r[3]/n.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=n.cameraToCenterDistance/r[3]),Ca(u,t,i))return!0}return!1}}function oo(t,e){const i=so([],[t.x,t.y,0,1],e);return new n(i[0]/i[3],i[1]/i[3])}class lo extends Aa{}let co;Hr("HeatmapBucket",lo,{omit:["layers"]});var ho={get paint(){return co=co||new Ms({"heatmap-radius":new As(lt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new As(lt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Is(lt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new zs(lt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Is(lt.paint_heatmap["heatmap-opacity"])})}};function uo(t,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${s.length} but got: ${e*i*r}`)}else s=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=s,t}function po(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const s=uo({},{width:e,height:i},r);mo(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=s.data}function mo(t,e,i,r,s,n){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=n;const a=t.expression.evaluate(e);s.data[i+r+0]=Math.floor(255*a.r/a.a),s.data[i+r+1]=Math.floor(255*a.g/a.a),s.data[i+r+2]=Math.floor(255*a.b/a.a),s.data[i+r+3]=Math.floor(255*a.a)};if(t.clips)for(let e=0,s=0;e80*i){r=n=t[0],s=a=t[1];for(var m=i;mn&&(n=o),l>a&&(a=l);c=0!==(c=Math.max(n-r,a-s))?32767/c:0}return Co(p,d,i,r,s,c,0),d}function Ao(t,e,i,r,s){var n,a;if(s===Ko(t,e,i,r)>0)for(n=e;n=e;n-=r)a=Ho(n,t[n],t[n+1],a);return a&&No(a,a.next)&&(Wo(a),a=a.next),a}function Eo(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!No(r,r.next)&&0!==Uo(r.prev,r,r.next))r=r.next;else{if(Wo(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Co(t,e,i,r,s,n,a){if(t){!a&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=Bo(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,a,o,l,c=1;do{for(i=t,t=null,n=null,a=0;i;){for(a++,r=i,o=0,e=0;e0||l>0&&r;)0!==o&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,c*=2}while(a>1)}(s)}(t,r,s,n);for(var o,l,c=t;t.prev!==t.next;)if(o=t.prev,l=t.next,n?Mo(t,r,s,n):zo(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Wo(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Co(t=Po(Eo(t),e,i),e,i,r,s,n,2):2===a&&ko(t,e,i,r,s,n):Co(Eo(t),e,i,r,s,n,1);break}}}function zo(t){var e=t.prev,i=t,r=t.next;if(Uo(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,a=r.x,o=e.y,l=i.y,c=r.y,h=sn?s>a?s:a:n>a?n:a,d=o>l?o>c?o:c:l>c?l:c,m=r.next;m!==e;){if(m.x>=h&&m.x<=p&&m.y>=u&&m.y<=d&&Oo(s,o,n,l,a,c,m.x,m.y)&&Uo(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Mo(t,e,i,r){var s=t.prev,n=t,a=t.next;if(Uo(s,n,a)>=0)return!1;for(var o=s.x,l=n.x,c=a.x,h=s.y,u=n.y,p=a.y,d=ol?o>c?o:c:l>c?l:c,_=h>u?h>p?h:p:u>p?u:p,g=Bo(d,m,e,i,r),y=Bo(f,_,e,i,r),x=t.prevZ,v=t.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=d&&x.x<=f&&x.y>=m&&x.y<=_&&x!==s&&x!==a&&Oo(o,h,l,u,c,p,x.x,x.y)&&Uo(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=d&&v.x<=f&&v.y>=m&&v.y<=_&&v!==s&&v!==a&&Oo(o,h,l,u,c,p,v.x,v.y)&&Uo(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=f&&x.y>=m&&x.y<=_&&x!==s&&x!==a&&Oo(o,h,l,u,c,p,x.x,x.y)&&Uo(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=f&&v.y>=m&&v.y<=_&&v!==s&&v!==a&&Oo(o,h,l,u,c,p,v.x,v.y)&&Uo(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Po(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!No(s,n)&&$o(s,r,r.next,n)&&jo(s,n)&&jo(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),Wo(r),Wo(r.next),r=t=n),r=r.next}while(r!==t);return Eo(r)}function ko(t,e,i,r,s,n){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Vo(a,o)){var l=Go(a,o);return a=Eo(a,a.next),l=Eo(l,l.next),Co(a,e,i,r,s,n,0),void Co(l,e,i,r,s,n,0)}o=o.next}a=a.next}while(a!==t)}function Do(t,e){return t.x-e.x}function Lo(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,a=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var o=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=s&&o>a&&(a=o,i=r.x=r.x&&r.x>=h&&s!==r.x&&Oo(ni.x||r.x===i.x&&Ro(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Go(i,t);return Eo(r,r.next),Eo(i,i.next)}function Ro(t,e){return Uo(t.prev,t,e.prev)<0&&Uo(e.next,t,t.next)<0}function Bo(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Fo(t){var e=t,i=t;do{(e.x=(t-a)*(n-o)&&(t-a)*(r-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function Vo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&$o(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(jo(t,e)&&jo(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Uo(t.prev,t,e.prev)||Uo(t,e.prev,e))||No(t,e)&&Uo(t.prev,t,t.next)>0&&Uo(e.prev,e,e.next)>0)}function Uo(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function No(t,e){return t.x===e.x&&t.y===e.y}function $o(t,e,i,r){var s=Zo(Uo(t,e,i)),n=Zo(Uo(t,e,r)),a=Zo(Uo(i,r,t)),o=Zo(Uo(i,r,e));return s!==n&&a!==o||!(0!==s||!qo(t,i,e))||!(0!==n||!qo(t,r,e))||!(0!==a||!qo(i,t,r))||!(0!==o||!qo(i,e,r))}function qo(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Zo(t){return t>0?1:t<0?-1:0}function jo(t,e){return Uo(t.prev,t,t.next)<0?Uo(t,e,t.next)>=0&&Uo(t,t.prev,e)>=0:Uo(t,e,t.prev)<0||Uo(t,t.next,e)<0}function Go(t,e){var i=new Xo(t.i,t.x,t.y),r=new Xo(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Ho(t,e,i,r){var s=new Xo(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Wo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Xo(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ko(t,e,i,r){for(var s=0,n=e,a=i-r;n0&&i.holes.push(r+=t[s-1].length)}return i};var Yo=i(So.exports);function Jo(t,e,i,r,s){Qo(t,e,i||0,r||t.length-1,s||el)}function Qo(t,e,i,r,s){for(;r>i;){if(r-i>600){var n=r-i+1,a=e-i+1,o=Math.log(n),l=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*l*(n-l)/n)*(a-n/2<0?-1:1);Qo(t,e,Math.max(i,Math.floor(e-a*l/n+c)),Math.min(r,Math.floor(e+(n-a)*l/n+c)),s)}var h=t[e],u=i,p=r;for(tl(t,i,e),s(t[r],h)>0&&tl(t,i,r);u0;)p--}0===s(t[i],h)?tl(t,i,p):tl(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function tl(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function el(t,e){return te?1:0}function il(t,e){const i=t.length;if(i<=1)return[t];const r=[];let s,n;for(let e=0;e1)for(let t=0;tt.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Sn,this.indexArray=new Bn,this.indexArray2=new Fn,this.programConfigurations=new ga(t.layers,t.zoom),this.segments=new Nn,this.segments2=new Nn,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=sl("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),s=!r.isConstant(),n=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=Sa(a,t);if(!this.layers[0]._featureFilter.filter(new _s(this.zoom),h,i))continue;const u=s?r.evaluate(h,{},i,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Ta(a),patterns:{},sortKey:u};n.push(p)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=nl("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,To),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,s){for(const t of il(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,s=[],n=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&n.push(s.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),s.push(e[0].x),s.push(e[0].y);for(let t=1;t>3}if(s--,1===r||2===r)n+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&o.push(e),e=[]),e.push(new fl(n,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&o.push(e),o},gl.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,s=0,n=0,a=1/0,o=-1/0,l=1/0,c=-1/0;t.pos>3}if(r--,1===i||2===i)(s+=t.readSVarint())o&&(o=s),(n+=t.readSVarint())c&&(c=n);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,o,c]},gl.prototype.toGeoJSON=function(t,e,i){var r,s,n=this.extent*Math.pow(2,i),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),c=gl.types[this.type];function h(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}wl.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new vl(this._pbf,e,this.extent,this._keys,this._values)};var Sl=bl;function Il(t,e,i){if(3===t){var r=new Sl(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}ml.VectorTile=function(t,e){this.layers=t.readFields(Il,{},e)},ml.VectorTileFeature=_l,ml.VectorTileLayer=bl;const Al=ml.VectorTileFeature.types,El=Math.pow(2,13);function Cl(t,e,i,r,s,n,a,o){t.emplaceBack(e,i,2*Math.floor(r*El)+a,s*El*2,n*El*2,Math.round(o))}class zl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new In,this.centroidVertexArray=new vn,this.indexArray=new Bn,this.programConfigurations=new ga(t.layers,t.zoom),this.segments=new Nn,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=sl("fill-extrusion",this.layers,e);for(const{feature:r,id:s,index:n,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=Sa(r,t);if(!this.layers[0]._featureFilter.filter(new _s(this.zoom),o,i))continue;const l={id:s,sourceLayerIndex:a,index:n,geometry:t?o.geometry:Ta(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(nl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,n,i,{}),e.featureIndex.insert(r,l.geometry,n,a,this.index,!0)}}addFeatures(t,e,i){for(const t of this.features){const{geometry:r}=t;this.addFeature(t,r,t.index,e,i)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,dl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,pl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,s){const n={x:0,y:0,vertexCount:0};for(const i of il(e,500)){let e=0;for(const t of i)e+=t.length;let r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of i){if(0===t.length)continue;if(Pl(t))continue;let e=0;for(let i=0;i=1){const a=t[i-1];if(!Ml(s,a)){r.vertexLength+4>Nn.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(a)._perp()._unit(),i=a.dist(s);e+i>32768&&(e=0),Cl(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,e),Cl(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,e),n.x+=2*s.x,n.y+=2*s.y,n.vertexCount+=2,e+=i,Cl(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,e),Cl(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,e),n.x+=2*a.x,n.y+=2*a.y,n.vertexCount+=2;const o=r.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+e>Nn.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==Al[t.type])continue;const s=[],a=[],o=r.vertexLength;for(const t of i)if(0!==t.length){t!==i[0]&&a.push(s.length/2);for(let e=0;eva)||t.y===e.y&&(t.y<0||t.y>va)}function Pl(t){return t.every((t=>t.x<0))||t.every((t=>t.x>va))||t.every((t=>t.y<0))||t.every((t=>t.y>va))}let kl;Hr("FillExtrusionBucket",zl,{omit:["layers","features"]});var Dl={get paint(){return kl=kl||new Ms({"fill-extrusion-opacity":new Is(lt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new As(lt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Is(lt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Is(lt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Es(lt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new As(lt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new As(lt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Is(lt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Ll extends ks{constructor(t){super(t,Dl)}createBucket(t){return new zl(t)}queryRadius(){return Va(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,i,r,s,a,o,l){const c=Ua(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,o),h=this.paint.get("fill-extrusion-height").evaluate(e,i),u=this.paint.get("fill-extrusion-base").evaluate(e,i),p=function(t,e,i,r){const s=[];for(const i of t){const t=[i.x,i.y,0,1];so(t,t,e),s.push(new n(t[0]/t[3],t[1]/t[3]))}return s}(c,l),d=function(t,e,i,r){const s=[],a=[],o=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,p=r[9]*i,d=r[10]*i,m=r[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x,a=s.y,f=r[0]*e+r[4]*a+r[12],_=r[1]*e+r[5]*a+r[13],g=r[2]*e+r[6]*a+r[14],y=r[3]*e+r[7]*a+r[15],x=g+c,v=y+h,b=f+u,w=_+p,T=g+d,S=y+m,I=new n((f+o)/v,(_+l)/v);I.z=x/v,t.push(I);const A=new n(b/S,w/S);A.z=T/S,i.push(A)}s.push(t),a.push(i)}return[s,a]}(r,u,h,l);return function(t,e,i){let r=1/0;za(i,e)&&(r=Bl(i,e[0]));for(let s=0;st.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new An,this.layoutVertexArray2=new En,this.indexArray=new Bn,this.programConfigurations=new ga(t.layers,t.zoom),this.segments=new Nn,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=sl("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),s=!r.isConstant(),n=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Sa(e,t);if(!this.layers[0]._featureFilter.filter(new _s(this.zoom),c,i))continue;const h=s?r.evaluate(c,{},i):void 0,u={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:Ta(e),patterns:{},sortKey:h};n.push(u)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=nl("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ul)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ol),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,s){const n=this.layers[0].layout,a=n.get("line-join").evaluate(t,{}),o=n.get("line-cap"),l=n.get("line-miter-limit"),c=n.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,o,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}addLine(t,e,i,r,s,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(b&&e>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,m,0,0,h),p=e}}const T=p&&d;let S=T?i:a?"butt":r;if(T&&"round"===S&&(xs&&(S="bevel"),"bevel"===S&&(x>2&&(S="flipbevel"),x100)_=f.mult(-1);else{const t=x*m.add(f).mag()/m.sub(f).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,m,e,i,h),"fakeround"===S){const t=Math.round(180*v/Math.PI/20);for(let e=1;e2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,f,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,s,n=!1){const a=e.y*r-e.x,o=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,s),this.addHalfVertex(t,a,o,n,!0,-r,s),this.distance>ql/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,s,n))}addHalfVertex({x:t,y:e},i,r,s,n,a,o){const l=.5*(this.lineClips?this.scaledDistance*(ql-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(s?1:0),(e<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),o.primitiveLength++),n?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let jl,Gl;Hr("LineBucket",Zl,{omit:["layers","patternFeatures"]});var Hl={get paint(){return Gl=Gl||new Ms({"line-opacity":new As(lt.paint_line["line-opacity"]),"line-color":new As(lt.paint_line["line-color"]),"line-translate":new Is(lt.paint_line["line-translate"]),"line-translate-anchor":new Is(lt.paint_line["line-translate-anchor"]),"line-width":new As(lt.paint_line["line-width"]),"line-gap-width":new As(lt.paint_line["line-gap-width"]),"line-offset":new As(lt.paint_line["line-offset"]),"line-blur":new As(lt.paint_line["line-blur"]),"line-dasharray":new Cs(lt.paint_line["line-dasharray"]),"line-pattern":new Es(lt.paint_line["line-pattern"]),"line-gradient":new zs(lt.paint_line["line-gradient"])})},get layout(){return jl=jl||new Ms({"line-cap":new Is(lt.layout_line["line-cap"]),"line-join":new As(lt.layout_line["line-join"]),"line-miter-limit":new Is(lt.layout_line["line-miter-limit"]),"line-round-limit":new Is(lt.layout_line["line-round-limit"]),"line-sort-key":new As(lt.layout_line["line-sort-key"])})}};class Wl extends As{possiblyEvaluate(t,e){return e=new _s(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=g({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}let Xl;class Kl extends ks{constructor(t){super(t,Hl),this.gradientVersion=0,Xl||(Xl=new Wl(Hl.paint.properties["line-width"].specification),Xl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof ii,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Xl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Zl(t)}queryRadius(t){const e=t,i=Yl(Oa("line-width",this,e),Oa("line-gap-width",this,e)),r=Oa("line-offset",this,e);return i/2+Math.abs(r)+Va(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,s,a,o){const l=Ua(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,o),c=o/2*Yl(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),h=this.paint.get("line-offset").evaluate(e,i);return h&&(r=function(t,e){const i=[];for(let r=0;r=3)for(let e=0;e0?e+2*t:t}const Jl=Bs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ql=Bs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Bs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const tc=Bs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Bs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const ec=Bs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),ic=Bs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function rc(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),t}(t.text,e,i)})),t}Bs([{name:"triangle",components:3,type:"Uint16"}]),Bs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Bs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Bs([{type:"Float32",name:"offsetX"}]),Bs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Bs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const sc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var nc=lc,ac=function(t,e,i,r,s){var n,a,o=8*s-r-1,l=(1<>1,h=-7,u=i?s-1:0,p=i?-1:1,d=t[e+u];for(u+=p,n=d&(1<<-h)-1,d>>=-h,h+=o;h>0;n=256*n+t[e+u],u+=p,h-=8);for(a=n&(1<<-h)-1,n>>=-h,h+=r;h>0;a=256*a+t[e+u],u+=p,h-=8);if(0===n)n=1-c;else{if(n===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),n-=c}return(d?-1:1)*a*Math.pow(2,n-r)},oc=function(t,e,i,r,s,n){var a,o,l,c=8*n-s-1,h=(1<>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:n-1,m=r?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(a++,l/=2),a+u>=h?(o=0,a=h):a+u>=1?(o=(e*l-1)*Math.pow(2,s),a+=u):(o=e*Math.pow(2,u-1)*Math.pow(2,s),a=0));s>=8;t[i+d]=255&o,d+=m,o/=256,s-=8);for(a=a<0;t[i+d]=255&a,d+=m,a/=256,c-=8);t[i+d-m]|=128*f};function lc(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}lc.Varint=0,lc.Fixed64=1,lc.Bytes=2,lc.Fixed32=5;var cc=4294967296,hc=1/cc,uc="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function pc(t){return t.type===lc.Bytes?t.readVarint()+t.pos:t.pos+1}function dc(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function mc(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var s=i.pos-1;s>=t;s--)i.buf[s+r]=i.buf[s]}function fc(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Ac(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}lc.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos>3,n=this.pos;this.type=7&r,t(s,e,this),this.pos===n&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Sc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Ac(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Sc(this.buf,this.pos)+Sc(this.buf,this.pos+4)*cc;return this.pos+=8,t},readSFixed64:function(){var t=Sc(this.buf,this.pos)+Ac(this.buf,this.pos+4)*cc;return this.pos+=8,t},readFloat:function(){var t=ac(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ac(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,s,n=i.buf;if(r=(112&(s=n[i.pos++]))>>4,s<128)return dc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<3,s<128)return dc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<10,s<128)return dc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<17,s<128)return dc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<24,s<128)return dc(t,r,e);if(r|=(1&(s=n[i.pos++]))<<31,s<128)return dc(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&uc?function(t,e,i){return uc.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",s=e;s239?4:l>223?3:l>191?2:1;if(s+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(n=t[s+1]))&&(c=(31&l)<<6|63&n)<=127&&(c=null):3===h?(a=t[s+2],128==(192&(n=t[s+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&n)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(a=t[s+2],o=t[s+3],128==(192&(n=t[s+1]))&&128==(192&a)&&128==(192&o)&&((c=(15&l)<<18|(63&n)<<12|(63&a)<<6|63&o)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),s+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==lc.Bytes)return t.push(this.readVarint(e));var i=pc(this);for(t=t||[];this.pos127;);else if(e===lc.Bytes)this.pos=this.readVarint()+this.pos;else if(e===lc.Fixed32)this.pos+=4;else{if(e!==lc.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,s,n=0;n55295&&r<57344){if(!s){r>56319||n+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):s=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,s=r;continue}r=s-55296<<10|r-56320|65536,s=null}else s&&(t[i++]=239,t[i++]=191,t[i++]=189,s=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&mc(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),oc(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),oc(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&mc(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,lc.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,fc,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,_c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,xc,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,gc,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,yc,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,vc,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,bc,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,wc,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Tc,e)},writeBytesField:function(t,e){this.writeTag(t,lc.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,lc.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,lc.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,lc.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,lc.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,lc.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,lc.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,lc.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,lc.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,lc.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Ec=i(nc);const Cc=3;function zc(t,e,i){1===t&&i.readMessage(Mc,e)}function Mc(t,e,i){if(3===t){const{id:t,bitmap:r,width:s,height:n,left:a,top:o,advance:l}=i.readMessage(Pc,{});e.push({id:t,bitmap:new fo({width:s+2*Cc,height:n+2*Cc},r),metrics:{width:s,height:n,left:a,top:o,advance:l}})}}function Pc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function kc(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,n=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();tt.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ha([]),this.placementViewportMatrix=Ha([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Oc(this.zoom,e["text-size"]),this.iconSizeData=Oc(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),s=i.get("symbol-z-order");this.canOverlap="never"!==Nc(i,"text-overlap","text-allow-overlap")||"never"!==Nc(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((t=>Lc[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Hc(new ga(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Hc(new ga(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mn,this.lineVertexArray=new fn,this.symbolInstances=new dn,this.textAnchorOffsets=new gn}calculateGlyphDependencies(t,e,i,r,s){for(let n=0;n0)&&("constant"!==n.value.kind||n.value.value.length>0),c="constant"!==o.value.kind||!!o.value.value||Object.keys(o.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!l&&!c)return;const u=e.iconDependencies,p=e.glyphDependencies,d=e.availableImages,m=new _s(this.zoom);for(const{feature:e,id:a,index:o,sourceLayerIndex:f}of t){const t=r._featureFilter.needGeometry,_=Sa(e,t);if(!r._featureFilter.filter(m,_,i))continue;let g,y;if(t||(_.geometry=Ta(e)),l){const t=r.getValueAndResolveTokens("text-field",_,i,d),e=de.factory(t);Gc(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ds()||this.hasRTLText&&fs.isParsed())&&(g=rc(e,r,_))}if(c){const t=r.getValueAndResolveTokens("icon-image",_,i,d);y=t instanceof ge?t:ge.fromString(t)}if(!g&&!y)continue;const x=this.sortFeaturesByKey?h.evaluate(_,{},i):void 0;if(this.features.push({id:a,text:g,icon:y,index:o,sourceLayerIndex:f,geometry:_.geometry,properties:e.properties,type:$c[e.type],sortKey:x}),y&&(u[y.name]=!0),g){const t=n.evaluate(_,{},i).join(","),e="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Lc.vertical)>=0;for(const i of g.sections)if(i.image)u[i.image.name]=!0;else{const r=Qr(g.toString()),s=i.fontStack||t,n=p[s]=p[s]||{};this.calculateGlyphDependencies(i.text,n,e,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let s=0;function n(e){r.push(t[e]),s++}function a(t,e,s){const n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(s[0]),n}function o(t,i,s){const n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=s[0].concat(r[n].geometry[0]),n}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const s={};for(let r=t.segment+1;r=0;i--)s[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;er[t]-r[e]||s[e]-s[t])),n}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Kc,Yc;Hr("SymbolBucket",Xc,{omit:["layers","collisionBoxArray","features","compareText"]}),Xc.MAX_GLYPHS=65535,Xc.addDynamicAttributes=jc;var Jc={get paint(){return Yc=Yc||new Ms({"icon-opacity":new As(lt.paint_symbol["icon-opacity"]),"icon-color":new As(lt.paint_symbol["icon-color"]),"icon-halo-color":new As(lt.paint_symbol["icon-halo-color"]),"icon-halo-width":new As(lt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new As(lt.paint_symbol["icon-halo-blur"]),"icon-translate":new Is(lt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Is(lt.paint_symbol["icon-translate-anchor"]),"text-opacity":new As(lt.paint_symbol["text-opacity"]),"text-color":new As(lt.paint_symbol["text-color"],{runtimeType:zt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new As(lt.paint_symbol["text-halo-color"]),"text-halo-width":new As(lt.paint_symbol["text-halo-width"]),"text-halo-blur":new As(lt.paint_symbol["text-halo-blur"]),"text-translate":new Is(lt.paint_symbol["text-translate"]),"text-translate-anchor":new Is(lt.paint_symbol["text-translate-anchor"])})},get layout(){return Kc=Kc||new Ms({"symbol-placement":new Is(lt.layout_symbol["symbol-placement"]),"symbol-spacing":new Is(lt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Is(lt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new As(lt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Is(lt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Is(lt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Is(lt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Is(lt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Is(lt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Is(lt.layout_symbol["icon-rotation-alignment"]),"icon-size":new As(lt.layout_symbol["icon-size"]),"icon-text-fit":new Is(lt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Is(lt.layout_symbol["icon-text-fit-padding"]),"icon-image":new As(lt.layout_symbol["icon-image"]),"icon-rotate":new As(lt.layout_symbol["icon-rotate"]),"icon-padding":new As(lt.layout_symbol["icon-padding"]),"icon-keep-upright":new Is(lt.layout_symbol["icon-keep-upright"]),"icon-offset":new As(lt.layout_symbol["icon-offset"]),"icon-anchor":new As(lt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Is(lt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Is(lt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Is(lt.layout_symbol["text-rotation-alignment"]),"text-field":new As(lt.layout_symbol["text-field"]),"text-font":new As(lt.layout_symbol["text-font"]),"text-size":new As(lt.layout_symbol["text-size"]),"text-max-width":new As(lt.layout_symbol["text-max-width"]),"text-line-height":new Is(lt.layout_symbol["text-line-height"]),"text-letter-spacing":new As(lt.layout_symbol["text-letter-spacing"]),"text-justify":new As(lt.layout_symbol["text-justify"]),"text-radial-offset":new As(lt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Is(lt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new As(lt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new As(lt.layout_symbol["text-anchor"]),"text-max-angle":new Is(lt.layout_symbol["text-max-angle"]),"text-writing-mode":new Is(lt.layout_symbol["text-writing-mode"]),"text-rotate":new As(lt.layout_symbol["text-rotate"]),"text-padding":new Is(lt.layout_symbol["text-padding"]),"text-keep-upright":new Is(lt.layout_symbol["text-keep-upright"]),"text-transform":new As(lt.layout_symbol["text-transform"]),"text-offset":new As(lt.layout_symbol["text-offset"]),"text-allow-overlap":new Is(lt.layout_symbol["text-allow-overlap"]),"text-overlap":new Is(lt.layout_symbol["text-overlap"]),"text-ignore-placement":new Is(lt.layout_symbol["text-ignore-placement"]),"text-optional":new Is(lt.layout_symbol["text-optional"])})}};class Qc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:It,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Hr("FormatSectionOverride",Qc,{omit:["defaultValue"]});class th extends ks{constructor(t){super(t,Jc)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const s=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||Xi(n.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,s)}createBucket(t){return new Xc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Jc.paint.overridableProperties){if(!th.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Qc(e),r=new Wi(i,e.property.specification);let s=null;s="constant"===e.value.kind||"source"===e.value.kind?new Yi("source",r):new Ji("composite",r,e.value.zoomStops),this.paint._values[t]=new Ts(e.property,s,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&th.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Jc.paint.properties[e];let s=!1;const n=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(s=!0)};if("constant"===i.value.kind&&i.value.value instanceof de)n(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{s||(e instanceof we&&ve(e.value)===Dt?n(e.value.sections):e instanceof Ai?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}}let eh;var ih={get paint(){return eh=eh||new Ms({"background-color":new Is(lt.paint_background["background-color"]),"background-pattern":new Cs(lt.paint_background["background-pattern"]),"background-opacity":new Is(lt.paint_background["background-opacity"])})}};class rh extends ks{constructor(t){super(t,ih)}}let sh;var nh={get paint(){return sh=sh||new Ms({"raster-opacity":new Is(lt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Is(lt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Is(lt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Is(lt.paint_raster["raster-brightness-max"]),"raster-saturation":new Is(lt.paint_raster["raster-saturation"]),"raster-contrast":new Is(lt.paint_raster["raster-contrast"]),"raster-resampling":new Is(lt.paint_raster["raster-resampling"]),"raster-fade-duration":new Is(lt.paint_raster["raster-fade-duration"])})}};class ah extends ks{constructor(t){super(t,nh)}}class oh extends ks{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}function lh(t){if("custom"===t.type)return new oh(t);switch(t.type){case"background":return new rh(t);case"circle":return new ao(t);case"fill":return new hl(t);case"fill-extrusion":return new Ll(t);case"heatmap":return new yo(t);case"hillshade":return new bo(t);case"line":return new Kl(t);case"raster":return new ah(t);case"symbol":return new th(t)}}function ch(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:r,url:s}of t){const t=`${r}${s}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:r,url:s}))}}return e}function hh(t,e,i,r,s){if(r)return void t(r);if(s!==Object.values(e).length||s!==Object.values(i).length)return;const n={};for(const t in e){n[t]={};const r=B.getImageCanvasContext(i[t]),s=e[t];for(const e in s){const{width:i,height:a,x:o,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:p,content:d}=s[e];n[t][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:p,content:d,spriteData:{width:i,height:a,x:o,y:l,context:r}}}}t(null,n)}class uh{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:s}=t,n=!(this.size&&this.size[0]===r&&this.size[1]===s||i),{context:a}=this,{gl:o}=a;if(this.useMipmap=Boolean(e&&e.useMipmap),o.bindTexture(o.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA&&(!e||!1!==e.premultiply)),n)this.size=[r,s],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||k(t)?o.texImage2D(o.TEXTURE_2D,0,this.format,this.format,o.UNSIGNED_BYTE,t):o.texImage2D(o.TEXTURE_2D,0,this.format,r,s,0,this.format,o.UNSIGNED_BYTE,t.data);else{const{x:e,y:n}=i||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||k(t)?o.texSubImage2D(o.TEXTURE_2D,0,e,n,o.RGBA,o.UNSIGNED_BYTE,t):o.texSubImage2D(o.TEXTURE_2D,0,e,n,r,s,o.RGBA,o.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i){const{context:r}=this,{gl:s}=r;s.bindTexture(s.TEXTURE_2D,this.texture),i!==s.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function ph(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class dh extends ot{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new _o({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){const e=this.images[t];if(e&&!e.data&&e.spriteData){const t=e.spriteData;e.data=new _o({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),e.spriteData=null}return e}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,e){let i=!0;const r=e.data||e.spriteData;return this._validateStretch(e.stretchX,r&&r.width)||(this.fire(new at(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,r&&r.height)||(this.fire(new at(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new at(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]-1);l++,n[l]=o,a[l]=c,a[l+1]=mh}for(let o=0,l=0;o{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{}});let s=r.glyphs[e];if(void 0!==s)return void i(null,{stack:t,id:e,glyph:s});if(s=this._tinySDF(r,t,e),s)return r.glyphs[e]=s,void i(null,{stack:t,id:e,glyph:s});const n=Math.floor(e/256);if(256*n>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[n])return void i(null,{stack:t,id:e,glyph:s});if(!this.url)return void i(new Error("glyphsUrl is not set"));let a=r.requests[n];a||(a=r.requests[n]=[],gh.loadGlyphRange(t,n,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e[+t]);r.ranges[n]=!0}for(const i of a)i(t,e);delete r.requests[n]}))),a.push(((r,s)=>{r?i(r):s&&i(null,{stack:t,id:e,glyph:s[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:s}of i)(t[e]||(t[e]={}))[r]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};e(null,t)}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(Jr["CJK Unified Ideographs"](t)||Jr["Hangul Syllables"](t)||Jr.Hiragana(t)||Jr.Katakana(t))}_tinySDF(t,e,i){const r=this.localIdeographFontFamily;if(!r)return;if(!this._doesCharSupportLocalGlyph(i))return;let s=t.tinySDF;if(!s){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),s=t.tinySDF=new gh.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:i})}const n=s.draw(String.fromCharCode(i));return{id:i,bitmap:new fo({width:n.width||60,height:n.height||60},n.data),metrics:{width:n.glyphWidth/2||24,height:n.glyphHeight/2||24,left:n.glyphLeft/2+.5||0,top:n.glyphTop/2-27.5||-8,advance:n.glyphAdvance/2||24,isDoubleResolution:!0}}}}gh.loadGlyphRange=function(t,e,i,r,s){const n=256*e,a=n+255,o=r.transformRequest(i.replace("{fontstack}",t).replace("{range}",`${n}-${a}`),tt.Glyphs);j(o,((t,e)=>{if(t)s(t);else if(e){const t={};for(const i of function(t){return new Ec(t).readFields(zc,[])}(e))t[i.id]=i;s(null,t)}}))},gh.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:n="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const o=this.size=t+4*e,l=this._createCanvas(o),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${n} ${t}px ${s}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:n}=this.ctx.measureText(t),a=Math.ceil(i),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n-s))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=o+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return d;const{ctx:m,buffer:f,gridInner:_,gridOuter:g}=this;m.clearRect(f,f,o,l),m.fillText(t,f,f+a);const y=m.getImageData(f,f,o,l);g.fill(mh,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[r]=t<0?t*t:0}}fh(g,0,0,c,h,c,this.f,this.v,this.z),fh(_,f,f,o,l,c,this.f,this.v,this.z);for(let t=0;t1&&(a=t[++n]);const l=Math.abs(o-a.left),c=Math.abs(o-a.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(a.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.data[s+o]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let s=0,n=t[s];for(let e=0;e1&&(n=t[++s]);const i=Math.abs(e-n.left),a=Math.abs(e-n.right),o=Math.min(i,a);this.data[r+e]=Math.max(0,Math.min(255,(n.isDash?o:-o)+128))}}addDash(t,e){const i=e?7:0,r=2*i+1;if(this.nextRow+r>this.height)return A("LineAtlas out of space"),null;let s=0;for(let e=0;e{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){delete this._channel,this._callback=()=>{}}}class Th{constructor(t,e,i){this.receive=t=>{const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[i];const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t()}else z()||e.mustQueue?(this.tasks[i]=e,this.taskQueue.push(i),this.invoker.trigger()):this.processTask(i,e)},this.process=()=>{if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)},this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new wh(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=z()?t:window}send(t,e,i,r,s=!1){const n=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(this.callbacks[n]=i);const a=[],o={id:n,type:t,hasCallback:!!i,targetMapId:r,mustQueue:s,sourceMapId:this.mapId,data:Xr(e,a)};return this.target.postMessage(o,{transfer:a}),{cancel:()=>{i&&delete this.callbacks[n],this.target.postMessage({id:n,type:"",targetMapId:r,sourceMapId:this.mapId})}}}processTask(t,e){if(""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Kr(e.error)):i(null,Kr(e.data)))}else{let i=!1;const r=[],s=e.hasCallback?(e,s)=>{i=!0,delete this.cancelCallbacks[t];const n={id:t,type:"",sourceMapId:this.mapId,error:e?Xr(e):null,data:Xr(s,r)};this.target.postMessage(n,{transfer:r})}:t=>{i=!0};let n=null;const a=Kr(e.data);if(this.parent[e.type])n=this.parent[e.type](e.sourceMapId,a,s);else if("getWorkerSource"in this.parent){const t=e.type.split(".");n=this.parent.getWorkerSource(e.sourceMapId,t[0],a.source)[t[1]](a,s)}else s(new Error(`Could not find function ${e.type}`));!i&&n&&n.cancel&&(this.cancelCallbacks[t]=n.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}}class Sh{constructor(t,e,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let t=0;t{i.send(t,e,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((t=>{t.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}}function Ih(t,e,i){const r=function(e,r){if(e)return i(e);if(r){const e=y(g(r,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(e.vectorLayers=r.vector_layers,e.vectorLayerIds=e.vectorLayers.map((t=>t.id))),i(null,e)}};return t.url?Z(e.transformRequest(t.url,tt.Source),r):B.frame((()=>r(null,t)))}const Ah=6371008.8;class Eh{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Eh(f(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,s=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Ah*Math.acos(Math.min(s,1))}static convert(t){if(t instanceof Eh)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Eh(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Eh(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Ch{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof Eh?new Eh(t.lng,t.lat):Eh.convert(t),this}setSouthWest(t){return this._sw=t instanceof Eh?new Eh(t.lng,t.lat):Eh.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,s;if(t instanceof Eh)r=t,s=t;else{if(!(t instanceof Ch))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Ch.convert(t)):this.extend(Eh.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(Eh.convert(t)):this;if(r=t._sw,s=t._ne,!r||!s)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(s.lng,i.lng),i.lat=Math.max(s.lat,i.lat)):(this._sw=new Eh(r.lng,r.lat),this._ne=new Eh(s.lng,s.lat)),this}getCenter(){return new Eh((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Eh(this.getWest(),this.getNorth())}getSouthEast(){return new Eh(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Eh.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return t instanceof Ch?t:t?new Ch(t):t}static fromLngLat(t,e=0){const i=360*e/40075017,r=i/Math.cos(Math.PI/180*t.lat);return new Ch(new Eh(t.lng-r,t.lat-i),new Eh(t.lng+r,t.lat+i))}}const zh=2*Math.PI*Ah;function Mh(t){return zh*Math.cos(t*Math.PI/180)}function Ph(t){return(180+t)/360}function kh(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Dh(t,e){return t/Mh(e)}function Lh(t){return 360*t-180}function Rh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class Bh{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Eh.convert(t);return new Bh(Ph(i.lng),kh(i.lat),Dh(e,i.lat))}toLngLat(){return new Eh(Lh(this.x),Rh(this.y))}toAltitude(){return this.z*Mh(Rh(this.y))}meterInMercatorCoordinateUnits(){return 1/zh*(t=Rh(this.y),1/Math.cos(t*Math.PI/180));var t}}class Fh{constructor(t,e,i){this.bounds=Ch.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const e=Math.pow(2,t.z),i=Math.floor(Ph(this.bounds.getWest())*e),r=Math.floor(kh(this.bounds.getNorth())*e),s=Math.ceil(Ph(this.bounds.getEast())*e),n=Math.ceil(kh(this.bounds.getSouth())*e);return t.x>=i&&t.x=r&&t.y{this._loaded=!1,this.fire(new nt("dataloading",{dataType:"source"})),this._tileJSONRequest=Ih(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t?this.fire(new at(t)):e&&(g(this,e),e.bounds&&(this.tileBounds=new Fh(e.bounds,this.minzoom,this.maxzoom)),this.fire(new nt("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new nt("data",{dataType:"source",sourceDataType:"content"})))}))},this.serialize=()=>g({},this._options),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,g(this,y(e,["url","scheme","tileSize","promoteId"])),this._options=g({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:this.map._requestManager.transformRequest(i,tt.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function s(i,r){return delete t.request,t.aborted?e(null):i&&404!==i.status?e(i):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state?"loading"===t.state?t.reloadCallback=e:t.request=t.actor.send("reloadTile",r,s.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,s.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class Vh extends ot{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=g({type:"raster"},e),g(this,y(e,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new nt("dataloading",{dataType:"source"})),this._tileJSONRequest=Ih(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new at(t)):e&&(g(this,e),e.bounds&&(this.tileBounds=new Fh(e.bounds,this.minzoom,this.maxzoom)),this.fire(new nt("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new nt("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}serialize(){return g({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=Q.getImage(this.map._requestManager.transformRequest(i,tt.Tile),((i,r,s)=>{if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(r){this.map._refreshExpiredTiles&&s&&t.setExpiryData(s);const i=this.map.painter.context,n=i.gl;t.texture=this.map.painter.getTileTexture(r.width),t.texture?t.texture.update(r,{useMipmap:!0}):(t.texture=new uh(i,r,n.RGBA,{useMipmap:!0}),t.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),i.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),t.state="loaded",e(null)}}),this.map._refreshExpiredTiles)}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}function Uh(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Nh{constructor(t,e,i){if(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=Zh(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(n=this.y,a=this.z,o=Uh(256*(s=this.x),256*(n=Math.pow(2,a)-n-1),a),l=Uh(256*(s+1),256*(n+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var s,n,a,o,l;const c=function(t,e,i){let r,s="";for(let n=t;n>0;n--)r=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new n((t.x*e-this.x)*va,(t.y*e-this.y)*va)}toString(){return`${this.z}/${this.x}/${this.y}`}}class $h{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Zh(t,e.z,e.z,e.x,e.y)}}class qh{constructor(t,e,i,r,s){if(t= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Nh(i,+r,+s),this.key=Zh(e,t,i,r,s)}clone(){return new qh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new qh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new qh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?Zh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Zh(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new qh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new qh(e,this.wrap,e,i,r),new qh(e,this.wrap,e,i+1,r),new qh(e,this.wrap,e,i,r+1),new qh(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=i),i=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}getPixels(){return new _o({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,s=e*this.dim+this.dim,n=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:r=s-1;break;case 1:s=r+1}switch(i){case-1:n=a-1;break;case 1:a=n+1}const o=-e*this.dim,l=-i*this.dim;for(let e=n;ee(this,void 0,void 0,(function*(){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(s){this.map._refreshExpiredTiles&&t.setExpiryData(a);const i=k(s)&&u()?s:yield function(t){return e(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&function(){if(null==h&&(h=!1,u())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i0&&(o[new qh(t.overscaledZ,s,e.z,r,e.y-1).key]={backfilled:!1},o[new qh(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},o[new qh(t.overscaledZ,a,e.z,n,e.y-1).key]={backfilled:!1}),e.y+1{this._updateWorkerData()},this.serialize=()=>g({},this._options,{type:this.type,data:this._data}),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=i.getActor(),this.setEventedParent(r),this._data=e.data,this._options=g({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const s=va/this.tileSize;this.workerOptions=g({source:this.id,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(void 0!==e.buffer?e.buffer:128)*s,tolerance:(void 0!==e.tolerance?e.tolerance:.375)*s,extent:va,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:void 0!==e.clusterMaxZoom?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:va,radius:(e.clusterRadius||50)*s,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions),"string"==typeof this.promoteId&&(this.workerOptions.promoteId=this.promoteId)}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(void 0!==t.clusterRadius&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),void 0!==t.clusterMaxZoom&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(t){const e=g({},this.workerOptions);t?e.dataDiff=t:"string"==typeof this._data?(e.request=this.map._requestManager.transformRequest(B.resolveURL(this._data),tt.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new nt("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,e,((t,e)=>{if(this._pendingLoads--,this._removed||e&&e.abandoned)return void this.fire(new nt("dataabort",{dataType:"source"}));let i=null;if(e&&e.resourceTiming&&e.resourceTiming[this.id]&&(i=e.resourceTiming[this.id].slice(0)),t)return void this.fire(new at(t));const r={dataType:"source"};this._collectResourceTiming&&i&&i.length>0&&g(r,{resourceTiming:i}),this.fire(new nt("data",Object.assign(Object.assign({},r),{sourceDataType:"metadata"}))),this.fire(new nt("data",Object.assign(Object.assign({},r),{sourceDataType:"content"})))}))}loaded(){return 0===this._pendingLoads}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(i,r,((r,s)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(s,this.map.painter,"reloadTile"===i),e(null)))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}hasTransition(){return!1}}var Hh=Bs([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Wh extends ot{constructor(t,e,i,r){super(),this.load=(t,e)=>{this._loaded=!1,this.fire(new nt("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=Q.getImage(this.map._requestManager.transformRequest(this.url,tt.Image),((i,r)=>{this._request=null,this._loaded=!0,i?this.fire(new at(i)):r&&(this.image=r,t&&(this.coordinates=t),e&&e(),this._finishLoading())}))},this.prepare=()=>{if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,e=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,Hh.members)),this.boundsSegments||(this.boundsSegments=Nn.simpleSegment(0,0,4,2)),this.texture||(this.texture=new uh(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));let i=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new nt("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"image",url:this.options.url,coordinates:this.coordinates}),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new nt("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.cancel(),this._request=null)}setCoordinates(t){this.coordinates=t;const e=t.map(Bh.fromLngLat);this.tileID=function(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);const n=Math.max(r-e,s-i),a=Math.max(0,Math.floor(-Math.log(n)/Math.LN2)),o=Math.pow(2,a);return new Nh(a,Math.floor((e+r)/2*o),Math.floor((i+s)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;const i=e.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new wn,this._boundsArray.emplaceBack(i[0].x,i[0].y,0,0),this._boundsArray.emplaceBack(i[1].x,i[1].y,va,0),this._boundsArray.emplaceBack(i[3].x,i[3].y,0,va),this._boundsArray.emplaceBack(i[2].x,i[2].y,va,va),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new nt("data",{dataType:"source",sourceDataType:"content"})),this}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}hasTransition(){return!1}}class Xh extends Wh{constructor(t,e,i,r){super(t,e,i,r),this.load=()=>{this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,tt.Source).url);!function(t,e){const i=window.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e{this._loaded=!0,t?this.fire(new at(t)):e&&(this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))},this.prepare=()=>{if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,e=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,Hh.members)),this.boundsSegments||(this.boundsSegments=Nn.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new uh(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));let i=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new nt("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"video",urls:this.urls,coordinates:this.coordinates}),this.roundZoom=!0,this.type="video",this.options=e}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const e=this.video.seekable;te.end(0)?this.fire(new at(new bt(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}hasTransition(){return this.video&&!this.video.paused}}class Kh extends Wh{constructor(t,e,i,r){super(t,e,i,r),this.load=()=>{this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new at(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},this.prepare=()=>{let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Hh.members)),this.boundsSegments||(this.boundsSegments=Nn.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new uh(e,this.canvas,i.RGBA,{premultiply:!0});let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new nt("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"canvas",coordinates:this.coordinates}),e.coordinates?Array.isArray(e.coordinates)&&4===e.coordinates.length&&!e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new at(new bt(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new at(new bt(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new at(new bt(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"==typeof e.canvas||e.canvas instanceof HTMLCanvasElement||this.fire(new at(new bt(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new at(new bt(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Yh={},Jh=t=>{switch(t){case"geojson":return Gh;case"image":return Wh;case"raster":return Vh;case"raster-dem":return jh;case"vector":return Oh;case"video":return Xh;case"canvas":return Kh}return Yh[t]};function Qh(t,e){const i=Ga();return Ka(i,i,[1,1,0]),Ya(i,i,[.5*t.width,.5*t.height,1]),Xa(i,i,t.calculatePosMatrix(e.toUnwrapped()))}function tu(t,e,i,r,s,n){const a=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(s&&s.layers,e,t.id),o=n.maxPitchScaleFactor(),l=t.tilesIn(r,o,a);l.sort(eu);const c=[];for(const r of l)c.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,s,n,o,Qh(t.transform,r.tileID))});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,s=r.wrappedTileID,n=i[s]=i[s]||{};for(const i in t){const r=t[i],s=n[i]=n[i]||{},a=e[i]=e[i]||[];for(const t of r)s[t.featureIndex]||(s[t.featureIndex]=!0,a.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function eu(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}class iu{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class ru{constructor(t,e,i,r,s){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=s}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}function su(t,e,i,r,s){return b(t,((t,n)=>{const a=e instanceof Ss?e.get(n):null;return a&&a.evaluate?a.evaluate(i,r,s):a}))}function nu(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);return{minX:e,minY:i,maxX:r,maxY:s}}function au(t,e){return e-t}Hr("FeatureIndex",class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new jr(va,16,0),this.grid3D=new jr(va,16,0),this.featureIndexArray=new xn,this.promoteId=e}insert(t,e,i,r,s,n){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,s);const o=n?this.grid3D:this.grid;for(let t=0;t=0&&r[3]>=0&&o.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new ml.VectorTile(new Ec(this.rawTileData)).layers,this.sourceLayerCoder=new iu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const s=t.params||{},a=va/t.tileSize/t.scale,o=sr(s.filter),l=t.queryGeometry,c=t.queryPadding*a,h=nu(l),u=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),p=nu(t.cameraQueryGeometry),d=this.grid3D.query(p.minX-c,p.minY-c,p.maxX+c,p.maxY+c,((e,i,r,s)=>function(t,e,i,r,s){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&s>=n.y)return!0;const a=[new n(e,i),new n(e,s),new n(r,s),new n(r,i)];if(t.length>2)for(const e of a)if(Ba(t,e))return!0;for(let e=0;e(p||(p=Ta(e)),i.queryIntersectsFeature(l,e,r,p,this.z,t.transform,a,t.pixelPosMatrix))))}return m}loadMatchingFeature(t,e,i,r,s,n,a,o,l,c,h){const u=this.bucketLayerIDs[e];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,u))return;const p=this.sourceLayerCoder.decode(i),d=this.vtLayers[p].feature(r);if(s.needGeometry){const t=Sa(d,!0);if(!s.filter(new _s(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new _s(this.tileID.overscaledZ),d))return;const m=this.getId(d,p);for(let e=0;ee.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Xc){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Xc&&e.hasRTLText){this.hasRTLText=!0,fs.isLoading()||fs.isLoaded()||"deferred"!==ds()||ms();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new cn}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new uh(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new uh(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,s,n,a,o,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:s,scale:n,tileSize:this.tileSize,pixelPosMatrix:c,transform:o,params:a,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),s=e&&e.sourceLayer?e.sourceLayer:"",n=r._geojsonTileLayer||r[s];if(!n)return;const a=sr(e&&e.filter),{z:o,x:l,y:c}=this.tileID.canonical,h={z:o,x:l,y:c};for(let e=0;e@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,s)=>{const n=r||s;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime{this.remove(t,s)}),i)),this.data[r].push(s),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][r];return this.data[i].splice(r,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class cu{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},g(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=g({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),g(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},g(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class hu extends ot{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((t,e,i,r)=>{const s=new(Jh(e.type))(t,e,i,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return s})(t,e,i,this),this._tiles={},this._cache=new lu(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cu,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,e){return this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,(()=>{})),this._source.fire(new nt("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(uu).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,s=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),a=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||a.y-s.y||a.x-s.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(uu).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)return t.state="errored",void(404!==r.status?this._source.fire(new at(r,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=B.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new nt("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[n]&&(t.neighboringTiles[n].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const s in this._tiles){let n=this._tiles[s];if(r[s]||!n.hasData()||n.tileID.overscaledZ<=e||n.tileID.overscaledZ>i)continue;let a=n.tileID;for(;n&&n.tileID.overscaledZ>e+1;){const t=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[t.key],n&&n.hasData()&&(a=t)}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){r[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const e=Math.ceil(t.width/this._source.tileSize)+1,i=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*i*(null===this._maxTileCacheZoomLevels?O.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t])}}update(t,e){if(this.transform=t,this.terrain=e,!this._sourceLoaded||this._paused)return;let i;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new qh(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:e}),this._source.hasTile&&(i=i.filter((t=>this._source.hasTile(t))))):i=[];const r=t.coveringZoomLevel(this._source),s=Math.max(r-hu.maxOverzooming,this._source.minzoom),n=Math.max(r+hu.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of i)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}i=i.concat(Object.values(t))}const a=0===i.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new nt("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const o=this._updateRetainedTiles(i,r);if(pu(this._source.type)){const t={},a={},l=Object.keys(o),c=B.now();for(const e of l){const i=o[e],r=this._tiles[e];if(!r||0!==r.fadeEndTime&&r.fadeEndTime<=c)continue;const n=this.findLoadedParent(i,s);n&&(this._addTile(n.tileID),t[n.tileID.key]=n.tileID),a[e]=i}this._retainLoadedChildren(a,r,n,o);for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e]);if(e){const t={},e={};for(const r of i)this._tiles[r.key].hasData()?t[r.key]=r:e[r.key]=r;for(const i in e){const r=e[i].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=o[r[0].key]=r[0],t[r[1].key]=o[r[1].key]=r[1],t[r[2].key]=o[r[2].key]=r[2],t[r[3].key]=o[r[3].key]=r[3],delete e[i])}for(const i in e){const r=this.findLoadedParent(e[i],this._source.minzoom);if(r){t[r.tileID.key]=o[r.tileID.key]=r.tileID;for(const e in t)t[e].isChildOf(r.tileID)&&delete t[e]}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}for(const t in o)this._tiles[t].clearFadeHold();const l=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,o);for(const t of l){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){const i={},r={},s=Math.max(e-hu.maxOverzooming,this._source.minzoom),n=Math.max(e+hu.maxUnderzooming,this._source.minzoom),a={};for(const r of t){const t=this._addTile(r);i[r.key]=r,t.hasData()||ethis._source.maxzoom){const t=n.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){i[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let a=t.wasRequested();for(let e=n.overscaledZ-1;e>=s;--e){const s=n.scaledTo(e);if(r[s.key])break;if(r[s.key]=!0,t=this.getTile(s),!t&&a&&(t=this._addTile(s)),t){const e=t.hasData();if((a||e)&&(i[s.key]=s),a=t.wasRequested(),e)break}}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=e;return e||(e=new ou(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))),e.uses++,this._tiles[t.key]=e,i||this._source.fire(new nt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,e,i){const r=[],s=this.transform;if(!s)return r;const n=i?s.getCameraQueryGeometry(t):t,a=t.map((t=>s.pointCoordinate(t,this.terrain))),o=n.map((t=>s.pointCoordinate(t,this.terrain))),l=this.getIds();let c=1/0,h=1/0,u=-1/0,p=-1/0;for(const t of o)c=Math.min(c,t.x),h=Math.min(h,t.y),u=Math.max(u,t.x),p=Math.max(p,t.y);for(let t=0;t=0&&f[1].y+m>=0){const t=a.map((t=>n.getTilePoint(t))),e=o.map((t=>n.getTilePoint(t)));r.push({tile:i,tileID:n,queryGeometry:t,cameraQueryGeometry:e,scale:d})}}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(pu(this._source.type)){const t=B.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function uu(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function pu(t){return"raster"===t||"image"===t||"video"===t}hu.maxOverzooming=10,hu.maxUnderzooming=3;const du="mapboxgl_preloaded_worker_pool";class mu{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[du]}numActive(){return Object.keys(this.active).length}}const fu=Math.floor(B.hardwareConcurrency/2);let _u;function gu(){return _u||(_u=new mu),_u}mu.workerCount=P(globalThis)?Math.max(Math.min(fu,3),1):1;class yu{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t0?(r-n)/a:0;return this.points[s].mult(1-o).add(this.points[e].mult(o))}}function xu(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class vu{constructor(t,e,i){const r=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||r<0||e>this.height)return[];const o=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(s)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t0}hitTestCircle(t,e,i,r,s){const n=t-i,a=t+i,o=e-i,l=e+i;if(a<0||n>this.width||l<0||o>this.height)return!1;const c=[];return this._forEachCell(n,o,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),c.length>0}_queryCell(t,e,i,r,s,n,a,o){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const s=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,p=this.boxKeys[a];if(t<=s[u+2]&&e<=s[u+3]&&i>=s[u+0]&&r>=s[u+1]&&(!o||o(p))&&(!c||!xu(h,p.overlapMode))&&(n.push({key:p,x1:s[u],y1:s[u+1],x2:s[u+2],y2:s[u+3]}),c))return!0}}const p=this.circleCells[s];if(null!==p){const s=this.circles;for(const a of p)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,p=this.circleKeys[a];if(this._circleAndRectCollide(s[u],s[u+1],s[u+2],t,e,i,r)&&(!o||o(p))&&(!c||!xu(h,p.overlapMode))){const t=s[u],e=s[u+1],i=s[u+2];if(n.push({key:p,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,s,n,a,o){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!o||o(r))&&!xu(h,r.overlapMode))return n.push(!0),!0}}const p=this.circleCells[s];if(null!==p){const t=this.circles;for(const e of p)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!o||o(r))&&!xu(h,r.overlapMode))return n.push(!0),!0}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(s.call(this,t,e,i,r,this.xCellCount*l+p,n,a,o))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,s,n){const a=r-t,o=s-e,l=i+n;return l*l>a*a+o*o}_circleAndRectCollide(t,e,i,r,s,n,a){const o=(n-r)/2,l=Math.abs(t-(r+o));if(l>o+i)return!1;const c=(a-s)/2,h=Math.abs(e-(s+c));if(h>c+i)return!1;if(l<=o||h<=c)return!0;const u=l-o,p=h-c;return u*u+p*p<=i*i}}function bu(t,e,i,r,s){const n=Ga();return e?(Ya(n,n,[1/s,1/s,1]),i||Ja(n,n,r.angle)):Xa(n,r.labelPlaneMatrix,t),n}function wu(t,e,i,r,s){if(e){const e=function(t){var e=new ja(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}(t);return Ya(e,e,[s,s,1]),i||Ja(e,e,-r.angle),e}return r.glCoordMatrix}function Tu(t,e,i){let r;i?(r=[t.x,t.y,i(t.x,t.y),1],so(r,r,e)):(r=[t.x,t.y,0,1],Fu(r,r,e));const s=r[3];return{point:new n(r[0]/s,r[1]/s),signedDistanceFromCamera:s}}function Su(t,e){return.5+t/e*.5}function Iu(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function Au(t,e,i,r,s,a,o,l,c,h){const u=r?t.textSizeData:t.iconSizeData,p=Uc(u,i.transform.zoom),d=[256/i.width*2+1,256/i.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();const f=t.lineVertexArray,_=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,g=i.transform.width/i.transform.height;let y=!1;for(let r=0;r<_.length;r++){const x=_.get(r);if(x.hidden||x.writingMode===Lc.vertical&&!y){Bu(x.numGlyphs,m);continue}let v;if(y=!1,h?(v=[x.anchorX,x.anchorY,h(x.anchorX,x.anchorY),1],so(v,v,e)):(v=[x.anchorX,x.anchorY,0,1],Fu(v,v,e)),!Iu(v,d)){Bu(x.numGlyphs,m);continue}const b=Su(i.transform.cameraToCenterDistance,v[3]),w=Vc(u,p,x),T=o?w/b:w*b,S=new n(x.anchorX,x.anchorY),I=Tu(S,s,h).point,A={projections:{},offsets:{}},E=zu(x,T,!1,l,e,s,a,t.glyphOffsetArray,f,m,I,S,A,g,c,h);y=E.useVertical,(E.notEnoughRoom||y||E.needsFlipping&&zu(x,T,!0,l,e,s,a,t.glyphOffsetArray,f,m,I,S,A,g,c,h).notEnoughRoom)&&Bu(x.numGlyphs,m)}r?t.text.dynamicLayoutVertexBuffer.updateData(m):t.icon.dynamicLayoutVertexBuffer.updateData(m)}function Eu(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=o.glyphStartIndex+o.numGlyphs,m=o.lineStartIndex,f=o.lineStartIndex+o.lineLength,_=e.getoffsetX(o.glyphStartIndex),g=e.getoffsetX(d-1),y=Lu(t*_,i,r,s,n,a,o.segment,m,f,l,c,h,u,p);if(!y)return null;const x=Lu(t*g,i,r,s,n,a,o.segment,m,f,l,c,h,u,p);return x?{first:y,last:x}:null}function Cu(t,e,i,r){return t===Lc.horizontal&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:(t===Lc.vertical?e.yi.x)?{needsFlipping:!0}:null}function zu(t,e,i,r,s,a,o,l,c,h,u,p,d,m,f,_){const g=e/24,y=t.lineOffsetX*g,x=t.lineOffsetY*g;let v;if(t.numGlyphs>1){const e=t.glyphStartIndex+t.numGlyphs,s=t.lineStartIndex,n=t.lineStartIndex+t.lineLength,h=Eu(g,l,y,x,i,u,p,t,c,a,d,f,_);if(!h)return{notEnoughRoom:!0};const b=Tu(h.first.point,o,_).point,w=Tu(h.last.point,o,_).point;if(r&&!i){const e=Cu(t.writingMode,b,w,m);if(e)return e}v=[h.first];for(let r=t.glyphStartIndex+1;r0?a.point:Mu(p,r,e,1,s,_),l=Cu(t.writingMode,e,o,m);if(l)return l}const e=Lu(g*l.getoffsetX(t.glyphStartIndex),y,x,i,u,p,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,a,d,f,_);if(!e)return{notEnoughRoom:!0};v=[e]}for(const t of v)jc(h,t.point,t.angle);return{}}function Mu(t,e,i,r,s,n){const a=Tu(t.add(t.sub(e)._unit()),s,n).point,o=i.sub(a);return i.add(o._mult(r/o.mag()))}function Pu(t,e){const{projectionCache:i,lineVertexArray:r,labelPlaneMatrix:s,tileAnchorPoint:a,distanceFromAnchor:o,getElevation:l,previousVertex:c,direction:h,absOffsetX:u}=e;if(i.projections[t])return i.projections[t];const p=new n(r.getx(t),r.gety(t)),d=Tu(p,s,l);if(d.signedDistanceFromCamera>0)return i.projections[t]=d.point,d.point;const m=t-h;return Mu(0===o?a:new n(r.getx(m),r.gety(m)),p,c,u-o+1,s,l)}function ku(t,e,i){return t._unit()._perp()._mult(e*i)}function Du(t,e,i,r,s,a,o,l){const{projectionCache:c,direction:h}=l;if(c.offsets[t])return c.offsets[t];const u=i.add(e);if(t+h=s)return c.offsets[t]=u,u;const p=Pu(t+h,l),d=ku(p.sub(i),o,h),m=i.add(d),f=p.add(d);return c.offsets[t]=function(t,e,i,r){const s=e.y-t.y,a=e.x-t.x,o=r.y-i.y,l=r.x-i.x,c=o*a-l*s;if(0===c)return null;const h=(l*(t.y-i.y)-o*(t.x-i.x))/c;return new n(t.x+h*a,t.y+h*s)}(a,u,m,f)||u,c.offsets[t]}function Lu(t,e,i,r,s,n,a,o,l,c,h,u,p,d){const m=r?t-e:t+e;let f=m>0?1:-1,_=0;r&&(f*=-1,_=Math.PI),f<0&&(_+=Math.PI);let g,y,x=f>0?o+a:o+a+1,v=s,b=s,w=0,T=0;const S=Math.abs(m),I=[];let A;for(;w+T<=S;){if(x+=f,x=l)return null;w+=T,b=v,y=g;const t={projectionCache:u,lineVertexArray:c,labelPlaneMatrix:h,tileAnchorPoint:n,distanceFromAnchor:w,getElevation:d,previousVertex:b,direction:f,absOffsetX:S};if(v=Pu(x,t),0===i)I.push(b),A=v.sub(b);else{let e;const r=v.sub(b);e=0===r.mag()?ku(Pu(x+f,t).sub(v),i,f):ku(r,i,f),y||(y=b.add(e)),g=Du(x,e,v,o,l,y,i,t),I.push(y),A=g.sub(y)}T=A.mag()}const E=A._mult((S-w)/T)._add(y||b),C=_+Math.atan2(v.y-b.y,v.x-b.x);return I.push(E),{point:E,angle:p?C:0,path:I}}const Ru=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Bu(t,e){for(let i=0;i=1;t--)h.push(a.path[t]);for(let t=1;tTu(t,l,m)));h=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let g=[];if(h.length>0){const t=h[0].clone(),e=h[0].clone();for(let i=1;i=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[h]:e.xr.x||e.yr.y?[]:function(t,e,i,r,s){const a=[];for(let o=0;o=r&&h.x>=r||(o.x>=r?o=new n(r,o.y+(r-o.x)/(h.x-o.x)*(h.y-o.y))._round():h.x>=r&&(h=new n(r,o.y+(r-o.x)/(h.x-o.x)*(h.y-o.y))._round()),o.y>=s&&h.y>=s||(o.y>=s?o=new n(o.x+(s-o.y)/(h.y-o.y)*(h.x-o.x),s)._round():h.y>=s&&(h=new n(o.x+(s-o.y)/(h.y-o.y)*(h.x-o.x),s)._round()),c&&o.equals(c[c.length-1])||(c=[o],a.push(c)),c.push(h)))))}}return a}([h],i.x,i.y,r.x,r.y)}for(const i of g){s.reset(i,.25*e);let r=0;r=s.length<=.5*e?1:Math.ceil(s.paddedLength/_)+1;for(let i=0;i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t=0&&et.collisionGroupID===e}}return this.collisionGroups[t]}}function Xu(t,e,i,r,s){const{horizontalAlign:a,verticalAlign:o}=Rc(t);return new n(-(a-.5)*e+r[0]*s,-(o-.5)*i+r[1]*s)}function Ku(t,e,i,r,s,a){const{x1:o,x2:l,y1:c,y2:h,anchorPointX:u,anchorPointY:p}=t,d=new n(e,i);return r&&d._rotate(s?a:-a),{x1:o+d.x,y1:c+d.y,x2:l+d.x,y2:h+d.y,anchorPointX:u,anchorPointY:p}}class Yu{constructor(t,e,i,r,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new Vu(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Wu(r),this.collisionCircleArrays={},this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,e,i,r){const s=i.getBucket(e),n=i.latestFeatureIndex;if(!s||!n||e.id!==s.layerIds[0])return;const a=i.collisionBoxArray,o=s.layers[0].layout,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/va,h=this.transform.calculatePosMatrix(i.tileID.toUnwrapped()),u="map"===o.get("text-pitch-alignment"),p="map"===o.get("text-rotation-alignment"),d=$u(i,1,this.transform.zoom),m=bu(h,u,p,this.transform,d);let f=null;if(u){const t=wu(h,u,p,this.transform,d);f=Xa([],this.transform.labelPlaneMatrix,t)}this.retainedQueryData[s.bucketInstanceId]=new Hu(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,i.tileID);const _={bucket:s,layout:o,posMatrix:h,textLabelPlaneMatrix:m,labelToScreenMatrix:f,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:Uc(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s,parameters:_})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:_})}attemptAnchorPlacement(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f){const _=Nu[t.textAnchor],g=[t.textOffset0,t.textOffset1],y=Xu(_,i,r,g,s),x=this.collisionIndex.placeCollisionBox(Ku(e,y.x,y.y,n,a,this.transform.angle),h,o,l,c.predicate,f);if((!m||0!==this.collisionIndex.placeCollisionBox(Ku(m,y.x,y.y,n,a,this.transform.angle),h,o,l,c.predicate,f).box.length)&&x.box.length>0){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(t=this.prevPlacement.variableOffsets[u.crossTileID].anchor),0===u.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[u.crossTileID]={textOffset:g,width:i,height:r,anchor:_,textBoxScale:s,prevAnchor:t},this.markUsedJustification(p,_,u,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,u),this.placedOrientations[u.crossTileID]=d),{shift:y,placedGlyphBoxes:x}}}placeLayerBucketPart(t,e,i){const{bucket:r,layout:s,posMatrix:n,textLabelPlaneMatrix:a,labelToScreenMatrix:o,textPixelRatio:l,holdingForFade:c,collisionBoxArray:h,partiallyEvaluatedTextSize:u,collisionGroup:p}=t.parameters,d=s.get("text-optional"),m=s.get("icon-optional"),f=Nc(s,"text-overlap","text-allow-overlap"),_="always"===f,g=Nc(s,"icon-overlap","icon-allow-overlap"),y="always"===g,x="map"===s.get("text-rotation-alignment"),v="map"===s.get("text-pitch-alignment"),b="none"!==s.get("icon-text-fit"),w="viewport-y"===s.get("symbol-z-order"),T=_&&(y||!r.hasIconData()||m),S=y&&(_||!r.hasTextData()||d);!r.collisionArrays&&h&&r.deserializeCollisionBoxes(h);const I=this.retainedQueryData[r.bucketInstanceId].tileID,E=this.terrain?(t,e)=>this.terrain.getElevation(I,t,e):null,C=(t,h)=>{var y,w;if(e[t.crossTileID])return;if(c)return void(this.placements[t.crossTileID]=new ju(!1,!1,!1));let I=!1,C=!1,z=!0,M=null,P={box:null,offscreen:null},k={box:null,offscreen:null},D=null,L=null,R=null,B=0,F=0,O=0;h.textFeatureIndex?B=h.textFeatureIndex:t.useRuntimeCollisionCircles&&(B=t.featureIndex),h.verticalTextFeatureIndex&&(F=h.verticalTextFeatureIndex);const V=h.textBox;if(V){const e=e=>{let i=Lc.horizontal;if(r.allowVerticalPlacement&&!e&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(r,i,t))}return i},i=(e,i)=>{if(r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&h.verticalTextBox){for(const t of r.writingModes)if(t===Lc.vertical?(P=i(),k=P):P=e(),P&&P.box&&P.box.length)break}else P=e()},s=t.textAnchorOffsetStartIndex,a=t.textAnchorOffsetEndIndex;if(a===s){const s=(e,i)=>{const s=this.collisionIndex.placeCollisionBox(e,f,l,n,p.predicate,E);return s&&s.box&&s.box.length&&(this.markUsedOrientation(r,i,t),this.placedOrientations[t.crossTileID]=i),s};i((()=>s(V,Lc.horizontal)),(()=>{const e=h.verticalTextBox;return r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?s(e,Lc.vertical):{box:null,offscreen:null}})),e(P&&P.box&&P.box.length)}else{let o=Nu[null===(w=null===(y=this.prevPlacement)||void 0===y?void 0:y.variableOffsets[t.crossTileID])||void 0===w?void 0:w.anchor];const c=(e,i,c)=>{const h=e.x2-e.x1,u=e.y2-e.y1,d=t.textBoxScale,m=b&&"never"===g?i:null;let _={box:[],offscreen:!1},y="never"===f?1:2,w="never";o&&y++;for(let i=0;ic(V,h.iconBox,Lc.horizontal)),(()=>{const e=h.verticalTextBox;return r.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&t.numVerticalGlyphVertices>0&&e?c(e,h.verticalIconBox,Lc.vertical):{box:null,offscreen:null}})),P&&(I=P.box,z=P.offscreen);const u=e(P&&P.box);if(!I&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(r,e.anchor,t,u))}}}if(D=P,I=D&&D.box&&D.box.length>0,z=D&&D.offscreen,t.useRuntimeCollisionCircles){const e=r.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),l=Vc(r.textSizeData,u,e),c=s.get("text-padding");L=this.collisionIndex.placeCollisionCircles(f,e,r.lineVertexArray,r.glyphOffsetArray,l,n,a,o,i,v,p.predicate,t.collisionCircleDiameter,c,E),L.circles.length&&L.collisionDetected&&!i&&A("Collisions detected, but collision boxes are not shown"),I=_||L.circles.length>0&&!L.collisionDetected,z=z&&L.offscreen}if(h.iconFeatureIndex&&(O=h.iconFeatureIndex),h.iconBox){const t=t=>{const e=b&&M?Ku(t,M.x,M.y,x,v,this.transform.angle):t;return this.collisionIndex.placeCollisionBox(e,g,l,n,p.predicate,E)};k&&k.box&&k.box.length&&h.verticalIconBox?(R=t(h.verticalIconBox),C=R.box.length>0):(R=t(h.iconBox),C=R.box.length>0),z=z&&R.offscreen}const U=d||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,N=m||0===t.numIconVertices;if(U||N?N?U||(C=C&&I):I=C&&I:C=I=C&&I,I&&D&&D.box&&this.collisionIndex.insertCollisionBox(D.box,f,s.get("text-ignore-placement"),r.bucketInstanceId,k&&k.box&&F?F:B,p.ID),C&&R&&this.collisionIndex.insertCollisionBox(R.box,g,s.get("icon-ignore-placement"),r.bucketInstanceId,O,p.ID),L&&(I&&this.collisionIndex.insertCollisionCircles(L.circles,f,s.get("text-ignore-placement"),r.bucketInstanceId,B,p.ID),i)){const t=r.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Gu);for(let t=0;t=0;--t){const i=e[t];C(r.symbolInstances.get(i),r.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=s>=0&&e!==s?0:i.crossTileID)}markUsedOrientation(t,e,i){const r=e===Lc.horizontal||e===Lc.horizontalOnly?e:0,s=e===Lc.vertical?e:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const e of n)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=s)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},n=e?e.variableOffsets:{},a=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],n=s[t];n?(this.opacities[t]=new Zu(n,r,e.text,e.icon),i=i||e.text!==n.text.placed||e.icon!==n.icon.placed):(this.opacities[t]=new Zu(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in s){const e=s[t];if(!this.opacities[t]){const s=new Zu(e,r,!1,!1);s.isHidden()||(this.opacities[t]=s,i=i||e.text.placed||e.icon.placed)}}for(const t in n)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=n[t]);for(const t in a)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=a[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(t,e,i){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0],s=r.layout,a=new Zu(null,0,!1,!1,!0),o=s.get("text-allow-overlap"),l=s.get("icon-allow-overlap"),c=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),u="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),d=new Zu(null,0,o&&(l||!t.hasIconData()||s.get("icon-optional")),l&&(o||!t.hasTextData()||s.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const m=(t,e,i)=>{for(let r=0;r0,g=this.placedOrientations[r.crossTileID],y=g===Lc.vertical,x=g===Lc.horizontal||g===Lc.horizontalOnly;if(s>0||o>0){const e=ap(f.text);m(t.text,s,y?op:e),m(t.text,o,x?op:e);const i=f.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||y?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(t,n.anchor,r,g);const a=this.placedOrientations[r.crossTileID];a&&(this.markUsedJustification(t,"left",r,a),this.markUsedOrientation(t,a,r))}if(_){const e=ap(f.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(m(t.icon,r.numIconVertices,i?e:op),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=f.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,r.numVerticalIconVertices,i?op:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=f.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const e=t.collisionArrays[i];if(e){let i=new n(0,0);if(e.textBox||e.verticalTextBox){let r=!0;if(c){const t=this.variableOffsets[l];t?(i=Xu(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),h&&i._rotate(u?this.transform.angle:-this.transform.angle)):r=!1}e.textBox&&Ju(t.textCollisionBox.collisionVertexArray,f.text.placed,!r||y,i.x,i.y),e.verticalTextBox&&Ju(t.textCollisionBox.collisionVertexArray,f.text.placed,!r||x,i.x,i.y)}const r=Boolean(!x&&e.verticalIconBox);e.iconBox&&Ju(t.iconCollisionBox.collisionVertexArray,f.icon.placed,r,p?i.x:0,p?i.y:0),e.verticalIconBox&&Ju(t.iconCollisionBox.collisionVertexArray,f.icon.placed,!r,p?i.x:0,p?i.y:0)}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Ju(t,e,i,r,s){t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0)}const Qu=Math.pow(2,25),tp=Math.pow(2,24),ep=Math.pow(2,17),ip=Math.pow(2,16),rp=Math.pow(2,9),sp=Math.pow(2,8),np=Math.pow(2,1);function ap(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Qu+e*tp+i*ep+e*ip+i*rp+e*sp+i*np+e}const op=0;class lp{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,s){const n=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex!this._forceFullPlacement&&B.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new lp(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const hp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class up{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const s=hp[15&i];if(!s)throw new Error("Unrecognized array type.");const[n]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new up(a,n,s,t)}constructor(t,e=64,i=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=hp.indexOf(this.ArrayType),n=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+n+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return pp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:n,nodeSize:a}=this,o=[0,s.length-1,0],l=[];for(;o.length;){const c=o.pop()||0,h=o.pop()||0,u=o.pop()||0;if(h-u<=a){for(let a=u;a<=h;a++){const o=n[2*a],c=n[2*a+1];o>=t&&o<=i&&c>=e&&c<=r&&l.push(s[a])}continue}const p=u+h>>1,d=n[2*p],m=n[2*p+1];d>=t&&d<=i&&m>=e&&m<=r&&l.push(s[p]),(0===c?t<=d:e<=m)&&(o.push(u),o.push(p-1),o.push(1-c)),(0===c?i>=d:r>=m)&&(o.push(p+1),o.push(h),o.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:s,nodeSize:n}=this,a=[0,r.length-1,0],o=[],l=i*i;for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=n){for(let i=u;i<=h;i++)_p(s[2*i],s[2*i+1],t,e)<=l&&o.push(r[i]);continue}const p=u+h>>1,d=s[2*p],m=s[2*p+1];_p(d,m,t,e)<=l&&o.push(r[p]),(0===c?t-i<=d:e-i<=m)&&(a.push(u),a.push(p-1),a.push(1-c)),(0===c?t+i>=d:e+i>=m)&&(a.push(p+1),a.push(h),a.push(1-c))}return o}}function pp(t,e,i,r,s,n){if(s-r<=i)return;const a=r+s>>1;dp(t,e,a,r,s,n),pp(t,e,i,r,a-1,1-n),pp(t,e,i,a+1,s,1-n)}function dp(t,e,i,r,s,n){for(;s>r;){if(s-r>600){const a=s-r+1,o=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(a-c)/a)*(o-a/2<0?-1:1);dp(t,e,i,Math.max(r,Math.floor(i-o*c/a+h)),Math.min(s,Math.floor(i+(a-o)*c/a+h)),n)}const a=e[2*i+n];let o=r,l=s;for(mp(t,e,r,i),e[2*s+n]>a&&mp(t,e,r,s);oa;)l--}e[2*r+n]===a?mp(t,e,r,l):(l++,mp(t,e,l,s)),l<=i&&(r=l+1),i<=l&&(s=l-1)}}function mp(t,e,i,r){fp(t,i,r),fp(e,2*i,2*r),fp(e,2*i+1,2*r+1)}function fp(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function _p(t,e,i,r){const s=t-i,n=e-r;return s*s+n*n}const gp=512/va/2;class yp{constructor(t,e,i){this.tileID=t,this.bucketInstanceId=i,this._symbolsByKey={};const r=new Map;for(let t=0;t({x:Math.floor(t.anchorX*gp),y:Math.floor(t.anchorY*gp)}))),crossTileIDs:e.map((t=>t.crossTileID))};if(i.positions.length>128){const t=new up(i.positions.length,16,Uint16Array);for(const{x:e,y:r}of i.positions)t.add(e,r);t.finish(),delete i.positions,i.index=t}this._symbolsByKey[t]=i}}getScaledCoordinates(t,e){const{x:i,y:r,z:s}=this.tileID.canonical,{x:n,y:a,z:o}=e.canonical,l=gp/Math.pow(2,o-s),c=(a*va+t.anchorY)*l,h=r*va*gp;return{x:Math.floor((n*va+t.anchorX)*l-i*va*gp),y:Math.floor(c-h)}}findMatches(t,e,i){const r=this.tileID.canonical.zt))}}class xp{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class vp{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),r[s.tileID.key]=s}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;tt.overscaledZ)for(const i in s){const n=s[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{const n=s[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const wp=(t,e)=>Zr(t,e&&e.filter((t=>"source.canvas"!==t.identifier))),Tp=y(dt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),Sp=y(dt,["setCenter","setZoom","setBearing","setPitch"]),Ip=function(){const t={},e=lt.$version;for(const i in lt.$root){const r=lt.$root[i];if(r.required){let s=null;s="version"===i?e:"array"===r.type?[]:{},null!=s&&(t[i]=s)}}return t}();class Ap extends ot{constructor(t,e={}){super(),this.map=t,this.dispatcher=new Sh(gu(),this,t._getMapId()),this.imageManager=new dh,this.imageManager.setEventedParent(this),this.glyphManager=new gh(t._requestManager,e.localIdeographFontFamily),this.lineAtlas=new bh(256,512),this.crossTileSymbolIndex=new bp,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new Yr,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",U());const i=this;this._rtlTextPluginCallback=Ap.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,e)=>{if(hs(t),e&&e.every((t=>t)))for(const t in i.sourceCaches){const e=i.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||i.sourceCaches[t].reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(t,e={},i){this.fire(new nt("dataloading",{dataType:"style"})),e.validate="boolean"!=typeof e.validate||e.validate;const r=this.map._requestManager.transformRequest(t,tt.Style);this._request=Z(r,((t,r)=>{this._request=null,t?this.fire(new at(t)):r&&this._load(r,e,i)}))}loadJSON(t,e={},i){this.fire(new nt("dataloading",{dataType:"style"})),this._request=B.frame((()=>{this._request=null,e.validate=!1!==e.validate,this._load(t,e,i)}))}loadEmpty(){this.fire(new nt("dataloading",{dataType:"style"})),this._load(Ip,{validate:!1})}_load(t,e,i){var r;const s=e.transformStyle?e.transformStyle(i,t):t;if(!e.validate||!wp(this,Ur(s))){this._loaded=!0,this.stylesheet=s;for(const t in s.sources)this.addSource(t,s.sources[t],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new vh(this.stylesheet.light),this.map.setTerrain(null!==(r=this.stylesheet.terrain)&&void 0!==r?r:null),this.fire(new nt("data",{dataType:"style"})),this.fire(new nt("style.load"))}}_createLayers(){const t=ut(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const e of t){const t=lh(e);t.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=t}}_loadSprite(t,e=!1,i=void 0){this.imageManager.setLoaded(!1),this._spriteRequest=function(t,e,i,r){const s=ch(t),n=s.length,a=i>1?"@2x":"",o={},l={},c={};for(const{id:t,url:i}of s){const s=e.transformRequest(e.normalizeSpriteURL(i,a,".json"),tt.SpriteJSON),h=`${t}_${s.url}`;o[h]=Z(s,((e,i)=>{delete o[h],l[t]=i,hh(r,l,c,e,n)}));const u=e.transformRequest(e.normalizeSpriteURL(i,a,".png"),tt.SpriteImage),p=`${t}_${u.url}`;o[p]=Q.getImage(u,((e,i)=>{delete o[p],c[t]=i,hh(r,l,c,e,n)}))}return{cancel(){for(const t of Object.values(o))t.cancel()}}}(t,this.map._requestManager,this.map.getPixelRatio(),((t,r)=>{if(this._spriteRequest=null,t)this.fire(new at(t));else if(r)for(const t in r){this._spritesImagesIds[t]=[];const i=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in r))):[];for(const t of i)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const i in r[t]){const s="default"===t?i:`${t}:${i}`;this._spritesImagesIds[t].push(s),s in this.imageManager.images?this.imageManager.updateImage(s,r[t][i],!1):this.imageManager.addImage(s,r[t][i]),e&&(this._changedImages[s]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),e&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new nt("data",{dataType:"style"})),i&&i(t)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new nt("data",{dataType:"style"}))}_validateLayer(t){const e=this.sourceCaches[t.source];if(!e)return;const i=t.sourceLayer;if(!i)return;const r=e.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new at(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const e=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e);const i=[];for(const r of t)e[r]&&i.push(e[r]);return i}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const e=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const i={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];i[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const t in i){const e=this.sourceCaches[t];i[t]!==e.used&&e.fire(new nt("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.z=t.zoom,e&&this.fire(new nt("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,e={}){this._checkLoaded();const i=this.serialize();if(t=e.transformStyle?e.transformStyle(i,t):t,wp(this,Ur(t)))return!1;(t=S(t)).layers=ut(t.layers);const r=function(t,e){if(!t)return[{command:dt.setStyle,args:[e]}];let i=[];try{if(!pt(t.version,e.version))return[{command:dt.setStyle,args:[e]}];pt(t.center,e.center)||i.push({command:dt.setCenter,args:[e.center]}),pt(t.zoom,e.zoom)||i.push({command:dt.setZoom,args:[e.zoom]}),pt(t.bearing,e.bearing)||i.push({command:dt.setBearing,args:[e.bearing]}),pt(t.pitch,e.pitch)||i.push({command:dt.setPitch,args:[e.pitch]}),pt(t.sprite,e.sprite)||i.push({command:dt.setSprite,args:[e.sprite]}),pt(t.glyphs,e.glyphs)||i.push({command:dt.setGlyphs,args:[e.glyphs]}),pt(t.transition,e.transition)||i.push({command:dt.setTransition,args:[e.transition]}),pt(t.light,e.light)||i.push({command:dt.setLight,args:[e.light]});const r={},s=[];!function(t,e,i,r){let s;for(s in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,s)&&(Object.prototype.hasOwnProperty.call(e,s)||ft(s,i,r));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?pt(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&>(t,e,s)?i.push({command:dt.setGeoJSONSourceData,args:[s,e[s].data]}):_t(s,e,i,r)):mt(s,e,i))}(t.sources,e.sources,s,r);const n=[];t.layers&&t.layers.forEach((t=>{r[t.source]?i.push({command:dt.removeLayer,args:[t.id]}):n.push(t)})),i=i.concat(s),function(t,e,i){e=e||[];const r=(t=t||[]).map(xt),s=e.map(xt),n=t.reduce(vt,{}),a=e.reduce(vt,{}),o=r.slice(),l=Object.create(null);let c,h,u,p,d,m,f;for(c=0,h=0;c!(t.command in Sp)));if(0===r.length)return!1;const s=r.filter((t=>!(t.command in Tp)));if(s.length>0)throw new Error(`Unimplemented: ${s.map((t=>t.command)).join(", ")}.`);for(const t of r)"setTransition"!==t.command&&this[t.command].apply(this,t.args);return this.stylesheet=t,this._serializedLayers=null,!0}addImage(t,e){if(this.getImage(t))return this.fire(new at(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,e),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new at(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new nt("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!e.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(e.type)>=0&&this._validate(Ur.source,`sources.${t}`,e,null,i))return;this.map&&this.map._collectResourceTiming&&(e.collectResourceTiming=!0);const r=this.sourceCaches[t]=new hu(t,e,this.dispatcher);r.style=this,r.setEventedParent(this,(()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:t}))),r.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===t)return this.fire(new at(new Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));const e=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],e.fire(new nt("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),e.setEventedParent(null),e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,e,i={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new at(new Error(`Layer "${r}" already exists on this map.`)));let s;if("custom"===t.type){if(wp(this,function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e}(t)))return;s=lh(t)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(r,t.source),t=g(t=S(t),{source:r})),this._validate(Ur.layer,`layers.${r}`,t,{arrayIndex:-1},i))return;s=lh(t),this._validateLayer(s),s.setEventedParent(this,{layer:{id:r}})}const n=e?this._order.indexOf(e):this._order.length;if(e&&-1===n)this.fire(new at(new Error(`Cannot add layer "${r}" before non-existing layer "${e}".`)));else{if(this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=s,this._removedLayers[r]&&s.source&&"custom"!==s.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.sourceCaches[s.source].pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map)}}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new at(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;const i=this._order.indexOf(t);this._order.splice(i,1);const r=e?this._order.indexOf(e):this._order.length;e&&-1===r?this.fire(new at(new Error(`Cannot move layer "${t}" before non-existing layer "${e}".`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const e=this._layers[t];if(!e)return void this.fire(new at(new Error(`Cannot remove non-existing layer "${t}".`)));e.setEventedParent(null);const i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],e.onRemove&&e.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,e,i){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===e&&r.maxzoom===i||(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new at(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,e,i={}){this._checkLoaded();const r=this.getLayer(t);if(r){if(!T(r.filter,e))return null==e?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Ur.filter,`layers.${r.id}.filter`,e,null,i)||(r.filter=S(e),this._updateLayer(r)))}else this.fire(new at(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return S(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();const s=this.getLayer(t);s?T(s.getLayoutProperty(e),i)||(s.setLayoutProperty(e,i,r),this._updateLayer(s)):this.fire(new at(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){const i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new at(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();const s=this.getLayer(t);s?T(s.getPaintProperty(e),i)||(s.setPaintProperty(e,i,r)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new at(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();const i=t.source,r=t.sourceLayer,s=this.sourceCaches[i];if(void 0===s)return void this.fire(new at(new Error(`The source '${i}' does not exist in the map's style.`)));const n=s.getSource().type;"geojson"===n&&r?this.fire(new at(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==n||r?(void 0===t.id&&this.fire(new at(new Error("The feature id parameter must be provided."))),s.setFeatureState(r,t.id,e)):this.fire(new at(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,e){this._checkLoaded();const i=t.source,r=this.sourceCaches[i];if(void 0===r)return void this.fire(new at(new Error(`The source '${i}' does not exist in the map's style.`)));const s=r.getSource().type,n="vector"===s?t.sourceLayer:void 0;"vector"!==s||n?e&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new at(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,t.id,e):this.fire(new at(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const e=t.source,i=t.sourceLayer,r=this.sourceCaches[e];if(void 0!==r)return"vector"!==r.getSource().type||i?(void 0===t.id&&this.fire(new at(new Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id)):void this.fire(new at(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new at(new Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return g({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=b(this.sourceCaches,(t=>t.serialize())),e=this._serializeByIds(this._order),i=this.map.getTerrain()||void 0,r=this.stylesheet;return w({version:r.version,name:r.name,metadata:r.metadata,light:r.light,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,sources:t,layers:e,terrain:i},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let s=this._order.length-1;s>=0;s--){const n=this._order[s];if(e(n)){i[n]=s;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const s=[];for(let n=this._order.length-1;n>=0;n--){const a=this._order[n];if(e(a))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of s)e.push(t)}}for(const e in o)o[e].forEach((r=>{const s=r.feature,n=i[t[e].source].getFeatureState(s.layer["source-layer"],s.id);s.source=s.layer.source,s.layer["source-layer"]&&(s.sourceLayer=s.layer["source-layer"]),s.state=n}));return o}(this._layers,n,this.sourceCaches,t,e,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(t,e){e&&e.filter&&this._validate(Ur.filter,"querySourceFeatures.filter",e.filter,null,e);const i=this.sourceCaches[t];return i?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],s={};for(let t=0;t{Yh[t]=e})(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const e in t)if(!T(t[e],i[e])){r=!0;break}if(!r)return;const s={now:B.now(),transition:g({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(s)}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&wp(this,t.call(Ur,g({key:e,style:this.serialize(),value:i,styleSpec:lt},r)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),ps.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,e,i,r,s=!1){let n=!1,a=!1;const o={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!o[i.source]){const t=this.sourceCaches[i.source];o[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,o[i.source],t.center.lng);n=n||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((s=s||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(B.now(),t.zoom))&&(this.pauseablePlacement=new cp(t,this.map.terrain,this._order,s,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(B.now()),a=!0),n&&this.pauseablePlacement.placement.setStale()),a||n)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,o[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(B.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,e.icons)}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i);const r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,[""])}getResource(t,e,i){return q(e,i)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,e={}){this._checkLoaded(),t&&this._validate(Ur.glyphs,"glyphs",t,null,e)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,e,i={},r){this._checkLoaded();const s=[{id:t,url:e}],n=[...ch(this.stylesheet.sprite),...s];this._validate(Ur.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(s,!0,r))}removeSprite(t){this._checkLoaded();const e=ch(this.stylesheet.sprite);if(e.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;e.splice(e.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=e.length>0?e:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new nt("data",{dataType:"style"}))}else this.fire(new at(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return ch(this.stylesheet.sprite)}setSprite(t,e={},i){this._checkLoaded(),t&&this._validate(Ur.sprite,"sprite",t,null,e)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,i):(this._unloadSprite(),i&&i(null)))}}Ap.registerForPluginStateChange=function(t){return t({pluginStatus:ls,pluginURL:cs}),ps.on("pluginStateChange",t),t};var Ep=Bs([{name:"a_pos",type:"Int16",components:2}]),Cp="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const zp={prelude:Mp("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:Mp("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:Mp("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Mp("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Mp("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Mp("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}"),heatmapTexture:Mp("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Mp("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Mp("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Mp("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:Mp("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),fillOutline:Mp("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillOutlinePattern:Mp("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillPattern:Mp("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:Mp("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Mp("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Mp("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Mp("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:Mp("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Mp("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Mp("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Mp("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:Mp("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Mp("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Mp("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Mp("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Mp("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",Cp),terrainDepth:Mp("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",Cp),terrainCoords:Mp("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",Cp)};function Mp(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=n?n.concat(s):s,o={};return{fragmentSource:t=t.replace(i,((t,e,i,r,s)=>(o[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = u_${s};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,s)=>{const n="float"===r?"vec2":"vec4",a=s.match(/color/)?"color":n;return o[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class Pp{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,s,n,a,o,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t({u_depth:new ia(t,e.u_depth),u_terrain:new ia(t,e.u_terrain),u_terrain_dim:new ra(t,e.u_terrain_dim),u_terrain_matrix:new ca(t,e.u_terrain_matrix),u_terrain_unpack:new aa(t,e.u_terrain_unpack),u_terrain_exaggeration:new ra(t,e.u_terrain_exaggeration)}))(t,v),this.binderUniforms=i?i.getUniforms(t,v):[]}draw(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g){const y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(s),t.setCullFace(n),o){t.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,o.depthTexture),t.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,o.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(o[t])}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(a[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});let x=0;switch(e){case y.LINES:x=2;break;case y.TRIANGLES:x=3;break;case y.LINE_STRIP:x=1}for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[l]||(r[l]=new Pp)).bind(t,this,c,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,f,_,g),y.drawElements(e,i.primitiveLength*x,y.UNSIGNED_SHORT,i.primitiveOffset*x*2)}}}function Lp(t,e,i){const r=1/$u(i,1,e.transform.tileZoom),s=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,e.transform.tileZoom)/s,a=n*(i.tileID.canonical.x+i.tileID.wrap*s),o=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,o>>16],u_pixel_coord_lower:[65535&a,65535&o]}}const Rp=(t,e,i,r)=>{const s=e.style.light,n=s.properties.get("position"),a=[n.x,n.y,n.z],o=function(){var t=new ja(9);return ja!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}();"viewport"===s.properties.get("anchor")&&function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(o,-e.transform.angle),function(t,e,i){var r=e[0],s=e[1],n=e[2];t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8]}(a,a,o);const l=s.properties.get("color");return{u_matrix:t,u_lightpos:a,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+i,u_opacity:r}},Bp=(t,e,i,r,s,n,a)=>g(Rp(t,e,i,r),Lp(n,e,a),{u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8}),Fp=t=>({u_matrix:t}),Op=(t,e,i,r)=>g(Fp(t),Lp(i,e,r)),Vp=(t,e)=>({u_matrix:t,u_world:e}),Up=(t,e,i,r,s)=>g(Op(t,e,i,r),{u_world:s}),Np=(t,e,i,r)=>{const s=t.transform;let n,a;if("map"===r.paint.get("circle-pitch-alignment")){const t=$u(i,1,s.zoom);n=!0,a=[t,t]}else n=!1,a=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),u_pitch_with_map:+n,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},$p=(t,e,i)=>{const r=$u(i,1,e.zoom),s=Math.pow(2,e.zoom-i.tileID.overscaledZ),n=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:r,u_extrude_scale:[e.pixelsToGLUnits[0]/(r*s),e.pixelsToGLUnits[1]/(r*s)],u_overscale_factor:n}},qp=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),Zp=t=>({u_matrix:t}),jp=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:$u(e,1,i),u_intensity:r});function Gp(t,e){const i=Math.pow(2,e.canonical.z),r=e.canonical.y;return[new Bh(0,r/i).toLngLat().lat,new Bh(0,(r+1)/i).toLngLat().lat]}const Hp=(t,e,i,r)=>{const s=t.transform;return{u_matrix:Jp(t,e,i,r),u_ratio:1/$u(e,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Wp=(t,e,i,r,s)=>g(Hp(t,e,i,s),{u_image:0,u_image_height:r}),Xp=(t,e,i,r,s)=>{const n=t.transform,a=Yp(e,n);return{u_matrix:Jp(t,e,i,s),u_texsize:e.imageAtlasTexture.size,u_ratio:1/$u(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},Kp=(t,e,i,r,s,n)=>{const a=t.lineAtlas,o=Yp(e,t.transform),l="round"===i.layout.get("line-cap"),c=a.getDash(r.from,l),h=a.getDash(r.to,l),u=c.width*s.fromScale,p=h.width*s.toScale;return g(Hp(t,e,i,n),{u_patternscale_a:[o/u,-c.height/2],u_patternscale_b:[o/p,-h.height/2],u_sdfgamma:a.width/(256*Math.min(u,p)*t.pixelRatio)/2,u_image:0,u_tex_y_a:c.y,u_tex_y_b:h.y,u_mix:s.t})};function Yp(t,e){return 1/$u(t,1,e.tileZoom)}function Jp(t,e,i,r){return t.translatePosMatrix(r?r.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Qp=(t,e,i,r,s)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(a=s.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(n=s.paint.get("raster-contrast"),n>0?1/(1-n):1+n),u_spin_weights:td(s.paint.get("raster-hue-rotate"))};var n,a};function td(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const ed=(t,e,i,r,s,n,a,o,l,c)=>{const h=s.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:h.width/h.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:a,u_coord_matrix:o,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},id=(t,e,i,r,s,n,a,o,l,c,h)=>{const u=s.transform;return g(ed(t,e,i,r,s,n,a,o,l,c),{u_gamma_scale:r?Math.cos(u._pitch)*u.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+h})},rd=(t,e,i,r,s,n,a,o,l,c)=>g(id(t,e,i,r,s,n,a,o,!0,l,!0),{u_texsize_icon:c,u_texture_icon:1}),sd=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),nd=(t,e,i,r,s,n)=>g(function(t,e,i,r){const s=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:a,height:o}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[a,o],u_mix:e.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/$u(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(r,n,i,s),{u_matrix:t,u_opacity:e}),ad={fillExtrusion:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_lightpos:new na(t,e.u_lightpos),u_lightintensity:new ra(t,e.u_lightintensity),u_lightcolor:new na(t,e.u_lightcolor),u_vertical_gradient:new ra(t,e.u_vertical_gradient),u_opacity:new ra(t,e.u_opacity)}),fillExtrusionPattern:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_lightpos:new na(t,e.u_lightpos),u_lightintensity:new ra(t,e.u_lightintensity),u_lightcolor:new na(t,e.u_lightcolor),u_vertical_gradient:new ra(t,e.u_vertical_gradient),u_height_factor:new ra(t,e.u_height_factor),u_image:new ia(t,e.u_image),u_texsize:new sa(t,e.u_texsize),u_pixel_coord_upper:new sa(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new sa(t,e.u_pixel_coord_lower),u_scale:new na(t,e.u_scale),u_fade:new ra(t,e.u_fade),u_opacity:new ra(t,e.u_opacity)}),fill:(t,e)=>({u_matrix:new ca(t,e.u_matrix)}),fillPattern:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_image:new ia(t,e.u_image),u_texsize:new sa(t,e.u_texsize),u_pixel_coord_upper:new sa(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new sa(t,e.u_pixel_coord_lower),u_scale:new na(t,e.u_scale),u_fade:new ra(t,e.u_fade)}),fillOutline:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_world:new sa(t,e.u_world)}),fillOutlinePattern:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_world:new sa(t,e.u_world),u_image:new ia(t,e.u_image),u_texsize:new sa(t,e.u_texsize),u_pixel_coord_upper:new sa(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new sa(t,e.u_pixel_coord_lower),u_scale:new na(t,e.u_scale),u_fade:new ra(t,e.u_fade)}),circle:(t,e)=>({u_camera_to_center_distance:new ra(t,e.u_camera_to_center_distance),u_scale_with_map:new ia(t,e.u_scale_with_map),u_pitch_with_map:new ia(t,e.u_pitch_with_map),u_extrude_scale:new sa(t,e.u_extrude_scale),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_matrix:new ca(t,e.u_matrix)}),collisionBox:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_camera_to_center_distance:new ra(t,e.u_camera_to_center_distance),u_pixels_to_tile_units:new ra(t,e.u_pixels_to_tile_units),u_extrude_scale:new sa(t,e.u_extrude_scale),u_overscale_factor:new ra(t,e.u_overscale_factor)}),collisionCircle:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_inv_matrix:new ca(t,e.u_inv_matrix),u_camera_to_center_distance:new ra(t,e.u_camera_to_center_distance),u_viewport_size:new sa(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new oa(t,e.u_color),u_matrix:new ca(t,e.u_matrix),u_overlay:new ia(t,e.u_overlay),u_overlay_scale:new ra(t,e.u_overlay_scale)}),clippingMask:(t,e)=>({u_matrix:new ca(t,e.u_matrix)}),heatmap:(t,e)=>({u_extrude_scale:new ra(t,e.u_extrude_scale),u_intensity:new ra(t,e.u_intensity),u_matrix:new ca(t,e.u_matrix)}),heatmapTexture:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_world:new sa(t,e.u_world),u_image:new ia(t,e.u_image),u_color_ramp:new ia(t,e.u_color_ramp),u_opacity:new ra(t,e.u_opacity)}),hillshade:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_image:new ia(t,e.u_image),u_latrange:new sa(t,e.u_latrange),u_light:new sa(t,e.u_light),u_shadow:new oa(t,e.u_shadow),u_highlight:new oa(t,e.u_highlight),u_accent:new oa(t,e.u_accent)}),hillshadePrepare:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_image:new ia(t,e.u_image),u_dimension:new sa(t,e.u_dimension),u_zoom:new ra(t,e.u_zoom),u_unpack:new aa(t,e.u_unpack)}),line:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_ratio:new ra(t,e.u_ratio),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_units_to_pixels:new sa(t,e.u_units_to_pixels)}),lineGradient:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_ratio:new ra(t,e.u_ratio),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_units_to_pixels:new sa(t,e.u_units_to_pixels),u_image:new ia(t,e.u_image),u_image_height:new ra(t,e.u_image_height)}),linePattern:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_texsize:new sa(t,e.u_texsize),u_ratio:new ra(t,e.u_ratio),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_image:new ia(t,e.u_image),u_units_to_pixels:new sa(t,e.u_units_to_pixels),u_scale:new na(t,e.u_scale),u_fade:new ra(t,e.u_fade)}),lineSDF:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_ratio:new ra(t,e.u_ratio),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_units_to_pixels:new sa(t,e.u_units_to_pixels),u_patternscale_a:new sa(t,e.u_patternscale_a),u_patternscale_b:new sa(t,e.u_patternscale_b),u_sdfgamma:new ra(t,e.u_sdfgamma),u_image:new ia(t,e.u_image),u_tex_y_a:new ra(t,e.u_tex_y_a),u_tex_y_b:new ra(t,e.u_tex_y_b),u_mix:new ra(t,e.u_mix)}),raster:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_tl_parent:new sa(t,e.u_tl_parent),u_scale_parent:new ra(t,e.u_scale_parent),u_buffer_scale:new ra(t,e.u_buffer_scale),u_fade_t:new ra(t,e.u_fade_t),u_opacity:new ra(t,e.u_opacity),u_image0:new ia(t,e.u_image0),u_image1:new ia(t,e.u_image1),u_brightness_low:new ra(t,e.u_brightness_low),u_brightness_high:new ra(t,e.u_brightness_high),u_saturation_factor:new ra(t,e.u_saturation_factor),u_contrast_factor:new ra(t,e.u_contrast_factor),u_spin_weights:new na(t,e.u_spin_weights)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new ia(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new ia(t,e.u_is_size_feature_constant),u_size_t:new ra(t,e.u_size_t),u_size:new ra(t,e.u_size),u_camera_to_center_distance:new ra(t,e.u_camera_to_center_distance),u_pitch:new ra(t,e.u_pitch),u_rotate_symbol:new ia(t,e.u_rotate_symbol),u_aspect_ratio:new ra(t,e.u_aspect_ratio),u_fade_change:new ra(t,e.u_fade_change),u_matrix:new ca(t,e.u_matrix),u_label_plane_matrix:new ca(t,e.u_label_plane_matrix),u_coord_matrix:new ca(t,e.u_coord_matrix),u_is_text:new ia(t,e.u_is_text),u_pitch_with_map:new ia(t,e.u_pitch_with_map),u_texsize:new sa(t,e.u_texsize),u_texture:new ia(t,e.u_texture)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new ia(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new ia(t,e.u_is_size_feature_constant),u_size_t:new ra(t,e.u_size_t),u_size:new ra(t,e.u_size),u_camera_to_center_distance:new ra(t,e.u_camera_to_center_distance),u_pitch:new ra(t,e.u_pitch),u_rotate_symbol:new ia(t,e.u_rotate_symbol),u_aspect_ratio:new ra(t,e.u_aspect_ratio),u_fade_change:new ra(t,e.u_fade_change),u_matrix:new ca(t,e.u_matrix),u_label_plane_matrix:new ca(t,e.u_label_plane_matrix),u_coord_matrix:new ca(t,e.u_coord_matrix),u_is_text:new ia(t,e.u_is_text),u_pitch_with_map:new ia(t,e.u_pitch_with_map),u_texsize:new sa(t,e.u_texsize),u_texture:new ia(t,e.u_texture),u_gamma_scale:new ra(t,e.u_gamma_scale),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_is_halo:new ia(t,e.u_is_halo)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new ia(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new ia(t,e.u_is_size_feature_constant),u_size_t:new ra(t,e.u_size_t),u_size:new ra(t,e.u_size),u_camera_to_center_distance:new ra(t,e.u_camera_to_center_distance),u_pitch:new ra(t,e.u_pitch),u_rotate_symbol:new ia(t,e.u_rotate_symbol),u_aspect_ratio:new ra(t,e.u_aspect_ratio),u_fade_change:new ra(t,e.u_fade_change),u_matrix:new ca(t,e.u_matrix),u_label_plane_matrix:new ca(t,e.u_label_plane_matrix),u_coord_matrix:new ca(t,e.u_coord_matrix),u_is_text:new ia(t,e.u_is_text),u_pitch_with_map:new ia(t,e.u_pitch_with_map),u_texsize:new sa(t,e.u_texsize),u_texsize_icon:new sa(t,e.u_texsize_icon),u_texture:new ia(t,e.u_texture),u_texture_icon:new ia(t,e.u_texture_icon),u_gamma_scale:new ra(t,e.u_gamma_scale),u_device_pixel_ratio:new ra(t,e.u_device_pixel_ratio),u_is_halo:new ia(t,e.u_is_halo)}),background:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_opacity:new ra(t,e.u_opacity),u_color:new oa(t,e.u_color)}),backgroundPattern:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_opacity:new ra(t,e.u_opacity),u_image:new ia(t,e.u_image),u_pattern_tl_a:new sa(t,e.u_pattern_tl_a),u_pattern_br_a:new sa(t,e.u_pattern_br_a),u_pattern_tl_b:new sa(t,e.u_pattern_tl_b),u_pattern_br_b:new sa(t,e.u_pattern_br_b),u_texsize:new sa(t,e.u_texsize),u_mix:new ra(t,e.u_mix),u_pattern_size_a:new sa(t,e.u_pattern_size_a),u_pattern_size_b:new sa(t,e.u_pattern_size_b),u_scale_a:new ra(t,e.u_scale_a),u_scale_b:new ra(t,e.u_scale_b),u_pixel_coord_upper:new sa(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new sa(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new ra(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_texture:new ia(t,e.u_texture),u_ele_delta:new ra(t,e.u_ele_delta)}),terrainDepth:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_ele_delta:new ra(t,e.u_ele_delta)}),terrainCoords:(t,e)=>({u_matrix:new ca(t,e.u_matrix),u_texture:new ia(t,e.u_texture),u_terrain_coords_id:new ra(t,e.u_terrain_coords_id),u_ele_delta:new ra(t,e.u_ele_delta)})};class od{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ld={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class cd{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i0){const e=Ga(),i=g;to(e,_.placementInvProjMatrix,t.transform.glCoordMatrix),to(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:p,transform:i,invTransform:e,coord:m}),u+=x.length/4,p=u}y&&c.draw(o,l.LINES,Yd.disabled,Qd.disabled,t.colorModeForRenderPass(),tm.disabled,$p(g,t.transform,f),t.style.map.terrain&&t.style.map.terrain.getTerrainData(m),i.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,null,y.collisionVertexBuffer)}if(!a||!h.length)return;const d=t.useProgram("collisionCircle"),m=new Dn;m.resize(4*u),m._trim();let f=0;for(const t of h)for(let e=0;e=0&&(f[_.associatedIconIndex]={shiftedAnchor:I,angle:A})}else Bu(_.numGlyphs,d)}if(h){m.clear();const e=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(o,e,i):null,r="map"===i.layout.get("text-rotation-alignment");Au(l,o.posMatrix,t,s,R,B,_,c,r,e)}const V=t.translatePosMatrix(o.posMatrix,r,n,a),U=g||s&&w||O?rm:R,N=t.translatePosMatrix(B,r,n,a,!0),$=p&&0!==i.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let q;q=p?l.iconsInText?rd(b.kind,A,y,_,t,V,U,N,C,k):id(b.kind,A,y,_,t,V,U,N,s,C,!0):ed(b.kind,A,y,_,t,V,U,N,s,C);const Z={program:I,buffers:h,uniformValues:q,atlasTexture:z,atlasTextureIcon:D,atlasInterpolation:M,atlasInterpolationIcon:P,isSDF:p,hasHalo:$};if(x&&l.canOverlap){v=!0;const t=h.segments.get();for(const e of t)T.push({segments:new Nn([e]),sortKey:e.sortKey,state:Z,terrainData:E})}else T.push({segments:h.segments,sortKey:0,state:Z,terrainData:E})}v&&T.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of T){const r=e.state;if(p.activeTexture.set(d.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,d.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(d.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,d.CLAMP_TO_EDGE)),r.isSDF){const s=r.uniformValues;r.hasHalo&&(s.u_is_halo=1,lm(r.buffers,e.segments,i,t,r.program,b,h,u,s,e.terrainData)),s.u_is_halo=0}lm(r.buffers,e.segments,i,t,r.program,b,h,u,r.uniformValues,e.terrainData)}}function lm(t,e,i,r,s,n,a,o,l,c){const h=r.context;s.draw(h,h.gl.TRIANGLES,n,a,o,tm.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function cm(t,e,i,r,s){if(!i||!r||!r.imageAtlas)return;const n=r.imageAtlas.patternPositions;let a=n[i.to.toString()],o=n[i.from.toString()];if(!a&&o&&(a=o),!o&&a&&(o=a),!a||!o){const t=s.getPaintProperty(e);a=n[t],o=n[t]}a&&o&&t.setConstantPatternPositions(a,o)}function hm(t,e,i,r,s,n,a){const o=t.context.gl,l="fill-pattern",c=i.paint.get(l),h=c&&c.constantOr(1),u=i.getCrossfadeParameters();let p,d,m,f,_;a?(d=h&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=o.LINES):(d=h?"fillPattern":"fill",p=o.TRIANGLES);const g=c.constantOr(null);for(const c of r){const r=e.getTile(c);if(h&&!r.patternsLoaded())continue;const y=r.getBucket(i);if(!y)continue;const x=y.programConfigurations.get(i.id),v=t.useProgram(d,x),b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(c);h&&(t.context.activeTexture.set(o.TEXTURE0),r.imageAtlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),x.updatePaintBuffers(u)),cm(x,l,g,r,i);const w=b?c:null,T=t.translatePosMatrix(w?w.posMatrix:c.posMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){f=y.indexBuffer2,_=y.segments2;const e=[o.drawingBufferWidth,o.drawingBufferHeight];m="fillOutlinePattern"===d&&h?Up(T,t,u,r,e):Vp(T,e)}else f=y.indexBuffer,_=y.segments,m=h?Op(T,t,u,r):Fp(T);v.draw(t.context,p,s,t.stencilModeForClipping(c),n,tm.disabled,m,b,i.id,y.layoutVertexBuffer,f,_,i.paint,t.transform.zoom,x)}}function um(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c="fill-extrusion-pattern",h=i.paint.get(c),u=h.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),m=h.constantOr(null);for(const h of r){const r=e.getTile(h),f=r.getBucket(i);if(!f)continue;const _=t.style.map.terrain&&t.style.map.terrain.getTerrainData(h),g=f.programConfigurations.get(i.id),y=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",g);u&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),g.updatePaintBuffers(p)),cm(g,c,m,r,i);const x=t.translatePosMatrix(h.posMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),b=u?Bp(x,t,v,d,h,p,r):Rp(x,t,v,d);y.draw(o,o.gl.TRIANGLES,s,n,a,tm.backCCW,b,_,i.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,i.paint,t.transform.zoom,g,t.style.map.terrain&&f.centroidVertexBuffer)}}function pm(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=i.fbo;if(!c)return;const h=t.useProgram("hillshade"),u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);o.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get()),h.draw(o,l.TRIANGLES,s,n,a,tm.disabled,((t,e,i,r)=>{const s=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let o=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(o-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:Gp(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),o],u_shadow:s,u_highlight:n,u_accent:a}})(t,i,r,u?e:null),u,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}function dm(t,e,i,r,s,n){const a=t.context,o=a.gl,l=e.dem;if(l&&l.data){const c=l.dim,h=l.stride,u=l.getPixels();if(a.activeTexture.set(o.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||t.getTileTexture(h),e.demTexture){const t=e.demTexture;t.update(u,{premultiply:!1}),t.bind(o.NEAREST,o.CLAMP_TO_EDGE)}else e.demTexture=new uh(a,u,o.RGBA,{premultiply:!1}),e.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);a.activeTexture.set(o.TEXTURE0);let p=e.fbo;if(!p){const t=new uh(a,{width:c,height:c,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),p=e.fbo=a.createFramebuffer(c,c,!0,!1),p.colorAttachment.set(t.texture)}a.bindFramebuffer.set(p.framebuffer),a.viewport.set([0,0,c,c]),t.useProgram("hillshadePrepare").draw(a,o.TRIANGLES,r,s,n,tm.disabled,((t,e)=>{const i=e.stride,r=Ga();return Qa(r,0,va,-va,0,0,1),Ka(r,r,[0,-va,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.getUnpackVector()}})(e.tileID,l),null,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function mm(t,e,i,r,s,n){const a=r.paint.get("raster-fade-duration");if(!n&&a>0){const r=B.now(),n=(r-t.timeAdded)/a,o=e?(r-e.timeAdded)/a:-1,l=i.getSource(),c=s.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),h=!e||Math.abs(e.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),u=h&&t.refreshedUponExpiration?1:m(h?n:1-o,0,1);return t.refreshedUponExpiration&&n>=1&&(t.refreshedUponExpiration=!1),e?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return{opacity:1,mix:0}}const fm=new he(1,0,0,1),_m=new he(0,1,0,1),gm=new he(0,0,1,1),ym=new he(1,0,1,1),xm=new he(0,1,1,1);function vm(t,e,i,r){wm(t,0,e+i/2,t.transform.width,i,r)}function bm(t,e,i,r){wm(t,e-i/2,0,i,t.transform.height,r)}function wm(t,e,i,r,s,n){const a=t.context,o=a.gl;o.enable(o.SCISSOR_TEST),o.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,s*t.pixelRatio),a.clear({color:n}),o.disable(o.SCISSOR_TEST)}function Tm(t,e,i){const r=t.context,s=r.gl,n=i.posMatrix,a=t.useProgram("debug"),o=Yd.disabled,l=Qd.disabled,c=t.colorModeForRenderPass(),h="$debug",u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(i);r.activeTexture.set(s.TEXTURE0);const p=e.getTileByID(i.key).latestRawTileData,d=Math.floor((p&&p.byteLength||0)/1024),m=e.getTile(i).tileSize,f=512/Math.min(m,512)*(i.overscaledZ/t.transform.zoom)*.5;let _=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(_+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${_} ${d}kB`),a.draw(r,s.TRIANGLES,o,l,Xd.alphaBlended,tm.disabled,qp(n,he.transparent,f),null,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),a.draw(r,s.LINE_STRIP,o,l,c,tm.disabled,qp(n,he.red),u,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Sm(t,e,i){const r=t.context,s=r.gl,n=t.colorModeForRenderPass(),a=new Yd(s.LEQUAL,Yd.ReadWrite,t.depthRangeFor3D),o=t.useProgram("terrain"),l=e.getTerrainMesh();r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]);for(const c of i){const i=t.renderToTexture.getTexture(c),h=e.getTerrainData(c.tileID);r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,i.texture);const u={u_matrix:t.transform.calculatePosMatrix(c.tileID.toUnwrapped()),u_texture:0,u_ele_delta:e.getMeshFrameDelta(t.transform.zoom)};o.draw(r,s.TRIANGLES,a,Qd.disabled,n,tm.backCCW,u,h,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}class Im{constructor(t,e){this.context=new Kd(t),this.transform=e,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:Ga(),renderTime:0},this.setup(),this.numSublayers=hu.maxUnderzooming+hu.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new bp}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,e=new vn;e.emplaceBack(0,0),e.emplaceBack(va,0),e.emplaceBack(0,va),e.emplaceBack(va,va),this.tileExtentBuffer=t.createVertexBuffer(e,Ep.members),this.tileExtentSegments=Nn.simpleSegment(0,0,4,2);const i=new vn;i.emplaceBack(0,0),i.emplaceBack(va,0),i.emplaceBack(0,va),i.emplaceBack(va,va),this.debugBuffer=t.createVertexBuffer(i,Ep.members),this.debugSegments=Nn.simpleSegment(0,0,4,5);const r=new wn;r.emplaceBack(0,0,0,0),r.emplaceBack(va,0,va,0),r.emplaceBack(0,va,0,va),r.emplaceBack(va,va,va,va),this.rasterBoundsBuffer=t.createVertexBuffer(r,Hh.members),this.rasterBoundsSegments=Nn.simpleSegment(0,0,4,2);const s=new vn;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,Ep.members),this.viewportSegments=Nn.simpleSegment(0,0,4,2);const n=new On;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(n);const a=new Bn;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const o=this.context.gl;this.stencilClearMode=new Qd({func:o.ALWAYS,mask:0},0,255,o.ZERO,o.ZERO,o.ZERO)}clearStencil(){const t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const i=Ga();Qa(i,0,this.width,this.height,0,0,1),Ya(i,i,[e.drawingBufferWidth,e.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,e.TRIANGLES,Yd.disabled,this.stencilClearMode,Xd.disabled,tm.disabled,Zp(i),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const i=this.context,r=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(Xd.disabled),i.setDepthMode(Yd.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,n=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);s.draw(i,r.TRIANGLES,Yd.disabled,new Qd({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Xd.disabled,tm.disabled,Zp(t.posMatrix),n,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Qd({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Qd({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,s=i[0].overscaledZ-r+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const t={};for(let i=0;i=0;this.currentLayer--){const t=this.style._layers[i[this.currentLayer]],e=r[t.source],n=s[t.source];this._renderTileClippingMasks(t,n),this.renderLayer(this,e,t,n)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayeri.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[])),s=r.filter((t=>"vector"===t.getSource().type)),n=r.filter((t=>"vector"!==t.getSource().type)),a=t=>{(!i||i.getSource().maxzooma(t))),i||n.forEach((t=>a(t))),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let r=0;re.style.map.terrain.getElevation(s,t,i):null)}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),s),0!==i.paint.get("icon-opacity").constantOr(1)&&om(t,e,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),n,a),0!==i.paint.get("text-opacity").constantOr(1)&&om(t,e,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),n,a),e.map.showCollisionBoxes&&(im(t,e,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),im(t,e,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))}(t,e,i,r,this.style.placement.variableOffsets);break;case"circle":!function(t,e,i,r){if("translucent"!==t.renderPass)return;const s=i.paint.get("circle-opacity"),n=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),o=!i.layout.get("circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===n.constantOr(1)||0===a.constantOr(1)))return;const l=t.context,c=l.gl,h=t.depthModeForSublayer(0,Yd.ReadOnly),u=Qd.disabled,p=t.colorModeForRenderPass(),d=[];for(let s=0;st.sortKey-e.sortKey));for(const e of d){const{programConfiguration:r,program:s,layoutVertexBuffer:n,indexBuffer:a,uniformValues:o,terrainData:d}=e.state;s.draw(l,c.TRIANGLES,h,u,p,tm.disabled,o,d,i.id,n,a,e.segments,i.paint,t.transform.zoom,r)}}(t,e,i,r);break;case"heatmap":!function(t,e,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const s=t.context,n=s.gl,a=Qd.disabled,o=new Xd([n.ONE,n.ONE],he.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let s=i.heatmapFbo;if(s)r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer);else{const n=r.createTexture();r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),s=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1,!1),function(t,e,i,r){var s,n;const a=t.gl,o=null!==(s=t.HALF_FLOAT)&&void 0!==s?s:a.UNSIGNED_BYTE,l=null!==(n=t.RGBA16F)&&void 0!==n?n:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,e.width/4,e.height/4,0,a.RGBA,o,null),r.colorAttachment.set(i)}(t,e,n,s)}}(s,t,i),s.clear({color:he.transparent});for(let l=0;l{const s=Ga();Qa(s,0,t.width,t.height,0,0,1);const n=t.context.gl;return{u_matrix:s,u_world:[n.drawingBufferWidth,n.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}})(t,e),null,e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.transform.zoom)}(t,i))}(t,e,i,r);break;case"line":!function(t,e,i,r){if("translucent"!==t.renderPass)return;const s=i.paint.get("line-opacity"),n=i.paint.get("line-width");if(0===s.constantOr(1)||0===n.constantOr(1))return;const a=t.depthModeForSublayer(0,Yd.ReadOnly),o=t.colorModeForRenderPass(),l=i.paint.get("line-dasharray"),c=i.paint.get("line-pattern"),h=c.constantOr(1),u=i.paint.get("line-gradient"),p=i.getCrossfadeParameters(),d=h?"linePattern":l?"lineSDF":u?"lineGradient":"line",f=t.context,_=f.gl;let g=!0;for(const s of r){const r=e.getTile(s);if(h&&!r.patternsLoaded())continue;const n=r.getBucket(i);if(!n)continue;const x=n.programConfigurations.get(i.id),v=t.context.program.get(),b=t.useProgram(d,x),w=g||b.program!==v,T=t.style.map.terrain&&t.style.map.terrain.getTerrainData(s),S=c.constantOr(null);if(S&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[S.to.toString()],i=t.patternPositions[S.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const I=T?s:null,A=h?Xp(t,r,i,p,I):l?Kp(t,r,i,l,p,I):u?Wp(t,r,i,n.lineClipsArray.length,I):Hp(t,r,i,I);if(h)f.activeTexture.set(_.TEXTURE0),r.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),x.updatePaintBuffers(p);else if(l&&(w||t.lineAtlas.dirty))f.activeTexture.set(_.TEXTURE0),t.lineAtlas.bind(f);else if(u){const r=n.gradients[i.id];let a=r.texture;if(i.gradientVersion!==r.version){let o=256;if(i.stepInterpolant){const i=e.getSource().maxzoom,r=s.canonical.z===i?Math.ceil(1<0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new Dp(this.context,zp[t],e,ad[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new uh(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class Am{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i){const r=Math.pow(2,i),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const s=1/(i=so([],i,t))[3]/e*r;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(i,i,[s,s,1/i[3],s])})),n=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=function(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}([],function(t,e,i){var r=e[0],s=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-n*o,t[1]=n*a-r*l,t[2]=r*o-s*a,t}([],ro([],s[t[0]],s[t[1]]),ro([],s[t[2]],s[t[1]]))),i=-((r=e)[0]*(n=s[t[1]])[0]+r[1]*n[1]+r[2]*n[2]);var r,n;return e.concat(i)}));return new Am(s,n)}}class Em{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max))}quadrant(t){const e=[t%2==0,t<2],i=eo(this.min),r=eo(this.max);for(let t=0;t=0&&o++;if(0===o)return 0;o!==e.length&&(i=!1)}var r,s;if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let s=0;sthis.max[e]-this.min[e])return 0}return 1}}class Cm{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=ni.number(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=ni.number(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=ni.number(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=ni.number(t.right,e.right,i)),this}getCenter(t,e){const i=m((this.left+t-this.right)/2,0,t),r=m((this.top+e-this.bottom)/2,0,e);return new n(i,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Cm(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class zm{constructor(t,e,i,r,s){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===s||!!s,this._minZoom=t||0,this._maxZoom=e||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setMaxBounds(),this.width=0,this.height=0,this._center=new Eh(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Cm,this._posMatrixCache={},this._alignedPosMatrixCache={},this._minEleveationForCurrentTile=0}clone(){const t=new zm(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this._minEleveationForCurrentTile=t._minEleveationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new n(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const e=-f(t,-180,180)*Math.PI/180;this.angle!==e&&(this._unmodified=!1,this.angle=e,this._calcMatrices(),this.rotationMatrix=function(){var t=new ja(4);return ja!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}(),function(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*o,t[1]=s*l+a*o,t[2]=r*-o+n*l,t[3]=s*-o+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const e=m(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==e&&(this._unmodified=!1,this._pitch=e,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const e=[new $h(0,t)];if(this._renderWorldCopies){const i=this.pointCoordinate(new n(0,0)),r=this.pointCoordinate(new n(this.width,0)),s=this.pointCoordinate(new n(this.width,this.height)),a=this.pointCoordinate(new n(0,this.height)),o=Math.floor(Math.min(i.x,r.x,s.x,a.x)),l=Math.floor(Math.max(i.x,r.x,s.x,a.x)),c=1;for(let i=o-c;i<=l+c;i++)0!==i&&e.push(new $h(i,t))}return e}coveringTiles(t){var e,i;let r=this.coveringZoomLevel(t);const s=r;if(void 0!==t.minzoom&&rt.maxzoom&&(r=t.maxzoom);const n=this.pointCoordinate(this.getCameraPoint()),a=Bh.fromLngLat(this.center),o=Math.pow(2,r),l=[o*n.x,o*n.y,0],c=[o*a.x,o*a.y,0],h=Am.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r);let u=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(u=r);const p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,d=t=>({aabb:new Em([t*o,0,0],[(t+1)*o,o,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],f=[],_=r,g=t.reparseOverscaled?s:r;if(this._renderWorldCopies)for(let t=1;t<=3;t++)m.push(d(-t)),m.push(d(t));for(m.push(d(0));m.length>0;){const r=m.pop(),s=r.x,n=r.y;let a=r.fullyVisible;if(!a){const t=r.aabb.intersects(h);if(0===t)continue;a=2===t}const o=t.terrain?l:c,d=r.aabb.distanceX(o),y=r.aabb.distanceY(o),x=Math.max(Math.abs(d),Math.abs(y));if(r.zoom===_||x>p+(1<<_-r.zoom)-2&&r.zoom>=u){const t=_-r.zoom,e=l[0]-.5-(s<>1),h=r.zoom+1;let u=r.aabb.quadrant(o);if(t.terrain){const s=new qh(h,r.wrap,h,l,c),n=t.terrain.getMinMaxElevation(s),a=null!==(e=n.minElevation)&&void 0!==e?e:this.elevation,o=null!==(i=n.maxElevation)&&void 0!==i?i:this.elevation;u=new Em([u.min[0],u.min[1],a],[u.max[0],u.max[1],o])}m.push({aabb:u,zoom:h,x:l,y:c,wrap:r.wrap,fullyVisible:a})}}return f.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const e=m(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new n(Ph(t.lng)*this.worldSize,kh(e)*this.worldSize)}unproject(t){return new Bh(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const e=this.pointLocation(this.centerPoint,t),i=t.getElevationForLngLatZoom(e,this.tileZoom);if(!(this.elevation-i))return;const r=this.getCameraPosition(),s=Bh.fromLngLat(r.lngLat,r.altitude),n=Bh.fromLngLat(e,i),a=s.x-n.x,o=s.y-n.y,l=s.z-n.z,c=Math.sqrt(a*a+o*o+l*l),h=this.scaleZoom(this.cameraToCenterDistance/c/this.tileSize);this._elevation=i,this._center=e,this.zoom=h}setLocationAtPoint(t,e){const i=this.pointCoordinate(e),r=this.pointCoordinate(this.centerPoint),s=this.locationCoordinate(t),n=new Bh(s.x-(i.x-r.x),s.y-(i.y-r.y));this.center=this.coordinateLocation(n),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return Bh.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];so(i,i,this.pixelMatrixInverse),so(r,r,this.pixelMatrixInverse);const s=i[3],n=r[3],a=i[1]/s,o=r[1]/n,l=i[2]/s,c=r[2]/n,h=l===c?0:(0-l)/(c-l);return new Bh(ni.number(i[0]/s,r[0]/n,h)/this.worldSize,ni.number(a,o,h)/this.worldSize)}coordinatePoint(t,e=0,i=this.pixelMatrix){const r=[t.x*this.worldSize,t.y*this.worldSize,e,1];return so(r,r,i),new n(r[0]/r[3],r[1]/r[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return(new Ch).extend(this.pointLocation(new n(0,t))).extend(this.pointLocation(new n(this.width,t))).extend(this.pointLocation(new n(this.width,this.height))).extend(this.pointLocation(new n(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new Ch([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,e=!1){const i=t.key,r=e?this._alignedPosMatrixCache:this._posMatrixCache;if(r[i])return r[i];const s=t.canonical,n=this.worldSize/this.zoomScale(s.z),a=s.x+Math.pow(2,s.z)*t.wrap,o=Ha(new Float64Array(16));return Ka(o,o,[a*n,s.y*n,0]),Ya(o,o,[n/va,n/va,1]),Xa(o,e?this.alignedProjMatrix:this.projMatrix,o),r[i]=new Float32Array(o),r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,e,i,r,s=-90,a=90,o=-180,l=180;const c=this.size,h=this._unmodified;if(this.latRange){const e=this.latRange;s=kh(e[1])*this.worldSize,a=kh(e[0])*this.worldSize,t=a-sa&&(r=a-e)}if(this.lngRange){const t=(o+l)/2,e=f(u.x,t-this.worldSize/2,t+this.worldSize/2),r=c.x/2;e-rl&&(i=l-r)}void 0===i&&void 0===r||(this.center=this.unproject(new n(void 0!==i?i:u.x,void 0!==r?r:u.y)).wrap()),this._unmodified=h,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,e=this.point.x,i=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=Dh(1,this.center.lat)*this.worldSize;let r=Ha(new Float64Array(16));Ya(r,r,[this.width/2,-this.height/2,1]),Ka(r,r,[1,-1,0]),this.labelPlaneMatrix=r,r=Ha(new Float64Array(16)),Ya(r,r,[1,-1,1]),Ka(r,r,[-1,-1,0]),Ya(r,r,[2/this.width,2/this.height,1]),this.glCoordMatrix=r;const s=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),n=Math.min(this.elevation,this._minEleveationForCurrentTile),a=s-n*this._pixelPerMeter/Math.cos(this._pitch),o=n<0?a:s,l=Math.PI/2+this._pitch,c=this._fov*(.5+t.y/this.height),h=Math.sin(c)*o/Math.sin(m(Math.PI-l-c,.01,Math.PI-.01)),u=this.getHorizon(),p=2*Math.atan(u/this.cameraToCenterDistance)*(.5+t.y/(2*u)),d=Math.sin(p)*o/Math.sin(m(Math.PI-l-p,.01,Math.PI-.01)),f=Math.min(h,d),_=1.01*(Math.cos(Math.PI/2-this._pitch)*f+o),g=this.height/50;r=new Float64Array(16),function(t,e,i,r,s){var n,a=1/Math.tan(e/2);t[0]=a/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0?(t[10]=(s+r)*(n=1/(r-s)),t[14]=2*s*r*n):(t[10]=-1,t[14]=-2*r)}(r,this._fov,this.width/this.height,g,_),r[8]=2*-t.x/this.width,r[9]=2*t.y/this.height,Ya(r,r,[1,-1,1]),Ka(r,r,[0,0,-this.cameraToCenterDistance]),function(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],p=e[11];e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*s+c*r,t[5]=a*s+h*r,t[6]=o*s+u*r,t[7]=l*s+p*r,t[8]=c*s-n*r,t[9]=h*s-a*r,t[10]=u*s-o*r,t[11]=p*s-l*r}(r,r,this._pitch),Ja(r,r,this.angle),Ka(r,r,[-e,-i,0]),this.mercatorMatrix=Ya([],r,[this.worldSize,this.worldSize,this.worldSize]),Ya(r,r,[1,1,this._pixelPerMeter]),this.pixelMatrix=Xa(new Float64Array(16),this.labelPlaneMatrix,r),Ka(r,r,[0,0,-this.elevation]),this.projMatrix=r,this.invProjMatrix=Wa([],r),this.pixelMatrix3D=Xa(new Float64Array(16),this.labelPlaneMatrix,r);const y=this.width%2/2,x=this.height%2/2,v=Math.cos(this.angle),b=Math.sin(this.angle),w=e-Math.round(e)+v*y+b*x,T=i-Math.round(i)+v*x+b*y,S=new Float64Array(r);if(Ka(S,S,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=S,r=Wa(new Float64Array(16),this.pixelMatrix),!r)throw new Error("failed to invert matrix");this.pixelMatrixInverse=r,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new n(0,0)),e=[t.x*this.worldSize,t.y*this.worldSize,0,1];return so(e,e,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new n(0,t))}getCameraQueryGeometry(t){const e=this.getCameraPoint();if(1===t.length)return[t[0],e];{let i=e.x,r=e.y,s=e.x,a=e.y;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y);return[new n(i,r),new n(s,r),new n(s,a),new n(i,a),new n(i,r)]}}}function Mm(t,e){let i,r=!1,s=null,n=null;const a=()=>{s=null,r&&(t.apply(n,i),s=setTimeout(a,e),r=!1)};return(...t)=>(r=!0,n=this,i=t,s||a(),s)}class Pm{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}},this._updateHash=Mm(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),n=Math.round(e.lng*s)/s,a=Math.round(e.lat*s)/s,o=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${n}/${a}/${i}`:`${i}/${a}/${n}`,(o||l)&&(c+="/"+Math.round(10*o)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}}const km={linearity:.3,easing:p(0,0,.3,1)},Dm=g({deceleration:2500,maxSpeed:1400},km),Lm=g({deceleration:20,maxSpeed:1400},km),Rm=g({deceleration:1e3,maxSpeed:360},km),Bm=g({deceleration:1e3,maxSpeed:90},km);class Fm{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:B.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=B.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const e={zoom:0,bearing:0,pitch:0,pan:new n(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)e.zoom+=t.zoomDelta||0,e.bearing+=t.bearingDelta||0,e.pitch+=t.pitchDelta||0,t.panDelta&&e.pan._add(t.panDelta),t.around&&(e.around=t.around),t.pinchAround&&(e.pinchAround=t.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(e.pan.mag()){const s=Vm(e.pan.mag(),i,g({},Dm,t||{}));r.offset=e.pan.mult(s.amount/e.pan.mag()),r.center=this._map.transform.center,Om(r,s)}if(e.zoom){const t=Vm(e.zoom,i,Lm);r.zoom=this._map.transform.zoom+t.amount,Om(r,t)}if(e.bearing){const t=Vm(e.bearing,i,Rm);r.bearing=this._map.transform.bearing+m(t.amount,-179,179),Om(r,t)}if(e.pitch){const t=Vm(e.pitch,i,Bm);r.pitch=this._map.transform.pitch+t.amount,Om(r,t)}if(r.zoom||r.bearing){const t=void 0===e.pinchAround?e.around:e.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),g(r,{noMoveStart:!0})}}function Om(t,e){(!t.duration||t.duratione.unproject(t))),o=s.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new n(0,0));super(t,{points:s,point:o,lngLats:a,lngLat:e.unproject(o),originalEvent:i}),this._defaultPrevented=!1}}class $m extends nt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class qm{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new $m(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new Um(t.type,this._map,t))}mouseup(t){this._map.fire(new Um(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new Um(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Um(t.type,this._map,t))}mouseover(t){this._map.fire(new Um(t.type,this._map,t))}mouseout(t){this._map.fire(new Um(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Nm(t.type,this._map,t))}touchmove(t){this._map.fire(new Nm(t.type,this._map,t))}touchend(t){this._map.fire(new Nm(t.type,this._map,t))}touchcancel(t){this._map.fire(new Nm(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Zm{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Um(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Um("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Um(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class jm{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(n.convert(t),this._map.terrain)}}class Gm{constructor(t,e){this._map=t,this._tr=new jm(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(F.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)t.fitScreenCoordinates(i,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(F.remove(this._box),this._box=null),F.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new nt(t,{originalEvent:e}))}}function Hm(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const e=new n(0,0);for(const i of t)e._add(i);return e.div(t.length)}(e),this.touches=Hm(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=Hm(i,e);for(const t in this.touches){const e=r[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Xm{constructor(t){this.singleTap=new Wm(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Km{constructor(t){this._tr=new jm(t),this._zoomIn=new Xm({numTouches:1,numTaps:2}),this._zoomOut=new Xm({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),s=this._zoomOut.touchend(t,e,i),n=this._tr;return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:n.zoom+1,around:n.unproject(r)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:n.zoom-1,around:n.unproject(s)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ym{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const r=e.length?e[0]:e;return!this._moved&&r.dist(i){t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=function(t){t.preventDefault()}},rf=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const r=new Qm({checkCorrectEvent:t=>0===F.mouseButton(t)&&t.ctrlKey||2===F.mouseButton(t)});return new Ym({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:r,enable:t,assignEvents:ef})},sf=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const r=new Qm({checkCorrectEvent:t=>0===F.mouseButton(t)&&t.ctrlKey||2===F.mouseButton(t)});return new Ym({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:ef})};class nf{constructor(t,e){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new n(0,0),setTimeout((()=>{this._cancelCooperativeMessage=!1}),200)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._map._cooperativeGestures&&(2===this._minTouches&&i.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,i.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(i.length0&&(this._active=!0);const r=Hm(i,e),s=new n(0,0),a=new n(0,0);let o=0;for(const t in r){const e=r[t],i=this._touches[t];i&&(s._add(e),a._add(e.sub(i)),o++,r[t]=e)}if(this._touches=r,oMath.abs(t.x)}class df extends af{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,pf(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,s,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+s.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,s=e.mag()>=2;if(!r&&!s)return;if(!r||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=t.y>0==e.y>0;return pf(t)&&pf(e)&&n}}const mf={panStep:100,bearingStep:15,pitchStep:10};class ff{constructor(t){this._tr=new jm(t);const e=mf;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,s=0,n=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const o=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:_f,zoom:e?Math.round(o.zoom)+e*(t.shiftKey?2:1):o.zoom,bearing:o.bearing+i*this._bearingStep,pitch:o.pitch+r*this._pitchStep,offset:[-s*this._panStep,-n*this._panStep],center:o.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function _f(t){return t*(2-t)}const gf=4.000244140625;class yf{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new jm(t),this._el=t.getCanvasContainer(),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!t[this._map._metaKey])return;t.preventDefault()}let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=B.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%gf==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const e=F.mousePos(this._el,t),i=this._tr;this._around=Eh.convert(this._aroundCenter?i.center:i.unproject(e)),this._aroundPoint=i.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>gf?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const r="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(r*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const e="number"==typeof this._targetZoom?this._targetZoom:t.zoom,i=this._startZoom,r=this._easing;let s,n=!1;if("wheel"===this._type&&i&&r){const t=Math.min((B.now()-this._lastWheelEventTime)/200,1),a=r(t);s=ni.number(i,e,a),t<1?this._frameId||(this._frameId=!0):n=!0}else s=e,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!n,zoomDelta:s-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=d;if(this._prevEase){const t=this._prevEase,i=(B.now()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),s=.27/Math.sqrt(r*r+1e-4)*.01;e=p(s,Math.sqrt(.0729-s*s),.25,1)}return this._prevEase={start:B.now(),duration:t,easing:e},e}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class xf{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class vf{constructor(t){this._tr=new jm(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bf{constructor(){this._tap=new Xm({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const r=e[0],s=t.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;s&&n?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],s=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wf{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Tf{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Sf{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const If=t=>t.zoom||t.drag||t.pitch||t.rotate;class Af extends nt{}function Ef(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Cf{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},s={},n={},a=t.touches,o=a?this._getMapTouches(a):void 0,l=o?F.touchPos(this._el,o):F.mousePos(this._el,t);for(const{handlerName:a,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(n,h,a)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,o),this.mergeHandlerResult(r,s,u,a,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(n[a]=c)}const c={};for(const t in this._previousActiveHandlers)n[t]||(c[t]=i);this._previousActiveHandlers=n,(Object.keys(c).length||Ef(r))&&(this._changes.push([r,s,c]),this._triggerRenderFrame()),(Object.keys(n).length||Ef(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Fm(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)F.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)F.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new qm(e,t));const r=e.boxZoom=new Gm(e,t);this._add("boxZoom",r),t.interactive&&t.boxZoom&&r.enable();const s=new Km(e),n=new vf(e);e.doubleClickZoom=new xf(n,s),this._add("tapZoom",s),this._add("clickZoom",n),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();const a=new bf;this._add("tapDragZoom",a);const o=e.touchPitch=new df(e);this._add("touchPitch",o),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);const l=rf(t),c=sf(t);e.dragRotate=new Tf(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();const h=(({enable:t,clickTolerance:e})=>{const i=new Qm({checkCorrectEvent:t=>0===F.mouseButton(t)&&!t.ctrlKey});return new Ym({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:ef})})(t),u=new nf(t,e);e.dragPan=new wf(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);const p=new uf,d=new cf;e.touchZoomRotate=new Sf(i,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);const m=e.scrollZoom=new yf(e,(()=>this._triggerRenderFrame()));this._add("scrollZoom",m,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);const f=e.keyboard=new ff(e);this._add("keyboard",f),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new Zm(e))}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(If(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,e,i,r,s){if(!i)return;g(t,i);const n={handlerName:r,originalEvent:i.originalEvent||s};void 0!==i.zoomDelta&&(e.zoom=n),void 0!==i.panDelta&&(e.drag=n),void 0!==i.pitchDelta&&(e.pitch=n),void 0!==i.bearingDelta&&(e.rotate=n)}_applyChanges(){const t={},e={},i={};for(const[r,s,a]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new n(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),g(e,s),g(i,a);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,s=r._getTransformForUpdate(),n=r.terrain;if(!(Ef(t)||n&&this._terrainMovement))return this._fireEvents(e,i,!0);let{panDelta:a,zoomDelta:o,bearingDelta:l,pitchDelta:c,around:h,pinchAround:u}=t;void 0!==u&&(h=u),r._stop(!0),h=h||r.transform.centerPoint;const p=s.pointLocation(a?h.sub(a):h);l&&(s.bearing+=l),c&&(s.pitch+=c),o&&(s.zoom+=o),n?this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?s.center=s.pointLocation(s.centerPoint.sub(a)):s.setLocationAtPoint(p,h):(this._terrainMovement=!0,this._map._elevationFreeze=!0,s.setLocationAtPoint(p,h),this._map.once("moveend",(()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,s.recalculateZoom(r.terrain)}))):s.setLocationAtPoint(p,h),r._applyUpdatedTransform(s),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,e,i){const r=If(this._eventsInProgress),s=If(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(const t in n)this._fireEvent(t,n[t]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let o;for(const t in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],o=e[i]||r,a[`${t}end`]=o)}for(const t in a)this._fireEvent(t,a[t]);const l=If(this._eventsInProgress);if(i&&(r||s)&&!l){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Af("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class zf extends ot{constructor(t,e){super(),this._renderFrameCallback=()=>{const t=Math.min((B.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new Eh(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,e,i){return t=n.convert(t).mult(-1),this.panTo(this.transform.center,g({offset:t},e),i)}panTo(t,e,i){return this.easeTo(g({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(g({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,e,i){return this.easeTo(g({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,g({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(g({bearing:0,pitch:0,duration:1e3},t),e),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(i.zoom=ni.number(r,l,n)),this._rotating&&(i.bearing=ni.number(s,c,n)),this._pitching&&(i.pitch=ni.number(a,h,n)),this._padding&&(i.interpolatePadding(o,u,n),m=i.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n),b)i.setLocationAtPoint(b,w);else{const t=i.zoomScale(i.zoom-r),e=l>r?Math.min(2,v):Math.max(.5,v),s=Math.pow(e,1-n),a=i.unproject(y.add(x.mult(n*s)).mult(t));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,m)}this._applyUpdatedTransform(i),this._fireMoveEvents(e)}),(t=>{this.terrain&&this._finalizeElevation(),this._afterEase(e,t)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,e||i.moving||this.fire(new nt("movestart",t)),this._zooming&&!i.zooming&&this.fire(new nt("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new nt("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new nt("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const e=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&e!==this._elevationTarget){const i=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(i-(e-(i*t+this._elevationStart))/(1-t)),this._elevationTarget=e}this.transform.elevation=ni.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const e=t.clone(),{center:i,zoom:r,pitch:s,bearing:n,elevation:a}=this.transformCameraUpdate(e);i&&(e.center=i),void 0!==r&&(e.zoom=r),void 0!==s&&(e.pitch=s),void 0!==n&&(e.bearing=n),void 0!==a&&(e.elevation=a),this.transform.apply(e)}_fireMoveEvents(t){this.fire(new nt("move",t)),this._zooming&&this.fire(new nt("zoom",t)),this._rotating&&this.fire(new nt("rotate",t)),this._pitching&&this.fire(new nt("pitch",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)return;delete this._easeId;const i=this._zooming,r=this._rotating,s=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new nt("zoomend",t)),r&&this.fire(new nt("rotateend",t)),s&&this.fire(new nt("pitchend",t)),this.fire(new nt("moveend",t))}flyTo(t,e){if(!t.essential&&B.prefersReducedMotion){const i=y(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,e)}this.stop(),t=g({offset:[0,0],speed:1.2,curve:1.42,easing:d},t);const i=this._getTransformForUpdate(),r=this.getZoom(),s=this.getBearing(),a=this.getPitch(),o=this.getPadding(),l="zoom"in t?m(+t.zoom,i.minZoom,i.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:a,u="padding"in t?t.padding:i.padding,p=i.zoomScale(l-r),f=n.convert(t.offset);let _=i.centerPoint.add(f);const x=i.pointLocation(_),v=Eh.convert(t.center||x);this._normalizeCenter(v);const b=i.project(x),w=i.project(v).sub(b);let T=t.curve;const S=Math.max(i.width,i.height),I=S/p,A=w.mag();if("minZoom"in t){const e=m(Math.min(t.minZoom,r,l),i.minZoom,i.maxZoom),s=S/i.zoomScale(e-r);T=Math.sqrt(s/A*2)}const E=T*T;function C(t){const e=(I*I-S*S+(t?-1:1)*E*E*A*A)/(2*(t?I:S)*E*A);return Math.log(Math.sqrt(e*e+1)-e)}function z(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}const P=C(!1);let k=function(t){return M(P)/M(P+T*t)},D=function(t){return S*((M(P)*(z(e=P+T*t)/M(e))-z(P))/E)/A;var e},L=(C(!0)-P)/T;if(Math.abs(A)<1e-6||!isFinite(L)){if(Math.abs(S-I)<1e-6)return this.easeTo(t,e);const i=It.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=s!==c,this._pitching=h!==a,this._padding=!i.isPaddingEqual(u),this._prepareEase(e,!1),this.terrain&&this._prepareElevation(v),this._ease((n=>{const p=n*L,d=1/k(p);i.zoom=1===n?l:r+i.scaleZoom(d),this._rotating&&(i.bearing=ni.number(s,c,n)),this._pitching&&(i.pitch=ni.number(a,h,n)),this._padding&&(i.interpolatePadding(o,u,n),_=i.centerPoint.add(f)),this.terrain&&!t.freezeElevation&&this._updateElevation(n);const m=1===n?v:i.unproject(b.add(w.mult(D(p))).mult(d));i.setLocationAtPoint(i.renderWorldCopies?m.wrap():m,_),this._applyUpdatedTransform(i),this._fireMoveEvents(e)}),(()=>{this.terrain&&this._finalizeElevation(),this._afterEase(e)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=B.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,e){t=f(t,-180,180);const i=Math.abs(t-e);return Math.abs(t-360-e)180?-360:i<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(Eh.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}class Mf{constructor(t={}){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=F.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=F.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=F.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){F.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const i in e){const r=e[i];if(r.used||r.usedForTerrain){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r=0)return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Pf{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=F.create("div","maplibregl-ctrl");const e=F.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){F.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class kf{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Df;!function(t){t.create="create",t.load="load",t.fullLoad="fullLoad"}(Df||(Df={}));let Lf=null,Rf=[];const Bf=1e3/60,Ff="loadTime",Of="fullLoadTime",Vf={mark(t){performance.mark(t)},frame(t){const e=t;null!=Lf&&Rf.push(e-Lf),Lf=e},clearMetrics(){Lf=null,Rf=[],performance.clearMeasures(Ff),performance.clearMeasures(Of);for(const t in Df)performance.clearMarks(Df[t])},getPerformanceMetrics(){performance.measure(Ff,Df.create,Df.load),performance.measure(Of,Df.create,Df.fullLoad);const t=performance.getEntriesByName(Ff)[0].duration,e=performance.getEntriesByName(Of)[0].duration,i=Rf.length,r=1/(Rf.reduce(((t,e)=>t+e),0)/i/1e3),s=Rf.filter((t=>t>Bf)).reduce(((t,e)=>t+(e-Bf)/Bf),0);return{loadTime:t,fullLoadTime:e,fps:r,percentDroppedFrames:s/(i+s)*100,totalFrames:i}}},Uf={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var Nf=Bs([{name:"a_pos3d",type:"Int16",components:3}]);class $f extends ot{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,e){this.sourceCache.update(t,e),this._renderableTilesKeys=[];const i={};for(const r of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:e}))i[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.posMatrix=new Float64Array(16),Qa(r.posMatrix,0,va,0,va,0,1),this._tiles[r.key]=new ou(r,this.tileSize));for(const t in this._tiles)i[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const e={};for(const i of this._renderableTilesKeys){const r=this._tiles[i].tileID;if(r.canonical.equals(t.canonical)){const r=t.clone();r.posMatrix=new Float64Array(16),Qa(r.posMatrix,0,va,0,va,0,1),e[i]=r}else if(r.canonical.isChildOf(t.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16);const n=r.canonical.z-t.canonical.z,a=r.canonical.x-(r.canonical.x>>n<>n<>n;Qa(s.posMatrix,0,l,0,l,0,1),Ka(s.posMatrix,s.posMatrix,[-a*l,-o*l,0]),e[i]=s}else if(t.canonical.isChildOf(r.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16);const n=t.canonical.z-r.canonical.z,a=t.canonical.x-(t.canonical.x>>n<>n<>n;Qa(s.posMatrix,0,va,0,va,0,1),Ka(s.posMatrix,s.posMatrix,[a*l,o*l,0]),Ya(s.posMatrix,s.posMatrix,[1/2**n,1/2**n,0]),e[i]=s}}return e}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!s||!s.dem);)s=this.sourceCache.getTileByID(t.scaledTo(r--).key);return s}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeAdded>=t))}}class qf{constructor(t,e,i){this.painter=t,this.sourceCache=new $f(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,e,i,r=va){var s;if(!(e>=0&&e=0&&it.canonical.z&&(t.canonical.z>=i?r=t.canonical.z-i:A("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=t.canonical.x-(t.canonical.x>>r<>r<>8<<4|t>>8,e[i+3]=0;const i=new _o({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(e.buffer)),r=new uh(t,i,t.gl.RGBA,{premultiply:!1});return r.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(t){const e=new Uint8Array(4),i=this.painter.context,r=i.gl;i.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null);const s=e[0]+(e[2]>>4<<8),n=e[1]+((15&e[2])<<8),a=this.coordsIndex[255-e[3]],o=a&&this.sourceCache.getTileByID(a);if(!o)return null;const l=this._coordsTextureSize,c=(1<0&&Math.sign(s)<0||!i&&Math.sign(r)<0&&Math.sign(s)>0?(r=360*Math.sign(s)+r,Ph(r)):e}}class Zf{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const e=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new uh(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),e.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),e.colorAttachment.set(i.texture),{id:t,fbo:e,texture:i,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((e=>t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse))}}const jf={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Gf{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new Zf(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsDescendingInv={};for(const e in t.sourceCaches){this._coordsDescendingInv[e]={};const i=t.sourceCaches[e].getVisibleCoordinates();for(const t of i){const i=this.terrain.sourceCache.getTerrainCoords(t);for(const t in i)this._coordsDescendingInv[e][t]||(this._coordsDescendingInv[e][t]=[]),this._coordsDescendingInv[e][t].push(i[t])}}this._coordsDescendingInvStr={};for(const e of t._order){const i=t._layers[e],r=i.source;if(jf[i.type]&&!this._coordsDescendingInvStr[r]){this._coordsDescendingInvStr[r]={};for(const t in this._coordsDescendingInv[r])this._coordsDescendingInvStr[r][t]=this._coordsDescendingInv[r][t].map((t=>t.key)).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsDescendingInvStr){const i=this._coordsDescendingInvStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const e=t.type,i=this.painter,r=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(jf[e]&&(this._prevType&&jf[this._prevType]||this._stacks.push([]),this._prevType=e,this._stacks[this._stacks.length-1].push(t.id),!r))return!0;if(jf[this._prevType]||jf[e]&&r){this._prevType=e;const t=this._stacks.length-1,r=this._stacks[t]||[];for(const e of this._renderableTiles){if(this.pool.isFull()&&(Sm(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(e),e.rtt[t]){const i=this.pool.getObjectForId(e.rtt[t].id);if(i.stamp===e.rtt[t].stamp){this.pool.useObject(i);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),e.rtt[t]={id:s.id,stamp:s.stamp},i.context.bindFramebuffer.set(s.fbo.framebuffer),i.context.clear({color:he.transparent,stencil:0}),i.currentStencilSource=void 0;for(let t=0;t{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd},Kf={showCompass:!0,showZoom:!0,visualizePitch:!1};class Yf{constructor(t,e,i=!1){this.mousedown=t=>{this.startMouse(g({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),F.mousePos(this.element,t)),F.addEventListener(window,"mousemove",this.mousemove),F.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.moveMouse(t,F.mousePos(this.element,t))},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=F.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),F.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),F.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=F.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const r=t.dragRotate._mouseRotate.getClickTolerance(),s=t.dragRotate._mousePitch.getClickTolerance();this.element=e,this.mouseRotate=rf({clickTolerance:r,enable:!0}),this.touchRotate=(({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const r=new tf;return new Ym({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:r,enable:t,assignEvents:Xf})})({clickTolerance:r,enable:!0}),this.map=t,i&&(this.mousePitch=sf({clickTolerance:s,enable:!0}),this.touchPitch=(({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const r=new tf;return new Ym({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:Xf})})({clickTolerance:s,enable:!0})),F.addEventListener(e,"mousedown",this.mousedown),F.addEventListener(e,"touchstart",this.touchstart,{passive:!1}),F.addEventListener(e,"touchcancel",this.reset)}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),F.disableDrag()}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),F.disableDrag()}moveMouse(t,e){const i=this.map,{bearingDelta:r}=this.mouseRotate.dragMove(t,e)||{};if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const{pitchDelta:r}=this.mousePitch.dragMove(t,e)||{};r&&i.setPitch(i.getPitch()+r)}}moveTouch(t,e){const i=this.map,{bearingDelta:r}=this.touchRotate.dragMove(t,e)||{};if(r&&i.setBearing(i.getBearing()+r),this.touchPitch){const{pitchDelta:r}=this.touchPitch.dragMove(t,e)||{};r&&i.setPitch(i.getPitch()+r)}}off(){const t=this.element;F.removeEventListener(t,"mousedown",this.mousedown),F.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),F.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),F.removeEventListener(window,"touchend",this.touchend),F.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){F.enableDrag(),F.removeEventListener(window,"mousemove",this.mousemove),F.removeEventListener(window,"mouseup",this.mouseup),F.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),F.removeEventListener(window,"touchend",this.touchend)}}let Jf;function Qf(t,e,i){if(t=new Eh(t.lng,t.lat),e){const r=new Eh(t.lng-360,t.lat),s=new Eh(t.lng+360,t.lat),n=i.locationPoint(t).distSqr(e);i.locationPoint(r).distSqr(e)180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const t_={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function e_(t,e,i){const r=t.classList;for(const t in t_)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}class i_ extends ot{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{if(!this._map)return;const e=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!e)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=Qf(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),F.setTransform(this._element,`${t_[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout((()=>{const t=this._map.unproject(this._pos),e=40075016.686*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=t.distanceTo(this._lngLat)>20*e?"0.2":"1.0",this._opacityTimeout=null}),100))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new nt("dragstart"))),this.fire(new nt("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new nt("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,t&&t.element)this._element=t.element,this._offset=n.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=F.create("div"),this._element.setAttribute("aria-label","Map marker");const e=F.createNS("http://www.w3.org/2000/svg","svg"),i=41,r=27;e.setAttributeNS(null,"display","block"),e.setAttributeNS(null,"height",`${i}px`),e.setAttributeNS(null,"width",`${r}px`),e.setAttributeNS(null,"viewBox",`0 0 ${r} ${i}`);const s=F.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const a=F.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"fill-rule","nonzero");const o=F.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"transform","translate(3.0, 29.0)"),o.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of l){const e=F.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),o.appendChild(e)}const c=F.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=F.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const u=F.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"opacity","0.25"),u.setAttributeNS(null,"fill","#000000");const p=F.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),u.appendChild(p);const d=F.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(6.0, 7.0)"),d.setAttributeNS(null,"fill","#FFFFFF");const m=F.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=F.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const _=F.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(_),a.appendChild(o),a.appendChild(c),a.appendChild(u),a.appendChild(d),a.appendChild(m),e.appendChild(a),e.setAttributeNS(null,"height",i*this._scale+"px"),e.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(e),this._offset=n.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),e_(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),F.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Eh.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}getOffset(){return this._offset}setOffset(t){return this._offset=n.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const r_={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let s_=0,n_=!1;const a_={maxWidth:100,unit:"metric"};function o_(t,e,i){const r=i&&i.maxWidth||100,s=t._container.clientHeight/2,n=t.unproject([0,s]),a=t.unproject([r,s]),o=n.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*o;i>5280?l_(e,r,i/5280,t._getUIString("ScaleControl.Miles")):l_(e,r,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?l_(e,r,o/1852,t._getUIString("ScaleControl.NauticalMiles")):o>=1e3?l_(e,r,o/1e3,t._getUIString("ScaleControl.Kilometers")):l_(e,r,o,t._getUIString("ScaleControl.Meters"))}function l_(t,e,i,r){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s} ${r}`}const c_={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},h_=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function u_(t){if(t){if("number"==typeof t){const e=Math.round(Math.abs(t)/Math.SQRT2);return{center:new n(0,0),top:new n(0,t),"top-left":new n(e,e),"top-right":new n(-e,e),bottom:new n(0,-t),"bottom-left":new n(e,-e),"bottom-right":new n(-e,-e),left:new n(t,0),right:new n(-t,0)}}if(t instanceof n||Array.isArray(t)){const e=n.convert(t);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:n.convert(t.center||[0,0]),top:n.convert(t.top||[0,0]),"top-left":n.convert(t["top-left"]||[0,0]),"top-right":n.convert(t["top-right"]||[0,0]),bottom:n.convert(t.bottom||[0,0]),"bottom-left":n.convert(t["bottom-left"]||[0,0]),"bottom-right":n.convert(t["bottom-right"]||[0,0]),left:n.convert(t.left||[0,0]),right:n.convert(t.right||[0,0])}}return u_(new n(0,0))}const p_={extend:(t,...e)=>g(t,...e),run(t){t()},logToElement(t,e=!1,i="log"){const r=window.document.getElementById(i);r&&(e&&(r.innerHTML=""),r.innerHTML+=`
${t}`)}},d_=t;class m_{static get version(){return d_}static get workerCount(){return mu.workerCount}static set workerCount(t){mu.workerCount=t}static get maxParallelImageRequests(){return O.MAX_PARALLEL_IMAGE_REQUESTS}static set maxParallelImageRequests(t){O.MAX_PARALLEL_IMAGE_REQUESTS=t}static get workerUrl(){return O.WORKER_URL}static set workerUrl(t){O.WORKER_URL=t}static addProtocol(t,e){O.REGISTERED_PROTOCOLS[t]=e}static removeProtocol(t){delete O.REGISTERED_PROTOCOLS[t]}}return m_.Map=class extends zf{constructor(t){if(Vf.mark(Df.create),null!=(t=g({},Wf,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new zm(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._cooperativeGesturesOnWheel=t=>{this._onCooperativeGesture(t,t[this._metaKey],1)},this._contextLost=t=>{t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new nt("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new nt("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._cooperativeGestures=t.cooperativeGestures,this._metaKey=0===navigator.platform.indexOf("Mac")?"metaKey":"ctrlKey",this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._renderTaskQueue=new kf,this._controls=[],this._mapId=v(),this._locale=g({},Uf,t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this._imageQueueHandle=Q.addThrottleControl((()=>this.isMoving())),this._requestManager=new et(t.transformRequest),"string"==typeof t.container){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=Mm((t=>{this._trackResize&&!this._removed&&this.resize(t)._update()}),50);this._resizeObserver=new ResizeObserver((i=>{t?e(i):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Cf(this,t),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=t.hash&&new Pm("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,g({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Mf({customAttribution:t.customAttribution})),t.maplibreLogo&&this.addControl(new Pf,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new nt(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new nt(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new nt("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new at(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new at(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,r)}resize(t){var e;const i=this._containerDimensions(),r=i[0],s=i[1],n=this._getClampedPixelRatio(r,s);if(this._resizeCanvas(r,s,n),this.painter.resize(r,s,n),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(r,s);this._resizeCanvas(r,s,e),this.painter.resize(r,s,e)}this.transform.resize(r,s),null===(e=this._requestedCameraState)||void 0===e||e.resize(r,s);const a=!this._moving;return a&&(this.stop(),this.fire(new nt("movestart",t)).fire(new nt("move",t))),this.fire(new nt("resize",t)),a&&this.fire(new nt("moveend",t)),this}_getClampedPixelRatio(t,e){const{0:i,1:r}=this._maxCanvasSize,s=this.getPixelRatio(),n=t*s,a=e*s;return Math.min(n>i?i/n:1,a>r?r/a:1)*s}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(Ch.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(t){return this._cooperativeGestures=t,this._cooperativeGestures?this._setupCooperativeGestures():this._destroyCooperativeGestures(),this}project(t){return this.transform.locationPoint(Eh.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(n.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const s=s=>{const n=this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[];n.length?r||(r=!0,i.call(this,new Um(t,this,s.originalEvent,{features:n}))):r=!1};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const s=s=>{(this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[]).length?r=!0:r&&(r=!1,i.call(this,new Um(t,this,s.originalEvent)))},n=e=>{r&&(r=!1,i.call(this,new Um(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:n}}}{const r=t=>{const r=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(r=>{const s=this._delegatedListeners[t];for(let t=0;tthis._updateStyle(t,e)));const i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Ap(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ap(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,e){if("string"==typeof t){const i=this._requestManager.transformRequest(t,tt.Style);Z(i,((t,i)=>{t?this.fire(new at(t)):i&&this._updateDiff(i,e)}))}else"object"==typeof t&&this._updateDiff(t,e)}_updateDiff(t,e){try{this.style.setState(t,e)&&this._update(!0)}catch(i){A(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(t,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():A("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const e=this.style&&this.style.sourceCaches[t];if(void 0!==e)return e.loaded();this.fire(new at(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const e=this.style.sourceCaches[t.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);for(const e in this.style._layers){const i=this.style._layers[e];"hillshade"===i.type&&i.source===t.source&&A("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new qf(this.painter,e,t),this.painter.renderToTexture=new Gf(this.painter,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0;return this.fire(new nt("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,e,i={}){const{pixelRatio:r=1,sdf:s=!1,stretchX:n,stretchY:a,content:o}=i;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||k(e))){if(void 0===e.width||void 0===e.height)return this.fire(new at(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:i,height:l,data:c}=e,h=e;return this.style.addImage(t,{data:new _o({width:i,height:l},new Uint8Array(c)),pixelRatio:r,stretchX:n,stretchY:a,content:o,sdf:s,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t),this}}{const{width:i,height:l,data:c}=B.getImageData(e);this.style.addImage(t,{data:new _o({width:i,height:l},c),pixelRatio:r,stretchX:n,stretchY:a,content:o,sdf:s,version:0})}}updateImage(t,e){const i=this.style.getImage(t);if(!i)return this.fire(new at(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=e instanceof HTMLImageElement||k(e)?B.getImageData(e):e,{width:s,height:n,data:a}=r;if(void 0===s||void 0===n)return this.fire(new at(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==i.data.width||n!==i.data.height)return this.fire(new at(new Error("The width and height of the updated image must be that same as the previous version of the image")));const o=!(e instanceof HTMLImageElement||k(e));return i.data.replace(a,o),this.style.updateImage(t,i),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new at(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t,e){Q.getImage(this._requestManager.transformRequest(t,tt.Image),e)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=F.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=F.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const s=this._controlContainer=F.create("div","maplibregl-control-container",t),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{n[t]=F.create("div",`maplibregl-ctrl-${t} `,s)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){this._cooperativeGesturesScreen=F.create("div","maplibregl-cooperative-gesture-screen",this._container);let t="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";0===navigator.platform.indexOf("Mac")&&(t="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map"),this._cooperativeGesturesScreen.innerHTML=`\n
${t}
\n
${"boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}
\n `,this._cooperativeGesturesScreen.setAttribute("aria-hidden","true"),this._canvasContainer.addEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.add("maplibregl-cooperative-gestures")}_destroyCooperativeGestures(){F.remove(this._cooperativeGesturesScreen),this._canvasContainer.removeEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.remove("maplibregl-cooperative-gestures")}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)}),{once:!0});const i=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Im(i,this.transform),H.testSupport(i)}_onCooperativeGesture(t,e,i){return!e&&i<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout((()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")}),100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){const e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let i=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,r=B.now();this.style.zoomHistory.update(t,r);const s=new _s(t,{now:r,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=s.crossFadingFactor();1===n&&n===this._crossFadingFactor||(i=!0,this._crossFadingFactor=n),this.style.update(s)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new nt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,Vf.mark(Df.load),this.fire(new nt("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const r=this._sourcesDirty||this._styleDirty||this._placementDirty;return r||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new nt("idle")),!this._loaded||this._fullyLoaded||r||(this._fullyLoaded=!0,Vf.mark(Df.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),Q.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),F.remove(this._canvasContainer),F.remove(this._controlContainer),this._cooperativeGestures&&this._destroyCooperativeGestures(),this._container.classList.remove("maplibregl-map"),Vf.clearMetrics(),this._removed=!0,this.fire(new nt("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=B.frame((t=>{Vf.frame(t),this._frame=null,this._render(t)})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return Hf}getCameraTargetElevation(){return this.transform.elevation}},m_.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=g({},Kf,t),this._container=F.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),F.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),F.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=F.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Yf(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){F.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=F.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},m_.GeolocateControl=class extends ot{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new nt("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new nt("geolocate",t)),this._finish()}},this._updateCamera=t=>{const e=new Eh(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,r=g({bearing:this._map.getBearing()},this.options.fitBoundsOptions),s=Ch.fromLngLat(e,i);this._map.fitBounds(s,r,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const e=new Eh(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(e).addTo(this._map),this._userLocationDotMarker.setLngLat(e).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&n_)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new nt("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=F.create("button","maplibregl-ctrl-geolocate",this._container),F.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){A("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=F.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new i_({element:this._dotElement}),this._circleElement=F.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new i_({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new nt("trackuserlocationend")))}))}},this.options=g({},r_,t)}onAdd(t){return this._map=t,this._container=F.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(t,e=!1){void 0===Jf||e?void 0!==window.navigator.permissions?window.navigator.permissions.query({name:"geolocation"}).then((e=>{Jf="denied"!==e.state,t(Jf)})).catch((()=>{Jf=!!window.navigator.geolocation,t(Jf)})):(Jf=!!window.navigator.geolocation,t(Jf)):t(Jf)}(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),F.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,s_=0,n_=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),r=e.distanceTo(i),s=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}trigger(){if(!this._setup)return A("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new nt("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":s_--,n_=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new nt("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new nt("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),s_++,s_>1?(t={maximumAge:6e5,timeout:0},n_=!0):(t=this.options.positionOptions,n_=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},m_.AttributionControl=Mf,m_.LogoControl=Pf,m_.ScaleControl=class{constructor(t){this._onMove=()=>{o_(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,o_(this._map,this._container,this.options)},this.options=g({},a_,t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=F.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){F.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},m_.FullscreenControl=class extends ot{constructor(t={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:A("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=F.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){F.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=F.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);F.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new nt("fullscreenstart")),this._map._cooperativeGestures&&(this._prevCooperativeGestures=this._map._cooperativeGestures,this._map.setCooperativeGestures())):(this.fire(new nt("fullscreenend")),this._prevCooperativeGestures&&(this._map.setCooperativeGestures(this._prevCooperativeGestures),delete this._prevCooperativeGestures))}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},m_.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))},this.options=t}onAdd(t){return this._map=t,this._container=F.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=F.create("button","maplibregl-ctrl-terrain",this._container),F.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){F.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},m_.Popup=class extends ot{constructor(t){super(),this.remove=()=>(this._content&&F.remove(this._content),this._container&&(F.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new nt("close")),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=F.create("div","maplibregl-popup",this._map.getContainer()),this._tip=F.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Qf(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const e=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let i=this.options.anchor;const r=u_(this.options.offset);if(!i){const t=this._container.offsetWidth,s=this._container.offsetHeight;let n;n=e.y+r.bottom.ythis._map.transform.height-s?["bottom"]:[],e.xthis._map.transform.width-t/2&&n.push("right"),i=0===n.length?"bottom":n.join("-")}const s=e.add(r[i]).round();F.setTransform(this._container,`${t_[i]} translate(${s.x}px,${s.y}px)`),e_(this._container,i,"popup")},this._onClose=()=>{this.remove()},this.options=g(Object.create(c_),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new nt("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Eh.convert(t),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=F.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}_createCloseButton(){this.options.closeButton&&(this._closeButton=F.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(h_);t&&t.focus()}},m_.Marker=i_,m_.Style=Ap,m_.LngLat=Eh,m_.LngLatBounds=Ch,m_.Point=n,m_.MercatorCoordinate=Bh,m_.Evented=ot,m_.AJAXError=V,m_.config=O,m_.CanvasSource=Kh,m_.GeoJSONSource=Gh,m_.ImageSource=Wh,m_.RasterDEMTileSource=jh,m_.RasterTileSource=Vh,m_.VectorTileSource=Oh,m_.VideoSource=Xh,m_.setRTLTextPlugin=function(t,e,i=!1){if(ls===ss||ls===ns||ls===as)throw new Error("setRTLTextPlugin cannot be called multiple times.");cs=B.resolveURL(t),ls=ss,os=e,us(),i||ms()},m_.getRTLTextPluginStatus=ds,m_.prewarm=function(){gu().acquire(du)},m_.clearPrewarmedResources=function(){const t=_u;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(du),_u=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},p_.extend(m_,{isSafari:P,getPerformanceMetrics:Vf.getPerformanceMetrics}),m_})); +//# sourceMappingURL=maplibre-gl-csp.js.map diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl-csp.js.map b/web/libraries/maplibre-gl/dist/maplibre-gl-csp.js.map new file mode 100644 index 00000000..49cb3001 --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl-csp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"maplibre-gl-csp.js","sources":["../node_modules/tslib/tslib.es6.js","../node_modules/@mapbox/point-geometry/index.js","../node_modules/@mapbox/unitbezier/index.js","../src/util/offscreen_canvas_supported.ts","../src/util/offscreen_canvas_distorted.ts","../src/util/util.ts","../src/util/browser.ts","../src/util/dom.ts","../src/util/config.ts","../src/util/ajax.ts","../src/util/webp_supported.ts","../src/util/image_request.ts","../src/util/request_manager.ts","../src/util/evented.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.mjs","../src/style/validate_style.ts","../src/util/transferable_grid_index.ts","../src/util/web_worker_transfer.ts","../src/style/zoom_history.ts","../src/util/is_char_in_unicode_block.ts","../src/util/script_detection.ts","../src/source/rtl_text_plugin.ts","../src/style/evaluation_parameters.ts","../src/style/properties.ts","../src/style/style_layer.ts","../src/util/struct_array.ts","../src/data/array_types.g.ts","../src/data/bucket/circle_attributes.ts","../src/data/segment.ts","../src/shaders/encode_attribute.ts","../src/data/bucket/pattern_attributes.ts","../node_modules/murmurhash-js/murmurhash3_gc.js","../node_modules/murmurhash-js/murmurhash2_gc.js","../node_modules/murmurhash-js/index.js","../src/data/feature_position_map.ts","../src/render/uniform_binding.ts","../src/data/program_configuration.ts","../src/data/extent.ts","../src/data/load_geometry.ts","../src/data/evaluation_feature.ts","../src/data/bucket/circle_bucket.ts","../src/util/intersection_tests.ts","../src/style/query_utils.ts","../src/style/style_layer/circle_style_layer_properties.g.ts","../node_modules/gl-matrix/esm/common.js","../node_modules/gl-matrix/esm/mat4.js","../node_modules/gl-matrix/esm/vec3.js","../node_modules/gl-matrix/esm/vec4.js","../node_modules/gl-matrix/esm/vec2.js","../src/style/style_layer/circle_style_layer.ts","../src/data/bucket/heatmap_bucket.ts","../src/style/style_layer/heatmap_style_layer_properties.g.ts","../src/util/image.ts","../src/util/color_ramp.ts","../src/style/style_layer/heatmap_style_layer.ts","../src/style/style_layer/hillshade_style_layer_properties.g.ts","../src/style/style_layer/hillshade_style_layer.ts","../src/data/bucket/fill_attributes.ts","../node_modules/earcut/src/earcut.js","../node_modules/quickselect/index.js","../src/util/classify_rings.ts","../src/data/bucket/pattern_bucket_features.ts","../src/data/bucket/fill_bucket.ts","../src/style/style_layer/fill_style_layer_properties.g.ts","../src/style/style_layer/fill_style_layer.ts","../src/data/bucket/fill_extrusion_attributes.ts","../node_modules/@mapbox/vector-tile/lib/vectortilefeature.js","../node_modules/@mapbox/vector-tile/lib/vectortilelayer.js","../node_modules/@mapbox/vector-tile/lib/vectortile.js","../node_modules/@mapbox/vector-tile/index.js","../src/data/bucket/fill_extrusion_bucket.ts","../src/style/style_layer/fill_extrusion_style_layer_properties.g.ts","../src/style/style_layer/fill_extrusion_style_layer.ts","../src/data/bucket/line_attributes.ts","../src/data/bucket/line_attributes_ext.ts","../src/data/bucket/line_bucket.ts","../src/style/style_layer/line_style_layer_properties.g.ts","../src/style/style_layer/line_style_layer.ts","../src/data/bucket/symbol_attributes.ts","../src/symbol/transform_text.ts","../src/util/verticalize_punctuation.ts","../src/symbol/one_em.ts","../node_modules/pbf/index.js","../node_modules/ieee754/index.js","../src/style/parse_glyph_pbf.ts","../node_modules/potpack/index.js","../src/render/image_atlas.ts","../src/symbol/shaping.ts","../src/symbol/symbol_size.ts","../src/style/style_layer/overlap_mode.ts","../src/data/bucket/symbol_bucket.ts","../src/symbol/merge_lines.ts","../src/style/style_layer/symbol_style_layer_properties.g.ts","../src/style/format_section_override.ts","../src/style/style_layer/symbol_style_layer.ts","../src/util/resolve_tokens.ts","../src/style/style_layer/background_style_layer_properties.g.ts","../src/style/style_layer/background_style_layer.ts","../src/style/style_layer/raster_style_layer_properties.g.ts","../src/style/style_layer/raster_style_layer.ts","../src/style/style_layer/custom_style_layer.ts","../src/style/create_style_layer.ts","../src/util/style.ts","../src/style/load_sprite.ts","../src/render/texture.ts","../src/style/style_image.ts","../src/render/image_manager.ts","../node_modules/@mapbox/tiny-sdf/index.js","../src/render/glyph_manager.ts","../src/style/load_glyph_range.ts","../src/style/light.ts","../src/render/line_atlas.ts","../src/util/throttled_invoker.ts","../src/util/actor.ts","../src/util/dispatcher.ts","../src/source/load_tilejson.ts","../src/geo/lng_lat.ts","../src/geo/lng_lat_bounds.ts","../src/geo/mercator_coordinate.ts","../src/source/tile_bounds.ts","../src/source/vector_tile_source.ts","../src/source/raster_tile_source.ts","../node_modules/@mapbox/whoots-js/index.mjs","../src/source/tile_id.ts","../src/data/dem_data.ts","../src/source/raster_dem_tile_source.ts","../src/source/geojson_source.ts","../src/data/raster_bounds_attributes.ts","../src/source/image_source.ts","../src/source/video_source.ts","../src/source/canvas_source.ts","../src/source/source.ts","../src/source/query_features.ts","../src/util/dictionary_coder.ts","../src/util/vectortile_to_geojson.ts","../src/data/feature_index.ts","../src/source/tile.ts","../src/data/bucket.ts","../src/source/tile_cache.ts","../src/source/source_state.ts","../src/source/source_cache.ts","../src/util/worker_pool.ts","../src/util/web_worker.ts","../src/util/global_worker_pool.ts","../src/symbol/path_interpolator.ts","../src/symbol/grid_index.ts","../src/symbol/projection.ts","../src/symbol/collision_index.ts","../src/symbol/clip_line.ts","../src/symbol/anchor.ts","../src/style/style_layer/variable_text_anchor.ts","../src/source/pixels_to_tile_units.ts","../src/symbol/placement.ts","../src/symbol/symbol_layout.ts","../src/style/pauseable_placement.ts","../node_modules/kdbush/index.js","../src/symbol/cross_tile_symbol_index.ts","../src/style/style.ts","../src/data/pos_attributes.ts","../src/shaders/terrain.vertex.glsl.g.ts","../src/shaders/shaders.ts","../src/shaders/_prelude.fragment.glsl.g.ts","../src/shaders/_prelude.vertex.glsl.g.ts","../src/shaders/background.fragment.glsl.g.ts","../src/shaders/background.vertex.glsl.g.ts","../src/shaders/background_pattern.fragment.glsl.g.ts","../src/shaders/background_pattern.vertex.glsl.g.ts","../src/shaders/circle.fragment.glsl.g.ts","../src/shaders/circle.vertex.glsl.g.ts","../src/shaders/clipping_mask.fragment.glsl.g.ts","../src/shaders/clipping_mask.vertex.glsl.g.ts","../src/shaders/heatmap.fragment.glsl.g.ts","../src/shaders/heatmap.vertex.glsl.g.ts","../src/shaders/heatmap_texture.fragment.glsl.g.ts","../src/shaders/heatmap_texture.vertex.glsl.g.ts","../src/shaders/collision_box.fragment.glsl.g.ts","../src/shaders/collision_box.vertex.glsl.g.ts","../src/shaders/collision_circle.fragment.glsl.g.ts","../src/shaders/collision_circle.vertex.glsl.g.ts","../src/shaders/debug.fragment.glsl.g.ts","../src/shaders/debug.vertex.glsl.g.ts","../src/shaders/fill.fragment.glsl.g.ts","../src/shaders/fill.vertex.glsl.g.ts","../src/shaders/fill_outline.fragment.glsl.g.ts","../src/shaders/fill_outline.vertex.glsl.g.ts","../src/shaders/fill_outline_pattern.fragment.glsl.g.ts","../src/shaders/fill_outline_pattern.vertex.glsl.g.ts","../src/shaders/fill_pattern.fragment.glsl.g.ts","../src/shaders/fill_pattern.vertex.glsl.g.ts","../src/shaders/fill_extrusion.fragment.glsl.g.ts","../src/shaders/fill_extrusion.vertex.glsl.g.ts","../src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts","../src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts","../src/shaders/hillshade_prepare.fragment.glsl.g.ts","../src/shaders/hillshade_prepare.vertex.glsl.g.ts","../src/shaders/hillshade.fragment.glsl.g.ts","../src/shaders/hillshade.vertex.glsl.g.ts","../src/shaders/line.fragment.glsl.g.ts","../src/shaders/line.vertex.glsl.g.ts","../src/shaders/line_gradient.fragment.glsl.g.ts","../src/shaders/line_gradient.vertex.glsl.g.ts","../src/shaders/line_pattern.fragment.glsl.g.ts","../src/shaders/line_pattern.vertex.glsl.g.ts","../src/shaders/line_sdf.fragment.glsl.g.ts","../src/shaders/line_sdf.vertex.glsl.g.ts","../src/shaders/raster.fragment.glsl.g.ts","../src/shaders/raster.vertex.glsl.g.ts","../src/shaders/symbol_icon.fragment.glsl.g.ts","../src/shaders/symbol_icon.vertex.glsl.g.ts","../src/shaders/symbol_sdf.fragment.glsl.g.ts","../src/shaders/symbol_sdf.vertex.glsl.g.ts","../src/shaders/symbol_text_and_icon.fragment.glsl.g.ts","../src/shaders/symbol_text_and_icon.vertex.glsl.g.ts","../src/shaders/terrain.fragment.glsl.g.ts","../src/shaders/terrain_depth.fragment.glsl.g.ts","../src/shaders/terrain_coords.fragment.glsl.g.ts","../src/render/vertex_array_object.ts","../src/render/program.ts","../src/render/program/terrain_program.ts","../src/render/program/pattern.ts","../src/render/program/fill_extrusion_program.ts","../node_modules/gl-matrix/esm/mat3.js","../src/render/program/fill_program.ts","../src/render/program/circle_program.ts","../src/render/program/collision_program.ts","../src/render/program/debug_program.ts","../src/render/program/clipping_mask_program.ts","../src/render/program/heatmap_program.ts","../src/render/program/hillshade_program.ts","../src/render/program/line_program.ts","../src/render/program/raster_program.ts","../src/render/program/symbol_program.ts","../src/render/program/background_program.ts","../src/render/program/program_uniforms.ts","../src/gl/index_buffer.ts","../src/gl/vertex_buffer.ts","../src/gl/webgl2.ts","../src/gl/value.ts","../src/gl/framebuffer.ts","../src/gl/color_mode.ts","../src/gl/context.ts","../src/gl/depth_mode.ts","../src/gl/stencil_mode.ts","../src/gl/cull_face_mode.ts","../src/render/draw_collision_debug.ts","../src/render/draw_symbol.ts","../src/render/update_pattern_positions_in_program.ts","../src/render/draw_fill.ts","../src/render/draw_fill_extrusion.ts","../src/render/draw_hillshade.ts","../src/render/draw_raster.ts","../src/render/draw_debug.ts","../src/render/draw_terrain.ts","../src/render/painter.ts","../src/render/draw_circle.ts","../src/render/draw_heatmap.ts","../src/render/draw_line.ts","../src/render/draw_background.ts","../src/render/draw_custom.ts","../src/util/primitives.ts","../src/geo/edge_insets.ts","../src/geo/transform.ts","../node_modules/gl-matrix/esm/mat2.js","../src/util/throttle.ts","../src/ui/hash.ts","../src/ui/handler_inertia.ts","../src/ui/events.ts","../src/ui/handler/map_event.ts","../src/ui/handler/transform-provider.ts","../src/ui/handler/box_zoom.ts","../src/ui/handler/handler_util.ts","../src/ui/handler/tap_recognizer.ts","../src/ui/handler/tap_zoom.ts","../src/ui/handler/drag_handler.ts","../src/ui/handler/drag_move_state_manager.ts","../src/ui/handler/mouse.ts","../src/ui/handler/touch_pan.ts","../src/ui/handler/two_fingers_touch.ts","../src/ui/handler/keyboard.ts","../src/ui/handler/scroll_zoom.ts","../src/ui/handler/shim/dblclick_zoom.ts","../src/ui/handler/click_zoom.ts","../src/ui/handler/tap_drag_zoom.ts","../src/ui/handler/shim/drag_pan.ts","../src/ui/handler/shim/drag_rotate.ts","../src/ui/handler/shim/two_fingers_touch.ts","../src/ui/handler_manager.ts","../src/ui/camera.ts","../src/ui/control/attribution_control.ts","../src/ui/control/logo_control.ts","../src/util/task_queue.ts","../src/util/performance.ts","../src/ui/default_locale.ts","../src/data/pos3d_attributes.ts","../src/source/terrain_source_cache.ts","../src/render/terrain.ts","../src/gl/render_pool.ts","../src/render/render_to_texture.ts","../src/ui/map.ts","../src/ui/handler/one_finger_touch_drag.ts","../src/ui/control/navigation_control.ts","../src/util/geolocation_support.ts","../src/util/smart_wrap.ts","../src/ui/anchor.ts","../src/ui/marker.ts","../src/ui/control/geolocate_control.ts","../src/ui/control/scale_control.ts","../src/ui/popup.ts","../src/util/debug.ts","../src/index.ts","../src/ui/control/fullscreen_control.ts","../src/ui/control/terrain_control.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","'use strict';\n\nmodule.exports = Point;\n\n/**\n * A standalone point geometry with useful accessor, comparison, and\n * modification methods.\n *\n * @class Point\n * @param {Number} x the x-coordinate. this could be longitude or screen\n * pixels, or any other sort of unit.\n * @param {Number} y the y-coordinate. this could be latitude or screen\n * pixels, or any other sort of unit.\n * @example\n * var point = new Point(-77, 38);\n */\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n}\n\nPoint.prototype = {\n\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone: function() { return new Point(this.x, this.y); },\n\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add: function(p) { return this.clone()._add(p); },\n\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub: function(p) { return this.clone()._sub(p); },\n\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint: function(p) { return this.clone()._multByPoint(p); },\n\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint: function(p) { return this.clone()._divByPoint(p); },\n\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n mult: function(k) { return this.clone()._mult(k); },\n\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n div: function(k) { return this.clone()._div(k); },\n\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate: function(a) { return this.clone()._rotate(a); },\n\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); },\n\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {Array} m transformation matrix\n * @return {Point} output point\n */\n matMult: function(m) { return this.clone()._matMult(m); },\n\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit: function() { return this.clone()._unit(); },\n\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp: function() { return this.clone()._perp(); },\n\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round: function() { return this.clone()._round(); },\n\n /**\n * Return the magitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {Number} magnitude\n */\n mag: function() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals: function(other) {\n return this.x === other.x &&\n this.y === other.y;\n },\n\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {Number} distance\n */\n dist: function(p) {\n return Math.sqrt(this.distSqr(p));\n },\n\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {Number} distance\n */\n distSqr: function(p) {\n var dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {Number} angle\n */\n angle: function() {\n return Math.atan2(this.y, this.x);\n },\n\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleTo: function(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleWith: function(b) {\n return this.angleWithSep(b.x, b.y);\n },\n\n /*\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(θ) for θ.\n * @param {Number} x the x-coordinate\n * @param {Number} y the y-coordinate\n * @return {Number} the angle in radians\n */\n angleWithSep: function(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y);\n },\n\n _matMult: function(m) {\n var x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _add: function(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n\n _sub: function(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n\n _mult: function(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n\n _div: function(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n\n _multByPoint: function(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n\n _divByPoint: function(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n\n _unit: function() {\n this._div(this.mag());\n return this;\n },\n\n _perp: function() {\n var y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n\n _rotate: function(angle) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _rotateAround: function(angle, p) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n\n _round: function() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n }\n};\n\n/**\n * Construct a point from an array if necessary, otherwise if the input\n * is already a Point, or an unknown type, return it unchanged\n * @param {Array|Point|*} a any kind of input value\n * @return {Point} constructed point, or passed-through value.\n * @example\n * // this\n * var point = Point.convert([0, 1]);\n * // is equivalent to\n * var point = new Point(0, 1);\n */\nPoint.convert = function (a) {\n if (a instanceof Point) {\n return a;\n }\n if (Array.isArray(a)) {\n return new Point(a[0], a[1]);\n }\n return a;\n};\n","'use strict';\n\nmodule.exports = UnitBezier;\n\nfunction UnitBezier(p1x, p1y, p2x, p2y) {\n // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n this.cx = 3.0 * p1x;\n this.bx = 3.0 * (p2x - p1x) - this.cx;\n this.ax = 1.0 - this.cx - this.bx;\n\n this.cy = 3.0 * p1y;\n this.by = 3.0 * (p2y - p1y) - this.cy;\n this.ay = 1.0 - this.cy - this.by;\n\n this.p1x = p1x;\n this.p1y = p1y;\n this.p2x = p2x;\n this.p2y = p2y;\n}\n\nUnitBezier.prototype = {\n sampleCurveX: function (t) {\n // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n return ((this.ax * t + this.bx) * t + this.cx) * t;\n },\n\n sampleCurveY: function (t) {\n return ((this.ay * t + this.by) * t + this.cy) * t;\n },\n\n sampleCurveDerivativeX: function (t) {\n return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n },\n\n solveCurveX: function (x, epsilon) {\n if (epsilon === undefined) epsilon = 1e-6;\n\n if (x < 0.0) return 0.0;\n if (x > 1.0) return 1.0;\n\n var t = x;\n\n // First try a few iterations of Newton's method - normally very fast.\n for (var i = 0; i < 8; i++) {\n var x2 = this.sampleCurveX(t) - x;\n if (Math.abs(x2) < epsilon) return t;\n\n var d2 = this.sampleCurveDerivativeX(t);\n if (Math.abs(d2) < 1e-6) break;\n\n t = t - x2 / d2;\n }\n\n // Fall back to the bisection method for reliability.\n var t0 = 0.0;\n var t1 = 1.0;\n t = x;\n\n for (i = 0; i < 20; i++) {\n x2 = this.sampleCurveX(t);\n if (Math.abs(x2 - x) < epsilon) break;\n\n if (x > x2) {\n t0 = t;\n } else {\n t1 = t;\n }\n\n t = (t1 - t0) * 0.5 + t0;\n }\n\n return t;\n },\n\n solve: function (x, epsilon) {\n return this.sampleCurveY(this.solveCurveX(x, epsilon));\n }\n};\n","let supportsOffscreenCanvas: boolean;\n\nexport function offscreenCanvasSupported(): boolean {\n if (supportsOffscreenCanvas == null) {\n supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&\n new OffscreenCanvas(1, 1).getContext('2d') &&\n typeof createImageBitmap === 'function';\n }\n\n return supportsOffscreenCanvas;\n}\n","import {offscreenCanvasSupported} from './offscreen_canvas_supported';\n\nlet offscreenCanvasDistorted: boolean;\n\n/**\n * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185).\n * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false\n * if they don't match.\n *\n * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise.\n */\nexport function isOffscreenCanvasDistorted(): boolean {\n if (offscreenCanvasDistorted == null) {\n offscreenCanvasDistorted = false;\n if (offscreenCanvasSupported()) {\n const size = 5;\n const canvas = new OffscreenCanvas(size, size);\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (context) {\n // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel):\n // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...]\n for (let i = 0; i < size * size; i++) {\n const base = i * 4;\n context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;\n context.fillRect(i % size, Math.floor(i / size), 1, 1);\n }\n const data = context.getImageData(0, 0, size, size).data;\n for (let i = 0; i < size * size * 4; i++) {\n if (i % 4 !== 3 && data[i] !== i) {\n offscreenCanvasDistorted = true;\n break;\n }\n }\n }\n }\n }\n\n return offscreenCanvasDistorted || false;\n}\n","import Point from '@mapbox/point-geometry';\nimport UnitBezier from '@mapbox/unitbezier';\nimport type {Callback} from '../types/callback';\nimport {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted';\nimport type {Size} from './image';\n\n/**\n * Given a value `t` that varies between 0 and 1, return\n * an interpolation function that eases between 0 and 1 in a pleasing\n * cubic in-out fashion.\n */\nexport function easeCubicInOut(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n const t2 = t * t,\n t3 = t2 * t;\n return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75);\n}\n\n/**\n * Given given (x, y), (x1, y1) control points for a bezier curve,\n * return a function that interpolates along that curve.\n *\n * @param p1x - control point 1 x coordinate\n * @param p1y - control point 1 y coordinate\n * @param p2x - control point 2 x coordinate\n * @param p2y - control point 2 y coordinate\n */\nexport function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {\n const bezier = new UnitBezier(p1x, p1y, p2x, p2y);\n return function(t: number) {\n return bezier.solve(t);\n };\n}\n\n/**\n * A default bezier-curve powered easing function with\n * control points (0.25, 0.1) and (0.25, 1)\n */\nexport const defaultEasing = bezier(0.25, 0.1, 0.25, 1);\n\n/**\n * constrain n to the given range via min + max\n *\n * @param n - value\n * @param min - the minimum value to be returned\n * @param max - the maximum value to be returned\n * @returns the clamped value\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/**\n * constrain n to the given range, excluding the minimum, via modular arithmetic\n *\n * @param n - value\n * @param min - the minimum value to be returned, exclusive\n * @param max - the maximum value to be returned, inclusive\n * @returns constrained number\n */\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((n - min) % d + d) % d + min;\n return (w === min) ? max : w;\n}\n\n/**\n * Call an asynchronous function on an array of arguments,\n * calling `callback` with the completed results of all calls.\n *\n * @param array - input to each call of the async function.\n * @param fn - an async function with signature (data, callback)\n * @param callback - a callback run after all async work is done.\n * called with an array, containing the results of each async call.\n */\nexport function asyncAll(\n array: Array,\n fn: (item: Item, fnCallback: Callback) => void,\n callback: Callback>\n) {\n if (!array.length) { return callback(null, []); }\n let remaining = array.length;\n const results = new Array(array.length);\n let error = null;\n array.forEach((item, i) => {\n fn(item, (err, result) => {\n if (err) error = err;\n results[i] = (result as any as Result); // https://github.com/facebook/flow/issues/2123\n if (--remaining === 0) callback(error, results);\n });\n });\n}\n\n/**\n * Compute the difference between the keys in one object and the keys\n * in another object.\n *\n * @returns keys difference\n */\nexport function keysDifference(\n obj: {[key: string]: S},\n other: {[key: string]: T}\n): Array {\n const difference = [];\n for (const i in obj) {\n if (!(i in other)) {\n difference.push(i);\n }\n }\n return difference;\n}\n\n/**\n * Given a destination object and optionally many source objects,\n * copy all properties from the source objects into the destination.\n * The last source object given overrides properties from previous\n * source objects.\n *\n * @param dest - destination object\n * @param sources - sources from which properties are pulled\n */\nexport function extend(dest: any, ...sources: Array): any {\n for (const src of sources) {\n for (const k in src) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n/**\n * Given an object and a number of properties as strings, return version\n * of that object with only those properties.\n *\n * @param src - the object\n * @param properties - an array of property names chosen\n * to appear on the resulting object.\n * @returns object with limited properties.\n * @example\n * ```ts\n * let foo = { name: 'Charlie', age: 10 };\n * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' }\n * ```\n */\nexport function pick(src: any, properties: Array): any {\n const result = {};\n for (let i = 0; i < properties.length; i++) {\n const k = properties[i];\n if (k in src) {\n result[k] = src[k];\n }\n }\n return result;\n}\n\nlet id = 1;\n\n/**\n * Return a unique numeric id, starting at 1 and incrementing with\n * each call.\n *\n * @returns unique numeric id.\n */\nexport function uniqueId(): number {\n return id++;\n}\n\n/**\n * Return whether a given value is a power of two\n */\nexport function isPowerOfTwo(value: number): boolean {\n return (Math.log(value) / Math.LN2) % 1 === 0;\n}\n\n/**\n * Return the next power of two, or the input value if already a power of two\n */\nexport function nextPowerOfTwo(value: number): number {\n if (value <= 1) return 1;\n return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/**\n * Create an object by mapping all the values of an existing object while\n * preserving their keys.\n */\nexport function mapObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n output[key] = iterator.call(context || this, input[key], key, input);\n }\n return output;\n}\n\n/**\n * Create an object by filtering out values of an existing object.\n */\nexport function filterObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n if (iterator.call(context || this, input[key], key, input)) {\n output[key] = input[key];\n }\n }\n return output;\n}\n\n/**\n * Deeply compares two object literals.\n * @param a - first object literal to be compared\n * @param b - second object literal to be compared\n * @returns true if the two object literals are deeply equal, false otherwise\n */\nexport function deepEqual(a?: unknown | null, b?: unknown | null): boolean {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object')) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key])) return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * Deeply clones two objects.\n */\nexport function clone(input: T): T {\n if (Array.isArray(input)) {\n return input.map(clone) as any as T;\n } else if (typeof input === 'object' && input) {\n return mapObject(input, clone) as any as T;\n } else {\n return input;\n }\n}\n\n/**\n * Check if two arrays have at least one common element.\n */\nexport function arraysIntersect(a: Array, b: Array): boolean {\n for (let l = 0; l < a.length; l++) {\n if (b.indexOf(a[l]) >= 0) return true;\n }\n return false;\n}\n\n/**\n * Print a warning message to the console and ensure duplicate warning messages\n * are not printed.\n */\nconst warnOnceHistory: {[key: string]: boolean} = {};\n\nexport function warnOnce(message: string): void {\n if (!warnOnceHistory[message]) {\n // console isn't defined in some WebWorkers, see #2558\n if (typeof console !== 'undefined') console.warn(message);\n warnOnceHistory[message] = true;\n }\n}\n\n/**\n * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order\n *\n * @returns true for a counter clockwise set of points\n */\n// http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/\nexport function isCounterClockwise(a: Point, b: Point, c: Point): boolean {\n return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x);\n}\n\n/**\n * For two lines a and b in 2d space, defined by any two points along the lines,\n * find the intersection point, or return null if the lines are parallel\n *\n * @param a1 - First point on line a\n * @param a2 - Second point on line a\n * @param b1 - First point on line b\n * @param b2 - Second point on line b\n *\n * @returns the intersection point of the two lines or null if they are parallel\n */\nexport function findLineIntersection(a1: Point, a2: Point, b1: Point, b2: Point): Point | null {\n const aDeltaY = a2.y - a1.y;\n const aDeltaX = a2.x - a1.x;\n const bDeltaY = b2.y - b1.y;\n const bDeltaX = b2.x - b1.x;\n\n const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY);\n\n if (denominator === 0) {\n // Lines are parallel\n return null;\n }\n\n const originDeltaY = a1.y - b1.y;\n const originDeltaX = a1.x - b1.x;\n const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator;\n\n // Find intersection by projecting out from origin of first segment\n return new Point(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY));\n}\n\n/**\n * Returns the signed area for the polygon ring. Positive areas are exterior rings and\n * have a clockwise winding. Negative areas are interior rings and have a counter clockwise\n * ordering.\n *\n * @param ring - Exterior or interior ring\n */\nexport function calculateSignedArea(ring: Array): number {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\n/**\n * Detects closed polygons, first + last point are equal\n *\n * @param points - array of points\n * @returns `true` if the points are a closed polygon\n */\nexport function isClosedPolygon(points: Array): boolean {\n // If it is 2 points that are the same then it is a point\n // If it is 3 points with start and end the same then it is a line\n if (points.length < 4)\n return false;\n\n const p1 = points[0];\n const p2 = points[points.length - 1];\n\n if (Math.abs(p1.x - p2.x) > 0 ||\n Math.abs(p1.y - p2.y) > 0) {\n return false;\n }\n\n // polygon simplification can produce polygons with zero area and more than 3 points\n return Math.abs(calculateSignedArea(points)) > 0.01;\n}\n\n/**\n * Converts spherical coordinates to cartesian coordinates.\n *\n * @param spherical - Spherical coordinates, in [radial, azimuthal, polar]\n * @returns cartesian coordinates in [x, y, z]\n */\n\nexport function sphericalToCartesian([r, azimuthal, polar]: [number, number, number]): {\n x: number;\n y: number;\n z: number;\n} {\n // We abstract \"north\"/\"up\" (compass-wise) to be 0° when really this is 90° (π/2):\n // correct for that here\n azimuthal += 90;\n\n // Convert azimuthal and polar angles to radians\n azimuthal *= Math.PI / 180;\n polar *= Math.PI / 180;\n\n return {\n x: r * Math.cos(azimuthal) * Math.sin(polar),\n y: r * Math.sin(azimuthal) * Math.sin(polar),\n z: r * Math.cos(polar)\n };\n}\n\n/**\n * Returns true if the when run in the web-worker context.\n *\n * @returns `true` if the when run in the web-worker context.\n */\nexport function isWorker(): boolean {\n // @ts-ignore\n return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;\n}\n\n/**\n * Parses data from 'Cache-Control' headers.\n *\n * @param cacheControl - Value of 'Cache-Control' header\n * @returns object containing parsed header info.\n */\n\nexport function parseCacheControl(cacheControl: string): any {\n // Taken from [Wreck](https://github.com/hapijs/wreck)\n const re = /(?:^|(?:\\s*\\,\\s*))([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)(?:\\=(?:([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)|(?:\\\"((?:[^\"\\\\]|\\\\.)*)\\\")))?/g;\n\n const header = {};\n cacheControl.replace(re, ($0, $1, $2, $3) => {\n const value = $2 || $3;\n header[$1] = value ? value.toLowerCase() : true;\n return '';\n });\n\n if (header['max-age']) {\n const maxAge = parseInt(header['max-age'], 10);\n if (isNaN(maxAge)) delete header['max-age'];\n else header['max-age'] = maxAge;\n }\n\n return header;\n}\n\nlet _isSafari = null;\n\n/**\n * Returns true when run in WebKit derived browsers.\n * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to\n * transfer data between WebWorkers and the main thread.\n * https://github.com/mapbox/mapbox-gl-js/issues/8771\n *\n * This should be removed once the underlying Safari issue is fixed.\n *\n * @param scope - Since this function is used both on the main thread and WebWorker context,\n * let the calling scope pass in the global scope object.\n * @returns `true` when run in WebKit derived browsers.\n */\nexport function isSafari(scope: any): boolean {\n if (_isSafari == null) {\n const userAgent = scope.navigator ? scope.navigator.userAgent : null;\n _isSafari = !!scope.safari ||\n !!(userAgent && (/\\b(iPad|iPhone|iPod)\\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome'))));\n }\n return _isSafari;\n}\n\nexport function storageAvailable(type: string): boolean {\n try {\n const storage = window[type];\n storage.setItem('_mapbox_test_', 1);\n storage.removeItem('_mapbox_test_');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n//Unicode compliant base64 encoder for strings\nexport function b64EncodeUnicode(str: string) {\n return btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,\n (match, p1) => {\n return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line\n }\n )\n );\n}\n\n// Unicode compliant decoder for base64-encoded strings\nexport function b64DecodeUnicode(str: string) {\n return decodeURIComponent(atob(str).split('').map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line\n }).join(''));\n}\n\nexport function isImageBitmap(image: any): image is ImageBitmap {\n return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;\n}\n\n/**\n * Converts an ArrayBuffer to an ImageBitmap.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image bitmap (when no error) as the second\n */\nexport function arrayBufferToImageBitmap(data: ArrayBuffer, callback: (err?: Error | null, image?: ImageBitmap | null) => void) {\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n createImageBitmap(blob).then((imgBitmap) => {\n callback(null, imgBitmap);\n }).catch((e) => {\n callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));\n });\n}\n\nconst transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';\n\n/**\n * Converts an ArrayBuffer to an HTMLImageElement.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image element (when no error) as the second\n */\nexport function arrayBufferToImage(data: ArrayBuffer, callback: (err?: Error | null, image?: HTMLImageElement | null) => void) {\n const img: HTMLImageElement = new Image();\n img.onload = () => {\n callback(null, img);\n URL.revokeObjectURL(img.src);\n // prevent image dataURI memory leak in Safari;\n // but don't free the image immediately because it might be uploaded in the next frame\n // https://github.com/mapbox/mapbox-gl-js/issues/10226\n img.onload = null;\n window.requestAnimationFrame(() => { img.src = transparentPngUrl; });\n };\n img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;\n}\n\n/**\n * Computes the webcodecs VideoFrame API options to select a rectangle out of\n * an image and write it into the destination rectangle.\n *\n * Rect (x/y/width/height) select the overlapping rectangle from the source image\n * and layout (offset/stride) write that overlapping rectangle to the correct place\n * in the destination image.\n *\n * Offset is the byte offset in the dest image that the first pixel appears at\n * and stride is the number of bytes to the start of the next row:\n * ┌───────────┐\n * │ dest │\n * │ ┌───┼───────┐\n * │offset→│▓▓▓│ source│\n * │ │▓▓▓│ │\n * │ └───┼───────┘\n * │stride ⇠╌╌╌│\n * │╌╌╌╌╌╌→ │\n * └───────────┘\n *\n * @param image - source image containing a width and height attribute\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns the layout and rect options to pass into VideoFrame API\n */\nfunction computeVideoFrameParameters(image: Size, x: number, y: number, width: number, height: number): VideoFrameCopyToOptions {\n const destRowOffset = Math.max(-x, 0) * 4;\n const firstSourceRow = Math.max(0, y);\n const firstDestRow = firstSourceRow - y;\n const offset = firstDestRow * width * 4 + destRowOffset;\n const stride = width * 4;\n\n const sourceLeft = Math.max(0, x);\n const sourceTop = Math.max(0, y);\n const sourceRight = Math.min(image.width, x + width);\n const sourceBottom = Math.min(image.height, y + height);\n return {\n rect: {\n x: sourceLeft,\n y: sourceTop,\n width: sourceRight - sourceLeft,\n height: sourceBottom - sourceTop\n },\n layout: [{offset, stride}]\n };\n}\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport async function readImageUsingVideoFrame(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (typeof VideoFrame === 'undefined') {\n throw new Error('VideoFrame not supported');\n }\n const frame = new VideoFrame(image, {timestamp: 0});\n try {\n const format = frame?.format;\n if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {\n throw new Error(`Unrecognized format ${format}`);\n }\n const swapBR = format.startsWith('BGR');\n const result = new Uint8ClampedArray(width * height * 4);\n await frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));\n if (swapBR) {\n for (let i = 0; i < result.length; i += 4) {\n const tmp = result[i];\n result[i] = result[i + 2];\n result[i + 2] = tmp;\n }\n }\n return result;\n } finally {\n frame.close();\n }\n}\n\nlet offscreenCanvas: OffscreenCanvas;\nlet offscreenCanvasContext: OffscreenCanvasRenderingContext2D;\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport function readImageDataUsingOffscreenCanvas(\n imgBitmap: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Uint8ClampedArray {\n const origWidth = imgBitmap.width;\n const origHeight = imgBitmap.height;\n // Lazily initialize OffscreenCanvas\n if (!offscreenCanvas || !offscreenCanvasContext) {\n // Dem tiles are typically 256x256\n offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);\n offscreenCanvasContext = offscreenCanvas.getContext('2d', {willReadFrequently: true});\n }\n\n offscreenCanvas.width = origWidth;\n offscreenCanvas.height = origHeight;\n\n offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);\n const imgData = offscreenCanvasContext.getImageData(x, y, width, height);\n offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);\n return imgData.data;\n}\n\n/**\n * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and\n * the browser is mangling OffscreenCanvas getImageData results.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image\n */\nexport async function getImageData(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (isOffscreenCanvasDistorted()) {\n try {\n return await readImageUsingVideoFrame(image, x, y, width, height);\n } catch (e) {\n // fall back to OffscreenCanvas\n }\n }\n return readImageDataUsingOffscreenCanvas(image, x, y, width, height);\n}\n","import type {Cancelable} from '../types/cancelable';\n\nconst now = typeof performance !== 'undefined' && performance && performance.now ?\n performance.now.bind(performance) :\n Date.now.bind(Date);\n\nlet linkEl;\n\nlet reducedMotionQuery: MediaQueryList;\n\n/** */\nexport const browser = {\n /**\n * Provides a function that outputs milliseconds: either performance.now()\n * or a fallback to Date.now()\n */\n now,\n\n frame(fn: (paintStartTimestamp: number) => void): Cancelable {\n const frame = requestAnimationFrame(fn);\n return {cancel: () => cancelAnimationFrame(frame)};\n },\n\n getImageData(img: HTMLImageElement | ImageBitmap, padding: number = 0): ImageData {\n const context = this.getImageCanvasContext(img);\n return context.getImageData(-padding, -padding, img.width as number + 2 * padding, img.height as number + 2 * padding);\n },\n\n getImageCanvasContext(img: HTMLImageElement | ImageBitmap): CanvasRenderingContext2D {\n const canvas = window.document.createElement('canvas') as HTMLCanvasElement;\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (!context) {\n throw new Error('failed to create canvas 2d context');\n }\n canvas.width = img.width as number;\n canvas.height = img.height as number;\n context.drawImage(img, 0, 0, img.width as number, img.height as number);\n return context;\n },\n\n resolveURL(path: string) {\n if (!linkEl) linkEl = document.createElement('a');\n linkEl.href = path;\n return linkEl.href;\n },\n\n hardwareConcurrency: typeof navigator !== 'undefined' && navigator.hardwareConcurrency || 4,\n\n get prefersReducedMotion(): boolean {\n // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util'\n if (!matchMedia) return false;\n //Lazily initialize media query\n if (reducedMotionQuery == null) {\n reducedMotionQuery = matchMedia('(prefers-reduced-motion: reduce)');\n }\n return reducedMotionQuery.matches;\n },\n};\n","import Point from '@mapbox/point-geometry';\n\nexport class DOM {\n private static readonly docStyle = typeof window !== 'undefined' && window.document && window.document.documentElement.style;\n\n private static userSelect: string;\n\n private static selectProp = DOM.testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);\n\n private static transformProp = DOM.testProp(['transform', 'WebkitTransform']);\n\n private static testProp(props: string[]): string {\n if (!DOM.docStyle) return props[0];\n for (let i = 0; i < props.length; i++) {\n if (props[i] in DOM.docStyle) {\n return props[i];\n }\n }\n return props[0];\n }\n\n public static create(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K] {\n const el = window.document.createElement(tagName);\n if (className !== undefined) el.className = className;\n if (container) container.appendChild(el);\n return el;\n }\n\n public static createNS(namespaceURI: string, tagName: string) {\n const el = window.document.createElementNS(namespaceURI, tagName);\n return el;\n }\n\n public static disableDrag() {\n if (DOM.docStyle && DOM.selectProp) {\n DOM.userSelect = DOM.docStyle[DOM.selectProp];\n DOM.docStyle[DOM.selectProp] = 'none';\n }\n }\n\n public static enableDrag() {\n if (DOM.docStyle && DOM.selectProp) {\n DOM.docStyle[DOM.selectProp] = DOM.userSelect;\n }\n }\n\n public static setTransform(el: HTMLElement, value: string) {\n el.style[DOM.transformProp] = value;\n }\n\n public static addEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: {\n passive?: boolean;\n capture?: boolean;\n } = {}) {\n if ('passive' in options) {\n target.addEventListener(type, callback, options);\n } else {\n target.addEventListener(type, callback, options.capture);\n }\n }\n\n public static removeEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: {\n passive?: boolean;\n capture?: boolean;\n } = {}) {\n if ('passive' in options) {\n target.removeEventListener(type, callback, options);\n } else {\n target.removeEventListener(type, callback, options.capture);\n }\n }\n\n // Suppress the next click, but only if it's immediate.\n private static suppressClickInternal(e) {\n e.preventDefault();\n e.stopPropagation();\n window.removeEventListener('click', DOM.suppressClickInternal, true);\n }\n\n public static suppressClick() {\n window.addEventListener('click', DOM.suppressClickInternal, true);\n window.setTimeout(() => {\n window.removeEventListener('click', DOM.suppressClickInternal, true);\n }, 0);\n }\n\n public static mousePos(el: HTMLElement, e: MouseEvent | Touch) {\n const rect = el.getBoundingClientRect();\n return new Point(\n e.clientX - rect.left - el.clientLeft,\n e.clientY - rect.top - el.clientTop\n );\n }\n\n public static touchPos(el: HTMLElement, touches: TouchList) {\n const rect = el.getBoundingClientRect();\n const points: Point[] = [];\n for (let i = 0; i < touches.length; i++) {\n points.push(new Point(\n touches[i].clientX - rect.left - el.clientLeft,\n touches[i].clientY - rect.top - el.clientTop\n ));\n }\n return points;\n }\n\n public static mouseButton(e: MouseEvent) {\n return e.button;\n }\n\n public static remove(node: HTMLElement) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n}\n","import type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from './ajax';\n\n/**\n * This is a global config object used to store the configuration\n * It is available in the workers as well.\n * Only serializable data should be stored in it.\n */\ntype Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: number;\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number;\n MAX_TILE_CACHE_ZOOM_LEVELS: number;\n REGISTERED_PROTOCOLS: {[x: string]: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable};\n WORKER_URL: string;\n};\n\nexport const config: Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: 16,\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8,\n MAX_TILE_CACHE_ZOOM_LEVELS: 5,\n REGISTERED_PROTOCOLS: {},\n WORKER_URL: ''\n};\n","import {extend, warnOnce, isWorker} from './util';\nimport {config} from './config';\n\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\n/**\n * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks.\n * @example\n * ```ts\n * // use transformRequest to modify requests that begin with `http://myHost`\n * transformRequest: function(url, resourceType) {\n * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true },\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * ```\n */\nexport type RequestParameters = {\n /**\n * The URL to be requested.\n */\n url: string;\n /**\n * The headers to be sent with the request.\n */\n headers?: any;\n /**\n * Request method `'GET' | 'POST' | 'PUT'`.\n */\n method?: 'GET' | 'POST' | 'PUT';\n /**\n * Request body.\n */\n body?: string;\n /**\n * Response body type to be returned `'string' | 'json' | 'arrayBuffer'`.\n */\n type?: 'string' | 'json' | 'arrayBuffer' | 'image';\n /**\n * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests.\n */\n credentials?: 'same-origin' | 'include';\n /**\n * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events.\n */\n collectResourceTiming?: boolean;\n /**\n * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)\n */\n cache?: RequestCache;\n};\n\n/**\n * The response callback used in various places\n */\nexport type ResponseCallback = (\n error?: Error | null,\n data?: T | null,\n cacheControl?: string | null,\n expires?: string | null\n) => void;\n\n/**\n * An error thrown when a HTTP request results in an error response.\n */\nexport class AJAXError extends Error {\n /**\n * The response's HTTP status code.\n */\n status: number;\n\n /**\n * The response's HTTP status text.\n */\n statusText: string;\n\n /**\n * The request's URL.\n */\n url: string;\n\n /**\n * The response's body.\n */\n body: Blob;\n\n /**\n * @param status - The response's HTTP status code.\n * @param statusText - The response's HTTP status text.\n * @param url - The request's URL.\n * @param body - The response's body.\n */\n constructor(status: number, statusText: string, url: string, body: Blob) {\n super(`AJAXError: ${statusText} (${status}): ${url}`);\n this.status = status;\n this.statusText = statusText;\n this.url = url;\n this.body = body;\n }\n}\n\n// Ensure that we're sending the correct referrer from blob URL worker bundles.\n// For files loaded from the local file system, `location.origin` will be set\n// to the string(!) \"null\" (Firefox), or \"file://\" (Chrome, Safari, Edge, IE),\n// and we will set an empty referrer. Otherwise, we're using the document's URL.\n/* global self */\nexport const getReferrer = isWorker() ?\n () => (self as any).worker && (self as any).worker.referrer :\n () => (window.location.protocol === 'blob:' ? window.parent : window).location.href;\n\nexport const getProtocolAction = url => config.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))];\n\n// Determines whether a URL is a file:// URL. This is obviously the case if it begins\n// with file://. Relative URLs are also file:// URLs iff the original document was loaded\n// via a file:// URL.\nconst isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\\w+:/.test(url));\n\nfunction makeFetchRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const controller = new AbortController();\n const request = new Request(requestParameters.url, {\n method: requestParameters.method || 'GET',\n body: requestParameters.body,\n credentials: requestParameters.credentials,\n headers: requestParameters.headers,\n cache: requestParameters.cache,\n referrer: getReferrer(),\n signal: controller.signal\n });\n let complete = false;\n let aborted = false;\n\n if (requestParameters.type === 'json') {\n request.headers.set('Accept', 'application/json');\n }\n\n const validateOrFetch = (err, cachedResponse?, responseIsFresh?) => {\n if (aborted) return;\n\n if (err) {\n // Do fetch in case of cache error.\n // HTTP pages in Edge trigger a security error that can be ignored.\n if (err.message !== 'SecurityError') {\n warnOnce(err);\n }\n }\n\n if (cachedResponse && responseIsFresh) {\n return finishRequest(cachedResponse);\n }\n\n if (cachedResponse) {\n // We can't do revalidation with 'If-None-Match' because then the\n // request doesn't have simple cors headers.\n }\n\n fetch(request).then(response => {\n if (response.ok) {\n return finishRequest(response);\n\n } else {\n return response.blob().then(body => callback(new AJAXError(response.status, response.statusText, requestParameters.url, body)));\n }\n }).catch(error => {\n if (error.code === 20) {\n // silence expected AbortError\n return;\n }\n callback(new Error(error.message));\n });\n };\n\n const finishRequest = (response) => {\n (\n (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') ? response.arrayBuffer() :\n requestParameters.type === 'json' ? response.json() :\n response.text()\n ).then(result => {\n if (aborted) return;\n complete = true;\n callback(null, result, response.headers.get('Cache-Control'), response.headers.get('Expires'));\n }).catch(err => {\n if (!aborted) callback(new Error(err.message));\n });\n };\n\n validateOrFetch(null, null);\n\n return {cancel: () => {\n aborted = true;\n if (!complete) controller.abort();\n }};\n}\n\nfunction makeXMLHttpRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const xhr: XMLHttpRequest = new XMLHttpRequest();\n\n xhr.open(requestParameters.method || 'GET', requestParameters.url, true);\n if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') {\n xhr.responseType = 'arraybuffer';\n }\n for (const k in requestParameters.headers) {\n xhr.setRequestHeader(k, requestParameters.headers[k]);\n }\n if (requestParameters.type === 'json') {\n xhr.responseType = 'text';\n xhr.setRequestHeader('Accept', 'application/json');\n }\n xhr.withCredentials = requestParameters.credentials === 'include';\n xhr.onerror = () => {\n callback(new Error(xhr.statusText));\n };\n xhr.onload = () => {\n if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) {\n let data: unknown = xhr.response;\n if (requestParameters.type === 'json') {\n // We're manually parsing JSON here to get better error messages.\n try {\n data = JSON.parse(xhr.response);\n } catch (err) {\n return callback(err);\n }\n }\n callback(null, data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires'));\n } else {\n const body = new Blob([xhr.response], {type: xhr.getResponseHeader('Content-Type')});\n callback(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body));\n }\n };\n xhr.send(requestParameters.body);\n return {cancel: () => xhr.abort()};\n}\n\nexport const makeRequest = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n // We're trying to use the Fetch API if possible. However, in some situations we can't use it:\n // - IE11 doesn't support it at all. In this case, we dispatch the request to the main thread so\n // that we can get an accruate referrer header.\n // - Safari exposes window.AbortController, but it doesn't work actually abort any requests in\n // some versions (see https://bugs.webkit.org/show_bug.cgi?id=174980#c2)\n // - Requests for resources with the file:// URI scheme don't work with the Fetch API either. In\n // this case we unconditionally use XHR on the current thread since referrers don't matter.\n if (/:\\/\\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) {\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n return (self as any).worker.actor.send('getResource', requestParameters, callback);\n }\n if (!isWorker()) {\n const action = getProtocolAction(requestParameters.url) || makeFetchRequest;\n return action(requestParameters, callback);\n }\n }\n if (!isFileURL(requestParameters.url)) {\n if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) {\n return makeFetchRequest(requestParameters, callback);\n }\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n const queueOnMainThread = true;\n return (self as any).worker.actor.send('getResource', requestParameters, callback, undefined, queueOnMainThread);\n }\n }\n return makeXMLHttpRequest(requestParameters, callback);\n};\n\nexport const getJSON = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'json'}), callback);\n};\n\nexport const getArrayBuffer = function(\n requestParameters: RequestParameters,\n callback: ResponseCallback\n): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), callback);\n};\n\nexport const postData = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {method: 'POST'}), callback);\n};\n\nexport function sameOrigin(inComingUrl: string) {\n // URL class should be available everywhere\n // https://developer.mozilla.org/en-US/docs/Web/API/URL\n // In addtion, a relative URL \"/foo\" or \"./foo\" will throw exception in its ctor,\n // try-catch is expansive so just use a heuristic check to avoid it\n // also check data URL\n if (!inComingUrl ||\n inComingUrl.indexOf('://') <= 0 || // relative URL\n inComingUrl.indexOf('data:image/') === 0 || // data image URL\n inComingUrl.indexOf('blob:') === 0) { // blob\n return true;\n }\n const urlObj = new URL(inComingUrl);\n const locationObj = window.location;\n return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host;\n}\n/**\n * A type used to store the tile's expiration date and cache control definition\n */\nexport type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null};\nexport const getVideo = function(urls: Array, callback: Callback): Cancelable {\n const video: HTMLVideoElement = window.document.createElement('video');\n video.muted = true;\n video.onloadstart = function() {\n callback(null, video);\n };\n for (let i = 0; i < urls.length; i++) {\n const s: HTMLSourceElement = window.document.createElement('source');\n if (!sameOrigin(urls[i])) {\n video.crossOrigin = 'Anonymous';\n }\n s.src = urls[i];\n video.appendChild(s);\n }\n return {cancel: () => {}};\n};\n","export const webpSupported = {\n supported: false,\n testSupport\n};\n\nlet glForTesting: WebGLRenderingContext|WebGL2RenderingContext;\nlet webpCheckComplete = false;\nlet webpImgTest;\nlet webpImgTestOnloadComplete = false;\n\nif (typeof document !== 'undefined') {\n webpImgTest = document.createElement('img');\n webpImgTest.onload = function() {\n if (glForTesting) testWebpTextureUpload(glForTesting);\n glForTesting = null;\n webpImgTestOnloadComplete = true;\n };\n webpImgTest.onerror = function() {\n webpCheckComplete = true;\n glForTesting = null;\n };\n webpImgTest.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=';\n}\n\nfunction testSupport(gl: WebGLRenderingContext | WebGL2RenderingContext) {\n if (webpCheckComplete || !webpImgTest) return;\n\n // HTMLImageElement.complete is set when an image is done loading it's source\n // regardless of whether the load was successful or not.\n // It's possible for an error to set HTMLImageElement.complete to true which would trigger\n // testWebpTextureUpload and mistakenly set exported.supported to true in browsers which don't support webp\n // To avoid this, we set a flag in the image's onload handler and only call testWebpTextureUpload\n // after a successful image load event.\n if (webpImgTestOnloadComplete) {\n testWebpTextureUpload(gl);\n } else {\n glForTesting = gl;\n\n }\n}\n\nfunction testWebpTextureUpload(gl: WebGLRenderingContext|WebGL2RenderingContext) {\n // Edge 18 supports WebP but not uploading a WebP image to a gl texture\n // Test support for this before allowing WebP images.\n // https://github.com/mapbox/mapbox-gl-js/issues/7671\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n\n try {\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, webpImgTest);\n\n // The error does not get triggered in Edge if the context is lost\n if (gl.isContextLost()) return;\n\n webpSupported.supported = true;\n } catch (e) {\n // Catch \"Unspecified Error.\" in Edge 18.\n }\n\n gl.deleteTexture(texture);\n\n webpCheckComplete = true;\n}\n","import type {Cancelable} from '../types/cancelable';\nimport {RequestParameters, ExpiryData, makeRequest, sameOrigin, getProtocolAction} from './ajax';\nimport type {Callback} from '../types/callback';\n\nimport {arrayBufferToImageBitmap, arrayBufferToImage, extend, isWorker, isImageBitmap} from './util';\nimport {webpSupported} from './webp_supported';\nimport {config} from './config';\n\n/**\n * The callback that is being called after an image was fetched\n */\nexport type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void;\n\ntype ImageQueueThrottleControlCallback = () => boolean;\n\nexport type ImageRequestQueueItem = Cancelable & {\n requestParameters: RequestParameters;\n supportImageRefresh: boolean;\n callback: GetImageCallback;\n cancelled: boolean;\n completed: boolean;\n innerRequest?: Cancelable;\n}\n\ntype ImageQueueThrottleCallbackDictionary = {\n [Key: number]: ImageQueueThrottleControlCallback;\n}\n\ntype HTMLImageElementWithPriority = HTMLImageElement &\n{\n // fetchPriority is experimental property supported on Chromium browsers from Version 102\n // By default images are downloaded with priority low, whereas fetch request downloads with priority high\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority\n fetchPriority?: 'auto' | 'high' | 'low';\n};\n\n/**\n * By default, the image queue is self driven, meaning as soon as one requested item is processed,\n * it will move on to next one as quickly as it can while limiting\n * the number of concurrent requests to MAX_PARALLEL_IMAGE_REQUESTS. The default behavior\n * ensures that static views of the map can be rendered with minimal delay.\n *\n * However, the default behavior can prevent dynamic views of the map from rendering\n * smoothly in that many requests can finish in one render frame, putting too much pressure on GPU.\n *\n * When the view of the map is moving dynamically, smoother frame rates can be achieved\n * by throttling the number of items processed by the queue per frame. This can be\n * accomplished by using {@link addThrottleControl} to allow the caller to\n * use a lambda function to determine when the queue should be throttled (e.g. when isMoving())\n * and manually calling {@link processQueue} in the render loop.\n */\nexport namespace ImageRequest {\n let imageRequestQueue : ImageRequestQueueItem[];\n let currentParallelImageRequests:number;\n\n let throttleControlCallbackHandleCounter: number;\n let throttleControlCallbacks: ImageQueueThrottleCallbackDictionary;\n\n /**\n * Reset the image request queue, removing all pending requests.\n */\n export const resetRequestQueue = (): void => {\n imageRequestQueue = [];\n currentParallelImageRequests = 0;\n throttleControlCallbackHandleCounter = 0;\n throttleControlCallbacks = {};\n };\n\n /**\n * Install a callback to control when image queue throttling is desired.\n * (e.g. when the map view is moving)\n * @param callback - The callback function to install\n * @returns handle that identifies the installed callback.\n */\n export const addThrottleControl = (callback: ImageQueueThrottleControlCallback): number => {\n const handle = throttleControlCallbackHandleCounter++;\n throttleControlCallbacks[handle] = callback;\n return handle;\n };\n\n /**\n * Remove a previously installed callback by passing in the handle returned\n * by {@link addThrottleControl}.\n * @param callbackHandle - The handle for the callback to remove.\n */\n export const removeThrottleControl = (callbackHandle: number): void => {\n delete throttleControlCallbacks[callbackHandle];\n // Try updating the queue\n processQueue();\n };\n\n /**\n * Check to see if any of the installed callbacks are requesting the queue\n * to be throttled.\n * @returns `true` if any callback is causing the queue to be throttled.\n */\n const isThrottled = (): boolean => {\n const allControlKeys = Object.keys(throttleControlCallbacks);\n let throttleingRequested = false;\n if (allControlKeys.length > 0) {\n for (const key of allControlKeys) {\n throttleingRequested = throttleControlCallbacks[key]();\n if (throttleingRequested) {\n break;\n }\n }\n }\n return throttleingRequested;\n };\n\n /**\n * Request to load an image.\n * @param requestParameters - Request parameters.\n * @param callback - Callback to issue when the request completes.\n * @param supportImageRefresh - `true`, if the image request need to support refresh based on cache headers.\n * @returns Cancelable request.\n */\n export const getImage = (\n requestParameters: RequestParameters,\n callback: GetImageCallback,\n supportImageRefresh: boolean = true\n ): ImageRequestQueueItem => {\n if (webpSupported.supported) {\n if (!requestParameters.headers) {\n requestParameters.headers = {};\n }\n requestParameters.headers.accept = 'image/webp,*/*';\n }\n\n const request:ImageRequestQueueItem = {\n requestParameters,\n supportImageRefresh,\n callback,\n cancelled: false,\n completed: false,\n cancel: () => {\n if (!request.completed && !request.cancelled) {\n request.cancelled = true;\n\n // Only reduce currentParallelImageRequests, if the image request was issued.\n if (request.innerRequest) {\n request.innerRequest.cancel();\n currentParallelImageRequests--;\n }\n\n // in the case of cancelling, it WILL move on\n processQueue();\n }\n }\n };\n\n imageRequestQueue.push(request);\n processQueue();\n return request;\n };\n\n const arrayBufferToCanvasImageSource = (data: ArrayBuffer, callback: Callback) => {\n const imageBitmapSupported = typeof createImageBitmap === 'function';\n if (imageBitmapSupported) {\n arrayBufferToImageBitmap(data, callback);\n } else {\n arrayBufferToImage(data, callback);\n }\n };\n\n const doImageRequest = (itemInQueue: ImageRequestQueueItem): Cancelable => {\n const {requestParameters, supportImageRefresh, callback} = itemInQueue;\n extend(requestParameters, {type: 'image'});\n\n // - If refreshExpiredTiles is false, then we can use HTMLImageElement to download raster images.\n // - Fetch/XHR (via MakeRequest API) will be used to download images for following scenarios:\n // 1. Style image sprite will had a issue with HTMLImageElement as described\n // here: https://github.com/mapbox/mapbox-gl-js/issues/1470\n // 2. If refreshExpiredTiles is true (default), then in order to read the image cache header,\n // fetch/XHR request will be required\n // - For any special case handling like use of AddProtocol, worker initiated request or additional headers\n // let makeRequest handle it.\n // - HtmlImageElement request automatically adds accept header for all the browser supported images\n const canUseHTMLImageElement = supportImageRefresh === false &&\n !isWorker() &&\n !getProtocolAction(requestParameters.url) &&\n (!requestParameters.headers ||\n Object.keys(requestParameters.headers).reduce((acc, item) => acc && item === 'accept', true));\n\n const action = canUseHTMLImageElement ? getImageUsingHtmlImage : makeRequest;\n return action(\n requestParameters,\n (err?: Error | null,\n data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null,\n cacheControl?: string | null,\n expires?: string | null) => {\n onImageResponse(itemInQueue, callback, err, data, cacheControl, expires);\n });\n };\n\n const onImageResponse = (\n itemInQueue: ImageRequestQueueItem,\n callback:GetImageCallback,\n err?: Error | null,\n data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null,\n cacheControl?: string | null,\n expires?: string | null): void => {\n if (err) {\n callback(err);\n } else if (data instanceof HTMLImageElement || isImageBitmap(data)) {\n // User using addProtocol can directly return HTMLImageElement/ImageBitmap type\n // If HtmlImageElement is used to get image then response type will be HTMLImageElement\n callback(null, data);\n } else if (data) {\n const decoratedCallback = (imgErr?: Error | null, imgResult?: CanvasImageSource | null) => {\n if (imgErr != null) {\n callback(imgErr);\n } else if (imgResult != null) {\n callback(null, imgResult as (HTMLImageElement | ImageBitmap), {cacheControl, expires});\n }\n };\n arrayBufferToCanvasImageSource(data, decoratedCallback);\n }\n if (!itemInQueue.cancelled) {\n itemInQueue.completed = true;\n currentParallelImageRequests--;\n\n processQueue();\n }\n };\n\n /**\n * Process some number of items in the image request queue.\n */\n const processQueue = (): void => {\n\n const maxImageRequests = isThrottled() ?\n config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME :\n config.MAX_PARALLEL_IMAGE_REQUESTS;\n\n // limit concurrent image loads to help with raster sources performance on big screens\n for (let numImageRequests = currentParallelImageRequests;\n numImageRequests < maxImageRequests && imageRequestQueue.length > 0;\n numImageRequests++) {\n\n const topItemInQueue: ImageRequestQueueItem = imageRequestQueue.shift();\n if (topItemInQueue.cancelled) {\n numImageRequests--;\n continue;\n }\n\n const innerRequest = doImageRequest(topItemInQueue);\n\n currentParallelImageRequests++;\n\n topItemInQueue.innerRequest = innerRequest;\n }\n };\n\n const getImageUsingHtmlImage = (requestParameters: RequestParameters, callback: GetImageCallback): Cancelable => {\n const image = new Image() as HTMLImageElementWithPriority;\n const url = requestParameters.url;\n let requestCancelled = false;\n const credentials = requestParameters.credentials;\n if (credentials && credentials === 'include') {\n image.crossOrigin = 'use-credentials';\n } else if ((credentials && credentials === 'same-origin') || !sameOrigin(url)) {\n image.crossOrigin = 'anonymous';\n }\n\n image.fetchPriority = 'high';\n image.onload = () => {\n callback(null, image);\n image.onerror = image.onload = null;\n };\n image.onerror = () => {\n if (!requestCancelled) {\n callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n }\n image.onerror = image.onload = null;\n };\n image.src = url;\n return {\n cancel: () => {\n requestCancelled = true;\n // Set src to '' to actually cancel the request\n image.src = '';\n }\n };\n };\n}\n\nImageRequest.resetRequestQueue();\n","import type {RequestParameters} from './ajax';\n\n/**\n * A type of MapLibre resource.\n */\nexport const enum ResourceType {\n Glyphs = 'Glyphs',\n Image = 'Image',\n Source = 'Source',\n SpriteImage = 'SpriteImage',\n SpriteJSON = 'SpriteJSON',\n Style = 'Style',\n Tile = 'Tile',\n Unknown = 'Unknown',\n}\n\n/**\n * This function is used to tranform a request.\n * It is used just before executing the relevant request.\n */\nexport type RequestTransformFunction = (url: string, resourceType?: ResourceType) => RequestParameters | undefined;\n\ntype UrlObject = {\n protocol: string;\n authority: string;\n path: string;\n params: Array;\n};\n\nexport class RequestManager {\n _transformRequestFn: RequestTransformFunction;\n\n constructor(transformRequestFn?: RequestTransformFunction) {\n this._transformRequestFn = transformRequestFn;\n }\n\n transformRequest(url: string, type: ResourceType) {\n if (this._transformRequestFn) {\n return this._transformRequestFn(url, type) || {url};\n }\n\n return {url};\n }\n\n normalizeSpriteURL(url: string, format: string, extension: string): string {\n const urlObject = parseUrl(url);\n urlObject.path += `${format}${extension}`;\n return formatUrl(urlObject);\n }\n\n setTransformRequest(transformRequest: RequestTransformFunction) {\n this._transformRequestFn = transformRequest;\n }\n}\n\nconst urlRe = /^(\\w+):\\/\\/([^/?]*)(\\/[^?]+)?\\??(.+)?/;\n\nfunction parseUrl(url: string): UrlObject {\n const parts = url.match(urlRe);\n if (!parts) {\n throw new Error(`Unable to parse URL \"${url}\"`);\n }\n return {\n protocol: parts[1],\n authority: parts[2],\n path: parts[3] || '/',\n params: parts[4] ? parts[4].split('&') : []\n };\n}\n\nfunction formatUrl(obj: UrlObject): string {\n const params = obj.params.length ? `?${obj.params.join('&')}` : '';\n return `${obj.protocol}://${obj.authority}${obj.path}${params}`;\n}\n","import {extend} from './util';\n\n/**\n * A listener method used as a callback to events\n */\nexport type Listener = (a: any) => any;\n\ntype Listeners = {[_: string]: Array};\n\nfunction _addEventListener(type: string, listener: Listener, listenerList: Listeners) {\n const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;\n if (!listenerExists) {\n listenerList[type] = listenerList[type] || [];\n listenerList[type].push(listener);\n }\n}\n\nfunction _removeEventListener(type: string, listener: Listener, listenerList: Listeners) {\n if (listenerList && listenerList[type]) {\n const index = listenerList[type].indexOf(listener);\n if (index !== -1) {\n listenerList[type].splice(index, 1);\n }\n }\n}\n\n/**\n * The event class\n */\nexport class Event {\n readonly type: string;\n\n constructor(type: string, data: any = {}) {\n extend(this, data);\n this.type = type;\n }\n}\n\ninterface ErrorLike {\n message: string;\n}\n\n/**\n * An error event\n */\nexport class ErrorEvent extends Event {\n error: ErrorLike;\n\n constructor(error: ErrorLike, data: any = {}) {\n super('error', extend({error}, data));\n }\n}\n\n/**\n * Methods mixed in to other classes for event capabilities.\n *\n * @group Event Related\n */\nexport class Evented {\n _listeners: Listeners;\n _oneTimeListeners: Listeners;\n _eventedParent: Evented;\n _eventedParentData: any | (() => any);\n\n /**\n * Adds a listener to a specified event type.\n *\n * @param type - The event type to add a listen for.\n * @param listener - The function to be called when the event is fired.\n * The listener function is called with the data object passed to `fire`,\n * extended with `target` and `type` properties.\n * @returns `this`\n */\n on(type: string, listener: Listener): this {\n this._listeners = this._listeners || {};\n _addEventListener(type, listener, this._listeners);\n\n return this;\n }\n\n /**\n * Removes a previously registered event listener.\n *\n * @param type - The event type to remove listeners for.\n * @param listener - The listener function to remove.\n * @returns `this`\n */\n off(type: string, listener: Listener) {\n _removeEventListener(type, listener, this._listeners);\n _removeEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type.\n *\n * The listener will be called first time the event fires after the listener is registered.\n *\n * @param type - The event type to listen for.\n * @param listener - The function to be called when the event is fired the first time.\n * @returns `this` or a promise if a listener is not provided\n */\n once(type: string, listener?: Listener): this | Promise {\n if (!listener) {\n return new Promise((resolve) => this.once(type, resolve));\n }\n this._oneTimeListeners = this._oneTimeListeners || {};\n _addEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n fire(event: Event | string, properties?: any) {\n // Compatibility with (type: string, properties: Object) signature from previous versions.\n // See https://github.com/mapbox/mapbox-gl-js/issues/6522,\n // https://github.com/mapbox/mapbox-gl-draw/issues/766\n if (typeof event === 'string') {\n event = new Event(event, properties || {});\n }\n\n const type = event.type;\n\n if (this.listens(type)) {\n (event as any).target = this;\n\n // make sure adding or removing listeners inside other listeners won't cause an infinite loop\n const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];\n for (const listener of listeners) {\n listener.call(this, event);\n }\n\n const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];\n for (const listener of oneTimeListeners) {\n _removeEventListener(type, listener, this._oneTimeListeners);\n listener.call(this, event);\n }\n\n const parent = this._eventedParent;\n if (parent) {\n extend(\n event,\n typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData\n );\n parent.fire(event);\n }\n\n // To ensure that no error events are dropped, print them to the\n // console if they have no listeners.\n } else if (event instanceof ErrorEvent) {\n console.error(event.error);\n }\n\n return this;\n }\n\n /**\n * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.\n *\n * @param type - The event type\n * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise\n */\n listens(type: string): boolean {\n return (\n (this._listeners && this._listeners[type] && this._listeners[type].length > 0) ||\n (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) ||\n (this._eventedParent && this._eventedParent.listens(type))\n );\n }\n\n /**\n * Bubble all events fired by this instance of Evented to this parent instance of Evented.\n * @returns `this`\n */\n setEventedParent(parent?: Evented | null, data?: any | (() => any)) {\n this._eventedParent = parent;\n this._eventedParentData = data;\n\n return this;\n }\n}\n","import UnitBezier from '@mapbox/unitbezier';\n\nvar $version = 8;\nvar $root = {\n\tversion: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: [\n\t\t\t8\n\t\t]\n\t},\n\tname: {\n\t\ttype: \"string\"\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tcenter: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\"\n\t},\n\tzoom: {\n\t\ttype: \"number\"\n\t},\n\tbearing: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\"\n\t},\n\tpitch: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"degrees\"\n\t},\n\tlight: {\n\t\ttype: \"light\"\n\t},\n\tterrain: {\n\t\ttype: \"terrain\"\n\t},\n\tsources: {\n\t\trequired: true,\n\t\ttype: \"sources\"\n\t},\n\tsprite: {\n\t\ttype: \"sprite\"\n\t},\n\tglyphs: {\n\t\ttype: \"string\"\n\t},\n\ttransition: {\n\t\ttype: \"transition\"\n\t},\n\tlayers: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"layer\"\n\t}\n};\nvar sources = {\n\t\"*\": {\n\t\ttype: \"source\"\n\t}\n};\nvar source = [\n\t\"source_vector\",\n\t\"source_raster\",\n\t\"source_raster_dem\",\n\t\"source_geojson\",\n\t\"source_video\",\n\t\"source_image\"\n];\nvar source_vector = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvector: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\traster: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster_dem = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\t\"raster-dem\": {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tencoding: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tterrarium: {\n\t\t\t},\n\t\t\tmapbox: {\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"mapbox\"\n\t},\n\tredFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tblueFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tgreenFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tbaseShift: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_geojson = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tgeojson: {\n\t\t\t}\n\t\t}\n\t},\n\tdata: {\n\t\trequired: true,\n\t\ttype: \"*\"\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 18\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tbuffer: {\n\t\ttype: \"number\",\n\t\t\"default\": 128,\n\t\tmaximum: 512,\n\t\tminimum: 0\n\t},\n\tfilter: {\n\t\ttype: \"*\"\n\t},\n\ttolerance: {\n\t\ttype: \"number\",\n\t\t\"default\": 0.375\n\t},\n\tcluster: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tclusterRadius: {\n\t\ttype: \"number\",\n\t\t\"default\": 50,\n\t\tminimum: 0\n\t},\n\tclusterMaxZoom: {\n\t\ttype: \"number\"\n\t},\n\tclusterMinPoints: {\n\t\ttype: \"number\"\n\t},\n\tclusterProperties: {\n\t\ttype: \"*\"\n\t},\n\tlineMetrics: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tgenerateId: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t}\n};\nvar source_video = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvideo: {\n\t\t\t}\n\t\t}\n\t},\n\turls: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar source_image = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\timage: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\trequired: true,\n\t\ttype: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar layer = {\n\tid: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tfill: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\tsymbol: {\n\t\t\t},\n\t\t\tcircle: {\n\t\t\t},\n\t\t\theatmap: {\n\t\t\t},\n\t\t\t\"fill-extrusion\": {\n\t\t\t},\n\t\t\traster: {\n\t\t\t},\n\t\t\thillshade: {\n\t\t\t},\n\t\t\tbackground: {\n\t\t\t}\n\t\t},\n\t\trequired: true\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tsource: {\n\t\ttype: \"string\"\n\t},\n\t\"source-layer\": {\n\t\ttype: \"string\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tfilter: {\n\t\ttype: \"filter\"\n\t},\n\tlayout: {\n\t\ttype: \"layout\"\n\t},\n\tpaint: {\n\t\ttype: \"paint\"\n\t}\n};\nvar layout = [\n\t\"layout_fill\",\n\t\"layout_line\",\n\t\"layout_circle\",\n\t\"layout_heatmap\",\n\t\"layout_fill-extrusion\",\n\t\"layout_symbol\",\n\t\"layout_raster\",\n\t\"layout_hillshade\",\n\t\"layout_background\"\n];\nvar layout_background = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_fill = {\n\t\"fill-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_circle = {\n\t\"circle-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_heatmap = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_line = {\n\t\"line-cap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbutt: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tsquare: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"butt\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-join\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbevel: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tmiter: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"miter\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-miter-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"miter\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-round-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.05,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"round\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_symbol = {\n\t\"symbol-placement\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tpoint: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\t\"line-center\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"point\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 250,\n\t\tminimum: 1,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"symbol-placement\": \"line\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-avoid-edges\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"symbol-z-order\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\t\"viewport-y\": {\n\t\t\t},\n\t\t\tsource: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"!\": \"icon-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tunits: \"factor of the original icon size\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-text-fit\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\twidth: {\n\t\t\t},\n\t\t\theight: {\n\t\t\t},\n\t\t\tboth: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-text-fit-padding\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"icon-text-fit\": [\n\t\t\t\t\t\"both\",\n\t\t\t\t\t\"width\",\n\t\t\t\t\t\"height\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-image\": {\n\t\ttype: \"resolvedImage\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-padding\": {\n\t\ttype: \"padding\",\n\t\t\"default\": [\n\t\t\t2\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"icon-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\t\"viewport-glyph\": {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-field\": {\n\t\ttype: \"formatted\",\n\t\t\"default\": \"\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-font\": {\n\t\ttype: \"array\",\n\t\tvalue: \"string\",\n\t\t\"default\": [\n\t\t\t\"Open Sans Regular\",\n\t\t\t\"Arial Unicode MS Regular\"\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 16,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 10,\n\t\tminimum: 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-line-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.2,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-letter-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-justify\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-radial-offset\": {\n\t\ttype: \"number\",\n\t\tunits: \"ems\",\n\t\t\"default\": 0,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\t\"property-type\": \"data-driven\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t}\n\t},\n\t\"text-variable-anchor\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-variable-anchor-offset\": {\n\t\ttype: \"variableAnchorOffsetCollection\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-variable-anchor\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-angle\": {\n\t\ttype: \"number\",\n\t\t\"default\": 45,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-writing-mode\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\thorizontal: {\n\t\t\t},\n\t\t\tvertical: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-padding\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"text-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-transform\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\tuppercase: {\n\t\t\t},\n\t\t\tlowercase: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tunits: \"ems\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-radial-offset\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_raster = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_hillshade = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar filter = {\n\ttype: \"array\",\n\tvalue: \"*\"\n};\nvar filter_operator = {\n\ttype: \"enum\",\n\tvalues: {\n\t\t\"==\": {\n\t\t},\n\t\t\"!=\": {\n\t\t},\n\t\t\">\": {\n\t\t},\n\t\t\">=\": {\n\t\t},\n\t\t\"<\": {\n\t\t},\n\t\t\"<=\": {\n\t\t},\n\t\t\"in\": {\n\t\t},\n\t\t\"!in\": {\n\t\t},\n\t\tall: {\n\t\t},\n\t\tany: {\n\t\t},\n\t\tnone: {\n\t\t},\n\t\thas: {\n\t\t},\n\t\t\"!has\": {\n\t\t},\n\t\twithin: {\n\t\t}\n\t}\n};\nvar geometry_type = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tPoint: {\n\t\t},\n\t\tLineString: {\n\t\t},\n\t\tPolygon: {\n\t\t}\n\t}\n};\nvar function_stop = {\n\ttype: \"array\",\n\tminimum: 0,\n\tmaximum: 24,\n\tvalue: [\n\t\t\"number\",\n\t\t\"color\"\n\t],\n\tlength: 2\n};\nvar expression$1 = {\n\ttype: \"array\",\n\tvalue: \"*\",\n\tminimum: 1\n};\nvar light = {\n\tanchor: {\n\t\ttype: \"enum\",\n\t\t\"default\": \"viewport\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tposition: {\n\t\ttype: \"array\",\n\t\t\"default\": [\n\t\t\t1.15,\n\t\t\t210,\n\t\t\t30\n\t\t],\n\t\tlength: 3,\n\t\tvalue: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tcolor: {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\tintensity: {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar terrain = {\n\tsource: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\texaggeration: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\t\"default\": 1\n\t}\n};\nvar paint = [\n\t\"paint_fill\",\n\t\"paint_line\",\n\t\"paint_circle\",\n\t\"paint_heatmap\",\n\t\"paint_fill-extrusion\",\n\t\"paint_symbol\",\n\t\"paint_raster\",\n\t\"paint_hillshade\",\n\t\"paint_background\"\n];\nvar paint_fill = {\n\t\"fill-antialias\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-outline-color\": {\n\t\ttype: \"color\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fill-antialias\": true\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t}\n};\nvar paint_line = {\n\t\"line-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"line-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-gap-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-offset\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-dasharray\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"line widths\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"line-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-gradient\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-dasharray\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"geojson\",\n\t\t\t\thas: {\n\t\t\t\t\tlineMetrics: true\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"line-progress\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n};\nvar paint_circle = {\n\t\"circle-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 5,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"circle-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-scale\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-stroke-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t}\n};\nvar paint_heatmap = {\n\t\"heatmap-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 30,\n\t\tminimum: 1,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-weight\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-intensity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"heatmap-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": [\n\t\t\t\"interpolate\",\n\t\t\t[\n\t\t\t\t\"linear\"\n\t\t\t],\n\t\t\t[\n\t\t\t\t\"heatmap-density\"\n\t\t\t],\n\t\t\t0,\n\t\t\t\"rgba(0, 0, 255, 0)\",\n\t\t\t0.1,\n\t\t\t\"royalblue\",\n\t\t\t0.3,\n\t\t\t\"cyan\",\n\t\t\t0.5,\n\t\t\t\"lime\",\n\t\t\t0.7,\n\t\t\t\"yellow\",\n\t\t\t1,\n\t\t\t\"red\"\n\t\t],\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"heatmap-density\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t},\n\t\"heatmap-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_symbol = {\n\t\"icon-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"icon-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\toverridable: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"text-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_raster = {\n\t\"raster-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-hue-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\ttransition: true,\n\t\tunits: \"degrees\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-min\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-max\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-saturation\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-contrast\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-resampling\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tlinear: {\n\t\t\t},\n\t\t\tnearest: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"linear\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-fade-duration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\tunits: \"milliseconds\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_hillshade = {\n\t\"hillshade-illumination-direction\": {\n\t\ttype: \"number\",\n\t\t\"default\": 335,\n\t\tminimum: 0,\n\t\tmaximum: 359,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-exaggeration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-shadow-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-highlight-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#FFFFFF\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-accent-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_background = {\n\t\"background-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"background-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"background-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"background-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar transition = {\n\tduration: {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t},\n\tdelay: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t}\n};\nvar promoteId = {\n\t\"*\": {\n\t\ttype: \"string\"\n\t}\n};\nvar v8Spec = {\n\t$version: $version,\n\t$root: $root,\n\tsources: sources,\n\tsource: source,\n\tsource_vector: source_vector,\n\tsource_raster: source_raster,\n\tsource_raster_dem: source_raster_dem,\n\tsource_geojson: source_geojson,\n\tsource_video: source_video,\n\tsource_image: source_image,\n\tlayer: layer,\n\tlayout: layout,\n\tlayout_background: layout_background,\n\tlayout_fill: layout_fill,\n\tlayout_circle: layout_circle,\n\tlayout_heatmap: layout_heatmap,\n\t\"layout_fill-extrusion\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n},\n\tlayout_line: layout_line,\n\tlayout_symbol: layout_symbol,\n\tlayout_raster: layout_raster,\n\tlayout_hillshade: layout_hillshade,\n\tfilter: filter,\n\tfilter_operator: filter_operator,\n\tgeometry_type: geometry_type,\n\t\"function\": {\n\texpression: {\n\t\ttype: \"expression\"\n\t},\n\tstops: {\n\t\ttype: \"array\",\n\t\tvalue: \"function_stop\"\n\t},\n\tbase: {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0\n\t},\n\tproperty: {\n\t\ttype: \"string\",\n\t\t\"default\": \"$zoom\"\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tidentity: {\n\t\t\t},\n\t\t\texponential: {\n\t\t\t},\n\t\t\tinterval: {\n\t\t\t},\n\t\t\tcategorical: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"exponential\"\n\t},\n\tcolorSpace: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\trgb: {\n\t\t\t},\n\t\t\tlab: {\n\t\t\t},\n\t\t\thcl: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"rgb\"\n\t},\n\t\"default\": {\n\t\ttype: \"*\",\n\t\trequired: false\n\t}\n},\n\tfunction_stop: function_stop,\n\texpression: expression$1,\n\tlight: light,\n\tterrain: terrain,\n\tpaint: paint,\n\tpaint_fill: paint_fill,\n\t\"paint_fill-extrusion\": {\n\t\"fill-extrusion-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-extrusion-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-extrusion-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"fill-extrusion-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-base\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"fill-extrusion-height\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-vertical-gradient\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tpaint_line: paint_line,\n\tpaint_circle: paint_circle,\n\tpaint_heatmap: paint_heatmap,\n\tpaint_symbol: paint_symbol,\n\tpaint_raster: paint_raster,\n\tpaint_hillshade: paint_hillshade,\n\tpaint_background: paint_background,\n\ttransition: transition,\n\t\"property-type\": {\n\t\"data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded-data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"color-ramp\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"data-constant\": {\n\t\ttype: \"property-type\"\n\t},\n\tconstant: {\n\t\ttype: \"property-type\"\n\t}\n},\n\tpromoteId: promoteId\n};\n\nconst refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\n\nfunction deref(layer, parent) {\n const result = {};\n for (const k in layer) {\n if (k !== 'ref') {\n result[k] = layer[k];\n }\n }\n refProperties.forEach((k) => {\n if (k in parent) {\n result[k] = parent[k];\n }\n });\n return result;\n}\n/**\n * Given an array of layers, some of which may contain `ref` properties\n * whose value is the `id` of another property, return a new array where\n * such layers have been augmented with the 'type', 'source', etc. properties\n * from the parent layer, and the `ref` property has been removed.\n *\n * The input is not modified. The output may contain references to portions\n * of the input.\n *\n * @private\n * @param {Array} layers\n * @returns {Array}\n */\nfunction derefLayers(layers) {\n layers = layers.slice();\n const map = Object.create(null);\n for (let i = 0; i < layers.length; i++) {\n map[layers[i].id] = layers[i];\n }\n for (let i = 0; i < layers.length; i++) {\n if ('ref' in layers[i]) {\n layers[i] = deref(layers[i], map[layers[i].ref]);\n }\n }\n return layers;\n}\n\n/**\n * Deeply compares two object literals.\n *\n * @private\n */\nfunction deepEqual(a, b) {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object'))\n return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length)\n return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a === b;\n}\n\nconst operations = {\n /*\n * { command: 'setStyle', args: [stylesheet] }\n */\n setStyle: 'setStyle',\n /*\n * { command: 'addLayer', args: [layer, 'beforeLayerId'] }\n */\n addLayer: 'addLayer',\n /*\n * { command: 'removeLayer', args: ['layerId'] }\n */\n removeLayer: 'removeLayer',\n /*\n * { command: 'setPaintProperty', args: ['layerId', 'prop', value] }\n */\n setPaintProperty: 'setPaintProperty',\n /*\n * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }\n */\n setLayoutProperty: 'setLayoutProperty',\n /*\n * { command: 'setFilter', args: ['layerId', filter] }\n */\n setFilter: 'setFilter',\n /*\n * { command: 'addSource', args: ['sourceId', source] }\n */\n addSource: 'addSource',\n /*\n * { command: 'removeSource', args: ['sourceId'] }\n */\n removeSource: 'removeSource',\n /*\n * { command: 'setGeoJSONSourceData', args: ['sourceId', data] }\n */\n setGeoJSONSourceData: 'setGeoJSONSourceData',\n /*\n * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }\n */\n setLayerZoomRange: 'setLayerZoomRange',\n /*\n * { command: 'setLayerProperty', args: ['layerId', 'prop', value] }\n */\n setLayerProperty: 'setLayerProperty',\n /*\n * { command: 'setCenter', args: [[lon, lat]] }\n */\n setCenter: 'setCenter',\n /*\n * { command: 'setZoom', args: [zoom] }\n */\n setZoom: 'setZoom',\n /*\n * { command: 'setBearing', args: [bearing] }\n */\n setBearing: 'setBearing',\n /*\n * { command: 'setPitch', args: [pitch] }\n */\n setPitch: 'setPitch',\n /*\n * { command: 'setSprite', args: ['spriteUrl'] }\n */\n setSprite: 'setSprite',\n /*\n * { command: 'setGlyphs', args: ['glyphsUrl'] }\n */\n setGlyphs: 'setGlyphs',\n /*\n * { command: 'setTransition', args: [transition] }\n */\n setTransition: 'setTransition',\n /*\n * { command: 'setLighting', args: [lightProperties] }\n */\n setLight: 'setLight'\n};\nfunction addSource(sourceId, after, commands) {\n commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] });\n}\nfunction removeSource(sourceId, commands, sourcesRemoved) {\n commands.push({ command: operations.removeSource, args: [sourceId] });\n sourcesRemoved[sourceId] = true;\n}\nfunction updateSource(sourceId, after, commands, sourcesRemoved) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\nfunction canUpdateGeoJSON(before, after, sourceId) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\nfunction diffSources(before, after, commands, sourcesRemoved) {\n before = before || {};\n after = after || {};\n let sourceId;\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n }\n else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {\n commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] });\n }\n else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\nfunction diffLayerPropertyChanges(before, after, commands, layerId, klass, command) {\n before = before || {};\n after = after || {};\n let prop;\n for (prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n for (prop in after) {\n if (!Object.prototype.hasOwnProperty.call(after, prop) || Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n}\nfunction pluckId(layer) {\n return layer.id;\n}\nfunction indexById(group, layer) {\n group[layer.id] = layer;\n return group;\n}\nfunction diffLayers(before, after, commands) {\n before = before || [];\n after = after || [];\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;\n // remove layers\n for (i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.indexOf(layerId, d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n // add/reorder layers\n for (i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n if (tracker[tracker.length - 1 - i] === layerId)\n continue;\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n commands.push({ command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId] });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n // update layers\n for (i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer))\n continue;\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n commands.push({ command: operations.addLayer, args: [afterLayer, insertBeforeLayerId] });\n continue;\n }\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);\n diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n commands.push({ command: operations.setFilter, args: [layerId, afterLayer.filter] });\n }\n if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) || !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) {\n commands.push({ command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] });\n }\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n for (prop in afterLayer) {\n if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) || Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n }\n}\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nfunction diffStyles(before, after) {\n if (!before)\n return [{ command: operations.setStyle, args: [after] }];\n let commands = [];\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{ command: operations.setStyle, args: [after] }];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({ command: operations.setCenter, args: [after.center] });\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({ command: operations.setZoom, args: [after.zoom] });\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({ command: operations.setBearing, args: [after.bearing] });\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({ command: operations.setPitch, args: [after.pitch] });\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({ command: operations.setSprite, args: [after.sprite] });\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({ command: operations.setGlyphs, args: [after.glyphs] });\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({ command: operations.setTransition, args: [after.transition] });\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({ command: operations.setLight, args: [after.light] });\n }\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if (sourcesRemoved[layer.source]) {\n commands.push({ command: operations.removeLayer, args: [layer.id] });\n }\n else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n }\n catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{ command: operations.setStyle, args: [after] }];\n }\n return commands;\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ValidationError {\n constructor(key, value, message, identifier) {\n this.message = (key ? `${key}: ` : '') + message;\n if (identifier)\n this.identifier = identifier;\n if (value !== null && value !== undefined && value.__line__) {\n this.line = value.__line__;\n }\n }\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ParsingError {\n constructor(error) {\n this.error = error;\n this.message = error.message;\n const match = error.message.match(/line (\\d+)/);\n this.line = match ? parseInt(match[1], 10) : 0;\n }\n}\n\nfunction extendBy(output, ...inputs) {\n for (const input of inputs) {\n for (const k in input) {\n output[k] = input[k];\n }\n }\n return output;\n}\n\nclass ExpressionParsingError extends Error {\n constructor(key, message) {\n super(message);\n this.message = message;\n this.key = key;\n }\n}\n\n/**\n * Tracks `let` bindings during expression parsing.\n * @private\n */\nclass Scope {\n constructor(parent, bindings = []) {\n this.parent = parent;\n this.bindings = {};\n for (const [name, expression] of bindings) {\n this.bindings[name] = expression;\n }\n }\n concat(bindings) {\n return new Scope(this, bindings);\n }\n get(name) {\n if (this.bindings[name]) {\n return this.bindings[name];\n }\n if (this.parent) {\n return this.parent.get(name);\n }\n throw new Error(`${name} not found in scope.`);\n }\n has(name) {\n if (this.bindings[name])\n return true;\n return this.parent ? this.parent.has(name) : false;\n }\n}\n\nconst NullType = { kind: 'null' };\nconst NumberType = { kind: 'number' };\nconst StringType = { kind: 'string' };\nconst BooleanType = { kind: 'boolean' };\nconst ColorType = { kind: 'color' };\nconst ObjectType = { kind: 'object' };\nconst ValueType = { kind: 'value' };\nconst ErrorType = { kind: 'error' };\nconst CollatorType = { kind: 'collator' };\nconst FormattedType = { kind: 'formatted' };\nconst PaddingType = { kind: 'padding' };\nconst ResolvedImageType = { kind: 'resolvedImage' };\nconst VariableAnchorOffsetCollectionType = { kind: 'variableAnchorOffsetCollection' };\nfunction array$1(itemType, N) {\n return {\n kind: 'array',\n itemType,\n N\n };\n}\nfunction toString$1(type) {\n if (type.kind === 'array') {\n const itemType = toString$1(type.itemType);\n return typeof type.N === 'number' ?\n `array<${itemType}, ${type.N}>` :\n type.itemType.kind === 'value' ? 'array' : `array<${itemType}>`;\n }\n else {\n return type.kind;\n }\n}\nconst valueMemberTypes = [\n NullType,\n NumberType,\n StringType,\n BooleanType,\n ColorType,\n FormattedType,\n ObjectType,\n array$1(ValueType),\n PaddingType,\n ResolvedImageType,\n VariableAnchorOffsetCollectionType\n];\n/**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message.\n * @private\n */\nfunction checkSubtype(expected, t) {\n if (t.kind === 'error') {\n // Error is a subtype of every type\n return null;\n }\n else if (expected.kind === 'array') {\n if (t.kind === 'array' &&\n ((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) &&\n (typeof expected.N !== 'number' || expected.N === t.N)) {\n return null;\n }\n }\n else if (expected.kind === t.kind) {\n return null;\n }\n else if (expected.kind === 'value') {\n for (const memberType of valueMemberTypes) {\n if (!checkSubtype(memberType, t)) {\n return null;\n }\n }\n }\n return `Expected ${toString$1(expected)} but found ${toString$1(t)} instead.`;\n}\nfunction isValidType(provided, allowedTypes) {\n return allowedTypes.some(t => t.kind === provided.kind);\n}\nfunction isValidNativeType(provided, allowedTypes) {\n return allowedTypes.some(t => {\n if (t === 'null') {\n return provided === null;\n }\n else if (t === 'array') {\n return Array.isArray(provided);\n }\n else if (t === 'object') {\n return provided && !Array.isArray(provided) && typeof provided === 'object';\n }\n else {\n return t === typeof provided;\n }\n });\n}\n/**\n * Verify whether the specified type is of the same type as the specified sample.\n *\n * @param provided Type to verify\n * @param sample Sample type to reference\n * @returns `true` if both objects are of the same type, `false` otherwise\n * @example basic types\n * if (verifyType(outputType, ValueType)) {\n * // type narrowed to:\n * outputType.kind; // 'value'\n * }\n * @example array types\n * if (verifyType(outputType, array(NumberType))) {\n * // type narrowed to:\n * outputType.kind; // 'array'\n * outputType.itemType; // NumberTypeT\n * outputType.itemType.kind; // 'number'\n * }\n */\nfunction verifyType(provided, sample) {\n if (provided.kind === 'array' && sample.kind === 'array') {\n return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number';\n }\n return provided.kind === sample.kind;\n}\n\n// See https://observablehq.com/@mbostock/lab-and-rgb\nconst Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;\nfunction constrainAngle(angle) {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\nfunction rgbToLab([r, g, b, alpha]) {\n r = rgb2xyz(r);\n g = rgb2xyz(g);\n b = rgb2xyz(b);\n let x, z;\n const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn);\n if (r === g && g === b) {\n x = z = y;\n }\n else {\n x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);\n z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);\n }\n const l = 116 * y - 16;\n return [(l < 0) ? 0 : l, 500 * (x - y), 200 * (y - z), alpha];\n}\nfunction rgb2xyz(x) {\n return (x <= 0.04045) ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);\n}\nfunction xyz2lab(t) {\n return (t > t3) ? Math.pow(t, 1 / 3) : t / t2 + t0;\n}\nfunction labToRgb([l, a, b, alpha]) {\n let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200;\n y = Yn * lab2xyz(y);\n x = Xn * lab2xyz(x);\n z = Zn * lab2xyz(z);\n return [\n xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z),\n xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),\n xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),\n alpha,\n ];\n}\nfunction xyz2rgb(x) {\n x = (x <= 0.00304) ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;\n return (x < 0) ? 0 : (x > 1) ? 1 : x; // clip to 0..1 range\n}\nfunction lab2xyz(t) {\n return (t > t1) ? t * t * t : t2 * (t - t0);\n}\nfunction rgbToHcl(rgbColor) {\n const [l, a, b, alpha] = rgbToLab(rgbColor);\n const c = Math.sqrt(a * a + b * b);\n const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN;\n return [h, c, l, alpha];\n}\nfunction hclToRgb([h, c, l, alpha]) {\n h = isNaN(h) ? 0 : h * deg2rad;\n return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]);\n}\n// https://drafts.csswg.org/css-color-4/#hsl-to-rgb\nfunction hslToRgb([h, s, l, alpha]) {\n h = constrainAngle(h);\n s /= 100;\n l /= 100;\n function f(n) {\n const k = (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n return [f(0), f(8), f(4), alpha];\n}\n\n/**\n * CSS color parser compliant with CSS Color 4 Specification.\n * Supports: named colors, `transparent` keyword, all rgb hex notations,\n * rgb(), rgba(), hsl() and hsla() functions.\n * Does not round the parsed values to integers from the range 0..255.\n *\n * Syntax:\n *\n * = | \n * = | \n *\n * rgb() = rgb( {3} [ / ]? ) | rgb( {3} [ / ]? )\n * rgb() = rgb( #{3} , ? ) | rgb( #{3} , ? )\n *\n * hsl() = hsl( [ / ]? )\n * hsl() = hsl( , , , ? )\n *\n * Caveats:\n * - - with optional `deg` suffix; `grad`, `rad`, `turn` are not supported\n * - `none` keyword is not supported\n * - comments inside rgb()/hsl() are not supported\n * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb()\n * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl()\n *\n * @param input CSS color string to parse.\n * @returns Color in sRGB color space, with `red`, `green`, `blue`\n * and `alpha` channels normalized to the range 0..1,\n * or `undefined` if the input is not a valid color string.\n */\nfunction parseCssColor(input) {\n input = input.toLowerCase().trim();\n if (input === 'transparent') {\n return [0, 0, 0, 0];\n }\n // 'white', 'black', 'blue'\n const namedColorsMatch = namedColors[input];\n if (namedColorsMatch) {\n const [r, g, b] = namedColorsMatch;\n return [r / 255, g / 255, b / 255, 1];\n }\n // #f0c, #f0cf, #ff00cc, #ff00ccff\n if (input.startsWith('#')) {\n const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n if (hexRegexp.test(input)) {\n const step = input.length < 6 ? 1 : 2;\n let i = 1;\n return [\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i + step) || 'ff'),\n ];\n }\n }\n // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6)\n if (input.startsWith('rgb')) {\n const rgbRegExp = /^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const rgbMatch = input.match(rgbRegExp);\n if (rgbMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n r, // \n rp, // % (optional)\n f1, // , (optional)\n g, // \n gp, // % (optional)\n f2, // , (optional)\n b, // \n bp, // % (optional)\n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = rgbMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const valFormat = [rp, gp, bp].join('');\n const maxValue = (valFormat === '%%%') ? 100 :\n (valFormat === '') ? 255 : 0;\n if (maxValue) {\n const rgba = [\n clamp(+r / maxValue, 0, 1),\n clamp(+g / maxValue, 0, 1),\n clamp(+b / maxValue, 0, 1),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(rgba)) {\n return rgba;\n }\n // invalid numbers\n }\n // values must be all numbers or all percentages\n }\n return; // comma optional syntax requires no commas at all\n }\n }\n // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%)\n const hslRegExp = /^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const hslMatch = input.match(hslRegExp);\n if (hslMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n h, // \n f1, // , (optional)\n s, // \n f2, // , (optional)\n l, // \n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = hslMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const hsla = [\n +h,\n clamp(+s, 0, 100),\n clamp(+l, 0, 100),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(hsla)) {\n return hslToRgb(hsla);\n }\n // invalid numbers\n }\n // comma optional syntax requires no commas at all\n }\n}\nfunction parseHex(hex) {\n return parseInt(hex.padEnd(2, hex), 16) / 255;\n}\nfunction parseAlpha(a, asPercentage) {\n return clamp(asPercentage ? (a / 100) : a, 0, 1);\n}\nfunction clamp(n, min, max) {\n return Math.min(Math.max(min, n), max);\n}\n/**\n * The regular expression for numeric values is not super specific, and it may\n * happen that it will accept a value that is not a valid number. In order to\n * detect and eliminate such values this function exists.\n *\n * @param array Array of uncertain numbers.\n * @returns `true` if the specified array contains only valid numbers, `false` otherwise.\n */\nfunction validateNumbers(array) {\n return !array.some(Number.isNaN);\n}\n/**\n * To generate:\n * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors}\n * - run in the console:\n * @example\n * copy(`{\\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\\s+/).join(', ')}],`).join('\\n')}\\n}`);\n */\nconst namedColors = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n\n/**\n * Color representation used by WebGL.\n * Defined in sRGB color space and pre-blended with alpha.\n * @private\n */\nclass Color {\n /**\n * @param r Red component premultiplied by `alpha` 0..1\n * @param g Green component premultiplied by `alpha` 0..1\n * @param b Blue component premultiplied by `alpha` 0..1\n * @param [alpha=1] Alpha component 0..1\n * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already\n * been multiplied by alpha. If `true` nothing happens if `false` then they will\n * be multiplied automatically.\n */\n constructor(r, g, b, alpha = 1, premultiplied = true) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = alpha;\n if (!premultiplied) {\n this.r *= alpha;\n this.g *= alpha;\n this.b *= alpha;\n if (!alpha) {\n // alpha = 0 erases completely rgb channels. This behavior is not desirable\n // if this particular color is later used in color interpolation.\n // Because of that, a reference to original color is saved.\n this.overwriteGetter('rgb', [r, g, b, alpha]);\n }\n }\n }\n /**\n * Parses CSS color strings and converts colors to sRGB color space if needed.\n * Officially supported color formats:\n * - keyword, e.g. 'aquamarine' or 'steelblue'\n * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'\n * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'\n * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'\n *\n * @param input CSS color string to parse.\n * @returns A `Color` instance, or `undefined` if the input is not a valid color string.\n */\n static parse(input) {\n // in zoom-and-property function input could be an instance of Color class\n if (input instanceof Color) {\n return input;\n }\n if (typeof input !== 'string') {\n return;\n }\n const rgba = parseCssColor(input);\n if (rgba) {\n return new Color(...rgba, false);\n }\n }\n /**\n * Used in color interpolation and by 'to-rgba' expression.\n *\n * @returns Gien color, with reversed alpha blending, in sRGB color space.\n */\n get rgb() {\n const { r, g, b, a } = this;\n const f = a || Infinity; // reverse alpha blending factor\n return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]);\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in HCL color space.\n */\n get hcl() {\n return this.overwriteGetter('hcl', rgbToHcl(this.rgb));\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in LAB color space.\n */\n get lab() {\n return this.overwriteGetter('lab', rgbToLab(this.rgb));\n }\n /**\n * Lazy getter pattern. When getter is called for the first time lazy value\n * is calculated and then overwrites getter function in given object instance.\n *\n * @example:\n * const redColor = Color.parse('red');\n * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate\n * // the value of red in HCL space and invoke this `overwriteGetter` function\n * // which in turn will set a field with a key 'hcl' in the `redColor` object.\n * // In other words it will override `get hcl()` from its `Color` prototype\n * // with its own property: hcl = [calculated red value in hcl].\n * let y = redColor.hcl; // next call will no longer invoke getter but simply\n * // return the previously calculated value\n * x === y; // true - `x` is exactly the same object as `y`\n *\n * @param getterKey Getter key\n * @param lazyValue Lazily calculated value to be memoized by current instance\n * @private\n */\n overwriteGetter(getterKey, lazyValue) {\n Object.defineProperty(this, getterKey, { value: lazyValue });\n return lazyValue;\n }\n /**\n * Used by 'to-string' expression.\n *\n * @returns Serialized color in format `rgba(r,g,b,a)`\n * where r,g,b are numbers within 0..255 and alpha is number within 1..0\n *\n * @example\n * var purple = new Color.parse('purple');\n * purple.toString; // = \"rgba(128,0,128,1)\"\n * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');\n * translucentGreen.toString(); // = \"rgba(26,207,26,0.73)\"\n */\n toString() {\n const [r, g, b, a] = this.rgb;\n return `rgba(${[r, g, b].map(n => Math.round(n * 255)).join(',')},${a})`;\n }\n}\nColor.black = new Color(0, 0, 0, 1);\nColor.white = new Color(1, 1, 1, 1);\nColor.transparent = new Color(0, 0, 0, 0);\nColor.red = new Color(1, 0, 0, 1);\n\n// Flow type declarations for Intl cribbed from\n// https://github.com/facebook/flow/issues/1270\nclass Collator {\n constructor(caseSensitive, diacriticSensitive, locale) {\n if (caseSensitive)\n this.sensitivity = diacriticSensitive ? 'variant' : 'case';\n else\n this.sensitivity = diacriticSensitive ? 'accent' : 'base';\n this.locale = locale;\n this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: 'search' });\n }\n compare(lhs, rhs) {\n return this.collator.compare(lhs, rhs);\n }\n resolvedLocale() {\n // We create a Collator without \"usage: search\" because we don't want\n // the search options encoded in our result (e.g. \"en-u-co-search\")\n return new Intl.Collator(this.locale ? this.locale : [])\n .resolvedOptions().locale;\n }\n}\n\nclass FormattedSection {\n constructor(text, image, scale, fontStack, textColor) {\n this.text = text;\n this.image = image;\n this.scale = scale;\n this.fontStack = fontStack;\n this.textColor = textColor;\n }\n}\nclass Formatted {\n constructor(sections) {\n this.sections = sections;\n }\n static fromString(unformatted) {\n return new Formatted([new FormattedSection(unformatted, null, null, null, null)]);\n }\n isEmpty() {\n if (this.sections.length === 0)\n return true;\n return !this.sections.some(section => section.text.length !== 0 ||\n (section.image && section.image.name.length !== 0));\n }\n static factory(text) {\n if (text instanceof Formatted) {\n return text;\n }\n else {\n return Formatted.fromString(text);\n }\n }\n toString() {\n if (this.sections.length === 0)\n return '';\n return this.sections.map(section => section.text).join('');\n }\n}\n\n/**\n * A set of four numbers representing padding around a box. Create instances from\n * bare arrays or numeric values using the static method `Padding.parse`.\n * @private\n */\nclass Padding {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric padding values\n * @param input A padding value\n * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value.\n */\n static parse(input) {\n if (input instanceof Padding) {\n return input;\n }\n // Backwards compatibility: bare number is treated the same as array with single value.\n // Padding applies to all four sides.\n if (typeof input === 'number') {\n return new Padding([input, input, input, input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n if (input.length < 1 || input.length > 4) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n // Expand shortcut properties into explicit 4-sided values\n switch (input.length) {\n case 1:\n input = [input[0], input[0], input[0], input[0]];\n break;\n case 2:\n input = [input[0], input[1], input[0], input[1]];\n break;\n case 3:\n input = [input[0], input[1], input[2], input[1]];\n break;\n }\n return new Padding(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\n/** Set of valid anchor positions, as a set for validation */\nconst anchors = new Set(['center', 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right']);\n/**\n * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from\n * bare arrays using the static method `VariableAnchorOffsetCollection.parse`.\n * @private\n */\nclass VariableAnchorOffsetCollection {\n constructor(values) {\n this.values = values.slice();\n }\n static parse(input) {\n if (input instanceof VariableAnchorOffsetCollection) {\n return input;\n }\n if (!Array.isArray(input) ||\n input.length < 1 ||\n input.length % 2 !== 0) {\n return undefined;\n }\n for (let i = 0; i < input.length; i += 2) {\n // Elements in even positions should be anchor positions; Elements in odd positions should be offset values\n const anchorValue = input[i];\n const offsetValue = input[i + 1];\n if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) {\n return undefined;\n }\n if (!Array.isArray(offsetValue) || offsetValue.length !== 2 || typeof offsetValue[0] !== 'number' || typeof offsetValue[1] !== 'number') {\n return undefined;\n }\n }\n return new VariableAnchorOffsetCollection(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\nclass ResolvedImage {\n constructor(options) {\n this.name = options.name;\n this.available = options.available;\n }\n toString() {\n return this.name;\n }\n static fromString(name) {\n if (!name)\n return null; // treat empty values as no image\n return new ResolvedImage({ name, available: false });\n }\n}\n\nfunction validateRGBA(r, g, b, a) {\n if (!(typeof r === 'number' && r >= 0 && r <= 255 &&\n typeof g === 'number' && g >= 0 && g <= 255 &&\n typeof b === 'number' && b >= 0 && b <= 255)) {\n const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];\n return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;\n }\n if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) {\n return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;\n }\n return null;\n}\nfunction isValue(mixed) {\n if (mixed === null ||\n typeof mixed === 'string' ||\n typeof mixed === 'boolean' ||\n typeof mixed === 'number' ||\n mixed instanceof Color ||\n mixed instanceof Collator ||\n mixed instanceof Formatted ||\n mixed instanceof Padding ||\n mixed instanceof VariableAnchorOffsetCollection ||\n mixed instanceof ResolvedImage) {\n return true;\n }\n else if (Array.isArray(mixed)) {\n for (const item of mixed) {\n if (!isValue(item)) {\n return false;\n }\n }\n return true;\n }\n else if (typeof mixed === 'object') {\n for (const key in mixed) {\n if (!isValue(mixed[key])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\nfunction typeOf(value) {\n if (value === null) {\n return NullType;\n }\n else if (typeof value === 'string') {\n return StringType;\n }\n else if (typeof value === 'boolean') {\n return BooleanType;\n }\n else if (typeof value === 'number') {\n return NumberType;\n }\n else if (value instanceof Color) {\n return ColorType;\n }\n else if (value instanceof Collator) {\n return CollatorType;\n }\n else if (value instanceof Formatted) {\n return FormattedType;\n }\n else if (value instanceof Padding) {\n return PaddingType;\n }\n else if (value instanceof VariableAnchorOffsetCollection) {\n return VariableAnchorOffsetCollectionType;\n }\n else if (value instanceof ResolvedImage) {\n return ResolvedImageType;\n }\n else if (Array.isArray(value)) {\n const length = value.length;\n let itemType;\n for (const item of value) {\n const t = typeOf(item);\n if (!itemType) {\n itemType = t;\n }\n else if (itemType === t) {\n continue;\n }\n else {\n itemType = ValueType;\n break;\n }\n }\n return array$1(itemType || ValueType, length);\n }\n else {\n return ObjectType;\n }\n}\nfunction toString(value) {\n const type = typeof value;\n if (value === null) {\n return '';\n }\n else if (type === 'string' || type === 'number' || type === 'boolean') {\n return String(value);\n }\n else if (value instanceof Color || value instanceof Formatted || value instanceof Padding || value instanceof VariableAnchorOffsetCollection || value instanceof ResolvedImage) {\n return value.toString();\n }\n else {\n return JSON.stringify(value);\n }\n}\n\nclass Literal {\n constructor(type, value) {\n this.type = type;\n this.value = value;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (!isValue(args[1]))\n return context.error('invalid value');\n const value = args[1];\n let type = typeOf(value);\n // special case: infer the item type if possible for zero-length arrays\n const expected = context.expectedType;\n if (type.kind === 'array' &&\n type.N === 0 &&\n expected &&\n expected.kind === 'array' &&\n (typeof expected.N !== 'number' || expected.N === 0)) {\n type = expected;\n }\n return new Literal(type, value);\n }\n evaluate() {\n return this.value;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass RuntimeError {\n constructor(message) {\n this.name = 'ExpressionEvaluationError';\n this.message = message;\n }\n toJSON() {\n return this.message;\n }\n}\n\nconst types$1 = {\n string: StringType,\n number: NumberType,\n boolean: BooleanType,\n object: ObjectType\n};\nclass Assertion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n let i = 1;\n let type;\n const name = args[0];\n if (name === 'array') {\n let itemType;\n if (args.length > 2) {\n const type = args[1];\n if (typeof type !== 'string' || !(type in types$1) || type === 'object')\n return context.error('The item type argument of \"array\" must be one of string, number, boolean', 1);\n itemType = types$1[type];\n i++;\n }\n else {\n itemType = ValueType;\n }\n let N;\n if (args.length > 3) {\n if (args[2] !== null &&\n (typeof args[2] !== 'number' ||\n args[2] < 0 ||\n args[2] !== Math.floor(args[2]))) {\n return context.error('The length argument to \"array\" must be a positive integer literal', 2);\n }\n N = args[2];\n i++;\n }\n type = array$1(itemType, N);\n }\n else {\n if (!types$1[name])\n throw new Error(`Types doesn't contain name = ${name}`);\n type = types$1[name];\n }\n const parsed = [];\n for (; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Assertion(type, parsed);\n }\n evaluate(ctx) {\n for (let i = 0; i < this.args.length; i++) {\n const value = this.args[i].evaluate(ctx);\n const error = checkSubtype(this.type, typeOf(value));\n if (!error) {\n return value;\n }\n else if (i === this.args.length - 1) {\n throw new RuntimeError(`Expected value to be of type ${toString$1(this.type)}, but found ${toString$1(typeOf(value))} instead.`);\n }\n }\n throw new Error();\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst types = {\n 'to-boolean': BooleanType,\n 'to-color': ColorType,\n 'to-number': NumberType,\n 'to-string': StringType\n};\n/**\n * Special form for error-coalescing coercion expressions \"to-number\",\n * \"to-color\". Since these coercions can fail at runtime, they accept multiple\n * arguments, only evaluating one at a time until one succeeds.\n *\n * @private\n */\nclass Coercion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n const name = args[0];\n if (!types[name])\n throw new Error(`Can't parse ${name} as it is not part of the known types`);\n if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2)\n return context.error('Expected one argument.');\n const type = types[name];\n const parsed = [];\n for (let i = 1; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Coercion(type, parsed);\n }\n evaluate(ctx) {\n switch (this.type.kind) {\n case 'boolean':\n return Boolean(this.args[0].evaluate(ctx));\n case 'color': {\n let input;\n let error;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n error = null;\n if (input instanceof Color) {\n return input;\n }\n else if (typeof input === 'string') {\n const c = ctx.parseColor(input);\n if (c)\n return c;\n }\n else if (Array.isArray(input)) {\n if (input.length < 3 || input.length > 4) {\n error = `Invalid rbga value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`;\n }\n else {\n error = validateRGBA(input[0], input[1], input[2], input[3]);\n }\n if (!error) {\n return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);\n }\n }\n }\n throw new RuntimeError(error || `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'padding': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const pad = Padding.parse(input);\n if (pad) {\n return pad;\n }\n }\n throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'variableAnchorOffsetCollection': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const coll = VariableAnchorOffsetCollection.parse(input);\n if (coll) {\n return coll;\n }\n }\n throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'number': {\n let value = null;\n for (const arg of this.args) {\n value = arg.evaluate(ctx);\n if (value === null)\n return 0;\n const num = Number(value);\n if (isNaN(num))\n continue;\n return num;\n }\n throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`);\n }\n case 'formatted':\n // There is no explicit 'to-formatted' but this coercion can be implicitly\n // created by properties that expect the 'formatted' type.\n return Formatted.fromString(toString(this.args[0].evaluate(ctx)));\n case 'resolvedImage':\n return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx)));\n default:\n return toString(this.args[0].evaluate(ctx));\n }\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\nclass EvaluationContext {\n constructor() {\n this.globals = null;\n this.feature = null;\n this.featureState = null;\n this.formattedSection = null;\n this._parseColorCache = {};\n this.availableImages = null;\n this.canonical = null;\n }\n id() {\n return this.feature && 'id' in this.feature ? this.feature.id : null;\n }\n geometryType() {\n return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;\n }\n geometry() {\n return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n }\n canonicalID() {\n return this.canonical;\n }\n properties() {\n return this.feature && this.feature.properties || {};\n }\n parseColor(input) {\n let cached = this._parseColorCache[input];\n if (!cached) {\n cached = this._parseColorCache[input] = Color.parse(input);\n }\n return cached;\n }\n}\n\n/**\n * State associated parsing at a given point in an expression tree.\n * @private\n */\nclass ParsingContext {\n constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) {\n this.registry = registry;\n this.path = path;\n this.key = path.map(part => `[${part}]`).join('');\n this.scope = scope;\n this.errors = errors;\n this.expectedType = expectedType;\n this._isConstant = isConstantFunc;\n }\n /**\n * @param expr the JSON expression to parse\n * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed\n * @param options\n * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.\n * @private\n */\n parse(expr, index, expectedType, bindings, options = {}) {\n if (index) {\n return this.concat(index, expectedType, bindings)._parse(expr, options);\n }\n return this._parse(expr, options);\n }\n _parse(expr, options) {\n if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {\n expr = ['literal', expr];\n }\n function annotate(parsed, type, typeAnnotation) {\n if (typeAnnotation === 'assert') {\n return new Assertion(type, [parsed]);\n }\n else if (typeAnnotation === 'coerce') {\n return new Coercion(type, [parsed]);\n }\n else {\n return parsed;\n }\n }\n if (Array.isArray(expr)) {\n if (expr.length === 0) {\n return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');\n }\n const op = expr[0];\n if (typeof op !== 'string') {\n this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use [\"literal\", [...]].`, 0);\n return null;\n }\n const Expr = this.registry[op];\n if (Expr) {\n let parsed = Expr.parse(expr, this);\n if (!parsed)\n return null;\n if (this.expectedType) {\n const expected = this.expectedType;\n const actual = parsed.type;\n // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.\n // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.\n // Otherwise, we do static type-checking.\n //\n // These behaviors are overridable for:\n // * The \"coalesce\" operator, which needs to omit type annotations.\n // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.\n //\n if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');\n }\n else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'padding' && (actual.kind === 'value' || actual.kind === 'number' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'variableAnchorOffsetCollection' && (actual.kind === 'value' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (this.checkSubtype(expected, actual)) {\n return null;\n }\n }\n // If an expression's arguments are all literals, we can evaluate\n // it immediately and replace it with a literal value in the\n // parsed/compiled result. Expressions that expect an image should\n // not be resolved here so we can later get the available images.\n if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && this._isConstant(parsed)) {\n const ec = new EvaluationContext();\n try {\n parsed = new Literal(parsed.type, parsed.evaluate(ec));\n }\n catch (e) {\n this.error(e.message);\n return null;\n }\n }\n return parsed;\n }\n return this.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n else if (typeof expr === 'undefined') {\n return this.error('\\'undefined\\' value invalid. Use null instead.');\n }\n else if (typeof expr === 'object') {\n return this.error('Bare objects invalid. Use [\"literal\", {...}] instead.');\n }\n else {\n return this.error(`Expected an array, but found ${typeof expr} instead.`);\n }\n }\n /**\n * Returns a copy of this context suitable for parsing the subexpression at\n * index `index`, optionally appending to 'let' binding map.\n *\n * Note that `errors` property, intended for collecting errors while\n * parsing, is copied by reference rather than cloned.\n * @private\n */\n concat(index, expectedType, bindings) {\n const path = typeof index === 'number' ? this.path.concat(index) : this.path;\n const scope = bindings ? this.scope.concat(bindings) : this.scope;\n return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors);\n }\n /**\n * Push a parsing (or type checking) error into the `this.errors`\n * @param error The message\n * @param keys Optionally specify the source of the error at a child\n * of the current expression at `this.key`.\n * @private\n */\n error(error, ...keys) {\n const key = `${this.key}${keys.map(k => `[${k}]`).join('')}`;\n this.errors.push(new ExpressionParsingError(key, error));\n }\n /**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message and also pushes it to `this.errors`.\n * @param expected The expected type\n * @param t The actual type\n * @returns null if `t` is a subtype of `expected`; otherwise returns an error message\n */\n checkSubtype(expected, t) {\n const error = checkSubtype(expected, t);\n if (error)\n this.error(error);\n return error;\n }\n}\n\nclass CollatorExpression {\n constructor(caseSensitive, diacriticSensitive, locale) {\n this.type = CollatorType;\n this.locale = locale;\n this.caseSensitive = caseSensitive;\n this.diacriticSensitive = diacriticSensitive;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error('Expected one argument.');\n const options = args[1];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('Collator options argument must be an object.');\n const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);\n if (!caseSensitive)\n return null;\n const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);\n if (!diacriticSensitive)\n return null;\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n return new CollatorExpression(caseSensitive, diacriticSensitive, locale);\n }\n evaluate(ctx) {\n return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);\n }\n eachChild(fn) {\n fn(this.caseSensitive);\n fn(this.diacriticSensitive);\n if (this.locale) {\n fn(this.locale);\n }\n }\n outputDefined() {\n // Technically the set of possible outputs is the combinatoric set of Collators produced\n // by all possible outputs of locale/caseSensitive/diacriticSensitive\n // But for the primary use of Collators in comparison operators, we ignore the Collator's\n // possible outputs anyway, so we can get away with leaving this false for now.\n return false;\n }\n}\n\nconst EXTENT = 8192;\nfunction updateBBox(bbox, coord) {\n bbox[0] = Math.min(bbox[0], coord[0]);\n bbox[1] = Math.min(bbox[1], coord[1]);\n bbox[2] = Math.max(bbox[2], coord[0]);\n bbox[3] = Math.max(bbox[3], coord[1]);\n}\nfunction mercatorXfromLng(lng) {\n return (180 + lng) / 360;\n}\nfunction mercatorYfromLat(lat) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\nfunction boxWithinBox(bbox1, bbox2) {\n if (bbox1[0] <= bbox2[0])\n return false;\n if (bbox1[2] >= bbox2[2])\n return false;\n if (bbox1[1] <= bbox2[1])\n return false;\n if (bbox1[3] >= bbox2[3])\n return false;\n return true;\n}\nfunction getTileCoordinates(p, canonical) {\n const x = mercatorXfromLng(p[0]);\n const y = mercatorYfromLat(p[1]);\n const tilesAtZoom = Math.pow(2, canonical.z);\n return [Math.round(x * tilesAtZoom * EXTENT), Math.round(y * tilesAtZoom * EXTENT)];\n}\nfunction onBoundary(p, p1, p2) {\n const x1 = p[0] - p1[0];\n const y1 = p[1] - p1[1];\n const x2 = p[0] - p2[0];\n const y2 = p[1] - p2[1];\n return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);\n}\nfunction rayIntersect(p, p1, p2) {\n return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]);\n}\n// ray casting algorithm for detecting if point is in polygon\nfunction pointWithinPolygon(point, rings) {\n let inside = false;\n for (let i = 0, len = rings.length; i < len; i++) {\n const ring = rings[i];\n for (let j = 0, len2 = ring.length; j < len2 - 1; j++) {\n if (onBoundary(point, ring[j], ring[j + 1]))\n return false;\n if (rayIntersect(point, ring[j], ring[j + 1]))\n inside = !inside;\n }\n }\n return inside;\n}\nfunction pointWithinPolygons(point, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (pointWithinPolygon(point, polygons[i]))\n return true;\n }\n return false;\n}\nfunction perp(v1, v2) {\n return (v1[0] * v2[1] - v1[1] * v2[0]);\n}\n// check if p1 and p2 are in different sides of line segment q1->q2\nfunction twoSided(p1, p2, q1, q2) {\n // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)\n const x1 = p1[0] - q1[0];\n const y1 = p1[1] - q1[1];\n const x2 = p2[0] - q1[0];\n const y2 = p2[1] - q1[1];\n const x3 = q2[0] - q1[0];\n const y3 = q2[1] - q1[1];\n const det1 = (x1 * y3 - x3 * y1);\n const det2 = (x2 * y3 - x3 * y2);\n if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0))\n return true;\n return false;\n}\n// a, b are end points for line segment1, c and d are end points for line segment2\nfunction lineIntersectLine(a, b, c, d) {\n // check if two segments are parallel or not\n // precondition is end point a, b is inside polygon, if line a->b is\n // parallel to polygon edge c->d, then a->b won't intersect with c->d\n const vectorP = [b[0] - a[0], b[1] - a[1]];\n const vectorQ = [d[0] - c[0], d[1] - c[1]];\n if (perp(vectorQ, vectorP) === 0)\n return false;\n // If lines are intersecting with each other, the relative location should be:\n // a and b lie in different sides of segment c->d\n // c and d lie in different sides of segment a->b\n if (twoSided(a, b, c, d) && twoSided(c, d, a, b))\n return true;\n return false;\n}\nfunction lineIntersectPolygon(p1, p2, polygon) {\n for (const ring of polygon) {\n // loop through every edge of the ring\n for (let j = 0; j < ring.length - 1; ++j) {\n if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) {\n return true;\n }\n }\n }\n return false;\n}\nfunction lineStringWithinPolygon(line, polygon) {\n // First, check if geometry points of line segments are all inside polygon\n for (let i = 0; i < line.length; ++i) {\n if (!pointWithinPolygon(line[i], polygon)) {\n return false;\n }\n }\n // Second, check if there is line segment intersecting polygon edge\n for (let i = 0; i < line.length - 1; ++i) {\n if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {\n return false;\n }\n }\n return true;\n}\nfunction lineStringWithinPolygons(line, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (lineStringWithinPolygon(line, polygons[i]))\n return true;\n }\n return false;\n}\nfunction getTilePolygon(coordinates, bbox, canonical) {\n const polygon = [];\n for (let i = 0; i < coordinates.length; i++) {\n const ring = [];\n for (let j = 0; j < coordinates[i].length; j++) {\n const coord = getTileCoordinates(coordinates[i][j], canonical);\n updateBBox(bbox, coord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n return polygon;\n}\nfunction getTilePolygons(coordinates, bbox, canonical) {\n const polygons = [];\n for (let i = 0; i < coordinates.length; i++) {\n const polygon = getTilePolygon(coordinates[i], bbox, canonical);\n polygons.push(polygon);\n }\n return polygons;\n}\nfunction updatePoint(p, bbox, polyBBox, worldSize) {\n if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {\n const halfWorldSize = worldSize * 0.5;\n let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0;\n if (shift === 0) {\n shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0;\n }\n p[0] += shift;\n }\n updateBBox(bbox, p);\n}\nfunction resetBBox(bbox) {\n bbox[0] = bbox[1] = Infinity;\n bbox[2] = bbox[3] = -Infinity;\n}\nfunction getTilePoints(geometry, pointBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tilePoints = [];\n for (const points of geometry) {\n for (const point of points) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updatePoint(p, pointBBox, polyBBox, worldSize);\n tilePoints.push(p);\n }\n }\n return tilePoints;\n}\nfunction getTileLines(geometry, lineBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tileLines = [];\n for (const line of geometry) {\n const tileLine = [];\n for (const point of line) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updateBBox(lineBBox, p);\n tileLine.push(p);\n }\n tileLines.push(tileLine);\n }\n if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {\n resetBBox(lineBBox);\n for (const line of tileLines) {\n for (const p of line) {\n updatePoint(p, lineBBox, polyBBox, worldSize);\n }\n }\n }\n return tileLines;\n}\nfunction pointsWithinPolygons(ctx, polygonGeometry) {\n const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygon(point, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygons(point, tilePolygons))\n return false;\n }\n }\n return true;\n}\nfunction linesWithinPolygons(ctx, polygonGeometry) {\n const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygon(line, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygons(line, tilePolygons))\n return false;\n }\n }\n return true;\n}\nclass Within {\n constructor(geojson, geometries) {\n this.type = BooleanType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n for (let i = 0; i < geojson.features.length; ++i) {\n const type = geojson.features[i].geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.features[i].geometry);\n }\n }\n }\n else if (geojson.type === 'Feature') {\n const type = geojson.geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.geometry);\n }\n }\n else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {\n return new Within(geojson, geojson);\n }\n }\n return context.error('\\'within\\' expression requires valid geojson object that contains polygon geometry type.');\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointsWithinPolygons(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return linesWithinPolygons(ctx, this.geometries);\n }\n }\n return false;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass Var {\n constructor(name, boundExpression) {\n this.type = boundExpression.type;\n this.name = name;\n this.boundExpression = boundExpression;\n }\n static parse(args, context) {\n if (args.length !== 2 || typeof args[1] !== 'string')\n return context.error('\\'var\\' expression requires exactly one string literal argument.');\n const name = args[1];\n if (!context.scope.has(name)) {\n return context.error(`Unknown variable \"${name}\". Make sure \"${name}\" has been bound in an enclosing \"let\" expression before using it.`, 1);\n }\n return new Var(name, context.scope.get(name));\n }\n evaluate(ctx) {\n return this.boundExpression.evaluate(ctx);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nclass CompoundExpression {\n constructor(name, type, evaluate, args) {\n this.name = name;\n this.type = type;\n this._evaluate = evaluate;\n this.args = args;\n }\n evaluate(ctx) {\n return this._evaluate(ctx, this.args);\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return false;\n }\n static parse(args, context) {\n const op = args[0];\n const definition = CompoundExpression.definitions[op];\n if (!definition) {\n return context.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n // Now check argument types against each signature\n const type = Array.isArray(definition) ?\n definition[0] : definition.type;\n const availableOverloads = Array.isArray(definition) ?\n [[definition[1], definition[2]]] :\n definition.overloads;\n const overloads = availableOverloads.filter(([signature]) => (!Array.isArray(signature) || // varags\n signature.length === args.length - 1 // correct param count\n ));\n let signatureContext = null;\n for (const [params, evaluate] of overloads) {\n // Use a fresh context for each attempted signature so that, if\n // we eventually succeed, we haven't polluted `context.errors`.\n signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope);\n // First parse all the args, potentially coercing to the\n // types expected by this overload.\n const parsedArgs = [];\n let argParseFailed = false;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n const expectedType = Array.isArray(params) ?\n params[i - 1] :\n params.type;\n const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);\n if (!parsed) {\n argParseFailed = true;\n break;\n }\n parsedArgs.push(parsed);\n }\n if (argParseFailed) {\n // Couldn't coerce args of this overload to expected type, move\n // on to next one.\n continue;\n }\n if (Array.isArray(params)) {\n if (params.length !== parsedArgs.length) {\n signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);\n continue;\n }\n }\n for (let i = 0; i < parsedArgs.length; i++) {\n const expected = Array.isArray(params) ? params[i] : params.type;\n const arg = parsedArgs[i];\n signatureContext.concat(i + 1).checkSubtype(expected, arg.type);\n }\n if (signatureContext.errors.length === 0) {\n return new CompoundExpression(op, type, evaluate, parsedArgs);\n }\n }\n if (overloads.length === 1) {\n context.errors.push(...signatureContext.errors);\n }\n else {\n const expected = overloads.length ? overloads : availableOverloads;\n const signatures = expected\n .map(([params]) => stringifySignature(params))\n .join(' | ');\n const actualTypes = [];\n // For error message, re-parse arguments without trying to\n // apply any coercions\n for (let i = 1; i < args.length; i++) {\n const parsed = context.parse(args[i], 1 + actualTypes.length);\n if (!parsed)\n return null;\n actualTypes.push(toString$1(parsed.type));\n }\n context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);\n }\n return null;\n }\n static register(registry, definitions) {\n CompoundExpression.definitions = definitions;\n for (const name in definitions) {\n registry[name] = CompoundExpression;\n }\n }\n}\nfunction stringifySignature(signature) {\n if (Array.isArray(signature)) {\n return `(${signature.map(toString$1).join(', ')})`;\n }\n else {\n return `(${toString$1(signature.type)}...)`;\n }\n}\nfunction isExpressionConstant(expression) {\n if (expression instanceof Var) {\n return isExpressionConstant(expression.boundExpression);\n }\n else if (expression instanceof CompoundExpression && expression.name === 'error') {\n return false;\n }\n else if (expression instanceof CollatorExpression) {\n // Although the results of a Collator expression with fixed arguments\n // generally shouldn't change between executions, we can't serialize them\n // as constant expressions because results change based on environment.\n return false;\n }\n else if (expression instanceof Within) {\n return false;\n }\n const isTypeAnnotation = expression instanceof Coercion ||\n expression instanceof Assertion;\n let childrenConstant = true;\n expression.eachChild(child => {\n // We can _almost_ assume that if `expressions` children are constant,\n // they would already have been evaluated to Literal values when they\n // were parsed. Type annotations are the exception, because they might\n // have been inferred and added after a child was parsed.\n // So we recurse into isConstant() for the children of type annotations,\n // but otherwise simply check whether they are Literals.\n if (isTypeAnnotation) {\n childrenConstant = childrenConstant && isExpressionConstant(child);\n }\n else {\n childrenConstant = childrenConstant && child instanceof Literal;\n }\n });\n if (!childrenConstant) {\n return false;\n }\n return isFeatureConstant(expression) &&\n isGlobalPropertyConstant(expression, ['zoom', 'heatmap-density', 'line-progress', 'accumulated', 'is-supported-script']);\n}\nfunction isFeatureConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'get' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'feature-state') {\n return false;\n }\n else if (e.name === 'has' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'properties' ||\n e.name === 'geometry-type' ||\n e.name === 'id') {\n return false;\n }\n else if (/^filter-/.test(e.name)) {\n return false;\n }\n }\n if (e instanceof Within) {\n return false;\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isFeatureConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isStateConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'feature-state') {\n return false;\n }\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isStateConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isGlobalPropertyConstant(e, properties) {\n if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isGlobalPropertyConstant(arg, properties)) {\n result = false;\n }\n });\n return result;\n}\n\n/**\n * Returns the index of the last stop <= input, or 0 if it doesn't exist.\n * @private\n */\nfunction findStopLessThanOrEqualTo(stops, input) {\n const lastIndex = stops.length - 1;\n let lowerIndex = 0;\n let upperIndex = lastIndex;\n let currentIndex = 0;\n let currentValue, nextValue;\n while (lowerIndex <= upperIndex) {\n currentIndex = Math.floor((lowerIndex + upperIndex) / 2);\n currentValue = stops[currentIndex];\n nextValue = stops[currentIndex + 1];\n if (currentValue <= input) {\n if (currentIndex === lastIndex || input < nextValue) { // Search complete\n return currentIndex;\n }\n lowerIndex = currentIndex + 1;\n }\n else if (currentValue > input) {\n upperIndex = currentIndex - 1;\n }\n else {\n throw new RuntimeError('Input is not a number.');\n }\n }\n return 0;\n}\n\nclass Step {\n constructor(type, input, stops) {\n this.type = type;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static parse(args, context) {\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n const input = context.parse(args[1], 1, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 1; i < args.length; i += 2) {\n const label = i === 1 ? -Infinity : args[i];\n const value = args[i + 1];\n const labelKey = i;\n const valueKey = i + 1;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"step\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n return new Step(outputType, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n return outputs[index].evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n\n/**\n * Checks whether the specified color space is one of the supported interpolation color spaces.\n *\n * @param colorSpace Color space key to verify.\n * @returns `true` if the specified color space is one of the supported\n * interpolation color spaces, `false` otherwise\n */\nfunction isSupportedInterpolationColorSpace(colorSpace) {\n return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab';\n}\n/**\n * @param interpolationType Interpolation type\n * @returns interpolation fn\n * @deprecated use `interpolate[type]` instead\n */\nconst interpolateFactory = (interpolationType) => {\n switch (interpolationType) {\n case 'number': return number;\n case 'color': return color;\n case 'array': return array;\n case 'padding': return padding;\n case 'variableAnchorOffsetCollection': return variableAnchorOffsetCollection;\n }\n};\nfunction number(from, to, t) {\n return from + t * (to - from);\n}\nfunction color(from, to, t, spaceKey = 'rgb') {\n switch (spaceKey) {\n case 'rgb': {\n const [r, g, b, alpha] = array(from.rgb, to.rgb, t);\n return new Color(r, g, b, alpha, false);\n }\n case 'hcl': {\n const [hue0, chroma0, light0, alphaF] = from.hcl;\n const [hue1, chroma1, light1, alphaT] = to.hcl;\n // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js\n let hue, chroma;\n if (!isNaN(hue0) && !isNaN(hue1)) {\n let dh = hue1 - hue0;\n if (hue1 > hue0 && dh > 180) {\n dh -= 360;\n }\n else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh += 360;\n }\n hue = hue0 + t * dh;\n }\n else if (!isNaN(hue0)) {\n hue = hue0;\n if (light1 === 1 || light1 === 0)\n chroma = chroma0;\n }\n else if (!isNaN(hue1)) {\n hue = hue1;\n if (light0 === 1 || light0 === 0)\n chroma = chroma1;\n }\n else {\n hue = NaN;\n }\n const [r, g, b, alpha] = hclToRgb([\n hue,\n chroma !== null && chroma !== void 0 ? chroma : number(chroma0, chroma1, t),\n number(light0, light1, t),\n number(alphaF, alphaT, t),\n ]);\n return new Color(r, g, b, alpha, false);\n }\n case 'lab': {\n const [r, g, b, alpha] = labToRgb(array(from.lab, to.lab, t));\n return new Color(r, g, b, alpha, false);\n }\n }\n}\nfunction array(from, to, t) {\n return from.map((d, i) => {\n return number(d, to[i], t);\n });\n}\nfunction padding(from, to, t) {\n return new Padding(array(from.values, to.values, t));\n}\nfunction variableAnchorOffsetCollection(from, to, t) {\n const fromValues = from.values;\n const toValues = to.values;\n if (fromValues.length !== toValues.length) {\n throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`);\n }\n const output = [];\n for (let i = 0; i < fromValues.length; i += 2) {\n // Anchor entries must match\n if (fromValues[i] !== toValues[i]) {\n throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`);\n }\n output.push(fromValues[i]);\n // Interpolate the offset values for each anchor\n const [fx, fy] = fromValues[i + 1];\n const [tx, ty] = toValues[i + 1];\n output.push([number(fx, tx, t), number(fy, ty, t)]);\n }\n return new VariableAnchorOffsetCollection(output);\n}\nconst interpolate = {\n number,\n color,\n array,\n padding,\n variableAnchorOffsetCollection\n};\n\nclass Interpolate {\n constructor(type, operator, interpolation, input, stops) {\n this.type = type;\n this.operator = operator;\n this.interpolation = interpolation;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static interpolationFactor(interpolation, input, lower, upper) {\n let t = 0;\n if (interpolation.name === 'exponential') {\n t = exponentialInterpolation(input, interpolation.base, lower, upper);\n }\n else if (interpolation.name === 'linear') {\n t = exponentialInterpolation(input, 1, lower, upper);\n }\n else if (interpolation.name === 'cubic-bezier') {\n const c = interpolation.controlPoints;\n const ub = new UnitBezier(c[0], c[1], c[2], c[3]);\n t = ub.solve(exponentialInterpolation(input, 1, lower, upper));\n }\n return t;\n }\n static parse(args, context) {\n let [operator, interpolation, input, ...rest] = args;\n if (!Array.isArray(interpolation) || interpolation.length === 0) {\n return context.error('Expected an interpolation type expression.', 1);\n }\n if (interpolation[0] === 'linear') {\n interpolation = { name: 'linear' };\n }\n else if (interpolation[0] === 'exponential') {\n const base = interpolation[1];\n if (typeof base !== 'number')\n return context.error('Exponential interpolation requires a numeric base.', 1, 1);\n interpolation = {\n name: 'exponential',\n base\n };\n }\n else if (interpolation[0] === 'cubic-bezier') {\n const controlPoints = interpolation.slice(1);\n if (controlPoints.length !== 4 ||\n controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)) {\n return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);\n }\n interpolation = {\n name: 'cubic-bezier',\n controlPoints: controlPoints\n };\n }\n else {\n return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);\n }\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n input = context.parse(input, 2, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {\n outputType = ColorType;\n }\n else if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 0; i < rest.length; i += 2) {\n const label = rest[i];\n const value = rest[i + 1];\n const labelKey = i + 3;\n const valueKey = i + 4;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"interpolate\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n if (!verifyType(outputType, NumberType) &&\n !verifyType(outputType, ColorType) &&\n !verifyType(outputType, PaddingType) &&\n !verifyType(outputType, VariableAnchorOffsetCollectionType) &&\n !verifyType(outputType, array$1(NumberType))) {\n return context.error(`Type ${toString$1(outputType)} is not interpolatable.`);\n }\n return new Interpolate(outputType, operator, interpolation, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n const lower = labels[index];\n const upper = labels[index + 1];\n const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);\n const outputLower = outputs[index].evaluate(ctx);\n const outputUpper = outputs[index + 1].evaluate(ctx);\n switch (this.operator) {\n case 'interpolate':\n return interpolate[this.type.kind](outputLower, outputUpper, t);\n case 'interpolate-hcl':\n return interpolate.color(outputLower, outputUpper, t, 'hcl');\n case 'interpolate-lab':\n return interpolate.color(outputLower, outputUpper, t, 'lab');\n }\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n*/\nfunction exponentialInterpolation(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass Coalesce {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expectected at least one argument.');\n }\n let outputType = null;\n const expectedType = context.expectedType;\n if (expectedType && expectedType.kind !== 'value') {\n outputType = expectedType;\n }\n const parsedArgs = [];\n for (const arg of args.slice(1)) {\n const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' });\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n parsedArgs.push(parsed);\n }\n if (!outputType)\n throw new Error('No output type');\n // Above, we parse arguments without inferred type annotation so that\n // they don't produce a runtime error for `null` input, which would\n // preempt the desired null-coalescing behavior.\n // Thus, if any of our arguments would have needed an annotation, we\n // need to wrap the enclosing coalesce expression with it instead.\n const needsAnnotation = expectedType &&\n parsedArgs.some(arg => checkSubtype(expectedType, arg.type));\n return needsAnnotation ?\n new Coalesce(ValueType, parsedArgs) :\n new Coalesce(outputType, parsedArgs);\n }\n evaluate(ctx) {\n let result = null;\n let argCount = 0;\n let requestedImageName;\n for (const arg of this.args) {\n argCount++;\n result = arg.evaluate(ctx);\n // we need to keep track of the first requested image in a coalesce statement\n // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire\n if (result && result instanceof ResolvedImage && !result.available) {\n if (!requestedImageName) {\n requestedImageName = result.name;\n }\n result = null;\n if (argCount === this.args.length) {\n result = requestedImageName;\n }\n }\n if (result !== null)\n break;\n }\n return result;\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nclass Let {\n constructor(bindings, result) {\n this.type = result.type;\n this.bindings = [].concat(bindings);\n this.result = result;\n }\n evaluate(ctx) {\n return this.result.evaluate(ctx);\n }\n eachChild(fn) {\n for (const binding of this.bindings) {\n fn(binding[1]);\n }\n fn(this.result);\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);\n const bindings = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const name = args[i];\n if (typeof name !== 'string') {\n return context.error(`Expected string, but found ${typeof name} instead.`, i);\n }\n if (/[^a-zA-Z0-9_]/.test(name)) {\n return context.error('Variable names must contain only alphanumeric characters or \\'_\\'.', i);\n }\n const value = context.parse(args[i + 1], i + 1);\n if (!value)\n return null;\n bindings.push([name, value]);\n }\n const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);\n if (!result)\n return null;\n return new Let(bindings, result);\n }\n outputDefined() {\n return this.result.outputDefined();\n }\n}\n\nclass At {\n constructor(type, index, input) {\n this.type = type;\n this.index = index;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n const index = context.parse(args[1], 1, NumberType);\n const input = context.parse(args[2], 2, array$1(context.expectedType || ValueType));\n if (!index || !input)\n return null;\n const t = input.type;\n return new At(t.itemType, index, input);\n }\n evaluate(ctx) {\n const index = this.index.evaluate(ctx);\n const array = this.input.evaluate(ctx);\n if (index < 0) {\n throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);\n }\n if (index >= array.length) {\n throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);\n }\n if (index !== Math.floor(index)) {\n throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);\n }\n return array[index];\n }\n eachChild(fn) {\n fn(this.index);\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nclass In {\n constructor(needle, haystack) {\n this.type = BooleanType;\n this.needle = needle;\n this.haystack = haystack;\n }\n static parse(args, context) {\n if (args.length !== 3) {\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n return new In(needle, haystack);\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!haystack)\n return false;\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n return haystack.indexOf(needle) >= 0;\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n }\n outputDefined() {\n return true;\n }\n}\n\nclass IndexOf {\n constructor(needle, haystack, fromIndex) {\n this.type = NumberType;\n this.needle = needle;\n this.haystack = haystack;\n this.fromIndex = fromIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n if (args.length === 4) {\n const fromIndex = context.parse(args[3], 3, NumberType);\n if (!fromIndex)\n return null;\n return new IndexOf(needle, haystack, fromIndex);\n }\n else {\n return new IndexOf(needle, haystack);\n }\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n if (this.fromIndex) {\n const fromIndex = this.fromIndex.evaluate(ctx);\n return haystack.indexOf(needle, fromIndex);\n }\n return haystack.indexOf(needle);\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n if (this.fromIndex) {\n fn(this.fromIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass Match {\n constructor(inputType, outputType, input, cases, outputs, otherwise) {\n this.inputType = inputType;\n this.type = outputType;\n this.input = input;\n this.cases = cases;\n this.outputs = outputs;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 5)\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 1)\n return context.error('Expected an even number of arguments.');\n let inputType;\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const cases = {};\n const outputs = [];\n for (let i = 2; i < args.length - 1; i += 2) {\n let labels = args[i];\n const value = args[i + 1];\n if (!Array.isArray(labels)) {\n labels = [labels];\n }\n const labelContext = context.concat(i);\n if (labels.length === 0) {\n return labelContext.error('Expected at least one branch label.');\n }\n for (const label of labels) {\n if (typeof label !== 'number' && typeof label !== 'string') {\n return labelContext.error('Branch labels must be numbers or strings.');\n }\n else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {\n return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);\n }\n else if (typeof label === 'number' && Math.floor(label) !== label) {\n return labelContext.error('Numeric branch labels must be integer values.');\n }\n else if (!inputType) {\n inputType = typeOf(label);\n }\n else if (labelContext.checkSubtype(inputType, typeOf(label))) {\n return null;\n }\n if (typeof cases[String(label)] !== 'undefined') {\n return labelContext.error('Branch labels must be unique.');\n }\n cases[String(label)] = outputs.length;\n }\n const result = context.parse(value, i, outputType);\n if (!result)\n return null;\n outputType = outputType || result.type;\n outputs.push(result);\n }\n const input = context.parse(args[1], 1, ValueType);\n if (!input)\n return null;\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {\n return null;\n }\n return new Match(inputType, outputType, input, cases, outputs, otherwise);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;\n return output.evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n this.outputs.forEach(fn);\n fn(this.otherwise);\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Case {\n constructor(type, branches, otherwise) {\n this.type = type;\n this.branches = branches;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 0)\n return context.error('Expected an odd number of arguments.');\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const branches = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const test = context.parse(args[i], i, BooleanType);\n if (!test)\n return null;\n const result = context.parse(args[i + 1], i + 1, outputType);\n if (!result)\n return null;\n branches.push([test, result]);\n outputType = outputType || result.type;\n }\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (!outputType)\n throw new Error('Can\\'t infer output type');\n return new Case(outputType, branches, otherwise);\n }\n evaluate(ctx) {\n for (const [test, expression] of this.branches) {\n if (test.evaluate(ctx)) {\n return expression.evaluate(ctx);\n }\n }\n return this.otherwise.evaluate(ctx);\n }\n eachChild(fn) {\n for (const [test, expression] of this.branches) {\n fn(test);\n fn(expression);\n }\n fn(this.otherwise);\n }\n outputDefined() {\n return this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Slice {\n constructor(type, input, beginIndex, endIndex) {\n this.type = type;\n this.input = input;\n this.beginIndex = beginIndex;\n this.endIndex = endIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const input = context.parse(args[1], 1, ValueType);\n const beginIndex = context.parse(args[2], 2, NumberType);\n if (!input || !beginIndex)\n return null;\n if (!isValidType(input.type, [array$1(ValueType), StringType, ValueType])) {\n return context.error(`Expected first argument to be of type array or string, but found ${toString$1(input.type)} instead`);\n }\n if (args.length === 4) {\n const endIndex = context.parse(args[3], 3, NumberType);\n if (!endIndex)\n return null;\n return new Slice(input.type, input, beginIndex, endIndex);\n }\n else {\n return new Slice(input.type, input, beginIndex);\n }\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const beginIndex = this.beginIndex.evaluate(ctx);\n if (!isValidNativeType(input, ['string', 'array'])) {\n throw new RuntimeError(`Expected first argument to be of type array or string, but found ${toString$1(typeOf(input))} instead.`);\n }\n if (this.endIndex) {\n const endIndex = this.endIndex.evaluate(ctx);\n return input.slice(beginIndex, endIndex);\n }\n return input.slice(beginIndex);\n }\n eachChild(fn) {\n fn(this.input);\n fn(this.beginIndex);\n if (this.endIndex) {\n fn(this.endIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nfunction isComparableType(op, type) {\n if (op === '==' || op === '!=') {\n // equality operator\n return type.kind === 'boolean' ||\n type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'null' ||\n type.kind === 'value';\n }\n else {\n // ordering operator\n return type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'value';\n }\n}\nfunction eq(ctx, a, b) { return a === b; }\nfunction neq(ctx, a, b) { return a !== b; }\nfunction lt(ctx, a, b) { return a < b; }\nfunction gt(ctx, a, b) { return a > b; }\nfunction lteq(ctx, a, b) { return a <= b; }\nfunction gteq(ctx, a, b) { return a >= b; }\nfunction eqCollate(ctx, a, b, c) { return c.compare(a, b) === 0; }\nfunction neqCollate(ctx, a, b, c) { return !eqCollate(ctx, a, b, c); }\nfunction ltCollate(ctx, a, b, c) { return c.compare(a, b) < 0; }\nfunction gtCollate(ctx, a, b, c) { return c.compare(a, b) > 0; }\nfunction lteqCollate(ctx, a, b, c) { return c.compare(a, b) <= 0; }\nfunction gteqCollate(ctx, a, b, c) { return c.compare(a, b) >= 0; }\n/**\n * Special form for comparison operators, implementing the signatures:\n * - (T, T, ?Collator) => boolean\n * - (T, value, ?Collator) => boolean\n * - (value, T, ?Collator) => boolean\n *\n * For inequalities, T must be either value, string, or number. For ==/!=, it\n * can also be boolean or null.\n *\n * Equality semantics are equivalent to Javascript's strict equality (===/!==)\n * -- i.e., when the arguments' types don't match, == evaluates to false, != to\n * true.\n *\n * When types don't match in an ordering comparison, a runtime error is thrown.\n *\n * @private\n */\nfunction makeComparison(op, compareBasic, compareWithCollator) {\n const isOrderComparison = op !== '==' && op !== '!=';\n return class Comparison {\n constructor(lhs, rhs, collator) {\n this.type = BooleanType;\n this.lhs = lhs;\n this.rhs = rhs;\n this.collator = collator;\n this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';\n }\n static parse(args, context) {\n if (args.length !== 3 && args.length !== 4)\n return context.error('Expected two or three arguments.');\n const op = args[0];\n let lhs = context.parse(args[1], 1, ValueType);\n if (!lhs)\n return null;\n if (!isComparableType(op, lhs.type)) {\n return context.concat(1).error(`\"${op}\" comparisons are not supported for type '${toString$1(lhs.type)}'.`);\n }\n let rhs = context.parse(args[2], 2, ValueType);\n if (!rhs)\n return null;\n if (!isComparableType(op, rhs.type)) {\n return context.concat(2).error(`\"${op}\" comparisons are not supported for type '${toString$1(rhs.type)}'.`);\n }\n if (lhs.type.kind !== rhs.type.kind &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`);\n }\n if (isOrderComparison) {\n // typing rules specific to less/greater than operators\n if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {\n // (value, T)\n lhs = new Assertion(rhs.type, [lhs]);\n }\n else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {\n // (T, value)\n rhs = new Assertion(lhs.type, [rhs]);\n }\n }\n let collator = null;\n if (args.length === 4) {\n if (lhs.type.kind !== 'string' &&\n rhs.type.kind !== 'string' &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error('Cannot use collator to compare non-string types.');\n }\n collator = context.parse(args[3], 3, CollatorType);\n if (!collator)\n return null;\n }\n return new Comparison(lhs, rhs, collator);\n }\n evaluate(ctx) {\n const lhs = this.lhs.evaluate(ctx);\n const rhs = this.rhs.evaluate(ctx);\n if (isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n // check that type is string or number, and equal\n if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {\n throw new RuntimeError(`Expected arguments for \"${op}\" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`);\n }\n }\n if (this.collator && !isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n if (lt.kind !== 'string' || rt.kind !== 'string') {\n return compareBasic(ctx, lhs, rhs);\n }\n }\n return this.collator ?\n compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) :\n compareBasic(ctx, lhs, rhs);\n }\n eachChild(fn) {\n fn(this.lhs);\n fn(this.rhs);\n if (this.collator) {\n fn(this.collator);\n }\n }\n outputDefined() {\n return true;\n }\n };\n}\nconst Equals = makeComparison('==', eq, eqCollate);\nconst NotEquals = makeComparison('!=', neq, neqCollate);\nconst LessThan = makeComparison('<', lt, ltCollate);\nconst GreaterThan = makeComparison('>', gt, gtCollate);\nconst LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);\nconst GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);\n\nclass NumberFormat {\n constructor(number, locale, currency, minFractionDigits, maxFractionDigits) {\n this.type = StringType;\n this.number = number;\n this.locale = locale;\n this.currency = currency;\n this.minFractionDigits = minFractionDigits;\n this.maxFractionDigits = maxFractionDigits;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error('Expected two arguments.');\n const number = context.parse(args[1], 1, NumberType);\n if (!number)\n return null;\n const options = args[2];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('NumberFormat options argument must be an object.');\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n let currency = null;\n if (options['currency']) {\n currency = context.parse(options['currency'], 1, StringType);\n if (!currency)\n return null;\n }\n let minFractionDigits = null;\n if (options['min-fraction-digits']) {\n minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);\n if (!minFractionDigits)\n return null;\n }\n let maxFractionDigits = null;\n if (options['max-fraction-digits']) {\n maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);\n if (!maxFractionDigits)\n return null;\n }\n return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);\n }\n evaluate(ctx) {\n return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {\n style: this.currency ? 'currency' : 'decimal',\n currency: this.currency ? this.currency.evaluate(ctx) : undefined,\n minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,\n maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,\n }).format(this.number.evaluate(ctx));\n }\n eachChild(fn) {\n fn(this.number);\n if (this.locale) {\n fn(this.locale);\n }\n if (this.currency) {\n fn(this.currency);\n }\n if (this.minFractionDigits) {\n fn(this.minFractionDigits);\n }\n if (this.maxFractionDigits) {\n fn(this.maxFractionDigits);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass FormatExpression {\n constructor(sections) {\n this.type = FormattedType;\n this.sections = sections;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n const firstArg = args[1];\n if (!Array.isArray(firstArg) && typeof firstArg === 'object') {\n return context.error('First argument must be an image or text section.');\n }\n const sections = [];\n let nextTokenMayBeObject = false;\n for (let i = 1; i <= args.length - 1; ++i) {\n const arg = args[i];\n if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) {\n nextTokenMayBeObject = false;\n let scale = null;\n if (arg['font-scale']) {\n scale = context.parse(arg['font-scale'], 1, NumberType);\n if (!scale)\n return null;\n }\n let font = null;\n if (arg['text-font']) {\n font = context.parse(arg['text-font'], 1, array$1(StringType));\n if (!font)\n return null;\n }\n let textColor = null;\n if (arg['text-color']) {\n textColor = context.parse(arg['text-color'], 1, ColorType);\n if (!textColor)\n return null;\n }\n const lastExpression = sections[sections.length - 1];\n lastExpression.scale = scale;\n lastExpression.font = font;\n lastExpression.textColor = textColor;\n }\n else {\n const content = context.parse(args[i], 1, ValueType);\n if (!content)\n return null;\n const kind = content.type.kind;\n if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage')\n return context.error('Formatted text type must be \\'string\\', \\'value\\', \\'image\\' or \\'null\\'.');\n nextTokenMayBeObject = true;\n sections.push({ content, scale: null, font: null, textColor: null });\n }\n }\n return new FormatExpression(sections);\n }\n evaluate(ctx) {\n const evaluateSection = section => {\n const evaluatedContent = section.content.evaluate(ctx);\n if (typeOf(evaluatedContent) === ResolvedImageType) {\n return new FormattedSection('', evaluatedContent, null, null, null);\n }\n return new FormattedSection(toString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null);\n };\n return new Formatted(this.sections.map(evaluateSection));\n }\n eachChild(fn) {\n for (const section of this.sections) {\n fn(section.content);\n if (section.scale) {\n fn(section.scale);\n }\n if (section.font) {\n fn(section.font);\n }\n if (section.textColor) {\n fn(section.textColor);\n }\n }\n }\n outputDefined() {\n // Technically the combinatoric set of all children\n // Usually, this.text will be undefined anyway\n return false;\n }\n}\n\nclass ImageExpression {\n constructor(input) {\n this.type = ResolvedImageType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error('Expected two arguments.');\n }\n const name = context.parse(args[1], 1, StringType);\n if (!name)\n return context.error('No image name provided.');\n return new ImageExpression(name);\n }\n evaluate(ctx) {\n const evaluatedImageName = this.input.evaluate(ctx);\n const value = ResolvedImage.fromString(evaluatedImageName);\n if (value && ctx.availableImages)\n value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;\n return value;\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n // The output of image is determined by the list of available images in the evaluation context\n return false;\n }\n}\n\nclass Length {\n constructor(input) {\n this.type = NumberType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n const input = context.parse(args[1], 1);\n if (!input)\n return null;\n if (input.type.kind !== 'array' && input.type.kind !== 'string' && input.type.kind !== 'value')\n return context.error(`Expected argument of type string or array, but found ${toString$1(input.type)} instead.`);\n return new Length(input);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n if (typeof input === 'string') {\n return input.length;\n }\n else if (Array.isArray(input)) {\n return input.length;\n }\n else {\n throw new RuntimeError(`Expected value to be of type string or array, but found ${toString$1(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nconst expressions = {\n // special forms\n '==': Equals,\n '!=': NotEquals,\n '>': GreaterThan,\n '<': LessThan,\n '>=': GreaterThanOrEqual,\n '<=': LessThanOrEqual,\n 'array': Assertion,\n 'at': At,\n 'boolean': Assertion,\n 'case': Case,\n 'coalesce': Coalesce,\n 'collator': CollatorExpression,\n 'format': FormatExpression,\n 'image': ImageExpression,\n 'in': In,\n 'index-of': IndexOf,\n 'interpolate': Interpolate,\n 'interpolate-hcl': Interpolate,\n 'interpolate-lab': Interpolate,\n 'length': Length,\n 'let': Let,\n 'literal': Literal,\n 'match': Match,\n 'number': Assertion,\n 'number-format': NumberFormat,\n 'object': Assertion,\n 'slice': Slice,\n 'step': Step,\n 'string': Assertion,\n 'to-boolean': Coercion,\n 'to-color': Coercion,\n 'to-number': Coercion,\n 'to-string': Coercion,\n 'var': Var,\n 'within': Within\n};\nfunction rgba(ctx, [r, g, b, a]) {\n r = r.evaluate(ctx);\n g = g.evaluate(ctx);\n b = b.evaluate(ctx);\n const alpha = a ? a.evaluate(ctx) : 1;\n const error = validateRGBA(r, g, b, alpha);\n if (error)\n throw new RuntimeError(error);\n return new Color(r / 255, g / 255, b / 255, alpha, false);\n}\nfunction has(key, obj) {\n return key in obj;\n}\nfunction get(key, obj) {\n const v = obj[key];\n return typeof v === 'undefined' ? null : v;\n}\nfunction binarySearch(v, a, i, j) {\n while (i <= j) {\n const m = (i + j) >> 1;\n if (a[m] === v)\n return true;\n if (a[m] > v)\n j = m - 1;\n else\n i = m + 1;\n }\n return false;\n}\nfunction varargs(type) {\n return { type };\n}\nCompoundExpression.register(expressions, {\n 'error': [\n ErrorType,\n [StringType],\n (ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); }\n ],\n 'typeof': [\n StringType,\n [ValueType],\n (ctx, [v]) => toString$1(typeOf(v.evaluate(ctx)))\n ],\n 'to-rgba': [\n array$1(NumberType, 4),\n [ColorType],\n (ctx, [v]) => {\n const [r, g, b, a] = v.evaluate(ctx).rgb;\n return [r * 255, g * 255, b * 255, a];\n },\n ],\n 'rgb': [\n ColorType,\n [NumberType, NumberType, NumberType],\n rgba\n ],\n 'rgba': [\n ColorType,\n [NumberType, NumberType, NumberType, NumberType],\n rgba\n ],\n 'has': {\n type: BooleanType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'get': {\n type: ValueType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'feature-state': [\n ValueType,\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})\n ],\n 'properties': [\n ObjectType,\n [],\n (ctx) => ctx.properties()\n ],\n 'geometry-type': [\n StringType,\n [],\n (ctx) => ctx.geometryType()\n ],\n 'id': [\n ValueType,\n [],\n (ctx) => ctx.id()\n ],\n 'zoom': [\n NumberType,\n [],\n (ctx) => ctx.globals.zoom\n ],\n 'heatmap-density': [\n NumberType,\n [],\n (ctx) => ctx.globals.heatmapDensity || 0\n ],\n 'line-progress': [\n NumberType,\n [],\n (ctx) => ctx.globals.lineProgress || 0\n ],\n 'accumulated': [\n ValueType,\n [],\n (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated\n ],\n '+': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 0;\n for (const arg of args) {\n result += arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '*': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 1;\n for (const arg of args) {\n result *= arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '-': {\n type: NumberType,\n overloads: [\n [\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)\n ], [\n [NumberType],\n (ctx, [a]) => -a.evaluate(ctx)\n ]\n ]\n },\n '/': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)\n ],\n '%': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)\n ],\n 'ln2': [\n NumberType,\n [],\n () => Math.LN2\n ],\n 'pi': [\n NumberType,\n [],\n () => Math.PI\n ],\n 'e': [\n NumberType,\n [],\n () => Math.E\n ],\n '^': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))\n ],\n 'sqrt': [\n NumberType,\n [NumberType],\n (ctx, [x]) => Math.sqrt(x.evaluate(ctx))\n ],\n 'log10': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10\n ],\n 'ln': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx))\n ],\n 'log2': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2\n ],\n 'sin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.sin(n.evaluate(ctx))\n ],\n 'cos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.cos(n.evaluate(ctx))\n ],\n 'tan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.tan(n.evaluate(ctx))\n ],\n 'asin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.asin(n.evaluate(ctx))\n ],\n 'acos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.acos(n.evaluate(ctx))\n ],\n 'atan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.atan(n.evaluate(ctx))\n ],\n 'min': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'max': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'abs': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.abs(n.evaluate(ctx))\n ],\n 'round': [\n NumberType,\n [NumberType],\n (ctx, [n]) => {\n const v = n.evaluate(ctx);\n // Javascript's Math.round() rounds towards +Infinity for halfway\n // values, even when they're negative. It's more common to round\n // away from 0 (e.g., this is what python and C++ do)\n return v < 0 ? -Math.round(-v) : Math.round(v);\n }\n ],\n 'floor': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.floor(n.evaluate(ctx))\n ],\n 'ceil': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.ceil(n.evaluate(ctx))\n ],\n 'filter-==': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => ctx.properties()[k.value] === v.value\n ],\n 'filter-id-==': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => ctx.id() === v.value\n ],\n 'filter-type-==': [\n BooleanType,\n [StringType],\n (ctx, [v]) => ctx.geometryType() === v.value\n ],\n 'filter-<': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter-id-<': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter->': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-id->': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-<=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter-id-<=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter->=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-id->=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-has': [\n BooleanType,\n [ValueType],\n (ctx, [k]) => k.value in ctx.properties()\n ],\n 'filter-has-id': [\n BooleanType,\n [],\n (ctx) => (ctx.id() !== null && ctx.id() !== undefined)\n ],\n 'filter-type-in': [\n BooleanType,\n [array$1(StringType)],\n (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0\n ],\n 'filter-id-in': [\n BooleanType,\n [array$1(ValueType)],\n (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0\n ],\n 'filter-in-small': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is an array literal\n (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0\n ],\n 'filter-in-large': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is a array literal with values sorted in ascending order and of a single type\n (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)\n ],\n 'all': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (!arg.evaluate(ctx))\n return false;\n }\n return true;\n }\n ]\n ]\n },\n 'any': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (arg.evaluate(ctx))\n return true;\n }\n return false;\n }\n ]\n ]\n },\n '!': [\n BooleanType,\n [BooleanType],\n (ctx, [b]) => !b.evaluate(ctx)\n ],\n 'is-supported-script': [\n BooleanType,\n [StringType],\n // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant\n (ctx, [s]) => {\n const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;\n if (isSupportedScript) {\n return isSupportedScript(s.evaluate(ctx));\n }\n return true;\n }\n ],\n 'upcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toUpperCase()\n ],\n 'downcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toLowerCase()\n ],\n 'concat': [\n StringType,\n varargs(ValueType),\n (ctx, args) => args.map(arg => toString(arg.evaluate(ctx))).join('')\n ],\n 'resolved-locale': [\n StringType,\n [CollatorType],\n (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()\n ]\n});\n\nfunction success(value) {\n return { result: 'success', value };\n}\nfunction error(value) {\n return { result: 'error', value };\n}\n\nfunction supportsPropertyExpression(spec) {\n return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven';\n}\nfunction supportsZoomExpression(spec) {\n return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;\n}\nfunction supportsInterpolation(spec) {\n return !!spec.expression && spec.expression.interpolated;\n}\n\nfunction getType(val) {\n if (val instanceof Number) {\n return 'number';\n }\n else if (val instanceof String) {\n return 'string';\n }\n else if (val instanceof Boolean) {\n return 'boolean';\n }\n else if (Array.isArray(val)) {\n return 'array';\n }\n else if (val === null) {\n return 'null';\n }\n else {\n return typeof val;\n }\n}\n\nfunction isFunction(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\nfunction identityFunction(x) {\n return x;\n}\nfunction createFunction(parameters, propertySpec) {\n const isColor = propertySpec.type === 'color';\n const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');\n if (isColor || propertySpec.type === 'padding') {\n const parseFn = isColor ? Color.parse : Padding.parse;\n parameters = extendBy({}, parameters);\n if (parameters.stops) {\n parameters.stops = parameters.stops.map((stop) => {\n return [stop[0], parseFn(stop[1])];\n });\n }\n if (parameters.default) {\n parameters.default = parseFn(parameters.default);\n }\n else {\n parameters.default = parseFn(propertySpec.default);\n }\n }\n if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) {\n throw new Error(`Unknown color space: \"${parameters.colorSpace}\"`);\n }\n let innerFun;\n let hashedStops;\n let categoricalKeyType;\n if (type === 'exponential') {\n innerFun = evaluateExponentialFunction;\n }\n else if (type === 'interval') {\n innerFun = evaluateIntervalFunction;\n }\n else if (type === 'categorical') {\n innerFun = evaluateCategoricalFunction;\n // For categorical functions, generate an Object as a hashmap of the stops for fast searching\n hashedStops = Object.create(null);\n for (const stop of parameters.stops) {\n hashedStops[stop[0]] = stop[1];\n }\n // Infer key type based on first stop key-- used to encforce strict type checking later\n categoricalKeyType = typeof parameters.stops[0][0];\n }\n else if (type === 'identity') {\n innerFun = evaluateIdentityFunction;\n }\n else {\n throw new Error(`Unknown function type \"${type}\"`);\n }\n if (zoomAndFeatureDependent) {\n const featureFunctions = {};\n const zoomStops = [];\n for (let s = 0; s < parameters.stops.length; s++) {\n const stop = parameters.stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctions[zoom] === undefined) {\n featureFunctions[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n stops: []\n };\n zoomStops.push(zoom);\n }\n featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);\n }\n const featureFunctionStops = [];\n for (const z of zoomStops) {\n featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);\n }\n const interpolationType = { name: 'linear' };\n return {\n kind: 'composite',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: featureFunctionStops.map(s => s[0]),\n evaluate({ zoom }, properties) {\n return evaluateExponentialFunction({\n stops: featureFunctionStops,\n base: parameters.base\n }, propertySpec, zoom).evaluate(zoom, properties);\n }\n };\n }\n else if (zoomDependent) {\n const interpolationType = type === 'exponential' ?\n { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 } : null;\n return {\n kind: 'camera',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: parameters.stops.map(s => s[0]),\n evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)\n };\n }\n else {\n return {\n kind: 'source',\n evaluate(_, feature) {\n const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;\n if (value === undefined) {\n return coalesce$1(parameters.default, propertySpec.default);\n }\n return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);\n }\n };\n }\n}\nfunction coalesce$1(a, b, c) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n if (c !== undefined)\n return c;\n}\nfunction evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {\n const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input\n return coalesce$1(evaluated, parameters.default, propertySpec.default);\n}\nfunction evaluateIntervalFunction(parameters, propertySpec, input) {\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n return parameters.stops[index][1];\n}\nfunction evaluateExponentialFunction(parameters, propertySpec, input) {\n const base = parameters.base !== undefined ? parameters.base : 1;\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);\n const outputLower = parameters.stops[index][1];\n const outputUpper = parameters.stops[index + 1][1];\n const interp = interpolate[propertySpec.type] || identityFunction;\n if (typeof outputLower.evaluate === 'function') {\n return {\n evaluate(...args) {\n const evaluatedLower = outputLower.evaluate.apply(undefined, args);\n const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);\n // Special case for fill-outline-color, which has no spec default.\n if (evaluatedLower === undefined || evaluatedUpper === undefined) {\n return undefined;\n }\n return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace);\n }\n };\n }\n return interp(outputLower, outputUpper, t, parameters.colorSpace);\n}\nfunction evaluateIdentityFunction(parameters, propertySpec, input) {\n switch (propertySpec.type) {\n case 'color':\n input = Color.parse(input);\n break;\n case 'formatted':\n input = Formatted.fromString(input.toString());\n break;\n case 'resolvedImage':\n input = ResolvedImage.fromString(input.toString());\n break;\n case 'padding':\n input = Padding.parse(input);\n break;\n default:\n if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {\n input = undefined;\n }\n }\n return coalesce$1(input, parameters.default, propertySpec.default);\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n *\n * How it works:\n * Two consecutive stop values define a (scaled and shifted) exponential\n * function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction interpolationFactor(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass StyleExpression {\n constructor(expression, propertySpec) {\n this.expression = expression;\n this._warningHistory = {};\n this._evaluator = new EvaluationContext();\n this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;\n this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature;\n this._evaluator.featureState = featureState;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection;\n return this.expression.evaluate(this._evaluator);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature || null;\n this._evaluator.featureState = featureState || null;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection || null;\n try {\n const val = this.expression.evaluate(this._evaluator);\n // eslint-disable-next-line no-self-compare\n if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {\n return this._defaultValue;\n }\n if (this._enumValues && !(val in this._enumValues)) {\n throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);\n }\n return val;\n }\n catch (e) {\n if (!this._warningHistory[e.message]) {\n this._warningHistory[e.message] = true;\n if (typeof console !== 'undefined') {\n console.warn(e.message);\n }\n }\n return this._defaultValue;\n }\n }\n}\nfunction isExpression(expression) {\n return Array.isArray(expression) && expression.length > 0 &&\n typeof expression[0] === 'string' && expression[0] in expressions;\n}\n/**\n * Parse and typecheck the given style spec JSON expression. If\n * options.defaultValue is provided, then the resulting StyleExpression's\n * `evaluate()` method will handle errors by logging a warning (once per\n * message) and returning the default value. Otherwise, it will throw\n * evaluation errors.\n *\n * @private\n */\nfunction createExpression(expression, propertySpec) {\n const parser = new ParsingContext(expressions, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined);\n // For string-valued properties, coerce to string at the top level rather than asserting.\n const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);\n if (!parsed) {\n return error(parser.errors);\n }\n return success(new StyleExpression(parsed, propertySpec));\n}\nclass ZoomConstantExpression {\n constructor(kind, expression) {\n this.kind = kind;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'constant' && !isStateConstant(expression.expression);\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n}\nclass ZoomDependentExpression {\n constructor(kind, expression, zoomStops, interpolationType) {\n this.kind = kind;\n this.zoomStops = zoomStops;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'camera' && !isStateConstant(expression.expression);\n this.interpolationType = interpolationType;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n interpolationFactor(input, lower, upper) {\n if (this.interpolationType) {\n return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);\n }\n else {\n return 0;\n }\n }\n}\nfunction isZoomExpression(expression) {\n return expression._styleExpression !== undefined;\n}\nfunction createPropertyExpression(expressionInput, propertySpec) {\n const expression = createExpression(expressionInput, propertySpec);\n if (expression.result === 'error') {\n return expression;\n }\n const parsed = expression.value.expression;\n const isFeatureConstantResult = isFeatureConstant(parsed);\n if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'data expressions not supported')]);\n }\n const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']);\n if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'zoom expressions not supported')]);\n }\n const zoomCurve = findZoomCurve(parsed);\n if (!zoomCurve && !isZoomConstant) {\n return error([new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.')]);\n }\n else if (zoomCurve instanceof ExpressionParsingError) {\n return error([zoomCurve]);\n }\n else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {\n return error([new ExpressionParsingError('', '\"interpolate\" expressions cannot be used with this property')]);\n }\n if (!zoomCurve) {\n return success(isFeatureConstantResult ?\n new ZoomConstantExpression('constant', expression.value) :\n new ZoomConstantExpression('source', expression.value));\n }\n const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;\n return success(isFeatureConstantResult ?\n new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType) :\n new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType));\n}\n// serialization wrapper for old-style stop functions normalized to the\n// expression interface\nclass StylePropertyFunction {\n constructor(parameters, specification) {\n this._parameters = parameters;\n this._specification = specification;\n extendBy(this, createFunction(this._parameters, this._specification));\n }\n static deserialize(serialized) {\n return new StylePropertyFunction(serialized._parameters, serialized._specification);\n }\n static serialize(input) {\n return {\n _parameters: input._parameters,\n _specification: input._specification\n };\n }\n}\nfunction normalizePropertyExpression(value, specification) {\n if (isFunction(value)) {\n return new StylePropertyFunction(value, specification);\n }\n else if (isExpression(value)) {\n const expression = createPropertyExpression(value, specification);\n if (expression.result === 'error') {\n // this should have been caught in validation\n throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n return expression.value;\n }\n else {\n let constant = value;\n if (specification.type === 'color' && typeof value === 'string') {\n constant = Color.parse(value);\n }\n else if (specification.type === 'padding' && (typeof value === 'number' || Array.isArray(value))) {\n constant = Padding.parse(value);\n }\n else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) {\n constant = VariableAnchorOffsetCollection.parse(value);\n }\n return {\n kind: 'constant',\n evaluate: () => constant\n };\n }\n}\n// Zoom-dependent expressions may only use [\"zoom\"] as the input to a top-level \"step\" or \"interpolate\"\n// expression (collectively referred to as a \"curve\"). The curve may be wrapped in one or more \"let\" or\n// \"coalesce\" expressions.\nfunction findZoomCurve(expression) {\n let result = null;\n if (expression instanceof Let) {\n result = findZoomCurve(expression.result);\n }\n else if (expression instanceof Coalesce) {\n for (const arg of expression.args) {\n result = findZoomCurve(arg);\n if (result) {\n break;\n }\n }\n }\n else if ((expression instanceof Step || expression instanceof Interpolate) &&\n expression.input instanceof CompoundExpression &&\n expression.input.name === 'zoom') {\n result = expression;\n }\n if (result instanceof ExpressionParsingError) {\n return result;\n }\n expression.eachChild((child) => {\n const childResult = findZoomCurve(child);\n if (childResult instanceof ExpressionParsingError) {\n result = childResult;\n }\n else if (!result && childResult) {\n result = new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.');\n }\n else if (result && childResult && result !== childResult) {\n result = new ExpressionParsingError('', 'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.');\n }\n });\n return result;\n}\nfunction getExpectedType(spec) {\n const types = {\n color: ColorType,\n string: StringType,\n number: NumberType,\n enum: StringType,\n boolean: BooleanType,\n formatted: FormattedType,\n padding: PaddingType,\n resolvedImage: ResolvedImageType,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType\n };\n if (spec.type === 'array') {\n return array$1(types[spec.value] || ValueType, spec.length);\n }\n return types[spec.type];\n}\nfunction getDefaultValue(spec) {\n if (spec.type === 'color' && isFunction(spec.default)) {\n // Special case for heatmap-color: it uses the 'default:' to define a\n // default color ramp, but createExpression expects a simple value to fall\n // back to in case of runtime errors\n return new Color(0, 0, 0, 0);\n }\n else if (spec.type === 'color') {\n return Color.parse(spec.default) || null;\n }\n else if (spec.type === 'padding') {\n return Padding.parse(spec.default) || null;\n }\n else if (spec.type === 'variableAnchorOffsetCollection') {\n return VariableAnchorOffsetCollection.parse(spec.default) || null;\n }\n else if (spec.default === undefined) {\n return null;\n }\n else {\n return spec.default;\n }\n}\n\nfunction isExpressionFilter(filter) {\n if (filter === true || filter === false) {\n return true;\n }\n if (!Array.isArray(filter) || filter.length === 0) {\n return false;\n }\n switch (filter[0]) {\n case 'has':\n return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';\n case 'in':\n return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2]));\n case '!in':\n case '!has':\n case 'none':\n return false;\n case '==':\n case '!=':\n case '>':\n case '>=':\n case '<':\n case '<=':\n return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2]));\n case 'any':\n case 'all':\n for (const f of filter.slice(1)) {\n if (!isExpressionFilter(f) && typeof f !== 'boolean') {\n return false;\n }\n }\n return true;\n default:\n return true;\n }\n}\nconst filterSpec = {\n 'type': 'boolean',\n 'default': false,\n 'transition': false,\n 'property-type': 'data-driven',\n 'expression': {\n 'interpolated': false,\n 'parameters': ['zoom', 'feature']\n }\n};\n/**\n * Given a filter expressed as nested arrays, return a new function\n * that evaluates whether a given feature (with a .properties or .tags property)\n * passes its test.\n *\n * @private\n * @param {Array} filter MapLibre filter\n * @returns {Function} filter-evaluating function\n */\nfunction createFilter(filter) {\n if (filter === null || filter === undefined) {\n return { filter: () => true, needGeometry: false };\n }\n if (!isExpressionFilter(filter)) {\n filter = convertFilter$1(filter);\n }\n const compiled = createExpression(filter, filterSpec);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n else {\n const needGeometry = geometryNeeded(filter);\n return { filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical),\n needGeometry };\n }\n}\n// Comparison function to sort numbers and strings\nfunction compare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\nfunction geometryNeeded(filter) {\n if (!Array.isArray(filter))\n return false;\n if (filter[0] === 'within')\n return true;\n for (let index = 1; index < filter.length; index++) {\n if (geometryNeeded(filter[index]))\n return true;\n }\n return false;\n}\nfunction convertFilter$1(filter) {\n if (!filter)\n return true;\n const op = filter[0];\n if (filter.length <= 1)\n return (op !== 'any');\n const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') :\n op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) :\n op === '<' ||\n op === '>' ||\n op === '<=' ||\n op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) :\n op === 'any' ? convertDisjunctionOp(filter.slice(1)) :\n op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) :\n op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) :\n op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) :\n op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) :\n op === 'has' ? convertHasOp$1(filter[1]) :\n op === '!has' ? convertNegation(convertHasOp$1(filter[1])) :\n op === 'within' ? filter :\n true;\n return converted;\n}\nfunction convertComparisonOp$1(property, value, op) {\n switch (property) {\n case '$type':\n return [`filter-type-${op}`, value];\n case '$id':\n return [`filter-id-${op}`, value];\n default:\n return [`filter-${op}`, property, value];\n }\n}\nfunction convertDisjunctionOp(filters) {\n return ['any'].concat(filters.map(convertFilter$1));\n}\nfunction convertInOp$1(property, values) {\n if (values.length === 0) {\n return false;\n }\n switch (property) {\n case '$type':\n return ['filter-type-in', ['literal', values]];\n case '$id':\n return ['filter-id-in', ['literal', values]];\n default:\n if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) {\n return ['filter-in-large', property, ['literal', values.sort(compare)]];\n }\n else {\n return ['filter-in-small', property, ['literal', values]];\n }\n }\n}\nfunction convertHasOp$1(property) {\n switch (property) {\n case '$type':\n return true;\n case '$id':\n return ['filter-has-id'];\n default:\n return ['filter-has', property];\n }\n}\nfunction convertNegation(filter) {\n return ['!', filter];\n}\n\n/*\n * Convert the given filter to an expression, storing the expected types for\n * any feature properties referenced in expectedTypes.\n *\n * These expected types are needed in order to construct preflight type checks\n * needed for handling 'any' filters. A preflight type check is necessary in\n * order to mimic legacy filters' semantics around expected type mismatches.\n * For example, consider the legacy filter:\n *\n * [\"any\", [\"all\", [\">\", \"y\", 0], [\">\", \"y\", 0]], [\">\", \"x\", 0]]\n *\n * Naively, we might convert this to the expression:\n *\n * [\"any\", [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]], [\">\", [\"get\", \"x\"], 0]]\n *\n * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the\n * [\">\", [\"get\", \"y\"], 0] would cause an evaluation error, leading to the\n * entire filter returning false. Legacy filter semantics, though, ask for\n * [\">\", \"y\", 0] to simply return `false` when `y` is of the wrong type,\n * allowing the subsequent terms of the outer \"any\" expression to be evaluated\n * (resulting, in this case, in a `true` value, because x > 0).\n *\n * We account for this by inserting a preflight type-checking expression before\n * each \"any\" term, allowing us to avoid evaluating the actual converted filter\n * if any type mismatches would cause it to produce an evalaution error:\n *\n * [\"any\",\n * [\"case\",\n * [\"all\", [\"==\", [\"typeof\", [\"get\", \"y\"]], \"number\"], [\"==\", [\"typeof\", [\"get\", \"z\"], \"number]],\n * [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]],\n * false\n * ],\n * [\"case\",\n * [\"==\", [\"typeof\", [\"get\", \"x\"], \"number\"]],\n * [\">\", [\"get\", \"x\"], 0],\n * false\n * ]\n * ]\n *\n * An alternative, possibly more direct approach would be to use type checks\n * in the conversion of each comparison operator, so that the converted version\n * of each individual ==, >=, etc. would mimic the legacy filter semantics. The\n * downside of this approach is that it can lead to many more type checks than\n * would otherwise be necessary: outside the context of an \"any\" expression,\n * bailing out due to a runtime type error (expression semantics) and returning\n * false (legacy filter semantics) are equivalent: they cause the filter to\n * produce a `false` result.\n */\nfunction convertFilter(filter, expectedTypes = {}) {\n if (isExpressionFilter(filter))\n return filter;\n if (!filter)\n return true;\n const legacyFilter = filter;\n const legacyOp = legacyFilter[0];\n if (filter.length <= 1)\n return (legacyOp !== 'any');\n switch (legacyOp) {\n case '==':\n case '!=':\n case '<':\n case '>':\n case '<=':\n case '>=': {\n const [, property, value] = filter;\n return convertComparisonOp(property, value, legacyOp, expectedTypes);\n }\n case 'any': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => {\n const types = {};\n const child = convertFilter(f, types);\n const typechecks = runtimeTypeChecks(types);\n return typechecks === true ? child : ['case', typechecks, child, false];\n });\n return ['any', ...children];\n }\n case 'all': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map(f => convertFilter(f, expectedTypes));\n return children.length > 1 ? ['all', ...children] : children[0];\n }\n case 'none': {\n const [, ...conditions] = legacyFilter;\n return ['!', convertFilter(['any', ...conditions], {})];\n }\n case 'in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values);\n }\n case '!in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values, true);\n }\n case 'has':\n return convertHasOp(legacyFilter[1]);\n case '!has':\n return ['!', convertHasOp(legacyFilter[1])];\n default:\n return true;\n }\n}\n// Given a set of feature properties and an expected type for each one,\n// construct an boolean expression that tests whether each property has the\n// right type.\n// E.g.: for {name: 'string', population: 'number'}, return\n// [ 'all',\n// ['==', ['typeof', ['get', 'name'], 'string']],\n// ['==', ['typeof', ['get', 'population'], 'number]]\n// ]\nfunction runtimeTypeChecks(expectedTypes) {\n const conditions = [];\n for (const property in expectedTypes) {\n const get = property === '$id' ? ['id'] : ['get', property];\n conditions.push(['==', ['typeof', get], expectedTypes[property]]);\n }\n if (conditions.length === 0)\n return true;\n if (conditions.length === 1)\n return conditions[0];\n return ['all', ...conditions];\n}\nfunction convertComparisonOp(property, value, op, expectedTypes) {\n let get;\n if (property === '$type') {\n return [op, ['geometry-type'], value];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n if (expectedTypes && value !== null) {\n const type = typeof value;\n expectedTypes[property] = type;\n }\n if (op === '==' && property !== '$id' && value === null) {\n return [\n 'all',\n ['has', property],\n ['==', get, null]\n ];\n }\n else if (op === '!=' && property !== '$id' && value === null) {\n return [\n 'any',\n ['!', ['has', property]],\n ['!=', get, null]\n ];\n }\n return [op, get, value];\n}\nfunction convertInOp(property, values, negate = false) {\n if (values.length === 0)\n return negate;\n let get;\n if (property === '$type') {\n get = ['geometry-type'];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n // Determine if the list of values to be searched is homogenously typed.\n // If so (and if the type is string or number), then we can use a\n // [match, input, [...values], true, false] construction rather than a\n // bunch of `==` tests.\n let uniformTypes = true;\n const type = typeof values[0];\n for (const value of values) {\n if (typeof value !== type) {\n uniformTypes = false;\n break;\n }\n }\n if (uniformTypes && (type === 'string' || type === 'number')) {\n // Match expressions must have unique values.\n const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);\n return ['match', get, uniqueValues, !negate, negate];\n }\n if (negate) {\n return ['all', ...values.map(v => ['!=', get, v])];\n }\n else {\n return ['any', ...values.map(v => ['==', get, v])];\n }\n}\nfunction convertHasOp(property) {\n if (property === '$type') {\n return true;\n }\n else if (property === '$id') {\n return ['!=', ['id'], null];\n }\n else {\n return ['has', property];\n }\n}\n\nfunction convertLiteral(value) {\n return typeof value === 'object' ? ['literal', value] : value;\n}\nfunction convertFunction(parameters, propertySpec) {\n let stops = parameters.stops;\n if (!stops) {\n // identity function\n return convertIdentityFunction(parameters, propertySpec);\n }\n const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n stops = stops.map((stop) => {\n if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {\n return [stop[0], convertTokenString(stop[1])];\n }\n return [stop[0], convertLiteral(stop[1])];\n });\n if (zoomAndFeatureDependent) {\n return convertZoomAndPropertyFunction(parameters, propertySpec, stops);\n }\n else if (zoomDependent) {\n return convertZoomFunction(parameters, propertySpec, stops);\n }\n else {\n return convertPropertyFunction(parameters, propertySpec, stops);\n }\n}\nfunction convertIdentityFunction(parameters, propertySpec) {\n const get = ['get', parameters.property];\n if (parameters.default === undefined) {\n // By default, expressions for string-valued properties get coerced. To preserve\n // legacy function semantics, insert an explicit assertion instead.\n return propertySpec.type === 'string' ? ['string', get] : get;\n }\n else if (propertySpec.type === 'enum') {\n return [\n 'match',\n get,\n Object.keys(propertySpec.values),\n get,\n parameters.default\n ];\n }\n else {\n const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];\n if (propertySpec.type === 'array') {\n expression.splice(1, 0, propertySpec.value, propertySpec.length || null);\n }\n return expression;\n }\n}\nfunction getInterpolateOperator(parameters) {\n switch (parameters.colorSpace) {\n case 'hcl': return 'interpolate-hcl';\n case 'lab': return 'interpolate-lab';\n default: return 'interpolate';\n }\n}\nfunction convertZoomAndPropertyFunction(parameters, propertySpec, stops) {\n const featureFunctionParameters = {};\n const featureFunctionStops = {};\n const zoomStops = [];\n for (let s = 0; s < stops.length; s++) {\n const stop = stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctionParameters[zoom] === undefined) {\n featureFunctionParameters[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n };\n featureFunctionStops[zoom] = [];\n zoomStops.push(zoom);\n }\n featureFunctionStops[zoom].push([stop[0].value, stop[1]]);\n }\n // the interpolation type for the zoom dimension of a zoom-and-property\n // function is determined directly from the style property specification\n // for which it's being used: linear for interpolatable properties, step\n // otherwise.\n const functionType = getFunctionType({}, propertySpec);\n if (functionType === 'exponential') {\n const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, false);\n }\n return expression;\n }\n else {\n const expression = ['step', ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, true);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n }\n}\nfunction coalesce(a, b) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n}\nfunction getFallback(parameters, propertySpec) {\n const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));\n /*\n * Some fields with type: resolvedImage have an undefined default.\n * Because undefined is an invalid value for resolvedImage, set fallback to\n * an empty string instead of undefined to ensure output\n * passes validation.\n */\n if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {\n return '';\n }\n return defaultValue;\n}\nfunction convertPropertyFunction(parameters, propertySpec, stops) {\n const type = getFunctionType(parameters, propertySpec);\n const get = ['get', parameters.property];\n if (type === 'categorical' && typeof stops[0][0] === 'boolean') {\n const expression = ['case'];\n for (const stop of stops) {\n expression.push(['==', get, stop[0]], stop[1]);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'categorical') {\n const expression = ['match', get];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'interval') {\n const expression = ['step', ['number', get]];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], true);\n }\n fixupDegenerateStepCurve(expression);\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n const expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n ['number', get]\n ];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else {\n throw new Error(`Unknown property function type ${type}`);\n }\n}\nfunction convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) {\n const type = getFunctionType(parameters, propertySpec);\n let expression;\n let isStep = false;\n if (type === 'interval') {\n expression = ['step', input];\n isStep = true;\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n expression = [getInterpolateOperator(parameters), base === 1 ? ['linear'] : ['exponential', base], input];\n }\n else {\n throw new Error(`Unknown zoom function type \"${type}\"`);\n }\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], isStep);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n}\nfunction fixupDegenerateStepCurve(expression) {\n // degenerate step curve (i.e. a constant function): add a noop stop\n if (expression[0] === 'step' && expression.length === 3) {\n expression.push(0);\n expression.push(expression[3]);\n }\n}\nfunction appendStopPair(curve, input, output, isStep) {\n // Skip duplicate stop values. They were not validated for functions, but they are for expressions.\n // https://github.com/mapbox/mapbox-gl-js/issues/4107\n if (curve.length > 3 && input === curve[curve.length - 2]) {\n return;\n }\n // step curves don't get the first input value, as it is redundant.\n if (!(isStep && curve.length === 2)) {\n curve.push(input);\n }\n curve.push(output);\n}\nfunction getFunctionType(parameters, propertySpec) {\n if (parameters.type) {\n return parameters.type;\n }\n else {\n return propertySpec.expression.interpolated ? 'exponential' : 'interval';\n }\n}\n// \"String with {name} token\" => [\"concat\", \"String with \", [\"get\", \"name\"], \" token\"]\nfunction convertTokenString(s) {\n const result = ['concat'];\n const re = /{([^{}]+)}/g;\n let pos = 0;\n for (let match = re.exec(s); match !== null; match = re.exec(s)) {\n const literal = s.slice(pos, re.lastIndex - match[0].length);\n pos = re.lastIndex;\n if (literal.length > 0)\n result.push(literal);\n result.push(['get', match[1]]);\n }\n if (result.length === 1) {\n return s;\n }\n if (pos < s.length) {\n result.push(s.slice(pos));\n }\n else if (result.length === 2) {\n return ['to-string', result[1]];\n }\n return result;\n}\n\nfunction getPropertyReference(propertyName) {\n for (let i = 0; i < v8Spec.layout.length; i++) {\n for (const key in v8Spec[v8Spec.layout[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.layout[i]][key];\n }\n }\n for (let i = 0; i < v8Spec.paint.length; i++) {\n for (const key in v8Spec[v8Spec.paint[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.paint[i]][key];\n }\n }\n return null;\n}\nfunction eachSource(style, callback) {\n for (const k in style.sources) {\n callback(style.sources[k]);\n }\n}\nfunction eachLayer(style, callback) {\n for (const layer of style.layers) {\n callback(layer);\n }\n}\nfunction eachProperty(style, options, callback) {\n function inner(layer, propertyType) {\n const properties = layer[propertyType];\n if (!properties)\n return;\n Object.keys(properties).forEach((key) => {\n callback({\n path: [layer.id, propertyType, key],\n key,\n value: properties[key],\n reference: getPropertyReference(key),\n set(x) {\n properties[key] = x;\n }\n });\n });\n }\n eachLayer(style, (layer) => {\n if (options.paint) {\n inner(layer, 'paint');\n }\n if (options.layout) {\n inner(layer, 'layout');\n }\n });\n}\n\nfunction stringify(obj) {\n const type = typeof obj;\n if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null)\n return JSON.stringify(obj);\n if (Array.isArray(obj)) {\n let str = '[';\n for (const val of obj) {\n str += `${stringify(val)},`;\n }\n return `${str}]`;\n }\n const keys = Object.keys(obj).sort();\n let str = '{';\n for (let i = 0; i < keys.length; i++) {\n str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`;\n }\n return `${str}}`;\n}\nfunction getKey(layer) {\n let key = '';\n for (const k of refProperties) {\n key += `/${stringify(layer[k])}`;\n }\n return key;\n}\n/**\n * Given an array of layers, return an array of arrays of layers where all\n * layers in each group have identical layout-affecting properties. These\n * are the properties that were formerly used by explicit `ref` mechanism\n * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n * 'filter', and 'layout'.\n *\n * The input is not modified. The output layers are references to the\n * input layers.\n *\n * @private\n * @param {Array} layers\n * @param {Object} [cachedKeys] - an object to keep already calculated keys.\n * @returns {Array>}\n */\nfunction groupByLayout(layers, cachedKeys) {\n const groups = {};\n for (let i = 0; i < layers.length; i++) {\n const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);\n // update the cache if there is one\n if (cachedKeys)\n cachedKeys[layers[i].id] = k;\n let group = groups[k];\n if (!group) {\n group = groups[k] = [];\n }\n group.push(layers[i]);\n }\n const result = [];\n for (const k in groups) {\n result.push(groups[k]);\n }\n return result;\n}\n\nfunction emptyStyle() {\n const style = {};\n const version = v8Spec['$version'];\n for (const styleKey in v8Spec['$root']) {\n const spec = v8Spec['$root'][styleKey];\n if (spec.required) {\n let value = null;\n if (styleKey === 'version') {\n value = version;\n }\n else {\n if (spec.type === 'array') {\n value = [];\n }\n else {\n value = {};\n }\n }\n if (value != null) {\n style[styleKey] = value;\n }\n }\n }\n return style;\n}\n\nfunction validateConstants(options) {\n const key = options.key;\n const constants = options.value;\n if (constants) {\n return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];\n }\n else {\n return [];\n }\n}\n\n// Turn jsonlint-lines-primitives objects into primitive objects\nfunction unbundle(value) {\n if (value instanceof Number || value instanceof String || value instanceof Boolean) {\n return value.valueOf();\n }\n else {\n return value;\n }\n}\nfunction deepUnbundle(value) {\n if (Array.isArray(value)) {\n return value.map(deepUnbundle);\n }\n else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {\n const unbundledValue = {};\n for (const key in value) {\n unbundledValue[key] = deepUnbundle(value[key]);\n }\n return unbundledValue;\n }\n return unbundle(value);\n}\n\nfunction validateObject(options) {\n const key = options.key;\n const object = options.value;\n const elementSpecs = options.valueSpec || {};\n const elementValidators = options.objectElementValidators || {};\n const style = options.style;\n const styleSpec = options.styleSpec;\n const validateSpec = options.validateSpec;\n let errors = [];\n const type = getType(object);\n if (type !== 'object') {\n return [new ValidationError(key, object, `object expected, ${type} found`)];\n }\n for (const objectKey in object) {\n const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'\n const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];\n let validateElement;\n if (elementValidators[elementSpecKey]) {\n validateElement = elementValidators[elementSpecKey];\n }\n else if (elementSpecs[elementSpecKey]) {\n validateElement = validateSpec;\n }\n else if (elementValidators['*']) {\n validateElement = elementValidators['*'];\n }\n else if (elementSpecs['*']) {\n validateElement = validateSpec;\n }\n else {\n errors.push(new ValidationError(key, object[objectKey], `unknown property \"${objectKey}\"`));\n continue;\n }\n errors = errors.concat(validateElement({\n key: (key ? `${key}.` : key) + objectKey,\n value: object[objectKey],\n valueSpec: elementSpec,\n style,\n styleSpec,\n object,\n objectKey,\n validateSpec,\n }, object));\n }\n for (const elementSpecKey in elementSpecs) {\n // Don't check `required` when there's a custom validator for that property.\n if (elementValidators[elementSpecKey]) {\n continue;\n }\n if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {\n errors.push(new ValidationError(key, object, `missing required property \"${elementSpecKey}\"`));\n }\n }\n return errors;\n}\n\nfunction validateArray(options) {\n const array = options.value;\n const arraySpec = options.valueSpec;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const key = options.key;\n const validateArrayElement = options.arrayElementValidator || validateSpec;\n if (getType(array) !== 'array') {\n return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];\n }\n if (arraySpec.length && array.length !== arraySpec.length) {\n return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)];\n }\n if (arraySpec['min-length'] && array.length < arraySpec['min-length']) {\n return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)];\n }\n let arrayElementSpec = {\n 'type': arraySpec.value,\n 'values': arraySpec.values\n };\n if (styleSpec.$version < 7) {\n arrayElementSpec['function'] = arraySpec.function;\n }\n if (getType(arraySpec.value) === 'object') {\n arrayElementSpec = arraySpec.value;\n }\n let errors = [];\n for (let i = 0; i < array.length; i++) {\n errors = errors.concat(validateArrayElement({\n array,\n arrayIndex: i,\n value: array[i],\n valueSpec: arrayElementSpec,\n validateSpec: options.validateSpec,\n style,\n styleSpec,\n key: `${key}[${i}]`\n }));\n }\n return errors;\n}\n\nfunction validateNumber(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n let type = getType(value);\n // eslint-disable-next-line no-self-compare\n if (type === 'number' && value !== value) {\n type = 'NaN';\n }\n if (type !== 'number') {\n return [new ValidationError(key, value, `number expected, ${type} found`)];\n }\n if ('minimum' in valueSpec && value < valueSpec.minimum) {\n return [new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)];\n }\n if ('maximum' in valueSpec && value > valueSpec.maximum) {\n return [new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)];\n }\n return [];\n}\n\nfunction validateFunction(options) {\n const functionValueSpec = options.valueSpec;\n const functionType = unbundle(options.value.type);\n let stopKeyType;\n let stopDomainValues = {};\n let previousStopDomainValue;\n let previousStopDomainZoom;\n const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;\n const isPropertyFunction = !isZoomFunction;\n const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' &&\n getType(options.value.stops[0]) === 'array' &&\n getType(options.value.stops[0][0]) === 'object';\n const errors = validateObject({\n key: options.key,\n value: options.value,\n valueSpec: options.styleSpec.function,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n stops: validateFunctionStops,\n default: validateFunctionDefault\n }\n });\n if (functionType === 'identity' && isZoomFunction) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"property\"'));\n }\n if (functionType !== 'identity' && !options.value.stops) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"stops\"'));\n }\n if (functionType === 'exponential' && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported'));\n }\n if (options.styleSpec.$version >= 8) {\n if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'property functions not supported'));\n }\n else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));\n }\n }\n if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) {\n errors.push(new ValidationError(options.key, options.value, '\"property\" property is required'));\n }\n return errors;\n function validateFunctionStops(options) {\n if (functionType === 'identity') {\n return [new ValidationError(options.key, options.value, 'identity function may not have a \"stops\" property')];\n }\n let errors = [];\n const value = options.value;\n errors = errors.concat(validateArray({\n key: options.key,\n value,\n valueSpec: options.valueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n arrayElementValidator: validateFunctionStop\n }));\n if (getType(value) === 'array' && value.length === 0) {\n errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));\n }\n return errors;\n }\n function validateFunctionStop(options) {\n let errors = [];\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n if (value.length !== 2) {\n return [new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)];\n }\n if (isZoomAndPropertyFunction) {\n if (getType(value[0]) !== 'object') {\n return [new ValidationError(key, value, `object expected, ${getType(value[0])} found`)];\n }\n if (value[0].zoom === undefined) {\n return [new ValidationError(key, value, 'object stop key must have zoom')];\n }\n if (value[0].value === undefined) {\n return [new ValidationError(key, value, 'object stop key must have value')];\n }\n if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {\n return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')];\n }\n if (unbundle(value[0].zoom) !== previousStopDomainZoom) {\n previousStopDomainZoom = unbundle(value[0].zoom);\n previousStopDomainValue = undefined;\n stopDomainValues = {};\n }\n errors = errors.concat(validateObject({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: { zoom: {} },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue }\n }));\n }\n else {\n errors = errors.concat(validateStopDomainValue({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: {},\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }, value));\n }\n if (isExpression(deepUnbundle(value[1]))) {\n return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]);\n }\n return errors.concat(options.validateSpec({\n key: `${key}[1]`,\n value: value[1],\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n function validateStopDomainValue(options, stop) {\n const type = getType(options.value);\n const value = unbundle(options.value);\n const reportValue = options.value !== null ? options.value : stop;\n if (!stopKeyType) {\n stopKeyType = type;\n }\n else if (type !== stopKeyType) {\n return [new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)];\n }\n if (type !== 'number' && type !== 'string' && type !== 'boolean') {\n return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];\n }\n if (type !== 'number' && functionType !== 'categorical') {\n let message = `number expected, ${type} found`;\n if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {\n message += '\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.';\n }\n return [new ValidationError(options.key, reportValue, message)];\n }\n if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) {\n return [new ValidationError(options.key, reportValue, `integer expected, found ${value}`)];\n }\n if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];\n }\n else {\n previousStopDomainValue = value;\n }\n if (functionType === 'categorical' && value in stopDomainValues) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];\n }\n else {\n stopDomainValues[value] = true;\n }\n return [];\n }\n function validateFunctionDefault(options) {\n return options.validateSpec({\n key: options.key,\n value: options.value,\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n });\n }\n}\n\nfunction validateExpression(options) {\n const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);\n if (expression.result === 'error') {\n return expression.value.map((error) => {\n return new ValidationError(`${options.key}${error.key}`, options.value, error.message);\n });\n }\n const expressionObj = expression.value.expression || expression.value._styleExpression.expression;\n if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&\n !expressionObj.outputDefined()) {\n return [new ValidationError(options.key, options.value, `Invalid data expression for \"${options.propertyKey}\". Output values must be contained as literals within the expression.`)];\n }\n if (options.expressionContext === 'property' && options.propertyType === 'layout' &&\n (!isStateConstant(expressionObj))) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with layout properties.')];\n }\n if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with filters.')];\n }\n if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {\n if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {\n return [new ValidationError(options.key, options.value, '\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.')];\n }\n if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')];\n }\n }\n return [];\n}\n\nfunction validateBoolean(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'boolean') {\n return [new ValidationError(key, value, `boolean expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateColor(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `color expected, ${type} found`)];\n }\n if (!Color.parse(String(value))) { // cast String object to string primitive\n return [new ValidationError(key, value, `color expected, \"${value}\" found`)];\n }\n return [];\n}\n\nfunction validateEnum(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n const errors = [];\n if (Array.isArray(valueSpec.values)) { // <=v7\n if (valueSpec.values.indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n else { // >=v8\n if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n return errors;\n}\n\nfunction validateFilter(options) {\n if (isExpressionFilter(deepUnbundle(options.value))) {\n return validateExpression(extendBy({}, options, {\n expressionContext: 'filter',\n valueSpec: { value: 'boolean' }\n }));\n }\n else {\n return validateNonExpressionFilter(options);\n }\n}\nfunction validateNonExpressionFilter(options) {\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n const styleSpec = options.styleSpec;\n let type;\n let errors = [];\n if (value.length < 1) {\n return [new ValidationError(key, value, 'filter array must have at least 1 element')];\n }\n errors = errors.concat(validateEnum({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: styleSpec.filter_operator,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n switch (unbundle(value[0])) {\n case '<':\n case '<=':\n case '>':\n case '>=':\n if (value.length >= 2 && unbundle(value[1]) === '$type') {\n errors.push(new ValidationError(key, value, `\"$type\" cannot be use with operator \"${value[0]}\"`));\n }\n /* falls through */\n case '==':\n case '!=':\n if (value.length !== 3) {\n errors.push(new ValidationError(key, value, `filter array for operator \"${value[0]}\" must have 3 elements`));\n }\n /* falls through */\n case 'in':\n case '!in':\n if (value.length >= 2) {\n type = getType(value[1]);\n if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n }\n for (let i = 2; i < value.length; i++) {\n type = getType(value[i]);\n if (unbundle(value[1]) === '$type') {\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec.geometry_type,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));\n }\n }\n break;\n case 'any':\n case 'all':\n case 'none':\n for (let i = 1; i < value.length; i++) {\n errors = errors.concat(validateNonExpressionFilter({\n key: `${key}[${i}]`,\n value: value[i],\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n break;\n case 'has':\n case '!has':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n break;\n case 'within':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'object') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`));\n }\n break;\n }\n return errors;\n}\n\nfunction validateProperty(options, propertyType) {\n const key = options.key;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const value = options.value;\n const propertyKey = options.objectKey;\n const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];\n if (!layerSpec)\n return [];\n const transitionMatch = propertyKey.match(/^(.*)-transition$/);\n if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {\n return validateSpec({\n key,\n value,\n valueSpec: styleSpec.transition,\n style,\n styleSpec\n });\n }\n const valueSpec = options.valueSpec || layerSpec[propertyKey];\n if (!valueSpec) {\n return [new ValidationError(key, value, `unknown property \"${propertyKey}\"`)];\n }\n let tokenMatch;\n if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {\n return [new ValidationError(key, value, `\"${propertyKey}\" does not support interpolation syntax\\n` +\n `Use an identity property function instead: \\`{ \"type\": \"identity\", \"property\": ${JSON.stringify(tokenMatch[1])} }\\`.`)];\n }\n const errors = [];\n if (options.layerType === 'symbol') {\n if (propertyKey === 'text-field' && style && !style.glyphs) {\n errors.push(new ValidationError(key, value, 'use of \"text-field\" requires a style \"glyphs\" property'));\n }\n if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') {\n errors.push(new ValidationError(key, value, '\"text-font\" does not support identity functions'));\n }\n }\n return errors.concat(validateSpec({\n key: options.key,\n value,\n valueSpec,\n style,\n styleSpec,\n expressionContext: 'property',\n propertyType,\n propertyKey\n }));\n}\n\nfunction validatePaintProperty(options) {\n return validateProperty(options, 'paint');\n}\n\nfunction validateLayoutProperty(options) {\n return validateProperty(options, 'layout');\n}\n\nfunction validateLayer(options) {\n let errors = [];\n const layer = options.value;\n const key = options.key;\n const style = options.style;\n const styleSpec = options.styleSpec;\n if (!layer.type && !layer.ref) {\n errors.push(new ValidationError(key, layer, 'either \"type\" or \"ref\" is required'));\n }\n let type = unbundle(layer.type);\n const ref = unbundle(layer.ref);\n if (layer.id) {\n const layerId = unbundle(layer.id);\n for (let i = 0; i < options.arrayIndex; i++) {\n const otherLayer = style.layers[i];\n if (unbundle(otherLayer.id) === layerId) {\n errors.push(new ValidationError(key, layer.id, `duplicate layer id \"${layer.id}\", previously used at line ${otherLayer.id.__line__}`));\n }\n }\n }\n if ('ref' in layer) {\n ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => {\n if (p in layer) {\n errors.push(new ValidationError(key, layer[p], `\"${p}\" is prohibited for ref layers`));\n }\n });\n let parent;\n style.layers.forEach((layer) => {\n if (unbundle(layer.id) === ref)\n parent = layer;\n });\n if (!parent) {\n errors.push(new ValidationError(key, layer.ref, `ref layer \"${ref}\" not found`));\n }\n else if (parent.ref) {\n errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));\n }\n else {\n type = unbundle(parent.type);\n }\n }\n else if (type !== 'background') {\n if (!layer.source) {\n errors.push(new ValidationError(key, layer, 'missing required property \"source\"'));\n }\n else {\n const source = style.sources && style.sources[layer.source];\n const sourceType = source && unbundle(source.type);\n if (!source) {\n errors.push(new ValidationError(key, layer.source, `source \"${layer.source}\" not found`));\n }\n else if (sourceType === 'vector' && type === 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'hillshade') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType === 'raster' && type !== 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a vector source`));\n }\n else if (sourceType === 'vector' && !layer['source-layer']) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" must specify a \"source-layer\"`));\n }\n else if (sourceType === 'raster-dem' && type !== 'hillshade') {\n errors.push(new ValidationError(key, layer.source, 'raster-dem source can only be used with layer type \\'hillshade\\'.'));\n }\n else if (type === 'line' && layer.paint && layer.paint['line-gradient'] &&\n (sourceType !== 'geojson' || !source.lineMetrics)) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`));\n }\n }\n }\n errors = errors.concat(validateObject({\n key,\n value: layer,\n valueSpec: styleSpec.layer,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'() {\n return [];\n },\n // We don't want to enforce the spec's `\"requires\": true` for backward compatibility with refs;\n // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772.\n type() {\n return options.validateSpec({\n key: `${key}.type`,\n value: layer.type,\n valueSpec: styleSpec.layer.type,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n object: layer,\n objectKey: 'type'\n });\n },\n filter: validateFilter,\n layout(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validateLayoutProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n },\n paint(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validatePaintProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n }\n }\n }));\n return errors;\n}\n\nfunction validateString(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `string expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateRasterDEMSource(options) {\n var _a;\n const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';\n const rasterDEM = options.value;\n const styleSpec = options.styleSpec;\n const rasterDEMSpec = styleSpec.source_raster_dem;\n const style = options.style;\n let errors = [];\n const rootType = getType(rasterDEM);\n if (rasterDEM === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));\n return errors;\n }\n const encoding = unbundle(rasterDEM.encoding);\n const isCustomEncoding = encoding === 'custom';\n const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];\n const encodingName = options.value.encoding ? `\"${options.value.encoding}\"` : 'Default';\n for (const key in rasterDEM) {\n if (!isCustomEncoding && customEncodingKeys.includes(key)) {\n errors.push(new ValidationError(key, rasterDEM[key], `In \"${sourceName}\": \"${key}\" is only valid when \"encoding\" is set to \"custom\". ${encodingName} encoding found`));\n }\n else if (rasterDEMSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: rasterDEM[key],\n valueSpec: rasterDEMSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors.push(new ValidationError(key, rasterDEM[key], `unknown property \"${key}\"`));\n }\n }\n return errors;\n}\n\nconst objectElementValidators = {\n promoteId: validatePromoteId\n};\nfunction validateSource(options) {\n const value = options.value;\n const key = options.key;\n const styleSpec = options.styleSpec;\n const style = options.style;\n const validateSpec = options.validateSpec;\n if (!value.type) {\n return [new ValidationError(key, value, '\"type\" is required')];\n }\n const type = unbundle(value.type);\n let errors;\n switch (type) {\n case 'vector':\n case 'raster':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec[`source_${type.replace('-', '_')}`],\n style: options.style,\n styleSpec,\n objectElementValidators,\n validateSpec,\n });\n return errors;\n case 'raster-dem':\n errors = validateRasterDEMSource({\n sourceName: key,\n value,\n style: options.style,\n styleSpec,\n validateSpec,\n });\n return errors;\n case 'geojson':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec.source_geojson,\n style,\n styleSpec,\n validateSpec,\n objectElementValidators\n });\n if (value.cluster) {\n for (const prop in value.clusterProperties) {\n const [operator, mapExpr] = value.clusterProperties[prop];\n const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator;\n errors.push(...validateExpression({\n key: `${key}.${prop}.map`,\n value: mapExpr,\n validateSpec,\n expressionContext: 'cluster-map'\n }));\n errors.push(...validateExpression({\n key: `${key}.${prop}.reduce`,\n value: reduceExpr,\n validateSpec,\n expressionContext: 'cluster-reduce'\n }));\n }\n }\n return errors;\n case 'video':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_video,\n style,\n validateSpec,\n styleSpec\n });\n case 'image':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_image,\n style,\n validateSpec,\n styleSpec\n });\n case 'canvas':\n return [new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')];\n default:\n return validateEnum({\n key: `${key}.type`,\n value: value.type,\n valueSpec: { values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image'] },\n style,\n validateSpec,\n styleSpec\n });\n }\n}\nfunction validatePromoteId({ key, value }) {\n if (getType(value) === 'string') {\n return validateString({ key, value });\n }\n else {\n const errors = [];\n for (const prop in value) {\n errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] }));\n }\n return errors;\n }\n}\n\nfunction validateLight(options) {\n const light = options.value;\n const styleSpec = options.styleSpec;\n const lightSpec = styleSpec.light;\n const style = options.style;\n let errors = [];\n const rootType = getType(light);\n if (light === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in light) {\n const transitionMatch = key.match(/^(.*)-transition$/);\n if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: styleSpec.transition,\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else if (lightSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: lightSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, light[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateTerrain(options) {\n const terrain = options.value;\n const styleSpec = options.styleSpec;\n const terrainSpec = styleSpec.terrain;\n const style = options.style;\n let errors = [];\n const rootType = getType(terrain);\n if (terrain === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in terrain) {\n if (terrainSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: terrain[key],\n valueSpec: terrainSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, terrain[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateFormatted(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validateImage(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validatePadding(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1 || value.length > 4) {\n return [new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)];\n }\n const arrayElementSpec = {\n type: 'number'\n };\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateVariableAnchorOffsetCollection(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n const styleSpec = options.styleSpec;\n if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) {\n return [new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')];\n }\n let errors = [];\n for (let i = 0; i < value.length; i += 2) {\n // Elements in even positions should be values from text-anchor enum\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec['layout_symbol']['text-anchor']\n }));\n // Elements in odd positions should be points (2-element numeric arrays)\n errors = errors.concat(validateArray({\n key: `${key}[${i + 1}]`,\n value: value[i + 1],\n valueSpec: {\n length: 2,\n value: 'number'\n },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec\n }));\n }\n return errors;\n}\n\nfunction validateSprite(options) {\n let errors = [];\n const sprite = options.value;\n const key = options.key;\n if (!Array.isArray(sprite)) {\n return validateString({\n key,\n value: sprite\n });\n }\n else {\n const allSpriteIds = [];\n const allSpriteURLs = [];\n for (const i in sprite) {\n if (sprite[i].id && allSpriteIds.includes(sprite[i].id))\n errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`));\n allSpriteIds.push(sprite[i].id);\n if (sprite[i].url && allSpriteURLs.includes(sprite[i].url))\n errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`));\n allSpriteURLs.push(sprite[i].url);\n const pairSpec = {\n id: {\n type: 'string',\n required: true,\n },\n url: {\n type: 'string',\n required: true,\n }\n };\n errors = errors.concat(validateObject({\n key: `${key}[${i}]`,\n value: sprite[i],\n valueSpec: pairSpec,\n validateSpec: options.validateSpec,\n }));\n }\n return errors;\n }\n}\n\nconst VALIDATORS = {\n '*'() {\n return [];\n },\n 'array': validateArray,\n 'boolean': validateBoolean,\n 'number': validateNumber,\n 'color': validateColor,\n 'constants': validateConstants,\n 'enum': validateEnum,\n 'filter': validateFilter,\n 'function': validateFunction,\n 'layer': validateLayer,\n 'object': validateObject,\n 'source': validateSource,\n 'light': validateLight,\n 'terrain': validateTerrain,\n 'string': validateString,\n 'formatted': validateFormatted,\n 'resolvedImage': validateImage,\n 'padding': validatePadding,\n 'variableAnchorOffsetCollection': validateVariableAnchorOffsetCollection,\n 'sprite': validateSprite,\n};\n// Main recursive validation function. Tracks:\n//\n// - key: string representing location of validation in style tree. Used only\n// for more informative error reporting.\n// - value: current value from style being evaluated. May be anything from a\n// high level object that needs to be descended into deeper or a simple\n// scalar value.\n// - valueSpec: current spec being evaluated. Tracks value.\n// - styleSpec: current full spec being evaluated.\nfunction validate(options) {\n const value = options.value;\n const valueSpec = options.valueSpec;\n const styleSpec = options.styleSpec;\n options.validateSpec = validate;\n if (valueSpec.expression && isFunction(unbundle(value))) {\n return validateFunction(options);\n }\n else if (valueSpec.expression && isExpression(deepUnbundle(value))) {\n return validateExpression(options);\n }\n else if (valueSpec.type && VALIDATORS[valueSpec.type]) {\n return VALIDATORS[valueSpec.type](options);\n }\n else {\n const valid = validateObject(extendBy({}, options, {\n valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec\n }));\n return valid;\n }\n}\n\nfunction validateGlyphsUrl(options) {\n const value = options.value;\n const key = options.key;\n const errors = validateString(options);\n if (errors.length)\n return errors;\n if (value.indexOf('{fontstack}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{fontstack}\" token'));\n }\n if (value.indexOf('{range}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{range}\" token'));\n }\n return errors;\n}\n\n/**\n * Validate a MapLibre style against the style specification. This entrypoint,\n * `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as\n * small a browserify bundle as possible by omitting unnecessary functionality\n * and legacy style specifications.\n *\n * @private\n * @param {Object} style The style to be validated.\n * @param {Object} [styleSpec] The style specification to validate against.\n * If omitted, the latest style spec is used.\n * @returns {Array}\n * @example\n * var validate = require('maplibre-gl-style-spec/lib/validate_style.min');\n * var errors = validate(style);\n */\nfunction validateStyleMin(style, styleSpec = v8Spec) {\n let errors = [];\n errors = errors.concat(validate({\n key: '',\n value: style,\n valueSpec: styleSpec.$root,\n styleSpec,\n style,\n validateSpec: validate,\n objectElementValidators: {\n glyphs: validateGlyphsUrl,\n '*'() {\n return [];\n }\n }\n }));\n if (style['constants']) {\n errors = errors.concat(validateConstants({\n key: 'constants',\n value: style['constants'],\n style,\n styleSpec,\n validateSpec: validate,\n }));\n }\n return sortErrors(errors);\n}\nvalidateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource));\nvalidateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite));\nvalidateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl));\nvalidateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight));\nvalidateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain));\nvalidateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer));\nvalidateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter));\nvalidateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty));\nvalidateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty));\nfunction injectValidateSpec(validator) {\n return function (options) {\n return validator({\n ...options,\n validateSpec: validate,\n });\n };\n}\nfunction sortErrors(errors) {\n return [].concat(errors).sort((a, b) => {\n return a.line - b.line;\n });\n}\nfunction wrapCleanErrors(inner) {\n return function (...args) {\n return sortErrors(inner.apply(this, args));\n };\n}\n\nconst v8 = v8Spec;\nconst expression = {\n StyleExpression,\n StylePropertyFunction,\n ZoomConstantExpression,\n ZoomDependentExpression,\n createExpression,\n createPropertyExpression,\n isExpression,\n isExpressionFilter,\n isZoomExpression,\n normalizePropertyExpression,\n};\nconst styleFunction = {\n convertFunction,\n createFunction,\n isFunction\n};\nconst visit = { eachLayer, eachProperty, eachSource };\n\nexport { Color, ColorType, CompoundExpression, EvaluationContext, FormatExpression, Formatted, FormattedSection, FormattedType, Interpolate, Literal, NullType, Padding, ParsingError, ResolvedImage, Step, StyleExpression, StylePropertyFunction, ValidationError, VariableAnchorOffsetCollection, ZoomConstantExpression, ZoomDependentExpression, convertFilter, convertFunction, createExpression, createFunction, createPropertyExpression, derefLayers, diffStyles as diff, emptyStyle, expression, expressions, createFilter as featureFilter, styleFunction as function, groupByLayout, interpolateFactory, interpolate as interpolates, isExpression, isFunction, isZoomExpression, v8Spec as latest, normalizePropertyExpression, operations, supportsPropertyExpression, toString$1 as toString, typeOf, v8, validateStyleMin, visit };\n//# sourceMappingURL=index.mjs.map\n","import {validateStyleMin} from '@maplibre/maplibre-gl-style-spec';\nimport {ErrorEvent} from '../util/evented';\n\nimport type {Evented} from '../util/evented';\n\ntype ValidationError = {\n message: string;\n line: number;\n identifier?: string;\n};\n\nexport type Validator = (a: any) => ReadonlyArray;\n\ntype ValidateStyle = {\n source: Validator;\n sprite: Validator;\n glyphs: Validator;\n layer: Validator;\n light: Validator;\n terrain: Validator;\n filter: Validator;\n paintProperty: Validator;\n layoutProperty: Validator;\n (b: any, a?: any | null): ReadonlyArray;\n};\n\nexport const validateStyle = (validateStyleMin as unknown as ValidateStyle);\n\nexport const validateSource = validateStyle.source;\nexport const validateLight = validateStyle.light;\nexport const validateTerrain = validateStyle.terrain;\nexport const validateFilter = validateStyle.filter;\nexport const validatePaintProperty = validateStyle.paintProperty;\nexport const validateLayoutProperty = validateStyle.layoutProperty;\n\nexport function emitValidationErrors(\n emitter: Evented,\n errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n }> | null\n): boolean {\n let hasErrors = false;\n if (errors && errors.length) {\n for (const error of errors) {\n emitter.fire(new ErrorEvent(new Error(error.message)));\n hasErrors = true;\n }\n }\n return hasErrors;\n}\n","/*\nThis file was copied from https://github.com/mapbox/grid-index and was\nmigrated from JavaScript to TypeScript.\n\nCopyright (c) 2016, Mapbox\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n*/\n\nconst NUM_PARAMS = 3;\n\nexport type SerializedGrid = {\n buffer: ArrayBuffer;\n};\n\nexport class TransferableGridIndex {\n cells: number[][];\n arrayBuffer: ArrayBuffer;\n d: number;\n keys: number[];\n bboxes: number[];\n n: number;\n extent: number;\n padding: number;\n scale: any;\n uid: number;\n min: number;\n max: number;\n\n constructor(extent: number | ArrayBuffer, n?: number, padding?: number) {\n const cells = this.cells = [];\n\n if (extent instanceof ArrayBuffer) {\n this.arrayBuffer = extent;\n const array = new Int32Array(this.arrayBuffer);\n extent = array[0];\n n = array[1];\n padding = array[2];\n\n this.d = n + 2 * padding;\n for (let k = 0; k < this.d * this.d; k++) {\n const start = array[NUM_PARAMS + k];\n const end = array[NUM_PARAMS + k + 1];\n cells.push(start === end ? null : array.subarray(start, end));\n }\n const keysOffset = array[NUM_PARAMS + cells.length];\n const bboxesOffset = array[NUM_PARAMS + cells.length + 1];\n this.keys = array.subarray(keysOffset, bboxesOffset) as any as number[];\n this.bboxes = array.subarray(bboxesOffset) as any as number[];\n\n this.insert = this._insertReadonly;\n\n } else {\n this.d = n + 2 * padding;\n for (let i = 0; i < this.d * this.d; i++) {\n cells.push([]);\n }\n this.keys = [];\n this.bboxes = [];\n }\n\n this.n = n;\n this.extent = extent;\n this.padding = padding;\n this.scale = n / extent;\n this.uid = 0;\n\n const p = (padding / n) * extent;\n this.min = -p;\n this.max = extent + p;\n }\n\n insert(key: number, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined);\n this.keys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n _insertReadonly() {\n throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.');\n }\n\n _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.cells[cellIndex].push(uid);\n }\n\n query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[] {\n const min = this.min;\n const max = this.max;\n if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) {\n // We use `Array#slice` because `this.keys` may be a `Int32Array` and\n // some browsers (Safari and IE) do not support `TypedArray#slice`\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility\n return Array.prototype.slice.call(this.keys);\n\n } else {\n const result = [];\n const seenUids = {};\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest);\n return result;\n }\n }\n\n _queryCell(x1: number, y1: number, x2: number, y2:number, cellIndex:number, result, seenUids, intersectionTest: Function) {\n const cell = this.cells[cellIndex];\n if (cell !== null) {\n const keys = this.keys;\n const bboxes = this.bboxes;\n for (let u = 0; u < cell.length; u++) {\n const uid = cell[u];\n if (seenUids[uid] === undefined) {\n const offset = uid * 4;\n if (intersectionTest ?\n intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) :\n ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]))) {\n seenUids[uid] = true;\n result.push(keys[uid]);\n } else {\n seenUids[uid] = false;\n }\n }\n }\n }\n }\n\n _forEachCell(x1: number, y1: number, x2:number, y2:number, fn: Function, arg1, arg2, intersectionTest) {\n const cx1 = this._convertToCellCoord(x1);\n const cy1 = this._convertToCellCoord(y1);\n const cx2 = this._convertToCellCoord(x2);\n const cy2 = this._convertToCellCoord(y2);\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.d * y + x;\n if (intersectionTest && !intersectionTest(\n this._convertFromCellCoord(x),\n this._convertFromCellCoord(y),\n this._convertFromCellCoord(x + 1),\n this._convertFromCellCoord(y + 1))) continue;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) return;\n }\n }\n }\n\n _convertFromCellCoord (x) {\n return (x - this.padding) / this.scale;\n }\n\n _convertToCellCoord(x) {\n return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding));\n }\n\n toArrayBuffer(): ArrayBuffer {\n if (this.arrayBuffer) return this.arrayBuffer;\n\n const cells = this.cells;\n\n const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1;\n let totalCellLength = 0;\n for (let i = 0; i < this.cells.length; i++) {\n totalCellLength += this.cells[i].length;\n }\n\n const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length);\n array[0] = this.extent;\n array[1] = this.n;\n array[2] = this.padding;\n\n let offset = metadataLength;\n for (let k = 0; k < cells.length; k++) {\n const cell = cells[k];\n array[NUM_PARAMS + k] = offset;\n array.set(cell, offset);\n offset += cell.length;\n }\n\n array[NUM_PARAMS + cells.length] = offset;\n array.set(this.keys, offset);\n offset += this.keys.length;\n\n array[NUM_PARAMS + cells.length + 1] = offset;\n array.set(this.bboxes, offset);\n offset += this.bboxes.length;\n\n return array.buffer;\n }\n\n public static serialize(grid: TransferableGridIndex, transferables?: Array): SerializedGrid {\n const buffer = grid.toArrayBuffer();\n if (transferables) {\n transferables.push(buffer);\n }\n return {buffer};\n }\n\n public static deserialize(serialized: SerializedGrid): TransferableGridIndex {\n return new TransferableGridIndex(serialized.buffer);\n }\n}\n","import {TransferableGridIndex} from './transferable_grid_index';\nimport {Color, CompoundExpression, expressions, ResolvedImage, StylePropertyFunction,\n StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport {AJAXError} from './ajax';\n\nimport type {Transferable} from '../types/transferable';\nimport {isImageBitmap} from './util';\n\ntype SerializedObject = {\n [_: string]: S;\n};\n\nexport type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array | SerializedObject;\n\ntype Registry = {\n [_: string]: {\n klass: {\n new (...args: any): any;\n deserialize?: (input: Serialized) => unknown;\n };\n omit: ReadonlyArray;\n shallow: ReadonlyArray;\n };\n};\n\n/**\n * Register options\n */\ntype RegisterOptions = {\n /**\n * List of properties to omit from serialization (e.g., cached/computed properties)\n */\n omit?: ReadonlyArray;\n /**\n * List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize().\n */\n shallow?: ReadonlyArray;\n};\n\nconst registry: Registry = {};\n\n/**\n * Register the given class as serializable.\n *\n * @param options - the registration options\n */\nexport function register(\n name: string,\n klass: {\n new (...args: any): T;\n },\n options: RegisterOptions = {}\n) {\n if (registry[name]) throw new Error(`${name} is already registered.`);\n ((Object.defineProperty as any))(klass, '_classRegistryKey', {\n value: name,\n writeable: false\n });\n registry[name] = {\n klass,\n omit: options.omit as ReadonlyArray || [],\n shallow: options.shallow as ReadonlyArray || []\n };\n}\n\nregister('Object', Object);\nregister('TransferableGridIndex', TransferableGridIndex);\n\nregister('Color', Color);\nregister('Error', Error);\nregister('AJAXError', AJAXError);\nregister('ResolvedImage', ResolvedImage);\n\nregister('StylePropertyFunction', StylePropertyFunction);\nregister('StyleExpression', StyleExpression, {omit: ['_evaluator']});\n\nregister('ZoomDependentExpression', ZoomDependentExpression);\nregister('ZoomConstantExpression', ZoomConstantExpression);\nregister('CompoundExpression', CompoundExpression, {omit: ['_evaluate']});\nfor (const name in expressions) {\n if ((expressions[name] as any)._classRegistryKey) continue;\n register(`Expression_${name}`, expressions[name]);\n}\n\nfunction isArrayBuffer(value: any): value is ArrayBuffer {\n return value && typeof ArrayBuffer !== 'undefined' &&\n (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer'));\n}\n\n/**\n * Serialize the given object for transfer to or from a web worker.\n *\n * For non-builtin types, recursively serialize each property (possibly\n * omitting certain properties - see register()), and package the result along\n * with the constructor's `name` so that the appropriate constructor can be\n * looked up in `deserialize()`.\n *\n * If a `transferables` array is provided, add any transferable objects (i.e.,\n * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed,\n * this should happen in the client code, before using serialize().)\n */\nexport function serialize(input: unknown, transferables?: Array | null): Serialized {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob) {\n return input;\n }\n\n if (isArrayBuffer(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (isImageBitmap(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (ArrayBuffer.isView(input)) {\n const view = input;\n if (transferables) {\n transferables.push(view.buffer);\n }\n return view;\n }\n\n if (input instanceof ImageData) {\n if (transferables) {\n transferables.push(input.data.buffer);\n }\n return input;\n }\n\n if (Array.isArray(input)) {\n const serialized: Array = [];\n for (const item of input) {\n serialized.push(serialize(item, transferables));\n }\n return serialized;\n }\n\n if (typeof input === 'object') {\n const klass = (input.constructor as any);\n const name = klass._classRegistryKey;\n if (!name) {\n throw new Error('can\\'t serialize object of unregistered class');\n }\n if (!registry[name]) throw new Error(`${name} is not registered.`);\n\n const properties: SerializedObject = klass.serialize ?\n // (Temporary workaround) allow a class to provide static\n // `serialize()` and `deserialize()` methods to bypass the generic\n // approach.\n // This temporary workaround lets us use the generic serialization\n // approach for objects whose members include instances of dynamic\n // StructArray types. Once we refactor StructArray to be static,\n // we can remove this complexity.\n (klass.serialize(input, transferables) as SerializedObject) : {};\n\n if (!klass.serialize) {\n for (const key in input) {\n if (!input.hasOwnProperty(key)) continue; // eslint-disable-line no-prototype-builtins\n if (registry[name].omit.indexOf(key) >= 0) continue;\n const property = input[key];\n properties[key] = registry[name].shallow.indexOf(key) >= 0 ?\n property :\n serialize(property, transferables);\n }\n if (input instanceof Error) {\n properties.message = input.message;\n }\n } else {\n if (transferables && properties === transferables[transferables.length - 1]) {\n throw new Error('statically serialized object won\\'t survive transfer of $name property');\n }\n }\n\n if (properties.$name) {\n throw new Error('$name property is reserved for worker serialization logic.');\n }\n if (name !== 'Object') {\n properties.$name = name;\n }\n\n return properties;\n }\n\n throw new Error(`can't serialize object of type ${typeof input}`);\n}\n\nexport function deserialize(input: Serialized): unknown {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob ||\n isArrayBuffer(input) ||\n isImageBitmap(input) ||\n ArrayBuffer.isView(input) ||\n input instanceof ImageData) {\n return input;\n }\n\n if (Array.isArray(input)) {\n return input.map(deserialize);\n }\n\n if (typeof input === 'object') {\n const name = input.$name || 'Object';\n if (!registry[name]) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n const {klass} = registry[name];\n if (!klass) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n\n if (klass.deserialize) {\n return klass.deserialize(input);\n }\n\n const result = Object.create(klass.prototype);\n\n for (const key of Object.keys(input)) {\n if (key === '$name') continue;\n const value = (input as SerializedObject)[key];\n result[key] = registry[name].shallow.indexOf(key) >= 0 ? value : deserialize(value);\n }\n\n return result;\n }\n\n throw new Error(`can't deserialize object of type ${typeof input}`);\n}\n","export class ZoomHistory {\n lastZoom: number;\n lastFloorZoom: number;\n lastIntegerZoom: number;\n lastIntegerZoomTime: number;\n first: boolean;\n\n constructor() {\n this.first = true;\n }\n\n update(z: number, now: number) {\n const floorZ = Math.floor(z);\n\n if (this.first) {\n this.first = false;\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = 0;\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n if (this.lastFloorZoom > floorZ) {\n this.lastIntegerZoom = floorZ + 1;\n this.lastIntegerZoomTime = now;\n } else if (this.lastFloorZoom < floorZ) {\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = now;\n }\n\n if (z !== this.lastZoom) {\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n return false;\n }\n}\n","// The following table comes from .\n// Keep it synchronized with .\n\ntype UnicodeBlockLookup = {[key: string]: (char: number) => boolean};\n\nexport const unicodeBlockLookup: UnicodeBlockLookup = {\n // 'Basic Latin': (char) => char >= 0x0000 && char <= 0x007F,\n 'Latin-1 Supplement': (char) => char >= 0x0080 && char <= 0x00FF,\n // 'Latin Extended-A': (char) => char >= 0x0100 && char <= 0x017F,\n // 'Latin Extended-B': (char) => char >= 0x0180 && char <= 0x024F,\n // 'IPA Extensions': (char) => char >= 0x0250 && char <= 0x02AF,\n // 'Spacing Modifier Letters': (char) => char >= 0x02B0 && char <= 0x02FF,\n // 'Combining Diacritical Marks': (char) => char >= 0x0300 && char <= 0x036F,\n // 'Greek and Coptic': (char) => char >= 0x0370 && char <= 0x03FF,\n // 'Cyrillic': (char) => char >= 0x0400 && char <= 0x04FF,\n // 'Cyrillic Supplement': (char) => char >= 0x0500 && char <= 0x052F,\n // 'Armenian': (char) => char >= 0x0530 && char <= 0x058F,\n //'Hebrew': (char) => char >= 0x0590 && char <= 0x05FF,\n 'Arabic': (char) => char >= 0x0600 && char <= 0x06FF,\n //'Syriac': (char) => char >= 0x0700 && char <= 0x074F,\n 'Arabic Supplement': (char) => char >= 0x0750 && char <= 0x077F,\n // 'Thaana': (char) => char >= 0x0780 && char <= 0x07BF,\n // 'NKo': (char) => char >= 0x07C0 && char <= 0x07FF,\n // 'Samaritan': (char) => char >= 0x0800 && char <= 0x083F,\n // 'Mandaic': (char) => char >= 0x0840 && char <= 0x085F,\n // 'Syriac Supplement': (char) => char >= 0x0860 && char <= 0x086F,\n 'Arabic Extended-A': (char) => char >= 0x08A0 && char <= 0x08FF,\n // 'Devanagari': (char) => char >= 0x0900 && char <= 0x097F,\n // 'Bengali': (char) => char >= 0x0980 && char <= 0x09FF,\n // 'Gurmukhi': (char) => char >= 0x0A00 && char <= 0x0A7F,\n // 'Gujarati': (char) => char >= 0x0A80 && char <= 0x0AFF,\n // 'Oriya': (char) => char >= 0x0B00 && char <= 0x0B7F,\n // 'Tamil': (char) => char >= 0x0B80 && char <= 0x0BFF,\n // 'Telugu': (char) => char >= 0x0C00 && char <= 0x0C7F,\n // 'Kannada': (char) => char >= 0x0C80 && char <= 0x0CFF,\n // 'Malayalam': (char) => char >= 0x0D00 && char <= 0x0D7F,\n // 'Sinhala': (char) => char >= 0x0D80 && char <= 0x0DFF,\n // 'Thai': (char) => char >= 0x0E00 && char <= 0x0E7F,\n // 'Lao': (char) => char >= 0x0E80 && char <= 0x0EFF,\n // 'Tibetan': (char) => char >= 0x0F00 && char <= 0x0FFF,\n // 'Myanmar': (char) => char >= 0x1000 && char <= 0x109F,\n // 'Georgian': (char) => char >= 0x10A0 && char <= 0x10FF,\n 'Hangul Jamo': (char) => char >= 0x1100 && char <= 0x11FF,\n // 'Ethiopic': (char) => char >= 0x1200 && char <= 0x137F,\n // 'Ethiopic Supplement': (char) => char >= 0x1380 && char <= 0x139F,\n // 'Cherokee': (char) => char >= 0x13A0 && char <= 0x13FF,\n 'Unified Canadian Aboriginal Syllabics': (char) => char >= 0x1400 && char <= 0x167F,\n // 'Ogham': (char) => char >= 0x1680 && char <= 0x169F,\n // 'Runic': (char) => char >= 0x16A0 && char <= 0x16FF,\n // 'Tagalog': (char) => char >= 0x1700 && char <= 0x171F,\n // 'Hanunoo': (char) => char >= 0x1720 && char <= 0x173F,\n // 'Buhid': (char) => char >= 0x1740 && char <= 0x175F,\n // 'Tagbanwa': (char) => char >= 0x1760 && char <= 0x177F,\n 'Khmer': (char) => char >= 0x1780 && char <= 0x17FF,\n // 'Mongolian': (char) => char >= 0x1800 && char <= 0x18AF,\n 'Unified Canadian Aboriginal Syllabics Extended': (char) => char >= 0x18B0 && char <= 0x18FF,\n // 'Limbu': (char) => char >= 0x1900 && char <= 0x194F,\n // 'Tai Le': (char) => char >= 0x1950 && char <= 0x197F,\n // 'New Tai Lue': (char) => char >= 0x1980 && char <= 0x19DF,\n // 'Khmer Symbols': (char) => char >= 0x19E0 && char <= 0x19FF,\n // 'Buginese': (char) => char >= 0x1A00 && char <= 0x1A1F,\n // 'Tai Tham': (char) => char >= 0x1A20 && char <= 0x1AAF,\n // 'Combining Diacritical Marks Extended': (char) => char >= 0x1AB0 && char <= 0x1AFF,\n // 'Balinese': (char) => char >= 0x1B00 && char <= 0x1B7F,\n // 'Sundanese': (char) => char >= 0x1B80 && char <= 0x1BBF,\n // 'Batak': (char) => char >= 0x1BC0 && char <= 0x1BFF,\n // 'Lepcha': (char) => char >= 0x1C00 && char <= 0x1C4F,\n // 'Ol Chiki': (char) => char >= 0x1C50 && char <= 0x1C7F,\n // 'Cyrillic Extended-C': (char) => char >= 0x1C80 && char <= 0x1C8F,\n // 'Georgian Extended': (char) => char >= 0x1C90 && char <= 0x1CBF,\n // 'Sundanese Supplement': (char) => char >= 0x1CC0 && char <= 0x1CCF,\n // 'Vedic Extensions': (char) => char >= 0x1CD0 && char <= 0x1CFF,\n // 'Phonetic Extensions': (char) => char >= 0x1D00 && char <= 0x1D7F,\n // 'Phonetic Extensions Supplement': (char) => char >= 0x1D80 && char <= 0x1DBF,\n // 'Combining Diacritical Marks Supplement': (char) => char >= 0x1DC0 && char <= 0x1DFF,\n // 'Latin Extended Additional': (char) => char >= 0x1E00 && char <= 0x1EFF,\n // 'Greek Extended': (char) => char >= 0x1F00 && char <= 0x1FFF,\n 'General Punctuation': (char) => char >= 0x2000 && char <= 0x206F,\n // 'Superscripts and Subscripts': (char) => char >= 0x2070 && char <= 0x209F,\n // 'Currency Symbols': (char) => char >= 0x20A0 && char <= 0x20CF,\n // 'Combining Diacritical Marks for Symbols': (char) => char >= 0x20D0 && char <= 0x20FF,\n 'Letterlike Symbols': (char) => char >= 0x2100 && char <= 0x214F,\n 'Number Forms': (char) => char >= 0x2150 && char <= 0x218F,\n // 'Arrows': (char) => char >= 0x2190 && char <= 0x21FF,\n // 'Mathematical Operators': (char) => char >= 0x2200 && char <= 0x22FF,\n 'Miscellaneous Technical': (char) => char >= 0x2300 && char <= 0x23FF,\n 'Control Pictures': (char) => char >= 0x2400 && char <= 0x243F,\n 'Optical Character Recognition': (char) => char >= 0x2440 && char <= 0x245F,\n 'Enclosed Alphanumerics': (char) => char >= 0x2460 && char <= 0x24FF,\n // 'Box Drawing': (char) => char >= 0x2500 && char <= 0x257F,\n // 'Block Elements': (char) => char >= 0x2580 && char <= 0x259F,\n 'Geometric Shapes': (char) => char >= 0x25A0 && char <= 0x25FF,\n 'Miscellaneous Symbols': (char) => char >= 0x2600 && char <= 0x26FF,\n // 'Dingbats': (char) => char >= 0x2700 && char <= 0x27BF,\n // 'Miscellaneous Mathematical Symbols-A': (char) => char >= 0x27C0 && char <= 0x27EF,\n // 'Supplemental Arrows-A': (char) => char >= 0x27F0 && char <= 0x27FF,\n // 'Braille Patterns': (char) => char >= 0x2800 && char <= 0x28FF,\n // 'Supplemental Arrows-B': (char) => char >= 0x2900 && char <= 0x297F,\n // 'Miscellaneous Mathematical Symbols-B': (char) => char >= 0x2980 && char <= 0x29FF,\n // 'Supplemental Mathematical Operators': (char) => char >= 0x2A00 && char <= 0x2AFF,\n 'Miscellaneous Symbols and Arrows': (char) => char >= 0x2B00 && char <= 0x2BFF,\n // 'Glagolitic': (char) => char >= 0x2C00 && char <= 0x2C5F,\n // 'Latin Extended-C': (char) => char >= 0x2C60 && char <= 0x2C7F,\n // 'Coptic': (char) => char >= 0x2C80 && char <= 0x2CFF,\n // 'Georgian Supplement': (char) => char >= 0x2D00 && char <= 0x2D2F,\n // 'Tifinagh': (char) => char >= 0x2D30 && char <= 0x2D7F,\n // 'Ethiopic Extended': (char) => char >= 0x2D80 && char <= 0x2DDF,\n // 'Cyrillic Extended-A': (char) => char >= 0x2DE0 && char <= 0x2DFF,\n // 'Supplemental Punctuation': (char) => char >= 0x2E00 && char <= 0x2E7F,\n 'CJK Radicals Supplement': (char) => char >= 0x2E80 && char <= 0x2EFF,\n 'Kangxi Radicals': (char) => char >= 0x2F00 && char <= 0x2FDF,\n 'Ideographic Description Characters': (char) => char >= 0x2FF0 && char <= 0x2FFF,\n 'CJK Symbols and Punctuation': (char) => char >= 0x3000 && char <= 0x303F,\n 'Hiragana': (char) => char >= 0x3040 && char <= 0x309F,\n 'Katakana': (char) => char >= 0x30A0 && char <= 0x30FF,\n 'Bopomofo': (char) => char >= 0x3100 && char <= 0x312F,\n 'Hangul Compatibility Jamo': (char) => char >= 0x3130 && char <= 0x318F,\n 'Kanbun': (char) => char >= 0x3190 && char <= 0x319F,\n 'Bopomofo Extended': (char) => char >= 0x31A0 && char <= 0x31BF,\n 'CJK Strokes': (char) => char >= 0x31C0 && char <= 0x31EF,\n 'Katakana Phonetic Extensions': (char) => char >= 0x31F0 && char <= 0x31FF,\n 'Enclosed CJK Letters and Months': (char) => char >= 0x3200 && char <= 0x32FF,\n 'CJK Compatibility': (char) => char >= 0x3300 && char <= 0x33FF,\n 'CJK Unified Ideographs Extension A': (char) => char >= 0x3400 && char <= 0x4DBF,\n 'Yijing Hexagram Symbols': (char) => char >= 0x4DC0 && char <= 0x4DFF,\n 'CJK Unified Ideographs': (char) => char >= 0x4E00 && char <= 0x9FFF,\n 'Yi Syllables': (char) => char >= 0xA000 && char <= 0xA48F,\n 'Yi Radicals': (char) => char >= 0xA490 && char <= 0xA4CF,\n // 'Lisu': (char) => char >= 0xA4D0 && char <= 0xA4FF,\n // 'Vai': (char) => char >= 0xA500 && char <= 0xA63F,\n // 'Cyrillic Extended-B': (char) => char >= 0xA640 && char <= 0xA69F,\n // 'Bamum': (char) => char >= 0xA6A0 && char <= 0xA6FF,\n // 'Modifier Tone Letters': (char) => char >= 0xA700 && char <= 0xA71F,\n // 'Latin Extended-D': (char) => char >= 0xA720 && char <= 0xA7FF,\n // 'Syloti Nagri': (char) => char >= 0xA800 && char <= 0xA82F,\n // 'Common Indic Number Forms': (char) => char >= 0xA830 && char <= 0xA83F,\n // 'Phags-pa': (char) => char >= 0xA840 && char <= 0xA87F,\n // 'Saurashtra': (char) => char >= 0xA880 && char <= 0xA8DF,\n // 'Devanagari Extended': (char) => char >= 0xA8E0 && char <= 0xA8FF,\n // 'Kayah Li': (char) => char >= 0xA900 && char <= 0xA92F,\n // 'Rejang': (char) => char >= 0xA930 && char <= 0xA95F,\n 'Hangul Jamo Extended-A': (char) => char >= 0xA960 && char <= 0xA97F,\n // 'Javanese': (char) => char >= 0xA980 && char <= 0xA9DF,\n // 'Myanmar Extended-B': (char) => char >= 0xA9E0 && char <= 0xA9FF,\n // 'Cham': (char) => char >= 0xAA00 && char <= 0xAA5F,\n // 'Myanmar Extended-A': (char) => char >= 0xAA60 && char <= 0xAA7F,\n // 'Tai Viet': (char) => char >= 0xAA80 && char <= 0xAADF,\n // 'Meetei Mayek Extensions': (char) => char >= 0xAAE0 && char <= 0xAAFF,\n // 'Ethiopic Extended-A': (char) => char >= 0xAB00 && char <= 0xAB2F,\n // 'Latin Extended-E': (char) => char >= 0xAB30 && char <= 0xAB6F,\n // 'Cherokee Supplement': (char) => char >= 0xAB70 && char <= 0xABBF,\n // 'Meetei Mayek': (char) => char >= 0xABC0 && char <= 0xABFF,\n 'Hangul Syllables': (char) => char >= 0xAC00 && char <= 0xD7AF,\n 'Hangul Jamo Extended-B': (char) => char >= 0xD7B0 && char <= 0xD7FF,\n // 'High Surrogates': (char) => char >= 0xD800 && char <= 0xDB7F,\n // 'High Private Use Surrogates': (char) => char >= 0xDB80 && char <= 0xDBFF,\n // 'Low Surrogates': (char) => char >= 0xDC00 && char <= 0xDFFF,\n 'Private Use Area': (char) => char >= 0xE000 && char <= 0xF8FF,\n 'CJK Compatibility Ideographs': (char) => char >= 0xF900 && char <= 0xFAFF,\n // 'Alphabetic Presentation Forms': (char) => char >= 0xFB00 && char <= 0xFB4F,\n 'Arabic Presentation Forms-A': (char) => char >= 0xFB50 && char <= 0xFDFF,\n // 'Variation Selectors': (char) => char >= 0xFE00 && char <= 0xFE0F,\n 'Vertical Forms': (char) => char >= 0xFE10 && char <= 0xFE1F,\n // 'Combining Half Marks': (char) => char >= 0xFE20 && char <= 0xFE2F,\n 'CJK Compatibility Forms': (char) => char >= 0xFE30 && char <= 0xFE4F,\n 'Small Form Variants': (char) => char >= 0xFE50 && char <= 0xFE6F,\n 'Arabic Presentation Forms-B': (char) => char >= 0xFE70 && char <= 0xFEFF,\n 'Halfwidth and Fullwidth Forms': (char) => char >= 0xFF00 && char <= 0xFFEF\n // 'Specials': (char) => char >= 0xFFF0 && char <= 0xFFFF,\n // 'Linear B Syllabary': (char) => char >= 0x10000 && char <= 0x1007F,\n // 'Linear B Ideograms': (char) => char >= 0x10080 && char <= 0x100FF,\n // 'Aegean Numbers': (char) => char >= 0x10100 && char <= 0x1013F,\n // 'Ancient Greek Numbers': (char) => char >= 0x10140 && char <= 0x1018F,\n // 'Ancient Symbols': (char) => char >= 0x10190 && char <= 0x101CF,\n // 'Phaistos Disc': (char) => char >= 0x101D0 && char <= 0x101FF,\n // 'Lycian': (char) => char >= 0x10280 && char <= 0x1029F,\n // 'Carian': (char) => char >= 0x102A0 && char <= 0x102DF,\n // 'Coptic Epact Numbers': (char) => char >= 0x102E0 && char <= 0x102FF,\n // 'Old Italic': (char) => char >= 0x10300 && char <= 0x1032F,\n // 'Gothic': (char) => char >= 0x10330 && char <= 0x1034F,\n // 'Old Permic': (char) => char >= 0x10350 && char <= 0x1037F,\n // 'Ugaritic': (char) => char >= 0x10380 && char <= 0x1039F,\n // 'Old Persian': (char) => char >= 0x103A0 && char <= 0x103DF,\n // 'Deseret': (char) => char >= 0x10400 && char <= 0x1044F,\n // 'Shavian': (char) => char >= 0x10450 && char <= 0x1047F,\n // 'Osmanya': (char) => char >= 0x10480 && char <= 0x104AF,\n // 'Osage': (char) => char >= 0x104B0 && char <= 0x104FF,\n // 'Elbasan': (char) => char >= 0x10500 && char <= 0x1052F,\n // 'Caucasian Albanian': (char) => char >= 0x10530 && char <= 0x1056F,\n // 'Linear A': (char) => char >= 0x10600 && char <= 0x1077F,\n // 'Cypriot Syllabary': (char) => char >= 0x10800 && char <= 0x1083F,\n // 'Imperial Aramaic': (char) => char >= 0x10840 && char <= 0x1085F,\n // 'Palmyrene': (char) => char >= 0x10860 && char <= 0x1087F,\n // 'Nabataean': (char) => char >= 0x10880 && char <= 0x108AF,\n // 'Hatran': (char) => char >= 0x108E0 && char <= 0x108FF,\n // 'Phoenician': (char) => char >= 0x10900 && char <= 0x1091F,\n // 'Lydian': (char) => char >= 0x10920 && char <= 0x1093F,\n // 'Meroitic Hieroglyphs': (char) => char >= 0x10980 && char <= 0x1099F,\n // 'Meroitic Cursive': (char) => char >= 0x109A0 && char <= 0x109FF,\n // 'Kharoshthi': (char) => char >= 0x10A00 && char <= 0x10A5F,\n // 'Old South Arabian': (char) => char >= 0x10A60 && char <= 0x10A7F,\n // 'Old North Arabian': (char) => char >= 0x10A80 && char <= 0x10A9F,\n // 'Manichaean': (char) => char >= 0x10AC0 && char <= 0x10AFF,\n // 'Avestan': (char) => char >= 0x10B00 && char <= 0x10B3F,\n // 'Inscriptional Parthian': (char) => char >= 0x10B40 && char <= 0x10B5F,\n // 'Inscriptional Pahlavi': (char) => char >= 0x10B60 && char <= 0x10B7F,\n // 'Psalter Pahlavi': (char) => char >= 0x10B80 && char <= 0x10BAF,\n // 'Old Turkic': (char) => char >= 0x10C00 && char <= 0x10C4F,\n // 'Old Hungarian': (char) => char >= 0x10C80 && char <= 0x10CFF,\n // 'Hanifi Rohingya': (char) => char >= 0x10D00 && char <= 0x10D3F,\n // 'Rumi Numeral Symbols': (char) => char >= 0x10E60 && char <= 0x10E7F,\n // 'Old Sogdian': (char) => char >= 0x10F00 && char <= 0x10F2F,\n // 'Sogdian': (char) => char >= 0x10F30 && char <= 0x10F6F,\n // 'Elymaic': (char) => char >= 0x10FE0 && char <= 0x10FFF,\n // 'Brahmi': (char) => char >= 0x11000 && char <= 0x1107F,\n // 'Kaithi': (char) => char >= 0x11080 && char <= 0x110CF,\n // 'Sora Sompeng': (char) => char >= 0x110D0 && char <= 0x110FF,\n // 'Chakma': (char) => char >= 0x11100 && char <= 0x1114F,\n // 'Mahajani': (char) => char >= 0x11150 && char <= 0x1117F,\n // 'Sharada': (char) => char >= 0x11180 && char <= 0x111DF,\n // 'Sinhala Archaic Numbers': (char) => char >= 0x111E0 && char <= 0x111FF,\n // 'Khojki': (char) => char >= 0x11200 && char <= 0x1124F,\n // 'Multani': (char) => char >= 0x11280 && char <= 0x112AF,\n // 'Khudawadi': (char) => char >= 0x112B0 && char <= 0x112FF,\n // 'Grantha': (char) => char >= 0x11300 && char <= 0x1137F,\n // 'Newa': (char) => char >= 0x11400 && char <= 0x1147F,\n // 'Tirhuta': (char) => char >= 0x11480 && char <= 0x114DF,\n // 'Siddham': (char) => char >= 0x11580 && char <= 0x115FF,\n // 'Modi': (char) => char >= 0x11600 && char <= 0x1165F,\n // 'Mongolian Supplement': (char) => char >= 0x11660 && char <= 0x1167F,\n // 'Takri': (char) => char >= 0x11680 && char <= 0x116CF,\n // 'Ahom': (char) => char >= 0x11700 && char <= 0x1173F,\n // 'Dogra': (char) => char >= 0x11800 && char <= 0x1184F,\n // 'Warang Citi': (char) => char >= 0x118A0 && char <= 0x118FF,\n // 'Nandinagari': (char) => char >= 0x119A0 && char <= 0x119FF,\n // 'Zanabazar Square': (char) => char >= 0x11A00 && char <= 0x11A4F,\n // 'Soyombo': (char) => char >= 0x11A50 && char <= 0x11AAF,\n // 'Pau Cin Hau': (char) => char >= 0x11AC0 && char <= 0x11AFF,\n // 'Bhaiksuki': (char) => char >= 0x11C00 && char <= 0x11C6F,\n // 'Marchen': (char) => char >= 0x11C70 && char <= 0x11CBF,\n // 'Masaram Gondi': (char) => char >= 0x11D00 && char <= 0x11D5F,\n // 'Gunjala Gondi': (char) => char >= 0x11D60 && char <= 0x11DAF,\n // 'Makasar': (char) => char >= 0x11EE0 && char <= 0x11EFF,\n // 'Tamil Supplement': (char) => char >= 0x11FC0 && char <= 0x11FFF,\n // 'Cuneiform': (char) => char >= 0x12000 && char <= 0x123FF,\n // 'Cuneiform Numbers and Punctuation': (char) => char >= 0x12400 && char <= 0x1247F,\n // 'Early Dynastic Cuneiform': (char) => char >= 0x12480 && char <= 0x1254F,\n // 'Egyptian Hieroglyphs': (char) => char >= 0x13000 && char <= 0x1342F,\n // 'Egyptian Hieroglyph Format Controls': (char) => char >= 0x13430 && char <= 0x1343F,\n // 'Anatolian Hieroglyphs': (char) => char >= 0x14400 && char <= 0x1467F,\n // 'Bamum Supplement': (char) => char >= 0x16800 && char <= 0x16A3F,\n // 'Mro': (char) => char >= 0x16A40 && char <= 0x16A6F,\n // 'Bassa Vah': (char) => char >= 0x16AD0 && char <= 0x16AFF,\n // 'Pahawh Hmong': (char) => char >= 0x16B00 && char <= 0x16B8F,\n // 'Medefaidrin': (char) => char >= 0x16E40 && char <= 0x16E9F,\n // 'Miao': (char) => char >= 0x16F00 && char <= 0x16F9F,\n // 'Ideographic Symbols and Punctuation': (char) => char >= 0x16FE0 && char <= 0x16FFF,\n // 'Tangut': (char) => char >= 0x17000 && char <= 0x187FF,\n // 'Tangut Components': (char) => char >= 0x18800 && char <= 0x18AFF,\n // 'Kana Supplement': (char) => char >= 0x1B000 && char <= 0x1B0FF,\n // 'Kana Extended-A': (char) => char >= 0x1B100 && char <= 0x1B12F,\n // 'Small Kana Extension': (char) => char >= 0x1B130 && char <= 0x1B16F,\n // 'Nushu': (char) => char >= 0x1B170 && char <= 0x1B2FF,\n // 'Duployan': (char) => char >= 0x1BC00 && char <= 0x1BC9F,\n // 'Shorthand Format Controls': (char) => char >= 0x1BCA0 && char <= 0x1BCAF,\n // 'Byzantine Musical Symbols': (char) => char >= 0x1D000 && char <= 0x1D0FF,\n // 'Musical Symbols': (char) => char >= 0x1D100 && char <= 0x1D1FF,\n // 'Ancient Greek Musical Notation': (char) => char >= 0x1D200 && char <= 0x1D24F,\n // 'Mayan Numerals': (char) => char >= 0x1D2E0 && char <= 0x1D2FF,\n // 'Tai Xuan Jing Symbols': (char) => char >= 0x1D300 && char <= 0x1D35F,\n // 'Counting Rod Numerals': (char) => char >= 0x1D360 && char <= 0x1D37F,\n // 'Mathematical Alphanumeric Symbols': (char) => char >= 0x1D400 && char <= 0x1D7FF,\n // 'Sutton SignWriting': (char) => char >= 0x1D800 && char <= 0x1DAAF,\n // 'Glagolitic Supplement': (char) => char >= 0x1E000 && char <= 0x1E02F,\n // 'Nyiakeng Puachue Hmong': (char) => char >= 0x1E100 && char <= 0x1E14F,\n // 'Wancho': (char) => char >= 0x1E2C0 && char <= 0x1E2FF,\n // 'Mende Kikakui': (char) => char >= 0x1E800 && char <= 0x1E8DF,\n // 'Adlam': (char) => char >= 0x1E900 && char <= 0x1E95F,\n // 'Indic Siyaq Numbers': (char) => char >= 0x1EC70 && char <= 0x1ECBF,\n // 'Ottoman Siyaq Numbers': (char) => char >= 0x1ED00 && char <= 0x1ED4F,\n // 'Arabic Mathematical Alphabetic Symbols': (char) => char >= 0x1EE00 && char <= 0x1EEFF,\n // 'Mahjong Tiles': (char) => char >= 0x1F000 && char <= 0x1F02F,\n // 'Domino Tiles': (char) => char >= 0x1F030 && char <= 0x1F09F,\n // 'Playing Cards': (char) => char >= 0x1F0A0 && char <= 0x1F0FF,\n // 'Enclosed Alphanumeric Supplement': (char) => char >= 0x1F100 && char <= 0x1F1FF,\n // 'Enclosed Ideographic Supplement': (char) => char >= 0x1F200 && char <= 0x1F2FF,\n // 'Miscellaneous Symbols and Pictographs': (char) => char >= 0x1F300 && char <= 0x1F5FF,\n // 'Emoticons': (char) => char >= 0x1F600 && char <= 0x1F64F,\n // 'Ornamental Dingbats': (char) => char >= 0x1F650 && char <= 0x1F67F,\n // 'Transport and Map Symbols': (char) => char >= 0x1F680 && char <= 0x1F6FF,\n // 'Alchemical Symbols': (char) => char >= 0x1F700 && char <= 0x1F77F,\n // 'Geometric Shapes Extended': (char) => char >= 0x1F780 && char <= 0x1F7FF,\n // 'Supplemental Arrows-C': (char) => char >= 0x1F800 && char <= 0x1F8FF,\n // 'Supplemental Symbols and Pictographs': (char) => char >= 0x1F900 && char <= 0x1F9FF,\n // 'Chess Symbols': (char) => char >= 0x1FA00 && char <= 0x1FA6F,\n // 'Symbols and Pictographs Extended-A': (char) => char >= 0x1FA70 && char <= 0x1FAFF,\n // 'CJK Unified Ideographs Extension B': (char) => char >= 0x20000 && char <= 0x2A6DF,\n // 'CJK Unified Ideographs Extension C': (char) => char >= 0x2A700 && char <= 0x2B73F,\n // 'CJK Unified Ideographs Extension D': (char) => char >= 0x2B740 && char <= 0x2B81F,\n // 'CJK Unified Ideographs Extension E': (char) => char >= 0x2B820 && char <= 0x2CEAF,\n // 'CJK Unified Ideographs Extension F': (char) => char >= 0x2CEB0 && char <= 0x2EBEF,\n // 'CJK Compatibility Ideographs Supplement': (char) => char >= 0x2F800 && char <= 0x2FA1F,\n // 'Tags': (char) => char >= 0xE0000 && char <= 0xE007F,\n // 'Variation Selectors Supplement': (char) => char >= 0xE0100 && char <= 0xE01EF,\n // 'Supplementary Private Use Area-A': (char) => char >= 0xF0000 && char <= 0xFFFFF,\n // 'Supplementary Private Use Area-B': (char) => char >= 0x100000 && char <= 0x10FFFF,\n};\n","/* eslint-disable new-cap */\n\nimport {unicodeBlockLookup as isChar} from './is_char_in_unicode_block';\n\nexport function allowsIdeographicBreaking(chars: string) {\n for (const char of chars) {\n if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function allowsVerticalWritingMode(chars: string) {\n for (const char of chars) {\n if (charHasUprightVerticalOrientation(char.charCodeAt(0))) return true;\n }\n return false;\n}\n\nexport function allowsLetterSpacing(chars: string) {\n for (const char of chars) {\n if (!charAllowsLetterSpacing(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function charAllowsLetterSpacing(char: number) {\n if (isChar['Arabic'](char)) return false;\n if (isChar['Arabic Supplement'](char)) return false;\n if (isChar['Arabic Extended-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-B'](char)) return false;\n\n return true;\n}\n\nexport function charAllowsIdeographicBreaking(char: number) {\n // Return early for characters outside all ideographic ranges.\n if (char < 0x2E80) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n\n return false;\n}\n\n// The following logic comes from\n// .\n// Keep it synchronized with\n// .\n// The data file denotes with “U” or “Tu” any codepoint that may be drawn\n// upright in vertical text but does not distinguish between upright and\n// “neutral” characters.\n\n// Blocks in the Unicode supplementary planes are excluded from this module due\n// to .\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * upright orientation.\n *\n * A character has upright orientation if it is drawn upright (unrotated)\n * whether the line is oriented horizontally or vertically, even if both\n * adjacent characters can be rotated. For example, a Chinese character is\n * always drawn upright. An uprightly oriented character causes an adjacent\n * “neutral” character to be drawn upright as well.\n */\nexport function charHasUprightVerticalOrientation(char: number) {\n if (char === 0x02EA /* modifier letter yin departing tone mark */ ||\n char === 0x02EB /* modifier letter yang departing tone mark */) {\n return true;\n }\n\n // Return early for characters outside all ranges whose characters remain\n // upright in vertical writing mode.\n if (char < 0x1100) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) {\n if (!((char >= 0xFE49 /* dashed overline */ && char <= 0xFE4F) /* wavy low line */)) {\n return true;\n }\n }\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) {\n if (!((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) &&\n !((char >= 0x3014 /* left tortoise shell bracket */ && char <= 0x301F) /* low double prime quotation mark */) &&\n char !== 0x3030 /* wavy dash */) {\n return true;\n }\n }\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Hangul Compatibility Jamo'](char)) return true;\n if (isChar['Hangul Jamo Extended-A'](char)) return true;\n if (isChar['Hangul Jamo Extended-B'](char)) return true;\n if (isChar['Hangul Jamo'](char)) return true;\n if (isChar['Hangul Syllables'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kanbun'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) {\n if (char !== 0x30FC /* katakana-hiragana prolonged sound mark */) {\n return true;\n }\n }\n if (isChar['Halfwidth and Fullwidth Forms'](char)) {\n if (char !== 0xFF08 /* fullwidth left parenthesis */ &&\n char !== 0xFF09 /* fullwidth right parenthesis */ &&\n char !== 0xFF0D /* fullwidth hyphen-minus */ &&\n !((char >= 0xFF1A /* fullwidth colon */ && char <= 0xFF1E) /* fullwidth greater-than sign */) &&\n char !== 0xFF3B /* fullwidth left square bracket */ &&\n char !== 0xFF3D /* fullwidth right square bracket */ &&\n char !== 0xFF3F /* fullwidth low line */ &&\n !(char >= 0xFF5B /* fullwidth left curly bracket */ && char <= 0xFFDF) &&\n char !== 0xFFE3 /* fullwidth macron */ &&\n !(char >= 0xFFE8 /* halfwidth forms light vertical */ && char <= 0xFFEF)) {\n return true;\n }\n }\n if (isChar['Small Form Variants'](char)) {\n if (!((char >= 0xFE58 /* small em dash */ && char <= 0xFE5E) /* small right tortoise shell bracket */) &&\n !((char >= 0xFE63 /* small hyphen-minus */ && char <= 0xFE66) /* small equals sign */)) {\n return true;\n }\n }\n if (isChar['Unified Canadian Aboriginal Syllabics'](char)) return true;\n if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yijing Hexagram Symbols'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * neutral orientation.\n *\n * A character has neutral orientation if it may be drawn rotated or unrotated\n * when the line is oriented vertically, depending on the orientation of the\n * adjacent characters. For example, along a verticlly oriented line, the vulgar\n * fraction ½ is drawn upright among Chinese characters but rotated among Latin\n * letters. A neutrally oriented character does not influence whether an\n * adjacent character is drawn upright or rotated.\n */\nexport function charHasNeutralVerticalOrientation(char: number) {\n if (isChar['Latin-1 Supplement'](char)) {\n if (char === 0x00A7 /* section sign */ ||\n char === 0x00A9 /* copyright sign */ ||\n char === 0x00AE /* registered sign */ ||\n char === 0x00B1 /* plus-minus sign */ ||\n char === 0x00BC /* vulgar fraction one quarter */ ||\n char === 0x00BD /* vulgar fraction one half */ ||\n char === 0x00BE /* vulgar fraction three quarters */ ||\n char === 0x00D7 /* multiplication sign */ ||\n char === 0x00F7 /* division sign */) {\n return true;\n }\n }\n if (isChar['General Punctuation'](char)) {\n if (char === 0x2016 /* double vertical line */ ||\n char === 0x2020 /* dagger */ ||\n char === 0x2021 /* double dagger */ ||\n char === 0x2030 /* per mille sign */ ||\n char === 0x2031 /* per ten thousand sign */ ||\n char === 0x203B /* reference mark */ ||\n char === 0x203C /* double exclamation mark */ ||\n char === 0x2042 /* asterism */ ||\n char === 0x2047 /* double question mark */ ||\n char === 0x2048 /* question exclamation mark */ ||\n char === 0x2049 /* exclamation question mark */ ||\n char === 0x2051 /* two asterisks aligned vertically */) {\n return true;\n }\n }\n if (isChar['Letterlike Symbols'](char)) return true;\n if (isChar['Number Forms'](char)) return true;\n if (isChar['Miscellaneous Technical'](char)) {\n if ((char >= 0x2300 /* diameter sign */ && char <= 0x2307 /* wavy line */) ||\n (char >= 0x230C /* bottom right crop */ && char <= 0x231F /* bottom right corner */) ||\n (char >= 0x2324 /* up arrowhead between two horizontal bars */ && char <= 0x2328 /* keyboard */) ||\n char === 0x232B /* erase to the left */ ||\n (char >= 0x237D /* shouldered open box */ && char <= 0x239A /* clear screen symbol */) ||\n (char >= 0x23BE /* dentistry symbol light vertical and top right */ && char <= 0x23CD /* square foot */) ||\n char === 0x23CF /* eject symbol */ ||\n (char >= 0x23D1 /* metrical breve */ && char <= 0x23DB /* fuse */) ||\n (char >= 0x23E2 /* white trapezium */ && char <= 0x23FF)) {\n return true;\n }\n }\n if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) return true;\n if (isChar['Optical Character Recognition'](char)) return true;\n if (isChar['Enclosed Alphanumerics'](char)) return true;\n if (isChar['Geometric Shapes'](char)) return true;\n if (isChar['Miscellaneous Symbols'](char)) {\n if (!((char >= 0x261A /* black left pointing index */ && char <= 0x261F) /* white down pointing index */)) {\n return true;\n }\n }\n if (isChar['Miscellaneous Symbols and Arrows'](char)) {\n if ((char >= 0x2B12 /* square with top half black */ && char <= 0x2B2F /* white vertical ellipse */) ||\n (char >= 0x2B50 /* white medium star */ && char <= 0x2B59 /* heavy circled saltire */) ||\n (char >= 0x2BB8 /* upwards white arrow from bar with horizontal bar */ && char <= 0x2BEB)) {\n return true;\n }\n }\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Private Use Area'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['Small Form Variants'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n\n if (char === 0x221E /* infinity */ ||\n char === 0x2234 /* therefore */ ||\n char === 0x2235 /* because */ ||\n (char >= 0x2700 /* black safety scissors */ && char <= 0x2767 /* rotated floral heart bullet */) ||\n (char >= 0x2776 /* dingbat negative circled digit one */ && char <= 0x2793 /* dingbat negative circled sans-serif number ten */) ||\n char === 0xFFFC /* object replacement character */ ||\n char === 0xFFFD /* replacement character */) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * rotated orientation.\n *\n * A character has rotated orientation if it is drawn rotated when the line is\n * oriented vertically, even if both adjacent characters are upright. For\n * example, a Latin letter is drawn rotated along a vertical line. A rotated\n * character causes an adjacent “neutral” character to be drawn rotated as well.\n */\nexport function charHasRotatedVerticalOrientation(char: number) {\n return !(charHasUprightVerticalOrientation(char) ||\n charHasNeutralVerticalOrientation(char));\n}\n\nexport function charInComplexShapingScript(char: number) {\n return isChar['Arabic'](char) ||\n isChar['Arabic Supplement'](char) ||\n isChar['Arabic Extended-A'](char) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInRTLScript(char: number) {\n // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts\n return (char >= 0x0590 && char <= 0x08FF) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInSupportedScript(char: number, canRenderRTL: boolean) {\n // This is a rough heuristic: whether we \"can render\" a script\n // actually depends on the properties of the font being used\n // and whether differences from the ideal rendering are considered\n // semantically significant.\n\n // Even in Latin script, we \"can't render\" combinations such as the fi\n // ligature, but we don't consider that semantically significant.\n if (!canRenderRTL && charInRTLScript(char)) {\n return false;\n }\n if ((char >= 0x0900 && char <= 0x0DFF) ||\n // Main blocks for Indic scripts and Sinhala\n (char >= 0x0F00 && char <= 0x109F) ||\n // Main blocks for Tibetan and Myanmar\n isChar['Khmer'](char)) {\n // These blocks cover common scripts that require\n // complex text shaping, based on unicode script metadata:\n // http://www.unicode.org/repos/cldr/trunk/common/properties/scriptMetadata.txt\n // where \"Web Rank <= 32\" \"Shaping Required = YES\"\n return false;\n }\n return true;\n}\n\nexport function stringContainsRTLText(chars: string): boolean {\n for (const char of chars) {\n if (charInRTLScript(char.charCodeAt(0))) {\n return true;\n }\n }\n return false;\n}\n\nexport function isStringInSupportedScript(chars: string, canRenderRTL: boolean) {\n for (const char of chars) {\n if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {\n return false;\n }\n }\n return true;\n}\n","import {getArrayBuffer} from '../util/ajax';\nimport {browser} from '../util/browser';\nimport {Event, Evented} from '../util/evented';\nimport {isWorker} from '../util/util';\n\nconst status = {\n unavailable: 'unavailable', // Not loaded\n deferred: 'deferred', // The plugin URL has been specified, but loading has been deferred\n loading: 'loading', // request in-flight\n loaded: 'loaded',\n error: 'error'\n};\n\nexport type PluginState = {\n pluginStatus: typeof status[keyof typeof status];\n pluginURL: string;\n};\n\n/**\n * An error callback\n */\ntype ErrorCallback = (error?: Error | null) => void;\ntype PluginStateSyncCallback = (state: PluginState) => void;\nlet _completionCallback = null;\n\n//Variables defining the current state of the plugin\nlet pluginStatus = status.unavailable;\nlet pluginURL = null;\n\nexport const triggerPluginCompletionEvent = function(error: Error | string) {\n // NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin\n if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) {\n pluginStatus = status.error;\n }\n\n if (_completionCallback) {\n _completionCallback(error);\n }\n};\n\nfunction sendPluginStateToWorker() {\n evented.fire(new Event('pluginStateChange', {pluginStatus, pluginURL}));\n}\n\nexport const evented = new Evented();\n\nexport const getRTLTextPluginStatus = function () {\n return pluginStatus;\n};\n\nexport const registerForPluginStateChange = function(callback: PluginStateSyncCallback) {\n // Do an initial sync of the state\n callback({pluginStatus, pluginURL});\n // Listen for all future state changes\n evented.on('pluginStateChange', callback);\n return callback;\n};\n\nexport const clearRTLTextPlugin = function() {\n pluginStatus = status.unavailable;\n pluginURL = null;\n _completionCallback = null;\n};\n\nexport const setRTLTextPlugin = function(url: string, callback: ErrorCallback, deferred: boolean = false) {\n if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) {\n throw new Error('setRTLTextPlugin cannot be called multiple times.');\n }\n pluginURL = browser.resolveURL(url);\n pluginStatus = status.deferred;\n _completionCallback = callback;\n sendPluginStateToWorker();\n\n //Start downloading the plugin immediately if not intending to lazy-load\n if (!deferred) {\n downloadRTLTextPlugin();\n }\n};\n\nexport const downloadRTLTextPlugin = function() {\n if (pluginStatus !== status.deferred || !pluginURL) {\n throw new Error('rtl-text-plugin cannot be downloaded unless a pluginURL is specified');\n }\n pluginStatus = status.loading;\n sendPluginStateToWorker();\n if (pluginURL) {\n getArrayBuffer({url: pluginURL}, (error) => {\n if (error) {\n triggerPluginCompletionEvent(error);\n } else {\n pluginStatus = status.loaded;\n sendPluginStateToWorker();\n }\n });\n }\n};\n\nexport const plugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n isLoaded: () => boolean;\n isLoading: () => boolean;\n setState: (state: PluginState) => void;\n isParsed: () => boolean;\n getPluginURL: () => string;\n} = {\n applyArabicShaping: null,\n processBidirectionalText: null,\n processStyledBidirectionalText: null,\n isLoaded() {\n return pluginStatus === status.loaded || // Main Thread: loaded if the completion callback returned successfully\n plugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled\n },\n isLoading() { // Main Thread Only: query the loading status, this function does not return the correct value in the worker context.\n return pluginStatus === status.loading;\n },\n setState(state: PluginState) { // Worker thread only: this tells the worker threads that the plugin is available on the Main thread\n if (!isWorker()) throw new Error('Cannot set the state of the rtl-text-plugin when not in the web-worker context');\n\n pluginStatus = state.pluginStatus;\n pluginURL = state.pluginURL;\n },\n isParsed(): boolean {\n if (!isWorker()) throw new Error('rtl-text-plugin is only parsed on the worker-threads');\n\n return plugin.applyArabicShaping != null &&\n plugin.processBidirectionalText != null &&\n plugin.processStyledBidirectionalText != null;\n },\n getPluginURL(): string {\n if (!isWorker()) throw new Error('rtl-text-plugin url can only be queried from the worker threads');\n return pluginURL;\n }\n};\n\nexport const lazyLoadRTLTextPlugin = function() {\n if (!plugin.isLoading() &&\n !plugin.isLoaded() &&\n getRTLTextPluginStatus() === 'deferred'\n ) {\n downloadRTLTextPlugin();\n }\n};\n","import {ZoomHistory} from './zoom_history';\nimport {isStringInSupportedScript} from '../util/script_detection';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {TransitionSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CrossfadeParameters = {\n fromScale: number;\n toScale: number;\n t: number;\n};\n\n/**\n * @internal\n * A parameter that can be evaluated to a value\n */\nexport class EvaluationParameters {\n zoom: number;\n now: number;\n fadeDuration: number;\n zoomHistory: ZoomHistory;\n transition: TransitionSpecification;\n\n // \"options\" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate\n constructor(zoom: number, options?: any) {\n this.zoom = zoom;\n\n if (options) {\n this.now = options.now;\n this.fadeDuration = options.fadeDuration;\n this.zoomHistory = options.zoomHistory;\n this.transition = options.transition;\n } else {\n this.now = 0;\n this.fadeDuration = 0;\n this.zoomHistory = new ZoomHistory();\n this.transition = {};\n }\n }\n\n isSupportedScript(str: string): boolean {\n return isStringInSupportedScript(str, rtlTextPlugin.isLoaded());\n }\n\n crossFadingFactor() {\n if (this.fadeDuration === 0) {\n return 1;\n } else {\n return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);\n }\n }\n\n getCrossfadeParameters(): CrossfadeParameters {\n const z = this.zoom;\n const fraction = z - Math.floor(z);\n const t = this.crossFadingFactor();\n\n return z > this.zoomHistory.lastIntegerZoom ?\n {fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t} :\n {fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction};\n }\n}\n","import {clone, extend, easeCubicInOut} from '../util/util';\nimport {interpolates, Color, StylePropertySpecification, normalizePropertyExpression,\n Feature,\n FeatureState,\n StylePropertyExpression,\n SourceExpression,\n CompositeExpression, TransitionSpecification,\n PropertyValueSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from './evaluation_parameters';\n\nimport {CanonicalTileID} from '../source/tile_id';\n\ntype TimePoint = number;\n\n/**\n * A from-to type\n */\nexport type CrossFaded = {\n to: T;\n from: T;\n};\n\n/**\n * @internal\n * Implementations of the `Property` interface:\n *\n * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value,\n * the default value, etc. This comes from the style specification JSON.\n * * Define behavior that needs to be polymorphic across different properties: \"possibly evaluating\"\n * an input value (see below), and interpolating between two possibly-evaluted values.\n *\n * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`).\n * The type `R` is the intermediate \"possibly evaluated\" value type. See below.\n *\n * There are two main implementations of the interface -- one for properties that allow data-driven values,\n * and one for properties that don't. There are a few \"special case\" implementations as well: one for properties\n * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`,\n * and one for `light-position`.\n */\nexport interface Property {\n specification: StylePropertySpecification;\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R;\n interpolate(a: R, b: R, t: number): R;\n}\n\n/**\n * @internal\n * `PropertyValue` represents the value part of a property key-value unit. It's used to represent both\n * paint and layout property values, and regardless of whether or not their property supports data-driven\n * expressions.\n *\n * `PropertyValue` stores the raw input value as seen in a style or a runtime styling API call, i.e. one of the\n * following:\n *\n * * A constant value of the type appropriate for the property\n * * A function which produces a value of that type (but functions are quasi-deprecated in favor of expressions)\n * * An expression which produces a value of that type\n * * \"undefined\"/\"not present\", in which case the property is assumed to take on its default value.\n *\n * In addition to storing the original input value, `PropertyValue` also stores a normalized representation,\n * effectively treating functions as if they are expressions, and constant or default values as if they are\n * (constant) expressions.\n */\nexport class PropertyValue {\n property: Property;\n value: PropertyValueSpecification | void;\n expression: StylePropertyExpression;\n\n constructor(property: Property, value: PropertyValueSpecification | void) {\n this.property = property;\n this.value = value;\n this.expression = normalizePropertyExpression(value === undefined ? property.specification.default : value, property.specification);\n }\n\n isDataDriven(): boolean {\n return this.expression.kind === 'source' || this.expression.kind === 'composite';\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R {\n return this.property.possiblyEvaluate(this, parameters, canonical, availableImages);\n }\n}\n\nexport type TransitionParameters = {\n now: TimePoint;\n transition: TransitionSpecification;\n};\n\n/**\n * @internal\n * Paint properties are _transitionable_: they can change in a fluid manner, interpolating or cross-fading between\n * old and new value. The duration of the transition, and the delay before it begins, is configurable.\n *\n * `TransitionablePropertyValue` is a compositional class that stores both the property value and that transition\n * configuration.\n *\n * A `TransitionablePropertyValue` can calculate the next step in the evaluation chain for paint property values:\n * `TransitioningPropertyValue`.\n */\nclass TransitionablePropertyValue {\n property: Property;\n value: PropertyValue;\n transition: TransitionSpecification | void;\n\n constructor(property: Property) {\n this.property = property;\n this.value = new PropertyValue(property, undefined);\n }\n\n transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, prior,\n extend({}, parameters.transition, this.transition), parameters.now);\n }\n\n untransitioned(): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, null, {}, 0);\n }\n}\n\n/**\n * @internal\n * `Transitionable` stores a map of all (property name, `TransitionablePropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the `TransitioningPropertyValue`s for all of them at once, producing a\n * `Transitioning` instance for the same set of properties.\n */\nexport class Transitionable {\n _properties: Properties;\n _values: {[K in keyof Props]: TransitionablePropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitionablePropertyValues) as any);\n }\n\n getValue(name: S): PropertyValueSpecification | void {\n return clone(this._values[name].value.value);\n }\n\n setValue(name: S, value: PropertyValueSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n // Note that we do not _remove_ an own property in the case where a value is being reset\n // to the default: the transition might still be non-default.\n this._values[name].value = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value));\n }\n\n getTransition(name: S): TransitionSpecification | void {\n return clone(this._values[name].transition);\n }\n\n setTransition(name: S, value: TransitionSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n this._values[name].transition = clone(value) || undefined;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n\n const transition = this.getTransition(property as keyof Props);\n if (transition !== undefined) {\n result[`${property}-transition`] = transition;\n }\n }\n return result;\n }\n\n transitioned(parameters: TransitionParameters, prior: Transitioning): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].transitioned(parameters, prior._values[property]);\n }\n return result;\n }\n\n untransitioned(): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].untransitioned();\n }\n return result;\n }\n}\n\n/**\n * @internal\n * `TransitioningPropertyValue` implements the first of two intermediate steps in the evaluation chain of a paint\n * property value. In this step, transitions between old and new values are handled: as long as the transition is in\n * progress, `TransitioningPropertyValue` maintains a reference to the prior value, and interpolates between it and\n * the new value based on the current time and the configured transition duration and delay. The product is the next\n * step in the evaluation chain: the \"possibly evaluated\" result type `R`. See below for more on this concept.\n */\nclass TransitioningPropertyValue {\n property: Property;\n value: PropertyValue;\n prior: TransitioningPropertyValue;\n begin: TimePoint;\n end: TimePoint;\n\n constructor(property: Property,\n value: PropertyValue,\n prior: TransitioningPropertyValue,\n transition: TransitionSpecification,\n now: TimePoint) {\n this.property = property;\n this.value = value;\n this.begin = now + transition.delay || 0;\n this.end = this.begin + transition.duration || 0;\n if (property.specification.transition && (transition.delay || transition.duration)) {\n this.prior = prior;\n }\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical: CanonicalTileID,\n availableImages: Array\n ): R {\n const now = parameters.now || 0;\n const finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages);\n const prior = this.prior;\n if (!prior) {\n // No prior value.\n return finalValue;\n } else if (now > this.end) {\n // Transition from prior value is now complete.\n this.prior = null;\n return finalValue;\n } else if (this.value.isDataDriven()) {\n // Transitions to data-driven properties are not supported.\n // We snap immediately to the data-driven value so that, when we perform layout,\n // we see the data-driven function and can use it to populate vertex buffers.\n this.prior = null;\n return finalValue;\n } else if (now < this.begin) {\n // Transition hasn't started yet.\n return prior.possiblyEvaluate(parameters, canonical, availableImages);\n } else {\n // Interpolate between recursively-calculated prior value and final.\n const t = (now - this.begin) / (this.end - this.begin);\n return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t));\n }\n }\n}\n\n/**\n * @internal\n * `Transitioning` stores a map of all (property name, `TransitioningPropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Transitioning {\n _properties: Properties;\n _values: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitioningPropertyValues) as any);\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n\n hasTransition() {\n for (const property of Object.keys(this._values)) {\n if (this._values[property].prior) {\n return true;\n }\n }\n return false;\n }\n}\n\n// ------- Layout -------\n\n/**\n * Because layout properties are not transitionable, they have a simpler representation and evaluation chain than\n * paint properties: `PropertyValue`s are possibly evaluated, producing possibly evaluated values, which are then\n * fully evaluated.\n *\n * `Layout` stores a map of all (property name, `PropertyValue`) pairs for layout properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Layout {\n _properties: Properties;\n _values: {[K in keyof Props]: PropertyValue>};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultPropertyValues) as any);\n }\n\n hasValue(name: S) {\n return this._values[name].value !== undefined;\n }\n\n getValue(name: S) {\n return clone(this._values[name].value);\n }\n\n setValue(name: S, value: any) {\n this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value)) as any;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n }\n return result;\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n}\n\n// ------- PossiblyEvaluated -------\n\n/**\n * \"Possibly evaluated value\" is an intermediate stage in the evaluation chain for both paint and layout property\n * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code\n * which uses data-driven property values must assume that the value is dependent on feature data, and request that it\n * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation\n * will not actually depend on the feature, and we can benefit from returning the prior result of having done the\n * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and \"global\" parameters\n * such as current zoom level.\n *\n * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or\n * camera expression, then the \"possibly evaluated\" result is a constant value. Otherwise, the input value was either\n * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate\n * the source and composite cases because they are handled differently when generating GL attributes, buffers, and\n * uniforms.\n *\n * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that\n * do not allow data-driven values. For such properties, we know that the \"possibly evaluated\" result is always a constant\n * scalar value. See below.\n */\ntype PossiblyEvaluatedValue = {\n kind: 'constant';\n value: T;\n} | SourceExpression | CompositeExpression;\n\n/**\n * @internal\n * `PossiblyEvaluatedPropertyValue` is used for data-driven paint and layout property values. It holds a\n * `PossiblyEvaluatedValue` and the `GlobalProperties` that were used to generate it. You're not allowed to supply\n * a different set of `GlobalProperties` when performing the final evaluation because they would be ignored in the\n * case where the input value was a constant or camera function.\n */\nexport class PossiblyEvaluatedPropertyValue {\n property: DataDrivenProperty;\n value: PossiblyEvaluatedValue;\n parameters: EvaluationParameters;\n\n constructor(property: DataDrivenProperty, value: PossiblyEvaluatedValue, parameters: EvaluationParameters) {\n this.property = property;\n this.value = value;\n this.parameters = parameters;\n }\n\n isConstant(): boolean {\n return this.value.kind === 'constant';\n }\n\n constantOr(value: T): T {\n if (this.value.kind === 'constant') {\n return this.value.value;\n } else {\n return value;\n }\n }\n\n evaluate(\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages);\n }\n}\n\n/**\n * @internal\n * `PossiblyEvaluated` stores a map of all (property name, `R`) pairs for paint or layout properties of a\n * given layer type.\n */\nexport class PossiblyEvaluated {\n _properties: Properties;\n _values: PossibleEvaluatedProps;\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = Object.create(properties.defaultPossiblyEvaluatedValues);\n }\n\n get(name: S): PossibleEvaluatedProps[S] {\n return this._values[name];\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that do not permit data-driven (source or composite) expressions.\n * This restriction allows us to declare statically that the result of possibly evaluating this kind of property\n * is in fact always the scalar type `T`, and can be used without further evaluating the value on a per-feature basis.\n */\nexport class DataConstantProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters): T {\n if (value.isDataDriven()) throw new Error('Value should not be data driven');\n return value.expression.evaluate(parameters);\n }\n\n interpolate(a: T, b: T, t: number): T {\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n return interpolationFn(a, b, t);\n } else {\n return a;\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that permit data-driven (source or composite) expressions.\n * The result of possibly evaluating this kind of property is `PossiblyEvaluatedPropertyValue`; obtaining\n * a scalar value `T` requires further evaluation on a per-feature basis.\n */\nexport class DataDrivenProperty implements Property> {\n specification: StylePropertySpecification;\n overrides: any;\n\n constructor(specification: StylePropertySpecification, overrides?: any) {\n this.specification = specification;\n this.overrides = overrides;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue {\n if (value.expression.kind === 'constant' || value.expression.kind === 'camera') {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: value.expression.evaluate(parameters, null, {}, canonical, availableImages)}, parameters);\n } else {\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n interpolate(\n a: PossiblyEvaluatedPropertyValue,\n b: PossiblyEvaluatedPropertyValue,\n t: number\n ): PossiblyEvaluatedPropertyValue {\n // If either possibly-evaluated value is non-constant, give up: we aren't able to interpolate data-driven values.\n if (a.value.kind !== 'constant' || b.value.kind !== 'constant') {\n return a;\n }\n\n // Special case hack solely for fill-outline-color. The undefined value is subsequently handled in\n // FillStyleLayer#recalculate, which sets fill-outline-color to the fill-color value if the former\n // is a PossiblyEvaluatedPropertyValue containing a constant undefined value. In addition to the\n // return value here, the other source of a PossiblyEvaluatedPropertyValue containing a constant\n // undefined value is the \"default value\" for fill-outline-color held in\n // `Properties#defaultPossiblyEvaluatedValues`, which serves as the prototype of\n // `PossiblyEvaluated#_values`.\n if (a.value.value === undefined || b.value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, a.parameters);\n }\n\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n const interpolatedValue = interpolationFn(a.value.value, b.value.value, t);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: interpolatedValue}, a.parameters);\n } else {\n return a;\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue,\n parameters: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return value.evaluate(parameters, feature, featureState, canonical, availableImages);\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for data driven `line-pattern` which are transitioned by cross-fading\n * rather than interpolation.\n */\n\nexport class CrossFadedDataDrivenProperty extends DataDrivenProperty> {\n\n possiblyEvaluate(\n value: PropertyValue, PossiblyEvaluatedPropertyValue>>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue> {\n if (value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, parameters);\n } else if (value.expression.kind === 'constant') {\n const evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n const isImageExpression = value.property.specification.type as any === 'resolvedImage';\n const constantValue = isImageExpression && typeof evaluatedValue !== 'string' ? evaluatedValue.name : evaluatedValue;\n const constant = this._calculate(constantValue, constantValue, constantValue, parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: constant}, parameters);\n } else if (value.expression.kind === 'camera') {\n const cameraVal = this._calculate(\n value.expression.evaluate({zoom: parameters.zoom - 1.0}),\n value.expression.evaluate({zoom: parameters.zoom}),\n value.expression.evaluate({zoom: parameters.zoom + 1.0}),\n parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: cameraVal}, parameters);\n } else {\n // source or composite expression\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue>,\n globals: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.kind === 'source') {\n const constant = value.evaluate(globals, feature, featureState, canonical, availableImages);\n return this._calculate(constant, constant, constant, globals);\n } else if (value.kind === 'composite') {\n return this._calculate(\n value.evaluate({zoom: Math.floor(globals.zoom) - 1.0}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom)}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom) + 1.0}, feature, featureState),\n globals);\n } else {\n return value.value;\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue> {\n return a;\n }\n}\n/**\n * @internal\n * An implementation of `Property` for `*-pattern` and `line-dasharray`, which are transitioned by cross-fading\n * rather than interpolation.\n */\nexport class CrossFadedProperty implements Property> {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.value === undefined) {\n return undefined;\n } else if (value.expression.kind === 'constant') {\n const constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n return this._calculate(constant, constant, constant, parameters);\n } else {\n return this._calculate(\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1.0), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1.0), parameters)),\n parameters);\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a?: CrossFaded | null): CrossFaded {\n return a;\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for `heatmap-color` and `line-gradient`. Interpolation is a no-op, and\n * evaluation returns a boolean value in order to indicate its presence, but the real\n * evaluation happens in StyleLayer classes.\n */\n\nexport class ColorRampProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): boolean {\n return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n }\n\n interpolate(): boolean { return false; }\n}\n\n/**\n * @internal\n * `Properties` holds objects containing default values for the layout or paint property set of a given\n * layer type. These objects are immutable, and they are used as the prototypes for the `_values` members of\n * `Transitionable`, `Transitioning`, `Layout`, and `PossiblyEvaluated`. This allows these classes to avoid\n * doing work in the common case where a property has no explicit value set and should be considered to take\n * on the default value: using `for (const property of Object.keys(this._values))`, they can iterate over\n * only the _own_ properties of `_values`, skipping repeated calculation of transitions and possible/final\n * evaluations for defaults, the result of which will always be the same.\n */\nexport class Properties {\n properties: Props;\n defaultPropertyValues: {[K in keyof Props]: PropertyValue};\n defaultTransitionablePropertyValues: {[K in keyof Props]: TransitionablePropertyValue};\n defaultTransitioningPropertyValues: {[K in keyof Props]: TransitioningPropertyValue};\n defaultPossiblyEvaluatedValues: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n overridableProperties: Array;\n\n constructor(properties: Props) {\n this.properties = properties;\n this.defaultPropertyValues = ({} as any);\n this.defaultTransitionablePropertyValues = ({} as any);\n this.defaultTransitioningPropertyValues = ({} as any);\n this.defaultPossiblyEvaluatedValues = ({} as any);\n this.overridableProperties = ([] as any);\n\n for (const property in properties) {\n const prop = properties[property] as any;\n if (prop.specification.overridable) {\n this.overridableProperties.push(property);\n }\n const defaultPropertyValue = this.defaultPropertyValues[property] =\n new PropertyValue(prop, undefined);\n const defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] =\n new TransitionablePropertyValue(prop);\n this.defaultTransitioningPropertyValues[property] =\n defaultTransitionablePropertyValue.untransitioned();\n this.defaultPossiblyEvaluatedValues[property] =\n defaultPropertyValue.possiblyEvaluate({} as any);\n }\n }\n}\n\nregister('DataDrivenProperty', DataDrivenProperty);\nregister('DataConstantProperty', DataConstantProperty);\nregister('CrossFadedDataDrivenProperty', CrossFadedDataDrivenProperty);\nregister('CrossFadedProperty', CrossFadedProperty);\nregister('ColorRampProperty', ColorRampProperty);\n","import {filterObject} from '../util/util';\n\nimport {latest as styleSpec, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {\n validateStyle,\n validateLayoutProperty,\n validatePaintProperty,\n emitValidationErrors\n} from './validate_style';\nimport {Evented} from '../util/evented';\nimport {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties';\n\nimport type {Bucket} from '../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureFilter, FeatureState,\n LayerSpecification,\n FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {TransitionParameters, PropertyValue} from './properties';\nimport {EvaluationParameters} from './evaluation_parameters';\nimport type {CrossfadeParameters} from './evaluation_parameters';\n\nimport type {Transform} from '../geo/transform';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Map} from '../ui/map';\nimport type {StyleSetterOptions} from './style';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nconst TRANSITION_SUFFIX = '-transition';\n\n/**\n * A base class for style layers\n */\nexport abstract class StyleLayer extends Evented {\n id: string;\n metadata: unknown;\n type: LayerSpecification['type'] | CustomLayerInterface['type'];\n source: string;\n sourceLayer: string;\n minzoom: number;\n maxzoom: number;\n filter: FilterSpecification | void;\n visibility: 'visible' | 'none' | void;\n _crossfadeParameters: CrossfadeParameters;\n\n _unevaluatedLayout: Layout;\n readonly layout: unknown;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n readonly paint: unknown;\n\n _featureFilter: FeatureFilter;\n\n readonly onAdd: ((map: Map) => void);\n readonly onRemove: ((map: Map) => void);\n\n queryRadius?(bucket: Bucket): number;\n queryIntersectsFeature?(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number;\n\n constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{\n layout?: Properties;\n paint?: Properties;\n }>) {\n super();\n\n this.id = layer.id;\n this.type = layer.type;\n this._featureFilter = {filter: () => true, needGeometry: false};\n\n if (layer.type === 'custom') return;\n\n layer = (layer as any as LayerSpecification);\n\n this.metadata = layer.metadata;\n this.minzoom = layer.minzoom;\n this.maxzoom = layer.maxzoom;\n\n if (layer.type !== 'background') {\n this.source = layer.source;\n this.sourceLayer = layer['source-layer'];\n this.filter = layer.filter;\n }\n\n if (properties.layout) {\n this._unevaluatedLayout = new Layout(properties.layout);\n }\n\n if (properties.paint) {\n this._transitionablePaint = new Transitionable(properties.paint);\n\n for (const property in layer.paint) {\n this.setPaintProperty(property, layer.paint[property], {validate: false});\n }\n for (const property in layer.layout) {\n this.setLayoutProperty(property, layer.layout[property], {validate: false});\n }\n\n this._transitioningPaint = this._transitionablePaint.untransitioned();\n //$FlowFixMe\n this.paint = new PossiblyEvaluated(properties.paint);\n }\n }\n\n getCrossfadeParameters() {\n return this._crossfadeParameters;\n }\n\n getLayoutProperty(name: string) {\n if (name === 'visibility') {\n return this.visibility;\n }\n\n return this._unevaluatedLayout.getValue(name);\n }\n\n setLayoutProperty(name: string, value: any, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.layout.${name}`;\n if (this._validate(validateLayoutProperty, key, name, value, options)) {\n return;\n }\n }\n\n if (name === 'visibility') {\n this.visibility = value;\n return;\n }\n\n this._unevaluatedLayout.setValue(name, value);\n }\n\n getPaintProperty(name: string) {\n if (name.endsWith(TRANSITION_SUFFIX)) {\n return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length));\n } else {\n return this._transitionablePaint.getValue(name);\n }\n }\n\n setPaintProperty(name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.paint.${name}`;\n if (this._validate(validatePaintProperty, key, name, value, options)) {\n return false;\n }\n }\n\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), (value as any) || undefined);\n return false;\n } else {\n const transitionable = this._transitionablePaint._values[name];\n const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven';\n const wasDataDriven = transitionable.value.isDataDriven();\n const oldValue = transitionable.value;\n\n this._transitionablePaint.setValue(name, value);\n this._handleSpecialPaintPropertyUpdate(name);\n\n const newValue = this._transitionablePaint._values[name].value;\n const isDataDriven = newValue.isDataDriven();\n\n // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas\n // so a call to _updateLayer is necessary, and we return true from this function so it gets called in\n // Style#setPaintProperty\n return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name, oldValue, newValue);\n }\n }\n\n _handleSpecialPaintPropertyUpdate(_: string) {\n // No-op; can be overridden by derived classes.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n // No-op; can be overridden by derived classes.\n return false;\n }\n\n isHidden(zoom: number) {\n if (this.minzoom && zoom < this.minzoom) return true;\n if (this.maxzoom && zoom >= this.maxzoom) return true;\n return this.visibility === 'none';\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint);\n }\n\n hasTransition() {\n return this._transitioningPaint.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n if (parameters.getCrossfadeParameters) {\n this._crossfadeParameters = parameters.getCrossfadeParameters();\n }\n\n if (this._unevaluatedLayout) {\n (this as any).layout = this._unevaluatedLayout.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n (this as any).paint = this._transitioningPaint.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n serialize(): LayerSpecification {\n const output: LayerSpecification = {\n 'id': this.id,\n 'type': this.type as LayerSpecification['type'],\n 'source': this.source,\n 'source-layer': this.sourceLayer,\n 'metadata': this.metadata,\n 'minzoom': this.minzoom,\n 'maxzoom': this.maxzoom,\n 'filter': this.filter as FilterSpecification,\n 'layout': this._unevaluatedLayout && this._unevaluatedLayout.serialize(),\n 'paint': this._transitionablePaint && this._transitionablePaint.serialize()\n };\n\n if (this.visibility) {\n output.layout = output.layout || {};\n output.layout.visibility = this.visibility;\n }\n\n return filterObject(output, (value, key) => {\n return value !== undefined &&\n !(key === 'layout' && !Object.keys(value).length) &&\n !(key === 'paint' && !Object.keys(value).length);\n });\n }\n\n _validate(validate: Function, key: string, name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, {\n key,\n layerType: this.type,\n objectKey: name,\n value,\n styleSpec,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true}\n }));\n }\n\n is3D() {\n return false;\n }\n\n isTileClipped() {\n return false;\n }\n\n hasOffscreenPass() {\n return false;\n }\n\n resize() {\n // noop\n }\n\n isStateDependent() {\n for (const property in (this as any).paint._values) {\n const value = (this as any).paint.get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n\n if ((value.value.kind === 'source' || value.value.kind === 'composite') &&\n value.value.isStateDependent) {\n return true;\n }\n }\n return false;\n }\n}\n","// Note: all \"sizes\" are measured in bytes\n\nimport type {Transferable} from '../types/transferable';\n\n/**\n * @internal\n * A view type size\n */\nconst viewTypes = {\n 'Int8': Int8Array,\n 'Uint8': Uint8Array,\n 'Int16': Int16Array,\n 'Uint16': Uint16Array,\n 'Int32': Int32Array,\n 'Uint32': Uint32Array,\n 'Float32': Float32Array\n};\n\n/**\n * @internal\n * A view type size\n */\nexport type ViewType = keyof typeof viewTypes;\n\n/** @internal */\nclass Struct {\n _pos1: number;\n _pos2: number;\n _pos4: number;\n _pos8: number;\n readonly _structArray: StructArray;\n\n // The following properties are defined on the prototype of sub classes.\n size: number;\n\n /**\n * @param structArray - The StructArray the struct is stored in\n * @param index - The index of the struct in the StructArray.\n */\n constructor(structArray: StructArray, index: number) {\n (this as any)._structArray = structArray;\n this._pos1 = index * this.size;\n this._pos2 = this._pos1 / 2;\n this._pos4 = this._pos1 / 4;\n this._pos8 = this._pos1 / 8;\n }\n}\n\nconst DEFAULT_CAPACITY = 128;\nconst RESIZE_MULTIPLIER = 5;\n\n/**\n * @internal\n * A struct array memeber\n */\nexport type StructArrayMember = {\n name: string;\n type: ViewType;\n components: number;\n offset: number;\n};\n\nexport type StructArrayLayout = {\n members: Array;\n size: number;\n alignment: number;\n};\n\n/**\n * An array that can be desialized\n */\nexport type SerializedStructArray = {\n length: number;\n arrayBuffer: ArrayBuffer;\n};\n\n/**\n * @internal\n * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray`\n * making it behave like an array of typed structs.\n *\n * Conceptually, a StructArray is comprised of elements, i.e., instances of its\n * associated struct type. Each particular struct type, together with an\n * alignment size, determines the memory layout of a StructArray whose elements\n * are of that type. Thus, for each such layout that we need, we have\n * a corresponding StructArrayLayout class, inheriting from StructArray and\n * implementing `emplaceBack()` and `_refreshViews()`.\n *\n * In some cases, where we need to access particular elements of a StructArray,\n * we implement a more specific subclass that inherits from one of the\n * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured\n * object whose properties are proxies into the underlying memory space for the\n * i-th element. This affords the convience of working with (seemingly) plain\n * Javascript objects without the overhead of serializing/deserializing them\n * into ArrayBuffers for efficient web worker transfer.\n */\nabstract class StructArray {\n capacity: number;\n length: number;\n isTransferred: boolean;\n arrayBuffer: ArrayBuffer;\n uint8: Uint8Array;\n\n // The following properties are defined on the prototype.\n members: Array;\n bytesPerElement: number;\n abstract emplaceBack(...v: number[]);\n abstract emplace(i: number, ...v: number[]);\n\n constructor() {\n this.isTransferred = false;\n this.capacity = -1;\n this.resize(0);\n }\n\n /**\n * Serialize a StructArray instance. Serializes both the raw data and the\n * metadata needed to reconstruct the StructArray base class during\n * deserialization.\n */\n static serialize(array: StructArray, transferables?: Array): SerializedStructArray {\n\n array._trim();\n\n if (transferables) {\n array.isTransferred = true;\n transferables.push(array.arrayBuffer);\n }\n\n return {\n length: array.length,\n arrayBuffer: array.arrayBuffer,\n };\n }\n\n static deserialize(input: SerializedStructArray) {\n const structArray = Object.create(this.prototype);\n structArray.arrayBuffer = input.arrayBuffer;\n structArray.length = input.length;\n structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;\n structArray._refreshViews();\n return structArray;\n }\n\n /**\n * Resize the array to discard unused capacity.\n */\n _trim() {\n if (this.length !== this.capacity) {\n this.capacity = this.length;\n this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement);\n this._refreshViews();\n }\n }\n\n /**\n * Resets the length of the array to 0 without de-allocating capcacity.\n */\n clear() {\n this.length = 0;\n }\n\n /**\n * Resize the array.\n * If `n` is greater than the current length then additional elements with undefined values are added.\n * If `n` is less than the current length then the array will be reduced to the first `n` elements.\n * @param n - The new size of the array.\n */\n resize(n: number) {\n this.reserve(n);\n this.length = n;\n }\n\n /**\n * Indicate a planned increase in size, so that any necessary allocation may\n * be done once, ahead of time.\n * @param n - The expected size of the array.\n */\n reserve(n: number) {\n if (n > this.capacity) {\n this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY);\n this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);\n\n const oldUint8Array = this.uint8;\n this._refreshViews();\n if (oldUint8Array) this.uint8.set(oldUint8Array);\n }\n }\n\n /**\n * Create TypedArray views for the current ArrayBuffer.\n */\n _refreshViews() {\n throw new Error('_refreshViews() must be implemented by each concrete StructArray layout');\n }\n}\n\n/**\n * Given a list of member fields, create a full StructArrayLayout, in\n * particular calculating the correct byte offset for each field. This data\n * is used at build time to generate StructArrayLayout_*#emplaceBack() and\n * other accessors, and at runtime for binding vertex buffer attributes.\n */\nfunction createLayout(\n members: Array<{\n name: string;\n type: ViewType;\n readonly components?: number;\n }>,\n alignment: number = 1\n): StructArrayLayout {\n\n let offset = 0;\n let maxSize = 0;\n const layoutMembers = members.map((member) => {\n const typeSize = sizeOf(member.type);\n const memberOffset = offset = align(offset, Math.max(alignment, typeSize));\n const components = member.components || 1;\n\n maxSize = Math.max(maxSize, typeSize);\n offset += typeSize * components;\n\n return {\n name: member.name,\n type: member.type,\n components,\n offset: memberOffset,\n };\n });\n\n const size = align(offset, Math.max(maxSize, alignment));\n\n return {\n members: layoutMembers,\n size,\n alignment\n };\n}\n\nfunction sizeOf(type: ViewType): number {\n return viewTypes[type].BYTES_PER_ELEMENT;\n}\n\nfunction align(offset: number, size: number): number {\n return Math.ceil(offset / size) * size;\n}\n\nexport {StructArray, Struct, viewTypes, createLayout};\n","// This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`.\n\nimport {Struct, StructArray} from '../util/struct_array';\nimport {register} from '../util/web_worker_transfer';\nimport Point from '@mapbox/point-geometry';\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n *\n */\nclass StructArrayLayout2i4 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2i4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2i4', StructArrayLayout2i4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[3]\n *\n */\nclass StructArrayLayout3i6 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3i6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3i6', StructArrayLayout3i6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n *\n */\nclass StructArrayLayout4i8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o2 = i * 4;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4i8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout4i8', StructArrayLayout4i8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[4]\n *\n */\nclass StructArrayLayout2i4i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i4i12', StructArrayLayout2i4i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint8[4]\n *\n */\nclass StructArrayLayout2i4ub8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 4;\n const o1 = i * 8;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint8[o1 + 4] = v2;\n this.uint8[o1 + 5] = v3;\n this.uint8[o1 + 6] = v4;\n this.uint8[o1 + 7] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4ub8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n *\n */\nclass StructArrayLayout2f8 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o4 = i * 2;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2f8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2f8', StructArrayLayout2f8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[10]\n *\n */\nclass StructArrayLayout10ui20 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const o2 = i * 10;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n return i;\n }\n}\n\nStructArrayLayout10ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout10ui20', StructArrayLayout10ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n * [8]: Uint16[4]\n * [16]: Int16[4]\n *\n */\nclass StructArrayLayout4i4ui4i24 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const o2 = i * 12;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.int16[o2 + 8] = v8;\n this.int16[o2 + 9] = v9;\n this.int16[o2 + 10] = v10;\n this.int16[o2 + 11] = v11;\n return i;\n }\n}\n\nStructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24;\nregister('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[3]\n *\n */\nclass StructArrayLayout3f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 3;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout3f12', StructArrayLayout3f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n *\n */\nclass StructArrayLayout1ul4 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.uint32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ul4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1ul4', StructArrayLayout1ul4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[6]\n * [12]: Uint32[1]\n * [16]: Uint16[2]\n *\n */\nclass StructArrayLayout6i1ul2ui20 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const o2 = i * 10;\n const o4 = i * 5;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.uint32[o4 + 3] = v6;\n this.uint16[o2 + 8] = v7;\n this.uint16[o2 + 9] = v8;\n return i;\n }\n}\n\nStructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[2]\n * [8]: Int16[2]\n *\n */\nclass StructArrayLayout2i2i2i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i2i2i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n * [8]: Float32[1]\n * [12]: Int16[2]\n *\n */\nclass StructArrayLayout2f1f2i16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number) {\n const o4 = i * 4;\n const o2 = i * 8;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.int16[o2 + 6] = v3;\n this.int16[o2 + 7] = v4;\n return i;\n }\n}\n\nStructArrayLayout2f1f2i16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint8[2]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout2ub2f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o1 = i * 12;\n const o4 = i * 3;\n this.uint8[o1 + 0] = v0;\n this.uint8[o1 + 1] = v1;\n this.float32[o4 + 1] = v2;\n this.float32[o4 + 2] = v3;\n return i;\n }\n}\n\nStructArrayLayout2ub2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[3]\n *\n */\nclass StructArrayLayout3ui6 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3ui6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3ui6', StructArrayLayout3ui6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint16[2]\n * [8]: Uint32[3]\n * [20]: Uint16[3]\n * [28]: Float32[2]\n * [36]: Uint8[3]\n * [40]: Uint32[1]\n * [44]: Int16[1]\n *\n */\nclass StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const o2 = i * 24;\n const o4 = i * 12;\n const o1 = i * 48;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint32[o4 + 2] = v4;\n this.uint32[o4 + 3] = v5;\n this.uint32[o4 + 4] = v6;\n this.uint16[o2 + 10] = v7;\n this.uint16[o2 + 11] = v8;\n this.uint16[o2 + 12] = v9;\n this.float32[o4 + 7] = v10;\n this.float32[o4 + 8] = v11;\n this.uint8[o1 + 36] = v12;\n this.uint8[o1 + 37] = v13;\n this.uint8[o1 + 38] = v14;\n this.uint32[o4 + 10] = v15;\n this.int16[o2 + 22] = v16;\n return i;\n }\n}\n\nStructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48;\nregister('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[8]\n * [16]: Uint16[15]\n * [48]: Uint32[1]\n * [52]: Float32[2]\n * [60]: Uint16[2]\n *\n */\nclass StructArrayLayout8i15ui1ul2f2ui64 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const o2 = i * 32;\n const o4 = i * 16;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.int16[o2 + 6] = v6;\n this.int16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n this.uint16[o2 + 10] = v10;\n this.uint16[o2 + 11] = v11;\n this.uint16[o2 + 12] = v12;\n this.uint16[o2 + 13] = v13;\n this.uint16[o2 + 14] = v14;\n this.uint16[o2 + 15] = v15;\n this.uint16[o2 + 16] = v16;\n this.uint16[o2 + 17] = v17;\n this.uint16[o2 + 18] = v18;\n this.uint16[o2 + 19] = v19;\n this.uint16[o2 + 20] = v20;\n this.uint16[o2 + 21] = v21;\n this.uint16[o2 + 22] = v22;\n this.uint32[o4 + 12] = v23;\n this.float32[o4 + 13] = v24;\n this.float32[o4 + 14] = v25;\n this.uint16[o2 + 30] = v26;\n this.uint16[o2 + 31] = v27;\n return i;\n }\n}\n\nStructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64;\nregister('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[1]\n *\n */\nclass StructArrayLayout1f4 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.float32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1f4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1f4', StructArrayLayout1f4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout1ui2f12 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 6;\n const o4 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ui2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n * [4]: Uint16[2]\n *\n */\nclass StructArrayLayout1ul2ui8 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 2;\n const o2 = i * 4;\n this.uint32[o4 + 0] = v0;\n this.uint16[o2 + 2] = v1;\n this.uint16[o2 + 3] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ul2ui8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[2]\n *\n */\nclass StructArrayLayout2ui4 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2ui4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2ui4', StructArrayLayout2ui4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n *\n */\nclass StructArrayLayout1ui2 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o2 = i * 1;\n this.uint16[o2 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ui2.prototype.bytesPerElement = 2;\nregister('StructArrayLayout1ui2', StructArrayLayout1ui2);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[4]\n *\n */\nclass StructArrayLayout4f16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o4 = i * 4;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.float32[o4 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4f16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout4f16', StructArrayLayout4f16);\n\n/** @internal */\nclass CollisionBoxStruct extends Struct {\n _structArray: CollisionBoxArray;\n get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorPointY() { return this._structArray.int16[this._pos2 + 1]; }\n get x1() { return this._structArray.int16[this._pos2 + 2]; }\n get y1() { return this._structArray.int16[this._pos2 + 3]; }\n get x2() { return this._structArray.int16[this._pos2 + 4]; }\n get y2() { return this._structArray.int16[this._pos2 + 5]; }\n get featureIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 8]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); }\n}\n\nCollisionBoxStruct.prototype.size = 20;\n\nexport type CollisionBox = CollisionBoxStruct;\n\n/** @internal */\nexport class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {\n /**\n * Return the CollisionBoxStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): CollisionBoxStruct {\n return new CollisionBoxStruct(this, index);\n }\n}\n\nregister('CollisionBoxArray', CollisionBoxArray);\n\n/** @internal */\nclass PlacedSymbolStruct extends Struct {\n _structArray: PlacedSymbolArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get glyphStartIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get numGlyphs() { return this._structArray.uint16[this._pos2 + 3]; }\n get vertexStartIndex() { return this._structArray.uint32[this._pos4 + 2]; }\n get lineStartIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get lineLength() { return this._structArray.uint32[this._pos4 + 4]; }\n get segment() { return this._structArray.uint16[this._pos2 + 10]; }\n get lowerSize() { return this._structArray.uint16[this._pos2 + 11]; }\n get upperSize() { return this._structArray.uint16[this._pos2 + 12]; }\n get lineOffsetX() { return this._structArray.float32[this._pos4 + 7]; }\n get lineOffsetY() { return this._structArray.float32[this._pos4 + 8]; }\n get writingMode() { return this._structArray.uint8[this._pos1 + 36]; }\n get placedOrientation() { return this._structArray.uint8[this._pos1 + 37]; }\n set placedOrientation(x: number) { this._structArray.uint8[this._pos1 + 37] = x; }\n get hidden() { return this._structArray.uint8[this._pos1 + 38]; }\n set hidden(x: number) { this._structArray.uint8[this._pos1 + 38] = x; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 10]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 10] = x; }\n get associatedIconIndex() { return this._structArray.int16[this._pos2 + 22]; }\n}\n\nPlacedSymbolStruct.prototype.size = 48;\n\nexport type PlacedSymbol = PlacedSymbolStruct;\n\n/** @internal */\nexport class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 {\n /**\n * Return the PlacedSymbolStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): PlacedSymbolStruct {\n return new PlacedSymbolStruct(this, index);\n }\n}\n\nregister('PlacedSymbolArray', PlacedSymbolArray);\n\n/** @internal */\nclass SymbolInstanceStruct extends Struct {\n _structArray: SymbolInstanceArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get rightJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 2]; }\n get centerJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 3]; }\n get leftJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 4]; }\n get verticalPlacedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 5]; }\n get placedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 6]; }\n get verticalPlacedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 7]; }\n get key() { return this._structArray.uint16[this._pos2 + 8]; }\n get textBoxStartIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get textBoxEndIndex() { return this._structArray.uint16[this._pos2 + 10]; }\n get verticalTextBoxStartIndex() { return this._structArray.uint16[this._pos2 + 11]; }\n get verticalTextBoxEndIndex() { return this._structArray.uint16[this._pos2 + 12]; }\n get iconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 13]; }\n get iconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 14]; }\n get verticalIconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 15]; }\n get verticalIconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 16]; }\n get featureIndex() { return this._structArray.uint16[this._pos2 + 17]; }\n get numHorizontalGlyphVertices() { return this._structArray.uint16[this._pos2 + 18]; }\n get numVerticalGlyphVertices() { return this._structArray.uint16[this._pos2 + 19]; }\n get numIconVertices() { return this._structArray.uint16[this._pos2 + 20]; }\n get numVerticalIconVertices() { return this._structArray.uint16[this._pos2 + 21]; }\n get useRuntimeCollisionCircles() { return this._structArray.uint16[this._pos2 + 22]; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 12] = x; }\n get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; }\n get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; }\n get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; }\n get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; }\n}\n\nSymbolInstanceStruct.prototype.size = 64;\n\nexport type SymbolInstance = SymbolInstanceStruct;\n\n/** @internal */\nexport class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 {\n /**\n * Return the SymbolInstanceStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): SymbolInstanceStruct {\n return new SymbolInstanceStruct(this, index);\n }\n}\n\nregister('SymbolInstanceArray', SymbolInstanceArray);\n\n/** @internal */\nexport class GlyphOffsetArray extends StructArrayLayout1f4 {\n getoffsetX(index: number) { return this.float32[index * 1 + 0]; }\n}\n\nregister('GlyphOffsetArray', GlyphOffsetArray);\n\n/** @internal */\nexport class SymbolLineVertexArray extends StructArrayLayout3i6 {\n getx(index: number) { return this.int16[index * 3 + 0]; }\n gety(index: number) { return this.int16[index * 3 + 1]; }\n gettileUnitDistanceFromAnchor(index: number) { return this.int16[index * 3 + 2]; }\n}\n\nregister('SymbolLineVertexArray', SymbolLineVertexArray);\n\n/** @internal */\nclass TextAnchorOffsetStruct extends Struct {\n _structArray: TextAnchorOffsetArray;\n get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; }\n get textOffset0() { return this._structArray.float32[this._pos4 + 1]; }\n get textOffset1() { return this._structArray.float32[this._pos4 + 2]; }\n}\n\nTextAnchorOffsetStruct.prototype.size = 12;\n\nexport type TextAnchorOffset = TextAnchorOffsetStruct;\n\n/** @internal */\nexport class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 {\n /**\n * Return the TextAnchorOffsetStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): TextAnchorOffsetStruct {\n return new TextAnchorOffsetStruct(this, index);\n }\n}\n\nregister('TextAnchorOffsetArray', TextAnchorOffsetArray);\n\n/** @internal */\nclass FeatureIndexStruct extends Struct {\n _structArray: FeatureIndexArray;\n get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 3]; }\n}\n\nFeatureIndexStruct.prototype.size = 8;\n\nexport type FeatureIndex = FeatureIndexStruct;\n\n/** @internal */\nexport class FeatureIndexArray extends StructArrayLayout1ul2ui8 {\n /**\n * Return the FeatureIndexStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): FeatureIndexStruct {\n return new FeatureIndexStruct(this, index);\n }\n}\n\nregister('FeatureIndexArray', FeatureIndexArray);\n\nexport class PosArray extends StructArrayLayout2i4 {}\nexport class Pos3dArray extends StructArrayLayout3i6 {}\nexport class RasterBoundsArray extends StructArrayLayout4i8 {}\nexport class CircleLayoutArray extends StructArrayLayout2i4 {}\nexport class FillLayoutArray extends StructArrayLayout2i4 {}\nexport class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 {}\nexport class HeatmapLayoutArray extends StructArrayLayout2i4 {}\nexport class LineLayoutArray extends StructArrayLayout2i4ub8 {}\nexport class LineExtLayoutArray extends StructArrayLayout2f8 {}\nexport class PatternLayoutArray extends StructArrayLayout10ui20 {}\nexport class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 {}\nexport class SymbolDynamicLayoutArray extends StructArrayLayout3f12 {}\nexport class SymbolOpacityArray extends StructArrayLayout1ul4 {}\nexport class CollisionBoxLayoutArray extends StructArrayLayout2i2i2i12 {}\nexport class CollisionCircleLayoutArray extends StructArrayLayout2f1f2i16 {}\nexport class CollisionVertexArray extends StructArrayLayout2ub2f12 {}\nexport class QuadTriangleArray extends StructArrayLayout3ui6 {}\nexport class TriangleIndexArray extends StructArrayLayout3ui6 {}\nexport class LineIndexArray extends StructArrayLayout2ui4 {}\nexport class LineStripIndexArray extends StructArrayLayout1ui2 {}\nexport {\n StructArrayLayout2i4,\n StructArrayLayout3i6,\n StructArrayLayout4i8,\n StructArrayLayout2i4i12,\n StructArrayLayout2i4ub8,\n StructArrayLayout2f8,\n StructArrayLayout10ui20,\n StructArrayLayout4i4ui4i24,\n StructArrayLayout3f12,\n StructArrayLayout1ul4,\n StructArrayLayout6i1ul2ui20,\n StructArrayLayout2i2i2i12,\n StructArrayLayout2f1f2i16,\n StructArrayLayout2ub2f12,\n StructArrayLayout3ui6,\n StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48,\n StructArrayLayout8i15ui1ul2f2ui64,\n StructArrayLayout1f4,\n StructArrayLayout1ui2f12,\n StructArrayLayout1ul2ui8,\n StructArrayLayout2ui4,\n StructArrayLayout1ui2,\n StructArrayLayout4f16\n};\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","import {warnOnce} from '../util/util';\n\nimport {register} from '../util/web_worker_transfer';\n\nimport type {VertexArrayObject} from '../render/vertex_array_object';\nimport type {StructArray} from '../util/struct_array';\n\n/**\n * @internal\n * A single segment of a vector\n */\nexport type Segment = {\n sortKey?: number;\n vertexOffset: number;\n primitiveOffset: number;\n vertexLength: number;\n primitiveLength: number;\n vaos: {[_: string]: VertexArrayObject};\n};\n\n/**\n * @internal\n * Used for calculations on vector segments\n */\nexport class SegmentVector {\n static MAX_VERTEX_ARRAY_LENGTH: number;\n segments: Array;\n\n constructor(segments: Array = []) {\n this.segments = segments;\n }\n\n prepareSegment(\n numVertices: number,\n layoutVertexArray: StructArray,\n indexArray: StructArray,\n sortKey?: number\n ): Segment {\n let segment: Segment = this.segments[this.segments.length - 1];\n if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`);\n if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) {\n segment = ({\n vertexOffset: layoutVertexArray.length,\n primitiveOffset: indexArray.length,\n vertexLength: 0,\n primitiveLength: 0\n } as any);\n if (sortKey !== undefined) segment.sortKey = sortKey;\n this.segments.push(segment);\n }\n return segment;\n }\n\n get() {\n return this.segments;\n }\n\n destroy() {\n for (const segment of this.segments) {\n for (const k in segment.vaos) {\n segment.vaos[k].destroy();\n }\n }\n }\n\n static simpleSegment(\n vertexOffset: number,\n primitiveOffset: number,\n vertexLength: number,\n primitiveLength: number\n ): SegmentVector {\n return new SegmentVector([{\n vertexOffset,\n primitiveOffset,\n vertexLength,\n primitiveLength,\n vaos: {},\n sortKey: 0\n }]);\n }\n}\n\n/**\n * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit\n * addressing of vertex buffers.\n */\nSegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1;\n\nregister('SegmentVector', SegmentVector);\n","import {clamp} from '../util/util';\n\n/**\n * Packs two numbers, interpreted as 8-bit unsigned integers, into a single\n * float. Unpack them in the shader using the `unpack_float()` function,\n * defined in _prelude.vertex.glsl\n */\nexport function packUint8ToFloat(a: number, b: number) {\n // coerce a and b to 8-bit ints\n a = clamp(Math.floor(a), 0, 255);\n b = clamp(Math.floor(b), 0, 255);\n return 256 * a + b;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const patternAttributes = createLayout([\n // [tl.x, tl.y, br.x, br.y]\n {name: 'a_pattern_from', components: 4, type: 'Uint16'},\n {name: 'a_pattern_to', components: 4, type: 'Uint16'},\n {name: 'a_pixel_ratio_from', components: 1, type: 'Uint16'},\n {name: 'a_pixel_ratio_to', components: 1, type: 'Uint16'},\n]);\n","/**\n * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} key ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash \n */\n\nfunction murmurhash3_32_gc(key, seed) {\n\tvar remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;\n\t\n\tremainder = key.length & 3; // key.length % 4\n\tbytes = key.length - remainder;\n\th1 = seed;\n\tc1 = 0xcc9e2d51;\n\tc2 = 0x1b873593;\n\ti = 0;\n\t\n\twhile (i < bytes) {\n\t \tk1 = \n\t \t ((key.charCodeAt(i) & 0xff)) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 8) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 16) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 24);\n\t\t++i;\n\t\t\n\t\tk1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;\n\n\t\th1 ^= k1;\n h1 = (h1 << 13) | (h1 >>> 19);\n\t\th1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;\n\t\th1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));\n\t}\n\t\n\tk1 = 0;\n\t\n\tswitch (remainder) {\n\t\tcase 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;\n\t\tcase 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;\n\t\tcase 1: k1 ^= (key.charCodeAt(i) & 0xff);\n\t\t\n\t\tk1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;\n\t\th1 ^= k1;\n\t}\n\t\n\th1 ^= key.length;\n\n\th1 ^= h1 >>> 16;\n\th1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;\n\th1 ^= h1 >>> 13;\n\th1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;\n\th1 ^= h1 >>> 16;\n\n\treturn h1 >>> 0;\n}\n\nif(typeof module !== \"undefined\") {\n module.exports = murmurhash3_32_gc\n}","/**\n * JS Implementation of MurmurHash2\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} str ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash\n */\n\nfunction murmurhash2_32_gc(str, seed) {\n var\n l = str.length,\n h = seed ^ l,\n i = 0,\n k;\n \n while (l >= 4) {\n \tk = \n \t ((str.charCodeAt(i) & 0xff)) |\n \t ((str.charCodeAt(++i) & 0xff) << 8) |\n \t ((str.charCodeAt(++i) & 0xff) << 16) |\n \t ((str.charCodeAt(++i) & 0xff) << 24);\n \n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n k ^= k >>> 24;\n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\n\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;\n\n l -= 4;\n ++i;\n }\n \n switch (l) {\n case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n case 1: h ^= (str.charCodeAt(i) & 0xff);\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n }\n\n h ^= h >>> 13;\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n h ^= h >>> 15;\n\n return h >>> 0;\n}\n\nif(typeof module !== undefined) {\n module.exports = murmurhash2_32_gc\n}\n","var murmur3 = require(\"./murmurhash3_gc.js\")\nvar murmur2 = require(\"./murmurhash2_gc.js\")\n\nmodule.exports = murmur3\nmodule.exports.murmur3 = murmur3\nmodule.exports.murmur2 = murmur2\n","import murmur3 from 'murmurhash-js';\nimport {register} from '../util/web_worker_transfer';\n\ntype SerializedFeaturePositionMap = {\n ids: Float64Array;\n positions: Uint32Array;\n};\n\ntype FeaturePosition = {\n index: number;\n start: number;\n end: number;\n};\n\n// A transferable data structure that maps feature ids to their indices and buffer offsets\nexport class FeaturePositionMap {\n ids: Array;\n positions: Array;\n indexed: boolean;\n\n constructor() {\n this.ids = [];\n this.positions = [];\n this.indexed = false;\n }\n\n add(id: unknown, index: number, start: number, end: number) {\n this.ids.push(getNumericId(id));\n this.positions.push(index, start, end);\n }\n\n getPositions(id: unknown): Array {\n if (!this.indexed) throw new Error('Trying to get index, but feature positions are not indexed');\n\n const intId = getNumericId(id);\n\n // binary search for the first occurrence of id in this.ids;\n // relies on ids/positions being sorted by id, which happens in serialization\n let i = 0;\n let j = this.ids.length - 1;\n while (i < j) {\n const m = (i + j) >> 1;\n if (this.ids[m] >= intId) {\n j = m;\n } else {\n i = m + 1;\n }\n }\n const positions = [];\n while (this.ids[i] === intId) {\n const index = this.positions[3 * i];\n const start = this.positions[3 * i + 1];\n const end = this.positions[3 * i + 2];\n positions.push({index, start, end});\n i++;\n }\n return positions;\n }\n\n static serialize(map: FeaturePositionMap, transferables: Array): SerializedFeaturePositionMap {\n const ids = new Float64Array(map.ids);\n const positions = new Uint32Array(map.positions);\n\n sort(ids, positions, 0, ids.length - 1);\n\n if (transferables) {\n transferables.push(ids.buffer, positions.buffer);\n }\n\n return {ids, positions};\n }\n\n static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap {\n const map = new FeaturePositionMap();\n // after transferring, we only use these arrays statically (no pushes),\n // so TypedArray vs Array distinction that flow points out doesn't matter\n map.ids = (obj.ids as any);\n map.positions = (obj.positions as any);\n map.indexed = true;\n return map;\n }\n}\n\nfunction getNumericId(value: unknown) {\n const numValue = +value;\n if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) {\n return numValue;\n }\n return murmur3(String(value));\n}\n\n// custom quicksort that sorts ids, indices and offsets together (by ids)\n// uses Hoare partitioning & manual tail call optimization to avoid worst case scenarios\nfunction sort(ids, positions, left, right) {\n while (left < right) {\n const pivot = ids[(left + right) >> 1];\n let i = left - 1;\n let j = right + 1;\n\n while (true) {\n do i++; while (ids[i] < pivot);\n do j--; while (ids[j] > pivot);\n if (i >= j) break;\n swap(ids, i, j);\n swap(positions, 3 * i, 3 * j);\n swap(positions, 3 * i + 1, 3 * j + 1);\n swap(positions, 3 * i + 2, 3 * j + 2);\n }\n\n if (j - left < right - j) {\n sort(ids, positions, left, j);\n left = j + 1;\n } else {\n sort(ids, positions, j + 1, right);\n right = j;\n }\n }\n}\n\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nregister('FeaturePositionMap', FeaturePositionMap);\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Context} from '../gl/context';\nimport {mat4, vec2, vec3, vec4} from 'gl-matrix';\n\ntype $ObjMap any> = {\n [K in keyof T]: F extends (v: T[K]) => infer R ? R : never;\n};\n\nexport type UniformValues = $ObjMap(u: Uniform) => V>;\nexport type UniformLocations = {[_: string]: WebGLUniformLocation};\n\n/**\n * @internal\n * A base uniform abstract class\n */\nabstract class Uniform {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n location: WebGLUniformLocation;\n current: T;\n\n constructor(context: Context, location: WebGLUniformLocation) {\n this.gl = context.gl;\n this.location = location;\n }\n\n abstract set(v: T): void;\n}\n\nclass Uniform1i extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1i(this.location, v);\n }\n }\n}\n\nclass Uniform1f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1f(this.location, v);\n }\n }\n}\n\nclass Uniform2f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0];\n }\n\n set(v: vec2): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1]) {\n this.current = v;\n this.gl.uniform2f(this.location, v[0], v[1]);\n }\n }\n}\n\nclass Uniform3f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0];\n }\n\n set(v: vec3): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) {\n this.current = v;\n this.gl.uniform3f(this.location, v[0], v[1], v[2]);\n }\n }\n}\n\nclass Uniform4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0, 0];\n }\n\n set(v: vec4): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] ||\n v[2] !== this.current[2] || v[3] !== this.current[3]) {\n this.current = v;\n this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]);\n }\n }\n}\n\nclass UniformColor extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = Color.transparent;\n }\n\n set(v: Color): void {\n if (v.r !== this.current.r || v.g !== this.current.g ||\n v.b !== this.current.b || v.a !== this.current.a) {\n this.current = v;\n this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a);\n }\n }\n}\n\nconst emptyMat4 = new Float32Array(16) as mat4;\nclass UniformMatrix4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = emptyMat4;\n }\n\n set(v: mat4): void {\n // The vast majority of matrix comparisons that will trip this set\n // happen at i=12 or i=0, so we check those first to avoid lots of\n // unnecessary iteration:\n if (v[12] !== this.current[12] || v[0] !== this.current[0]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n return;\n }\n for (let i = 1; i < 16; i++) {\n if (v[i] !== this.current[i]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n break;\n }\n }\n }\n}\n\nexport {\n Uniform,\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n Uniform4f,\n UniformColor,\n UniformMatrix4f\n};\n\n/**\n * @internal\n * A uniform bindings\n */\nexport type UniformBindings = {[_: string]: Uniform};\n","import {packUint8ToFloat} from '../shaders/encode_attribute';\nimport {Color, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types.g';\nimport {clamp} from '../util/util';\nimport {patternAttributes} from './bucket/pattern_attributes';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {FeaturePositionMap} from './feature_position_map';\nimport {Uniform, Uniform1f, UniformColor, Uniform4f} from '../render/uniform_binding';\n\nimport type {UniformLocations} from '../render/uniform_binding';\n\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Context} from '../gl/context';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {CrossfadeParameters} from '../style/evaluation_parameters';\nimport type {StructArray, StructArrayMember} from '../util/struct_array';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {\n Feature,\n FeatureState,\n GlobalProperties,\n SourceExpression,\n CompositeExpression,\n FormattedSection\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureStates} from '../source/source_state';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type BinderUniform = {\n name: string;\n property: string;\n binding: Uniform;\n};\n\nfunction packColor(color: Color): [number, number] {\n return [\n packUint8ToFloat(255 * color.r, 255 * color.g),\n packUint8ToFloat(255 * color.b, 255 * color.a)\n ];\n}\n\n/**\n * `Binder` is the interface definition for the strategies for constructing,\n * uploading, and binding paint property data as GLSL attributes. Most style-\n * spec properties have a 1:1 relationship to shader attribute/uniforms, but\n * some require multiple values per feature to be passed to the GPU, and in\n * those cases we bind multiple attributes/uniforms.\n *\n * It has three implementations, one for each of the three strategies we use:\n *\n * * For _constant_ properties -- those whose value is a constant, or the constant\n * result of evaluating a camera expression at a particular camera position -- we\n * don't need a vertex attribute buffer, and instead use a uniform.\n * * For data expressions, we use a vertex buffer with a single attribute value,\n * the evaluated result of the source function for the given feature.\n * * For composite expressions, we use a vertex buffer with two attributes: min and\n * max values covering the range of zooms at which we expect the tile to be\n * displayed. These values are calculated by evaluating the composite expression for\n * the given feature at strategically chosen zoom levels. In addition to this\n * attribute data, we also use a uniform value which the shader uses to interpolate\n * between the min and max value at the final displayed zoom level. The use of a\n * uniform allows us to cheaply update the value on every frame.\n *\n * Note that the shader source varies depending on whether we're using a uniform or\n * attribute. We dynamically compile shaders at runtime to accommodate this.\n */\ninterface AttributeBinder {\n populatePaintArray(\n length: number,\n feature: Feature,\n imagePositions: {[_: string]: ImagePosition},\n canonical?: CanonicalTileID,\n formattedSection?: FormattedSection\n ): void;\n updatePaintArray(\n start: number,\n length: number,\n feature: Feature,\n featureState: FeatureState,\n imagePositions: {[_: string]: ImagePosition}\n ): void;\n upload(a: Context): void;\n destroy(): void;\n}\n\ninterface UniformBinder {\n uniformNames: Array;\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue,\n uniformName: string\n ): void;\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial>;\n}\n\nclass ConstantBinder implements UniformBinder {\n value: unknown;\n type: string;\n uniformNames: Array;\n\n constructor(value: unknown, names: Array, type: string) {\n this.value = value;\n this.uniformNames = names.map(name => `u_${name}`);\n this.type = type;\n }\n\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue\n ): void {\n uniform.set(currentValue.constantOr(this.value));\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Partial> {\n return (this.type === 'color') ?\n new UniformColor(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedConstantBinder implements UniformBinder {\n uniformNames: Array;\n patternFrom: Array;\n patternTo: Array;\n pixelRatioFrom: number;\n pixelRatioTo: number;\n\n constructor(value: unknown, names: Array) {\n this.uniformNames = names.map(name => `u_${name}`);\n this.patternFrom = null;\n this.patternTo = null;\n this.pixelRatioFrom = 1.0;\n this.pixelRatioTo = 1.0;\n }\n\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n this.pixelRatioFrom = posFrom.pixelRatio;\n this.pixelRatioTo = posTo.pixelRatio;\n this.patternFrom = posFrom.tlbr;\n this.patternTo = posTo.tlbr;\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties, currentValue: PossiblyEvaluatedPropertyValue, uniformName: string) {\n const pos =\n uniformName === 'u_pattern_to' ? this.patternTo :\n uniformName === 'u_pattern_from' ? this.patternFrom :\n uniformName === 'u_pixel_ratio_to' ? this.pixelRatioTo :\n uniformName === 'u_pixel_ratio_from' ? this.pixelRatioFrom : null;\n if (pos) uniform.set(pos);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial> {\n return name.substr(0, 9) === 'u_pattern' ?\n new Uniform4f(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass SourceExpressionBinder implements AttributeBinder {\n expression: SourceExpression;\n type: string;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: SourceExpression, names: Array, type: string, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.type = type;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 2 : 1,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const start = this.paintVertexArray.length;\n const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection);\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, value);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const value = this.expression.evaluate({zoom: 0}, feature, featureState);\n this._setPaintValue(start, end, value);\n }\n\n _setPaintValue(start, end, value) {\n if (this.type === 'color') {\n const color = packColor(value);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, color[0], color[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, value);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(value));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n}\n\nclass CompositeExpressionBinder implements AttributeBinder, UniformBinder {\n expression: CompositeExpression;\n uniformNames: Array;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: CompositeExpression, names: Array, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.uniformNames = names.map(name => `u_${name}_t`);\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 4 : 2,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection);\n const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection);\n const start = this.paintVertexArray.length;\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, min, max);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const min = this.expression.evaluate({zoom: this.zoom}, feature, featureState);\n const max = this.expression.evaluate({zoom: this.zoom + 1}, feature, featureState);\n this._setPaintValue(start, end, min, max);\n }\n\n _setPaintValue(start, end, min, max) {\n if (this.type === 'color') {\n const minColor = packColor(min);\n const maxColor = packColor(max);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, min, max);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties): void {\n const currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom;\n const factor = clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1);\n uniform.set(factor);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Uniform1f {\n return new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedCompositeBinder implements AttributeBinder {\n expression: CompositeExpression;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n layerId: string;\n\n zoomInPaintVertexArray: StructArray;\n zoomOutPaintVertexArray: StructArray;\n zoomInPaintVertexBuffer: VertexBuffer;\n zoomOutPaintVertexBuffer: VertexBuffer;\n paintVertexAttributes: Array;\n\n constructor(expression: CompositeExpression, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }, layerId: string) {\n this.expression = expression;\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.layerId = layerId;\n\n this.zoomInPaintVertexArray = new PaintVertexArray();\n this.zoomOutPaintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}) {\n const start = this.zoomInPaintVertexArray.length;\n this.zoomInPaintVertexArray.resize(length);\n this.zoomOutPaintVertexArray.resize(length);\n this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}) {\n this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n _setPaintValues(start, end, patterns, positions) {\n if (!positions || !patterns) return;\n\n const {min, mid, max} = patterns;\n const imageMin = positions[min];\n const imageMid = positions[mid];\n const imageMax = positions[max];\n if (!imageMin || !imageMid || !imageMax) return;\n\n // We populate two paint arrays because, for cross-faded properties, we don't know which direction\n // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass\n // unnecessary vertex data to the shaders, we determine which to upload at draw time.\n for (let i = start; i < end; i++) {\n this.zoomInPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1],\n imageMid.pixelRatio,\n imageMin.pixelRatio,\n );\n this.zoomOutPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1],\n imageMid.pixelRatio,\n imageMax.pixelRatio,\n );\n }\n }\n\n upload(context: Context) {\n if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) {\n this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n }\n }\n\n destroy() {\n if (this.zoomOutPaintVertexBuffer) this.zoomOutPaintVertexBuffer.destroy();\n if (this.zoomInPaintVertexBuffer) this.zoomInPaintVertexBuffer.destroy();\n }\n}\n\n/**\n * @internal\n * ProgramConfiguration contains the logic for binding style layer properties and tile\n * layer feature data into GL program uniforms and vertex attributes.\n *\n * Non-data-driven property values are bound to shader uniforms. Data-driven property\n * values are bound to vertex attributes. In order to support a uniform GLSL syntax over\n * both, [Mapbox GL Shaders](https://github.com/mapbox/mapbox-gl-shaders) defines a `#pragma`\n * abstraction, which ProgramConfiguration is responsible for implementing. At runtime,\n * it examines the attributes of a particular layer, combines this with fixed knowledge\n * about how layers of the particular type are implemented, and determines which uniforms\n * and vertex attributes will be required. It can then substitute the appropriate text\n * into the shader source code, create and link a program, and bind the uniforms and\n * vertex attributes in preparation for drawing.\n *\n * When a vector tile is parsed, this same configuration information is used to\n * populate the attribute buffers needed for data-driven styling using the zoom\n * level and feature property data.\n */\nexport class ProgramConfiguration {\n binders: {[_: string]: AttributeBinder | UniformBinder};\n cacheKey: string;\n\n _buffers: Array;\n\n constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean) {\n this.binders = {};\n this._buffers = [];\n\n const keys = [];\n\n for (const property in layer.paint._values) {\n if (!filterProperties(property)) continue;\n const value = (layer.paint as any).get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n const names = paintAttributeNames(property, layer.type);\n const expression = value.value;\n const type = value.property.specification.type;\n const useIntegerZoom = (value.property as any).useIntegerZoom;\n const propType = value.property.specification['property-type'];\n const isCrossFaded = propType === 'cross-faded' || propType === 'cross-faded-data-driven';\n\n if (expression.kind === 'constant') {\n this.binders[property] = isCrossFaded ?\n new CrossFadedConstantBinder(expression.value, names) :\n new ConstantBinder(expression.value, names, type);\n keys.push(`/u_${property}`);\n\n } else if (expression.kind === 'source' || isCrossFaded) {\n const StructArrayLayout = layoutType(property, type, 'source');\n this.binders[property] = isCrossFaded ?\n new CrossFadedCompositeBinder(expression as CompositeExpression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) :\n new SourceExpressionBinder(expression as SourceExpression, names, type, StructArrayLayout);\n keys.push(`/a_${property}`);\n\n } else {\n const StructArrayLayout = layoutType(property, type, 'composite');\n this.binders[property] = new CompositeExpressionBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout);\n keys.push(`/z_${property}`);\n }\n }\n\n this.cacheKey = keys.sort().join('');\n }\n\n getMaxValue(property: string): number {\n const binder = this.binders[property];\n return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0;\n }\n\n populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n (binder as AttributeBinder).populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection);\n }\n }\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof CrossFadedConstantBinder)\n binder.setConstantPatternPositions(posTo, posFrom);\n }\n }\n\n updatePaintArrays(\n featureStates: FeatureStates,\n featureMap: FeaturePositionMap,\n vtLayer: VectorTileLayer,\n layer: TypedStyleLayer,\n imagePositions: {[_: string]: ImagePosition}\n ): boolean {\n let dirty: boolean = false;\n for (const id in featureStates) {\n const positions = featureMap.getPositions(id);\n\n for (const pos of positions) {\n const feature = vtLayer.feature(pos.index);\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ||\n binder instanceof CrossFadedCompositeBinder) && (binder as any).expression.isStateDependent === true) {\n //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255\n const value = (layer.paint as any).get(property);\n (binder as any).expression = value.value;\n (binder as AttributeBinder).updatePaintArray(pos.start, pos.end, feature, featureStates[id], imagePositions);\n dirty = true;\n }\n }\n }\n }\n return dirty;\n }\n\n defines(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {\n result.push(...binder.uniformNames.map(name => `#define HAS_UNIFORM_${name}`));\n }\n }\n return result;\n }\n\n getBinderAttributes(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) {\n for (let i = 0; i < binder.paintVertexAttributes.length; i++) {\n result.push(binder.paintVertexAttributes[i].name);\n }\n } else if (binder instanceof CrossFadedCompositeBinder) {\n for (let i = 0; i < patternAttributes.members.length; i++) {\n result.push(patternAttributes.members[i].name);\n }\n }\n }\n return result;\n }\n\n getBinderUniforms(): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const uniformName of binder.uniformNames) {\n uniforms.push(uniformName);\n }\n }\n }\n return uniforms;\n }\n\n getPaintVertexBuffers(): Array {\n return this._buffers;\n }\n\n getUniforms(context: Context, locations: UniformLocations): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const name of binder.uniformNames) {\n if (locations[name]) {\n const binding = binder.getBinding(context, locations[name], name);\n uniforms.push({name, property, binding});\n }\n }\n }\n }\n return uniforms;\n }\n\n setUniforms(\n context: Context,\n binderUniforms: Array,\n properties: any,\n globals: GlobalProperties\n ) {\n // Uniform state bindings are owned by the Program, but we set them\n // from within the ProgramConfiguraton's binder members.\n for (const {name, property, binding} of binderUniforms) {\n (this.binders[property] as any).setUniform(binding, globals, properties.get(property), name);\n }\n }\n\n updatePaintBuffers(crossfade?: CrossfadeParameters) {\n this._buffers = [];\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (crossfade && binder instanceof CrossFadedCompositeBinder) {\n const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;\n if (patternVertexBuffer) this._buffers.push(patternVertexBuffer);\n\n } else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) {\n this._buffers.push(binder.paintVertexBuffer);\n }\n }\n }\n\n upload(context: Context) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.upload(context);\n }\n this.updatePaintBuffers();\n }\n\n destroy() {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.destroy();\n }\n }\n}\n\nexport class ProgramConfigurationSet {\n programConfigurations: {[_: string]: ProgramConfiguration};\n needsUpload: boolean;\n _featureMap: FeaturePositionMap;\n _bufferOffset: number;\n\n constructor(layers: ReadonlyArray, zoom: number, filterProperties: (_: string) => boolean = () => true) {\n this.programConfigurations = {};\n for (const layer of layers) {\n this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties);\n }\n this.needsUpload = false;\n this._featureMap = new FeaturePositionMap();\n this._bufferOffset = 0;\n }\n\n populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[_: string]: ImagePosition}, canonical: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const key in this.programConfigurations) {\n this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection);\n }\n\n if (feature.id !== undefined) {\n this._featureMap.add(feature.id, index, this._bufferOffset, length);\n }\n this._bufferOffset = length;\n\n this.needsUpload = true;\n }\n\n updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: ReadonlyArray, imagePositions: {[_: string]: ImagePosition}) {\n for (const layer of layers) {\n this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload;\n }\n }\n\n get(layerId: string) {\n return this.programConfigurations[layerId];\n }\n\n upload(context: Context) {\n if (!this.needsUpload) return;\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].upload(context);\n }\n this.needsUpload = false;\n }\n\n destroy() {\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].destroy();\n }\n }\n}\n\nfunction paintAttributeNames(property, type) {\n const attributeNameExceptions = {\n 'text-opacity': ['opacity'],\n 'icon-opacity': ['opacity'],\n 'text-color': ['fill_color'],\n 'icon-color': ['fill_color'],\n 'text-halo-color': ['halo_color'],\n 'icon-halo-color': ['halo_color'],\n 'text-halo-blur': ['halo_blur'],\n 'icon-halo-blur': ['halo_blur'],\n 'text-halo-width': ['halo_width'],\n 'icon-halo-width': ['halo_width'],\n 'line-gap-width': ['gapwidth'],\n 'line-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-extrusion-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n };\n\n return attributeNameExceptions[property] || [property.replace(`${type}-`, '').replace(/-/g, '_')];\n}\n\nfunction getLayoutException(property) {\n const propertyExceptions = {\n 'line-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-extrusion-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n }\n };\n\n return propertyExceptions[property];\n}\n\nfunction layoutType(property, type, binderType) {\n const defaultLayouts = {\n 'color': {\n 'source': StructArrayLayout2f8,\n 'composite': StructArrayLayout4f16\n },\n 'number': {\n 'source': StructArrayLayout1f4,\n 'composite': StructArrayLayout2f8\n }\n };\n\n const layoutException = getLayoutException(property);\n return layoutException && layoutException[binderType] || defaultLayouts[type][binderType];\n}\n\nregister('ConstantBinder', ConstantBinder);\nregister('CrossFadedConstantBinder', CrossFadedConstantBinder);\nregister('SourceExpressionBinder', SourceExpressionBinder);\nregister('CrossFadedCompositeBinder', CrossFadedCompositeBinder);\nregister('CompositeExpressionBinder', CompositeExpressionBinder);\nregister('ProgramConfiguration', ProgramConfiguration, {omit: ['_buffers']});\nregister('ProgramConfigurationSet', ProgramConfigurationSet);\n","/**\n * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of\n * all source features normalized to this extent upon load.\n *\n * The value is a consequence of the following:\n *\n * * Vertex buffer store positions as signed 16 bit integers.\n * * One bit is lost for signedness to support tile buffers.\n * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.\n * * One bit is lost to support features extending past the extent on the right edge of the tile.\n * * This leaves us with 2^13 = 8192\n */\nexport const EXTENT = 8192;\n","import {warnOnce, clamp} from '../util/util';\n\nimport {EXTENT} from './extent';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n// These bounds define the minimum and maximum supported coordinate values.\n// While visible coordinates are within [0, EXTENT], tiles may theoretically\n// contain coordinates within [-Infinity, Infinity]. Our range is limited by the\n// number of bits used to represent the coordinate.\nconst BITS = 15;\nconst MAX = Math.pow(2, BITS - 1) - 1;\nconst MIN = -MAX - 1;\n\n/**\n * Loads a geometry from a VectorTileFeature and scales it to the common extent\n * used internally.\n * @param feature - the vector tile feature to load\n */\nexport function loadGeometry(feature: VectorTileFeature): Array> {\n const scale = EXTENT / feature.extent;\n const geometry = feature.loadGeometry();\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n for (let p = 0; p < ring.length; p++) {\n const point = ring[p];\n // round here because mapbox-gl-native uses integers to represent\n // points and we need to do the same to avoid renering differences.\n const x = Math.round(point.x * scale);\n const y = Math.round(point.y * scale);\n\n point.x = clamp(x, MIN, MAX);\n point.y = clamp(y, MIN, MAX);\n\n if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) {\n // warn when exceeding allowed extent except for the 1-px-off case\n // https://github.com/mapbox/mapbox-gl-js/issues/8992\n warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size');\n }\n }\n }\n return geometry;\n}\n","import {loadGeometry} from './load_geometry';\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\n\ntype EvaluationFeature = Feature & { geometry: Array> };\n/**\n * Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which\n * will be loaded based on necessity.\n * @param feature - the feature to evaluate\n * @param needGeometry - if set to true this will load the geometry\n */\nexport function toEvaluationFeature(feature: VectorTileFeature, needGeometry: boolean): EvaluationFeature {\n return {type: feature.type,\n id: feature.id,\n properties: feature.properties,\n geometry: needGeometry ? loadGeometry(feature) : []};\n}\n","import {CircleLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './circle_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EXTENT} from '../extent';\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nfunction addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {\n layoutVertexArray.emplaceBack(\n (x * 2) + ((extrudeX + 1) / 2),\n (y * 2) + ((extrudeY + 1) / 2));\n}\n\n/**\n * @internal\n * Circles are represented by two triangles.\n *\n * Each corner has a pos that is the center of the circle and an extrusion\n * vector that is where it points.\n */\nexport class CircleBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layerIds: Array;\n layers: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: CircleLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new CircleLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.segments = new SegmentVector();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const styleLayer = this.layers[0];\n const bucketFeatures: BucketFeature[] = [];\n let circleSortKey = null;\n let sortFeaturesByKey = false;\n\n // Heatmap layers are handled in this bucket and have no evaluated properties, so we check our access\n if (styleLayer.type === 'circle') {\n circleSortKey = (styleLayer as CircleStyleLayer).layout.get('circle-sort-key');\n sortFeaturesByKey = !circleSortKey.isConstant();\n }\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n circleSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n const feature = features[index].feature;\n\n this.addFeature(bucketFeature, geometry, index, canonical);\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID) {\n for (const ring of geometry) {\n for (const point of ring) {\n const x = point.x;\n const y = point.y;\n\n // Do not include points that are outside the tile boundaries.\n if (x < 0 || x >= EXTENT || y < 0 || y >= EXTENT) continue;\n\n // this geometry will be of the Point type, and we'll derive\n // two triangles from it.\n //\n // ┌─────────┐\n // │ 3 2 │\n // │ │\n // │ 0 1 │\n // └─────────┘\n\n const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey);\n const index = segment.vertexLength;\n\n addCircleVertex(this.layoutVertexArray, x, y, -1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, 1);\n addCircleVertex(this.layoutVertexArray, x, y, -1, 1);\n\n this.indexArray.emplaceBack(index, index + 1, index + 2);\n this.indexArray.emplaceBack(index, index + 3, index + 2);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical);\n }\n}\n\nregister('CircleBucket', CircleBucket, {omit: ['layers']});\n","import {isCounterClockwise} from './util';\n\nimport Point from '@mapbox/point-geometry';\n\nexport {polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox};\n\ntype Line = Array;\ntype MultiLine = Array;\ntype Ring = Array;\ntype Polygon = Array;\ntype MultiPolygon = Array;\n\nfunction polygonIntersectsPolygon(polygonA: Polygon, polygonB: Polygon) {\n for (let i = 0; i < polygonA.length; i++) {\n if (polygonContainsPoint(polygonB, polygonA[i])) return true;\n }\n\n for (let i = 0; i < polygonB.length; i++) {\n if (polygonContainsPoint(polygonA, polygonB[i])) return true;\n }\n\n if (lineIntersectsLine(polygonA, polygonB)) return true;\n\n return false;\n}\n\nfunction polygonIntersectsBufferedPoint(polygon: Polygon, point: Point, radius: number) {\n if (polygonContainsPoint(polygon, point)) return true;\n if (pointIntersectsBufferedLine(point, polygon, radius)) return true;\n return false;\n}\n\nfunction polygonIntersectsMultiPolygon(polygon: Polygon, multiPolygon: MultiPolygon) {\n\n if (polygon.length === 1) {\n return multiPolygonContainsPoint(multiPolygon, polygon[0]);\n }\n\n for (let m = 0; m < multiPolygon.length; m++) {\n const ring = multiPolygon[m];\n for (let n = 0; n < ring.length; n++) {\n if (polygonContainsPoint(polygon, ring[n])) return true;\n }\n }\n\n for (let i = 0; i < polygon.length; i++) {\n if (multiPolygonContainsPoint(multiPolygon, polygon[i])) return true;\n }\n\n for (let k = 0; k < multiPolygon.length; k++) {\n if (lineIntersectsLine(polygon, multiPolygon[k])) return true;\n }\n\n return false;\n}\n\nfunction polygonIntersectsBufferedMultiLine(polygon: Polygon, multiLine: MultiLine, radius: number) {\n for (let i = 0; i < multiLine.length; i++) {\n const line = multiLine[i];\n\n if (polygon.length >= 3) {\n for (let k = 0; k < line.length; k++) {\n if (polygonContainsPoint(polygon, line[k])) return true;\n }\n }\n\n if (lineIntersectsBufferedLine(polygon, line, radius)) return true;\n }\n return false;\n}\n\nfunction lineIntersectsBufferedLine(lineA: Line, lineB: Line, radius: number) {\n\n if (lineA.length > 1) {\n if (lineIntersectsLine(lineA, lineB)) return true;\n\n // Check whether any point in either line is within radius of the other line\n for (let j = 0; j < lineB.length; j++) {\n if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) return true;\n }\n }\n\n for (let k = 0; k < lineA.length; k++) {\n if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) return true;\n }\n\n return false;\n}\n\nfunction lineIntersectsLine(lineA: Line, lineB: Line) {\n if (lineA.length === 0 || lineB.length === 0) return false;\n for (let i = 0; i < lineA.length - 1; i++) {\n const a0 = lineA[i];\n const a1 = lineA[i + 1];\n for (let j = 0; j < lineB.length - 1; j++) {\n const b0 = lineB[j];\n const b1 = lineB[j + 1];\n if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) return true;\n }\n }\n return false;\n}\n\nfunction lineSegmentIntersectsLineSegment(a0: Point, a1: Point, b0: Point, b1: Point) {\n return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) &&\n isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1);\n}\n\nfunction pointIntersectsBufferedLine(p: Point, line: Line, radius: number) {\n const radiusSquared = radius * radius;\n\n if (line.length === 1) return p.distSqr(line[0]) < radiusSquared;\n\n for (let i = 1; i < line.length; i++) {\n // Find line segments that have a distance <= radius^2 to p\n // In that case, we treat the line as \"containing point p\".\n const v = line[i - 1], w = line[i];\n if (distToSegmentSquared(p, v, w) < radiusSquared) return true;\n }\n return false;\n}\n\n// Code from http://stackoverflow.com/a/1501725/331379.\nfunction distToSegmentSquared(p: Point, v: Point, w: Point) {\n const l2 = v.distSqr(w);\n if (l2 === 0) return p.distSqr(v);\n const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;\n if (t < 0) return p.distSqr(v);\n if (t > 1) return p.distSqr(w);\n return p.distSqr(w.sub(v)._mult(t)._add(v));\n}\n\n// point in polygon ray casting algorithm\nfunction multiPolygonContainsPoint(rings: Array, p: Point) {\n let c = false,\n ring, p1, p2;\n\n for (let k = 0; k < rings.length; k++) {\n ring = rings[k];\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n }\n return c;\n}\n\nfunction polygonContainsPoint(ring: Ring, p: Point) {\n let c = false;\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const p1 = ring[i];\n const p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n return c;\n}\n\nfunction polygonIntersectsBox(ring: Ring, boxX1: number, boxY1: number, boxX2: number, boxY2: number) {\n for (const p of ring) {\n if (boxX1 <= p.x &&\n boxY1 <= p.y &&\n boxX2 >= p.x &&\n boxY2 >= p.y) return true;\n }\n\n const corners = [\n new Point(boxX1, boxY1),\n new Point(boxX1, boxY2),\n new Point(boxX2, boxY2),\n new Point(boxX2, boxY1)];\n\n if (ring.length > 2) {\n for (const corner of corners) {\n if (polygonContainsPoint(ring, corner)) return true;\n }\n }\n\n for (let i = 0; i < ring.length - 1; i++) {\n const p1 = ring[i];\n const p2 = ring[i + 1];\n if (edgeIntersectsBox(p1, p2, corners)) return true;\n }\n\n return false;\n}\n\nfunction edgeIntersectsBox(e1: Point, e2: Point, corners: Array) {\n const tl = corners[0];\n const br = corners[2];\n // the edge and box do not intersect in either the x or y dimensions\n if (((e1.x < tl.x) && (e2.x < tl.x)) ||\n ((e1.x > br.x) && (e2.x > br.x)) ||\n ((e1.y < tl.y) && (e2.y < tl.y)) ||\n ((e1.y > br.y) && (e2.y > br.y))) return false;\n\n // check if all corners of the box are on the same side of the edge\n const dir = isCounterClockwise(e1, e2, corners[0]);\n return dir !== isCounterClockwise(e1, e2, corners[1]) ||\n dir !== isCounterClockwise(e1, e2, corners[2]) ||\n dir !== isCounterClockwise(e1, e2, corners[3]);\n}\n","import Point from '@mapbox/point-geometry';\n\nimport type {PossiblyEvaluatedPropertyValue} from './properties';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {LineBucket} from '../data/bucket/line_bucket';\n\nexport function getMaximumPaintValue(\n property: string,\n layer: StyleLayer,\n bucket: CircleBucket | LineBucket\n): number {\n const value = ((layer.paint as any).get(property) as PossiblyEvaluatedPropertyValue).value;\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return bucket.programConfigurations.get(layer.id).getMaxValue(property);\n }\n}\n\nexport function translateDistance(translate: [number, number]) {\n return Math.sqrt(translate[0] * translate[0] + translate[1] * translate[1]);\n}\n\nexport function translate(queryGeometry: Array,\n translate: [number, number],\n translateAnchor: 'viewport' | 'map',\n bearing: number,\n pixelsToTileUnits: number) {\n if (!translate[0] && !translate[1]) {\n return queryGeometry;\n }\n const pt = Point.convert(translate)._mult(pixelsToTileUnits);\n\n if (translateAnchor === 'viewport') {\n pt._rotate(-bearing);\n }\n\n const translated = [];\n for (let i = 0; i < queryGeometry.length; i++) {\n const point = queryGeometry[i];\n translated.push(point.sub(pt));\n }\n return translated;\n}\n\nexport function offsetLine(rings: Array>, offset: number) {\n const newRings: Array> = [];\n for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {\n const ring = rings[ringIndex];\n const newRing: Array = [];\n for (let index = 0; index < ring.length; index++) {\n const a = ring[index - 1];\n const b = ring[index];\n const c = ring[index + 1];\n const aToB = index === 0 ? new Point(0, 0) : b.sub(a)._unit()._perp();\n const bToC = index === ring.length - 1 ? new Point(0, 0) : c.sub(b)._unit()._perp();\n const extrude = aToB._add(bToC)._unit();\n\n const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;\n if (cosHalfAngle !== 0) {\n extrude._mult(1 / cosHalfAngle);\n }\n\n newRing.push(extrude._mult(offset)._add(b));\n }\n newRings.push(newRing);\n }\n return newRings;\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CircleLayoutProps = {\n \"circle-sort-key\": DataDrivenProperty,\n};\n\nexport type CircleLayoutPropsPossiblyEvaluated = {\n \"circle-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"circle-sort-key\": new DataDrivenProperty(styleSpec[\"layout_circle\"][\"circle-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type CirclePaintProps = {\n \"circle-radius\": DataDrivenProperty,\n \"circle-color\": DataDrivenProperty,\n \"circle-blur\": DataDrivenProperty,\n \"circle-opacity\": DataDrivenProperty,\n \"circle-translate\": DataConstantProperty<[number, number]>,\n \"circle-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-scale\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-stroke-width\": DataDrivenProperty,\n \"circle-stroke-color\": DataDrivenProperty,\n \"circle-stroke-opacity\": DataDrivenProperty,\n};\n\nexport type CirclePaintPropsPossiblyEvaluated = {\n \"circle-radius\": PossiblyEvaluatedPropertyValue,\n \"circle-color\": PossiblyEvaluatedPropertyValue,\n \"circle-blur\": PossiblyEvaluatedPropertyValue,\n \"circle-opacity\": PossiblyEvaluatedPropertyValue,\n \"circle-translate\": [number, number],\n \"circle-translate-anchor\": \"map\" | \"viewport\",\n \"circle-pitch-scale\": \"map\" | \"viewport\",\n \"circle-pitch-alignment\": \"map\" | \"viewport\",\n \"circle-stroke-width\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-color\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-opacity\": PossiblyEvaluatedPropertyValue,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"circle-radius\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-radius\"] as any as StylePropertySpecification),\n \"circle-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-color\"] as any as StylePropertySpecification),\n \"circle-blur\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-blur\"] as any as StylePropertySpecification),\n \"circle-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-opacity\"] as any as StylePropertySpecification),\n \"circle-translate\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate\"] as any as StylePropertySpecification),\n \"circle-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate-anchor\"] as any as StylePropertySpecification),\n \"circle-pitch-scale\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-scale\"] as any as StylePropertySpecification),\n \"circle-pitch-alignment\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-alignment\"] as any as StylePropertySpecification),\n \"circle-stroke-width\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-width\"] as any as StylePropertySpecification),\n \"circle-stroke-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-color\"] as any as StylePropertySpecification),\n \"circle-stroke-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","/**\n * Common utilities\n * @module glMatrix\n */\n// Configuration Constants\nexport var EPSILON = 0.000001;\nexport var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;\nexport var RANDOM = Math.random;\n/**\n * Sets the type of array used when creating new vectors and matrices\n *\n * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array\n */\n\nexport function setMatrixArrayType(type) {\n ARRAY_TYPE = type;\n}\nvar degree = Math.PI / 180;\n/**\n * Convert Degree To Radian\n *\n * @param {Number} a Angle in Degrees\n */\n\nexport function toRadian(a) {\n return a * degree;\n}\n/**\n * Tests whether or not the arguments have approximately the same value, within an absolute\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\n * than or equal to 1.0, and a relative tolerance is used for larger values)\n *\n * @param {Number} a The first number to test.\n * @param {Number} b The second number to test.\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\n */\n\nexport function equals(a, b) {\n return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));\n}\nif (!Math.hypot) Math.hypot = function () {\n var y = 0,\n i = arguments.length;\n\n while (i--) {\n y += arguments[i] * arguments[i];\n }\n\n return Math.sqrt(y);\n};","import * as glMatrix from \"./common.js\";\n/**\n * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.\n * @module mat4\n */\n\n/**\n * Creates a new identity mat4\n *\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(16);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n }\n\n out[0] = 1;\n out[5] = 1;\n out[10] = 1;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat4} a matrix to clone\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Copy the values from one mat4 to another\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Create a new mat4 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} A new mat4\n */\n\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set the components of a mat4 to the given values\n *\n * @param {mat4} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} out\n */\n\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set a mat4 to the identity matrix\n *\n * @param {mat4} out the receiving matrix\n * @returns {mat4} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a12 = a[6],\n a13 = a[7];\n var a23 = a[11];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a01;\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a02;\n out[9] = a12;\n out[11] = a[14];\n out[12] = a03;\n out[13] = a13;\n out[14] = a23;\n } else {\n out[0] = a[0];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a[1];\n out[5] = a[5];\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a[2];\n out[9] = a[6];\n out[10] = a[10];\n out[11] = a[14];\n out[12] = a[3];\n out[13] = a[7];\n out[14] = a[11];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Inverts a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22);\n out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\n out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12);\n out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\n out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\n out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22);\n out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\n out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12);\n out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21);\n out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\n out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11);\n out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\n out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\n out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21);\n out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\n out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11);\n return out;\n}\n/**\n * Calculates the determinant of a mat4\n *\n * @param {ReadonlyMat4} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n}\n/**\n * Multiplies two mat4s\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15]; // Cache only the current line of the second matrix\n\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[4];\n b1 = b[5];\n b2 = b[6];\n b3 = b[7];\n out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[8];\n b1 = b[9];\n b2 = b[10];\n b3 = b[11];\n out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[12];\n b1 = b[13];\n b2 = b[14];\n b3 = b[15];\n out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n return out;\n}\n/**\n * Translate a mat4 by the given vector\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to translate\n * @param {ReadonlyVec3} v vector to translate by\n * @returns {mat4} out\n */\n\nexport function translate(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n\n if (a === out) {\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n } else {\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a03;\n out[4] = a10;\n out[5] = a11;\n out[6] = a12;\n out[7] = a13;\n out[8] = a20;\n out[9] = a21;\n out[10] = a22;\n out[11] = a23;\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\n }\n\n return out;\n}\n/**\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {ReadonlyVec3} v the vec3 to scale the matrix by\n * @returns {mat4} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n out[0] = a[0] * x;\n out[1] = a[1] * x;\n out[2] = a[2] * x;\n out[3] = a[3] * x;\n out[4] = a[4] * y;\n out[5] = a[5] * y;\n out[6] = a[6] * y;\n out[7] = a[7] * y;\n out[8] = a[8] * z;\n out[9] = a[9] * z;\n out[10] = a[10] * z;\n out[11] = a[11] * z;\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Rotates a mat4 by the given angle around the given axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function rotate(out, a, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n var b00, b01, b02;\n var b10, b11, b12;\n var b20, b21, b22;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c;\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11]; // Construct the elements of the rotation matrix\n\n b00 = x * x * t + c;\n b01 = y * x * t + z * s;\n b02 = z * x * t - y * s;\n b10 = x * y * t - z * s;\n b11 = y * y * t + c;\n b12 = z * y * t + x * s;\n b20 = x * z * t + y * s;\n b21 = y * z * t - x * s;\n b22 = z * z * t + c; // Perform rotation-specific matrix multiplication\n\n out[0] = a00 * b00 + a10 * b01 + a20 * b02;\n out[1] = a01 * b00 + a11 * b01 + a21 * b02;\n out[2] = a02 * b00 + a12 * b01 + a22 * b02;\n out[3] = a03 * b00 + a13 * b01 + a23 * b02;\n out[4] = a00 * b10 + a10 * b11 + a20 * b12;\n out[5] = a01 * b10 + a11 * b11 + a21 * b12;\n out[6] = a02 * b10 + a12 * b11 + a22 * b12;\n out[7] = a03 * b10 + a13 * b11 + a23 * b12;\n out[8] = a00 * b20 + a10 * b21 + a20 * b22;\n out[9] = a01 * b20 + a11 * b21 + a21 * b22;\n out[10] = a02 * b20 + a12 * b21 + a22 * b22;\n out[11] = a03 * b20 + a13 * b21 + a23 * b22;\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the X axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateX(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[4] = a10 * c + a20 * s;\n out[5] = a11 * c + a21 * s;\n out[6] = a12 * c + a22 * s;\n out[7] = a13 * c + a23 * s;\n out[8] = a20 * c - a10 * s;\n out[9] = a21 * c - a11 * s;\n out[10] = a22 * c - a12 * s;\n out[11] = a23 * c - a13 * s;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Y axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateY(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c - a20 * s;\n out[1] = a01 * c - a21 * s;\n out[2] = a02 * c - a22 * s;\n out[3] = a03 * c - a23 * s;\n out[8] = a00 * s + a20 * c;\n out[9] = a01 * s + a21 * c;\n out[10] = a02 * s + a22 * c;\n out[11] = a03 * s + a23 * c;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Z axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateZ(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c + a10 * s;\n out[1] = a01 * c + a11 * s;\n out[2] = a02 * c + a12 * s;\n out[3] = a03 * c + a13 * s;\n out[4] = a10 * c - a00 * s;\n out[5] = a11 * c - a01 * s;\n out[6] = a12 * c - a02 * s;\n out[7] = a13 * c - a03 * s;\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.scale(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = v[1];\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = v[2];\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle around a given axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotate(dest, dest, rad, axis);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function fromRotation(out, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c; // Perform rotation-specific matrix multiplication\n\n out[0] = x * x * t + c;\n out[1] = y * x * t + z * s;\n out[2] = z * x * t - y * s;\n out[3] = 0;\n out[4] = x * y * t - z * s;\n out[5] = y * y * t + c;\n out[6] = z * y * t + x * s;\n out[7] = 0;\n out[8] = x * z * t + y * s;\n out[9] = y * z * t - x * s;\n out[10] = z * z * t + c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the X axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateX(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromXRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = c;\n out[6] = s;\n out[7] = 0;\n out[8] = 0;\n out[9] = -s;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Y axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateY(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromYRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = 0;\n out[2] = -s;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = s;\n out[9] = 0;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Z axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateZ(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromZRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = 0;\n out[4] = -s;\n out[5] = c;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation and vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslation(out, q, v) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 from a dual quat.\n *\n * @param {mat4} out Matrix\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @returns {mat4} mat4 receiving operation result\n */\n\nexport function fromQuat2(out, a) {\n var translation = new glMatrix.ARRAY_TYPE(3);\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7];\n var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense\n\n if (magnitude > 0) {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\n } else {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n }\n\n fromRotationTranslation(out, a, translation);\n return out;\n}\n/**\n * Returns the translation vector component of a transformation\n * matrix. If a matrix is built with fromRotationTranslation,\n * the returned vector will be the same as the translation vector\n * originally supplied.\n * @param {vec3} out Vector to receive translation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getTranslation(out, mat) {\n out[0] = mat[12];\n out[1] = mat[13];\n out[2] = mat[14];\n return out;\n}\n/**\n * Returns the scaling factor component of a transformation\n * matrix. If a matrix is built with fromRotationTranslationScale\n * with a normalized Quaternion paramter, the returned vector will be\n * the same as the scaling vector\n * originally supplied.\n * @param {vec3} out Vector to receive scaling factor component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getScaling(out, mat) {\n var m11 = mat[0];\n var m12 = mat[1];\n var m13 = mat[2];\n var m21 = mat[4];\n var m22 = mat[5];\n var m23 = mat[6];\n var m31 = mat[8];\n var m32 = mat[9];\n var m33 = mat[10];\n out[0] = Math.hypot(m11, m12, m13);\n out[1] = Math.hypot(m21, m22, m23);\n out[2] = Math.hypot(m31, m32, m33);\n return out;\n}\n/**\n * Returns a quaternion representing the rotational component\n * of a transformation matrix. If a matrix is built with\n * fromRotationTranslation, the returned quaternion will be the\n * same as the quaternion originally supplied.\n * @param {quat} out Quaternion to receive the rotation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {quat} out\n */\n\nexport function getRotation(out, mat) {\n var scaling = new glMatrix.ARRAY_TYPE(3);\n getScaling(scaling, mat);\n var is1 = 1 / scaling[0];\n var is2 = 1 / scaling[1];\n var is3 = 1 / scaling[2];\n var sm11 = mat[0] * is1;\n var sm12 = mat[1] * is2;\n var sm13 = mat[2] * is3;\n var sm21 = mat[4] * is1;\n var sm22 = mat[5] * is2;\n var sm23 = mat[6] * is3;\n var sm31 = mat[8] * is1;\n var sm32 = mat[9] * is2;\n var sm33 = mat[10] * is3;\n var trace = sm11 + sm22 + sm33;\n var S = 0;\n\n if (trace > 0) {\n S = Math.sqrt(trace + 1.0) * 2;\n out[3] = 0.25 * S;\n out[0] = (sm23 - sm32) / S;\n out[1] = (sm31 - sm13) / S;\n out[2] = (sm12 - sm21) / S;\n } else if (sm11 > sm22 && sm11 > sm33) {\n S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n out[3] = (sm23 - sm32) / S;\n out[0] = 0.25 * S;\n out[1] = (sm12 + sm21) / S;\n out[2] = (sm31 + sm13) / S;\n } else if (sm22 > sm33) {\n S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n out[3] = (sm31 - sm13) / S;\n out[0] = (sm12 + sm21) / S;\n out[1] = 0.25 * S;\n out[2] = (sm23 + sm32) / S;\n } else {\n S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n out[3] = (sm12 - sm21) / S;\n out[0] = (sm31 + sm13) / S;\n out[1] = (sm23 + sm32) / S;\n out[2] = 0.25 * S;\n }\n\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScale(out, q, v, s) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n out[0] = (1 - (yy + zz)) * sx;\n out[1] = (xy + wz) * sx;\n out[2] = (xz - wy) * sx;\n out[3] = 0;\n out[4] = (xy - wz) * sy;\n out[5] = (1 - (xx + zz)) * sy;\n out[6] = (yz + wx) * sy;\n out[7] = 0;\n out[8] = (xz + wy) * sz;\n out[9] = (yz - wx) * sz;\n out[10] = (1 - (xx + yy)) * sz;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * mat4.translate(dest, origin);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n * mat4.translate(dest, negativeOrigin);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @param {ReadonlyVec3} o The origin vector around which to scale and rotate\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n var ox = o[0];\n var oy = o[1];\n var oz = o[2];\n var out0 = (1 - (yy + zz)) * sx;\n var out1 = (xy + wz) * sx;\n var out2 = (xz - wy) * sx;\n var out4 = (xy - wz) * sy;\n var out5 = (1 - (xx + zz)) * sy;\n var out6 = (yz + wx) * sy;\n var out8 = (xz + wy) * sz;\n var out9 = (yz - wx) * sz;\n var out10 = (1 - (xx + yy)) * sz;\n out[0] = out0;\n out[1] = out1;\n out[2] = out2;\n out[3] = 0;\n out[4] = out4;\n out[5] = out5;\n out[6] = out6;\n out[7] = 0;\n out[8] = out8;\n out[9] = out9;\n out[10] = out10;\n out[11] = 0;\n out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\n out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\n out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\n out[15] = 1;\n return out;\n}\n/**\n * Calculates a 4x4 matrix from the given quaternion\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat4} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[1] = yx + wz;\n out[2] = zx - wy;\n out[3] = 0;\n out[4] = yx - wz;\n out[5] = 1 - xx - zz;\n out[6] = zy + wx;\n out[7] = 0;\n out[8] = zx + wy;\n out[9] = zy - wx;\n out[10] = 1 - xx - yy;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a frustum matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Number} left Left bound of the frustum\n * @param {Number} right Right bound of the frustum\n * @param {Number} bottom Bottom bound of the frustum\n * @param {Number} top Top bound of the frustum\n * @param {Number} near Near bound of the frustum\n * @param {Number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function frustum(out, left, right, bottom, top, near, far) {\n var rl = 1 / (right - left);\n var tb = 1 / (top - bottom);\n var nf = 1 / (near - far);\n out[0] = near * 2 * rl;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = near * 2 * tb;\n out[6] = 0;\n out[7] = 0;\n out[8] = (right + left) * rl;\n out[9] = (top + bottom) * tb;\n out[10] = (far + near) * nf;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[14] = far * near * 2 * nf;\n out[15] = 0;\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveNO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = (far + near) * nf;\n out[14] = 2 * far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -2 * near;\n }\n\n return out;\n}\n/**\n * Alias for {@link mat4.perspectiveNO}\n * @function\n */\n\nexport var perspective = perspectiveNO;\n/**\n * Generates a perspective projection matrix suitable for WebGPU with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveZO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = far * nf;\n out[14] = far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -near;\n }\n\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given field of view.\n * This is primarily useful for generating projection matrices to be used\n * with the still experiemental WebVR API.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\n var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);\n var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);\n var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);\n var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);\n var xScale = 2.0 / (leftTan + rightTan);\n var yScale = 2.0 / (upTan + downTan);\n out[0] = xScale;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n out[4] = 0.0;\n out[5] = yScale;\n out[6] = 0.0;\n out[7] = 0.0;\n out[8] = -((leftTan - rightTan) * xScale * 0.5);\n out[9] = (upTan - downTan) * yScale * 0.5;\n out[10] = far / (near - far);\n out[11] = -1.0;\n out[12] = 0.0;\n out[13] = 0.0;\n out[14] = far * near / (near - far);\n out[15] = 0.0;\n return out;\n}\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoNO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 2 * nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = (far + near) * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Alias for {@link mat4.orthoNO}\n * @function\n */\n\nexport var ortho = orthoNO;\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoZO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = near * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a look-at matrix with the given eye position, focal point, and up axis.\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function lookAt(out, eye, center, up) {\n var x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\n var eyex = eye[0];\n var eyey = eye[1];\n var eyez = eye[2];\n var upx = up[0];\n var upy = up[1];\n var upz = up[2];\n var centerx = center[0];\n var centery = center[1];\n var centerz = center[2];\n\n if (Math.abs(eyex - centerx) < glMatrix.EPSILON && Math.abs(eyey - centery) < glMatrix.EPSILON && Math.abs(eyez - centerz) < glMatrix.EPSILON) {\n return identity(out);\n }\n\n z0 = eyex - centerx;\n z1 = eyey - centery;\n z2 = eyez - centerz;\n len = 1 / Math.hypot(z0, z1, z2);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n x0 = upy * z2 - upz * z1;\n x1 = upz * z0 - upx * z2;\n x2 = upx * z1 - upy * z0;\n len = Math.hypot(x0, x1, x2);\n\n if (!len) {\n x0 = 0;\n x1 = 0;\n x2 = 0;\n } else {\n len = 1 / len;\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n y0 = z1 * x2 - z2 * x1;\n y1 = z2 * x0 - z0 * x2;\n y2 = z0 * x1 - z1 * x0;\n len = Math.hypot(y0, y1, y2);\n\n if (!len) {\n y0 = 0;\n y1 = 0;\n y2 = 0;\n } else {\n len = 1 / len;\n y0 *= len;\n y1 *= len;\n y2 *= len;\n }\n\n out[0] = x0;\n out[1] = y0;\n out[2] = z0;\n out[3] = 0;\n out[4] = x1;\n out[5] = y1;\n out[6] = z1;\n out[7] = 0;\n out[8] = x2;\n out[9] = y2;\n out[10] = z2;\n out[11] = 0;\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n out[15] = 1;\n return out;\n}\n/**\n * Generates a matrix that makes something look at something else.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function targetTo(out, eye, target, up) {\n var eyex = eye[0],\n eyey = eye[1],\n eyez = eye[2],\n upx = up[0],\n upy = up[1],\n upz = up[2];\n var z0 = eyex - target[0],\n z1 = eyey - target[1],\n z2 = eyez - target[2];\n var len = z0 * z0 + z1 * z1 + z2 * z2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n }\n\n var x0 = upy * z2 - upz * z1,\n x1 = upz * z0 - upx * z2,\n x2 = upx * z1 - upy * z0;\n len = x0 * x0 + x1 * x1 + x2 * x2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n out[0] = x0;\n out[1] = x1;\n out[2] = x2;\n out[3] = 0;\n out[4] = z1 * x2 - z2 * x1;\n out[5] = z2 * x0 - z0 * x2;\n out[6] = z0 * x1 - z1 * x0;\n out[7] = 0;\n out[8] = z0;\n out[9] = z1;\n out[10] = z2;\n out[11] = 0;\n out[12] = eyex;\n out[13] = eyey;\n out[14] = eyez;\n out[15] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat4\n *\n * @param {ReadonlyMat4} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \", \" + a[9] + \", \" + a[10] + \", \" + a[11] + \", \" + a[12] + \", \" + a[13] + \", \" + a[14] + \", \" + a[15] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat4\n *\n * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);\n}\n/**\n * Adds two mat4's\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n out[9] = a[9] + b[9];\n out[10] = a[10] + b[10];\n out[11] = a[11] + b[11];\n out[12] = a[12] + b[12];\n out[13] = a[13] + b[13];\n out[14] = a[14] + b[14];\n out[15] = a[15] + b[15];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n out[9] = a[9] - b[9];\n out[10] = a[10] - b[10];\n out[11] = a[11] - b[11];\n out[12] = a[12] - b[12];\n out[13] = a[13] - b[13];\n out[14] = a[14] - b[14];\n out[15] = a[15] - b[15];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat4} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n out[9] = a[9] * b;\n out[10] = a[10] * b;\n out[11] = a[11] * b;\n out[12] = a[12] * b;\n out[13] = a[13] * b;\n out[14] = a[14] * b;\n out[15] = a[15] * b;\n return out;\n}\n/**\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat4} out the receiving vector\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat4} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n out[9] = a[9] + b[9] * scale;\n out[10] = a[10] + b[10] * scale;\n out[11] = a[11] + b[11] * scale;\n out[12] = a[12] + b[12] * scale;\n out[13] = a[13] + b[13] * scale;\n out[14] = a[14] + b[14] * scale;\n out[15] = a[15] + b[15] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7];\n var a8 = a[8],\n a9 = a[9],\n a10 = a[10],\n a11 = a[11];\n var a12 = a[12],\n a13 = a[13],\n a14 = a[14],\n a15 = a[15];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n var b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7];\n var b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11];\n var b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15));\n}\n/**\n * Alias for {@link mat4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat4.subtract}\n * @function\n */\n\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n/**\n * 3 Dimensional Vector\n * @module vec3\n */\n\n/**\n * Creates a new, empty vec3\n *\n * @returns {vec3} a new 3D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(3);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec3 initialized with values from an existing vector\n *\n * @param {ReadonlyVec3} a vector to clone\n * @returns {vec3} a new 3D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Calculates the length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Creates a new vec3 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} a new 3D vector\n */\n\nexport function fromValues(x, y, z) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Copy the values from one vec3 to another\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the source vector\n * @returns {vec3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Set the components of a vec3 to the given values\n *\n * @param {vec3} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} out\n */\n\nexport function set(out, x, y, z) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Adds two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n return out;\n}\n/**\n * Multiplies two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n return out;\n}\n/**\n * Divides two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n return out;\n}\n/**\n * Math.ceil the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to ceil\n * @returns {vec3} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n return out;\n}\n/**\n * Math.floor the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to floor\n * @returns {vec3} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n return out;\n}\n/**\n * Returns the minimum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n return out;\n}\n/**\n * Returns the maximum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n return out;\n}\n/**\n * Math.round the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to round\n * @returns {vec3} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n return out;\n}\n/**\n * Scales a vec3 by a scalar number\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec3} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n return out;\n}\n/**\n * Adds two vec3's after scaling the second operand by a scalar value\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec3} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Calculates the squared euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Calculates the squared length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Negates the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to negate\n * @returns {vec3} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to invert\n * @returns {vec3} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n return out;\n}\n/**\n * Normalize a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to normalize\n * @returns {vec3} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var len = x * x + y * y + z * z;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n out[2] = a[2] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n/**\n * Computes the cross product of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2];\n var bx = b[0],\n by = b[1],\n bz = b[2];\n out[0] = ay * bz - az * by;\n out[1] = az * bx - ax * bz;\n out[2] = ax * by - ay * bx;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n return out;\n}\n/**\n * Performs a hermite interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function hermite(out, a, b, c, d, t) {\n var factorTimes2 = t * t;\n var factor1 = factorTimes2 * (2 * t - 3) + 1;\n var factor2 = factorTimes2 * (t - 2) + t;\n var factor3 = factorTimes2 * (t - 1);\n var factor4 = factorTimes2 * (3 - 2 * t);\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Performs a bezier interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function bezier(out, a, b, c, d, t) {\n var inverseFactor = 1 - t;\n var inverseFactorTimesTwo = inverseFactor * inverseFactor;\n var factorTimes2 = t * t;\n var factor1 = inverseFactorTimesTwo * inverseFactor;\n var factor2 = 3 * t * inverseFactorTimesTwo;\n var factor3 = 3 * factorTimes2 * inverseFactor;\n var factor4 = factorTimes2 * t;\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec3} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec3} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n var z = glMatrix.RANDOM() * 2.0 - 1.0;\n var zScale = Math.sqrt(1.0 - z * z) * scale;\n out[0] = Math.cos(r) * zScale;\n out[1] = Math.sin(r) * zScale;\n out[2] = z * scale;\n return out;\n}\n/**\n * Transforms the vec3 with a mat4.\n * 4th vector component is implicitly '1'\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var w = m[3] * x + m[7] * y + m[11] * z + m[15];\n w = w || 1.0;\n out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n return out;\n}\n/**\n * Transforms the vec3 with a mat3.\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat3} m the 3x3 matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n out[0] = x * m[0] + y * m[3] + z * m[6];\n out[1] = x * m[1] + y * m[4] + z * m[7];\n out[2] = x * m[2] + y * m[5] + z * m[8];\n return out;\n}\n/**\n * Transforms the vec3 with a quat\n * Can also be used for dual quaternions. (Multiply it with the real part)\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec3} out\n */\n\nexport function transformQuat(out, a, q) {\n // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3];\n var x = a[0],\n y = a[1],\n z = a[2]; // var qvec = [qx, qy, qz];\n // var uv = vec3.cross([], qvec, a);\n\n var uvx = qy * z - qz * y,\n uvy = qz * x - qx * z,\n uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv);\n\n var uuvx = qy * uvz - qz * uvy,\n uuvy = qz * uvx - qx * uvz,\n uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w);\n\n var w2 = qw * 2;\n uvx *= w2;\n uvy *= w2;\n uvz *= w2; // vec3.scale(uuv, uuv, 2);\n\n uuvx *= 2;\n uuvy *= 2;\n uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv));\n\n out[0] = x + uvx + uuvx;\n out[1] = y + uvy + uuvy;\n out[2] = z + uvz + uuvz;\n return out;\n}\n/**\n * Rotate a 3D vector around the x-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateX(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the y-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateY(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the z-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateZ(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2]; //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Get the angle between two 3D vectors\n * @param {ReadonlyVec3} a The first operand\n * @param {ReadonlyVec3} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2],\n bx = b[0],\n by = b[1],\n bz = b[2],\n mag1 = Math.sqrt(ax * ax + ay * ay + az * az),\n mag2 = Math.sqrt(bx * bx + by * by + bz * bz),\n mag = mag1 * mag2,\n cosine = mag && dot(a, b) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec3 to zero\n *\n * @param {vec3} out the receiving vector\n * @returns {vec3} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec3} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));\n}\n/**\n * Alias for {@link vec3.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec3.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec3.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec3.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec3.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec3.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec3s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 3;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n }\n\n return a;\n };\n}();","import * as glMatrix from \"./common.js\";\n/**\n * 4 Dimensional Vector\n * @module vec4\n */\n\n/**\n * Creates a new, empty vec4\n *\n * @returns {vec4} a new 4D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec4 initialized with values from an existing vector\n *\n * @param {ReadonlyVec4} a vector to clone\n * @returns {vec4} a new 4D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Creates a new vec4 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} a new 4D vector\n */\n\nexport function fromValues(x, y, z, w) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Copy the values from one vec4 to another\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the source vector\n * @returns {vec4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to the given values\n *\n * @param {vec4} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} out\n */\n\nexport function set(out, x, y, z, w) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Adds two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Multiplies two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n out[3] = a[3] * b[3];\n return out;\n}\n/**\n * Divides two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n out[3] = a[3] / b[3];\n return out;\n}\n/**\n * Math.ceil the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to ceil\n * @returns {vec4} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n out[3] = Math.ceil(a[3]);\n return out;\n}\n/**\n * Math.floor the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to floor\n * @returns {vec4} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n out[3] = Math.floor(a[3]);\n return out;\n}\n/**\n * Returns the minimum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n out[3] = Math.min(a[3], b[3]);\n return out;\n}\n/**\n * Returns the maximum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n out[3] = Math.max(a[3], b[3]);\n return out;\n}\n/**\n * Math.round the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to round\n * @returns {vec4} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n out[3] = Math.round(a[3]);\n return out;\n}\n/**\n * Scales a vec4 by a scalar number\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec4} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two vec4's after scaling the second operand by a scalar value\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec4} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Calculates the length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Negates the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to negate\n * @returns {vec4} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = -a[3];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to invert\n * @returns {vec4} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n out[3] = 1.0 / a[3];\n return out;\n}\n/**\n * Normalize a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to normalize\n * @returns {vec4} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n var len = x * x + y * y + z * z + w * w;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = x * len;\n out[1] = y * len;\n out[2] = z * len;\n out[3] = w * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n/**\n * Returns the cross-product of three vectors in a 4-dimensional space\n *\n * @param {ReadonlyVec4} result the receiving vector\n * @param {ReadonlyVec4} U the first vector\n * @param {ReadonlyVec4} V the second vector\n * @param {ReadonlyVec4} W the third vector\n * @returns {vec4} result\n */\n\nexport function cross(out, u, v, w) {\n var A = v[0] * w[1] - v[1] * w[0],\n B = v[0] * w[2] - v[2] * w[0],\n C = v[0] * w[3] - v[3] * w[0],\n D = v[1] * w[2] - v[2] * w[1],\n E = v[1] * w[3] - v[3] * w[1],\n F = v[2] * w[3] - v[3] * w[2];\n var G = u[0];\n var H = u[1];\n var I = u[2];\n var J = u[3];\n out[0] = H * F - I * E + J * D;\n out[1] = -(G * F) + I * C - J * B;\n out[2] = G * E - H * C + J * A;\n out[3] = -(G * D) + H * B - I * A;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec4} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n var aw = a[3];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n out[3] = aw + t * (b[3] - aw);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec4} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec4} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a\n // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.\n // http://projecteuclid.org/euclid.aoms/1177692644;\n\n var v1, v2, v3, v4;\n var s1, s2;\n\n do {\n v1 = glMatrix.RANDOM() * 2 - 1;\n v2 = glMatrix.RANDOM() * 2 - 1;\n s1 = v1 * v1 + v2 * v2;\n } while (s1 >= 1);\n\n do {\n v3 = glMatrix.RANDOM() * 2 - 1;\n v4 = glMatrix.RANDOM() * 2 - 1;\n s2 = v3 * v3 + v4 * v4;\n } while (s2 >= 1);\n\n var d = Math.sqrt((1 - s1) / s2);\n out[0] = scale * v1;\n out[1] = scale * v2;\n out[2] = scale * v3 * d;\n out[3] = scale * v4 * d;\n return out;\n}\n/**\n * Transforms the vec4 with a mat4.\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec4} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2],\n w = a[3];\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n return out;\n}\n/**\n * Transforms the vec4 with a quat\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec4} out\n */\n\nexport function transformQuat(out, a, q) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3]; // calculate quat * vec\n\n var ix = qw * x + qy * z - qz * y;\n var iy = qw * y + qz * x - qx * z;\n var iz = qw * z + qx * y - qy * x;\n var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat\n\n out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to zero\n *\n * @param {vec4} out the receiving vector\n * @returns {vec4} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec4} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Alias for {@link vec4.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec4.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec4.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec4.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec4.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec4.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec4s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 4;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n vec[3] = a[i + 3];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n a[i + 3] = vec[3];\n }\n\n return a;\n };\n}();","import * as glMatrix from \"./common.js\";\n/**\n * 2 Dimensional Vector\n * @module vec2\n */\n\n/**\n * Creates a new, empty vec2\n *\n * @returns {vec2} a new 2D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(2);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec2 initialized with values from an existing vector\n *\n * @param {ReadonlyVec2} a vector to clone\n * @returns {vec2} a new 2D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(2);\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n/**\n * Creates a new vec2 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} a new 2D vector\n */\n\nexport function fromValues(x, y) {\n var out = new glMatrix.ARRAY_TYPE(2);\n out[0] = x;\n out[1] = y;\n return out;\n}\n/**\n * Copy the values from one vec2 to another\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the source vector\n * @returns {vec2} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n/**\n * Set the components of a vec2 to the given values\n *\n * @param {vec2} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} out\n */\n\nexport function set(out, x, y) {\n out[0] = x;\n out[1] = y;\n return out;\n}\n/**\n * Adds two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n return out;\n}\n/**\n * Multiplies two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n return out;\n}\n/**\n * Divides two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n return out;\n}\n/**\n * Math.ceil the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to ceil\n * @returns {vec2} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n return out;\n}\n/**\n * Math.floor the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to floor\n * @returns {vec2} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n return out;\n}\n/**\n * Returns the minimum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n return out;\n}\n/**\n * Returns the maximum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n return out;\n}\n/**\n * Math.round the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to round\n * @returns {vec2} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n return out;\n}\n/**\n * Scales a vec2 by a scalar number\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec2} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n return out;\n}\n/**\n * Adds two vec2's after scaling the second operand by a scalar value\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec2} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return Math.hypot(x, y);\n}\n/**\n * Calculates the squared euclidian distance between two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return x * x + y * y;\n}\n/**\n * Calculates the length of a vec2\n *\n * @param {ReadonlyVec2} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0],\n y = a[1];\n return Math.hypot(x, y);\n}\n/**\n * Calculates the squared length of a vec2\n *\n * @param {ReadonlyVec2} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0],\n y = a[1];\n return x * x + y * y;\n}\n/**\n * Negates the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to negate\n * @returns {vec2} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to invert\n * @returns {vec2} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n return out;\n}\n/**\n * Normalize a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to normalize\n * @returns {vec2} out\n */\n\nexport function normalize(out, a) {\n var x = a[0],\n y = a[1];\n var len = x * x + y * y;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1];\n}\n/**\n * Computes the cross product of two vec2's\n * Note that the cross product must by definition produce a 3D vector\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var z = a[0] * b[1] - a[1] * b[0];\n out[0] = out[1] = 0;\n out[2] = z;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec2} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0],\n ay = a[1];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec2} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec2} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n out[0] = Math.cos(r) * scale;\n out[1] = Math.sin(r) * scale;\n return out;\n}\n/**\n * Transforms the vec2 with a mat2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat2} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat2(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y;\n out[1] = m[1] * x + m[3] * y;\n return out;\n}\n/**\n * Transforms the vec2 with a mat2d\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat2d} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat2d(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y + m[4];\n out[1] = m[1] * x + m[3] * y + m[5];\n return out;\n}\n/**\n * Transforms the vec2 with a mat3\n * 3rd vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat3} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[3] * y + m[6];\n out[1] = m[1] * x + m[4] * y + m[7];\n return out;\n}\n/**\n * Transforms the vec2 with a mat4\n * 3rd vector component is implicitly '0'\n * 4th vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0];\n var y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n return out;\n}\n/**\n * Rotate a 2D vector\n * @param {vec2} out The receiving vec2\n * @param {ReadonlyVec2} a The vec2 point to rotate\n * @param {ReadonlyVec2} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec2} out\n */\n\nexport function rotate(out, a, b, rad) {\n //Translate point to the origin\n var p0 = a[0] - b[0],\n p1 = a[1] - b[1],\n sinC = Math.sin(rad),\n cosC = Math.cos(rad); //perform rotation and translate to correct position\n\n out[0] = p0 * cosC - p1 * sinC + b[0];\n out[1] = p0 * sinC + p1 * cosC + b[1];\n return out;\n}\n/**\n * Get the angle between two 2D vectors\n * @param {ReadonlyVec2} a The first operand\n * @param {ReadonlyVec2} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var x1 = a[0],\n y1 = a[1],\n x2 = b[0],\n y2 = b[1],\n // mag is the product of the magnitudes of a and b\n mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2),\n // mag &&.. short circuits if mag == 0\n cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1\n\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec2 to zero\n *\n * @param {vec2} out the receiving vector\n * @returns {vec2} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec2} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec2(\" + a[0] + \", \" + a[1] + \")\";\n}\n/**\n * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec2} a The first vector.\n * @param {ReadonlyVec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec2} a The first vector.\n * @param {ReadonlyVec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1];\n var b0 = b[0],\n b1 = b[1];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));\n}\n/**\n * Alias for {@link vec2.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec2.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec2.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec2.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec2.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec2.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec2s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 2;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n }\n\n return a;\n };\n}();","import {StyleLayer} from '../style_layer';\n\nimport {CircleBucket} from '../../data/bucket/circle_bucket';\nimport {polygonIntersectsBufferedPoint} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate} from '../query_utils';\nimport properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../../geo/transform';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties.g';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n/**\n * A style layer that defines a circle\n */\nexport class CircleStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new CircleBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const circleBucket: CircleBucket = (bucket as any);\n return getMaximumPaintValue('circle-radius', this, circleBucket) +\n getMaximumPaintValue('circle-stroke-width', this, circleBucket) +\n translateDistance(this.paint.get('circle-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('circle-translate'),\n this.paint.get('circle-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const radius = this.paint.get('circle-radius').evaluate(feature, featureState);\n const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState);\n const size = radius + stroke;\n\n // For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile\n // // Otherwise, compare geometry in the plane of the viewport\n // // A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance\n // // A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance\n const alignWithMap = this.paint.get('circle-pitch-alignment') === 'map';\n const transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry(translatedPolygon, pixelPosMatrix);\n const transformedSize = alignWithMap ? size * pixelsToTileUnits : size;\n\n for (const ring of geometry) {\n for (const point of ring) {\n\n const transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix);\n\n let adjustedSize = transformedSize;\n const projectedCenter = vec4.transformMat4([] as any, [point.x, point.y, 0, 1], pixelPosMatrix);\n if (this.paint.get('circle-pitch-scale') === 'viewport' && this.paint.get('circle-pitch-alignment') === 'map') {\n adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance;\n } else if (this.paint.get('circle-pitch-scale') === 'map' && this.paint.get('circle-pitch-alignment') === 'viewport') {\n adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3];\n }\n\n if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) return true;\n }\n }\n\n return false;\n }\n}\n\nfunction projectPoint(p: Point, pixelPosMatrix: mat4) {\n const point = vec4.transformMat4([] as any, [p.x, p.y, 0, 1], pixelPosMatrix);\n return new Point(point[0] / point[3], point[1] / point[3]);\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4) {\n return queryGeometry.map((p) => {\n return projectPoint(p, pixelPosMatrix);\n });\n}\n","import {CircleBucket} from './circle_bucket';\nimport {register} from '../../util/web_worker_transfer';\n\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport class HeatmapBucket extends CircleBucket {\n // Needed for flow to accept omit: ['layers'] below, due to\n // https://github.com/facebook/flow/issues/4262\n layers: Array;\n}\n\nregister('HeatmapBucket', HeatmapBucket, {omit: ['layers']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HeatmapPaintProps = {\n \"heatmap-radius\": DataDrivenProperty,\n \"heatmap-weight\": DataDrivenProperty,\n \"heatmap-intensity\": DataConstantProperty,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": DataConstantProperty,\n};\n\nexport type HeatmapPaintPropsPossiblyEvaluated = {\n \"heatmap-radius\": PossiblyEvaluatedPropertyValue,\n \"heatmap-weight\": PossiblyEvaluatedPropertyValue,\n \"heatmap-intensity\": number,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"heatmap-radius\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-radius\"] as any as StylePropertySpecification),\n \"heatmap-weight\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-weight\"] as any as StylePropertySpecification),\n \"heatmap-intensity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-intensity\"] as any as StylePropertySpecification),\n \"heatmap-color\": new ColorRampProperty(styleSpec[\"paint_heatmap\"][\"heatmap-color\"] as any as StylePropertySpecification),\n \"heatmap-opacity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {register} from './web_worker_transfer';\n\nexport type Size = {\n width: number;\n height: number;\n};\n\ntype Point2D = {\n x: number;\n y: number;\n};\n\nfunction createImage(image: any, {\n width,\n height\n}: Size, channels: number, data?: Uint8Array | Uint8ClampedArray) {\n if (!data) {\n data = new Uint8Array(width * height * channels);\n } else if (data instanceof Uint8ClampedArray) {\n data = new Uint8Array(data.buffer);\n } else if (data.length !== width * height * channels) {\n throw new RangeError(`mismatched image size. expected: ${data.length} but got: ${width * height * channels}`);\n }\n image.width = width;\n image.height = height;\n image.data = data;\n return image;\n}\n\nfunction resizeImage(image: any, {\n width,\n height\n}: Size, channels: number) {\n if (width === image.width && height === image.height) {\n return;\n }\n\n const newImage = createImage({}, {width, height}, channels);\n\n copyImage(image, newImage, {x: 0, y: 0}, {x: 0, y: 0}, {\n width: Math.min(image.width, width),\n height: Math.min(image.height, height)\n }, channels);\n\n image.width = width;\n image.height = height;\n image.data = newImage.data;\n}\n\nfunction copyImage(srcImg: any, dstImg: any, srcPt: Point2D, dstPt: Point2D, size: Size, channels: number) {\n if (size.width === 0 || size.height === 0) {\n return dstImg;\n }\n\n if (size.width > srcImg.width ||\n size.height > srcImg.height ||\n srcPt.x > srcImg.width - size.width ||\n srcPt.y > srcImg.height - size.height) {\n throw new RangeError('out of range source coordinates for image copy');\n }\n\n if (size.width > dstImg.width ||\n size.height > dstImg.height ||\n dstPt.x > dstImg.width - size.width ||\n dstPt.y > dstImg.height - size.height) {\n throw new RangeError('out of range destination coordinates for image copy');\n }\n\n const srcData = srcImg.data;\n const dstData = dstImg.data;\n\n if (srcData === dstData) throw new Error('srcData equals dstData, so image is already copied');\n\n for (let y = 0; y < size.height; y++) {\n const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels;\n const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels;\n for (let i = 0; i < size.width * channels; i++) {\n dstData[dstOffset + i] = srcData[srcOffset + i];\n }\n }\n return dstImg;\n}\n\n/**\n * @internal\n * An image with alpha color value\n */\nexport class AlphaImage {\n width: number;\n height: number;\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 1, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 1);\n }\n\n clone() {\n return new AlphaImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 1);\n }\n}\n\n/**\n * An object to store image data not premultiplied, because ImageData is not premultiplied.\n * UNPACK_PREMULTIPLY_ALPHA_WEBGL must be used when uploading to a texture.\n */\nexport class RGBAImage {\n width: number;\n height: number;\n\n /**\n * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers.\n */\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 4, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 4);\n }\n\n replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean) {\n if (copy) {\n this.data.set(data);\n } else if (data instanceof Uint8ClampedArray) {\n this.data = new Uint8Array(data.buffer);\n } else {\n this.data = data;\n }\n }\n\n clone() {\n return new RGBAImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 4);\n }\n}\n\nregister('AlphaImage', AlphaImage);\nregister('RGBAImage', RGBAImage);\n","import {RGBAImage} from './image';\nimport {isPowerOfTwo} from './util';\n\nimport type {StylePropertyExpression} from '@maplibre/maplibre-gl-style-spec';\n\nexport type ColorRampParams = {\n expression: StylePropertyExpression;\n evaluationKey: string;\n resolution?: number;\n image?: RGBAImage;\n clips?: Array;\n};\n\n/**\n * Given an expression that should evaluate to a color ramp,\n * return a RGBA image representing that ramp expression.\n */\nexport function renderColorRamp(params: ColorRampParams): RGBAImage {\n const evaluationGlobals = {};\n const width = params.resolution || 256;\n const height = params.clips ? params.clips.length : 1;\n const image = params.image || new RGBAImage({width, height});\n\n if (!isPowerOfTwo(width)) throw new Error(`width is not a power of 2 - ${width}`);\n\n const renderPixel = (stride, index, progress) => {\n evaluationGlobals[params.evaluationKey] = progress;\n const pxColor = params.expression.evaluate(evaluationGlobals as any);\n // the colors are being unpremultiplied because Color uses\n // premultiplied values, and the Texture class expects unpremultiplied ones\n image.data[stride + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a);\n image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a);\n image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a);\n image.data[stride + index + 3] = Math.floor(pxColor.a * 255);\n };\n\n if (!params.clips) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n const progress = i / (width - 1);\n\n renderPixel(0, j, progress);\n }\n } else {\n for (let clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n // Remap progress between clips\n const progress = i / (width - 1);\n const {start, end} = params.clips[clip];\n const evaluationProgress = start * (1 - progress) + end * progress;\n renderPixel(stride, j, evaluationProgress);\n }\n }\n }\n\n return image;\n}\n","import {StyleLayer} from '../style_layer';\n\nimport {HeatmapBucket} from '../../data/bucket/heatmap_bucket';\nimport {RGBAImage} from '../../util/image';\nimport properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties.g';\nimport {renderColorRamp} from '../../util/color_ramp';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {Texture} from '../../render/texture';\nimport type {Framebuffer} from '../../gl/framebuffer';\nimport type {HeatmapPaintProps} from './heatmap_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A style layer that defines a heatmap\n */\nexport class HeatmapStyleLayer extends StyleLayer {\n\n heatmapFbo: Framebuffer;\n colorRamp: RGBAImage;\n colorRampTexture: Texture;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n createBucket(options: any) {\n return new HeatmapBucket(options);\n }\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n\n // make sure color ramp texture is generated for default heatmap color too\n this._updateColorRamp();\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'heatmap-color') {\n this._updateColorRamp();\n }\n }\n\n _updateColorRamp() {\n const expression = this._transitionablePaint._values['heatmap-color'].value.expression;\n this.colorRamp = renderColorRamp({\n expression,\n evaluationKey: 'heatmapDensity',\n image: this.colorRamp\n });\n this.colorRampTexture = null;\n }\n\n resize() {\n if (this.heatmapFbo) {\n this.heatmapFbo.destroy();\n this.heatmapFbo = null;\n }\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n return false;\n }\n\n hasOffscreenPass() {\n return this.paint.get('heatmap-opacity') !== 0 && this.visibility !== 'none';\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HillshadePaintProps = {\n \"hillshade-illumination-direction\": DataConstantProperty,\n \"hillshade-illumination-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"hillshade-exaggeration\": DataConstantProperty,\n \"hillshade-shadow-color\": DataConstantProperty,\n \"hillshade-highlight-color\": DataConstantProperty,\n \"hillshade-accent-color\": DataConstantProperty,\n};\n\nexport type HillshadePaintPropsPossiblyEvaluated = {\n \"hillshade-illumination-direction\": number,\n \"hillshade-illumination-anchor\": \"map\" | \"viewport\",\n \"hillshade-exaggeration\": number,\n \"hillshade-shadow-color\": Color,\n \"hillshade-highlight-color\": Color,\n \"hillshade-accent-color\": Color,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"hillshade-illumination-direction\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-direction\"] as any as StylePropertySpecification),\n \"hillshade-illumination-anchor\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-anchor\"] as any as StylePropertySpecification),\n \"hillshade-exaggeration\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-exaggeration\"] as any as StylePropertySpecification),\n \"hillshade-shadow-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-shadow-color\"] as any as StylePropertySpecification),\n \"hillshade-highlight-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-highlight-color\"] as any as StylePropertySpecification),\n \"hillshade-accent-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-accent-color\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {HillshadePaintPropsPossiblyEvaluated} from './hillshade_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {HillshadePaintProps} from './hillshade_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class HillshadeStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n hasOffscreenPass() {\n return this.paint.get('hillshade-exaggeration') !== 0 && this.visibility !== 'none';\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nmodule.exports = earcut;\nmodule.exports.default = earcut;\n\nfunction earcut(data, holeIndices, dim) {\n\n dim = dim || 2;\n\n var hasHoles = holeIndices && holeIndices.length,\n outerLen = hasHoles ? holeIndices[0] * dim : data.length,\n outerNode = linkedList(data, 0, outerLen, dim, true),\n triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n var minX, minY, maxX, maxY, x, y, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = maxX = data[0];\n minY = maxY = data[1];\n\n for (var i = dim; i < outerLen; i += dim) {\n x = data[i];\n y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n var i, last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n } else {\n for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n var p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n var stop = ear,\n prev, next;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n prev = ear.prev;\n next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n // cut off the triangle\n triangles.push(prev.i / dim | 0);\n triangles.push(ear.i / dim | 0);\n triangles.push(next.i / dim | 0);\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n var p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n // z-order range for the current triangle bbox;\n var minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n var p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles, dim) {\n var p = start;\n do {\n var a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i / dim | 0);\n triangles.push(p.i / dim | 0);\n triangles.push(b.i / dim | 0);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n var a = start;\n do {\n var b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n var c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n var queue = [],\n i, len, start, end, list;\n\n for (i = 0, len = holeIndices.length; i < len; i++) {\n start = holeIndices[i] * dim;\n end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareX);\n\n // process holes from left to right\n for (i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareX(a, b) {\n return a.x - b.x;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and and link it\nfunction eliminateHole(hole, outerNode) {\n var bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n var bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n var p = outerNode,\n hx = hole.x,\n hy = hole.y,\n qx = -Infinity,\n m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n do {\n if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n var stop = m,\n mx = m.x,\n my = m.y,\n tanMin = Infinity,\n tan;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n var p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n var i, p, q, e, tail, numMerges, pSize, qSize,\n inSize = 1;\n\n do {\n p = list;\n list = null;\n tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n q = p;\n pSize = 0;\n for (i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n var p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n var o1 = sign(area(p1, q1, p2));\n var o2 = sign(area(p1, q1, q2));\n var o3 = sign(area(p2, q2, p1));\n var o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n var p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n var p = a,\n inside = false,\n px = (a.x + b.x) / 2,\n py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n var a2 = new Node(a.i, a.x, a.y),\n b2 = new Node(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n var p = new Node(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n // vertex index in coordinates array\n this.i = i;\n\n // vertex coordinates\n this.x = x;\n this.y = y;\n\n // previous and next vertex nodes in a polygon ring\n this.prev = null;\n this.next = null;\n\n // z-order curve value\n this.z = 0;\n\n // previous and next nodes in z-order\n this.prevZ = null;\n this.nextZ = null;\n\n // indicates whether this is a steiner point\n this.steiner = false;\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nearcut.deviation = function (data, holeIndices, dim, triangles) {\n var hasHoles = holeIndices && holeIndices.length;\n var outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (var i = 0, len = holeIndices.length; i < len; i++) {\n var start = holeIndices[i] * dim;\n var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n var trianglesArea = 0;\n for (i = 0; i < triangles.length; i += 3) {\n var a = triangles[i] * dim;\n var b = triangles[i + 1] * dim;\n var c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n};\n\nfunction signedArea(data, start, end, dim) {\n var sum = 0;\n for (var i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nearcut.flatten = function (data) {\n var dim = data[0][0].length,\n result = {vertices: [], holes: [], dimensions: dim},\n holeIndex = 0;\n\n for (var i = 0; i < data.length; i++) {\n for (var j = 0; j < data[i].length; j++) {\n for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);\n }\n if (i > 0) {\n holeIndex += data[i - 1].length;\n result.holes.push(holeIndex);\n }\n }\n return result;\n};\n","\nexport default function quickselect(arr, k, left, right, compare) {\n quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);\n}\n\nfunction quickselectStep(arr, k, left, right, compare) {\n\n while (right > left) {\n if (right - left > 600) {\n var n = right - left + 1;\n var m = k - left + 1;\n var z = Math.log(n);\n var s = 0.5 * Math.exp(2 * z / 3);\n var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselectStep(arr, k, newLeft, newRight, compare);\n }\n\n var t = arr[k];\n var i = left;\n var j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\nfunction swap(arr, i, j) {\n var tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import quickselect from 'quickselect';\n\nimport {calculateSignedArea} from './util';\n\nimport type Point from '@mapbox/point-geometry';\n\n// classifies an array of rings into polygons with outer rings and holes\nexport function classifyRings(rings: Array>, maxRings: number) {\n const len = rings.length;\n\n if (len <= 1) return [rings];\n\n const polygons = [];\n let polygon,\n ccw;\n\n for (let i = 0; i < len; i++) {\n const area = calculateSignedArea(rings[i]);\n if (area === 0) continue;\n\n (rings[i] as any).area = Math.abs(area);\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n (polygon as any).push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n // Earcut performance degrades with the # of rings in a polygon. For this\n // reason, we limit strip out all but the `maxRings` largest rings.\n if (maxRings > 1) {\n for (let j = 0; j < polygons.length; j++) {\n if (polygons[j].length <= maxRings) continue;\n quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);\n polygons[j] = polygons[j].slice(0, maxRings);\n }\n }\n\n return polygons;\n}\n\nfunction compareAreas(a, b) {\n return b.area - a.area;\n}\n","import type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\n\nimport type {\n BucketFeature,\n PopulateParameters\n} from '../bucket';\nimport {PossiblyEvaluated} from '../../style/properties';\n\ntype PatternStyleLayers = Array | Array | Array;\n\nexport function hasPattern(type: string, layers: PatternStyleLayers, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n let hasPattern = false;\n\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n if (!patternProperty.isConstant()) {\n hasPattern = true;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern) {\n hasPattern = true;\n patterns[constantPattern.to] = true;\n patterns[constantPattern.from] = true;\n }\n }\n\n return hasPattern;\n}\n\nexport function addPatternDependencies(type: string, layers: PatternStyleLayers, patternFeature: BucketFeature, zoom: number, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n\n const patternPropertyValue = patternProperty.value;\n if (patternPropertyValue.kind !== 'constant') {\n let min = patternPropertyValue.evaluate({zoom: zoom - 1}, patternFeature, {}, options.availableImages);\n let mid = patternPropertyValue.evaluate({zoom}, patternFeature, {}, options.availableImages);\n let max = patternPropertyValue.evaluate({zoom: zoom + 1}, patternFeature, {}, options.availableImages);\n min = min && min.name ? min.name : min;\n mid = mid && mid.name ? mid.name : mid;\n max = max && max.name ? max.name : max;\n // add to patternDependencies\n patterns[min] = true;\n patterns[mid] = true;\n patterns[max] = true;\n\n // save for layout\n patternFeature.patterns[layer.id] = {min, mid, max};\n }\n }\n return patternFeature;\n}\n","import {FillLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './fill_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {LineIndexArray, TriangleIndexArray} from '../index_array_type';\nimport earcut from 'earcut';\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport class FillBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n\n layoutVertexArray: FillLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n indexArray2: LineIndexArray;\n indexBuffer2: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n segments2: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n\n this.layoutVertexArray = new FillLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.indexArray2 = new LineIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.segments2 = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('fill', this.layers, options);\n const fillSortKey = this.layers[0].layout.get('fill-sort-key');\n const sortFeaturesByKey = !fillSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternFeature = addPatternDependencies('fill', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending(): boolean {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.indexBuffer2 = context.createIndexBuffer(this.indexArray2);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.indexBuffer2.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.segments2.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n\n const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n const triangleIndex = triangleSegment.vertexLength;\n\n const flattened = [];\n const holeIndices = [];\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2);\n const lineIndex = lineSegment.vertexLength;\n\n this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y);\n this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex);\n flattened.push(ring[0].x);\n flattened.push(ring[0].y);\n\n for (let i = 1; i < ring.length; i++) {\n this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y);\n this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);\n flattened.push(ring[i].x);\n flattened.push(ring[i].y);\n }\n\n lineSegment.vertexLength += ring.length;\n lineSegment.primitiveLength += ring.length;\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let i = 0; i < indices.length; i += 3) {\n this.indexArray.emplaceBack(\n triangleIndex + indices[i],\n triangleIndex + indices[i + 1],\n triangleIndex + indices[i + 2]);\n }\n\n triangleSegment.vertexLength += numVertices;\n triangleSegment.primitiveLength += indices.length / 3;\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillBucket', FillBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FillLayoutProps = {\n \"fill-sort-key\": DataDrivenProperty,\n};\n\nexport type FillLayoutPropsPossiblyEvaluated = {\n \"fill-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"fill-sort-key\": new DataDrivenProperty(styleSpec[\"layout_fill\"][\"fill-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type FillPaintProps = {\n \"fill-antialias\": DataConstantProperty,\n \"fill-opacity\": DataDrivenProperty,\n \"fill-color\": DataDrivenProperty,\n \"fill-outline-color\": DataDrivenProperty,\n \"fill-translate\": DataConstantProperty<[number, number]>,\n \"fill-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-pattern\": CrossFadedDataDrivenProperty,\n};\n\nexport type FillPaintPropsPossiblyEvaluated = {\n \"fill-antialias\": boolean,\n \"fill-opacity\": PossiblyEvaluatedPropertyValue,\n \"fill-color\": PossiblyEvaluatedPropertyValue,\n \"fill-outline-color\": PossiblyEvaluatedPropertyValue,\n \"fill-translate\": [number, number],\n \"fill-translate-anchor\": \"map\" | \"viewport\",\n \"fill-pattern\": PossiblyEvaluatedPropertyValue>,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-antialias\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-antialias\"] as any as StylePropertySpecification),\n \"fill-opacity\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-opacity\"] as any as StylePropertySpecification),\n \"fill-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-color\"] as any as StylePropertySpecification),\n \"fill-outline-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-outline-color\"] as any as StylePropertySpecification),\n \"fill-translate\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate\"] as any as StylePropertySpecification),\n \"fill-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-pattern\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillBucket} from '../../data/bucket/fill_bucket';\nimport {polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\n\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class FillStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n const outlineColor = this.paint._values['fill-outline-color'];\n if (outlineColor.value.kind === 'constant' && outlineColor.value.value === undefined) {\n this.paint._values['fill-outline-color'] = this.paint._values['fill-color'];\n }\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-translate'),\n this.paint.get('fill-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n return polygonIntersectsMultiPolygon(translatedPolygon, geometry);\n }\n\n isTileClipped() {\n return true;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_normal_ed', components: 4, type: 'Int16'},\n], 4);\n\nexport const centroidAttributes = createLayout([\n {name: 'a_centroid', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nvar Point = require('@mapbox/point-geometry');\n\nmodule.exports = VectorTileFeature;\n\nfunction VectorTileFeature(pbf, end, extent, keys, values) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n\n pbf.readFields(readFeature, this, end);\n}\n\nfunction readFeature(tag, feature, pbf) {\n if (tag == 1) feature.id = pbf.readVarint();\n else if (tag == 2) readTag(pbf, feature);\n else if (tag == 3) feature.type = pbf.readVarint();\n else if (tag == 4) feature._geometry = pbf.pos;\n}\n\nfunction readTag(pbf, feature) {\n var end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var key = feature._keys[pbf.readVarint()],\n value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n\nVectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\nVectorTileFeature.prototype.loadGeometry = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n lines = [],\n line;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) { // moveTo\n if (line) lines.push(line);\n line = [];\n }\n\n line.push(new Point(x, y));\n\n } else if (cmd === 7) {\n\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].clone()); // closePolygon\n }\n\n } else {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n if (line) lines.push(line);\n\n return lines;\n};\n\nVectorTileFeature.prototype.bbox = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n x1 = Infinity,\n x2 = -Infinity,\n y1 = Infinity,\n y2 = -Infinity;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n\n } else if (cmd !== 7) {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n return [x1, y1, x2, y2];\n};\n\nVectorTileFeature.prototype.toGeoJSON = function(x, y, z) {\n var size = this.extent * Math.pow(2, z),\n x0 = this.extent * x,\n y0 = this.extent * y,\n coords = this.loadGeometry(),\n type = VectorTileFeature.types[this.type],\n i, j;\n\n function project(line) {\n for (var j = 0; j < line.length; j++) {\n var p = line[j], y2 = 180 - (p.y + y0) * 360 / size;\n line[j] = [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90\n ];\n }\n }\n\n switch (this.type) {\n case 1:\n var points = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n project(coords);\n break;\n\n case 2:\n for (i = 0; i < coords.length; i++) {\n project(coords[i]);\n }\n break;\n\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n project(coords[i][j]);\n }\n }\n break;\n }\n\n if (coords.length === 1) {\n coords = coords[0];\n } else {\n type = 'Multi' + type;\n }\n\n var result = {\n type: \"Feature\",\n geometry: {\n type: type,\n coordinates: coords\n },\n properties: this.properties\n };\n\n if ('id' in this) {\n result.id = this.id;\n }\n\n return result;\n};\n\n// classifies an array of rings into polygons with outer rings and holes\n\nfunction classifyRings(rings) {\n var len = rings.length;\n\n if (len <= 1) return [rings];\n\n var polygons = [],\n polygon,\n ccw;\n\n for (var i = 0; i < len; i++) {\n var area = signedArea(rings[i]);\n if (area === 0) continue;\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n return polygons;\n}\n\nfunction signedArea(ring) {\n var sum = 0;\n for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n","'use strict';\n\nvar VectorTileFeature = require('./vectortilefeature.js');\n\nmodule.exports = VectorTileLayer;\n\nfunction VectorTileLayer(pbf, end) {\n // Public\n this.version = 1;\n this.name = null;\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n}\n\nfunction readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n}\n\nfunction readValueMessage(pbf) {\n var value = null,\n end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var tag = pbf.readVarint() >> 3;\n\n value = tag === 1 ? pbf.readString() :\n tag === 2 ? pbf.readFloat() :\n tag === 3 ? pbf.readDouble() :\n tag === 4 ? pbf.readVarint64() :\n tag === 5 ? pbf.readVarint() :\n tag === 6 ? pbf.readSVarint() :\n tag === 7 ? pbf.readBoolean() : null;\n }\n\n return value;\n}\n\n// return feature `i` from this layer as a `VectorTileFeature`\nVectorTileLayer.prototype.feature = function(i) {\n if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');\n\n this._pbf.pos = this._features[i];\n\n var end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n};\n","'use strict';\n\nvar VectorTileLayer = require('./vectortilelayer');\n\nmodule.exports = VectorTile;\n\nfunction VectorTile(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n}\n\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n}\n\n","module.exports.VectorTile = require('./lib/vectortile.js');\nmodule.exports.VectorTileFeature = require('./lib/vectortilefeature.js');\nmodule.exports.VectorTileLayer = require('./lib/vectortilelayer.js');\n","import {FillExtrusionLayoutArray, PosArray} from '../array_types.g';\n\nimport {members as layoutAttributes, centroidAttributes} from './fill_extrusion_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport earcut from 'earcut';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\n\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nconst FACTOR = Math.pow(2, 13);\n\nfunction addVertex(vertexArray, x, y, nx, ny, nz, t, e) {\n vertexArray.emplaceBack(\n // a_pos\n x,\n y,\n // a_normal_ed: 3-component normal and 1-component edgedistance\n Math.floor(nx * FACTOR) * 2 + t,\n ny * FACTOR * 2,\n nz * FACTOR * 2,\n // edgedistance (used for wrapping patterns around extrusion sides)\n Math.round(e)\n );\n}\n\nexport class FillExtrusionBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: FillExtrusionLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n centroidVertexArray: PosArray;\n centroidVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n features: Array;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new FillExtrusionLayoutArray();\n this.centroidVertexArray = new PosArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.features = [];\n this.hasPattern = hasPattern('fill-extrusion', this.layers, options);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const bucketFeature: BucketFeature = {\n id,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n properties: feature.properties,\n type: feature.type,\n patterns: {}\n };\n\n if (this.hasPattern) {\n this.features.push(addPatternDependencies('fill-extrusion', this.layers, bucketFeature, this.zoom, options));\n } else {\n this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {});\n }\n\n options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);\n }\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.features) {\n const {geometry} = feature;\n this.addFeature(feature, geometry, feature.index, canonical, imagePositions);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.centroidVertexBuffer.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const centroid = {x: 0, y: 0, vertexCount: 0};\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n let segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (isEntirelyOutside(ring)) {\n continue;\n }\n\n let edgeDistance = 0;\n\n for (let p = 0; p < ring.length; p++) {\n const p1 = ring[p];\n\n if (p >= 1) {\n const p2 = ring[p - 1];\n\n if (!isBoundaryEdge(p1, p2)) {\n if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n }\n\n const perp = p1.sub(p2)._perp()._unit();\n const dist = p2.dist(p1);\n if (edgeDistance + dist > 32768) edgeDistance = 0;\n\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p1.x;\n centroid.y += 2 * p1.y;\n centroid.vertexCount += 2;\n\n edgeDistance += dist;\n\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p2.x;\n centroid.y += 2 * p2.y;\n centroid.vertexCount += 2;\n\n const bottomRight = segment.vertexLength;\n\n // ┌──────┐\n // │ 0 1 │ Counter-clockwise winding order.\n // │ │ Triangle 1: 0 => 2 => 1\n // │ 2 3 │ Triangle 2: 1 => 2 => 3\n // └──────┘\n this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);\n this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n }\n\n }\n\n if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n }\n\n //Only triangulate and draw the area of the feature if it is a polygon\n //Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined\n if (vectorTileFeatureTypes[feature.type] !== 'Polygon')\n continue;\n\n const flattened = [];\n const holeIndices = [];\n const triangleIndex = segment.vertexLength;\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n\n addVertex(this.layoutVertexArray, p.x, p.y, 0, 0, 1, 1, 0);\n centroid.x += p.x;\n centroid.y += p.y;\n centroid.vertexCount += 1;\n\n flattened.push(p.x);\n flattened.push(p.y);\n }\n\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let j = 0; j < indices.length; j += 3) {\n // Counter-clockwise winding order.\n this.indexArray.emplaceBack(\n triangleIndex + indices[j],\n triangleIndex + indices[j + 2],\n triangleIndex + indices[j + 1]);\n }\n\n segment.primitiveLength += indices.length / 3;\n segment.vertexLength += numVertices;\n }\n\n // remember polygon centroid to calculate elevation in GPU\n for (let i = 0; i < centroid.vertexCount; i++) {\n this.centroidVertexArray.emplaceBack(\n Math.floor(centroid.x / centroid.vertexCount),\n Math.floor(centroid.y / centroid.vertexCount)\n );\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillExtrusionBucket', FillExtrusionBucket, {omit: ['layers', 'features']});\n\nfunction isBoundaryEdge(p1, p2) {\n return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) ||\n (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT));\n}\n\nfunction isEntirelyOutside(ring) {\n return ring.every(p => p.x < 0) ||\n ring.every(p => p.x > EXTENT) ||\n ring.every(p => p.y < 0) ||\n ring.every(p => p.y > EXTENT);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type FillExtrusionPaintProps = {\n \"fill-extrusion-opacity\": DataConstantProperty,\n \"fill-extrusion-color\": DataDrivenProperty,\n \"fill-extrusion-translate\": DataConstantProperty<[number, number]>,\n \"fill-extrusion-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-extrusion-pattern\": CrossFadedDataDrivenProperty,\n \"fill-extrusion-height\": DataDrivenProperty,\n \"fill-extrusion-base\": DataDrivenProperty,\n \"fill-extrusion-vertical-gradient\": DataConstantProperty,\n};\n\nexport type FillExtrusionPaintPropsPossiblyEvaluated = {\n \"fill-extrusion-opacity\": number,\n \"fill-extrusion-color\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-translate\": [number, number],\n \"fill-extrusion-translate-anchor\": \"map\" | \"viewport\",\n \"fill-extrusion-pattern\": PossiblyEvaluatedPropertyValue>,\n \"fill-extrusion-height\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-base\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-vertical-gradient\": boolean,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-extrusion-opacity\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-opacity\"] as any as StylePropertySpecification),\n \"fill-extrusion-color\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-color\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-extrusion-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-pattern\"] as any as StylePropertySpecification),\n \"fill-extrusion-height\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-height\"] as any as StylePropertySpecification),\n \"fill-extrusion-base\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-base\"] as any as StylePropertySpecification),\n \"fill-extrusion-vertical-gradient\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-vertical-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillExtrusionBucket} from '../../data/bucket/fill_extrusion_bucket';\nimport {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class Point3D extends Point {\n z: number;\n}\n\nexport class FillExtrusionStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillExtrusionBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-extrusion-translate'));\n }\n\n is3D(): boolean {\n return true;\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number {\n\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-extrusion-translate'),\n this.paint.get('fill-extrusion-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n\n const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState);\n const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState);\n\n const projectedQueryGeometry = projectQueryGeometry(translatedPolygon, pixelPosMatrix, transform, 0);\n\n const projected = projectExtrusion(geometry, base, height, pixelPosMatrix);\n const projectedBase = projected[0];\n const projectedTop = projected[1];\n return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry);\n }\n}\n\nfunction dot(a, b) {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function getIntersectionDistance(projectedQueryGeometry: Array, projectedFace: Array) {\n\n if (projectedQueryGeometry.length === 1) {\n // For point queries calculate the z at which the point intersects the face\n // using barycentric coordinates.\n\n // Find the barycentric coordinates of the projected point within the first\n // triangle of the face, using only the xy plane. It doesn't matter if the\n // point is outside the first triangle because all the triangles in the face\n // are in the same plane.\n //\n // Check whether points are coincident and use other points if they are.\n let i = 0;\n const a = projectedFace[i++];\n let b;\n while (!b || a.equals(b)) {\n b = projectedFace[i++];\n if (!b) return Infinity;\n }\n\n // Loop until point `c` is not colinear with points `a` and `b`.\n for (; i < projectedFace.length; i++) {\n const c = projectedFace[i];\n\n const p = projectedQueryGeometry[0];\n\n const ab = b.sub(a);\n const ac = c.sub(a);\n const ap = p.sub(a);\n\n const dotABAB = dot(ab, ab);\n const dotABAC = dot(ab, ac);\n const dotACAC = dot(ac, ac);\n const dotAPAB = dot(ap, ab);\n const dotAPAC = dot(ap, ac);\n const denom = dotABAB * dotACAC - dotABAC * dotABAC;\n\n const v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom;\n const w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom;\n const u = 1 - v - w;\n\n // Use the barycentric weighting along with the original triangle z coordinates to get the point of intersection.\n const distance = a.z * u + b.z * v + c.z * w;\n\n if (isFinite(distance)) return distance;\n }\n\n return Infinity;\n\n } else {\n // The counts as closest is less clear when the query is a box. This\n // returns the distance to the nearest point on the face, whether it is\n // within the query or not. It could be more correct to return the\n // distance to the closest point within the query box but this would be\n // more complicated and expensive to calculate with little benefit.\n let closestDistance = Infinity;\n for (const p of projectedFace) {\n closestDistance = Math.min(closestDistance, p.z);\n }\n return closestDistance;\n }\n}\n\nfunction checkIntersection(projectedBase: Array>, projectedTop: Array>, projectedQueryGeometry: Array) {\n let closestDistance = Infinity;\n\n if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) {\n closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]);\n }\n\n for (let r = 0; r < projectedTop.length; r++) {\n const ringTop = projectedTop[r];\n const ringBase = projectedBase[r];\n for (let p = 0; p < ringTop.length - 1; p++) {\n const topA = ringTop[p];\n const topB = ringTop[p + 1];\n const baseA = ringBase[p];\n const baseB = ringBase[p + 1];\n const face = [topA, topB, baseB, baseA, topA];\n if (polygonIntersectsPolygon(projectedQueryGeometry, face)) {\n closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face));\n }\n }\n }\n\n return closestDistance === Infinity ? false : closestDistance;\n}\n\n/*\n * Project the geometry using matrix `m`. This is essentially doing\n * `vec4.transformMat4([], [p.x, p.y, z, 1], m)` but the multiplication\n * is inlined so that parts of the projection that are the same across\n * different points can only be done once. This produced a measurable\n * performance improvement.\n */\nfunction projectExtrusion(geometry: Array>, zBase: number, zTop: number, m: mat4): [Array>, Array>] {\n const projectedBase = [] as Array>;\n const projectedTop = [] as Array>;\n const baseXZ = m[8] * zBase;\n const baseYZ = m[9] * zBase;\n const baseZZ = m[10] * zBase;\n const baseWZ = m[11] * zBase;\n const topXZ = m[8] * zTop;\n const topYZ = m[9] * zTop;\n const topZZ = m[10] * zTop;\n const topWZ = m[11] * zTop;\n\n for (const r of geometry) {\n const ringBase = [] as Array;\n const ringTop = [] as Array;\n for (const p of r) {\n const x = p.x;\n const y = p.y;\n\n const sX = m[0] * x + m[4] * y + m[12];\n const sY = m[1] * x + m[5] * y + m[13];\n const sZ = m[2] * x + m[6] * y + m[14];\n const sW = m[3] * x + m[7] * y + m[15];\n\n const baseX = sX + baseXZ;\n const baseY = sY + baseYZ;\n const baseZ = sZ + baseZZ;\n const baseW = sW + baseWZ;\n\n const topX = sX + topXZ;\n const topY = sY + topYZ;\n const topZ = sZ + topZZ;\n const topW = sW + topWZ;\n\n const b = new Point(baseX / baseW, baseY / baseW) as Point3D;\n b.z = baseZ / baseW;\n ringBase.push(b);\n\n const t = new Point(topX / topW, topY / topW) as Point3D;\n t.z = topZ / topW;\n ringTop.push(t);\n }\n projectedBase.push(ringBase);\n projectedTop.push(ringTop);\n }\n return [projectedBase, projectedTop];\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4, transform: Transform, z: number) {\n const projectedQueryGeometry = [];\n for (const p of queryGeometry) {\n const v = [p.x, p.y, z, 1] as vec4;\n vec4.transformMat4(v, v, pixelPosMatrix);\n projectedQueryGeometry.push(new Point(v[0] / v[3], v[1] / v[3]));\n }\n return projectedQueryGeometry;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributes = createLayout([\n {name: 'a_pos_normal', components: 2, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint8'}\n], 4);\n\nexport const {members, size, alignment} = lineLayoutAttributes;\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributesExt = createLayout([\n {name: 'a_uv_x', components: 1, type: 'Float32'},\n {name: 'a_split_index', components: 1, type: 'Float32'},\n]);\n\nexport const {members, size, alignment} = lineLayoutAttributesExt;\n","import {LineLayoutArray, LineExtLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './line_attributes';\nimport {members as layoutAttributesExt} from './line_attributes_ext';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Segment} from '../segment';\nimport {RGBAImage} from '../../util/image';\nimport type {Context} from '../../gl/context';\nimport type {Texture} from '../../render/texture';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\n// NOTE ON EXTRUDE SCALE:\n// scale the extrusion vector so that the normal length is this value.\n// contains the \"texture\" normals (-1..1). this is distinct from the extrude\n// normals for line joins, because the x-value remains 0 for the texture\n// normal array, while the extrude normal actually moves the vertex to create\n// the acute/bevelled line join.\nconst EXTRUDE_SCALE = 63;\n\n/*\n * Sharp corners cause dashed lines to tilt because the distance along the line\n * is the same at both the inner and outer corners. To improve the appearance of\n * dashed lines we add extra points near sharp corners so that a smaller part\n * of the line is tilted.\n *\n * COS_HALF_SHARP_CORNER controls how sharp a corner has to be for us to add an\n * extra vertex. The default is 75 degrees.\n *\n * The newly created vertices are placed SHARP_CORNER_OFFSET pixels from the corner.\n */\nconst COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180));\nconst SHARP_CORNER_OFFSET = 15;\n\n// Angle per triangle for approximating round line joins.\nconst DEG_PER_TRIANGLE = 20;\n\n// The number of bits that is used to store the line distance in the buffer.\nconst LINE_DISTANCE_BUFFER_BITS = 15;\n\n// We don't have enough bits for the line distance as we'd like to have, so\n// use this value to scale the line distance (in tile units) down to a smaller\n// value. This lets us store longer distances while sacrificing precision.\nconst LINE_DISTANCE_SCALE = 1 / 2;\n\n// The maximum line distance, in tile units, that fits in the buffer.\nconst MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE;\n\ntype LineClips = {\n start: number;\n end: number;\n};\n\ntype GradientTexture = {\n texture?: Texture;\n gradient?: RGBAImage;\n version?: number;\n};\n\n/**\n * @internal\n * Line bucket class\n */\nexport class LineBucket implements Bucket {\n distance: number;\n totalDistance: number;\n maxLineLength: number;\n scaledDistance: number;\n lineClips?: LineClips;\n\n e1: number;\n e2: number;\n\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n gradients: {[x: string]: GradientTexture};\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n lineClipsArray: Array;\n\n layoutVertexArray: LineLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n layoutVertexArray2: LineExtLayoutArray;\n layoutVertexBuffer2: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n this.lineClipsArray = [];\n this.gradients = {};\n this.layers.forEach(layer => {\n this.gradients[layer.id] = {};\n });\n\n this.layoutVertexArray = new LineLayoutArray();\n this.layoutVertexArray2 = new LineExtLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.maxLineLength = 0;\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('line', this.layers, options);\n const lineSortKey = this.layers[0].layout.get('line-sort-key');\n const sortFeaturesByKey = !lineSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n lineSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => {\n return (a.sortKey) - (b.sortKey);\n });\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternBucketFeature = addPatternDependencies('line', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternBucketFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n if (this.layoutVertexArray2.length !== 0) {\n this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, layoutAttributesExt);\n }\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n lineFeatureClips(feature: BucketFeature): LineClips | undefined {\n if (!!feature.properties && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_start') && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_end')) {\n const start = +feature.properties['mapbox_clip_start'];\n const end = +feature.properties['mapbox_clip_end'];\n return {start, end};\n }\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const layout = this.layers[0].layout;\n const join = layout.get('line-join').evaluate(feature, {});\n const cap = layout.get('line-cap');\n const miterLimit = layout.get('line-miter-limit');\n const roundLimit = layout.get('line-round-limit');\n this.lineClips = this.lineFeatureClips(feature);\n\n for (const line of geometry) {\n this.addLine(line, feature, join, cap, miterLimit, roundLimit);\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n\n addLine(vertices: Array, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number) {\n this.distance = 0;\n this.scaledDistance = 0;\n this.totalDistance = 0;\n\n if (this.lineClips) {\n this.lineClipsArray.push(this.lineClips);\n // Calculate the total distance, in tile units, of this tiled line feature\n for (let i = 0; i < vertices.length - 1; i++) {\n this.totalDistance += vertices[i].dist(vertices[i + 1]);\n }\n this.updateScaledDistance();\n this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);\n }\n\n const isPolygon = vectorTileFeatureTypes[feature.type] === 'Polygon';\n\n // If the line has duplicate vertices at the ends, adjust start/length to remove them.\n let len = vertices.length;\n while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) {\n len--;\n }\n let first = 0;\n while (first < len - 1 && vertices[first].equals(vertices[first + 1])) {\n first++;\n }\n\n // Ignore invalid geometry.\n if (len < (isPolygon ? 3 : 2)) return;\n\n if (join === 'bevel') miterLimit = 1.05;\n\n const sharpCornerOffset = this.overscaling <= 16 ?\n SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) :\n 0;\n\n // we could be more precise, but it would only save a negligible amount of space\n const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray);\n\n let currentVertex: Point;\n let prevVertex: Point;\n let nextVertex: Point;\n let prevNormal: Point;\n let nextNormal: Point;\n\n // the last two vertices added\n this.e1 = this.e2 = -1;\n\n if (isPolygon) {\n currentVertex = vertices[len - 2];\n nextNormal = vertices[first].sub(currentVertex)._unit()._perp();\n }\n\n for (let i = first; i < len; i++) {\n\n nextVertex = i === len - 1 ?\n (isPolygon ? vertices[first + 1] : undefined) : // if it's a polygon, treat the last vertex like the first\n vertices[i + 1]; // just the next vertex\n\n // if two consecutive vertices exist, skip the current one\n if (nextVertex && vertices[i].equals(nextVertex)) continue;\n\n if (nextNormal) prevNormal = nextNormal;\n if (currentVertex) prevVertex = currentVertex;\n\n currentVertex = vertices[i];\n\n // Calculate the normal towards the next vertex in this line. In case\n // there is no next vertex, pretend that the line is continuing straight,\n // meaning that we are just using the previous normal.\n nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal;\n\n // If we still don't have a previous normal, this is the beginning of a\n // non-closed line, so we're doing a straight \"join\".\n prevNormal = prevNormal || nextNormal;\n\n // Determine the normal of the join extrusion. It is the angle bisector\n // of the segments between the previous line and the next line.\n // In the case of 180° angles, the prev and next normals cancel each other out:\n // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be\n // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle\n // below will also become 0 and miterLength will become Infinity.\n let joinNormal = prevNormal.add(nextNormal);\n if (joinNormal.x !== 0 || joinNormal.y !== 0) {\n joinNormal._unit();\n }\n /* joinNormal prevNormal\n * ↖ ↑\n * .________. prevVertex\n * |\n * nextNormal ← | currentVertex\n * |\n * nextVertex !\n *\n */\n\n // calculate cosines of the angle (and its half) using dot product\n const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y;\n const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y;\n\n // Calculate the length of the miter (the ratio of the miter to the width)\n // as the inverse of cosine of the angle between next and join normals\n const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity;\n\n // approximate angle from cosine\n const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle);\n\n const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex;\n const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0;\n\n if (isSharpCorner && i > first) {\n const prevSegmentLength = currentVertex.dist(prevVertex);\n if (prevSegmentLength > 2 * sharpCornerOffset) {\n const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round());\n this.updateDistance(prevVertex, newPrevVertex);\n this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment);\n prevVertex = newPrevVertex;\n }\n }\n\n // The join if a middle vertex, otherwise the cap.\n const middleVertex = prevVertex && nextVertex;\n let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap;\n\n if (middleVertex && currentJoin === 'round') {\n if (miterLength < roundLimit) {\n currentJoin = 'miter';\n } else if (miterLength <= 2) {\n currentJoin = 'fakeround';\n }\n }\n\n if (currentJoin === 'miter' && miterLength > miterLimit) {\n currentJoin = 'bevel';\n }\n\n if (currentJoin === 'bevel') {\n // The maximum extrude length is 128 / 63 = 2 times the width of the line\n // so if miterLength >= 2 we need to draw a different type of bevel here.\n if (miterLength > 2) currentJoin = 'flipbevel';\n\n // If the miterLength is really small and the line bevel wouldn't be visible,\n // just draw a miter join to save a triangle.\n if (miterLength < miterLimit) currentJoin = 'miter';\n }\n\n // Calculate how far along the line the currentVertex is\n if (prevVertex) this.updateDistance(prevVertex, currentVertex);\n\n if (currentJoin === 'miter') {\n\n joinNormal._mult(miterLength);\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n\n } else if (currentJoin === 'flipbevel') {\n // miter is too big, flip the direction to make a beveled join\n\n if (miterLength > 100) {\n // Almost parallel lines\n joinNormal = nextNormal.mult(-1);\n\n } else {\n const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag();\n joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1));\n }\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment);\n\n } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') {\n const offset = -Math.sqrt(miterLength * miterLength - 1);\n const offsetA = lineTurnsLeft ? offset : 0;\n const offsetB = lineTurnsLeft ? 0 : offset;\n\n // Close previous segment with a bevel\n if (prevVertex) {\n this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment);\n }\n\n if (currentJoin === 'fakeround') {\n // The join angle is sharp enough that a round join would be visible.\n // Bevel joins fill the gap between segments with a single pie slice triangle.\n // Create a round join by adding multiple pie slices. The join isn't actually round, but\n // it looks like it is at the sizes we render lines at.\n\n // pick the number of triangles for approximating round join by based on the angle between normals\n const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE);\n\n for (let m = 1; m < n; m++) {\n let t = m / n;\n if (t !== 0.5) {\n // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp\n const t2 = t - 0.5;\n const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519));\n const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638);\n t = t + t * t2 * (t - 1) * (A * t2 * t2 + B);\n }\n const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1);\n this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment);\n }\n }\n\n if (nextVertex) {\n // Start next segment\n this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment);\n }\n\n } else if (currentJoin === 'butt') {\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap\n\n } else if (currentJoin === 'square') {\n const offset = prevVertex ? 1 : -1; // closing or starting square cap\n this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment);\n\n } else if (currentJoin === 'round') {\n\n if (prevVertex) {\n // Close previous segment with butt\n this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment);\n\n // Add round cap or linejoin at end of segment\n this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true);\n }\n if (nextVertex) {\n // Add round cap before first segment\n this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true);\n\n // Start next segment with a butt\n this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment);\n }\n }\n\n if (isSharpCorner && i < len - 1) {\n const nextSegmentLength = currentVertex.dist(nextVertex);\n if (nextSegmentLength > 2 * sharpCornerOffset) {\n const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round());\n this.updateDistance(currentVertex, newCurrentVertex);\n this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment);\n currentVertex = newCurrentVertex;\n }\n }\n }\n }\n\n /**\n * Add two vertices to the buffers.\n *\n * @param p - the line vertex to add buffer vertices for\n * @param normal - vertex normal\n * @param endLeft - extrude to shift the left vertex along the line\n * @param endRight - extrude to shift the left vertex along the line\n * @param segment - the segment object to add the vertex to\n * @param round - whether this is a round cap\n */\n addCurrentVertex(p: Point, normal: Point, endLeft: number, endRight: number, segment: Segment, round: boolean = false) {\n // left and right extrude vectors, perpendicularly shifted by endLeft/endRight\n const leftX = normal.x + normal.y * endLeft;\n const leftY = normal.y - normal.x * endLeft;\n const rightX = -normal.x + normal.y * endRight;\n const rightY = -normal.y - normal.x * endRight;\n\n this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment);\n this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment);\n\n // There is a maximum \"distance along the line\" that we can store in the buffers.\n // When we get close to the distance, reset it to zero and add the vertex again with\n // a distance of zero. The max distance is determined by the number of bits we allocate\n // to `linesofar`.\n if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) {\n this.distance = 0;\n this.updateScaledDistance();\n this.addCurrentVertex(p, normal, endLeft, endRight, segment, round);\n }\n }\n\n addHalfVertex({x, y}: Point, extrudeX: number, extrudeY: number, round: boolean, up: boolean, dir: number, segment: Segment) {\n const totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance;\n // scale down so that we can store longer distances while sacrificing precision.\n const linesofarScaled = totalDistance * LINE_DISTANCE_SCALE;\n\n this.layoutVertexArray.emplaceBack(\n // a_pos_normal\n // Encode round/up the least significant bits\n (x << 1) + (round ? 1 : 0),\n (y << 1) + (up ? 1 : 0),\n // a_data\n // add 128 to store a byte in an unsigned byte\n Math.round(EXTRUDE_SCALE * extrudeX) + 128,\n Math.round(EXTRUDE_SCALE * extrudeY) + 128,\n // Encode the -1/0/1 direction value into the first two bits of .z of a_data.\n // Combine it with the lower 6 bits of `linesofarScaled` (shifted by 2 bits to make\n // room for the direction value). The upper 8 bits of `linesofarScaled` are placed in\n // the `w` component.\n ((dir === 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofarScaled & 0x3F) << 2),\n linesofarScaled >> 6);\n\n // Constructs a second vertex buffer with higher precision line progress\n if (this.lineClips) {\n const progressRealigned = this.scaledDistance - this.lineClips.start;\n const endClipRealigned = this.lineClips.end - this.lineClips.start;\n const uvX = progressRealigned / endClipRealigned;\n this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length);\n }\n\n const e = segment.vertexLength++;\n if (this.e1 >= 0 && this.e2 >= 0) {\n this.indexArray.emplaceBack(this.e1, this.e2, e);\n segment.primitiveLength++;\n }\n if (up) {\n this.e2 = e;\n } else {\n this.e1 = e;\n }\n }\n\n updateScaledDistance() {\n // Knowing the ratio of the full linestring covered by this tiled feature, as well\n // as the total distance (in tile units) of this tiled feature, and the distance\n // (in tile units) of the current vertex, we can determine the relative distance\n // of this vertex along the full linestring feature and scale it to [0, 2^15)\n this.scaledDistance = this.lineClips ?\n this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance :\n this.distance;\n }\n\n updateDistance(prev: Point, next: Point) {\n this.distance += prev.dist(next);\n this.updateScaledDistance();\n }\n}\n\nregister('LineBucket', LineBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LineLayoutProps = {\n \"line-cap\": DataConstantProperty<\"butt\" | \"round\" | \"square\">,\n \"line-join\": DataDrivenProperty<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": DataConstantProperty,\n \"line-round-limit\": DataConstantProperty,\n \"line-sort-key\": DataDrivenProperty,\n};\n\nexport type LineLayoutPropsPossiblyEvaluated = {\n \"line-cap\": \"butt\" | \"round\" | \"square\",\n \"line-join\": PossiblyEvaluatedPropertyValue<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": number,\n \"line-round-limit\": number,\n \"line-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"line-cap\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-cap\"] as any as StylePropertySpecification),\n \"line-join\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-join\"] as any as StylePropertySpecification),\n \"line-miter-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-miter-limit\"] as any as StylePropertySpecification),\n \"line-round-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-round-limit\"] as any as StylePropertySpecification),\n \"line-sort-key\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type LinePaintProps = {\n \"line-opacity\": DataDrivenProperty,\n \"line-color\": DataDrivenProperty,\n \"line-translate\": DataConstantProperty<[number, number]>,\n \"line-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"line-width\": DataDrivenProperty,\n \"line-gap-width\": DataDrivenProperty,\n \"line-offset\": DataDrivenProperty,\n \"line-blur\": DataDrivenProperty,\n \"line-dasharray\": CrossFadedProperty>,\n \"line-pattern\": CrossFadedDataDrivenProperty,\n \"line-gradient\": ColorRampProperty,\n};\n\nexport type LinePaintPropsPossiblyEvaluated = {\n \"line-opacity\": PossiblyEvaluatedPropertyValue,\n \"line-color\": PossiblyEvaluatedPropertyValue,\n \"line-translate\": [number, number],\n \"line-translate-anchor\": \"map\" | \"viewport\",\n \"line-width\": PossiblyEvaluatedPropertyValue,\n \"line-gap-width\": PossiblyEvaluatedPropertyValue,\n \"line-offset\": PossiblyEvaluatedPropertyValue,\n \"line-blur\": PossiblyEvaluatedPropertyValue,\n \"line-dasharray\": CrossFaded>,\n \"line-pattern\": PossiblyEvaluatedPropertyValue>,\n \"line-gradient\": ColorRampProperty,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"line-opacity\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-opacity\"] as any as StylePropertySpecification),\n \"line-color\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-color\"] as any as StylePropertySpecification),\n \"line-translate\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate\"] as any as StylePropertySpecification),\n \"line-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate-anchor\"] as any as StylePropertySpecification),\n \"line-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-width\"] as any as StylePropertySpecification),\n \"line-gap-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-gap-width\"] as any as StylePropertySpecification),\n \"line-offset\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-offset\"] as any as StylePropertySpecification),\n \"line-blur\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-blur\"] as any as StylePropertySpecification),\n \"line-dasharray\": new CrossFadedProperty(styleSpec[\"paint_line\"][\"line-dasharray\"] as any as StylePropertySpecification),\n \"line-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_line\"][\"line-pattern\"] as any as StylePropertySpecification),\n \"line-gradient\": new ColorRampProperty(styleSpec[\"paint_line\"][\"line-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import Point from '@mapbox/point-geometry';\n\nimport {StyleLayer} from '../style_layer';\nimport {LineBucket} from '../../data/bucket/line_bucket';\nimport {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate, offsetLine} from '../query_utils';\nimport properties, {LineLayoutPropsPossiblyEvaluated, LinePaintPropsPossiblyEvaluated} from './line_style_layer_properties.g';\nimport {extend} from '../../util/util';\nimport {EvaluationParameters} from '../evaluation_parameters';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties';\n\nimport {isZoomExpression, Step} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {LineLayoutProps, LinePaintProps} from './line_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class LineFloorwidthProperty extends DataDrivenProperty {\n useIntegerZoom: true;\n\n possiblyEvaluate(value, parameters) {\n parameters = new EvaluationParameters(Math.floor(parameters.zoom), {\n now: parameters.now,\n fadeDuration: parameters.fadeDuration,\n zoomHistory: parameters.zoomHistory,\n transition: parameters.transition\n });\n return super.possiblyEvaluate(value, parameters);\n }\n\n evaluate(value, globals, feature, featureState) {\n globals = extend({}, globals, {zoom: Math.floor(globals.zoom)});\n return super.evaluate(value, globals, feature, featureState);\n }\n}\n\nlet lineFloorwidthProperty: LineFloorwidthProperty;\n\nexport class LineStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n gradientVersion: number;\n stepInterpolant: boolean;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n this.gradientVersion = 0;\n if (!lineFloorwidthProperty) {\n lineFloorwidthProperty =\n new LineFloorwidthProperty(properties.paint.properties['line-width'].specification);\n lineFloorwidthProperty.useIntegerZoom = true;\n }\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'line-gradient') {\n const expression = this.gradientExpression();\n if (isZoomExpression(expression)) {\n this.stepInterpolant = expression._styleExpression.expression instanceof Step;\n } else {\n this.stepInterpolant = false;\n }\n this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;\n }\n }\n\n gradientExpression() {\n return this._transitionablePaint._values['line-gradient'].value.expression;\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n (this.paint._values as any)['line-floorwidth'] =\n lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values['line-width'].value, parameters);\n }\n\n createBucket(parameters: BucketParameters) {\n return new LineBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const lineBucket: LineBucket = (bucket as any);\n const width = getLineWidth(\n getMaximumPaintValue('line-width', this, lineBucket),\n getMaximumPaintValue('line-gap-width', this, lineBucket));\n const offset = getMaximumPaintValue('line-offset', this, lineBucket);\n return width / 2 + Math.abs(offset) + translateDistance(this.paint.get('line-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('line-translate'),\n this.paint.get('line-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const halfWidth = pixelsToTileUnits / 2 * getLineWidth(\n this.paint.get('line-width').evaluate(feature, featureState),\n this.paint.get('line-gap-width').evaluate(feature, featureState));\n const lineOffset = this.paint.get('line-offset').evaluate(feature, featureState);\n if (lineOffset) {\n geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits);\n }\n\n return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth);\n }\n\n isTileClipped() {\n return true;\n }\n}\n\nfunction getLineWidth(lineWidth, lineGapWidth) {\n if (lineGapWidth > 0) {\n return lineGapWidth + 2 * lineWidth;\n } else {\n return lineWidth;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const symbolLayoutAttributes = createLayout([\n {name: 'a_pos_offset', components: 4, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint16'},\n {name: 'a_pixeloffset', components: 4, type: 'Int16'}\n], 4);\n\nexport const dynamicLayoutAttributes = createLayout([\n {name: 'a_projected_pos', components: 3, type: 'Float32'}\n], 4);\n\nexport const placementOpacityAttributes = createLayout([\n {name: 'a_fade_opacity', components: 1, type: 'Uint32'}\n], 4);\n\nexport const collisionVertexAttributes = createLayout([\n {name: 'a_placed', components: 2, type: 'Uint8'},\n {name: 'a_shift', components: 2, type: 'Float32'}\n]);\n\nexport const collisionBox = createLayout([\n // the box is centered around the anchor point\n {type: 'Int16', name: 'anchorPointX'},\n {type: 'Int16', name: 'anchorPointY'},\n\n // distances to the edges from the anchor\n {type: 'Int16', name: 'x1'},\n {type: 'Int16', name: 'y1'},\n {type: 'Int16', name: 'x2'},\n {type: 'Int16', name: 'y2'},\n\n // the index of the feature in the original vectortile\n {type: 'Uint32', name: 'featureIndex'},\n // the source layer the feature appears in\n {type: 'Uint16', name: 'sourceLayerIndex'},\n // the bucket the feature appears in\n {type: 'Uint16', name: 'bucketIndex'},\n]);\n\nexport const collisionBoxLayout = createLayout([ // used to render collision boxes for debugging purposes\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_anchor_pos', components: 2, type: 'Int16'},\n {name: 'a_extrude', components: 2, type: 'Int16'}\n], 4);\n\nexport const collisionCircleLayout = createLayout([ // used to render collision circles for debugging purposes\n {name: 'a_pos', components: 2, type: 'Float32'},\n {name: 'a_radius', components: 1, type: 'Float32'},\n {name: 'a_flags', components: 2, type: 'Int16'}\n], 4);\n\nexport const quadTriangle = createLayout([\n {name: 'triangle', components: 3, type: 'Uint16'},\n]);\n\nexport const placement = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Uint16', name: 'glyphStartIndex'},\n {type: 'Uint16', name: 'numGlyphs'},\n {type: 'Uint32', name: 'vertexStartIndex'},\n {type: 'Uint32', name: 'lineStartIndex'},\n {type: 'Uint32', name: 'lineLength'},\n {type: 'Uint16', name: 'segment'},\n {type: 'Uint16', name: 'lowerSize'},\n {type: 'Uint16', name: 'upperSize'},\n {type: 'Float32', name: 'lineOffsetX'},\n {type: 'Float32', name: 'lineOffsetY'},\n {type: 'Uint8', name: 'writingMode'},\n {type: 'Uint8', name: 'placedOrientation'},\n {type: 'Uint8', name: 'hidden'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Int16', name: 'associatedIconIndex'}\n]);\n\nexport const symbolInstance = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Int16', name: 'rightJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'centerJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'leftJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedTextSymbolIndex'},\n {type: 'Int16', name: 'placedIconSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedIconSymbolIndex'},\n {type: 'Uint16', name: 'key'},\n {type: 'Uint16', name: 'textBoxStartIndex'},\n {type: 'Uint16', name: 'textBoxEndIndex'},\n {type: 'Uint16', name: 'verticalTextBoxStartIndex'},\n {type: 'Uint16', name: 'verticalTextBoxEndIndex'},\n {type: 'Uint16', name: 'iconBoxStartIndex'},\n {type: 'Uint16', name: 'iconBoxEndIndex'},\n {type: 'Uint16', name: 'verticalIconBoxStartIndex'},\n {type: 'Uint16', name: 'verticalIconBoxEndIndex'},\n {type: 'Uint16', name: 'featureIndex'},\n {type: 'Uint16', name: 'numHorizontalGlyphVertices'},\n {type: 'Uint16', name: 'numVerticalGlyphVertices'},\n {type: 'Uint16', name: 'numIconVertices'},\n {type: 'Uint16', name: 'numVerticalIconVertices'},\n {type: 'Uint16', name: 'useRuntimeCollisionCircles'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Float32', name: 'textBoxScale'},\n {type: 'Float32', name: 'collisionCircleDiameter'},\n {type: 'Uint16', name: 'textAnchorOffsetStartIndex'},\n {type: 'Uint16', name: 'textAnchorOffsetEndIndex'}\n]);\n\nexport const glyphOffset = createLayout([\n {type: 'Float32', name: 'offsetX'}\n]);\n\nexport const lineVertex = createLayout([\n {type: 'Int16', name: 'x'},\n {type: 'Int16', name: 'y'},\n {type: 'Int16', name: 'tileUnitDistanceFromAnchor'}\n]);\n\nexport const textAnchorOffset = createLayout([\n {type: 'Uint16', name: 'textAnchor'},\n {type: 'Float32', components: 2, name: 'textOffset'}\n]);\n","import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport {Formatted} from '@maplibre/maplibre-gl-style-spec';\n\nfunction transformTextInternal(text: string, layer: SymbolStyleLayer, feature: Feature) {\n const transform = layer.layout.get('text-transform').evaluate(feature, {});\n if (transform === 'uppercase') {\n text = text.toLocaleUpperCase();\n } else if (transform === 'lowercase') {\n text = text.toLocaleLowerCase();\n }\n\n if (rtlTextPlugin.applyArabicShaping) {\n text = rtlTextPlugin.applyArabicShaping(text);\n }\n\n return text;\n}\n\nexport function transformText(text: Formatted, layer: SymbolStyleLayer, feature: Feature): Formatted {\n text.sections.forEach(section => {\n section.text = transformTextInternal(section.text, layer, feature);\n });\n return text;\n}\n","import {charHasRotatedVerticalOrientation} from './script_detection';\n\nexport const verticalizedCharacterMap = {\n '!': '︕',\n '#': '#',\n '$': '$',\n '%': '%',\n '&': '&',\n '(': '︵',\n ')': '︶',\n '*': '*',\n '+': '+',\n ',': '︐',\n '-': '︲',\n '.': '・',\n '/': '/',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '=': '=',\n '>': '﹀',\n '?': '︖',\n '@': '@',\n '[': '﹇',\n '\\\\': '\',\n ']': '﹈',\n '^': '^',\n '_': '︳',\n '`': '`',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '~': '~',\n '¢': '¢',\n '£': '£',\n '¥': '¥',\n '¦': '¦',\n '¬': '¬',\n '¯': ' ̄',\n '–': '︲',\n '—': '︱',\n '‘': '﹃',\n '’': '﹄',\n '“': '﹁',\n '”': '﹂',\n '…': '︙',\n '‧': '・',\n '₩': '₩',\n '、': '︑',\n '。': '︒',\n '〈': '︿',\n '〉': '﹀',\n '《': '︽',\n '》': '︾',\n '「': '﹁',\n '」': '﹂',\n '『': '﹃',\n '』': '﹄',\n '【': '︻',\n '】': '︼',\n '〔': '︹',\n '〕': '︺',\n '〖': '︗',\n '〗': '︘',\n '!': '︕',\n '(': '︵',\n ')': '︶',\n ',': '︐',\n '-': '︲',\n '.': '・',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '>': '﹀',\n '?': '︖',\n '[': '﹇',\n ']': '﹈',\n '_': '︳',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '⦅': '︵',\n '⦆': '︶',\n '。': '︒',\n '「': '﹁',\n '」': '﹂'\n};\n\nexport function verticalizePunctuation(input: string) {\n let output = '';\n\n for (let i = 0; i < input.length; i++) {\n const nextCharCode = input.charCodeAt(i + 1) || null;\n const prevCharCode = input.charCodeAt(i - 1) || null;\n\n const canReplacePunctuation = (\n (!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) &&\n (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]])\n );\n\n if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) {\n output += verticalizedCharacterMap[input[i]];\n } else {\n output += input[i];\n }\n }\n\n return output;\n}\n\n","// ONE_EM constant used to go between \"em\" units used in style spec and \"points\" used internally for layout\n\nexport default 24;\n","'use strict';\n\nmodule.exports = Pbf;\n\nvar ieee754 = require('ieee754');\n\nfunction Pbf(buf) {\n this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n}\n\nPbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum\nPbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64\nPbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields\nPbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32\n\nvar SHIFT_LEFT_32 = (1 << 16) * (1 << 16),\n SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n\n// Threshold chosen based on both benchmarking and knowledge about browser string\n// data structures (which currently switch structure types at 12 bytes or more)\nvar TEXT_DECODER_MIN_LENGTH = 12;\nvar utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');\n\nPbf.prototype = {\n\n destroy: function() {\n this.buf = null;\n },\n\n // === READING =================================================================\n\n readFields: function(readField, result, end) {\n end = end || this.length;\n\n while (this.pos < end) {\n var val = this.readVarint(),\n tag = val >> 3,\n startPos = this.pos;\n\n this.type = val & 0x7;\n readField(tag, result, this);\n\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n },\n\n readMessage: function(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n },\n\n readFixed32: function() {\n var val = readUInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n readSFixed32: function() {\n var val = readInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n\n readFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readSFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readFloat: function() {\n var val = ieee754.read(this.buf, this.pos, true, 23, 4);\n this.pos += 4;\n return val;\n },\n\n readDouble: function() {\n var val = ieee754.read(this.buf, this.pos, true, 52, 8);\n this.pos += 8;\n return val;\n },\n\n readVarint: function(isSigned) {\n var buf = this.buf,\n val, b;\n\n b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;\n b = buf[this.pos]; val |= (b & 0x0f) << 28;\n\n return readVarintRemainder(val, isSigned, this);\n },\n\n readVarint64: function() { // for compatibility with v2.0.1\n return this.readVarint(true);\n },\n\n readSVarint: function() {\n var num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding\n },\n\n readBoolean: function() {\n return Boolean(this.readVarint());\n },\n\n readString: function() {\n var end = this.readVarint() + this.pos;\n var pos = this.pos;\n this.pos = end;\n\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n // longer strings are fast with the built-in browser TextDecoder API\n return readUtf8TextDecoder(this.buf, pos, end);\n }\n // short strings are fast with our custom implementation\n return readUtf8(this.buf, pos, end);\n },\n\n readBytes: function() {\n var end = this.readVarint() + this.pos,\n buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n },\n\n // verbose for performance reasons; doesn't affect gzipped size\n\n readPackedVarint: function(arr, isSigned) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n },\n readPackedSVarint: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n },\n readPackedBoolean: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n },\n readPackedFloat: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n },\n readPackedDouble: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n },\n readPackedFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n },\n readPackedSFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n },\n readPackedFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n },\n readPackedSFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n },\n\n skip: function(val) {\n var type = val & 0x7;\n if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}\n else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;\n else if (type === Pbf.Fixed32) this.pos += 4;\n else if (type === Pbf.Fixed64) this.pos += 8;\n else throw new Error('Unimplemented type: ' + type);\n },\n\n // === WRITING =================================================================\n\n writeTag: function(tag, type) {\n this.writeVarint((tag << 3) | type);\n },\n\n realloc: function(min) {\n var length = this.length || 16;\n\n while (length < this.pos + min) length *= 2;\n\n if (length !== this.length) {\n var buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.length = length;\n }\n },\n\n finish: function() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n },\n\n writeFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeSFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeSFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeVarint: function(val) {\n val = +val || 0;\n\n if (val > 0xfffffff || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n\n this.realloc(4);\n\n this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = (val >>> 7) & 0x7f;\n },\n\n writeSVarint: function(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n },\n\n writeBoolean: function(val) {\n this.writeVarint(Boolean(val));\n },\n\n writeString: function(str) {\n str = String(str);\n this.realloc(str.length * 4);\n\n this.pos++; // reserve 1 byte for short string length\n\n var startPos = this.pos;\n // write the string directly to the buffer and see how much was written\n this.pos = writeUtf8(this.buf, str, this.pos);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeFloat: function(val) {\n this.realloc(4);\n ieee754.write(this.buf, val, this.pos, true, 23, 4);\n this.pos += 4;\n },\n\n writeDouble: function(val) {\n this.realloc(8);\n ieee754.write(this.buf, val, this.pos, true, 52, 8);\n this.pos += 8;\n },\n\n writeBytes: function(buffer) {\n var len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n },\n\n writeRawMessage: function(fn, obj) {\n this.pos++; // reserve 1 byte for short message length\n\n // write the message directly to the buffer and see how much was written\n var startPos = this.pos;\n fn(obj, this);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeMessage: function(tag, fn, obj) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeRawMessage(fn, obj);\n },\n\n writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },\n writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },\n writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },\n writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },\n writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },\n writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },\n writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },\n writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },\n writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },\n\n writeBytesField: function(tag, buffer) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeBytes(buffer);\n },\n writeFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFixed32(val);\n },\n writeSFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeSFixed32(val);\n },\n writeFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeFixed64(val);\n },\n writeSFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeSFixed64(val);\n },\n writeVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeVarint(val);\n },\n writeSVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeSVarint(val);\n },\n writeStringField: function(tag, str) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeString(str);\n },\n writeFloatField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFloat(val);\n },\n writeDoubleField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeDouble(val);\n },\n writeBooleanField: function(tag, val) {\n this.writeVarintField(tag, Boolean(val));\n }\n};\n\nfunction readVarintRemainder(l, s, p) {\n var buf = p.buf,\n h, b;\n\n b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);\n\n throw new Error('Expected varint not more than 10 bytes');\n}\n\nfunction readPackedEnd(pbf) {\n return pbf.type === Pbf.Bytes ?\n pbf.readVarint() + pbf.pos : pbf.pos + 1;\n}\n\nfunction toNum(low, high, isSigned) {\n if (isSigned) {\n return high * 0x100000000 + (low >>> 0);\n }\n\n return ((high >>> 0) * 0x100000000) + (low >>> 0);\n}\n\nfunction writeBigVarint(val, pbf) {\n var low, high;\n\n if (val >= 0) {\n low = (val % 0x100000000) | 0;\n high = (val / 0x100000000) | 0;\n } else {\n low = ~(-val % 0x100000000);\n high = ~(-val / 0x100000000);\n\n if (low ^ 0xffffffff) {\n low = (low + 1) | 0;\n } else {\n low = 0;\n high = (high + 1) | 0;\n }\n }\n\n if (val >= 0x10000000000000000 || val < -0x10000000000000000) {\n throw new Error('Given varint doesn\\'t fit into 10 bytes');\n }\n\n pbf.realloc(10);\n\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n}\n\nfunction writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos] = low & 0x7f;\n}\n\nfunction writeBigVarintHigh(high, pbf) {\n var lsb = (high & 0x07) << 4;\n\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f;\n}\n\nfunction makeRoomForExtraLength(startPos, len, pbf) {\n var extraLen =\n len <= 0x3fff ? 1 :\n len <= 0x1fffff ? 2 :\n len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n\n // if 1 byte isn't enough for encoding message length, shift the data to the right\n pbf.realloc(extraLen);\n for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n}\n\nfunction writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }\nfunction writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }\nfunction writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }\nfunction writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }\nfunction writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }\nfunction writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }\nfunction writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }\nfunction writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }\nfunction writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }\n\n// Buffer code below from https://github.com/feross/buffer, MIT-licensed\n\nfunction readUInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] * 0x1000000);\n}\n\nfunction writeInt32(buf, val, pos) {\n buf[pos] = val;\n buf[pos + 1] = (val >>> 8);\n buf[pos + 2] = (val >>> 16);\n buf[pos + 3] = (val >>> 24);\n}\n\nfunction readInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] << 24);\n}\n\nfunction readUtf8(buf, pos, end) {\n var str = '';\n var i = pos;\n\n while (i < end) {\n var b0 = buf[i];\n var c = null; // codepoint\n var bytesPerSequence =\n b0 > 0xEF ? 4 :\n b0 > 0xDF ? 3 :\n b0 > 0xBF ? 2 : 1;\n\n if (i + bytesPerSequence > end) break;\n\n var b1, b2, b3;\n\n if (bytesPerSequence === 1) {\n if (b0 < 0x80) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 0xC0) === 0x80) {\n c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);\n if (c <= 0x7F) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);\n if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);\n if (c <= 0xFFFF || c >= 0x110000) {\n c = null;\n }\n }\n }\n\n if (c === null) {\n c = 0xFFFD;\n bytesPerSequence = 1;\n\n } else if (c > 0xFFFF) {\n c -= 0x10000;\n str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);\n c = 0xDC00 | c & 0x3FF;\n }\n\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n\n return str;\n}\n\nfunction readUtf8TextDecoder(buf, pos, end) {\n return utf8TextDecoder.decode(buf.subarray(pos, end));\n}\n\nfunction writeUtf8(buf, str, pos) {\n for (var i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i); // code point\n\n if (c > 0xD7FF && c < 0xE000) {\n if (lead) {\n if (c < 0xDC00) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = c;\n continue;\n } else {\n c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;\n lead = null;\n }\n } else {\n if (c > 0xDBFF || (i + 1 === str.length)) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = null;\n }\n\n if (c < 0x80) {\n buf[pos++] = c;\n } else {\n if (c < 0x800) {\n buf[pos++] = c >> 0x6 | 0xC0;\n } else {\n if (c < 0x10000) {\n buf[pos++] = c >> 0xC | 0xE0;\n } else {\n buf[pos++] = c >> 0x12 | 0xF0;\n buf[pos++] = c >> 0xC & 0x3F | 0x80;\n }\n buf[pos++] = c >> 0x6 & 0x3F | 0x80;\n }\n buf[pos++] = c & 0x3F | 0x80;\n }\n }\n return pos;\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","import {AlphaImage} from '../util/image';\n\nimport Protobuf from 'pbf';\nconst border = 3;\n\nimport type {StyleGlyph} from './style_glyph';\n\nfunction readFontstacks(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 1) {\n pbf.readMessage(readFontstack, glyphs);\n }\n}\n\nfunction readFontstack(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 3) {\n const {id, bitmap, width, height, left, top, advance} = pbf.readMessage(readGlyph, {});\n glyphs.push({\n id,\n bitmap: new AlphaImage({\n width: width + 2 * border,\n height: height + 2 * border\n }, bitmap),\n metrics: {width, height, left, top, advance}\n });\n }\n}\n\nfunction readGlyph(tag: number, glyph: any, pbf: Protobuf) {\n if (tag === 1) glyph.id = pbf.readVarint();\n else if (tag === 2) glyph.bitmap = pbf.readBytes();\n else if (tag === 3) glyph.width = pbf.readVarint();\n else if (tag === 4) glyph.height = pbf.readVarint();\n else if (tag === 5) glyph.left = pbf.readSVarint();\n else if (tag === 6) glyph.top = pbf.readSVarint();\n else if (tag === 7) glyph.advance = pbf.readVarint();\n}\n\nexport function parseGlyphPbf(data: ArrayBuffer | Uint8Array): Array {\n return new Protobuf(data).readFields(readFontstacks, []);\n}\n\nexport const GLYPH_PBF_BORDER = border;\n","\nexport default function potpack(boxes) {\n\n // calculate total box area and maximum box width\n let area = 0;\n let maxWidth = 0;\n\n for (const box of boxes) {\n area += box.w * box.h;\n maxWidth = Math.max(maxWidth, box.w);\n }\n\n // sort the boxes for insertion by height, descending\n boxes.sort((a, b) => b.h - a.h);\n\n // aim for a squarish resulting container,\n // slightly adjusted for sub-100% space utilization\n const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth);\n\n // start with a single empty space, unbounded at the bottom\n const spaces = [{x: 0, y: 0, w: startWidth, h: Infinity}];\n\n let width = 0;\n let height = 0;\n\n for (const box of boxes) {\n // look through spaces backwards so that we check smaller spaces first\n for (let i = spaces.length - 1; i >= 0; i--) {\n const space = spaces[i];\n\n // look for empty spaces that can accommodate the current box\n if (box.w > space.w || box.h > space.h) continue;\n\n // found the space; add the box to its top-left corner\n // |-------|-------|\n // | box | |\n // |_______| |\n // | space |\n // |_______________|\n box.x = space.x;\n box.y = space.y;\n\n height = Math.max(height, box.y + box.h);\n width = Math.max(width, box.x + box.w);\n\n if (box.w === space.w && box.h === space.h) {\n // space matches the box exactly; remove it\n const last = spaces.pop();\n if (i < spaces.length) spaces[i] = last;\n\n } else if (box.h === space.h) {\n // space matches the box height; update it accordingly\n // |-------|---------------|\n // | box | updated space |\n // |_______|_______________|\n space.x += box.w;\n space.w -= box.w;\n\n } else if (box.w === space.w) {\n // space matches the box width; update it accordingly\n // |---------------|\n // | box |\n // |_______________|\n // | updated space |\n // |_______________|\n space.y += box.h;\n space.h -= box.h;\n\n } else {\n // otherwise the box splits the space into two spaces\n // |-------|-----------|\n // | box | new space |\n // |_______|___________|\n // | updated space |\n // |___________________|\n spaces.push({\n x: space.x + box.w,\n y: space.y,\n w: space.w - box.w,\n h: box.h\n });\n space.y += box.h;\n space.h -= box.h;\n }\n break;\n }\n }\n\n return {\n w: width, // container width\n h: height, // container height\n fill: (area / (width * height)) || 0 // space utilization\n };\n}\n","/* eslint-disable key-spacing */\nimport {RGBAImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {ImageManager} from './image_manager';\nimport type {Texture} from './texture';\nimport type {Rect} from './glyph_atlas';\n\nconst IMAGE_PADDING: number = 1;\nexport {IMAGE_PADDING};\n\nexport class ImagePosition {\n paddedRect: Rect;\n pixelRatio: number;\n version: number;\n stretchY: Array<[number, number]>;\n stretchX: Array<[number, number]>;\n content: [number, number, number, number];\n\n constructor(paddedRect: Rect, {\n pixelRatio,\n version,\n stretchX,\n stretchY,\n content\n }: StyleImage) {\n this.paddedRect = paddedRect;\n this.pixelRatio = pixelRatio;\n this.stretchX = stretchX;\n this.stretchY = stretchY;\n this.content = content;\n this.version = version;\n }\n\n get tl(): [number, number] {\n return [\n this.paddedRect.x + IMAGE_PADDING,\n this.paddedRect.y + IMAGE_PADDING\n ];\n }\n\n get br(): [number, number] {\n return [\n this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING,\n this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING\n ];\n }\n\n get tlbr(): Array {\n return this.tl.concat(this.br);\n }\n\n get displaySize(): [number, number] {\n return [\n (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio,\n (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio\n ];\n }\n}\n\n/**\n * @internal\n * A class holding all the images\n */\nexport class ImageAtlas {\n image: RGBAImage;\n iconPositions: {[_: string]: ImagePosition};\n patternPositions: {[_: string]: ImagePosition};\n haveRenderCallbacks: Array;\n uploaded: boolean;\n\n constructor(icons: {[_: string]: StyleImage}, patterns: {[_: string]: StyleImage}) {\n const iconPositions = {}, patternPositions = {};\n this.haveRenderCallbacks = [];\n\n const bins = [];\n\n this.addImages(icons, iconPositions, bins);\n this.addImages(patterns, patternPositions, bins);\n\n const {w, h} = potpack(bins);\n const image = new RGBAImage({width: w || 1, height: h || 1});\n\n for (const id in icons) {\n const src = icons[id];\n const bin = iconPositions[id].paddedRect;\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: bin.x + IMAGE_PADDING, y: bin.y + IMAGE_PADDING}, src.data);\n }\n\n for (const id in patterns) {\n const src = patterns[id];\n const bin = patternPositions[id].paddedRect;\n const x = bin.x + IMAGE_PADDING,\n y = bin.y + IMAGE_PADDING,\n w = src.data.width,\n h = src.data.height;\n\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y}, src.data);\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src.data, image, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src.data, image, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.image = image;\n this.iconPositions = iconPositions;\n this.patternPositions = patternPositions;\n }\n\n addImages(images: {[_: string]: StyleImage}, positions: {[_: string]: ImagePosition}, bins: Array) {\n for (const id in images) {\n const src = images[id];\n const bin = {\n x: 0,\n y: 0,\n w: src.data.width + 2 * IMAGE_PADDING,\n h: src.data.height + 2 * IMAGE_PADDING,\n };\n bins.push(bin);\n positions[id] = new ImagePosition(bin, src);\n\n if (src.hasRenderCallback) {\n this.haveRenderCallbacks.push(id);\n }\n }\n }\n\n patchUpdatedImages(imageManager: ImageManager, texture: Texture) {\n imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks);\n for (const name in imageManager.updatedImages) {\n this.patchUpdatedImage(this.iconPositions[name], imageManager.getImage(name), texture);\n this.patchUpdatedImage(this.patternPositions[name], imageManager.getImage(name), texture);\n }\n }\n\n patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture) {\n if (!position || !image) return;\n\n if (position.version === image.version) return;\n\n position.version = image.version;\n const [x, y] = position.tl;\n texture.update(image.data, undefined, {x, y});\n }\n\n}\n\nregister('ImagePosition', ImagePosition);\nregister('ImageAtlas', ImageAtlas);\n","import {\n charHasUprightVerticalOrientation,\n charAllowsIdeographicBreaking,\n charInComplexShapingScript\n} from '../util/script_detection';\nimport {verticalizePunctuation} from '../util/verticalize_punctuation';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\nimport ONE_EM from './one_em';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleGlyph, GlyphMetrics} from '../style/style_glyph';\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\nimport type {ImagePosition} from '../render/image_atlas';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {Rect, GlyphPosition} from '../render/glyph_atlas';\nimport {Formatted, FormattedSection} from '@maplibre/maplibre-gl-style-spec';\n\nenum WritingMode {\n none = 0,\n horizontal = 1,\n vertical = 2,\n horizontalOnly = 3\n}\n\nconst SHAPING_DEFAULT_OFFSET = -17;\nexport {shapeText, shapeIcon, fitIconToText, getAnchorAlignment, WritingMode, SHAPING_DEFAULT_OFFSET};\n\n// The position of a glyph relative to the text's anchor point.\nexport type PositionedGlyph = {\n glyph: number;\n imageName: string | null;\n x: number;\n y: number;\n vertical: boolean;\n scale: number;\n fontStack: string;\n sectionIndex: number;\n metrics: GlyphMetrics;\n rect: Rect | null;\n};\n\nexport type PositionedLine = {\n positionedGlyphs: Array;\n lineOffset: number;\n};\n\n// A collection of positioned glyphs and some metadata\nexport type Shaping = {\n positionedLines: Array;\n top: number;\n bottom: number;\n left: number;\n right: number;\n writingMode: WritingMode.horizontal | WritingMode.vertical;\n text: string;\n iconsInText: boolean;\n verticalizable: boolean;\n};\n\nfunction isEmpty(positionedLines: Array) {\n for (const line of positionedLines) {\n if (line.positionedGlyphs.length !== 0) {\n return false;\n }\n }\n return true;\n}\n\nexport type SymbolAnchor = 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\nexport type TextJustify = 'left' | 'center' | 'right';\n\n// Max number of images in label is 6401 U+E000–U+F8FF that covers\n// Basic Multilingual Plane Unicode Private Use Area (PUA).\nconst PUAbegin = 0xE000;\nconst PUAend = 0xF8FF;\n\nclass SectionOptions {\n // Text options\n scale: number;\n fontStack: string;\n // Image options\n imageName: string | null;\n\n constructor() {\n this.scale = 1.0;\n this.fontStack = '';\n this.imageName = null;\n }\n\n static forText(scale: number | null, fontStack: string) {\n const textOptions = new SectionOptions();\n textOptions.scale = scale || 1;\n textOptions.fontStack = fontStack;\n return textOptions;\n }\n\n static forImage(imageName: string) {\n const imageOptions = new SectionOptions();\n imageOptions.imageName = imageName;\n return imageOptions;\n }\n\n}\n\nclass TaggedString {\n text: string;\n sectionIndex: Array; // maps each character in 'text' to its corresponding entry in 'sections'\n sections: Array;\n imageSectionID: number | null;\n\n constructor() {\n this.text = '';\n this.sectionIndex = [];\n this.sections = [];\n this.imageSectionID = null;\n }\n\n static fromFeature(text: Formatted, defaultFontStack: string) {\n const result = new TaggedString();\n for (let i = 0; i < text.sections.length; i++) {\n const section = text.sections[i];\n if (!section.image) {\n result.addTextSection(section, defaultFontStack);\n } else {\n result.addImageSection(section);\n }\n }\n return result;\n }\n\n length(): number {\n return this.text.length;\n }\n\n getSection(index: number): SectionOptions {\n return this.sections[this.sectionIndex[index]];\n }\n\n getSectionIndex(index: number): number {\n return this.sectionIndex[index];\n }\n\n getCharCode(index: number): number {\n return this.text.charCodeAt(index);\n }\n\n verticalizePunctuation() {\n this.text = verticalizePunctuation(this.text);\n }\n\n trim() {\n let beginningWhitespace = 0;\n for (let i = 0;\n i < this.text.length && whitespace[this.text.charCodeAt(i)];\n i++) {\n beginningWhitespace++;\n }\n let trailingWhitespace = this.text.length;\n for (let i = this.text.length - 1;\n i >= 0 && i >= beginningWhitespace && whitespace[this.text.charCodeAt(i)];\n i--) {\n trailingWhitespace--;\n }\n this.text = this.text.substring(beginningWhitespace, trailingWhitespace);\n this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace);\n }\n\n substring(start: number, end: number): TaggedString {\n const substring = new TaggedString();\n substring.text = this.text.substring(start, end);\n substring.sectionIndex = this.sectionIndex.slice(start, end);\n substring.sections = this.sections;\n return substring;\n }\n\n toString(): string {\n return this.text;\n }\n\n getMaxScale() {\n return this.sectionIndex.reduce((max, index) => Math.max(max, this.sections[index].scale), 0);\n }\n\n addTextSection(section: FormattedSection, defaultFontStack: string) {\n this.text += section.text;\n this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack));\n const index = this.sections.length - 1;\n for (let i = 0; i < section.text.length; ++i) {\n this.sectionIndex.push(index);\n }\n }\n\n addImageSection(section: FormattedSection) {\n const imageName = section.image ? section.image.name : '';\n if (imageName.length === 0) {\n warnOnce('Can\\'t add FormattedSection with an empty image.');\n return;\n }\n\n const nextImageSectionCharCode = this.getNextImageSectionCharCode();\n if (!nextImageSectionCharCode) {\n warnOnce(`Reached maximum number of images ${PUAend - PUAbegin + 2}`);\n return;\n }\n\n this.text += String.fromCharCode(nextImageSectionCharCode);\n this.sections.push(SectionOptions.forImage(imageName));\n this.sectionIndex.push(this.sections.length - 1);\n }\n\n getNextImageSectionCharCode(): number | null {\n if (!this.imageSectionID) {\n this.imageSectionID = PUAbegin;\n return this.imageSectionID;\n }\n\n if (this.imageSectionID >= PUAend) return null;\n return ++this.imageSectionID;\n }\n}\n\nfunction breakLines(input: TaggedString, lineBreakPoints: Array): Array {\n const lines = [];\n const text = input.text;\n let start = 0;\n for (const lineBreak of lineBreakPoints) {\n lines.push(input.substring(start, lineBreak));\n start = lineBreak;\n }\n\n if (start < text.length) {\n lines.push(input.substring(start, text.length));\n }\n return lines;\n}\n\nfunction shapeText(\n text: Formatted,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n defaultFontStack: string,\n maxWidth: number,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n spacing: number,\n translate: [number, number],\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n allowVerticalPlacement: boolean,\n symbolPlacement: string,\n layoutTextSize: number,\n layoutTextSizeThisZoom: number\n): Shaping | false {\n const logicalInput = TaggedString.fromFeature(text, defaultFontStack);\n\n if (writingMode === WritingMode.vertical) {\n logicalInput.verticalizePunctuation();\n }\n\n let lines: Array;\n\n const {processBidirectionalText, processStyledBidirectionalText} = rtlTextPlugin;\n if (processBidirectionalText && logicalInput.sections.length === 1) {\n // Bidi doesn't have to be style-aware\n lines = [];\n const untaggedLines =\n processBidirectionalText(logicalInput.toString(),\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of untaggedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line;\n taggedLine.sections = logicalInput.sections;\n for (let i = 0; i < line.length; i++) {\n taggedLine.sectionIndex.push(0);\n }\n lines.push(taggedLine);\n }\n } else if (processStyledBidirectionalText) {\n // Need version of mapbox-gl-rtl-text with style support for combining RTL text\n // with formatting\n lines = [];\n const processedLines =\n processStyledBidirectionalText(logicalInput.text,\n logicalInput.sectionIndex,\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of processedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line[0];\n taggedLine.sectionIndex = line[1];\n taggedLine.sections = logicalInput.sections;\n lines.push(taggedLine);\n }\n } else {\n lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n }\n\n const positionedLines = [];\n const shaping = {\n positionedLines,\n text: logicalInput.toString(),\n top: translate[1],\n bottom: translate[1],\n left: translate[0],\n right: translate[0],\n writingMode,\n iconsInText: false,\n verticalizable: false\n };\n\n shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom);\n if (isEmpty(positionedLines)) return false;\n\n return shaping;\n}\n\n// using computed properties due to https://github.com/facebook/flow/issues/380\n/* eslint no-useless-computed-key: 0 */\n\nconst whitespace: {\n [_: number]: boolean;\n} = {\n [0x09]: true, // tab\n [0x0a]: true, // newline\n [0x0b]: true, // vertical tab\n [0x0c]: true, // form feed\n [0x0d]: true, // carriage return\n [0x20]: true, // space\n};\n\nconst breakable: {\n [_: number]: boolean;\n} = {\n [0x0a]: true, // newline\n [0x20]: true, // space\n [0x26]: true, // ampersand\n [0x28]: true, // left parenthesis\n [0x29]: true, // right parenthesis\n [0x2b]: true, // plus sign\n [0x2d]: true, // hyphen-minus\n [0x2f]: true, // solidus\n [0xad]: true, // soft hyphen\n [0xb7]: true, // middle dot\n [0x200b]: true, // zero-width space\n [0x2010]: true, // hyphen\n [0x2013]: true, // en dash\n [0x2027]: true // interpunct\n // Many other characters may be reasonable breakpoints\n // Consider \"neutral orientation\" characters at scriptDetection.charHasNeutralVerticalOrientation\n // See https://github.com/mapbox/mapbox-gl-js/issues/3658\n};\n\nfunction getGlyphAdvance(\n codePoint: number,\n section: SectionOptions,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n spacing: number,\n layoutTextSize: number\n): number {\n if (!section.imageName) {\n const positions = glyphMap[section.fontStack];\n const glyph = positions && positions[codePoint];\n if (!glyph) return 0;\n return glyph.metrics.advance * section.scale + spacing;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) return 0;\n return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing;\n }\n}\n\nfunction determineAverageLineWidth(logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n layoutTextSize: number) {\n let totalWidth = 0;\n\n for (let index = 0; index < logicalInput.length(); index++) {\n const section = logicalInput.getSection(index);\n totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize);\n }\n\n const lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth));\n return totalWidth / lineCount;\n}\n\nfunction calculateBadness(lineWidth: number,\n targetWidth: number,\n penalty: number,\n isLastBreak: boolean) {\n const raggedness = Math.pow(lineWidth - targetWidth, 2);\n if (isLastBreak) {\n // Favor finals lines shorter than average over longer than average\n if (lineWidth < targetWidth) {\n return raggedness / 2;\n } else {\n return raggedness * 2;\n }\n }\n\n return raggedness + Math.abs(penalty) * penalty;\n}\n\nfunction calculatePenalty(codePoint: number, nextCodePoint: number, penalizableIdeographicBreak: boolean) {\n let penalty = 0;\n // Force break on newline\n if (codePoint === 0x0a) {\n penalty -= 10000;\n }\n // Penalize breaks between characters that allow ideographic breaking because\n // they are less preferable than breaks at spaces (or zero width spaces).\n if (penalizableIdeographicBreak) {\n penalty += 150;\n }\n\n // Penalize open parenthesis at end of line\n if (codePoint === 0x28 || codePoint === 0xff08) {\n penalty += 50;\n }\n\n // Penalize close parenthesis at beginning of line\n if (nextCodePoint === 0x29 || nextCodePoint === 0xff09) {\n penalty += 50;\n }\n return penalty;\n}\n\ntype Break = {\n index: number;\n x: number;\n priorBreak: Break;\n badness: number;\n};\n\nfunction evaluateBreak(\n breakIndex: number,\n breakX: number,\n targetWidth: number,\n potentialBreaks: Array,\n penalty: number,\n isLastBreak: boolean\n): Break {\n // We could skip evaluating breaks where the line length (breakX - priorBreak.x) > maxWidth\n // ...but in fact we allow lines longer than maxWidth (if there's no break points)\n // ...and when targetWidth and maxWidth are close, strictly enforcing maxWidth can give\n // more lopsided results.\n\n let bestPriorBreak: Break = null;\n let bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak);\n\n for (const potentialBreak of potentialBreaks) {\n const lineWidth = breakX - potentialBreak.x;\n const breakBadness =\n calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness;\n if (breakBadness <= bestBreakBadness) {\n bestPriorBreak = potentialBreak;\n bestBreakBadness = breakBadness;\n }\n }\n\n return {\n index: breakIndex,\n x: breakX,\n priorBreak: bestPriorBreak,\n badness: bestBreakBadness\n };\n}\n\nfunction leastBadBreaks(lastLineBreak?: Break | null): Array {\n if (!lastLineBreak) {\n return [];\n }\n return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index);\n}\n\nfunction determineLineBreaks(\n logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n symbolPlacement: string,\n layoutTextSize: number\n): Array {\n if (symbolPlacement !== 'point')\n return [];\n\n if (!logicalInput)\n return [];\n\n const potentialLineBreaks = [];\n const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize);\n\n const hasServerSuggestedBreakpoints = logicalInput.text.indexOf('\\u200b') >= 0;\n\n let currentX = 0;\n\n for (let i = 0; i < logicalInput.length(); i++) {\n const section = logicalInput.getSection(i);\n const codePoint = logicalInput.getCharCode(i);\n if (!whitespace[codePoint]) currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize);\n\n // Ideographic characters, spaces, and word-breaking punctuation that often appear without\n // surrounding spaces.\n if ((i < logicalInput.length() - 1)) {\n const ideographicBreak = charAllowsIdeographicBreaking(codePoint);\n if (breakable[codePoint] || ideographicBreak || section.imageName) {\n\n potentialLineBreaks.push(\n evaluateBreak(\n i + 1,\n currentX,\n targetWidth,\n potentialLineBreaks,\n calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints),\n false));\n }\n }\n }\n\n return leastBadBreaks(\n evaluateBreak(\n logicalInput.length(),\n currentX,\n targetWidth,\n potentialLineBreaks,\n 0,\n true));\n}\n\nfunction getAnchorAlignment(anchor: SymbolAnchor) {\n let horizontalAlign = 0.5, verticalAlign = 0.5;\n\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n horizontalAlign = 1;\n break;\n case 'left':\n case 'top-left':\n case 'bottom-left':\n horizontalAlign = 0;\n break;\n }\n\n switch (anchor) {\n case 'bottom':\n case 'bottom-right':\n case 'bottom-left':\n verticalAlign = 1;\n break;\n case 'top':\n case 'top-right':\n case 'top-left':\n verticalAlign = 0;\n break;\n }\n\n return {horizontalAlign, verticalAlign};\n}\n\nfunction shapeLines(shaping: Shaping,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n lines: Array,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n spacing: number,\n allowVerticalPlacement: boolean,\n layoutTextSizeThisZoom: number) {\n\n let x = 0;\n let y = SHAPING_DEFAULT_OFFSET;\n\n let maxLineLength = 0;\n let maxLineHeight = 0;\n\n const justify =\n textJustify === 'right' ? 1 :\n textJustify === 'left' ? 0 : 0.5;\n\n let lineIndex = 0;\n for (const line of lines) {\n line.trim();\n\n const lineMaxScale = line.getMaxScale();\n const maxLineOffset = (lineMaxScale - 1) * ONE_EM;\n const positionedLine = {positionedGlyphs: [], lineOffset: 0};\n shaping.positionedLines[lineIndex] = positionedLine;\n const positionedGlyphs = positionedLine.positionedGlyphs;\n let lineOffset = 0.0;\n\n if (!line.length()) {\n y += lineHeight; // Still need a line feed after empty line\n ++lineIndex;\n continue;\n }\n\n for (let i = 0; i < line.length(); i++) {\n const section = line.getSection(i);\n const sectionIndex = line.getSectionIndex(i);\n const codePoint = line.getCharCode(i);\n let baselineOffset = 0.0;\n let metrics = null;\n let rect = null;\n let imageName = null;\n let verticalAdvance = ONE_EM;\n const vertical = !(writingMode === WritingMode.horizontal ||\n // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled.\n (!allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint)) ||\n // If vertical placement is enabled, don't verticalize glyphs that\n // are from complex text layout script, or whitespaces.\n (allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint))));\n\n if (!section.imageName) {\n const positions = glyphPositions[section.fontStack];\n const glyphPosition = positions && positions[codePoint];\n if (glyphPosition && glyphPosition.rect) {\n rect = glyphPosition.rect;\n metrics = glyphPosition.metrics;\n } else {\n const glyphs = glyphMap[section.fontStack];\n const glyph = glyphs && glyphs[codePoint];\n if (!glyph) continue;\n metrics = glyph.metrics;\n }\n\n // We don't know the baseline, but since we're laying out\n // at 24 points, we can calculate how much it will move when\n // we scale up or down.\n baselineOffset = (lineMaxScale - section.scale) * ONE_EM;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) continue;\n imageName = section.imageName;\n shaping.iconsInText = shaping.iconsInText || true;\n rect = imagePosition.paddedRect;\n const size = imagePosition.displaySize;\n // If needed, allow to set scale factor for an image using\n // alias \"image-scale\" that could be alias for \"font-scale\"\n // when FormattedSection is an image section.\n section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom;\n\n metrics = {width: size[0],\n height: size[1],\n left: IMAGE_PADDING,\n top: -GLYPH_PBF_BORDER,\n advance: vertical ? size[1] : size[0]};\n\n // Difference between one EM and an image size.\n // Aligns bottom of an image to a baseline level.\n const imageOffset = ONE_EM - size[1] * section.scale;\n baselineOffset = maxLineOffset + imageOffset;\n verticalAdvance = metrics.advance;\n\n // Difference between height of an image and one EM at max line scale.\n // Pushes current line down if an image size is over 1 EM at max line scale.\n const offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale :\n size[1] * section.scale - ONE_EM * lineMaxScale;\n if (offset > 0 && offset > lineOffset) {\n lineOffset = offset;\n }\n }\n\n if (!vertical) {\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += metrics.advance * section.scale + spacing;\n } else {\n shaping.verticalizable = true;\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += verticalAdvance * section.scale + spacing;\n }\n }\n\n // Only justify if we placed at least one glyph\n if (positionedGlyphs.length !== 0) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset);\n }\n\n x = 0;\n const currentLineHeight = lineHeight * lineMaxScale + lineOffset;\n positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset);\n y += currentLineHeight;\n maxLineHeight = Math.max(currentLineHeight, maxLineHeight);\n ++lineIndex;\n }\n\n // Calculate the bounding box and justify / align text block.\n const height = y - SHAPING_DEFAULT_OFFSET;\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(textAnchor);\n align(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length);\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top + height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\n// justify right = 1, left = 0, center = 0.5\nfunction justifyLine(positionedGlyphs: Array,\n start: number,\n end: number,\n justify: 1 | 0 | 0.5,\n lineOffset: number) {\n if (!justify && !lineOffset)\n return;\n\n const lastPositionedGlyph = positionedGlyphs[end];\n const lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale;\n const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;\n\n for (let j = start; j <= end; j++) {\n positionedGlyphs[j].x -= lineIndent;\n positionedGlyphs[j].y += lineOffset;\n }\n}\n\nfunction align(positionedLines: Array,\n justify: number,\n horizontalAlign: number,\n verticalAlign: number,\n maxLineLength: number,\n maxLineHeight: number,\n lineHeight: number,\n blockHeight: number,\n lineCount: number) {\n const shiftX = (justify - horizontalAlign) * maxLineLength;\n let shiftY = 0;\n\n if (maxLineHeight !== lineHeight) {\n shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET;\n } else {\n shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;\n }\n\n for (const line of positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n positionedGlyph.x += shiftX;\n positionedGlyph.y += shiftY;\n }\n }\n}\n\nexport type PositionedIcon = {\n image: ImagePosition;\n top: number;\n bottom: number;\n left: number;\n right: number;\n collisionPadding?: [number, number, number, number];\n};\n\nfunction shapeIcon(\n image: ImagePosition,\n iconOffset: [number, number],\n iconAnchor: SymbolAnchor\n): PositionedIcon {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(iconAnchor);\n const dx = iconOffset[0];\n const dy = iconOffset[1];\n const x1 = dx - image.displaySize[0] * horizontalAlign;\n const x2 = x1 + image.displaySize[0];\n const y1 = dy - image.displaySize[1] * verticalAlign;\n const y2 = y1 + image.displaySize[1];\n return {image, top: y1, bottom: y2, left: x1, right: x2};\n}\n\nfunction fitIconToText(\n shapedIcon: PositionedIcon,\n shapedText: Shaping,\n textFit: string,\n padding: [number, number, number, number],\n iconOffset: [number, number],\n fontScale: number\n): PositionedIcon {\n\n const image = shapedIcon.image;\n\n let collisionPadding;\n if (image.content) {\n const content = image.content;\n const pixelRatio = image.pixelRatio || 1;\n collisionPadding = [\n content[0] / pixelRatio,\n content[1] / pixelRatio,\n image.displaySize[0] - content[2] / pixelRatio,\n image.displaySize[1] - content[3] / pixelRatio\n ];\n }\n\n // We don't respect the icon-anchor, because icon-text-fit is set. Instead,\n // the icon will be centered on the text, then stretched in the given\n // dimensions.\n\n const textLeft = shapedText.left * fontScale;\n const textRight = shapedText.right * fontScale;\n\n let top, right, bottom, left;\n if (textFit === 'width' || textFit === 'both') {\n // Stretched horizontally to the text width\n left = iconOffset[0] + textLeft - padding[3];\n right = iconOffset[0] + textRight + padding[1];\n } else {\n // Centered on the text\n left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2;\n right = left + image.displaySize[0];\n }\n\n const textTop = shapedText.top * fontScale;\n const textBottom = shapedText.bottom * fontScale;\n if (textFit === 'height' || textFit === 'both') {\n // Stretched vertically to the text height\n top = iconOffset[1] + textTop - padding[0];\n bottom = iconOffset[1] + textBottom + padding[2];\n } else {\n // Centered on the text\n top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2;\n bottom = top + image.displaySize[1];\n }\n\n return {image, top, right, bottom, left, collisionPadding};\n}\n","import {Interpolate, interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {clamp} from '../util/util';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\n\nimport type {PropertyValue, PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport type {InterpolationType} from '@maplibre/maplibre-gl-style-spec';\n\nconst MAX_GLYPH_ICON_SIZE = 255;\nconst SIZE_PACK_FACTOR = 128;\nconst MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;\n\nexport {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR, MAX_GLYPH_ICON_SIZE, MAX_PACKED_SIZE};\n\nexport type SizeData = {\n kind: 'constant';\n layoutSize: number;\n} | {\n kind: 'source';\n} | {\n kind: 'camera';\n minZoom: number;\n maxZoom: number;\n minSize: number;\n maxSize: number;\n interpolationType: InterpolationType;\n} | {\n kind: 'composite';\n minZoom: number;\n maxZoom: number;\n interpolationType: InterpolationType;\n};\n\nexport type EvaluatedZoomSize = {uSizeT: number; uSize: number};\n\n// For {text,icon}-size, get the bucket-level data that will be needed by\n// the painter to set symbol-size-related uniforms\nfunction getSizeData(\n tileZoom: number,\n value: PropertyValue>\n): SizeData {\n const {expression} = value;\n\n if (expression.kind === 'constant') {\n const layoutSize = expression.evaluate(new EvaluationParameters(tileZoom + 1));\n return {kind: 'constant', layoutSize};\n\n } else if (expression.kind === 'source') {\n return {kind: 'source'};\n\n } else {\n const {zoomStops, interpolationType} = expression;\n\n // calculate covering zoom stops for zoom-dependent values\n let lower = 0;\n while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) lower++;\n lower = Math.max(0, lower - 1);\n let upper = lower;\n while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) upper++;\n upper = Math.min(zoomStops.length - 1, upper);\n\n const minZoom = zoomStops[lower];\n const maxZoom = zoomStops[upper];\n\n // We'd like to be able to use CameraExpression or CompositeExpression in these\n // return types rather than ExpressionSpecification, but the former are not\n // transferrable across Web Worker boundaries.\n if (expression.kind === 'composite') {\n return {kind: 'composite', minZoom, maxZoom, interpolationType};\n }\n\n // for camera functions, also save off the function values\n // evaluated at the covering zoom levels\n const minSize = expression.evaluate(new EvaluationParameters(minZoom));\n const maxSize = expression.evaluate(new EvaluationParameters(maxZoom));\n\n return {kind: 'camera', minZoom, maxZoom, minSize, maxSize, interpolationType};\n }\n}\n\nfunction evaluateSizeForFeature(sizeData: SizeData,\n {\n uSize,\n uSizeT\n }: {\n uSize: number;\n uSizeT: number;\n },\n {\n lowerSize,\n upperSize\n }: {\n lowerSize: number;\n upperSize: number;\n }): number {\n if (sizeData.kind === 'source') {\n return lowerSize / SIZE_PACK_FACTOR;\n } else if (sizeData.kind === 'composite') {\n return interpolates.number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT);\n }\n return uSize;\n}\n\nfunction evaluateSizeForZoom(sizeData: SizeData, zoom: number): EvaluatedZoomSize {\n let uSizeT = 0;\n let uSize = 0;\n\n if (sizeData.kind === 'constant') {\n uSize = sizeData.layoutSize;\n\n } else if (sizeData.kind !== 'source') {\n const {interpolationType, minZoom, maxZoom} = sizeData;\n\n // Even though we could get the exact value of the camera function\n // at z = tr.zoom, we intentionally do not: instead, we interpolate\n // between the camera function values at a pair of zoom stops covering\n // [tileZoom, tileZoom + 1] in order to be consistent with this\n // restriction on composite functions\n const t = !interpolationType ? 0 : clamp(\n Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1);\n\n if (sizeData.kind === 'camera') {\n uSize = interpolates.number(sizeData.minSize, sizeData.maxSize, t);\n } else {\n uSizeT = t;\n }\n }\n\n return {uSizeT, uSize};\n}\n","import {SymbolLayoutPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\nimport type {SymbolLayoutProps} from './symbol_style_layer_properties.g';\nimport {PossiblyEvaluated} from '../properties';\n\n/**\n * The overlap mode for properties like `icon-overlap`and `text-overlap`\n */\nexport type OverlapMode = 'never' | 'always' | 'cooperative';\n\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap', allowOverlapProp: 'icon-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'text-overlap', allowOverlapProp: 'text-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap' | 'text-overlap', allowOverlapProp: 'icon-allow-overlap' | 'text-allow-overlap'): OverlapMode {\n let result: OverlapMode = 'never';\n const overlap = layout.get(overlapProp);\n\n if (overlap) {\n // if -overlap is set, use it\n result = overlap;\n } else if (layout.get(allowOverlapProp)) {\n // fall back to -allow-overlap, with false='never', true='always'\n result = 'always';\n }\n\n return result;\n}\n","import {\n symbolLayoutAttributes,\n collisionVertexAttributes,\n collisionBoxLayout,\n dynamicLayoutAttributes,\n} from './symbol_attributes';\n\nimport {SymbolLayoutArray,\n SymbolDynamicLayoutArray,\n SymbolOpacityArray,\n CollisionBoxLayoutArray,\n CollisionVertexArray,\n PlacedSymbolArray,\n SymbolInstanceArray,\n GlyphOffsetArray,\n SymbolLineVertexArray,\n TextAnchorOffsetArray\n} from '../array_types.g';\n\nimport Point from '@mapbox/point-geometry';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray, LineIndexArray} from '../index_array_type';\nimport {transformText} from '../../symbol/transform_text';\nimport {mergeLines} from '../../symbol/merge_lines';\nimport {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';\nimport {WritingMode} from '../../symbol/shaping';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {verticalizedCharacterMap} from '../../util/verticalize_punctuation';\nimport {Anchor} from '../../symbol/anchor';\nimport {getSizeData, MAX_PACKED_SIZE} from '../../symbol/symbol_size';\n\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\nimport {Formatted, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';\nimport {mat4} from 'gl-matrix';\nimport {getOverlapMode} from '../../style/style_layer/overlap_mode';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types.g';\nimport type {StructArray, StructArrayMember, ViewType} from '../../util/struct_array';\nimport type {SymbolStyleLayer} from '../../style/style_layer/symbol_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {SymbolQuad} from '../../symbol/quads';\nimport type {SizeData} from '../../symbol/symbol_size';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type SingleCollisionBox = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n anchorPointX: number;\n anchorPointY: number;\n};\n\nexport type CollisionArrays = {\n textBox?: SingleCollisionBox;\n verticalTextBox?: SingleCollisionBox;\n iconBox?: SingleCollisionBox;\n verticalIconBox?: SingleCollisionBox;\n textFeatureIndex?: number;\n verticalTextFeatureIndex?: number;\n iconFeatureIndex?: number;\n verticalIconFeatureIndex?: number;\n};\n\nexport type SymbolFeature = {\n sortKey: number | void;\n text: Formatted | void;\n icon: ResolvedImage;\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 'Unknown' | 'Point' | 'LineString' | 'Polygon';\n id?: any;\n};\n\nexport type SortKeyRange = {\n sortKey: number;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n};\n\n// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them\n// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph\n// 7 bits are for the current opacity, and the lowest bit is the target opacity\n\n// actually defined in symbol_attributes.js\n// const placementOpacityAttributes = [\n// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }\n// ];\nconst shaderOpacityAttributes = [\n {name: 'a_fade_opacity', components: 1, type: 'Uint8' as ViewType, offset: 0}\n];\n\nfunction addVertex(\n array: StructArray,\n anchorX: number,\n anchorY: number,\n ox: number,\n oy: number,\n tx: number,\n ty: number,\n sizeVertex: number,\n isSDF: boolean,\n pixelOffsetX: number,\n pixelOffsetY: number,\n minFontScaleX: number,\n minFontScaleY: number\n) {\n const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;\n const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;\n array.emplaceBack(\n // a_pos_offset\n anchorX,\n anchorY,\n Math.round(ox * 32),\n Math.round(oy * 32),\n\n // a_data\n tx, // x coordinate of symbol on glyph atlas texture\n ty, // y coordinate of symbol on glyph atlas texture\n (aSizeX << 1) + (isSDF ? 1 : 0),\n aSizeY,\n pixelOffsetX * 16,\n pixelOffsetY * 16,\n minFontScaleX * 256,\n minFontScaleY * 256\n );\n}\n\nfunction addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) {\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n}\n\nfunction containsRTLText(formattedText: Formatted): boolean {\n for (const section of formattedText.sections) {\n if (stringContainsRTLText(section.text)) {\n return true;\n }\n }\n return false;\n}\n\nexport class SymbolBuffers {\n layoutVertexArray: SymbolLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n\n dynamicLayoutVertexArray: SymbolDynamicLayoutArray;\n dynamicLayoutVertexBuffer: VertexBuffer;\n\n opacityVertexArray: SymbolOpacityArray;\n opacityVertexBuffer: VertexBuffer;\n hasVisibleVertices: boolean;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n placedSymbolArray: PlacedSymbolArray;\n\n constructor(programConfigurations: ProgramConfigurationSet) {\n this.layoutVertexArray = new SymbolLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = programConfigurations;\n this.segments = new SegmentVector();\n this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();\n this.opacityVertexArray = new SymbolOpacityArray();\n this.hasVisibleVertices = false;\n this.placedSymbolArray = new PlacedSymbolArray();\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 &&\n this.indexArray.length === 0 &&\n this.dynamicLayoutVertexArray.length === 0 &&\n this.opacityVertexArray.length === 0;\n }\n\n upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) {\n if (this.isEmpty()) {\n return;\n }\n\n if (upload) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);\n this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);\n this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);\n this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);\n // This is a performance hack so that we can write to opacityVertexArray with uint32s\n // even though the shaders read uint8s\n this.opacityVertexBuffer.itemSize = 1;\n }\n if (upload || update) {\n this.programConfigurations.upload(context);\n }\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.dynamicLayoutVertexBuffer.destroy();\n this.opacityVertexBuffer.destroy();\n }\n}\n\nregister('SymbolBuffers', SymbolBuffers);\n\nclass CollisionBuffers {\n layoutVertexArray: StructArray;\n layoutAttributes: Array;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray | LineIndexArray;\n indexBuffer: IndexBuffer;\n\n segments: SegmentVector;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n constructor(LayoutArray: {\n new (...args: any): StructArray;\n },\n layoutAttributes: Array,\n IndexArray: {\n new (...args: any): TriangleIndexArray | LineIndexArray;\n }) {\n this.layoutVertexArray = new LayoutArray();\n this.layoutAttributes = layoutAttributes;\n this.indexArray = new IndexArray();\n this.segments = new SegmentVector();\n this.collisionVertexArray = new CollisionVertexArray();\n }\n\n upload(context: Context) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.segments.destroy();\n this.collisionVertexBuffer.destroy();\n }\n}\n\nregister('CollisionBuffers', CollisionBuffers);\n\n/**\n * @internal\n * Unlike other buckets, which simply implement #addFeature with type-specific\n * logic for (essentially) triangulating feature geometries, SymbolBucket\n * requires specialized behavior:\n *\n * 1. WorkerTile#parse(), the logical owner of the bucket creation process,\n * calls SymbolBucket#populate(), which resolves text and icon tokens on\n * each feature, adds each glyphs and symbols needed to the passed-in\n * collections options.glyphDependencies and options.iconDependencies, and\n * stores the feature data for use in subsequent step (this.features).\n *\n * 2. WorkerTile asynchronously requests from the main thread all of the glyphs\n * and icons needed (by this bucket and any others). When glyphs and icons\n * have been received, the WorkerTile creates a CollisionIndex and invokes:\n *\n * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and\n * layout on a Symbol Bucket. This step populates:\n * `this.symbolInstances`: metadata on generated symbols\n * `this.collisionBoxArray`: collision data for use by foreground\n * `this.text`: SymbolBuffers for text symbols\n * `this.icons`: SymbolBuffers for icons\n * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes\n * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes\n * The results are sent to the foreground for rendering\n *\n * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,\n * and uses the CollisionIndex along with current camera settings to determine\n * which symbols can actually show on the map. Collided symbols are hidden\n * using a dynamic \"OpacityVertexArray\".\n */\nexport class SymbolBucket implements Bucket {\n static MAX_GLYPHS: number;\n static addDynamicAttributes: typeof addDynamicAttributes;\n\n collisionBoxArray: CollisionBoxArray;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n index: number;\n sdfIcons: boolean;\n iconsInText: boolean;\n iconsNeedLinear: boolean;\n bucketInstanceId: number;\n justReloaded: boolean;\n hasPattern: boolean;\n\n textSizeData: SizeData;\n iconSizeData: SizeData;\n\n glyphOffsetArray: GlyphOffsetArray;\n lineVertexArray: SymbolLineVertexArray;\n features: Array;\n symbolInstances: SymbolInstanceArray;\n textAnchorOffsets: TextAnchorOffsetArray;\n collisionArrays: Array;\n sortKeyRanges: Array;\n pixelRatio: number;\n tilePixelRatio: number;\n compareText: {[_: string]: Array};\n fadeStartTime: number;\n sortFeaturesByKey: boolean;\n sortFeaturesByY: boolean;\n canOverlap: boolean;\n sortedAngle: number;\n featureSortOrder: Array;\n\n collisionCircleArray: Array;\n placementInvProjMatrix: mat4;\n placementViewportMatrix: mat4;\n\n text: SymbolBuffers;\n icon: SymbolBuffers;\n textCollisionBox: CollisionBuffers;\n iconCollisionBox: CollisionBuffers;\n uploaded: boolean;\n sourceLayerIndex: number;\n sourceID: string;\n symbolInstanceIndexes: Array;\n writingModes: WritingMode[];\n allowVerticalPlacement: boolean;\n hasRTLText: boolean;\n\n constructor(options: BucketParameters) {\n this.collisionBoxArray = options.collisionBoxArray;\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.pixelRatio = options.pixelRatio;\n this.sourceLayerIndex = options.sourceLayerIndex;\n this.hasPattern = false;\n this.hasRTLText = false;\n this.sortKeyRanges = [];\n\n this.collisionCircleArray = [];\n this.placementInvProjMatrix = mat4.identity([] as any);\n this.placementViewportMatrix = mat4.identity([] as any);\n\n const layer = this.layers[0];\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);\n this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);\n\n const layout = this.layers[0].layout;\n const sortKey = layout.get('symbol-sort-key');\n const zOrder = layout.get('symbol-z-order');\n this.canOverlap =\n getOverlapMode(layout, 'text-overlap', 'text-allow-overlap') !== 'never' ||\n getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap') !== 'never' ||\n layout.get('text-ignore-placement') ||\n layout.get('icon-ignore-placement');\n this.sortFeaturesByKey = zOrder !== 'viewport-y' && !sortKey.isConstant();\n const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey);\n this.sortFeaturesByY = zOrderByViewportY && this.canOverlap;\n\n if (layout.get('symbol-placement') === 'point') {\n this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]);\n }\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n\n this.sourceID = options.sourceID;\n }\n\n createArrays() {\n this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property)));\n this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property)));\n\n this.glyphOffsetArray = new GlyphOffsetArray();\n this.lineVertexArray = new SymbolLineVertexArray();\n this.symbolInstances = new SymbolInstanceArray();\n this.textAnchorOffsets = new TextAnchorOffsetArray();\n }\n\n calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {\n for (let i = 0; i < text.length; i++) {\n stack[text.charCodeAt(i)] = true;\n if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {\n const verticalChar = verticalizedCharacterMap[text.charAt(i)];\n if (verticalChar) {\n stack[verticalChar.charCodeAt(0)] = true;\n }\n }\n }\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const layer = this.layers[0];\n const layout = layer.layout;\n\n const textFont = layout.get('text-font');\n const textField = layout.get('text-field');\n const iconImage = layout.get('icon-image');\n const hasText =\n (textField.value.kind !== 'constant' ||\n (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) ||\n textField.value.value.toString().length > 0) &&\n (textFont.value.kind !== 'constant' || textFont.value.value.length > 0);\n // we should always resolve the icon-image value if the property was defined in the style\n // this allows us to fire the styleimagemissing event if image evaluation returns null\n // the only way to distinguish between null returned from a coalesce statement with no valid images\n // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object\n const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;\n const symbolSortKey = layout.get('symbol-sort-key');\n\n this.features = [];\n\n if (!hasText && !hasIcon) {\n return;\n }\n\n const icons = options.iconDependencies;\n const stacks = options.glyphDependencies;\n const availableImages = options.availableImages;\n const globalProperties = new EvaluationParameters(this.zoom);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n\n const needGeometry = layer._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {\n continue;\n }\n\n if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature);\n\n let text: Formatted | void;\n if (hasText) {\n // Expression evaluation will automatically coerce to Formatted\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages);\n const formattedText = Formatted.factory(resolvedTokens);\n if (containsRTLText(formattedText)) {\n this.hasRTLText = true;\n }\n if (\n !this.hasRTLText || // non-rtl text so can proceed safely\n getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping\n this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text\n ) {\n text = transformText(formattedText, layer, evaluationFeature);\n }\n }\n\n let icon: ResolvedImage;\n if (hasIcon) {\n // Expression evaluation will automatically coerce to Image\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages);\n if (resolvedTokens instanceof ResolvedImage) {\n icon = resolvedTokens;\n } else {\n icon = ResolvedImage.fromString(resolvedTokens);\n }\n }\n\n if (!text && !icon) {\n continue;\n }\n const sortKey = this.sortFeaturesByKey ?\n symbolSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const symbolFeature: SymbolFeature = {\n id,\n text,\n icon,\n index,\n sourceLayerIndex,\n geometry: evaluationFeature.geometry,\n properties: feature.properties,\n type: vectorTileFeatureTypes[feature.type],\n sortKey\n };\n this.features.push(symbolFeature);\n\n if (icon) {\n icons[icon.name] = true;\n }\n\n if (text) {\n const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;\n for (const section of text.sections) {\n if (!section.image) {\n const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());\n const sectionFont = section.fontStack || fontStack;\n const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};\n this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);\n } else {\n // Add section image to the list of dependencies.\n icons[section.image.name] = true;\n }\n }\n }\n }\n\n if (layout.get('symbol-placement') === 'line') {\n // Merge adjacent lines with the same text to improve labelling.\n // It's better to place labels on one long line than on many short segments.\n this.features = mergeLines(this.features);\n }\n\n if (this.sortFeaturesByKey) {\n this.features.sort((a, b) => {\n // a.sortKey is always a number when sortFeaturesByKey is true\n return (a.sortKey as number) - (b.sortKey as number);\n });\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n }\n\n isEmpty() {\n // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created.\n // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary.\n return this.symbolInstances.length === 0 && !this.hasRTLText;\n }\n\n uploadPending() {\n return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded && this.hasDebugData()) {\n this.textCollisionBox.upload(context);\n this.iconCollisionBox.upload(context);\n }\n this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);\n this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);\n this.uploaded = true;\n }\n\n destroyDebugData() {\n this.textCollisionBox.destroy();\n this.iconCollisionBox.destroy();\n }\n\n destroy() {\n this.text.destroy();\n this.icon.destroy();\n\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n }\n\n addToLineVertexArray(anchor: Anchor, line: any) {\n const lineStartIndex = this.lineVertexArray.length;\n if (anchor.segment !== undefined) {\n let sumForwardLength = anchor.dist(line[anchor.segment + 1]);\n let sumBackwardLength = anchor.dist(line[anchor.segment]);\n const vertices = {};\n for (let i = anchor.segment + 1; i < line.length; i++) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};\n if (i < line.length - 1) {\n sumForwardLength += line[i + 1].dist(line[i]);\n }\n }\n for (let i = anchor.segment || 0; i >= 0; i--) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};\n if (i > 0) {\n sumBackwardLength += line[i - 1].dist(line[i]);\n }\n }\n for (let i = 0; i < line.length; i++) {\n const vertex = vertices[i];\n this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);\n }\n }\n return {\n lineStartIndex,\n lineLength: this.lineVertexArray.length - lineStartIndex\n };\n }\n\n addSymbols(arrays: SymbolBuffers,\n quads: Array,\n sizeVertex: any,\n lineOffset: [number, number],\n alongLine: boolean,\n feature: SymbolFeature,\n writingMode: WritingMode,\n labelAnchor: Anchor,\n lineStartIndex: number,\n lineLength: number,\n associatedIconIndex: number,\n canonical: CanonicalTileID) {\n const indexArray = arrays.indexArray;\n const layoutVertexArray = arrays.layoutVertexArray;\n\n const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey as number : undefined);\n const glyphOffsetArrayStart = this.glyphOffsetArray.length;\n const vertexStartIndex = segment.vertexLength;\n\n const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0;\n\n const sections = feature.text && feature.text.sections;\n\n for (let i = 0; i < quads.length; i++) {\n const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i];\n const index = segment.vertexLength;\n\n const y = glyphOffset[1];\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n\n addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);\n\n indexArray.emplaceBack(index, index + 1, index + 2);\n indexArray.emplaceBack(index + 1, index + 2, index + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n\n this.glyphOffsetArray.emplaceBack(glyphOffset[0]);\n\n if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {\n arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);\n }\n }\n\n arrays.placedSymbolArray.emplaceBack(\n labelAnchor.x, labelAnchor.y,\n glyphOffsetArrayStart,\n this.glyphOffsetArray.length - glyphOffsetArrayStart,\n vertexStartIndex,\n lineStartIndex,\n lineLength,\n labelAnchor.segment,\n sizeVertex ? sizeVertex[0] : 0,\n sizeVertex ? sizeVertex[1] : 0,\n lineOffset[0], lineOffset[1],\n writingMode,\n // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed\n 0,\n false as unknown as number,\n // The crossTileID is only filled/used on the foreground for dynamic text anchors\n 0,\n associatedIconIndex\n );\n }\n\n _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) {\n collisionVertexArray.emplaceBack(0, 0);\n return layoutVertexArray.emplaceBack(\n // pos\n point.x,\n point.y,\n // a_anchor_pos\n anchorX,\n anchorY,\n // extrude\n Math.round(extrude.x),\n Math.round(extrude.y));\n }\n\n addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance) {\n const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);\n const index = segment.vertexLength;\n\n const layoutVertexArray = arrays.layoutVertexArray;\n const collisionVertexArray = arrays.collisionVertexArray;\n\n const anchorX = symbolInstance.anchorX;\n const anchorY = symbolInstance.anchorY;\n\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2));\n\n segment.vertexLength += 4;\n\n const indexArray = arrays.indexArray as LineIndexArray;\n indexArray.emplaceBack(index, index + 1);\n indexArray.emplaceBack(index + 1, index + 2);\n indexArray.emplaceBack(index + 2, index + 3);\n indexArray.emplaceBack(index + 3, index);\n\n segment.primitiveLength += 4;\n }\n\n addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {\n for (let b = startIndex; b < endIndex; b++) {\n const box: CollisionBox = this.collisionBoxArray.get(b);\n const x1 = box.x1;\n const y1 = box.y1;\n const x2 = box.x2;\n const y2 = box.y2;\n\n this.addCollisionDebugVertices(x1, y1, x2, y2,\n isText ? this.textCollisionBox : this.iconCollisionBox,\n box.anchorPoint, symbolInstance);\n }\n }\n\n generateCollisionDebugBuffers() {\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n\n this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false);\n this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false);\n }\n }\n\n // These flat arrays are meant to be quicker to iterate over than the source\n // CollisionBoxArray\n _deserializeCollisionBoxesForSymbol(\n collisionBoxArray: CollisionBoxArray,\n textStartIndex: number,\n textEndIndex: number,\n verticalTextStartIndex: number,\n verticalTextEndIndex: number,\n iconStartIndex: number,\n iconEndIndex: number,\n verticalIconStartIndex: number,\n verticalIconEndIndex: number\n ): CollisionArrays {\n\n const collisionArrays = {} as CollisionArrays;\n for (let k = textStartIndex; k < textEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.textFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalTextFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = iconStartIndex; k < iconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.iconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalIconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n return collisionArrays;\n }\n\n deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) {\n this.collisionArrays = [];\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(\n collisionBoxArray,\n symbolInstance.textBoxStartIndex,\n symbolInstance.textBoxEndIndex,\n symbolInstance.verticalTextBoxStartIndex,\n symbolInstance.verticalTextBoxEndIndex,\n symbolInstance.iconBoxStartIndex,\n symbolInstance.iconBoxEndIndex,\n symbolInstance.verticalIconBoxStartIndex,\n symbolInstance.verticalIconBoxEndIndex\n ));\n }\n }\n\n hasTextData() {\n return this.text.segments.get().length > 0;\n }\n\n hasIconData() {\n return this.icon.segments.get().length > 0;\n }\n\n hasDebugData() {\n return this.textCollisionBox && this.iconCollisionBox;\n }\n\n hasTextCollisionBoxData() {\n return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;\n }\n\n hasIconCollisionBoxData() {\n return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;\n }\n\n addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) {\n const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);\n\n const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;\n for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {\n iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);\n iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);\n }\n }\n\n getSortedSymbolIndexes(angle: number) {\n if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) {\n return this.symbolInstanceIndexes;\n }\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n const rotatedYs = [];\n const featureIndexes = [];\n const result = [];\n\n for (let i = 0; i < this.symbolInstances.length; ++i) {\n result.push(i);\n const symbolInstance = this.symbolInstances.get(i);\n rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);\n featureIndexes.push(symbolInstance.featureIndex);\n }\n\n result.sort((aIndex, bIndex) => {\n return (rotatedYs[aIndex] - rotatedYs[bIndex]) ||\n (featureIndexes[bIndex] - featureIndexes[aIndex]);\n });\n\n return result;\n }\n\n addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) {\n const last = this.sortKeyRanges[this.sortKeyRanges.length - 1];\n if (last && last.sortKey === sortKey) {\n last.symbolInstanceEnd = symbolInstanceIndex + 1;\n } else {\n this.sortKeyRanges.push({\n sortKey,\n symbolInstanceStart: symbolInstanceIndex,\n symbolInstanceEnd: symbolInstanceIndex + 1\n });\n }\n }\n\n sortFeatures(angle: number) {\n if (!this.sortFeaturesByY) return;\n if (this.sortedAngle === angle) return;\n\n // The current approach to sorting doesn't sort across segments so don't try.\n // Sorting within segments separately seemed not to be worth the complexity.\n if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return;\n\n // If the symbols are allowed to overlap sort them by their vertical screen position.\n // The index array buffer is rewritten to reference the (unchanged) vertices in the\n // sorted order.\n\n // To avoid sorting the actual symbolInstance array we sort an array of indexes.\n this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);\n this.sortedAngle = angle;\n\n this.text.indexArray.clear();\n this.icon.indexArray.clear();\n\n this.featureSortOrder = [];\n\n for (const i of this.symbolInstanceIndexes) {\n const symbolInstance = this.symbolInstances.get(i);\n this.featureSortOrder.push(symbolInstance.featureIndex);\n\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach((index, i, array) => {\n // Only add a given index the first time it shows up,\n // to avoid duplicate opacity entries when multiple justifications\n // share the same glyphs.\n if (index >= 0 && array.indexOf(index) === i) {\n this.addIndicesForPlacedSymbol(this.text, index);\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex);\n }\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex);\n }\n }\n\n if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray);\n if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray);\n }\n}\n\nregister('SymbolBucket', SymbolBucket, {\n omit: ['layers', 'collisionBoxArray', 'features', 'compareText']\n});\n\n// this constant is based on the size of StructArray indexes used in a symbol\n// bucket--namely, glyphOffsetArrayStart\n// eg the max valid UInt16 is 65,535\n// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation\n// lineStartIndex and textBoxStartIndex could potentially be concerns\n// but we expect there to be many fewer boxes/lines than glyphs\nSymbolBucket.MAX_GLYPHS = 65535;\n\nSymbolBucket.addDynamicAttributes = addDynamicAttributes;\n\nexport {addDynamicAttributes};\n","import type {SymbolFeature} from '../data/bucket/symbol_bucket';\n\nexport function mergeLines(features: Array): Array {\n const leftIndex: {[_: string]: number} = {};\n const rightIndex: {[_: string]: number} = {};\n const mergedFeatures = [];\n let mergedIndex = 0;\n\n function add(k) {\n mergedFeatures.push(features[k]);\n mergedIndex++;\n }\n\n function mergeFromRight(leftKey: string, rightKey: string, geom) {\n const i = rightIndex[leftKey];\n delete rightIndex[leftKey];\n rightIndex[rightKey] = i;\n\n mergedFeatures[i].geometry[0].pop();\n mergedFeatures[i].geometry[0] = mergedFeatures[i].geometry[0].concat(geom[0]);\n return i;\n }\n\n function mergeFromLeft(leftKey: string, rightKey: string, geom) {\n const i = leftIndex[rightKey];\n delete leftIndex[rightKey];\n leftIndex[leftKey] = i;\n\n mergedFeatures[i].geometry[0].shift();\n mergedFeatures[i].geometry[0] = geom[0].concat(mergedFeatures[i].geometry[0]);\n return i;\n }\n\n function getKey(text, geom, onRight?) {\n const point = onRight ? geom[0][geom[0].length - 1] : geom[0][0];\n return `${text}:${point.x}:${point.y}`;\n }\n\n for (let k = 0; k < features.length; k++) {\n const feature = features[k];\n const geom = feature.geometry;\n const text = feature.text ? feature.text.toString() : null;\n\n if (!text) {\n add(k);\n continue;\n }\n\n const leftKey = getKey(text, geom),\n rightKey = getKey(text, geom, true);\n\n if ((leftKey in rightIndex) && (rightKey in leftIndex) && (rightIndex[leftKey] !== leftIndex[rightKey])) {\n // found lines with the same text adjacent to both ends of the current line, merge all three\n const j = mergeFromLeft(leftKey, rightKey, geom);\n const i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry);\n\n delete leftIndex[leftKey];\n delete rightIndex[rightKey];\n\n rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i;\n mergedFeatures[j].geometry = null;\n\n } else if (leftKey in rightIndex) {\n // found mergeable line adjacent to the start of the current line, merge\n mergeFromRight(leftKey, rightKey, geom);\n\n } else if (rightKey in leftIndex) {\n // found mergeable line adjacent to the end of the current line, merge\n mergeFromLeft(leftKey, rightKey, geom);\n\n } else {\n // no adjacent lines, add as a new item\n add(k);\n leftIndex[leftKey] = mergedIndex - 1;\n rightIndex[rightKey] = mergedIndex - 1;\n }\n }\n\n return mergedFeatures.filter((f) => f.geometry);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n ColorType\n } from '@maplibre/maplibre-gl-style-spec';\n \nexport type SymbolLayoutProps = {\n \"symbol-placement\": DataConstantProperty<\"point\" | \"line\" | \"line-center\">,\n \"symbol-spacing\": DataConstantProperty,\n \"symbol-avoid-edges\": DataConstantProperty,\n \"symbol-sort-key\": DataDrivenProperty,\n \"symbol-z-order\": DataConstantProperty<\"auto\" | \"viewport-y\" | \"source\">,\n \"icon-allow-overlap\": DataConstantProperty,\n \"icon-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"icon-ignore-placement\": DataConstantProperty,\n \"icon-optional\": DataConstantProperty,\n \"icon-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"icon-size\": DataDrivenProperty,\n \"icon-text-fit\": DataConstantProperty<\"none\" | \"width\" | \"height\" | \"both\">,\n \"icon-text-fit-padding\": DataConstantProperty<[number, number, number, number]>,\n \"icon-image\": DataDrivenProperty,\n \"icon-rotate\": DataDrivenProperty,\n \"icon-padding\": DataDrivenProperty,\n \"icon-keep-upright\": DataConstantProperty,\n \"icon-offset\": DataDrivenProperty<[number, number]>,\n \"icon-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\">,\n \"text-field\": DataDrivenProperty,\n \"text-font\": DataDrivenProperty>,\n \"text-size\": DataDrivenProperty,\n \"text-max-width\": DataDrivenProperty,\n \"text-line-height\": DataConstantProperty,\n \"text-letter-spacing\": DataDrivenProperty,\n \"text-justify\": DataDrivenProperty<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": DataDrivenProperty,\n \"text-variable-anchor\": DataConstantProperty>,\n \"text-variable-anchor-offset\": DataDrivenProperty,\n \"text-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": DataConstantProperty,\n \"text-writing-mode\": DataConstantProperty>,\n \"text-rotate\": DataDrivenProperty,\n \"text-padding\": DataConstantProperty,\n \"text-keep-upright\": DataConstantProperty,\n \"text-transform\": DataDrivenProperty<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": DataDrivenProperty<[number, number]>,\n \"text-allow-overlap\": DataConstantProperty,\n \"text-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"text-ignore-placement\": DataConstantProperty,\n \"text-optional\": DataConstantProperty,\n};\n\nexport type SymbolLayoutPropsPossiblyEvaluated = {\n \"symbol-placement\": \"point\" | \"line\" | \"line-center\",\n \"symbol-spacing\": number,\n \"symbol-avoid-edges\": boolean,\n \"symbol-sort-key\": PossiblyEvaluatedPropertyValue,\n \"symbol-z-order\": \"auto\" | \"viewport-y\" | \"source\",\n \"icon-allow-overlap\": boolean,\n \"icon-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"icon-ignore-placement\": boolean,\n \"icon-optional\": boolean,\n \"icon-rotation-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"icon-size\": PossiblyEvaluatedPropertyValue,\n \"icon-text-fit\": \"none\" | \"width\" | \"height\" | \"both\",\n \"icon-text-fit-padding\": [number, number, number, number],\n \"icon-image\": PossiblyEvaluatedPropertyValue,\n \"icon-rotate\": PossiblyEvaluatedPropertyValue,\n \"icon-padding\": PossiblyEvaluatedPropertyValue,\n \"icon-keep-upright\": boolean,\n \"icon-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"icon-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-rotation-alignment\": \"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\",\n \"text-field\": PossiblyEvaluatedPropertyValue,\n \"text-font\": PossiblyEvaluatedPropertyValue>,\n \"text-size\": PossiblyEvaluatedPropertyValue,\n \"text-max-width\": PossiblyEvaluatedPropertyValue,\n \"text-line-height\": number,\n \"text-letter-spacing\": PossiblyEvaluatedPropertyValue,\n \"text-justify\": PossiblyEvaluatedPropertyValue<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": PossiblyEvaluatedPropertyValue,\n \"text-variable-anchor\": Array<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-variable-anchor-offset\": PossiblyEvaluatedPropertyValue,\n \"text-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": number,\n \"text-writing-mode\": Array<\"horizontal\" | \"vertical\">,\n \"text-rotate\": PossiblyEvaluatedPropertyValue,\n \"text-padding\": number,\n \"text-keep-upright\": boolean,\n \"text-transform\": PossiblyEvaluatedPropertyValue<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"text-allow-overlap\": boolean,\n \"text-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"text-ignore-placement\": boolean,\n \"text-optional\": boolean,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"symbol-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-placement\"] as any as StylePropertySpecification),\n \"symbol-spacing\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-spacing\"] as any as StylePropertySpecification),\n \"symbol-avoid-edges\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-avoid-edges\"] as any as StylePropertySpecification),\n \"symbol-sort-key\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"symbol-sort-key\"] as any as StylePropertySpecification),\n \"symbol-z-order\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-z-order\"] as any as StylePropertySpecification),\n \"icon-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-allow-overlap\"] as any as StylePropertySpecification),\n \"icon-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-overlap\"] as any as StylePropertySpecification),\n \"icon-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-ignore-placement\"] as any as StylePropertySpecification),\n \"icon-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-optional\"] as any as StylePropertySpecification),\n \"icon-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-rotation-alignment\"] as any as StylePropertySpecification),\n \"icon-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-size\"] as any as StylePropertySpecification),\n \"icon-text-fit\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit\"] as any as StylePropertySpecification),\n \"icon-text-fit-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit-padding\"] as any as StylePropertySpecification),\n \"icon-image\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-image\"] as any as StylePropertySpecification),\n \"icon-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-rotate\"] as any as StylePropertySpecification),\n \"icon-padding\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-padding\"] as any as StylePropertySpecification),\n \"icon-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-keep-upright\"] as any as StylePropertySpecification),\n \"icon-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-offset\"] as any as StylePropertySpecification),\n \"icon-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-anchor\"] as any as StylePropertySpecification),\n \"icon-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-rotation-alignment\"] as any as StylePropertySpecification),\n \"text-field\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-field\"] as any as StylePropertySpecification),\n \"text-font\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-font\"] as any as StylePropertySpecification),\n \"text-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-size\"] as any as StylePropertySpecification),\n \"text-max-width\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-max-width\"] as any as StylePropertySpecification),\n \"text-line-height\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-line-height\"] as any as StylePropertySpecification),\n \"text-letter-spacing\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-letter-spacing\"] as any as StylePropertySpecification),\n \"text-justify\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-justify\"] as any as StylePropertySpecification),\n \"text-radial-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-radial-offset\"] as any as StylePropertySpecification),\n \"text-variable-anchor\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor\"] as any as StylePropertySpecification),\n \"text-variable-anchor-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor-offset\"] as any as StylePropertySpecification),\n \"text-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-anchor\"] as any as StylePropertySpecification),\n \"text-max-angle\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-max-angle\"] as any as StylePropertySpecification),\n \"text-writing-mode\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-writing-mode\"] as any as StylePropertySpecification),\n \"text-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-rotate\"] as any as StylePropertySpecification),\n \"text-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-padding\"] as any as StylePropertySpecification),\n \"text-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-keep-upright\"] as any as StylePropertySpecification),\n \"text-transform\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-transform\"] as any as StylePropertySpecification),\n \"text-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-offset\"] as any as StylePropertySpecification),\n \"text-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-allow-overlap\"] as any as StylePropertySpecification),\n \"text-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-overlap\"] as any as StylePropertySpecification),\n \"text-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-ignore-placement\"] as any as StylePropertySpecification),\n \"text-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-optional\"] as any as StylePropertySpecification),\n});\n\nexport type SymbolPaintProps = {\n \"icon-opacity\": DataDrivenProperty,\n \"icon-color\": DataDrivenProperty,\n \"icon-halo-color\": DataDrivenProperty,\n \"icon-halo-width\": DataDrivenProperty,\n \"icon-halo-blur\": DataDrivenProperty,\n \"icon-translate\": DataConstantProperty<[number, number]>,\n \"icon-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"text-opacity\": DataDrivenProperty,\n \"text-color\": DataDrivenProperty,\n \"text-halo-color\": DataDrivenProperty,\n \"text-halo-width\": DataDrivenProperty,\n \"text-halo-blur\": DataDrivenProperty,\n \"text-translate\": DataConstantProperty<[number, number]>,\n \"text-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n};\n\nexport type SymbolPaintPropsPossiblyEvaluated = {\n \"icon-opacity\": PossiblyEvaluatedPropertyValue,\n \"icon-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-width\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"icon-translate\": [number, number],\n \"icon-translate-anchor\": \"map\" | \"viewport\",\n \"text-opacity\": PossiblyEvaluatedPropertyValue,\n \"text-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-width\": PossiblyEvaluatedPropertyValue,\n \"text-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"text-translate\": [number, number],\n \"text-translate-anchor\": \"map\" | \"viewport\",\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"icon-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-opacity\"] as any as StylePropertySpecification),\n \"icon-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-color\"] as any as StylePropertySpecification),\n \"icon-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-color\"] as any as StylePropertySpecification),\n \"icon-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-width\"] as any as StylePropertySpecification),\n \"icon-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-blur\"] as any as StylePropertySpecification),\n \"icon-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate\"] as any as StylePropertySpecification),\n \"icon-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate-anchor\"] as any as StylePropertySpecification),\n \"text-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-opacity\"] as any as StylePropertySpecification),\n \"text-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-color\"] as any as StylePropertySpecification, { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }),\n \"text-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-color\"] as any as StylePropertySpecification),\n \"text-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-width\"] as any as StylePropertySpecification),\n \"text-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-blur\"] as any as StylePropertySpecification),\n \"text-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate\"] as any as StylePropertySpecification),\n \"text-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate-anchor\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import type {Expression, EvaluationContext, Type, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {NullType} from '@maplibre/maplibre-gl-style-spec';\nimport {PossiblyEvaluatedPropertyValue} from './properties';\nimport {register} from '../util/web_worker_transfer';\n\n// This is an internal expression class. It is only used in GL JS and\n// has GL JS dependencies which can break the standalone style-spec module\nexport class FormatSectionOverride implements Expression {\n type: Type;\n defaultValue: PossiblyEvaluatedPropertyValue;\n\n constructor(defaultValue: PossiblyEvaluatedPropertyValue) {\n if (defaultValue.property.overrides === undefined) throw new Error('overrides must be provided to instantiate FormatSectionOverride class');\n this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType;\n this.defaultValue = defaultValue;\n }\n\n evaluate(ctx: EvaluationContext) {\n if (ctx.formattedSection) {\n const overrides = this.defaultValue.property.overrides;\n if (overrides && overrides.hasOverride(ctx.formattedSection)) {\n return overrides.getOverride(ctx.formattedSection);\n }\n }\n\n if (ctx.feature && ctx.featureState) {\n return this.defaultValue.evaluate(ctx.feature, ctx.featureState);\n }\n\n return this.defaultValue.property.specification.default;\n }\n\n eachChild(fn: (_: Expression) => void) {\n if (!this.defaultValue.isConstant()) {\n const expr: ZoomConstantExpression<'source'> = (this.defaultValue.value as any);\n fn(expr._styleExpression.expression);\n }\n }\n\n // Cannot be statically evaluated, as the output depends on the evaluation context.\n outputDefined() {\n return false;\n }\n\n serialize() {\n return null;\n }\n}\n\nregister('FormatSectionOverride', FormatSectionOverride, {omit: ['defaultValue']});\n","import {StyleLayer} from '../style_layer';\n\nimport {SymbolBucket, SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {resolveTokens} from '../../util/resolve_tokens';\nimport properties, {SymbolLayoutPropsPossiblyEvaluated, SymbolPaintPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\n\nimport {\n Transitionable,\n Transitioning,\n Layout,\n PossiblyEvaluated,\n PossiblyEvaluatedPropertyValue,\n PropertyValue\n} from '../properties';\n\nimport {\n isExpression,\n StyleExpression,\n ZoomConstantExpression,\n ZoomDependentExpression,\n FormattedType,\n typeOf,\n Formatted,\n FormatExpression,\n Literal} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BucketParameters} from '../../data/bucket';\nimport type {SymbolLayoutProps, SymbolPaintProps} from './symbol_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Expression, Feature, SourceExpression, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport {FormatSectionOverride} from '../format_section_override';\n\nexport class SymbolStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n if (this.layout.get('icon-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['icon-rotation-alignment'] = 'map';\n } else {\n this.layout._values['icon-rotation-alignment'] = 'viewport';\n }\n }\n\n if (this.layout.get('text-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['text-rotation-alignment'] = 'map';\n } else {\n this.layout._values['text-rotation-alignment'] = 'viewport';\n }\n }\n\n // If unspecified, `*-pitch-alignment` inherits `*-rotation-alignment`\n if (this.layout.get('text-pitch-alignment') === 'auto') {\n this.layout._values['text-pitch-alignment'] = this.layout.get('text-rotation-alignment') === 'map' ? 'map' : 'viewport';\n }\n if (this.layout.get('icon-pitch-alignment') === 'auto') {\n this.layout._values['icon-pitch-alignment'] = this.layout.get('icon-rotation-alignment');\n }\n\n if (this.layout.get('symbol-placement') === 'point') {\n const writingModes = this.layout.get('text-writing-mode');\n if (writingModes) {\n // remove duplicates, preserving order\n const deduped = [];\n for (const m of writingModes) {\n if (deduped.indexOf(m) < 0) deduped.push(m);\n }\n this.layout._values['text-writing-mode'] = deduped;\n } else {\n this.layout._values['text-writing-mode'] = ['horizontal'];\n }\n }\n\n this._setPaintOverrides();\n }\n\n getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array) {\n const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages);\n const unevaluated = this._unevaluatedLayout._values[name];\n if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) {\n return resolveTokens(feature.properties, value);\n }\n\n return value;\n }\n\n createBucket(parameters: BucketParameters) {\n return new SymbolBucket(parameters);\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n throw new Error('Should take a different path in FeatureIndex');\n }\n\n _setPaintOverrides() {\n for (const overridable of properties.paint.overridableProperties) {\n if (!SymbolStyleLayer.hasPaintOverride(this.layout, overridable)) {\n continue;\n }\n const overriden = this.paint.get(overridable as keyof SymbolPaintPropsPossiblyEvaluated) as PossiblyEvaluatedPropertyValue;\n const override = new FormatSectionOverride(overriden);\n const styleExpression = new StyleExpression(override, overriden.property.specification);\n let expression = null;\n if (overriden.value.kind === 'constant' || overriden.value.kind === 'source') {\n expression = new ZoomConstantExpression('source', styleExpression) as SourceExpression;\n } else {\n expression = new ZoomDependentExpression('composite',\n styleExpression,\n overriden.value.zoomStops);\n }\n this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property,\n expression,\n overriden.parameters);\n }\n }\n\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) {\n return false;\n }\n return SymbolStyleLayer.hasPaintOverride(this.layout, name);\n }\n\n static hasPaintOverride(layout: PossiblyEvaluated, propertyName: string): boolean {\n const textField = layout.get('text-field');\n const property = properties.paint.properties[propertyName];\n let hasOverrides = false;\n\n const checkSections = (sections) => {\n for (const section of sections) {\n if (property.overrides && property.overrides.hasOverride(section)) {\n hasOverrides = true;\n return;\n }\n }\n };\n\n if (textField.value.kind === 'constant' && textField.value.value instanceof Formatted) {\n checkSections(textField.value.value.sections);\n } else if (textField.value.kind === 'source') {\n\n const checkExpression = (expression: Expression) => {\n if (hasOverrides) return;\n\n if (expression instanceof Literal && typeOf(expression.value) === FormattedType) {\n const formatted: Formatted = (expression.value as any);\n checkSections(formatted.sections);\n } else if (expression instanceof FormatExpression) {\n checkSections(expression.sections);\n } else {\n expression.eachChild(checkExpression);\n }\n };\n\n const expr: ZoomConstantExpression<'source'> = (textField.value as any);\n if (expr._styleExpression) {\n checkExpression(expr._styleExpression.expression);\n }\n }\n\n return hasOverrides;\n }\n}\n\nexport type SymbolPadding = [number, number, number, number];\n\nexport function getIconPadding(layout: PossiblyEvaluated, feature: SymbolFeature, canonical: CanonicalTileID, pixelRatio = 1): SymbolPadding {\n // Support text-padding in addition to icon-padding? Unclear how to apply asymmetric text-padding to the radius for collision circles.\n const result = layout.get('icon-padding').evaluate(feature, {}, canonical);\n const values = result && result.values;\n\n return [\n values[0] * pixelRatio,\n values[1] * pixelRatio,\n values[2] * pixelRatio,\n values[3] * pixelRatio,\n ];\n}\n","/**\n * Replace tokens in a string template with values in an object\n *\n * @param properties - a key/value relationship between tokens and replacements\n * @param text - the template string\n * @returns the template with tokens replaced\n */\nexport function resolveTokens(\n properties: {\n readonly [x: string]: unknown;\n } | null,\n text: string\n): string {\n return text.replace(/{([^{}]+)}/g, (match, key: string) => {\n return properties && key in properties ? String(properties[key]) : '';\n });\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type BackgroundPaintProps = {\n \"background-color\": DataConstantProperty,\n \"background-pattern\": CrossFadedProperty,\n \"background-opacity\": DataConstantProperty,\n};\n\nexport type BackgroundPaintPropsPossiblyEvaluated = {\n \"background-color\": Color,\n \"background-pattern\": CrossFaded,\n \"background-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"background-color\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-color\"] as any as StylePropertySpecification),\n \"background-pattern\": new CrossFadedProperty(styleSpec[\"paint_background\"][\"background-pattern\"] as any as StylePropertySpecification),\n \"background-opacity\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {BackgroundPaintProps} from './background_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class BackgroundStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type RasterPaintProps = {\n \"raster-opacity\": DataConstantProperty,\n \"raster-hue-rotate\": DataConstantProperty,\n \"raster-brightness-min\": DataConstantProperty,\n \"raster-brightness-max\": DataConstantProperty,\n \"raster-saturation\": DataConstantProperty,\n \"raster-contrast\": DataConstantProperty,\n \"raster-resampling\": DataConstantProperty<\"linear\" | \"nearest\">,\n \"raster-fade-duration\": DataConstantProperty,\n};\n\nexport type RasterPaintPropsPossiblyEvaluated = {\n \"raster-opacity\": number,\n \"raster-hue-rotate\": number,\n \"raster-brightness-min\": number,\n \"raster-brightness-max\": number,\n \"raster-saturation\": number,\n \"raster-contrast\": number,\n \"raster-resampling\": \"linear\" | \"nearest\",\n \"raster-fade-duration\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"raster-opacity\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-opacity\"] as any as StylePropertySpecification),\n \"raster-hue-rotate\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-hue-rotate\"] as any as StylePropertySpecification),\n \"raster-brightness-min\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-min\"] as any as StylePropertySpecification),\n \"raster-brightness-max\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-max\"] as any as StylePropertySpecification),\n \"raster-saturation\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-saturation\"] as any as StylePropertySpecification),\n \"raster-contrast\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-contrast\"] as any as StylePropertySpecification),\n \"raster-resampling\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-resampling\"] as any as StylePropertySpecification),\n \"raster-fade-duration\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-fade-duration\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {RasterPaintPropsPossiblyEvaluated} from './raster_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {RasterPaintProps} from './raster_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class RasterStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","import {StyleLayer} from '../style_layer';\nimport type {Map} from '../../ui/map';\nimport {mat4} from 'gl-matrix';\nimport {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * @param gl - The map's gl context.\n * @param matrix - The map's camera matrix. It projects spherical mercator\n * coordinates to gl coordinates. The spherical mercator coordinate `[0, 0]` represents the\n * top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When\n * the `renderingMode` is `\"3d\"`, the z coordinate is conformal. A box with identical x, y, and z\n * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate.fromLngLat}\n * can be used to project a `LngLat` to a mercator coordinate.\n */\ntype CustomRenderMethod = (gl: WebGLRenderingContext|WebGL2RenderingContext, matrix: mat4) => void;\n\n/**\n * Interface for custom style layers. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Custom layers allow a user to render directly into the map's GL context using the map's camera.\n * These layers can be added between any regular layers using {@link Map#addLayer}.\n *\n * Custom layers must have a unique `id` and must have the `type` of `\"custom\"`.\n * They must implement `render` and may implement `prerender`, `onAdd` and `onRemove`.\n * They can trigger rendering using {@link Map#triggerRepaint}\n * and they should appropriately handle {@link MapContextEvent} with `webglcontextlost` and `webglcontextrestored`.\n *\n * The `renderingMode` property controls whether the layer is treated as a `\"2d\"` or `\"3d\"` map layer. Use:\n * - `\"renderingMode\": \"3d\"` to use the depth buffer and share it with other layers\n * - `\"renderingMode\": \"2d\"` to add a layer with no depth. If you need to use the depth buffer for a `\"2d\"` layer you must use an offscreen\n * framebuffer and {@link CustomLayerInterface#prerender}\n *\n * @example\n * Custom layer implemented as ES6 class\n * ```ts\n * class NullIslandLayer {\n * constructor() {\n * this.id = 'null-island';\n * this.type = 'custom';\n * this.renderingMode = '2d';\n * }\n *\n * onAdd(map, gl) {\n * const vertexSource = `\n * uniform mat4 u_matrix;\n * void main() {\n * gl_Position = u_matrix * vec4(0.5, 0.5, 0.0, 1.0);\n * gl_PointSize = 20.0;\n * }`;\n *\n * const fragmentSource = `\n * void main() {\n * fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n * }`;\n *\n * const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n * gl.shaderSource(vertexShader, vertexSource);\n * gl.compileShader(vertexShader);\n * const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n * gl.shaderSource(fragmentShader, fragmentSource);\n * gl.compileShader(fragmentShader);\n *\n * this.program = gl.createProgram();\n * gl.attachShader(this.program, vertexShader);\n * gl.attachShader(this.program, fragmentShader);\n * gl.linkProgram(this.program);\n * }\n *\n * render(gl, matrix) {\n * gl.useProgram(this.program);\n * gl.uniformMatrix4fv(gl.getUniformLocation(this.program, \"u_matrix\"), false, matrix);\n * gl.drawArrays(gl.POINTS, 0, 1);\n * }\n * }\n *\n * map.on('load', function() {\n * map.addLayer(new NullIslandLayer());\n * });\n * ```\n */\nexport interface CustomLayerInterface {\n /**\n * A unique layer id.\n */\n id: string;\n /**\n * The layer's type. Must be `\"custom\"`.\n */\n type: 'custom';\n /**\n * Either `\"2d\"` or `\"3d\"`. Defaults to `\"2d\"`.\n */\n renderingMode?: '2d' | '3d';\n /**\n * Called during a render frame allowing the layer to draw into the GL context.\n *\n * The layer can assume blending and depth state is set to allow the layer to properly\n * blend and clip other layers. The layer cannot make any other assumptions about the\n * current GL state.\n *\n * If the layer needs to render to a texture, it should implement the `prerender` method\n * to do this and only use the `render` method for drawing directly into the main framebuffer.\n *\n * The blend function is set to `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. This expects\n * colors to be provided in premultiplied alpha form where the `r`, `g` and `b` values are already\n * multiplied by the `a` value. If you are unable to provide colors in premultiplied form you\n * may want to change the blend function to\n * `gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`.\n */\n render: CustomRenderMethod;\n /**\n * Optional method called during a render frame to allow a layer to prepare resources or render into a texture.\n *\n * The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering.\n */\n prerender?: CustomRenderMethod;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This\n * gives the layer a chance to initialize gl resources and register event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onAdd?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n /**\n * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This\n * gives the layer a chance to clean up gl resources and event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onRemove?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n}\n\nexport function validateCustomStyleLayer(layerObject: CustomLayerInterface) {\n const errors = [];\n const id = layerObject.id;\n\n if (id === undefined) {\n errors.push({\n message: `layers.${id}: missing required property \"id\"`\n });\n }\n\n if (layerObject.render === undefined) {\n errors.push({\n message: `layers.${id}: missing required method \"render\"`\n });\n }\n\n if (layerObject.renderingMode &&\n layerObject.renderingMode !== '2d' &&\n layerObject.renderingMode !== '3d') {\n errors.push({\n message: `layers.${id}: property \"renderingMode\" must be either \"2d\" or \"3d\"`\n });\n }\n\n return errors;\n}\n\nexport class CustomStyleLayer extends StyleLayer {\n\n implementation: CustomLayerInterface;\n\n constructor(implementation: CustomLayerInterface) {\n super(implementation, {});\n this.implementation = implementation;\n }\n\n is3D() {\n return this.implementation.renderingMode === '3d';\n }\n\n hasOffscreenPass() {\n return this.implementation.prerender !== undefined;\n }\n\n recalculate() {}\n updateTransitions() {}\n hasTransition() { return false; }\n\n serialize(): LayerSpecification {\n throw new Error('Custom layers cannot be serialized');\n }\n\n onAdd = (map: Map) => {\n if (this.implementation.onAdd) {\n this.implementation.onAdd(map, map.painter.context.gl);\n }\n };\n\n onRemove = (map: Map) => {\n if (this.implementation.onRemove) {\n this.implementation.onRemove(map, map.painter.context.gl);\n }\n };\n}\n","import {CircleStyleLayer} from './style_layer/circle_style_layer';\nimport {HeatmapStyleLayer} from './style_layer/heatmap_style_layer';\nimport {HillshadeStyleLayer} from './style_layer/hillshade_style_layer';\nimport {FillStyleLayer} from './style_layer/fill_style_layer';\nimport {FillExtrusionStyleLayer} from './style_layer/fill_extrusion_style_layer';\nimport {LineStyleLayer} from './style_layer/line_style_layer';\nimport {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport {BackgroundStyleLayer} from './style_layer/background_style_layer';\nimport {RasterStyleLayer} from './style_layer/raster_style_layer';\nimport {CustomStyleLayer, type CustomLayerInterface} from './style_layer/custom_style_layer';\n\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) {\n if (layer.type === 'custom') {\n return new CustomStyleLayer(layer);\n }\n switch (layer.type) {\n case 'background':\n return new BackgroundStyleLayer(layer);\n case 'circle':\n return new CircleStyleLayer(layer);\n case 'fill':\n return new FillStyleLayer(layer);\n case 'fill-extrusion':\n return new FillExtrusionStyleLayer(layer);\n case 'heatmap':\n return new HeatmapStyleLayer(layer);\n case 'hillshade':\n return new HillshadeStyleLayer(layer);\n case 'line':\n return new LineStyleLayer(layer);\n case 'raster':\n return new RasterStyleLayer(layer);\n case 'symbol':\n return new SymbolStyleLayer(layer);\n }\n}\n\n","import {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * Takes a SpriteSpecification value and returns it in its array form. If `undefined` is passed as an input value, an\n * empty array is returned.\n * duplicated entries with identical id/url will be removed in returned array\n * @param sprite - optional sprite to coerce\n * @returns an empty array in case `undefined` is passed; id-url pairs otherwise\n */\nexport function coerceSpriteToArray(sprite?: SpriteSpecification): {id: string; url: string}[] {\n const resultArray: {id: string; url: string}[] = [];\n\n if (typeof sprite === 'string') {\n resultArray.push({id: 'default', url: sprite});\n } else if (sprite && sprite.length > 0) {\n const dedupArray: string[] = [];\n for (const {id, url} of sprite) {\n const key = `${id}${url}`;\n if (dedupArray.indexOf(key) === -1) {\n dedupArray.push(key);\n resultArray.push({id, url});\n }\n }\n }\n\n return resultArray;\n\n}\n","import {getJSON} from '../util/ajax';\nimport {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\n\nimport {browser} from '../util/browser';\nimport {coerceSpriteToArray} from '../util/style';\n\nimport type {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {StyleImage} from './style_image';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\nexport function loadSprite(\n originalSprite: SpriteSpecification,\n requestManager: RequestManager,\n pixelRatio: number,\n callback: Callback<{[spriteName: string]: {[id: string]: StyleImage}}>\n): Cancelable {\n const spriteArray = coerceSpriteToArray(originalSprite);\n const spriteArrayLength = spriteArray.length;\n const format = pixelRatio > 1 ? '@2x' : '';\n\n const combinedRequestsMap: {[requestKey: string]: Cancelable} = {};\n const jsonsMap: {[id: string]: any} = {};\n const imagesMap: {[id: string]: (HTMLImageElement | ImageBitmap)} = {};\n\n for (const {id, url} of spriteArray) {\n const jsonRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.json'), ResourceType.SpriteJSON);\n const jsonRequestKey = `${id}_${jsonRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique\n combinedRequestsMap[jsonRequestKey] = getJSON(jsonRequestParameters, (err?: Error | null, data?: any | null) => {\n delete combinedRequestsMap[jsonRequestKey];\n jsonsMap[id] = data;\n doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength);\n });\n\n const imageRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.png'), ResourceType.SpriteImage);\n const imageRequestKey = `${id}_${imageRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique\n combinedRequestsMap[imageRequestKey] = ImageRequest.getImage(imageRequestParameters, (err, img) => {\n delete combinedRequestsMap[imageRequestKey];\n imagesMap[id] = img;\n doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength);\n });\n }\n\n return {\n cancel() {\n for (const requst of Object.values(combinedRequestsMap)) {\n requst.cancel();\n }\n }\n };\n}\n\n/**\n * @param callbackFunc - the callback function (both erro and success)\n * @param jsonsMap - JSON data map\n * @param imagesMap - image data map\n * @param err - error object\n * @param expectedResultCounter - number of expected JSON or Image results when everything is finished, respectively.\n */\nfunction doOnceCompleted(\n callbackFunc:Callback<{[spriteName: string]: {[id: string]: StyleImage}}>,\n jsonsMap:{[id: string]: any},\n imagesMap:{[id: string]: (HTMLImageElement | ImageBitmap)},\n err: Error,\n expectedResultCounter: number): void {\n\n if (err) {\n callbackFunc(err);\n return;\n }\n\n if (expectedResultCounter !== Object.values(jsonsMap).length || expectedResultCounter !== Object.values(imagesMap).length) {\n // not done yet, nothing to do\n return;\n }\n\n const result = {} as {[spriteName: string]: {[id: string]: StyleImage}};\n for (const spriteName in jsonsMap) {\n result[spriteName] = {};\n\n const context = browser.getImageCanvasContext(imagesMap[spriteName]);\n const json = jsonsMap[spriteName];\n\n for (const id in json) {\n const {width, height, x, y, sdf, pixelRatio, stretchX, stretchY, content} = json[id];\n const spriteData = {width, height, x, y, context};\n result[spriteName][id] = {data: null, pixelRatio, sdf, stretchX, stretchY, content, spriteData};\n }\n }\n\n callbackFunc(null, result);\n}\n","import type {Context} from '../gl/context';\nimport type {RGBAImage, AlphaImage} from '../util/image';\nimport {isImageBitmap} from '../util/util';\n\nexport type TextureFormat = WebGLRenderingContextBase['RGBA'] | WebGLRenderingContextBase['ALPHA'];\nexport type TextureFilter = WebGLRenderingContextBase['LINEAR'] | WebGLRenderingContextBase['LINEAR_MIPMAP_NEAREST'] | WebGLRenderingContextBase['NEAREST'];\nexport type TextureWrap = WebGLRenderingContextBase['REPEAT'] | WebGLRenderingContextBase['CLAMP_TO_EDGE'] | WebGLRenderingContextBase['MIRRORED_REPEAT'];\n\ntype EmptyImage = {\n width: number;\n height: number;\n data: null;\n};\n\ntype DataTextureImage = RGBAImage | AlphaImage | EmptyImage;\nexport type TextureImage = TexImageSource | DataTextureImage;\n\n/**\n * @internal\n * A `Texture` GL related object\n */\nexport class Texture {\n context: Context;\n size: [number, number];\n texture: WebGLTexture;\n format: TextureFormat;\n filter: TextureFilter;\n wrap: TextureWrap;\n useMipmap: boolean;\n\n constructor(context: Context, image: TextureImage, format: TextureFormat, options?: {\n premultiply?: boolean;\n useMipmap?: boolean;\n } | null) {\n this.context = context;\n this.format = format;\n this.texture = context.gl.createTexture();\n this.update(image, options);\n }\n\n update(image: TextureImage, options?: {\n premultiply?: boolean;\n useMipmap?: boolean;\n } | null, position?: {\n x: number;\n y: number;\n }) {\n const {width, height} = image as {width: number; height: number};\n const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position;\n const {context} = this;\n const {gl} = context;\n\n this.useMipmap = Boolean(options && options.useMipmap);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n context.pixelStoreUnpackFlipY.set(false);\n context.pixelStoreUnpack.set(1);\n context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl.RGBA && (!options || options.premultiply !== false));\n\n if (resize) {\n this.size = [width, height];\n\n if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image);\n } else {\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);\n }\n\n } else {\n const {x, y} = position || {x: 0, y: 0};\n if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image);\n } else {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);\n }\n }\n\n if (this.useMipmap && this.isSizePowerOfTwo()) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n }\n\n bind(filter: TextureFilter, wrap: TextureWrap, minFilter?: TextureFilter | null) {\n const {context} = this;\n const {gl} = context;\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n if (minFilter === gl.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) {\n minFilter = gl.LINEAR;\n }\n\n if (filter !== this.filter) {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || filter);\n this.filter = filter;\n }\n\n if (wrap !== this.wrap) {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);\n this.wrap = wrap;\n }\n }\n\n isSizePowerOfTwo() {\n return this.size[0] === this.size[1] && (Math.log(this.size[0]) / Math.LN2) % 1 === 0;\n }\n\n destroy() {\n const {gl} = this.context;\n gl.deleteTexture(this.texture);\n this.texture = null;\n }\n}\n","import {RGBAImage} from '../util/image';\n\nimport type {Map} from '../ui/map';\n\n/**\n * The sprite data\n */\nexport type SpriteOnDemandStyleImage = {\n width: number;\n height: number;\n x: number;\n y: number;\n context: CanvasRenderingContext2D;\n};\n\n/**\n * The style's image metadata\n */\nexport type StyleImageData = {\n data: RGBAImage;\n version?: number;\n hasRenderCallback?: boolean;\n userImage?: StyleImageInterface;\n spriteData?: SpriteOnDemandStyleImage;\n};\n\n/**\n * The style's image metadata\n */\nexport type StyleImageMetadata = {\n /**\n * The ratio of pixels in the image to physical pixels on the screen\n */\n pixelRatio: number;\n /**\n * Whether the image should be interpreted as an SDF image\n */\n sdf: boolean;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally.\n */\n stretchX?: Array<[number, number]>;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically.\n */\n stretchY?: Array<[number, number]>;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`.\n */\n content?: [number, number, number, number];\n};\n\n/**\n * the style's image, including data and metedata\n */\nexport type StyleImage = StyleImageData & StyleImageMetadata;\n\n/**\n * Interface for dynamically generated style images. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Images implementing this interface can be redrawn for every frame. They can be used to animate\n * icons and patterns or make them respond to user input. Style images can implement a\n * {@link StyleImageInterface#render} method. The method is called every frame and\n * can be used to update the image.\n *\n * @see [Add an animated icon to the map.](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/)\n *\n * @example\n * ```ts\n * let flashingSquare = {\n * width: 64,\n * height: 64,\n * data: new Uint8Array(64 * 64 * 4),\n *\n * onAdd: function(map) {\n * this.map = map;\n * },\n *\n * render: function() {\n * // keep repainting while the icon is on the map\n * this.map.triggerRepaint();\n *\n * // alternate between black and white based on the time\n * let value = Math.round(Date.now() / 1000) % 2 === 0 ? 255 : 0;\n *\n * // check if image needs to be changed\n * if (value !== this.previousValue) {\n * this.previousValue = value;\n *\n * let bytesPerPixel = 4;\n * for (let x = 0; x < this.width; x++) {\n * for (let y = 0; y < this.height; y++) {\n * let offset = (y * this.width + x) * bytesPerPixel;\n * this.data[offset + 0] = value;\n * this.data[offset + 1] = value;\n * this.data[offset + 2] = value;\n * this.data[offset + 3] = 255;\n * }\n * }\n *\n * // return true to indicate that the image changed\n * return true;\n * }\n * }\n * }\n *\n * map.addImage('flashing_square', flashingSquare);\n * ```\n */\n\nexport interface StyleImageInterface {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n /**\n * This method is called once before every frame where the icon will be used.\n * The method can optionally update the image's `data` member with a new image.\n *\n * If the method updates the image it must return `true` to commit the change.\n * If the method returns `false` or nothing the image is assumed to not have changed.\n *\n * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update\n * the image instead of implementing this method.\n *\n * @returns `true` if this method updated the image. `false` if the image was not changed.\n */\n render?: () => boolean;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addImage}.\n *\n * @param map - The Map this custom layer was just added to.\n */\n onAdd?: (map: Map, id: string) => void;\n /**\n * Optional method called when the icon is removed from the map with {@link Map#removeImage}.\n * This gives the image a chance to clean up resources and event listeners.\n */\n onRemove?: () => void;\n}\n\nexport function renderStyleImage(image: StyleImage) {\n const {userImage} = image;\n if (userImage && userImage.render) {\n const updated = userImage.render();\n if (updated) {\n image.data.replace(new Uint8Array(userImage.data.buffer));\n return true;\n }\n }\n return false;\n}\n","/* eslint-disable key-spacing */\nimport potpack from 'potpack';\n\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {RGBAImage} from '../util/image';\nimport {ImagePosition} from './image_atlas';\nimport {Texture} from './texture';\nimport {renderStyleImage} from '../style/style_image';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {Context} from '../gl/context';\nimport type {PotpackBox} from 'potpack';\nimport type {Callback} from '../types/callback';\n\ntype Pattern = {\n bin: PotpackBox;\n position: ImagePosition;\n};\n\n// When copied into the atlas texture, image data is padded by one pixel on each side. Icon\n// images are padded with fully transparent pixels, while pattern images are padded with a\n// copy of the image data wrapped from the opposite side. In both cases, this ensures the\n// correct behavior of GL_LINEAR texture sampling mode.\nconst padding = 1;\n\n/*\n ImageManager does three things:\n\n 1. Tracks requests for icon images from tile workers and sends responses when the requests are fulfilled.\n 2. Builds a texture atlas for pattern images.\n 3. Rerenders renderable images once per frame\n\n These are disparate responsibilities and should eventually be handled by different classes. When we implement\n data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time\n to refactor this.\n*/\nexport class ImageManager extends Evented {\n images: {[_: string]: StyleImage};\n updatedImages: {[_: string]: boolean};\n callbackDispatchedThisFrame: {[_: string]: boolean};\n loaded: boolean;\n requestors: Array<{\n ids: Array;\n callback: Callback<{[_: string]: StyleImage}>;\n }>;\n\n patterns: {[_: string]: Pattern};\n atlasImage: RGBAImage;\n atlasTexture: Texture;\n dirty: boolean;\n\n constructor() {\n super();\n this.images = {};\n this.updatedImages = {};\n this.callbackDispatchedThisFrame = {};\n this.loaded = false;\n this.requestors = [];\n\n this.patterns = {};\n this.atlasImage = new RGBAImage({width: 1, height: 1});\n this.dirty = true;\n }\n\n isLoaded() {\n return this.loaded;\n }\n\n setLoaded(loaded: boolean) {\n if (this.loaded === loaded) {\n return;\n }\n\n this.loaded = loaded;\n\n if (loaded) {\n for (const {ids, callback} of this.requestors) {\n this._notify(ids, callback);\n }\n this.requestors = [];\n }\n }\n\n getImage(id: string): StyleImage {\n const image = this.images[id];\n\n // Extract sprite image data on demand\n if (image && !image.data && image.spriteData) {\n const spriteData = image.spriteData;\n image.data = new RGBAImage({\n width: spriteData.width,\n height: spriteData.height\n }, spriteData.context.getImageData(\n spriteData.x,\n spriteData.y,\n spriteData.width,\n spriteData.height).data);\n image.spriteData = null;\n }\n\n return image;\n }\n\n addImage(id: string, image: StyleImage) {\n if (this.images[id]) throw new Error(`Image id ${id} already exist, use updateImage instead`);\n if (this._validate(id, image)) {\n this.images[id] = image;\n }\n }\n\n _validate(id: string, image: StyleImage) {\n let valid = true;\n const data = image.data || image.spriteData;\n if (!this._validateStretch(image.stretchX, data && data.width)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"stretchX\" value`)));\n valid = false;\n }\n if (!this._validateStretch(image.stretchY, data && data.height)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"stretchY\" value`)));\n valid = false;\n }\n if (!this._validateContent(image.content, image)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"content\" value`)));\n valid = false;\n }\n return valid;\n }\n\n _validateStretch(stretch: Array<[number, number]>, size: number) {\n if (!stretch) return true;\n let last = 0;\n for (const part of stretch) {\n if (part[0] < last || part[1] < part[0] || size < part[1]) return false;\n last = part[1];\n }\n return true;\n }\n\n _validateContent(content: [number, number, number, number], image: StyleImage) {\n if (!content) return true;\n if (content.length !== 4) return false;\n const spriteData = image.spriteData;\n const width = (spriteData && spriteData.width) || image.data.width;\n const height = (spriteData && spriteData.height) || image.data.height;\n if (content[0] < 0 || width < content[0]) return false;\n if (content[1] < 0 || height < content[1]) return false;\n if (content[2] < 0 || width < content[2]) return false;\n if (content[3] < 0 || height < content[3]) return false;\n if (content[2] < content[0]) return false;\n if (content[3] < content[1]) return false;\n return true;\n }\n\n updateImage(id: string, image: StyleImage, validate = true) {\n const oldImage = this.getImage(id);\n if (validate && (oldImage.data.width !== image.data.width || oldImage.data.height !== image.data.height)) {\n throw new Error(`size mismatch between old image (${oldImage.data.width}x${oldImage.data.height}) and new image (${image.data.width}x${image.data.height}).`);\n }\n image.version = oldImage.version + 1;\n this.images[id] = image;\n this.updatedImages[id] = true;\n }\n\n removeImage(id: string) {\n const image = this.images[id];\n delete this.images[id];\n delete this.patterns[id];\n\n if (image.userImage && image.userImage.onRemove) {\n image.userImage.onRemove();\n }\n }\n\n listImages(): Array {\n return Object.keys(this.images);\n }\n\n getImages(ids: Array, callback: Callback<{[_: string]: StyleImage}>) {\n // If the sprite has been loaded, or if all the icon dependencies are already present\n // (i.e. if they've been added via runtime styling), then notify the requestor immediately.\n // Otherwise, delay notification until the sprite is loaded. At that point, if any of the\n // dependencies are still unavailable, we'll just assume they are permanently missing.\n let hasAllDependencies = true;\n if (!this.isLoaded()) {\n for (const id of ids) {\n if (!this.images[id]) {\n hasAllDependencies = false;\n }\n }\n }\n if (this.isLoaded() || hasAllDependencies) {\n this._notify(ids, callback);\n } else {\n this.requestors.push({ids, callback});\n }\n }\n\n _notify(ids: Array, callback: Callback<{[_: string]: StyleImage}>) {\n const response = {};\n\n for (const id of ids) {\n let image = this.getImage(id);\n\n if (!image) {\n this.fire(new Event('styleimagemissing', {id}));\n //Try to acquire image again in case styleimagemissing has populated it\n image = this.getImage(id);\n }\n\n if (image) {\n // Clone the image so that our own copy of its ArrayBuffer doesn't get transferred.\n response[id] = {\n data: image.data.clone(),\n pixelRatio: image.pixelRatio,\n sdf: image.sdf,\n version: image.version,\n stretchX: image.stretchX,\n stretchY: image.stretchY,\n content: image.content,\n hasRenderCallback: Boolean(image.userImage && image.userImage.render)\n };\n } else {\n warnOnce(`Image \"${id}\" could not be loaded. Please make sure you have added the image with map.addImage() or a \"sprite\" property in your style. You can provide missing images by listening for the \"styleimagemissing\" map event.`);\n }\n }\n\n callback(null, response);\n }\n\n // Pattern stuff\n\n getPixelSize() {\n const {width, height} = this.atlasImage;\n return {width, height};\n }\n\n getPattern(id: string): ImagePosition {\n const pattern = this.patterns[id];\n\n const image = this.getImage(id);\n if (!image) {\n return null;\n }\n\n if (pattern && pattern.position.version === image.version) {\n return pattern.position;\n }\n\n if (!pattern) {\n const w = image.data.width + padding * 2;\n const h = image.data.height + padding * 2;\n const bin = {w, h, x: 0, y: 0};\n const position = new ImagePosition(bin, image);\n this.patterns[id] = {bin, position};\n } else {\n pattern.position.version = image.version;\n }\n\n this._updatePatternAtlas();\n\n return this.patterns[id].position;\n }\n\n bind(context: Context) {\n const gl = context.gl;\n if (!this.atlasTexture) {\n this.atlasTexture = new Texture(context, this.atlasImage, gl.RGBA);\n } else if (this.dirty) {\n this.atlasTexture.update(this.atlasImage);\n this.dirty = false;\n }\n\n this.atlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n _updatePatternAtlas() {\n const bins = [];\n for (const id in this.patterns) {\n bins.push(this.patterns[id].bin);\n }\n\n const {w, h} = potpack(bins);\n\n const dst = this.atlasImage;\n dst.resize({width: w || 1, height: h || 1});\n\n for (const id in this.patterns) {\n const {bin} = this.patterns[id];\n const x = bin.x + padding;\n const y = bin.y + padding;\n const src = this.getImage(id).data;\n const w = src.width;\n const h = src.height;\n\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y}, {width: w, height: h});\n\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src, dst, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src, dst, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.dirty = true;\n }\n\n beginFrame() {\n this.callbackDispatchedThisFrame = {};\n }\n\n dispatchRenderCallbacks(ids: Array) {\n for (const id of ids) {\n\n // the callback for the image was already dispatched for a different frame\n if (this.callbackDispatchedThisFrame[id]) continue;\n this.callbackDispatchedThisFrame[id] = true;\n\n const image = this.getImage(id);\n if (!image) warnOnce(`Image with ID: \"${id}\" was not found`);\n\n const updated = renderStyleImage(image);\n if (updated) {\n this.updateImage(id, image);\n }\n }\n }\n}\n","const INF = 1e20;\n\nexport default class TinySDF {\n constructor({\n fontSize = 24,\n buffer = 3,\n radius = 8,\n cutoff = 0.25,\n fontFamily = 'sans-serif',\n fontWeight = 'normal',\n fontStyle = 'normal'\n } = {}) {\n this.buffer = buffer;\n this.cutoff = cutoff;\n this.radius = radius;\n\n // make the canvas size big enough to both have the specified buffer around the glyph\n // for \"halo\", and account for some glyphs possibly being larger than their font size\n const size = this.size = fontSize + buffer * 4;\n\n const canvas = this._createCanvas(size);\n const ctx = this.ctx = canvas.getContext('2d', {willReadFrequently: true});\n ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;\n\n ctx.textBaseline = 'alphabetic';\n ctx.textAlign = 'left'; // Necessary so that RTL text doesn't have different alignment\n ctx.fillStyle = 'black';\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(size * size);\n this.gridInner = new Float64Array(size * size);\n this.f = new Float64Array(size);\n this.z = new Float64Array(size + 1);\n this.v = new Uint16Array(size);\n }\n\n _createCanvas(size) {\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = size;\n return canvas;\n }\n\n draw(char) {\n const {\n width: glyphAdvance,\n actualBoundingBoxAscent,\n actualBoundingBoxDescent,\n actualBoundingBoxLeft,\n actualBoundingBoxRight\n } = this.ctx.measureText(char);\n\n // The integer/pixel part of the top alignment is encoded in metrics.glyphTop\n // The remainder is implicitly encoded in the rasterization\n const glyphTop = Math.ceil(actualBoundingBoxAscent);\n const glyphLeft = 0;\n\n // If the glyph overflows the canvas size, it will be clipped at the bottom/right\n const glyphWidth = Math.max(0, Math.min(this.size - this.buffer, Math.ceil(actualBoundingBoxRight - actualBoundingBoxLeft)));\n const glyphHeight = Math.min(this.size - this.buffer, glyphTop + Math.ceil(actualBoundingBoxDescent));\n\n const width = glyphWidth + 2 * this.buffer;\n const height = glyphHeight + 2 * this.buffer;\n\n const len = Math.max(width * height, 0);\n const data = new Uint8ClampedArray(len);\n const glyph = {data, width, height, glyphWidth, glyphHeight, glyphTop, glyphLeft, glyphAdvance};\n if (glyphWidth === 0 || glyphHeight === 0) return glyph;\n\n const {ctx, buffer, gridInner, gridOuter} = this;\n ctx.clearRect(buffer, buffer, glyphWidth, glyphHeight);\n ctx.fillText(char, buffer, buffer + glyphTop);\n const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight);\n\n // Initialize grids outside the glyph range to alpha 0\n gridOuter.fill(INF, 0, len);\n gridInner.fill(0, 0, len);\n\n for (let y = 0; y < glyphHeight; y++) {\n for (let x = 0; x < glyphWidth; x++) {\n const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 255; // alpha value\n if (a === 0) continue; // empty pixels\n\n const j = (y + buffer) * width + x + buffer;\n\n if (a === 1) { // fully drawn pixels\n gridOuter[j] = 0;\n gridInner[j] = INF;\n\n } else { // aliased pixels\n const d = 0.5 - a;\n gridOuter[j] = d > 0 ? d * d : 0;\n gridInner[j] = d < 0 ? d * d : 0;\n }\n }\n }\n\n edt(gridOuter, 0, 0, width, height, width, this.f, this.v, this.z);\n edt(gridInner, buffer, buffer, glyphWidth, glyphHeight, width, this.f, this.v, this.z);\n\n for (let i = 0; i < len; i++) {\n const d = Math.sqrt(gridOuter[i]) - Math.sqrt(gridInner[i]);\n data[i] = Math.round(255 - 255 * (d / this.radius + this.cutoff));\n }\n\n return glyph;\n }\n}\n\n// 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nfunction edt(data, x0, y0, width, height, gridSize, f, v, z) {\n for (let x = x0; x < x0 + width; x++) edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z);\n for (let y = y0; y < y0 + height; y++) edt1d(data, y * gridSize + x0, 1, width, f, v, z);\n}\n\n// 1D squared distance transform\nfunction edt1d(grid, offset, stride, length, f, v, z) {\n v[0] = 0;\n z[0] = -INF;\n z[1] = INF;\n f[0] = grid[offset];\n\n for (let q = 1, k = 0, s = 0; q < length; q++) {\n f[q] = grid[offset + q * stride];\n const q2 = q * q;\n do {\n const r = v[k];\n s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2;\n } while (s <= z[k] && --k > -1);\n\n k++;\n v[k] = q;\n z[k] = s;\n z[k + 1] = INF;\n }\n\n for (let q = 0, k = 0; q < length; q++) {\n while (z[k + 1] < q) k++;\n const r = v[k];\n const qr = q - r;\n grid[offset + q * stride] = f[r] + qr * qr;\n }\n}\n","import {loadGlyphRange} from '../style/load_glyph_range';\n\nimport TinySDF from '@mapbox/tiny-sdf';\nimport {unicodeBlockLookup} from '../util/is_char_in_unicode_block';\nimport {asyncAll} from '../util/util';\nimport {AlphaImage} from '../util/image';\n\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\n\ntype Entry = {\n // null means we've requested the range, but the glyph wasn't included in the result.\n glyphs: {\n [id: number]: StyleGlyph | null;\n };\n requests: {\n [range: number]: Array>;\n };\n ranges: {\n [range: number]: boolean | null;\n };\n tinySDF?: TinySDF;\n};\n\nexport class GlyphManager {\n requestManager: RequestManager;\n localIdeographFontFamily: string;\n entries: {\n [_: string]: Entry;\n };\n url: string;\n\n // exposed as statics to enable stubbing in unit tests\n static loadGlyphRange = loadGlyphRange;\n static TinySDF = TinySDF;\n\n constructor(requestManager: RequestManager, localIdeographFontFamily?: string | null) {\n this.requestManager = requestManager;\n this.localIdeographFontFamily = localIdeographFontFamily;\n this.entries = {};\n }\n\n setURL(url?: string | null) {\n this.url = url;\n }\n\n getGlyphs(glyphs: {\n [stack: string]: Array;\n }, callback: Callback<{\n [stack: string]: {\n [id: number]: StyleGlyph;\n };\n }>) {\n const all = [];\n\n for (const stack in glyphs) {\n for (const id of glyphs[stack]) {\n all.push({stack, id});\n }\n }\n\n asyncAll(all, ({stack, id}, callback: Callback<{\n stack: string;\n id: number;\n glyph: StyleGlyph;\n }>) => {\n let entry = this.entries[stack];\n if (!entry) {\n entry = this.entries[stack] = {\n glyphs: {},\n requests: {},\n ranges: {}\n };\n }\n\n let glyph = entry.glyphs[id];\n if (glyph !== undefined) {\n callback(null, {stack, id, glyph});\n return;\n }\n\n glyph = this._tinySDF(entry, stack, id);\n if (glyph) {\n entry.glyphs[id] = glyph;\n callback(null, {stack, id, glyph});\n return;\n }\n\n const range = Math.floor(id / 256);\n if (range * 256 > 65535) {\n callback(new Error('glyphs > 65535 not supported'));\n return;\n }\n\n if (entry.ranges[range]) {\n callback(null, {stack, id, glyph});\n return;\n }\n\n if (!this.url) {\n callback(new Error('glyphsUrl is not set'));\n return;\n }\n\n let requests = entry.requests[range];\n if (!requests) {\n requests = entry.requests[range] = [];\n GlyphManager.loadGlyphRange(stack, range, this.url, this.requestManager,\n (err, response?: {\n [_: number]: StyleGlyph | null;\n } | null) => {\n if (response) {\n for (const id in response) {\n if (!this._doesCharSupportLocalGlyph(+id)) {\n entry.glyphs[+id] = response[+id];\n }\n }\n entry.ranges[range] = true;\n }\n for (const cb of requests) {\n cb(err, response);\n }\n delete entry.requests[range];\n });\n }\n\n requests.push((err, result?: {\n [_: number]: StyleGlyph | null;\n } | null) => {\n if (err) {\n callback(err);\n } else if (result) {\n callback(null, {stack, id, glyph: result[id] || null});\n }\n });\n }, (err, glyphs?: Array<{\n stack: string;\n id: number;\n glyph: StyleGlyph;\n }> | null) => {\n if (err) {\n callback(err);\n } else if (glyphs) {\n const result = {};\n\n for (const {stack, id, glyph} of glyphs) {\n // Clone the glyph so that our own copy of its ArrayBuffer doesn't get transferred.\n (result[stack] || (result[stack] = {}))[id] = glyph && {\n id: glyph.id,\n bitmap: glyph.bitmap.clone(),\n metrics: glyph.metrics\n };\n }\n\n callback(null, result);\n }\n });\n }\n\n _doesCharSupportLocalGlyph(id: number): boolean {\n /* eslint-disable new-cap */\n return !!this.localIdeographFontFamily &&\n (unicodeBlockLookup['CJK Unified Ideographs'](id) ||\n unicodeBlockLookup['Hangul Syllables'](id) ||\n unicodeBlockLookup['Hiragana'](id) ||\n unicodeBlockLookup['Katakana'](id));\n /* eslint-enable new-cap */\n }\n\n _tinySDF(entry: Entry, stack: string, id: number): StyleGlyph {\n const fontFamily = this.localIdeographFontFamily;\n if (!fontFamily) {\n return;\n }\n\n if (!this._doesCharSupportLocalGlyph(id)) {\n return;\n }\n\n // Client-generated glyphs are rendered at 2x texture scale,\n // because CJK glyphs are more detailed than others.\n const textureScale = 2;\n\n let tinySDF = entry.tinySDF;\n if (!tinySDF) {\n let fontWeight = '400';\n if (/bold/i.test(stack)) {\n fontWeight = '900';\n } else if (/medium/i.test(stack)) {\n fontWeight = '500';\n } else if (/light/i.test(stack)) {\n fontWeight = '200';\n }\n tinySDF = entry.tinySDF = new GlyphManager.TinySDF({\n fontSize: 24 * textureScale,\n buffer: 3 * textureScale,\n radius: 8 * textureScale,\n cutoff: 0.25,\n fontFamily,\n fontWeight\n });\n }\n\n const char = tinySDF.draw(String.fromCharCode(id));\n\n /**\n * TinySDF's \"top\" is the distance from the alphabetic baseline to the top of the glyph.\n * Server-generated fonts specify \"top\" relative to an origin above the em box (the origin\n * comes from FreeType, but I'm unclear on exactly how it's derived)\n * ref: https://github.com/mapbox/sdf-glyph-foundry\n *\n * Server fonts don't yet include baseline information, so we can't line up exactly with them\n * (and they don't line up with each other)\n * ref: https://github.com/mapbox/node-fontnik/pull/160\n *\n * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment\n * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode)\n */\n const topAdjustment = 27.5;\n\n const leftAdjustment = 0.5;\n\n return {\n id,\n bitmap: new AlphaImage({width: char.width || 30 * textureScale, height: char.height || 30 * textureScale}, char.data),\n metrics: {\n width: char.glyphWidth / textureScale || 24,\n height: char.glyphHeight / textureScale || 24,\n left: (char.glyphLeft / textureScale + leftAdjustment) || 0,\n top: char.glyphTop / textureScale - topAdjustment || -8,\n advance: char.glyphAdvance / textureScale || 24,\n isDoubleResolution: true\n }\n };\n }\n}\n","import {getArrayBuffer} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\n\nimport {parseGlyphPbf} from './parse_glyph_pbf';\n\nimport type {StyleGlyph} from './style_glyph';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\n\nexport function loadGlyphRange(fontstack: string,\n range: number,\n urlTemplate: string,\n requestManager: RequestManager,\n callback: Callback<{\n [_: number]: StyleGlyph | null;\n }>) {\n const begin = range * 256;\n const end = begin + 255;\n\n const request = requestManager.transformRequest(\n urlTemplate.replace('{fontstack}', fontstack).replace('{range}', `${begin}-${end}`),\n ResourceType.Glyphs\n );\n\n getArrayBuffer(request, (err?: Error | null, data?: ArrayBuffer | null) => {\n if (err) {\n callback(err);\n } else if (data) {\n const glyphs = {};\n\n for (const glyph of parseGlyphPbf(data)) {\n glyphs[glyph.id] = glyph;\n }\n\n callback(null, glyphs);\n }\n });\n}\n","import {interpolates, Color, latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {extend, sphericalToCartesian} from '../util/util';\nimport {Evented} from '../util/evented';\nimport {\n validateStyle,\n validateLight,\n emitValidationErrors\n} from './validate_style';\n\nimport type {StylePropertySpecification, LightSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {EvaluationParameters} from './evaluation_parameters';\nimport type {StyleSetterOptions} from '../style/style';\nimport {Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty} from './properties';\n\nimport type {\n Property,\n PropertyValue,\n TransitionParameters\n} from './properties';\n\ntype LightPosition = {\n x: number;\n y: number;\n z: number;\n};\n\nclass LightPositionProperty implements Property<[number, number, number], LightPosition> {\n specification: StylePropertySpecification;\n\n constructor() {\n this.specification = styleSpec.light.position as StylePropertySpecification;\n }\n\n possiblyEvaluate(\n value: PropertyValue<[number, number, number], LightPosition>,\n parameters: EvaluationParameters\n ): LightPosition {\n return sphericalToCartesian(value.expression.evaluate(parameters));\n }\n\n interpolate(a: LightPosition, b: LightPosition, t: number): LightPosition {\n return {\n x: interpolates.number(a.x, b.x, t),\n y: interpolates.number(a.y, b.y, t),\n z: interpolates.number(a.z, b.z, t),\n };\n }\n}\n\ntype Props = {\n 'anchor': DataConstantProperty<'map' | 'viewport'>;\n 'position': LightPositionProperty;\n 'color': DataConstantProperty;\n 'intensity': DataConstantProperty;\n};\n\ntype PropsPossiblyEvaluated = {\n 'anchor': 'map' | 'viewport';\n 'position': LightPosition;\n 'color': Color;\n 'intensity': number;\n};\n\nconst TRANSITION_SUFFIX = '-transition';\n\nlet lightProperties: Properties;\n\n/*\n * Represents the light used to light extruded features.\n */\nexport class Light extends Evented {\n _transitionable: Transitionable;\n _transitioning: Transitioning;\n properties: PossiblyEvaluated;\n\n constructor(lightOptions?: LightSpecification) {\n super();\n lightProperties = lightProperties || new Properties({\n 'anchor': new DataConstantProperty(styleSpec.light.anchor as StylePropertySpecification),\n 'position': new LightPositionProperty(),\n 'color': new DataConstantProperty(styleSpec.light.color as StylePropertySpecification),\n 'intensity': new DataConstantProperty(styleSpec.light.intensity as StylePropertySpecification),\n });\n this._transitionable = new Transitionable(lightProperties);\n this.setLight(lightOptions);\n this._transitioning = this._transitionable.untransitioned();\n }\n\n getLight(): LightSpecification {\n return this._transitionable.serialize();\n }\n\n setLight(light?: LightSpecification, options: StyleSetterOptions = {}) {\n if (this._validate(validateLight, light, options)) {\n return;\n }\n\n for (const name in light) {\n const value = light[name];\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionable.setTransition(name.slice(0, -TRANSITION_SUFFIX.length) as keyof Props, value);\n } else {\n this._transitionable.setValue(name as keyof Props, value);\n }\n }\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioning = this._transitionable.transitioned(parameters, this._transitioning);\n }\n\n hasTransition() {\n return this._transitioning.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters) {\n this.properties = this._transitioning.possiblyEvaluate(parameters);\n }\n\n _validate(validate: Function, value: unknown, options?: {\n validate?: boolean;\n }) {\n if (options && options.validate === false) {\n return false;\n }\n\n return emitValidationErrors(this, validate.call(validateStyle, extend({\n value,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true},\n styleSpec\n })));\n }\n}\n","import {warnOnce} from '../util/util';\n\nimport type {Context} from '../gl/context';\n\n/**\n * A dash entry\n */\ntype DashEntry = {\n y: number;\n height: number;\n width: number;\n}\n\n/**\n * @internal\n * A LineAtlas lets us reuse rendered dashed lines\n * by writing many of them to a texture and then fetching their positions\n * using {@link LineAtlas#getDash}.\n *\n * @param width - the width\n * @param height - the height\n */\nexport class LineAtlas {\n width: number;\n height: number;\n nextRow: number;\n bytes: number;\n data: Uint8Array;\n dashEntry: {[_: string]: DashEntry};\n dirty: boolean;\n texture: WebGLTexture;\n\n constructor(width: number, height: number) {\n this.width = width;\n this.height = height;\n this.nextRow = 0;\n\n this.data = new Uint8Array(this.width * this.height);\n\n this.dashEntry = {};\n }\n\n /**\n * Get or create a dash line pattern.\n *\n * @param dasharray - the key (represented by numbers) to get the dash texture\n * @param round - whether to add circle caps in between dash segments\n * @returns position of dash texture in {@link DashEntry}\n */\n getDash(dasharray: Array, round: boolean) {\n const key = dasharray.join(',') + String(round);\n\n if (!this.dashEntry[key]) {\n this.dashEntry[key] = this.addDash(dasharray, round);\n }\n return this.dashEntry[key];\n }\n\n getDashRanges(dasharray: Array, lineAtlasWidth: number, stretch: number) {\n // If dasharray has an odd length, both the first and last parts\n // are dashes and should be joined seamlessly.\n const oddDashArray = dasharray.length % 2 === 1;\n\n const ranges = [];\n\n let left = oddDashArray ? -dasharray[dasharray.length - 1] * stretch : 0;\n let right = dasharray[0] * stretch;\n let isDash = true;\n\n ranges.push({left, right, isDash, zeroLength: dasharray[0] === 0});\n\n let currentDashLength = dasharray[0];\n for (let i = 1; i < dasharray.length; i++) {\n isDash = !isDash;\n\n const dashLength = dasharray[i];\n left = currentDashLength * stretch;\n currentDashLength += dashLength;\n right = currentDashLength * stretch;\n\n ranges.push({left, right, isDash, zeroLength: dashLength === 0});\n }\n\n return ranges;\n }\n\n addRoundDash(ranges: any, stretch: number, n: number) {\n const halfStretch = stretch / 2;\n\n for (let y = -n; y <= n; y++) {\n const row = this.nextRow + n + y;\n const index = this.width * row;\n let currIndex = 0;\n let range = ranges[currIndex];\n\n for (let x = 0; x < this.width; x++) {\n if (x / range.right > 1) { range = ranges[++currIndex]; }\n\n const distLeft = Math.abs(x - range.left);\n const distRight = Math.abs(x - range.right);\n const minDist = Math.min(distLeft, distRight);\n let signedDistance;\n\n const distMiddle = y / n * (halfStretch + 1);\n if (range.isDash) {\n const distEdge = halfStretch - Math.abs(distMiddle);\n signedDistance = Math.sqrt(minDist * minDist + distEdge * distEdge);\n } else {\n signedDistance = halfStretch - Math.sqrt(minDist * minDist + distMiddle * distMiddle);\n }\n\n this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128));\n }\n }\n }\n\n addRegularDash(ranges: any) {\n\n // Collapse any zero-length range\n // Collapse neighbouring same-type parts into a single part\n for (let i = ranges.length - 1; i >= 0; --i) {\n const part = ranges[i];\n const next = ranges[i + 1];\n if (part.zeroLength) {\n ranges.splice(i, 1);\n } else if (next && next.isDash === part.isDash) {\n next.left = part.left;\n ranges.splice(i, 1);\n }\n }\n\n // Combine the first and last parts if possible\n const first = ranges[0];\n const last = ranges[ranges.length - 1];\n if (first.isDash === last.isDash) {\n first.left = last.left - this.width;\n last.right = first.right + this.width;\n }\n\n const index = this.width * this.nextRow;\n let currIndex = 0;\n let range = ranges[currIndex];\n\n for (let x = 0; x < this.width; x++) {\n if (x / range.right > 1) {\n range = ranges[++currIndex];\n }\n\n const distLeft = Math.abs(x - range.left);\n const distRight = Math.abs(x - range.right);\n\n const minDist = Math.min(distLeft, distRight);\n const signedDistance = range.isDash ? minDist : -minDist;\n\n this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128));\n }\n }\n\n addDash(dasharray: Array, round: boolean): DashEntry {\n const n = round ? 7 : 0;\n const height = 2 * n + 1;\n\n if (this.nextRow + height > this.height) {\n warnOnce('LineAtlas out of space');\n return null;\n }\n\n let length = 0;\n for (let i = 0; i < dasharray.length; i++) { length += dasharray[i]; }\n\n if (length !== 0) {\n const stretch = this.width / length;\n const ranges = this.getDashRanges(dasharray, this.width, stretch);\n\n if (round) {\n this.addRoundDash(ranges, stretch, n);\n } else {\n this.addRegularDash(ranges);\n }\n }\n\n const dashEntry = {\n y: (this.nextRow + n + 0.5) / this.height,\n height: 2 * n / this.height,\n width: length\n };\n\n this.nextRow += height;\n this.dirty = true;\n\n return dashEntry;\n }\n\n bind(context: Context) {\n const gl = context.gl;\n if (!this.texture) {\n this.texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, this.width, this.height, 0, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);\n\n } else {\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n if (this.dirty) {\n this.dirty = false;\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);\n }\n }\n }\n}\n","/**\n * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests\n * are ignored until the function was actually invoked.\n */\nexport class ThrottledInvoker {\n _channel: MessageChannel;\n _triggered: boolean;\n _callback: Function;\n\n constructor(callback: Function) {\n this._callback = callback;\n this._triggered = false;\n if (typeof MessageChannel !== 'undefined') {\n this._channel = new MessageChannel();\n this._channel.port2.onmessage = () => {\n this._triggered = false;\n this._callback();\n };\n }\n }\n\n trigger() {\n if (!this._triggered) {\n this._triggered = true;\n if (this._channel) {\n this._channel.port1.postMessage(true);\n } else {\n setTimeout(() => {\n this._triggered = false;\n this._callback();\n }, 0);\n }\n }\n }\n\n remove() {\n delete this._channel;\n this._callback = () => {};\n }\n}\n","import {isWorker} from './util';\nimport {serialize, deserialize, Serialized} from './web_worker_transfer';\nimport {ThrottledInvoker} from './throttled_invoker';\n\nimport type {Transferable} from '../types/transferable';\nimport type {Cancelable} from '../types/cancelable';\nimport type {WorkerSource} from '../source/worker_source';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {Callback} from '../types/callback';\nimport type {StyleGlyph} from '../style/style_glyph';\n\nexport interface ActorTarget {\n addEventListener: typeof window.addEventListener;\n removeEventListener: typeof window.removeEventListener;\n postMessage: typeof window.postMessage;\n terminate?: () => void;\n}\n\nexport interface WorkerSourceProvider {\n getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource;\n}\n\nexport interface GlyphsProvider {\n getGlyphs(mapId: string, params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n );\n}\n\nexport type MessageType = '' | '' |\n'geojson.getClusterExpansionZoom' | 'geojson.getClusterChildren' | 'geojson.getClusterLeaves' | 'geojson.loadData' |\n'removeSource' | 'loadWorkerSource' | 'loadDEMTile' | 'removeDEMTile' |\n'removeTile' | 'reloadTile' | 'abortTile' | 'loadTile' | 'getTile' |\n'getGlyphs' | 'getImages' | 'setImages' |\n'syncRTLPluginState' | 'setReferrer' | 'setLayers' | 'updateLayers';\n\nexport type MessageData = {\n id: string;\n type: MessageType;\n data?: Serialized;\n targetMapId?: string | number | null;\n mustQueue?: boolean;\n error?: Serialized | null;\n hasCallback?: boolean;\n sourceMapId: string | number | null;\n}\n\nexport type Message = {\n data: MessageData;\n}\n\n/**\n * An implementation of the [Actor design pattern](http://en.wikipedia.org/wiki/Actor_model)\n * that maintains the relationship between asynchronous tasks and the objects\n * that spin them off - in this case, tasks like parsing parts of styles,\n * owned by the styles\n */\nexport class Actor {\n target: ActorTarget;\n parent: WorkerSourceProvider | GlyphsProvider;\n mapId: string | number | null;\n callbacks: { [x: number]: Function};\n name: string;\n tasks: { [x: number]: MessageData };\n taskQueue: Array;\n cancelCallbacks: { [x: number]: () => void };\n invoker: ThrottledInvoker;\n globalScope: ActorTarget;\n\n /**\n * @param target - The target\n * @param parent - The parent\n * @param mapId - A unique identifier for the Map instance using this Actor.\n */\n constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number) {\n this.target = target;\n this.parent = parent;\n this.mapId = mapId;\n this.callbacks = {};\n this.tasks = {};\n this.taskQueue = [];\n this.cancelCallbacks = {};\n this.invoker = new ThrottledInvoker(this.process);\n this.target.addEventListener('message', this.receive, false);\n this.globalScope = isWorker() ? target : window;\n }\n\n /**\n * Sends a message from a main-thread map to a Worker or from a Worker back to\n * a main-thread map instance.\n *\n * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource.\n * @param targetMapId - A particular mapId to which to send this message.\n */\n send(\n type: MessageType,\n data: unknown,\n callback?: Function | null,\n targetMapId?: string | null,\n mustQueue: boolean = false\n ): Cancelable {\n // We're using a string ID instead of numbers because they are being used as object keys\n // anyway, and thus stringified implicitly. We use random IDs because an actor may receive\n // message from multiple other actors which could run in different execution context. A\n // linearly increasing ID could produce collisions.\n const id = Math.round((Math.random() * 1e18)).toString(36).substring(0, 10);\n if (callback) {\n this.callbacks[id] = callback;\n }\n const buffers: Array = [];\n const message: MessageData = {\n id,\n type,\n hasCallback: !!callback,\n targetMapId,\n mustQueue,\n sourceMapId: this.mapId,\n data: serialize(data, buffers)\n };\n\n this.target.postMessage(message, {transfer: buffers});\n return {\n cancel: () => {\n if (callback) {\n // Set the callback to null so that it never fires after the request is aborted.\n delete this.callbacks[id];\n }\n const cancelMessage: MessageData = {\n id,\n type: '',\n targetMapId,\n sourceMapId: this.mapId\n };\n this.target.postMessage(cancelMessage);\n }\n };\n }\n\n receive = (message: Message) => {\n const data = message.data;\n const id = data.id;\n\n if (!id) {\n return;\n }\n\n if (data.targetMapId && this.mapId !== data.targetMapId) {\n return;\n }\n\n if (data.type === '') {\n // Remove the original request from the queue. This is only possible if it\n // hasn't been kicked off yet. The id will remain in the queue, but because\n // there is no associated task, it will be dropped once it's time to execute it.\n delete this.tasks[id];\n const cancel = this.cancelCallbacks[id];\n delete this.cancelCallbacks[id];\n if (cancel) {\n cancel();\n }\n } else {\n if (isWorker() || data.mustQueue) {\n // In workers, store the tasks that we need to process before actually processing them. This\n // is necessary because we want to keep receiving messages, and in particular,\n // messages. Some tasks may take a while in the worker thread, so before\n // executing the next task in our queue, postMessage preempts this and \n // messages can be processed. We're using a MessageChannel object to get throttle the\n // process() flow to one at a time.\n this.tasks[id] = data;\n this.taskQueue.push(id);\n this.invoker.trigger();\n } else {\n // In the main thread, process messages immediately so that other work does not slip in\n // between getting partial data back from workers.\n this.processTask(id, data);\n }\n }\n };\n\n process = () => {\n if (!this.taskQueue.length) {\n return;\n }\n const id = this.taskQueue.shift();\n const task = this.tasks[id];\n delete this.tasks[id];\n // Schedule another process call if we know there's more to process _before_ invoking the\n // current task. This is necessary so that processing continues even if the current task\n // doesn't execute successfully.\n if (this.taskQueue.length) {\n this.invoker.trigger();\n }\n if (!task) {\n // If the task ID doesn't have associated task data anymore, it was canceled.\n return;\n }\n\n this.processTask(id, task);\n };\n\n processTask(id: string, task: MessageData) {\n if (task.type === '') {\n // The done() function in the counterpart has been called, and we are now\n // firing the callback in the originating actor, if there is one.\n const callback = this.callbacks[id];\n delete this.callbacks[id];\n if (callback) {\n // If we get a response, but don't have a callback, the request was canceled.\n if (task.error) {\n callback(deserialize(task.error));\n } else {\n callback(null, deserialize(task.data));\n }\n }\n } else {\n let completed = false;\n const buffers: Array = [];\n const done = task.hasCallback ? (err: Error, data?: any) => {\n completed = true;\n delete this.cancelCallbacks[id];\n const responseMessage: MessageData = {\n id,\n type: '',\n sourceMapId: this.mapId,\n error: err ? serialize(err) : null,\n data: serialize(data, buffers)\n };\n this.target.postMessage(responseMessage, {transfer: buffers});\n } : (_) => {\n completed = true;\n };\n\n let callback: Cancelable = null;\n const params = deserialize(task.data);\n if (this.parent[task.type]) {\n // task.type == 'loadTile', 'removeTile', etc.\n callback = this.parent[task.type](task.sourceMapId, params, done);\n } else if ('getWorkerSource' in this.parent) {\n // task.type == sourcetype.method\n const keys = task.type.split('.');\n const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], (params as any).source);\n callback = scope[keys[1]](params, done);\n } else {\n // No function was found.\n done(new Error(`Could not find function ${task.type}`));\n }\n\n if (!completed && callback && callback.cancel) {\n // Allows canceling the task as long as it hasn't been completed yet.\n this.cancelCallbacks[id] = callback.cancel;\n }\n }\n }\n\n remove() {\n this.invoker.remove();\n this.target.removeEventListener('message', this.receive, false);\n }\n}\n","import {asyncAll} from './util';\nimport {Actor, GlyphsProvider, MessageType} from './actor';\n\nimport type {WorkerPool} from './worker_pool';\nimport type {WorkerSource} from '../source/worker_source'; /* eslint-disable-line */ // this is used for the docs' import\n/**\n * Responsible for sending messages from a {@link Source} to an associated\n * {@link WorkerSource}.\n */\nexport class Dispatcher {\n workerPool: WorkerPool;\n actors: Array;\n currentActor: number;\n id: string | number;\n\n constructor(workerPool: WorkerPool, parent: GlyphsProvider, mapId: string | number) {\n this.workerPool = workerPool;\n this.actors = [];\n this.currentActor = 0;\n this.id = mapId;\n const workers = this.workerPool.acquire(mapId);\n for (let i = 0; i < workers.length; i++) {\n const worker = workers[i];\n const actor = new Actor(worker, parent, mapId);\n actor.name = `Worker ${i}`;\n this.actors.push(actor);\n }\n if (!this.actors.length) throw new Error('No actors found');\n }\n\n /**\n * Broadcast a message to all Workers.\n */\n broadcast(type: MessageType, data: unknown, cb?: (...args: any[]) => any) {\n cb = cb || function () {};\n asyncAll(this.actors, (actor, done) => {\n actor.send(type, data, done);\n }, cb);\n }\n\n /**\n * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion.\n * @returns An actor object backed by a web worker for processing messages.\n */\n getActor(): Actor {\n this.currentActor = (this.currentActor + 1) % this.actors.length;\n return this.actors[this.currentActor];\n }\n\n remove(mapRemoved: boolean = true) {\n this.actors.forEach((actor) => { actor.remove(); });\n this.actors = [];\n if (mapRemoved) this.workerPool.release(this.id);\n }\n}\n","import {pick, extend} from '../util/util';\n\nimport {getJSON} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\n\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\nimport type {TileJSON} from '../types/tilejson';\nimport type {Cancelable} from '../types/cancelable';\nimport type {RasterDEMSourceSpecification, RasterSourceSpecification, VectorSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function loadTileJson(\n options: RasterSourceSpecification | RasterDEMSourceSpecification | VectorSourceSpecification,\n requestManager: RequestManager,\n callback: Callback\n): Cancelable {\n const loaded = function(err: Error, tileJSON: any) {\n if (err) {\n return callback(err);\n } else if (tileJSON) {\n const result: any = pick(\n // explicit source options take precedence over TileJSON\n extend(tileJSON, options),\n ['tiles', 'minzoom', 'maxzoom', 'attribution', 'bounds', 'scheme', 'tileSize', 'encoding']\n );\n\n if (tileJSON.vector_layers) {\n result.vectorLayers = tileJSON.vector_layers;\n result.vectorLayerIds = result.vectorLayers.map((layer) => { return layer.id; });\n }\n\n callback(null, result);\n }\n };\n\n if (options.url) {\n return getJSON(requestManager.transformRequest(options.url, ResourceType.Source), loaded);\n } else {\n return browser.frame(() => loaded(null, options));\n }\n}\n","import {wrap} from '../util/util';\n\n/*\n* Approximate radius of the earth in meters.\n* Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84\n* 6371008.8 is one published \"average radius\" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4\n*/\nexport const earthRadius = 6371008.8;\n\n/**\n * A {@link LngLat} object, an array of two numbers representing longitude and latitude,\n * or an object with `lng` and `lat` or `lon` and `lat` properties.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLat(-122.420679, 37.772537);\n * let v2 = [-122.420679, 37.772537];\n * let v3 = {lon: -122.420679, lat: 37.772537};\n * ```\n */\nexport type LngLatLike = LngLat | {\n lng: number;\n lat: number;\n} | {\n lon: number;\n lat: number;\n} | [number, number];\n\n/**\n * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.\n * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).\n *\n * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the\n * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).\n *\n * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option\n * can also accept an `Array` of two numbers and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-123.9749, 40.7736);\n * ll.lng; // = -123.9749\n * ```\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\nexport class LngLat {\n lng: number;\n lat: number;\n\n /**\n * @param lng - Longitude, measured in degrees.\n * @param lat - Latitude, measured in degrees.\n */\n constructor(lng: number, lat: number) {\n if (isNaN(lng) || isNaN(lat)) {\n throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);\n }\n this.lng = +lng;\n this.lat = +lat;\n if (this.lat > 90 || this.lat < -90) {\n throw new Error('Invalid LngLat latitude value: must be between -90 and 90');\n }\n }\n\n /**\n * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).\n *\n * @returns The wrapped `LngLat` object.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(286.0251, 40.7736);\n * let wrapped = ll.wrap();\n * wrapped.lng; // = -73.9749\n * ```\n */\n wrap() {\n return new LngLat(wrap(this.lng, -180, 180), this.lat);\n }\n\n /**\n * Returns the coordinates represented as an array of two numbers.\n *\n * @returns The coordinates represented as an array of longitude and latitude.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toArray(); // = [-73.9749, 40.7736]\n * ```\n */\n toArray(): [number, number] {\n return [this.lng, this.lat];\n }\n\n /**\n * Returns the coordinates represent as a string.\n *\n * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toString(); // = \"LngLat(-73.9749, 40.7736)\"\n * ```\n */\n toString(): string {\n return `LngLat(${this.lng}, ${this.lat})`;\n }\n\n /**\n * Returns the approximate distance between a pair of coordinates in meters\n * Uses the Haversine Formula (from R.W. Sinnott, \"Virtues of the Haversine\", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)\n *\n * @param lngLat - coordinates to compute the distance to\n * @returns Distance in meters between the two coordinates.\n * @example\n * ```ts\n * let new_york = new maplibregl.LngLat(-74.0060, 40.7128);\n * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522);\n * new_york.distanceTo(los_angeles); // = 3935751.690893987, \"true distance\" using a non-spherical approximation is ~3966km\n * ```\n */\n distanceTo(lngLat: LngLat): number {\n const rad = Math.PI / 180;\n const lat1 = this.lat * rad;\n const lat2 = lngLat.lat * rad;\n const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);\n\n const maxMeters = earthRadius * Math.acos(Math.min(a, 1));\n return maxMeters;\n }\n\n /**\n * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties\n * to a `LngLat` object.\n *\n * If a `LngLat` object is passed in, the function returns it unchanged.\n *\n * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.\n * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.\n * @example\n * ```ts\n * let arr = [-73.9749, 40.7736];\n * let ll = maplibregl.LngLat.convert(arr);\n * ll; // = LngLat {lng: -73.9749, lat: 40.7736}\n * ```\n */\n static convert(input: LngLatLike): LngLat {\n if (input instanceof LngLat) {\n return input;\n }\n if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {\n return new LngLat(Number(input[0]), Number(input[1]));\n }\n if (!Array.isArray(input) && typeof input === 'object' && input !== null) {\n return new LngLat(\n // flow can't refine this to have one of lng or lat, so we have to cast to any\n Number('lng' in input ? (input as any).lng : (input as any).lon),\n Number(input.lat)\n );\n }\n throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]');\n }\n}\n","import {LngLat} from './lng_lat';\nimport type {LngLatLike} from './lng_lat';\n\n/**\n * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,\n * or an array of numbers in [west, south, east, north] order.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLatBounds(\n * new maplibregl.LngLat(-73.9876, 40.7661),\n * new maplibregl.LngLat(-73.9397, 40.8002)\n * );\n * let v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])\n * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];\n * ```\n */\nexport type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];\n\n/**\n * A `LngLatBounds` object represents a geographical bounding box,\n * defined by its southwest and northeast points in longitude and latitude.\n *\n * If no arguments are provided to the constructor, a `null` bounding box is created.\n *\n * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option\n * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatBoundsLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let sw = new maplibregl.LngLat(-73.9876, 40.7661);\n * let ne = new maplibregl.LngLat(-73.9397, 40.8002);\n * let llb = new maplibregl.LngLatBounds(sw, ne);\n * ```\n */\nexport class LngLatBounds {\n _ne: LngLat;\n _sw: LngLat;\n\n /**\n * @param sw - The southwest corner of the bounding box.\n * OR array of 4 numbers in the order of west, south, east, north\n * OR array of 2 LngLatLike: [sw,ne]\n * @param ne - The northeast corner of the bounding box.\n * @example\n * ```ts\n * let sw = new maplibregl.LngLat(-73.9876, 40.7661);\n * let ne = new maplibregl.LngLat(-73.9397, 40.8002);\n * let llb = new maplibregl.LngLatBounds(sw, ne);\n * ```\n * OR\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);\n * ```\n * OR\n * ```ts\n * let llb = new maplibregl.LngLatBounds([sw, ne]);\n * ```\n */\n constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike) {\n if (!sw) {\n // noop\n } else if (ne) {\n this.setSouthWest(sw).setNorthEast(ne);\n } else if (Array.isArray(sw)) {\n if (sw.length === 4) {\n // 4 element array: west, south, east, north\n this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);\n } else {\n this.setSouthWest(sw[0] as LngLatLike).setNorthEast(sw[1] as LngLatLike);\n }\n }\n }\n\n /**\n * Set the northeast corner of the bounding box\n *\n * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box.\n * @returns `this`\n */\n setNorthEast(ne: LngLatLike): this {\n this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);\n return this;\n }\n\n /**\n * Set the southwest corner of the bounding box\n *\n * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box.\n * @returns `this`\n */\n setSouthWest(sw: LngLatLike): this {\n this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);\n return this;\n }\n\n /**\n * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.\n *\n * @param obj - object to extend to\n * @returns `this`\n */\n extend(obj: LngLatLike | LngLatBoundsLike): this {\n const sw = this._sw,\n ne = this._ne;\n let sw2, ne2;\n\n if (obj instanceof LngLat) {\n sw2 = obj;\n ne2 = obj;\n\n } else if (obj instanceof LngLatBounds) {\n sw2 = obj._sw;\n ne2 = obj._ne;\n\n if (!sw2 || !ne2) return this;\n\n } else {\n if (Array.isArray(obj)) {\n if (obj.length === 4 || (obj as any[]).every(Array.isArray)) {\n const lngLatBoundsObj = (obj as any as LngLatBoundsLike);\n return this.extend(LngLatBounds.convert(lngLatBoundsObj));\n } else {\n const lngLatObj = (obj as any as LngLatLike);\n return this.extend(LngLat.convert(lngLatObj));\n }\n\n } else if (obj && ('lng' in obj || 'lon' in obj) && 'lat' in obj) {\n return this.extend(LngLat.convert(obj));\n }\n\n return this;\n }\n\n if (!sw && !ne) {\n this._sw = new LngLat(sw2.lng, sw2.lat);\n this._ne = new LngLat(ne2.lng, ne2.lat);\n\n } else {\n sw.lng = Math.min(sw2.lng, sw.lng);\n sw.lat = Math.min(sw2.lat, sw.lat);\n ne.lng = Math.max(ne2.lng, ne.lng);\n ne.lat = Math.max(ne2.lat, ne.lat);\n }\n\n return this;\n }\n\n /**\n * Returns the geographical coordinate equidistant from the bounding box's corners.\n *\n * @returns The bounding box's center.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}\n * ```\n */\n getCenter(): LngLat {\n return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);\n }\n\n /**\n * Returns the southwest corner of the bounding box.\n *\n * @returns The southwest corner of the bounding box.\n */\n getSouthWest(): LngLat { return this._sw; }\n\n /**\n * Returns the northeast corner of the bounding box.\n *\n * @returns The northeast corner of the bounding box.\n */\n getNorthEast(): LngLat { return this._ne; }\n\n /**\n * Returns the northwest corner of the bounding box.\n *\n * @returns The northwest corner of the bounding box.\n */\n getNorthWest(): LngLat { return new LngLat(this.getWest(), this.getNorth()); }\n\n /**\n * Returns the southeast corner of the bounding box.\n *\n * @returns The southeast corner of the bounding box.\n */\n getSouthEast(): LngLat { return new LngLat(this.getEast(), this.getSouth()); }\n\n /**\n * Returns the west edge of the bounding box.\n *\n * @returns The west edge of the bounding box.\n */\n getWest(): number { return this._sw.lng; }\n\n /**\n * Returns the south edge of the bounding box.\n *\n * @returns The south edge of the bounding box.\n */\n getSouth(): number { return this._sw.lat; }\n\n /**\n * Returns the east edge of the bounding box.\n *\n * @returns The east edge of the bounding box.\n */\n getEast(): number { return this._ne.lng; }\n\n /**\n * Returns the north edge of the bounding box.\n *\n * @returns The north edge of the bounding box.\n */\n getNorth(): number { return this._ne.lat; }\n\n /**\n * Returns the bounding box represented as an array.\n *\n * @returns The bounding box represented as an array, consisting of the\n * southwest and northeast coordinates of the bounding represented as arrays of numbers.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]\n * ```\n */\n toArray() {\n return [this._sw.toArray(), this._ne.toArray()];\n }\n\n /**\n * Return the bounding box represented as a string.\n *\n * @returns The bounding box represents as a string of the format\n * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.toString(); // = \"LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))\"\n * ```\n */\n toString() {\n return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;\n }\n\n /**\n * Check if the bounding box is an empty/`null`-type box.\n *\n * @returns True if bounds have been defined, otherwise false.\n */\n isEmpty() {\n return !(this._sw && this._ne);\n }\n\n /**\n * Check if the point is within the bounding box.\n *\n * @param lnglat - geographic point to check against.\n * @returns `true` if the point is within the bounding box.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds(\n * new maplibregl.LngLat(-73.9876, 40.7661),\n * new maplibregl.LngLat(-73.9397, 40.8002)\n * );\n *\n * let ll = new maplibregl.LngLat(-73.9567, 40.7789);\n *\n * console.log(llb.contains(ll)); // = true\n * ```\n */\n contains(lnglat: LngLatLike) {\n const {lng, lat} = LngLat.convert(lnglat);\n\n const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat;\n let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng;\n if (this._sw.lng > this._ne.lng) { // wrapped coordinates\n containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng;\n }\n\n return containsLatitude && containsLongitude;\n }\n\n /**\n * Converts an array to a `LngLatBounds` object.\n *\n * If a `LngLatBounds` object is passed in, the function returns it unchanged.\n *\n * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.\n *\n * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return.\n * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.\n * @example\n * ```ts\n * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];\n * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}\n * ```\n */\n static convert(input: LngLatBoundsLike | null): LngLatBounds {\n if (input instanceof LngLatBounds) return input;\n if (!input) return input as null;\n return new LngLatBounds(input);\n }\n\n /**\n * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.\n *\n * @param center - center coordinates of the new bounds.\n * @param radius - Distance in meters from the coordinates to extend the bounds.\n * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`.\n * @example\n * ```ts\n * let center = new maplibregl.LngLat(-73.9749, 40.7736);\n * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]\n * ```\n */\n static fromLngLat(center: LngLat, radius:number = 0): LngLatBounds {\n const earthCircumferenceInMetersAtEquator = 40075017;\n const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator,\n lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * center.lat);\n\n return new LngLatBounds(new LngLat(center.lng - lngAccuracy, center.lat - latAccuracy),\n new LngLat(center.lng + lngAccuracy, center.lat + latAccuracy));\n }\n}\n","import {LngLat, earthRadius} from '../geo/lng_lat';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport {IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/*\n * The average circumference of the world in meters.\n */\nconst earthCircumfrence = 2 * Math.PI * earthRadius; // meters\n\n/*\n * The circumference at a line of latitude in meters.\n */\nfunction circumferenceAtLatitude(latitude: number) {\n return earthCircumfrence * Math.cos(latitude * Math.PI / 180);\n}\n\nexport function mercatorXfromLng(lng: number) {\n return (180 + lng) / 360;\n}\n\nexport function mercatorYfromLat(lat: number) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\n\nexport function mercatorZfromAltitude(altitude: number, lat: number) {\n return altitude / circumferenceAtLatitude(lat);\n}\n\nexport function lngFromMercatorX(x: number) {\n return x * 360 - 180;\n}\n\nexport function latFromMercatorY(y: number) {\n const y2 = 180 - y * 360;\n return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;\n}\n\nexport function altitudeFromMercatorZ(z: number, y: number) {\n return z * circumferenceAtLatitude(latFromMercatorY(y));\n}\n\n/**\n * Determine the Mercator scale factor for a given latitude, see\n * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor\n *\n * At the equator the scale factor will be 1, which increases at higher latitudes.\n *\n * @param lat - Latitude\n * @returns scale factor\n */\nexport function mercatorScale(lat: number) {\n return 1 / Math.cos(lat * Math.PI / 180);\n}\n\n/**\n * A `MercatorCoordinate` object represents a projected three dimensional position.\n *\n * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:\n * - the size of 1 unit is the width of the projected world instead of the \"mercator meter\"\n * - the origin of the coordinate space is at the north-west corner instead of the middle\n *\n * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and\n * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with\n * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think\n * of the coordinate space as the `0/0/0` tile with an extent of `1`.\n *\n * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let nullIsland = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * ```\n * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/)\n */\nexport class MercatorCoordinate implements IMercatorCoordinate {\n x: number;\n y: number;\n z: number;\n\n /**\n * @param x - The x component of the position.\n * @param y - The y component of the position.\n * @param z - The z component of the position.\n */\n constructor(x: number, y: number, z: number = 0) {\n this.x = +x;\n this.y = +y;\n this.z = +z;\n }\n\n /**\n * Project a `LngLat` to a `MercatorCoordinate`.\n *\n * @param lngLatLike - The location to project.\n * @param altitude - The altitude in meters of the position.\n * @returns The projected mercator coordinate.\n * @example\n * ```ts\n * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);\n * coord; // MercatorCoordinate(0.5, 0.5, 0)\n * ```\n */\n static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0): MercatorCoordinate {\n const lngLat = LngLat.convert(lngLatLike);\n\n return new MercatorCoordinate(\n mercatorXfromLng(lngLat.lng),\n mercatorYfromLat(lngLat.lat),\n mercatorZfromAltitude(altitude, lngLat.lat));\n }\n\n /**\n * Returns the `LngLat` for the coordinate.\n *\n * @returns The `LngLat` object.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * let lngLat = coord.toLngLat(); // LngLat(0, 0)\n * ```\n */\n toLngLat() {\n return new LngLat(\n lngFromMercatorX(this.x),\n latFromMercatorY(this.y));\n }\n\n /**\n * Returns the altitude in meters of the coordinate.\n *\n * @returns The altitude in meters.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02);\n * coord.toAltitude(); // 6914.281956295339\n * ```\n */\n toAltitude(): number {\n return altitudeFromMercatorZ(this.z, this.y);\n }\n\n /**\n * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.\n *\n * For coordinates in real world units using meters, this naturally provides the scale\n * to transform into `MercatorCoordinate`s.\n *\n * @returns Distance of 1 meter in `MercatorCoordinate` units.\n */\n meterInMercatorCoordinateUnits(): number {\n // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude\n return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));\n }\n}\n","import {LngLatBounds, LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport {mercatorXfromLng, mercatorYfromLat} from '../geo/mercator_coordinate';\n\nimport type {CanonicalTileID} from './tile_id';\n\nexport class TileBounds {\n bounds: LngLatBounds;\n minzoom: number;\n maxzoom: number;\n\n constructor(bounds: [number, number, number, number], minzoom?: number | null, maxzoom?: number | null) {\n this.bounds = LngLatBounds.convert(this.validateBounds(bounds));\n this.minzoom = minzoom || 0;\n this.maxzoom = maxzoom || 24;\n }\n\n validateBounds(bounds: [number, number, number, number]): LngLatBoundsLike {\n // make sure the bounds property contains valid longitude and latitudes\n if (!Array.isArray(bounds) || bounds.length !== 4) return [-180, -90, 180, 90];\n return [Math.max(-180, bounds[0]), Math.max(-90, bounds[1]), Math.min(180, bounds[2]), Math.min(90, bounds[3])];\n }\n\n contains(tileID: CanonicalTileID) {\n const worldSize = Math.pow(2, tileID.z);\n const level = {\n minX: Math.floor(mercatorXfromLng(this.bounds.getWest()) * worldSize),\n minY: Math.floor(mercatorYfromLat(this.bounds.getNorth()) * worldSize),\n maxX: Math.ceil(mercatorXfromLng(this.bounds.getEast()) * worldSize),\n maxY: Math.ceil(mercatorYfromLat(this.bounds.getSouth()) * worldSize)\n };\n const hit = tileID.x >= level.minX && tileID.x < level.maxX && tileID.y >= level.minY && tileID.y < level.maxY;\n return hit;\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\n\nimport {extend, pick} from '../util/util';\nimport {loadTileJson} from './load_tilejson';\nimport {TileBounds} from './tile_bounds';\nimport {ResourceType} from '../util/request_manager';\n\nimport type {Source} from './source';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport type {VectorSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type VectorTileSourceOptions = VectorSourceSpecification & {\n collectResourceTiming?: boolean;\n}\n\n/**\n * A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/).\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'vector',\n * tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],\n * minzoom: 6,\n * maxzoom: 14\n * });\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setUrl(\"https://demotiles.maplibre.org/tiles/tiles.json\");\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);\n * ```\n * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)\n */\nexport class VectorTileSource extends Evented implements Source {\n type: 'vector';\n id: string;\n minzoom: number;\n maxzoom: number;\n url: string;\n scheme: string;\n tileSize: number;\n promoteId: PromoteIdSpecification;\n\n _options: VectorSourceSpecification;\n _collectResourceTiming: boolean;\n dispatcher: Dispatcher;\n map: Map;\n bounds: [number, number, number, number];\n tiles: Array;\n tileBounds: TileBounds;\n reparseOverscaled: boolean;\n isTileClipped: boolean;\n _tileJSONRequest: Cancelable;\n _loaded: boolean;\n\n constructor(id: string, options: VectorTileSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n\n this.type = 'vector';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.scheme = 'xyz';\n this.tileSize = 512;\n this.reparseOverscaled = true;\n this.isTileClipped = true;\n this._loaded = false;\n\n extend(this, pick(options, ['url', 'scheme', 'tileSize', 'promoteId']));\n this._options = extend({type: 'vector'}, options);\n\n this._collectResourceTiming = options.collectResourceTiming;\n\n if (this.tileSize !== 512) {\n throw new Error('vector tile sources must have a tileSize of 512');\n }\n\n this.setEventedParent(eventedParent);\n }\n\n load = () => {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {\n this._tileJSONRequest = null;\n this._loaded = true;\n this.map.style.sourceCaches[this.id].clearTiles();\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (tileJSON) {\n extend(this, tileJSON);\n if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);\n\n // `content` is included here to prevent a race condition where `Style#_updateSources` is called\n // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives\n // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n }\n });\n };\n\n loaded(): boolean {\n return this._loaded;\n }\n\n hasTile(tileID: OverscaledTileID) {\n return !this.tileBounds || this.tileBounds.contains(tileID.canonical);\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n setSourceProperty(callback: Function) {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n }\n\n callback();\n\n this.load();\n }\n\n /**\n * Sets the source `tiles` property and re-renders the map.\n *\n * @param tiles - An array of one or more tile source URLs, as in the TileJSON spec.\n * @returns `this`\n */\n setTiles(tiles: Array): this {\n this.setSourceProperty(() => {\n this._options.tiles = tiles;\n });\n\n return this;\n }\n\n /**\n * Sets the source `url` property and re-renders the map.\n *\n * @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`.\n * @returns `this`\n */\n setUrl(url: string): this {\n this.setSourceProperty(() => {\n this.url = url;\n this._options.url = url;\n });\n\n return this;\n }\n\n onRemove() {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n this._tileJSONRequest = null;\n }\n }\n\n serialize = (): VectorSourceSpecification => {\n return extend({}, this._options);\n };\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n const params = {\n request: this.map._requestManager.transformRequest(url, ResourceType.Tile),\n uid: tile.uid,\n tileID: tile.tileID,\n zoom: tile.tileID.overscaledZ,\n tileSize: this.tileSize * tile.tileID.overscaleFactor(),\n type: this.type,\n source: this.id,\n pixelRatio: this.map.getPixelRatio(),\n showCollisionBoxes: this.map.showCollisionBoxes,\n promoteId: this.promoteId\n };\n params.request.collectResourceTiming = this._collectResourceTiming;\n\n if (!tile.actor || tile.state === 'expired') {\n tile.actor = this.dispatcher.getActor();\n tile.request = tile.actor.send('loadTile', params, done.bind(this));\n } else if (tile.state === 'loading') {\n // schedule tile reloading after it has been loaded\n tile.reloadCallback = callback;\n } else {\n tile.request = tile.actor.send('reloadTile', params, done.bind(this));\n }\n\n function done(err, data) {\n delete tile.request;\n\n if (tile.aborted)\n return callback(null);\n\n if (err && err.status !== 404) {\n return callback(err);\n }\n\n if (data && data.resourceTiming)\n tile.resourceTiming = data.resourceTiming;\n\n if (this.map._refreshExpiredTiles && data) tile.setExpiryData(data);\n tile.loadVectorData(data, this.map.painter);\n\n callback(null);\n\n if (tile.reloadCallback) {\n this.loadTile(tile, tile.reloadCallback);\n tile.reloadCallback = null;\n }\n }\n }\n\n abortTile(tile: Tile) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n if (tile.actor) {\n tile.actor.send('abortTile', {uid: tile.uid, type: this.type, source: this.id}, undefined);\n }\n }\n\n unloadTile(tile: Tile) {\n tile.unloadVectorData();\n if (tile.actor) {\n tile.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}, undefined);\n }\n }\n\n hasTransition() {\n return false;\n }\n}\n","import {extend, pick} from '../util/util';\n\nimport {ImageRequest} from '../util/image_request';\n\nimport {ResourceType} from '../util/request_manager';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {loadTileJson} from './load_tilejson';\nimport {TileBounds} from './tile_bounds';\nimport {Texture} from '../render/texture';\n\nimport type {Source} from './source';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport type {\n RasterSourceSpecification,\n RasterDEMSourceSpecification\n} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A source containing raster tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('raster-source', {\n * 'type': 'raster',\n * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'],\n * 'tileSize': 256,\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('wms-test-source', {\n * 'type': 'raster',\n * // use the tiles option to specify a WMS tile source URL\n * 'tiles': [\n * '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'\n * ],\n * 'tileSize': 256\n * });\n * ```\n * @see [Add a raster tile source](https://maplibre.org/maplibre-gl-js/docs/examples/map-tiles/)\n * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/)\n * @see [Display a satellite map](https://maplibre.org/maplibre-gl-js/docs/examples/satellite-map/)\n */\nexport class RasterTileSource extends Evented implements Source {\n type: 'raster' | 'raster-dem';\n id: string;\n minzoom: number;\n maxzoom: number;\n url: string;\n scheme: string;\n tileSize: number;\n\n bounds: [number, number, number, number];\n tileBounds: TileBounds;\n roundZoom: boolean;\n dispatcher: Dispatcher;\n map: Map;\n tiles: Array;\n\n _loaded: boolean;\n _options: RasterSourceSpecification | RasterDEMSourceSpecification;\n _tileJSONRequest: Cancelable;\n\n constructor(id: string, options: RasterSourceSpecification | RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n this.setEventedParent(eventedParent);\n\n this.type = 'raster';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.roundZoom = true;\n this.scheme = 'xyz';\n this.tileSize = 512;\n this._loaded = false;\n\n this._options = extend({type: 'raster'}, options);\n extend(this, pick(options, ['url', 'scheme', 'tileSize']));\n }\n\n load() {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {\n this._tileJSONRequest = null;\n this._loaded = true;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (tileJSON) {\n extend(this, tileJSON);\n if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);\n\n // `content` is included here to prevent a race condition where `Style#_updateSources` is called\n // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives\n // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n }\n });\n }\n\n loaded(): boolean {\n return this._loaded;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n onRemove() {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n this._tileJSONRequest = null;\n }\n }\n\n setSourceProperty(callback: Function) {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n }\n\n callback();\n\n this.load();\n }\n\n /**\n * Sets the source `tiles` property and re-renders the map.\n *\n * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/)\n * @returns `this`\n */\n setTiles(tiles: Array): this {\n this.setSourceProperty(() => {\n this._options.tiles = tiles;\n });\n\n return this;\n }\n\n serialize() {\n return extend({}, this._options);\n }\n\n hasTile(tileID: OverscaledTileID) {\n return !this.tileBounds || this.tileBounds.contains(tileID.canonical);\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), (err, img, expiry) => {\n delete tile.request;\n\n if (tile.aborted) {\n tile.state = 'unloaded';\n callback(null);\n } else if (err) {\n tile.state = 'errored';\n callback(err);\n } else if (img) {\n if (this.map._refreshExpiredTiles && expiry) tile.setExpiryData(expiry);\n\n const context = this.map.painter.context;\n const gl = context.gl;\n tile.texture = this.map.painter.getTileTexture(img.width);\n if (tile.texture) {\n tile.texture.update(img, {useMipmap: true});\n } else {\n tile.texture = new Texture(context, img, gl.RGBA, {useMipmap: true});\n tile.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n\n if (context.extTextureFilterAnisotropic) {\n gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax);\n }\n }\n\n tile.state = 'loaded';\n\n callback(null);\n }\n }, this.map._refreshExpiredTiles);\n }\n\n abortTile(tile: Tile, callback: Callback) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n callback();\n }\n\n unloadTile(tile: Tile, callback: Callback) {\n if (tile.texture) this.map.painter.saveTileTexture(tile.texture);\n callback();\n }\n\n hasTransition() {\n return false;\n }\n}\n","export { getURL, getTileBBox, getMercCoords };\n\n\n/**\n * getURL\n *\n * @param {String} baseUrl Base url of the WMS server\n * @param {String} layer Layer name\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @param {Object} [options]\n * @param {String} [options.format='image/png']\n * @param {String} [options.service='WMS']\n * @param {String} [options.version='1.1.1']\n * @param {String} [options.request='GetMap']\n * @param {String} [options.srs='EPSG:3857']\n * @param {Number} [options.width='256']\n * @param {Number} [options.height='256']\n * @returns {String} url\n * @example\n * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';\n * var layer = 'Natural2015';\n * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19);\n */\nfunction getURL(baseUrl, layer, x, y, z, options) {\n options = options || {};\n\n var url = baseUrl + '?' + [\n 'bbox=' + getTileBBox(x, y, z),\n 'format=' + (options.format || 'image/png'),\n 'service=' + (options.service || 'WMS'),\n 'version=' + (options.version || '1.1.1'),\n 'request=' + (options.request || 'GetMap'),\n 'srs=' + (options.srs || 'EPSG:3857'),\n 'width=' + (options.width || 256),\n 'height=' + (options.height || 256),\n 'layers=' + layer\n ].join('&');\n\n return url;\n}\n\n\n/**\n * getTileBBox\n *\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @returns {String} String of the bounding box\n */\nfunction getTileBBox(x, y, z) {\n // for Google/OSM tile scheme we need to alter the y\n y = (Math.pow(2, z) - y - 1);\n\n var min = getMercCoords(x * 256, y * 256, z),\n max = getMercCoords((x + 1) * 256, (y + 1) * 256, z);\n\n return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1];\n}\n\n\n/**\n * getMercCoords\n *\n * @param {Number} x Pixel coordinate x\n * @param {Number} y Pixel coordinate y\n * @param {Number} z Tile zoom\n * @returns {Array} [x, y]\n */\nfunction getMercCoords(x, y, z) {\n var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z),\n merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0),\n merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0);\n\n return [merc_x, merc_y];\n}\n","import {getTileBBox} from '@mapbox/whoots-js';\nimport {EXTENT} from '../data/extent';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {register} from '../util/web_worker_transfer';\nimport {mat4} from 'gl-matrix';\nimport {ICanonicalTileID, IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A canonical way to define a tile ID\n */\nexport class CanonicalTileID implements ICanonicalTileID {\n z: number;\n x: number;\n y: number;\n key: string;\n\n constructor(z: number, x: number, y: number) {\n\n if (z < 0 || z > 25 || y < 0 || y >= Math.pow(2, z) || x < 0 || x >= Math.pow(2, z)) {\n throw new Error(`x=${x}, y=${y}, z=${z} outside of bounds. 0<=x<${Math.pow(2, z)}, 0<=y<${Math.pow(2, z)} 0<=z<=25 `);\n }\n\n this.z = z;\n this.x = x;\n this.y = y;\n this.key = calculateKey(0, z, z, x, y);\n }\n\n equals(id: ICanonicalTileID) {\n return this.z === id.z && this.x === id.x && this.y === id.y;\n }\n\n // given a list of urls, choose a url template and return a tile URL\n url(urls: Array, pixelRatio: number, scheme?: string | null) {\n const bbox = getTileBBox(this.x, this.y, this.z);\n const quadkey = getQuadkey(this.z, this.x, this.y);\n\n return urls[(this.x + this.y) % urls.length]\n .replace(/{prefix}/g, (this.x % 16).toString(16) + (this.y % 16).toString(16))\n .replace(/{z}/g, String(this.z))\n .replace(/{x}/g, String(this.x))\n .replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))\n .replace(/{ratio}/g, pixelRatio > 1 ? '@2x' : '')\n .replace(/{quadkey}/g, quadkey)\n .replace(/{bbox-epsg-3857}/g, bbox);\n }\n\n isChildOf(parent: ICanonicalTileID) {\n const dz = this.z - parent.z;\n return dz > 0 && parent.x === (this.x >> dz) && parent.y === (this.y >> dz);\n }\n\n getTilePoint(coord: IMercatorCoordinate) {\n const tilesAtZoom = Math.pow(2, this.z);\n return new Point(\n (coord.x * tilesAtZoom - this.x) * EXTENT,\n (coord.y * tilesAtZoom - this.y) * EXTENT);\n }\n\n toString() {\n return `${this.z}/${this.x}/${this.y}`;\n }\n}\n\n/**\n * @internal\n * An unwrapped tile identifier\n */\nexport class UnwrappedTileID {\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n\n constructor(wrap: number, canonical: CanonicalTileID) {\n this.wrap = wrap;\n this.canonical = canonical;\n this.key = calculateKey(wrap, canonical.z, canonical.z, canonical.x, canonical.y);\n }\n}\n\n/**\n * An overscaled tile identifier\n */\nexport class OverscaledTileID {\n overscaledZ: number;\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n posMatrix: mat4;\n\n constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number) {\n if (overscaledZ < z) throw new Error(`overscaledZ should be >= z; overscaledZ = ${overscaledZ}; z = ${z}`);\n this.overscaledZ = overscaledZ;\n this.wrap = wrap;\n this.canonical = new CanonicalTileID(z, +x, +y);\n this.key = calculateKey(wrap, overscaledZ, z, x, y);\n }\n\n clone() {\n return new OverscaledTileID(this.overscaledZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n equals(id: OverscaledTileID) {\n return this.overscaledZ === id.overscaledZ && this.wrap === id.wrap && this.canonical.equals(id.canonical);\n }\n\n scaledTo(targetZ: number) {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return new OverscaledTileID(targetZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return new OverscaledTileID(targetZ, this.wrap, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n /*\n * calculateScaledKey is an optimization:\n * when withWrap == true, implements the same as this.scaledTo(z).key,\n * when withWrap == false, implements the same as this.scaledTo(z).wrapped().key.\n */\n calculateScaledKey(targetZ: number, withWrap: boolean): string {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return calculateKey(this.wrap * +withWrap, targetZ, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return calculateKey(this.wrap * +withWrap, targetZ, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n isChildOf(parent: OverscaledTileID) {\n if (parent.wrap !== this.wrap) {\n // We can't be a child if we're in a different world copy\n return false;\n }\n const zDifference = this.canonical.z - parent.canonical.z;\n // We're first testing for z == 0, to avoid a 32 bit shift, which is undefined.\n return parent.overscaledZ === 0 || (\n parent.overscaledZ < this.overscaledZ &&\n parent.canonical.x === (this.canonical.x >> zDifference) &&\n parent.canonical.y === (this.canonical.y >> zDifference));\n }\n\n children(sourceMaxZoom: number) {\n if (this.overscaledZ >= sourceMaxZoom) {\n // return a single tile coord representing a an overscaled tile\n return [new OverscaledTileID(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)];\n }\n\n const z = this.canonical.z + 1;\n const x = this.canonical.x * 2;\n const y = this.canonical.y * 2;\n return [\n new OverscaledTileID(z, this.wrap, z, x, y),\n new OverscaledTileID(z, this.wrap, z, x + 1, y),\n new OverscaledTileID(z, this.wrap, z, x, y + 1),\n new OverscaledTileID(z, this.wrap, z, x + 1, y + 1)\n ];\n }\n\n isLessThan(rhs: OverscaledTileID) {\n if (this.wrap < rhs.wrap) return true;\n if (this.wrap > rhs.wrap) return false;\n\n if (this.overscaledZ < rhs.overscaledZ) return true;\n if (this.overscaledZ > rhs.overscaledZ) return false;\n\n if (this.canonical.x < rhs.canonical.x) return true;\n if (this.canonical.x > rhs.canonical.x) return false;\n\n if (this.canonical.y < rhs.canonical.y) return true;\n return false;\n }\n\n wrapped() {\n return new OverscaledTileID(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n unwrapTo(wrap: number) {\n return new OverscaledTileID(this.overscaledZ, wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n overscaleFactor() {\n return Math.pow(2, this.overscaledZ - this.canonical.z);\n }\n\n toUnwrapped() {\n return new UnwrappedTileID(this.wrap, this.canonical);\n }\n\n toString() {\n return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`;\n }\n\n getTilePoint(coord: MercatorCoordinate) {\n return this.canonical.getTilePoint(new MercatorCoordinate(coord.x - this.wrap, coord.y));\n }\n}\n\nfunction calculateKey(wrap: number, overscaledZ: number, z: number, x: number, y: number): string {\n wrap *= 2;\n if (wrap < 0) wrap = wrap * -1 - 1;\n const dim = 1 << z;\n return (dim * dim * wrap + dim * y + x).toString(36) + z.toString(36) + overscaledZ.toString(36);\n}\n\nfunction getQuadkey(z, x, y) {\n let quadkey = '', mask;\n for (let i = z; i > 0; i--) {\n mask = 1 << (i - 1);\n quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0));\n }\n return quadkey;\n}\n\nregister('CanonicalTileID', CanonicalTileID);\nregister('OverscaledTileID', OverscaledTileID, {omit: ['posMatrix']});\n","import {RGBAImage} from '../util/image';\n\nimport {warnOnce} from '../util/util';\nimport {register} from '../util/web_worker_transfer';\n\n// DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders\n// data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially\n// loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the\n// elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of\n// integer overflow when creating the texture used in the hillshadePrepare step.\n\n// DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8\n// surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a\n// tile's edge without backfilling from neighboring tiles.\n\nexport type DEMEncoding = 'mapbox' | 'terrarium' | 'custom'\n\nexport class DEMData {\n uid: string;\n data: Uint32Array;\n stride: number;\n dim: number;\n min: number;\n max: number;\n redFactor: number;\n greenFactor: number;\n blueFactor: number;\n baseShift: number;\n\n // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride\n // and dim is calculated as stride - 2.\n constructor(uid: string, data: RGBAImage, encoding: DEMEncoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {\n this.uid = uid;\n if (data.height !== data.width) throw new RangeError('DEM tiles must be square');\n if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {\n warnOnce(`\"${encoding}\" is not a valid encoding type. Valid types include \"mapbox\", \"terrarium\" and \"custom\".`);\n return;\n }\n this.stride = data.height;\n const dim = this.dim = data.height - 2;\n this.data = new Uint32Array(data.data.buffer);\n switch (encoding) {\n case 'terrarium':\n // unpacking formula for mapzen terrarium:\n // https://aws.amazon.com/public-datasets/terrain/\n this.redFactor = 256.0;\n this.greenFactor = 1.0;\n this.blueFactor = 1.0 / 256.0;\n this.baseShift = 32768.0;\n break;\n case 'custom':\n this.redFactor = redFactor;\n this.greenFactor = greenFactor;\n this.blueFactor = blueFactor;\n this.baseShift = baseShift;\n break;\n case 'mapbox':\n default:\n // unpacking formula for mapbox.terrain-rgb:\n // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb\n this.redFactor = 6553.6;\n this.greenFactor = 25.6;\n this.blueFactor = 0.1;\n this.baseShift = 10000.0;\n break;\n }\n\n // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image\n // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring\n // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder\n for (let x = 0; x < dim; x++) {\n // left vertical border\n this.data[this._idx(-1, x)] = this.data[this._idx(0, x)];\n // right vertical border\n this.data[this._idx(dim, x)] = this.data[this._idx(dim - 1, x)];\n // left horizontal border\n this.data[this._idx(x, -1)] = this.data[this._idx(x, 0)];\n // right horizontal border\n this.data[this._idx(x, dim)] = this.data[this._idx(x, dim - 1)];\n }\n // corners\n this.data[this._idx(-1, -1)] = this.data[this._idx(0, 0)];\n this.data[this._idx(dim, -1)] = this.data[this._idx(dim - 1, 0)];\n this.data[this._idx(-1, dim)] = this.data[this._idx(0, dim - 1)];\n this.data[this._idx(dim, dim)] = this.data[this._idx(dim - 1, dim - 1)];\n\n // calculate min/max values\n this.min = Number.MAX_SAFE_INTEGER;\n this.max = Number.MIN_SAFE_INTEGER;\n for (let x = 0; x < dim; x++) {\n for (let y = 0; y < dim; y++) {\n const ele = this.get(x, y);\n if (ele > this.max) this.max = ele;\n if (ele < this.min) this.min = ele;\n }\n }\n }\n\n get(x: number, y: number) {\n const pixels = new Uint8Array(this.data.buffer);\n const index = this._idx(x, y) * 4;\n return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);\n }\n\n getUnpackVector() {\n return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];\n }\n\n _idx(x: number, y: number) {\n if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) throw new RangeError('out of range source coordinates for DEM data');\n return (y + 1) * this.stride + (x + 1);\n }\n\n unpack(r: number, g: number, b: number) {\n return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);\n }\n\n getPixels() {\n return new RGBAImage({width: this.stride, height: this.stride}, new Uint8Array(this.data.buffer));\n }\n\n backfillBorder(borderTile: DEMData, dx: number, dy: number) {\n if (this.dim !== borderTile.dim) throw new Error('dem dimension mismatch');\n\n let xMin = dx * this.dim,\n xMax = dx * this.dim + this.dim,\n yMin = dy * this.dim,\n yMax = dy * this.dim + this.dim;\n\n switch (dx) {\n case -1:\n xMin = xMax - 1;\n break;\n case 1:\n xMax = xMin + 1;\n break;\n }\n\n switch (dy) {\n case -1:\n yMin = yMax - 1;\n break;\n case 1:\n yMax = yMin + 1;\n break;\n }\n\n const ox = -dx * this.dim;\n const oy = -dy * this.dim;\n for (let y = yMin; y < yMax; y++) {\n for (let x = xMin; x < xMax; x++) {\n this.data[this._idx(x, y)] = borderTile.data[this._idx(x + ox, y + oy)];\n }\n }\n }\n}\n\nregister('DEMData', DEMData);\n","import {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\nimport {extend, isImageBitmap, readImageUsingVideoFrame} from '../util/util';\nimport {Evented} from '../util/evented';\nimport {browser} from '../util/browser';\nimport {offscreenCanvasSupported} from '../util/offscreen_canvas_supported';\nimport {OverscaledTileID} from './tile_id';\nimport {RasterTileSource} from './raster_tile_source';\n// ensure DEMData is registered for worker transfer on main thread:\nimport '../data/dem_data';\nimport type {DEMEncoding} from '../data/dem_data';\n\nimport type {Source} from './source';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {RasterDEMSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {ExpiryData} from '../util/ajax';\nimport {isOffscreenCanvasDistorted} from '../util/offscreen_canvas_distorted';\nimport {RGBAImage} from '../util/image';\n\n/**\n * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n * This source can be used to show hillshading and 3D terrain\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('raster-dem-source', {\n * type: 'raster-dem',\n * url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',\n * tileSize: 256\n * });\n * ```\n * @see [3D Terrain](https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/)\n */\nexport class RasterDEMTileSource extends RasterTileSource implements Source {\n encoding: DEMEncoding;\n redFactor?: number;\n greenFactor?: number;\n blueFactor?: number;\n baseShift?: number;\n\n constructor(id: string, options: RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n this.type = 'raster-dem';\n this.maxzoom = 22;\n this._options = extend({type: 'raster-dem'}, options);\n this.encoding = options.encoding || 'mapbox';\n this.redFactor = options.redFactor;\n this.greenFactor = options.greenFactor;\n this.blueFactor = options.blueFactor;\n this.baseShift = options.baseShift;\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n const request = this.map._requestManager.transformRequest(url, ResourceType.Tile);\n tile.neighboringTiles = this._getNeighboringTiles(tile.tileID);\n tile.request = ImageRequest.getImage(request, async (err: Error, img: (HTMLImageElement | ImageBitmap), expiry: ExpiryData) => {\n delete tile.request;\n if (tile.aborted) {\n tile.state = 'unloaded';\n callback(null);\n } else if (err) {\n tile.state = 'errored';\n callback(err);\n } else if (img) {\n if (this.map._refreshExpiredTiles) tile.setExpiryData(expiry);\n const transfer = isImageBitmap(img) && offscreenCanvasSupported();\n const rawImageData = transfer ? img : await readImageNow(img);\n const params = {\n uid: tile.uid,\n coord: tile.tileID,\n source: this.id,\n rawImageData,\n encoding: this.encoding,\n redFactor: this.redFactor,\n greenFactor: this.greenFactor,\n blueFactor: this.blueFactor,\n baseShift: this.baseShift\n };\n\n if (!tile.actor || tile.state === 'expired') {\n tile.actor = this.dispatcher.getActor();\n tile.actor.send('loadDEMTile', params, done);\n }\n }\n }, this.map._refreshExpiredTiles);\n\n async function readImageNow(img: ImageBitmap | HTMLImageElement): Promise {\n if (typeof VideoFrame !== 'undefined' && isOffscreenCanvasDistorted()) {\n const width = img.width + 2;\n const height = img.height + 2;\n try {\n return new RGBAImage({width, height}, await readImageUsingVideoFrame(img, -1, -1, width, height));\n } catch (e) {\n // fall-back to browser canvas decoding\n }\n }\n return browser.getImageData(img, 1);\n }\n\n function done(err, data) {\n if (err) {\n tile.state = 'errored';\n callback(err);\n }\n\n if (data) {\n tile.dem = data;\n tile.needsHillshadePrepare = true;\n tile.needsTerrainPrepare = true;\n tile.state = 'loaded';\n callback(null);\n }\n }\n }\n\n _getNeighboringTiles(tileID: OverscaledTileID) {\n const canonical = tileID.canonical;\n const dim = Math.pow(2, canonical.z);\n\n const px = (canonical.x - 1 + dim) % dim;\n const pxw = canonical.x === 0 ? tileID.wrap - 1 : tileID.wrap;\n const nx = (canonical.x + 1 + dim) % dim;\n const nxw = canonical.x + 1 === dim ? tileID.wrap + 1 : tileID.wrap;\n\n const neighboringTiles = {};\n // add adjacent tiles\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y).key] = {backfilled: false};\n\n // Add upper neighboringTiles\n if (canonical.y > 0) {\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y - 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y - 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y - 1).key] = {backfilled: false};\n }\n // Add lower neighboringTiles\n if (canonical.y + 1 < dim) {\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y + 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y + 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y + 1).key] = {backfilled: false};\n }\n\n return neighboringTiles;\n }\n\n unloadTile(tile: Tile) {\n if (tile.demTexture) this.map.painter.saveTileTexture(tile.demTexture);\n if (tile.fbo) {\n tile.fbo.destroy();\n delete tile.fbo;\n }\n if (tile.dem) delete tile.dem;\n delete tile.neighboringTiles;\n\n tile.state = 'unloaded';\n if (tile.actor) {\n tile.actor.send('removeDEMTile', {uid: tile.uid, source: this.id});\n }\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\n\nimport {extend} from '../util/util';\nimport {EXTENT} from '../data/extent';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\n\nimport type {Source} from './source';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Actor} from '../util/actor';\nimport type {Callback} from '../types/callback';\nimport type {GeoJSONSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {GeoJSONSourceDiff} from './geojson_source_diff';\nimport type {Options, ClusterProperties} from 'supercluster';\n\nexport type GeoJSONSourceOptions = GeoJSONSourceSpecification & {\n workerOptions?: WorkerOptions;\n collectResourceTiming?: boolean;\n}\n\nexport type GeoJsonSourceOptions = {\n data?: GeoJSON.GeoJSON | string | undefined;\n cluster?: boolean;\n clusterMaxZoom?: number;\n clusterRadius?: number;\n clusterMinPoints?: number;\n generateId?: boolean;\n}\nexport type WorkerOptions = {\n source?: string;\n cluster?: boolean;\n geojsonVtOptions?: {\n buffer?: number;\n tolerance?: number;\n extent?: number;\n maxZoom?: number;\n linemetrics?: boolean;\n generateId?: boolean;\n };\n superclusterOptions?: Options;\n clusterProperties?: ClusterProperties;\n fliter?: any;\n promoteId?: any;\n collectResourceTiming?: boolean;\n}\n\n/**\n * The cluster options to set\n */\nexport type SetClusterOptions = {\n /**\n * Whether or not to cluster\n */\n cluster?: boolean;\n /**\n * The cluster's max zoom\n */\n clusterMaxZoom?: number;\n /**\n * The cluster's radius\n */\n clusterRadius?: number;\n}\n\n/**\n * A source containing GeoJSON.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-geojson) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'geojson',\n * data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'geojson',\n * data: {\n * \"type\": \"FeatureCollection\",\n * \"features\": [{\n * \"type\": \"Feature\",\n * \"properties\": {},\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [\n * -76.53063297271729,\n * 39.18174077994108\n * ]\n * }\n * }]\n * }\n * });\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setData({\n * \"type\": \"FeatureCollection\",\n * \"features\": [{\n * \"type\": \"Feature\",\n * \"properties\": { \"name\": \"Null Island\" },\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [ 0, 0 ]\n * }\n * }]\n * });\n * ```\n * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)\n * @see [Add a GeoJSON line](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-line/)\n * @see [Create a heatmap from points](https://maplibre.org/maplibre-gl-js/docs/examples/heatmap/)\n * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)\n */\nexport class GeoJSONSource extends Evented implements Source {\n type: 'geojson';\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution: string;\n promoteId: PromoteIdSpecification;\n\n isTileClipped: boolean;\n reparseOverscaled: boolean;\n _data: GeoJSON.GeoJSON | string | undefined;\n _options: GeoJsonSourceOptions;\n workerOptions: WorkerOptions;\n map: Map;\n actor: Actor;\n _pendingLoads: number;\n _collectResourceTiming: boolean;\n _removed: boolean;\n\n /** @internal */\n constructor(id: string, options: GeoJSONSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n\n this.id = id;\n\n // `type` is a property rather than a constant to make it easy for 3rd\n // parties to use GeoJSONSource to build their own source types.\n this.type = 'geojson';\n\n this.minzoom = 0;\n this.maxzoom = 18;\n this.tileSize = 512;\n this.isTileClipped = true;\n this.reparseOverscaled = true;\n this._removed = false;\n this._pendingLoads = 0;\n\n this.actor = dispatcher.getActor();\n this.setEventedParent(eventedParent);\n\n this._data = (options.data as any);\n this._options = extend({}, options);\n\n this._collectResourceTiming = options.collectResourceTiming;\n\n if (options.maxzoom !== undefined) this.maxzoom = options.maxzoom;\n if (options.type) this.type = options.type;\n if (options.attribution) this.attribution = options.attribution;\n this.promoteId = options.promoteId;\n\n const scale = EXTENT / this.tileSize;\n\n // sent to the worker, along with `url: ...` or `data: literal geojson`,\n // so that it can load/parse/index the geojson data\n // extending with `options.workerOptions` helps to make it easy for\n // third-party sources to hack/reuse GeoJSONSource.\n this.workerOptions = extend({\n source: this.id,\n cluster: options.cluster || false,\n geojsonVtOptions: {\n buffer: (options.buffer !== undefined ? options.buffer : 128) * scale,\n tolerance: (options.tolerance !== undefined ? options.tolerance : 0.375) * scale,\n extent: EXTENT,\n maxZoom: this.maxzoom,\n lineMetrics: options.lineMetrics || false,\n generateId: options.generateId || false\n },\n superclusterOptions: {\n maxZoom: options.clusterMaxZoom !== undefined ? options.clusterMaxZoom : this.maxzoom - 1,\n minPoints: Math.max(2, options.clusterMinPoints || 2),\n extent: EXTENT,\n radius: (options.clusterRadius || 50) * scale,\n log: false,\n generateId: options.generateId || false\n },\n clusterProperties: options.clusterProperties,\n filter: options.filter\n }, options.workerOptions);\n\n // send the promoteId to the worker to have more flexible updates, but only if it is a string\n if (typeof this.promoteId === 'string') {\n this.workerOptions.promoteId = this.promoteId;\n }\n }\n\n load = () => {\n this._updateWorkerData();\n };\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n /**\n * Sets the GeoJSON data and re-renders the map.\n *\n * @param data - A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files.\n * @returns `this`\n */\n setData(data: GeoJSON.GeoJSON | string): this {\n this._data = data;\n this._updateWorkerData();\n\n return this;\n }\n\n /**\n * Updates the source's GeoJSON, and re-renders the map.\n *\n * For sources with lots of features, this method can be used to make updates more quickly.\n *\n * This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature,\n * or by using the promoteId option to specify which property should be used as the ID.\n *\n * It is an error to call updateData on a source that did not have unique IDs for each of its features already.\n *\n * Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error.\n *\n * @param diff - The changes that need to be applied.\n * @returns `this`\n */\n updateData(diff: GeoJSONSourceDiff): this {\n this._updateWorkerData(diff);\n\n return this;\n }\n\n /**\n * To disable/enable clustering on the source options\n * @param options - The options to set\n * @returns `this`\n * @example\n * ```ts\n * map.getSource('some id').setClusterOptions({cluster: false});\n * map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14});\n * ```\n */\n setClusterOptions(options: SetClusterOptions): this {\n this.workerOptions.cluster = options.cluster;\n if (options) {\n if (options.clusterRadius !== undefined) this.workerOptions.superclusterOptions.radius = options.clusterRadius;\n if (options.clusterMaxZoom !== undefined) this.workerOptions.superclusterOptions.maxZoom = options.clusterMaxZoom;\n }\n this._updateWorkerData();\n return this;\n }\n\n /**\n * For clustered sources, fetches the zoom at which the given cluster expands.\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param callback - A callback to be called when the zoom value is retrieved (`(error, zoom) => { ... }`).\n * @returns `this`\n */\n getClusterExpansionZoom(clusterId: number, callback: Callback): this {\n this.actor.send('geojson.getClusterExpansionZoom', {clusterId, source: this.id}, callback);\n return this;\n }\n\n /**\n * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`).\n * @returns `this`\n */\n getClusterChildren(clusterId: number, callback: Callback>): this {\n this.actor.send('geojson.getClusterChildren', {clusterId, source: this.id}, callback);\n return this;\n }\n\n /**\n * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param limit - The maximum number of features to return.\n * @param offset - The number of features to skip (e.g. for pagination).\n * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`).\n * @returns `this`\n * @example\n * Retrieve cluster leaves on click\n * ```ts\n * map.on('click', 'clusters', function(e) {\n * let features = map.queryRenderedFeatures(e.point, {\n * layers: ['clusters']\n * });\n *\n * let clusterId = features[0].properties.cluster_id;\n * let pointCount = features[0].properties.point_count;\n * let clusterSource = map.getSource('clusters');\n *\n * clusterSource.getClusterLeaves(clusterId, pointCount, 0, function(error, features) {\n * // Print cluster leaves in the console\n * console.log('Cluster leaves:', error, features);\n * })\n * });\n * ```\n */\n getClusterLeaves(clusterId: number, limit: number, offset: number, callback: Callback>): this {\n this.actor.send('geojson.getClusterLeaves', {\n source: this.id,\n clusterId,\n limit,\n offset\n }, callback);\n return this;\n }\n\n /**\n * Responsible for invoking WorkerSource's geojson.loadData target, which\n * handles loading the geojson data and preparing to serve it up as tiles,\n * using geojson-vt or supercluster as appropriate.\n * @param diff - the diff object\n */\n _updateWorkerData(diff?: GeoJSONSourceDiff) {\n const options = extend({}, this.workerOptions);\n if (diff) {\n options.dataDiff = diff;\n } else if (typeof this._data === 'string') {\n options.request = this.map._requestManager.transformRequest(browser.resolveURL(this._data as string), ResourceType.Source);\n options.request.collectResourceTiming = this._collectResourceTiming;\n } else {\n options.data = JSON.stringify(this._data);\n }\n\n this._pendingLoads++;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n\n // target {this.type}.loadData rather than literally geojson.loadData,\n // so that other geojson-like source types can easily reuse this\n // implementation\n this.actor.send(`${this.type}.loadData`, options, (err, result) => {\n this._pendingLoads--;\n\n if (this._removed || (result && result.abandoned)) {\n this.fire(new Event('dataabort', {dataType: 'source'}));\n return;\n }\n\n let resourceTiming = null;\n if (result && result.resourceTiming && result.resourceTiming[this.id])\n resourceTiming = result.resourceTiming[this.id].slice(0);\n\n if (err) {\n this.fire(new ErrorEvent(err));\n return;\n }\n\n const data: any = {dataType: 'source'};\n if (this._collectResourceTiming && resourceTiming && resourceTiming.length > 0)\n extend(data, {resourceTiming});\n\n // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache\n // know its ok to start requesting tiles.\n this.fire(new Event('data', {...data, sourceDataType: 'metadata'}));\n this.fire(new Event('data', {...data, sourceDataType: 'content'}));\n });\n }\n\n loaded(): boolean {\n return this._pendingLoads === 0;\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const message = !tile.actor ? 'loadTile' : 'reloadTile';\n tile.actor = this.actor;\n const params = {\n type: this.type,\n uid: tile.uid,\n tileID: tile.tileID,\n zoom: tile.tileID.overscaledZ,\n maxZoom: this.maxzoom,\n tileSize: this.tileSize,\n source: this.id,\n pixelRatio: this.map.getPixelRatio(),\n showCollisionBoxes: this.map.showCollisionBoxes,\n promoteId: this.promoteId\n };\n\n tile.request = this.actor.send(message, params, (err, data) => {\n delete tile.request;\n tile.unloadVectorData();\n\n if (tile.aborted) {\n return callback(null);\n }\n\n if (err) {\n return callback(err);\n }\n\n tile.loadVectorData(data, this.map.painter, message === 'reloadTile');\n\n return callback(null);\n });\n }\n\n abortTile(tile: Tile) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n tile.aborted = true;\n }\n\n unloadTile(tile: Tile) {\n tile.unloadVectorData();\n this.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id});\n }\n\n onRemove() {\n this._removed = true;\n this.actor.send('removeSource', {type: this.type, source: this.id});\n }\n\n serialize = (): GeoJSONSourceSpecification => {\n return extend({}, this._options, {\n type: this.type,\n data: this._data\n });\n };\n\n hasTransition() {\n return false;\n }\n}\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos', type: 'Int16', components: 2},\n {name: 'a_texture_pos', type: 'Int16', components: 2}\n]);\n","import {CanonicalTileID} from './tile_id';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\nimport {EXTENT} from '../data/extent';\nimport {RasterBoundsArray} from '../data/array_types.g';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\n\nimport type {Source} from './source';\nimport type {CanvasSourceSpecification} from './canvas_source';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {\n ImageSourceSpecification,\n VideoSourceSpecification\n} from '@maplibre/maplibre-gl-style-spec';\nimport {Cancelable} from '../types/cancelable';\n\n/**\n * Four geographical coordinates,\n * represented as arrays of longitude and latitude numbers, which define the corners of the image.\n * The coordinates start at the top left corner of the image and proceed in clockwise order.\n * They do not have to represent a rectangle.\n */\nexport type Coordinates = [[number, number], [number, number], [number, number], [number, number]];\n\n/**\n * The options object for the {@link ImageSource#updateImage} method\n */\nexport type UpdateImageOptions = {\n /**\n * Required image URL.\n */\n url: string;\n /**\n * The image coordinates\n */\n coordinates?: Coordinates;\n}\n\n/**\n * A data source containing an image.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-image) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'image',\n * url: 'https://www.maplibre.org/images/foo.png',\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update coordinates\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * // update url and coordinates simultaneously\n * mySource.updateImage({\n * url: 'https://www.maplibre.org/images/bar.png',\n * coordinates: [\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]\n * })\n *\n * map.removeSource('some id'); // remove\n * ```\n */\nexport class ImageSource extends Evented implements Source {\n type: string;\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n url: string;\n\n coordinates: Coordinates;\n tiles: {[_: string]: Tile};\n options: any;\n dispatcher: Dispatcher;\n map: Map;\n texture: Texture | null;\n image: HTMLImageElement | ImageBitmap;\n tileID: CanonicalTileID;\n _boundsArray: RasterBoundsArray;\n boundsBuffer: VertexBuffer;\n boundsSegments: SegmentVector;\n _loaded: boolean;\n _request: Cancelable;\n\n /** @internal */\n constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n this.coordinates = options.coordinates;\n\n this.type = 'image';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.tileSize = 512;\n this.tiles = {};\n this._loaded = false;\n\n this.setEventedParent(eventedParent);\n\n this.options = options;\n }\n\n load = (newCoordinates?: Coordinates, successCallback?: () => void) => {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n\n this.url = this.options.url;\n\n this._request = ImageRequest.getImage(this.map._requestManager.transformRequest(this.url, ResourceType.Image), (err, image) => {\n this._request = null;\n this._loaded = true;\n\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (image) {\n this.image = image;\n if (newCoordinates) {\n this.coordinates = newCoordinates;\n }\n if (successCallback) {\n successCallback();\n }\n this._finishLoading();\n }\n });\n };\n\n loaded(): boolean {\n return this._loaded;\n }\n\n /**\n * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing,\n * set the `raster-fade-duration` paint property on the raster layer to 0.\n *\n * @param options - The options object.\n * @returns `this`\n */\n updateImage(options: UpdateImageOptions): this {\n if (!options.url) {\n return this;\n }\n\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n\n this.options.url = options.url;\n this.load(options.coordinates, () => { this.texture = null; });\n return this;\n }\n\n _finishLoading() {\n if (this.map) {\n this.setCoordinates(this.coordinates);\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n }\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n onRemove() {\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n }\n\n /**\n * Sets the image's coordinates and re-renders the map.\n *\n * @param coordinates - Four geographical coordinates,\n * represented as arrays of longitude and latitude numbers, which define the corners of the image.\n * The coordinates start at the top left corner of the image and proceed in clockwise order.\n * They do not have to represent a rectangle.\n * @returns `this`\n */\n setCoordinates(coordinates: Coordinates): this {\n this.coordinates = coordinates;\n\n // Calculate which mercator tile is suitable for rendering the video in\n // and create a buffer with the corner coordinates. These coordinates\n // may be outside the tile, because raster tiles aren't clipped when rendering.\n\n // transform the geo coordinates into (zoom 0) tile space coordinates\n const cornerCoords = coordinates.map(MercatorCoordinate.fromLngLat);\n\n // Compute the coordinates of the tile we'll use to hold this image's\n // render data\n this.tileID = getCoordinatesCenterTileID(cornerCoords);\n\n // Constrain min/max zoom to our tile's zoom level in order to force\n // SourceCache to request this tile (no matter what the map's zoom\n // level)\n this.minzoom = this.maxzoom = this.tileID.z;\n\n // Transform the corner coordinates into the coordinate space of our\n // tile.\n const tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round());\n\n this._boundsArray = new RasterBoundsArray();\n this._boundsArray.emplaceBack(tileCoords[0].x, tileCoords[0].y, 0, 0);\n this._boundsArray.emplaceBack(tileCoords[1].x, tileCoords[1].y, EXTENT, 0);\n this._boundsArray.emplaceBack(tileCoords[3].x, tileCoords[3].y, 0, EXTENT);\n this._boundsArray.emplaceBack(tileCoords[2].x, tileCoords[2].y, EXTENT, EXTENT);\n\n if (this.boundsBuffer) {\n this.boundsBuffer.destroy();\n delete this.boundsBuffer;\n }\n\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n return this;\n }\n\n prepare = () => {\n if (Object.keys(this.tiles).length === 0 || !this.image) {\n return;\n }\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.image, gl.RGBA);\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n loadTile(tile: Tile, callback: Callback) {\n // We have a single tile -- whose coordinates are this.tileID -- that\n // covers the image we want to render. If that's the one being\n // requested, set it up with the image; otherwise, mark the tile as\n // `errored` to indicate that we have no data for it.\n // If the world wraps, we may have multiple \"wrapped\" copies of the\n // single tile.\n if (this.tileID && this.tileID.equals(tile.tileID.canonical)) {\n this.tiles[String(tile.tileID.wrap)] = tile;\n tile.buckets = {};\n callback(null);\n } else {\n tile.state = 'errored';\n callback(null);\n }\n }\n\n serialize = (): ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification => {\n return {\n type: 'image',\n url: this.options.url,\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return false;\n }\n}\n\n/**\n * Given a list of coordinates, get their center as a coordinate.\n *\n * @returns centerpoint\n * @internal\n */\nexport function getCoordinatesCenterTileID(coords: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const coord of coords) {\n minX = Math.min(minX, coord.x);\n minY = Math.min(minY, coord.y);\n maxX = Math.max(maxX, coord.x);\n maxY = Math.max(maxY, coord.y);\n }\n\n const dx = maxX - minX;\n const dy = maxY - minY;\n const dMax = Math.max(dx, dy);\n const zoom = Math.max(0, Math.floor(-Math.log(dMax) / Math.LN2));\n const tilesAtZoom = Math.pow(2, zoom);\n\n return new CanonicalTileID(\n zoom,\n Math.floor((minX + maxX) / 2 * tilesAtZoom),\n Math.floor((minY + maxY) / 2 * tilesAtZoom));\n}\n","import {getVideo} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\n\nimport {ImageSource} from './image_source';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {Event, ErrorEvent} from '../util/evented';\nimport {ValidationError} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Evented} from '../util/evented';\nimport type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A data source containing video.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-video) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'video',\n * url: [\n * 'https://www.mapbox.com/blog/assets/baltimore-smoke.mp4',\n * 'https://www.mapbox.com/blog/assets/baltimore-smoke.webm'\n * ],\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * map.removeSource('some id'); // remove\n * ```\n * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)\n *\n * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.\n * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,\n * set the layer's `raster-fade-duration` property to `0`.\n */\nexport class VideoSource extends ImageSource {\n options: VideoSourceSpecification;\n urls: Array;\n video: HTMLVideoElement;\n roundZoom: boolean;\n\n constructor(id: string, options: VideoSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n this.roundZoom = true;\n this.type = 'video';\n this.options = options;\n }\n\n load = () => {\n this._loaded = false;\n const options = this.options;\n\n this.urls = [];\n for (const url of options.urls) {\n this.urls.push(this.map._requestManager.transformRequest(url, ResourceType.Source).url);\n }\n\n getVideo(this.urls, (err, video) => {\n this._loaded = true;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (video) {\n this.video = video;\n this.video.loop = true;\n\n // Start repainting when video starts playing. hasTransition() will then return\n // true to trigger additional frames as long as the videos continues playing.\n this.video.addEventListener('playing', () => {\n this.map.triggerRepaint();\n });\n\n if (this.map) {\n this.video.play();\n }\n\n this._finishLoading();\n }\n });\n };\n\n /**\n * Pauses the video.\n */\n pause() {\n if (this.video) {\n this.video.pause();\n }\n }\n\n /**\n * Plays the video.\n */\n play() {\n if (this.video) {\n this.video.play();\n }\n }\n\n /**\n * Sets playback to a timestamp, in seconds.\n */\n seek(seconds: number) {\n if (this.video) {\n const seekableRange = this.video.seekable;\n if (seconds < seekableRange.start(0) || seconds > seekableRange.end(0)) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`, null, `Playback for this video can be set only between the ${seekableRange.start(0)} and ${seekableRange.end(0)}-second mark.`)));\n } else this.video.currentTime = seconds;\n }\n }\n\n /**\n * Returns the HTML `video` element.\n *\n * @returns The HTML `video` element.\n */\n getVideo(): HTMLVideoElement {\n return this.video;\n }\n\n onAdd(map: Map) {\n if (this.map) return;\n this.map = map;\n this.load();\n if (this.video) {\n this.video.play();\n this.setCoordinates(this.coordinates);\n }\n }\n\n /**\n * Sets the video's coordinates and re-renders the map.\n *\n * @returns `this`\n */\n prepare = (): this => {\n if (Object.keys(this.tiles).length === 0 || this.video.readyState < 2) {\n return; // not enough data for current position\n }\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.video, gl.RGBA);\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n } else if (!this.video.paused) {\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, this.video);\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n serialize = (): VideoSourceSpecification => {\n return {\n type: 'video',\n urls: this.urls,\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return this.video && !this.video.paused;\n }\n}\n","import {ImageSource} from './image_source';\n\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {Event, ErrorEvent} from '../util/evented';\nimport {ValidationError} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Evented} from '../util/evented';\n\n/**\n * Options to add a canvas source type to the map.\n */\nexport type CanvasSourceSpecification = {\n /**\n * Source type. Must be `\"canvas\"`.\n */\n type: 'canvas';\n /**\n * Four geographical coordinates denoting where to place the corners of the canvas, specified in `[longitude, latitude]` pairs.\n */\n coordinates: [[number, number], [number, number], [number, number], [number, number]];\n /**\n * Whether the canvas source is animated. If the canvas is static (i.e. pixels do not need to be re-read on every frame), `animate` should be set to `false` to improve performance.\n * @defaultValue true\n */\n animate?: boolean;\n /**\n * Canvas source from which to read pixels. Can be a string representing the ID of the canvas element, or the `HTMLCanvasElement` itself.\n */\n canvas?: string | HTMLCanvasElement;\n};\n\n/**\n * A data source containing the contents of an HTML canvas. See {@link CanvasSourceSpecification} for detailed documentation of options.\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'canvas',\n * canvas: 'idOfMyHTMLCanvas',\n * animate: true,\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * map.removeSource('some id'); // remove\n * ```\n */\nexport class CanvasSource extends ImageSource {\n options: CanvasSourceSpecification;\n animate: boolean;\n canvas: HTMLCanvasElement;\n width: number;\n height: number;\n /**\n * Enables animation. The image will be copied from the canvas to the map on each frame.\n */\n play: () => void;\n /**\n * Disables animation. The map will display a static copy of the canvas image.\n */\n pause: () => void;\n _playing: boolean;\n\n /** @internal */\n constructor(id: string, options: CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n\n // We build in some validation here, since canvas sources aren't included in the style spec:\n if (!options.coordinates) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property \"coordinates\"')));\n } else if (!Array.isArray(options.coordinates) || options.coordinates.length !== 4 ||\n options.coordinates.some(c => !Array.isArray(c) || c.length !== 2 || c.some(l => typeof l !== 'number'))) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '\"coordinates\" property must be an array of 4 longitude/latitude array pairs')));\n }\n\n if (options.animate && typeof options.animate !== 'boolean') {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'optional \"animate\" property must be a boolean value')));\n }\n\n if (!options.canvas) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property \"canvas\"')));\n } else if (typeof options.canvas !== 'string' && !(options.canvas instanceof HTMLCanvasElement)) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '\"canvas\" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance')));\n }\n\n this.options = options;\n this.animate = options.animate !== undefined ? options.animate : true;\n }\n\n load = () => {\n this._loaded = true;\n if (!this.canvas) {\n this.canvas = (this.options.canvas instanceof HTMLCanvasElement) ?\n this.options.canvas :\n document.getElementById(this.options.canvas) as HTMLCanvasElement;\n // cast to HTMLCanvasElement in else of ternary\n // should we do a safety check and throw if it's not actually HTMLCanvasElement?\n }\n this.width = this.canvas.width;\n this.height = this.canvas.height;\n\n if (this._hasInvalidDimensions()) {\n this.fire(new ErrorEvent(new Error('Canvas dimensions cannot be less than or equal to zero.')));\n return;\n }\n\n this.play = function() {\n this._playing = true;\n this.map.triggerRepaint();\n };\n\n this.pause = function() {\n if (this._playing) {\n this.prepare();\n this._playing = false;\n }\n };\n\n this._finishLoading();\n };\n\n /**\n * Returns the HTML `canvas` element.\n *\n * @returns The HTML `canvas` element.\n */\n getCanvas(): HTMLCanvasElement {\n return this.canvas;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n if (this.canvas) {\n if (this.animate) this.play();\n }\n }\n\n onRemove() {\n this.pause();\n }\n\n prepare = () => {\n let resize = false;\n if (this.canvas.width !== this.width) {\n this.width = this.canvas.width;\n resize = true;\n }\n if (this.canvas.height !== this.height) {\n this.height = this.canvas.height;\n resize = true;\n }\n\n if (this._hasInvalidDimensions()) return;\n\n if (Object.keys(this.tiles).length === 0) return; // not enough data for current position\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.canvas, gl.RGBA, {premultiply: true});\n } else if (resize || this._playing) {\n this.texture.update(this.canvas, {premultiply: true});\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n serialize = (): CanvasSourceSpecification => {\n return {\n type: 'canvas',\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return this._playing;\n }\n\n _hasInvalidDimensions() {\n for (const x of [this.canvas.width, this.canvas.height]) {\n if (isNaN(x) || x <= 0) return true;\n }\n return false;\n }\n}\n","import {VectorTileSource} from '../source/vector_tile_source';\nimport {RasterTileSource} from '../source/raster_tile_source';\nimport {RasterDEMTileSource} from '../source/raster_dem_tile_source';\nimport {GeoJSONSource} from '../source/geojson_source';\nimport {VideoSource} from '../source/video_source';\nimport {ImageSource} from '../source/image_source';\nimport {CanvasSource} from '../source/canvas_source';\n\nimport type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Event, Evented} from '../util/evented';\nimport type {Map} from '../ui/map';\nimport type {Tile} from './tile';\nimport type {OverscaledTileID, CanonicalTileID} from './tile_id';\nimport type {Callback} from '../types/callback';\nimport type {CanvasSourceSpecification} from '../source/canvas_source';\n\nconst registeredSources = {} as {[key:string]: SourceClass};\n\n/**\n * The `Source` interface must be implemented by each source type, including \"core\" types (`vector`, `raster`,\n * `video`, etc.) and all custom, third-party types.\n *\n * @event `data` - Fired with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata\n * has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}`\n * to indicate that the source data has changed, so that any current caches should be flushed.\n *\n * @group Sources\n */\nexport interface Source {\n readonly type: string;\n /**\n * The id for the source. Must not be used by any existing source.\n */\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution?: string;\n /**\n * `true` if zoom levels are rounded to the nearest integer in the source data, `false` if they are floor-ed to the nearest integer.\n */\n roundZoom?: boolean;\n /**\n * `false` if tiles can be drawn outside their boundaries, `true` if they cannot.\n */\n isTileClipped?: boolean;\n tileID?: CanonicalTileID;\n /**\n * `true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not.\n */\n reparseOverscaled?: boolean;\n vectorLayerIds?: Array;\n hasTransition(): boolean;\n loaded(): boolean;\n fire(event: Event): unknown;\n readonly onAdd?: (map: Map) => void;\n readonly onRemove?: (map: Map) => void;\n loadTile(tile: Tile, callback: Callback): void;\n readonly hasTile?: (tileID: OverscaledTileID) => boolean;\n readonly abortTile?: (tile: Tile, callback: Callback) => void;\n readonly unloadTile?: (tile: Tile, callback: Callback) => void;\n /**\n * @returns A plain (stringifiable) JS object representing the current state of the source.\n * Creating a source using the returned object as the `options` should result in a Source that is\n * equivalent to this one.\n */\n serialize(): any;\n readonly prepare?: () => void;\n}\n\n/**\n * A supporting type to the source definition\n */\ntype SourceStatics = {\n /*\n * An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource}\n * implementation for this Source type by calling `self.registerWorkerSource(workerSource: WorkerSource)`.\n */\n workerSourceURL?: URL;\n};\n\n/**\n * A general definition of a {@link Source} class for factory usage\n */\nexport type SourceClass = {\n new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source;\n} & SourceStatics;\n\n/**\n * Creates a tiled data source instance given an options object.\n *\n * @param id - The id for the source. Must not be used by any existing source.\n * @param specification - Source options, specific to the source type (except for `options.type`, which is always required).\n * @param source - A source definition object compliant with\n * [`maplibre-gl-style-spec`](https://maplibre.org/maplibre-style-spec/#sources) or, for a third-party source type,\n * with that type's requirements.\n * @param dispatcher - A {@link Dispatcher} instance, which can be used to send messages to the workers.\n * @returns a newly created source\n */\nexport const create = (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source => {\n\n const Class = getSourceType(specification.type);\n const source = new Class(id, specification, dispatcher, eventedParent);\n\n if (source.id !== id) {\n throw new Error(`Expected Source id to be ${id} instead of ${source.id}`);\n }\n\n return source;\n};\n\nexport const getSourceType = (name: string): SourceClass => {\n switch (name) {\n case 'geojson':\n return GeoJSONSource;\n case 'image':\n return ImageSource;\n case 'raster':\n return RasterTileSource;\n case 'raster-dem':\n return RasterDEMTileSource;\n case 'vector':\n return VectorTileSource;\n case 'video':\n return VideoSource;\n case 'canvas':\n return CanvasSource;\n }\n return registeredSources[name];\n};\n\nexport const setSourceType = (name: string, type: SourceClass) => {\n registeredSources[name] = type;\n};\n\nexport interface Actor {\n send(type: string, data: any, callback: Callback): void;\n}\n","import type {SourceCache} from './source_cache';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CollisionIndex} from '../symbol/collision_index';\nimport type {Transform} from '../geo/transform';\nimport type {RetainedQueryData} from '../symbol/placement';\nimport type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type Point from '@mapbox/point-geometry';\nimport {mat4} from 'gl-matrix';\n\n/**\n * Options to pass to query the map for the rendered features\n */\nexport type QueryRenderedFeaturesOptions = {\n /**\n * An array of [style layer IDs](https://maplibre.org/maplibre-style-spec/#layer-id) for the query to inspect.\n * Only features within these layers will be returned. If this parameter is undefined, all layers will be checked.\n */\n layers?: Array;\n /**\n * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) to limit query results.\n */\n filter?: FilterSpecification;\n /**\n * An array of string representing the available images\n */\n availableImages?: Array;\n /**\n * Whether to check if the [options.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n */\n validate?: boolean;\n};\n\n/**\n * The options object related to the {@link Map#queryRenderedFeatures} method\n */\nexport type QuerySourceFeatureOptions = {\n /**\n * The name of the source layer to query. *For vector tile sources, this parameter is required.* For GeoJSON sources, it is ignored.\n */\n sourceLayer?: string;\n /**\n * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter)\n * to limit query results.\n */\n filter?: FilterSpecification;\n /**\n * Whether to check if the [parameters.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n * @defaultValue true\n */\n validate?: boolean;\n}\n\n/*\n * Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates.\n */\nfunction getPixelPosMatrix(transform, tileID) {\n const t = mat4.create();\n mat4.translate(t, t, [1, 1, 0]);\n mat4.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]);\n return mat4.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped()));\n}\n\nfunction queryIncludes3DLayer(layers: Array, styleLayers: {[_: string]: StyleLayer}, sourceID: string) {\n if (layers) {\n for (const layerID of layers) {\n const layer = styleLayers[layerID];\n if (layer && layer.source === sourceID && layer.type === 'fill-extrusion') {\n return true;\n }\n }\n } else {\n for (const key in styleLayers) {\n const layer = styleLayers[key];\n if (layer.source === sourceID && layer.type === 'fill-extrusion') {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function queryRenderedFeatures(\n sourceCache: SourceCache,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n queryGeometry: Array,\n params: QueryRenderedFeaturesOptions,\n transform: Transform\n): { [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> } {\n\n const has3DLayer = queryIncludes3DLayer(params && params.layers, styleLayers, sourceCache.id);\n const maxPitchScaleFactor = transform.maxPitchScaleFactor();\n const tilesIn = sourceCache.tilesIn(queryGeometry, maxPitchScaleFactor, has3DLayer);\n\n tilesIn.sort(sortTilesIn);\n const renderedFeatureLayers = [];\n for (const tileIn of tilesIn) {\n renderedFeatureLayers.push({\n wrappedTileID: tileIn.tileID.wrapped().key,\n queryResults: tileIn.tile.queryRenderedFeatures(\n styleLayers,\n serializedLayers,\n sourceCache._state,\n tileIn.queryGeometry,\n tileIn.cameraQueryGeometry,\n tileIn.scale,\n params,\n transform,\n maxPitchScaleFactor,\n getPixelPosMatrix(sourceCache.transform, tileIn.tileID))\n });\n }\n\n const result = mergeRenderedFeatureLayers(renderedFeatureLayers);\n\n // Merge state from SourceCache into the results\n for (const layerID in result) {\n result[layerID].forEach((featureWrapper) => {\n const feature = featureWrapper.feature as MapGeoJSONFeature;\n const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id);\n feature.source = feature.layer.source;\n if (feature.layer['source-layer']) {\n feature.sourceLayer = feature.layer['source-layer'];\n }\n feature.state = state;\n });\n }\n return result;\n}\n\nexport function queryRenderedSymbols(styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: StyleLayer},\n sourceCaches: {[_: string]: SourceCache},\n queryGeometry: Array,\n params: QueryRenderedFeaturesOptions,\n collisionIndex: CollisionIndex,\n retainedQueryData: {\n [_: number]: RetainedQueryData;\n }) {\n const result = {};\n const renderedSymbols = collisionIndex.queryRenderedSymbols(queryGeometry);\n const bucketQueryData = [];\n for (const bucketInstanceId of Object.keys(renderedSymbols).map(Number)) {\n bucketQueryData.push(retainedQueryData[bucketInstanceId]);\n }\n bucketQueryData.sort(sortTilesIn);\n\n for (const queryData of bucketQueryData) {\n const bucketSymbols = queryData.featureIndex.lookupSymbolFeatures(\n renderedSymbols[queryData.bucketInstanceId],\n serializedLayers,\n queryData.bucketIndex,\n queryData.sourceLayerIndex,\n params.filter,\n params.layers,\n params.availableImages,\n styleLayers);\n\n for (const layerID in bucketSymbols) {\n const resultFeatures = result[layerID] = result[layerID] || [];\n const layerSymbols = bucketSymbols[layerID];\n layerSymbols.sort((a, b) => {\n // Match topDownFeatureComparator from FeatureIndex, but using\n // most recent sorting of features from bucket.sortFeatures\n const featureSortOrder = queryData.featureSortOrder;\n if (featureSortOrder) {\n // queryRenderedSymbols documentation says we'll return features in\n // \"top-to-bottom\" rendering order (aka last-to-first).\n // Actually there can be multiple symbol instances per feature, so\n // we sort each feature based on the first matching symbol instance.\n const sortedA = featureSortOrder.indexOf(a.featureIndex);\n const sortedB = featureSortOrder.indexOf(b.featureIndex);\n return sortedB - sortedA;\n } else {\n // Bucket hasn't been re-sorted based on angle, so use the\n // reverse of the order the features appeared in the data.\n return b.featureIndex - a.featureIndex;\n }\n });\n for (const symbolFeature of layerSymbols) {\n resultFeatures.push(symbolFeature);\n }\n }\n }\n\n // Merge state from SourceCache into the results\n for (const layerName in result) {\n result[layerName].forEach((featureWrapper) => {\n const feature = featureWrapper.feature;\n const layer = styleLayers[layerName];\n const sourceCache = sourceCaches[layer.source];\n const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id);\n feature.source = feature.layer.source;\n if (feature.layer['source-layer']) {\n feature.sourceLayer = feature.layer['source-layer'];\n }\n feature.state = state;\n });\n }\n return result;\n}\n\nexport function querySourceFeatures(sourceCache: SourceCache, params: QuerySourceFeatureOptions) {\n const tiles = sourceCache.getRenderableIds().map((id) => {\n return sourceCache.getTileByID(id);\n });\n\n const result = [];\n\n const dataTiles = {};\n for (let i = 0; i < tiles.length; i++) {\n const tile = tiles[i];\n const dataID = tile.tileID.canonical.key;\n if (!dataTiles[dataID]) {\n dataTiles[dataID] = true;\n tile.querySourceFeatures(result, params);\n }\n }\n\n return result;\n}\n\nfunction sortTilesIn(a, b) {\n const idA = a.tileID;\n const idB = b.tileID;\n return (idA.overscaledZ - idB.overscaledZ) || (idA.canonical.y - idB.canonical.y) || (idA.wrap - idB.wrap) || (idA.canonical.x - idB.canonical.x);\n}\n\nfunction mergeRenderedFeatureLayers(tiles) {\n // Merge results from all tiles, but if two tiles share the same\n // wrapped ID, don't duplicate features between the two tiles\n const result = {};\n const wrappedIDLayerMap = {};\n for (const tile of tiles) {\n const queryResults = tile.queryResults;\n const wrappedID = tile.wrappedTileID;\n const wrappedIDLayers = wrappedIDLayerMap[wrappedID] = wrappedIDLayerMap[wrappedID] || {};\n for (const layerID in queryResults) {\n const tileFeatures = queryResults[layerID];\n const wrappedIDFeatures = wrappedIDLayers[layerID] = wrappedIDLayers[layerID] || {};\n const resultFeatures = result[layerID] = result[layerID] || [];\n for (const tileFeature of tileFeatures) {\n if (!wrappedIDFeatures[tileFeature.featureIndex]) {\n wrappedIDFeatures[tileFeature.featureIndex] = true;\n resultFeatures.push(tileFeature);\n }\n }\n }\n }\n return result;\n}\n","export class DictionaryCoder {\n _stringToNumber: {[_: string]: number};\n _numberToString: Array;\n\n constructor(strings: Array) {\n this._stringToNumber = {};\n this._numberToString = [];\n for (let i = 0; i < strings.length; i++) {\n const string = strings[i];\n this._stringToNumber[string] = i;\n this._numberToString[i] = string;\n }\n }\n\n encode(string: string) {\n return this._stringToNumber[string];\n }\n\n decode(n: number) {\n if (n >= this._numberToString.length) throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`);\n return this._numberToString[n];\n }\n}\n","import type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveKeys = T extends T ? keyof T : never;\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveOmit> = T extends unknown\n ? Omit\n : never;\n\n/**\n * An extended geojson feature used by the events to return data to the listener\n */\nexport type MapGeoJSONFeature = GeoJSONFeature & {\n layer: DistributiveOmit & {source: string};\n source: string;\n sourceLayer?: string;\n state: { [key: string]: any };\n}\n\n/**\n * A geojson feature\n */\nexport class GeoJSONFeature {\n type: 'Feature';\n _geometry: GeoJSON.Geometry;\n properties: { [name: string]: any };\n id: number | string | undefined;\n\n _vectorTileFeature: VectorTileFeature;\n\n constructor(vectorTileFeature: VectorTileFeature, z: number, x: number, y: number, id: string | number | undefined) {\n this.type = 'Feature';\n\n this._vectorTileFeature = vectorTileFeature;\n (vectorTileFeature as any)._z = z;\n (vectorTileFeature as any)._x = x;\n (vectorTileFeature as any)._y = y;\n\n this.properties = vectorTileFeature.properties;\n this.id = id;\n }\n\n get geometry(): GeoJSON.Geometry {\n if (this._geometry === undefined) {\n this._geometry = this._vectorTileFeature.toGeoJSON(\n (this._vectorTileFeature as any)._x,\n (this._vectorTileFeature as any)._y,\n (this._vectorTileFeature as any)._z).geometry;\n }\n return this._geometry;\n }\n\n set geometry(g: GeoJSON.Geometry) {\n this._geometry = g;\n }\n\n toJSON() {\n const json: any = {\n geometry: this.geometry\n };\n for (const i in this) {\n if (i === '_geometry' || i === '_vectorTileFeature') continue;\n json[i] = (this)[i];\n }\n return json;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {loadGeometry} from './load_geometry';\nimport {toEvaluationFeature} from './evaluation_feature';\nimport {EXTENT} from './extent';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {TransferableGridIndex} from '../util/transferable_grid_index';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {arraysIntersect, mapObject, extend} from '../util/util';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {polygonIntersectsBox} from '../util/intersection_tests';\nimport {PossiblyEvaluated} from '../style/properties';\nimport {FeatureIndexArray} from './array_types.g';\nimport {mat4} from 'gl-matrix';\n\nimport type {StyleLayer} from '../style/style_layer';\nimport type {FeatureFilter, FeatureState, FilterSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\n\ntype QueryParameters = {\n scale: number;\n pixelPosMatrix: mat4;\n transform: Transform;\n tileSize: number;\n queryGeometry: Array;\n cameraQueryGeometry: Array;\n queryPadding: number;\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n };\n};\n\n/**\n * @internal\n * An in memory index class to allow fast interaction with features\n */\nexport class FeatureIndex {\n tileID: OverscaledTileID;\n x: number;\n y: number;\n z: number;\n grid: TransferableGridIndex;\n grid3D: TransferableGridIndex;\n featureIndexArray: FeatureIndexArray;\n promoteId?: PromoteIdSpecification;\n\n rawTileData: ArrayBuffer;\n bucketLayerIDs: Array>;\n\n vtLayers: {[_: string]: VectorTileLayer};\n sourceLayerCoder: DictionaryCoder;\n\n constructor(tileID: OverscaledTileID, promoteId?: PromoteIdSpecification | null) {\n this.tileID = tileID;\n this.x = tileID.canonical.x;\n this.y = tileID.canonical.y;\n this.z = tileID.canonical.z;\n this.grid = new TransferableGridIndex(EXTENT, 16, 0);\n this.grid3D = new TransferableGridIndex(EXTENT, 16, 0);\n this.featureIndexArray = new FeatureIndexArray();\n this.promoteId = promoteId;\n }\n\n insert(feature: VectorTileFeature, geometry: Array>, featureIndex: number, sourceLayerIndex: number, bucketIndex: number, is3D?: boolean) {\n const key = this.featureIndexArray.length;\n this.featureIndexArray.emplaceBack(featureIndex, sourceLayerIndex, bucketIndex);\n\n const grid = is3D ? this.grid3D : this.grid;\n\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n bbox[0] = Math.min(bbox[0], p.x);\n bbox[1] = Math.min(bbox[1], p.y);\n bbox[2] = Math.max(bbox[2], p.x);\n bbox[3] = Math.max(bbox[3], p.y);\n }\n\n if (bbox[0] < EXTENT &&\n bbox[1] < EXTENT &&\n bbox[2] >= 0 &&\n bbox[3] >= 0) {\n grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]);\n }\n }\n }\n\n loadVTLayers(): {[_: string]: VectorTileLayer} {\n if (!this.vtLayers) {\n this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers;\n this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']);\n }\n return this.vtLayers;\n }\n\n // Finds non-symbol features in this tile at a particular position.\n query(\n args: QueryParameters,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n this.loadVTLayers();\n\n const params = args.params || {} as { filter: any; layers: string[]; availableImages: string[] },\n pixelsToTileUnits = EXTENT / args.tileSize / args.scale,\n filter = featureFilter(params.filter);\n\n const queryGeometry = args.queryGeometry;\n const queryPadding = args.queryPadding * pixelsToTileUnits;\n\n const bounds = getBounds(queryGeometry);\n const matching = this.grid.query(bounds.minX - queryPadding, bounds.minY - queryPadding, bounds.maxX + queryPadding, bounds.maxY + queryPadding);\n\n const cameraBounds = getBounds(args.cameraQueryGeometry);\n const matching3D = this.grid3D.query(\n cameraBounds.minX - queryPadding, cameraBounds.minY - queryPadding, cameraBounds.maxX + queryPadding, cameraBounds.maxY + queryPadding,\n (bx1, by1, bx2, by2) => {\n return polygonIntersectsBox(args.cameraQueryGeometry, bx1 - queryPadding, by1 - queryPadding, bx2 + queryPadding, by2 + queryPadding);\n });\n\n for (const key of matching3D) {\n matching.push(key);\n }\n\n matching.sort(topDownFeatureComparator);\n\n const result = {};\n let previousIndex;\n for (let k = 0; k < matching.length; k++) {\n const index = matching[k];\n\n // don't check the same feature more than once\n if (index === previousIndex) continue;\n previousIndex = index;\n\n const match = this.featureIndexArray.get(index);\n let featureGeometry = null;\n this.loadMatchingFeature(\n result,\n match.bucketIndex,\n match.sourceLayerIndex,\n match.featureIndex,\n filter,\n params.layers,\n params.availableImages,\n styleLayers,\n serializedLayers,\n sourceFeatureState,\n (feature: VectorTileFeature, styleLayer: StyleLayer, featureState: FeatureState) => {\n if (!featureGeometry) {\n featureGeometry = loadGeometry(feature);\n }\n\n return styleLayer.queryIntersectsFeature(queryGeometry, feature, featureState, featureGeometry, this.z, args.transform, pixelsToTileUnits, args.pixelPosMatrix);\n }\n );\n }\n\n return result;\n }\n\n loadMatchingFeature(\n result: {\n [_: string]: Array<{\n featureIndex: number;\n feature: GeoJSONFeature;\n intersectionZ?: boolean | number;\n }>;\n },\n bucketIndex: number,\n sourceLayerIndex: number,\n featureIndex: number,\n filter: FeatureFilter,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState?: SourceFeatureState,\n intersectionTest?: (\n feature: VectorTileFeature,\n styleLayer: StyleLayer,\n featureState: any,\n id: string | number | void\n ) => boolean | number) {\n\n const layerIDs = this.bucketLayerIDs[bucketIndex];\n if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs))\n return;\n\n const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);\n const sourceLayer = this.vtLayers[sourceLayerName];\n const feature = sourceLayer.feature(featureIndex);\n\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) {\n return;\n }\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n return;\n }\n\n const id = this.getId(feature, sourceLayerName);\n\n for (let l = 0; l < layerIDs.length; l++) {\n const layerID = layerIDs[l];\n\n if (filterLayerIDs && filterLayerIDs.indexOf(layerID) < 0) {\n continue;\n }\n\n const styleLayer = styleLayers[layerID];\n\n if (!styleLayer) continue;\n\n let featureState = {};\n if (id && sourceFeatureState) {\n // `feature-state` expression evaluation requires feature state to be available\n featureState = sourceFeatureState.getState(styleLayer.sourceLayer || '_geojsonTileLayer', id);\n }\n\n const serializedLayer = extend({}, serializedLayers[layerID]);\n\n serializedLayer.paint = evaluateProperties(serializedLayer.paint, styleLayer.paint, feature, featureState, availableImages);\n serializedLayer.layout = evaluateProperties(serializedLayer.layout, styleLayer.layout, feature, featureState, availableImages);\n\n const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer, featureState);\n if (!intersectionZ) {\n // Only applied for non-symbol features\n continue;\n }\n\n const geojsonFeature = new GeoJSONFeature(feature, this.z, this.x, this.y, id) as MapGeoJSONFeature;\n geojsonFeature.layer = serializedLayer;\n let layerResult = result[layerID];\n if (layerResult === undefined) {\n layerResult = result[layerID] = [];\n }\n layerResult.push({featureIndex, feature: geojsonFeature, intersectionZ});\n }\n }\n\n // Given a set of symbol indexes that have already been looked up,\n // return a matching set of GeoJSONFeatures\n lookupSymbolFeatures(symbolFeatureIndexes: Array,\n serializedLayers: {[_: string]: StyleLayer},\n bucketIndex: number,\n sourceLayerIndex: number,\n filterSpec: FilterSpecification,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer}) {\n const result = {};\n this.loadVTLayers();\n\n const filter = featureFilter(filterSpec);\n\n for (const symbolFeatureIndex of symbolFeatureIndexes) {\n this.loadMatchingFeature(\n result,\n bucketIndex,\n sourceLayerIndex,\n symbolFeatureIndex,\n filter,\n filterLayerIDs,\n availableImages,\n styleLayers,\n serializedLayers\n );\n\n }\n return result;\n }\n\n hasLayer(id: string) {\n for (const layerIDs of this.bucketLayerIDs) {\n for (const layerID of layerIDs) {\n if (id === layerID) return true;\n }\n }\n\n return false;\n }\n\n getId(feature: VectorTileFeature, sourceLayerId: string): string | number {\n let id: string | number = feature.id;\n if (this.promoteId) {\n const propName = typeof this.promoteId === 'string' ? this.promoteId : this.promoteId[sourceLayerId];\n id = feature.properties[propName] as string | number;\n if (typeof id === 'boolean') id = Number(id);\n }\n return id;\n }\n}\n\nregister(\n 'FeatureIndex',\n FeatureIndex,\n {omit: ['rawTileData', 'sourceLayerCoder']}\n);\n\nfunction evaluateProperties(serializedProperties, styleLayerProperties, feature, featureState, availableImages) {\n return mapObject(serializedProperties, (property, key) => {\n const prop = styleLayerProperties instanceof PossiblyEvaluated ? styleLayerProperties.get(key) : null;\n return prop && prop.evaluate ? prop.evaluate(feature, featureState, availableImages) : prop;\n });\n}\n\nfunction getBounds(geometry: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const p of geometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return {minX, minY, maxX, maxY};\n}\n\nfunction topDownFeatureComparator(a, b) {\n return b - a;\n}\n","import {uniqueId, parseCacheControl} from '../util/util';\nimport {deserialize as deserializeBucket} from '../data/bucket';\nimport '../data/feature_index';\nimport type {FeatureIndex} from '../data/feature_index';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {CollisionBoxArray} from '../data/array_types.g';\nimport {Texture} from '../render/texture';\nimport {browser} from '../util/browser';\nimport {toEvaluationFeature} from '../data/evaluation_feature';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {lazyLoadRTLTextPlugin} from './rtl_text_plugin';\n\nconst CLOCK_SKEW_RETRY_TIMEOUT = 30000;\n\nimport type {Bucket} from '../data/bucket';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {WorkerTileResult} from './worker_source';\nimport type {Actor} from '../util/actor';\nimport type {DEMData} from '../data/dem_data';\nimport type {AlphaImage} from '../util/image';\nimport type {ImageAtlas} from '../render/image_atlas';\nimport type {ImageManager} from '../render/image_manager';\nimport type {Context} from '../gl/context';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Framebuffer} from '../gl/framebuffer';\nimport type {Transform} from '../geo/transform';\nimport type {LayerFeatureStates} from './source_state';\nimport type {Cancelable} from '../types/cancelable';\nimport type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type Point from '@mapbox/point-geometry';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\nimport {ExpiryData} from '../util/ajax';\n\n/**\n * The tile's state, can be:\n * - `loading` Tile data is in the process of loading.\n * - `loaded` Tile data has been loaded. Tile can be rendered.\n * - `reloading` Tile data has been loaded and is being updated. Tile can be rendered.\n * - `unloaded` Tile data has been deleted.\n * - `errored` Tile data was not loaded because of an error.\n * - `expired` Tile data was previously loaded, but has expired per its HTTP headers and is in the process of refreshing.\n */\nexport type TileState = 'loading' | 'loaded' | 'reloading' | 'unloaded' | 'errored' | 'expired';\n\n/**\n * @internal\n * A tile object is the combination of a Coordinate, which defines\n * its place, as well as a unique ID and data tracking for its content\n */\nexport class Tile {\n tileID: OverscaledTileID;\n uid: number;\n uses: number;\n tileSize: number;\n buckets: {[_: string]: Bucket};\n latestFeatureIndex: FeatureIndex;\n latestRawTileData: ArrayBuffer;\n imageAtlas: ImageAtlas;\n imageAtlasTexture: Texture;\n glyphAtlasImage: AlphaImage;\n glyphAtlasTexture: Texture;\n expirationTime: any;\n expiredRequestCount: number;\n state: TileState;\n timeAdded: number = 0;\n fadeEndTime: number = 0;\n collisionBoxArray: CollisionBoxArray;\n redoWhenDone: boolean;\n showCollisionBoxes: boolean;\n placementSource: any;\n actor: Actor;\n vtLayers: {[_: string]: VectorTileLayer};\n\n neighboringTiles: any;\n dem: DEMData;\n demMatrix: mat4;\n aborted: boolean;\n needsHillshadePrepare: boolean;\n needsTerrainPrepare: boolean;\n request: Cancelable;\n texture: any;\n fbo: Framebuffer;\n demTexture: Texture;\n refreshedUponExpiration: boolean;\n reloadCallback: any;\n resourceTiming: Array;\n queryPadding: number;\n\n symbolFadeHoldUntil: number;\n hasSymbolBuckets: boolean;\n hasRTLText: boolean;\n dependencies: any;\n rtt: Array<{id: number; stamp: number}>;\n rttCoords: {[_:string]: string};\n\n /**\n * @param tileID - the tile ID\n * @param size - The tile size\n */\n constructor(tileID: OverscaledTileID, size: number) {\n this.tileID = tileID;\n this.uid = uniqueId();\n this.uses = 0;\n this.tileSize = size;\n this.buckets = {};\n this.expirationTime = null;\n this.queryPadding = 0;\n this.hasSymbolBuckets = false;\n this.hasRTLText = false;\n this.dependencies = {};\n this.rtt = [];\n this.rttCoords = {};\n\n // Counts the number of times a response was already expired when\n // received. We're using this to add a delay when making a new request\n // so we don't have to keep retrying immediately in case of a server\n // serving expired tiles.\n this.expiredRequestCount = 0;\n\n this.state = 'loading';\n }\n\n registerFadeDuration(duration: number) {\n const fadeEndTime = duration + this.timeAdded;\n\n if (fadeEndTime < this.fadeEndTime) {\n return;\n }\n\n this.fadeEndTime = fadeEndTime;\n }\n\n wasRequested() {\n return this.state === 'errored' || this.state === 'loaded' || this.state === 'reloading';\n }\n\n clearTextures(painter: any) {\n if (this.demTexture) painter.saveTileTexture(this.demTexture);\n this.demTexture = null;\n }\n\n /**\n * Given a data object with a 'buffers' property, load it into\n * this tile's elementGroups and buffers properties and set loaded\n * to true. If the data is null, like in the case of an empty\n * GeoJSON tile, no-op but still set loaded to true.\n * @param data - The data from the worker\n * @param painter - the painter\n * @param justReloaded - `true` to just reload\n */\n loadVectorData(data: WorkerTileResult, painter: any, justReloaded?: boolean | null) {\n if (this.hasData()) {\n this.unloadVectorData();\n }\n\n this.state = 'loaded';\n\n // empty GeoJSON tile\n if (!data) {\n this.collisionBoxArray = new CollisionBoxArray();\n return;\n }\n\n if (data.featureIndex) {\n this.latestFeatureIndex = data.featureIndex;\n if (data.rawTileData) {\n // Only vector tiles have rawTileData, and they won't update it for\n // 'reloadTile'\n this.latestRawTileData = data.rawTileData;\n this.latestFeatureIndex.rawTileData = data.rawTileData;\n } else if (this.latestRawTileData) {\n // If rawTileData hasn't updated, hold onto a pointer to the last\n // one we received\n this.latestFeatureIndex.rawTileData = this.latestRawTileData;\n }\n }\n this.collisionBoxArray = data.collisionBoxArray;\n this.buckets = deserializeBucket(data.buckets, painter.style);\n\n this.hasSymbolBuckets = false;\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket instanceof SymbolBucket) {\n this.hasSymbolBuckets = true;\n if (justReloaded) {\n bucket.justReloaded = true;\n } else {\n break;\n }\n }\n }\n\n this.hasRTLText = false;\n if (this.hasSymbolBuckets) {\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket instanceof SymbolBucket) {\n if (bucket.hasRTLText) {\n this.hasRTLText = true;\n lazyLoadRTLTextPlugin();\n break;\n }\n }\n }\n }\n\n this.queryPadding = 0;\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(id).queryRadius(bucket));\n }\n\n if (data.imageAtlas) {\n this.imageAtlas = data.imageAtlas;\n }\n if (data.glyphAtlasImage) {\n this.glyphAtlasImage = data.glyphAtlasImage;\n }\n }\n\n /**\n * Release any data or WebGL resources referenced by this tile.\n */\n unloadVectorData() {\n for (const id in this.buckets) {\n this.buckets[id].destroy();\n }\n this.buckets = {};\n\n if (this.imageAtlasTexture) {\n this.imageAtlasTexture.destroy();\n }\n\n if (this.imageAtlas) {\n this.imageAtlas = null;\n }\n\n if (this.glyphAtlasTexture) {\n this.glyphAtlasTexture.destroy();\n }\n\n this.latestFeatureIndex = null;\n this.state = 'unloaded';\n }\n\n getBucket(layer: StyleLayer) {\n return this.buckets[layer.id];\n }\n\n upload(context: Context) {\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket.uploadPending()) {\n bucket.upload(context);\n }\n }\n\n const gl = context.gl;\n if (this.imageAtlas && !this.imageAtlas.uploaded) {\n this.imageAtlasTexture = new Texture(context, this.imageAtlas.image, gl.RGBA);\n this.imageAtlas.uploaded = true;\n }\n\n if (this.glyphAtlasImage) {\n this.glyphAtlasTexture = new Texture(context, this.glyphAtlasImage, gl.ALPHA);\n this.glyphAtlasImage = null;\n }\n }\n\n prepare(imageManager: ImageManager) {\n if (this.imageAtlas) {\n this.imageAtlas.patchUpdatedImages(imageManager, this.imageAtlasTexture);\n }\n }\n\n // Queries non-symbol features rendered for this tile.\n // Symbol features are queried globally\n queryRenderedFeatures(\n layers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState,\n queryGeometry: Array,\n cameraQueryGeometry: Array,\n scale: number,\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n },\n transform: Transform,\n maxPitchScaleFactor: number,\n pixelPosMatrix: mat4\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData)\n return {};\n\n return this.latestFeatureIndex.query({\n queryGeometry,\n cameraQueryGeometry,\n scale,\n tileSize: this.tileSize,\n pixelPosMatrix,\n transform,\n params,\n queryPadding: this.queryPadding * maxPitchScaleFactor\n }, layers, serializedLayers, sourceFeatureState);\n }\n\n querySourceFeatures(result: Array, params?: {\n sourceLayer?: string;\n filter?: FilterSpecification;\n validate?: boolean;\n }) {\n const featureIndex = this.latestFeatureIndex;\n if (!featureIndex || !featureIndex.rawTileData) return;\n\n const vtLayers = featureIndex.loadVTLayers();\n\n const sourceLayer = params && params.sourceLayer ? params.sourceLayer : '';\n const layer = vtLayers._geojsonTileLayer || vtLayers[sourceLayer];\n\n if (!layer) return;\n\n const filter = featureFilter(params && params.filter);\n const {z, x, y} = this.tileID.canonical;\n const coord = {z, x, y};\n\n for (let i = 0; i < layer.length; i++) {\n const feature = layer.feature(i);\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) continue;\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n continue;\n }\n const id = featureIndex.getId(feature, sourceLayer);\n const geojsonFeature = new GeoJSONFeature(feature, z, x, y, id);\n (geojsonFeature as any).tile = coord;\n result.push(geojsonFeature);\n }\n }\n\n hasData() {\n return this.state === 'loaded' || this.state === 'reloading' || this.state === 'expired';\n }\n\n patternsLoaded() {\n return this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;\n }\n\n setExpiryData(data: ExpiryData) {\n const prior = this.expirationTime;\n\n if (data.cacheControl) {\n const parsedCC = parseCacheControl(data.cacheControl);\n if (parsedCC['max-age']) this.expirationTime = Date.now() + parsedCC['max-age'] * 1000;\n } else if (data.expires) {\n this.expirationTime = new Date(data.expires).getTime();\n }\n\n if (this.expirationTime) {\n const now = Date.now();\n let isExpired = false;\n\n if (this.expirationTime > now) {\n isExpired = false;\n } else if (!prior) {\n isExpired = true;\n } else if (this.expirationTime < prior) {\n // Expiring date is going backwards:\n // fall back to exponential backoff\n isExpired = true;\n\n } else {\n const delta = this.expirationTime - prior;\n\n if (!delta) {\n // Server is serving the same expired resource over and over: fall\n // back to exponential backoff.\n isExpired = true;\n\n } else {\n // Assume that either the client or the server clock is wrong and\n // try to interpolate a valid expiration date (from the client POV)\n // observing a minimum timeout.\n this.expirationTime = now + Math.max(delta, CLOCK_SKEW_RETRY_TIMEOUT);\n\n }\n }\n\n if (isExpired) {\n this.expiredRequestCount++;\n this.state = 'expired';\n } else {\n this.expiredRequestCount = 0;\n }\n }\n }\n\n getExpiryTimeout() {\n if (this.expirationTime) {\n if (this.expiredRequestCount) {\n return 1000 * (1 << Math.min(this.expiredRequestCount - 1, 31));\n } else {\n // Max value for `setTimeout` implementations is a 32 bit integer; cap this accordingly\n return Math.min(this.expirationTime - new Date().getTime(), Math.pow(2, 31) - 1);\n }\n }\n }\n\n setFeatureState(states: LayerFeatureStates, painter: any) {\n if (!this.latestFeatureIndex ||\n !this.latestFeatureIndex.rawTileData ||\n Object.keys(states).length === 0) {\n return;\n }\n\n const vtLayers = this.latestFeatureIndex.loadVTLayers();\n\n for (const id in this.buckets) {\n if (!painter.style.hasLayer(id)) continue;\n\n const bucket = this.buckets[id];\n // Buckets are grouped by common source-layer\n const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer';\n const sourceLayer = vtLayers[sourceLayerId];\n const sourceLayerStates = states[sourceLayerId];\n if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) continue;\n\n bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {});\n const layer = painter && painter.style && painter.style.getLayer(id);\n if (layer) {\n this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket));\n }\n }\n }\n\n holdingForFade(): boolean {\n return this.symbolFadeHoldUntil !== undefined;\n }\n\n symbolFadeFinished(): boolean {\n return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < browser.now();\n }\n\n clearFadeHold() {\n this.symbolFadeHoldUntil = undefined;\n }\n\n setHoldDuration(duration: number) {\n this.symbolFadeHoldUntil = browser.now() + duration;\n }\n\n setDependencies(namespace: string, dependencies: Array) {\n const index = {};\n for (const dep of dependencies) {\n index[dep] = true;\n }\n this.dependencies[namespace] = index;\n }\n\n hasDependency(namespaces: Array, keys: Array) {\n for (const namespace of namespaces) {\n const dependencies = this.dependencies[namespace];\n if (dependencies) {\n for (const key of keys) {\n if (dependencies[key]) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}\n","import type {CollisionBoxArray} from './array_types.g';\nimport type {Style} from '../style/style';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {FeatureIndex} from './feature_index';\nimport type {Context} from '../gl/context';\nimport type {FeatureStates} from '../source/source_state';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\nimport Point from '@mapbox/point-geometry';\n\nexport type BucketParameters = {\n index: number;\n layers: Array;\n zoom: number;\n pixelRatio: number;\n overscaling: number;\n collisionBoxArray: CollisionBoxArray;\n sourceLayerIndex: number;\n sourceID: string;\n};\n\nexport type PopulateParameters = {\n featureIndex: FeatureIndex;\n iconDependencies: {};\n patternDependencies: {};\n glyphDependencies: {};\n availableImages: Array;\n};\n\nexport type IndexedFeature = {\n feature: VectorTileFeature;\n id: number | string;\n index: number;\n sourceLayerIndex: number;\n};\n\nexport type BucketFeature = {\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 0 | 1 | 2 | 3;\n id?: any;\n readonly patterns: {\n [_: string]: {\n 'min': string;\n 'mid': string;\n 'max': string;\n };\n };\n sortKey?: number;\n};\n\n/**\n * The `Bucket` interface is the single point of knowledge about turning vector\n * tiles into WebGL buffers.\n *\n * `Bucket` is an abstract interface. An implementation exists for each style layer type.\n * Create a bucket via the `StyleLayer#createBucket` method.\n *\n * The concrete bucket types, using layout options from the style layer,\n * transform feature geometries into vertex and index data for use by the\n * vertex shader. They also (via `ProgramConfiguration`) use feature\n * properties and the zoom level to populate the attributes needed for\n * data-driven styling.\n *\n * Buckets are designed to be built on a worker thread and then serialized and\n * transferred back to the main thread for rendering. On the worker side, a\n * bucket's vertex, index, and attribute data is stored in `bucket.arrays: ArrayGroup`.\n * When a bucket's data is serialized and sent back to the main thread,\n * is gets deserialized (using `new Bucket(serializedBucketData)`, with\n * the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups\n * hold the same data as ArrayGroups, but are tuned for consumption by WebGL.\n */\nexport interface Bucket {\n layerIds: Array;\n hasPattern: boolean;\n readonly layers: Array;\n readonly stateDependentLayers: Array;\n readonly stateDependentLayerIds: Array;\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void;\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}): void;\n isEmpty(): boolean;\n upload(context: Context): void;\n uploadPending(): boolean;\n /**\n * Release the WebGL resources associated with the buffers. Note that because\n * buckets are shared between layers having the same layout properties, they\n * must be destroyed in groups (all buckets for a tile, or all symbol buckets).\n */\n destroy(): void;\n}\n\nexport function deserialize(input: Array, style: Style): {[_: string]: Bucket} {\n const output = {};\n\n // Guard against the case where the map's style has been set to null while\n // this bucket has been parsing.\n if (!style) return output;\n\n for (const bucket of input) {\n const layers = bucket.layerIds\n .map((id) => style.getLayer(id))\n .filter(Boolean);\n\n if (layers.length === 0) {\n continue;\n }\n\n // look up StyleLayer objects from layer ids (since we don't\n // want to waste time serializing/copying them from the worker)\n (bucket as any).layers = layers;\n if (bucket.stateDependentLayerIds) {\n (bucket as any).stateDependentLayers = bucket.stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]);\n }\n for (const layer of layers) {\n output[layer.id] = bucket;\n }\n }\n\n return output;\n}\n","import {OverscaledTileID} from './tile_id';\nimport type {Tile} from './tile';\n\n/**\n * @internal\n * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms)\n * with hash lookup made possible by keeping a list of keys in parallel to\n * an array of dictionary of values\n */\nexport class TileCache {\n max: number;\n data: {\n [key: string]: Array<{\n value: Tile;\n timeout: ReturnType;\n }>;\n };\n order: Array;\n onRemove: (element: Tile) => void;\n /**\n * @param max - number of permitted values\n * @param onRemove - callback called with items when they expire\n */\n constructor(max: number, onRemove: (element: Tile) => void) {\n this.max = max;\n this.onRemove = onRemove;\n this.reset();\n }\n\n /**\n * Clear the cache\n *\n * @returns this cache\n */\n reset() {\n for (const key in this.data) {\n for (const removedData of this.data[key]) {\n if (removedData.timeout) clearTimeout(removedData.timeout);\n this.onRemove(removedData.value);\n }\n }\n\n this.data = {};\n this.order = [];\n\n return this;\n }\n\n /**\n * Add a key, value combination to the cache, trimming its size if this pushes\n * it over max length.\n *\n * @param tileID - lookup key for the item\n * @param data - tile data\n *\n * @returns this cache\n */\n add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void) {\n const key = tileID.wrapped().key;\n if (this.data[key] === undefined) {\n this.data[key] = [];\n }\n\n const dataWrapper = {\n value: data,\n timeout: undefined\n };\n\n if (expiryTimeout !== undefined) {\n dataWrapper.timeout = setTimeout(() => {\n this.remove(tileID, dataWrapper);\n }, expiryTimeout as number);\n }\n\n this.data[key].push(dataWrapper);\n this.order.push(key);\n\n if (this.order.length > this.max) {\n const removedData = this._getAndRemoveByKey(this.order[0]);\n if (removedData) this.onRemove(removedData);\n }\n\n return this;\n }\n\n /**\n * Determine whether the value attached to `key` is present\n *\n * @param tileID - the key to be looked-up\n * @returns whether the cache has this value\n */\n has(tileID: OverscaledTileID): boolean {\n return tileID.wrapped().key in this.data;\n }\n\n /**\n * Get the value attached to a specific key and remove data from cache.\n * If the key is not found, returns `null`\n *\n * @param tileID - the key to look up\n * @returns the tile data, or null if it isn't found\n */\n getAndRemove(tileID: OverscaledTileID): Tile {\n if (!this.has(tileID)) { return null; }\n return this._getAndRemoveByKey(tileID.wrapped().key);\n }\n\n /*\n * Get and remove the value with the specified key.\n */\n _getAndRemoveByKey(key: string): Tile {\n const data = this.data[key].shift();\n if (data.timeout) clearTimeout(data.timeout);\n\n if (this.data[key].length === 0) {\n delete this.data[key];\n }\n this.order.splice(this.order.indexOf(key), 1);\n\n return data.value;\n }\n\n /*\n * Get the value with the specified (wrapped tile) key.\n */\n getByKey(key: string): Tile {\n const data = this.data[key];\n return data ? data[0].value : null;\n }\n\n /**\n * Get the value attached to a specific key without removing data\n * from the cache. If the key is not found, returns `null`\n *\n * @param tileID - the key to look up\n * @returns the tile data, or null if it isn't found\n */\n get(tileID: OverscaledTileID): Tile {\n if (!this.has(tileID)) { return null; }\n\n const data = this.data[tileID.wrapped().key][0];\n return data.value;\n }\n\n /**\n * Remove a key/value combination from the cache.\n *\n * @param tileID - the key for the pair to delete\n * @param value - If a value is provided, remove that exact version of the value.\n * @returns this cache\n */\n remove(tileID: OverscaledTileID, value?: {\n value: Tile;\n timeout: ReturnType;\n }) {\n if (!this.has(tileID)) { return this; }\n const key = tileID.wrapped().key;\n\n const dataIndex = value === undefined ? 0 : this.data[key].indexOf(value);\n const data = this.data[key][dataIndex];\n this.data[key].splice(dataIndex, 1);\n if (data.timeout) clearTimeout(data.timeout);\n if (this.data[key].length === 0) {\n delete this.data[key];\n }\n this.onRemove(data.value);\n this.order.splice(this.order.indexOf(key), 1);\n\n return this;\n }\n\n /**\n * Change the max size of the cache.\n *\n * @param max - the max size of the cache\n * @returns this cache\n */\n setMaxSize(max: number): TileCache {\n this.max = max;\n\n while (this.order.length > this.max) {\n const removedData = this._getAndRemoveByKey(this.order[0]);\n if (removedData) this.onRemove(removedData);\n }\n\n return this;\n }\n\n /**\n * Remove entries that do not pass a filter function. Used for removing\n * stale tiles from the cache.\n *\n * @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out.\n */\n filter(filterFn: (tile: Tile) => boolean) {\n const removed = [];\n for (const key in this.data) {\n for (const entry of this.data[key]) {\n if (!filterFn(entry.value)) {\n removed.push(entry);\n }\n }\n }\n for (const r of removed) {\n this.remove(r.value.tileID, r);\n }\n }\n}\n","import {extend} from '../util/util';\nimport {Tile} from './tile';\nimport type {FeatureState} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FeatureStates = {[featureId: string]: FeatureState};\nexport type LayerFeatureStates = {[layer: string]: FeatureStates};\n\n/**\n * @internal\n * SourceFeatureState manages the state and pending changes\n * to features in a source, separated by source layer.\n * stateChanges and deletedStates batch all changes to the tile (updates and removes, respectively)\n * between coalesce() events. addFeatureState() and removeFeatureState() also update their counterpart's\n * list of changes, such that coalesce() can apply the proper state changes while agnostic to the order of operations.\n * In deletedStates, all null's denote complete removal of state at that scope\n*/\nexport class SourceFeatureState {\n state: LayerFeatureStates;\n stateChanges: LayerFeatureStates;\n deletedStates: {};\n\n constructor() {\n this.state = {};\n this.stateChanges = {};\n this.deletedStates = {};\n }\n\n updateState(sourceLayer: string, featureId: number | string, newState: any) {\n const feature = String(featureId);\n this.stateChanges[sourceLayer] = this.stateChanges[sourceLayer] || {};\n this.stateChanges[sourceLayer][feature] = this.stateChanges[sourceLayer][feature] || {};\n extend(this.stateChanges[sourceLayer][feature], newState);\n\n if (this.deletedStates[sourceLayer] === null) {\n this.deletedStates[sourceLayer] = {};\n for (const ft in this.state[sourceLayer]) {\n if (ft !== feature) this.deletedStates[sourceLayer][ft] = null;\n }\n } else {\n const featureDeletionQueued = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] === null;\n if (featureDeletionQueued) {\n this.deletedStates[sourceLayer][feature] = {};\n for (const prop in this.state[sourceLayer][feature]) {\n if (!newState[prop]) this.deletedStates[sourceLayer][feature][prop] = null;\n }\n } else {\n for (const key in newState) {\n const deletionInQueue = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] && this.deletedStates[sourceLayer][feature][key] === null;\n if (deletionInQueue) delete this.deletedStates[sourceLayer][feature][key];\n }\n }\n }\n }\n\n removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string) {\n const sourceLayerDeleted = this.deletedStates[sourceLayer] === null;\n if (sourceLayerDeleted) return;\n\n const feature = String(featureId);\n\n this.deletedStates[sourceLayer] = this.deletedStates[sourceLayer] || {};\n\n if (key && featureId !== undefined) {\n if (this.deletedStates[sourceLayer][feature] !== null) {\n this.deletedStates[sourceLayer][feature] = this.deletedStates[sourceLayer][feature] || {};\n this.deletedStates[sourceLayer][feature][key] = null;\n }\n } else if (featureId !== undefined) {\n const updateInQueue = this.stateChanges[sourceLayer] && this.stateChanges[sourceLayer][feature];\n if (updateInQueue) {\n this.deletedStates[sourceLayer][feature] = {};\n for (key in this.stateChanges[sourceLayer][feature]) this.deletedStates[sourceLayer][feature][key] = null;\n\n } else {\n this.deletedStates[sourceLayer][feature] = null;\n }\n } else {\n this.deletedStates[sourceLayer] = null;\n }\n\n }\n\n getState(sourceLayer: string, featureId: number | string) {\n const feature = String(featureId);\n const base = this.state[sourceLayer] || {};\n const changes = this.stateChanges[sourceLayer] || {};\n\n const reconciledState = extend({}, base[feature], changes[feature]);\n\n //return empty object if the whole source layer is awaiting deletion\n if (this.deletedStates[sourceLayer] === null) return {};\n else if (this.deletedStates[sourceLayer]) {\n const featureDeletions = this.deletedStates[sourceLayer][featureId];\n if (featureDeletions === null) return {};\n for (const prop in featureDeletions) delete reconciledState[prop];\n }\n return reconciledState;\n }\n\n initializeTileState(tile: Tile, painter: any) {\n tile.setFeatureState(this.state, painter);\n }\n\n coalesceChanges(tiles: {\n [_ in any]: Tile;\n }, painter: any) {\n //track changes with full state objects, but only for features that got modified\n const featuresChanged: LayerFeatureStates = {};\n\n for (const sourceLayer in this.stateChanges) {\n this.state[sourceLayer] = this.state[sourceLayer] || {};\n const layerStates = {};\n for (const feature in this.stateChanges[sourceLayer]) {\n if (!this.state[sourceLayer][feature]) this.state[sourceLayer][feature] = {};\n extend(this.state[sourceLayer][feature], this.stateChanges[sourceLayer][feature]);\n layerStates[feature] = this.state[sourceLayer][feature];\n }\n featuresChanged[sourceLayer] = layerStates;\n }\n\n for (const sourceLayer in this.deletedStates) {\n this.state[sourceLayer] = this.state[sourceLayer] || {};\n const layerStates = {};\n\n if (this.deletedStates[sourceLayer] === null) {\n for (const ft in this.state[sourceLayer]) {\n layerStates[ft] = {};\n this.state[sourceLayer][ft] = {};\n }\n } else {\n for (const feature in this.deletedStates[sourceLayer]) {\n const deleteWholeFeatureState = this.deletedStates[sourceLayer][feature] === null;\n if (deleteWholeFeatureState) this.state[sourceLayer][feature] = {};\n else {\n for (const key of Object.keys(this.deletedStates[sourceLayer][feature])) {\n delete this.state[sourceLayer][feature][key];\n }\n }\n layerStates[feature] = this.state[sourceLayer][feature];\n }\n }\n\n featuresChanged[sourceLayer] = featuresChanged[sourceLayer] || {};\n extend(featuresChanged[sourceLayer], layerStates);\n }\n\n this.stateChanges = {};\n this.deletedStates = {};\n\n if (Object.keys(featuresChanged).length === 0) return;\n\n for (const id in tiles) {\n const tile = tiles[id];\n tile.setFeatureState(featuresChanged, painter);\n }\n }\n}\n","import {create as createSource} from './source';\n\nimport {Tile} from './tile';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {TileCache} from './tile_cache';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {keysDifference} from '../util/util';\nimport {EXTENT} from '../data/extent';\nimport {Context} from '../gl/context';\nimport Point from '@mapbox/point-geometry';\nimport {browser} from '../util/browser';\nimport {OverscaledTileID} from './tile_id';\nimport {SourceFeatureState} from './source_state';\n\nimport type {Source} from './source';\nimport type {Map} from '../ui/map';\nimport type {Style} from '../style/style';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Transform} from '../geo/transform';\nimport type {TileState} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {MapSourceDataEvent} from '../ui/events';\nimport {Terrain} from '../render/terrain';\nimport {config} from '../util/config';\n\n/**\n * @internal\n * `SourceCache` is responsible for\n *\n * - creating an instance of `Source`\n * - forwarding events from `Source`\n * - caching tiles loaded from an instance of `Source`\n * - loading the tiles needed to render a given viewport\n * - unloading the cached tiles not needed to render a given viewport\n */\nexport class SourceCache extends Evented {\n id: string;\n dispatcher: Dispatcher;\n map: Map;\n style: Style;\n\n _source: Source;\n _sourceLoaded: boolean;\n _sourceErrored: boolean;\n _tiles: {[_: string]: Tile};\n _prevLng: number;\n _cache: TileCache;\n _timers: {\n [_ in any]: ReturnType;\n };\n _cacheTimers: {\n [_ in any]: ReturnType;\n };\n _maxTileCacheSize: number;\n _maxTileCacheZoomLevels: number;\n _paused: boolean;\n _shouldReloadOnResume: boolean;\n _coveredTiles: {[_: string]: boolean};\n transform: Transform;\n terrain: Terrain;\n used: boolean;\n usedForTerrain: boolean;\n tileSize: number;\n _state: SourceFeatureState;\n _loadedParentTiles: {[_: string]: Tile};\n _didEmitContent: boolean;\n _updated: boolean;\n\n static maxUnderzooming: number;\n static maxOverzooming: number;\n\n constructor(id: string, options: SourceSpecification, dispatcher: Dispatcher) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n\n this.on('data', (e: MapSourceDataEvent) => {\n // this._sourceLoaded signifies that the TileJSON is loaded if applicable.\n // if the source type does not come with a TileJSON, the flag signifies the\n // source data has loaded (i.e geojson has been tiled on the worker and is ready)\n if (e.dataType === 'source' && e.sourceDataType === 'metadata') this._sourceLoaded = true;\n\n // for sources with mutable data, this event fires when the underlying data\n // to a source is changed. (i.e. GeoJSONSource#setData and ImageSource#serCoordinates)\n if (this._sourceLoaded && !this._paused && e.dataType === 'source' && e.sourceDataType === 'content') {\n this.reload();\n if (this.transform) {\n this.update(this.transform, this.terrain);\n }\n\n this._didEmitContent = true;\n }\n });\n\n this.on('dataloading', () => {\n this._sourceErrored = false;\n });\n\n this.on('error', () => {\n // Only set _sourceErrored if the source does not have pending loads.\n this._sourceErrored = this._source.loaded();\n });\n\n this._source = createSource(id, options, dispatcher, this);\n\n this._tiles = {};\n this._cache = new TileCache(0, this._unloadTile.bind(this));\n this._timers = {};\n this._cacheTimers = {};\n this._maxTileCacheSize = null;\n this._maxTileCacheZoomLevels = null;\n this._loadedParentTiles = {};\n\n this._coveredTiles = {};\n this._state = new SourceFeatureState();\n this._didEmitContent = false;\n this._updated = false;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this._maxTileCacheSize = map ? map._maxTileCacheSize : null;\n this._maxTileCacheZoomLevels = map ? map._maxTileCacheZoomLevels : null;\n if (this._source && this._source.onAdd) {\n this._source.onAdd(map);\n }\n }\n\n onRemove(map: Map) {\n this.clearTiles();\n if (this._source && this._source.onRemove) {\n this._source.onRemove(map);\n }\n }\n\n /**\n * Return true if no tile data is pending, tiles will not change unless\n * an additional API call is received.\n */\n loaded(): boolean {\n if (this._sourceErrored) { return true; }\n if (!this._sourceLoaded) { return false; }\n if (!this._source.loaded()) { return false; }\n if ((this.used !== undefined || this.usedForTerrain !== undefined) && !this.used && !this.usedForTerrain) { return true; }\n // do not consider as loaded if the update hasn't been called yet (we do not know if we will have any tiles to fetch)\n if (!this._updated) { return false; }\n\n for (const t in this._tiles) {\n const tile = this._tiles[t];\n if (tile.state !== 'loaded' && tile.state !== 'errored')\n return false;\n }\n return true;\n }\n\n getSource(): Source {\n return this._source;\n }\n\n pause() {\n this._paused = true;\n }\n\n resume() {\n if (!this._paused) return;\n const shouldReload = this._shouldReloadOnResume;\n this._paused = false;\n this._shouldReloadOnResume = false;\n if (shouldReload) this.reload();\n if (this.transform) this.update(this.transform, this.terrain);\n }\n\n _loadTile(tile: Tile, callback: Callback) {\n return this._source.loadTile(tile, callback);\n }\n\n _unloadTile(tile: Tile) {\n if (this._source.unloadTile)\n return this._source.unloadTile(tile, () => {});\n }\n\n _abortTile(tile: Tile) {\n if (this._source.abortTile)\n this._source.abortTile(tile, () => {});\n\n this._source.fire(new Event('dataabort', {tile, coord: tile.tileID, dataType: 'source'}));\n }\n\n serialize() {\n return this._source.serialize();\n }\n\n prepare(context: Context) {\n if (this._source.prepare) {\n this._source.prepare();\n }\n\n this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null);\n for (const i in this._tiles) {\n const tile = this._tiles[i];\n tile.upload(context);\n tile.prepare(this.map.style.imageManager);\n }\n }\n\n /**\n * Return all tile ids ordered with z-order, and cast to numbers\n */\n getIds(): Array {\n return (Object.values(this._tiles) as any).map((tile: Tile) => tile.tileID).sort(compareTileId).map(id => id.key);\n }\n\n getRenderableIds(symbolLayer?: boolean): Array {\n const renderables: Array = [];\n for (const id in this._tiles) {\n if (this._isIdRenderable(id, symbolLayer)) renderables.push(this._tiles[id]);\n }\n if (symbolLayer) {\n return renderables.sort((a_: Tile, b_: Tile) => {\n const a = a_.tileID;\n const b = b_.tileID;\n const rotatedA = (new Point(a.canonical.x, a.canonical.y))._rotate(this.transform.angle);\n const rotatedB = (new Point(b.canonical.x, b.canonical.y))._rotate(this.transform.angle);\n return a.overscaledZ - b.overscaledZ || rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x;\n }).map(tile => tile.tileID.key);\n }\n return renderables.map(tile => tile.tileID).sort(compareTileId).map(id => id.key);\n }\n\n hasRenderableParent(tileID: OverscaledTileID) {\n const parentTile = this.findLoadedParent(tileID, 0);\n if (parentTile) {\n return this._isIdRenderable(parentTile.tileID.key);\n }\n return false;\n }\n\n _isIdRenderable(id: string, symbolLayer?: boolean) {\n return this._tiles[id] && this._tiles[id].hasData() &&\n !this._coveredTiles[id] && (symbolLayer || !this._tiles[id].holdingForFade());\n }\n\n reload() {\n if (this._paused) {\n this._shouldReloadOnResume = true;\n return;\n }\n\n this._cache.reset();\n\n for (const i in this._tiles) {\n if (this._tiles[i].state !== 'errored') this._reloadTile(i, 'reloading');\n }\n }\n\n _reloadTile(id: string, state: TileState) {\n const tile = this._tiles[id];\n\n // this potentially does not address all underlying\n // issues https://github.com/mapbox/mapbox-gl-js/issues/4252\n // - hard to tell without repro steps\n if (!tile) return;\n\n // The difference between \"loading\" tiles and \"reloading\" or \"expired\"\n // tiles is that \"reloading\"/\"expired\" tiles are \"renderable\".\n // Therefore, a \"loading\" tile cannot become a \"reloading\" tile without\n // first becoming a \"loaded\" tile.\n if (tile.state !== 'loading') {\n tile.state = state;\n }\n\n this._loadTile(tile, this._tileLoaded.bind(this, tile, id, state));\n }\n\n _tileLoaded(tile: Tile, id: string, previousState: TileState, err?: Error | null) {\n if (err) {\n tile.state = 'errored';\n if ((err as any).status !== 404) this._source.fire(new ErrorEvent(err, {tile}));\n // continue to try loading parent/children tiles if a tile doesn't exist (404)\n else this.update(this.transform, this.terrain);\n return;\n }\n\n tile.timeAdded = browser.now();\n if (previousState === 'expired') tile.refreshedUponExpiration = true;\n this._setTileReloadTimer(id, tile);\n if (this.getSource().type === 'raster-dem' && tile.dem) this._backfillDEM(tile);\n this._state.initializeTileState(tile, this.map ? this.map.painter : null);\n\n if (!tile.aborted) {\n this._source.fire(new Event('data', {dataType: 'source', tile, coord: tile.tileID}));\n }\n }\n\n /**\n * For raster terrain source, backfill DEM to eliminate visible tile boundaries\n */\n _backfillDEM(tile: Tile) {\n const renderables = this.getRenderableIds();\n for (let i = 0; i < renderables.length; i++) {\n const borderId = renderables[i];\n if (tile.neighboringTiles && tile.neighboringTiles[borderId]) {\n const borderTile = this.getTileByID(borderId);\n fillBorder(tile, borderTile);\n fillBorder(borderTile, tile);\n }\n }\n\n function fillBorder(tile, borderTile) {\n tile.needsHillshadePrepare = true;\n tile.needsTerrainPrepare = true;\n let dx = borderTile.tileID.canonical.x - tile.tileID.canonical.x;\n const dy = borderTile.tileID.canonical.y - tile.tileID.canonical.y;\n const dim = Math.pow(2, tile.tileID.canonical.z);\n const borderId = borderTile.tileID.key;\n if (dx === 0 && dy === 0) return;\n\n if (Math.abs(dy) > 1) {\n return;\n }\n if (Math.abs(dx) > 1) {\n // Adjust the delta coordinate for world wraparound.\n if (Math.abs(dx + dim) === 1) {\n dx += dim;\n } else if (Math.abs(dx - dim) === 1) {\n dx -= dim;\n }\n }\n if (!borderTile.dem || !tile.dem) return;\n tile.dem.backfillBorder(borderTile.dem, dx, dy);\n if (tile.neighboringTiles && tile.neighboringTiles[borderId])\n tile.neighboringTiles[borderId].backfilled = true;\n }\n }\n /**\n * Get a specific tile by TileID\n */\n getTile(tileID: OverscaledTileID): Tile {\n return this.getTileByID(tileID.key);\n }\n\n /**\n * Get a specific tile by id\n */\n getTileByID(id: string): Tile {\n return this._tiles[id];\n }\n\n /**\n * For a given set of tiles, retain children that are loaded and have a zoom\n * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive)\n */\n _retainLoadedChildren(\n idealTiles: {\n [_ in any]: OverscaledTileID;\n },\n zoom: number,\n maxCoveringZoom: number,\n retain: {\n [_ in any]: OverscaledTileID;\n }\n ) {\n for (const id in this._tiles) {\n let tile = this._tiles[id];\n\n // only consider renderable tiles up to maxCoveringZoom\n if (retain[id] ||\n !tile.hasData() ||\n tile.tileID.overscaledZ <= zoom ||\n tile.tileID.overscaledZ > maxCoveringZoom\n ) continue;\n\n // loop through parents and retain the topmost loaded one if found\n let topmostLoadedID = tile.tileID;\n while (tile && tile.tileID.overscaledZ > zoom + 1) {\n const parentID = tile.tileID.scaledTo(tile.tileID.overscaledZ - 1);\n\n tile = this._tiles[parentID.key];\n\n if (tile && tile.hasData()) {\n topmostLoadedID = parentID;\n }\n }\n\n // loop through ancestors of the topmost loaded child to see if there's one that needed it\n let tileID = topmostLoadedID;\n while (tileID.overscaledZ > zoom) {\n tileID = tileID.scaledTo(tileID.overscaledZ - 1);\n\n if (idealTiles[tileID.key]) {\n // found a parent that needed a loaded child; retain that child\n retain[topmostLoadedID.key] = topmostLoadedID;\n break;\n }\n }\n }\n }\n\n /**\n * Find a loaded parent of the given tile (up to minCoveringZoom)\n */\n findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): Tile {\n if (tileID.key in this._loadedParentTiles) {\n const parent = this._loadedParentTiles[tileID.key];\n if (parent && parent.tileID.overscaledZ >= minCoveringZoom) {\n return parent;\n } else {\n return null;\n }\n }\n for (let z = tileID.overscaledZ - 1; z >= minCoveringZoom; z--) {\n const parentTileID = tileID.scaledTo(z);\n const tile = this._getLoadedTile(parentTileID);\n if (tile) {\n return tile;\n }\n }\n }\n\n _getLoadedTile(tileID: OverscaledTileID): Tile {\n const tile = this._tiles[tileID.key];\n if (tile && tile.hasData()) {\n return tile;\n }\n // TileCache ignores wrap in lookup.\n const cachedTile = this._cache.getByKey(tileID.wrapped().key);\n return cachedTile;\n }\n\n /**\n * Resizes the tile cache based on the current viewport's size\n * or the maxTileCacheSize option passed during map creation\n *\n * Larger viewports use more tiles and need larger caches. Larger viewports\n * are more likely to be found on devices with more memory and on pages where\n * the map is more important.\n */\n updateCacheSize(transform: Transform) {\n const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1;\n const heightInTiles = Math.ceil(transform.height / this._source.tileSize) + 1;\n const approxTilesInView = widthInTiles * heightInTiles;\n const commonZoomRange = this._maxTileCacheZoomLevels === null ?\n config.MAX_TILE_CACHE_ZOOM_LEVELS : this._maxTileCacheZoomLevels;\n const viewDependentMaxSize = Math.floor(approxTilesInView * commonZoomRange);\n const maxSize = typeof this._maxTileCacheSize === 'number' ?\n Math.min(this._maxTileCacheSize, viewDependentMaxSize) : viewDependentMaxSize;\n\n this._cache.setMaxSize(maxSize);\n }\n\n handleWrapJump(lng: number) {\n // On top of the regular z/x/y values, TileIDs have a `wrap` value that specify\n // which cppy of the world the tile belongs to. For example, at `lng: 10` you\n // might render z/x/y/0 while at `lng: 370` you would render z/x/y/1.\n //\n // When lng values get wrapped (going from `lng: 370` to `long: 10`) you expect\n // to see the same thing on the screen (370 degrees and 10 degrees is the same\n // place in the world) but all the TileIDs will have different wrap values.\n //\n // In order to make this transition seamless, we calculate the rounded difference of\n // \"worlds\" between the last frame and the current frame. If the map panned by\n // a world, then we can assign all the tiles new TileIDs with updated wrap values.\n // For example, assign z/x/y/1 a new id: z/x/y/0. It is the same tile, just rendered\n // in a different position.\n //\n // This enables us to reuse the tiles at more ideal locations and prevent flickering.\n const prevLng = this._prevLng === undefined ? lng : this._prevLng;\n const lngDifference = lng - prevLng;\n const worldDifference = lngDifference / 360;\n const wrapDelta = Math.round(worldDifference);\n this._prevLng = lng;\n\n if (wrapDelta) {\n const tiles: {[_: string]: Tile} = {};\n for (const key in this._tiles) {\n const tile = this._tiles[key];\n tile.tileID = tile.tileID.unwrapTo(tile.tileID.wrap + wrapDelta);\n tiles[tile.tileID.key] = tile;\n }\n this._tiles = tiles;\n\n // Reset tile reload timers\n for (const id in this._timers) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n this._setTileReloadTimer(id, tile);\n }\n }\n }\n\n /**\n * Removes tiles that are outside the viewport and adds new tiles that\n * are inside the viewport.\n */\n update(transform: Transform, terrain?: Terrain) {\n this.transform = transform;\n this.terrain = terrain;\n if (!this._sourceLoaded || this._paused) { return; }\n\n this.updateCacheSize(transform);\n this.handleWrapJump(this.transform.center.lng);\n\n // Covered is a list of retained tiles who's areas are fully covered by other,\n // better, retained tiles. They are not drawn separately.\n this._coveredTiles = {};\n\n let idealTileIDs;\n if (!this.used && !this.usedForTerrain) {\n idealTileIDs = [];\n } else if (this._source.tileID) {\n idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID)\n .map((unwrapped) => new OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y));\n } else {\n idealTileIDs = transform.coveringTiles({\n tileSize: this.usedForTerrain ? this.tileSize : this._source.tileSize,\n minzoom: this._source.minzoom,\n maxzoom: this._source.maxzoom,\n roundZoom: this.usedForTerrain ? false : this._source.roundZoom,\n reparseOverscaled: this._source.reparseOverscaled,\n terrain\n });\n\n if (this._source.hasTile) {\n idealTileIDs = idealTileIDs.filter((coord) => (this._source.hasTile as any)(coord));\n }\n }\n\n // Determine the overzooming/underzooming amounts.\n const zoom = transform.coveringZoomLevel(this._source);\n const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);\n const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);\n\n // When sourcecache is used for terrain also load parent tiles to avoid flickering when zooming out\n if (this.usedForTerrain) {\n const parents = {};\n for (const tileID of idealTileIDs) {\n if (tileID.canonical.z > this._source.minzoom) {\n const parent = tileID.scaledTo(tileID.canonical.z - 1);\n parents[parent.key] = parent;\n // load very low zoom to calculate tile visibility in transform.coveringTiles and high zoomlevels correct\n const parent2 = tileID.scaledTo(Math.max(this._source.minzoom, Math.min(tileID.canonical.z, 5)));\n parents[parent2.key] = parent2;\n }\n }\n idealTileIDs = idealTileIDs.concat(Object.values(parents));\n }\n\n const noPendingDataEmissions = idealTileIDs.length === 0 && !this._updated && this._didEmitContent;\n this._updated = true;\n // if we won't have any tiles to fetch and content is already emitted\n // there will be no more data emissions, so we need to emit the event with isSourceLoaded = true\n if (noPendingDataEmissions) {\n this.fire(new Event('data', {sourceDataType: 'idle', dataType: 'source', sourceId: this.id}));\n }\n\n // Retain is a list of tiles that we shouldn't delete, even if they are not\n // the most ideal tile for the current viewport. This may include tiles like\n // parent or child tiles that are *already* loaded.\n const retain = this._updateRetainedTiles(idealTileIDs, zoom);\n\n if (isRasterType(this._source.type)) {\n const parentsForFading: {[_: string]: OverscaledTileID} = {};\n const fadingTiles = {};\n const ids = Object.keys(retain);\n const now = browser.now();\n for (const id of ids) {\n const tileID = retain[id];\n\n const tile = this._tiles[id];\n\n // when fadeEndTime is 0, the tile is created but registerFadeDuration\n // has not been called, therefore must be kept in fadingTiles dictionary\n // for next round of rendering\n if (!tile || (tile.fadeEndTime !== 0 && tile.fadeEndTime <= now)) {\n continue;\n }\n\n // if the tile is loaded but still fading in, find parents to cross-fade with it\n const parentTile = this.findLoadedParent(tileID, minCoveringZoom);\n if (parentTile) {\n this._addTile(parentTile.tileID);\n parentsForFading[parentTile.tileID.key] = parentTile.tileID;\n }\n\n fadingTiles[id] = tileID;\n }\n\n // for tiles that are still fading in, also find children to cross-fade with\n this._retainLoadedChildren(fadingTiles, zoom, maxCoveringZoom, retain);\n\n for (const id in parentsForFading) {\n if (!retain[id]) {\n // If a tile is only needed for fading, mark it as covered so that it isn't rendered on it's own.\n this._coveredTiles[id] = true;\n retain[id] = parentsForFading[id];\n }\n }\n\n // disable fading logic in terrain3D mode to avoid rendering two tiles on the same place\n if (terrain) {\n const idealRasterTileIDs: {[_: string]: OverscaledTileID} = {};\n const missingTileIDs: {[_: string]: OverscaledTileID} = {};\n for (const tileID of idealTileIDs) {\n if (this._tiles[tileID.key].hasData())\n idealRasterTileIDs[tileID.key] = tileID;\n else\n missingTileIDs[tileID.key] = tileID;\n }\n // search for a complete set of children for each missing tile\n for (const key in missingTileIDs) {\n const children = missingTileIDs[key].children(this._source.maxzoom);\n if (this._tiles[children[0].key] && this._tiles[children[1].key] && this._tiles[children[2].key] && this._tiles[children[3].key]) {\n idealRasterTileIDs[children[0].key] = retain[children[0].key] = children[0];\n idealRasterTileIDs[children[1].key] = retain[children[1].key] = children[1];\n idealRasterTileIDs[children[2].key] = retain[children[2].key] = children[2];\n idealRasterTileIDs[children[3].key] = retain[children[3].key] = children[3];\n delete missingTileIDs[key];\n }\n }\n // search for parent for each missing tile\n for (const key in missingTileIDs) {\n const parent = this.findLoadedParent(missingTileIDs[key], this._source.minzoom);\n if (parent) {\n idealRasterTileIDs[parent.tileID.key] = retain[parent.tileID.key] = parent.tileID;\n // remove idealTiles which would be rendered twice\n for (const key in idealRasterTileIDs) {\n if (idealRasterTileIDs[key].isChildOf(parent.tileID)) delete idealRasterTileIDs[key];\n }\n }\n }\n // cover all tiles which are not needed\n for (const key in this._tiles) {\n if (!idealRasterTileIDs[key]) this._coveredTiles[key] = true;\n }\n }\n }\n\n for (const retainedId in retain) {\n // Make sure retained tiles always clear any existing fade holds\n // so that if they're removed again their fade timer starts fresh.\n this._tiles[retainedId].clearFadeHold();\n }\n\n // Remove the tiles we don't need anymore.\n const remove = keysDifference(this._tiles, retain);\n for (const tileID of remove) {\n const tile = this._tiles[tileID];\n if (tile.hasSymbolBuckets && !tile.holdingForFade()) {\n tile.setHoldDuration(this.map._fadeDuration);\n } else if (!tile.hasSymbolBuckets || tile.symbolFadeFinished()) {\n this._removeTile(tileID);\n }\n }\n\n // Construct a cache of loaded parents\n this._updateLoadedParentTileCache();\n }\n\n releaseSymbolFadeTiles() {\n for (const id in this._tiles) {\n if (this._tiles[id].holdingForFade()) {\n this._removeTile(id);\n }\n }\n }\n\n _updateRetainedTiles(idealTileIDs: Array, zoom: number): {[_: string]: OverscaledTileID} {\n const retain: {[_: string]: OverscaledTileID} = {};\n const checked: {[_: string]: boolean} = {};\n const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);\n const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);\n\n const missingTiles = {};\n for (const tileID of idealTileIDs) {\n const tile = this._addTile(tileID);\n\n // retain the tile even if it's not loaded because it's an ideal tile.\n retain[tileID.key] = tileID;\n\n if (tile.hasData()) continue;\n\n if (zoom < this._source.maxzoom) {\n // save missing tiles that potentially have loaded children\n missingTiles[tileID.key] = tileID;\n }\n }\n\n // retain any loaded children of ideal tiles up to maxCoveringZoom\n this._retainLoadedChildren(missingTiles, zoom, maxCoveringZoom, retain);\n\n for (const tileID of idealTileIDs) {\n let tile = this._tiles[tileID.key];\n\n if (tile.hasData()) continue;\n\n // The tile we require is not yet loaded or does not exist;\n // Attempt to find children that fully cover it.\n\n if (zoom + 1 > this._source.maxzoom) {\n // We're looking for an overzoomed child tile.\n const childCoord = tileID.children(this._source.maxzoom)[0];\n const childTile = this.getTile(childCoord);\n if (!!childTile && childTile.hasData()) {\n retain[childCoord.key] = childCoord;\n continue; // tile is covered by overzoomed child\n }\n } else {\n // check if all 4 immediate children are loaded (i.e. the missing ideal tile is covered)\n const children = tileID.children(this._source.maxzoom);\n\n if (retain[children[0].key] &&\n retain[children[1].key] &&\n retain[children[2].key] &&\n retain[children[3].key]) continue; // tile is covered by children\n }\n\n // We couldn't find child tiles that entirely cover the ideal tile; look for parents now.\n\n // As we ascend up the tile pyramid of the ideal tile, we check whether the parent\n // tile has been previously requested (and errored because we only loop over tiles with no data)\n // in order to determine if we need to request its parent.\n let parentWasRequested = tile.wasRequested();\n\n for (let overscaledZ = tileID.overscaledZ - 1; overscaledZ >= minCoveringZoom; --overscaledZ) {\n const parentId = tileID.scaledTo(overscaledZ);\n\n // Break parent tile ascent if this route has been previously checked by another child.\n if (checked[parentId.key]) break;\n checked[parentId.key] = true;\n\n tile = this.getTile(parentId);\n if (!tile && parentWasRequested) {\n tile = this._addTile(parentId);\n }\n if (tile) {\n const hasData = tile.hasData();\n if (parentWasRequested || hasData) {\n retain[parentId.key] = parentId;\n }\n // Save the current values, since they're the parent of the next iteration\n // of the parent tile ascent loop.\n parentWasRequested = tile.wasRequested();\n if (hasData) break;\n }\n }\n }\n\n return retain;\n }\n\n _updateLoadedParentTileCache() {\n this._loadedParentTiles = {};\n\n for (const tileKey in this._tiles) {\n const path = [];\n let parentTile: Tile;\n let currentId = this._tiles[tileKey].tileID;\n\n // Find the closest loaded ancestor by traversing the tile tree towards the root and\n // caching results along the way\n while (currentId.overscaledZ > 0) {\n\n // Do we have a cached result from previous traversals?\n if (currentId.key in this._loadedParentTiles) {\n parentTile = this._loadedParentTiles[currentId.key];\n break;\n }\n\n path.push(currentId.key);\n\n // Is the parent loaded?\n const parentId = currentId.scaledTo(currentId.overscaledZ - 1);\n parentTile = this._getLoadedTile(parentId);\n if (parentTile) {\n break;\n }\n\n currentId = parentId;\n }\n\n // Cache the result of this traversal to all newly visited tiles\n for (const key of path) {\n this._loadedParentTiles[key] = parentTile;\n }\n }\n }\n\n /**\n * Add a tile, given its coordinate, to the pyramid.\n */\n _addTile(tileID: OverscaledTileID): Tile {\n let tile = this._tiles[tileID.key];\n if (tile)\n return tile;\n\n tile = this._cache.getAndRemove(tileID);\n if (tile) {\n this._setTileReloadTimer(tileID.key, tile);\n // set the tileID because the cached tile could have had a different wrap value\n tile.tileID = tileID;\n this._state.initializeTileState(tile, this.map ? this.map.painter : null);\n if (this._cacheTimers[tileID.key]) {\n clearTimeout(this._cacheTimers[tileID.key]);\n delete this._cacheTimers[tileID.key];\n this._setTileReloadTimer(tileID.key, tile);\n }\n }\n\n const cached = tile;\n\n if (!tile) {\n tile = new Tile(tileID, this._source.tileSize * tileID.overscaleFactor());\n this._loadTile(tile, this._tileLoaded.bind(this, tile, tileID.key, tile.state));\n }\n\n tile.uses++;\n this._tiles[tileID.key] = tile;\n if (!cached) {\n this._source.fire(new Event('dataloading', {tile, coord: tile.tileID, dataType: 'source'}));\n }\n\n return tile;\n }\n\n _setTileReloadTimer(id: string, tile: Tile) {\n if (id in this._timers) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n\n const expiryTimeout = tile.getExpiryTimeout();\n if (expiryTimeout) {\n this._timers[id] = setTimeout(() => {\n this._reloadTile(id, 'expired');\n delete this._timers[id];\n }, expiryTimeout);\n }\n }\n\n /**\n * Remove a tile, given its id, from the pyramid\n */\n _removeTile(id: string) {\n const tile = this._tiles[id];\n if (!tile)\n return;\n\n tile.uses--;\n delete this._tiles[id];\n if (this._timers[id]) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n\n if (tile.uses > 0)\n return;\n\n if (tile.hasData() && tile.state !== 'reloading') {\n this._cache.add(tile.tileID, tile, tile.getExpiryTimeout());\n } else {\n tile.aborted = true;\n this._abortTile(tile);\n this._unloadTile(tile);\n }\n }\n\n /**\n * Remove all tiles from this pyramid\n */\n clearTiles() {\n this._shouldReloadOnResume = false;\n this._paused = false;\n\n for (const id in this._tiles)\n this._removeTile(id);\n\n this._cache.reset();\n }\n\n /**\n * Search through our current tiles and attempt to find the tiles that\n * cover the given bounds.\n * @param pointQueryGeometry - coordinates of the corners of bounding rectangle\n * @returns result items have `{tile, minX, maxX, minY, maxY}`, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile.\n */\n tilesIn(pointQueryGeometry: Array, maxPitchScaleFactor: number, has3DLayer: boolean): any[] {\n\n const tileResults = [];\n\n const transform = this.transform;\n if (!transform) return tileResults;\n\n const cameraPointQueryGeometry = has3DLayer ?\n transform.getCameraQueryGeometry(pointQueryGeometry) :\n pointQueryGeometry;\n\n const queryGeometry = pointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain));\n const cameraQueryGeometry = cameraPointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain));\n\n const ids = this.getIds();\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const p of cameraQueryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n\n for (let i = 0; i < ids.length; i++) {\n const tile = this._tiles[ids[i]];\n if (tile.holdingForFade()) {\n // Tiles held for fading are covered by tiles that are closer to ideal\n continue;\n }\n const tileID = tile.tileID;\n const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);\n const queryPadding = maxPitchScaleFactor * tile.queryPadding * EXTENT / tile.tileSize / scale;\n\n const tileSpaceBounds = [\n tileID.getTilePoint(new MercatorCoordinate(minX, minY)),\n tileID.getTilePoint(new MercatorCoordinate(maxX, maxY))\n ];\n\n if (tileSpaceBounds[0].x - queryPadding < EXTENT && tileSpaceBounds[0].y - queryPadding < EXTENT &&\n tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) {\n\n const tileSpaceQueryGeometry: Array = queryGeometry.map((c) => tileID.getTilePoint(c));\n const tileSpaceCameraQueryGeometry = cameraQueryGeometry.map((c) => tileID.getTilePoint(c));\n\n tileResults.push({\n tile,\n tileID,\n queryGeometry: tileSpaceQueryGeometry,\n cameraQueryGeometry: tileSpaceCameraQueryGeometry,\n scale\n });\n }\n }\n\n return tileResults;\n }\n\n getVisibleCoordinates(symbolLayer?: boolean): Array {\n const coords = this.getRenderableIds(symbolLayer).map((id) => this._tiles[id].tileID);\n for (const coord of coords) {\n coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped());\n }\n return coords;\n }\n\n hasTransition() {\n if (this._source.hasTransition()) {\n return true;\n }\n\n if (isRasterType(this._source.type)) {\n const now = browser.now();\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n if (tile.fadeEndTime >= now) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Set the value of a particular state for a feature\n */\n setFeatureState(sourceLayer: string, featureId: number | string, state: any) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n this._state.updateState(sourceLayer, featureId, state);\n }\n\n /**\n * Resets the value of a particular state key for a feature\n */\n removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n this._state.removeFeatureState(sourceLayer, featureId, key);\n }\n\n /**\n * Get the entire state object for a feature\n */\n getFeatureState(sourceLayer: string, featureId: number | string) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n return this._state.getState(sourceLayer, featureId);\n }\n\n /**\n * Sets the set of keys that the tile depends on. This allows tiles to\n * be reloaded when their dependencies change.\n */\n setDependencies(tileKey: string, namespace: string, dependencies: Array) {\n const tile = this._tiles[tileKey];\n if (tile) {\n tile.setDependencies(namespace, dependencies);\n }\n }\n\n /**\n * Reloads all tiles that depend on the given keys.\n */\n reloadTilesForDependencies(namespaces: Array, keys: Array) {\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n if (tile.hasDependency(namespaces, keys)) {\n this._reloadTile(id, 'reloading');\n }\n }\n this._cache.filter(tile => !tile.hasDependency(namespaces, keys));\n }\n}\n\nSourceCache.maxOverzooming = 10;\nSourceCache.maxUnderzooming = 3;\n\nfunction compareTileId(a: OverscaledTileID, b: OverscaledTileID): number {\n // Different copies of the world are sorted based on their distance to the center.\n // Wrap values are converted to unsigned distances by reserving odd number for copies\n // with negative wrap and even numbers for copies with positive wrap.\n const aWrap = Math.abs(a.wrap * 2) - +(a.wrap < 0);\n const bWrap = Math.abs(b.wrap * 2) - +(b.wrap < 0);\n return a.overscaledZ - b.overscaledZ || bWrap - aWrap || b.canonical.y - a.canonical.y || b.canonical.x - a.canonical.x;\n}\n\nfunction isRasterType(type) {\n return type === 'raster' || type === 'image' || type === 'video';\n}\n","import {workerFactory} from './web_worker';\nimport {browser} from './browser';\nimport {isSafari} from './util';\nimport {ActorTarget} from './actor';\n\nexport const PRELOAD_POOL_ID = 'mapboxgl_preloaded_worker_pool';\n\n/**\n * Constructs a worker pool.\n */\nexport class WorkerPool {\n static workerCount: number;\n\n active: {\n [_ in number | string]: boolean;\n };\n workers: Array;\n\n constructor() {\n this.active = {};\n }\n\n acquire(mapId: number | string): Array {\n if (!this.workers) {\n // Lazily look up the value of mapboxgl.workerCount so that\n // client code has had a chance to set it.\n this.workers = [];\n while (this.workers.length < WorkerPool.workerCount) {\n this.workers.push(workerFactory());\n }\n }\n\n this.active[mapId] = true;\n return this.workers.slice();\n }\n\n release(mapId: number | string) {\n delete this.active[mapId];\n if (this.numActive() === 0) {\n this.workers.forEach((w) => {\n w.terminate();\n });\n this.workers = null;\n }\n }\n\n isPreloaded(): boolean {\n return !!this.active[PRELOAD_POOL_ID];\n }\n\n numActive(): number {\n return Object.keys(this.active).length;\n }\n}\n\n// Based on results from A/B testing: https://github.com/maplibre/maplibre-gl-js/pull/2354\nconst availableLogicalProcessors = Math.floor(browser.hardwareConcurrency / 2);\nWorkerPool.workerCount = isSafari(globalThis) ? Math.max(Math.min(availableLogicalProcessors, 3), 1) : 1;\n","import {config} from './config';\n\nimport type {WorkerSource} from '../source/worker_source';\n\nexport interface WorkerGlobalScopeInterface {\n importScripts(...urls: Array): void;\n registerWorkerSource: (\n b: string,\n a: {\n new(...args: any): WorkerSource;\n }\n ) => void;\n registerRTLTextPlugin: (_: any) => void;\n}\n\nexport function workerFactory() {\n return new Worker(config.WORKER_URL);\n}\n","import {WorkerPool, PRELOAD_POOL_ID} from './worker_pool';\n\nlet globalWorkerPool;\n\n/**\n * Creates (if necessary) and returns the single, global WorkerPool instance\n * to be shared across each Map\n */\nexport function getGlobalWorkerPool() {\n if (!globalWorkerPool) {\n globalWorkerPool = new WorkerPool();\n }\n return globalWorkerPool;\n}\n\nexport function prewarm() {\n const workerPool = getGlobalWorkerPool();\n workerPool.acquire(PRELOAD_POOL_ID);\n}\n\nexport function clearPrewarmedResources() {\n const pool = globalWorkerPool;\n if (pool) {\n // Remove the pool only if all maps that referenced the preloaded global worker pool have been removed.\n if (pool.isPreloaded() && pool.numActive() === 1) {\n pool.release(PRELOAD_POOL_ID);\n globalWorkerPool = null;\n } else {\n console.warn('Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()');\n }\n }\n}\n","import {clamp} from '../util/util';\nimport Point from '@mapbox/point-geometry';\n\nexport class PathInterpolator {\n points: Array;\n length: number;\n paddedLength: number;\n padding: number;\n _distances: Array;\n\n constructor(points_?: Array | null, padding_?: number | null) {\n this.reset(points_, padding_);\n }\n\n reset(points_?: Array | null, padding_?: number | null) {\n this.points = points_ || [];\n\n // Compute cumulative distance from first point to every other point in the segment.\n // Last entry in the array is total length of the path\n this._distances = [0.0];\n\n for (let i = 1; i < this.points.length; i++) {\n this._distances[i] = this._distances[i - 1] + this.points[i].dist(this.points[i - 1]);\n }\n\n this.length = this._distances[this._distances.length - 1];\n this.padding = Math.min(padding_ || 0, this.length * 0.5);\n this.paddedLength = this.length - this.padding * 2.0;\n }\n\n lerp(t: number): Point {\n if (this.points.length === 1) {\n return this.points[0];\n }\n\n t = clamp(t, 0, 1);\n\n // Find the correct segment [p0, p1] where p0 <= x < p1\n let currentIndex = 1;\n let distOfCurrentIdx = this._distances[currentIndex];\n const distToTarget = t * this.paddedLength + this.padding;\n\n while (distOfCurrentIdx < distToTarget && currentIndex < this._distances.length) {\n distOfCurrentIdx = this._distances[++currentIndex];\n }\n\n // Interpolate between the two points of the segment\n const idxOfPrevPoint = currentIndex - 1;\n const distOfPrevIdx = this._distances[idxOfPrevPoint];\n const segmentLength = distOfCurrentIdx - distOfPrevIdx;\n const segmentT = segmentLength > 0 ? (distToTarget - distOfPrevIdx) / segmentLength : 0;\n\n return this.points[idxOfPrevPoint].mult(1.0 - segmentT).add(this.points[currentIndex].mult(segmentT));\n }\n}\n","import type {OverlapMode} from '../style/style_layer/overlap_mode';\n\ntype QueryArgs = {\n hitTest: boolean;\n overlapMode?: OverlapMode;\n circle?: {\n x: number;\n y: number;\n radius: number;\n };\n seenUids: {\n box: {\n [_: number]: boolean;\n };\n circle: {\n [_: number]: boolean;\n };\n };\n};\n\ntype QueryResult = {\n key: T;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n};\n\n/**\n * A key for the grid\n */\nexport type GridKey = {\n overlapMode?: OverlapMode;\n}\n\nfunction overlapAllowed(overlapA: OverlapMode, overlapB: OverlapMode): boolean {\n let allowed = true;\n\n if (overlapA === 'always') {\n // symbol A using 'always' overlap - allowed to overlap anything.\n } else if (overlapA === 'never' || overlapB === 'never') {\n // symbol A using 'never' overlap - can't overlap anything\n // symbol A using 'cooperative' overlap - can overlap 'always' or 'cooperative' symbol; can't overlap 'never'\n allowed = false;\n }\n\n return allowed;\n}\n\n/**\n * @internal\n * GridIndex is a data structure for testing the intersection of\n * circles and rectangles in a 2d plane.\n * It is optimized for rapid insertion and querying.\n * GridIndex splits the plane into a set of \"cells\" and keeps track\n * of which geometries intersect with each cell. At query time,\n * full geometry comparisons are only done for items that share\n * at least one cell. As long as the geometries are relatively\n * uniformly distributed across the plane, this greatly reduces\n * the number of comparisons necessary.\n */\nexport class GridIndex {\n circleKeys: Array;\n boxKeys: Array;\n boxCells: Array>;\n circleCells: Array>;\n bboxes: Array;\n circles: Array;\n xCellCount: number;\n yCellCount: number;\n width: number;\n height: number;\n xScale: number;\n yScale: number;\n boxUid: number;\n circleUid: number;\n\n constructor (width: number, height: number, cellSize: number) {\n const boxCells = this.boxCells = [];\n const circleCells = this.circleCells = [];\n\n // More cells -> fewer geometries to check per cell, but items tend\n // to be split across more cells.\n // Sweet spot allows most small items to fit in one cell\n this.xCellCount = Math.ceil(width / cellSize);\n this.yCellCount = Math.ceil(height / cellSize);\n\n for (let i = 0; i < this.xCellCount * this.yCellCount; i++) {\n boxCells.push([]);\n circleCells.push([]);\n }\n this.circleKeys = [];\n this.boxKeys = [];\n this.bboxes = [];\n this.circles = [];\n\n this.width = width;\n this.height = height;\n this.xScale = this.xCellCount / width;\n this.yScale = this.yCellCount / height;\n this.boxUid = 0;\n this.circleUid = 0;\n }\n\n keysLength() {\n return this.boxKeys.length + this.circleKeys.length;\n }\n\n insert(key: T, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertBoxCell, this.boxUid++);\n this.boxKeys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n insertCircle(key: T, x: number, y: number, radius: number) {\n // Insert circle into grid for all cells in the circumscribing square\n // It's more than necessary (by a factor of 4/PI), but fast to insert\n this._forEachCell(x - radius, y - radius, x + radius, y + radius, this._insertCircleCell, this.circleUid++);\n this.circleKeys.push(key);\n this.circles.push(x);\n this.circles.push(y);\n this.circles.push(radius);\n }\n\n private _insertBoxCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.boxCells[cellIndex].push(uid);\n }\n\n private _insertCircleCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.circleCells[cellIndex].push(uid);\n }\n\n private _query(x1: number, y1: number, x2: number, y2: number, hitTest: boolean, overlapMode: OverlapMode, predicate?: (key: T) => boolean): Array> {\n if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {\n return [];\n }\n const result: Array> = [];\n if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {\n if (hitTest) {\n // Covers the entire grid, so collides with everything\n return [{\n key: null,\n x1,\n y1,\n x2,\n y2\n }];\n }\n for (let boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {\n result.push({\n key: this.boxKeys[boxUid],\n x1: this.bboxes[boxUid * 4],\n y1: this.bboxes[boxUid * 4 + 1],\n x2: this.bboxes[boxUid * 4 + 2],\n y2: this.bboxes[boxUid * 4 + 3]\n });\n }\n for (let circleUid = 0; circleUid < this.circleKeys.length; circleUid++) {\n const x = this.circles[circleUid * 3];\n const y = this.circles[circleUid * 3 + 1];\n const radius = this.circles[circleUid * 3 + 2];\n result.push({\n key: this.circleKeys[circleUid],\n x1: x - radius,\n y1: y - radius,\n x2: x + radius,\n y2: y + radius\n });\n }\n } else {\n const queryArgs: QueryArgs = {\n hitTest,\n overlapMode,\n seenUids: {box: {}, circle: {}}\n };\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, queryArgs, predicate);\n }\n\n return result;\n }\n\n query(x1: number, y1: number, x2: number, y2: number): Array> {\n return this._query(x1, y1, x2, y2, false, null);\n }\n\n hitTest(x1: number, y1: number, x2: number, y2: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean {\n return this._query(x1, y1, x2, y2, true, overlapMode, predicate).length > 0;\n }\n\n hitTestCircle(x: number, y: number, radius: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean {\n // Insert circle into grid for all cells in the circumscribing square\n // It's more than necessary (by a factor of 4/PI), but fast to insert\n const x1 = x - radius;\n const x2 = x + radius;\n const y1 = y - radius;\n const y2 = y + radius;\n if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {\n return false;\n }\n\n // Box query early exits if the bounding box is larger than the grid, but we don't do\n // the equivalent calculation for circle queries because early exit is less likely\n // and the calculation is more expensive\n const result: boolean[] = [];\n const queryArgs: QueryArgs = {\n hitTest: true,\n overlapMode,\n circle: {x, y, radius},\n seenUids: {box: {}, circle: {}}\n };\n this._forEachCell(x1, y1, x2, y2, this._queryCellCircle, result, queryArgs, predicate);\n return result.length > 0;\n }\n\n private _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array>, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean {\n const {seenUids, hitTest, overlapMode} = queryArgs;\n const boxCell = this.boxCells[cellIndex];\n\n if (boxCell !== null) {\n const bboxes = this.bboxes;\n for (const boxUid of boxCell) {\n if (!seenUids.box[boxUid]) {\n seenUids.box[boxUid] = true;\n const offset = boxUid * 4;\n const key = this.boxKeys[boxUid];\n\n if ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]) &&\n (!predicate || predicate(key))) {\n if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push({\n key,\n x1: bboxes[offset],\n y1: bboxes[offset + 1],\n x2: bboxes[offset + 2],\n y2: bboxes[offset + 3]\n });\n if (hitTest) {\n // true return value stops the query after first match\n return true;\n }\n }\n }\n }\n }\n }\n const circleCell = this.circleCells[cellIndex];\n if (circleCell !== null) {\n const circles = this.circles;\n for (const circleUid of circleCell) {\n if (!seenUids.circle[circleUid]) {\n seenUids.circle[circleUid] = true;\n const offset = circleUid * 3;\n const key = this.circleKeys[circleUid];\n\n if (this._circleAndRectCollide(\n circles[offset],\n circles[offset + 1],\n circles[offset + 2],\n x1,\n y1,\n x2,\n y2) &&\n (!predicate || predicate(key))) {\n if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) {\n const x = circles[offset];\n const y = circles[offset + 1];\n const radius = circles[offset + 2];\n result.push({\n key,\n x1: x - radius,\n y1: y - radius,\n x2: x + radius,\n y2: y + radius\n });\n if (hitTest) {\n // true return value stops the query after first match\n return true;\n }\n }\n }\n }\n }\n }\n\n // false return to continue query\n return false;\n }\n\n private _queryCellCircle(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean {\n const {circle, seenUids, overlapMode} = queryArgs;\n const boxCell = this.boxCells[cellIndex];\n\n if (boxCell !== null) {\n const bboxes = this.bboxes;\n for (const boxUid of boxCell) {\n if (!seenUids.box[boxUid]) {\n seenUids.box[boxUid] = true;\n const offset = boxUid * 4;\n const key = this.boxKeys[boxUid];\n if (this._circleAndRectCollide(\n circle.x,\n circle.y,\n circle.radius,\n bboxes[offset + 0],\n bboxes[offset + 1],\n bboxes[offset + 2],\n bboxes[offset + 3]) &&\n (!predicate || predicate(key)) &&\n !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push(true);\n return true;\n }\n }\n }\n }\n\n const circleCell = this.circleCells[cellIndex];\n if (circleCell !== null) {\n const circles = this.circles;\n for (const circleUid of circleCell) {\n if (!seenUids.circle[circleUid]) {\n seenUids.circle[circleUid] = true;\n const offset = circleUid * 3;\n const key = this.circleKeys[circleUid];\n if (this._circlesCollide(\n circles[offset],\n circles[offset + 1],\n circles[offset + 2],\n circle.x,\n circle.y,\n circle.radius) &&\n (!predicate || predicate(key)) &&\n !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push(true);\n return true;\n }\n }\n }\n }\n }\n\n private _forEachCell(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n fn: (x1: number, y1: number, x2: number, y2: number, cellIndex: number, arg1: TArg, arg2?: QueryArgs, predicate?: (key: T) => boolean) => boolean | void,\n arg1: TArg,\n arg2?: QueryArgs,\n predicate?: (key: T) => boolean) {\n const cx1 = this._convertToXCellCoord(x1);\n const cy1 = this._convertToYCellCoord(y1);\n const cx2 = this._convertToXCellCoord(x2);\n const cy2 = this._convertToYCellCoord(y2);\n\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.xCellCount * y + x;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) return;\n }\n }\n }\n\n private _convertToXCellCoord(x: number) {\n return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale)));\n }\n\n private _convertToYCellCoord(y: number) {\n return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));\n }\n\n private _circlesCollide(x1: number, y1: number, r1: number, x2: number, y2: number, r2: number): boolean {\n const dx = x2 - x1;\n const dy = y2 - y1;\n const bothRadii = r1 + r2;\n return (bothRadii * bothRadii) > (dx * dx + dy * dy);\n }\n\n private _circleAndRectCollide(\n circleX: number,\n circleY: number,\n radius: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number\n ): boolean {\n const halfRectWidth = (x2 - x1) / 2;\n const distX = Math.abs(circleX - (x1 + halfRectWidth));\n if (distX > (halfRectWidth + radius)) {\n return false;\n }\n\n const halfRectHeight = (y2 - y1) / 2;\n const distY = Math.abs(circleY - (y1 + halfRectHeight));\n if (distY > (halfRectHeight + radius)) {\n return false;\n }\n\n if (distX <= halfRectWidth || distY <= halfRectHeight) {\n return true;\n }\n\n const dx = distX - halfRectWidth;\n const dy = distY - halfRectHeight;\n return (dx * dx + dy * dy <= (radius * radius));\n }\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {mat4, vec4} from 'gl-matrix';\nimport * as symbolSize from './symbol_size';\nimport {addDynamicAttributes} from '../data/bucket/symbol_bucket';\n\nimport type {Painter} from '../render/painter';\nimport type {Transform} from '../geo/transform';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport type {\n GlyphOffsetArray,\n SymbolLineVertexArray,\n SymbolDynamicLayoutArray\n} from '../data/array_types.g';\nimport {WritingMode} from '../symbol/shaping';\nimport {findLineIntersection} from '../util/util';\n\nexport {updateLineLabels, hideGlyphs, getLabelPlaneMatrix, getGlCoordMatrix, project, getPerspectiveRatio, placeFirstAndLastGlyph, placeGlyphAlongLine, xyTransformMat4, projectVertexToViewport, findOffsetIntersectionPoint, transformToOffsetNormal};\n\n/*\n * # Overview of coordinate spaces\n *\n * ## Tile coordinate spaces\n * Each label has an anchor. Some labels have corresponding line geometries.\n * The points for both anchors and lines are stored in tile units. Each tile has it's own\n * coordinate space going from (0, 0) at the top left to (EXTENT, EXTENT) at the bottom right.\n *\n * ## GL coordinate space\n * At the end of everything, the vertex shader needs to produce a position in GL coordinate space,\n * which is (-1, 1) at the top left and (1, -1) in the bottom right.\n *\n * ## Map pixel coordinate spaces\n * Each tile has a pixel coordinate space. It's just the tile units scaled so that one unit is\n * whatever counts as 1 pixel at the current zoom.\n * This space is used for pitch-alignment=map, rotation-alignment=map\n *\n * ## Rotated map pixel coordinate spaces\n * Like the above, but rotated so axis of the space are aligned with the viewport instead of the tile.\n * This space is used for pitch-alignment=map, rotation-alignment=viewport\n *\n * ## Viewport pixel coordinate space\n * (0, 0) is at the top left of the canvas and (pixelWidth, pixelHeight) is at the bottom right corner\n * of the canvas. This space is used for pitch-alignment=viewport\n *\n *\n * # Vertex projection\n * It goes roughly like this:\n * 1. project the anchor and line from tile units into the correct label coordinate space\n * - map pixel space pitch-alignment=map rotation-alignment=map\n * - rotated map pixel space pitch-alignment=map rotation-alignment=viewport\n * - viewport pixel space pitch-alignment=viewport rotation-alignment=*\n * 2. if the label follows a line, find the point along the line that is the correct distance from the anchor.\n * 3. add the glyph's corner offset to the point from step 3\n * 4. convert from the label coordinate space to gl coordinates\n *\n * For horizontal labels we want to do step 1 in the shader for performance reasons (no cpu work).\n * This is what `u_label_plane_matrix` is used for.\n * For labels aligned with lines we have to steps 1 and 2 on the cpu since we need access to the line geometry.\n * This is what `updateLineLabels(...)` does.\n * Since the conversion is handled on the cpu we just set `u_label_plane_matrix` to an identity matrix.\n *\n * Steps 3 and 4 are done in the shaders for all labels.\n */\n\n/*\n * Returns a matrix for converting from tile units to the correct label coordinate space.\n */\nfunction getLabelPlaneMatrix(posMatrix: mat4,\n pitchWithMap: boolean,\n rotateWithMap: boolean,\n transform: Transform,\n pixelsToTileUnits: number) {\n const m = mat4.create();\n if (pitchWithMap) {\n mat4.scale(m, m, [1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1]);\n if (!rotateWithMap) {\n mat4.rotateZ(m, m, transform.angle);\n }\n } else {\n mat4.multiply(m, transform.labelPlaneMatrix, posMatrix);\n }\n return m;\n}\n\n/*\n * Returns a matrix for converting from the correct label coordinate space to gl coords.\n */\nfunction getGlCoordMatrix(posMatrix: mat4,\n pitchWithMap: boolean,\n rotateWithMap: boolean,\n transform: Transform,\n pixelsToTileUnits: number) {\n if (pitchWithMap) {\n const m = mat4.clone(posMatrix);\n mat4.scale(m, m, [pixelsToTileUnits, pixelsToTileUnits, 1]);\n if (!rotateWithMap) {\n mat4.rotateZ(m, m, -transform.angle);\n }\n return m;\n } else {\n return transform.glCoordMatrix;\n }\n}\n\nfunction project(point: Point, matrix: mat4, getElevation?: (x: number, y: number) => number) {\n let pos;\n if (getElevation) { // slow because of handle z-index\n pos = [point.x, point.y, getElevation(point.x, point.y), 1] as vec4;\n vec4.transformMat4(pos, pos, matrix);\n } else { // fast because of ignore z-index\n pos = [point.x, point.y, 0, 1] as vec4;\n xyTransformMat4(pos, pos, matrix);\n }\n const w = pos[3];\n return {\n point: new Point(pos[0] / w, pos[1] / w),\n signedDistanceFromCamera: w\n };\n}\n\nfunction getPerspectiveRatio(cameraToCenterDistance: number, signedDistanceFromCamera: number): number {\n return 0.5 + 0.5 * (cameraToCenterDistance / signedDistanceFromCamera);\n}\n\nfunction isVisible(anchorPos: vec4,\n clippingBuffer: [number, number]) {\n const x = anchorPos[0] / anchorPos[3];\n const y = anchorPos[1] / anchorPos[3];\n const inPaddedViewport = (\n x >= -clippingBuffer[0] &&\n x <= clippingBuffer[0] &&\n y >= -clippingBuffer[1] &&\n y <= clippingBuffer[1]);\n return inPaddedViewport;\n}\n\n/*\n * Update the `dynamicLayoutVertexBuffer` for the buffer with the correct glyph positions for the current map view.\n * This is only run on labels that are aligned with lines. Horizontal labels are handled entirely in the shader.\n */\nfunction updateLineLabels(bucket: SymbolBucket,\n posMatrix: mat4,\n painter: Painter,\n isText: boolean,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n pitchWithMap: boolean,\n keepUpright: boolean,\n rotateToLine: boolean,\n getElevation: (x: number, y: number) => number) {\n\n const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;\n const partiallyEvaluatedSize = symbolSize.evaluateSizeForZoom(sizeData, painter.transform.zoom);\n\n const clippingBuffer: [number, number] = [256 / painter.width * 2 + 1, 256 / painter.height * 2 + 1];\n\n const dynamicLayoutVertexArray = isText ?\n bucket.text.dynamicLayoutVertexArray :\n bucket.icon.dynamicLayoutVertexArray;\n dynamicLayoutVertexArray.clear();\n\n const lineVertexArray = bucket.lineVertexArray;\n const placedSymbols = isText ? bucket.text.placedSymbolArray : bucket.icon.placedSymbolArray;\n\n const aspectRatio = painter.transform.width / painter.transform.height;\n\n let useVertical = false;\n\n for (let s = 0; s < placedSymbols.length; s++) {\n const symbol = placedSymbols.get(s);\n\n // Don't do calculations for vertical glyphs unless the previous symbol was horizontal\n // and we determined that vertical glyphs were necessary.\n // Also don't do calculations for symbols that are collided and fully faded out\n if (symbol.hidden || symbol.writingMode === WritingMode.vertical && !useVertical) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n continue;\n }\n // Awkward... but we're counting on the paired \"vertical\" symbol coming immediately after its horizontal counterpart\n useVertical = false;\n\n let anchorPos;\n if (getElevation) { // slow because of handle z-index\n anchorPos = [symbol.anchorX, symbol.anchorY, getElevation(symbol.anchorX, symbol.anchorY), 1] as vec4;\n vec4.transformMat4(anchorPos, anchorPos, posMatrix);\n } else { // fast because of ignore z-index\n anchorPos = [symbol.anchorX, symbol.anchorY, 0, 1] as vec4;\n xyTransformMat4(anchorPos, anchorPos, posMatrix);\n }\n\n // Don't bother calculating the correct point for invisible labels.\n if (!isVisible(anchorPos, clippingBuffer)) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n continue;\n }\n\n const cameraToAnchorDistance = anchorPos[3];\n const perspectiveRatio = getPerspectiveRatio(painter.transform.cameraToCenterDistance, cameraToAnchorDistance);\n\n const fontSize = symbolSize.evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol);\n const pitchScaledFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;\n\n const tileAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);\n const anchorPoint = project(tileAnchorPoint, labelPlaneMatrix, getElevation).point;\n const projectionCache = {projections: {}, offsets: {}};\n\n const placeUnflipped: any = placeGlyphsAlongLine(symbol, pitchScaledFontSize, false /*unflipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix,\n bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation);\n\n useVertical = placeUnflipped.useVertical;\n\n if (placeUnflipped.notEnoughRoom || useVertical ||\n (placeUnflipped.needsFlipping &&\n (placeGlyphsAlongLine(symbol, pitchScaledFontSize, true /*flipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix,\n bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) as any).notEnoughRoom)) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n }\n }\n\n if (isText) {\n bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray);\n } else {\n bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray);\n }\n}\n\ntype FirstAndLastGlyphPlacement = {\n first: PlacedGlyph;\n last: PlacedGlyph;\n} | null;\n\n/*\n * Place the first and last glyph of a line label, projected to the label plane.\n * This function is called both during collision detection (to determine the label's size)\n * and during line label rendering (to make sure the label fits on the line geometry with\n * the current camera position, which may differ from the position used during collision detection).\n *\n * Calling this function has the effect of populating the \"projectionCache\" with all projected\n * vertex locations the label will need, making future calls to placeGlyphAlongLine (for all the\n * intermediate glyphs) much cheaper.\n *\n * Returns null if the label can't fit on the geometry\n */\nfunction placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffsetArray, lineOffsetX: number, lineOffsetY: number, flip: boolean, anchorPoint: Point, tileAnchorPoint: Point, symbol: any, lineVertexArray: SymbolLineVertexArray, labelPlaneMatrix: mat4, projectionCache: ProjectionCache, rotateToLine: boolean, getElevation: (x: number, y: number) => number): FirstAndLastGlyphPlacement {\n const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;\n const lineStartIndex = symbol.lineStartIndex;\n const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;\n\n const firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex);\n const lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1);\n\n const firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!firstPlacedGlyph)\n return null;\n\n const lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!lastPlacedGlyph)\n return null;\n\n return {first: firstPlacedGlyph, last: lastPlacedGlyph};\n}\n\nfunction requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRatio) {\n if (writingMode === WritingMode.horizontal) {\n // On top of choosing whether to flip, choose whether to render this version of the glyphs or the alternate\n // vertical glyphs. We can't just filter out vertical glyphs in the horizontal range because the horizontal\n // and vertical versions can have slightly different projections which could lead to angles where both or\n // neither showed.\n const rise = Math.abs(lastPoint.y - firstPoint.y);\n const run = Math.abs(lastPoint.x - firstPoint.x) * aspectRatio;\n if (rise > run) {\n return {useVertical: true};\n }\n }\n\n if (writingMode === WritingMode.vertical ? firstPoint.y < lastPoint.y : firstPoint.x > lastPoint.x) {\n // Includes \"horizontalOnly\" case for labels without vertical glyphs\n return {needsFlipping: true};\n }\n\n return null;\n}\n\n/*\n* Place first and last glyph along the line projected to label plane, and if they fit\n* iterate through all the intermediate glyphs, calculating their label plane positions\n* from the projected line.\n*\n* Finally, add resulting glyph position calculations to dynamicLayoutVertexArray for\n* upload to the GPU\n*/\nfunction placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) {\n const fontScale = fontSize / 24;\n const lineOffsetX = symbol.lineOffsetX * fontScale;\n const lineOffsetY = symbol.lineOffsetY * fontScale;\n\n let placedGlyphs;\n if (symbol.numGlyphs > 1) {\n const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;\n const lineStartIndex = symbol.lineStartIndex;\n const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;\n\n // Place the first and the last glyph in the label first, so we can figure out\n // the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode\n const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!firstAndLastGlyph) {\n return {notEnoughRoom: true};\n }\n const firstPoint = project(firstAndLastGlyph.first.point, glCoordMatrix, getElevation).point;\n const lastPoint = project(firstAndLastGlyph.last.point, glCoordMatrix, getElevation).point;\n\n if (keepUpright && !flip) {\n const orientationChange = requiresOrientationChange(symbol.writingMode, firstPoint, lastPoint, aspectRatio);\n if (orientationChange) {\n return orientationChange;\n }\n }\n\n placedGlyphs = [firstAndLastGlyph.first];\n for (let glyphIndex = symbol.glyphStartIndex + 1; glyphIndex < glyphEndIndex - 1; glyphIndex++) {\n // Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed\n placedGlyphs.push(placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation));\n }\n placedGlyphs.push(firstAndLastGlyph.last);\n } else {\n // Only a single glyph to place\n // So, determine whether to flip based on projected angle of the line segment it's on\n if (keepUpright && !flip) {\n const a = project(tileAnchorPoint, posMatrix, getElevation).point;\n const tileVertexIndex = (symbol.lineStartIndex + symbol.segment + 1);\n const tileSegmentEnd = new Point(lineVertexArray.getx(tileVertexIndex), lineVertexArray.gety(tileVertexIndex));\n const projectedVertex = project(tileSegmentEnd, posMatrix, getElevation);\n // We know the anchor will be in the viewport, but the end of the line segment may be\n // behind the plane of the camera, in which case we can use a point at any arbitrary (closer)\n // point on the segment.\n const b = (projectedVertex.signedDistanceFromCamera > 0) ?\n projectedVertex.point :\n projectTruncatedLineSegment(tileAnchorPoint, tileSegmentEnd, a, 1, posMatrix, getElevation);\n\n const orientationChange = requiresOrientationChange(symbol.writingMode, a, b, aspectRatio);\n if (orientationChange) {\n return orientationChange;\n }\n }\n const singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(symbol.glyphStartIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n symbol.lineStartIndex, symbol.lineStartIndex + symbol.lineLength, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!singleGlyph)\n return {notEnoughRoom: true};\n\n placedGlyphs = [singleGlyph];\n }\n\n for (const glyph of placedGlyphs) {\n addDynamicAttributes(dynamicLayoutVertexArray, glyph.point, glyph.angle);\n }\n return {};\n}\n\nfunction projectTruncatedLineSegment(previousTilePoint: Point, currentTilePoint: Point, previousProjectedPoint: Point, minimumLength: number, projectionMatrix: mat4, getElevation: (x: number, y: number) => number) {\n // We are assuming \"previousTilePoint\" won't project to a point within one unit of the camera plane\n // If it did, that would mean our label extended all the way out from within the viewport to a (very distant)\n // point near the plane of the camera. We wouldn't be able to render the label anyway once it crossed the\n // plane of the camera.\n const projectedUnitVertex = project(previousTilePoint.add(previousTilePoint.sub(currentTilePoint)._unit()), projectionMatrix, getElevation).point;\n const projectedUnitSegment = previousProjectedPoint.sub(projectedUnitVertex);\n\n return previousProjectedPoint.add(projectedUnitSegment._mult(minimumLength / projectedUnitSegment.mag()));\n}\n\ntype IndexToPointCache = { [lineIndex: number]: Point };\n\n/**\n * We calculate label-plane projected points for line vertices as we place glyphs along the line\n * Since we will use the same vertices for potentially many glyphs, cache the results for this bucket\n * over the course of the render. Each vertex location also potentially has one offset equivalent\n * for us to hold onto. The vertex indices are per-symbol-bucket.\n */\ntype ProjectionCache = {\n /**\n * tile-unit vertices projected into label-plane units\n */\n projections: IndexToPointCache;\n /**\n * label-plane vertices which have been shifted to follow an offset line\n */\n offsets: IndexToPointCache;\n};\n\n/**\n * Arguments necessary to project a vertex to the label plane\n */\ntype ProjectionArgs = {\n /**\n * Used to cache results, save cost if projecting the same vertex multiple times\n */\n projectionCache: ProjectionCache;\n /**\n * The array of tile-unit vertices transferred from worker\n */\n lineVertexArray: SymbolLineVertexArray;\n /**\n * Label plane projection matrix\n */\n labelPlaneMatrix: mat4;\n /**\n * Function to get elevation at a point\n * @param x - the x coordinate\n * @param y - the y coordinate\n */\n getElevation: (x: number, y: number) => number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n tileAnchorPoint: Point;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n distanceFromAnchor: number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n previousVertex: Point;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n direction: number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n absOffsetX: number;\n};\n\n/**\n * Transform a vertex from tile coordinates to label plane coordinates\n * @param index - index of vertex to project\n * @param projectionArgs - necessary data to project a vertex\n * @returns the vertex projected to the label plane\n */\nfunction projectVertexToViewport(index: number, projectionArgs: ProjectionArgs): Point {\n const {projectionCache, lineVertexArray, labelPlaneMatrix, tileAnchorPoint, distanceFromAnchor, getElevation, previousVertex, direction, absOffsetX} = projectionArgs;\n if (projectionCache.projections[index]) {\n return projectionCache.projections[index];\n }\n const currentVertex = new Point(lineVertexArray.getx(index), lineVertexArray.gety(index));\n const projection = project(currentVertex, labelPlaneMatrix, getElevation);\n if (projection.signedDistanceFromCamera > 0) {\n projectionCache.projections[index] = projection.point;\n return projection.point;\n }\n\n // The vertex is behind the plane of the camera, so we can't project it\n // Instead, we'll create a vertex along the line that's far enough to include the glyph\n const previousLineVertexIndex = index - direction;\n const previousTilePoint = distanceFromAnchor === 0 ?\n tileAnchorPoint :\n new Point(lineVertexArray.getx(previousLineVertexIndex), lineVertexArray.gety(previousLineVertexIndex));\n // Don't cache because the new vertex might not be far enough out for future glyphs on the same segment\n return projectTruncatedLineSegment(previousTilePoint, currentVertex, previousVertex, absOffsetX - distanceFromAnchor + 1, labelPlaneMatrix, getElevation);\n}\n\n/**\n * Calculate the normal vector for a line segment\n * @param segmentVector - will be mutated as a tiny optimization\n * @param offset - magnitude of resulting vector\n * @param direction - direction of line traversal\n * @returns a normal vector from the segment, with magnitude equal to offset amount\n */\nfunction transformToOffsetNormal(segmentVector: Point, offset: number, direction: number): Point {\n return segmentVector._unit()._perp()._mult(offset * direction);\n}\n\n/**\n * Construct offset line segments for the current segment and the next segment, then extend/shrink\n * the segments until they intersect. If the segments are parallel, then they will touch with no modification.\n *\n * @param index - Index of the current vertex\n * @param prevToCurrentOffsetNormal - Normal vector of the line segment from the previous vertex to the current vertex\n * @param currentVertex - Current (non-offset) vertex projected to the label plane\n * @param lineStartIndex - Beginning index for the line this label is on\n * @param lineEndIndex - End index for the line this label is on\n * @param offsetPreviousVertex - The previous vertex projected to the label plane, and then offset along the previous segments normal\n * @param lineOffsetY - Magnitude of the offset\n * @param projectionArgs - Necessary data for tile-to-label-plane projection\n * @returns The point at which the current and next line segments intersect, once offset and extended/shrunk to their meeting point\n */\nfunction findOffsetIntersectionPoint(index: number, prevToCurrentOffsetNormal: Point, currentVertex: Point, lineStartIndex: number, lineEndIndex: number, offsetPreviousVertex: Point, lineOffsetY: number, projectionArgs: ProjectionArgs) {\n const {projectionCache, direction} = projectionArgs;\n if (projectionCache.offsets[index]) {\n return projectionCache.offsets[index];\n }\n\n const offsetCurrentVertex = currentVertex.add(prevToCurrentOffsetNormal);\n\n if (index + direction < lineStartIndex || index + direction >= lineEndIndex) {\n // This is the end of the line, no intersection to calculate\n projectionCache.offsets[index] = offsetCurrentVertex;\n return offsetCurrentVertex;\n }\n // Offset the vertices for the next segment\n const nextVertex = projectVertexToViewport(index + direction, projectionArgs);\n const currentToNextOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction);\n const offsetNextSegmentBegin = currentVertex.add(currentToNextOffsetNormal);\n const offsetNextSegmentEnd = nextVertex.add(currentToNextOffsetNormal);\n\n // find the intersection of these two lines\n // if the lines are parallel, offsetCurrent/offsetNextBegin will touch\n projectionCache.offsets[index] = findLineIntersection(offsetPreviousVertex, offsetCurrentVertex, offsetNextSegmentBegin, offsetNextSegmentEnd) || offsetCurrentVertex;\n\n return projectionCache.offsets[index];\n}\n\n/**\n * Placed Glyph type\n */\ntype PlacedGlyph = {\n /**\n * The point at which the glyph should be placed, in label plane coordinates\n */\n point: Point;\n /**\n * The angle at which the glyph should be placed\n */\n angle: number;\n /**\n * The label-plane path used to reach this glyph: used only for collision detection\n */\n path: Array;\n};\n\n/*\n * Place a single glyph along its line, projected into the label plane, by iterating outward\n * from the anchor point until the distance traversed in the label plane equals the glyph's\n * offsetX. Returns null if the glyph can't fit on the line geometry.\n */\nfunction placeGlyphAlongLine(\n offsetX: number,\n lineOffsetX: number,\n lineOffsetY: number,\n flip: boolean,\n anchorPoint: Point,\n tileAnchorPoint: Point,\n anchorSegment: number,\n lineStartIndex: number,\n lineEndIndex: number,\n lineVertexArray: SymbolLineVertexArray,\n labelPlaneMatrix: mat4,\n projectionCache: ProjectionCache,\n rotateToLine: boolean,\n getElevation: (x: number, y: number) => number): PlacedGlyph | null {\n\n const combinedOffsetX = flip ?\n offsetX - lineOffsetX :\n offsetX + lineOffsetX;\n\n let direction = combinedOffsetX > 0 ? 1 : -1;\n\n let angle = 0;\n if (flip) {\n // The label needs to be flipped to keep text upright.\n // Iterate in the reverse direction.\n direction *= -1;\n angle = Math.PI;\n }\n\n if (direction < 0) angle += Math.PI;\n\n let currentIndex = direction > 0 ?\n lineStartIndex + anchorSegment :\n lineStartIndex + anchorSegment + 1;\n\n let currentVertex = anchorPoint;\n let previousVertex = anchorPoint;\n\n // offsetPrev and intersectionPoint are analogous to previousVertex and currentVertex\n // but if there's a line offset they are calculated in parallel as projection happens\n let offsetIntersectionPoint: Point;\n let offsetPreviousVertex: Point;\n\n let distanceFromAnchor = 0;\n let currentSegmentDistance = 0;\n const absOffsetX = Math.abs(combinedOffsetX);\n const pathVertices: Array = [];\n\n let currentLineSegment: Point;\n while (distanceFromAnchor + currentSegmentDistance <= absOffsetX) {\n currentIndex += direction;\n\n // offset does not fit on the projected line\n if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex)\n return null;\n\n // accumulate values from last iteration\n distanceFromAnchor += currentSegmentDistance;\n previousVertex = currentVertex;\n offsetPreviousVertex = offsetIntersectionPoint;\n\n const projectionArgs: ProjectionArgs = {\n projectionCache,\n lineVertexArray,\n labelPlaneMatrix,\n tileAnchorPoint,\n distanceFromAnchor,\n getElevation,\n previousVertex,\n direction,\n absOffsetX\n };\n\n // find next vertex in viewport space\n currentVertex = projectVertexToViewport(currentIndex, projectionArgs);\n if (lineOffsetY === 0) {\n // Store vertices for collision detection and update current segment geometry\n pathVertices.push(previousVertex);\n currentLineSegment = currentVertex.sub(previousVertex);\n } else {\n // Calculate the offset for this section\n let prevToCurrentOffsetNormal;\n const prevToCurrent = currentVertex.sub(previousVertex);\n if (prevToCurrent.mag() === 0) {\n // We are starting with our anchor point directly on the vertex, so look one vertex ahead\n // to calculate a normal\n const nextVertex = projectVertexToViewport(currentIndex + direction, projectionArgs);\n prevToCurrentOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction);\n } else {\n prevToCurrentOffsetNormal = transformToOffsetNormal(prevToCurrent, lineOffsetY, direction);\n }\n // Initialize offsetPrev on our first iteration, after that it will be pre-calculated\n if (!offsetPreviousVertex)\n offsetPreviousVertex = previousVertex.add(prevToCurrentOffsetNormal);\n\n offsetIntersectionPoint = findOffsetIntersectionPoint(currentIndex, prevToCurrentOffsetNormal, currentVertex, lineStartIndex, lineEndIndex, offsetPreviousVertex, lineOffsetY, projectionArgs);\n\n pathVertices.push(offsetPreviousVertex);\n currentLineSegment = offsetIntersectionPoint.sub(offsetPreviousVertex);\n }\n currentSegmentDistance = currentLineSegment.mag();\n }\n\n // The point is on the current segment. Interpolate to find it.\n const segmentInterpolationT = (absOffsetX - distanceFromAnchor) / currentSegmentDistance;\n const p = currentLineSegment._mult(segmentInterpolationT)._add(offsetPreviousVertex || previousVertex);\n\n const segmentAngle = angle + Math.atan2(currentVertex.y - previousVertex.y, currentVertex.x - previousVertex.x);\n\n pathVertices.push(p);\n\n return {\n point: p,\n angle: rotateToLine ? segmentAngle : 0.0,\n path: pathVertices\n };\n}\n\nconst hiddenGlyphAttributes = new Float32Array([-Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0]);\n\n// Hide them by moving them offscreen. We still need to add them to the buffer\n// because the dynamic buffer is paired with a static buffer that doesn't get updated.\nfunction hideGlyphs(num: number, dynamicLayoutVertexArray: SymbolDynamicLayoutArray) {\n for (let i = 0; i < num; i++) {\n const offset = dynamicLayoutVertexArray.length;\n dynamicLayoutVertexArray.resize(offset + 4);\n // Since all hidden glyphs have the same attributes, we can build up the array faster with a single call to Float32Array.set\n // for each set of four vertices, instead of calling addDynamicAttributes for each vertex.\n dynamicLayoutVertexArray.float32.set(hiddenGlyphAttributes, offset * 3);\n }\n}\n\n// For line label layout, we're not using z output and our w input is always 1\n// This custom matrix transformation ignores those components to make projection faster\nfunction xyTransformMat4(out: vec4, a: vec4, m: mat4) {\n const x = a[0], y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n out[3] = m[3] * x + m[7] * y + m[15];\n return out;\n}\n","import Point from '@mapbox/point-geometry';\nimport {clipLine} from './clip_line';\nimport {PathInterpolator} from './path_interpolator';\n\nimport * as intersectionTests from '../util/intersection_tests';\nimport {GridIndex} from './grid_index';\nimport {mat4, vec4} from 'gl-matrix';\nimport ONE_EM from '../symbol/one_em';\n\nimport * as projection from '../symbol/projection';\n\nimport type {Transform} from '../geo/transform';\nimport type {SingleCollisionBox} from '../data/bucket/symbol_bucket';\nimport type {\n GlyphOffsetArray,\n SymbolLineVertexArray\n} from '../data/array_types.g';\nimport type {OverlapMode} from '../style/style_layer/overlap_mode';\n\n// When a symbol crosses the edge that causes it to be included in\n// collision detection, it will cause changes in the symbols around\n// it. This constant specifies how many pixels to pad the edge of\n// the viewport for collision detection so that the bulk of the changes\n// occur offscreen. Making this constant greater increases label\n// stability, but it's expensive.\nconst viewportPadding = 100;\n\nexport type FeatureKey = {\n bucketInstanceId: number;\n featureIndex: number;\n collisionGroupID: number;\n overlapMode: OverlapMode;\n};\n\n/**\n * @internal\n * A collision index used to prevent symbols from overlapping. It keep tracks of\n * where previous symbols have been placed and is used to check if a new\n * symbol overlaps with any previously added symbols.\n *\n * There are two steps to insertion: first placeCollisionBox/Circles checks if\n * there's room for a symbol, then insertCollisionBox/Circles actually puts the\n * symbol in the index. The two step process allows paired symbols to be inserted\n * together even if they overlap.\n */\nexport class CollisionIndex {\n grid: GridIndex;\n ignoredGrid: GridIndex;\n transform: Transform;\n pitchfactor: number;\n screenRightBoundary: number;\n screenBottomBoundary: number;\n gridRightBoundary: number;\n gridBottomBoundary: number;\n\n // With perspectiveRatio the fontsize is calculated for tilted maps (near = bigger, far = smaller).\n // The cutoff defines a threshold to no longer render labels near the horizon.\n perspectiveRatioCutoff: number;\n\n constructor(\n transform: Transform,\n grid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25),\n ignoredGrid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25)\n ) {\n this.transform = transform;\n\n this.grid = grid;\n this.ignoredGrid = ignoredGrid;\n this.pitchfactor = Math.cos(transform._pitch) * transform.cameraToCenterDistance;\n\n this.screenRightBoundary = transform.width + viewportPadding;\n this.screenBottomBoundary = transform.height + viewportPadding;\n this.gridRightBoundary = transform.width + 2 * viewportPadding;\n this.gridBottomBoundary = transform.height + 2 * viewportPadding;\n\n this.perspectiveRatioCutoff = 0.6;\n }\n\n placeCollisionBox(\n collisionBox: SingleCollisionBox,\n overlapMode: OverlapMode,\n textPixelRatio: number,\n posMatrix: mat4,\n collisionGroupPredicate?: (key: FeatureKey) => boolean,\n getElevation?: (x: number, y: number) => number\n ): {\n box: Array;\n offscreen: boolean;\n } {\n const projectedPoint = this.projectAndGetPerspectiveRatio(posMatrix, collisionBox.anchorPointX, collisionBox.anchorPointY, getElevation);\n const tileToViewport = textPixelRatio * projectedPoint.perspectiveRatio;\n const tlX = collisionBox.x1 * tileToViewport + projectedPoint.point.x;\n const tlY = collisionBox.y1 * tileToViewport + projectedPoint.point.y;\n const brX = collisionBox.x2 * tileToViewport + projectedPoint.point.x;\n const brY = collisionBox.y2 * tileToViewport + projectedPoint.point.y;\n\n if (!this.isInsideGrid(tlX, tlY, brX, brY) ||\n (overlapMode !== 'always' && this.grid.hitTest(tlX, tlY, brX, brY, overlapMode, collisionGroupPredicate)) ||\n projectedPoint.perspectiveRatio < this.perspectiveRatioCutoff) {\n return {\n box: [],\n offscreen: false\n };\n }\n\n return {\n box: [tlX, tlY, brX, brY],\n offscreen: this.isOffscreen(tlX, tlY, brX, brY)\n };\n }\n\n placeCollisionCircles(\n overlapMode: OverlapMode,\n symbol: any,\n lineVertexArray: SymbolLineVertexArray,\n glyphOffsetArray: GlyphOffsetArray,\n fontSize: number,\n posMatrix: mat4,\n labelPlaneMatrix: mat4,\n labelToScreenMatrix: mat4,\n showCollisionCircles: boolean,\n pitchWithMap: boolean,\n collisionGroupPredicate: (key: FeatureKey) => boolean,\n circlePixelDiameter: number,\n textPixelPadding: number,\n getElevation: (x: number, y: number) => number\n ): {\n circles: Array;\n offscreen: boolean;\n collisionDetected: boolean;\n } {\n const placedCollisionCircles = [];\n\n const tileUnitAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);\n const screenAnchorPoint = projection.project(tileUnitAnchorPoint, posMatrix, getElevation);\n const perspectiveRatio = projection.getPerspectiveRatio(this.transform.cameraToCenterDistance, screenAnchorPoint.signedDistanceFromCamera);\n const labelPlaneFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;\n const labelPlaneFontScale = labelPlaneFontSize / ONE_EM;\n\n const labelPlaneAnchorPoint = projection.project(tileUnitAnchorPoint, labelPlaneMatrix, getElevation).point;\n\n const projectionCache = {projections: {}, offsets: {}};\n const lineOffsetX = symbol.lineOffsetX * labelPlaneFontScale;\n const lineOffsetY = symbol.lineOffsetY * labelPlaneFontScale;\n\n const firstAndLastGlyph = projection.placeFirstAndLastGlyph(\n labelPlaneFontScale,\n glyphOffsetArray,\n lineOffsetX,\n lineOffsetY,\n /*flip*/ false,\n labelPlaneAnchorPoint,\n tileUnitAnchorPoint,\n symbol,\n lineVertexArray,\n labelPlaneMatrix,\n projectionCache,\n false,\n getElevation);\n\n let collisionDetected = false;\n let inGrid = false;\n let entirelyOffscreen = true;\n\n if (firstAndLastGlyph) {\n const radius = circlePixelDiameter * 0.5 * perspectiveRatio + textPixelPadding;\n const screenPlaneMin = new Point(-viewportPadding, -viewportPadding);\n const screenPlaneMax = new Point(this.screenRightBoundary, this.screenBottomBoundary);\n const interpolator = new PathInterpolator();\n\n // Construct a projected path from projected line vertices. Anchor points are ignored and removed\n const first = firstAndLastGlyph.first;\n const last = firstAndLastGlyph.last;\n\n let projectedPath = [];\n for (let i = first.path.length - 1; i >= 1; i--) {\n projectedPath.push(first.path[i]);\n }\n for (let i = 1; i < last.path.length; i++) {\n projectedPath.push(last.path[i]);\n }\n\n // Tolerate a slightly longer distance than one diameter between two adjacent circles\n const circleDist = radius * 2.5;\n\n // The path might need to be converted into screen space if a pitched map is used as the label space\n if (labelToScreenMatrix) {\n const screenSpacePath = projectedPath.map(p => projection.project(p, labelToScreenMatrix, getElevation));\n\n // Do not try to place collision circles if even of the points is behind the camera.\n // This is a plausible scenario with big camera pitch angles\n if (screenSpacePath.some(point => point.signedDistanceFromCamera <= 0)) {\n projectedPath = [];\n } else {\n projectedPath = screenSpacePath.map(p => p.point);\n }\n }\n\n let segments = [];\n\n if (projectedPath.length > 0) {\n // Quickly check if the path is fully inside or outside of the padded collision region.\n // For overlapping paths we'll only create collision circles for the visible segments\n const minPoint = projectedPath[0].clone();\n const maxPoint = projectedPath[0].clone();\n\n for (let i = 1; i < projectedPath.length; i++) {\n minPoint.x = Math.min(minPoint.x, projectedPath[i].x);\n minPoint.y = Math.min(minPoint.y, projectedPath[i].y);\n maxPoint.x = Math.max(maxPoint.x, projectedPath[i].x);\n maxPoint.y = Math.max(maxPoint.y, projectedPath[i].y);\n }\n\n if (minPoint.x >= screenPlaneMin.x && maxPoint.x <= screenPlaneMax.x &&\n minPoint.y >= screenPlaneMin.y && maxPoint.y <= screenPlaneMax.y) {\n // Quad fully visible\n segments = [projectedPath];\n } else if (maxPoint.x < screenPlaneMin.x || minPoint.x > screenPlaneMax.x ||\n maxPoint.y < screenPlaneMin.y || minPoint.y > screenPlaneMax.y) {\n // Not visible\n segments = [];\n } else {\n segments = clipLine([projectedPath], screenPlaneMin.x, screenPlaneMin.y, screenPlaneMax.x, screenPlaneMax.y);\n }\n }\n\n for (const seg of segments) {\n // interpolate positions for collision circles. Add a small padding to both ends of the segment\n interpolator.reset(seg, radius * 0.25);\n\n let numCircles = 0;\n\n if (interpolator.length <= 0.5 * radius) {\n numCircles = 1;\n } else {\n numCircles = Math.ceil(interpolator.paddedLength / circleDist) + 1;\n }\n\n for (let i = 0; i < numCircles; i++) {\n const t = i / Math.max(numCircles - 1, 1);\n const circlePosition = interpolator.lerp(t);\n\n // add viewport padding to the position and perform initial collision check\n const centerX = circlePosition.x + viewportPadding;\n const centerY = circlePosition.y + viewportPadding;\n\n placedCollisionCircles.push(centerX, centerY, radius, 0);\n\n const x1 = centerX - radius;\n const y1 = centerY - radius;\n const x2 = centerX + radius;\n const y2 = centerY + radius;\n\n entirelyOffscreen = entirelyOffscreen && this.isOffscreen(x1, y1, x2, y2);\n inGrid = inGrid || this.isInsideGrid(x1, y1, x2, y2);\n\n if (overlapMode !== 'always' && this.grid.hitTestCircle(centerX, centerY, radius, overlapMode, collisionGroupPredicate)) {\n // Don't early exit if we're showing the debug circles because we still want to calculate\n // which circles are in use\n collisionDetected = true;\n if (!showCollisionCircles) {\n return {\n circles: [],\n offscreen: false,\n collisionDetected\n };\n }\n }\n }\n }\n }\n\n return {\n circles: ((!showCollisionCircles && collisionDetected) || !inGrid || perspectiveRatio < this.perspectiveRatioCutoff) ? [] : placedCollisionCircles,\n offscreen: entirelyOffscreen,\n collisionDetected\n };\n }\n\n /**\n * Because the geometries in the CollisionIndex are an approximation of the shape of\n * symbols on the map, we use the CollisionIndex to look up the symbol part of\n * `queryRenderedFeatures`.\n */\n queryRenderedSymbols(viewportQueryGeometry: Array) {\n if (viewportQueryGeometry.length === 0 || (this.grid.keysLength() === 0 && this.ignoredGrid.keysLength() === 0)) {\n return {};\n }\n\n const query = [];\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const point of viewportQueryGeometry) {\n const gridPoint = new Point(point.x + viewportPadding, point.y + viewportPadding);\n minX = Math.min(minX, gridPoint.x);\n minY = Math.min(minY, gridPoint.y);\n maxX = Math.max(maxX, gridPoint.x);\n maxY = Math.max(maxY, gridPoint.y);\n query.push(gridPoint);\n }\n\n const features = this.grid.query(minX, minY, maxX, maxY)\n .concat(this.ignoredGrid.query(minX, minY, maxX, maxY));\n\n const seenFeatures = {};\n const result = {};\n\n for (const feature of features) {\n const featureKey = feature.key;\n // Skip already seen features.\n if (seenFeatures[featureKey.bucketInstanceId] === undefined) {\n seenFeatures[featureKey.bucketInstanceId] = {};\n }\n if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) {\n continue;\n }\n\n // Check if query intersects with the feature box\n // \"Collision Circles\" for line labels are treated as boxes here\n // Since there's no actual collision taking place, the circle vs. square\n // distinction doesn't matter as much, and box geometry is easier\n // to work with.\n const bbox = [\n new Point(feature.x1, feature.y1),\n new Point(feature.x2, feature.y1),\n new Point(feature.x2, feature.y2),\n new Point(feature.x1, feature.y2)\n ];\n if (!intersectionTests.polygonIntersectsPolygon(query, bbox)) {\n continue;\n }\n\n seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true;\n if (result[featureKey.bucketInstanceId] === undefined) {\n result[featureKey.bucketInstanceId] = [];\n }\n result[featureKey.bucketInstanceId].push(featureKey.featureIndex);\n }\n\n return result;\n }\n\n insertCollisionBox(collisionBox: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) {\n const grid = ignorePlacement ? this.ignoredGrid : this.grid;\n\n const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode};\n grid.insert(key, collisionBox[0], collisionBox[1], collisionBox[2], collisionBox[3]);\n }\n\n insertCollisionCircles(collisionCircles: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) {\n const grid = ignorePlacement ? this.ignoredGrid : this.grid;\n\n const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode};\n for (let k = 0; k < collisionCircles.length; k += 4) {\n grid.insertCircle(key, collisionCircles[k], collisionCircles[k + 1], collisionCircles[k + 2]);\n }\n }\n\n projectAndGetPerspectiveRatio(posMatrix: mat4, x: number, y: number, getElevation?: (x: number, y: number) => number) {\n let p;\n if (getElevation) { // slow because of handle z-index\n p = [x, y, getElevation(x, y), 1] as vec4;\n vec4.transformMat4(p, p, posMatrix);\n } else { // fast because of ignore z-index\n p = [x, y, 0, 1] as vec4;\n projection.xyTransformMat4(p, p, posMatrix);\n }\n const a = new Point(\n (((p[0] / p[3] + 1) / 2) * this.transform.width) + viewportPadding,\n (((-p[1] / p[3] + 1) / 2) * this.transform.height) + viewportPadding\n );\n return {\n point: a,\n // See perspective ratio comment in symbol_sdf.vertex\n // We're doing collision detection in viewport space so we need\n // to scale down boxes in the distance\n perspectiveRatio: 0.5 + 0.5 * (this.transform.cameraToCenterDistance / p[3])\n };\n }\n\n isOffscreen(x1: number, y1: number, x2: number, y2: number) {\n return x2 < viewportPadding || x1 >= this.screenRightBoundary || y2 < viewportPadding || y1 > this.screenBottomBoundary;\n }\n\n isInsideGrid(x1: number, y1: number, x2: number, y2: number) {\n return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary;\n }\n\n /*\n * Returns a matrix for transforming collision shapes to viewport coordinate space.\n * Use this function to render e.g. collision circles on the screen.\n * example transformation: clipPos = glCoordMatrix * viewportMatrix * circle_pos\n */\n getViewportMatrix() {\n const m = mat4.identity([] as any);\n mat4.translate(m, m, [-viewportPadding, -viewportPadding, 0.0]);\n return m;\n }\n}\n","import Point from '@mapbox/point-geometry';\n\n/**\n * Returns the part of a multiline that intersects with the provided rectangular box.\n *\n * @param lines - the lines to check\n * @param x1 - the left edge of the box\n * @param y1 - the top edge of the box\n * @param x2 - the right edge of the box\n * @param y2 - the bottom edge of the box\n * @returns lines\n */\nexport function clipLine(lines: Array>, x1: number, y1: number, x2: number, y2: number): Array> {\n const clippedLines = [];\n\n for (let l = 0; l < lines.length; l++) {\n const line = lines[l];\n let clippedLine;\n\n for (let i = 0; i < line.length - 1; i++) {\n let p0 = line[i];\n let p1 = line[i + 1];\n\n if (p0.x < x1 && p1.x < x1) {\n continue;\n } else if (p0.x < x1) {\n p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x < x1) {\n p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y < y1 && p1.y < y1) {\n continue;\n } else if (p0.y < y1) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n } else if (p1.y < y1) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n }\n\n if (p0.x >= x2 && p1.x >= x2) {\n continue;\n } else if (p0.x >= x2) {\n p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x >= x2) {\n p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y >= y2 && p1.y >= y2) {\n continue;\n } else if (p0.y >= y2) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n } else if (p1.y >= y2) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n }\n\n if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) {\n clippedLine = [p0];\n clippedLines.push(clippedLine);\n }\n\n clippedLine.push(p1);\n }\n }\n\n return clippedLines;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {register} from '../util/web_worker_transfer';\n\nexport class Anchor extends Point {\n angle: any;\n segment?: number;\n\n constructor(x: number, y: number, angle: number, segment?: number) {\n super(x, y);\n this.angle = angle;\n if (segment !== undefined) {\n this.segment = segment;\n }\n }\n\n clone() {\n return new Anchor(this.x, this.y, this.angle, this.segment);\n }\n}\n\nregister('Anchor', Anchor);\n","import {VariableAnchorOffsetCollection, VariableAnchorOffsetCollectionSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {CanonicalTileID} from '../../source/tile_id';\nimport ONE_EM from '../../symbol/one_em';\nimport {SymbolStyleLayer} from './symbol_style_layer';\n\nexport enum TextAnchorEnum {\n 'center' = 1,\n 'left' = 2,\n 'right' = 3,\n 'top' = 4,\n 'bottom' = 5,\n 'top-left' = 6,\n 'top-right' = 7,\n 'bottom-left' = 8,\n 'bottom-right' = 9\n}\n\nexport type TextAnchor = keyof typeof TextAnchorEnum;\n\n// The radial offset is to the edge of the text box\n// In the horizontal direction, the edge of the text box is where glyphs start\n// But in the vertical direction, the glyphs appear to \"start\" at the baseline\n// We don't actually load baseline data, but we assume an offset of ONE_EM - 17\n// (see \"yOffset\" in shaping.js)\nconst baselineOffset = 7;\nexport const INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY;\n\nexport function evaluateVariableOffset(anchor: TextAnchor, offset: [number, number]): [number, number] {\n\n function fromRadialOffset(anchor: TextAnchor, radialOffset: number): [number, number] {\n let x = 0, y = 0;\n if (radialOffset < 0) radialOffset = 0; // Ignore negative offset.\n // solve for r where r^2 + r^2 = radialOffset^2\n const hypotenuse = radialOffset / Math.SQRT2;\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n y = hypotenuse - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n y = -hypotenuse + baselineOffset;\n break;\n case 'bottom':\n y = -radialOffset + baselineOffset;\n break;\n case 'top':\n y = radialOffset - baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n x = -hypotenuse;\n break;\n case 'top-left':\n case 'bottom-left':\n x = hypotenuse;\n break;\n case 'left':\n x = radialOffset;\n break;\n case 'right':\n x = -radialOffset;\n break;\n }\n\n return [x, y];\n }\n\n function fromTextOffset(anchor: TextAnchor, offsetX: number, offsetY: number): [number, number] {\n let x = 0, y = 0;\n // Use absolute offset values.\n offsetX = Math.abs(offsetX);\n offsetY = Math.abs(offsetY);\n\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n case 'top':\n y = offsetY - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n case 'bottom':\n y = -offsetY + baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n case 'right':\n x = -offsetX;\n break;\n case 'top-left':\n case 'bottom-left':\n case 'left':\n x = offsetX;\n break;\n }\n\n return [x, y];\n }\n\n return (offset[1] !== INVALID_TEXT_OFFSET) ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]);\n}\n\n// Helper to support both text-variable-anchor and text-variable-anchor-offset. Offset values converted from EMs to PXs\nexport function getTextVariableAnchorOffset(layer: SymbolStyleLayer, feature: SymbolFeature, canonical: CanonicalTileID): VariableAnchorOffsetCollection | null {\n const layout = layer.layout;\n // If style specifies text-variable-anchor-offset, just return it\n const variableAnchorOffset = layout.get('text-variable-anchor-offset')?.evaluate(feature, {}, canonical);\n\n if (variableAnchorOffset) {\n const sourceValues = variableAnchorOffset.values;\n const destValues: VariableAnchorOffsetCollectionSpecification = [];\n\n // Convert offsets from EM to PX, and apply baseline shift\n for (let i = 0; i < sourceValues.length; i += 2) {\n const anchor = destValues[i] = sourceValues[i] as TextAnchor;\n const offset = (sourceValues[i + 1] as [number, number]).map(t => t * ONE_EM) as [number, number];\n\n if (anchor.startsWith('top')) {\n offset[1] -= baselineOffset;\n } else if (anchor.startsWith('bottom')) {\n offset[1] += baselineOffset;\n }\n\n destValues[i + 1] = offset;\n }\n\n return new VariableAnchorOffsetCollection(destValues);\n }\n\n // If style specifies text-variable-anchor, convert to the new format\n const variableAnchor = layout.get('text-variable-anchor');\n\n if (variableAnchor) {\n let textOffset: [number, number];\n const unevaluatedLayout = layer._unevaluatedLayout;\n\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n if (unevaluatedLayout.getValue('text-radial-offset') !== undefined) {\n textOffset = [layout.get('text-radial-offset').evaluate(feature, {}, canonical) * ONE_EM, INVALID_TEXT_OFFSET];\n } else {\n textOffset = layout.get('text-offset').evaluate(feature, {}, canonical).map(t => t * ONE_EM) as [number, number];\n }\n\n const anchorOffsets: VariableAnchorOffsetCollectionSpecification = [];\n\n for (const anchor of variableAnchor) {\n anchorOffsets.push(anchor, evaluateVariableOffset(anchor, textOffset));\n }\n\n return new VariableAnchorOffsetCollection(anchorOffsets);\n }\n\n return null;\n}\n","import {EXTENT} from '../data/extent';\n\nimport type {OverscaledTileID} from './tile_id';\n\n/**\n * Converts a pixel value at a the given zoom level to tile units.\n *\n * The shaders mostly calculate everything in tile units so style\n * properties need to be converted from pixels to tile units using this.\n *\n * For example, a translation by 30 pixels at zoom 6.5 will be a\n * translation by pixelsToTileUnits(30, 6.5) tile units.\n *\n * @returns value in tile units\n */\nexport function pixelsToTileUnits(\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n },\n pixelValue: number,\n z: number\n): number {\n return pixelValue * (EXTENT / (tile.tileSize * Math.pow(2, z - tile.tileID.overscaledZ)));\n}\n","import {CollisionIndex} from './collision_index';\nimport type {FeatureKey} from './collision_index';\nimport {EXTENT} from '../data/extent';\nimport * as symbolSize from './symbol_size';\nimport * as projection from './projection';\nimport {getAnchorJustification} from './symbol_layout';\nimport {getAnchorAlignment, WritingMode} from './shaping';\nimport {mat4} from 'gl-matrix';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport Point from '@mapbox/point-geometry';\nimport type {Transform} from '../geo/transform';\nimport type {StyleLayer} from '../style/style_layer';\nimport {PossiblyEvaluated} from '../style/properties';\nimport type {SymbolLayoutProps, SymbolLayoutPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties.g';\nimport {getOverlapMode, OverlapMode} from '../style/style_layer/overlap_mode';\n\nimport type {Tile} from '../source/tile';\nimport {SymbolBucket, CollisionArrays, SingleCollisionBox} from '../data/bucket/symbol_bucket';\n\nimport type {CollisionBoxArray, CollisionVertexArray, SymbolInstance, TextAnchorOffset} from '../data/array_types.g';\nimport type {FeatureIndex} from '../data/feature_index';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {Terrain} from '../render/terrain';\nimport {warnOnce} from '../util/util';\nimport {TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\nclass OpacityState {\n opacity: number;\n placed: boolean;\n constructor(prevState: OpacityState, increment: number, placed: boolean, skipFade?: boolean | null) {\n if (prevState) {\n this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment)));\n } else {\n this.opacity = (skipFade && placed) ? 1 : 0;\n }\n this.placed = placed;\n }\n isHidden() {\n return this.opacity === 0 && !this.placed;\n }\n}\n\nclass JointOpacityState {\n text: OpacityState;\n icon: OpacityState;\n constructor(prevState: JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null) {\n this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade);\n this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade);\n }\n isHidden() {\n return this.text.isHidden() && this.icon.isHidden();\n }\n}\n\nclass JointPlacement {\n text: boolean;\n icon: boolean;\n // skipFade = outside viewport, but within CollisionIndex::viewportPadding px of the edge\n // Because these symbols aren't onscreen yet, we can skip the \"fade in\" animation,\n // and if a subsequent viewport change brings them into view, they'll be fully\n // visible right away.\n skipFade: boolean;\n constructor(text: boolean, icon: boolean, skipFade: boolean) {\n this.text = text;\n this.icon = icon;\n this.skipFade = skipFade;\n }\n}\n\nclass CollisionCircleArray {\n // Stores collision circles and placement matrices of a bucket for debug rendering.\n invProjMatrix: mat4;\n viewportMatrix: mat4;\n circles: Array;\n\n constructor() {\n this.invProjMatrix = mat4.create();\n this.viewportMatrix = mat4.create();\n this.circles = [];\n }\n}\n\nexport class RetainedQueryData {\n bucketInstanceId: number;\n featureIndex: FeatureIndex;\n sourceLayerIndex: number;\n bucketIndex: number;\n tileID: OverscaledTileID;\n featureSortOrder: Array;\n constructor(bucketInstanceId: number,\n featureIndex: FeatureIndex,\n sourceLayerIndex: number,\n bucketIndex: number,\n tileID: OverscaledTileID) {\n this.bucketInstanceId = bucketInstanceId;\n this.featureIndex = featureIndex;\n this.sourceLayerIndex = sourceLayerIndex;\n this.bucketIndex = bucketIndex;\n this.tileID = tileID;\n }\n}\n\ntype CollisionGroup = {\n ID: number;\n predicate?: (key: FeatureKey) => boolean;\n};\n\nclass CollisionGroups {\n collisionGroups: {[groupName: string]: CollisionGroup};\n maxGroupID: number;\n crossSourceCollisions: boolean;\n\n constructor(crossSourceCollisions: boolean) {\n this.crossSourceCollisions = crossSourceCollisions;\n this.maxGroupID = 0;\n this.collisionGroups = {};\n }\n\n get(sourceID: string) {\n // The predicate/groupID mechanism allows for arbitrary grouping,\n // but the current interface defines one source == one group when\n // crossSourceCollisions == true.\n if (!this.crossSourceCollisions) {\n if (!this.collisionGroups[sourceID]) {\n const nextGroupID = ++this.maxGroupID;\n this.collisionGroups[sourceID] = {\n ID: nextGroupID,\n predicate: (key) => {\n return key.collisionGroupID === nextGroupID;\n }\n };\n }\n return this.collisionGroups[sourceID];\n } else {\n return {ID: 0, predicate: null};\n }\n }\n}\n\nfunction calculateVariableLayoutShift(\n anchor: TextAnchor,\n width: number,\n height: number,\n textOffset: [number, number],\n textBoxScale: number\n): Point {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);\n const shiftX = -(horizontalAlign - 0.5) * width;\n const shiftY = -(verticalAlign - 0.5) * height;\n return new Point(\n shiftX + textOffset[0] * textBoxScale,\n shiftY + textOffset[1] * textBoxScale\n );\n}\n\nfunction shiftVariableCollisionBox(collisionBox: SingleCollisionBox,\n shiftX: number, shiftY: number,\n rotateWithMap: boolean, pitchWithMap: boolean,\n angle: number) {\n const {x1, x2, y1, y2, anchorPointX, anchorPointY} = collisionBox;\n const rotatedOffset = new Point(shiftX, shiftY);\n if (rotateWithMap) {\n rotatedOffset._rotate(pitchWithMap ? angle : -angle);\n }\n return {\n x1: x1 + rotatedOffset.x,\n y1: y1 + rotatedOffset.y,\n x2: x2 + rotatedOffset.x,\n y2: y2 + rotatedOffset.y,\n // symbol anchor point stays the same regardless of text-anchor\n anchorPointX,\n anchorPointY\n };\n}\n\nexport type VariableOffset = {\n textOffset: [number, number];\n width: number;\n height: number;\n anchor: TextAnchor;\n textBoxScale: number;\n prevAnchor?: TextAnchor;\n};\n\ntype TileLayerParameters = {\n bucket: SymbolBucket;\n layout: PossiblyEvaluated;\n posMatrix: mat4;\n textLabelPlaneMatrix: mat4;\n labelToScreenMatrix: mat4;\n scale: number;\n textPixelRatio: number;\n holdingForFade: boolean;\n collisionBoxArray: CollisionBoxArray;\n partiallyEvaluatedTextSize: {\n uSize: number;\n uSizeT: number;\n };\n collisionGroup: CollisionGroup;\n};\n\nexport type BucketPart = {\n sortKey?: number | void;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n parameters: TileLayerParameters;\n};\n\nexport type CrossTileID = string | number;\n\nexport class Placement {\n transform: Transform;\n terrain: Terrain;\n collisionIndex: CollisionIndex;\n placements: {\n [_ in CrossTileID]: JointPlacement;\n };\n opacities: {\n [_ in CrossTileID]: JointOpacityState;\n };\n variableOffsets: {\n [_ in CrossTileID]: VariableOffset;\n };\n placedOrientations: {\n [_ in CrossTileID]: number;\n };\n commitTime: number;\n prevZoomAdjustment: number;\n lastPlacementChangeTime: number;\n stale: boolean;\n fadeDuration: number;\n retainedQueryData: {\n [_: number]: RetainedQueryData;\n };\n collisionGroups: CollisionGroups;\n prevPlacement: Placement;\n zoomAtLastRecencyCheck: number;\n collisionCircleArrays: {\n [k in any]: CollisionCircleArray;\n };\n\n constructor(transform: Transform, terrain: Terrain, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement) {\n this.transform = transform.clone();\n this.terrain = terrain;\n this.collisionIndex = new CollisionIndex(this.transform);\n this.placements = {};\n this.opacities = {};\n this.variableOffsets = {};\n this.stale = false;\n this.commitTime = 0;\n this.fadeDuration = fadeDuration;\n this.retainedQueryData = {};\n this.collisionGroups = new CollisionGroups(crossSourceCollisions);\n this.collisionCircleArrays = {};\n\n this.prevPlacement = prevPlacement;\n if (prevPlacement) {\n prevPlacement.prevPlacement = undefined; // Only hold on to one placement back\n }\n\n this.placedOrientations = {};\n }\n\n getBucketParts(results: Array, styleLayer: StyleLayer, tile: Tile, sortAcrossTiles: boolean) {\n const symbolBucket = (tile.getBucket(styleLayer) as SymbolBucket);\n const bucketFeatureIndex = tile.latestFeatureIndex;\n if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0])\n return;\n\n const collisionBoxArray = tile.collisionBoxArray;\n\n const layout = symbolBucket.layers[0].layout;\n\n const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ);\n const textPixelRatio = tile.tileSize / EXTENT;\n\n const posMatrix = this.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pixelsToTiles = pixelsToTileUnits(tile, 1, this.transform.zoom);\n\n const textLabelPlaneMatrix = projection.getLabelPlaneMatrix(posMatrix,\n pitchWithMap,\n rotateWithMap,\n this.transform,\n pixelsToTiles);\n\n let labelToScreenMatrix = null;\n\n if (pitchWithMap) {\n const glMatrix = projection.getGlCoordMatrix(\n posMatrix,\n pitchWithMap,\n rotateWithMap,\n this.transform,\n pixelsToTiles);\n\n labelToScreenMatrix = mat4.multiply([] as any, this.transform.labelPlaneMatrix, glMatrix);\n }\n\n // As long as this placement lives, we have to hold onto this bucket's\n // matching FeatureIndex/data for querying purposes\n this.retainedQueryData[symbolBucket.bucketInstanceId] = new RetainedQueryData(\n symbolBucket.bucketInstanceId,\n bucketFeatureIndex,\n symbolBucket.sourceLayerIndex,\n symbolBucket.index,\n tile.tileID\n );\n\n const parameters = {\n bucket: symbolBucket,\n layout,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n scale,\n textPixelRatio,\n holdingForFade: tile.holdingForFade(),\n collisionBoxArray,\n partiallyEvaluatedTextSize: symbolSize.evaluateSizeForZoom(symbolBucket.textSizeData, this.transform.zoom),\n collisionGroup: this.collisionGroups.get(symbolBucket.sourceID)\n };\n\n if (sortAcrossTiles) {\n for (const range of symbolBucket.sortKeyRanges) {\n const {sortKey, symbolInstanceStart, symbolInstanceEnd} = range;\n results.push({sortKey, symbolInstanceStart, symbolInstanceEnd, parameters});\n }\n } else {\n results.push({\n symbolInstanceStart: 0,\n symbolInstanceEnd: symbolBucket.symbolInstances.length,\n parameters\n });\n }\n }\n\n attemptAnchorPlacement(\n textAnchorOffset: TextAnchorOffset,\n textBox: SingleCollisionBox,\n width: number,\n height: number,\n textBoxScale: number,\n rotateWithMap: boolean,\n pitchWithMap: boolean,\n textPixelRatio: number,\n posMatrix: mat4,\n collisionGroup: CollisionGroup,\n textOverlapMode: OverlapMode,\n symbolInstance: SymbolInstance,\n bucket: SymbolBucket,\n orientation: number,\n iconBox?: SingleCollisionBox | null,\n getElevation?: (x: number, y: number) => number\n ): {\n shift: Point;\n placedGlyphBoxes: {\n box: Array;\n offscreen: boolean;\n };\n } {\n\n const anchor = TextAnchorEnum[textAnchorOffset.textAnchor] as TextAnchor;\n const textOffset = [textAnchorOffset.textOffset0, textAnchorOffset.textOffset1] as [number, number];\n const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale);\n\n const placedGlyphBoxes = this.collisionIndex.placeCollisionBox(\n shiftVariableCollisionBox(\n textBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle),\n textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n\n if (iconBox) {\n const placedIconBoxes = this.collisionIndex.placeCollisionBox(\n shiftVariableCollisionBox(\n iconBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle),\n textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n if (placedIconBoxes.box.length === 0) return;\n }\n\n if (placedGlyphBoxes.box.length > 0) {\n let prevAnchor;\n // If this label was placed in the previous placement, record the anchor position\n // to allow us to animate the transition\n if (this.prevPlacement &&\n this.prevPlacement.variableOffsets[symbolInstance.crossTileID] &&\n this.prevPlacement.placements[symbolInstance.crossTileID] &&\n this.prevPlacement.placements[symbolInstance.crossTileID].text) {\n prevAnchor = this.prevPlacement.variableOffsets[symbolInstance.crossTileID].anchor;\n }\n if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\\'t be 0');\n this.variableOffsets[symbolInstance.crossTileID] = {\n textOffset,\n width,\n height,\n anchor,\n textBoxScale,\n prevAnchor\n };\n this.markUsedJustification(bucket, anchor, symbolInstance, orientation);\n\n if (bucket.allowVerticalPlacement) {\n this.markUsedOrientation(bucket, orientation, symbolInstance);\n this.placedOrientations[symbolInstance.crossTileID] = orientation;\n }\n\n return {shift, placedGlyphBoxes};\n }\n }\n\n placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: {\n [k in string | number]: boolean;\n }, showCollisionBoxes: boolean) {\n\n const {\n bucket,\n layout,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n textPixelRatio,\n holdingForFade,\n collisionBoxArray,\n partiallyEvaluatedTextSize,\n collisionGroup\n } = bucketPart.parameters;\n\n const textOptional = layout.get('text-optional');\n const iconOptional = layout.get('icon-optional');\n const textOverlapMode = getOverlapMode(layout, 'text-overlap', 'text-allow-overlap');\n const textAlwaysOverlap = textOverlapMode === 'always';\n const iconOverlapMode = getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap');\n const iconAlwaysOverlap = iconOverlapMode === 'always';\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const hasIconTextFit = layout.get('icon-text-fit') !== 'none';\n const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y';\n\n // This logic is similar to the \"defaultOpacityState\" logic below in updateBucketOpacities\n // If we know a symbol is always supposed to show, force it to be marked visible even if\n // it wasn't placed into the collision index (because some or all of it was outside the range\n // of the collision grid).\n // There is a subtle edge case here we're accepting:\n // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false\n // A's icon is outside the grid, so doesn't get placed\n // A's text would be inside grid, but doesn't get placed because of icon-optional: false\n // We still show A because of the allow-overlap settings.\n // Symbol B has allow-overlap: false, and gets placed where A's text would be\n // On panning in, there is a short period when Symbol B and Symbol A will overlap\n // This is the reverse of our normal policy of \"fade in on pan\", but should look like any other\n // collision and hopefully not be too noticeable.\n // See https://github.com/mapbox/mapbox-gl-js/issues/7172\n const alwaysShowText = textAlwaysOverlap && (iconAlwaysOverlap || !bucket.hasIconData() || iconOptional);\n const alwaysShowIcon = iconAlwaysOverlap && (textAlwaysOverlap || !bucket.hasTextData() || textOptional);\n\n if (!bucket.collisionArrays && collisionBoxArray) {\n bucket.deserializeCollisionBoxes(collisionBoxArray);\n }\n\n const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID;\n const getElevation = this.terrain ? (x: number, y: number) => this.terrain.getElevation(tileID, x, y) : null;\n\n const placeSymbol = (symbolInstance: SymbolInstance, collisionArrays: CollisionArrays) => {\n if (seenCrossTileIDs[symbolInstance.crossTileID]) return;\n if (holdingForFade) {\n // Mark all symbols from this tile as \"not placed\", but don't add to seenCrossTileIDs, because we don't\n // know yet if we have a duplicate in a parent tile that _should_ be placed.\n this.placements[symbolInstance.crossTileID] = new JointPlacement(false, false, false);\n return;\n }\n\n let placeText = false;\n let placeIcon = false;\n let offscreen = true;\n let shift = null;\n\n let placed = {box: null, offscreen: null};\n let placedVerticalText = {box: null, offscreen: null};\n\n let placedGlyphBoxes = null;\n let placedGlyphCircles = null;\n let placedIconBoxes = null;\n let textFeatureIndex = 0;\n let verticalTextFeatureIndex = 0;\n let iconFeatureIndex = 0;\n\n if (collisionArrays.textFeatureIndex) {\n textFeatureIndex = collisionArrays.textFeatureIndex;\n } else if (symbolInstance.useRuntimeCollisionCircles) {\n textFeatureIndex = symbolInstance.featureIndex;\n }\n if (collisionArrays.verticalTextFeatureIndex) {\n verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex;\n }\n\n const textBox = collisionArrays.textBox;\n if (textBox) {\n\n const updatePreviousOrientationIfNotPlaced = (isPlaced) => {\n let previousOrientation = WritingMode.horizontal;\n if (bucket.allowVerticalPlacement && !isPlaced && this.prevPlacement) {\n const prevPlacedOrientation = this.prevPlacement.placedOrientations[symbolInstance.crossTileID];\n if (prevPlacedOrientation) {\n this.placedOrientations[symbolInstance.crossTileID] = prevPlacedOrientation;\n previousOrientation = prevPlacedOrientation;\n this.markUsedOrientation(bucket, previousOrientation, symbolInstance);\n }\n }\n return previousOrientation;\n };\n\n const placeTextForPlacementModes = (placeHorizontalFn, placeVerticalFn) => {\n if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && collisionArrays.verticalTextBox) {\n for (const placementMode of bucket.writingModes) {\n if (placementMode === WritingMode.vertical) {\n placed = placeVerticalFn();\n placedVerticalText = placed;\n } else {\n placed = placeHorizontalFn();\n }\n if (placed && placed.box && placed.box.length) break;\n }\n } else {\n placed = placeHorizontalFn();\n }\n };\n\n const textAnchorOffsetStart = symbolInstance.textAnchorOffsetStartIndex;\n const textAnchorOffsetEnd = symbolInstance.textAnchorOffsetEndIndex;\n\n // If start+end indices match, text-variable-anchor is not in play.\n if (textAnchorOffsetEnd === textAnchorOffsetStart) {\n const placeBox = (collisionTextBox, orientation) => {\n const placedFeature = this.collisionIndex.placeCollisionBox(\n collisionTextBox,\n textOverlapMode,\n textPixelRatio,\n posMatrix,\n collisionGroup.predicate,\n getElevation\n );\n if (placedFeature && placedFeature.box && placedFeature.box.length) {\n this.markUsedOrientation(bucket, orientation, symbolInstance);\n this.placedOrientations[symbolInstance.crossTileID] = orientation;\n }\n return placedFeature;\n };\n\n const placeHorizontal = () => {\n return placeBox(textBox, WritingMode.horizontal);\n };\n\n const placeVertical = () => {\n const verticalTextBox = collisionArrays.verticalTextBox;\n if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {\n return placeBox(verticalTextBox, WritingMode.vertical);\n }\n return {box: null, offscreen: null};\n };\n\n placeTextForPlacementModes(placeHorizontal, placeVertical);\n updatePreviousOrientationIfNotPlaced(placed && placed.box && placed.box.length);\n\n } else {\n // If this symbol was in the last placement, prefer placement using same anchor, if it's still available\n let prevAnchor = TextAnchorEnum[this.prevPlacement?.variableOffsets[symbolInstance.crossTileID]?.anchor];\n\n const placeBoxForVariableAnchors = (collisionTextBox, collisionIconBox, orientation) => {\n const width = collisionTextBox.x2 - collisionTextBox.x1;\n const height = collisionTextBox.y2 - collisionTextBox.y1;\n const textBoxScale = symbolInstance.textBoxScale;\n const variableIconBox = hasIconTextFit && (iconOverlapMode === 'never') ? collisionIconBox : null;\n\n let placedBox: {\n box: Array;\n offscreen: boolean;\n } = {box: [], offscreen: false};\n let placementPasses = (textOverlapMode === 'never') ? 1 : 2;\n let overlapMode: OverlapMode = 'never';\n\n if (prevAnchor) {\n placementPasses++;\n }\n\n for (let pass = 0; pass < placementPasses; pass++) {\n for (let i = textAnchorOffsetStart; i < textAnchorOffsetEnd; i++) {\n const textAnchorOffset = bucket.textAnchorOffsets.get(i);\n\n if (prevAnchor && textAnchorOffset.textAnchor !== prevAnchor) {\n continue;\n }\n\n const result = this.attemptAnchorPlacement(\n textAnchorOffset, collisionTextBox, width, height,\n textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix,\n collisionGroup, overlapMode, symbolInstance, bucket, orientation, variableIconBox, getElevation);\n\n if (result) {\n placedBox = result.placedGlyphBoxes;\n if (placedBox && placedBox.box && placedBox.box.length) {\n placeText = true;\n shift = result.shift;\n return placedBox;\n }\n }\n }\n\n if (prevAnchor) {\n prevAnchor = null;\n } else {\n overlapMode = textOverlapMode;\n }\n }\n\n return placedBox;\n };\n\n const placeHorizontal = () => {\n return placeBoxForVariableAnchors(textBox, collisionArrays.iconBox, WritingMode.horizontal);\n };\n\n const placeVertical = () => {\n const verticalTextBox = collisionArrays.verticalTextBox;\n const wasPlaced = placed && placed.box && placed.box.length;\n if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {\n return placeBoxForVariableAnchors(verticalTextBox, collisionArrays.verticalIconBox, WritingMode.vertical);\n }\n return {box: null, offscreen: null};\n };\n\n placeTextForPlacementModes(placeHorizontal, placeVertical);\n\n if (placed) {\n placeText = placed.box;\n offscreen = placed.offscreen;\n }\n\n const prevOrientation = updatePreviousOrientationIfNotPlaced(placed && placed.box);\n\n // If we didn't get placed, we still need to copy our position from the last placement for\n // fade animations\n if (!placeText && this.prevPlacement) {\n const prevOffset = this.prevPlacement.variableOffsets[symbolInstance.crossTileID];\n if (prevOffset) {\n this.variableOffsets[symbolInstance.crossTileID] = prevOffset;\n this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, prevOrientation);\n }\n }\n\n }\n }\n\n placedGlyphBoxes = placed;\n placeText = placedGlyphBoxes && placedGlyphBoxes.box && placedGlyphBoxes.box.length > 0;\n\n offscreen = placedGlyphBoxes && placedGlyphBoxes.offscreen;\n\n if (symbolInstance.useRuntimeCollisionCircles) {\n const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.centerJustifiedTextSymbolIndex);\n const fontSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol);\n\n const textPixelPadding = layout.get('text-padding');\n const circlePixelDiameter = symbolInstance.collisionCircleDiameter;\n\n placedGlyphCircles = this.collisionIndex.placeCollisionCircles(\n textOverlapMode,\n placedSymbol,\n bucket.lineVertexArray,\n bucket.glyphOffsetArray,\n fontSize,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n showCollisionBoxes,\n pitchWithMap,\n collisionGroup.predicate,\n circlePixelDiameter,\n textPixelPadding,\n getElevation\n );\n\n if (placedGlyphCircles.circles.length && placedGlyphCircles.collisionDetected && !showCollisionBoxes) {\n warnOnce('Collisions detected, but collision boxes are not shown');\n }\n\n // If text-overlap is set to 'always', force \"placedCircles\" to true\n // In theory there should always be at least one circle placed\n // in this case, but for now quirks in text-anchor\n // and text-offset may prevent that from being true.\n placeText = textAlwaysOverlap || (placedGlyphCircles.circles.length > 0 && !placedGlyphCircles.collisionDetected);\n offscreen = offscreen && placedGlyphCircles.offscreen;\n }\n\n if (collisionArrays.iconFeatureIndex) {\n iconFeatureIndex = collisionArrays.iconFeatureIndex;\n }\n\n if (collisionArrays.iconBox) {\n const placeIconFeature = iconBox => {\n const shiftedIconBox = hasIconTextFit && shift ?\n shiftVariableCollisionBox(\n iconBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle) :\n iconBox;\n return this.collisionIndex.placeCollisionBox(shiftedIconBox,\n iconOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n };\n\n if (placedVerticalText && placedVerticalText.box && placedVerticalText.box.length && collisionArrays.verticalIconBox) {\n placedIconBoxes = placeIconFeature(collisionArrays.verticalIconBox);\n placeIcon = placedIconBoxes.box.length > 0;\n } else {\n placedIconBoxes = placeIconFeature(collisionArrays.iconBox);\n placeIcon = placedIconBoxes.box.length > 0;\n }\n offscreen = offscreen && placedIconBoxes.offscreen;\n }\n\n const iconWithoutText = textOptional ||\n (symbolInstance.numHorizontalGlyphVertices === 0 && symbolInstance.numVerticalGlyphVertices === 0);\n const textWithoutIcon = iconOptional || symbolInstance.numIconVertices === 0;\n\n // Combine the scales for icons and text.\n if (!iconWithoutText && !textWithoutIcon) {\n placeIcon = placeText = placeIcon && placeText;\n } else if (!textWithoutIcon) {\n placeText = placeIcon && placeText;\n } else if (!iconWithoutText) {\n placeIcon = placeIcon && placeText;\n }\n\n if (placeText && placedGlyphBoxes && placedGlyphBoxes.box) {\n if (placedVerticalText && placedVerticalText.box && verticalTextFeatureIndex) {\n this.collisionIndex.insertCollisionBox(\n placedGlyphBoxes.box,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n verticalTextFeatureIndex,\n collisionGroup.ID);\n } else {\n this.collisionIndex.insertCollisionBox(\n placedGlyphBoxes.box,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n textFeatureIndex,\n collisionGroup.ID);\n }\n\n }\n if (placeIcon && placedIconBoxes) {\n this.collisionIndex.insertCollisionBox(\n placedIconBoxes.box,\n iconOverlapMode,\n layout.get('icon-ignore-placement'),\n bucket.bucketInstanceId,\n iconFeatureIndex,\n collisionGroup.ID);\n }\n if (placedGlyphCircles) {\n if (placeText) {\n this.collisionIndex.insertCollisionCircles(\n placedGlyphCircles.circles,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n textFeatureIndex,\n collisionGroup.ID);\n }\n\n if (showCollisionBoxes) {\n const id = bucket.bucketInstanceId;\n let circleArray = this.collisionCircleArrays[id];\n\n // Group collision circles together by bucket. Circles can't be pushed forward for rendering yet as the symbol placement\n // for a bucket is not guaranteed to be complete before the commit-function has been called\n if (circleArray === undefined)\n circleArray = this.collisionCircleArrays[id] = new CollisionCircleArray();\n\n for (let i = 0; i < placedGlyphCircles.circles.length; i += 4) {\n circleArray.circles.push(placedGlyphCircles.circles[i + 0]); // x\n circleArray.circles.push(placedGlyphCircles.circles[i + 1]); // y\n circleArray.circles.push(placedGlyphCircles.circles[i + 2]); // radius\n circleArray.circles.push(placedGlyphCircles.collisionDetected ? 1 : 0); // collisionDetected-flag\n }\n }\n }\n\n if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\\'t be 0');\n if (bucket.bucketInstanceId === 0) throw new Error('bucket.bucketInstanceId can\\'t be 0');\n\n this.placements[symbolInstance.crossTileID] = new JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded);\n seenCrossTileIDs[symbolInstance.crossTileID] = true;\n };\n\n if (zOrderByViewportY) {\n if (bucketPart.symbolInstanceStart !== 0) throw new Error('bucket.bucketInstanceId should be 0');\n const symbolIndexes = bucket.getSortedSymbolIndexes(this.transform.angle);\n for (let i = symbolIndexes.length - 1; i >= 0; --i) {\n const symbolIndex = symbolIndexes[i];\n placeSymbol(bucket.symbolInstances.get(symbolIndex), bucket.collisionArrays[symbolIndex]);\n }\n } else {\n for (let i = bucketPart.symbolInstanceStart; i < bucketPart.symbolInstanceEnd; i++) {\n placeSymbol(bucket.symbolInstances.get(i), bucket.collisionArrays[i]);\n }\n }\n\n if (showCollisionBoxes && bucket.bucketInstanceId in this.collisionCircleArrays) {\n const circleArray = this.collisionCircleArrays[bucket.bucketInstanceId];\n\n // Store viewport and inverse projection matrices per bucket\n mat4.invert(circleArray.invProjMatrix, posMatrix);\n circleArray.viewportMatrix = this.collisionIndex.getViewportMatrix();\n }\n\n bucket.justReloaded = false;\n }\n\n markUsedJustification(bucket: SymbolBucket, placedAnchor: TextAnchor, symbolInstance: SymbolInstance, orientation: number) {\n const justifications = {\n 'left': symbolInstance.leftJustifiedTextSymbolIndex,\n 'center': symbolInstance.centerJustifiedTextSymbolIndex,\n 'right': symbolInstance.rightJustifiedTextSymbolIndex\n };\n\n let autoIndex;\n if (orientation === WritingMode.vertical) {\n autoIndex = symbolInstance.verticalPlacedTextSymbolIndex;\n } else {\n autoIndex = justifications[getAnchorJustification(placedAnchor)];\n }\n\n const indexes = [\n symbolInstance.leftJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.verticalPlacedTextSymbolIndex\n ];\n\n for (const index of indexes) {\n if (index >= 0) {\n if (autoIndex >= 0 && index !== autoIndex) {\n // There are multiple justifications and this one isn't it: shift offscreen\n bucket.text.placedSymbolArray.get(index).crossTileID = 0;\n } else {\n // Either this is the chosen justification or the justification is hardwired: use this one\n bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID;\n }\n }\n }\n }\n\n markUsedOrientation(bucket: SymbolBucket, orientation: number, symbolInstance: SymbolInstance) {\n const horizontal = (orientation === WritingMode.horizontal || orientation === WritingMode.horizontalOnly) ? orientation : 0;\n const vertical = orientation === WritingMode.vertical ? orientation : 0;\n\n const horizontalIndexes = [\n symbolInstance.leftJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.rightJustifiedTextSymbolIndex\n ];\n\n for (const index of horizontalIndexes) {\n bucket.text.placedSymbolArray.get(index).placedOrientation = horizontal;\n }\n\n if (symbolInstance.verticalPlacedTextSymbolIndex) {\n bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).placedOrientation = vertical;\n }\n }\n\n commit(now: number): void {\n this.commitTime = now;\n this.zoomAtLastRecencyCheck = this.transform.zoom;\n\n const prevPlacement = this.prevPlacement;\n let placementChanged = false;\n\n this.prevZoomAdjustment = prevPlacement ? prevPlacement.zoomAdjustment(this.transform.zoom) : 0;\n const increment = prevPlacement ? prevPlacement.symbolFadeChange(now) : 1;\n\n const prevOpacities = prevPlacement ? prevPlacement.opacities : {};\n const prevOffsets = prevPlacement ? prevPlacement.variableOffsets : {};\n const prevOrientations = prevPlacement ? prevPlacement.placedOrientations : {};\n\n // add the opacities from the current placement, and copy their current values from the previous placement\n for (const crossTileID in this.placements) {\n const jointPlacement = this.placements[crossTileID];\n const prevOpacity = prevOpacities[crossTileID];\n if (prevOpacity) {\n this.opacities[crossTileID] = new JointOpacityState(prevOpacity, increment, jointPlacement.text, jointPlacement.icon);\n placementChanged = placementChanged ||\n jointPlacement.text !== prevOpacity.text.placed ||\n jointPlacement.icon !== prevOpacity.icon.placed;\n } else {\n this.opacities[crossTileID] = new JointOpacityState(null, increment, jointPlacement.text, jointPlacement.icon, jointPlacement.skipFade);\n placementChanged = placementChanged || jointPlacement.text || jointPlacement.icon;\n }\n }\n\n // copy and update values from the previous placement that aren't in the current placement but haven't finished fading\n for (const crossTileID in prevOpacities) {\n const prevOpacity = prevOpacities[crossTileID];\n if (!this.opacities[crossTileID]) {\n const jointOpacity = new JointOpacityState(prevOpacity, increment, false, false);\n if (!jointOpacity.isHidden()) {\n this.opacities[crossTileID] = jointOpacity;\n placementChanged = placementChanged || prevOpacity.text.placed || prevOpacity.icon.placed;\n }\n }\n }\n for (const crossTileID in prevOffsets) {\n if (!this.variableOffsets[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {\n this.variableOffsets[crossTileID] = prevOffsets[crossTileID];\n }\n }\n\n for (const crossTileID in prevOrientations) {\n if (!this.placedOrientations[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {\n this.placedOrientations[crossTileID] = prevOrientations[crossTileID];\n }\n }\n\n // this.lastPlacementChangeTime is the time of the last commit() that\n // resulted in a placement change -- in other words, the start time of\n // the last symbol fade animation\n if (prevPlacement && prevPlacement.lastPlacementChangeTime === undefined) {\n throw new Error('Last placement time for previous placement is not defined');\n }\n if (placementChanged) {\n this.lastPlacementChangeTime = now;\n } else if (typeof this.lastPlacementChangeTime !== 'number') {\n this.lastPlacementChangeTime = prevPlacement ? prevPlacement.lastPlacementChangeTime : now;\n }\n }\n\n updateLayerOpacities(styleLayer: StyleLayer, tiles: Array) {\n const seenCrossTileIDs = {};\n for (const tile of tiles) {\n const symbolBucket = tile.getBucket(styleLayer) as SymbolBucket;\n if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) {\n this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray);\n }\n }\n }\n\n updateBucketOpacities(bucket: SymbolBucket, seenCrossTileIDs: {\n [k in string | number]: boolean;\n }, collisionBoxArray?: CollisionBoxArray | null) {\n if (bucket.hasTextData()) {\n bucket.text.opacityVertexArray.clear();\n bucket.text.hasVisibleVertices = false;\n }\n if (bucket.hasIconData()) {\n bucket.icon.opacityVertexArray.clear();\n bucket.icon.hasVisibleVertices = false;\n }\n if (bucket.hasIconCollisionBoxData()) bucket.iconCollisionBox.collisionVertexArray.clear();\n if (bucket.hasTextCollisionBoxData()) bucket.textCollisionBox.collisionVertexArray.clear();\n\n const layer = bucket.layers[0];\n const layout = layer.layout;\n const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true);\n const textAllowOverlap = layout.get('text-allow-overlap');\n const iconAllowOverlap = layout.get('icon-allow-overlap');\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const hasIconTextFit = layout.get('icon-text-fit') !== 'none';\n // If allow-overlap is true, we can show symbols before placement runs on them\n // But we have to wait for placement if we potentially depend on a paired icon/text\n // with allow-overlap: false.\n // See https://github.com/mapbox/mapbox-gl-js/issues/7032\n const defaultOpacityState = new JointOpacityState(null, 0,\n textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || layout.get('icon-optional')),\n iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || layout.get('text-optional')),\n true);\n\n if (!bucket.collisionArrays && collisionBoxArray && ((bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()))) {\n bucket.deserializeCollisionBoxes(collisionBoxArray);\n }\n\n const addOpacities = (iconOrText, numVertices: number, opacity: number) => {\n for (let i = 0; i < numVertices / 4; i++) {\n iconOrText.opacityVertexArray.emplaceBack(opacity);\n }\n iconOrText.hasVisibleVertices = iconOrText.hasVisibleVertices || (opacity !== PACKED_HIDDEN_OPACITY);\n };\n\n for (let s = 0; s < bucket.symbolInstances.length; s++) {\n const symbolInstance = bucket.symbolInstances.get(s);\n const {\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n crossTileID\n } = symbolInstance;\n\n const isDuplicate = seenCrossTileIDs[crossTileID];\n\n let opacityState = this.opacities[crossTileID];\n if (isDuplicate) {\n opacityState = duplicateOpacityState;\n } else if (!opacityState) {\n opacityState = defaultOpacityState;\n // store the state so that future placements use it as a starting point\n this.opacities[crossTileID] = opacityState;\n }\n\n seenCrossTileIDs[crossTileID] = true;\n\n const hasText = numHorizontalGlyphVertices > 0 || numVerticalGlyphVertices > 0;\n const hasIcon = symbolInstance.numIconVertices > 0;\n\n const placedOrientation = this.placedOrientations[symbolInstance.crossTileID];\n const horizontalHidden = placedOrientation === WritingMode.vertical;\n const verticalHidden = placedOrientation === WritingMode.horizontal || placedOrientation === WritingMode.horizontalOnly;\n\n if (hasText) {\n const packedOpacity = packOpacity(opacityState.text);\n // Vertical text fades in/out on collision the same way as corresponding\n // horizontal text. Switch between vertical/horizontal should be instantaneous\n const horizontalOpacity = horizontalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;\n addOpacities(bucket.text, numHorizontalGlyphVertices, horizontalOpacity);\n const verticalOpacity = verticalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;\n addOpacities(bucket.text, numVerticalGlyphVertices, verticalOpacity);\n\n // If this label is completely faded, mark it so that we don't have to calculate\n // its position at render time. If this layer has variable placement, shift the various\n // symbol instances appropriately so that symbols from buckets that have yet to be placed\n // offset appropriately.\n const symbolHidden = opacityState.text.isHidden();\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach(index => {\n if (index >= 0) {\n bucket.text.placedSymbolArray.get(index).hidden = symbolHidden || horizontalHidden ? 1 : 0;\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).hidden = symbolHidden || verticalHidden ? 1 : 0;\n }\n\n const prevOffset = this.variableOffsets[symbolInstance.crossTileID];\n if (prevOffset) {\n this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, placedOrientation);\n }\n\n const prevOrientation = this.placedOrientations[symbolInstance.crossTileID];\n if (prevOrientation) {\n this.markUsedJustification(bucket, 'left', symbolInstance, prevOrientation);\n this.markUsedOrientation(bucket, prevOrientation, symbolInstance);\n }\n }\n\n if (hasIcon) {\n const packedOpacity = packOpacity(opacityState.icon);\n\n const useHorizontal = !(hasIconTextFit && symbolInstance.verticalPlacedIconSymbolIndex && horizontalHidden);\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;\n addOpacities(bucket.icon, symbolInstance.numIconVertices, horizontalOpacity);\n bucket.icon.placedSymbolArray.get(symbolInstance.placedIconSymbolIndex).hidden =\n (opacityState.icon.isHidden() as any);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n const verticalOpacity = !useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;\n addOpacities(bucket.icon, symbolInstance.numVerticalIconVertices, verticalOpacity);\n bucket.icon.placedSymbolArray.get(symbolInstance.verticalPlacedIconSymbolIndex).hidden =\n (opacityState.icon.isHidden() as any);\n }\n }\n\n if (bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()) {\n const collisionArrays = bucket.collisionArrays[s];\n if (collisionArrays) {\n let shift = new Point(0, 0);\n if (collisionArrays.textBox || collisionArrays.verticalTextBox) {\n let used = true;\n if (hasVariablePlacement) {\n const variableOffset = this.variableOffsets[crossTileID];\n if (variableOffset) {\n // This will show either the currently placed position or the last\n // successfully placed position (so you can visualize what collision\n // just made the symbol disappear, and the most likely place for the\n // symbol to come back)\n shift = calculateVariableLayoutShift(variableOffset.anchor,\n variableOffset.width,\n variableOffset.height,\n variableOffset.textOffset,\n variableOffset.textBoxScale);\n if (rotateWithMap) {\n shift._rotate(pitchWithMap ? this.transform.angle : -this.transform.angle);\n }\n } else {\n // No offset -> this symbol hasn't been placed since coming on-screen\n // No single box is particularly meaningful and all of them would be too noisy\n // Use the center box just to show something's there, but mark it \"not used\"\n used = false;\n }\n }\n\n if (collisionArrays.textBox) {\n updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || horizontalHidden, shift.x, shift.y);\n }\n if (collisionArrays.verticalTextBox) {\n updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || verticalHidden, shift.x, shift.y);\n }\n }\n\n const verticalIconUsed = Boolean(!verticalHidden && collisionArrays.verticalIconBox);\n\n if (collisionArrays.iconBox) {\n updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, verticalIconUsed,\n hasIconTextFit ? shift.x : 0,\n hasIconTextFit ? shift.y : 0);\n }\n\n if (collisionArrays.verticalIconBox) {\n updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, !verticalIconUsed,\n hasIconTextFit ? shift.x : 0,\n hasIconTextFit ? shift.y : 0);\n }\n }\n }\n }\n\n bucket.sortFeatures(this.transform.angle);\n if (this.retainedQueryData[bucket.bucketInstanceId]) {\n this.retainedQueryData[bucket.bucketInstanceId].featureSortOrder = bucket.featureSortOrder;\n }\n\n if (bucket.hasTextData() && bucket.text.opacityVertexBuffer) {\n bucket.text.opacityVertexBuffer.updateData(bucket.text.opacityVertexArray);\n }\n if (bucket.hasIconData() && bucket.icon.opacityVertexBuffer) {\n bucket.icon.opacityVertexBuffer.updateData(bucket.icon.opacityVertexArray);\n }\n if (bucket.hasIconCollisionBoxData() && bucket.iconCollisionBox.collisionVertexBuffer) {\n bucket.iconCollisionBox.collisionVertexBuffer.updateData(bucket.iconCollisionBox.collisionVertexArray);\n }\n if (bucket.hasTextCollisionBoxData() && bucket.textCollisionBox.collisionVertexBuffer) {\n bucket.textCollisionBox.collisionVertexBuffer.updateData(bucket.textCollisionBox.collisionVertexArray);\n }\n\n if (bucket.text.opacityVertexArray.length !== bucket.text.layoutVertexArray.length / 4) throw new Error(`bucket.text.opacityVertexArray.length (= ${bucket.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${bucket.text.layoutVertexArray.length}) / 4`);\n if (bucket.icon.opacityVertexArray.length !== bucket.icon.layoutVertexArray.length / 4) throw new Error(`bucket.icon.opacityVertexArray.length (= ${bucket.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${bucket.icon.layoutVertexArray.length}) / 4`);\n\n // Push generated collision circles to the bucket for debug rendering\n if (bucket.bucketInstanceId in this.collisionCircleArrays) {\n const instance = this.collisionCircleArrays[bucket.bucketInstanceId];\n\n bucket.placementInvProjMatrix = instance.invProjMatrix;\n bucket.placementViewportMatrix = instance.viewportMatrix;\n bucket.collisionCircleArray = instance.circles;\n\n delete this.collisionCircleArrays[bucket.bucketInstanceId];\n }\n }\n\n symbolFadeChange(now: number) {\n return this.fadeDuration === 0 ?\n 1 :\n ((now - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment);\n }\n\n zoomAdjustment(zoom: number) {\n // When zooming out quickly, labels can overlap each other. This\n // adjustment is used to reduce the interval between placement calculations\n // and to reduce the fade duration when zooming out quickly. Discovering the\n // collisions more quickly and fading them more quickly reduces the unwanted effect.\n return Math.max(0, (this.transform.zoom - zoom) / 1.5);\n }\n\n hasTransitions(now: number) {\n return this.stale ||\n now - this.lastPlacementChangeTime < this.fadeDuration;\n }\n\n stillRecent(now: number, zoom: number) {\n // The adjustment makes placement more frequent when zooming.\n // This condition applies the adjustment only after the map has\n // stopped zooming. This avoids adding extra jank while zooming.\n const durationAdjustment = this.zoomAtLastRecencyCheck === zoom ?\n (1 - this.zoomAdjustment(zoom)) :\n 1;\n this.zoomAtLastRecencyCheck = zoom;\n\n return this.commitTime + this.fadeDuration * durationAdjustment > now;\n }\n\n setStale() {\n this.stale = true;\n }\n}\n\nfunction updateCollisionVertices(collisionVertexArray: CollisionVertexArray, placed: boolean, notUsed: boolean | number, shiftX?: number, shiftY?: number) {\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n}\n\n// All four vertices for a glyph will have the same opacity state\n// So we pack the opacity into a uint8, and then repeat it four times\n// to make a single uint32 that we can upload for each glyph in the\n// label.\nconst shift25 = Math.pow(2, 25);\nconst shift24 = Math.pow(2, 24);\nconst shift17 = Math.pow(2, 17);\nconst shift16 = Math.pow(2, 16);\nconst shift9 = Math.pow(2, 9);\nconst shift8 = Math.pow(2, 8);\nconst shift1 = Math.pow(2, 1);\nfunction packOpacity(opacityState: OpacityState): number {\n if (opacityState.opacity === 0 && !opacityState.placed) {\n return 0;\n } else if (opacityState.opacity === 1 && opacityState.placed) {\n return 4294967295;\n }\n const targetBit = opacityState.placed ? 1 : 0;\n const opacityBits = Math.floor(opacityState.opacity * 127);\n return opacityBits * shift25 + targetBit * shift24 +\n opacityBits * shift17 + targetBit * shift16 +\n opacityBits * shift9 + targetBit * shift8 +\n opacityBits * shift1 + targetBit;\n}\n\nconst PACKED_HIDDEN_OPACITY = 0;\n","import {Anchor} from './anchor';\n\nimport {getAnchors, getCenterAnchor} from './get_anchors';\nimport {clipLine} from './clip_line';\nimport {shapeText, shapeIcon, WritingMode, fitIconToText} from './shaping';\nimport {getGlyphQuads, getIconQuads} from './quads';\nimport {CollisionFeature} from './collision_feature';\nimport {warnOnce} from '../util/util';\nimport {\n allowsVerticalWritingMode,\n allowsLetterSpacing\n} from '../util/script_detection';\nimport {findPoleOfInaccessibility} from '../util/find_pole_of_inaccessibility';\nimport {classifyRings} from '../util/classify_rings';\nimport {EXTENT} from '../data/extent';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SIZE_PACK_FACTOR, MAX_PACKED_SIZE, MAX_GLYPH_ICON_SIZE} from './symbol_size';\nimport ONE_EM from './one_em';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Shaping, PositionedIcon, TextJustify} from './shaping';\nimport type {CollisionBoxArray, TextAnchorOffsetArray} from '../data/array_types.g';\nimport type {SymbolFeature} from '../data/bucket/symbol_bucket';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {GlyphPosition} from '../render/glyph_atlas';\nimport type {PossiblyEvaluatedPropertyValue} from '../style/properties';\n\nimport Point from '@mapbox/point-geometry';\nimport murmur3 from 'murmurhash-js';\nimport {getIconPadding, SymbolPadding} from '../style/style_layer/symbol_style_layer';\nimport {VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {getTextVariableAnchorOffset, evaluateVariableOffset, INVALID_TEXT_OFFSET, TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\n// The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and\n// `icon-size` at up to three:\n//\n// 1. `text-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `text-size`\n// expressions, and to calculate the box dimensions for icon-text-fit.\n// 2. `icon-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `icon-size`\n// expressions.\n// 3. `text-size` and `icon-size` at the zoom level of the bucket, plus one. Used to calculate collision boxes.\n// 4. `text-size` at zoom level 18. Used for something line-symbol-placement-related.\n// 5. For composite `*-size` expressions: two zoom levels of curve stops that \"cover\" the zoom level of the\n// bucket. These go into a vertex buffer and are used by the shader to interpolate the size at render time.\n//\n// (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below.\n//\ntype Sizes = {\n layoutTextSize: PossiblyEvaluatedPropertyValue; // (3),\n layoutIconSize: PossiblyEvaluatedPropertyValue; // (3),\n textMaxSize: PossiblyEvaluatedPropertyValue; // (4),\n compositeTextSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5),\n compositeIconSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5)\n};\n\ntype ShapedTextOrientations = {\n vertical: Shaping | false;\n horizontal: Record;\n};\n\nexport function performSymbolLayout(args: {\n bucket: SymbolBucket;\n glyphMap: {\n [_: string]: {\n [x: number]: StyleGlyph;\n };\n };\n glyphPositions: {\n [_: string]: {\n [x: number]: GlyphPosition;\n };\n };\n imageMap: {[_: string]: StyleImage};\n imagePositions: {[_: string]: ImagePosition};\n showCollisionBoxes: boolean;\n canonical: CanonicalTileID;\n}) {\n args.bucket.createArrays();\n\n const tileSize = 512 * args.bucket.overscaling;\n args.bucket.tilePixelRatio = EXTENT / tileSize;\n args.bucket.compareText = {};\n args.bucket.iconsNeedLinear = false;\n\n const layer = args.bucket.layers[0];\n const layout = layer.layout;\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n const sizes: Sizes = {\n // Filled in below, if *SizeData.kind is 'composite'\n // compositeIconSizes: undefined,\n // compositeTextSizes: undefined,\n layoutIconSize: unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n layoutTextSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n textMaxSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18))\n } as Sizes;\n\n if (args.bucket.textSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.textSizeData;\n sizes.compositeTextSizes = [\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n if (args.bucket.iconSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.iconSizeData;\n sizes.compositeIconSizes = [\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n const lineHeight = layout.get('text-line-height') * ONE_EM;\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n const keepUpright = layout.get('text-keep-upright');\n const textSize = layout.get('text-size');\n\n for (const feature of args.bucket.features) {\n const fontstack = layout.get('text-font').evaluate(feature, {}, args.canonical).join(',');\n const layoutTextSizeThisZoom = textSize.evaluate(feature, {}, args.canonical);\n const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, args.canonical);\n const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, args.canonical);\n\n const shapedTextOrientations: ShapedTextOrientations = {\n horizontal: {} as Record,\n vertical: undefined\n };\n const text = feature.text;\n let textOffset: [number, number] = [0, 0];\n if (text) {\n const unformattedText = text.toString();\n const spacing = layout.get('text-letter-spacing').evaluate(feature, {}, args.canonical) * ONE_EM;\n const spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0;\n\n const textAnchor = layout.get('text-anchor').evaluate(feature, {}, args.canonical);\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, args.canonical);\n\n if (!variableAnchorOffset) {\n const radialOffset = layout.get('text-radial-offset').evaluate(feature, {}, args.canonical);\n // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector\n // is calculated at placement time instead of layout time\n if (radialOffset) {\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n textOffset = evaluateVariableOffset(textAnchor, [radialOffset * ONE_EM, INVALID_TEXT_OFFSET]);\n } else {\n textOffset = (layout.get('text-offset').evaluate(feature, {}, args.canonical).map(t => t * ONE_EM) as [number, number]);\n }\n }\n\n let textJustify = textAlongLine ?\n 'center' :\n layout.get('text-justify').evaluate(feature, {}, args.canonical);\n\n const symbolPlacement = layout.get('symbol-placement');\n const maxWidth = symbolPlacement === 'point' ?\n layout.get('text-max-width').evaluate(feature, {}, args.canonical) * ONE_EM :\n 0;\n\n const addVerticalShapingForPointLabelIfNeeded = () => {\n if (args.bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) {\n // Vertical POI label placement is meant to be used for scripts that support vertical\n // writing mode, thus, default left justification is used. If Latin\n // scripts would need to be supported, this should take into account other justifications.\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor,\n 'left', spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n };\n\n // If this layer uses text-variable-anchor, generate shapings for all justification possibilities.\n if (!textAlongLine && variableAnchorOffset) {\n const justifications = new Set();\n\n if (textJustify === 'auto') {\n for (let i = 0; i < variableAnchorOffset.values.length; i += 2) {\n justifications.add(getAnchorJustification(variableAnchorOffset.values[i] as TextAnchor));\n }\n } else {\n justifications.add(textJustify);\n }\n\n let singleLine = false;\n for (const justification of justifications) {\n if (shapedTextOrientations.horizontal[justification]) continue;\n if (singleLine) {\n // If the shaping for the first justification was only a single line, we\n // can re-use it for the other justifications\n shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0];\n } else {\n // If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply\n // the offsets for the anchor in the placement step.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, 'center',\n justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) {\n shapedTextOrientations.horizontal[justification] = shaping;\n singleLine = shaping.positionedLines.length === 1;\n }\n }\n }\n\n addVerticalShapingForPointLabelIfNeeded();\n } else {\n if (textJustify === 'auto') {\n textJustify = getAnchorJustification(textAnchor);\n }\n\n // Horizontal point or line label.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed,\n textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) shapedTextOrientations.horizontal[textJustify] = shaping;\n\n // Vertical point label (if allowVerticalPlacement is enabled).\n addVerticalShapingForPointLabelIfNeeded();\n\n // Verticalized line label.\n if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) {\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify,\n spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n }\n }\n\n let shapedIcon;\n let isSDFIcon = false;\n if (feature.icon && feature.icon.name) {\n const image = args.imageMap[feature.icon.name];\n if (image) {\n shapedIcon = shapeIcon(\n args.imagePositions[feature.icon.name],\n layout.get('icon-offset').evaluate(feature, {}, args.canonical),\n layout.get('icon-anchor').evaluate(feature, {}, args.canonical));\n // null/undefined SDF property treated same as default (false)\n isSDFIcon = !!image.sdf;\n if (args.bucket.sdfIcons === undefined) {\n args.bucket.sdfIcons = isSDFIcon;\n } else if (args.bucket.sdfIcons !== isSDFIcon) {\n warnOnce('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer');\n }\n if (image.pixelRatio !== args.bucket.pixelRatio) {\n args.bucket.iconsNeedLinear = true;\n } else if (layout.get('icon-rotate').constantOr(1) !== 0) {\n args.bucket.iconsNeedLinear = true;\n }\n }\n }\n\n const shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical;\n args.bucket.iconsInText = shapedText ? shapedText.iconsInText : false;\n if (shapedText || shapedIcon) {\n addFeature(args.bucket, feature, shapedTextOrientations, shapedIcon, args.imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, args.canonical);\n }\n }\n\n if (args.showCollisionBoxes) {\n args.bucket.generateCollisionDebugBuffers();\n }\n}\n\n// Choose the justification that matches the direction of the TextAnchor\nexport function getAnchorJustification(anchor: TextAnchor): TextJustify {\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n return 'right';\n case 'left':\n case 'top-left':\n case 'bottom-left':\n return 'left';\n }\n return 'center';\n}\n\n/**\n * Given a feature and its shaped text and icon data, add a 'symbol\n * instance' for each _possible_ placement of the symbol feature.\n * (At render timePlaceSymbols#place() selects which of these instances to\n * show or hide based on collisions with symbols in other layers.)\n */\nfunction addFeature(bucket: SymbolBucket,\n feature: SymbolFeature,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon,\n imageMap: {[_: string]: StyleImage},\n sizes: Sizes,\n layoutTextSize: number,\n layoutIconSize: number,\n textOffset: [number, number],\n isSDFIcon: boolean, canonical: CanonicalTileID) {\n // To reduce the number of labels that jump around when zooming we need\n // to use a text-size value that is the same for all zoom levels.\n // bucket calculates text-size at a high zoom level so that all tiles can\n // use the same value when calculating anchor positions.\n let textMaxSize = sizes.textMaxSize.evaluate(feature, {});\n if (textMaxSize === undefined) {\n textMaxSize = layoutTextSize;\n }\n const layout = bucket.layers[0].layout;\n const iconOffset = layout.get('icon-offset').evaluate(feature, {}, canonical);\n const defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal);\n const glyphSize = 24,\n fontScale = layoutTextSize / glyphSize,\n textBoxScale = bucket.tilePixelRatio * fontScale,\n textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize,\n iconBoxScale = bucket.tilePixelRatio * layoutIconSize,\n symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing'),\n textPadding = layout.get('text-padding') * bucket.tilePixelRatio,\n iconPadding = getIconPadding(layout, feature, canonical, bucket.tilePixelRatio),\n textMaxAngle = layout.get('text-max-angle') / 180 * Math.PI,\n textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point',\n iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point',\n symbolPlacement = layout.get('symbol-placement'),\n textRepeatDistance = symbolMinDistance / 2;\n\n const iconTextFit = layout.get('icon-text-fit');\n let verticallyShapedIcon;\n // Adjust shaped icon size when icon-text-fit is used.\n if (shapedIcon && iconTextFit !== 'none') {\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n if (defaultHorizontalShaping) {\n shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n }\n\n const addSymbolAtAnchor = (line, anchor) => {\n if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) {\n // Symbol layers are drawn across tile boundaries, We filter out symbols\n // outside our tile boundaries (which may be included in vector tile buffers)\n // to prevent double-drawing symbols.\n return;\n }\n\n addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0],\n bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index,\n textBoxScale, [textPadding, textPadding, textPadding, textPadding], textAlongLine, textOffset,\n iconBoxScale, iconPadding, iconAlongLine, iconOffset,\n feature, sizes, isSDFIcon, canonical, layoutTextSize);\n };\n\n if (symbolPlacement === 'line') {\n for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) {\n const anchors = getAnchors(\n line,\n symbolMinDistance,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale,\n bucket.overscaling,\n EXTENT\n );\n for (const anchor of anchors) {\n const shapedText = defaultHorizontalShaping;\n if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (symbolPlacement === 'line-center') {\n // No clipping, multiple lines per feature are allowed\n // \"lines\" with only one point are ignored as in clipLines\n for (const line of feature.geometry) {\n if (line.length > 1) {\n const anchor = getCenterAnchor(\n line,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale);\n if (anchor) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (feature.type === 'Polygon') {\n for (const polygon of classifyRings(feature.geometry, 0)) {\n // 16 here represents 2 pixels\n const poi = findPoleOfInaccessibility(polygon, 16);\n addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0));\n }\n } else if (feature.type === 'LineString') {\n // https://github.com/mapbox/mapbox-gl-js/issues/3808\n for (const line of feature.geometry) {\n addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0));\n }\n } else if (feature.type === 'Point') {\n for (const points of feature.geometry) {\n for (const point of points) {\n addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0));\n }\n }\n }\n}\n\nfunction addTextVariableAnchorOffsets(textAnchorOffsets: TextAnchorOffsetArray, variableAnchorOffset: VariableAnchorOffsetCollection): [number, number] {\n const startIndex = textAnchorOffsets.length;\n const values = variableAnchorOffset?.values;\n\n if (values?.length > 0) {\n for (let i = 0; i < values.length; i += 2) {\n const anchor = TextAnchorEnum[values[i] as TextAnchor];\n const offset = values[i + 1] as [number, number];\n\n textAnchorOffsets.emplaceBack(anchor, offset[0], offset[1]);\n }\n }\n\n return [startIndex, textAnchorOffsets.length];\n}\n\nfunction addTextVertices(bucket: SymbolBucket,\n anchor: Point,\n shapedText: Shaping,\n imageMap: {[_: string]: StyleImage},\n layer: SymbolStyleLayer,\n textAlongLine: boolean,\n feature: SymbolFeature,\n textOffset: [number, number],\n lineArray: {\n lineStartIndex: number;\n lineLength: number;\n },\n writingMode: WritingMode,\n placementTypes: Array<'vertical' | 'center' | 'left' | 'right'>,\n placedTextSymbolIndices: {[_: string]: number},\n placedIconIndex: number,\n sizes: Sizes,\n canonical: CanonicalTileID) {\n const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset,\n layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement);\n\n const sizeData = bucket.textSizeData;\n let textSizeData = null;\n\n if (sizeData.kind === 'source') {\n textSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {})\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n textSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical)\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.text,\n glyphQuads,\n textSizeData,\n textOffset,\n textAlongLine,\n feature,\n writingMode,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n placedIconIndex,\n canonical);\n\n // The placedSymbolArray is used at render time in drawTileSymbols\n // These indices allow access to the array at collision detection time\n for (const placementType of placementTypes) {\n placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1;\n }\n\n return glyphQuads.length * 4;\n}\n\nfunction getDefaultHorizontalShaping(\n horizontalShaping: Record\n): Shaping | null {\n // We don't care which shaping we get because this is used for collision purposes\n // and all the justifications have the same collision box\n for (const justification in horizontalShaping) {\n return horizontalShaping[justification];\n }\n return null;\n}\n\n/**\n * Add a single label & icon placement.\n */\nfunction addSymbol(bucket: SymbolBucket,\n anchor: Anchor,\n line: Array,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon | void,\n imageMap: {[_: string]: StyleImage},\n verticallyShapedIcon: PositionedIcon | void,\n layer: SymbolStyleLayer,\n collisionBoxArray: CollisionBoxArray,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n textBoxScale: number,\n textPadding: SymbolPadding,\n textAlongLine: boolean,\n textOffset: [number, number],\n iconBoxScale: number,\n iconPadding: SymbolPadding,\n iconAlongLine: boolean,\n iconOffset: [number, number],\n feature: SymbolFeature,\n sizes: Sizes,\n isSDFIcon: boolean,\n canonical: CanonicalTileID,\n layoutTextSize: number) {\n const lineArray = bucket.addToLineVertexArray(anchor, line);\n\n let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature;\n\n let numIconVertices = 0;\n let numVerticalIconVertices = 0;\n let numHorizontalGlyphVertices = 0;\n let numVerticalGlyphVertices = 0;\n let placedIconSymbolIndex = -1;\n let verticalPlacedIconSymbolIndex = -1;\n const placedTextSymbolIndices: {[k: string]: number} = {};\n let key = murmur3('');\n\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n const textRotation = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n const verticalTextRotation = textRotation + 90.0;\n const verticalShaping = shapedTextOrientations.vertical;\n verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation);\n\n if (verticallyShapedIcon) {\n verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation);\n }\n }\n\n //Place icon first, so text can have a reference to its index in the placed symbol array.\n //Text symbols can lazily shift at render-time because of variable anchor placement.\n //If the style specifies an `icon-text-fit` then the icon would have to shift along with it.\n // For more info check `updateVariableAnchors` in `draw_symbol.js` .\n if (shapedIcon) {\n const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {});\n const hasIconTextFit = layer.layout.get('icon-text-fit') !== 'none';\n const iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit);\n const verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : undefined;\n iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/false, iconRotate);\n\n numIconVertices = iconQuads.length * 4;\n\n const sizeData = bucket.iconSizeData;\n let iconSizeData = null;\n\n if (sizeData.kind === 'source') {\n iconSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {})\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n iconSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical)\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.icon,\n iconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.none,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n\n if (verticalIconQuads) {\n numVerticalIconVertices = verticalIconQuads.length * 4;\n\n bucket.addSymbols(\n bucket.icon,\n verticalIconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.vertical,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n }\n }\n\n const justifications = Object.keys(shapedTextOrientations.horizontal) as TextJustify[];\n for (const justification of justifications) {\n const shaping = shapedTextOrientations.horizontal[justification];\n\n if (!textCollisionFeature) {\n key = murmur3(shaping.text);\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature\n // We're counting on all versions having similar dimensions\n textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate);\n }\n\n const singleLine = shaping.positionedLines.length === 1;\n numHorizontalGlyphVertices += addTextVertices(\n bucket, anchor, shaping, imageMap, layer, textAlongLine, feature, textOffset, lineArray,\n shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly,\n singleLine ? justifications : [justification],\n placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical);\n\n if (singleLine) {\n break;\n }\n }\n\n if (shapedTextOrientations.vertical) {\n numVerticalGlyphVertices += addTextVertices(\n bucket, anchor, shapedTextOrientations.vertical, imageMap, layer, textAlongLine, feature,\n textOffset, lineArray, WritingMode.vertical, ['vertical'], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical);\n }\n\n const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n // Check if runtime collision circles should be used for any of the collision features.\n // It is enough to choose the tallest feature shape as circles are always placed on a line.\n // All measurements are in glyph metrics and later converted into pixels using proper font size \"layoutTextSize\"\n let collisionCircleDiameter = -1;\n\n const getCollisionCircleHeight = (feature: CollisionFeature, prevHeight: number): number => {\n if (feature && feature.circleDiameter)\n return Math.max(feature.circleDiameter, prevHeight);\n return prevHeight;\n };\n\n collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter);\n const useRuntimeCollisionCircles = (collisionCircleDiameter > -1) ? 1 : 0;\n\n // Convert circle collision height into pixels\n if (useRuntimeCollisionCircles)\n collisionCircleDiameter *= layoutTextSize / ONE_EM;\n\n if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) warnOnce(\n 'Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907'\n );\n\n if (feature.sortKey !== undefined) {\n bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey as number);\n }\n\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, canonical);\n const [textAnchorOffsetStartIndex, textAnchorOffsetEndIndex] = addTextVariableAnchorOffsets(bucket.textAnchorOffsets, variableAnchorOffset);\n\n bucket.symbolInstances.emplaceBack(\n anchor.x,\n anchor.y,\n placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1,\n placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1,\n placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1,\n placedTextSymbolIndices.vertical || -1,\n placedIconSymbolIndex,\n verticalPlacedIconSymbolIndex,\n key,\n textBoxStartIndex,\n textBoxEndIndex,\n verticalTextBoxStartIndex,\n verticalTextBoxEndIndex,\n iconBoxStartIndex,\n iconBoxEndIndex,\n verticalIconBoxStartIndex,\n verticalIconBoxEndIndex,\n featureIndex,\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n numIconVertices,\n numVerticalIconVertices,\n useRuntimeCollisionCircles,\n 0,\n textBoxScale,\n collisionCircleDiameter,\n textAnchorOffsetStartIndex,\n textAnchorOffsetEndIndex);\n}\n\nfunction anchorIsTooClose(bucket: SymbolBucket, text: string, repeatDistance: number, anchor: Point) {\n const compareText = bucket.compareText;\n if (!(text in compareText)) {\n compareText[text] = [];\n } else {\n const otherAnchors = compareText[text];\n for (let k = otherAnchors.length - 1; k >= 0; k--) {\n if (anchor.dist(otherAnchors[k]) < repeatDistance) {\n // If it's within repeatDistance of one anchor, stop looking\n return true;\n }\n }\n }\n // If anchor is not within repeatDistance of any other anchor, add to array\n compareText[text].push(anchor);\n return false;\n}\n","import {browser} from '../util/browser';\n\nimport {Placement} from '../symbol/placement';\n\nimport type {Transform} from '../geo/transform';\nimport type {StyleLayer} from './style_layer';\nimport type {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport type {Tile} from '../source/tile';\nimport type {BucketPart} from '../symbol/placement';\nimport {Terrain} from '../render/terrain';\n\nclass LayerPlacement {\n _sortAcrossTiles: boolean;\n _currentTileIndex: number;\n _currentPartIndex: number;\n _seenCrossTileIDs: {\n [k in string | number]: boolean;\n };\n _bucketParts: Array;\n\n constructor(styleLayer: SymbolStyleLayer) {\n this._sortAcrossTiles = styleLayer.layout.get('symbol-z-order') !== 'viewport-y' &&\n !styleLayer.layout.get('symbol-sort-key').isConstant();\n\n this._currentTileIndex = 0;\n this._currentPartIndex = 0;\n this._seenCrossTileIDs = {};\n this._bucketParts = [];\n }\n\n continuePlacement(tiles: Array, placement: Placement, showCollisionBoxes: boolean, styleLayer: StyleLayer, shouldPausePlacement: () => boolean) {\n\n const bucketParts = this._bucketParts;\n\n while (this._currentTileIndex < tiles.length) {\n const tile = tiles[this._currentTileIndex];\n placement.getBucketParts(bucketParts, styleLayer, tile, this._sortAcrossTiles);\n\n this._currentTileIndex++;\n if (shouldPausePlacement()) {\n return true;\n }\n }\n\n if (this._sortAcrossTiles) {\n this._sortAcrossTiles = false;\n bucketParts.sort((a, b) => (a.sortKey as any as number) - (b.sortKey as any as number));\n }\n\n while (this._currentPartIndex < bucketParts.length) {\n const bucketPart = bucketParts[this._currentPartIndex];\n placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes);\n\n this._currentPartIndex++;\n if (shouldPausePlacement()) {\n return true;\n }\n }\n return false;\n }\n}\n\nexport class PauseablePlacement {\n placement: Placement;\n _done: boolean;\n _currentPlacementIndex: number;\n _forceFullPlacement: boolean;\n _showCollisionBoxes: boolean;\n _inProgressLayer: LayerPlacement;\n\n constructor(\n transform: Transform,\n terrain: Terrain,\n order: Array,\n forceFullPlacement: boolean,\n showCollisionBoxes: boolean,\n fadeDuration: number,\n crossSourceCollisions: boolean,\n prevPlacement?: Placement\n ) {\n this.placement = new Placement(transform, terrain, fadeDuration, crossSourceCollisions, prevPlacement);\n this._currentPlacementIndex = order.length - 1;\n this._forceFullPlacement = forceFullPlacement;\n this._showCollisionBoxes = showCollisionBoxes;\n this._done = false;\n }\n\n isDone() {\n return this._done;\n }\n\n continuePlacement(\n order: Array,\n layers: {[_: string]: StyleLayer},\n layerTiles: {[_: string]: Array}\n ) {\n const startTime = browser.now();\n\n const shouldPausePlacement = () => {\n return this._forceFullPlacement ? false : (browser.now() - startTime) > 2;\n };\n\n while (this._currentPlacementIndex >= 0) {\n const layerId = order[this._currentPlacementIndex];\n const layer = layers[layerId];\n const placementZoom = this.placement.collisionIndex.transform.zoom;\n if (layer.type === 'symbol' &&\n (!layer.minzoom || layer.minzoom <= placementZoom) &&\n (!layer.maxzoom || layer.maxzoom > placementZoom)) {\n\n if (!this._inProgressLayer) {\n this._inProgressLayer = new LayerPlacement(layer as any as SymbolStyleLayer);\n }\n\n const pausePlacement = this._inProgressLayer.continuePlacement(layerTiles[layer.source], this.placement, this._showCollisionBoxes, layer, shouldPausePlacement);\n\n if (pausePlacement) {\n // We didn't finish placing all layers within 2ms,\n // but we can keep rendering with a partial placement\n // We'll resume here on the next frame\n return;\n }\n\n delete this._inProgressLayer;\n }\n\n this._currentPlacementIndex--;\n }\n\n this._done = true;\n }\n\n commit(now: number) {\n this.placement.commit(now);\n return this.placement;\n }\n}\n","\nconst ARRAY_TYPES = [\n Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n];\n\n/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */\n\nconst VERSION = 1; // serialized format version\nconst HEADER_SIZE = 8;\n\nexport default class KDBush {\n\n /**\n * Creates an index from raw `ArrayBuffer` data.\n * @param {ArrayBuffer} data\n */\n static from(data) {\n if (!(data instanceof ArrayBuffer)) {\n throw new Error('Data must be an instance of ArrayBuffer.');\n }\n const [magic, versionAndType] = new Uint8Array(data, 0, 2);\n if (magic !== 0xdb) {\n throw new Error('Data does not appear to be in a KDBush format.');\n }\n const version = versionAndType >> 4;\n if (version !== VERSION) {\n throw new Error(`Got v${version} data when expected v${VERSION}.`);\n }\n const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];\n if (!ArrayType) {\n throw new Error('Unrecognized array type.');\n }\n const [nodeSize] = new Uint16Array(data, 2, 1);\n const [numItems] = new Uint32Array(data, 4, 1);\n\n return new KDBush(numItems, nodeSize, ArrayType, data);\n }\n\n /**\n * Creates an index that will hold a given number of items.\n * @param {number} numItems\n * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).\n * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).\n * @param {ArrayBuffer} [data] (For internal use only)\n */\n constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) {\n if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`);\n\n this.numItems = +numItems;\n this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);\n this.ArrayType = ArrayType;\n this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;\n\n const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);\n const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;\n const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;\n const padCoords = (8 - idsByteSize % 8) % 8;\n\n if (arrayTypeIndex < 0) {\n throw new Error(`Unexpected typed array class: ${ArrayType}.`);\n }\n\n if (data && (data instanceof ArrayBuffer)) { // reconstruct an index from a buffer\n this.data = data;\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = numItems * 2;\n this._finished = true;\n } else { // initialize a new index\n this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = 0;\n this._finished = false;\n\n // set header\n new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);\n new Uint16Array(this.data, 2, 1)[0] = nodeSize;\n new Uint32Array(this.data, 4, 1)[0] = numItems;\n }\n }\n\n /**\n * Add a point to the index.\n * @param {number} x\n * @param {number} y\n * @returns {number} An incremental index associated with the added item (starting from `0`).\n */\n add(x, y) {\n const index = this._pos >> 1;\n this.ids[index] = index;\n this.coords[this._pos++] = x;\n this.coords[this._pos++] = y;\n return index;\n }\n\n /**\n * Perform indexing of the added points.\n */\n finish() {\n const numAdded = this._pos >> 1;\n if (numAdded !== this.numItems) {\n throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);\n }\n // kd-sort both arrays for efficient search\n sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);\n\n this._finished = true;\n return this;\n }\n\n /**\n * Search the index for items within a given bounding box.\n * @param {number} minX\n * @param {number} minY\n * @param {number} maxX\n * @param {number} maxY\n * @returns {number[]} An array of indices correponding to the found items.\n */\n range(minX, minY, maxX, maxY) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n\n // recursively search for items in range in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n const x = coords[2 * i];\n const y = coords[2 * i + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? minX <= x : minY <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? maxX >= x : maxY >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n\n /**\n * Search the index for items within a given radius.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @returns {number[]} An array of indices correponding to the found items.\n */\n within(qx, qy, r) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n const r2 = r * r;\n\n // recursively search for items within radius in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? qx - r <= x : qy - r <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? qx + r >= x : qy + r >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} nodeSize\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction sort(ids, coords, nodeSize, left, right, axis) {\n if (right - left <= nodeSize) return;\n\n const m = (left + right) >> 1; // middle index\n\n // sort ids and coords around the middle index so that the halves lie\n // either left/right or top/bottom correspondingly (taking turns)\n select(ids, coords, m, left, right, axis);\n\n // recursively kd-sort first half and second half on the opposite axis\n sort(ids, coords, nodeSize, left, m - 1, 1 - axis);\n sort(ids, coords, nodeSize, m + 1, right, 1 - axis);\n}\n\n/**\n * Custom Floyd-Rivest selection algorithm: sort ids and coords so that\n * [left..k-1] items are smaller than k-th item (on either x or y axis)\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} k\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction select(ids, coords, k, left, right, axis) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n select(ids, coords, k, newLeft, newRight, axis);\n }\n\n const t = coords[2 * k + axis];\n let i = left;\n let j = right;\n\n swapItem(ids, coords, left, k);\n if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);\n\n while (i < j) {\n swapItem(ids, coords, i, j);\n i++;\n j--;\n while (coords[2 * i + axis] < t) i++;\n while (coords[2 * j + axis] > t) j--;\n }\n\n if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);\n else {\n j++;\n swapItem(ids, coords, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} i\n * @param {number} j\n */\nfunction swapItem(ids, coords, i, j) {\n swap(ids, i, j);\n swap(coords, 2 * i, 2 * j);\n swap(coords, 2 * i + 1, 2 * j + 1);\n}\n\n/**\n * @param {InstanceType} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @param {number} ax\n * @param {number} ay\n * @param {number} bx\n * @param {number} by\n */\nfunction sqDist(ax, ay, bx, by) {\n const dx = ax - bx;\n const dy = ay - by;\n return dx * dx + dy * dy;\n}\n","import KDBush from 'kdbush';\nimport {EXTENT} from '../data/extent';\n\nimport {SymbolInstanceArray} from '../data/array_types.g';\n\nimport type {SymbolInstance} from '../data/array_types.g';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {Tile} from '../source/tile';\n\n/*\n The CrossTileSymbolIndex generally works on the assumption that\n a conceptual \"unique symbol\" can be identified by the text of\n the label combined with the anchor point. The goal is to assign\n these conceptual \"unique symbols\" a shared crossTileID that can be\n used by Placement to keep fading opacity states consistent and to\n deduplicate labels.\n\n The CrossTileSymbolIndex indexes all the current symbol instances and\n their crossTileIDs. When a symbol bucket gets added or updated, the\n index assigns a crossTileID to each of it's symbol instances by either\n matching it with an existing id or assigning a new one.\n*/\n\n// Round anchor positions to roughly 4 pixel grid\nconst roundingFactor = 512 / EXTENT / 2;\n\nexport const KDBUSH_THRESHHOLD = 128;\n\ninterface SymbolsByKeyEntry {\n index?: KDBush;\n positions?: {x: number; y: number}[];\n crossTileIDs: number[];\n}\n\nclass TileLayerIndex {\n _symbolsByKey: Record = {};\n\n constructor(public tileID: OverscaledTileID, symbolInstances: SymbolInstanceArray, public bucketInstanceId: number) {\n // group the symbolInstances by key\n const symbolInstancesByKey = new Map();\n for (let i = 0; i < symbolInstances.length; i++) {\n const symbolInstance = symbolInstances.get(i);\n const key = symbolInstance.key;\n const instances = symbolInstancesByKey.get(key);\n if (instances) {\n // This tile may have multiple symbol instances with the same key\n // Store each one along with its coordinates\n instances.push(symbolInstance);\n } else {\n symbolInstancesByKey.set(key, [symbolInstance]);\n }\n }\n\n // index the SymbolInstances in this each bucket\n for (const [key, symbols] of symbolInstancesByKey) {\n const positions = symbols.map(symbolInstance => ({x: Math.floor(symbolInstance.anchorX * roundingFactor), y: Math.floor(symbolInstance.anchorY * roundingFactor)}));\n const crossTileIDs = symbols.map(v => v.crossTileID);\n const entry: SymbolsByKeyEntry = {positions, crossTileIDs};\n\n // once we get too many symbols for a given key, it becomes much faster to index it before queries\n if (entry.positions.length > KDBUSH_THRESHHOLD) {\n\n const index = new KDBush(entry.positions.length, 16, Uint16Array);\n for (const {x, y} of entry.positions) index.add(x, y);\n index.finish();\n\n // clear all references to the original positions data\n delete entry.positions;\n entry.index = index;\n }\n\n this._symbolsByKey[key] = entry;\n }\n }\n\n // Converts the coordinates of the input symbol instance into coordinates that be can compared\n // against other symbols in this index. Coordinates are:\n // (1) local-tile-based (so after correction we get x,y values relative to our local anchorX/Y)\n // (2) converted to the z-scale of this TileLayerIndex\n // (3) down-sampled by \"roundingFactor\" from tile coordinate precision in order to be\n // more tolerant of small differences between tiles.\n getScaledCoordinates(symbolInstance: SymbolInstance, childTileID: OverscaledTileID): {x: number; y: number} {\n const {x: localX, y: localY, z: localZ} = this.tileID.canonical;\n const {x, y, z} = childTileID.canonical;\n\n const zDifference = z - localZ;\n const scale = roundingFactor / Math.pow(2, zDifference);\n const xWorld = (x * EXTENT + symbolInstance.anchorX) * scale;\n const yWorld = (y * EXTENT + symbolInstance.anchorY) * scale;\n const xOffset = localX * EXTENT * roundingFactor;\n const yOffset = localY * EXTENT * roundingFactor;\n const result = {\n x: Math.floor(xWorld - xOffset),\n y: Math.floor(yWorld - yOffset)\n };\n\n return result;\n }\n\n findMatches(symbolInstances: SymbolInstanceArray, newTileID: OverscaledTileID, zoomCrossTileIDs: {\n [crossTileID: number]: boolean;\n }) {\n const tolerance = this.tileID.canonical.z < newTileID.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - newTileID.canonical.z);\n\n for (let i = 0; i < symbolInstances.length; i++) {\n const symbolInstance = symbolInstances.get(i);\n if (symbolInstance.crossTileID) {\n // already has a match, skip\n continue;\n }\n\n const entry = this._symbolsByKey[symbolInstance.key];\n if (!entry) {\n // No symbol with this key in this bucket\n continue;\n }\n\n const scaledSymbolCoord = this.getScaledCoordinates(symbolInstance, newTileID);\n\n if (entry.index) {\n // Return any symbol with the same keys whose coordinates are within 1\n // grid unit. (with a 4px grid, this covers a 12px by 12px area)\n const indexes = entry.index.range(\n scaledSymbolCoord.x - tolerance,\n scaledSymbolCoord.y - tolerance,\n scaledSymbolCoord.x + tolerance,\n scaledSymbolCoord.y + tolerance).sort();\n\n for (const i of indexes) {\n const crossTileID = entry.crossTileIDs[i];\n\n if (!zoomCrossTileIDs[crossTileID]) {\n // Once we've marked ourselves duplicate against this parent symbol,\n // don't let any other symbols at the same zoom level duplicate against\n // the same parent (see issue #5993)\n zoomCrossTileIDs[crossTileID] = true;\n symbolInstance.crossTileID = crossTileID;\n break;\n }\n }\n } else if (entry.positions) {\n for (let i = 0; i < entry.positions.length; i++) {\n const thisTileSymbol = entry.positions[i];\n const crossTileID = entry.crossTileIDs[i];\n\n // Return any symbol with the same keys whose coordinates are within 1\n // grid unit. (with a 4px grid, this covers a 12px by 12px area)\n if (Math.abs(thisTileSymbol.x - scaledSymbolCoord.x) <= tolerance &&\n Math.abs(thisTileSymbol.y - scaledSymbolCoord.y) <= tolerance &&\n !zoomCrossTileIDs[crossTileID]) {\n // Once we've marked ourselves duplicate against this parent symbol,\n // don't let any other symbols at the same zoom level duplicate against\n // the same parent (see issue #5993)\n zoomCrossTileIDs[crossTileID] = true;\n symbolInstance.crossTileID = crossTileID;\n break;\n }\n }\n }\n }\n }\n\n getCrossTileIDsLists() {\n return Object.values(this._symbolsByKey).map(({crossTileIDs}) => crossTileIDs);\n }\n}\n\nclass CrossTileIDs {\n maxCrossTileID: number;\n constructor() {\n this.maxCrossTileID = 0;\n }\n generate() {\n return ++this.maxCrossTileID;\n }\n}\n\nclass CrossTileSymbolLayerIndex {\n indexes: {\n [zoom in string | number]: {\n [tileId in string | number]: TileLayerIndex;\n };\n };\n usedCrossTileIDs: {\n [zoom in string | number]: {\n [crossTileID: number]: boolean;\n };\n };\n lng: number;\n\n constructor() {\n this.indexes = {};\n this.usedCrossTileIDs = {};\n this.lng = 0;\n }\n\n /*\n * Sometimes when a user pans across the antimeridian the longitude value gets wrapped.\n * To prevent labels from flashing out and in we adjust the tileID values in the indexes\n * so that they match the new wrapped version of the map.\n */\n handleWrapJump(lng: number) {\n const wrapDelta = Math.round((lng - this.lng) / 360);\n if (wrapDelta !== 0) {\n for (const zoom in this.indexes) {\n const zoomIndexes = this.indexes[zoom];\n const newZoomIndex = {};\n for (const key in zoomIndexes) {\n // change the tileID's wrap and add it to a new index\n const index = zoomIndexes[key];\n index.tileID = index.tileID.unwrapTo(index.tileID.wrap + wrapDelta);\n newZoomIndex[index.tileID.key] = index;\n }\n this.indexes[zoom] = newZoomIndex;\n }\n }\n this.lng = lng;\n }\n\n addBucket(tileID: OverscaledTileID, bucket: SymbolBucket, crossTileIDs: CrossTileIDs) {\n if (this.indexes[tileID.overscaledZ] &&\n this.indexes[tileID.overscaledZ][tileID.key]) {\n if (this.indexes[tileID.overscaledZ][tileID.key].bucketInstanceId ===\n bucket.bucketInstanceId) {\n return false;\n } else {\n // We're replacing this bucket with an updated version\n // Remove the old bucket's \"used crossTileIDs\" now so that\n // the new bucket can claim them.\n // The old index entries themselves stick around until\n // 'removeStaleBuckets' is called.\n this.removeBucketCrossTileIDs(tileID.overscaledZ,\n this.indexes[tileID.overscaledZ][tileID.key]);\n }\n }\n\n for (let i = 0; i < bucket.symbolInstances.length; i++) {\n const symbolInstance = bucket.symbolInstances.get(i);\n symbolInstance.crossTileID = 0;\n }\n\n if (!this.usedCrossTileIDs[tileID.overscaledZ]) {\n this.usedCrossTileIDs[tileID.overscaledZ] = {};\n }\n const zoomCrossTileIDs = this.usedCrossTileIDs[tileID.overscaledZ];\n\n for (const zoom in this.indexes) {\n const zoomIndexes = this.indexes[zoom];\n if (Number(zoom) > tileID.overscaledZ) {\n for (const id in zoomIndexes) {\n const childIndex = zoomIndexes[id];\n if (childIndex.tileID.isChildOf(tileID)) {\n childIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs);\n }\n }\n } else {\n const parentCoord = tileID.scaledTo(Number(zoom));\n const parentIndex = zoomIndexes[parentCoord.key];\n if (parentIndex) {\n parentIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs);\n }\n }\n }\n\n for (let i = 0; i < bucket.symbolInstances.length; i++) {\n const symbolInstance = bucket.symbolInstances.get(i);\n if (!symbolInstance.crossTileID) {\n // symbol did not match any known symbol, assign a new id\n symbolInstance.crossTileID = crossTileIDs.generate();\n zoomCrossTileIDs[symbolInstance.crossTileID] = true;\n }\n }\n\n if (this.indexes[tileID.overscaledZ] === undefined) {\n this.indexes[tileID.overscaledZ] = {};\n }\n this.indexes[tileID.overscaledZ][tileID.key] = new TileLayerIndex(tileID, bucket.symbolInstances, bucket.bucketInstanceId);\n\n return true;\n }\n\n removeBucketCrossTileIDs(zoom: string | number, removedBucket: TileLayerIndex) {\n for (const crossTileIDs of removedBucket.getCrossTileIDsLists()) {\n for (const crossTileID of crossTileIDs) {\n delete this.usedCrossTileIDs[zoom][crossTileID];\n }\n }\n }\n\n removeStaleBuckets(currentIDs: {\n [k in string | number]: boolean;\n }) {\n let tilesChanged = false;\n for (const z in this.indexes) {\n const zoomIndexes = this.indexes[z];\n for (const tileKey in zoomIndexes) {\n if (!currentIDs[zoomIndexes[tileKey].bucketInstanceId]) {\n this.removeBucketCrossTileIDs(z, zoomIndexes[tileKey]);\n delete zoomIndexes[tileKey];\n tilesChanged = true;\n }\n }\n }\n return tilesChanged;\n }\n}\n\nexport class CrossTileSymbolIndex {\n layerIndexes: {[layerId: string]: CrossTileSymbolLayerIndex};\n crossTileIDs: CrossTileIDs;\n maxBucketInstanceId: number;\n bucketsInCurrentPlacement: {[_: number]: boolean};\n\n constructor() {\n this.layerIndexes = {};\n this.crossTileIDs = new CrossTileIDs();\n this.maxBucketInstanceId = 0;\n this.bucketsInCurrentPlacement = {};\n }\n\n addLayer(styleLayer: StyleLayer, tiles: Array, lng: number) {\n let layerIndex = this.layerIndexes[styleLayer.id];\n if (layerIndex === undefined) {\n layerIndex = this.layerIndexes[styleLayer.id] = new CrossTileSymbolLayerIndex();\n }\n\n let symbolBucketsChanged = false;\n const currentBucketIDs = {};\n\n layerIndex.handleWrapJump(lng);\n\n for (const tile of tiles) {\n const symbolBucket = (tile.getBucket(styleLayer) as any as SymbolBucket);\n if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0])\n continue;\n\n if (!symbolBucket.bucketInstanceId) {\n symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId;\n }\n\n if (layerIndex.addBucket(tile.tileID, symbolBucket, this.crossTileIDs)) {\n symbolBucketsChanged = true;\n }\n currentBucketIDs[symbolBucket.bucketInstanceId] = true;\n }\n\n if (layerIndex.removeStaleBuckets(currentBucketIDs)) {\n symbolBucketsChanged = true;\n }\n\n return symbolBucketsChanged;\n }\n\n pruneUnusedLayers(usedLayers: Array) {\n const usedLayerMap = {};\n usedLayers.forEach((usedLayer) => {\n usedLayerMap[usedLayer] = true;\n });\n for (const layerId in this.layerIndexes) {\n if (!usedLayerMap[layerId]) {\n delete this.layerIndexes[layerId];\n }\n }\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\nimport {StyleLayer} from './style_layer';\nimport {createStyleLayer} from './create_style_layer';\nimport {loadSprite} from './load_sprite';\nimport {ImageManager} from '../render/image_manager';\nimport {GlyphManager} from '../render/glyph_manager';\nimport {Light} from './light';\nimport {LineAtlas} from '../render/line_atlas';\nimport {pick, clone, extend, deepEqual, filterObject, mapObject} from '../util/util';\nimport {coerceSpriteToArray} from '../util/style';\nimport {getJSON, getReferrer, makeRequest} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\nimport {Dispatcher} from '../util/dispatcher';\nimport {validateStyle, emitValidationErrors as _emitValidationErrors} from './validate_style';\nimport {getSourceType, setSourceType, Source} from '../source/source';\nimport type {SourceClass} from '../source/source';\nimport {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions, queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures} from '../source/query_features';\nimport {SourceCache} from '../source/source_cache';\nimport {GeoJSONSource} from '../source/geojson_source';\nimport {latest as styleSpec, derefLayers as deref, emptyStyle, diff as diffStyles, operations as diffOperations} from '@maplibre/maplibre-gl-style-spec';\nimport {getGlobalWorkerPool} from '../util/global_worker_pool';\nimport {\n registerForPluginStateChange,\n evented as rtlTextPluginEvented,\n triggerPluginCompletionEvent\n} from '../source/rtl_text_plugin';\nimport {PauseablePlacement} from './pauseable_placement';\nimport {ZoomHistory} from './zoom_history';\nimport {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';\nimport {validateCustomStyleLayer} from './style_layer/custom_style_layer';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\n\n// We're skipping validation errors with the `source.canvas` identifier in order\n// to continue to allow canvas sources to be added at runtime/updated in\n// smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424):\nconst emitValidationErrors = (evented: Evented, errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n}> | null) =>\n _emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas'));\n\nimport type {Map} from '../ui/map';\nimport type {Transform} from '../geo/transform';\nimport type {StyleImage} from './style_image';\nimport type {StyleGlyph} from './style_glyph';\nimport type {Callback} from '../types/callback';\nimport type {EvaluationParameters} from './evaluation_parameters';\nimport type {Placement} from '../symbol/placement';\nimport type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from '../util/ajax';\nimport type {\n LayerSpecification,\n FilterSpecification,\n StyleSpecification,\n LightSpecification,\n SourceSpecification,\n SpriteSpecification,\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Validator} from './validate_style';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nconst supportedDiffOperations = pick(diffOperations, [\n 'addLayer',\n 'removeLayer',\n 'setPaintProperty',\n 'setLayoutProperty',\n 'setFilter',\n 'addSource',\n 'removeSource',\n 'setLayerZoomRange',\n 'setLight',\n 'setTransition',\n 'setGeoJSONSourceData',\n 'setGlyphs',\n 'setSprite',\n]);\n\nconst ignoredDiffOperations = pick(diffOperations, [\n 'setCenter',\n 'setZoom',\n 'setBearing',\n 'setPitch'\n]);\n\nconst empty = emptyStyle() as StyleSpecification;\n/**\n * A feature identifier that is bound to a source\n */\nexport type FeatureIdentifier = {\n /**\n * Unique id of the feature.\n */\n id?: string | number | undefined;\n /**\n * The id of the vector or GeoJSON source for the feature.\n */\n source: string;\n /**\n * *For vector tile sources, `sourceLayer` is required.*\n */\n sourceLayer?: string | undefined;\n};\n\n/**\n * The options object related to the {@link Map}'s style related methods\n */\nexport type StyleOptions = {\n /**\n * If false, style validation will be skipped. Useful in production environment.\n */\n validate?: boolean;\n /**\n * Defines a CSS\n * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.\n * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).\n * Set to `false`, to enable font settings from the map's style for these glyph ranges.\n * Forces a full update.\n */\n localIdeographFontFamily?: string;\n};\n\n/**\n * Supporting type to add validation to another style related type\n */\nexport type StyleSetterOptions = {\n /**\n * Whether to check if the filter conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n */\n validate?: boolean;\n};\n\n/**\n * Part of {@link Map#setStyle} options, transformStyle is a convenience function that allows to modify a style after it is fetched but before it is committed to the map state\n * this function exposes previous and next styles, it can be commonly used to support a range of functionalities like:\n * when previous style carries certain 'state' that needs to be carried over to a new style gracefully\n * when a desired style is a certain combination of previous and incoming style\n * when an incoming style requires modification based on external state\n *\n * @param previousStyle - The current style.\n * @param nextStyle - The next style.\n * @returns resulting style that will to be applied to the map\n *\n * @example\n * ```ts\n * map.setStyle('https://demotiles.maplibre.org/style.json', {\n * transformStyle: (previousStyle, nextStyle) => ({\n * ...nextStyle,\n * sources: {\n * ...nextStyle.sources,\n * // copy a source from previous style\n * 'osm': previousStyle.sources.osm\n * },\n * layers: [\n * // background layer\n * nextStyle.layers[0],\n * // copy a layer from previous style\n * previousStyle.layers[0],\n * // other layers from the next style\n * ...nextStyle.layers.slice(1).map(layer => {\n * // hide the layers we don't need from demotiles style\n * if (layer.id.startsWith('geolines')) {\n * layer.layout = {...layer.layout || {}, visibility: 'none'};\n * // filter out US polygons\n * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {\n * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];\n * }\n * return layer;\n * })\n * ]\n * })\n * });\n * ```\n */\nexport type TransformStyleFunction = (previous: StyleSpecification | undefined, next: StyleSpecification) => StyleSpecification;\n\n/**\n * The options object related to the {@link Map}'s style related methods\n */\nexport type StyleSwapOptions = {\n /**\n * If false, force a 'full' update, removing the current style\n * and building the given one instead of attempting a diff-based update.\n */\n diff?: boolean;\n /**\n * TransformStyleFunction is a convenience function\n * that allows to modify a style after it is fetched but before it is committed to the map state. Refer to {@link TransformStyleFunction}.\n */\n transformStyle?: TransformStyleFunction;\n}\n\n/**\n * Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification}\n * or a {@link CustomLayerInterface}, a {@link LayerSpecification} with an embedded {@link SourceSpecification} can also be provided.\n */\nexport type AddLayerObject = LayerSpecification | (Omit & {source: SourceSpecification}) | CustomLayerInterface;\n\n/**\n * The Style base class\n */\nexport class Style extends Evented {\n map: Map;\n stylesheet: StyleSpecification;\n dispatcher: Dispatcher;\n imageManager: ImageManager;\n glyphManager: GlyphManager;\n lineAtlas: LineAtlas;\n light: Light;\n\n _request: Cancelable;\n _spriteRequest: Cancelable;\n _layers: {[_: string]: StyleLayer};\n _serializedLayers: {[_: string]: LayerSpecification};\n _order: Array;\n sourceCaches: {[_: string]: SourceCache};\n zoomHistory: ZoomHistory;\n _loaded: boolean;\n _rtlTextPluginCallback: (a: any) => any;\n _changed: boolean;\n _updatedSources: {[_: string]: 'clear' | 'reload'};\n _updatedLayers: {[_: string]: true};\n _removedLayers: {[_: string]: StyleLayer};\n _changedImages: {[_: string]: true};\n _glyphsDidChange: boolean;\n _updatedPaintProps: {[layer: string]: true};\n _layerOrderChanged: boolean;\n // image ids of images loaded from style's sprite\n _spritesImagesIds: {[spriteId: string]: string[]};\n // image ids of all images loaded (sprite + user)\n _availableImages: Array;\n\n crossTileSymbolIndex: CrossTileSymbolIndex;\n pauseablePlacement: PauseablePlacement;\n placement: Placement;\n z: number;\n\n static registerForPluginStateChange: typeof registerForPluginStateChange;\n\n constructor(map: Map, options: StyleOptions = {}) {\n super();\n\n this.map = map;\n this.dispatcher = new Dispatcher(getGlobalWorkerPool(), this, map._getMapId());\n this.imageManager = new ImageManager();\n this.imageManager.setEventedParent(this);\n this.glyphManager = new GlyphManager(map._requestManager, options.localIdeographFontFamily);\n this.lineAtlas = new LineAtlas(256, 512);\n this.crossTileSymbolIndex = new CrossTileSymbolIndex();\n\n this._spritesImagesIds = {};\n this._layers = {};\n\n this._order = [];\n this.sourceCaches = {};\n this.zoomHistory = new ZoomHistory();\n this._loaded = false;\n this._availableImages = [];\n\n this._resetUpdates();\n\n this.dispatcher.broadcast('setReferrer', getReferrer());\n\n const self = this;\n this._rtlTextPluginCallback = Style.registerForPluginStateChange((event) => {\n const state = {\n pluginStatus: event.pluginStatus,\n pluginURL: event.pluginURL\n };\n self.dispatcher.broadcast('syncRTLPluginState', state, (err, results) => {\n triggerPluginCompletionEvent(err);\n if (results) {\n const allComplete = results.every((elem) => elem);\n if (allComplete) {\n for (const id in self.sourceCaches) {\n const sourceType = self.sourceCaches[id].getSource().type;\n if (sourceType === 'vector' || sourceType === 'geojson') {\n // Non-vector sources don't have any symbols buckets to reload when the RTL text plugin loads\n // They also load more quickly, so they're more likely to have already displaying tiles\n // that would be unnecessarily booted by the plugin load event\n self.sourceCaches[id].reload(); // Should be a no-op if the plugin loads before any tiles load\n }\n }\n }\n }\n\n });\n });\n\n this.on('data', (event) => {\n if (event.dataType !== 'source' || event.sourceDataType !== 'metadata') {\n return;\n }\n\n const sourceCache = this.sourceCaches[event.sourceId];\n if (!sourceCache) {\n return;\n }\n\n const source = sourceCache.getSource();\n if (!source || !source.vectorLayerIds) {\n return;\n }\n\n for (const layerId in this._layers) {\n const layer = this._layers[layerId];\n if (layer.source === source.id) {\n this._validateLayer(layer);\n }\n }\n });\n }\n\n loadURL(url: string, options: StyleSwapOptions & StyleSetterOptions = {}, previousStyle?: StyleSpecification) {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n\n options.validate = typeof options.validate === 'boolean' ?\n options.validate : true;\n\n const request = this.map._requestManager.transformRequest(url, ResourceType.Style);\n this._request = getJSON(request, (error?: Error | null, json?: any | null) => {\n this._request = null;\n if (error) {\n this.fire(new ErrorEvent(error));\n } else if (json) {\n this._load(json, options, previousStyle);\n }\n });\n }\n\n loadJSON(json: StyleSpecification, options: StyleSetterOptions & StyleSwapOptions = {}, previousStyle?: StyleSpecification) {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n\n this._request = browser.frame(() => {\n this._request = null;\n options.validate = options.validate !== false;\n this._load(json, options, previousStyle);\n });\n }\n\n loadEmpty() {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n this._load(empty, {validate: false});\n }\n\n _load(json: StyleSpecification, options: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification) {\n const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json;\n if (options.validate && emitValidationErrors(this, validateStyle(nextState))) {\n return;\n }\n\n this._loaded = true;\n this.stylesheet = nextState;\n\n for (const id in nextState.sources) {\n this.addSource(id, nextState.sources[id], {validate: false});\n }\n\n if (nextState.sprite) {\n this._loadSprite(nextState.sprite);\n } else {\n this.imageManager.setLoaded(true);\n }\n\n this.glyphManager.setURL(nextState.glyphs);\n this._createLayers();\n\n this.light = new Light(this.stylesheet.light);\n\n this.map.setTerrain(this.stylesheet.terrain ?? null);\n\n this.fire(new Event('data', {dataType: 'style'}));\n this.fire(new Event('style.load'));\n }\n\n private _createLayers() {\n const dereferencedLayers = deref(this.stylesheet.layers);\n\n // Broadcast layers to workers first, so that expensive style processing (createStyleLayer)\n // can happen in parallel on both main and worker threads.\n this.dispatcher.broadcast('setLayers', dereferencedLayers);\n\n this._order = dereferencedLayers.map((layer) => layer.id);\n this._layers = {};\n\n // reset serialization field, to be populated only when needed\n this._serializedLayers = null;\n for (const layer of dereferencedLayers) {\n const styledLayer = createStyleLayer(layer);\n styledLayer.setEventedParent(this, {layer: {id: layer.id}});\n this._layers[layer.id] = styledLayer;\n }\n }\n\n _loadSprite(sprite: SpriteSpecification, isUpdate: boolean = false, completion: (err: Error) => void = undefined) {\n this.imageManager.setLoaded(false);\n\n this._spriteRequest = loadSprite(sprite, this.map._requestManager, this.map.getPixelRatio(), (err, images) => {\n this._spriteRequest = null;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (images) {\n for (const spriteId in images) {\n this._spritesImagesIds[spriteId] = [];\n\n // remove old sprite's loaded images (for the same sprite id) that are not in new sprite\n const imagesToRemove = this._spritesImagesIds[spriteId] ? this._spritesImagesIds[spriteId].filter(id => !(id in images)) : [];\n for (const id of imagesToRemove) {\n this.imageManager.removeImage(id);\n this._changedImages[id] = true;\n }\n\n for (const id in images[spriteId]) {\n // don't prefix images of the \"default\" sprite\n const imageId = spriteId === 'default' ? id : `${spriteId}:${id}`;\n // save all the sprite's images' ids to be able to delete them in `removeSprite`\n this._spritesImagesIds[spriteId].push(imageId);\n if (imageId in this.imageManager.images) {\n this.imageManager.updateImage(imageId, images[spriteId][id], false);\n } else {\n this.imageManager.addImage(imageId, images[spriteId][id]);\n }\n\n if (isUpdate) {\n this._changedImages[imageId] = true;\n }\n }\n }\n }\n\n this.imageManager.setLoaded(true);\n this._availableImages = this.imageManager.listImages();\n\n if (isUpdate) {\n this._changed = true;\n }\n\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n\n if (completion) {\n completion(err);\n }\n });\n }\n\n _unloadSprite() {\n for (const id of Object.values(this._spritesImagesIds).flat()) {\n this.imageManager.removeImage(id);\n this._changedImages[id] = true;\n }\n\n this._spritesImagesIds = {};\n this._availableImages = this.imageManager.listImages();\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n _validateLayer(layer: StyleLayer) {\n const sourceCache = this.sourceCaches[layer.source];\n if (!sourceCache) {\n return;\n }\n\n const sourceLayer = layer.sourceLayer;\n if (!sourceLayer) {\n return;\n }\n\n const source = sourceCache.getSource();\n if (source.type === 'geojson' || (source.vectorLayerIds && source.vectorLayerIds.indexOf(sourceLayer) === -1)) {\n this.fire(new ErrorEvent(new Error(\n `Source layer \"${sourceLayer}\" ` +\n `does not exist on source \"${source.id}\" ` +\n `as specified by style layer \"${layer.id}\".`\n )));\n }\n }\n\n loaded() {\n if (!this._loaded)\n return false;\n\n if (Object.keys(this._updatedSources).length)\n return false;\n\n for (const id in this.sourceCaches)\n if (!this.sourceCaches[id].loaded())\n return false;\n\n if (!this.imageManager.isLoaded())\n return false;\n\n return true;\n }\n\n /**\n * take an array of string IDs, and based on this._layers, generate an array of LayerSpecification\n * @param ids - an array of string IDs, for which serialized layers will be generated. If omitted, all serialized layers will be returned\n * @returns generated result\n */\n private _serializeByIds(ids?: Array): Array {\n\n const serializedLayersDictionary = this._serializedAllLayers();\n if (!ids || ids.length === 0) {\n return Object.values(serializedLayersDictionary);\n }\n\n const serializedLayers = [];\n for (const id of ids) {\n // this check will skip all custom layers\n if (serializedLayersDictionary[id]) {\n serializedLayers.push(serializedLayersDictionary[id]);\n }\n }\n\n return serializedLayers;\n }\n\n /**\n * Lazy initialization of this._serializedLayers dictionary and return it\n * @returns this._serializedLayers dictionary\n */\n private _serializedAllLayers(): {[_: string]: LayerSpecification} {\n let serializedLayers = this._serializedLayers;\n if (serializedLayers) {\n return serializedLayers;\n }\n\n serializedLayers = this._serializedLayers = {};\n const allLayerIds: string [] = Object.keys(this._layers);\n for (const layerId of allLayerIds) {\n const layer = this._layers[layerId];\n if (layer.type !== 'custom') {\n serializedLayers[layerId] = layer.serialize();\n }\n }\n\n return serializedLayers;\n }\n\n hasTransitions() {\n if (this.light && this.light.hasTransition()) {\n return true;\n }\n\n for (const id in this.sourceCaches) {\n if (this.sourceCaches[id].hasTransition()) {\n return true;\n }\n }\n\n for (const id in this._layers) {\n if (this._layers[id].hasTransition()) {\n return true;\n }\n }\n\n return false;\n }\n\n _checkLoaded() {\n if (!this._loaded) {\n throw new Error('Style is not done loading.');\n }\n }\n\n /**\n * @internal\n * Apply queued style updates in a batch and recalculate zoom-dependent paint properties.\n */\n update(parameters: EvaluationParameters) {\n if (!this._loaded) {\n return;\n }\n\n const changed = this._changed;\n if (this._changed) {\n const updatedIds = Object.keys(this._updatedLayers);\n const removedIds = Object.keys(this._removedLayers);\n\n if (updatedIds.length || removedIds.length) {\n this._updateWorkerLayers(updatedIds, removedIds);\n }\n for (const id in this._updatedSources) {\n const action = this._updatedSources[id];\n\n if (action === 'reload') {\n this._reloadSource(id);\n } else if (action === 'clear') {\n this._clearSource(id);\n } else {\n throw new Error(`Invalid action ${action}`);\n }\n }\n\n this._updateTilesForChangedImages();\n this._updateTilesForChangedGlyphs();\n\n for (const id in this._updatedPaintProps) {\n this._layers[id].updateTransitions(parameters);\n }\n\n this.light.updateTransitions(parameters);\n\n this._resetUpdates();\n }\n\n const sourcesUsedBefore = {};\n\n for (const sourceId in this.sourceCaches) {\n const sourceCache = this.sourceCaches[sourceId];\n sourcesUsedBefore[sourceId] = sourceCache.used;\n sourceCache.used = false;\n }\n\n for (const layerId of this._order) {\n const layer = this._layers[layerId];\n\n layer.recalculate(parameters, this._availableImages);\n if (!layer.isHidden(parameters.zoom) && layer.source) {\n this.sourceCaches[layer.source].used = true;\n }\n }\n\n for (const sourceId in sourcesUsedBefore) {\n const sourceCache = this.sourceCaches[sourceId];\n if (sourcesUsedBefore[sourceId] !== sourceCache.used) {\n sourceCache.fire(new Event('data', {sourceDataType: 'visibility', dataType: 'source', sourceId}));\n }\n }\n\n this.light.recalculate(parameters);\n this.z = parameters.zoom;\n\n if (changed) {\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n }\n\n /*\n * Apply any queued image changes.\n */\n _updateTilesForChangedImages() {\n const changedImages = Object.keys(this._changedImages);\n if (changedImages.length) {\n for (const name in this.sourceCaches) {\n this.sourceCaches[name].reloadTilesForDependencies(['icons', 'patterns'], changedImages);\n }\n this._changedImages = {};\n }\n }\n\n _updateTilesForChangedGlyphs() {\n if (this._glyphsDidChange) {\n for (const name in this.sourceCaches) {\n this.sourceCaches[name].reloadTilesForDependencies(['glyphs'], ['']);\n }\n this._glyphsDidChange = false;\n }\n }\n\n _updateWorkerLayers(updatedIds: Array, removedIds: Array) {\n this.dispatcher.broadcast('updateLayers', {\n layers: this._serializeByIds(updatedIds),\n removedIds\n });\n }\n\n _resetUpdates() {\n this._changed = false;\n\n this._updatedLayers = {};\n this._removedLayers = {};\n\n this._updatedSources = {};\n this._updatedPaintProps = {};\n\n this._changedImages = {};\n this._glyphsDidChange = false;\n }\n\n /**\n * Update this style's state to match the given style JSON, performing only\n * the necessary mutations.\n *\n * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec\n * diff algorithm produces an operation that is not supported.\n *\n * @returns true if any changes were made; false otherwise\n */\n setState(nextState: StyleSpecification, options: StyleSwapOptions = {}) {\n this._checkLoaded();\n\n const serializedStyle = this.serialize();\n nextState = options.transformStyle ? options.transformStyle(serializedStyle, nextState) : nextState;\n if (emitValidationErrors(this, validateStyle(nextState))) return false;\n\n nextState = clone(nextState);\n nextState.layers = deref(nextState.layers);\n\n const changes = diffStyles(serializedStyle, nextState)\n .filter(op => !(op.command in ignoredDiffOperations));\n\n if (changes.length === 0) {\n return false;\n }\n\n const unimplementedOps = changes.filter(op => !(op.command in supportedDiffOperations));\n if (unimplementedOps.length > 0) {\n throw new Error(`Unimplemented: ${unimplementedOps.map(op => op.command).join(', ')}.`);\n }\n\n for (const op of changes) {\n if (op.command === 'setTransition') {\n // `transition` is always read directly off of\n // `this.stylesheet`, which we update below\n continue;\n }\n (this as any)[op.command].apply(this, op.args);\n }\n\n this.stylesheet = nextState;\n\n // reset serialization field, to be populated only when needed\n this._serializedLayers = null;\n\n return true;\n }\n\n addImage(id: string, image: StyleImage) {\n if (this.getImage(id)) {\n return this.fire(new ErrorEvent(new Error(`An image named \"${id}\" already exists.`)));\n }\n this.imageManager.addImage(id, image);\n this._afterImageUpdated(id);\n }\n\n updateImage(id: string, image: StyleImage) {\n this.imageManager.updateImage(id, image);\n }\n\n getImage(id: string): StyleImage {\n return this.imageManager.getImage(id);\n }\n\n removeImage(id: string) {\n if (!this.getImage(id)) {\n return this.fire(new ErrorEvent(new Error(`An image named \"${id}\" does not exist.`)));\n }\n this.imageManager.removeImage(id);\n this._afterImageUpdated(id);\n }\n\n _afterImageUpdated(id: string) {\n this._availableImages = this.imageManager.listImages();\n this._changedImages[id] = true;\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n listImages() {\n this._checkLoaded();\n\n return this.imageManager.listImages();\n }\n\n addSource(id: string, source: SourceSpecification, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n if (this.sourceCaches[id] !== undefined) {\n throw new Error(`Source \"${id}\" already exists.`);\n }\n\n if (!source.type) {\n throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(source).join(', ')}.`);\n }\n\n const builtIns = ['vector', 'raster', 'geojson', 'video', 'image'];\n const shouldValidate = builtIns.indexOf(source.type) >= 0;\n if (shouldValidate && this._validate(validateStyle.source, `sources.${id}`, source, null, options)) return;\n\n if (this.map && this.map._collectResourceTiming) (source as any).collectResourceTiming = true;\n const sourceCache = this.sourceCaches[id] = new SourceCache(id, source, this.dispatcher);\n sourceCache.style = this;\n sourceCache.setEventedParent(this, () => ({\n isSourceLoaded: sourceCache.loaded(),\n source: sourceCache.serialize(),\n sourceId: id\n }));\n\n sourceCache.onAdd(this.map);\n this._changed = true;\n }\n\n /**\n * Remove a source from this stylesheet, given its id.\n * @param id - id of the source to remove\n * @throws if no source is found with the given ID\n * @returns `this`.\n */\n removeSource(id: string): this {\n this._checkLoaded();\n\n if (this.sourceCaches[id] === undefined) {\n throw new Error('There is no source with this ID');\n }\n for (const layerId in this._layers) {\n if (this._layers[layerId].source === id) {\n return this.fire(new ErrorEvent(new Error(`Source \"${id}\" cannot be removed while layer \"${layerId}\" is using it.`)));\n }\n }\n\n const sourceCache = this.sourceCaches[id];\n delete this.sourceCaches[id];\n delete this._updatedSources[id];\n sourceCache.fire(new Event('data', {sourceDataType: 'metadata', dataType: 'source', sourceId: id}));\n sourceCache.setEventedParent(null);\n sourceCache.onRemove(this.map);\n this._changed = true;\n }\n\n /**\n * Set the data of a GeoJSON source, given its id.\n * @param id - id of the source\n * @param data - GeoJSON source\n */\n setGeoJSONSourceData(id: string, data: GeoJSON.GeoJSON | string) {\n this._checkLoaded();\n\n if (this.sourceCaches[id] === undefined) throw new Error(`There is no source with this ID=${id}`);\n const geojsonSource: GeoJSONSource = (this.sourceCaches[id].getSource() as any);\n if (geojsonSource.type !== 'geojson') throw new Error(`geojsonSource.type is ${geojsonSource.type}, which is !== 'geojson`);\n\n geojsonSource.setData(data);\n this._changed = true;\n }\n\n /**\n * Get a source by ID.\n * @param id - ID of the desired source\n * @returns source\n */\n getSource(id: string): Source | undefined {\n return this.sourceCaches[id] && this.sourceCaches[id].getSource();\n }\n\n /**\n * Add a layer to the map style. The layer will be inserted before the layer with\n * ID `before`, or appended if `before` is omitted.\n * @param layerObject - The style layer to add.\n * @param before - ID of an existing layer to insert before\n * @param options - Style setter options.\n * @returns `this`.\n */\n addLayer(layerObject: AddLayerObject, before?: string, options: StyleSetterOptions = {}): this {\n this._checkLoaded();\n\n const id = layerObject.id;\n\n if (this.getLayer(id)) {\n this.fire(new ErrorEvent(new Error(`Layer \"${id}\" already exists on this map.`)));\n return;\n }\n\n let layer: ReturnType;\n if (layerObject.type === 'custom') {\n\n if (emitValidationErrors(this, validateCustomStyleLayer(layerObject))) return;\n\n layer = createStyleLayer(layerObject);\n\n } else {\n if ('source' in layerObject && typeof layerObject.source === 'object') {\n this.addSource(id, layerObject.source);\n layerObject = clone(layerObject);\n layerObject = extend(layerObject, {source: id});\n }\n\n // this layer is not in the style.layers array, so we pass an impossible array index\n if (this._validate(validateStyle.layer,\n `layers.${id}`, layerObject, {arrayIndex: -1}, options)) return;\n\n layer = createStyleLayer(layerObject as LayerSpecification | CustomLayerInterface);\n this._validateLayer(layer);\n\n layer.setEventedParent(this, {layer: {id}});\n }\n\n const index = before ? this._order.indexOf(before) : this._order.length;\n if (before && index === -1) {\n this.fire(new ErrorEvent(new Error(`Cannot add layer \"${id}\" before non-existing layer \"${before}\".`)));\n return;\n }\n\n this._order.splice(index, 0, id);\n this._layerOrderChanged = true;\n\n this._layers[id] = layer;\n\n if (this._removedLayers[id] && layer.source && layer.type !== 'custom') {\n // If, in the current batch, we have already removed this layer\n // and we are now re-adding it with a different `type`, then we\n // need to clear (rather than just reload) the underlying source's\n // tiles. Otherwise, tiles marked 'reloading' will have buckets /\n // buffers that are set up for the _previous_ version of this\n // layer, causing, e.g.:\n // https://github.com/mapbox/mapbox-gl-js/issues/3633\n const removed = this._removedLayers[id];\n delete this._removedLayers[id];\n if (removed.type !== layer.type) {\n this._updatedSources[layer.source] = 'clear';\n } else {\n this._updatedSources[layer.source] = 'reload';\n this.sourceCaches[layer.source].pause();\n }\n }\n this._updateLayer(layer);\n\n if (layer.onAdd) {\n layer.onAdd(this.map);\n }\n }\n\n /**\n * Moves a layer to a different z-position. The layer will be inserted before the layer with\n * ID `before`, or appended if `before` is omitted.\n * @param id - ID of the layer to move\n * @param before - ID of an existing layer to insert before\n */\n moveLayer(id: string, before?: string) {\n this._checkLoaded();\n this._changed = true;\n\n const layer = this._layers[id];\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be moved.`)));\n return;\n }\n\n if (id === before) {\n return;\n }\n\n const index = this._order.indexOf(id);\n this._order.splice(index, 1);\n\n const newIndex = before ? this._order.indexOf(before) : this._order.length;\n if (before && newIndex === -1) {\n this.fire(new ErrorEvent(new Error(`Cannot move layer \"${id}\" before non-existing layer \"${before}\".`)));\n return;\n }\n this._order.splice(newIndex, 0, id);\n\n this._layerOrderChanged = true;\n }\n\n /**\n * Remove the layer with the given id from the style.\n *\n * If no such layer exists, an `error` event is fired.\n *\n * @param id - id of the layer to remove\n * @event `error` - Fired if the layer does not exist\n */\n removeLayer(id: string) {\n this._checkLoaded();\n\n const layer = this._layers[id];\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot remove non-existing layer \"${id}\".`)));\n return;\n }\n\n layer.setEventedParent(null);\n\n const index = this._order.indexOf(id);\n this._order.splice(index, 1);\n\n this._layerOrderChanged = true;\n this._changed = true;\n this._removedLayers[id] = layer;\n delete this._layers[id];\n\n if (this._serializedLayers) {\n delete this._serializedLayers[id];\n }\n delete this._updatedLayers[id];\n delete this._updatedPaintProps[id];\n\n if (layer.onRemove) {\n layer.onRemove(this.map);\n }\n }\n\n /**\n * Return the style layer object with the given `id`.\n *\n * @param id - id of the desired layer\n * @returns a layer, if one with the given `id` exists\n */\n getLayer(id: string): StyleLayer | undefined {\n return this._layers[id];\n }\n\n /**\n * Return the ids of all layers currently in the style, including custom layers, in order.\n *\n * @returns ids of layers, in order\n */\n getLayersOrder(): string[] {\n return [...this._order];\n }\n\n /**\n * Checks if a specific layer is present within the style.\n *\n * @param id - the id of the desired layer\n * @returns a boolean specifying if the given layer is present\n */\n hasLayer(id: string): boolean {\n return id in this._layers;\n }\n\n setLayerZoomRange(layerId: string, minzoom?: number | null, maxzoom?: number | null) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (layer.minzoom === minzoom && layer.maxzoom === maxzoom) return;\n\n if (minzoom != null) {\n layer.minzoom = minzoom;\n }\n if (maxzoom != null) {\n layer.maxzoom = maxzoom;\n }\n this._updateLayer(layer);\n }\n\n setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot filter non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.filter, filter)) {\n return;\n }\n\n if (filter === null || filter === undefined) {\n layer.filter = undefined;\n this._updateLayer(layer);\n return;\n }\n\n if (this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter, null, options)) {\n return;\n }\n\n layer.filter = clone(filter);\n this._updateLayer(layer);\n }\n\n /**\n * Get a layer's filter object\n * @param layer - the layer to inspect\n * @returns the layer's filter, if any\n */\n getFilter(layer: string): FilterSpecification | void {\n return clone(this.getLayer(layer).filter);\n }\n\n setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.getLayoutProperty(name), value)) return;\n\n layer.setLayoutProperty(name, value, options);\n this._updateLayer(layer);\n }\n\n /**\n * Get a layout property's value from a given layer\n * @param layerId - the layer to inspect\n * @param name - the name of the layout property\n * @returns the property value\n */\n getLayoutProperty(layerId: string, name: string) {\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot get style of non-existing layer \"${layerId}\".`)));\n return;\n }\n\n return layer.getLayoutProperty(name);\n }\n\n setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.getPaintProperty(name), value)) return;\n\n const requiresRelayout = layer.setPaintProperty(name, value, options);\n if (requiresRelayout) {\n this._updateLayer(layer);\n }\n\n this._changed = true;\n this._updatedPaintProps[layerId] = true;\n }\n\n getPaintProperty(layer: string, name: string) {\n return this.getLayer(layer).getPaintProperty(name);\n }\n\n setFeatureState(target: FeatureIdentifier, state: any) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceLayer = target.sourceLayer;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n const sourceType = sourceCache.getSource().type;\n if (sourceType === 'geojson' && sourceLayer) {\n this.fire(new ErrorEvent(new Error('GeoJSON sources cannot have a sourceLayer parameter.')));\n return;\n }\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n if (target.id === undefined) {\n this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.')));\n }\n\n sourceCache.setFeatureState(sourceLayer, target.id, state);\n }\n\n removeFeatureState(target: FeatureIdentifier, key?: string) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n\n const sourceType = sourceCache.getSource().type;\n const sourceLayer = sourceType === 'vector' ? target.sourceLayer : undefined;\n\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n\n if (key && (typeof target.id !== 'string' && typeof target.id !== 'number')) {\n this.fire(new ErrorEvent(new Error('A feature id is required to remove its specific state property.')));\n return;\n }\n\n sourceCache.removeFeatureState(sourceLayer, target.id, key);\n }\n\n getFeatureState(target: FeatureIdentifier) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceLayer = target.sourceLayer;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n const sourceType = sourceCache.getSource().type;\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n if (target.id === undefined) {\n this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.')));\n }\n\n return sourceCache.getFeatureState(sourceLayer, target.id);\n }\n\n getTransition() {\n return extend({duration: 300, delay: 0}, this.stylesheet && this.stylesheet.transition);\n }\n\n serialize(): StyleSpecification {\n // We return undefined before we're loaded, following the pattern of Map.getStyle() before\n // the Style object is initialized.\n // Internally, Style._validate() calls Style.serialize() but callers are responsible for\n // calling Style._checkLoaded() first if their validation requires the style to be loaded.\n if (!this._loaded) return;\n\n const sources = mapObject(this.sourceCaches, (source) => source.serialize());\n const layers = this._serializeByIds(this._order);\n const terrain = this.map.getTerrain() || undefined;\n const myStyleSheet = this.stylesheet;\n\n return filterObject({\n version: myStyleSheet.version,\n name: myStyleSheet.name,\n metadata: myStyleSheet.metadata,\n light: myStyleSheet.light,\n center: myStyleSheet.center,\n zoom: myStyleSheet.zoom,\n bearing: myStyleSheet.bearing,\n pitch: myStyleSheet.pitch,\n sprite: myStyleSheet.sprite,\n glyphs: myStyleSheet.glyphs,\n transition: myStyleSheet.transition,\n sources,\n layers,\n terrain\n },\n (value) => { return value !== undefined; });\n }\n\n _updateLayer(layer: StyleLayer) {\n this._updatedLayers[layer.id] = true;\n if (layer.source && !this._updatedSources[layer.source] &&\n //Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865)\n this.sourceCaches[layer.source].getSource().type !== 'raster') {\n this._updatedSources[layer.source] = 'reload';\n this.sourceCaches[layer.source].pause();\n }\n\n // upon updating, serilized layer dictionary should be reset.\n // When needed, it will be populated with the correct copy again.\n this._serializedLayers = null;\n this._changed = true;\n }\n\n _flattenAndSortRenderedFeatures(sourceResults: Array<{ [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> }>) {\n // Feature order is complicated.\n // The order between features in two 2D layers is always determined by layer order.\n // The order between features in two 3D layers is always determined by depth.\n // The order between a feature in a 2D layer and a 3D layer is tricky:\n // Most often layer order determines the feature order in this case. If\n // a line layer is above a extrusion layer the line feature will be rendered\n // above the extrusion. If the line layer is below the extrusion layer,\n // it will be rendered below it.\n //\n // There is a weird case though.\n // You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b\n // Each layer has a feature that overlaps the other features.\n // The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above.\n // The feature in line_layer is rendered above extrusion_layer_a.\n // This means that that the line_layer feature is above the extrusion_layer_b feature despite\n // it being in an earlier layer.\n\n const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion';\n\n const layerIndex = {};\n const features3D = [];\n for (let l = this._order.length - 1; l >= 0; l--) {\n const layerId = this._order[l];\n if (isLayer3D(layerId)) {\n layerIndex[layerId] = l;\n for (const sourceResult of sourceResults) {\n const layerFeatures = sourceResult[layerId];\n if (layerFeatures) {\n for (const featureWrapper of layerFeatures) {\n features3D.push(featureWrapper);\n }\n }\n }\n }\n }\n\n features3D.sort((a, b) => {\n return b.intersectionZ - a.intersectionZ;\n });\n\n const features = [];\n for (let l = this._order.length - 1; l >= 0; l--) {\n const layerId = this._order[l];\n\n if (isLayer3D(layerId)) {\n // add all 3D features that are in or above the current layer\n for (let i = features3D.length - 1; i >= 0; i--) {\n const topmost3D = features3D[i].feature;\n if (layerIndex[topmost3D.layer.id] < l) break;\n features.push(topmost3D);\n features3D.pop();\n }\n } else {\n for (const sourceResult of sourceResults) {\n const layerFeatures = sourceResult[layerId];\n if (layerFeatures) {\n for (const featureWrapper of layerFeatures) {\n features.push(featureWrapper.feature);\n }\n }\n }\n }\n }\n\n return features;\n }\n\n queryRenderedFeatures(queryGeometry: any, params: QueryRenderedFeaturesOptions, transform: Transform) {\n if (params && params.filter) {\n this._validate(validateStyle.filter, 'queryRenderedFeatures.filter', params.filter, null, params);\n }\n\n const includedSources = {};\n if (params && params.layers) {\n if (!Array.isArray(params.layers)) {\n this.fire(new ErrorEvent(new Error('parameters.layers must be an Array.')));\n return [];\n }\n for (const layerId of params.layers) {\n const layer = this._layers[layerId];\n if (!layer) {\n // this layer is not in the style.layers array\n this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be queried for features.`)));\n return [];\n }\n includedSources[layer.source] = true;\n }\n }\n\n const sourceResults = [];\n\n params.availableImages = this._availableImages;\n\n // LayerSpecification is serialized StyleLayer, and this casting is safe.\n const serializedLayers = this._serializedAllLayers() as {[_: string]: StyleLayer};\n\n for (const id in this.sourceCaches) {\n if (params.layers && !includedSources[id]) continue;\n sourceResults.push(\n queryRenderedFeatures(\n this.sourceCaches[id],\n this._layers,\n serializedLayers,\n queryGeometry,\n params,\n transform)\n );\n }\n\n if (this.placement) {\n // If a placement has run, query against its CollisionIndex\n // for symbol results, and treat it as an extra source to merge\n sourceResults.push(\n queryRenderedSymbols(\n this._layers,\n serializedLayers,\n this.sourceCaches,\n queryGeometry,\n params,\n this.placement.collisionIndex,\n this.placement.retainedQueryData)\n );\n }\n\n return this._flattenAndSortRenderedFeatures(sourceResults);\n }\n\n querySourceFeatures(\n sourceID: string,\n params?: QuerySourceFeatureOptions\n ) {\n if (params && params.filter) {\n this._validate(validateStyle.filter, 'querySourceFeatures.filter', params.filter, null, params);\n }\n const sourceCache = this.sourceCaches[sourceID];\n return sourceCache ? querySourceFeatures(sourceCache, params) : [];\n }\n\n addSourceType(name: string, SourceType: SourceClass, callback: Callback) {\n if (getSourceType(name)) {\n return callback(new Error(`A source type called \"${name}\" already exists.`));\n }\n\n setSourceType(name, SourceType);\n\n if (!SourceType.workerSourceURL) {\n return callback(null, null);\n }\n\n this.dispatcher.broadcast('loadWorkerSource', {\n name,\n url: SourceType.workerSourceURL\n }, callback);\n }\n\n getLight() {\n return this.light.getLight();\n }\n\n setLight(lightOptions: LightSpecification, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const light = this.light.getLight();\n let _update = false;\n for (const key in lightOptions) {\n if (!deepEqual(lightOptions[key], light[key])) {\n _update = true;\n break;\n }\n }\n if (!_update) return;\n\n const parameters = {\n now: browser.now(),\n transition: extend({\n duration: 300,\n delay: 0\n }, this.stylesheet.transition)\n };\n\n this.light.setLight(lightOptions, options);\n this.light.updateTransitions(parameters);\n }\n\n _validate(validate: Validator, key: string, value: any, props: any, options: {\n validate?: boolean;\n } = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, extend({\n key,\n style: this.serialize(),\n value,\n styleSpec\n }, props)));\n }\n\n _remove(mapRemoved: boolean = true) {\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n if (this._spriteRequest) {\n this._spriteRequest.cancel();\n this._spriteRequest = null;\n }\n rtlTextPluginEvented.off('pluginStateChange', this._rtlTextPluginCallback);\n for (const layerId in this._layers) {\n const layer: StyleLayer = this._layers[layerId];\n layer.setEventedParent(null);\n }\n for (const id in this.sourceCaches) {\n const sourceCache = this.sourceCaches[id];\n sourceCache.setEventedParent(null);\n sourceCache.onRemove(this.map);\n }\n this.imageManager.setEventedParent(null);\n this.setEventedParent(null);\n this.dispatcher.remove(mapRemoved);\n }\n\n _clearSource(id: string) {\n this.sourceCaches[id].clearTiles();\n }\n\n _reloadSource(id: string) {\n this.sourceCaches[id].resume();\n this.sourceCaches[id].reload();\n }\n\n _updateSources(transform: Transform) {\n for (const id in this.sourceCaches) {\n this.sourceCaches[id].update(transform, this.map.terrain);\n }\n }\n\n _generateCollisionBoxes() {\n for (const id in this.sourceCaches) {\n this._reloadSource(id);\n }\n }\n\n _updatePlacement(transform: Transform, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, forceFullPlacement: boolean = false) {\n let symbolBucketsChanged = false;\n let placementCommitted = false;\n\n const layerTiles = {};\n\n for (const layerID of this._order) {\n const styleLayer = this._layers[layerID];\n if (styleLayer.type !== 'symbol') continue;\n\n if (!layerTiles[styleLayer.source]) {\n const sourceCache = this.sourceCaches[styleLayer.source];\n layerTiles[styleLayer.source] = sourceCache.getRenderableIds(true)\n .map((id) => sourceCache.getTileByID(id))\n .sort((a, b) => (b.tileID.overscaledZ - a.tileID.overscaledZ) || (a.tileID.isLessThan(b.tileID) ? -1 : 1));\n }\n\n const layerBucketsChanged = this.crossTileSymbolIndex.addLayer(styleLayer, layerTiles[styleLayer.source], transform.center.lng);\n symbolBucketsChanged = symbolBucketsChanged || layerBucketsChanged;\n }\n this.crossTileSymbolIndex.pruneUnusedLayers(this._order);\n\n // Anything that changes our \"in progress\" layer and tile indices requires us\n // to start over. When we start over, we do a full placement instead of incremental\n // to prevent starvation.\n // We need to restart placement to keep layer indices in sync.\n // Also force full placement when fadeDuration === 0 to ensure that newly loaded\n // tiles will fully display symbols in their first frame\n forceFullPlacement = forceFullPlacement || this._layerOrderChanged || fadeDuration === 0;\n\n if (forceFullPlacement || !this.pauseablePlacement || (this.pauseablePlacement.isDone() && !this.placement.stillRecent(browser.now(), transform.zoom))) {\n this.pauseablePlacement = new PauseablePlacement(transform, this.map.terrain, this._order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, this.placement);\n this._layerOrderChanged = false;\n }\n\n if (this.pauseablePlacement.isDone()) {\n // the last placement finished running, but the next one hasn’t\n // started yet because of the `stillRecent` check immediately\n // above, so mark it stale to ensure that we request another\n // render frame\n this.placement.setStale();\n } else {\n this.pauseablePlacement.continuePlacement(this._order, this._layers, layerTiles);\n\n if (this.pauseablePlacement.isDone()) {\n this.placement = this.pauseablePlacement.commit(browser.now());\n placementCommitted = true;\n }\n\n if (symbolBucketsChanged) {\n // since the placement gets split over multiple frames it is possible\n // these buckets were processed before they were changed and so the\n // placement is already stale while it is in progress\n this.pauseablePlacement.placement.setStale();\n }\n }\n\n if (placementCommitted || symbolBucketsChanged) {\n for (const layerID of this._order) {\n const styleLayer = this._layers[layerID];\n if (styleLayer.type !== 'symbol') continue;\n this.placement.updateLayerOpacities(styleLayer, layerTiles[styleLayer.source]);\n }\n }\n\n // needsRender is false when we have just finished a placement that didn't change the visibility of any symbols\n const needsRerender = !this.pauseablePlacement.isDone() || this.placement.hasTransitions(browser.now());\n return needsRerender;\n }\n\n _releaseSymbolFadeTiles() {\n for (const id in this.sourceCaches) {\n this.sourceCaches[id].releaseSymbolFadeTiles();\n }\n }\n\n // Callbacks from web workers\n\n getImages(\n mapId: string,\n params: {\n icons: Array;\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: StyleImage}>\n ) {\n this.imageManager.getImages(params.icons, callback);\n\n // Apply queued image changes before setting the tile's dependencies so that the tile\n // is not reloaded unnecessarily. Without this forced update the reload could happen in cases\n // like this one:\n // - icons contains \"my-image\"\n // - imageManager.getImages(...) triggers `onstyleimagemissing`\n // - the user adds \"my-image\" within the callback\n // - addImage adds \"my-image\" to this._changedImages\n // - the next frame triggers a reload of this tile even though it already has the latest version\n this._updateTilesForChangedImages();\n\n const sourceCache = this.sourceCaches[params.source];\n if (sourceCache) {\n sourceCache.setDependencies(params.tileID.key, params.type, params.icons);\n }\n }\n\n getGlyphs(\n mapId: string,\n params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n ) {\n this.glyphManager.getGlyphs(params.stacks, callback);\n const sourceCache = this.sourceCaches[params.source];\n if (sourceCache) {\n // we are not setting stacks as dependencies since for now\n // we just need to know which tiles have glyph dependencies\n sourceCache.setDependencies(params.tileID.key, params.type, ['']);\n }\n }\n\n getResource(mapId: string, params: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(params, callback);\n }\n\n getGlyphsUrl() {\n return this.stylesheet.glyphs || null;\n }\n\n setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n if (glyphsUrl && this._validate(validateStyle.glyphs, 'glyphs', glyphsUrl, null, options)) {\n return;\n }\n\n this._glyphsDidChange = true;\n this.stylesheet.glyphs = glyphsUrl;\n this.glyphManager.entries = {};\n this.glyphManager.setURL(glyphsUrl);\n }\n\n /**\n * Add a sprite.\n *\n * @param id - The id of the desired sprite\n * @param url - The url to load the desired sprite from\n * @param options - The style setter options\n * @param completion - The completion handler\n */\n addSprite(id: string, url: string, options: StyleSetterOptions = {}, completion?: (err: Error) => void) {\n this._checkLoaded();\n\n const spriteToAdd = [{id, url}];\n const updatedSprite = [\n ...coerceSpriteToArray(this.stylesheet.sprite),\n ...spriteToAdd\n ];\n\n if (this._validate(validateStyle.sprite, 'sprite', updatedSprite, null, options)) return;\n\n this.stylesheet.sprite = updatedSprite;\n this._loadSprite(spriteToAdd, true, completion);\n }\n\n /**\n * Remove a sprite by its id. When the last sprite is removed, the whole `this.stylesheet.sprite` object becomes\n * `undefined`. This falsy `undefined` value later prevents attempts to load the sprite when it's absent.\n *\n * @param id - the id of the sprite to remove\n */\n removeSprite(id: string) {\n this._checkLoaded();\n\n const internalSpriteRepresentation = coerceSpriteToArray(this.stylesheet.sprite);\n\n if (!internalSpriteRepresentation.find(sprite => sprite.id === id)) {\n this.fire(new ErrorEvent(new Error(`Sprite \"${id}\" doesn't exists on this map.`)));\n return;\n }\n\n if (this._spritesImagesIds[id]) {\n for (const imageId of this._spritesImagesIds[id]) {\n this.imageManager.removeImage(imageId);\n this._changedImages[imageId] = true;\n }\n }\n\n internalSpriteRepresentation.splice(internalSpriteRepresentation.findIndex(sprite => sprite.id === id), 1);\n this.stylesheet.sprite = internalSpriteRepresentation.length > 0 ? internalSpriteRepresentation : undefined;\n\n delete this._spritesImagesIds[id];\n this._availableImages = this.imageManager.listImages();\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n /**\n * Get the current sprite value.\n *\n * @returns empty array when no sprite is set; id-url pairs otherwise\n */\n getSprite() {\n return coerceSpriteToArray(this.stylesheet.sprite);\n }\n\n /**\n * Set a new value for the style's sprite.\n *\n * @param sprite - new sprite value\n * @param options - style setter options\n * @param completion - the completion handler\n */\n setSprite(sprite: SpriteSpecification, options: StyleSetterOptions = {}, completion?: (err: Error) => void) {\n this._checkLoaded();\n\n if (sprite && this._validate(validateStyle.sprite, 'sprite', sprite, null, options)) {\n return;\n }\n\n this.stylesheet.sprite = sprite;\n\n if (sprite) {\n this._loadSprite(sprite, true, completion);\n } else {\n this._unloadSprite();\n if (completion) {\n completion(null);\n }\n }\n }\n}\n\nStyle.registerForPluginStateChange = registerForPluginStateChange;\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos', type: 'Int16', components: 2}\n]);\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}';\n","\n// Disable Flow annotations here because Flow doesn't support importing GLSL files\n\nimport preludeFrag from './_prelude.fragment.glsl.g';\nimport preludeVert from './_prelude.vertex.glsl.g';\nimport backgroundFrag from './background.fragment.glsl.g';\nimport backgroundVert from './background.vertex.glsl.g';\nimport backgroundPatternFrag from './background_pattern.fragment.glsl.g';\nimport backgroundPatternVert from './background_pattern.vertex.glsl.g';\nimport circleFrag from './circle.fragment.glsl.g';\nimport circleVert from './circle.vertex.glsl.g';\nimport clippingMaskFrag from './clipping_mask.fragment.glsl.g';\nimport clippingMaskVert from './clipping_mask.vertex.glsl.g';\nimport heatmapFrag from './heatmap.fragment.glsl.g';\nimport heatmapVert from './heatmap.vertex.glsl.g';\nimport heatmapTextureFrag from './heatmap_texture.fragment.glsl.g';\nimport heatmapTextureVert from './heatmap_texture.vertex.glsl.g';\nimport collisionBoxFrag from './collision_box.fragment.glsl.g';\nimport collisionBoxVert from './collision_box.vertex.glsl.g';\nimport collisionCircleFrag from './collision_circle.fragment.glsl.g';\nimport collisionCircleVert from './collision_circle.vertex.glsl.g';\nimport debugFrag from './debug.fragment.glsl.g';\nimport debugVert from './debug.vertex.glsl.g';\nimport fillFrag from './fill.fragment.glsl.g';\nimport fillVert from './fill.vertex.glsl.g';\nimport fillOutlineFrag from './fill_outline.fragment.glsl.g';\nimport fillOutlineVert from './fill_outline.vertex.glsl.g';\nimport fillOutlinePatternFrag from './fill_outline_pattern.fragment.glsl.g';\nimport fillOutlinePatternVert from './fill_outline_pattern.vertex.glsl.g';\nimport fillPatternFrag from './fill_pattern.fragment.glsl.g';\nimport fillPatternVert from './fill_pattern.vertex.glsl.g';\nimport fillExtrusionFrag from './fill_extrusion.fragment.glsl.g';\nimport fillExtrusionVert from './fill_extrusion.vertex.glsl.g';\nimport fillExtrusionPatternFrag from './fill_extrusion_pattern.fragment.glsl.g';\nimport fillExtrusionPatternVert from './fill_extrusion_pattern.vertex.glsl.g';\nimport hillshadePrepareFrag from './hillshade_prepare.fragment.glsl.g';\nimport hillshadePrepareVert from './hillshade_prepare.vertex.glsl.g';\nimport hillshadeFrag from './hillshade.fragment.glsl.g';\nimport hillshadeVert from './hillshade.vertex.glsl.g';\nimport lineFrag from './line.fragment.glsl.g';\nimport lineVert from './line.vertex.glsl.g';\nimport lineGradientFrag from './line_gradient.fragment.glsl.g';\nimport lineGradientVert from './line_gradient.vertex.glsl.g';\nimport linePatternFrag from './line_pattern.fragment.glsl.g';\nimport linePatternVert from './line_pattern.vertex.glsl.g';\nimport lineSDFFrag from './line_sdf.fragment.glsl.g';\nimport lineSDFVert from './line_sdf.vertex.glsl.g';\nimport rasterFrag from './raster.fragment.glsl.g';\nimport rasterVert from './raster.vertex.glsl.g';\nimport symbolIconFrag from './symbol_icon.fragment.glsl.g';\nimport symbolIconVert from './symbol_icon.vertex.glsl.g';\nimport symbolSDFFrag from './symbol_sdf.fragment.glsl.g';\nimport symbolSDFVert from './symbol_sdf.vertex.glsl.g';\nimport symbolTextAndIconFrag from './symbol_text_and_icon.fragment.glsl.g';\nimport symbolTextAndIconVert from './symbol_text_and_icon.vertex.glsl.g';\nimport terrainDepthFrag from './terrain_depth.fragment.glsl.g';\nimport terrainCoordsFrag from './terrain_coords.fragment.glsl.g';\nimport terrainFrag from './terrain.fragment.glsl.g';\nimport terrainVert from './terrain.vertex.glsl.g';\n\nexport const shaders = {\n prelude: compile(preludeFrag, preludeVert),\n background: compile(backgroundFrag, backgroundVert),\n backgroundPattern: compile(backgroundPatternFrag, backgroundPatternVert),\n circle: compile(circleFrag, circleVert),\n clippingMask: compile(clippingMaskFrag, clippingMaskVert),\n heatmap: compile(heatmapFrag, heatmapVert),\n heatmapTexture: compile(heatmapTextureFrag, heatmapTextureVert),\n collisionBox: compile(collisionBoxFrag, collisionBoxVert),\n collisionCircle: compile(collisionCircleFrag, collisionCircleVert),\n debug: compile(debugFrag, debugVert),\n fill: compile(fillFrag, fillVert),\n fillOutline: compile(fillOutlineFrag, fillOutlineVert),\n fillOutlinePattern: compile(fillOutlinePatternFrag, fillOutlinePatternVert),\n fillPattern: compile(fillPatternFrag, fillPatternVert),\n fillExtrusion: compile(fillExtrusionFrag, fillExtrusionVert),\n fillExtrusionPattern: compile(fillExtrusionPatternFrag, fillExtrusionPatternVert),\n hillshadePrepare: compile(hillshadePrepareFrag, hillshadePrepareVert),\n hillshade: compile(hillshadeFrag, hillshadeVert),\n line: compile(lineFrag, lineVert),\n lineGradient: compile(lineGradientFrag, lineGradientVert),\n linePattern: compile(linePatternFrag, linePatternVert),\n lineSDF: compile(lineSDFFrag, lineSDFVert),\n raster: compile(rasterFrag, rasterVert),\n symbolIcon: compile(symbolIconFrag, symbolIconVert),\n symbolSDF: compile(symbolSDFFrag, symbolSDFVert),\n symbolTextAndIcon: compile(symbolTextAndIconFrag, symbolTextAndIconVert),\n terrain: compile(terrainFrag, terrainVert),\n terrainDepth: compile(terrainDepthFrag, terrainVert),\n terrainCoords: compile(terrainCoordsFrag, terrainVert)\n};\n\n// Expand #pragmas to #ifdefs.\n\nfunction compile(fragmentSource, vertexSource) {\n const re = /#pragma mapbox: ([\\w]+) ([\\w]+) ([\\w]+) ([\\w]+)/g;\n\n const staticAttributes = vertexSource.match(/attribute ([\\w]+) ([\\w]+)/g);\n const fragmentUniforms = fragmentSource.match(/uniform ([\\w]+) ([\\w]+)([\\s]*)([\\w]*)/g);\n const vertexUniforms = vertexSource.match(/uniform ([\\w]+) ([\\w]+)([\\s]*)([\\w]*)/g);\n const staticUniforms = vertexUniforms ? vertexUniforms.concat(fragmentUniforms) : fragmentUniforms;\n\n const fragmentPragmas = {};\n\n fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => {\n fragmentPragmas[name] = true;\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nvarying ${precision} ${type} ${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n return `\n#ifdef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n });\n\n vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => {\n const attrType = type === 'float' ? 'vec2' : 'vec4';\n const unpackType = name.match(/color/) ? 'color' : attrType;\n\n if (fragmentPragmas[name]) {\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nuniform lowp float u_${name}_t;\nattribute ${precision} ${attrType} a_${name};\nvarying ${precision} ${type} ${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n if (unpackType === 'vec4') {\n // vec4 attributes are only used for cross-faded properties, and are not packed\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${name} = a_${name};\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n } else {\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n }\n } else {\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nuniform lowp float u_${name}_t;\nattribute ${precision} ${attrType} a_${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n if (unpackType === 'vec4') {\n // vec4 attributes are only used for cross-faded properties, and are not packed\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = a_${name};\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n } else /* */ {\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n }\n }\n });\n\n return {fragmentSource, vertexSource, staticAttributes, staticUniforms};\n}\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision mediump float;\\n#else\\n#if !defined(lowp)\\n#define lowp\\n#endif\\n#if !defined(mediump)\\n#define mediump\\n#endif\\n#if !defined(highp)\\n#define highp\\n#endif\\n#endif\\n';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#else\\n#if !defined(lowp)\\n#define lowp\\n#endif\\n#if !defined(mediump)\\n#define mediump\\n#endif\\n#if !defined(highp)\\n#define highp\\n#endif\\n#endif\\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\\n#ifdef TERRAIN3D\\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\\n#endif\\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\\n#ifdef TERRAIN3D\\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\\n#else\\nreturn 1.0;\\n#endif\\n}float calculate_visibility(vec4 pos) {\\n#ifdef TERRAIN3D\\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\\n#else\\nreturn 1.0;\\n#endif\\n}float ele(vec2 pos) {\\n#ifdef TERRAIN3D\\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\\n#else\\nreturn 0.0;\\n#endif\\n}float get_elevation(vec2 pos) {\\n#ifdef TERRAIN3D\\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\\n#else\\nreturn 0.0;\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec3 v_data;varying float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvoid main(void) {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'void main() {gl_FragColor=vec4(1.0);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform highp float u_intensity;varying vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main() {\\n#pragma mapbox: initialize highp float weight\\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#pragma mapbox: define mediump float radius\\nconst highp float ZERO=1.0/255.0/16.0;\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main(void) {\\n#pragma mapbox: initialize highp float weight\\n#pragma mapbox: initialize mediump float radius\\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(0.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_FragColor=color*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec4 v_color;void main() {gl_FragColor=v_color;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\\n#ifdef TERRAIN3D\\nattribute vec2 a_centroid;\\n#endif\\nvarying vec4 v_color;\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\n#pragma mapbox: define highp vec4 color\\nvoid main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\n#pragma mapbox: initialize highp vec4 color\\nvec3 normal=a_normal_ed.xyz;\\n#ifdef TERRAIN3D\\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\\n#else\\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\\n#endif\\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\\n#pragma mapbox: define lowp float base\\n#pragma mapbox: define lowp float height\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float base\\n#pragma mapbox: initialize lowp float height\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\\n#ifdef TERRAIN3D\\nattribute vec2 a_centroid;\\n#endif\\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\\n#pragma mapbox: define lowp float base\\n#pragma mapbox: define lowp float height\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float base\\n#pragma mapbox: initialize lowp float height\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\\n#ifdef TERRAIN3D\\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\\n#else\\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\\n#endif\\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\\n? a_pos\\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\\n#define PI 3.141592653589793\\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\n#define LINE_DISTANCE_SCALE 2.0\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\n#define LINE_DISTANCE_SCALE 2.0\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#define SDF_PX 8.0\\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#define SDF_PX 8.0\\n#define SDF 1.0\\n#define ICON 0.0\\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}';\n","\nimport type {Program} from './program';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {Context} from '../gl/context';\n\n/**\n * @internal\n * A vertex array object used to pass data to the webgl code\n */\nexport class VertexArrayObject {\n context: Context;\n boundProgram: Program;\n boundLayoutVertexBuffer: VertexBuffer;\n boundPaintVertexBuffers: Array;\n boundIndexBuffer: IndexBuffer;\n boundVertexOffset: number;\n boundDynamicVertexBuffer: VertexBuffer;\n boundDynamicVertexBuffer2: VertexBuffer;\n boundDynamicVertexBuffer3: VertexBuffer;\n vao: any;\n\n constructor() {\n this.boundProgram = null;\n this.boundLayoutVertexBuffer = null;\n this.boundPaintVertexBuffers = [];\n this.boundIndexBuffer = null;\n this.boundVertexOffset = null;\n this.boundDynamicVertexBuffer = null;\n this.vao = null;\n }\n\n bind(context: Context,\n program: Program,\n layoutVertexBuffer: VertexBuffer,\n paintVertexBuffers: Array,\n indexBuffer?: IndexBuffer | null,\n vertexOffset?: number | null,\n dynamicVertexBuffer?: VertexBuffer | null,\n dynamicVertexBuffer2?: VertexBuffer | null,\n dynamicVertexBuffer3?: VertexBuffer | null) {\n\n this.context = context;\n\n let paintBuffersDiffer = this.boundPaintVertexBuffers.length !== paintVertexBuffers.length;\n for (let i = 0; !paintBuffersDiffer && i < paintVertexBuffers.length; i++) {\n if (this.boundPaintVertexBuffers[i] !== paintVertexBuffers[i]) {\n paintBuffersDiffer = true;\n }\n }\n\n const isFreshBindRequired = (\n !this.vao ||\n this.boundProgram !== program ||\n this.boundLayoutVertexBuffer !== layoutVertexBuffer ||\n paintBuffersDiffer ||\n this.boundIndexBuffer !== indexBuffer ||\n this.boundVertexOffset !== vertexOffset ||\n this.boundDynamicVertexBuffer !== dynamicVertexBuffer ||\n this.boundDynamicVertexBuffer2 !== dynamicVertexBuffer2 ||\n this.boundDynamicVertexBuffer3 !== dynamicVertexBuffer3\n );\n\n if (isFreshBindRequired) {\n this.freshBind(program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3);\n } else {\n context.bindVertexArray.set(this.vao);\n\n if (dynamicVertexBuffer) {\n // The buffer may have been updated. Rebind to upload data.\n dynamicVertexBuffer.bind();\n }\n\n if (indexBuffer && indexBuffer.dynamicDraw) {\n indexBuffer.bind();\n }\n\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.bind();\n }\n\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.bind();\n }\n }\n }\n\n freshBind(program: Program,\n layoutVertexBuffer: VertexBuffer,\n paintVertexBuffers: Array,\n indexBuffer?: IndexBuffer | null,\n vertexOffset?: number | null,\n dynamicVertexBuffer?: VertexBuffer | null,\n dynamicVertexBuffer2?: VertexBuffer | null,\n dynamicVertexBuffer3?: VertexBuffer | null) {\n\n const numNextAttributes = program.numAttributes;\n\n const context = this.context;\n const gl = context.gl;\n\n if (this.vao) this.destroy();\n this.vao = context.createVertexArray();\n context.bindVertexArray.set(this.vao);\n\n // store the arguments so that we can verify them when the vao is bound again\n this.boundProgram = program;\n this.boundLayoutVertexBuffer = layoutVertexBuffer;\n this.boundPaintVertexBuffers = paintVertexBuffers;\n this.boundIndexBuffer = indexBuffer;\n this.boundVertexOffset = vertexOffset;\n this.boundDynamicVertexBuffer = dynamicVertexBuffer;\n this.boundDynamicVertexBuffer2 = dynamicVertexBuffer2;\n this.boundDynamicVertexBuffer3 = dynamicVertexBuffer3;\n\n layoutVertexBuffer.enableAttributes(gl, program);\n for (const vertexBuffer of paintVertexBuffers) {\n vertexBuffer.enableAttributes(gl, program);\n }\n\n if (dynamicVertexBuffer) {\n dynamicVertexBuffer.enableAttributes(gl, program);\n }\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.enableAttributes(gl, program);\n }\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.enableAttributes(gl, program);\n }\n\n layoutVertexBuffer.bind();\n layoutVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n for (const vertexBuffer of paintVertexBuffers) {\n vertexBuffer.bind();\n vertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n }\n\n if (dynamicVertexBuffer) {\n dynamicVertexBuffer.bind();\n dynamicVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n }\n if (indexBuffer) {\n indexBuffer.bind();\n }\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.bind();\n dynamicVertexBuffer2.setVertexAttribPointers(gl, program, vertexOffset);\n }\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.bind();\n dynamicVertexBuffer3.setVertexAttribPointers(gl, program, vertexOffset);\n }\n\n context.currentNumAttributes = numNextAttributes;\n }\n\n destroy() {\n if (this.vao) {\n this.context.deleteVertexArray(this.vao);\n this.vao = null;\n }\n }\n}\n","import {shaders} from '../shaders/shaders';\nimport {ProgramConfiguration} from '../data/program_configuration';\nimport {VertexArrayObject} from './vertex_array_object';\nimport {Context} from '../gl/context';\n\nimport type {SegmentVector} from '../data/segment';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {DepthMode} from '../gl/depth_mode';\nimport type {StencilMode} from '../gl/stencil_mode';\nimport type {ColorMode} from '../gl/color_mode';\nimport type {CullFaceMode} from '../gl/cull_face_mode';\nimport type {UniformBindings, UniformValues, UniformLocations} from './uniform_binding';\nimport type {BinderUniform} from '../data/program_configuration';\nimport {terrainPreludeUniforms, TerrainPreludeUniformsType} from './program/terrain_program';\nimport type {TerrainData} from '../render/terrain';\nimport {Terrain} from '../render/terrain';\n\nexport type DrawMode = WebGLRenderingContextBase['LINES'] | WebGLRenderingContextBase['TRIANGLES'] | WebGL2RenderingContext['LINE_STRIP'];\n\nfunction getTokenizedAttributesAndUniforms(array: Array): Array {\n const result = [];\n\n for (let i = 0; i < array.length; i++) {\n if (array[i] === null) continue;\n const token = array[i].split(' ');\n result.push(token.pop());\n }\n return result;\n}\n\n/**\n * @internal\n * A webgl program to execute in the GPU space\n */\nexport class Program {\n program: WebGLProgram;\n attributes: {[_: string]: number};\n numAttributes: number;\n fixedUniforms: Us;\n terrainUniforms: TerrainPreludeUniformsType;\n binderUniforms: Array;\n failedToCreate: boolean;\n\n constructor(context: Context,\n source: {\n fragmentSource: string;\n vertexSource: string;\n staticAttributes: Array;\n staticUniforms: Array;\n },\n configuration: ProgramConfiguration,\n fixedUniforms: (b: Context, a: UniformLocations) => Us,\n showOverdrawInspector: boolean,\n terrain: Terrain) {\n\n const gl = context.gl;\n this.program = gl.createProgram();\n\n const staticAttrInfo = getTokenizedAttributesAndUniforms(source.staticAttributes);\n const dynamicAttrInfo = configuration ? configuration.getBinderAttributes() : [];\n const allAttrInfo = staticAttrInfo.concat(dynamicAttrInfo);\n\n const preludeUniformsInfo = shaders.prelude.staticUniforms ? getTokenizedAttributesAndUniforms(shaders.prelude.staticUniforms) : [];\n const staticUniformsInfo = source.staticUniforms ? getTokenizedAttributesAndUniforms(source.staticUniforms) : [];\n const dynamicUniformsInfo = configuration ? configuration.getBinderUniforms() : [];\n // remove duplicate uniforms\n const uniformList = preludeUniformsInfo.concat(staticUniformsInfo).concat(dynamicUniformsInfo);\n const allUniformsInfo = [];\n for (const uniform of uniformList) {\n if (allUniformsInfo.indexOf(uniform) < 0) allUniformsInfo.push(uniform);\n }\n\n const defines = configuration ? configuration.defines() : [];\n if (showOverdrawInspector) {\n defines.push('#define OVERDRAW_INSPECTOR;');\n }\n if (terrain) {\n defines.push('#define TERRAIN3D;');\n }\n\n const fragmentSource = defines.concat(shaders.prelude.fragmentSource, source.fragmentSource).join('\\n');\n const vertexSource = defines.concat(shaders.prelude.vertexSource, source.vertexSource).join('\\n');\n\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (gl.isContextLost()) {\n this.failedToCreate = true;\n return;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);\n }\n\n gl.attachShader(this.program, fragmentShader);\n\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n if (gl.isContextLost()) {\n this.failedToCreate = true;\n return;\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);\n }\n\n gl.attachShader(this.program, vertexShader);\n\n this.attributes = {};\n const uniformLocations = {};\n\n this.numAttributes = allAttrInfo.length;\n\n for (let i = 0; i < this.numAttributes; i++) {\n if (allAttrInfo[i]) {\n gl.bindAttribLocation(this.program, i, allAttrInfo[i]);\n this.attributes[allAttrInfo[i]] = i;\n }\n }\n\n gl.linkProgram(this.program);\n\n if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {\n throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);\n }\n\n gl.deleteShader(vertexShader);\n gl.deleteShader(fragmentShader);\n\n for (let it = 0; it < allUniformsInfo.length; it++) {\n const uniform = allUniformsInfo[it];\n if (uniform && !uniformLocations[uniform]) {\n const uniformLocation = gl.getUniformLocation(this.program, uniform);\n if (uniformLocation) {\n uniformLocations[uniform] = uniformLocation;\n }\n }\n }\n\n this.fixedUniforms = fixedUniforms(context, uniformLocations);\n this.terrainUniforms = terrainPreludeUniforms(context, uniformLocations);\n this.binderUniforms = configuration ? configuration.getUniforms(context, uniformLocations) : [];\n }\n\n draw(context: Context,\n drawMode: DrawMode,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly,\n cullFaceMode: Readonly,\n uniformValues: UniformValues,\n terrain: TerrainData,\n layerID: string,\n layoutVertexBuffer: VertexBuffer,\n indexBuffer: IndexBuffer,\n segments: SegmentVector,\n currentProperties?: any,\n zoom?: number | null,\n configuration?: ProgramConfiguration | null,\n dynamicLayoutBuffer?: VertexBuffer | null,\n dynamicLayoutBuffer2?: VertexBuffer | null,\n dynamicLayoutBuffer3?: VertexBuffer | null) {\n\n const gl = context.gl;\n\n if (this.failedToCreate) return;\n\n context.program.set(this.program);\n context.setDepthMode(depthMode);\n context.setStencilMode(stencilMode);\n context.setColorMode(colorMode);\n context.setCullFace(cullFaceMode);\n\n // set variables used by the 3d functions defined in _prelude.vertex.glsl\n if (terrain) {\n context.activeTexture.set(gl.TEXTURE2);\n gl.bindTexture(gl.TEXTURE_2D, terrain.depthTexture);\n context.activeTexture.set(gl.TEXTURE3);\n gl.bindTexture(gl.TEXTURE_2D, terrain.texture);\n for (const name in this.terrainUniforms) {\n this.terrainUniforms[name].set(terrain[name]);\n }\n }\n\n for (const name in this.fixedUniforms) {\n this.fixedUniforms[name].set(uniformValues[name]);\n }\n\n if (configuration) {\n configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom as any)});\n }\n\n let primitiveSize = 0;\n switch (drawMode) {\n case gl.LINES:\n primitiveSize = 2;\n break;\n case gl.TRIANGLES:\n primitiveSize = 3;\n break;\n case gl.LINE_STRIP:\n primitiveSize = 1;\n break;\n }\n\n for (const segment of segments.get()) {\n const vaos = segment.vaos || (segment.vaos = {});\n const vao: VertexArrayObject = vaos[layerID] || (vaos[layerID] = new VertexArrayObject());\n\n vao.bind(\n context,\n this,\n layoutVertexBuffer,\n configuration ? configuration.getPaintVertexBuffers() : [],\n indexBuffer,\n segment.vertexOffset,\n dynamicLayoutBuffer,\n dynamicLayoutBuffer2,\n dynamicLayoutBuffer3\n );\n\n gl.drawElements(\n drawMode,\n segment.primitiveLength * primitiveSize,\n gl.UNSIGNED_SHORT,\n segment.primitiveOffset * primitiveSize * 2);\n }\n }\n}\n","import {\n Uniform1i,\n Uniform1f,\n Uniform4f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../../render/uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type TerrainPreludeUniformsType = {\n 'u_depth': Uniform1i;\n 'u_terrain': Uniform1i;\n 'u_terrain_dim': Uniform1f;\n 'u_terrain_matrix': UniformMatrix4f;\n 'u_terrain_unpack': Uniform4f;\n 'u_terrain_exaggeration': Uniform1f;\n};\n\nexport type TerrainUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texture': Uniform1i;\n 'u_ele_delta': Uniform1f;\n};\n\nexport type TerrainDepthUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ele_delta': Uniform1f;\n};\n\nexport type TerrainCoordsUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texture': Uniform1i;\n 'u_terrain_coords_id': Uniform1f;\n 'u_ele_delta': Uniform1f;\n};\n\nconst terrainPreludeUniforms = (context: Context, locations: UniformLocations): TerrainPreludeUniformsType => ({\n 'u_depth': new Uniform1i(context, locations.u_depth),\n 'u_terrain': new Uniform1i(context, locations.u_terrain),\n 'u_terrain_dim': new Uniform1f(context, locations.u_terrain_dim),\n 'u_terrain_matrix': new UniformMatrix4f(context, locations.u_terrain_matrix),\n 'u_terrain_unpack': new Uniform4f(context, locations.u_terrain_unpack),\n 'u_terrain_exaggeration': new Uniform1f(context, locations.u_terrain_exaggeration)\n});\n\nconst terrainUniforms = (context: Context, locations: UniformLocations): TerrainUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainDepthUniforms = (context: Context, locations: UniformLocations): TerrainDepthUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainCoordsUniforms = (context: Context, locations: UniformLocations): TerrainCoordsUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_terrain_coords_id': new Uniform1f(context, locations.u_terrain_coords_id),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainUniformValues = (\n matrix: mat4,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_texture': 0,\n 'u_ele_delta': eleDelta\n});\n\nconst terrainDepthUniformValues = (\n matrix: mat4,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_ele_delta': eleDelta\n});\n\nconst terrainCoordsUniformValues = (\n matrix: mat4,\n coordsId: number,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_terrain_coords_id': coordsId / 255,\n 'u_texture': 0,\n 'u_ele_delta': eleDelta\n});\n\nexport {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms, terrainPreludeUniforms, terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues};\n","import {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f\n} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Painter} from '../painter';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {CrossFaded} from '../../style/properties';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {UniformValues} from '../uniform_binding';\nimport type {Tile} from '../../source/tile';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\n\ntype BackgroundPatternUniformsType = {\n 'u_image': Uniform1i;\n 'u_pattern_tl_a': Uniform2f;\n 'u_pattern_br_a': Uniform2f;\n 'u_pattern_tl_b': Uniform2f;\n 'u_pattern_br_b': Uniform2f;\n 'u_texsize': Uniform2f;\n 'u_mix': Uniform1f;\n 'u_pattern_size_a': Uniform2f;\n 'u_pattern_size_b': Uniform2f;\n 'u_scale_a': Uniform1f;\n 'u_scale_b': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_tile_units_to_pixels': Uniform1f;\n};\n\nexport type PatternUniformsType = {\n // pattern uniforms:\n 'u_image': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n};\n\nfunction patternUniformValues(crossfade: CrossfadeParameters, painter: Painter, tile: Tile): UniformValues {\n\n const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom);\n\n const numTiles = Math.pow(2, tile.tileID.overscaledZ);\n const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;\n\n const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);\n const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;\n\n return {\n 'u_image': 0,\n 'u_texsize': tile.imageAtlasTexture.size,\n 'u_scale': [tileRatio, crossfade.fromScale, crossfade.toScale],\n 'u_fade': crossfade.t,\n // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.\n 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],\n 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]\n };\n}\n\nfunction bgPatternUniformValues(\n image: CrossFaded,\n crossfade: CrossfadeParameters,\n painter: Painter,\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n }\n): UniformValues {\n const imagePosA = painter.imageManager.getPattern(image.from.toString());\n const imagePosB = painter.imageManager.getPattern(image.to.toString());\n const {width, height} = painter.imageManager.getPixelSize();\n\n const numTiles = Math.pow(2, tile.tileID.overscaledZ);\n const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;\n\n const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);\n const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;\n\n return {\n 'u_image': 0,\n 'u_pattern_tl_a': (imagePosA as any).tl,\n 'u_pattern_br_a': (imagePosA as any).br,\n 'u_pattern_tl_b': (imagePosB as any).tl,\n 'u_pattern_br_b': (imagePosB as any).br,\n 'u_texsize': [width, height],\n 'u_mix': crossfade.t,\n 'u_pattern_size_a': (imagePosA as any).displaySize,\n 'u_pattern_size_b': (imagePosB as any).displaySize,\n 'u_scale_a': crossfade.fromScale,\n 'u_scale_b': crossfade.toScale,\n 'u_tile_units_to_pixels': 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom),\n // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.\n 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],\n 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]\n };\n}\nexport {bgPatternUniformValues, patternUniformValues};\n","import {patternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n UniformMatrix4f\n} from '../uniform_binding';\n\nimport {mat3, mat4, vec3} from 'gl-matrix';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {Painter} from '../painter';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {Tile} from '../../source/tile';\n\nexport type FillExtrusionUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_lightpos': Uniform3f;\n 'u_lightintensity': Uniform1f;\n 'u_lightcolor': Uniform3f;\n 'u_vertical_gradient': Uniform1f;\n 'u_opacity': Uniform1f;\n};\n\nexport type FillExtrusionPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_lightpos': Uniform3f;\n 'u_lightintensity': Uniform1f;\n 'u_lightcolor': Uniform3f;\n 'u_height_factor': Uniform1f;\n 'u_vertical_gradient': Uniform1f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n 'u_opacity': Uniform1f;\n};\n\nconst fillExtrusionUniforms = (context: Context, locations: UniformLocations): FillExtrusionUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_lightpos': new Uniform3f(context, locations.u_lightpos),\n 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity),\n 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor),\n 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst fillExtrusionPatternUniforms = (context: Context, locations: UniformLocations): FillExtrusionPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_lightpos': new Uniform3f(context, locations.u_lightpos),\n 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity),\n 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor),\n 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient),\n 'u_height_factor': new Uniform1f(context, locations.u_height_factor),\n // pattern uniforms\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst fillExtrusionUniformValues = (\n matrix: mat4,\n painter: Painter,\n shouldUseVerticalGradient: boolean,\n opacity: number\n): UniformValues => {\n const light = painter.style.light;\n const _lp = light.properties.get('position');\n const lightPos = [_lp.x, _lp.y, _lp.z] as vec3;\n const lightMat = mat3.create();\n if (light.properties.get('anchor') === 'viewport') {\n mat3.fromRotation(lightMat, -painter.transform.angle);\n }\n vec3.transformMat3(lightPos, lightPos, lightMat);\n\n const lightColor = light.properties.get('color');\n\n return {\n 'u_matrix': matrix,\n 'u_lightpos': lightPos,\n 'u_lightintensity': light.properties.get('intensity'),\n 'u_lightcolor': [lightColor.r, lightColor.g, lightColor.b],\n 'u_vertical_gradient': +shouldUseVerticalGradient,\n 'u_opacity': opacity\n };\n};\n\nconst fillExtrusionPatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n shouldUseVerticalGradient: boolean,\n opacity: number,\n coord: OverscaledTileID,\n crossfade: CrossfadeParameters,\n tile: Tile\n): UniformValues => {\n return extend(fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity),\n patternUniformValues(crossfade, painter, tile),\n {\n 'u_height_factor': -Math.pow(2, coord.overscaledZ) / tile.tileSize / 8\n });\n};\n\nexport {\n fillExtrusionUniforms,\n fillExtrusionPatternUniforms,\n fillExtrusionUniformValues,\n fillExtrusionPatternUniformValues\n};\n","import * as glMatrix from \"./common.js\";\n/**\n * 3x3 Matrix\n * @module mat3\n */\n\n/**\n * Creates a new identity mat3\n *\n * @returns {mat3} a new 3x3 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(9);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n }\n\n out[0] = 1;\n out[4] = 1;\n out[8] = 1;\n return out;\n}\n/**\n * Copies the upper-left 3x3 values into the given mat3.\n *\n * @param {mat3} out the receiving 3x3 matrix\n * @param {ReadonlyMat4} a the source 4x4 matrix\n * @returns {mat3} out\n */\n\nexport function fromMat4(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[4];\n out[4] = a[5];\n out[5] = a[6];\n out[6] = a[8];\n out[7] = a[9];\n out[8] = a[10];\n return out;\n}\n/**\n * Creates a new mat3 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat3} a matrix to clone\n * @returns {mat3} a new 3x3 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(9);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Copy the values from one mat3 to another\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Create a new mat3 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} A new mat3\n */\n\nexport function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n var out = new glMatrix.ARRAY_TYPE(9);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n/**\n * Set the components of a mat3 to the given values\n *\n * @param {mat3} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} out\n */\n\nexport function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n/**\n * Set a mat3 to the identity matrix\n *\n * @param {mat3} out the receiving matrix\n * @returns {mat3} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a12 = a[5];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a01;\n out[5] = a[7];\n out[6] = a02;\n out[7] = a12;\n } else {\n out[0] = a[0];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a[1];\n out[4] = a[4];\n out[5] = a[7];\n out[6] = a[2];\n out[7] = a[5];\n out[8] = a[8];\n }\n\n return out;\n}\n/**\n * Inverts a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n var b01 = a22 * a11 - a12 * a21;\n var b11 = -a22 * a10 + a12 * a20;\n var b21 = a21 * a10 - a11 * a20; // Calculate the determinant\n\n var det = a00 * b01 + a01 * b11 + a02 * b21;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = b01 * det;\n out[1] = (-a22 * a01 + a02 * a21) * det;\n out[2] = (a12 * a01 - a02 * a11) * det;\n out[3] = b11 * det;\n out[4] = (a22 * a00 - a02 * a20) * det;\n out[5] = (-a12 * a00 + a02 * a10) * det;\n out[6] = b21 * det;\n out[7] = (-a21 * a00 + a01 * a20) * det;\n out[8] = (a11 * a00 - a01 * a10) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n out[0] = a11 * a22 - a12 * a21;\n out[1] = a02 * a21 - a01 * a22;\n out[2] = a01 * a12 - a02 * a11;\n out[3] = a12 * a20 - a10 * a22;\n out[4] = a00 * a22 - a02 * a20;\n out[5] = a02 * a10 - a00 * a12;\n out[6] = a10 * a21 - a11 * a20;\n out[7] = a01 * a20 - a00 * a21;\n out[8] = a00 * a11 - a01 * a10;\n return out;\n}\n/**\n * Calculates the determinant of a mat3\n *\n * @param {ReadonlyMat3} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);\n}\n/**\n * Multiplies two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n var b00 = b[0],\n b01 = b[1],\n b02 = b[2];\n var b10 = b[3],\n b11 = b[4],\n b12 = b[5];\n var b20 = b[6],\n b21 = b[7],\n b22 = b[8];\n out[0] = b00 * a00 + b01 * a10 + b02 * a20;\n out[1] = b00 * a01 + b01 * a11 + b02 * a21;\n out[2] = b00 * a02 + b01 * a12 + b02 * a22;\n out[3] = b10 * a00 + b11 * a10 + b12 * a20;\n out[4] = b10 * a01 + b11 * a11 + b12 * a21;\n out[5] = b10 * a02 + b11 * a12 + b12 * a22;\n out[6] = b20 * a00 + b21 * a10 + b22 * a20;\n out[7] = b20 * a01 + b21 * a11 + b22 * a21;\n out[8] = b20 * a02 + b21 * a12 + b22 * a22;\n return out;\n}\n/**\n * Translate a mat3 by the given vector\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to translate\n * @param {ReadonlyVec2} v vector to translate by\n * @returns {mat3} out\n */\n\nexport function translate(out, a, v) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a10 = a[3],\n a11 = a[4],\n a12 = a[5],\n a20 = a[6],\n a21 = a[7],\n a22 = a[8],\n x = v[0],\n y = v[1];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a10;\n out[4] = a11;\n out[5] = a12;\n out[6] = x * a00 + y * a10 + a20;\n out[7] = x * a01 + y * a11 + a21;\n out[8] = x * a02 + y * a12 + a22;\n return out;\n}\n/**\n * Rotates a mat3 by the given angle\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\n\nexport function rotate(out, a, rad) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a10 = a[3],\n a11 = a[4],\n a12 = a[5],\n a20 = a[6],\n a21 = a[7],\n a22 = a[8],\n s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c * a00 + s * a10;\n out[1] = c * a01 + s * a11;\n out[2] = c * a02 + s * a12;\n out[3] = c * a10 - s * a00;\n out[4] = c * a11 - s * a01;\n out[5] = c * a12 - s * a02;\n out[6] = a20;\n out[7] = a21;\n out[8] = a22;\n return out;\n}\n/**\n * Scales the mat3 by the dimensions in the given vec2\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat3} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1];\n out[0] = x * a[0];\n out[1] = x * a[1];\n out[2] = x * a[2];\n out[3] = y * a[3];\n out[4] = y * a[4];\n out[5] = y * a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.translate(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Translation vector\n * @returns {mat3} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = v[0];\n out[7] = v[1];\n out[8] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.rotate(dest, dest, rad);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = -s;\n out[4] = c;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.scale(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat3} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = v[1];\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Copies the values from a mat2d into a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to copy\n * @returns {mat3} out\n **/\n\nexport function fromMat2d(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = 0;\n out[3] = a[2];\n out[4] = a[3];\n out[5] = 0;\n out[6] = a[4];\n out[7] = a[5];\n out[8] = 1;\n return out;\n}\n/**\n * Calculates a 3x3 matrix from the given quaternion\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat3} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[3] = yx - wz;\n out[6] = zx + wy;\n out[1] = yx + wz;\n out[4] = 1 - xx - zz;\n out[7] = zy - wx;\n out[2] = zx - wy;\n out[5] = zy + wx;\n out[8] = 1 - xx - yy;\n return out;\n}\n/**\n * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from\n *\n * @returns {mat3} out\n */\n\nexport function normalFromMat4(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n return out;\n}\n/**\n * Generates a 2D projection matrix with the given bounds\n *\n * @param {mat3} out mat3 frustum matrix will be written into\n * @param {number} width Width of your gl context\n * @param {number} height Height of gl context\n * @returns {mat3} out\n */\n\nexport function projection(out, width, height) {\n out[0] = 2 / width;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = -2 / height;\n out[5] = 0;\n out[6] = -1;\n out[7] = 1;\n out[8] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat3\n *\n * @param {ReadonlyMat3} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat3\n *\n * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);\n}\n/**\n * Adds two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat3} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n return out;\n}\n/**\n * Adds two mat3's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat3} out the receiving vector\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat3} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7],\n a8 = a[8];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));\n}\n/**\n * Alias for {@link mat3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat3.subtract}\n * @function\n */\n\nexport var sub = subtract;","import {patternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {Tile} from '../../source/tile';\nimport {mat4} from 'gl-matrix';\n\nexport type FillUniformsType = {\n 'u_matrix': UniformMatrix4f;\n};\n\nexport type FillOutlineUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n};\n\nexport type FillPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nexport type FillOutlinePatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nconst fillUniforms = (context: Context, locations: UniformLocations): FillUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst fillPatternUniforms = (context: Context, locations: UniformLocations): FillPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst fillOutlineUniforms = (context: Context, locations: UniformLocations): FillOutlineUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world)\n});\n\nconst fillOutlinePatternUniforms = (context: Context, locations: UniformLocations): FillOutlinePatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst fillUniformValues = (matrix: mat4): UniformValues => ({\n 'u_matrix': matrix\n});\n\nconst fillPatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n crossfade: CrossfadeParameters,\n tile: Tile\n): UniformValues => extend(\n fillUniformValues(matrix),\n patternUniformValues(crossfade, painter, tile)\n);\n\nconst fillOutlineUniformValues = (matrix: mat4, drawingBufferSize: [number, number]): UniformValues => ({\n 'u_matrix': matrix,\n 'u_world': drawingBufferSize\n});\n\nconst fillOutlinePatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n crossfade: CrossfadeParameters,\n tile: Tile,\n drawingBufferSize: [number, number]\n): UniformValues => extend(\n fillPatternUniformValues(matrix, painter, crossfade, tile),\n {\n 'u_world': drawingBufferSize\n }\n);\n\nexport {\n fillUniforms,\n fillPatternUniforms,\n fillOutlineUniforms,\n fillOutlinePatternUniforms,\n fillUniformValues,\n fillPatternUniformValues,\n fillOutlineUniformValues,\n fillOutlinePatternUniformValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {Tile} from '../../source/tile';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {Painter} from '../painter';\n\nexport type CircleUniformsType = {\n 'u_camera_to_center_distance': Uniform1f;\n 'u_scale_with_map': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_extrude_scale': Uniform2f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n};\n\nconst circleUniforms = (context: Context, locations: UniformLocations): CircleUniformsType => ({\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_scale_with_map': new Uniform1i(context, locations.u_scale_with_map),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst circleUniformValues = (\n painter: Painter,\n coord: OverscaledTileID,\n tile: Tile,\n layer: CircleStyleLayer\n): UniformValues => {\n const transform = painter.transform;\n\n let pitchWithMap: boolean, extrudeScale: [number, number];\n if (layer.paint.get('circle-pitch-alignment') === 'map') {\n const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom);\n pitchWithMap = true;\n extrudeScale = [pixelRatio, pixelRatio];\n } else {\n pitchWithMap = false;\n extrudeScale = transform.pixelsToGLUnits;\n }\n\n return {\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_scale_with_map': +(layer.paint.get('circle-pitch-scale') === 'map'),\n 'u_matrix': painter.translatePosMatrix(\n coord.posMatrix,\n tile,\n layer.paint.get('circle-translate'),\n layer.paint.get('circle-translate-anchor')),\n 'u_pitch_with_map': +(pitchWithMap),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_extrude_scale': extrudeScale\n };\n};\n\nexport {circleUniforms, circleUniformValues};\n","import {Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Transform} from '../../geo/transform';\nimport type {Tile} from '../../source/tile';\nimport {mat4} from 'gl-matrix';\n\nexport type CollisionUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pixels_to_tile_units': Uniform1f;\n 'u_extrude_scale': Uniform2f;\n 'u_overscale_factor': Uniform1f;\n};\n\nexport type CollisionCircleUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_inv_matrix': UniformMatrix4f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_viewport_size': Uniform2f;\n};\n\nconst collisionUniforms = (context: Context, locations: UniformLocations): CollisionUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pixels_to_tile_units': new Uniform1f(context, locations.u_pixels_to_tile_units),\n 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale),\n 'u_overscale_factor': new Uniform1f(context, locations.u_overscale_factor)\n});\n\nconst collisionCircleUniforms = (context: Context, locations: UniformLocations): CollisionCircleUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_inv_matrix': new UniformMatrix4f(context, locations.u_inv_matrix),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_viewport_size': new Uniform2f(context, locations.u_viewport_size)\n});\n\nconst collisionUniformValues = (matrix: mat4, transform: Transform, tile: Tile): UniformValues => {\n const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom);\n const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);\n const overscaleFactor = tile.tileID.overscaleFactor();\n return {\n 'u_matrix': matrix,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_pixels_to_tile_units': pixelRatio,\n 'u_extrude_scale': [transform.pixelsToGLUnits[0] / (pixelRatio * scale),\n transform.pixelsToGLUnits[1] / (pixelRatio * scale)],\n 'u_overscale_factor': overscaleFactor\n };\n};\n\nconst collisionCircleUniformValues = (matrix: mat4, invMatrix: mat4, transform: Transform): UniformValues => {\n return {\n 'u_matrix': matrix,\n 'u_inv_matrix': invMatrix,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_viewport_size': [transform.width, transform.height]\n };\n};\n\nexport {collisionUniforms, collisionUniformValues, collisionCircleUniforms, collisionCircleUniformValues};\n","import {UniformColor, UniformMatrix4f, Uniform1i, Uniform1f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {mat4} from 'gl-matrix';\n\nexport type DebugUniformsType = {\n 'u_color': UniformColor;\n 'u_matrix': UniformMatrix4f;\n 'u_overlay': Uniform1i;\n 'u_overlay_scale': Uniform1f;\n};\n\nconst debugUniforms = (context: Context, locations: UniformLocations): DebugUniformsType => ({\n 'u_color': new UniformColor(context, locations.u_color),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_overlay': new Uniform1i(context, locations.u_overlay),\n 'u_overlay_scale': new Uniform1f(context, locations.u_overlay_scale)\n});\n\nconst debugUniformValues = (matrix: mat4, color: Color, scaleRatio: number = 1): UniformValues => ({\n 'u_matrix': matrix,\n 'u_color': color,\n 'u_overlay': 0,\n 'u_overlay_scale': scaleRatio\n});\n\nexport {debugUniforms, debugUniformValues};\n","import {UniformMatrix4f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type ClippingMaskUniformsType = {\n 'u_matrix': UniformMatrix4f;\n};\n\nconst clippingMaskUniforms = (context: Context, locations: UniformLocations): ClippingMaskUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst clippingMaskUniformValues = (matrix: mat4): UniformValues => ({\n 'u_matrix': matrix\n});\n\nexport {clippingMaskUniforms, clippingMaskUniformValues};\n","import {mat4} from 'gl-matrix';\n\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {Tile} from '../../source/tile';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Painter} from '../painter';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport type HeatmapUniformsType = {\n 'u_extrude_scale': Uniform1f;\n 'u_intensity': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n};\n\nexport type HeatmapTextureUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n 'u_image': Uniform1i;\n 'u_color_ramp': Uniform1i;\n 'u_opacity': Uniform1f;\n};\n\nconst heatmapUniforms = (context: Context, locations: UniformLocations): HeatmapUniformsType => ({\n 'u_extrude_scale': new Uniform1f(context, locations.u_extrude_scale),\n 'u_intensity': new Uniform1f(context, locations.u_intensity),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst heatmapTextureUniforms = (context: Context, locations: UniformLocations): HeatmapTextureUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_color_ramp': new Uniform1i(context, locations.u_color_ramp),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst heatmapUniformValues = (matrix: mat4, tile: Tile, zoom: number, intensity: number): UniformValues => ({\n 'u_matrix': matrix,\n 'u_extrude_scale': pixelsToTileUnits(tile, 1, zoom),\n 'u_intensity': intensity\n});\n\nconst heatmapTextureUniformValues = (\n painter: Painter,\n layer: HeatmapStyleLayer,\n textureUnit: number,\n colorRampUnit: number\n): UniformValues => {\n const matrix = mat4.create();\n mat4.ortho(matrix, 0, painter.width, painter.height, 0, 0, 1);\n\n const gl = painter.context.gl;\n\n return {\n 'u_matrix': matrix,\n 'u_world': [gl.drawingBufferWidth, gl.drawingBufferHeight],\n 'u_image': textureUnit,\n 'u_color_ramp': colorRampUnit,\n 'u_opacity': layer.paint.get('heatmap-opacity')\n };\n};\n\nexport {\n heatmapUniforms,\n heatmapTextureUniforms,\n heatmapUniformValues,\n heatmapTextureUniformValues\n};\n","import {mat4} from 'gl-matrix';\n\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformColor,\n UniformMatrix4f,\n Uniform4f\n} from '../uniform_binding';\nimport {EXTENT} from '../../data/extent';\nimport {MercatorCoordinate} from '../../geo/mercator_coordinate';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Tile} from '../../source/tile';\nimport type {Painter} from '../painter';\nimport type {HillshadeStyleLayer} from '../../style/style_layer/hillshade_style_layer';\nimport type {DEMData} from '../../data/dem_data';\nimport type {OverscaledTileID} from '../../source/tile_id';\n\nexport type HillshadeUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_image': Uniform1i;\n 'u_latrange': Uniform2f;\n 'u_light': Uniform2f;\n 'u_shadow': UniformColor;\n 'u_highlight': UniformColor;\n 'u_accent': UniformColor;\n};\n\nexport type HillshadePrepareUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_image': Uniform1i;\n 'u_dimension': Uniform2f;\n 'u_zoom': Uniform1f;\n 'u_unpack': Uniform4f;\n};\n\nconst hillshadeUniforms = (context: Context, locations: UniformLocations): HillshadeUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_latrange': new Uniform2f(context, locations.u_latrange),\n 'u_light': new Uniform2f(context, locations.u_light),\n 'u_shadow': new UniformColor(context, locations.u_shadow),\n 'u_highlight': new UniformColor(context, locations.u_highlight),\n 'u_accent': new UniformColor(context, locations.u_accent)\n});\n\nconst hillshadePrepareUniforms = (context: Context, locations: UniformLocations): HillshadePrepareUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_dimension': new Uniform2f(context, locations.u_dimension),\n 'u_zoom': new Uniform1f(context, locations.u_zoom),\n 'u_unpack': new Uniform4f(context, locations.u_unpack)\n});\n\nconst hillshadeUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: HillshadeStyleLayer,\n coord: OverscaledTileID\n): UniformValues => {\n const shadow = layer.paint.get('hillshade-shadow-color');\n const highlight = layer.paint.get('hillshade-highlight-color');\n const accent = layer.paint.get('hillshade-accent-color');\n\n let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180);\n // modify azimuthal angle by map rotation if light is anchored at the viewport\n if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') {\n azimuthal -= painter.transform.angle;\n }\n const align = !painter.options.moving;\n return {\n 'u_matrix': coord ? coord.posMatrix : painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align),\n 'u_image': 0,\n 'u_latrange': getTileLatRange(painter, tile.tileID),\n 'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal],\n 'u_shadow': shadow,\n 'u_highlight': highlight,\n 'u_accent': accent\n };\n};\n\nconst hillshadeUniformPrepareValues = (tileID: OverscaledTileID, dem: DEMData): UniformValues => {\n\n const stride = dem.stride;\n const matrix = mat4.create();\n // Flip rendering at y axis.\n mat4.ortho(matrix, 0, EXTENT, -EXTENT, 0, 0, 1);\n mat4.translate(matrix, matrix, [0, -EXTENT, 0]);\n\n return {\n 'u_matrix': matrix,\n 'u_image': 1,\n 'u_dimension': [stride, stride],\n 'u_zoom': tileID.overscaledZ,\n 'u_unpack': dem.getUnpackVector()\n };\n};\n\nfunction getTileLatRange(painter: Painter, tileID: OverscaledTileID) {\n // for scaling the magnitude of a points slope by its latitude\n const tilesAtZoom = Math.pow(2, tileID.canonical.z);\n const y = tileID.canonical.y;\n return [\n new MercatorCoordinate(0, y / tilesAtZoom).toLngLat().lat,\n new MercatorCoordinate(0, (y + 1) / tilesAtZoom).toLngLat().lat];\n}\n\nexport {\n hillshadeUniforms,\n hillshadePrepareUniforms,\n hillshadeUniformValues,\n hillshadeUniformPrepareValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Transform} from '../../geo/transform';\nimport type {Tile} from '../../source/tile';\nimport type {CrossFaded} from '../../style/properties';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type {Painter} from '../painter';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport {OverscaledTileID} from '../../source/tile_id';\n\nexport type LineUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n};\n\nexport type LineGradientUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_image': Uniform1i;\n 'u_image_height': Uniform1f;\n};\n\nexport type LinePatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texsize': Uniform2f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_image': Uniform1i;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nexport type LineSDFUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_patternscale_a': Uniform2f;\n 'u_patternscale_b': Uniform2f;\n 'u_sdfgamma': Uniform1f;\n 'u_image': Uniform1i;\n 'u_tex_y_a': Uniform1f;\n 'u_tex_y_b': Uniform1f;\n 'u_mix': Uniform1f;\n};\n\nconst lineUniforms = (context: Context, locations: UniformLocations): LineUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels)\n});\n\nconst lineGradientUniforms = (context: Context, locations: UniformLocations): LineGradientUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_image_height': new Uniform1f(context, locations.u_image_height)\n});\n\nconst linePatternUniforms = (context: Context, locations: UniformLocations): LinePatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst lineSDFUniforms = (context: Context, locations: UniformLocations): LineSDFUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_patternscale_a': new Uniform2f(context, locations.u_patternscale_a),\n 'u_patternscale_b': new Uniform2f(context, locations.u_patternscale_b),\n 'u_sdfgamma': new Uniform1f(context, locations.u_sdfgamma),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_tex_y_a': new Uniform1f(context, locations.u_tex_y_a),\n 'u_tex_y_b': new Uniform1f(context, locations.u_tex_y_b),\n 'u_mix': new Uniform1f(context, locations.u_mix)\n});\n\nconst lineUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n\n return {\n 'u_matrix': calculateMatrix(painter, tile, layer, coord),\n 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_units_to_pixels': [\n 1 / transform.pixelsToGLUnits[0],\n 1 / transform.pixelsToGLUnits[1]\n ]\n };\n};\n\nconst lineGradientUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n imageHeight: number,\n coord: OverscaledTileID\n): UniformValues => {\n return extend(lineUniformValues(painter, tile, layer, coord), {\n 'u_image': 0,\n 'u_image_height': imageHeight,\n });\n};\n\nconst linePatternUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n crossfade: CrossfadeParameters,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n const tileZoomRatio = calculateTileRatio(tile, transform);\n return {\n 'u_matrix': calculateMatrix(painter, tile, layer, coord),\n 'u_texsize': tile.imageAtlasTexture.size,\n // camera zoom ratio\n 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_image': 0,\n 'u_scale': [tileZoomRatio, crossfade.fromScale, crossfade.toScale],\n 'u_fade': crossfade.t,\n 'u_units_to_pixels': [\n 1 / transform.pixelsToGLUnits[0],\n 1 / transform.pixelsToGLUnits[1]\n ]\n };\n};\n\nconst lineSDFUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n dasharray: CrossFaded>,\n crossfade: CrossfadeParameters,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n const lineAtlas = painter.lineAtlas;\n const tileRatio = calculateTileRatio(tile, transform);\n\n const round = layer.layout.get('line-cap') === 'round';\n\n const posA = lineAtlas.getDash(dasharray.from, round);\n const posB = lineAtlas.getDash(dasharray.to, round);\n\n const widthA = posA.width * crossfade.fromScale;\n const widthB = posB.width * crossfade.toScale;\n\n return extend(lineUniformValues(painter, tile, layer, coord), {\n 'u_patternscale_a': [tileRatio / widthA, -posA.height / 2],\n 'u_patternscale_b': [tileRatio / widthB, -posB.height / 2],\n 'u_sdfgamma': lineAtlas.width / (Math.min(widthA, widthB) * 256 * painter.pixelRatio) / 2,\n 'u_image': 0,\n 'u_tex_y_a': posA.y,\n 'u_tex_y_b': posB.y,\n 'u_mix': crossfade.t\n });\n};\n\nfunction calculateTileRatio(tile: Tile, transform: Transform) {\n return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom);\n}\n\nfunction calculateMatrix(painter: Painter, tile: Tile, layer: LineStyleLayer, coord: OverscaledTileID) {\n return painter.translatePosMatrix(\n coord ? coord.posMatrix : tile.tileID.posMatrix,\n tile,\n layer.paint.get('line-translate'),\n layer.paint.get('line-translate-anchor')\n );\n}\n\nexport {\n lineUniforms,\n lineGradientUniforms,\n linePatternUniforms,\n lineSDFUniforms,\n lineUniformValues,\n lineGradientUniformValues,\n linePatternUniformValues,\n lineSDFUniformValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {RasterStyleLayer} from '../../style/style_layer/raster_style_layer';\nimport {mat4} from 'gl-matrix';\n\nexport type RasterUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_tl_parent': Uniform2f;\n 'u_scale_parent': Uniform1f;\n 'u_buffer_scale': Uniform1f;\n 'u_fade_t': Uniform1f;\n 'u_opacity': Uniform1f;\n 'u_image0': Uniform1i;\n 'u_image1': Uniform1i;\n 'u_brightness_low': Uniform1f;\n 'u_brightness_high': Uniform1f;\n 'u_saturation_factor': Uniform1f;\n 'u_contrast_factor': Uniform1f;\n 'u_spin_weights': Uniform3f;\n};\n\nconst rasterUniforms = (context: Context, locations: UniformLocations): RasterUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_tl_parent': new Uniform2f(context, locations.u_tl_parent),\n 'u_scale_parent': new Uniform1f(context, locations.u_scale_parent),\n 'u_buffer_scale': new Uniform1f(context, locations.u_buffer_scale),\n 'u_fade_t': new Uniform1f(context, locations.u_fade_t),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_image0': new Uniform1i(context, locations.u_image0),\n 'u_image1': new Uniform1i(context, locations.u_image1),\n 'u_brightness_low': new Uniform1f(context, locations.u_brightness_low),\n 'u_brightness_high': new Uniform1f(context, locations.u_brightness_high),\n 'u_saturation_factor': new Uniform1f(context, locations.u_saturation_factor),\n 'u_contrast_factor': new Uniform1f(context, locations.u_contrast_factor),\n 'u_spin_weights': new Uniform3f(context, locations.u_spin_weights)\n});\n\nconst rasterUniformValues = (\n matrix: mat4,\n parentTL: [number, number],\n parentScaleBy: number,\n fade: {\n mix: number;\n opacity: number;\n },\n layer: RasterStyleLayer\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_tl_parent': parentTL,\n 'u_scale_parent': parentScaleBy,\n 'u_buffer_scale': 1,\n 'u_fade_t': fade.mix,\n 'u_opacity': fade.opacity * layer.paint.get('raster-opacity'),\n 'u_image0': 0,\n 'u_image1': 1,\n 'u_brightness_low': layer.paint.get('raster-brightness-min'),\n 'u_brightness_high': layer.paint.get('raster-brightness-max'),\n 'u_saturation_factor': saturationFactor(layer.paint.get('raster-saturation')),\n 'u_contrast_factor': contrastFactor(layer.paint.get('raster-contrast')),\n 'u_spin_weights': spinWeights(layer.paint.get('raster-hue-rotate'))\n});\n\nfunction spinWeights(angle) {\n angle *= Math.PI / 180;\n const s = Math.sin(angle);\n const c = Math.cos(angle);\n return [\n (2 * c + 1) / 3,\n (-Math.sqrt(3) * s - c + 1) / 3,\n (Math.sqrt(3) * s - c + 1) / 3\n ];\n}\n\nfunction contrastFactor(contrast) {\n return contrast > 0 ?\n 1 / (1 - contrast) :\n 1 + contrast;\n}\n\nfunction saturationFactor(saturation) {\n return saturation > 0 ?\n 1 - 1 / (1.001 - saturation) :\n -saturation;\n}\n\nexport {rasterUniforms, rasterUniformValues};\n","import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type SymbolIconUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texture': Uniform1i;\n};\n\nexport type SymbolSDFUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texture': Uniform1i;\n 'u_gamma_scale': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_is_halo': Uniform1i;\n};\n\nexport type symbolTextAndIconUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texsize_icon': Uniform2f;\n 'u_texture': Uniform1i;\n 'u_texture_icon': Uniform1i;\n 'u_gamma_scale': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_is_halo': Uniform1i;\n};\n\nconst symbolIconUniforms = (context: Context, locations: UniformLocations): SymbolIconUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texture': new Uniform1i(context, locations.u_texture)\n});\n\nconst symbolSDFUniforms = (context: Context, locations: UniformLocations): SymbolSDFUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_is_halo': new Uniform1i(context, locations.u_is_halo)\n});\n\nconst symbolTextAndIconUniforms = (context: Context, locations: UniformLocations): symbolTextAndIconUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texsize_icon': new Uniform2f(context, locations.u_texsize_icon),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_texture_icon': new Uniform1i(context, locations.u_texture_icon),\n 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_is_halo': new Uniform1i(context, locations.u_is_halo)\n});\n\nconst symbolIconUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n isText: boolean,\n texSize: [number, number]\n): UniformValues => {\n const transform = painter.transform;\n\n return {\n 'u_is_size_zoom_constant': +(functionType === 'constant' || functionType === 'source'),\n 'u_is_size_feature_constant': +(functionType === 'constant' || functionType === 'camera'),\n 'u_size_t': size ? size.uSizeT : 0,\n 'u_size': size ? size.uSize : 0,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_pitch': transform.pitch / 360 * 2 * Math.PI,\n 'u_rotate_symbol': +rotateInShader,\n 'u_aspect_ratio': transform.width / transform.height,\n 'u_fade_change': painter.options.fadeDuration ? painter.symbolFadeChange : 1,\n 'u_matrix': matrix,\n 'u_label_plane_matrix': labelPlaneMatrix,\n 'u_coord_matrix': glCoordMatrix,\n 'u_is_text': +isText,\n 'u_pitch_with_map': +pitchWithMap,\n 'u_texsize': texSize,\n 'u_texture': 0\n };\n};\n\nconst symbolSDFUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n isText: boolean,\n texSize: [number, number],\n isHalo: boolean\n): UniformValues => {\n const transform = painter.transform;\n\n return extend(symbolIconUniformValues(functionType, size,\n rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,\n glCoordMatrix, isText, texSize), {\n 'u_gamma_scale': (pitchWithMap ? Math.cos(transform._pitch) * transform.cameraToCenterDistance : 1),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_is_halo': +isHalo\n });\n};\n\nconst symbolTextAndIconUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n texSizeSDF: [number, number],\n texSizeIcon: [number, number]\n): UniformValues => {\n return extend(symbolSDFUniformValues(functionType, size,\n rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,\n glCoordMatrix, true, texSizeSDF, true), {\n 'u_texsize_icon': texSizeIcon,\n 'u_texture_icon': 1\n });\n};\n\nexport {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues, symbolTextAndIconUniformValues, symbolTextAndIconUniforms};\n","import {bgPatternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformColor,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {Color, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport type {CrossFaded} from '../../style/properties';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport {mat4} from 'gl-matrix';\n\nexport type BackgroundUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_opacity': Uniform1f;\n 'u_color': UniformColor;\n};\n\nexport type BackgroundPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_opacity': Uniform1f;\n // pattern uniforms:\n 'u_image': Uniform1i;\n 'u_pattern_tl_a': Uniform2f;\n 'u_pattern_br_a': Uniform2f;\n 'u_pattern_tl_b': Uniform2f;\n 'u_pattern_br_b': Uniform2f;\n 'u_texsize': Uniform2f;\n 'u_mix': Uniform1f;\n 'u_pattern_size_a': Uniform2f;\n 'u_pattern_size_b': Uniform2f;\n 'u_scale_a': Uniform1f;\n 'u_scale_b': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_tile_units_to_pixels': Uniform1f;\n};\n\nconst backgroundUniforms = (context: Context, locations: UniformLocations): BackgroundUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_color': new UniformColor(context, locations.u_color)\n});\n\nconst backgroundPatternUniforms = (context: Context, locations: UniformLocations): BackgroundPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_pattern_tl_a': new Uniform2f(context, locations.u_pattern_tl_a),\n 'u_pattern_br_a': new Uniform2f(context, locations.u_pattern_br_a),\n 'u_pattern_tl_b': new Uniform2f(context, locations.u_pattern_tl_b),\n 'u_pattern_br_b': new Uniform2f(context, locations.u_pattern_br_b),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_mix': new Uniform1f(context, locations.u_mix),\n 'u_pattern_size_a': new Uniform2f(context, locations.u_pattern_size_a),\n 'u_pattern_size_b': new Uniform2f(context, locations.u_pattern_size_b),\n 'u_scale_a': new Uniform1f(context, locations.u_scale_a),\n 'u_scale_b': new Uniform1f(context, locations.u_scale_b),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_tile_units_to_pixels': new Uniform1f(context, locations.u_tile_units_to_pixels)\n});\n\nconst backgroundUniformValues = (matrix: mat4, opacity: number, color: Color): UniformValues => ({\n 'u_matrix': matrix,\n 'u_opacity': opacity,\n 'u_color': color\n});\n\nconst backgroundPatternUniformValues = (\n matrix: mat4,\n opacity: number,\n painter: Painter,\n image: CrossFaded,\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n },\n crossfade: CrossfadeParameters\n): UniformValues => extend(\n bgPatternUniformValues(image, crossfade, painter, tile),\n {\n 'u_matrix': matrix,\n 'u_opacity': opacity\n }\n);\n\nexport {\n backgroundUniforms,\n backgroundPatternUniforms,\n backgroundUniformValues,\n backgroundPatternUniformValues\n};\n","import {fillExtrusionUniforms, fillExtrusionPatternUniforms} from './fill_extrusion_program';\nimport {fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms} from './fill_program';\nimport {circleUniforms} from './circle_program';\nimport {collisionUniforms, collisionCircleUniforms} from './collision_program';\nimport {debugUniforms} from './debug_program';\nimport {clippingMaskUniforms} from './clipping_mask_program';\nimport {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program';\nimport {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program';\nimport {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program';\nimport {rasterUniforms} from './raster_program';\nimport {symbolIconUniforms, symbolSDFUniforms, symbolTextAndIconUniforms} from './symbol_program';\nimport {backgroundUniforms, backgroundPatternUniforms} from './background_program';\nimport {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms} from './terrain_program';\n\nexport const programUniforms = {\n fillExtrusion: fillExtrusionUniforms,\n fillExtrusionPattern: fillExtrusionPatternUniforms,\n fill: fillUniforms,\n fillPattern: fillPatternUniforms,\n fillOutline: fillOutlineUniforms,\n fillOutlinePattern: fillOutlinePatternUniforms,\n circle: circleUniforms,\n collisionBox: collisionUniforms,\n collisionCircle: collisionCircleUniforms,\n debug: debugUniforms,\n clippingMask: clippingMaskUniforms,\n heatmap: heatmapUniforms,\n heatmapTexture: heatmapTextureUniforms,\n hillshade: hillshadeUniforms,\n hillshadePrepare: hillshadePrepareUniforms,\n line: lineUniforms,\n lineGradient: lineGradientUniforms,\n linePattern: linePatternUniforms,\n lineSDF: lineSDFUniforms,\n raster: rasterUniforms,\n symbolIcon: symbolIconUniforms,\n symbolSDF: symbolSDFUniforms,\n symbolTextAndIcon: symbolTextAndIconUniforms,\n background: backgroundUniforms,\n backgroundPattern: backgroundPatternUniforms,\n terrain: terrainUniforms,\n terrainDepth: terrainDepthUniforms,\n terrainCoords: terrainCoordsUniforms\n};\n","\nimport type {StructArray} from '../util/struct_array';\nimport type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';\nimport type {Context} from '../gl/context';\n\n/**\n * @internal\n * an index buffer class\n */\nexport class IndexBuffer {\n context: Context;\n buffer: WebGLBuffer;\n dynamicDraw: boolean;\n\n constructor(context: Context, array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) {\n this.context = context;\n const gl = context.gl;\n this.buffer = gl.createBuffer();\n this.dynamicDraw = Boolean(dynamicDraw);\n\n // The bound index buffer is part of vertex array object state. We don't want to\n // modify whatever VAO happens to be currently bound, so make sure the default\n // vertex array provided by the context is bound instead.\n this.context.unbindVAO();\n\n context.bindElementBuffer.set(this.buffer);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);\n\n if (!this.dynamicDraw) {\n delete array.arrayBuffer;\n }\n }\n\n bind() {\n this.context.bindElementBuffer.set(this.buffer);\n }\n\n updateData(array: StructArray) {\n const gl = this.context.gl;\n if (!this.dynamicDraw) throw new Error('Attempted to update data while not in dynamic mode.');\n // The right VAO will get this buffer re-bound later in VertexArrayObject#bind\n // See https://github.com/mapbox/mapbox-gl-js/issues/5620\n this.context.unbindVAO();\n this.bind();\n gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, array.arrayBuffer);\n }\n\n destroy() {\n const gl = this.context.gl;\n if (this.buffer) {\n gl.deleteBuffer(this.buffer);\n delete this.buffer;\n }\n }\n}\n","\nimport type {\n StructArray,\n StructArrayMember\n} from '../util/struct_array';\n\nimport type {Program} from '../render/program';\nimport type {Context} from '../gl/context';\n\n/**\n * An Enum for AttributeType\n */\nconst AttributeType = {\n Int8: 'BYTE',\n Uint8: 'UNSIGNED_BYTE',\n Int16: 'SHORT',\n Uint16: 'UNSIGNED_SHORT',\n Int32: 'INT',\n Uint32: 'UNSIGNED_INT',\n Float32: 'FLOAT'\n};\n\n/**\n * @internal\n * The `VertexBuffer` class turns a `StructArray` into a WebGL buffer. Each member of the StructArray's\n * Struct type is converted to a WebGL attribute.\n */\nexport class VertexBuffer {\n length: number;\n attributes: ReadonlyArray;\n itemSize: number;\n dynamicDraw: boolean;\n context: Context;\n buffer: WebGLBuffer;\n\n /**\n * @param dynamicDraw - Whether this buffer will be repeatedly updated.\n */\n constructor(context: Context, array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) {\n this.length = array.length;\n this.attributes = attributes;\n this.itemSize = array.bytesPerElement;\n this.dynamicDraw = dynamicDraw;\n\n this.context = context;\n const gl = context.gl;\n this.buffer = gl.createBuffer();\n context.bindVertexBuffer.set(this.buffer);\n gl.bufferData(gl.ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);\n\n if (!this.dynamicDraw) {\n delete array.arrayBuffer;\n }\n }\n\n bind() {\n this.context.bindVertexBuffer.set(this.buffer);\n }\n\n updateData(array: StructArray) {\n if (array.length !== this.length) throw new Error(`Length of new data is ${array.length}, which doesn't match current length of ${this.length}`);\n const gl = this.context.gl;\n this.bind();\n gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer);\n }\n\n enableAttributes(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program) {\n for (let j = 0; j < this.attributes.length; j++) {\n const member = this.attributes[j];\n const attribIndex: number | void = program.attributes[member.name];\n if (attribIndex !== undefined) {\n gl.enableVertexAttribArray(attribIndex);\n }\n }\n }\n\n /**\n * Set the attribute pointers in a WebGL context\n * @param gl - The WebGL context\n * @param program - The active WebGL program\n * @param vertexOffset - Index of the starting vertex of the segment\n */\n setVertexAttribPointers(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program, vertexOffset?: number | null) {\n for (let j = 0; j < this.attributes.length; j++) {\n const member = this.attributes[j];\n const attribIndex: number | void = program.attributes[member.name];\n\n if (attribIndex !== undefined) {\n gl.vertexAttribPointer(\n attribIndex,\n member.components,\n (gl as any)[AttributeType[member.type]],\n false,\n this.itemSize,\n member.offset + (this.itemSize * (vertexOffset || 0))\n );\n }\n }\n }\n\n /**\n * Destroy the GL buffer bound to the given WebGL context\n */\n destroy() {\n const gl = this.context.gl;\n if (this.buffer) {\n gl.deleteBuffer(this.buffer);\n delete this.buffer;\n }\n }\n}\n","const cache = new WeakMap();\nexport function isWebGL2(\n gl: WebGLRenderingContext | WebGL2RenderingContext\n): gl is WebGL2RenderingContext {\n if (cache.has(gl)) {\n return cache.get(gl);\n } else {\n const value = gl.getParameter(gl.VERSION)?.startsWith('WebGL 2.0');\n cache.set(gl, value);\n return value;\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {isWebGL2} from './webgl2';\n\nimport type {Context} from './context';\nimport type {\n BlendFuncType,\n BlendEquationType,\n ColorMaskType,\n DepthRangeType,\n DepthMaskType,\n StencilFuncType,\n StencilOpType,\n DepthFuncType,\n TextureUnitType,\n ViewportType,\n CullFaceModeType,\n FrontFaceType,\n} from './types';\n\nexport interface IValue {\n current: T;\n default: T;\n dirty: boolean;\n get(): T;\n setDefault(): void;\n set(value: T): void;\n}\n\nclass BaseValue implements IValue {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n current: T;\n default: T;\n dirty: boolean;\n\n constructor(context: Context) {\n this.gl = context.gl;\n this.default = this.getDefault();\n this.current = this.default;\n this.dirty = false;\n }\n\n get(): T {\n return this.current;\n }\n set(value: T) { // eslint-disable-line\n // overridden in child classes;\n }\n\n getDefault(): T {\n return this.default; // overriden in child classes\n }\n setDefault() {\n this.set(this.default);\n }\n}\n\nexport class ClearColor extends BaseValue {\n getDefault(): Color {\n return Color.transparent;\n }\n set(v: Color) {\n const c = this.current;\n if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return;\n this.gl.clearColor(v.r, v.g, v.b, v.a);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ClearDepth extends BaseValue {\n getDefault(): number {\n return 1;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n this.gl.clearDepth(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ClearStencil extends BaseValue {\n getDefault(): number {\n return 0;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n this.gl.clearStencil(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ColorMask extends BaseValue {\n getDefault(): ColorMaskType {\n return [true, true, true, true];\n }\n set(v: ColorMaskType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return;\n this.gl.colorMask(v[0], v[1], v[2], v[3]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthMask extends BaseValue {\n getDefault(): DepthMaskType {\n return true;\n }\n set(v: DepthMaskType): void {\n if (v === this.current && !this.dirty) return;\n this.gl.depthMask(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilMask extends BaseValue {\n getDefault(): number {\n return 0xFF;\n }\n set(v: number): void {\n if (v === this.current && !this.dirty) return;\n this.gl.stencilMask(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilFunc extends BaseValue {\n getDefault(): StencilFuncType {\n return {\n func: this.gl.ALWAYS,\n ref: 0,\n mask: 0xFF\n };\n }\n set(v: StencilFuncType): void {\n const c = this.current;\n if (v.func === c.func && v.ref === c.ref && v.mask === c.mask && !this.dirty) return;\n this.gl.stencilFunc(v.func, v.ref, v.mask);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilOp extends BaseValue {\n getDefault(): StencilOpType {\n const gl = this.gl;\n return [gl.KEEP, gl.KEEP, gl.KEEP];\n }\n set(v: StencilOpType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && !this.dirty) return;\n this.gl.stencilOp(v[0], v[1], v[2]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilTest extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.STENCIL_TEST);\n } else {\n gl.disable(gl.STENCIL_TEST);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthRange extends BaseValue {\n getDefault(): DepthRangeType {\n return [0, 1];\n }\n set(v: DepthRangeType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return;\n this.gl.depthRange(v[0], v[1]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthTest extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.DEPTH_TEST);\n } else {\n gl.disable(gl.DEPTH_TEST);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthFunc extends BaseValue {\n getDefault(): DepthFuncType {\n return this.gl.LESS;\n }\n set(v: DepthFuncType) {\n if (v === this.current && !this.dirty) return;\n this.gl.depthFunc(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class Blend extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.BLEND);\n } else {\n gl.disable(gl.BLEND);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendFunc extends BaseValue {\n getDefault(): BlendFuncType {\n const gl = this.gl;\n return [gl.ONE, gl.ZERO];\n }\n set(v: BlendFuncType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return;\n this.gl.blendFunc(v[0], v[1]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendColor extends BaseValue {\n getDefault(): Color {\n return Color.transparent;\n }\n set(v: Color) {\n const c = this.current;\n if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return;\n this.gl.blendColor(v.r, v.g, v.b, v.a);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendEquation extends BaseValue {\n getDefault(): BlendEquationType {\n return this.gl.FUNC_ADD;\n }\n set(v: BlendEquationType) {\n if (v === this.current && !this.dirty) return;\n this.gl.blendEquation(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class CullFace extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.CULL_FACE);\n } else {\n gl.disable(gl.CULL_FACE);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class CullFaceSide extends BaseValue {\n getDefault(): CullFaceModeType {\n return this.gl.BACK;\n }\n set(v: CullFaceModeType) {\n if (v === this.current && !this.dirty) return;\n this.gl.cullFace(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class FrontFace extends BaseValue {\n getDefault(): FrontFaceType {\n return this.gl.CCW;\n }\n set(v: FrontFaceType) {\n if (v === this.current && !this.dirty) return;\n this.gl.frontFace(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ProgramValue extends BaseValue {\n getDefault(): WebGLProgram {\n return null;\n }\n set(v?: WebGLProgram | null) {\n if (v === this.current && !this.dirty) return;\n this.gl.useProgram(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ActiveTextureUnit extends BaseValue {\n getDefault(): TextureUnitType {\n return this.gl.TEXTURE0;\n }\n set(v: TextureUnitType) {\n if (v === this.current && !this.dirty) return;\n this.gl.activeTexture(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class Viewport extends BaseValue {\n getDefault(): ViewportType {\n const gl = this.gl;\n return [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight];\n }\n set(v: ViewportType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return;\n this.gl.viewport(v[0], v[1], v[2], v[3]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindFramebuffer extends BaseValue {\n getDefault(): WebGLFramebuffer {\n return null;\n }\n set(v?: WebGLFramebuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindFramebuffer(gl.FRAMEBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindRenderbuffer extends BaseValue {\n getDefault(): WebGLRenderbuffer {\n return null;\n }\n set(v?: WebGLRenderbuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindRenderbuffer(gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindTexture extends BaseValue {\n getDefault(): WebGLTexture {\n return null;\n }\n set(v?: WebGLTexture | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindVertexBuffer extends BaseValue {\n getDefault(): WebGLBuffer {\n return null;\n }\n set(v?: WebGLBuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindBuffer(gl.ARRAY_BUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindElementBuffer extends BaseValue {\n getDefault(): WebGLBuffer {\n return null;\n }\n set(v?: WebGLBuffer | null) {\n // Always rebind\n const gl = this.gl;\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindVertexArray extends BaseValue {\n getDefault(): WebGLVertexArrayObject | null {\n return null;\n }\n set(v: WebGLVertexArrayObject | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n\n if (isWebGL2(gl)) {\n gl.bindVertexArray(v);\n } else {\n gl.getExtension('OES_vertex_array_object')?.bindVertexArrayOES(v);\n }\n\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpack extends BaseValue {\n getDefault(): number {\n return 4;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpackPremultiplyAlpha extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean): void {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, ((v as any)));\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpackFlipY extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean): void {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, ((v as any)));\n this.current = v;\n this.dirty = false;\n }\n}\n\nclass FramebufferAttachment extends BaseValue {\n parent: WebGLFramebuffer;\n context: Context;\n\n constructor(context: Context, parent: WebGLFramebuffer) {\n super(context);\n this.context = context;\n this.parent = parent;\n }\n getDefault() {\n return null;\n }\n}\n\nexport class ColorAttachment extends FramebufferAttachment {\n setDirty() {\n this.dirty = true;\n }\n set(v?: WebGLTexture | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a renderbuffer to the color\n // attachment point, but thus far MBGL only uses textures for color\n const gl = this.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, v, 0);\n\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthAttachment extends FramebufferAttachment {\n set(v?: WebGLRenderbuffer | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a texture to the depth attachment\n // point, but thus far MBGL only uses renderbuffers for depth\n const gl = this.gl;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthStencilAttachment extends FramebufferAttachment {\n set(v?: WebGLRenderbuffer | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a texture to the depth attachment\n // point, but thus far MBGL only uses renderbuffers for depth\n const gl = this.gl;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n","import {ColorAttachment, DepthAttachment, DepthStencilAttachment} from './value';\n\nimport type {Context} from './context';\n\n/**\n * @internal\n * A framebuffer holder object\n */\nexport class Framebuffer {\n context: Context;\n width: number;\n height: number;\n framebuffer: WebGLFramebuffer;\n colorAttachment: ColorAttachment;\n depthAttachment: DepthAttachment;\n\n constructor(context: Context, width: number, height: number, hasDepth: boolean, hasStencil: boolean) {\n this.context = context;\n this.width = width;\n this.height = height;\n const gl = context.gl;\n const fbo = this.framebuffer = gl.createFramebuffer();\n\n this.colorAttachment = new ColorAttachment(context, fbo);\n if (hasDepth) {\n this.depthAttachment = hasStencil ? new DepthStencilAttachment(context, fbo) : new DepthAttachment(context, fbo);\n } else if (hasStencil) {\n throw new Error('Stencil cannot be setted without depth');\n }\n if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error('Framebuffer is not complete');\n }\n }\n\n destroy() {\n const gl = this.context.gl;\n\n const texture = this.colorAttachment.get();\n if (texture) gl.deleteTexture(texture);\n\n if (this.depthAttachment) {\n const renderbuffer = this.depthAttachment.get();\n if (renderbuffer) gl.deleteRenderbuffer(renderbuffer);\n }\n\n gl.deleteFramebuffer(this.framebuffer);\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BlendFuncType, ColorMaskType} from './types';\n\nconst ZERO = 0x0000;\nconst ONE = 0x0001;\nconst ONE_MINUS_SRC_ALPHA = 0x0303;\n\nexport class ColorMode {\n blendFunction: BlendFuncType;\n blendColor: Color;\n mask: ColorMaskType;\n\n constructor(blendFunction: BlendFuncType, blendColor: Color, mask: ColorMaskType) {\n this.blendFunction = blendFunction;\n this.blendColor = blendColor;\n this.mask = mask;\n }\n\n static Replace: BlendFuncType;\n\n static disabled: Readonly;\n static unblended: Readonly;\n static alphaBlended: Readonly;\n}\n\nColorMode.Replace = [ONE, ZERO];\n\nColorMode.disabled = new ColorMode(ColorMode.Replace, Color.transparent, [false, false, false, false]);\nColorMode.unblended = new ColorMode(ColorMode.Replace, Color.transparent, [true, true, true, true]);\nColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [true, true, true, true]);\n","import {IndexBuffer} from './index_buffer';\n\nimport {VertexBuffer} from './vertex_buffer';\nimport {Framebuffer} from './framebuffer';\nimport {DepthMode} from './depth_mode';\nimport {StencilMode} from './stencil_mode';\nimport {ColorMode} from './color_mode';\nimport {CullFaceMode} from './cull_face_mode';\nimport {deepEqual} from '../util/util';\nimport {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, BlendEquation, CullFace, CullFaceSide, FrontFace, ProgramValue, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArray, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha, PixelStoreUnpackFlipY} from './value';\n\nimport type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';\nimport type {\n StructArray,\n StructArrayMember\n} from '../util/struct_array';\nimport type {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {isWebGL2} from './webgl2';\n\ntype ClearArgs = {\n color?: Color;\n depth?: number;\n stencil?: number;\n};\n\n/**\n * @internal\n * A webgl wrapper class to allow injection, mocking and abstaction\n */\nexport class Context {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n\n currentNumAttributes: number;\n maxTextureSize: number;\n\n clearColor: ClearColor;\n clearDepth: ClearDepth;\n clearStencil: ClearStencil;\n colorMask: ColorMask;\n depthMask: DepthMask;\n stencilMask: StencilMask;\n stencilFunc: StencilFunc;\n stencilOp: StencilOp;\n stencilTest: StencilTest;\n depthRange: DepthRange;\n depthTest: DepthTest;\n depthFunc: DepthFunc;\n blend: Blend;\n blendFunc: BlendFunc;\n blendColor: BlendColor;\n blendEquation: BlendEquation;\n cullFace: CullFace;\n cullFaceSide: CullFaceSide;\n frontFace: FrontFace;\n program: ProgramValue;\n activeTexture: ActiveTextureUnit;\n viewport: Viewport;\n bindFramebuffer: BindFramebuffer;\n bindRenderbuffer: BindRenderbuffer;\n bindTexture: BindTexture;\n bindVertexBuffer: BindVertexBuffer;\n bindElementBuffer: BindElementBuffer;\n bindVertexArray: BindVertexArray;\n pixelStoreUnpack: PixelStoreUnpack;\n pixelStoreUnpackPremultiplyAlpha: PixelStoreUnpackPremultiplyAlpha;\n pixelStoreUnpackFlipY: PixelStoreUnpackFlipY;\n\n // eslint-disable-next-line camelcase\n extTextureFilterAnisotropic: EXT_texture_filter_anisotropic | null;\n extTextureFilterAnisotropicMax?: GLfloat;\n HALF_FLOAT?: GLenum;\n RGBA16F?: GLenum;\n RGB16F?: GLenum;\n\n constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) {\n this.gl = gl;\n this.clearColor = new ClearColor(this);\n this.clearDepth = new ClearDepth(this);\n this.clearStencil = new ClearStencil(this);\n this.colorMask = new ColorMask(this);\n this.depthMask = new DepthMask(this);\n this.stencilMask = new StencilMask(this);\n this.stencilFunc = new StencilFunc(this);\n this.stencilOp = new StencilOp(this);\n this.stencilTest = new StencilTest(this);\n this.depthRange = new DepthRange(this);\n this.depthTest = new DepthTest(this);\n this.depthFunc = new DepthFunc(this);\n this.blend = new Blend(this);\n this.blendFunc = new BlendFunc(this);\n this.blendColor = new BlendColor(this);\n this.blendEquation = new BlendEquation(this);\n this.cullFace = new CullFace(this);\n this.cullFaceSide = new CullFaceSide(this);\n this.frontFace = new FrontFace(this);\n this.program = new ProgramValue(this);\n this.activeTexture = new ActiveTextureUnit(this);\n this.viewport = new Viewport(this);\n this.bindFramebuffer = new BindFramebuffer(this);\n this.bindRenderbuffer = new BindRenderbuffer(this);\n this.bindTexture = new BindTexture(this);\n this.bindVertexBuffer = new BindVertexBuffer(this);\n this.bindElementBuffer = new BindElementBuffer(this);\n this.bindVertexArray = new BindVertexArray(this);\n this.pixelStoreUnpack = new PixelStoreUnpack(this);\n this.pixelStoreUnpackPremultiplyAlpha = new PixelStoreUnpackPremultiplyAlpha(this);\n this.pixelStoreUnpackFlipY = new PixelStoreUnpackFlipY(this);\n\n this.extTextureFilterAnisotropic = (\n gl.getExtension('EXT_texture_filter_anisotropic') ||\n gl.getExtension('MOZ_EXT_texture_filter_anisotropic') ||\n gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')\n );\n\n if (this.extTextureFilterAnisotropic) {\n this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\n }\n\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n\n if (isWebGL2(gl)) {\n this.HALF_FLOAT = gl.HALF_FLOAT;\n const extColorBufferHalfFloat = gl.getExtension('EXT_color_buffer_half_float');\n this.RGBA16F = gl.RGBA16F ?? extColorBufferHalfFloat?.RGBA16F_EXT;\n this.RGB16F = gl.RGB16F ?? extColorBufferHalfFloat?.RGB16F_EXT;\n gl.getExtension('EXT_color_buffer_float');\n } else {\n gl.getExtension('EXT_color_buffer_half_float');\n gl.getExtension('OES_texture_half_float_linear');\n const extTextureHalfFloat = gl.getExtension('OES_texture_half_float');\n this.HALF_FLOAT = extTextureHalfFloat?.HALF_FLOAT_OES;\n }\n }\n\n setDefault() {\n this.unbindVAO();\n\n this.clearColor.setDefault();\n this.clearDepth.setDefault();\n this.clearStencil.setDefault();\n this.colorMask.setDefault();\n this.depthMask.setDefault();\n this.stencilMask.setDefault();\n this.stencilFunc.setDefault();\n this.stencilOp.setDefault();\n this.stencilTest.setDefault();\n this.depthRange.setDefault();\n this.depthTest.setDefault();\n this.depthFunc.setDefault();\n this.blend.setDefault();\n this.blendFunc.setDefault();\n this.blendColor.setDefault();\n this.blendEquation.setDefault();\n this.cullFace.setDefault();\n this.cullFaceSide.setDefault();\n this.frontFace.setDefault();\n this.program.setDefault();\n this.activeTexture.setDefault();\n this.bindFramebuffer.setDefault();\n this.pixelStoreUnpack.setDefault();\n this.pixelStoreUnpackPremultiplyAlpha.setDefault();\n this.pixelStoreUnpackFlipY.setDefault();\n }\n\n setDirty() {\n this.clearColor.dirty = true;\n this.clearDepth.dirty = true;\n this.clearStencil.dirty = true;\n this.colorMask.dirty = true;\n this.depthMask.dirty = true;\n this.stencilMask.dirty = true;\n this.stencilFunc.dirty = true;\n this.stencilOp.dirty = true;\n this.stencilTest.dirty = true;\n this.depthRange.dirty = true;\n this.depthTest.dirty = true;\n this.depthFunc.dirty = true;\n this.blend.dirty = true;\n this.blendFunc.dirty = true;\n this.blendColor.dirty = true;\n this.blendEquation.dirty = true;\n this.cullFace.dirty = true;\n this.cullFaceSide.dirty = true;\n this.frontFace.dirty = true;\n this.program.dirty = true;\n this.activeTexture.dirty = true;\n this.viewport.dirty = true;\n this.bindFramebuffer.dirty = true;\n this.bindRenderbuffer.dirty = true;\n this.bindTexture.dirty = true;\n this.bindVertexBuffer.dirty = true;\n this.bindElementBuffer.dirty = true;\n this.bindVertexArray.dirty = true;\n this.pixelStoreUnpack.dirty = true;\n this.pixelStoreUnpackPremultiplyAlpha.dirty = true;\n this.pixelStoreUnpackFlipY.dirty = true;\n }\n\n createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) {\n return new IndexBuffer(this, array, dynamicDraw);\n }\n\n createVertexBuffer(array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) {\n return new VertexBuffer(this, array, attributes, dynamicDraw);\n }\n\n createRenderbuffer(storageFormat: number, width: number, height: number) {\n const gl = this.gl;\n\n const rbo = gl.createRenderbuffer();\n this.bindRenderbuffer.set(rbo);\n gl.renderbufferStorage(gl.RENDERBUFFER, storageFormat, width, height);\n this.bindRenderbuffer.set(null);\n\n return rbo;\n }\n\n createFramebuffer(width: number, height: number, hasDepth: boolean, hasStencil: boolean) {\n return new Framebuffer(this, width, height, hasDepth, hasStencil);\n }\n\n clear({\n color,\n depth,\n stencil\n }: ClearArgs) {\n const gl = this.gl;\n let mask = 0;\n\n if (color) {\n mask |= gl.COLOR_BUFFER_BIT;\n this.clearColor.set(color);\n this.colorMask.set([true, true, true, true]);\n }\n\n if (typeof depth !== 'undefined') {\n mask |= gl.DEPTH_BUFFER_BIT;\n\n // Workaround for platforms where clearDepth doesn't seem to work\n // without resetting the depthRange. See https://github.com/mapbox/mapbox-gl-js/issues/3437\n this.depthRange.set([0, 1]);\n\n this.clearDepth.set(depth);\n this.depthMask.set(true);\n }\n\n if (typeof stencil !== 'undefined') {\n mask |= gl.STENCIL_BUFFER_BIT;\n this.clearStencil.set(stencil);\n this.stencilMask.set(0xFF);\n }\n\n gl.clear(mask);\n }\n\n setCullFace(cullFaceMode: Readonly) {\n if (cullFaceMode.enable === false) {\n this.cullFace.set(false);\n } else {\n this.cullFace.set(true);\n this.cullFaceSide.set(cullFaceMode.mode);\n this.frontFace.set(cullFaceMode.frontFace);\n }\n }\n\n setDepthMode(depthMode: Readonly) {\n if (depthMode.func === this.gl.ALWAYS && !depthMode.mask) {\n this.depthTest.set(false);\n } else {\n this.depthTest.set(true);\n this.depthFunc.set(depthMode.func);\n this.depthMask.set(depthMode.mask);\n this.depthRange.set(depthMode.range);\n }\n }\n\n setStencilMode(stencilMode: Readonly) {\n if (stencilMode.test.func === this.gl.ALWAYS && !stencilMode.mask) {\n this.stencilTest.set(false);\n } else {\n this.stencilTest.set(true);\n this.stencilMask.set(stencilMode.mask);\n this.stencilOp.set([stencilMode.fail, stencilMode.depthFail, stencilMode.pass]);\n this.stencilFunc.set({\n func: stencilMode.test.func,\n ref: stencilMode.ref,\n mask: stencilMode.test.mask\n });\n }\n }\n\n setColorMode(colorMode: Readonly) {\n if (deepEqual(colorMode.blendFunction, ColorMode.Replace)) {\n this.blend.set(false);\n } else {\n this.blend.set(true);\n this.blendFunc.set(colorMode.blendFunction);\n this.blendColor.set(colorMode.blendColor);\n }\n\n this.colorMask.set(colorMode.mask);\n }\n\n createVertexArray(): WebGLVertexArrayObject | undefined {\n if (isWebGL2(this.gl))\n return this.gl.createVertexArray();\n return this.gl.getExtension('OES_vertex_array_object')?.createVertexArrayOES();\n }\n\n deleteVertexArray(x: WebGLVertexArrayObject | undefined) {\n if (isWebGL2(this.gl))\n return this.gl.deleteVertexArray(x);\n return this.gl.getExtension('OES_vertex_array_object')?.deleteVertexArrayOES(x);\n }\n\n unbindVAO() {\n // Unbinding the VAO prevents other things (custom layers, new buffer creation) from\n // unintentionally changing the state of the last VAO used.\n this.bindVertexArray.set(null);\n }\n}\n","import type {DepthFuncType, DepthMaskType, DepthRangeType} from './types';\n\nconst ALWAYS = 0x0207;\n\nexport class DepthMode {\n func: DepthFuncType;\n mask: DepthMaskType;\n range: DepthRangeType;\n\n // DepthMask enums\n static ReadOnly: boolean;\n static ReadWrite: boolean;\n\n constructor(depthFunc: DepthFuncType, depthMask: DepthMaskType, depthRange: DepthRangeType) {\n this.func = depthFunc;\n this.mask = depthMask;\n this.range = depthRange;\n }\n\n static disabled: Readonly;\n}\n\nDepthMode.ReadOnly = false;\nDepthMode.ReadWrite = true;\n\nDepthMode.disabled = new DepthMode(ALWAYS, DepthMode.ReadOnly, [0, 1]);\n","import type {StencilOpConstant, StencilTestGL} from './types';\n\nconst ALWAYS = 0x0207;\nconst KEEP = 0x1E00;\n\nexport class StencilMode {\n test: StencilTestGL;\n ref: number;\n mask: number;\n fail: StencilOpConstant;\n depthFail: StencilOpConstant;\n pass: StencilOpConstant;\n\n constructor(test: StencilTestGL, ref: number, mask: number, fail: StencilOpConstant,\n depthFail: StencilOpConstant, pass: StencilOpConstant) {\n this.test = test;\n this.ref = ref;\n this.mask = mask;\n this.fail = fail;\n this.depthFail = depthFail;\n this.pass = pass;\n }\n\n static disabled: Readonly;\n}\n\nStencilMode.disabled = new StencilMode({func: ALWAYS, mask: 0}, 0, 0, KEEP, KEEP, KEEP);\n","import type {CullFaceModeType, FrontFaceType} from './types';\n\nconst BACK = 0x0405;\nconst CCW = 0x0901;\n\nexport class CullFaceMode {\n enable: boolean;\n mode: CullFaceModeType;\n frontFace: FrontFaceType;\n\n constructor(enable: boolean, mode: CullFaceModeType, frontFace: FrontFaceType) {\n this.enable = enable;\n this.mode = mode;\n this.frontFace = frontFace;\n }\n\n static disabled: Readonly;\n static backCCW: Readonly;\n}\n\nCullFaceMode.disabled = new CullFaceMode(false, BACK, CCW);\nCullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW);\n","import type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {collisionUniformValues, collisionCircleUniformValues} from './program/collision_program';\n\nimport {QuadTriangleArray, CollisionCircleLayoutArray} from '../data/array_types.g';\nimport {collisionCircleLayout} from '../data/bucket/symbol_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {mat4} from 'gl-matrix';\nimport {VertexBuffer} from '../gl/vertex_buffer';\nimport {IndexBuffer} from '../gl/index_buffer';\n\ntype TileBatch = {\n circleArray: Array;\n circleOffset: number;\n transform: mat4;\n invTransform: mat4;\n coord: OverscaledTileID;\n};\n\nlet quadTriangles: QuadTriangleArray;\n\nexport function drawCollisionDebug(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array, translate: [number, number], translateAnchor: 'map' | 'viewport', isText: boolean) {\n const context = painter.context;\n const gl = context.gl;\n const program = painter.useProgram('collisionBox');\n const tileBatches: Array = [];\n let circleCount = 0;\n let circleOffset = 0;\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n const tile = sourceCache.getTile(coord);\n const bucket: SymbolBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n let posMatrix = coord.posMatrix;\n if (translate[0] !== 0 || translate[1] !== 0) {\n posMatrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor);\n }\n const buffers = isText ? bucket.textCollisionBox : bucket.iconCollisionBox;\n // Get collision circle data of this bucket\n const circleArray: Array = bucket.collisionCircleArray;\n if (circleArray.length > 0) {\n // We need to know the projection matrix that was used for projecting collision circles to the screen.\n // This might vary between buckets as the symbol placement is a continuous process. This matrix is\n // required for transforming points from previous screen space to the current one\n const invTransform = mat4.create();\n const transform = posMatrix;\n\n mat4.mul(invTransform, bucket.placementInvProjMatrix, painter.transform.glCoordMatrix);\n mat4.mul(invTransform, invTransform, bucket.placementViewportMatrix);\n\n tileBatches.push({\n circleArray,\n circleOffset,\n transform,\n invTransform,\n coord\n });\n\n circleCount += circleArray.length / 4; // 4 values per circle\n circleOffset = circleCount;\n }\n if (!buffers) continue;\n program.draw(context, gl.LINES,\n DepthMode.disabled, StencilMode.disabled,\n painter.colorModeForRenderPass(),\n CullFaceMode.disabled,\n collisionUniformValues(\n posMatrix,\n painter.transform,\n tile),\n painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord),\n layer.id, buffers.layoutVertexBuffer, buffers.indexBuffer,\n buffers.segments, null, painter.transform.zoom, null, null,\n buffers.collisionVertexBuffer);\n }\n\n if (!isText || !tileBatches.length) {\n return;\n }\n\n // Render collision circles\n const circleProgram = painter.useProgram('collisionCircle');\n\n // Construct vertex data\n const vertexData = new CollisionCircleLayoutArray();\n vertexData.resize(circleCount * 4);\n vertexData._trim();\n\n let vertexOffset = 0;\n\n for (const batch of tileBatches) {\n for (let i = 0; i < batch.circleArray.length / 4; i++) {\n const circleIdx = i * 4;\n const x = batch.circleArray[circleIdx + 0];\n const y = batch.circleArray[circleIdx + 1];\n const radius = batch.circleArray[circleIdx + 2];\n const collision = batch.circleArray[circleIdx + 3];\n\n // 4 floats per vertex, 4 vertices per quad\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 0);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 1);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 2);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 3);\n }\n }\n if (!quadTriangles || quadTriangles.length < circleCount * 2) {\n quadTriangles = createQuadTriangles(circleCount);\n }\n\n const indexBuffer: IndexBuffer = context.createIndexBuffer(quadTriangles, true);\n const vertexBuffer: VertexBuffer = context.createVertexBuffer(vertexData, collisionCircleLayout.members, true);\n\n // Render batches\n for (const batch of tileBatches) {\n const uniforms = collisionCircleUniformValues(\n batch.transform,\n batch.invTransform,\n painter.transform\n );\n\n circleProgram.draw(\n context,\n gl.TRIANGLES,\n DepthMode.disabled,\n StencilMode.disabled,\n painter.colorModeForRenderPass(),\n CullFaceMode.disabled,\n uniforms,\n painter.style.map.terrain && painter.style.map.terrain.getTerrainData(batch.coord),\n layer.id,\n vertexBuffer,\n indexBuffer,\n SegmentVector.simpleSegment(0, batch.circleOffset * 2, batch.circleArray.length, batch.circleArray.length / 2),\n null,\n painter.transform.zoom,\n null,\n null,\n null);\n }\n\n vertexBuffer.destroy();\n indexBuffer.destroy();\n}\n\nfunction createQuadTriangles(quadCount: number): QuadTriangleArray {\n const triCount = quadCount * 2;\n const array = new QuadTriangleArray();\n\n array.resize(triCount);\n array._trim();\n\n // Two triangles and 4 vertices per quad.\n for (let i = 0; i < triCount; i++) {\n const idx = i * 6;\n\n array.uint16[idx + 0] = i * 4 + 0;\n array.uint16[idx + 1] = i * 4 + 1;\n array.uint16[idx + 2] = i * 4 + 2;\n array.uint16[idx + 3] = i * 4 + 2;\n array.uint16[idx + 4] = i * 4 + 3;\n array.uint16[idx + 5] = i * 4 + 0;\n }\n\n return array;\n}\n","import Point from '@mapbox/point-geometry';\nimport {drawCollisionDebug} from './draw_collision_debug';\n\nimport {SegmentVector} from '../data/segment';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport * as symbolProjection from '../symbol/projection';\nimport {EvaluatedZoomSize, evaluateSizeForFeature, evaluateSizeForZoom} from '../symbol/symbol_size';\nimport {mat4} from 'gl-matrix';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {addDynamicAttributes} from '../data/bucket/symbol_bucket';\n\nimport {getAnchorAlignment, WritingMode} from '../symbol/shaping';\nimport ONE_EM from '../symbol/one_em';\n\nimport {\n SymbolIconUniformsType,\n symbolIconUniformValues,\n symbolSDFUniformValues,\n symbolTextAndIconUniformValues\n} from './program/symbol_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\n\nimport type {Texture} from '../render/texture';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {UniformValues} from './uniform_binding';\nimport type {SymbolSDFUniformsType} from '../render/program/symbol_program';\nimport type {CrossTileID, VariableOffset} from '../symbol/placement';\nimport type {SymbolBucket, SymbolBuffers} from '../data/bucket/symbol_bucket';\nimport type {TerrainData} from '../render/terrain';\nimport type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {ColorMode} from '../gl/color_mode';\nimport type {Program} from './program';\nimport type {TextAnchor} from '../style/style_layer/variable_text_anchor';\n\ntype SymbolTileRenderState = {\n segments: SegmentVector;\n sortKey: number;\n terrainData: TerrainData;\n state: {\n program: Program;\n buffers: SymbolBuffers;\n uniformValues: UniformValues;\n atlasTexture: Texture;\n atlasTextureIcon: Texture | null;\n atlasInterpolation: GLenum;\n atlasInterpolationIcon: GLenum;\n isSDF: boolean;\n hasHalo: boolean;\n };\n};\n\nconst identityMat4 = mat4.identity(new Float32Array(16));\n\nexport function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array, variableOffsets: {\n [_ in CrossTileID]: VariableOffset;\n}) {\n if (painter.renderPass !== 'translucent') return;\n\n // Disable the stencil test so that labels aren't clipped to tile boundaries.\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n\n //Compute variable-offsets before painting since icons and text data positioning\n //depend on each other in this case.\n if (hasVariablePlacement) {\n updateVariableAnchors(coords, painter, layer, sourceCache,\n layer.layout.get('text-rotation-alignment'),\n layer.layout.get('text-pitch-alignment'),\n variableOffsets\n );\n }\n\n if (layer.paint.get('icon-opacity').constantOr(1) !== 0) {\n drawLayerSymbols(painter, sourceCache, layer, coords, false,\n layer.paint.get('icon-translate'),\n layer.paint.get('icon-translate-anchor'),\n layer.layout.get('icon-rotation-alignment'),\n layer.layout.get('icon-pitch-alignment'),\n layer.layout.get('icon-keep-upright'),\n stencilMode, colorMode\n );\n }\n\n if (layer.paint.get('text-opacity').constantOr(1) !== 0) {\n drawLayerSymbols(painter, sourceCache, layer, coords, true,\n layer.paint.get('text-translate'),\n layer.paint.get('text-translate-anchor'),\n layer.layout.get('text-rotation-alignment'),\n layer.layout.get('text-pitch-alignment'),\n layer.layout.get('text-keep-upright'),\n stencilMode, colorMode\n );\n }\n\n if (sourceCache.map.showCollisionBoxes) {\n drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'),\n layer.paint.get('text-translate-anchor'), true);\n drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'),\n layer.paint.get('icon-translate-anchor'), false);\n }\n}\n\nfunction calculateVariableRenderShift(\n anchor: TextAnchor,\n width: number,\n height: number,\n textOffset: [number, number],\n textBoxScale: number,\n renderTextSize: number): Point {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);\n const shiftX = -(horizontalAlign - 0.5) * width;\n const shiftY = -(verticalAlign - 0.5) * height;\n return new Point(\n (shiftX / textBoxScale + textOffset[0]) * renderTextSize,\n (shiftY / textBoxScale + textOffset[1]) * renderTextSize\n );\n}\n\nfunction updateVariableAnchors(coords: Array,\n painter: Painter,\n layer:SymbolStyleLayer, sourceCache: SourceCache,\n rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'],\n pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'],\n variableOffsets: {[_ in CrossTileID]: VariableOffset}) {\n const tr = painter.transform;\n const rotateWithMap = rotationAlignment === 'map';\n const pitchWithMap = pitchAlignment === 'map';\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n const bucket = tile.getBucket(layer) as SymbolBucket;\n if (!bucket || !bucket.text || !bucket.text.segments.get().length) continue;\n\n const sizeData = bucket.textSizeData;\n const size = evaluateSizeForZoom(sizeData, tr.zoom);\n\n const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom);\n const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale);\n const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData();\n\n if (size) {\n const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ);\n const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null;\n updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets,\n tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon, getElevation);\n }\n }\n}\n\nfunction updateVariableAnchorsForBucket(\n bucket: SymbolBucket,\n rotateWithMap: boolean,\n pitchWithMap: boolean,\n variableOffsets: {[_ in CrossTileID]: VariableOffset},\n transform: Transform,\n labelPlaneMatrix: mat4,\n posMatrix: mat4,\n tileScale: number,\n size: EvaluatedZoomSize,\n updateTextFitIcon: boolean,\n getElevation: (x: number, y: number) => number) {\n const placedSymbols = bucket.text.placedSymbolArray;\n const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray;\n const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray;\n const placedTextShifts = {};\n\n dynamicTextLayoutVertexArray.clear();\n for (let s = 0; s < placedSymbols.length; s++) {\n const symbol = placedSymbols.get(s);\n const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation;\n const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null;\n\n if (!variableOffset) {\n // These symbols are from a justification that is not being used, or a label that wasn't placed\n // so we don't need to do the extra math to figure out what incremental shift to apply.\n symbolProjection.hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray);\n } else {\n const tileAnchor = new Point(symbol.anchorX, symbol.anchorY);\n const projectedAnchor = symbolProjection.project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix, getElevation);\n const perspectiveRatio = symbolProjection.getPerspectiveRatio(transform.cameraToCenterDistance, projectedAnchor.signedDistanceFromCamera);\n let renderTextSize = evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / ONE_EM;\n if (pitchWithMap) {\n // Go from size in pixels to equivalent size in tile units\n renderTextSize *= bucket.tilePixelRatio / tileScale;\n }\n\n const {width, height, anchor, textOffset, textBoxScale} = variableOffset;\n\n const shift = calculateVariableRenderShift(\n anchor, width, height, textOffset, textBoxScale, renderTextSize);\n\n // Usual case is that we take the projected anchor and add the pixel-based shift\n // calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent\n // tile-unit based shift to the anchor before projecting to the label plane.\n const shiftedAnchor = pitchWithMap ?\n symbolProjection.project(tileAnchor.add(shift), labelPlaneMatrix, getElevation).point :\n projectedAnchor.point.add(rotateWithMap ?\n shift.rotate(-transform.angle) :\n shift);\n\n const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === WritingMode.vertical) ? Math.PI / 2 : 0;\n for (let g = 0; g < symbol.numGlyphs; g++) {\n addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle);\n }\n //Only offset horizontal text icons\n if (updateTextFitIcon && symbol.associatedIconIndex >= 0) {\n placedTextShifts[symbol.associatedIconIndex] = {shiftedAnchor, angle};\n }\n }\n }\n\n if (updateTextFitIcon) {\n dynamicIconLayoutVertexArray.clear();\n const placedIcons = bucket.icon.placedSymbolArray;\n for (let i = 0; i < placedIcons.length; i++) {\n const placedIcon = placedIcons.get(i);\n if (placedIcon.hidden) {\n symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);\n } else {\n const shift = placedTextShifts[i];\n if (!shift) {\n symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);\n } else {\n for (let g = 0; g < placedIcon.numGlyphs; g++) {\n addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle);\n }\n }\n }\n }\n bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray);\n }\n bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray);\n}\n\nfunction getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) {\n if (bucket.iconsInText && isText) {\n return 'symbolTextAndIcon';\n } else if (isSDF) {\n return 'symbolSDF';\n } else {\n return 'symbolIcon';\n }\n}\n\nfunction drawLayerSymbols(\n painter: Painter,\n sourceCache: SourceCache,\n layer: SymbolStyleLayer,\n coords: Array,\n isText: boolean,\n translate: [number, number],\n translateAnchor: 'map' | 'viewport',\n rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'],\n pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'],\n keepUpright: boolean,\n stencilMode: StencilMode,\n colorMode: Readonly) {\n\n const context = painter.context;\n const gl = context.gl;\n const tr = painter.transform;\n\n const rotateWithMap = rotationAlignment === 'map';\n const pitchWithMap = pitchAlignment === 'map';\n const alongLine = rotationAlignment !== 'viewport' && layer.layout.get('symbol-placement') !== 'point';\n // Line label rotation happens in `updateLineLabels`\n // Pitched point labels are automatically rotated by the labelPlaneMatrix projection\n // Unpitched point labels need to have their rotation applied after projection\n const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;\n\n const hasSortKey = !layer.layout.get('symbol-sort-key').isConstant();\n let sortFeaturesByKey = false;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n\n const tileRenderState: Array = [];\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n const bucket = tile.getBucket(layer) as SymbolBucket;\n if (!bucket) continue;\n const buffers = isText ? bucket.text : bucket.icon;\n\n if (!buffers || !buffers.segments.get().length || !buffers.hasVisibleVertices) continue;\n const programConfiguration = buffers.programConfigurations.get(layer.id);\n\n const isSDF = isText || bucket.sdfIcons;\n\n const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;\n const transformed = pitchWithMap || tr.pitch !== 0;\n\n const program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration);\n const size = evaluateSizeForZoom(sizeData, tr.zoom);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n let texSize: [number, number];\n let texSizeIcon: [number, number] = [0, 0];\n let atlasTexture: Texture;\n let atlasInterpolation: GLenum;\n let atlasTextureIcon = null;\n let atlasInterpolationIcon: GLenum;\n if (isText) {\n atlasTexture = tile.glyphAtlasTexture;\n atlasInterpolation = gl.LINEAR;\n texSize = tile.glyphAtlasTexture.size;\n if (bucket.iconsInText) {\n texSizeIcon = tile.imageAtlasTexture.size;\n atlasTextureIcon = tile.imageAtlasTexture;\n const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera';\n atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST;\n }\n } else {\n const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;\n atlasTexture = tile.imageAtlasTexture;\n atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ?\n gl.LINEAR :\n gl.NEAREST;\n texSize = tile.imageAtlasTexture.size;\n }\n\n const s = pixelsToTileUnits(tile, 1, painter.transform.zoom);\n const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);\n const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);\n\n const hasVariableAnchors = hasVariablePlacement && bucket.hasTextData();\n const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&\n hasVariableAnchors &&\n bucket.hasIconData();\n\n if (alongLine) {\n const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null;\n const rotateToLine = layer.layout.get('text-rotation-alignment') === 'map';\n symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright, rotateToLine, getElevation);\n }\n\n const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),\n uLabelPlaneMatrix = (alongLine || (isText && hasVariablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,\n uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);\n\n const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;\n\n let uniformValues: UniformValues;\n if (isSDF) {\n if (!bucket.iconsInText) {\n uniformValues = symbolSDFUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);\n } else {\n uniformValues = symbolTextAndIconUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);\n }\n } else {\n uniformValues = symbolIconUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, isText, texSize);\n }\n\n const state = {\n program,\n buffers,\n uniformValues,\n atlasTexture,\n atlasTextureIcon,\n atlasInterpolation,\n atlasInterpolationIcon,\n isSDF,\n hasHalo\n };\n\n if (hasSortKey && bucket.canOverlap) {\n sortFeaturesByKey = true;\n const oldSegments = buffers.segments.get();\n for (const segment of oldSegments) {\n tileRenderState.push({\n segments: new SegmentVector([segment]),\n sortKey: segment.sortKey,\n state,\n terrainData\n });\n }\n } else {\n tileRenderState.push({\n segments: buffers.segments,\n sortKey: 0,\n state,\n terrainData\n });\n }\n }\n\n if (sortFeaturesByKey) {\n tileRenderState.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const segmentState of tileRenderState) {\n const state = segmentState.state;\n\n context.activeTexture.set(gl.TEXTURE0);\n // @ts-ignore\n state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE);\n if (state.atlasTextureIcon) {\n context.activeTexture.set(gl.TEXTURE1);\n if (state.atlasTextureIcon) {\n // @ts-ignore\n state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE);\n }\n }\n\n if (state.isSDF) {\n const uniformValues = state.uniformValues;\n if (state.hasHalo) {\n uniformValues['u_is_halo'] = 1;\n drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues, segmentState.terrainData);\n }\n uniformValues['u_is_halo'] = 0;\n }\n drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues, segmentState.terrainData);\n }\n}\n\nfunction drawSymbolElements(\n buffers: SymbolBuffers,\n segments: SegmentVector,\n layer: SymbolStyleLayer,\n painter: Painter,\n program: Program,\n depthMode: Readonly,\n stencilMode: StencilMode,\n colorMode: Readonly,\n uniformValues: UniformValues,\n terrainData: TerrainData) {\n const context = painter.context;\n const gl = context.gl;\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, buffers.layoutVertexBuffer,\n buffers.indexBuffer, segments, layer.paint,\n painter.transform.zoom, buffers.programConfigurations.get(layer.id),\n buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer);\n}\n","import type {CrossFaded} from '../style/properties';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport type {Tile} from '../source/tile';\nimport type {ProgramConfiguration} from '../data/program_configuration';\nimport type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';\nimport type {FillStyleLayer} from '../style/style_layer/fill_style_layer';\n\n/**\n * A simple helper shared by draw_fill and draw_fill_extrusions to find the correct pattern positions AND update program.\n * For transtionable properties, especially 'fill-pattern' and 'fill-extrusion-pattern', while rendering certain frames\n * tile.imageAtlas has been updated by worker to hold the new pattern only, but rendering code is still looking for the previous image.\n * The mismatch was causing setConstantPatternPositions method not being called and pixelRatio was always the\n * default of 1, instead of actual values set by original map.addImage.\n *\n * @param programConfiguration - to be used to set pattern position and device pixel ratio.\n * @param propertyName - 'fill-pattern' or 'fill-extrusion-pattern' property key\n * @param constantPattern - either 'fill-pattern' or 'fill-extrusion-pattern' property value\n * @param tile - current tile being drawn\n * @param layer - current layer being rendered\n */\nexport function updatePatternPositionsInProgram(\n programConfiguration: ProgramConfiguration,\n propertyName: 'fill-pattern' | 'fill-extrusion-pattern',\n constantPattern: CrossFaded,\n tile: Tile,\n layer: FillStyleLayer | FillExtrusionStyleLayer): void {\n\n if (!constantPattern || !tile || !tile.imageAtlas) {\n return;\n }\n\n const patternPositions = tile.imageAtlas.patternPositions;\n let posTo = patternPositions[constantPattern.to.toString()];\n let posFrom = patternPositions[constantPattern.from.toString()];\n\n // https://github.com/maplibre/maplibre-gl-js/issues/3377\n if (!posTo && posFrom) posTo = posFrom;\n if (!posFrom && posTo) posFrom = posTo;\n\n // try again in case patternPositions has been updated by worker\n if (!posTo || !posFrom) {\n const transitioned = layer.getPaintProperty(propertyName) as string;\n posTo = patternPositions[transitioned];\n posFrom = patternPositions[transitioned];\n }\n\n if (posTo && posFrom) {\n programConfiguration.setConstantPatternPositions(posTo, posFrom);\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {\n fillUniformValues,\n fillPatternUniformValues,\n fillOutlineUniformValues,\n fillOutlinePatternUniformValues\n} from './program/fill_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {FillStyleLayer} from '../style/style_layer/fill_style_layer';\nimport type {FillBucket} from '../data/bucket/fill_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';\n\nexport function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLayer, coords: Array) {\n const color = layer.paint.get('fill-color');\n const opacity = layer.paint.get('fill-opacity');\n\n if (opacity.constantOr(1) === 0) {\n return;\n }\n\n const colorMode = painter.colorModeForRenderPass();\n\n const pattern = layer.paint.get('fill-pattern');\n const pass = painter.opaquePassEnabledForLayer() &&\n (!pattern.constantOr(1 as any) &&\n color.constantOr(Color.transparent).a === 1 &&\n opacity.constantOr(0) === 1) ? 'opaque' : 'translucent';\n\n // Draw fill\n if (painter.renderPass === pass) {\n const depthMode = painter.depthModeForSublayer(\n 1, painter.renderPass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly);\n drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, false);\n }\n\n // Draw stroke\n if (painter.renderPass === 'translucent' && layer.paint.get('fill-antialias')) {\n\n // If we defined a different color for the fill outline, we are\n // going to ignore the bits in 0x07 and just care about the global\n // clipping mask.\n // Otherwise, we only want to drawFill the antialiased parts that are\n // *outside* the current shape. This is important in case the fill\n // or stroke color is translucent. If we wouldn't clip to outside\n // the current shape, some pixels from the outline stroke overlapped\n // the (non-antialiased) fill.\n const depthMode = painter.depthModeForSublayer(\n layer.getPaintProperty('fill-outline-color') ? 2 : 0, DepthMode.ReadOnly);\n drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, true);\n }\n}\n\nfunction drawFillTiles(\n painter: Painter,\n sourceCache: SourceCache,\n layer: FillStyleLayer,\n coords: Array,\n depthMode: Readonly,\n colorMode: Readonly,\n isOutline: boolean) {\n const gl = painter.context.gl;\n const fillPropertyName = 'fill-pattern';\n const patternProperty = layer.paint.get(fillPropertyName);\n const image = patternProperty && patternProperty.constantOr(1 as any);\n const crossfade = layer.getCrossfadeParameters();\n let drawMode, programName, uniformValues, indexBuffer, segments;\n\n if (!isOutline) {\n programName = image ? 'fillPattern' : 'fill';\n drawMode = gl.TRIANGLES;\n } else {\n programName = image && !layer.getPaintProperty('fill-outline-color') ? 'fillOutlinePattern' : 'fillOutline';\n drawMode = gl.LINES;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n if (image && !tile.patternsLoaded()) continue;\n\n const bucket: FillBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram(programName, programConfiguration);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n if (image) {\n painter.context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n }\n\n updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer);\n\n const terrainCoord = terrainData ? coord : null;\n const posMatrix = terrainCoord ? terrainCoord.posMatrix : coord.posMatrix;\n const tileMatrix = painter.translatePosMatrix(posMatrix, tile,\n layer.paint.get('fill-translate'), layer.paint.get('fill-translate-anchor'));\n\n if (!isOutline) {\n indexBuffer = bucket.indexBuffer;\n segments = bucket.segments;\n uniformValues = image ?\n fillPatternUniformValues(tileMatrix, painter, crossfade, tile) :\n fillUniformValues(tileMatrix);\n } else {\n indexBuffer = bucket.indexBuffer2;\n segments = bucket.segments2;\n const drawingBufferSize = [gl.drawingBufferWidth, gl.drawingBufferHeight] as [number, number];\n uniformValues = (programName === 'fillOutlinePattern' && image) ?\n fillOutlinePatternUniformValues(tileMatrix, painter, crossfade, tile, drawingBufferSize) :\n fillOutlineUniformValues(tileMatrix, drawingBufferSize);\n }\n\n program.draw(painter.context, drawMode, depthMode,\n painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData,\n layer.id, bucket.layoutVertexBuffer, indexBuffer, segments,\n layer.paint, painter.transform.zoom, programConfiguration);\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {\n fillExtrusionUniformValues,\n fillExtrusionPatternUniformValues,\n} from './program/fill_extrusion_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';\nimport type {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nimport {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';\n\nexport function drawFillExtrusion(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLayer, coords: Array) {\n const opacity = layer.paint.get('fill-extrusion-opacity');\n if (opacity === 0) {\n return;\n }\n\n if (painter.renderPass === 'translucent') {\n const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);\n\n if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1 as any)) {\n const colorMode = painter.colorModeForRenderPass();\n drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode);\n\n } else {\n // Draw transparent buildings in two passes so that only the closest surface is drawn.\n // First draw all the extrusions into only the depth buffer. No colors are drawn.\n drawExtrusionTiles(painter, source, layer, coords, depthMode,\n StencilMode.disabled,\n ColorMode.disabled);\n\n // Then draw all the extrusions a second type, only coloring fragments if they have the\n // same depth value as the closest fragment in the previous pass. Use the stencil buffer\n // to prevent the second draw in cases where we have coincident polygons.\n drawExtrusionTiles(painter, source, layer, coords, depthMode,\n painter.stencilModeFor3D(),\n painter.colorModeForRenderPass());\n }\n }\n}\n\nfunction drawExtrusionTiles(\n painter: Painter,\n source: SourceCache,\n layer: FillExtrusionStyleLayer,\n coords: OverscaledTileID[],\n depthMode: DepthMode,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const fillPropertyName = 'fill-extrusion-pattern';\n const patternProperty = layer.paint.get(fillPropertyName);\n const image = patternProperty.constantOr(1 as any);\n const crossfade = layer.getCrossfadeParameters();\n const opacity = layer.paint.get('fill-extrusion-opacity');\n const constantPattern = patternProperty.constantOr(null);\n for (const coord of coords) {\n const tile = source.getTile(coord);\n const bucket: FillExtrusionBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration);\n\n if (image) {\n painter.context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n }\n\n updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer);\n\n const matrix = painter.translatePosMatrix(\n coord.posMatrix,\n tile,\n layer.paint.get('fill-extrusion-translate'),\n layer.paint.get('fill-extrusion-translate-anchor'));\n\n const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient');\n const uniformValues = image ?\n fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile) :\n fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity);\n\n program.draw(context, context.gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.backCCW,\n uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer,\n bucket.segments, layer.paint, painter.transform.zoom,\n programConfiguration, painter.style.map.terrain && bucket.centroidVertexBuffer);\n }\n}\n","import {Texture} from './texture';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {Tile} from '../source/tile';\nimport {\n hillshadeUniformValues,\n hillshadeUniformPrepareValues\n} from './program/hillshade_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: HillshadeStyleLayer, tileIDs: Array) {\n if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') return;\n\n const context = painter.context;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n\n const [stencilModes, coords] = painter.renderPass === 'translucent' ?\n painter.stencilConfigForOverlap(tileIDs) : [{}, tileIDs];\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n if (typeof tile.needsHillshadePrepare !== 'undefined' && tile.needsHillshadePrepare && painter.renderPass === 'offscreen') {\n prepareHillshade(painter, tile, layer, depthMode, StencilMode.disabled, colorMode);\n } else if (painter.renderPass === 'translucent') {\n renderHillshade(painter, coord, tile, layer, depthMode, stencilModes[coord.overscaledZ], colorMode);\n }\n }\n\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\nfunction renderHillshade(\n painter: Painter,\n coord: OverscaledTileID,\n tile: Tile,\n layer: HillshadeStyleLayer,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const fbo = tile.fbo;\n if (!fbo) return;\n\n const program = painter.useProgram('hillshade');\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n\n const terrainCoord = terrainData ? coord : null;\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n hillshadeUniformValues(painter, tile, layer, terrainCoord), terrainData, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n\n}\n\n// hillshade rendering is done in two steps. the prepare step first calculates the slope of the terrain in the x and y\n// directions for each pixel, and saves those values to a framebuffer texture in the r and g channels.\nfunction prepareHillshade(\n painter: Painter,\n tile: Tile,\n layer: HillshadeStyleLayer,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const dem = tile.dem;\n if (dem && dem.data) {\n const tileSize = dem.dim;\n const textureStride = dem.stride;\n\n const pixelData = dem.getPixels();\n context.activeTexture.set(gl.TEXTURE1);\n\n context.pixelStoreUnpackPremultiplyAlpha.set(false);\n tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride);\n if (tile.demTexture) {\n const demTexture = tile.demTexture;\n demTexture.update(pixelData, {premultiply: false});\n demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);\n } else {\n tile.demTexture = new Texture(context, pixelData, gl.RGBA, {premultiply: false});\n tile.demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);\n }\n\n context.activeTexture.set(gl.TEXTURE0);\n\n let fbo = tile.fbo;\n\n if (!fbo) {\n const renderTexture = new Texture(context, {width: tileSize, height: tileSize, data: null}, gl.RGBA);\n renderTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n\n fbo = tile.fbo = context.createFramebuffer(tileSize, tileSize, true, false);\n fbo.colorAttachment.set(renderTexture.texture);\n }\n\n context.bindFramebuffer.set(fbo.framebuffer);\n context.viewport.set([0, 0, tileSize, tileSize]);\n\n painter.useProgram('hillshadePrepare').draw(context, gl.TRIANGLES,\n depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n hillshadeUniformPrepareValues(tile.tileID, dem),\n null, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n\n tile.needsHillshadePrepare = false;\n }\n}\n","import {clamp} from '../util/util';\n\nimport {ImageSource} from '../source/image_source';\nimport {browser} from '../util/browser';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {rasterUniformValues} from './program/raster_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {RasterStyleLayer} from '../style/style_layer/raster_style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array) {\n if (painter.renderPass !== 'translucent') return;\n if (layer.paint.get('raster-opacity') === 0) return;\n if (!tileIDs.length) return;\n\n const context = painter.context;\n const gl = context.gl;\n const source = sourceCache.getSource();\n const program = painter.useProgram('raster');\n\n const colorMode = painter.colorModeForRenderPass();\n\n const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] :\n painter.stencilConfigForOverlap(tileIDs);\n\n const minTileZ = coords[coords.length - 1].overscaledZ;\n\n const align = !painter.options.moving;\n for (const coord of coords) {\n // Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers\n // Use gl.LESS to prevent double drawing in areas where tiles overlap.\n const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ,\n layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS);\n\n const tile = sourceCache.getTile(coord);\n\n tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));\n\n const parentTile = sourceCache.findLoadedParent(coord, 0),\n fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform, painter.style.map.terrain);\n\n let parentScaleBy, parentTL;\n\n const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;\n\n context.activeTexture.set(gl.TEXTURE0);\n tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n\n context.activeTexture.set(gl.TEXTURE1);\n\n if (parentTile) {\n parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ);\n parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1];\n\n } else {\n tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n }\n\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const terrainCoord = terrainData ? coord : null;\n const posMatrix = terrainCoord ? terrainCoord.posMatrix : painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);\n const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer);\n\n if (source instanceof ImageSource) {\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, source.boundsBuffer,\n painter.quadTriangleIndexBuffer, source.boundsSegments);\n } else {\n program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n }\n }\n}\n\nfunction getFadeValues(tile, parentTile, sourceCache, layer, transform, terrain) {\n const fadeDuration = layer.paint.get('raster-fade-duration');\n\n if (!terrain && fadeDuration > 0) {\n const now = browser.now();\n const sinceTile = (now - tile.timeAdded) / fadeDuration;\n const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1;\n\n const source = sourceCache.getSource();\n const idealZ = transform.coveringZoomLevel({\n tileSize: source.tileSize,\n roundZoom: source.roundZoom\n });\n\n // if no parent or parent is older, fade in; if parent is younger, fade out\n const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ);\n\n const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1);\n\n // we don't crossfade tiles that were just refreshed upon expiring:\n // once they're old enough to pass the crossfading threshold\n // (fadeDuration), unset the `refreshedUponExpiration` flag so we don't\n // incorrectly fail to crossfade them when zooming\n if (tile.refreshedUponExpiration && sinceTile >= 1) tile.refreshedUponExpiration = false;\n\n if (parentTile) {\n return {\n opacity: 1,\n mix: 1 - childOpacity\n };\n } else {\n return {\n opacity: childOpacity,\n mix: 0\n };\n }\n } else {\n return {\n opacity: 1,\n mix: 0\n };\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {debugUniformValues} from './program/debug_program';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {ColorMode} from '../gl/color_mode';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {Style} from '../style/style';\n\nconst topColor = new Color(1, 0, 0, 1);\nconst btmColor = new Color(0, 1, 0, 1);\nconst leftColor = new Color(0, 0, 1, 1);\nconst rightColor = new Color(1, 0, 1, 1);\nconst centerColor = new Color(0, 1, 1, 1);\n\nexport function drawDebugPadding(painter: Painter) {\n const padding = painter.transform.padding;\n const lineWidth = 3;\n // Top\n drawHorizontalLine(painter, painter.transform.height - (padding.top || 0), lineWidth, topColor);\n // Bottom\n drawHorizontalLine(painter, padding.bottom || 0, lineWidth, btmColor);\n // Left\n drawVerticalLine(painter, padding.left || 0, lineWidth, leftColor);\n // Right\n drawVerticalLine(painter, painter.transform.width - (padding.right || 0), lineWidth, rightColor);\n // Center\n const center = painter.transform.centerPoint;\n drawCrosshair(painter, center.x, painter.transform.height - center.y, centerColor);\n}\n\nfunction drawCrosshair(painter: Painter, x: number, y: number, color: Color) {\n const size = 20;\n const lineWidth = 2;\n //Vertical line\n drawDebugSSRect(painter, x - lineWidth / 2, y - size / 2, lineWidth, size, color);\n //Horizontal line\n drawDebugSSRect(painter, x - size / 2, y - lineWidth / 2, size, lineWidth, color);\n}\n\nfunction drawHorizontalLine(painter: Painter, y: number, lineWidth: number, color: Color) {\n drawDebugSSRect(painter, 0, y + lineWidth / 2, painter.transform.width, lineWidth, color);\n}\n\nfunction drawVerticalLine(painter: Painter, x: number, lineWidth: number, color: Color) {\n drawDebugSSRect(painter, x - lineWidth / 2, 0, lineWidth, painter.transform.height, color);\n}\n\nfunction drawDebugSSRect(painter: Painter, x: number, y: number, width: number, height: number, color: Color) {\n const context = painter.context;\n const gl = context.gl;\n\n gl.enable(gl.SCISSOR_TEST);\n gl.scissor(x * painter.pixelRatio, y * painter.pixelRatio, width * painter.pixelRatio, height * painter.pixelRatio);\n context.clear({color});\n gl.disable(gl.SCISSOR_TEST);\n}\n\nexport function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array) {\n for (let i = 0; i < coords.length; i++) {\n drawDebugTile(painter, sourceCache, coords[i]);\n }\n}\n\nfunction drawDebugTile(painter: Painter, sourceCache: SourceCache, coord: OverscaledTileID) {\n const context = painter.context;\n const gl = context.gl;\n\n const posMatrix = coord.posMatrix;\n const program = painter.useProgram('debug');\n\n const depthMode = DepthMode.disabled;\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n const id = '$debug';\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n context.activeTexture.set(gl.TEXTURE0);\n\n const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData;\n const tileByteLength = (tileRawData && tileRawData.byteLength) || 0;\n const tileSizeKb = Math.floor(tileByteLength / 1024);\n const tileSize = sourceCache.getTile(coord).tileSize;\n const scaleRatio = (512 / Math.min(tileSize, 512) * (coord.overscaledZ / painter.transform.zoom)) * 0.5;\n let tileIdText = coord.canonical.toString();\n if (coord.overscaledZ !== coord.canonical.z) {\n tileIdText += ` => ${coord.overscaledZ}`;\n }\n const tileLabel = `${tileIdText} ${tileSizeKb}kB`;\n drawTextToOverlay(painter, tileLabel);\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, ColorMode.alphaBlended, CullFaceMode.disabled,\n debugUniformValues(posMatrix, Color.transparent, scaleRatio), null, id,\n painter.debugBuffer, painter.quadTriangleIndexBuffer, painter.debugSegments);\n program.draw(context, gl.LINE_STRIP, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n debugUniformValues(posMatrix, Color.red), terrainData, id,\n painter.debugBuffer, painter.tileBorderIndexBuffer, painter.debugSegments);\n}\n\nfunction drawTextToOverlay(painter: Painter, text: string) {\n painter.initDebugOverlayCanvas();\n const canvas = painter.debugOverlayCanvas;\n const gl = painter.context.gl;\n const ctx2d = painter.debugOverlayCanvas.getContext('2d');\n ctx2d.clearRect(0, 0, canvas.width, canvas.height);\n\n ctx2d.shadowColor = 'white';\n ctx2d.shadowBlur = 2;\n ctx2d.lineWidth = 1.5;\n ctx2d.strokeStyle = 'white';\n ctx2d.textBaseline = 'top';\n ctx2d.font = `bold ${36}px Open Sans, sans-serif`;\n ctx2d.fillText(text, 5, 5);\n ctx2d.strokeText(text, 5, 5);\n\n painter.debugOverlayTexture.update(canvas);\n painter.debugOverlayTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n}\n\nexport function selectDebugSource(style: Style, zoom: number): SourceCache | null {\n // Use vector source with highest maxzoom\n // Else use source with highest maxzoom of any type\n let selectedSource: SourceCache = null;\n const layers = Object.values(style._layers);\n const sources = layers.flatMap((layer) => {\n if (layer.source && !layer.isHidden(zoom)) {\n const sourceCache = style.sourceCaches[layer.source];\n return [sourceCache];\n } else {\n return [];\n }\n });\n const vectorSources = sources.filter((source) => source.getSource().type === 'vector');\n const otherSources = sources.filter((source) => source.getSource().type !== 'vector');\n const considerSource = (source: SourceCache) => {\n if (!selectedSource || (selectedSource.getSource().maxzoom < source.getSource().maxzoom)) {\n selectedSource = source;\n }\n };\n vectorSources.forEach((source) => considerSource(source));\n if (!selectedSource) {\n otherSources.forEach((source) => considerSource(source));\n }\n return selectedSource;\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues} from './program/terrain_program';\nimport type {Painter} from './painter';\nimport type {Tile} from '../source/tile';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {ColorMode} from '../gl/color_mode';\nimport {Terrain} from './terrain';\n\n/**\n * Redraw the Depth Framebuffer\n * @param painter - the painter\n * @param terrain - the terrain\n */\nfunction drawDepth(painter: Painter, terrain: Terrain) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = ColorMode.unblended;\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]);\n const mesh = terrain.getTerrainMesh();\n const tiles = terrain.sourceCache.getRenderableTiles();\n const program = painter.useProgram('terrainDepth');\n context.bindFramebuffer.set(terrain.getFramebuffer('depth').framebuffer);\n context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]);\n context.clear({color: Color.transparent, depth: 1});\n for (const tile of tiles) {\n const terrainData = terrain.getTerrainData(tile.tileID);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainDepthUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n }\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\n/**\n * Redraw the Coords Framebuffers\n * @param painter - the painter\n * @param terrain - the terrain\n */\nfunction drawCoords(painter: Painter, terrain: Terrain) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = ColorMode.unblended;\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]);\n const mesh = terrain.getTerrainMesh();\n const coords = terrain.getCoordsTexture();\n const tiles = terrain.sourceCache.getRenderableTiles();\n\n // draw tile-coords into framebuffer\n const program = painter.useProgram('terrainCoords');\n context.bindFramebuffer.set(terrain.getFramebuffer('coords').framebuffer);\n context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]);\n context.clear({color: Color.transparent, depth: 1});\n terrain.coordsIndex = [];\n for (const tile of tiles) {\n const terrainData = terrain.getTerrainData(tile.tileID);\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, coords.texture);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainCoordsUniformValues(posMatrix, 255 - terrain.coordsIndex.length, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n terrain.coordsIndex.push(tile.tileID.key);\n }\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\nfunction drawTerrain(painter: Painter, terrain: Terrain, tiles: Array) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = painter.colorModeForRenderPass();\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);\n const program = painter.useProgram('terrain');\n const mesh = terrain.getTerrainMesh();\n\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n\n for (const tile of tiles) {\n const texture = painter.renderToTexture.getTexture(tile);\n const terrainData = terrain.getTerrainData(tile.tileID);\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture.texture);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n }\n\n}\n\nexport {\n drawTerrain,\n drawDepth,\n drawCoords\n};\n","import {browser} from '../util/browser';\nimport {mat4, vec3} from 'gl-matrix';\nimport {SourceCache} from '../source/source_cache';\nimport {EXTENT} from '../data/extent';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport {SegmentVector} from '../data/segment';\nimport {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types.g';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport posAttributes from '../data/pos_attributes';\nimport {ProgramConfiguration} from '../data/program_configuration';\nimport {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';\nimport {shaders} from '../shaders/shaders';\nimport {Program} from './program';\nimport {programUniforms} from './program/program_uniforms';\nimport {Context} from '../gl/context';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Texture} from './texture';\nimport {clippingMaskUniformValues} from './program/clipping_mask_program';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {drawSymbols} from './draw_symbol';\nimport {drawCircles} from './draw_circle';\nimport {drawHeatmap} from './draw_heatmap';\nimport {drawLine} from './draw_line';\nimport {drawFill} from './draw_fill';\nimport {drawFillExtrusion} from './draw_fill_extrusion';\nimport {drawHillshade} from './draw_hillshade';\nimport {drawRaster} from './draw_raster';\nimport {drawBackground} from './draw_background';\nimport {drawDebug, drawDebugPadding, selectDebugSource} from './draw_debug';\nimport {drawCustom} from './draw_custom';\nimport {drawDepth, drawCoords} from './draw_terrain';\nimport {OverscaledTileID} from '../source/tile_id';\n\nimport type {Transform} from '../geo/transform';\nimport type {Tile} from '../source/tile';\nimport type {Style} from '../style/style';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CrossFaded} from '../style/properties';\nimport type {LineAtlas} from './line_atlas';\nimport type {ImageManager} from './image_manager';\nimport type {GlyphManager} from './glyph_manager';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {DepthRangeType, DepthMaskType, DepthFuncType} from '../gl/types';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {RenderToTexture} from './render_to_texture';\n\nexport type RenderPass = 'offscreen' | 'opaque' | 'translucent';\n\ntype PainterOptions = {\n showOverdrawInspector: boolean;\n showTileBoundaries: boolean;\n showPadding: boolean;\n rotating: boolean;\n zooming: boolean;\n moving: boolean;\n fadeDuration: number;\n};\n\n/**\n * @internal\n * Initialize a new painter object.\n */\nexport class Painter {\n context: Context;\n transform: Transform;\n renderToTexture: RenderToTexture;\n _tileTextures: {\n [_: number]: Array;\n };\n numSublayers: number;\n depthEpsilon: number;\n emptyProgramConfiguration: ProgramConfiguration;\n width: number;\n height: number;\n pixelRatio: number;\n tileExtentBuffer: VertexBuffer;\n tileExtentSegments: SegmentVector;\n debugBuffer: VertexBuffer;\n debugSegments: SegmentVector;\n rasterBoundsBuffer: VertexBuffer;\n rasterBoundsSegments: SegmentVector;\n viewportBuffer: VertexBuffer;\n viewportSegments: SegmentVector;\n quadTriangleIndexBuffer: IndexBuffer;\n tileBorderIndexBuffer: IndexBuffer;\n _tileClippingMaskIDs: {[_: string]: number};\n stencilClearMode: StencilMode;\n style: Style;\n options: PainterOptions;\n lineAtlas: LineAtlas;\n imageManager: ImageManager;\n glyphManager: GlyphManager;\n depthRangeFor3D: DepthRangeType;\n opaquePassCutoff: number;\n renderPass: RenderPass;\n currentLayer: number;\n currentStencilSource: string;\n nextStencilID: number;\n id: string;\n _showOverdrawInspector: boolean;\n cache: {[_: string]: Program};\n crossTileSymbolIndex: CrossTileSymbolIndex;\n symbolFadeChange: number;\n debugOverlayTexture: Texture;\n debugOverlayCanvas: HTMLCanvasElement;\n // this object stores the current camera-matrix and the last render time\n // of the terrain-facilitators. e.g. depth & coords framebuffers\n // every time the camera-matrix changes the terrain-facilitators will be redrawn.\n terrainFacilitator: {dirty: boolean; matrix: mat4; renderTime: number};\n\n constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, transform: Transform) {\n this.context = new Context(gl);\n this.transform = transform;\n this._tileTextures = {};\n this.terrainFacilitator = {dirty: true, matrix: mat4.create(), renderTime: 0};\n\n this.setup();\n\n // Within each layer there are multiple distinct z-planes that can be drawn to.\n // This is implemented using the WebGL depth buffer.\n this.numSublayers = SourceCache.maxUnderzooming + SourceCache.maxOverzooming + 1;\n this.depthEpsilon = 1 / Math.pow(2, 16);\n\n this.crossTileSymbolIndex = new CrossTileSymbolIndex();\n }\n\n /*\n * Update the GL viewport, projection matrix, and transforms to compensate\n * for a new width and height value.\n */\n resize(width: number, height: number, pixelRatio: number) {\n this.width = Math.floor(width * pixelRatio);\n this.height = Math.floor(height * pixelRatio);\n this.pixelRatio = pixelRatio;\n this.context.viewport.set([0, 0, this.width, this.height]);\n\n if (this.style) {\n for (const layerId of this.style._order) {\n this.style._layers[layerId].resize();\n }\n }\n }\n\n setup() {\n const context = this.context;\n\n const tileExtentArray = new PosArray();\n tileExtentArray.emplaceBack(0, 0);\n tileExtentArray.emplaceBack(EXTENT, 0);\n tileExtentArray.emplaceBack(0, EXTENT);\n tileExtentArray.emplaceBack(EXTENT, EXTENT);\n this.tileExtentBuffer = context.createVertexBuffer(tileExtentArray, posAttributes.members);\n this.tileExtentSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const debugArray = new PosArray();\n debugArray.emplaceBack(0, 0);\n debugArray.emplaceBack(EXTENT, 0);\n debugArray.emplaceBack(0, EXTENT);\n debugArray.emplaceBack(EXTENT, EXTENT);\n this.debugBuffer = context.createVertexBuffer(debugArray, posAttributes.members);\n this.debugSegments = SegmentVector.simpleSegment(0, 0, 4, 5);\n\n const rasterBoundsArray = new RasterBoundsArray();\n rasterBoundsArray.emplaceBack(0, 0, 0, 0);\n rasterBoundsArray.emplaceBack(EXTENT, 0, EXTENT, 0);\n rasterBoundsArray.emplaceBack(0, EXTENT, 0, EXTENT);\n rasterBoundsArray.emplaceBack(EXTENT, EXTENT, EXTENT, EXTENT);\n this.rasterBoundsBuffer = context.createVertexBuffer(rasterBoundsArray, rasterBoundsAttributes.members);\n this.rasterBoundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const viewportArray = new PosArray();\n viewportArray.emplaceBack(0, 0);\n viewportArray.emplaceBack(1, 0);\n viewportArray.emplaceBack(0, 1);\n viewportArray.emplaceBack(1, 1);\n this.viewportBuffer = context.createVertexBuffer(viewportArray, posAttributes.members);\n this.viewportSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const tileLineStripIndices = new LineStripIndexArray();\n tileLineStripIndices.emplaceBack(0);\n tileLineStripIndices.emplaceBack(1);\n tileLineStripIndices.emplaceBack(3);\n tileLineStripIndices.emplaceBack(2);\n tileLineStripIndices.emplaceBack(0);\n this.tileBorderIndexBuffer = context.createIndexBuffer(tileLineStripIndices);\n\n const quadTriangleIndices = new TriangleIndexArray();\n quadTriangleIndices.emplaceBack(0, 1, 2);\n quadTriangleIndices.emplaceBack(2, 1, 3);\n this.quadTriangleIndexBuffer = context.createIndexBuffer(quadTriangleIndices);\n\n const gl = this.context.gl;\n this.stencilClearMode = new StencilMode({func: gl.ALWAYS, mask: 0}, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO);\n }\n\n /*\n * Reset the drawing canvas by clearing the stencil buffer so that we can draw\n * new tiles at the same location, while retaining previously drawn pixels.\n */\n clearStencil() {\n const context = this.context;\n const gl = context.gl;\n\n this.nextStencilID = 1;\n this.currentStencilSource = undefined;\n\n // As a temporary workaround for https://github.com/mapbox/mapbox-gl-js/issues/5490,\n // pending an upstream fix, we draw a fullscreen stencil=0 clipping mask here,\n // effectively clearing the stencil buffer: once an upstream patch lands, remove\n // this function in favor of context.clear({ stencil: 0x0 })\n\n const matrix = mat4.create();\n mat4.ortho(matrix, 0, this.width, this.height, 0, 0, 1);\n mat4.scale(matrix, matrix, [gl.drawingBufferWidth, gl.drawingBufferHeight, 0]);\n\n this.useProgram('clippingMask').draw(context, gl.TRIANGLES,\n DepthMode.disabled, this.stencilClearMode, ColorMode.disabled, CullFaceMode.disabled,\n clippingMaskUniformValues(matrix), null,\n '$clipping', this.viewportBuffer,\n this.quadTriangleIndexBuffer, this.viewportSegments);\n }\n\n _renderTileClippingMasks(layer: StyleLayer, tileIDs: Array) {\n if (this.currentStencilSource === layer.source || !layer.isTileClipped() || !tileIDs || !tileIDs.length) return;\n\n this.currentStencilSource = layer.source;\n\n const context = this.context;\n const gl = context.gl;\n\n if (this.nextStencilID + tileIDs.length > 256) {\n // we'll run out of fresh IDs so we need to clear and start from scratch\n this.clearStencil();\n }\n\n context.setColorMode(ColorMode.disabled);\n context.setDepthMode(DepthMode.disabled);\n\n const program = this.useProgram('clippingMask');\n\n this._tileClippingMaskIDs = {};\n\n for (const tileID of tileIDs) {\n const id = this._tileClippingMaskIDs[tileID.key] = this.nextStencilID++;\n const terrainData = this.style.map.terrain && this.style.map.terrain.getTerrainData(tileID);\n\n program.draw(context, gl.TRIANGLES, DepthMode.disabled,\n // Tests will always pass, and ref value will be written to stencil buffer.\n new StencilMode({func: gl.ALWAYS, mask: 0}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE),\n ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(tileID.posMatrix),\n terrainData, '$clipping', this.tileExtentBuffer,\n this.quadTriangleIndexBuffer, this.tileExtentSegments);\n }\n }\n\n stencilModeFor3D(): StencilMode {\n this.currentStencilSource = undefined;\n\n if (this.nextStencilID + 1 > 256) {\n this.clearStencil();\n }\n\n const id = this.nextStencilID++;\n const gl = this.context.gl;\n return new StencilMode({func: gl.NOTEQUAL, mask: 0xFF}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n\n stencilModeForClipping(tileID: OverscaledTileID): StencilMode {\n const gl = this.context.gl;\n return new StencilMode({func: gl.EQUAL, mask: 0xFF}, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n\n /*\n * Sort coordinates by Z as drawing tiles is done in Z-descending order.\n * All children with the same Z write the same stencil value. Children\n * stencil values are greater than parent's. This is used only for raster\n * and raster-dem tiles, which are already clipped to tile boundaries, to\n * mask area of tile overlapped by children tiles.\n * Stencil ref values continue range used in _tileClippingMaskIDs.\n *\n * Returns [StencilMode for tile overscaleZ map, sortedCoords].\n */\n stencilConfigForOverlap(tileIDs: Array): [{\n [_: number]: Readonly;\n }, Array] {\n const gl = this.context.gl;\n const coords = tileIDs.sort((a, b) => b.overscaledZ - a.overscaledZ);\n const minTileZ = coords[coords.length - 1].overscaledZ;\n const stencilValues = coords[0].overscaledZ - minTileZ + 1;\n if (stencilValues > 1) {\n this.currentStencilSource = undefined;\n if (this.nextStencilID + stencilValues > 256) {\n this.clearStencil();\n }\n const zToStencilMode = {};\n for (let i = 0; i < stencilValues; i++) {\n zToStencilMode[i + minTileZ] = new StencilMode({func: gl.GEQUAL, mask: 0xFF}, i + this.nextStencilID, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n this.nextStencilID += stencilValues;\n return [zToStencilMode, coords];\n }\n return [{[minTileZ]: StencilMode.disabled}, coords];\n }\n\n colorModeForRenderPass(): Readonly {\n const gl = this.context.gl;\n if (this._showOverdrawInspector) {\n const numOverdrawSteps = 8;\n const a = 1 / numOverdrawSteps;\n\n return new ColorMode([gl.CONSTANT_COLOR, gl.ONE], new Color(a, a, a, 0), [true, true, true, true]);\n } else if (this.renderPass === 'opaque') {\n return ColorMode.unblended;\n } else {\n return ColorMode.alphaBlended;\n }\n }\n\n depthModeForSublayer(n: number, mask: DepthMaskType, func?: DepthFuncType | null): Readonly {\n if (!this.opaquePassEnabledForLayer()) return DepthMode.disabled;\n const depth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon;\n return new DepthMode(func || this.context.gl.LEQUAL, mask, [depth, depth]);\n }\n\n /*\n * The opaque pass and 3D layers both use the depth buffer.\n * Layers drawn above 3D layers need to be drawn using the\n * painter's algorithm so that they appear above 3D features.\n * This returns true for layers that can be drawn using the\n * opaque pass.\n */\n opaquePassEnabledForLayer() {\n return this.currentLayer < this.opaquePassCutoff;\n }\n\n render(style: Style, options: PainterOptions) {\n this.style = style;\n this.options = options;\n\n this.lineAtlas = style.lineAtlas;\n this.imageManager = style.imageManager;\n this.glyphManager = style.glyphManager;\n\n this.symbolFadeChange = style.placement.symbolFadeChange(browser.now());\n\n this.imageManager.beginFrame();\n\n const layerIds = this.style._order;\n const sourceCaches = this.style.sourceCaches;\n\n const coordsAscending: {[_: string]: Array} = {};\n const coordsDescending: {[_: string]: Array} = {};\n const coordsDescendingSymbol: {[_: string]: Array} = {};\n\n for (const id in sourceCaches) {\n const sourceCache = sourceCaches[id];\n if (sourceCache.used) {\n sourceCache.prepare(this.context);\n }\n\n coordsAscending[id] = sourceCache.getVisibleCoordinates();\n coordsDescending[id] = coordsAscending[id].slice().reverse();\n coordsDescendingSymbol[id] = sourceCache.getVisibleCoordinates(true).reverse();\n }\n\n this.opaquePassCutoff = Infinity;\n for (let i = 0; i < layerIds.length; i++) {\n const layerId = layerIds[i];\n if (this.style._layers[layerId].is3D()) {\n this.opaquePassCutoff = i;\n break;\n }\n }\n\n if (this.renderToTexture) {\n this.renderToTexture.prepareForRender(this.style, this.transform.zoom);\n // this is disabled, because render-to-texture is rendering all layers from bottom to top.\n this.opaquePassCutoff = 0;\n\n // update coords/depth-framebuffer on camera movement, or tile reloading\n const newTiles = this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);\n if (this.terrainFacilitator.dirty || !mat4.equals(this.terrainFacilitator.matrix, this.transform.projMatrix) || newTiles.length) {\n mat4.copy(this.terrainFacilitator.matrix, this.transform.projMatrix);\n this.terrainFacilitator.renderTime = Date.now();\n this.terrainFacilitator.dirty = false;\n drawDepth(this, this.style.map.terrain);\n drawCoords(this, this.style.map.terrain);\n }\n }\n\n // Offscreen pass ===============================================\n // We first do all rendering that requires rendering to a separate\n // framebuffer, and then save those for rendering back to the map\n // later: in doing this we avoid doing expensive framebuffer restores.\n this.renderPass = 'offscreen';\n\n for (const layerId of layerIds) {\n const layer = this.style._layers[layerId];\n if (!layer.hasOffscreenPass() || layer.isHidden(this.transform.zoom)) continue;\n\n const coords = coordsDescending[layer.source];\n if (layer.type !== 'custom' && !coords.length) continue;\n\n this.renderLayer(this, sourceCaches[layer.source], layer, coords);\n }\n\n // Rebind the main framebuffer now that all offscreen layers have been rendered:\n this.context.bindFramebuffer.set(null);\n\n // Clear buffers in preparation for drawing to the main framebuffer\n this.context.clear({color: options.showOverdrawInspector ? Color.black : Color.transparent, depth: 1});\n this.clearStencil();\n\n this._showOverdrawInspector = options.showOverdrawInspector;\n this.depthRangeFor3D = [0, 1 - ((style._order.length + 2) * this.numSublayers * this.depthEpsilon)];\n\n // Opaque pass ===============================================\n // Draw opaque layers top-to-bottom first.\n if (!this.renderToTexture) {\n this.renderPass = 'opaque';\n\n for (this.currentLayer = layerIds.length - 1; this.currentLayer >= 0; this.currentLayer--) {\n const layer = this.style._layers[layerIds[this.currentLayer]];\n const sourceCache = sourceCaches[layer.source];\n const coords = coordsAscending[layer.source];\n\n this._renderTileClippingMasks(layer, coords);\n this.renderLayer(this, sourceCache, layer, coords);\n }\n }\n\n // Translucent pass ===============================================\n // Draw all other layers bottom-to-top.\n this.renderPass = 'translucent';\n\n for (this.currentLayer = 0; this.currentLayer < layerIds.length; this.currentLayer++) {\n const layer = this.style._layers[layerIds[this.currentLayer]];\n const sourceCache = sourceCaches[layer.source];\n\n if (this.renderToTexture && this.renderToTexture.renderLayer(layer)) continue;\n\n // For symbol layers in the translucent pass, we add extra tiles to the renderable set\n // for cross-tile symbol fading. Symbol layers don't use tile clipping, so no need to render\n // separate clipping masks\n const coords = (layer.type === 'symbol' ? coordsDescendingSymbol : coordsDescending)[layer.source];\n\n this._renderTileClippingMasks(layer, coordsAscending[layer.source]);\n this.renderLayer(this, sourceCache, layer, coords);\n }\n\n if (this.options.showTileBoundaries) {\n const selectedSource = selectDebugSource(this.style, this.transform.zoom);\n if (selectedSource) {\n drawDebug(this, selectedSource, selectedSource.getVisibleCoordinates());\n }\n }\n\n if (this.options.showPadding) {\n drawDebugPadding(this);\n }\n\n // Set defaults for most GL values so that anyone using the state after the render\n // encounters more expected values.\n this.context.setDefault();\n }\n\n renderLayer(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array) {\n if (layer.isHidden(this.transform.zoom)) return;\n if (layer.type !== 'background' && layer.type !== 'custom' && !(coords || []).length) return;\n this.id = layer.id;\n\n switch (layer.type) {\n case 'symbol':\n drawSymbols(painter, sourceCache, layer as any, coords, this.style.placement.variableOffsets);\n break;\n case 'circle':\n drawCircles(painter, sourceCache, layer as any, coords);\n break;\n case 'heatmap':\n drawHeatmap(painter, sourceCache, layer as any, coords);\n break;\n case 'line':\n drawLine(painter, sourceCache, layer as any, coords);\n break;\n case 'fill':\n drawFill(painter, sourceCache, layer as any, coords);\n break;\n case 'fill-extrusion':\n drawFillExtrusion(painter, sourceCache, layer as any, coords);\n break;\n case 'hillshade':\n drawHillshade(painter, sourceCache, layer as any, coords);\n break;\n case 'raster':\n drawRaster(painter, sourceCache, layer as any, coords);\n break;\n case 'background':\n drawBackground(painter, sourceCache, layer as any, coords);\n break;\n case 'custom':\n drawCustom(painter, sourceCache, layer as any);\n break;\n }\n }\n\n /**\n * Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it.\n * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units.\n * @returns matrix\n */\n translatePosMatrix(matrix: mat4, tile: Tile, translate: [number, number], translateAnchor: 'map' | 'viewport', inViewportPixelUnitsUnits?: boolean): mat4 {\n if (!translate[0] && !translate[1]) return matrix;\n\n const angle = inViewportPixelUnitsUnits ?\n (translateAnchor === 'map' ? this.transform.angle : 0) :\n (translateAnchor === 'viewport' ? -this.transform.angle : 0);\n\n if (angle) {\n const sinA = Math.sin(angle);\n const cosA = Math.cos(angle);\n translate = [\n translate[0] * cosA - translate[1] * sinA,\n translate[0] * sinA + translate[1] * cosA\n ];\n }\n\n const translation = [\n inViewportPixelUnitsUnits ? translate[0] : pixelsToTileUnits(tile, translate[0], this.transform.zoom),\n inViewportPixelUnitsUnits ? translate[1] : pixelsToTileUnits(tile, translate[1], this.transform.zoom),\n 0\n ] as vec3;\n\n const translatedMatrix = new Float32Array(16);\n mat4.translate(translatedMatrix, matrix, translation);\n return translatedMatrix;\n }\n\n saveTileTexture(texture: Texture) {\n const textures = this._tileTextures[texture.size[0]];\n if (!textures) {\n this._tileTextures[texture.size[0]] = [texture];\n } else {\n textures.push(texture);\n }\n }\n\n getTileTexture(size: number) {\n const textures = this._tileTextures[size];\n return textures && textures.length > 0 ? textures.pop() : null;\n }\n\n /**\n * Checks whether a pattern image is needed, and if it is, whether it is not loaded.\n *\n * @returns true if a needed image is missing and rendering needs to be skipped.\n */\n isPatternMissing(image?: CrossFaded | null): boolean {\n if (!image) return false;\n if (!image.from || !image.to) return true;\n const imagePosA = this.imageManager.getPattern(image.from.toString());\n const imagePosB = this.imageManager.getPattern(image.to.toString());\n return !imagePosA || !imagePosB;\n }\n\n useProgram(name: string, programConfiguration?: ProgramConfiguration | null): Program {\n this.cache = this.cache || {};\n const key = name +\n (programConfiguration ? programConfiguration.cacheKey : '') +\n (this._showOverdrawInspector ? '/overdraw' : '') +\n (this.style.map.terrain ? '/terrain' : '');\n if (!this.cache[key]) {\n this.cache[key] = new Program(\n this.context,\n shaders[name],\n programConfiguration,\n programUniforms[name],\n this._showOverdrawInspector,\n this.style.map.terrain\n );\n }\n return this.cache[key];\n }\n\n /*\n * Reset some GL state to default values to avoid hard-to-debug bugs\n * in custom layers.\n */\n setCustomLayerDefaults() {\n // Prevent custom layers from unintentionally modify the last VAO used.\n // All other state is state is restored on it's own, but for VAOs it's\n // simpler to unbind so that we don't have to track the state of VAOs.\n this.context.unbindVAO();\n\n // The default values for this state is meaningful and often expected.\n // Leaving this state dirty could cause a lot of confusion for users.\n this.context.cullFace.setDefault();\n this.context.activeTexture.setDefault();\n this.context.pixelStoreUnpack.setDefault();\n this.context.pixelStoreUnpackPremultiplyAlpha.setDefault();\n this.context.pixelStoreUnpackFlipY.setDefault();\n }\n\n /*\n * Set GL state that is shared by all layers.\n */\n setBaseState() {\n const gl = this.context.gl;\n this.context.cullFace.set(false);\n this.context.viewport.set([0, 0, this.width, this.height]);\n this.context.blendEquation.set(gl.FUNC_ADD);\n }\n\n initDebugOverlayCanvas() {\n if (this.debugOverlayCanvas == null) {\n this.debugOverlayCanvas = document.createElement('canvas');\n this.debugOverlayCanvas.width = 512;\n this.debugOverlayCanvas.height = 512;\n const gl = this.context.gl;\n this.debugOverlayTexture = new Texture(this.context, this.debugOverlayCanvas, gl.RGBA);\n }\n }\n\n destroy() {\n if (this.debugOverlayTexture) {\n this.debugOverlayTexture.destroy();\n }\n }\n\n /*\n * Return true if drawing buffer size is != from requested size.\n * That means that we've reached GL limits somehow.\n * Note: drawing buffer size changes only when canvas size changes\n */\n overLimit() {\n const {drawingBufferWidth, drawingBufferHeight} = this.context.gl;\n return this.width !== drawingBufferWidth || this.height !== drawingBufferHeight;\n }\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Program} from './program';\nimport {circleUniformValues} from './program/circle_program';\nimport {SegmentVector} from '../data/segment';\nimport {OverscaledTileID} from '../source/tile_id';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {CircleStyleLayer} from '../style/style_layer/circle_style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {ProgramConfiguration} from '../data/program_configuration';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {UniformValues} from './uniform_binding';\nimport type {CircleUniformsType} from './program/circle_program';\nimport type {TerrainData} from '../render/terrain';\n\ntype TileRenderState = {\n programConfiguration: ProgramConfiguration;\n program: Program;\n layoutVertexBuffer: VertexBuffer;\n indexBuffer: IndexBuffer;\n uniformValues: UniformValues;\n terrainData: TerrainData;\n};\n\ntype SegmentsTileRenderState = {\n segments: SegmentVector;\n sortKey: number;\n state: TileRenderState;\n};\n\nexport function drawCircles(painter: Painter, sourceCache: SourceCache, layer: CircleStyleLayer, coords: Array) {\n if (painter.renderPass !== 'translucent') return;\n\n const opacity = layer.paint.get('circle-opacity');\n const strokeWidth = layer.paint.get('circle-stroke-width');\n const strokeOpacity = layer.paint.get('circle-stroke-opacity');\n const sortFeaturesByKey = !layer.layout.get('circle-sort-key').isConstant();\n\n if (opacity.constantOr(1) === 0 && (strokeWidth.constantOr(1) === 0 || strokeOpacity.constantOr(1) === 0)) {\n return;\n }\n\n const context = painter.context;\n const gl = context.gl;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n // Turn off stencil testing to allow circles to be drawn across boundaries,\n // so that large circles are not clipped to tiles\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n\n const segmentsRenderStates: Array = [];\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n\n const tile = sourceCache.getTile(coord);\n const bucket: CircleBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram('circle', programConfiguration);\n const layoutVertexBuffer = bucket.layoutVertexBuffer;\n const indexBuffer = bucket.indexBuffer;\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const uniformValues = circleUniformValues(painter, coord, tile, layer);\n\n const state: TileRenderState = {\n programConfiguration,\n program,\n layoutVertexBuffer,\n indexBuffer,\n uniformValues,\n terrainData\n };\n\n if (sortFeaturesByKey) {\n const oldSegments = bucket.segments.get();\n for (const segment of oldSegments) {\n segmentsRenderStates.push({\n segments: new SegmentVector([segment]),\n sortKey: (segment.sortKey as any as number),\n state\n });\n }\n } else {\n segmentsRenderStates.push({\n segments: bucket.segments,\n sortKey: 0,\n state\n });\n }\n\n }\n\n if (sortFeaturesByKey) {\n segmentsRenderStates.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const segmentsState of segmentsRenderStates) {\n const {programConfiguration, program, layoutVertexBuffer, indexBuffer, uniformValues, terrainData} = segmentsState.state;\n const segments = segmentsState.segments;\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id,\n layoutVertexBuffer, indexBuffer, segments,\n layer.paint, painter.transform.zoom, programConfiguration);\n }\n}\n","import {Texture} from './texture';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Context} from '../gl/context';\nimport {Framebuffer} from '../gl/framebuffer';\nimport {\n heatmapUniformValues,\n heatmapTextureUniformValues\n} from './program/heatmap_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {HeatmapStyleLayer} from '../style/style_layer/heatmap_style_layer';\nimport type {HeatmapBucket} from '../data/bucket/heatmap_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapStyleLayer, coords: Array) {\n if (layer.paint.get('heatmap-opacity') === 0) {\n return;\n }\n\n if (painter.renderPass === 'offscreen') {\n const context = painter.context;\n const gl = context.gl;\n\n // Allow kernels to be drawn across boundaries, so that\n // large kernels are not clipped to tiles\n const stencilMode = StencilMode.disabled;\n // Turn on additive blending for kernels, which is a key aspect of kernel density estimation formula\n const colorMode = new ColorMode([gl.ONE, gl.ONE], Color.transparent, [true, true, true, true]);\n\n bindFramebuffer(context, painter, layer);\n\n context.clear({color: Color.transparent});\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n\n // Skip tiles that have uncovered parents to avoid flickering; we don't need\n // to use complex tile masking here because the change between zoom levels is subtle,\n // so it's fine to simply render the parent until all its 4 children are loaded\n if (sourceCache.hasRenderableParent(coord)) continue;\n\n const tile = sourceCache.getTile(coord);\n const bucket: HeatmapBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram('heatmap', programConfiguration);\n const {zoom} = painter.transform;\n\n program.draw(context, gl.TRIANGLES, DepthMode.disabled, stencilMode, colorMode, CullFaceMode.disabled,\n heatmapUniformValues(coord.posMatrix, tile, zoom, layer.paint.get('heatmap-intensity')), null,\n layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer,\n bucket.segments, layer.paint, painter.transform.zoom,\n programConfiguration);\n }\n\n context.viewport.set([0, 0, painter.width, painter.height]);\n\n } else if (painter.renderPass === 'translucent') {\n painter.context.setColorMode(painter.colorModeForRenderPass());\n renderTextureToMap(painter, layer);\n }\n}\n\nfunction bindFramebuffer(context: Context, painter: Painter, layer: HeatmapStyleLayer) {\n const gl = context.gl;\n context.activeTexture.set(gl.TEXTURE1);\n\n // Use a 4x downscaled screen texture for better performance\n context.viewport.set([0, 0, painter.width / 4, painter.height / 4]);\n\n let fbo = layer.heatmapFbo;\n\n if (!fbo) {\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\n fbo = layer.heatmapFbo = context.createFramebuffer(painter.width / 4, painter.height / 4, false, false);\n\n bindTextureToFramebuffer(context, painter, texture, fbo);\n\n } else {\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n context.bindFramebuffer.set(fbo.framebuffer);\n }\n}\n\nfunction bindTextureToFramebuffer(context: Context, painter: Painter, texture: WebGLTexture, fbo: Framebuffer) {\n const gl = context.gl;\n // Use the higher precision half-float texture where available (producing much smoother looking heatmaps);\n // Otherwise, fall back to a low precision texture\n\n const numType = context.HALF_FLOAT ?? gl.UNSIGNED_BYTE;\n const internalFormat = context.RGBA16F ?? gl.RGBA;\n\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, painter.width / 4, painter.height / 4, 0, gl.RGBA, numType, null);\n fbo.colorAttachment.set(texture);\n}\n\nfunction renderTextureToMap(painter: Painter, layer: HeatmapStyleLayer) {\n const context = painter.context;\n const gl = context.gl;\n\n // Here we bind two different textures from which we'll sample in drawing\n // heatmaps: the kernel texture, prepared in the offscreen pass, and a\n // color ramp texture.\n const fbo = layer.heatmapFbo;\n if (!fbo) return;\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n\n context.activeTexture.set(gl.TEXTURE1);\n let colorRampTexture = layer.colorRampTexture;\n if (!colorRampTexture) {\n colorRampTexture = layer.colorRampTexture = new Texture(context, layer.colorRamp, gl.RGBA);\n }\n colorRampTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n\n painter.useProgram('heatmapTexture').draw(context, gl.TRIANGLES,\n DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled,\n heatmapTextureUniformValues(painter, layer, 0, 1), null,\n layer.id, painter.viewportBuffer, painter.quadTriangleIndexBuffer,\n painter.viewportSegments, layer.paint, painter.transform.zoom);\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Texture} from './texture';\nimport {\n lineUniformValues,\n linePatternUniformValues,\n lineSDFUniformValues,\n lineGradientUniformValues\n} from './program/line_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {LineStyleLayer} from '../style/style_layer/line_style_layer';\nimport type {LineBucket} from '../data/bucket/line_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {clamp, nextPowerOfTwo} from '../util/util';\nimport {renderColorRamp} from '../util/color_ramp';\nimport {EXTENT} from '../data/extent';\n\nexport function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array) {\n if (painter.renderPass !== 'translucent') return;\n\n const opacity = layer.paint.get('line-opacity');\n const width = layer.paint.get('line-width');\n if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n\n const dasharray = layer.paint.get('line-dasharray');\n const patternProperty = layer.paint.get('line-pattern');\n const image = patternProperty.constantOr(1 as any);\n\n const gradient = layer.paint.get('line-gradient');\n const crossfade = layer.getCrossfadeParameters();\n\n const programId =\n image ? 'linePattern' :\n dasharray ? 'lineSDF' :\n gradient ? 'lineGradient' : 'line';\n\n const context = painter.context;\n const gl = context.gl;\n\n let firstTile = true;\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n\n if (image && !tile.patternsLoaded()) continue;\n\n const bucket: LineBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const prevProgram = painter.context.program.get();\n const program = painter.useProgram(programId, programConfiguration);\n const programChanged = firstTile || program.program !== prevProgram;\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern && tile.imageAtlas) {\n const atlas = tile.imageAtlas;\n const posTo = atlas.patternPositions[constantPattern.to.toString()];\n const posFrom = atlas.patternPositions[constantPattern.from.toString()];\n if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);\n }\n\n const terrainCoord = terrainData ? coord : null;\n const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade, terrainCoord) :\n dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade, terrainCoord) :\n gradient ? lineGradientUniformValues(painter, tile, layer, bucket.lineClipsArray.length, terrainCoord) :\n lineUniformValues(painter, tile, layer, terrainCoord);\n\n if (image) {\n context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n } else if (dasharray && (programChanged || painter.lineAtlas.dirty)) {\n context.activeTexture.set(gl.TEXTURE0);\n painter.lineAtlas.bind(context);\n } else if (gradient) {\n const layerGradient = bucket.gradients[layer.id];\n let gradientTexture = layerGradient.texture;\n if (layer.gradientVersion !== layerGradient.version) {\n let textureResolution = 256;\n if (layer.stepInterpolant) {\n const sourceMaxZoom = sourceCache.getSource().maxzoom;\n const potentialOverzoom = coord.canonical.z === sourceMaxZoom ?\n Math.ceil(1 << (painter.transform.maxZoom - coord.canonical.z)) : 1;\n const lineLength = bucket.maxLineLength / EXTENT;\n // Logical pixel tile size is 512px, and 1024px right before current zoom + 1\n const maxTilePixelSize = 1024;\n // Maximum possible texture coverage heuristic, bound by hardware max texture size\n const maxTextureCoverage = lineLength * maxTilePixelSize * potentialOverzoom;\n textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize);\n }\n layerGradient.gradient = renderColorRamp({\n expression: layer.gradientExpression(),\n evaluationKey: 'lineProgress',\n resolution: textureResolution,\n image: layerGradient.gradient || undefined,\n clips: bucket.lineClipsArray\n });\n if (layerGradient.texture) {\n layerGradient.texture.update(layerGradient.gradient);\n } else {\n layerGradient.texture = new Texture(context, layerGradient.gradient, gl.RGBA);\n }\n layerGradient.version = layer.gradientVersion;\n gradientTexture = layerGradient.texture;\n }\n context.activeTexture.set(gl.TEXTURE0);\n gradientTexture.bind(layer.stepInterpolant ? gl.NEAREST : gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n program.draw(context, gl.TRIANGLES, depthMode,\n painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData,\n layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments,\n layer.paint, painter.transform.zoom, programConfiguration, bucket.layoutVertexBuffer2);\n\n firstTile = false;\n // once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic\n }\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {\n backgroundUniformValues,\n backgroundPatternUniformValues\n} from './program/background_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {BackgroundStyleLayer} from '../style/style_layer/background_style_layer';\nimport {OverscaledTileID} from '../source/tile_id';\n\nexport function drawBackground(painter: Painter, sourceCache: SourceCache, layer: BackgroundStyleLayer, coords?: Array) {\n const color = layer.paint.get('background-color');\n const opacity = layer.paint.get('background-opacity');\n\n if (opacity === 0) return;\n\n const context = painter.context;\n const gl = context.gl;\n const transform = painter.transform;\n const tileSize = transform.tileSize;\n const image = layer.paint.get('background-pattern');\n if (painter.isPatternMissing(image)) return;\n\n const pass = (!image && color.a === 1 && opacity === 1 && painter.opaquePassEnabledForLayer()) ? 'opaque' : 'translucent';\n if (painter.renderPass !== pass) return;\n\n const stencilMode = StencilMode.disabled;\n const depthMode = painter.depthModeForSublayer(0, pass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n const program = painter.useProgram(image ? 'backgroundPattern' : 'background');\n const tileIDs = coords ? coords : transform.coveringTiles({tileSize, terrain: painter.style.map.terrain});\n\n if (image) {\n context.activeTexture.set(gl.TEXTURE0);\n painter.imageManager.bind(painter.context);\n }\n\n const crossfade = layer.getCrossfadeParameters();\n for (const tileID of tileIDs) {\n const matrix = coords ? tileID.posMatrix : painter.transform.calculatePosMatrix(tileID.toUnwrapped());\n const uniformValues = image ?\n backgroundPatternUniformValues(matrix, opacity, painter, image, {tileID, tileSize}, crossfade) :\n backgroundUniformValues(matrix, opacity, color);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(tileID);\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, painter.tileExtentBuffer,\n painter.quadTriangleIndexBuffer, painter.tileExtentSegments);\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {CustomStyleLayer} from '../style/style_layer/custom_style_layer';\n\nexport function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) {\n\n const context = painter.context;\n const implementation = layer.implementation;\n\n if (painter.renderPass === 'offscreen') {\n\n const prerender = implementation.prerender;\n if (prerender) {\n painter.setCustomLayerDefaults();\n context.setColorMode(painter.colorModeForRenderPass());\n\n prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());\n\n context.setDirty();\n painter.setBaseState();\n }\n\n } else if (painter.renderPass === 'translucent') {\n\n painter.setCustomLayerDefaults();\n\n context.setColorMode(painter.colorModeForRenderPass());\n context.setStencilMode(StencilMode.disabled);\n\n const depthMode = implementation.renderingMode === '3d' ?\n new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D) :\n painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n\n context.setDepthMode(depthMode);\n\n implementation.render(context.gl, painter.transform.customLayerMatrix());\n\n context.setDirty();\n painter.setBaseState();\n context.bindFramebuffer.set(null);\n }\n}\n","import {mat4, vec3, vec4} from 'gl-matrix';\n\nclass Frustum {\n\n constructor(public points: vec4[], public planes: vec4[]) { }\n\n public static fromInvProjectionMatrix(invProj: mat4, worldSize: number, zoom: number): Frustum {\n const clipSpaceCorners = [\n [-1, 1, -1, 1],\n [1, 1, -1, 1],\n [1, -1, -1, 1],\n [-1, -1, -1, 1],\n [-1, 1, 1, 1],\n [1, 1, 1, 1],\n [1, -1, 1, 1],\n [-1, -1, 1, 1]\n ];\n\n const scale = Math.pow(2, zoom);\n\n // Transform frustum corner points from clip space to tile space, Z to meters\n const frustumCoords = clipSpaceCorners.map(v => {\n v = vec4.transformMat4([] as any, v as any, invProj) as any;\n const s = 1.0 / v[3] / worldSize * scale;\n return vec4.mul(v as any, v as any, [s, s, 1.0 / v[3], s] as vec4);\n });\n\n const frustumPlanePointIndices = [\n [0, 1, 2], // near\n [6, 5, 4], // far\n [0, 3, 7], // left\n [2, 1, 5], // right\n [3, 2, 6], // bottom\n [0, 4, 5] // top\n ];\n\n const frustumPlanes = frustumPlanePointIndices.map((p: number[]) => {\n const a = vec3.sub([] as any, frustumCoords[p[0]] as vec3, frustumCoords[p[1]] as vec3);\n const b = vec3.sub([] as any, frustumCoords[p[2]] as vec3, frustumCoords[p[1]] as vec3);\n const n = vec3.normalize([] as any, vec3.cross([] as any, a, b)) as any;\n const d = -vec3.dot(n, frustumCoords[p[1]] as vec3);\n return n.concat(d);\n });\n\n return new Frustum(frustumCoords, frustumPlanes);\n }\n}\n\nclass Aabb {\n min: vec3;\n max: vec3;\n center: vec3;\n\n constructor(min_: vec3, max_: vec3) {\n this.min = min_;\n this.max = max_;\n this.center = vec3.scale([] as any, vec3.add([] as any, this.min, this.max), 0.5);\n }\n\n quadrant(index: number): Aabb {\n const split = [(index % 2) === 0, index < 2];\n const qMin = vec3.clone(this.min);\n const qMax = vec3.clone(this.max);\n for (let axis = 0; axis < split.length; axis++) {\n qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];\n qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];\n }\n // Elevation is always constant, hence quadrant.max.z = this.max.z\n qMax[2] = this.max[2];\n return new Aabb(qMin, qMax);\n }\n\n distanceX(point: Array): number {\n const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);\n return pointOnAabb - point[0];\n }\n\n distanceY(point: Array): number {\n const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);\n return pointOnAabb - point[1];\n }\n\n // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,\n // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.\n intersects(frustum: Frustum): number {\n // Execute separating axis test between two convex objects to find intersections\n // Each frustum plane together with 3 major axes define the separating axes\n\n const aabbPoints = [\n [this.min[0], this.min[1], this.min[2], 1],\n [this.max[0], this.min[1], this.min[2], 1],\n [this.max[0], this.max[1], this.min[2], 1],\n [this.min[0], this.max[1], this.min[2], 1],\n [this.min[0], this.min[1], this.max[2], 1],\n [this.max[0], this.min[1], this.max[2], 1],\n [this.max[0], this.max[1], this.max[2], 1],\n [this.min[0], this.max[1], this.max[2], 1]\n ];\n\n let fullyInside = true;\n\n for (let p = 0; p < frustum.planes.length; p++) {\n const plane = frustum.planes[p];\n let pointsInside = 0;\n\n for (let i = 0; i < aabbPoints.length; i++) {\n if (vec4.dot(plane, aabbPoints[i] as any) >= 0) {\n pointsInside++;\n }\n }\n\n if (pointsInside === 0)\n return 0;\n\n if (pointsInside !== aabbPoints.length)\n fullyInside = false;\n }\n\n if (fullyInside)\n return 2;\n\n for (let axis = 0; axis < 3; axis++) {\n let projMin = Number.MAX_VALUE;\n let projMax = -Number.MAX_VALUE;\n\n for (let p = 0; p < frustum.points.length; p++) {\n const projectedPoint = frustum.points[p][axis] - this.min[axis];\n\n projMin = Math.min(projMin, projectedPoint);\n projMax = Math.max(projMax, projectedPoint);\n }\n\n if (projMax < 0 || projMin > this.max[axis] - this.min[axis])\n return 0;\n }\n\n return 1;\n }\n}\nexport {\n Aabb,\n Frustum\n};\n","import {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport Point from '@mapbox/point-geometry';\nimport {clamp} from '../util/util';\n\n/**\n * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.\n * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements\n * on top of the map and having the vanishing point shift as UI elements resize.\n *\n * @group Geography and Geometry\n */\nexport class EdgeInsets {\n /**\n * @defaultValue 0\n */\n top: number;\n /**\n * @defaultValue 0\n */\n bottom: number;\n /**\n * @defaultValue 0\n */\n left: number;\n /**\n * @defaultValue 0\n */\n right: number;\n\n constructor(top: number = 0, bottom: number = 0, left: number = 0, right: number = 0) {\n if (isNaN(top) || top < 0 ||\n isNaN(bottom) || bottom < 0 ||\n isNaN(left) || left < 0 ||\n isNaN(right) || right < 0\n ) {\n throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');\n }\n\n this.top = top;\n this.bottom = bottom;\n this.left = left;\n this.right = right;\n }\n\n /**\n * Interpolates the inset in-place.\n * This maintains the current inset value for any inset not present in `target`.\n * @param start - interpolation start\n * @param target - interpolation target\n * @param t - interpolation step/weight\n * @returns the insets\n */\n interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets {\n if (target.top != null && start.top != null) this.top = interpolates.number(start.top, target.top, t);\n if (target.bottom != null && start.bottom != null) this.bottom = interpolates.number(start.bottom, target.bottom, t);\n if (target.left != null && start.left != null) this.left = interpolates.number(start.left, target.left, t);\n if (target.right != null && start.right != null) this.right = interpolates.number(start.right, target.right, t);\n\n return this;\n }\n\n /**\n * Utility method that computes the new apprent center or vanishing point after applying insets.\n * This is in pixels and with the top left being (0.0) and +y being downwards.\n *\n * @param width - the width\n * @param height - the height\n * @returns the point\n */\n getCenter(width: number, height: number): Point {\n // Clamp insets so they never overflow width/height and always calculate a valid center\n const x = clamp((this.left + width - this.right) / 2, 0, width);\n const y = clamp((this.top + height - this.bottom) / 2, 0, height);\n\n return new Point(x, y);\n }\n\n equals(other: PaddingOptions): boolean {\n return this.top === other.top &&\n this.bottom === other.bottom &&\n this.left === other.left &&\n this.right === other.right;\n }\n\n clone(): EdgeInsets {\n return new EdgeInsets(this.top, this.bottom, this.left, this.right);\n }\n\n /**\n * Returns the current state as json, useful when you want to have a\n * read-only representation of the inset.\n *\n * @returns state as json\n */\n toJSON(): PaddingOptions {\n return {\n top: this.top,\n bottom: this.bottom,\n left: this.left,\n right: this.right\n };\n }\n}\n\n/**\n * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be\n * non-negative integers.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n *\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: 20\n * });\n * ```\n * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)\n * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)\n */\nexport type PaddingOptions = {\n /**\n * Padding in pixels from the top of the map canvas.\n */\n top: number;\n /**\n * Padding in pixels from the bottom of the map canvas.\n */\n bottom: number;\n /**\n * Padding in pixels from the left of the map canvas.\n */\n right: number;\n /**\n * Padding in pixels from the right of the map canvas.\n */\n left: number;\n};\n","import {LngLat} from './lng_lat';\nimport {LngLatBounds} from './lng_lat_bounds';\nimport {MercatorCoordinate, mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude} from './mercator_coordinate';\nimport Point from '@mapbox/point-geometry';\nimport {wrap, clamp} from '../util/util';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {EXTENT} from '../data/extent';\nimport {vec3, vec4, mat4, mat2, vec2} from 'gl-matrix';\nimport {Aabb, Frustum} from '../util/primitives';\nimport {EdgeInsets} from './edge_insets';\n\nimport {UnwrappedTileID, OverscaledTileID, CanonicalTileID} from '../source/tile_id';\nimport type {PaddingOptions} from './edge_insets';\nimport {Terrain} from '../render/terrain';\n\n/**\n * @internal\n * A single transform, generally used for a single tile to be\n * scaled, rotated, and zoomed.\n */\nexport class Transform {\n tileSize: number;\n tileZoom: number;\n lngRange: [number, number];\n latRange: [number, number];\n maxValidLatitude: number;\n scale: number;\n width: number;\n height: number;\n angle: number;\n rotationMatrix: mat2;\n pixelsToGLUnits: [number, number];\n cameraToCenterDistance: number;\n mercatorMatrix: mat4;\n projMatrix: mat4;\n invProjMatrix: mat4;\n alignedProjMatrix: mat4;\n pixelMatrix: mat4;\n pixelMatrix3D: mat4;\n pixelMatrixInverse: mat4;\n glCoordMatrix: mat4;\n labelPlaneMatrix: mat4;\n _fov: number;\n _pitch: number;\n _zoom: number;\n _unmodified: boolean;\n _renderWorldCopies: boolean;\n _minZoom: number;\n _maxZoom: number;\n _minPitch: number;\n _maxPitch: number;\n _center: LngLat;\n _elevation: number;\n _pixelPerMeter: number;\n _edgeInsets: EdgeInsets;\n _constraining: boolean;\n _posMatrixCache: {[_: string]: mat4};\n _alignedPosMatrixCache: {[_: string]: mat4};\n _minEleveationForCurrentTile: number;\n\n constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean) {\n this.tileSize = 512; // constant\n this.maxValidLatitude = 85.051129; // constant\n\n this._renderWorldCopies = renderWorldCopies === undefined ? true : !!renderWorldCopies;\n this._minZoom = minZoom || 0;\n this._maxZoom = maxZoom || 22;\n\n this._minPitch = (minPitch === undefined || minPitch === null) ? 0 : minPitch;\n this._maxPitch = (maxPitch === undefined || maxPitch === null) ? 60 : maxPitch;\n\n this.setMaxBounds();\n\n this.width = 0;\n this.height = 0;\n this._center = new LngLat(0, 0);\n this._elevation = 0;\n this.zoom = 0;\n this.angle = 0;\n this._fov = 0.6435011087932844;\n this._pitch = 0;\n this._unmodified = true;\n this._edgeInsets = new EdgeInsets();\n this._posMatrixCache = {};\n this._alignedPosMatrixCache = {};\n this._minEleveationForCurrentTile = 0;\n }\n\n clone(): Transform {\n const clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies);\n clone.apply(this);\n return clone;\n }\n\n apply(that: Transform) {\n this.tileSize = that.tileSize;\n this.latRange = that.latRange;\n this.width = that.width;\n this.height = that.height;\n this._center = that._center;\n this._elevation = that._elevation;\n this._minEleveationForCurrentTile = that._minEleveationForCurrentTile;\n this.zoom = that.zoom;\n this.angle = that.angle;\n this._fov = that._fov;\n this._pitch = that._pitch;\n this._unmodified = that._unmodified;\n this._edgeInsets = that._edgeInsets.clone();\n this._calcMatrices();\n }\n\n get minZoom(): number { return this._minZoom; }\n set minZoom(zoom: number) {\n if (this._minZoom === zoom) return;\n this._minZoom = zoom;\n this.zoom = Math.max(this.zoom, zoom);\n }\n\n get maxZoom(): number { return this._maxZoom; }\n set maxZoom(zoom: number) {\n if (this._maxZoom === zoom) return;\n this._maxZoom = zoom;\n this.zoom = Math.min(this.zoom, zoom);\n }\n\n get minPitch(): number { return this._minPitch; }\n set minPitch(pitch: number) {\n if (this._minPitch === pitch) return;\n this._minPitch = pitch;\n this.pitch = Math.max(this.pitch, pitch);\n }\n\n get maxPitch(): number { return this._maxPitch; }\n set maxPitch(pitch: number) {\n if (this._maxPitch === pitch) return;\n this._maxPitch = pitch;\n this.pitch = Math.min(this.pitch, pitch);\n }\n\n get renderWorldCopies(): boolean { return this._renderWorldCopies; }\n set renderWorldCopies(renderWorldCopies: boolean) {\n if (renderWorldCopies === undefined) {\n renderWorldCopies = true;\n } else if (renderWorldCopies === null) {\n renderWorldCopies = false;\n }\n\n this._renderWorldCopies = renderWorldCopies;\n }\n\n get worldSize(): number {\n return this.tileSize * this.scale;\n }\n\n get centerOffset(): Point {\n return this.centerPoint._sub(this.size._div(2));\n }\n\n get size(): Point {\n return new Point(this.width, this.height);\n }\n\n get bearing(): number {\n return -this.angle / Math.PI * 180;\n }\n set bearing(bearing: number) {\n const b = -wrap(bearing, -180, 180) * Math.PI / 180;\n if (this.angle === b) return;\n this._unmodified = false;\n this.angle = b;\n this._calcMatrices();\n\n // 2x2 matrix for rotating points\n this.rotationMatrix = mat2.create();\n mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);\n }\n\n get pitch(): number {\n return this._pitch / Math.PI * 180;\n }\n set pitch(pitch: number) {\n const p = clamp(pitch, this.minPitch, this.maxPitch) / 180 * Math.PI;\n if (this._pitch === p) return;\n this._unmodified = false;\n this._pitch = p;\n this._calcMatrices();\n }\n\n get fov(): number {\n return this._fov / Math.PI * 180;\n }\n set fov(fov: number) {\n fov = Math.max(0.01, Math.min(60, fov));\n if (this._fov === fov) return;\n this._unmodified = false;\n this._fov = fov / 180 * Math.PI;\n this._calcMatrices();\n }\n\n get zoom(): number { return this._zoom; }\n set zoom(zoom: number) {\n const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);\n if (this._zoom === constrainedZoom) return;\n this._unmodified = false;\n this._zoom = constrainedZoom;\n this.tileZoom = Math.max(0, Math.floor(constrainedZoom));\n this.scale = this.zoomScale(constrainedZoom);\n this._constrain();\n this._calcMatrices();\n }\n\n get center(): LngLat { return this._center; }\n set center(center: LngLat) {\n if (center.lat === this._center.lat && center.lng === this._center.lng) return;\n this._unmodified = false;\n this._center = center;\n this._constrain();\n this._calcMatrices();\n }\n\n get elevation(): number { return this._elevation; }\n set elevation(elevation: number) {\n if (elevation === this._elevation) return;\n this._elevation = elevation;\n this._constrain();\n this._calcMatrices();\n }\n\n get padding(): PaddingOptions { return this._edgeInsets.toJSON(); }\n set padding(padding: PaddingOptions) {\n if (this._edgeInsets.equals(padding)) return;\n this._unmodified = false;\n //Update edge-insets inplace\n this._edgeInsets.interpolate(this._edgeInsets, padding, 1);\n this._calcMatrices();\n }\n\n /**\n * The center of the screen in pixels with the top-left corner being (0,0)\n * and +y axis pointing downwards. This accounts for padding.\n */\n get centerPoint(): Point {\n return this._edgeInsets.getCenter(this.width, this.height);\n }\n\n /**\n * Returns if the padding params match\n *\n * @param padding - the padding to check against\n * @returns true if they are equal, false otherwise\n */\n isPaddingEqual(padding: PaddingOptions): boolean {\n return this._edgeInsets.equals(padding);\n }\n\n /**\n * Helper method to update edge-insets in place\n *\n * @param start - the starting padding\n * @param target - the target padding\n * @param t - the step/weight\n */\n interpolatePadding(start: PaddingOptions, target: PaddingOptions, t: number) {\n this._unmodified = false;\n this._edgeInsets.interpolate(start, target, t);\n this._constrain();\n this._calcMatrices();\n }\n\n /**\n * Return a zoom level that will cover all tiles the transform\n * @param options - the options\n * @returns zoom level An integer zoom level at which all tiles will be visible.\n */\n coveringZoomLevel(options: {\n /**\n * Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.\n */\n roundZoom?: boolean;\n /**\n * Tile size, expressed in screen pixels.\n */\n tileSize: number;\n }): number {\n const z = (options.roundZoom ? Math.round : Math.floor)(\n this.zoom + this.scaleZoom(this.tileSize / options.tileSize)\n );\n // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.\n return Math.max(0, z);\n }\n\n /**\n * Return any \"wrapped\" copies of a given tile coordinate that are visible\n * in the current view.\n */\n getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) {\n const result = [new UnwrappedTileID(0, tileID)];\n if (this._renderWorldCopies) {\n const utl = this.pointCoordinate(new Point(0, 0));\n const utr = this.pointCoordinate(new Point(this.width, 0));\n const ubl = this.pointCoordinate(new Point(this.width, this.height));\n const ubr = this.pointCoordinate(new Point(0, this.height));\n const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));\n const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));\n\n // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.\n // Both sources draw outside the tile boundaries of the tile that \"contains them\" so we need\n // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.\n const extraWorldCopy = 1;\n\n for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {\n if (w === 0) continue;\n result.push(new UnwrappedTileID(w, tileID));\n }\n }\n return result;\n }\n\n /**\n * Return all coordinates that could cover this transform for a covering\n * zoom level.\n * @param options - the options\n * @returns OverscaledTileIDs\n */\n coveringTiles(\n options: {\n tileSize: number;\n minzoom?: number;\n maxzoom?: number;\n roundZoom?: boolean;\n reparseOverscaled?: boolean;\n renderWorldCopies?: boolean;\n terrain?: Terrain;\n }\n ): Array {\n let z = this.coveringZoomLevel(options);\n const actualZ = z;\n\n if (options.minzoom !== undefined && z < options.minzoom) return [];\n if (options.maxzoom !== undefined && z > options.maxzoom) z = options.maxzoom;\n\n const cameraCoord = this.pointCoordinate(this.getCameraPoint());\n const centerCoord = MercatorCoordinate.fromLngLat(this.center);\n const numTiles = Math.pow(2, z);\n const cameraPoint = [numTiles * cameraCoord.x, numTiles * cameraCoord.y, 0];\n const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];\n const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, z);\n\n // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level\n let minZoom = options.minzoom || 0;\n // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks\n if (!options.terrain && this.pitch <= 60.0 && this._edgeInsets.top < 0.1)\n minZoom = z;\n\n // There should always be a certain number of maximum zoom level tiles surrounding the center location in 2D or in front of the camera in 3D\n const radiusOfMaxLvlLodInTiles = options.terrain ? 2 / Math.min(this.tileSize, options.tileSize) * this.tileSize : 3;\n\n const newRootTile = (wrap: number): any => {\n return {\n aabb: new Aabb([wrap * numTiles, 0, 0], [(wrap + 1) * numTiles, numTiles, 0]),\n zoom: 0,\n x: 0,\n y: 0,\n wrap,\n fullyVisible: false\n };\n };\n\n // Do a depth-first traversal to find visible tiles and proper levels of detail\n const stack = [];\n const result = [];\n const maxZoom = z;\n const overscaledZ = options.reparseOverscaled ? actualZ : z;\n\n if (this._renderWorldCopies) {\n // Render copy of the globe thrice on both sides\n for (let i = 1; i <= 3; i++) {\n stack.push(newRootTile(-i));\n stack.push(newRootTile(i));\n }\n }\n\n stack.push(newRootTile(0));\n\n while (stack.length > 0) {\n const it = stack.pop();\n const x = it.x;\n const y = it.y;\n let fullyVisible = it.fullyVisible;\n\n // Visibility of a tile is not required if any of its ancestor if fully inside the frustum\n if (!fullyVisible) {\n const intersectResult = it.aabb.intersects(cameraFrustum);\n\n if (intersectResult === 0)\n continue;\n\n fullyVisible = intersectResult === 2;\n }\n\n const refPoint = options.terrain ? cameraPoint : centerPoint;\n const distanceX = it.aabb.distanceX(refPoint);\n const distanceY = it.aabb.distanceY(refPoint);\n const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));\n\n // We're using distance based heuristics to determine if a tile should be split into quadrants or not.\n // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.\n // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)\n // we can define distance thresholds for each relative level:\n // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as \"offset+2^(k+1)-2\"\n const distToSplit = radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;\n\n // Have we reached the target depth or is the tile too far away to be any split further?\n if (it.zoom === maxZoom || (longestDim > distToSplit && it.zoom >= minZoom)) {\n const dz = maxZoom - it.zoom, dx = cameraPoint[0] - 0.5 - (x << dz), dy = cameraPoint[1] - 0.5 - (y << dz);\n result.push({\n tileID: new OverscaledTileID(it.zoom === maxZoom ? overscaledZ : it.zoom, it.wrap, it.zoom, x, y),\n distanceSq: vec2.sqrLen([centerPoint[0] - 0.5 - x, centerPoint[1] - 0.5 - y]),\n // this variable is currently not used, but may be important to reduce the amount of loaded tiles\n tileDistanceToCamera: Math.sqrt(dx * dx + dy * dy)\n });\n continue;\n }\n\n for (let i = 0; i < 4; i++) {\n const childX = (x << 1) + (i % 2);\n const childY = (y << 1) + (i >> 1);\n const childZ = it.zoom + 1;\n let quadrant = it.aabb.quadrant(i);\n if (options.terrain) {\n const tileID = new OverscaledTileID(childZ, it.wrap, childZ, childX, childY);\n const minMax = options.terrain.getMinMaxElevation(tileID);\n const minElevation = minMax.minElevation ?? this.elevation;\n const maxElevation = minMax.maxElevation ?? this.elevation;\n quadrant = new Aabb(\n [quadrant.min[0], quadrant.min[1], minElevation] as vec3,\n [quadrant.max[0], quadrant.max[1], maxElevation] as vec3\n );\n }\n stack.push({aabb: quadrant, zoom: childZ, x: childX, y: childY, wrap: it.wrap, fullyVisible});\n }\n }\n\n return result.sort((a, b) => a.distanceSq - b.distanceSq).map(a => a.tileID);\n }\n\n resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n this.pixelsToGLUnits = [2 / width, -2 / height];\n this._constrain();\n this._calcMatrices();\n }\n\n get unmodified(): boolean { return this._unmodified; }\n\n zoomScale(zoom: number) { return Math.pow(2, zoom); }\n scaleZoom(scale: number) { return Math.log(scale) / Math.LN2; }\n\n project(lnglat: LngLat) {\n const lat = clamp(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude);\n return new Point(\n mercatorXfromLng(lnglat.lng) * this.worldSize,\n mercatorYfromLat(lat) * this.worldSize);\n }\n\n unproject(point: Point): LngLat {\n return new MercatorCoordinate(point.x / this.worldSize, point.y / this.worldSize).toLngLat();\n }\n\n get point(): Point { return this.project(this.center); }\n\n /**\n * get the camera position in LngLat and altitudes in meter\n * @returns An object with lngLat & altitude.\n */\n getCameraPosition(): {\n lngLat: LngLat;\n altitude: number;\n } {\n const lngLat = this.pointLocation(this.getCameraPoint());\n const altitude = Math.cos(this._pitch) * this.cameraToCenterDistance / this._pixelPerMeter;\n return {lngLat, altitude: altitude + this.elevation};\n }\n\n /**\n * This method works in combination with freezeElevation activated.\n * freezeElevtion is enabled during map-panning because during this the camera should sit in constant height.\n * After panning finished, call this method to recalculate the zoomlevel for the current camera-height in current terrain.\n * @param terrain - the terrain\n */\n recalculateZoom(terrain: Terrain) {\n // find position the camera is looking on\n const center = this.pointLocation(this.centerPoint, terrain);\n const elevation = terrain.getElevationForLngLatZoom(center, this.tileZoom);\n const deltaElevation = this.elevation - elevation;\n if (!deltaElevation) return;\n\n // calculate mercator distance between camera & target\n const cameraPosition = this.getCameraPosition();\n const camera = MercatorCoordinate.fromLngLat(cameraPosition.lngLat, cameraPosition.altitude);\n const target = MercatorCoordinate.fromLngLat(center, elevation);\n const dx = camera.x - target.x, dy = camera.y - target.y, dz = camera.z - target.z;\n const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);\n\n // from this distance we calculate the new zoomlevel\n const zoom = this.scaleZoom(this.cameraToCenterDistance / distance / this.tileSize);\n\n // update matrices\n this._elevation = elevation;\n this._center = center;\n this.zoom = zoom;\n }\n\n setLocationAtPoint(lnglat: LngLat, point: Point) {\n const a = this.pointCoordinate(point);\n const b = this.pointCoordinate(this.centerPoint);\n const loc = this.locationCoordinate(lnglat);\n const newCenter = new MercatorCoordinate(\n loc.x - (a.x - b.x),\n loc.y - (a.y - b.y));\n this.center = this.coordinateLocation(newCenter);\n if (this._renderWorldCopies) {\n this.center = this.center.wrap();\n }\n }\n\n /**\n * Given a location, return the screen point that corresponds to it\n * @param lnglat - location\n * @param terrain - optional terrain\n * @returns screen point\n */\n locationPoint(lnglat: LngLat, terrain?: Terrain): Point {\n return terrain ?\n this.coordinatePoint(this.locationCoordinate(lnglat), terrain.getElevationForLngLatZoom(lnglat, this.tileZoom), this.pixelMatrix3D) :\n this.coordinatePoint(this.locationCoordinate(lnglat));\n }\n\n /**\n * Given a point on screen, return its lnglat\n * @param p - screen point\n * @param terrain - optional terrain\n * @returns lnglat location\n */\n pointLocation(p: Point, terrain?: Terrain): LngLat {\n return this.coordinateLocation(this.pointCoordinate(p, terrain));\n }\n\n /**\n * Given a geographical lnglat, return an unrounded\n * coordinate that represents it at this transform's zoom level.\n * @param lnglat - the location\n * @returns The mercator coordinate\n */\n locationCoordinate(lnglat: LngLat): MercatorCoordinate {\n return MercatorCoordinate.fromLngLat(lnglat);\n }\n\n /**\n * Given a Coordinate, return its geographical position.\n * @param coord - mercator coordivates\n * @returns lng and lat\n */\n coordinateLocation(coord: MercatorCoordinate): LngLat {\n return coord && coord.toLngLat();\n }\n\n /**\n * Given a Point, return its mercator coordinate.\n * @param p - the point\n * @param terrain - optional terrain\n * @returns lnglat\n */\n pointCoordinate(p: Point, terrain?: Terrain): MercatorCoordinate {\n // get point-coordinate from terrain coordinates framebuffer\n if (terrain) {\n const coordinate = terrain.pointCoordinate(p);\n if (coordinate != null) {\n return coordinate;\n }\n }\n\n // calculate point-coordinate on flat earth\n const targetZ = 0;\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that\n // line with z=0\n\n const coord0 = [p.x, p.y, 0, 1] as any;\n const coord1 = [p.x, p.y, 1, 1] as any;\n\n vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);\n vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);\n\n const w0 = coord0[3];\n const w1 = coord1[3];\n const x0 = coord0[0] / w0;\n const x1 = coord1[0] / w1;\n const y0 = coord0[1] / w0;\n const y1 = coord1[1] / w1;\n const z0 = coord0[2] / w0;\n const z1 = coord1[2] / w1;\n\n const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);\n\n return new MercatorCoordinate(\n interpolates.number(x0, x1, t) / this.worldSize,\n interpolates.number(y0, y1, t) / this.worldSize);\n }\n\n /**\n * Given a coordinate, return the screen point that corresponds to it\n * @param coord - the coordinates\n * @param elevation - the elevation\n * @param pixelMatrix - the pixel matrix\n * @returns screen point\n */\n coordinatePoint(coord: MercatorCoordinate, elevation: number = 0, pixelMatrix = this.pixelMatrix): Point {\n const p = [coord.x * this.worldSize, coord.y * this.worldSize, elevation, 1] as any;\n vec4.transformMat4(p, p, pixelMatrix);\n return new Point(p[0] / p[3], p[1] / p[3]);\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds.\n */\n getBounds(): LngLatBounds {\n const top = Math.max(0, this.height / 2 - this.getHorizon());\n return new LngLatBounds()\n .extend(this.pointLocation(new Point(0, top)))\n .extend(this.pointLocation(new Point(this.width, top)))\n .extend(this.pointLocation(new Point(this.width, this.height)))\n .extend(this.pointLocation(new Point(0, this.height)));\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns max bounds\n */\n getMaxBounds(): LngLatBounds | null {\n if (!this.latRange || this.latRange.length !== 2 ||\n !this.lngRange || this.lngRange.length !== 2) return null;\n\n return new LngLatBounds([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]);\n }\n\n /**\n * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),\n * multiplied by a static factor to simulate the earth-radius.\n * The calculated value is the horizontal line from the camera-height to sea-level.\n * @returns Horizon above center in pixels.\n */\n getHorizon(): number {\n return Math.tan(Math.PI / 2 - this._pitch) * this.cameraToCenterDistance * 0.85;\n }\n\n /**\n * Sets or clears the map's geographical constraints.\n * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map.\n */\n setMaxBounds(bounds?: LngLatBounds | null) {\n if (bounds) {\n this.lngRange = [bounds.getWest(), bounds.getEast()];\n this.latRange = [bounds.getSouth(), bounds.getNorth()];\n this._constrain();\n } else {\n this.lngRange = null;\n this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];\n }\n }\n\n /**\n * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map.\n * @param unwrappedTileID - the tile ID\n */\n calculatePosMatrix(unwrappedTileID: UnwrappedTileID, aligned: boolean = false): mat4 {\n const posMatrixKey = unwrappedTileID.key;\n const cache = aligned ? this._alignedPosMatrixCache : this._posMatrixCache;\n if (cache[posMatrixKey]) {\n return cache[posMatrixKey];\n }\n\n const canonical = unwrappedTileID.canonical;\n const scale = this.worldSize / this.zoomScale(canonical.z);\n const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;\n\n const posMatrix = mat4.identity(new Float64Array(16) as any);\n mat4.translate(posMatrix, posMatrix, [unwrappedX * scale, canonical.y * scale, 0]);\n mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);\n mat4.multiply(posMatrix, aligned ? this.alignedProjMatrix : this.projMatrix, posMatrix);\n\n cache[posMatrixKey] = new Float32Array(posMatrix);\n return cache[posMatrixKey];\n }\n\n customLayerMatrix(): mat4 {\n return this.mercatorMatrix.slice() as any;\n }\n\n _constrain() {\n if (!this.center || !this.width || !this.height || this._constraining) return;\n\n this._constraining = true;\n\n let minY = -90;\n let maxY = 90;\n let minX = -180;\n let maxX = 180;\n let sy, sx, x2, y2;\n const size = this.size,\n unmodified = this._unmodified;\n\n if (this.latRange) {\n const latRange = this.latRange;\n minY = mercatorYfromLat(latRange[1]) * this.worldSize;\n maxY = mercatorYfromLat(latRange[0]) * this.worldSize;\n sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;\n }\n\n if (this.lngRange) {\n const lngRange = this.lngRange;\n\n minX = wrap(\n mercatorXfromLng(lngRange[0]) * this.worldSize,\n 0,\n this.worldSize\n );\n maxX = wrap(\n mercatorXfromLng(lngRange[1]) * this.worldSize,\n 0,\n this.worldSize\n );\n\n if (maxX < minX) maxX += this.worldSize;\n\n sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;\n }\n\n const point = this.point;\n\n // how much the map should scale to fit the screen into given latitude/longitude ranges\n const s = Math.max(sx || 0, sy || 0);\n\n if (s) {\n this.center = this.unproject(new Point(\n sx ? (maxX + minX) / 2 : point.x,\n sy ? (maxY + minY) / 2 : point.y));\n this.zoom += this.scaleZoom(s);\n this._unmodified = unmodified;\n this._constraining = false;\n return;\n }\n\n if (this.latRange) {\n const y = point.y,\n h2 = size.y / 2;\n\n if (y - h2 < minY) y2 = minY + h2;\n if (y + h2 > maxY) y2 = maxY - h2;\n }\n\n if (this.lngRange) {\n const centerX = (minX + maxX) / 2;\n const x = wrap(point.x, centerX - this.worldSize / 2, centerX + this.worldSize / 2);\n const w2 = size.x / 2;\n\n if (x - w2 < minX) x2 = minX + w2;\n if (x + w2 > maxX) x2 = maxX - w2;\n }\n\n // pan the map if the screen goes off the range\n if (x2 !== undefined || y2 !== undefined) {\n this.center = this.unproject(new Point(\n x2 !== undefined ? x2 : point.x,\n y2 !== undefined ? y2 : point.y)).wrap();\n }\n\n this._unmodified = unmodified;\n this._constraining = false;\n }\n\n _calcMatrices() {\n if (!this.height) return;\n\n const halfFov = this._fov / 2;\n const offset = this.centerOffset;\n const x = this.point.x, y = this.point.y;\n this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;\n this._pixelPerMeter = mercatorZfromAltitude(1, this.center.lat) * this.worldSize;\n\n let m = mat4.identity(new Float64Array(16) as any);\n mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);\n mat4.translate(m, m, [1, -1, 0]);\n this.labelPlaneMatrix = m;\n\n m = mat4.identity(new Float64Array(16) as any);\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [-1, -1, 0]);\n mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);\n this.glCoordMatrix = m;\n\n // Calculate the camera to sea-level distance in pixel in respect of terrain\n const cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch);\n // In case of negative minimum elevation (e.g. the dead see, under the sea maps) use a lower plane for calculation\n const minElevation = Math.min(this.elevation, this._minEleveationForCurrentTile);\n const cameraToLowestPointDistance = cameraToSeaLevelDistance - minElevation * this._pixelPerMeter / Math.cos(this._pitch);\n const lowestPlane = minElevation < 0 ? cameraToLowestPointDistance : cameraToSeaLevelDistance;\n\n // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the\n // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.\n // 1 Z unit is equivalent to 1 horizontal px at the center of the map\n // (the distance between[width/2, height/2] and [width/2 + 1, height/2])\n const groundAngle = Math.PI / 2 + this._pitch;\n const fovAboveCenter = this._fov * (0.5 + offset.y / this.height);\n const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));\n\n // Find the distance from the center point to the horizon\n const horizon = this.getHorizon();\n const horizonAngle = Math.atan(horizon / this.cameraToCenterDistance);\n const fovCenterToHorizon = 2 * horizonAngle * (0.5 + offset.y / (horizon * 2));\n const topHalfSurfaceDistanceHorizon = Math.sin(fovCenterToHorizon) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovCenterToHorizon, 0.01, Math.PI - 0.01));\n\n // Calculate z distance of the farthest fragment that should be rendered.\n // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n const topHalfMinDistance = Math.min(topHalfSurfaceDistance, topHalfSurfaceDistanceHorizon);\n const farZ = (Math.cos(Math.PI / 2 - this._pitch) * topHalfMinDistance + lowestPlane) * 1.01;\n\n // The larger the value of nearZ is\n // - the more depth precision is available for features (good)\n // - clipping starts appearing sooner when the camera is close to 3d features (bad)\n //\n // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues\n // when rendering it's layers using custom layers. This value was experimentally chosen and\n // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.\n const nearZ = this.height / 50;\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n m = new Float64Array(16) as any;\n mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);\n\n // Apply center of perspective offset\n m[8] = -offset.x * 2 / this.width;\n m[9] = offset.y * 2 / this.height;\n\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);\n mat4.rotateX(m, m, this._pitch);\n mat4.rotateZ(m, m, this.angle);\n mat4.translate(m, m, [-x, -y, 0]);\n\n // The mercatorMatrix can be used to transform points from mercator coordinates\n // ([0, 0] nw, [1, 1] se) to GL coordinates.\n this.mercatorMatrix = mat4.scale([] as any, m, [this.worldSize, this.worldSize, this.worldSize]);\n\n // scale vertically to meters per pixel (inverse of ground resolution):\n mat4.scale(m, m, [1, 1, this._pixelPerMeter]);\n\n // matrix for conversion from location to screen coordinates in 2D\n this.pixelMatrix = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n mat4.translate(m, m, [0, 0, -this.elevation]); // elevate camera over terrain\n this.projMatrix = m;\n this.invProjMatrix = mat4.invert([] as any, m);\n\n // matrix for conversion from location to screen coordinates in 2D\n this.pixelMatrix3D = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);\n\n // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.\n // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional\n // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension\n // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle\n // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that\n // it is always <= 0.5 pixels.\n const xShift = (this.width % 2) / 2, yShift = (this.height % 2) / 2,\n angleCos = Math.cos(this.angle), angleSin = Math.sin(this.angle),\n dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift,\n dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;\n const alignedM = new Float64Array(m) as any as mat4;\n mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);\n this.alignedProjMatrix = alignedM;\n\n // inverse matrix for conversion from screen coordinaes to location\n m = mat4.invert(new Float64Array(16) as any, this.pixelMatrix);\n if (!m) throw new Error('failed to invert matrix');\n this.pixelMatrixInverse = m;\n\n this._posMatrixCache = {};\n this._alignedPosMatrixCache = {};\n }\n\n maxPitchScaleFactor() {\n // calcMatrices hasn't run yet\n if (!this.pixelMatrixInverse) return 1;\n\n const coord = this.pointCoordinate(new Point(0, 0));\n const p = [coord.x * this.worldSize, coord.y * this.worldSize, 0, 1] as vec4;\n const topPoint = vec4.transformMat4(p, p, this.pixelMatrix);\n return topPoint[3] / this.cameraToCenterDistance;\n }\n\n /**\n * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`\n * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).\n * `cameraPoint` is the projected position of the `cameraLocation`.\n *\n * This point is useful to us because only fill-extrusions that are between `cameraPoint` and\n * the query point on the surface of the earth can extend and intersect the query.\n *\n * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because\n * the camera is right above the center of the map.\n */\n getCameraPoint() {\n const pitch = this._pitch;\n const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);\n return this.centerPoint.add(new Point(0, yOffset));\n }\n\n /**\n * When the map is pitched, some of the 3D features that intersect a query will not intersect\n * the query at the surface of the earth. Instead the feature may be closer and only intersect\n * the query because it extrudes into the air.\n * @param queryGeometry - For point queries, the line from the query point to the \"camera point\",\n * for other geometries, the envelope of the query geometry and the \"camera point\"\n * @returns a geometry that includes all of the original query as well as all possible ares of the\n * screen where the *base* of a visible extrusion could be.\n *\n */\n getCameraQueryGeometry(queryGeometry: Array): Array {\n const c = this.getCameraPoint();\n\n if (queryGeometry.length === 1) {\n return [queryGeometry[0], c];\n } else {\n let minX = c.x;\n let minY = c.y;\n let maxX = c.x;\n let maxY = c.y;\n for (const p of queryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return [\n new Point(minX, minY),\n new Point(maxX, minY),\n new Point(maxX, maxY),\n new Point(minX, maxY),\n new Point(minX, minY)\n ];\n }\n }\n}\n","import * as glMatrix from \"./common.js\";\n/**\n * 2x2 Matrix\n * @module mat2\n */\n\n/**\n * Creates a new identity mat2\n *\n * @returns {mat2} a new 2x2 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n }\n\n out[0] = 1;\n out[3] = 1;\n return out;\n}\n/**\n * Creates a new mat2 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat2} a matrix to clone\n * @returns {mat2} a new 2x2 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Copy the values from one mat2 to another\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set a mat2 to the identity matrix\n *\n * @param {mat2} out the receiving matrix\n * @returns {mat2} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n}\n/**\n * Create a new mat2 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out A new 2x2 matrix\n */\n\nexport function fromValues(m00, m01, m10, m11) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n/**\n * Set the components of a mat2 to the given values\n *\n * @param {mat2} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out\n */\n\nexport function set(out, m00, m01, m10, m11) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n/**\n * Transpose the values of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache\n // some values\n if (out === a) {\n var a1 = a[1];\n out[1] = a[2];\n out[2] = a1;\n } else {\n out[0] = a[0];\n out[1] = a[2];\n out[2] = a[1];\n out[3] = a[3];\n }\n\n return out;\n}\n/**\n * Inverts a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function invert(out, a) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3]; // Calculate the determinant\n\n var det = a0 * a3 - a2 * a1;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = a3 * det;\n out[1] = -a1 * det;\n out[2] = -a2 * det;\n out[3] = a0 * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function adjoint(out, a) {\n // Caching this value is nessecary if out == a\n var a0 = a[0];\n out[0] = a[3];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a0;\n return out;\n}\n/**\n * Calculates the determinant of a mat2\n *\n * @param {ReadonlyMat2} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n return a[0] * a[3] - a[2] * a[1];\n}\n/**\n * Multiplies two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function multiply(out, a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = a0 * b0 + a2 * b1;\n out[1] = a1 * b0 + a3 * b1;\n out[2] = a0 * b2 + a2 * b3;\n out[3] = a1 * b2 + a3 * b3;\n return out;\n}\n/**\n * Rotates a mat2 by the given angle\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\n\nexport function rotate(out, a, rad) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = a0 * c + a2 * s;\n out[1] = a1 * c + a3 * s;\n out[2] = a0 * -s + a2 * c;\n out[3] = a1 * -s + a3 * c;\n return out;\n}\n/**\n * Scales the mat2 by the dimensions in the given vec2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to rotate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat2} out\n **/\n\nexport function scale(out, a, v) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var v0 = v[0],\n v1 = v[1];\n out[0] = a0 * v0;\n out[1] = a1 * v0;\n out[2] = a2 * v1;\n out[3] = a3 * v1;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.rotate(dest, dest, rad);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = -s;\n out[3] = c;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.scale(dest, dest, vec);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat2} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = v[1];\n return out;\n}\n/**\n * Returns a string representation of a mat2\n *\n * @param {ReadonlyMat2} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat2(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat2\n *\n * @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3]);\n}\n/**\n * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix\n * @param {ReadonlyMat2} L the lower triangular matrix\n * @param {ReadonlyMat2} D the diagonal matrix\n * @param {ReadonlyMat2} U the upper triangular matrix\n * @param {ReadonlyMat2} a the input matrix to factorize\n */\n\nexport function LDU(L, D, U, a) {\n L[2] = a[2] / a[0];\n U[0] = a[0];\n U[1] = a[1];\n U[3] = a[3] - L[2] * U[1];\n return [L, D, U];\n}\n/**\n * Adds two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat2} a The first matrix.\n * @param {ReadonlyMat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat2} a The first matrix.\n * @param {ReadonlyMat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat2} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two mat2's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat2} out the receiving vector\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat2} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Alias for {@link mat2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat2.subtract}\n * @function\n */\n\nexport var sub = subtract;","/**\n * Throttle the given function to run at most every `period` milliseconds.\n */\nexport function throttle void>(fn: T, time: number): (...args: Parameters) => ReturnType {\n let pending = false;\n let timerId: ReturnType = null;\n let lastCallContext = null;\n let lastCallArgs: Parameters;\n\n const later = () => {\n timerId = null;\n if (pending) {\n fn.apply(lastCallContext, lastCallArgs);\n timerId = setTimeout(later, time);\n pending = false;\n }\n };\n\n return (...args: Parameters) => {\n pending = true;\n lastCallContext = this;\n lastCallArgs = args;\n if (!timerId) {\n later();\n }\n return timerId;\n };\n}\n","import {throttle} from '../util/throttle';\n\nimport type {Map} from './map';\n\n/**\n * Adds the map's position to its page's location hash.\n * Passed as an option to the map object.\n *\n * @group Markers and Controls\n */\nexport class Hash {\n _map: Map;\n _hashName: string;\n\n constructor(hashName?: string | null) {\n this._hashName = hashName && encodeURIComponent(hashName);\n }\n\n /**\n * Map element to listen for coordinate changes\n *\n * @param map - The map object\n * @returns `this`\n */\n addTo(map: Map) {\n this._map = map;\n addEventListener('hashchange', this._onHashChange, false);\n this._map.on('moveend', this._updateHash);\n return this;\n }\n\n /**\n * Removes hash\n *\n * @returns `this`\n */\n remove() {\n removeEventListener('hashchange', this._onHashChange, false);\n this._map.off('moveend', this._updateHash);\n clearTimeout(this._updateHash());\n\n delete this._map;\n return this;\n }\n\n getHashString(mapFeedback?: boolean) {\n const center = this._map.getCenter(),\n zoom = Math.round(this._map.getZoom() * 100) / 100,\n // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px\n precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10),\n m = Math.pow(10, precision),\n lng = Math.round(center.lng * m) / m,\n lat = Math.round(center.lat * m) / m,\n bearing = this._map.getBearing(),\n pitch = this._map.getPitch();\n let hash = '';\n if (mapFeedback) {\n // new map feedback site has some constraints that don't allow\n // us to use the same hash format as we do for the Map hash option.\n hash += `/${lng}/${lat}/${zoom}`;\n } else {\n hash += `${zoom}/${lat}/${lng}`;\n }\n\n if (bearing || pitch) hash += (`/${Math.round(bearing * 10) / 10}`);\n if (pitch) hash += (`/${Math.round(pitch)}`);\n\n if (this._hashName) {\n const hashName = this._hashName;\n let found = false;\n const parts = window.location.hash.slice(1).split('&').map(part => {\n const key = part.split('=')[0];\n if (key === hashName) {\n found = true;\n return `${key}=${hash}`;\n }\n return part;\n }).filter(a => a);\n if (!found) {\n parts.push(`${hashName}=${hash}`);\n }\n return `#${parts.join('&')}`;\n }\n\n return `#${hash}`;\n }\n\n _getCurrentHash = () => {\n // Get the current hash from location, stripped from its number sign\n const hash = window.location.hash.replace('#', '');\n if (this._hashName) {\n // Split the parameter-styled hash into parts and find the value we need\n let keyval;\n hash.split('&').map(\n part => part.split('=')\n ).forEach(part => {\n if (part[0] === this._hashName) {\n keyval = part;\n }\n });\n return (keyval ? keyval[1] || '' : '').split('/');\n }\n return hash.split('/');\n };\n\n _onHashChange = () => {\n const loc = this._getCurrentHash();\n if (loc.length >= 3 && !loc.some(v => isNaN(v))) {\n const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this._map.getBearing();\n this._map.jumpTo({\n center: [+loc[2], +loc[1]],\n zoom: +loc[0],\n bearing,\n pitch: +(loc[4] || 0)\n });\n return true;\n }\n return false;\n };\n\n _updateHashUnthrottled = () => {\n // Replace if already present, else append the updated hash string\n const location = window.location.href.replace(/(#.+)?$/, this.getHashString());\n try {\n window.history.replaceState(window.history.state, null, location);\n } catch (SecurityError) {\n // IE11 does not allow this if the page is within an iframe created\n // with iframe.contentWindow.document.write(...).\n // https://github.com/mapbox/mapbox-gl-js/issues/7410\n }\n };\n\n /**\n * Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.\n */\n _updateHash: () => ReturnType = throttle(this._updateHashUnthrottled, 30 * 1000 / 100);\n}\n","import {browser} from '../util/browser';\nimport type {Map} from './map';\nimport {bezier, clamp, extend} from '../util/util';\nimport Point from '@mapbox/point-geometry';\nimport type {DragPanOptions} from './handler/shim/drag_pan';\n\nconst defaultInertiaOptions = {\n linearity: 0.3,\n easing: bezier(0, 0, 0.3, 1),\n};\n\nconst defaultPanInertiaOptions = extend({\n deceleration: 2500,\n maxSpeed: 1400\n}, defaultInertiaOptions);\n\nconst defaultZoomInertiaOptions = extend({\n deceleration: 20,\n maxSpeed: 1400\n}, defaultInertiaOptions);\n\nconst defaultBearingInertiaOptions = extend({\n deceleration: 1000,\n maxSpeed: 360\n}, defaultInertiaOptions);\n\nconst defaultPitchInertiaOptions = extend({\n deceleration: 1000,\n maxSpeed: 90\n}, defaultInertiaOptions);\n\nexport type InertiaOptions = {\n linearity: number;\n easing: (t: number) => number;\n deceleration: number;\n maxSpeed: number;\n};\n\nexport type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;\n\nexport class HandlerInertia {\n _map: Map;\n _inertiaBuffer: Array<{\n time: number;\n settings: any;\n }>;\n\n constructor(map: Map) {\n this._map = map;\n this.clear();\n }\n\n clear() {\n this._inertiaBuffer = [];\n }\n\n record(settings: any) {\n this._drainInertiaBuffer();\n this._inertiaBuffer.push({time: browser.now(), settings});\n }\n\n _drainInertiaBuffer() {\n const inertia = this._inertiaBuffer,\n now = browser.now(),\n cutoff = 160; //msec\n\n while (inertia.length > 0 && now - inertia[0].time > cutoff)\n inertia.shift();\n }\n\n _onMoveEnd(panInertiaOptions?: DragPanOptions | boolean) {\n this._drainInertiaBuffer();\n if (this._inertiaBuffer.length < 2) {\n return;\n }\n\n const deltas = {\n zoom: 0,\n bearing: 0,\n pitch: 0,\n pan: new Point(0, 0),\n pinchAround: undefined,\n around: undefined\n };\n\n for (const {settings} of this._inertiaBuffer) {\n deltas.zoom += settings.zoomDelta || 0;\n deltas.bearing += settings.bearingDelta || 0;\n deltas.pitch += settings.pitchDelta || 0;\n if (settings.panDelta) deltas.pan._add(settings.panDelta);\n if (settings.around) deltas.around = settings.around;\n if (settings.pinchAround) deltas.pinchAround = settings.pinchAround;\n }\n\n const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1];\n const duration = (lastEntry.time - this._inertiaBuffer[0].time);\n\n const easeOptions = {} as any;\n\n if (deltas.pan.mag()) {\n const result = calculateEasing(deltas.pan.mag(), duration, extend({}, defaultPanInertiaOptions, panInertiaOptions || {}));\n easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());\n easeOptions.center = this._map.transform.center;\n extendDuration(easeOptions, result);\n }\n\n if (deltas.zoom) {\n const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);\n easeOptions.zoom = this._map.transform.zoom + result.amount;\n extendDuration(easeOptions, result);\n }\n\n if (deltas.bearing) {\n const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);\n easeOptions.bearing = this._map.transform.bearing + clamp(result.amount, -179, 179);\n extendDuration(easeOptions, result);\n }\n\n if (deltas.pitch) {\n const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);\n easeOptions.pitch = this._map.transform.pitch + result.amount;\n extendDuration(easeOptions, result);\n }\n\n if (easeOptions.zoom || easeOptions.bearing) {\n const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;\n easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter();\n }\n\n this.clear();\n return extend(easeOptions, {\n noMoveStart: true\n });\n\n }\n}\n\n// Unfortunately zoom, bearing, etc can't have different durations and easings so\n// we need to choose one. We use the longest duration and it's corresponding easing.\nfunction extendDuration(easeOptions, result) {\n if (!easeOptions.duration || easeOptions.duration < result.duration) {\n easeOptions.duration = result.duration;\n easeOptions.easing = result.easing;\n }\n}\n\nfunction calculateEasing(amount, inertiaDuration: number, inertiaOptions) {\n const {maxSpeed, linearity, deceleration} = inertiaOptions;\n const speed = clamp(\n amount * linearity / (inertiaDuration / 1000),\n -maxSpeed,\n maxSpeed);\n const duration = Math.abs(speed) / (deceleration * linearity);\n return {\n easing: inertiaOptions.easing,\n duration: duration * 1000,\n amount: speed * (duration / 2)\n };\n}\n","import {Event} from '../util/evented';\n\nimport {DOM} from '../util/dom';\nimport Point from '@mapbox/point-geometry';\nimport {extend} from '../util/util';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\n\nimport type {Map} from './map';\nimport type {LngLat} from '../geo/lng_lat';\nimport {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * An event from the mouse relevant to a specific layer.\n *\n * @group Event Related\n */\nexport type MapLayerMouseEvent = MapMouseEvent & { features?: MapGeoJSONFeature[] };\n\n/**\n * An event from a touch device relevat to a specific layer.\n *\n * @group Event Related\n */\nexport type MapLayerTouchEvent = MapTouchEvent & { features?: MapGeoJSONFeature[] };\n\n/**\n * The source event data type\n */\nexport type MapSourceDataType = 'content' | 'metadata' | 'visibility' | 'idle';\n\n/**\n * `MapLayerEventType` - a mapping between the event name and the event.\n * **Note:** These events are compatible with the optional `layerId` parameter.\n * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the\n * event action contains a visible portion of the specified layer.\n * The following example can be used for all the events.\n *\n * @group Event Related\n * @example\n * ```ts\n * // Initialize the map\n * let map = new maplibregl.Map({ // map options });\n * // Set an event listener for a specific layer\n * map.on('the-event-name', 'poi-label', function(e) {\n * console.log('An event has occurred on a visible portion of the poi-label layer');\n * });\n * ```\n */\nexport type MapLayerEventType = {\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released contains a visible portion of the specified layer.\n *\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n click: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released twice contains a visible portion of the specified layer.\n *\n * **Note:** Under normal conditions, this event will be preceded by two `click` events.\n */\n dblclick: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed while inside a visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mousedown: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is released while inside a visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mouseup: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved while the cursor is inside a visible portion of the specified layer.\n * As you move the cursor across the layer, the event will fire every time the cursor changes position within that layer.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mousemove: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from\n * outside that layer or outside the map canvas.\n *\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n */\n mouseenter: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves\n * the map canvas.\n *\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n */\n mouseleave: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved inside a visible portion of the specified layer.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mouseover: MapLayerMouseEvent;\n /**\n * Fired when a point device (usually a mouse) leaves the visible portion of the specified layer.\n */\n mouseout: MapLayerMouseEvent;\n /**\n * Fired when the right button of the mouse is clicked or the context menu key is pressed within visible portion of the specified layer.\n */\n contextmenu: MapLayerMouseEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchstart: MapLayerTouchEvent;\n /**\n * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchend: MapLayerTouchEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchcancel: MapLayerTouchEvent;\n};\n\n/**\n * `MapEventType` - a mapping between the event name and the event value.\n * These events are used with the {@link Map#on} method.\n * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}.\n * The following example can be used for all the events.\n *\n * @group Event Related\n * @example\n * ```ts\n * // Initialize the map\n * let map = new maplibregl.Map({ // map options });\n * // Set an event listener\n * map.on('the-event-name', () => {\n * console.log('An event has occurred!');\n * });\n * ```\n */\nexport type MapEventType = {\n /**\n * Fired when an error occurs. This is GL JS's primary error reporting\n * mechanism. We use an event instead of `throw` to better accommodate\n * asynchronous operations. If no listeners are bound to the `error` event, the\n * error will be printed to the console.\n */\n error: ErrorEvent;\n /**\n * @event `load` Fired immediately after all necessary resources have been downloaded\n * and the first visually complete rendering of the map has occurred.\n *\n * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)\n * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)\n */\n load: MapLibreEvent;\n /**\n * Fired after the last frame rendered before the map enters an\n * \"idle\" state:\n *\n * - No camera transitions are in progress\n * - All currently requested tiles have loaded\n * - All fade/transition animations have completed\n */\n idle: MapLibreEvent;\n /**\n * Fired immediately after the map has been removed with {@link Map#remove}.\n */\n remove: MapLibreEvent;\n /**\n * Fired whenever the map is drawn to the screen, as the result of\n *\n * - a change to the map's position, zoom, pitch, or bearing\n * - a change to the map's style\n * - a change to a GeoJSON source\n * - the loading of a vector tile, GeoJSON file, glyph, or sprite\n */\n render: MapLibreEvent;\n /**\n * Fired immediately after the map has been resized.\n */\n resize: MapLibreEvent;\n /**\n * Fired when the WebGL context is lost.\n */\n webglcontextlost: MapContextEvent;\n /**\n * Fired when the WebGL context is restored.\n */\n webglcontextrestored: MapContextEvent;\n /**\n * Fired when any map data (style, source, tile, etc) begins loading or\n * changing asynchronously. All `dataloading` events are followed by a `data`,\n * `dataabort` or `error` event.\n */\n dataloading: MapDataEvent;\n /**\n * Fired when any map data loads or changes. See {@link MapDataEvent} for more information.\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n data: MapDataEvent;\n tiledataloading: MapDataEvent;\n /**\n * Fired when one of the map's sources begins loading or changing asynchronously.\n * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event.\n */\n sourcedataloading: MapSourceDataEvent;\n /**\n * Fired when the map's style begins loading or changing asynchronously.\n * All `styledataloading` events are followed by a `styledata`\n * or `error` event.\n */\n styledataloading: MapStyleDataEvent;\n /**\n * Fired when one of the map's sources loads or changes, including if a tile belonging\n * to a source loads or changes.\n */\n sourcedata: MapSourceDataEvent;\n /**\n * Fired when the map's style loads or changes.\n */\n styledata: MapStyleDataEvent;\n /**\n * Fired when an icon or pattern needed by the style is missing. The missing image can\n * be added with {@link Map#addImage} within this event listener callback to prevent the image from\n * being skipped. This event can be used to dynamically generate icons and patterns.\n * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n */\n styleimagemissing: MapStyleImageMissingEvent;\n /**\n * Fired when a request for one of the map's sources' tiles or data is aborted.\n */\n dataabort: MapDataEvent;\n /**\n * Fired when a request for one of the map's sources' data is aborted.\n */\n sourcedataabort: MapSourceDataEvent;\n /**\n * Fired when the user cancels a \"box zoom\" interaction, or when the bounding box does not meet the minimum size threshold.\n * See {@link BoxZoomHandler}.\n */\n boxzoomcancel: MapLibreZoomEvent;\n /**\n * Fired when a \"box zoom\" interaction starts. See {@link BoxZoomHandler}.\n */\n boxzoomstart: MapLibreZoomEvent;\n /**\n * Fired when a \"box zoom\" interaction ends. See {@link BoxZoomHandler}.\n */\n boxzoomend: MapLibreZoomEvent;\n /**\n * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.\n */\n touchcancel: MapTouchEvent;\n /**\n * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchmove: MapTouchEvent;\n /**\n * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchend: MapTouchEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchstart: MapTouchEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.\n *\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n click: MapMouseEvent;\n /**\n * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.\n */\n contextmenu: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession.\n *\n * **Note:** Under normal conditions, this event will be preceded by two `click` events.\n */\n dblclick: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map.\n * As you move the cursor across the map, the event will fire every time the cursor changes position within the map.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mousemove: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is released within the map.\n *\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mouseup: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed within the map.\n *\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mousedown: MapMouseEvent;\n /**\n * Fired when a point device (usually a mouse) leaves the map's canvas.\n */\n mouseout: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved within the map.\n * As you move the cursor across a web page containing a map,\n * the event will fire each time it enters the map or any child elements.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mouseover: MapMouseEvent;\n /**\n * Fired just before the map begins a transition from one\n * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.\n *\n */\n movestart: MapLibreEvent;\n /**\n * Fired repeatedly during an animated transition from one view to\n * another, as the result of either user interaction or methods such as {@link Map#flyTo}.\n *\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n move: MapLibreEvent;\n /**\n * Fired just after the map completes a transition from one\n * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.\n *\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n moveend: MapLibreEvent;\n /**\n * Fired just before the map begins a transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoomstart: MapLibreEvent;\n /**\n * Fired repeatedly during an animated transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoom: MapLibreEvent;\n /**\n * Fired just after the map completes a transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoomend: MapLibreEvent;\n /**\n * Fired when a \"drag to rotate\" interaction starts. See {@link DragRotateHandler}.\n */\n rotatestart: MapLibreEvent;\n /**\n * Fired repeatedly during a \"drag to rotate\" interaction. See {@link DragRotateHandler}.\n */\n rotate: MapLibreEvent;\n /**\n * Fired when a \"drag to rotate\" interaction ends. See {@link DragRotateHandler}.\n */\n rotateend: MapLibreEvent;\n /**\n * Fired when a \"drag to pan\" interaction starts. See {@link DragPanHandler}.\n */\n dragstart: MapLibreEvent;\n /**\n * Fired repeatedly during a \"drag to pan\" interaction. See {@link DragPanHandler}.\n */\n drag: MapLibreEvent;\n /**\n * Fired when a \"drag to pan\" interaction ends. See {@link DragPanHandler}.\n * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n dragend: MapLibreEvent;\n /**\n * Fired whenever the map's pitch (tilt) begins a change as\n * the result of either user interaction or methods such as {@link Map#flyTo} .\n */\n pitchstart: MapLibreEvent;\n /**\n * Fired repeatedly during the map's pitch (tilt) animation between\n * one state and another as the result of either user interaction\n * or methods such as {@link Map#flyTo}.\n */\n pitch: MapLibreEvent;\n /**\n * Fired immediately after the map's pitch (tilt) finishes changing as\n * the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n pitchend: MapLibreEvent;\n /**\n * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.\n */\n wheel: MapWheelEvent;\n /**\n * Fired when terrain is changed\n */\n terrain: MapTerrainEvent;\n};\n\n/**\n * The base event for MapLibre\n *\n * @group Event Related\n */\nexport type MapLibreEvent = {\n type: keyof MapEventType | keyof MapLayerEventType;\n target: Map;\n originalEvent: TOrig;\n}\n\n/**\n * The style data event\n *\n * @group Event Related\n */\nexport type MapStyleDataEvent = MapLibreEvent & {\n dataType: 'style';\n}\n\n/**\n * The source data event interface\n *\n * @group Event Related\n */\nexport type MapSourceDataEvent = MapLibreEvent & {\n dataType: 'source';\n /**\n * True if the event has a `dataType` of `source` and the source has no outstanding network requests.\n */\n isSourceLoaded: boolean;\n /**\n * The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`.\n */\n source: SourceSpecification;\n sourceId: string;\n sourceDataType: MapSourceDataType;\n /**\n * The tile being loaded or changed, if the event has a `dataType` of `source` and\n * the event is related to loading of a tile.\n */\n tile: any;\n}\n/**\n * `MapMouseEvent` is the event type for mouse-related map events.\n * @example\n * ```ts\n * // The `click` event is an example of a `MapMouseEvent`.\n * // Set up an event listener on the map.\n * map.on('click', function(e) {\n * // The event object (e) contains information like the\n * // coordinates of the point on the map that was clicked.\n * console.log('A click event has occurred at ' + e.lngLat);\n * });\n * ```\n */\nexport class MapMouseEvent extends Event implements MapLibreEvent {\n /**\n * The event type\n */\n type: 'mousedown' | 'mouseup' | 'click' | 'dblclick' | 'mousemove' | 'mouseover' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'contextmenu';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: MouseEvent;\n\n /**\n * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.\n */\n point: Point;\n\n /**\n * The geographic location on the map of the mouse cursor.\n */\n lngLat: LngLat;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the following default map behaviors:\n *\n * * On `mousedown` events, the behavior of {@link DragPanHandler}\n * * On `mousedown` events, the behavior of {@link DragRotateHandler}\n * * On `mousedown` events, the behavior of {@link BoxZoomHandler}\n * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}\n *\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n constructor(type: string, map: Map, originalEvent: MouseEvent, data: any = {}) {\n const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);\n const lngLat = map.unproject(point);\n super(type, extend({point, lngLat, originalEvent}, data));\n this._defaultPrevented = false;\n this.target = map;\n }\n}\n\n/**\n * `MapTouchEvent` is the event type for touch-related map events.\n *\n * @group Event Related\n */\nexport class MapTouchEvent extends Event implements MapLibreEvent {\n /**\n * The event type.\n */\n type: 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: TouchEvent;\n\n /**\n * The geographic location on the map of the center of the touch event points.\n */\n lngLat: LngLat;\n\n /**\n * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left\n * corner.\n */\n point: Point;\n\n /**\n * The array of pixel coordinates corresponding to a\n * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.\n */\n points: Array;\n\n /**\n * The geographical locations on the map corresponding to a\n * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.\n */\n lngLats: Array;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the following default map behaviors:\n *\n * * On `touchstart` events, the behavior of {@link DragPanHandler}\n * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler}\n *\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n constructor(type: string, map: Map, originalEvent: TouchEvent) {\n const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;\n const points = DOM.touchPos(map.getCanvasContainer(), touches);\n const lngLats = points.map((t) => map.unproject(t));\n const point = points.reduce((prev, curr, i, arr) => {\n return prev.add(curr.div(arr.length));\n }, new Point(0, 0));\n const lngLat = map.unproject(point);\n super(type, {points, point, lngLats, lngLat, originalEvent});\n this._defaultPrevented = false;\n }\n}\n\n/**\n * `MapWheelEvent` is the event type for the `wheel` map event.\n *\n * @group Event Related\n */\nexport class MapWheelEvent extends Event {\n /**\n * The event type.\n */\n type: 'wheel';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: WheelEvent;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the behavior of {@link ScrollZoomHandler}.\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n /** */\n constructor(type: string, map: Map, originalEvent: WheelEvent) {\n super(type, {originalEvent});\n this._defaultPrevented = false;\n }\n}\n\n/**\n * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.\n *\n * @group Event Related\n */\nexport type MapLibreZoomEvent = {\n /**\n * The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel`\n */\n type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel';\n /**\n * The `Map` instance that triggered the event\n */\n target: Map;\n /**\n * The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent`\n */\n originalEvent: MouseEvent;\n};\n\n/**\n * A `MapDataEvent` object is emitted with the `data`\n * and `dataloading` events. Possible values for\n * `dataType`s are:\n *\n * - `'source'`: The non-tile data associated with any source\n * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map\n *\n * Possible values for `sourceDataType`s are:\n *\n * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles\n * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource)\n * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible')\n * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading)\n *\n * @group Event Related\n *\n * @example\n * ```ts\n * // The sourcedata event is an example of MapDataEvent.\n * // Set up an event listener on the map.\n * map.on('sourcedata', function(e) {\n * if (e.isSourceLoaded) {\n * // Do something when the source has finished loading\n * }\n * });\n * ```\n */\nexport type MapDataEvent = {\n /**\n * The event type.\n */\n type: string;\n /**\n * The type of data that has changed. One of `'source'`, `'style'`.\n */\n dataType: string;\n /**\n * Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`.\n */\n sourceDataType: MapSourceDataType;\n};\n\n/**\n * The terrain event\n *\n * @group Event Related\n */\nexport type MapTerrainEvent = {\n type: 'terrain';\n};\n\n/**\n * An event related to the web gl context\n *\n * @group Event Related\n */\nexport type MapContextEvent = {\n type: 'webglcontextlost' | 'webglcontextrestored';\n originalEvent: WebGLContextEvent;\n};\n\n/**\n * The style image missing event\n *\n * @group Event Related\n *\n * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n */\nexport type MapStyleImageMissingEvent = MapLibreEvent & {\n type: 'styleimagemissing';\n id: string;\n}\n","import {MapMouseEvent, MapTouchEvent, MapWheelEvent} from '../events';\nimport {Handler} from '../handler_manager';\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\n\nexport class MapEventHandler implements Handler {\n\n _mousedownPos: Point;\n _clickTolerance: number;\n _map: Map;\n\n constructor(map: Map, options: {\n clickTolerance: number;\n }) {\n this._map = map;\n this._clickTolerance = options.clickTolerance;\n }\n\n reset() {\n delete this._mousedownPos;\n }\n\n wheel(e: WheelEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - ScrollZoom\n return this._firePreventable(new MapWheelEvent(e.type, this._map, e));\n }\n\n mousedown(e: MouseEvent, point: Point) {\n this._mousedownPos = point;\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - MousePan\n // - MouseRotate\n // - MousePitch\n // - DblclickHandler\n return this._firePreventable(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseup(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n click(e: MouseEvent, point: Point) {\n if (this._mousedownPos && this._mousedownPos.dist(point) >= this._clickTolerance) return;\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n dblclick(e: MouseEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - DblClickZoom\n return this._firePreventable(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseover(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseout(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n touchstart(e: TouchEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - TouchPan\n // - TouchZoom\n // - TouchRotate\n // - TouchPitch\n // - TapZoom\n // - SwipeZoom\n return this._firePreventable(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchmove(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchend(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchcancel(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n _firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent) {\n this._map.fire(mapEvent);\n if (mapEvent.defaultPrevented) {\n // returning an object marks the handler as active and resets other handlers\n return {};\n }\n }\n\n isEnabled() {\n return true;\n }\n\n isActive() {\n return false;\n }\n enable() {}\n disable() {}\n}\n\nexport class BlockableMapEventHandler {\n _map: Map;\n _delayContextMenu: boolean;\n _ignoreContextMenu: boolean;\n _contextMenuEvent: MouseEvent;\n\n constructor(map: Map) {\n this._map = map;\n }\n\n reset() {\n this._delayContextMenu = false;\n this._ignoreContextMenu = true;\n delete this._contextMenuEvent;\n }\n\n mousemove(e: MouseEvent) {\n // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n mousedown() {\n this._delayContextMenu = true;\n this._ignoreContextMenu = false;\n }\n\n mouseup() {\n this._delayContextMenu = false;\n if (this._contextMenuEvent) {\n this._map.fire(new MapMouseEvent('contextmenu', this._map, this._contextMenuEvent));\n delete this._contextMenuEvent;\n }\n }\n contextmenu(e: MouseEvent) {\n if (this._delayContextMenu) {\n // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake\n this._contextMenuEvent = e;\n } else if (!this._ignoreContextMenu) {\n // Windows: contextmenu fired on mouseup, so fire event now\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n // prevent browser context menu when necessary\n if (this._map.listens('contextmenu')) {\n e.preventDefault();\n }\n }\n\n isEnabled() {\n return true;\n }\n\n isActive() {\n return false;\n }\n enable() {}\n disable() {}\n}\n","import type {Map} from '../map';\nimport type {PointLike} from '../camera';\nimport type {Transform} from '../../geo/transform';\nimport Point from '@mapbox/point-geometry';\nimport {LngLat} from '../../geo/lng_lat';\n\n/**\n * @internal\n * Shared utilities for the Handler classes to access the correct camera state.\n * If Camera.transformCameraUpdate is specified, the \"desired state\" of camera may differ from the state used for rendering.\n * The handlers need the \"desired state\" to track accumulated changes.\n */\nexport class TransformProvider {\n _map: Map;\n\n constructor(map: Map) {\n this._map = map;\n }\n\n get transform(): Transform {\n return this._map._requestedCameraState || this._map.transform;\n }\n\n get center() {\n return {lng: this.transform.center.lng, lat: this.transform.center.lat};\n }\n\n get zoom() {\n return this.transform.zoom;\n }\n\n get pitch() {\n return this.transform.pitch;\n }\n\n get bearing() {\n return this.transform.bearing;\n }\n\n unproject(point: PointLike): LngLat {\n return this.transform.pointLocation(Point.convert(point), this._map.terrain);\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport {Event} from '../../util/evented';\nimport {TransformProvider} from './transform-provider';\n\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\nimport {Handler} from '../handler_manager';\n\n/**\n * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.\n * The bounding box is defined by clicking and holding `shift` while dragging the cursor.\n *\n * @group Handlers\n */\nexport class BoxZoomHandler implements Handler {\n _map: Map;\n _tr: TransformProvider;\n _el: HTMLElement;\n _container: HTMLElement;\n _enabled: boolean;\n _active: boolean;\n _startPos: Point;\n _lastPos: Point;\n _box: HTMLElement;\n _clickTolerance: number;\n\n /** @internal */\n constructor(map: Map, options: {\n clickTolerance: number;\n }) {\n this._map = map;\n this._tr = new TransformProvider(map);\n this._el = map.getCanvasContainer();\n this._container = map.getContainer();\n this._clickTolerance = options.clickTolerance || 1;\n }\n\n /**\n * Returns a Boolean indicating whether the \"box zoom\" interaction is enabled.\n *\n * @returns `true` if the \"box zoom\" interaction is enabled.\n */\n isEnabled() {\n return !!this._enabled;\n }\n\n /**\n * Returns a Boolean indicating whether the \"box zoom\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"box zoom\" interaction is active.\n */\n isActive() {\n return !!this._active;\n }\n\n /**\n * Enables the \"box zoom\" interaction.\n *\n * @example\n * ```ts\n * map.boxZoom.enable();\n * ```\n */\n enable() {\n if (this.isEnabled()) return;\n this._enabled = true;\n }\n\n /**\n * Disables the \"box zoom\" interaction.\n *\n * @example\n * ```ts\n * map.boxZoom.disable();\n * ```\n */\n disable() {\n if (!this.isEnabled()) return;\n this._enabled = false;\n }\n\n mousedown(e: MouseEvent, point: Point) {\n if (!this.isEnabled()) return;\n if (!(e.shiftKey && e.button === 0)) return;\n\n DOM.disableDrag();\n this._startPos = this._lastPos = point;\n this._active = true;\n }\n\n mousemoveWindow(e: MouseEvent, point: Point) {\n if (!this._active) return;\n\n const pos = point;\n\n if (this._lastPos.equals(pos) || (!this._box && pos.dist(this._startPos) < this._clickTolerance)) {\n return;\n }\n\n const p0 = this._startPos;\n this._lastPos = pos;\n\n if (!this._box) {\n this._box = DOM.create('div', 'maplibregl-boxzoom', this._container);\n this._container.classList.add('maplibregl-crosshair');\n this._fireEvent('boxzoomstart', e);\n }\n\n const minX = Math.min(p0.x, pos.x),\n maxX = Math.max(p0.x, pos.x),\n minY = Math.min(p0.y, pos.y),\n maxY = Math.max(p0.y, pos.y);\n\n DOM.setTransform(this._box, `translate(${minX}px,${minY}px)`);\n\n this._box.style.width = `${maxX - minX}px`;\n this._box.style.height = `${maxY - minY}px`;\n }\n\n mouseupWindow(e: MouseEvent, point: Point) {\n if (!this._active) return;\n\n if (e.button !== 0) return;\n\n const p0 = this._startPos,\n p1 = point;\n\n this.reset();\n\n DOM.suppressClick();\n\n if (p0.x === p1.x && p0.y === p1.y) {\n this._fireEvent('boxzoomcancel', e);\n } else {\n this._map.fire(new Event('boxzoomend', {originalEvent: e}));\n return {\n cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this._tr.bearing, {linear: true})\n };\n }\n }\n\n keydown(e: KeyboardEvent) {\n if (!this._active) return;\n\n if (e.keyCode === 27) {\n this.reset();\n this._fireEvent('boxzoomcancel', e);\n }\n }\n\n reset() {\n this._active = false;\n\n this._container.classList.remove('maplibregl-crosshair');\n\n if (this._box) {\n DOM.remove(this._box);\n this._box = null;\n }\n\n DOM.enableDrag();\n\n delete this._startPos;\n delete this._lastPos;\n }\n\n _fireEvent(type: string, e: any) {\n return this._map.fire(new Event(type, {originalEvent: e}));\n }\n}\n","import Point from '@mapbox/point-geometry';\n\nexport function indexTouches(touches: Array, points: Array) {\n if (touches.length !== points.length) throw new Error(`The number of touches and points are not equal - touches ${touches.length}, points ${points.length}`);\n const obj = {};\n for (let i = 0; i < touches.length; i++) {\n obj[touches[i].identifier] = points[i];\n }\n return obj;\n}\n","import Point from '@mapbox/point-geometry';\nimport {indexTouches} from './handler_util';\n\nfunction getCentroid(points: Array) {\n const sum = new Point(0, 0);\n for (const point of points) {\n sum._add(point);\n }\n return sum.div(points.length);\n}\n\nexport const MAX_TAP_INTERVAL = 500;\nconst MAX_TOUCH_TIME = 500;\nexport const MAX_DIST = 30;\n\nexport class SingleTapRecognizer {\n\n numTouches: number;\n centroid: Point;\n startTime: number;\n aborted: boolean;\n touches: {\n [k in number | string]: Point;\n };\n\n constructor(options: {\n numTouches: number;\n }) {\n this.reset();\n this.numTouches = options.numTouches;\n }\n\n reset() {\n delete this.centroid;\n delete this.startTime;\n delete this.touches;\n this.aborted = false;\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n\n if (this.centroid || mapTouches.length > this.numTouches) {\n this.aborted = true;\n }\n if (this.aborted) {\n return;\n }\n\n if (this.startTime === undefined) {\n this.startTime = e.timeStamp;\n }\n\n if (mapTouches.length === this.numTouches) {\n this.centroid = getCentroid(points);\n this.touches = indexTouches(mapTouches, points);\n }\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this.aborted || !this.centroid) return;\n\n const newTouches = indexTouches(mapTouches, points);\n for (const id in this.touches) {\n const prevPos = this.touches[id];\n const pos = newTouches[id];\n if (!pos || pos.dist(prevPos) > MAX_DIST) {\n this.aborted = true;\n }\n }\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {\n this.aborted = true;\n }\n\n if (mapTouches.length === 0) {\n const centroid = !this.aborted && this.centroid;\n this.reset();\n if (centroid) return centroid;\n }\n }\n\n}\n\nexport class TapRecognizer {\n\n singleTap: SingleTapRecognizer;\n numTaps: number;\n lastTime: number;\n lastTap: Point;\n count: number;\n\n constructor(options: {\n numTaps: number;\n numTouches: number;\n }) {\n this.singleTap = new SingleTapRecognizer(options);\n this.numTaps = options.numTaps;\n this.reset();\n }\n\n reset() {\n this.lastTime = Infinity;\n delete this.lastTap;\n this.count = 0;\n this.singleTap.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n this.singleTap.touchstart(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n this.singleTap.touchmove(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n const tap = this.singleTap.touchend(e, points, mapTouches);\n if (tap) {\n const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;\n const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;\n\n if (!soonEnough || !closeEnough) {\n this.reset();\n }\n\n this.count++;\n this.lastTime = e.timeStamp;\n this.lastTap = tap;\n\n if (this.count === this.numTaps) {\n this.reset();\n return tap;\n }\n }\n }\n}\n","import {TapRecognizer} from './tap_recognizer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\nimport {Handler} from '../handler_manager';\n\nexport class TapZoomHandler implements Handler {\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n _zoomIn: TapRecognizer;\n _zoomOut: TapRecognizer;\n\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n this._zoomIn = new TapRecognizer({\n numTouches: 1,\n numTaps: 2\n });\n\n this._zoomOut = new TapRecognizer({\n numTouches: 2,\n numTaps: 1\n });\n\n this.reset();\n }\n\n reset() {\n this._active = false;\n this._zoomIn.reset();\n this._zoomOut.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n this._zoomIn.touchstart(e, points, mapTouches);\n this._zoomOut.touchstart(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n this._zoomIn.touchmove(e, points, mapTouches);\n this._zoomOut.touchmove(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches);\n const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches);\n const tr = this._tr;\n\n if (zoomInPoint) {\n this._active = true;\n e.preventDefault();\n setTimeout(() => this.reset(), 0);\n return {\n cameraAnimation: (map: Map) => map.easeTo({\n duration: 300,\n zoom: tr.zoom + 1,\n around: tr.unproject(zoomInPoint)\n }, {originalEvent: e})\n };\n } else if (zoomOutPoint) {\n this._active = true;\n e.preventDefault();\n setTimeout(() => this.reset(), 0);\n return {\n cameraAnimation: (map: Map) => map.easeTo({\n duration: 300,\n zoom: tr.zoom - 1,\n around: tr.unproject(zoomOutPoint)\n }, {originalEvent: e})\n };\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import {DOM} from '../../util/dom';\nimport type Point from '@mapbox/point-geometry';\nimport {DragMoveStateManager} from './drag_move_state_manager';\nimport {Handler} from '../handler_manager';\n\ninterface DragMovementResult {\n bearingDelta?: number;\n pitchDelta?: number;\n around?: Point;\n panDelta?: Point;\n}\n\nexport interface DragPanResult extends DragMovementResult {\n around: Point;\n panDelta: Point;\n}\n\nexport interface DragRotateResult extends DragMovementResult {\n bearingDelta: number;\n}\n\nexport interface DragPitchResult extends DragMovementResult {\n pitchDelta: number;\n}\n\ntype DragMoveFunction = (lastPoint: Point, point: Point) => T;\n\nexport interface DragMoveHandler extends Handler {\n dragStart: (e: E, point: Point) => void;\n dragMove: (e: E, point: Point) => T | void;\n dragEnd: (e: E) => void;\n getClickTolerance: () => number;\n}\n\nexport type DragMoveHandlerOptions = {\n /**\n * If the movement is shorter than this value, consider it a click.\n */\n clickTolerance: number;\n /**\n * The move function to run on a valid movement.\n */\n move: DragMoveFunction;\n /**\n * A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details.\n */\n moveStateManager: DragMoveStateManager;\n /**\n * A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler\n * @param handler - the handler\n */\n assignEvents: (handler: DragMoveHandler) => void;\n /**\n * Should the move start on the \"start\" event, or should it start on the first valid move.\n */\n activateOnStart?: boolean;\n /**\n * If true, handler will be enabled during construction\n */\n enable?: boolean;\n}\n\n/**\n * A generic class to create handlers for drag events, from both mouse and touch events.\n */\nexport class DragHandler implements DragMoveHandler {\n // Event handlers that may be assigned by the implementations of this class\n contextmenu?: Handler['contextmenu'];\n mousedown?: Handler['mousedown'];\n mousemoveWindow?: Handler['mousemoveWindow'];\n mouseup?: Handler['mouseup'];\n touchstart?: Handler['touchstart'];\n touchmoveWindow?: Handler['touchmoveWindow'];\n touchend?: Handler['touchend'];\n\n _clickTolerance: number;\n _moveFunction: DragMoveFunction;\n _activateOnStart: boolean;\n _active: boolean;\n _enabled: boolean;\n _moved: boolean;\n _lastPoint: Point | null;\n _moveStateManager: DragMoveStateManager;\n\n constructor(options: DragMoveHandlerOptions) {\n this._enabled = !!options.enable;\n this._moveStateManager = options.moveStateManager;\n this._clickTolerance = options.clickTolerance || 1;\n this._moveFunction = options.move;\n this._activateOnStart = !!options.activateOnStart;\n\n options.assignEvents(this);\n\n this.reset();\n }\n\n reset(e?: E) {\n this._active = false;\n this._moved = false;\n delete this._lastPoint;\n this._moveStateManager.endMove(e);\n }\n\n _move(...params: Parameters>) {\n const move = this._moveFunction(...params);\n if (move.bearingDelta || move.pitchDelta || move.around || move.panDelta) {\n this._active = true;\n return move;\n }\n }\n\n dragStart(e: E, point: Point);\n dragStart(e: E, point: Point[]);\n dragStart(e: E, point: Point | Point[]) {\n if (!this.isEnabled() || this._lastPoint) return;\n\n if (!this._moveStateManager.isValidStartEvent(e)) return;\n this._moveStateManager.startMove(e);\n\n this._lastPoint = point['length'] ? point[0] : point;\n\n if (this._activateOnStart && this._lastPoint) this._active = true;\n }\n\n dragMove(e: E, point: Point);\n dragMove(e: E, point: Point[]);\n dragMove(e: E, point: Point | Point[]) {\n if (!this.isEnabled()) return;\n const lastPoint = this._lastPoint;\n if (!lastPoint) return;\n e.preventDefault();\n\n if (!this._moveStateManager.isValidMoveEvent(e)) {\n this.reset(e);\n return;\n }\n\n const movePoint = point['length'] ? point[0] : point;\n\n if (!this._moved && movePoint.dist(lastPoint) < this._clickTolerance) return;\n this._moved = true;\n this._lastPoint = movePoint;\n\n return this._move(lastPoint, movePoint);\n }\n\n dragEnd(e: E) {\n if (!this.isEnabled() || !this._lastPoint) return;\n if (!this._moveStateManager.isValidEndEvent(e)) return;\n if (this._moved) DOM.suppressClick();\n this.reset(e);\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n\n getClickTolerance() {\n return this._clickTolerance;\n }\n}\n","import {DOM} from '../../util/dom';\n\nconst LEFT_BUTTON = 0;\nconst RIGHT_BUTTON = 2;\n\n// the values for each button in MouseEvent.buttons\nconst BUTTONS_FLAGS = {\n [LEFT_BUTTON]: 1,\n [RIGHT_BUTTON]: 2\n};\n\nfunction buttonNoLongerPressed(e: MouseEvent, button: number) {\n const flag = BUTTONS_FLAGS[button];\n return e.buttons === undefined || (e.buttons & flag) !== flag;\n}\n\n/*\n * Drag events are initiated by specific interaction which needs to be tracked until it ends.\n * This requires some state management:\n * 1. registering the initiating event,\n * 2. tracking that it was not canceled / not confusing it with another event firing.\n * 3. recognizing the ending event and cleaning up any internal state\n *\n * Concretely, we implement two state managers:\n * 1. MouseMoveStateManager\n * Receives a functions that is used to recognize mouse events that should be registered as the\n * relevant drag interactions - i.e. dragging with the right mouse button, or while CTRL is pressed.\n * 2. OneFingerTouchMoveStateManager\n * Checks if a drag event is using one finger, and continuously tracking that this is the same event\n * (i.e. to make sure not additional finger has started interacting with the screen before raising\n * the first finger).\n */\nexport interface DragMoveStateManager {\n startMove: (e: E) => void;\n endMove: (e?: E) => void;\n isValidStartEvent: (e: E) => boolean;\n isValidMoveEvent: (e: E) => boolean;\n isValidEndEvent: (e?: E) => boolean;\n}\n\nexport class MouseMoveStateManager implements DragMoveStateManager {\n _eventButton: number | undefined;\n _correctEvent: (e: MouseEvent) => boolean;\n\n constructor(options: {\n checkCorrectEvent: (e: MouseEvent) => boolean;\n }) {\n this._correctEvent = options.checkCorrectEvent;\n }\n\n startMove(e: MouseEvent) {\n const eventButton = DOM.mouseButton(e);\n this._eventButton = eventButton;\n }\n\n endMove(_e?: MouseEvent) {\n delete this._eventButton;\n }\n\n isValidStartEvent(e: MouseEvent) {\n return this._correctEvent(e);\n }\n\n isValidMoveEvent(e: MouseEvent) {\n // Some browsers don't fire a `mouseup` when the mouseup occurs outside\n // the window or iframe:\n // https://github.com/mapbox/mapbox-gl-js/issues/4622\n //\n // If the button is no longer pressed during this `mousemove` it may have\n // been released outside of the window or iframe.\n return !buttonNoLongerPressed(e, this._eventButton);\n }\n\n isValidEndEvent(e: MouseEvent) {\n const eventButton = DOM.mouseButton(e);\n return eventButton === this._eventButton;\n }\n}\n\nexport class OneFingerTouchMoveStateManager implements DragMoveStateManager {\n _firstTouch: number | undefined;\n\n constructor() {\n this._firstTouch = undefined;\n }\n\n _isOneFingerTouch(e: TouchEvent) {\n return e.targetTouches.length === 1;\n }\n\n _isSameTouchEvent(e: TouchEvent) {\n return e.targetTouches[0].identifier === this._firstTouch;\n }\n\n startMove(e: TouchEvent) {\n const firstTouch = e.targetTouches[0].identifier;\n this._firstTouch = firstTouch;\n }\n\n endMove(_e?: TouchEvent) {\n delete this._firstTouch;\n }\n\n isValidStartEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e);\n }\n\n isValidMoveEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);\n }\n\n isValidEndEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);\n }\n}\n","import type Point from '@mapbox/point-geometry';\n\nimport {DOM} from '../../util/dom';\nimport {DragMoveHandler, DragPanResult, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';\nimport {MouseMoveStateManager} from './drag_move_state_manager';\n\nexport interface MousePanHandler extends DragMoveHandler {}\nexport interface MouseRotateHandler extends DragMoveHandler {}\nexport interface MousePitchHandler extends DragMoveHandler {}\n\nconst LEFT_BUTTON = 0;\nconst RIGHT_BUTTON = 2;\n\nconst assignEvents = (handler: DragHandler) => {\n handler.mousedown = handler.dragStart;\n handler.mousemoveWindow = handler.dragMove;\n handler.mouseup = handler.dragEnd;\n handler.contextmenu = function(e: MouseEvent) {\n e.preventDefault();\n };\n};\n\nexport const generateMousePanHandler = ({enable, clickTolerance,}: {\n clickTolerance: number;\n enable?: boolean;\n}): MousePanHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent) => DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey,\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({around: point, panDelta: point.sub(lastPoint)}),\n activateOnStart: true,\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateMouseRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: {\n clickTolerance: number;\n bearingDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): MouseRotateHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent): boolean =>\n (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) ||\n (DOM.mouseButton(e) === RIGHT_BUTTON),\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}),\n // prevent browser context menu when necessary; we don't allow it with rotation\n // because we can't discern rotation gesture start from contextmenu on Mac\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateMousePitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: {\n clickTolerance: number;\n pitchDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): MousePitchHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent): boolean =>\n (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) ||\n (DOM.mouseButton(e) === RIGHT_BUTTON),\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}),\n // prevent browser context menu when necessary; we don't allow it with rotation\n // because we can't discern rotation gesture start from contextmenu on Mac\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n","import Point from '@mapbox/point-geometry';\nimport {indexTouches} from './handler_util';\nimport type {Map} from '../map';\nimport {GestureOptions} from '../map';\nimport {Handler} from '../handler_manager';\n\nexport class TouchPanHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _touches: {\n [k in string | number]: Point;\n };\n _minTouches: number;\n _clickTolerance: number;\n _sum: Point;\n _map: Map;\n _cancelCooperativeMessage: boolean;\n\n constructor(options: {\n clickTolerance: number;\n cooperativeGestures: boolean | GestureOptions;\n }, map: Map) {\n this._minTouches = options.cooperativeGestures ? 2 : 1;\n this._clickTolerance = options.clickTolerance || 1;\n this._map = map;\n this.reset();\n }\n\n reset() {\n this._active = false;\n this._touches = {};\n this._sum = new Point(0, 0);\n\n // Put a delay on the cooperative gesture message so it's less twitchy\n setTimeout(() => {\n this._cancelCooperativeMessage = false;\n }, 200);\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n return this._calculateTransform(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this._map._cooperativeGestures) {\n if (this._minTouches === 2 && mapTouches.length < 2 && !this._cancelCooperativeMessage) {\n // If coop gesture enabled, show panning info to user\n this._map._onCooperativeGesture(e, false, mapTouches.length);\n } else if (!this._cancelCooperativeMessage) {\n // If user is successfully navigating, we don't need this warning until the touch resets\n this._cancelCooperativeMessage = true;\n }\n }\n if (!this._active || mapTouches.length < this._minTouches) return;\n e.preventDefault();\n return this._calculateTransform(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n this._calculateTransform(e, points, mapTouches);\n\n if (this._active && mapTouches.length < this._minTouches) {\n this.reset();\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n _calculateTransform(e: TouchEvent, points: Array, mapTouches: Array) {\n if (mapTouches.length > 0) this._active = true;\n\n const touches = indexTouches(mapTouches, points);\n\n const touchPointSum = new Point(0, 0);\n const touchDeltaSum = new Point(0, 0);\n let touchDeltaCount = 0;\n\n for (const identifier in touches) {\n const point = touches[identifier];\n const prevPoint = this._touches[identifier];\n if (prevPoint) {\n touchPointSum._add(point);\n touchDeltaSum._add(point.sub(prevPoint));\n touchDeltaCount++;\n touches[identifier] = point;\n }\n }\n\n this._touches = touches;\n\n if (touchDeltaCount < this._minTouches || !touchDeltaSum.mag()) return;\n\n const panDelta = touchDeltaSum.div(touchDeltaCount);\n this._sum._add(panDelta);\n if (this._sum.mag() < this._clickTolerance) return;\n\n const around = touchPointSum.div(touchDeltaCount);\n\n return {\n around,\n panDelta\n };\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {DOM} from '../../util/dom';\nimport type {Map} from '../map';\nimport {Handler} from '../handler_manager';\n\n/**\n * An options object sent to the enable function of some of the handlers\n */\nexport type AroundCenterOptions = {\n /**\n * If \"center\" is passed, map will zoom around the center of map\n */\n around: 'center';\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers\n *\n * @group Handlers\n */\nabstract class TwoFingersTouchHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _firstTwoTouches: [number, number];\n _vector: Point;\n _startVector: Point;\n _aroundCenter: boolean;\n\n /** @internal */\n constructor() {\n this.reset();\n }\n\n reset() {\n this._active = false;\n delete this._firstTwoTouches;\n }\n\n abstract _start(points: [Point, Point]);\n abstract _move(points: [Point, Point], pinchAround: Point, e: TouchEvent);\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n //log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);\n if (this._firstTwoTouches || mapTouches.length < 2) return;\n\n this._firstTwoTouches = [\n mapTouches[0].identifier,\n mapTouches[1].identifier\n ];\n\n // implemented by child classes\n this._start([points[0], points[1]]);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._firstTwoTouches) return;\n\n e.preventDefault();\n\n const [idA, idB] = this._firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (!a || !b) return;\n const pinchAround = this._aroundCenter ? null : a.add(b).div(2);\n\n // implemented by child classes\n return this._move([a, b], pinchAround, e);\n\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._firstTwoTouches) return;\n\n const [idA, idB] = this._firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (a && b) return;\n\n if (this._active) DOM.suppressClick();\n\n this.reset();\n }\n\n touchcancel() {\n this.reset();\n }\n\n /**\n * Enables the \"drag to pitch\" interaction.\n *\n * @example\n * ```ts\n * map.touchPitch.enable();\n * ```\n */\n enable(options?: AroundCenterOptions | boolean | null) {\n this._enabled = true;\n this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';\n }\n\n /**\n * Disables the \"drag to pitch\" interaction.\n *\n * @example\n * ```ts\n * map.touchPitch.disable();\n * ```\n */\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pitch\" interaction is enabled.\n *\n * @returns `true` if the \"drag to pitch\" interaction is enabled.\n */\n isEnabled() {\n return this._enabled;\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pitch\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to pitch\" interaction is active.\n */\n isActive() {\n return this._active;\n }\n}\n\nfunction getTouchById(mapTouches: Array, points: Array, identifier: number) {\n for (let i = 0; i < mapTouches.length; i++) {\n if (mapTouches[i].identifier === identifier) return points[i];\n }\n}\n\n/* ZOOM */\n\nconst ZOOM_THRESHOLD = 0.1;\n\nfunction getZoomDelta(distance, lastDistance) {\n return Math.log(distance / lastDistance) / Math.LN2;\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers\n *\n * @group Handlers\n */\nexport class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {\n\n _distance: number;\n _startDistance: number;\n\n reset() {\n super.reset();\n delete this._distance;\n delete this._startDistance;\n }\n\n _start(points: [Point, Point]) {\n this._startDistance = this._distance = points[0].dist(points[1]);\n }\n\n _move(points: [Point, Point], pinchAround: Point) {\n const lastDistance = this._distance;\n this._distance = points[0].dist(points[1]);\n if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) return;\n this._active = true;\n return {\n zoomDelta: getZoomDelta(this._distance, lastDistance),\n pinchAround\n };\n }\n}\n\n/* ROTATE */\n\nconst ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle\n\nfunction getBearingDelta(a, b) {\n return a.angleWith(b) * 180 / Math.PI;\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers\n *\n * @group Handlers\n */\nexport class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {\n _minDiameter: number;\n\n reset() {\n super.reset();\n delete this._minDiameter;\n delete this._startVector;\n delete this._vector;\n }\n\n _start(points: [Point, Point]) {\n this._startVector = this._vector = points[0].sub(points[1]);\n this._minDiameter = points[0].dist(points[1]);\n }\n\n _move(points: [Point, Point], pinchAround: Point) {\n const lastVector = this._vector;\n this._vector = points[0].sub(points[1]);\n\n if (!this._active && this._isBelowThreshold(this._vector)) return;\n this._active = true;\n\n return {\n bearingDelta: getBearingDelta(this._vector, lastVector),\n pinchAround\n };\n }\n\n _isBelowThreshold(vector: Point) {\n /*\n * The threshold before a rotation actually happens is configured in\n * pixels along the circumference of the circle formed by the two fingers.\n * This makes the threshold in degrees larger when the fingers are close\n * together and smaller when the fingers are far apart.\n *\n * Use the smallest diameter from the whole gesture to reduce sensitivity\n * when pinching in and out.\n */\n\n this._minDiameter = Math.min(this._minDiameter, vector.mag());\n const circumference = Math.PI * this._minDiameter;\n const threshold = ROTATION_THRESHOLD / circumference * 360;\n\n const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector);\n return Math.abs(bearingDeltaSinceStart) < threshold;\n }\n}\n\n/* PITCH */\n\nfunction isVertical(vector) {\n return Math.abs(vector.y) > Math.abs(vector.x);\n}\n\nconst ALLOWED_SINGLE_TOUCH_TIME = 100;\n\n/**\n * The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.\n *\n * @group Handlers\n */\nexport class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {\n\n _valid: boolean | void;\n _firstMove: number;\n _lastPoints: [Point, Point];\n _map: Map;\n _currentTouchCount: number;\n\n constructor(map: Map) {\n super();\n this._map = map;\n }\n\n reset() {\n super.reset();\n this._valid = undefined;\n delete this._firstMove;\n delete this._lastPoints;\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n super.touchstart(e, points, mapTouches);\n this._currentTouchCount = mapTouches.length;\n }\n\n _start(points: [Point, Point]) {\n this._lastPoints = points;\n if (isVertical(points[0].sub(points[1]))) {\n // fingers are more horizontal than vertical\n this._valid = false;\n\n }\n }\n\n _move(points: [Point, Point], center: Point, e: TouchEvent) {\n // If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register\n if (this._map._cooperativeGestures && this._currentTouchCount < 3) {\n return;\n }\n\n const vectorA = points[0].sub(this._lastPoints[0]);\n const vectorB = points[1].sub(this._lastPoints[1]);\n\n this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);\n if (!this._valid) return;\n\n this._lastPoints = points;\n this._active = true;\n const yDeltaAverage = (vectorA.y + vectorB.y) / 2;\n const degreesPerPixelMoved = -0.5;\n return {\n pitchDelta: yDeltaAverage * degreesPerPixelMoved\n };\n }\n\n gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number) {\n if (this._valid !== undefined) return this._valid;\n\n const threshold = 2;\n const movedA = vectorA.mag() >= threshold;\n const movedB = vectorB.mag() >= threshold;\n\n // neither finger has moved a meaningful amount, wait\n if (!movedA && !movedB) return;\n\n // One finger has moved and the other has not.\n // If enough time has passed, decide it is not a pitch.\n if (!movedA || !movedB) {\n if (this._firstMove === undefined) {\n this._firstMove = timeStamp;\n }\n\n if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) {\n // still waiting for a movement from the second finger\n return undefined;\n } else {\n return false;\n }\n }\n\n const isSameDirection = vectorA.y > 0 === vectorB.y > 0;\n return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;\n }\n}\n","import {Handler} from '../handler_manager';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\n\nconst defaultOptions = {\n panStep: 100,\n bearingStep: 15,\n pitchStep: 10\n};\n\n/**\n * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using\n * the following keyboard shortcuts:\n *\n * - `=` / `+`: Increase the zoom level by 1.\n * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.\n * - `-`: Decrease the zoom level by 1.\n * - `Shift--`: Decrease the zoom level by 2.\n * - Arrow keys: Pan by 100 pixels.\n * - `Shift+⇢`: Increase the rotation by 15 degrees.\n * - `Shift+⇠`: Decrease the rotation by 15 degrees.\n * - `Shift+⇡`: Increase the pitch by 10 degrees.\n * - `Shift+⇣`: Decrease the pitch by 10 degrees.\n *\n * @group Handlers\n */\nexport class KeyboardHandler implements Handler {\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n _panStep: number;\n _bearingStep: number;\n _pitchStep: number;\n _rotationDisabled: boolean;\n\n /** @internal */\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n const stepOptions = defaultOptions;\n this._panStep = stepOptions.panStep;\n this._bearingStep = stepOptions.bearingStep;\n this._pitchStep = stepOptions.pitchStep;\n this._rotationDisabled = false;\n }\n\n reset() {\n this._active = false;\n }\n\n keydown(e: KeyboardEvent) {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n\n let zoomDir = 0;\n let bearingDir = 0;\n let pitchDir = 0;\n let xDir = 0;\n let yDir = 0;\n\n switch (e.keyCode) {\n case 61:\n case 107:\n case 171:\n case 187:\n zoomDir = 1;\n break;\n\n case 189:\n case 109:\n case 173:\n zoomDir = -1;\n break;\n\n case 37:\n if (e.shiftKey) {\n bearingDir = -1;\n } else {\n e.preventDefault();\n xDir = -1;\n }\n break;\n\n case 39:\n if (e.shiftKey) {\n bearingDir = 1;\n } else {\n e.preventDefault();\n xDir = 1;\n }\n break;\n\n case 38:\n if (e.shiftKey) {\n pitchDir = 1;\n } else {\n e.preventDefault();\n yDir = -1;\n }\n break;\n\n case 40:\n if (e.shiftKey) {\n pitchDir = -1;\n } else {\n e.preventDefault();\n yDir = 1;\n }\n break;\n\n default:\n return;\n }\n\n if (this._rotationDisabled) {\n bearingDir = 0;\n pitchDir = 0;\n }\n\n return {\n cameraAnimation: (map: Map) => {\n const tr = this._tr;\n map.easeTo({\n duration: 300,\n easeId: 'keyboardHandler',\n easing: easeOut,\n\n zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom,\n bearing: tr.bearing + bearingDir * this._bearingStep,\n pitch: tr.pitch + pitchDir * this._pitchStep,\n offset: [-xDir * this._panStep, -yDir * this._panStep],\n center: tr.center\n }, {originalEvent: e});\n }\n };\n }\n\n /**\n * Enables the \"keyboard rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.enable();\n * ```\n */\n enable() {\n this._enabled = true;\n }\n\n /**\n * Disables the \"keyboard rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.disable();\n * ```\n */\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n /**\n * Returns a Boolean indicating whether the \"keyboard rotate and zoom\"\n * interaction is enabled.\n *\n * @returns `true` if the \"keyboard rotate and zoom\"\n * interaction is enabled.\n */\n isEnabled() {\n return this._enabled;\n }\n\n /**\n * Returns true if the handler is enabled and has detected the start of a\n * zoom/rotate gesture.\n *\n * @returns `true` if the handler is enabled and has detected the\n * start of a zoom/rotate gesture.\n */\n isActive() {\n return this._active;\n }\n\n /**\n * Disables the \"keyboard pan/rotate\" interaction, leaving the\n * \"keyboard zoom\" interaction enabled.\n *\n * @example\n * ```ts\n * map.keyboard.disableRotation();\n * ```\n */\n disableRotation() {\n this._rotationDisabled = true;\n }\n\n /**\n * Enables the \"keyboard pan/rotate\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.enable();\n * map.keyboard.enableRotation();\n * ```\n */\n enableRotation() {\n this._rotationDisabled = false;\n }\n}\n\nfunction easeOut(t: number) {\n return t * (2 - t);\n}\n","import {DOM} from '../../util/dom';\n\nimport {defaultEasing, bezier} from '../../util/util';\nimport {browser} from '../../util/browser';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {LngLat} from '../../geo/lng_lat';\nimport {TransformProvider} from './transform-provider';\n\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\nimport type {AroundCenterOptions} from './two_fingers_touch';\nimport {Handler} from '../handler_manager';\n\n// deltaY value for mouse scroll wheel identification\nconst wheelZoomDelta = 4.000244140625;\n\n// These magic numbers control the rate of zoom. Trackpad events fire at a greater\n// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick\nconst defaultZoomRate = 1 / 100;\nconst wheelZoomRate = 1 / 450;\n\n// upper bound on how much we scale the map in any single render frame; this\n// is used to limit zoom rate in the case of very fast scrolling\nconst maxScalePerFrame = 2;\n\n/**\n * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.\n *\n * @group Handlers\n */\nexport class ScrollZoomHandler implements Handler {\n _map: Map;\n _tr: TransformProvider;\n _el: HTMLElement;\n _enabled: boolean;\n _active: boolean;\n _zooming: boolean;\n _aroundCenter: boolean;\n _around: LngLat;\n _aroundPoint: Point;\n _type: 'wheel' | 'trackpad' | null;\n _lastValue: number;\n _timeout: ReturnType; // used for delayed-handling of a single wheel movement\n _finishTimeout: ReturnType; // used to delay final '{move,zoom}end' events\n\n _lastWheelEvent: any;\n _lastWheelEventTime: number;\n\n _startZoom: number;\n _targetZoom: number;\n _delta: number;\n _easing: ((a: number) => number);\n _prevEase: {\n start: number;\n duration: number;\n easing: (_: number) => number;\n };\n\n _frameId: boolean;\n _triggerRenderFrame: () => void;\n\n _defaultZoomRate: number;\n _wheelZoomRate: number;\n\n /** @internal */\n constructor(map: Map, triggerRenderFrame: () => void) {\n this._map = map;\n this._tr = new TransformProvider(map);\n this._el = map.getCanvasContainer();\n this._triggerRenderFrame = triggerRenderFrame;\n\n this._delta = 0;\n\n this._defaultZoomRate = defaultZoomRate;\n this._wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Set the zoom rate of a trackpad\n * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value.\n * @example\n * Speed up trackpad zoom\n * ```ts\n * map.scrollZoom.setZoomRate(1/25);\n * ```\n */\n setZoomRate(zoomRate: number) {\n this._defaultZoomRate = zoomRate;\n }\n\n /**\n * Set the zoom rate of a mouse wheel\n * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value.\n * @example\n * Slow down zoom of mouse wheel\n * ```ts\n * map.scrollZoom.setWheelZoomRate(1/600);\n * ```\n */\n setWheelZoomRate(wheelZoomRate: number) {\n this._wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Returns a Boolean indicating whether the \"scroll to zoom\" interaction is enabled.\n * @returns `true` if the \"scroll to zoom\" interaction is enabled.\n */\n isEnabled() {\n return !!this._enabled;\n }\n\n /*\n * Active state is turned on and off with every scroll wheel event and is set back to false before the map\n * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in\n * progress.\n */\n isActive() {\n return !!this._active || this._finishTimeout !== undefined;\n }\n\n isZooming() {\n return !!this._zooming;\n }\n\n /**\n * Enables the \"scroll to zoom\" interaction.\n *\n * @param options - Options object.\n * @example\n * ```ts\n * map.scrollZoom.enable();\n * map.scrollZoom.enable({ around: 'center' })\n * ```\n */\n enable(options?: AroundCenterOptions | boolean) {\n if (this.isEnabled()) return;\n this._enabled = true;\n this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';\n }\n\n /**\n * Disables the \"scroll to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.scrollZoom.disable();\n * ```\n */\n disable() {\n if (!this.isEnabled()) return;\n this._enabled = false;\n }\n\n wheel(e: WheelEvent) {\n if (!this.isEnabled()) return;\n if (this._map._cooperativeGestures) {\n if (e[this._map._metaKey]) {\n e.preventDefault();\n } else {\n return;\n }\n }\n let value = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;\n const now = browser.now(),\n timeDelta = now - (this._lastWheelEventTime || 0);\n\n this._lastWheelEventTime = now;\n\n if (value !== 0 && (value % wheelZoomDelta) === 0) {\n // This one is definitely a mouse wheel event.\n this._type = 'wheel';\n\n } else if (value !== 0 && Math.abs(value) < 4) {\n // This one is definitely a trackpad event because it is so small.\n this._type = 'trackpad';\n\n } else if (timeDelta > 400) {\n // This is likely a new scroll action.\n this._type = null;\n this._lastValue = value;\n\n // Start a timeout in case this was a singular event, and dely it by up to 40ms.\n this._timeout = setTimeout(this._onTimeout, 40, e);\n\n } else if (!this._type) {\n // This is a repeating event, but we don't know the type of event just yet.\n // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.\n this._type = (Math.abs(timeDelta * value) < 200) ? 'trackpad' : 'wheel';\n\n // Make sure our delayed event isn't fired again, because we accumulate\n // the previous event (which was less than 40ms ago) into this event.\n if (this._timeout) {\n clearTimeout(this._timeout);\n this._timeout = null;\n value += this._lastValue;\n }\n }\n\n // Slow down zoom if shift key is held for more precise zooming\n if (e.shiftKey && value) value = value / 4;\n\n // Only fire the callback if we actually know what type of scrolling device the user uses.\n if (this._type) {\n this._lastWheelEvent = e;\n this._delta -= value;\n if (!this._active) {\n this._start(e);\n }\n }\n\n e.preventDefault();\n }\n\n _onTimeout = (initialEvent: MouseEvent) => {\n this._type = 'wheel';\n this._delta -= this._lastValue;\n if (!this._active) {\n this._start(initialEvent);\n }\n };\n\n _start(e: MouseEvent) {\n if (!this._delta) return;\n\n if (this._frameId) {\n this._frameId = null;\n }\n\n this._active = true;\n if (!this.isZooming()) {\n this._zooming = true;\n }\n\n if (this._finishTimeout) {\n clearTimeout(this._finishTimeout);\n delete this._finishTimeout;\n }\n\n const pos = DOM.mousePos(this._el, e);\n const tr = this._tr;\n\n this._around = LngLat.convert(this._aroundCenter ? tr.center : tr.unproject(pos));\n this._aroundPoint = tr.transform.locationPoint(this._around);\n if (!this._frameId) {\n this._frameId = true;\n this._triggerRenderFrame();\n }\n }\n\n renderFrame() {\n if (!this._frameId) return;\n this._frameId = null;\n\n if (!this.isActive()) return;\n const tr = this._tr.transform;\n\n // if we've had scroll events since the last render frame, consume the\n // accumulated delta, and update the target zoom level accordingly\n if (this._delta !== 0) {\n // For trackpad events and single mouse wheel ticks, use the default zoom rate\n const zoomRate = (this._type === 'wheel' && Math.abs(this._delta) > wheelZoomDelta) ? this._wheelZoomRate : this._defaultZoomRate;\n // Scale by sigmoid of scroll wheel delta.\n let scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate)));\n\n if (this._delta < 0 && scale !== 0) {\n scale = 1 / scale;\n }\n\n const fromScale = typeof this._targetZoom === 'number' ? tr.zoomScale(this._targetZoom) : tr.scale;\n this._targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)));\n\n // if this is a mouse wheel, refresh the starting zoom and easing\n // function we're using to smooth out the zooming between wheel\n // events\n if (this._type === 'wheel') {\n this._startZoom = tr.zoom;\n this._easing = this._smoothOutEasing(200);\n }\n\n this._delta = 0;\n }\n\n const targetZoom = typeof this._targetZoom === 'number' ?\n this._targetZoom : tr.zoom;\n const startZoom = this._startZoom;\n const easing = this._easing;\n\n let finished = false;\n let zoom;\n if (this._type === 'wheel' && startZoom && easing) {\n\n const t = Math.min((browser.now() - this._lastWheelEventTime) / 200, 1);\n const k = easing(t);\n zoom = interpolates.number(startZoom, targetZoom, k);\n if (t < 1) {\n if (!this._frameId) {\n this._frameId = true;\n }\n } else {\n finished = true;\n }\n } else {\n zoom = targetZoom;\n finished = true;\n }\n\n this._active = true;\n\n if (finished) {\n this._active = false;\n this._finishTimeout = setTimeout(() => {\n this._zooming = false;\n this._triggerRenderFrame();\n delete this._targetZoom;\n delete this._finishTimeout;\n }, 200);\n }\n\n return {\n noInertia: true,\n needsRenderFrame: !finished,\n zoomDelta: zoom - tr.zoom,\n around: this._aroundPoint,\n originalEvent: this._lastWheelEvent\n };\n }\n\n _smoothOutEasing(duration: number) {\n let easing = defaultEasing;\n\n if (this._prevEase) {\n const currentEase = this._prevEase;\n const t = (browser.now() - currentEase.start) / currentEase.duration;\n const speed = currentEase.easing(t + 0.01) - currentEase.easing(t);\n\n // Quick hack to make new bezier that is continuous with last\n const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;\n const y = Math.sqrt(0.27 * 0.27 - x * x);\n\n easing = bezier(x, y, 0.25, 1);\n }\n\n this._prevEase = {\n start: browser.now(),\n duration,\n easing\n };\n\n return easing;\n }\n\n reset() {\n this._active = false;\n this._zooming = false;\n delete this._targetZoom;\n if (this._finishTimeout) {\n clearTimeout(this._finishTimeout);\n delete this._finishTimeout;\n }\n }\n}\n","import type {ClickZoomHandler} from '../click_zoom';\nimport type {TapZoomHandler} from './../tap_zoom';\n\n/**\n * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by\n * double clicking or double tapping.\n *\n * @group Handlers\n */\nexport class DoubleClickZoomHandler {\n\n _clickZoom: ClickZoomHandler;\n _tapZoom: TapZoomHandler;\n\n /** @internal */\n constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler) {\n this._clickZoom = clickZoom;\n this._tapZoom = TapZoom;\n }\n\n /**\n * Enables the \"double click to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.doubleClickZoom.enable();\n * ```\n */\n enable() {\n this._clickZoom.enable();\n this._tapZoom.enable();\n }\n\n /**\n * Disables the \"double click to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.doubleClickZoom.disable();\n * ```\n */\n disable() {\n this._clickZoom.disable();\n this._tapZoom.disable();\n }\n\n /**\n * Returns a Boolean indicating whether the \"double click to zoom\" interaction is enabled.\n *\n * @returns `true` if the \"double click to zoom\" interaction is enabled.\n */\n isEnabled() {\n return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();\n }\n\n /**\n * Returns a Boolean indicating whether the \"double click to zoom\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"double click to zoom\" interaction is active.\n */\n isActive() {\n return this._clickZoom.isActive() || this._tapZoom.isActive();\n }\n}\n","import type Point from '@mapbox/point-geometry';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\nimport {Handler} from '../handler_manager';\n\n/**\n * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking\n * It is used by other handlers\n */\nexport class ClickZoomHandler implements Handler {\n\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n\n /** @internal */\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n this.reset();\n }\n\n reset() {\n this._active = false;\n }\n\n dblclick(e: MouseEvent, point: Point) {\n e.preventDefault();\n return {\n cameraAnimation: (map: Map) => {\n map.easeTo({\n duration: 300,\n zoom: this._tr.zoom + (e.shiftKey ? -1 : 1),\n around: this._tr.unproject(point)\n }, {originalEvent: e});\n }\n };\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import {Handler} from '../handler_manager';\nimport {TapRecognizer, MAX_TAP_INTERVAL, MAX_DIST} from './tap_recognizer';\nimport type Point from '@mapbox/point-geometry';\n\nexport class TapDragZoomHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _swipePoint: Point;\n _swipeTouch: number;\n _tapTime: number;\n _tapPoint: Point;\n _tap: TapRecognizer;\n\n constructor() {\n\n this._tap = new TapRecognizer({\n numTouches: 1,\n numTaps: 1\n });\n\n this.reset();\n }\n\n reset() {\n this._active = false;\n delete this._swipePoint;\n delete this._swipeTouch;\n delete this._tapTime;\n delete this._tapPoint;\n this._tap.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this._swipePoint) return;\n\n if (!this._tapTime) {\n this._tap.touchstart(e, points, mapTouches);\n } else {\n const swipePoint = points[0];\n\n const soonEnough = e.timeStamp - this._tapTime < MAX_TAP_INTERVAL;\n const closeEnough = this._tapPoint.dist(swipePoint) < MAX_DIST;\n\n if (!soonEnough || !closeEnough) {\n this.reset();\n } else if (mapTouches.length > 0) {\n this._swipePoint = swipePoint;\n this._swipeTouch = mapTouches[0].identifier;\n }\n }\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._tapTime) {\n this._tap.touchmove(e, points, mapTouches);\n } else if (this._swipePoint) {\n if (mapTouches[0].identifier !== this._swipeTouch) {\n return;\n }\n\n const newSwipePoint = points[0];\n const dist = newSwipePoint.y - this._swipePoint.y;\n this._swipePoint = newSwipePoint;\n\n e.preventDefault();\n this._active = true;\n\n return {\n zoomDelta: dist / 128\n };\n }\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._tapTime) {\n const point = this._tap.touchend(e, points, mapTouches);\n if (point) {\n this._tapTime = e.timeStamp;\n this._tapPoint = point;\n }\n } else if (this._swipePoint) {\n if (mapTouches.length === 0) {\n this.reset();\n }\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import type {MousePanHandler} from '../mouse';\nimport type {TouchPanHandler} from './../touch_pan';\n\n/**\n * A {@link DragPanHandler} options object\n */\nexport type DragPanOptions = {\n /**\n * factor used to scale the drag velocity\n * @defaultValue 0\n */\n linearity?: number;\n /**\n * easing function applled to `map.panTo` when applying the drag.\n * @param t - the easing function\n * @defaultValue bezier(0, 0, 0.3, 1)\n */\n easing?: (t: number) => number;\n /**\n * the maximum value of the drag velocity.\n * @defaultValue 1400\n */\n deceleration?: number;\n /**\n * the rate at which the speed reduces after the pan ends.\n * @defaultValue 2500\n */\n maxSpeed?: number;\n};\n\n/**\n * The `DragPanHandler` allows the user to pan the map by clicking and dragging\n * the cursor.\n *\n * @group Handlers\n */\nexport class DragPanHandler {\n\n _el: HTMLElement;\n _mousePan: MousePanHandler;\n _touchPan: TouchPanHandler;\n _inertiaOptions: DragPanOptions | boolean;\n\n /** @internal */\n constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler) {\n this._el = el;\n this._mousePan = mousePan;\n this._touchPan = touchPan;\n }\n\n /**\n * Enables the \"drag to pan\" interaction.\n *\n * @param options - Options object\n * @example\n * ```ts\n * map.dragPan.enable();\n * map.dragPan.enable({\n * linearity: 0.3,\n * easing: bezier(0, 0, 0.3, 1),\n * maxSpeed: 1400,\n * deceleration: 2500,\n * });\n * ```\n */\n enable(options?: DragPanOptions | boolean) {\n this._inertiaOptions = options || {};\n this._mousePan.enable();\n this._touchPan.enable();\n this._el.classList.add('maplibregl-touch-drag-pan');\n }\n\n /**\n * Disables the \"drag to pan\" interaction.\n *\n * @example\n * ```ts\n * map.dragPan.disable();\n * ```\n */\n disable() {\n this._mousePan.disable();\n this._touchPan.disable();\n this._el.classList.remove('maplibregl-touch-drag-pan');\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pan\" interaction is enabled.\n *\n * @returns `true` if the \"drag to pan\" interaction is enabled.\n */\n isEnabled() {\n return this._mousePan.isEnabled() && this._touchPan.isEnabled();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pan\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to pan\" interaction is active.\n */\n isActive() {\n return this._mousePan.isActive() || this._touchPan.isActive();\n }\n}\n","import type {MousePitchHandler, MouseRotateHandler} from '../mouse';\n\nexport type DragRotateHandlerOptions = {\n /**\n * Control the map pitch in addition to the bearing\n * @defaultValue true\n */\n pitchWithRotate: boolean;\n}\n\n/**\n * The `DragRotateHandler` allows the user to rotate the map by clicking and\n * dragging the cursor while holding the right mouse button or `ctrl` key.\n *\n * @group Handlers\n */\nexport class DragRotateHandler {\n\n _mouseRotate: MouseRotateHandler;\n _mousePitch: MousePitchHandler;\n _pitchWithRotate: boolean;\n\n /** @internal */\n constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler) {\n this._pitchWithRotate = options.pitchWithRotate;\n this._mouseRotate = mouseRotate;\n this._mousePitch = mousePitch;\n }\n\n /**\n * Enables the \"drag to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.dragRotate.enable();\n * ```\n */\n enable() {\n this._mouseRotate.enable();\n if (this._pitchWithRotate) this._mousePitch.enable();\n }\n\n /**\n * Disables the \"drag to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.dragRotate.disable();\n * ```\n */\n disable() {\n this._mouseRotate.disable();\n this._mousePitch.disable();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to rotate\" interaction is enabled.\n *\n * @returns `true` if the \"drag to rotate\" interaction is enabled.\n */\n isEnabled() {\n return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled());\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to rotate\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to rotate\" interaction is active.\n */\n isActive() {\n return this._mouseRotate.isActive() || this._mousePitch.isActive();\n }\n}\n","import type {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, AroundCenterOptions} from '../two_fingers_touch';\nimport type {TapDragZoomHandler} from '../tap_drag_zoom';\n\n/**\n * The `TwoFingersTouchZoomRotateHandler` allows the user to zoom and rotate the map by\n * pinching on a touchscreen.\n *\n * They can zoom with one finger by double tapping and dragging. On the second tap,\n * hold the finger down and drag up or down to zoom in or out.\n *\n * @group Handlers\n */\nexport class TwoFingersTouchZoomRotateHandler {\n\n _el: HTMLElement;\n _touchZoom: TwoFingersTouchZoomHandler;\n _touchRotate: TwoFingersTouchRotateHandler;\n _tapDragZoom: TapDragZoomHandler;\n _rotationDisabled: boolean;\n _enabled: boolean;\n\n /** @internal */\n constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler) {\n this._el = el;\n this._touchZoom = touchZoom;\n this._touchRotate = touchRotate;\n this._tapDragZoom = tapDragZoom;\n this._rotationDisabled = false;\n this._enabled = true;\n }\n\n /**\n * Enables the \"pinch to rotate and zoom\" interaction.\n *\n * @param options - Options object.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.enable();\n * map.touchZoomRotate.enable({ around: 'center' });\n * ```\n */\n enable(options?: AroundCenterOptions | boolean | null) {\n this._touchZoom.enable(options);\n if (!this._rotationDisabled) this._touchRotate.enable(options);\n this._tapDragZoom.enable();\n this._el.classList.add('maplibregl-touch-zoom-rotate');\n }\n\n /**\n * Disables the \"pinch to rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.disable();\n * ```\n */\n disable() {\n this._touchZoom.disable();\n this._touchRotate.disable();\n this._tapDragZoom.disable();\n this._el.classList.remove('maplibregl-touch-zoom-rotate');\n }\n\n /**\n * Returns a Boolean indicating whether the \"pinch to rotate and zoom\" interaction is enabled.\n *\n * @returns `true` if the \"pinch to rotate and zoom\" interaction is enabled.\n */\n isEnabled() {\n return this._touchZoom.isEnabled() &&\n (this._rotationDisabled || this._touchRotate.isEnabled()) &&\n this._tapDragZoom.isEnabled();\n }\n\n /**\n * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.\n *\n * @returns `true` if the handler is active, `false` otherwise\n */\n isActive() {\n return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive();\n }\n\n /**\n * Disables the \"pinch to rotate\" interaction, leaving the \"pinch to zoom\"\n * interaction enabled.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.disableRotation();\n * ```\n */\n disableRotation() {\n this._rotationDisabled = true;\n this._touchRotate.disable();\n }\n\n /**\n * Enables the \"pinch to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.enable();\n * map.touchZoomRotate.enableRotation();\n * ```\n */\n enableRotation() {\n this._rotationDisabled = false;\n if (this._touchZoom.isEnabled()) this._touchRotate.enable();\n }\n}\n","import {Event} from '../util/evented';\nimport {DOM} from '../util/dom';\nimport {Map, CompleteMapOptions} from './map';\nimport {HandlerInertia} from './handler_inertia';\nimport {MapEventHandler, BlockableMapEventHandler} from './handler/map_event';\nimport {BoxZoomHandler} from './handler/box_zoom';\nimport {TapZoomHandler} from './handler/tap_zoom';\nimport {generateMouseRotationHandler, generateMousePitchHandler, generateMousePanHandler} from './handler/mouse';\nimport {TouchPanHandler} from './handler/touch_pan';\nimport {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';\nimport {KeyboardHandler} from './handler/keyboard';\nimport {ScrollZoomHandler} from './handler/scroll_zoom';\nimport {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';\nimport {ClickZoomHandler} from './handler/click_zoom';\nimport {TapDragZoomHandler} from './handler/tap_drag_zoom';\nimport {DragPanHandler} from './handler/shim/drag_pan';\nimport {DragRotateHandler} from './handler/shim/drag_rotate';\nimport {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';\nimport {extend} from '../util/util';\nimport {browser} from '../util/browser';\nimport Point from '@mapbox/point-geometry';\n\nexport type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;\n\nconst isMoving = p => p.zoom || p.drag || p.pitch || p.rotate;\n\nclass RenderFrameEvent extends Event {\n type: 'renderFrame';\n timeStamp: number;\n}\n\n/**\n * Handlers interpret dom events and return camera changes that should be\n * applied to the map (`HandlerResult`s). The camera changes are all deltas.\n * The handler itself should have no knowledge of the map's current state.\n * This makes it easier to merge multiple results and keeps handlers simpler.\n * For example, if there is a mousedown and mousemove, the mousePan handler\n * would return a `panDelta` on the mousemove.\n */\nexport interface Handler {\n enable(): void;\n disable(): void;\n isEnabled(): boolean;\n isActive(): boolean;\n /**\n * `reset` can be called by the manager at any time and must reset everything to it's original state\n */\n reset(): void;\n // Handlers can optionally implement these methods.\n // They are called with dom events whenever those dom evens are received.\n readonly touchstart?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchmove?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchmoveWindow?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchend?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchcancel?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly contextmenu?: (e: MouseEvent) => HandlerResult | void;\n readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void;\n readonly keydown?: (e: KeyboardEvent) => HandlerResult | void;\n readonly keyup?: (e: KeyboardEvent) => HandlerResult | void;\n /**\n * `renderFrame` is the only non-dom event. It is called during render\n * frames and can be used to smooth camera changes (see scroll handler).\n */\n readonly renderFrame?: () => HandlerResult | void;\n}\n\n/**\n * All handler methods that are called with events can optionally return a `HandlerResult`.\n */\nexport type HandlerResult = {\n panDelta?: Point;\n zoomDelta?: number;\n bearingDelta?: number;\n pitchDelta?: number;\n /**\n * the point to not move when changing the camera\n */\n around?: Point | null;\n /**\n * same as above, except for pinch actions, which are given higher priority\n */\n pinchAround?: Point | null;\n /**\n * A method that can fire a one-off easing by directly changing the map's camera.\n */\n cameraAnimation?: (map: Map) => any;\n /**\n * The last three properties are needed by only one handler: scrollzoom.\n * The DOM event to be used as the `originalEvent` on any camera change events.\n */\n originalEvent?: Event;\n /**\n * Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom).\n */\n needsRenderFrame?: boolean;\n /**\n * The camera changes won't get recorded for inertial zooming.\n */\n noInertia?: boolean;\n};\n\nexport type EventInProgress = {\n handlerName: string;\n originalEvent: Event;\n}\n\nexport type EventsInProgress = {\n zoom?: EventInProgress;\n pitch?: EventInProgress;\n rotate?: EventInProgress;\n drag?: EventInProgress;\n}\n\nfunction hasChange(result: HandlerResult) {\n return (result.panDelta && result.panDelta.mag()) || result.zoomDelta || result.bearingDelta || result.pitchDelta;\n}\n\nexport class HandlerManager {\n _map: Map;\n _el: HTMLElement;\n _handlers: Array<{\n handlerName: string;\n handler: Handler;\n allowed: Array;\n }>;\n _eventsInProgress: EventsInProgress;\n _frameId: number;\n _inertia: HandlerInertia;\n _bearingSnap: number;\n _handlersById: {[x: string]: Handler};\n _updatingCamera: boolean;\n _changes: Array<[HandlerResult, EventsInProgress, {[handlerName: string]: Event}]>;\n _terrainMovement: boolean;\n _zoom: {handlerName: string};\n _previousActiveHandlers: {[x: string]: Handler};\n _listeners: Array<[Window | Document | HTMLElement, string, {\n passive?: boolean;\n capture?: boolean;\n } | undefined]>;\n\n constructor(map: Map, options: CompleteMapOptions) {\n this._map = map;\n this._el = this._map.getCanvasContainer();\n this._handlers = [];\n this._handlersById = {};\n this._changes = [];\n\n this._inertia = new HandlerInertia(map);\n this._bearingSnap = options.bearingSnap;\n this._previousActiveHandlers = {};\n\n // Track whether map is currently moving, to compute start/move/end events\n this._eventsInProgress = {};\n\n this._addDefaultHandlers(options);\n\n const el = this._el;\n\n this._listeners = [\n // This needs to be `passive: true` so that a double tap fires two\n // pairs of touchstart/end events in iOS Safari 13. If this is set to\n // `passive: false` then the second pair of events is only fired if\n // preventDefault() is called on the first touchstart. Calling preventDefault()\n // undesirably prevents click events.\n [el, 'touchstart', {passive: true}],\n // This needs to be `passive: false` so that scrolls and pinches can be\n // prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12.\n [el, 'touchmove', {passive: false}],\n [el, 'touchend', undefined],\n [el, 'touchcancel', undefined],\n\n [el, 'mousedown', undefined],\n [el, 'mousemove', undefined],\n [el, 'mouseup', undefined],\n\n // Bind window-level event listeners for move and up/end events. In the absence of\n // the pointer capture API, which is not supported by all necessary platforms,\n // window-level event listeners give us the best shot at capturing events that\n // fall outside the map canvas element. Use `{capture: true}` for the move event\n // to prevent map move events from being fired during a drag.\n [document, 'mousemove', {capture: true}],\n [document, 'mouseup', undefined],\n\n [el, 'mouseover', undefined],\n [el, 'mouseout', undefined],\n [el, 'dblclick', undefined],\n [el, 'click', undefined],\n\n [el, 'keydown', {capture: false}],\n [el, 'keyup', undefined],\n\n [el, 'wheel', {passive: false}],\n [el, 'contextmenu', undefined],\n\n [window, 'blur', undefined]\n ];\n\n for (const [target, type, listenerOptions] of this._listeners) {\n DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);\n }\n }\n\n destroy() {\n for (const [target, type, listenerOptions] of this._listeners) {\n DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);\n }\n }\n\n _addDefaultHandlers(options: CompleteMapOptions) {\n const map = this._map;\n const el = map.getCanvasContainer();\n this._add('mapEvent', new MapEventHandler(map, options));\n\n const boxZoom = map.boxZoom = new BoxZoomHandler(map, options);\n this._add('boxZoom', boxZoom);\n if (options.interactive && options.boxZoom) {\n boxZoom.enable();\n }\n\n const tapZoom = new TapZoomHandler(map);\n const clickZoom = new ClickZoomHandler(map);\n map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);\n this._add('tapZoom', tapZoom);\n this._add('clickZoom', clickZoom);\n if (options.interactive && options.doubleClickZoom) {\n map.doubleClickZoom.enable();\n }\n\n const tapDragZoom = new TapDragZoomHandler();\n this._add('tapDragZoom', tapDragZoom);\n\n const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map);\n this._add('touchPitch', touchPitch);\n if (options.interactive && options.touchPitch) {\n map.touchPitch.enable(options.touchPitch);\n }\n\n const mouseRotate = generateMouseRotationHandler(options);\n const mousePitch = generateMousePitchHandler(options);\n map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);\n this._add('mouseRotate', mouseRotate, ['mousePitch']);\n this._add('mousePitch', mousePitch, ['mouseRotate']);\n if (options.interactive && options.dragRotate) {\n map.dragRotate.enable();\n }\n\n const mousePan = generateMousePanHandler(options);\n const touchPan = new TouchPanHandler(options, map);\n map.dragPan = new DragPanHandler(el, mousePan, touchPan);\n this._add('mousePan', mousePan);\n this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']);\n if (options.interactive && options.dragPan) {\n map.dragPan.enable(options.dragPan);\n }\n\n const touchRotate = new TwoFingersTouchRotateHandler();\n const touchZoom = new TwoFingersTouchZoomHandler();\n map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);\n this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);\n this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);\n if (options.interactive && options.touchZoomRotate) {\n map.touchZoomRotate.enable(options.touchZoomRotate);\n }\n\n const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame());\n this._add('scrollZoom', scrollZoom, ['mousePan']);\n if (options.interactive && options.scrollZoom) {\n map.scrollZoom.enable(options.scrollZoom);\n }\n\n const keyboard = map.keyboard = new KeyboardHandler(map);\n this._add('keyboard', keyboard);\n if (options.interactive && options.keyboard) {\n map.keyboard.enable();\n }\n\n this._add('blockableMapEvent', new BlockableMapEventHandler(map));\n }\n\n _add(handlerName: string, handler: Handler, allowed?: Array) {\n this._handlers.push({handlerName, handler, allowed});\n this._handlersById[handlerName] = handler;\n }\n\n stop(allowEndAnimation: boolean) {\n // do nothing if this method was triggered by a gesture update\n if (this._updatingCamera) return;\n\n for (const {handler} of this._handlers) {\n handler.reset();\n }\n this._inertia.clear();\n this._fireEvents({}, {}, allowEndAnimation);\n this._changes = [];\n }\n\n isActive() {\n for (const {handler} of this._handlers) {\n if (handler.isActive()) return true;\n }\n return false;\n }\n\n isZooming() {\n return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();\n }\n isRotating() {\n return !!this._eventsInProgress.rotate;\n }\n\n isMoving() {\n return Boolean(isMoving(this._eventsInProgress)) || this.isZooming();\n }\n\n _blockedByActive(activeHandlers: {[x: string]: Handler}, allowed: Array, myName: string) {\n for (const name in activeHandlers) {\n if (name === myName) continue;\n if (!allowed || allowed.indexOf(name) < 0) {\n return true;\n }\n }\n return false;\n }\n\n handleWindowEvent = (e: { type: 'mousemove' | 'mouseup' | 'touchmove'}) => {\n this.handleEvent(e, `${e.type}Window`);\n };\n\n _getMapTouches(touches: TouchList) {\n const mapTouches = [];\n for (const t of touches) {\n const target = (t.target as any as Node);\n if (this._el.contains(target)) {\n mapTouches.push(t);\n }\n }\n return mapTouches as any as TouchList;\n }\n\n handleEvent = (e: Event, eventName?: keyof Handler) => {\n\n if (e.type === 'blur') {\n this.stop(true);\n return;\n }\n\n this._updatingCamera = true;\n\n const inputEvent = e.type === 'renderFrame' ? undefined : e as InputEvent;\n\n /*\n * We don't call e.preventDefault() for any events by default.\n * Handlers are responsible for calling it where necessary.\n */\n\n const mergedHandlerResult: HandlerResult = {needsRenderFrame: false};\n const eventsInProgress: EventsInProgress = {};\n const activeHandlers = {};\n const eventTouches = (e as TouchEvent).touches;\n\n const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined;\n const points = mapTouches ? DOM.touchPos(this._el, mapTouches) : DOM.mousePos(this._el, ((e as MouseEvent)));\n\n for (const {handlerName, handler, allowed} of this._handlers) {\n if (!handler.isEnabled()) continue;\n\n let data: HandlerResult;\n if (this._blockedByActive(activeHandlers, allowed, handlerName)) {\n handler.reset();\n\n } else {\n if (handler[eventName || e.type]) {\n data = handler[eventName || e.type](e, points, mapTouches);\n this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent);\n if (data && data.needsRenderFrame) {\n this._triggerRenderFrame();\n }\n }\n }\n\n if (data || handler.isActive()) {\n activeHandlers[handlerName] = handler;\n }\n }\n\n const deactivatedHandlers: {[handlerName: string]: Event} = {};\n for (const name in this._previousActiveHandlers) {\n if (!activeHandlers[name]) {\n deactivatedHandlers[name] = inputEvent;\n }\n }\n this._previousActiveHandlers = activeHandlers;\n\n if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) {\n this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]);\n this._triggerRenderFrame();\n }\n\n if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) {\n this._map._stop(true);\n }\n\n this._updatingCamera = false;\n\n const {cameraAnimation} = mergedHandlerResult;\n if (cameraAnimation) {\n this._inertia.clear();\n this._fireEvents({}, {}, true);\n this._changes = [];\n cameraAnimation(this._map);\n }\n };\n\n mergeHandlerResult(mergedHandlerResult: HandlerResult,\n eventsInProgress: EventsInProgress,\n handlerResult: HandlerResult,\n name: string,\n e?: InputEvent) {\n if (!handlerResult) return;\n\n extend(mergedHandlerResult, handlerResult);\n\n const eventData = {handlerName: name, originalEvent: handlerResult.originalEvent || e};\n\n // track which handler changed which camera property\n if (handlerResult.zoomDelta !== undefined) {\n eventsInProgress.zoom = eventData;\n }\n if (handlerResult.panDelta !== undefined) {\n eventsInProgress.drag = eventData;\n }\n if (handlerResult.pitchDelta !== undefined) {\n eventsInProgress.pitch = eventData;\n }\n if (handlerResult.bearingDelta !== undefined) {\n eventsInProgress.rotate = eventData;\n }\n\n }\n\n _applyChanges() {\n const combined: HandlerResult = {};\n const combinedEventsInProgress: EventsInProgress = {};\n const combinedDeactivatedHandlers = {};\n\n for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) {\n\n if (change.panDelta) combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta);\n if (change.zoomDelta) combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;\n if (change.bearingDelta) combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;\n if (change.pitchDelta) combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;\n if (change.around !== undefined) combined.around = change.around;\n if (change.pinchAround !== undefined) combined.pinchAround = change.pinchAround;\n if (change.noInertia) combined.noInertia = change.noInertia;\n\n extend(combinedEventsInProgress, eventsInProgress);\n extend(combinedDeactivatedHandlers, deactivatedHandlers);\n }\n\n this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);\n this._changes = [];\n }\n\n _updateMapTransform(combinedResult: HandlerResult,\n combinedEventsInProgress: EventsInProgress,\n deactivatedHandlers: {[handlerName: string]: Event}) {\n const map = this._map;\n const tr = map._getTransformForUpdate();\n const terrain = map.terrain;\n\n if (!hasChange(combinedResult) && !(terrain && this._terrainMovement)) {\n return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);\n }\n\n let {panDelta, zoomDelta, bearingDelta, pitchDelta, around, pinchAround} = combinedResult;\n\n if (pinchAround !== undefined) {\n around = pinchAround;\n }\n\n // stop any ongoing camera animations (easeTo, flyTo)\n map._stop(true);\n\n around = around || map.transform.centerPoint;\n const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);\n if (bearingDelta) tr.bearing += bearingDelta;\n if (pitchDelta) tr.pitch += pitchDelta;\n if (zoomDelta) tr.zoom += zoomDelta;\n\n if (!terrain) {\n tr.setLocationAtPoint(loc, around);\n } else {\n // when 3d-terrain is enabled act a little different:\n // - dragging do not drag the picked point itself, instead it drags the map by pixel-delta.\n // With this approach it is no longer possible to pick a point from somewhere near\n // the horizon to the center in one move.\n // So this logic avoids the problem, that in such cases you easily loose orientation.\n if (!this._terrainMovement &&\n (combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) {\n // When starting to drag or move, flag it and register moveend to clear flagging\n this._terrainMovement = true;\n this._map._elevationFreeze = true;\n tr.setLocationAtPoint(loc, around);\n this._map.once('moveend', () => {\n this._map._elevationFreeze = false;\n this._terrainMovement = false;\n tr.recalculateZoom(map.terrain);\n });\n } else if (combinedEventsInProgress.drag && this._terrainMovement) {\n // drag map\n tr.center = tr.pointLocation(tr.centerPoint.sub(panDelta));\n } else {\n tr.setLocationAtPoint(loc, around);\n }\n }\n\n map._applyUpdatedTransform(tr);\n\n this._map._update();\n if (!combinedResult.noInertia) this._inertia.record(combinedResult);\n this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);\n\n }\n\n _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {[handlerName: string]: Event}, allowEndAnimation: boolean) {\n\n const wasMoving = isMoving(this._eventsInProgress);\n const nowMoving = isMoving(newEventsInProgress);\n\n const startEvents = {};\n\n for (const eventName in newEventsInProgress) {\n const {originalEvent} = newEventsInProgress[eventName];\n if (!this._eventsInProgress[eventName]) {\n startEvents[`${eventName}start`] = originalEvent;\n }\n this._eventsInProgress[eventName] = newEventsInProgress[eventName];\n }\n\n // fire start events only after this._eventsInProgress has been updated\n if (!wasMoving && nowMoving) {\n this._fireEvent('movestart', nowMoving.originalEvent);\n }\n\n for (const name in startEvents) {\n this._fireEvent(name, startEvents[name]);\n }\n\n if (nowMoving) {\n this._fireEvent('move', nowMoving.originalEvent);\n }\n\n for (const eventName in newEventsInProgress) {\n const {originalEvent} = newEventsInProgress[eventName];\n this._fireEvent(eventName, originalEvent);\n }\n\n const endEvents = {};\n\n let originalEndEvent;\n for (const eventName in this._eventsInProgress) {\n const {handlerName, originalEvent} = this._eventsInProgress[eventName];\n if (!this._handlersById[handlerName].isActive()) {\n delete this._eventsInProgress[eventName];\n originalEndEvent = deactivatedHandlers[handlerName] || originalEvent;\n endEvents[`${eventName}end`] = originalEndEvent;\n }\n }\n\n for (const name in endEvents) {\n this._fireEvent(name, endEvents[name]);\n }\n\n const stillMoving = isMoving(this._eventsInProgress);\n if (allowEndAnimation && (wasMoving || nowMoving) && !stillMoving) {\n this._updatingCamera = true;\n const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);\n\n const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;\n\n if (inertialEase && (inertialEase.essential || !browser.prefersReducedMotion)) {\n if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {\n inertialEase.bearing = 0;\n }\n inertialEase.freezeElevation = true;\n this._map.easeTo(inertialEase, {originalEvent: originalEndEvent});\n } else {\n this._map.fire(new Event('moveend', {originalEvent: originalEndEvent}));\n if (shouldSnapToNorth(this._map.getBearing())) {\n this._map.resetNorth();\n }\n }\n this._updatingCamera = false;\n }\n\n }\n\n _fireEvent(type: string, e?: Event) {\n this._map.fire(new Event(type, e ? {originalEvent: e} : {}));\n }\n\n _requestFrame() {\n this._map.triggerRepaint();\n return this._map._renderTaskQueue.add(timeStamp => {\n delete this._frameId;\n this.handleEvent(new RenderFrameEvent('renderFrame', {timeStamp}));\n this._applyChanges();\n });\n }\n\n _triggerRenderFrame() {\n if (this._frameId === undefined) {\n this._frameId = this._requestFrame();\n }\n }\n}\n","import {extend, warnOnce, clamp, wrap, defaultEasing, pick} from '../util/util';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {browser} from '../util/browser';\nimport {LngLat} from '../geo/lng_lat';\nimport {LngLatBounds} from '../geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {Event, Evented} from '../util/evented';\nimport {Terrain} from '../render/terrain';\n\nimport type {Transform} from '../geo/transform';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport type {TaskID} from '../util/task_queue';\nimport type {PaddingOptions} from '../geo/edge_insets';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\n\n/**\n * A [Point](https://github.com/mapbox/point-geometry) or an array of two numbers representing `x` and `y` screen coordinates in pixels.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let p1 = new Point(-77, 38); // a PointLike which is a Point\n * let p2 = [-77, 38]; // a PointLike which is an array of two numbers\n * ```\n */\nexport type PointLike = Point | [number, number];\n\n/**\n * A helper to allow require of at least one propery\n */\nexport type RequireAtLeastOne = { [K in keyof T]-?: Required> & Partial>>; }[keyof T];\n\n/**\n * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location,\n * zoom, bearing, and pitch of the camera. All properties are optional, and when a property is omitted, the current\n * camera value for that property will remain unchanged.\n *\n * @example\n * Set the map's initial perspective with CameraOptions\n * ```ts\n * let map = new maplibregl.Map({\n * container: 'map',\n * style: 'https://demotiles.maplibre.org/style.json',\n * center: [-73.5804, 45.53483],\n * pitch: 60,\n * bearing: -60,\n * zoom: 10\n * });\n * ```\n * @see [Set pitch and bearing](https://maplibre.org/maplibre-gl-js/docs/examples/set-perspective/)\n * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/)\n * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/)\n * @see [Display buildings in 3D](https://maplibre.org/maplibre-gl-js/docs/examples/3d-buildings/)\n */\nexport type CameraOptions = CenterZoomBearing & {\n /**\n * The desired pitch in degrees. The pitch is the angle towards the horizon\n * measured in degrees with a range between 0 and 60 degrees. For example, pitch: 0 provides the appearance\n * of looking straight down at the map, while pitch: 60 tilts the user's perspective towards the horizon.\n * Increasing the pitch value is often used to display 3D objects.\n */\n pitch?: number;\n /**\n * If `zoom` is specified, `around` determines the point around which the zoom is centered.\n */\n around?: LngLatLike;\n};\n\n/**\n * Holds center, zoom and bearing properties\n */\nexport type CenterZoomBearing = {\n /**\n * The desired center.\n */\n center?: LngLatLike;\n /**\n * The desired zoom level.\n */\n zoom?: number;\n /**\n * The desired bearing in degrees. The bearing is the compass direction that\n * is \"up\". For example, `bearing: 90` orients the map so that east is up.\n */\n bearing?: number;\n}\n\n/**\n * The options object related to the {@link Map#jumpTo} method\n */\nexport type JumpToOptions = CameraOptions & {\n /**\n * Dimensions in pixels applied on each side of the viewport for shifting the vanishing point.\n */\n padding?: PaddingOptions;\n}\n\n/**\n * A options object for the {@link Map#cameraForBounds} method\n */\nexport type CameraForBoundsOptions = CameraOptions & {\n /**\n * The amount of padding in pixels to add to the given bounds.\n */\n padding?: number | RequireAtLeastOne;\n /**\n * The center of the given bounds relative to the map's center, measured in pixels.\n * @defaultValue [0, 0]\n */\n offset?: PointLike;\n /**\n * The maximum zoom level to allow when the camera would transition to the specified bounds.\n */\n maxZoom?: number;\n}\n\n/**\n * The {@link Map#flyTo} options object\n */\nexport type FlyToOptions = AnimationOptions & CameraOptions & {\n /**\n * The zooming \"curve\" that will occur along the\n * flight path. A high value maximizes zooming for an exaggerated animation, while a low\n * value minimizes zooming for an effect closer to {@link Map#easeTo}. 1.42 is the average\n * value selected by participants in the user study discussed in\n * [van Wijk (2003)](https://www.win.tue.nl/~vanwijk/zoompan.pdf). A value of\n * `Math.pow(6, 0.25)` would be equivalent to the root mean squared average velocity. A\n * value of 1 would produce a circular motion.\n * @defaultValue 1.42\n */\n curve?: number;\n /**\n * The zero-based zoom level at the peak of the flight path. If\n * `options.curve` is specified, this option is ignored.\n */\n minZoom?: number;\n /**\n * The average speed of the animation defined in relation to\n * `options.curve`. A speed of 1.2 means that the map appears to move along the flight path\n * by 1.2 times `options.curve` screenfuls every second. A _screenful_ is the map's visible span.\n * It does not correspond to a fixed physical distance, but varies by zoom level.\n * @defaultValue 1.2\n */\n speed?: number;\n /**\n * The average speed of the animation measured in screenfuls\n * per second, assuming a linear timing curve. If `options.speed` is specified, this option is ignored.\n */\n screenSpeed?: number;\n /**\n * The animation's maximum duration, measured in milliseconds.\n * If duration exceeds maximum duration, it resets to 0.\n */\n maxDuration?: number;\n /**\n * The amount of padding in pixels to add to the given bounds.\n */\n padding?: number | RequireAtLeastOne;\n}\n\nexport type EaseToOptions = AnimationOptions & CameraOptions & {\n delayEndEvents?: number;\n padding?: number | RequireAtLeastOne;\n}\n\n/**\n * Options for {@link Map#fitBounds} method\n */\nexport type FitBoundsOptions = FlyToOptions & {\n /**\n * If `true`, the map transitions using {@link Map#easeTo}. If `false`, the map transitions using {@link Map#flyTo}.\n * See those functions and {@link AnimationOptions} for information about options available.\n * @defaultValue false\n */\n linear?: boolean;\n /**\n * The center of the given bounds relative to the map's center, measured in pixels.\n * @defaultValue [0, 0]\n */\n offset?: PointLike;\n /**\n * The maximum zoom level to allow when the map view transitions to the specified bounds.\n */\n maxZoom?: number;\n}\n\n/**\n * Options common to map movement methods that involve animation, such as {@link Map#panBy} and\n * {@link Map#easeTo}, controlling the duration and easing function of the animation. All properties\n * are optional.\n *\n */\nexport type AnimationOptions = {\n /**\n * The animation's duration, measured in milliseconds.\n */\n duration?: number;\n /**\n * A function taking a time in the range 0..1 and returning a number where 0 is\n * the initial state and 1 is the final state.\n */\n easing?: (_: number) => number;\n /**\n * of the target center relative to real map container center at the end of animation.\n */\n offset?: PointLike;\n /**\n * If `false`, no animation will occur.\n */\n animate?: boolean;\n /**\n * If `true`, then the animation is considered essential and will not be affected by\n * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/\\@media/prefers-reduced-motion).\n */\n essential?: boolean;\n /**\n * Default false. Needed in 3D maps to let the camera stay in a constant\n * height based on sea-level. After the animation finished the zoom-level will be recalculated in respect of\n * the distance from the camera to the center-coordinate-altitude.\n */\n freezeElevation?: boolean;\n};\n\n/**\n * A callback hook that allows manipulating the camera and being notified about camera updates before they happen\n */\nexport type CameraUpdateTransformFunction = (next: {\n center: LngLat;\n zoom: number;\n pitch: number;\n bearing: number;\n elevation: number;\n}) => {\n center?: LngLat;\n zoom?: number;\n pitch?: number;\n bearing?: number;\n elevation?: number;\n};\n\nexport abstract class Camera extends Evented {\n transform: Transform;\n terrain: Terrain;\n\n _moving: boolean;\n _zooming: boolean;\n _rotating: boolean;\n _pitching: boolean;\n _padding: boolean;\n\n _bearingSnap: number;\n _easeStart: number;\n _easeOptions: {\n duration?: number;\n easing?: (_: number) => number;\n };\n _easeId: string | void;\n\n _onEaseFrame: (_: number) => void;\n _onEaseEnd: (easeId?: string) => void;\n _easeFrameId: TaskID;\n\n /**\n * @internal\n * holds the geographical coordinate of the target\n */\n _elevationCenter: LngLat;\n /**\n * @internal\n * holds the targ altitude value, = center elevation of the target.\n * This value may changes during flight, because new terrain-tiles loads during flight.\n */\n _elevationTarget: number;\n /**\n * @internal\n * holds the start altitude value, = center elevation before animation begins\n * this value will recalculated during flight in respect of changing _elevationTarget values,\n * so the linear interpolation between start and target keeps smooth and without jumps.\n */\n _elevationStart: number;\n /**\n * @internal\n * Saves the current state of the elevation freeze - this is used during map movement to prevent \"rocky\" camera movement.\n */\n _elevationFreeze: boolean;\n /**\n * @internal\n * Used to track accumulated changes during continuous interaction\n */\n _requestedCameraState?: Transform;\n /**\n * A callback used to defer camera updates or apply arbitrary constraints.\n * If specified, this Camera instance can be used as a stateless component in React etc.\n */\n transformCameraUpdate: CameraUpdateTransformFunction | null;\n\n abstract _requestRenderFrame(a: () => void): TaskID;\n abstract _cancelRenderFrame(_: TaskID): void;\n\n constructor(transform: Transform, options: {\n bearingSnap: number;\n }) {\n super();\n this._moving = false;\n this._zooming = false;\n this.transform = transform;\n this._bearingSnap = options.bearingSnap;\n\n this.on('moveend', () => {\n delete this._requestedCameraState;\n });\n }\n\n /**\n * Returns the map's geographical centerpoint.\n *\n * @returns The map's geographical centerpoint.\n * @example\n * Return a LngLat object such as `{lng: 0, lat: 0}`\n * ```ts\n * let center = map.getCenter();\n * // access longitude and latitude values directly\n * let {lng, lat} = map.getCenter();\n * ```\n */\n getCenter(): LngLat { return new LngLat(this.transform.center.lng, this.transform.center.lat); }\n\n /**\n * Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param center - The centerpoint to set.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * map.setCenter([-74, 38]);\n * ```\n */\n setCenter(center: LngLatLike, eventData?: any) {\n return this.jumpTo({center}, eventData);\n }\n\n /**\n * Pans the map by the specified offset.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param offset - `x` and `y` coordinates by which to pan the map.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n panBy(offset: PointLike, options?: AnimationOptions, eventData?: any): this {\n offset = Point.convert(offset).mult(-1);\n return this.panTo(this.transform.center, extend({offset}, options), eventData);\n }\n\n /**\n * Pans the map to the specified location with an animated transition.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param lnglat - The location to pan the map to.\n * @param options - Options describing the destination and animation of the transition.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * map.panTo([-74, 38]);\n * // Specify that the panTo animation should last 5000 milliseconds.\n * map.panTo([-74, 38], {duration: 5000});\n * ```\n * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/)\n */\n panTo(lnglat: LngLatLike, options?: AnimationOptions, eventData?: any): this {\n return this.easeTo(extend({\n center: lnglat\n }, options), eventData);\n }\n\n /**\n * Returns the map's current zoom level.\n *\n * @returns The map's current zoom level.\n * @example\n * ```ts\n * map.getZoom();\n * ```\n */\n getZoom(): number { return this.transform.zoom; }\n\n /**\n * Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param zoom - The zoom level to set (0-20).\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom to the zoom level 5 without an animated transition\n * ```ts\n * map.setZoom(5);\n * ```\n */\n setZoom(zoom: number, eventData?: any): this {\n this.jumpTo({zoom}, eventData);\n return this;\n }\n\n /**\n * Zooms the map to the specified zoom level, with an animated transition.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param zoom - The zoom level to transition to.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // Zoom to the zoom level 5 without an animated transition\n * map.zoomTo(5);\n * // Zoom to the zoom level 8 with an animated transition\n * map.zoomTo(8, {\n * duration: 2000,\n * offset: [100, 50]\n * });\n * ```\n */\n zoomTo(zoom: number, options?: AnimationOptions | null, eventData?: any): this {\n return this.easeTo(extend({\n zoom\n }, options), eventData);\n }\n\n /**\n * Increases the map's zoom level by 1.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom the map in one level with a custom animation duration\n * ```ts\n * map.zoomIn({duration: 1000});\n * ```\n */\n zoomIn(options?: AnimationOptions, eventData?: any): this {\n this.zoomTo(this.getZoom() + 1, options, eventData);\n return this;\n }\n\n /**\n * Decreases the map's zoom level by 1.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom the map out one level with a custom animation offset\n * ```ts\n * map.zoomOut({offset: [80, 60]});\n * ```\n */\n zoomOut(options?: AnimationOptions, eventData?: any): this {\n this.zoomTo(this.getZoom() - 1, options, eventData);\n return this;\n }\n\n /**\n * Returns the map's current bearing. The bearing is the compass direction that is \"up\"; for example, a bearing\n * of 90° orients the map so that east is up.\n *\n * @returns The map's current bearing.\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n getBearing(): number { return this.transform.bearing; }\n\n /**\n * Sets the map's bearing (rotation). The bearing is the compass direction that is \"up\"; for example, a bearing\n * of 90° orients the map so that east is up.\n *\n * Equivalent to `jumpTo({bearing: bearing})`.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param bearing - The desired bearing.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Rotate the map to 90 degrees\n * ```ts\n * map.setBearing(90);\n * ```\n */\n setBearing(bearing: number, eventData?: any): this {\n this.jumpTo({bearing}, eventData);\n return this;\n }\n\n /**\n * Returns the current padding applied around the map viewport.\n *\n * @returns The current padding around the map viewport.\n */\n getPadding(): PaddingOptions { return this.transform.padding; }\n\n /**\n * Sets the padding in pixels around the viewport.\n *\n * Equivalent to `jumpTo({padding: padding})`.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param padding - The desired padding.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Sets a left padding of 300px, and a top padding of 50px\n * ```ts\n * map.setPadding({ left: 300, top: 50 });\n * ```\n */\n setPadding(padding: PaddingOptions, eventData?: any): this {\n this.jumpTo({padding}, eventData);\n return this;\n }\n\n /**\n * Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction\n * that is \"up\"; for example, a bearing of 90° orients the map so that east is up.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param bearing - The desired bearing.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n rotateTo(bearing: number, options?: AnimationOptions, eventData?: any): this {\n return this.easeTo(extend({\n bearing\n }, options), eventData);\n }\n\n /**\n * Rotates the map so that north is up (0° bearing), with an animated transition.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n resetNorth(options?: AnimationOptions, eventData?: any): this {\n this.rotateTo(0, extend({duration: 1000}, options), eventData);\n return this;\n }\n\n /**\n * Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n resetNorthPitch(options?: AnimationOptions, eventData?: any): this {\n this.easeTo(extend({\n bearing: 0,\n pitch: 0,\n duration: 1000\n }, options), eventData);\n return this;\n }\n\n /**\n * Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the\n * `bearingSnap` threshold).\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n snapToNorth(options?: AnimationOptions, eventData?: any): this {\n if (Math.abs(this.getBearing()) < this._bearingSnap) {\n return this.resetNorth(options, eventData);\n }\n return this;\n }\n\n /**\n * Returns the map's current pitch (tilt).\n *\n * @returns The map's current pitch, measured in degrees away from the plane of the screen.\n */\n getPitch(): number { return this.transform.pitch; }\n\n /**\n * Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`.\n *\n * Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`.\n *\n * @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60).\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n setPitch(pitch: number, eventData?: any): this {\n this.jumpTo({pitch}, eventData);\n return this;\n }\n\n /**\n * @param bounds - Calculate the center for these bounds in the viewport and use\n * the highest zoom level up to and including `Map#getMaxZoom()` that fits\n * in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0.\n * @param options - Options object\n * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.\n * If map is unable to fit, method will warn and return undefined.\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * let newCameraTransform = map.cameraForBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n */\n cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CenterZoomBearing {\n bounds = LngLatBounds.convert(bounds);\n const bearing = options && options.bearing || 0;\n return this._cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), bearing, options);\n }\n\n /**\n * @internal\n * Calculate the center of these two points in the viewport and use\n * the highest zoom level up to and including `Map#getMaxZoom()` that fits\n * the points in the viewport at the specified bearing.\n * @param p0 - First point\n * @param p1 - Second point\n * @param bearing - Desired map bearing at end of animation, in degrees\n * @param options - the camera options\n * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.\n * If map is unable to fit, method will warn and return undefined.\n * @example\n * ```ts\n * let p0 = [-79, 43];\n * let p1 = [-73, 45];\n * let bearing = 90;\n * let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n */\n _cameraForBoxAndBearing(p0: LngLatLike, p1: LngLatLike, bearing: number, options?: CameraForBoundsOptions): CenterZoomBearing {\n const defaultPadding = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n options = extend({\n padding: defaultPadding,\n offset: [0, 0],\n maxZoom: this.transform.maxZoom\n }, options);\n\n if (typeof options.padding === 'number') {\n const p = options.padding;\n options.padding = {\n top: p,\n bottom: p,\n right: p,\n left: p\n };\n }\n\n options.padding = extend(defaultPadding, options.padding) as PaddingOptions;\n const tr = this.transform;\n const edgePadding = tr.padding;\n\n // We want to calculate the upper right and lower left of the box defined by p0 and p1\n // in a coordinate system rotate to match the destination bearing.\n const p0world = tr.project(LngLat.convert(p0));\n const p1world = tr.project(LngLat.convert(p1));\n const p0rotated = p0world.rotate(-bearing * Math.PI / 180);\n const p1rotated = p1world.rotate(-bearing * Math.PI / 180);\n\n const upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));\n const lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));\n\n // Calculate zoom: consider the original bbox and padding.\n const size = upperRight.sub(lowerLeft);\n const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x;\n const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y;\n\n if (scaleY < 0 || scaleX < 0) {\n warnOnce(\n 'Map cannot fit within canvas with the given bounds, padding, and/or offset.'\n );\n return undefined;\n }\n\n const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);\n\n // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.\n const offset = Point.convert(options.offset);\n const paddingOffsetX = (options.padding.left - options.padding.right) / 2;\n const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;\n const paddingOffset = new Point(paddingOffsetX, paddingOffsetY);\n const rotatedPaddingOffset = paddingOffset.rotate(bearing * Math.PI / 180);\n const offsetAtInitialZoom = offset.add(rotatedPaddingOffset);\n const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));\n\n const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));\n\n return {\n center,\n zoom,\n bearing\n };\n }\n\n /**\n * Pans and zooms the map to contain its visible area within the specified geographical bounds.\n * This function will also reset the map's bearing to 0 if bearing is nonzero.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param bounds - Center these bounds in the viewport and use the highest\n * zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport.\n * @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)\n */\n fitBounds(bounds: LngLatBoundsLike, options?: FitBoundsOptions, eventData?: any): this {\n return this._fitInternal(\n this.cameraForBounds(bounds, options),\n options,\n eventData);\n }\n\n /**\n * Pans, rotates and zooms the map to to fit the box made by points p0 and p1\n * once the map is rotated to the specified bearing. To zoom without rotating,\n * pass in the current map bearing.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`.\n *\n * @param p0 - First point on screen, in pixel coordinates\n * @param p1 - Second point on screen, in pixel coordinates\n * @param bearing - Desired map bearing at end of animation, in degrees\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * let p0 = [220, 400];\n * let p1 = [500, 900];\n * map.fitScreenCoordinates(p0, p1, map.getBearing(), {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n * @see Used by {@link BoxZoomHandler}\n */\n fitScreenCoordinates(p0: PointLike, p1: PointLike, bearing: number, options?: FitBoundsOptions, eventData?: any): this {\n return this._fitInternal(\n this._cameraForBoxAndBearing(\n this.transform.pointLocation(Point.convert(p0)),\n this.transform.pointLocation(Point.convert(p1)),\n bearing,\n options),\n options,\n eventData);\n }\n\n _fitInternal(calculatedOptions?: CenterZoomBearing, options?: FitBoundsOptions, eventData?: any): this {\n // cameraForBounds warns + returns undefined if unable to fit:\n if (!calculatedOptions) return this;\n\n options = extend(calculatedOptions, options);\n // Explicitly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.\n delete options.padding;\n\n return options.linear ?\n this.easeTo(options, eventData) :\n this.flyTo(options, eventData);\n }\n\n /**\n * Changes any combination of center, zoom, bearing, and pitch, without\n * an animated transition. The map will retain its current values for any\n * details not specified in `options`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // jump to coordinates at current zoom\n * map.jumpTo({center: [0, 0]});\n * // jump with zoom, pitch, and bearing options\n * map.jumpTo({\n * center: [0, 0],\n * zoom: 8,\n * pitch: 45,\n * bearing: 90\n * });\n * ```\n * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/)\n * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/)\n */\n jumpTo(options: JumpToOptions, eventData?: any): this {\n this.stop();\n\n const tr = this._getTransformForUpdate();\n let zoomChanged = false,\n bearingChanged = false,\n pitchChanged = false;\n\n if ('zoom' in options && tr.zoom !== +options.zoom) {\n zoomChanged = true;\n tr.zoom = +options.zoom;\n }\n\n if (options.center !== undefined) {\n tr.center = LngLat.convert(options.center);\n }\n\n if ('bearing' in options && tr.bearing !== +options.bearing) {\n bearingChanged = true;\n tr.bearing = +options.bearing;\n }\n\n if ('pitch' in options && tr.pitch !== +options.pitch) {\n pitchChanged = true;\n tr.pitch = +options.pitch;\n }\n\n if (options.padding != null && !tr.isPaddingEqual(options.padding)) {\n tr.padding = options.padding;\n }\n this._applyUpdatedTransform(tr);\n\n this.fire(new Event('movestart', eventData))\n .fire(new Event('move', eventData));\n\n if (zoomChanged) {\n this.fire(new Event('zoomstart', eventData))\n .fire(new Event('zoom', eventData))\n .fire(new Event('zoomend', eventData));\n }\n\n if (bearingChanged) {\n this.fire(new Event('rotatestart', eventData))\n .fire(new Event('rotate', eventData))\n .fire(new Event('rotateend', eventData));\n }\n\n if (pitchChanged) {\n this.fire(new Event('pitchstart', eventData))\n .fire(new Event('pitch', eventData))\n .fire(new Event('pitchend', eventData));\n }\n\n return this.fire(new Event('moveend', eventData));\n }\n\n /**\n * Calculates pitch, zoom and bearing for looking at `newCenter` with the camera position being `newCenter`\n * and returns them as {@link CameraOptions}.\n * @param from - The camera to look from\n * @param altitudeFrom - The altitude of the camera to look from\n * @param to - The center to look at\n * @param altitudeTo - Optional altitude of the center to look at. If none given the ground height will be used.\n * @returns the calculated camera options\n */\n calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo: number = 0): CameraOptions {\n const fromMerc = MercatorCoordinate.fromLngLat(from, altitudeFrom);\n const toMerc = MercatorCoordinate.fromLngLat(to, altitudeTo);\n const dx = toMerc.x - fromMerc.x;\n const dy = toMerc.y - fromMerc.y;\n const dz = toMerc.z - fromMerc.z;\n\n const distance3D = Math.hypot(dx, dy, dz);\n if (distance3D === 0) throw new Error('Can\\'t calculate camera options with same From and To');\n\n const groundDistance = Math.hypot(dx, dy);\n\n const zoom = this.transform.scaleZoom(this.transform.cameraToCenterDistance / distance3D / this.transform.tileSize);\n const bearing = (Math.atan2(dx, -dy) * 180) / Math.PI;\n let pitch = (Math.acos(groundDistance / distance3D) * 180) / Math.PI;\n pitch = dz < 0 ? 90 - pitch : 90 + pitch;\n\n return {\n center: toMerc.toLngLat(),\n zoom,\n pitch,\n bearing\n };\n }\n\n /**\n * Changes any combination of `center`, `zoom`, `bearing`, `pitch`, and `padding` with an animated transition\n * between old and new values. The map will retain its current values for any\n * details not specified in `options`.\n *\n * Note: The transition will happen instantly if the user has enabled\n * the `reduced motion` accessibility feature enabled in their operating system,\n * unless `options` includes `essential: true`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options describing the destination and animation of the transition.\n * Accepts {@link CameraOptions} and {@link AnimationOptions}.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n easeTo(options: EaseToOptions & {\n easeId?: string;\n noMoveStart?: boolean;\n }, eventData?: any): this {\n this._stop(false, options.easeId);\n\n options = extend({\n offset: [0, 0],\n duration: 500,\n easing: defaultEasing\n }, options);\n\n if (options.animate === false || (!options.essential && browser.prefersReducedMotion)) options.duration = 0;\n\n const tr = this._getTransformForUpdate(),\n startZoom = this.getZoom(),\n startBearing = this.getBearing(),\n startPitch = this.getPitch(),\n startPadding = this.getPadding(),\n\n zoom = 'zoom' in options ? +options.zoom : startZoom,\n bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing,\n pitch = 'pitch' in options ? +options.pitch : startPitch,\n padding = 'padding' in options ? options.padding : tr.padding;\n\n const offsetAsPoint = Point.convert(options.offset);\n let pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n const locationAtOffset = tr.pointLocation(pointAtOffset);\n const center = LngLat.convert(options.center || locationAtOffset);\n this._normalizeCenter(center);\n\n const from = tr.project(locationAtOffset);\n const delta = tr.project(center).sub(from);\n const finalScale = tr.zoomScale(zoom - startZoom);\n\n let around, aroundPoint;\n\n if (options.around) {\n around = LngLat.convert(options.around);\n aroundPoint = tr.locationPoint(around);\n }\n\n const currently = {\n moving: this._moving,\n zooming: this._zooming,\n rotating: this._rotating,\n pitching: this._pitching\n };\n\n this._zooming = this._zooming || (zoom !== startZoom);\n this._rotating = this._rotating || (startBearing !== bearing);\n this._pitching = this._pitching || (pitch !== startPitch);\n this._padding = !tr.isPaddingEqual(padding as PaddingOptions);\n\n this._easeId = options.easeId;\n this._prepareEase(eventData, options.noMoveStart, currently);\n if (this.terrain) this._prepareElevation(center);\n\n this._ease((k) => {\n if (this._zooming) {\n tr.zoom = interpolates.number(startZoom, zoom, k);\n }\n if (this._rotating) {\n tr.bearing = interpolates.number(startBearing, bearing, k);\n }\n if (this._pitching) {\n tr.pitch = interpolates.number(startPitch, pitch, k);\n }\n if (this._padding) {\n tr.interpolatePadding(startPadding, padding as PaddingOptions, k);\n // When padding is being applied, Transform#centerPoint is changing continuously,\n // thus we need to recalculate offsetPoint every frame\n pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n }\n\n if (this.terrain && !options.freezeElevation) this._updateElevation(k);\n\n if (around) {\n tr.setLocationAtPoint(around, aroundPoint);\n } else {\n const scale = tr.zoomScale(tr.zoom - startZoom);\n const base = zoom > startZoom ?\n Math.min(2, finalScale) :\n Math.max(0.5, finalScale);\n const speedup = Math.pow(base, 1 - k);\n const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));\n tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);\n }\n\n this._applyUpdatedTransform(tr);\n\n this._fireMoveEvents(eventData);\n\n }, (interruptingEaseId?: string) => {\n if (this.terrain) this._finalizeElevation();\n this._afterEase(eventData, interruptingEaseId);\n }, options as any);\n\n return this;\n }\n\n _prepareEase(eventData: any, noMoveStart: boolean, currently: any = {}) {\n this._moving = true;\n if (!noMoveStart && !currently.moving) {\n this.fire(new Event('movestart', eventData));\n }\n if (this._zooming && !currently.zooming) {\n this.fire(new Event('zoomstart', eventData));\n }\n if (this._rotating && !currently.rotating) {\n this.fire(new Event('rotatestart', eventData));\n }\n if (this._pitching && !currently.pitching) {\n this.fire(new Event('pitchstart', eventData));\n }\n }\n\n _prepareElevation(center: LngLat) {\n this._elevationCenter = center;\n this._elevationStart = this.transform.elevation;\n this._elevationTarget = this.terrain.getElevationForLngLatZoom(center, this.transform.tileZoom);\n this._elevationFreeze = true;\n }\n\n _updateElevation(k: number) {\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);\n const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);\n // target terrain updated during flight, slowly move camera to new height\n if (k < 1 && elevation !== this._elevationTarget) {\n const pitch1 = this._elevationTarget - this._elevationStart;\n const pitch2 = (elevation - (pitch1 * k + this._elevationStart)) / (1 - k);\n this._elevationStart += k * (pitch1 - pitch2);\n this._elevationTarget = elevation;\n }\n this.transform.elevation = interpolates.number(this._elevationStart, this._elevationTarget, k);\n }\n\n _finalizeElevation() {\n this._elevationFreeze = false;\n this.transform.recalculateZoom(this.terrain);\n }\n\n /**\n * @internal\n * Called when the camera is about to be manipulated.\n * If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes.\n * This underlying transform represents the \"desired state\" proposed by input handlers / animations / UI controls.\n * It may differ from the state used for rendering (`this.transform`).\n * @returns Transform to apply changes to\n */\n _getTransformForUpdate(): Transform {\n if (!this.transformCameraUpdate) return this.transform;\n\n if (!this._requestedCameraState) {\n this._requestedCameraState = this.transform.clone();\n }\n return this._requestedCameraState;\n }\n\n /**\n * @internal\n * Called after the camera is done being manipulated.\n * @param tr - the requested camera end state\n * Call `transformCameraUpdate` if present, and then apply the \"approved\" changes.\n */\n _applyUpdatedTransform(tr: Transform) {\n if (!this.transformCameraUpdate) return;\n\n const nextTransform = tr.clone();\n const {\n center,\n zoom,\n pitch,\n bearing,\n elevation\n } = this.transformCameraUpdate(nextTransform);\n if (center) nextTransform.center = center;\n if (zoom !== undefined) nextTransform.zoom = zoom;\n if (pitch !== undefined) nextTransform.pitch = pitch;\n if (bearing !== undefined) nextTransform.bearing = bearing;\n if (elevation !== undefined) nextTransform.elevation = elevation;\n this.transform.apply(nextTransform);\n }\n\n _fireMoveEvents(eventData?: any) {\n this.fire(new Event('move', eventData));\n if (this._zooming) {\n this.fire(new Event('zoom', eventData));\n }\n if (this._rotating) {\n this.fire(new Event('rotate', eventData));\n }\n if (this._pitching) {\n this.fire(new Event('pitch', eventData));\n }\n }\n\n _afterEase(eventData?: any, easeId?: string) {\n // if this easing is being stopped to start another easing with\n // the same id then don't fire any events to avoid extra start/stop events\n if (this._easeId && easeId && this._easeId === easeId) {\n return;\n }\n delete this._easeId;\n\n const wasZooming = this._zooming;\n const wasRotating = this._rotating;\n const wasPitching = this._pitching;\n this._moving = false;\n this._zooming = false;\n this._rotating = false;\n this._pitching = false;\n this._padding = false;\n\n if (wasZooming) {\n this.fire(new Event('zoomend', eventData));\n }\n if (wasRotating) {\n this.fire(new Event('rotateend', eventData));\n }\n if (wasPitching) {\n this.fire(new Event('pitchend', eventData));\n }\n this.fire(new Event('moveend', eventData));\n }\n\n /**\n * Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that\n * evokes flight. The animation seamlessly incorporates zooming and panning to help\n * the user maintain her bearings even after traversing a great distance.\n *\n * Note: The animation will be skipped, and this will behave equivalently to `jumpTo`\n * if the user has the `reduced motion` accessibility feature enabled in their operating system,\n * unless 'options' includes `essential: true`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options describing the destination and animation of the transition.\n * Accepts {@link CameraOptions}, {@link AnimationOptions},\n * and the following additional options.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // fly with default options to null island\n * map.flyTo({center: [0, 0], zoom: 9});\n * // using flyTo options\n * map.flyTo({\n * center: [0, 0],\n * zoom: 9,\n * speed: 0.2,\n * curve: 1,\n * easing(t) {\n * return t;\n * }\n * });\n * ```\n * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/)\n * @see [Slowly fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto-options/)\n * @see [Fly to a location based on scroll position](https://maplibre.org/maplibre-gl-js/docs/examples/scroll-fly-to/)\n */\n flyTo(options: FlyToOptions, eventData?: any): this {\n // Fall through to jumpTo if user has set prefers-reduced-motion\n if (!options.essential && browser.prefersReducedMotion) {\n const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']) as CameraOptions;\n return this.jumpTo(coercedOptions, eventData);\n }\n\n // This method implements an “optimal path” animation, as detailed in:\n //\n // Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and panning.” INFOVIS\n // ’03. pp. 15–22. .\n //\n // Where applicable, local variable documentation begins with the associated variable or\n // function in van Wijk (2003).\n\n this.stop();\n\n options = extend({\n offset: [0, 0],\n speed: 1.2,\n curve: 1.42,\n easing: defaultEasing\n }, options);\n\n const tr = this._getTransformForUpdate(),\n startZoom = this.getZoom(),\n startBearing = this.getBearing(),\n startPitch = this.getPitch(),\n startPadding = this.getPadding();\n\n const zoom = 'zoom' in options ? clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;\n const bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing;\n const pitch = 'pitch' in options ? +options.pitch : startPitch;\n const padding = 'padding' in options ? options.padding : tr.padding;\n\n const scale = tr.zoomScale(zoom - startZoom);\n const offsetAsPoint = Point.convert(options.offset);\n let pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n const locationAtOffset = tr.pointLocation(pointAtOffset);\n const center = LngLat.convert(options.center || locationAtOffset);\n this._normalizeCenter(center);\n\n const from = tr.project(locationAtOffset);\n const delta = tr.project(center).sub(from);\n\n let rho = options.curve;\n\n // w₀: Initial visible span, measured in pixels at the initial scale.\n const w0 = Math.max(tr.width, tr.height),\n // w₁: Final visible span, measured in pixels with respect to the initial scale.\n w1 = w0 / scale,\n // Length of the flight path as projected onto the ground plane, measured in pixels from\n // the world image origin at the initial scale.\n u1 = delta.mag();\n\n if ('minZoom' in options) {\n const minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);\n // wm: Maximum visible span, measured in pixels with respect to the initial\n // scale.\n const wMax = w0 / tr.zoomScale(minZoom - startZoom);\n rho = Math.sqrt(wMax / u1 * 2);\n }\n\n // ρ²\n const rho2 = rho * rho;\n\n /**\n * rᵢ: Returns the zoom-out factor at one end of the animation.\n *\n * @param descent - `true` for the descent, `false` for the ascent\n */\n function zoomOutFactor(descent: boolean) {\n const b = (w1 * w1 - w0 * w0 + (descent ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (descent ? w1 : w0) * rho2 * u1);\n return Math.log(Math.sqrt(b * b + 1) - b);\n }\n\n function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; }\n function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; }\n function tanh(n) { return sinh(n) / cosh(n); }\n\n // r₀: Zoom-out factor during ascent.\n const r0 = zoomOutFactor(false);\n\n // w(s): Returns the visible span on the ground, measured in pixels with respect to the\n // initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°.\n let w: (_: number) => number = function (s) {\n return (cosh(r0) / cosh(r0 + rho * s));\n };\n\n // u(s): Returns the distance along the flight path as projected onto the ground plane,\n // measured in pixels from the world image origin at the initial scale.\n let u: (_: number) => number = function (s) {\n return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;\n };\n\n // S: Total length of the flight path, measured in ρ-screenfuls.\n let S = (zoomOutFactor(true) - r0) / rho;\n\n // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.\n if (Math.abs(u1) < 0.000001 || !isFinite(S)) {\n // Perform a more or less instantaneous transition if the path is too short.\n if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData);\n\n const k = w1 < w0 ? -1 : 1;\n S = Math.abs(Math.log(w1 / w0)) / rho;\n\n u = function() { return 0; };\n w = function(s) { return Math.exp(k * rho * s); };\n }\n\n if ('duration' in options) {\n options.duration = +options.duration;\n } else {\n const V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;\n options.duration = 1000 * S / V;\n }\n\n if (options.maxDuration && options.duration > options.maxDuration) {\n options.duration = 0;\n }\n\n this._zooming = true;\n this._rotating = (startBearing !== bearing);\n this._pitching = (pitch !== startPitch);\n this._padding = !tr.isPaddingEqual(padding as PaddingOptions);\n\n this._prepareEase(eventData, false);\n if (this.terrain) this._prepareElevation(center);\n\n this._ease((k) => {\n // s: The distance traveled along the flight path, measured in ρ-screenfuls.\n const s = k * S;\n const scale = 1 / w(s);\n tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale);\n\n if (this._rotating) {\n tr.bearing = interpolates.number(startBearing, bearing, k);\n }\n if (this._pitching) {\n tr.pitch = interpolates.number(startPitch, pitch, k);\n }\n if (this._padding) {\n tr.interpolatePadding(startPadding, padding as PaddingOptions, k);\n // When padding is being applied, Transform#centerPoint is changing continuously,\n // thus we need to recalculate offsetPoint every frame\n pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n }\n\n if (this.terrain && !options.freezeElevation) this._updateElevation(k);\n\n const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(scale));\n tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);\n\n this._applyUpdatedTransform(tr);\n\n this._fireMoveEvents(eventData);\n\n }, () => {\n if (this.terrain) this._finalizeElevation();\n this._afterEase(eventData);\n }, options);\n\n return this;\n }\n\n isEasing() {\n return !!this._easeFrameId;\n }\n\n /**\n * Stops any animated transition underway.\n *\n * @returns `this`\n */\n stop(): this {\n return this._stop();\n }\n\n _stop(allowGestures?: boolean, easeId?: string): this {\n if (this._easeFrameId) {\n this._cancelRenderFrame(this._easeFrameId);\n delete this._easeFrameId;\n delete this._onEaseFrame;\n }\n\n if (this._onEaseEnd) {\n // The _onEaseEnd function might emit events which trigger new\n // animation, which sets a new _onEaseEnd. Ensure we don't delete\n // it unintentionally.\n const onEaseEnd = this._onEaseEnd;\n delete this._onEaseEnd;\n onEaseEnd.call(this, easeId);\n }\n if (!allowGestures) {\n const handlers = (this as any).handlers;\n if (handlers) handlers.stop(false);\n }\n return this;\n }\n\n _ease(frame: (_: number) => void,\n finish: () => void,\n options: {\n animate?: boolean;\n duration?: number;\n easing?: (_: number) => number;\n }) {\n if (options.animate === false || options.duration === 0) {\n frame(1);\n finish();\n } else {\n this._easeStart = browser.now();\n this._easeOptions = options;\n this._onEaseFrame = frame;\n this._onEaseEnd = finish;\n this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);\n }\n }\n\n // Callback for map._requestRenderFrame\n _renderFrameCallback = () => {\n const t = Math.min((browser.now() - this._easeStart) / this._easeOptions.duration, 1);\n this._onEaseFrame(this._easeOptions.easing(t));\n\n // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted\n if (t < 1 && this._easeFrameId) {\n this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);\n } else {\n this.stop();\n }\n };\n\n // convert bearing so that it's numerically close to the current one so that it interpolates properly\n _normalizeBearing(bearing: number, currentBearing: number) {\n bearing = wrap(bearing, -180, 180);\n const diff = Math.abs(bearing - currentBearing);\n if (Math.abs(bearing - 360 - currentBearing) < diff) bearing -= 360;\n if (Math.abs(bearing + 360 - currentBearing) < diff) bearing += 360;\n return bearing;\n }\n\n // If a path crossing the antimeridian would be shorter, extend the final coordinate so that\n // interpolating between the two endpoints will cross it.\n _normalizeCenter(center: LngLat) {\n const tr = this.transform;\n if (!tr.renderWorldCopies || tr.lngRange) return;\n\n const delta = center.lng - tr.center.lng;\n center.lng +=\n delta > 180 ? -360 :\n delta < -180 ? 360 : 0;\n }\n\n /**\n * Query the current elevation of location. It return null if terrain is not enabled. the elevation is in meters relative to mean sea-level\n * @param lngLatLike - [x,y] or LngLat coordinates of the location\n * @returns elevation in meters\n */\n queryTerrainElevation(lngLatLike: LngLatLike): number | null {\n if (!this.terrain) {\n return null;\n }\n const elevation = this.terrain.getElevationForLngLatZoom(LngLat.convert(lngLatLike), this.transform.tileZoom);\n /**\n * Different zoomlevels with different terrain-tiles the elevation-values are not the same.\n * map.transform.elevation variable with the center-altitude.\n * In maplibre the proj-matrix is translated by this value in negative z-direction.\n * So we need to add this value to the elevation to get the correct value.\n */\n return elevation - this.transform.elevation;\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\nimport type {MapDataEvent} from '../events';\nimport type {StyleSpecification} from '@maplibre/maplibre-gl-style-spec';\n/**\n * The {@link AttributionControl} options\n */\ntype AttributionOptions = {\n /**\n * If `true`, the attribution control will always collapse when moving the map. If `false`,\n * force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide.\n * **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.**\n */\n compact?: boolean;\n /**\n * Attributions to show in addition to any other attributions.\n */\n customAttribution?: string | Array;\n};\n\n/**\n * An `AttributionControl` control presents the map's attribution information. By default, the attribution control is expanded (regardless of map width).\n * @group Markers and Controls\n * @example\n * ```ts\n * let map = new maplibregl.Map({attributionControl: false})\n * .addControl(new maplibregl.AttributionControl({\n * compact: true\n * }));\n * ```\n */\nexport class AttributionControl implements IControl {\n options: AttributionOptions;\n _map: Map;\n _compact: boolean;\n _container: HTMLElement;\n _innerContainer: HTMLElement;\n _compactButton: HTMLElement;\n _editLink: HTMLAnchorElement;\n _attribHTML: string;\n styleId: string;\n styleOwner: string;\n\n /**\n * @param options - the attribution options\n */\n constructor(options: AttributionOptions = {}) {\n this.options = options;\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-right';\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._compact = this.options && this.options.compact;\n this._container = DOM.create('details', 'maplibregl-ctrl maplibregl-ctrl-attrib');\n this._compactButton = DOM.create('summary', 'maplibregl-ctrl-attrib-button', this._container);\n this._compactButton.addEventListener('click', this._toggleAttribution);\n this._setElementTitle(this._compactButton, 'ToggleAttribution');\n this._innerContainer = DOM.create('div', 'maplibregl-ctrl-attrib-inner', this._container);\n\n this._updateAttributions();\n this._updateCompact();\n\n this._map.on('styledata', this._updateData);\n this._map.on('sourcedata', this._updateData);\n this._map.on('terrain', this._updateData);\n this._map.on('resize', this._updateCompact);\n this._map.on('drag', this._updateCompactMinimize);\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n\n this._map.off('styledata', this._updateData);\n this._map.off('sourcedata', this._updateData);\n this._map.off('terrain', this._updateData);\n this._map.off('resize', this._updateCompact);\n this._map.off('drag', this._updateCompactMinimize);\n\n this._map = undefined;\n this._compact = undefined;\n this._attribHTML = undefined;\n }\n\n _setElementTitle(element: HTMLElement, title: string) {\n const str = this._map._getUIString(`AttributionControl.${title}`);\n element.title = str;\n element.setAttribute('aria-label', str);\n }\n\n _toggleAttribution = () => {\n if (this._container.classList.contains('maplibregl-compact')) {\n if (this._container.classList.contains('maplibregl-compact-show')) {\n this._container.setAttribute('open', '');\n this._container.classList.remove('maplibregl-compact-show');\n } else {\n this._container.classList.add('maplibregl-compact-show');\n this._container.removeAttribute('open');\n }\n }\n };\n\n _updateData = (e: MapDataEvent) => {\n if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style' || e.type === 'terrain')) {\n this._updateAttributions();\n }\n };\n\n _updateAttributions() {\n if (!this._map.style) return;\n let attributions: Array = [];\n if (this.options.customAttribution) {\n if (Array.isArray(this.options.customAttribution)) {\n attributions = attributions.concat(\n this.options.customAttribution.map(attribution => {\n if (typeof attribution !== 'string') return '';\n return attribution;\n })\n );\n } else if (typeof this.options.customAttribution === 'string') {\n attributions.push(this.options.customAttribution);\n }\n }\n\n if (this._map.style.stylesheet) {\n const stylesheet = this._map.style.stylesheet as StyleSpecification & { owner: string; id: string };\n this.styleOwner = stylesheet.owner;\n this.styleId = stylesheet.id;\n }\n\n const sourceCaches = this._map.style.sourceCaches;\n for (const id in sourceCaches) {\n const sourceCache = sourceCaches[id];\n if (sourceCache.used || sourceCache.usedForTerrain) {\n const source = sourceCache.getSource();\n if (source.attribution && attributions.indexOf(source.attribution) < 0) {\n attributions.push(source.attribution);\n }\n }\n }\n\n // remove any entries that are whitespace\n attributions = attributions.filter(e => String(e).trim());\n\n // remove any entries that are substrings of another entry.\n // first sort by length so that substrings come first\n attributions.sort((a, b) => a.length - b.length);\n attributions = attributions.filter((attrib, i) => {\n for (let j = i + 1; j < attributions.length; j++) {\n if (attributions[j].indexOf(attrib) >= 0) { return false; }\n }\n return true;\n });\n\n // check if attribution string is different to minimize DOM changes\n const attribHTML = attributions.join(' | ');\n if (attribHTML === this._attribHTML) return;\n\n this._attribHTML = attribHTML;\n\n if (attributions.length) {\n this._innerContainer.innerHTML = attribHTML;\n this._container.classList.remove('maplibregl-attrib-empty');\n } else {\n this._container.classList.add('maplibregl-attrib-empty');\n }\n this._updateCompact();\n // remove old DOM node from _editLink\n this._editLink = null;\n }\n\n _updateCompact = () => {\n if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {\n if (this._compact === false) {\n this._container.setAttribute('open', '');\n } else if (!this._container.classList.contains('maplibregl-compact') && !this._container.classList.contains('maplibregl-attrib-empty')) {\n this._container.setAttribute('open', '');\n this._container.classList.add('maplibregl-compact', 'maplibregl-compact-show');\n }\n } else {\n this._container.setAttribute('open', '');\n if (this._container.classList.contains('maplibregl-compact')) {\n this._container.classList.remove('maplibregl-compact', 'maplibregl-compact-show');\n }\n }\n };\n\n _updateCompactMinimize = () => {\n if (this._container.classList.contains('maplibregl-compact')) {\n if (this._container.classList.contains('maplibregl-compact-show')) {\n this._container.classList.remove('maplibregl-compact-show');\n }\n }\n };\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\n\n/**\n * The {@link LogoControl} options object\n */\ntype LogoOptions = {\n /**\n * If `true`, force a compact logo.\n * If `false`, force the full logo. The default is a responsive logo that collapses when the map is less than 640 pixels wide.\n */\n compact?: boolean;\n};\n\n/**\n * A `LogoControl` is a control that adds the watermark.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.LogoControl({compact: false}));\n * ```\n **/\nexport class LogoControl implements IControl {\n options: LogoOptions;\n _map: Map;\n _compact: boolean;\n _container: HTMLElement;\n\n constructor(options: LogoOptions = {}) {\n this.options = options;\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-left';\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._compact = this.options && this.options.compact;\n this._container = DOM.create('div', 'maplibregl-ctrl');\n const anchor = DOM.create('a', 'maplibregl-ctrl-logo');\n anchor.target = '_blank';\n anchor.rel = 'noopener nofollow';\n anchor.href = 'https://maplibre.org/';\n anchor.setAttribute('aria-label', this._map._getUIString('LogoControl.Title'));\n anchor.setAttribute('rel', 'noopener nofollow');\n this._container.appendChild(anchor);\n this._container.style.display = 'block';\n\n this._map.on('resize', this._updateCompact);\n this._updateCompact();\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('resize', this._updateCompact);\n this._map = undefined;\n this._compact = undefined;\n }\n\n _updateCompact = () => {\n const containerChildren = this._container.children;\n if (containerChildren.length) {\n const anchor = containerChildren[0];\n if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {\n if (this._compact !== false) {\n anchor.classList.add('maplibregl-compact');\n }\n } else {\n anchor.classList.remove('maplibregl-compact');\n }\n }\n };\n\n}\n","export type TaskID = number; // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61\n\ntype Task = {\n callback: (timeStamp: number) => void;\n id: TaskID;\n cancelled: boolean;\n};\n\nexport class TaskQueue {\n _queue: Array;\n _id: TaskID;\n _cleared: boolean;\n _currentlyRunning: Array | false;\n\n constructor() {\n this._queue = [];\n this._id = 0;\n this._cleared = false;\n this._currentlyRunning = false;\n }\n\n add(callback: (timeStamp: number) => void): TaskID {\n const id = ++this._id;\n const queue = this._queue;\n queue.push({callback, id, cancelled: false});\n return id;\n }\n\n remove(id: TaskID) {\n const running = this._currentlyRunning;\n const queue = running ? this._queue.concat(running) : this._queue;\n for (const task of queue) {\n if (task.id === id) {\n task.cancelled = true;\n return;\n }\n }\n }\n\n run(timeStamp: number = 0) {\n if (this._currentlyRunning) throw new Error('Attempting to run(), but is already running.');\n const queue = this._currentlyRunning = this._queue;\n\n // Tasks queued by callbacks in the current queue should be executed\n // on the next run, not the current run.\n this._queue = [];\n\n for (const task of queue) {\n if (task.cancelled) continue;\n task.callback(timeStamp);\n if (this._cleared) break;\n }\n\n this._cleared = false;\n this._currentlyRunning = false;\n }\n\n clear() {\n if (this._currentlyRunning) {\n this._cleared = true;\n }\n this._queue = [];\n }\n}\n","import type {RequestParameters} from '../util/ajax';\n\nexport type PerformanceMetrics = {\n loadTime: number;\n fullLoadTime: number;\n fps: number;\n percentDroppedFrames: number;\n totalFrames: number;\n};\n\nexport enum PerformanceMarkers {\n create = 'create',\n load = 'load',\n fullLoad = 'fullLoad'\n}\n\nlet lastFrameTime = null;\nlet frameTimes = [];\n\nconst minFramerateTarget = 60;\nconst frameTimeTarget = 1000 / minFramerateTarget;\n\nconst loadTimeKey = 'loadTime';\nconst fullLoadTimeKey = 'fullLoadTime';\n\nexport const PerformanceUtils = {\n mark(marker: PerformanceMarkers) {\n performance.mark(marker);\n },\n frame(timestamp: number) {\n const currTimestamp = timestamp;\n if (lastFrameTime != null) {\n const frameTime = currTimestamp - lastFrameTime;\n frameTimes.push(frameTime);\n }\n lastFrameTime = currTimestamp;\n },\n clearMetrics() {\n lastFrameTime = null;\n frameTimes = [];\n performance.clearMeasures(loadTimeKey);\n performance.clearMeasures(fullLoadTimeKey);\n\n for (const marker in PerformanceMarkers) {\n performance.clearMarks(PerformanceMarkers[marker]);\n }\n },\n\n getPerformanceMetrics(): PerformanceMetrics {\n performance.measure(loadTimeKey, PerformanceMarkers.create, PerformanceMarkers.load);\n performance.measure(fullLoadTimeKey, PerformanceMarkers.create, PerformanceMarkers.fullLoad);\n const loadTime = performance.getEntriesByName(loadTimeKey)[0].duration;\n const fullLoadTime = performance.getEntriesByName(fullLoadTimeKey)[0].duration;\n const totalFrames = frameTimes.length;\n\n const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;\n const fps = 1 / avgFrameTime;\n\n // count frames that missed our framerate target\n const droppedFrames = frameTimes\n .filter((frameTime) => frameTime > frameTimeTarget)\n .reduce((acc, curr) => {\n return acc + (curr - frameTimeTarget) / frameTimeTarget;\n }, 0);\n const percentDroppedFrames = (droppedFrames / (totalFrames + droppedFrames)) * 100;\n\n return {\n loadTime,\n fullLoadTime,\n fps,\n percentDroppedFrames,\n totalFrames\n };\n }\n};\n\n/**\n * @internal\n * Safe wrapper for the performance resource timing API in web workers with graceful degradation\n */\nexport class RequestPerformance {\n _marks: {\n start: string;\n end: string;\n measure: string;\n };\n\n constructor (request: RequestParameters) {\n this._marks = {\n start: [request.url, 'start'].join('#'),\n end: [request.url, 'end'].join('#'),\n measure: request.url.toString()\n };\n\n performance.mark(this._marks.start);\n }\n\n finish() {\n performance.mark(this._marks.end);\n let resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // fallback if web worker implementation of perf.getEntriesByName returns empty\n if (resourceTimingData.length === 0) {\n performance.measure(this._marks.measure, this._marks.start, this._marks.end);\n resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // cleanup\n performance.clearMarks(this._marks.start);\n performance.clearMarks(this._marks.end);\n performance.clearMeasures(this._marks.measure);\n }\n\n return resourceTimingData;\n }\n}\n\nexport default performance;\n","export const defaultLocale = {\n 'AttributionControl.ToggleAttribution': 'Toggle attribution',\n 'AttributionControl.MapFeedback': 'Map feedback',\n 'FullscreenControl.Enter': 'Enter fullscreen',\n 'FullscreenControl.Exit': 'Exit fullscreen',\n 'GeolocateControl.FindMyLocation': 'Find my location',\n 'GeolocateControl.LocationNotAvailable': 'Location not available',\n 'LogoControl.Title': 'Mapbox logo',\n 'NavigationControl.ResetBearing': 'Reset bearing to north',\n 'NavigationControl.ZoomIn': 'Zoom in',\n 'NavigationControl.ZoomOut': 'Zoom out',\n 'ScaleControl.Feet': 'ft',\n 'ScaleControl.Meters': 'm',\n 'ScaleControl.Kilometers': 'km',\n 'ScaleControl.Miles': 'mi',\n 'ScaleControl.NauticalMiles': 'nm',\n 'TerrainControl.enableTerrain': 'Enable terrain',\n 'TerrainControl.disableTerrain': 'Disable terrain'\n};\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos3d', type: 'Int16', components: 3}\n]);\n","import {OverscaledTileID} from './tile_id';\nimport {Tile} from './tile';\nimport {EXTENT} from '../data/extent';\nimport {mat4} from 'gl-matrix';\nimport {Evented} from '../util/evented';\nimport type {Transform} from '../geo/transform';\nimport type {SourceCache} from '../source/source_cache';\nimport {Terrain} from '../render/terrain';\n\n/**\n * @internal\n * This class is a helper for the Terrain-class, it:\n * - loads raster-dem tiles\n * - manages all renderToTexture tiles.\n * - caches previous rendered tiles.\n * - finds all necessary renderToTexture tiles for a OverscaledTileID area\n * - finds the corresponding raster-dem tile for OverscaledTileID\n */\nexport class TerrainSourceCache extends Evented {\n /**\n * source-cache for the raster-dem source.\n */\n sourceCache: SourceCache;\n /**\n * stores all render-to-texture tiles.\n */\n _tiles: {[_: string]: Tile};\n /**\n * contains a list of tileID-keys for the current scene. (only for performance)\n */\n _renderableTilesKeys: Array;\n /**\n * raster-dem-tile for a TileID cache.\n */\n _sourceTileCache: {[_: string]: string};\n /**\n * minimum zoomlevel to render the terrain.\n */\n minzoom: number;\n /**\n * maximum zoomlevel to render the terrain.\n */\n maxzoom: number;\n /**\n * render-to-texture tileSize in scene.\n */\n tileSize: number;\n /**\n * raster-dem tiles will load for performance the actualZoom - deltaZoom zoom-level.\n */\n deltaZoom: number;\n\n constructor(sourceCache: SourceCache) {\n super();\n this.sourceCache = sourceCache;\n this._tiles = {};\n this._renderableTilesKeys = [];\n this._sourceTileCache = {};\n this.minzoom = 0;\n this.maxzoom = 22;\n this.tileSize = 512;\n this.deltaZoom = 1;\n sourceCache.usedForTerrain = true;\n sourceCache.tileSize = this.tileSize * 2 ** this.deltaZoom;\n }\n\n destruct() {\n this.sourceCache.usedForTerrain = false;\n this.sourceCache.tileSize = null;\n }\n\n /**\n * Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory.\n * @param transform - the operation to do\n * @param terrain - the terrain\n */\n update(transform: Transform, terrain: Terrain): void {\n // load raster-dem tiles for the current scene.\n this.sourceCache.update(transform, terrain);\n // create internal render-to-texture tiles for the current scene.\n this._renderableTilesKeys = [];\n const keys = {};\n for (const tileID of transform.coveringTiles({\n tileSize: this.tileSize,\n minzoom: this.minzoom,\n maxzoom: this.maxzoom,\n reparseOverscaled: false,\n terrain\n })) {\n keys[tileID.key] = true;\n this._renderableTilesKeys.push(tileID.key);\n if (!this._tiles[tileID.key]) {\n tileID.posMatrix = new Float64Array(16) as any;\n mat4.ortho(tileID.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n this._tiles[tileID.key] = new Tile(tileID, this.tileSize);\n }\n }\n // free unused tiles\n for (const key in this._tiles) {\n if (!keys[key]) delete this._tiles[key];\n }\n }\n\n /**\n * Free render to texture cache\n * @param tileID - optional, free only corresponding to tileID.\n */\n freeRtt(tileID?: OverscaledTileID) {\n for (const key in this._tiles) {\n const tile = this._tiles[key];\n if (!tileID || tile.tileID.equals(tileID) || tile.tileID.isChildOf(tileID) || tileID.isChildOf(tile.tileID))\n tile.rtt = [];\n }\n }\n\n /**\n * get a list of tiles, which are loaded and should be rendered in the current scene\n * @returns the renderable tiles\n */\n getRenderableTiles(): Array {\n return this._renderableTilesKeys.map(key => this.getTileByID(key));\n }\n\n /**\n * get terrain tile by the TileID key\n * @param id - the tile id\n * @returns the tile\n */\n getTileByID(id: string): Tile {\n return this._tiles[id];\n }\n\n /**\n * Searches for the corresponding current renderable terrain-tiles\n * @param tileID - the tile to look for\n * @returns the tiles that were found\n */\n getTerrainCoords(tileID: OverscaledTileID): Record {\n const coords = {};\n for (const key of this._renderableTilesKeys) {\n const _tileID = this._tiles[key].tileID;\n if (_tileID.canonical.equals(tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n coords[key] = coord;\n } else if (_tileID.canonical.isChildOf(tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n const dz = _tileID.canonical.z - tileID.canonical.z;\n const dx = _tileID.canonical.x - (_tileID.canonical.x >> dz << dz);\n const dy = _tileID.canonical.y - (_tileID.canonical.y >> dz << dz);\n const size = EXTENT >> dz;\n mat4.ortho(coord.posMatrix, 0, size, 0, size, 0, 1);\n mat4.translate(coord.posMatrix, coord.posMatrix, [-dx * size, -dy * size, 0]);\n coords[key] = coord;\n } else if (tileID.canonical.isChildOf(_tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n const dz = tileID.canonical.z - _tileID.canonical.z;\n const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);\n const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);\n const size = EXTENT >> dz;\n mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n mat4.translate(coord.posMatrix, coord.posMatrix, [dx * size, dy * size, 0]);\n mat4.scale(coord.posMatrix, coord.posMatrix, [1 / (2 ** dz), 1 / (2 ** dz), 0]);\n coords[key] = coord;\n }\n }\n return coords;\n }\n\n /**\n * find the covering raster-dem tile\n * @param tileID - the tile to look for\n * @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem.\n * @returns the tile\n */\n getSourceTile(tileID: OverscaledTileID, searchForDEM?: boolean): Tile {\n const source = this.sourceCache._source;\n let z = tileID.overscaledZ - this.deltaZoom;\n if (z > source.maxzoom) z = source.maxzoom;\n if (z < source.minzoom) return null;\n // cache for tileID to terrain-tileID\n if (!this._sourceTileCache[tileID.key])\n this._sourceTileCache[tileID.key] = tileID.scaledTo(z).key;\n let tile = this.sourceCache.getTileByID(this._sourceTileCache[tileID.key]);\n // during tile-loading phase look if parent tiles (with loaded dem) are available.\n if (!(tile && tile.dem) && searchForDEM)\n while (z >= source.minzoom && !(tile && tile.dem))\n tile = this.sourceCache.getTileByID(tileID.scaledTo(z--).key);\n return tile;\n }\n\n /**\n * get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers.\n * @param time - the time\n * @returns the relevant tiles\n */\n tilesAfterTime(time = Date.now()): Array {\n return Object.values(this._tiles).filter(t => t.timeAdded >= time);\n }\n}\n","\nimport {Tile} from '../source/tile';\nimport {mat4, vec2} from 'gl-matrix';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {RGBAImage} from '../util/image';\nimport {warnOnce} from '../util/util';\nimport {Pos3dArray, TriangleIndexArray} from '../data/array_types.g';\nimport pos3dAttributes from '../data/pos3d_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {VertexBuffer} from '../gl/vertex_buffer';\nimport {IndexBuffer} from '../gl/index_buffer';\nimport {Painter} from './painter';\nimport {Texture} from '../render/texture';\nimport type {Framebuffer} from '../gl/framebuffer';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate, lngFromMercatorX, mercatorXfromLng} from '../geo/mercator_coordinate';\nimport {TerrainSourceCache} from '../source/terrain_source_cache';\nimport {SourceCache} from '../source/source_cache';\nimport {EXTENT} from '../data/extent';\nimport type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {LngLat, earthRadius} from '../geo/lng_lat';\n\n/**\n * @internal\n * A terrain GPU related object\n */\nexport type TerrainData = {\n 'u_depth': number;\n 'u_terrain': number;\n 'u_terrain_dim': number;\n 'u_terrain_matrix': mat4;\n 'u_terrain_unpack': number[];\n 'u_terrain_exaggeration': number;\n texture: WebGLTexture;\n depthTexture: WebGLTexture;\n tile: Tile;\n}\n\n/**\n * @internal\n * A terrain mesh object\n */\nexport type TerrainMesh = {\n indexBuffer: IndexBuffer;\n vertexBuffer: VertexBuffer;\n segments: SegmentVector;\n}\n\n/**\n * @internal\n * This is the main class which handles most of the 3D Terrain logic. It has the following topics:\n * 1) loads raster-dem tiles via the internal sourceCache this.sourceCache\n * 2) creates a depth-framebuffer, which is used to calculate the visibility of coordinates\n * 3) creates a coords-framebuffer, which is used the get to tile-coordinate for a screen-pixel\n * 4) stores all render-to-texture tiles in the this.sourceCache._tiles\n * 5) calculates the elevation for a specific tile-coordinate\n * 6) creates a terrain-mesh\n *\n * A note about the GPU resource-usage:\n * Framebuffers:\n * - one for the depth & coords framebuffer with the size of the map-div.\n * - one for rendering a tile to texture with the size of tileSize (= 512x512).\n * Textures:\n * - one texture for an empty raster-dem tile with size 1x1\n * - one texture for an empty depth-buffer, when terrain is disabled with size 1x1\n * - one texture for an each loaded raster-dem with size of the source.tileSize\n * - one texture for the coords-framebuffer with the size of the map-div.\n * - one texture for the depth-framebuffer with the size of the map-div.\n * - one texture for the encoded tile-coords with the size 2*tileSize (=1024x1024)\n * - finally for each render-to-texture tile (= this._tiles) a set of textures\n * for each render stack (The stack-concept is documented in painter.ts).\n * Normally there exists 1-3 Textures per tile, depending on the stylesheet.\n * Each Textures has the size 2*tileSize (= 1024x1024). Also there exists a\n * cache of the last 150 newest rendered tiles.\n *\n */\nexport class Terrain {\n /**\n * The style this terrain crresponds to\n */\n painter: Painter;\n /**\n * the sourcecache this terrain is based on\n */\n sourceCache: TerrainSourceCache;\n /**\n * the TerrainSpecification object passed to this instance\n */\n options: TerrainSpecification;\n /**\n * define the meshSize per tile.\n */\n meshSize: number;\n /**\n * multiplicator for the elevation. Used to make terrain more \"extreme\".\n */\n exaggeration: number;\n /**\n * to not see pixels in the render-to-texture tiles it is good to render them bigger\n * this number is the multiplicator (must be a power of 2) for the current tileSize.\n * So to get good results with not too much memory footprint a value of 2 should be fine.\n */\n qualityFactor: number;\n /**\n * holds the framebuffer object in size of the screen to render the coords & depth into a texture.\n */\n _fbo: Framebuffer;\n _fboCoordsTexture: Texture;\n _fboDepthTexture: Texture;\n _emptyDepthTexture: Texture;\n /**\n * GL Objects for the terrain-mesh\n * The mesh is a regular mesh, which has the advantage that it can be reused for all tiles.\n */\n _mesh: TerrainMesh;\n /**\n * coords index contains a list of tileID.keys. This index is used to identify\n * the tile via the alpha-cannel in the coords-texture.\n * As the alpha-channel has 1 Byte a max of 255 tiles can rendered without an error.\n */\n coordsIndex: Array;\n /**\n * tile-coords encoded in the rgb channel, _coordsIndex is in the alpha-channel.\n */\n _coordsTexture: Texture;\n /**\n * accuracy of the coords. 2 * tileSize should be enoughth.\n */\n _coordsTextureSize: number;\n /**\n * variables for an empty dem texture, which is used while the raster-dem tile is loading.\n */\n _emptyDemUnpack: number[];\n _emptyDemTexture: Texture;\n _emptyDemMatrix: mat4;\n /**\n * as of overzooming of raster-dem tiles in high zoomlevels, this cache contains\n * matrices to transform from vector-tile coords to raster-dem-tile coords.\n */\n _demMatrixCache: {[_: string]: { matrix: mat4; coord: OverscaledTileID }};\n\n constructor(painter: Painter, sourceCache: SourceCache, options: TerrainSpecification) {\n this.painter = painter;\n this.sourceCache = new TerrainSourceCache(sourceCache);\n this.options = options;\n this.exaggeration = typeof options.exaggeration === 'number' ? options.exaggeration : 1.0;\n this.qualityFactor = 2;\n this.meshSize = 128;\n this._demMatrixCache = {};\n this.coordsIndex = [];\n this._coordsTextureSize = 1024;\n }\n\n /**\n * get the elevation-value from original dem-data for a given tile-coordinate\n * @param tileID - the tile to get elevation for\n * @param x - between 0 .. EXTENT\n * @param y - between 0 .. EXTENT\n * @param extent - optional, default 8192\n * @returns the elevation\n */\n getDEMElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {\n if (!(x >= 0 && x < extent && y >= 0 && y < extent)) return 0;\n const terrain = this.getTerrainData(tileID);\n const dem = terrain.tile?.dem;\n if (!dem)\n return 0;\n\n const pos = vec2.transformMat4([] as any, [x / extent * EXTENT, y / extent * EXTENT], terrain.u_terrain_matrix);\n const coord = [pos[0] * dem.dim, pos[1] * dem.dim];\n\n // bilinear interpolation\n const cx = Math.floor(coord[0]),\n cy = Math.floor(coord[1]),\n tx = coord[0] - cx,\n ty = coord[1] - cy;\n return (\n dem.get(cx, cy) * (1 - tx) * (1 - ty) +\n dem.get(cx + 1, cy) * (tx) * (1 - ty) +\n dem.get(cx, cy + 1) * (1 - tx) * (ty) +\n dem.get(cx + 1, cy + 1) * (tx) * (ty)\n );\n }\n\n /**\n * Get the elevation for given {@link LngLat} in respect of exaggeration.\n * @param lnglat - the location\n * @param zoom - the zoom\n * @returns the elevation\n */\n getElevationForLngLatZoom(lnglat: LngLat, zoom: number) {\n const {tileID, mercatorX, mercatorY} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);\n return this.getElevation(tileID, mercatorX % EXTENT, mercatorY % EXTENT, EXTENT);\n }\n\n /**\n * Get the elevation for given coordinate in respect of exaggeration.\n * @param tileID - the tile id\n * @param x - between 0 .. EXTENT\n * @param y - between 0 .. EXTENT\n * @param extent - optional, default 8192\n * @returns the elevation\n */\n getElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {\n return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration;\n }\n\n /**\n * returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object\n * @param tileID - the tile to get the terrain for\n * @returns the terrain data to use in the program\n */\n getTerrainData(tileID: OverscaledTileID): TerrainData {\n // create empty DEM Objects, which will used while raster-dem tiles are loading.\n // creates an empty depth-buffer texture which is needed, during the initialization process of the 3d mesh..\n if (!this._emptyDemTexture) {\n const context = this.painter.context;\n const image = new RGBAImage({width: 1, height: 1}, new Uint8Array(1 * 4));\n this._emptyDepthTexture = new Texture(context, image, context.gl.RGBA, {premultiply: false});\n this._emptyDemUnpack = [0, 0, 0, 0];\n this._emptyDemTexture = new Texture(context, new RGBAImage({width: 1, height: 1}), context.gl.RGBA, {premultiply: false});\n this._emptyDemTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n this._emptyDemMatrix = mat4.identity([] as any);\n }\n // find covering dem tile and prepare demTexture\n const sourceTile = this.sourceCache.getSourceTile(tileID, true);\n if (sourceTile && sourceTile.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) {\n const context = this.painter.context;\n sourceTile.demTexture = this.painter.getTileTexture(sourceTile.dem.stride);\n if (sourceTile.demTexture) sourceTile.demTexture.update(sourceTile.dem.getPixels(), {premultiply: false});\n else sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, {premultiply: false});\n sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n sourceTile.needsTerrainPrepare = false;\n }\n // create matrix for lookup in dem data\n const matrixKey = sourceTile && (sourceTile + sourceTile.tileID.key) + tileID.key;\n if (matrixKey && !this._demMatrixCache[matrixKey]) {\n const maxzoom = this.sourceCache.sourceCache._source.maxzoom;\n let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;\n if (tileID.overscaledZ > tileID.canonical.z) {\n if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;\n else warnOnce('cannot calculate elevation if elevation maxzoom > source.maxzoom');\n }\n const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);\n const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);\n const demMatrix = mat4.fromScaling(new Float64Array(16) as any, [1 / (EXTENT << dz), 1 / (EXTENT << dz), 0]);\n mat4.translate(demMatrix, demMatrix, [dx * EXTENT, dy * EXTENT, 0]);\n this._demMatrixCache[tileID.key] = {matrix: demMatrix, coord: tileID};\n }\n // return uniform values & textures\n return {\n 'u_depth': 2,\n 'u_terrain': 3,\n 'u_terrain_dim': sourceTile && sourceTile.dem && sourceTile.dem.dim || 1,\n 'u_terrain_matrix': matrixKey ? this._demMatrixCache[tileID.key].matrix : this._emptyDemMatrix,\n 'u_terrain_unpack': sourceTile && sourceTile.dem && sourceTile.dem.getUnpackVector() || this._emptyDemUnpack,\n 'u_terrain_exaggeration': this.exaggeration,\n texture: (sourceTile && sourceTile.demTexture || this._emptyDemTexture).texture,\n depthTexture: (this._fboDepthTexture || this._emptyDepthTexture).texture,\n tile: sourceTile\n };\n }\n\n /**\n * get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture\n * @param texture - the texture\n * @returns the frame buffer\n */\n getFramebuffer(texture: string): Framebuffer {\n const painter = this.painter;\n const width = painter.width / devicePixelRatio;\n const height = painter.height / devicePixelRatio;\n if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) {\n this._fbo.destroy();\n this._fboCoordsTexture.destroy();\n this._fboDepthTexture.destroy();\n delete this._fbo;\n delete this._fboDepthTexture;\n delete this._fboCoordsTexture;\n }\n if (!this._fboCoordsTexture) {\n this._fboCoordsTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});\n this._fboCoordsTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);\n }\n if (!this._fboDepthTexture) {\n this._fboDepthTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});\n this._fboDepthTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);\n }\n if (!this._fbo) {\n this._fbo = painter.context.createFramebuffer(width, height, true, false);\n this._fbo.depthAttachment.set(painter.context.createRenderbuffer(painter.context.gl.DEPTH_COMPONENT16, width, height));\n }\n this._fbo.colorAttachment.set(texture === 'coords' ? this._fboCoordsTexture.texture : this._fboDepthTexture.texture);\n return this._fbo;\n }\n\n /**\n * create coords texture, needed to grab coordinates from canvas\n * encode coords coordinate into 4 bytes:\n * - 8 lower bits for x\n * - 8 lower bits for y\n * - 4 higher bits for x\n * - 4 higher bits for y\n * - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value\n * @returns the texture\n */\n getCoordsTexture(): Texture {\n const context = this.painter.context;\n if (this._coordsTexture) return this._coordsTexture;\n const data = new Uint8Array(this._coordsTextureSize * this._coordsTextureSize * 4);\n for (let y = 0, i = 0; y < this._coordsTextureSize; y++) for (let x = 0; x < this._coordsTextureSize; x++, i += 4) {\n data[i + 0] = x & 255;\n data[i + 1] = y & 255;\n data[i + 2] = ((x >> 8) << 4) | (y >> 8);\n data[i + 3] = 0;\n }\n const image = new RGBAImage({width: this._coordsTextureSize, height: this._coordsTextureSize}, new Uint8Array(data.buffer));\n const texture = new Texture(context, image, context.gl.RGBA, {premultiply: false});\n texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n this._coordsTexture = texture;\n return texture;\n }\n\n /**\n * Reads a pixel from the coords-framebuffer and translate this to mercator.\n * @param p - Screen-Coordinate\n * @returns mercator coordinate for a screen pixel\n */\n pointCoordinate(p: Point): MercatorCoordinate {\n const rgba = new Uint8Array(4);\n const context = this.painter.context, gl = context.gl;\n // grab coordinate pixel from coordinates framebuffer\n context.bindFramebuffer.set(this.getFramebuffer('coords').framebuffer);\n gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);\n context.bindFramebuffer.set(null);\n // decode coordinates (encoding see getCoordsTexture)\n const x = rgba[0] + ((rgba[2] >> 4) << 8);\n const y = rgba[1] + ((rgba[2] & 15) << 8);\n const tileID = this.coordsIndex[255 - rgba[3]];\n const tile = tileID && this.sourceCache.getTileByID(tileID);\n if (!tile) return null;\n const coordsSize = this._coordsTextureSize;\n const worldSize = (1 << tile.tileID.canonical.z) * coordsSize;\n const mercatorX = (tile.tileID.canonical.x * coordsSize + x) / worldSize;\n return new MercatorCoordinate(\n this._allowMercatorOverflow(p, mercatorX),\n (tile.tileID.canonical.y * coordsSize + y) / worldSize,\n this.getElevation(tile.tileID, x, y, coordsSize)\n );\n }\n\n /**\n * create a regular mesh which will be used by all terrain-tiles\n * @returns the created regular mesh\n */\n getTerrainMesh(): TerrainMesh {\n if (this._mesh) return this._mesh;\n const context = this.painter.context;\n const vertexArray = new Pos3dArray();\n const indexArray = new TriangleIndexArray();\n const meshSize = this.meshSize;\n const delta = EXTENT / meshSize;\n const meshSize2 = meshSize * meshSize;\n for (let y = 0; y <= meshSize; y++) for (let x = 0; x <= meshSize; x++)\n vertexArray.emplaceBack(x * delta, y * delta, 0);\n for (let y = 0; y < meshSize2; y += meshSize + 1) for (let x = 0; x < meshSize; x++) {\n indexArray.emplaceBack(x + y, meshSize + x + y + 1, meshSize + x + y + 2);\n indexArray.emplaceBack(x + y, meshSize + x + y + 2, x + y + 1);\n }\n // add an extra frame around the mesh to avoid stiching on tile boundaries with different zoomlevels\n // first code-block is for top-bottom frame and second for left-right frame\n const offsetTop = vertexArray.length, offsetBottom = offsetTop + (meshSize + 1) * 2;\n for (const y of [0, 1]) for (let x = 0; x <= meshSize; x++) for (const z of [0, 1])\n vertexArray.emplaceBack(x * delta, y * EXTENT, z);\n for (let x = 0; x < meshSize * 2; x += 2) {\n indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 1, offsetBottom + x + 3);\n indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 3, offsetBottom + x + 2);\n indexArray.emplaceBack(offsetTop + x, offsetTop + x + 3, offsetTop + x + 1);\n indexArray.emplaceBack(offsetTop + x, offsetTop + x + 2, offsetTop + x + 3);\n }\n const offsetLeft = vertexArray.length, offsetRight = offsetLeft + (meshSize + 1) * 2;\n for (const x of [0, 1]) for (let y = 0; y <= meshSize; y++) for (const z of [0, 1])\n vertexArray.emplaceBack(x * EXTENT, y * delta, z);\n for (let y = 0; y < meshSize * 2; y += 2) {\n indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 1, offsetLeft + y + 3);\n indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 3, offsetLeft + y + 2);\n indexArray.emplaceBack(offsetRight + y, offsetRight + y + 3, offsetRight + y + 1);\n indexArray.emplaceBack(offsetRight + y, offsetRight + y + 2, offsetRight + y + 3);\n }\n this._mesh = {\n indexBuffer: context.createIndexBuffer(indexArray),\n vertexBuffer: context.createVertexBuffer(vertexArray, pos3dAttributes.members),\n segments: SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length)\n };\n return this._mesh;\n }\n\n /**\n * Calculates a height of the frame around the terrain-mesh to avoid stiching between\n * tile boundaries in different zoomlevels.\n * @param zoom - current zoomlevel\n * @returns the elevation delta in meters\n */\n getMeshFrameDelta(zoom: number): number {\n // divide by 5 is evaluated by trial & error to get a frame in the right height\n return 2 * Math.PI * earthRadius / Math.pow(2, zoom) / 5;\n }\n\n getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number) {\n const {tileID} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);\n return this.getMinMaxElevation(tileID).minElevation ?? 0;\n }\n\n /**\n * Get the minimum and maximum elevation contained in a tile. This includes any\n * exaggeration included in the terrain.\n *\n * @param tileID - ID of the tile to be used as a source for the min/max elevation\n * @returns the minimum and maximum elevation found in the tile, including the terrain's\n * exaggeration\n */\n getMinMaxElevation(tileID: OverscaledTileID): {minElevation: number | null; maxElevation: number | null} {\n const tile = this.getTerrainData(tileID).tile;\n const minMax = {minElevation: null, maxElevation: null};\n if (tile && tile.dem) {\n minMax.minElevation = tile.dem.min * this.exaggeration;\n minMax.maxElevation = tile.dem.max * this.exaggeration;\n }\n return minMax;\n }\n\n _getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { tileID: OverscaledTileID; mercatorX: number; mercatorY: number} {\n const mercatorCoordinate = MercatorCoordinate.fromLngLat(lnglat.wrap());\n const worldSize = (1 << zoom) * EXTENT;\n const mercatorX = mercatorCoordinate.x * worldSize;\n const mercatorY = mercatorCoordinate.y * worldSize;\n const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);\n const tileID = new OverscaledTileID(zoom, 0, zoom, tileX, tileY);\n return {\n tileID,\n mercatorX,\n mercatorY\n };\n }\n\n _allowMercatorOverflow(p: Point, mercatorX: number): number {\n const inLeftHalf = p.x < (this.painter.width / 2);\n let lng = lngFromMercatorX(mercatorX);\n const centerLng = this.painter.transform.center.lng;\n if (\n (inLeftHalf && Math.sign(lng) > 0 && Math.sign(centerLng) < 0) ||\n (!inLeftHalf && Math.sign(lng) < 0 && Math.sign(centerLng) > 0)\n ) {\n lng = 360 * Math.sign(centerLng) + lng;\n return mercatorXfromLng(lng);\n }\n return mercatorX;\n }\n}\n","import {Texture} from '../render/texture';\nimport {Context} from './context';\nimport {Framebuffer} from './framebuffer';\n\nexport type PoolObject = {\n id: number;\n fbo: Framebuffer;\n texture: Texture;\n stamp: number;\n inUse: boolean;\n};\n/**\n * @internal\n * `RenderPool` is a resource pool for textures and framebuffers\n */\nexport class RenderPool {\n private _objects: Array;\n /**\n * An index array of recently used pool objects.\n * Items that are used recently are last in the array\n */\n private _recentlyUsed: Array;\n private _stamp: number;\n\n constructor(\n private readonly _context: Context,\n private readonly _size: number,\n private readonly _tileSize: number) {\n this._objects = [];\n this._recentlyUsed = [];\n this._stamp = 0;\n }\n\n public destruct() {\n for (const obj of this._objects) {\n obj.texture.destroy();\n obj.fbo.destroy();\n }\n }\n\n private _createObject(id: number): PoolObject {\n const fbo = this._context.createFramebuffer(this._tileSize, this._tileSize, true, true);\n const texture = new Texture(this._context, {width: this._tileSize, height: this._tileSize, data: null}, this._context.gl.RGBA);\n texture.bind(this._context.gl.LINEAR, this._context.gl.CLAMP_TO_EDGE);\n fbo.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL, this._tileSize, this._tileSize));\n fbo.colorAttachment.set(texture.texture);\n return {id, fbo, texture, stamp: -1, inUse: false};\n }\n\n public getObjectForId(id: number): PoolObject {\n return this._objects[id];\n }\n\n public useObject(obj: PoolObject) {\n obj.inUse = true;\n this._recentlyUsed = this._recentlyUsed.filter(id => obj.id !== id);\n this._recentlyUsed.push(obj.id);\n }\n\n public stampObject(obj: PoolObject) {\n obj.stamp = ++this._stamp;\n }\n\n public getOrCreateFreeObject(): PoolObject {\n // check for free existing object\n for (const id of this._recentlyUsed) {\n if (!this._objects[id].inUse)\n return this._objects[id];\n }\n if (this._objects.length >= this._size)\n throw new Error('No free RenderPool available, call freeAllObjects() required!');\n // create new object\n const obj = this._createObject(this._objects.length);\n this._objects.push(obj);\n return obj;\n }\n\n public freeObject(obj: PoolObject) {\n obj.inUse = false;\n }\n\n public freeAllObjects() {\n for (const obj of this._objects)\n this.freeObject(obj);\n }\n\n public isFull(): boolean {\n if (this._objects.length < this._size) {\n return false;\n }\n return this._objects.some(o => !o.inUse) === false;\n }\n}\n","import {Painter} from './painter';\nimport {Tile} from '../source/tile';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {drawTerrain} from './draw_terrain';\nimport {Style} from '../style/style';\nimport {Terrain} from './terrain';\nimport {RenderPool} from '../gl/render_pool';\nimport {Texture} from './texture';\nimport type {StyleLayer} from '../style/style_layer';\n\n/**\n * lookup table which layers should rendered to texture\n */\nconst LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {\n background: true,\n fill: true,\n line: true,\n raster: true,\n hillshade: true\n};\n\n/**\n * @internal\n * A helper class to help define what should be rendered to texture and how\n */\nexport class RenderToTexture {\n painter: Painter;\n terrain: Terrain;\n pool: RenderPool;\n /**\n * coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile\n * e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile\n */\n _coordsDescendingInv: {[_: string]: {[_:string]: Array}};\n /**\n * create a string representation of all to tiles rendered to render-to-texture tiles\n * this string representation is used to check if tile should be re-rendered.\n */\n _coordsDescendingInvStr: {[_: string]: {[_:string]: string}};\n /**\n * store for render-stacks\n * a render stack is a set of layers which should be rendered into one texture\n * every stylesheet can have multiple stacks. A new stack is created if layers which should\n * not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols\n */\n _stacks: Array>;\n /**\n * remember the previous processed layer to check if a new stack is needed\n */\n _prevType: string;\n /**\n * a list of tiles that can potentially rendered\n */\n _renderableTiles: Array;\n /**\n * a list of tiles that should be rendered to screen in the next render-call\n */\n _rttTiles: Array;\n /**\n * a list of all layer-ids which should be rendered\n */\n _renderableLayerIds: Array;\n\n constructor(painter: Painter, terrain: Terrain) {\n this.painter = painter;\n this.terrain = terrain;\n this.pool = new RenderPool(painter.context, 30, terrain.sourceCache.tileSize * terrain.qualityFactor);\n }\n\n destruct() {\n this.pool.destruct();\n }\n\n getTexture(tile: Tile): Texture {\n return this.pool.getObjectForId(tile.rtt[this._stacks.length - 1].id).texture;\n }\n\n prepareForRender(style: Style, zoom: number) {\n this._stacks = [];\n this._prevType = null;\n this._rttTiles = [];\n this._renderableTiles = this.terrain.sourceCache.getRenderableTiles();\n this._renderableLayerIds = style._order.filter(id => !style._layers[id].isHidden(zoom));\n\n this._coordsDescendingInv = {};\n for (const id in style.sourceCaches) {\n this._coordsDescendingInv[id] = {};\n const tileIDs = style.sourceCaches[id].getVisibleCoordinates();\n for (const tileID of tileIDs) {\n const keys = this.terrain.sourceCache.getTerrainCoords(tileID);\n for (const key in keys) {\n if (!this._coordsDescendingInv[id][key]) this._coordsDescendingInv[id][key] = [];\n this._coordsDescendingInv[id][key].push(keys[key]);\n }\n }\n }\n\n this._coordsDescendingInvStr = {};\n for (const id of style._order) {\n const layer = style._layers[id], source = layer.source;\n if (LAYERS[layer.type]) {\n if (!this._coordsDescendingInvStr[source]) {\n this._coordsDescendingInvStr[source] = {};\n for (const key in this._coordsDescendingInv[source])\n this._coordsDescendingInvStr[source][key] = this._coordsDescendingInv[source][key].map(c => c.key).sort().join();\n }\n }\n }\n\n // check tiles to render\n for (const tile of this._renderableTiles) {\n for (const source in this._coordsDescendingInvStr) {\n // rerender if there are more coords to render than in the last rendering\n const coords = this._coordsDescendingInvStr[source][tile.tileID.key];\n if (coords && coords !== tile.rttCoords[source]) tile.rtt = [];\n }\n }\n }\n\n /**\n * due that switching textures is relatively slow, the render\n * layer-by-layer context is not practicable. To bypass this problem\n * this lines of code stack all layers and later render all at once.\n * Because of the stylesheet possibility to mixing render-to-texture layers\n * and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example\n * a symbol-layer is in between of fill-layers.\n * @param layer - the layer to render\n * @returns if true layer is rendered to texture, otherwise false\n */\n renderLayer(layer: StyleLayer): boolean {\n if (layer.isHidden(this.painter.transform.zoom)) return false;\n\n const type = layer.type;\n const painter = this.painter;\n const isLastLayer = this._renderableLayerIds[this._renderableLayerIds.length - 1] === layer.id;\n\n // remember background, fill, line & raster layer to render into a stack\n if (LAYERS[type]) {\n // create a new stack if previous layer was not rendered to texture (f.e. symbols)\n if (!this._prevType || !LAYERS[this._prevType]) this._stacks.push([]);\n // push current render-to-texture layer to render-stack\n this._prevType = type;\n this._stacks[this._stacks.length - 1].push(layer.id);\n // rendering is done later, all in once\n if (!isLastLayer) return true;\n }\n\n // in case a stack is finished render all collected stack-layers into a texture\n if (LAYERS[this._prevType] || (LAYERS[type] && isLastLayer)) {\n this._prevType = type;\n const stack = this._stacks.length - 1, layers = this._stacks[stack] || [];\n for (const tile of this._renderableTiles) {\n // if render pool is full draw current tiles to screen and free pool\n if (this.pool.isFull()) {\n drawTerrain(this.painter, this.terrain, this._rttTiles);\n this._rttTiles = [];\n this.pool.freeAllObjects();\n }\n this._rttTiles.push(tile);\n // check for cached PoolObject\n if (tile.rtt[stack]) {\n const obj = this.pool.getObjectForId(tile.rtt[stack].id);\n if (obj.stamp === tile.rtt[stack].stamp) {\n this.pool.useObject(obj);\n continue;\n }\n }\n // get free PoolObject\n const obj = this.pool.getOrCreateFreeObject();\n this.pool.useObject(obj);\n this.pool.stampObject(obj);\n tile.rtt[stack] = {id: obj.id, stamp: obj.stamp};\n // prepare PoolObject for rendering\n painter.context.bindFramebuffer.set(obj.fbo.framebuffer);\n painter.context.clear({color: Color.transparent, stencil: 0});\n painter.currentStencilSource = undefined;\n for (let l = 0; l < layers.length; l++) {\n const layer = painter.style._layers[layers[l]];\n const coords = layer.source ? this._coordsDescendingInv[layer.source][tile.tileID.key] : [tile.tileID];\n painter.context.viewport.set([0, 0, obj.fbo.width, obj.fbo.height]);\n painter._renderTileClippingMasks(layer, coords);\n painter.renderLayer(painter, painter.style.sourceCaches[layer.source], layer, coords);\n if (layer.source) tile.rttCoords[layer.source] = this._coordsDescendingInvStr[layer.source][tile.tileID.key];\n }\n }\n drawTerrain(this.painter, this.terrain, this._rttTiles);\n this._rttTiles = [];\n this.pool.freeAllObjects();\n\n return LAYERS[type];\n }\n\n return false;\n }\n\n}\n","import {extend, warnOnce, uniqueId, isImageBitmap} from '../util/util';\nimport {browser} from '../util/browser';\nimport {DOM} from '../util/dom';\nimport packageJSON from '../../package.json' assert {type: 'json'};\n\nimport {getJSON} from '../util/ajax';\nimport {ImageRequest} from '../util/image_request';\nimport type {GetImageCallback} from '../util/image_request';\n\nimport {RequestManager, ResourceType} from '../util/request_manager';\nimport {Style, StyleSwapOptions} from '../style/style';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {Painter} from '../render/painter';\nimport {Transform} from '../geo/transform';\nimport {Hash} from './hash';\nimport {HandlerManager} from './handler_manager';\nimport {Camera, CameraOptions, CameraUpdateTransformFunction, FitBoundsOptions} from './camera';\nimport {LngLat} from '../geo/lng_lat';\nimport {LngLatBounds} from '../geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {AttributionControl} from './control/attribution_control';\nimport {LogoControl} from './control/logo_control';\n\nimport {RGBAImage} from '../util/image';\nimport {Event, ErrorEvent, Listener} from '../util/evented';\nimport {MapEventType, MapLayerEventType, MapMouseEvent, MapSourceDataEvent, MapStyleDataEvent} from './events';\nimport {TaskQueue} from '../util/task_queue';\nimport {throttle} from '../util/throttle';\nimport {webpSupported} from '../util/webp_supported';\nimport {PerformanceMarkers, PerformanceUtils} from '../util/performance';\nimport {Source, SourceClass} from '../source/source';\nimport {StyleLayer} from '../style/style_layer';\n\nimport type {RequestTransformFunction} from '../util/request_manager';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport type {AddLayerObject, FeatureIdentifier, StyleOptions, StyleSetterOptions} from '../style/style';\nimport type {MapDataEvent} from './events';\nimport type {StyleImage, StyleImageInterface, StyleImageMetadata} from '../style/style_image';\nimport type {PointLike} from './camera';\nimport type {ScrollZoomHandler} from './handler/scroll_zoom';\nimport type {BoxZoomHandler} from './handler/box_zoom';\nimport type {AroundCenterOptions, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';\nimport type {DragRotateHandler} from './handler/shim/drag_rotate';\nimport {DragPanHandler, DragPanOptions} from './handler/shim/drag_pan';\n\nimport type {KeyboardHandler} from './handler/keyboard';\nimport type {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';\nimport type {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';\nimport {defaultLocale} from './default_locale';\nimport type {TaskID} from '../util/task_queue';\nimport type {Cancelable} from '../types/cancelable';\nimport type {\n FilterSpecification,\n StyleSpecification,\n LightSpecification,\n SourceSpecification,\n TerrainSpecification\n} from '@maplibre/maplibre-gl-style-spec';\n\nimport {Callback} from '../types/callback';\nimport type {ControlPosition, IControl} from './control/control';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {Terrain} from '../render/terrain';\nimport {RenderToTexture} from '../render/render_to_texture';\nimport {config} from '../util/config';\nimport type {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions} from '../source/query_features';\n\nconst version = packageJSON.version;\n\n/**\n * The {@link Map} options object.\n */\nexport type MapOptions = {\n /**\n * If `true`, the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL.\n * For example, `http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60`.\n * An additional string may optionally be provided to indicate a parameter-styled hash,\n * e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar, where foo\n * is a custom parameter and bar is an arbitrary hash distinct from the map hash.\n * @defaultValue false\n */\n hash?: boolean | string;\n /**\n * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.\n * @defaultValue true\n */\n interactive?: boolean;\n /**\n * The HTML element in which MapLibre GL JS will render the map, or the element's string `id`. The specified element must have no children.\n */\n container: HTMLElement | string;\n /**\n * The threshold, measured in degrees, that determines when the map's\n * bearing will snap to north. For example, with a `bearingSnap` of 7, if the user rotates\n * the map within 7 degrees of north, the map will automatically snap to exact north.\n * @defaultValue 7\n */\n bearingSnap?: number;\n /**\n * If `true`, an {@link AttributionControl} will be added to the map.\n * @defaultValue true\n */\n attributionControl?: boolean;\n /**\n * Attribution text to show in an {@link AttributionControl}. Only applicable if `options.attributionControl` is `true`.\n */\n customAttribution?: string | Array;\n /**\n * If `true`, the MapLibre logo will be shown.\n * @defaultValue false\n */\n maplibreLogo?: boolean;\n /**\n * A string representing the position of the MapLibre wordmark on the map. Valid options are `top-left`,`top-right`, `bottom-left`, or `bottom-right`.\n * @defaultValue 'bottom-left'\n */\n logoPosition?: ControlPosition;\n /**\n * If `true`, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected\n * (i.e. a software renderer would be used).\n * @defaultValue false\n */\n failIfMajorPerformanceCaveat?: boolean;\n /**\n * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization.\n * @defaultValue false\n */\n preserveDrawingBuffer?: boolean;\n /**\n * If `true`, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. This is `false` by default as a performance optimization.\n */\n antialias?: boolean;\n /**\n * If `false`, the map won't attempt to re-request tiles once they expire per their HTTP `cacheControl`/`expires` headers.\n * @defaultValue true\n */\n refreshExpiredTiles?: boolean;\n /**\n * If set, the map will be constrained to the given bounds.\n */\n maxBounds?: LngLatBoundsLike;\n /**\n * If `true`, the \"scroll to zoom\" interaction is enabled. {@link AroundCenterOptions} are passed as options to {@link ScrollZoomHandler#enable}.\n * @defaultValue true\n */\n scrollZoom?: boolean | AroundCenterOptions;\n /**\n * The minimum zoom level of the map (0-24).\n * @defaultValue 0\n */\n minZoom?: number | null;\n /**\n * The maximum zoom level of the map (0-24).\n * @defaultValue 22\n */\n maxZoom?: number | null;\n /**\n * The minimum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 0\n */\n minPitch?: number | null;\n /**\n * The maximum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 60\n */\n maxPitch?: number | null;\n /**\n * If `true`, the \"box zoom\" interaction is enabled (see {@link BoxZoomHandler}).\n * @defaultValue true\n */\n boxZoom?: boolean;\n /**\n * If `true`, the \"drag to rotate\" interaction is enabled (see {@link DragRotateHandler}).\n * @defaultValue true\n */\n dragRotate?: boolean;\n /**\n * If `true`, the \"drag to pan\" interaction is enabled. An `Object` value is passed as options to {@link DragPanHandler#enable}.\n * @defaultValue true\n */\n dragPan?: boolean | DragPanOptions;\n /**\n * If `true`, keyboard shortcuts are enabled (see {@link KeyboardHandler}).\n * @defaultValue true\n */\n keyboard?: boolean;\n /**\n * If `true`, the \"double click to zoom\" interaction is enabled (see {@link DoubleClickZoomHandler}).\n * @defaultValue true\n */\n doubleClickZoom?: boolean;\n /**\n * If `true`, the \"pinch to rotate and zoom\" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchZoomRotateHandler#enable}.\n * @defaultValue true\n */\n touchZoomRotate?: boolean | AroundCenterOptions;\n /**\n * If `true`, the \"drag to pitch\" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchPitchHandler#enable}.\n * @defaultValue true\n */\n touchPitch?: boolean | AroundCenterOptions;\n /**\n * If `true` or set to an options object, the map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, \"drag to pitch\" requires a three-finger gesture. Cooperative gestures are disabled when a map enters fullscreen using {@link FullscreenControl}.\n * @defaultValue undefined\n */\n cooperativeGestures?: boolean | GestureOptions;\n /**\n * If `true`, the map will automatically resize when the browser window resizes.\n * @defaultValue true\n */\n trackResize?: boolean;\n /**\n * The initial geographical centerpoint of the map. If `center` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.\n * @defaultValue [0, 0]\n */\n center?: LngLatLike;\n /**\n * The initial zoom level of the map. If `zoom` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.\n * @defaultValue 0\n */\n zoom?: number;\n /**\n * The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If `bearing` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.\n * @defaultValue 0\n */\n bearing?: number;\n /**\n * The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If `pitch` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 0\n */\n pitch?: number;\n /**\n * If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n * @defaultValue true\n */\n renderWorldCopies?: boolean;\n /**\n * The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport which can be set using `maxTileCacheZoomLevels` constructor options.\n * @defaultValue null\n */\n maxTileCacheSize?: number;\n /**\n * The maximum number of zoom levels for which to store tiles for a given source. Tile cache dynamic size is calculated by multiplying `maxTileCacheZoomLevels` with the approximate number of tiles in the viewport for a given source.\n * @defaultValue 5\n */\n maxTileCacheZoomLevels?: number;\n /**\n * A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.\n * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties.\n */\n transformRequest?: RequestTransformFunction;\n /**\n * A callback run before the map's camera is moved due to user input or animation. The callback can be used to modify the new center, zoom, pitch and bearing.\n * Expected to return an object containing center, zoom, pitch or bearing values to overwrite.\n */\n transformCameraUpdate?: CameraUpdateTransformFunction;\n /**\n * A patch to apply to the default localization table for UI strings, e.g. control tooltips. The `locale` object maps namespaced UI string IDs to translated strings in the target language; see `src/ui/default_locale.js` for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table).\n * @defaultValue null\n */\n locale?: any;\n /**\n * Controls the duration of the fade-in/fade-out animation for label collisions after initial map load, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading.\n * @defaultValue 300\n */\n fadeDuration?: number;\n /**\n * If `true`, symbols from multiple sources can collide with each other during collision detection. If `false`, collision detection is run separately for the symbols in each source.\n * @defaultValue true\n */\n crossSourceCollisions?: boolean;\n /**\n * If `true`, Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers (this information is normally inaccessible from the main Javascript thread). Information will be returned in a `resourceTiming` property of relevant `data` events.\n * @defaultValue false\n */\n collectResourceTiming?: boolean;\n /**\n * The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag).\n * @defaultValue true\n */\n clickTolerance?: number;\n /**\n * The initial bounds of the map. If `bounds` is specified, it overrides `center` and `zoom` constructor options.\n */\n bounds?: LngLatBoundsLike;\n /**\n * A {@link FitBoundsOptions} options object to use _only_ when fitting the initial `bounds` provided above.\n */\n fitBoundsOptions?: FitBoundsOptions;\n /**\n * Defines a CSS\n * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.\n * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).\n * Set to `false`, to enable font settings from the map's style for these glyph ranges.\n * The purpose of this option is to avoid bandwidth-intensive glyph server requests. (See [Use locally generated ideographs](https://maplibre.org/maplibre-gl-js/docs/examples/local-ideographs).)\n * @defaultValue 'sans-serif'\n */\n localIdeographFontFamily?: string;\n /**\n * The map's MapLibre style. This must be a JSON object conforming to\n * the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/),\n * or a URL to such JSON.\n */\n style: StyleSpecification | string;\n /**\n * If `false`, the map's pitch (tilt) control with \"drag to rotate\" interaction will be disabled.\n * @defaultValue true\n */\n pitchWithRotate?: boolean;\n /**\n * The pixel ratio. The canvas' `width` attribute will be `container.clientWidth * pixelRatio` and its `height` attribute will be `container.clientHeight * pixelRatio`. Defaults to `devicePixelRatio` if not specified.\n */\n pixelRatio?: number;\n /**\n * If false, style validation will be skipped. Useful in production environment.\n * @defaultValue true\n */\n validateStyle?: boolean;\n /**\n * The canvas' `width` and `height` max size. The values are passed as an array where the first element is max width and the second element is max height.\n * You shouldn't set this above WebGl `MAX_TEXTURE_SIZE`. Defaults to [4096, 4096].\n */\n maxCanvasSize?: [number, number];\n};\n\n/**\n * An options object for the gesture settings\n * @example\n * ```ts\n * let options = {\n * windowsHelpText: \"Use Ctrl + scroll to zoom the map\",\n * macHelpText: \"Use ⌘ + scroll to zoom the map\",\n * mobileHelpText: \"Use two fingers to move the map\",\n * }\n * ```\n */\nexport type GestureOptions = {\n windowsHelpText?: string;\n macHelpText?: string;\n mobileHelpText?: string;\n};\n\nexport type AddImageOptions = {\n\n}\n\n// See article here: https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585\ntype Complete = {\n [P in keyof Required]: Pick extends Required> ? T[P] : (T[P] | undefined);\n}\n\n// This type is used inside map since all properties are assigned a default value.\nexport type CompleteMapOptions = Complete;\n\nconst defaultMinZoom = -2;\nconst defaultMaxZoom = 22;\n\n// the default values, but also the valid range\nconst defaultMinPitch = 0;\nconst defaultMaxPitch = 60;\n\n// use this variable to check maxPitch for validity\nconst maxPitchThreshold = 85;\n\nconst defaultOptions = {\n center: [0, 0],\n zoom: 0,\n bearing: 0,\n pitch: 0,\n\n minZoom: defaultMinZoom,\n maxZoom: defaultMaxZoom,\n\n minPitch: defaultMinPitch,\n maxPitch: defaultMaxPitch,\n\n interactive: true,\n scrollZoom: true,\n boxZoom: true,\n dragRotate: true,\n dragPan: true,\n keyboard: true,\n doubleClickZoom: true,\n touchZoomRotate: true,\n touchPitch: true,\n cooperativeGestures: undefined,\n\n bearingSnap: 7,\n clickTolerance: 3,\n pitchWithRotate: true,\n\n hash: false,\n attributionControl: true,\n maplibreLogo: false,\n\n failIfMajorPerformanceCaveat: false,\n preserveDrawingBuffer: false,\n trackResize: true,\n renderWorldCopies: true,\n refreshExpiredTiles: true,\n maxTileCacheSize: null,\n maxTileCacheZoomLevels: config.MAX_TILE_CACHE_ZOOM_LEVELS,\n localIdeographFontFamily: 'sans-serif',\n transformRequest: null,\n transformCameraUpdate: null,\n fadeDuration: 300,\n crossSourceCollisions: true,\n validateStyle: true,\n /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */\n maxCanvasSize: [4096, 4096]\n} as CompleteMapOptions;\n\n/**\n * The `Map` object represents the map on your page. It exposes methods\n * and properties that enable you to programmatically change the map,\n * and fires events as users interact with it.\n *\n * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list.\n * Then MapLibre GL JS initializes the map on the page and returns your `Map` object.\n *\n * @group Main\n *\n * @example\n * ```ts\n * let map = new maplibregl.Map({\n * container: 'map',\n * center: [-122.420679, 37.772537],\n * zoom: 13,\n * style: style_object,\n * hash: true,\n * transformRequest: (url, resourceType)=> {\n * if(resourceType === 'Source' && url.startsWith('http://myHost')) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true},\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * });\n * ```\n * @see [Display a map](https://maplibre.org/maplibre-gl-js/docs/examples/simple-map/)\n */\nexport class Map extends Camera {\n style: Style;\n painter: Painter;\n handlers: HandlerManager;\n\n _container: HTMLElement;\n _canvasContainer: HTMLElement;\n _controlContainer: HTMLElement;\n _controlPositions: {[_: string]: HTMLElement};\n _interactive: boolean;\n _cooperativeGestures: boolean | GestureOptions;\n _cooperativeGesturesScreen: HTMLElement;\n _metaKey: keyof MouseEvent;\n _showTileBoundaries: boolean;\n _showCollisionBoxes: boolean;\n _showPadding: boolean;\n _showOverdrawInspector: boolean;\n _repaint: boolean;\n _vertices: boolean;\n _canvas: HTMLCanvasElement;\n _maxTileCacheSize: number;\n _maxTileCacheZoomLevels: number;\n _frame: Cancelable;\n _styleDirty: boolean;\n _sourcesDirty: boolean;\n _placementDirty: boolean;\n\n _loaded: boolean;\n _idleTriggered: boolean;\n // accounts for placement finishing as well\n _fullyLoaded: boolean;\n _trackResize: boolean;\n _resizeObserver: ResizeObserver;\n _preserveDrawingBuffer: boolean;\n _failIfMajorPerformanceCaveat: boolean;\n _antialias: boolean;\n _refreshExpiredTiles: boolean;\n _hash: Hash;\n _delegatedListeners: any;\n _fadeDuration: number;\n _crossSourceCollisions: boolean;\n _crossFadingFactor: number;\n _collectResourceTiming: boolean;\n _renderTaskQueue: TaskQueue;\n _controls: Array;\n _mapId: number;\n _localIdeographFontFamily: string;\n _validateStyle: boolean;\n _requestManager: RequestManager;\n _locale: any;\n _removed: boolean;\n _clickTolerance: number;\n _overridePixelRatio: number | null;\n _maxCanvasSize: [number, number];\n _terrainDataCallback: (e: MapStyleDataEvent | MapSourceDataEvent) => void;\n\n /**\n * @internal\n * image queue throttling handle. To be used later when clean up\n */\n _imageQueueHandle: number;\n\n /**\n * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.\n * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.\n */\n scrollZoom: ScrollZoomHandler;\n\n /**\n * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed.\n * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section.\n */\n boxZoom: BoxZoomHandler;\n\n /**\n * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right\n * mouse button or with the Control key pressed. Find more details and examples using `dragRotate`\n * in the {@link DragRotateHandler} section.\n */\n dragRotate: DragRotateHandler;\n\n /**\n * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture.\n * Find more details and examples using `dragPan` in the {@link DragPanHandler} section.\n */\n dragPan: DragPanHandler;\n\n /**\n * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard\n * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section.\n */\n keyboard: KeyboardHandler;\n\n /**\n * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking.\n * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section.\n */\n doubleClickZoom: DoubleClickZoomHandler;\n\n /**\n * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures.\n * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section.\n */\n touchZoomRotate: TwoFingersTouchZoomRotateHandler;\n\n /**\n * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures.\n * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section.\n */\n touchPitch: TwoFingersTouchPitchHandler;\n\n constructor(options: MapOptions) {\n PerformanceUtils.mark(PerformanceMarkers.create);\n\n options = extend({}, defaultOptions, options);\n\n if (options.minZoom != null && options.maxZoom != null && options.minZoom > options.maxZoom) {\n throw new Error('maxZoom must be greater than or equal to minZoom');\n }\n\n if (options.minPitch != null && options.maxPitch != null && options.minPitch > options.maxPitch) {\n throw new Error('maxPitch must be greater than or equal to minPitch');\n }\n\n if (options.minPitch != null && options.minPitch < defaultMinPitch) {\n throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);\n }\n\n if (options.maxPitch != null && options.maxPitch > maxPitchThreshold) {\n throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);\n }\n\n const transform = new Transform(options.minZoom, options.maxZoom, options.minPitch, options.maxPitch, options.renderWorldCopies);\n super(transform, {bearingSnap: options.bearingSnap});\n\n this._interactive = options.interactive;\n this._cooperativeGestures = options.cooperativeGestures;\n this._metaKey = navigator.platform.indexOf('Mac') === 0 ? 'metaKey' : 'ctrlKey';\n this._maxTileCacheSize = options.maxTileCacheSize;\n this._maxTileCacheZoomLevels = options.maxTileCacheZoomLevels;\n this._failIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat;\n this._preserveDrawingBuffer = options.preserveDrawingBuffer;\n this._antialias = options.antialias;\n this._trackResize = options.trackResize;\n this._bearingSnap = options.bearingSnap;\n this._refreshExpiredTiles = options.refreshExpiredTiles;\n this._fadeDuration = options.fadeDuration;\n this._crossSourceCollisions = options.crossSourceCollisions;\n this._crossFadingFactor = 1;\n this._collectResourceTiming = options.collectResourceTiming;\n this._renderTaskQueue = new TaskQueue();\n this._controls = [];\n this._mapId = uniqueId();\n this._locale = extend({}, defaultLocale, options.locale);\n this._clickTolerance = options.clickTolerance;\n this._overridePixelRatio = options.pixelRatio;\n this._maxCanvasSize = options.maxCanvasSize;\n this.transformCameraUpdate = options.transformCameraUpdate;\n\n this._imageQueueHandle = ImageRequest.addThrottleControl(() => this.isMoving());\n\n this._requestManager = new RequestManager(options.transformRequest);\n\n if (typeof options.container === 'string') {\n this._container = document.getElementById(options.container);\n if (!this._container) {\n throw new Error(`Container '${options.container}' not found.`);\n }\n } else if (options.container instanceof HTMLElement) {\n this._container = options.container;\n } else {\n throw new Error('Invalid type: \\'container\\' must be a String or HTMLElement.');\n }\n\n if (options.maxBounds) {\n this.setMaxBounds(options.maxBounds);\n }\n\n this._setupContainer();\n this._setupPainter();\n\n this.on('move', () => this._update(false));\n this.on('moveend', () => this._update(false));\n this.on('zoom', () => this._update(true));\n this.on('terrain', () => {\n this.painter.terrainFacilitator.dirty = true;\n this._update(true);\n });\n this.once('idle', () => { this._idleTriggered = true; });\n\n if (typeof window !== 'undefined') {\n addEventListener('online', this._onWindowOnline, false);\n let initialResizeEventCaptured = false;\n const throttledResizeCallback = throttle((entries: ResizeObserverEntry[]) => {\n if (this._trackResize && !this._removed) {\n this.resize(entries)._update();\n }\n }, 50);\n this._resizeObserver = new ResizeObserver((entries) => {\n if (!initialResizeEventCaptured) {\n initialResizeEventCaptured = true;\n return;\n }\n throttledResizeCallback(entries);\n });\n this._resizeObserver.observe(this._container);\n }\n\n this.handlers = new HandlerManager(this, options as CompleteMapOptions);\n\n if (this._cooperativeGestures) {\n this._setupCooperativeGestures();\n }\n\n const hashName = (typeof options.hash === 'string' && options.hash) || undefined;\n this._hash = options.hash && (new Hash(hashName)).addTo(this);\n // don't set position from options if set through hash\n if (!this._hash || !this._hash._onHashChange()) {\n this.jumpTo({\n center: options.center,\n zoom: options.zoom,\n bearing: options.bearing,\n pitch: options.pitch\n });\n\n if (options.bounds) {\n this.resize();\n this.fitBounds(options.bounds, extend({}, options.fitBoundsOptions, {duration: 0}));\n }\n }\n\n this.resize();\n\n this._localIdeographFontFamily = options.localIdeographFontFamily;\n this._validateStyle = options.validateStyle;\n\n if (options.style) this.setStyle(options.style, {localIdeographFontFamily: options.localIdeographFontFamily});\n\n if (options.attributionControl)\n this.addControl(new AttributionControl({customAttribution: options.customAttribution}));\n\n if (options.maplibreLogo)\n this.addControl(new LogoControl(), options.logoPosition);\n\n this.on('style.load', () => {\n if (this.transform.unmodified) {\n this.jumpTo(this.style.stylesheet as any);\n }\n });\n this.on('data', (event: MapDataEvent) => {\n this._update(event.dataType === 'style');\n this.fire(new Event(`${event.dataType}data`, event));\n });\n this.on('dataloading', (event: MapDataEvent) => {\n this.fire(new Event(`${event.dataType}dataloading`, event));\n });\n this.on('dataabort', (event: MapDataEvent) => {\n this.fire(new Event('sourcedataabort', event));\n });\n }\n\n /**\n * @internal\n * Returns a unique number for this map instance which is used for the MapLoadEvent\n * to make sure we only fire one event per instantiated map object.\n * @returns the uniq map ID\n */\n _getMapId() {\n return this._mapId;\n }\n\n /**\n * Adds an {@link IControl} to the map, calling `control.onAdd(this)`.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param control - The {@link IControl} to add.\n * @param position - position on the map to which the control will be added.\n * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`.\n * @returns `this`\n * @example\n * Add zoom and rotation controls to the map.\n * ```ts\n * map.addControl(new maplibregl.NavigationControl());\n * ```\n * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)\n */\n addControl(control: IControl, position?: ControlPosition): Map {\n if (position === undefined) {\n if (control.getDefaultPosition) {\n position = control.getDefaultPosition();\n } else {\n position = 'top-right';\n }\n }\n if (!control || !control.onAdd) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.')));\n }\n const controlElement = control.onAdd(this);\n this._controls.push(control);\n\n const positionContainer = this._controlPositions[position];\n if (position.indexOf('bottom') !== -1) {\n positionContainer.insertBefore(controlElement, positionContainer.firstChild);\n } else {\n positionContainer.appendChild(controlElement);\n }\n return this;\n }\n\n /**\n * Removes the control from the map.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param control - The {@link IControl} to remove.\n * @returns `this`\n * @example\n * ```ts\n * // Define a new navigation control.\n * let navigation = new maplibregl.NavigationControl();\n * // Add zoom and rotation controls to the map.\n * map.addControl(navigation);\n * // Remove zoom and rotation controls from the map.\n * map.removeControl(navigation);\n * ```\n */\n removeControl(control: IControl): Map {\n if (!control || !control.onRemove) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.')));\n }\n const ci = this._controls.indexOf(control);\n if (ci > -1) this._controls.splice(ci, 1);\n control.onRemove(this);\n return this;\n }\n\n /**\n * Checks if a control exists on the map.\n *\n * @param control - The {@link IControl} to check.\n * @returns true if map contains control.\n * @example\n * ```ts\n * // Define a new navigation control.\n * let navigation = new maplibregl.NavigationControl();\n * // Add zoom and rotation controls to the map.\n * map.addControl(navigation);\n * // Check that the navigation control exists on the map.\n * map.hasControl(navigation);\n * ```\n */\n hasControl(control: IControl): boolean {\n return this._controls.indexOf(control) > -1;\n }\n\n calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions {\n if (altitudeTo == null && this.terrain) {\n altitudeTo = this.terrain.getElevationForLngLatZoom(to, this.transform.tileZoom);\n }\n return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo);\n }\n\n /**\n * Resizes the map according to the dimensions of its\n * `container` element.\n *\n * Checks if the map container size changed and updates the map if it has changed.\n * This method must be called after the map's `container` is resized programmatically\n * or when the map is shown after being initially hidden with CSS.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`.\n *\n * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend`\n * events that get triggered as a result of resize. This can be useful for differentiating the\n * source of an event (for example, user-initiated or programmatically-triggered events).\n * @returns `this`\n * @example\n * Resize the map when the map container is shown after being initially hidden with CSS.\n * ```ts\n * let mapDiv = document.getElementById('map');\n * if (mapDiv.style.visibility === true) map.resize();\n * ```\n */\n resize(eventData?: any): Map {\n const dimensions = this._containerDimensions();\n const width = dimensions[0];\n const height = dimensions[1];\n\n const clampedPixelRatio = this._getClampedPixelRatio(width, height);\n this._resizeCanvas(width, height, clampedPixelRatio);\n this.painter.resize(width, height, clampedPixelRatio);\n\n // check if we've reached GL limits, in that case further clamps pixelRatio\n if (this.painter.overLimit()) {\n const gl = this.painter.context.gl;\n // store updated _maxCanvasSize value\n this._maxCanvasSize = [gl.drawingBufferWidth, gl.drawingBufferHeight];\n const clampedPixelRatio = this._getClampedPixelRatio(width, height);\n this._resizeCanvas(width, height, clampedPixelRatio);\n this.painter.resize(width, height, clampedPixelRatio);\n }\n\n this.transform.resize(width, height);\n this._requestedCameraState?.resize(width, height);\n\n const fireMoving = !this._moving;\n if (fireMoving) {\n this.stop();\n this.fire(new Event('movestart', eventData))\n .fire(new Event('move', eventData));\n }\n\n this.fire(new Event('resize', eventData));\n\n if (fireMoving) this.fire(new Event('moveend', eventData));\n\n return this;\n }\n\n /**\n * @internal\n * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize.\n * Internally you should use this and not getPixelRatio().\n */\n _getClampedPixelRatio(width: number, height: number): number {\n const {0: maxCanvasWidth, 1: maxCanvasHeight} = this._maxCanvasSize;\n const pixelRatio = this.getPixelRatio();\n\n const canvasWidth = width * pixelRatio;\n const canvasHeight = height * pixelRatio;\n\n const widthScaleFactor = canvasWidth > maxCanvasWidth ? (maxCanvasWidth / canvasWidth) : 1;\n const heightScaleFactor = canvasHeight > maxCanvasHeight ? (maxCanvasHeight / canvasHeight) : 1;\n\n return Math.min(widthScaleFactor, heightScaleFactor) * pixelRatio;\n }\n\n /**\n * Returns the map's pixel ratio.\n * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.\n * @returns The pixel ratio.\n */\n getPixelRatio(): number {\n return this._overridePixelRatio ?? devicePixelRatio;\n }\n\n /**\n * Sets the map's pixel ratio. This allows to override `devicePixelRatio`.\n * After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio`\n * and its height attribute will be `container.clientHeight * pixelRatio`.\n * Set this to null to disable `devicePixelRatio` override.\n * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.\n * @param pixelRatio - The pixel ratio.\n */\n setPixelRatio(pixelRatio: number) {\n this._overridePixelRatio = pixelRatio;\n this.resize();\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns The geographical bounds of the map as {@link LngLatBounds}.\n * @example\n * ```ts\n * let bounds = map.getBounds();\n * ```\n */\n getBounds(): LngLatBounds {\n return this.transform.getBounds();\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns The map object.\n * @example\n * ```ts\n * let maxBounds = map.getMaxBounds();\n * ```\n */\n getMaxBounds(): LngLatBounds | null {\n return this.transform.getMaxBounds();\n }\n\n /**\n * Sets or clears the map's geographical bounds.\n *\n * Pan and zoom operations are constrained within these bounds.\n * If a pan or zoom is performed that would\n * display regions outside these bounds, the map will\n * instead display a position and zoom level\n * as close as possible to the operation's request while still\n * remaining within the bounds.\n *\n * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds.\n * @returns `this`\n * @example\n * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds.\n * ```ts\n * let bounds = [\n * [-74.04728, 40.68392], // [west, south]\n * [-73.91058, 40.87764] // [east, north]\n * ];\n * map.setMaxBounds(bounds);\n * ```\n */\n setMaxBounds(bounds?: LngLatBoundsLike | null): Map {\n this.transform.setMaxBounds(LngLatBounds.convert(bounds));\n return this._update();\n }\n\n /**\n * Sets or clears the map's minimum zoom level.\n * If the map's current zoom level is lower than the new minimum,\n * the map will zoom to the new minimum.\n *\n * It is not always possible to zoom out and reach the set `minZoom`.\n * Other factors such as map height may restrict zooming. For example,\n * if the map is 512px tall it will not be possible to zoom below zoom 0\n * no matter what the `minZoom` is set to.\n *\n * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.\n *\n * @param minZoom - The minimum zoom level to set (-2 - 24).\n * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2).\n * @returns `this`\n * @example\n * ```ts\n * map.setMinZoom(12.25);\n * ```\n */\n setMinZoom(minZoom?: number | null): Map {\n\n minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;\n\n if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {\n this.transform.minZoom = minZoom;\n this._update();\n\n if (this.getZoom() < minZoom) this.setZoom(minZoom);\n\n return this;\n\n } else throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);\n }\n\n /**\n * Returns the map's minimum allowable zoom level.\n *\n * @returns minZoom\n * @example\n * ```ts\n * let minZoom = map.getMinZoom();\n * ```\n */\n getMinZoom(): number { return this.transform.minZoom; }\n\n /**\n * Sets or clears the map's maximum zoom level.\n * If the map's current zoom level is higher than the new maximum,\n * the map will zoom to the new maximum.\n *\n * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.\n *\n * @param maxZoom - The maximum zoom level to set.\n * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).\n * @returns `this`\n * @example\n * ```ts\n * map.setMaxZoom(18.75);\n * ```\n */\n setMaxZoom(maxZoom?: number | null): Map {\n\n maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;\n\n if (maxZoom >= this.transform.minZoom) {\n this.transform.maxZoom = maxZoom;\n this._update();\n\n if (this.getZoom() > maxZoom) this.setZoom(maxZoom);\n\n return this;\n\n } else throw new Error('maxZoom must be greater than the current minZoom');\n }\n\n /**\n * Returns the map's maximum allowable zoom level.\n *\n * @returns The maxZoom\n * @example\n * ```ts\n * let maxZoom = map.getMaxZoom();\n * ```\n */\n getMaxZoom(): number { return this.transform.maxZoom; }\n\n /**\n * Sets or clears the map's minimum pitch.\n * If the map's current pitch is lower than the new minimum,\n * the map will pitch to the new minimum.\n *\n * A {@link ErrorEvent} event will be fired if minPitch is out of bounds.\n *\n * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0).\n * @returns `this`\n */\n setMinPitch(minPitch?: number | null): Map {\n\n minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;\n\n if (minPitch < defaultMinPitch) {\n throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);\n }\n\n if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {\n this.transform.minPitch = minPitch;\n this._update();\n\n if (this.getPitch() < minPitch) this.setPitch(minPitch);\n\n return this;\n\n } else throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);\n }\n\n /**\n * Returns the map's minimum allowable pitch.\n *\n * @returns The minPitch\n */\n getMinPitch(): number { return this.transform.minPitch; }\n\n /**\n * Sets or clears the map's maximum pitch.\n * If the map's current pitch is higher than the new maximum,\n * the map will pitch to the new maximum.\n *\n * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds.\n *\n * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60).\n * @returns `this`\n */\n setMaxPitch(maxPitch?: number | null): Map {\n\n maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;\n\n if (maxPitch > maxPitchThreshold) {\n throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);\n }\n\n if (maxPitch >= this.transform.minPitch) {\n this.transform.maxPitch = maxPitch;\n this._update();\n\n if (this.getPitch() > maxPitch) this.setPitch(maxPitch);\n\n return this;\n\n } else throw new Error('maxPitch must be greater than the current minPitch');\n }\n\n /**\n * Returns the map's maximum allowable pitch.\n *\n * @returns The maxPitch\n */\n getMaxPitch(): number { return this.transform.maxPitch; }\n\n /**\n * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n * @returns The renderWorldCopies\n * @example\n * ```ts\n * let worldCopiesRendered = map.getRenderWorldCopies();\n * ```\n * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)\n */\n getRenderWorldCopies(): boolean { return this.transform.renderWorldCopies; }\n\n /**\n * Sets the state of `renderWorldCopies`.\n *\n * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n *\n * `undefined` is treated as `true`, `null` is treated as `false`.\n * @returns `this`\n * @example\n * ```ts\n * map.setRenderWorldCopies(true);\n * ```\n * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)\n */\n setRenderWorldCopies(renderWorldCopies?: boolean | null): Map {\n this.transform.renderWorldCopies = renderWorldCopies;\n return this._update();\n }\n\n /**\n * Gets the map's cooperativeGestures option\n *\n * @returns The gestureOptions\n */\n getCooperativeGestures(): boolean | GestureOptions {\n return this._cooperativeGestures;\n }\n\n /**\n * Sets or clears the map's cooperativeGestures option\n *\n * @param gestureOptions - If `true` or set to an options object, map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, \"drag to pitch\" requires a three-finger gesture.\n * @returns `this`\n */\n setCooperativeGestures(gestureOptions?: GestureOptions | boolean | null): Map {\n this._cooperativeGestures = gestureOptions;\n if (this._cooperativeGestures) {\n this._setupCooperativeGestures();\n } else {\n this._destroyCooperativeGestures();\n }\n\n return this;\n }\n\n /**\n * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`,\n * that correspond to the specified geographical location.\n *\n * @param lnglat - The geographical location to project.\n * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`.\n * @example\n * ```ts\n * let coordinate = [-122.420679, 37.772537];\n * let point = map.project(coordinate);\n * ```\n */\n project(lnglat: LngLatLike): Point {\n return this.transform.locationPoint(LngLat.convert(lnglat), this.style && this.terrain);\n }\n\n /**\n * Returns a {@link LngLat} representing geographical coordinates that correspond\n * to the specified pixel coordinates.\n *\n * @param point - The pixel coordinates to unproject.\n * @returns The {@link LngLat} corresponding to `point`.\n * @example\n * ```ts\n * map.on('click', function(e) {\n * // When the map is clicked, get the geographic coordinate.\n * let coordinate = map.unproject(e.point);\n * });\n * ```\n */\n unproject(point: PointLike): LngLat {\n return this.transform.pointLocation(Point.convert(point), this.terrain);\n }\n\n /**\n * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.\n * @returns true if the map is moving.\n * @example\n * ```ts\n * let isMoving = map.isMoving();\n * ```\n */\n isMoving(): boolean {\n return this._moving || this.handlers?.isMoving();\n }\n\n /**\n * Returns true if the map is zooming due to a camera animation or user gesture.\n * @returns true if the map is zooming.\n * @example\n * ```ts\n * let isZooming = map.isZooming();\n * ```\n */\n isZooming(): boolean {\n return this._zooming || this.handlers?.isZooming();\n }\n\n /**\n * Returns true if the map is rotating due to a camera animation or user gesture.\n * @returns true if the map is rotating.\n * @example\n * ```ts\n * map.isRotating();\n * ```\n */\n isRotating(): boolean {\n return this._rotating || this.handlers?.isRotating();\n }\n\n _createDelegatedListener(type: keyof MapEventType | string, layerId: string, listener: Listener): {\n layer: string;\n listener: Listener;\n delegates: {[type in keyof MapEventType]?: (e: any) => void};\n } {\n if (type === 'mouseenter' || type === 'mouseover') {\n let mousein = false;\n const mousemove = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (!features.length) {\n mousein = false;\n } else if (!mousein) {\n mousein = true;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent, {features}));\n }\n };\n const mouseout = () => {\n mousein = false;\n };\n return {layer: layerId, listener, delegates: {mousemove, mouseout}};\n } else if (type === 'mouseleave' || type === 'mouseout') {\n let mousein = false;\n const mousemove = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (features.length) {\n mousein = true;\n } else if (mousein) {\n mousein = false;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent));\n }\n };\n const mouseout = (e) => {\n if (mousein) {\n mousein = false;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent));\n }\n };\n return {layer: layerId, listener, delegates: {mousemove, mouseout}};\n } else {\n const delegate = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (features.length) {\n // Here we need to mutate the original event, so that preventDefault works as expected.\n e.features = features;\n listener.call(this, e);\n delete e.features;\n }\n };\n return {layer: layerId, listener, delegates: {[type]: delegate}};\n }\n }\n\n /**\n * @event\n * Adds a listener for events of a specified type, optionally limited to features in a specified style layer.\n * See {@link MapEventType} and {@link MapLayerEventType} for a full list of events and their description.\n *\n * | Event | Compatible with `layerId` |\n * |------------------------|---------------------------|\n * | `mousedown` | yes |\n * | `mouseup` | yes |\n * | `mouseover` | yes |\n * | `mouseout` | yes |\n * | `mousemove` | yes |\n * | `mouseenter` | yes (required) |\n * | `mouseleave` | yes (required) |\n * | `click` | yes |\n * | `dblclick` | yes |\n * | `contextmenu` | yes |\n * | `touchstart` | yes |\n * | `touchend` | yes |\n * | `touchcancel` | yes |\n * | `wheel` | |\n * | `resize` | |\n * | `remove` | |\n * | `touchmove` | |\n * | `movestart` | |\n * | `move` | |\n * | `moveend` | |\n * | `dragstart` | |\n * | `drag` | |\n * | `dragend` | |\n * | `zoomstart` | |\n * | `zoom` | |\n * | `zoomend` | |\n * | `rotatestart` | |\n * | `rotate` | |\n * | `rotateend` | |\n * | `pitchstart` | |\n * | `pitch` | |\n * | `pitchend` | |\n * | `boxzoomstart` | |\n * | `boxzoomend` | |\n * | `boxzoomcancel` | |\n * | `webglcontextlost` | |\n * | `webglcontextrestored` | |\n * | `load` | |\n * | `render` | |\n * | `idle` | |\n * | `error` | |\n * | `data` | |\n * | `styledata` | |\n * | `sourcedata` | |\n * | `dataloading` | |\n * | `styledataloading` | |\n * | `sourcedataloading` | |\n * | `styleimagemissing` | |\n * | `dataabort` | |\n * | `sourcedataabort` | |\n *\n * @param type - The event type to listen for. Events compatible with the optional `layerId` parameter are triggered\n * when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas.\n * @param layer - The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location\n * is within a visible feature in this layer. The event will have a `features` property containing\n * an array of the matching features. If `layer` is not supplied, the event will not have a `features` property.\n * Please note that many event types are not compatible with the optional `layer` parameter.\n * @param listener - The function to be called when the event is fired.\n * @returns `this`\n * @example\n * ```ts\n * // Set an event listener that will fire\n * // when the map has finished loading\n * map.on('load', function() {\n * // Once the map has finished loading,\n * // add a new layer\n * map.addLayer({\n * id: 'points-of-interest',\n * source: {\n * type: 'vector',\n * url: 'https://maplibre.org/maplibre-style-spec/'\n * },\n * 'source-layer': 'poi_label',\n * type: 'circle',\n * paint: {\n * // MapLibre Style Specification paint properties\n * },\n * layout: {\n * // MapLibre Style Specification layout properties\n * }\n * });\n * });\n * ```\n * @example\n * ```ts\n * // Set an event listener that will fire\n * // when a feature on the countries layer of the map is clicked\n * map.on('click', 'countries', (e) => {\n * new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setHTML(`Country name: ${e.features[0].properties.name}`)\n * .addTo(map);\n * });\n * ```\n * @see [Display popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n on(\n type: T,\n layer: string,\n listener: (ev: MapLayerEventType[T] & Object) => void,\n ): Map;\n /**\n * Overload of the `on` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n on(type: T, listener: (ev: MapEventType[T] & Object) => void): this;\n /**\n * Overload of the `on` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n on(type: keyof MapEventType | string, listener: Listener): this;\n on(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {\n if (listener === undefined) {\n return super.on(type, layerIdOrListener as Listener);\n }\n\n const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener);\n\n this._delegatedListeners = this._delegatedListeners || {};\n this._delegatedListeners[type] = this._delegatedListeners[type] || [];\n this._delegatedListeners[type].push(delegatedListener);\n\n for (const event in delegatedListener.delegates) {\n this.on(event, delegatedListener.delegates[event]);\n }\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer.\n *\n * @event\n * @param type - The event type to listen for; one of `'mousedown'`, `'mouseup'`, `'click'`, `'dblclick'`,\n * `'mousemove'`, `'mouseenter'`, `'mouseleave'`, `'mouseover'`, `'mouseout'`, `'contextmenu'`, `'touchstart'`,\n * `'touchend'`, or `'touchcancel'`. `mouseenter` and `mouseover` events are triggered when the cursor enters\n * a visible portion of the specified layer from outside that layer or outside the map canvas. `mouseleave`\n * and `mouseout` events are triggered when the cursor leaves a visible portion of the specified layer, or leaves\n * the map canvas.\n * @param layer - The ID of a style layer or a listener if no ID is provided. Only events whose location is within a visible\n * feature in this layer will trigger the listener. The event will have a `features` property containing\n * an array of the matching features.\n * @param listener - The function to be called when the event is fired.\n * @returns `this` if listener is provided, promise otherwise to allow easier usage of async/await\n */\n once(\n type: T,\n layer: string,\n listener?: (ev: MapLayerEventType[T] & Object) => void,\n ): this | Promise;\n /**\n * Overload of the `once` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n once(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise;\n /**\n * Overload of the `once` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n once(type: keyof MapEventType | string, listener?: Listener): this | Promise;\n once(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this | Promise {\n\n if (listener === undefined) {\n return super.once(type, layerIdOrListener as Listener);\n }\n\n const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener);\n\n for (const event in delegatedListener.delegates) {\n this.once(event, delegatedListener.delegates[event]);\n }\n\n return this;\n }\n\n /**\n * Removes an event listener for events previously added with `Map#on`.\n *\n * @event\n * @param type - The event type previously used to install the listener.\n * @param layer - The layer ID or listener previously used to install the listener.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(\n type: T,\n layer: string,\n listener: (ev: MapLayerEventType[T] & Object) => void,\n ): this;\n /**\n * Overload of the `off` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(type: T, listener: (ev: MapEventType[T] & Object) => void): this;\n /**\n * Overload of the `off` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(type: keyof MapEventType | string, listener: Listener): this;\n off(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {\n if (listener === undefined) {\n return super.off(type, layerIdOrListener as Listener);\n }\n\n const removeDelegatedListener = (delegatedListeners) => {\n const listeners = delegatedListeners[type];\n for (let i = 0; i < listeners.length; i++) {\n const delegatedListener = listeners[i];\n if (delegatedListener.layer === layerIdOrListener && delegatedListener.listener === listener) {\n for (const event in delegatedListener.delegates) {\n this.off(((event as any)), delegatedListener.delegates[event]);\n }\n listeners.splice(i, 1);\n return this;\n }\n }\n };\n\n if (this._delegatedListeners && this._delegatedListeners[type]) {\n removeDelegatedListener(this._delegatedListeners);\n }\n\n return this;\n }\n\n /**\n * Returns an array of MapGeoJSONFeature objects\n * representing visible features that satisfy the query parameters.\n *\n * @param geometryOrOptions - (optional) The geometry of the query region:\n * either a single point or southwest and northeast points describing a bounding box.\n * Omitting this parameter (i.e. calling {@link Map#queryRenderedFeatures} with zero arguments,\n * or with only a `options` argument) is equivalent to passing a bounding box encompassing the entire\n * map viewport.\n * The geometryOrOptions can receive a {@link QueryRenderedFeaturesOptions} only to support a situation where the function receives only one parameter which is the options parameter.\n * @param options - (optional) Options object.\n *\n * @returns An array of MapGeoJSONFeature objects.\n *\n * The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only\n * string and numeric property values are supported (i.e. `null`, `Array`, and `Object` values are not supported).\n *\n * Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object\n * representing the style layer to which the feature belongs. Layout and paint properties in this object contain values\n * which are fully evaluated for the given zoom level and feature.\n *\n * Only features that are currently rendered are included. Some features will **not** be included, like:\n *\n * - Features from layers whose `visibility` property is `\"none\"`.\n * - Features from layers whose zoom range excludes the current zoom level.\n * - Symbol features that have been hidden due to text or icon collision.\n *\n * Features from all other layers are included, including features that may have no visible\n * contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to\n * 0.\n *\n * The topmost rendered feature appears first in the returned array, and subsequent features are sorted by\n * descending z-order. Features that are rendered multiple times (due to wrapping across the antemeridian at low\n * zoom levels) are returned only once (though subject to the following caveat).\n *\n * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature\n * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple\n * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query.\n * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding\n * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile\n * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple\n * tiles due to tile buffering.\n *\n * @example\n * Find all features at a point\n * ```ts\n * let features = map.queryRenderedFeatures(\n * [20, 35],\n * { layers: ['my-layer-name'] }\n * );\n * ```\n *\n * @example\n * Find all features within a static bounding box\n * ```ts\n * let features = map.queryRenderedFeatures(\n * [[10, 20], [30, 50]],\n * { layers: ['my-layer-name'] }\n * );\n * ```\n *\n * @example\n * Find all features within a bounding box around a point\n * ```ts\n * let width = 10;\n * let height = 20;\n * let features = map.queryRenderedFeatures([\n * [point.x - width / 2, point.y - height / 2],\n * [point.x + width / 2, point.y + height / 2]\n * ], { layers: ['my-layer-name'] });\n * ```\n *\n * @example\n * Query all rendered features from a single layer\n * ```ts\n * let features = map.queryRenderedFeatures({ layers: ['my-layer-name'] });\n * ```\n * @see [Get features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/queryrenderedfeatures/)\n */\n queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[] {\n if (!this.style) {\n return [];\n }\n let queryGeometry;\n const isGeometry = geometryOrOptions instanceof Point || Array.isArray(geometryOrOptions);\n const geometry = isGeometry ? geometryOrOptions : [[0, 0], [this.transform.width, this.transform.height]];\n options = options || (isGeometry ? {} : geometryOrOptions) || {};\n\n if (geometry instanceof Point || typeof geometry[0] === 'number') {\n queryGeometry = [Point.convert(geometry as PointLike)];\n } else {\n const tl = Point.convert(geometry[0] as PointLike);\n const br = Point.convert(geometry[1] as PointLike);\n queryGeometry = [tl, new Point(br.x, tl.y), br, new Point(tl.x, br.y), tl];\n }\n\n return this.style.queryRenderedFeatures(queryGeometry, options, this.transform);\n }\n\n /**\n * Returns an array of MapGeoJSONFeature objects\n * representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.\n *\n * @param sourceId - The ID of the vector tile or GeoJSON source to query.\n * @param parameters - The options object.\n * @returns An array of MapGeoJSONFeature objects.\n *\n * In contrast to {@link Map#queryRenderedFeatures}, this function returns all features matching the query parameters,\n * whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded\n * vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently\n * visible viewport.\n *\n * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature\n * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple\n * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query.\n * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding\n * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile\n * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple\n * tiles due to tile buffering.\n *\n * @example\n * Find all features in one source layer in a vector source\n * ```ts\n * let features = map.querySourceFeatures('your-source-id', {\n * sourceLayer: 'your-source-layer'\n * });\n * ```\n *\n */\n querySourceFeatures(sourceId: string, parameters?: QuerySourceFeatureOptions | null): MapGeoJSONFeature[] {\n return this.style.querySourceFeatures(sourceId, parameters);\n }\n\n /**\n * Updates the map's MapLibre style object with a new value.\n *\n * If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style\n * against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites\n * (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current\n * style and the given style are different in any way, the map renderer will force a full update, removing the current style and building\n * the given one from scratch.\n *\n *\n * @param style - A JSON object conforming to the schema described in the\n * [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), or a URL to such JSON.\n * @param options - The options object.\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setStyle(\"https://demotiles.maplibre.org/style.json\");\n *\n * map.setStyle('https://demotiles.maplibre.org/style.json', {\n * transformStyle: (previousStyle, nextStyle) => ({\n * ...nextStyle,\n * sources: {\n * ...nextStyle.sources,\n * // copy a source from previous style\n * 'osm': previousStyle.sources.osm\n * },\n * layers: [\n * // background layer\n * nextStyle.layers[0],\n * // copy a layer from previous style\n * previousStyle.layers[0],\n * // other layers from the next style\n * ...nextStyle.layers.slice(1).map(layer => {\n * // hide the layers we don't need from demotiles style\n * if (layer.id.startsWith('geolines')) {\n * layer.layout = {...layer.layout || {}, visibility: 'none'};\n * // filter out US polygons\n * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {\n * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];\n * }\n * return layer;\n * })\n * ]\n * })\n * });\n * ```\n */\n setStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions): this {\n options = extend({},\n {\n localIdeographFontFamily: this._localIdeographFontFamily,\n validate: this._validateStyle\n }, options);\n\n if ((options.diff !== false && options.localIdeographFontFamily === this._localIdeographFontFamily) && this.style && style) {\n this._diffStyle(style, options);\n return this;\n } else {\n this._localIdeographFontFamily = options.localIdeographFontFamily;\n return this._updateStyle(style, options);\n }\n }\n\n /**\n * Updates the requestManager's transform request with a new function\n *\n * @param transformRequest - A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.\n * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties\n *\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setTransformRequest((url: string, resourceType: string) => {});\n * ```\n */\n setTransformRequest(transformRequest: RequestTransformFunction): this {\n this._requestManager.setTransformRequest(transformRequest);\n return this;\n }\n\n _getUIString(key: string) {\n const str = this._locale[key];\n if (str == null) {\n throw new Error(`Missing UI string '${key}'`);\n }\n\n return str;\n }\n\n _updateStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions) {\n // transformStyle relies on having previous style serialized, if it is not loaded yet, delay _updateStyle until previous style is loaded\n if (options.transformStyle && this.style && !this.style._loaded) {\n this.style.once('style.load', () => this._updateStyle(style, options));\n return;\n }\n\n const previousStyle = this.style && options.transformStyle ? this.style.serialize() : undefined;\n if (this.style) {\n this.style.setEventedParent(null);\n\n // Only release workers when map is getting disposed\n this.style._remove(!style);\n }\n\n if (!style) {\n delete this.style;\n return this;\n } else {\n this.style = new Style(this, options || {});\n }\n\n this.style.setEventedParent(this, {style: this.style});\n\n if (typeof style === 'string') {\n this.style.loadURL(style, options, previousStyle);\n } else {\n this.style.loadJSON(style, options, previousStyle);\n }\n\n return this;\n }\n\n _lazyInitEmptyStyle() {\n if (!this.style) {\n this.style = new Style(this, {});\n this.style.setEventedParent(this, {style: this.style});\n this.style.loadEmpty();\n }\n }\n\n _diffStyle(style: StyleSpecification | string, options?: StyleSwapOptions & StyleOptions) {\n if (typeof style === 'string') {\n const url = style;\n const request = this._requestManager.transformRequest(url, ResourceType.Style);\n getJSON(request, (error?: Error | null, json?: any | null) => {\n if (error) {\n this.fire(new ErrorEvent(error));\n } else if (json) {\n this._updateDiff(json, options);\n }\n });\n } else if (typeof style === 'object') {\n this._updateDiff(style, options);\n }\n }\n\n _updateDiff(style: StyleSpecification, options?: StyleSwapOptions & StyleOptions) {\n try {\n if (this.style.setState(style, options)) {\n this._update(true);\n }\n } catch (e) {\n warnOnce(\n `Unable to perform style diff: ${e.message || e.error || e}. Rebuilding the style from scratch.`\n );\n this._updateStyle(style, options);\n }\n }\n\n /**\n * Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style.\n *\n * @returns The map's style JSON object.\n *\n * @example\n * ```ts\n * let styleJson = map.getStyle();\n * ```\n *\n */\n getStyle(): StyleSpecification {\n if (this.style) {\n return this.style.serialize();\n }\n }\n\n /**\n * Returns a Boolean indicating whether the map's style is fully loaded.\n *\n * @returns A Boolean indicating whether the style is fully loaded.\n *\n * @example\n * ```ts\n * let styleLoadStatus = map.isStyleLoaded();\n * ```\n */\n isStyleLoaded(): boolean | void {\n if (!this.style) return warnOnce('There is no style added to the map.');\n return this.style.loaded();\n }\n\n /**\n * Adds a source to the map's style.\n *\n * Events triggered:\n *\n * Triggers the `source.add` event.\n *\n * @param id - The ID of the source to add. Must not conflict with existing sources.\n * @param source - The source object, conforming to the\n * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or\n * {@link CanvasSourceSpecification}.\n * @returns `this`\n * @example\n * ```ts\n * map.addSource('my-data', {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * });\n * ```\n * @example\n * ```ts\n * map.addSource('my-data', {\n * \"type\": \"geojson\",\n * \"data\": {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [-77.0323, 38.9131]\n * },\n * \"properties\": {\n * \"title\": \"Mapbox DC\",\n * \"marker-symbol\": \"monument\"\n * }\n * }\n * });\n * ```\n * @see GeoJSON source: [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n */\n addSource(id: string, source: SourceSpecification): this {\n this._lazyInitEmptyStyle();\n this.style.addSource(id, source);\n return this._update(true);\n }\n\n /**\n * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with\n * the given ID in the map's style has no outstanding network requests, otherwise `false`.\n *\n * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID.\n *\n * @param id - The ID of the source to be checked.\n * @returns A Boolean indicating whether the source is loaded.\n * @example\n * ```ts\n * let sourceLoaded = map.isSourceLoaded('bathymetry-data');\n * ```\n */\n isSourceLoaded(id: string): boolean {\n const source = this.style && this.style.sourceCaches[id];\n if (source === undefined) {\n this.fire(new ErrorEvent(new Error(`There is no source with ID '${id}'`)));\n return;\n }\n return source.loaded();\n }\n\n /**\n * Loads a 3D terrain mesh, based on a \"raster-dem\" source.\n *\n * Triggers the `terrain` event.\n *\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setTerrain({ source: 'terrain' });\n * ```\n */\n setTerrain(options: TerrainSpecification | null): this {\n this.style._checkLoaded();\n\n // clear event handlers\n if (this._terrainDataCallback) this.style.off('data', this._terrainDataCallback);\n\n if (!options) {\n // remove terrain\n if (this.terrain) this.terrain.sourceCache.destruct();\n this.terrain = null;\n if (this.painter.renderToTexture) this.painter.renderToTexture.destruct();\n this.painter.renderToTexture = null;\n this.transform._minEleveationForCurrentTile = 0;\n this.transform.elevation = 0;\n } else {\n // add terrain\n const sourceCache = this.style.sourceCaches[options.source];\n if (!sourceCache) throw new Error(`cannot load terrain, because there exists no source with ID: ${options.source}`);\n // Warn once if user is using the same source for hillshade and terrain\n for (const index in this.style._layers) {\n const thisLayer = this.style._layers[index];\n if (thisLayer.type === 'hillshade' && thisLayer.source === options.source) {\n warnOnce('You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.');\n }\n }\n this.terrain = new Terrain(this.painter, sourceCache, options);\n this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain);\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this._terrainDataCallback = e => {\n if (e.dataType === 'style') {\n this.terrain.sourceCache.freeRtt();\n } else if (e.dataType === 'source' && e.tile) {\n if (e.sourceId === options.source && !this._elevationFreeze) {\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n }\n this.terrain.sourceCache.freeRtt(e.tile.tileID);\n }\n };\n this.style.on('data', this._terrainDataCallback);\n }\n\n this.fire(new Event('terrain', {terrain: options}));\n return this;\n }\n\n /**\n * Get the terrain-options if terrain is loaded\n * @returns the TerrainSpecification passed to setTerrain\n * @example\n * ```ts\n * map.getTerrain(); // { source: 'terrain' };\n * ```\n */\n getTerrain(): TerrainSpecification | null {\n return this.terrain?.options ?? null;\n }\n\n /**\n * Returns a Boolean indicating whether all tiles in the viewport from all sources on\n * the style are loaded.\n *\n * @returns A Boolean indicating whether all tiles are loaded.\n * @example\n * ```ts\n * let tilesLoaded = map.areTilesLoaded();\n * ```\n */\n areTilesLoaded(): boolean {\n const sources = this.style && this.style.sourceCaches;\n for (const id in sources) {\n const source = sources[id];\n const tiles = source._tiles;\n for (const t in tiles) {\n const tile = tiles[t];\n if (!(tile.state === 'loaded' || tile.state === 'errored')) return false;\n }\n }\n return true;\n }\n\n /**\n * Adds a [custom source type](#Custom Sources), making it available for use with\n * {@link Map#addSource}.\n * @param name - The name of the source type; source definition objects use this name in the `{type: ...}` field.\n * @param SourceType - A {@link Source} constructor.\n * @param callback - Called when the source type is ready or with an error argument if there is an error.\n */\n addSourceType(name: string, SourceType: SourceClass, callback: Callback) {\n this._lazyInitEmptyStyle();\n return this.style.addSourceType(name, SourceType, callback);\n }\n\n /**\n * Removes a source from the map's style.\n *\n * @param id - The ID of the source to remove.\n * @returns `this`\n * @example\n * ```ts\n * map.removeSource('bathymetry-data');\n * ```\n */\n removeSource(id: string): Map {\n this.style.removeSource(id);\n return this._update(true);\n }\n\n /**\n * Returns the source with the specified ID in the map's style.\n *\n * This method is often used to update a source using the instance members for the relevant\n * source type as defined in [Sources](#sources).\n * For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates`\n * of an image source.\n *\n * @param id - The ID of the source to get.\n * @returns The style source with the specified ID or `undefined` if the ID\n * corresponds to no existing sources.\n * The shape of the object varies by source type.\n * A list of options for each source type is available on the MapLibre Style Specification's\n * [Sources](https://maplibre.org/maplibre-style-spec/sources/) page.\n * @example\n * ```ts\n * let sourceObject = map.getSource('points');\n * ```\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)\n * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n */\n getSource(id: string): Source | undefined {\n return this.style.getSource(id);\n }\n\n /**\n * Add an image to the style. This image can be displayed on the map like any other icon in the style's\n * sprite using the image's ID with\n * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),\n * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),\n * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),\n * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).\n *\n * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image.\n *\n * @param id - The ID of the image.\n * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`\n * properties with the same format as `ImageData`.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * // If the style's sprite does not already contain an image with ID 'cat',\n * // add the image 'cat-icon.png' to the style's sprite with the ID 'cat'.\n * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) {\n * if (error) throw error;\n * if (!map.hasImage('cat')) map.addImage('cat', image);\n * });\n *\n * // Add a stretchable image that can be used with `icon-text-fit`\n * // In this example, the image is 600px wide by 400px high.\n * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png', function(error, image) {\n * if (error) throw error;\n * if (!map.hasImage('border-image')) {\n * map.addImage('border-image', image, {\n * content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border\n * stretchX: [[16, 584]], // stretch everything horizontally except the 16px border\n * stretchY: [[16, 384]], // stretch everything vertically except the 16px border\n * });\n * }\n * });\n * ```\n * @see Use `HTMLImageElement`: [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/)\n * @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-generated/)\n */\n addImage(id: string,\n image: HTMLImageElement | ImageBitmap | ImageData | {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n } | StyleImageInterface,\n options: Partial = {}): this {\n const {\n pixelRatio = 1,\n sdf = false,\n stretchX,\n stretchY,\n content\n } = options;\n this._lazyInitEmptyStyle();\n const version = 0;\n\n if (image instanceof HTMLImageElement || isImageBitmap(image)) {\n const {width, height, data} = browser.getImageData(image);\n this.style.addImage(id, {data: new RGBAImage({width, height}, data), pixelRatio, stretchX, stretchY, content, sdf, version});\n } else if (image.width === undefined || image.height === undefined) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' +\n 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`')));\n } else {\n const {width, height, data} = image as ImageData;\n const userImage = (image as any as StyleImageInterface);\n\n this.style.addImage(id, {\n data: new RGBAImage({width, height}, new Uint8Array(data)),\n pixelRatio,\n stretchX,\n stretchY,\n content,\n sdf,\n version,\n userImage\n });\n\n if (userImage.onAdd) {\n userImage.onAdd(this, id);\n }\n return this;\n }\n }\n\n /**\n * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's\n * sprite using the image's ID with\n * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),\n * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),\n * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),\n * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the image.\n * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`\n * properties with the same format as `ImageData`.\n * @returns `this`\n * @example\n * ```ts\n * // If an image with the ID 'cat' already exists in the style's sprite,\n * // replace that image with a new image, 'other-cat-icon.png'.\n * if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png');\n * ```\n */\n updateImage(id: string,\n image: HTMLImageElement | ImageBitmap | ImageData | {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n } | StyleImageInterface): this {\n\n const existingImage = this.style.getImage(id);\n if (!existingImage) {\n return this.fire(new ErrorEvent(new Error(\n 'The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.')));\n }\n const imageData = (image instanceof HTMLImageElement || isImageBitmap(image)) ?\n browser.getImageData(image) :\n image;\n const {width, height, data} = imageData;\n\n if (width === undefined || height === undefined) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' +\n 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`')));\n }\n\n if (width !== existingImage.data.width || height !== existingImage.data.height) {\n return this.fire(new ErrorEvent(new Error(\n 'The width and height of the updated image must be that same as the previous version of the image')));\n }\n\n const copy = !(image instanceof HTMLImageElement || isImageBitmap(image));\n existingImage.data.replace(data, copy);\n\n this.style.updateImage(id, existingImage);\n return this;\n }\n\n /**\n * Returns an image, specified by ID, currently available in the map.\n * This includes both images from the style's original sprite\n * and any images that have been added at runtime using {@link Map#addImage}.\n *\n * @param id - The ID of the image.\n * @returns An image in the map with the specified ID.\n *\n * @example\n * ```ts\n * let coffeeShopIcon = map.getImage(\"coffee_cup\");\n * ```\n */\n getImage(id: string): StyleImage {\n return this.style.getImage(id);\n }\n\n /**\n * Check whether or not an image with a specific ID exists in the style. This checks both images\n * in the style's original sprite and any images\n * that have been added at runtime using {@link Map#addImage}.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the image.\n *\n * @returns A Boolean indicating whether the image exists.\n * @example\n * Check if an image with the ID 'cat' exists in the style's sprite.\n * ```ts\n * let catIconExists = map.hasImage('cat');\n * ```\n */\n hasImage(id: string): boolean {\n if (!id) {\n this.fire(new ErrorEvent(new Error('Missing required image id')));\n return false;\n }\n\n return !!this.style.getImage(id);\n }\n\n /**\n * Remove an image from a style. This can be an image from the style's original\n * sprite or any images\n * that have been added at runtime using {@link Map#addImage}.\n *\n * @param id - The ID of the image.\n *\n * @example\n * ```ts\n * // If an image with the ID 'cat' exists in\n * // the style's sprite, remove it.\n * if (map.hasImage('cat')) map.removeImage('cat');\n * ```\n */\n removeImage(id: string) {\n this.style.removeImage(id);\n }\n\n /**\n * Load an image from an external URL to be used with {@link Map#addImage}. External\n * domains must support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS).\n *\n * @param url - The URL of the image file. Image file must be in png, webp, or jpg format.\n * @param callback - Expecting `callback(error, data)`. Called when the image has loaded or with an error argument if there is an error.\n *\n * @example\n * Load an image from an external URL.\n * ```ts\n * map.loadImage('http://placekitten.com/50/50', function(error, image) {\n * if (error) throw error;\n * // Add the loaded image to the style's sprite with the ID 'kitten'.\n * map.addImage('kitten', image);\n * });\n * ```\n * @see [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/)\n */\n loadImage(url: string, callback: GetImageCallback) {\n ImageRequest.getImage(this._requestManager.transformRequest(url, ResourceType.Image), callback);\n }\n\n /**\n * Returns an Array of strings containing the IDs of all images currently available in the map.\n * This includes both images from the style's original sprite\n * and any images that have been added at runtime using {@link Map#addImage}.\n *\n * @returns An Array of strings containing the names of all sprites/images currently available in the map.\n *\n * @example\n * ```ts\n * let allImages = map.listImages();\n * ```\n */\n listImages(): Array {\n return this.style.listImages();\n }\n\n /**\n * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers)\n * to the map's style.\n *\n * A layer defines how data from a specified source will be styled. Read more about layer types\n * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers).\n *\n * @param layer - The layer to add,\n * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,\n * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition.\n * The MapLibre Style Specification's layer definition is appropriate for most layers.\n *\n * @param beforeId - The ID of an existing layer to insert the new layer before,\n * resulting in the new layer appearing visually beneath the existing layer.\n * If this argument is not specified, the layer will be appended to the end of the layers array\n * and appear visually above all other layers.\n *\n * @returns `this`\n *\n * @example\n * Add a circle layer with a vector source\n * ```ts\n * map.addLayer({\n * id: 'points-of-interest',\n * source: {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * },\n * 'source-layer': 'poi_label',\n * type: 'circle',\n * paint: {\n * // MapLibre Style Specification paint properties\n * },\n * layout: {\n * // MapLibre Style Specification layout properties\n * }\n * });\n * ```\n *\n * @example\n * Define a source before using it to create a new layer\n * ```ts\n * map.addSource('state-data', {\n * type: 'geojson',\n * data: 'path/to/data.geojson'\n * });\n *\n * map.addLayer({\n * id: 'states',\n * // References the GeoJSON source defined above\n * // and does not require a `source-layer`\n * source: 'state-data',\n * type: 'symbol',\n * layout: {\n * // Set the label content to the\n * // feature's `name` property\n * text-field: ['get', 'name']\n * }\n * });\n * ```\n *\n * @example\n * Add a new symbol layer before an existing layer\n * ```ts\n * map.addLayer({\n * id: 'states',\n * // References a source that's already been defined\n * source: 'state-data',\n * type: 'symbol',\n * layout: {\n * // Set the label content to the\n * // feature's `name` property\n * text-field: ['get', 'name']\n * }\n * // Add the layer before the existing `cities` layer\n * }, 'cities');\n * ```\n * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)\n * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)\n * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/)\n */\n addLayer(layer: AddLayerObject, beforeId?: string) {\n this._lazyInitEmptyStyle();\n this.style.addLayer(layer, beforeId);\n return this._update(true);\n }\n\n /**\n * Moves a layer to a different z-position.\n *\n * @param id - The ID of the layer to move.\n * @param beforeId - The ID of an existing layer to insert the new layer before. When viewing the map, the `id` layer will appear beneath the `beforeId` layer. If `beforeId` is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map.\n * @returns `this`\n *\n * @example\n * Move a layer with ID 'polygon' before the layer with ID 'country-label'. The `polygon` layer will appear beneath the `country-label` layer on the map.\n * ```ts\n * map.moveLayer('polygon', 'country-label');\n * ```\n */\n moveLayer(id: string, beforeId?: string): this {\n this.style.moveLayer(id, beforeId);\n return this._update(true);\n }\n\n /**\n * Removes the layer with the given ID from the map's style.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the layer to remove\n * @returns `this`\n *\n * @example\n * If a layer with ID 'state-data' exists, remove it.\n * ```ts\n * if (map.getLayer('state-data')) map.removeLayer('state-data');\n * ```\n */\n removeLayer(id: string): this {\n this.style.removeLayer(id);\n return this._update(true);\n }\n\n /**\n * Returns the layer with the specified ID in the map's style.\n *\n * @param id - The ID of the layer to get.\n * @returns The layer with the specified ID, or `undefined`\n * if the ID corresponds to no existing layers.\n *\n * @example\n * ```ts\n * let stateDataLayer = map.getLayer('state-data');\n * ```\n * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/)\n * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/)\n */\n getLayer(id: string): StyleLayer | undefined {\n return this.style.getLayer(id);\n }\n\n /**\n * Return the ids of all layers currently in the style, including custom layers, in order.\n *\n * @returns ids of layers, in order\n *\n * @example\n * ```ts\n * const orderedLayerIds = map.getLayersOrder();\n * ```\n */\n getLayersOrder(): string[] {\n return this.style.getLayersOrder();\n }\n\n /**\n * Sets the zoom extent for the specified style layer. The zoom extent includes the\n * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)\n * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom))\n * at which the layer will be rendered.\n *\n * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the\n * minimum zoom level of the _source layer_ because the data does not exist at those zoom levels. If the minimum\n * zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style\n * layer will not be rendered at all zoom levels in the zoom range.\n *\n * @param layerId - The ID of the layer to which the zoom extent will be applied.\n * @param minzoom - The minimum zoom to set (0-24).\n * @param maxzoom - The maximum zoom to set (0-24).\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setLayerZoomRange('my-layer', 2, 5);\n * ```\n */\n setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this {\n this.style.setLayerZoomRange(layerId, minzoom, maxzoom);\n return this._update(true);\n }\n\n /**\n * Sets the filter for the specified style layer.\n *\n * Filters control which features a style layer renders from its source.\n * Any feature for which the filter expression evaluates to `true` will be\n * rendered on the map. Those that are false will be hidden.\n *\n * Use `setFilter` to show a subset of your source data.\n *\n * To clear the filter, pass `null` or `undefined` as the second parameter.\n *\n * @param layerId - The ID of the layer to which the filter will be applied.\n * @param filter - The filter, conforming to the MapLibre Style Specification's\n * [filter definition](https://maplibre.org/maplibre-style-spec/layers/#filter). If `null` or `undefined` is provided, the function removes any existing filter from the layer.\n * @param options - Options object.\n * @returns `this`\n *\n * @example\n * Display only features with the 'name' property 'USA'\n * ```ts\n * map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']);\n * ```\n * @example\n * Display only features with five or more 'available-spots'\n * ```ts\n * map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]);\n * ```\n * @example\n * Remove the filter for the 'bike-docks' style layer\n * ```ts\n * map.setFilter('bike-docks', null);\n * ```\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\n setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) {\n this.style.setFilter(layerId, filter, options);\n return this._update(true);\n }\n\n /**\n * Returns the filter applied to the specified style layer.\n *\n * @param layerId - The ID of the style layer whose filter to get.\n * @returns The layer's filter.\n */\n getFilter(layerId: string): FilterSpecification | void {\n return this.style.getFilter(layerId);\n }\n\n /**\n * Sets the value of a paint property in the specified style layer.\n *\n * @param layerId - The ID of the layer to set the paint property in.\n * @param name - The name of the paint property to set.\n * @param value - The value of the paint property to set.\n * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).\n * Pass `null` to unset the existing value.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setPaintProperty('my-layer', 'fill-color', '#faafee');\n * ```\n * @see [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/)\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this {\n this.style.setPaintProperty(layerId, name, value, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of a paint property in the specified style layer.\n *\n * @param layerId - The ID of the layer to get the paint property from.\n * @param name - The name of a paint property to get.\n * @returns The value of the specified paint property.\n */\n getPaintProperty(layerId: string, name: string) {\n return this.style.getPaintProperty(layerId, name);\n }\n\n /**\n * Sets the value of a layout property in the specified style layer.\n *\n * @param layerId - The ID of the layer to set the layout property in.\n * @param name - The name of the layout property to set.\n * @param value - The value of the layout property. Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).\n * @param options - The options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setLayoutProperty('my-layer', 'visibility', 'none');\n * ```\n */\n setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this {\n this.style.setLayoutProperty(layerId, name, value, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of a layout property in the specified style layer.\n *\n * @param layerId - The ID of the layer to get the layout property from.\n * @param name - The name of the layout property to get.\n * @returns The value of the specified layout property.\n */\n getLayoutProperty(layerId: string, name: string) {\n return this.style.getLayoutProperty(layerId, name);\n }\n\n /**\n * Sets the value of the style's glyphs property.\n *\n * @param glyphsUrl - Glyph URL to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/glyphs/).\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setGlyphs('https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf');\n * ```\n */\n setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}): this {\n this._lazyInitEmptyStyle();\n this.style.setGlyphs(glyphsUrl, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of the style's glyphs URL\n *\n * @returns glyphs Style's glyphs url\n */\n getGlyphs(): string | null {\n return this.style.getGlyphsUrl();\n }\n\n /**\n * Adds a sprite to the map's style. Fires the `style` event.\n *\n * @param id - The ID of the sprite to add. Must not conflict with existing sprites.\n * @param url - The URL to load the sprite from\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.addSprite('sprite-two', 'http://example.com/sprite-two');\n * ```\n */\n addSprite(id: string, url: string, options: StyleSetterOptions = {}): this {\n this._lazyInitEmptyStyle();\n this.style.addSprite(id, url, options, (err) => {\n if (!err) {\n this._update(true);\n }\n });\n return this;\n }\n\n /**\n * Removes the sprite from the map's style. Fires the `style` event.\n *\n * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be \"default\".\n * @returns `this`\n * @example\n * ```ts\n * map.removeSprite('sprite-two');\n * map.removeSprite('default');\n * ```\n */\n removeSprite(id: string) {\n this._lazyInitEmptyStyle();\n this.style.removeSprite(id);\n return this._update(true);\n }\n\n /**\n * Returns the as-is value of the style's sprite.\n *\n * @returns style's sprite list of id-url pairs\n */\n getSprite(): {id: string; url: string}[] {\n return this.style.getSprite();\n }\n\n /**\n * Sets the value of the style's sprite property.\n *\n * @param spriteUrl - Sprite URL to set.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setSprite('YOUR_SPRITE_URL');\n * ```\n */\n setSprite(spriteUrl: string | null, options: StyleSetterOptions = {}) {\n this._lazyInitEmptyStyle();\n this.style.setSprite(spriteUrl, options, (err) => {\n if (!err) {\n this._update(true);\n }\n });\n return this;\n }\n\n /**\n * Sets the any combination of light values.\n *\n * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light).\n * @param options - Options object.\n * @returns `this`\n *\n * @example\n * ```ts\n * let layerVisibility = map.getLayoutProperty('my-layer', 'visibility');\n * ```\n */\n setLight(light: LightSpecification, options: StyleSetterOptions = {}) {\n this._lazyInitEmptyStyle();\n this.style.setLight(light, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of the light object.\n *\n * @returns light Light properties of the style.\n */\n getLight(): LightSpecification {\n return this.style.getLight();\n }\n\n /**\n * Sets the `state` of a feature.\n * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime.\n * When using this method, the `state` object is merged with any existing key-value pairs in the feature's state.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * This method can only be used with sources that have a `feature.id` attribute. The `feature.id` attribute can be defined in three ways:\n * - For vector or GeoJSON sources, including an `id` attribute in the original data file.\n * - For vector or GeoJSON sources, using the [`promoteId`](https://maplibre.org/maplibre-style-spec/sources/#vector-promoteId) option at the time the source is defined.\n * - For GeoJSON sources, using the [`generateId`](https://maplibre.org/maplibre-style-spec/sources/#geojson-generateId) option to auto-assign an `id` based on the feature's index in the source data. If you change feature data using `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values.\n *\n * _Note: You can use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) to access the values in a feature's state object for the purposes of styling._\n *\n * @param feature - Feature identifier. Feature objects returned from\n * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @param state - A set of key-value pairs. The values should be valid JSON types.\n * @returns `this`\n *\n * @example\n * ```ts\n * // When the mouse moves over the `my-layer` layer, update\n * // the feature state for the feature under the mouse\n * map.on('mousemove', 'my-layer', function(e) {\n * if (e.features.length > 0) {\n * map.setFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id,\n * }, {\n * hover: true\n * });\n * }\n * });\n * ```\n * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n */\n setFeatureState(feature: FeatureIdentifier, state: any): this {\n this.style.setFeatureState(feature, state);\n return this._update();\n }\n\n /**\n * Removes the `state` of a feature, setting it back to the default behavior.\n * If only a `target.source` is specified, it will remove the state for all features from that source.\n * If `target.id` is also specified, it will remove all keys for that feature's state.\n * If `key` is also specified, it removes only that key from that feature's state.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * @param target - Identifier of where to remove state. It can be a source, a feature, or a specific key of feature.\n * Feature objects returned from {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @param key - (optional) The key in the feature state to reset.\n * @returns `this`\n * @example\n * Reset the entire state object for all features in the `my-source` source\n * ```ts\n * map.removeFeatureState({\n * source: 'my-source'\n * });\n * ```\n *\n * @example\n * When the mouse leaves the `my-layer` layer,\n * reset the entire state object for the\n * feature under the mouse\n * ```ts\n * map.on('mouseleave', 'my-layer', function(e) {\n * map.removeFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * });\n * });\n * ```\n *\n * @example\n * When the mouse leaves the `my-layer` layer,\n * reset only the `hover` key-value pair in the\n * state for the feature under the mouse\n * ```ts\n * map.on('mouseleave', 'my-layer', function(e) {\n * map.removeFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * }, 'hover');\n * });\n * ```\n */\n removeFeatureState(target: FeatureIdentifier, key?: string): this {\n this.style.removeFeatureState(target, key);\n return this._update();\n }\n\n /**\n * Gets the `state` of a feature.\n * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * _Note: To access the values in a feature's state object for the purposes of styling the feature, use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state)._\n *\n * @param feature - Feature identifier. Feature objects returned from\n * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @returns The state of the feature: a set of key-value pairs that was assigned to the feature at runtime.\n *\n * @example\n * When the mouse moves over the `my-layer` layer,\n * get the feature state for the feature under the mouse\n * ```ts\n * map.on('mousemove', 'my-layer', function(e) {\n * if (e.features.length > 0) {\n * map.getFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * });\n * }\n * });\n * ```\n */\n getFeatureState(feature: FeatureIdentifier): any {\n return this.style.getFeatureState(feature);\n }\n\n /**\n * Returns the map's containing HTML element.\n *\n * @returns The map's container.\n */\n getContainer(): HTMLElement {\n return this._container;\n }\n\n /**\n * Returns the HTML element containing the map's `` element.\n *\n * If you want to add non-GL overlays to the map, you should append them to this element.\n *\n * This is the element to which event bindings for map interactivity (such as panning and zooming) are\n * attached. It will receive bubbled events from child elements such as the ``, but not from\n * map controls.\n *\n * @returns The container of the map's ``.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n getCanvasContainer(): HTMLElement {\n return this._canvasContainer;\n }\n\n /**\n * Returns the map's `` element.\n *\n * @returns The map's `` element.\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n getCanvas(): HTMLCanvasElement {\n return this._canvas;\n }\n\n _containerDimensions() {\n let width = 0;\n let height = 0;\n\n if (this._container) {\n width = this._container.clientWidth || 400;\n height = this._container.clientHeight || 300;\n }\n\n return [width, height];\n }\n\n _setupContainer() {\n const container = this._container;\n container.classList.add('maplibregl-map');\n\n const canvasContainer = this._canvasContainer = DOM.create('div', 'maplibregl-canvas-container', container);\n if (this._interactive) {\n canvasContainer.classList.add('maplibregl-interactive');\n }\n\n this._canvas = DOM.create('canvas', 'maplibregl-canvas', canvasContainer);\n this._canvas.addEventListener('webglcontextlost', this._contextLost, false);\n this._canvas.addEventListener('webglcontextrestored', this._contextRestored, false);\n this._canvas.setAttribute('tabindex', '0');\n this._canvas.setAttribute('aria-label', 'Map');\n this._canvas.setAttribute('role', 'region');\n\n const dimensions = this._containerDimensions();\n const clampedPixelRatio = this._getClampedPixelRatio(dimensions[0], dimensions[1]);\n this._resizeCanvas(dimensions[0], dimensions[1], clampedPixelRatio);\n\n const controlContainer = this._controlContainer = DOM.create('div', 'maplibregl-control-container', container);\n const positions = this._controlPositions = {};\n ['top-left', 'top-right', 'bottom-left', 'bottom-right'].forEach((positionName) => {\n positions[positionName] = DOM.create('div', `maplibregl-ctrl-${positionName} `, controlContainer);\n });\n\n this._container.addEventListener('scroll', this._onMapScroll, false);\n }\n\n _cooperativeGesturesOnWheel = (event: WheelEvent) => {\n this._onCooperativeGesture(event, event[this._metaKey], 1);\n };\n\n _setupCooperativeGestures() {\n const container = this._container;\n this._cooperativeGesturesScreen = DOM.create('div', 'maplibregl-cooperative-gesture-screen', container);\n let desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.windowsHelpText ? this._cooperativeGestures.windowsHelpText : 'Use Ctrl + scroll to zoom the map';\n if (navigator.platform.indexOf('Mac') === 0) {\n desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.macHelpText ? this._cooperativeGestures.macHelpText : 'Use ⌘ + scroll to zoom the map';\n }\n const mobileMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.mobileHelpText ? this._cooperativeGestures.mobileHelpText : 'Use two fingers to move the map';\n this._cooperativeGesturesScreen.innerHTML = `\n
${desktopMessage}
\n
${mobileMessage}
\n `;\n\n // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures\n this._cooperativeGesturesScreen.setAttribute('aria-hidden', 'true');\n\n // Add event to canvas container since gesture container is pointer-events: none\n this._canvasContainer.addEventListener('wheel', this._cooperativeGesturesOnWheel, false);\n\n // Add a cooperative gestures class (enable touch-action: pan-x pan-y;)\n this._canvasContainer.classList.add('maplibregl-cooperative-gestures');\n }\n\n _destroyCooperativeGestures() {\n DOM.remove(this._cooperativeGesturesScreen);\n this._canvasContainer.removeEventListener('wheel', this._cooperativeGesturesOnWheel, false);\n this._canvasContainer.classList.remove('maplibregl-cooperative-gestures');\n }\n\n _resizeCanvas(width: number, height: number, pixelRatio: number) {\n // Request the required canvas size taking the pixelratio into account.\n this._canvas.width = Math.floor(pixelRatio * width);\n this._canvas.height = Math.floor(pixelRatio * height);\n\n // Maintain the same canvas size, potentially downscaling it for HiDPI displays\n this._canvas.style.width = `${width}px`;\n this._canvas.style.height = `${height}px`;\n }\n\n _setupPainter() {\n\n const attributes = {\n alpha: true,\n stencil: true,\n depth: true,\n failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat,\n preserveDrawingBuffer: this._preserveDrawingBuffer,\n antialias: this._antialias || false\n };\n\n let webglcontextcreationerrorDetailObject: any = null;\n this._canvas.addEventListener('webglcontextcreationerror', (args: WebGLContextEvent) => {\n webglcontextcreationerrorDetailObject = {requestedAttributes: attributes};\n if (args) {\n webglcontextcreationerrorDetailObject.statusMessage = args.statusMessage;\n webglcontextcreationerrorDetailObject.type = args.type;\n }\n }, {once: true});\n\n const gl =\n this._canvas.getContext('webgl2', attributes) as WebGL2RenderingContext ||\n this._canvas.getContext('webgl', attributes) as WebGLRenderingContext;\n\n if (!gl) {\n const msg = 'Failed to initialize WebGL';\n if (webglcontextcreationerrorDetailObject) {\n webglcontextcreationerrorDetailObject.message = msg;\n throw new Error(JSON.stringify(webglcontextcreationerrorDetailObject));\n } else {\n throw new Error(msg);\n }\n }\n\n this.painter = new Painter(gl, this.transform);\n\n webpSupported.testSupport(gl);\n }\n\n _contextLost = (event: any) => {\n event.preventDefault();\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this.fire(new Event('webglcontextlost', {originalEvent: event}));\n };\n\n _contextRestored = (event: any) => {\n this._setupPainter();\n this.resize();\n this._update();\n this.fire(new Event('webglcontextrestored', {originalEvent: event}));\n };\n\n _onMapScroll = (event: any) => {\n if (event.target !== this._container) return;\n\n // Revert any scroll which would move the canvas outside of the view\n this._container.scrollTop = 0;\n this._container.scrollLeft = 0;\n return false;\n };\n\n _onCooperativeGesture(event: any, metaPress, touches) {\n if (!metaPress && touches < 2) {\n // Alert user how to scroll/pan\n this._cooperativeGesturesScreen.classList.add('maplibregl-show');\n setTimeout(() => {\n this._cooperativeGesturesScreen.classList.remove('maplibregl-show');\n }, 100);\n }\n return false;\n }\n\n /**\n * Returns a Boolean indicating whether the map is fully loaded.\n *\n * Returns `false` if the style is not yet fully loaded,\n * or if there has been a change to the sources or style that\n * has not yet fully loaded.\n *\n * @returns A Boolean indicating whether the map is fully loaded.\n */\n loaded(): boolean {\n return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded();\n }\n\n /**\n * @internal\n * Update this map's style and sources, and re-render the map.\n *\n * @param updateStyle - mark the map's style for reprocessing as\n * well as its sources\n * @returns `this`\n */\n _update(updateStyle?: boolean) {\n if (!this.style || !this.style._loaded) return this;\n\n this._styleDirty = this._styleDirty || updateStyle;\n this._sourcesDirty = true;\n this.triggerRepaint();\n\n return this;\n }\n\n /**\n * @internal\n * Request that the given callback be executed during the next render\n * frame. Schedule a render frame if one is not already scheduled.\n *\n * @returns An id that can be used to cancel the callback\n */\n _requestRenderFrame(callback: () => void): TaskID {\n this._update();\n return this._renderTaskQueue.add(callback);\n }\n\n _cancelRenderFrame(id: TaskID) {\n this._renderTaskQueue.remove(id);\n }\n\n /**\n * @internal\n * Call when a (re-)render of the map is required:\n * - The style has changed (`setPaintProperty()`, etc.)\n * - Source data has changed (e.g. tiles have finished loading)\n * - The map has is moving (or just finished moving)\n * - A transition is in progress\n *\n * @param paintStartTimeStamp - The time when the animation frame began executing.\n *\n * @returns `this`\n */\n _render(paintStartTimeStamp: number) {\n const fadeDuration = this._idleTriggered ? this._fadeDuration : 0;\n\n // A custom layer may have used the context asynchronously. Mark the state as dirty.\n this.painter.context.setDirty();\n this.painter.setBaseState();\n\n this._renderTaskQueue.run(paintStartTimeStamp);\n // A task queue callback may have fired a user event which may have removed the map\n if (this._removed) return;\n\n let crossFading = false;\n\n // If the style has changed, the map is being zoomed, or a transition or fade is in progress:\n // - Apply style changes (in a batch)\n // - Recalculate paint properties.\n if (this.style && this._styleDirty) {\n this._styleDirty = false;\n\n const zoom = this.transform.zoom;\n const now = browser.now();\n this.style.zoomHistory.update(zoom, now);\n\n const parameters = new EvaluationParameters(zoom, {\n now,\n fadeDuration,\n zoomHistory: this.style.zoomHistory,\n transition: this.style.getTransition()\n });\n\n const factor = parameters.crossFadingFactor();\n if (factor !== 1 || factor !== this._crossFadingFactor) {\n crossFading = true;\n this._crossFadingFactor = factor;\n }\n\n this.style.update(parameters);\n }\n\n // If we are in _render for any reason other than an in-progress paint\n // transition, update source caches to check for and load any tiles we\n // need for the current transform\n if (this.style && this._sourcesDirty) {\n this._sourcesDirty = false;\n this.style._updateSources(this.transform);\n }\n\n // update terrain stuff\n if (this.terrain) {\n this.terrain.sourceCache.update(this.transform, this.terrain);\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n if (!this._elevationFreeze) {\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n }\n } else {\n this.transform._minEleveationForCurrentTile = 0;\n this.transform.elevation = 0;\n }\n\n this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions);\n\n // Actually draw\n this.painter.render(this.style, {\n showTileBoundaries: this.showTileBoundaries,\n showOverdrawInspector: this._showOverdrawInspector,\n rotating: this.isRotating(),\n zooming: this.isZooming(),\n moving: this.isMoving(),\n fadeDuration,\n showPadding: this.showPadding,\n });\n\n this.fire(new Event('render'));\n\n if (this.loaded() && !this._loaded) {\n this._loaded = true;\n PerformanceUtils.mark(PerformanceMarkers.load);\n this.fire(new Event('load'));\n }\n\n if (this.style && (this.style.hasTransitions() || crossFading)) {\n this._styleDirty = true;\n }\n\n if (this.style && !this._placementDirty) {\n // Since no fade operations are in progress, we can release\n // all tiles held for fading. If we didn't do this, the tiles\n // would just sit in the SourceCaches until the next render\n this.style._releaseSymbolFadeTiles();\n }\n\n // Schedule another render frame if it's needed.\n //\n // Even though `_styleDirty` and `_sourcesDirty` are reset in this\n // method, synchronous events fired during Style#update or\n // Style#_updateSources could have caused them to be set again.\n const somethingDirty = this._sourcesDirty || this._styleDirty || this._placementDirty;\n if (somethingDirty || this._repaint) {\n this.triggerRepaint();\n } else if (!this.isMoving() && this.loaded()) {\n this.fire(new Event('idle'));\n }\n\n if (this._loaded && !this._fullyLoaded && !somethingDirty) {\n this._fullyLoaded = true;\n PerformanceUtils.mark(PerformanceMarkers.fullLoad);\n }\n\n return this;\n }\n\n /**\n * Force a synchronous redraw of the map.\n * @returns `this`\n * @example\n * ```ts\n * map.redraw();\n * ```\n */\n redraw(): this {\n if (this.style) {\n // cancel the scheduled update\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this._render(0);\n }\n return this;\n }\n\n /**\n * Clean up and release all internal resources associated with this map.\n *\n * This includes DOM elements, event bindings, web workers, and WebGL resources.\n *\n * Use this method when you are done using the map and wish to ensure that it no\n * longer consumes browser resources. Afterwards, you must not call any other\n * methods on the map.\n */\n remove() {\n if (this._hash) this._hash.remove();\n\n for (const control of this._controls) control.onRemove(this);\n this._controls = [];\n\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this._renderTaskQueue.clear();\n this.painter.destroy();\n this.handlers.destroy();\n delete this.handlers;\n this.setStyle(null);\n if (typeof window !== 'undefined') {\n removeEventListener('online', this._onWindowOnline, false);\n }\n\n ImageRequest.removeThrottleControl(this._imageQueueHandle);\n\n this._resizeObserver?.disconnect();\n const extension = this.painter.context.gl.getExtension('WEBGL_lose_context');\n if (extension) extension.loseContext();\n this._canvas.removeEventListener('webglcontextrestored', this._contextRestored, false);\n this._canvas.removeEventListener('webglcontextlost', this._contextLost, false);\n DOM.remove(this._canvasContainer);\n DOM.remove(this._controlContainer);\n if (this._cooperativeGestures) {\n this._destroyCooperativeGestures();\n }\n this._container.classList.remove('maplibregl-map');\n\n PerformanceUtils.clearMetrics();\n\n this._removed = true;\n this.fire(new Event('remove'));\n }\n\n /**\n * Trigger the rendering of a single frame. Use this method with custom layers to\n * repaint the map when the layer changes. Calling this multiple times before the\n * next frame is rendered will still result in only a single frame being rendered.\n * @example\n * ```ts\n * map.triggerRepaint();\n * ```\n * @see [Add a 3D model](https://maplibre.org/maplibre-gl-js/docs/examples/add-3d-model/)\n * @see [Add an animated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/)\n */\n triggerRepaint() {\n if (this.style && !this._frame) {\n this._frame = browser.frame((paintStartTimeStamp: number) => {\n PerformanceUtils.frame(paintStartTimeStamp);\n this._frame = null;\n this._render(paintStartTimeStamp);\n });\n }\n }\n\n _onWindowOnline = () => {\n this._update();\n };\n\n /**\n * Gets and sets a Boolean indicating whether the map will render an outline\n * around each tile and the tile ID. These tile boundaries are useful for\n * debugging.\n *\n * The uncompressed file size of the first vector source is drawn in the top left\n * corner of each tile, next to the tile ID.\n *\n * @example\n * ```ts\n * map.showTileBoundaries = true;\n * ```\n */\n get showTileBoundaries(): boolean { return !!this._showTileBoundaries; }\n set showTileBoundaries(value: boolean) {\n if (this._showTileBoundaries === value) return;\n this._showTileBoundaries = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will visualize\n * the padding offsets.\n */\n get showPadding(): boolean { return !!this._showPadding; }\n set showPadding(value: boolean) {\n if (this._showPadding === value) return;\n this._showPadding = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will render boxes\n * around all symbols in the data source, revealing which symbols\n * were rendered or which were hidden due to collisions.\n * This information is useful for debugging.\n */\n get showCollisionBoxes(): boolean { return !!this._showCollisionBoxes; }\n set showCollisionBoxes(value: boolean) {\n if (this._showCollisionBoxes === value) return;\n this._showCollisionBoxes = value;\n if (value) {\n // When we turn collision boxes on we have to generate them for existing tiles\n // When we turn them off, there's no cost to leaving existing boxes in place\n this.style._generateCollisionBoxes();\n } else {\n // Otherwise, call an update to remove collision boxes\n this._update();\n }\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map should color-code\n * each fragment to show how many times it has been shaded.\n * White fragments have been shaded 8 or more times.\n * Black fragments have been shaded 0 times.\n * This information is useful for debugging.\n */\n get showOverdrawInspector(): boolean { return !!this._showOverdrawInspector; }\n set showOverdrawInspector(value: boolean) {\n if (this._showOverdrawInspector === value) return;\n this._showOverdrawInspector = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will\n * continuously repaint. This information is useful for analyzing performance.\n */\n get repaint(): boolean { return !!this._repaint; }\n set repaint(value: boolean) {\n if (this._repaint !== value) {\n this._repaint = value;\n this.triggerRepaint();\n }\n }\n // show vertices\n get vertices(): boolean { return !!this._vertices; }\n set vertices(value: boolean) { this._vertices = value; this._update(); }\n\n /**\n * Returns the package version of the library\n * @returns Package version of the library\n */\n get version(): string {\n return version;\n }\n\n /**\n * Returns the elevation for the point where the camera is looking.\n * This value corresponds to:\n * \"meters above sea level\" * \"exaggeration\"\n * @returns The elevation.\n */\n getCameraTargetElevation(): number {\n return this.transform.elevation;\n }\n}\n","import type Point from '@mapbox/point-geometry';\n\nimport {DragMoveHandler, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';\nimport {OneFingerTouchMoveStateManager} from './drag_move_state_manager';\n\nexport interface OneFingerTouchRotateHandler extends DragMoveHandler {}\nexport interface OneFingerTouchPitchHandler extends DragMoveHandler {}\n\nconst assignEvents = (handler: DragHandler) => {\n handler.touchstart = handler.dragStart;\n handler.touchmoveWindow = handler.dragMove;\n handler.touchend = handler.dragEnd;\n};\n\nexport const generateOneFingerTouchRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: {\n clickTolerance: number;\n bearingDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): OneFingerTouchRotateHandler => {\n const touchMoveStateManager = new OneFingerTouchMoveStateManager();\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}),\n moveStateManager: touchMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateOneFingerTouchPitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: {\n clickTolerance: number;\n pitchDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): OneFingerTouchPitchHandler => {\n const touchMoveStateManager = new OneFingerTouchMoveStateManager();\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}),\n moveStateManager: touchMoveStateManager,\n enable,\n assignEvents,\n });\n};\n","import Point from '@mapbox/point-geometry';\n\nimport {DOM} from '../../util/dom';\nimport {extend} from '../../util/util';\nimport {generateMousePitchHandler, generateMouseRotationHandler, MousePitchHandler, MouseRotateHandler} from '../handler/mouse';\nimport {generateOneFingerTouchPitchHandler, generateOneFingerTouchRotationHandler, OneFingerTouchPitchHandler, OneFingerTouchRotateHandler} from '../handler/one_finger_touch_drag';\n\nimport type {Map} from '../map';\nimport type {IControl} from './control';\n\n/**\n * The {@link NavigationControl} options object\n */\ntype NavigationOptions = {\n /**\n * If `true` the compass button is included.\n */\n showCompass?: boolean;\n /**\n * If `true` the zoom-in and zoom-out buttons are included.\n */\n showZoom?: boolean;\n /**\n * If `true` the pitch is visualized by rotating X-axis of compass.\n */\n visualizePitch?: boolean;\n};\n\nconst defaultOptions: NavigationOptions = {\n showCompass: true,\n showZoom: true,\n visualizePitch: false\n};\n\n/**\n * A `NavigationControl` control contains zoom buttons and a compass.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let nav = new maplibregl.NavigationControl();\n * map.addControl(nav, 'top-left');\n * ```\n * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)\n */\nexport class NavigationControl implements IControl {\n _map: Map;\n options: NavigationOptions;\n _container: HTMLElement;\n _zoomInButton: HTMLButtonElement;\n _zoomOutButton: HTMLButtonElement;\n _compass: HTMLButtonElement;\n _compassIcon: HTMLElement;\n _handler: MouseRotateWrapper;\n\n /**\n * @param options - the control's options\n */\n constructor(options?: NavigationOptions) {\n this.options = extend({}, defaultOptions, options);\n\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._container.addEventListener('contextmenu', (e) => e.preventDefault());\n\n if (this.options.showZoom) {\n this._zoomInButton = this._createButton('maplibregl-ctrl-zoom-in', (e) => this._map.zoomIn({}, {originalEvent: e}));\n DOM.create('span', 'maplibregl-ctrl-icon', this._zoomInButton).setAttribute('aria-hidden', 'true');\n this._zoomOutButton = this._createButton('maplibregl-ctrl-zoom-out', (e) => this._map.zoomOut({}, {originalEvent: e}));\n DOM.create('span', 'maplibregl-ctrl-icon', this._zoomOutButton).setAttribute('aria-hidden', 'true');\n }\n if (this.options.showCompass) {\n this._compass = this._createButton('maplibregl-ctrl-compass', (e) => {\n if (this.options.visualizePitch) {\n this._map.resetNorthPitch({}, {originalEvent: e});\n } else {\n this._map.resetNorth({}, {originalEvent: e});\n }\n });\n this._compassIcon = DOM.create('span', 'maplibregl-ctrl-icon', this._compass);\n this._compassIcon.setAttribute('aria-hidden', 'true');\n }\n }\n\n _updateZoomButtons = () => {\n const zoom = this._map.getZoom();\n const isMax = zoom === this._map.getMaxZoom();\n const isMin = zoom === this._map.getMinZoom();\n this._zoomInButton.disabled = isMax;\n this._zoomOutButton.disabled = isMin;\n this._zoomInButton.setAttribute('aria-disabled', isMax.toString());\n this._zoomOutButton.setAttribute('aria-disabled', isMin.toString());\n };\n\n _rotateCompassArrow = () => {\n const rotate = this.options.visualizePitch ?\n `scale(${1 / Math.pow(Math.cos(this._map.transform.pitch * (Math.PI / 180)), 0.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle * (180 / Math.PI)}deg)` :\n `rotate(${this._map.transform.angle * (180 / Math.PI)}deg)`;\n\n this._compassIcon.style.transform = rotate;\n };\n\n onAdd(map: Map) {\n this._map = map;\n if (this.options.showZoom) {\n this._setButtonTitle(this._zoomInButton, 'ZoomIn');\n this._setButtonTitle(this._zoomOutButton, 'ZoomOut');\n this._map.on('zoom', this._updateZoomButtons);\n this._updateZoomButtons();\n }\n if (this.options.showCompass) {\n this._setButtonTitle(this._compass, 'ResetBearing');\n if (this.options.visualizePitch) {\n this._map.on('pitch', this._rotateCompassArrow);\n }\n this._map.on('rotate', this._rotateCompassArrow);\n this._rotateCompassArrow();\n this._handler = new MouseRotateWrapper(this._map, this._compass, this.options.visualizePitch);\n }\n return this._container;\n }\n\n onRemove() {\n DOM.remove(this._container);\n if (this.options.showZoom) {\n this._map.off('zoom', this._updateZoomButtons);\n }\n if (this.options.showCompass) {\n if (this.options.visualizePitch) {\n this._map.off('pitch', this._rotateCompassArrow);\n }\n this._map.off('rotate', this._rotateCompassArrow);\n this._handler.off();\n delete this._handler;\n }\n\n delete this._map;\n }\n\n _createButton(className: string, fn: (e?: any) => unknown) {\n const a = DOM.create('button', className, this._container) as HTMLButtonElement;\n a.type = 'button';\n a.addEventListener('click', fn);\n return a;\n }\n\n _setButtonTitle = (button: HTMLButtonElement, title: string) => {\n const str = this._map._getUIString(`NavigationControl.${title}`);\n button.title = str;\n button.setAttribute('aria-label', str);\n };\n}\n\nclass MouseRotateWrapper {\n\n map: Map;\n _clickTolerance: number;\n element: HTMLElement;\n // Rotation and pitch handlers are separated due to different _clickTolerance values\n mouseRotate: MouseRotateHandler;\n touchRotate: OneFingerTouchRotateHandler;\n mousePitch: MousePitchHandler;\n touchPitch: OneFingerTouchPitchHandler;\n _startPos: Point;\n _lastPos: Point;\n\n constructor(map: Map, element: HTMLElement, pitch: boolean = false) {\n this._clickTolerance = 10;\n const mapRotateTolerance = map.dragRotate._mouseRotate.getClickTolerance();\n const mapPitchTolerance = map.dragRotate._mousePitch.getClickTolerance();\n this.element = element;\n this.mouseRotate = generateMouseRotationHandler({clickTolerance: mapRotateTolerance, enable: true});\n this.touchRotate = generateOneFingerTouchRotationHandler({clickTolerance: mapRotateTolerance, enable: true});\n this.map = map;\n if (pitch) {\n this.mousePitch = generateMousePitchHandler({clickTolerance: mapPitchTolerance, enable: true});\n this.touchPitch = generateOneFingerTouchPitchHandler({clickTolerance: mapPitchTolerance, enable: true});\n }\n\n DOM.addEventListener(element, 'mousedown', this.mousedown);\n DOM.addEventListener(element, 'touchstart', this.touchstart, {passive: false});\n DOM.addEventListener(element, 'touchcancel', this.reset);\n }\n\n startMouse(e: MouseEvent, point: Point) {\n this.mouseRotate.dragStart(e, point);\n if (this.mousePitch) this.mousePitch.dragStart(e, point);\n DOM.disableDrag();\n }\n\n startTouch(e: TouchEvent, point: Point) {\n this.touchRotate.dragStart(e, point);\n if (this.touchPitch) this.touchPitch.dragStart(e, point);\n DOM.disableDrag();\n }\n\n moveMouse(e: MouseEvent, point: Point) {\n const map = this.map;\n const {bearingDelta} = this.mouseRotate.dragMove(e, point) || {};\n if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta);\n if (this.mousePitch) {\n const {pitchDelta} = this.mousePitch.dragMove(e, point) || {};\n if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta);\n }\n }\n\n moveTouch(e: TouchEvent, point: Point) {\n const map = this.map;\n const {bearingDelta} = this.touchRotate.dragMove(e, point) || {};\n if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta);\n if (this.touchPitch) {\n const {pitchDelta} = this.touchPitch.dragMove(e, point) || {};\n if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta);\n }\n }\n\n off() {\n const element = this.element;\n DOM.removeEventListener(element, 'mousedown', this.mousedown);\n DOM.removeEventListener(element, 'touchstart', this.touchstart, {passive: false});\n DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.removeEventListener(window, 'touchend', this.touchend);\n DOM.removeEventListener(element, 'touchcancel', this.reset);\n this.offTemp();\n }\n\n offTemp() {\n DOM.enableDrag();\n DOM.removeEventListener(window, 'mousemove', this.mousemove);\n DOM.removeEventListener(window, 'mouseup', this.mouseup);\n DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.removeEventListener(window, 'touchend', this.touchend);\n }\n\n mousedown = (e: MouseEvent) => {\n this.startMouse(extend({}, e, {ctrlKey: true, preventDefault: () => e.preventDefault()}), DOM.mousePos(this.element, e));\n DOM.addEventListener(window, 'mousemove', this.mousemove);\n DOM.addEventListener(window, 'mouseup', this.mouseup);\n };\n\n mousemove = (e: MouseEvent) => {\n this.moveMouse(e, DOM.mousePos(this.element, e));\n };\n\n mouseup = (e: MouseEvent) => {\n this.mouseRotate.dragEnd(e);\n if (this.mousePitch) this.mousePitch.dragEnd(e);\n this.offTemp();\n };\n\n touchstart = (e: TouchEvent) => {\n if (e.targetTouches.length !== 1) {\n this.reset();\n } else {\n this._startPos = this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0];\n this.startTouch(e, this._startPos);\n DOM.addEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.addEventListener(window, 'touchend', this.touchend);\n }\n };\n\n touchmove = (e: TouchEvent) => {\n if (e.targetTouches.length !== 1) {\n this.reset();\n } else {\n this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0];\n this.moveTouch(e, this._lastPos);\n }\n };\n\n touchend = (e: TouchEvent) => {\n if (e.targetTouches.length === 0 &&\n this._startPos &&\n this._lastPos &&\n this._startPos.dist(this._lastPos) < this._clickTolerance) {\n this.element.click();\n }\n delete this._startPos;\n delete this._lastPos;\n this.offTemp();\n };\n\n reset = () => {\n this.mouseRotate.reset();\n if (this.mousePitch) this.mousePitch.reset();\n this.touchRotate.reset();\n if (this.touchPitch) this.touchPitch.reset();\n delete this._startPos;\n delete this._lastPos;\n this.offTemp();\n };\n}\n","let supportsGeolocation;\n\nexport function checkGeolocationSupport(callback: (supported: boolean) => void, forceRecalculation = false): void {\n if (supportsGeolocation !== undefined && !forceRecalculation) {\n callback(supportsGeolocation);\n } else if (window.navigator.permissions !== undefined) {\n // navigator.permissions has incomplete browser support\n // http://caniuse.com/#feat=permissions-api\n // Test for the case where a browser disables Geolocation because of an\n // insecure origin\n window.navigator.permissions.query({name: 'geolocation'}).then((p) => {\n supportsGeolocation = p.state !== 'denied';\n callback(supportsGeolocation);\n }).catch(() => {\n // Fix for iOS16 which rejects query but still supports geolocation\n supportsGeolocation = !!window.navigator.geolocation;\n callback(supportsGeolocation);\n });\n\n } else {\n supportsGeolocation = !!window.navigator.geolocation;\n callback(supportsGeolocation);\n }\n}\n","import {LngLat} from '../geo/lng_lat';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {Transform} from '../geo/transform';\n\n/**\n * Given a LngLat, prior projected position, and a transform, return a new LngLat shifted\n * n × 360° east or west for some n ≥ 0 such that:\n *\n * * the projected location of the result is on screen, if possible, and secondarily:\n * * the difference between the projected location of the result and the prior position\n * is minimized.\n *\n * The object is to preserve perceived object constancy for Popups and Markers as much as\n * possible; they should avoid shifting large distances across the screen, even when the\n * map center changes by ±360° due to automatic wrapping, and when about to go off screen,\n * should wrap just enough to avoid doing so.\n */\nexport function smartWrap(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {\n lngLat = new LngLat(lngLat.lng, lngLat.lat);\n\n // First, try shifting one world in either direction, and see if either is closer to the\n // prior position. This preserves object constancy when the map center is auto-wrapped\n // during animations.\n if (priorPos) {\n const left = new LngLat(lngLat.lng - 360, lngLat.lat);\n const right = new LngLat(lngLat.lng + 360, lngLat.lat);\n const delta = transform.locationPoint(lngLat).distSqr(priorPos);\n if (transform.locationPoint(left).distSqr(priorPos) < delta) {\n lngLat = left;\n } else if (transform.locationPoint(right).distSqr(priorPos) < delta) {\n lngLat = right;\n }\n }\n\n // Second, wrap toward the center until the new position is on screen, or we can't get\n // any closer.\n while (Math.abs(lngLat.lng - transform.center.lng) > 180) {\n const pos = transform.locationPoint(lngLat);\n if (pos.x >= 0 && pos.y >= 0 && pos.x <= transform.width && pos.y <= transform.height) {\n break;\n }\n if (lngLat.lng > transform.center.lng) {\n lngLat.lng -= 360;\n } else {\n lngLat.lng += 360;\n }\n }\n\n return lngLat;\n}\n","/**\n * Where to position the anchor.\n * Used by a popup and a marker.\n */\nexport type PositionAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport const anchorTranslate: {\n [_ in PositionAnchor]: string;\n} = {\n 'center': 'translate(-50%,-50%)',\n 'top': 'translate(-50%,0)',\n 'top-left': 'translate(0,0)',\n 'top-right': 'translate(-100%,0)',\n 'bottom': 'translate(-50%,-100%)',\n 'bottom-left': 'translate(0,-100%)',\n 'bottom-right': 'translate(-100%,-100%)',\n 'left': 'translate(0,-50%)',\n 'right': 'translate(-100%,-50%)'\n};\n\nexport function applyAnchorClass(element: HTMLElement, anchor: PositionAnchor, prefix: string) {\n const classList = element.classList;\n for (const key in anchorTranslate) {\n classList.remove(`maplibregl-${prefix}-anchor-${key}`);\n }\n classList.add(`maplibregl-${prefix}-anchor-${anchor}`);\n}\n","import {DOM} from '../util/dom';\nimport {LngLat} from '../geo/lng_lat';\nimport Point from '@mapbox/point-geometry';\nimport {smartWrap} from '../util/smart_wrap';\nimport {anchorTranslate, applyAnchorClass} from './anchor';\nimport type {PositionAnchor} from './anchor';\nimport {Event, Evented} from '../util/evented';\nimport type {Map} from './map';\nimport {Popup, Offset} from './popup';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {MapMouseEvent, MapTouchEvent} from './events';\nimport type {PointLike} from './camera';\n\n/**\n * Alignment options of rotation and pitch\n */\ntype Alignment = 'map' | 'viewport' | 'auto';\n\n/**\n * The {@link Marker} options object\n */\ntype MarkerOptions = {\n /**\n * DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker.\n */\n element?: HTMLElement;\n /**\n * Space-separated CSS class names to add to marker element.\n */\n className?: string;\n /**\n * The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.\n */\n offset?: PointLike;\n /**\n * A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}.\n * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.\n * @defaultValue 'center'\n * */\n anchor?: PositionAnchor;\n /**\n * The color to use for the default marker if options.element is not provided. The default is light blue.\n * @defaultValue '#3FB1CE'\n */\n color?: string;\n /**\n * The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`.\n * @defaultValue 1\n */\n scale?: number;\n /**\n * A boolean indicating whether or not a marker is able to be dragged to a new position on the map.\n * @defaultValue false\n */\n draggable?: boolean;\n /**\n * The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance.\n * @defaultValue 0\n */\n clickTolerance?: number;\n /**\n * The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.\n * @defaultValue 0\n */\n rotation?: number;\n /**\n * `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`.\n * @defaultValue 'auto'\n */\n rotationAlignment?: Alignment;\n /**\n * `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`.\n * @defaultValue 'auto'\n */\n pitchAlignment?: Alignment;\n};\n\n/**\n * Creates a marker component\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([30.5, 50.5])\n * .addTo(map);\n * ```\n *\n * @example\n * Set options\n * ```ts\n * let marker = new maplibregl.Marker({\n * color: \"#FFFFFF\",\n * draggable: true\n * }).setLngLat([30.5, 50.5])\n * .addTo(map);\n * ```\n * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n *\n * ### Events\n *\n * @event `dragstart` Fired when dragging starts, `marker` object that is being dragged\n *\n * @event `drag` Fired while dragging. `marker` object that is being dragged\n *\n * @event `dragend` Fired when the marker is finished being dragged, `marker` object that was dragged\n */\nexport class Marker extends Evented {\n _map: Map;\n _anchor: PositionAnchor;\n _offset: Point;\n _element: HTMLElement;\n _popup: Popup;\n _lngLat: LngLat;\n _pos: Point;\n _color: string;\n _scale: number;\n _defaultMarker: boolean;\n _draggable: boolean;\n _clickTolerance: number;\n _isDragging: boolean;\n _state: 'inactive' | 'pending' | 'active'; // used for handling drag events\n _positionDelta: Point;\n _pointerdownPos: Point;\n _rotation: number;\n _pitchAlignment: Alignment;\n _rotationAlignment: Alignment;\n _originalTabIndex: string; // original tabindex of _element\n _opacityTimeout: ReturnType;\n\n /**\n * @param options - the options\n */\n constructor(options?: MarkerOptions) {\n super();\n\n this._anchor = options && options.anchor || 'center';\n this._color = options && options.color || '#3FB1CE';\n this._scale = options && options.scale || 1;\n this._draggable = options && options.draggable || false;\n this._clickTolerance = options && options.clickTolerance || 0;\n this._isDragging = false;\n this._state = 'inactive';\n this._rotation = options && options.rotation || 0;\n this._rotationAlignment = options && options.rotationAlignment || 'auto';\n this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment;\n\n if (!options || !options.element) {\n this._defaultMarker = true;\n this._element = DOM.create('div');\n this._element.setAttribute('aria-label', 'Map marker');\n\n // create default map marker SVG\n const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg');\n const defaultHeight = 41;\n const defaultWidth = 27;\n svg.setAttributeNS(null, 'display', 'block');\n svg.setAttributeNS(null, 'height', `${defaultHeight}px`);\n svg.setAttributeNS(null, 'width', `${defaultWidth}px`);\n svg.setAttributeNS(null, 'viewBox', `0 0 ${defaultWidth} ${defaultHeight}`);\n\n const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n markerLarge.setAttributeNS(null, 'stroke', 'none');\n markerLarge.setAttributeNS(null, 'stroke-width', '1');\n markerLarge.setAttributeNS(null, 'fill', 'none');\n markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd');\n\n const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n page1.setAttributeNS(null, 'fill-rule', 'nonzero');\n\n const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)');\n shadow.setAttributeNS(null, 'fill', '#000000');\n\n const ellipses = [\n {'rx': '10.5', 'ry': '5.25002273'},\n {'rx': '10.5', 'ry': '5.25002273'},\n {'rx': '9.5', 'ry': '4.77275007'},\n {'rx': '8.5', 'ry': '4.29549936'},\n {'rx': '7.5', 'ry': '3.81822308'},\n {'rx': '6.5', 'ry': '3.34094679'},\n {'rx': '5.5', 'ry': '2.86367051'},\n {'rx': '4.5', 'ry': '2.38636864'}\n ];\n\n for (const data of ellipses) {\n const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse');\n ellipse.setAttributeNS(null, 'opacity', '0.04');\n ellipse.setAttributeNS(null, 'cx', '10.5');\n ellipse.setAttributeNS(null, 'cy', '5.80029008');\n ellipse.setAttributeNS(null, 'rx', data['rx']);\n ellipse.setAttributeNS(null, 'ry', data['ry']);\n shadow.appendChild(ellipse);\n }\n\n const background = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n background.setAttributeNS(null, 'fill', this._color);\n\n const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');\n bgPath.setAttributeNS(null, 'd', 'M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z');\n\n background.appendChild(bgPath);\n\n const border = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n border.setAttributeNS(null, 'opacity', '0.25');\n border.setAttributeNS(null, 'fill', '#000000');\n\n const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');\n borderPath.setAttributeNS(null, 'd', 'M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z');\n\n border.appendChild(borderPath);\n\n const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)');\n maki.setAttributeNS(null, 'fill', '#FFFFFF');\n\n const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)');\n\n const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');\n circle1.setAttributeNS(null, 'fill', '#000000');\n circle1.setAttributeNS(null, 'opacity', '0.25');\n circle1.setAttributeNS(null, 'cx', '5.5');\n circle1.setAttributeNS(null, 'cy', '5.5');\n circle1.setAttributeNS(null, 'r', '5.4999962');\n\n const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');\n circle2.setAttributeNS(null, 'fill', '#FFFFFF');\n circle2.setAttributeNS(null, 'cx', '5.5');\n circle2.setAttributeNS(null, 'cy', '5.5');\n circle2.setAttributeNS(null, 'r', '5.4999962');\n\n circleContainer.appendChild(circle1);\n circleContainer.appendChild(circle2);\n\n page1.appendChild(shadow);\n page1.appendChild(background);\n page1.appendChild(border);\n page1.appendChild(maki);\n page1.appendChild(circleContainer);\n\n svg.appendChild(page1);\n\n svg.setAttributeNS(null, 'height', `${defaultHeight * this._scale}px`);\n svg.setAttributeNS(null, 'width', `${defaultWidth * this._scale}px`);\n\n this._element.appendChild(svg);\n\n // if no element and no offset option given apply an offset for the default marker\n // the -14 as the y value of the default marker offset was determined as follows\n //\n // the marker tip is at the center of the shadow ellipse from the default svg\n // the y value of the center of the shadow ellipse relative to the svg top left is \"shadow transform translate-y (29.0) + ellipse cy (5.80029008)\"\n // offset to the svg center \"height (41 / 2)\" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14\n // negative is used to move the marker up from the center so the tip is at the Marker lngLat\n this._offset = Point.convert(options && options.offset || [0, -14]);\n } else {\n this._element = options.element;\n this._offset = Point.convert(options && options.offset || [0, 0]);\n }\n\n this._element.classList.add('maplibregl-marker');\n this._element.addEventListener('dragstart', (e: DragEvent) => {\n e.preventDefault();\n });\n this._element.addEventListener('mousedown', (e: MouseEvent) => {\n // prevent focusing on click\n e.preventDefault();\n });\n applyAnchorClass(this._element, this._anchor, 'marker');\n\n if (options && options.className) {\n for (const name of options.className.split(' ')) {\n this._element.classList.add(name);\n }\n }\n\n this._popup = null;\n }\n\n /**\n * Attaches the `Marker` to a `Map` object.\n * @param map - The MapLibre GL JS map to add the marker to.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([30.5, 50.5])\n * .addTo(map); // add the marker to the map\n * ```\n */\n addTo(map: Map): this {\n this.remove();\n this._map = map;\n map.getCanvasContainer().appendChild(this._element);\n map.on('move', this._update);\n map.on('moveend', this._update);\n map.on('terrain', this._update);\n\n this.setDraggable(this._draggable);\n this._update();\n\n // If we attached the `click` listener to the marker element, the popup\n // would close once the event propagated to `map` due to the\n // `Popup#_onClickClose` listener.\n this._map.on('click', this._onMapClick);\n\n return this;\n }\n\n /**\n * Removes the marker from a map\n * @example\n * ```ts\n * let marker = new maplibregl.Marker().addTo(map);\n * marker.remove();\n * ```\n * @returns `this`\n */\n remove(): this {\n if (this._opacityTimeout) {\n clearTimeout(this._opacityTimeout);\n delete this._opacityTimeout;\n }\n if (this._map) {\n this._map.off('click', this._onMapClick);\n this._map.off('move', this._update);\n this._map.off('moveend', this._update);\n this._map.off('mousedown', this._addDragHandler);\n this._map.off('touchstart', this._addDragHandler);\n this._map.off('mouseup', this._onUp);\n this._map.off('touchend', this._onUp);\n this._map.off('mousemove', this._onMove);\n this._map.off('touchmove', this._onMove);\n delete this._map;\n }\n DOM.remove(this._element);\n if (this._popup) this._popup.remove();\n return this;\n }\n\n /**\n * Get the marker's geographical location.\n *\n * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously\n * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep\n * the marker on screen.\n *\n * @returns A {@link LngLat} describing the marker's location.\n * @example\n * ```ts\n * // Store the marker's longitude and latitude coordinates in a variable\n * let lngLat = marker.getLngLat();\n * // Print the marker's longitude and latitude values in the console\n * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat )\n * ```\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n /**\n * Set the marker's geographical position and move it.\n * @param lnglat - A {@link LngLat} describing where the marker should be located.\n * @returns `this`\n * @example\n * Create a new marker, set the longitude and latitude, and add it to the map\n * ```ts\n * new maplibregl.Marker()\n * .setLngLat([-65.017, -16.457])\n * .addTo(map);\n * ```\n * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n setLngLat(lnglat: LngLatLike): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n if (this._popup) this._popup.setLngLat(this._lngLat);\n this._update();\n return this;\n }\n\n /**\n * Returns the `Marker`'s HTML element.\n * @returns element\n */\n getElement(): HTMLElement {\n return this._element;\n }\n\n /**\n * Binds a {@link Popup} to the {@link Marker}.\n * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup\n * set on this {@link Marker} instance is unset.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\")) // add popup\n * .addTo(map);\n * ```\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n */\n setPopup(popup?: Popup | null): this {\n if (this._popup) {\n this._popup.remove();\n this._popup = null;\n this._element.removeEventListener('keypress', this._onKeyPress);\n\n if (!this._originalTabIndex) {\n this._element.removeAttribute('tabindex');\n }\n }\n\n if (popup) {\n if (!('offset' in popup.options)) {\n const markerHeight = 41 - (5.8 / 2);\n const markerRadius = 13.5;\n const linearOffset = Math.abs(markerRadius) / Math.SQRT2;\n popup.options.offset = this._defaultMarker ? {\n 'top': [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n 'bottom': [0, -markerHeight],\n 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n 'left': [markerRadius, (markerHeight - markerRadius) * -1],\n 'right': [-markerRadius, (markerHeight - markerRadius) * -1]\n } as Offset : this._offset;\n }\n this._popup = popup;\n if (this._lngLat) this._popup.setLngLat(this._lngLat);\n\n this._originalTabIndex = this._element.getAttribute('tabindex');\n if (!this._originalTabIndex) {\n this._element.setAttribute('tabindex', '0');\n }\n this._element.addEventListener('keypress', this._onKeyPress);\n }\n\n return this;\n }\n\n _onKeyPress = (e: KeyboardEvent) => {\n const code = e.code;\n const legacyCode = e.charCode || e.keyCode;\n\n if (\n (code === 'Space') || (code === 'Enter') ||\n (legacyCode === 32) || (legacyCode === 13) // space or enter\n ) {\n this.togglePopup();\n }\n };\n\n _onMapClick = (e: MapMouseEvent) => {\n const targetElement = e.originalEvent.target;\n const element = this._element;\n\n if (this._popup && (targetElement === element || element.contains(targetElement as any))) {\n this.togglePopup();\n }\n };\n\n /**\n * Returns the {@link Popup} instance that is bound to the {@link Marker}.\n * @returns popup\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\"))\n * .addTo(map);\n *\n * console.log(marker.getPopup()); // return the popup instance\n * ```\n */\n getPopup(): Popup {\n return this._popup;\n }\n\n /**\n * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\"))\n * .addTo(map);\n *\n * marker.togglePopup(); // toggle popup open or closed\n * ```\n */\n togglePopup(): this {\n const popup = this._popup;\n\n if (!popup) return this;\n else if (popup.isOpen()) popup.remove();\n else popup.addTo(this._map);\n return this;\n }\n\n _update = (e?: { type: 'move' | 'moveend' | 'terrain' | 'render' }) => {\n if (!this._map) return;\n\n const isFullyLoaded = this._map.loaded() && !this._map.isMoving();\n if (e?.type === 'terrain' || (e?.type === 'render' && !isFullyLoaded)) {\n this._map.once('render', this._update);\n }\n\n if (this._map.transform.renderWorldCopies) {\n this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);\n }\n\n this._pos = this._map.project(this._lngLat)._add(this._offset);\n\n let rotation = '';\n if (this._rotationAlignment === 'viewport' || this._rotationAlignment === 'auto') {\n rotation = `rotateZ(${this._rotation}deg)`;\n } else if (this._rotationAlignment === 'map') {\n rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`;\n }\n\n let pitch = '';\n if (this._pitchAlignment === 'viewport' || this._pitchAlignment === 'auto') {\n pitch = 'rotateX(0deg)';\n } else if (this._pitchAlignment === 'map') {\n pitch = `rotateX(${this._map.getPitch()}deg)`;\n }\n\n // because rounding the coordinates at every `move` event causes stuttered zooming\n // we only round them when _update is called with `moveend` or when its called with\n // no arguments (when the Marker is initialized or Marker#setLngLat is invoked).\n if (!e || e.type === 'moveend') {\n this._pos = this._pos.round();\n }\n\n DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`);\n\n // in case of 3D, ask the terrain coords-framebuffer for this pos and check if the marker is visible\n // call this logic in setTimeout with a timeout of 100ms to save performance in map-movement\n if (this._map.terrain && !this._opacityTimeout) this._opacityTimeout = setTimeout(() => {\n const lnglat = this._map.unproject(this._pos);\n const metresPerPixel = 40075016.686 * Math.abs(Math.cos(this._lngLat.lat * Math.PI / 180)) / Math.pow(2, this._map.transform.tileZoom + 8);\n this._element.style.opacity = lnglat.distanceTo(this._lngLat) > metresPerPixel * 20 ? '0.2' : '1.0';\n this._opacityTimeout = null;\n }, 100);\n };\n\n /**\n * Get the marker's offset.\n * @returns The marker's screen coordinates in pixels.\n */\n getOffset(): Point {\n return this._offset;\n }\n\n /**\n * Sets the offset of the marker\n * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.\n * @returns `this`\n */\n setOffset(offset: PointLike): this {\n this._offset = Point.convert(offset);\n this._update();\n return this;\n }\n\n /**\n * Adds a CSS class to the marker element.\n *\n * @param className - on-empty string with CSS class name to add to marker element\n *\n * @example\n * ```\n * let marker = new maplibregl.Marker()\n * marker.addClassName('some-class')\n * ```\n */\n addClassName(className: string) {\n this._element.classList.add(className);\n }\n\n /**\n * Removes a CSS class from the marker element.\n *\n * @param className - Non-empty string with CSS class name to remove from marker element\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * marker.removeClassName('some-class')\n * ```\n */\n removeClassName(className: string) {\n this._element.classList.remove(className);\n }\n\n /**\n * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class.\n *\n * @param className - Non-empty string with CSS class name to add/remove\n *\n * @returns if the class was removed return false, if class was added, then return true\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * marker.toggleClassName('toggleClass')\n * ```\n */\n toggleClassName(className: string): boolean {\n return this._element.classList.toggle(className);\n }\n\n _onMove = (e: MapMouseEvent | MapTouchEvent) => {\n if (!this._isDragging) {\n const clickTolerance = this._clickTolerance || this._map._clickTolerance;\n this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance;\n }\n if (!this._isDragging) return;\n\n this._pos = e.point.sub(this._positionDelta);\n this._lngLat = this._map.unproject(this._pos);\n this.setLngLat(this._lngLat);\n // suppress click event so that popups don't toggle on drag\n this._element.style.pointerEvents = 'none';\n\n // make sure dragstart only fires on the first move event after mousedown.\n // this can't be on mousedown because that event doesn't necessarily\n // imply that a drag is about to happen.\n if (this._state === 'pending') {\n this._state = 'active';\n this.fire(new Event('dragstart'));\n }\n this.fire(new Event('drag'));\n };\n\n _onUp = () => {\n // revert to normal pointer event handling\n this._element.style.pointerEvents = 'auto';\n this._positionDelta = null;\n this._pointerdownPos = null;\n this._isDragging = false;\n this._map.off('mousemove', this._onMove);\n this._map.off('touchmove', this._onMove);\n\n // only fire dragend if it was preceded by at least one drag event\n if (this._state === 'active') {\n this.fire(new Event('dragend'));\n }\n\n this._state = 'inactive';\n };\n\n _addDragHandler = (e: MapMouseEvent | MapTouchEvent) => {\n if (this._element.contains(e.originalEvent.target as any)) {\n e.preventDefault();\n\n // We need to calculate the pixel distance between the click point\n // and the marker position, with the offset accounted for. Then we\n // can subtract this distance from the mousemove event's position\n // to calculate the new marker position.\n // If we don't do this, the marker 'jumps' to the click position\n // creating a jarring UX effect.\n this._positionDelta = e.point.sub(this._pos).add(this._offset);\n\n this._pointerdownPos = e.point;\n\n this._state = 'pending';\n this._map.on('mousemove', this._onMove);\n this._map.on('touchmove', this._onMove);\n this._map.once('mouseup', this._onUp);\n this._map.once('touchend', this._onUp);\n }\n };\n\n /**\n * Sets the `draggable` property and functionality of the marker\n * @param shouldBeDraggable - Turns drag functionality on/off\n * @returns `this`\n */\n setDraggable(shouldBeDraggable?: boolean): this {\n this._draggable = !!shouldBeDraggable; // convert possible undefined value to false\n\n // handle case where map may not exist yet\n // e.g. when setDraggable is called before addTo\n if (this._map) {\n if (shouldBeDraggable) {\n this._map.on('mousedown', this._addDragHandler);\n this._map.on('touchstart', this._addDragHandler);\n } else {\n this._map.off('mousedown', this._addDragHandler);\n this._map.off('touchstart', this._addDragHandler);\n }\n }\n\n return this;\n }\n\n /**\n * Returns true if the marker can be dragged\n * @returns True if the marker is draggable.\n */\n isDraggable(): boolean {\n return this._draggable;\n }\n\n /**\n * Sets the `rotation` property of the marker.\n * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting.\n * @returns `this`\n */\n setRotation(rotation?: number): this {\n this._rotation = rotation || 0;\n this._update();\n return this;\n }\n\n /**\n * Returns the current rotation angle of the marker (in degrees).\n * @returns The current rotation angle of the marker.\n */\n getRotation(): number {\n return this._rotation;\n }\n\n /**\n * Sets the `rotationAlignment` property of the marker.\n * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto'\n * @returns `this`\n */\n setRotationAlignment(alignment?: Alignment): this {\n this._rotationAlignment = alignment || 'auto';\n this._update();\n return this;\n }\n\n /**\n * Returns the current `rotationAlignment` property of the marker.\n * @returns The current rotational alignment of the marker.\n */\n getRotationAlignment(): Alignment {\n return this._rotationAlignment;\n }\n\n /**\n * Sets the `pitchAlignment` property of the marker.\n * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`.\n * @returns `this`\n */\n setPitchAlignment(alignment?: Alignment): this {\n this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment;\n this._update();\n return this;\n }\n\n /**\n * Returns the current `pitchAlignment` property of the marker.\n * @returns The current pitch alignment of the marker in degrees.\n */\n getPitchAlignment(): Alignment {\n return this._pitchAlignment;\n }\n}\n","import {Event, Evented} from '../../util/evented';\nimport {DOM} from '../../util/dom';\nimport {extend, warnOnce} from '../../util/util';\nimport {checkGeolocationSupport} from '../../util/geolocation_support';\nimport {LngLat} from '../../geo/lng_lat';\nimport {Marker} from '../marker';\n\nimport type {Map} from '../map';\nimport type {FitBoundsOptions} from '../camera';\nimport type {IControl} from './control';\nimport {LngLatBounds} from '../../geo/lng_lat_bounds';\n\n/**\n * The {@link GeolocateControl} options\n */\ntype GeolocateOptions = {\n /**\n * A Geolocation API [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) object.\n * @defaultValue `{enableHighAccuracy: false, timeout: 6000}`\n */\n positionOptions?: PositionOptions;\n /**\n * A options object to use when the map is panned and zoomed to the user's location. The default is to use a `maxZoom` of 15 to limit how far the map will zoom in for very accurate locations.\n */\n fitBoundsOptions?: FitBoundsOptions;\n /**\n * If `true` the Geolocate Control becomes a toggle button and when active the map will receive updates to the user's location as it changes.\n * @defaultValue false\n */\n trackUserLocation?: boolean;\n /**\n * By default, if showUserLocation is `true`, a transparent circle will be drawn around the user location indicating the accuracy (95% confidence level) of the user's location. Set to `false` to disable. Always disabled when showUserLocation is `false`.\n * @defaultValue true\n */\n showAccuracyCircle?: boolean;\n /**\n * By default a dot will be shown on the map at the user's location. Set to `false` to disable.\n * @defaultValue true\n */\n showUserLocation?: boolean;\n};\n\nconst defaultOptions: GeolocateOptions = {\n positionOptions: {\n enableHighAccuracy: false,\n maximumAge: 0,\n timeout: 6000 /* 6 sec */\n },\n fitBoundsOptions: {\n maxZoom: 15\n },\n trackUserLocation: false,\n showAccuracyCircle: true,\n showUserLocation: true\n};\n\nlet numberOfWatches = 0;\nlet noTimeout = false;\n\n/**\n * A `GeolocateControl` control provides a button that uses the browser's geolocation\n * API to locate the user on the map.\n *\n * Not all browsers support geolocation,\n * and some users may disable the feature. Geolocation support for modern\n * browsers including Chrome requires sites to be served over HTTPS. If\n * geolocation support is not available, the GeolocateControl will show\n * as disabled.\n *\n * The zoom level applied will depend on the accuracy of the geolocation provided by the device.\n *\n * The GeolocateControl has two modes. If `trackUserLocation` is `false` (default) the control acts as a button, which when pressed will set the map's camera to target the user location. If the user moves, the map won't update. This is most suited for the desktop. If `trackUserLocation` is `true` the control acts as a toggle button that when active the user's location is actively monitored for changes. In this mode the GeolocateControl has three interaction states:\n * * active - the map's camera automatically updates as the user's location changes, keeping the location dot in the center. Initial state and upon clicking the `GeolocateControl` button.\n * * passive - the user's location dot automatically updates, but the map's camera does not. Occurs upon the user initiating a map movement.\n * * disabled - occurs if Geolocation is not available, disabled or denied.\n *\n * These interaction states can't be controlled programmatically, rather they are set based on user interactions.\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * }));\n * ```\n * @see [Locate the user](https://maplibre.org/maplibre-gl-js/docs/examples/locate-user/)\n *\n * ### Events\n *\n * @event `trackuserlocationend` - Fired when the Geolocate Control changes to the background state, which happens when a user changes the camera during an active position lock. This only applies when trackUserLocation is true. In the background state, the dot on the map will update with location updates but the camera will not.\n *\n * @event `trackuserlocationstart` - Fired when the Geolocate Control changes to the active lock state, which happens either upon first obtaining a successful Geolocation API position for the user (a geolocate event will follow), or the user clicks the geolocate button when in the background state which uses the last known position to recenter the map and enter active lock state (no geolocate event will follow unless the users's location changes).\n *\n * @event `geolocate` - Fired on each Geolocation API position update which returned as success.\n * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @event `error` - Fired on each Geolocation API position update which returned as an error.\n * `data` - The returned [PositionError](https://developer.mozilla.org/en-US/docs/Web/API/PositionError) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @event `outofmaxbounds` Fired on each Geolocation API position update which returned as success but user position is out of map maxBounds.\n * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a trackuserlocationend event occurs.\n * geolocate.on('trackuserlocationend', function() {\n * console.log('A trackuserlocationend event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a trackuserlocationstart event occurs.\n * geolocate.on('trackuserlocationstart', function() {\n * console.log('A trackuserlocationstart event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a geolocate event occurs.\n * geolocate.on('geolocate', function() {\n * console.log('A geolocate event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when an error event occurs.\n * geolocate.on('error', function() {\n * console.log('An error event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when an outofmaxbounds event occurs.\n * geolocate.on('outofmaxbounds', function() {\n * console.log('An outofmaxbounds event has occurred.')\n * });\n * ```\n */\nexport class GeolocateControl extends Evented implements IControl {\n _map: Map;\n options: GeolocateOptions;\n _container: HTMLElement;\n _dotElement: HTMLElement;\n _circleElement: HTMLElement;\n _geolocateButton: HTMLButtonElement;\n _geolocationWatchID: number;\n _timeoutId: ReturnType;\n /* Geolocate Control Watch States\n * This is the private state of the control.\n *\n * OFF\n * off/inactive\n * WAITING_ACTIVE\n * Geolocate Control was clicked but still waiting for Geolocation API response with user location\n * ACTIVE_LOCK\n * Showing the user location as a dot AND tracking the camera to be fixed to their location. If their location changes the map moves to follow.\n * ACTIVE_ERROR\n * There was en error from the Geolocation API while trying to show and track the user location.\n * BACKGROUND\n * Showing the user location as a dot but the camera doesn't follow their location as it changes.\n * BACKGROUND_ERROR\n * There was an error from the Geolocation API while trying to show (but not track) the user location.\n */\n _watchState: 'OFF' | 'ACTIVE_LOCK' | 'WAITING_ACTIVE' | 'ACTIVE_ERROR' | 'BACKGROUND' | 'BACKGROUND_ERROR';\n _lastKnownPosition: any;\n _userLocationDotMarker: Marker;\n _accuracyCircleMarker: Marker;\n _accuracy: number;\n _setup: boolean; // set to true once the control has been setup\n\n constructor(options: GeolocateOptions) {\n super();\n this.options = extend({}, defaultOptions, options);\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n checkGeolocationSupport(this._setupUI);\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n // clear the geolocation watch if exists\n if (this._geolocationWatchID !== undefined) {\n window.navigator.geolocation.clearWatch(this._geolocationWatchID);\n this._geolocationWatchID = undefined;\n }\n\n // clear the markers from the map\n if (this.options.showUserLocation && this._userLocationDotMarker) {\n this._userLocationDotMarker.remove();\n }\n if (this.options.showAccuracyCircle && this._accuracyCircleMarker) {\n this._accuracyCircleMarker.remove();\n }\n\n DOM.remove(this._container);\n this._map.off('zoom', this._onZoom);\n this._map = undefined;\n numberOfWatches = 0;\n noTimeout = false;\n }\n\n /**\n * Check if the Geolocation API Position is outside the map's maxbounds.\n *\n * @param position - the Geolocation API Position\n * @returns `true` if position is outside the map's maxbounds, otherwise returns `false`.\n */\n _isOutOfMapMaxBounds(position: GeolocationPosition) {\n const bounds = this._map.getMaxBounds();\n const coordinates = position.coords;\n\n return bounds && (\n coordinates.longitude < bounds.getWest() ||\n coordinates.longitude > bounds.getEast() ||\n coordinates.latitude < bounds.getSouth() ||\n coordinates.latitude > bounds.getNorth()\n );\n }\n\n _setErrorState() {\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n this._watchState = 'ACTIVE_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error');\n break;\n case 'ACTIVE_LOCK':\n this._watchState = 'ACTIVE_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n // turn marker grey\n break;\n case 'BACKGROUND':\n this._watchState = 'BACKGROUND_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n // turn marker grey\n break;\n case 'ACTIVE_ERROR':\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n }\n\n /**\n * When the Geolocation API returns a new location, update the GeolocateControl.\n *\n * @param position - the Geolocation API Position\n */\n _onSuccess = (position: GeolocationPosition) => {\n if (!this._map) {\n // control has since been removed\n return;\n }\n\n if (this._isOutOfMapMaxBounds(position)) {\n this._setErrorState();\n\n this.fire(new Event('outofmaxbounds', position));\n this._updateMarker();\n this._finish();\n\n return;\n }\n\n if (this.options.trackUserLocation) {\n // keep a record of the position so that if the state is BACKGROUND and the user\n // clicks the button, we can move to ACTIVE_LOCK immediately without waiting for\n // watchPosition to trigger _onSuccess\n this._lastKnownPosition = position;\n\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n case 'ACTIVE_LOCK':\n case 'ACTIVE_ERROR':\n this._watchState = 'ACTIVE_LOCK';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'BACKGROUND':\n case 'BACKGROUND_ERROR':\n this._watchState = 'BACKGROUND';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background');\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n }\n\n // if showUserLocation and the watch state isn't off then update the marker location\n if (this.options.showUserLocation && this._watchState !== 'OFF') {\n this._updateMarker(position);\n }\n\n // if in normal mode (not watch mode), or if in watch mode and the state is active watch\n // then update the camera\n if (!this.options.trackUserLocation || this._watchState === 'ACTIVE_LOCK') {\n this._updateCamera(position);\n }\n\n if (this.options.showUserLocation) {\n this._dotElement.classList.remove('maplibregl-user-location-dot-stale');\n }\n\n this.fire(new Event('geolocate', position));\n this._finish();\n };\n\n /**\n * Update the camera location to center on the current position\n *\n * @param position - the Geolocation API Position\n */\n _updateCamera = (position: GeolocationPosition) => {\n const center = new LngLat(position.coords.longitude, position.coords.latitude);\n const radius = position.coords.accuracy;\n const bearing = this._map.getBearing();\n const options = extend({bearing}, this.options.fitBoundsOptions);\n const newBounds = LngLatBounds.fromLngLat(center, radius);\n\n this._map.fitBounds(newBounds, options, {\n geolocateSource: true // tag this camera change so it won't cause the control to change to background state\n });\n };\n\n /**\n * Update the user location dot Marker to the current position\n *\n * @param position - the Geolocation API Position\n */\n _updateMarker = (position?: GeolocationPosition | null) => {\n if (position) {\n const center = new LngLat(position.coords.longitude, position.coords.latitude);\n this._accuracyCircleMarker.setLngLat(center).addTo(this._map);\n this._userLocationDotMarker.setLngLat(center).addTo(this._map);\n this._accuracy = position.coords.accuracy;\n if (this.options.showUserLocation && this.options.showAccuracyCircle) {\n this._updateCircleRadius();\n }\n } else {\n this._userLocationDotMarker.remove();\n this._accuracyCircleMarker.remove();\n }\n };\n\n _updateCircleRadius() {\n const bounds = this._map.getBounds();\n const southEastPoint = bounds.getSouthEast();\n const northEastPoint = bounds.getNorthEast();\n const mapHeightInMeters = southEastPoint.distanceTo(northEastPoint);\n const mapHeightInPixels = this._map._container.clientHeight;\n const circleDiameter = Math.ceil(2 * (this._accuracy / (mapHeightInMeters / mapHeightInPixels)));\n this._circleElement.style.width = `${circleDiameter}px`;\n this._circleElement.style.height = `${circleDiameter}px`;\n }\n\n _onZoom = () => {\n if (this.options.showUserLocation && this.options.showAccuracyCircle) {\n this._updateCircleRadius();\n }\n };\n\n _onError = (error: GeolocationPositionError) => {\n if (!this._map) {\n // control has since been removed\n return;\n }\n\n if (this.options.trackUserLocation) {\n if (error.code === 1) {\n // PERMISSION_DENIED\n this._watchState = 'OFF';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.disabled = true;\n const title = this._map._getUIString('GeolocateControl.LocationNotAvailable');\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n\n if (this._geolocationWatchID !== undefined) {\n this._clearWatch();\n }\n } else if (error.code === 3 && noTimeout) {\n // this represents a forced error state\n // this was triggered to force immediate geolocation when a watch is already present\n // see https://github.com/mapbox/mapbox-gl-js/issues/8214\n // and https://w3c.github.io/geolocation-api/#example-5-forcing-the-user-agent-to-return-a-fresh-cached-position\n return;\n } else {\n this._setErrorState();\n }\n }\n\n if (this._watchState !== 'OFF' && this.options.showUserLocation) {\n this._dotElement.classList.add('maplibregl-user-location-dot-stale');\n }\n\n this.fire(new Event('error', error));\n\n this._finish();\n };\n\n _finish = () => {\n if (this._timeoutId) { clearTimeout(this._timeoutId); }\n this._timeoutId = undefined;\n };\n\n _setupUI = (supported: boolean) => {\n // this method is called asynchronously during onAdd\n // the control could have been removed before reaching here\n if (!this._map) {\n return;\n }\n\n this._container.addEventListener('contextmenu', (e: MouseEvent) => e.preventDefault());\n this._geolocateButton = DOM.create('button', 'maplibregl-ctrl-geolocate', this._container);\n DOM.create('span', 'maplibregl-ctrl-icon', this._geolocateButton).setAttribute('aria-hidden', 'true');\n this._geolocateButton.type = 'button';\n\n if (supported === false) {\n warnOnce('Geolocation support is not available so the GeolocateControl will be disabled.');\n const title = this._map._getUIString('GeolocateControl.LocationNotAvailable');\n this._geolocateButton.disabled = true;\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n } else {\n const title = this._map._getUIString('GeolocateControl.FindMyLocation');\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n }\n\n if (this.options.trackUserLocation) {\n this._geolocateButton.setAttribute('aria-pressed', 'false');\n this._watchState = 'OFF';\n }\n\n // when showUserLocation is enabled, keep the Geolocate button disabled until the device location marker is setup on the map\n if (this.options.showUserLocation) {\n this._dotElement = DOM.create('div', 'maplibregl-user-location-dot');\n\n this._userLocationDotMarker = new Marker({element: this._dotElement});\n\n this._circleElement = DOM.create('div', 'maplibregl-user-location-accuracy-circle');\n this._accuracyCircleMarker = new Marker({element: this._circleElement, pitchAlignment: 'map'});\n\n if (this.options.trackUserLocation) this._watchState = 'OFF';\n\n this._map.on('zoom', this._onZoom);\n }\n\n this._geolocateButton.addEventListener('click',\n this.trigger.bind(this));\n\n this._setup = true;\n\n // when the camera is changed (and it's not as a result of the Geolocation Control) change\n // the watch mode to background watch, so that the marker is updated but not the camera.\n if (this.options.trackUserLocation) {\n this._map.on('movestart', (event: any) => {\n const fromResize = event.originalEvent && event.originalEvent.type === 'resize';\n if (!event.geolocateSource && this._watchState === 'ACTIVE_LOCK' && !fromResize) {\n this._watchState = 'BACKGROUND';\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n\n this.fire(new Event('trackuserlocationend'));\n }\n });\n }\n };\n\n /**\n * Programmatically request and move the map to the user's location.\n *\n * @returns `false` if called before control was added to a map, otherwise returns `true`.\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * map.on('load', function() {\n * geolocate.trigger();\n * });\n * ```\n */\n trigger(): boolean {\n if (!this._setup) {\n warnOnce('Geolocate control triggered before added to a map');\n return false;\n }\n if (this.options.trackUserLocation) {\n // update watchState and do any outgoing state cleanup\n switch (this._watchState) {\n case 'OFF':\n // turn on the Geolocate Control\n this._watchState = 'WAITING_ACTIVE';\n\n this.fire(new Event('trackuserlocationstart'));\n break;\n case 'WAITING_ACTIVE':\n case 'ACTIVE_LOCK':\n case 'ACTIVE_ERROR':\n case 'BACKGROUND_ERROR':\n // turn off the Geolocate Control\n numberOfWatches--;\n noTimeout = false;\n this._watchState = 'OFF';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n\n this.fire(new Event('trackuserlocationend'));\n break;\n case 'BACKGROUND':\n this._watchState = 'ACTIVE_LOCK';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n // set camera to last known location\n if (this._lastKnownPosition) this._updateCamera(this._lastKnownPosition);\n\n this.fire(new Event('trackuserlocationstart'));\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n\n // incoming state setup\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'ACTIVE_LOCK':\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'OFF':\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n\n // manage geolocation.watchPosition / geolocation.clearWatch\n if (this._watchState === 'OFF' && this._geolocationWatchID !== undefined) {\n // clear watchPosition as we've changed to an OFF state\n this._clearWatch();\n } else if (this._geolocationWatchID === undefined) {\n // enable watchPosition since watchState is not OFF and there is no watchPosition already running\n\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.setAttribute('aria-pressed', 'true');\n\n numberOfWatches++;\n let positionOptions;\n if (numberOfWatches > 1) {\n positionOptions = {maximumAge: 600000, timeout: 0};\n noTimeout = true;\n } else {\n positionOptions = this.options.positionOptions;\n noTimeout = false;\n }\n\n this._geolocationWatchID = window.navigator.geolocation.watchPosition(\n this._onSuccess, this._onError, positionOptions);\n }\n } else {\n window.navigator.geolocation.getCurrentPosition(\n this._onSuccess, this._onError, this.options.positionOptions);\n\n // This timeout ensures that we still call finish() even if\n // the user declines to share their location in Firefox\n this._timeoutId = setTimeout(this._finish, 10000 /* 10sec */);\n }\n\n return true;\n }\n\n _clearWatch() {\n window.navigator.geolocation.clearWatch(this._geolocationWatchID);\n\n this._geolocationWatchID = undefined;\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.setAttribute('aria-pressed', 'false');\n\n if (this.options.showUserLocation) {\n this._updateMarker(null);\n }\n }\n}\n\n","import {DOM} from '../../util/dom';\nimport {extend} from '../../util/util';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\n\n/**\n * The unit type for length to use for the {@link ScaleControl}\n */\nexport type Unit = 'imperial' | 'metric' | 'nautical';\n\n/**\n * The {@link ScaleControl} options object\n */\ntype ScaleOptions = {\n /**\n * The maximum length of the scale control in pixels.\n * @defaultValue 100\n */\n maxWidth?: number;\n /**\n * Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).\n * @defaultValue 'metric'\n */\n unit?: Unit;\n};\n\nconst defaultOptions: ScaleOptions = {\n maxWidth: 100,\n unit: 'metric'\n};\n\n/**\n * A `ScaleControl` control displays the ratio of a distance on the map to the corresponding distance on the ground.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let scale = new maplibregl.ScaleControl({\n * maxWidth: 80,\n * unit: 'imperial'\n * });\n * map.addControl(scale);\n *\n * scale.setUnit('metric');\n * ```\n */\nexport class ScaleControl implements IControl {\n _map: Map;\n _container: HTMLElement;\n options: ScaleOptions;\n\n constructor(options: ScaleOptions) {\n this.options = extend({}, defaultOptions, options);\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-left';\n }\n\n _onMove = () => {\n updateScale(this._map, this._container, this.options);\n };\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-scale', map.getContainer());\n\n this._map.on('move', this._onMove);\n this._onMove();\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('move', this._onMove);\n this._map = undefined;\n }\n\n /**\n * Set the scale's unit of the distance\n *\n * @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).\n */\n setUnit = (unit: Unit) => {\n this.options.unit = unit;\n updateScale(this._map, this._container, this.options);\n };\n}\n\nfunction updateScale(map, container, options) {\n // A horizontal scale is imagined to be present at center of the map\n // container with maximum length (Default) as 100px.\n // Using spherical law of cosines approximation, the real distance is\n // found between the two coordinates.\n const maxWidth = options && options.maxWidth || 100;\n\n const y = map._container.clientHeight / 2;\n const left = map.unproject([0, y]);\n const right = map.unproject([maxWidth, y]);\n const maxMeters = left.distanceTo(right);\n // The real distance corresponding to 100px scale length is rounded off to\n // near pretty number and the scale length for the same is found out.\n // Default unit of the scale is based on User's locale.\n if (options && options.unit === 'imperial') {\n const maxFeet = 3.2808 * maxMeters;\n if (maxFeet > 5280) {\n const maxMiles = maxFeet / 5280;\n setScale(container, maxWidth, maxMiles, map._getUIString('ScaleControl.Miles'));\n } else {\n setScale(container, maxWidth, maxFeet, map._getUIString('ScaleControl.Feet'));\n }\n } else if (options && options.unit === 'nautical') {\n const maxNauticals = maxMeters / 1852;\n setScale(container, maxWidth, maxNauticals, map._getUIString('ScaleControl.NauticalMiles'));\n } else if (maxMeters >= 1000) {\n setScale(container, maxWidth, maxMeters / 1000, map._getUIString('ScaleControl.Kilometers'));\n } else {\n setScale(container, maxWidth, maxMeters, map._getUIString('ScaleControl.Meters'));\n }\n}\n\nfunction setScale(container, maxWidth, maxDistance, unit) {\n const distance = getRoundNum(maxDistance);\n const ratio = distance / maxDistance;\n container.style.width = `${maxWidth * ratio}px`;\n container.innerHTML = `${distance} ${unit}`;\n}\n\nfunction getDecimalRoundNum(d) {\n const multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10));\n return Math.round(d * multiplier) / multiplier;\n}\n\nfunction getRoundNum(num) {\n const pow10 = Math.pow(10, (`${Math.floor(num)}`).length - 1);\n let d = num / pow10;\n\n d = d >= 10 ? 10 :\n d >= 5 ? 5 :\n d >= 3 ? 3 :\n d >= 2 ? 2 :\n d >= 1 ? 1 : getDecimalRoundNum(d);\n\n return pow10 * d;\n}\n","import {extend} from '../util/util';\nimport {Event, Evented} from '../util/evented';\nimport {MapMouseEvent} from '../ui/events';\nimport {DOM} from '../util/dom';\nimport {LngLat} from '../geo/lng_lat';\nimport Point from '@mapbox/point-geometry';\nimport {smartWrap} from '../util/smart_wrap';\nimport {anchorTranslate, applyAnchorClass} from './anchor';\n\nimport type {PositionAnchor} from './anchor';\nimport type {Map} from './map';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {PointLike} from './camera';\n\nconst defaultOptions = {\n closeButton: true,\n closeOnClick: true,\n focusAfterOpen: true,\n className: '',\n maxWidth: '240px'\n};\n\n/**\n * A pixel offset specified as:\n * - a single number specifying a distance from the location\n * - a {@link PointLike} specifying a constant offset\n * - an object of {@link Point}s specifying an offset for each anchor position\n * Negative offsets indicate left and up.\n */\nexport type Offset = number | PointLike | {\n [_ in PositionAnchor]: PointLike;\n};\n\nexport type PopupOptions = {\n /**\n * If `true`, a close button will appear in the top right corner of the popup.\n * @defaultValue true\n */\n closeButton?: boolean;\n /**\n * If `true`, the popup will closed when the map is clicked.\n * @defaultValue true\n */\n closeOnClick?: boolean;\n /**\n * If `true`, the popup will closed when the map moves.\n * @defaultValue false\n */\n closeOnMove?: boolean;\n /**\n * If `true`, the popup will try to focus the first focusable element inside the popup.\n * @defaultValue true\n */\n focusAfterOpen?: boolean;\n /**\n * A string indicating the part of the Popup that should\n * be positioned closest to the coordinate set via {@link Popup#setLngLat}.\n * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`,\n * `'top-right'`, `'bottom-left'`, and `'bottom-right'`. If unset the anchor will be\n * dynamically set to ensure the popup falls within the map container with a preference\n * for `'bottom'`.\n */\n anchor?: PositionAnchor;\n /**\n * A pixel offset applied to the popup's location\n */\n offset?: Offset;\n /**\n * Space-separated CSS class names to add to popup container\n */\n className?: string;\n /**\n * A string that sets the CSS property of the popup's maximum width, eg `'300px'`.\n * To ensure the popup resizes to fit its content, set this property to `'none'`.\n * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width\n * @defaultValue '240px'\n */\n maxWidth?: string;\n};\n\nconst focusQuerySelector = [\n 'a[href]',\n '[tabindex]:not([tabindex=\\'-1\\'])',\n '[contenteditable]:not([contenteditable=\\'false\\'])',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n].join(', ');\n\n/**\n * A popup component.\n *\n * @group Markers and Controls\n *\n *\n * @example\n * Create a popup\n * ```ts\n * let popup = new maplibregl.Popup();\n * // Set an event listener that will fire\n * // any time the popup is opened\n * popup.on('open', function(){\n * console.log('popup was opened');\n * });\n * ```\n *\n * @example\n * Create a popup\n * ```ts\n * let popup = new maplibregl.Popup();\n * // Set an event listener that will fire\n * // any time the popup is closed\n * popup.on('close', function(){\n * console.log('popup was closed');\n * });\n * ```\n *\n * @example\n * ```ts\n * let markerHeight = 50, markerRadius = 10, linearOffset = 25;\n * let popupOffsets = {\n * 'top': [0, 0],\n * 'top-left': [0,0],\n * 'top-right': [0,0],\n * 'bottom': [0, -markerHeight],\n * 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n * 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n * 'left': [markerRadius, (markerHeight - markerRadius) * -1],\n * 'right': [-markerRadius, (markerHeight - markerRadius) * -1]\n * };\n * let popup = new maplibregl.Popup({offset: popupOffsets, className: 'my-class'})\n * .setLngLat(e.lngLat)\n * .setHTML(\"

Hello World!

\")\n * .setMaxWidth(\"300px\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n *\n * ### Events\n *\n * @event `open` Fired when the popup is opened manually or programmatically. `popup` object that was opened\n *\n * @event `close` Fired when the popup is closed manually or programmatically. `popup` object that was closed\n */\nexport class Popup extends Evented {\n _map: Map;\n options: PopupOptions;\n _content: HTMLElement;\n _container: HTMLElement;\n _closeButton: HTMLButtonElement;\n _tip: HTMLElement;\n _lngLat: LngLat;\n _trackPointer: boolean;\n _pos: Point;\n\n constructor(options?: PopupOptions) {\n super();\n this.options = extend(Object.create(defaultOptions), options);\n }\n\n /**\n * Adds the popup to a map.\n *\n * @param map - The MapLibre GL JS map to add the popup to.\n * @returns `this`\n * @example\n * ```ts\n * new maplibregl.Popup()\n * .setLngLat([0, 0])\n * .setHTML(\"

Null Island

\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Show polygon information on click](https://maplibre.org/maplibre-gl-js/docs/examples/polygon-popup-on-click/)\n */\n addTo(map: Map): this {\n if (this._map) this.remove();\n\n this._map = map;\n if (this.options.closeOnClick) {\n this._map.on('click', this._onClose);\n }\n\n if (this.options.closeOnMove) {\n this._map.on('move', this._onClose);\n }\n\n this._map.on('remove', this.remove);\n this._update();\n this._focusFirstElement();\n\n if (this._trackPointer) {\n this._map.on('mousemove', this._onMouseMove);\n this._map.on('mouseup', this._onMouseUp);\n if (this._container) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.add('maplibregl-track-pointer');\n } else {\n this._map.on('move', this._update);\n }\n\n this.fire(new Event('open'));\n\n return this;\n }\n\n /**\n * @returns `true` if the popup is open, `false` if it is closed.\n */\n isOpen() {\n return !!this._map;\n }\n\n /**\n * Removes the popup from the map it has been added to.\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup().addTo(map);\n * popup.remove();\n * ```\n * @returns `this`\n */\n remove = (): this => {\n if (this._content) {\n DOM.remove(this._content);\n }\n\n if (this._container) {\n DOM.remove(this._container);\n delete this._container;\n }\n\n if (this._map) {\n this._map.off('move', this._update);\n this._map.off('move', this._onClose);\n this._map.off('click', this._onClose);\n this._map.off('remove', this.remove);\n this._map.off('mousemove', this._onMouseMove);\n this._map.off('mouseup', this._onMouseUp);\n this._map.off('drag', this._onDrag);\n delete this._map;\n }\n\n this.fire(new Event('close'));\n\n return this;\n };\n\n /**\n * Returns the geographical location of the popup's anchor.\n *\n * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously\n * set by `setLngLat` because `Popup` wraps the anchor longitude across copies of the world to keep\n * the popup on screen.\n *\n * @returns The geographical location of the popup's anchor.\n */\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n /**\n * Sets the geographical location of the popup's anchor, and moves the popup to it. Replaces trackPointer() behavior.\n *\n * @param lnglat - The geographical location to set as the popup's anchor.\n * @returns `this`\n */\n setLngLat(lnglat: LngLatLike): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n\n this._trackPointer = false;\n\n this._update();\n\n if (this._map) {\n this._map.on('move', this._update);\n this._map.off('mousemove', this._onMouseMove);\n if (this._container) {\n this._container.classList.remove('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.remove('maplibregl-track-pointer');\n }\n\n return this;\n }\n\n /**\n * Tracks the popup anchor to the cursor position on screens with a pointer device (it will be hidden on touchscreens). Replaces the `setLngLat` behavior.\n * For most use cases, set `closeOnClick` and `closeButton` to `false`.\n * @example\n * ```ts\n * let popup = new maplibregl.Popup({ closeOnClick: false, closeButton: false })\n * .setHTML(\"

Hello World!

\")\n * .trackPointer()\n * .addTo(map);\n * ```\n * @returns `this`\n */\n trackPointer(): this {\n this._trackPointer = true;\n this._pos = null;\n this._update();\n if (this._map) {\n this._map.off('move', this._update);\n this._map.on('mousemove', this._onMouseMove);\n this._map.on('drag', this._onDrag);\n if (this._container) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.add('maplibregl-track-pointer');\n }\n\n return this;\n\n }\n\n /**\n * Returns the `Popup`'s HTML element.\n * @example\n * Change the `Popup` element's font size\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat([-96, 37.8])\n * .setHTML(\"

Hello World!

\")\n * .addTo(map);\n * let popupElem = popup.getElement();\n * popupElem.style.fontSize = \"25px\";\n * ```\n * @returns element\n */\n getElement(): HTMLElement {\n return this._container;\n }\n\n /**\n * Sets the popup's content to a string of text.\n *\n * This function creates a [Text](https://developer.mozilla.org/en-US/docs/Web/API/Text) node in the DOM,\n * so it cannot insert raw HTML. Use this method for security against XSS\n * if the popup content is user-provided.\n *\n * @param text - Textual content for the popup.\n * @returns `this`\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setText('Hello, world!')\n * .addTo(map);\n * ```\n */\n setText(text: string): this {\n return this.setDOMContent(document.createTextNode(text));\n }\n\n /**\n * Sets the popup's content to the HTML provided as a string.\n *\n * This method does not perform HTML filtering or sanitization, and must be\n * used only with trusted content. Consider {@link Popup#setText} if\n * the content is an untrusted text string.\n *\n * @param html - A string representing HTML content for the popup.\n * @returns `this`\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setHTML(\"

Hello World!

\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n */\n setHTML(html: string): this {\n const frag = document.createDocumentFragment();\n const temp = document.createElement('body');\n let child;\n temp.innerHTML = html;\n while (true) {\n child = temp.firstChild;\n if (!child) break;\n frag.appendChild(child);\n }\n\n return this.setDOMContent(frag);\n }\n\n /**\n * Returns the popup's maximum width.\n *\n * @returns The maximum width of the popup.\n */\n getMaxWidth(): string {\n return this._container?.style.maxWidth;\n }\n\n /**\n * Sets the popup's maximum width. This is setting the CSS property `max-width`.\n * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width\n *\n * @param maxWidth - A string representing the value for the maximum width.\n * @returns `this`\n */\n setMaxWidth(maxWidth: string): this {\n this.options.maxWidth = maxWidth;\n this._update();\n return this;\n }\n\n /**\n * Sets the popup's content to the element provided as a DOM node.\n *\n * @param htmlNode - A DOM node to be used as content for the popup.\n * @returns `this`\n * @example\n * Create an element with the popup content\n * ```ts\n * let div = document.createElement('div');\n * div.innerHTML = 'Hello, world!';\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setDOMContent(div)\n * .addTo(map);\n * ```\n */\n setDOMContent(htmlNode: Node): this {\n if (this._content) {\n // Clear out children first.\n while (this._content.hasChildNodes()) {\n if (this._content.firstChild) {\n this._content.removeChild(this._content.firstChild);\n }\n }\n } else {\n this._content = DOM.create('div', 'maplibregl-popup-content', this._container);\n }\n\n // The close button should be the last tabbable element inside the popup for a good keyboard UX.\n this._content.appendChild(htmlNode);\n this._createCloseButton();\n this._update();\n this._focusFirstElement();\n return this;\n }\n\n /**\n * Adds a CSS class to the popup container element.\n *\n * @param className - Non-empty string with CSS class name to add to popup container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.addClassName('some-class')\n * ```\n */\n addClassName(className: string) {\n if (this._container) {\n this._container.classList.add(className);\n }\n }\n\n /**\n * Removes a CSS class from the popup container element.\n *\n * @param className - Non-empty string with CSS class name to remove from popup container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.removeClassName('some-class')\n * ```\n */\n removeClassName(className: string) {\n if (this._container) {\n this._container.classList.remove(className);\n }\n }\n\n /**\n * Sets the popup's offset.\n *\n * @param offset - Sets the popup's offset.\n * @returns `this`\n */\n setOffset (offset?: Offset): this {\n this.options.offset = offset;\n this._update();\n return this;\n }\n\n /**\n * Add or remove the given CSS class on the popup container, depending on whether the container currently has that class.\n *\n * @param className - Non-empty string with CSS class name to add/remove\n *\n * @returns if the class was removed return false, if class was added, then return true, undefined if there is no container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.toggleClassName('toggleClass')\n * ```\n */\n toggleClassName(className: string): boolean | undefined {\n if (this._container) {\n return this._container.classList.toggle(className);\n }\n }\n\n _createCloseButton() {\n if (this.options.closeButton) {\n this._closeButton = DOM.create('button', 'maplibregl-popup-close-button', this._content);\n this._closeButton.type = 'button';\n this._closeButton.setAttribute('aria-label', 'Close popup');\n this._closeButton.innerHTML = '×';\n this._closeButton.addEventListener('click', this._onClose);\n }\n }\n\n _onMouseUp = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _onMouseMove = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _onDrag = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _update = (cursor?: Point) => {\n const hasPosition = this._lngLat || this._trackPointer;\n\n if (!this._map || !hasPosition || !this._content) { return; }\n\n if (!this._container) {\n this._container = DOM.create('div', 'maplibregl-popup', this._map.getContainer());\n this._tip = DOM.create('div', 'maplibregl-popup-tip', this._container);\n this._container.appendChild(this._content);\n if (this.options.className) {\n for (const name of this.options.className.split(' ')) {\n this._container.classList.add(name);\n }\n }\n\n if (this._trackPointer) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n }\n\n if (this.options.maxWidth && this._container.style.maxWidth !== this.options.maxWidth) {\n this._container.style.maxWidth = this.options.maxWidth;\n }\n\n if (this._map.transform.renderWorldCopies && !this._trackPointer) {\n this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);\n }\n\n if (this._trackPointer && !cursor) return;\n\n const pos = this._pos = this._trackPointer && cursor ? cursor : this._map.project(this._lngLat);\n\n let anchor = this.options.anchor;\n const offset = normalizeOffset(this.options.offset);\n\n if (!anchor) {\n const width = this._container.offsetWidth;\n const height = this._container.offsetHeight;\n let anchorComponents;\n\n if (pos.y + offset.bottom.y < height) {\n anchorComponents = ['top'];\n } else if (pos.y > this._map.transform.height - height) {\n anchorComponents = ['bottom'];\n } else {\n anchorComponents = [];\n }\n\n if (pos.x < width / 2) {\n anchorComponents.push('left');\n } else if (pos.x > this._map.transform.width - width / 2) {\n anchorComponents.push('right');\n }\n\n if (anchorComponents.length === 0) {\n anchor = 'bottom';\n } else {\n anchor = (anchorComponents.join('-') as any);\n }\n }\n\n const offsetedPos = pos.add(offset[anchor]).round();\n DOM.setTransform(this._container, `${anchorTranslate[anchor]} translate(${offsetedPos.x}px,${offsetedPos.y}px)`);\n applyAnchorClass(this._container, anchor, 'popup');\n };\n\n _focusFirstElement() {\n if (!this.options.focusAfterOpen || !this._container) return;\n\n const firstFocusable = this._container.querySelector(focusQuerySelector) as HTMLElement;\n\n if (firstFocusable) firstFocusable.focus();\n }\n\n _onClose = () => {\n this.remove();\n };\n}\n\nfunction normalizeOffset(offset?: Offset | null) {\n if (!offset) {\n return normalizeOffset(new Point(0, 0));\n\n } else if (typeof offset === 'number') {\n // input specifies a radius from which to calculate offsets at all positions\n const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);\n return {\n 'center': new Point(0, 0),\n 'top': new Point(0, offset),\n 'top-left': new Point(cornerOffset, cornerOffset),\n 'top-right': new Point(-cornerOffset, cornerOffset),\n 'bottom': new Point(0, -offset),\n 'bottom-left': new Point(cornerOffset, -cornerOffset),\n 'bottom-right': new Point(-cornerOffset, -cornerOffset),\n 'left': new Point(offset, 0),\n 'right': new Point(-offset, 0)\n };\n\n } else if (offset instanceof Point || Array.isArray(offset)) {\n // input specifies a single offset to be applied to all positions\n const convertedOffset = Point.convert(offset);\n return {\n 'center': convertedOffset,\n 'top': convertedOffset,\n 'top-left': convertedOffset,\n 'top-right': convertedOffset,\n 'bottom': convertedOffset,\n 'bottom-left': convertedOffset,\n 'bottom-right': convertedOffset,\n 'left': convertedOffset,\n 'right': convertedOffset\n };\n\n } else {\n // input specifies an offset per position\n return {\n 'center': Point.convert(offset['center'] || [0, 0]),\n 'top': Point.convert(offset['top'] || [0, 0]),\n 'top-left': Point.convert(offset['top-left'] || [0, 0]),\n 'top-right': Point.convert(offset['top-right'] || [0, 0]),\n 'bottom': Point.convert(offset['bottom'] || [0, 0]),\n 'bottom-left': Point.convert(offset['bottom-left'] || [0, 0]),\n 'bottom-right': Point.convert(offset['bottom-right'] || [0, 0]),\n 'left': Point.convert(offset['left'] || [0, 0]),\n 'right': Point.convert(offset['right'] || [0, 0])\n };\n }\n}\n","import {extend} from './util';\n\n/**\n * This is a private namespace for utility functions that will get automatically stripped\n * out in production builds.\n */\nexport const Debug = {\n extend(dest: any, ...sources: Array): any {\n return extend(dest, ...sources);\n },\n\n run(fn: () => any) {\n fn();\n },\n\n logToElement(message: string, overwrite: boolean = false, id: string = 'log') {\n const el = window.document.getElementById(id);\n if (el) {\n if (overwrite) el.innerHTML = '';\n el.innerHTML += `
${message}`;\n }\n\n }\n};\n","import packageJSON from '../package.json' assert {type: 'json'};\nimport {Map} from './ui/map';\nimport {NavigationControl} from './ui/control/navigation_control';\nimport {GeolocateControl} from './ui/control/geolocate_control';\nimport {AttributionControl} from './ui/control/attribution_control';\nimport {LogoControl} from './ui/control/logo_control';\nimport {ScaleControl} from './ui/control/scale_control';\nimport {FullscreenControl} from './ui/control/fullscreen_control';\nimport {TerrainControl} from './ui/control/terrain_control';\nimport {Popup} from './ui/popup';\nimport {Marker} from './ui/marker';\nimport {Style} from './style/style';\nimport {LngLat} from './geo/lng_lat';\nimport {LngLatBounds} from './geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from './geo/mercator_coordinate';\nimport {Evented} from './util/evented';\nimport {config} from './util/config';\nimport {Debug} from './util/debug';\nimport {isSafari} from './util/util';\nimport {setRTLTextPlugin, getRTLTextPluginStatus} from './source/rtl_text_plugin';\nimport {WorkerPool} from './util/worker_pool';\nimport {prewarm, clearPrewarmedResources} from './util/global_worker_pool';\nimport {PerformanceUtils} from './util/performance';\nimport {AJAXError} from './util/ajax';\nimport type {RequestParameters, ResponseCallback} from './util/ajax';\nimport type {Cancelable} from './types/cancelable';\nimport {GeoJSONSource} from './source/geojson_source';\nimport {CanvasSource} from './source/canvas_source';\nimport {ImageSource} from './source/image_source';\nimport {RasterDEMTileSource} from './source/raster_dem_tile_source';\nimport {RasterTileSource} from './source/raster_tile_source';\nimport {VectorTileSource} from './source/vector_tile_source';\nimport {VideoSource} from './source/video_source';\n\nconst version = packageJSON.version;\n\nexport type * from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * `maplibregl` is the global object that allows configurations that are not specific to a map instance\n *\n * @group Main\n */\nclass MapLibreGL {\n static Map = Map;\n static NavigationControl = NavigationControl;\n static GeolocateControl = GeolocateControl;\n static AttributionControl = AttributionControl;\n static LogoControl = LogoControl;\n static ScaleControl = ScaleControl;\n static FullscreenControl = FullscreenControl;\n static TerrainControl = TerrainControl;\n static Popup = Popup;\n static Marker = Marker;\n static Style = Style;\n static LngLat = LngLat;\n static LngLatBounds = LngLatBounds;\n static Point = Point;\n static MercatorCoordinate = MercatorCoordinate;\n static Evented = Evented;\n static AJAXError = AJAXError;\n static config = config;\n static CanvasSource = CanvasSource;\n static GeoJSONSource = GeoJSONSource;\n static ImageSource = ImageSource;\n static RasterDEMTileSource = RasterDEMTileSource;\n static RasterTileSource = RasterTileSource;\n static VectorTileSource = VectorTileSource;\n static VideoSource = VideoSource;\n /**\n * Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text).\n * Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left.\n *\n * @param pluginURL - URL pointing to the Mapbox RTL text plugin source.\n * @param callback - Called with an error argument if there is an error.\n * @param lazy - If set to `true`, mapboxgl will defer loading the plugin until rtl text is encountered,\n * rtl text will then be rendered only after the plugin finishes loading.\n * @example\n * ```ts\n * maplibregl.setRTLTextPlugin('https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.js');\n * ```\n * @see [Add support for right-to-left scripts](https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/)\n */\n static setRTLTextPlugin = setRTLTextPlugin;\n /**\n * Gets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) status.\n * The status can be `unavailable` (i.e. not requested or removed), `loading`, `loaded` or `error`.\n * If the status is `loaded` and the plugin is requested again, an error will be thrown.\n *\n * @example\n * ```ts\n * const pluginStatus = maplibregl.getRTLTextPluginStatus();\n * ```\n */\n static getRTLTextPluginStatus = getRTLTextPluginStatus;\n /**\n * Initializes resources like WebWorkers that can be shared across maps to lower load\n * times in some situations. `maplibregl.workerUrl` and `maplibregl.workerCount`, if being\n * used, must be set before `prewarm()` is called to have an effect.\n *\n * By default, the lifecycle of these resources is managed automatically, and they are\n * lazily initialized when a Map is first created. By invoking `prewarm()`, these\n * resources will be created ahead of time, and will not be cleared when the last Map\n * is removed from the page. This allows them to be re-used by new Map instances that\n * are created later. They can be manually cleared by calling\n * `maplibregl.clearPrewarmedResources()`. This is only necessary if your web page remains\n * active but stops using maps altogether.\n *\n * This is primarily useful when using GL-JS maps in a single page app, wherein a user\n * would navigate between various views that can cause Map instances to constantly be\n * created and destroyed.\n *\n * @example\n * ```ts\n * maplibregl.prewarm()\n * ```\n */\n static prewarm = prewarm;\n /**\n * Clears up resources that have previously been created by `maplibregl.prewarm()`.\n * Note that this is typically not necessary. You should only call this function\n * if you expect the user of your app to not return to a Map view at any point\n * in your application.\n *\n * @example\n * ```ts\n * maplibregl.clearPrewarmedResources()\n * ```\n */\n static clearPrewarmedResources = clearPrewarmedResources;\n /**\n * Returns the package version of the library\n * @returns Package version of the library\n */\n static get version(): string {\n return version;\n }\n\n /**\n * Gets and sets the number of web workers instantiated on a page with GL JS maps.\n * By default, workerCount is 1 except for Safari browser where it is set to half the number of CPU cores (capped at 3).\n * Make sure to set this property before creating any map instances for it to have effect.\n *\n * @returns Number of workers currently configured.\n * @example\n * ```ts\n * maplibregl.workerCount = 2;\n * ```\n */\n static get workerCount(): number {\n return WorkerPool.workerCount;\n }\n\n static set workerCount(count: number) {\n WorkerPool.workerCount = count;\n }\n /**\n * Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel,\n * which affects performance in raster-heavy maps. 16 by default.\n *\n * @returns Number of parallel requests currently configured.\n * @example\n * ```ts\n * maplibregl.maxParallelImageRequests = 10;\n * ```\n */\n static get maxParallelImageRequests(): number {\n return config.MAX_PARALLEL_IMAGE_REQUESTS;\n }\n\n static set maxParallelImageRequests(numRequests: number) {\n config.MAX_PARALLEL_IMAGE_REQUESTS = numRequests;\n }\n\n static get workerUrl(): string {\n return config.WORKER_URL;\n }\n\n static set workerUrl(value: string) {\n config.WORKER_URL = value;\n }\n\n /**\n * Sets a custom load tile function that will be called when using a source that starts with a custom url schema.\n * The example below will be triggered for custom:// urls defined in the sources list in the style definitions.\n * The function passed will receive the request parameters and should call the callback with the resulting request,\n * for example a pbf vector tile, non-compressed, represented as ArrayBuffer.\n *\n * @param customProtocol - the protocol to hook, for example 'custom'\n * @param loadFn - the function to use when trying to fetch a tile specified by the customProtocol\n * @example\n * This will fetch a file using the fetch API (this is obviously a non interesting example...)\n * ```ts\n * maplibregl.addProtocol('custom', (params, callback) => {\n fetch(`https://${params.url.split(\"://\")[1]}`)\n .then(t => {\n if (t.status == 200) {\n t.arrayBuffer().then(arr => {\n callback(null, arr, null, null);\n });\n } else {\n callback(new Error(`Tile fetch error: ${t.statusText}`));\n }\n })\n .catch(e => {\n callback(new Error(e));\n });\n return { cancel: () => { } };\n });\n * // the following is an example of a way to return an error when trying to load a tile\n * maplibregl.addProtocol('custom2', (params, callback) => {\n * callback(new Error('someErrorMessage'));\n * return { cancel: () => { } };\n * });\n * ```\n */\n static addProtocol(customProtocol: string, loadFn: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable) {\n config.REGISTERED_PROTOCOLS[customProtocol] = loadFn;\n }\n\n /**\n * Removes a previously added protocol\n *\n * @param customProtocol - the custom protocol to remove registration for\n * @example\n * ```ts\n * maplibregl.removeProtocol('custom');\n * ```\n */\n static removeProtocol(customProtocol: string) {\n delete config.REGISTERED_PROTOCOLS[customProtocol];\n }\n}\n\n//This gets automatically stripped out in production builds.\nDebug.extend(MapLibreGL, {isSafari, getPerformanceMetrics: PerformanceUtils.getPerformanceMetrics});\n\nexport default MapLibreGL;\n","import {DOM} from '../../util/dom';\n\nimport {warnOnce} from '../../util/util';\n\nimport {Event, Evented} from '../../util/evented';\nimport type {Map, GestureOptions} from '../map';\nimport type {IControl} from './control';\n\n/**\n * The {@link FullscreenControl} options\n */\ntype FullscreenOptions = {\n /**\n * `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen.\n */\n container?: HTMLElement;\n};\n\n/**\n * A `FullscreenControl` control contains a button for toggling the map in and out of fullscreen mode.\n * When [requestFullscreen](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen) is not supported, fullscreen is handled via CSS properties.\n * The map's `cooperativeGestures` option is temporarily disabled while the map\n * is in fullscreen mode, and is restored when the map exist fullscreen mode.\n *\n * @group Markers and Controls\n * @param options - the full screen control options\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')}));\n * ```\n * @see [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/)\n *\n * ### Events\n *\n * @event `fullscreenstart` - Fired when fullscreen mode has started\n *\n * @event `fullscreenend` - Fired when fullscreen mode has ended\n */\nexport class FullscreenControl extends Evented implements IControl {\n _map: Map;\n _controlContainer: HTMLElement;\n _fullscreen: boolean;\n _fullscreenchange: string;\n _fullscreenButton: HTMLButtonElement;\n _container: HTMLElement;\n _prevCooperativeGestures: boolean | GestureOptions;\n\n constructor(options: FullscreenOptions = {}) {\n super();\n this._fullscreen = false;\n\n if (options && options.container) {\n if (options.container instanceof HTMLElement) {\n this._container = options.container;\n } else {\n warnOnce('Full screen control \\'container\\' must be a DOM element.');\n }\n }\n\n if ('onfullscreenchange' in document) {\n this._fullscreenchange = 'fullscreenchange';\n } else if ('onmozfullscreenchange' in document) {\n this._fullscreenchange = 'mozfullscreenchange';\n } else if ('onwebkitfullscreenchange' in document) {\n this._fullscreenchange = 'webkitfullscreenchange';\n } else if ('onmsfullscreenchange' in document) {\n this._fullscreenchange = 'MSFullscreenChange';\n }\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map): HTMLElement {\n this._map = map;\n if (!this._container) this._container = this._map.getContainer();\n this._controlContainer = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._setupUI();\n return this._controlContainer;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._controlContainer);\n this._map = null;\n window.document.removeEventListener(this._fullscreenchange, this._onFullscreenChange);\n }\n\n _setupUI() {\n const button = this._fullscreenButton = DOM.create('button', (('maplibregl-ctrl-fullscreen')), this._controlContainer);\n DOM.create('span', 'maplibregl-ctrl-icon', button).setAttribute('aria-hidden', 'true');\n button.type = 'button';\n this._updateTitle();\n this._fullscreenButton.addEventListener('click', this._onClickFullscreen);\n window.document.addEventListener(this._fullscreenchange, this._onFullscreenChange);\n }\n\n _updateTitle() {\n const title = this._getTitle();\n this._fullscreenButton.setAttribute('aria-label', title);\n this._fullscreenButton.title = title;\n }\n\n _getTitle() {\n return this._map._getUIString(this._isFullscreen() ? 'FullscreenControl.Exit' : 'FullscreenControl.Enter');\n }\n\n _isFullscreen() {\n return this._fullscreen;\n }\n\n _onFullscreenChange = () => {\n const fullscreenElement =\n window.document.fullscreenElement ||\n (window.document as any).mozFullScreenElement ||\n (window.document as any).webkitFullscreenElement ||\n (window.document as any).msFullscreenElement;\n\n if ((fullscreenElement === this._container) !== this._fullscreen) {\n this._handleFullscreenChange();\n }\n };\n\n _handleFullscreenChange() {\n this._fullscreen = !this._fullscreen;\n this._fullscreenButton.classList.toggle('maplibregl-ctrl-shrink');\n this._fullscreenButton.classList.toggle('maplibregl-ctrl-fullscreen');\n this._updateTitle();\n\n if (this._fullscreen) {\n this.fire(new Event('fullscreenstart'));\n if (this._map._cooperativeGestures) {\n this._prevCooperativeGestures = this._map._cooperativeGestures;\n this._map.setCooperativeGestures();\n }\n } else {\n this.fire(new Event('fullscreenend'));\n if (this._prevCooperativeGestures) {\n this._map.setCooperativeGestures(this._prevCooperativeGestures);\n delete this._prevCooperativeGestures;\n }\n }\n }\n\n _onClickFullscreen = () => {\n if (this._isFullscreen()) {\n this._exitFullscreen();\n } else {\n this._requestFullscreen();\n }\n };\n\n _exitFullscreen() {\n if (window.document.exitFullscreen) {\n (window.document as any).exitFullscreen();\n } else if ((window.document as any).mozCancelFullScreen) {\n (window.document as any).mozCancelFullScreen();\n } else if ((window.document as any).msExitFullscreen) {\n (window.document as any).msExitFullscreen();\n } else if ((window.document as any).webkitCancelFullScreen) {\n (window.document as any).webkitCancelFullScreen();\n } else {\n this._togglePseudoFullScreen();\n }\n }\n\n _requestFullscreen() {\n if (this._container.requestFullscreen) {\n this._container.requestFullscreen();\n } else if ((this._container as any).mozRequestFullScreen) {\n (this._container as any).mozRequestFullScreen();\n } else if ((this._container as any).msRequestFullscreen) {\n (this._container as any).msRequestFullscreen();\n } else if ((this._container as any).webkitRequestFullscreen) {\n (this._container as any).webkitRequestFullscreen();\n } else {\n this._togglePseudoFullScreen();\n }\n }\n\n _togglePseudoFullScreen() {\n this._container.classList.toggle('maplibregl-pseudo-fullscreen');\n this._handleFullscreenChange();\n this._map.resize();\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {IControl} from './control';\nimport type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A `TerrainControl` control contains a button for turning the terrain on and off.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let map = new maplibregl.Map({TerrainControl: false})\n * .addControl(new maplibregl.TerrainControl({\n * source: \"terrain\"\n * }));\n * ```\n */\nexport class TerrainControl implements IControl {\n options: TerrainSpecification;\n _map: Map;\n _container: HTMLElement;\n _terrainButton: HTMLButtonElement;\n\n constructor(options: TerrainSpecification) {\n this.options = options;\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._terrainButton = DOM.create('button', 'maplibregl-ctrl-terrain', this._container);\n DOM.create('span', 'maplibregl-ctrl-icon', this._terrainButton).setAttribute('aria-hidden', 'true');\n this._terrainButton.type = 'button';\n this._terrainButton.addEventListener('click', this._toggleTerrain);\n\n this._updateTerrainIcon();\n this._map.on('terrain', this._updateTerrainIcon);\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('terrain', this._updateTerrainIcon);\n this._map = undefined;\n }\n\n _toggleTerrain = () => {\n if (this._map.getTerrain()) {\n this._map.setTerrain(null);\n } else {\n this._map.setTerrain(this.options);\n }\n this._updateTerrainIcon();\n };\n\n _updateTerrainIcon = () => {\n this._terrainButton.classList.remove('maplibregl-ctrl-terrain');\n this._terrainButton.classList.remove('maplibregl-ctrl-terrain-enabled');\n if (this._map.terrain) {\n this._terrainButton.classList.add('maplibregl-ctrl-terrain-enabled');\n this._terrainButton.title = this._map._getUIString('TerrainControl.disableTerrain');\n } else {\n this._terrainButton.classList.add('maplibregl-ctrl-terrain');\n this._terrainButton.title = this._map._getUIString('TerrainControl.enableTerrain');\n }\n };\n}\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","pointGeometry","Point","x","y","this","prototype","clone","add","p","_add","sub","_sub","multByPoint","_multByPoint","divByPoint","_divByPoint","mult","k","_mult","div","_div","rotate","a","_rotate","rotateAround","_rotateAround","matMult","m","_matMult","unit","_unit","perp","_perp","round","_round","mag","Math","sqrt","equals","other","dist","distSqr","dx","dy","angle","atan2","angleTo","b","angleWith","angleWithSep","cos","sin","convert","Array","isArray","unitbezier","UnitBezier","p1x","p1y","p2x","p2y","cx","bx","ax","cy","by","ay","sampleCurveX","t","sampleCurveY","sampleCurveDerivativeX","solveCurveX","epsilon","undefined","i","x2","abs","d2","t0","t1","solve","supportsOffscreenCanvas","offscreenCanvasDistorted","offscreenCanvasSupported","OffscreenCanvas","getContext","createImageBitmap","bezier","defaultEasing","clamp","n","min","max","wrap","d","w","asyncAll","array","fn","callback","length","remaining","results","error","forEach","item","err","extend","dest","sources","src","pick","properties","id","uniqueId","mapObject","input","iterator","context","output","key","call","filterObject","deepEqual","Object","keys","map","warnOnceHistory","warnOnce","message","console","warn","isCounterClockwise","c","calculateSignedArea","ring","sum","p1","p2","len","j","isWorker","WorkerGlobalScope","self","_isSafari","isSafari","scope","userAgent","navigator","safari","test","match","isImageBitmap","image","ImageBitmap","transparentPngUrl","linkEl","reducedMotionQuery","browser","now","performance","bind","Date","frame","requestAnimationFrame","cancel","cancelAnimationFrame","getImageData","img","padding","getImageCanvasContext","width","height","canvas","window","document","createElement","willReadFrequently","Error","drawImage","resolveURL","path","href","hardwareConcurrency","prefersReducedMotion","matchMedia","matches","DOM","static","props","docStyle","tagName","className","container","el","appendChild","namespaceURI","createElementNS","selectProp","userSelect","style","transformProp","target","type","options","addEventListener","capture","removeEventListener","preventDefault","stopPropagation","suppressClickInternal","setTimeout","rect","getBoundingClientRect","clientX","left","clientLeft","clientY","top","clientTop","touches","points","push","button","node","parentNode","removeChild","documentElement","testProp","config","MAX_PARALLEL_IMAGE_REQUESTS","MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME","MAX_TILE_CACHE_ZOOM_LEVELS","REGISTERED_PROTOCOLS","WORKER_URL","AJAXError","constructor","status","statusText","url","body","super","getReferrer","worker","referrer","location","protocol","parent","getProtocolAction","substring","indexOf","makeFetchRequest","requestParameters","controller","AbortController","request","Request","method","credentials","headers","cache","signal","complete","aborted","set","fetch","response","ok","arrayBuffer","json","text","get","catch","finishRequest","blob","code","abort","makeRequest","actor","send","hasOwnProperty","xhr","XMLHttpRequest","open","responseType","setRequestHeader","withCredentials","onerror","onload","data","JSON","parse","getResponseHeader","Blob","makeXMLHttpRequest","getJSON","getArrayBuffer","sameOrigin","inComingUrl","urlObj","URL","locationObj","host","webpSupported","supported","testSupport","gl","webpCheckComplete","webpImgTest","webpImgTestOnloadComplete","testWebpTextureUpload","glForTesting","texture","createTexture","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","isContextLost","deleteTexture","ImageRequest","ResourceType","imageRequestQueue","currentParallelImageRequests","throttleControlCallbackHandleCounter","throttleControlCallbacks","resetRequestQueue","addThrottleControl","handle","removeThrottleControl","callbackHandle","processQueue","getImage","supportImageRefresh","accept","cancelled","completed","innerRequest","doImageRequest","itemInQueue","reduce","acc","getImageUsingHtmlImage","cacheControl","expires","onImageResponse","HTMLImageElement","Uint8Array","imgBitmap","arrayBufferToImageBitmap","Image","revokeObjectURL","byteLength","createObjectURL","arrayBufferToImage","arrayBufferToCanvasImageSource","imgErr","imgResult","maxImageRequests","allControlKeys","throttleingRequested","isThrottled","numImageRequests","topItemInQueue","shift","requestCancelled","crossOrigin","fetchPriority","RequestManager","transformRequestFn","_transformRequestFn","transformRequest","normalizeSpriteURL","format","extension","urlObject","parts","urlRe","authority","params","split","parseUrl","obj","join","formatUrl","setTransformRequest","_addEventListener","listener","listenerList","_removeEventListener","index","splice","Event","ErrorEvent","Evented","on","_listeners","off","_oneTimeListeners","once","fire","event","listens","listeners","slice","oneTimeListeners","_eventedParent","_eventedParentData","setEventedParent","v8Spec","$version","$root","version","required","values","name","metadata","center","zoom","bearing","default","period","units","pitch","light","terrain","sprite","glyphs","transition","layers","source","source_vector","vector","tiles","bounds","scheme","xyz","tms","minzoom","maxzoom","attribution","promoteId","volatile","source_raster","raster","tileSize","source_raster_dem","encoding","terrarium","mapbox","custom","redFactor","blueFactor","greenFactor","baseShift","source_geojson","geojson","buffer","maximum","minimum","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","source_video","video","urls","coordinates","source_image","layer","fill","line","symbol","circle","heatmap","hillshade","background","layout","paint","layout_background","visibility","visible","none","layout_fill","expression","interpolated","parameters","layout_circle","layout_heatmap","layout_line","butt","square","bevel","miter","requires","layout_symbol","point","auto","never","always","cooperative","viewport","both","tokens","right","bottom","horizontal","vertical","uppercase","lowercase","layout_raster","layout_hillshade","filter_operator","in","all","any","has","within","geometry_type","LineString","Polygon","function","stops","base","property","identity","exponential","interval","categorical","colorSpace","rgb","lab","hcl","function_stop","anchor","position","color","intensity","exaggeration","paint_fill","paint_line","paint_circle","paint_heatmap","paint_symbol","overridable","paint_raster","linear","nearest","paint_hillshade","paint_background","duration","delay","constant","refProperties","deref","derefLayers","create","ref","operations","setStyle","addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setGeoJSONSourceData","setLayerZoomRange","setLayerProperty","setCenter","setZoom","setBearing","setPitch","setSprite","setGlyphs","setTransition","setLight","sourceId","after","commands","command","args","sourcesRemoved","updateSource","canUpdateGeoJSON","before","prop","diffLayerPropertyChanges","layerId","klass","pluckId","indexById","group","ValidationError","identifier","__line__","extendBy","inputs","ExpressionParsingError","Scope","bindings","concat","NullType","kind","NumberType","StringType","BooleanType","ColorType","ObjectType","ValueType","CollatorType","FormattedType","PaddingType","ResolvedImageType","VariableAnchorOffsetCollectionType","array$1","itemType","N","toString$1","valueMemberTypes","checkSubtype","expected","memberType","isValidType","provided","allowedTypes","some","isValidNativeType","verifyType","sample","Xn","Zn","t2","t3","deg2rad","PI","rad2deg","constrainAngle","rgbToLab","r","g","alpha","z","xyz2lab","rgb2xyz","l","pow","labToRgb","isNaN","lab2xyz","xyz2rgb","parseHex","hex","parseInt","padEnd","parseAlpha","asPercentage","validateNumbers","Number","namedColors","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","Color","premultiplied","overwriteGetter","rgba","toLowerCase","trim","namedColorsMatch","startsWith","rgbMatch","_","rp","f1","gp","f2","bp","f3","ap","argFormat","valFormat","maxValue","hslMatch","h","s","hsla","f","hslToRgb","parseCssColor","Infinity","rgbColor","NaN","rgbToHcl","getterKey","lazyValue","defineProperty","toString","transparent","Collator","caseSensitive","diacriticSensitive","locale","sensitivity","collator","Intl","usage","compare","lhs","rhs","resolvedLocale","resolvedOptions","FormattedSection","scale","fontStack","textColor","Formatted","sections","unformatted","isEmpty","section","fromString","Padding","val","stringify","anchors","Set","VariableAnchorOffsetCollection","anchorValue","offsetValue","ResolvedImage","available","validateRGBA","isValue","mixed","typeOf","String","Literal","expectedType","evaluate","eachChild","outputDefined","RuntimeError","toJSON","types$1","string","number","boolean","object","Assertion","floor","parsed","ctx","every","arg","types","Coercion","Boolean","parseColor","pad","coll","num","geometryTypes","EvaluationContext","globals","feature","featureState","formattedSection","_parseColorCache","availableImages","canonical","geometryType","geometry","canonicalID","cached","ParsingContext","registry","isConstantFunc","errors","part","_isConstant","expr","_parse","annotate","typeAnnotation","op","Expr","actual","ec","CollatorExpression","EXTENT","updateBBox","bbox","coord","boxWithinBox","bbox1","bbox2","getTileCoordinates","log","tilesAtZoom","onBoundary","x1","y1","y2","pointWithinPolygon","rings","inside","len2","pointWithinPolygons","polygons","twoSided","q1","q2","x3","y3","det1","det2","lineIntersectPolygon","polygon","v1","v2","lineStringWithinPolygon","lineStringWithinPolygons","getTilePolygon","getTilePolygons","updatePoint","polyBBox","worldSize","halfWorldSize","getTilePoints","pointBBox","shifts","tilePoints","getTileLines","lineBBox","tileLines","tileLine","Within","geometries","features","polygonGeometry","tilePolygon","tilePolygons","pointsWithinPolygons","linesWithinPolygons","Var","boundExpression","CompoundExpression","_evaluate","definition","definitions","availableOverloads","overloads","signature","signatureContext","isExpressionConstant","parsedArgs","argParseFailed","signatures","stringifySignature","actualTypes","isTypeAnnotation","childrenConstant","child","isFeatureConstant","isGlobalPropertyConstant","isStateConstant","findStopLessThanOrEqualTo","lastIndex","currentValue","nextValue","lowerIndex","upperIndex","currentIndex","Step","labels","outputs","label","outputType","labelKey","valueKey","stopCount","out","from","to","interpolate","spaceKey","hue0","chroma0","light0","alphaF","hue1","chroma1","light1","alphaT","hue","chroma","dh","hclToRgb","variableAnchorOffsetCollection","fromValues","toValues","fx","fy","tx","ty","Interpolate","operator","interpolation","lower","upper","exponentialInterpolation","controlPoints","rest","interpolationFactor","outputLower","outputUpper","lowerValue","upperValue","difference","progress","Coalesce","needsAnnotation","requestedImageName","argCount","Let","binding","At","In","needle","haystack","IndexOf","fromIndex","Match","inputType","cases","otherwise","labelContext","MAX_SAFE_INTEGER","Case","branches","Slice","beginIndex","endIndex","isComparableType","eqCollate","makeComparison","compareBasic","compareWithCollator","isOrderComparison","Comparison","hasUntypedArgument","lt","rt","Equals","NotEquals","LessThan","GreaterThan","LessThanOrEqual","GreaterThanOrEqual","NumberFormat","currency","minFractionDigits","maxFractionDigits","minimumFractionDigits","maximumFractionDigits","FormatExpression","firstArg","nextTokenMayBeObject","font","lastExpression","content","evaluatedContent","ImageExpression","evaluatedImageName","Length","expressions","at","case","coalesce","let","literal","var","v","varargs","success","supportsPropertyExpression","spec","supportsZoomExpression","supportsInterpolation","getType","isFunction","identityFunction","createFunction","propertySpec","isColor","zoomAndFeatureDependent","zoomDependent","parseFn","stop","innerFun","hashedStops","categoricalKeyType","evaluateExponentialFunction","evaluateIntervalFunction","evaluateCategoricalFunction","evaluateIdentityFunction","featureFunctions","zoomStops","featureFunctionStops","interpolationType","coalesce$1","keyType","interp","evaluatedLower","evaluatedUpper","register","typeof","heatmapDensity","lineProgress","accumulated","ln2","LN2","pi","E","log10","LN10","ln","log2","asin","acos","atan","ceil","binarySearch","isSupportedScript","upcase","toUpperCase","downcase","StyleExpression","_warningHistory","_evaluator","_defaultValue","_enumValues","evaluateWithoutErrorHandling","isExpression","createExpression","parser","enum","formatted","resolvedImage","getExpectedType","ZoomConstantExpression","_styleExpression","isStateDependent","ZoomDependentExpression","createPropertyExpression","expressionInput","isFeatureConstantResult","isZoomConstant","zoomCurve","findZoomCurve","StylePropertyFunction","specification","_parameters","_specification","serialized","childResult","isExpressionFilter","filterSpec","createFilter","needGeometry","convertFilter$1","compiled","globalProperties","geometryNeeded","convertComparisonOp$1","convertNegation","filters","convertInOp$1","convertHasOp$1","sort","validateConstants","constants","unbundle","valueOf","deepUnbundle","unbundledValue","validateObject","elementSpecs","valueSpec","elementValidators","objectElementValidators","styleSpec","validateSpec","objectKey","elementSpecKey","elementSpec","validateElement","validateArray","arraySpec","validateArrayElement","arrayElementValidator","arrayElementSpec","arrayIndex","validateNumber","validateFunction","functionValueSpec","functionType","stopKeyType","previousStopDomainValue","previousStopDomainZoom","stopDomainValues","isZoomFunction","isPropertyFunction","isZoomAndPropertyFunction","validateFunctionStop","validateStopDomainValue","reportValue","isFinite","validateExpression","expressionContext","expressionObj","propertyKey","propertyType","validateEnum","validateFilter","validateNonExpressionFilter","validateProperty","layerSpec","layerType","transitionMatch","tokenMatch","exec","validatePaintProperty","validateLayoutProperty","validateLayer","otherLayer","sourceType","validateString","validateSource","replace","_a","sourceName","rasterDEM","rasterDEMSpec","rootType","isCustomEncoding","customEncodingKeys","encodingName","includes","validateRasterDEMSource","mapExpr","reduceExpr","validateLight","lightSpec","validateTerrain","terrainSpec","validateSprite","allSpriteIds","allSpriteURLs","VALIDATORS","validate","validateGlyphsUrl","validateStyleMin","sortErrors","injectValidateSpec","validator","wrapCleanErrors","inner","paintProperty","layoutProperty","validateStyle","emitValidationErrors","emitter","hasErrors","TransferableGridIndex","extent","cells","ArrayBuffer","Int32Array","start","end","subarray","bboxesOffset","bboxes","insert","_insertReadonly","uid","_forEachCell","_insertCell","cellIndex","query","intersectionTest","_queryCell","seenUids","cell","u","offset","arg1","arg2","cx1","_convertToCellCoord","cy1","cx2","cy2","_convertFromCellCoord","toArrayBuffer","metadataLength","totalCellLength","grid","transferables","writeable","omit","shallow","_classRegistryKey","isArrayBuffer","serialize","RegExp","isView","view","ImageData","$name","deserialize","ZoomHistory","first","update","floorZ","lastIntegerZoom","lastIntegerZoomTime","lastZoom","lastFloorZoom","unicodeBlockLookup","char","Arabic","Khmer","Hiragana","Katakana","Bopomofo","Kanbun","allowsVerticalWritingMode","chars","charHasUprightVerticalOrientation","charCodeAt","isChar","charInRTLScript","charInSupportedScript","canRenderRTL","stringContainsRTLText","_completionCallback","pluginStatus","pluginURL","triggerPluginCompletionEvent","sendPluginStateToWorker","evented","getRTLTextPluginStatus","downloadRTLTextPlugin","plugin","applyArabicShaping","processBidirectionalText","processStyledBidirectionalText","isLoaded","isLoading","setState","state","isParsed","getPluginURL","EvaluationParameters","fadeDuration","zoomHistory","str","isStringInSupportedScript","rtlTextPlugin","crossFadingFactor","getCrossfadeParameters","fraction","fromScale","toScale","PropertyValue","normalizePropertyExpression","isDataDriven","possiblyEvaluate","TransitionablePropertyValue","transitioned","prior","TransitioningPropertyValue","untransitioned","Transitionable","_properties","_values","defaultTransitionablePropertyValues","getValue","setValue","getTransition","Transitioning","begin","finalValue","easeCubicInOut","defaultTransitioningPropertyValues","PossiblyEvaluated","hasTransition","Layout","defaultPropertyValues","hasValue","PossiblyEvaluatedPropertyValue","isConstant","constantOr","defaultPossiblyEvaluatedValues","DataConstantProperty","interpolationFn","interpolates","DataDrivenProperty","overrides","interpolatedValue","CrossFadedDataDrivenProperty","evaluatedValue","constantValue","_calculate","cameraVal","mid","CrossFadedProperty","ColorRampProperty","Properties","overridableProperties","defaultPropertyValue","defaultTransitionablePropertyValue","TRANSITION_SUFFIX","StyleLayer","_featureFilter","sourceLayer","_unevaluatedLayout","_transitionablePaint","_transitioningPaint","_crossfadeParameters","getLayoutProperty","_validate","getPaintProperty","endsWith","transitionable","isCrossFadedProperty","wasDataDriven","oldValue","_handleSpecialPaintPropertyUpdate","newValue","_handleOverridablePaintPropertyUpdate","isHidden","updateTransitions","recalculate","is3D","isTileClipped","hasOffscreenPass","resize","viewTypes","Int8","Int8Array","Uint8","Int16","Int16Array","Uint16","Uint16Array","Int32","Uint32","Uint32Array","Float32","Float32Array","Struct","structArray","_structArray","_pos1","size","_pos2","_pos4","_pos8","StructArray","isTransferred","capacity","_trim","bytesPerElement","_refreshViews","clear","reserve","oldUint8Array","uint8","createLayout","members","alignment","maxSize","member","typeSize","BYTES_PER_ELEMENT","memberOffset","align","components","StructArrayLayout2i4","int16","emplaceBack","v0","emplace","o2","StructArrayLayout3i6","StructArrayLayout4i8","v3","StructArrayLayout2i4i12","v4","v5","StructArrayLayout2i4ub8","o1","StructArrayLayout2f8","float32","o4","StructArrayLayout10ui20","uint16","v6","v7","v8","v9","StructArrayLayout4i4ui4i24","v10","v11","StructArrayLayout3f12","StructArrayLayout1ul4","uint32","StructArrayLayout6i1ul2ui20","StructArrayLayout2i2i2i12","StructArrayLayout2f1f2i16","StructArrayLayout2ub2f12","StructArrayLayout3ui6","StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48","v12","v13","v14","v15","v16","StructArrayLayout8i15ui1ul2f2ui64","v17","v18","v19","v20","v21","v22","v23","v24","v25","v26","v27","StructArrayLayout1f4","StructArrayLayout1ui2f12","StructArrayLayout1ul2ui8","StructArrayLayout2ui4","StructArrayLayout1ui2","StructArrayLayout4f16","CollisionBoxStruct","anchorPointX","anchorPointY","featureIndex","sourceLayerIndex","bucketIndex","anchorPoint","CollisionBoxArray","PlacedSymbolStruct","anchorX","anchorY","glyphStartIndex","numGlyphs","vertexStartIndex","lineStartIndex","lineLength","segment","lowerSize","upperSize","lineOffsetX","lineOffsetY","writingMode","placedOrientation","hidden","crossTileID","associatedIconIndex","PlacedSymbolArray","SymbolInstanceStruct","rightJustifiedTextSymbolIndex","centerJustifiedTextSymbolIndex","leftJustifiedTextSymbolIndex","verticalPlacedTextSymbolIndex","placedIconSymbolIndex","verticalPlacedIconSymbolIndex","textBoxStartIndex","textBoxEndIndex","verticalTextBoxStartIndex","verticalTextBoxEndIndex","iconBoxStartIndex","iconBoxEndIndex","verticalIconBoxStartIndex","verticalIconBoxEndIndex","numHorizontalGlyphVertices","numVerticalGlyphVertices","numIconVertices","numVerticalIconVertices","useRuntimeCollisionCircles","textBoxScale","collisionCircleDiameter","textAnchorOffsetStartIndex","textAnchorOffsetEndIndex","SymbolInstanceArray","GlyphOffsetArray","getoffsetX","SymbolLineVertexArray","getx","gety","gettileUnitDistanceFromAnchor","TextAnchorOffsetStruct","textAnchor","textOffset0","textOffset1","TextAnchorOffsetArray","FeatureIndexStruct","FeatureIndexArray","PosArray","Pos3dArray","RasterBoundsArray","CircleLayoutArray","FillLayoutArray","FillExtrusionLayoutArray","LineLayoutArray","LineExtLayoutArray","PatternLayoutArray","SymbolLayoutArray","SymbolDynamicLayoutArray","SymbolOpacityArray","CollisionBoxLayoutArray","CollisionCircleLayoutArray","CollisionVertexArray","QuadTriangleArray","TriangleIndexArray","LineIndexArray","LineStripIndexArray","SegmentVector","segments","prepareSegment","numVertices","layoutVertexArray","indexArray","sortKey","MAX_VERTEX_ARRAY_LENGTH","vertexLength","vertexOffset","primitiveOffset","primitiveLength","destroy","vaos","packUint8ToFloat","patternAttributes","module","seed","remainder","bytes","h1","h1b","c1","c2","k1","murmur3","require$$0","murmur2","murmurhashJsModule","exports","FeaturePositionMap","ids","positions","indexed","getNumericId","getPositions","intId","Float64Array","numValue","pivot","swap","arr","tmp","Uniform","Uniform1i","current","uniform1i","Uniform1f","uniform1f","Uniform2f","uniform2f","Uniform3f","uniform3f","Uniform4f","uniform4f","UniformColor","emptyMat4","UniformMatrix4f","uniformMatrix4fv","packColor","ConstantBinder","names","uniformNames","setUniform","uniform","getBinding","CrossFadedConstantBinder","patternFrom","patternTo","pixelRatioFrom","pixelRatioTo","setConstantPatternPositions","posTo","posFrom","pixelRatio","tlbr","uniformName","pos","substr","SourceExpressionBinder","PaintVertexArray","paintVertexAttributes","paintVertexArray","populatePaintArray","newLength","imagePositions","_setPaintValue","updatePaintArray","upload","paintVertexBuffer","updateData","createVertexBuffer","CompositeExpressionBinder","useIntegerZoom","minColor","maxColor","currentZoom","factor","CrossFadedCompositeBinder","zoomInPaintVertexArray","zoomOutPaintVertexArray","_setPaintValues","patterns","imageMin","imageMid","imageMax","tl","br","zoomInPaintVertexBuffer","zoomOutPaintVertexBuffer","ProgramConfiguration","filterProperties","binders","_buffers","paintAttributeNames","propType","isCrossFaded","StructArrayLayout","layoutType","cacheKey","getMaxValue","binder","populatePaintArrays","updatePaintArrays","featureStates","featureMap","vtLayer","dirty","defines","getBinderAttributes","getBinderUniforms","uniforms","getPaintVertexBuffers","getUniforms","locations","setUniforms","binderUniforms","updatePaintBuffers","crossfade","patternVertexBuffer","ProgramConfigurationSet","programConfigurations","needsUpload","_featureMap","_bufferOffset","binderType","defaultLayouts","composite","layoutException","getLayoutException","MAX","BITS","MIN","loadGeometry","toEvaluationFeature","addCircleVertex","extrudeX","extrudeY","CircleBucket","overscaling","layerIds","hasPattern","stateDependentLayerIds","populate","styleLayer","bucketFeatures","circleSortKey","sortFeaturesByKey","evaluationFeature","bucketFeature","addFeature","states","stateDependentLayers","uploadPending","uploaded","layoutVertexBuffer","layoutAttributes","indexBuffer","createIndexBuffer","polygonIntersectsPolygon","polygonA","polygonB","polygonContainsPoint","lineIntersectsLine","polygonIntersectsBufferedPoint","radius","pointIntersectsBufferedLine","polygonIntersectsMultiPolygon","multiPolygon","multiPolygonContainsPoint","lineIntersectsBufferedLine","lineA","lineB","a0","a1","lineSegmentIntersectsLineSegment","b0","b1","radiusSquared","distToSegmentSquared","l2","edgeIntersectsBox","e1","e2","corners","dir","getMaximumPaintValue","bucket","translateDistance","translate","queryGeometry","translateAnchor","pixelsToTileUnits","pt","translated","properties$8","EPSILON","ARRAY_TYPE","glMatrix.ARRAY_TYPE","invert","a00","a01","a02","a03","a10","a11","a12","a13","a20","a21","a22","a23","a30","a31","a32","a33","b00","b01","b02","b03","b04","b05","b06","b07","b08","b09","b10","b11","det","multiply","b2","b3","rotateZ","rad","hypot","arguments","ortho","near","far","lr","bt","nf","mul","transformMat4","sqrLen","CircleStyleLayer","createBucket","queryRadius","circleBucket","queryIntersectsFeature","transform","pixelPosMatrix","translatedPolygon","alignWithMap","transformedPolygon","projectPoint","projectQueryGeometry","transformedSize","transformedPoint","adjustedSize","projectedCenter","vec4.transformMat4","cameraToCenterDistance","HeatmapBucket","properties$7","createImage","channels","Uint8ClampedArray","RangeError","resizeImage","newImage","copyImage","srcImg","dstImg","srcPt","dstPt","srcData","dstData","srcOffset","dstOffset","AlphaImage","RGBAImage","copy","renderColorRamp","evaluationGlobals","resolution","clips","renderPixel","stride","evaluationKey","pxColor","clip","HeatmapStyleLayer","_updateColorRamp","colorRamp","colorRampTexture","heatmapFbo","properties$6","HillshadeStyleLayer","earcut","holeIndices","dim","minX","minY","maxX","maxY","invSize","hasHoles","outerLen","outerNode","linkedList","triangles","prev","list","queue","steiner","getLeftmost","compareX","eliminateHole","eliminateHoles","earcutLinked","clockwise","last","signedArea","insertNode","removeNode","filterPoints","again","area","ear","pass","zOrder","prevZ","nextZ","q","tail","numMerges","pSize","qSize","inSize","sortLinked","indexCurve","isEarHashed","isEar","cureLocalIntersections","splitEarcut","x0","y0","pointInTriangle","minZ","maxZ","intersects","locallyInside","isValidDiagonal","splitPolygon","hole","bridge","hx","hy","qx","mx","my","tanMin","sectorContainsSector","findHoleBridge","bridgeReverse","leftmost","px","py","intersectsPolygon","middleInside","sign","o3","onSegment","a2","Node","an","earcutModule","deviation","polygonArea","trianglesArea","flatten","vertices","holes","dimensions","holeIndex","quickselect","quickselectStep","defaultCompare","exp","sd","classifyRings","maxRings","ccw","compareAreas","patternDependencies","patternProperty","constantPattern","addPatternDependencies","patternFeature","patternPropertyValue","FillBucket","patternFeatures","indexArray2","segments2","fillSortKey","addFeatures","indexBuffer2","triangleSegment","triangleIndex","flattened","lineSegment","lineIndex","indices","properties$5","FillStyleLayer","outlineColor","centroidAttributes","vectortilefeature","VectorTileFeature","pbf","_pbf","_geometry","_keys","readFields","readFeature","tag","readVarint","readTag","cmd","lines","cmdLen","readSVarint","toGeoJSON","coords","project","vectortilelayer","VectorTileLayer","_features","readLayer","readString","readFloat","readDouble","readVarint64","readBoolean","readValueMessage","readTile","vectorTile","VectorTile","require$$1","require$$2","vectorTileFeatureTypes","mvt","FACTOR","addVertex","vertexArray","nx","ny","nz","FillExtrusionBucket","centroidVertexArray","centroidVertexBuffer","centroid","vertexCount","isEntirelyOutside","edgeDistance","isBoundaryEdge","bottomRight","properties$4","FillExtrusionStyleLayer","projectedQueryGeometry","projected","zBase","zTop","projectedBase","projectedTop","baseXZ","baseYZ","baseZZ","baseWZ","topXZ","topYZ","topZZ","topWZ","ringBase","ringTop","sX","sY","sZ","sW","baseZ","baseW","topX","topY","topZ","topW","projectExtrusion","closestDistance","getIntersectionDistance","topA","face","checkIntersection","dot","projectedFace","ab","ac","dotABAB","dotABAC","dotACAC","dotAPAB","dotAPAC","denom","distance","lineLayoutAttributes","lineLayoutAttributesExt","COS_HALF_SHARP_CORNER","MAX_LINE_DISTANCE","LINE_DISTANCE_BUFFER_BITS","LineBucket","lineClipsArray","gradients","layoutVertexArray2","maxLineLength","lineSortKey","patternBucketFeature","layoutVertexBuffer2","layoutAttributesExt","lineFeatureClips","cap","miterLimit","roundLimit","lineClips","addLine","scaledDistance","totalDistance","updateScaledDistance","isPolygon","sharpCornerOffset","currentVertex","prevVertex","nextVertex","prevNormal","nextNormal","joinNormal","cosAngle","cosHalfAngle","miterLength","approxAngle","isSharpCorner","lineTurnsLeft","prevSegmentLength","newPrevVertex","updateDistance","addCurrentVertex","middleVertex","currentJoin","bevelLength","offsetA","offsetB","extrude","addHalfVertex","nextSegmentLength","newCurrentVertex","normal","endLeft","endRight","rightX","rightY","up","linesofarScaled","properties$3","LineFloorwidthProperty","lineFloorwidthProperty","LineStyleLayer","gradientVersion","gradientExpression","stepInterpolant","isZoomExpression","lineBucket","getLineWidth","halfWidth","lineOffset","newRings","ringIndex","newRing","aToB","bToC","offsetLine","multiLine","polygonIntersectsBufferedMultiLine","lineWidth","lineGapWidth","symbolLayoutAttributes","dynamicLayoutAttributes","collisionVertexAttributes","collisionBoxLayout","collisionCircleLayout","transformText","toLocaleUpperCase","toLocaleLowerCase","transformTextInternal","verticalizedCharacterMap","$","Pbf","ieee754","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","buf","Varint","Fixed64","Bytes","Fixed32","SHIFT_LEFT_32","SHIFT_RIGHT_32","utf8TextDecoder","TextDecoder","readPackedEnd","toNum","low","high","isSigned","makeRoomForExtraLength","startPos","extraLen","realloc","writePackedVarint","writeVarint","writePackedSVarint","writeSVarint","writePackedFloat","writeFloat","writePackedDouble","writeDouble","writePackedBoolean","writeBoolean","writePackedFixed32","writeFixed32","writePackedSFixed32","writeSFixed32","writePackedFixed64","writeFixed64","writePackedSFixed64","writeSFixed64","readUInt32","writeInt32","readInt32","readField","skip","readMessage","readFixed32","readSFixed32","readFixed64","readSFixed64","readVarintRemainder","decode","readUtf8TextDecoder","bytesPerSequence","fromCharCode","readUtf8","readBytes","readPackedVarint","readPackedSVarint","readPackedBoolean","readPackedFloat","readPackedDouble","readPackedFixed32","readPackedSFixed32","readPackedFixed64","readPackedSFixed64","writeTag","finish","writeBigVarintLow","lsb","writeBigVarintHigh","writeBigVarint","writeString","lead","writeUtf8","writeBytes","writeRawMessage","writeMessage","writeBytesField","writeFixed32Field","writeSFixed32Field","writeFixed64Field","writeSFixed64Field","writeVarintField","writeSVarintField","writeStringField","writeFloatField","writeDoubleField","writeBooleanField","border","readFontstacks","readFontstack","bitmap","advance","readGlyph","metrics","glyph","potpack","boxes","maxWidth","box","spaces","space","pop","ImagePosition","paddedRect","stretchX","stretchY","displaySize","IMAGE_PADDING","WritingMode","getAnchorAlignment","horizontalAlign","verticalAlign","icons","iconPositions","patternPositions","haveRenderCallbacks","bins","addImages","bin","images","hasRenderCallback","patchUpdatedImages","imageManager","dispatchRenderCallbacks","updatedImages","patchUpdatedImage","SIZE_PACK_FACTOR","MAX_PACKED_SIZE","getSizeData","tileZoom","layoutSize","minZoom","maxZoom","minSize","evaluateSizeForFeature","sizeData","uSize","uSizeT","evaluateSizeForZoom","getOverlapMode","overlapProp","allowOverlapProp","overlap","shaderOpacityAttributes","ox","oy","sizeVertex","isSDF","pixelOffsetX","pixelOffsetY","minFontScaleX","minFontScaleY","aSizeX","aSizeY","addDynamicAttributes","dynamicLayoutVertexArray","containsRTLText","formattedText","SymbolBuffers","opacityVertexArray","hasVisibleVertices","placedSymbolArray","dynamicIndexBuffer","dynamicLayoutVertexBuffer","opacityVertexBuffer","itemSize","CollisionBuffers","LayoutArray","IndexArray","collisionVertexArray","collisionVertexBuffer","SymbolBucket","collisionBoxArray","hasRTLText","sortKeyRanges","collisionCircleArray","placementInvProjMatrix","mat4.identity","placementViewportMatrix","unevaluatedLayoutValues","textSizeData","iconSizeData","canOverlap","sortFeaturesByY","writingModes","wm","sourceID","createArrays","icon","glyphOffsetArray","lineVertexArray","symbolInstances","textAnchorOffsets","calculateGlyphDependencies","stack","textAlongLine","allowVerticalPlacement","doesAllowVerticalWritingMode","verticalChar","charAt","textFont","textField","iconImage","hasText","hasIcon","symbolSortKey","iconDependencies","stacks","glyphDependencies","resolvedTokens","getValueAndResolveTokens","factory","globalRTLTextPlugin","sectionFont","sectionStack","leftIndex","rightIndex","mergedFeatures","mergedIndex","mergeFromRight","leftKey","rightKey","geom","mergeFromLeft","getKey","onRight","mergeLines","hasDebugData","textCollisionBox","iconCollisionBox","destroyDebugData","addToLineVertexArray","sumForwardLength","sumBackwardLength","tileUnitDistanceFromAnchor","vertex","addSymbols","arrays","quads","alongLine","labelAnchor","glyphOffsetArrayStart","tr","bl","tex","pixelOffsetTL","pixelOffsetBR","glyphOffset","sectionIndex","_addCollisionDebugVertex","addCollisionDebugVertices","boxAnchorPoint","symbolInstance","addDebugCollisionBoxes","startIndex","isText","generateCollisionDebugBuffers","_deserializeCollisionBoxesForSymbol","textStartIndex","textEndIndex","verticalTextStartIndex","verticalTextEndIndex","iconStartIndex","iconEndIndex","verticalIconStartIndex","verticalIconEndIndex","collisionArrays","textBox","textFeatureIndex","verticalTextBox","verticalTextFeatureIndex","iconBox","iconFeatureIndex","verticalIconBox","verticalIconFeatureIndex","deserializeCollisionBoxes","hasTextData","hasIconData","hasTextCollisionBoxData","hasIconCollisionBoxData","addIndicesForPlacedSymbol","iconOrText","placedSymbolIndex","placedSymbol","vertexIndex","getSortedSymbolIndexes","sortedAngle","symbolInstanceIndexes","rotatedYs","featureIndexes","aIndex","bIndex","addToSortKeyRanges","symbolInstanceIndex","symbolInstanceEnd","symbolInstanceStart","sortFeatures","featureSortOrder","MAX_GLYPHS","properties$2","runtimeType","getOverride","o","hasOverride","FormatSectionOverride","defaultValue","SymbolStyleLayer","deduped","_setPaintOverrides","unevaluated","resolveTokens","hasPaintOverride","overriden","override","styleExpression","propertyName","hasOverrides","checkSections","checkExpression","properties$1","BackgroundStyleLayer","RasterStyleLayer","CustomStyleLayer","implementation","onAdd","painter","onRemove","renderingMode","prerender","createStyleLayer","coerceSpriteToArray","resultArray","dedupArray","doOnceCompleted","callbackFunc","jsonsMap","imagesMap","expectedResultCounter","spriteName","sdf","spriteData","Texture","useMipmap","pixelStoreUnpackFlipY","pixelStoreUnpack","pixelStoreUnpackPremultiplyAlpha","premultiply","HTMLCanvasElement","HTMLVideoElement","texSubImage2D","isSizePowerOfTwo","generateMipmap","minFilter","LINEAR_MIPMAP_NEAREST","LINEAR","texParameteri","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","renderStyleImage","userImage","render","ImageManager","callbackDispatchedThisFrame","loaded","requestors","atlasImage","setLoaded","_notify","addImage","valid","_validateStretch","_validateContent","stretch","updateImage","oldImage","removeImage","listImages","getImages","hasAllDependencies","getPixelSize","getPattern","pattern","_updatePatternAtlas","atlasTexture","CLAMP_TO_EDGE","dst","beginFrame","INF","edt","gridSize","edt1d","qr","GlyphManager","requestManager","localIdeographFontFamily","entries","setURL","getGlyphs","entry","requests","ranges","_tinySDF","range","loadGlyphRange","_doesCharSupportLocalGlyph","cb","fontFamily","tinySDF","fontWeight","TinySDF","fontSize","cutoff","draw","glyphWidth","glyphHeight","glyphLeft","glyphTop","glyphAdvance","isDoubleResolution","fontstack","urlTemplate","Glyphs","Protobuf","parseGlyphPbf","fontStyle","_createCanvas","textBaseline","textAlign","fillStyle","gridOuter","gridInner","actualBoundingBoxAscent","actualBoundingBoxDescent","actualBoundingBoxLeft","actualBoundingBoxRight","measureText","clearRect","fillText","imgData","LightPositionProperty","azimuthal","polar","sphericalToCartesian","lightProperties","Light","lightOptions","_transitionable","_transitioning","getLight","LineAtlas","nextRow","dashEntry","getDash","dasharray","addDash","getDashRanges","lineAtlasWidth","isDash","zeroLength","currentDashLength","dashLength","addRoundDash","halfStretch","currIndex","distLeft","distRight","minDist","signedDistance","distMiddle","distEdge","addRegularDash","ALPHA","REPEAT","ThrottledInvoker","_callback","_triggered","MessageChannel","_channel","port2","onmessage","trigger","port1","postMessage","remove","Actor","mapId","receive","targetMapId","tasks","cancelCallbacks","mustQueue","taskQueue","invoker","processTask","process","task","callbacks","globalScope","random","buffers","hasCallback","sourceMapId","transfer","responseMessage","getWorkerSource","Dispatcher","workerPool","actors","currentActor","workers","acquire","broadcast","getActor","mapRemoved","release","loadTileJson","tileJSON","vector_layers","vectorLayers","vectorLayerIds","Source","earthRadius","LngLat","lng","lat","toArray","distanceTo","lngLat","lat1","lat2","lon","LngLatBounds","sw","ne","setSouthWest","setNorthEast","_ne","_sw","sw2","ne2","getCenter","getSouthWest","getNorthEast","getNorthWest","getWest","getNorth","getSouthEast","getEast","getSouth","contains","lnglat","containsLongitude","latAccuracy","lngAccuracy","earthCircumfrence","circumferenceAtLatitude","latitude","mercatorXfromLng","mercatorYfromLat","mercatorZfromAltitude","altitude","lngFromMercatorX","latFromMercatorY","MercatorCoordinate","lngLatLike","toLngLat","toAltitude","meterInMercatorCoordinateUnits","TileBounds","validateBounds","tileID","level","VectorTileSource","dispatcher","eventedParent","load","_loaded","dataType","_tileJSONRequest","_options","_requestManager","sourceCaches","clearTiles","tileBounds","sourceDataType","reparseOverscaled","_collectResourceTiming","collectResourceTiming","hasTile","setSourceProperty","setTiles","setUrl","loadTile","tile","getPixelRatio","Tile","overscaledZ","overscaleFactor","showCollisionBoxes","resourceTiming","_refreshExpiredTiles","setExpiryData","loadVectorData","reloadCallback","abortTile","unloadTile","unloadVectorData","RasterTileSource","roundZoom","expiry","getTileTexture","extTextureFilterAnisotropic","texParameterf","TEXTURE_MAX_ANISOTROPY_EXT","extTextureFilterAnisotropicMax","saveTileTexture","getMercCoords","CanonicalTileID","calculateKey","quadkey","mask","getQuadkey","isChildOf","dz","getTilePoint","UnwrappedTileID","OverscaledTileID","scaledTo","targetZ","zDifference","calculateScaledKey","withWrap","children","sourceMaxZoom","isLessThan","wrapped","unwrapTo","toUnwrapped","_idx","MIN_SAFE_INTEGER","ele","pixels","unpack","getUnpackVector","getPixels","backfillBorder","borderTile","xMin","xMax","yMin","yMax","RasterDEMTileSource","dem","needsHillshadePrepare","needsTerrainPrepare","neighboringTiles","_getNeighboringTiles","rawImageData","VideoFrame","fillRect","isOffscreenCanvasDistorted","timestamp","swapBR","copyTo","destRowOffset","sourceLeft","sourceTop","computeVideoFrameParameters","close","readImageUsingVideoFrame","readImageNow","pxw","nxw","backfilled","demTexture","fbo","GeoJSONSource","_updateWorkerData","_data","_removed","_pendingLoads","workerOptions","geojsonVtOptions","superclusterOptions","minPoints","setData","diff","setClusterOptions","getClusterExpansionZoom","clusterId","getClusterChildren","getClusterLeaves","limit","dataDiff","abandoned","assign","rasterBoundsAttributes","ImageSource","newCoordinates","successCallback","_request","_finishLoading","prepare","boundsBuffer","_boundsArray","boundsSegments","simpleSegment","newTilesLoaded","setCoordinates","cornerCoords","fromLngLat","dMax","getCoordinatesCenterTileID","tileCoords","buckets","VideoSource","muted","onloadstart","getVideo","loop","triggerRepaint","play","readyState","paused","pause","seek","seconds","seekableRange","seekable","currentTime","CanvasSource","getElementById","_hasInvalidDimensions","_playing","animate","getCanvas","registeredSources","getSourceType","getPixelPosMatrix","mat4.create","mat4.translate","mat4.scale","mat4.multiply","calculatePosMatrix","queryRenderedFeatures","sourceCache","styleLayers","serializedLayers","has3DLayer","layerID","queryIncludes3DLayer","maxPitchScaleFactor","tilesIn","sortTilesIn","renderedFeatureLayers","tileIn","wrappedTileID","queryResults","_state","cameraQueryGeometry","wrappedIDLayerMap","wrappedID","wrappedIDLayers","tileFeatures","wrappedIDFeatures","resultFeatures","tileFeature","mergeRenderedFeatureLayers","featureWrapper","getFeatureState","idA","idB","DictionaryCoder","strings","_stringToNumber","_numberToString","encode","GeoJSONFeature","vectorTileFeature","_vectorTileFeature","_z","_x","_y","evaluateProperties","serializedProperties","styleLayerProperties","getBounds","topDownFeatureComparator","grid3D","featureIndexArray","loadVTLayers","vtLayers","vt","rawTileData","sourceLayerCoder","sourceFeatureState","featureFilter","queryPadding","matching","cameraBounds","matching3D","bx1","by1","bx2","by2","boxX1","boxY1","boxX2","boxY2","corner","polygonIntersectsBox","previousIndex","featureGeometry","loadMatchingFeature","filterLayerIDs","layerIDs","bucketLayerIDs","arraysIntersect","sourceLayerName","getId","getState","serializedLayer","intersectionZ","geojsonFeature","layerResult","lookupSymbolFeatures","symbolFeatureIndexes","symbolFeatureIndex","hasLayer","sourceLayerId","timeAdded","fadeEndTime","uses","expirationTime","hasSymbolBuckets","dependencies","rtt","rttCoords","expiredRequestCount","registerFadeDuration","wasRequested","clearTextures","justReloaded","hasData","latestFeatureIndex","latestRawTileData","getLayer","lId","deserializeBucket","imageAtlas","glyphAtlasImage","imageAtlasTexture","glyphAtlasTexture","getBucket","querySourceFeatures","_geojsonTileLayer","patternsLoaded","parsedCC","header","$0","$1","$2","$3","maxAge","parseCacheControl","getTime","isExpired","delta","getExpiryTimeout","setFeatureState","sourceLayerStates","holdingForFade","symbolFadeHoldUntil","symbolFadeFinished","clearFadeHold","setHoldDuration","setDependencies","namespace","dep","hasDependency","namespaces","TileCache","reset","removedData","timeout","clearTimeout","order","expiryTimeout","dataWrapper","_getAndRemoveByKey","getAndRemove","getByKey","dataIndex","setMaxSize","filterFn","removed","SourceFeatureState","stateChanges","deletedStates","updateState","featureId","newState","ft","removeFeatureState","reconciledState","featureDeletions","initializeTileState","coalesceChanges","featuresChanged","layerStates","SourceCache","_sourceLoaded","_paused","reload","_didEmitContent","_sourceErrored","_source","createSource","_tiles","_cache","_unloadTile","_timers","_cacheTimers","_maxTileCacheSize","_maxTileCacheZoomLevels","_loadedParentTiles","_coveredTiles","_updated","used","usedForTerrain","getSource","resume","shouldReload","_shouldReloadOnResume","_loadTile","_abortTile","getIds","compareTileId","getRenderableIds","symbolLayer","renderables","_isIdRenderable","a_","b_","rotatedA","rotatedB","hasRenderableParent","parentTile","findLoadedParent","_reloadTile","_tileLoaded","previousState","refreshedUponExpiration","_setTileReloadTimer","_backfillDEM","borderId","getTileByID","fillBorder","getTile","_retainLoadedChildren","idealTiles","maxCoveringZoom","retain","topmostLoadedID","parentID","minCoveringZoom","parentTileID","_getLoadedTile","updateCacheSize","widthInTiles","heightInTiles","viewDependentMaxSize","handleWrapJump","wrapDelta","_prevLng","idealTileIDs","getVisibleUnwrappedCoordinates","unwrapped","coveringTiles","coveringZoomLevel","maxOverzooming","maxUnderzooming","parents","parent2","noPendingDataEmissions","_updateRetainedTiles","isRasterType","parentsForFading","fadingTiles","_addTile","idealRasterTileIDs","missingTileIDs","retainedId","keysDifference","_fadeDuration","_removeTile","_updateLoadedParentTileCache","releaseSymbolFadeTiles","checked","missingTiles","childCoord","childTile","parentWasRequested","parentId","tileKey","currentId","pointQueryGeometry","tileResults","cameraPointQueryGeometry","getCameraQueryGeometry","pointCoordinate","tileSpaceBounds","tileSpaceQueryGeometry","tileSpaceCameraQueryGeometry","getVisibleCoordinates","posMatrix","reloadTilesForDependencies","aWrap","bWrap","PRELOAD_POOL_ID","WorkerPool","active","workerCount","Worker","numActive","terminate","isPreloaded","availableLogicalProcessors","globalWorkerPool","getGlobalWorkerPool","globalThis","PathInterpolator","points_","padding_","_distances","paddedLength","lerp","distOfCurrentIdx","distToTarget","idxOfPrevPoint","distOfPrevIdx","segmentLength","segmentT","overlapAllowed","overlapA","overlapB","allowed","GridIndex","cellSize","boxCells","circleCells","xCellCount","yCellCount","circleKeys","boxKeys","circles","xScale","yScale","boxUid","circleUid","keysLength","_insertBoxCell","insertCircle","_insertCircleCell","_query","hitTest","overlapMode","predicate","hitTestCircle","_queryCellCircle","queryArgs","boxCell","circleCell","_circleAndRectCollide","_circlesCollide","_convertToXCellCoord","_convertToYCellCoord","r1","r2","bothRadii","circleX","circleY","halfRectWidth","distX","halfRectHeight","distY","getLabelPlaneMatrix","pitchWithMap","rotateWithMap","mat4.rotateZ","labelPlaneMatrix","getGlCoordMatrix","mat4.clone","glCoordMatrix","matrix","getElevation","xyTransformMat4","signedDistanceFromCamera","getPerspectiveRatio","isVisible","anchorPos","clippingBuffer","updateLineLabels","keepUpright","rotateToLine","partiallyEvaluatedSize","symbolSize.evaluateSizeForZoom","placedSymbols","aspectRatio","useVertical","hideGlyphs","perspectiveRatio","symbolSize.evaluateSizeForFeature","pitchScaledFontSize","tileAnchorPoint","projectionCache","projections","offsets","placeUnflipped","placeGlyphsAlongLine","notEnoughRoom","needsFlipping","placeFirstAndLastGlyph","fontScale","flip","glyphEndIndex","lineEndIndex","firstGlyphOffset","lastGlyphOffset","firstPlacedGlyph","placeGlyphAlongLine","lastPlacedGlyph","requiresOrientationChange","firstPoint","lastPoint","placedGlyphs","firstAndLastGlyph","orientationChange","glyphIndex","tileVertexIndex","tileSegmentEnd","projectedVertex","projectTruncatedLineSegment","singleGlyph","previousTilePoint","currentTilePoint","previousProjectedPoint","minimumLength","projectionMatrix","projectedUnitVertex","projectedUnitSegment","projectVertexToViewport","projectionArgs","distanceFromAnchor","previousVertex","direction","absOffsetX","projection","previousLineVertexIndex","transformToOffsetNormal","segmentVector","findOffsetIntersectionPoint","prevToCurrentOffsetNormal","offsetPreviousVertex","offsetCurrentVertex","currentToNextOffsetNormal","offsetNextSegmentBegin","offsetNextSegmentEnd","aDeltaY","aDeltaX","bDeltaY","bDeltaX","denominator","aInterpolation","findLineIntersection","offsetX","anchorSegment","combinedOffsetX","offsetIntersectionPoint","currentSegmentDistance","pathVertices","currentLineSegment","prevToCurrent","segmentAngle","hiddenGlyphAttributes","viewportPadding","CollisionIndex","ignoredGrid","pitchfactor","_pitch","screenRightBoundary","screenBottomBoundary","gridRightBoundary","gridBottomBoundary","perspectiveRatioCutoff","placeCollisionBox","collisionBox","textPixelRatio","collisionGroupPredicate","projectedPoint","projectAndGetPerspectiveRatio","tileToViewport","tlX","tlY","brX","brY","isInsideGrid","offscreen","isOffscreen","placeCollisionCircles","labelToScreenMatrix","showCollisionCircles","circlePixelDiameter","textPixelPadding","placedCollisionCircles","tileUnitAnchorPoint","screenAnchorPoint","projection.project","projection.getPerspectiveRatio","labelPlaneFontScale","labelPlaneAnchorPoint","projection.placeFirstAndLastGlyph","collisionDetected","inGrid","entirelyOffscreen","screenPlaneMin","screenPlaneMax","interpolator","projectedPath","circleDist","screenSpacePath","minPoint","maxPoint","clippedLines","clippedLine","p0","clipLine","seg","numCircles","circlePosition","centerX","centerY","queryRenderedSymbols","viewportQueryGeometry","gridPoint","seenFeatures","featureKey","bucketInstanceId","intersectionTests.polygonIntersectsPolygon","insertCollisionBox","ignorePlacement","collisionGroupID","insertCollisionCircles","collisionCircles","projection.xyTransformMat4","getViewportMatrix","Anchor","TextAnchorEnum","pixelValue","OpacityState","prevState","increment","placed","skipFade","opacity","JointOpacityState","placedText","placedIcon","JointPlacement","CollisionCircleArray","invProjMatrix","viewportMatrix","RetainedQueryData","CollisionGroups","crossSourceCollisions","maxGroupID","collisionGroups","ID","nextGroupID","calculateVariableLayoutShift","textOffset","shiftVariableCollisionBox","shiftX","shiftY","rotatedOffset","Placement","prevPlacement","collisionIndex","placements","opacities","variableOffsets","stale","commitTime","retainedQueryData","collisionCircleArrays","placedOrientations","getBucketParts","sortAcrossTiles","symbolBucket","bucketFeatureIndex","pixelsToTiles","textLabelPlaneMatrix","projection.getLabelPlaneMatrix","glMatrix","projection.getGlCoordMatrix","partiallyEvaluatedTextSize","collisionGroup","attemptAnchorPlacement","textAnchorOffset","textOverlapMode","orientation","placedGlyphBoxes","prevAnchor","markUsedJustification","markUsedOrientation","placeLayerBucketPart","bucketPart","seenCrossTileIDs","textOptional","iconOptional","textAlwaysOverlap","iconOverlapMode","iconAlwaysOverlap","hasIconTextFit","zOrderByViewportY","alwaysShowText","alwaysShowIcon","placeSymbol","placeText","placeIcon","placedVerticalText","placedGlyphCircles","placedIconBoxes","updatePreviousOrientationIfNotPlaced","isPlaced","previousOrientation","prevPlacedOrientation","placeTextForPlacementModes","placeHorizontalFn","placeVerticalFn","placementMode","textAnchorOffsetStart","textAnchorOffsetEnd","placeBox","collisionTextBox","placedFeature","_b","placeBoxForVariableAnchors","collisionIconBox","variableIconBox","placedBox","placementPasses","prevOrientation","prevOffset","placeIconFeature","shiftedIconBox","iconWithoutText","textWithoutIcon","circleArray","symbolIndexes","symbolIndex","mat4.invert","placedAnchor","autoIndex","getAnchorJustification","indexes","horizontalOnly","horizontalIndexes","commit","zoomAtLastRecencyCheck","placementChanged","prevZoomAdjustment","zoomAdjustment","symbolFadeChange","prevOpacities","prevOffsets","prevOrientations","jointPlacement","prevOpacity","jointOpacity","lastPlacementChangeTime","updateLayerOpacities","updateBucketOpacities","duplicateOpacityState","textAllowOverlap","iconAllowOverlap","hasVariablePlacement","defaultOpacityState","addOpacities","PACKED_HIDDEN_OPACITY","opacityState","horizontalHidden","verticalHidden","packedOpacity","packOpacity","symbolHidden","useHorizontal","variableOffset","updateCollisionVertices","verticalIconUsed","instance","hasTransitions","stillRecent","durationAdjustment","setStale","notUsed","shift25","shift24","shift17","shift16","shift9","shift8","shift1","targetBit","opacityBits","LayerPlacement","_sortAcrossTiles","_currentTileIndex","_currentPartIndex","_seenCrossTileIDs","_bucketParts","continuePlacement","placement","shouldPausePlacement","bucketParts","PauseablePlacement","forceFullPlacement","_currentPlacementIndex","_forceFullPlacement","_showCollisionBoxes","_done","isDone","layerTiles","startTime","placementZoom","_inProgressLayer","ARRAY_TYPES","KDBush","magic","versionAndType","ArrayType","nodeSize","numItems","IndexArrayType","arrayTypeIndex","coordsByteSize","idsByteSize","padCoords","_pos","_finished","numAdded","axis","qy","sqDist","select","swapItem","roundingFactor","TileLayerIndex","_symbolsByKey","symbolInstancesByKey","Map","instances","symbols","crossTileIDs","getScaledCoordinates","childTileID","localX","localY","localZ","yWorld","yOffset","findMatches","newTileID","zoomCrossTileIDs","scaledSymbolCoord","thisTileSymbol","getCrossTileIDsLists","CrossTileIDs","maxCrossTileID","generate","CrossTileSymbolLayerIndex","usedCrossTileIDs","zoomIndexes","newZoomIndex","addBucket","removeBucketCrossTileIDs","childIndex","parentIndex","removedBucket","removeStaleBuckets","currentIDs","tilesChanged","CrossTileSymbolIndex","layerIndexes","maxBucketInstanceId","bucketsInCurrentPlacement","layerIndex","symbolBucketsChanged","currentBucketIDs","pruneUnusedLayers","usedLayers","usedLayerMap","usedLayer","_emitValidationErrors","supportedDiffOperations","diffOperations","ignoredDiffOperations","empty","styleKey","emptyStyle","Style","_getMapId","glyphManager","lineAtlas","crossTileSymbolIndex","_spritesImagesIds","_layers","_order","_availableImages","_resetUpdates","_rtlTextPluginCallback","registerForPluginStateChange","elem","_validateLayer","loadURL","previousStyle","_load","loadJSON","loadEmpty","nextState","transformStyle","stylesheet","_loadSprite","_createLayers","setTerrain","dereferencedLayers","_serializedLayers","styledLayer","isUpdate","completion","_spriteRequest","originalSprite","spriteArray","spriteArrayLength","combinedRequestsMap","jsonRequestParameters","SpriteJSON","jsonRequestKey","imageRequestParameters","SpriteImage","imageRequestKey","requst","loadSprite","spriteId","imagesToRemove","_changedImages","imageId","_changed","_unloadSprite","flat","_updatedSources","_serializeByIds","serializedLayersDictionary","_serializedAllLayers","allLayerIds","_checkLoaded","changed","updatedIds","_updatedLayers","removedIds","_removedLayers","_updateWorkerLayers","action","_reloadSource","_clearSource","_updateTilesForChangedImages","_updateTilesForChangedGlyphs","_updatedPaintProps","sourcesUsedBefore","changedImages","_glyphsDidChange","serializedStyle","changes","removeOrAddSourceCommands","diffSources","beforeLayers","beforeOrder","afterOrder","beforeIndex","afterIndex","tracker","clean","beforeLayer","afterLayer","insertBeforeLayerId","lastIndexOf","diffLayers","diffStyles","unimplementedOps","_afterImageUpdated","isSourceLoaded","geojsonSource","layerObject","validateCustomStyleLayer","_layerOrderChanged","_updateLayer","moveLayer","newIndex","getLayersOrder","getFilter","getTerrain","myStyleSheet","_flattenAndSortRenderedFeatures","sourceResults","isLayer3D","features3D","sourceResult","layerFeatures","topmost3D","includedSources","renderedSymbols","bucketQueryData","queryData","bucketSymbols","layerSymbols","sortedA","symbolFeature","layerName","dataTiles","dataID","addSourceType","SourceType","setSourceType","workerSourceURL","_update","_remove","rtlTextPluginEvented","_updateSources","_generateCollisionBoxes","_updatePlacement","placementCommitted","layerBucketsChanged","pauseablePlacement","_releaseSymbolFadeTiles","getResource","getGlyphsUrl","glyphsUrl","addSprite","spriteToAdd","updatedSprite","removeSprite","internalSpriteRepresentation","find","findIndex","getSprite","posAttributes","terrainVert","shaders","prelude","compile","backgroundPattern","clippingMask","heatmapTexture","collisionCircle","debug","fillOutline","fillOutlinePattern","fillPattern","fillExtrusion","fillExtrusionPattern","hillshadePrepare","lineGradient","linePattern","lineSDF","symbolIcon","symbolSDF","symbolTextAndIcon","terrainDepth","terrainCoords","fragmentSource","vertexSource","re","staticAttributes","fragmentUniforms","vertexUniforms","staticUniforms","fragmentPragmas","operation","precision","attrType","unpackType","VertexArrayObject","boundProgram","boundLayoutVertexBuffer","boundPaintVertexBuffers","boundIndexBuffer","boundVertexOffset","boundDynamicVertexBuffer","vao","program","paintVertexBuffers","dynamicVertexBuffer","dynamicVertexBuffer2","dynamicVertexBuffer3","paintBuffersDiffer","boundDynamicVertexBuffer2","boundDynamicVertexBuffer3","freshBind","bindVertexArray","dynamicDraw","numNextAttributes","numAttributes","createVertexArray","enableAttributes","vertexBuffer","setVertexAttribPointers","currentNumAttributes","deleteVertexArray","getTokenizedAttributesAndUniforms","token","Program","configuration","fixedUniforms","showOverdrawInspector","createProgram","staticAttrInfo","dynamicAttrInfo","allAttrInfo","preludeUniformsInfo","staticUniformsInfo","dynamicUniformsInfo","uniformList","allUniformsInfo","fragmentShader","createShader","FRAGMENT_SHADER","failedToCreate","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","getShaderInfoLog","attachShader","vertexShader","VERTEX_SHADER","attributes","uniformLocations","bindAttribLocation","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","deleteShader","it","uniformLocation","getUniformLocation","terrainUniforms","u_depth","u_terrain","u_terrain_dim","u_terrain_matrix","u_terrain_unpack","u_terrain_exaggeration","terrainPreludeUniforms","drawMode","depthMode","stencilMode","colorMode","cullFaceMode","uniformValues","currentProperties","dynamicLayoutBuffer","dynamicLayoutBuffer2","dynamicLayoutBuffer3","setDepthMode","setStencilMode","setColorMode","setCullFace","activeTexture","TEXTURE2","depthTexture","TEXTURE3","primitiveSize","LINES","TRIANGLES","LINE_STRIP","drawElements","UNSIGNED_SHORT","patternUniformValues","tileRatio","numTiles","tileSizeAtNearestZoom","pixelX","pixelY","u_image","u_texsize","u_scale","u_fade","u_pixel_coord_upper","u_pixel_coord_lower","fillExtrusionUniformValues","shouldUseVerticalGradient","_lp","lightPos","lightMat","mat3.create","mat3.fromRotation","vec3.transformMat3","lightColor","u_matrix","u_lightpos","u_lightintensity","u_lightcolor","u_vertical_gradient","u_opacity","fillExtrusionPatternUniformValues","u_height_factor","fillUniformValues","fillPatternUniformValues","fillOutlineUniformValues","drawingBufferSize","u_world","fillOutlinePatternUniformValues","circleUniformValues","extrudeScale","pixelsToGLUnits","u_camera_to_center_distance","u_scale_with_map","translatePosMatrix","u_pitch_with_map","u_device_pixel_ratio","u_extrude_scale","collisionUniformValues","u_pixels_to_tile_units","u_overscale_factor","debugUniformValues","scaleRatio","u_color","u_overlay","u_overlay_scale","clippingMaskUniformValues","heatmapUniformValues","u_intensity","getTileLatRange","lineUniformValues","calculateMatrix","u_ratio","u_units_to_pixels","lineGradientUniformValues","imageHeight","u_image_height","linePatternUniformValues","tileZoomRatio","calculateTileRatio","lineSDFUniformValues","posA","posB","widthA","widthB","u_patternscale_a","u_patternscale_b","u_sdfgamma","u_tex_y_a","u_tex_y_b","u_mix","rasterUniformValues","parentTL","parentScaleBy","fade","u_tl_parent","u_scale_parent","u_buffer_scale","u_fade_t","mix","u_image0","u_image1","u_brightness_low","u_brightness_high","u_saturation_factor","saturation","u_contrast_factor","contrast","u_spin_weights","spinWeights","symbolIconUniformValues","rotateInShader","texSize","u_is_size_zoom_constant","u_is_size_feature_constant","u_size_t","u_size","u_pitch","u_rotate_symbol","u_aspect_ratio","u_fade_change","u_label_plane_matrix","u_coord_matrix","u_is_text","u_texture","symbolSDFUniformValues","isHalo","u_gamma_scale","u_is_halo","symbolTextAndIconUniformValues","texSizeSDF","texSizeIcon","u_texsize_icon","u_texture_icon","backgroundUniformValues","backgroundPatternUniformValues","imagePosA","imagePosB","u_pattern_tl_a","u_pattern_br_a","u_pattern_tl_b","u_pattern_br_b","u_pattern_size_a","u_pattern_size_b","u_scale_a","u_scale_b","u_tile_units_to_pixels","bgPatternUniformValues","programUniforms","u_inv_matrix","u_viewport_size","u_color_ramp","u_latrange","u_light","u_shadow","u_highlight","u_accent","u_dimension","u_zoom","u_unpack","u_ele_delta","u_terrain_coords_id","IndexBuffer","createBuffer","unbindVAO","bindElementBuffer","bufferData","ELEMENT_ARRAY_BUFFER","DYNAMIC_DRAW","STATIC_DRAW","bufferSubData","deleteBuffer","AttributeType","VertexBuffer","bindVertexBuffer","ARRAY_BUFFER","attribIndex","enableVertexAttribArray","vertexAttribPointer","WeakMap","isWebGL2","getParameter","VERSION","BaseValue","getDefault","setDefault","ClearColor","clearColor","ClearDepth","clearDepth","ClearStencil","clearStencil","ColorMask","colorMask","DepthMask","depthMask","StencilMask","stencilMask","StencilFunc","func","ALWAYS","stencilFunc","StencilOp","KEEP","stencilOp","StencilTest","enable","STENCIL_TEST","disable","DepthRange","depthRange","DepthTest","DEPTH_TEST","DepthFunc","LESS","depthFunc","Blend","BLEND","BlendFunc","ONE","ZERO","blendFunc","BlendColor","blendColor","BlendEquation","FUNC_ADD","blendEquation","CullFace","CULL_FACE","CullFaceSide","BACK","cullFace","FrontFace","CCW","frontFace","ProgramValue","useProgram","ActiveTextureUnit","TEXTURE0","Viewport","drawingBufferWidth","drawingBufferHeight","BindFramebuffer","bindFramebuffer","FRAMEBUFFER","BindRenderbuffer","bindRenderbuffer","RENDERBUFFER","BindTexture","BindVertexBuffer","bindBuffer","BindElementBuffer","BindVertexArray","getExtension","bindVertexArrayOES","PixelStoreUnpack","pixelStorei","UNPACK_ALIGNMENT","PixelStoreUnpackPremultiplyAlpha","UNPACK_PREMULTIPLY_ALPHA_WEBGL","PixelStoreUnpackFlipY","UNPACK_FLIP_Y_WEBGL","FramebufferAttachment","ColorAttachment","setDirty","framebufferTexture2D","COLOR_ATTACHMENT0","DepthAttachment","framebufferRenderbuffer","DEPTH_ATTACHMENT","DepthStencilAttachment","DEPTH_STENCIL_ATTACHMENT","Framebuffer","hasDepth","hasStencil","framebuffer","createFramebuffer","colorAttachment","depthAttachment","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","renderbuffer","deleteRenderbuffer","deleteFramebuffer","ColorMode","blendFunction","Replace","disabled","unblended","alphaBlended","Context","stencilTest","depthTest","blend","cullFaceSide","MAX_TEXTURE_MAX_ANISOTROPY_EXT","maxTextureSize","MAX_TEXTURE_SIZE","HALF_FLOAT","extColorBufferHalfFloat","RGBA16F","RGBA16F_EXT","RGB16F","RGB16F_EXT","extTextureHalfFloat","HALF_FLOAT_OES","createRenderbuffer","storageFormat","rbo","renderbufferStorage","depth","stencil","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT","mode","fail","depthFail","createVertexArrayOES","deleteVertexArrayOES","DepthMode","ReadOnly","ReadWrite","StencilMode","CullFaceMode","quadTriangles","drawCollisionDebug","tileBatches","circleCount","circleOffset","invTransform","mat4.mul","colorModeForRenderPass","getTerrainData","circleProgram","vertexData","batch","circleIdx","collision","quadCount","triCount","idx","createQuadTriangles","backCCW","identityMat4","calculateVariableRenderShift","renderTextSize","updateVariableAnchorsForBucket","tileScale","updateTextFitIcon","dynamicTextLayoutVertexArray","dynamicIconLayoutVertexArray","placedTextShifts","tileAnchor","projectedAnchor","symbolProjection.project","symbolProjection.getPerspectiveRatio","tilePixelRatio","shiftedAnchor","symbolProjection.hideGlyphs","placedIcons","getSymbolProgramName","iconsInText","drawLayerSymbols","rotationAlignment","pitchAlignment","hasSortKey","depthModeForSublayer","tileRenderState","programConfiguration","sdfIcons","transformed","terrainData","atlasInterpolation","atlasInterpolationIcon","atlasTextureIcon","rotating","zooming","NEAREST","iconScaled","iconsNeedLinear","symbolProjection.getLabelPlaneMatrix","symbolProjection.getGlCoordMatrix","hasVariableAnchors","symbolProjection.updateLineLabels","uLabelPlaneMatrix","uglCoordMatrix","hasHalo","oldSegments","segmentState","TEXTURE1","drawSymbolElements","updatePatternPositionsInProgram","drawFillTiles","isOutline","fillPropertyName","programName","terrainCoord","tileMatrix","stencilModeForClipping","drawExtrusionTiles","renderHillshade","shadow","highlight","accent","moving","hillshadeUniformValues","rasterBoundsBuffer","quadTriangleIndexBuffer","rasterBoundsSegments","prepareHillshade","textureStride","pixelData","renderTexture","mat4.ortho","hillshadeUniformPrepareValues","getFadeValues","sinceTile","sinceParent","idealZ","fadeIn","childOpacity","topColor","btmColor","leftColor","rightColor","centerColor","drawHorizontalLine","drawDebugSSRect","drawVerticalLine","SCISSOR_TEST","scissor","drawDebugTile","tileRawData","tileSizeKb","tileIdText","initDebugOverlayCanvas","debugOverlayCanvas","ctx2d","shadowColor","shadowBlur","strokeStyle","strokeText","debugOverlayTexture","drawTextToOverlay","debugBuffer","debugSegments","tileBorderIndexBuffer","drawTerrain","LEQUAL","depthRangeFor3D","mesh","getTerrainMesh","renderToTexture","getTexture","getMeshFrameDelta","Painter","_tileTextures","terrainFacilitator","renderTime","setup","numSublayers","depthEpsilon","tileExtentArray","tileExtentBuffer","tileExtentSegments","debugArray","rasterBoundsArray","viewportArray","viewportBuffer","viewportSegments","tileLineStripIndices","quadTriangleIndices","stencilClearMode","nextStencilID","currentStencilSource","_renderTileClippingMasks","tileIDs","_tileClippingMaskIDs","REPLACE","stencilModeFor3D","NOTEQUAL","EQUAL","stencilConfigForOverlap","minTileZ","stencilValues","zToStencilMode","GEQUAL","_showOverdrawInspector","CONSTANT_COLOR","renderPass","opaquePassEnabledForLayer","currentLayer","opaquePassCutoff","coordsAscending","coordsDescending","coordsDescendingSymbol","reverse","prepareForRender","newTiles","tilesAfterTime","a3","a4","a5","a6","a7","a8","a9","a14","a15","projMatrix","b4","b5","b6","b7","b8","b9","b12","b13","b14","b15","glMatrix.EPSILON","mat4.copy","getRenderableTiles","getFramebuffer","devicePixelRatio","drawDepth","getCoordsTexture","coordsIndex","drawCoords","renderLayer","showTileBoundaries","selectedSource","flatMap","vectorSources","otherSources","considerSource","selectDebugSource","drawDebug","showPadding","centerPoint","drawCrosshair","drawDebugPadding","pixelToTileScale","updateVariableAnchors","drawSymbols","strokeWidth","strokeOpacity","segmentsRenderStates","segmentsState","drawCircles","numType","internalFormat","bindTextureToFramebuffer","textureUnit","colorRampUnit","heatmapTextureUniformValues","renderTextureToMap","drawHeatmap","gradient","programId","firstTile","prevProgram","programChanged","atlas","layerGradient","gradientTexture","textureResolution","potentialOverzoom","drawLine","drawFill","drawFillExtrusion","stencilModes","drawHillshade","textureFilter","drawRaster","isPatternMissing","drawBackground","setCustomLayerDefaults","customLayerMatrix","setBaseState","drawCustom","inViewportPixelUnitsUnits","sinA","cosA","translation","translatedMatrix","textures","overLimit","Frustum","planes","invProj","frustumCoords","vec4.mul","frustumPlanes","vec3.normalize","az","bz","vec3.cross","vec3.sub","Aabb","min_","max_","vec3.scale","vec3.add","quadrant","qMin","vec3.clone","qMax","distanceX","distanceY","frustum","aabbPoints","fullyInside","plane","pointsInside","projMin","MAX_VALUE","projMax","EdgeInsets","Transform","minPitch","maxPitch","renderWorldCopies","maxValidLatitude","_renderWorldCopies","_minZoom","_maxZoom","_minPitch","_maxPitch","setMaxBounds","_center","_elevation","_fov","_unmodified","_edgeInsets","_posMatrixCache","_alignedPosMatrixCache","_minEleveationForCurrentTile","that","latRange","_calcMatrices","centerOffset","rotationMatrix","mat2.create","mat2.rotate","fov","_zoom","constrainedZoom","zoomScale","_constrain","elevation","isPaddingEqual","interpolatePadding","scaleZoom","utl","utr","ubl","ubr","w0","w1","extraWorldCopy","actualZ","cameraCoord","getCameraPoint","centerCoord","cameraPoint","cameraFrustum","fromInvProjectionMatrix","radiusOfMaxLvlLodInTiles","newRootTile","aabb","fullyVisible","intersectResult","refPoint","longestDim","distanceSq","vec2.sqrLen","tileDistanceToCamera","childX","childY","childZ","minMax","getMinMaxElevation","minElevation","maxElevation","unmodified","unproject","getCameraPosition","pointLocation","_pixelPerMeter","recalculateZoom","getElevationForLngLatZoom","cameraPosition","camera","setLocationAtPoint","loc","locationCoordinate","newCenter","coordinateLocation","locationPoint","coordinatePoint","pixelMatrix3D","coordinate","coord0","coord1","pixelMatrixInverse","z0","z1","pixelMatrix","getHorizon","getMaxBounds","lngRange","unwrappedTileID","aligned","posMatrixKey","unwrappedX","alignedProjMatrix","mercatorMatrix","_constraining","sy","sx","h2","w2","cameraToSeaLevelDistance","cameraToLowestPointDistance","lowestPlane","groundAngle","fovAboveCenter","topHalfSurfaceDistance","horizon","fovCenterToHorizon","topHalfSurfaceDistanceHorizon","topHalfMinDistance","farZ","nearZ","fovy","aspect","mat4.perspective","mat4.rotateX","xShift","yShift","angleCos","angleSin","alignedM","throttle","time","lastCallArgs","pending","timerId","lastCallContext","later","Hash","hashName","_getCurrentHash","hash","_hashName","keyval","_onHashChange","_map","dragRotate","isEnabled","touchZoomRotate","getBearing","jumpTo","_updateHashUnthrottled","getHashString","history","replaceState","SecurityError","_updateHash","encodeURIComponent","addTo","mapFeedback","getZoom","getPitch","found","defaultInertiaOptions","linearity","easing","defaultPanInertiaOptions","deceleration","maxSpeed","defaultZoomInertiaOptions","defaultBearingInertiaOptions","defaultPitchInertiaOptions","HandlerInertia","_inertiaBuffer","record","settings","_drainInertiaBuffer","inertia","_onMoveEnd","panInertiaOptions","deltas","pan","pinchAround","around","zoomDelta","bearingDelta","pitchDelta","panDelta","easeOptions","calculateEasing","amount","extendDuration","noMoveStart","inertiaDuration","inertiaOptions","speed","MapMouseEvent","_defaultPrevented","defaultPrevented","originalEvent","mousePos","getCanvasContainer","MapTouchEvent","changedTouches","touchPos","lngLats","curr","MapWheelEvent","MapEventHandler","_clickTolerance","clickTolerance","_mousedownPos","wheel","_firePreventable","mousedown","mouseup","click","dblclick","mouseover","mouseout","touchstart","touchmove","touchend","touchcancel","mapEvent","isActive","BlockableMapEventHandler","_delayContextMenu","_ignoreContextMenu","_contextMenuEvent","mousemove","contextmenu","TransformProvider","_requestedCameraState","BoxZoomHandler","_tr","_el","_container","getContainer","_enabled","_active","shiftKey","disableDrag","_startPos","_lastPos","mousemoveWindow","_box","classList","_fireEvent","setTransform","mouseupWindow","suppressClick","cameraAnimation","fitScreenCoordinates","keydown","keyCode","enableDrag","indexTouches","SingleTapRecognizer","numTouches","mapTouches","timeStamp","getCentroid","newTouches","TapRecognizer","singleTap","numTaps","lastTime","lastTap","count","tap","soonEnough","closeEnough","TapZoomHandler","_zoomIn","_zoomOut","zoomInPoint","zoomOutPoint","easeTo","DragHandler","_moveStateManager","moveStateManager","_moveFunction","move","_activateOnStart","activateOnStart","assignEvents","_moved","_lastPoint","endMove","_move","dragStart","isValidStartEvent","startMove","dragMove","isValidMoveEvent","movePoint","dragEnd","isValidEndEvent","getClickTolerance","BUTTONS_FLAGS","MouseMoveStateManager","_correctEvent","checkCorrectEvent","eventButton","mouseButton","_eventButton","_e","flag","buttons","buttonNoLongerPressed","OneFingerTouchMoveStateManager","_firstTouch","_isOneFingerTouch","targetTouches","_isSameTouchEvent","handler","generateMouseRotationHandler","bearingDegreesPerPixelMoved","mouseMoveStateManager","ctrlKey","generateMousePitchHandler","pitchDegreesPerPixelMoved","TouchPanHandler","_minTouches","cooperativeGestures","_touches","_sum","_cancelCooperativeMessage","_calculateTransform","_cooperativeGestures","_onCooperativeGesture","touchPointSum","touchDeltaSum","touchDeltaCount","prevPoint","TwoFingersTouchHandler","_firstTwoTouches","_start","getTouchById","_aroundCenter","getZoomDelta","lastDistance","TwoFingersTouchZoomHandler","_distance","_startDistance","getBearingDelta","TwoFingersTouchRotateHandler","_minDiameter","_startVector","_vector","lastVector","_isBelowThreshold","threshold","bearingDeltaSinceStart","isVertical","TwoFingersTouchPitchHandler","_valid","_firstMove","_lastPoints","_currentTouchCount","vectorA","vectorB","gestureBeginsVertically","movedA","movedB","isSameDirection","defaultOptions","panStep","bearingStep","pitchStep","KeyboardHandler","stepOptions","_panStep","_bearingStep","_pitchStep","_rotationDisabled","altKey","metaKey","zoomDir","bearingDir","pitchDir","xDir","yDir","easeId","easeOut","disableRotation","enableRotation","wheelZoomDelta","ScrollZoomHandler","triggerRenderFrame","_onTimeout","initialEvent","_type","_delta","_lastValue","_triggerRenderFrame","_defaultZoomRate","_wheelZoomRate","setZoomRate","zoomRate","setWheelZoomRate","wheelZoomRate","_finishTimeout","isZooming","_zooming","_metaKey","deltaMode","WheelEvent","DOM_DELTA_LINE","deltaY","timeDelta","_lastWheelEventTime","_timeout","_lastWheelEvent","_frameId","_around","_aroundPoint","renderFrame","_targetZoom","_startZoom","_easing","_smoothOutEasing","targetZoom","startZoom","finished","noInertia","needsRenderFrame","_prevEase","currentEase","DoubleClickZoomHandler","clickZoom","TapZoom","_clickZoom","_tapZoom","ClickZoomHandler","TapDragZoomHandler","_tap","_swipePoint","_swipeTouch","_tapTime","_tapPoint","swipePoint","newSwipePoint","DragPanHandler","mousePan","touchPan","_mousePan","_touchPan","_inertiaOptions","DragRotateHandler","mouseRotate","mousePitch","_pitchWithRotate","pitchWithRotate","_mouseRotate","_mousePitch","TwoFingersTouchZoomRotateHandler","touchZoom","touchRotate","tapDragZoom","_touchZoom","_touchRotate","_tapDragZoom","isMoving","drag","RenderFrameEvent","hasChange","HandlerManager","handleWindowEvent","handleEvent","eventName","_updatingCamera","inputEvent","mergedHandlerResult","eventsInProgress","activeHandlers","eventTouches","_getMapTouches","handlerName","_handlers","_blockedByActive","mergeHandlerResult","deactivatedHandlers","_previousActiveHandlers","_changes","_stop","_inertia","_fireEvents","_handlersById","_bearingSnap","bearingSnap","_eventsInProgress","_addDefaultHandlers","passive","listenerOptions","boxZoom","interactive","tapZoom","doubleClickZoom","touchPitch","generateMousePanHandler","dragPan","scrollZoom","keyboard","allowEndAnimation","isRotating","myName","handlerResult","eventData","_applyChanges","combined","combinedEventsInProgress","combinedDeactivatedHandlers","change","_updateMapTransform","combinedResult","_getTransformForUpdate","_terrainMovement","_elevationFreeze","_applyUpdatedTransform","newEventsInProgress","wasMoving","nowMoving","startEvents","endEvents","originalEndEvent","stillMoving","inertialEase","shouldSnapToNorth","essential","resetNorth","freezeElevation","_requestFrame","_renderTaskQueue","Camera","_renderFrameCallback","_easeStart","_easeOptions","_onEaseFrame","_easeFrameId","_requestRenderFrame","_moving","panBy","panTo","zoomTo","zoomIn","zoomOut","getPadding","setPadding","rotateTo","resetNorthPitch","snapToNorth","cameraForBounds","_cameraForBoxAndBearing","defaultPadding","edgePadding","p0world","p1world","p0rotated","p1rotated","upperRight","lowerLeft","scaleX","scaleY","rotatedPaddingOffset","offsetAtFinalZoom","fitBounds","_fitInternal","calculatedOptions","flyTo","zoomChanged","bearingChanged","pitchChanged","calculateCameraOptionsFromTo","altitudeFrom","altitudeTo","fromMerc","toMerc","distance3D","groundDistance","startBearing","startPitch","startPadding","_normalizeBearing","offsetAsPoint","pointAtOffset","locationAtOffset","_normalizeCenter","finalScale","aroundPoint","currently","_rotating","pitching","_pitching","_padding","_easeId","_prepareEase","_prepareElevation","_ease","_updateElevation","speedup","_fireMoveEvents","interruptingEaseId","_finalizeElevation","_afterEase","_elevationCenter","_elevationStart","_elevationTarget","getMinTileElevationForLngLatZoom","pitch1","transformCameraUpdate","nextTransform","wasZooming","wasRotating","wasPitching","coercedOptions","curve","rho","u1","wMax","rho2","zoomOutFactor","descent","sinh","cosh","r0","S","screenSpeed","maxDuration","isEasing","allowGestures","_cancelRenderFrame","_onEaseEnd","onEaseEnd","handlers","currentBearing","queryTerrainElevation","AttributionControl","_toggleAttribution","setAttribute","removeAttribute","_updateData","_updateAttributions","_updateCompact","offsetWidth","_compact","_updateCompactMinimize","getDefaultPosition","compact","_compactButton","_setElementTitle","_innerContainer","_attribHTML","element","title","_getUIString","attributions","customAttribution","styleOwner","owner","styleId","attrib","attribHTML","innerHTML","_editLink","LogoControl","containerChildren","rel","display","TaskQueue","_queue","_id","_cleared","_currentlyRunning","running","run","PerformanceMarkers","lastFrameTime","frameTimes","frameTimeTarget","loadTimeKey","fullLoadTimeKey","PerformanceUtils","mark","marker","currTimestamp","clearMetrics","clearMeasures","clearMarks","getPerformanceMetrics","measure","fullLoad","loadTime","getEntriesByName","fullLoadTime","totalFrames","fps","droppedFrames","frameTime","percentDroppedFrames","defaultLocale","pos3dAttributes","TerrainSourceCache","_renderableTilesKeys","_sourceTileCache","deltaZoom","destruct","freeRtt","getTerrainCoords","_tileID","getSourceTile","searchForDEM","Terrain","qualityFactor","meshSize","_demMatrixCache","_coordsTextureSize","getDEMElevation","vec2.transformMat4","mercatorX","mercatorY","_getOverscaledTileIDFromLngLatZoom","_emptyDemTexture","_emptyDepthTexture","_emptyDemUnpack","_emptyDemMatrix","sourceTile","matrixKey","demMatrix","mat4.fromScaling","_fboDepthTexture","_fbo","_fboCoordsTexture","DEPTH_COMPONENT16","_coordsTexture","readPixels","coordsSize","_allowMercatorOverflow","_mesh","meshSize2","offsetTop","offsetBottom","offsetLeft","offsetRight","mercatorCoordinate","tileX","tileY","inLeftHalf","centerLng","RenderPool","_context","_size","_tileSize","_objects","_recentlyUsed","_stamp","_createObject","DEPTH_STENCIL","stamp","inUse","getObjectForId","useObject","stampObject","getOrCreateFreeObject","freeObject","freeAllObjects","isFull","LAYERS","RenderToTexture","pool","_stacks","_prevType","_rttTiles","_renderableTiles","_renderableLayerIds","_coordsDescendingInv","_coordsDescendingInvStr","isLastLayer","packageJSON","attributionControl","maplibreLogo","failIfMajorPerformanceCaveat","preserveDrawingBuffer","trackResize","refreshExpiredTiles","maxTileCacheSize","maxTileCacheZoomLevels","maxCanvasSize","touchmoveWindow","showCompass","showZoom","visualizePitch","MouseRotateWrapper","startMouse","moveMouse","offTemp","startTouch","moveTouch","mapRotateTolerance","mapPitchTolerance","touchMoveStateManager","generateOneFingerTouchRotationHandler","generateOneFingerTouchPitchHandler","supportsGeolocation","smartWrap","priorPos","anchorTranslate","applyAnchorClass","prefix","Marker","_onKeyPress","legacyCode","charCode","togglePopup","_onMapClick","targetElement","_element","_popup","isFullyLoaded","_lngLat","_offset","rotation","_rotationAlignment","_rotation","_pitchAlignment","_anchor","_opacityTimeout","metresPerPixel","_onMove","_isDragging","_pointerdownPos","_positionDelta","setLngLat","pointerEvents","_onUp","_addDragHandler","_color","_scale","_draggable","draggable","_defaultMarker","svg","createNS","defaultHeight","defaultWidth","setAttributeNS","markerLarge","page1","ellipses","rx","ry","ellipse","bgPath","borderPath","maki","circleContainer","circle1","circle2","setDraggable","getLngLat","getElement","setPopup","popup","_originalTabIndex","markerHeight","markerRadius","linearOffset","SQRT2","getAttribute","getPopup","isOpen","getOffset","setOffset","addClassName","removeClassName","toggleClassName","toggle","shouldBeDraggable","isDraggable","setRotation","getRotation","setRotationAlignment","getRotationAlignment","setPitchAlignment","getPitchAlignment","positionOptions","enableHighAccuracy","maximumAge","fitBoundsOptions","trackUserLocation","showAccuracyCircle","showUserLocation","numberOfWatches","noTimeout","updateScale","clientHeight","maxMeters","maxFeet","setScale","maxDistance","pow10","multiplier","getDecimalRoundNum","getRoundNum","closeButton","closeOnClick","focusAfterOpen","focusQuerySelector","normalizeOffset","cornerOffset","convertedOffset","Debug","logToElement","overwrite","MapLibreGL","maxParallelImageRequests","numRequests","workerUrl","customProtocol","loadFn","_cooperativeGesturesOnWheel","_contextLost","_frame","_contextRestored","_setupPainter","_onMapScroll","scrollTop","scrollLeft","_onWindowOnline","_interactive","platform","_failIfMajorPerformanceCaveat","_preserveDrawingBuffer","_antialias","antialias","_trackResize","_crossSourceCollisions","_crossFadingFactor","_controls","_mapId","_locale","_overridePixelRatio","_maxCanvasSize","_imageQueueHandle","HTMLElement","maxBounds","_setupContainer","_idleTriggered","initialResizeEventCaptured","throttledResizeCallback","_resizeObserver","ResizeObserver","observe","_setupCooperativeGestures","_hash","_localIdeographFontFamily","_validateStyle","addControl","logoPosition","control","controlElement","positionContainer","_controlPositions","insertBefore","firstChild","removeControl","ci","hasControl","_containerDimensions","clampedPixelRatio","_getClampedPixelRatio","_resizeCanvas","fireMoving","maxCanvasWidth","maxCanvasHeight","canvasWidth","canvasHeight","setPixelRatio","setMinZoom","getMinZoom","setMaxZoom","getMaxZoom","setMinPitch","getMinPitch","setMaxPitch","getMaxPitch","getRenderWorldCopies","setRenderWorldCopies","getCooperativeGestures","setCooperativeGestures","gestureOptions","_destroyCooperativeGestures","_createDelegatedListener","mousein","delegates","delegate","layerIdOrListener","delegatedListener","_delegatedListeners","delegatedListeners","removeDelegatedListener","geometryOrOptions","isGeometry","_diffStyle","_updateStyle","_lazyInitEmptyStyle","_updateDiff","getStyle","isStyleLoaded","_terrainDataCallback","thisLayer","areTilesLoaded","existingImage","imageData","hasImage","loadImage","beforeId","spriteUrl","_canvasContainer","_canvas","clientWidth","canvasContainer","controlContainer","_controlContainer","positionName","_cooperativeGesturesScreen","desktopMessage","windowsHelpText","macHelpText","mobileHelpText","webglcontextcreationerrorDetailObject","requestedAttributes","statusMessage","msg","metaPress","_styleDirty","_sourcesDirty","updateStyle","_render","paintStartTimeStamp","crossFading","_placementDirty","somethingDirty","_repaint","_fullyLoaded","redraw","disconnect","loseContext","_showTileBoundaries","_showPadding","repaint","_vertices","getCameraTargetElevation","NavigationControl","_updateZoomButtons","isMax","isMin","_zoomInButton","_zoomOutButton","_rotateCompassArrow","_compassIcon","_setButtonTitle","_createButton","_compass","_handler","GeolocateControl","_onSuccess","_isOutOfMapMaxBounds","_setErrorState","_updateMarker","_finish","_lastKnownPosition","_watchState","_geolocateButton","_updateCamera","_dotElement","longitude","accuracy","newBounds","geolocateSource","_accuracyCircleMarker","_userLocationDotMarker","_accuracy","_updateCircleRadius","_onZoom","_onError","_geolocationWatchID","_clearWatch","_timeoutId","_setupUI","_circleElement","_setup","forceRecalculation","permissions","geolocation","checkGeolocationSupport","clearWatch","southEastPoint","northEastPoint","mapHeightInMeters","circleDiameter","watchPosition","getCurrentPosition","ScaleControl","setUnit","FullscreenControl","_onFullscreenChange","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","_fullscreen","_handleFullscreenChange","_onClickFullscreen","_isFullscreen","_exitFullscreen","_requestFullscreen","_fullscreenchange","_fullscreenButton","_updateTitle","_getTitle","_prevCooperativeGestures","exitFullscreen","mozCancelFullScreen","msExitFullscreen","webkitCancelFullScreen","_togglePseudoFullScreen","requestFullscreen","mozRequestFullScreen","msRequestFullscreen","webkitRequestFullscreen","TerrainControl","_toggleTerrain","_updateTerrainIcon","_terrainButton","Popup","_content","_onClose","_onMouseMove","_onMouseUp","_onDrag","cursor","_trackPointer","_tip","offsetHeight","anchorComponents","offsetedPos","closeOnMove","_focusFirstElement","trackPointer","setText","setDOMContent","createTextNode","setHTML","html","frag","createDocumentFragment","temp","getMaxWidth","setMaxWidth","htmlNode","hasChildNodes","_createCloseButton","_closeButton","firstFocusable","querySelector","focus","setRTLTextPlugin","deferred","prewarm","clearPrewarmedResources"],"mappings":"yPAkHO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,KAAKR,EAAWK,EAAY,CAC9GH,GAAMN,EAAYA,EAAUa,MAAMhB,EAASC,GAAc,KAAKS,OACtE,GACA,qGAiMkD,mBAApBO,iBAAiCA,oBCzT/DC,EAAiBC,EAcjB,SAASA,EAAMC,EAAGC,GACdC,KAAKF,EAAIA,EACTE,KAAKD,EAAIA,CACb,CAEAF,EAAMI,UAAY,CAOdC,MAAO,WAAa,OAAO,IAAIL,EAAMG,KAAKF,EAAGE,KAAKD,EAAK,EAQvDI,IAAS,SAASC,GAAK,OAAOJ,KAAKE,QAAQG,KAAKD,EAAK,EAQrDE,IAAS,SAASF,GAAK,OAAOJ,KAAKE,QAAQK,KAAKH,EAAK,EAQrDI,YAAgB,SAASJ,GAAK,OAAOJ,KAAKE,QAAQO,aAAaL,EAAK,EAQpEM,WAAgB,SAASN,GAAK,OAAOJ,KAAKE,QAAQS,YAAYP,EAAK,EAQnEQ,KAAS,SA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file diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl-dev.js b/web/libraries/maplibre-gl/dist/maplibre-gl-dev.js new file mode 100644 index 00000000..3d6880e7 --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl-dev.js @@ -0,0 +1,58062 @@ +/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.6.2/LICENSE.txt */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var shared, worker, maplibregl; +// define gets called three times: one for each chunk. we rely on the order +// they're imported to know which is which +function define(_, chunk) { + if (!shared) { + shared = chunk; + } else if (!worker) { + worker = chunk; + } else { + var workerBundleString = 'var sharedChunk = {}; (' + shared + ')(sharedChunk); (' + worker + ')(sharedChunk);' + + var sharedChunk = {}; + shared(sharedChunk); + maplibregl = chunk(sharedChunk); + if (typeof window !== 'undefined') { + maplibregl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); + } + } +} + + +define(['exports'], (function (exports) { 'use strict'; + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +var tslib_es6 = { + __extends: __extends, + __assign: __assign, + __rest: __rest, + __decorate: __decorate, + __param: __param, + __metadata: __metadata, + __awaiter: __awaiter, + __generator: __generator, + __createBinding: __createBinding, + __exportStar: __exportStar, + __values: __values, + __read: __read, + __spread: __spread, + __spreadArrays: __spreadArrays, + __spreadArray: __spreadArray, + __await: __await, + __asyncGenerator: __asyncGenerator, + __asyncDelegator: __asyncDelegator, + __asyncValues: __asyncValues, + __makeTemplateObject: __makeTemplateObject, + __importStar: __importStar, + __importDefault: __importDefault, + __classPrivateFieldGet: __classPrivateFieldGet, + __classPrivateFieldSet: __classPrivateFieldSet, + __classPrivateFieldIn: __classPrivateFieldIn, + __addDisposableResource: __addDisposableResource, + __disposeResources: __disposeResources, +}; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getDefaultExportFromNamespaceIfPresent (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n; +} + +function getDefaultExportFromNamespaceIfNotNamed (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n; +} + +function getAugmentedNamespace(n) { + if (n.__esModule) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + if (this instanceof a) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +'use strict'; + +var pointGeometry = Point$1; + +/** + * A standalone point geometry with useful accessor, comparison, and + * modification methods. + * + * @class Point + * @param {Number} x the x-coordinate. this could be longitude or screen + * pixels, or any other sort of unit. + * @param {Number} y the y-coordinate. this could be latitude or screen + * pixels, or any other sort of unit. + * @example + * var point = new Point(-77, 38); + */ +function Point$1(x, y) { + this.x = x; + this.y = y; +} + +Point$1.prototype = { + + /** + * Clone this point, returning a new point that can be modified + * without affecting the old one. + * @return {Point} the clone + */ + clone: function() { return new Point$1(this.x, this.y); }, + + /** + * Add this point's x & y coordinates to another point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + add: function(p) { return this.clone()._add(p); }, + + /** + * Subtract this point's x & y coordinates to from point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + sub: function(p) { return this.clone()._sub(p); }, + + /** + * Multiply this point's x & y coordinates by point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + multByPoint: function(p) { return this.clone()._multByPoint(p); }, + + /** + * Divide this point's x & y coordinates by point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + divByPoint: function(p) { return this.clone()._divByPoint(p); }, + + /** + * Multiply this point's x & y coordinates by a factor, + * yielding a new point. + * @param {Point} k factor + * @return {Point} output point + */ + mult: function(k) { return this.clone()._mult(k); }, + + /** + * Divide this point's x & y coordinates by a factor, + * yielding a new point. + * @param {Point} k factor + * @return {Point} output point + */ + div: function(k) { return this.clone()._div(k); }, + + /** + * Rotate this point around the 0, 0 origin by an angle a, + * given in radians + * @param {Number} a angle to rotate around, in radians + * @return {Point} output point + */ + rotate: function(a) { return this.clone()._rotate(a); }, + + /** + * Rotate this point around p point by an angle a, + * given in radians + * @param {Number} a angle to rotate around, in radians + * @param {Point} p Point to rotate around + * @return {Point} output point + */ + rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); }, + + /** + * Multiply this point by a 4x1 transformation matrix + * @param {Array} m transformation matrix + * @return {Point} output point + */ + matMult: function(m) { return this.clone()._matMult(m); }, + + /** + * Calculate this point but as a unit vector from 0, 0, meaning + * that the distance from the resulting point to the 0, 0 + * coordinate will be equal to 1 and the angle from the resulting + * point to the 0, 0 coordinate will be the same as before. + * @return {Point} unit vector point + */ + unit: function() { return this.clone()._unit(); }, + + /** + * Compute a perpendicular point, where the new y coordinate + * is the old x coordinate and the new x coordinate is the old y + * coordinate multiplied by -1 + * @return {Point} perpendicular point + */ + perp: function() { return this.clone()._perp(); }, + + /** + * Return a version of this point with the x & y coordinates + * rounded to integers. + * @return {Point} rounded point + */ + round: function() { return this.clone()._round(); }, + + /** + * Return the magitude of this point: this is the Euclidean + * distance from the 0, 0 coordinate to this point's x and y + * coordinates. + * @return {Number} magnitude + */ + mag: function() { + return Math.sqrt(this.x * this.x + this.y * this.y); + }, + + /** + * Judge whether this point is equal to another point, returning + * true or false. + * @param {Point} other the other point + * @return {boolean} whether the points are equal + */ + equals: function(other) { + return this.x === other.x && + this.y === other.y; + }, + + /** + * Calculate the distance from this point to another point + * @param {Point} p the other point + * @return {Number} distance + */ + dist: function(p) { + return Math.sqrt(this.distSqr(p)); + }, + + /** + * Calculate the distance from this point to another point, + * without the square root step. Useful if you're comparing + * relative distances. + * @param {Point} p the other point + * @return {Number} distance + */ + distSqr: function(p) { + var dx = p.x - this.x, + dy = p.y - this.y; + return dx * dx + dy * dy; + }, + + /** + * Get the angle from the 0, 0 coordinate to this point, in radians + * coordinates. + * @return {Number} angle + */ + angle: function() { + return Math.atan2(this.y, this.x); + }, + + /** + * Get the angle from this point to another point, in radians + * @param {Point} b the other point + * @return {Number} angle + */ + angleTo: function(b) { + return Math.atan2(this.y - b.y, this.x - b.x); + }, + + /** + * Get the angle between this point and another point, in radians + * @param {Point} b the other point + * @return {Number} angle + */ + angleWith: function(b) { + return this.angleWithSep(b.x, b.y); + }, + + /* + * Find the angle of the two vectors, solving the formula for + * the cross product a x b = |a||b|sin(θ) for θ. + * @param {Number} x the x-coordinate + * @param {Number} y the y-coordinate + * @return {Number} the angle in radians + */ + angleWithSep: function(x, y) { + return Math.atan2( + this.x * y - this.y * x, + this.x * x + this.y * y); + }, + + _matMult: function(m) { + var x = m[0] * this.x + m[1] * this.y, + y = m[2] * this.x + m[3] * this.y; + this.x = x; + this.y = y; + return this; + }, + + _add: function(p) { + this.x += p.x; + this.y += p.y; + return this; + }, + + _sub: function(p) { + this.x -= p.x; + this.y -= p.y; + return this; + }, + + _mult: function(k) { + this.x *= k; + this.y *= k; + return this; + }, + + _div: function(k) { + this.x /= k; + this.y /= k; + return this; + }, + + _multByPoint: function(p) { + this.x *= p.x; + this.y *= p.y; + return this; + }, + + _divByPoint: function(p) { + this.x /= p.x; + this.y /= p.y; + return this; + }, + + _unit: function() { + this._div(this.mag()); + return this; + }, + + _perp: function() { + var y = this.y; + this.y = this.x; + this.x = -y; + return this; + }, + + _rotate: function(angle) { + var cos = Math.cos(angle), + sin = Math.sin(angle), + x = cos * this.x - sin * this.y, + y = sin * this.x + cos * this.y; + this.x = x; + this.y = y; + return this; + }, + + _rotateAround: function(angle, p) { + var cos = Math.cos(angle), + sin = Math.sin(angle), + x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), + y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y); + this.x = x; + this.y = y; + return this; + }, + + _round: function() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + return this; + } +}; + +/** + * Construct a point from an array if necessary, otherwise if the input + * is already a Point, or an unknown type, return it unchanged + * @param {Array|Point|*} a any kind of input value + * @return {Point} constructed point, or passed-through value. + * @example + * // this + * var point = Point.convert([0, 1]); + * // is equivalent to + * var point = new Point(0, 1); + */ +Point$1.convert = function (a) { + if (a instanceof Point$1) { + return a; + } + if (Array.isArray(a)) { + return new Point$1(a[0], a[1]); + } + return a; +}; + +var Point$2 = /*@__PURE__*/getDefaultExportFromCjs(pointGeometry); + +'use strict'; + +var unitbezier = UnitBezier; + +function UnitBezier(p1x, p1y, p2x, p2y) { + // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1). + this.cx = 3.0 * p1x; + this.bx = 3.0 * (p2x - p1x) - this.cx; + this.ax = 1.0 - this.cx - this.bx; + + this.cy = 3.0 * p1y; + this.by = 3.0 * (p2y - p1y) - this.cy; + this.ay = 1.0 - this.cy - this.by; + + this.p1x = p1x; + this.p1y = p1y; + this.p2x = p2x; + this.p2y = p2y; +} + +UnitBezier.prototype = { + sampleCurveX: function (t) { + // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule. + return ((this.ax * t + this.bx) * t + this.cx) * t; + }, + + sampleCurveY: function (t) { + return ((this.ay * t + this.by) * t + this.cy) * t; + }, + + sampleCurveDerivativeX: function (t) { + return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx; + }, + + solveCurveX: function (x, epsilon) { + if (epsilon === undefined) epsilon = 1e-6; + + if (x < 0.0) return 0.0; + if (x > 1.0) return 1.0; + + var t = x; + + // First try a few iterations of Newton's method - normally very fast. + for (var i = 0; i < 8; i++) { + var x2 = this.sampleCurveX(t) - x; + if (Math.abs(x2) < epsilon) return t; + + var d2 = this.sampleCurveDerivativeX(t); + if (Math.abs(d2) < 1e-6) break; + + t = t - x2 / d2; + } + + // Fall back to the bisection method for reliability. + var t0 = 0.0; + var t1 = 1.0; + t = x; + + for (i = 0; i < 20; i++) { + x2 = this.sampleCurveX(t); + if (Math.abs(x2 - x) < epsilon) break; + + if (x > x2) { + t0 = t; + } else { + t1 = t; + } + + t = (t1 - t0) * 0.5 + t0; + } + + return t; + }, + + solve: function (x, epsilon) { + return this.sampleCurveY(this.solveCurveX(x, epsilon)); + } +}; + +var UnitBezier$1 = /*@__PURE__*/getDefaultExportFromCjs(unitbezier); + +let supportsOffscreenCanvas; +function offscreenCanvasSupported() { + if (supportsOffscreenCanvas == null) { + supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' && + new OffscreenCanvas(1, 1).getContext('2d') && + typeof createImageBitmap === 'function'; + } + return supportsOffscreenCanvas; +} + +let offscreenCanvasDistorted; +/** + * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185). + * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false + * if they don't match. + * + * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise. + */ +function isOffscreenCanvasDistorted() { + if (offscreenCanvasDistorted == null) { + offscreenCanvasDistorted = false; + if (offscreenCanvasSupported()) { + const size = 5; + const canvas = new OffscreenCanvas(size, size); + const context = canvas.getContext('2d', { willReadFrequently: true }); + if (context) { + // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel): + // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...] + for (let i = 0; i < size * size; i++) { + const base = i * 4; + context.fillStyle = `rgb(${base},${base + 1},${base + 2})`; + context.fillRect(i % size, Math.floor(i / size), 1, 1); + } + const data = context.getImageData(0, 0, size, size).data; + for (let i = 0; i < size * size * 4; i++) { + if (i % 4 !== 3 && data[i] !== i) { + offscreenCanvasDistorted = true; + break; + } + } + } + } + } + return offscreenCanvasDistorted || false; +} + +/** + * Given a value `t` that varies between 0 and 1, return + * an interpolation function that eases between 0 and 1 in a pleasing + * cubic in-out fashion. + */ +function easeCubicInOut(t) { + if (t <= 0) + return 0; + if (t >= 1) + return 1; + const t2 = t * t, t3 = t2 * t; + return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75); +} +/** + * Given given (x, y), (x1, y1) control points for a bezier curve, + * return a function that interpolates along that curve. + * + * @param p1x - control point 1 x coordinate + * @param p1y - control point 1 y coordinate + * @param p2x - control point 2 x coordinate + * @param p2y - control point 2 y coordinate + */ +function bezier$1(p1x, p1y, p2x, p2y) { + const bezier = new UnitBezier$1(p1x, p1y, p2x, p2y); + return function (t) { + return bezier.solve(t); + }; +} +/** + * A default bezier-curve powered easing function with + * control points (0.25, 0.1) and (0.25, 1) + */ +const defaultEasing = bezier$1(0.25, 0.1, 0.25, 1); +/** + * constrain n to the given range via min + max + * + * @param n - value + * @param min - the minimum value to be returned + * @param max - the maximum value to be returned + * @returns the clamped value + */ +function clamp$1(n, min, max) { + return Math.min(max, Math.max(min, n)); +} +/** + * constrain n to the given range, excluding the minimum, via modular arithmetic + * + * @param n - value + * @param min - the minimum value to be returned, exclusive + * @param max - the maximum value to be returned, inclusive + * @returns constrained number + */ +function wrap(n, min, max) { + const d = max - min; + const w = ((n - min) % d + d) % d + min; + return (w === min) ? max : w; +} +/** + * Call an asynchronous function on an array of arguments, + * calling `callback` with the completed results of all calls. + * + * @param array - input to each call of the async function. + * @param fn - an async function with signature (data, callback) + * @param callback - a callback run after all async work is done. + * called with an array, containing the results of each async call. + */ +function asyncAll(array, fn, callback) { + if (!array.length) { + return callback(null, []); + } + let remaining = array.length; + const results = new Array(array.length); + let error = null; + array.forEach((item, i) => { + fn(item, (err, result) => { + if (err) + error = err; + results[i] = result; // https://github.com/facebook/flow/issues/2123 + if (--remaining === 0) + callback(error, results); + }); + }); +} +/** + * Compute the difference between the keys in one object and the keys + * in another object. + * + * @returns keys difference + */ +function keysDifference(obj, other) { + const difference = []; + for (const i in obj) { + if (!(i in other)) { + difference.push(i); + } + } + return difference; +} +/** + * Given a destination object and optionally many source objects, + * copy all properties from the source objects into the destination. + * The last source object given overrides properties from previous + * source objects. + * + * @param dest - destination object + * @param sources - sources from which properties are pulled + */ +function extend(dest, ...sources) { + for (const src of sources) { + for (const k in src) { + dest[k] = src[k]; + } + } + return dest; +} +/** + * Given an object and a number of properties as strings, return version + * of that object with only those properties. + * + * @param src - the object + * @param properties - an array of property names chosen + * to appear on the resulting object. + * @returns object with limited properties. + * @example + * ```ts + * let foo = { name: 'Charlie', age: 10 }; + * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' } + * ``` + */ +function pick(src, properties) { + const result = {}; + for (let i = 0; i < properties.length; i++) { + const k = properties[i]; + if (k in src) { + result[k] = src[k]; + } + } + return result; +} +let id = 1; +/** + * Return a unique numeric id, starting at 1 and incrementing with + * each call. + * + * @returns unique numeric id. + */ +function uniqueId() { + return id++; +} +/** + * Return whether a given value is a power of two + */ +function isPowerOfTwo(value) { + return (Math.log(value) / Math.LN2) % 1 === 0; +} +/** + * Return the next power of two, or the input value if already a power of two + */ +function nextPowerOfTwo(value) { + if (value <= 1) + return 1; + return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2)); +} +/** + * Create an object by mapping all the values of an existing object while + * preserving their keys. + */ +function mapObject(input, iterator, context) { + const output = {}; + for (const key in input) { + output[key] = iterator.call(context || this, input[key], key, input); + } + return output; +} +/** + * Create an object by filtering out values of an existing object. + */ +function filterObject(input, iterator, context) { + const output = {}; + for (const key in input) { + if (iterator.call(context || this, input[key], key, input)) { + output[key] = input[key]; + } + } + return output; +} +/** + * Deeply compares two object literals. + * @param a - first object literal to be compared + * @param b - second object literal to be compared + * @returns true if the two object literals are deeply equal, false otherwise + */ +function deepEqual$1(a, b) { + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) + return false; + for (let i = 0; i < a.length; i++) { + if (!deepEqual$1(a[i], b[i])) + return false; + } + return true; + } + if (typeof a === 'object' && a !== null && b !== null) { + if (!(typeof b === 'object')) + return false; + const keys = Object.keys(a); + if (keys.length !== Object.keys(b).length) + return false; + for (const key in a) { + if (!deepEqual$1(a[key], b[key])) + return false; + } + return true; + } + return a === b; +} +/** + * Deeply clones two objects. + */ +function clone$9(input) { + if (Array.isArray(input)) { + return input.map(clone$9); + } + else if (typeof input === 'object' && input) { + return mapObject(input, clone$9); + } + else { + return input; + } +} +/** + * Check if two arrays have at least one common element. + */ +function arraysIntersect(a, b) { + for (let l = 0; l < a.length; l++) { + if (b.indexOf(a[l]) >= 0) + return true; + } + return false; +} +/** + * Print a warning message to the console and ensure duplicate warning messages + * are not printed. + */ +const warnOnceHistory = {}; +function warnOnce(message) { + if (!warnOnceHistory[message]) { + // console isn't defined in some WebWorkers, see #2558 + if (typeof console !== 'undefined') + console.warn(message); + warnOnceHistory[message] = true; + } +} +/** + * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order + * + * @returns true for a counter clockwise set of points + */ +// http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/ +function isCounterClockwise(a, b, c) { + return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x); +} +/** + * For two lines a and b in 2d space, defined by any two points along the lines, + * find the intersection point, or return null if the lines are parallel + * + * @param a1 - First point on line a + * @param a2 - Second point on line a + * @param b1 - First point on line b + * @param b2 - Second point on line b + * + * @returns the intersection point of the two lines or null if they are parallel + */ +function findLineIntersection(a1, a2, b1, b2) { + const aDeltaY = a2.y - a1.y; + const aDeltaX = a2.x - a1.x; + const bDeltaY = b2.y - b1.y; + const bDeltaX = b2.x - b1.x; + const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY); + if (denominator === 0) { + // Lines are parallel + return null; + } + const originDeltaY = a1.y - b1.y; + const originDeltaX = a1.x - b1.x; + const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator; + // Find intersection by projecting out from origin of first segment + return new Point$2(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY)); +} +/** + * Returns the signed area for the polygon ring. Positive areas are exterior rings and + * have a clockwise winding. Negative areas are interior rings and have a counter clockwise + * ordering. + * + * @param ring - Exterior or interior ring + */ +function calculateSignedArea(ring) { + let sum = 0; + for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) { + p1 = ring[i]; + p2 = ring[j]; + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + return sum; +} +/** + * Detects closed polygons, first + last point are equal + * + * @param points - array of points + * @returns `true` if the points are a closed polygon + */ +function isClosedPolygon(points) { + // If it is 2 points that are the same then it is a point + // If it is 3 points with start and end the same then it is a line + if (points.length < 4) + return false; + const p1 = points[0]; + const p2 = points[points.length - 1]; + if (Math.abs(p1.x - p2.x) > 0 || + Math.abs(p1.y - p2.y) > 0) { + return false; + } + // polygon simplification can produce polygons with zero area and more than 3 points + return Math.abs(calculateSignedArea(points)) > 0.01; +} +/** + * Converts spherical coordinates to cartesian coordinates. + * + * @param spherical - Spherical coordinates, in [radial, azimuthal, polar] + * @returns cartesian coordinates in [x, y, z] + */ +function sphericalToCartesian([r, azimuthal, polar]) { + // We abstract "north"/"up" (compass-wise) to be 0° when really this is 90° (π/2): + // correct for that here + azimuthal += 90; + // Convert azimuthal and polar angles to radians + azimuthal *= Math.PI / 180; + polar *= Math.PI / 180; + return { + x: r * Math.cos(azimuthal) * Math.sin(polar), + y: r * Math.sin(azimuthal) * Math.sin(polar), + z: r * Math.cos(polar) + }; +} +/** + * Returns true if the when run in the web-worker context. + * + * @returns `true` if the when run in the web-worker context. + */ +function isWorker() { + // @ts-ignore + return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope; +} +/** + * Parses data from 'Cache-Control' headers. + * + * @param cacheControl - Value of 'Cache-Control' header + * @returns object containing parsed header info. + */ +function parseCacheControl(cacheControl) { + // Taken from [Wreck](https://github.com/hapijs/wreck) + const re = /(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g; + const header = {}; + cacheControl.replace(re, ($0, $1, $2, $3) => { + const value = $2 || $3; + header[$1] = value ? value.toLowerCase() : true; + return ''; + }); + if (header['max-age']) { + const maxAge = parseInt(header['max-age'], 10); + if (isNaN(maxAge)) + delete header['max-age']; + else + header['max-age'] = maxAge; + } + return header; +} +let _isSafari = null; +/** + * Returns true when run in WebKit derived browsers. + * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to + * transfer data between WebWorkers and the main thread. + * https://github.com/mapbox/mapbox-gl-js/issues/8771 + * + * This should be removed once the underlying Safari issue is fixed. + * + * @param scope - Since this function is used both on the main thread and WebWorker context, + * let the calling scope pass in the global scope object. + * @returns `true` when run in WebKit derived browsers. + */ +function isSafari(scope) { + if (_isSafari == null) { + const userAgent = scope.navigator ? scope.navigator.userAgent : null; + _isSafari = !!scope.safari || + !!(userAgent && (/\b(iPad|iPhone|iPod)\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome')))); + } + return _isSafari; +} +function storageAvailable(type) { + try { + const storage = window[type]; + storage.setItem('_mapbox_test_', 1); + storage.removeItem('_mapbox_test_'); + return true; + } + catch (e) { + return false; + } +} +// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem +//Unicode compliant base64 encoder for strings +function b64EncodeUnicode(str) { + return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => { + return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line + })); +} +// Unicode compliant decoder for base64-encoded strings +function b64DecodeUnicode(str) { + return decodeURIComponent(atob(str).split('').map((c) => { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line + }).join('')); +} +function isImageBitmap(image) { + return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap; +} +/** + * Converts an ArrayBuffer to an ImageBitmap. + * + * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work + * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting + * ArrayBuffers. + * + * @param data - Data to convert + * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image bitmap (when no error) as the second + */ +function arrayBufferToImageBitmap(data, callback) { + const blob = new Blob([new Uint8Array(data)], { type: 'image/png' }); + createImageBitmap(blob).then((imgBitmap) => { + callback(null, imgBitmap); + }).catch((e) => { + callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)); + }); +} +const transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII='; +/** + * Converts an ArrayBuffer to an HTMLImageElement. + * + * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work + * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting + * ArrayBuffers. + * + * @param data - Data to convert + * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image element (when no error) as the second + */ +function arrayBufferToImage(data, callback) { + const img = new Image(); + img.onload = () => { + callback(null, img); + URL.revokeObjectURL(img.src); + // prevent image dataURI memory leak in Safari; + // but don't free the image immediately because it might be uploaded in the next frame + // https://github.com/mapbox/mapbox-gl-js/issues/10226 + img.onload = null; + window.requestAnimationFrame(() => { img.src = transparentPngUrl; }); + }; + img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.')); + const blob = new Blob([new Uint8Array(data)], { type: 'image/png' }); + img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl; +} +/** + * Computes the webcodecs VideoFrame API options to select a rectangle out of + * an image and write it into the destination rectangle. + * + * Rect (x/y/width/height) select the overlapping rectangle from the source image + * and layout (offset/stride) write that overlapping rectangle to the correct place + * in the destination image. + * + * Offset is the byte offset in the dest image that the first pixel appears at + * and stride is the number of bytes to the start of the next row: + * ┌───────────┐ + * │ dest │ + * │ ┌───┼───────┐ + * │offset→│▓▓▓│ source│ + * │ │▓▓▓│ │ + * │ └───┼───────┘ + * │stride ⇠╌╌╌│ + * │╌╌╌╌╌╌→ │ + * └───────────┘ + * + * @param image - source image containing a width and height attribute + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns the layout and rect options to pass into VideoFrame API + */ +function computeVideoFrameParameters(image, x, y, width, height) { + const destRowOffset = Math.max(-x, 0) * 4; + const firstSourceRow = Math.max(0, y); + const firstDestRow = firstSourceRow - y; + const offset = firstDestRow * width * 4 + destRowOffset; + const stride = width * 4; + const sourceLeft = Math.max(0, x); + const sourceTop = Math.max(0, y); + const sourceRight = Math.min(image.width, x + width); + const sourceBottom = Math.min(image.height, y + height); + return { + rect: { + x: sourceLeft, + y: sourceTop, + width: sourceRight - sourceLeft, + height: sourceBottom - sourceTop + }, + layout: [{ offset, stride }] + }; +} +/** + * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API. + * + * @param data - image, imagebitmap, or canvas to parse + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred + */ +function readImageUsingVideoFrame(image, x, y, width, height) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof VideoFrame === 'undefined') { + throw new Error('VideoFrame not supported'); + } + const frame = new VideoFrame(image, { timestamp: 0 }); + try { + const format = frame === null || frame === void 0 ? void 0 : frame.format; + if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) { + throw new Error(`Unrecognized format ${format}`); + } + const swapBR = format.startsWith('BGR'); + const result = new Uint8ClampedArray(width * height * 4); + yield frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height)); + if (swapBR) { + for (let i = 0; i < result.length; i += 4) { + const tmp = result[i]; + result[i] = result[i + 2]; + result[i + 2] = tmp; + } + } + return result; + } + finally { + frame.close(); + } + }); +} +let offscreenCanvas; +let offscreenCanvasContext; +/** + * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas + * + * @param data - image, imagebitmap, or canvas to parse + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred + */ +function readImageDataUsingOffscreenCanvas(imgBitmap, x, y, width, height) { + const origWidth = imgBitmap.width; + const origHeight = imgBitmap.height; + // Lazily initialize OffscreenCanvas + if (!offscreenCanvas || !offscreenCanvasContext) { + // Dem tiles are typically 256x256 + offscreenCanvas = new OffscreenCanvas(origWidth, origHeight); + offscreenCanvasContext = offscreenCanvas.getContext('2d', { willReadFrequently: true }); + } + offscreenCanvas.width = origWidth; + offscreenCanvas.height = origHeight; + offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight); + const imgData = offscreenCanvasContext.getImageData(x, y, width, height); + offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight); + return imgData.data; +} +/** + * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and + * the browser is mangling OffscreenCanvas getImageData results. + * + * @param data - image, imagebitmap, or canvas to parse + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns a promise containing the parsed RGBA pixel values of the image + */ +function getImageData(image, x, y, width, height) { + return __awaiter(this, void 0, void 0, function* () { + if (isOffscreenCanvasDistorted()) { + try { + return yield readImageUsingVideoFrame(image, x, y, width, height); + } + catch (e) { + // fall back to OffscreenCanvas + } + } + return readImageDataUsingOffscreenCanvas(image, x, y, width, height); + }); +} + +const now = typeof performance !== 'undefined' && performance && performance.now ? + performance.now.bind(performance) : + Date.now.bind(Date); +let linkEl; +let reducedMotionQuery; +/** */ +const browser = { + /** + * Provides a function that outputs milliseconds: either performance.now() + * or a fallback to Date.now() + */ + now, + frame(fn) { + const frame = requestAnimationFrame(fn); + return { cancel: () => cancelAnimationFrame(frame) }; + }, + getImageData(img, padding = 0) { + const context = this.getImageCanvasContext(img); + return context.getImageData(-padding, -padding, img.width + 2 * padding, img.height + 2 * padding); + }, + getImageCanvasContext(img) { + const canvas = window.document.createElement('canvas'); + const context = canvas.getContext('2d', { willReadFrequently: true }); + if (!context) { + throw new Error('failed to create canvas 2d context'); + } + canvas.width = img.width; + canvas.height = img.height; + context.drawImage(img, 0, 0, img.width, img.height); + return context; + }, + resolveURL(path) { + if (!linkEl) + linkEl = document.createElement('a'); + linkEl.href = path; + return linkEl.href; + }, + hardwareConcurrency: typeof navigator !== 'undefined' && navigator.hardwareConcurrency || 4, + get prefersReducedMotion() { + // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util' + if (!matchMedia) + return false; + //Lazily initialize media query + if (reducedMotionQuery == null) { + reducedMotionQuery = matchMedia('(prefers-reduced-motion: reduce)'); + } + return reducedMotionQuery.matches; + }, +}; + +const config = { + MAX_PARALLEL_IMAGE_REQUESTS: 16, + MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8, + MAX_TILE_CACHE_ZOOM_LEVELS: 5, + REGISTERED_PROTOCOLS: {}, + WORKER_URL: '' +}; + +/** + * An error thrown when a HTTP request results in an error response. + */ +class AJAXError extends Error { + /** + * @param status - The response's HTTP status code. + * @param statusText - The response's HTTP status text. + * @param url - The request's URL. + * @param body - The response's body. + */ + constructor(status, statusText, url, body) { + super(`AJAXError: ${statusText} (${status}): ${url}`); + this.status = status; + this.statusText = statusText; + this.url = url; + this.body = body; + } +} +// Ensure that we're sending the correct referrer from blob URL worker bundles. +// For files loaded from the local file system, `location.origin` will be set +// to the string(!) "null" (Firefox), or "file://" (Chrome, Safari, Edge, IE), +// and we will set an empty referrer. Otherwise, we're using the document's URL. +/* global self */ +const getReferrer = isWorker() ? + () => self.worker && self.worker.referrer : + () => (window.location.protocol === 'blob:' ? window.parent : window).location.href; +const getProtocolAction = url => config.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))]; +// Determines whether a URL is a file:// URL. This is obviously the case if it begins +// with file://. Relative URLs are also file:// URLs iff the original document was loaded +// via a file:// URL. +const isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\w+:/.test(url)); +function makeFetchRequest(requestParameters, callback) { + const controller = new AbortController(); + const request = new Request(requestParameters.url, { + method: requestParameters.method || 'GET', + body: requestParameters.body, + credentials: requestParameters.credentials, + headers: requestParameters.headers, + cache: requestParameters.cache, + referrer: getReferrer(), + signal: controller.signal + }); + let complete = false; + let aborted = false; + if (requestParameters.type === 'json') { + request.headers.set('Accept', 'application/json'); + } + const validateOrFetch = (err, cachedResponse, responseIsFresh) => { + if (aborted) + return; + if (err) { + // Do fetch in case of cache error. + // HTTP pages in Edge trigger a security error that can be ignored. + if (err.message !== 'SecurityError') { + warnOnce(err); + } + } + if (cachedResponse && responseIsFresh) { + return finishRequest(cachedResponse); + } + if (cachedResponse) { + // We can't do revalidation with 'If-None-Match' because then the + // request doesn't have simple cors headers. + } + fetch(request).then(response => { + if (response.ok) { + return finishRequest(response); + } + else { + return response.blob().then(body => callback(new AJAXError(response.status, response.statusText, requestParameters.url, body))); + } + }).catch(error => { + if (error.code === 20) { + // silence expected AbortError + return; + } + callback(new Error(error.message)); + }); + }; + const finishRequest = (response) => { + ((requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') ? response.arrayBuffer() : + requestParameters.type === 'json' ? response.json() : + response.text()).then(result => { + if (aborted) + return; + complete = true; + callback(null, result, response.headers.get('Cache-Control'), response.headers.get('Expires')); + }).catch(err => { + if (!aborted) + callback(new Error(err.message)); + }); + }; + validateOrFetch(null, null); + return { cancel: () => { + aborted = true; + if (!complete) + controller.abort(); + } }; +} +function makeXMLHttpRequest(requestParameters, callback) { + const xhr = new XMLHttpRequest(); + xhr.open(requestParameters.method || 'GET', requestParameters.url, true); + if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') { + xhr.responseType = 'arraybuffer'; + } + for (const k in requestParameters.headers) { + xhr.setRequestHeader(k, requestParameters.headers[k]); + } + if (requestParameters.type === 'json') { + xhr.responseType = 'text'; + xhr.setRequestHeader('Accept', 'application/json'); + } + xhr.withCredentials = requestParameters.credentials === 'include'; + xhr.onerror = () => { + callback(new Error(xhr.statusText)); + }; + xhr.onload = () => { + if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) { + let data = xhr.response; + if (requestParameters.type === 'json') { + // We're manually parsing JSON here to get better error messages. + try { + data = JSON.parse(xhr.response); + } + catch (err) { + return callback(err); + } + } + callback(null, data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires')); + } + else { + const body = new Blob([xhr.response], { type: xhr.getResponseHeader('Content-Type') }); + callback(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body)); + } + }; + xhr.send(requestParameters.body); + return { cancel: () => xhr.abort() }; +} +const makeRequest = function (requestParameters, callback) { + // We're trying to use the Fetch API if possible. However, in some situations we can't use it: + // - IE11 doesn't support it at all. In this case, we dispatch the request to the main thread so + // that we can get an accruate referrer header. + // - Safari exposes window.AbortController, but it doesn't work actually abort any requests in + // some versions (see https://bugs.webkit.org/show_bug.cgi?id=174980#c2) + // - Requests for resources with the file:// URI scheme don't work with the Fetch API either. In + // this case we unconditionally use XHR on the current thread since referrers don't matter. + if (/:\/\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) { + if (isWorker() && self.worker && self.worker.actor) { + return self.worker.actor.send('getResource', requestParameters, callback); + } + if (!isWorker()) { + const action = getProtocolAction(requestParameters.url) || makeFetchRequest; + return action(requestParameters, callback); + } + } + if (!isFileURL(requestParameters.url)) { + if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) { + return makeFetchRequest(requestParameters, callback); + } + if (isWorker() && self.worker && self.worker.actor) { + const queueOnMainThread = true; + return self.worker.actor.send('getResource', requestParameters, callback, undefined, queueOnMainThread); + } + } + return makeXMLHttpRequest(requestParameters, callback); +}; +const getJSON = function (requestParameters, callback) { + return makeRequest(extend(requestParameters, { type: 'json' }), callback); +}; +const getArrayBuffer = function (requestParameters, callback) { + return makeRequest(extend(requestParameters, { type: 'arrayBuffer' }), callback); +}; +const postData = function (requestParameters, callback) { + return makeRequest(extend(requestParameters, { method: 'POST' }), callback); +}; +function sameOrigin(inComingUrl) { + // URL class should be available everywhere + // https://developer.mozilla.org/en-US/docs/Web/API/URL + // In addtion, a relative URL "/foo" or "./foo" will throw exception in its ctor, + // try-catch is expansive so just use a heuristic check to avoid it + // also check data URL + if (!inComingUrl || + inComingUrl.indexOf('://') <= 0 || // relative URL + inComingUrl.indexOf('data:image/') === 0 || // data image URL + inComingUrl.indexOf('blob:') === 0) { // blob + return true; + } + const urlObj = new URL(inComingUrl); + const locationObj = window.location; + return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host; +} +const getVideo = function (urls, callback) { + const video = window.document.createElement('video'); + video.muted = true; + video.onloadstart = function () { + callback(null, video); + }; + for (let i = 0; i < urls.length; i++) { + const s = window.document.createElement('source'); + if (!sameOrigin(urls[i])) { + video.crossOrigin = 'Anonymous'; + } + s.src = urls[i]; + video.appendChild(s); + } + return { cancel: () => { } }; +}; + +function _addEventListener(type, listener, listenerList) { + const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1; + if (!listenerExists) { + listenerList[type] = listenerList[type] || []; + listenerList[type].push(listener); + } +} +function _removeEventListener(type, listener, listenerList) { + if (listenerList && listenerList[type]) { + const index = listenerList[type].indexOf(listener); + if (index !== -1) { + listenerList[type].splice(index, 1); + } + } +} +/** + * The event class + */ +class Event { + constructor(type, data = {}) { + extend(this, data); + this.type = type; + } +} +/** + * An error event + */ +class ErrorEvent extends Event { + constructor(error, data = {}) { + super('error', extend({ error }, data)); + } +} +/** + * Methods mixed in to other classes for event capabilities. + * + * @group Event Related + */ +class Evented { + /** + * Adds a listener to a specified event type. + * + * @param type - The event type to add a listen for. + * @param listener - The function to be called when the event is fired. + * The listener function is called with the data object passed to `fire`, + * extended with `target` and `type` properties. + * @returns `this` + */ + on(type, listener) { + this._listeners = this._listeners || {}; + _addEventListener(type, listener, this._listeners); + return this; + } + /** + * Removes a previously registered event listener. + * + * @param type - The event type to remove listeners for. + * @param listener - The listener function to remove. + * @returns `this` + */ + off(type, listener) { + _removeEventListener(type, listener, this._listeners); + _removeEventListener(type, listener, this._oneTimeListeners); + return this; + } + /** + * Adds a listener that will be called only once to a specified event type. + * + * The listener will be called first time the event fires after the listener is registered. + * + * @param type - The event type to listen for. + * @param listener - The function to be called when the event is fired the first time. + * @returns `this` or a promise if a listener is not provided + */ + once(type, listener) { + if (!listener) { + return new Promise((resolve) => this.once(type, resolve)); + } + this._oneTimeListeners = this._oneTimeListeners || {}; + _addEventListener(type, listener, this._oneTimeListeners); + return this; + } + fire(event, properties) { + // Compatibility with (type: string, properties: Object) signature from previous versions. + // See https://github.com/mapbox/mapbox-gl-js/issues/6522, + // https://github.com/mapbox/mapbox-gl-draw/issues/766 + if (typeof event === 'string') { + event = new Event(event, properties || {}); + } + const type = event.type; + if (this.listens(type)) { + event.target = this; + // make sure adding or removing listeners inside other listeners won't cause an infinite loop + const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : []; + for (const listener of listeners) { + listener.call(this, event); + } + const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : []; + for (const listener of oneTimeListeners) { + _removeEventListener(type, listener, this._oneTimeListeners); + listener.call(this, event); + } + const parent = this._eventedParent; + if (parent) { + extend(event, typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData); + parent.fire(event); + } + // To ensure that no error events are dropped, print them to the + // console if they have no listeners. + } + else if (event instanceof ErrorEvent) { + console.error(event.error); + } + return this; + } + /** + * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type. + * + * @param type - The event type + * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise + */ + listens(type) { + return ((this._listeners && this._listeners[type] && this._listeners[type].length > 0) || + (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) || + (this._eventedParent && this._eventedParent.listens(type))); + } + /** + * Bubble all events fired by this instance of Evented to this parent instance of Evented. + * @returns `this` + */ + setEventedParent(parent, data) { + this._eventedParent = parent; + this._eventedParentData = data; + return this; + } +} + +var $version = 8; +var $root = { + version: { + required: true, + type: "enum", + values: [ + 8 + ] + }, + name: { + type: "string" + }, + metadata: { + type: "*" + }, + center: { + type: "array", + value: "number" + }, + zoom: { + type: "number" + }, + bearing: { + type: "number", + "default": 0, + period: 360, + units: "degrees" + }, + pitch: { + type: "number", + "default": 0, + units: "degrees" + }, + light: { + type: "light" + }, + terrain: { + type: "terrain" + }, + sources: { + required: true, + type: "sources" + }, + sprite: { + type: "sprite" + }, + glyphs: { + type: "string" + }, + transition: { + type: "transition" + }, + layers: { + required: true, + type: "array", + value: "layer" + } +}; +var sources = { + "*": { + type: "source" + } +}; +var source = [ + "source_vector", + "source_raster", + "source_raster_dem", + "source_geojson", + "source_video", + "source_image" +]; +var source_vector = { + type: { + required: true, + type: "enum", + values: { + vector: { + } + } + }, + url: { + type: "string" + }, + tiles: { + type: "array", + value: "string" + }, + bounds: { + type: "array", + value: "number", + length: 4, + "default": [ + -180, + -85.051129, + 180, + 85.051129 + ] + }, + scheme: { + type: "enum", + values: { + xyz: { + }, + tms: { + } + }, + "default": "xyz" + }, + minzoom: { + type: "number", + "default": 0 + }, + maxzoom: { + type: "number", + "default": 22 + }, + attribution: { + type: "string" + }, + promoteId: { + type: "promoteId" + }, + volatile: { + type: "boolean", + "default": false + }, + "*": { + type: "*" + } +}; +var source_raster = { + type: { + required: true, + type: "enum", + values: { + raster: { + } + } + }, + url: { + type: "string" + }, + tiles: { + type: "array", + value: "string" + }, + bounds: { + type: "array", + value: "number", + length: 4, + "default": [ + -180, + -85.051129, + 180, + 85.051129 + ] + }, + minzoom: { + type: "number", + "default": 0 + }, + maxzoom: { + type: "number", + "default": 22 + }, + tileSize: { + type: "number", + "default": 512, + units: "pixels" + }, + scheme: { + type: "enum", + values: { + xyz: { + }, + tms: { + } + }, + "default": "xyz" + }, + attribution: { + type: "string" + }, + volatile: { + type: "boolean", + "default": false + }, + "*": { + type: "*" + } +}; +var source_raster_dem = { + type: { + required: true, + type: "enum", + values: { + "raster-dem": { + } + } + }, + url: { + type: "string" + }, + tiles: { + type: "array", + value: "string" + }, + bounds: { + type: "array", + value: "number", + length: 4, + "default": [ + -180, + -85.051129, + 180, + 85.051129 + ] + }, + minzoom: { + type: "number", + "default": 0 + }, + maxzoom: { + type: "number", + "default": 22 + }, + tileSize: { + type: "number", + "default": 512, + units: "pixels" + }, + attribution: { + type: "string" + }, + encoding: { + type: "enum", + values: { + terrarium: { + }, + mapbox: { + }, + custom: { + } + }, + "default": "mapbox" + }, + redFactor: { + type: "number", + "default": 1 + }, + blueFactor: { + type: "number", + "default": 1 + }, + greenFactor: { + type: "number", + "default": 1 + }, + baseShift: { + type: "number", + "default": 0 + }, + volatile: { + type: "boolean", + "default": false + }, + "*": { + type: "*" + } +}; +var source_geojson = { + type: { + required: true, + type: "enum", + values: { + geojson: { + } + } + }, + data: { + required: true, + type: "*" + }, + maxzoom: { + type: "number", + "default": 18 + }, + attribution: { + type: "string" + }, + buffer: { + type: "number", + "default": 128, + maximum: 512, + minimum: 0 + }, + filter: { + type: "*" + }, + tolerance: { + type: "number", + "default": 0.375 + }, + cluster: { + type: "boolean", + "default": false + }, + clusterRadius: { + type: "number", + "default": 50, + minimum: 0 + }, + clusterMaxZoom: { + type: "number" + }, + clusterMinPoints: { + type: "number" + }, + clusterProperties: { + type: "*" + }, + lineMetrics: { + type: "boolean", + "default": false + }, + generateId: { + type: "boolean", + "default": false + }, + promoteId: { + type: "promoteId" + } +}; +var source_video = { + type: { + required: true, + type: "enum", + values: { + video: { + } + } + }, + urls: { + required: true, + type: "array", + value: "string" + }, + coordinates: { + required: true, + type: "array", + length: 4, + value: { + type: "array", + length: 2, + value: "number" + } + } +}; +var source_image = { + type: { + required: true, + type: "enum", + values: { + image: { + } + } + }, + url: { + required: true, + type: "string" + }, + coordinates: { + required: true, + type: "array", + length: 4, + value: { + type: "array", + length: 2, + value: "number" + } + } +}; +var layer = { + id: { + type: "string", + required: true + }, + type: { + type: "enum", + values: { + fill: { + }, + line: { + }, + symbol: { + }, + circle: { + }, + heatmap: { + }, + "fill-extrusion": { + }, + raster: { + }, + hillshade: { + }, + background: { + } + }, + required: true + }, + metadata: { + type: "*" + }, + source: { + type: "string" + }, + "source-layer": { + type: "string" + }, + minzoom: { + type: "number", + minimum: 0, + maximum: 24 + }, + maxzoom: { + type: "number", + minimum: 0, + maximum: 24 + }, + filter: { + type: "filter" + }, + layout: { + type: "layout" + }, + paint: { + type: "paint" + } +}; +var layout$7 = [ + "layout_fill", + "layout_line", + "layout_circle", + "layout_heatmap", + "layout_fill-extrusion", + "layout_symbol", + "layout_raster", + "layout_hillshade", + "layout_background" +]; +var layout_background = { + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_fill = { + "fill-sort-key": { + type: "number", + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_circle = { + "circle-sort-key": { + type: "number", + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_heatmap = { + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_line = { + "line-cap": { + type: "enum", + values: { + butt: { + }, + round: { + }, + square: { + } + }, + "default": "butt", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "line-join": { + type: "enum", + values: { + bevel: { + }, + round: { + }, + miter: { + } + }, + "default": "miter", + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "line-miter-limit": { + type: "number", + "default": 2, + requires: [ + { + "line-join": "miter" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "line-round-limit": { + type: "number", + "default": 1.05, + requires: [ + { + "line-join": "round" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "line-sort-key": { + type: "number", + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_symbol = { + "symbol-placement": { + type: "enum", + values: { + point: { + }, + line: { + }, + "line-center": { + } + }, + "default": "point", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "symbol-spacing": { + type: "number", + "default": 250, + minimum: 1, + units: "pixels", + requires: [ + { + "symbol-placement": "line" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "symbol-avoid-edges": { + type: "boolean", + "default": false, + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "symbol-sort-key": { + type: "number", + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "symbol-z-order": { + type: "enum", + values: { + auto: { + }, + "viewport-y": { + }, + source: { + } + }, + "default": "auto", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-allow-overlap": { + type: "boolean", + "default": false, + requires: [ + "icon-image", + { + "!": "icon-overlap" + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-overlap": { + type: "enum", + values: { + never: { + }, + always: { + }, + cooperative: { + } + }, + requires: [ + "icon-image" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-ignore-placement": { + type: "boolean", + "default": false, + requires: [ + "icon-image" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-optional": { + type: "boolean", + "default": false, + requires: [ + "icon-image", + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-rotation-alignment": { + type: "enum", + values: { + map: { + }, + viewport: { + }, + auto: { + } + }, + "default": "auto", + requires: [ + "icon-image" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-size": { + type: "number", + "default": 1, + minimum: 0, + units: "factor of the original icon size", + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "icon-text-fit": { + type: "enum", + values: { + none: { + }, + width: { + }, + height: { + }, + both: { + } + }, + "default": "none", + requires: [ + "icon-image", + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-text-fit-padding": { + type: "array", + value: "number", + length: 4, + "default": [ + 0, + 0, + 0, + 0 + ], + units: "pixels", + requires: [ + "icon-image", + "text-field", + { + "icon-text-fit": [ + "both", + "width", + "height" + ] + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-image": { + type: "resolvedImage", + tokens: true, + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "icon-rotate": { + type: "number", + "default": 0, + period: 360, + units: "degrees", + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "icon-padding": { + type: "padding", + "default": [ + 2 + ], + units: "pixels", + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "icon-keep-upright": { + type: "boolean", + "default": false, + requires: [ + "icon-image", + { + "icon-rotation-alignment": "map" + }, + { + "symbol-placement": [ + "line", + "line-center" + ] + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-offset": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "icon-anchor": { + type: "enum", + values: { + center: { + }, + left: { + }, + right: { + }, + top: { + }, + bottom: { + }, + "top-left": { + }, + "top-right": { + }, + "bottom-left": { + }, + "bottom-right": { + } + }, + "default": "center", + requires: [ + "icon-image" + ], + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "icon-pitch-alignment": { + type: "enum", + values: { + map: { + }, + viewport: { + }, + auto: { + } + }, + "default": "auto", + requires: [ + "icon-image" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-pitch-alignment": { + type: "enum", + values: { + map: { + }, + viewport: { + }, + auto: { + } + }, + "default": "auto", + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-rotation-alignment": { + type: "enum", + values: { + map: { + }, + viewport: { + }, + "viewport-glyph": { + }, + auto: { + } + }, + "default": "auto", + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-field": { + type: "formatted", + "default": "", + tokens: true, + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-font": { + type: "array", + value: "string", + "default": [ + "Open Sans Regular", + "Arial Unicode MS Regular" + ], + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-size": { + type: "number", + "default": 16, + minimum: 0, + units: "pixels", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-max-width": { + type: "number", + "default": 10, + minimum: 0, + units: "ems", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-line-height": { + type: "number", + "default": 1.2, + units: "ems", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-letter-spacing": { + type: "number", + "default": 0, + units: "ems", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-justify": { + type: "enum", + values: { + auto: { + }, + left: { + }, + center: { + }, + right: { + } + }, + "default": "center", + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-radial-offset": { + type: "number", + units: "ems", + "default": 0, + requires: [ + "text-field" + ], + "property-type": "data-driven", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + } + }, + "text-variable-anchor": { + type: "array", + value: "enum", + values: { + center: { + }, + left: { + }, + right: { + }, + top: { + }, + bottom: { + }, + "top-left": { + }, + "top-right": { + }, + "bottom-left": { + }, + "bottom-right": { + } + }, + requires: [ + "text-field", + { + "symbol-placement": [ + "point" + ] + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-variable-anchor-offset": { + type: "variableAnchorOffsetCollection", + requires: [ + "text-field", + { + "symbol-placement": [ + "point" + ] + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-anchor": { + type: "enum", + values: { + center: { + }, + left: { + }, + right: { + }, + top: { + }, + bottom: { + }, + "top-left": { + }, + "top-right": { + }, + "bottom-left": { + }, + "bottom-right": { + } + }, + "default": "center", + requires: [ + "text-field", + { + "!": "text-variable-anchor" + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-max-angle": { + type: "number", + "default": 45, + units: "degrees", + requires: [ + "text-field", + { + "symbol-placement": [ + "line", + "line-center" + ] + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-writing-mode": { + type: "array", + value: "enum", + values: { + horizontal: { + }, + vertical: { + } + }, + requires: [ + "text-field", + { + "symbol-placement": [ + "point" + ] + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-rotate": { + type: "number", + "default": 0, + period: 360, + units: "degrees", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-padding": { + type: "number", + "default": 2, + minimum: 0, + units: "pixels", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-keep-upright": { + type: "boolean", + "default": true, + requires: [ + "text-field", + { + "text-rotation-alignment": "map" + }, + { + "symbol-placement": [ + "line", + "line-center" + ] + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-transform": { + type: "enum", + values: { + none: { + }, + uppercase: { + }, + lowercase: { + } + }, + "default": "none", + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-offset": { + type: "array", + value: "number", + units: "ems", + length: 2, + "default": [ + 0, + 0 + ], + requires: [ + "text-field", + { + "!": "text-radial-offset" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "data-driven" + }, + "text-allow-overlap": { + type: "boolean", + "default": false, + requires: [ + "text-field", + { + "!": "text-overlap" + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-overlap": { + type: "enum", + values: { + never: { + }, + always: { + }, + cooperative: { + } + }, + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-ignore-placement": { + type: "boolean", + "default": false, + requires: [ + "text-field" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-optional": { + type: "boolean", + "default": false, + requires: [ + "text-field", + "icon-image" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_raster = { + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var layout_hillshade = { + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}; +var filter = { + type: "array", + value: "*" +}; +var filter_operator = { + type: "enum", + values: { + "==": { + }, + "!=": { + }, + ">": { + }, + ">=": { + }, + "<": { + }, + "<=": { + }, + "in": { + }, + "!in": { + }, + all: { + }, + any: { + }, + none: { + }, + has: { + }, + "!has": { + }, + within: { + } + } +}; +var geometry_type = { + type: "enum", + values: { + Point: { + }, + LineString: { + }, + Polygon: { + } + } +}; +var function_stop = { + type: "array", + minimum: 0, + maximum: 24, + value: [ + "number", + "color" + ], + length: 2 +}; +var expression$1 = { + type: "array", + value: "*", + minimum: 1 +}; +var light = { + anchor: { + type: "enum", + "default": "viewport", + values: { + map: { + }, + viewport: { + } + }, + "property-type": "data-constant", + transition: false, + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + } + }, + position: { + type: "array", + "default": [ + 1.15, + 210, + 30 + ], + length: 3, + value: "number", + "property-type": "data-constant", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + } + }, + color: { + type: "color", + "property-type": "data-constant", + "default": "#ffffff", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + transition: true + }, + intensity: { + type: "number", + "property-type": "data-constant", + "default": 0.5, + minimum: 0, + maximum: 1, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + transition: true + } +}; +var terrain = { + source: { + type: "string", + required: true + }, + exaggeration: { + type: "number", + minimum: 0, + "default": 1 + } +}; +var paint$9 = [ + "paint_fill", + "paint_line", + "paint_circle", + "paint_heatmap", + "paint_fill-extrusion", + "paint_symbol", + "paint_raster", + "paint_hillshade", + "paint_background" +]; +var paint_fill = { + "fill-antialias": { + type: "boolean", + "default": true, + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "fill-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "fill-color": { + type: "color", + "default": "#000000", + transition: true, + requires: [ + { + "!": "fill-pattern" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "fill-outline-color": { + type: "color", + transition: true, + requires: [ + { + "!": "fill-pattern" + }, + { + "fill-antialias": true + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "fill-translate": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "fill-translate-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + requires: [ + "fill-translate" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "fill-pattern": { + type: "resolvedImage", + transition: true, + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "cross-faded-data-driven" + } +}; +var paint_line = { + "line-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "line-color": { + type: "color", + "default": "#000000", + transition: true, + requires: [ + { + "!": "line-pattern" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "line-translate": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "line-translate-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + requires: [ + "line-translate" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "line-width": { + type: "number", + "default": 1, + minimum: 0, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "line-gap-width": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "line-offset": { + type: "number", + "default": 0, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "line-blur": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "line-dasharray": { + type: "array", + value: "number", + minimum: 0, + transition: true, + units: "line widths", + requires: [ + { + "!": "line-pattern" + } + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "cross-faded" + }, + "line-pattern": { + type: "resolvedImage", + transition: true, + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "cross-faded-data-driven" + }, + "line-gradient": { + type: "color", + transition: false, + requires: [ + { + "!": "line-dasharray" + }, + { + "!": "line-pattern" + }, + { + source: "geojson", + has: { + lineMetrics: true + } + } + ], + expression: { + interpolated: true, + parameters: [ + "line-progress" + ] + }, + "property-type": "color-ramp" + } +}; +var paint_circle = { + "circle-radius": { + type: "number", + "default": 5, + minimum: 0, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "circle-color": { + type: "color", + "default": "#000000", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "circle-blur": { + type: "number", + "default": 0, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "circle-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "circle-translate": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "circle-translate-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + requires: [ + "circle-translate" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "circle-pitch-scale": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "circle-pitch-alignment": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "viewport", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "circle-stroke-width": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "circle-stroke-color": { + type: "color", + "default": "#000000", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "circle-stroke-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + } +}; +var paint_heatmap = { + "heatmap-radius": { + type: "number", + "default": 30, + minimum: 1, + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "heatmap-weight": { + type: "number", + "default": 1, + minimum: 0, + transition: false, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "heatmap-intensity": { + type: "number", + "default": 1, + minimum: 0, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "heatmap-color": { + type: "color", + "default": [ + "interpolate", + [ + "linear" + ], + [ + "heatmap-density" + ], + 0, + "rgba(0, 0, 255, 0)", + 0.1, + "royalblue", + 0.3, + "cyan", + 0.5, + "lime", + 0.7, + "yellow", + 1, + "red" + ], + transition: false, + expression: { + interpolated: true, + parameters: [ + "heatmap-density" + ] + }, + "property-type": "color-ramp" + }, + "heatmap-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + } +}; +var paint_symbol = { + "icon-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "icon-color": { + type: "color", + "default": "#000000", + transition: true, + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "icon-halo-color": { + type: "color", + "default": "rgba(0, 0, 0, 0)", + transition: true, + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "icon-halo-width": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "icon-halo-blur": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "icon-translate": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + transition: true, + units: "pixels", + requires: [ + "icon-image" + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "icon-translate-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + requires: [ + "icon-image", + "icon-translate" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "text-color": { + type: "color", + "default": "#000000", + transition: true, + overridable: true, + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "text-halo-color": { + type: "color", + "default": "rgba(0, 0, 0, 0)", + transition: true, + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "text-halo-width": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "text-halo-blur": { + type: "number", + "default": 0, + minimum: 0, + transition: true, + units: "pixels", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "text-translate": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + transition: true, + units: "pixels", + requires: [ + "text-field" + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "text-translate-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + requires: [ + "text-field", + "text-translate" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + } +}; +var paint_raster = { + "raster-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-hue-rotate": { + type: "number", + "default": 0, + period: 360, + transition: true, + units: "degrees", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-brightness-min": { + type: "number", + "default": 0, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-brightness-max": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-saturation": { + type: "number", + "default": 0, + minimum: -1, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-contrast": { + type: "number", + "default": 0, + minimum: -1, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-resampling": { + type: "enum", + values: { + linear: { + }, + nearest: { + } + }, + "default": "linear", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "raster-fade-duration": { + type: "number", + "default": 300, + minimum: 0, + transition: false, + units: "milliseconds", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + } +}; +var paint_hillshade = { + "hillshade-illumination-direction": { + type: "number", + "default": 335, + minimum: 0, + maximum: 359, + transition: false, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "hillshade-illumination-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "viewport", + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "hillshade-exaggeration": { + type: "number", + "default": 0.5, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "hillshade-shadow-color": { + type: "color", + "default": "#000000", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "hillshade-highlight-color": { + type: "color", + "default": "#FFFFFF", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "hillshade-accent-color": { + type: "color", + "default": "#000000", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + } +}; +var paint_background = { + "background-color": { + type: "color", + "default": "#000000", + transition: true, + requires: [ + { + "!": "background-pattern" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "background-pattern": { + type: "resolvedImage", + transition: true, + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "cross-faded" + }, + "background-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + } +}; +var transition = { + duration: { + type: "number", + "default": 300, + minimum: 0, + units: "milliseconds" + }, + delay: { + type: "number", + "default": 0, + minimum: 0, + units: "milliseconds" + } +}; +var promoteId = { + "*": { + type: "string" + } +}; +var v8Spec = { + $version: $version, + $root: $root, + sources: sources, + source: source, + source_vector: source_vector, + source_raster: source_raster, + source_raster_dem: source_raster_dem, + source_geojson: source_geojson, + source_video: source_video, + source_image: source_image, + layer: layer, + layout: layout$7, + layout_background: layout_background, + layout_fill: layout_fill, + layout_circle: layout_circle, + layout_heatmap: layout_heatmap, + "layout_fill-extrusion": { + visibility: { + type: "enum", + values: { + visible: { + }, + none: { + } + }, + "default": "visible", + "property-type": "constant" + } +}, + layout_line: layout_line, + layout_symbol: layout_symbol, + layout_raster: layout_raster, + layout_hillshade: layout_hillshade, + filter: filter, + filter_operator: filter_operator, + geometry_type: geometry_type, + "function": { + expression: { + type: "expression" + }, + stops: { + type: "array", + value: "function_stop" + }, + base: { + type: "number", + "default": 1, + minimum: 0 + }, + property: { + type: "string", + "default": "$zoom" + }, + type: { + type: "enum", + values: { + identity: { + }, + exponential: { + }, + interval: { + }, + categorical: { + } + }, + "default": "exponential" + }, + colorSpace: { + type: "enum", + values: { + rgb: { + }, + lab: { + }, + hcl: { + } + }, + "default": "rgb" + }, + "default": { + type: "*", + required: false + } +}, + function_stop: function_stop, + expression: expression$1, + light: light, + terrain: terrain, + paint: paint$9, + paint_fill: paint_fill, + "paint_fill-extrusion": { + "fill-extrusion-opacity": { + type: "number", + "default": 1, + minimum: 0, + maximum: 1, + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "fill-extrusion-color": { + type: "color", + "default": "#000000", + transition: true, + requires: [ + { + "!": "fill-extrusion-pattern" + } + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "fill-extrusion-translate": { + type: "array", + value: "number", + length: 2, + "default": [ + 0, + 0 + ], + transition: true, + units: "pixels", + expression: { + interpolated: true, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "fill-extrusion-translate-anchor": { + type: "enum", + values: { + map: { + }, + viewport: { + } + }, + "default": "map", + requires: [ + "fill-extrusion-translate" + ], + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + }, + "fill-extrusion-pattern": { + type: "resolvedImage", + transition: true, + expression: { + interpolated: false, + parameters: [ + "zoom", + "feature" + ] + }, + "property-type": "cross-faded-data-driven" + }, + "fill-extrusion-height": { + type: "number", + "default": 0, + minimum: 0, + units: "meters", + transition: true, + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "fill-extrusion-base": { + type: "number", + "default": 0, + minimum: 0, + units: "meters", + transition: true, + requires: [ + "fill-extrusion-height" + ], + expression: { + interpolated: true, + parameters: [ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type": "data-driven" + }, + "fill-extrusion-vertical-gradient": { + type: "boolean", + "default": true, + transition: false, + expression: { + interpolated: false, + parameters: [ + "zoom" + ] + }, + "property-type": "data-constant" + } +}, + paint_line: paint_line, + paint_circle: paint_circle, + paint_heatmap: paint_heatmap, + paint_symbol: paint_symbol, + paint_raster: paint_raster, + paint_hillshade: paint_hillshade, + paint_background: paint_background, + transition: transition, + "property-type": { + "data-driven": { + type: "property-type" + }, + "cross-faded": { + type: "property-type" + }, + "cross-faded-data-driven": { + type: "property-type" + }, + "color-ramp": { + type: "property-type" + }, + "data-constant": { + type: "property-type" + }, + constant: { + type: "property-type" + } +}, + promoteId: promoteId +}; + +const refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout']; + +function deref(layer, parent) { + const result = {}; + for (const k in layer) { + if (k !== 'ref') { + result[k] = layer[k]; + } + } + refProperties.forEach((k) => { + if (k in parent) { + result[k] = parent[k]; + } + }); + return result; +} +/** + * Given an array of layers, some of which may contain `ref` properties + * whose value is the `id` of another property, return a new array where + * such layers have been augmented with the 'type', 'source', etc. properties + * from the parent layer, and the `ref` property has been removed. + * + * The input is not modified. The output may contain references to portions + * of the input. + * + * @private + * @param {Array} layers + * @returns {Array} + */ +function derefLayers(layers) { + layers = layers.slice(); + const map = Object.create(null); + for (let i = 0; i < layers.length; i++) { + map[layers[i].id] = layers[i]; + } + for (let i = 0; i < layers.length; i++) { + if ('ref' in layers[i]) { + layers[i] = deref(layers[i], map[layers[i].ref]); + } + } + return layers; +} + +/** + * Deeply compares two object literals. + * + * @private + */ +function deepEqual(a, b) { + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) + return false; + for (let i = 0; i < a.length; i++) { + if (!deepEqual(a[i], b[i])) + return false; + } + return true; + } + if (typeof a === 'object' && a !== null && b !== null) { + if (!(typeof b === 'object')) + return false; + const keys = Object.keys(a); + if (keys.length !== Object.keys(b).length) + return false; + for (const key in a) { + if (!deepEqual(a[key], b[key])) + return false; + } + return true; + } + return a === b; +} + +const operations = { + /* + * { command: 'setStyle', args: [stylesheet] } + */ + setStyle: 'setStyle', + /* + * { command: 'addLayer', args: [layer, 'beforeLayerId'] } + */ + addLayer: 'addLayer', + /* + * { command: 'removeLayer', args: ['layerId'] } + */ + removeLayer: 'removeLayer', + /* + * { command: 'setPaintProperty', args: ['layerId', 'prop', value] } + */ + setPaintProperty: 'setPaintProperty', + /* + * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] } + */ + setLayoutProperty: 'setLayoutProperty', + /* + * { command: 'setFilter', args: ['layerId', filter] } + */ + setFilter: 'setFilter', + /* + * { command: 'addSource', args: ['sourceId', source] } + */ + addSource: 'addSource', + /* + * { command: 'removeSource', args: ['sourceId'] } + */ + removeSource: 'removeSource', + /* + * { command: 'setGeoJSONSourceData', args: ['sourceId', data] } + */ + setGeoJSONSourceData: 'setGeoJSONSourceData', + /* + * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] } + */ + setLayerZoomRange: 'setLayerZoomRange', + /* + * { command: 'setLayerProperty', args: ['layerId', 'prop', value] } + */ + setLayerProperty: 'setLayerProperty', + /* + * { command: 'setCenter', args: [[lon, lat]] } + */ + setCenter: 'setCenter', + /* + * { command: 'setZoom', args: [zoom] } + */ + setZoom: 'setZoom', + /* + * { command: 'setBearing', args: [bearing] } + */ + setBearing: 'setBearing', + /* + * { command: 'setPitch', args: [pitch] } + */ + setPitch: 'setPitch', + /* + * { command: 'setSprite', args: ['spriteUrl'] } + */ + setSprite: 'setSprite', + /* + * { command: 'setGlyphs', args: ['glyphsUrl'] } + */ + setGlyphs: 'setGlyphs', + /* + * { command: 'setTransition', args: [transition] } + */ + setTransition: 'setTransition', + /* + * { command: 'setLighting', args: [lightProperties] } + */ + setLight: 'setLight' +}; +function addSource(sourceId, after, commands) { + commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] }); +} +function removeSource(sourceId, commands, sourcesRemoved) { + commands.push({ command: operations.removeSource, args: [sourceId] }); + sourcesRemoved[sourceId] = true; +} +function updateSource(sourceId, after, commands, sourcesRemoved) { + removeSource(sourceId, commands, sourcesRemoved); + addSource(sourceId, after, commands); +} +function canUpdateGeoJSON(before, after, sourceId) { + let prop; + for (prop in before[sourceId]) { + if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop)) + continue; + if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) { + return false; + } + } + for (prop in after[sourceId]) { + if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop)) + continue; + if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) { + return false; + } + } + return true; +} +function diffSources(before, after, commands, sourcesRemoved) { + before = before || {}; + after = after || {}; + let sourceId; + // look for sources to remove + for (sourceId in before) { + if (!Object.prototype.hasOwnProperty.call(before, sourceId)) + continue; + if (!Object.prototype.hasOwnProperty.call(after, sourceId)) { + removeSource(sourceId, commands, sourcesRemoved); + } + } + // look for sources to add/update + for (sourceId in after) { + if (!Object.prototype.hasOwnProperty.call(after, sourceId)) + continue; + if (!Object.prototype.hasOwnProperty.call(before, sourceId)) { + addSource(sourceId, after, commands); + } + else if (!deepEqual(before[sourceId], after[sourceId])) { + if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) { + commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] }); + } + else { + // no update command, must remove then add + updateSource(sourceId, after, commands, sourcesRemoved); + } + } + } +} +function diffLayerPropertyChanges(before, after, commands, layerId, klass, command) { + before = before || {}; + after = after || {}; + let prop; + for (prop in before) { + if (!Object.prototype.hasOwnProperty.call(before, prop)) + continue; + if (!deepEqual(before[prop], after[prop])) { + commands.push({ command, args: [layerId, prop, after[prop], klass] }); + } + } + for (prop in after) { + if (!Object.prototype.hasOwnProperty.call(after, prop) || Object.prototype.hasOwnProperty.call(before, prop)) + continue; + if (!deepEqual(before[prop], after[prop])) { + commands.push({ command, args: [layerId, prop, after[prop], klass] }); + } + } +} +function pluckId(layer) { + return layer.id; +} +function indexById(group, layer) { + group[layer.id] = layer; + return group; +} +function diffLayers(before, after, commands) { + before = before || []; + after = after || []; + // order of layers by id + const beforeOrder = before.map(pluckId); + const afterOrder = after.map(pluckId); + // index of layer by id + const beforeIndex = before.reduce(indexById, {}); + const afterIndex = after.reduce(indexById, {}); + // track order of layers as if they have been mutated + const tracker = beforeOrder.slice(); + // layers that have been added do not need to be diffed + const clean = Object.create(null); + let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop; + // remove layers + for (i = 0, d = 0; i < beforeOrder.length; i++) { + layerId = beforeOrder[i]; + if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) { + commands.push({ command: operations.removeLayer, args: [layerId] }); + tracker.splice(tracker.indexOf(layerId, d), 1); + } + else { + // limit where in tracker we need to look for a match + d++; + } + } + // add/reorder layers + for (i = 0, d = 0; i < afterOrder.length; i++) { + // work backwards as insert is before an existing layer + layerId = afterOrder[afterOrder.length - 1 - i]; + if (tracker[tracker.length - 1 - i] === layerId) + continue; + if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) { + // remove the layer before we insert at the correct position + commands.push({ command: operations.removeLayer, args: [layerId] }); + tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1); + } + else { + // limit where in tracker we need to look for a match + d++; + } + // add layer at correct position + insertBeforeLayerId = tracker[tracker.length - i]; + commands.push({ command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId] }); + tracker.splice(tracker.length - i, 0, layerId); + clean[layerId] = true; + } + // update layers + for (i = 0; i < afterOrder.length; i++) { + layerId = afterOrder[i]; + beforeLayer = beforeIndex[layerId]; + afterLayer = afterIndex[layerId]; + // no need to update if previously added (new or moved) + if (clean[layerId] || deepEqual(beforeLayer, afterLayer)) + continue; + // If source, source-layer, or type have changes, then remove the layer + // and add it back 'from scratch'. + if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) { + commands.push({ command: operations.removeLayer, args: [layerId] }); + // we add the layer back at the same position it was already in, so + // there's no need to update the `tracker` + insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1]; + commands.push({ command: operations.addLayer, args: [afterLayer, insertBeforeLayerId] }); + continue; + } + // layout, paint, filter, minzoom, maxzoom + diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty); + diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty); + if (!deepEqual(beforeLayer.filter, afterLayer.filter)) { + commands.push({ command: operations.setFilter, args: [layerId, afterLayer.filter] }); + } + if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) || !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) { + commands.push({ command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] }); + } + // handle all other layer props, including paint.* + for (prop in beforeLayer) { + if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop)) + continue; + if (prop === 'layout' || prop === 'paint' || prop === 'filter' || + prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom') + continue; + if (prop.indexOf('paint.') === 0) { + diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty); + } + else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) { + commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] }); + } + } + for (prop in afterLayer) { + if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) || Object.prototype.hasOwnProperty.call(beforeLayer, prop)) + continue; + if (prop === 'layout' || prop === 'paint' || prop === 'filter' || + prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom') + continue; + if (prop.indexOf('paint.') === 0) { + diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty); + } + else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) { + commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] }); + } + } + } +} +/** + * Diff two stylesheet + * + * Creates semanticly aware diffs that can easily be applied at runtime. + * Operations produced by the diff closely resemble the maplibre-gl-js API. Any + * error creating the diff will fall back to the 'setStyle' operation. + * + * Example diff: + * [ + * { command: 'setConstant', args: ['@water', '#0000FF'] }, + * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] } + * ] + * + * @private + * @param {*} [before] stylesheet to compare from + * @param {*} after stylesheet to compare to + * @returns Array list of changes + */ +function diffStyles(before, after) { + if (!before) + return [{ command: operations.setStyle, args: [after] }]; + let commands = []; + try { + // Handle changes to top-level properties + if (!deepEqual(before.version, after.version)) { + return [{ command: operations.setStyle, args: [after] }]; + } + if (!deepEqual(before.center, after.center)) { + commands.push({ command: operations.setCenter, args: [after.center] }); + } + if (!deepEqual(before.zoom, after.zoom)) { + commands.push({ command: operations.setZoom, args: [after.zoom] }); + } + if (!deepEqual(before.bearing, after.bearing)) { + commands.push({ command: operations.setBearing, args: [after.bearing] }); + } + if (!deepEqual(before.pitch, after.pitch)) { + commands.push({ command: operations.setPitch, args: [after.pitch] }); + } + if (!deepEqual(before.sprite, after.sprite)) { + commands.push({ command: operations.setSprite, args: [after.sprite] }); + } + if (!deepEqual(before.glyphs, after.glyphs)) { + commands.push({ command: operations.setGlyphs, args: [after.glyphs] }); + } + if (!deepEqual(before.transition, after.transition)) { + commands.push({ command: operations.setTransition, args: [after.transition] }); + } + if (!deepEqual(before.light, after.light)) { + commands.push({ command: operations.setLight, args: [after.light] }); + } + // Handle changes to `sources` + // If a source is to be removed, we also--before the removeSource + // command--need to remove all the style layers that depend on it. + const sourcesRemoved = {}; + // First collect the {add,remove}Source commands + const removeOrAddSourceCommands = []; + diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved); + // Push a removeLayer command for each style layer that depends on a + // source that's being removed. + // Also, exclude any such layers them from the input to `diffLayers` + // below, so that diffLayers produces the appropriate `addLayers` + // command + const beforeLayers = []; + if (before.layers) { + before.layers.forEach((layer) => { + if (sourcesRemoved[layer.source]) { + commands.push({ command: operations.removeLayer, args: [layer.id] }); + } + else { + beforeLayers.push(layer); + } + }); + } + commands = commands.concat(removeOrAddSourceCommands); + // Handle changes to `layers` + diffLayers(beforeLayers, after.layers, commands); + } + catch (e) { + // fall back to setStyle + console.warn('Unable to compute style diff:', e); + commands = [{ command: operations.setStyle, args: [after] }]; + } + return commands; +} + +// Note: Do not inherit from Error. It breaks when transpiling to ES5. +class ValidationError { + constructor(key, value, message, identifier) { + this.message = (key ? `${key}: ` : '') + message; + if (identifier) + this.identifier = identifier; + if (value !== null && value !== undefined && value.__line__) { + this.line = value.__line__; + } + } +} + +// Note: Do not inherit from Error. It breaks when transpiling to ES5. +class ParsingError { + constructor(error) { + this.error = error; + this.message = error.message; + const match = error.message.match(/line (\d+)/); + this.line = match ? parseInt(match[1], 10) : 0; + } +} + +function extendBy(output, ...inputs) { + for (const input of inputs) { + for (const k in input) { + output[k] = input[k]; + } + } + return output; +} + +class ExpressionParsingError extends Error { + constructor(key, message) { + super(message); + this.message = message; + this.key = key; + } +} + +/** + * Tracks `let` bindings during expression parsing. + * @private + */ +class Scope { + constructor(parent, bindings = []) { + this.parent = parent; + this.bindings = {}; + for (const [name, expression] of bindings) { + this.bindings[name] = expression; + } + } + concat(bindings) { + return new Scope(this, bindings); + } + get(name) { + if (this.bindings[name]) { + return this.bindings[name]; + } + if (this.parent) { + return this.parent.get(name); + } + throw new Error(`${name} not found in scope.`); + } + has(name) { + if (this.bindings[name]) + return true; + return this.parent ? this.parent.has(name) : false; + } +} + +const NullType = { kind: 'null' }; +const NumberType = { kind: 'number' }; +const StringType = { kind: 'string' }; +const BooleanType = { kind: 'boolean' }; +const ColorType = { kind: 'color' }; +const ObjectType = { kind: 'object' }; +const ValueType = { kind: 'value' }; +const ErrorType = { kind: 'error' }; +const CollatorType = { kind: 'collator' }; +const FormattedType = { kind: 'formatted' }; +const PaddingType = { kind: 'padding' }; +const ResolvedImageType = { kind: 'resolvedImage' }; +const VariableAnchorOffsetCollectionType = { kind: 'variableAnchorOffsetCollection' }; +function array$1(itemType, N) { + return { + kind: 'array', + itemType, + N + }; +} +function toString$1(type) { + if (type.kind === 'array') { + const itemType = toString$1(type.itemType); + return typeof type.N === 'number' ? + `array<${itemType}, ${type.N}>` : + type.itemType.kind === 'value' ? 'array' : `array<${itemType}>`; + } + else { + return type.kind; + } +} +const valueMemberTypes = [ + NullType, + NumberType, + StringType, + BooleanType, + ColorType, + FormattedType, + ObjectType, + array$1(ValueType), + PaddingType, + ResolvedImageType, + VariableAnchorOffsetCollectionType +]; +/** + * Returns null if `t` is a subtype of `expected`; otherwise returns an + * error message. + * @private + */ +function checkSubtype(expected, t) { + if (t.kind === 'error') { + // Error is a subtype of every type + return null; + } + else if (expected.kind === 'array') { + if (t.kind === 'array' && + ((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) && + (typeof expected.N !== 'number' || expected.N === t.N)) { + return null; + } + } + else if (expected.kind === t.kind) { + return null; + } + else if (expected.kind === 'value') { + for (const memberType of valueMemberTypes) { + if (!checkSubtype(memberType, t)) { + return null; + } + } + } + return `Expected ${toString$1(expected)} but found ${toString$1(t)} instead.`; +} +function isValidType(provided, allowedTypes) { + return allowedTypes.some(t => t.kind === provided.kind); +} +function isValidNativeType(provided, allowedTypes) { + return allowedTypes.some(t => { + if (t === 'null') { + return provided === null; + } + else if (t === 'array') { + return Array.isArray(provided); + } + else if (t === 'object') { + return provided && !Array.isArray(provided) && typeof provided === 'object'; + } + else { + return t === typeof provided; + } + }); +} +/** + * Verify whether the specified type is of the same type as the specified sample. + * + * @param provided Type to verify + * @param sample Sample type to reference + * @returns `true` if both objects are of the same type, `false` otherwise + * @example basic types + * if (verifyType(outputType, ValueType)) { + * // type narrowed to: + * outputType.kind; // 'value' + * } + * @example array types + * if (verifyType(outputType, array(NumberType))) { + * // type narrowed to: + * outputType.kind; // 'array' + * outputType.itemType; // NumberTypeT + * outputType.itemType.kind; // 'number' + * } + */ +function verifyType(provided, sample) { + if (provided.kind === 'array' && sample.kind === 'array') { + return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number'; + } + return provided.kind === sample.kind; +} + +// See https://observablehq.com/@mbostock/lab-and-rgb +const Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI; +function constrainAngle(angle) { + angle = angle % 360; + if (angle < 0) { + angle += 360; + } + return angle; +} +function rgbToLab([r, g, b, alpha]) { + r = rgb2xyz(r); + g = rgb2xyz(g); + b = rgb2xyz(b); + let x, z; + const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn); + if (r === g && g === b) { + x = z = y; + } + else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } + const l = 116 * y - 16; + return [(l < 0) ? 0 : l, 500 * (x - y), 200 * (y - z), alpha]; +} +function rgb2xyz(x) { + return (x <= 0.04045) ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); +} +function xyz2lab(t) { + return (t > t3) ? Math.pow(t, 1 / 3) : t / t2 + t0; +} +function labToRgb([l, a, b, alpha]) { + let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200; + y = Yn * lab2xyz(y); + x = Xn * lab2xyz(x); + z = Zn * lab2xyz(z); + return [ + xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z), + alpha, + ]; +} +function xyz2rgb(x) { + x = (x <= 0.00304) ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055; + return (x < 0) ? 0 : (x > 1) ? 1 : x; // clip to 0..1 range +} +function lab2xyz(t) { + return (t > t1) ? t * t * t : t2 * (t - t0); +} +function rgbToHcl(rgbColor) { + const [l, a, b, alpha] = rgbToLab(rgbColor); + const c = Math.sqrt(a * a + b * b); + const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN; + return [h, c, l, alpha]; +} +function hclToRgb([h, c, l, alpha]) { + h = isNaN(h) ? 0 : h * deg2rad; + return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]); +} +// https://drafts.csswg.org/css-color-4/#hsl-to-rgb +function hslToRgb([h, s, l, alpha]) { + h = constrainAngle(h); + s /= 100; + l /= 100; + function f(n) { + const k = (n + h / 30) % 12; + const a = s * Math.min(l, 1 - l); + return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)); + } + return [f(0), f(8), f(4), alpha]; +} + +/** + * CSS color parser compliant with CSS Color 4 Specification. + * Supports: named colors, `transparent` keyword, all rgb hex notations, + * rgb(), rgba(), hsl() and hsla() functions. + * Does not round the parsed values to integers from the range 0..255. + * + * Syntax: + * + * = | + * = | + * + * rgb() = rgb( {3} [ / ]? ) | rgb( {3} [ / ]? ) + * rgb() = rgb( #{3} , ? ) | rgb( #{3} , ? ) + * + * hsl() = hsl( [ / ]? ) + * hsl() = hsl( , , , ? ) + * + * Caveats: + * - - with optional `deg` suffix; `grad`, `rad`, `turn` are not supported + * - `none` keyword is not supported + * - comments inside rgb()/hsl() are not supported + * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb() + * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl() + * + * @param input CSS color string to parse. + * @returns Color in sRGB color space, with `red`, `green`, `blue` + * and `alpha` channels normalized to the range 0..1, + * or `undefined` if the input is not a valid color string. + */ +function parseCssColor(input) { + input = input.toLowerCase().trim(); + if (input === 'transparent') { + return [0, 0, 0, 0]; + } + // 'white', 'black', 'blue' + const namedColorsMatch = namedColors[input]; + if (namedColorsMatch) { + const [r, g, b] = namedColorsMatch; + return [r / 255, g / 255, b / 255, 1]; + } + // #f0c, #f0cf, #ff00cc, #ff00ccff + if (input.startsWith('#')) { + const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/; + if (hexRegexp.test(input)) { + const step = input.length < 6 ? 1 : 2; + let i = 1; + return [ + parseHex(input.slice(i, i += step)), + parseHex(input.slice(i, i += step)), + parseHex(input.slice(i, i += step)), + parseHex(input.slice(i, i + step) || 'ff'), + ]; + } + } + // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6) + if (input.startsWith('rgb')) { + const rgbRegExp = /^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/; + const rgbMatch = input.match(rgbRegExp); + if (rgbMatch) { + const [_, // eslint-disable-line @typescript-eslint/no-unused-vars + r, // + rp, // % (optional) + f1, // , (optional) + g, // + gp, // % (optional) + f2, // , (optional) + b, // + bp, // % (optional) + f3, // ,|/ (optional) + a, // (optional) + ap, // % (optional) + ] = rgbMatch; + const argFormat = [f1 || ' ', f2 || ' ', f3].join(''); + if (argFormat === ' ' || + argFormat === ' /' || + argFormat === ',,' || + argFormat === ',,,') { + const valFormat = [rp, gp, bp].join(''); + const maxValue = (valFormat === '%%%') ? 100 : + (valFormat === '') ? 255 : 0; + if (maxValue) { + const rgba = [ + clamp(+r / maxValue, 0, 1), + clamp(+g / maxValue, 0, 1), + clamp(+b / maxValue, 0, 1), + a ? parseAlpha(+a, ap) : 1, + ]; + if (validateNumbers(rgba)) { + return rgba; + } + // invalid numbers + } + // values must be all numbers or all percentages + } + return; // comma optional syntax requires no commas at all + } + } + // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%) + const hslRegExp = /^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/; + const hslMatch = input.match(hslRegExp); + if (hslMatch) { + const [_, // eslint-disable-line @typescript-eslint/no-unused-vars + h, // + f1, // , (optional) + s, // + f2, // , (optional) + l, // + f3, // ,|/ (optional) + a, // (optional) + ap, // % (optional) + ] = hslMatch; + const argFormat = [f1 || ' ', f2 || ' ', f3].join(''); + if (argFormat === ' ' || + argFormat === ' /' || + argFormat === ',,' || + argFormat === ',,,') { + const hsla = [ + +h, + clamp(+s, 0, 100), + clamp(+l, 0, 100), + a ? parseAlpha(+a, ap) : 1, + ]; + if (validateNumbers(hsla)) { + return hslToRgb(hsla); + } + // invalid numbers + } + // comma optional syntax requires no commas at all + } +} +function parseHex(hex) { + return parseInt(hex.padEnd(2, hex), 16) / 255; +} +function parseAlpha(a, asPercentage) { + return clamp(asPercentage ? (a / 100) : a, 0, 1); +} +function clamp(n, min, max) { + return Math.min(Math.max(min, n), max); +} +/** + * The regular expression for numeric values is not super specific, and it may + * happen that it will accept a value that is not a valid number. In order to + * detect and eliminate such values this function exists. + * + * @param array Array of uncertain numbers. + * @returns `true` if the specified array contains only valid numbers, `false` otherwise. + */ +function validateNumbers(array) { + return !array.some(Number.isNaN); +} +/** + * To generate: + * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors} + * - run in the console: + * @example + * copy(`{\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\s+/).join(', ')}],`).join('\n')}\n}`); + */ +const namedColors = { + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + grey: [128, 128, 128], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + rebeccapurple: [102, 51, 153], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50], +}; + +/** + * Color representation used by WebGL. + * Defined in sRGB color space and pre-blended with alpha. + * @private + */ +class Color { + /** + * @param r Red component premultiplied by `alpha` 0..1 + * @param g Green component premultiplied by `alpha` 0..1 + * @param b Blue component premultiplied by `alpha` 0..1 + * @param [alpha=1] Alpha component 0..1 + * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already + * been multiplied by alpha. If `true` nothing happens if `false` then they will + * be multiplied automatically. + */ + constructor(r, g, b, alpha = 1, premultiplied = true) { + this.r = r; + this.g = g; + this.b = b; + this.a = alpha; + if (!premultiplied) { + this.r *= alpha; + this.g *= alpha; + this.b *= alpha; + if (!alpha) { + // alpha = 0 erases completely rgb channels. This behavior is not desirable + // if this particular color is later used in color interpolation. + // Because of that, a reference to original color is saved. + this.overwriteGetter('rgb', [r, g, b, alpha]); + } + } + } + /** + * Parses CSS color strings and converts colors to sRGB color space if needed. + * Officially supported color formats: + * - keyword, e.g. 'aquamarine' or 'steelblue' + * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9' + * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)' + * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)' + * + * @param input CSS color string to parse. + * @returns A `Color` instance, or `undefined` if the input is not a valid color string. + */ + static parse(input) { + // in zoom-and-property function input could be an instance of Color class + if (input instanceof Color) { + return input; + } + if (typeof input !== 'string') { + return; + } + const rgba = parseCssColor(input); + if (rgba) { + return new Color(...rgba, false); + } + } + /** + * Used in color interpolation and by 'to-rgba' expression. + * + * @returns Gien color, with reversed alpha blending, in sRGB color space. + */ + get rgb() { + const { r, g, b, a } = this; + const f = a || Infinity; // reverse alpha blending factor + return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]); + } + /** + * Used in color interpolation. + * + * @returns Gien color, with reversed alpha blending, in HCL color space. + */ + get hcl() { + return this.overwriteGetter('hcl', rgbToHcl(this.rgb)); + } + /** + * Used in color interpolation. + * + * @returns Gien color, with reversed alpha blending, in LAB color space. + */ + get lab() { + return this.overwriteGetter('lab', rgbToLab(this.rgb)); + } + /** + * Lazy getter pattern. When getter is called for the first time lazy value + * is calculated and then overwrites getter function in given object instance. + * + * @example: + * const redColor = Color.parse('red'); + * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate + * // the value of red in HCL space and invoke this `overwriteGetter` function + * // which in turn will set a field with a key 'hcl' in the `redColor` object. + * // In other words it will override `get hcl()` from its `Color` prototype + * // with its own property: hcl = [calculated red value in hcl]. + * let y = redColor.hcl; // next call will no longer invoke getter but simply + * // return the previously calculated value + * x === y; // true - `x` is exactly the same object as `y` + * + * @param getterKey Getter key + * @param lazyValue Lazily calculated value to be memoized by current instance + * @private + */ + overwriteGetter(getterKey, lazyValue) { + Object.defineProperty(this, getterKey, { value: lazyValue }); + return lazyValue; + } + /** + * Used by 'to-string' expression. + * + * @returns Serialized color in format `rgba(r,g,b,a)` + * where r,g,b are numbers within 0..255 and alpha is number within 1..0 + * + * @example + * var purple = new Color.parse('purple'); + * purple.toString; // = "rgba(128,0,128,1)" + * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)'); + * translucentGreen.toString(); // = "rgba(26,207,26,0.73)" + */ + toString() { + const [r, g, b, a] = this.rgb; + return `rgba(${[r, g, b].map(n => Math.round(n * 255)).join(',')},${a})`; + } +} +Color.black = new Color(0, 0, 0, 1); +Color.white = new Color(1, 1, 1, 1); +Color.transparent = new Color(0, 0, 0, 0); +Color.red = new Color(1, 0, 0, 1); + +// Flow type declarations for Intl cribbed from +// https://github.com/facebook/flow/issues/1270 +class Collator { + constructor(caseSensitive, diacriticSensitive, locale) { + if (caseSensitive) + this.sensitivity = diacriticSensitive ? 'variant' : 'case'; + else + this.sensitivity = diacriticSensitive ? 'accent' : 'base'; + this.locale = locale; + this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: 'search' }); + } + compare(lhs, rhs) { + return this.collator.compare(lhs, rhs); + } + resolvedLocale() { + // We create a Collator without "usage: search" because we don't want + // the search options encoded in our result (e.g. "en-u-co-search") + return new Intl.Collator(this.locale ? this.locale : []) + .resolvedOptions().locale; + } +} + +class FormattedSection { + constructor(text, image, scale, fontStack, textColor) { + this.text = text; + this.image = image; + this.scale = scale; + this.fontStack = fontStack; + this.textColor = textColor; + } +} +class Formatted { + constructor(sections) { + this.sections = sections; + } + static fromString(unformatted) { + return new Formatted([new FormattedSection(unformatted, null, null, null, null)]); + } + isEmpty() { + if (this.sections.length === 0) + return true; + return !this.sections.some(section => section.text.length !== 0 || + (section.image && section.image.name.length !== 0)); + } + static factory(text) { + if (text instanceof Formatted) { + return text; + } + else { + return Formatted.fromString(text); + } + } + toString() { + if (this.sections.length === 0) + return ''; + return this.sections.map(section => section.text).join(''); + } +} + +/** + * A set of four numbers representing padding around a box. Create instances from + * bare arrays or numeric values using the static method `Padding.parse`. + * @private + */ +class Padding { + constructor(values) { + this.values = values.slice(); + } + /** + * Numeric padding values + * @param input A padding value + * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value. + */ + static parse(input) { + if (input instanceof Padding) { + return input; + } + // Backwards compatibility: bare number is treated the same as array with single value. + // Padding applies to all four sides. + if (typeof input === 'number') { + return new Padding([input, input, input, input]); + } + if (!Array.isArray(input)) { + return undefined; + } + if (input.length < 1 || input.length > 4) { + return undefined; + } + for (const val of input) { + if (typeof val !== 'number') { + return undefined; + } + } + // Expand shortcut properties into explicit 4-sided values + switch (input.length) { + case 1: + input = [input[0], input[0], input[0], input[0]]; + break; + case 2: + input = [input[0], input[1], input[0], input[1]]; + break; + case 3: + input = [input[0], input[1], input[2], input[1]]; + break; + } + return new Padding(input); + } + toString() { + return JSON.stringify(this.values); + } +} + +/** Set of valid anchor positions, as a set for validation */ +const anchors = new Set(['center', 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right']); +/** + * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from + * bare arrays using the static method `VariableAnchorOffsetCollection.parse`. + * @private + */ +class VariableAnchorOffsetCollection { + constructor(values) { + this.values = values.slice(); + } + static parse(input) { + if (input instanceof VariableAnchorOffsetCollection) { + return input; + } + if (!Array.isArray(input) || + input.length < 1 || + input.length % 2 !== 0) { + return undefined; + } + for (let i = 0; i < input.length; i += 2) { + // Elements in even positions should be anchor positions; Elements in odd positions should be offset values + const anchorValue = input[i]; + const offsetValue = input[i + 1]; + if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) { + return undefined; + } + if (!Array.isArray(offsetValue) || offsetValue.length !== 2 || typeof offsetValue[0] !== 'number' || typeof offsetValue[1] !== 'number') { + return undefined; + } + } + return new VariableAnchorOffsetCollection(input); + } + toString() { + return JSON.stringify(this.values); + } +} + +class ResolvedImage { + constructor(options) { + this.name = options.name; + this.available = options.available; + } + toString() { + return this.name; + } + static fromString(name) { + if (!name) + return null; // treat empty values as no image + return new ResolvedImage({ name, available: false }); + } +} + +function validateRGBA(r, g, b, a) { + if (!(typeof r === 'number' && r >= 0 && r <= 255 && + typeof g === 'number' && g >= 0 && g <= 255 && + typeof b === 'number' && b >= 0 && b <= 255)) { + const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b]; + return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`; + } + if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) { + return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`; + } + return null; +} +function isValue(mixed) { + if (mixed === null || + typeof mixed === 'string' || + typeof mixed === 'boolean' || + typeof mixed === 'number' || + mixed instanceof Color || + mixed instanceof Collator || + mixed instanceof Formatted || + mixed instanceof Padding || + mixed instanceof VariableAnchorOffsetCollection || + mixed instanceof ResolvedImage) { + return true; + } + else if (Array.isArray(mixed)) { + for (const item of mixed) { + if (!isValue(item)) { + return false; + } + } + return true; + } + else if (typeof mixed === 'object') { + for (const key in mixed) { + if (!isValue(mixed[key])) { + return false; + } + } + return true; + } + else { + return false; + } +} +function typeOf(value) { + if (value === null) { + return NullType; + } + else if (typeof value === 'string') { + return StringType; + } + else if (typeof value === 'boolean') { + return BooleanType; + } + else if (typeof value === 'number') { + return NumberType; + } + else if (value instanceof Color) { + return ColorType; + } + else if (value instanceof Collator) { + return CollatorType; + } + else if (value instanceof Formatted) { + return FormattedType; + } + else if (value instanceof Padding) { + return PaddingType; + } + else if (value instanceof VariableAnchorOffsetCollection) { + return VariableAnchorOffsetCollectionType; + } + else if (value instanceof ResolvedImage) { + return ResolvedImageType; + } + else if (Array.isArray(value)) { + const length = value.length; + let itemType; + for (const item of value) { + const t = typeOf(item); + if (!itemType) { + itemType = t; + } + else if (itemType === t) { + continue; + } + else { + itemType = ValueType; + break; + } + } + return array$1(itemType || ValueType, length); + } + else { + return ObjectType; + } +} +function toString(value) { + const type = typeof value; + if (value === null) { + return ''; + } + else if (type === 'string' || type === 'number' || type === 'boolean') { + return String(value); + } + else if (value instanceof Color || value instanceof Formatted || value instanceof Padding || value instanceof VariableAnchorOffsetCollection || value instanceof ResolvedImage) { + return value.toString(); + } + else { + return JSON.stringify(value); + } +} + +class Literal { + constructor(type, value) { + this.type = type; + this.value = value; + } + static parse(args, context) { + if (args.length !== 2) + return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`); + if (!isValue(args[1])) + return context.error('invalid value'); + const value = args[1]; + let type = typeOf(value); + // special case: infer the item type if possible for zero-length arrays + const expected = context.expectedType; + if (type.kind === 'array' && + type.N === 0 && + expected && + expected.kind === 'array' && + (typeof expected.N !== 'number' || expected.N === 0)) { + type = expected; + } + return new Literal(type, value); + } + evaluate() { + return this.value; + } + eachChild() { } + outputDefined() { + return true; + } +} + +class RuntimeError { + constructor(message) { + this.name = 'ExpressionEvaluationError'; + this.message = message; + } + toJSON() { + return this.message; + } +} + +const types$1 = { + string: StringType, + number: NumberType, + boolean: BooleanType, + object: ObjectType +}; +class Assertion { + constructor(type, args) { + this.type = type; + this.args = args; + } + static parse(args, context) { + if (args.length < 2) + return context.error('Expected at least one argument.'); + let i = 1; + let type; + const name = args[0]; + if (name === 'array') { + let itemType; + if (args.length > 2) { + const type = args[1]; + if (typeof type !== 'string' || !(type in types$1) || type === 'object') + return context.error('The item type argument of "array" must be one of string, number, boolean', 1); + itemType = types$1[type]; + i++; + } + else { + itemType = ValueType; + } + let N; + if (args.length > 3) { + if (args[2] !== null && + (typeof args[2] !== 'number' || + args[2] < 0 || + args[2] !== Math.floor(args[2]))) { + return context.error('The length argument to "array" must be a positive integer literal', 2); + } + N = args[2]; + i++; + } + type = array$1(itemType, N); + } + else { + if (!types$1[name]) + throw new Error(`Types doesn't contain name = ${name}`); + type = types$1[name]; + } + const parsed = []; + for (; i < args.length; i++) { + const input = context.parse(args[i], i, ValueType); + if (!input) + return null; + parsed.push(input); + } + return new Assertion(type, parsed); + } + evaluate(ctx) { + for (let i = 0; i < this.args.length; i++) { + const value = this.args[i].evaluate(ctx); + const error = checkSubtype(this.type, typeOf(value)); + if (!error) { + return value; + } + else if (i === this.args.length - 1) { + throw new RuntimeError(`Expected value to be of type ${toString$1(this.type)}, but found ${toString$1(typeOf(value))} instead.`); + } + } + throw new Error(); + } + eachChild(fn) { + this.args.forEach(fn); + } + outputDefined() { + return this.args.every(arg => arg.outputDefined()); + } +} + +const types = { + 'to-boolean': BooleanType, + 'to-color': ColorType, + 'to-number': NumberType, + 'to-string': StringType +}; +/** + * Special form for error-coalescing coercion expressions "to-number", + * "to-color". Since these coercions can fail at runtime, they accept multiple + * arguments, only evaluating one at a time until one succeeds. + * + * @private + */ +class Coercion { + constructor(type, args) { + this.type = type; + this.args = args; + } + static parse(args, context) { + if (args.length < 2) + return context.error('Expected at least one argument.'); + const name = args[0]; + if (!types[name]) + throw new Error(`Can't parse ${name} as it is not part of the known types`); + if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2) + return context.error('Expected one argument.'); + const type = types[name]; + const parsed = []; + for (let i = 1; i < args.length; i++) { + const input = context.parse(args[i], i, ValueType); + if (!input) + return null; + parsed.push(input); + } + return new Coercion(type, parsed); + } + evaluate(ctx) { + switch (this.type.kind) { + case 'boolean': + return Boolean(this.args[0].evaluate(ctx)); + case 'color': { + let input; + let error; + for (const arg of this.args) { + input = arg.evaluate(ctx); + error = null; + if (input instanceof Color) { + return input; + } + else if (typeof input === 'string') { + const c = ctx.parseColor(input); + if (c) + return c; + } + else if (Array.isArray(input)) { + if (input.length < 3 || input.length > 4) { + error = `Invalid rbga value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`; + } + else { + error = validateRGBA(input[0], input[1], input[2], input[3]); + } + if (!error) { + return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]); + } + } + } + throw new RuntimeError(error || `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`); + } + case 'padding': { + let input; + for (const arg of this.args) { + input = arg.evaluate(ctx); + const pad = Padding.parse(input); + if (pad) { + return pad; + } + } + throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`); + } + case 'variableAnchorOffsetCollection': { + let input; + for (const arg of this.args) { + input = arg.evaluate(ctx); + const coll = VariableAnchorOffsetCollection.parse(input); + if (coll) { + return coll; + } + } + throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`); + } + case 'number': { + let value = null; + for (const arg of this.args) { + value = arg.evaluate(ctx); + if (value === null) + return 0; + const num = Number(value); + if (isNaN(num)) + continue; + return num; + } + throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`); + } + case 'formatted': + // There is no explicit 'to-formatted' but this coercion can be implicitly + // created by properties that expect the 'formatted' type. + return Formatted.fromString(toString(this.args[0].evaluate(ctx))); + case 'resolvedImage': + return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx))); + default: + return toString(this.args[0].evaluate(ctx)); + } + } + eachChild(fn) { + this.args.forEach(fn); + } + outputDefined() { + return this.args.every(arg => arg.outputDefined()); + } +} + +const geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon']; +class EvaluationContext { + constructor() { + this.globals = null; + this.feature = null; + this.featureState = null; + this.formattedSection = null; + this._parseColorCache = {}; + this.availableImages = null; + this.canonical = null; + } + id() { + return this.feature && 'id' in this.feature ? this.feature.id : null; + } + geometryType() { + return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null; + } + geometry() { + return this.feature && 'geometry' in this.feature ? this.feature.geometry : null; + } + canonicalID() { + return this.canonical; + } + properties() { + return this.feature && this.feature.properties || {}; + } + parseColor(input) { + let cached = this._parseColorCache[input]; + if (!cached) { + cached = this._parseColorCache[input] = Color.parse(input); + } + return cached; + } +} + +/** + * State associated parsing at a given point in an expression tree. + * @private + */ +class ParsingContext { + constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) { + this.registry = registry; + this.path = path; + this.key = path.map(part => `[${part}]`).join(''); + this.scope = scope; + this.errors = errors; + this.expectedType = expectedType; + this._isConstant = isConstantFunc; + } + /** + * @param expr the JSON expression to parse + * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed + * @param options + * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation. + * @private + */ + parse(expr, index, expectedType, bindings, options = {}) { + if (index) { + return this.concat(index, expectedType, bindings)._parse(expr, options); + } + return this._parse(expr, options); + } + _parse(expr, options) { + if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') { + expr = ['literal', expr]; + } + function annotate(parsed, type, typeAnnotation) { + if (typeAnnotation === 'assert') { + return new Assertion(type, [parsed]); + } + else if (typeAnnotation === 'coerce') { + return new Coercion(type, [parsed]); + } + else { + return parsed; + } + } + if (Array.isArray(expr)) { + if (expr.length === 0) { + return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].'); + } + const op = expr[0]; + if (typeof op !== 'string') { + this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use ["literal", [...]].`, 0); + return null; + } + const Expr = this.registry[op]; + if (Expr) { + let parsed = Expr.parse(expr, this); + if (!parsed) + return null; + if (this.expectedType) { + const expected = this.expectedType; + const actual = parsed.type; + // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion. + // When we expect a color or formatted string, but have a string or value, wrap it in a coercion. + // Otherwise, we do static type-checking. + // + // These behaviors are overridable for: + // * The "coalesce" operator, which needs to omit type annotations. + // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion. + // + if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') { + parsed = annotate(parsed, expected, options.typeAnnotation || 'assert'); + } + else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) { + parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce'); + } + else if (expected.kind === 'padding' && (actual.kind === 'value' || actual.kind === 'number' || actual.kind === 'array')) { + parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce'); + } + else if (expected.kind === 'variableAnchorOffsetCollection' && (actual.kind === 'value' || actual.kind === 'array')) { + parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce'); + } + else if (this.checkSubtype(expected, actual)) { + return null; + } + } + // If an expression's arguments are all literals, we can evaluate + // it immediately and replace it with a literal value in the + // parsed/compiled result. Expressions that expect an image should + // not be resolved here so we can later get the available images. + if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && this._isConstant(parsed)) { + const ec = new EvaluationContext(); + try { + parsed = new Literal(parsed.type, parsed.evaluate(ec)); + } + catch (e) { + this.error(e.message); + return null; + } + } + return parsed; + } + return this.error(`Unknown expression "${op}". If you wanted a literal array, use ["literal", [...]].`, 0); + } + else if (typeof expr === 'undefined') { + return this.error('\'undefined\' value invalid. Use null instead.'); + } + else if (typeof expr === 'object') { + return this.error('Bare objects invalid. Use ["literal", {...}] instead.'); + } + else { + return this.error(`Expected an array, but found ${typeof expr} instead.`); + } + } + /** + * Returns a copy of this context suitable for parsing the subexpression at + * index `index`, optionally appending to 'let' binding map. + * + * Note that `errors` property, intended for collecting errors while + * parsing, is copied by reference rather than cloned. + * @private + */ + concat(index, expectedType, bindings) { + const path = typeof index === 'number' ? this.path.concat(index) : this.path; + const scope = bindings ? this.scope.concat(bindings) : this.scope; + return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors); + } + /** + * Push a parsing (or type checking) error into the `this.errors` + * @param error The message + * @param keys Optionally specify the source of the error at a child + * of the current expression at `this.key`. + * @private + */ + error(error, ...keys) { + const key = `${this.key}${keys.map(k => `[${k}]`).join('')}`; + this.errors.push(new ExpressionParsingError(key, error)); + } + /** + * Returns null if `t` is a subtype of `expected`; otherwise returns an + * error message and also pushes it to `this.errors`. + * @param expected The expected type + * @param t The actual type + * @returns null if `t` is a subtype of `expected`; otherwise returns an error message + */ + checkSubtype(expected, t) { + const error = checkSubtype(expected, t); + if (error) + this.error(error); + return error; + } +} + +class CollatorExpression { + constructor(caseSensitive, diacriticSensitive, locale) { + this.type = CollatorType; + this.locale = locale; + this.caseSensitive = caseSensitive; + this.diacriticSensitive = diacriticSensitive; + } + static parse(args, context) { + if (args.length !== 2) + return context.error('Expected one argument.'); + const options = args[1]; + if (typeof options !== 'object' || Array.isArray(options)) + return context.error('Collator options argument must be an object.'); + const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType); + if (!caseSensitive) + return null; + const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType); + if (!diacriticSensitive) + return null; + let locale = null; + if (options['locale']) { + locale = context.parse(options['locale'], 1, StringType); + if (!locale) + return null; + } + return new CollatorExpression(caseSensitive, diacriticSensitive, locale); + } + evaluate(ctx) { + return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null); + } + eachChild(fn) { + fn(this.caseSensitive); + fn(this.diacriticSensitive); + if (this.locale) { + fn(this.locale); + } + } + outputDefined() { + // Technically the set of possible outputs is the combinatoric set of Collators produced + // by all possible outputs of locale/caseSensitive/diacriticSensitive + // But for the primary use of Collators in comparison operators, we ignore the Collator's + // possible outputs anyway, so we can get away with leaving this false for now. + return false; + } +} + +const EXTENT$1 = 8192; +function updateBBox(bbox, coord) { + bbox[0] = Math.min(bbox[0], coord[0]); + bbox[1] = Math.min(bbox[1], coord[1]); + bbox[2] = Math.max(bbox[2], coord[0]); + bbox[3] = Math.max(bbox[3], coord[1]); +} +function mercatorXfromLng$1(lng) { + return (180 + lng) / 360; +} +function mercatorYfromLat$1(lat) { + return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360; +} +function boxWithinBox(bbox1, bbox2) { + if (bbox1[0] <= bbox2[0]) + return false; + if (bbox1[2] >= bbox2[2]) + return false; + if (bbox1[1] <= bbox2[1]) + return false; + if (bbox1[3] >= bbox2[3]) + return false; + return true; +} +function getTileCoordinates(p, canonical) { + const x = mercatorXfromLng$1(p[0]); + const y = mercatorYfromLat$1(p[1]); + const tilesAtZoom = Math.pow(2, canonical.z); + return [Math.round(x * tilesAtZoom * EXTENT$1), Math.round(y * tilesAtZoom * EXTENT$1)]; +} +function onBoundary(p, p1, p2) { + const x1 = p[0] - p1[0]; + const y1 = p[1] - p1[1]; + const x2 = p[0] - p2[0]; + const y2 = p[1] - p2[1]; + return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0); +} +function rayIntersect(p, p1, p2) { + return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]); +} +// ray casting algorithm for detecting if point is in polygon +function pointWithinPolygon(point, rings) { + let inside = false; + for (let i = 0, len = rings.length; i < len; i++) { + const ring = rings[i]; + for (let j = 0, len2 = ring.length; j < len2 - 1; j++) { + if (onBoundary(point, ring[j], ring[j + 1])) + return false; + if (rayIntersect(point, ring[j], ring[j + 1])) + inside = !inside; + } + } + return inside; +} +function pointWithinPolygons(point, polygons) { + for (let i = 0; i < polygons.length; i++) { + if (pointWithinPolygon(point, polygons[i])) + return true; + } + return false; +} +function perp(v1, v2) { + return (v1[0] * v2[1] - v1[1] * v2[0]); +} +// check if p1 and p2 are in different sides of line segment q1->q2 +function twoSided(p1, p2, q1, q2) { + // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3) + const x1 = p1[0] - q1[0]; + const y1 = p1[1] - q1[1]; + const x2 = p2[0] - q1[0]; + const y2 = p2[1] - q1[1]; + const x3 = q2[0] - q1[0]; + const y3 = q2[1] - q1[1]; + const det1 = (x1 * y3 - x3 * y1); + const det2 = (x2 * y3 - x3 * y2); + if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0)) + return true; + return false; +} +// a, b are end points for line segment1, c and d are end points for line segment2 +function lineIntersectLine(a, b, c, d) { + // check if two segments are parallel or not + // precondition is end point a, b is inside polygon, if line a->b is + // parallel to polygon edge c->d, then a->b won't intersect with c->d + const vectorP = [b[0] - a[0], b[1] - a[1]]; + const vectorQ = [d[0] - c[0], d[1] - c[1]]; + if (perp(vectorQ, vectorP) === 0) + return false; + // If lines are intersecting with each other, the relative location should be: + // a and b lie in different sides of segment c->d + // c and d lie in different sides of segment a->b + if (twoSided(a, b, c, d) && twoSided(c, d, a, b)) + return true; + return false; +} +function lineIntersectPolygon(p1, p2, polygon) { + for (const ring of polygon) { + // loop through every edge of the ring + for (let j = 0; j < ring.length - 1; ++j) { + if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) { + return true; + } + } + } + return false; +} +function lineStringWithinPolygon(line, polygon) { + // First, check if geometry points of line segments are all inside polygon + for (let i = 0; i < line.length; ++i) { + if (!pointWithinPolygon(line[i], polygon)) { + return false; + } + } + // Second, check if there is line segment intersecting polygon edge + for (let i = 0; i < line.length - 1; ++i) { + if (lineIntersectPolygon(line[i], line[i + 1], polygon)) { + return false; + } + } + return true; +} +function lineStringWithinPolygons(line, polygons) { + for (let i = 0; i < polygons.length; i++) { + if (lineStringWithinPolygon(line, polygons[i])) + return true; + } + return false; +} +function getTilePolygon(coordinates, bbox, canonical) { + const polygon = []; + for (let i = 0; i < coordinates.length; i++) { + const ring = []; + for (let j = 0; j < coordinates[i].length; j++) { + const coord = getTileCoordinates(coordinates[i][j], canonical); + updateBBox(bbox, coord); + ring.push(coord); + } + polygon.push(ring); + } + return polygon; +} +function getTilePolygons(coordinates, bbox, canonical) { + const polygons = []; + for (let i = 0; i < coordinates.length; i++) { + const polygon = getTilePolygon(coordinates[i], bbox, canonical); + polygons.push(polygon); + } + return polygons; +} +function updatePoint(p, bbox, polyBBox, worldSize) { + if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) { + const halfWorldSize = worldSize * 0.5; + let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0; + if (shift === 0) { + shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0; + } + p[0] += shift; + } + updateBBox(bbox, p); +} +function resetBBox(bbox) { + bbox[0] = bbox[1] = Infinity; + bbox[2] = bbox[3] = -Infinity; +} +function getTilePoints(geometry, pointBBox, polyBBox, canonical) { + const worldSize = Math.pow(2, canonical.z) * EXTENT$1; + const shifts = [canonical.x * EXTENT$1, canonical.y * EXTENT$1]; + const tilePoints = []; + for (const points of geometry) { + for (const point of points) { + const p = [point.x + shifts[0], point.y + shifts[1]]; + updatePoint(p, pointBBox, polyBBox, worldSize); + tilePoints.push(p); + } + } + return tilePoints; +} +function getTileLines(geometry, lineBBox, polyBBox, canonical) { + const worldSize = Math.pow(2, canonical.z) * EXTENT$1; + const shifts = [canonical.x * EXTENT$1, canonical.y * EXTENT$1]; + const tileLines = []; + for (const line of geometry) { + const tileLine = []; + for (const point of line) { + const p = [point.x + shifts[0], point.y + shifts[1]]; + updateBBox(lineBBox, p); + tileLine.push(p); + } + tileLines.push(tileLine); + } + if (lineBBox[2] - lineBBox[0] <= worldSize / 2) { + resetBBox(lineBBox); + for (const line of tileLines) { + for (const p of line) { + updatePoint(p, lineBBox, polyBBox, worldSize); + } + } + } + return tileLines; +} +function pointsWithinPolygons(ctx, polygonGeometry) { + const pointBBox = [Infinity, Infinity, -Infinity, -Infinity]; + const polyBBox = [Infinity, Infinity, -Infinity, -Infinity]; + const canonical = ctx.canonicalID(); + if (polygonGeometry.type === 'Polygon') { + const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical); + const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical); + if (!boxWithinBox(pointBBox, polyBBox)) + return false; + for (const point of tilePoints) { + if (!pointWithinPolygon(point, tilePolygon)) + return false; + } + } + if (polygonGeometry.type === 'MultiPolygon') { + const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical); + const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical); + if (!boxWithinBox(pointBBox, polyBBox)) + return false; + for (const point of tilePoints) { + if (!pointWithinPolygons(point, tilePolygons)) + return false; + } + } + return true; +} +function linesWithinPolygons(ctx, polygonGeometry) { + const lineBBox = [Infinity, Infinity, -Infinity, -Infinity]; + const polyBBox = [Infinity, Infinity, -Infinity, -Infinity]; + const canonical = ctx.canonicalID(); + if (polygonGeometry.type === 'Polygon') { + const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical); + const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical); + if (!boxWithinBox(lineBBox, polyBBox)) + return false; + for (const line of tileLines) { + if (!lineStringWithinPolygon(line, tilePolygon)) + return false; + } + } + if (polygonGeometry.type === 'MultiPolygon') { + const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical); + const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical); + if (!boxWithinBox(lineBBox, polyBBox)) + return false; + for (const line of tileLines) { + if (!lineStringWithinPolygons(line, tilePolygons)) + return false; + } + } + return true; +} +class Within { + constructor(geojson, geometries) { + this.type = BooleanType; + this.geojson = geojson; + this.geometries = geometries; + } + static parse(args, context) { + if (args.length !== 2) + return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`); + if (isValue(args[1])) { + const geojson = args[1]; + if (geojson.type === 'FeatureCollection') { + for (let i = 0; i < geojson.features.length; ++i) { + const type = geojson.features[i].geometry.type; + if (type === 'Polygon' || type === 'MultiPolygon') { + return new Within(geojson, geojson.features[i].geometry); + } + } + } + else if (geojson.type === 'Feature') { + const type = geojson.geometry.type; + if (type === 'Polygon' || type === 'MultiPolygon') { + return new Within(geojson, geojson.geometry); + } + } + else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') { + return new Within(geojson, geojson); + } + } + return context.error('\'within\' expression requires valid geojson object that contains polygon geometry type.'); + } + evaluate(ctx) { + if (ctx.geometry() != null && ctx.canonicalID() != null) { + if (ctx.geometryType() === 'Point') { + return pointsWithinPolygons(ctx, this.geometries); + } + else if (ctx.geometryType() === 'LineString') { + return linesWithinPolygons(ctx, this.geometries); + } + } + return false; + } + eachChild() { } + outputDefined() { + return true; + } +} + +class Var { + constructor(name, boundExpression) { + this.type = boundExpression.type; + this.name = name; + this.boundExpression = boundExpression; + } + static parse(args, context) { + if (args.length !== 2 || typeof args[1] !== 'string') + return context.error('\'var\' expression requires exactly one string literal argument.'); + const name = args[1]; + if (!context.scope.has(name)) { + return context.error(`Unknown variable "${name}". Make sure "${name}" has been bound in an enclosing "let" expression before using it.`, 1); + } + return new Var(name, context.scope.get(name)); + } + evaluate(ctx) { + return this.boundExpression.evaluate(ctx); + } + eachChild() { } + outputDefined() { + return false; + } +} + +class CompoundExpression { + constructor(name, type, evaluate, args) { + this.name = name; + this.type = type; + this._evaluate = evaluate; + this.args = args; + } + evaluate(ctx) { + return this._evaluate(ctx, this.args); + } + eachChild(fn) { + this.args.forEach(fn); + } + outputDefined() { + return false; + } + static parse(args, context) { + const op = args[0]; + const definition = CompoundExpression.definitions[op]; + if (!definition) { + return context.error(`Unknown expression "${op}". If you wanted a literal array, use ["literal", [...]].`, 0); + } + // Now check argument types against each signature + const type = Array.isArray(definition) ? + definition[0] : definition.type; + const availableOverloads = Array.isArray(definition) ? + [[definition[1], definition[2]]] : + definition.overloads; + const overloads = availableOverloads.filter(([signature]) => (!Array.isArray(signature) || // varags + signature.length === args.length - 1 // correct param count + )); + let signatureContext = null; + for (const [params, evaluate] of overloads) { + // Use a fresh context for each attempted signature so that, if + // we eventually succeed, we haven't polluted `context.errors`. + signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope); + // First parse all the args, potentially coercing to the + // types expected by this overload. + const parsedArgs = []; + let argParseFailed = false; + for (let i = 1; i < args.length; i++) { + const arg = args[i]; + const expectedType = Array.isArray(params) ? + params[i - 1] : + params.type; + const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType); + if (!parsed) { + argParseFailed = true; + break; + } + parsedArgs.push(parsed); + } + if (argParseFailed) { + // Couldn't coerce args of this overload to expected type, move + // on to next one. + continue; + } + if (Array.isArray(params)) { + if (params.length !== parsedArgs.length) { + signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`); + continue; + } + } + for (let i = 0; i < parsedArgs.length; i++) { + const expected = Array.isArray(params) ? params[i] : params.type; + const arg = parsedArgs[i]; + signatureContext.concat(i + 1).checkSubtype(expected, arg.type); + } + if (signatureContext.errors.length === 0) { + return new CompoundExpression(op, type, evaluate, parsedArgs); + } + } + if (overloads.length === 1) { + context.errors.push(...signatureContext.errors); + } + else { + const expected = overloads.length ? overloads : availableOverloads; + const signatures = expected + .map(([params]) => stringifySignature(params)) + .join(' | '); + const actualTypes = []; + // For error message, re-parse arguments without trying to + // apply any coercions + for (let i = 1; i < args.length; i++) { + const parsed = context.parse(args[i], 1 + actualTypes.length); + if (!parsed) + return null; + actualTypes.push(toString$1(parsed.type)); + } + context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`); + } + return null; + } + static register(registry, definitions) { + CompoundExpression.definitions = definitions; + for (const name in definitions) { + registry[name] = CompoundExpression; + } + } +} +function stringifySignature(signature) { + if (Array.isArray(signature)) { + return `(${signature.map(toString$1).join(', ')})`; + } + else { + return `(${toString$1(signature.type)}...)`; + } +} +function isExpressionConstant(expression) { + if (expression instanceof Var) { + return isExpressionConstant(expression.boundExpression); + } + else if (expression instanceof CompoundExpression && expression.name === 'error') { + return false; + } + else if (expression instanceof CollatorExpression) { + // Although the results of a Collator expression with fixed arguments + // generally shouldn't change between executions, we can't serialize them + // as constant expressions because results change based on environment. + return false; + } + else if (expression instanceof Within) { + return false; + } + const isTypeAnnotation = expression instanceof Coercion || + expression instanceof Assertion; + let childrenConstant = true; + expression.eachChild(child => { + // We can _almost_ assume that if `expressions` children are constant, + // they would already have been evaluated to Literal values when they + // were parsed. Type annotations are the exception, because they might + // have been inferred and added after a child was parsed. + // So we recurse into isConstant() for the children of type annotations, + // but otherwise simply check whether they are Literals. + if (isTypeAnnotation) { + childrenConstant = childrenConstant && isExpressionConstant(child); + } + else { + childrenConstant = childrenConstant && child instanceof Literal; + } + }); + if (!childrenConstant) { + return false; + } + return isFeatureConstant(expression) && + isGlobalPropertyConstant(expression, ['zoom', 'heatmap-density', 'line-progress', 'accumulated', 'is-supported-script']); +} +function isFeatureConstant(e) { + if (e instanceof CompoundExpression) { + if (e.name === 'get' && e.args.length === 1) { + return false; + } + else if (e.name === 'feature-state') { + return false; + } + else if (e.name === 'has' && e.args.length === 1) { + return false; + } + else if (e.name === 'properties' || + e.name === 'geometry-type' || + e.name === 'id') { + return false; + } + else if (/^filter-/.test(e.name)) { + return false; + } + } + if (e instanceof Within) { + return false; + } + let result = true; + e.eachChild(arg => { + if (result && !isFeatureConstant(arg)) { + result = false; + } + }); + return result; +} +function isStateConstant(e) { + if (e instanceof CompoundExpression) { + if (e.name === 'feature-state') { + return false; + } + } + let result = true; + e.eachChild(arg => { + if (result && !isStateConstant(arg)) { + result = false; + } + }); + return result; +} +function isGlobalPropertyConstant(e, properties) { + if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) { + return false; + } + let result = true; + e.eachChild((arg) => { + if (result && !isGlobalPropertyConstant(arg, properties)) { + result = false; + } + }); + return result; +} + +/** + * Returns the index of the last stop <= input, or 0 if it doesn't exist. + * @private + */ +function findStopLessThanOrEqualTo(stops, input) { + const lastIndex = stops.length - 1; + let lowerIndex = 0; + let upperIndex = lastIndex; + let currentIndex = 0; + let currentValue, nextValue; + while (lowerIndex <= upperIndex) { + currentIndex = Math.floor((lowerIndex + upperIndex) / 2); + currentValue = stops[currentIndex]; + nextValue = stops[currentIndex + 1]; + if (currentValue <= input) { + if (currentIndex === lastIndex || input < nextValue) { // Search complete + return currentIndex; + } + lowerIndex = currentIndex + 1; + } + else if (currentValue > input) { + upperIndex = currentIndex - 1; + } + else { + throw new RuntimeError('Input is not a number.'); + } + } + return 0; +} + +class Step { + constructor(type, input, stops) { + this.type = type; + this.input = input; + this.labels = []; + this.outputs = []; + for (const [label, expression] of stops) { + this.labels.push(label); + this.outputs.push(expression); + } + } + static parse(args, context) { + if (args.length - 1 < 4) { + return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`); + } + if ((args.length - 1) % 2 !== 0) { + return context.error('Expected an even number of arguments.'); + } + const input = context.parse(args[1], 1, NumberType); + if (!input) + return null; + const stops = []; + let outputType = null; + if (context.expectedType && context.expectedType.kind !== 'value') { + outputType = context.expectedType; + } + for (let i = 1; i < args.length; i += 2) { + const label = i === 1 ? -Infinity : args[i]; + const value = args[i + 1]; + const labelKey = i; + const valueKey = i + 1; + if (typeof label !== 'number') { + return context.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey); + } + if (stops.length && stops[stops.length - 1][0] >= label) { + return context.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', labelKey); + } + const parsed = context.parse(value, valueKey, outputType); + if (!parsed) + return null; + outputType = outputType || parsed.type; + stops.push([label, parsed]); + } + return new Step(outputType, input, stops); + } + evaluate(ctx) { + const labels = this.labels; + const outputs = this.outputs; + if (labels.length === 1) { + return outputs[0].evaluate(ctx); + } + const value = this.input.evaluate(ctx); + if (value <= labels[0]) { + return outputs[0].evaluate(ctx); + } + const stopCount = labels.length; + if (value >= labels[stopCount - 1]) { + return outputs[stopCount - 1].evaluate(ctx); + } + const index = findStopLessThanOrEqualTo(labels, value); + return outputs[index].evaluate(ctx); + } + eachChild(fn) { + fn(this.input); + for (const expression of this.outputs) { + fn(expression); + } + } + outputDefined() { + return this.outputs.every(out => out.outputDefined()); + } +} + +/** + * Checks whether the specified color space is one of the supported interpolation color spaces. + * + * @param colorSpace Color space key to verify. + * @returns `true` if the specified color space is one of the supported + * interpolation color spaces, `false` otherwise + */ +function isSupportedInterpolationColorSpace(colorSpace) { + return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab'; +} +/** + * @param interpolationType Interpolation type + * @returns interpolation fn + * @deprecated use `interpolate[type]` instead + */ +const interpolateFactory = (interpolationType) => { + switch (interpolationType) { + case 'number': return number; + case 'color': return color; + case 'array': return array; + case 'padding': return padding; + case 'variableAnchorOffsetCollection': return variableAnchorOffsetCollection; + } +}; +function number(from, to, t) { + return from + t * (to - from); +} +function color(from, to, t, spaceKey = 'rgb') { + switch (spaceKey) { + case 'rgb': { + const [r, g, b, alpha] = array(from.rgb, to.rgb, t); + return new Color(r, g, b, alpha, false); + } + case 'hcl': { + const [hue0, chroma0, light0, alphaF] = from.hcl; + const [hue1, chroma1, light1, alphaT] = to.hcl; + // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js + let hue, chroma; + if (!isNaN(hue0) && !isNaN(hue1)) { + let dh = hue1 - hue0; + if (hue1 > hue0 && dh > 180) { + dh -= 360; + } + else if (hue1 < hue0 && hue0 - hue1 > 180) { + dh += 360; + } + hue = hue0 + t * dh; + } + else if (!isNaN(hue0)) { + hue = hue0; + if (light1 === 1 || light1 === 0) + chroma = chroma0; + } + else if (!isNaN(hue1)) { + hue = hue1; + if (light0 === 1 || light0 === 0) + chroma = chroma1; + } + else { + hue = NaN; + } + const [r, g, b, alpha] = hclToRgb([ + hue, + chroma !== null && chroma !== void 0 ? chroma : number(chroma0, chroma1, t), + number(light0, light1, t), + number(alphaF, alphaT, t), + ]); + return new Color(r, g, b, alpha, false); + } + case 'lab': { + const [r, g, b, alpha] = labToRgb(array(from.lab, to.lab, t)); + return new Color(r, g, b, alpha, false); + } + } +} +function array(from, to, t) { + return from.map((d, i) => { + return number(d, to[i], t); + }); +} +function padding(from, to, t) { + return new Padding(array(from.values, to.values, t)); +} +function variableAnchorOffsetCollection(from, to, t) { + const fromValues = from.values; + const toValues = to.values; + if (fromValues.length !== toValues.length) { + throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`); + } + const output = []; + for (let i = 0; i < fromValues.length; i += 2) { + // Anchor entries must match + if (fromValues[i] !== toValues[i]) { + throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`); + } + output.push(fromValues[i]); + // Interpolate the offset values for each anchor + const [fx, fy] = fromValues[i + 1]; + const [tx, ty] = toValues[i + 1]; + output.push([number(fx, tx, t), number(fy, ty, t)]); + } + return new VariableAnchorOffsetCollection(output); +} +const interpolate = { + number, + color, + array, + padding, + variableAnchorOffsetCollection +}; + +class Interpolate { + constructor(type, operator, interpolation, input, stops) { + this.type = type; + this.operator = operator; + this.interpolation = interpolation; + this.input = input; + this.labels = []; + this.outputs = []; + for (const [label, expression] of stops) { + this.labels.push(label); + this.outputs.push(expression); + } + } + static interpolationFactor(interpolation, input, lower, upper) { + let t = 0; + if (interpolation.name === 'exponential') { + t = exponentialInterpolation(input, interpolation.base, lower, upper); + } + else if (interpolation.name === 'linear') { + t = exponentialInterpolation(input, 1, lower, upper); + } + else if (interpolation.name === 'cubic-bezier') { + const c = interpolation.controlPoints; + const ub = new UnitBezier$1(c[0], c[1], c[2], c[3]); + t = ub.solve(exponentialInterpolation(input, 1, lower, upper)); + } + return t; + } + static parse(args, context) { + let [operator, interpolation, input, ...rest] = args; + if (!Array.isArray(interpolation) || interpolation.length === 0) { + return context.error('Expected an interpolation type expression.', 1); + } + if (interpolation[0] === 'linear') { + interpolation = { name: 'linear' }; + } + else if (interpolation[0] === 'exponential') { + const base = interpolation[1]; + if (typeof base !== 'number') + return context.error('Exponential interpolation requires a numeric base.', 1, 1); + interpolation = { + name: 'exponential', + base + }; + } + else if (interpolation[0] === 'cubic-bezier') { + const controlPoints = interpolation.slice(1); + if (controlPoints.length !== 4 || + controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)) { + return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1); + } + interpolation = { + name: 'cubic-bezier', + controlPoints: controlPoints + }; + } + else { + return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0); + } + if (args.length - 1 < 4) { + return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`); + } + if ((args.length - 1) % 2 !== 0) { + return context.error('Expected an even number of arguments.'); + } + input = context.parse(input, 2, NumberType); + if (!input) + return null; + const stops = []; + let outputType = null; + if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') { + outputType = ColorType; + } + else if (context.expectedType && context.expectedType.kind !== 'value') { + outputType = context.expectedType; + } + for (let i = 0; i < rest.length; i += 2) { + const label = rest[i]; + const value = rest[i + 1]; + const labelKey = i + 3; + const valueKey = i + 4; + if (typeof label !== 'number') { + return context.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey); + } + if (stops.length && stops[stops.length - 1][0] >= label) { + return context.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', labelKey); + } + const parsed = context.parse(value, valueKey, outputType); + if (!parsed) + return null; + outputType = outputType || parsed.type; + stops.push([label, parsed]); + } + if (!verifyType(outputType, NumberType) && + !verifyType(outputType, ColorType) && + !verifyType(outputType, PaddingType) && + !verifyType(outputType, VariableAnchorOffsetCollectionType) && + !verifyType(outputType, array$1(NumberType))) { + return context.error(`Type ${toString$1(outputType)} is not interpolatable.`); + } + return new Interpolate(outputType, operator, interpolation, input, stops); + } + evaluate(ctx) { + const labels = this.labels; + const outputs = this.outputs; + if (labels.length === 1) { + return outputs[0].evaluate(ctx); + } + const value = this.input.evaluate(ctx); + if (value <= labels[0]) { + return outputs[0].evaluate(ctx); + } + const stopCount = labels.length; + if (value >= labels[stopCount - 1]) { + return outputs[stopCount - 1].evaluate(ctx); + } + const index = findStopLessThanOrEqualTo(labels, value); + const lower = labels[index]; + const upper = labels[index + 1]; + const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper); + const outputLower = outputs[index].evaluate(ctx); + const outputUpper = outputs[index + 1].evaluate(ctx); + switch (this.operator) { + case 'interpolate': + return interpolate[this.type.kind](outputLower, outputUpper, t); + case 'interpolate-hcl': + return interpolate.color(outputLower, outputUpper, t, 'hcl'); + case 'interpolate-lab': + return interpolate.color(outputLower, outputUpper, t, 'lab'); + } + } + eachChild(fn) { + fn(this.input); + for (const expression of this.outputs) { + fn(expression); + } + } + outputDefined() { + return this.outputs.every(out => out.outputDefined()); + } +} +/** + * Returns a ratio that can be used to interpolate between exponential function + * stops. + * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base, + * and `a` and `b` are constants affording sufficient degrees of freedom to fit + * the function to the given stops. + * + * Here's a bit of algebra that lets us compute `f(x)` directly from the stop + * values without explicitly solving for `a` and `b`: + * + * First stop value: `f(x0) = y0 = a * base^x0 + b` + * Second stop value: `f(x1) = y1 = a * base^x1 + b` + * => `y1 - y0 = a(base^x1 - base^x0)` + * => `a = (y1 - y0)/(base^x1 - base^x0)` + * + * Desired value: `f(x) = y = a * base^x + b` + * => `f(x) = y0 + a * (base^x - base^x0)` + * + * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a + * little algebra: + * ``` + * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0) + * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0) + * ``` + * + * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have + * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as + * an interpolation factor between the two stops' output values. + * + * (Note: a slightly different form for `ratio`, + * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer + * expensive `Math.pow()` operations.) + * + * @private +*/ +function exponentialInterpolation(input, base, lowerValue, upperValue) { + const difference = upperValue - lowerValue; + const progress = input - lowerValue; + if (difference === 0) { + return 0; + } + else if (base === 1) { + return progress / difference; + } + else { + return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1); + } +} + +class Coalesce { + constructor(type, args) { + this.type = type; + this.args = args; + } + static parse(args, context) { + if (args.length < 2) { + return context.error('Expectected at least one argument.'); + } + let outputType = null; + const expectedType = context.expectedType; + if (expectedType && expectedType.kind !== 'value') { + outputType = expectedType; + } + const parsedArgs = []; + for (const arg of args.slice(1)) { + const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' }); + if (!parsed) + return null; + outputType = outputType || parsed.type; + parsedArgs.push(parsed); + } + if (!outputType) + throw new Error('No output type'); + // Above, we parse arguments without inferred type annotation so that + // they don't produce a runtime error for `null` input, which would + // preempt the desired null-coalescing behavior. + // Thus, if any of our arguments would have needed an annotation, we + // need to wrap the enclosing coalesce expression with it instead. + const needsAnnotation = expectedType && + parsedArgs.some(arg => checkSubtype(expectedType, arg.type)); + return needsAnnotation ? + new Coalesce(ValueType, parsedArgs) : + new Coalesce(outputType, parsedArgs); + } + evaluate(ctx) { + let result = null; + let argCount = 0; + let requestedImageName; + for (const arg of this.args) { + argCount++; + result = arg.evaluate(ctx); + // we need to keep track of the first requested image in a coalesce statement + // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire + if (result && result instanceof ResolvedImage && !result.available) { + if (!requestedImageName) { + requestedImageName = result.name; + } + result = null; + if (argCount === this.args.length) { + result = requestedImageName; + } + } + if (result !== null) + break; + } + return result; + } + eachChild(fn) { + this.args.forEach(fn); + } + outputDefined() { + return this.args.every(arg => arg.outputDefined()); + } +} + +class Let { + constructor(bindings, result) { + this.type = result.type; + this.bindings = [].concat(bindings); + this.result = result; + } + evaluate(ctx) { + return this.result.evaluate(ctx); + } + eachChild(fn) { + for (const binding of this.bindings) { + fn(binding[1]); + } + fn(this.result); + } + static parse(args, context) { + if (args.length < 4) + return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`); + const bindings = []; + for (let i = 1; i < args.length - 1; i += 2) { + const name = args[i]; + if (typeof name !== 'string') { + return context.error(`Expected string, but found ${typeof name} instead.`, i); + } + if (/[^a-zA-Z0-9_]/.test(name)) { + return context.error('Variable names must contain only alphanumeric characters or \'_\'.', i); + } + const value = context.parse(args[i + 1], i + 1); + if (!value) + return null; + bindings.push([name, value]); + } + const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings); + if (!result) + return null; + return new Let(bindings, result); + } + outputDefined() { + return this.result.outputDefined(); + } +} + +class At { + constructor(type, index, input) { + this.type = type; + this.index = index; + this.input = input; + } + static parse(args, context) { + if (args.length !== 3) + return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`); + const index = context.parse(args[1], 1, NumberType); + const input = context.parse(args[2], 2, array$1(context.expectedType || ValueType)); + if (!index || !input) + return null; + const t = input.type; + return new At(t.itemType, index, input); + } + evaluate(ctx) { + const index = this.index.evaluate(ctx); + const array = this.input.evaluate(ctx); + if (index < 0) { + throw new RuntimeError(`Array index out of bounds: ${index} < 0.`); + } + if (index >= array.length) { + throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`); + } + if (index !== Math.floor(index)) { + throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`); + } + return array[index]; + } + eachChild(fn) { + fn(this.index); + fn(this.input); + } + outputDefined() { + return false; + } +} + +class In { + constructor(needle, haystack) { + this.type = BooleanType; + this.needle = needle; + this.haystack = haystack; + } + static parse(args, context) { + if (args.length !== 3) { + return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`); + } + const needle = context.parse(args[1], 1, ValueType); + const haystack = context.parse(args[2], 2, ValueType); + if (!needle || !haystack) + return null; + if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) { + return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`); + } + return new In(needle, haystack); + } + evaluate(ctx) { + const needle = this.needle.evaluate(ctx); + const haystack = this.haystack.evaluate(ctx); + if (!haystack) + return false; + if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) { + throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`); + } + if (!isValidNativeType(haystack, ['string', 'array'])) { + throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`); + } + return haystack.indexOf(needle) >= 0; + } + eachChild(fn) { + fn(this.needle); + fn(this.haystack); + } + outputDefined() { + return true; + } +} + +class IndexOf { + constructor(needle, haystack, fromIndex) { + this.type = NumberType; + this.needle = needle; + this.haystack = haystack; + this.fromIndex = fromIndex; + } + static parse(args, context) { + if (args.length <= 2 || args.length >= 5) { + return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`); + } + const needle = context.parse(args[1], 1, ValueType); + const haystack = context.parse(args[2], 2, ValueType); + if (!needle || !haystack) + return null; + if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) { + return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`); + } + if (args.length === 4) { + const fromIndex = context.parse(args[3], 3, NumberType); + if (!fromIndex) + return null; + return new IndexOf(needle, haystack, fromIndex); + } + else { + return new IndexOf(needle, haystack); + } + } + evaluate(ctx) { + const needle = this.needle.evaluate(ctx); + const haystack = this.haystack.evaluate(ctx); + if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) { + throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`); + } + if (!isValidNativeType(haystack, ['string', 'array'])) { + throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`); + } + if (this.fromIndex) { + const fromIndex = this.fromIndex.evaluate(ctx); + return haystack.indexOf(needle, fromIndex); + } + return haystack.indexOf(needle); + } + eachChild(fn) { + fn(this.needle); + fn(this.haystack); + if (this.fromIndex) { + fn(this.fromIndex); + } + } + outputDefined() { + return false; + } +} + +class Match { + constructor(inputType, outputType, input, cases, outputs, otherwise) { + this.inputType = inputType; + this.type = outputType; + this.input = input; + this.cases = cases; + this.outputs = outputs; + this.otherwise = otherwise; + } + static parse(args, context) { + if (args.length < 5) + return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`); + if (args.length % 2 !== 1) + return context.error('Expected an even number of arguments.'); + let inputType; + let outputType; + if (context.expectedType && context.expectedType.kind !== 'value') { + outputType = context.expectedType; + } + const cases = {}; + const outputs = []; + for (let i = 2; i < args.length - 1; i += 2) { + let labels = args[i]; + const value = args[i + 1]; + if (!Array.isArray(labels)) { + labels = [labels]; + } + const labelContext = context.concat(i); + if (labels.length === 0) { + return labelContext.error('Expected at least one branch label.'); + } + for (const label of labels) { + if (typeof label !== 'number' && typeof label !== 'string') { + return labelContext.error('Branch labels must be numbers or strings.'); + } + else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) { + return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`); + } + else if (typeof label === 'number' && Math.floor(label) !== label) { + return labelContext.error('Numeric branch labels must be integer values.'); + } + else if (!inputType) { + inputType = typeOf(label); + } + else if (labelContext.checkSubtype(inputType, typeOf(label))) { + return null; + } + if (typeof cases[String(label)] !== 'undefined') { + return labelContext.error('Branch labels must be unique.'); + } + cases[String(label)] = outputs.length; + } + const result = context.parse(value, i, outputType); + if (!result) + return null; + outputType = outputType || result.type; + outputs.push(result); + } + const input = context.parse(args[1], 1, ValueType); + if (!input) + return null; + const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType); + if (!otherwise) + return null; + if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) { + return null; + } + return new Match(inputType, outputType, input, cases, outputs, otherwise); + } + evaluate(ctx) { + const input = this.input.evaluate(ctx); + const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise; + return output.evaluate(ctx); + } + eachChild(fn) { + fn(this.input); + this.outputs.forEach(fn); + fn(this.otherwise); + } + outputDefined() { + return this.outputs.every(out => out.outputDefined()) && this.otherwise.outputDefined(); + } +} + +class Case { + constructor(type, branches, otherwise) { + this.type = type; + this.branches = branches; + this.otherwise = otherwise; + } + static parse(args, context) { + if (args.length < 4) + return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`); + if (args.length % 2 !== 0) + return context.error('Expected an odd number of arguments.'); + let outputType; + if (context.expectedType && context.expectedType.kind !== 'value') { + outputType = context.expectedType; + } + const branches = []; + for (let i = 1; i < args.length - 1; i += 2) { + const test = context.parse(args[i], i, BooleanType); + if (!test) + return null; + const result = context.parse(args[i + 1], i + 1, outputType); + if (!result) + return null; + branches.push([test, result]); + outputType = outputType || result.type; + } + const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType); + if (!otherwise) + return null; + if (!outputType) + throw new Error('Can\'t infer output type'); + return new Case(outputType, branches, otherwise); + } + evaluate(ctx) { + for (const [test, expression] of this.branches) { + if (test.evaluate(ctx)) { + return expression.evaluate(ctx); + } + } + return this.otherwise.evaluate(ctx); + } + eachChild(fn) { + for (const [test, expression] of this.branches) { + fn(test); + fn(expression); + } + fn(this.otherwise); + } + outputDefined() { + return this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined(); + } +} + +class Slice { + constructor(type, input, beginIndex, endIndex) { + this.type = type; + this.input = input; + this.beginIndex = beginIndex; + this.endIndex = endIndex; + } + static parse(args, context) { + if (args.length <= 2 || args.length >= 5) { + return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`); + } + const input = context.parse(args[1], 1, ValueType); + const beginIndex = context.parse(args[2], 2, NumberType); + if (!input || !beginIndex) + return null; + if (!isValidType(input.type, [array$1(ValueType), StringType, ValueType])) { + return context.error(`Expected first argument to be of type array or string, but found ${toString$1(input.type)} instead`); + } + if (args.length === 4) { + const endIndex = context.parse(args[3], 3, NumberType); + if (!endIndex) + return null; + return new Slice(input.type, input, beginIndex, endIndex); + } + else { + return new Slice(input.type, input, beginIndex); + } + } + evaluate(ctx) { + const input = this.input.evaluate(ctx); + const beginIndex = this.beginIndex.evaluate(ctx); + if (!isValidNativeType(input, ['string', 'array'])) { + throw new RuntimeError(`Expected first argument to be of type array or string, but found ${toString$1(typeOf(input))} instead.`); + } + if (this.endIndex) { + const endIndex = this.endIndex.evaluate(ctx); + return input.slice(beginIndex, endIndex); + } + return input.slice(beginIndex); + } + eachChild(fn) { + fn(this.input); + fn(this.beginIndex); + if (this.endIndex) { + fn(this.endIndex); + } + } + outputDefined() { + return false; + } +} + +function isComparableType(op, type) { + if (op === '==' || op === '!=') { + // equality operator + return type.kind === 'boolean' || + type.kind === 'string' || + type.kind === 'number' || + type.kind === 'null' || + type.kind === 'value'; + } + else { + // ordering operator + return type.kind === 'string' || + type.kind === 'number' || + type.kind === 'value'; + } +} +function eq(ctx, a, b) { return a === b; } +function neq(ctx, a, b) { return a !== b; } +function lt(ctx, a, b) { return a < b; } +function gt(ctx, a, b) { return a > b; } +function lteq(ctx, a, b) { return a <= b; } +function gteq(ctx, a, b) { return a >= b; } +function eqCollate(ctx, a, b, c) { return c.compare(a, b) === 0; } +function neqCollate(ctx, a, b, c) { return !eqCollate(ctx, a, b, c); } +function ltCollate(ctx, a, b, c) { return c.compare(a, b) < 0; } +function gtCollate(ctx, a, b, c) { return c.compare(a, b) > 0; } +function lteqCollate(ctx, a, b, c) { return c.compare(a, b) <= 0; } +function gteqCollate(ctx, a, b, c) { return c.compare(a, b) >= 0; } +/** + * Special form for comparison operators, implementing the signatures: + * - (T, T, ?Collator) => boolean + * - (T, value, ?Collator) => boolean + * - (value, T, ?Collator) => boolean + * + * For inequalities, T must be either value, string, or number. For ==/!=, it + * can also be boolean or null. + * + * Equality semantics are equivalent to Javascript's strict equality (===/!==) + * -- i.e., when the arguments' types don't match, == evaluates to false, != to + * true. + * + * When types don't match in an ordering comparison, a runtime error is thrown. + * + * @private + */ +function makeComparison(op, compareBasic, compareWithCollator) { + const isOrderComparison = op !== '==' && op !== '!='; + return class Comparison { + constructor(lhs, rhs, collator) { + this.type = BooleanType; + this.lhs = lhs; + this.rhs = rhs; + this.collator = collator; + this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value'; + } + static parse(args, context) { + if (args.length !== 3 && args.length !== 4) + return context.error('Expected two or three arguments.'); + const op = args[0]; + let lhs = context.parse(args[1], 1, ValueType); + if (!lhs) + return null; + if (!isComparableType(op, lhs.type)) { + return context.concat(1).error(`"${op}" comparisons are not supported for type '${toString$1(lhs.type)}'.`); + } + let rhs = context.parse(args[2], 2, ValueType); + if (!rhs) + return null; + if (!isComparableType(op, rhs.type)) { + return context.concat(2).error(`"${op}" comparisons are not supported for type '${toString$1(rhs.type)}'.`); + } + if (lhs.type.kind !== rhs.type.kind && + lhs.type.kind !== 'value' && + rhs.type.kind !== 'value') { + return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`); + } + if (isOrderComparison) { + // typing rules specific to less/greater than operators + if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') { + // (value, T) + lhs = new Assertion(rhs.type, [lhs]); + } + else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') { + // (T, value) + rhs = new Assertion(lhs.type, [rhs]); + } + } + let collator = null; + if (args.length === 4) { + if (lhs.type.kind !== 'string' && + rhs.type.kind !== 'string' && + lhs.type.kind !== 'value' && + rhs.type.kind !== 'value') { + return context.error('Cannot use collator to compare non-string types.'); + } + collator = context.parse(args[3], 3, CollatorType); + if (!collator) + return null; + } + return new Comparison(lhs, rhs, collator); + } + evaluate(ctx) { + const lhs = this.lhs.evaluate(ctx); + const rhs = this.rhs.evaluate(ctx); + if (isOrderComparison && this.hasUntypedArgument) { + const lt = typeOf(lhs); + const rt = typeOf(rhs); + // check that type is string or number, and equal + if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) { + throw new RuntimeError(`Expected arguments for "${op}" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`); + } + } + if (this.collator && !isOrderComparison && this.hasUntypedArgument) { + const lt = typeOf(lhs); + const rt = typeOf(rhs); + if (lt.kind !== 'string' || rt.kind !== 'string') { + return compareBasic(ctx, lhs, rhs); + } + } + return this.collator ? + compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) : + compareBasic(ctx, lhs, rhs); + } + eachChild(fn) { + fn(this.lhs); + fn(this.rhs); + if (this.collator) { + fn(this.collator); + } + } + outputDefined() { + return true; + } + }; +} +const Equals = makeComparison('==', eq, eqCollate); +const NotEquals = makeComparison('!=', neq, neqCollate); +const LessThan = makeComparison('<', lt, ltCollate); +const GreaterThan = makeComparison('>', gt, gtCollate); +const LessThanOrEqual = makeComparison('<=', lteq, lteqCollate); +const GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate); + +class NumberFormat { + constructor(number, locale, currency, minFractionDigits, maxFractionDigits) { + this.type = StringType; + this.number = number; + this.locale = locale; + this.currency = currency; + this.minFractionDigits = minFractionDigits; + this.maxFractionDigits = maxFractionDigits; + } + static parse(args, context) { + if (args.length !== 3) + return context.error('Expected two arguments.'); + const number = context.parse(args[1], 1, NumberType); + if (!number) + return null; + const options = args[2]; + if (typeof options !== 'object' || Array.isArray(options)) + return context.error('NumberFormat options argument must be an object.'); + let locale = null; + if (options['locale']) { + locale = context.parse(options['locale'], 1, StringType); + if (!locale) + return null; + } + let currency = null; + if (options['currency']) { + currency = context.parse(options['currency'], 1, StringType); + if (!currency) + return null; + } + let minFractionDigits = null; + if (options['min-fraction-digits']) { + minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType); + if (!minFractionDigits) + return null; + } + let maxFractionDigits = null; + if (options['max-fraction-digits']) { + maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType); + if (!maxFractionDigits) + return null; + } + return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits); + } + evaluate(ctx) { + return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], { + style: this.currency ? 'currency' : 'decimal', + currency: this.currency ? this.currency.evaluate(ctx) : undefined, + minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined, + maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined, + }).format(this.number.evaluate(ctx)); + } + eachChild(fn) { + fn(this.number); + if (this.locale) { + fn(this.locale); + } + if (this.currency) { + fn(this.currency); + } + if (this.minFractionDigits) { + fn(this.minFractionDigits); + } + if (this.maxFractionDigits) { + fn(this.maxFractionDigits); + } + } + outputDefined() { + return false; + } +} + +class FormatExpression { + constructor(sections) { + this.type = FormattedType; + this.sections = sections; + } + static parse(args, context) { + if (args.length < 2) { + return context.error('Expected at least one argument.'); + } + const firstArg = args[1]; + if (!Array.isArray(firstArg) && typeof firstArg === 'object') { + return context.error('First argument must be an image or text section.'); + } + const sections = []; + let nextTokenMayBeObject = false; + for (let i = 1; i <= args.length - 1; ++i) { + const arg = args[i]; + if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) { + nextTokenMayBeObject = false; + let scale = null; + if (arg['font-scale']) { + scale = context.parse(arg['font-scale'], 1, NumberType); + if (!scale) + return null; + } + let font = null; + if (arg['text-font']) { + font = context.parse(arg['text-font'], 1, array$1(StringType)); + if (!font) + return null; + } + let textColor = null; + if (arg['text-color']) { + textColor = context.parse(arg['text-color'], 1, ColorType); + if (!textColor) + return null; + } + const lastExpression = sections[sections.length - 1]; + lastExpression.scale = scale; + lastExpression.font = font; + lastExpression.textColor = textColor; + } + else { + const content = context.parse(args[i], 1, ValueType); + if (!content) + return null; + const kind = content.type.kind; + if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage') + return context.error('Formatted text type must be \'string\', \'value\', \'image\' or \'null\'.'); + nextTokenMayBeObject = true; + sections.push({ content, scale: null, font: null, textColor: null }); + } + } + return new FormatExpression(sections); + } + evaluate(ctx) { + const evaluateSection = section => { + const evaluatedContent = section.content.evaluate(ctx); + if (typeOf(evaluatedContent) === ResolvedImageType) { + return new FormattedSection('', evaluatedContent, null, null, null); + } + return new FormattedSection(toString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null); + }; + return new Formatted(this.sections.map(evaluateSection)); + } + eachChild(fn) { + for (const section of this.sections) { + fn(section.content); + if (section.scale) { + fn(section.scale); + } + if (section.font) { + fn(section.font); + } + if (section.textColor) { + fn(section.textColor); + } + } + } + outputDefined() { + // Technically the combinatoric set of all children + // Usually, this.text will be undefined anyway + return false; + } +} + +class ImageExpression { + constructor(input) { + this.type = ResolvedImageType; + this.input = input; + } + static parse(args, context) { + if (args.length !== 2) { + return context.error('Expected two arguments.'); + } + const name = context.parse(args[1], 1, StringType); + if (!name) + return context.error('No image name provided.'); + return new ImageExpression(name); + } + evaluate(ctx) { + const evaluatedImageName = this.input.evaluate(ctx); + const value = ResolvedImage.fromString(evaluatedImageName); + if (value && ctx.availableImages) + value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1; + return value; + } + eachChild(fn) { + fn(this.input); + } + outputDefined() { + // The output of image is determined by the list of available images in the evaluation context + return false; + } +} + +class Length { + constructor(input) { + this.type = NumberType; + this.input = input; + } + static parse(args, context) { + if (args.length !== 2) + return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`); + const input = context.parse(args[1], 1); + if (!input) + return null; + if (input.type.kind !== 'array' && input.type.kind !== 'string' && input.type.kind !== 'value') + return context.error(`Expected argument of type string or array, but found ${toString$1(input.type)} instead.`); + return new Length(input); + } + evaluate(ctx) { + const input = this.input.evaluate(ctx); + if (typeof input === 'string') { + return input.length; + } + else if (Array.isArray(input)) { + return input.length; + } + else { + throw new RuntimeError(`Expected value to be of type string or array, but found ${toString$1(typeOf(input))} instead.`); + } + } + eachChild(fn) { + fn(this.input); + } + outputDefined() { + return false; + } +} + +const expressions = { + // special forms + '==': Equals, + '!=': NotEquals, + '>': GreaterThan, + '<': LessThan, + '>=': GreaterThanOrEqual, + '<=': LessThanOrEqual, + 'array': Assertion, + 'at': At, + 'boolean': Assertion, + 'case': Case, + 'coalesce': Coalesce, + 'collator': CollatorExpression, + 'format': FormatExpression, + 'image': ImageExpression, + 'in': In, + 'index-of': IndexOf, + 'interpolate': Interpolate, + 'interpolate-hcl': Interpolate, + 'interpolate-lab': Interpolate, + 'length': Length, + 'let': Let, + 'literal': Literal, + 'match': Match, + 'number': Assertion, + 'number-format': NumberFormat, + 'object': Assertion, + 'slice': Slice, + 'step': Step, + 'string': Assertion, + 'to-boolean': Coercion, + 'to-color': Coercion, + 'to-number': Coercion, + 'to-string': Coercion, + 'var': Var, + 'within': Within +}; +function rgba(ctx, [r, g, b, a]) { + r = r.evaluate(ctx); + g = g.evaluate(ctx); + b = b.evaluate(ctx); + const alpha = a ? a.evaluate(ctx) : 1; + const error = validateRGBA(r, g, b, alpha); + if (error) + throw new RuntimeError(error); + return new Color(r / 255, g / 255, b / 255, alpha, false); +} +function has(key, obj) { + return key in obj; +} +function get(key, obj) { + const v = obj[key]; + return typeof v === 'undefined' ? null : v; +} +function binarySearch(v, a, i, j) { + while (i <= j) { + const m = (i + j) >> 1; + if (a[m] === v) + return true; + if (a[m] > v) + j = m - 1; + else + i = m + 1; + } + return false; +} +function varargs(type) { + return { type }; +} +CompoundExpression.register(expressions, { + 'error': [ + ErrorType, + [StringType], + (ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); } + ], + 'typeof': [ + StringType, + [ValueType], + (ctx, [v]) => toString$1(typeOf(v.evaluate(ctx))) + ], + 'to-rgba': [ + array$1(NumberType, 4), + [ColorType], + (ctx, [v]) => { + const [r, g, b, a] = v.evaluate(ctx).rgb; + return [r * 255, g * 255, b * 255, a]; + }, + ], + 'rgb': [ + ColorType, + [NumberType, NumberType, NumberType], + rgba + ], + 'rgba': [ + ColorType, + [NumberType, NumberType, NumberType, NumberType], + rgba + ], + 'has': { + type: BooleanType, + overloads: [ + [ + [StringType], + (ctx, [key]) => has(key.evaluate(ctx), ctx.properties()) + ], [ + [StringType, ObjectType], + (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx)) + ] + ] + }, + 'get': { + type: ValueType, + overloads: [ + [ + [StringType], + (ctx, [key]) => get(key.evaluate(ctx), ctx.properties()) + ], [ + [StringType, ObjectType], + (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx)) + ] + ] + }, + 'feature-state': [ + ValueType, + [StringType], + (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {}) + ], + 'properties': [ + ObjectType, + [], + (ctx) => ctx.properties() + ], + 'geometry-type': [ + StringType, + [], + (ctx) => ctx.geometryType() + ], + 'id': [ + ValueType, + [], + (ctx) => ctx.id() + ], + 'zoom': [ + NumberType, + [], + (ctx) => ctx.globals.zoom + ], + 'heatmap-density': [ + NumberType, + [], + (ctx) => ctx.globals.heatmapDensity || 0 + ], + 'line-progress': [ + NumberType, + [], + (ctx) => ctx.globals.lineProgress || 0 + ], + 'accumulated': [ + ValueType, + [], + (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated + ], + '+': [ + NumberType, + varargs(NumberType), + (ctx, args) => { + let result = 0; + for (const arg of args) { + result += arg.evaluate(ctx); + } + return result; + } + ], + '*': [ + NumberType, + varargs(NumberType), + (ctx, args) => { + let result = 1; + for (const arg of args) { + result *= arg.evaluate(ctx); + } + return result; + } + ], + '-': { + type: NumberType, + overloads: [ + [ + [NumberType, NumberType], + (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx) + ], [ + [NumberType], + (ctx, [a]) => -a.evaluate(ctx) + ] + ] + }, + '/': [ + NumberType, + [NumberType, NumberType], + (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx) + ], + '%': [ + NumberType, + [NumberType, NumberType], + (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx) + ], + 'ln2': [ + NumberType, + [], + () => Math.LN2 + ], + 'pi': [ + NumberType, + [], + () => Math.PI + ], + 'e': [ + NumberType, + [], + () => Math.E + ], + '^': [ + NumberType, + [NumberType, NumberType], + (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx)) + ], + 'sqrt': [ + NumberType, + [NumberType], + (ctx, [x]) => Math.sqrt(x.evaluate(ctx)) + ], + 'log10': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10 + ], + 'ln': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.log(n.evaluate(ctx)) + ], + 'log2': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2 + ], + 'sin': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.sin(n.evaluate(ctx)) + ], + 'cos': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.cos(n.evaluate(ctx)) + ], + 'tan': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.tan(n.evaluate(ctx)) + ], + 'asin': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.asin(n.evaluate(ctx)) + ], + 'acos': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.acos(n.evaluate(ctx)) + ], + 'atan': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.atan(n.evaluate(ctx)) + ], + 'min': [ + NumberType, + varargs(NumberType), + (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx))) + ], + 'max': [ + NumberType, + varargs(NumberType), + (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx))) + ], + 'abs': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.abs(n.evaluate(ctx)) + ], + 'round': [ + NumberType, + [NumberType], + (ctx, [n]) => { + const v = n.evaluate(ctx); + // Javascript's Math.round() rounds towards +Infinity for halfway + // values, even when they're negative. It's more common to round + // away from 0 (e.g., this is what python and C++ do) + return v < 0 ? -Math.round(-v) : Math.round(v); + } + ], + 'floor': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.floor(n.evaluate(ctx)) + ], + 'ceil': [ + NumberType, + [NumberType], + (ctx, [n]) => Math.ceil(n.evaluate(ctx)) + ], + 'filter-==': [ + BooleanType, + [StringType, ValueType], + (ctx, [k, v]) => ctx.properties()[k.value] === v.value + ], + 'filter-id-==': [ + BooleanType, + [ValueType], + (ctx, [v]) => ctx.id() === v.value + ], + 'filter-type-==': [ + BooleanType, + [StringType], + (ctx, [v]) => ctx.geometryType() === v.value + ], + 'filter-<': [ + BooleanType, + [StringType, ValueType], + (ctx, [k, v]) => { + const a = ctx.properties()[k.value]; + const b = v.value; + return typeof a === typeof b && a < b; + } + ], + 'filter-id-<': [ + BooleanType, + [ValueType], + (ctx, [v]) => { + const a = ctx.id(); + const b = v.value; + return typeof a === typeof b && a < b; + } + ], + 'filter->': [ + BooleanType, + [StringType, ValueType], + (ctx, [k, v]) => { + const a = ctx.properties()[k.value]; + const b = v.value; + return typeof a === typeof b && a > b; + } + ], + 'filter-id->': [ + BooleanType, + [ValueType], + (ctx, [v]) => { + const a = ctx.id(); + const b = v.value; + return typeof a === typeof b && a > b; + } + ], + 'filter-<=': [ + BooleanType, + [StringType, ValueType], + (ctx, [k, v]) => { + const a = ctx.properties()[k.value]; + const b = v.value; + return typeof a === typeof b && a <= b; + } + ], + 'filter-id-<=': [ + BooleanType, + [ValueType], + (ctx, [v]) => { + const a = ctx.id(); + const b = v.value; + return typeof a === typeof b && a <= b; + } + ], + 'filter->=': [ + BooleanType, + [StringType, ValueType], + (ctx, [k, v]) => { + const a = ctx.properties()[k.value]; + const b = v.value; + return typeof a === typeof b && a >= b; + } + ], + 'filter-id->=': [ + BooleanType, + [ValueType], + (ctx, [v]) => { + const a = ctx.id(); + const b = v.value; + return typeof a === typeof b && a >= b; + } + ], + 'filter-has': [ + BooleanType, + [ValueType], + (ctx, [k]) => k.value in ctx.properties() + ], + 'filter-has-id': [ + BooleanType, + [], + (ctx) => (ctx.id() !== null && ctx.id() !== undefined) + ], + 'filter-type-in': [ + BooleanType, + [array$1(StringType)], + (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0 + ], + 'filter-id-in': [ + BooleanType, + [array$1(ValueType)], + (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0 + ], + 'filter-in-small': [ + BooleanType, + [StringType, array$1(ValueType)], + // assumes v is an array literal + (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0 + ], + 'filter-in-large': [ + BooleanType, + [StringType, array$1(ValueType)], + // assumes v is a array literal with values sorted in ascending order and of a single type + (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1) + ], + 'all': { + type: BooleanType, + overloads: [ + [ + [BooleanType, BooleanType], + (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx) + ], + [ + varargs(BooleanType), + (ctx, args) => { + for (const arg of args) { + if (!arg.evaluate(ctx)) + return false; + } + return true; + } + ] + ] + }, + 'any': { + type: BooleanType, + overloads: [ + [ + [BooleanType, BooleanType], + (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx) + ], + [ + varargs(BooleanType), + (ctx, args) => { + for (const arg of args) { + if (arg.evaluate(ctx)) + return true; + } + return false; + } + ] + ] + }, + '!': [ + BooleanType, + [BooleanType], + (ctx, [b]) => !b.evaluate(ctx) + ], + 'is-supported-script': [ + BooleanType, + [StringType], + // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant + (ctx, [s]) => { + const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript; + if (isSupportedScript) { + return isSupportedScript(s.evaluate(ctx)); + } + return true; + } + ], + 'upcase': [ + StringType, + [StringType], + (ctx, [s]) => s.evaluate(ctx).toUpperCase() + ], + 'downcase': [ + StringType, + [StringType], + (ctx, [s]) => s.evaluate(ctx).toLowerCase() + ], + 'concat': [ + StringType, + varargs(ValueType), + (ctx, args) => args.map(arg => toString(arg.evaluate(ctx))).join('') + ], + 'resolved-locale': [ + StringType, + [CollatorType], + (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale() + ] +}); + +function success(value) { + return { result: 'success', value }; +} +function error(value) { + return { result: 'error', value }; +} + +function supportsPropertyExpression(spec) { + return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven'; +} +function supportsZoomExpression(spec) { + return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1; +} +function supportsInterpolation(spec) { + return !!spec.expression && spec.expression.interpolated; +} + +function getType(val) { + if (val instanceof Number) { + return 'number'; + } + else if (val instanceof String) { + return 'string'; + } + else if (val instanceof Boolean) { + return 'boolean'; + } + else if (Array.isArray(val)) { + return 'array'; + } + else if (val === null) { + return 'null'; + } + else { + return typeof val; + } +} + +function isFunction(value) { + return typeof value === 'object' && value !== null && !Array.isArray(value); +} +function identityFunction(x) { + return x; +} +function createFunction(parameters, propertySpec) { + const isColor = propertySpec.type === 'color'; + const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object'; + const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined; + const zoomDependent = zoomAndFeatureDependent || !featureDependent; + const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval'); + if (isColor || propertySpec.type === 'padding') { + const parseFn = isColor ? Color.parse : Padding.parse; + parameters = extendBy({}, parameters); + if (parameters.stops) { + parameters.stops = parameters.stops.map((stop) => { + return [stop[0], parseFn(stop[1])]; + }); + } + if (parameters.default) { + parameters.default = parseFn(parameters.default); + } + else { + parameters.default = parseFn(propertySpec.default); + } + } + if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) { + throw new Error(`Unknown color space: "${parameters.colorSpace}"`); + } + let innerFun; + let hashedStops; + let categoricalKeyType; + if (type === 'exponential') { + innerFun = evaluateExponentialFunction; + } + else if (type === 'interval') { + innerFun = evaluateIntervalFunction; + } + else if (type === 'categorical') { + innerFun = evaluateCategoricalFunction; + // For categorical functions, generate an Object as a hashmap of the stops for fast searching + hashedStops = Object.create(null); + for (const stop of parameters.stops) { + hashedStops[stop[0]] = stop[1]; + } + // Infer key type based on first stop key-- used to encforce strict type checking later + categoricalKeyType = typeof parameters.stops[0][0]; + } + else if (type === 'identity') { + innerFun = evaluateIdentityFunction; + } + else { + throw new Error(`Unknown function type "${type}"`); + } + if (zoomAndFeatureDependent) { + const featureFunctions = {}; + const zoomStops = []; + for (let s = 0; s < parameters.stops.length; s++) { + const stop = parameters.stops[s]; + const zoom = stop[0].zoom; + if (featureFunctions[zoom] === undefined) { + featureFunctions[zoom] = { + zoom, + type: parameters.type, + property: parameters.property, + default: parameters.default, + stops: [] + }; + zoomStops.push(zoom); + } + featureFunctions[zoom].stops.push([stop[0].value, stop[1]]); + } + const featureFunctionStops = []; + for (const z of zoomStops) { + featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]); + } + const interpolationType = { name: 'linear' }; + return { + kind: 'composite', + interpolationType, + interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType), + zoomStops: featureFunctionStops.map(s => s[0]), + evaluate({ zoom }, properties) { + return evaluateExponentialFunction({ + stops: featureFunctionStops, + base: parameters.base + }, propertySpec, zoom).evaluate(zoom, properties); + } + }; + } + else if (zoomDependent) { + const interpolationType = type === 'exponential' ? + { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 } : null; + return { + kind: 'camera', + interpolationType, + interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType), + zoomStops: parameters.stops.map(s => s[0]), + evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType) + }; + } + else { + return { + kind: 'source', + evaluate(_, feature) { + const value = feature && feature.properties ? feature.properties[parameters.property] : undefined; + if (value === undefined) { + return coalesce$1(parameters.default, propertySpec.default); + } + return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType); + } + }; + } +} +function coalesce$1(a, b, c) { + if (a !== undefined) + return a; + if (b !== undefined) + return b; + if (c !== undefined) + return c; +} +function evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) { + const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input + return coalesce$1(evaluated, parameters.default, propertySpec.default); +} +function evaluateIntervalFunction(parameters, propertySpec, input) { + // Edge cases + if (getType(input) !== 'number') + return coalesce$1(parameters.default, propertySpec.default); + const n = parameters.stops.length; + if (n === 1) + return parameters.stops[0][1]; + if (input <= parameters.stops[0][0]) + return parameters.stops[0][1]; + if (input >= parameters.stops[n - 1][0]) + return parameters.stops[n - 1][1]; + const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input); + return parameters.stops[index][1]; +} +function evaluateExponentialFunction(parameters, propertySpec, input) { + const base = parameters.base !== undefined ? parameters.base : 1; + // Edge cases + if (getType(input) !== 'number') + return coalesce$1(parameters.default, propertySpec.default); + const n = parameters.stops.length; + if (n === 1) + return parameters.stops[0][1]; + if (input <= parameters.stops[0][0]) + return parameters.stops[0][1]; + if (input >= parameters.stops[n - 1][0]) + return parameters.stops[n - 1][1]; + const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input); + const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]); + const outputLower = parameters.stops[index][1]; + const outputUpper = parameters.stops[index + 1][1]; + const interp = interpolate[propertySpec.type] || identityFunction; + if (typeof outputLower.evaluate === 'function') { + return { + evaluate(...args) { + const evaluatedLower = outputLower.evaluate.apply(undefined, args); + const evaluatedUpper = outputUpper.evaluate.apply(undefined, args); + // Special case for fill-outline-color, which has no spec default. + if (evaluatedLower === undefined || evaluatedUpper === undefined) { + return undefined; + } + return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace); + } + }; + } + return interp(outputLower, outputUpper, t, parameters.colorSpace); +} +function evaluateIdentityFunction(parameters, propertySpec, input) { + switch (propertySpec.type) { + case 'color': + input = Color.parse(input); + break; + case 'formatted': + input = Formatted.fromString(input.toString()); + break; + case 'resolvedImage': + input = ResolvedImage.fromString(input.toString()); + break; + case 'padding': + input = Padding.parse(input); + break; + default: + if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) { + input = undefined; + } + } + return coalesce$1(input, parameters.default, propertySpec.default); +} +/** + * Returns a ratio that can be used to interpolate between exponential function + * stops. + * + * How it works: + * Two consecutive stop values define a (scaled and shifted) exponential + * function `f(x) = a * base^x + b`, where `base` is the user-specified base, + * and `a` and `b` are constants affording sufficient degrees of freedom to fit + * the function to the given stops. + * + * Here's a bit of algebra that lets us compute `f(x)` directly from the stop + * values without explicitly solving for `a` and `b`: + * + * First stop value: `f(x0) = y0 = a * base^x0 + b` + * Second stop value: `f(x1) = y1 = a * base^x1 + b` + * => `y1 - y0 = a(base^x1 - base^x0)` + * => `a = (y1 - y0)/(base^x1 - base^x0)` + * + * Desired value: `f(x) = y = a * base^x + b` + * => `f(x) = y0 + a * (base^x - base^x0)` + * + * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a + * little algebra: + * ``` + * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0) + * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0) + * ``` + * + * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have + * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as + * an interpolation factor between the two stops' output values. + * + * (Note: a slightly different form for `ratio`, + * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer + * expensive `Math.pow()` operations.) + * + * @private + */ +function interpolationFactor(input, base, lowerValue, upperValue) { + const difference = upperValue - lowerValue; + const progress = input - lowerValue; + if (difference === 0) { + return 0; + } + else if (base === 1) { + return progress / difference; + } + else { + return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1); + } +} + +class StyleExpression { + constructor(expression, propertySpec) { + this.expression = expression; + this._warningHistory = {}; + this._evaluator = new EvaluationContext(); + this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null; + this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null; + } + evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) { + this._evaluator.globals = globals; + this._evaluator.feature = feature; + this._evaluator.featureState = featureState; + this._evaluator.canonical = canonical; + this._evaluator.availableImages = availableImages || null; + this._evaluator.formattedSection = formattedSection; + return this.expression.evaluate(this._evaluator); + } + evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) { + this._evaluator.globals = globals; + this._evaluator.feature = feature || null; + this._evaluator.featureState = featureState || null; + this._evaluator.canonical = canonical; + this._evaluator.availableImages = availableImages || null; + this._evaluator.formattedSection = formattedSection || null; + try { + const val = this.expression.evaluate(this._evaluator); + // eslint-disable-next-line no-self-compare + if (val === null || val === undefined || (typeof val === 'number' && val !== val)) { + return this._defaultValue; + } + if (this._enumValues && !(val in this._enumValues)) { + throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`); + } + return val; + } + catch (e) { + if (!this._warningHistory[e.message]) { + this._warningHistory[e.message] = true; + if (typeof console !== 'undefined') { + console.warn(e.message); + } + } + return this._defaultValue; + } + } +} +function isExpression(expression) { + return Array.isArray(expression) && expression.length > 0 && + typeof expression[0] === 'string' && expression[0] in expressions; +} +/** + * Parse and typecheck the given style spec JSON expression. If + * options.defaultValue is provided, then the resulting StyleExpression's + * `evaluate()` method will handle errors by logging a warning (once per + * message) and returning the default value. Otherwise, it will throw + * evaluation errors. + * + * @private + */ +function createExpression(expression, propertySpec) { + const parser = new ParsingContext(expressions, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined); + // For string-valued properties, coerce to string at the top level rather than asserting. + const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined); + if (!parsed) { + return error(parser.errors); + } + return success(new StyleExpression(parsed, propertySpec)); +} +class ZoomConstantExpression { + constructor(kind, expression) { + this.kind = kind; + this._styleExpression = expression; + this.isStateDependent = kind !== 'constant' && !isStateConstant(expression.expression); + } + evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) { + return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection); + } + evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) { + return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection); + } +} +class ZoomDependentExpression { + constructor(kind, expression, zoomStops, interpolationType) { + this.kind = kind; + this.zoomStops = zoomStops; + this._styleExpression = expression; + this.isStateDependent = kind !== 'camera' && !isStateConstant(expression.expression); + this.interpolationType = interpolationType; + } + evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) { + return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection); + } + evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) { + return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection); + } + interpolationFactor(input, lower, upper) { + if (this.interpolationType) { + return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper); + } + else { + return 0; + } + } +} +function isZoomExpression(expression) { + return expression._styleExpression !== undefined; +} +function createPropertyExpression(expressionInput, propertySpec) { + const expression = createExpression(expressionInput, propertySpec); + if (expression.result === 'error') { + return expression; + } + const parsed = expression.value.expression; + const isFeatureConstantResult = isFeatureConstant(parsed); + if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) { + return error([new ExpressionParsingError('', 'data expressions not supported')]); + } + const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']); + if (!isZoomConstant && !supportsZoomExpression(propertySpec)) { + return error([new ExpressionParsingError('', 'zoom expressions not supported')]); + } + const zoomCurve = findZoomCurve(parsed); + if (!zoomCurve && !isZoomConstant) { + return error([new ExpressionParsingError('', '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]); + } + else if (zoomCurve instanceof ExpressionParsingError) { + return error([zoomCurve]); + } + else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) { + return error([new ExpressionParsingError('', '"interpolate" expressions cannot be used with this property')]); + } + if (!zoomCurve) { + return success(isFeatureConstantResult ? + new ZoomConstantExpression('constant', expression.value) : + new ZoomConstantExpression('source', expression.value)); + } + const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined; + return success(isFeatureConstantResult ? + new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType) : + new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType)); +} +// serialization wrapper for old-style stop functions normalized to the +// expression interface +class StylePropertyFunction { + constructor(parameters, specification) { + this._parameters = parameters; + this._specification = specification; + extendBy(this, createFunction(this._parameters, this._specification)); + } + static deserialize(serialized) { + return new StylePropertyFunction(serialized._parameters, serialized._specification); + } + static serialize(input) { + return { + _parameters: input._parameters, + _specification: input._specification + }; + } +} +function normalizePropertyExpression(value, specification) { + if (isFunction(value)) { + return new StylePropertyFunction(value, specification); + } + else if (isExpression(value)) { + const expression = createPropertyExpression(value, specification); + if (expression.result === 'error') { + // this should have been caught in validation + throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', ')); + } + return expression.value; + } + else { + let constant = value; + if (specification.type === 'color' && typeof value === 'string') { + constant = Color.parse(value); + } + else if (specification.type === 'padding' && (typeof value === 'number' || Array.isArray(value))) { + constant = Padding.parse(value); + } + else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) { + constant = VariableAnchorOffsetCollection.parse(value); + } + return { + kind: 'constant', + evaluate: () => constant + }; + } +} +// Zoom-dependent expressions may only use ["zoom"] as the input to a top-level "step" or "interpolate" +// expression (collectively referred to as a "curve"). The curve may be wrapped in one or more "let" or +// "coalesce" expressions. +function findZoomCurve(expression) { + let result = null; + if (expression instanceof Let) { + result = findZoomCurve(expression.result); + } + else if (expression instanceof Coalesce) { + for (const arg of expression.args) { + result = findZoomCurve(arg); + if (result) { + break; + } + } + } + else if ((expression instanceof Step || expression instanceof Interpolate) && + expression.input instanceof CompoundExpression && + expression.input.name === 'zoom') { + result = expression; + } + if (result instanceof ExpressionParsingError) { + return result; + } + expression.eachChild((child) => { + const childResult = findZoomCurve(child); + if (childResult instanceof ExpressionParsingError) { + result = childResult; + } + else if (!result && childResult) { + result = new ExpressionParsingError('', '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'); + } + else if (result && childResult && result !== childResult) { + result = new ExpressionParsingError('', 'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'); + } + }); + return result; +} +function getExpectedType(spec) { + const types = { + color: ColorType, + string: StringType, + number: NumberType, + enum: StringType, + boolean: BooleanType, + formatted: FormattedType, + padding: PaddingType, + resolvedImage: ResolvedImageType, + variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType + }; + if (spec.type === 'array') { + return array$1(types[spec.value] || ValueType, spec.length); + } + return types[spec.type]; +} +function getDefaultValue(spec) { + if (spec.type === 'color' && isFunction(spec.default)) { + // Special case for heatmap-color: it uses the 'default:' to define a + // default color ramp, but createExpression expects a simple value to fall + // back to in case of runtime errors + return new Color(0, 0, 0, 0); + } + else if (spec.type === 'color') { + return Color.parse(spec.default) || null; + } + else if (spec.type === 'padding') { + return Padding.parse(spec.default) || null; + } + else if (spec.type === 'variableAnchorOffsetCollection') { + return VariableAnchorOffsetCollection.parse(spec.default) || null; + } + else if (spec.default === undefined) { + return null; + } + else { + return spec.default; + } +} + +function isExpressionFilter(filter) { + if (filter === true || filter === false) { + return true; + } + if (!Array.isArray(filter) || filter.length === 0) { + return false; + } + switch (filter[0]) { + case 'has': + return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type'; + case 'in': + return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2])); + case '!in': + case '!has': + case 'none': + return false; + case '==': + case '!=': + case '>': + case '>=': + case '<': + case '<=': + return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2])); + case 'any': + case 'all': + for (const f of filter.slice(1)) { + if (!isExpressionFilter(f) && typeof f !== 'boolean') { + return false; + } + } + return true; + default: + return true; + } +} +const filterSpec = { + 'type': 'boolean', + 'default': false, + 'transition': false, + 'property-type': 'data-driven', + 'expression': { + 'interpolated': false, + 'parameters': ['zoom', 'feature'] + } +}; +/** + * Given a filter expressed as nested arrays, return a new function + * that evaluates whether a given feature (with a .properties or .tags property) + * passes its test. + * + * @private + * @param {Array} filter MapLibre filter + * @returns {Function} filter-evaluating function + */ +function createFilter(filter) { + if (filter === null || filter === undefined) { + return { filter: () => true, needGeometry: false }; + } + if (!isExpressionFilter(filter)) { + filter = convertFilter$1(filter); + } + const compiled = createExpression(filter, filterSpec); + if (compiled.result === 'error') { + throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', ')); + } + else { + const needGeometry = geometryNeeded(filter); + return { filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical), + needGeometry }; + } +} +// Comparison function to sort numbers and strings +function compare(a, b) { + return a < b ? -1 : a > b ? 1 : 0; +} +function geometryNeeded(filter) { + if (!Array.isArray(filter)) + return false; + if (filter[0] === 'within') + return true; + for (let index = 1; index < filter.length; index++) { + if (geometryNeeded(filter[index])) + return true; + } + return false; +} +function convertFilter$1(filter) { + if (!filter) + return true; + const op = filter[0]; + if (filter.length <= 1) + return (op !== 'any'); + const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') : + op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) : + op === '<' || + op === '>' || + op === '<=' || + op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) : + op === 'any' ? convertDisjunctionOp(filter.slice(1)) : + op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) : + op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) : + op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) : + op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) : + op === 'has' ? convertHasOp$1(filter[1]) : + op === '!has' ? convertNegation(convertHasOp$1(filter[1])) : + op === 'within' ? filter : + true; + return converted; +} +function convertComparisonOp$1(property, value, op) { + switch (property) { + case '$type': + return [`filter-type-${op}`, value]; + case '$id': + return [`filter-id-${op}`, value]; + default: + return [`filter-${op}`, property, value]; + } +} +function convertDisjunctionOp(filters) { + return ['any'].concat(filters.map(convertFilter$1)); +} +function convertInOp$1(property, values) { + if (values.length === 0) { + return false; + } + switch (property) { + case '$type': + return ['filter-type-in', ['literal', values]]; + case '$id': + return ['filter-id-in', ['literal', values]]; + default: + if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) { + return ['filter-in-large', property, ['literal', values.sort(compare)]]; + } + else { + return ['filter-in-small', property, ['literal', values]]; + } + } +} +function convertHasOp$1(property) { + switch (property) { + case '$type': + return true; + case '$id': + return ['filter-has-id']; + default: + return ['filter-has', property]; + } +} +function convertNegation(filter) { + return ['!', filter]; +} + +/* + * Convert the given filter to an expression, storing the expected types for + * any feature properties referenced in expectedTypes. + * + * These expected types are needed in order to construct preflight type checks + * needed for handling 'any' filters. A preflight type check is necessary in + * order to mimic legacy filters' semantics around expected type mismatches. + * For example, consider the legacy filter: + * + * ["any", ["all", [">", "y", 0], [">", "y", 0]], [">", "x", 0]] + * + * Naively, we might convert this to the expression: + * + * ["any", ["all", [">", ["get", "y"], 0], [">", ["get", "z"], 0]], [">", ["get", "x"], 0]] + * + * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the + * [">", ["get", "y"], 0] would cause an evaluation error, leading to the + * entire filter returning false. Legacy filter semantics, though, ask for + * [">", "y", 0] to simply return `false` when `y` is of the wrong type, + * allowing the subsequent terms of the outer "any" expression to be evaluated + * (resulting, in this case, in a `true` value, because x > 0). + * + * We account for this by inserting a preflight type-checking expression before + * each "any" term, allowing us to avoid evaluating the actual converted filter + * if any type mismatches would cause it to produce an evalaution error: + * + * ["any", + * ["case", + * ["all", ["==", ["typeof", ["get", "y"]], "number"], ["==", ["typeof", ["get", "z"], "number]], + * ["all", [">", ["get", "y"], 0], [">", ["get", "z"], 0]], + * false + * ], + * ["case", + * ["==", ["typeof", ["get", "x"], "number"]], + * [">", ["get", "x"], 0], + * false + * ] + * ] + * + * An alternative, possibly more direct approach would be to use type checks + * in the conversion of each comparison operator, so that the converted version + * of each individual ==, >=, etc. would mimic the legacy filter semantics. The + * downside of this approach is that it can lead to many more type checks than + * would otherwise be necessary: outside the context of an "any" expression, + * bailing out due to a runtime type error (expression semantics) and returning + * false (legacy filter semantics) are equivalent: they cause the filter to + * produce a `false` result. + */ +function convertFilter(filter, expectedTypes = {}) { + if (isExpressionFilter(filter)) + return filter; + if (!filter) + return true; + const legacyFilter = filter; + const legacyOp = legacyFilter[0]; + if (filter.length <= 1) + return (legacyOp !== 'any'); + switch (legacyOp) { + case '==': + case '!=': + case '<': + case '>': + case '<=': + case '>=': { + const [, property, value] = filter; + return convertComparisonOp(property, value, legacyOp, expectedTypes); + } + case 'any': { + const [, ...conditions] = legacyFilter; + const children = conditions.map((f) => { + const types = {}; + const child = convertFilter(f, types); + const typechecks = runtimeTypeChecks(types); + return typechecks === true ? child : ['case', typechecks, child, false]; + }); + return ['any', ...children]; + } + case 'all': { + const [, ...conditions] = legacyFilter; + const children = conditions.map(f => convertFilter(f, expectedTypes)); + return children.length > 1 ? ['all', ...children] : children[0]; + } + case 'none': { + const [, ...conditions] = legacyFilter; + return ['!', convertFilter(['any', ...conditions], {})]; + } + case 'in': { + const [, property, ...values] = legacyFilter; + return convertInOp(property, values); + } + case '!in': { + const [, property, ...values] = legacyFilter; + return convertInOp(property, values, true); + } + case 'has': + return convertHasOp(legacyFilter[1]); + case '!has': + return ['!', convertHasOp(legacyFilter[1])]; + default: + return true; + } +} +// Given a set of feature properties and an expected type for each one, +// construct an boolean expression that tests whether each property has the +// right type. +// E.g.: for {name: 'string', population: 'number'}, return +// [ 'all', +// ['==', ['typeof', ['get', 'name'], 'string']], +// ['==', ['typeof', ['get', 'population'], 'number]] +// ] +function runtimeTypeChecks(expectedTypes) { + const conditions = []; + for (const property in expectedTypes) { + const get = property === '$id' ? ['id'] : ['get', property]; + conditions.push(['==', ['typeof', get], expectedTypes[property]]); + } + if (conditions.length === 0) + return true; + if (conditions.length === 1) + return conditions[0]; + return ['all', ...conditions]; +} +function convertComparisonOp(property, value, op, expectedTypes) { + let get; + if (property === '$type') { + return [op, ['geometry-type'], value]; + } + else if (property === '$id') { + get = ['id']; + } + else { + get = ['get', property]; + } + if (expectedTypes && value !== null) { + const type = typeof value; + expectedTypes[property] = type; + } + if (op === '==' && property !== '$id' && value === null) { + return [ + 'all', + ['has', property], + ['==', get, null] + ]; + } + else if (op === '!=' && property !== '$id' && value === null) { + return [ + 'any', + ['!', ['has', property]], + ['!=', get, null] + ]; + } + return [op, get, value]; +} +function convertInOp(property, values, negate = false) { + if (values.length === 0) + return negate; + let get; + if (property === '$type') { + get = ['geometry-type']; + } + else if (property === '$id') { + get = ['id']; + } + else { + get = ['get', property]; + } + // Determine if the list of values to be searched is homogenously typed. + // If so (and if the type is string or number), then we can use a + // [match, input, [...values], true, false] construction rather than a + // bunch of `==` tests. + let uniformTypes = true; + const type = typeof values[0]; + for (const value of values) { + if (typeof value !== type) { + uniformTypes = false; + break; + } + } + if (uniformTypes && (type === 'string' || type === 'number')) { + // Match expressions must have unique values. + const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v); + return ['match', get, uniqueValues, !negate, negate]; + } + if (negate) { + return ['all', ...values.map(v => ['!=', get, v])]; + } + else { + return ['any', ...values.map(v => ['==', get, v])]; + } +} +function convertHasOp(property) { + if (property === '$type') { + return true; + } + else if (property === '$id') { + return ['!=', ['id'], null]; + } + else { + return ['has', property]; + } +} + +function convertLiteral(value) { + return typeof value === 'object' ? ['literal', value] : value; +} +function convertFunction(parameters, propertySpec) { + let stops = parameters.stops; + if (!stops) { + // identity function + return convertIdentityFunction(parameters, propertySpec); + } + const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object'; + const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined; + const zoomDependent = zoomAndFeatureDependent || !featureDependent; + stops = stops.map((stop) => { + if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') { + return [stop[0], convertTokenString(stop[1])]; + } + return [stop[0], convertLiteral(stop[1])]; + }); + if (zoomAndFeatureDependent) { + return convertZoomAndPropertyFunction(parameters, propertySpec, stops); + } + else if (zoomDependent) { + return convertZoomFunction(parameters, propertySpec, stops); + } + else { + return convertPropertyFunction(parameters, propertySpec, stops); + } +} +function convertIdentityFunction(parameters, propertySpec) { + const get = ['get', parameters.property]; + if (parameters.default === undefined) { + // By default, expressions for string-valued properties get coerced. To preserve + // legacy function semantics, insert an explicit assertion instead. + return propertySpec.type === 'string' ? ['string', get] : get; + } + else if (propertySpec.type === 'enum') { + return [ + 'match', + get, + Object.keys(propertySpec.values), + get, + parameters.default + ]; + } + else { + const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)]; + if (propertySpec.type === 'array') { + expression.splice(1, 0, propertySpec.value, propertySpec.length || null); + } + return expression; + } +} +function getInterpolateOperator(parameters) { + switch (parameters.colorSpace) { + case 'hcl': return 'interpolate-hcl'; + case 'lab': return 'interpolate-lab'; + default: return 'interpolate'; + } +} +function convertZoomAndPropertyFunction(parameters, propertySpec, stops) { + const featureFunctionParameters = {}; + const featureFunctionStops = {}; + const zoomStops = []; + for (let s = 0; s < stops.length; s++) { + const stop = stops[s]; + const zoom = stop[0].zoom; + if (featureFunctionParameters[zoom] === undefined) { + featureFunctionParameters[zoom] = { + zoom, + type: parameters.type, + property: parameters.property, + default: parameters.default, + }; + featureFunctionStops[zoom] = []; + zoomStops.push(zoom); + } + featureFunctionStops[zoom].push([stop[0].value, stop[1]]); + } + // the interpolation type for the zoom dimension of a zoom-and-property + // function is determined directly from the style property specification + // for which it's being used: linear for interpolatable properties, step + // otherwise. + const functionType = getFunctionType({}, propertySpec); + if (functionType === 'exponential') { + const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']]; + for (const z of zoomStops) { + const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]); + appendStopPair(expression, z, output, false); + } + return expression; + } + else { + const expression = ['step', ['zoom']]; + for (const z of zoomStops) { + const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]); + appendStopPair(expression, z, output, true); + } + fixupDegenerateStepCurve(expression); + return expression; + } +} +function coalesce(a, b) { + if (a !== undefined) + return a; + if (b !== undefined) + return b; +} +function getFallback(parameters, propertySpec) { + const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default)); + /* + * Some fields with type: resolvedImage have an undefined default. + * Because undefined is an invalid value for resolvedImage, set fallback to + * an empty string instead of undefined to ensure output + * passes validation. + */ + if (defaultValue === undefined && propertySpec.type === 'resolvedImage') { + return ''; + } + return defaultValue; +} +function convertPropertyFunction(parameters, propertySpec, stops) { + const type = getFunctionType(parameters, propertySpec); + const get = ['get', parameters.property]; + if (type === 'categorical' && typeof stops[0][0] === 'boolean') { + const expression = ['case']; + for (const stop of stops) { + expression.push(['==', get, stop[0]], stop[1]); + } + expression.push(getFallback(parameters, propertySpec)); + return expression; + } + else if (type === 'categorical') { + const expression = ['match', get]; + for (const stop of stops) { + appendStopPair(expression, stop[0], stop[1], false); + } + expression.push(getFallback(parameters, propertySpec)); + return expression; + } + else if (type === 'interval') { + const expression = ['step', ['number', get]]; + for (const stop of stops) { + appendStopPair(expression, stop[0], stop[1], true); + } + fixupDegenerateStepCurve(expression); + return parameters.default === undefined ? expression : [ + 'case', + ['==', ['typeof', get], 'number'], + expression, + convertLiteral(parameters.default) + ]; + } + else if (type === 'exponential') { + const base = parameters.base !== undefined ? parameters.base : 1; + const expression = [ + getInterpolateOperator(parameters), + base === 1 ? ['linear'] : ['exponential', base], + ['number', get] + ]; + for (const stop of stops) { + appendStopPair(expression, stop[0], stop[1], false); + } + return parameters.default === undefined ? expression : [ + 'case', + ['==', ['typeof', get], 'number'], + expression, + convertLiteral(parameters.default) + ]; + } + else { + throw new Error(`Unknown property function type ${type}`); + } +} +function convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) { + const type = getFunctionType(parameters, propertySpec); + let expression; + let isStep = false; + if (type === 'interval') { + expression = ['step', input]; + isStep = true; + } + else if (type === 'exponential') { + const base = parameters.base !== undefined ? parameters.base : 1; + expression = [getInterpolateOperator(parameters), base === 1 ? ['linear'] : ['exponential', base], input]; + } + else { + throw new Error(`Unknown zoom function type "${type}"`); + } + for (const stop of stops) { + appendStopPair(expression, stop[0], stop[1], isStep); + } + fixupDegenerateStepCurve(expression); + return expression; +} +function fixupDegenerateStepCurve(expression) { + // degenerate step curve (i.e. a constant function): add a noop stop + if (expression[0] === 'step' && expression.length === 3) { + expression.push(0); + expression.push(expression[3]); + } +} +function appendStopPair(curve, input, output, isStep) { + // Skip duplicate stop values. They were not validated for functions, but they are for expressions. + // https://github.com/mapbox/mapbox-gl-js/issues/4107 + if (curve.length > 3 && input === curve[curve.length - 2]) { + return; + } + // step curves don't get the first input value, as it is redundant. + if (!(isStep && curve.length === 2)) { + curve.push(input); + } + curve.push(output); +} +function getFunctionType(parameters, propertySpec) { + if (parameters.type) { + return parameters.type; + } + else { + return propertySpec.expression.interpolated ? 'exponential' : 'interval'; + } +} +// "String with {name} token" => ["concat", "String with ", ["get", "name"], " token"] +function convertTokenString(s) { + const result = ['concat']; + const re = /{([^{}]+)}/g; + let pos = 0; + for (let match = re.exec(s); match !== null; match = re.exec(s)) { + const literal = s.slice(pos, re.lastIndex - match[0].length); + pos = re.lastIndex; + if (literal.length > 0) + result.push(literal); + result.push(['get', match[1]]); + } + if (result.length === 1) { + return s; + } + if (pos < s.length) { + result.push(s.slice(pos)); + } + else if (result.length === 2) { + return ['to-string', result[1]]; + } + return result; +} + +function getPropertyReference(propertyName) { + for (let i = 0; i < v8Spec.layout.length; i++) { + for (const key in v8Spec[v8Spec.layout[i]]) { + if (key === propertyName) + return v8Spec[v8Spec.layout[i]][key]; + } + } + for (let i = 0; i < v8Spec.paint.length; i++) { + for (const key in v8Spec[v8Spec.paint[i]]) { + if (key === propertyName) + return v8Spec[v8Spec.paint[i]][key]; + } + } + return null; +} +function eachSource(style, callback) { + for (const k in style.sources) { + callback(style.sources[k]); + } +} +function eachLayer(style, callback) { + for (const layer of style.layers) { + callback(layer); + } +} +function eachProperty(style, options, callback) { + function inner(layer, propertyType) { + const properties = layer[propertyType]; + if (!properties) + return; + Object.keys(properties).forEach((key) => { + callback({ + path: [layer.id, propertyType, key], + key, + value: properties[key], + reference: getPropertyReference(key), + set(x) { + properties[key] = x; + } + }); + }); + } + eachLayer(style, (layer) => { + if (options.paint) { + inner(layer, 'paint'); + } + if (options.layout) { + inner(layer, 'layout'); + } + }); +} + +function stringify(obj) { + const type = typeof obj; + if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null) + return JSON.stringify(obj); + if (Array.isArray(obj)) { + let str = '['; + for (const val of obj) { + str += `${stringify(val)},`; + } + return `${str}]`; + } + const keys = Object.keys(obj).sort(); + let str = '{'; + for (let i = 0; i < keys.length; i++) { + str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`; + } + return `${str}}`; +} +function getKey(layer) { + let key = ''; + for (const k of refProperties) { + key += `/${stringify(layer[k])}`; + } + return key; +} +/** + * Given an array of layers, return an array of arrays of layers where all + * layers in each group have identical layout-affecting properties. These + * are the properties that were formerly used by explicit `ref` mechanism + * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom', + * 'filter', and 'layout'. + * + * The input is not modified. The output layers are references to the + * input layers. + * + * @private + * @param {Array} layers + * @param {Object} [cachedKeys] - an object to keep already calculated keys. + * @returns {Array>} + */ +function groupByLayout(layers, cachedKeys) { + const groups = {}; + for (let i = 0; i < layers.length; i++) { + const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]); + // update the cache if there is one + if (cachedKeys) + cachedKeys[layers[i].id] = k; + let group = groups[k]; + if (!group) { + group = groups[k] = []; + } + group.push(layers[i]); + } + const result = []; + for (const k in groups) { + result.push(groups[k]); + } + return result; +} + +function emptyStyle() { + const style = {}; + const version = v8Spec['$version']; + for (const styleKey in v8Spec['$root']) { + const spec = v8Spec['$root'][styleKey]; + if (spec.required) { + let value = null; + if (styleKey === 'version') { + value = version; + } + else { + if (spec.type === 'array') { + value = []; + } + else { + value = {}; + } + } + if (value != null) { + style[styleKey] = value; + } + } + } + return style; +} + +function validateConstants(options) { + const key = options.key; + const constants = options.value; + if (constants) { + return [new ValidationError(key, constants, 'constants have been deprecated as of v8')]; + } + else { + return []; + } +} + +// Turn jsonlint-lines-primitives objects into primitive objects +function unbundle(value) { + if (value instanceof Number || value instanceof String || value instanceof Boolean) { + return value.valueOf(); + } + else { + return value; + } +} +function deepUnbundle(value) { + if (Array.isArray(value)) { + return value.map(deepUnbundle); + } + else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) { + const unbundledValue = {}; + for (const key in value) { + unbundledValue[key] = deepUnbundle(value[key]); + } + return unbundledValue; + } + return unbundle(value); +} + +function validateObject(options) { + const key = options.key; + const object = options.value; + const elementSpecs = options.valueSpec || {}; + const elementValidators = options.objectElementValidators || {}; + const style = options.style; + const styleSpec = options.styleSpec; + const validateSpec = options.validateSpec; + let errors = []; + const type = getType(object); + if (type !== 'object') { + return [new ValidationError(key, object, `object expected, ${type} found`)]; + } + for (const objectKey in object) { + const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint' + const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*']; + let validateElement; + if (elementValidators[elementSpecKey]) { + validateElement = elementValidators[elementSpecKey]; + } + else if (elementSpecs[elementSpecKey]) { + validateElement = validateSpec; + } + else if (elementValidators['*']) { + validateElement = elementValidators['*']; + } + else if (elementSpecs['*']) { + validateElement = validateSpec; + } + else { + errors.push(new ValidationError(key, object[objectKey], `unknown property "${objectKey}"`)); + continue; + } + errors = errors.concat(validateElement({ + key: (key ? `${key}.` : key) + objectKey, + value: object[objectKey], + valueSpec: elementSpec, + style, + styleSpec, + object, + objectKey, + validateSpec, + }, object)); + } + for (const elementSpecKey in elementSpecs) { + // Don't check `required` when there's a custom validator for that property. + if (elementValidators[elementSpecKey]) { + continue; + } + if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) { + errors.push(new ValidationError(key, object, `missing required property "${elementSpecKey}"`)); + } + } + return errors; +} + +function validateArray(options) { + const array = options.value; + const arraySpec = options.valueSpec; + const validateSpec = options.validateSpec; + const style = options.style; + const styleSpec = options.styleSpec; + const key = options.key; + const validateArrayElement = options.arrayElementValidator || validateSpec; + if (getType(array) !== 'array') { + return [new ValidationError(key, array, `array expected, ${getType(array)} found`)]; + } + if (arraySpec.length && array.length !== arraySpec.length) { + return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)]; + } + if (arraySpec['min-length'] && array.length < arraySpec['min-length']) { + return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)]; + } + let arrayElementSpec = { + 'type': arraySpec.value, + 'values': arraySpec.values + }; + if (styleSpec.$version < 7) { + arrayElementSpec['function'] = arraySpec.function; + } + if (getType(arraySpec.value) === 'object') { + arrayElementSpec = arraySpec.value; + } + let errors = []; + for (let i = 0; i < array.length; i++) { + errors = errors.concat(validateArrayElement({ + array, + arrayIndex: i, + value: array[i], + valueSpec: arrayElementSpec, + validateSpec: options.validateSpec, + style, + styleSpec, + key: `${key}[${i}]` + })); + } + return errors; +} + +function validateNumber(options) { + const key = options.key; + const value = options.value; + const valueSpec = options.valueSpec; + let type = getType(value); + // eslint-disable-next-line no-self-compare + if (type === 'number' && value !== value) { + type = 'NaN'; + } + if (type !== 'number') { + return [new ValidationError(key, value, `number expected, ${type} found`)]; + } + if ('minimum' in valueSpec && value < valueSpec.minimum) { + return [new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)]; + } + if ('maximum' in valueSpec && value > valueSpec.maximum) { + return [new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)]; + } + return []; +} + +function validateFunction(options) { + const functionValueSpec = options.valueSpec; + const functionType = unbundle(options.value.type); + let stopKeyType; + let stopDomainValues = {}; + let previousStopDomainValue; + let previousStopDomainZoom; + const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined; + const isPropertyFunction = !isZoomFunction; + const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' && + getType(options.value.stops[0]) === 'array' && + getType(options.value.stops[0][0]) === 'object'; + const errors = validateObject({ + key: options.key, + value: options.value, + valueSpec: options.styleSpec.function, + validateSpec: options.validateSpec, + style: options.style, + styleSpec: options.styleSpec, + objectElementValidators: { + stops: validateFunctionStops, + default: validateFunctionDefault + } + }); + if (functionType === 'identity' && isZoomFunction) { + errors.push(new ValidationError(options.key, options.value, 'missing required property "property"')); + } + if (functionType !== 'identity' && !options.value.stops) { + errors.push(new ValidationError(options.key, options.value, 'missing required property "stops"')); + } + if (functionType === 'exponential' && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) { + errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported')); + } + if (options.styleSpec.$version >= 8) { + if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) { + errors.push(new ValidationError(options.key, options.value, 'property functions not supported')); + } + else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) { + errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported')); + } + } + if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) { + errors.push(new ValidationError(options.key, options.value, '"property" property is required')); + } + return errors; + function validateFunctionStops(options) { + if (functionType === 'identity') { + return [new ValidationError(options.key, options.value, 'identity function may not have a "stops" property')]; + } + let errors = []; + const value = options.value; + errors = errors.concat(validateArray({ + key: options.key, + value, + valueSpec: options.valueSpec, + validateSpec: options.validateSpec, + style: options.style, + styleSpec: options.styleSpec, + arrayElementValidator: validateFunctionStop + })); + if (getType(value) === 'array' && value.length === 0) { + errors.push(new ValidationError(options.key, value, 'array must have at least one stop')); + } + return errors; + } + function validateFunctionStop(options) { + let errors = []; + const value = options.value; + const key = options.key; + if (getType(value) !== 'array') { + return [new ValidationError(key, value, `array expected, ${getType(value)} found`)]; + } + if (value.length !== 2) { + return [new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)]; + } + if (isZoomAndPropertyFunction) { + if (getType(value[0]) !== 'object') { + return [new ValidationError(key, value, `object expected, ${getType(value[0])} found`)]; + } + if (value[0].zoom === undefined) { + return [new ValidationError(key, value, 'object stop key must have zoom')]; + } + if (value[0].value === undefined) { + return [new ValidationError(key, value, 'object stop key must have value')]; + } + if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) { + return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')]; + } + if (unbundle(value[0].zoom) !== previousStopDomainZoom) { + previousStopDomainZoom = unbundle(value[0].zoom); + previousStopDomainValue = undefined; + stopDomainValues = {}; + } + errors = errors.concat(validateObject({ + key: `${key}[0]`, + value: value[0], + valueSpec: { zoom: {} }, + validateSpec: options.validateSpec, + style: options.style, + styleSpec: options.styleSpec, + objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue } + })); + } + else { + errors = errors.concat(validateStopDomainValue({ + key: `${key}[0]`, + value: value[0], + valueSpec: {}, + validateSpec: options.validateSpec, + style: options.style, + styleSpec: options.styleSpec + }, value)); + } + if (isExpression(deepUnbundle(value[1]))) { + return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]); + } + return errors.concat(options.validateSpec({ + key: `${key}[1]`, + value: value[1], + valueSpec: functionValueSpec, + validateSpec: options.validateSpec, + style: options.style, + styleSpec: options.styleSpec + })); + } + function validateStopDomainValue(options, stop) { + const type = getType(options.value); + const value = unbundle(options.value); + const reportValue = options.value !== null ? options.value : stop; + if (!stopKeyType) { + stopKeyType = type; + } + else if (type !== stopKeyType) { + return [new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)]; + } + if (type !== 'number' && type !== 'string' && type !== 'boolean') { + return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')]; + } + if (type !== 'number' && functionType !== 'categorical') { + let message = `number expected, ${type} found`; + if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) { + message += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.'; + } + return [new ValidationError(options.key, reportValue, message)]; + } + if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) { + return [new ValidationError(options.key, reportValue, `integer expected, found ${value}`)]; + } + if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) { + return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')]; + } + else { + previousStopDomainValue = value; + } + if (functionType === 'categorical' && value in stopDomainValues) { + return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')]; + } + else { + stopDomainValues[value] = true; + } + return []; + } + function validateFunctionDefault(options) { + return options.validateSpec({ + key: options.key, + value: options.value, + valueSpec: functionValueSpec, + validateSpec: options.validateSpec, + style: options.style, + styleSpec: options.styleSpec + }); + } +} + +function validateExpression(options) { + const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec); + if (expression.result === 'error') { + return expression.value.map((error) => { + return new ValidationError(`${options.key}${error.key}`, options.value, error.message); + }); + } + const expressionObj = expression.value.expression || expression.value._styleExpression.expression; + if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') && + !expressionObj.outputDefined()) { + return [new ValidationError(options.key, options.value, `Invalid data expression for "${options.propertyKey}". Output values must be contained as literals within the expression.`)]; + } + if (options.expressionContext === 'property' && options.propertyType === 'layout' && + (!isStateConstant(expressionObj))) { + return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with layout properties.')]; + } + if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) { + return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with filters.')]; + } + if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) { + if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) { + return [new ValidationError(options.key, options.value, '"zoom" and "feature-state" expressions are not supported with cluster properties.')]; + } + if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) { + return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')]; + } + } + return []; +} + +function validateBoolean(options) { + const value = options.value; + const key = options.key; + const type = getType(value); + if (type !== 'boolean') { + return [new ValidationError(key, value, `boolean expected, ${type} found`)]; + } + return []; +} + +function validateColor(options) { + const key = options.key; + const value = options.value; + const type = getType(value); + if (type !== 'string') { + return [new ValidationError(key, value, `color expected, ${type} found`)]; + } + if (!Color.parse(String(value))) { // cast String object to string primitive + return [new ValidationError(key, value, `color expected, "${value}" found`)]; + } + return []; +} + +function validateEnum(options) { + const key = options.key; + const value = options.value; + const valueSpec = options.valueSpec; + const errors = []; + if (Array.isArray(valueSpec.values)) { // <=v7 + if (valueSpec.values.indexOf(unbundle(value)) === -1) { + errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`)); + } + } + else { // >=v8 + if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) { + errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`)); + } + } + return errors; +} + +function validateFilter$1(options) { + if (isExpressionFilter(deepUnbundle(options.value))) { + return validateExpression(extendBy({}, options, { + expressionContext: 'filter', + valueSpec: { value: 'boolean' } + })); + } + else { + return validateNonExpressionFilter(options); + } +} +function validateNonExpressionFilter(options) { + const value = options.value; + const key = options.key; + if (getType(value) !== 'array') { + return [new ValidationError(key, value, `array expected, ${getType(value)} found`)]; + } + const styleSpec = options.styleSpec; + let type; + let errors = []; + if (value.length < 1) { + return [new ValidationError(key, value, 'filter array must have at least 1 element')]; + } + errors = errors.concat(validateEnum({ + key: `${key}[0]`, + value: value[0], + valueSpec: styleSpec.filter_operator, + style: options.style, + styleSpec: options.styleSpec + })); + switch (unbundle(value[0])) { + case '<': + case '<=': + case '>': + case '>=': + if (value.length >= 2 && unbundle(value[1]) === '$type') { + errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${value[0]}"`)); + } + /* falls through */ + case '==': + case '!=': + if (value.length !== 3) { + errors.push(new ValidationError(key, value, `filter array for operator "${value[0]}" must have 3 elements`)); + } + /* falls through */ + case 'in': + case '!in': + if (value.length >= 2) { + type = getType(value[1]); + if (type !== 'string') { + errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`)); + } + } + for (let i = 2; i < value.length; i++) { + type = getType(value[i]); + if (unbundle(value[1]) === '$type') { + errors = errors.concat(validateEnum({ + key: `${key}[${i}]`, + value: value[i], + valueSpec: styleSpec.geometry_type, + style: options.style, + styleSpec: options.styleSpec + })); + } + else if (type !== 'string' && type !== 'number' && type !== 'boolean') { + errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`)); + } + } + break; + case 'any': + case 'all': + case 'none': + for (let i = 1; i < value.length; i++) { + errors = errors.concat(validateNonExpressionFilter({ + key: `${key}[${i}]`, + value: value[i], + style: options.style, + styleSpec: options.styleSpec + })); + } + break; + case 'has': + case '!has': + type = getType(value[1]); + if (value.length !== 2) { + errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`)); + } + else if (type !== 'string') { + errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`)); + } + break; + case 'within': + type = getType(value[1]); + if (value.length !== 2) { + errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`)); + } + else if (type !== 'object') { + errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`)); + } + break; + } + return errors; +} + +function validateProperty(options, propertyType) { + const key = options.key; + const validateSpec = options.validateSpec; + const style = options.style; + const styleSpec = options.styleSpec; + const value = options.value; + const propertyKey = options.objectKey; + const layerSpec = styleSpec[`${propertyType}_${options.layerType}`]; + if (!layerSpec) + return []; + const transitionMatch = propertyKey.match(/^(.*)-transition$/); + if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) { + return validateSpec({ + key, + value, + valueSpec: styleSpec.transition, + style, + styleSpec + }); + } + const valueSpec = options.valueSpec || layerSpec[propertyKey]; + if (!valueSpec) { + return [new ValidationError(key, value, `unknown property "${propertyKey}"`)]; + } + let tokenMatch; + if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) { + return [new ValidationError(key, value, `"${propertyKey}" does not support interpolation syntax\n` + + `Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(tokenMatch[1])} }\`.`)]; + } + const errors = []; + if (options.layerType === 'symbol') { + if (propertyKey === 'text-field' && style && !style.glyphs) { + errors.push(new ValidationError(key, value, 'use of "text-field" requires a style "glyphs" property')); + } + if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') { + errors.push(new ValidationError(key, value, '"text-font" does not support identity functions')); + } + } + return errors.concat(validateSpec({ + key: options.key, + value, + valueSpec, + style, + styleSpec, + expressionContext: 'property', + propertyType, + propertyKey + })); +} + +function validatePaintProperty$1(options) { + return validateProperty(options, 'paint'); +} + +function validateLayoutProperty$1(options) { + return validateProperty(options, 'layout'); +} + +function validateLayer(options) { + let errors = []; + const layer = options.value; + const key = options.key; + const style = options.style; + const styleSpec = options.styleSpec; + if (!layer.type && !layer.ref) { + errors.push(new ValidationError(key, layer, 'either "type" or "ref" is required')); + } + let type = unbundle(layer.type); + const ref = unbundle(layer.ref); + if (layer.id) { + const layerId = unbundle(layer.id); + for (let i = 0; i < options.arrayIndex; i++) { + const otherLayer = style.layers[i]; + if (unbundle(otherLayer.id) === layerId) { + errors.push(new ValidationError(key, layer.id, `duplicate layer id "${layer.id}", previously used at line ${otherLayer.id.__line__}`)); + } + } + } + if ('ref' in layer) { + ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => { + if (p in layer) { + errors.push(new ValidationError(key, layer[p], `"${p}" is prohibited for ref layers`)); + } + }); + let parent; + style.layers.forEach((layer) => { + if (unbundle(layer.id) === ref) + parent = layer; + }); + if (!parent) { + errors.push(new ValidationError(key, layer.ref, `ref layer "${ref}" not found`)); + } + else if (parent.ref) { + errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer')); + } + else { + type = unbundle(parent.type); + } + } + else if (type !== 'background') { + if (!layer.source) { + errors.push(new ValidationError(key, layer, 'missing required property "source"')); + } + else { + const source = style.sources && style.sources[layer.source]; + const sourceType = source && unbundle(source.type); + if (!source) { + errors.push(new ValidationError(key, layer.source, `source "${layer.source}" not found`)); + } + else if (sourceType === 'vector' && type === 'raster') { + errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster source`)); + } + else if (sourceType !== 'raster-dem' && type === 'hillshade') { + errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster-dem source`)); + } + else if (sourceType === 'raster' && type !== 'raster') { + errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a vector source`)); + } + else if (sourceType === 'vector' && !layer['source-layer']) { + errors.push(new ValidationError(key, layer, `layer "${layer.id}" must specify a "source-layer"`)); + } + else if (sourceType === 'raster-dem' && type !== 'hillshade') { + errors.push(new ValidationError(key, layer.source, 'raster-dem source can only be used with layer type \'hillshade\'.')); + } + else if (type === 'line' && layer.paint && layer.paint['line-gradient'] && + (sourceType !== 'geojson' || !source.lineMetrics)) { + errors.push(new ValidationError(key, layer, `layer "${layer.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)); + } + } + } + errors = errors.concat(validateObject({ + key, + value: layer, + valueSpec: styleSpec.layer, + style: options.style, + styleSpec: options.styleSpec, + validateSpec: options.validateSpec, + objectElementValidators: { + '*'() { + return []; + }, + // We don't want to enforce the spec's `"requires": true` for backward compatibility with refs; + // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772. + type() { + return options.validateSpec({ + key: `${key}.type`, + value: layer.type, + valueSpec: styleSpec.layer.type, + style: options.style, + styleSpec: options.styleSpec, + validateSpec: options.validateSpec, + object: layer, + objectKey: 'type' + }); + }, + filter: validateFilter$1, + layout(options) { + return validateObject({ + layer, + key: options.key, + value: options.value, + style: options.style, + styleSpec: options.styleSpec, + validateSpec: options.validateSpec, + objectElementValidators: { + '*'(options) { + return validateLayoutProperty$1(extendBy({ layerType: type }, options)); + } + } + }); + }, + paint(options) { + return validateObject({ + layer, + key: options.key, + value: options.value, + style: options.style, + styleSpec: options.styleSpec, + validateSpec: options.validateSpec, + objectElementValidators: { + '*'(options) { + return validatePaintProperty$1(extendBy({ layerType: type }, options)); + } + } + }); + } + } + })); + return errors; +} + +function validateString(options) { + const value = options.value; + const key = options.key; + const type = getType(value); + if (type !== 'string') { + return [new ValidationError(key, value, `string expected, ${type} found`)]; + } + return []; +} + +function validateRasterDEMSource(options) { + var _a; + const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : ''; + const rasterDEM = options.value; + const styleSpec = options.styleSpec; + const rasterDEMSpec = styleSpec.source_raster_dem; + const style = options.style; + let errors = []; + const rootType = getType(rasterDEM); + if (rasterDEM === undefined) { + return errors; + } + else if (rootType !== 'object') { + errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`)); + return errors; + } + const encoding = unbundle(rasterDEM.encoding); + const isCustomEncoding = encoding === 'custom'; + const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift']; + const encodingName = options.value.encoding ? `"${options.value.encoding}"` : 'Default'; + for (const key in rasterDEM) { + if (!isCustomEncoding && customEncodingKeys.includes(key)) { + errors.push(new ValidationError(key, rasterDEM[key], `In "${sourceName}": "${key}" is only valid when "encoding" is set to "custom". ${encodingName} encoding found`)); + } + else if (rasterDEMSpec[key]) { + errors = errors.concat(options.validateSpec({ + key, + value: rasterDEM[key], + valueSpec: rasterDEMSpec[key], + validateSpec: options.validateSpec, + style, + styleSpec + })); + } + else { + errors.push(new ValidationError(key, rasterDEM[key], `unknown property "${key}"`)); + } + } + return errors; +} + +const objectElementValidators = { + promoteId: validatePromoteId +}; +function validateSource$1(options) { + const value = options.value; + const key = options.key; + const styleSpec = options.styleSpec; + const style = options.style; + const validateSpec = options.validateSpec; + if (!value.type) { + return [new ValidationError(key, value, '"type" is required')]; + } + const type = unbundle(value.type); + let errors; + switch (type) { + case 'vector': + case 'raster': + errors = validateObject({ + key, + value, + valueSpec: styleSpec[`source_${type.replace('-', '_')}`], + style: options.style, + styleSpec, + objectElementValidators, + validateSpec, + }); + return errors; + case 'raster-dem': + errors = validateRasterDEMSource({ + sourceName: key, + value, + style: options.style, + styleSpec, + validateSpec, + }); + return errors; + case 'geojson': + errors = validateObject({ + key, + value, + valueSpec: styleSpec.source_geojson, + style, + styleSpec, + validateSpec, + objectElementValidators + }); + if (value.cluster) { + for (const prop in value.clusterProperties) { + const [operator, mapExpr] = value.clusterProperties[prop]; + const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator; + errors.push(...validateExpression({ + key: `${key}.${prop}.map`, + value: mapExpr, + validateSpec, + expressionContext: 'cluster-map' + })); + errors.push(...validateExpression({ + key: `${key}.${prop}.reduce`, + value: reduceExpr, + validateSpec, + expressionContext: 'cluster-reduce' + })); + } + } + return errors; + case 'video': + return validateObject({ + key, + value, + valueSpec: styleSpec.source_video, + style, + validateSpec, + styleSpec + }); + case 'image': + return validateObject({ + key, + value, + valueSpec: styleSpec.source_image, + style, + validateSpec, + styleSpec + }); + case 'canvas': + return [new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')]; + default: + return validateEnum({ + key: `${key}.type`, + value: value.type, + valueSpec: { values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image'] }, + style, + validateSpec, + styleSpec + }); + } +} +function validatePromoteId({ key, value }) { + if (getType(value) === 'string') { + return validateString({ key, value }); + } + else { + const errors = []; + for (const prop in value) { + errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] })); + } + return errors; + } +} + +function validateLight$1(options) { + const light = options.value; + const styleSpec = options.styleSpec; + const lightSpec = styleSpec.light; + const style = options.style; + let errors = []; + const rootType = getType(light); + if (light === undefined) { + return errors; + } + else if (rootType !== 'object') { + errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]); + return errors; + } + for (const key in light) { + const transitionMatch = key.match(/^(.*)-transition$/); + if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) { + errors = errors.concat(options.validateSpec({ + key, + value: light[key], + valueSpec: styleSpec.transition, + validateSpec: options.validateSpec, + style, + styleSpec + })); + } + else if (lightSpec[key]) { + errors = errors.concat(options.validateSpec({ + key, + value: light[key], + valueSpec: lightSpec[key], + validateSpec: options.validateSpec, + style, + styleSpec + })); + } + else { + errors = errors.concat([new ValidationError(key, light[key], `unknown property "${key}"`)]); + } + } + return errors; +} + +function validateTerrain$1(options) { + const terrain = options.value; + const styleSpec = options.styleSpec; + const terrainSpec = styleSpec.terrain; + const style = options.style; + let errors = []; + const rootType = getType(terrain); + if (terrain === undefined) { + return errors; + } + else if (rootType !== 'object') { + errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${rootType} found`)]); + return errors; + } + for (const key in terrain) { + if (terrainSpec[key]) { + errors = errors.concat(options.validateSpec({ + key, + value: terrain[key], + valueSpec: terrainSpec[key], + validateSpec: options.validateSpec, + style, + styleSpec + })); + } + else { + errors = errors.concat([new ValidationError(key, terrain[key], `unknown property "${key}"`)]); + } + } + return errors; +} + +function validateFormatted(options) { + if (validateString(options).length === 0) { + return []; + } + return validateExpression(options); +} + +function validateImage(options) { + if (validateString(options).length === 0) { + return []; + } + return validateExpression(options); +} + +function validatePadding(options) { + const key = options.key; + const value = options.value; + const type = getType(value); + if (type === 'array') { + if (value.length < 1 || value.length > 4) { + return [new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)]; + } + const arrayElementSpec = { + type: 'number' + }; + let errors = []; + for (let i = 0; i < value.length; i++) { + errors = errors.concat(options.validateSpec({ + key: `${key}[${i}]`, + value: value[i], + validateSpec: options.validateSpec, + valueSpec: arrayElementSpec + })); + } + return errors; + } + else { + return validateNumber({ + key, + value, + valueSpec: {} + }); + } +} + +function validateVariableAnchorOffsetCollection(options) { + const key = options.key; + const value = options.value; + const type = getType(value); + const styleSpec = options.styleSpec; + if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) { + return [new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')]; + } + let errors = []; + for (let i = 0; i < value.length; i += 2) { + // Elements in even positions should be values from text-anchor enum + errors = errors.concat(validateEnum({ + key: `${key}[${i}]`, + value: value[i], + valueSpec: styleSpec['layout_symbol']['text-anchor'] + })); + // Elements in odd positions should be points (2-element numeric arrays) + errors = errors.concat(validateArray({ + key: `${key}[${i + 1}]`, + value: value[i + 1], + valueSpec: { + length: 2, + value: 'number' + }, + validateSpec: options.validateSpec, + style: options.style, + styleSpec + })); + } + return errors; +} + +function validateSprite(options) { + let errors = []; + const sprite = options.value; + const key = options.key; + if (!Array.isArray(sprite)) { + return validateString({ + key, + value: sprite + }); + } + else { + const allSpriteIds = []; + const allSpriteURLs = []; + for (const i in sprite) { + if (sprite[i].id && allSpriteIds.includes(sprite[i].id)) + errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`)); + allSpriteIds.push(sprite[i].id); + if (sprite[i].url && allSpriteURLs.includes(sprite[i].url)) + errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`)); + allSpriteURLs.push(sprite[i].url); + const pairSpec = { + id: { + type: 'string', + required: true, + }, + url: { + type: 'string', + required: true, + } + }; + errors = errors.concat(validateObject({ + key: `${key}[${i}]`, + value: sprite[i], + valueSpec: pairSpec, + validateSpec: options.validateSpec, + })); + } + return errors; + } +} + +const VALIDATORS = { + '*'() { + return []; + }, + 'array': validateArray, + 'boolean': validateBoolean, + 'number': validateNumber, + 'color': validateColor, + 'constants': validateConstants, + 'enum': validateEnum, + 'filter': validateFilter$1, + 'function': validateFunction, + 'layer': validateLayer, + 'object': validateObject, + 'source': validateSource$1, + 'light': validateLight$1, + 'terrain': validateTerrain$1, + 'string': validateString, + 'formatted': validateFormatted, + 'resolvedImage': validateImage, + 'padding': validatePadding, + 'variableAnchorOffsetCollection': validateVariableAnchorOffsetCollection, + 'sprite': validateSprite, +}; +// Main recursive validation function. Tracks: +// +// - key: string representing location of validation in style tree. Used only +// for more informative error reporting. +// - value: current value from style being evaluated. May be anything from a +// high level object that needs to be descended into deeper or a simple +// scalar value. +// - valueSpec: current spec being evaluated. Tracks value. +// - styleSpec: current full spec being evaluated. +function validate(options) { + const value = options.value; + const valueSpec = options.valueSpec; + const styleSpec = options.styleSpec; + options.validateSpec = validate; + if (valueSpec.expression && isFunction(unbundle(value))) { + return validateFunction(options); + } + else if (valueSpec.expression && isExpression(deepUnbundle(value))) { + return validateExpression(options); + } + else if (valueSpec.type && VALIDATORS[valueSpec.type]) { + return VALIDATORS[valueSpec.type](options); + } + else { + const valid = validateObject(extendBy({}, options, { + valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec + })); + return valid; + } +} + +function validateGlyphsUrl(options) { + const value = options.value; + const key = options.key; + const errors = validateString(options); + if (errors.length) + return errors; + if (value.indexOf('{fontstack}') === -1) { + errors.push(new ValidationError(key, value, '"glyphs" url must include a "{fontstack}" token')); + } + if (value.indexOf('{range}') === -1) { + errors.push(new ValidationError(key, value, '"glyphs" url must include a "{range}" token')); + } + return errors; +} + +/** + * Validate a MapLibre style against the style specification. This entrypoint, + * `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as + * small a browserify bundle as possible by omitting unnecessary functionality + * and legacy style specifications. + * + * @private + * @param {Object} style The style to be validated. + * @param {Object} [styleSpec] The style specification to validate against. + * If omitted, the latest style spec is used. + * @returns {Array} + * @example + * var validate = require('maplibre-gl-style-spec/lib/validate_style.min'); + * var errors = validate(style); + */ +function validateStyleMin(style, styleSpec = v8Spec) { + let errors = []; + errors = errors.concat(validate({ + key: '', + value: style, + valueSpec: styleSpec.$root, + styleSpec, + style, + validateSpec: validate, + objectElementValidators: { + glyphs: validateGlyphsUrl, + '*'() { + return []; + } + } + })); + if (style['constants']) { + errors = errors.concat(validateConstants({ + key: 'constants', + value: style['constants'], + style, + styleSpec, + validateSpec: validate, + })); + } + return sortErrors(errors); +} +validateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource$1)); +validateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite)); +validateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl)); +validateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight$1)); +validateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain$1)); +validateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer)); +validateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter$1)); +validateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty$1)); +validateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty$1)); +function injectValidateSpec(validator) { + return function (options) { + return validator({ + ...options, + validateSpec: validate, + }); + }; +} +function sortErrors(errors) { + return [].concat(errors).sort((a, b) => { + return a.line - b.line; + }); +} +function wrapCleanErrors(inner) { + return function (...args) { + return sortErrors(inner.apply(this, args)); + }; +} + +const v8 = v8Spec; +const expression = { + StyleExpression, + StylePropertyFunction, + ZoomConstantExpression, + ZoomDependentExpression, + createExpression, + createPropertyExpression, + isExpression, + isExpressionFilter, + isZoomExpression, + normalizePropertyExpression, +}; +const styleFunction = { + convertFunction, + createFunction, + isFunction +}; +const visit = { eachLayer, eachProperty, eachSource }; + +const validateStyle = validateStyleMin; +const validateSource = validateStyle.source; +const validateLight = validateStyle.light; +const validateTerrain = validateStyle.terrain; +const validateFilter = validateStyle.filter; +const validatePaintProperty = validateStyle.paintProperty; +const validateLayoutProperty = validateStyle.layoutProperty; +function emitValidationErrors(emitter, errors) { + let hasErrors = false; + if (errors && errors.length) { + for (const error of errors) { + emitter.fire(new ErrorEvent(new Error(error.message))); + hasErrors = true; + } + } + return hasErrors; +} + +/* +This file was copied from https://github.com/mapbox/grid-index and was +migrated from JavaScript to TypeScript. + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. +*/ +const NUM_PARAMS = 3; +class TransferableGridIndex { + constructor(extent, n, padding) { + const cells = this.cells = []; + if (extent instanceof ArrayBuffer) { + this.arrayBuffer = extent; + const array = new Int32Array(this.arrayBuffer); + extent = array[0]; + n = array[1]; + padding = array[2]; + this.d = n + 2 * padding; + for (let k = 0; k < this.d * this.d; k++) { + const start = array[NUM_PARAMS + k]; + const end = array[NUM_PARAMS + k + 1]; + cells.push(start === end ? null : array.subarray(start, end)); + } + const keysOffset = array[NUM_PARAMS + cells.length]; + const bboxesOffset = array[NUM_PARAMS + cells.length + 1]; + this.keys = array.subarray(keysOffset, bboxesOffset); + this.bboxes = array.subarray(bboxesOffset); + this.insert = this._insertReadonly; + } + else { + this.d = n + 2 * padding; + for (let i = 0; i < this.d * this.d; i++) { + cells.push([]); + } + this.keys = []; + this.bboxes = []; + } + this.n = n; + this.extent = extent; + this.padding = padding; + this.scale = n / extent; + this.uid = 0; + const p = (padding / n) * extent; + this.min = -p; + this.max = extent + p; + } + insert(key, x1, y1, x2, y2) { + this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined); + this.keys.push(key); + this.bboxes.push(x1); + this.bboxes.push(y1); + this.bboxes.push(x2); + this.bboxes.push(y2); + } + _insertReadonly() { + throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.'); + } + _insertCell(x1, y1, x2, y2, cellIndex, uid) { + this.cells[cellIndex].push(uid); + } + query(x1, y1, x2, y2, intersectionTest) { + const min = this.min; + const max = this.max; + if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) { + // We use `Array#slice` because `this.keys` may be a `Int32Array` and + // some browsers (Safari and IE) do not support `TypedArray#slice` + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility + return Array.prototype.slice.call(this.keys); + } + else { + const result = []; + const seenUids = {}; + this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest); + return result; + } + } + _queryCell(x1, y1, x2, y2, cellIndex, result, seenUids, intersectionTest) { + const cell = this.cells[cellIndex]; + if (cell !== null) { + const keys = this.keys; + const bboxes = this.bboxes; + for (let u = 0; u < cell.length; u++) { + const uid = cell[u]; + if (seenUids[uid] === undefined) { + const offset = uid * 4; + if (intersectionTest ? + intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) : + ((x1 <= bboxes[offset + 2]) && + (y1 <= bboxes[offset + 3]) && + (x2 >= bboxes[offset + 0]) && + (y2 >= bboxes[offset + 1]))) { + seenUids[uid] = true; + result.push(keys[uid]); + } + else { + seenUids[uid] = false; + } + } + } + } + } + _forEachCell(x1, y1, x2, y2, fn, arg1, arg2, intersectionTest) { + const cx1 = this._convertToCellCoord(x1); + const cy1 = this._convertToCellCoord(y1); + const cx2 = this._convertToCellCoord(x2); + const cy2 = this._convertToCellCoord(y2); + for (let x = cx1; x <= cx2; x++) { + for (let y = cy1; y <= cy2; y++) { + const cellIndex = this.d * y + x; + if (intersectionTest && !intersectionTest(this._convertFromCellCoord(x), this._convertFromCellCoord(y), this._convertFromCellCoord(x + 1), this._convertFromCellCoord(y + 1))) + continue; + if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) + return; + } + } + } + _convertFromCellCoord(x) { + return (x - this.padding) / this.scale; + } + _convertToCellCoord(x) { + return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding)); + } + toArrayBuffer() { + if (this.arrayBuffer) + return this.arrayBuffer; + const cells = this.cells; + const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1; + let totalCellLength = 0; + for (let i = 0; i < this.cells.length; i++) { + totalCellLength += this.cells[i].length; + } + const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length); + array[0] = this.extent; + array[1] = this.n; + array[2] = this.padding; + let offset = metadataLength; + for (let k = 0; k < cells.length; k++) { + const cell = cells[k]; + array[NUM_PARAMS + k] = offset; + array.set(cell, offset); + offset += cell.length; + } + array[NUM_PARAMS + cells.length] = offset; + array.set(this.keys, offset); + offset += this.keys.length; + array[NUM_PARAMS + cells.length + 1] = offset; + array.set(this.bboxes, offset); + offset += this.bboxes.length; + return array.buffer; + } + static serialize(grid, transferables) { + const buffer = grid.toArrayBuffer(); + if (transferables) { + transferables.push(buffer); + } + return { buffer }; + } + static deserialize(serialized) { + return new TransferableGridIndex(serialized.buffer); + } +} + +const registry = {}; +/** + * Register the given class as serializable. + * + * @param options - the registration options + */ +function register(name, klass, options = {}) { + if (registry[name]) + throw new Error(`${name} is already registered.`); + Object.defineProperty(klass, '_classRegistryKey', { + value: name, + writeable: false + }); + registry[name] = { + klass, + omit: options.omit || [], + shallow: options.shallow || [] + }; +} +register('Object', Object); +register('TransferableGridIndex', TransferableGridIndex); +register('Color', Color); +register('Error', Error); +register('AJAXError', AJAXError); +register('ResolvedImage', ResolvedImage); +register('StylePropertyFunction', StylePropertyFunction); +register('StyleExpression', StyleExpression, { omit: ['_evaluator'] }); +register('ZoomDependentExpression', ZoomDependentExpression); +register('ZoomConstantExpression', ZoomConstantExpression); +register('CompoundExpression', CompoundExpression, { omit: ['_evaluate'] }); +for (const name in expressions) { + if (expressions[name]._classRegistryKey) + continue; + register(`Expression_${name}`, expressions[name]); +} +function isArrayBuffer(value) { + return value && typeof ArrayBuffer !== 'undefined' && + (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer')); +} +/** + * Serialize the given object for transfer to or from a web worker. + * + * For non-builtin types, recursively serialize each property (possibly + * omitting certain properties - see register()), and package the result along + * with the constructor's `name` so that the appropriate constructor can be + * looked up in `deserialize()`. + * + * If a `transferables` array is provided, add any transferable objects (i.e., + * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed, + * this should happen in the client code, before using serialize().) + */ +function serialize(input, transferables) { + if (input === null || + input === undefined || + typeof input === 'boolean' || + typeof input === 'number' || + typeof input === 'string' || + input instanceof Boolean || + input instanceof Number || + input instanceof String || + input instanceof Date || + input instanceof RegExp || + input instanceof Blob) { + return input; + } + if (isArrayBuffer(input)) { + if (transferables) { + transferables.push(input); + } + return input; + } + if (isImageBitmap(input)) { + if (transferables) { + transferables.push(input); + } + return input; + } + if (ArrayBuffer.isView(input)) { + const view = input; + if (transferables) { + transferables.push(view.buffer); + } + return view; + } + if (input instanceof ImageData) { + if (transferables) { + transferables.push(input.data.buffer); + } + return input; + } + if (Array.isArray(input)) { + const serialized = []; + for (const item of input) { + serialized.push(serialize(item, transferables)); + } + return serialized; + } + if (typeof input === 'object') { + const klass = input.constructor; + const name = klass._classRegistryKey; + if (!name) { + throw new Error('can\'t serialize object of unregistered class'); + } + if (!registry[name]) + throw new Error(`${name} is not registered.`); + const properties = klass.serialize ? + // (Temporary workaround) allow a class to provide static + // `serialize()` and `deserialize()` methods to bypass the generic + // approach. + // This temporary workaround lets us use the generic serialization + // approach for objects whose members include instances of dynamic + // StructArray types. Once we refactor StructArray to be static, + // we can remove this complexity. + klass.serialize(input, transferables) : {}; + if (!klass.serialize) { + for (const key in input) { + if (!input.hasOwnProperty(key)) + continue; // eslint-disable-line no-prototype-builtins + if (registry[name].omit.indexOf(key) >= 0) + continue; + const property = input[key]; + properties[key] = registry[name].shallow.indexOf(key) >= 0 ? + property : + serialize(property, transferables); + } + if (input instanceof Error) { + properties.message = input.message; + } + } + else { + if (transferables && properties === transferables[transferables.length - 1]) { + throw new Error('statically serialized object won\'t survive transfer of $name property'); + } + } + if (properties.$name) { + throw new Error('$name property is reserved for worker serialization logic.'); + } + if (name !== 'Object') { + properties.$name = name; + } + return properties; + } + throw new Error(`can't serialize object of type ${typeof input}`); +} +function deserialize(input) { + if (input === null || + input === undefined || + typeof input === 'boolean' || + typeof input === 'number' || + typeof input === 'string' || + input instanceof Boolean || + input instanceof Number || + input instanceof String || + input instanceof Date || + input instanceof RegExp || + input instanceof Blob || + isArrayBuffer(input) || + isImageBitmap(input) || + ArrayBuffer.isView(input) || + input instanceof ImageData) { + return input; + } + if (Array.isArray(input)) { + return input.map(deserialize); + } + if (typeof input === 'object') { + const name = input.$name || 'Object'; + if (!registry[name]) { + throw new Error(`can't deserialize unregistered class ${name}`); + } + const { klass } = registry[name]; + if (!klass) { + throw new Error(`can't deserialize unregistered class ${name}`); + } + if (klass.deserialize) { + return klass.deserialize(input); + } + const result = Object.create(klass.prototype); + for (const key of Object.keys(input)) { + if (key === '$name') + continue; + const value = input[key]; + result[key] = registry[name].shallow.indexOf(key) >= 0 ? value : deserialize(value); + } + return result; + } + throw new Error(`can't deserialize object of type ${typeof input}`); +} + +class ZoomHistory { + constructor() { + this.first = true; + } + update(z, now) { + const floorZ = Math.floor(z); + if (this.first) { + this.first = false; + this.lastIntegerZoom = floorZ; + this.lastIntegerZoomTime = 0; + this.lastZoom = z; + this.lastFloorZoom = floorZ; + return true; + } + if (this.lastFloorZoom > floorZ) { + this.lastIntegerZoom = floorZ + 1; + this.lastIntegerZoomTime = now; + } + else if (this.lastFloorZoom < floorZ) { + this.lastIntegerZoom = floorZ; + this.lastIntegerZoomTime = now; + } + if (z !== this.lastZoom) { + this.lastZoom = z; + this.lastFloorZoom = floorZ; + return true; + } + return false; + } +} + +// The following table comes from . +// Keep it synchronized with . +const unicodeBlockLookup = { + // 'Basic Latin': (char) => char >= 0x0000 && char <= 0x007F, + 'Latin-1 Supplement': (char) => char >= 0x0080 && char <= 0x00FF, + // 'Latin Extended-A': (char) => char >= 0x0100 && char <= 0x017F, + // 'Latin Extended-B': (char) => char >= 0x0180 && char <= 0x024F, + // 'IPA Extensions': (char) => char >= 0x0250 && char <= 0x02AF, + // 'Spacing Modifier Letters': (char) => char >= 0x02B0 && char <= 0x02FF, + // 'Combining Diacritical Marks': (char) => char >= 0x0300 && char <= 0x036F, + // 'Greek and Coptic': (char) => char >= 0x0370 && char <= 0x03FF, + // 'Cyrillic': (char) => char >= 0x0400 && char <= 0x04FF, + // 'Cyrillic Supplement': (char) => char >= 0x0500 && char <= 0x052F, + // 'Armenian': (char) => char >= 0x0530 && char <= 0x058F, + //'Hebrew': (char) => char >= 0x0590 && char <= 0x05FF, + 'Arabic': (char) => char >= 0x0600 && char <= 0x06FF, + //'Syriac': (char) => char >= 0x0700 && char <= 0x074F, + 'Arabic Supplement': (char) => char >= 0x0750 && char <= 0x077F, + // 'Thaana': (char) => char >= 0x0780 && char <= 0x07BF, + // 'NKo': (char) => char >= 0x07C0 && char <= 0x07FF, + // 'Samaritan': (char) => char >= 0x0800 && char <= 0x083F, + // 'Mandaic': (char) => char >= 0x0840 && char <= 0x085F, + // 'Syriac Supplement': (char) => char >= 0x0860 && char <= 0x086F, + 'Arabic Extended-A': (char) => char >= 0x08A0 && char <= 0x08FF, + // 'Devanagari': (char) => char >= 0x0900 && char <= 0x097F, + // 'Bengali': (char) => char >= 0x0980 && char <= 0x09FF, + // 'Gurmukhi': (char) => char >= 0x0A00 && char <= 0x0A7F, + // 'Gujarati': (char) => char >= 0x0A80 && char <= 0x0AFF, + // 'Oriya': (char) => char >= 0x0B00 && char <= 0x0B7F, + // 'Tamil': (char) => char >= 0x0B80 && char <= 0x0BFF, + // 'Telugu': (char) => char >= 0x0C00 && char <= 0x0C7F, + // 'Kannada': (char) => char >= 0x0C80 && char <= 0x0CFF, + // 'Malayalam': (char) => char >= 0x0D00 && char <= 0x0D7F, + // 'Sinhala': (char) => char >= 0x0D80 && char <= 0x0DFF, + // 'Thai': (char) => char >= 0x0E00 && char <= 0x0E7F, + // 'Lao': (char) => char >= 0x0E80 && char <= 0x0EFF, + // 'Tibetan': (char) => char >= 0x0F00 && char <= 0x0FFF, + // 'Myanmar': (char) => char >= 0x1000 && char <= 0x109F, + // 'Georgian': (char) => char >= 0x10A0 && char <= 0x10FF, + 'Hangul Jamo': (char) => char >= 0x1100 && char <= 0x11FF, + // 'Ethiopic': (char) => char >= 0x1200 && char <= 0x137F, + // 'Ethiopic Supplement': (char) => char >= 0x1380 && char <= 0x139F, + // 'Cherokee': (char) => char >= 0x13A0 && char <= 0x13FF, + 'Unified Canadian Aboriginal Syllabics': (char) => char >= 0x1400 && char <= 0x167F, + // 'Ogham': (char) => char >= 0x1680 && char <= 0x169F, + // 'Runic': (char) => char >= 0x16A0 && char <= 0x16FF, + // 'Tagalog': (char) => char >= 0x1700 && char <= 0x171F, + // 'Hanunoo': (char) => char >= 0x1720 && char <= 0x173F, + // 'Buhid': (char) => char >= 0x1740 && char <= 0x175F, + // 'Tagbanwa': (char) => char >= 0x1760 && char <= 0x177F, + 'Khmer': (char) => char >= 0x1780 && char <= 0x17FF, + // 'Mongolian': (char) => char >= 0x1800 && char <= 0x18AF, + 'Unified Canadian Aboriginal Syllabics Extended': (char) => char >= 0x18B0 && char <= 0x18FF, + // 'Limbu': (char) => char >= 0x1900 && char <= 0x194F, + // 'Tai Le': (char) => char >= 0x1950 && char <= 0x197F, + // 'New Tai Lue': (char) => char >= 0x1980 && char <= 0x19DF, + // 'Khmer Symbols': (char) => char >= 0x19E0 && char <= 0x19FF, + // 'Buginese': (char) => char >= 0x1A00 && char <= 0x1A1F, + // 'Tai Tham': (char) => char >= 0x1A20 && char <= 0x1AAF, + // 'Combining Diacritical Marks Extended': (char) => char >= 0x1AB0 && char <= 0x1AFF, + // 'Balinese': (char) => char >= 0x1B00 && char <= 0x1B7F, + // 'Sundanese': (char) => char >= 0x1B80 && char <= 0x1BBF, + // 'Batak': (char) => char >= 0x1BC0 && char <= 0x1BFF, + // 'Lepcha': (char) => char >= 0x1C00 && char <= 0x1C4F, + // 'Ol Chiki': (char) => char >= 0x1C50 && char <= 0x1C7F, + // 'Cyrillic Extended-C': (char) => char >= 0x1C80 && char <= 0x1C8F, + // 'Georgian Extended': (char) => char >= 0x1C90 && char <= 0x1CBF, + // 'Sundanese Supplement': (char) => char >= 0x1CC0 && char <= 0x1CCF, + // 'Vedic Extensions': (char) => char >= 0x1CD0 && char <= 0x1CFF, + // 'Phonetic Extensions': (char) => char >= 0x1D00 && char <= 0x1D7F, + // 'Phonetic Extensions Supplement': (char) => char >= 0x1D80 && char <= 0x1DBF, + // 'Combining Diacritical Marks Supplement': (char) => char >= 0x1DC0 && char <= 0x1DFF, + // 'Latin Extended Additional': (char) => char >= 0x1E00 && char <= 0x1EFF, + // 'Greek Extended': (char) => char >= 0x1F00 && char <= 0x1FFF, + 'General Punctuation': (char) => char >= 0x2000 && char <= 0x206F, + // 'Superscripts and Subscripts': (char) => char >= 0x2070 && char <= 0x209F, + // 'Currency Symbols': (char) => char >= 0x20A0 && char <= 0x20CF, + // 'Combining Diacritical Marks for Symbols': (char) => char >= 0x20D0 && char <= 0x20FF, + 'Letterlike Symbols': (char) => char >= 0x2100 && char <= 0x214F, + 'Number Forms': (char) => char >= 0x2150 && char <= 0x218F, + // 'Arrows': (char) => char >= 0x2190 && char <= 0x21FF, + // 'Mathematical Operators': (char) => char >= 0x2200 && char <= 0x22FF, + 'Miscellaneous Technical': (char) => char >= 0x2300 && char <= 0x23FF, + 'Control Pictures': (char) => char >= 0x2400 && char <= 0x243F, + 'Optical Character Recognition': (char) => char >= 0x2440 && char <= 0x245F, + 'Enclosed Alphanumerics': (char) => char >= 0x2460 && char <= 0x24FF, + // 'Box Drawing': (char) => char >= 0x2500 && char <= 0x257F, + // 'Block Elements': (char) => char >= 0x2580 && char <= 0x259F, + 'Geometric Shapes': (char) => char >= 0x25A0 && char <= 0x25FF, + 'Miscellaneous Symbols': (char) => char >= 0x2600 && char <= 0x26FF, + // 'Dingbats': (char) => char >= 0x2700 && char <= 0x27BF, + // 'Miscellaneous Mathematical Symbols-A': (char) => char >= 0x27C0 && char <= 0x27EF, + // 'Supplemental Arrows-A': (char) => char >= 0x27F0 && char <= 0x27FF, + // 'Braille Patterns': (char) => char >= 0x2800 && char <= 0x28FF, + // 'Supplemental Arrows-B': (char) => char >= 0x2900 && char <= 0x297F, + // 'Miscellaneous Mathematical Symbols-B': (char) => char >= 0x2980 && char <= 0x29FF, + // 'Supplemental Mathematical Operators': (char) => char >= 0x2A00 && char <= 0x2AFF, + 'Miscellaneous Symbols and Arrows': (char) => char >= 0x2B00 && char <= 0x2BFF, + // 'Glagolitic': (char) => char >= 0x2C00 && char <= 0x2C5F, + // 'Latin Extended-C': (char) => char >= 0x2C60 && char <= 0x2C7F, + // 'Coptic': (char) => char >= 0x2C80 && char <= 0x2CFF, + // 'Georgian Supplement': (char) => char >= 0x2D00 && char <= 0x2D2F, + // 'Tifinagh': (char) => char >= 0x2D30 && char <= 0x2D7F, + // 'Ethiopic Extended': (char) => char >= 0x2D80 && char <= 0x2DDF, + // 'Cyrillic Extended-A': (char) => char >= 0x2DE0 && char <= 0x2DFF, + // 'Supplemental Punctuation': (char) => char >= 0x2E00 && char <= 0x2E7F, + 'CJK Radicals Supplement': (char) => char >= 0x2E80 && char <= 0x2EFF, + 'Kangxi Radicals': (char) => char >= 0x2F00 && char <= 0x2FDF, + 'Ideographic Description Characters': (char) => char >= 0x2FF0 && char <= 0x2FFF, + 'CJK Symbols and Punctuation': (char) => char >= 0x3000 && char <= 0x303F, + 'Hiragana': (char) => char >= 0x3040 && char <= 0x309F, + 'Katakana': (char) => char >= 0x30A0 && char <= 0x30FF, + 'Bopomofo': (char) => char >= 0x3100 && char <= 0x312F, + 'Hangul Compatibility Jamo': (char) => char >= 0x3130 && char <= 0x318F, + 'Kanbun': (char) => char >= 0x3190 && char <= 0x319F, + 'Bopomofo Extended': (char) => char >= 0x31A0 && char <= 0x31BF, + 'CJK Strokes': (char) => char >= 0x31C0 && char <= 0x31EF, + 'Katakana Phonetic Extensions': (char) => char >= 0x31F0 && char <= 0x31FF, + 'Enclosed CJK Letters and Months': (char) => char >= 0x3200 && char <= 0x32FF, + 'CJK Compatibility': (char) => char >= 0x3300 && char <= 0x33FF, + 'CJK Unified Ideographs Extension A': (char) => char >= 0x3400 && char <= 0x4DBF, + 'Yijing Hexagram Symbols': (char) => char >= 0x4DC0 && char <= 0x4DFF, + 'CJK Unified Ideographs': (char) => char >= 0x4E00 && char <= 0x9FFF, + 'Yi Syllables': (char) => char >= 0xA000 && char <= 0xA48F, + 'Yi Radicals': (char) => char >= 0xA490 && char <= 0xA4CF, + // 'Lisu': (char) => char >= 0xA4D0 && char <= 0xA4FF, + // 'Vai': (char) => char >= 0xA500 && char <= 0xA63F, + // 'Cyrillic Extended-B': (char) => char >= 0xA640 && char <= 0xA69F, + // 'Bamum': (char) => char >= 0xA6A0 && char <= 0xA6FF, + // 'Modifier Tone Letters': (char) => char >= 0xA700 && char <= 0xA71F, + // 'Latin Extended-D': (char) => char >= 0xA720 && char <= 0xA7FF, + // 'Syloti Nagri': (char) => char >= 0xA800 && char <= 0xA82F, + // 'Common Indic Number Forms': (char) => char >= 0xA830 && char <= 0xA83F, + // 'Phags-pa': (char) => char >= 0xA840 && char <= 0xA87F, + // 'Saurashtra': (char) => char >= 0xA880 && char <= 0xA8DF, + // 'Devanagari Extended': (char) => char >= 0xA8E0 && char <= 0xA8FF, + // 'Kayah Li': (char) => char >= 0xA900 && char <= 0xA92F, + // 'Rejang': (char) => char >= 0xA930 && char <= 0xA95F, + 'Hangul Jamo Extended-A': (char) => char >= 0xA960 && char <= 0xA97F, + // 'Javanese': (char) => char >= 0xA980 && char <= 0xA9DF, + // 'Myanmar Extended-B': (char) => char >= 0xA9E0 && char <= 0xA9FF, + // 'Cham': (char) => char >= 0xAA00 && char <= 0xAA5F, + // 'Myanmar Extended-A': (char) => char >= 0xAA60 && char <= 0xAA7F, + // 'Tai Viet': (char) => char >= 0xAA80 && char <= 0xAADF, + // 'Meetei Mayek Extensions': (char) => char >= 0xAAE0 && char <= 0xAAFF, + // 'Ethiopic Extended-A': (char) => char >= 0xAB00 && char <= 0xAB2F, + // 'Latin Extended-E': (char) => char >= 0xAB30 && char <= 0xAB6F, + // 'Cherokee Supplement': (char) => char >= 0xAB70 && char <= 0xABBF, + // 'Meetei Mayek': (char) => char >= 0xABC0 && char <= 0xABFF, + 'Hangul Syllables': (char) => char >= 0xAC00 && char <= 0xD7AF, + 'Hangul Jamo Extended-B': (char) => char >= 0xD7B0 && char <= 0xD7FF, + // 'High Surrogates': (char) => char >= 0xD800 && char <= 0xDB7F, + // 'High Private Use Surrogates': (char) => char >= 0xDB80 && char <= 0xDBFF, + // 'Low Surrogates': (char) => char >= 0xDC00 && char <= 0xDFFF, + 'Private Use Area': (char) => char >= 0xE000 && char <= 0xF8FF, + 'CJK Compatibility Ideographs': (char) => char >= 0xF900 && char <= 0xFAFF, + // 'Alphabetic Presentation Forms': (char) => char >= 0xFB00 && char <= 0xFB4F, + 'Arabic Presentation Forms-A': (char) => char >= 0xFB50 && char <= 0xFDFF, + // 'Variation Selectors': (char) => char >= 0xFE00 && char <= 0xFE0F, + 'Vertical Forms': (char) => char >= 0xFE10 && char <= 0xFE1F, + // 'Combining Half Marks': (char) => char >= 0xFE20 && char <= 0xFE2F, + 'CJK Compatibility Forms': (char) => char >= 0xFE30 && char <= 0xFE4F, + 'Small Form Variants': (char) => char >= 0xFE50 && char <= 0xFE6F, + 'Arabic Presentation Forms-B': (char) => char >= 0xFE70 && char <= 0xFEFF, + 'Halfwidth and Fullwidth Forms': (char) => char >= 0xFF00 && char <= 0xFFEF + // 'Specials': (char) => char >= 0xFFF0 && char <= 0xFFFF, + // 'Linear B Syllabary': (char) => char >= 0x10000 && char <= 0x1007F, + // 'Linear B Ideograms': (char) => char >= 0x10080 && char <= 0x100FF, + // 'Aegean Numbers': (char) => char >= 0x10100 && char <= 0x1013F, + // 'Ancient Greek Numbers': (char) => char >= 0x10140 && char <= 0x1018F, + // 'Ancient Symbols': (char) => char >= 0x10190 && char <= 0x101CF, + // 'Phaistos Disc': (char) => char >= 0x101D0 && char <= 0x101FF, + // 'Lycian': (char) => char >= 0x10280 && char <= 0x1029F, + // 'Carian': (char) => char >= 0x102A0 && char <= 0x102DF, + // 'Coptic Epact Numbers': (char) => char >= 0x102E0 && char <= 0x102FF, + // 'Old Italic': (char) => char >= 0x10300 && char <= 0x1032F, + // 'Gothic': (char) => char >= 0x10330 && char <= 0x1034F, + // 'Old Permic': (char) => char >= 0x10350 && char <= 0x1037F, + // 'Ugaritic': (char) => char >= 0x10380 && char <= 0x1039F, + // 'Old Persian': (char) => char >= 0x103A0 && char <= 0x103DF, + // 'Deseret': (char) => char >= 0x10400 && char <= 0x1044F, + // 'Shavian': (char) => char >= 0x10450 && char <= 0x1047F, + // 'Osmanya': (char) => char >= 0x10480 && char <= 0x104AF, + // 'Osage': (char) => char >= 0x104B0 && char <= 0x104FF, + // 'Elbasan': (char) => char >= 0x10500 && char <= 0x1052F, + // 'Caucasian Albanian': (char) => char >= 0x10530 && char <= 0x1056F, + // 'Linear A': (char) => char >= 0x10600 && char <= 0x1077F, + // 'Cypriot Syllabary': (char) => char >= 0x10800 && char <= 0x1083F, + // 'Imperial Aramaic': (char) => char >= 0x10840 && char <= 0x1085F, + // 'Palmyrene': (char) => char >= 0x10860 && char <= 0x1087F, + // 'Nabataean': (char) => char >= 0x10880 && char <= 0x108AF, + // 'Hatran': (char) => char >= 0x108E0 && char <= 0x108FF, + // 'Phoenician': (char) => char >= 0x10900 && char <= 0x1091F, + // 'Lydian': (char) => char >= 0x10920 && char <= 0x1093F, + // 'Meroitic Hieroglyphs': (char) => char >= 0x10980 && char <= 0x1099F, + // 'Meroitic Cursive': (char) => char >= 0x109A0 && char <= 0x109FF, + // 'Kharoshthi': (char) => char >= 0x10A00 && char <= 0x10A5F, + // 'Old South Arabian': (char) => char >= 0x10A60 && char <= 0x10A7F, + // 'Old North Arabian': (char) => char >= 0x10A80 && char <= 0x10A9F, + // 'Manichaean': (char) => char >= 0x10AC0 && char <= 0x10AFF, + // 'Avestan': (char) => char >= 0x10B00 && char <= 0x10B3F, + // 'Inscriptional Parthian': (char) => char >= 0x10B40 && char <= 0x10B5F, + // 'Inscriptional Pahlavi': (char) => char >= 0x10B60 && char <= 0x10B7F, + // 'Psalter Pahlavi': (char) => char >= 0x10B80 && char <= 0x10BAF, + // 'Old Turkic': (char) => char >= 0x10C00 && char <= 0x10C4F, + // 'Old Hungarian': (char) => char >= 0x10C80 && char <= 0x10CFF, + // 'Hanifi Rohingya': (char) => char >= 0x10D00 && char <= 0x10D3F, + // 'Rumi Numeral Symbols': (char) => char >= 0x10E60 && char <= 0x10E7F, + // 'Old Sogdian': (char) => char >= 0x10F00 && char <= 0x10F2F, + // 'Sogdian': (char) => char >= 0x10F30 && char <= 0x10F6F, + // 'Elymaic': (char) => char >= 0x10FE0 && char <= 0x10FFF, + // 'Brahmi': (char) => char >= 0x11000 && char <= 0x1107F, + // 'Kaithi': (char) => char >= 0x11080 && char <= 0x110CF, + // 'Sora Sompeng': (char) => char >= 0x110D0 && char <= 0x110FF, + // 'Chakma': (char) => char >= 0x11100 && char <= 0x1114F, + // 'Mahajani': (char) => char >= 0x11150 && char <= 0x1117F, + // 'Sharada': (char) => char >= 0x11180 && char <= 0x111DF, + // 'Sinhala Archaic Numbers': (char) => char >= 0x111E0 && char <= 0x111FF, + // 'Khojki': (char) => char >= 0x11200 && char <= 0x1124F, + // 'Multani': (char) => char >= 0x11280 && char <= 0x112AF, + // 'Khudawadi': (char) => char >= 0x112B0 && char <= 0x112FF, + // 'Grantha': (char) => char >= 0x11300 && char <= 0x1137F, + // 'Newa': (char) => char >= 0x11400 && char <= 0x1147F, + // 'Tirhuta': (char) => char >= 0x11480 && char <= 0x114DF, + // 'Siddham': (char) => char >= 0x11580 && char <= 0x115FF, + // 'Modi': (char) => char >= 0x11600 && char <= 0x1165F, + // 'Mongolian Supplement': (char) => char >= 0x11660 && char <= 0x1167F, + // 'Takri': (char) => char >= 0x11680 && char <= 0x116CF, + // 'Ahom': (char) => char >= 0x11700 && char <= 0x1173F, + // 'Dogra': (char) => char >= 0x11800 && char <= 0x1184F, + // 'Warang Citi': (char) => char >= 0x118A0 && char <= 0x118FF, + // 'Nandinagari': (char) => char >= 0x119A0 && char <= 0x119FF, + // 'Zanabazar Square': (char) => char >= 0x11A00 && char <= 0x11A4F, + // 'Soyombo': (char) => char >= 0x11A50 && char <= 0x11AAF, + // 'Pau Cin Hau': (char) => char >= 0x11AC0 && char <= 0x11AFF, + // 'Bhaiksuki': (char) => char >= 0x11C00 && char <= 0x11C6F, + // 'Marchen': (char) => char >= 0x11C70 && char <= 0x11CBF, + // 'Masaram Gondi': (char) => char >= 0x11D00 && char <= 0x11D5F, + // 'Gunjala Gondi': (char) => char >= 0x11D60 && char <= 0x11DAF, + // 'Makasar': (char) => char >= 0x11EE0 && char <= 0x11EFF, + // 'Tamil Supplement': (char) => char >= 0x11FC0 && char <= 0x11FFF, + // 'Cuneiform': (char) => char >= 0x12000 && char <= 0x123FF, + // 'Cuneiform Numbers and Punctuation': (char) => char >= 0x12400 && char <= 0x1247F, + // 'Early Dynastic Cuneiform': (char) => char >= 0x12480 && char <= 0x1254F, + // 'Egyptian Hieroglyphs': (char) => char >= 0x13000 && char <= 0x1342F, + // 'Egyptian Hieroglyph Format Controls': (char) => char >= 0x13430 && char <= 0x1343F, + // 'Anatolian Hieroglyphs': (char) => char >= 0x14400 && char <= 0x1467F, + // 'Bamum Supplement': (char) => char >= 0x16800 && char <= 0x16A3F, + // 'Mro': (char) => char >= 0x16A40 && char <= 0x16A6F, + // 'Bassa Vah': (char) => char >= 0x16AD0 && char <= 0x16AFF, + // 'Pahawh Hmong': (char) => char >= 0x16B00 && char <= 0x16B8F, + // 'Medefaidrin': (char) => char >= 0x16E40 && char <= 0x16E9F, + // 'Miao': (char) => char >= 0x16F00 && char <= 0x16F9F, + // 'Ideographic Symbols and Punctuation': (char) => char >= 0x16FE0 && char <= 0x16FFF, + // 'Tangut': (char) => char >= 0x17000 && char <= 0x187FF, + // 'Tangut Components': (char) => char >= 0x18800 && char <= 0x18AFF, + // 'Kana Supplement': (char) => char >= 0x1B000 && char <= 0x1B0FF, + // 'Kana Extended-A': (char) => char >= 0x1B100 && char <= 0x1B12F, + // 'Small Kana Extension': (char) => char >= 0x1B130 && char <= 0x1B16F, + // 'Nushu': (char) => char >= 0x1B170 && char <= 0x1B2FF, + // 'Duployan': (char) => char >= 0x1BC00 && char <= 0x1BC9F, + // 'Shorthand Format Controls': (char) => char >= 0x1BCA0 && char <= 0x1BCAF, + // 'Byzantine Musical Symbols': (char) => char >= 0x1D000 && char <= 0x1D0FF, + // 'Musical Symbols': (char) => char >= 0x1D100 && char <= 0x1D1FF, + // 'Ancient Greek Musical Notation': (char) => char >= 0x1D200 && char <= 0x1D24F, + // 'Mayan Numerals': (char) => char >= 0x1D2E0 && char <= 0x1D2FF, + // 'Tai Xuan Jing Symbols': (char) => char >= 0x1D300 && char <= 0x1D35F, + // 'Counting Rod Numerals': (char) => char >= 0x1D360 && char <= 0x1D37F, + // 'Mathematical Alphanumeric Symbols': (char) => char >= 0x1D400 && char <= 0x1D7FF, + // 'Sutton SignWriting': (char) => char >= 0x1D800 && char <= 0x1DAAF, + // 'Glagolitic Supplement': (char) => char >= 0x1E000 && char <= 0x1E02F, + // 'Nyiakeng Puachue Hmong': (char) => char >= 0x1E100 && char <= 0x1E14F, + // 'Wancho': (char) => char >= 0x1E2C0 && char <= 0x1E2FF, + // 'Mende Kikakui': (char) => char >= 0x1E800 && char <= 0x1E8DF, + // 'Adlam': (char) => char >= 0x1E900 && char <= 0x1E95F, + // 'Indic Siyaq Numbers': (char) => char >= 0x1EC70 && char <= 0x1ECBF, + // 'Ottoman Siyaq Numbers': (char) => char >= 0x1ED00 && char <= 0x1ED4F, + // 'Arabic Mathematical Alphabetic Symbols': (char) => char >= 0x1EE00 && char <= 0x1EEFF, + // 'Mahjong Tiles': (char) => char >= 0x1F000 && char <= 0x1F02F, + // 'Domino Tiles': (char) => char >= 0x1F030 && char <= 0x1F09F, + // 'Playing Cards': (char) => char >= 0x1F0A0 && char <= 0x1F0FF, + // 'Enclosed Alphanumeric Supplement': (char) => char >= 0x1F100 && char <= 0x1F1FF, + // 'Enclosed Ideographic Supplement': (char) => char >= 0x1F200 && char <= 0x1F2FF, + // 'Miscellaneous Symbols and Pictographs': (char) => char >= 0x1F300 && char <= 0x1F5FF, + // 'Emoticons': (char) => char >= 0x1F600 && char <= 0x1F64F, + // 'Ornamental Dingbats': (char) => char >= 0x1F650 && char <= 0x1F67F, + // 'Transport and Map Symbols': (char) => char >= 0x1F680 && char <= 0x1F6FF, + // 'Alchemical Symbols': (char) => char >= 0x1F700 && char <= 0x1F77F, + // 'Geometric Shapes Extended': (char) => char >= 0x1F780 && char <= 0x1F7FF, + // 'Supplemental Arrows-C': (char) => char >= 0x1F800 && char <= 0x1F8FF, + // 'Supplemental Symbols and Pictographs': (char) => char >= 0x1F900 && char <= 0x1F9FF, + // 'Chess Symbols': (char) => char >= 0x1FA00 && char <= 0x1FA6F, + // 'Symbols and Pictographs Extended-A': (char) => char >= 0x1FA70 && char <= 0x1FAFF, + // 'CJK Unified Ideographs Extension B': (char) => char >= 0x20000 && char <= 0x2A6DF, + // 'CJK Unified Ideographs Extension C': (char) => char >= 0x2A700 && char <= 0x2B73F, + // 'CJK Unified Ideographs Extension D': (char) => char >= 0x2B740 && char <= 0x2B81F, + // 'CJK Unified Ideographs Extension E': (char) => char >= 0x2B820 && char <= 0x2CEAF, + // 'CJK Unified Ideographs Extension F': (char) => char >= 0x2CEB0 && char <= 0x2EBEF, + // 'CJK Compatibility Ideographs Supplement': (char) => char >= 0x2F800 && char <= 0x2FA1F, + // 'Tags': (char) => char >= 0xE0000 && char <= 0xE007F, + // 'Variation Selectors Supplement': (char) => char >= 0xE0100 && char <= 0xE01EF, + // 'Supplementary Private Use Area-A': (char) => char >= 0xF0000 && char <= 0xFFFFF, + // 'Supplementary Private Use Area-B': (char) => char >= 0x100000 && char <= 0x10FFFF, +}; + +/* eslint-disable new-cap */ +function allowsIdeographicBreaking(chars) { + for (const char of chars) { + if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) + return false; + } + return true; +} +function allowsVerticalWritingMode(chars) { + for (const char of chars) { + if (charHasUprightVerticalOrientation(char.charCodeAt(0))) + return true; + } + return false; +} +function allowsLetterSpacing(chars) { + for (const char of chars) { + if (!charAllowsLetterSpacing(char.charCodeAt(0))) + return false; + } + return true; +} +function charAllowsLetterSpacing(char) { + if (unicodeBlockLookup['Arabic'](char)) + return false; + if (unicodeBlockLookup['Arabic Supplement'](char)) + return false; + if (unicodeBlockLookup['Arabic Extended-A'](char)) + return false; + if (unicodeBlockLookup['Arabic Presentation Forms-A'](char)) + return false; + if (unicodeBlockLookup['Arabic Presentation Forms-B'](char)) + return false; + return true; +} +function charAllowsIdeographicBreaking(char) { + // Return early for characters outside all ideographic ranges. + if (char < 0x2E80) + return false; + if (unicodeBlockLookup['Bopomofo Extended'](char)) + return true; + if (unicodeBlockLookup['Bopomofo'](char)) + return true; + if (unicodeBlockLookup['CJK Compatibility Forms'](char)) + return true; + if (unicodeBlockLookup['CJK Compatibility Ideographs'](char)) + return true; + if (unicodeBlockLookup['CJK Compatibility'](char)) + return true; + if (unicodeBlockLookup['CJK Radicals Supplement'](char)) + return true; + if (unicodeBlockLookup['CJK Strokes'](char)) + return true; + if (unicodeBlockLookup['CJK Symbols and Punctuation'](char)) + return true; + if (unicodeBlockLookup['CJK Unified Ideographs Extension A'](char)) + return true; + if (unicodeBlockLookup['CJK Unified Ideographs'](char)) + return true; + if (unicodeBlockLookup['Enclosed CJK Letters and Months'](char)) + return true; + if (unicodeBlockLookup['Halfwidth and Fullwidth Forms'](char)) + return true; + if (unicodeBlockLookup['Hiragana'](char)) + return true; + if (unicodeBlockLookup['Ideographic Description Characters'](char)) + return true; + if (unicodeBlockLookup['Kangxi Radicals'](char)) + return true; + if (unicodeBlockLookup['Katakana Phonetic Extensions'](char)) + return true; + if (unicodeBlockLookup['Katakana'](char)) + return true; + if (unicodeBlockLookup['Vertical Forms'](char)) + return true; + if (unicodeBlockLookup['Yi Radicals'](char)) + return true; + if (unicodeBlockLookup['Yi Syllables'](char)) + return true; + return false; +} +// The following logic comes from +// . +// Keep it synchronized with +// . +// The data file denotes with “U” or “Tu” any codepoint that may be drawn +// upright in vertical text but does not distinguish between upright and +// “neutral” characters. +// Blocks in the Unicode supplementary planes are excluded from this module due +// to . +/** + * Returns true if the given Unicode codepoint identifies a character with + * upright orientation. + * + * A character has upright orientation if it is drawn upright (unrotated) + * whether the line is oriented horizontally or vertically, even if both + * adjacent characters can be rotated. For example, a Chinese character is + * always drawn upright. An uprightly oriented character causes an adjacent + * “neutral” character to be drawn upright as well. + */ +function charHasUprightVerticalOrientation(char) { + if (char === 0x02EA /* modifier letter yin departing tone mark */ || + char === 0x02EB /* modifier letter yang departing tone mark */) { + return true; + } + // Return early for characters outside all ranges whose characters remain + // upright in vertical writing mode. + if (char < 0x1100) + return false; + if (unicodeBlockLookup['Bopomofo Extended'](char)) + return true; + if (unicodeBlockLookup['Bopomofo'](char)) + return true; + if (unicodeBlockLookup['CJK Compatibility Forms'](char)) { + if (!((char >= 0xFE49 /* dashed overline */ && char <= 0xFE4F) /* wavy low line */)) { + return true; + } + } + if (unicodeBlockLookup['CJK Compatibility Ideographs'](char)) + return true; + if (unicodeBlockLookup['CJK Compatibility'](char)) + return true; + if (unicodeBlockLookup['CJK Radicals Supplement'](char)) + return true; + if (unicodeBlockLookup['CJK Strokes'](char)) + return true; + if (unicodeBlockLookup['CJK Symbols and Punctuation'](char)) { + if (!((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) && + !((char >= 0x3014 /* left tortoise shell bracket */ && char <= 0x301F) /* low double prime quotation mark */) && + char !== 0x3030 /* wavy dash */) { + return true; + } + } + if (unicodeBlockLookup['CJK Unified Ideographs Extension A'](char)) + return true; + if (unicodeBlockLookup['CJK Unified Ideographs'](char)) + return true; + if (unicodeBlockLookup['Enclosed CJK Letters and Months'](char)) + return true; + if (unicodeBlockLookup['Hangul Compatibility Jamo'](char)) + return true; + if (unicodeBlockLookup['Hangul Jamo Extended-A'](char)) + return true; + if (unicodeBlockLookup['Hangul Jamo Extended-B'](char)) + return true; + if (unicodeBlockLookup['Hangul Jamo'](char)) + return true; + if (unicodeBlockLookup['Hangul Syllables'](char)) + return true; + if (unicodeBlockLookup['Hiragana'](char)) + return true; + if (unicodeBlockLookup['Ideographic Description Characters'](char)) + return true; + if (unicodeBlockLookup['Kanbun'](char)) + return true; + if (unicodeBlockLookup['Kangxi Radicals'](char)) + return true; + if (unicodeBlockLookup['Katakana Phonetic Extensions'](char)) + return true; + if (unicodeBlockLookup['Katakana'](char)) { + if (char !== 0x30FC /* katakana-hiragana prolonged sound mark */) { + return true; + } + } + if (unicodeBlockLookup['Halfwidth and Fullwidth Forms'](char)) { + if (char !== 0xFF08 /* fullwidth left parenthesis */ && + char !== 0xFF09 /* fullwidth right parenthesis */ && + char !== 0xFF0D /* fullwidth hyphen-minus */ && + !((char >= 0xFF1A /* fullwidth colon */ && char <= 0xFF1E) /* fullwidth greater-than sign */) && + char !== 0xFF3B /* fullwidth left square bracket */ && + char !== 0xFF3D /* fullwidth right square bracket */ && + char !== 0xFF3F /* fullwidth low line */ && + !(char >= 0xFF5B /* fullwidth left curly bracket */ && char <= 0xFFDF) && + char !== 0xFFE3 /* fullwidth macron */ && + !(char >= 0xFFE8 /* halfwidth forms light vertical */ && char <= 0xFFEF)) { + return true; + } + } + if (unicodeBlockLookup['Small Form Variants'](char)) { + if (!((char >= 0xFE58 /* small em dash */ && char <= 0xFE5E) /* small right tortoise shell bracket */) && + !((char >= 0xFE63 /* small hyphen-minus */ && char <= 0xFE66) /* small equals sign */)) { + return true; + } + } + if (unicodeBlockLookup['Unified Canadian Aboriginal Syllabics'](char)) + return true; + if (unicodeBlockLookup['Unified Canadian Aboriginal Syllabics Extended'](char)) + return true; + if (unicodeBlockLookup['Vertical Forms'](char)) + return true; + if (unicodeBlockLookup['Yijing Hexagram Symbols'](char)) + return true; + if (unicodeBlockLookup['Yi Syllables'](char)) + return true; + if (unicodeBlockLookup['Yi Radicals'](char)) + return true; + return false; +} +/** + * Returns true if the given Unicode codepoint identifies a character with + * neutral orientation. + * + * A character has neutral orientation if it may be drawn rotated or unrotated + * when the line is oriented vertically, depending on the orientation of the + * adjacent characters. For example, along a verticlly oriented line, the vulgar + * fraction ½ is drawn upright among Chinese characters but rotated among Latin + * letters. A neutrally oriented character does not influence whether an + * adjacent character is drawn upright or rotated. + */ +function charHasNeutralVerticalOrientation(char) { + if (unicodeBlockLookup['Latin-1 Supplement'](char)) { + if (char === 0x00A7 /* section sign */ || + char === 0x00A9 /* copyright sign */ || + char === 0x00AE /* registered sign */ || + char === 0x00B1 /* plus-minus sign */ || + char === 0x00BC /* vulgar fraction one quarter */ || + char === 0x00BD /* vulgar fraction one half */ || + char === 0x00BE /* vulgar fraction three quarters */ || + char === 0x00D7 /* multiplication sign */ || + char === 0x00F7 /* division sign */) { + return true; + } + } + if (unicodeBlockLookup['General Punctuation'](char)) { + if (char === 0x2016 /* double vertical line */ || + char === 0x2020 /* dagger */ || + char === 0x2021 /* double dagger */ || + char === 0x2030 /* per mille sign */ || + char === 0x2031 /* per ten thousand sign */ || + char === 0x203B /* reference mark */ || + char === 0x203C /* double exclamation mark */ || + char === 0x2042 /* asterism */ || + char === 0x2047 /* double question mark */ || + char === 0x2048 /* question exclamation mark */ || + char === 0x2049 /* exclamation question mark */ || + char === 0x2051 /* two asterisks aligned vertically */) { + return true; + } + } + if (unicodeBlockLookup['Letterlike Symbols'](char)) + return true; + if (unicodeBlockLookup['Number Forms'](char)) + return true; + if (unicodeBlockLookup['Miscellaneous Technical'](char)) { + if ((char >= 0x2300 /* diameter sign */ && char <= 0x2307 /* wavy line */) || + (char >= 0x230C /* bottom right crop */ && char <= 0x231F /* bottom right corner */) || + (char >= 0x2324 /* up arrowhead between two horizontal bars */ && char <= 0x2328 /* keyboard */) || + char === 0x232B /* erase to the left */ || + (char >= 0x237D /* shouldered open box */ && char <= 0x239A /* clear screen symbol */) || + (char >= 0x23BE /* dentistry symbol light vertical and top right */ && char <= 0x23CD /* square foot */) || + char === 0x23CF /* eject symbol */ || + (char >= 0x23D1 /* metrical breve */ && char <= 0x23DB /* fuse */) || + (char >= 0x23E2 /* white trapezium */ && char <= 0x23FF)) { + return true; + } + } + if (unicodeBlockLookup['Control Pictures'](char) && char !== 0x2423 /* open box */) + return true; + if (unicodeBlockLookup['Optical Character Recognition'](char)) + return true; + if (unicodeBlockLookup['Enclosed Alphanumerics'](char)) + return true; + if (unicodeBlockLookup['Geometric Shapes'](char)) + return true; + if (unicodeBlockLookup['Miscellaneous Symbols'](char)) { + if (!((char >= 0x261A /* black left pointing index */ && char <= 0x261F) /* white down pointing index */)) { + return true; + } + } + if (unicodeBlockLookup['Miscellaneous Symbols and Arrows'](char)) { + if ((char >= 0x2B12 /* square with top half black */ && char <= 0x2B2F /* white vertical ellipse */) || + (char >= 0x2B50 /* white medium star */ && char <= 0x2B59 /* heavy circled saltire */) || + (char >= 0x2BB8 /* upwards white arrow from bar with horizontal bar */ && char <= 0x2BEB)) { + return true; + } + } + if (unicodeBlockLookup['CJK Symbols and Punctuation'](char)) + return true; + if (unicodeBlockLookup['Katakana'](char)) + return true; + if (unicodeBlockLookup['Private Use Area'](char)) + return true; + if (unicodeBlockLookup['CJK Compatibility Forms'](char)) + return true; + if (unicodeBlockLookup['Small Form Variants'](char)) + return true; + if (unicodeBlockLookup['Halfwidth and Fullwidth Forms'](char)) + return true; + if (char === 0x221E /* infinity */ || + char === 0x2234 /* therefore */ || + char === 0x2235 /* because */ || + (char >= 0x2700 /* black safety scissors */ && char <= 0x2767 /* rotated floral heart bullet */) || + (char >= 0x2776 /* dingbat negative circled digit one */ && char <= 0x2793 /* dingbat negative circled sans-serif number ten */) || + char === 0xFFFC /* object replacement character */ || + char === 0xFFFD /* replacement character */) { + return true; + } + return false; +} +/** + * Returns true if the given Unicode codepoint identifies a character with + * rotated orientation. + * + * A character has rotated orientation if it is drawn rotated when the line is + * oriented vertically, even if both adjacent characters are upright. For + * example, a Latin letter is drawn rotated along a vertical line. A rotated + * character causes an adjacent “neutral” character to be drawn rotated as well. + */ +function charHasRotatedVerticalOrientation(char) { + return !(charHasUprightVerticalOrientation(char) || + charHasNeutralVerticalOrientation(char)); +} +function charInComplexShapingScript(char) { + return unicodeBlockLookup['Arabic'](char) || + unicodeBlockLookup['Arabic Supplement'](char) || + unicodeBlockLookup['Arabic Extended-A'](char) || + unicodeBlockLookup['Arabic Presentation Forms-A'](char) || + unicodeBlockLookup['Arabic Presentation Forms-B'](char); +} +function charInRTLScript(char) { + // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts + return (char >= 0x0590 && char <= 0x08FF) || + unicodeBlockLookup['Arabic Presentation Forms-A'](char) || + unicodeBlockLookup['Arabic Presentation Forms-B'](char); +} +function charInSupportedScript(char, canRenderRTL) { + // This is a rough heuristic: whether we "can render" a script + // actually depends on the properties of the font being used + // and whether differences from the ideal rendering are considered + // semantically significant. + // Even in Latin script, we "can't render" combinations such as the fi + // ligature, but we don't consider that semantically significant. + if (!canRenderRTL && charInRTLScript(char)) { + return false; + } + if ((char >= 0x0900 && char <= 0x0DFF) || + // Main blocks for Indic scripts and Sinhala + (char >= 0x0F00 && char <= 0x109F) || + // Main blocks for Tibetan and Myanmar + unicodeBlockLookup['Khmer'](char)) { + // These blocks cover common scripts that require + // complex text shaping, based on unicode script metadata: + // http://www.unicode.org/repos/cldr/trunk/common/properties/scriptMetadata.txt + // where "Web Rank <= 32" "Shaping Required = YES" + return false; + } + return true; +} +function stringContainsRTLText(chars) { + for (const char of chars) { + if (charInRTLScript(char.charCodeAt(0))) { + return true; + } + } + return false; +} +function isStringInSupportedScript(chars, canRenderRTL) { + for (const char of chars) { + if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) { + return false; + } + } + return true; +} + +const status = { + unavailable: 'unavailable', + deferred: 'deferred', + loading: 'loading', + loaded: 'loaded', + error: 'error' +}; +let _completionCallback = null; +//Variables defining the current state of the plugin +let pluginStatus = status.unavailable; +let pluginURL = null; +const triggerPluginCompletionEvent = function (error) { + // NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin + if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) { + pluginStatus = status.error; + } + if (_completionCallback) { + _completionCallback(error); + } +}; +function sendPluginStateToWorker() { + evented.fire(new Event('pluginStateChange', { pluginStatus, pluginURL })); +} +const evented = new Evented(); +const getRTLTextPluginStatus = function () { + return pluginStatus; +}; +const registerForPluginStateChange = function (callback) { + // Do an initial sync of the state + callback({ pluginStatus, pluginURL }); + // Listen for all future state changes + evented.on('pluginStateChange', callback); + return callback; +}; +const clearRTLTextPlugin = function () { + pluginStatus = status.unavailable; + pluginURL = null; + _completionCallback = null; +}; +const setRTLTextPlugin = function (url, callback, deferred = false) { + if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) { + throw new Error('setRTLTextPlugin cannot be called multiple times.'); + } + pluginURL = browser.resolveURL(url); + pluginStatus = status.deferred; + _completionCallback = callback; + sendPluginStateToWorker(); + //Start downloading the plugin immediately if not intending to lazy-load + if (!deferred) { + downloadRTLTextPlugin(); + } +}; +const downloadRTLTextPlugin = function () { + if (pluginStatus !== status.deferred || !pluginURL) { + throw new Error('rtl-text-plugin cannot be downloaded unless a pluginURL is specified'); + } + pluginStatus = status.loading; + sendPluginStateToWorker(); + if (pluginURL) { + getArrayBuffer({ url: pluginURL }, (error) => { + if (error) { + triggerPluginCompletionEvent(error); + } + else { + pluginStatus = status.loaded; + sendPluginStateToWorker(); + } + }); + } +}; +const plugin = { + applyArabicShaping: null, + processBidirectionalText: null, + processStyledBidirectionalText: null, + isLoaded() { + return pluginStatus === status.loaded || // Main Thread: loaded if the completion callback returned successfully + plugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled + }, + isLoading() { + return pluginStatus === status.loading; + }, + setState(state) { + if (!isWorker()) + throw new Error('Cannot set the state of the rtl-text-plugin when not in the web-worker context'); + pluginStatus = state.pluginStatus; + pluginURL = state.pluginURL; + }, + isParsed() { + if (!isWorker()) + throw new Error('rtl-text-plugin is only parsed on the worker-threads'); + return plugin.applyArabicShaping != null && + plugin.processBidirectionalText != null && + plugin.processStyledBidirectionalText != null; + }, + getPluginURL() { + if (!isWorker()) + throw new Error('rtl-text-plugin url can only be queried from the worker threads'); + return pluginURL; + } +}; +const lazyLoadRTLTextPlugin = function () { + if (!plugin.isLoading() && + !plugin.isLoaded() && + getRTLTextPluginStatus() === 'deferred') { + downloadRTLTextPlugin(); + } +}; + +/** + * @internal + * A parameter that can be evaluated to a value + */ +class EvaluationParameters { + // "options" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate + constructor(zoom, options) { + this.zoom = zoom; + if (options) { + this.now = options.now; + this.fadeDuration = options.fadeDuration; + this.zoomHistory = options.zoomHistory; + this.transition = options.transition; + } + else { + this.now = 0; + this.fadeDuration = 0; + this.zoomHistory = new ZoomHistory(); + this.transition = {}; + } + } + isSupportedScript(str) { + return isStringInSupportedScript(str, plugin.isLoaded()); + } + crossFadingFactor() { + if (this.fadeDuration === 0) { + return 1; + } + else { + return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1); + } + } + getCrossfadeParameters() { + const z = this.zoom; + const fraction = z - Math.floor(z); + const t = this.crossFadingFactor(); + return z > this.zoomHistory.lastIntegerZoom ? + { fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t } : + { fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction }; + } +} + +/** + * @internal + * `PropertyValue` represents the value part of a property key-value unit. It's used to represent both + * paint and layout property values, and regardless of whether or not their property supports data-driven + * expressions. + * + * `PropertyValue` stores the raw input value as seen in a style or a runtime styling API call, i.e. one of the + * following: + * + * * A constant value of the type appropriate for the property + * * A function which produces a value of that type (but functions are quasi-deprecated in favor of expressions) + * * An expression which produces a value of that type + * * "undefined"/"not present", in which case the property is assumed to take on its default value. + * + * In addition to storing the original input value, `PropertyValue` also stores a normalized representation, + * effectively treating functions as if they are expressions, and constant or default values as if they are + * (constant) expressions. + */ +class PropertyValue { + constructor(property, value) { + this.property = property; + this.value = value; + this.expression = normalizePropertyExpression(value === undefined ? property.specification.default : value, property.specification); + } + isDataDriven() { + return this.expression.kind === 'source' || this.expression.kind === 'composite'; + } + possiblyEvaluate(parameters, canonical, availableImages) { + return this.property.possiblyEvaluate(this, parameters, canonical, availableImages); + } +} +/** + * @internal + * Paint properties are _transitionable_: they can change in a fluid manner, interpolating or cross-fading between + * old and new value. The duration of the transition, and the delay before it begins, is configurable. + * + * `TransitionablePropertyValue` is a compositional class that stores both the property value and that transition + * configuration. + * + * A `TransitionablePropertyValue` can calculate the next step in the evaluation chain for paint property values: + * `TransitioningPropertyValue`. + */ +class TransitionablePropertyValue { + constructor(property) { + this.property = property; + this.value = new PropertyValue(property, undefined); + } + transitioned(parameters, prior) { + return new TransitioningPropertyValue(this.property, this.value, prior, extend({}, parameters.transition, this.transition), parameters.now); + } + untransitioned() { + return new TransitioningPropertyValue(this.property, this.value, null, {}, 0); + } +} +/** + * @internal + * `Transitionable` stores a map of all (property name, `TransitionablePropertyValue`) pairs for paint properties of a + * given layer type. It can calculate the `TransitioningPropertyValue`s for all of them at once, producing a + * `Transitioning` instance for the same set of properties. + */ +class Transitionable { + constructor(properties) { + this._properties = properties; + this._values = Object.create(properties.defaultTransitionablePropertyValues); + } + getValue(name) { + return clone$9(this._values[name].value.value); + } + setValue(name, value) { + if (!Object.prototype.hasOwnProperty.call(this._values, name)) { + this._values[name] = new TransitionablePropertyValue(this._values[name].property); + } + // Note that we do not _remove_ an own property in the case where a value is being reset + // to the default: the transition might still be non-default. + this._values[name].value = new PropertyValue(this._values[name].property, value === null ? undefined : clone$9(value)); + } + getTransition(name) { + return clone$9(this._values[name].transition); + } + setTransition(name, value) { + if (!Object.prototype.hasOwnProperty.call(this._values, name)) { + this._values[name] = new TransitionablePropertyValue(this._values[name].property); + } + this._values[name].transition = clone$9(value) || undefined; + } + serialize() { + const result = {}; + for (const property of Object.keys(this._values)) { + const value = this.getValue(property); + if (value !== undefined) { + result[property] = value; + } + const transition = this.getTransition(property); + if (transition !== undefined) { + result[`${property}-transition`] = transition; + } + } + return result; + } + transitioned(parameters, prior) { + const result = new Transitioning(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].transitioned(parameters, prior._values[property]); + } + return result; + } + untransitioned() { + const result = new Transitioning(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].untransitioned(); + } + return result; + } +} +/** + * @internal + * `TransitioningPropertyValue` implements the first of two intermediate steps in the evaluation chain of a paint + * property value. In this step, transitions between old and new values are handled: as long as the transition is in + * progress, `TransitioningPropertyValue` maintains a reference to the prior value, and interpolates between it and + * the new value based on the current time and the configured transition duration and delay. The product is the next + * step in the evaluation chain: the "possibly evaluated" result type `R`. See below for more on this concept. + */ +class TransitioningPropertyValue { + constructor(property, value, prior, transition, now) { + this.property = property; + this.value = value; + this.begin = now + transition.delay || 0; + this.end = this.begin + transition.duration || 0; + if (property.specification.transition && (transition.delay || transition.duration)) { + this.prior = prior; + } + } + possiblyEvaluate(parameters, canonical, availableImages) { + const now = parameters.now || 0; + const finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages); + const prior = this.prior; + if (!prior) { + // No prior value. + return finalValue; + } + else if (now > this.end) { + // Transition from prior value is now complete. + this.prior = null; + return finalValue; + } + else if (this.value.isDataDriven()) { + // Transitions to data-driven properties are not supported. + // We snap immediately to the data-driven value so that, when we perform layout, + // we see the data-driven function and can use it to populate vertex buffers. + this.prior = null; + return finalValue; + } + else if (now < this.begin) { + // Transition hasn't started yet. + return prior.possiblyEvaluate(parameters, canonical, availableImages); + } + else { + // Interpolate between recursively-calculated prior value and final. + const t = (now - this.begin) / (this.end - this.begin); + return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t)); + } + } +} +/** + * @internal + * `Transitioning` stores a map of all (property name, `TransitioningPropertyValue`) pairs for paint properties of a + * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a + * `PossiblyEvaluated` instance for the same set of properties. + */ +class Transitioning { + constructor(properties) { + this._properties = properties; + this._values = Object.create(properties.defaultTransitioningPropertyValues); + } + possiblyEvaluate(parameters, canonical, availableImages) { + const result = new PossiblyEvaluated(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages); + } + return result; + } + hasTransition() { + for (const property of Object.keys(this._values)) { + if (this._values[property].prior) { + return true; + } + } + return false; + } +} +// ------- Layout ------- +/** + * Because layout properties are not transitionable, they have a simpler representation and evaluation chain than + * paint properties: `PropertyValue`s are possibly evaluated, producing possibly evaluated values, which are then + * fully evaluated. + * + * `Layout` stores a map of all (property name, `PropertyValue`) pairs for layout properties of a + * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a + * `PossiblyEvaluated` instance for the same set of properties. + */ +class Layout { + constructor(properties) { + this._properties = properties; + this._values = Object.create(properties.defaultPropertyValues); + } + hasValue(name) { + return this._values[name].value !== undefined; + } + getValue(name) { + return clone$9(this._values[name].value); + } + setValue(name, value) { + this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone$9(value)); + } + serialize() { + const result = {}; + for (const property of Object.keys(this._values)) { + const value = this.getValue(property); + if (value !== undefined) { + result[property] = value; + } + } + return result; + } + possiblyEvaluate(parameters, canonical, availableImages) { + const result = new PossiblyEvaluated(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages); + } + return result; + } +} +/** + * @internal + * `PossiblyEvaluatedPropertyValue` is used for data-driven paint and layout property values. It holds a + * `PossiblyEvaluatedValue` and the `GlobalProperties` that were used to generate it. You're not allowed to supply + * a different set of `GlobalProperties` when performing the final evaluation because they would be ignored in the + * case where the input value was a constant or camera function. + */ +class PossiblyEvaluatedPropertyValue { + constructor(property, value, parameters) { + this.property = property; + this.value = value; + this.parameters = parameters; + } + isConstant() { + return this.value.kind === 'constant'; + } + constantOr(value) { + if (this.value.kind === 'constant') { + return this.value.value; + } + else { + return value; + } + } + evaluate(feature, featureState, canonical, availableImages) { + return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages); + } +} +/** + * @internal + * `PossiblyEvaluated` stores a map of all (property name, `R`) pairs for paint or layout properties of a + * given layer type. + */ +class PossiblyEvaluated { + constructor(properties) { + this._properties = properties; + this._values = Object.create(properties.defaultPossiblyEvaluatedValues); + } + get(name) { + return this._values[name]; + } +} +/** + * @internal + * An implementation of `Property` for properties that do not permit data-driven (source or composite) expressions. + * This restriction allows us to declare statically that the result of possibly evaluating this kind of property + * is in fact always the scalar type `T`, and can be used without further evaluating the value on a per-feature basis. + */ +class DataConstantProperty { + constructor(specification) { + this.specification = specification; + } + possiblyEvaluate(value, parameters) { + if (value.isDataDriven()) + throw new Error('Value should not be data driven'); + return value.expression.evaluate(parameters); + } + interpolate(a, b, t) { + const interpolationType = this.specification.type; + const interpolationFn = interpolate[interpolationType]; + if (interpolationFn) { + return interpolationFn(a, b, t); + } + else { + return a; + } + } +} +/** + * @internal + * An implementation of `Property` for properties that permit data-driven (source or composite) expressions. + * The result of possibly evaluating this kind of property is `PossiblyEvaluatedPropertyValue`; obtaining + * a scalar value `T` requires further evaluation on a per-feature basis. + */ +class DataDrivenProperty { + constructor(specification, overrides) { + this.specification = specification; + this.overrides = overrides; + } + possiblyEvaluate(value, parameters, canonical, availableImages) { + if (value.expression.kind === 'constant' || value.expression.kind === 'camera') { + return new PossiblyEvaluatedPropertyValue(this, { kind: 'constant', value: value.expression.evaluate(parameters, null, {}, canonical, availableImages) }, parameters); + } + else { + return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters); + } + } + interpolate(a, b, t) { + // If either possibly-evaluated value is non-constant, give up: we aren't able to interpolate data-driven values. + if (a.value.kind !== 'constant' || b.value.kind !== 'constant') { + return a; + } + // Special case hack solely for fill-outline-color. The undefined value is subsequently handled in + // FillStyleLayer#recalculate, which sets fill-outline-color to the fill-color value if the former + // is a PossiblyEvaluatedPropertyValue containing a constant undefined value. In addition to the + // return value here, the other source of a PossiblyEvaluatedPropertyValue containing a constant + // undefined value is the "default value" for fill-outline-color held in + // `Properties#defaultPossiblyEvaluatedValues`, which serves as the prototype of + // `PossiblyEvaluated#_values`. + if (a.value.value === undefined || b.value.value === undefined) { + return new PossiblyEvaluatedPropertyValue(this, { kind: 'constant', value: undefined }, a.parameters); + } + const interpolationType = this.specification.type; + const interpolationFn = interpolate[interpolationType]; + if (interpolationFn) { + const interpolatedValue = interpolationFn(a.value.value, b.value.value, t); + return new PossiblyEvaluatedPropertyValue(this, { kind: 'constant', value: interpolatedValue }, a.parameters); + } + else { + return a; + } + } + evaluate(value, parameters, feature, featureState, canonical, availableImages) { + if (value.kind === 'constant') { + return value.value; + } + else { + return value.evaluate(parameters, feature, featureState, canonical, availableImages); + } + } +} +/** + * @internal + * An implementation of `Property` for data driven `line-pattern` which are transitioned by cross-fading + * rather than interpolation. + */ +class CrossFadedDataDrivenProperty extends DataDrivenProperty { + possiblyEvaluate(value, parameters, canonical, availableImages) { + if (value.value === undefined) { + return new PossiblyEvaluatedPropertyValue(this, { kind: 'constant', value: undefined }, parameters); + } + else if (value.expression.kind === 'constant') { + const evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages); + const isImageExpression = value.property.specification.type === 'resolvedImage'; + const constantValue = isImageExpression && typeof evaluatedValue !== 'string' ? evaluatedValue.name : evaluatedValue; + const constant = this._calculate(constantValue, constantValue, constantValue, parameters); + return new PossiblyEvaluatedPropertyValue(this, { kind: 'constant', value: constant }, parameters); + } + else if (value.expression.kind === 'camera') { + const cameraVal = this._calculate(value.expression.evaluate({ zoom: parameters.zoom - 1.0 }), value.expression.evaluate({ zoom: parameters.zoom }), value.expression.evaluate({ zoom: parameters.zoom + 1.0 }), parameters); + return new PossiblyEvaluatedPropertyValue(this, { kind: 'constant', value: cameraVal }, parameters); + } + else { + // source or composite expression + return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters); + } + } + evaluate(value, globals, feature, featureState, canonical, availableImages) { + if (value.kind === 'source') { + const constant = value.evaluate(globals, feature, featureState, canonical, availableImages); + return this._calculate(constant, constant, constant, globals); + } + else if (value.kind === 'composite') { + return this._calculate(value.evaluate({ zoom: Math.floor(globals.zoom) - 1.0 }, feature, featureState), value.evaluate({ zoom: Math.floor(globals.zoom) }, feature, featureState), value.evaluate({ zoom: Math.floor(globals.zoom) + 1.0 }, feature, featureState), globals); + } + else { + return value.value; + } + } + _calculate(min, mid, max, parameters) { + const z = parameters.zoom; + return z > parameters.zoomHistory.lastIntegerZoom ? { from: min, to: mid } : { from: max, to: mid }; + } + interpolate(a) { + return a; + } +} +/** + * @internal + * An implementation of `Property` for `*-pattern` and `line-dasharray`, which are transitioned by cross-fading + * rather than interpolation. + */ +class CrossFadedProperty { + constructor(specification) { + this.specification = specification; + } + possiblyEvaluate(value, parameters, canonical, availableImages) { + if (value.value === undefined) { + return undefined; + } + else if (value.expression.kind === 'constant') { + const constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages); + return this._calculate(constant, constant, constant, parameters); + } + else { + return this._calculate(value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1.0), parameters)), value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)), value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1.0), parameters)), parameters); + } + } + _calculate(min, mid, max, parameters) { + const z = parameters.zoom; + return z > parameters.zoomHistory.lastIntegerZoom ? { from: min, to: mid } : { from: max, to: mid }; + } + interpolate(a) { + return a; + } +} +/** + * @internal + * An implementation of `Property` for `heatmap-color` and `line-gradient`. Interpolation is a no-op, and + * evaluation returns a boolean value in order to indicate its presence, but the real + * evaluation happens in StyleLayer classes. + */ +class ColorRampProperty { + constructor(specification) { + this.specification = specification; + } + possiblyEvaluate(value, parameters, canonical, availableImages) { + return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages); + } + interpolate() { return false; } +} +/** + * @internal + * `Properties` holds objects containing default values for the layout or paint property set of a given + * layer type. These objects are immutable, and they are used as the prototypes for the `_values` members of + * `Transitionable`, `Transitioning`, `Layout`, and `PossiblyEvaluated`. This allows these classes to avoid + * doing work in the common case where a property has no explicit value set and should be considered to take + * on the default value: using `for (const property of Object.keys(this._values))`, they can iterate over + * only the _own_ properties of `_values`, skipping repeated calculation of transitions and possible/final + * evaluations for defaults, the result of which will always be the same. + */ +class Properties { + constructor(properties) { + this.properties = properties; + this.defaultPropertyValues = {}; + this.defaultTransitionablePropertyValues = {}; + this.defaultTransitioningPropertyValues = {}; + this.defaultPossiblyEvaluatedValues = {}; + this.overridableProperties = []; + for (const property in properties) { + const prop = properties[property]; + if (prop.specification.overridable) { + this.overridableProperties.push(property); + } + const defaultPropertyValue = this.defaultPropertyValues[property] = + new PropertyValue(prop, undefined); + const defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] = + new TransitionablePropertyValue(prop); + this.defaultTransitioningPropertyValues[property] = + defaultTransitionablePropertyValue.untransitioned(); + this.defaultPossiblyEvaluatedValues[property] = + defaultPropertyValue.possiblyEvaluate({}); + } + } +} +register('DataDrivenProperty', DataDrivenProperty); +register('DataConstantProperty', DataConstantProperty); +register('CrossFadedDataDrivenProperty', CrossFadedDataDrivenProperty); +register('CrossFadedProperty', CrossFadedProperty); +register('ColorRampProperty', ColorRampProperty); + +const TRANSITION_SUFFIX = '-transition'; +/** + * A base class for style layers + */ +class StyleLayer extends Evented { + constructor(layer, properties) { + super(); + this.id = layer.id; + this.type = layer.type; + this._featureFilter = { filter: () => true, needGeometry: false }; + if (layer.type === 'custom') + return; + layer = layer; + this.metadata = layer.metadata; + this.minzoom = layer.minzoom; + this.maxzoom = layer.maxzoom; + if (layer.type !== 'background') { + this.source = layer.source; + this.sourceLayer = layer['source-layer']; + this.filter = layer.filter; + } + if (properties.layout) { + this._unevaluatedLayout = new Layout(properties.layout); + } + if (properties.paint) { + this._transitionablePaint = new Transitionable(properties.paint); + for (const property in layer.paint) { + this.setPaintProperty(property, layer.paint[property], { validate: false }); + } + for (const property in layer.layout) { + this.setLayoutProperty(property, layer.layout[property], { validate: false }); + } + this._transitioningPaint = this._transitionablePaint.untransitioned(); + //$FlowFixMe + this.paint = new PossiblyEvaluated(properties.paint); + } + } + getCrossfadeParameters() { + return this._crossfadeParameters; + } + getLayoutProperty(name) { + if (name === 'visibility') { + return this.visibility; + } + return this._unevaluatedLayout.getValue(name); + } + setLayoutProperty(name, value, options = {}) { + if (value !== null && value !== undefined) { + const key = `layers.${this.id}.layout.${name}`; + if (this._validate(validateLayoutProperty, key, name, value, options)) { + return; + } + } + if (name === 'visibility') { + this.visibility = value; + return; + } + this._unevaluatedLayout.setValue(name, value); + } + getPaintProperty(name) { + if (name.endsWith(TRANSITION_SUFFIX)) { + return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length)); + } + else { + return this._transitionablePaint.getValue(name); + } + } + setPaintProperty(name, value, options = {}) { + if (value !== null && value !== undefined) { + const key = `layers.${this.id}.paint.${name}`; + if (this._validate(validatePaintProperty, key, name, value, options)) { + return false; + } + } + if (name.endsWith(TRANSITION_SUFFIX)) { + this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), value || undefined); + return false; + } + else { + const transitionable = this._transitionablePaint._values[name]; + const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven'; + const wasDataDriven = transitionable.value.isDataDriven(); + const oldValue = transitionable.value; + this._transitionablePaint.setValue(name, value); + this._handleSpecialPaintPropertyUpdate(name); + const newValue = this._transitionablePaint._values[name].value; + const isDataDriven = newValue.isDataDriven(); + // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas + // so a call to _updateLayer is necessary, and we return true from this function so it gets called in + // Style#setPaintProperty + return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name, oldValue, newValue); + } + } + _handleSpecialPaintPropertyUpdate(_) { + // No-op; can be overridden by derived classes. + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _handleOverridablePaintPropertyUpdate(name, oldValue, newValue) { + // No-op; can be overridden by derived classes. + return false; + } + isHidden(zoom) { + if (this.minzoom && zoom < this.minzoom) + return true; + if (this.maxzoom && zoom >= this.maxzoom) + return true; + return this.visibility === 'none'; + } + updateTransitions(parameters) { + this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint); + } + hasTransition() { + return this._transitioningPaint.hasTransition(); + } + recalculate(parameters, availableImages) { + if (parameters.getCrossfadeParameters) { + this._crossfadeParameters = parameters.getCrossfadeParameters(); + } + if (this._unevaluatedLayout) { + this.layout = this._unevaluatedLayout.possiblyEvaluate(parameters, undefined, availableImages); + } + this.paint = this._transitioningPaint.possiblyEvaluate(parameters, undefined, availableImages); + } + serialize() { + const output = { + 'id': this.id, + 'type': this.type, + 'source': this.source, + 'source-layer': this.sourceLayer, + 'metadata': this.metadata, + 'minzoom': this.minzoom, + 'maxzoom': this.maxzoom, + 'filter': this.filter, + 'layout': this._unevaluatedLayout && this._unevaluatedLayout.serialize(), + 'paint': this._transitionablePaint && this._transitionablePaint.serialize() + }; + if (this.visibility) { + output.layout = output.layout || {}; + output.layout.visibility = this.visibility; + } + return filterObject(output, (value, key) => { + return value !== undefined && + !(key === 'layout' && !Object.keys(value).length) && + !(key === 'paint' && !Object.keys(value).length); + }); + } + _validate(validate, key, name, value, options = {}) { + if (options && options.validate === false) { + return false; + } + return emitValidationErrors(this, validate.call(validateStyle, { + key, + layerType: this.type, + objectKey: name, + value, + styleSpec: v8Spec, + // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407 + style: { glyphs: true, sprite: true } + })); + } + is3D() { + return false; + } + isTileClipped() { + return false; + } + hasOffscreenPass() { + return false; + } + resize() { + // noop + } + isStateDependent() { + for (const property in this.paint._values) { + const value = this.paint.get(property); + if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) { + continue; + } + if ((value.value.kind === 'source' || value.value.kind === 'composite') && + value.value.isStateDependent) { + return true; + } + } + return false; + } +} + +// Note: all "sizes" are measured in bytes +/** + * @internal + * A view type size + */ +const viewTypes = { + 'Int8': Int8Array, + 'Uint8': Uint8Array, + 'Int16': Int16Array, + 'Uint16': Uint16Array, + 'Int32': Int32Array, + 'Uint32': Uint32Array, + 'Float32': Float32Array +}; +/** @internal */ +class Struct { + /** + * @param structArray - The StructArray the struct is stored in + * @param index - The index of the struct in the StructArray. + */ + constructor(structArray, index) { + this._structArray = structArray; + this._pos1 = index * this.size; + this._pos2 = this._pos1 / 2; + this._pos4 = this._pos1 / 4; + this._pos8 = this._pos1 / 8; + } +} +const DEFAULT_CAPACITY = 128; +const RESIZE_MULTIPLIER = 5; +/** + * @internal + * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray` + * making it behave like an array of typed structs. + * + * Conceptually, a StructArray is comprised of elements, i.e., instances of its + * associated struct type. Each particular struct type, together with an + * alignment size, determines the memory layout of a StructArray whose elements + * are of that type. Thus, for each such layout that we need, we have + * a corresponding StructArrayLayout class, inheriting from StructArray and + * implementing `emplaceBack()` and `_refreshViews()`. + * + * In some cases, where we need to access particular elements of a StructArray, + * we implement a more specific subclass that inherits from one of the + * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured + * object whose properties are proxies into the underlying memory space for the + * i-th element. This affords the convience of working with (seemingly) plain + * Javascript objects without the overhead of serializing/deserializing them + * into ArrayBuffers for efficient web worker transfer. + */ +class StructArray { + constructor() { + this.isTransferred = false; + this.capacity = -1; + this.resize(0); + } + /** + * Serialize a StructArray instance. Serializes both the raw data and the + * metadata needed to reconstruct the StructArray base class during + * deserialization. + */ + static serialize(array, transferables) { + array._trim(); + if (transferables) { + array.isTransferred = true; + transferables.push(array.arrayBuffer); + } + return { + length: array.length, + arrayBuffer: array.arrayBuffer, + }; + } + static deserialize(input) { + const structArray = Object.create(this.prototype); + structArray.arrayBuffer = input.arrayBuffer; + structArray.length = input.length; + structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement; + structArray._refreshViews(); + return structArray; + } + /** + * Resize the array to discard unused capacity. + */ + _trim() { + if (this.length !== this.capacity) { + this.capacity = this.length; + this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement); + this._refreshViews(); + } + } + /** + * Resets the length of the array to 0 without de-allocating capcacity. + */ + clear() { + this.length = 0; + } + /** + * Resize the array. + * If `n` is greater than the current length then additional elements with undefined values are added. + * If `n` is less than the current length then the array will be reduced to the first `n` elements. + * @param n - The new size of the array. + */ + resize(n) { + this.reserve(n); + this.length = n; + } + /** + * Indicate a planned increase in size, so that any necessary allocation may + * be done once, ahead of time. + * @param n - The expected size of the array. + */ + reserve(n) { + if (n > this.capacity) { + this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY); + this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement); + const oldUint8Array = this.uint8; + this._refreshViews(); + if (oldUint8Array) + this.uint8.set(oldUint8Array); + } + } + /** + * Create TypedArray views for the current ArrayBuffer. + */ + _refreshViews() { + throw new Error('_refreshViews() must be implemented by each concrete StructArray layout'); + } +} +/** + * Given a list of member fields, create a full StructArrayLayout, in + * particular calculating the correct byte offset for each field. This data + * is used at build time to generate StructArrayLayout_*#emplaceBack() and + * other accessors, and at runtime for binding vertex buffer attributes. + */ +function createLayout(members, alignment = 1) { + let offset = 0; + let maxSize = 0; + const layoutMembers = members.map((member) => { + const typeSize = sizeOf(member.type); + const memberOffset = offset = align$1(offset, Math.max(alignment, typeSize)); + const components = member.components || 1; + maxSize = Math.max(maxSize, typeSize); + offset += typeSize * components; + return { + name: member.name, + type: member.type, + components, + offset: memberOffset, + }; + }); + const size = align$1(offset, Math.max(maxSize, alignment)); + return { + members: layoutMembers, + size, + alignment + }; +} +function sizeOf(type) { + return viewTypes[type].BYTES_PER_ELEMENT; +} +function align$1(offset, size) { + return Math.ceil(offset / size) * size; +} + +// This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`. +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * + */ +class StructArrayLayout2i4 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1); + } + emplace(i, v0, v1) { + const o2 = i * 2; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + return i; + } +} +StructArrayLayout2i4.prototype.bytesPerElement = 4; +register('StructArrayLayout2i4', StructArrayLayout2i4); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[3] + * + */ +class StructArrayLayout3i6 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + emplace(i, v0, v1, v2) { + const o2 = i * 3; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + return i; + } +} +StructArrayLayout3i6.prototype.bytesPerElement = 6; +register('StructArrayLayout3i6', StructArrayLayout3i6); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[4] + * + */ +class StructArrayLayout4i8 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3); + } + emplace(i, v0, v1, v2, v3) { + const o2 = i * 4; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + return i; + } +} +StructArrayLayout4i8.prototype.bytesPerElement = 8; +register('StructArrayLayout4i8', StructArrayLayout4i8); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Int16[4] + * + */ +class StructArrayLayout2i4i12 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5); + } + emplace(i, v0, v1, v2, v3, v4, v5) { + const o2 = i * 6; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + return i; + } +} +StructArrayLayout2i4i12.prototype.bytesPerElement = 12; +register('StructArrayLayout2i4i12', StructArrayLayout2i4i12); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Uint8[4] + * + */ +class StructArrayLayout2i4ub8 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5); + } + emplace(i, v0, v1, v2, v3, v4, v5) { + const o2 = i * 4; + const o1 = i * 8; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.uint8[o1 + 4] = v2; + this.uint8[o1 + 5] = v3; + this.uint8[o1 + 6] = v4; + this.uint8[o1 + 7] = v5; + return i; + } +} +StructArrayLayout2i4ub8.prototype.bytesPerElement = 8; +register('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[2] + * + */ +class StructArrayLayout2f8 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1); + } + emplace(i, v0, v1) { + const o4 = i * 2; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + return i; + } +} +StructArrayLayout2f8.prototype.bytesPerElement = 8; +register('StructArrayLayout2f8', StructArrayLayout2f8); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[10] + * + */ +class StructArrayLayout10ui20 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) { + const o2 = i * 10; + this.uint16[o2 + 0] = v0; + this.uint16[o2 + 1] = v1; + this.uint16[o2 + 2] = v2; + this.uint16[o2 + 3] = v3; + this.uint16[o2 + 4] = v4; + this.uint16[o2 + 5] = v5; + this.uint16[o2 + 6] = v6; + this.uint16[o2 + 7] = v7; + this.uint16[o2 + 8] = v8; + this.uint16[o2 + 9] = v9; + return i; + } +} +StructArrayLayout10ui20.prototype.bytesPerElement = 20; +register('StructArrayLayout10ui20', StructArrayLayout10ui20); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[4] + * [8]: Uint16[4] + * [16]: Int16[4] + * + */ +class StructArrayLayout4i4ui4i24 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) { + const o2 = i * 12; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.uint16[o2 + 4] = v4; + this.uint16[o2 + 5] = v5; + this.uint16[o2 + 6] = v6; + this.uint16[o2 + 7] = v7; + this.int16[o2 + 8] = v8; + this.int16[o2 + 9] = v9; + this.int16[o2 + 10] = v10; + this.int16[o2 + 11] = v11; + return i; + } +} +StructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24; +register('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[3] + * + */ +class StructArrayLayout3f12 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + emplace(i, v0, v1, v2) { + const o4 = i * 3; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + return i; + } +} +StructArrayLayout3f12.prototype.bytesPerElement = 12; +register('StructArrayLayout3f12', StructArrayLayout3f12); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint32[1] + * + */ +class StructArrayLayout1ul4 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + } + emplaceBack(v0) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0); + } + emplace(i, v0) { + const o4 = i * 1; + this.uint32[o4 + 0] = v0; + return i; + } +} +StructArrayLayout1ul4.prototype.bytesPerElement = 4; +register('StructArrayLayout1ul4', StructArrayLayout1ul4); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[6] + * [12]: Uint32[1] + * [16]: Uint16[2] + * + */ +class StructArrayLayout6i1ul2ui20 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8); + } + emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8) { + const o2 = i * 10; + const o4 = i * 5; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + this.uint32[o4 + 3] = v6; + this.uint16[o2 + 8] = v7; + this.uint16[o2 + 9] = v8; + return i; + } +} +StructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20; +register('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Int16[2] + * [8]: Int16[2] + * + */ +class StructArrayLayout2i2i2i12 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5); + } + emplace(i, v0, v1, v2, v3, v4, v5) { + const o2 = i * 6; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + return i; + } +} +StructArrayLayout2i2i2i12.prototype.bytesPerElement = 12; +register('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[2] + * [8]: Float32[1] + * [12]: Int16[2] + * + */ +class StructArrayLayout2f1f2i16 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4); + } + emplace(i, v0, v1, v2, v3, v4) { + const o4 = i * 4; + const o2 = i * 8; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + this.int16[o2 + 6] = v3; + this.int16[o2 + 7] = v4; + return i; + } +} +StructArrayLayout2f1f2i16.prototype.bytesPerElement = 16; +register('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint8[2] + * [4]: Float32[2] + * + */ +class StructArrayLayout2ub2f12 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3); + } + emplace(i, v0, v1, v2, v3) { + const o1 = i * 12; + const o4 = i * 3; + this.uint8[o1 + 0] = v0; + this.uint8[o1 + 1] = v1; + this.float32[o4 + 1] = v2; + this.float32[o4 + 2] = v3; + return i; + } +} +StructArrayLayout2ub2f12.prototype.bytesPerElement = 12; +register('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[3] + * + */ +class StructArrayLayout3ui6 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + emplace(i, v0, v1, v2) { + const o2 = i * 3; + this.uint16[o2 + 0] = v0; + this.uint16[o2 + 1] = v1; + this.uint16[o2 + 2] = v2; + return i; + } +} +StructArrayLayout3ui6.prototype.bytesPerElement = 6; +register('StructArrayLayout3ui6', StructArrayLayout3ui6); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Uint16[2] + * [8]: Uint32[3] + * [20]: Uint16[3] + * [28]: Float32[2] + * [36]: Uint8[3] + * [40]: Uint32[1] + * [44]: Int16[1] + * + */ +class StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) { + const o2 = i * 24; + const o4 = i * 12; + const o1 = i * 48; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.uint16[o2 + 2] = v2; + this.uint16[o2 + 3] = v3; + this.uint32[o4 + 2] = v4; + this.uint32[o4 + 3] = v5; + this.uint32[o4 + 4] = v6; + this.uint16[o2 + 10] = v7; + this.uint16[o2 + 11] = v8; + this.uint16[o2 + 12] = v9; + this.float32[o4 + 7] = v10; + this.float32[o4 + 8] = v11; + this.uint8[o1 + 36] = v12; + this.uint8[o1 + 37] = v13; + this.uint8[o1 + 38] = v14; + this.uint32[o4 + 10] = v15; + this.int16[o2 + 22] = v16; + return i; + } +} +StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48; +register('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[8] + * [16]: Uint16[15] + * [48]: Uint32[1] + * [52]: Float32[2] + * [60]: Uint16[2] + * + */ +class StructArrayLayout8i15ui1ul2f2ui64 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27); + } + emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) { + const o2 = i * 32; + const o4 = i * 16; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + this.int16[o2 + 6] = v6; + this.int16[o2 + 7] = v7; + this.uint16[o2 + 8] = v8; + this.uint16[o2 + 9] = v9; + this.uint16[o2 + 10] = v10; + this.uint16[o2 + 11] = v11; + this.uint16[o2 + 12] = v12; + this.uint16[o2 + 13] = v13; + this.uint16[o2 + 14] = v14; + this.uint16[o2 + 15] = v15; + this.uint16[o2 + 16] = v16; + this.uint16[o2 + 17] = v17; + this.uint16[o2 + 18] = v18; + this.uint16[o2 + 19] = v19; + this.uint16[o2 + 20] = v20; + this.uint16[o2 + 21] = v21; + this.uint16[o2 + 22] = v22; + this.uint32[o4 + 12] = v23; + this.float32[o4 + 13] = v24; + this.float32[o4 + 14] = v25; + this.uint16[o2 + 30] = v26; + this.uint16[o2 + 31] = v27; + return i; + } +} +StructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64; +register('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[1] + * + */ +class StructArrayLayout1f4 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0); + } + emplace(i, v0) { + const o4 = i * 1; + this.float32[o4 + 0] = v0; + return i; + } +} +StructArrayLayout1f4.prototype.bytesPerElement = 4; +register('StructArrayLayout1f4', StructArrayLayout1f4); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[1] + * [4]: Float32[2] + * + */ +class StructArrayLayout1ui2f12 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + emplace(i, v0, v1, v2) { + const o2 = i * 6; + const o4 = i * 3; + this.uint16[o2 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + return i; + } +} +StructArrayLayout1ui2f12.prototype.bytesPerElement = 12; +register('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint32[1] + * [4]: Uint16[2] + * + */ +class StructArrayLayout1ul2ui8 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + emplace(i, v0, v1, v2) { + const o4 = i * 2; + const o2 = i * 4; + this.uint32[o4 + 0] = v0; + this.uint16[o2 + 2] = v1; + this.uint16[o2 + 3] = v2; + return i; + } +} +StructArrayLayout1ul2ui8.prototype.bytesPerElement = 8; +register('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[2] + * + */ +class StructArrayLayout2ui4 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0, v1) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1); + } + emplace(i, v0, v1) { + const o2 = i * 2; + this.uint16[o2 + 0] = v0; + this.uint16[o2 + 1] = v1; + return i; + } +} +StructArrayLayout2ui4.prototype.bytesPerElement = 4; +register('StructArrayLayout2ui4', StructArrayLayout2ui4); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[1] + * + */ +class StructArrayLayout1ui2 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + emplaceBack(v0) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0); + } + emplace(i, v0) { + const o2 = i * 1; + this.uint16[o2 + 0] = v0; + return i; + } +} +StructArrayLayout1ui2.prototype.bytesPerElement = 2; +register('StructArrayLayout1ui2', StructArrayLayout1ui2); +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[4] + * + */ +class StructArrayLayout4f16 extends StructArray { + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + emplaceBack(v0, v1, v2, v3) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3); + } + emplace(i, v0, v1, v2, v3) { + const o4 = i * 4; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + this.float32[o4 + 3] = v3; + return i; + } +} +StructArrayLayout4f16.prototype.bytesPerElement = 16; +register('StructArrayLayout4f16', StructArrayLayout4f16); +/** @internal */ +class CollisionBoxStruct extends Struct { + get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; } + get anchorPointY() { return this._structArray.int16[this._pos2 + 1]; } + get x1() { return this._structArray.int16[this._pos2 + 2]; } + get y1() { return this._structArray.int16[this._pos2 + 3]; } + get x2() { return this._structArray.int16[this._pos2 + 4]; } + get y2() { return this._structArray.int16[this._pos2 + 5]; } + get featureIndex() { return this._structArray.uint32[this._pos4 + 3]; } + get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 8]; } + get bucketIndex() { return this._structArray.uint16[this._pos2 + 9]; } + get anchorPoint() { return new Point$2(this.anchorPointX, this.anchorPointY); } +} +CollisionBoxStruct.prototype.size = 20; +/** @internal */ +class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 { + /** + * Return the CollisionBoxStruct at the given location in the array. + * @param index The index of the element. + */ + get(index) { + return new CollisionBoxStruct(this, index); + } +} +register('CollisionBoxArray', CollisionBoxArray); +/** @internal */ +class PlacedSymbolStruct extends Struct { + get anchorX() { return this._structArray.int16[this._pos2 + 0]; } + get anchorY() { return this._structArray.int16[this._pos2 + 1]; } + get glyphStartIndex() { return this._structArray.uint16[this._pos2 + 2]; } + get numGlyphs() { return this._structArray.uint16[this._pos2 + 3]; } + get vertexStartIndex() { return this._structArray.uint32[this._pos4 + 2]; } + get lineStartIndex() { return this._structArray.uint32[this._pos4 + 3]; } + get lineLength() { return this._structArray.uint32[this._pos4 + 4]; } + get segment() { return this._structArray.uint16[this._pos2 + 10]; } + get lowerSize() { return this._structArray.uint16[this._pos2 + 11]; } + get upperSize() { return this._structArray.uint16[this._pos2 + 12]; } + get lineOffsetX() { return this._structArray.float32[this._pos4 + 7]; } + get lineOffsetY() { return this._structArray.float32[this._pos4 + 8]; } + get writingMode() { return this._structArray.uint8[this._pos1 + 36]; } + get placedOrientation() { return this._structArray.uint8[this._pos1 + 37]; } + set placedOrientation(x) { this._structArray.uint8[this._pos1 + 37] = x; } + get hidden() { return this._structArray.uint8[this._pos1 + 38]; } + set hidden(x) { this._structArray.uint8[this._pos1 + 38] = x; } + get crossTileID() { return this._structArray.uint32[this._pos4 + 10]; } + set crossTileID(x) { this._structArray.uint32[this._pos4 + 10] = x; } + get associatedIconIndex() { return this._structArray.int16[this._pos2 + 22]; } +} +PlacedSymbolStruct.prototype.size = 48; +/** @internal */ +class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 { + /** + * Return the PlacedSymbolStruct at the given location in the array. + * @param index The index of the element. + */ + get(index) { + return new PlacedSymbolStruct(this, index); + } +} +register('PlacedSymbolArray', PlacedSymbolArray); +/** @internal */ +class SymbolInstanceStruct extends Struct { + get anchorX() { return this._structArray.int16[this._pos2 + 0]; } + get anchorY() { return this._structArray.int16[this._pos2 + 1]; } + get rightJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 2]; } + get centerJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 3]; } + get leftJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 4]; } + get verticalPlacedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 5]; } + get placedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 6]; } + get verticalPlacedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 7]; } + get key() { return this._structArray.uint16[this._pos2 + 8]; } + get textBoxStartIndex() { return this._structArray.uint16[this._pos2 + 9]; } + get textBoxEndIndex() { return this._structArray.uint16[this._pos2 + 10]; } + get verticalTextBoxStartIndex() { return this._structArray.uint16[this._pos2 + 11]; } + get verticalTextBoxEndIndex() { return this._structArray.uint16[this._pos2 + 12]; } + get iconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 13]; } + get iconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 14]; } + get verticalIconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 15]; } + get verticalIconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 16]; } + get featureIndex() { return this._structArray.uint16[this._pos2 + 17]; } + get numHorizontalGlyphVertices() { return this._structArray.uint16[this._pos2 + 18]; } + get numVerticalGlyphVertices() { return this._structArray.uint16[this._pos2 + 19]; } + get numIconVertices() { return this._structArray.uint16[this._pos2 + 20]; } + get numVerticalIconVertices() { return this._structArray.uint16[this._pos2 + 21]; } + get useRuntimeCollisionCircles() { return this._structArray.uint16[this._pos2 + 22]; } + get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; } + set crossTileID(x) { this._structArray.uint32[this._pos4 + 12] = x; } + get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; } + get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; } + get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; } + get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; } +} +SymbolInstanceStruct.prototype.size = 64; +/** @internal */ +class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 { + /** + * Return the SymbolInstanceStruct at the given location in the array. + * @param index The index of the element. + */ + get(index) { + return new SymbolInstanceStruct(this, index); + } +} +register('SymbolInstanceArray', SymbolInstanceArray); +/** @internal */ +class GlyphOffsetArray extends StructArrayLayout1f4 { + getoffsetX(index) { return this.float32[index * 1 + 0]; } +} +register('GlyphOffsetArray', GlyphOffsetArray); +/** @internal */ +class SymbolLineVertexArray extends StructArrayLayout3i6 { + getx(index) { return this.int16[index * 3 + 0]; } + gety(index) { return this.int16[index * 3 + 1]; } + gettileUnitDistanceFromAnchor(index) { return this.int16[index * 3 + 2]; } +} +register('SymbolLineVertexArray', SymbolLineVertexArray); +/** @internal */ +class TextAnchorOffsetStruct extends Struct { + get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; } + get textOffset0() { return this._structArray.float32[this._pos4 + 1]; } + get textOffset1() { return this._structArray.float32[this._pos4 + 2]; } +} +TextAnchorOffsetStruct.prototype.size = 12; +/** @internal */ +class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 { + /** + * Return the TextAnchorOffsetStruct at the given location in the array. + * @param index The index of the element. + */ + get(index) { + return new TextAnchorOffsetStruct(this, index); + } +} +register('TextAnchorOffsetArray', TextAnchorOffsetArray); +/** @internal */ +class FeatureIndexStruct extends Struct { + get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; } + get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 2]; } + get bucketIndex() { return this._structArray.uint16[this._pos2 + 3]; } +} +FeatureIndexStruct.prototype.size = 8; +/** @internal */ +class FeatureIndexArray extends StructArrayLayout1ul2ui8 { + /** + * Return the FeatureIndexStruct at the given location in the array. + * @param index The index of the element. + */ + get(index) { + return new FeatureIndexStruct(this, index); + } +} +register('FeatureIndexArray', FeatureIndexArray); +class PosArray extends StructArrayLayout2i4 { +} +class Pos3dArray extends StructArrayLayout3i6 { +} +class RasterBoundsArray extends StructArrayLayout4i8 { +} +class CircleLayoutArray extends StructArrayLayout2i4 { +} +class FillLayoutArray extends StructArrayLayout2i4 { +} +class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 { +} +class HeatmapLayoutArray extends StructArrayLayout2i4 { +} +class LineLayoutArray extends StructArrayLayout2i4ub8 { +} +class LineExtLayoutArray extends StructArrayLayout2f8 { +} +class PatternLayoutArray extends StructArrayLayout10ui20 { +} +class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 { +} +class SymbolDynamicLayoutArray extends StructArrayLayout3f12 { +} +class SymbolOpacityArray extends StructArrayLayout1ul4 { +} +class CollisionBoxLayoutArray extends StructArrayLayout2i2i2i12 { +} +class CollisionCircleLayoutArray extends StructArrayLayout2f1f2i16 { +} +class CollisionVertexArray extends StructArrayLayout2ub2f12 { +} +class QuadTriangleArray extends StructArrayLayout3ui6 { +} +class TriangleIndexArray extends StructArrayLayout3ui6 { +} +class LineIndexArray extends StructArrayLayout2ui4 { +} +class LineStripIndexArray extends StructArrayLayout1ui2 { +} + +const layout$6 = createLayout([ + { name: 'a_pos', components: 2, type: 'Int16' } +], 4); +const { members: members$4, size: size$4, alignment: alignment$4 } = layout$6; + +/** + * @internal + * Used for calculations on vector segments + */ +class SegmentVector { + constructor(segments = []) { + this.segments = segments; + } + prepareSegment(numVertices, layoutVertexArray, indexArray, sortKey) { + let segment = this.segments[this.segments.length - 1]; + if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) + warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`); + if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) { + segment = { + vertexOffset: layoutVertexArray.length, + primitiveOffset: indexArray.length, + vertexLength: 0, + primitiveLength: 0 + }; + if (sortKey !== undefined) + segment.sortKey = sortKey; + this.segments.push(segment); + } + return segment; + } + get() { + return this.segments; + } + destroy() { + for (const segment of this.segments) { + for (const k in segment.vaos) { + segment.vaos[k].destroy(); + } + } + } + static simpleSegment(vertexOffset, primitiveOffset, vertexLength, primitiveLength) { + return new SegmentVector([{ + vertexOffset, + primitiveOffset, + vertexLength, + primitiveLength, + vaos: {}, + sortKey: 0 + }]); + } +} +/** + * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit + * addressing of vertex buffers. + */ +SegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1; +register('SegmentVector', SegmentVector); + +/** + * Packs two numbers, interpreted as 8-bit unsigned integers, into a single + * float. Unpack them in the shader using the `unpack_float()` function, + * defined in _prelude.vertex.glsl + */ +function packUint8ToFloat(a, b) { + // coerce a and b to 8-bit ints + a = clamp$1(Math.floor(a), 0, 255); + b = clamp$1(Math.floor(b), 0, 255); + return 256 * a + b; +} + +const patternAttributes = createLayout([ + // [tl.x, tl.y, br.x, br.y] + { name: 'a_pattern_from', components: 4, type: 'Uint16' }, + { name: 'a_pattern_to', components: 4, type: 'Uint16' }, + { name: 'a_pixel_ratio_from', components: 1, type: 'Uint16' }, + { name: 'a_pixel_ratio_to', components: 1, type: 'Uint16' }, +]); + +var murmurhashJs$1 = {exports: {}}; + +var murmurhash3_gc$2 = {exports: {}}; + +/** + * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011) + * + * @author Gary Court + * @see http://github.com/garycourt/murmurhash-js + * @author Austin Appleby + * @see http://sites.google.com/site/murmurhash/ + * + * @param {string} key ASCII only + * @param {number} seed Positive integer only + * @return {number} 32-bit positive integer hash + */ +var murmurhash3_gc = murmurhash3_gc$2.exports; + +(function (module) { + function murmurhash3_32_gc(key, seed) { + var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i; + + remainder = key.length & 3; // key.length % 4 + bytes = key.length - remainder; + h1 = seed; + c1 = 0xcc9e2d51; + c2 = 0x1b873593; + i = 0; + + while (i < bytes) { + k1 = + ((key.charCodeAt(i) & 0xff)) | + ((key.charCodeAt(++i) & 0xff) << 8) | + ((key.charCodeAt(++i) & 0xff) << 16) | + ((key.charCodeAt(++i) & 0xff) << 24); + ++i; + + k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; + k1 = (k1 << 15) | (k1 >>> 17); + k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; + + h1 ^= k1; + h1 = (h1 << 13) | (h1 >>> 19); + h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; + h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); + } + + k1 = 0; + + switch (remainder) { + case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; + case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; + case 1: k1 ^= (key.charCodeAt(i) & 0xff); + + k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; + k1 = (k1 << 15) | (k1 >>> 17); + k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; + h1 ^= k1; + } + + h1 ^= key.length; + + h1 ^= h1 >>> 16; + h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; + h1 ^= h1 >>> 13; + h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; + h1 ^= h1 >>> 16; + + return h1 >>> 0; + } + + if('object' !== "undefined") { + module.exports = murmurhash3_32_gc; + } +} (murmurhash3_gc$2)); + +var murmurhash3_gcExports = murmurhash3_gc$2.exports; +var murmurhash3_gc$1 = /*@__PURE__*/getDefaultExportFromCjs(murmurhash3_gcExports); + +var murmurhash2_gc$2 = {exports: {}}; + +/** + * JS Implementation of MurmurHash2 + * + * @author Gary Court + * @see http://github.com/garycourt/murmurhash-js + * @author Austin Appleby + * @see http://sites.google.com/site/murmurhash/ + * + * @param {string} str ASCII only + * @param {number} seed Positive integer only + * @return {number} 32-bit positive integer hash + */ +var murmurhash2_gc = murmurhash2_gc$2.exports; + +(function (module) { + function murmurhash2_32_gc(str, seed) { + var + l = str.length, + h = seed ^ l, + i = 0, + k; + + while (l >= 4) { + k = + ((str.charCodeAt(i) & 0xff)) | + ((str.charCodeAt(++i) & 0xff) << 8) | + ((str.charCodeAt(++i) & 0xff) << 16) | + ((str.charCodeAt(++i) & 0xff) << 24); + + k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16)); + k ^= k >>> 24; + k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16)); + + h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k; + + l -= 4; + ++i; + } + + switch (l) { + case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16; + case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8; + case 1: h ^= (str.charCodeAt(i) & 0xff); + h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)); + } + + h ^= h >>> 13; + h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)); + h ^= h >>> 15; + + return h >>> 0; + } + + if('object' !== undefined) { + module.exports = murmurhash2_32_gc; + } +} (murmurhash2_gc$2)); + +var murmurhash2_gcExports = murmurhash2_gc$2.exports; +var murmurhash2_gc$1 = /*@__PURE__*/getDefaultExportFromCjs(murmurhash2_gcExports); + +var murmurhashJs = murmurhashJs$1.exports; + +var murmur3 = murmurhash3_gcExports; +var murmur2 = murmurhash2_gcExports; + +murmurhashJs$1.exports = murmur3; +var murmur3_1 = murmurhashJs$1.exports.murmur3 = murmur3; +var murmur2_1 = murmurhashJs$1.exports.murmur2 = murmur2; + +var murmurhashJsExports = murmurhashJs$1.exports; +var murmur3$1 = /*@__PURE__*/getDefaultExportFromCjs(murmurhashJsExports); + +// A transferable data structure that maps feature ids to their indices and buffer offsets +class FeaturePositionMap { + constructor() { + this.ids = []; + this.positions = []; + this.indexed = false; + } + add(id, index, start, end) { + this.ids.push(getNumericId(id)); + this.positions.push(index, start, end); + } + getPositions(id) { + if (!this.indexed) + throw new Error('Trying to get index, but feature positions are not indexed'); + const intId = getNumericId(id); + // binary search for the first occurrence of id in this.ids; + // relies on ids/positions being sorted by id, which happens in serialization + let i = 0; + let j = this.ids.length - 1; + while (i < j) { + const m = (i + j) >> 1; + if (this.ids[m] >= intId) { + j = m; + } + else { + i = m + 1; + } + } + const positions = []; + while (this.ids[i] === intId) { + const index = this.positions[3 * i]; + const start = this.positions[3 * i + 1]; + const end = this.positions[3 * i + 2]; + positions.push({ index, start, end }); + i++; + } + return positions; + } + static serialize(map, transferables) { + const ids = new Float64Array(map.ids); + const positions = new Uint32Array(map.positions); + sort$1(ids, positions, 0, ids.length - 1); + if (transferables) { + transferables.push(ids.buffer, positions.buffer); + } + return { ids, positions }; + } + static deserialize(obj) { + const map = new FeaturePositionMap(); + // after transferring, we only use these arrays statically (no pushes), + // so TypedArray vs Array distinction that flow points out doesn't matter + map.ids = obj.ids; + map.positions = obj.positions; + map.indexed = true; + return map; + } +} +function getNumericId(value) { + const numValue = +value; + if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) { + return numValue; + } + return murmur3$1(String(value)); +} +// custom quicksort that sorts ids, indices and offsets together (by ids) +// uses Hoare partitioning & manual tail call optimization to avoid worst case scenarios +function sort$1(ids, positions, left, right) { + while (left < right) { + const pivot = ids[(left + right) >> 1]; + let i = left - 1; + let j = right + 1; + while (true) { + do + i++; + while (ids[i] < pivot); + do + j--; + while (ids[j] > pivot); + if (i >= j) + break; + swap$2(ids, i, j); + swap$2(positions, 3 * i, 3 * j); + swap$2(positions, 3 * i + 1, 3 * j + 1); + swap$2(positions, 3 * i + 2, 3 * j + 2); + } + if (j - left < right - j) { + sort$1(ids, positions, left, j); + left = j + 1; + } + else { + sort$1(ids, positions, j + 1, right); + right = j; + } + } +} +function swap$2(arr, i, j) { + const tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} +register('FeaturePositionMap', FeaturePositionMap); + +/** + * @internal + * A base uniform abstract class + */ +class Uniform { + constructor(context, location) { + this.gl = context.gl; + this.location = location; + } +} +class Uniform1i extends Uniform { + constructor(context, location) { + super(context, location); + this.current = 0; + } + set(v) { + if (this.current !== v) { + this.current = v; + this.gl.uniform1i(this.location, v); + } + } +} +class Uniform1f extends Uniform { + constructor(context, location) { + super(context, location); + this.current = 0; + } + set(v) { + if (this.current !== v) { + this.current = v; + this.gl.uniform1f(this.location, v); + } + } +} +class Uniform2f extends Uniform { + constructor(context, location) { + super(context, location); + this.current = [0, 0]; + } + set(v) { + if (v[0] !== this.current[0] || v[1] !== this.current[1]) { + this.current = v; + this.gl.uniform2f(this.location, v[0], v[1]); + } + } +} +class Uniform3f extends Uniform { + constructor(context, location) { + super(context, location); + this.current = [0, 0, 0]; + } + set(v) { + if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) { + this.current = v; + this.gl.uniform3f(this.location, v[0], v[1], v[2]); + } + } +} +class Uniform4f extends Uniform { + constructor(context, location) { + super(context, location); + this.current = [0, 0, 0, 0]; + } + set(v) { + if (v[0] !== this.current[0] || v[1] !== this.current[1] || + v[2] !== this.current[2] || v[3] !== this.current[3]) { + this.current = v; + this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]); + } + } +} +class UniformColor extends Uniform { + constructor(context, location) { + super(context, location); + this.current = Color.transparent; + } + set(v) { + if (v.r !== this.current.r || v.g !== this.current.g || + v.b !== this.current.b || v.a !== this.current.a) { + this.current = v; + this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a); + } + } +} +const emptyMat4 = new Float32Array(16); +class UniformMatrix4f extends Uniform { + constructor(context, location) { + super(context, location); + this.current = emptyMat4; + } + set(v) { + // The vast majority of matrix comparisons that will trip this set + // happen at i=12 or i=0, so we check those first to avoid lots of + // unnecessary iteration: + if (v[12] !== this.current[12] || v[0] !== this.current[0]) { + this.current = v; + this.gl.uniformMatrix4fv(this.location, false, v); + return; + } + for (let i = 1; i < 16; i++) { + if (v[i] !== this.current[i]) { + this.current = v; + this.gl.uniformMatrix4fv(this.location, false, v); + break; + } + } + } +} + +function packColor(color) { + return [ + packUint8ToFloat(255 * color.r, 255 * color.g), + packUint8ToFloat(255 * color.b, 255 * color.a) + ]; +} +class ConstantBinder { + constructor(value, names, type) { + this.value = value; + this.uniformNames = names.map(name => `u_${name}`); + this.type = type; + } + setUniform(uniform, globals, currentValue) { + uniform.set(currentValue.constantOr(this.value)); + } + getBinding(context, location, _) { + return (this.type === 'color') ? + new UniformColor(context, location) : + new Uniform1f(context, location); + } +} +class CrossFadedConstantBinder { + constructor(value, names) { + this.uniformNames = names.map(name => `u_${name}`); + this.patternFrom = null; + this.patternTo = null; + this.pixelRatioFrom = 1.0; + this.pixelRatioTo = 1.0; + } + setConstantPatternPositions(posTo, posFrom) { + this.pixelRatioFrom = posFrom.pixelRatio; + this.pixelRatioTo = posTo.pixelRatio; + this.patternFrom = posFrom.tlbr; + this.patternTo = posTo.tlbr; + } + setUniform(uniform, globals, currentValue, uniformName) { + const pos = uniformName === 'u_pattern_to' ? this.patternTo : + uniformName === 'u_pattern_from' ? this.patternFrom : + uniformName === 'u_pixel_ratio_to' ? this.pixelRatioTo : + uniformName === 'u_pixel_ratio_from' ? this.pixelRatioFrom : null; + if (pos) + uniform.set(pos); + } + getBinding(context, location, name) { + return name.substr(0, 9) === 'u_pattern' ? + new Uniform4f(context, location) : + new Uniform1f(context, location); + } +} +class SourceExpressionBinder { + constructor(expression, names, type, PaintVertexArray) { + this.expression = expression; + this.type = type; + this.maxValue = 0; + this.paintVertexAttributes = names.map((name) => ({ + name: `a_${name}`, + type: 'Float32', + components: type === 'color' ? 2 : 1, + offset: 0 + })); + this.paintVertexArray = new PaintVertexArray(); + } + populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection) { + const start = this.paintVertexArray.length; + const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection); + this.paintVertexArray.resize(newLength); + this._setPaintValue(start, newLength, value); + } + updatePaintArray(start, end, feature, featureState) { + const value = this.expression.evaluate({ zoom: 0 }, feature, featureState); + this._setPaintValue(start, end, value); + } + _setPaintValue(start, end, value) { + if (this.type === 'color') { + const color = packColor(value); + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, color[0], color[1]); + } + } + else { + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, value); + } + this.maxValue = Math.max(this.maxValue, Math.abs(value)); + } + } + upload(context) { + if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) { + if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) { + this.paintVertexBuffer.updateData(this.paintVertexArray); + } + else { + this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent); + } + } + } + destroy() { + if (this.paintVertexBuffer) { + this.paintVertexBuffer.destroy(); + } + } +} +class CompositeExpressionBinder { + constructor(expression, names, type, useIntegerZoom, zoom, PaintVertexArray) { + this.expression = expression; + this.uniformNames = names.map(name => `u_${name}_t`); + this.type = type; + this.useIntegerZoom = useIntegerZoom; + this.zoom = zoom; + this.maxValue = 0; + this.paintVertexAttributes = names.map((name) => ({ + name: `a_${name}`, + type: 'Float32', + components: type === 'color' ? 4 : 2, + offset: 0 + })); + this.paintVertexArray = new PaintVertexArray(); + } + populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection) { + const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection); + const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection); + const start = this.paintVertexArray.length; + this.paintVertexArray.resize(newLength); + this._setPaintValue(start, newLength, min, max); + } + updatePaintArray(start, end, feature, featureState) { + const min = this.expression.evaluate({ zoom: this.zoom }, feature, featureState); + const max = this.expression.evaluate({ zoom: this.zoom + 1 }, feature, featureState); + this._setPaintValue(start, end, min, max); + } + _setPaintValue(start, end, min, max) { + if (this.type === 'color') { + const minColor = packColor(min); + const maxColor = packColor(max); + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]); + } + } + else { + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, min, max); + } + this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max)); + } + } + upload(context) { + if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) { + if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) { + this.paintVertexBuffer.updateData(this.paintVertexArray); + } + else { + this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent); + } + } + } + destroy() { + if (this.paintVertexBuffer) { + this.paintVertexBuffer.destroy(); + } + } + setUniform(uniform, globals) { + const currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom; + const factor = clamp$1(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1); + uniform.set(factor); + } + getBinding(context, location, _) { + return new Uniform1f(context, location); + } +} +class CrossFadedCompositeBinder { + constructor(expression, type, useIntegerZoom, zoom, PaintVertexArray, layerId) { + this.expression = expression; + this.type = type; + this.useIntegerZoom = useIntegerZoom; + this.zoom = zoom; + this.layerId = layerId; + this.zoomInPaintVertexArray = new PaintVertexArray(); + this.zoomOutPaintVertexArray = new PaintVertexArray(); + } + populatePaintArray(length, feature, imagePositions) { + const start = this.zoomInPaintVertexArray.length; + this.zoomInPaintVertexArray.resize(length); + this.zoomOutPaintVertexArray.resize(length); + this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions); + } + updatePaintArray(start, end, feature, featureState, imagePositions) { + this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions); + } + _setPaintValues(start, end, patterns, positions) { + if (!positions || !patterns) + return; + const { min, mid, max } = patterns; + const imageMin = positions[min]; + const imageMid = positions[mid]; + const imageMax = positions[max]; + if (!imageMin || !imageMid || !imageMax) + return; + // We populate two paint arrays because, for cross-faded properties, we don't know which direction + // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass + // unnecessary vertex data to the shaders, we determine which to upload at draw time. + for (let i = start; i < end; i++) { + this.zoomInPaintVertexArray.emplace(i, imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1], imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1], imageMid.pixelRatio, imageMin.pixelRatio); + this.zoomOutPaintVertexArray.emplace(i, imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1], imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1], imageMid.pixelRatio, imageMax.pixelRatio); + } + } + upload(context) { + if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) { + this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent); + this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent); + } + } + destroy() { + if (this.zoomOutPaintVertexBuffer) + this.zoomOutPaintVertexBuffer.destroy(); + if (this.zoomInPaintVertexBuffer) + this.zoomInPaintVertexBuffer.destroy(); + } +} +/** + * @internal + * ProgramConfiguration contains the logic for binding style layer properties and tile + * layer feature data into GL program uniforms and vertex attributes. + * + * Non-data-driven property values are bound to shader uniforms. Data-driven property + * values are bound to vertex attributes. In order to support a uniform GLSL syntax over + * both, [Mapbox GL Shaders](https://github.com/mapbox/mapbox-gl-shaders) defines a `#pragma` + * abstraction, which ProgramConfiguration is responsible for implementing. At runtime, + * it examines the attributes of a particular layer, combines this with fixed knowledge + * about how layers of the particular type are implemented, and determines which uniforms + * and vertex attributes will be required. It can then substitute the appropriate text + * into the shader source code, create and link a program, and bind the uniforms and + * vertex attributes in preparation for drawing. + * + * When a vector tile is parsed, this same configuration information is used to + * populate the attribute buffers needed for data-driven styling using the zoom + * level and feature property data. + */ +class ProgramConfiguration { + constructor(layer, zoom, filterProperties) { + this.binders = {}; + this._buffers = []; + const keys = []; + for (const property in layer.paint._values) { + if (!filterProperties(property)) + continue; + const value = layer.paint.get(property); + if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) { + continue; + } + const names = paintAttributeNames(property, layer.type); + const expression = value.value; + const type = value.property.specification.type; + const useIntegerZoom = value.property.useIntegerZoom; + const propType = value.property.specification['property-type']; + const isCrossFaded = propType === 'cross-faded' || propType === 'cross-faded-data-driven'; + if (expression.kind === 'constant') { + this.binders[property] = isCrossFaded ? + new CrossFadedConstantBinder(expression.value, names) : + new ConstantBinder(expression.value, names, type); + keys.push(`/u_${property}`); + } + else if (expression.kind === 'source' || isCrossFaded) { + const StructArrayLayout = layoutType(property, type, 'source'); + this.binders[property] = isCrossFaded ? + new CrossFadedCompositeBinder(expression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) : + new SourceExpressionBinder(expression, names, type, StructArrayLayout); + keys.push(`/a_${property}`); + } + else { + const StructArrayLayout = layoutType(property, type, 'composite'); + this.binders[property] = new CompositeExpressionBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout); + keys.push(`/z_${property}`); + } + } + this.cacheKey = keys.sort().join(''); + } + getMaxValue(property) { + const binder = this.binders[property]; + return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0; + } + populatePaintArrays(newLength, feature, imagePositions, canonical, formattedSection) { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) + binder.populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection); + } + } + setConstantPatternPositions(posTo, posFrom) { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof CrossFadedConstantBinder) + binder.setConstantPatternPositions(posTo, posFrom); + } + } + updatePaintArrays(featureStates, featureMap, vtLayer, layer, imagePositions) { + let dirty = false; + for (const id in featureStates) { + const positions = featureMap.getPositions(id); + for (const pos of positions) { + const feature = vtLayer.feature(pos.index); + for (const property in this.binders) { + const binder = this.binders[property]; + if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || + binder instanceof CrossFadedCompositeBinder) && binder.expression.isStateDependent === true) { + //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255 + const value = layer.paint.get(property); + binder.expression = value.value; + binder.updatePaintArray(pos.start, pos.end, feature, featureStates[id], imagePositions); + dirty = true; + } + } + } + } + return dirty; + } + defines() { + const result = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) { + result.push(...binder.uniformNames.map(name => `#define HAS_UNIFORM_${name}`)); + } + } + return result; + } + getBinderAttributes() { + const result = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) { + for (let i = 0; i < binder.paintVertexAttributes.length; i++) { + result.push(binder.paintVertexAttributes[i].name); + } + } + else if (binder instanceof CrossFadedCompositeBinder) { + for (let i = 0; i < patternAttributes.members.length; i++) { + result.push(patternAttributes.members[i].name); + } + } + } + return result; + } + getBinderUniforms() { + const uniforms = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) { + for (const uniformName of binder.uniformNames) { + uniforms.push(uniformName); + } + } + } + return uniforms; + } + getPaintVertexBuffers() { + return this._buffers; + } + getUniforms(context, locations) { + const uniforms = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) { + for (const name of binder.uniformNames) { + if (locations[name]) { + const binding = binder.getBinding(context, locations[name], name); + uniforms.push({ name, property, binding }); + } + } + } + } + return uniforms; + } + setUniforms(context, binderUniforms, properties, globals) { + // Uniform state bindings are owned by the Program, but we set them + // from within the ProgramConfiguraton's binder members. + for (const { name, property, binding } of binderUniforms) { + this.binders[property].setUniform(binding, globals, properties.get(property), name); + } + } + updatePaintBuffers(crossfade) { + this._buffers = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (crossfade && binder instanceof CrossFadedCompositeBinder) { + const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer; + if (patternVertexBuffer) + this._buffers.push(patternVertexBuffer); + } + else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) { + this._buffers.push(binder.paintVertexBuffer); + } + } + } + upload(context) { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) + binder.upload(context); + } + this.updatePaintBuffers(); + } + destroy() { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) + binder.destroy(); + } + } +} +class ProgramConfigurationSet { + constructor(layers, zoom, filterProperties = () => true) { + this.programConfigurations = {}; + for (const layer of layers) { + this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties); + } + this.needsUpload = false; + this._featureMap = new FeaturePositionMap(); + this._bufferOffset = 0; + } + populatePaintArrays(length, feature, index, imagePositions, canonical, formattedSection) { + for (const key in this.programConfigurations) { + this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection); + } + if (feature.id !== undefined) { + this._featureMap.add(feature.id, index, this._bufferOffset, length); + } + this._bufferOffset = length; + this.needsUpload = true; + } + updatePaintArrays(featureStates, vtLayer, layers, imagePositions) { + for (const layer of layers) { + this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload; + } + } + get(layerId) { + return this.programConfigurations[layerId]; + } + upload(context) { + if (!this.needsUpload) + return; + for (const layerId in this.programConfigurations) { + this.programConfigurations[layerId].upload(context); + } + this.needsUpload = false; + } + destroy() { + for (const layerId in this.programConfigurations) { + this.programConfigurations[layerId].destroy(); + } + } +} +function paintAttributeNames(property, type) { + const attributeNameExceptions = { + 'text-opacity': ['opacity'], + 'icon-opacity': ['opacity'], + 'text-color': ['fill_color'], + 'icon-color': ['fill_color'], + 'text-halo-color': ['halo_color'], + 'icon-halo-color': ['halo_color'], + 'text-halo-blur': ['halo_blur'], + 'icon-halo-blur': ['halo_blur'], + 'text-halo-width': ['halo_width'], + 'icon-halo-width': ['halo_width'], + 'line-gap-width': ['gapwidth'], + 'line-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'], + 'fill-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'], + 'fill-extrusion-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'], + }; + return attributeNameExceptions[property] || [property.replace(`${type}-`, '').replace(/-/g, '_')]; +} +function getLayoutException(property) { + const propertyExceptions = { + 'line-pattern': { + 'source': PatternLayoutArray, + 'composite': PatternLayoutArray + }, + 'fill-pattern': { + 'source': PatternLayoutArray, + 'composite': PatternLayoutArray + }, + 'fill-extrusion-pattern': { + 'source': PatternLayoutArray, + 'composite': PatternLayoutArray + } + }; + return propertyExceptions[property]; +} +function layoutType(property, type, binderType) { + const defaultLayouts = { + 'color': { + 'source': StructArrayLayout2f8, + 'composite': StructArrayLayout4f16 + }, + 'number': { + 'source': StructArrayLayout1f4, + 'composite': StructArrayLayout2f8 + } + }; + const layoutException = getLayoutException(property); + return layoutException && layoutException[binderType] || defaultLayouts[type][binderType]; +} +register('ConstantBinder', ConstantBinder); +register('CrossFadedConstantBinder', CrossFadedConstantBinder); +register('SourceExpressionBinder', SourceExpressionBinder); +register('CrossFadedCompositeBinder', CrossFadedCompositeBinder); +register('CompositeExpressionBinder', CompositeExpressionBinder); +register('ProgramConfiguration', ProgramConfiguration, { omit: ['_buffers'] }); +register('ProgramConfigurationSet', ProgramConfigurationSet); + +/** + * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of + * all source features normalized to this extent upon load. + * + * The value is a consequence of the following: + * + * * Vertex buffer store positions as signed 16 bit integers. + * * One bit is lost for signedness to support tile buffers. + * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int. + * * One bit is lost to support features extending past the extent on the right edge of the tile. + * * This leaves us with 2^13 = 8192 + */ +const EXTENT = 8192; + +// These bounds define the minimum and maximum supported coordinate values. +// While visible coordinates are within [0, EXTENT], tiles may theoretically +// contain coordinates within [-Infinity, Infinity]. Our range is limited by the +// number of bits used to represent the coordinate. +const BITS = 15; +const MAX = Math.pow(2, BITS - 1) - 1; +const MIN = -MAX - 1; +/** + * Loads a geometry from a VectorTileFeature and scales it to the common extent + * used internally. + * @param feature - the vector tile feature to load + */ +function loadGeometry(feature) { + const scale = EXTENT / feature.extent; + const geometry = feature.loadGeometry(); + for (let r = 0; r < geometry.length; r++) { + const ring = geometry[r]; + for (let p = 0; p < ring.length; p++) { + const point = ring[p]; + // round here because mapbox-gl-native uses integers to represent + // points and we need to do the same to avoid renering differences. + const x = Math.round(point.x * scale); + const y = Math.round(point.y * scale); + point.x = clamp$1(x, MIN, MAX); + point.y = clamp$1(y, MIN, MAX); + if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) { + // warn when exceeding allowed extent except for the 1-px-off case + // https://github.com/mapbox/mapbox-gl-js/issues/8992 + warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size'); + } + } + } + return geometry; +} + +/** + * Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which + * will be loaded based on necessity. + * @param feature - the feature to evaluate + * @param needGeometry - if set to true this will load the geometry + */ +function toEvaluationFeature(feature, needGeometry) { + return { type: feature.type, + id: feature.id, + properties: feature.properties, + geometry: needGeometry ? loadGeometry(feature) : [] }; +} + +function addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) { + layoutVertexArray.emplaceBack((x * 2) + ((extrudeX + 1) / 2), (y * 2) + ((extrudeY + 1) / 2)); +} +/** + * @internal + * Circles are represented by two triangles. + * + * Each corner has a pos that is the center of the circle and an extrusion + * vector that is where it points. + */ +class CircleBucket { + constructor(options) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + this.layoutVertexArray = new CircleLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.segments = new SegmentVector(); + this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom); + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + } + populate(features, options, canonical) { + const styleLayer = this.layers[0]; + const bucketFeatures = []; + 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.layout.get('circle-sort-key'); + sortFeaturesByKey = !circleSortKey.isConstant(); + } + for (const { feature, id, index, sourceLayerIndex } of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) + continue; + const sortKey = sortFeaturesByKey ? + circleSortKey.evaluate(evaluationFeature, {}, canonical) : + undefined; + const bucketFeature = { + id, + properties: feature.properties, + type: feature.type, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + patterns: {}, + sortKey + }; + bucketFeatures.push(bucketFeature); + } + if (sortFeaturesByKey) { + bucketFeatures.sort((a, b) => a.sortKey - b.sortKey); + } + for (const bucketFeature of bucketFeatures) { + const { geometry, index, sourceLayerIndex } = bucketFeature; + const feature = features[index].feature; + this.addFeature(bucketFeature, geometry, index, canonical); + options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index); + } + } + update(states, vtLayer, imagePositions) { + if (!this.stateDependentLayers.length) + return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + isEmpty() { + return this.layoutVertexArray.length === 0; + } + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + upload(context) { + if (!this.uploaded) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$4); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + destroy() { + if (!this.layoutVertexBuffer) + return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + } + addFeature(feature, geometry, index, canonical) { + for (const ring of geometry) { + for (const point of ring) { + const x = point.x; + const y = point.y; + // Do not include points that are outside the tile boundaries. + if (x < 0 || x >= EXTENT || y < 0 || y >= EXTENT) + continue; + // this geometry will be of the Point type, and we'll derive + // two triangles from it. + // + // ┌─────────┐ + // │ 3 2 │ + // │ │ + // │ 0 1 │ + // └─────────┘ + const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey); + const index = segment.vertexLength; + addCircleVertex(this.layoutVertexArray, x, y, -1, -1); + addCircleVertex(this.layoutVertexArray, x, y, 1, -1); + addCircleVertex(this.layoutVertexArray, x, y, 1, 1); + addCircleVertex(this.layoutVertexArray, x, y, -1, 1); + this.indexArray.emplaceBack(index, index + 1, index + 2); + this.indexArray.emplaceBack(index, index + 3, index + 2); + segment.vertexLength += 4; + segment.primitiveLength += 2; + } + } + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical); + } +} +register('CircleBucket', CircleBucket, { omit: ['layers'] }); + +function polygonIntersectsPolygon(polygonA, polygonB) { + for (let i = 0; i < polygonA.length; i++) { + if (polygonContainsPoint(polygonB, polygonA[i])) + return true; + } + for (let i = 0; i < polygonB.length; i++) { + if (polygonContainsPoint(polygonA, polygonB[i])) + return true; + } + if (lineIntersectsLine(polygonA, polygonB)) + return true; + return false; +} +function polygonIntersectsBufferedPoint(polygon, point, radius) { + if (polygonContainsPoint(polygon, point)) + return true; + if (pointIntersectsBufferedLine(point, polygon, radius)) + return true; + return false; +} +function polygonIntersectsMultiPolygon(polygon, multiPolygon) { + if (polygon.length === 1) { + return multiPolygonContainsPoint(multiPolygon, polygon[0]); + } + for (let m = 0; m < multiPolygon.length; m++) { + const ring = multiPolygon[m]; + for (let n = 0; n < ring.length; n++) { + if (polygonContainsPoint(polygon, ring[n])) + return true; + } + } + for (let i = 0; i < polygon.length; i++) { + if (multiPolygonContainsPoint(multiPolygon, polygon[i])) + return true; + } + for (let k = 0; k < multiPolygon.length; k++) { + if (lineIntersectsLine(polygon, multiPolygon[k])) + return true; + } + return false; +} +function polygonIntersectsBufferedMultiLine(polygon, multiLine, radius) { + for (let i = 0; i < multiLine.length; i++) { + const line = multiLine[i]; + if (polygon.length >= 3) { + for (let k = 0; k < line.length; k++) { + if (polygonContainsPoint(polygon, line[k])) + return true; + } + } + if (lineIntersectsBufferedLine(polygon, line, radius)) + return true; + } + return false; +} +function lineIntersectsBufferedLine(lineA, lineB, radius) { + if (lineA.length > 1) { + if (lineIntersectsLine(lineA, lineB)) + return true; + // Check whether any point in either line is within radius of the other line + for (let j = 0; j < lineB.length; j++) { + if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) + return true; + } + } + for (let k = 0; k < lineA.length; k++) { + if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) + return true; + } + return false; +} +function lineIntersectsLine(lineA, lineB) { + if (lineA.length === 0 || lineB.length === 0) + return false; + for (let i = 0; i < lineA.length - 1; i++) { + const a0 = lineA[i]; + const a1 = lineA[i + 1]; + for (let j = 0; j < lineB.length - 1; j++) { + const b0 = lineB[j]; + const b1 = lineB[j + 1]; + if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) + return true; + } + } + return false; +} +function lineSegmentIntersectsLineSegment(a0, a1, b0, b1) { + return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) && + isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1); +} +function pointIntersectsBufferedLine(p, line, radius) { + const radiusSquared = radius * radius; + if (line.length === 1) + return p.distSqr(line[0]) < radiusSquared; + for (let i = 1; i < line.length; i++) { + // Find line segments that have a distance <= radius^2 to p + // In that case, we treat the line as "containing point p". + const v = line[i - 1], w = line[i]; + if (distToSegmentSquared(p, v, w) < radiusSquared) + return true; + } + return false; +} +// Code from http://stackoverflow.com/a/1501725/331379. +function distToSegmentSquared(p, v, w) { + const l2 = v.distSqr(w); + if (l2 === 0) + return p.distSqr(v); + const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2; + if (t < 0) + return p.distSqr(v); + if (t > 1) + return p.distSqr(w); + return p.distSqr(w.sub(v)._mult(t)._add(v)); +} +// point in polygon ray casting algorithm +function multiPolygonContainsPoint(rings, p) { + let c = false, ring, p1, p2; + for (let k = 0; k < rings.length; k++) { + ring = rings[k]; + for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) { + p1 = ring[i]; + p2 = ring[j]; + if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { + c = !c; + } + } + } + return c; +} +function polygonContainsPoint(ring, p) { + let c = false; + for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) { + const p1 = ring[i]; + const p2 = ring[j]; + if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { + c = !c; + } + } + return c; +} +function polygonIntersectsBox(ring, boxX1, boxY1, boxX2, boxY2) { + for (const p of ring) { + if (boxX1 <= p.x && + boxY1 <= p.y && + boxX2 >= p.x && + boxY2 >= p.y) + return true; + } + const corners = [ + new Point$2(boxX1, boxY1), + new Point$2(boxX1, boxY2), + new Point$2(boxX2, boxY2), + new Point$2(boxX2, boxY1) + ]; + if (ring.length > 2) { + for (const corner of corners) { + if (polygonContainsPoint(ring, corner)) + return true; + } + } + for (let i = 0; i < ring.length - 1; i++) { + const p1 = ring[i]; + const p2 = ring[i + 1]; + if (edgeIntersectsBox(p1, p2, corners)) + return true; + } + return false; +} +function edgeIntersectsBox(e1, e2, corners) { + const tl = corners[0]; + const br = corners[2]; + // the edge and box do not intersect in either the x or y dimensions + if (((e1.x < tl.x) && (e2.x < tl.x)) || + ((e1.x > br.x) && (e2.x > br.x)) || + ((e1.y < tl.y) && (e2.y < tl.y)) || + ((e1.y > br.y) && (e2.y > br.y))) + return false; + // check if all corners of the box are on the same side of the edge + const dir = isCounterClockwise(e1, e2, corners[0]); + return dir !== isCounterClockwise(e1, e2, corners[1]) || + dir !== isCounterClockwise(e1, e2, corners[2]) || + dir !== isCounterClockwise(e1, e2, corners[3]); +} + +function getMaximumPaintValue(property, layer, bucket) { + const value = layer.paint.get(property).value; + if (value.kind === 'constant') { + return value.value; + } + else { + return bucket.programConfigurations.get(layer.id).getMaxValue(property); + } +} +function translateDistance(translate) { + return Math.sqrt(translate[0] * translate[0] + translate[1] * translate[1]); +} +function translate$4(queryGeometry, translate, translateAnchor, bearing, pixelsToTileUnits) { + if (!translate[0] && !translate[1]) { + return queryGeometry; + } + const pt = Point$2.convert(translate)._mult(pixelsToTileUnits); + if (translateAnchor === 'viewport') { + pt._rotate(-bearing); + } + const translated = []; + for (let i = 0; i < queryGeometry.length; i++) { + const point = queryGeometry[i]; + translated.push(point.sub(pt)); + } + return translated; +} +function offsetLine(rings, offset) { + const newRings = []; + for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) { + const ring = rings[ringIndex]; + const newRing = []; + for (let index = 0; index < ring.length; index++) { + const a = ring[index - 1]; + const b = ring[index]; + const c = ring[index + 1]; + const aToB = index === 0 ? new Point$2(0, 0) : b.sub(a)._unit()._perp(); + const bToC = index === ring.length - 1 ? new Point$2(0, 0) : c.sub(b)._unit()._perp(); + const extrude = aToB._add(bToC)._unit(); + const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y; + if (cosHalfAngle !== 0) { + extrude._mult(1 / cosHalfAngle); + } + newRing.push(extrude._mult(offset)._add(b)); + } + newRings.push(newRing); + } + return newRings; +} + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let layout$5; +const getLayout$3 = () => layout$5 = layout$5 || new Properties({ + "circle-sort-key": new DataDrivenProperty(v8Spec["layout_circle"]["circle-sort-key"]), +}); +let paint$8; +const getPaint$8 = () => paint$8 = paint$8 || new Properties({ + "circle-radius": new DataDrivenProperty(v8Spec["paint_circle"]["circle-radius"]), + "circle-color": new DataDrivenProperty(v8Spec["paint_circle"]["circle-color"]), + "circle-blur": new DataDrivenProperty(v8Spec["paint_circle"]["circle-blur"]), + "circle-opacity": new DataDrivenProperty(v8Spec["paint_circle"]["circle-opacity"]), + "circle-translate": new DataConstantProperty(v8Spec["paint_circle"]["circle-translate"]), + "circle-translate-anchor": new DataConstantProperty(v8Spec["paint_circle"]["circle-translate-anchor"]), + "circle-pitch-scale": new DataConstantProperty(v8Spec["paint_circle"]["circle-pitch-scale"]), + "circle-pitch-alignment": new DataConstantProperty(v8Spec["paint_circle"]["circle-pitch-alignment"]), + "circle-stroke-width": new DataDrivenProperty(v8Spec["paint_circle"]["circle-stroke-width"]), + "circle-stroke-color": new DataDrivenProperty(v8Spec["paint_circle"]["circle-stroke-color"]), + "circle-stroke-opacity": new DataDrivenProperty(v8Spec["paint_circle"]["circle-stroke-opacity"]), +}); +var properties$8 = ({ get paint() { return getPaint$8(); }, get layout() { return getLayout$3(); } }); + +/** + * Common utilities + * @module glMatrix + */ +// Configuration Constants +var EPSILON = 0.000001; +var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array; +var RANDOM = Math.random; +/** + * Sets the type of array used when creating new vectors and matrices + * + * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array + */ + +function setMatrixArrayType(type) { + ARRAY_TYPE = type; +} +var degree = Math.PI / 180; +/** + * Convert Degree To Radian + * + * @param {Number} a Angle in Degrees + */ + +function toRadian(a) { + return a * degree; +} +/** + * Tests whether or not the arguments have approximately the same value, within an absolute + * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less + * than or equal to 1.0, and a relative tolerance is used for larger values) + * + * @param {Number} a The first number to test. + * @param {Number} b The second number to test. + * @returns {Boolean} True if the numbers are approximately equal, false otherwise. + */ + +function equals$a(a, b) { + return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b)); +} +if (!Math.hypot) Math.hypot = function () { + var y = 0, + i = arguments.length; + + while (i--) { + y += arguments[i] * arguments[i]; + } + + return Math.sqrt(y); +}; + +var common = /*#__PURE__*/Object.freeze({ +__proto__: null, +get ARRAY_TYPE () { return ARRAY_TYPE; }, +EPSILON: EPSILON, +RANDOM: RANDOM, +equals: equals$a, +setMatrixArrayType: setMatrixArrayType, +toRadian: toRadian +}); + +/** + * 2x2 Matrix + * @module mat2 + */ + +/** + * Creates a new identity mat2 + * + * @returns {mat2} a new 2x2 matrix + */ + +function create$8() { + var out = new ARRAY_TYPE(4); + + if (ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + } + + out[0] = 1; + out[3] = 1; + return out; +} +/** + * Creates a new mat2 initialized with values from an existing matrix + * + * @param {ReadonlyMat2} a matrix to clone + * @returns {mat2} a new 2x2 matrix + */ + +function clone$8(a) { + var out = new ARRAY_TYPE(4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} +/** + * Copy the values from one mat2 to another + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {mat2} out + */ + +function copy$8(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} +/** + * Set a mat2 to the identity matrix + * + * @param {mat2} out the receiving matrix + * @returns {mat2} out + */ + +function identity$5(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +} +/** + * Create a new mat2 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out A new 2x2 matrix + */ + +function fromValues$8(m00, m01, m10, m11) { + var out = new ARRAY_TYPE(4); + out[0] = m00; + out[1] = m01; + out[2] = m10; + out[3] = m11; + return out; +} +/** + * Set the components of a mat2 to the given values + * + * @param {mat2} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out + */ + +function set$8(out, m00, m01, m10, m11) { + out[0] = m00; + out[1] = m01; + out[2] = m10; + out[3] = m11; + return out; +} +/** + * Transpose the values of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {mat2} out + */ + +function transpose$2(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache + // some values + if (out === a) { + var a1 = a[1]; + out[1] = a[2]; + out[2] = a1; + } else { + out[0] = a[0]; + out[1] = a[2]; + out[2] = a[1]; + out[3] = a[3]; + } + + return out; +} +/** + * Inverts a mat2 + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {mat2} out + */ + +function invert$5(out, a) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; // Calculate the determinant + + var det = a0 * a3 - a2 * a1; + + if (!det) { + return null; + } + + det = 1.0 / det; + out[0] = a3 * det; + out[1] = -a1 * det; + out[2] = -a2 * det; + out[3] = a0 * det; + return out; +} +/** + * Calculates the adjugate of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the source matrix + * @returns {mat2} out + */ + +function adjoint$2(out, a) { + // Caching this value is nessecary if out == a + var a0 = a[0]; + out[0] = a[3]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a0; + return out; +} +/** + * Calculates the determinant of a mat2 + * + * @param {ReadonlyMat2} a the source matrix + * @returns {Number} determinant of a + */ + +function determinant$3(a) { + return a[0] * a[3] - a[2] * a[1]; +} +/** + * Multiplies two mat2's + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {mat2} out + */ + +function multiply$8(out, a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3]; + out[0] = a0 * b0 + a2 * b1; + out[1] = a1 * b0 + a3 * b1; + out[2] = a0 * b2 + a2 * b3; + out[3] = a1 * b2 + a3 * b3; + return out; +} +/** + * Rotates a mat2 by the given angle + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ + +function rotate$4(out, a, rad) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var s = Math.sin(rad); + var c = Math.cos(rad); + out[0] = a0 * c + a2 * s; + out[1] = a1 * c + a3 * s; + out[2] = a0 * -s + a2 * c; + out[3] = a1 * -s + a3 * c; + return out; +} +/** + * Scales the mat2 by the dimensions in the given vec2 + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the matrix to rotate + * @param {ReadonlyVec2} v the vec2 to scale the matrix by + * @returns {mat2} out + **/ + +function scale$8(out, a, v) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var v0 = v[0], + v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + return out; +} +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.rotate(dest, dest, rad); + * + * @param {mat2} out mat2 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ + +function fromRotation$4(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = -s; + out[3] = c; + return out; +} +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.scale(dest, dest, vec); + * + * @param {mat2} out mat2 receiving operation result + * @param {ReadonlyVec2} v Scaling vector + * @returns {mat2} out + */ + +function fromScaling$3(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = v[1]; + return out; +} +/** + * Returns a string representation of a mat2 + * + * @param {ReadonlyMat2} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + +function str$8(a) { + return "mat2(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; +} +/** + * Returns Frobenius norm of a mat2 + * + * @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + +function frob$3(a) { + return Math.hypot(a[0], a[1], a[2], a[3]); +} +/** + * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix + * @param {ReadonlyMat2} L the lower triangular matrix + * @param {ReadonlyMat2} D the diagonal matrix + * @param {ReadonlyMat2} U the upper triangular matrix + * @param {ReadonlyMat2} a the input matrix to factorize + */ + +function LDU(L, D, U, a) { + L[2] = a[2] / a[0]; + U[0] = a[0]; + U[1] = a[1]; + U[3] = a[3] - L[2] * U[1]; + return [L, D, U]; +} +/** + * Adds two mat2's + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {mat2} out + */ + +function add$8(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + return out; +} +/** + * Subtracts matrix b from matrix a + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @returns {mat2} out + */ + +function subtract$6(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + return out; +} +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat2} a The first matrix. + * @param {ReadonlyMat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function exactEquals$8(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat2} a The first matrix. + * @param {ReadonlyMat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function equals$9(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)); +} +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2} out the receiving matrix + * @param {ReadonlyMat2} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat2} out + */ + +function multiplyScalar$3(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + return out; +} +/** + * Adds two mat2's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2} out the receiving vector + * @param {ReadonlyMat2} a the first operand + * @param {ReadonlyMat2} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat2} out + */ + +function multiplyScalarAndAdd$3(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; + return out; +} +/** + * Alias for {@link mat2.multiply} + * @function + */ + +var mul$8 = multiply$8; +/** + * Alias for {@link mat2.subtract} + * @function + */ + +var sub$6 = subtract$6; + +var mat2 = /*#__PURE__*/Object.freeze({ +__proto__: null, +LDU: LDU, +add: add$8, +adjoint: adjoint$2, +clone: clone$8, +copy: copy$8, +create: create$8, +determinant: determinant$3, +equals: equals$9, +exactEquals: exactEquals$8, +frob: frob$3, +fromRotation: fromRotation$4, +fromScaling: fromScaling$3, +fromValues: fromValues$8, +identity: identity$5, +invert: invert$5, +mul: mul$8, +multiply: multiply$8, +multiplyScalar: multiplyScalar$3, +multiplyScalarAndAdd: multiplyScalarAndAdd$3, +rotate: rotate$4, +scale: scale$8, +set: set$8, +str: str$8, +sub: sub$6, +subtract: subtract$6, +transpose: transpose$2 +}); + +/** + * 2x3 Matrix + * @module mat2d + * @description + * A mat2d contains six elements defined as: + *
+ * [a, b,
+ *  c, d,
+ *  tx, ty]
+ * 
+ * This is a short form for the 3x3 matrix: + *
+ * [a, b, 0,
+ *  c, d, 0,
+ *  tx, ty, 1]
+ * 
+ * The last column is ignored so the array is shorter and operations are faster. + */ + +/** + * Creates a new identity mat2d + * + * @returns {mat2d} a new 2x3 matrix + */ + +function create$7() { + var out = new ARRAY_TYPE(6); + + if (ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[4] = 0; + out[5] = 0; + } + + out[0] = 1; + out[3] = 1; + return out; +} +/** + * Creates a new mat2d initialized with values from an existing matrix + * + * @param {ReadonlyMat2d} a matrix to clone + * @returns {mat2d} a new 2x3 matrix + */ + +function clone$7(a) { + var out = new ARRAY_TYPE(6); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} +/** + * Copy the values from one mat2d to another + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the source matrix + * @returns {mat2d} out + */ + +function copy$7(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} +/** + * Set a mat2d to the identity matrix + * + * @param {mat2d} out the receiving matrix + * @returns {mat2d} out + */ + +function identity$4(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; +} +/** + * Create a new mat2d with the given values + * + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {mat2d} A new mat2d + */ + +function fromValues$7(a, b, c, d, tx, ty) { + var out = new ARRAY_TYPE(6); + out[0] = a; + out[1] = b; + out[2] = c; + out[3] = d; + out[4] = tx; + out[5] = ty; + return out; +} +/** + * Set the components of a mat2d to the given values + * + * @param {mat2d} out the receiving matrix + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {mat2d} out + */ + +function set$7(out, a, b, c, d, tx, ty) { + out[0] = a; + out[1] = b; + out[2] = c; + out[3] = d; + out[4] = tx; + out[5] = ty; + return out; +} +/** + * Inverts a mat2d + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the source matrix + * @returns {mat2d} out + */ + +function invert$4(out, a) { + var aa = a[0], + ab = a[1], + ac = a[2], + ad = a[3]; + var atx = a[4], + aty = a[5]; + var det = aa * ad - ab * ac; + + if (!det) { + return null; + } + + det = 1.0 / det; + out[0] = ad * det; + out[1] = -ab * det; + out[2] = -ac * det; + out[3] = aa * det; + out[4] = (ac * aty - ad * atx) * det; + out[5] = (ab * atx - aa * aty) * det; + return out; +} +/** + * Calculates the determinant of a mat2d + * + * @param {ReadonlyMat2d} a the source matrix + * @returns {Number} determinant of a + */ + +function determinant$2(a) { + return a[0] * a[3] - a[1] * a[2]; +} +/** + * Multiplies two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {mat2d} out + */ + +function multiply$7(out, a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3], + b4 = b[4], + b5 = b[5]; + out[0] = a0 * b0 + a2 * b1; + out[1] = a1 * b0 + a3 * b1; + out[2] = a0 * b2 + a2 * b3; + out[3] = a1 * b2 + a3 * b3; + out[4] = a0 * b4 + a2 * b5 + a4; + out[5] = a1 * b4 + a3 * b5 + a5; + return out; +} +/** + * Rotates a mat2d by the given angle + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ + +function rotate$3(out, a, rad) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5]; + var s = Math.sin(rad); + var c = Math.cos(rad); + out[0] = a0 * c + a2 * s; + out[1] = a1 * c + a3 * s; + out[2] = a0 * -s + a2 * c; + out[3] = a1 * -s + a3 * c; + out[4] = a4; + out[5] = a5; + return out; +} +/** + * Scales the mat2d by the dimensions in the given vec2 + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to translate + * @param {ReadonlyVec2} v the vec2 to scale the matrix by + * @returns {mat2d} out + **/ + +function scale$7(out, a, v) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5]; + var v0 = v[0], + v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + out[4] = a4; + out[5] = a5; + return out; +} +/** + * Translates the mat2d by the dimensions in the given vec2 + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to translate + * @param {ReadonlyVec2} v the vec2 to translate the matrix by + * @returns {mat2d} out + **/ + +function translate$3(out, a, v) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5]; + var v0 = v[0], + v1 = v[1]; + out[0] = a0; + out[1] = a1; + out[2] = a2; + out[3] = a3; + out[4] = a0 * v0 + a2 * v1 + a4; + out[5] = a1 * v0 + a3 * v1 + a5; + return out; +} +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.rotate(dest, dest, rad); + * + * @param {mat2d} out mat2d receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ + +function fromRotation$3(out, rad) { + var s = Math.sin(rad), + c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = -s; + out[3] = c; + out[4] = 0; + out[5] = 0; + return out; +} +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.scale(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {ReadonlyVec2} v Scaling vector + * @returns {mat2d} out + */ + +function fromScaling$2(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = v[1]; + out[4] = 0; + out[5] = 0; + return out; +} +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.translate(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {ReadonlyVec2} v Translation vector + * @returns {mat2d} out + */ + +function fromTranslation$3(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = v[0]; + out[5] = v[1]; + return out; +} +/** + * Returns a string representation of a mat2d + * + * @param {ReadonlyMat2d} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + +function str$7(a) { + return "mat2d(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ")"; +} +/** + * Returns Frobenius norm of a mat2d + * + * @param {ReadonlyMat2d} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + +function frob$2(a) { + return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], 1); +} +/** + * Adds two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {mat2d} out + */ + +function add$7(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + return out; +} +/** + * Subtracts matrix b from matrix a + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @returns {mat2d} out + */ + +function subtract$5(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + return out; +} +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2d} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat2d} out + */ + +function multiplyScalar$2(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + return out; +} +/** + * Adds two mat2d's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2d} out the receiving vector + * @param {ReadonlyMat2d} a the first operand + * @param {ReadonlyMat2d} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat2d} out + */ + +function multiplyScalarAndAdd$2(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; + out[4] = a[4] + b[4] * scale; + out[5] = a[5] + b[5] * scale; + return out; +} +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat2d} a The first matrix. + * @param {ReadonlyMat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function exactEquals$7(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5]; +} +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat2d} a The first matrix. + * @param {ReadonlyMat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function equals$8(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3], + b4 = b[4], + b5 = b[5]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)); +} +/** + * Alias for {@link mat2d.multiply} + * @function + */ + +var mul$7 = multiply$7; +/** + * Alias for {@link mat2d.subtract} + * @function + */ + +var sub$5 = subtract$5; + +var mat2d = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$7, +clone: clone$7, +copy: copy$7, +create: create$7, +determinant: determinant$2, +equals: equals$8, +exactEquals: exactEquals$7, +frob: frob$2, +fromRotation: fromRotation$3, +fromScaling: fromScaling$2, +fromTranslation: fromTranslation$3, +fromValues: fromValues$7, +identity: identity$4, +invert: invert$4, +mul: mul$7, +multiply: multiply$7, +multiplyScalar: multiplyScalar$2, +multiplyScalarAndAdd: multiplyScalarAndAdd$2, +rotate: rotate$3, +scale: scale$7, +set: set$7, +str: str$7, +sub: sub$5, +subtract: subtract$5, +translate: translate$3 +}); + +/** + * 3x3 Matrix + * @module mat3 + */ + +/** + * Creates a new identity mat3 + * + * @returns {mat3} a new 3x3 matrix + */ + +function create$6() { + var out = new ARRAY_TYPE(9); + + if (ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + } + + out[0] = 1; + out[4] = 1; + out[8] = 1; + return out; +} +/** + * Copies the upper-left 3x3 values into the given mat3. + * + * @param {mat3} out the receiving 3x3 matrix + * @param {ReadonlyMat4} a the source 4x4 matrix + * @returns {mat3} out + */ + +function fromMat4$1(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + return out; +} +/** + * Creates a new mat3 initialized with values from an existing matrix + * + * @param {ReadonlyMat3} a matrix to clone + * @returns {mat3} a new 3x3 matrix + */ + +function clone$6(a) { + var out = new ARRAY_TYPE(9); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} +/** + * Copy the values from one mat3 to another + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out + */ + +function copy$6(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} +/** + * Create a new mat3 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} A new mat3 + */ + +function fromValues$6(m00, m01, m02, m10, m11, m12, m20, m21, m22) { + var out = new ARRAY_TYPE(9); + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} +/** + * Set the components of a mat3 to the given values + * + * @param {mat3} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} out + */ + +function set$6(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} +/** + * Set a mat3 to the identity matrix + * + * @param {mat3} out the receiving matrix + * @returns {mat3} out + */ + +function identity$3(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} +/** + * Transpose the values of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out + */ + +function transpose$1(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + var a01 = a[1], + a02 = a[2], + a12 = a[5]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a01; + out[5] = a[7]; + out[6] = a02; + out[7] = a12; + } else { + out[0] = a[0]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a[1]; + out[4] = a[4]; + out[5] = a[7]; + out[6] = a[2]; + out[7] = a[5]; + out[8] = a[8]; + } + + return out; +} +/** + * Inverts a mat3 + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out + */ + +function invert$3(out, a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2]; + var a10 = a[3], + a11 = a[4], + a12 = a[5]; + var a20 = a[6], + a21 = a[7], + a22 = a[8]; + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; // Calculate the determinant + + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) { + return null; + } + + det = 1.0 / det; + out[0] = b01 * det; + out[1] = (-a22 * a01 + a02 * a21) * det; + out[2] = (a12 * a01 - a02 * a11) * det; + out[3] = b11 * det; + out[4] = (a22 * a00 - a02 * a20) * det; + out[5] = (-a12 * a00 + a02 * a10) * det; + out[6] = b21 * det; + out[7] = (-a21 * a00 + a01 * a20) * det; + out[8] = (a11 * a00 - a01 * a10) * det; + return out; +} +/** + * Calculates the adjugate of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out + */ + +function adjoint$1(out, a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2]; + var a10 = a[3], + a11 = a[4], + a12 = a[5]; + var a20 = a[6], + a21 = a[7], + a22 = a[8]; + out[0] = a11 * a22 - a12 * a21; + out[1] = a02 * a21 - a01 * a22; + out[2] = a01 * a12 - a02 * a11; + out[3] = a12 * a20 - a10 * a22; + out[4] = a00 * a22 - a02 * a20; + out[5] = a02 * a10 - a00 * a12; + out[6] = a10 * a21 - a11 * a20; + out[7] = a01 * a20 - a00 * a21; + out[8] = a00 * a11 - a01 * a10; + return out; +} +/** + * Calculates the determinant of a mat3 + * + * @param {ReadonlyMat3} a the source matrix + * @returns {Number} determinant of a + */ + +function determinant$1(a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2]; + var a10 = a[3], + a11 = a[4], + a12 = a[5]; + var a20 = a[6], + a21 = a[7], + a22 = a[8]; + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); +} +/** + * Multiplies two mat3's + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {mat3} out + */ + +function multiply$6(out, a, b) { + var a00 = a[0], + a01 = a[1], + a02 = a[2]; + var a10 = a[3], + a11 = a[4], + a12 = a[5]; + var a20 = a[6], + a21 = a[7], + a22 = a[8]; + var b00 = b[0], + b01 = b[1], + b02 = b[2]; + var b10 = b[3], + b11 = b[4], + b12 = b[5]; + var b20 = b[6], + b21 = b[7], + b22 = b[8]; + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b20 * a02 + b21 * a12 + b22 * a22; + return out; +} +/** + * Translate a mat3 by the given vector + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to translate + * @param {ReadonlyVec2} v vector to translate by + * @returns {mat3} out + */ + +function translate$2(out, a, v) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a10 = a[3], + a11 = a[4], + a12 = a[5], + a20 = a[6], + a21 = a[7], + a22 = a[8], + x = v[0], + y = v[1]; + out[0] = a00; + out[1] = a01; + out[2] = a02; + out[3] = a10; + out[4] = a11; + out[5] = a12; + out[6] = x * a00 + y * a10 + a20; + out[7] = x * a01 + y * a11 + a21; + out[8] = x * a02 + y * a12 + a22; + return out; +} +/** + * Rotates a mat3 by the given angle + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ + +function rotate$2(out, a, rad) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a10 = a[3], + a11 = a[4], + a12 = a[5], + a20 = a[6], + a21 = a[7], + a22 = a[8], + s = Math.sin(rad), + c = Math.cos(rad); + out[0] = c * a00 + s * a10; + out[1] = c * a01 + s * a11; + out[2] = c * a02 + s * a12; + out[3] = c * a10 - s * a00; + out[4] = c * a11 - s * a01; + out[5] = c * a12 - s * a02; + out[6] = a20; + out[7] = a21; + out[8] = a22; + return out; +} +/** + * Scales the mat3 by the dimensions in the given vec2 + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to rotate + * @param {ReadonlyVec2} v the vec2 to scale the matrix by + * @returns {mat3} out + **/ + +function scale$6(out, a, v) { + var x = v[0], + y = v[1]; + out[0] = x * a[0]; + out[1] = x * a[1]; + out[2] = x * a[2]; + out[3] = y * a[3]; + out[4] = y * a[4]; + out[5] = y * a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.translate(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyVec2} v Translation vector + * @returns {mat3} out + */ + +function fromTranslation$2(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = v[0]; + out[7] = v[1]; + out[8] = 1; + return out; +} +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.rotate(dest, dest, rad); + * + * @param {mat3} out mat3 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ + +function fromRotation$2(out, rad) { + var s = Math.sin(rad), + c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = 0; + out[3] = -s; + out[4] = c; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.scale(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyVec2} v Scaling vector + * @returns {mat3} out + */ + +function fromScaling$1(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = v[1]; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} +/** + * Copies the values from a mat2d into a mat3 + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to copy + * @returns {mat3} out + **/ + +function fromMat2d(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = 0; + out[3] = a[2]; + out[4] = a[3]; + out[5] = 0; + out[6] = a[4]; + out[7] = a[5]; + out[8] = 1; + return out; +} +/** + * Calculates a 3x3 matrix from the given quaternion + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyQuat} q Quaternion to create matrix from + * + * @returns {mat3} out + */ + +function fromQuat$1(out, q) { + var x = q[0], + y = q[1], + z = q[2], + w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var yx = y * x2; + var yy = y * y2; + var zx = z * x2; + var zy = z * y2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = 1 - yy - zz; + out[3] = yx - wz; + out[6] = zx + wy; + out[1] = yx + wz; + out[4] = 1 - xx - zz; + out[7] = zy - wx; + out[2] = zx - wy; + out[5] = zy + wx; + out[8] = 1 - xx - yy; + return out; +} +/** + * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from + * + * @returns {mat3} out + */ + +function normalFromMat4(out, a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3]; + var a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; + var a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + var a30 = a[12], + a31 = a[13], + a32 = a[14], + a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; // Calculate the determinant + + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) { + return null; + } + + det = 1.0 / det; + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + return out; +} +/** + * Generates a 2D projection matrix with the given bounds + * + * @param {mat3} out mat3 frustum matrix will be written into + * @param {number} width Width of your gl context + * @param {number} height Height of gl context + * @returns {mat3} out + */ + +function projection(out, width, height) { + out[0] = 2 / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = -2 / height; + out[5] = 0; + out[6] = -1; + out[7] = 1; + out[8] = 1; + return out; +} +/** + * Returns a string representation of a mat3 + * + * @param {ReadonlyMat3} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + +function str$6(a) { + return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")"; +} +/** + * Returns Frobenius norm of a mat3 + * + * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + +function frob$1(a) { + return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); +} +/** + * Adds two mat3's + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {mat3} out + */ + +function add$6(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + return out; +} +/** + * Subtracts matrix b from matrix a + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {mat3} out + */ + +function subtract$4(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + return out; +} +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat3} out + */ + +function multiplyScalar$1(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + return out; +} +/** + * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * + * @param {mat3} out the receiving vector + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat3} out + */ + +function multiplyScalarAndAdd$1(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; + out[4] = a[4] + b[4] * scale; + out[5] = a[5] + b[5] * scale; + out[6] = a[6] + b[6] * scale; + out[7] = a[7] + b[7] * scale; + out[8] = a[8] + b[8] * scale; + return out; +} +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat3} a The first matrix. + * @param {ReadonlyMat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function exactEquals$6(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; +} +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat3} a The first matrix. + * @param {ReadonlyMat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function equals$7(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5], + a6 = a[6], + a7 = a[7], + a8 = a[8]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3], + b4 = b[4], + b5 = b[5], + b6 = b[6], + b7 = b[7], + b8 = b[8]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)); +} +/** + * Alias for {@link mat3.multiply} + * @function + */ + +var mul$6 = multiply$6; +/** + * Alias for {@link mat3.subtract} + * @function + */ + +var sub$4 = subtract$4; + +var mat3 = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$6, +adjoint: adjoint$1, +clone: clone$6, +copy: copy$6, +create: create$6, +determinant: determinant$1, +equals: equals$7, +exactEquals: exactEquals$6, +frob: frob$1, +fromMat2d: fromMat2d, +fromMat4: fromMat4$1, +fromQuat: fromQuat$1, +fromRotation: fromRotation$2, +fromScaling: fromScaling$1, +fromTranslation: fromTranslation$2, +fromValues: fromValues$6, +identity: identity$3, +invert: invert$3, +mul: mul$6, +multiply: multiply$6, +multiplyScalar: multiplyScalar$1, +multiplyScalarAndAdd: multiplyScalarAndAdd$1, +normalFromMat4: normalFromMat4, +projection: projection, +rotate: rotate$2, +scale: scale$6, +set: set$6, +str: str$6, +sub: sub$4, +subtract: subtract$4, +translate: translate$2, +transpose: transpose$1 +}); + +/** + * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied. + * @module mat4 + */ + +/** + * Creates a new identity mat4 + * + * @returns {mat4} a new 4x4 matrix + */ + +function create$5() { + var out = new ARRAY_TYPE(16); + + if (ARRAY_TYPE != Float32Array) { + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + } + + out[0] = 1; + out[5] = 1; + out[10] = 1; + out[15] = 1; + return out; +} +/** + * Creates a new mat4 initialized with values from an existing matrix + * + * @param {ReadonlyMat4} a matrix to clone + * @returns {mat4} a new 4x4 matrix + */ + +function clone$5(a) { + var out = new ARRAY_TYPE(16); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} +/** + * Copy the values from one mat4 to another + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out + */ + +function copy$5(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} +/** + * Create a new mat4 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} A new mat4 + */ + +function fromValues$5(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + var out = new ARRAY_TYPE(16); + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; + return out; +} +/** + * Set the components of a mat4 to the given values + * + * @param {mat4} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} out + */ + +function set$5(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; + return out; +} +/** + * Set a mat4 to the identity matrix + * + * @param {mat4} out the receiving matrix + * @returns {mat4} out + */ + +function identity$2(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Transpose the values of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out + */ + +function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + var a01 = a[1], + a02 = a[2], + a03 = a[3]; + var a12 = a[6], + a13 = a[7]; + var a23 = a[11]; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a01; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a02; + out[9] = a12; + out[11] = a[14]; + out[12] = a03; + out[13] = a13; + out[14] = a23; + } else { + out[0] = a[0]; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a[1]; + out[5] = a[5]; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a[2]; + out[9] = a[6]; + out[10] = a[10]; + out[11] = a[14]; + out[12] = a[3]; + out[13] = a[7]; + out[14] = a[11]; + out[15] = a[15]; + } + + return out; +} +/** + * Inverts a mat4 + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out + */ + +function invert$2(out, a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3]; + var a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; + var a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + var a30 = a[12], + a31 = a[13], + a32 = a[14], + a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; // Calculate the determinant + + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) { + return null; + } + + det = 1.0 / det; + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + return out; +} +/** + * Calculates the adjugate of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out + */ + +function adjoint(out, a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3]; + var a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; + var a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + var a30 = a[12], + a31 = a[13], + a32 = a[14], + a33 = a[15]; + out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22); + out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12); + out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22); + out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12); + out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21); + out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11); + out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21); + out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11); + return out; +} +/** + * Calculates the determinant of a mat4 + * + * @param {ReadonlyMat4} a the source matrix + * @returns {Number} determinant of a + */ + +function determinant(a) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3]; + var a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; + var a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + var a30 = a[12], + a31 = a[13], + a32 = a[14], + a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; // Calculate the determinant + + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; +} +/** + * Multiplies two mat4s + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {mat4} out + */ + +function multiply$5(out, a, b) { + var a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3]; + var a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; + var a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + var a30 = a[12], + a31 = a[13], + a32 = a[14], + a33 = a[15]; // Cache only the current line of the second matrix + + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3]; + out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + return out; +} +/** + * Translate a mat4 by the given vector + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to translate + * @param {ReadonlyVec3} v vector to translate by + * @returns {mat4} out + */ + +function translate$1(out, a, v) { + var x = v[0], + y = v[1], + z = v[2]; + var a00, a01, a02, a03; + var a10, a11, a12, a13; + var a20, a21, a22, a23; + + if (a === out) { + out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + } else { + a00 = a[0]; + a01 = a[1]; + a02 = a[2]; + a03 = a[3]; + a10 = a[4]; + a11 = a[5]; + a12 = a[6]; + a13 = a[7]; + a20 = a[8]; + a21 = a[9]; + a22 = a[10]; + a23 = a[11]; + out[0] = a00; + out[1] = a01; + out[2] = a02; + out[3] = a03; + out[4] = a10; + out[5] = a11; + out[6] = a12; + out[7] = a13; + out[8] = a20; + out[9] = a21; + out[10] = a22; + out[11] = a23; + out[12] = a00 * x + a10 * y + a20 * z + a[12]; + out[13] = a01 * x + a11 * y + a21 * z + a[13]; + out[14] = a02 * x + a12 * y + a22 * z + a[14]; + out[15] = a03 * x + a13 * y + a23 * z + a[15]; + } + + return out; +} +/** + * Scales the mat4 by the dimensions in the given vec3 not using vectorization + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to scale + * @param {ReadonlyVec3} v the vec3 to scale the matrix by + * @returns {mat4} out + **/ + +function scale$5(out, a, v) { + var x = v[0], + y = v[1], + z = v[2]; + out[0] = a[0] * x; + out[1] = a[1] * x; + out[2] = a[2] * x; + out[3] = a[3] * x; + out[4] = a[4] * y; + out[5] = a[5] * y; + out[6] = a[6] * y; + out[7] = a[7] * y; + out[8] = a[8] * z; + out[9] = a[9] * z; + out[10] = a[10] * z; + out[11] = a[11] * z; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} +/** + * Rotates a mat4 by the given angle around the given axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @param {ReadonlyVec3} axis the axis to rotate around + * @returns {mat4} out + */ + +function rotate$1(out, a, rad, axis) { + var x = axis[0], + y = axis[1], + z = axis[2]; + var len = Math.hypot(x, y, z); + var s, c, t; + var a00, a01, a02, a03; + var a10, a11, a12, a13; + var a20, a21, a22, a23; + var b00, b01, b02; + var b10, b11, b12; + var b20, b21, b22; + + if (len < EPSILON) { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + a00 = a[0]; + a01 = a[1]; + a02 = a[2]; + a03 = a[3]; + a10 = a[4]; + a11 = a[5]; + a12 = a[6]; + a13 = a[7]; + a20 = a[8]; + a21 = a[9]; + a22 = a[10]; + a23 = a[11]; // Construct the elements of the rotation matrix + + b00 = x * x * t + c; + b01 = y * x * t + z * s; + b02 = z * x * t - y * s; + b10 = x * y * t - z * s; + b11 = y * y * t + c; + b12 = z * y * t + x * s; + b20 = x * z * t + y * s; + b21 = y * z * t - x * s; + b22 = z * z * t + c; // Perform rotation-specific matrix multiplication + + out[0] = a00 * b00 + a10 * b01 + a20 * b02; + out[1] = a01 * b00 + a11 * b01 + a21 * b02; + out[2] = a02 * b00 + a12 * b01 + a22 * b02; + out[3] = a03 * b00 + a13 * b01 + a23 * b02; + out[4] = a00 * b10 + a10 * b11 + a20 * b12; + out[5] = a01 * b10 + a11 * b11 + a21 * b12; + out[6] = a02 * b10 + a12 * b11 + a22 * b12; + out[7] = a03 * b10 + a13 * b11 + a23 * b12; + out[8] = a00 * b20 + a10 * b21 + a20 * b22; + out[9] = a01 * b20 + a11 * b21 + a21 * b22; + out[10] = a02 * b20 + a12 * b21 + a22 * b22; + out[11] = a03 * b20 + a13 * b21 + a23 * b22; + + if (a !== out) { + // If the source and destination differ, copy the unchanged last row + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + return out; +} +/** + * Rotates a matrix by the given angle around the X axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + +function rotateX$3(out, a, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + if (a !== out) { + // If the source and destination differ, copy the unchanged rows + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } // Perform axis-specific matrix multiplication + + + out[4] = a10 * c + a20 * s; + out[5] = a11 * c + a21 * s; + out[6] = a12 * c + a22 * s; + out[7] = a13 * c + a23 * s; + out[8] = a20 * c - a10 * s; + out[9] = a21 * c - a11 * s; + out[10] = a22 * c - a12 * s; + out[11] = a23 * c - a13 * s; + return out; +} +/** + * Rotates a matrix by the given angle around the Y axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + +function rotateY$3(out, a, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + if (a !== out) { + // If the source and destination differ, copy the unchanged rows + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } // Perform axis-specific matrix multiplication + + + out[0] = a00 * c - a20 * s; + out[1] = a01 * c - a21 * s; + out[2] = a02 * c - a22 * s; + out[3] = a03 * c - a23 * s; + out[8] = a00 * s + a20 * c; + out[9] = a01 * s + a21 * c; + out[10] = a02 * s + a22 * c; + out[11] = a03 * s + a23 * c; + return out; +} +/** + * Rotates a matrix by the given angle around the Z axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + +function rotateZ$3(out, a, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + if (a !== out) { + // If the source and destination differ, copy the unchanged last row + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } // Perform axis-specific matrix multiplication + + + out[0] = a00 * c + a10 * s; + out[1] = a01 * c + a11 * s; + out[2] = a02 * c + a12 * s; + out[3] = a03 * c + a13 * s; + out[4] = a10 * c - a00 * s; + out[5] = a11 * c - a01 * s; + out[6] = a12 * c - a02 * s; + out[7] = a13 * c - a03 * s; + return out; +} +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {ReadonlyVec3} v Translation vector + * @returns {mat4} out + */ + +function fromTranslation$1(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; +} +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.scale(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {ReadonlyVec3} v Scaling vector + * @returns {mat4} out + */ + +function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = v[1]; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = v[2]; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Creates a matrix from a given angle around a given axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotate(dest, dest, rad, axis); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @param {ReadonlyVec3} axis the axis to rotate around + * @returns {mat4} out + */ + +function fromRotation$1(out, rad, axis) { + var x = axis[0], + y = axis[1], + z = axis[2]; + var len = Math.hypot(x, y, z); + var s, c, t; + + if (len < EPSILON) { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; // Perform rotation-specific matrix multiplication + + out[0] = x * x * t + c; + out[1] = y * x * t + z * s; + out[2] = z * x * t - y * s; + out[3] = 0; + out[4] = x * y * t - z * s; + out[5] = y * y * t + c; + out[6] = z * y * t + x * s; + out[7] = 0; + out[8] = x * z * t + y * s; + out[9] = y * z * t - x * s; + out[10] = z * z * t + c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Creates a matrix from the given angle around the X axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateX(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + +function fromXRotation(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); // Perform axis-specific matrix multiplication + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = c; + out[6] = s; + out[7] = 0; + out[8] = 0; + out[9] = -s; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Creates a matrix from the given angle around the Y axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateY(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + +function fromYRotation(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); // Perform axis-specific matrix multiplication + + out[0] = c; + out[1] = 0; + out[2] = -s; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = s; + out[9] = 0; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Creates a matrix from the given angle around the Z axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateZ(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + +function fromZRotation(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); // Perform axis-specific matrix multiplication + + out[0] = c; + out[1] = s; + out[2] = 0; + out[3] = 0; + out[4] = -s; + out[5] = c; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Creates a matrix from a quaternion rotation and vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @returns {mat4} out + */ + +function fromRotationTranslation$1(out, q, v) { + // Quaternion math + var x = q[0], + y = q[1], + z = q[2], + w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; +} +/** + * Creates a new mat4 from a dual quat. + * + * @param {mat4} out Matrix + * @param {ReadonlyQuat2} a Dual Quaternion + * @returns {mat4} mat4 receiving operation result + */ + +function fromQuat2(out, a) { + var translation = new ARRAY_TYPE(3); + var bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7]; + var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense + + if (magnitude > 0) { + translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude; + translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude; + translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude; + } else { + translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; + translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; + translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; + } + + fromRotationTranslation$1(out, a, translation); + return out; +} +/** + * Returns the translation vector component of a transformation + * matrix. If a matrix is built with fromRotationTranslation, + * the returned vector will be the same as the translation vector + * originally supplied. + * @param {vec3} out Vector to receive translation component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ + +function getTranslation$1(out, mat) { + out[0] = mat[12]; + out[1] = mat[13]; + out[2] = mat[14]; + return out; +} +/** + * Returns the scaling factor component of a transformation + * matrix. If a matrix is built with fromRotationTranslationScale + * with a normalized Quaternion paramter, the returned vector will be + * the same as the scaling vector + * originally supplied. + * @param {vec3} out Vector to receive scaling factor component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ + +function getScaling(out, mat) { + var m11 = mat[0]; + var m12 = mat[1]; + var m13 = mat[2]; + var m21 = mat[4]; + var m22 = mat[5]; + var m23 = mat[6]; + var m31 = mat[8]; + var m32 = mat[9]; + var m33 = mat[10]; + out[0] = Math.hypot(m11, m12, m13); + out[1] = Math.hypot(m21, m22, m23); + out[2] = Math.hypot(m31, m32, m33); + return out; +} +/** + * Returns a quaternion representing the rotational component + * of a transformation matrix. If a matrix is built with + * fromRotationTranslation, the returned quaternion will be the + * same as the quaternion originally supplied. + * @param {quat} out Quaternion to receive the rotation component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {quat} out + */ + +function getRotation(out, mat) { + var scaling = new ARRAY_TYPE(3); + getScaling(scaling, mat); + var is1 = 1 / scaling[0]; + var is2 = 1 / scaling[1]; + var is3 = 1 / scaling[2]; + var sm11 = mat[0] * is1; + var sm12 = mat[1] * is2; + var sm13 = mat[2] * is3; + var sm21 = mat[4] * is1; + var sm22 = mat[5] * is2; + var sm23 = mat[6] * is3; + var sm31 = mat[8] * is1; + var sm32 = mat[9] * is2; + var sm33 = mat[10] * is3; + var trace = sm11 + sm22 + sm33; + var S = 0; + + if (trace > 0) { + S = Math.sqrt(trace + 1.0) * 2; + out[3] = 0.25 * S; + out[0] = (sm23 - sm32) / S; + out[1] = (sm31 - sm13) / S; + out[2] = (sm12 - sm21) / S; + } else if (sm11 > sm22 && sm11 > sm33) { + S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2; + out[3] = (sm23 - sm32) / S; + out[0] = 0.25 * S; + out[1] = (sm12 + sm21) / S; + out[2] = (sm31 + sm13) / S; + } else if (sm22 > sm33) { + S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2; + out[3] = (sm31 - sm13) / S; + out[0] = (sm12 + sm21) / S; + out[1] = 0.25 * S; + out[2] = (sm23 + sm32) / S; + } else { + S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2; + out[3] = (sm12 - sm21) / S; + out[0] = (sm31 + sm13) / S; + out[1] = (sm23 + sm32) / S; + out[2] = 0.25 * S; + } + + return out; +} +/** + * Creates a matrix from a quaternion rotation, vector translation and vector scale + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @param {ReadonlyVec3} s Scaling vector + * @returns {mat4} out + */ + +function fromRotationTranslationScale(out, q, v, s) { + // Quaternion math + var x = q[0], + y = q[1], + z = q[2], + w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = s[0]; + var sy = s[1]; + var sz = s[2]; + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; +} +/** + * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * mat4.translate(dest, origin); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * mat4.translate(dest, negativeOrigin); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @param {ReadonlyVec3} s Scaling vector + * @param {ReadonlyVec3} o The origin vector around which to scale and rotate + * @returns {mat4} out + */ + +function fromRotationTranslationScaleOrigin(out, q, v, s, o) { + // Quaternion math + var x = q[0], + y = q[1], + z = q[2], + w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = s[0]; + var sy = s[1]; + var sz = s[2]; + var ox = o[0]; + var oy = o[1]; + var oz = o[2]; + var out0 = (1 - (yy + zz)) * sx; + var out1 = (xy + wz) * sx; + var out2 = (xz - wy) * sx; + var out4 = (xy - wz) * sy; + var out5 = (1 - (xx + zz)) * sy; + var out6 = (yz + wx) * sy; + var out8 = (xz + wy) * sz; + var out9 = (yz - wx) * sz; + var out10 = (1 - (xx + yy)) * sz; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = 0; + out[4] = out4; + out[5] = out5; + out[6] = out6; + out[7] = 0; + out[8] = out8; + out[9] = out9; + out[10] = out10; + out[11] = 0; + out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz); + out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz); + out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz); + out[15] = 1; + return out; +} +/** + * Calculates a 4x4 matrix from the given quaternion + * + * @param {mat4} out mat4 receiving operation result + * @param {ReadonlyQuat} q Quaternion to create matrix from + * + * @returns {mat4} out + */ + +function fromQuat(out, q) { + var x = q[0], + y = q[1], + z = q[2], + w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var yx = y * x2; + var yy = y * y2; + var zx = z * x2; + var zy = z * y2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = 1 - yy - zz; + out[1] = yx + wz; + out[2] = zx - wy; + out[3] = 0; + out[4] = yx - wz; + out[5] = 1 - xx - zz; + out[6] = zy + wx; + out[7] = 0; + out[8] = zx + wy; + out[9] = zy - wx; + out[10] = 1 - xx - yy; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +/** + * Generates a frustum matrix with the given bounds + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Number} left Left bound of the frustum + * @param {Number} right Right bound of the frustum + * @param {Number} bottom Bottom bound of the frustum + * @param {Number} top Top bound of the frustum + * @param {Number} near Near bound of the frustum + * @param {Number} far Far bound of the frustum + * @returns {mat4} out + */ + +function frustum(out, left, right, bottom, top, near, far) { + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + out[0] = near * 2 * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = near * 2 * tb; + out[6] = 0; + out[7] = 0; + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = far * near * 2 * nf; + out[15] = 0; + return out; +} +/** + * Generates a perspective projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {mat4} out + */ + +function perspectiveNO(out, fovy, aspect, near, far) { + var f = 1.0 / Math.tan(fovy / 2), + nf; + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[15] = 0; + + if (far != null && far !== Infinity) { + nf = 1 / (near - far); + out[10] = (far + near) * nf; + out[14] = 2 * far * near * nf; + } else { + out[10] = -1; + out[14] = -2 * near; + } + + return out; +} +/** + * Alias for {@link mat4.perspectiveNO} + * @function + */ + +var perspective = perspectiveNO; +/** + * Generates a perspective projection matrix suitable for WebGPU with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], + * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {mat4} out + */ + +function perspectiveZO(out, fovy, aspect, near, far) { + var f = 1.0 / Math.tan(fovy / 2), + nf; + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[15] = 0; + + if (far != null && far !== Infinity) { + nf = 1 / (near - far); + out[10] = far * nf; + out[14] = far * near * nf; + } else { + out[10] = -1; + out[14] = -near; + } + + return out; +} +/** + * Generates a perspective projection matrix with the given field of view. + * This is primarily useful for generating projection matrices to be used + * with the still experiemental WebVR API. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ + +function perspectiveFromFieldOfView(out, fov, near, far) { + var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0); + var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0); + var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0); + var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0); + var xScale = 2.0 / (leftTan + rightTan); + var yScale = 2.0 / (upTan + downTan); + out[0] = xScale; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; + out[4] = 0.0; + out[5] = yScale; + out[6] = 0.0; + out[7] = 0.0; + out[8] = -((leftTan - rightTan) * xScale * 0.5); + out[9] = (upTan - downTan) * yScale * 0.5; + out[10] = far / (near - far); + out[11] = -1.0; + out[12] = 0.0; + out[13] = 0.0; + out[14] = far * near / (near - far); + out[15] = 0.0; + return out; +} +/** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ + +function orthoNO(out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right); + var bt = 1 / (bottom - top); + var nf = 1 / (near - far); + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + return out; +} +/** + * Alias for {@link mat4.orthoNO} + * @function + */ + +var ortho = orthoNO; +/** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], + * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ + +function orthoZO(out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right); + var bt = 1 / (bottom - top); + var nf = 1 / (near - far); + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = nf; + out[11] = 0; + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = near * nf; + out[15] = 1; + return out; +} +/** + * Generates a look-at matrix with the given eye position, focal point, and up axis. + * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {ReadonlyVec3} eye Position of the viewer + * @param {ReadonlyVec3} center Point the viewer is looking at + * @param {ReadonlyVec3} up vec3 pointing up + * @returns {mat4} out + */ + +function lookAt(out, eye, center, up) { + var x0, x1, x2, y0, y1, y2, z0, z1, z2, len; + var eyex = eye[0]; + var eyey = eye[1]; + var eyez = eye[2]; + var upx = up[0]; + var upy = up[1]; + var upz = up[2]; + var centerx = center[0]; + var centery = center[1]; + var centerz = center[2]; + + if (Math.abs(eyex - centerx) < EPSILON && Math.abs(eyey - centery) < EPSILON && Math.abs(eyez - centerz) < EPSILON) { + return identity$2(out); + } + + z0 = eyex - centerx; + z1 = eyey - centery; + z2 = eyez - centerz; + len = 1 / Math.hypot(z0, z1, z2); + z0 *= len; + z1 *= len; + z2 *= len; + x0 = upy * z2 - upz * z1; + x1 = upz * z0 - upx * z2; + x2 = upx * z1 - upy * z0; + len = Math.hypot(x0, x1, x2); + + if (!len) { + x0 = 0; + x1 = 0; + x2 = 0; + } else { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + y0 = z1 * x2 - z2 * x1; + y1 = z2 * x0 - z0 * x2; + y2 = z0 * x1 - z1 * x0; + len = Math.hypot(y0, y1, y2); + + if (!len) { + y0 = 0; + y1 = 0; + y2 = 0; + } else { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + return out; +} +/** + * Generates a matrix that makes something look at something else. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {ReadonlyVec3} eye Position of the viewer + * @param {ReadonlyVec3} center Point the viewer is looking at + * @param {ReadonlyVec3} up vec3 pointing up + * @returns {mat4} out + */ + +function targetTo(out, eye, target, up) { + var eyex = eye[0], + eyey = eye[1], + eyez = eye[2], + upx = up[0], + upy = up[1], + upz = up[2]; + var z0 = eyex - target[0], + z1 = eyey - target[1], + z2 = eyez - target[2]; + var len = z0 * z0 + z1 * z1 + z2 * z2; + + if (len > 0) { + len = 1 / Math.sqrt(len); + z0 *= len; + z1 *= len; + z2 *= len; + } + + var x0 = upy * z2 - upz * z1, + x1 = upz * z0 - upx * z2, + x2 = upx * z1 - upy * z0; + len = x0 * x0 + x1 * x1 + x2 * x2; + + if (len > 0) { + len = 1 / Math.sqrt(len); + x0 *= len; + x1 *= len; + x2 *= len; + } + + out[0] = x0; + out[1] = x1; + out[2] = x2; + out[3] = 0; + out[4] = z1 * x2 - z2 * x1; + out[5] = z2 * x0 - z0 * x2; + out[6] = z0 * x1 - z1 * x0; + out[7] = 0; + out[8] = z0; + out[9] = z1; + out[10] = z2; + out[11] = 0; + out[12] = eyex; + out[13] = eyey; + out[14] = eyez; + out[15] = 1; + return out; +} +/** + * Returns a string representation of a mat4 + * + * @param {ReadonlyMat4} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ + +function str$5(a) { + return "mat4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ", " + a[9] + ", " + a[10] + ", " + a[11] + ", " + a[12] + ", " + a[13] + ", " + a[14] + ", " + a[15] + ")"; +} +/** + * Returns Frobenius norm of a mat4 + * + * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ + +function frob(a) { + return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); +} +/** + * Adds two mat4's + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {mat4} out + */ + +function add$5(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + out[9] = a[9] + b[9]; + out[10] = a[10] + b[10]; + out[11] = a[11] + b[11]; + out[12] = a[12] + b[12]; + out[13] = a[13] + b[13]; + out[14] = a[14] + b[14]; + out[15] = a[15] + b[15]; + return out; +} +/** + * Subtracts matrix b from matrix a + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {mat4} out + */ + +function subtract$3(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + out[9] = a[9] - b[9]; + out[10] = a[10] - b[10]; + out[11] = a[11] - b[11]; + out[12] = a[12] - b[12]; + out[13] = a[13] - b[13]; + out[14] = a[14] - b[14]; + out[15] = a[15] - b[15]; + return out; +} +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat4} out + */ + +function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + out[9] = a[9] * b; + out[10] = a[10] * b; + out[11] = a[11] * b; + out[12] = a[12] * b; + out[13] = a[13] * b; + out[14] = a[14] * b; + out[15] = a[15] * b; + return out; +} +/** + * Adds two mat4's after multiplying each element of the second operand by a scalar value. + * + * @param {mat4} out the receiving vector + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat4} out + */ + +function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; + out[4] = a[4] + b[4] * scale; + out[5] = a[5] + b[5] * scale; + out[6] = a[6] + b[6] * scale; + out[7] = a[7] + b[7] * scale; + out[8] = a[8] + b[8] * scale; + out[9] = a[9] + b[9] * scale; + out[10] = a[10] + b[10] * scale; + out[11] = a[11] + b[11] * scale; + out[12] = a[12] + b[12] * scale; + out[13] = a[13] + b[13] * scale; + out[14] = a[14] + b[14] * scale; + out[15] = a[15] + b[15] * scale; + return out; +} +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyMat4} a The first matrix. + * @param {ReadonlyMat4} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function exactEquals$5(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; +} +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {ReadonlyMat4} a The first matrix. + * @param {ReadonlyMat4} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ + +function equals$6(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var a4 = a[4], + a5 = a[5], + a6 = a[6], + a7 = a[7]; + var a8 = a[8], + a9 = a[9], + a10 = a[10], + a11 = a[11]; + var a12 = a[12], + a13 = a[13], + a14 = a[14], + a15 = a[15]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3]; + var b4 = b[4], + b5 = b[5], + b6 = b[6], + b7 = b[7]; + var b8 = b[8], + b9 = b[9], + b10 = b[10], + b11 = b[11]; + var b12 = b[12], + b13 = b[13], + b14 = b[14], + b15 = b[15]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15)); +} +/** + * Alias for {@link mat4.multiply} + * @function + */ + +var mul$5 = multiply$5; +/** + * Alias for {@link mat4.subtract} + * @function + */ + +var sub$3 = subtract$3; + +var mat4 = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$5, +adjoint: adjoint, +clone: clone$5, +copy: copy$5, +create: create$5, +determinant: determinant, +equals: equals$6, +exactEquals: exactEquals$5, +frob: frob, +fromQuat: fromQuat, +fromQuat2: fromQuat2, +fromRotation: fromRotation$1, +fromRotationTranslation: fromRotationTranslation$1, +fromRotationTranslationScale: fromRotationTranslationScale, +fromRotationTranslationScaleOrigin: fromRotationTranslationScaleOrigin, +fromScaling: fromScaling, +fromTranslation: fromTranslation$1, +fromValues: fromValues$5, +fromXRotation: fromXRotation, +fromYRotation: fromYRotation, +fromZRotation: fromZRotation, +frustum: frustum, +getRotation: getRotation, +getScaling: getScaling, +getTranslation: getTranslation$1, +identity: identity$2, +invert: invert$2, +lookAt: lookAt, +mul: mul$5, +multiply: multiply$5, +multiplyScalar: multiplyScalar, +multiplyScalarAndAdd: multiplyScalarAndAdd, +ortho: ortho, +orthoNO: orthoNO, +orthoZO: orthoZO, +perspective: perspective, +perspectiveFromFieldOfView: perspectiveFromFieldOfView, +perspectiveNO: perspectiveNO, +perspectiveZO: perspectiveZO, +rotate: rotate$1, +rotateX: rotateX$3, +rotateY: rotateY$3, +rotateZ: rotateZ$3, +scale: scale$5, +set: set$5, +str: str$5, +sub: sub$3, +subtract: subtract$3, +targetTo: targetTo, +translate: translate$1, +transpose: transpose +}); + +/** + * 3 Dimensional Vector + * @module vec3 + */ + +/** + * Creates a new, empty vec3 + * + * @returns {vec3} a new 3D vector + */ + +function create$4() { + var out = new ARRAY_TYPE(3); + + if (ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } + + return out; +} +/** + * Creates a new vec3 initialized with values from an existing vector + * + * @param {ReadonlyVec3} a vector to clone + * @returns {vec3} a new 3D vector + */ + +function clone$4(a) { + var out = new ARRAY_TYPE(3); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} +/** + * Calculates the length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate length of + * @returns {Number} length of a + */ + +function length$4(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + return Math.hypot(x, y, z); +} +/** + * Creates a new vec3 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} a new 3D vector + */ + +function fromValues$4(x, y, z) { + var out = new ARRAY_TYPE(3); + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} +/** + * Copy the values from one vec3 to another + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the source vector + * @returns {vec3} out + */ + +function copy$4(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} +/** + * Set the components of a vec3 to the given values + * + * @param {vec3} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} out + */ + +function set$4(out, x, y, z) { + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} +/** + * Adds two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function add$4(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + return out; +} +/** + * Subtracts vector b from vector a + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function subtract$2(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + return out; +} +/** + * Multiplies two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function multiply$4(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + return out; +} +/** + * Divides two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function divide$2(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + return out; +} +/** + * Math.ceil the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to ceil + * @returns {vec3} out + */ + +function ceil$2(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + return out; +} +/** + * Math.floor the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to floor + * @returns {vec3} out + */ + +function floor$2(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + return out; +} +/** + * Returns the minimum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function min$2(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + return out; +} +/** + * Returns the maximum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function max$2(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + return out; +} +/** + * Math.round the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to round + * @returns {vec3} out + */ + +function round$2(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + return out; +} +/** + * Scales a vec3 by a scalar number + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec3} out + */ + +function scale$4(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + return out; +} +/** + * Adds two vec3's after scaling the second operand by a scalar value + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec3} out + */ + +function scaleAndAdd$2(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + return out; +} +/** + * Calculates the euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} distance between a and b + */ + +function distance$2(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + return Math.hypot(x, y, z); +} +/** + * Calculates the squared euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} squared distance between a and b + */ + +function squaredDistance$2(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + return x * x + y * y + z * z; +} +/** + * Calculates the squared length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + +function squaredLength$4(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + return x * x + y * y + z * z; +} +/** + * Negates the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to negate + * @returns {vec3} out + */ + +function negate$2(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + return out; +} +/** + * Returns the inverse of the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to invert + * @returns {vec3} out + */ + +function inverse$2(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + return out; +} +/** + * Normalize a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to normalize + * @returns {vec3} out + */ + +function normalize$4(out, a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var len = x * x + y * y + z * z; + + if (len > 0) { + //TODO: evaluate use of glm_invsqrt here? + len = 1 / Math.sqrt(len); + } + + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; + return out; +} +/** + * Calculates the dot product of two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} dot product of a and b + */ + +function dot$5(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} +/** + * Computes the cross product of two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ + +function cross$2(out, a, b) { + var ax = a[0], + ay = a[1], + az = a[2]; + var bx = b[0], + by = b[1], + bz = b[2]; + out[0] = ay * bz - az * by; + out[1] = az * bx - ax * bz; + out[2] = ax * by - ay * bx; + return out; +} +/** + * Performs a linear interpolation between two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ + +function lerp$4(out, a, b, t) { + var ax = a[0]; + var ay = a[1]; + var az = a[2]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + return out; +} +/** + * Performs a hermite interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec3} c the third operand + * @param {ReadonlyVec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ + +function hermite(out, a, b, c, d, t) { + var factorTimes2 = t * t; + var factor1 = factorTimes2 * (2 * t - 3) + 1; + var factor2 = factorTimes2 * (t - 2) + t; + var factor3 = factorTimes2 * (t - 1); + var factor4 = factorTimes2 * (3 - 2 * t); + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + return out; +} +/** + * Performs a bezier interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec3} c the third operand + * @param {ReadonlyVec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ + +function bezier(out, a, b, c, d, t) { + var inverseFactor = 1 - t; + var inverseFactorTimesTwo = inverseFactor * inverseFactor; + var factorTimes2 = t * t; + var factor1 = inverseFactorTimesTwo * inverseFactor; + var factor2 = 3 * t * inverseFactorTimesTwo; + var factor3 = 3 * factorTimes2 * inverseFactor; + var factor4 = factorTimes2 * t; + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + return out; +} +/** + * Generates a random vector with the given scale + * + * @param {vec3} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec3} out + */ + +function random$3(out, scale) { + scale = scale || 1.0; + var r = RANDOM() * 2.0 * Math.PI; + var z = RANDOM() * 2.0 - 1.0; + var zScale = Math.sqrt(1.0 - z * z) * scale; + out[0] = Math.cos(r) * zScale; + out[1] = Math.sin(r) * zScale; + out[2] = z * scale; + return out; +} +/** + * Transforms the vec3 with a mat4. + * 4th vector component is implicitly '1' + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {vec3} out + */ + +function transformMat4$2(out, a, m) { + var x = a[0], + y = a[1], + z = a[2]; + var w = m[3] * x + m[7] * y + m[11] * z + m[15]; + w = w || 1.0; + out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return out; +} +/** + * Transforms the vec3 with a mat3. + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyMat3} m the 3x3 matrix to transform with + * @returns {vec3} out + */ + +function transformMat3$1(out, a, m) { + var x = a[0], + y = a[1], + z = a[2]; + out[0] = x * m[0] + y * m[3] + z * m[6]; + out[1] = x * m[1] + y * m[4] + z * m[7]; + out[2] = x * m[2] + y * m[5] + z * m[8]; + return out; +} +/** + * Transforms the vec3 with a quat + * Can also be used for dual quaternions. (Multiply it with the real part) + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyQuat} q quaternion to transform with + * @returns {vec3} out + */ + +function transformQuat$1(out, a, q) { + // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed + var qx = q[0], + qy = q[1], + qz = q[2], + qw = q[3]; + var x = a[0], + y = a[1], + z = a[2]; // var qvec = [qx, qy, qz]; + // var uv = vec3.cross([], qvec, a); + + var uvx = qy * z - qz * y, + uvy = qz * x - qx * z, + uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv); + + var uuvx = qy * uvz - qz * uvy, + uuvy = qz * uvx - qx * uvz, + uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w); + + var w2 = qw * 2; + uvx *= w2; + uvy *= w2; + uvz *= w2; // vec3.scale(uuv, uuv, 2); + + uuvx *= 2; + uuvy *= 2; + uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv)); + + out[0] = x + uvx + uuvx; + out[1] = y + uvy + uuvy; + out[2] = z + uvz + uuvz; + return out; +} +/** + * Rotate a 3D vector around the x-axis + * @param {vec3} out The receiving vec3 + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec3} out + */ + +function rotateX$2(out, a, b, rad) { + var p = [], + r = []; //Translate point to the origin + + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; //perform rotation + + r[0] = p[0]; + r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad); + r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position + + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + return out; +} +/** + * Rotate a 3D vector around the y-axis + * @param {vec3} out The receiving vec3 + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec3} out + */ + +function rotateY$2(out, a, b, rad) { + var p = [], + r = []; //Translate point to the origin + + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; //perform rotation + + r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad); + r[1] = p[1]; + r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position + + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + return out; +} +/** + * Rotate a 3D vector around the z-axis + * @param {vec3} out The receiving vec3 + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec3} out + */ + +function rotateZ$2(out, a, b, rad) { + var p = [], + r = []; //Translate point to the origin + + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; //perform rotation + + r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad); + r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad); + r[2] = p[2]; //translate to correct position + + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + return out; +} +/** + * Get the angle between two 3D vectors + * @param {ReadonlyVec3} a The first operand + * @param {ReadonlyVec3} b The second operand + * @returns {Number} The angle in radians + */ + +function angle$1(a, b) { + var ax = a[0], + ay = a[1], + az = a[2], + bx = b[0], + by = b[1], + bz = b[2], + mag1 = Math.sqrt(ax * ax + ay * ay + az * az), + mag2 = Math.sqrt(bx * bx + by * by + bz * bz), + mag = mag1 * mag2, + cosine = mag && dot$5(a, b) / mag; + return Math.acos(Math.min(Math.max(cosine, -1), 1)); +} +/** + * Set the components of a vec3 to zero + * + * @param {vec3} out the receiving vector + * @returns {vec3} out + */ + +function zero$2(out) { + out[0] = 0.0; + out[1] = 0.0; + out[2] = 0.0; + return out; +} +/** + * Returns a string representation of a vector + * + * @param {ReadonlyVec3} a vector to represent as a string + * @returns {String} string representation of the vector + */ + +function str$4(a) { + return "vec3(" + a[0] + ", " + a[1] + ", " + a[2] + ")"; +} +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec3} a The first vector. + * @param {ReadonlyVec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +function exactEquals$4(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +} +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec3} a The first vector. + * @param {ReadonlyVec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +function equals$5(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2]; + var b0 = b[0], + b1 = b[1], + b2 = b[2]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)); +} +/** + * Alias for {@link vec3.subtract} + * @function + */ + +var sub$2 = subtract$2; +/** + * Alias for {@link vec3.multiply} + * @function + */ + +var mul$4 = multiply$4; +/** + * Alias for {@link vec3.divide} + * @function + */ + +var div$2 = divide$2; +/** + * Alias for {@link vec3.distance} + * @function + */ + +var dist$2 = distance$2; +/** + * Alias for {@link vec3.squaredDistance} + * @function + */ + +var sqrDist$2 = squaredDistance$2; +/** + * Alias for {@link vec3.length} + * @function + */ + +var len$4 = length$4; +/** + * Alias for {@link vec3.squaredLength} + * @function + */ + +var sqrLen$4 = squaredLength$4; +/** + * Perform some operation over an array of vec3s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ + +var forEach$2 = function () { + var vec = create$4(); + return function (a, stride, offset, count, fn, arg) { + var i, l; + + if (!stride) { + stride = 3; + } + + if (!offset) { + offset = 0; + } + + if (count) { + l = Math.min(count * stride + offset, a.length); + } else { + l = a.length; + } + + for (i = offset; i < l; i += stride) { + vec[0] = a[i]; + vec[1] = a[i + 1]; + vec[2] = a[i + 2]; + fn(vec, vec, arg); + a[i] = vec[0]; + a[i + 1] = vec[1]; + a[i + 2] = vec[2]; + } + + return a; + }; +}(); + +var vec3 = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$4, +angle: angle$1, +bezier: bezier, +ceil: ceil$2, +clone: clone$4, +copy: copy$4, +create: create$4, +cross: cross$2, +dist: dist$2, +distance: distance$2, +div: div$2, +divide: divide$2, +dot: dot$5, +equals: equals$5, +exactEquals: exactEquals$4, +floor: floor$2, +forEach: forEach$2, +fromValues: fromValues$4, +hermite: hermite, +inverse: inverse$2, +len: len$4, +length: length$4, +lerp: lerp$4, +max: max$2, +min: min$2, +mul: mul$4, +multiply: multiply$4, +negate: negate$2, +normalize: normalize$4, +random: random$3, +rotateX: rotateX$2, +rotateY: rotateY$2, +rotateZ: rotateZ$2, +round: round$2, +scale: scale$4, +scaleAndAdd: scaleAndAdd$2, +set: set$4, +sqrDist: sqrDist$2, +sqrLen: sqrLen$4, +squaredDistance: squaredDistance$2, +squaredLength: squaredLength$4, +str: str$4, +sub: sub$2, +subtract: subtract$2, +transformMat3: transformMat3$1, +transformMat4: transformMat4$2, +transformQuat: transformQuat$1, +zero: zero$2 +}); + +/** + * 4 Dimensional Vector + * @module vec4 + */ + +/** + * Creates a new, empty vec4 + * + * @returns {vec4} a new 4D vector + */ + +function create$3() { + var out = new ARRAY_TYPE(4); + + if (ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + } + + return out; +} +/** + * Creates a new vec4 initialized with values from an existing vector + * + * @param {ReadonlyVec4} a vector to clone + * @returns {vec4} a new 4D vector + */ + +function clone$3(a) { + var out = new ARRAY_TYPE(4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} +/** + * Creates a new vec4 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} a new 4D vector + */ + +function fromValues$3(x, y, z, w) { + var out = new ARRAY_TYPE(4); + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; + return out; +} +/** + * Copy the values from one vec4 to another + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the source vector + * @returns {vec4} out + */ + +function copy$3(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} +/** + * Set the components of a vec4 to the given values + * + * @param {vec4} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} out + */ + +function set$3(out, x, y, z, w) { + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; + return out; +} +/** + * Adds two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ + +function add$3(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + return out; +} +/** + * Subtracts vector b from vector a + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ + +function subtract$1(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + return out; +} +/** + * Multiplies two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ + +function multiply$3(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + out[3] = a[3] * b[3]; + return out; +} +/** + * Divides two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ + +function divide$1(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + out[3] = a[3] / b[3]; + return out; +} +/** + * Math.ceil the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to ceil + * @returns {vec4} out + */ + +function ceil$1(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + out[3] = Math.ceil(a[3]); + return out; +} +/** + * Math.floor the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to floor + * @returns {vec4} out + */ + +function floor$1(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + out[3] = Math.floor(a[3]); + return out; +} +/** + * Returns the minimum of two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ + +function min$1(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + out[3] = Math.min(a[3], b[3]); + return out; +} +/** + * Returns the maximum of two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ + +function max$1(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + out[3] = Math.max(a[3], b[3]); + return out; +} +/** + * Math.round the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to round + * @returns {vec4} out + */ + +function round$1(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + out[3] = Math.round(a[3]); + return out; +} +/** + * Scales a vec4 by a scalar number + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec4} out + */ + +function scale$3(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + return out; +} +/** + * Adds two vec4's after scaling the second operand by a scalar value + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec4} out + */ + +function scaleAndAdd$1(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; + return out; +} +/** + * Calculates the euclidian distance between two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} distance between a and b + */ + +function distance$1(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + var w = b[3] - a[3]; + return Math.hypot(x, y, z, w); +} +/** + * Calculates the squared euclidian distance between two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} squared distance between a and b + */ + +function squaredDistance$1(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + var w = b[3] - a[3]; + return x * x + y * y + z * z + w * w; +} +/** + * Calculates the length of a vec4 + * + * @param {ReadonlyVec4} a vector to calculate length of + * @returns {Number} length of a + */ + +function length$3(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var w = a[3]; + return Math.hypot(x, y, z, w); +} +/** + * Calculates the squared length of a vec4 + * + * @param {ReadonlyVec4} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + +function squaredLength$3(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var w = a[3]; + return x * x + y * y + z * z + w * w; +} +/** + * Negates the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to negate + * @returns {vec4} out + */ + +function negate$1(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = -a[3]; + return out; +} +/** + * Returns the inverse of the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to invert + * @returns {vec4} out + */ + +function inverse$1(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + out[3] = 1.0 / a[3]; + return out; +} +/** + * Normalize a vec4 + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to normalize + * @returns {vec4} out + */ + +function normalize$3(out, a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var w = a[3]; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) { + len = 1 / Math.sqrt(len); + } + + out[0] = x * len; + out[1] = y * len; + out[2] = z * len; + out[3] = w * len; + return out; +} +/** + * Calculates the dot product of two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} dot product of a and b + */ + +function dot$4(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; +} +/** + * Returns the cross-product of three vectors in a 4-dimensional space + * + * @param {ReadonlyVec4} result the receiving vector + * @param {ReadonlyVec4} U the first vector + * @param {ReadonlyVec4} V the second vector + * @param {ReadonlyVec4} W the third vector + * @returns {vec4} result + */ + +function cross$1(out, u, v, w) { + var A = v[0] * w[1] - v[1] * w[0], + B = v[0] * w[2] - v[2] * w[0], + C = v[0] * w[3] - v[3] * w[0], + D = v[1] * w[2] - v[2] * w[1], + E = v[1] * w[3] - v[3] * w[1], + F = v[2] * w[3] - v[3] * w[2]; + var G = u[0]; + var H = u[1]; + var I = u[2]; + var J = u[3]; + out[0] = H * F - I * E + J * D; + out[1] = -(G * F) + I * C - J * B; + out[2] = G * E - H * C + J * A; + out[3] = -(G * D) + H * B - I * A; + return out; +} +/** + * Performs a linear interpolation between two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec4} out + */ + +function lerp$3(out, a, b, t) { + var ax = a[0]; + var ay = a[1]; + var az = a[2]; + var aw = a[3]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + out[3] = aw + t * (b[3] - aw); + return out; +} +/** + * Generates a random vector with the given scale + * + * @param {vec4} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec4} out + */ + +function random$2(out, scale) { + scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a + // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646. + // http://projecteuclid.org/euclid.aoms/1177692644; + + var v1, v2, v3, v4; + var s1, s2; + + do { + v1 = RANDOM() * 2 - 1; + v2 = RANDOM() * 2 - 1; + s1 = v1 * v1 + v2 * v2; + } while (s1 >= 1); + + do { + v3 = RANDOM() * 2 - 1; + v4 = RANDOM() * 2 - 1; + s2 = v3 * v3 + v4 * v4; + } while (s2 >= 1); + + var d = Math.sqrt((1 - s1) / s2); + out[0] = scale * v1; + out[1] = scale * v2; + out[2] = scale * v3 * d; + out[3] = scale * v4 * d; + return out; +} +/** + * Transforms the vec4 with a mat4. + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {vec4} out + */ + +function transformMat4$1(out, a, m) { + var x = a[0], + y = a[1], + z = a[2], + w = a[3]; + out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + return out; +} +/** + * Transforms the vec4 with a quat + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the vector to transform + * @param {ReadonlyQuat} q quaternion to transform with + * @returns {vec4} out + */ + +function transformQuat(out, a, q) { + var x = a[0], + y = a[1], + z = a[2]; + var qx = q[0], + qy = q[1], + qz = q[2], + qw = q[3]; // calculate quat * vec + + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat + + out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; + out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; + out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; + out[3] = a[3]; + return out; +} +/** + * Set the components of a vec4 to zero + * + * @param {vec4} out the receiving vector + * @returns {vec4} out + */ + +function zero$1(out) { + out[0] = 0.0; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; + return out; +} +/** + * Returns a string representation of a vector + * + * @param {ReadonlyVec4} a vector to represent as a string + * @returns {String} string representation of the vector + */ + +function str$3(a) { + return "vec4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; +} +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec4} a The first vector. + * @param {ReadonlyVec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +function exactEquals$3(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec4} a The first vector. + * @param {ReadonlyVec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +function equals$4(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)); +} +/** + * Alias for {@link vec4.subtract} + * @function + */ + +var sub$1 = subtract$1; +/** + * Alias for {@link vec4.multiply} + * @function + */ + +var mul$3 = multiply$3; +/** + * Alias for {@link vec4.divide} + * @function + */ + +var div$1 = divide$1; +/** + * Alias for {@link vec4.distance} + * @function + */ + +var dist$1 = distance$1; +/** + * Alias for {@link vec4.squaredDistance} + * @function + */ + +var sqrDist$1 = squaredDistance$1; +/** + * Alias for {@link vec4.length} + * @function + */ + +var len$3 = length$3; +/** + * Alias for {@link vec4.squaredLength} + * @function + */ + +var sqrLen$3 = squaredLength$3; +/** + * Perform some operation over an array of vec4s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ + +var forEach$1 = function () { + var vec = create$3(); + return function (a, stride, offset, count, fn, arg) { + var i, l; + + if (!stride) { + stride = 4; + } + + if (!offset) { + offset = 0; + } + + if (count) { + l = Math.min(count * stride + offset, a.length); + } else { + l = a.length; + } + + for (i = offset; i < l; i += stride) { + vec[0] = a[i]; + vec[1] = a[i + 1]; + vec[2] = a[i + 2]; + vec[3] = a[i + 3]; + fn(vec, vec, arg); + a[i] = vec[0]; + a[i + 1] = vec[1]; + a[i + 2] = vec[2]; + a[i + 3] = vec[3]; + } + + return a; + }; +}(); + +var vec4 = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$3, +ceil: ceil$1, +clone: clone$3, +copy: copy$3, +create: create$3, +cross: cross$1, +dist: dist$1, +distance: distance$1, +div: div$1, +divide: divide$1, +dot: dot$4, +equals: equals$4, +exactEquals: exactEquals$3, +floor: floor$1, +forEach: forEach$1, +fromValues: fromValues$3, +inverse: inverse$1, +len: len$3, +length: length$3, +lerp: lerp$3, +max: max$1, +min: min$1, +mul: mul$3, +multiply: multiply$3, +negate: negate$1, +normalize: normalize$3, +random: random$2, +round: round$1, +scale: scale$3, +scaleAndAdd: scaleAndAdd$1, +set: set$3, +sqrDist: sqrDist$1, +sqrLen: sqrLen$3, +squaredDistance: squaredDistance$1, +squaredLength: squaredLength$3, +str: str$3, +sub: sub$1, +subtract: subtract$1, +transformMat4: transformMat4$1, +transformQuat: transformQuat, +zero: zero$1 +}); + +/** + * Quaternion + * @module quat + */ + +/** + * Creates a new identity quat + * + * @returns {quat} a new quaternion + */ + +function create$2() { + var out = new ARRAY_TYPE(4); + + if (ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } + + out[3] = 1; + return out; +} +/** + * Set a quat to the identity quaternion + * + * @param {quat} out the receiving quaternion + * @returns {quat} out + */ + +function identity$1(out) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +} +/** + * Sets a quat from the given angle and rotation axis, + * then returns it. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyVec3} axis the axis around which to rotate + * @param {Number} rad the angle in radians + * @returns {quat} out + **/ + +function setAxisAngle(out, axis, rad) { + rad = rad * 0.5; + var s = Math.sin(rad); + out[0] = s * axis[0]; + out[1] = s * axis[1]; + out[2] = s * axis[2]; + out[3] = Math.cos(rad); + return out; +} +/** + * Gets the rotation axis and angle for a given + * quaternion. If a quaternion is created with + * setAxisAngle, this method will return the same + * values as providied in the original parameter list + * OR functionally equivalent values. + * Example: The quaternion formed by axis [0, 0, 1] and + * angle -90 is the same as the quaternion formed by + * [0, 0, 1] and 270. This method favors the latter. + * @param {vec3} out_axis Vector receiving the axis of rotation + * @param {ReadonlyQuat} q Quaternion to be decomposed + * @return {Number} Angle, in radians, of the rotation + */ + +function getAxisAngle(out_axis, q) { + var rad = Math.acos(q[3]) * 2.0; + var s = Math.sin(rad / 2.0); + + if (s > EPSILON) { + out_axis[0] = q[0] / s; + out_axis[1] = q[1] / s; + out_axis[2] = q[2] / s; + } else { + // If s is zero, return any axis (no rotation - axis does not matter) + out_axis[0] = 1; + out_axis[1] = 0; + out_axis[2] = 0; + } + + return rad; +} +/** + * Gets the angular distance between two unit quaternions + * + * @param {ReadonlyQuat} a Origin unit quaternion + * @param {ReadonlyQuat} b Destination unit quaternion + * @return {Number} Angle, in radians, between the two quaternions + */ + +function getAngle(a, b) { + var dotproduct = dot$3(a, b); + return Math.acos(2 * dotproduct * dotproduct - 1); +} +/** + * Multiplies two quat's + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {quat} out + */ + +function multiply$2(out, a, b) { + var ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + var bx = b[0], + by = b[1], + bz = b[2], + bw = b[3]; + out[0] = ax * bw + aw * bx + ay * bz - az * by; + out[1] = ay * bw + aw * by + az * bx - ax * bz; + out[2] = az * bw + aw * bz + ax * by - ay * bx; + out[3] = aw * bw - ax * bx - ay * by - az * bz; + return out; +} +/** + * Rotates a quaternion by the given angle about the X axis + * + * @param {quat} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ + +function rotateX$1(out, a, rad) { + rad *= 0.5; + var ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + var bx = Math.sin(rad), + bw = Math.cos(rad); + out[0] = ax * bw + aw * bx; + out[1] = ay * bw + az * bx; + out[2] = az * bw - ay * bx; + out[3] = aw * bw - ax * bx; + return out; +} +/** + * Rotates a quaternion by the given angle about the Y axis + * + * @param {quat} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ + +function rotateY$1(out, a, rad) { + rad *= 0.5; + var ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + var by = Math.sin(rad), + bw = Math.cos(rad); + out[0] = ax * bw - az * by; + out[1] = ay * bw + aw * by; + out[2] = az * bw + ax * by; + out[3] = aw * bw - ay * by; + return out; +} +/** + * Rotates a quaternion by the given angle about the Z axis + * + * @param {quat} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ + +function rotateZ$1(out, a, rad) { + rad *= 0.5; + var ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + var bz = Math.sin(rad), + bw = Math.cos(rad); + out[0] = ax * bw + ay * bz; + out[1] = ay * bw - ax * bz; + out[2] = az * bw + aw * bz; + out[3] = aw * bw - az * bz; + return out; +} +/** + * Calculates the W component of a quat from the X, Y, and Z components. + * Assumes that quaternion is 1 unit in length. + * Any existing W component will be ignored. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate W component of + * @returns {quat} out + */ + +function calculateW(out, a) { + var x = a[0], + y = a[1], + z = a[2]; + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); + return out; +} +/** + * Calculate the exponential of a unit quaternion. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @returns {quat} out + */ + +function exp(out, a) { + var x = a[0], + y = a[1], + z = a[2], + w = a[3]; + var r = Math.sqrt(x * x + y * y + z * z); + var et = Math.exp(w); + var s = r > 0 ? et * Math.sin(r) / r : 0; + out[0] = x * s; + out[1] = y * s; + out[2] = z * s; + out[3] = et * Math.cos(r); + return out; +} +/** + * Calculate the natural logarithm of a unit quaternion. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @returns {quat} out + */ + +function ln(out, a) { + var x = a[0], + y = a[1], + z = a[2], + w = a[3]; + var r = Math.sqrt(x * x + y * y + z * z); + var t = r > 0 ? Math.atan2(r, w) / r : 0; + out[0] = x * t; + out[1] = y * t; + out[2] = z * t; + out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w); + return out; +} +/** + * Calculate the scalar power of a unit quaternion. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @param {Number} b amount to scale the quaternion by + * @returns {quat} out + */ + +function pow(out, a, b) { + ln(out, a); + scale$2(out, out, b); + exp(out, out); + return out; +} +/** + * Performs a spherical linear interpolation between two quat + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + */ + +function slerp(out, a, b, t) { + // benchmarks: + // http://jsperf.com/quaternion-slerp-implementations + var ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + var bx = b[0], + by = b[1], + bz = b[2], + bw = b[3]; + var omega, cosom, sinom, scale0, scale1; // calc cosine + + cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary) + + if (cosom < 0.0) { + cosom = -cosom; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } // calculate coefficients + + + if (1.0 - cosom > EPSILON) { + // standard case (slerp) + omega = Math.acos(cosom); + sinom = Math.sin(omega); + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t; + scale1 = t; + } // calculate final values + + + out[0] = scale0 * ax + scale1 * bx; + out[1] = scale0 * ay + scale1 * by; + out[2] = scale0 * az + scale1 * bz; + out[3] = scale0 * aw + scale1 * bw; + return out; +} +/** + * Generates a random unit quaternion + * + * @param {quat} out the receiving quaternion + * @returns {quat} out + */ + +function random$1(out) { + // Implementation of http://planning.cs.uiuc.edu/node198.html + // TODO: Calling random 3 times is probably not the fastest solution + var u1 = RANDOM(); + var u2 = RANDOM(); + var u3 = RANDOM(); + var sqrt1MinusU1 = Math.sqrt(1 - u1); + var sqrtU1 = Math.sqrt(u1); + out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2); + out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2); + out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3); + out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3); + return out; +} +/** + * Calculates the inverse of a quat + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate inverse of + * @returns {quat} out + */ + +function invert$1(out, a) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3]; + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + out[0] = -a0 * invDot; + out[1] = -a1 * invDot; + out[2] = -a2 * invDot; + out[3] = a3 * invDot; + return out; +} +/** + * Calculates the conjugate of a quat + * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate conjugate of + * @returns {quat} out + */ + +function conjugate$1(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; + return out; +} +/** + * Creates a quaternion from the given 3x3 rotation matrix. + * + * NOTE: The resultant quaternion is not normalized, so you should be sure + * to renormalize the quaternion yourself where necessary. + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyMat3} m rotation matrix + * @returns {quat} out + * @function + */ + +function fromMat3(out, m) { + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0.0) { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + out[3] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; // 1/(4w) + + out[0] = (m[5] - m[7]) * fRoot; + out[1] = (m[6] - m[2]) * fRoot; + out[2] = (m[1] - m[3]) * fRoot; + } else { + // |w| <= 1/2 + var i = 0; + if (m[4] > m[0]) i = 1; + if (m[8] > m[i * 3 + i]) i = 2; + var j = (i + 1) % 3; + var k = (i + 2) % 3; + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0); + out[i] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot; + out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + } + + return out; +} +/** + * Creates a quaternion from the given euler angle x, y, z. + * + * @param {quat} out the receiving quaternion + * @param {x} Angle to rotate around X axis in degrees. + * @param {y} Angle to rotate around Y axis in degrees. + * @param {z} Angle to rotate around Z axis in degrees. + * @returns {quat} out + * @function + */ + +function fromEuler(out, x, y, z) { + var halfToRad = 0.5 * Math.PI / 180.0; + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; + var sx = Math.sin(x); + var cx = Math.cos(x); + var sy = Math.sin(y); + var cy = Math.cos(y); + var sz = Math.sin(z); + var cz = Math.cos(z); + out[0] = sx * cy * cz - cx * sy * sz; + out[1] = cx * sy * cz + sx * cy * sz; + out[2] = cx * cy * sz - sx * sy * cz; + out[3] = cx * cy * cz + sx * sy * sz; + return out; +} +/** + * Returns a string representation of a quatenion + * + * @param {ReadonlyQuat} a vector to represent as a string + * @returns {String} string representation of the vector + */ + +function str$2(a) { + return "quat(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; +} +/** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {ReadonlyQuat} a quaternion to clone + * @returns {quat} a new quaternion + * @function + */ + +var clone$2 = clone$3; +/** + * Creates a new quat initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {quat} a new quaternion + * @function + */ + +var fromValues$2 = fromValues$3; +/** + * Copy the values from one quat to another + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the source quaternion + * @returns {quat} out + * @function + */ + +var copy$2 = copy$3; +/** + * Set the components of a quat to the given values + * + * @param {quat} out the receiving quaternion + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {quat} out + * @function + */ + +var set$2 = set$3; +/** + * Adds two quat's + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {quat} out + * @function + */ + +var add$2 = add$3; +/** + * Alias for {@link quat.multiply} + * @function + */ + +var mul$2 = multiply$2; +/** + * Scales a quat by a scalar number + * + * @param {quat} out the receiving vector + * @param {ReadonlyQuat} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {quat} out + * @function + */ + +var scale$2 = scale$3; +/** + * Calculates the dot product of two quat's + * + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {Number} dot product of a and b + * @function + */ + +var dot$3 = dot$4; +/** + * Performs a linear interpolation between two quat's + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + * @function + */ + +var lerp$2 = lerp$3; +/** + * Calculates the length of a quat + * + * @param {ReadonlyQuat} a vector to calculate length of + * @returns {Number} length of a + */ + +var length$2 = length$3; +/** + * Alias for {@link quat.length} + * @function + */ + +var len$2 = length$2; +/** + * Calculates the squared length of a quat + * + * @param {ReadonlyQuat} a vector to calculate squared length of + * @returns {Number} squared length of a + * @function + */ + +var squaredLength$2 = squaredLength$3; +/** + * Alias for {@link quat.squaredLength} + * @function + */ + +var sqrLen$2 = squaredLength$2; +/** + * Normalize a quat + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quaternion to normalize + * @returns {quat} out + * @function + */ + +var normalize$2 = normalize$3; +/** + * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyQuat} a The first quaternion. + * @param {ReadonlyQuat} b The second quaternion. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +var exactEquals$2 = exactEquals$3; +/** + * Returns whether or not the quaternions have approximately the same elements in the same position. + * + * @param {ReadonlyQuat} a The first vector. + * @param {ReadonlyQuat} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +var equals$3 = equals$4; +/** + * Sets a quaternion to represent the shortest rotation from one + * vector to another. + * + * Both vectors are assumed to be unit length. + * + * @param {quat} out the receiving quaternion. + * @param {ReadonlyVec3} a the initial vector + * @param {ReadonlyVec3} b the destination vector + * @returns {quat} out + */ + +var rotationTo = function () { + var tmpvec3 = create$4(); + var xUnitVec3 = fromValues$4(1, 0, 0); + var yUnitVec3 = fromValues$4(0, 1, 0); + return function (out, a, b) { + var dot = dot$5(a, b); + + if (dot < -0.999999) { + cross$2(tmpvec3, xUnitVec3, a); + if (len$4(tmpvec3) < 0.000001) cross$2(tmpvec3, yUnitVec3, a); + normalize$4(tmpvec3, tmpvec3); + setAxisAngle(out, tmpvec3, Math.PI); + return out; + } else if (dot > 0.999999) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; + } else { + cross$2(tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot; + return normalize$2(out, out); + } + }; +}(); +/** + * Performs a spherical linear interpolation with two control points + * + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @param {ReadonlyQuat} c the third operand + * @param {ReadonlyQuat} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + */ + +var sqlerp = function () { + var temp1 = create$2(); + var temp2 = create$2(); + return function (out, a, b, c, d, t) { + slerp(temp1, a, d, t); + slerp(temp2, b, c, t); + slerp(out, temp1, temp2, 2 * t * (1 - t)); + return out; + }; +}(); +/** + * Sets the specified quaternion with values corresponding to the given + * axes. Each axis is a vec3 and is expected to be unit length and + * perpendicular to all other specified axes. + * + * @param {ReadonlyVec3} view the vector representing the viewing direction + * @param {ReadonlyVec3} right the vector representing the local "right" direction + * @param {ReadonlyVec3} up the vector representing the local "up" direction + * @returns {quat} out + */ + +var setAxes = function () { + var matr = create$6(); + return function (out, view, right, up) { + matr[0] = right[0]; + matr[3] = right[1]; + matr[6] = right[2]; + matr[1] = up[0]; + matr[4] = up[1]; + matr[7] = up[2]; + matr[2] = -view[0]; + matr[5] = -view[1]; + matr[8] = -view[2]; + return normalize$2(out, fromMat3(out, matr)); + }; +}(); + +var quat = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$2, +calculateW: calculateW, +clone: clone$2, +conjugate: conjugate$1, +copy: copy$2, +create: create$2, +dot: dot$3, +equals: equals$3, +exactEquals: exactEquals$2, +exp: exp, +fromEuler: fromEuler, +fromMat3: fromMat3, +fromValues: fromValues$2, +getAngle: getAngle, +getAxisAngle: getAxisAngle, +identity: identity$1, +invert: invert$1, +len: len$2, +length: length$2, +lerp: lerp$2, +ln: ln, +mul: mul$2, +multiply: multiply$2, +normalize: normalize$2, +pow: pow, +random: random$1, +rotateX: rotateX$1, +rotateY: rotateY$1, +rotateZ: rotateZ$1, +rotationTo: rotationTo, +scale: scale$2, +set: set$2, +setAxes: setAxes, +setAxisAngle: setAxisAngle, +slerp: slerp, +sqlerp: sqlerp, +sqrLen: sqrLen$2, +squaredLength: squaredLength$2, +str: str$2 +}); + +/** + * Dual Quaternion
+ * Format: [real, dual]
+ * Quaternion format: XYZW
+ * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.
+ * @module quat2 + */ + +/** + * Creates a new identity dual quat + * + * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] + */ + +function create$1() { + var dq = new ARRAY_TYPE(8); + + if (ARRAY_TYPE != Float32Array) { + dq[0] = 0; + dq[1] = 0; + dq[2] = 0; + dq[4] = 0; + dq[5] = 0; + dq[6] = 0; + dq[7] = 0; + } + + dq[3] = 1; + return dq; +} +/** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {ReadonlyQuat2} a dual quaternion to clone + * @returns {quat2} new dual quaternion + * @function + */ + +function clone$1(a) { + var dq = new ARRAY_TYPE(8); + dq[0] = a[0]; + dq[1] = a[1]; + dq[2] = a[2]; + dq[3] = a[3]; + dq[4] = a[4]; + dq[5] = a[5]; + dq[6] = a[6]; + dq[7] = a[7]; + return dq; +} +/** + * Creates a new dual quat initialized with the given values + * + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component + * @param {Number} y2 Y component + * @param {Number} z2 Z component + * @param {Number} w2 W component + * @returns {quat2} new dual quaternion + * @function + */ + +function fromValues$1(x1, y1, z1, w1, x2, y2, z2, w2) { + var dq = new ARRAY_TYPE(8); + dq[0] = x1; + dq[1] = y1; + dq[2] = z1; + dq[3] = w1; + dq[4] = x2; + dq[5] = y2; + dq[6] = z2; + dq[7] = w2; + return dq; +} +/** + * Creates a new dual quat from the given values (quat and translation) + * + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component (translation) + * @param {Number} y2 Y component (translation) + * @param {Number} z2 Z component (translation) + * @returns {quat2} new dual quaternion + * @function + */ + +function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { + var dq = new ARRAY_TYPE(8); + dq[0] = x1; + dq[1] = y1; + dq[2] = z1; + dq[3] = w1; + var ax = x2 * 0.5, + ay = y2 * 0.5, + az = z2 * 0.5; + dq[4] = ax * w1 + ay * z1 - az * y1; + dq[5] = ay * w1 + az * x1 - ax * z1; + dq[6] = az * w1 + ax * y1 - ay * x1; + dq[7] = -ax * x1 - ay * y1 - az * z1; + return dq; +} +/** + * Creates a dual quat from a quaternion and a translation + * + * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @param {ReadonlyQuat} q a normalized quaternion + * @param {ReadonlyVec3} t tranlation vector + * @returns {quat2} dual quaternion receiving operation result + * @function + */ + +function fromRotationTranslation(out, q, t) { + var ax = t[0] * 0.5, + ay = t[1] * 0.5, + az = t[2] * 0.5, + bx = q[0], + by = q[1], + bz = q[2], + bw = q[3]; + out[0] = bx; + out[1] = by; + out[2] = bz; + out[3] = bw; + out[4] = ax * bw + ay * bz - az * by; + out[5] = ay * bw + az * bx - ax * bz; + out[6] = az * bw + ax * by - ay * bx; + out[7] = -ax * bx - ay * by - az * bz; + return out; +} +/** + * Creates a dual quat from a translation + * + * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @param {ReadonlyVec3} t translation vector + * @returns {quat2} dual quaternion receiving operation result + * @function + */ + +function fromTranslation(out, t) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = t[0] * 0.5; + out[5] = t[1] * 0.5; + out[6] = t[2] * 0.5; + out[7] = 0; + return out; +} +/** + * Creates a dual quat from a quaternion + * + * @param {ReadonlyQuat2} dual quaternion receiving operation result + * @param {ReadonlyQuat} q the quaternion + * @returns {quat2} dual quaternion receiving operation result + * @function + */ + +function fromRotation(out, q) { + out[0] = q[0]; + out[1] = q[1]; + out[2] = q[2]; + out[3] = q[3]; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + return out; +} +/** + * Creates a new dual quat from a matrix (4x4) + * + * @param {quat2} out the dual quaternion + * @param {ReadonlyMat4} a the matrix + * @returns {quat2} dual quat receiving operation result + * @function + */ + +function fromMat4(out, a) { + //TODO Optimize this + var outer = create$2(); + getRotation(outer, a); + var t = new ARRAY_TYPE(3); + getTranslation$1(t, a); + fromRotationTranslation(out, outer, t); + return out; +} +/** + * Copy the values from one dual quat to another + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the source dual quaternion + * @returns {quat2} out + * @function + */ + +function copy$1(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + return out; +} +/** + * Set a dual quat to the identity dual quaternion + * + * @param {quat2} out the receiving quaternion + * @returns {quat2} out + */ + +function identity(out) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + return out; +} +/** + * Set the components of a dual quat to the given values + * + * @param {quat2} out the receiving quaternion + * @param {Number} x1 X component + * @param {Number} y1 Y component + * @param {Number} z1 Z component + * @param {Number} w1 W component + * @param {Number} x2 X component + * @param {Number} y2 Y component + * @param {Number} z2 Z component + * @param {Number} w2 W component + * @returns {quat2} out + * @function + */ + +function set$1(out, x1, y1, z1, w1, x2, y2, z2, w2) { + out[0] = x1; + out[1] = y1; + out[2] = z1; + out[3] = w1; + out[4] = x2; + out[5] = y2; + out[6] = z2; + out[7] = w2; + return out; +} +/** + * Gets the real part of a dual quat + * @param {quat} out real part + * @param {ReadonlyQuat2} a Dual Quaternion + * @return {quat} real part + */ + +var getReal = copy$2; +/** + * Gets the dual part of a dual quat + * @param {quat} out dual part + * @param {ReadonlyQuat2} a Dual Quaternion + * @return {quat} dual part + */ + +function getDual(out, a) { + out[0] = a[4]; + out[1] = a[5]; + out[2] = a[6]; + out[3] = a[7]; + return out; +} +/** + * Set the real component of a dual quat to the given quaternion + * + * @param {quat2} out the receiving quaternion + * @param {ReadonlyQuat} q a quaternion representing the real part + * @returns {quat2} out + * @function + */ + +var setReal = copy$2; +/** + * Set the dual component of a dual quat to the given quaternion + * + * @param {quat2} out the receiving quaternion + * @param {ReadonlyQuat} q a quaternion representing the dual part + * @returns {quat2} out + * @function + */ + +function setDual(out, q) { + out[4] = q[0]; + out[5] = q[1]; + out[6] = q[2]; + out[7] = q[3]; + return out; +} +/** + * Gets the translation of a normalized dual quat + * @param {vec3} out translation + * @param {ReadonlyQuat2} a Dual Quaternion to be decomposed + * @return {vec3} translation + */ + +function getTranslation(out, a) { + var ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3]; + out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; + out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; + out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; + return out; +} +/** + * Translates a dual quat by the given vector + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to translate + * @param {ReadonlyVec3} v vector to translate by + * @returns {quat2} out + */ + +function translate(out, a, v) { + var ax1 = a[0], + ay1 = a[1], + az1 = a[2], + aw1 = a[3], + bx1 = v[0] * 0.5, + by1 = v[1] * 0.5, + bz1 = v[2] * 0.5, + ax2 = a[4], + ay2 = a[5], + az2 = a[6], + aw2 = a[7]; + out[0] = ax1; + out[1] = ay1; + out[2] = az1; + out[3] = aw1; + out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2; + out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2; + out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2; + out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2; + return out; +} +/** + * Rotates a dual quat around the X axis + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {quat2} out + */ + +function rotateX(out, a, rad) { + var bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + ax1 = ax * bw + aw * bx + ay * bz - az * by, + ay1 = ay * bw + aw * by + az * bx - ax * bz, + az1 = az * bw + aw * bz + ax * by - ay * bx, + aw1 = aw * bw - ax * bx - ay * by - az * bz; + rotateX$1(out, a, rad); + bx = out[0]; + by = out[1]; + bz = out[2]; + bw = out[3]; + out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + return out; +} +/** + * Rotates a dual quat around the Y axis + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {quat2} out + */ + +function rotateY(out, a, rad) { + var bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + ax1 = ax * bw + aw * bx + ay * bz - az * by, + ay1 = ay * bw + aw * by + az * bx - ax * bz, + az1 = az * bw + aw * bz + ax * by - ay * bx, + aw1 = aw * bw - ax * bx - ay * by - az * bz; + rotateY$1(out, a, rad); + bx = out[0]; + by = out[1]; + bz = out[2]; + bw = out[3]; + out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + return out; +} +/** + * Rotates a dual quat around the Z axis + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {number} rad how far should the rotation be + * @returns {quat2} out + */ + +function rotateZ(out, a, rad) { + var bx = -a[0], + by = -a[1], + bz = -a[2], + bw = a[3], + ax = a[4], + ay = a[5], + az = a[6], + aw = a[7], + ax1 = ax * bw + aw * bx + ay * bz - az * by, + ay1 = ay * bw + aw * by + az * bx - ax * bz, + az1 = az * bw + aw * bz + ax * by - ay * bx, + aw1 = aw * bw - ax * bx - ay * by - az * bz; + rotateZ$1(out, a, rad); + bx = out[0]; + by = out[1]; + bz = out[2]; + bw = out[3]; + out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + return out; +} +/** + * Rotates a dual quat by a given quaternion (a * q) + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {ReadonlyQuat} q quaternion to rotate by + * @returns {quat2} out + */ + +function rotateByQuatAppend(out, a, q) { + var qx = q[0], + qy = q[1], + qz = q[2], + qw = q[3], + ax = a[0], + ay = a[1], + az = a[2], + aw = a[3]; + out[0] = ax * qw + aw * qx + ay * qz - az * qy; + out[1] = ay * qw + aw * qy + az * qx - ax * qz; + out[2] = az * qw + aw * qz + ax * qy - ay * qx; + out[3] = aw * qw - ax * qx - ay * qy - az * qz; + ax = a[4]; + ay = a[5]; + az = a[6]; + aw = a[7]; + out[4] = ax * qw + aw * qx + ay * qz - az * qy; + out[5] = ay * qw + aw * qy + az * qx - ax * qz; + out[6] = az * qw + aw * qz + ax * qy - ay * qx; + out[7] = aw * qw - ax * qx - ay * qy - az * qz; + return out; +} +/** + * Rotates a dual quat by a given quaternion (q * a) + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat} q quaternion to rotate by + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @returns {quat2} out + */ + +function rotateByQuatPrepend(out, q, a) { + var qx = q[0], + qy = q[1], + qz = q[2], + qw = q[3], + bx = a[0], + by = a[1], + bz = a[2], + bw = a[3]; + out[0] = qx * bw + qw * bx + qy * bz - qz * by; + out[1] = qy * bw + qw * by + qz * bx - qx * bz; + out[2] = qz * bw + qw * bz + qx * by - qy * bx; + out[3] = qw * bw - qx * bx - qy * by - qz * bz; + bx = a[4]; + by = a[5]; + bz = a[6]; + bw = a[7]; + out[4] = qx * bw + qw * bx + qy * bz - qz * by; + out[5] = qy * bw + qw * by + qz * bx - qx * bz; + out[6] = qz * bw + qw * bz + qx * by - qy * bx; + out[7] = qw * bw - qx * bx - qy * by - qz * bz; + return out; +} +/** + * Rotates a dual quat around a given axis. Does the normalisation automatically + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the dual quaternion to rotate + * @param {ReadonlyVec3} axis the axis to rotate around + * @param {Number} rad how far the rotation should be + * @returns {quat2} out + */ + +function rotateAroundAxis(out, a, axis, rad) { + //Special case for rad = 0 + if (Math.abs(rad) < EPSILON) { + return copy$1(out, a); + } + + var axisLength = Math.hypot(axis[0], axis[1], axis[2]); + rad = rad * 0.5; + var s = Math.sin(rad); + var bx = s * axis[0] / axisLength; + var by = s * axis[1] / axisLength; + var bz = s * axis[2] / axisLength; + var bw = Math.cos(rad); + var ax1 = a[0], + ay1 = a[1], + az1 = a[2], + aw1 = a[3]; + out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; + out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; + out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; + out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; + var ax = a[4], + ay = a[5], + az = a[6], + aw = a[7]; + out[4] = ax * bw + aw * bx + ay * bz - az * by; + out[5] = ay * bw + aw * by + az * bx - ax * bz; + out[6] = az * bw + aw * bz + ax * by - ay * bx; + out[7] = aw * bw - ax * bx - ay * by - az * bz; + return out; +} +/** + * Adds two dual quat's + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {quat2} out + * @function + */ + +function add$1(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + return out; +} +/** + * Multiplies two dual quat's + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {quat2} out + */ + +function multiply$1(out, a, b) { + var ax0 = a[0], + ay0 = a[1], + az0 = a[2], + aw0 = a[3], + bx1 = b[4], + by1 = b[5], + bz1 = b[6], + bw1 = b[7], + ax1 = a[4], + ay1 = a[5], + az1 = a[6], + aw1 = a[7], + bx0 = b[0], + by0 = b[1], + bz0 = b[2], + bw0 = b[3]; + out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0; + out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0; + out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0; + out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0; + out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0; + out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0; + out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0; + out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0; + return out; +} +/** + * Alias for {@link quat2.multiply} + * @function + */ + +var mul$1 = multiply$1; +/** + * Scales a dual quat by a scalar number + * + * @param {quat2} out the receiving dual quat + * @param {ReadonlyQuat2} a the dual quat to scale + * @param {Number} b amount to scale the dual quat by + * @returns {quat2} out + * @function + */ + +function scale$1(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + return out; +} +/** + * Calculates the dot product of two dual quat's (The dot product of the real parts) + * + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @returns {Number} dot product of a and b + * @function + */ + +var dot$2 = dot$3; +/** + * Performs a linear interpolation between two dual quats's + * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) + * + * @param {quat2} out the receiving dual quat + * @param {ReadonlyQuat2} a the first operand + * @param {ReadonlyQuat2} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat2} out + */ + +function lerp$1(out, a, b, t) { + var mt = 1 - t; + if (dot$2(a, b) < 0) t = -t; + out[0] = a[0] * mt + b[0] * t; + out[1] = a[1] * mt + b[1] * t; + out[2] = a[2] * mt + b[2] * t; + out[3] = a[3] * mt + b[3] * t; + out[4] = a[4] * mt + b[4] * t; + out[5] = a[5] * mt + b[5] * t; + out[6] = a[6] * mt + b[6] * t; + out[7] = a[7] * mt + b[7] * t; + return out; +} +/** + * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a dual quat to calculate inverse of + * @returns {quat2} out + */ + +function invert(out, a) { + var sqlen = squaredLength$1(a); + out[0] = -a[0] / sqlen; + out[1] = -a[1] / sqlen; + out[2] = -a[2] / sqlen; + out[3] = a[3] / sqlen; + out[4] = -a[4] / sqlen; + out[5] = -a[5] / sqlen; + out[6] = -a[6] / sqlen; + out[7] = a[7] / sqlen; + return out; +} +/** + * Calculates the conjugate of a dual quat + * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. + * + * @param {quat2} out the receiving quaternion + * @param {ReadonlyQuat2} a quat to calculate conjugate of + * @returns {quat2} out + */ + +function conjugate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; + out[4] = -a[4]; + out[5] = -a[5]; + out[6] = -a[6]; + out[7] = a[7]; + return out; +} +/** + * Calculates the length of a dual quat + * + * @param {ReadonlyQuat2} a dual quat to calculate length of + * @returns {Number} length of a + * @function + */ + +var length$1 = length$2; +/** + * Alias for {@link quat2.length} + * @function + */ + +var len$1 = length$1; +/** + * Calculates the squared length of a dual quat + * + * @param {ReadonlyQuat2} a dual quat to calculate squared length of + * @returns {Number} squared length of a + * @function + */ + +var squaredLength$1 = squaredLength$2; +/** + * Alias for {@link quat2.squaredLength} + * @function + */ + +var sqrLen$1 = squaredLength$1; +/** + * Normalize a dual quat + * + * @param {quat2} out the receiving dual quaternion + * @param {ReadonlyQuat2} a dual quaternion to normalize + * @returns {quat2} out + * @function + */ + +function normalize$1(out, a) { + var magnitude = squaredLength$1(a); + + if (magnitude > 0) { + magnitude = Math.sqrt(magnitude); + var a0 = a[0] / magnitude; + var a1 = a[1] / magnitude; + var a2 = a[2] / magnitude; + var a3 = a[3] / magnitude; + var b0 = a[4]; + var b1 = a[5]; + var b2 = a[6]; + var b3 = a[7]; + var a_dot_b = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3; + out[0] = a0; + out[1] = a1; + out[2] = a2; + out[3] = a3; + out[4] = (b0 - a0 * a_dot_b) / magnitude; + out[5] = (b1 - a1 * a_dot_b) / magnitude; + out[6] = (b2 - a2 * a_dot_b) / magnitude; + out[7] = (b3 - a3 * a_dot_b) / magnitude; + } + + return out; +} +/** + * Returns a string representation of a dual quatenion + * + * @param {ReadonlyQuat2} a dual quaternion to represent as a string + * @returns {String} string representation of the dual quat + */ + +function str$1(a) { + return "quat2(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ")"; +} +/** + * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyQuat2} a the first dual quaternion. + * @param {ReadonlyQuat2} b the second dual quaternion. + * @returns {Boolean} true if the dual quaternions are equal, false otherwise. + */ + +function exactEquals$1(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7]; +} +/** + * Returns whether or not the dual quaternions have approximately the same elements in the same position. + * + * @param {ReadonlyQuat2} a the first dual quat. + * @param {ReadonlyQuat2} b the second dual quat. + * @returns {Boolean} true if the dual quats are equal, false otherwise. + */ + +function equals$2(a, b) { + var a0 = a[0], + a1 = a[1], + a2 = a[2], + a3 = a[3], + a4 = a[4], + a5 = a[5], + a6 = a[6], + a7 = a[7]; + var b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3], + b4 = b[4], + b5 = b[5], + b6 = b[6], + b7 = b[7]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)); +} + +var quat2 = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add$1, +clone: clone$1, +conjugate: conjugate, +copy: copy$1, +create: create$1, +dot: dot$2, +equals: equals$2, +exactEquals: exactEquals$1, +fromMat4: fromMat4, +fromRotation: fromRotation, +fromRotationTranslation: fromRotationTranslation, +fromRotationTranslationValues: fromRotationTranslationValues, +fromTranslation: fromTranslation, +fromValues: fromValues$1, +getDual: getDual, +getReal: getReal, +getTranslation: getTranslation, +identity: identity, +invert: invert, +len: len$1, +length: length$1, +lerp: lerp$1, +mul: mul$1, +multiply: multiply$1, +normalize: normalize$1, +rotateAroundAxis: rotateAroundAxis, +rotateByQuatAppend: rotateByQuatAppend, +rotateByQuatPrepend: rotateByQuatPrepend, +rotateX: rotateX, +rotateY: rotateY, +rotateZ: rotateZ, +scale: scale$1, +set: set$1, +setDual: setDual, +setReal: setReal, +sqrLen: sqrLen$1, +squaredLength: squaredLength$1, +str: str$1, +translate: translate +}); + +/** + * 2 Dimensional Vector + * @module vec2 + */ + +/** + * Creates a new, empty vec2 + * + * @returns {vec2} a new 2D vector + */ + +function create() { + var out = new ARRAY_TYPE(2); + + if (ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + } + + return out; +} +/** + * Creates a new vec2 initialized with values from an existing vector + * + * @param {ReadonlyVec2} a vector to clone + * @returns {vec2} a new 2D vector + */ + +function clone(a) { + var out = new ARRAY_TYPE(2); + out[0] = a[0]; + out[1] = a[1]; + return out; +} +/** + * Creates a new vec2 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @returns {vec2} a new 2D vector + */ + +function fromValues(x, y) { + var out = new ARRAY_TYPE(2); + out[0] = x; + out[1] = y; + return out; +} +/** + * Copy the values from one vec2 to another + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the source vector + * @returns {vec2} out + */ + +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + return out; +} +/** + * Set the components of a vec2 to the given values + * + * @param {vec2} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @returns {vec2} out + */ + +function set(out, x, y) { + out[0] = x; + out[1] = y; + return out; +} +/** + * Adds two vec2's + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out + */ + +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + return out; +} +/** + * Subtracts vector b from vector a + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out + */ + +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + return out; +} +/** + * Multiplies two vec2's + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out + */ + +function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + return out; +} +/** + * Divides two vec2's + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out + */ + +function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + return out; +} +/** + * Math.ceil the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to ceil + * @returns {vec2} out + */ + +function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + return out; +} +/** + * Math.floor the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to floor + * @returns {vec2} out + */ + +function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + return out; +} +/** + * Returns the minimum of two vec2's + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out + */ + +function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + return out; +} +/** + * Returns the maximum of two vec2's + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out + */ + +function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + return out; +} +/** + * Math.round the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to round + * @returns {vec2} out + */ + +function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + return out; +} +/** + * Scales a vec2 by a scalar number + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec2} out + */ + +function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + return out; +} +/** + * Adds two vec2's after scaling the second operand by a scalar value + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec2} out + */ + +function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + return out; +} +/** + * Calculates the euclidian distance between two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} distance between a and b + */ + +function distance(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return Math.hypot(x, y); +} +/** + * Calculates the squared euclidian distance between two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} squared distance between a and b + */ + +function squaredDistance(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return x * x + y * y; +} +/** + * Calculates the length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate length of + * @returns {Number} length of a + */ + +function length(a) { + var x = a[0], + y = a[1]; + return Math.hypot(x, y); +} +/** + * Calculates the squared length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate squared length of + * @returns {Number} squared length of a + */ + +function squaredLength(a) { + var x = a[0], + y = a[1]; + return x * x + y * y; +} +/** + * Negates the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to negate + * @returns {vec2} out + */ + +function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + return out; +} +/** + * Returns the inverse of the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to invert + * @returns {vec2} out + */ + +function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + return out; +} +/** + * Normalize a vec2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to normalize + * @returns {vec2} out + */ + +function normalize(out, a) { + var x = a[0], + y = a[1]; + var len = x * x + y * y; + + if (len > 0) { + //TODO: evaluate use of glm_invsqrt here? + len = 1 / Math.sqrt(len); + } + + out[0] = a[0] * len; + out[1] = a[1] * len; + return out; +} +/** + * Calculates the dot product of two vec2's + * + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {Number} dot product of a and b + */ + +function dot$1(a, b) { + return a[0] * b[0] + a[1] * b[1]; +} +/** + * Computes the cross product of two vec2's + * Note that the cross product must by definition produce a 3D vector + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec3} out + */ + +function cross(out, a, b) { + var z = a[0] * b[1] - a[1] * b[0]; + out[0] = out[1] = 0; + out[2] = z; + return out; +} +/** + * Performs a linear interpolation between two vec2's + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec2} out + */ + +function lerp(out, a, b, t) { + var ax = a[0], + ay = a[1]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + return out; +} +/** + * Generates a random vector with the given scale + * + * @param {vec2} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec2} out + */ + +function random(out, scale) { + scale = scale || 1.0; + var r = RANDOM() * 2.0 * Math.PI; + out[0] = Math.cos(r) * scale; + out[1] = Math.sin(r) * scale; + return out; +} +/** + * Transforms the vec2 with a mat2 + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat2} m matrix to transform with + * @returns {vec2} out + */ + +function transformMat2(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[2] * y; + out[1] = m[1] * x + m[3] * y; + return out; +} +/** + * Transforms the vec2 with a mat2d + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat2d} m matrix to transform with + * @returns {vec2} out + */ + +function transformMat2d(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; + return out; +} +/** + * Transforms the vec2 with a mat3 + * 3rd vector component is implicitly '1' + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat3} m matrix to transform with + * @returns {vec2} out + */ + +function transformMat3(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[3] * y + m[6]; + out[1] = m[1] * x + m[4] * y + m[7]; + return out; +} +/** + * Transforms the vec2 with a mat4 + * 3rd vector component is implicitly '0' + * 4th vector component is implicitly '1' + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {vec2} out + */ + +function transformMat4(out, a, m) { + var x = a[0]; + var y = a[1]; + out[0] = m[0] * x + m[4] * y + m[12]; + out[1] = m[1] * x + m[5] * y + m[13]; + return out; +} +/** + * Rotate a 2D vector + * @param {vec2} out The receiving vec2 + * @param {ReadonlyVec2} a The vec2 point to rotate + * @param {ReadonlyVec2} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec2} out + */ + +function rotate(out, a, b, rad) { + //Translate point to the origin + var p0 = a[0] - b[0], + p1 = a[1] - b[1], + sinC = Math.sin(rad), + cosC = Math.cos(rad); //perform rotation and translate to correct position + + out[0] = p0 * cosC - p1 * sinC + b[0]; + out[1] = p0 * sinC + p1 * cosC + b[1]; + return out; +} +/** + * Get the angle between two 2D vectors + * @param {ReadonlyVec2} a The first operand + * @param {ReadonlyVec2} b The second operand + * @returns {Number} The angle in radians + */ + +function angle(a, b) { + var x1 = a[0], + y1 = a[1], + x2 = b[0], + y2 = b[1], + // mag is the product of the magnitudes of a and b + mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2), + // mag &&.. short circuits if mag == 0 + cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1 + + return Math.acos(Math.min(Math.max(cosine, -1), 1)); +} +/** + * Set the components of a vec2 to zero + * + * @param {vec2} out the receiving vector + * @returns {vec2} out + */ + +function zero(out) { + out[0] = 0.0; + out[1] = 0.0; + return out; +} +/** + * Returns a string representation of a vector + * + * @param {ReadonlyVec2} a vector to represent as a string + * @returns {String} string representation of the vector + */ + +function str(a) { + return "vec2(" + a[0] + ", " + a[1] + ")"; +} +/** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec2} a The first vector. + * @param {ReadonlyVec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1]; +} +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec2} a The first vector. + * @param {ReadonlyVec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ + +function equals$1(a, b) { + var a0 = a[0], + a1 = a[1]; + var b0 = b[0], + b1 = b[1]; + return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)); +} +/** + * Alias for {@link vec2.length} + * @function + */ + +var len = length; +/** + * Alias for {@link vec2.subtract} + * @function + */ + +var sub = subtract; +/** + * Alias for {@link vec2.multiply} + * @function + */ + +var mul = multiply; +/** + * Alias for {@link vec2.divide} + * @function + */ + +var div = divide; +/** + * Alias for {@link vec2.distance} + * @function + */ + +var dist = distance; +/** + * Alias for {@link vec2.squaredDistance} + * @function + */ + +var sqrDist = squaredDistance; +/** + * Alias for {@link vec2.squaredLength} + * @function + */ + +var sqrLen = squaredLength; +/** + * Perform some operation over an array of vec2s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ + +var forEach = function () { + var vec = create(); + return function (a, stride, offset, count, fn, arg) { + var i, l; + + if (!stride) { + stride = 2; + } + + if (!offset) { + offset = 0; + } + + if (count) { + l = Math.min(count * stride + offset, a.length); + } else { + l = a.length; + } + + for (i = offset; i < l; i += stride) { + vec[0] = a[i]; + vec[1] = a[i + 1]; + fn(vec, vec, arg); + a[i] = vec[0]; + a[i + 1] = vec[1]; + } + + return a; + }; +}(); + +var vec2 = /*#__PURE__*/Object.freeze({ +__proto__: null, +add: add, +angle: angle, +ceil: ceil, +clone: clone, +copy: copy, +create: create, +cross: cross, +dist: dist, +distance: distance, +div: div, +divide: divide, +dot: dot$1, +equals: equals$1, +exactEquals: exactEquals, +floor: floor, +forEach: forEach, +fromValues: fromValues, +inverse: inverse, +len: len, +length: length, +lerp: lerp, +max: max, +min: min, +mul: mul, +multiply: multiply, +negate: negate, +normalize: normalize, +random: random, +rotate: rotate, +round: round, +scale: scale, +scaleAndAdd: scaleAndAdd, +set: set, +sqrDist: sqrDist, +sqrLen: sqrLen, +squaredDistance: squaredDistance, +squaredLength: squaredLength, +str: str, +sub: sub, +subtract: subtract, +transformMat2: transformMat2, +transformMat2d: transformMat2d, +transformMat3: transformMat3, +transformMat4: transformMat4, +zero: zero +}); + +/** + * A style layer that defines a circle + */ +class CircleStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$8); + } + createBucket(parameters) { + return new CircleBucket(parameters); + } + queryRadius(bucket) { + const circleBucket = bucket; + return getMaximumPaintValue('circle-radius', this, circleBucket) + + getMaximumPaintValue('circle-stroke-width', this, circleBucket) + + translateDistance(this.paint.get('circle-translate')); + } + queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits, pixelPosMatrix) { + const translatedPolygon = translate$4(queryGeometry, this.paint.get('circle-translate'), this.paint.get('circle-translate-anchor'), transform.angle, pixelsToTileUnits); + const radius = this.paint.get('circle-radius').evaluate(feature, featureState); + const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState); + const size = radius + stroke; + // For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile + // // Otherwise, compare geometry in the plane of the viewport + // // A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance + // // A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance + const alignWithMap = this.paint.get('circle-pitch-alignment') === 'map'; + const transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry$1(translatedPolygon, pixelPosMatrix); + const transformedSize = alignWithMap ? size * pixelsToTileUnits : size; + for (const ring of geometry) { + for (const point of ring) { + const transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix); + let adjustedSize = transformedSize; + const projectedCenter = transformMat4$1([], [point.x, point.y, 0, 1], pixelPosMatrix); + if (this.paint.get('circle-pitch-scale') === 'viewport' && this.paint.get('circle-pitch-alignment') === 'map') { + adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance; + } + else if (this.paint.get('circle-pitch-scale') === 'map' && this.paint.get('circle-pitch-alignment') === 'viewport') { + adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3]; + } + if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) + return true; + } + } + return false; + } +} +function projectPoint(p, pixelPosMatrix) { + const point = transformMat4$1([], [p.x, p.y, 0, 1], pixelPosMatrix); + return new Point$2(point[0] / point[3], point[1] / point[3]); +} +function projectQueryGeometry$1(queryGeometry, pixelPosMatrix) { + return queryGeometry.map((p) => { + return projectPoint(p, pixelPosMatrix); + }); +} + +class HeatmapBucket extends CircleBucket { +} +register('HeatmapBucket', HeatmapBucket, { omit: ['layers'] }); + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let paint$7; +const getPaint$7 = () => paint$7 = paint$7 || new Properties({ + "heatmap-radius": new DataDrivenProperty(v8Spec["paint_heatmap"]["heatmap-radius"]), + "heatmap-weight": new DataDrivenProperty(v8Spec["paint_heatmap"]["heatmap-weight"]), + "heatmap-intensity": new DataConstantProperty(v8Spec["paint_heatmap"]["heatmap-intensity"]), + "heatmap-color": new ColorRampProperty(v8Spec["paint_heatmap"]["heatmap-color"]), + "heatmap-opacity": new DataConstantProperty(v8Spec["paint_heatmap"]["heatmap-opacity"]), +}); +var properties$7 = ({ get paint() { return getPaint$7(); } }); + +function createImage(image, { width, height }, channels, data) { + if (!data) { + data = new Uint8Array(width * height * channels); + } + else if (data instanceof Uint8ClampedArray) { + data = new Uint8Array(data.buffer); + } + else if (data.length !== width * height * channels) { + throw new RangeError(`mismatched image size. expected: ${data.length} but got: ${width * height * channels}`); + } + image.width = width; + image.height = height; + image.data = data; + return image; +} +function resizeImage(image, { width, height }, channels) { + if (width === image.width && height === image.height) { + return; + } + const newImage = createImage({}, { width, height }, channels); + copyImage(image, newImage, { x: 0, y: 0 }, { x: 0, y: 0 }, { + width: Math.min(image.width, width), + height: Math.min(image.height, height) + }, channels); + image.width = width; + image.height = height; + image.data = newImage.data; +} +function copyImage(srcImg, dstImg, srcPt, dstPt, size, channels) { + if (size.width === 0 || size.height === 0) { + return dstImg; + } + if (size.width > srcImg.width || + size.height > srcImg.height || + srcPt.x > srcImg.width - size.width || + srcPt.y > srcImg.height - size.height) { + throw new RangeError('out of range source coordinates for image copy'); + } + if (size.width > dstImg.width || + size.height > dstImg.height || + dstPt.x > dstImg.width - size.width || + dstPt.y > dstImg.height - size.height) { + throw new RangeError('out of range destination coordinates for image copy'); + } + const srcData = srcImg.data; + const dstData = dstImg.data; + if (srcData === dstData) + throw new Error('srcData equals dstData, so image is already copied'); + for (let y = 0; y < size.height; y++) { + const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels; + const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels; + for (let i = 0; i < size.width * channels; i++) { + dstData[dstOffset + i] = srcData[srcOffset + i]; + } + } + return dstImg; +} +/** + * @internal + * An image with alpha color value + */ +class AlphaImage { + constructor(size, data) { + createImage(this, size, 1, data); + } + resize(size) { + resizeImage(this, size, 1); + } + clone() { + return new AlphaImage({ width: this.width, height: this.height }, new Uint8Array(this.data)); + } + static copy(srcImg, dstImg, srcPt, dstPt, size) { + copyImage(srcImg, dstImg, srcPt, dstPt, size, 1); + } +} +/** + * An object to store image data not premultiplied, because ImageData is not premultiplied. + * UNPACK_PREMULTIPLY_ALPHA_WEBGL must be used when uploading to a texture. + */ +class RGBAImage { + constructor(size, data) { + createImage(this, size, 4, data); + } + resize(size) { + resizeImage(this, size, 4); + } + replace(data, copy) { + if (copy) { + this.data.set(data); + } + else if (data instanceof Uint8ClampedArray) { + this.data = new Uint8Array(data.buffer); + } + else { + this.data = data; + } + } + clone() { + return new RGBAImage({ width: this.width, height: this.height }, new Uint8Array(this.data)); + } + static copy(srcImg, dstImg, srcPt, dstPt, size) { + copyImage(srcImg, dstImg, srcPt, dstPt, size, 4); + } +} +register('AlphaImage', AlphaImage); +register('RGBAImage', RGBAImage); + +/** + * Given an expression that should evaluate to a color ramp, + * return a RGBA image representing that ramp expression. + */ +function renderColorRamp(params) { + const evaluationGlobals = {}; + const width = params.resolution || 256; + const height = params.clips ? params.clips.length : 1; + const image = params.image || new RGBAImage({ width, height }); + if (!isPowerOfTwo(width)) + throw new Error(`width is not a power of 2 - ${width}`); + const renderPixel = (stride, index, progress) => { + evaluationGlobals[params.evaluationKey] = progress; + const pxColor = params.expression.evaluate(evaluationGlobals); + // the colors are being unpremultiplied because Color uses + // premultiplied values, and the Texture class expects unpremultiplied ones + image.data[stride + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a); + image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a); + image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a); + image.data[stride + index + 3] = Math.floor(pxColor.a * 255); + }; + if (!params.clips) { + for (let i = 0, j = 0; i < width; i++, j += 4) { + const progress = i / (width - 1); + renderPixel(0, j, progress); + } + } + else { + for (let clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) { + for (let i = 0, j = 0; i < width; i++, j += 4) { + // Remap progress between clips + const progress = i / (width - 1); + const { start, end } = params.clips[clip]; + const evaluationProgress = start * (1 - progress) + end * progress; + renderPixel(stride, j, evaluationProgress); + } + } + } + return image; +} + +/** + * A style layer that defines a heatmap + */ +class HeatmapStyleLayer extends StyleLayer { + createBucket(options) { + return new HeatmapBucket(options); + } + constructor(layer) { + super(layer, properties$7); + // make sure color ramp texture is generated for default heatmap color too + this._updateColorRamp(); + } + _handleSpecialPaintPropertyUpdate(name) { + if (name === 'heatmap-color') { + this._updateColorRamp(); + } + } + _updateColorRamp() { + const expression = this._transitionablePaint._values['heatmap-color'].value.expression; + this.colorRamp = renderColorRamp({ + expression, + evaluationKey: 'heatmapDensity', + image: this.colorRamp + }); + this.colorRampTexture = null; + } + resize() { + if (this.heatmapFbo) { + this.heatmapFbo.destroy(); + this.heatmapFbo = null; + } + } + queryRadius() { + return 0; + } + queryIntersectsFeature() { + return false; + } + hasOffscreenPass() { + return this.paint.get('heatmap-opacity') !== 0 && this.visibility !== 'none'; + } +} + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let paint$6; +const getPaint$6 = () => paint$6 = paint$6 || new Properties({ + "hillshade-illumination-direction": new DataConstantProperty(v8Spec["paint_hillshade"]["hillshade-illumination-direction"]), + "hillshade-illumination-anchor": new DataConstantProperty(v8Spec["paint_hillshade"]["hillshade-illumination-anchor"]), + "hillshade-exaggeration": new DataConstantProperty(v8Spec["paint_hillshade"]["hillshade-exaggeration"]), + "hillshade-shadow-color": new DataConstantProperty(v8Spec["paint_hillshade"]["hillshade-shadow-color"]), + "hillshade-highlight-color": new DataConstantProperty(v8Spec["paint_hillshade"]["hillshade-highlight-color"]), + "hillshade-accent-color": new DataConstantProperty(v8Spec["paint_hillshade"]["hillshade-accent-color"]), +}); +var properties$6 = ({ get paint() { return getPaint$6(); } }); + +class HillshadeStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$6); + } + hasOffscreenPass() { + return this.paint.get('hillshade-exaggeration') !== 0 && this.visibility !== 'none'; + } +} + +const layout$4 = createLayout([ + { name: 'a_pos', components: 2, type: 'Int16' } +], 4); +const { members: members$3, size: size$3, alignment: alignment$3 } = layout$4; + +var earcut$2 = {exports: {}}; + +var earcut_1 = earcut$2.exports; + +'use strict'; + +earcut$2.exports = earcut; +var _default = earcut$2.exports.default = earcut; + +function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; + + if (!outerNode || outerNode.next === outerNode.prev) return triangles; + + var minX, minY, maxX, maxY, x, y, invSize; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and invSize are later used to transform coords into integers for z-order calculation + invSize = Math.max(maxX - minX, maxY - minY); + invSize = invSize !== 0 ? 32767 / invSize : 0; + } + + earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0); + + return triangles; +} + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea$1(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) break; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && invSize) indexCurve(ear, minX, minY, invSize); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim | 0); + triangles.push(ear.i / dim | 0); + triangles.push(next.i / dim | 0); + + removeNode(ear); + + // skipping the next vertex leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(filterPoints(ear), triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, invSize); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y; + + // triangle bbox; min & max are calculated like this for speed + var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx), + y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy), + x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx), + y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy); + + var p = c.next; + while (p !== a) { + if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && + pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, invSize) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y; + + // triangle bbox; min & max are calculated like this for speed + var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx), + y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy), + x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx), + y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy); + + // z-order range for the current triangle bbox; + var minZ = zOrder(x0, y0, minX, minY, invSize), + maxZ = zOrder(x1, y1, minX, minY, invSize); + + var p = ear.prevZ, + n = ear.nextZ; + + // look for points inside the triangle in both directions + while (p && p.z >= minZ && n && n.z <= maxZ) { + if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + + if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + + // look for remaining points in decreasing z-order + while (p && p.z >= minZ) { + if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + // look for remaining points in increasing z-order + while (n && n.z <= maxZ) { + if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim | 0); + triangles.push(p.i / dim | 0); + triangles.push(b.i / dim | 0); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return filterPoints(p); +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, invSize) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, invSize, 0); + earcutLinked(c, triangles, dim, minX, minY, invSize, 0); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + outerNode = eliminateHole(queue[i], outerNode); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + var bridge = findHoleBridge(hole, outerNode); + if (!bridge) { + return outerNode; + } + + var bridgeReverse = splitPolygon(bridge, hole); + + // filter collinear points around the cuts + filterPoints(bridgeReverse, bridgeReverse.next); + return filterPoints(bridge, bridge.next); +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + m = p.x < p.next.x ? p : p.next; + if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m; + + do { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if (locallyInside(p, hole) && + (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } while (p !== stop); + + return m; +} + +// whether sector in vertex m contains sector in vertex p in the same coordinates +function sectorContainsSector(m, p) { + return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, invSize) { + var p = start; + do { + if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and inverse of the longer side of data bbox +function zOrder(x, y, minX, minY, invSize) { + // coords are transformed into non-negative 15-bit integer range + x = (x - minX) * invSize | 0; + y = (y - minY) * invSize | 0; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && + (ax - px) * (by - py) >= (bx - px) * (ay - py) && + (bx - px) * (cy - py) >= (cx - px) * (by - py); +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges + (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible + (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors + equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + var o1 = sign(area(p1, q1, p2)); + var o2 = sign(area(p1, q1, q2)); + var o3 = sign(area(p2, q2, p1)); + var o4 = sign(area(p2, q2, q1)); + + if (o1 !== o2 && o3 !== o4) return true; // general case + + if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; +} + +// for collinear points p, q, r, check if point q lies on segment pr +function onSegment(p, q, r) { + return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y); +} + +function sign(num) { + return num > 0 ? 1 : num < 0 ? -1 : 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertex index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertex nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = 0; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea$1(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea$1(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea$1(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; + +var earcutExports = earcut$2.exports; +var earcut$1 = /*@__PURE__*/getDefaultExportFromCjs(earcutExports); + +function quickselect(arr, k, left, right, compare) { + quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare$1); +} + +function quickselectStep(arr, k, left, right, compare) { + + while (right > left) { + if (right - left > 600) { + var n = right - left + 1; + var m = k - left + 1; + var z = Math.log(n); + var s = 0.5 * Math.exp(2 * z / 3); + var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + quickselectStep(arr, k, newLeft, newRight, compare); + } + + var t = arr[k]; + var i = left; + var j = right; + + swap$1(arr, left, k); + if (compare(arr[right], t) > 0) swap$1(arr, left, right); + + while (i < j) { + swap$1(arr, i, j); + i++; + j--; + while (compare(arr[i], t) < 0) i++; + while (compare(arr[j], t) > 0) j--; + } + + if (compare(arr[left], t) === 0) swap$1(arr, left, j); + else { + j++; + swap$1(arr, j, right); + } + + if (j <= k) left = j + 1; + if (k <= j) right = j - 1; + } +} + +function swap$1(arr, i, j) { + var tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +function defaultCompare$1(a, b) { + return a < b ? -1 : a > b ? 1 : 0; +} + +// classifies an array of rings into polygons with outer rings and holes +function classifyRings$1(rings, maxRings) { + const len = rings.length; + if (len <= 1) + return [rings]; + const polygons = []; + let polygon, ccw; + for (let i = 0; i < len; i++) { + const area = calculateSignedArea(rings[i]); + if (area === 0) + continue; + rings[i].area = Math.abs(area); + if (ccw === undefined) + ccw = area < 0; + if (ccw === area < 0) { + if (polygon) + polygons.push(polygon); + polygon = [rings[i]]; + } + else { + polygon.push(rings[i]); + } + } + if (polygon) + polygons.push(polygon); + // Earcut performance degrades with the # of rings in a polygon. For this + // reason, we limit strip out all but the `maxRings` largest rings. + if (maxRings > 1) { + for (let j = 0; j < polygons.length; j++) { + if (polygons[j].length <= maxRings) + continue; + quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas); + polygons[j] = polygons[j].slice(0, maxRings); + } + } + return polygons; +} +function compareAreas(a, b) { + return b.area - a.area; +} + +function hasPattern(type, layers, options) { + const patterns = options.patternDependencies; + let hasPattern = false; + for (const layer of layers) { + const patternProperty = layer.paint.get(`${type}-pattern`); + if (!patternProperty.isConstant()) { + hasPattern = true; + } + const constantPattern = patternProperty.constantOr(null); + if (constantPattern) { + hasPattern = true; + patterns[constantPattern.to] = true; + patterns[constantPattern.from] = true; + } + } + return hasPattern; +} +function addPatternDependencies(type, layers, patternFeature, zoom, options) { + const patterns = options.patternDependencies; + for (const layer of layers) { + const patternProperty = layer.paint.get(`${type}-pattern`); + const patternPropertyValue = patternProperty.value; + if (patternPropertyValue.kind !== 'constant') { + let min = patternPropertyValue.evaluate({ zoom: zoom - 1 }, patternFeature, {}, options.availableImages); + let mid = patternPropertyValue.evaluate({ zoom }, patternFeature, {}, options.availableImages); + let max = patternPropertyValue.evaluate({ zoom: zoom + 1 }, patternFeature, {}, options.availableImages); + min = min && min.name ? min.name : min; + mid = mid && mid.name ? mid.name : mid; + max = max && max.name ? max.name : max; + // add to patternDependencies + patterns[min] = true; + patterns[mid] = true; + patterns[max] = true; + // save for layout + patternFeature.patterns[layer.id] = { min, mid, max }; + } + } + return patternFeature; +} + +const EARCUT_MAX_RINGS$1 = 500; +class FillBucket { + constructor(options) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + this.patternFeatures = []; + this.layoutVertexArray = new FillLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.indexArray2 = new LineIndexArray(); + this.programConfigurations = new ProgramConfigurationSet(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, options, canonical) { + this.hasPattern = hasPattern('fill', this.layers, options); + const fillSortKey = this.layers[0].layout.get('fill-sort-key'); + const sortFeaturesByKey = !fillSortKey.isConstant(); + const bucketFeatures = []; + for (const { feature, id, index, sourceLayerIndex } of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) + continue; + const sortKey = sortFeaturesByKey ? + fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) : + undefined; + const bucketFeature = { + id, + properties: feature.properties, + type: feature.type, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + patterns: {}, + sortKey + }; + bucketFeatures.push(bucketFeature); + } + if (sortFeaturesByKey) { + bucketFeatures.sort((a, b) => a.sortKey - b.sortKey); + } + for (const bucketFeature of bucketFeatures) { + const { geometry, index, sourceLayerIndex } = bucketFeature; + if (this.hasPattern) { + const patternFeature = addPatternDependencies('fill', this.layers, bucketFeature, this.zoom, options); + // pattern features are added only once the pattern is loaded into the image atlas + // so are stored during populate until later updated with positions by tile worker in addFeatures + this.patternFeatures.push(patternFeature); + } + else { + this.addFeature(bucketFeature, geometry, index, canonical, {}); + } + const feature = features[index].feature; + options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index); + } + } + update(states, vtLayer, imagePositions) { + if (!this.stateDependentLayers.length) + return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + addFeatures(options, canonical, imagePositions) { + for (const feature of this.patternFeatures) { + this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions); + } + } + isEmpty() { + return this.layoutVertexArray.length === 0; + } + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + upload(context) { + if (!this.uploaded) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$3); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + this.indexBuffer2 = context.createIndexBuffer(this.indexArray2); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + destroy() { + if (!this.layoutVertexBuffer) + return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.indexBuffer2.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + this.segments2.destroy(); + } + addFeature(feature, geometry, index, canonical, imagePositions) { + for (const polygon of classifyRings$1(geometry, EARCUT_MAX_RINGS$1)) { + let numVertices = 0; + for (const ring of polygon) { + numVertices += ring.length; + } + const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray); + const triangleIndex = triangleSegment.vertexLength; + const flattened = []; + const holeIndices = []; + for (const ring of polygon) { + if (ring.length === 0) { + continue; + } + if (ring !== polygon[0]) { + holeIndices.push(flattened.length / 2); + } + const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2); + const lineIndex = lineSegment.vertexLength; + this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y); + this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex); + flattened.push(ring[0].x); + flattened.push(ring[0].y); + for (let i = 1; i < ring.length; i++) { + this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y); + this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i); + flattened.push(ring[i].x); + flattened.push(ring[i].y); + } + lineSegment.vertexLength += ring.length; + lineSegment.primitiveLength += ring.length; + } + const indices = earcut$1(flattened, holeIndices); + for (let i = 0; i < indices.length; i += 3) { + this.indexArray.emplaceBack(triangleIndex + indices[i], triangleIndex + indices[i + 1], triangleIndex + indices[i + 2]); + } + triangleSegment.vertexLength += numVertices; + triangleSegment.primitiveLength += indices.length / 3; + } + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical); + } +} +register('FillBucket', FillBucket, { omit: ['layers', 'patternFeatures'] }); + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let layout$3; +const getLayout$2 = () => layout$3 = layout$3 || new Properties({ + "fill-sort-key": new DataDrivenProperty(v8Spec["layout_fill"]["fill-sort-key"]), +}); +let paint$5; +const getPaint$5 = () => paint$5 = paint$5 || new Properties({ + "fill-antialias": new DataConstantProperty(v8Spec["paint_fill"]["fill-antialias"]), + "fill-opacity": new DataDrivenProperty(v8Spec["paint_fill"]["fill-opacity"]), + "fill-color": new DataDrivenProperty(v8Spec["paint_fill"]["fill-color"]), + "fill-outline-color": new DataDrivenProperty(v8Spec["paint_fill"]["fill-outline-color"]), + "fill-translate": new DataConstantProperty(v8Spec["paint_fill"]["fill-translate"]), + "fill-translate-anchor": new DataConstantProperty(v8Spec["paint_fill"]["fill-translate-anchor"]), + "fill-pattern": new CrossFadedDataDrivenProperty(v8Spec["paint_fill"]["fill-pattern"]), +}); +var properties$5 = ({ get paint() { return getPaint$5(); }, get layout() { return getLayout$2(); } }); + +class FillStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$5); + } + recalculate(parameters, availableImages) { + super.recalculate(parameters, availableImages); + const outlineColor = this.paint._values['fill-outline-color']; + if (outlineColor.value.kind === 'constant' && outlineColor.value.value === undefined) { + this.paint._values['fill-outline-color'] = this.paint._values['fill-color']; + } + } + createBucket(parameters) { + return new FillBucket(parameters); + } + queryRadius() { + return translateDistance(this.paint.get('fill-translate')); + } + queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits) { + const translatedPolygon = translate$4(queryGeometry, this.paint.get('fill-translate'), this.paint.get('fill-translate-anchor'), transform.angle, pixelsToTileUnits); + return polygonIntersectsMultiPolygon(translatedPolygon, geometry); + } + isTileClipped() { + return true; + } +} + +const layout$2 = createLayout([ + { name: 'a_pos', components: 2, type: 'Int16' }, + { name: 'a_normal_ed', components: 4, type: 'Int16' }, +], 4); +const centroidAttributes = createLayout([ + { name: 'a_centroid', components: 2, type: 'Int16' } +], 4); +const { members: members$2, size: size$2, alignment: alignment$2 } = layout$2; + +var vectorTile = {}; + +'use strict'; + +var Point = pointGeometry; + +var vectortilefeature = VectorTileFeature$2; + +function VectorTileFeature$2(pbf, end, extent, keys, values) { + // Public + this.properties = {}; + this.extent = extent; + this.type = 0; + + // Private + this._pbf = pbf; + this._geometry = -1; + this._keys = keys; + this._values = values; + + pbf.readFields(readFeature, this, end); +} + +function readFeature(tag, feature, pbf) { + if (tag == 1) feature.id = pbf.readVarint(); + else if (tag == 2) readTag(pbf, feature); + else if (tag == 3) feature.type = pbf.readVarint(); + else if (tag == 4) feature._geometry = pbf.pos; +} + +function readTag(pbf, feature) { + var end = pbf.readVarint() + pbf.pos; + + while (pbf.pos < end) { + var key = feature._keys[pbf.readVarint()], + value = feature._values[pbf.readVarint()]; + feature.properties[key] = value; + } +} + +VectorTileFeature$2.types = ['Unknown', 'Point', 'LineString', 'Polygon']; + +VectorTileFeature$2.prototype.loadGeometry = function() { + var pbf = this._pbf; + pbf.pos = this._geometry; + + var end = pbf.readVarint() + pbf.pos, + cmd = 1, + length = 0, + x = 0, + y = 0, + lines = [], + line; + + while (pbf.pos < end) { + if (length <= 0) { + var cmdLen = pbf.readVarint(); + cmd = cmdLen & 0x7; + length = cmdLen >> 3; + } + + length--; + + if (cmd === 1 || cmd === 2) { + x += pbf.readSVarint(); + y += pbf.readSVarint(); + + if (cmd === 1) { // moveTo + if (line) lines.push(line); + line = []; + } + + line.push(new Point(x, y)); + + } else if (cmd === 7) { + + // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90 + if (line) { + line.push(line[0].clone()); // closePolygon + } + + } else { + throw new Error('unknown command ' + cmd); + } + } + + if (line) lines.push(line); + + return lines; +}; + +VectorTileFeature$2.prototype.bbox = function() { + var pbf = this._pbf; + pbf.pos = this._geometry; + + var end = pbf.readVarint() + pbf.pos, + cmd = 1, + length = 0, + x = 0, + y = 0, + x1 = Infinity, + x2 = -Infinity, + y1 = Infinity, + y2 = -Infinity; + + while (pbf.pos < end) { + if (length <= 0) { + var cmdLen = pbf.readVarint(); + cmd = cmdLen & 0x7; + length = cmdLen >> 3; + } + + length--; + + if (cmd === 1 || cmd === 2) { + x += pbf.readSVarint(); + y += pbf.readSVarint(); + if (x < x1) x1 = x; + if (x > x2) x2 = x; + if (y < y1) y1 = y; + if (y > y2) y2 = y; + + } else if (cmd !== 7) { + throw new Error('unknown command ' + cmd); + } + } + + return [x1, y1, x2, y2]; +}; + +VectorTileFeature$2.prototype.toGeoJSON = function(x, y, z) { + var size = this.extent * Math.pow(2, z), + x0 = this.extent * x, + y0 = this.extent * y, + coords = this.loadGeometry(), + type = VectorTileFeature$2.types[this.type], + i, j; + + function project(line) { + for (var j = 0; j < line.length; j++) { + var p = line[j], y2 = 180 - (p.y + y0) * 360 / size; + line[j] = [ + (p.x + x0) * 360 / size - 180, + 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90 + ]; + } + } + + switch (this.type) { + case 1: + var points = []; + for (i = 0; i < coords.length; i++) { + points[i] = coords[i][0]; + } + coords = points; + project(coords); + break; + + case 2: + for (i = 0; i < coords.length; i++) { + project(coords[i]); + } + break; + + case 3: + coords = classifyRings(coords); + for (i = 0; i < coords.length; i++) { + for (j = 0; j < coords[i].length; j++) { + project(coords[i][j]); + } + } + break; + } + + if (coords.length === 1) { + coords = coords[0]; + } else { + type = 'Multi' + type; + } + + var result = { + type: "Feature", + geometry: { + type: type, + coordinates: coords + }, + properties: this.properties + }; + + if ('id' in this) { + result.id = this.id; + } + + return result; +}; + +// classifies an array of rings into polygons with outer rings and holes + +function classifyRings(rings) { + var len = rings.length; + + if (len <= 1) return [rings]; + + var polygons = [], + polygon, + ccw; + + for (var i = 0; i < len; i++) { + var area = signedArea(rings[i]); + if (area === 0) continue; + + if (ccw === undefined) ccw = area < 0; + + if (ccw === area < 0) { + if (polygon) polygons.push(polygon); + polygon = [rings[i]]; + + } else { + polygon.push(rings[i]); + } + } + if (polygon) polygons.push(polygon); + + return polygons; +} + +function signedArea(ring) { + var sum = 0; + for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) { + p1 = ring[i]; + p2 = ring[j]; + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + return sum; +} + +var vectortilefeature$1 = /*@__PURE__*/getDefaultExportFromCjs(vectortilefeature); + +'use strict'; + +var VectorTileFeature$1 = vectortilefeature; + +var vectortilelayer = VectorTileLayer$2; + +function VectorTileLayer$2(pbf, end) { + // Public + this.version = 1; + this.name = null; + this.extent = 4096; + this.length = 0; + + // Private + this._pbf = pbf; + this._keys = []; + this._values = []; + this._features = []; + + pbf.readFields(readLayer, this, end); + + this.length = this._features.length; +} + +function readLayer(tag, layer, pbf) { + if (tag === 15) layer.version = pbf.readVarint(); + else if (tag === 1) layer.name = pbf.readString(); + else if (tag === 5) layer.extent = pbf.readVarint(); + else if (tag === 2) layer._features.push(pbf.pos); + else if (tag === 3) layer._keys.push(pbf.readString()); + else if (tag === 4) layer._values.push(readValueMessage(pbf)); +} + +function readValueMessage(pbf) { + var value = null, + end = pbf.readVarint() + pbf.pos; + + while (pbf.pos < end) { + var tag = pbf.readVarint() >> 3; + + value = tag === 1 ? pbf.readString() : + tag === 2 ? pbf.readFloat() : + tag === 3 ? pbf.readDouble() : + tag === 4 ? pbf.readVarint64() : + tag === 5 ? pbf.readVarint() : + tag === 6 ? pbf.readSVarint() : + tag === 7 ? pbf.readBoolean() : null; + } + + return value; +} + +// return feature `i` from this layer as a `VectorTileFeature` +VectorTileLayer$2.prototype.feature = function(i) { + if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds'); + + this._pbf.pos = this._features[i]; + + var end = this._pbf.readVarint() + this._pbf.pos; + return new VectorTileFeature$1(this._pbf, end, this.extent, this._keys, this._values); +}; + +var vectortilelayer$1 = /*@__PURE__*/getDefaultExportFromCjs(vectortilelayer); + +'use strict'; + +var VectorTileLayer$1 = vectortilelayer; + +var vectortile = VectorTile$1; + +function VectorTile$1(pbf, end) { + this.layers = pbf.readFields(readTile, {}, end); +} + +function readTile(tag, layers, pbf) { + if (tag === 3) { + var layer = new VectorTileLayer$1(pbf, pbf.readVarint() + pbf.pos); + if (layer.length) layers[layer.name] = layer; + } +} + +var vectortile$1 = /*@__PURE__*/getDefaultExportFromCjs(vectortile); + +var VectorTile = vectorTile.VectorTile = vectortile; +var VectorTileFeature = vectorTile.VectorTileFeature = vectortilefeature; +var VectorTileLayer = vectorTile.VectorTileLayer = vectortilelayer; + +const vectorTileFeatureTypes$2 = vectorTile.VectorTileFeature.types; +const EARCUT_MAX_RINGS = 500; +const FACTOR = Math.pow(2, 13); +function addVertex$1(vertexArray, x, y, nx, ny, nz, t, e) { + vertexArray.emplaceBack( + // a_pos + x, y, + // a_normal_ed: 3-component normal and 1-component edgedistance + Math.floor(nx * FACTOR) * 2 + t, ny * FACTOR * 2, nz * FACTOR * 2, + // edgedistance (used for wrapping patterns around extrusion sides) + Math.round(e)); +} +class FillExtrusionBucket { + constructor(options) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + this.layoutVertexArray = new FillExtrusionLayoutArray(); + this.centroidVertexArray = new PosArray(); + this.indexArray = new TriangleIndexArray(); + this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom); + this.segments = new SegmentVector(); + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + } + populate(features, options, canonical) { + this.features = []; + this.hasPattern = hasPattern('fill-extrusion', this.layers, options); + for (const { feature, id, index, sourceLayerIndex } of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) + continue; + const bucketFeature = { + id, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + properties: feature.properties, + type: feature.type, + patterns: {} + }; + if (this.hasPattern) { + this.features.push(addPatternDependencies('fill-extrusion', this.layers, bucketFeature, this.zoom, options)); + } + else { + this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {}); + } + options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true); + } + } + addFeatures(options, canonical, imagePositions) { + for (const feature of this.features) { + const { geometry } = feature; + this.addFeature(feature, geometry, feature.index, canonical, imagePositions); + } + } + update(states, vtLayer, imagePositions) { + if (!this.stateDependentLayers.length) + return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + isEmpty() { + return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0; + } + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + upload(context) { + if (!this.uploaded) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$2); + this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + destroy() { + if (!this.layoutVertexBuffer) + return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + this.centroidVertexBuffer.destroy(); + } + addFeature(feature, geometry, index, canonical, imagePositions) { + const centroid = { x: 0, y: 0, vertexCount: 0 }; + for (const polygon of classifyRings$1(geometry, EARCUT_MAX_RINGS)) { + let numVertices = 0; + for (const ring of polygon) { + numVertices += ring.length; + } + let segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray); + for (const ring of polygon) { + if (ring.length === 0) { + continue; + } + if (isEntirelyOutside(ring)) { + continue; + } + let edgeDistance = 0; + for (let p = 0; p < ring.length; p++) { + const p1 = ring[p]; + if (p >= 1) { + const p2 = ring[p - 1]; + if (!isBoundaryEdge(p1, p2)) { + if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) { + segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray); + } + const perp = p1.sub(p2)._perp()._unit(); + const dist = p2.dist(p1); + if (edgeDistance + dist > 32768) + edgeDistance = 0; + addVertex$1(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance); + addVertex$1(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance); + centroid.x += 2 * p1.x; + centroid.y += 2 * p1.y; + centroid.vertexCount += 2; + edgeDistance += dist; + addVertex$1(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance); + addVertex$1(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance); + centroid.x += 2 * p2.x; + centroid.y += 2 * p2.y; + centroid.vertexCount += 2; + const bottomRight = segment.vertexLength; + // ┌──────┐ + // │ 0 1 │ Counter-clockwise winding order. + // │ │ Triangle 1: 0 => 2 => 1 + // │ 2 3 │ Triangle 2: 1 => 2 => 3 + // └──────┘ + this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1); + this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3); + segment.vertexLength += 4; + segment.primitiveLength += 2; + } + } + } + } + if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) { + segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray); + } + //Only triangulate and draw the area of the feature if it is a polygon + //Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined + if (vectorTileFeatureTypes$2[feature.type] !== 'Polygon') + continue; + const flattened = []; + const holeIndices = []; + const triangleIndex = segment.vertexLength; + for (const ring of polygon) { + if (ring.length === 0) { + continue; + } + if (ring !== polygon[0]) { + holeIndices.push(flattened.length / 2); + } + for (let i = 0; i < ring.length; i++) { + const p = ring[i]; + addVertex$1(this.layoutVertexArray, p.x, p.y, 0, 0, 1, 1, 0); + centroid.x += p.x; + centroid.y += p.y; + centroid.vertexCount += 1; + flattened.push(p.x); + flattened.push(p.y); + } + } + const indices = earcut$1(flattened, holeIndices); + for (let j = 0; j < indices.length; j += 3) { + // Counter-clockwise winding order. + this.indexArray.emplaceBack(triangleIndex + indices[j], triangleIndex + indices[j + 2], triangleIndex + indices[j + 1]); + } + segment.primitiveLength += indices.length / 3; + segment.vertexLength += numVertices; + } + // remember polygon centroid to calculate elevation in GPU + for (let i = 0; i < centroid.vertexCount; i++) { + this.centroidVertexArray.emplaceBack(Math.floor(centroid.x / centroid.vertexCount), Math.floor(centroid.y / centroid.vertexCount)); + } + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical); + } +} +register('FillExtrusionBucket', FillExtrusionBucket, { omit: ['layers', 'features'] }); +function isBoundaryEdge(p1, p2) { + return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) || + (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT)); +} +function isEntirelyOutside(ring) { + return ring.every(p => p.x < 0) || + ring.every(p => p.x > EXTENT) || + ring.every(p => p.y < 0) || + ring.every(p => p.y > EXTENT); +} + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let paint$4; +const getPaint$4 = () => paint$4 = paint$4 || new Properties({ + "fill-extrusion-opacity": new DataConstantProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-opacity"]), + "fill-extrusion-color": new DataDrivenProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-color"]), + "fill-extrusion-translate": new DataConstantProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-translate"]), + "fill-extrusion-translate-anchor": new DataConstantProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]), + "fill-extrusion-pattern": new CrossFadedDataDrivenProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-pattern"]), + "fill-extrusion-height": new DataDrivenProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-height"]), + "fill-extrusion-base": new DataDrivenProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-base"]), + "fill-extrusion-vertical-gradient": new DataConstantProperty(v8Spec["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]), +}); +var properties$4 = ({ get paint() { return getPaint$4(); } }); + +class Point3D extends Point$2 { +} +class FillExtrusionStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$4); + } + createBucket(parameters) { + return new FillExtrusionBucket(parameters); + } + queryRadius() { + return translateDistance(this.paint.get('fill-extrusion-translate')); + } + is3D() { + return true; + } + queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits, pixelPosMatrix) { + const translatedPolygon = translate$4(queryGeometry, this.paint.get('fill-extrusion-translate'), this.paint.get('fill-extrusion-translate-anchor'), transform.angle, pixelsToTileUnits); + const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState); + const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState); + const projectedQueryGeometry = projectQueryGeometry(translatedPolygon, pixelPosMatrix, transform, 0); + const projected = projectExtrusion(geometry, base, height, pixelPosMatrix); + const projectedBase = projected[0]; + const projectedTop = projected[1]; + return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry); + } +} +function dot(a, b) { + return a.x * b.x + a.y * b.y; +} +function getIntersectionDistance(projectedQueryGeometry, projectedFace) { + if (projectedQueryGeometry.length === 1) { + // For point queries calculate the z at which the point intersects the face + // using barycentric coordinates. + // Find the barycentric coordinates of the projected point within the first + // triangle of the face, using only the xy plane. It doesn't matter if the + // point is outside the first triangle because all the triangles in the face + // are in the same plane. + // + // Check whether points are coincident and use other points if they are. + let i = 0; + const a = projectedFace[i++]; + let b; + while (!b || a.equals(b)) { + b = projectedFace[i++]; + if (!b) + return Infinity; + } + // Loop until point `c` is not colinear with points `a` and `b`. + for (; i < projectedFace.length; i++) { + const c = projectedFace[i]; + const p = projectedQueryGeometry[0]; + const ab = b.sub(a); + const ac = c.sub(a); + const ap = p.sub(a); + const dotABAB = dot(ab, ab); + const dotABAC = dot(ab, ac); + const dotACAC = dot(ac, ac); + const dotAPAB = dot(ap, ab); + const dotAPAC = dot(ap, ac); + const denom = dotABAB * dotACAC - dotABAC * dotABAC; + const v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom; + const w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom; + const u = 1 - v - w; + // Use the barycentric weighting along with the original triangle z coordinates to get the point of intersection. + const distance = a.z * u + b.z * v + c.z * w; + if (isFinite(distance)) + return distance; + } + return Infinity; + } + else { + // The counts as closest is less clear when the query is a box. This + // returns the distance to the nearest point on the face, whether it is + // within the query or not. It could be more correct to return the + // distance to the closest point within the query box but this would be + // more complicated and expensive to calculate with little benefit. + let closestDistance = Infinity; + for (const p of projectedFace) { + closestDistance = Math.min(closestDistance, p.z); + } + return closestDistance; + } +} +function checkIntersection(projectedBase, projectedTop, projectedQueryGeometry) { + let closestDistance = Infinity; + if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) { + closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]); + } + for (let r = 0; r < projectedTop.length; r++) { + const ringTop = projectedTop[r]; + const ringBase = projectedBase[r]; + for (let p = 0; p < ringTop.length - 1; p++) { + const topA = ringTop[p]; + const topB = ringTop[p + 1]; + const baseA = ringBase[p]; + const baseB = ringBase[p + 1]; + const face = [topA, topB, baseB, baseA, topA]; + if (polygonIntersectsPolygon(projectedQueryGeometry, face)) { + closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face)); + } + } + } + return closestDistance === Infinity ? false : closestDistance; +} +/* + * Project the geometry using matrix `m`. This is essentially doing + * `vec4.transformMat4([], [p.x, p.y, z, 1], m)` but the multiplication + * is inlined so that parts of the projection that are the same across + * different points can only be done once. This produced a measurable + * performance improvement. + */ +function projectExtrusion(geometry, zBase, zTop, m) { + const projectedBase = []; + const projectedTop = []; + const baseXZ = m[8] * zBase; + const baseYZ = m[9] * zBase; + const baseZZ = m[10] * zBase; + const baseWZ = m[11] * zBase; + const topXZ = m[8] * zTop; + const topYZ = m[9] * zTop; + const topZZ = m[10] * zTop; + const topWZ = m[11] * zTop; + for (const r of geometry) { + const ringBase = []; + const ringTop = []; + for (const p of r) { + const x = p.x; + const y = p.y; + const sX = m[0] * x + m[4] * y + m[12]; + const sY = m[1] * x + m[5] * y + m[13]; + const sZ = m[2] * x + m[6] * y + m[14]; + const sW = m[3] * x + m[7] * y + m[15]; + const baseX = sX + baseXZ; + const baseY = sY + baseYZ; + const baseZ = sZ + baseZZ; + const baseW = sW + baseWZ; + const topX = sX + topXZ; + const topY = sY + topYZ; + const topZ = sZ + topZZ; + const topW = sW + topWZ; + const b = new Point$2(baseX / baseW, baseY / baseW); + b.z = baseZ / baseW; + ringBase.push(b); + const t = new Point$2(topX / topW, topY / topW); + t.z = topZ / topW; + ringTop.push(t); + } + projectedBase.push(ringBase); + projectedTop.push(ringTop); + } + return [projectedBase, projectedTop]; +} +function projectQueryGeometry(queryGeometry, pixelPosMatrix, transform, z) { + const projectedQueryGeometry = []; + for (const p of queryGeometry) { + const v = [p.x, p.y, z, 1]; + transformMat4$1(v, v, pixelPosMatrix); + projectedQueryGeometry.push(new Point$2(v[0] / v[3], v[1] / v[3])); + } + return projectedQueryGeometry; +} + +const lineLayoutAttributes = createLayout([ + { name: 'a_pos_normal', components: 2, type: 'Int16' }, + { name: 'a_data', components: 4, type: 'Uint8' } +], 4); +const { members: members$1, size: size$1, alignment: alignment$1 } = lineLayoutAttributes; + +const lineLayoutAttributesExt = createLayout([ + { name: 'a_uv_x', components: 1, type: 'Float32' }, + { name: 'a_split_index', components: 1, type: 'Float32' }, +]); +const { members, size, alignment } = lineLayoutAttributesExt; + +const vectorTileFeatureTypes$1 = vectorTile.VectorTileFeature.types; +// NOTE ON EXTRUDE SCALE: +// scale the extrusion vector so that the normal length is this value. +// contains the "texture" normals (-1..1). this is distinct from the extrude +// normals for line joins, because the x-value remains 0 for the texture +// normal array, while the extrude normal actually moves the vertex to create +// the acute/bevelled line join. +const EXTRUDE_SCALE = 63; +/* + * Sharp corners cause dashed lines to tilt because the distance along the line + * is the same at both the inner and outer corners. To improve the appearance of + * dashed lines we add extra points near sharp corners so that a smaller part + * of the line is tilted. + * + * COS_HALF_SHARP_CORNER controls how sharp a corner has to be for us to add an + * extra vertex. The default is 75 degrees. + * + * The newly created vertices are placed SHARP_CORNER_OFFSET pixels from the corner. + */ +const COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180)); +const SHARP_CORNER_OFFSET = 15; +// Angle per triangle for approximating round line joins. +const DEG_PER_TRIANGLE = 20; +// The number of bits that is used to store the line distance in the buffer. +const LINE_DISTANCE_BUFFER_BITS = 15; +// We don't have enough bits for the line distance as we'd like to have, so +// use this value to scale the line distance (in tile units) down to a smaller +// value. This lets us store longer distances while sacrificing precision. +const LINE_DISTANCE_SCALE = 1 / 2; +// The maximum line distance, in tile units, that fits in the buffer. +const MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE; +/** + * @internal + * Line bucket class + */ +class LineBucket { + constructor(options) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + this.patternFeatures = []; + this.lineClipsArray = []; + this.gradients = {}; + this.layers.forEach(layer => { + this.gradients[layer.id] = {}; + }); + this.layoutVertexArray = new LineLayoutArray(); + this.layoutVertexArray2 = new LineExtLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom); + this.segments = new SegmentVector(); + this.maxLineLength = 0; + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + } + populate(features, options, canonical) { + this.hasPattern = hasPattern('line', this.layers, options); + const lineSortKey = this.layers[0].layout.get('line-sort-key'); + const sortFeaturesByKey = !lineSortKey.isConstant(); + const bucketFeatures = []; + for (const { feature, id, index, sourceLayerIndex } of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) + continue; + const sortKey = sortFeaturesByKey ? + lineSortKey.evaluate(evaluationFeature, {}, canonical) : + undefined; + const bucketFeature = { + id, + properties: feature.properties, + type: feature.type, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + patterns: {}, + sortKey + }; + bucketFeatures.push(bucketFeature); + } + if (sortFeaturesByKey) { + bucketFeatures.sort((a, b) => { + return (a.sortKey) - (b.sortKey); + }); + } + for (const bucketFeature of bucketFeatures) { + const { geometry, index, sourceLayerIndex } = bucketFeature; + if (this.hasPattern) { + const patternBucketFeature = addPatternDependencies('line', this.layers, bucketFeature, this.zoom, options); + // pattern features are added only once the pattern is loaded into the image atlas + // so are stored during populate until later updated with positions by tile worker in addFeatures + this.patternFeatures.push(patternBucketFeature); + } + else { + this.addFeature(bucketFeature, geometry, index, canonical, {}); + } + const feature = features[index].feature; + options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index); + } + } + update(states, vtLayer, imagePositions) { + if (!this.stateDependentLayers.length) + return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + addFeatures(options, canonical, imagePositions) { + for (const feature of this.patternFeatures) { + this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions); + } + } + isEmpty() { + return this.layoutVertexArray.length === 0; + } + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + upload(context) { + if (!this.uploaded) { + if (this.layoutVertexArray2.length !== 0) { + this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, members); + } + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$1); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + destroy() { + if (!this.layoutVertexBuffer) + return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + } + lineFeatureClips(feature) { + 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']; + return { start, end }; + } + } + addFeature(feature, geometry, index, canonical, imagePositions) { + const layout = this.layers[0].layout; + const join = layout.get('line-join').evaluate(feature, {}); + const cap = layout.get('line-cap'); + const miterLimit = layout.get('line-miter-limit'); + const roundLimit = layout.get('line-round-limit'); + this.lineClips = this.lineFeatureClips(feature); + for (const line of geometry) { + this.addLine(line, feature, join, cap, miterLimit, roundLimit); + } + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical); + } + addLine(vertices, feature, join, cap, miterLimit, roundLimit) { + this.distance = 0; + this.scaledDistance = 0; + this.totalDistance = 0; + if (this.lineClips) { + this.lineClipsArray.push(this.lineClips); + // Calculate the total distance, in tile units, of this tiled line feature + for (let i = 0; i < vertices.length - 1; i++) { + this.totalDistance += vertices[i].dist(vertices[i + 1]); + } + this.updateScaledDistance(); + this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance); + } + const isPolygon = vectorTileFeatureTypes$1[feature.type] === 'Polygon'; + // If the line has duplicate vertices at the ends, adjust start/length to remove them. + let len = vertices.length; + while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) { + len--; + } + let first = 0; + while (first < len - 1 && vertices[first].equals(vertices[first + 1])) { + first++; + } + // Ignore invalid geometry. + if (len < (isPolygon ? 3 : 2)) + return; + if (join === 'bevel') + miterLimit = 1.05; + const sharpCornerOffset = this.overscaling <= 16 ? + SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) : + 0; + // we could be more precise, but it would only save a negligible amount of space + const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray); + let currentVertex; + let prevVertex; + let nextVertex; + let prevNormal; + let nextNormal; + // the last two vertices added + this.e1 = this.e2 = -1; + if (isPolygon) { + currentVertex = vertices[len - 2]; + nextNormal = vertices[first].sub(currentVertex)._unit()._perp(); + } + for (let i = first; i < len; i++) { + nextVertex = i === len - 1 ? + (isPolygon ? vertices[first + 1] : undefined) : // if it's a polygon, treat the last vertex like the first + vertices[i + 1]; // just the next vertex + // if two consecutive vertices exist, skip the current one + if (nextVertex && vertices[i].equals(nextVertex)) + continue; + if (nextNormal) + prevNormal = nextNormal; + if (currentVertex) + prevVertex = currentVertex; + currentVertex = vertices[i]; + // Calculate the normal towards the next vertex in this line. In case + // there is no next vertex, pretend that the line is continuing straight, + // meaning that we are just using the previous normal. + nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal; + // If we still don't have a previous normal, this is the beginning of a + // non-closed line, so we're doing a straight "join". + prevNormal = prevNormal || nextNormal; + // Determine the normal of the join extrusion. It is the angle bisector + // of the segments between the previous line and the next line. + // In the case of 180° angles, the prev and next normals cancel each other out: + // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be + // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle + // below will also become 0 and miterLength will become Infinity. + let joinNormal = prevNormal.add(nextNormal); + if (joinNormal.x !== 0 || joinNormal.y !== 0) { + joinNormal._unit(); + } + /* joinNormal prevNormal + * ↖ ↑ + * .________. prevVertex + * | + * nextNormal ← | currentVertex + * | + * nextVertex ! + * + */ + // calculate cosines of the angle (and its half) using dot product + const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y; + const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y; + // Calculate the length of the miter (the ratio of the miter to the width) + // as the inverse of cosine of the angle between next and join normals + const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity; + // approximate angle from cosine + const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle); + const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex; + const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0; + if (isSharpCorner && i > first) { + const prevSegmentLength = currentVertex.dist(prevVertex); + if (prevSegmentLength > 2 * sharpCornerOffset) { + const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round()); + this.updateDistance(prevVertex, newPrevVertex); + this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment); + prevVertex = newPrevVertex; + } + } + // The join if a middle vertex, otherwise the cap. + const middleVertex = prevVertex && nextVertex; + let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap; + if (middleVertex && currentJoin === 'round') { + if (miterLength < roundLimit) { + currentJoin = 'miter'; + } + else if (miterLength <= 2) { + currentJoin = 'fakeround'; + } + } + if (currentJoin === 'miter' && miterLength > miterLimit) { + currentJoin = 'bevel'; + } + if (currentJoin === 'bevel') { + // The maximum extrude length is 128 / 63 = 2 times the width of the line + // so if miterLength >= 2 we need to draw a different type of bevel here. + if (miterLength > 2) + currentJoin = 'flipbevel'; + // If the miterLength is really small and the line bevel wouldn't be visible, + // just draw a miter join to save a triangle. + if (miterLength < miterLimit) + currentJoin = 'miter'; + } + // Calculate how far along the line the currentVertex is + if (prevVertex) + this.updateDistance(prevVertex, currentVertex); + if (currentJoin === 'miter') { + joinNormal._mult(miterLength); + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + } + else if (currentJoin === 'flipbevel') { + // miter is too big, flip the direction to make a beveled join + if (miterLength > 100) { + // Almost parallel lines + joinNormal = nextNormal.mult(-1); + } + else { + const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag(); + joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1)); + } + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment); + } + else if (currentJoin === 'bevel' || currentJoin === 'fakeround') { + const offset = -Math.sqrt(miterLength * miterLength - 1); + const offsetA = lineTurnsLeft ? offset : 0; + const offsetB = lineTurnsLeft ? 0 : offset; + // Close previous segment with a bevel + if (prevVertex) { + this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment); + } + if (currentJoin === 'fakeround') { + // The join angle is sharp enough that a round join would be visible. + // Bevel joins fill the gap between segments with a single pie slice triangle. + // Create a round join by adding multiple pie slices. The join isn't actually round, but + // it looks like it is at the sizes we render lines at. + // pick the number of triangles for approximating round join by based on the angle between normals + const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE); + for (let m = 1; m < n; m++) { + let t = m / n; + if (t !== 0.5) { + // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp + const t2 = t - 0.5; + const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519)); + const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638); + t = t + t * t2 * (t - 1) * (A * t2 * t2 + B); + } + const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1); + this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment); + } + } + if (nextVertex) { + // Start next segment + this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment); + } + } + else if (currentJoin === 'butt') { + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap + } + else if (currentJoin === 'square') { + const offset = prevVertex ? 1 : -1; // closing or starting square cap + this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment); + } + else if (currentJoin === 'round') { + if (prevVertex) { + // Close previous segment with butt + this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment); + // Add round cap or linejoin at end of segment + this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true); + } + if (nextVertex) { + // Add round cap before first segment + this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true); + // Start next segment with a butt + this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment); + } + } + if (isSharpCorner && i < len - 1) { + const nextSegmentLength = currentVertex.dist(nextVertex); + if (nextSegmentLength > 2 * sharpCornerOffset) { + const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round()); + this.updateDistance(currentVertex, newCurrentVertex); + this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment); + currentVertex = newCurrentVertex; + } + } + } + } + /** + * Add two vertices to the buffers. + * + * @param p - the line vertex to add buffer vertices for + * @param normal - vertex normal + * @param endLeft - extrude to shift the left vertex along the line + * @param endRight - extrude to shift the left vertex along the line + * @param segment - the segment object to add the vertex to + * @param round - whether this is a round cap + */ + addCurrentVertex(p, normal, endLeft, endRight, segment, round = false) { + // left and right extrude vectors, perpendicularly shifted by endLeft/endRight + const leftX = normal.x + normal.y * endLeft; + const leftY = normal.y - normal.x * endLeft; + const rightX = -normal.x + normal.y * endRight; + const rightY = -normal.y - normal.x * endRight; + this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment); + this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment); + // There is a maximum "distance along the line" that we can store in the buffers. + // When we get close to the distance, reset it to zero and add the vertex again with + // a distance of zero. The max distance is determined by the number of bits we allocate + // to `linesofar`. + if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) { + this.distance = 0; + this.updateScaledDistance(); + this.addCurrentVertex(p, normal, endLeft, endRight, segment, round); + } + } + addHalfVertex({ x, y }, extrudeX, extrudeY, round, up, dir, segment) { + const totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance; + // scale down so that we can store longer distances while sacrificing precision. + const linesofarScaled = totalDistance * LINE_DISTANCE_SCALE; + this.layoutVertexArray.emplaceBack( + // a_pos_normal + // Encode round/up the least significant bits + (x << 1) + (round ? 1 : 0), (y << 1) + (up ? 1 : 0), + // a_data + // add 128 to store a byte in an unsigned byte + Math.round(EXTRUDE_SCALE * extrudeX) + 128, Math.round(EXTRUDE_SCALE * extrudeY) + 128, + // Encode the -1/0/1 direction value into the first two bits of .z of a_data. + // Combine it with the lower 6 bits of `linesofarScaled` (shifted by 2 bits to make + // room for the direction value). The upper 8 bits of `linesofarScaled` are placed in + // the `w` component. + ((dir === 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofarScaled & 0x3F) << 2), linesofarScaled >> 6); + // Constructs a second vertex buffer with higher precision line progress + if (this.lineClips) { + const progressRealigned = this.scaledDistance - this.lineClips.start; + const endClipRealigned = this.lineClips.end - this.lineClips.start; + const uvX = progressRealigned / endClipRealigned; + this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length); + } + const e = segment.vertexLength++; + if (this.e1 >= 0 && this.e2 >= 0) { + this.indexArray.emplaceBack(this.e1, this.e2, e); + segment.primitiveLength++; + } + if (up) { + this.e2 = e; + } + else { + this.e1 = e; + } + } + updateScaledDistance() { + // Knowing the ratio of the full linestring covered by this tiled feature, as well + // as the total distance (in tile units) of this tiled feature, and the distance + // (in tile units) of the current vertex, we can determine the relative distance + // of this vertex along the full linestring feature and scale it to [0, 2^15) + this.scaledDistance = this.lineClips ? + this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance : + this.distance; + } + updateDistance(prev, next) { + this.distance += prev.dist(next); + this.updateScaledDistance(); + } +} +register('LineBucket', LineBucket, { omit: ['layers', 'patternFeatures'] }); + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let layout$1; +const getLayout$1 = () => layout$1 = layout$1 || new Properties({ + "line-cap": new DataConstantProperty(v8Spec["layout_line"]["line-cap"]), + "line-join": new DataDrivenProperty(v8Spec["layout_line"]["line-join"]), + "line-miter-limit": new DataConstantProperty(v8Spec["layout_line"]["line-miter-limit"]), + "line-round-limit": new DataConstantProperty(v8Spec["layout_line"]["line-round-limit"]), + "line-sort-key": new DataDrivenProperty(v8Spec["layout_line"]["line-sort-key"]), +}); +let paint$3; +const getPaint$3 = () => paint$3 = paint$3 || new Properties({ + "line-opacity": new DataDrivenProperty(v8Spec["paint_line"]["line-opacity"]), + "line-color": new DataDrivenProperty(v8Spec["paint_line"]["line-color"]), + "line-translate": new DataConstantProperty(v8Spec["paint_line"]["line-translate"]), + "line-translate-anchor": new DataConstantProperty(v8Spec["paint_line"]["line-translate-anchor"]), + "line-width": new DataDrivenProperty(v8Spec["paint_line"]["line-width"]), + "line-gap-width": new DataDrivenProperty(v8Spec["paint_line"]["line-gap-width"]), + "line-offset": new DataDrivenProperty(v8Spec["paint_line"]["line-offset"]), + "line-blur": new DataDrivenProperty(v8Spec["paint_line"]["line-blur"]), + "line-dasharray": new CrossFadedProperty(v8Spec["paint_line"]["line-dasharray"]), + "line-pattern": new CrossFadedDataDrivenProperty(v8Spec["paint_line"]["line-pattern"]), + "line-gradient": new ColorRampProperty(v8Spec["paint_line"]["line-gradient"]), +}); +var properties$3 = ({ get paint() { return getPaint$3(); }, get layout() { return getLayout$1(); } }); + +class LineFloorwidthProperty extends DataDrivenProperty { + possiblyEvaluate(value, parameters) { + parameters = new EvaluationParameters(Math.floor(parameters.zoom), { + now: parameters.now, + fadeDuration: parameters.fadeDuration, + zoomHistory: parameters.zoomHistory, + transition: parameters.transition + }); + return super.possiblyEvaluate(value, parameters); + } + evaluate(value, globals, feature, featureState) { + globals = extend({}, globals, { zoom: Math.floor(globals.zoom) }); + return super.evaluate(value, globals, feature, featureState); + } +} +let lineFloorwidthProperty; +class LineStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$3); + this.gradientVersion = 0; + if (!lineFloorwidthProperty) { + lineFloorwidthProperty = + new LineFloorwidthProperty(properties$3.paint.properties['line-width'].specification); + lineFloorwidthProperty.useIntegerZoom = true; + } + } + _handleSpecialPaintPropertyUpdate(name) { + if (name === 'line-gradient') { + const expression = this.gradientExpression(); + if (isZoomExpression(expression)) { + this.stepInterpolant = expression._styleExpression.expression instanceof Step; + } + else { + this.stepInterpolant = false; + } + this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER; + } + } + gradientExpression() { + return this._transitionablePaint._values['line-gradient'].value.expression; + } + recalculate(parameters, availableImages) { + super.recalculate(parameters, availableImages); + this.paint._values['line-floorwidth'] = + lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values['line-width'].value, parameters); + } + createBucket(parameters) { + return new LineBucket(parameters); + } + queryRadius(bucket) { + const lineBucket = bucket; + const width = getLineWidth(getMaximumPaintValue('line-width', this, lineBucket), getMaximumPaintValue('line-gap-width', this, lineBucket)); + const offset = getMaximumPaintValue('line-offset', this, lineBucket); + return width / 2 + Math.abs(offset) + translateDistance(this.paint.get('line-translate')); + } + queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits) { + const translatedPolygon = translate$4(queryGeometry, this.paint.get('line-translate'), this.paint.get('line-translate-anchor'), transform.angle, pixelsToTileUnits); + const halfWidth = pixelsToTileUnits / 2 * getLineWidth(this.paint.get('line-width').evaluate(feature, featureState), this.paint.get('line-gap-width').evaluate(feature, featureState)); + const lineOffset = this.paint.get('line-offset').evaluate(feature, featureState); + if (lineOffset) { + geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits); + } + return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth); + } + isTileClipped() { + return true; + } +} +function getLineWidth(lineWidth, lineGapWidth) { + if (lineGapWidth > 0) { + return lineGapWidth + 2 * lineWidth; + } + else { + return lineWidth; + } +} + +const symbolLayoutAttributes = createLayout([ + { name: 'a_pos_offset', components: 4, type: 'Int16' }, + { name: 'a_data', components: 4, type: 'Uint16' }, + { name: 'a_pixeloffset', components: 4, type: 'Int16' } +], 4); +const dynamicLayoutAttributes = createLayout([ + { name: 'a_projected_pos', components: 3, type: 'Float32' } +], 4); +const placementOpacityAttributes = createLayout([ + { name: 'a_fade_opacity', components: 1, type: 'Uint32' } +], 4); +const collisionVertexAttributes = createLayout([ + { name: 'a_placed', components: 2, type: 'Uint8' }, + { name: 'a_shift', components: 2, type: 'Float32' } +]); +const collisionBox = createLayout([ + // the box is centered around the anchor point + { type: 'Int16', name: 'anchorPointX' }, + { type: 'Int16', name: 'anchorPointY' }, + // distances to the edges from the anchor + { type: 'Int16', name: 'x1' }, + { type: 'Int16', name: 'y1' }, + { type: 'Int16', name: 'x2' }, + { type: 'Int16', name: 'y2' }, + // the index of the feature in the original vectortile + { type: 'Uint32', name: 'featureIndex' }, + // the source layer the feature appears in + { type: 'Uint16', name: 'sourceLayerIndex' }, + // the bucket the feature appears in + { type: 'Uint16', name: 'bucketIndex' }, +]); +const collisionBoxLayout = createLayout([ + { name: 'a_pos', components: 2, type: 'Int16' }, + { name: 'a_anchor_pos', components: 2, type: 'Int16' }, + { name: 'a_extrude', components: 2, type: 'Int16' } +], 4); +const collisionCircleLayout = createLayout([ + { name: 'a_pos', components: 2, type: 'Float32' }, + { name: 'a_radius', components: 1, type: 'Float32' }, + { name: 'a_flags', components: 2, type: 'Int16' } +], 4); +const quadTriangle = createLayout([ + { name: 'triangle', components: 3, type: 'Uint16' }, +]); +const placement = createLayout([ + { type: 'Int16', name: 'anchorX' }, + { type: 'Int16', name: 'anchorY' }, + { type: 'Uint16', name: 'glyphStartIndex' }, + { type: 'Uint16', name: 'numGlyphs' }, + { type: 'Uint32', name: 'vertexStartIndex' }, + { type: 'Uint32', name: 'lineStartIndex' }, + { type: 'Uint32', name: 'lineLength' }, + { type: 'Uint16', name: 'segment' }, + { type: 'Uint16', name: 'lowerSize' }, + { type: 'Uint16', name: 'upperSize' }, + { type: 'Float32', name: 'lineOffsetX' }, + { type: 'Float32', name: 'lineOffsetY' }, + { type: 'Uint8', name: 'writingMode' }, + { type: 'Uint8', name: 'placedOrientation' }, + { type: 'Uint8', name: 'hidden' }, + { type: 'Uint32', name: 'crossTileID' }, + { type: 'Int16', name: 'associatedIconIndex' } +]); +const symbolInstance = createLayout([ + { type: 'Int16', name: 'anchorX' }, + { type: 'Int16', name: 'anchorY' }, + { type: 'Int16', name: 'rightJustifiedTextSymbolIndex' }, + { type: 'Int16', name: 'centerJustifiedTextSymbolIndex' }, + { type: 'Int16', name: 'leftJustifiedTextSymbolIndex' }, + { type: 'Int16', name: 'verticalPlacedTextSymbolIndex' }, + { type: 'Int16', name: 'placedIconSymbolIndex' }, + { type: 'Int16', name: 'verticalPlacedIconSymbolIndex' }, + { type: 'Uint16', name: 'key' }, + { type: 'Uint16', name: 'textBoxStartIndex' }, + { type: 'Uint16', name: 'textBoxEndIndex' }, + { type: 'Uint16', name: 'verticalTextBoxStartIndex' }, + { type: 'Uint16', name: 'verticalTextBoxEndIndex' }, + { type: 'Uint16', name: 'iconBoxStartIndex' }, + { type: 'Uint16', name: 'iconBoxEndIndex' }, + { type: 'Uint16', name: 'verticalIconBoxStartIndex' }, + { type: 'Uint16', name: 'verticalIconBoxEndIndex' }, + { type: 'Uint16', name: 'featureIndex' }, + { type: 'Uint16', name: 'numHorizontalGlyphVertices' }, + { type: 'Uint16', name: 'numVerticalGlyphVertices' }, + { type: 'Uint16', name: 'numIconVertices' }, + { type: 'Uint16', name: 'numVerticalIconVertices' }, + { type: 'Uint16', name: 'useRuntimeCollisionCircles' }, + { type: 'Uint32', name: 'crossTileID' }, + { type: 'Float32', name: 'textBoxScale' }, + { type: 'Float32', name: 'collisionCircleDiameter' }, + { type: 'Uint16', name: 'textAnchorOffsetStartIndex' }, + { type: 'Uint16', name: 'textAnchorOffsetEndIndex' } +]); +const glyphOffset = createLayout([ + { type: 'Float32', name: 'offsetX' } +]); +const lineVertex = createLayout([ + { type: 'Int16', name: 'x' }, + { type: 'Int16', name: 'y' }, + { type: 'Int16', name: 'tileUnitDistanceFromAnchor' } +]); +const textAnchorOffset = createLayout([ + { type: 'Uint16', name: 'textAnchor' }, + { type: 'Float32', components: 2, name: 'textOffset' } +]); + +function transformTextInternal(text, layer, feature) { + const transform = layer.layout.get('text-transform').evaluate(feature, {}); + if (transform === 'uppercase') { + text = text.toLocaleUpperCase(); + } + else if (transform === 'lowercase') { + text = text.toLocaleLowerCase(); + } + if (plugin.applyArabicShaping) { + text = plugin.applyArabicShaping(text); + } + return text; +} +function transformText(text, layer, feature) { + text.sections.forEach(section => { + section.text = transformTextInternal(section.text, layer, feature); + }); + return text; +} + +function mergeLines(features) { + const leftIndex = {}; + const rightIndex = {}; + const mergedFeatures = []; + let mergedIndex = 0; + function add(k) { + mergedFeatures.push(features[k]); + mergedIndex++; + } + function mergeFromRight(leftKey, rightKey, geom) { + const i = rightIndex[leftKey]; + delete rightIndex[leftKey]; + rightIndex[rightKey] = i; + mergedFeatures[i].geometry[0].pop(); + mergedFeatures[i].geometry[0] = mergedFeatures[i].geometry[0].concat(geom[0]); + return i; + } + function mergeFromLeft(leftKey, rightKey, geom) { + const i = leftIndex[rightKey]; + delete leftIndex[rightKey]; + leftIndex[leftKey] = i; + mergedFeatures[i].geometry[0].shift(); + mergedFeatures[i].geometry[0] = geom[0].concat(mergedFeatures[i].geometry[0]); + return i; + } + function getKey(text, geom, onRight) { + const point = onRight ? geom[0][geom[0].length - 1] : geom[0][0]; + return `${text}:${point.x}:${point.y}`; + } + for (let k = 0; k < features.length; k++) { + const feature = features[k]; + const geom = feature.geometry; + const text = feature.text ? feature.text.toString() : null; + if (!text) { + add(k); + continue; + } + const leftKey = getKey(text, geom), rightKey = getKey(text, geom, true); + if ((leftKey in rightIndex) && (rightKey in leftIndex) && (rightIndex[leftKey] !== leftIndex[rightKey])) { + // found lines with the same text adjacent to both ends of the current line, merge all three + const j = mergeFromLeft(leftKey, rightKey, geom); + const i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry); + delete leftIndex[leftKey]; + delete rightIndex[rightKey]; + rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i; + mergedFeatures[j].geometry = null; + } + else if (leftKey in rightIndex) { + // found mergeable line adjacent to the start of the current line, merge + mergeFromRight(leftKey, rightKey, geom); + } + else if (rightKey in leftIndex) { + // found mergeable line adjacent to the end of the current line, merge + mergeFromLeft(leftKey, rightKey, geom); + } + else { + // no adjacent lines, add as a new item + add(k); + leftIndex[leftKey] = mergedIndex - 1; + rightIndex[rightKey] = mergedIndex - 1; + } + } + return mergedFeatures.filter((f) => f.geometry); +} + +const verticalizedCharacterMap = { + '!': '︕', + '#': '#', + '$': '$', + '%': '%', + '&': '&', + '(': '︵', + ')': '︶', + '*': '*', + '+': '+', + ',': '︐', + '-': '︲', + '.': '・', + '/': '/', + ':': '︓', + ';': '︔', + '<': '︿', + '=': '=', + '>': '﹀', + '?': '︖', + '@': '@', + '[': '﹇', + '\\': '\', + ']': '﹈', + '^': '^', + '_': '︳', + '`': '`', + '{': '︷', + '|': '―', + '}': '︸', + '~': '~', + '¢': '¢', + '£': '£', + '¥': '¥', + '¦': '¦', + '¬': '¬', + '¯': ' ̄', + '–': '︲', + '—': '︱', + '‘': '﹃', + '’': '﹄', + '“': '﹁', + '”': '﹂', + '…': '︙', + '‧': '・', + '₩': '₩', + '、': '︑', + '。': '︒', + '〈': '︿', + '〉': '﹀', + '《': '︽', + '》': '︾', + '「': '﹁', + '」': '﹂', + '『': '﹃', + '』': '﹄', + '【': '︻', + '】': '︼', + '〔': '︹', + '〕': '︺', + '〖': '︗', + '〗': '︘', + '!': '︕', + '(': '︵', + ')': '︶', + ',': '︐', + '-': '︲', + '.': '・', + ':': '︓', + ';': '︔', + '<': '︿', + '>': '﹀', + '?': '︖', + '[': '﹇', + ']': '﹈', + '_': '︳', + '{': '︷', + '|': '―', + '}': '︸', + '⦅': '︵', + '⦆': '︶', + '。': '︒', + '「': '﹁', + '」': '﹂' +}; +function verticalizePunctuation(input) { + let output = ''; + for (let i = 0; i < input.length; i++) { + const nextCharCode = input.charCodeAt(i + 1) || null; + const prevCharCode = input.charCodeAt(i - 1) || null; + const canReplacePunctuation = ((!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) && + (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]])); + if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) { + output += verticalizedCharacterMap[input[i]]; + } + else { + output += input[i]; + } + } + return output; +} + +// ONE_EM constant used to go between "em" units used in style spec and "points" used internally for layout +var ONE_EM = 24; + +var ieee754$1 = {}; + +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ + +var read = ieee754$1.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = (nBytes * 8) - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? (nBytes - 1) : 0; + var d = isLE ? -1 : 1; + var s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +}; + +var write = ieee754$1.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = (nBytes * 8) - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0); + var i = isLE ? 0 : (nBytes - 1); + var d = isLE ? 1 : -1; + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128; +}; + +'use strict'; + +var pbf = Pbf; + +var ieee754 = ieee754$1; + +function Pbf(buf) { + this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0); + this.pos = 0; + this.type = 0; + this.length = this.buf.length; +} + +Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum +Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64 +Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields +Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32 + +var SHIFT_LEFT_32 = (1 << 16) * (1 << 16), + SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32; + +// Threshold chosen based on both benchmarking and knowledge about browser string +// data structures (which currently switch structure types at 12 bytes or more) +var TEXT_DECODER_MIN_LENGTH = 12; +var utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8'); + +Pbf.prototype = { + + destroy: function() { + this.buf = null; + }, + + // === READING ================================================================= + + readFields: function(readField, result, end) { + end = end || this.length; + + while (this.pos < end) { + var val = this.readVarint(), + tag = val >> 3, + startPos = this.pos; + + this.type = val & 0x7; + readField(tag, result, this); + + if (this.pos === startPos) this.skip(val); + } + return result; + }, + + readMessage: function(readField, result) { + return this.readFields(readField, result, this.readVarint() + this.pos); + }, + + readFixed32: function() { + var val = readUInt32(this.buf, this.pos); + this.pos += 4; + return val; + }, + + readSFixed32: function() { + var val = readInt32(this.buf, this.pos); + this.pos += 4; + return val; + }, + + // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed) + + readFixed64: function() { + var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32; + this.pos += 8; + return val; + }, + + readSFixed64: function() { + var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32; + this.pos += 8; + return val; + }, + + readFloat: function() { + var val = ieee754.read(this.buf, this.pos, true, 23, 4); + this.pos += 4; + return val; + }, + + readDouble: function() { + var val = ieee754.read(this.buf, this.pos, true, 52, 8); + this.pos += 8; + return val; + }, + + readVarint: function(isSigned) { + var buf = this.buf, + val, b; + + b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val; + b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val; + b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val; + b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val; + b = buf[this.pos]; val |= (b & 0x0f) << 28; + + return readVarintRemainder(val, isSigned, this); + }, + + readVarint64: function() { // for compatibility with v2.0.1 + return this.readVarint(true); + }, + + readSVarint: function() { + var num = this.readVarint(); + return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding + }, + + readBoolean: function() { + return Boolean(this.readVarint()); + }, + + readString: function() { + var end = this.readVarint() + this.pos; + var pos = this.pos; + this.pos = end; + + if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) { + // longer strings are fast with the built-in browser TextDecoder API + return readUtf8TextDecoder(this.buf, pos, end); + } + // short strings are fast with our custom implementation + return readUtf8(this.buf, pos, end); + }, + + readBytes: function() { + var end = this.readVarint() + this.pos, + buffer = this.buf.subarray(this.pos, end); + this.pos = end; + return buffer; + }, + + // verbose for performance reasons; doesn't affect gzipped size + + readPackedVarint: function(arr, isSigned) { + if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned)); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readVarint(isSigned)); + return arr; + }, + readPackedSVarint: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readSVarint()); + return arr; + }, + readPackedBoolean: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readBoolean()); + return arr; + }, + readPackedFloat: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readFloat()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readFloat()); + return arr; + }, + readPackedDouble: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readDouble()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readDouble()); + return arr; + }, + readPackedFixed32: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readFixed32()); + return arr; + }, + readPackedSFixed32: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readSFixed32()); + return arr; + }, + readPackedFixed64: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readFixed64()); + return arr; + }, + readPackedSFixed64: function(arr) { + if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64()); + var end = readPackedEnd(this); + arr = arr || []; + while (this.pos < end) arr.push(this.readSFixed64()); + return arr; + }, + + skip: function(val) { + var type = val & 0x7; + if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {} + else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos; + else if (type === Pbf.Fixed32) this.pos += 4; + else if (type === Pbf.Fixed64) this.pos += 8; + else throw new Error('Unimplemented type: ' + type); + }, + + // === WRITING ================================================================= + + writeTag: function(tag, type) { + this.writeVarint((tag << 3) | type); + }, + + realloc: function(min) { + var length = this.length || 16; + + while (length < this.pos + min) length *= 2; + + if (length !== this.length) { + var buf = new Uint8Array(length); + buf.set(this.buf); + this.buf = buf; + this.length = length; + } + }, + + finish: function() { + this.length = this.pos; + this.pos = 0; + return this.buf.subarray(0, this.length); + }, + + writeFixed32: function(val) { + this.realloc(4); + writeInt32(this.buf, val, this.pos); + this.pos += 4; + }, + + writeSFixed32: function(val) { + this.realloc(4); + writeInt32(this.buf, val, this.pos); + this.pos += 4; + }, + + writeFixed64: function(val) { + this.realloc(8); + writeInt32(this.buf, val & -1, this.pos); + writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4); + this.pos += 8; + }, + + writeSFixed64: function(val) { + this.realloc(8); + writeInt32(this.buf, val & -1, this.pos); + writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4); + this.pos += 8; + }, + + writeVarint: function(val) { + val = +val || 0; + + if (val > 0xfffffff || val < 0) { + writeBigVarint(val, this); + return; + } + + this.realloc(4); + + this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return; + this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return; + this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return; + this.buf[this.pos++] = (val >>> 7) & 0x7f; + }, + + writeSVarint: function(val) { + this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2); + }, + + writeBoolean: function(val) { + this.writeVarint(Boolean(val)); + }, + + writeString: function(str) { + str = String(str); + this.realloc(str.length * 4); + + this.pos++; // reserve 1 byte for short string length + + var startPos = this.pos; + // write the string directly to the buffer and see how much was written + this.pos = writeUtf8(this.buf, str, this.pos); + var len = this.pos - startPos; + + if (len >= 0x80) makeRoomForExtraLength(startPos, len, this); + + // finally, write the message length in the reserved place and restore the position + this.pos = startPos - 1; + this.writeVarint(len); + this.pos += len; + }, + + writeFloat: function(val) { + this.realloc(4); + ieee754.write(this.buf, val, this.pos, true, 23, 4); + this.pos += 4; + }, + + writeDouble: function(val) { + this.realloc(8); + ieee754.write(this.buf, val, this.pos, true, 52, 8); + this.pos += 8; + }, + + writeBytes: function(buffer) { + var len = buffer.length; + this.writeVarint(len); + this.realloc(len); + for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i]; + }, + + writeRawMessage: function(fn, obj) { + this.pos++; // reserve 1 byte for short message length + + // write the message directly to the buffer and see how much was written + var startPos = this.pos; + fn(obj, this); + var len = this.pos - startPos; + + if (len >= 0x80) makeRoomForExtraLength(startPos, len, this); + + // finally, write the message length in the reserved place and restore the position + this.pos = startPos - 1; + this.writeVarint(len); + this.pos += len; + }, + + writeMessage: function(tag, fn, obj) { + this.writeTag(tag, Pbf.Bytes); + this.writeRawMessage(fn, obj); + }, + + writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); }, + writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); }, + writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); }, + writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); }, + writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); }, + writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); }, + writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); }, + writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); }, + writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); }, + + writeBytesField: function(tag, buffer) { + this.writeTag(tag, Pbf.Bytes); + this.writeBytes(buffer); + }, + writeFixed32Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed32); + this.writeFixed32(val); + }, + writeSFixed32Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed32); + this.writeSFixed32(val); + }, + writeFixed64Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed64); + this.writeFixed64(val); + }, + writeSFixed64Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed64); + this.writeSFixed64(val); + }, + writeVarintField: function(tag, val) { + this.writeTag(tag, Pbf.Varint); + this.writeVarint(val); + }, + writeSVarintField: function(tag, val) { + this.writeTag(tag, Pbf.Varint); + this.writeSVarint(val); + }, + writeStringField: function(tag, str) { + this.writeTag(tag, Pbf.Bytes); + this.writeString(str); + }, + writeFloatField: function(tag, val) { + this.writeTag(tag, Pbf.Fixed32); + this.writeFloat(val); + }, + writeDoubleField: function(tag, val) { + this.writeTag(tag, Pbf.Fixed64); + this.writeDouble(val); + }, + writeBooleanField: function(tag, val) { + this.writeVarintField(tag, Boolean(val)); + } +}; + +function readVarintRemainder(l, s, p) { + var buf = p.buf, + h, b; + + b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s); + b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s); + b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s); + b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s); + b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s); + b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s); + + throw new Error('Expected varint not more than 10 bytes'); +} + +function readPackedEnd(pbf) { + return pbf.type === Pbf.Bytes ? + pbf.readVarint() + pbf.pos : pbf.pos + 1; +} + +function toNum(low, high, isSigned) { + if (isSigned) { + return high * 0x100000000 + (low >>> 0); + } + + return ((high >>> 0) * 0x100000000) + (low >>> 0); +} + +function writeBigVarint(val, pbf) { + var low, high; + + if (val >= 0) { + low = (val % 0x100000000) | 0; + high = (val / 0x100000000) | 0; + } else { + low = ~(-val % 0x100000000); + high = ~(-val / 0x100000000); + + if (low ^ 0xffffffff) { + low = (low + 1) | 0; + } else { + low = 0; + high = (high + 1) | 0; + } + } + + if (val >= 0x10000000000000000 || val < -0x10000000000000000) { + throw new Error('Given varint doesn\'t fit into 10 bytes'); + } + + pbf.realloc(10); + + writeBigVarintLow(low, high, pbf); + writeBigVarintHigh(high, pbf); +} + +function writeBigVarintLow(low, high, pbf) { + pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7; + pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7; + pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7; + pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7; + pbf.buf[pbf.pos] = low & 0x7f; +} + +function writeBigVarintHigh(high, pbf) { + var lsb = (high & 0x07) << 4; + + pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return; + pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return; + pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return; + pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return; + pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return; + pbf.buf[pbf.pos++] = high & 0x7f; +} + +function makeRoomForExtraLength(startPos, len, pbf) { + var extraLen = + len <= 0x3fff ? 1 : + len <= 0x1fffff ? 2 : + len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7)); + + // if 1 byte isn't enough for encoding message length, shift the data to the right + pbf.realloc(extraLen); + for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i]; +} + +function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); } +function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); } +function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); } +function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); } +function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); } +function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); } +function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); } +function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); } +function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); } + +// Buffer code below from https://github.com/feross/buffer, MIT-licensed + +function readUInt32(buf, pos) { + return ((buf[pos]) | + (buf[pos + 1] << 8) | + (buf[pos + 2] << 16)) + + (buf[pos + 3] * 0x1000000); +} + +function writeInt32(buf, val, pos) { + buf[pos] = val; + buf[pos + 1] = (val >>> 8); + buf[pos + 2] = (val >>> 16); + buf[pos + 3] = (val >>> 24); +} + +function readInt32(buf, pos) { + return ((buf[pos]) | + (buf[pos + 1] << 8) | + (buf[pos + 2] << 16)) + + (buf[pos + 3] << 24); +} + +function readUtf8(buf, pos, end) { + var str = ''; + var i = pos; + + while (i < end) { + var b0 = buf[i]; + var c = null; // codepoint + var bytesPerSequence = + b0 > 0xEF ? 4 : + b0 > 0xDF ? 3 : + b0 > 0xBF ? 2 : 1; + + if (i + bytesPerSequence > end) break; + + var b1, b2, b3; + + if (bytesPerSequence === 1) { + if (b0 < 0x80) { + c = b0; + } + } else if (bytesPerSequence === 2) { + b1 = buf[i + 1]; + if ((b1 & 0xC0) === 0x80) { + c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F); + if (c <= 0x7F) { + c = null; + } + } + } else if (bytesPerSequence === 3) { + b1 = buf[i + 1]; + b2 = buf[i + 2]; + if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) { + c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F); + if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) { + c = null; + } + } + } else if (bytesPerSequence === 4) { + b1 = buf[i + 1]; + b2 = buf[i + 2]; + b3 = buf[i + 3]; + if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) { + c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F); + if (c <= 0xFFFF || c >= 0x110000) { + c = null; + } + } + } + + if (c === null) { + c = 0xFFFD; + bytesPerSequence = 1; + + } else if (c > 0xFFFF) { + c -= 0x10000; + str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800); + c = 0xDC00 | c & 0x3FF; + } + + str += String.fromCharCode(c); + i += bytesPerSequence; + } + + return str; +} + +function readUtf8TextDecoder(buf, pos, end) { + return utf8TextDecoder.decode(buf.subarray(pos, end)); +} + +function writeUtf8(buf, str, pos) { + for (var i = 0, c, lead; i < str.length; i++) { + c = str.charCodeAt(i); // code point + + if (c > 0xD7FF && c < 0xE000) { + if (lead) { + if (c < 0xDC00) { + buf[pos++] = 0xEF; + buf[pos++] = 0xBF; + buf[pos++] = 0xBD; + lead = c; + continue; + } else { + c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000; + lead = null; + } + } else { + if (c > 0xDBFF || (i + 1 === str.length)) { + buf[pos++] = 0xEF; + buf[pos++] = 0xBF; + buf[pos++] = 0xBD; + } else { + lead = c; + } + continue; + } + } else if (lead) { + buf[pos++] = 0xEF; + buf[pos++] = 0xBF; + buf[pos++] = 0xBD; + lead = null; + } + + if (c < 0x80) { + buf[pos++] = c; + } else { + if (c < 0x800) { + buf[pos++] = c >> 0x6 | 0xC0; + } else { + if (c < 0x10000) { + buf[pos++] = c >> 0xC | 0xE0; + } else { + buf[pos++] = c >> 0x12 | 0xF0; + buf[pos++] = c >> 0xC & 0x3F | 0x80; + } + buf[pos++] = c >> 0x6 & 0x3F | 0x80; + } + buf[pos++] = c & 0x3F | 0x80; + } + } + return pos; +} + +var Protobuf = /*@__PURE__*/getDefaultExportFromCjs(pbf); + +const border$1 = 3; +function readFontstacks(tag, glyphs, pbf) { + if (tag === 1) { + pbf.readMessage(readFontstack, glyphs); + } +} +function readFontstack(tag, glyphs, pbf) { + if (tag === 3) { + const { id, bitmap, width, height, left, top, advance } = pbf.readMessage(readGlyph, {}); + glyphs.push({ + id, + bitmap: new AlphaImage({ + width: width + 2 * border$1, + height: height + 2 * border$1 + }, bitmap), + metrics: { width, height, left, top, advance } + }); + } +} +function readGlyph(tag, glyph, pbf) { + if (tag === 1) + glyph.id = pbf.readVarint(); + else if (tag === 2) + glyph.bitmap = pbf.readBytes(); + else if (tag === 3) + glyph.width = pbf.readVarint(); + else if (tag === 4) + glyph.height = pbf.readVarint(); + else if (tag === 5) + glyph.left = pbf.readSVarint(); + else if (tag === 6) + glyph.top = pbf.readSVarint(); + else if (tag === 7) + glyph.advance = pbf.readVarint(); +} +function parseGlyphPbf(data) { + return new Protobuf(data).readFields(readFontstacks, []); +} +const GLYPH_PBF_BORDER = border$1; + +function potpack(boxes) { + + // calculate total box area and maximum box width + let area = 0; + let maxWidth = 0; + + for (const box of boxes) { + area += box.w * box.h; + maxWidth = Math.max(maxWidth, box.w); + } + + // sort the boxes for insertion by height, descending + boxes.sort((a, b) => b.h - a.h); + + // aim for a squarish resulting container, + // slightly adjusted for sub-100% space utilization + const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth); + + // start with a single empty space, unbounded at the bottom + const spaces = [{x: 0, y: 0, w: startWidth, h: Infinity}]; + + let width = 0; + let height = 0; + + for (const box of boxes) { + // look through spaces backwards so that we check smaller spaces first + for (let i = spaces.length - 1; i >= 0; i--) { + const space = spaces[i]; + + // look for empty spaces that can accommodate the current box + if (box.w > space.w || box.h > space.h) continue; + + // found the space; add the box to its top-left corner + // |-------|-------| + // | box | | + // |_______| | + // | space | + // |_______________| + box.x = space.x; + box.y = space.y; + + height = Math.max(height, box.y + box.h); + width = Math.max(width, box.x + box.w); + + if (box.w === space.w && box.h === space.h) { + // space matches the box exactly; remove it + const last = spaces.pop(); + if (i < spaces.length) spaces[i] = last; + + } else if (box.h === space.h) { + // space matches the box height; update it accordingly + // |-------|---------------| + // | box | updated space | + // |_______|_______________| + space.x += box.w; + space.w -= box.w; + + } else if (box.w === space.w) { + // space matches the box width; update it accordingly + // |---------------| + // | box | + // |_______________| + // | updated space | + // |_______________| + space.y += box.h; + space.h -= box.h; + + } else { + // otherwise the box splits the space into two spaces + // |-------|-----------| + // | box | new space | + // |_______|___________| + // | updated space | + // |___________________| + spaces.push({ + x: space.x + box.w, + y: space.y, + w: space.w - box.w, + h: box.h + }); + space.y += box.h; + space.h -= box.h; + } + break; + } + } + + return { + w: width, // container width + h: height, // container height + fill: (area / (width * height)) || 0 // space utilization + }; +} + +/* eslint-disable key-spacing */ +const IMAGE_PADDING = 1; +class ImagePosition { + constructor(paddedRect, { pixelRatio, version, stretchX, stretchY, content }) { + this.paddedRect = paddedRect; + this.pixelRatio = pixelRatio; + this.stretchX = stretchX; + this.stretchY = stretchY; + this.content = content; + this.version = version; + } + get tl() { + return [ + this.paddedRect.x + IMAGE_PADDING, + this.paddedRect.y + IMAGE_PADDING + ]; + } + get br() { + return [ + this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING, + this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING + ]; + } + get tlbr() { + return this.tl.concat(this.br); + } + get displaySize() { + return [ + (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio, + (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio + ]; + } +} +/** + * @internal + * A class holding all the images + */ +class ImageAtlas { + constructor(icons, patterns) { + const iconPositions = {}, patternPositions = {}; + this.haveRenderCallbacks = []; + const bins = []; + this.addImages(icons, iconPositions, bins); + this.addImages(patterns, patternPositions, bins); + const { w, h } = potpack(bins); + const image = new RGBAImage({ width: w || 1, height: h || 1 }); + for (const id in icons) { + const src = icons[id]; + const bin = iconPositions[id].paddedRect; + RGBAImage.copy(src.data, image, { x: 0, y: 0 }, { x: bin.x + IMAGE_PADDING, y: bin.y + IMAGE_PADDING }, src.data); + } + for (const id in patterns) { + const src = patterns[id]; + const bin = patternPositions[id].paddedRect; + const x = bin.x + IMAGE_PADDING, y = bin.y + IMAGE_PADDING, w = src.data.width, h = src.data.height; + RGBAImage.copy(src.data, image, { x: 0, y: 0 }, { x, y }, src.data); + // Add 1 pixel wrapped padding on each side of the image. + RGBAImage.copy(src.data, image, { x: 0, y: h - 1 }, { x, y: y - 1 }, { width: w, height: 1 }); // T + RGBAImage.copy(src.data, image, { x: 0, y: 0 }, { x, y: y + h }, { width: w, height: 1 }); // B + RGBAImage.copy(src.data, image, { x: w - 1, y: 0 }, { x: x - 1, y }, { width: 1, height: h }); // L + RGBAImage.copy(src.data, image, { x: 0, y: 0 }, { x: x + w, y }, { width: 1, height: h }); // R + } + this.image = image; + this.iconPositions = iconPositions; + this.patternPositions = patternPositions; + } + addImages(images, positions, bins) { + for (const id in images) { + const src = images[id]; + const bin = { + x: 0, + y: 0, + w: src.data.width + 2 * IMAGE_PADDING, + h: src.data.height + 2 * IMAGE_PADDING, + }; + bins.push(bin); + positions[id] = new ImagePosition(bin, src); + if (src.hasRenderCallback) { + this.haveRenderCallbacks.push(id); + } + } + } + patchUpdatedImages(imageManager, texture) { + imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks); + for (const name in imageManager.updatedImages) { + this.patchUpdatedImage(this.iconPositions[name], imageManager.getImage(name), texture); + this.patchUpdatedImage(this.patternPositions[name], imageManager.getImage(name), texture); + } + } + patchUpdatedImage(position, image, texture) { + if (!position || !image) + return; + if (position.version === image.version) + return; + position.version = image.version; + const [x, y] = position.tl; + texture.update(image.data, undefined, { x, y }); + } +} +register('ImagePosition', ImagePosition); +register('ImageAtlas', ImageAtlas); + +exports.WritingMode = void 0; +(function (WritingMode) { + WritingMode[WritingMode["none"] = 0] = "none"; + WritingMode[WritingMode["horizontal"] = 1] = "horizontal"; + WritingMode[WritingMode["vertical"] = 2] = "vertical"; + WritingMode[WritingMode["horizontalOnly"] = 3] = "horizontalOnly"; +})(exports.WritingMode || (exports.WritingMode = {})); +const SHAPING_DEFAULT_OFFSET = -17; +function isEmpty(positionedLines) { + for (const line of positionedLines) { + if (line.positionedGlyphs.length !== 0) { + return false; + } + } + return true; +} +// Max number of images in label is 6401 U+E000–U+F8FF that covers +// Basic Multilingual Plane Unicode Private Use Area (PUA). +const PUAbegin = 0xE000; +const PUAend = 0xF8FF; +class SectionOptions { + constructor() { + this.scale = 1.0; + this.fontStack = ''; + this.imageName = null; + } + static forText(scale, fontStack) { + const textOptions = new SectionOptions(); + textOptions.scale = scale || 1; + textOptions.fontStack = fontStack; + return textOptions; + } + static forImage(imageName) { + const imageOptions = new SectionOptions(); + imageOptions.imageName = imageName; + return imageOptions; + } +} +class TaggedString { + constructor() { + this.text = ''; + this.sectionIndex = []; + this.sections = []; + this.imageSectionID = null; + } + static fromFeature(text, defaultFontStack) { + const result = new TaggedString(); + for (let i = 0; i < text.sections.length; i++) { + const section = text.sections[i]; + if (!section.image) { + result.addTextSection(section, defaultFontStack); + } + else { + result.addImageSection(section); + } + } + return result; + } + length() { + return this.text.length; + } + getSection(index) { + return this.sections[this.sectionIndex[index]]; + } + getSectionIndex(index) { + return this.sectionIndex[index]; + } + getCharCode(index) { + return this.text.charCodeAt(index); + } + verticalizePunctuation() { + this.text = verticalizePunctuation(this.text); + } + trim() { + let beginningWhitespace = 0; + for (let i = 0; i < this.text.length && whitespace[this.text.charCodeAt(i)]; i++) { + beginningWhitespace++; + } + let trailingWhitespace = this.text.length; + for (let i = this.text.length - 1; i >= 0 && i >= beginningWhitespace && whitespace[this.text.charCodeAt(i)]; i--) { + trailingWhitespace--; + } + this.text = this.text.substring(beginningWhitespace, trailingWhitespace); + this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace); + } + substring(start, end) { + const substring = new TaggedString(); + substring.text = this.text.substring(start, end); + substring.sectionIndex = this.sectionIndex.slice(start, end); + substring.sections = this.sections; + return substring; + } + toString() { + return this.text; + } + getMaxScale() { + return this.sectionIndex.reduce((max, index) => Math.max(max, this.sections[index].scale), 0); + } + addTextSection(section, defaultFontStack) { + this.text += section.text; + this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack)); + const index = this.sections.length - 1; + for (let i = 0; i < section.text.length; ++i) { + this.sectionIndex.push(index); + } + } + addImageSection(section) { + const imageName = section.image ? section.image.name : ''; + if (imageName.length === 0) { + warnOnce('Can\'t add FormattedSection with an empty image.'); + return; + } + const nextImageSectionCharCode = this.getNextImageSectionCharCode(); + if (!nextImageSectionCharCode) { + warnOnce(`Reached maximum number of images ${PUAend - PUAbegin + 2}`); + return; + } + this.text += String.fromCharCode(nextImageSectionCharCode); + this.sections.push(SectionOptions.forImage(imageName)); + this.sectionIndex.push(this.sections.length - 1); + } + getNextImageSectionCharCode() { + if (!this.imageSectionID) { + this.imageSectionID = PUAbegin; + return this.imageSectionID; + } + if (this.imageSectionID >= PUAend) + return null; + return ++this.imageSectionID; + } +} +function breakLines(input, lineBreakPoints) { + const lines = []; + const text = input.text; + let start = 0; + for (const lineBreak of lineBreakPoints) { + lines.push(input.substring(start, lineBreak)); + start = lineBreak; + } + if (start < text.length) { + lines.push(input.substring(start, text.length)); + } + return lines; +} +function shapeText(text, glyphMap, glyphPositions, imagePositions, defaultFontStack, maxWidth, lineHeight, textAnchor, textJustify, spacing, translate, writingMode, allowVerticalPlacement, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom) { + const logicalInput = TaggedString.fromFeature(text, defaultFontStack); + if (writingMode === exports.WritingMode.vertical) { + logicalInput.verticalizePunctuation(); + } + let lines; + const { processBidirectionalText, processStyledBidirectionalText } = plugin; + if (processBidirectionalText && logicalInput.sections.length === 1) { + // Bidi doesn't have to be style-aware + lines = []; + const untaggedLines = processBidirectionalText(logicalInput.toString(), determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize)); + for (const line of untaggedLines) { + const taggedLine = new TaggedString(); + taggedLine.text = line; + taggedLine.sections = logicalInput.sections; + for (let i = 0; i < line.length; i++) { + taggedLine.sectionIndex.push(0); + } + lines.push(taggedLine); + } + } + else if (processStyledBidirectionalText) { + // Need version of mapbox-gl-rtl-text with style support for combining RTL text + // with formatting + lines = []; + const processedLines = processStyledBidirectionalText(logicalInput.text, logicalInput.sectionIndex, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize)); + for (const line of processedLines) { + const taggedLine = new TaggedString(); + taggedLine.text = line[0]; + taggedLine.sectionIndex = line[1]; + taggedLine.sections = logicalInput.sections; + lines.push(taggedLine); + } + } + else { + lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize)); + } + const positionedLines = []; + const shaping = { + positionedLines, + text: logicalInput.toString(), + top: translate[1], + bottom: translate[1], + left: translate[0], + right: translate[0], + writingMode, + iconsInText: false, + verticalizable: false + }; + shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom); + if (isEmpty(positionedLines)) + return false; + return shaping; +} +// using computed properties due to https://github.com/facebook/flow/issues/380 +/* eslint no-useless-computed-key: 0 */ +const whitespace = { + [0x09]: true, + [0x0a]: true, + [0x0b]: true, + [0x0c]: true, + [0x0d]: true, + [0x20]: true, // space +}; +const breakable = { + [0x0a]: true, + [0x20]: true, + [0x26]: true, + [0x28]: true, + [0x29]: true, + [0x2b]: true, + [0x2d]: true, + [0x2f]: true, + [0xad]: true, + [0xb7]: true, + [0x200b]: true, + [0x2010]: true, + [0x2013]: true, + [0x2027]: true // interpunct + // Many other characters may be reasonable breakpoints + // Consider "neutral orientation" characters at scriptDetection.charHasNeutralVerticalOrientation + // See https://github.com/mapbox/mapbox-gl-js/issues/3658 +}; +function getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize) { + if (!section.imageName) { + const positions = glyphMap[section.fontStack]; + const glyph = positions && positions[codePoint]; + if (!glyph) + return 0; + return glyph.metrics.advance * section.scale + spacing; + } + else { + const imagePosition = imagePositions[section.imageName]; + if (!imagePosition) + return 0; + return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing; + } +} +function determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize) { + let totalWidth = 0; + for (let index = 0; index < logicalInput.length(); index++) { + const section = logicalInput.getSection(index); + totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize); + } + const lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth)); + return totalWidth / lineCount; +} +function calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) { + const raggedness = Math.pow(lineWidth - targetWidth, 2); + if (isLastBreak) { + // Favor finals lines shorter than average over longer than average + if (lineWidth < targetWidth) { + return raggedness / 2; + } + else { + return raggedness * 2; + } + } + return raggedness + Math.abs(penalty) * penalty; +} +function calculatePenalty(codePoint, nextCodePoint, penalizableIdeographicBreak) { + let penalty = 0; + // Force break on newline + if (codePoint === 0x0a) { + penalty -= 10000; + } + // Penalize breaks between characters that allow ideographic breaking because + // they are less preferable than breaks at spaces (or zero width spaces). + if (penalizableIdeographicBreak) { + penalty += 150; + } + // Penalize open parenthesis at end of line + if (codePoint === 0x28 || codePoint === 0xff08) { + penalty += 50; + } + // Penalize close parenthesis at beginning of line + if (nextCodePoint === 0x29 || nextCodePoint === 0xff09) { + penalty += 50; + } + return penalty; +} +function evaluateBreak(breakIndex, breakX, targetWidth, potentialBreaks, penalty, isLastBreak) { + // We could skip evaluating breaks where the line length (breakX - priorBreak.x) > maxWidth + // ...but in fact we allow lines longer than maxWidth (if there's no break points) + // ...and when targetWidth and maxWidth are close, strictly enforcing maxWidth can give + // more lopsided results. + let bestPriorBreak = null; + let bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak); + for (const potentialBreak of potentialBreaks) { + const lineWidth = breakX - potentialBreak.x; + const breakBadness = calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness; + if (breakBadness <= bestBreakBadness) { + bestPriorBreak = potentialBreak; + bestBreakBadness = breakBadness; + } + } + return { + index: breakIndex, + x: breakX, + priorBreak: bestPriorBreak, + badness: bestBreakBadness + }; +} +function leastBadBreaks(lastLineBreak) { + if (!lastLineBreak) { + return []; + } + return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index); +} +function determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize) { + if (symbolPlacement !== 'point') + return []; + if (!logicalInput) + return []; + const potentialLineBreaks = []; + const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize); + const hasServerSuggestedBreakpoints = logicalInput.text.indexOf('\u200b') >= 0; + let currentX = 0; + for (let i = 0; i < logicalInput.length(); i++) { + const section = logicalInput.getSection(i); + const codePoint = logicalInput.getCharCode(i); + if (!whitespace[codePoint]) + currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize); + // Ideographic characters, spaces, and word-breaking punctuation that often appear without + // surrounding spaces. + if ((i < logicalInput.length() - 1)) { + const ideographicBreak = charAllowsIdeographicBreaking(codePoint); + if (breakable[codePoint] || ideographicBreak || section.imageName) { + potentialLineBreaks.push(evaluateBreak(i + 1, currentX, targetWidth, potentialLineBreaks, calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints), false)); + } + } + } + return leastBadBreaks(evaluateBreak(logicalInput.length(), currentX, targetWidth, potentialLineBreaks, 0, true)); +} +function getAnchorAlignment(anchor) { + let horizontalAlign = 0.5, verticalAlign = 0.5; + switch (anchor) { + case 'right': + case 'top-right': + case 'bottom-right': + horizontalAlign = 1; + break; + case 'left': + case 'top-left': + case 'bottom-left': + horizontalAlign = 0; + break; + } + switch (anchor) { + case 'bottom': + case 'bottom-right': + case 'bottom-left': + verticalAlign = 1; + break; + case 'top': + case 'top-right': + case 'top-left': + verticalAlign = 0; + break; + } + return { horizontalAlign, verticalAlign }; +} +function shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom) { + let x = 0; + let y = SHAPING_DEFAULT_OFFSET; + let maxLineLength = 0; + let maxLineHeight = 0; + const justify = textJustify === 'right' ? 1 : + textJustify === 'left' ? 0 : 0.5; + let lineIndex = 0; + for (const line of lines) { + line.trim(); + const lineMaxScale = line.getMaxScale(); + const maxLineOffset = (lineMaxScale - 1) * ONE_EM; + const positionedLine = { positionedGlyphs: [], lineOffset: 0 }; + shaping.positionedLines[lineIndex] = positionedLine; + const positionedGlyphs = positionedLine.positionedGlyphs; + let lineOffset = 0.0; + if (!line.length()) { + y += lineHeight; // Still need a line feed after empty line + ++lineIndex; + continue; + } + for (let i = 0; i < line.length(); i++) { + const section = line.getSection(i); + const sectionIndex = line.getSectionIndex(i); + const codePoint = line.getCharCode(i); + let baselineOffset = 0.0; + let metrics = null; + let rect = null; + let imageName = null; + let verticalAdvance = ONE_EM; + const vertical = !(writingMode === exports.WritingMode.horizontal || + // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled. + (!allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint)) || + // If vertical placement is enabled, don't verticalize glyphs that + // are from complex text layout script, or whitespaces. + (allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint)))); + if (!section.imageName) { + const positions = glyphPositions[section.fontStack]; + const glyphPosition = positions && positions[codePoint]; + if (glyphPosition && glyphPosition.rect) { + rect = glyphPosition.rect; + metrics = glyphPosition.metrics; + } + else { + const glyphs = glyphMap[section.fontStack]; + const glyph = glyphs && glyphs[codePoint]; + if (!glyph) + continue; + metrics = glyph.metrics; + } + // We don't know the baseline, but since we're laying out + // at 24 points, we can calculate how much it will move when + // we scale up or down. + baselineOffset = (lineMaxScale - section.scale) * ONE_EM; + } + else { + const imagePosition = imagePositions[section.imageName]; + if (!imagePosition) + continue; + imageName = section.imageName; + shaping.iconsInText = shaping.iconsInText || true; + rect = imagePosition.paddedRect; + const size = imagePosition.displaySize; + // If needed, allow to set scale factor for an image using + // alias "image-scale" that could be alias for "font-scale" + // when FormattedSection is an image section. + section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom; + metrics = { width: size[0], + height: size[1], + left: IMAGE_PADDING, + top: -GLYPH_PBF_BORDER, + advance: vertical ? size[1] : size[0] }; + // Difference between one EM and an image size. + // Aligns bottom of an image to a baseline level. + const imageOffset = ONE_EM - size[1] * section.scale; + baselineOffset = maxLineOffset + imageOffset; + verticalAdvance = metrics.advance; + // Difference between height of an image and one EM at max line scale. + // Pushes current line down if an image size is over 1 EM at max line scale. + const offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale : + size[1] * section.scale - ONE_EM * lineMaxScale; + if (offset > 0 && offset > lineOffset) { + lineOffset = offset; + } + } + if (!vertical) { + positionedGlyphs.push({ glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect }); + x += metrics.advance * section.scale + spacing; + } + else { + shaping.verticalizable = true; + positionedGlyphs.push({ glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect }); + x += verticalAdvance * section.scale + spacing; + } + } + // Only justify if we placed at least one glyph + if (positionedGlyphs.length !== 0) { + const lineLength = x - spacing; + maxLineLength = Math.max(lineLength, maxLineLength); + justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset); + } + x = 0; + const currentLineHeight = lineHeight * lineMaxScale + lineOffset; + positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset); + y += currentLineHeight; + maxLineHeight = Math.max(currentLineHeight, maxLineHeight); + ++lineIndex; + } + // Calculate the bounding box and justify / align text block. + const height = y - SHAPING_DEFAULT_OFFSET; + const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor); + align(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length); + shaping.top += -verticalAlign * height; + shaping.bottom = shaping.top + height; + shaping.left += -horizontalAlign * maxLineLength; + shaping.right = shaping.left + maxLineLength; +} +// justify right = 1, left = 0, center = 0.5 +function justifyLine(positionedGlyphs, start, end, justify, lineOffset) { + if (!justify && !lineOffset) + return; + const lastPositionedGlyph = positionedGlyphs[end]; + const lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale; + const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify; + for (let j = start; j <= end; j++) { + positionedGlyphs[j].x -= lineIndent; + positionedGlyphs[j].y += lineOffset; + } +} +function align(positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, blockHeight, lineCount) { + const shiftX = (justify - horizontalAlign) * maxLineLength; + let shiftY = 0; + if (maxLineHeight !== lineHeight) { + shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET; + } + else { + shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight; + } + for (const line of positionedLines) { + for (const positionedGlyph of line.positionedGlyphs) { + positionedGlyph.x += shiftX; + positionedGlyph.y += shiftY; + } + } +} +function shapeIcon(image, iconOffset, iconAnchor) { + const { horizontalAlign, verticalAlign } = getAnchorAlignment(iconAnchor); + const dx = iconOffset[0]; + const dy = iconOffset[1]; + const x1 = dx - image.displaySize[0] * horizontalAlign; + const x2 = x1 + image.displaySize[0]; + const y1 = dy - image.displaySize[1] * verticalAlign; + const y2 = y1 + image.displaySize[1]; + return { image, top: y1, bottom: y2, left: x1, right: x2 }; +} +function fitIconToText(shapedIcon, shapedText, textFit, padding, iconOffset, fontScale) { + const image = shapedIcon.image; + let collisionPadding; + if (image.content) { + const content = image.content; + const pixelRatio = image.pixelRatio || 1; + collisionPadding = [ + content[0] / pixelRatio, + content[1] / pixelRatio, + image.displaySize[0] - content[2] / pixelRatio, + image.displaySize[1] - content[3] / pixelRatio + ]; + } + // We don't respect the icon-anchor, because icon-text-fit is set. Instead, + // the icon will be centered on the text, then stretched in the given + // dimensions. + const textLeft = shapedText.left * fontScale; + const textRight = shapedText.right * fontScale; + let top, right, bottom, left; + if (textFit === 'width' || textFit === 'both') { + // Stretched horizontally to the text width + left = iconOffset[0] + textLeft - padding[3]; + right = iconOffset[0] + textRight + padding[1]; + } + else { + // Centered on the text + left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2; + right = left + image.displaySize[0]; + } + const textTop = shapedText.top * fontScale; + const textBottom = shapedText.bottom * fontScale; + if (textFit === 'height' || textFit === 'both') { + // Stretched vertically to the text height + top = iconOffset[1] + textTop - padding[0]; + bottom = iconOffset[1] + textBottom + padding[2]; + } + else { + // Centered on the text + top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2; + bottom = top + image.displaySize[1]; + } + return { image, top, right, bottom, left, collisionPadding }; +} + +const MAX_GLYPH_ICON_SIZE = 255; +const SIZE_PACK_FACTOR = 128; +const MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR; +// For {text,icon}-size, get the bucket-level data that will be needed by +// the painter to set symbol-size-related uniforms +function getSizeData(tileZoom, value) { + const { expression } = value; + if (expression.kind === 'constant') { + const layoutSize = expression.evaluate(new EvaluationParameters(tileZoom + 1)); + return { kind: 'constant', layoutSize }; + } + else if (expression.kind === 'source') { + return { kind: 'source' }; + } + else { + const { zoomStops, interpolationType } = expression; + // calculate covering zoom stops for zoom-dependent values + let lower = 0; + while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) + lower++; + lower = Math.max(0, lower - 1); + let upper = lower; + while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) + upper++; + upper = Math.min(zoomStops.length - 1, upper); + const minZoom = zoomStops[lower]; + const maxZoom = zoomStops[upper]; + // We'd like to be able to use CameraExpression or CompositeExpression in these + // return types rather than ExpressionSpecification, but the former are not + // transferrable across Web Worker boundaries. + if (expression.kind === 'composite') { + return { kind: 'composite', minZoom, maxZoom, interpolationType }; + } + // for camera functions, also save off the function values + // evaluated at the covering zoom levels + const minSize = expression.evaluate(new EvaluationParameters(minZoom)); + const maxSize = expression.evaluate(new EvaluationParameters(maxZoom)); + return { kind: 'camera', minZoom, maxZoom, minSize, maxSize, interpolationType }; + } +} +function evaluateSizeForFeature(sizeData, { uSize, uSizeT }, { lowerSize, upperSize }) { + if (sizeData.kind === 'source') { + return lowerSize / SIZE_PACK_FACTOR; + } + else if (sizeData.kind === 'composite') { + return interpolate.number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT); + } + return uSize; +} +function evaluateSizeForZoom(sizeData, zoom) { + let uSizeT = 0; + let uSize = 0; + if (sizeData.kind === 'constant') { + uSize = sizeData.layoutSize; + } + else if (sizeData.kind !== 'source') { + const { interpolationType, minZoom, maxZoom } = sizeData; + // Even though we could get the exact value of the camera function + // at z = tr.zoom, we intentionally do not: instead, we interpolate + // between the camera function values at a pair of zoom stops covering + // [tileZoom, tileZoom + 1] in order to be consistent with this + // restriction on composite functions + const t = !interpolationType ? 0 : clamp$1(Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1); + if (sizeData.kind === 'camera') { + uSize = interpolate.number(sizeData.minSize, sizeData.maxSize, t); + } + else { + uSizeT = t; + } + } + return { uSizeT, uSize }; +} + +function getOverlapMode(layout, overlapProp, allowOverlapProp) { + let result = 'never'; + const overlap = layout.get(overlapProp); + if (overlap) { + // if -overlap is set, use it + result = overlap; + } + else if (layout.get(allowOverlapProp)) { + // fall back to -allow-overlap, with false='never', true='always' + result = 'always'; + } + return result; +} + +const vectorTileFeatureTypes = vectorTile.VectorTileFeature.types; +// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them +// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph +// 7 bits are for the current opacity, and the lowest bit is the target opacity +// actually defined in symbol_attributes.js +// const placementOpacityAttributes = [ +// { name: 'a_fade_opacity', components: 1, type: 'Uint32' } +// ]; +const shaderOpacityAttributes = [ + { name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0 } +]; +function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex, isSDF, pixelOffsetX, pixelOffsetY, minFontScaleX, minFontScaleY) { + const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0; + const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0; + array.emplaceBack( + // a_pos_offset + anchorX, anchorY, Math.round(ox * 32), Math.round(oy * 32), + // a_data + tx, // x coordinate of symbol on glyph atlas texture + ty, // y coordinate of symbol on glyph atlas texture + (aSizeX << 1) + (isSDF ? 1 : 0), aSizeY, pixelOffsetX * 16, pixelOffsetY * 16, minFontScaleX * 256, minFontScaleY * 256); +} +function addDynamicAttributes(dynamicLayoutVertexArray, p, angle) { + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); +} +function containsRTLText(formattedText) { + for (const section of formattedText.sections) { + if (stringContainsRTLText(section.text)) { + return true; + } + } + return false; +} +class SymbolBuffers { + constructor(programConfigurations) { + this.layoutVertexArray = new SymbolLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.programConfigurations = programConfigurations; + this.segments = new SegmentVector(); + this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray(); + this.opacityVertexArray = new SymbolOpacityArray(); + this.hasVisibleVertices = false; + this.placedSymbolArray = new PlacedSymbolArray(); + } + isEmpty() { + return this.layoutVertexArray.length === 0 && + this.indexArray.length === 0 && + this.dynamicLayoutVertexArray.length === 0 && + this.opacityVertexArray.length === 0; + } + upload(context, dynamicIndexBuffer, upload, update) { + if (this.isEmpty()) { + return; + } + if (upload) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members); + this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer); + this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true); + this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true); + // This is a performance hack so that we can write to opacityVertexArray with uint32s + // even though the shaders read uint8s + this.opacityVertexBuffer.itemSize = 1; + } + if (upload || update) { + this.programConfigurations.upload(context); + } + } + destroy() { + if (!this.layoutVertexBuffer) + return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + this.dynamicLayoutVertexBuffer.destroy(); + this.opacityVertexBuffer.destroy(); + } +} +register('SymbolBuffers', SymbolBuffers); +class CollisionBuffers { + constructor(LayoutArray, layoutAttributes, IndexArray) { + this.layoutVertexArray = new LayoutArray(); + this.layoutAttributes = layoutAttributes; + this.indexArray = new IndexArray(); + this.segments = new SegmentVector(); + this.collisionVertexArray = new CollisionVertexArray(); + } + upload(context) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true); + } + destroy() { + if (!this.layoutVertexBuffer) + return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.segments.destroy(); + this.collisionVertexBuffer.destroy(); + } +} +register('CollisionBuffers', CollisionBuffers); +/** + * @internal + * Unlike other buckets, which simply implement #addFeature with type-specific + * logic for (essentially) triangulating feature geometries, SymbolBucket + * requires specialized behavior: + * + * 1. WorkerTile#parse(), the logical owner of the bucket creation process, + * calls SymbolBucket#populate(), which resolves text and icon tokens on + * each feature, adds each glyphs and symbols needed to the passed-in + * collections options.glyphDependencies and options.iconDependencies, and + * stores the feature data for use in subsequent step (this.features). + * + * 2. WorkerTile asynchronously requests from the main thread all of the glyphs + * and icons needed (by this bucket and any others). When glyphs and icons + * have been received, the WorkerTile creates a CollisionIndex and invokes: + * + * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and + * layout on a Symbol Bucket. This step populates: + * `this.symbolInstances`: metadata on generated symbols + * `this.collisionBoxArray`: collision data for use by foreground + * `this.text`: SymbolBuffers for text symbols + * `this.icons`: SymbolBuffers for icons + * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes + * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes + * The results are sent to the foreground for rendering + * + * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground, + * and uses the CollisionIndex along with current camera settings to determine + * which symbols can actually show on the map. Collided symbols are hidden + * using a dynamic "OpacityVertexArray". + */ +class SymbolBucket { + constructor(options) { + this.collisionBoxArray = options.collisionBoxArray; + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.pixelRatio = options.pixelRatio; + this.sourceLayerIndex = options.sourceLayerIndex; + this.hasPattern = false; + this.hasRTLText = false; + this.sortKeyRanges = []; + this.collisionCircleArray = []; + this.placementInvProjMatrix = identity$2([]); + this.placementViewportMatrix = identity$2([]); + const layer = this.layers[0]; + const unevaluatedLayoutValues = layer._unevaluatedLayout._values; + this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']); + this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']); + const layout = this.layers[0].layout; + const sortKey = layout.get('symbol-sort-key'); + const zOrder = layout.get('symbol-z-order'); + this.canOverlap = + getOverlapMode(layout, 'text-overlap', 'text-allow-overlap') !== 'never' || + getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap') !== 'never' || + layout.get('text-ignore-placement') || + layout.get('icon-ignore-placement'); + this.sortFeaturesByKey = zOrder !== 'viewport-y' && !sortKey.isConstant(); + const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey); + this.sortFeaturesByY = zOrderByViewportY && this.canOverlap; + if (layout.get('symbol-placement') === 'point') { + this.writingModes = layout.get('text-writing-mode').map(wm => exports.WritingMode[wm]); + } + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + this.sourceID = options.sourceID; + } + createArrays() { + this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property))); + this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property))); + this.glyphOffsetArray = new GlyphOffsetArray(); + this.lineVertexArray = new SymbolLineVertexArray(); + this.symbolInstances = new SymbolInstanceArray(); + this.textAnchorOffsets = new TextAnchorOffsetArray(); + } + calculateGlyphDependencies(text, stack, textAlongLine, allowVerticalPlacement, doesAllowVerticalWritingMode) { + for (let i = 0; i < text.length; i++) { + stack[text.charCodeAt(i)] = true; + if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) { + const verticalChar = verticalizedCharacterMap[text.charAt(i)]; + if (verticalChar) { + stack[verticalChar.charCodeAt(0)] = true; + } + } + } + } + populate(features, options, canonical) { + const layer = this.layers[0]; + const layout = layer.layout; + const textFont = layout.get('text-font'); + const textField = layout.get('text-field'); + const iconImage = layout.get('icon-image'); + const hasText = (textField.value.kind !== 'constant' || + (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) || + textField.value.value.toString().length > 0) && + (textFont.value.kind !== 'constant' || textFont.value.value.length > 0); + // we should always resolve the icon-image value if the property was defined in the style + // this allows us to fire the styleimagemissing event if image evaluation returns null + // the only way to distinguish between null returned from a coalesce statement with no valid images + // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object + const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0; + const symbolSortKey = layout.get('symbol-sort-key'); + this.features = []; + if (!hasText && !hasIcon) { + return; + } + const icons = options.iconDependencies; + const stacks = options.glyphDependencies; + const availableImages = options.availableImages; + const globalProperties = new EvaluationParameters(this.zoom); + for (const { feature, id, index, sourceLayerIndex } of features) { + const needGeometry = layer._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) { + continue; + } + if (!needGeometry) + evaluationFeature.geometry = loadGeometry(feature); + let text; + if (hasText) { + // Expression evaluation will automatically coerce to Formatted + // but plain string token evaluation skips that pathway so do the + // conversion here. + const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages); + const formattedText = Formatted.factory(resolvedTokens); + if (containsRTLText(formattedText)) { + this.hasRTLText = true; + } + if (!this.hasRTLText || // non-rtl text so can proceed safely + getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping + this.hasRTLText && plugin.isParsed() // Use the rtlText plugin to shape text + ) { + text = transformText(formattedText, layer, evaluationFeature); + } + } + let icon; + if (hasIcon) { + // Expression evaluation will automatically coerce to Image + // but plain string token evaluation skips that pathway so do the + // conversion here. + const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages); + if (resolvedTokens instanceof ResolvedImage) { + icon = resolvedTokens; + } + else { + icon = ResolvedImage.fromString(resolvedTokens); + } + } + if (!text && !icon) { + continue; + } + const sortKey = this.sortFeaturesByKey ? + symbolSortKey.evaluate(evaluationFeature, {}, canonical) : + undefined; + const symbolFeature = { + id, + text, + icon, + index, + sourceLayerIndex, + geometry: evaluationFeature.geometry, + properties: feature.properties, + type: vectorTileFeatureTypes[feature.type], + sortKey + }; + this.features.push(symbolFeature); + if (icon) { + icons[icon.name] = true; + } + if (text) { + const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(','); + const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point'; + this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(exports.WritingMode.vertical) >= 0; + for (const section of text.sections) { + if (!section.image) { + const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString()); + const sectionFont = section.fontStack || fontStack; + const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {}; + this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode); + } + else { + // Add section image to the list of dependencies. + icons[section.image.name] = true; + } + } + } + } + if (layout.get('symbol-placement') === 'line') { + // Merge adjacent lines with the same text to improve labelling. + // It's better to place labels on one long line than on many short segments. + this.features = mergeLines(this.features); + } + if (this.sortFeaturesByKey) { + this.features.sort((a, b) => { + // a.sortKey is always a number when sortFeaturesByKey is true + return a.sortKey - b.sortKey; + }); + } + } + update(states, vtLayer, imagePositions) { + if (!this.stateDependentLayers.length) + return; + this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions); + this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions); + } + isEmpty() { + // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created. + // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary. + return this.symbolInstances.length === 0 && !this.hasRTLText; + } + uploadPending() { + return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload; + } + upload(context) { + if (!this.uploaded && this.hasDebugData()) { + this.textCollisionBox.upload(context); + this.iconCollisionBox.upload(context); + } + this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload); + this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload); + this.uploaded = true; + } + destroyDebugData() { + this.textCollisionBox.destroy(); + this.iconCollisionBox.destroy(); + } + destroy() { + this.text.destroy(); + this.icon.destroy(); + if (this.hasDebugData()) { + this.destroyDebugData(); + } + } + addToLineVertexArray(anchor, line) { + const lineStartIndex = this.lineVertexArray.length; + if (anchor.segment !== undefined) { + let sumForwardLength = anchor.dist(line[anchor.segment + 1]); + let sumBackwardLength = anchor.dist(line[anchor.segment]); + const vertices = {}; + for (let i = anchor.segment + 1; i < line.length; i++) { + vertices[i] = { x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength }; + if (i < line.length - 1) { + sumForwardLength += line[i + 1].dist(line[i]); + } + } + for (let i = anchor.segment || 0; i >= 0; i--) { + vertices[i] = { x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength }; + if (i > 0) { + sumBackwardLength += line[i - 1].dist(line[i]); + } + } + for (let i = 0; i < line.length; i++) { + const vertex = vertices[i]; + this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor); + } + } + return { + lineStartIndex, + lineLength: this.lineVertexArray.length - lineStartIndex + }; + } + addSymbols(arrays, quads, sizeVertex, lineOffset, alongLine, feature, writingMode, labelAnchor, lineStartIndex, lineLength, associatedIconIndex, canonical) { + const indexArray = arrays.indexArray; + const layoutVertexArray = arrays.layoutVertexArray; + const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey : undefined); + const glyphOffsetArrayStart = this.glyphOffsetArray.length; + const vertexStartIndex = segment.vertexLength; + const angle = (this.allowVerticalPlacement && writingMode === exports.WritingMode.vertical) ? Math.PI / 2 : 0; + const sections = feature.text && feature.text.sections; + for (let i = 0; i < quads.length; i++) { + const { tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex } = quads[i]; + const index = segment.vertexLength; + const y = glyphOffset[1]; + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY); + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY); + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY); + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY); + addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle); + indexArray.emplaceBack(index, index + 1, index + 2); + indexArray.emplaceBack(index + 1, index + 2, index + 3); + segment.vertexLength += 4; + segment.primitiveLength += 2; + this.glyphOffsetArray.emplaceBack(glyphOffset[0]); + if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) { + arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]); + } + } + arrays.placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y, glyphOffsetArrayStart, this.glyphOffsetArray.length - glyphOffsetArrayStart, vertexStartIndex, lineStartIndex, lineLength, labelAnchor.segment, sizeVertex ? sizeVertex[0] : 0, sizeVertex ? sizeVertex[1] : 0, lineOffset[0], lineOffset[1], writingMode, + // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed + 0, false, + // The crossTileID is only filled/used on the foreground for dynamic text anchors + 0, associatedIconIndex); + } + _addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, point, anchorX, anchorY, extrude) { + collisionVertexArray.emplaceBack(0, 0); + return layoutVertexArray.emplaceBack( + // pos + point.x, point.y, + // a_anchor_pos + anchorX, anchorY, + // extrude + Math.round(extrude.x), Math.round(extrude.y)); + } + addCollisionDebugVertices(x1, y1, x2, y2, arrays, boxAnchorPoint, symbolInstance) { + const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray); + const index = segment.vertexLength; + const layoutVertexArray = arrays.layoutVertexArray; + const collisionVertexArray = arrays.collisionVertexArray; + const anchorX = symbolInstance.anchorX; + const anchorY = symbolInstance.anchorY; + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point$2(x1, y1)); + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point$2(x2, y1)); + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point$2(x2, y2)); + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point$2(x1, y2)); + segment.vertexLength += 4; + const indexArray = arrays.indexArray; + indexArray.emplaceBack(index, index + 1); + indexArray.emplaceBack(index + 1, index + 2); + indexArray.emplaceBack(index + 2, index + 3); + indexArray.emplaceBack(index + 3, index); + segment.primitiveLength += 4; + } + addDebugCollisionBoxes(startIndex, endIndex, symbolInstance, isText) { + for (let b = startIndex; b < endIndex; b++) { + const box = this.collisionBoxArray.get(b); + const x1 = box.x1; + const y1 = box.y1; + const x2 = box.x2; + const y2 = box.y2; + this.addCollisionDebugVertices(x1, y1, x2, y2, isText ? this.textCollisionBox : this.iconCollisionBox, box.anchorPoint, symbolInstance); + } + } + generateCollisionDebugBuffers() { + if (this.hasDebugData()) { + this.destroyDebugData(); + } + this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray); + this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray); + for (let i = 0; i < this.symbolInstances.length; i++) { + const symbolInstance = this.symbolInstances.get(i); + this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true); + this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true); + this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false); + this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false); + } + } + // These flat arrays are meant to be quicker to iterate over than the source + // CollisionBoxArray + _deserializeCollisionBoxesForSymbol(collisionBoxArray, textStartIndex, textEndIndex, verticalTextStartIndex, verticalTextEndIndex, iconStartIndex, iconEndIndex, verticalIconStartIndex, verticalIconEndIndex) { + const collisionArrays = {}; + for (let k = textStartIndex; k < textEndIndex; k++) { + const box = 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 = 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 = 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 = 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 + } + return collisionArrays; + } + deserializeCollisionBoxes(collisionBoxArray) { + this.collisionArrays = []; + for (let i = 0; i < this.symbolInstances.length; i++) { + const symbolInstance = this.symbolInstances.get(i); + this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(collisionBoxArray, symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex)); + } + } + hasTextData() { + return this.text.segments.get().length > 0; + } + hasIconData() { + return this.icon.segments.get().length > 0; + } + hasDebugData() { + return this.textCollisionBox && this.iconCollisionBox; + } + hasTextCollisionBoxData() { + return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0; + } + hasIconCollisionBoxData() { + return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0; + } + addIndicesForPlacedSymbol(iconOrText, placedSymbolIndex) { + const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex); + const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4; + for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) { + iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2); + iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3); + } + } + getSortedSymbolIndexes(angle) { + if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) { + return this.symbolInstanceIndexes; + } + const sin = Math.sin(angle); + const cos = Math.cos(angle); + const rotatedYs = []; + const featureIndexes = []; + const result = []; + for (let i = 0; i < this.symbolInstances.length; ++i) { + result.push(i); + const symbolInstance = this.symbolInstances.get(i); + rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0); + featureIndexes.push(symbolInstance.featureIndex); + } + result.sort((aIndex, bIndex) => { + return (rotatedYs[aIndex] - rotatedYs[bIndex]) || + (featureIndexes[bIndex] - featureIndexes[aIndex]); + }); + return result; + } + addToSortKeyRanges(symbolInstanceIndex, sortKey) { + const last = this.sortKeyRanges[this.sortKeyRanges.length - 1]; + if (last && last.sortKey === sortKey) { + last.symbolInstanceEnd = symbolInstanceIndex + 1; + } + else { + this.sortKeyRanges.push({ + sortKey, + symbolInstanceStart: symbolInstanceIndex, + symbolInstanceEnd: symbolInstanceIndex + 1 + }); + } + } + sortFeatures(angle) { + if (!this.sortFeaturesByY) + return; + if (this.sortedAngle === angle) + return; + // The current approach to sorting doesn't sort across segments so don't try. + // Sorting within segments separately seemed not to be worth the complexity. + if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) + return; + // If the symbols are allowed to overlap sort them by their vertical screen position. + // The index array buffer is rewritten to reference the (unchanged) vertices in the + // sorted order. + // To avoid sorting the actual symbolInstance array we sort an array of indexes. + this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle); + this.sortedAngle = angle; + this.text.indexArray.clear(); + this.icon.indexArray.clear(); + this.featureSortOrder = []; + for (const i of this.symbolInstanceIndexes) { + const symbolInstance = this.symbolInstances.get(i); + this.featureSortOrder.push(symbolInstance.featureIndex); + [ + symbolInstance.rightJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.leftJustifiedTextSymbolIndex + ].forEach((index, i, array) => { + // Only add a given index the first time it shows up, + // to avoid duplicate opacity entries when multiple justifications + // share the same glyphs. + if (index >= 0 && array.indexOf(index) === i) { + this.addIndicesForPlacedSymbol(this.text, index); + } + }); + if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) { + this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex); + } + if (symbolInstance.placedIconSymbolIndex >= 0) { + this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex); + } + if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) { + this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex); + } + } + if (this.text.indexBuffer) + this.text.indexBuffer.updateData(this.text.indexArray); + if (this.icon.indexBuffer) + this.icon.indexBuffer.updateData(this.icon.indexArray); + } +} +register('SymbolBucket', SymbolBucket, { + omit: ['layers', 'collisionBoxArray', 'features', 'compareText'] +}); +// this constant is based on the size of StructArray indexes used in a symbol +// bucket--namely, glyphOffsetArrayStart +// eg the max valid UInt16 is 65,535 +// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation +// lineStartIndex and textBoxStartIndex could potentially be concerns +// but we expect there to be many fewer boxes/lines than glyphs +SymbolBucket.MAX_GLYPHS = 65535; +SymbolBucket.addDynamicAttributes = addDynamicAttributes; + +/** + * Replace tokens in a string template with values in an object + * + * @param properties - a key/value relationship between tokens and replacements + * @param text - the template string + * @returns the template with tokens replaced + */ +function resolveTokens(properties, text) { + return text.replace(/{([^{}]+)}/g, (match, key) => { + return properties && key in properties ? String(properties[key]) : ''; + }); +} + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let layout; +const getLayout = () => layout = layout || new Properties({ + "symbol-placement": new DataConstantProperty(v8Spec["layout_symbol"]["symbol-placement"]), + "symbol-spacing": new DataConstantProperty(v8Spec["layout_symbol"]["symbol-spacing"]), + "symbol-avoid-edges": new DataConstantProperty(v8Spec["layout_symbol"]["symbol-avoid-edges"]), + "symbol-sort-key": new DataDrivenProperty(v8Spec["layout_symbol"]["symbol-sort-key"]), + "symbol-z-order": new DataConstantProperty(v8Spec["layout_symbol"]["symbol-z-order"]), + "icon-allow-overlap": new DataConstantProperty(v8Spec["layout_symbol"]["icon-allow-overlap"]), + "icon-overlap": new DataConstantProperty(v8Spec["layout_symbol"]["icon-overlap"]), + "icon-ignore-placement": new DataConstantProperty(v8Spec["layout_symbol"]["icon-ignore-placement"]), + "icon-optional": new DataConstantProperty(v8Spec["layout_symbol"]["icon-optional"]), + "icon-rotation-alignment": new DataConstantProperty(v8Spec["layout_symbol"]["icon-rotation-alignment"]), + "icon-size": new DataDrivenProperty(v8Spec["layout_symbol"]["icon-size"]), + "icon-text-fit": new DataConstantProperty(v8Spec["layout_symbol"]["icon-text-fit"]), + "icon-text-fit-padding": new DataConstantProperty(v8Spec["layout_symbol"]["icon-text-fit-padding"]), + "icon-image": new DataDrivenProperty(v8Spec["layout_symbol"]["icon-image"]), + "icon-rotate": new DataDrivenProperty(v8Spec["layout_symbol"]["icon-rotate"]), + "icon-padding": new DataDrivenProperty(v8Spec["layout_symbol"]["icon-padding"]), + "icon-keep-upright": new DataConstantProperty(v8Spec["layout_symbol"]["icon-keep-upright"]), + "icon-offset": new DataDrivenProperty(v8Spec["layout_symbol"]["icon-offset"]), + "icon-anchor": new DataDrivenProperty(v8Spec["layout_symbol"]["icon-anchor"]), + "icon-pitch-alignment": new DataConstantProperty(v8Spec["layout_symbol"]["icon-pitch-alignment"]), + "text-pitch-alignment": new DataConstantProperty(v8Spec["layout_symbol"]["text-pitch-alignment"]), + "text-rotation-alignment": new DataConstantProperty(v8Spec["layout_symbol"]["text-rotation-alignment"]), + "text-field": new DataDrivenProperty(v8Spec["layout_symbol"]["text-field"]), + "text-font": new DataDrivenProperty(v8Spec["layout_symbol"]["text-font"]), + "text-size": new DataDrivenProperty(v8Spec["layout_symbol"]["text-size"]), + "text-max-width": new DataDrivenProperty(v8Spec["layout_symbol"]["text-max-width"]), + "text-line-height": new DataConstantProperty(v8Spec["layout_symbol"]["text-line-height"]), + "text-letter-spacing": new DataDrivenProperty(v8Spec["layout_symbol"]["text-letter-spacing"]), + "text-justify": new DataDrivenProperty(v8Spec["layout_symbol"]["text-justify"]), + "text-radial-offset": new DataDrivenProperty(v8Spec["layout_symbol"]["text-radial-offset"]), + "text-variable-anchor": new DataConstantProperty(v8Spec["layout_symbol"]["text-variable-anchor"]), + "text-variable-anchor-offset": new DataDrivenProperty(v8Spec["layout_symbol"]["text-variable-anchor-offset"]), + "text-anchor": new DataDrivenProperty(v8Spec["layout_symbol"]["text-anchor"]), + "text-max-angle": new DataConstantProperty(v8Spec["layout_symbol"]["text-max-angle"]), + "text-writing-mode": new DataConstantProperty(v8Spec["layout_symbol"]["text-writing-mode"]), + "text-rotate": new DataDrivenProperty(v8Spec["layout_symbol"]["text-rotate"]), + "text-padding": new DataConstantProperty(v8Spec["layout_symbol"]["text-padding"]), + "text-keep-upright": new DataConstantProperty(v8Spec["layout_symbol"]["text-keep-upright"]), + "text-transform": new DataDrivenProperty(v8Spec["layout_symbol"]["text-transform"]), + "text-offset": new DataDrivenProperty(v8Spec["layout_symbol"]["text-offset"]), + "text-allow-overlap": new DataConstantProperty(v8Spec["layout_symbol"]["text-allow-overlap"]), + "text-overlap": new DataConstantProperty(v8Spec["layout_symbol"]["text-overlap"]), + "text-ignore-placement": new DataConstantProperty(v8Spec["layout_symbol"]["text-ignore-placement"]), + "text-optional": new DataConstantProperty(v8Spec["layout_symbol"]["text-optional"]), +}); +let paint$2; +const getPaint$2 = () => paint$2 = paint$2 || new Properties({ + "icon-opacity": new DataDrivenProperty(v8Spec["paint_symbol"]["icon-opacity"]), + "icon-color": new DataDrivenProperty(v8Spec["paint_symbol"]["icon-color"]), + "icon-halo-color": new DataDrivenProperty(v8Spec["paint_symbol"]["icon-halo-color"]), + "icon-halo-width": new DataDrivenProperty(v8Spec["paint_symbol"]["icon-halo-width"]), + "icon-halo-blur": new DataDrivenProperty(v8Spec["paint_symbol"]["icon-halo-blur"]), + "icon-translate": new DataConstantProperty(v8Spec["paint_symbol"]["icon-translate"]), + "icon-translate-anchor": new DataConstantProperty(v8Spec["paint_symbol"]["icon-translate-anchor"]), + "text-opacity": new DataDrivenProperty(v8Spec["paint_symbol"]["text-opacity"]), + "text-color": new DataDrivenProperty(v8Spec["paint_symbol"]["text-color"], { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }), + "text-halo-color": new DataDrivenProperty(v8Spec["paint_symbol"]["text-halo-color"]), + "text-halo-width": new DataDrivenProperty(v8Spec["paint_symbol"]["text-halo-width"]), + "text-halo-blur": new DataDrivenProperty(v8Spec["paint_symbol"]["text-halo-blur"]), + "text-translate": new DataConstantProperty(v8Spec["paint_symbol"]["text-translate"]), + "text-translate-anchor": new DataConstantProperty(v8Spec["paint_symbol"]["text-translate-anchor"]), +}); +var properties$2 = ({ get paint() { return getPaint$2(); }, get layout() { return getLayout(); } }); + +// This is an internal expression class. It is only used in GL JS and +// has GL JS dependencies which can break the standalone style-spec module +class FormatSectionOverride { + constructor(defaultValue) { + if (defaultValue.property.overrides === undefined) + throw new Error('overrides must be provided to instantiate FormatSectionOverride class'); + this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType; + this.defaultValue = defaultValue; + } + evaluate(ctx) { + if (ctx.formattedSection) { + const overrides = this.defaultValue.property.overrides; + if (overrides && overrides.hasOverride(ctx.formattedSection)) { + return overrides.getOverride(ctx.formattedSection); + } + } + if (ctx.feature && ctx.featureState) { + return this.defaultValue.evaluate(ctx.feature, ctx.featureState); + } + return this.defaultValue.property.specification.default; + } + eachChild(fn) { + if (!this.defaultValue.isConstant()) { + const expr = this.defaultValue.value; + fn(expr._styleExpression.expression); + } + } + // Cannot be statically evaluated, as the output depends on the evaluation context. + outputDefined() { + return false; + } + serialize() { + return null; + } +} +register('FormatSectionOverride', FormatSectionOverride, { omit: ['defaultValue'] }); + +class SymbolStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$2); + } + recalculate(parameters, availableImages) { + super.recalculate(parameters, availableImages); + if (this.layout.get('icon-rotation-alignment') === 'auto') { + if (this.layout.get('symbol-placement') !== 'point') { + this.layout._values['icon-rotation-alignment'] = 'map'; + } + else { + this.layout._values['icon-rotation-alignment'] = 'viewport'; + } + } + if (this.layout.get('text-rotation-alignment') === 'auto') { + if (this.layout.get('symbol-placement') !== 'point') { + this.layout._values['text-rotation-alignment'] = 'map'; + } + else { + this.layout._values['text-rotation-alignment'] = 'viewport'; + } + } + // If unspecified, `*-pitch-alignment` inherits `*-rotation-alignment` + if (this.layout.get('text-pitch-alignment') === 'auto') { + this.layout._values['text-pitch-alignment'] = this.layout.get('text-rotation-alignment') === 'map' ? 'map' : 'viewport'; + } + if (this.layout.get('icon-pitch-alignment') === 'auto') { + this.layout._values['icon-pitch-alignment'] = this.layout.get('icon-rotation-alignment'); + } + if (this.layout.get('symbol-placement') === 'point') { + const writingModes = this.layout.get('text-writing-mode'); + if (writingModes) { + // remove duplicates, preserving order + const deduped = []; + for (const m of writingModes) { + if (deduped.indexOf(m) < 0) + deduped.push(m); + } + this.layout._values['text-writing-mode'] = deduped; + } + else { + this.layout._values['text-writing-mode'] = ['horizontal']; + } + } + this._setPaintOverrides(); + } + getValueAndResolveTokens(name, feature, canonical, availableImages) { + const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages); + const unevaluated = this._unevaluatedLayout._values[name]; + if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) { + return resolveTokens(feature.properties, value); + } + return value; + } + createBucket(parameters) { + return new SymbolBucket(parameters); + } + queryRadius() { + return 0; + } + queryIntersectsFeature() { + throw new Error('Should take a different path in FeatureIndex'); + } + _setPaintOverrides() { + for (const overridable of properties$2.paint.overridableProperties) { + if (!SymbolStyleLayer.hasPaintOverride(this.layout, overridable)) { + continue; + } + const overriden = this.paint.get(overridable); + const override = new FormatSectionOverride(overriden); + const styleExpression = new StyleExpression(override, overriden.property.specification); + let expression = null; + if (overriden.value.kind === 'constant' || overriden.value.kind === 'source') { + expression = new ZoomConstantExpression('source', styleExpression); + } + else { + expression = new ZoomDependentExpression('composite', styleExpression, overriden.value.zoomStops); + } + this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property, expression, overriden.parameters); + } + } + _handleOverridablePaintPropertyUpdate(name, oldValue, newValue) { + if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) { + return false; + } + return SymbolStyleLayer.hasPaintOverride(this.layout, name); + } + static hasPaintOverride(layout, propertyName) { + const textField = layout.get('text-field'); + const property = properties$2.paint.properties[propertyName]; + let hasOverrides = false; + const checkSections = (sections) => { + for (const section of sections) { + if (property.overrides && property.overrides.hasOverride(section)) { + hasOverrides = true; + return; + } + } + }; + if (textField.value.kind === 'constant' && textField.value.value instanceof Formatted) { + checkSections(textField.value.value.sections); + } + else if (textField.value.kind === 'source') { + const checkExpression = (expression) => { + if (hasOverrides) + return; + if (expression instanceof Literal && typeOf(expression.value) === FormattedType) { + const formatted = expression.value; + checkSections(formatted.sections); + } + else if (expression instanceof FormatExpression) { + checkSections(expression.sections); + } + else { + expression.eachChild(checkExpression); + } + }; + const expr = textField.value; + if (expr._styleExpression) { + checkExpression(expr._styleExpression.expression); + } + } + return hasOverrides; + } +} +function getIconPadding(layout, feature, canonical, pixelRatio = 1) { + // Support text-padding in addition to icon-padding? Unclear how to apply asymmetric text-padding to the radius for collision circles. + const result = layout.get('icon-padding').evaluate(feature, {}, canonical); + const values = result && result.values; + return [ + values[0] * pixelRatio, + values[1] * pixelRatio, + values[2] * pixelRatio, + values[3] * pixelRatio, + ]; +} + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let paint$1; +const getPaint$1 = () => paint$1 = paint$1 || new Properties({ + "background-color": new DataConstantProperty(v8Spec["paint_background"]["background-color"]), + "background-pattern": new CrossFadedProperty(v8Spec["paint_background"]["background-pattern"]), + "background-opacity": new DataConstantProperty(v8Spec["paint_background"]["background-opacity"]), +}); +var properties$1 = ({ get paint() { return getPaint$1(); } }); + +class BackgroundStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties$1); + } +} + +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ +let paint; +const getPaint = () => paint = paint || new Properties({ + "raster-opacity": new DataConstantProperty(v8Spec["paint_raster"]["raster-opacity"]), + "raster-hue-rotate": new DataConstantProperty(v8Spec["paint_raster"]["raster-hue-rotate"]), + "raster-brightness-min": new DataConstantProperty(v8Spec["paint_raster"]["raster-brightness-min"]), + "raster-brightness-max": new DataConstantProperty(v8Spec["paint_raster"]["raster-brightness-max"]), + "raster-saturation": new DataConstantProperty(v8Spec["paint_raster"]["raster-saturation"]), + "raster-contrast": new DataConstantProperty(v8Spec["paint_raster"]["raster-contrast"]), + "raster-resampling": new DataConstantProperty(v8Spec["paint_raster"]["raster-resampling"]), + "raster-fade-duration": new DataConstantProperty(v8Spec["paint_raster"]["raster-fade-duration"]), +}); +var properties = ({ get paint() { return getPaint(); } }); + +class RasterStyleLayer extends StyleLayer { + constructor(layer) { + super(layer, properties); + } +} + +function validateCustomStyleLayer(layerObject) { + const errors = []; + const id = layerObject.id; + if (id === undefined) { + errors.push({ + message: `layers.${id}: missing required property "id"` + }); + } + if (layerObject.render === undefined) { + errors.push({ + message: `layers.${id}: missing required method "render"` + }); + } + if (layerObject.renderingMode && + layerObject.renderingMode !== '2d' && + layerObject.renderingMode !== '3d') { + errors.push({ + message: `layers.${id}: property "renderingMode" must be either "2d" or "3d"` + }); + } + return errors; +} +class CustomStyleLayer extends StyleLayer { + constructor(implementation) { + super(implementation, {}); + this.onAdd = (map) => { + if (this.implementation.onAdd) { + this.implementation.onAdd(map, map.painter.context.gl); + } + }; + this.onRemove = (map) => { + if (this.implementation.onRemove) { + this.implementation.onRemove(map, map.painter.context.gl); + } + }; + this.implementation = implementation; + } + is3D() { + return this.implementation.renderingMode === '3d'; + } + hasOffscreenPass() { + return this.implementation.prerender !== undefined; + } + recalculate() { } + updateTransitions() { } + hasTransition() { return false; } + serialize() { + throw new Error('Custom layers cannot be serialized'); + } +} + +function createStyleLayer(layer) { + if (layer.type === 'custom') { + return new CustomStyleLayer(layer); + } + switch (layer.type) { + case 'background': + return new BackgroundStyleLayer(layer); + case 'circle': + return new CircleStyleLayer(layer); + case 'fill': + return new FillStyleLayer(layer); + case 'fill-extrusion': + return new FillExtrusionStyleLayer(layer); + case 'heatmap': + return new HeatmapStyleLayer(layer); + case 'hillshade': + return new HillshadeStyleLayer(layer); + case 'line': + return new LineStyleLayer(layer); + case 'raster': + return new RasterStyleLayer(layer); + case 'symbol': + return new SymbolStyleLayer(layer); + } +} + +/** + * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests + * are ignored until the function was actually invoked. + */ +class ThrottledInvoker { + constructor(callback) { + this._callback = callback; + this._triggered = false; + if (typeof MessageChannel !== 'undefined') { + this._channel = new MessageChannel(); + this._channel.port2.onmessage = () => { + this._triggered = false; + this._callback(); + }; + } + } + trigger() { + if (!this._triggered) { + this._triggered = true; + if (this._channel) { + this._channel.port1.postMessage(true); + } + else { + setTimeout(() => { + this._triggered = false; + this._callback(); + }, 0); + } + } + } + remove() { + delete this._channel; + this._callback = () => { }; + } +} + +/** + * An implementation of the [Actor design pattern](http://en.wikipedia.org/wiki/Actor_model) + * that maintains the relationship between asynchronous tasks and the objects + * that spin them off - in this case, tasks like parsing parts of styles, + * owned by the styles + */ +class Actor { + /** + * @param target - The target + * @param parent - The parent + * @param mapId - A unique identifier for the Map instance using this Actor. + */ + constructor(target, parent, mapId) { + this.receive = (message) => { + const data = message.data; + const id = data.id; + if (!id) { + return; + } + if (data.targetMapId && this.mapId !== data.targetMapId) { + return; + } + if (data.type === '') { + // Remove the original request from the queue. This is only possible if it + // hasn't been kicked off yet. The id will remain in the queue, but because + // there is no associated task, it will be dropped once it's time to execute it. + delete this.tasks[id]; + const cancel = this.cancelCallbacks[id]; + delete this.cancelCallbacks[id]; + if (cancel) { + cancel(); + } + } + else { + if (isWorker() || data.mustQueue) { + // In workers, store the tasks that we need to process before actually processing them. This + // is necessary because we want to keep receiving messages, and in particular, + // messages. Some tasks may take a while in the worker thread, so before + // executing the next task in our queue, postMessage preempts this and + // messages can be processed. We're using a MessageChannel object to get throttle the + // process() flow to one at a time. + this.tasks[id] = data; + this.taskQueue.push(id); + this.invoker.trigger(); + } + else { + // In the main thread, process messages immediately so that other work does not slip in + // between getting partial data back from workers. + this.processTask(id, data); + } + } + }; + this.process = () => { + if (!this.taskQueue.length) { + return; + } + const id = this.taskQueue.shift(); + const task = this.tasks[id]; + delete this.tasks[id]; + // Schedule another process call if we know there's more to process _before_ invoking the + // current task. This is necessary so that processing continues even if the current task + // doesn't execute successfully. + if (this.taskQueue.length) { + this.invoker.trigger(); + } + if (!task) { + // If the task ID doesn't have associated task data anymore, it was canceled. + return; + } + this.processTask(id, task); + }; + this.target = target; + this.parent = parent; + this.mapId = mapId; + this.callbacks = {}; + this.tasks = {}; + this.taskQueue = []; + this.cancelCallbacks = {}; + this.invoker = new ThrottledInvoker(this.process); + this.target.addEventListener('message', this.receive, false); + this.globalScope = isWorker() ? target : window; + } + /** + * Sends a message from a main-thread map to a Worker or from a Worker back to + * a main-thread map instance. + * + * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource. + * @param targetMapId - A particular mapId to which to send this message. + */ + send(type, data, callback, targetMapId, mustQueue = false) { + // We're using a string ID instead of numbers because they are being used as object keys + // anyway, and thus stringified implicitly. We use random IDs because an actor may receive + // message from multiple other actors which could run in different execution context. A + // linearly increasing ID could produce collisions. + const id = Math.round((Math.random() * 1e18)).toString(36).substring(0, 10); + if (callback) { + this.callbacks[id] = callback; + } + const buffers = []; + const message = { + id, + type, + hasCallback: !!callback, + targetMapId, + mustQueue, + sourceMapId: this.mapId, + data: serialize(data, buffers) + }; + this.target.postMessage(message, { transfer: buffers }); + return { + cancel: () => { + if (callback) { + // Set the callback to null so that it never fires after the request is aborted. + delete this.callbacks[id]; + } + const cancelMessage = { + id, + type: '', + targetMapId, + sourceMapId: this.mapId + }; + this.target.postMessage(cancelMessage); + } + }; + } + processTask(id, task) { + if (task.type === '') { + // The done() function in the counterpart has been called, and we are now + // firing the callback in the originating actor, if there is one. + const callback = this.callbacks[id]; + delete this.callbacks[id]; + if (callback) { + // If we get a response, but don't have a callback, the request was canceled. + if (task.error) { + callback(deserialize(task.error)); + } + else { + callback(null, deserialize(task.data)); + } + } + } + else { + let completed = false; + const buffers = []; + const done = task.hasCallback ? (err, data) => { + completed = true; + delete this.cancelCallbacks[id]; + const responseMessage = { + id, + type: '', + sourceMapId: this.mapId, + error: err ? serialize(err) : null, + data: serialize(data, buffers) + }; + this.target.postMessage(responseMessage, { transfer: buffers }); + } : (_) => { + completed = true; + }; + let callback = null; + const params = deserialize(task.data); + if (this.parent[task.type]) { + // task.type == 'loadTile', 'removeTile', etc. + callback = this.parent[task.type](task.sourceMapId, params, done); + } + else if ('getWorkerSource' in this.parent) { + // task.type == sourcetype.method + const keys = task.type.split('.'); + const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], params.source); + callback = scope[keys[1]](params, done); + } + else { + // No function was found. + done(new Error(`Could not find function ${task.type}`)); + } + if (!completed && callback && callback.cancel) { + // Allows canceling the task as long as it hasn't been completed yet. + this.cancelCallbacks[id] = callback.cancel; + } + } + } + remove() { + this.invoker.remove(); + this.target.removeEventListener('message', this.receive, false); + } +} + +/* +* Approximate radius of the earth in meters. +* Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84 +* 6371008.8 is one published "average radius" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4 +*/ +const earthRadius = 6371008.8; +/** + * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees. + * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84). + * + * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the + * [GeoJSON specification](https://tools.ietf.org/html/rfc7946). + * + * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option + * can also accept an `Array` of two numbers and will perform an implicit conversion. + * This flexible type is documented as {@link LngLatLike}. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let ll = new maplibregl.LngLat(-123.9749, 40.7736); + * ll.lng; // = -123.9749 + * ``` + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/) + */ +class LngLat { + /** + * @param lng - Longitude, measured in degrees. + * @param lat - Latitude, measured in degrees. + */ + constructor(lng, lat) { + if (isNaN(lng) || isNaN(lat)) { + throw new Error(`Invalid LngLat object: (${lng}, ${lat})`); + } + this.lng = +lng; + this.lat = +lat; + if (this.lat > 90 || this.lat < -90) { + throw new Error('Invalid LngLat latitude value: must be between -90 and 90'); + } + } + /** + * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180). + * + * @returns The wrapped `LngLat` object. + * @example + * ```ts + * let ll = new maplibregl.LngLat(286.0251, 40.7736); + * let wrapped = ll.wrap(); + * wrapped.lng; // = -73.9749 + * ``` + */ + wrap() { + return new LngLat(wrap(this.lng, -180, 180), this.lat); + } + /** + * Returns the coordinates represented as an array of two numbers. + * + * @returns The coordinates represented as an array of longitude and latitude. + * @example + * ```ts + * let ll = new maplibregl.LngLat(-73.9749, 40.7736); + * ll.toArray(); // = [-73.9749, 40.7736] + * ``` + */ + toArray() { + return [this.lng, this.lat]; + } + /** + * Returns the coordinates represent as a string. + * + * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`. + * @example + * ```ts + * let ll = new maplibregl.LngLat(-73.9749, 40.7736); + * ll.toString(); // = "LngLat(-73.9749, 40.7736)" + * ``` + */ + toString() { + return `LngLat(${this.lng}, ${this.lat})`; + } + /** + * Returns the approximate distance between a pair of coordinates in meters + * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) + * + * @param lngLat - coordinates to compute the distance to + * @returns Distance in meters between the two coordinates. + * @example + * ```ts + * let new_york = new maplibregl.LngLat(-74.0060, 40.7128); + * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522); + * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km + * ``` + */ + distanceTo(lngLat) { + const rad = Math.PI / 180; + const lat1 = this.lat * rad; + const lat2 = lngLat.lat * rad; + const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad); + const maxMeters = earthRadius * Math.acos(Math.min(a, 1)); + return maxMeters; + } + /** + * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties + * to a `LngLat` object. + * + * If a `LngLat` object is passed in, the function returns it unchanged. + * + * @param input - An array of two numbers or object to convert, or a `LngLat` object to return. + * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object. + * @example + * ```ts + * let arr = [-73.9749, 40.7736]; + * let ll = maplibregl.LngLat.convert(arr); + * ll; // = LngLat {lng: -73.9749, lat: 40.7736} + * ``` + */ + static convert(input) { + if (input instanceof LngLat) { + return input; + } + if (Array.isArray(input) && (input.length === 2 || input.length === 3)) { + return new LngLat(Number(input[0]), Number(input[1])); + } + if (!Array.isArray(input) && typeof input === 'object' && input !== null) { + return new LngLat( + // flow can't refine this to have one of lng or lat, so we have to cast to any + Number('lng' in input ? input.lng : input.lon), Number(input.lat)); + } + throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]'); + } +} + +/* + * The average circumference of the world in meters. + */ +const earthCircumfrence = 2 * Math.PI * earthRadius; // meters +/* + * The circumference at a line of latitude in meters. + */ +function circumferenceAtLatitude(latitude) { + return earthCircumfrence * Math.cos(latitude * Math.PI / 180); +} +function mercatorXfromLng(lng) { + return (180 + lng) / 360; +} +function mercatorYfromLat(lat) { + return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360; +} +function mercatorZfromAltitude(altitude, lat) { + return altitude / circumferenceAtLatitude(lat); +} +function lngFromMercatorX(x) { + return x * 360 - 180; +} +function latFromMercatorY(y) { + const y2 = 180 - y * 360; + return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90; +} +function altitudeFromMercatorZ(z, y) { + return z * circumferenceAtLatitude(latFromMercatorY(y)); +} +/** + * Determine the Mercator scale factor for a given latitude, see + * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor + * + * At the equator the scale factor will be 1, which increases at higher latitudes. + * + * @param lat - Latitude + * @returns scale factor + */ +function mercatorScale(lat) { + return 1 / Math.cos(lat * Math.PI / 180); +} +/** + * A `MercatorCoordinate` object represents a projected three dimensional position. + * + * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units: + * - the size of 1 unit is the width of the projected world instead of the "mercator meter" + * - the origin of the coordinate space is at the north-west corner instead of the middle + * + * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and + * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with + * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think + * of the coordinate space as the `0/0/0` tile with an extent of `1`. + * + * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let nullIsland = new maplibregl.MercatorCoordinate(0.5, 0.5, 0); + * ``` + * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/) + */ +class MercatorCoordinate { + /** + * @param x - The x component of the position. + * @param y - The y component of the position. + * @param z - The z component of the position. + */ + constructor(x, y, z = 0) { + this.x = +x; + this.y = +y; + this.z = +z; + } + /** + * Project a `LngLat` to a `MercatorCoordinate`. + * + * @param lngLatLike - The location to project. + * @param altitude - The altitude in meters of the position. + * @returns The projected mercator coordinate. + * @example + * ```ts + * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0); + * coord; // MercatorCoordinate(0.5, 0.5, 0) + * ``` + */ + static fromLngLat(lngLatLike, altitude = 0) { + const lngLat = LngLat.convert(lngLatLike); + return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat)); + } + /** + * Returns the `LngLat` for the coordinate. + * + * @returns The `LngLat` object. + * @example + * ```ts + * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0); + * let lngLat = coord.toLngLat(); // LngLat(0, 0) + * ``` + */ + toLngLat() { + return new LngLat(lngFromMercatorX(this.x), latFromMercatorY(this.y)); + } + /** + * Returns the altitude in meters of the coordinate. + * + * @returns The altitude in meters. + * @example + * ```ts + * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02); + * coord.toAltitude(); // 6914.281956295339 + * ``` + */ + toAltitude() { + return altitudeFromMercatorZ(this.z, this.y); + } + /** + * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude. + * + * For coordinates in real world units using meters, this naturally provides the scale + * to transform into `MercatorCoordinate`s. + * + * @returns Distance of 1 meter in `MercatorCoordinate` units. + */ + meterInMercatorCoordinateUnits() { + // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude + return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y)); + } +} + +/** + * getURL + * + * @param {String} baseUrl Base url of the WMS server + * @param {String} layer Layer name + * @param {Number} x Tile coordinate x + * @param {Number} y Tile coordinate y + * @param {Number} z Tile zoom + * @param {Object} [options] + * @param {String} [options.format='image/png'] + * @param {String} [options.service='WMS'] + * @param {String} [options.version='1.1.1'] + * @param {String} [options.request='GetMap'] + * @param {String} [options.srs='EPSG:3857'] + * @param {Number} [options.width='256'] + * @param {Number} [options.height='256'] + * @returns {String} url + * @example + * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015'; + * var layer = 'Natural2015'; + * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19); + */ +function getURL(baseUrl, layer, x, y, z, options) { + options = options || {}; + + var url = baseUrl + '?' + [ + 'bbox=' + getTileBBox(x, y, z), + 'format=' + (options.format || 'image/png'), + 'service=' + (options.service || 'WMS'), + 'version=' + (options.version || '1.1.1'), + 'request=' + (options.request || 'GetMap'), + 'srs=' + (options.srs || 'EPSG:3857'), + 'width=' + (options.width || 256), + 'height=' + (options.height || 256), + 'layers=' + layer + ].join('&'); + + return url; +} + + +/** + * getTileBBox + * + * @param {Number} x Tile coordinate x + * @param {Number} y Tile coordinate y + * @param {Number} z Tile zoom + * @returns {String} String of the bounding box + */ +function getTileBBox(x, y, z) { + // for Google/OSM tile scheme we need to alter the y + y = (Math.pow(2, z) - y - 1); + + var min = getMercCoords(x * 256, y * 256, z), + max = getMercCoords((x + 1) * 256, (y + 1) * 256, z); + + return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1]; +} + + +/** + * getMercCoords + * + * @param {Number} x Pixel coordinate x + * @param {Number} y Pixel coordinate y + * @param {Number} z Tile zoom + * @returns {Array} [x, y] + */ +function getMercCoords(x, y, z) { + var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z), + merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0), + merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0); + + return [merc_x, merc_y]; +} + +/** + * A canonical way to define a tile ID + */ +class CanonicalTileID { + constructor(z, x, y) { + if (z < 0 || z > 25 || y < 0 || y >= Math.pow(2, z) || x < 0 || x >= Math.pow(2, z)) { + throw new Error(`x=${x}, y=${y}, z=${z} outside of bounds. 0<=x<${Math.pow(2, z)}, 0<=y<${Math.pow(2, z)} 0<=z<=25 `); + } + this.z = z; + this.x = x; + this.y = y; + this.key = calculateKey(0, z, z, x, y); + } + equals(id) { + return this.z === id.z && this.x === id.x && this.y === id.y; + } + // given a list of urls, choose a url template and return a tile URL + url(urls, pixelRatio, scheme) { + const bbox = getTileBBox(this.x, this.y, this.z); + const quadkey = getQuadkey(this.z, this.x, this.y); + return urls[(this.x + this.y) % urls.length] + .replace(/{prefix}/g, (this.x % 16).toString(16) + (this.y % 16).toString(16)) + .replace(/{z}/g, String(this.z)) + .replace(/{x}/g, String(this.x)) + .replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y)) + .replace(/{ratio}/g, pixelRatio > 1 ? '@2x' : '') + .replace(/{quadkey}/g, quadkey) + .replace(/{bbox-epsg-3857}/g, bbox); + } + isChildOf(parent) { + const dz = this.z - parent.z; + return dz > 0 && parent.x === (this.x >> dz) && parent.y === (this.y >> dz); + } + getTilePoint(coord) { + const tilesAtZoom = Math.pow(2, this.z); + return new Point$2((coord.x * tilesAtZoom - this.x) * EXTENT, (coord.y * tilesAtZoom - this.y) * EXTENT); + } + toString() { + return `${this.z}/${this.x}/${this.y}`; + } +} +/** + * @internal + * An unwrapped tile identifier + */ +class UnwrappedTileID { + constructor(wrap, canonical) { + this.wrap = wrap; + this.canonical = canonical; + this.key = calculateKey(wrap, canonical.z, canonical.z, canonical.x, canonical.y); + } +} +/** + * An overscaled tile identifier + */ +class OverscaledTileID { + constructor(overscaledZ, wrap, z, x, y) { + if (overscaledZ < z) + throw new Error(`overscaledZ should be >= z; overscaledZ = ${overscaledZ}; z = ${z}`); + this.overscaledZ = overscaledZ; + this.wrap = wrap; + this.canonical = new CanonicalTileID(z, +x, +y); + this.key = calculateKey(wrap, overscaledZ, z, x, y); + } + clone() { + return new OverscaledTileID(this.overscaledZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y); + } + equals(id) { + return this.overscaledZ === id.overscaledZ && this.wrap === id.wrap && this.canonical.equals(id.canonical); + } + scaledTo(targetZ) { + if (targetZ > this.overscaledZ) + throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`); + const zDifference = this.canonical.z - targetZ; + if (targetZ > this.canonical.z) { + return new OverscaledTileID(targetZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y); + } + else { + return new OverscaledTileID(targetZ, this.wrap, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference); + } + } + /* + * calculateScaledKey is an optimization: + * when withWrap == true, implements the same as this.scaledTo(z).key, + * when withWrap == false, implements the same as this.scaledTo(z).wrapped().key. + */ + calculateScaledKey(targetZ, withWrap) { + if (targetZ > this.overscaledZ) + throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`); + const zDifference = this.canonical.z - targetZ; + if (targetZ > this.canonical.z) { + return calculateKey(this.wrap * +withWrap, targetZ, this.canonical.z, this.canonical.x, this.canonical.y); + } + else { + return calculateKey(this.wrap * +withWrap, targetZ, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference); + } + } + isChildOf(parent) { + if (parent.wrap !== this.wrap) { + // We can't be a child if we're in a different world copy + return false; + } + const zDifference = this.canonical.z - parent.canonical.z; + // We're first testing for z == 0, to avoid a 32 bit shift, which is undefined. + return parent.overscaledZ === 0 || (parent.overscaledZ < this.overscaledZ && + parent.canonical.x === (this.canonical.x >> zDifference) && + parent.canonical.y === (this.canonical.y >> zDifference)); + } + children(sourceMaxZoom) { + if (this.overscaledZ >= sourceMaxZoom) { + // return a single tile coord representing a an overscaled tile + return [new OverscaledTileID(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)]; + } + const z = this.canonical.z + 1; + const x = this.canonical.x * 2; + const y = this.canonical.y * 2; + return [ + new OverscaledTileID(z, this.wrap, z, x, y), + new OverscaledTileID(z, this.wrap, z, x + 1, y), + new OverscaledTileID(z, this.wrap, z, x, y + 1), + new OverscaledTileID(z, this.wrap, z, x + 1, y + 1) + ]; + } + isLessThan(rhs) { + if (this.wrap < rhs.wrap) + return true; + if (this.wrap > rhs.wrap) + return false; + if (this.overscaledZ < rhs.overscaledZ) + return true; + if (this.overscaledZ > rhs.overscaledZ) + return false; + if (this.canonical.x < rhs.canonical.x) + return true; + if (this.canonical.x > rhs.canonical.x) + return false; + if (this.canonical.y < rhs.canonical.y) + return true; + return false; + } + wrapped() { + return new OverscaledTileID(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y); + } + unwrapTo(wrap) { + return new OverscaledTileID(this.overscaledZ, wrap, this.canonical.z, this.canonical.x, this.canonical.y); + } + overscaleFactor() { + return Math.pow(2, this.overscaledZ - this.canonical.z); + } + toUnwrapped() { + return new UnwrappedTileID(this.wrap, this.canonical); + } + toString() { + return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`; + } + getTilePoint(coord) { + return this.canonical.getTilePoint(new MercatorCoordinate(coord.x - this.wrap, coord.y)); + } +} +function calculateKey(wrap, overscaledZ, z, x, y) { + wrap *= 2; + if (wrap < 0) + wrap = wrap * -1 - 1; + const dim = 1 << z; + return (dim * dim * wrap + dim * y + x).toString(36) + z.toString(36) + overscaledZ.toString(36); +} +function getQuadkey(z, x, y) { + let quadkey = '', mask; + for (let i = z; i > 0; i--) { + mask = 1 << (i - 1); + quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0)); + } + return quadkey; +} +register('CanonicalTileID', CanonicalTileID); +register('OverscaledTileID', OverscaledTileID, { omit: ['posMatrix'] }); + +class DEMData { + // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride + // and dim is calculated as stride - 2. + constructor(uid, data, encoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) { + this.uid = uid; + if (data.height !== data.width) + throw new RangeError('DEM tiles must be square'); + if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) { + warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`); + return; + } + this.stride = data.height; + const dim = this.dim = data.height - 2; + this.data = new Uint32Array(data.data.buffer); + switch (encoding) { + case 'terrarium': + // unpacking formula for mapzen terrarium: + // https://aws.amazon.com/public-datasets/terrain/ + this.redFactor = 256.0; + this.greenFactor = 1.0; + this.blueFactor = 1.0 / 256.0; + this.baseShift = 32768.0; + break; + case 'custom': + this.redFactor = redFactor; + this.greenFactor = greenFactor; + this.blueFactor = blueFactor; + this.baseShift = baseShift; + break; + case 'mapbox': + default: + // unpacking formula for mapbox.terrain-rgb: + // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb + this.redFactor = 6553.6; + this.greenFactor = 25.6; + this.blueFactor = 0.1; + this.baseShift = 10000.0; + break; + } + // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image + // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring + // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder + for (let x = 0; x < dim; x++) { + // left vertical border + this.data[this._idx(-1, x)] = this.data[this._idx(0, x)]; + // right vertical border + this.data[this._idx(dim, x)] = this.data[this._idx(dim - 1, x)]; + // left horizontal border + this.data[this._idx(x, -1)] = this.data[this._idx(x, 0)]; + // right horizontal border + this.data[this._idx(x, dim)] = this.data[this._idx(x, dim - 1)]; + } + // corners + this.data[this._idx(-1, -1)] = this.data[this._idx(0, 0)]; + this.data[this._idx(dim, -1)] = this.data[this._idx(dim - 1, 0)]; + this.data[this._idx(-1, dim)] = this.data[this._idx(0, dim - 1)]; + this.data[this._idx(dim, dim)] = this.data[this._idx(dim - 1, dim - 1)]; + // calculate min/max values + this.min = Number.MAX_SAFE_INTEGER; + this.max = Number.MIN_SAFE_INTEGER; + for (let x = 0; x < dim; x++) { + for (let y = 0; y < dim; y++) { + const ele = this.get(x, y); + if (ele > this.max) + this.max = ele; + if (ele < this.min) + this.min = ele; + } + } + } + get(x, y) { + const pixels = new Uint8Array(this.data.buffer); + const index = this._idx(x, y) * 4; + return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]); + } + getUnpackVector() { + return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift]; + } + _idx(x, y) { + if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) + throw new RangeError('out of range source coordinates for DEM data'); + return (y + 1) * this.stride + (x + 1); + } + unpack(r, g, b) { + return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift); + } + getPixels() { + return new RGBAImage({ width: this.stride, height: this.stride }, new Uint8Array(this.data.buffer)); + } + backfillBorder(borderTile, dx, dy) { + if (this.dim !== borderTile.dim) + throw new Error('dem dimension mismatch'); + let xMin = dx * this.dim, xMax = dx * this.dim + this.dim, yMin = dy * this.dim, yMax = dy * this.dim + this.dim; + switch (dx) { + case -1: + xMin = xMax - 1; + break; + case 1: + xMax = xMin + 1; + break; + } + switch (dy) { + case -1: + yMin = yMax - 1; + break; + case 1: + yMax = yMin + 1; + break; + } + const ox = -dx * this.dim; + const oy = -dy * this.dim; + for (let y = yMin; y < yMax; y++) { + for (let x = xMin; x < xMax; x++) { + this.data[this._idx(x, y)] = borderTile.data[this._idx(x + ox, y + oy)]; + } + } + } +} +register('DEMData', DEMData); + +class DictionaryCoder { + constructor(strings) { + this._stringToNumber = {}; + this._numberToString = []; + for (let i = 0; i < strings.length; i++) { + const string = strings[i]; + this._stringToNumber[string] = i; + this._numberToString[i] = string; + } + } + encode(string) { + return this._stringToNumber[string]; + } + decode(n) { + if (n >= this._numberToString.length) + throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`); + return this._numberToString[n]; + } +} + +/** + * A geojson feature + */ +class GeoJSONFeature { + constructor(vectorTileFeature, z, x, y, id) { + this.type = 'Feature'; + this._vectorTileFeature = vectorTileFeature; + vectorTileFeature._z = z; + vectorTileFeature._x = x; + vectorTileFeature._y = y; + this.properties = vectorTileFeature.properties; + this.id = id; + } + get geometry() { + if (this._geometry === undefined) { + this._geometry = this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x, this._vectorTileFeature._y, this._vectorTileFeature._z).geometry; + } + return this._geometry; + } + set geometry(g) { + this._geometry = g; + } + toJSON() { + const json = { + geometry: this.geometry + }; + for (const i in this) { + if (i === '_geometry' || i === '_vectorTileFeature') + continue; + json[i] = (this)[i]; + } + return json; + } +} + +/** + * @internal + * An in memory index class to allow fast interaction with features + */ +class FeatureIndex { + constructor(tileID, promoteId) { + this.tileID = tileID; + this.x = tileID.canonical.x; + this.y = tileID.canonical.y; + this.z = tileID.canonical.z; + this.grid = new TransferableGridIndex(EXTENT, 16, 0); + this.grid3D = new TransferableGridIndex(EXTENT, 16, 0); + this.featureIndexArray = new FeatureIndexArray(); + this.promoteId = promoteId; + } + insert(feature, geometry, featureIndex, sourceLayerIndex, bucketIndex, is3D) { + const key = this.featureIndexArray.length; + this.featureIndexArray.emplaceBack(featureIndex, sourceLayerIndex, bucketIndex); + const grid = is3D ? this.grid3D : this.grid; + for (let r = 0; r < geometry.length; r++) { + const ring = geometry[r]; + const bbox = [Infinity, Infinity, -Infinity, -Infinity]; + for (let i = 0; i < ring.length; i++) { + const p = ring[i]; + bbox[0] = Math.min(bbox[0], p.x); + bbox[1] = Math.min(bbox[1], p.y); + bbox[2] = Math.max(bbox[2], p.x); + bbox[3] = Math.max(bbox[3], p.y); + } + if (bbox[0] < EXTENT && + bbox[1] < EXTENT && + bbox[2] >= 0 && + bbox[3] >= 0) { + grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]); + } + } + } + loadVTLayers() { + if (!this.vtLayers) { + this.vtLayers = new vectorTile.VectorTile(new Protobuf(this.rawTileData)).layers; + this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']); + } + return this.vtLayers; + } + // Finds non-symbol features in this tile at a particular position. + query(args, styleLayers, serializedLayers, sourceFeatureState) { + this.loadVTLayers(); + const params = args.params || {}, pixelsToTileUnits = EXTENT / args.tileSize / args.scale, filter = createFilter(params.filter); + const queryGeometry = args.queryGeometry; + const queryPadding = args.queryPadding * pixelsToTileUnits; + const bounds = getBounds(queryGeometry); + const matching = this.grid.query(bounds.minX - queryPadding, bounds.minY - queryPadding, bounds.maxX + queryPadding, bounds.maxY + queryPadding); + const cameraBounds = getBounds(args.cameraQueryGeometry); + const matching3D = this.grid3D.query(cameraBounds.minX - queryPadding, cameraBounds.minY - queryPadding, cameraBounds.maxX + queryPadding, cameraBounds.maxY + queryPadding, (bx1, by1, bx2, by2) => { + return polygonIntersectsBox(args.cameraQueryGeometry, bx1 - queryPadding, by1 - queryPadding, bx2 + queryPadding, by2 + queryPadding); + }); + for (const key of matching3D) { + matching.push(key); + } + matching.sort(topDownFeatureComparator); + const result = {}; + let previousIndex; + for (let k = 0; k < matching.length; k++) { + const index = matching[k]; + // don't check the same feature more than once + if (index === previousIndex) + continue; + previousIndex = index; + const match = this.featureIndexArray.get(index); + let featureGeometry = null; + this.loadMatchingFeature(result, match.bucketIndex, match.sourceLayerIndex, match.featureIndex, filter, params.layers, params.availableImages, styleLayers, serializedLayers, sourceFeatureState, (feature, styleLayer, featureState) => { + if (!featureGeometry) { + featureGeometry = loadGeometry(feature); + } + return styleLayer.queryIntersectsFeature(queryGeometry, feature, featureState, featureGeometry, this.z, args.transform, pixelsToTileUnits, args.pixelPosMatrix); + }); + } + return result; + } + loadMatchingFeature(result, bucketIndex, sourceLayerIndex, featureIndex, filter, filterLayerIDs, availableImages, styleLayers, serializedLayers, sourceFeatureState, intersectionTest) { + const layerIDs = this.bucketLayerIDs[bucketIndex]; + if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs)) + return; + const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex); + const sourceLayer = this.vtLayers[sourceLayerName]; + const feature = sourceLayer.feature(featureIndex); + if (filter.needGeometry) { + const evaluationFeature = toEvaluationFeature(feature, true); + if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) { + return; + } + } + else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) { + return; + } + const id = this.getId(feature, sourceLayerName); + for (let l = 0; l < layerIDs.length; l++) { + const layerID = layerIDs[l]; + if (filterLayerIDs && filterLayerIDs.indexOf(layerID) < 0) { + continue; + } + const styleLayer = styleLayers[layerID]; + if (!styleLayer) + continue; + let featureState = {}; + if (id && sourceFeatureState) { + // `feature-state` expression evaluation requires feature state to be available + featureState = sourceFeatureState.getState(styleLayer.sourceLayer || '_geojsonTileLayer', id); + } + const serializedLayer = extend({}, serializedLayers[layerID]); + serializedLayer.paint = evaluateProperties(serializedLayer.paint, styleLayer.paint, feature, featureState, availableImages); + serializedLayer.layout = evaluateProperties(serializedLayer.layout, styleLayer.layout, feature, featureState, availableImages); + const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer, featureState); + if (!intersectionZ) { + // Only applied for non-symbol features + continue; + } + const geojsonFeature = new GeoJSONFeature(feature, this.z, this.x, this.y, id); + geojsonFeature.layer = serializedLayer; + let layerResult = result[layerID]; + if (layerResult === undefined) { + layerResult = result[layerID] = []; + } + layerResult.push({ featureIndex, feature: geojsonFeature, intersectionZ }); + } + } + // Given a set of symbol indexes that have already been looked up, + // return a matching set of GeoJSONFeatures + lookupSymbolFeatures(symbolFeatureIndexes, serializedLayers, bucketIndex, sourceLayerIndex, filterSpec, filterLayerIDs, availableImages, styleLayers) { + const result = {}; + this.loadVTLayers(); + const filter = createFilter(filterSpec); + for (const symbolFeatureIndex of symbolFeatureIndexes) { + this.loadMatchingFeature(result, bucketIndex, sourceLayerIndex, symbolFeatureIndex, filter, filterLayerIDs, availableImages, styleLayers, serializedLayers); + } + return result; + } + hasLayer(id) { + for (const layerIDs of this.bucketLayerIDs) { + for (const layerID of layerIDs) { + if (id === layerID) + return true; + } + } + return false; + } + getId(feature, sourceLayerId) { + let id = feature.id; + if (this.promoteId) { + const propName = typeof this.promoteId === 'string' ? this.promoteId : this.promoteId[sourceLayerId]; + id = feature.properties[propName]; + if (typeof id === 'boolean') + id = Number(id); + } + return id; + } +} +register('FeatureIndex', FeatureIndex, { omit: ['rawTileData', 'sourceLayerCoder'] }); +function evaluateProperties(serializedProperties, styleLayerProperties, feature, featureState, availableImages) { + return mapObject(serializedProperties, (property, key) => { + const prop = styleLayerProperties instanceof PossiblyEvaluated ? styleLayerProperties.get(key) : null; + return prop && prop.evaluate ? prop.evaluate(feature, featureState, availableImages) : prop; + }); +} +function getBounds(geometry) { + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + for (const p of geometry) { + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + return { minX, minY, maxX, maxY }; +} +function topDownFeatureComparator(a, b) { + return b - a; +} + +/** + * Returns the part of a multiline that intersects with the provided rectangular box. + * + * @param lines - the lines to check + * @param x1 - the left edge of the box + * @param y1 - the top edge of the box + * @param x2 - the right edge of the box + * @param y2 - the bottom edge of the box + * @returns lines + */ +function clipLine(lines, x1, y1, x2, y2) { + const clippedLines = []; + for (let l = 0; l < lines.length; l++) { + const line = lines[l]; + let clippedLine; + for (let i = 0; i < line.length - 1; i++) { + let p0 = line[i]; + let p1 = line[i + 1]; + if (p0.x < x1 && p1.x < x1) { + continue; + } + else if (p0.x < x1) { + p0 = new Point$2(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round(); + } + else if (p1.x < x1) { + p1 = new Point$2(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round(); + } + if (p0.y < y1 && p1.y < y1) { + continue; + } + else if (p0.y < y1) { + p0 = new Point$2(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round(); + } + else if (p1.y < y1) { + p1 = new Point$2(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round(); + } + if (p0.x >= x2 && p1.x >= x2) { + continue; + } + else if (p0.x >= x2) { + p0 = new Point$2(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round(); + } + else if (p1.x >= x2) { + p1 = new Point$2(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round(); + } + if (p0.y >= y2 && p1.y >= y2) { + continue; + } + else if (p0.y >= y2) { + p0 = new Point$2(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round(); + } + else if (p1.y >= y2) { + p1 = new Point$2(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round(); + } + if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) { + clippedLine = [p0]; + clippedLines.push(clippedLine); + } + clippedLine.push(p1); + } + } + return clippedLines; +} + +class Anchor extends Point$2 { + constructor(x, y, angle, segment) { + super(x, y); + this.angle = angle; + if (segment !== undefined) { + this.segment = segment; + } + } + clone() { + return new Anchor(this.x, this.y, this.angle, this.segment); + } +} +register('Anchor', Anchor); + +/** + * Labels placed around really sharp angles aren't readable. Check if any + * part of the potential label has a combined angle that is too big. + * + * @param line - The line to check + * @param anchor - The point on the line around which the label is anchored. + * @param labelLength - The length of the label in geometry units. + * @param windowSize - The check fails if the combined angles within a part of the line that is `windowSize` long is too big. + * @param maxAngle - The maximum combined angle that any window along the label is allowed to have. + * + * @returns whether the label should be placed + */ +function checkMaxAngle(line, anchor, labelLength, windowSize, maxAngle) { + // horizontal labels and labels with length 0 always pass + if (anchor.segment === undefined || labelLength === 0) + return true; + let p = anchor; + let index = anchor.segment + 1; + let anchorDistance = 0; + // move backwards along the line to the first segment the label appears on + while (anchorDistance > -labelLength / 2) { + index--; + // there isn't enough room for the label after the beginning of the line + if (index < 0) + return false; + anchorDistance -= line[index].dist(p); + p = line[index]; + } + anchorDistance += line[index].dist(line[index + 1]); + index++; + // store recent corners and their total angle difference + const recentCorners = []; + let recentAngleDelta = 0; + // move forwards by the length of the label and check angles along the way + while (anchorDistance < labelLength / 2) { + const prev = line[index - 1]; + const current = line[index]; + const next = line[index + 1]; + // there isn't enough room for the label before the end of the line + if (!next) + return false; + let angleDelta = prev.angleTo(current) - current.angleTo(next); + // restrict angle to -pi..pi range + angleDelta = Math.abs(((angleDelta + 3 * Math.PI) % (Math.PI * 2)) - Math.PI); + recentCorners.push({ + distance: anchorDistance, + angleDelta + }); + recentAngleDelta += angleDelta; + // remove corners that are far enough away from the list of recent anchors + while (anchorDistance - recentCorners[0].distance > windowSize) { + recentAngleDelta -= recentCorners.shift().angleDelta; + } + // the sum of angles within the window area exceeds the maximum allowed value. check fails. + if (recentAngleDelta > maxAngle) + return false; + index++; + anchorDistance += current.dist(next); + } + // no part of the line had an angle greater than the maximum allowed. check passes. + return true; +} + +function getLineLength(line) { + let lineLength = 0; + for (let k = 0; k < line.length - 1; k++) { + lineLength += line[k].dist(line[k + 1]); + } + return lineLength; +} +function getAngleWindowSize(shapedText, glyphSize, boxScale) { + return shapedText ? + 3 / 5 * glyphSize * boxScale : + 0; +} +function getShapedLabelLength(shapedText, shapedIcon) { + return Math.max(shapedText ? shapedText.right - shapedText.left : 0, shapedIcon ? shapedIcon.right - shapedIcon.left : 0); +} +function getCenterAnchor(line, maxAngle, shapedText, shapedIcon, glyphSize, boxScale) { + const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale); + const labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale; + let prevDistance = 0; + const centerDistance = getLineLength(line) / 2; + for (let i = 0; i < line.length - 1; i++) { + const a = line[i], b = line[i + 1]; + const segmentDistance = a.dist(b); + if (prevDistance + segmentDistance > centerDistance) { + // The center is on this segment + const t = (centerDistance - prevDistance) / segmentDistance, x = interpolate.number(a.x, b.x, t), y = interpolate.number(a.y, b.y, t); + const anchor = new Anchor(x, y, b.angleTo(a), i); + anchor._round(); + if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) { + return anchor; + } + else { + return; + } + } + prevDistance += segmentDistance; + } +} +function getAnchors(line, spacing, maxAngle, shapedText, shapedIcon, glyphSize, boxScale, overscaling, tileExtent) { + // Resample a line to get anchor points for labels and check that each + // potential label passes text-max-angle check and has enough froom to fit + // on the line. + const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale); + const shapedLabelLength = getShapedLabelLength(shapedText, shapedIcon); + const labelLength = shapedLabelLength * boxScale; + // Is the line continued from outside the tile boundary? + const isLineContinued = line[0].x === 0 || line[0].x === tileExtent || line[0].y === 0 || line[0].y === tileExtent; + // Is the label long, relative to the spacing? + // If so, adjust the spacing so there is always a minimum space of `spacing / 4` between label edges. + if (spacing - labelLength < spacing / 4) { + spacing = labelLength + spacing / 4; + } + // Offset the first anchor by: + // Either half the label length plus a fixed extra offset if the line is not continued + // Or half the spacing if the line is continued. + // For non-continued lines, add a bit of fixed extra offset to avoid collisions at T intersections. + const fixedExtraOffset = glyphSize * 2; + const offset = !isLineContinued ? + ((shapedLabelLength / 2 + fixedExtraOffset) * boxScale * overscaling) % spacing : + (spacing / 2 * overscaling) % spacing; + return resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, false, tileExtent); +} +function resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, placeAtMiddle, tileExtent) { + const halfLabelLength = labelLength / 2; + const lineLength = getLineLength(line); + let distance = 0, markedDistance = offset - spacing; + let anchors = []; + for (let i = 0; i < line.length - 1; i++) { + const a = line[i], b = line[i + 1]; + const segmentDist = a.dist(b), angle = b.angleTo(a); + while (markedDistance + spacing < distance + segmentDist) { + markedDistance += spacing; + const t = (markedDistance - distance) / segmentDist, x = interpolate.number(a.x, b.x, t), y = interpolate.number(a.y, b.y, t); + // Check that the point is within the tile boundaries and that + // the label would fit before the beginning and end of the line + // if placed at this point. + if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent && + markedDistance - halfLabelLength >= 0 && + markedDistance + halfLabelLength <= lineLength) { + const anchor = new Anchor(x, y, angle, i); + anchor._round(); + if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) { + anchors.push(anchor); + } + } + } + distance += segmentDist; + } + if (!placeAtMiddle && !anchors.length && !isLineContinued) { + // The first attempt at finding anchors at which labels can be placed failed. + // Try again, but this time just try placing one anchor at the middle of the line. + // This has the most effect for short lines in overscaled tiles, since the + // initial offset used in overscaled tiles is calculated to align labels with positions in + // parent tiles instead of placing the label as close to the beginning as possible. + anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, true, tileExtent); + } + return anchors; +} + +// If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual +// pixels. The quad needs to be padded to account for this, otherwise they'll look slightly clipped +// on one edge in some cases. +const border = IMAGE_PADDING; +/** + * Create the quads used for rendering an icon. + */ +function getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit) { + const quads = []; + const image = shapedIcon.image; + const pixelRatio = image.pixelRatio; + const imageWidth = image.paddedRect.w - 2 * border; + const imageHeight = image.paddedRect.h - 2 * border; + const iconWidth = shapedIcon.right - shapedIcon.left; + const iconHeight = shapedIcon.bottom - shapedIcon.top; + const stretchX = image.stretchX || [[0, imageWidth]]; + const stretchY = image.stretchY || [[0, imageHeight]]; + const reduceRanges = (sum, range) => sum + range[1] - range[0]; + const stretchWidth = stretchX.reduce(reduceRanges, 0); + const stretchHeight = stretchY.reduce(reduceRanges, 0); + const fixedWidth = imageWidth - stretchWidth; + const fixedHeight = imageHeight - stretchHeight; + let stretchOffsetX = 0; + let stretchContentWidth = stretchWidth; + let stretchOffsetY = 0; + let stretchContentHeight = stretchHeight; + let fixedOffsetX = 0; + let fixedContentWidth = fixedWidth; + let fixedOffsetY = 0; + let fixedContentHeight = fixedHeight; + if (image.content && hasIconTextFit) { + const content = image.content; + stretchOffsetX = sumWithinRange(stretchX, 0, content[0]); + stretchOffsetY = sumWithinRange(stretchY, 0, content[1]); + stretchContentWidth = sumWithinRange(stretchX, content[0], content[2]); + stretchContentHeight = sumWithinRange(stretchY, content[1], content[3]); + fixedOffsetX = content[0] - stretchOffsetX; + fixedOffsetY = content[1] - stretchOffsetY; + fixedContentWidth = content[2] - content[0] - stretchContentWidth; + fixedContentHeight = content[3] - content[1] - stretchContentHeight; + } + const makeBox = (left, top, right, bottom) => { + const leftEm = getEmOffset(left.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left); + const leftPx = getPxOffset(left.fixed - fixedOffsetX, fixedContentWidth, left.stretch, stretchWidth); + const topEm = getEmOffset(top.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top); + const topPx = getPxOffset(top.fixed - fixedOffsetY, fixedContentHeight, top.stretch, stretchHeight); + const rightEm = getEmOffset(right.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left); + const rightPx = getPxOffset(right.fixed - fixedOffsetX, fixedContentWidth, right.stretch, stretchWidth); + const bottomEm = getEmOffset(bottom.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top); + const bottomPx = getPxOffset(bottom.fixed - fixedOffsetY, fixedContentHeight, bottom.stretch, stretchHeight); + const tl = new Point$2(leftEm, topEm); + const tr = new Point$2(rightEm, topEm); + const br = new Point$2(rightEm, bottomEm); + const bl = new Point$2(leftEm, bottomEm); + const pixelOffsetTL = new Point$2(leftPx / pixelRatio, topPx / pixelRatio); + const pixelOffsetBR = new Point$2(rightPx / pixelRatio, bottomPx / pixelRatio); + const angle = iconRotate * Math.PI / 180; + if (angle) { + const sin = Math.sin(angle), cos = Math.cos(angle), matrix = [cos, -sin, sin, cos]; + tl._matMult(matrix); + tr._matMult(matrix); + bl._matMult(matrix); + br._matMult(matrix); + } + const x1 = left.stretch + left.fixed; + const x2 = right.stretch + right.fixed; + const y1 = top.stretch + top.fixed; + const y2 = bottom.stretch + bottom.fixed; + const subRect = { + x: image.paddedRect.x + border + x1, + y: image.paddedRect.y + border + y1, + w: x2 - x1, + h: y2 - y1 + }; + const minFontScaleX = fixedContentWidth / pixelRatio / iconWidth; + const minFontScaleY = fixedContentHeight / pixelRatio / iconHeight; + // Icon quad is padded, so texture coordinates also need to be padded. + return { tl, tr, bl, br, tex: subRect, writingMode: undefined, glyphOffset: [0, 0], sectionIndex: 0, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, isSDF: isSDFIcon }; + }; + if (!hasIconTextFit || (!image.stretchX && !image.stretchY)) { + quads.push(makeBox({ fixed: 0, stretch: -1 }, { fixed: 0, stretch: -1 }, { fixed: 0, stretch: imageWidth + 1 }, { fixed: 0, stretch: imageHeight + 1 })); + } + else { + const xCuts = stretchZonesToCuts(stretchX, fixedWidth, stretchWidth); + const yCuts = stretchZonesToCuts(stretchY, fixedHeight, stretchHeight); + for (let xi = 0; xi < xCuts.length - 1; xi++) { + const x1 = xCuts[xi]; + const x2 = xCuts[xi + 1]; + for (let yi = 0; yi < yCuts.length - 1; yi++) { + const y1 = yCuts[yi]; + const y2 = yCuts[yi + 1]; + quads.push(makeBox(x1, y1, x2, y2)); + } + } + } + return quads; +} +function sumWithinRange(ranges, min, max) { + let sum = 0; + for (const range of ranges) { + sum += Math.max(min, Math.min(max, range[1])) - Math.max(min, Math.min(max, range[0])); + } + return sum; +} +function stretchZonesToCuts(stretchZones, fixedSize, stretchSize) { + const cuts = [{ fixed: -border, stretch: 0 }]; + for (const [c1, c2] of stretchZones) { + const last = cuts[cuts.length - 1]; + cuts.push({ + fixed: c1 - last.stretch, + stretch: last.stretch + }); + cuts.push({ + fixed: c1 - last.stretch, + stretch: last.stretch + (c2 - c1) + }); + } + cuts.push({ + fixed: fixedSize + border, + stretch: stretchSize + }); + return cuts; +} +function getEmOffset(stretchOffset, stretchSize, iconSize, iconOffset) { + return stretchOffset / stretchSize * iconSize + iconOffset; +} +function getPxOffset(fixedOffset, fixedSize, stretchOffset, stretchSize) { + return fixedOffset - fixedSize * stretchOffset / stretchSize; +} +/** + * Create the quads used for rendering a text label. + */ +function getGlyphQuads(anchor, shaping, textOffset, layer, alongLine, feature, imageMap, allowVerticalPlacement) { + const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}) * Math.PI / 180; + const quads = []; + for (const line of shaping.positionedLines) { + for (const positionedGlyph of line.positionedGlyphs) { + if (!positionedGlyph.rect) + continue; + const textureRect = positionedGlyph.rect || {}; + // The rects have an additional buffer that is not included in their size. + const glyphPadding = 1.0; + let rectBuffer = GLYPH_PBF_BORDER + glyphPadding; + let isSDF = true; + let pixelRatio = 1.0; + let lineOffset = 0.0; + const rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical; + const halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2; + // Align images and scaled glyphs in the middle of a vertical line. + if (allowVerticalPlacement && shaping.verticalizable) { + const scaledGlyphOffset = (positionedGlyph.scale - 1) * ONE_EM; + const imageOffset = (ONE_EM - positionedGlyph.metrics.width * positionedGlyph.scale) / 2; + lineOffset = line.lineOffset / 2 - (positionedGlyph.imageName ? -imageOffset : scaledGlyphOffset); + } + if (positionedGlyph.imageName) { + const image = imageMap[positionedGlyph.imageName]; + isSDF = image.sdf; + pixelRatio = image.pixelRatio; + rectBuffer = IMAGE_PADDING / pixelRatio; + } + const glyphOffset = alongLine ? + [positionedGlyph.x + halfAdvance, positionedGlyph.y] : + [0, 0]; + let builtInOffset = alongLine ? + [0, 0] : + [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1] - lineOffset]; + let verticalizedLabelOffset = [0, 0]; + if (rotateVerticalGlyph) { + // Vertical POI labels that are rotated 90deg CW and whose glyphs must preserve upright orientation + // need to be rotated 90deg CCW. After a quad is rotated, it is translated to the original built-in offset. + verticalizedLabelOffset = builtInOffset; + builtInOffset = [0, 0]; + } + const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1; + const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0]; + const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1]; + const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio; + const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio; + const tl = new Point$2(x1, y1); + const tr = new Point$2(x2, y1); + const bl = new Point$2(x1, y2); + const br = new Point$2(x2, y2); + if (rotateVerticalGlyph) { + // Vertical-supporting glyphs are laid out in 24x24 point boxes (1 square em) + // In horizontal orientation, the y values for glyphs are below the midline + // and we use a "yOffset" of -17 to pull them up to the middle. + // By rotating counter-clockwise around the point at the center of the left + // edge of a 24x24 layout box centered below the midline, we align the center + // of the glyphs with the horizontal midline, so the yOffset is no longer + // necessary, but we also pull the glyph to the left along the x axis. + // The y coordinate includes baseline yOffset, thus needs to be accounted + // for when glyph is rotated and translated. + const center = new Point$2(-halfAdvance, halfAdvance - SHAPING_DEFAULT_OFFSET); + const verticalRotation = -Math.PI / 2; + // xHalfWidthOffsetCorrection is a difference between full-width and half-width + // advance, should be 0 for full-width glyphs and will pull up half-width glyphs. + const xHalfWidthOffsetCorrection = ONE_EM / 2 - halfAdvance; + const yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0.0; + const halfWidthOffsetCorrection = new Point$2(5 - SHAPING_DEFAULT_OFFSET - xHalfWidthOffsetCorrection, -yImageOffsetCorrection); + const verticalOffsetCorrection = new Point$2(...verticalizedLabelOffset); + tl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + tr._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + bl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + br._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + } + if (textRotate) { + const sin = Math.sin(textRotate), cos = Math.cos(textRotate), matrix = [cos, -sin, sin, cos]; + tl._matMult(matrix); + tr._matMult(matrix); + bl._matMult(matrix); + br._matMult(matrix); + } + const pixelOffsetTL = new Point$2(0, 0); + const pixelOffsetBR = new Point$2(0, 0); + const minFontScaleX = 0; + const minFontScaleY = 0; + quads.push({ tl, tr, bl, br, tex: textureRect, writingMode: shaping.writingMode, glyphOffset, sectionIndex: positionedGlyph.sectionIndex, isSDF, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY }); + } + } + return quads; +} + +/** + * A CollisionFeature represents the area of the tile covered by a single label. + * It is used with CollisionIndex to check if the label overlaps with any + * previous labels. A CollisionFeature is mostly just a set of CollisionBox + * objects. + */ +class CollisionFeature { + /** + * Create a CollisionFeature, adding its collision box data to the given collisionBoxArray in the process. + * For line aligned labels a collision circle diameter is computed instead. + * + * @param anchor - The point along the line around which the label is anchored. + * @param shaped - The text or icon shaping results. + * @param boxScale - A magic number used to convert from glyph metrics units to geometry units. + * @param padding - The amount of padding to add around the label edges. + * @param alignLine - Whether the label is aligned with the line or the viewport. + */ + constructor(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaped, boxScale, padding, alignLine, rotate) { + this.boxStartIndex = collisionBoxArray.length; + if (alignLine) { + // Compute height of the shape in glyph metrics and apply collision padding. + // Note that the pixel based 'text-padding' is applied at runtime + let top = shaped.top; + let bottom = shaped.bottom; + const collisionPadding = shaped.collisionPadding; + if (collisionPadding) { + top -= collisionPadding[1]; + bottom += collisionPadding[3]; + } + let height = bottom - top; + if (height > 0) { + // set minimum box height to avoid very many small labels + height = Math.max(10, height); + this.circleDiameter = height; + } + } + else { + // margin is in CSS order: [top, right, bottom, left] + let y1 = shaped.top * boxScale - padding[0]; + let y2 = shaped.bottom * boxScale + padding[2]; + let x1 = shaped.left * boxScale - padding[3]; + let x2 = shaped.right * boxScale + padding[1]; + const collisionPadding = shaped.collisionPadding; + if (collisionPadding) { + x1 -= collisionPadding[0] * boxScale; + y1 -= collisionPadding[1] * boxScale; + x2 += collisionPadding[2] * boxScale; + y2 += collisionPadding[3] * boxScale; + } + if (rotate) { + // Account for *-rotate in point collision boxes + // See https://github.com/mapbox/mapbox-gl-js/issues/6075 + // Doesn't account for icon-text-fit + const tl = new Point$2(x1, y1); + const tr = new Point$2(x2, y1); + const bl = new Point$2(x1, y2); + const br = new Point$2(x2, y2); + const rotateRadians = rotate * Math.PI / 180; + tl._rotate(rotateRadians); + tr._rotate(rotateRadians); + bl._rotate(rotateRadians); + br._rotate(rotateRadians); + // Collision features require an "on-axis" geometry, + // so take the envelope of the rotated geometry + // (may be quite large for wide labels rotated 45 degrees) + x1 = Math.min(tl.x, tr.x, bl.x, br.x); + x2 = Math.max(tl.x, tr.x, bl.x, br.x); + y1 = Math.min(tl.y, tr.y, bl.y, br.y); + y2 = Math.max(tl.y, tr.y, bl.y, br.y); + } + collisionBoxArray.emplaceBack(anchor.x, anchor.y, x1, y1, x2, y2, featureIndex, sourceLayerIndex, bucketIndex); + } + this.boxEndIndex = collisionBoxArray.length; + } +} + +class TinyQueue { + constructor(data = [], compare = defaultCompare) { + this.data = data; + this.length = this.data.length; + this.compare = compare; + + if (this.length > 0) { + for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i); + } + } + + push(item) { + this.data.push(item); + this.length++; + this._up(this.length - 1); + } + + pop() { + if (this.length === 0) return undefined; + + const top = this.data[0]; + const bottom = this.data.pop(); + this.length--; + + if (this.length > 0) { + this.data[0] = bottom; + this._down(0); + } + + return top; + } + + peek() { + return this.data[0]; + } + + _up(pos) { + const {data, compare} = this; + const item = data[pos]; + + while (pos > 0) { + const parent = (pos - 1) >> 1; + const current = data[parent]; + if (compare(item, current) >= 0) break; + data[pos] = current; + pos = parent; + } + + data[pos] = item; + } + + _down(pos) { + const {data, compare} = this; + const halfLength = this.length >> 1; + const item = data[pos]; + + while (pos < halfLength) { + let left = (pos << 1) + 1; + let best = data[left]; + const right = left + 1; + + if (right < this.length && compare(data[right], best) < 0) { + left = right; + best = data[right]; + } + if (compare(best, item) >= 0) break; + + data[pos] = best; + pos = left; + } + + data[pos] = item; + } +} + +function defaultCompare(a, b) { + return a < b ? -1 : a > b ? 1 : 0; +} + +/** + * Finds an approximation of a polygon's Pole Of Inaccessibiliy https://en.wikipedia.org/wiki/Pole_of_inaccessibility + * This is a copy of http://github.com/mapbox/polylabel adapted to use Points + * + * @param polygonRings - first item in array is the outer ring followed optionally by the list of holes, should be an element of the result of util/classify_rings + * @param precision - Specified in input coordinate units. If 0 returns after first run, if `> 0` repeatedly narrows the search space until the radius of the area searched for the best pole is less than precision + * @param debug - Print some statistics to the console during execution + * @returns Pole of Inaccessibiliy. + */ +function findPoleOfInaccessibility(polygonRings, precision = 1, debug = false) { + // find the bounding box of the outer ring + let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity; + const outerRing = polygonRings[0]; + for (let i = 0; i < outerRing.length; i++) { + const p = outerRing[i]; + if (!i || p.x < minX) + minX = p.x; + if (!i || p.y < minY) + minY = p.y; + if (!i || p.x > maxX) + maxX = p.x; + if (!i || p.y > maxY) + maxY = p.y; + } + const width = maxX - minX; + const height = maxY - minY; + const cellSize = Math.min(width, height); + let h = cellSize / 2; + // a priority queue of cells in order of their "potential" (max distance to polygon) + const cellQueue = new TinyQueue([], compareMax); + if (cellSize === 0) + return new Point$2(minX, minY); + // cover polygon with initial cells + for (let x = minX; x < maxX; x += cellSize) { + for (let y = minY; y < maxY; y += cellSize) { + cellQueue.push(new Cell(x + h, y + h, h, polygonRings)); + } + } + // take centroid as the first best guess + let bestCell = getCentroidCell(polygonRings); + let numProbes = cellQueue.length; + while (cellQueue.length) { + // pick the most promising cell from the queue + const cell = cellQueue.pop(); + // update the best cell if we found a better one + if (cell.d > bestCell.d || !bestCell.d) { + bestCell = cell; + if (debug) + console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes); + } + // do not drill down further if there's no chance of a better solution + if (cell.max - bestCell.d <= precision) + continue; + // split the cell into four cells + h = cell.h / 2; + cellQueue.push(new Cell(cell.p.x - h, cell.p.y - h, h, polygonRings)); + cellQueue.push(new Cell(cell.p.x + h, cell.p.y - h, h, polygonRings)); + cellQueue.push(new Cell(cell.p.x - h, cell.p.y + h, h, polygonRings)); + cellQueue.push(new Cell(cell.p.x + h, cell.p.y + h, h, polygonRings)); + numProbes += 4; + } + if (debug) { + console.log(`num probes: ${numProbes}`); + console.log(`best distance: ${bestCell.d}`); + } + return bestCell.p; +} +function compareMax(a, b) { + return b.max - a.max; +} +function Cell(x, y, h, polygon) { + this.p = new Point$2(x, y); + this.h = h; // half the cell size + this.d = pointToPolygonDist(this.p, polygon); // distance from cell center to polygon + this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell +} +// signed distance from point to polygon outline (negative if point is outside) +function pointToPolygonDist(p, polygon) { + let inside = false; + let minDistSq = Infinity; + for (let k = 0; k < polygon.length; k++) { + const ring = polygon[k]; + for (let i = 0, len = ring.length, j = len - 1; i < len; j = i++) { + const a = ring[i]; + const b = ring[j]; + if ((a.y > p.y !== b.y > p.y) && + (p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x)) + inside = !inside; + minDistSq = Math.min(minDistSq, distToSegmentSquared(p, a, b)); + } + } + return (inside ? 1 : -1) * Math.sqrt(minDistSq); +} +// get polygon centroid +function getCentroidCell(polygon) { + let area = 0; + let x = 0; + let y = 0; + const points = polygon[0]; + for (let i = 0, len = points.length, j = len - 1; i < len; j = i++) { + const a = points[i]; + const b = points[j]; + const f = a.x * b.y - b.x * a.y; + x += (a.x + b.x) * f; + y += (a.y + b.y) * f; + area += f * 3; + } + return new Cell(x / area, y / area, 0, polygon); +} + +exports.TextAnchorEnum = void 0; +(function (TextAnchorEnum) { + TextAnchorEnum[TextAnchorEnum["center"] = 1] = "center"; + TextAnchorEnum[TextAnchorEnum["left"] = 2] = "left"; + TextAnchorEnum[TextAnchorEnum["right"] = 3] = "right"; + TextAnchorEnum[TextAnchorEnum["top"] = 4] = "top"; + TextAnchorEnum[TextAnchorEnum["bottom"] = 5] = "bottom"; + TextAnchorEnum[TextAnchorEnum["top-left"] = 6] = "top-left"; + TextAnchorEnum[TextAnchorEnum["top-right"] = 7] = "top-right"; + TextAnchorEnum[TextAnchorEnum["bottom-left"] = 8] = "bottom-left"; + TextAnchorEnum[TextAnchorEnum["bottom-right"] = 9] = "bottom-right"; +})(exports.TextAnchorEnum || (exports.TextAnchorEnum = {})); +// The radial offset is to the edge of the text box +// In the horizontal direction, the edge of the text box is where glyphs start +// But in the vertical direction, the glyphs appear to "start" at the baseline +// We don't actually load baseline data, but we assume an offset of ONE_EM - 17 +// (see "yOffset" in shaping.js) +const baselineOffset = 7; +const INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY; +function evaluateVariableOffset(anchor, offset) { + function fromRadialOffset(anchor, radialOffset) { + let x = 0, y = 0; + if (radialOffset < 0) + radialOffset = 0; // Ignore negative offset. + // solve for r where r^2 + r^2 = radialOffset^2 + const hypotenuse = radialOffset / Math.SQRT2; + switch (anchor) { + case 'top-right': + case 'top-left': + y = hypotenuse - baselineOffset; + break; + case 'bottom-right': + case 'bottom-left': + y = -hypotenuse + baselineOffset; + break; + case 'bottom': + y = -radialOffset + baselineOffset; + break; + case 'top': + y = radialOffset - baselineOffset; + break; + } + switch (anchor) { + case 'top-right': + case 'bottom-right': + x = -hypotenuse; + break; + case 'top-left': + case 'bottom-left': + x = hypotenuse; + break; + case 'left': + x = radialOffset; + break; + case 'right': + x = -radialOffset; + break; + } + return [x, y]; + } + function fromTextOffset(anchor, offsetX, offsetY) { + let x = 0, y = 0; + // Use absolute offset values. + offsetX = Math.abs(offsetX); + offsetY = Math.abs(offsetY); + switch (anchor) { + case 'top-right': + case 'top-left': + case 'top': + y = offsetY - baselineOffset; + break; + case 'bottom-right': + case 'bottom-left': + case 'bottom': + y = -offsetY + baselineOffset; + break; + } + switch (anchor) { + case 'top-right': + case 'bottom-right': + case 'right': + x = -offsetX; + break; + case 'top-left': + case 'bottom-left': + case 'left': + x = offsetX; + break; + } + return [x, y]; + } + return (offset[1] !== INVALID_TEXT_OFFSET) ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]); +} +// Helper to support both text-variable-anchor and text-variable-anchor-offset. Offset values converted from EMs to PXs +function getTextVariableAnchorOffset(layer, feature, canonical) { + var _a; + const layout = layer.layout; + // If style specifies text-variable-anchor-offset, just return it + const variableAnchorOffset = (_a = layout.get('text-variable-anchor-offset')) === null || _a === void 0 ? void 0 : _a.evaluate(feature, {}, canonical); + if (variableAnchorOffset) { + const sourceValues = variableAnchorOffset.values; + const destValues = []; + // Convert offsets from EM to PX, and apply baseline shift + for (let i = 0; i < sourceValues.length; i += 2) { + const anchor = destValues[i] = sourceValues[i]; + const offset = sourceValues[i + 1].map(t => t * ONE_EM); + if (anchor.startsWith('top')) { + offset[1] -= baselineOffset; + } + else if (anchor.startsWith('bottom')) { + offset[1] += baselineOffset; + } + destValues[i + 1] = offset; + } + return new VariableAnchorOffsetCollection(destValues); + } + // If style specifies text-variable-anchor, convert to the new format + const variableAnchor = layout.get('text-variable-anchor'); + if (variableAnchor) { + let textOffset; + const unevaluatedLayout = layer._unevaluatedLayout; + // The style spec says don't use `text-offset` and `text-radial-offset` together + // but doesn't actually specify what happens if you use both. We go with the radial offset. + if (unevaluatedLayout.getValue('text-radial-offset') !== undefined) { + textOffset = [layout.get('text-radial-offset').evaluate(feature, {}, canonical) * ONE_EM, INVALID_TEXT_OFFSET]; + } + else { + textOffset = layout.get('text-offset').evaluate(feature, {}, canonical).map(t => t * ONE_EM); + } + const anchorOffsets = []; + for (const anchor of variableAnchor) { + anchorOffsets.push(anchor, evaluateVariableOffset(anchor, textOffset)); + } + return new VariableAnchorOffsetCollection(anchorOffsets); + } + return null; +} + +function performSymbolLayout(args) { + args.bucket.createArrays(); + const tileSize = 512 * args.bucket.overscaling; + args.bucket.tilePixelRatio = EXTENT / tileSize; + args.bucket.compareText = {}; + args.bucket.iconsNeedLinear = false; + const layer = args.bucket.layers[0]; + const layout = layer.layout; + const unevaluatedLayoutValues = layer._unevaluatedLayout._values; + const sizes = { + // Filled in below, if *SizeData.kind is 'composite' + // compositeIconSizes: undefined, + // compositeTextSizes: undefined, + layoutIconSize: unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical), + layoutTextSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical), + textMaxSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18)) + }; + if (args.bucket.textSizeData.kind === 'composite') { + const { minZoom, maxZoom } = args.bucket.textSizeData; + sizes.compositeTextSizes = [ + unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical), + unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical) + ]; + } + if (args.bucket.iconSizeData.kind === 'composite') { + const { minZoom, maxZoom } = args.bucket.iconSizeData; + sizes.compositeIconSizes = [ + unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical), + unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical) + ]; + } + const lineHeight = layout.get('text-line-height') * ONE_EM; + const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point'; + const keepUpright = layout.get('text-keep-upright'); + const textSize = layout.get('text-size'); + for (const feature of args.bucket.features) { + const fontstack = layout.get('text-font').evaluate(feature, {}, args.canonical).join(','); + const layoutTextSizeThisZoom = textSize.evaluate(feature, {}, args.canonical); + const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, args.canonical); + const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, args.canonical); + const shapedTextOrientations = { + horizontal: {}, + vertical: undefined + }; + const text = feature.text; + let textOffset = [0, 0]; + if (text) { + const unformattedText = text.toString(); + const spacing = layout.get('text-letter-spacing').evaluate(feature, {}, args.canonical) * ONE_EM; + const spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0; + const textAnchor = layout.get('text-anchor').evaluate(feature, {}, args.canonical); + const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, args.canonical); + if (!variableAnchorOffset) { + const radialOffset = layout.get('text-radial-offset').evaluate(feature, {}, args.canonical); + // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector + // is calculated at placement time instead of layout time + if (radialOffset) { + // The style spec says don't use `text-offset` and `text-radial-offset` together + // but doesn't actually specify what happens if you use both. We go with the radial offset. + textOffset = evaluateVariableOffset(textAnchor, [radialOffset * ONE_EM, INVALID_TEXT_OFFSET]); + } + else { + textOffset = layout.get('text-offset').evaluate(feature, {}, args.canonical).map(t => t * ONE_EM); + } + } + let textJustify = textAlongLine ? + 'center' : + layout.get('text-justify').evaluate(feature, {}, args.canonical); + const symbolPlacement = layout.get('symbol-placement'); + const maxWidth = symbolPlacement === 'point' ? + layout.get('text-max-width').evaluate(feature, {}, args.canonical) * ONE_EM : + 0; + const addVerticalShapingForPointLabelIfNeeded = () => { + if (args.bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) { + // Vertical POI label placement is meant to be used for scripts that support vertical + // writing mode, thus, default left justification is used. If Latin + // scripts would need to be supported, this should take into account other justifications. + shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, 'left', spacingIfAllowed, textOffset, exports.WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + } + }; + // If this layer uses text-variable-anchor, generate shapings for all justification possibilities. + if (!textAlongLine && variableAnchorOffset) { + const justifications = new Set(); + if (textJustify === 'auto') { + for (let i = 0; i < variableAnchorOffset.values.length; i += 2) { + justifications.add(getAnchorJustification(variableAnchorOffset.values[i])); + } + } + else { + justifications.add(textJustify); + } + let singleLine = false; + for (const justification of justifications) { + if (shapedTextOrientations.horizontal[justification]) + continue; + if (singleLine) { + // If the shaping for the first justification was only a single line, we + // can re-use it for the other justifications + shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0]; + } + else { + // If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply + // the offsets for the anchor in the placement step. + const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, 'center', justification, spacingIfAllowed, textOffset, exports.WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + if (shaping) { + shapedTextOrientations.horizontal[justification] = shaping; + singleLine = shaping.positionedLines.length === 1; + } + } + } + addVerticalShapingForPointLabelIfNeeded(); + } + else { + if (textJustify === 'auto') { + textJustify = getAnchorJustification(textAnchor); + } + // Horizontal point or line label. + const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed, textOffset, exports.WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + if (shaping) + shapedTextOrientations.horizontal[textJustify] = shaping; + // Vertical point label (if allowVerticalPlacement is enabled). + addVerticalShapingForPointLabelIfNeeded(); + // Verticalized line label. + if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) { + shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed, textOffset, exports.WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + } + } + } + let shapedIcon; + let isSDFIcon = false; + if (feature.icon && feature.icon.name) { + const image = args.imageMap[feature.icon.name]; + if (image) { + shapedIcon = shapeIcon(args.imagePositions[feature.icon.name], layout.get('icon-offset').evaluate(feature, {}, args.canonical), layout.get('icon-anchor').evaluate(feature, {}, args.canonical)); + // null/undefined SDF property treated same as default (false) + isSDFIcon = !!image.sdf; + if (args.bucket.sdfIcons === undefined) { + args.bucket.sdfIcons = isSDFIcon; + } + else if (args.bucket.sdfIcons !== isSDFIcon) { + warnOnce('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer'); + } + if (image.pixelRatio !== args.bucket.pixelRatio) { + args.bucket.iconsNeedLinear = true; + } + else if (layout.get('icon-rotate').constantOr(1) !== 0) { + args.bucket.iconsNeedLinear = true; + } + } + } + const shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical; + args.bucket.iconsInText = shapedText ? shapedText.iconsInText : false; + if (shapedText || shapedIcon) { + addFeature(args.bucket, feature, shapedTextOrientations, shapedIcon, args.imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, args.canonical); + } + } + if (args.showCollisionBoxes) { + args.bucket.generateCollisionDebugBuffers(); + } +} +// Choose the justification that matches the direction of the TextAnchor +function getAnchorJustification(anchor) { + switch (anchor) { + case 'right': + case 'top-right': + case 'bottom-right': + return 'right'; + case 'left': + case 'top-left': + case 'bottom-left': + return 'left'; + } + return 'center'; +} +/** + * Given a feature and its shaped text and icon data, add a 'symbol + * instance' for each _possible_ placement of the symbol feature. + * (At render timePlaceSymbols#place() selects which of these instances to + * show or hide based on collisions with symbols in other layers.) + */ +function addFeature(bucket, feature, shapedTextOrientations, shapedIcon, imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, canonical) { + // To reduce the number of labels that jump around when zooming we need + // to use a text-size value that is the same for all zoom levels. + // bucket calculates text-size at a high zoom level so that all tiles can + // use the same value when calculating anchor positions. + let textMaxSize = sizes.textMaxSize.evaluate(feature, {}); + if (textMaxSize === undefined) { + textMaxSize = layoutTextSize; + } + const layout = bucket.layers[0].layout; + const iconOffset = layout.get('icon-offset').evaluate(feature, {}, canonical); + const defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal); + const glyphSize = 24, fontScale = layoutTextSize / glyphSize, textBoxScale = bucket.tilePixelRatio * fontScale, textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize, iconBoxScale = bucket.tilePixelRatio * layoutIconSize, symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing'), textPadding = layout.get('text-padding') * bucket.tilePixelRatio, iconPadding = getIconPadding(layout, feature, canonical, bucket.tilePixelRatio), textMaxAngle = layout.get('text-max-angle') / 180 * Math.PI, textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point', iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point', symbolPlacement = layout.get('symbol-placement'), textRepeatDistance = symbolMinDistance / 2; + const iconTextFit = layout.get('icon-text-fit'); + let verticallyShapedIcon; + // Adjust shaped icon size when icon-text-fit is used. + if (shapedIcon && iconTextFit !== 'none') { + if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) { + verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit, layout.get('icon-text-fit-padding'), iconOffset, fontScale); + } + if (defaultHorizontalShaping) { + shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit, layout.get('icon-text-fit-padding'), iconOffset, fontScale); + } + } + const addSymbolAtAnchor = (line, anchor) => { + if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) { + // Symbol layers are drawn across tile boundaries, We filter out symbols + // outside our tile boundaries (which may be included in vector tile buffers) + // to prevent double-drawing symbols. + return; + } + addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0], bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index, textBoxScale, [textPadding, textPadding, textPadding, textPadding], textAlongLine, textOffset, iconBoxScale, iconPadding, iconAlongLine, iconOffset, feature, sizes, isSDFIcon, canonical, layoutTextSize); + }; + if (symbolPlacement === 'line') { + for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) { + const anchors = getAnchors(line, symbolMinDistance, textMaxAngle, shapedTextOrientations.vertical || defaultHorizontalShaping, shapedIcon, glyphSize, textMaxBoxScale, bucket.overscaling, EXTENT); + for (const anchor of anchors) { + const shapedText = defaultHorizontalShaping; + if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) { + addSymbolAtAnchor(line, anchor); + } + } + } + } + else if (symbolPlacement === 'line-center') { + // No clipping, multiple lines per feature are allowed + // "lines" with only one point are ignored as in clipLines + for (const line of feature.geometry) { + if (line.length > 1) { + const anchor = getCenterAnchor(line, textMaxAngle, shapedTextOrientations.vertical || defaultHorizontalShaping, shapedIcon, glyphSize, textMaxBoxScale); + if (anchor) { + addSymbolAtAnchor(line, anchor); + } + } + } + } + else if (feature.type === 'Polygon') { + for (const polygon of classifyRings$1(feature.geometry, 0)) { + // 16 here represents 2 pixels + const poi = findPoleOfInaccessibility(polygon, 16); + addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0)); + } + } + else if (feature.type === 'LineString') { + // https://github.com/mapbox/mapbox-gl-js/issues/3808 + for (const line of feature.geometry) { + addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0)); + } + } + else if (feature.type === 'Point') { + for (const points of feature.geometry) { + for (const point of points) { + addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0)); + } + } + } +} +function addTextVariableAnchorOffsets(textAnchorOffsets, variableAnchorOffset) { + const startIndex = textAnchorOffsets.length; + const values = variableAnchorOffset === null || variableAnchorOffset === void 0 ? void 0 : variableAnchorOffset.values; + if ((values === null || values === void 0 ? void 0 : values.length) > 0) { + for (let i = 0; i < values.length; i += 2) { + const anchor = exports.TextAnchorEnum[values[i]]; + const offset = values[i + 1]; + textAnchorOffsets.emplaceBack(anchor, offset[0], offset[1]); + } + } + return [startIndex, textAnchorOffsets.length]; +} +function addTextVertices(bucket, anchor, shapedText, imageMap, layer, textAlongLine, feature, textOffset, lineArray, writingMode, placementTypes, placedTextSymbolIndices, placedIconIndex, sizes, canonical) { + const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset, layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement); + const sizeData = bucket.textSizeData; + let textSizeData = null; + if (sizeData.kind === 'source') { + textSizeData = [ + SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {}) + ]; + if (textSizeData[0] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "text-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "text-size".`); + } + } + else if (sizeData.kind === 'composite') { + textSizeData = [ + SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical), + SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical) + ]; + if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "text-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "text-size".`); + } + } + bucket.addSymbols(bucket.text, glyphQuads, textSizeData, textOffset, textAlongLine, feature, writingMode, anchor, lineArray.lineStartIndex, lineArray.lineLength, placedIconIndex, canonical); + // The placedSymbolArray is used at render time in drawTileSymbols + // These indices allow access to the array at collision detection time + for (const placementType of placementTypes) { + placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1; + } + return glyphQuads.length * 4; +} +function getDefaultHorizontalShaping(horizontalShaping) { + // We don't care which shaping we get because this is used for collision purposes + // and all the justifications have the same collision box + for (const justification in horizontalShaping) { + return horizontalShaping[justification]; + } + return null; +} +/** + * Add a single label & icon placement. + */ +function addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, layer, collisionBoxArray, featureIndex, sourceLayerIndex, bucketIndex, textBoxScale, textPadding, textAlongLine, textOffset, iconBoxScale, iconPadding, iconAlongLine, iconOffset, feature, sizes, isSDFIcon, canonical, layoutTextSize) { + const lineArray = bucket.addToLineVertexArray(anchor, line); + let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature; + let numIconVertices = 0; + let numVerticalIconVertices = 0; + let numHorizontalGlyphVertices = 0; + let numVerticalGlyphVertices = 0; + let placedIconSymbolIndex = -1; + let verticalPlacedIconSymbolIndex = -1; + const placedTextSymbolIndices = {}; + let key = murmur3$1(''); + if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) { + const textRotation = layer.layout.get('text-rotate').evaluate(feature, {}, canonical); + const verticalTextRotation = textRotation + 90.0; + const verticalShaping = shapedTextOrientations.vertical; + verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation); + if (verticallyShapedIcon) { + verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation); + } + } + //Place icon first, so text can have a reference to its index in the placed symbol array. + //Text symbols can lazily shift at render-time because of variable anchor placement. + //If the style specifies an `icon-text-fit` then the icon would have to shift along with it. + // For more info check `updateVariableAnchors` in `draw_symbol.js` . + if (shapedIcon) { + const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {}); + const hasIconTextFit = layer.layout.get('icon-text-fit') !== 'none'; + const iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit); + const verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : undefined; + iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/ false, iconRotate); + numIconVertices = iconQuads.length * 4; + const sizeData = bucket.iconSizeData; + let iconSizeData = null; + if (sizeData.kind === 'source') { + iconSizeData = [ + SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {}) + ]; + if (iconSizeData[0] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "icon-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "icon-size".`); + } + } + else if (sizeData.kind === 'composite') { + iconSizeData = [ + SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical), + SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical) + ]; + if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "icon-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "icon-size".`); + } + } + bucket.addSymbols(bucket.icon, iconQuads, iconSizeData, iconOffset, iconAlongLine, feature, exports.WritingMode.none, anchor, lineArray.lineStartIndex, lineArray.lineLength, + // The icon itself does not have an associated symbol since the text isnt placed yet + -1, canonical); + placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1; + if (verticalIconQuads) { + numVerticalIconVertices = verticalIconQuads.length * 4; + bucket.addSymbols(bucket.icon, verticalIconQuads, iconSizeData, iconOffset, iconAlongLine, feature, exports.WritingMode.vertical, anchor, lineArray.lineStartIndex, lineArray.lineLength, + // The icon itself does not have an associated symbol since the text isnt placed yet + -1, canonical); + verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1; + } + } + const justifications = Object.keys(shapedTextOrientations.horizontal); + for (const justification of justifications) { + const shaping = shapedTextOrientations.horizontal[justification]; + if (!textCollisionFeature) { + key = murmur3$1(shaping.text); + const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}, canonical); + // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature + // We're counting on all versions having similar dimensions + textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate); + } + const singleLine = shaping.positionedLines.length === 1; + numHorizontalGlyphVertices += addTextVertices(bucket, anchor, shaping, imageMap, layer, textAlongLine, feature, textOffset, lineArray, shapedTextOrientations.vertical ? exports.WritingMode.horizontal : exports.WritingMode.horizontalOnly, singleLine ? justifications : [justification], placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical); + if (singleLine) { + break; + } + } + if (shapedTextOrientations.vertical) { + numVerticalGlyphVertices += addTextVertices(bucket, anchor, shapedTextOrientations.vertical, imageMap, layer, textAlongLine, feature, textOffset, lineArray, exports.WritingMode.vertical, ['vertical'], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical); + } + const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + const verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + // Check if runtime collision circles should be used for any of the collision features. + // It is enough to choose the tallest feature shape as circles are always placed on a line. + // All measurements are in glyph metrics and later converted into pixels using proper font size "layoutTextSize" + let collisionCircleDiameter = -1; + const getCollisionCircleHeight = (feature, prevHeight) => { + if (feature && feature.circleDiameter) + return Math.max(feature.circleDiameter, prevHeight); + return prevHeight; + }; + collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter); + collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter); + collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter); + collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter); + const useRuntimeCollisionCircles = (collisionCircleDiameter > -1) ? 1 : 0; + // Convert circle collision height into pixels + if (useRuntimeCollisionCircles) + collisionCircleDiameter *= layoutTextSize / ONE_EM; + if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) + warnOnce('Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907'); + if (feature.sortKey !== undefined) { + bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey); + } + const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, canonical); + const [textAnchorOffsetStartIndex, textAnchorOffsetEndIndex] = addTextVariableAnchorOffsets(bucket.textAnchorOffsets, variableAnchorOffset); + bucket.symbolInstances.emplaceBack(anchor.x, anchor.y, placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1, placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1, placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1, placedTextSymbolIndices.vertical || -1, placedIconSymbolIndex, verticalPlacedIconSymbolIndex, key, textBoxStartIndex, textBoxEndIndex, verticalTextBoxStartIndex, verticalTextBoxEndIndex, iconBoxStartIndex, iconBoxEndIndex, verticalIconBoxStartIndex, verticalIconBoxEndIndex, featureIndex, numHorizontalGlyphVertices, numVerticalGlyphVertices, numIconVertices, numVerticalIconVertices, useRuntimeCollisionCircles, 0, textBoxScale, collisionCircleDiameter, textAnchorOffsetStartIndex, textAnchorOffsetEndIndex); +} +function anchorIsTooClose(bucket, text, repeatDistance, anchor) { + const compareText = bucket.compareText; + if (!(text in compareText)) { + compareText[text] = []; + } + else { + const otherAnchors = compareText[text]; + for (let k = otherAnchors.length - 1; k >= 0; k--) { + if (anchor.dist(otherAnchors[k]) < repeatDistance) { + // If it's within repeatDistance of one anchor, stop looking + return true; + } + } + } + // If anchor is not within repeatDistance of any other anchor, add to array + compareText[text].push(anchor); + return false; +} + +const ARRAY_TYPES = [ + Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, + Int32Array, Uint32Array, Float32Array, Float64Array +]; + +/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */ + +const VERSION = 1; // serialized format version +const HEADER_SIZE = 8; + +class KDBush { + + /** + * Creates an index from raw `ArrayBuffer` data. + * @param {ArrayBuffer} data + */ + static from(data) { + if (!(data instanceof ArrayBuffer)) { + throw new Error('Data must be an instance of ArrayBuffer.'); + } + const [magic, versionAndType] = new Uint8Array(data, 0, 2); + if (magic !== 0xdb) { + throw new Error('Data does not appear to be in a KDBush format.'); + } + const version = versionAndType >> 4; + if (version !== VERSION) { + throw new Error(`Got v${version} data when expected v${VERSION}.`); + } + const ArrayType = ARRAY_TYPES[versionAndType & 0x0f]; + if (!ArrayType) { + throw new Error('Unrecognized array type.'); + } + const [nodeSize] = new Uint16Array(data, 2, 1); + const [numItems] = new Uint32Array(data, 4, 1); + + return new KDBush(numItems, nodeSize, ArrayType, data); + } + + /** + * Creates an index that will hold a given number of items. + * @param {number} numItems + * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default). + * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default). + * @param {ArrayBuffer} [data] (For internal use only) + */ + constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) { + if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`); + + this.numItems = +numItems; + this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535); + this.ArrayType = ArrayType; + this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array; + + const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType); + const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT; + const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT; + const padCoords = (8 - idsByteSize % 8) % 8; + + if (arrayTypeIndex < 0) { + throw new Error(`Unexpected typed array class: ${ArrayType}.`); + } + + if (data && (data instanceof ArrayBuffer)) { // reconstruct an index from a buffer + this.data = data; + this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems); + this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2); + this._pos = numItems * 2; + this._finished = true; + } else { // initialize a new index + this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords); + this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems); + this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2); + this._pos = 0; + this._finished = false; + + // set header + new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]); + new Uint16Array(this.data, 2, 1)[0] = nodeSize; + new Uint32Array(this.data, 4, 1)[0] = numItems; + } + } + + /** + * Add a point to the index. + * @param {number} x + * @param {number} y + * @returns {number} An incremental index associated with the added item (starting from `0`). + */ + add(x, y) { + const index = this._pos >> 1; + this.ids[index] = index; + this.coords[this._pos++] = x; + this.coords[this._pos++] = y; + return index; + } + + /** + * Perform indexing of the added points. + */ + finish() { + const numAdded = this._pos >> 1; + if (numAdded !== this.numItems) { + throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`); + } + // kd-sort both arrays for efficient search + sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0); + + this._finished = true; + return this; + } + + /** + * Search the index for items within a given bounding box. + * @param {number} minX + * @param {number} minY + * @param {number} maxX + * @param {number} maxY + * @returns {number[]} An array of indices correponding to the found items. + */ + range(minX, minY, maxX, maxY) { + if (!this._finished) throw new Error('Data not yet indexed - call index.finish().'); + + const {ids, coords, nodeSize} = this; + const stack = [0, ids.length - 1, 0]; + const result = []; + + // recursively search for items in range in the kd-sorted arrays + while (stack.length) { + const axis = stack.pop() || 0; + const right = stack.pop() || 0; + const left = stack.pop() || 0; + + // if we reached "tree node", search linearly + if (right - left <= nodeSize) { + for (let i = left; i <= right; i++) { + const x = coords[2 * i]; + const y = coords[2 * i + 1]; + if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]); + } + continue; + } + + // otherwise find the middle index + const m = (left + right) >> 1; + + // include the middle item if it's in range + const x = coords[2 * m]; + const y = coords[2 * m + 1]; + if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]); + + // queue search in halves that intersect the query + if (axis === 0 ? minX <= x : minY <= y) { + stack.push(left); + stack.push(m - 1); + stack.push(1 - axis); + } + if (axis === 0 ? maxX >= x : maxY >= y) { + stack.push(m + 1); + stack.push(right); + stack.push(1 - axis); + } + } + + return result; + } + + /** + * Search the index for items within a given radius. + * @param {number} qx + * @param {number} qy + * @param {number} r Query radius. + * @returns {number[]} An array of indices correponding to the found items. + */ + within(qx, qy, r) { + if (!this._finished) throw new Error('Data not yet indexed - call index.finish().'); + + const {ids, coords, nodeSize} = this; + const stack = [0, ids.length - 1, 0]; + const result = []; + const r2 = r * r; + + // recursively search for items within radius in the kd-sorted arrays + while (stack.length) { + const axis = stack.pop() || 0; + const right = stack.pop() || 0; + const left = stack.pop() || 0; + + // if we reached "tree node", search linearly + if (right - left <= nodeSize) { + for (let i = left; i <= right; i++) { + if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]); + } + continue; + } + + // otherwise find the middle index + const m = (left + right) >> 1; + + // include the middle item if it's in range + const x = coords[2 * m]; + const y = coords[2 * m + 1]; + if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]); + + // queue search in halves that intersect the query + if (axis === 0 ? qx - r <= x : qy - r <= y) { + stack.push(left); + stack.push(m - 1); + stack.push(1 - axis); + } + if (axis === 0 ? qx + r >= x : qy + r >= y) { + stack.push(m + 1); + stack.push(right); + stack.push(1 - axis); + } + } + + return result; + } +} + +/** + * @param {Uint16Array | Uint32Array} ids + * @param {InstanceType} coords + * @param {number} nodeSize + * @param {number} left + * @param {number} right + * @param {number} axis + */ +function sort(ids, coords, nodeSize, left, right, axis) { + if (right - left <= nodeSize) return; + + const m = (left + right) >> 1; // middle index + + // sort ids and coords around the middle index so that the halves lie + // either left/right or top/bottom correspondingly (taking turns) + select(ids, coords, m, left, right, axis); + + // recursively kd-sort first half and second half on the opposite axis + sort(ids, coords, nodeSize, left, m - 1, 1 - axis); + sort(ids, coords, nodeSize, m + 1, right, 1 - axis); +} + +/** + * Custom Floyd-Rivest selection algorithm: sort ids and coords so that + * [left..k-1] items are smaller than k-th item (on either x or y axis) + * @param {Uint16Array | Uint32Array} ids + * @param {InstanceType} coords + * @param {number} k + * @param {number} left + * @param {number} right + * @param {number} axis + */ +function select(ids, coords, k, left, right, axis) { + + while (right > left) { + if (right - left > 600) { + const n = right - left + 1; + const m = k - left + 1; + const z = Math.log(n); + const s = 0.5 * Math.exp(2 * z / 3); + const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + const newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + select(ids, coords, k, newLeft, newRight, axis); + } + + const t = coords[2 * k + axis]; + let i = left; + let j = right; + + swapItem(ids, coords, left, k); + if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right); + + while (i < j) { + swapItem(ids, coords, i, j); + i++; + j--; + while (coords[2 * i + axis] < t) i++; + while (coords[2 * j + axis] > t) j--; + } + + if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j); + else { + j++; + swapItem(ids, coords, j, right); + } + + if (j <= k) left = j + 1; + if (k <= j) right = j - 1; + } +} + +/** + * @param {Uint16Array | Uint32Array} ids + * @param {InstanceType} coords + * @param {number} i + * @param {number} j + */ +function swapItem(ids, coords, i, j) { + swap(ids, i, j); + swap(coords, 2 * i, 2 * j); + swap(coords, 2 * i + 1, 2 * j + 1); +} + +/** + * @param {InstanceType} arr + * @param {number} i + * @param {number} j + */ +function swap(arr, i, j) { + const tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +/** + * @param {number} ax + * @param {number} ay + * @param {number} bx + * @param {number} by + */ +function sqDist(ax, ay, bx, by) { + const dx = ax - bx; + const dy = ay - by; + return dx * dx + dy * dy; +} + +exports.PerformanceMarkers = void 0; +(function (PerformanceMarkers) { + PerformanceMarkers["create"] = "create"; + PerformanceMarkers["load"] = "load"; + PerformanceMarkers["fullLoad"] = "fullLoad"; +})(exports.PerformanceMarkers || (exports.PerformanceMarkers = {})); +let lastFrameTime = null; +let frameTimes = []; +const minFramerateTarget = 60; +const frameTimeTarget = 1000 / minFramerateTarget; +const loadTimeKey = 'loadTime'; +const fullLoadTimeKey = 'fullLoadTime'; +const PerformanceUtils = { + mark(marker) { + performance.mark(marker); + }, + frame(timestamp) { + const currTimestamp = timestamp; + if (lastFrameTime != null) { + const frameTime = currTimestamp - lastFrameTime; + frameTimes.push(frameTime); + } + lastFrameTime = currTimestamp; + }, + clearMetrics() { + lastFrameTime = null; + frameTimes = []; + performance.clearMeasures(loadTimeKey); + performance.clearMeasures(fullLoadTimeKey); + for (const marker in exports.PerformanceMarkers) { + performance.clearMarks(exports.PerformanceMarkers[marker]); + } + }, + getPerformanceMetrics() { + performance.measure(loadTimeKey, exports.PerformanceMarkers.create, exports.PerformanceMarkers.load); + performance.measure(fullLoadTimeKey, exports.PerformanceMarkers.create, exports.PerformanceMarkers.fullLoad); + const loadTime = performance.getEntriesByName(loadTimeKey)[0].duration; + const fullLoadTime = performance.getEntriesByName(fullLoadTimeKey)[0].duration; + const totalFrames = frameTimes.length; + const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000; + const fps = 1 / avgFrameTime; + // count frames that missed our framerate target + const droppedFrames = frameTimes + .filter((frameTime) => frameTime > frameTimeTarget) + .reduce((acc, curr) => { + return acc + (curr - frameTimeTarget) / frameTimeTarget; + }, 0); + const percentDroppedFrames = (droppedFrames / (totalFrames + droppedFrames)) * 100; + return { + loadTime, + fullLoadTime, + fps, + percentDroppedFrames, + totalFrames + }; + } +}; +/** + * @internal + * Safe wrapper for the performance resource timing API in web workers with graceful degradation + */ +class RequestPerformance { + constructor(request) { + this._marks = { + start: [request.url, 'start'].join('#'), + end: [request.url, 'end'].join('#'), + measure: request.url.toString() + }; + performance.mark(this._marks.start); + } + finish() { + performance.mark(this._marks.end); + let resourceTimingData = performance.getEntriesByName(this._marks.measure); + // fallback if web worker implementation of perf.getEntriesByName returns empty + if (resourceTimingData.length === 0) { + performance.measure(this._marks.measure, this._marks.start, this._marks.end); + resourceTimingData = performance.getEntriesByName(this._marks.measure); + // cleanup + performance.clearMarks(this._marks.start); + performance.clearMarks(this._marks.end); + performance.clearMeasures(this._marks.measure); + } + return resourceTimingData; + } +} +var performance$1 = performance; + +exports.AJAXError = AJAXError; +exports.Actor = Actor; +exports.AlphaImage = AlphaImage; +exports.CanonicalTileID = CanonicalTileID; +exports.CollisionBoxArray = CollisionBoxArray; +exports.CollisionCircleLayoutArray = CollisionCircleLayoutArray; +exports.Color = Color; +exports.DEMData = DEMData; +exports.DataConstantProperty = DataConstantProperty; +exports.DictionaryCoder = DictionaryCoder; +exports.EXTENT = EXTENT; +exports.ErrorEvent = ErrorEvent; +exports.EvaluationParameters = EvaluationParameters; +exports.Event = Event; +exports.Evented = Evented; +exports.FeatureIndex = FeatureIndex; +exports.FillBucket = FillBucket; +exports.FillExtrusionBucket = FillExtrusionBucket; +exports.GeoJSONFeature = GeoJSONFeature; +exports.ImageAtlas = ImageAtlas; +exports.ImagePosition = ImagePosition; +exports.KDBush = KDBush; +exports.LineBucket = LineBucket; +exports.LineStripIndexArray = LineStripIndexArray; +exports.LngLat = LngLat; +exports.MercatorCoordinate = MercatorCoordinate; +exports.ONE_EM = ONE_EM; +exports.OverscaledTileID = OverscaledTileID; +exports.PerformanceUtils = PerformanceUtils; +exports.Point = Point$2; +exports.Pos3dArray = Pos3dArray; +exports.PosArray = PosArray; +exports.Properties = Properties; +exports.Protobuf = Protobuf; +exports.QuadTriangleArray = QuadTriangleArray; +exports.RGBAImage = RGBAImage; +exports.RasterBoundsArray = RasterBoundsArray; +exports.RequestPerformance = RequestPerformance; +exports.SegmentVector = SegmentVector; +exports.SymbolBucket = SymbolBucket; +exports.Transitionable = Transitionable; +exports.TriangleIndexArray = TriangleIndexArray; +exports.Uniform1f = Uniform1f; +exports.Uniform1i = Uniform1i; +exports.Uniform2f = Uniform2f; +exports.Uniform3f = Uniform3f; +exports.Uniform4f = Uniform4f; +exports.UniformColor = UniformColor; +exports.UniformMatrix4f = UniformMatrix4f; +exports.UnwrappedTileID = UnwrappedTileID; +exports.ValidationError = ValidationError; +exports.ZoomHistory = ZoomHistory; +exports.__awaiter = __awaiter; +exports.add = add$4; +exports.addDynamicAttributes = addDynamicAttributes; +exports.arrayBufferToImage = arrayBufferToImage; +exports.arrayBufferToImageBitmap = arrayBufferToImageBitmap; +exports.asyncAll = asyncAll; +exports.bezier = bezier$1; +exports.browser = browser; +exports.clamp = clamp$1; +exports.clipLine = clipLine; +exports.clone = clone$5; +exports.clone$1 = clone$9; +exports.clone$2 = clone$4; +exports.collisionCircleLayout = collisionCircleLayout; +exports.config = config; +exports.copy = copy$5; +exports.create = create$5; +exports.create$1 = create$6; +exports.create$2 = create$8; +exports.createExpression = createExpression; +exports.createFilter = createFilter; +exports.createLayout = createLayout; +exports.createStyleLayer = createStyleLayer; +exports.cross = cross$2; +exports.deepEqual = deepEqual$1; +exports.defaultEasing = defaultEasing; +exports.derefLayers = derefLayers; +exports.diffStyles = diffStyles; +exports.dot = dot$5; +exports.dot$1 = dot$4; +exports.earthRadius = earthRadius; +exports.emitValidationErrors = emitValidationErrors; +exports.emptyStyle = emptyStyle; +exports.equals = equals$6; +exports.evaluateSizeForFeature = evaluateSizeForFeature; +exports.evaluateSizeForZoom = evaluateSizeForZoom; +exports.evented = evented; +exports.extend = extend; +exports.filterObject = filterObject; +exports.findLineIntersection = findLineIntersection; +exports.fromRotation = fromRotation$2; +exports.fromScaling = fromScaling; +exports.getAnchorAlignment = getAnchorAlignment; +exports.getAnchorJustification = getAnchorJustification; +exports.getArrayBuffer = getArrayBuffer; +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +exports.getImageData = getImageData; +exports.getJSON = getJSON; +exports.getOverlapMode = getOverlapMode; +exports.getProtocolAction = getProtocolAction; +exports.getRTLTextPluginStatus = getRTLTextPluginStatus; +exports.getReferrer = getReferrer; +exports.getVideo = getVideo; +exports.groupByLayout = groupByLayout; +exports.identity = identity$2; +exports.interpolate = interpolate; +exports.invert = invert$2; +exports.isImageBitmap = isImageBitmap; +exports.isOffscreenCanvasDistorted = isOffscreenCanvasDistorted; +exports.isSafari = isSafari; +exports.isWorker = isWorker; +exports.keysDifference = keysDifference; +exports.lazyLoadRTLTextPlugin = lazyLoadRTLTextPlugin; +exports.lngFromMercatorX = lngFromMercatorX; +exports.makeRequest = makeRequest; +exports.mapObject = mapObject; +exports.mercatorXfromLng = mercatorXfromLng; +exports.mercatorYfromLat = mercatorYfromLat; +exports.mercatorZfromAltitude = mercatorZfromAltitude; +exports.mul = mul$5; +exports.mul$1 = mul$3; +exports.multiply = multiply$5; +exports.nextPowerOfTwo = nextPowerOfTwo; +exports.normalize = normalize$4; +exports.offscreenCanvasSupported = offscreenCanvasSupported; +exports.operations = operations; +exports.ortho = ortho; +exports.parseCacheControl = parseCacheControl; +exports.parseGlyphPbf = parseGlyphPbf; +exports.pbf = pbf; +exports.performSymbolLayout = performSymbolLayout; +exports.perspective = perspective; +exports.pick = pick; +exports.plugin = plugin; +exports.pointGeometry = pointGeometry; +exports.polygonIntersectsPolygon = polygonIntersectsPolygon; +exports.potpack = potpack; +exports.readImageUsingVideoFrame = readImageUsingVideoFrame; +exports.register = register; +exports.registerForPluginStateChange = registerForPluginStateChange; +exports.renderColorRamp = renderColorRamp; +exports.rotate = rotate$4; +exports.rotateX = rotateX$3; +exports.rotateZ = rotateZ$3; +exports.sameOrigin = sameOrigin; +exports.scale = scale$5; +exports.scale$1 = scale$4; +exports.setRTLTextPlugin = setRTLTextPlugin; +exports.sphericalToCartesian = sphericalToCartesian; +exports.sqrLen = sqrLen; +exports.sub = sub$2; +exports.toEvaluationFeature = toEvaluationFeature; +exports.transformMat3 = transformMat3$1; +exports.transformMat4 = transformMat4$1; +exports.transformMat4$1 = transformMat4; +exports.translate = translate$1; +exports.triggerPluginCompletionEvent = triggerPluginCompletionEvent; +exports.unicodeBlockLookup = unicodeBlockLookup; +exports.uniqueId = uniqueId; +exports.v8Spec = v8Spec; +exports.validateCustomStyleLayer = validateCustomStyleLayer; +exports.validateLight = validateLight; +exports.validateStyle = validateStyle; +exports.vectorTile = vectorTile; +exports.warnOnce = warnOnce; +exports.wrap = wrap; + +})); + +define(['./shared'], (function (performance) { 'use strict'; + +class StyleLayerIndex { + constructor(layerConfigs) { + this.keyCache = {}; + if (layerConfigs) { + this.replace(layerConfigs); + } + } + replace(layerConfigs) { + this._layerConfigs = {}; + this._layers = {}; + this.update(layerConfigs, []); + } + update(layerConfigs, removedIds) { + for (const layerConfig of layerConfigs) { + this._layerConfigs[layerConfig.id] = layerConfig; + const layer = this._layers[layerConfig.id] = performance.createStyleLayer(layerConfig); + layer._featureFilter = performance.createFilter(layer.filter); + if (this.keyCache[layerConfig.id]) + delete this.keyCache[layerConfig.id]; + } + for (const id of removedIds) { + delete this.keyCache[id]; + delete this._layerConfigs[id]; + delete this._layers[id]; + } + this.familiesBySource = {}; + const groups = performance.groupByLayout(Object.values(this._layerConfigs), this.keyCache); + for (const layerConfigs of groups) { + const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]); + const layer = layers[0]; + if (layer.visibility === 'none') { + continue; + } + const sourceId = layer.source || ''; + let sourceGroup = this.familiesBySource[sourceId]; + if (!sourceGroup) { + sourceGroup = this.familiesBySource[sourceId] = {}; + } + const sourceLayerId = layer.sourceLayer || '_geojsonTileLayer'; + let sourceLayerFamilies = sourceGroup[sourceLayerId]; + if (!sourceLayerFamilies) { + sourceLayerFamilies = sourceGroup[sourceLayerId] = []; + } + sourceLayerFamilies.push(layers); + } + } +} + +const padding = 1; +class GlyphAtlas { + constructor(stacks) { + const positions = {}; + const bins = []; + for (const stack in stacks) { + const glyphs = stacks[stack]; + const stackPositions = positions[stack] = {}; + for (const id in glyphs) { + const src = glyphs[+id]; + if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) + continue; + const bin = { + x: 0, + y: 0, + w: src.bitmap.width + 2 * padding, + h: src.bitmap.height + 2 * padding + }; + bins.push(bin); + stackPositions[id] = { rect: bin, metrics: src.metrics }; + } + } + const { w, h } = performance.potpack(bins); + const image = new performance.AlphaImage({ width: w || 1, height: h || 1 }); + for (const stack in stacks) { + const glyphs = stacks[stack]; + for (const id in glyphs) { + const src = glyphs[+id]; + if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) + continue; + const bin = positions[stack][id].rect; + performance.AlphaImage.copy(src.bitmap, image, { x: 0, y: 0 }, { x: bin.x + padding, y: bin.y + padding }, src.bitmap); + } + } + this.image = image; + this.positions = positions; + } +} +performance.register('GlyphAtlas', GlyphAtlas); + +class WorkerTile { + constructor(params) { + this.tileID = new performance.OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y); + this.uid = params.uid; + this.zoom = params.zoom; + this.pixelRatio = params.pixelRatio; + this.tileSize = params.tileSize; + this.source = params.source; + this.overscaling = this.tileID.overscaleFactor(); + this.showCollisionBoxes = params.showCollisionBoxes; + this.collectResourceTiming = !!params.collectResourceTiming; + this.returnDependencies = !!params.returnDependencies; + this.promoteId = params.promoteId; + this.inFlightDependencies = []; + this.dependencySentinel = -1; + } + parse(data, layerIndex, availableImages, actor, callback) { + this.status = 'parsing'; + this.data = data; + this.collisionBoxArray = new performance.CollisionBoxArray(); + const sourceLayerCoder = new performance.DictionaryCoder(Object.keys(data.layers).sort()); + const featureIndex = new performance.FeatureIndex(this.tileID, this.promoteId); + featureIndex.bucketLayerIDs = []; + const buckets = {}; + const options = { + featureIndex, + iconDependencies: {}, + patternDependencies: {}, + glyphDependencies: {}, + availableImages + }; + const layerFamilies = layerIndex.familiesBySource[this.source]; + for (const sourceLayerId in layerFamilies) { + const sourceLayer = data.layers[sourceLayerId]; + if (!sourceLayer) { + continue; + } + if (sourceLayer.version === 1) { + performance.warnOnce(`Vector tile source "${this.source}" layer "${sourceLayerId}" ` + + 'does not use vector tile spec v2 and therefore may have some rendering errors.'); + } + const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId); + const features = []; + for (let index = 0; index < sourceLayer.length; index++) { + const feature = sourceLayer.feature(index); + const id = featureIndex.getId(feature, sourceLayerId); + features.push({ feature, id, index, sourceLayerIndex }); + } + for (const family of layerFamilies[sourceLayerId]) { + const layer = family[0]; + if (layer.source !== this.source) { + performance.warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`); + } + if (layer.minzoom && this.zoom < Math.floor(layer.minzoom)) + continue; + if (layer.maxzoom && this.zoom >= layer.maxzoom) + continue; + if (layer.visibility === 'none') + continue; + recalculateLayers(family, this.zoom, availableImages); + const bucket = buckets[layer.id] = layer.createBucket({ + index: featureIndex.bucketLayerIDs.length, + layers: family, + zoom: this.zoom, + pixelRatio: this.pixelRatio, + overscaling: this.overscaling, + collisionBoxArray: this.collisionBoxArray, + sourceLayerIndex, + sourceID: this.source + }); + bucket.populate(features, options, this.tileID.canonical); + featureIndex.bucketLayerIDs.push(family.map((l) => l.id)); + } + } + let error; + let glyphMap; + let iconMap; + let patternMap; + const stacks = performance.mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number)); + this.inFlightDependencies.forEach((request) => request === null || request === void 0 ? void 0 : request.cancel()); + this.inFlightDependencies = []; + // cancelling seems to be not sufficient, we seems to still manage to get a callback hit, so use a sentinel to drop stale results + const dependencySentinel = ++this.dependencySentinel; + if (Object.keys(stacks).length) { + this.inFlightDependencies.push(actor.send('getGlyphs', { uid: this.uid, stacks, source: this.source, tileID: this.tileID, type: 'glyphs' }, (err, result) => { + if (dependencySentinel !== this.dependencySentinel) { + return; + } + if (!error) { + error = err; + glyphMap = result; + maybePrepare.call(this); + } + })); + } + else { + glyphMap = {}; + } + const icons = Object.keys(options.iconDependencies); + if (icons.length) { + this.inFlightDependencies.push(actor.send('getImages', { icons, source: this.source, tileID: this.tileID, type: 'icons' }, (err, result) => { + if (dependencySentinel !== this.dependencySentinel) { + return; + } + if (!error) { + error = err; + iconMap = result; + maybePrepare.call(this); + } + })); + } + else { + iconMap = {}; + } + const patterns = Object.keys(options.patternDependencies); + if (patterns.length) { + this.inFlightDependencies.push(actor.send('getImages', { icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns' }, (err, result) => { + if (dependencySentinel !== this.dependencySentinel) { + return; + } + if (!error) { + error = err; + patternMap = result; + maybePrepare.call(this); + } + })); + } + else { + patternMap = {}; + } + maybePrepare.call(this); + function maybePrepare() { + if (error) { + return callback(error); + } + else if (glyphMap && iconMap && patternMap) { + const glyphAtlas = new GlyphAtlas(glyphMap); + const imageAtlas = new performance.ImageAtlas(iconMap, patternMap); + for (const key in buckets) { + const bucket = buckets[key]; + if (bucket instanceof performance.SymbolBucket) { + recalculateLayers(bucket.layers, this.zoom, availableImages); + performance.performSymbolLayout({ + bucket, + glyphMap, + glyphPositions: glyphAtlas.positions, + imageMap: iconMap, + imagePositions: imageAtlas.iconPositions, + showCollisionBoxes: this.showCollisionBoxes, + canonical: this.tileID.canonical + }); + } + else if (bucket.hasPattern && + (bucket instanceof performance.LineBucket || + bucket instanceof performance.FillBucket || + bucket instanceof performance.FillExtrusionBucket)) { + recalculateLayers(bucket.layers, this.zoom, availableImages); + bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions); + } + } + this.status = 'done'; + callback(null, { + buckets: Object.values(buckets).filter(b => !b.isEmpty()), + featureIndex, + collisionBoxArray: this.collisionBoxArray, + glyphAtlasImage: glyphAtlas.image, + imageAtlas, + // Only used for benchmarking: + glyphMap: this.returnDependencies ? glyphMap : null, + iconMap: this.returnDependencies ? iconMap : null, + glyphPositions: this.returnDependencies ? glyphAtlas.positions : null + }); + } + } + } +} +function recalculateLayers(layers, zoom, availableImages) { + // Layers are shared and may have been used by a WorkerTile with a different zoom. + const parameters = new performance.EvaluationParameters(zoom); + for (const layer of layers) { + layer.recalculate(parameters, availableImages); + } +} + +/** + * Loads a vector tile + */ +function loadVectorTile(params, callback) { + const request = performance.getArrayBuffer(params.request, (err, data, cacheControl, expires) => { + if (err) { + callback(err); + } + else if (data) { + try { + const vectorTile = new performance.vectorTile.VectorTile(new performance.Protobuf(data)); + callback(null, { + vectorTile, + rawData: data, + cacheControl, + expires + }); + } + catch (ex) { + const bytes = new Uint8Array(data); + const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b; + let errorMessage = `Unable to parse the tile at ${params.request.url}, `; + if (isGzipped) { + errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server'; + } + else { + errorMessage += `got error: ${ex.messge}`; + } + callback(new Error(errorMessage)); + } + } + }); + return () => { + request.cancel(); + callback(); + }; +} +/** + * The {@link WorkerSource} implementation that supports {@link VectorTileSource}. + * This class is designed to be easily reused to support custom source types + * for data formats that can be parsed/converted into an in-memory VectorTile + * representation. To do so, create it with + * `new VectorTileWorkerSource(actor, styleLayers, customLoadVectorDataFunction)`. + */ +class VectorTileWorkerSource { + /** + * @param loadVectorData - Optional method for custom loading of a VectorTile + * object based on parameters passed from the main-thread Source. See + * {@link VectorTileWorkerSource#loadTile}. The default implementation simply + * loads the pbf at `params.url`. + */ + constructor(actor, layerIndex, availableImages, loadVectorData) { + this.actor = actor; + this.layerIndex = layerIndex; + this.availableImages = availableImages; + this.loadVectorData = loadVectorData || loadVectorTile; + this.fetching = {}; + this.loading = {}; + this.loaded = {}; + } + /** + * Implements {@link WorkerSource#loadTile}. Delegates to + * {@link VectorTileWorkerSource#loadVectorData} (which by default expects + * a `params.url` property) for fetching and producing a VectorTile object. + */ + loadTile(params, callback) { + const uid = params.uid; + if (!this.loading) + this.loading = {}; + const perf = (params && params.request && params.request.collectResourceTiming) ? + new performance.RequestPerformance(params.request) : false; + const workerTile = this.loading[uid] = new WorkerTile(params); + workerTile.abort = this.loadVectorData(params, (err, response) => { + delete this.loading[uid]; + if (err || !response) { + workerTile.status = 'done'; + this.loaded[uid] = workerTile; + return callback(err); + } + const rawTileData = response.rawData; + const cacheControl = {}; + if (response.expires) + cacheControl.expires = response.expires; + if (response.cacheControl) + cacheControl.cacheControl = response.cacheControl; + const resourceTiming = {}; + if (perf) { + const resourceTimingData = perf.finish(); + // it's necessary to eval the result of getEntriesByName() here via parse/stringify + // late evaluation in the main thread causes TypeError: illegal invocation + if (resourceTimingData) + resourceTiming.resourceTiming = JSON.parse(JSON.stringify(resourceTimingData)); + } + workerTile.vectorTile = response.vectorTile; + workerTile.parse(response.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => { + delete this.fetching[uid]; + if (err || !result) + return callback(err); + // Transferring a copy of rawTileData because the worker needs to retain its copy. + callback(null, performance.extend({ rawTileData: rawTileData.slice(0) }, result, cacheControl, resourceTiming)); + }); + this.loaded = this.loaded || {}; + this.loaded[uid] = workerTile; + // keep the original fetching state so that reload tile can pick it up if the original parse is cancelled by reloads' parse + this.fetching[uid] = { rawTileData, cacheControl, resourceTiming }; + }); + } + /** + * Implements {@link WorkerSource#reloadTile}. + */ + reloadTile(params, callback) { + const loaded = this.loaded; + const uid = params.uid; + if (loaded && loaded[uid]) { + const workerTile = loaded[uid]; + workerTile.showCollisionBoxes = params.showCollisionBoxes; + if (workerTile.status === 'parsing') { + workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => { + if (err || !result) + return callback(err, result); + // if we have cancelled the original parse, make sure to pass the rawTileData from the original fetch + let parseResult; + if (this.fetching[uid]) { + const { rawTileData, cacheControl, resourceTiming } = this.fetching[uid]; + delete this.fetching[uid]; + parseResult = performance.extend({ rawTileData: rawTileData.slice(0) }, result, cacheControl, resourceTiming); + } + else { + parseResult = result; + } + callback(null, parseResult); + }); + } + else if (workerTile.status === 'done') { + // if there was no vector tile data on the initial load, don't try and re-parse tile + if (workerTile.vectorTile) { + workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, callback); + } + else { + callback(); + } + } + } + } + /** + * Implements {@link WorkerSource#abortTile}. + * + * @param params - The tile parameters + * @param callback - The callback + */ + abortTile(params, callback) { + const loading = this.loading, uid = params.uid; + if (loading && loading[uid] && loading[uid].abort) { + loading[uid].abort(); + delete loading[uid]; + } + callback(); + } + /** + * Implements {@link WorkerSource#removeTile}. + * + * @param params - The tile parameters + * @param callback - The callback + */ + removeTile(params, callback) { + const loaded = this.loaded, uid = params.uid; + if (loaded && loaded[uid]) { + delete loaded[uid]; + } + callback(); + } +} + +class RasterDEMTileWorkerSource { + constructor() { + this.loaded = {}; + } + loadTile(params, callback) { + return performance.__awaiter(this, void 0, void 0, function* () { + const { uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift } = params; + const width = rawImageData.width + 2; + const height = rawImageData.height + 2; + const imagePixels = performance.isImageBitmap(rawImageData) ? + new performance.RGBAImage({ width, height }, yield performance.getImageData(rawImageData, -1, -1, width, height)) : + rawImageData; + const dem = new performance.DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift); + this.loaded = this.loaded || {}; + this.loaded[uid] = dem; + callback(null, dem); + }); + } + removeTile(params) { + const loaded = this.loaded, uid = params.uid; + if (loaded && loaded[uid]) { + delete loaded[uid]; + } + } +} + +var geojsonRewind = rewind$1; + +function rewind$1(gj, outer) { + var type = gj && gj.type, i; + + if (type === 'FeatureCollection') { + for (i = 0; i < gj.features.length; i++) rewind$1(gj.features[i], outer); + + } else if (type === 'GeometryCollection') { + for (i = 0; i < gj.geometries.length; i++) rewind$1(gj.geometries[i], outer); + + } else if (type === 'Feature') { + rewind$1(gj.geometry, outer); + + } else if (type === 'Polygon') { + rewindRings(gj.coordinates, outer); + + } else if (type === 'MultiPolygon') { + for (i = 0; i < gj.coordinates.length; i++) rewindRings(gj.coordinates[i], outer); + } + + return gj; +} + +function rewindRings(rings, outer) { + if (rings.length === 0) return; + + rewindRing(rings[0], outer); + for (var i = 1; i < rings.length; i++) { + rewindRing(rings[i], !outer); + } +} + +function rewindRing(ring, dir) { + var area = 0, err = 0; + for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) { + var k = (ring[i][0] - ring[j][0]) * (ring[j][1] + ring[i][1]); + var m = area + k; + err += Math.abs(area) >= Math.abs(k) ? area - m + k : k - m + area; + area = m; + } + if (area + err >= 0 !== !!dir) ring.reverse(); +} + +var rewind$2 = /*@__PURE__*/performance.getDefaultExportFromCjs(geojsonRewind); + +const toGeoJSON = performance.vectorTile.VectorTileFeature.prototype.toGeoJSON; +let FeatureWrapper$1 = class FeatureWrapper { + constructor(feature) { + this._feature = feature; + this.extent = performance.EXTENT; + this.type = feature.type; + this.properties = feature.tags; + // If the feature has a top-level `id` property, copy it over, but only + // if it can be coerced to an integer, because this wrapper is used for + // serializing geojson feature data into vector tile PBF data, and the + // vector tile spec only supports integer values for feature ids -- + // allowing non-integer values here results in a non-compliant PBF + // that causes an exception when it is parsed with vector-tile-js + if ('id' in feature && !isNaN(feature.id)) { + this.id = parseInt(feature.id, 10); + } + } + loadGeometry() { + if (this._feature.type === 1) { + const geometry = []; + for (const point of this._feature.geometry) { + geometry.push([new performance.Point(point[0], point[1])]); + } + return geometry; + } + else { + const geometry = []; + for (const ring of this._feature.geometry) { + const newRing = []; + for (const point of ring) { + newRing.push(new performance.Point(point[0], point[1])); + } + geometry.push(newRing); + } + return geometry; + } + } + toGeoJSON(x, y, z) { + return toGeoJSON.call(this, x, y, z); + } +}; +let GeoJSONWrapper$2 = class GeoJSONWrapper { + constructor(features) { + this.layers = { '_geojsonTileLayer': this }; + this.name = '_geojsonTileLayer'; + this.extent = performance.EXTENT; + this.length = features.length; + this._features = features; + } + feature(i) { + return new FeatureWrapper$1(this._features[i]); + } +}; + +var vtPbf$1 = {exports: {}}; + +'use strict'; + +var Point = performance.pointGeometry; +var VectorTileFeature = performance.vectorTile.VectorTileFeature; + +var geojson_wrapper = GeoJSONWrapper$1; + +// conform to vectortile api +function GeoJSONWrapper$1 (features, options) { + this.options = options || {}; + this.features = features; + this.length = features.length; +} + +GeoJSONWrapper$1.prototype.feature = function (i) { + return new FeatureWrapper(this.features[i], this.options.extent) +}; + +function FeatureWrapper (feature, extent) { + this.id = typeof feature.id === 'number' ? feature.id : undefined; + this.type = feature.type; + this.rawGeometry = feature.type === 1 ? [feature.geometry] : feature.geometry; + this.properties = feature.tags; + this.extent = extent || 4096; +} + +FeatureWrapper.prototype.loadGeometry = function () { + var rings = this.rawGeometry; + this.geometry = []; + + for (var i = 0; i < rings.length; i++) { + var ring = rings[i]; + var newRing = []; + for (var j = 0; j < ring.length; j++) { + newRing.push(new Point(ring[j][0], ring[j][1])); + } + this.geometry.push(newRing); + } + return this.geometry +}; + +FeatureWrapper.prototype.bbox = function () { + if (!this.geometry) this.loadGeometry(); + + var rings = this.geometry; + var x1 = Infinity; + var x2 = -Infinity; + var y1 = Infinity; + var y2 = -Infinity; + + for (var i = 0; i < rings.length; i++) { + var ring = rings[i]; + + for (var j = 0; j < ring.length; j++) { + var coord = ring[j]; + + x1 = Math.min(x1, coord.x); + x2 = Math.max(x2, coord.x); + y1 = Math.min(y1, coord.y); + y2 = Math.max(y2, coord.y); + } + } + + return [x1, y1, x2, y2] +}; + +FeatureWrapper.prototype.toGeoJSON = VectorTileFeature.prototype.toGeoJSON; + +var geojson_wrapper$1 = /*@__PURE__*/performance.getDefaultExportFromCjs(geojson_wrapper); + +var vtPbf = vtPbf$1.exports; + +var Pbf = performance.pbf; +var GeoJSONWrapper = geojson_wrapper; + +vtPbf$1.exports = fromVectorTileJs; +var fromVectorTileJs_1 = vtPbf$1.exports.fromVectorTileJs = fromVectorTileJs; +var fromGeojsonVt_1 = vtPbf$1.exports.fromGeojsonVt = fromGeojsonVt; +var GeoJSONWrapper_1 = vtPbf$1.exports.GeoJSONWrapper = GeoJSONWrapper; + +/** + * Serialize a vector-tile-js-created tile to pbf + * + * @param {Object} tile + * @return {Buffer} uncompressed, pbf-serialized tile data + */ +function fromVectorTileJs (tile) { + var out = new Pbf(); + writeTile(tile, out); + return out.finish() +} + +/** + * Serialized a geojson-vt-created tile to pbf. + * + * @param {Object} layers - An object mapping layer names to geojson-vt-created vector tile objects + * @param {Object} [options] - An object specifying the vector-tile specification version and extent that were used to create `layers`. + * @param {Number} [options.version=1] - Version of vector-tile spec used + * @param {Number} [options.extent=4096] - Extent of the vector tile + * @return {Buffer} uncompressed, pbf-serialized tile data + */ +function fromGeojsonVt (layers, options) { + options = options || {}; + var l = {}; + for (var k in layers) { + l[k] = new GeoJSONWrapper(layers[k].features, options); + l[k].name = k; + l[k].version = options.version; + l[k].extent = options.extent; + } + return fromVectorTileJs({ layers: l }) +} + +function writeTile (tile, pbf) { + for (var key in tile.layers) { + pbf.writeMessage(3, writeLayer, tile.layers[key]); + } +} + +function writeLayer (layer, pbf) { + pbf.writeVarintField(15, layer.version || 1); + pbf.writeStringField(1, layer.name || ''); + pbf.writeVarintField(5, layer.extent || 4096); + + var i; + var context = { + keys: [], + values: [], + keycache: {}, + valuecache: {} + }; + + for (i = 0; i < layer.length; i++) { + context.feature = layer.feature(i); + pbf.writeMessage(2, writeFeature, context); + } + + var keys = context.keys; + for (i = 0; i < keys.length; i++) { + pbf.writeStringField(3, keys[i]); + } + + var values = context.values; + for (i = 0; i < values.length; i++) { + pbf.writeMessage(4, writeValue, values[i]); + } +} + +function writeFeature (context, pbf) { + var feature = context.feature; + + if (feature.id !== undefined) { + pbf.writeVarintField(1, feature.id); + } + + pbf.writeMessage(2, writeProperties, context); + pbf.writeVarintField(3, feature.type); + pbf.writeMessage(4, writeGeometry, feature); +} + +function writeProperties (context, pbf) { + var feature = context.feature; + var keys = context.keys; + var values = context.values; + var keycache = context.keycache; + var valuecache = context.valuecache; + + for (var key in feature.properties) { + var value = feature.properties[key]; + + var keyIndex = keycache[key]; + if (value === null) continue // don't encode null value properties + + if (typeof keyIndex === 'undefined') { + keys.push(key); + keyIndex = keys.length - 1; + keycache[key] = keyIndex; + } + pbf.writeVarint(keyIndex); + + var type = typeof value; + if (type !== 'string' && type !== 'boolean' && type !== 'number') { + value = JSON.stringify(value); + } + var valueKey = type + ':' + value; + var valueIndex = valuecache[valueKey]; + if (typeof valueIndex === 'undefined') { + values.push(value); + valueIndex = values.length - 1; + valuecache[valueKey] = valueIndex; + } + pbf.writeVarint(valueIndex); + } +} + +function command (cmd, length) { + return (length << 3) + (cmd & 0x7) +} + +function zigzag (num) { + return (num << 1) ^ (num >> 31) +} + +function writeGeometry (feature, pbf) { + var geometry = feature.loadGeometry(); + var type = feature.type; + var x = 0; + var y = 0; + var rings = geometry.length; + for (var r = 0; r < rings; r++) { + var ring = geometry[r]; + var count = 1; + if (type === 1) { + count = ring.length; + } + pbf.writeVarint(command(1, count)); // moveto + // do not write polygon closing path as lineto + var lineCount = type === 3 ? ring.length - 1 : ring.length; + for (var i = 0; i < lineCount; i++) { + if (i === 1 && type !== 1) { + pbf.writeVarint(command(2, lineCount - 1)); // lineto + } + var dx = ring[i].x - x; + var dy = ring[i].y - y; + pbf.writeVarint(zigzag(dx)); + pbf.writeVarint(zigzag(dy)); + x += dx; + y += dy; + } + if (type === 3) { + pbf.writeVarint(command(7, 1)); // closepath + } + } +} + +function writeValue (value, pbf) { + var type = typeof value; + if (type === 'string') { + pbf.writeStringField(1, value); + } else if (type === 'boolean') { + pbf.writeBooleanField(7, value); + } else if (type === 'number') { + if (value % 1 !== 0) { + pbf.writeDoubleField(3, value); + } else if (value < 0) { + pbf.writeSVarintField(6, value); + } else { + pbf.writeVarintField(5, value); + } + } +} + +var vtPbfExports = vtPbf$1.exports; +var vtpbf = /*@__PURE__*/performance.getDefaultExportFromCjs(vtPbfExports); + +const defaultOptions = { + minZoom: 0, // min zoom to generate clusters on + maxZoom: 16, // max zoom level to cluster the points on + minPoints: 2, // minimum points to form a cluster + radius: 40, // cluster radius in pixels + extent: 512, // tile extent (radius is calculated relative to it) + nodeSize: 64, // size of the KD-tree leaf node, affects performance + log: false, // whether to log timing info + + // whether to generate numeric ids for input features (in vector tiles) + generateId: false, + + // a reduce function for calculating custom cluster properties + reduce: null, // (accumulated, props) => { accumulated.sum += props.sum; } + + // properties to use for individual points when running the reducer + map: props => props // props => ({sum: props.my_value}) +}; + +const fround = Math.fround || (tmp => ((x) => { tmp[0] = +x; return tmp[0]; }))(new Float32Array(1)); + +const OFFSET_ZOOM = 2; +const OFFSET_ID = 3; +const OFFSET_PARENT = 4; +const OFFSET_NUM = 5; +const OFFSET_PROP = 6; + +class Supercluster { + constructor(options) { + this.options = Object.assign(Object.create(defaultOptions), options); + this.trees = new Array(this.options.maxZoom + 1); + this.stride = this.options.reduce ? 7 : 6; + this.clusterProps = []; + } + + load(points) { + const {log, minZoom, maxZoom} = this.options; + + if (log) console.time('total time'); + + const timerId = `prepare ${ points.length } points`; + if (log) console.time(timerId); + + this.points = points; + + // generate a cluster object for each point and index input points into a KD-tree + const data = []; + + for (let i = 0; i < points.length; i++) { + const p = points[i]; + if (!p.geometry) continue; + + const [lng, lat] = p.geometry.coordinates; + const x = fround(lngX(lng)); + const y = fround(latY(lat)); + // store internal point/cluster data in flat numeric arrays for performance + data.push( + x, y, // projected point coordinates + Infinity, // the last zoom the point was processed at + i, // index of the source feature in the original input array + -1, // parent cluster id + 1 // number of points in a cluster + ); + if (this.options.reduce) data.push(0); // noop + } + let tree = this.trees[maxZoom + 1] = this._createTree(data); + + if (log) console.timeEnd(timerId); + + // cluster points on max zoom, then cluster the results on previous zoom, etc.; + // results in a cluster hierarchy across zoom levels + for (let z = maxZoom; z >= minZoom; z--) { + const now = +Date.now(); + + // create a new set of clusters for the zoom and index them with a KD-tree + tree = this.trees[z] = this._createTree(this._cluster(tree, z)); + + if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, +Date.now() - now); + } + + if (log) console.timeEnd('total time'); + + return this; + } + + getClusters(bbox, zoom) { + let minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180; + const minLat = Math.max(-90, Math.min(90, bbox[1])); + let maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180; + const maxLat = Math.max(-90, Math.min(90, bbox[3])); + + if (bbox[2] - bbox[0] >= 360) { + minLng = -180; + maxLng = 180; + } else if (minLng > maxLng) { + const easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom); + const westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom); + return easternHem.concat(westernHem); + } + + const tree = this.trees[this._limitZoom(zoom)]; + const ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat)); + const data = tree.data; + const clusters = []; + for (const id of ids) { + const k = this.stride * id; + clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]); + } + return clusters; + } + + getChildren(clusterId) { + const originId = this._getOriginId(clusterId); + const originZoom = this._getOriginZoom(clusterId); + const errorMsg = 'No cluster with the specified id.'; + + const tree = this.trees[originZoom]; + if (!tree) throw new Error(errorMsg); + + const data = tree.data; + if (originId * this.stride >= data.length) throw new Error(errorMsg); + + const r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1)); + const x = data[originId * this.stride]; + const y = data[originId * this.stride + 1]; + const ids = tree.within(x, y, r); + const children = []; + for (const id of ids) { + const k = id * this.stride; + if (data[k + OFFSET_PARENT] === clusterId) { + children.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]); + } + } + + if (children.length === 0) throw new Error(errorMsg); + + return children; + } + + getLeaves(clusterId, limit, offset) { + limit = limit || 10; + offset = offset || 0; + + const leaves = []; + this._appendLeaves(leaves, clusterId, limit, offset, 0); + + return leaves; + } + + getTile(z, x, y) { + const tree = this.trees[this._limitZoom(z)]; + const z2 = Math.pow(2, z); + const {extent, radius} = this.options; + const p = radius / extent; + const top = (y - p) / z2; + const bottom = (y + 1 + p) / z2; + + const tile = { + features: [] + }; + + this._addTileFeatures( + tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom), + tree.data, x, y, z2, tile); + + if (x === 0) { + this._addTileFeatures( + tree.range(1 - p / z2, top, 1, bottom), + tree.data, z2, y, z2, tile); + } + if (x === z2 - 1) { + this._addTileFeatures( + tree.range(0, top, p / z2, bottom), + tree.data, -1, y, z2, tile); + } + + return tile.features.length ? tile : null; + } + + getClusterExpansionZoom(clusterId) { + let expansionZoom = this._getOriginZoom(clusterId) - 1; + while (expansionZoom <= this.options.maxZoom) { + const children = this.getChildren(clusterId); + expansionZoom++; + if (children.length !== 1) break; + clusterId = children[0].properties.cluster_id; + } + return expansionZoom; + } + + _appendLeaves(result, clusterId, limit, offset, skipped) { + const children = this.getChildren(clusterId); + + for (const child of children) { + const props = child.properties; + + if (props && props.cluster) { + if (skipped + props.point_count <= offset) { + // skip the whole cluster + skipped += props.point_count; + } else { + // enter the cluster + skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped); + // exit the cluster + } + } else if (skipped < offset) { + // skip a single point + skipped++; + } else { + // add a single point + result.push(child); + } + if (result.length === limit) break; + } + + return skipped; + } + + _createTree(data) { + const tree = new performance.KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array); + for (let i = 0; i < data.length; i += this.stride) tree.add(data[i], data[i + 1]); + tree.finish(); + tree.data = data; + return tree; + } + + _addTileFeatures(ids, data, x, y, z2, tile) { + for (const i of ids) { + const k = i * this.stride; + const isCluster = data[k + OFFSET_NUM] > 1; + + let tags, px, py; + if (isCluster) { + tags = getClusterProperties(data, k, this.clusterProps); + px = data[k]; + py = data[k + 1]; + } else { + const p = this.points[data[k + OFFSET_ID]]; + tags = p.properties; + const [lng, lat] = p.geometry.coordinates; + px = lngX(lng); + py = latY(lat); + } + + const f = { + type: 1, + geometry: [[ + Math.round(this.options.extent * (px * z2 - x)), + Math.round(this.options.extent * (py * z2 - y)) + ]], + tags + }; + + // assign id + let id; + if (isCluster || this.options.generateId) { + // optionally generate id for points + id = data[k + OFFSET_ID]; + } else { + // keep id if already assigned + id = this.points[data[k + OFFSET_ID]].id; + } + + if (id !== undefined) f.id = id; + + tile.features.push(f); + } + } + + _limitZoom(z) { + return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1)); + } + + _cluster(tree, zoom) { + const {radius, extent, reduce, minPoints} = this.options; + const r = radius / (extent * Math.pow(2, zoom)); + const data = tree.data; + const nextData = []; + const stride = this.stride; + + // loop through each point + for (let i = 0; i < data.length; i += stride) { + // if we've already visited the point at this zoom level, skip it + if (data[i + OFFSET_ZOOM] <= zoom) continue; + data[i + OFFSET_ZOOM] = zoom; + + // find all nearby points + const x = data[i]; + const y = data[i + 1]; + const neighborIds = tree.within(data[i], data[i + 1], r); + + const numPointsOrigin = data[i + OFFSET_NUM]; + let numPoints = numPointsOrigin; + + // count the number of points in a potential cluster + for (const neighborId of neighborIds) { + const k = neighborId * stride; + // filter out neighbors that are already processed + if (data[k + OFFSET_ZOOM] > zoom) numPoints += data[k + OFFSET_NUM]; + } + + // if there were neighbors to merge, and there are enough points to form a cluster + if (numPoints > numPointsOrigin && numPoints >= minPoints) { + let wx = x * numPointsOrigin; + let wy = y * numPointsOrigin; + + let clusterProperties; + let clusterPropIndex = -1; + + // encode both zoom and point index on which the cluster originated -- offset by total length of features + const id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length; + + for (const neighborId of neighborIds) { + const k = neighborId * stride; + + if (data[k + OFFSET_ZOOM] <= zoom) continue; + data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice) + + const numPoints2 = data[k + OFFSET_NUM]; + wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center + wy += data[k + 1] * numPoints2; + + data[k + OFFSET_PARENT] = id; + + if (reduce) { + if (!clusterProperties) { + clusterProperties = this._map(data, i, true); + clusterPropIndex = this.clusterProps.length; + this.clusterProps.push(clusterProperties); + } + reduce(clusterProperties, this._map(data, k)); + } + } + + data[i + OFFSET_PARENT] = id; + nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints); + if (reduce) nextData.push(clusterPropIndex); + + } else { // left points as unclustered + for (let j = 0; j < stride; j++) nextData.push(data[i + j]); + + if (numPoints > 1) { + for (const neighborId of neighborIds) { + const k = neighborId * stride; + if (data[k + OFFSET_ZOOM] <= zoom) continue; + data[k + OFFSET_ZOOM] = zoom; + for (let j = 0; j < stride; j++) nextData.push(data[k + j]); + } + } + } + } + + return nextData; + } + + // get index of the point from which the cluster originated + _getOriginId(clusterId) { + return (clusterId - this.points.length) >> 5; + } + + // get zoom of the point from which the cluster originated + _getOriginZoom(clusterId) { + return (clusterId - this.points.length) % 32; + } + + _map(data, i, clone) { + if (data[i + OFFSET_NUM] > 1) { + const props = this.clusterProps[data[i + OFFSET_PROP]]; + return clone ? Object.assign({}, props) : props; + } + const original = this.points[data[i + OFFSET_ID]].properties; + const result = this.options.map(original); + return clone && result === original ? Object.assign({}, result) : result; + } +} + +function getClusterJSON(data, i, clusterProps) { + return { + type: 'Feature', + id: data[i + OFFSET_ID], + properties: getClusterProperties(data, i, clusterProps), + geometry: { + type: 'Point', + coordinates: [xLng(data[i]), yLat(data[i + 1])] + } + }; +} + +function getClusterProperties(data, i, clusterProps) { + const count = data[i + OFFSET_NUM]; + const abbrev = + count >= 10000 ? `${Math.round(count / 1000) }k` : + count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count; + const propIndex = data[i + OFFSET_PROP]; + const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]); + return Object.assign(properties, { + cluster: true, + cluster_id: data[i + OFFSET_ID], + point_count: count, + point_count_abbreviated: abbrev + }); +} + +// longitude/latitude to spherical mercator in [0..1] range +function lngX(lng) { + return lng / 360 + 0.5; +} +function latY(lat) { + const sin = Math.sin(lat * Math.PI / 180); + const y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI); + return y < 0 ? 0 : y > 1 ? 1 : y; +} + +// spherical mercator to longitude/latitude +function xLng(x) { + return (x - 0.5) * 360; +} +function yLat(y) { + const y2 = (180 - y * 360) * Math.PI / 180; + return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90; +} + +// calculate simplification data using optimized Douglas-Peucker algorithm + +function simplify(coords, first, last, sqTolerance) { + var maxSqDist = sqTolerance; + var mid = (last - first) >> 1; + var minPosToMid = last - first; + var index; + + var ax = coords[first]; + var ay = coords[first + 1]; + var bx = coords[last]; + var by = coords[last + 1]; + + for (var i = first + 3; i < last; i += 3) { + var d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by); + + if (d > maxSqDist) { + index = i; + maxSqDist = d; + + } else if (d === maxSqDist) { + // a workaround to ensure we choose a pivot close to the middle of the list, + // reducing recursion depth, for certain degenerate inputs + // https://github.com/mapbox/geojson-vt/issues/104 + var posToMid = Math.abs(i - mid); + if (posToMid < minPosToMid) { + index = i; + minPosToMid = posToMid; + } + } + } + + if (maxSqDist > sqTolerance) { + if (index - first > 3) simplify(coords, first, index, sqTolerance); + coords[index + 2] = maxSqDist; + if (last - index > 3) simplify(coords, index, last, sqTolerance); + } +} + +// square distance from a point to a segment +function getSqSegDist(px, py, x, y, bx, by) { + + var dx = bx - x; + var dy = by - y; + + if (dx !== 0 || dy !== 0) { + + var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy); + + if (t > 1) { + x = bx; + y = by; + + } else if (t > 0) { + x += dx * t; + y += dy * t; + } + } + + dx = px - x; + dy = py - y; + + return dx * dx + dy * dy; +} + +function createFeature(id, type, geom, tags) { + var feature = { + id: typeof id === 'undefined' ? null : id, + type: type, + geometry: geom, + tags: tags, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; + calcBBox(feature); + return feature; +} + +function calcBBox(feature) { + var geom = feature.geometry; + var type = feature.type; + + if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') { + calcLineBBox(feature, geom); + + } else if (type === 'Polygon' || type === 'MultiLineString') { + for (var i = 0; i < geom.length; i++) { + calcLineBBox(feature, geom[i]); + } + + } else if (type === 'MultiPolygon') { + for (i = 0; i < geom.length; i++) { + for (var j = 0; j < geom[i].length; j++) { + calcLineBBox(feature, geom[i][j]); + } + } + } +} + +function calcLineBBox(feature, geom) { + for (var i = 0; i < geom.length; i += 3) { + feature.minX = Math.min(feature.minX, geom[i]); + feature.minY = Math.min(feature.minY, geom[i + 1]); + feature.maxX = Math.max(feature.maxX, geom[i]); + feature.maxY = Math.max(feature.maxY, geom[i + 1]); + } +} + +// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data + +function convert(data, options) { + var features = []; + if (data.type === 'FeatureCollection') { + for (var i = 0; i < data.features.length; i++) { + convertFeature(features, data.features[i], options, i); + } + + } else if (data.type === 'Feature') { + convertFeature(features, data, options); + + } else { + // single geometry or a geometry collection + convertFeature(features, {geometry: data}, options); + } + + return features; +} + +function convertFeature(features, geojson, options, index) { + if (!geojson.geometry) return; + + var coords = geojson.geometry.coordinates; + var type = geojson.geometry.type; + var tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2); + var geometry = []; + var id = geojson.id; + if (options.promoteId) { + id = geojson.properties[options.promoteId]; + } else if (options.generateId) { + id = index || 0; + } + if (type === 'Point') { + convertPoint(coords, geometry); + + } else if (type === 'MultiPoint') { + for (var i = 0; i < coords.length; i++) { + convertPoint(coords[i], geometry); + } + + } else if (type === 'LineString') { + convertLine(coords, geometry, tolerance, false); + + } else if (type === 'MultiLineString') { + if (options.lineMetrics) { + // explode into linestrings to be able to track metrics + for (i = 0; i < coords.length; i++) { + geometry = []; + convertLine(coords[i], geometry, tolerance, false); + features.push(createFeature(id, 'LineString', geometry, geojson.properties)); + } + return; + } else { + convertLines(coords, geometry, tolerance, false); + } + + } else if (type === 'Polygon') { + convertLines(coords, geometry, tolerance, true); + + } else if (type === 'MultiPolygon') { + for (i = 0; i < coords.length; i++) { + var polygon = []; + convertLines(coords[i], polygon, tolerance, true); + geometry.push(polygon); + } + } else if (type === 'GeometryCollection') { + for (i = 0; i < geojson.geometry.geometries.length; i++) { + convertFeature(features, { + id: id, + geometry: geojson.geometry.geometries[i], + properties: geojson.properties + }, options, index); + } + return; + } else { + throw new Error('Input data is not a valid GeoJSON object.'); + } + + features.push(createFeature(id, type, geometry, geojson.properties)); +} + +function convertPoint(coords, out) { + out.push(projectX(coords[0])); + out.push(projectY(coords[1])); + out.push(0); +} + +function convertLine(ring, out, tolerance, isPolygon) { + var x0, y0; + var size = 0; + + for (var j = 0; j < ring.length; j++) { + var x = projectX(ring[j][0]); + var y = projectY(ring[j][1]); + + out.push(x); + out.push(y); + out.push(0); + + if (j > 0) { + if (isPolygon) { + size += (x0 * y - x * y0) / 2; // area + } else { + size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length + } + } + x0 = x; + y0 = y; + } + + var last = out.length - 3; + out[2] = 1; + simplify(out, 0, last, tolerance); + out[last + 2] = 1; + + out.size = Math.abs(size); + out.start = 0; + out.end = out.size; +} + +function convertLines(rings, out, tolerance, isPolygon) { + for (var i = 0; i < rings.length; i++) { + var geom = []; + convertLine(rings[i], geom, tolerance, isPolygon); + out.push(geom); + } +} + +function projectX(x) { + return x / 360 + 0.5; +} + +function projectY(y) { + var sin = Math.sin(y * Math.PI / 180); + var y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI; + return y2 < 0 ? 0 : y2 > 1 ? 1 : y2; +} + +/* clip features between two axis-parallel lines: + * | | + * ___|___ | / + * / | \____|____/ + * | | + */ + +function clip(features, scale, k1, k2, axis, minAll, maxAll, options) { + + k1 /= scale; + k2 /= scale; + + if (minAll >= k1 && maxAll < k2) return features; // trivial accept + else if (maxAll < k1 || minAll >= k2) return null; // trivial reject + + var clipped = []; + + for (var i = 0; i < features.length; i++) { + + var feature = features[i]; + var geometry = feature.geometry; + var type = feature.type; + + var min = axis === 0 ? feature.minX : feature.minY; + var max = axis === 0 ? feature.maxX : feature.maxY; + + if (min >= k1 && max < k2) { // trivial accept + clipped.push(feature); + continue; + } else if (max < k1 || min >= k2) { // trivial reject + continue; + } + + var newGeometry = []; + + if (type === 'Point' || type === 'MultiPoint') { + clipPoints(geometry, newGeometry, k1, k2, axis); + + } else if (type === 'LineString') { + clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics); + + } else if (type === 'MultiLineString') { + clipLines(geometry, newGeometry, k1, k2, axis, false); + + } else if (type === 'Polygon') { + clipLines(geometry, newGeometry, k1, k2, axis, true); + + } else if (type === 'MultiPolygon') { + for (var j = 0; j < geometry.length; j++) { + var polygon = []; + clipLines(geometry[j], polygon, k1, k2, axis, true); + if (polygon.length) { + newGeometry.push(polygon); + } + } + } + + if (newGeometry.length) { + if (options.lineMetrics && type === 'LineString') { + for (j = 0; j < newGeometry.length; j++) { + clipped.push(createFeature(feature.id, type, newGeometry[j], feature.tags)); + } + continue; + } + + if (type === 'LineString' || type === 'MultiLineString') { + if (newGeometry.length === 1) { + type = 'LineString'; + newGeometry = newGeometry[0]; + } else { + type = 'MultiLineString'; + } + } + if (type === 'Point' || type === 'MultiPoint') { + type = newGeometry.length === 3 ? 'Point' : 'MultiPoint'; + } + + clipped.push(createFeature(feature.id, type, newGeometry, feature.tags)); + } + } + + return clipped.length ? clipped : null; +} + +function clipPoints(geom, newGeom, k1, k2, axis) { + for (var i = 0; i < geom.length; i += 3) { + var a = geom[i + axis]; + + if (a >= k1 && a <= k2) { + newGeom.push(geom[i]); + newGeom.push(geom[i + 1]); + newGeom.push(geom[i + 2]); + } + } +} + +function clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) { + + var slice = newSlice(geom); + var intersect = axis === 0 ? intersectX : intersectY; + var len = geom.start; + var segLen, t; + + for (var i = 0; i < geom.length - 3; i += 3) { + var ax = geom[i]; + var ay = geom[i + 1]; + var az = geom[i + 2]; + var bx = geom[i + 3]; + var by = geom[i + 4]; + var a = axis === 0 ? ax : ay; + var b = axis === 0 ? bx : by; + var exited = false; + + if (trackMetrics) segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2)); + + if (a < k1) { + // ---|--> | (line enters the clip region from the left) + if (b > k1) { + t = intersect(slice, ax, ay, bx, by, k1); + if (trackMetrics) slice.start = len + segLen * t; + } + } else if (a > k2) { + // | <--|--- (line enters the clip region from the right) + if (b < k2) { + t = intersect(slice, ax, ay, bx, by, k2); + if (trackMetrics) slice.start = len + segLen * t; + } + } else { + addPoint(slice, ax, ay, az); + } + if (b < k1 && a >= k1) { + // <--|--- | or <--|-----|--- (line exits the clip region on the left) + t = intersect(slice, ax, ay, bx, by, k1); + exited = true; + } + if (b > k2 && a <= k2) { + // | ---|--> or ---|-----|--> (line exits the clip region on the right) + t = intersect(slice, ax, ay, bx, by, k2); + exited = true; + } + + if (!isPolygon && exited) { + if (trackMetrics) slice.end = len + segLen * t; + newGeom.push(slice); + slice = newSlice(geom); + } + + if (trackMetrics) len += segLen; + } + + // add the last point + var last = geom.length - 3; + ax = geom[last]; + ay = geom[last + 1]; + az = geom[last + 2]; + a = axis === 0 ? ax : ay; + if (a >= k1 && a <= k2) addPoint(slice, ax, ay, az); + + // close the polygon if its endpoints are not the same after clipping + last = slice.length - 3; + if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) { + addPoint(slice, slice[0], slice[1], slice[2]); + } + + // add the final slice + if (slice.length) { + newGeom.push(slice); + } +} + +function newSlice(line) { + var slice = []; + slice.size = line.size; + slice.start = line.start; + slice.end = line.end; + return slice; +} + +function clipLines(geom, newGeom, k1, k2, axis, isPolygon) { + for (var i = 0; i < geom.length; i++) { + clipLine(geom[i], newGeom, k1, k2, axis, isPolygon, false); + } +} + +function addPoint(out, x, y, z) { + out.push(x); + out.push(y); + out.push(z); +} + +function intersectX(out, ax, ay, bx, by, x) { + var t = (x - ax) / (bx - ax); + out.push(x); + out.push(ay + (by - ay) * t); + out.push(1); + return t; +} + +function intersectY(out, ax, ay, bx, by, y) { + var t = (y - ay) / (by - ay); + out.push(ax + (bx - ax) * t); + out.push(y); + out.push(1); + return t; +} + +function wrap(features, options) { + var buffer = options.buffer / options.extent; + var merged = features; + var left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy + var right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy + + if (left || right) { + merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy + + if (left) merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center + if (right) merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center + } + + return merged; +} + +function shiftFeatureCoords(features, offset) { + var newFeatures = []; + + for (var i = 0; i < features.length; i++) { + var feature = features[i], + type = feature.type; + + var newGeometry; + + if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') { + newGeometry = shiftCoords(feature.geometry, offset); + + } else if (type === 'MultiLineString' || type === 'Polygon') { + newGeometry = []; + for (var j = 0; j < feature.geometry.length; j++) { + newGeometry.push(shiftCoords(feature.geometry[j], offset)); + } + } else if (type === 'MultiPolygon') { + newGeometry = []; + for (j = 0; j < feature.geometry.length; j++) { + var newPolygon = []; + for (var k = 0; k < feature.geometry[j].length; k++) { + newPolygon.push(shiftCoords(feature.geometry[j][k], offset)); + } + newGeometry.push(newPolygon); + } + } + + newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags)); + } + + return newFeatures; +} + +function shiftCoords(points, offset) { + var newPoints = []; + newPoints.size = points.size; + + if (points.start !== undefined) { + newPoints.start = points.start; + newPoints.end = points.end; + } + + for (var i = 0; i < points.length; i += 3) { + newPoints.push(points[i] + offset, points[i + 1], points[i + 2]); + } + return newPoints; +} + +// Transforms the coordinates of each feature in the given tile from +// mercator-projected space into (extent x extent) tile space. +function transformTile(tile, extent) { + if (tile.transformed) return tile; + + var z2 = 1 << tile.z, + tx = tile.x, + ty = tile.y, + i, j, k; + + for (i = 0; i < tile.features.length; i++) { + var feature = tile.features[i], + geom = feature.geometry, + type = feature.type; + + feature.geometry = []; + + if (type === 1) { + for (j = 0; j < geom.length; j += 2) { + feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty)); + } + } else { + for (j = 0; j < geom.length; j++) { + var ring = []; + for (k = 0; k < geom[j].length; k += 2) { + ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty)); + } + feature.geometry.push(ring); + } + } + } + + tile.transformed = true; + + return tile; +} + +function transformPoint(x, y, extent, z2, tx, ty) { + return [ + Math.round(extent * (x * z2 - tx)), + Math.round(extent * (y * z2 - ty))]; +} + +function createTile(features, z, tx, ty, options) { + var tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent); + var tile = { + features: [], + numPoints: 0, + numSimplified: 0, + numFeatures: 0, + source: null, + x: tx, + y: ty, + z: z, + transformed: false, + minX: 2, + minY: 1, + maxX: -1, + maxY: 0 + }; + for (var i = 0; i < features.length; i++) { + tile.numFeatures++; + addFeature(tile, features[i], tolerance, options); + + var minX = features[i].minX; + var minY = features[i].minY; + var maxX = features[i].maxX; + var maxY = features[i].maxY; + + if (minX < tile.minX) tile.minX = minX; + if (minY < tile.minY) tile.minY = minY; + if (maxX > tile.maxX) tile.maxX = maxX; + if (maxY > tile.maxY) tile.maxY = maxY; + } + return tile; +} + +function addFeature(tile, feature, tolerance, options) { + + var geom = feature.geometry, + type = feature.type, + simplified = []; + + if (type === 'Point' || type === 'MultiPoint') { + for (var i = 0; i < geom.length; i += 3) { + simplified.push(geom[i]); + simplified.push(geom[i + 1]); + tile.numPoints++; + tile.numSimplified++; + } + + } else if (type === 'LineString') { + addLine(simplified, geom, tile, tolerance, false, false); + + } else if (type === 'MultiLineString' || type === 'Polygon') { + for (i = 0; i < geom.length; i++) { + addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0); + } + + } else if (type === 'MultiPolygon') { + + for (var k = 0; k < geom.length; k++) { + var polygon = geom[k]; + for (i = 0; i < polygon.length; i++) { + addLine(simplified, polygon[i], tile, tolerance, true, i === 0); + } + } + } + + if (simplified.length) { + var tags = feature.tags || null; + if (type === 'LineString' && options.lineMetrics) { + tags = {}; + for (var key in feature.tags) tags[key] = feature.tags[key]; + tags['mapbox_clip_start'] = geom.start / geom.size; + tags['mapbox_clip_end'] = geom.end / geom.size; + } + var tileFeature = { + geometry: simplified, + type: type === 'Polygon' || type === 'MultiPolygon' ? 3 : + type === 'LineString' || type === 'MultiLineString' ? 2 : 1, + tags: tags + }; + if (feature.id !== null) { + tileFeature.id = feature.id; + } + tile.features.push(tileFeature); + } +} + +function addLine(result, geom, tile, tolerance, isPolygon, isOuter) { + var sqTolerance = tolerance * tolerance; + + if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) { + tile.numPoints += geom.length / 3; + return; + } + + var ring = []; + + for (var i = 0; i < geom.length; i += 3) { + if (tolerance === 0 || geom[i + 2] > sqTolerance) { + tile.numSimplified++; + ring.push(geom[i]); + ring.push(geom[i + 1]); + } + tile.numPoints++; + } + + if (isPolygon) rewind(ring, isOuter); + + result.push(ring); +} + +function rewind(ring, clockwise) { + var area = 0; + for (var i = 0, len = ring.length, j = len - 2; i < len; j = i, i += 2) { + area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]); + } + if (area > 0 === clockwise) { + for (i = 0, len = ring.length; i < len / 2; i += 2) { + var x = ring[i]; + var y = ring[i + 1]; + ring[i] = ring[len - 2 - i]; + ring[i + 1] = ring[len - 1 - i]; + ring[len - 2 - i] = x; + ring[len - 1 - i] = y; + } + } +} + +function geojsonvt(data, options) { + return new GeoJSONVT(data, options); +} + +function GeoJSONVT(data, options) { + options = this.options = extend(Object.create(this.options), options); + + var debug = options.debug; + + if (debug) console.time('preprocess data'); + + if (options.maxZoom < 0 || options.maxZoom > 24) throw new Error('maxZoom should be in the 0-24 range'); + if (options.promoteId && options.generateId) throw new Error('promoteId and generateId cannot be used together.'); + + var features = convert(data, options); + + this.tiles = {}; + this.tileCoords = []; + + if (debug) { + console.timeEnd('preprocess data'); + console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints); + console.time('generate tiles'); + this.stats = {}; + this.total = 0; + } + + features = wrap(features, options); + + // start slicing from the top tile down + if (features.length) this.splitTile(features, 0, 0, 0); + + if (debug) { + if (features.length) console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints); + console.timeEnd('generate tiles'); + console.log('tiles generated:', this.total, JSON.stringify(this.stats)); + } +} + +GeoJSONVT.prototype.options = { + maxZoom: 14, // max zoom to preserve detail on + indexMaxZoom: 5, // max zoom in the tile index + indexMaxPoints: 100000, // max number of points per tile in the tile index + tolerance: 3, // simplification tolerance (higher means simpler) + extent: 4096, // tile extent + buffer: 64, // tile buffer on each side + lineMetrics: false, // whether to calculate line metrics + promoteId: null, // name of a feature property to be promoted to feature.id + generateId: false, // whether to generate feature ids. Cannot be used with promoteId + debug: 0 // logging level (0, 1 or 2) +}; + +GeoJSONVT.prototype.splitTile = function (features, z, x, y, cz, cx, cy) { + + var stack = [features, z, x, y], + options = this.options, + debug = options.debug; + + // avoid recursion by using a processing queue + while (stack.length) { + y = stack.pop(); + x = stack.pop(); + z = stack.pop(); + features = stack.pop(); + + var z2 = 1 << z, + id = toID(z, x, y), + tile = this.tiles[id]; + + if (!tile) { + if (debug > 1) console.time('creation'); + + tile = this.tiles[id] = createTile(features, z, x, y, options); + this.tileCoords.push({z: z, x: x, y: y}); + + if (debug) { + if (debug > 1) { + console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', + z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified); + console.timeEnd('creation'); + } + var key = 'z' + z; + this.stats[key] = (this.stats[key] || 0) + 1; + this.total++; + } + } + + // save reference to original geometry in tile so that we can drill down later if we stop now + tile.source = features; + + // if it's the first-pass tiling + if (!cz) { + // stop tiling if we reached max zoom, or if the tile is too simple + if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue; + + // if a drilldown to a specific tile + } else { + // stop tiling if we reached base zoom or our target tile zoom + if (z === options.maxZoom || z === cz) continue; + + // stop tiling if it's not an ancestor of the target tile + var m = 1 << (cz - z); + if (x !== Math.floor(cx / m) || y !== Math.floor(cy / m)) continue; + } + + // if we slice further down, no need to keep source geometry + tile.source = null; + + if (features.length === 0) continue; + + if (debug > 1) console.time('clipping'); + + // values we'll use for clipping + var k1 = 0.5 * options.buffer / options.extent, + k2 = 0.5 - k1, + k3 = 0.5 + k1, + k4 = 1 + k1, + tl, bl, tr, br, left, right; + + tl = bl = tr = br = null; + + left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options); + right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options); + features = null; + + if (left) { + tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options); + bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options); + left = null; + } + + if (right) { + tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options); + br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options); + right = null; + } + + if (debug > 1) console.timeEnd('clipping'); + + stack.push(tl || [], z + 1, x * 2, y * 2); + stack.push(bl || [], z + 1, x * 2, y * 2 + 1); + stack.push(tr || [], z + 1, x * 2 + 1, y * 2); + stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1); + } +}; + +GeoJSONVT.prototype.getTile = function (z, x, y) { + var options = this.options, + extent = options.extent, + debug = options.debug; + + if (z < 0 || z > 24) return null; + + var z2 = 1 << z; + x = ((x % z2) + z2) % z2; // wrap tile x coordinate + + var id = toID(z, x, y); + if (this.tiles[id]) return transformTile(this.tiles[id], extent); + + if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y); + + var z0 = z, + x0 = x, + y0 = y, + parent; + + while (!parent && z0 > 0) { + z0--; + x0 = Math.floor(x0 / 2); + y0 = Math.floor(y0 / 2); + parent = this.tiles[toID(z0, x0, y0)]; + } + + if (!parent || !parent.source) return null; + + // if we found a parent tile containing the original geometry, we can drill down from it + if (debug > 1) console.log('found parent tile z%d-%d-%d', z0, x0, y0); + + if (debug > 1) console.time('drilling down'); + this.splitTile(parent.source, z0, x0, y0, z, x, y); + if (debug > 1) console.timeEnd('drilling down'); + + return this.tiles[id] ? transformTile(this.tiles[id], extent) : null; +}; + +function toID(z, x, y) { + return (((1 << z) * y + x) * 32) + z; +} + +function extend(dest, src) { + for (var i in src) dest[i] = src[i]; + return dest; +} + +function getFeatureId(feature, promoteId) { + return promoteId ? feature.properties[promoteId] : feature.id; +} +function isUpdateableGeoJSON(data, promoteId) { + // null can be updated + if (data == null) { + return true; + } + // a single feature with an id can be updated, need to explicitly check against null because 0 is a valid feature id that is falsy + if (data.type === 'Feature') { + return getFeatureId(data, promoteId) != null; + } + // a feature collection can be updated if every feature has an id, and the ids are all unique + // this prevents us from silently dropping features if ids get reused + if (data.type === 'FeatureCollection') { + const seenIds = new Set(); + for (const feature of data.features) { + const id = getFeatureId(feature, promoteId); + if (id == null) { + return false; + } + if (seenIds.has(id)) { + return false; + } + seenIds.add(id); + } + return true; + } + return false; +} +function toUpdateable(data, promoteId) { + const result = new Map(); + if (data == null) { + // empty result + } + else if (data.type === 'Feature') { + result.set(getFeatureId(data, promoteId), data); + } + else { + for (const feature of data.features) { + result.set(getFeatureId(feature, promoteId), feature); + } + } + return result; +} +// mutates updateable +function applySourceDiff(updateable, diff, promoteId) { + var _a, _b, _c, _d; + if (diff.removeAll) { + updateable.clear(); + } + if (diff.remove) { + for (const id of diff.remove) { + updateable.delete(id); + } + } + if (diff.add) { + for (const feature of diff.add) { + const id = getFeatureId(feature, promoteId); + if (id != null) { + updateable.set(id, feature); + } + } + } + if (diff.update) { + for (const update of diff.update) { + let feature = updateable.get(update.id); + if (feature == null) { + continue; + } + // be careful to clone the feature and/or properties objects to avoid mutating our input + const cloneFeature = update.newGeometry || update.removeAllProperties; + // note: removeAllProperties gives us a new properties object, so we can skip the clone step + const cloneProperties = !update.removeAllProperties && (((_a = update.removeProperties) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = update.addOrUpdateProperties) === null || _b === void 0 ? void 0 : _b.length) > 0); + if (cloneFeature || cloneProperties) { + feature = Object.assign({}, feature); + updateable.set(update.id, feature); + if (cloneProperties) { + feature.properties = Object.assign({}, feature.properties); + } + } + if (update.newGeometry) { + feature.geometry = update.newGeometry; + } + if (update.removeAllProperties) { + feature.properties = {}; + } + else if (((_c = update.removeProperties) === null || _c === void 0 ? void 0 : _c.length) > 0) { + for (const prop of update.removeProperties) { + if (Object.prototype.hasOwnProperty.call(feature.properties, prop)) { + delete feature.properties[prop]; + } + } + } + if (((_d = update.addOrUpdateProperties) === null || _d === void 0 ? void 0 : _d.length) > 0) { + for (const { key, value } of update.addOrUpdateProperties) { + feature.properties[key] = value; + } + } + } + } +} + +/** + * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}. + * This class is designed to be easily reused to support custom source types + * for data formats that can be parsed/converted into an in-memory GeoJSON + * representation. To do so, create it with + * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`. + * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson). + */ +class GeoJSONWorkerSource extends VectorTileWorkerSource { + /** + * @param loadGeoJSON - Optional method for custom loading/parsing of + * GeoJSON based on parameters passed from the main-thread Source. + * See {@link GeoJSONWorkerSource#loadGeoJSON}. + */ + constructor(actor, layerIndex, availableImages, loadGeoJSON) { + super(actor, layerIndex, availableImages); + this._dataUpdateable = new Map(); + /** + * Fetch and parse GeoJSON according to the given params. Calls `callback` + * with `(err, data)`, where `data` is a parsed GeoJSON object. + * + * GeoJSON is loaded and parsed from `params.url` if it exists, or else + * expected as a literal (string or object) `params.data`. + * + * @param params - the parameters + * @param callback - the callback for completion or error + * @returns A Cancelable object. + */ + this.loadGeoJSON = (params, callback) => { + const { promoteId } = params; + // Because of same origin issues, urls must either include an explicit + // origin or absolute path. + // ie: /foo/bar.json or http://example.com/bar.json + // but not ../foo/bar.json + if (params.request) { + return performance.getJSON(params.request, (error, data, cacheControl, expires) => { + this._dataUpdateable = isUpdateableGeoJSON(data, promoteId) ? toUpdateable(data, promoteId) : undefined; + callback(error, data, cacheControl, expires); + }); + } + else if (typeof params.data === 'string') { + try { + const parsed = JSON.parse(params.data); + this._dataUpdateable = isUpdateableGeoJSON(parsed, promoteId) ? toUpdateable(parsed, promoteId) : undefined; + callback(null, parsed); + } + catch (e) { + callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); + } + } + else if (params.dataDiff) { + if (this._dataUpdateable) { + applySourceDiff(this._dataUpdateable, params.dataDiff, promoteId); + callback(null, { type: 'FeatureCollection', features: Array.from(this._dataUpdateable.values()) }); + } + else { + callback(new Error(`Cannot update existing geojson data in ${params.source}`)); + } + } + else { + callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); + } + return { cancel: () => { } }; + }; + this.loadVectorData = this.loadGeoJSONTile; + if (loadGeoJSON) { + this.loadGeoJSON = loadGeoJSON; + } + } + loadGeoJSONTile(params, callback) { + const canonical = params.tileID.canonical; + if (!this._geoJSONIndex) { + return callback(null, null); // we couldn't load the file + } + const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y); + if (!geoJSONTile) { + return callback(null, null); // nothing in the given tile + } + const geojsonWrapper = new GeoJSONWrapper$2(geoJSONTile.features); + // Encode the geojson-vt tile into binary vector tile form. This + // is a convenience that allows `FeatureIndex` to operate the same way + // across `VectorTileSource` and `GeoJSONSource` data. + let pbf = vtpbf(geojsonWrapper); + if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) { + // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35) + pbf = new Uint8Array(pbf); + } + callback(null, { + vectorTile: geojsonWrapper, + rawData: pbf.buffer + }); + } + /** + * Fetches (if appropriate), parses, and index geojson data into tiles. This + * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile} + * can correctly serve up tiles. + * + * Defers to {@link GeoJSONWorkerSource#loadGeoJSON} for the fetching/parsing, + * expecting `callback(error, data)` to be called with either an error or a + * parsed GeoJSON object. + * + * When a `loadData` request comes in while a previous one is being processed, + * the previous one is aborted. + * + * @param params - the parameters + * @param callback - the callback for completion or error + */ + loadData(params, callback) { + var _a; + (_a = this._pendingRequest) === null || _a === void 0 ? void 0 : _a.cancel(); + if (this._pendingCallback) { + // Tell the foreground the previous call has been abandoned + this._pendingCallback(null, { abandoned: true }); + } + const perf = (params && params.request && params.request.collectResourceTiming) ? + new performance.RequestPerformance(params.request) : false; + this._pendingCallback = callback; + this._pendingRequest = this.loadGeoJSON(params, (err, data) => { + delete this._pendingCallback; + delete this._pendingRequest; + if (err || !data) { + return callback(err); + } + else if (typeof data !== 'object') { + return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); + } + else { + rewind$2(data, true); + try { + if (params.filter) { + const compiled = performance.createExpression(params.filter, { type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false }); + if (compiled.result === 'error') + throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', ')); + const features = data.features.filter(feature => compiled.value.evaluate({ zoom: 0 }, feature)); + data = { type: 'FeatureCollection', features }; + } + this._geoJSONIndex = params.cluster ? + new Supercluster(getSuperclusterOptions(params)).load(data.features) : + geojsonvt(data, params.geojsonVtOptions); + } + catch (err) { + return callback(err); + } + this.loaded = {}; + const result = {}; + if (perf) { + const resourceTimingData = perf.finish(); + // it's necessary to eval the result of getEntriesByName() here via parse/stringify + // late evaluation in the main thread causes TypeError: illegal invocation + if (resourceTimingData) { + result.resourceTiming = {}; + result.resourceTiming[params.source] = JSON.parse(JSON.stringify(resourceTimingData)); + } + } + callback(null, result); + } + }); + } + /** + * Implements {@link WorkerSource#reloadTile}. + * + * If the tile is loaded, uses the implementation in VectorTileWorkerSource. + * Otherwise, such as after a setData() call, we load the tile fresh. + * + * @param params - the parameters + * @param callback - the callback for completion or error + */ + reloadTile(params, callback) { + const loaded = this.loaded, uid = params.uid; + if (loaded && loaded[uid]) { + return super.reloadTile(params, callback); + } + else { + return this.loadTile(params, callback); + } + } + removeSource(params, callback) { + if (this._pendingCallback) { + // Don't leak callbacks + this._pendingCallback(null, { abandoned: true }); + } + callback(); + } + getClusterExpansionZoom(params, callback) { + try { + callback(null, this._geoJSONIndex.getClusterExpansionZoom(params.clusterId)); + } + catch (e) { + callback(e); + } + } + getClusterChildren(params, callback) { + try { + callback(null, this._geoJSONIndex.getChildren(params.clusterId)); + } + catch (e) { + callback(e); + } + } + getClusterLeaves(params, callback) { + try { + callback(null, this._geoJSONIndex.getLeaves(params.clusterId, params.limit, params.offset)); + } + catch (e) { + callback(e); + } + } +} +function getSuperclusterOptions({ superclusterOptions, clusterProperties }) { + if (!clusterProperties || !superclusterOptions) + return superclusterOptions; + const mapExpressions = {}; + const reduceExpressions = {}; + const globals = { accumulated: null, zoom: 0 }; + const feature = { properties: null }; + const propertyNames = Object.keys(clusterProperties); + for (const key of propertyNames) { + const [operator, mapExpression] = clusterProperties[key]; + const mapExpressionParsed = performance.createExpression(mapExpression); + const reduceExpressionParsed = performance.createExpression(typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator); + mapExpressions[key] = mapExpressionParsed.value; + reduceExpressions[key] = reduceExpressionParsed.value; + } + superclusterOptions.map = (pointProperties) => { + feature.properties = pointProperties; + const properties = {}; + for (const key of propertyNames) { + properties[key] = mapExpressions[key].evaluate(globals, feature); + } + return properties; + }; + superclusterOptions.reduce = (accumulated, clusterProperties) => { + feature.properties = clusterProperties; + for (const key of propertyNames) { + globals.accumulated = accumulated[key]; + accumulated[key] = reduceExpressions[key].evaluate(globals, feature); + } + }; + return superclusterOptions; +} + +/** + * The Worker class responsidble for background thread related execution + */ +class Worker { + constructor(self) { + this.self = self; + this.actor = new performance.Actor(self, this); + this.layerIndexes = {}; + this.availableImages = {}; + this.workerSourceTypes = { + vector: VectorTileWorkerSource, + geojson: GeoJSONWorkerSource + }; + // [mapId][sourceType][sourceName] => worker source instance + this.workerSources = {}; + this.demWorkerSources = {}; + this.self.registerWorkerSource = (name, WorkerSource) => { + if (this.workerSourceTypes[name]) { + throw new Error(`Worker source with name "${name}" already registered.`); + } + this.workerSourceTypes[name] = WorkerSource; + }; + // This is invoked by the RTL text plugin when the download via the `importScripts` call has finished, and the code has been parsed. + this.self.registerRTLTextPlugin = (rtlTextPlugin) => { + if (performance.plugin.isParsed()) { + throw new Error('RTL text plugin already registered.'); + } + performance.plugin['applyArabicShaping'] = rtlTextPlugin.applyArabicShaping; + performance.plugin['processBidirectionalText'] = rtlTextPlugin.processBidirectionalText; + performance.plugin['processStyledBidirectionalText'] = rtlTextPlugin.processStyledBidirectionalText; + }; + } + setReferrer(mapID, referrer) { + this.referrer = referrer; + } + setImages(mapId, images, callback) { + this.availableImages[mapId] = images; + for (const workerSource in this.workerSources[mapId]) { + const ws = this.workerSources[mapId][workerSource]; + for (const source in ws) { + ws[source].availableImages = images; + } + } + callback(); + } + setLayers(mapId, layers, callback) { + this.getLayerIndex(mapId).replace(layers); + callback(); + } + updateLayers(mapId, params, callback) { + this.getLayerIndex(mapId).update(params.layers, params.removedIds); + callback(); + } + loadTile(mapId, params, callback) { + this.getWorkerSource(mapId, params.type, params.source).loadTile(params, callback); + } + loadDEMTile(mapId, params, callback) { + this.getDEMWorkerSource(mapId, params.source).loadTile(params, callback); + } + reloadTile(mapId, params, callback) { + this.getWorkerSource(mapId, params.type, params.source).reloadTile(params, callback); + } + abortTile(mapId, params, callback) { + this.getWorkerSource(mapId, params.type, params.source).abortTile(params, callback); + } + removeTile(mapId, params, callback) { + this.getWorkerSource(mapId, params.type, params.source).removeTile(params, callback); + } + removeDEMTile(mapId, params) { + this.getDEMWorkerSource(mapId, params.source).removeTile(params); + } + removeSource(mapId, params, callback) { + if (!this.workerSources[mapId] || + !this.workerSources[mapId][params.type] || + !this.workerSources[mapId][params.type][params.source]) { + return; + } + const worker = this.workerSources[mapId][params.type][params.source]; + delete this.workerSources[mapId][params.type][params.source]; + if (worker.removeSource !== undefined) { + worker.removeSource(params, callback); + } + else { + callback(); + } + } + /** + * Load a {@link WorkerSource} script at params.url. The script is run + * (using importScripts) with `registerWorkerSource` in scope, which is a + * function taking `(name, workerSourceObject)`. + */ + loadWorkerSource(map, params, callback) { + try { + this.self.importScripts(params.url); + callback(); + } + catch (e) { + callback(e.toString()); + } + } + syncRTLPluginState(map, state, callback) { + try { + performance.plugin.setState(state); + const pluginURL = performance.plugin.getPluginURL(); + if (performance.plugin.isLoaded() && + !performance.plugin.isParsed() && + pluginURL != null // Not possible when `isLoaded` is true, but keeps flow happy + ) { + this.self.importScripts(pluginURL); + const complete = performance.plugin.isParsed(); + const error = complete ? undefined : new Error(`RTL Text Plugin failed to import scripts from ${pluginURL}`); + callback(error, complete); + } + } + catch (e) { + callback(e.toString()); + } + } + getAvailableImages(mapId) { + let availableImages = this.availableImages[mapId]; + if (!availableImages) { + availableImages = []; + } + return availableImages; + } + getLayerIndex(mapId) { + let layerIndexes = this.layerIndexes[mapId]; + if (!layerIndexes) { + layerIndexes = this.layerIndexes[mapId] = new StyleLayerIndex(); + } + return layerIndexes; + } + getWorkerSource(mapId, sourceType, sourceName) { + if (!this.workerSources[mapId]) + this.workerSources[mapId] = {}; + if (!this.workerSources[mapId][sourceType]) + this.workerSources[mapId][sourceType] = {}; + if (!this.workerSources[mapId][sourceType][sourceName]) { + // use a wrapped actor so that we can attach a target mapId param + // to any messages invoked by the WorkerSource + const actor = { + send: (type, data, callback) => { + this.actor.send(type, data, callback, mapId); + } + }; + this.workerSources[mapId][sourceType][sourceName] = new this.workerSourceTypes[sourceType](actor, this.getLayerIndex(mapId), this.getAvailableImages(mapId)); + } + return this.workerSources[mapId][sourceType][sourceName]; + } + getDEMWorkerSource(mapId, source) { + if (!this.demWorkerSources[mapId]) + this.demWorkerSources[mapId] = {}; + if (!this.demWorkerSources[mapId][source]) { + this.demWorkerSources[mapId][source] = new RasterDEMTileWorkerSource(); + } + return this.demWorkerSources[mapId][source]; + } +} +if (performance.isWorker()) { + self.worker = new Worker(self); +} + +return Worker; + +})); + +define(['./shared'], (function (performance) { 'use strict'; + +var name = "maplibre-gl"; +var description = "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library"; +var version$2 = "3.6.2"; +var main = "dist/maplibre-gl.js"; +var style = "dist/maplibre-gl.css"; +var license = "BSD-3-Clause"; +var funding = "https://github.com/maplibre/maplibre-gl-js?sponsor=1"; +var repository = { + type: "git", + url: "git://github.com/maplibre/maplibre-gl-js.git" +}; +var types = "dist/maplibre-gl.d.ts"; +var type = "module"; +var dependencies = { + "@mapbox/geojson-rewind": "^0.5.2", + "@mapbox/jsonlint-lines-primitives": "^2.0.2", + "@mapbox/point-geometry": "^0.1.0", + "@mapbox/tiny-sdf": "^2.0.6", + "@mapbox/unitbezier": "^0.0.1", + "@mapbox/vector-tile": "^1.3.1", + "@mapbox/whoots-js": "^3.1.0", + "@maplibre/maplibre-gl-style-spec": "^19.3.3", + "@types/geojson": "^7946.0.13", + "@types/mapbox__point-geometry": "^0.1.4", + "@types/mapbox__vector-tile": "^1.3.4", + "@types/pbf": "^3.0.5", + "@types/supercluster": "^7.1.3", + earcut: "^2.2.4", + "geojson-vt": "^3.2.1", + "gl-matrix": "^3.4.3", + "global-prefix": "^3.0.0", + kdbush: "^4.0.2", + "murmurhash-js": "^1.0.0", + pbf: "^3.2.1", + potpack: "^2.0.0", + quickselect: "^2.0.0", + supercluster: "^8.0.1", + tinyqueue: "^2.0.3", + "vt-pbf": "^3.1.3" +}; +var devDependencies = { + "@mapbox/mapbox-gl-rtl-text": "^0.2.3", + "@mapbox/mvt-fixtures": "^3.10.0", + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.0.1", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-replace": "^5.0.5", + "@rollup/plugin-strip": "^3.0.4", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.5", + "@types/benchmark": "^2.1.5", + "@types/cssnano": "^5.0.0", + "@types/d3": "^7.4.3", + "@types/diff": "^5.0.8", + "@types/earcut": "^2.1.4", + "@types/eslint": "^8.44.7", + "@types/geojson-vt": "3.2.4", + "@types/gl": "^6.0.5", + "@types/glob": "^8.1.0", + "@types/jest": "^29.5.8", + "@types/jsdom": "^21.1.5", + "@types/minimist": "^1.2.5", + "@types/murmurhash-js": "^1.0.6", + "@types/nise": "^1.4.4", + "@types/node": "^20.9.2", + "@types/offscreencanvas": "^2019.7.3", + "@types/pixelmatch": "^5.2.6", + "@types/pngjs": "^6.0.4", + "@types/react": "^18.2.37", + "@types/react-dom": "^18.2.15", + "@types/request": "^2.48.12", + "@types/shuffle-seed": "^1.1.2", + "@types/window-or-global": "^1.0.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + address: "^2.0.1", + benchmark: "^2.1.4", + canvas: "^2.11.2", + cssnano: "^6.0.1", + d3: "^7.8.5", + "d3-queue": "^3.0.7", + "devtools-protocol": "^0.0.1226504", + diff: "^5.1.0", + "dts-bundle-generator": "^8.1.2", + eslint: "^8.54.0", + "eslint-config-mourner": "^3.0.0", + "eslint-plugin-html": "^7.1.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-jest": "^27.6.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-tsdoc": "0.2.17", + expect: "^29.7.0", + gl: "^6.0.2", + glob: "^10.3.10", + "is-builtin-module": "^3.2.1", + jest: "^29.7.0", + "jest-canvas-mock": "^2.5.2", + "jest-environment-jsdom": "^29.7.0", + jsdom: "^22.1.0", + "json-stringify-pretty-compact": "^4.0.0", + minimist: "^1.2.8", + "mock-geolocation": "^1.0.11", + nise: "^5.1.5", + "npm-font-open-sans": "^1.1.0", + "npm-run-all": "^4.1.5", + "pdf-merger-js": "^4.3.0", + pixelmatch: "^5.3.0", + pngjs: "^7.0.0", + postcss: "^8.4.31", + "postcss-cli": "^10.1.0", + "postcss-inline-svg": "^6.0.0", + "pretty-bytes": "^6.1.1", + puppeteer: "^21.5.2", + react: "^18.2.0", + "react-dom": "^18.2.0", + rollup: "^4.5.0", + "rollup-plugin-sourcemaps": "^0.6.3", + rw: "^1.3.3", + semver: "^7.5.4", + "shuffle-seed": "^1.1.6", + "source-map-explorer": "^2.5.3", + st: "^3.0.0", + stylelint: "^15.11.0", + "stylelint-config-standard": "^34.0.0", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.1", + tslib: "^2.6.2", + typedoc: "^0.25.3", + "typedoc-plugin-markdown": "^3.17.1", + "typedoc-plugin-missing-exports": "^2.1.0", + typescript: "^5.2.2" +}; +var overrides = { + "postcss-inline-svg": { + "css-select": "^5.1.0", + "dom-serializer": "^2.0.0", + htmlparser2: "^8.0.1", + "postcss-value-parser": "^4.2.0" + } +}; +var scripts = { + "generate-dist-package": "npm run tsnode build/generate-dist-package.js", + "generate-shaders": "npm run tsnode build/generate-shaders.ts", + "generate-struct-arrays": "npm run tsnode build/generate-struct-arrays.ts", + "generate-style-code": "npm run tsnode build/generate-style-code.ts", + "generate-typings": "npm run tsnode build/generate-typings.ts", + "generate-docs": "typedoc && npm run tsnode build/generate-docs.ts", + "generate-images": "npm run tsnode build/generate-doc-images.ts", + "build-dist": "run-p --print-label generate-typings build-dev build-prod build-csp build-csp-dev build-css", + "build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev", + "watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch", + "build-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production", + "build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts", + "build-csp-dev": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev", + "build-css": "postcss -o dist/maplibre-gl.css src/css/maplibre-gl.css", + "watch-css": "postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css", + "build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts", + "watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch", + "start-server": "st --no-cache -H 0.0.0.0 --port 9966 .", + "start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material", + start: "run-p watch-css watch-dev start-server", + "start-bench": "run-p watch-css watch-benchmarks start-server", + lint: "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .", + "lint-css": "stylelint src/css/maplibre-gl.css", + test: "run-p lint lint-css test-render jest", + jest: "jest", + "jest-ci": "jest --reporters=github-actions --reporters=summary", + "test-build": "jest --selectProjects=build", + "test-integration": "jest --selectProjects=integration", + "test-render": "npm run tsnode test/integration/render/run_render_tests.ts", + "test-unit": "jest --selectProjects=unit", + "test-watch-roots": "jest --watch", + codegen: "run-p generate-dist-package generate-style-code generate-struct-arrays generate-shaders", + benchmark: "npm run tsnode test/bench/run-benchmarks.ts", + "gl-stats": "npm run tsnode test/bench/gl-stats.ts", + prepare: "npm run codegen", + typecheck: "tsc --noEmit && tsc --project tsconfig.dist.json", + tsnode: "node --experimental-loader=ts-node/esm --no-warnings" +}; +var files = [ + "build/", + "dist/*", + "src/" +]; +var engines = { + npm: ">=8.1.0", + node: ">=16.14.0" +}; +var packageJSON = { + name: name, + description: description, + version: version$2, + main: main, + style: style, + license: license, + funding: funding, + repository: repository, + types: types, + type: type, + dependencies: dependencies, + devDependencies: devDependencies, + overrides: overrides, + scripts: scripts, + files: files, + engines: engines +}; + +class DOM { + static testProp(props) { + if (!DOM.docStyle) + return props[0]; + for (let i = 0; i < props.length; i++) { + if (props[i] in DOM.docStyle) { + return props[i]; + } + } + return props[0]; + } + static create(tagName, className, container) { + const el = window.document.createElement(tagName); + if (className !== undefined) + el.className = className; + if (container) + container.appendChild(el); + return el; + } + static createNS(namespaceURI, tagName) { + const el = window.document.createElementNS(namespaceURI, tagName); + return el; + } + static disableDrag() { + if (DOM.docStyle && DOM.selectProp) { + DOM.userSelect = DOM.docStyle[DOM.selectProp]; + DOM.docStyle[DOM.selectProp] = 'none'; + } + } + static enableDrag() { + if (DOM.docStyle && DOM.selectProp) { + DOM.docStyle[DOM.selectProp] = DOM.userSelect; + } + } + static setTransform(el, value) { + el.style[DOM.transformProp] = value; + } + static addEventListener(target, type, callback, options = {}) { + if ('passive' in options) { + target.addEventListener(type, callback, options); + } + else { + target.addEventListener(type, callback, options.capture); + } + } + static removeEventListener(target, type, callback, options = {}) { + if ('passive' in options) { + target.removeEventListener(type, callback, options); + } + else { + target.removeEventListener(type, callback, options.capture); + } + } + // Suppress the next click, but only if it's immediate. + static suppressClickInternal(e) { + e.preventDefault(); + e.stopPropagation(); + window.removeEventListener('click', DOM.suppressClickInternal, true); + } + static suppressClick() { + window.addEventListener('click', DOM.suppressClickInternal, true); + window.setTimeout(() => { + window.removeEventListener('click', DOM.suppressClickInternal, true); + }, 0); + } + static mousePos(el, e) { + const rect = el.getBoundingClientRect(); + return new performance.Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop); + } + static touchPos(el, touches) { + const rect = el.getBoundingClientRect(); + const points = []; + for (let i = 0; i < touches.length; i++) { + points.push(new performance.Point(touches[i].clientX - rect.left - el.clientLeft, touches[i].clientY - rect.top - el.clientTop)); + } + return points; + } + static mouseButton(e) { + return e.button; + } + static remove(node) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } +} +DOM.docStyle = typeof window !== 'undefined' && window.document && window.document.documentElement.style; +DOM.selectProp = DOM.testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']); +DOM.transformProp = DOM.testProp(['transform', 'WebkitTransform']); + +const webpSupported = { + supported: false, + testSupport +}; +let glForTesting; +let webpCheckComplete = false; +let webpImgTest; +let webpImgTestOnloadComplete = false; +if (typeof document !== 'undefined') { + webpImgTest = document.createElement('img'); + webpImgTest.onload = function () { + if (glForTesting) + testWebpTextureUpload(glForTesting); + glForTesting = null; + webpImgTestOnloadComplete = true; + }; + webpImgTest.onerror = function () { + webpCheckComplete = true; + glForTesting = null; + }; + webpImgTest.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA='; +} +function testSupport(gl) { + if (webpCheckComplete || !webpImgTest) + return; + // HTMLImageElement.complete is set when an image is done loading it's source + // regardless of whether the load was successful or not. + // It's possible for an error to set HTMLImageElement.complete to true which would trigger + // testWebpTextureUpload and mistakenly set exported.supported to true in browsers which don't support webp + // To avoid this, we set a flag in the image's onload handler and only call testWebpTextureUpload + // after a successful image load event. + if (webpImgTestOnloadComplete) { + testWebpTextureUpload(gl); + } + else { + glForTesting = gl; + } +} +function testWebpTextureUpload(gl) { + // Edge 18 supports WebP but not uploading a WebP image to a gl texture + // Test support for this before allowing WebP images. + // https://github.com/mapbox/mapbox-gl-js/issues/7671 + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + try { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, webpImgTest); + // The error does not get triggered in Edge if the context is lost + if (gl.isContextLost()) + return; + webpSupported.supported = true; + } + catch (e) { + // Catch "Unspecified Error." in Edge 18. + } + gl.deleteTexture(texture); + webpCheckComplete = true; +} + +/** + * By default, the image queue is self driven, meaning as soon as one requested item is processed, + * it will move on to next one as quickly as it can while limiting + * the number of concurrent requests to MAX_PARALLEL_IMAGE_REQUESTS. The default behavior + * ensures that static views of the map can be rendered with minimal delay. + * + * However, the default behavior can prevent dynamic views of the map from rendering + * smoothly in that many requests can finish in one render frame, putting too much pressure on GPU. + * + * When the view of the map is moving dynamically, smoother frame rates can be achieved + * by throttling the number of items processed by the queue per frame. This can be + * accomplished by using {@link addThrottleControl} to allow the caller to + * use a lambda function to determine when the queue should be throttled (e.g. when isMoving()) + * and manually calling {@link processQueue} in the render loop. + */ +var ImageRequest; +(function (ImageRequest) { + let imageRequestQueue; + let currentParallelImageRequests; + let throttleControlCallbackHandleCounter; + let throttleControlCallbacks; + /** + * Reset the image request queue, removing all pending requests. + */ + ImageRequest.resetRequestQueue = () => { + imageRequestQueue = []; + currentParallelImageRequests = 0; + throttleControlCallbackHandleCounter = 0; + throttleControlCallbacks = {}; + }; + /** + * Install a callback to control when image queue throttling is desired. + * (e.g. when the map view is moving) + * @param callback - The callback function to install + * @returns handle that identifies the installed callback. + */ + ImageRequest.addThrottleControl = (callback) => { + const handle = throttleControlCallbackHandleCounter++; + throttleControlCallbacks[handle] = callback; + return handle; + }; + /** + * Remove a previously installed callback by passing in the handle returned + * by {@link addThrottleControl}. + * @param callbackHandle - The handle for the callback to remove. + */ + ImageRequest.removeThrottleControl = (callbackHandle) => { + delete throttleControlCallbacks[callbackHandle]; + // Try updating the queue + processQueue(); + }; + /** + * Check to see if any of the installed callbacks are requesting the queue + * to be throttled. + * @returns `true` if any callback is causing the queue to be throttled. + */ + const isThrottled = () => { + const allControlKeys = Object.keys(throttleControlCallbacks); + let throttleingRequested = false; + if (allControlKeys.length > 0) { + for (const key of allControlKeys) { + throttleingRequested = throttleControlCallbacks[key](); + if (throttleingRequested) { + break; + } + } + } + return throttleingRequested; + }; + /** + * Request to load an image. + * @param requestParameters - Request parameters. + * @param callback - Callback to issue when the request completes. + * @param supportImageRefresh - `true`, if the image request need to support refresh based on cache headers. + * @returns Cancelable request. + */ + ImageRequest.getImage = (requestParameters, callback, supportImageRefresh = true) => { + if (webpSupported.supported) { + if (!requestParameters.headers) { + requestParameters.headers = {}; + } + requestParameters.headers.accept = 'image/webp,*/*'; + } + const request = { + requestParameters, + supportImageRefresh, + callback, + cancelled: false, + completed: false, + cancel: () => { + if (!request.completed && !request.cancelled) { + request.cancelled = true; + // Only reduce currentParallelImageRequests, if the image request was issued. + if (request.innerRequest) { + request.innerRequest.cancel(); + currentParallelImageRequests--; + } + // in the case of cancelling, it WILL move on + processQueue(); + } + } + }; + imageRequestQueue.push(request); + processQueue(); + return request; + }; + const arrayBufferToCanvasImageSource = (data, callback) => { + const imageBitmapSupported = typeof createImageBitmap === 'function'; + if (imageBitmapSupported) { + performance.arrayBufferToImageBitmap(data, callback); + } + else { + performance.arrayBufferToImage(data, callback); + } + }; + const doImageRequest = (itemInQueue) => { + const { requestParameters, supportImageRefresh, callback } = itemInQueue; + performance.extend(requestParameters, { type: 'image' }); + // - If refreshExpiredTiles is false, then we can use HTMLImageElement to download raster images. + // - Fetch/XHR (via MakeRequest API) will be used to download images for following scenarios: + // 1. Style image sprite will had a issue with HTMLImageElement as described + // here: https://github.com/mapbox/mapbox-gl-js/issues/1470 + // 2. If refreshExpiredTiles is true (default), then in order to read the image cache header, + // fetch/XHR request will be required + // - For any special case handling like use of AddProtocol, worker initiated request or additional headers + // let makeRequest handle it. + // - HtmlImageElement request automatically adds accept header for all the browser supported images + const canUseHTMLImageElement = supportImageRefresh === false && + !performance.isWorker() && + !performance.getProtocolAction(requestParameters.url) && + (!requestParameters.headers || + Object.keys(requestParameters.headers).reduce((acc, item) => acc && item === 'accept', true)); + const action = canUseHTMLImageElement ? getImageUsingHtmlImage : performance.makeRequest; + return action(requestParameters, (err, data, cacheControl, expires) => { + onImageResponse(itemInQueue, callback, err, data, cacheControl, expires); + }); + }; + const onImageResponse = (itemInQueue, callback, err, data, cacheControl, expires) => { + if (err) { + callback(err); + } + else if (data instanceof HTMLImageElement || performance.isImageBitmap(data)) { + // User using addProtocol can directly return HTMLImageElement/ImageBitmap type + // If HtmlImageElement is used to get image then response type will be HTMLImageElement + callback(null, data); + } + else if (data) { + const decoratedCallback = (imgErr, imgResult) => { + if (imgErr != null) { + callback(imgErr); + } + else if (imgResult != null) { + callback(null, imgResult, { cacheControl, expires }); + } + }; + arrayBufferToCanvasImageSource(data, decoratedCallback); + } + if (!itemInQueue.cancelled) { + itemInQueue.completed = true; + currentParallelImageRequests--; + processQueue(); + } + }; + /** + * Process some number of items in the image request queue. + */ + const processQueue = () => { + const maxImageRequests = isThrottled() ? + performance.config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME : + performance.config.MAX_PARALLEL_IMAGE_REQUESTS; + // limit concurrent image loads to help with raster sources performance on big screens + for (let numImageRequests = currentParallelImageRequests; numImageRequests < maxImageRequests && imageRequestQueue.length > 0; numImageRequests++) { + const topItemInQueue = imageRequestQueue.shift(); + if (topItemInQueue.cancelled) { + numImageRequests--; + continue; + } + const innerRequest = doImageRequest(topItemInQueue); + currentParallelImageRequests++; + topItemInQueue.innerRequest = innerRequest; + } + }; + const getImageUsingHtmlImage = (requestParameters, callback) => { + const image = new Image(); + const url = requestParameters.url; + let requestCancelled = false; + const credentials = requestParameters.credentials; + if (credentials && credentials === 'include') { + image.crossOrigin = 'use-credentials'; + } + else if ((credentials && credentials === 'same-origin') || !performance.sameOrigin(url)) { + image.crossOrigin = 'anonymous'; + } + image.fetchPriority = 'high'; + image.onload = () => { + callback(null, image); + image.onerror = image.onload = null; + }; + image.onerror = () => { + if (!requestCancelled) { + callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.')); + } + image.onerror = image.onload = null; + }; + image.src = url; + return { + cancel: () => { + requestCancelled = true; + // Set src to '' to actually cancel the request + image.src = ''; + } + }; + }; +})(ImageRequest || (ImageRequest = {})); +ImageRequest.resetRequestQueue(); + +/** + * A type of MapLibre resource. + */ +var ResourceType; +(function (ResourceType) { + ResourceType["Glyphs"] = "Glyphs"; + ResourceType["Image"] = "Image"; + ResourceType["Source"] = "Source"; + ResourceType["SpriteImage"] = "SpriteImage"; + ResourceType["SpriteJSON"] = "SpriteJSON"; + ResourceType["Style"] = "Style"; + ResourceType["Tile"] = "Tile"; + ResourceType["Unknown"] = "Unknown"; +})(ResourceType || (ResourceType = {})); +class RequestManager { + constructor(transformRequestFn) { + this._transformRequestFn = transformRequestFn; + } + transformRequest(url, type) { + if (this._transformRequestFn) { + return this._transformRequestFn(url, type) || { url }; + } + return { url }; + } + normalizeSpriteURL(url, format, extension) { + const urlObject = parseUrl(url); + urlObject.path += `${format}${extension}`; + return formatUrl(urlObject); + } + setTransformRequest(transformRequest) { + this._transformRequestFn = transformRequest; + } +} +const urlRe = /^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/; +function parseUrl(url) { + const parts = url.match(urlRe); + if (!parts) { + throw new Error(`Unable to parse URL "${url}"`); + } + return { + protocol: parts[1], + authority: parts[2], + path: parts[3] || '/', + params: parts[4] ? parts[4].split('&') : [] + }; +} +function formatUrl(obj) { + const params = obj.params.length ? `?${obj.params.join('&')}` : ''; + return `${obj.protocol}://${obj.authority}${obj.path}${params}`; +} + +/** + * Takes a SpriteSpecification value and returns it in its array form. If `undefined` is passed as an input value, an + * empty array is returned. + * duplicated entries with identical id/url will be removed in returned array + * @param sprite - optional sprite to coerce + * @returns an empty array in case `undefined` is passed; id-url pairs otherwise + */ +function coerceSpriteToArray(sprite) { + const resultArray = []; + if (typeof sprite === 'string') { + resultArray.push({ id: 'default', url: sprite }); + } + else if (sprite && sprite.length > 0) { + const dedupArray = []; + for (const { id, url } of sprite) { + const key = `${id}${url}`; + if (dedupArray.indexOf(key) === -1) { + dedupArray.push(key); + resultArray.push({ id, url }); + } + } + } + return resultArray; +} + +function loadSprite(originalSprite, requestManager, pixelRatio, callback) { + const spriteArray = coerceSpriteToArray(originalSprite); + const spriteArrayLength = spriteArray.length; + const format = pixelRatio > 1 ? '@2x' : ''; + const combinedRequestsMap = {}; + const jsonsMap = {}; + const imagesMap = {}; + for (const { id, url } of spriteArray) { + const jsonRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.json'), ResourceType.SpriteJSON); + const jsonRequestKey = `${id}_${jsonRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique + combinedRequestsMap[jsonRequestKey] = performance.getJSON(jsonRequestParameters, (err, data) => { + delete combinedRequestsMap[jsonRequestKey]; + jsonsMap[id] = data; + doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength); + }); + const imageRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.png'), ResourceType.SpriteImage); + const imageRequestKey = `${id}_${imageRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique + combinedRequestsMap[imageRequestKey] = ImageRequest.getImage(imageRequestParameters, (err, img) => { + delete combinedRequestsMap[imageRequestKey]; + imagesMap[id] = img; + doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength); + }); + } + return { + cancel() { + for (const requst of Object.values(combinedRequestsMap)) { + requst.cancel(); + } + } + }; +} +/** + * @param callbackFunc - the callback function (both erro and success) + * @param jsonsMap - JSON data map + * @param imagesMap - image data map + * @param err - error object + * @param expectedResultCounter - number of expected JSON or Image results when everything is finished, respectively. + */ +function doOnceCompleted(callbackFunc, jsonsMap, imagesMap, err, expectedResultCounter) { + if (err) { + callbackFunc(err); + return; + } + if (expectedResultCounter !== Object.values(jsonsMap).length || expectedResultCounter !== Object.values(imagesMap).length) { + // not done yet, nothing to do + return; + } + const result = {}; + for (const spriteName in jsonsMap) { + result[spriteName] = {}; + const context = performance.browser.getImageCanvasContext(imagesMap[spriteName]); + const json = jsonsMap[spriteName]; + for (const id in json) { + const { width, height, x, y, sdf, pixelRatio, stretchX, stretchY, content } = json[id]; + const spriteData = { width, height, x, y, context }; + result[spriteName][id] = { data: null, pixelRatio, sdf, stretchX, stretchY, content, spriteData }; + } + } + callbackFunc(null, result); +} + +/** + * @internal + * A `Texture` GL related object + */ +class Texture { + constructor(context, image, format, options) { + this.context = context; + this.format = format; + this.texture = context.gl.createTexture(); + this.update(image, options); + } + update(image, options, position) { + const { width, height } = image; + const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position; + const { context } = this; + const { gl } = context; + this.useMipmap = Boolean(options && options.useMipmap); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + context.pixelStoreUnpackFlipY.set(false); + context.pixelStoreUnpack.set(1); + context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl.RGBA && (!options || options.premultiply !== false)); + if (resize) { + this.size = [width, height]; + if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || performance.isImageBitmap(image)) { + gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image); + } + else { + gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, image.data); + } + } + else { + const { x, y } = position || { x: 0, y: 0 }; + if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || performance.isImageBitmap(image)) { + gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image); + } + else { + gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, image.data); + } + } + if (this.useMipmap && this.isSizePowerOfTwo()) { + gl.generateMipmap(gl.TEXTURE_2D); + } + } + bind(filter, wrap, minFilter) { + const { context } = this; + const { gl } = context; + gl.bindTexture(gl.TEXTURE_2D, this.texture); + if (minFilter === gl.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) { + minFilter = gl.LINEAR; + } + if (filter !== this.filter) { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || filter); + this.filter = filter; + } + if (wrap !== this.wrap) { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap); + this.wrap = wrap; + } + } + isSizePowerOfTwo() { + return this.size[0] === this.size[1] && (Math.log(this.size[0]) / Math.LN2) % 1 === 0; + } + destroy() { + const { gl } = this.context; + gl.deleteTexture(this.texture); + this.texture = null; + } +} + +function renderStyleImage(image) { + const { userImage } = image; + if (userImage && userImage.render) { + const updated = userImage.render(); + if (updated) { + image.data.replace(new Uint8Array(userImage.data.buffer)); + return true; + } + } + return false; +} + +/* eslint-disable key-spacing */ +// When copied into the atlas texture, image data is padded by one pixel on each side. Icon +// images are padded with fully transparent pixels, while pattern images are padded with a +// copy of the image data wrapped from the opposite side. In both cases, this ensures the +// correct behavior of GL_LINEAR texture sampling mode. +const padding = 1; +/* + ImageManager does three things: + + 1. Tracks requests for icon images from tile workers and sends responses when the requests are fulfilled. + 2. Builds a texture atlas for pattern images. + 3. Rerenders renderable images once per frame + + These are disparate responsibilities and should eventually be handled by different classes. When we implement + data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time + to refactor this. +*/ +class ImageManager extends performance.Evented { + constructor() { + super(); + this.images = {}; + this.updatedImages = {}; + this.callbackDispatchedThisFrame = {}; + this.loaded = false; + this.requestors = []; + this.patterns = {}; + this.atlasImage = new performance.RGBAImage({ width: 1, height: 1 }); + this.dirty = true; + } + isLoaded() { + return this.loaded; + } + setLoaded(loaded) { + if (this.loaded === loaded) { + return; + } + this.loaded = loaded; + if (loaded) { + for (const { ids, callback } of this.requestors) { + this._notify(ids, callback); + } + this.requestors = []; + } + } + getImage(id) { + const image = this.images[id]; + // Extract sprite image data on demand + if (image && !image.data && image.spriteData) { + const spriteData = image.spriteData; + image.data = new performance.RGBAImage({ + width: spriteData.width, + height: spriteData.height + }, spriteData.context.getImageData(spriteData.x, spriteData.y, spriteData.width, spriteData.height).data); + image.spriteData = null; + } + return image; + } + addImage(id, image) { + if (this.images[id]) + throw new Error(`Image id ${id} already exist, use updateImage instead`); + if (this._validate(id, image)) { + this.images[id] = image; + } + } + _validate(id, image) { + let valid = true; + const data = image.data || image.spriteData; + if (!this._validateStretch(image.stretchX, data && data.width)) { + this.fire(new performance.ErrorEvent(new Error(`Image "${id}" has invalid "stretchX" value`))); + valid = false; + } + if (!this._validateStretch(image.stretchY, data && data.height)) { + this.fire(new performance.ErrorEvent(new Error(`Image "${id}" has invalid "stretchY" value`))); + valid = false; + } + if (!this._validateContent(image.content, image)) { + this.fire(new performance.ErrorEvent(new Error(`Image "${id}" has invalid "content" value`))); + valid = false; + } + return valid; + } + _validateStretch(stretch, size) { + if (!stretch) + return true; + let last = 0; + for (const part of stretch) { + if (part[0] < last || part[1] < part[0] || size < part[1]) + return false; + last = part[1]; + } + return true; + } + _validateContent(content, image) { + if (!content) + return true; + if (content.length !== 4) + return false; + const spriteData = image.spriteData; + const width = (spriteData && spriteData.width) || image.data.width; + const height = (spriteData && spriteData.height) || image.data.height; + if (content[0] < 0 || width < content[0]) + return false; + if (content[1] < 0 || height < content[1]) + return false; + if (content[2] < 0 || width < content[2]) + return false; + if (content[3] < 0 || height < content[3]) + return false; + if (content[2] < content[0]) + return false; + if (content[3] < content[1]) + return false; + return true; + } + updateImage(id, image, validate = true) { + const oldImage = this.getImage(id); + if (validate && (oldImage.data.width !== image.data.width || oldImage.data.height !== image.data.height)) { + throw new Error(`size mismatch between old image (${oldImage.data.width}x${oldImage.data.height}) and new image (${image.data.width}x${image.data.height}).`); + } + image.version = oldImage.version + 1; + this.images[id] = image; + this.updatedImages[id] = true; + } + removeImage(id) { + const image = this.images[id]; + delete this.images[id]; + delete this.patterns[id]; + if (image.userImage && image.userImage.onRemove) { + image.userImage.onRemove(); + } + } + listImages() { + return Object.keys(this.images); + } + getImages(ids, callback) { + // If the sprite has been loaded, or if all the icon dependencies are already present + // (i.e. if they've been added via runtime styling), then notify the requestor immediately. + // Otherwise, delay notification until the sprite is loaded. At that point, if any of the + // dependencies are still unavailable, we'll just assume they are permanently missing. + let hasAllDependencies = true; + if (!this.isLoaded()) { + for (const id of ids) { + if (!this.images[id]) { + hasAllDependencies = false; + } + } + } + if (this.isLoaded() || hasAllDependencies) { + this._notify(ids, callback); + } + else { + this.requestors.push({ ids, callback }); + } + } + _notify(ids, callback) { + const response = {}; + for (const id of ids) { + let image = this.getImage(id); + if (!image) { + this.fire(new performance.Event('styleimagemissing', { id })); + //Try to acquire image again in case styleimagemissing has populated it + image = this.getImage(id); + } + if (image) { + // Clone the image so that our own copy of its ArrayBuffer doesn't get transferred. + response[id] = { + data: image.data.clone(), + pixelRatio: image.pixelRatio, + sdf: image.sdf, + version: image.version, + stretchX: image.stretchX, + stretchY: image.stretchY, + content: image.content, + hasRenderCallback: Boolean(image.userImage && image.userImage.render) + }; + } + else { + performance.warnOnce(`Image "${id}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`); + } + } + callback(null, response); + } + // Pattern stuff + getPixelSize() { + const { width, height } = this.atlasImage; + return { width, height }; + } + getPattern(id) { + const pattern = this.patterns[id]; + const image = this.getImage(id); + if (!image) { + return null; + } + if (pattern && pattern.position.version === image.version) { + return pattern.position; + } + if (!pattern) { + const w = image.data.width + padding * 2; + const h = image.data.height + padding * 2; + const bin = { w, h, x: 0, y: 0 }; + const position = new performance.ImagePosition(bin, image); + this.patterns[id] = { bin, position }; + } + else { + pattern.position.version = image.version; + } + this._updatePatternAtlas(); + return this.patterns[id].position; + } + bind(context) { + const gl = context.gl; + if (!this.atlasTexture) { + this.atlasTexture = new Texture(context, this.atlasImage, gl.RGBA); + } + else if (this.dirty) { + this.atlasTexture.update(this.atlasImage); + this.dirty = false; + } + this.atlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + } + _updatePatternAtlas() { + const bins = []; + for (const id in this.patterns) { + bins.push(this.patterns[id].bin); + } + const { w, h } = performance.potpack(bins); + const dst = this.atlasImage; + dst.resize({ width: w || 1, height: h || 1 }); + for (const id in this.patterns) { + const { bin } = this.patterns[id]; + const x = bin.x + padding; + const y = bin.y + padding; + const src = this.getImage(id).data; + const w = src.width; + const h = src.height; + performance.RGBAImage.copy(src, dst, { x: 0, y: 0 }, { x, y }, { width: w, height: h }); + // Add 1 pixel wrapped padding on each side of the image. + performance.RGBAImage.copy(src, dst, { x: 0, y: h - 1 }, { x, y: y - 1 }, { width: w, height: 1 }); // T + performance.RGBAImage.copy(src, dst, { x: 0, y: 0 }, { x, y: y + h }, { width: w, height: 1 }); // B + performance.RGBAImage.copy(src, dst, { x: w - 1, y: 0 }, { x: x - 1, y }, { width: 1, height: h }); // L + performance.RGBAImage.copy(src, dst, { x: 0, y: 0 }, { x: x + w, y }, { width: 1, height: h }); // R + } + this.dirty = true; + } + beginFrame() { + this.callbackDispatchedThisFrame = {}; + } + dispatchRenderCallbacks(ids) { + for (const id of ids) { + // the callback for the image was already dispatched for a different frame + if (this.callbackDispatchedThisFrame[id]) + continue; + this.callbackDispatchedThisFrame[id] = true; + const image = this.getImage(id); + if (!image) + performance.warnOnce(`Image with ID: "${id}" was not found`); + const updated = renderStyleImage(image); + if (updated) { + this.updateImage(id, image); + } + } + } +} + +function loadGlyphRange(fontstack, range, urlTemplate, requestManager, callback) { + const begin = range * 256; + const end = begin + 255; + const request = requestManager.transformRequest(urlTemplate.replace('{fontstack}', fontstack).replace('{range}', `${begin}-${end}`), ResourceType.Glyphs); + performance.getArrayBuffer(request, (err, data) => { + if (err) { + callback(err); + } + else if (data) { + const glyphs = {}; + for (const glyph of performance.parseGlyphPbf(data)) { + glyphs[glyph.id] = glyph; + } + callback(null, glyphs); + } + }); +} + +const INF = 1e20; + +class TinySDF { + constructor({ + fontSize = 24, + buffer = 3, + radius = 8, + cutoff = 0.25, + fontFamily = 'sans-serif', + fontWeight = 'normal', + fontStyle = 'normal' + } = {}) { + this.buffer = buffer; + this.cutoff = cutoff; + this.radius = radius; + + // make the canvas size big enough to both have the specified buffer around the glyph + // for "halo", and account for some glyphs possibly being larger than their font size + const size = this.size = fontSize + buffer * 4; + + const canvas = this._createCanvas(size); + const ctx = this.ctx = canvas.getContext('2d', {willReadFrequently: true}); + ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`; + + ctx.textBaseline = 'alphabetic'; + ctx.textAlign = 'left'; // Necessary so that RTL text doesn't have different alignment + ctx.fillStyle = 'black'; + + // temporary arrays for the distance transform + this.gridOuter = new Float64Array(size * size); + this.gridInner = new Float64Array(size * size); + this.f = new Float64Array(size); + this.z = new Float64Array(size + 1); + this.v = new Uint16Array(size); + } + + _createCanvas(size) { + const canvas = document.createElement('canvas'); + canvas.width = canvas.height = size; + return canvas; + } + + draw(char) { + const { + width: glyphAdvance, + actualBoundingBoxAscent, + actualBoundingBoxDescent, + actualBoundingBoxLeft, + actualBoundingBoxRight + } = this.ctx.measureText(char); + + // The integer/pixel part of the top alignment is encoded in metrics.glyphTop + // The remainder is implicitly encoded in the rasterization + const glyphTop = Math.ceil(actualBoundingBoxAscent); + const glyphLeft = 0; + + // If the glyph overflows the canvas size, it will be clipped at the bottom/right + const glyphWidth = Math.max(0, Math.min(this.size - this.buffer, Math.ceil(actualBoundingBoxRight - actualBoundingBoxLeft))); + const glyphHeight = Math.min(this.size - this.buffer, glyphTop + Math.ceil(actualBoundingBoxDescent)); + + const width = glyphWidth + 2 * this.buffer; + const height = glyphHeight + 2 * this.buffer; + + const len = Math.max(width * height, 0); + const data = new Uint8ClampedArray(len); + const glyph = {data, width, height, glyphWidth, glyphHeight, glyphTop, glyphLeft, glyphAdvance}; + if (glyphWidth === 0 || glyphHeight === 0) return glyph; + + const {ctx, buffer, gridInner, gridOuter} = this; + ctx.clearRect(buffer, buffer, glyphWidth, glyphHeight); + ctx.fillText(char, buffer, buffer + glyphTop); + const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight); + + // Initialize grids outside the glyph range to alpha 0 + gridOuter.fill(INF, 0, len); + gridInner.fill(0, 0, len); + + for (let y = 0; y < glyphHeight; y++) { + for (let x = 0; x < glyphWidth; x++) { + const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 255; // alpha value + if (a === 0) continue; // empty pixels + + const j = (y + buffer) * width + x + buffer; + + if (a === 1) { // fully drawn pixels + gridOuter[j] = 0; + gridInner[j] = INF; + + } else { // aliased pixels + const d = 0.5 - a; + gridOuter[j] = d > 0 ? d * d : 0; + gridInner[j] = d < 0 ? d * d : 0; + } + } + } + + edt(gridOuter, 0, 0, width, height, width, this.f, this.v, this.z); + edt(gridInner, buffer, buffer, glyphWidth, glyphHeight, width, this.f, this.v, this.z); + + for (let i = 0; i < len; i++) { + const d = Math.sqrt(gridOuter[i]) - Math.sqrt(gridInner[i]); + data[i] = Math.round(255 - 255 * (d / this.radius + this.cutoff)); + } + + return glyph; + } +} + +// 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf +function edt(data, x0, y0, width, height, gridSize, f, v, z) { + for (let x = x0; x < x0 + width; x++) edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); + for (let y = y0; y < y0 + height; y++) edt1d(data, y * gridSize + x0, 1, width, f, v, z); +} + +// 1D squared distance transform +function edt1d(grid, offset, stride, length, f, v, z) { + v[0] = 0; + z[0] = -INF; + z[1] = INF; + f[0] = grid[offset]; + + for (let q = 1, k = 0, s = 0; q < length; q++) { + f[q] = grid[offset + q * stride]; + const q2 = q * q; + do { + const r = v[k]; + s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; + } while (s <= z[k] && --k > -1); + + k++; + v[k] = q; + z[k] = s; + z[k + 1] = INF; + } + + for (let q = 0, k = 0; q < length; q++) { + while (z[k + 1] < q) k++; + const r = v[k]; + const qr = q - r; + grid[offset + q * stride] = f[r] + qr * qr; + } +} + +class GlyphManager { + constructor(requestManager, localIdeographFontFamily) { + this.requestManager = requestManager; + this.localIdeographFontFamily = localIdeographFontFamily; + this.entries = {}; + } + setURL(url) { + this.url = url; + } + getGlyphs(glyphs, callback) { + const all = []; + for (const stack in glyphs) { + for (const id of glyphs[stack]) { + all.push({ stack, id }); + } + } + performance.asyncAll(all, ({ stack, id }, callback) => { + let entry = this.entries[stack]; + if (!entry) { + entry = this.entries[stack] = { + glyphs: {}, + requests: {}, + ranges: {} + }; + } + let glyph = entry.glyphs[id]; + if (glyph !== undefined) { + callback(null, { stack, id, glyph }); + return; + } + glyph = this._tinySDF(entry, stack, id); + if (glyph) { + entry.glyphs[id] = glyph; + callback(null, { stack, id, glyph }); + return; + } + const range = Math.floor(id / 256); + if (range * 256 > 65535) { + callback(new Error('glyphs > 65535 not supported')); + return; + } + if (entry.ranges[range]) { + callback(null, { stack, id, glyph }); + return; + } + if (!this.url) { + callback(new Error('glyphsUrl is not set')); + return; + } + let requests = entry.requests[range]; + if (!requests) { + requests = entry.requests[range] = []; + GlyphManager.loadGlyphRange(stack, range, this.url, this.requestManager, (err, response) => { + if (response) { + for (const id in response) { + if (!this._doesCharSupportLocalGlyph(+id)) { + entry.glyphs[+id] = response[+id]; + } + } + entry.ranges[range] = true; + } + for (const cb of requests) { + cb(err, response); + } + delete entry.requests[range]; + }); + } + requests.push((err, result) => { + if (err) { + callback(err); + } + else if (result) { + callback(null, { stack, id, glyph: result[id] || null }); + } + }); + }, (err, glyphs) => { + if (err) { + callback(err); + } + else if (glyphs) { + const result = {}; + for (const { stack, id, glyph } of glyphs) { + // Clone the glyph so that our own copy of its ArrayBuffer doesn't get transferred. + (result[stack] || (result[stack] = {}))[id] = glyph && { + id: glyph.id, + bitmap: glyph.bitmap.clone(), + metrics: glyph.metrics + }; + } + callback(null, result); + } + }); + } + _doesCharSupportLocalGlyph(id) { + /* eslint-disable new-cap */ + return !!this.localIdeographFontFamily && + (performance.unicodeBlockLookup['CJK Unified Ideographs'](id) || + performance.unicodeBlockLookup['Hangul Syllables'](id) || + performance.unicodeBlockLookup['Hiragana'](id) || + performance.unicodeBlockLookup['Katakana'](id)); + /* eslint-enable new-cap */ + } + _tinySDF(entry, stack, id) { + const fontFamily = this.localIdeographFontFamily; + if (!fontFamily) { + return; + } + if (!this._doesCharSupportLocalGlyph(id)) { + return; + } + // Client-generated glyphs are rendered at 2x texture scale, + // because CJK glyphs are more detailed than others. + const textureScale = 2; + let tinySDF = entry.tinySDF; + if (!tinySDF) { + let fontWeight = '400'; + if (/bold/i.test(stack)) { + fontWeight = '900'; + } + else if (/medium/i.test(stack)) { + fontWeight = '500'; + } + else if (/light/i.test(stack)) { + fontWeight = '200'; + } + tinySDF = entry.tinySDF = new GlyphManager.TinySDF({ + fontSize: 24 * textureScale, + buffer: 3 * textureScale, + radius: 8 * textureScale, + cutoff: 0.25, + fontFamily, + fontWeight + }); + } + const char = tinySDF.draw(String.fromCharCode(id)); + /** + * TinySDF's "top" is the distance from the alphabetic baseline to the top of the glyph. + * Server-generated fonts specify "top" relative to an origin above the em box (the origin + * comes from FreeType, but I'm unclear on exactly how it's derived) + * ref: https://github.com/mapbox/sdf-glyph-foundry + * + * Server fonts don't yet include baseline information, so we can't line up exactly with them + * (and they don't line up with each other) + * ref: https://github.com/mapbox/node-fontnik/pull/160 + * + * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment + * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode) + */ + const topAdjustment = 27.5; + const leftAdjustment = 0.5; + return { + id, + bitmap: new performance.AlphaImage({ width: char.width || 30 * textureScale, height: char.height || 30 * textureScale }, char.data), + metrics: { + width: char.glyphWidth / textureScale || 24, + height: char.glyphHeight / textureScale || 24, + left: (char.glyphLeft / textureScale + leftAdjustment) || 0, + top: char.glyphTop / textureScale - topAdjustment || -8, + advance: char.glyphAdvance / textureScale || 24, + isDoubleResolution: true + } + }; + } +} +// exposed as statics to enable stubbing in unit tests +GlyphManager.loadGlyphRange = loadGlyphRange; +GlyphManager.TinySDF = TinySDF; + +class LightPositionProperty { + constructor() { + this.specification = performance.v8Spec.light.position; + } + possiblyEvaluate(value, parameters) { + return performance.sphericalToCartesian(value.expression.evaluate(parameters)); + } + interpolate(a, b, t) { + return { + x: performance.interpolate.number(a.x, b.x, t), + y: performance.interpolate.number(a.y, b.y, t), + z: performance.interpolate.number(a.z, b.z, t), + }; + } +} +const TRANSITION_SUFFIX = '-transition'; +let lightProperties; +/* + * Represents the light used to light extruded features. + */ +class Light extends performance.Evented { + constructor(lightOptions) { + super(); + lightProperties = lightProperties || new performance.Properties({ + 'anchor': new performance.DataConstantProperty(performance.v8Spec.light.anchor), + 'position': new LightPositionProperty(), + 'color': new performance.DataConstantProperty(performance.v8Spec.light.color), + 'intensity': new performance.DataConstantProperty(performance.v8Spec.light.intensity), + }); + this._transitionable = new performance.Transitionable(lightProperties); + this.setLight(lightOptions); + this._transitioning = this._transitionable.untransitioned(); + } + getLight() { + return this._transitionable.serialize(); + } + setLight(light, options = {}) { + if (this._validate(performance.validateLight, light, options)) { + return; + } + for (const name in light) { + const value = light[name]; + if (name.endsWith(TRANSITION_SUFFIX)) { + this._transitionable.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), value); + } + else { + this._transitionable.setValue(name, value); + } + } + } + updateTransitions(parameters) { + this._transitioning = this._transitionable.transitioned(parameters, this._transitioning); + } + hasTransition() { + return this._transitioning.hasTransition(); + } + recalculate(parameters) { + this.properties = this._transitioning.possiblyEvaluate(parameters); + } + _validate(validate, value, options) { + if (options && options.validate === false) { + return false; + } + return performance.emitValidationErrors(this, validate.call(performance.validateStyle, performance.extend({ + value, + // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407 + style: { glyphs: true, sprite: true }, + styleSpec: performance.v8Spec + }))); + } +} + +/** + * @internal + * A LineAtlas lets us reuse rendered dashed lines + * by writing many of them to a texture and then fetching their positions + * using {@link LineAtlas#getDash}. + * + * @param width - the width + * @param height - the height + */ +class LineAtlas { + constructor(width, height) { + this.width = width; + this.height = height; + this.nextRow = 0; + this.data = new Uint8Array(this.width * this.height); + this.dashEntry = {}; + } + /** + * Get or create a dash line pattern. + * + * @param dasharray - the key (represented by numbers) to get the dash texture + * @param round - whether to add circle caps in between dash segments + * @returns position of dash texture in {@link DashEntry} + */ + getDash(dasharray, round) { + const key = dasharray.join(',') + String(round); + if (!this.dashEntry[key]) { + this.dashEntry[key] = this.addDash(dasharray, round); + } + return this.dashEntry[key]; + } + getDashRanges(dasharray, lineAtlasWidth, stretch) { + // If dasharray has an odd length, both the first and last parts + // are dashes and should be joined seamlessly. + const oddDashArray = dasharray.length % 2 === 1; + const ranges = []; + let left = oddDashArray ? -dasharray[dasharray.length - 1] * stretch : 0; + let right = dasharray[0] * stretch; + let isDash = true; + ranges.push({ left, right, isDash, zeroLength: dasharray[0] === 0 }); + let currentDashLength = dasharray[0]; + for (let i = 1; i < dasharray.length; i++) { + isDash = !isDash; + const dashLength = dasharray[i]; + left = currentDashLength * stretch; + currentDashLength += dashLength; + right = currentDashLength * stretch; + ranges.push({ left, right, isDash, zeroLength: dashLength === 0 }); + } + return ranges; + } + addRoundDash(ranges, stretch, n) { + const halfStretch = stretch / 2; + for (let y = -n; y <= n; y++) { + const row = this.nextRow + n + y; + const index = this.width * row; + let currIndex = 0; + let range = ranges[currIndex]; + for (let x = 0; x < this.width; x++) { + if (x / range.right > 1) { + range = ranges[++currIndex]; + } + const distLeft = Math.abs(x - range.left); + const distRight = Math.abs(x - range.right); + const minDist = Math.min(distLeft, distRight); + let signedDistance; + const distMiddle = y / n * (halfStretch + 1); + if (range.isDash) { + const distEdge = halfStretch - Math.abs(distMiddle); + signedDistance = Math.sqrt(minDist * minDist + distEdge * distEdge); + } + else { + signedDistance = halfStretch - Math.sqrt(minDist * minDist + distMiddle * distMiddle); + } + this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128)); + } + } + } + addRegularDash(ranges) { + // Collapse any zero-length range + // Collapse neighbouring same-type parts into a single part + for (let i = ranges.length - 1; i >= 0; --i) { + const part = ranges[i]; + const next = ranges[i + 1]; + if (part.zeroLength) { + ranges.splice(i, 1); + } + else if (next && next.isDash === part.isDash) { + next.left = part.left; + ranges.splice(i, 1); + } + } + // Combine the first and last parts if possible + const first = ranges[0]; + const last = ranges[ranges.length - 1]; + if (first.isDash === last.isDash) { + first.left = last.left - this.width; + last.right = first.right + this.width; + } + const index = this.width * this.nextRow; + let currIndex = 0; + let range = ranges[currIndex]; + for (let x = 0; x < this.width; x++) { + if (x / range.right > 1) { + range = ranges[++currIndex]; + } + const distLeft = Math.abs(x - range.left); + const distRight = Math.abs(x - range.right); + const minDist = Math.min(distLeft, distRight); + const signedDistance = range.isDash ? minDist : -minDist; + this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128)); + } + } + addDash(dasharray, round) { + const n = round ? 7 : 0; + const height = 2 * n + 1; + if (this.nextRow + height > this.height) { + performance.warnOnce('LineAtlas out of space'); + return null; + } + let length = 0; + for (let i = 0; i < dasharray.length; i++) { + length += dasharray[i]; + } + if (length !== 0) { + const stretch = this.width / length; + const ranges = this.getDashRanges(dasharray, this.width, stretch); + if (round) { + this.addRoundDash(ranges, stretch, n); + } + else { + this.addRegularDash(ranges); + } + } + const dashEntry = { + y: (this.nextRow + n + 0.5) / this.height, + height: 2 * n / this.height, + width: length + }; + this.nextRow += height; + this.dirty = true; + return dashEntry; + } + bind(context) { + const gl = context.gl; + if (!this.texture) { + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, this.width, this.height, 0, gl.ALPHA, gl.UNSIGNED_BYTE, this.data); + } + else { + gl.bindTexture(gl.TEXTURE_2D, this.texture); + if (this.dirty) { + this.dirty = false; + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.ALPHA, gl.UNSIGNED_BYTE, this.data); + } + } + } +} + +/** + * Responsible for sending messages from a {@link Source} to an associated + * {@link WorkerSource}. + */ +class Dispatcher { + constructor(workerPool, parent, mapId) { + this.workerPool = workerPool; + this.actors = []; + this.currentActor = 0; + this.id = mapId; + const workers = this.workerPool.acquire(mapId); + for (let i = 0; i < workers.length; i++) { + const worker = workers[i]; + const actor = new performance.Actor(worker, parent, mapId); + actor.name = `Worker ${i}`; + this.actors.push(actor); + } + if (!this.actors.length) + throw new Error('No actors found'); + } + /** + * Broadcast a message to all Workers. + */ + broadcast(type, data, cb) { + cb = cb || function () { }; + performance.asyncAll(this.actors, (actor, done) => { + actor.send(type, data, done); + }, cb); + } + /** + * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion. + * @returns An actor object backed by a web worker for processing messages. + */ + getActor() { + this.currentActor = (this.currentActor + 1) % this.actors.length; + return this.actors[this.currentActor]; + } + remove(mapRemoved = true) { + this.actors.forEach((actor) => { actor.remove(); }); + this.actors = []; + if (mapRemoved) + this.workerPool.release(this.id); + } +} + +function loadTileJson(options, requestManager, callback) { + const loaded = function (err, tileJSON) { + if (err) { + return callback(err); + } + else if (tileJSON) { + const result = performance.pick( + // explicit source options take precedence over TileJSON + performance.extend(tileJSON, options), ['tiles', 'minzoom', 'maxzoom', 'attribution', 'bounds', 'scheme', 'tileSize', 'encoding']); + if (tileJSON.vector_layers) { + result.vectorLayers = tileJSON.vector_layers; + result.vectorLayerIds = result.vectorLayers.map((layer) => { return layer.id; }); + } + callback(null, result); + } + }; + if (options.url) { + return performance.getJSON(requestManager.transformRequest(options.url, ResourceType.Source), loaded); + } + else { + return performance.browser.frame(() => loaded(null, options)); + } +} + +/** + * A `LngLatBounds` object represents a geographical bounding box, + * defined by its southwest and northeast points in longitude and latitude. + * + * If no arguments are provided to the constructor, a `null` bounding box is created. + * + * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option + * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion. + * This flexible type is documented as {@link LngLatBoundsLike}. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let sw = new maplibregl.LngLat(-73.9876, 40.7661); + * let ne = new maplibregl.LngLat(-73.9397, 40.8002); + * let llb = new maplibregl.LngLatBounds(sw, ne); + * ``` + */ +class LngLatBounds { + /** + * @param sw - The southwest corner of the bounding box. + * OR array of 4 numbers in the order of west, south, east, north + * OR array of 2 LngLatLike: [sw,ne] + * @param ne - The northeast corner of the bounding box. + * @example + * ```ts + * let sw = new maplibregl.LngLat(-73.9876, 40.7661); + * let ne = new maplibregl.LngLat(-73.9397, 40.8002); + * let llb = new maplibregl.LngLatBounds(sw, ne); + * ``` + * OR + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]); + * ``` + * OR + * ```ts + * let llb = new maplibregl.LngLatBounds([sw, ne]); + * ``` + */ + constructor(sw, ne) { + if (!sw) { + // noop + } + else if (ne) { + this.setSouthWest(sw).setNorthEast(ne); + } + else if (Array.isArray(sw)) { + if (sw.length === 4) { + // 4 element array: west, south, east, north + this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]); + } + else { + this.setSouthWest(sw[0]).setNorthEast(sw[1]); + } + } + } + /** + * Set the northeast corner of the bounding box + * + * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box. + * @returns `this` + */ + setNorthEast(ne) { + this._ne = ne instanceof performance.LngLat ? new performance.LngLat(ne.lng, ne.lat) : performance.LngLat.convert(ne); + return this; + } + /** + * Set the southwest corner of the bounding box + * + * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box. + * @returns `this` + */ + setSouthWest(sw) { + this._sw = sw instanceof performance.LngLat ? new performance.LngLat(sw.lng, sw.lat) : performance.LngLat.convert(sw); + return this; + } + /** + * Extend the bounds to include a given LngLatLike or LngLatBoundsLike. + * + * @param obj - object to extend to + * @returns `this` + */ + extend(obj) { + const sw = this._sw, ne = this._ne; + let sw2, ne2; + if (obj instanceof performance.LngLat) { + sw2 = obj; + ne2 = obj; + } + else if (obj instanceof LngLatBounds) { + sw2 = obj._sw; + ne2 = obj._ne; + if (!sw2 || !ne2) + return this; + } + else { + if (Array.isArray(obj)) { + if (obj.length === 4 || obj.every(Array.isArray)) { + const lngLatBoundsObj = obj; + return this.extend(LngLatBounds.convert(lngLatBoundsObj)); + } + else { + const lngLatObj = obj; + return this.extend(performance.LngLat.convert(lngLatObj)); + } + } + else if (obj && ('lng' in obj || 'lon' in obj) && 'lat' in obj) { + return this.extend(performance.LngLat.convert(obj)); + } + return this; + } + if (!sw && !ne) { + this._sw = new performance.LngLat(sw2.lng, sw2.lat); + this._ne = new performance.LngLat(ne2.lng, ne2.lat); + } + else { + sw.lng = Math.min(sw2.lng, sw.lng); + sw.lat = Math.min(sw2.lat, sw.lat); + ne.lng = Math.max(ne2.lng, ne.lng); + ne.lat = Math.max(ne2.lat, ne.lat); + } + return this; + } + /** + * Returns the geographical coordinate equidistant from the bounding box's corners. + * + * @returns The bounding box's center. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315} + * ``` + */ + getCenter() { + return new performance.LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2); + } + /** + * Returns the southwest corner of the bounding box. + * + * @returns The southwest corner of the bounding box. + */ + getSouthWest() { return this._sw; } + /** + * Returns the northeast corner of the bounding box. + * + * @returns The northeast corner of the bounding box. + */ + getNorthEast() { return this._ne; } + /** + * Returns the northwest corner of the bounding box. + * + * @returns The northwest corner of the bounding box. + */ + getNorthWest() { return new performance.LngLat(this.getWest(), this.getNorth()); } + /** + * Returns the southeast corner of the bounding box. + * + * @returns The southeast corner of the bounding box. + */ + getSouthEast() { return new performance.LngLat(this.getEast(), this.getSouth()); } + /** + * Returns the west edge of the bounding box. + * + * @returns The west edge of the bounding box. + */ + getWest() { return this._sw.lng; } + /** + * Returns the south edge of the bounding box. + * + * @returns The south edge of the bounding box. + */ + getSouth() { return this._sw.lat; } + /** + * Returns the east edge of the bounding box. + * + * @returns The east edge of the bounding box. + */ + getEast() { return this._ne.lng; } + /** + * Returns the north edge of the bounding box. + * + * @returns The north edge of the bounding box. + */ + getNorth() { return this._ne.lat; } + /** + * Returns the bounding box represented as an array. + * + * @returns The bounding box represented as an array, consisting of the + * southwest and northeast coordinates of the bounding represented as arrays of numbers. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]] + * ``` + */ + toArray() { + return [this._sw.toArray(), this._ne.toArray()]; + } + /** + * Return the bounding box represented as a string. + * + * @returns The bounding box represents as a string of the format + * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))" + * ``` + */ + toString() { + return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`; + } + /** + * Check if the bounding box is an empty/`null`-type box. + * + * @returns True if bounds have been defined, otherwise false. + */ + isEmpty() { + return !(this._sw && this._ne); + } + /** + * Check if the point is within the bounding box. + * + * @param lnglat - geographic point to check against. + * @returns `true` if the point is within the bounding box. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds( + * new maplibregl.LngLat(-73.9876, 40.7661), + * new maplibregl.LngLat(-73.9397, 40.8002) + * ); + * + * let ll = new maplibregl.LngLat(-73.9567, 40.7789); + * + * console.log(llb.contains(ll)); // = true + * ``` + */ + contains(lnglat) { + const { lng, lat } = performance.LngLat.convert(lnglat); + const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat; + let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng; + if (this._sw.lng > this._ne.lng) { // wrapped coordinates + containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng; + } + return containsLatitude && containsLongitude; + } + /** + * Converts an array to a `LngLatBounds` object. + * + * If a `LngLatBounds` object is passed in, the function returns it unchanged. + * + * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values. + * + * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return. + * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object. + * @example + * ```ts + * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; + * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}} + * ``` + */ + static convert(input) { + if (input instanceof LngLatBounds) + return input; + if (!input) + return input; + return new LngLatBounds(input); + } + /** + * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`. + * + * @param center - center coordinates of the new bounds. + * @param radius - Distance in meters from the coordinates to extend the bounds. + * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`. + * @example + * ```ts + * let center = new maplibregl.LngLat(-73.9749, 40.7736); + * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]] + * ``` + */ + static fromLngLat(center, radius = 0) { + const earthCircumferenceInMetersAtEquator = 40075017; + const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator, lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * center.lat); + return new LngLatBounds(new performance.LngLat(center.lng - lngAccuracy, center.lat - latAccuracy), new performance.LngLat(center.lng + lngAccuracy, center.lat + latAccuracy)); + } +} + +class TileBounds { + constructor(bounds, minzoom, maxzoom) { + this.bounds = LngLatBounds.convert(this.validateBounds(bounds)); + this.minzoom = minzoom || 0; + this.maxzoom = maxzoom || 24; + } + validateBounds(bounds) { + // make sure the bounds property contains valid longitude and latitudes + if (!Array.isArray(bounds) || bounds.length !== 4) + return [-180, -90, 180, 90]; + return [Math.max(-180, bounds[0]), Math.max(-90, bounds[1]), Math.min(180, bounds[2]), Math.min(90, bounds[3])]; + } + contains(tileID) { + const worldSize = Math.pow(2, tileID.z); + const level = { + minX: Math.floor(performance.mercatorXfromLng(this.bounds.getWest()) * worldSize), + minY: Math.floor(performance.mercatorYfromLat(this.bounds.getNorth()) * worldSize), + maxX: Math.ceil(performance.mercatorXfromLng(this.bounds.getEast()) * worldSize), + maxY: Math.ceil(performance.mercatorYfromLat(this.bounds.getSouth()) * worldSize) + }; + const hit = tileID.x >= level.minX && tileID.x < level.maxX && tileID.y >= level.minY && tileID.y < level.maxY; + return hit; + } +} + +/** + * A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/). + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }); + * ``` + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'vector', + * tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'], + * minzoom: 6, + * maxzoom: 14 + * }); + * ``` + * + * @example + * ```ts + * map.getSource('some id').setUrl("https://demotiles.maplibre.org/tiles/tiles.json"); + * ``` + * + * @example + * ```ts + * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']); + * ``` + * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/) + */ +class VectorTileSource extends performance.Evented { + constructor(id, options, dispatcher, eventedParent) { + super(); + this.load = () => { + this._loaded = false; + this.fire(new performance.Event('dataloading', { dataType: 'source' })); + this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => { + this._tileJSONRequest = null; + this._loaded = true; + this.map.style.sourceCaches[this.id].clearTiles(); + if (err) { + this.fire(new performance.ErrorEvent(err)); + } + else if (tileJSON) { + performance.extend(this, tileJSON); + if (tileJSON.bounds) + this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom); + // `content` is included here to prevent a race condition where `Style#_updateSources` is called + // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives + // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088 + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'metadata' })); + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'content' })); + } + }); + }; + this.serialize = () => { + return performance.extend({}, this._options); + }; + this.id = id; + this.dispatcher = dispatcher; + this.type = 'vector'; + this.minzoom = 0; + this.maxzoom = 22; + this.scheme = 'xyz'; + this.tileSize = 512; + this.reparseOverscaled = true; + this.isTileClipped = true; + this._loaded = false; + performance.extend(this, performance.pick(options, ['url', 'scheme', 'tileSize', 'promoteId'])); + this._options = performance.extend({ type: 'vector' }, options); + this._collectResourceTiming = options.collectResourceTiming; + if (this.tileSize !== 512) { + throw new Error('vector tile sources must have a tileSize of 512'); + } + this.setEventedParent(eventedParent); + } + loaded() { + return this._loaded; + } + hasTile(tileID) { + return !this.tileBounds || this.tileBounds.contains(tileID.canonical); + } + onAdd(map) { + this.map = map; + this.load(); + } + setSourceProperty(callback) { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + } + callback(); + this.load(); + } + /** + * Sets the source `tiles` property and re-renders the map. + * + * @param tiles - An array of one or more tile source URLs, as in the TileJSON spec. + * @returns `this` + */ + setTiles(tiles) { + this.setSourceProperty(() => { + this._options.tiles = tiles; + }); + return this; + } + /** + * Sets the source `url` property and re-renders the map. + * + * @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`. + * @returns `this` + */ + setUrl(url) { + this.setSourceProperty(() => { + this.url = url; + this._options.url = url; + }); + return this; + } + onRemove() { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + this._tileJSONRequest = null; + } + } + loadTile(tile, callback) { + const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme); + const params = { + request: this.map._requestManager.transformRequest(url, ResourceType.Tile), + uid: tile.uid, + tileID: tile.tileID, + zoom: tile.tileID.overscaledZ, + tileSize: this.tileSize * tile.tileID.overscaleFactor(), + type: this.type, + source: this.id, + pixelRatio: this.map.getPixelRatio(), + showCollisionBoxes: this.map.showCollisionBoxes, + promoteId: this.promoteId + }; + params.request.collectResourceTiming = this._collectResourceTiming; + if (!tile.actor || tile.state === 'expired') { + tile.actor = this.dispatcher.getActor(); + tile.request = tile.actor.send('loadTile', params, done.bind(this)); + } + else if (tile.state === 'loading') { + // schedule tile reloading after it has been loaded + tile.reloadCallback = callback; + } + else { + tile.request = tile.actor.send('reloadTile', params, done.bind(this)); + } + function done(err, data) { + delete tile.request; + if (tile.aborted) + return callback(null); + if (err && err.status !== 404) { + return callback(err); + } + if (data && data.resourceTiming) + tile.resourceTiming = data.resourceTiming; + if (this.map._refreshExpiredTiles && data) + tile.setExpiryData(data); + tile.loadVectorData(data, this.map.painter); + callback(null); + if (tile.reloadCallback) { + this.loadTile(tile, tile.reloadCallback); + tile.reloadCallback = null; + } + } + } + abortTile(tile) { + if (tile.request) { + tile.request.cancel(); + delete tile.request; + } + if (tile.actor) { + tile.actor.send('abortTile', { uid: tile.uid, type: this.type, source: this.id }, undefined); + } + } + unloadTile(tile) { + tile.unloadVectorData(); + if (tile.actor) { + tile.actor.send('removeTile', { uid: tile.uid, type: this.type, source: this.id }, undefined); + } + } + hasTransition() { + return false; + } +} + +/** + * A source containing raster tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * map.addSource('raster-source', { + * 'type': 'raster', + * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'], + * 'tileSize': 256, + * }); + * ``` + * + * @example + * ```ts + * map.addSource('wms-test-source', { + * 'type': 'raster', + * // use the tiles option to specify a WMS tile source URL + * '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 [Add a raster tile source](https://maplibre.org/maplibre-gl-js/docs/examples/map-tiles/) + * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/) + * @see [Display a satellite map](https://maplibre.org/maplibre-gl-js/docs/examples/satellite-map/) + */ +class RasterTileSource extends performance.Evented { + constructor(id, options, dispatcher, eventedParent) { + super(); + this.id = id; + this.dispatcher = dispatcher; + this.setEventedParent(eventedParent); + this.type = 'raster'; + this.minzoom = 0; + this.maxzoom = 22; + this.roundZoom = true; + this.scheme = 'xyz'; + this.tileSize = 512; + this._loaded = false; + this._options = performance.extend({ type: 'raster' }, options); + performance.extend(this, performance.pick(options, ['url', 'scheme', 'tileSize'])); + } + load() { + this._loaded = false; + this.fire(new performance.Event('dataloading', { dataType: 'source' })); + this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => { + this._tileJSONRequest = null; + this._loaded = true; + if (err) { + this.fire(new performance.ErrorEvent(err)); + } + else if (tileJSON) { + performance.extend(this, tileJSON); + if (tileJSON.bounds) + this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom); + // `content` is included here to prevent a race condition where `Style#_updateSources` is called + // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives + // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088 + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'metadata' })); + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'content' })); + } + }); + } + loaded() { + return this._loaded; + } + onAdd(map) { + this.map = map; + this.load(); + } + onRemove() { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + this._tileJSONRequest = null; + } + } + setSourceProperty(callback) { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + } + callback(); + this.load(); + } + /** + * Sets the source `tiles` property and re-renders the map. + * + * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) + * @returns `this` + */ + setTiles(tiles) { + this.setSourceProperty(() => { + this._options.tiles = tiles; + }); + return this; + } + serialize() { + return performance.extend({}, this._options); + } + hasTile(tileID) { + return !this.tileBounds || this.tileBounds.contains(tileID.canonical); + } + loadTile(tile, callback) { + const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme); + tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), (err, img, expiry) => { + delete tile.request; + if (tile.aborted) { + tile.state = 'unloaded'; + callback(null); + } + else if (err) { + tile.state = 'errored'; + callback(err); + } + else if (img) { + if (this.map._refreshExpiredTiles && expiry) + tile.setExpiryData(expiry); + const context = this.map.painter.context; + const gl = context.gl; + tile.texture = this.map.painter.getTileTexture(img.width); + if (tile.texture) { + tile.texture.update(img, { useMipmap: true }); + } + else { + tile.texture = new Texture(context, img, gl.RGBA, { useMipmap: true }); + tile.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + if (context.extTextureFilterAnisotropic) { + gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax); + } + } + tile.state = 'loaded'; + callback(null); + } + }, this.map._refreshExpiredTiles); + } + abortTile(tile, callback) { + if (tile.request) { + tile.request.cancel(); + delete tile.request; + } + callback(); + } + unloadTile(tile, callback) { + if (tile.texture) + this.map.painter.saveTileTexture(tile.texture); + callback(); + } + hasTransition() { + return false; + } +} + +/** + * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.) + * This source can be used to show hillshading and 3D terrain + * + * @group Sources + * + * @example + * ```ts + * map.addSource('raster-dem-source', { + * type: 'raster-dem', + * url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json', + * tileSize: 256 + * }); + * ``` + * @see [3D Terrain](https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/) + */ +class RasterDEMTileSource extends RasterTileSource { + constructor(id, options, dispatcher, eventedParent) { + super(id, options, dispatcher, eventedParent); + this.type = 'raster-dem'; + this.maxzoom = 22; + this._options = performance.extend({ type: 'raster-dem' }, options); + this.encoding = options.encoding || 'mapbox'; + this.redFactor = options.redFactor; + this.greenFactor = options.greenFactor; + this.blueFactor = options.blueFactor; + this.baseShift = options.baseShift; + } + loadTile(tile, callback) { + const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme); + const request = this.map._requestManager.transformRequest(url, ResourceType.Tile); + tile.neighboringTiles = this._getNeighboringTiles(tile.tileID); + tile.request = ImageRequest.getImage(request, (err, img, expiry) => performance.__awaiter(this, void 0, void 0, function* () { + delete tile.request; + if (tile.aborted) { + tile.state = 'unloaded'; + callback(null); + } + else if (err) { + tile.state = 'errored'; + callback(err); + } + else if (img) { + if (this.map._refreshExpiredTiles) + tile.setExpiryData(expiry); + const transfer = performance.isImageBitmap(img) && performance.offscreenCanvasSupported(); + const rawImageData = transfer ? img : yield readImageNow(img); + const params = { + uid: tile.uid, + coord: tile.tileID, + source: this.id, + rawImageData, + encoding: this.encoding, + redFactor: this.redFactor, + greenFactor: this.greenFactor, + blueFactor: this.blueFactor, + baseShift: this.baseShift + }; + if (!tile.actor || tile.state === 'expired') { + tile.actor = this.dispatcher.getActor(); + tile.actor.send('loadDEMTile', params, done); + } + } + }), this.map._refreshExpiredTiles); + function readImageNow(img) { + return performance.__awaiter(this, void 0, void 0, function* () { + if (typeof VideoFrame !== 'undefined' && performance.isOffscreenCanvasDistorted()) { + const width = img.width + 2; + const height = img.height + 2; + try { + return new performance.RGBAImage({ width, height }, yield performance.readImageUsingVideoFrame(img, -1, -1, width, height)); + } + catch (e) { + // fall-back to browser canvas decoding + } + } + return performance.browser.getImageData(img, 1); + }); + } + function done(err, data) { + if (err) { + tile.state = 'errored'; + callback(err); + } + if (data) { + tile.dem = data; + tile.needsHillshadePrepare = true; + tile.needsTerrainPrepare = true; + tile.state = 'loaded'; + callback(null); + } + } + } + _getNeighboringTiles(tileID) { + const canonical = tileID.canonical; + const dim = Math.pow(2, canonical.z); + const px = (canonical.x - 1 + dim) % dim; + const pxw = canonical.x === 0 ? tileID.wrap - 1 : tileID.wrap; + const nx = (canonical.x + 1 + dim) % dim; + const nxw = canonical.x + 1 === dim ? tileID.wrap + 1 : tileID.wrap; + const neighboringTiles = {}; + // add adjacent tiles + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y).key] = { backfilled: false }; + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y).key] = { backfilled: false }; + // Add upper neighboringTiles + if (canonical.y > 0) { + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y - 1).key] = { backfilled: false }; + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y - 1).key] = { backfilled: false }; + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y - 1).key] = { backfilled: false }; + } + // Add lower neighboringTiles + if (canonical.y + 1 < dim) { + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y + 1).key] = { backfilled: false }; + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y + 1).key] = { backfilled: false }; + neighboringTiles[new performance.OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y + 1).key] = { backfilled: false }; + } + return neighboringTiles; + } + unloadTile(tile) { + if (tile.demTexture) + this.map.painter.saveTileTexture(tile.demTexture); + if (tile.fbo) { + tile.fbo.destroy(); + delete tile.fbo; + } + if (tile.dem) + delete tile.dem; + delete tile.neighboringTiles; + tile.state = 'unloaded'; + if (tile.actor) { + tile.actor.send('removeDEMTile', { uid: tile.uid, source: this.id }); + } + } +} + +/** + * A source containing GeoJSON. + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-geojson) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'geojson', + * data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson' + * }); + * ``` + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'geojson', + * data: { + * "type": "FeatureCollection", + * "features": [{ + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [ + * -76.53063297271729, + * 39.18174077994108 + * ] + * } + * }] + * } + * }); + * ``` + * + * @example + * ```ts + * map.getSource('some id').setData({ + * "type": "FeatureCollection", + * "features": [{ + * "type": "Feature", + * "properties": { "name": "Null Island" }, + * "geometry": { + * "type": "Point", + * "coordinates": [ 0, 0 ] + * } + * }] + * }); + * ``` + * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/) + * @see [Add a GeoJSON line](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-line/) + * @see [Create a heatmap from points](https://maplibre.org/maplibre-gl-js/docs/examples/heatmap/) + * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/) + */ +class GeoJSONSource extends performance.Evented { + /** @internal */ + constructor(id, options, dispatcher, eventedParent) { + super(); + this.load = () => { + this._updateWorkerData(); + }; + this.serialize = () => { + return performance.extend({}, this._options, { + type: this.type, + data: this._data + }); + }; + this.id = id; + // `type` is a property rather than a constant to make it easy for 3rd + // parties to use GeoJSONSource to build their own source types. + this.type = 'geojson'; + this.minzoom = 0; + this.maxzoom = 18; + this.tileSize = 512; + this.isTileClipped = true; + this.reparseOverscaled = true; + this._removed = false; + this._pendingLoads = 0; + this.actor = dispatcher.getActor(); + this.setEventedParent(eventedParent); + this._data = options.data; + this._options = performance.extend({}, options); + this._collectResourceTiming = options.collectResourceTiming; + if (options.maxzoom !== undefined) + this.maxzoom = options.maxzoom; + if (options.type) + this.type = options.type; + if (options.attribution) + this.attribution = options.attribution; + this.promoteId = options.promoteId; + const scale = performance.EXTENT / this.tileSize; + // sent to the worker, along with `url: ...` or `data: literal geojson`, + // so that it can load/parse/index the geojson data + // extending with `options.workerOptions` helps to make it easy for + // third-party sources to hack/reuse GeoJSONSource. + this.workerOptions = performance.extend({ + source: this.id, + cluster: options.cluster || false, + geojsonVtOptions: { + buffer: (options.buffer !== undefined ? options.buffer : 128) * scale, + tolerance: (options.tolerance !== undefined ? options.tolerance : 0.375) * scale, + extent: performance.EXTENT, + maxZoom: this.maxzoom, + lineMetrics: options.lineMetrics || false, + generateId: options.generateId || false + }, + superclusterOptions: { + maxZoom: options.clusterMaxZoom !== undefined ? options.clusterMaxZoom : this.maxzoom - 1, + minPoints: Math.max(2, options.clusterMinPoints || 2), + extent: performance.EXTENT, + radius: (options.clusterRadius || 50) * scale, + log: false, + generateId: options.generateId || false + }, + clusterProperties: options.clusterProperties, + filter: options.filter + }, options.workerOptions); + // send the promoteId to the worker to have more flexible updates, but only if it is a string + if (typeof this.promoteId === 'string') { + this.workerOptions.promoteId = this.promoteId; + } + } + onAdd(map) { + this.map = map; + this.load(); + } + /** + * Sets the GeoJSON data and re-renders the map. + * + * @param data - A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files. + * @returns `this` + */ + setData(data) { + this._data = data; + this._updateWorkerData(); + return this; + } + /** + * Updates the source's GeoJSON, and re-renders the map. + * + * For sources with lots of features, this method can be used to make updates more quickly. + * + * This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature, + * or by using the promoteId option to specify which property should be used as the ID. + * + * It is an error to call updateData on a source that did not have unique IDs for each of its features already. + * + * Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error. + * + * @param diff - The changes that need to be applied. + * @returns `this` + */ + updateData(diff) { + this._updateWorkerData(diff); + return this; + } + /** + * To disable/enable clustering on the source options + * @param options - The options to set + * @returns `this` + * @example + * ```ts + * map.getSource('some id').setClusterOptions({cluster: false}); + * map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14}); + * ``` + */ + setClusterOptions(options) { + this.workerOptions.cluster = options.cluster; + if (options) { + if (options.clusterRadius !== undefined) + this.workerOptions.superclusterOptions.radius = options.clusterRadius; + if (options.clusterMaxZoom !== undefined) + this.workerOptions.superclusterOptions.maxZoom = options.clusterMaxZoom; + } + this._updateWorkerData(); + return this; + } + /** + * For clustered sources, fetches the zoom at which the given cluster expands. + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param callback - A callback to be called when the zoom value is retrieved (`(error, zoom) => { ... }`). + * @returns `this` + */ + getClusterExpansionZoom(clusterId, callback) { + this.actor.send('geojson.getClusterExpansionZoom', { clusterId, source: this.id }, callback); + return this; + } + /** + * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features). + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`). + * @returns `this` + */ + getClusterChildren(clusterId, callback) { + this.actor.send('geojson.getClusterChildren', { clusterId, source: this.id }, callback); + return this; + } + /** + * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features). + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param limit - The maximum number of features to return. + * @param offset - The number of features to skip (e.g. for pagination). + * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`). + * @returns `this` + * @example + * Retrieve cluster leaves on click + * ```ts + * map.on('click', 'clusters', function(e) { + * let features = map.queryRenderedFeatures(e.point, { + * layers: ['clusters'] + * }); + * + * let clusterId = features[0].properties.cluster_id; + * let pointCount = features[0].properties.point_count; + * let clusterSource = map.getSource('clusters'); + * + * clusterSource.getClusterLeaves(clusterId, pointCount, 0, function(error, features) { + * // Print cluster leaves in the console + * console.log('Cluster leaves:', error, features); + * }) + * }); + * ``` + */ + getClusterLeaves(clusterId, limit, offset, callback) { + this.actor.send('geojson.getClusterLeaves', { + source: this.id, + clusterId, + limit, + offset + }, callback); + return this; + } + /** + * Responsible for invoking WorkerSource's geojson.loadData target, which + * handles loading the geojson data and preparing to serve it up as tiles, + * using geojson-vt or supercluster as appropriate. + * @param diff - the diff object + */ + _updateWorkerData(diff) { + const options = performance.extend({}, this.workerOptions); + if (diff) { + options.dataDiff = diff; + } + else if (typeof this._data === 'string') { + options.request = this.map._requestManager.transformRequest(performance.browser.resolveURL(this._data), ResourceType.Source); + options.request.collectResourceTiming = this._collectResourceTiming; + } + else { + options.data = JSON.stringify(this._data); + } + this._pendingLoads++; + this.fire(new performance.Event('dataloading', { dataType: 'source' })); + // target {this.type}.loadData rather than literally geojson.loadData, + // so that other geojson-like source types can easily reuse this + // implementation + this.actor.send(`${this.type}.loadData`, options, (err, result) => { + this._pendingLoads--; + if (this._removed || (result && result.abandoned)) { + this.fire(new performance.Event('dataabort', { dataType: 'source' })); + return; + } + let resourceTiming = null; + if (result && result.resourceTiming && result.resourceTiming[this.id]) + resourceTiming = result.resourceTiming[this.id].slice(0); + if (err) { + this.fire(new performance.ErrorEvent(err)); + return; + } + const data = { dataType: 'source' }; + if (this._collectResourceTiming && resourceTiming && resourceTiming.length > 0) + performance.extend(data, { resourceTiming }); + // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache + // know its ok to start requesting tiles. + this.fire(new performance.Event('data', Object.assign(Object.assign({}, data), { sourceDataType: 'metadata' }))); + this.fire(new performance.Event('data', Object.assign(Object.assign({}, data), { sourceDataType: 'content' }))); + }); + } + loaded() { + return this._pendingLoads === 0; + } + loadTile(tile, callback) { + const message = !tile.actor ? 'loadTile' : 'reloadTile'; + tile.actor = this.actor; + const params = { + type: this.type, + uid: tile.uid, + tileID: tile.tileID, + zoom: tile.tileID.overscaledZ, + maxZoom: this.maxzoom, + tileSize: this.tileSize, + source: this.id, + pixelRatio: this.map.getPixelRatio(), + showCollisionBoxes: this.map.showCollisionBoxes, + promoteId: this.promoteId + }; + tile.request = this.actor.send(message, params, (err, data) => { + delete tile.request; + tile.unloadVectorData(); + if (tile.aborted) { + return callback(null); + } + if (err) { + return callback(err); + } + tile.loadVectorData(data, this.map.painter, message === 'reloadTile'); + return callback(null); + }); + } + abortTile(tile) { + if (tile.request) { + tile.request.cancel(); + delete tile.request; + } + tile.aborted = true; + } + unloadTile(tile) { + tile.unloadVectorData(); + this.actor.send('removeTile', { uid: tile.uid, type: this.type, source: this.id }); + } + onRemove() { + this._removed = true; + this.actor.send('removeSource', { type: this.type, source: this.id }); + } + hasTransition() { + return false; + } +} + +var rasterBoundsAttributes = performance.createLayout([ + { name: 'a_pos', type: 'Int16', components: 2 }, + { name: 'a_texture_pos', type: 'Int16', components: 2 } +]); + +/** + * A data source containing an image. + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-image) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * // add to map + * map.addSource('some id', { + * type: 'image', + * url: 'https://www.maplibre.org/images/foo.png', + * coordinates: [ + * [-76.54, 39.18], + * [-76.52, 39.18], + * [-76.52, 39.17], + * [-76.54, 39.17] + * ] + * }); + * + * // update coordinates + * let mySource = map.getSource('some id'); + * mySource.setCoordinates([ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ]); + * + * // update url and coordinates simultaneously + * mySource.updateImage({ + * url: 'https://www.maplibre.org/images/bar.png', + * coordinates: [ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ] + * }) + * + * map.removeSource('some id'); // remove + * ``` + */ +class ImageSource extends performance.Evented { + /** @internal */ + constructor(id, options, dispatcher, eventedParent) { + super(); + this.load = (newCoordinates, successCallback) => { + this._loaded = false; + this.fire(new performance.Event('dataloading', { dataType: 'source' })); + this.url = this.options.url; + this._request = ImageRequest.getImage(this.map._requestManager.transformRequest(this.url, ResourceType.Image), (err, image) => { + this._request = null; + this._loaded = true; + if (err) { + this.fire(new performance.ErrorEvent(err)); + } + else if (image) { + this.image = image; + if (newCoordinates) { + this.coordinates = newCoordinates; + } + if (successCallback) { + successCallback(); + } + this._finishLoading(); + } + }); + }; + this.prepare = () => { + if (Object.keys(this.tiles).length === 0 || !this.image) { + return; + } + const context = this.map.painter.context; + const gl = context.gl; + if (!this.boundsBuffer) { + this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members); + } + if (!this.boundsSegments) { + this.boundsSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 2); + } + if (!this.texture) { + this.texture = new Texture(context, this.image, gl.RGBA); + this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + } + let newTilesLoaded = false; + for (const w in this.tiles) { + const tile = this.tiles[w]; + if (tile.state !== 'loaded') { + tile.state = 'loaded'; + tile.texture = this.texture; + newTilesLoaded = true; + } + } + if (newTilesLoaded) { + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'idle', sourceId: this.id })); + } + }; + this.serialize = () => { + return { + type: 'image', + url: this.options.url, + coordinates: this.coordinates + }; + }; + this.id = id; + this.dispatcher = dispatcher; + this.coordinates = options.coordinates; + this.type = 'image'; + this.minzoom = 0; + this.maxzoom = 22; + this.tileSize = 512; + this.tiles = {}; + this._loaded = false; + this.setEventedParent(eventedParent); + this.options = options; + } + loaded() { + return this._loaded; + } + /** + * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing, + * set the `raster-fade-duration` paint property on the raster layer to 0. + * + * @param options - The options object. + * @returns `this` + */ + updateImage(options) { + if (!options.url) { + return this; + } + if (this._request) { + this._request.cancel(); + this._request = null; + } + this.options.url = options.url; + this.load(options.coordinates, () => { this.texture = null; }); + return this; + } + _finishLoading() { + if (this.map) { + this.setCoordinates(this.coordinates); + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'metadata' })); + } + } + onAdd(map) { + this.map = map; + this.load(); + } + onRemove() { + if (this._request) { + this._request.cancel(); + this._request = null; + } + } + /** + * Sets the image's coordinates and re-renders the map. + * + * @param coordinates - Four geographical coordinates, + * represented as arrays of longitude and latitude numbers, which define the corners of the image. + * The coordinates start at the top left corner of the image and proceed in clockwise order. + * They do not have to represent a rectangle. + * @returns `this` + */ + setCoordinates(coordinates) { + this.coordinates = coordinates; + // Calculate which mercator tile is suitable for rendering the video in + // and create a buffer with the corner coordinates. These coordinates + // may be outside the tile, because raster tiles aren't clipped when rendering. + // transform the geo coordinates into (zoom 0) tile space coordinates + const cornerCoords = coordinates.map(performance.MercatorCoordinate.fromLngLat); + // Compute the coordinates of the tile we'll use to hold this image's + // render data + this.tileID = getCoordinatesCenterTileID(cornerCoords); + // Constrain min/max zoom to our tile's zoom level in order to force + // SourceCache to request this tile (no matter what the map's zoom + // level) + this.minzoom = this.maxzoom = this.tileID.z; + // Transform the corner coordinates into the coordinate space of our + // tile. + const tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round()); + this._boundsArray = new performance.RasterBoundsArray(); + this._boundsArray.emplaceBack(tileCoords[0].x, tileCoords[0].y, 0, 0); + this._boundsArray.emplaceBack(tileCoords[1].x, tileCoords[1].y, performance.EXTENT, 0); + this._boundsArray.emplaceBack(tileCoords[3].x, tileCoords[3].y, 0, performance.EXTENT); + this._boundsArray.emplaceBack(tileCoords[2].x, tileCoords[2].y, performance.EXTENT, performance.EXTENT); + if (this.boundsBuffer) { + this.boundsBuffer.destroy(); + delete this.boundsBuffer; + } + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'content' })); + return this; + } + loadTile(tile, callback) { + // We have a single tile -- whose coordinates are this.tileID -- that + // covers the image we want to render. If that's the one being + // requested, set it up with the image; otherwise, mark the tile as + // `errored` to indicate that we have no data for it. + // If the world wraps, we may have multiple "wrapped" copies of the + // single tile. + if (this.tileID && this.tileID.equals(tile.tileID.canonical)) { + this.tiles[String(tile.tileID.wrap)] = tile; + tile.buckets = {}; + callback(null); + } + else { + tile.state = 'errored'; + callback(null); + } + } + hasTransition() { + return false; + } +} +/** + * Given a list of coordinates, get their center as a coordinate. + * + * @returns centerpoint + * @internal + */ +function getCoordinatesCenterTileID(coords) { + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + for (const coord of coords) { + minX = Math.min(minX, coord.x); + minY = Math.min(minY, coord.y); + maxX = Math.max(maxX, coord.x); + maxY = Math.max(maxY, coord.y); + } + const dx = maxX - minX; + const dy = maxY - minY; + const dMax = Math.max(dx, dy); + const zoom = Math.max(0, Math.floor(-Math.log(dMax) / Math.LN2)); + const tilesAtZoom = Math.pow(2, zoom); + return new performance.CanonicalTileID(zoom, Math.floor((minX + maxX) / 2 * tilesAtZoom), Math.floor((minY + maxY) / 2 * tilesAtZoom)); +} + +/** + * A data source containing video. + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-video) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * // add to map + * map.addSource('some id', { + * type: 'video', + * url: [ + * 'https://www.mapbox.com/blog/assets/baltimore-smoke.mp4', + * 'https://www.mapbox.com/blog/assets/baltimore-smoke.webm' + * ], + * coordinates: [ + * [-76.54, 39.18], + * [-76.52, 39.18], + * [-76.52, 39.17], + * [-76.54, 39.17] + * ] + * }); + * + * // update + * let mySource = map.getSource('some id'); + * mySource.setCoordinates([ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ]); + * + * map.removeSource('some id'); // remove + * ``` + * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/) + * + * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in. + * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior, + * set the layer's `raster-fade-duration` property to `0`. + */ +class VideoSource extends ImageSource { + constructor(id, options, dispatcher, eventedParent) { + super(id, options, dispatcher, eventedParent); + this.load = () => { + this._loaded = false; + const options = this.options; + this.urls = []; + for (const url of options.urls) { + this.urls.push(this.map._requestManager.transformRequest(url, ResourceType.Source).url); + } + performance.getVideo(this.urls, (err, video) => { + this._loaded = true; + if (err) { + this.fire(new performance.ErrorEvent(err)); + } + else if (video) { + this.video = video; + this.video.loop = true; + // Start repainting when video starts playing. hasTransition() will then return + // true to trigger additional frames as long as the videos continues playing. + this.video.addEventListener('playing', () => { + this.map.triggerRepaint(); + }); + if (this.map) { + this.video.play(); + } + this._finishLoading(); + } + }); + }; + /** + * Sets the video's coordinates and re-renders the map. + * + * @returns `this` + */ + this.prepare = () => { + if (Object.keys(this.tiles).length === 0 || this.video.readyState < 2) { + return; // not enough data for current position + } + const context = this.map.painter.context; + const gl = context.gl; + if (!this.boundsBuffer) { + this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members); + } + if (!this.boundsSegments) { + this.boundsSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 2); + } + if (!this.texture) { + this.texture = new Texture(context, this.video, gl.RGBA); + this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + } + else if (!this.video.paused) { + this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, this.video); + } + let newTilesLoaded = false; + for (const w in this.tiles) { + const tile = this.tiles[w]; + if (tile.state !== 'loaded') { + tile.state = 'loaded'; + tile.texture = this.texture; + newTilesLoaded = true; + } + } + if (newTilesLoaded) { + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'idle', sourceId: this.id })); + } + }; + this.serialize = () => { + return { + type: 'video', + urls: this.urls, + coordinates: this.coordinates + }; + }; + this.roundZoom = true; + this.type = 'video'; + this.options = options; + } + /** + * Pauses the video. + */ + pause() { + if (this.video) { + this.video.pause(); + } + } + /** + * Plays the video. + */ + play() { + if (this.video) { + this.video.play(); + } + } + /** + * Sets playback to a timestamp, in seconds. + */ + seek(seconds) { + if (this.video) { + const seekableRange = this.video.seekable; + if (seconds < seekableRange.start(0) || seconds > seekableRange.end(0)) { + this.fire(new performance.ErrorEvent(new performance.ValidationError(`sources.${this.id}`, null, `Playback for this video can be set only between the ${seekableRange.start(0)} and ${seekableRange.end(0)}-second mark.`))); + } + else + this.video.currentTime = seconds; + } + } + /** + * Returns the HTML `video` element. + * + * @returns The HTML `video` element. + */ + getVideo() { + return this.video; + } + onAdd(map) { + if (this.map) + return; + this.map = map; + this.load(); + if (this.video) { + this.video.play(); + this.setCoordinates(this.coordinates); + } + } + hasTransition() { + return this.video && !this.video.paused; + } +} + +/** + * A data source containing the contents of an HTML canvas. See {@link CanvasSourceSpecification} for detailed documentation of options. + * + * @group Sources + * + * @example + * ```ts + * // add to map + * map.addSource('some id', { + * type: 'canvas', + * canvas: 'idOfMyHTMLCanvas', + * animate: true, + * coordinates: [ + * [-76.54, 39.18], + * [-76.52, 39.18], + * [-76.52, 39.17], + * [-76.54, 39.17] + * ] + * }); + * + * // update + * let mySource = map.getSource('some id'); + * mySource.setCoordinates([ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ]); + * + * map.removeSource('some id'); // remove + * ``` + */ +class CanvasSource extends ImageSource { + /** @internal */ + constructor(id, options, dispatcher, eventedParent) { + super(id, options, dispatcher, eventedParent); + this.load = () => { + this._loaded = true; + if (!this.canvas) { + this.canvas = (this.options.canvas instanceof HTMLCanvasElement) ? + this.options.canvas : + document.getElementById(this.options.canvas); + // cast to HTMLCanvasElement in else of ternary + // should we do a safety check and throw if it's not actually HTMLCanvasElement? + } + this.width = this.canvas.width; + this.height = this.canvas.height; + if (this._hasInvalidDimensions()) { + this.fire(new performance.ErrorEvent(new Error('Canvas dimensions cannot be less than or equal to zero.'))); + return; + } + this.play = function () { + this._playing = true; + this.map.triggerRepaint(); + }; + this.pause = function () { + if (this._playing) { + this.prepare(); + this._playing = false; + } + }; + this._finishLoading(); + }; + this.prepare = () => { + let resize = false; + if (this.canvas.width !== this.width) { + this.width = this.canvas.width; + resize = true; + } + if (this.canvas.height !== this.height) { + this.height = this.canvas.height; + resize = true; + } + if (this._hasInvalidDimensions()) + return; + if (Object.keys(this.tiles).length === 0) + return; // not enough data for current position + const context = this.map.painter.context; + const gl = context.gl; + if (!this.boundsBuffer) { + this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members); + } + if (!this.boundsSegments) { + this.boundsSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 2); + } + if (!this.texture) { + this.texture = new Texture(context, this.canvas, gl.RGBA, { premultiply: true }); + } + else if (resize || this._playing) { + this.texture.update(this.canvas, { premultiply: true }); + } + let newTilesLoaded = false; + for (const w in this.tiles) { + const tile = this.tiles[w]; + if (tile.state !== 'loaded') { + tile.state = 'loaded'; + tile.texture = this.texture; + newTilesLoaded = true; + } + } + if (newTilesLoaded) { + this.fire(new performance.Event('data', { dataType: 'source', sourceDataType: 'idle', sourceId: this.id })); + } + }; + this.serialize = () => { + return { + type: 'canvas', + coordinates: this.coordinates + }; + }; + // We build in some validation here, since canvas sources aren't included in the style spec: + if (!options.coordinates) { + this.fire(new performance.ErrorEvent(new performance.ValidationError(`sources.${id}`, null, 'missing required property "coordinates"'))); + } + else if (!Array.isArray(options.coordinates) || options.coordinates.length !== 4 || + options.coordinates.some(c => !Array.isArray(c) || c.length !== 2 || c.some(l => typeof l !== 'number'))) { + this.fire(new performance.ErrorEvent(new performance.ValidationError(`sources.${id}`, null, '"coordinates" property must be an array of 4 longitude/latitude array pairs'))); + } + if (options.animate && typeof options.animate !== 'boolean') { + this.fire(new performance.ErrorEvent(new performance.ValidationError(`sources.${id}`, null, 'optional "animate" property must be a boolean value'))); + } + if (!options.canvas) { + this.fire(new performance.ErrorEvent(new performance.ValidationError(`sources.${id}`, null, 'missing required property "canvas"'))); + } + else if (typeof options.canvas !== 'string' && !(options.canvas instanceof HTMLCanvasElement)) { + this.fire(new performance.ErrorEvent(new performance.ValidationError(`sources.${id}`, null, '"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))); + } + this.options = options; + this.animate = options.animate !== undefined ? options.animate : true; + } + /** + * Returns the HTML `canvas` element. + * + * @returns The HTML `canvas` element. + */ + getCanvas() { + return this.canvas; + } + onAdd(map) { + this.map = map; + this.load(); + if (this.canvas) { + if (this.animate) + this.play(); + } + } + onRemove() { + this.pause(); + } + hasTransition() { + return this._playing; + } + _hasInvalidDimensions() { + for (const x of [this.canvas.width, this.canvas.height]) { + if (isNaN(x) || x <= 0) + return true; + } + return false; + } +} + +const registeredSources = {}; +/** + * Creates a tiled data source instance given an options object. + * + * @param id - The id for the source. Must not be used by any existing source. + * @param specification - Source options, specific to the source type (except for `options.type`, which is always required). + * @param source - A source definition object compliant with + * [`maplibre-gl-style-spec`](https://maplibre.org/maplibre-style-spec/#sources) or, for a third-party source type, + * with that type's requirements. + * @param dispatcher - A {@link Dispatcher} instance, which can be used to send messages to the workers. + * @returns a newly created source + */ +const create = (id, specification, dispatcher, eventedParent) => { + const Class = getSourceType(specification.type); + const source = new Class(id, specification, dispatcher, eventedParent); + if (source.id !== id) { + throw new Error(`Expected Source id to be ${id} instead of ${source.id}`); + } + return source; +}; +const getSourceType = (name) => { + switch (name) { + case 'geojson': + return GeoJSONSource; + case 'image': + return ImageSource; + case 'raster': + return RasterTileSource; + case 'raster-dem': + return RasterDEMTileSource; + case 'vector': + return VectorTileSource; + case 'video': + return VideoSource; + case 'canvas': + return CanvasSource; + } + return registeredSources[name]; +}; +const setSourceType = (name, type) => { + registeredSources[name] = type; +}; + +/* + * Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates. + */ +function getPixelPosMatrix(transform, tileID) { + const t = performance.create(); + performance.translate(t, t, [1, 1, 0]); + performance.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]); + return performance.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped())); +} +function queryIncludes3DLayer(layers, styleLayers, sourceID) { + if (layers) { + for (const layerID of layers) { + const layer = styleLayers[layerID]; + if (layer && layer.source === sourceID && layer.type === 'fill-extrusion') { + return true; + } + } + } + else { + for (const key in styleLayers) { + const layer = styleLayers[key]; + if (layer.source === sourceID && layer.type === 'fill-extrusion') { + return true; + } + } + } + return false; +} +function queryRenderedFeatures(sourceCache, styleLayers, serializedLayers, queryGeometry, params, transform) { + const has3DLayer = queryIncludes3DLayer(params && params.layers, styleLayers, sourceCache.id); + const maxPitchScaleFactor = transform.maxPitchScaleFactor(); + const tilesIn = sourceCache.tilesIn(queryGeometry, maxPitchScaleFactor, has3DLayer); + tilesIn.sort(sortTilesIn); + const renderedFeatureLayers = []; + for (const tileIn of tilesIn) { + renderedFeatureLayers.push({ + wrappedTileID: tileIn.tileID.wrapped().key, + queryResults: tileIn.tile.queryRenderedFeatures(styleLayers, serializedLayers, sourceCache._state, tileIn.queryGeometry, tileIn.cameraQueryGeometry, tileIn.scale, params, transform, maxPitchScaleFactor, getPixelPosMatrix(sourceCache.transform, tileIn.tileID)) + }); + } + const result = mergeRenderedFeatureLayers(renderedFeatureLayers); + // Merge state from SourceCache into the results + for (const layerID in result) { + result[layerID].forEach((featureWrapper) => { + const feature = featureWrapper.feature; + const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id); + feature.source = feature.layer.source; + if (feature.layer['source-layer']) { + feature.sourceLayer = feature.layer['source-layer']; + } + feature.state = state; + }); + } + return result; +} +function queryRenderedSymbols(styleLayers, serializedLayers, sourceCaches, queryGeometry, params, collisionIndex, retainedQueryData) { + const result = {}; + const renderedSymbols = collisionIndex.queryRenderedSymbols(queryGeometry); + const bucketQueryData = []; + for (const bucketInstanceId of Object.keys(renderedSymbols).map(Number)) { + bucketQueryData.push(retainedQueryData[bucketInstanceId]); + } + bucketQueryData.sort(sortTilesIn); + for (const queryData of bucketQueryData) { + const bucketSymbols = queryData.featureIndex.lookupSymbolFeatures(renderedSymbols[queryData.bucketInstanceId], serializedLayers, queryData.bucketIndex, queryData.sourceLayerIndex, params.filter, params.layers, params.availableImages, styleLayers); + for (const layerID in bucketSymbols) { + const resultFeatures = result[layerID] = result[layerID] || []; + const layerSymbols = bucketSymbols[layerID]; + layerSymbols.sort((a, b) => { + // Match topDownFeatureComparator from FeatureIndex, but using + // most recent sorting of features from bucket.sortFeatures + const featureSortOrder = queryData.featureSortOrder; + if (featureSortOrder) { + // queryRenderedSymbols documentation says we'll return features in + // "top-to-bottom" rendering order (aka last-to-first). + // Actually there can be multiple symbol instances per feature, so + // we sort each feature based on the first matching symbol instance. + const sortedA = featureSortOrder.indexOf(a.featureIndex); + const sortedB = featureSortOrder.indexOf(b.featureIndex); + return sortedB - sortedA; + } + else { + // Bucket hasn't been re-sorted based on angle, so use the + // reverse of the order the features appeared in the data. + return b.featureIndex - a.featureIndex; + } + }); + for (const symbolFeature of layerSymbols) { + resultFeatures.push(symbolFeature); + } + } + } + // Merge state from SourceCache into the results + for (const layerName in result) { + result[layerName].forEach((featureWrapper) => { + const feature = featureWrapper.feature; + const layer = styleLayers[layerName]; + const sourceCache = sourceCaches[layer.source]; + const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id); + feature.source = feature.layer.source; + if (feature.layer['source-layer']) { + feature.sourceLayer = feature.layer['source-layer']; + } + feature.state = state; + }); + } + return result; +} +function querySourceFeatures(sourceCache, params) { + const tiles = sourceCache.getRenderableIds().map((id) => { + return sourceCache.getTileByID(id); + }); + const result = []; + const dataTiles = {}; + for (let i = 0; i < tiles.length; i++) { + const tile = tiles[i]; + const dataID = tile.tileID.canonical.key; + if (!dataTiles[dataID]) { + dataTiles[dataID] = true; + tile.querySourceFeatures(result, params); + } + } + return result; +} +function sortTilesIn(a, b) { + const idA = a.tileID; + const idB = b.tileID; + return (idA.overscaledZ - idB.overscaledZ) || (idA.canonical.y - idB.canonical.y) || (idA.wrap - idB.wrap) || (idA.canonical.x - idB.canonical.x); +} +function mergeRenderedFeatureLayers(tiles) { + // Merge results from all tiles, but if two tiles share the same + // wrapped ID, don't duplicate features between the two tiles + const result = {}; + const wrappedIDLayerMap = {}; + for (const tile of tiles) { + const queryResults = tile.queryResults; + const wrappedID = tile.wrappedTileID; + const wrappedIDLayers = wrappedIDLayerMap[wrappedID] = wrappedIDLayerMap[wrappedID] || {}; + for (const layerID in queryResults) { + const tileFeatures = queryResults[layerID]; + const wrappedIDFeatures = wrappedIDLayers[layerID] = wrappedIDLayers[layerID] || {}; + const resultFeatures = result[layerID] = result[layerID] || []; + for (const tileFeature of tileFeatures) { + if (!wrappedIDFeatures[tileFeature.featureIndex]) { + wrappedIDFeatures[tileFeature.featureIndex] = true; + resultFeatures.push(tileFeature); + } + } + } + } + return result; +} + +function deserialize(input, style) { + const output = {}; + // Guard against the case where the map's style has been set to null while + // this bucket has been parsing. + if (!style) + return output; + for (const bucket of input) { + const layers = bucket.layerIds + .map((id) => style.getLayer(id)) + .filter(Boolean); + if (layers.length === 0) { + continue; + } + // look up StyleLayer objects from layer ids (since we don't + // want to waste time serializing/copying them from the worker) + bucket.layers = layers; + if (bucket.stateDependentLayerIds) { + bucket.stateDependentLayers = bucket.stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]); + } + for (const layer of layers) { + output[layer.id] = bucket; + } + } + return output; +} + +const CLOCK_SKEW_RETRY_TIMEOUT = 30000; +/** + * @internal + * A tile object is the combination of a Coordinate, which defines + * its place, as well as a unique ID and data tracking for its content + */ +class Tile { + /** + * @param tileID - the tile ID + * @param size - The tile size + */ + constructor(tileID, size) { + this.timeAdded = 0; + this.fadeEndTime = 0; + this.tileID = tileID; + this.uid = performance.uniqueId(); + this.uses = 0; + this.tileSize = size; + this.buckets = {}; + this.expirationTime = null; + this.queryPadding = 0; + this.hasSymbolBuckets = false; + this.hasRTLText = false; + this.dependencies = {}; + this.rtt = []; + this.rttCoords = {}; + // Counts the number of times a response was already expired when + // received. We're using this to add a delay when making a new request + // so we don't have to keep retrying immediately in case of a server + // serving expired tiles. + this.expiredRequestCount = 0; + this.state = 'loading'; + } + registerFadeDuration(duration) { + const fadeEndTime = duration + this.timeAdded; + if (fadeEndTime < this.fadeEndTime) { + return; + } + this.fadeEndTime = fadeEndTime; + } + wasRequested() { + return this.state === 'errored' || this.state === 'loaded' || this.state === 'reloading'; + } + clearTextures(painter) { + if (this.demTexture) + painter.saveTileTexture(this.demTexture); + this.demTexture = null; + } + /** + * Given a data object with a 'buffers' property, load it into + * this tile's elementGroups and buffers properties and set loaded + * to true. If the data is null, like in the case of an empty + * GeoJSON tile, no-op but still set loaded to true. + * @param data - The data from the worker + * @param painter - the painter + * @param justReloaded - `true` to just reload + */ + loadVectorData(data, painter, justReloaded) { + if (this.hasData()) { + this.unloadVectorData(); + } + this.state = 'loaded'; + // empty GeoJSON tile + if (!data) { + this.collisionBoxArray = new performance.CollisionBoxArray(); + return; + } + if (data.featureIndex) { + this.latestFeatureIndex = data.featureIndex; + if (data.rawTileData) { + // Only vector tiles have rawTileData, and they won't update it for + // 'reloadTile' + this.latestRawTileData = data.rawTileData; + this.latestFeatureIndex.rawTileData = data.rawTileData; + } + else if (this.latestRawTileData) { + // If rawTileData hasn't updated, hold onto a pointer to the last + // one we received + this.latestFeatureIndex.rawTileData = this.latestRawTileData; + } + } + this.collisionBoxArray = data.collisionBoxArray; + this.buckets = deserialize(data.buckets, painter.style); + this.hasSymbolBuckets = false; + for (const id in this.buckets) { + const bucket = this.buckets[id]; + if (bucket instanceof performance.SymbolBucket) { + this.hasSymbolBuckets = true; + if (justReloaded) { + bucket.justReloaded = true; + } + else { + break; + } + } + } + this.hasRTLText = false; + if (this.hasSymbolBuckets) { + for (const id in this.buckets) { + const bucket = this.buckets[id]; + if (bucket instanceof performance.SymbolBucket) { + if (bucket.hasRTLText) { + this.hasRTLText = true; + performance.lazyLoadRTLTextPlugin(); + break; + } + } + } + } + this.queryPadding = 0; + for (const id in this.buckets) { + const bucket = this.buckets[id]; + this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(id).queryRadius(bucket)); + } + if (data.imageAtlas) { + this.imageAtlas = data.imageAtlas; + } + if (data.glyphAtlasImage) { + this.glyphAtlasImage = data.glyphAtlasImage; + } + } + /** + * Release any data or WebGL resources referenced by this tile. + */ + unloadVectorData() { + for (const id in this.buckets) { + this.buckets[id].destroy(); + } + this.buckets = {}; + if (this.imageAtlasTexture) { + this.imageAtlasTexture.destroy(); + } + if (this.imageAtlas) { + this.imageAtlas = null; + } + if (this.glyphAtlasTexture) { + this.glyphAtlasTexture.destroy(); + } + this.latestFeatureIndex = null; + this.state = 'unloaded'; + } + getBucket(layer) { + return this.buckets[layer.id]; + } + upload(context) { + for (const id in this.buckets) { + const bucket = this.buckets[id]; + if (bucket.uploadPending()) { + bucket.upload(context); + } + } + const gl = context.gl; + if (this.imageAtlas && !this.imageAtlas.uploaded) { + this.imageAtlasTexture = new Texture(context, this.imageAtlas.image, gl.RGBA); + this.imageAtlas.uploaded = true; + } + if (this.glyphAtlasImage) { + this.glyphAtlasTexture = new Texture(context, this.glyphAtlasImage, gl.ALPHA); + this.glyphAtlasImage = null; + } + } + prepare(imageManager) { + if (this.imageAtlas) { + this.imageAtlas.patchUpdatedImages(imageManager, this.imageAtlasTexture); + } + } + // Queries non-symbol features rendered for this tile. + // Symbol features are queried globally + queryRenderedFeatures(layers, serializedLayers, sourceFeatureState, queryGeometry, cameraQueryGeometry, scale, params, transform, maxPitchScaleFactor, pixelPosMatrix) { + if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData) + return {}; + return this.latestFeatureIndex.query({ + queryGeometry, + cameraQueryGeometry, + scale, + tileSize: this.tileSize, + pixelPosMatrix, + transform, + params, + queryPadding: this.queryPadding * maxPitchScaleFactor + }, layers, serializedLayers, sourceFeatureState); + } + querySourceFeatures(result, params) { + const featureIndex = this.latestFeatureIndex; + if (!featureIndex || !featureIndex.rawTileData) + return; + const vtLayers = featureIndex.loadVTLayers(); + const sourceLayer = params && params.sourceLayer ? params.sourceLayer : ''; + const layer = vtLayers._geojsonTileLayer || vtLayers[sourceLayer]; + if (!layer) + return; + const filter = performance.createFilter(params && params.filter); + const { z, x, y } = this.tileID.canonical; + const coord = { z, x, y }; + for (let i = 0; i < layer.length; i++) { + const feature = layer.feature(i); + if (filter.needGeometry) { + const evaluationFeature = performance.toEvaluationFeature(feature, true); + if (!filter.filter(new performance.EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) + continue; + } + else if (!filter.filter(new performance.EvaluationParameters(this.tileID.overscaledZ), feature)) { + continue; + } + const id = featureIndex.getId(feature, sourceLayer); + const geojsonFeature = new performance.GeoJSONFeature(feature, z, x, y, id); + geojsonFeature.tile = coord; + result.push(geojsonFeature); + } + } + hasData() { + return this.state === 'loaded' || this.state === 'reloading' || this.state === 'expired'; + } + patternsLoaded() { + return this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length; + } + setExpiryData(data) { + const prior = this.expirationTime; + if (data.cacheControl) { + const parsedCC = performance.parseCacheControl(data.cacheControl); + if (parsedCC['max-age']) + this.expirationTime = Date.now() + parsedCC['max-age'] * 1000; + } + else if (data.expires) { + this.expirationTime = new Date(data.expires).getTime(); + } + if (this.expirationTime) { + const now = Date.now(); + let isExpired = false; + if (this.expirationTime > now) { + isExpired = false; + } + else if (!prior) { + isExpired = true; + } + else if (this.expirationTime < prior) { + // Expiring date is going backwards: + // fall back to exponential backoff + isExpired = true; + } + else { + const delta = this.expirationTime - prior; + if (!delta) { + // Server is serving the same expired resource over and over: fall + // back to exponential backoff. + isExpired = true; + } + else { + // Assume that either the client or the server clock is wrong and + // try to interpolate a valid expiration date (from the client POV) + // observing a minimum timeout. + this.expirationTime = now + Math.max(delta, CLOCK_SKEW_RETRY_TIMEOUT); + } + } + if (isExpired) { + this.expiredRequestCount++; + this.state = 'expired'; + } + else { + this.expiredRequestCount = 0; + } + } + } + getExpiryTimeout() { + if (this.expirationTime) { + if (this.expiredRequestCount) { + return 1000 * (1 << Math.min(this.expiredRequestCount - 1, 31)); + } + else { + // Max value for `setTimeout` implementations is a 32 bit integer; cap this accordingly + return Math.min(this.expirationTime - new Date().getTime(), Math.pow(2, 31) - 1); + } + } + } + setFeatureState(states, painter) { + if (!this.latestFeatureIndex || + !this.latestFeatureIndex.rawTileData || + Object.keys(states).length === 0) { + return; + } + const vtLayers = this.latestFeatureIndex.loadVTLayers(); + for (const id in this.buckets) { + if (!painter.style.hasLayer(id)) + continue; + const bucket = this.buckets[id]; + // Buckets are grouped by common source-layer + const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer'; + const sourceLayer = vtLayers[sourceLayerId]; + const sourceLayerStates = states[sourceLayerId]; + if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) + continue; + bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {}); + const layer = painter && painter.style && painter.style.getLayer(id); + if (layer) { + this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket)); + } + } + } + holdingForFade() { + return this.symbolFadeHoldUntil !== undefined; + } + symbolFadeFinished() { + return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < performance.browser.now(); + } + clearFadeHold() { + this.symbolFadeHoldUntil = undefined; + } + setHoldDuration(duration) { + this.symbolFadeHoldUntil = performance.browser.now() + duration; + } + setDependencies(namespace, dependencies) { + const index = {}; + for (const dep of dependencies) { + index[dep] = true; + } + this.dependencies[namespace] = index; + } + hasDependency(namespaces, keys) { + for (const namespace of namespaces) { + const dependencies = this.dependencies[namespace]; + if (dependencies) { + for (const key of keys) { + if (dependencies[key]) { + return true; + } + } + } + } + return false; + } +} + +/** + * @internal + * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms) + * with hash lookup made possible by keeping a list of keys in parallel to + * an array of dictionary of values + */ +class TileCache { + /** + * @param max - number of permitted values + * @param onRemove - callback called with items when they expire + */ + constructor(max, onRemove) { + this.max = max; + this.onRemove = onRemove; + this.reset(); + } + /** + * Clear the cache + * + * @returns this cache + */ + reset() { + for (const key in this.data) { + for (const removedData of this.data[key]) { + if (removedData.timeout) + clearTimeout(removedData.timeout); + this.onRemove(removedData.value); + } + } + this.data = {}; + this.order = []; + return this; + } + /** + * Add a key, value combination to the cache, trimming its size if this pushes + * it over max length. + * + * @param tileID - lookup key for the item + * @param data - tile data + * + * @returns this cache + */ + add(tileID, data, expiryTimeout) { + const key = tileID.wrapped().key; + if (this.data[key] === undefined) { + this.data[key] = []; + } + const dataWrapper = { + value: data, + timeout: undefined + }; + if (expiryTimeout !== undefined) { + dataWrapper.timeout = setTimeout(() => { + this.remove(tileID, dataWrapper); + }, expiryTimeout); + } + this.data[key].push(dataWrapper); + this.order.push(key); + if (this.order.length > this.max) { + const removedData = this._getAndRemoveByKey(this.order[0]); + if (removedData) + this.onRemove(removedData); + } + return this; + } + /** + * Determine whether the value attached to `key` is present + * + * @param tileID - the key to be looked-up + * @returns whether the cache has this value + */ + has(tileID) { + return tileID.wrapped().key in this.data; + } + /** + * Get the value attached to a specific key and remove data from cache. + * If the key is not found, returns `null` + * + * @param tileID - the key to look up + * @returns the tile data, or null if it isn't found + */ + getAndRemove(tileID) { + if (!this.has(tileID)) { + return null; + } + return this._getAndRemoveByKey(tileID.wrapped().key); + } + /* + * Get and remove the value with the specified key. + */ + _getAndRemoveByKey(key) { + const data = this.data[key].shift(); + if (data.timeout) + clearTimeout(data.timeout); + if (this.data[key].length === 0) { + delete this.data[key]; + } + this.order.splice(this.order.indexOf(key), 1); + return data.value; + } + /* + * Get the value with the specified (wrapped tile) key. + */ + getByKey(key) { + const data = this.data[key]; + return data ? data[0].value : null; + } + /** + * Get the value attached to a specific key without removing data + * from the cache. If the key is not found, returns `null` + * + * @param tileID - the key to look up + * @returns the tile data, or null if it isn't found + */ + get(tileID) { + if (!this.has(tileID)) { + return null; + } + const data = this.data[tileID.wrapped().key][0]; + return data.value; + } + /** + * Remove a key/value combination from the cache. + * + * @param tileID - the key for the pair to delete + * @param value - If a value is provided, remove that exact version of the value. + * @returns this cache + */ + remove(tileID, value) { + if (!this.has(tileID)) { + return this; + } + const key = tileID.wrapped().key; + const dataIndex = value === undefined ? 0 : this.data[key].indexOf(value); + const data = this.data[key][dataIndex]; + this.data[key].splice(dataIndex, 1); + if (data.timeout) + clearTimeout(data.timeout); + if (this.data[key].length === 0) { + delete this.data[key]; + } + this.onRemove(data.value); + this.order.splice(this.order.indexOf(key), 1); + return this; + } + /** + * Change the max size of the cache. + * + * @param max - the max size of the cache + * @returns this cache + */ + setMaxSize(max) { + this.max = max; + while (this.order.length > this.max) { + const removedData = this._getAndRemoveByKey(this.order[0]); + if (removedData) + this.onRemove(removedData); + } + return this; + } + /** + * Remove entries that do not pass a filter function. Used for removing + * stale tiles from the cache. + * + * @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out. + */ + filter(filterFn) { + const removed = []; + for (const key in this.data) { + for (const entry of this.data[key]) { + if (!filterFn(entry.value)) { + removed.push(entry); + } + } + } + for (const r of removed) { + this.remove(r.value.tileID, r); + } + } +} + +/** + * @internal + * SourceFeatureState manages the state and pending changes + * to features in a source, separated by source layer. + * stateChanges and deletedStates batch all changes to the tile (updates and removes, respectively) + * between coalesce() events. addFeatureState() and removeFeatureState() also update their counterpart's + * list of changes, such that coalesce() can apply the proper state changes while agnostic to the order of operations. + * In deletedStates, all null's denote complete removal of state at that scope +*/ +class SourceFeatureState { + constructor() { + this.state = {}; + this.stateChanges = {}; + this.deletedStates = {}; + } + updateState(sourceLayer, featureId, newState) { + const feature = String(featureId); + this.stateChanges[sourceLayer] = this.stateChanges[sourceLayer] || {}; + this.stateChanges[sourceLayer][feature] = this.stateChanges[sourceLayer][feature] || {}; + performance.extend(this.stateChanges[sourceLayer][feature], newState); + if (this.deletedStates[sourceLayer] === null) { + this.deletedStates[sourceLayer] = {}; + for (const ft in this.state[sourceLayer]) { + if (ft !== feature) + this.deletedStates[sourceLayer][ft] = null; + } + } + else { + const featureDeletionQueued = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] === null; + if (featureDeletionQueued) { + this.deletedStates[sourceLayer][feature] = {}; + for (const prop in this.state[sourceLayer][feature]) { + if (!newState[prop]) + this.deletedStates[sourceLayer][feature][prop] = null; + } + } + else { + for (const key in newState) { + const deletionInQueue = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] && this.deletedStates[sourceLayer][feature][key] === null; + if (deletionInQueue) + delete this.deletedStates[sourceLayer][feature][key]; + } + } + } + } + removeFeatureState(sourceLayer, featureId, key) { + const sourceLayerDeleted = this.deletedStates[sourceLayer] === null; + if (sourceLayerDeleted) + return; + const feature = String(featureId); + this.deletedStates[sourceLayer] = this.deletedStates[sourceLayer] || {}; + if (key && featureId !== undefined) { + if (this.deletedStates[sourceLayer][feature] !== null) { + this.deletedStates[sourceLayer][feature] = this.deletedStates[sourceLayer][feature] || {}; + this.deletedStates[sourceLayer][feature][key] = null; + } + } + else if (featureId !== undefined) { + const updateInQueue = this.stateChanges[sourceLayer] && this.stateChanges[sourceLayer][feature]; + if (updateInQueue) { + this.deletedStates[sourceLayer][feature] = {}; + for (key in this.stateChanges[sourceLayer][feature]) + this.deletedStates[sourceLayer][feature][key] = null; + } + else { + this.deletedStates[sourceLayer][feature] = null; + } + } + else { + this.deletedStates[sourceLayer] = null; + } + } + getState(sourceLayer, featureId) { + const feature = String(featureId); + const base = this.state[sourceLayer] || {}; + const changes = this.stateChanges[sourceLayer] || {}; + const reconciledState = performance.extend({}, base[feature], changes[feature]); + //return empty object if the whole source layer is awaiting deletion + if (this.deletedStates[sourceLayer] === null) + return {}; + else if (this.deletedStates[sourceLayer]) { + const featureDeletions = this.deletedStates[sourceLayer][featureId]; + if (featureDeletions === null) + return {}; + for (const prop in featureDeletions) + delete reconciledState[prop]; + } + return reconciledState; + } + initializeTileState(tile, painter) { + tile.setFeatureState(this.state, painter); + } + coalesceChanges(tiles, painter) { + //track changes with full state objects, but only for features that got modified + const featuresChanged = {}; + for (const sourceLayer in this.stateChanges) { + this.state[sourceLayer] = this.state[sourceLayer] || {}; + const layerStates = {}; + for (const feature in this.stateChanges[sourceLayer]) { + if (!this.state[sourceLayer][feature]) + this.state[sourceLayer][feature] = {}; + performance.extend(this.state[sourceLayer][feature], this.stateChanges[sourceLayer][feature]); + layerStates[feature] = this.state[sourceLayer][feature]; + } + featuresChanged[sourceLayer] = layerStates; + } + for (const sourceLayer in this.deletedStates) { + this.state[sourceLayer] = this.state[sourceLayer] || {}; + const layerStates = {}; + if (this.deletedStates[sourceLayer] === null) { + for (const ft in this.state[sourceLayer]) { + layerStates[ft] = {}; + this.state[sourceLayer][ft] = {}; + } + } + else { + for (const feature in this.deletedStates[sourceLayer]) { + const deleteWholeFeatureState = this.deletedStates[sourceLayer][feature] === null; + if (deleteWholeFeatureState) + this.state[sourceLayer][feature] = {}; + else { + for (const key of Object.keys(this.deletedStates[sourceLayer][feature])) { + delete this.state[sourceLayer][feature][key]; + } + } + layerStates[feature] = this.state[sourceLayer][feature]; + } + } + featuresChanged[sourceLayer] = featuresChanged[sourceLayer] || {}; + performance.extend(featuresChanged[sourceLayer], layerStates); + } + this.stateChanges = {}; + this.deletedStates = {}; + if (Object.keys(featuresChanged).length === 0) + return; + for (const id in tiles) { + const tile = tiles[id]; + tile.setFeatureState(featuresChanged, painter); + } + } +} + +/** + * @internal + * `SourceCache` is responsible for + * + * - creating an instance of `Source` + * - forwarding events from `Source` + * - caching tiles loaded from an instance of `Source` + * - loading the tiles needed to render a given viewport + * - unloading the cached tiles not needed to render a given viewport + */ +class SourceCache extends performance.Evented { + constructor(id, options, dispatcher) { + super(); + this.id = id; + this.dispatcher = dispatcher; + this.on('data', (e) => { + // this._sourceLoaded signifies that the TileJSON is loaded if applicable. + // if the source type does not come with a TileJSON, the flag signifies the + // source data has loaded (i.e geojson has been tiled on the worker and is ready) + if (e.dataType === 'source' && e.sourceDataType === 'metadata') + this._sourceLoaded = true; + // for sources with mutable data, this event fires when the underlying data + // to a source is changed. (i.e. GeoJSONSource#setData and ImageSource#serCoordinates) + if (this._sourceLoaded && !this._paused && e.dataType === 'source' && e.sourceDataType === 'content') { + this.reload(); + if (this.transform) { + this.update(this.transform, this.terrain); + } + this._didEmitContent = true; + } + }); + this.on('dataloading', () => { + this._sourceErrored = false; + }); + this.on('error', () => { + // Only set _sourceErrored if the source does not have pending loads. + this._sourceErrored = this._source.loaded(); + }); + this._source = create(id, options, dispatcher, this); + this._tiles = {}; + this._cache = new TileCache(0, this._unloadTile.bind(this)); + this._timers = {}; + this._cacheTimers = {}; + this._maxTileCacheSize = null; + this._maxTileCacheZoomLevels = null; + this._loadedParentTiles = {}; + this._coveredTiles = {}; + this._state = new SourceFeatureState(); + this._didEmitContent = false; + this._updated = false; + } + onAdd(map) { + this.map = map; + this._maxTileCacheSize = map ? map._maxTileCacheSize : null; + this._maxTileCacheZoomLevels = map ? map._maxTileCacheZoomLevels : null; + if (this._source && this._source.onAdd) { + this._source.onAdd(map); + } + } + onRemove(map) { + this.clearTiles(); + if (this._source && this._source.onRemove) { + this._source.onRemove(map); + } + } + /** + * Return true if no tile data is pending, tiles will not change unless + * an additional API call is received. + */ + loaded() { + if (this._sourceErrored) { + return true; + } + if (!this._sourceLoaded) { + return false; + } + if (!this._source.loaded()) { + return false; + } + if ((this.used !== undefined || this.usedForTerrain !== undefined) && !this.used && !this.usedForTerrain) { + return true; + } + // do not consider as loaded if the update hasn't been called yet (we do not know if we will have any tiles to fetch) + if (!this._updated) { + return false; + } + for (const t in this._tiles) { + const tile = this._tiles[t]; + if (tile.state !== 'loaded' && tile.state !== 'errored') + return false; + } + return true; + } + getSource() { + return this._source; + } + pause() { + this._paused = true; + } + resume() { + if (!this._paused) + return; + const shouldReload = this._shouldReloadOnResume; + this._paused = false; + this._shouldReloadOnResume = false; + if (shouldReload) + this.reload(); + if (this.transform) + this.update(this.transform, this.terrain); + } + _loadTile(tile, callback) { + return this._source.loadTile(tile, callback); + } + _unloadTile(tile) { + if (this._source.unloadTile) + return this._source.unloadTile(tile, () => { }); + } + _abortTile(tile) { + if (this._source.abortTile) + this._source.abortTile(tile, () => { }); + this._source.fire(new performance.Event('dataabort', { tile, coord: tile.tileID, dataType: 'source' })); + } + serialize() { + return this._source.serialize(); + } + prepare(context) { + if (this._source.prepare) { + this._source.prepare(); + } + this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null); + for (const i in this._tiles) { + const tile = this._tiles[i]; + tile.upload(context); + tile.prepare(this.map.style.imageManager); + } + } + /** + * Return all tile ids ordered with z-order, and cast to numbers + */ + getIds() { + return Object.values(this._tiles).map((tile) => tile.tileID).sort(compareTileId).map(id => id.key); + } + getRenderableIds(symbolLayer) { + const renderables = []; + for (const id in this._tiles) { + if (this._isIdRenderable(id, symbolLayer)) + renderables.push(this._tiles[id]); + } + if (symbolLayer) { + return renderables.sort((a_, b_) => { + const a = a_.tileID; + const b = b_.tileID; + const rotatedA = (new performance.Point(a.canonical.x, a.canonical.y))._rotate(this.transform.angle); + const rotatedB = (new performance.Point(b.canonical.x, b.canonical.y))._rotate(this.transform.angle); + return a.overscaledZ - b.overscaledZ || rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x; + }).map(tile => tile.tileID.key); + } + return renderables.map(tile => tile.tileID).sort(compareTileId).map(id => id.key); + } + hasRenderableParent(tileID) { + const parentTile = this.findLoadedParent(tileID, 0); + if (parentTile) { + return this._isIdRenderable(parentTile.tileID.key); + } + return false; + } + _isIdRenderable(id, symbolLayer) { + return this._tiles[id] && this._tiles[id].hasData() && + !this._coveredTiles[id] && (symbolLayer || !this._tiles[id].holdingForFade()); + } + reload() { + if (this._paused) { + this._shouldReloadOnResume = true; + return; + } + this._cache.reset(); + for (const i in this._tiles) { + if (this._tiles[i].state !== 'errored') + this._reloadTile(i, 'reloading'); + } + } + _reloadTile(id, state) { + const tile = this._tiles[id]; + // this potentially does not address all underlying + // issues https://github.com/mapbox/mapbox-gl-js/issues/4252 + // - hard to tell without repro steps + if (!tile) + return; + // The difference between "loading" tiles and "reloading" or "expired" + // tiles is that "reloading"/"expired" tiles are "renderable". + // Therefore, a "loading" tile cannot become a "reloading" tile without + // first becoming a "loaded" tile. + if (tile.state !== 'loading') { + tile.state = state; + } + this._loadTile(tile, this._tileLoaded.bind(this, tile, id, state)); + } + _tileLoaded(tile, id, previousState, err) { + if (err) { + tile.state = 'errored'; + if (err.status !== 404) + this._source.fire(new performance.ErrorEvent(err, { tile })); + // continue to try loading parent/children tiles if a tile doesn't exist (404) + else + this.update(this.transform, this.terrain); + return; + } + tile.timeAdded = performance.browser.now(); + if (previousState === 'expired') + tile.refreshedUponExpiration = true; + this._setTileReloadTimer(id, tile); + if (this.getSource().type === 'raster-dem' && tile.dem) + this._backfillDEM(tile); + this._state.initializeTileState(tile, this.map ? this.map.painter : null); + if (!tile.aborted) { + this._source.fire(new performance.Event('data', { dataType: 'source', tile, coord: tile.tileID })); + } + } + /** + * For raster terrain source, backfill DEM to eliminate visible tile boundaries + */ + _backfillDEM(tile) { + const renderables = this.getRenderableIds(); + for (let i = 0; i < renderables.length; i++) { + const borderId = renderables[i]; + if (tile.neighboringTiles && tile.neighboringTiles[borderId]) { + const borderTile = this.getTileByID(borderId); + fillBorder(tile, borderTile); + fillBorder(borderTile, tile); + } + } + function fillBorder(tile, borderTile) { + tile.needsHillshadePrepare = true; + tile.needsTerrainPrepare = true; + let dx = borderTile.tileID.canonical.x - tile.tileID.canonical.x; + const dy = borderTile.tileID.canonical.y - tile.tileID.canonical.y; + const dim = Math.pow(2, tile.tileID.canonical.z); + const borderId = borderTile.tileID.key; + if (dx === 0 && dy === 0) + return; + if (Math.abs(dy) > 1) { + return; + } + if (Math.abs(dx) > 1) { + // Adjust the delta coordinate for world wraparound. + if (Math.abs(dx + dim) === 1) { + dx += dim; + } + else if (Math.abs(dx - dim) === 1) { + dx -= dim; + } + } + if (!borderTile.dem || !tile.dem) + return; + tile.dem.backfillBorder(borderTile.dem, dx, dy); + if (tile.neighboringTiles && tile.neighboringTiles[borderId]) + tile.neighboringTiles[borderId].backfilled = true; + } + } + /** + * Get a specific tile by TileID + */ + getTile(tileID) { + return this.getTileByID(tileID.key); + } + /** + * Get a specific tile by id + */ + getTileByID(id) { + return this._tiles[id]; + } + /** + * For a given set of tiles, retain children that are loaded and have a zoom + * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive) + */ + _retainLoadedChildren(idealTiles, zoom, maxCoveringZoom, retain) { + for (const id in this._tiles) { + let tile = this._tiles[id]; + // only consider renderable tiles up to maxCoveringZoom + if (retain[id] || + !tile.hasData() || + tile.tileID.overscaledZ <= zoom || + tile.tileID.overscaledZ > maxCoveringZoom) + continue; + // loop through parents and retain the topmost loaded one if found + let topmostLoadedID = tile.tileID; + while (tile && tile.tileID.overscaledZ > zoom + 1) { + const parentID = tile.tileID.scaledTo(tile.tileID.overscaledZ - 1); + tile = this._tiles[parentID.key]; + if (tile && tile.hasData()) { + topmostLoadedID = parentID; + } + } + // loop through ancestors of the topmost loaded child to see if there's one that needed it + let tileID = topmostLoadedID; + while (tileID.overscaledZ > zoom) { + tileID = tileID.scaledTo(tileID.overscaledZ - 1); + if (idealTiles[tileID.key]) { + // found a parent that needed a loaded child; retain that child + retain[topmostLoadedID.key] = topmostLoadedID; + break; + } + } + } + } + /** + * Find a loaded parent of the given tile (up to minCoveringZoom) + */ + findLoadedParent(tileID, minCoveringZoom) { + if (tileID.key in this._loadedParentTiles) { + const parent = this._loadedParentTiles[tileID.key]; + if (parent && parent.tileID.overscaledZ >= minCoveringZoom) { + return parent; + } + else { + return null; + } + } + for (let z = tileID.overscaledZ - 1; z >= minCoveringZoom; z--) { + const parentTileID = tileID.scaledTo(z); + const tile = this._getLoadedTile(parentTileID); + if (tile) { + return tile; + } + } + } + _getLoadedTile(tileID) { + const tile = this._tiles[tileID.key]; + if (tile && tile.hasData()) { + return tile; + } + // TileCache ignores wrap in lookup. + const cachedTile = this._cache.getByKey(tileID.wrapped().key); + return cachedTile; + } + /** + * Resizes the tile cache based on the current viewport's size + * or the maxTileCacheSize option passed during map creation + * + * Larger viewports use more tiles and need larger caches. Larger viewports + * are more likely to be found on devices with more memory and on pages where + * the map is more important. + */ + updateCacheSize(transform) { + const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1; + const heightInTiles = Math.ceil(transform.height / this._source.tileSize) + 1; + const approxTilesInView = widthInTiles * heightInTiles; + const commonZoomRange = this._maxTileCacheZoomLevels === null ? + performance.config.MAX_TILE_CACHE_ZOOM_LEVELS : this._maxTileCacheZoomLevels; + const viewDependentMaxSize = Math.floor(approxTilesInView * commonZoomRange); + const maxSize = typeof this._maxTileCacheSize === 'number' ? + Math.min(this._maxTileCacheSize, viewDependentMaxSize) : viewDependentMaxSize; + this._cache.setMaxSize(maxSize); + } + handleWrapJump(lng) { + // On top of the regular z/x/y values, TileIDs have a `wrap` value that specify + // which cppy of the world the tile belongs to. For example, at `lng: 10` you + // might render z/x/y/0 while at `lng: 370` you would render z/x/y/1. + // + // When lng values get wrapped (going from `lng: 370` to `long: 10`) you expect + // to see the same thing on the screen (370 degrees and 10 degrees is the same + // place in the world) but all the TileIDs will have different wrap values. + // + // In order to make this transition seamless, we calculate the rounded difference of + // "worlds" between the last frame and the current frame. If the map panned by + // a world, then we can assign all the tiles new TileIDs with updated wrap values. + // For example, assign z/x/y/1 a new id: z/x/y/0. It is the same tile, just rendered + // in a different position. + // + // This enables us to reuse the tiles at more ideal locations and prevent flickering. + const prevLng = this._prevLng === undefined ? lng : this._prevLng; + const lngDifference = lng - prevLng; + const worldDifference = lngDifference / 360; + const wrapDelta = Math.round(worldDifference); + this._prevLng = lng; + if (wrapDelta) { + const tiles = {}; + for (const key in this._tiles) { + const tile = this._tiles[key]; + tile.tileID = tile.tileID.unwrapTo(tile.tileID.wrap + wrapDelta); + tiles[tile.tileID.key] = tile; + } + this._tiles = tiles; + // Reset tile reload timers + for (const id in this._timers) { + clearTimeout(this._timers[id]); + delete this._timers[id]; + } + for (const id in this._tiles) { + const tile = this._tiles[id]; + this._setTileReloadTimer(id, tile); + } + } + } + /** + * Removes tiles that are outside the viewport and adds new tiles that + * are inside the viewport. + */ + update(transform, terrain) { + this.transform = transform; + this.terrain = terrain; + if (!this._sourceLoaded || this._paused) { + return; + } + this.updateCacheSize(transform); + this.handleWrapJump(this.transform.center.lng); + // Covered is a list of retained tiles who's areas are fully covered by other, + // better, retained tiles. They are not drawn separately. + this._coveredTiles = {}; + let idealTileIDs; + if (!this.used && !this.usedForTerrain) { + idealTileIDs = []; + } + else if (this._source.tileID) { + idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID) + .map((unwrapped) => new performance.OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y)); + } + else { + idealTileIDs = transform.coveringTiles({ + tileSize: this.usedForTerrain ? this.tileSize : this._source.tileSize, + minzoom: this._source.minzoom, + maxzoom: this._source.maxzoom, + roundZoom: this.usedForTerrain ? false : this._source.roundZoom, + reparseOverscaled: this._source.reparseOverscaled, + terrain + }); + if (this._source.hasTile) { + idealTileIDs = idealTileIDs.filter((coord) => this._source.hasTile(coord)); + } + } + // Determine the overzooming/underzooming amounts. + const zoom = transform.coveringZoomLevel(this._source); + const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom); + const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom); + // When sourcecache is used for terrain also load parent tiles to avoid flickering when zooming out + if (this.usedForTerrain) { + const parents = {}; + for (const tileID of idealTileIDs) { + if (tileID.canonical.z > this._source.minzoom) { + const parent = tileID.scaledTo(tileID.canonical.z - 1); + parents[parent.key] = parent; + // load very low zoom to calculate tile visibility in transform.coveringTiles and high zoomlevels correct + const parent2 = tileID.scaledTo(Math.max(this._source.minzoom, Math.min(tileID.canonical.z, 5))); + parents[parent2.key] = parent2; + } + } + idealTileIDs = idealTileIDs.concat(Object.values(parents)); + } + const noPendingDataEmissions = idealTileIDs.length === 0 && !this._updated && this._didEmitContent; + this._updated = true; + // if we won't have any tiles to fetch and content is already emitted + // there will be no more data emissions, so we need to emit the event with isSourceLoaded = true + if (noPendingDataEmissions) { + this.fire(new performance.Event('data', { sourceDataType: 'idle', dataType: 'source', sourceId: this.id })); + } + // Retain is a list of tiles that we shouldn't delete, even if they are not + // the most ideal tile for the current viewport. This may include tiles like + // parent or child tiles that are *already* loaded. + const retain = this._updateRetainedTiles(idealTileIDs, zoom); + if (isRasterType(this._source.type)) { + const parentsForFading = {}; + const fadingTiles = {}; + const ids = Object.keys(retain); + const now = performance.browser.now(); + for (const id of ids) { + const tileID = retain[id]; + const tile = this._tiles[id]; + // when fadeEndTime is 0, the tile is created but registerFadeDuration + // has not been called, therefore must be kept in fadingTiles dictionary + // for next round of rendering + if (!tile || (tile.fadeEndTime !== 0 && tile.fadeEndTime <= now)) { + continue; + } + // if the tile is loaded but still fading in, find parents to cross-fade with it + const parentTile = this.findLoadedParent(tileID, minCoveringZoom); + if (parentTile) { + this._addTile(parentTile.tileID); + parentsForFading[parentTile.tileID.key] = parentTile.tileID; + } + fadingTiles[id] = tileID; + } + // for tiles that are still fading in, also find children to cross-fade with + this._retainLoadedChildren(fadingTiles, zoom, maxCoveringZoom, retain); + for (const id in parentsForFading) { + if (!retain[id]) { + // If a tile is only needed for fading, mark it as covered so that it isn't rendered on it's own. + this._coveredTiles[id] = true; + retain[id] = parentsForFading[id]; + } + } + // disable fading logic in terrain3D mode to avoid rendering two tiles on the same place + if (terrain) { + const idealRasterTileIDs = {}; + const missingTileIDs = {}; + for (const tileID of idealTileIDs) { + if (this._tiles[tileID.key].hasData()) + idealRasterTileIDs[tileID.key] = tileID; + else + missingTileIDs[tileID.key] = tileID; + } + // search for a complete set of children for each missing tile + for (const key in missingTileIDs) { + const children = missingTileIDs[key].children(this._source.maxzoom); + if (this._tiles[children[0].key] && this._tiles[children[1].key] && this._tiles[children[2].key] && this._tiles[children[3].key]) { + idealRasterTileIDs[children[0].key] = retain[children[0].key] = children[0]; + idealRasterTileIDs[children[1].key] = retain[children[1].key] = children[1]; + idealRasterTileIDs[children[2].key] = retain[children[2].key] = children[2]; + idealRasterTileIDs[children[3].key] = retain[children[3].key] = children[3]; + delete missingTileIDs[key]; + } + } + // search for parent for each missing tile + for (const key in missingTileIDs) { + const parent = this.findLoadedParent(missingTileIDs[key], this._source.minzoom); + if (parent) { + idealRasterTileIDs[parent.tileID.key] = retain[parent.tileID.key] = parent.tileID; + // remove idealTiles which would be rendered twice + for (const key in idealRasterTileIDs) { + if (idealRasterTileIDs[key].isChildOf(parent.tileID)) + delete idealRasterTileIDs[key]; + } + } + } + // cover all tiles which are not needed + for (const key in this._tiles) { + if (!idealRasterTileIDs[key]) + this._coveredTiles[key] = true; + } + } + } + for (const retainedId in retain) { + // Make sure retained tiles always clear any existing fade holds + // so that if they're removed again their fade timer starts fresh. + this._tiles[retainedId].clearFadeHold(); + } + // Remove the tiles we don't need anymore. + const remove = performance.keysDifference(this._tiles, retain); + for (const tileID of remove) { + const tile = this._tiles[tileID]; + if (tile.hasSymbolBuckets && !tile.holdingForFade()) { + tile.setHoldDuration(this.map._fadeDuration); + } + else if (!tile.hasSymbolBuckets || tile.symbolFadeFinished()) { + this._removeTile(tileID); + } + } + // Construct a cache of loaded parents + this._updateLoadedParentTileCache(); + } + releaseSymbolFadeTiles() { + for (const id in this._tiles) { + if (this._tiles[id].holdingForFade()) { + this._removeTile(id); + } + } + } + _updateRetainedTiles(idealTileIDs, zoom) { + const retain = {}; + const checked = {}; + const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom); + const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom); + const missingTiles = {}; + for (const tileID of idealTileIDs) { + const tile = this._addTile(tileID); + // retain the tile even if it's not loaded because it's an ideal tile. + retain[tileID.key] = tileID; + if (tile.hasData()) + continue; + if (zoom < this._source.maxzoom) { + // save missing tiles that potentially have loaded children + missingTiles[tileID.key] = tileID; + } + } + // retain any loaded children of ideal tiles up to maxCoveringZoom + this._retainLoadedChildren(missingTiles, zoom, maxCoveringZoom, retain); + for (const tileID of idealTileIDs) { + let tile = this._tiles[tileID.key]; + if (tile.hasData()) + continue; + // The tile we require is not yet loaded or does not exist; + // Attempt to find children that fully cover it. + if (zoom + 1 > this._source.maxzoom) { + // We're looking for an overzoomed child tile. + const childCoord = tileID.children(this._source.maxzoom)[0]; + const childTile = this.getTile(childCoord); + if (!!childTile && childTile.hasData()) { + retain[childCoord.key] = childCoord; + continue; // tile is covered by overzoomed child + } + } + else { + // check if all 4 immediate children are loaded (i.e. the missing ideal tile is covered) + const children = tileID.children(this._source.maxzoom); + if (retain[children[0].key] && + retain[children[1].key] && + retain[children[2].key] && + retain[children[3].key]) + continue; // tile is covered by children + } + // We couldn't find child tiles that entirely cover the ideal tile; look for parents now. + // As we ascend up the tile pyramid of the ideal tile, we check whether the parent + // tile has been previously requested (and errored because we only loop over tiles with no data) + // in order to determine if we need to request its parent. + let parentWasRequested = tile.wasRequested(); + for (let overscaledZ = tileID.overscaledZ - 1; overscaledZ >= minCoveringZoom; --overscaledZ) { + const parentId = tileID.scaledTo(overscaledZ); + // Break parent tile ascent if this route has been previously checked by another child. + if (checked[parentId.key]) + break; + checked[parentId.key] = true; + tile = this.getTile(parentId); + if (!tile && parentWasRequested) { + tile = this._addTile(parentId); + } + if (tile) { + const hasData = tile.hasData(); + if (parentWasRequested || hasData) { + retain[parentId.key] = parentId; + } + // Save the current values, since they're the parent of the next iteration + // of the parent tile ascent loop. + parentWasRequested = tile.wasRequested(); + if (hasData) + break; + } + } + } + return retain; + } + _updateLoadedParentTileCache() { + this._loadedParentTiles = {}; + for (const tileKey in this._tiles) { + const path = []; + let parentTile; + let currentId = this._tiles[tileKey].tileID; + // Find the closest loaded ancestor by traversing the tile tree towards the root and + // caching results along the way + while (currentId.overscaledZ > 0) { + // Do we have a cached result from previous traversals? + if (currentId.key in this._loadedParentTiles) { + parentTile = this._loadedParentTiles[currentId.key]; + break; + } + path.push(currentId.key); + // Is the parent loaded? + const parentId = currentId.scaledTo(currentId.overscaledZ - 1); + parentTile = this._getLoadedTile(parentId); + if (parentTile) { + break; + } + currentId = parentId; + } + // Cache the result of this traversal to all newly visited tiles + for (const key of path) { + this._loadedParentTiles[key] = parentTile; + } + } + } + /** + * Add a tile, given its coordinate, to the pyramid. + */ + _addTile(tileID) { + let tile = this._tiles[tileID.key]; + if (tile) + return tile; + tile = this._cache.getAndRemove(tileID); + if (tile) { + this._setTileReloadTimer(tileID.key, tile); + // set the tileID because the cached tile could have had a different wrap value + tile.tileID = tileID; + this._state.initializeTileState(tile, this.map ? this.map.painter : null); + if (this._cacheTimers[tileID.key]) { + clearTimeout(this._cacheTimers[tileID.key]); + delete this._cacheTimers[tileID.key]; + this._setTileReloadTimer(tileID.key, tile); + } + } + const cached = tile; + if (!tile) { + tile = new Tile(tileID, this._source.tileSize * tileID.overscaleFactor()); + this._loadTile(tile, this._tileLoaded.bind(this, tile, tileID.key, tile.state)); + } + tile.uses++; + this._tiles[tileID.key] = tile; + if (!cached) { + this._source.fire(new performance.Event('dataloading', { tile, coord: tile.tileID, dataType: 'source' })); + } + return tile; + } + _setTileReloadTimer(id, tile) { + if (id in this._timers) { + clearTimeout(this._timers[id]); + delete this._timers[id]; + } + const expiryTimeout = tile.getExpiryTimeout(); + if (expiryTimeout) { + this._timers[id] = setTimeout(() => { + this._reloadTile(id, 'expired'); + delete this._timers[id]; + }, expiryTimeout); + } + } + /** + * Remove a tile, given its id, from the pyramid + */ + _removeTile(id) { + const tile = this._tiles[id]; + if (!tile) + return; + tile.uses--; + delete this._tiles[id]; + if (this._timers[id]) { + clearTimeout(this._timers[id]); + delete this._timers[id]; + } + if (tile.uses > 0) + return; + if (tile.hasData() && tile.state !== 'reloading') { + this._cache.add(tile.tileID, tile, tile.getExpiryTimeout()); + } + else { + tile.aborted = true; + this._abortTile(tile); + this._unloadTile(tile); + } + } + /** + * Remove all tiles from this pyramid + */ + clearTiles() { + this._shouldReloadOnResume = false; + this._paused = false; + for (const id in this._tiles) + this._removeTile(id); + this._cache.reset(); + } + /** + * Search through our current tiles and attempt to find the tiles that + * cover the given bounds. + * @param pointQueryGeometry - coordinates of the corners of bounding rectangle + * @returns result items have `{tile, minX, maxX, minY, maxY}`, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile. + */ + tilesIn(pointQueryGeometry, maxPitchScaleFactor, has3DLayer) { + const tileResults = []; + const transform = this.transform; + if (!transform) + return tileResults; + const cameraPointQueryGeometry = has3DLayer ? + transform.getCameraQueryGeometry(pointQueryGeometry) : + pointQueryGeometry; + const queryGeometry = pointQueryGeometry.map((p) => transform.pointCoordinate(p, this.terrain)); + const cameraQueryGeometry = cameraPointQueryGeometry.map((p) => transform.pointCoordinate(p, this.terrain)); + const ids = this.getIds(); + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + for (const p of cameraQueryGeometry) { + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + for (let i = 0; i < ids.length; i++) { + const tile = this._tiles[ids[i]]; + if (tile.holdingForFade()) { + // Tiles held for fading are covered by tiles that are closer to ideal + continue; + } + const tileID = tile.tileID; + const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ); + const queryPadding = maxPitchScaleFactor * tile.queryPadding * performance.EXTENT / tile.tileSize / scale; + const tileSpaceBounds = [ + tileID.getTilePoint(new performance.MercatorCoordinate(minX, minY)), + tileID.getTilePoint(new performance.MercatorCoordinate(maxX, maxY)) + ]; + if (tileSpaceBounds[0].x - queryPadding < performance.EXTENT && tileSpaceBounds[0].y - queryPadding < performance.EXTENT && + tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) { + const tileSpaceQueryGeometry = queryGeometry.map((c) => tileID.getTilePoint(c)); + const tileSpaceCameraQueryGeometry = cameraQueryGeometry.map((c) => tileID.getTilePoint(c)); + tileResults.push({ + tile, + tileID, + queryGeometry: tileSpaceQueryGeometry, + cameraQueryGeometry: tileSpaceCameraQueryGeometry, + scale + }); + } + } + return tileResults; + } + getVisibleCoordinates(symbolLayer) { + const coords = this.getRenderableIds(symbolLayer).map((id) => this._tiles[id].tileID); + for (const coord of coords) { + coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped()); + } + return coords; + } + hasTransition() { + if (this._source.hasTransition()) { + return true; + } + if (isRasterType(this._source.type)) { + const now = performance.browser.now(); + for (const id in this._tiles) { + const tile = this._tiles[id]; + if (tile.fadeEndTime >= now) { + return true; + } + } + } + return false; + } + /** + * Set the value of a particular state for a feature + */ + setFeatureState(sourceLayer, featureId, state) { + sourceLayer = sourceLayer || '_geojsonTileLayer'; + this._state.updateState(sourceLayer, featureId, state); + } + /** + * Resets the value of a particular state key for a feature + */ + removeFeatureState(sourceLayer, featureId, key) { + sourceLayer = sourceLayer || '_geojsonTileLayer'; + this._state.removeFeatureState(sourceLayer, featureId, key); + } + /** + * Get the entire state object for a feature + */ + getFeatureState(sourceLayer, featureId) { + sourceLayer = sourceLayer || '_geojsonTileLayer'; + return this._state.getState(sourceLayer, featureId); + } + /** + * Sets the set of keys that the tile depends on. This allows tiles to + * be reloaded when their dependencies change. + */ + setDependencies(tileKey, namespace, dependencies) { + const tile = this._tiles[tileKey]; + if (tile) { + tile.setDependencies(namespace, dependencies); + } + } + /** + * Reloads all tiles that depend on the given keys. + */ + reloadTilesForDependencies(namespaces, keys) { + for (const id in this._tiles) { + const tile = this._tiles[id]; + if (tile.hasDependency(namespaces, keys)) { + this._reloadTile(id, 'reloading'); + } + } + this._cache.filter(tile => !tile.hasDependency(namespaces, keys)); + } +} +SourceCache.maxOverzooming = 10; +SourceCache.maxUnderzooming = 3; +function compareTileId(a, b) { + // Different copies of the world are sorted based on their distance to the center. + // Wrap values are converted to unsigned distances by reserving odd number for copies + // with negative wrap and even numbers for copies with positive wrap. + const aWrap = Math.abs(a.wrap * 2) - +(a.wrap < 0); + const bWrap = Math.abs(b.wrap * 2) - +(b.wrap < 0); + return a.overscaledZ - b.overscaledZ || bWrap - aWrap || b.canonical.y - a.canonical.y || b.canonical.x - a.canonical.x; +} +function isRasterType(type) { + return type === 'raster' || type === 'image' || type === 'video'; +} + +function workerFactory() { + return new Worker(performance.config.WORKER_URL); +} + +const PRELOAD_POOL_ID = 'mapboxgl_preloaded_worker_pool'; +/** + * Constructs a worker pool. + */ +class WorkerPool { + constructor() { + this.active = {}; + } + acquire(mapId) { + if (!this.workers) { + // Lazily look up the value of mapboxgl.workerCount so that + // client code has had a chance to set it. + this.workers = []; + while (this.workers.length < WorkerPool.workerCount) { + this.workers.push(workerFactory()); + } + } + this.active[mapId] = true; + return this.workers.slice(); + } + release(mapId) { + delete this.active[mapId]; + if (this.numActive() === 0) { + this.workers.forEach((w) => { + w.terminate(); + }); + this.workers = null; + } + } + isPreloaded() { + return !!this.active[PRELOAD_POOL_ID]; + } + numActive() { + return Object.keys(this.active).length; + } +} +// Based on results from A/B testing: https://github.com/maplibre/maplibre-gl-js/pull/2354 +const availableLogicalProcessors = Math.floor(performance.browser.hardwareConcurrency / 2); +WorkerPool.workerCount = performance.isSafari(globalThis) ? Math.max(Math.min(availableLogicalProcessors, 3), 1) : 1; + +let globalWorkerPool; +/** + * Creates (if necessary) and returns the single, global WorkerPool instance + * to be shared across each Map + */ +function getGlobalWorkerPool() { + if (!globalWorkerPool) { + globalWorkerPool = new WorkerPool(); + } + return globalWorkerPool; +} +function prewarm() { + const workerPool = getGlobalWorkerPool(); + workerPool.acquire(PRELOAD_POOL_ID); +} +function clearPrewarmedResources() { + const pool = globalWorkerPool; + if (pool) { + // Remove the pool only if all maps that referenced the preloaded global worker pool have been removed. + if (pool.isPreloaded() && pool.numActive() === 1) { + pool.release(PRELOAD_POOL_ID); + globalWorkerPool = null; + } + else { + console.warn('Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()'); + } + } +} + +class PathInterpolator { + constructor(points_, padding_) { + this.reset(points_, padding_); + } + reset(points_, padding_) { + this.points = points_ || []; + // Compute cumulative distance from first point to every other point in the segment. + // Last entry in the array is total length of the path + this._distances = [0.0]; + for (let i = 1; i < this.points.length; i++) { + this._distances[i] = this._distances[i - 1] + this.points[i].dist(this.points[i - 1]); + } + this.length = this._distances[this._distances.length - 1]; + this.padding = Math.min(padding_ || 0, this.length * 0.5); + this.paddedLength = this.length - this.padding * 2.0; + } + lerp(t) { + if (this.points.length === 1) { + return this.points[0]; + } + t = performance.clamp(t, 0, 1); + // Find the correct segment [p0, p1] where p0 <= x < p1 + let currentIndex = 1; + let distOfCurrentIdx = this._distances[currentIndex]; + const distToTarget = t * this.paddedLength + this.padding; + while (distOfCurrentIdx < distToTarget && currentIndex < this._distances.length) { + distOfCurrentIdx = this._distances[++currentIndex]; + } + // Interpolate between the two points of the segment + const idxOfPrevPoint = currentIndex - 1; + const distOfPrevIdx = this._distances[idxOfPrevPoint]; + const segmentLength = distOfCurrentIdx - distOfPrevIdx; + const segmentT = segmentLength > 0 ? (distToTarget - distOfPrevIdx) / segmentLength : 0; + return this.points[idxOfPrevPoint].mult(1.0 - segmentT).add(this.points[currentIndex].mult(segmentT)); + } +} + +function overlapAllowed(overlapA, overlapB) { + let allowed = true; + if (overlapA === 'always') { + // symbol A using 'always' overlap - allowed to overlap anything. + } + else if (overlapA === 'never' || overlapB === 'never') { + // symbol A using 'never' overlap - can't overlap anything + // symbol A using 'cooperative' overlap - can overlap 'always' or 'cooperative' symbol; can't overlap 'never' + allowed = false; + } + return allowed; +} +/** + * @internal + * GridIndex is a data structure for testing the intersection of + * circles and rectangles in a 2d plane. + * It is optimized for rapid insertion and querying. + * GridIndex splits the plane into a set of "cells" and keeps track + * of which geometries intersect with each cell. At query time, + * full geometry comparisons are only done for items that share + * at least one cell. As long as the geometries are relatively + * uniformly distributed across the plane, this greatly reduces + * the number of comparisons necessary. + */ +class GridIndex { + constructor(width, height, cellSize) { + const boxCells = this.boxCells = []; + const circleCells = this.circleCells = []; + // More cells -> fewer geometries to check per cell, but items tend + // to be split across more cells. + // Sweet spot allows most small items to fit in one cell + this.xCellCount = Math.ceil(width / cellSize); + this.yCellCount = Math.ceil(height / cellSize); + for (let i = 0; i < this.xCellCount * this.yCellCount; i++) { + boxCells.push([]); + circleCells.push([]); + } + this.circleKeys = []; + this.boxKeys = []; + this.bboxes = []; + this.circles = []; + this.width = width; + this.height = height; + this.xScale = this.xCellCount / width; + this.yScale = this.yCellCount / height; + this.boxUid = 0; + this.circleUid = 0; + } + keysLength() { + return this.boxKeys.length + this.circleKeys.length; + } + insert(key, x1, y1, x2, y2) { + this._forEachCell(x1, y1, x2, y2, this._insertBoxCell, this.boxUid++); + this.boxKeys.push(key); + this.bboxes.push(x1); + this.bboxes.push(y1); + this.bboxes.push(x2); + this.bboxes.push(y2); + } + insertCircle(key, x, y, radius) { + // Insert circle into grid for all cells in the circumscribing square + // It's more than necessary (by a factor of 4/PI), but fast to insert + this._forEachCell(x - radius, y - radius, x + radius, y + radius, this._insertCircleCell, this.circleUid++); + this.circleKeys.push(key); + this.circles.push(x); + this.circles.push(y); + this.circles.push(radius); + } + _insertBoxCell(x1, y1, x2, y2, cellIndex, uid) { + this.boxCells[cellIndex].push(uid); + } + _insertCircleCell(x1, y1, x2, y2, cellIndex, uid) { + this.circleCells[cellIndex].push(uid); + } + _query(x1, y1, x2, y2, hitTest, overlapMode, predicate) { + if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) { + return []; + } + const result = []; + if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) { + if (hitTest) { + // Covers the entire grid, so collides with everything + return [{ + key: null, + x1, + y1, + x2, + y2 + }]; + } + for (let boxUid = 0; boxUid < this.boxKeys.length; boxUid++) { + result.push({ + key: this.boxKeys[boxUid], + x1: this.bboxes[boxUid * 4], + y1: this.bboxes[boxUid * 4 + 1], + x2: this.bboxes[boxUid * 4 + 2], + y2: this.bboxes[boxUid * 4 + 3] + }); + } + for (let circleUid = 0; circleUid < this.circleKeys.length; circleUid++) { + const x = this.circles[circleUid * 3]; + const y = this.circles[circleUid * 3 + 1]; + const radius = this.circles[circleUid * 3 + 2]; + result.push({ + key: this.circleKeys[circleUid], + x1: x - radius, + y1: y - radius, + x2: x + radius, + y2: y + radius + }); + } + } + else { + const queryArgs = { + hitTest, + overlapMode, + seenUids: { box: {}, circle: {} } + }; + this._forEachCell(x1, y1, x2, y2, this._queryCell, result, queryArgs, predicate); + } + return result; + } + query(x1, y1, x2, y2) { + return this._query(x1, y1, x2, y2, false, null); + } + hitTest(x1, y1, x2, y2, overlapMode, predicate) { + return this._query(x1, y1, x2, y2, true, overlapMode, predicate).length > 0; + } + hitTestCircle(x, y, radius, overlapMode, predicate) { + // Insert circle into grid for all cells in the circumscribing square + // It's more than necessary (by a factor of 4/PI), but fast to insert + const x1 = x - radius; + const x2 = x + radius; + const y1 = y - radius; + const y2 = y + radius; + if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) { + return false; + } + // Box query early exits if the bounding box is larger than the grid, but we don't do + // the equivalent calculation for circle queries because early exit is less likely + // and the calculation is more expensive + const result = []; + const queryArgs = { + hitTest: true, + overlapMode, + circle: { x, y, radius }, + seenUids: { box: {}, circle: {} } + }; + this._forEachCell(x1, y1, x2, y2, this._queryCellCircle, result, queryArgs, predicate); + return result.length > 0; + } + _queryCell(x1, y1, x2, y2, cellIndex, result, queryArgs, predicate) { + const { seenUids, hitTest, overlapMode } = queryArgs; + const boxCell = this.boxCells[cellIndex]; + if (boxCell !== null) { + const bboxes = this.bboxes; + for (const boxUid of boxCell) { + if (!seenUids.box[boxUid]) { + seenUids.box[boxUid] = true; + const offset = boxUid * 4; + const key = this.boxKeys[boxUid]; + if ((x1 <= bboxes[offset + 2]) && + (y1 <= bboxes[offset + 3]) && + (x2 >= bboxes[offset + 0]) && + (y2 >= bboxes[offset + 1]) && + (!predicate || predicate(key))) { + if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) { + result.push({ + key, + x1: bboxes[offset], + y1: bboxes[offset + 1], + x2: bboxes[offset + 2], + y2: bboxes[offset + 3] + }); + if (hitTest) { + // true return value stops the query after first match + return true; + } + } + } + } + } + } + const circleCell = this.circleCells[cellIndex]; + if (circleCell !== null) { + const circles = this.circles; + for (const circleUid of circleCell) { + if (!seenUids.circle[circleUid]) { + seenUids.circle[circleUid] = true; + const offset = circleUid * 3; + const key = this.circleKeys[circleUid]; + if (this._circleAndRectCollide(circles[offset], circles[offset + 1], circles[offset + 2], x1, y1, x2, y2) && + (!predicate || predicate(key))) { + if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) { + const x = circles[offset]; + const y = circles[offset + 1]; + const radius = circles[offset + 2]; + result.push({ + key, + x1: x - radius, + y1: y - radius, + x2: x + radius, + y2: y + radius + }); + if (hitTest) { + // true return value stops the query after first match + return true; + } + } + } + } + } + } + // false return to continue query + return false; + } + _queryCellCircle(x1, y1, x2, y2, cellIndex, result, queryArgs, predicate) { + const { circle, seenUids, overlapMode } = queryArgs; + const boxCell = this.boxCells[cellIndex]; + if (boxCell !== null) { + const bboxes = this.bboxes; + for (const boxUid of boxCell) { + if (!seenUids.box[boxUid]) { + seenUids.box[boxUid] = true; + const offset = boxUid * 4; + const key = this.boxKeys[boxUid]; + if (this._circleAndRectCollide(circle.x, circle.y, circle.radius, bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) && + (!predicate || predicate(key)) && + !overlapAllowed(overlapMode, key.overlapMode)) { + result.push(true); + return true; + } + } + } + } + const circleCell = this.circleCells[cellIndex]; + if (circleCell !== null) { + const circles = this.circles; + for (const circleUid of circleCell) { + if (!seenUids.circle[circleUid]) { + seenUids.circle[circleUid] = true; + const offset = circleUid * 3; + const key = this.circleKeys[circleUid]; + if (this._circlesCollide(circles[offset], circles[offset + 1], circles[offset + 2], circle.x, circle.y, circle.radius) && + (!predicate || predicate(key)) && + !overlapAllowed(overlapMode, key.overlapMode)) { + result.push(true); + return true; + } + } + } + } + } + _forEachCell(x1, y1, x2, y2, fn, arg1, arg2, predicate) { + const cx1 = this._convertToXCellCoord(x1); + const cy1 = this._convertToYCellCoord(y1); + const cx2 = this._convertToXCellCoord(x2); + const cy2 = this._convertToYCellCoord(y2); + for (let x = cx1; x <= cx2; x++) { + for (let y = cy1; y <= cy2; y++) { + const cellIndex = this.xCellCount * y + x; + if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) + return; + } + } + } + _convertToXCellCoord(x) { + return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale))); + } + _convertToYCellCoord(y) { + return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale))); + } + _circlesCollide(x1, y1, r1, x2, y2, r2) { + const dx = x2 - x1; + const dy = y2 - y1; + const bothRadii = r1 + r2; + return (bothRadii * bothRadii) > (dx * dx + dy * dy); + } + _circleAndRectCollide(circleX, circleY, radius, x1, y1, x2, y2) { + const halfRectWidth = (x2 - x1) / 2; + const distX = Math.abs(circleX - (x1 + halfRectWidth)); + if (distX > (halfRectWidth + radius)) { + return false; + } + const halfRectHeight = (y2 - y1) / 2; + const distY = Math.abs(circleY - (y1 + halfRectHeight)); + if (distY > (halfRectHeight + radius)) { + return false; + } + if (distX <= halfRectWidth || distY <= halfRectHeight) { + return true; + } + const dx = distX - halfRectWidth; + const dy = distY - halfRectHeight; + return (dx * dx + dy * dy <= (radius * radius)); + } +} + +/* + * # Overview of coordinate spaces + * + * ## Tile coordinate spaces + * Each label has an anchor. Some labels have corresponding line geometries. + * The points for both anchors and lines are stored in tile units. Each tile has it's own + * coordinate space going from (0, 0) at the top left to (EXTENT, EXTENT) at the bottom right. + * + * ## GL coordinate space + * At the end of everything, the vertex shader needs to produce a position in GL coordinate space, + * which is (-1, 1) at the top left and (1, -1) in the bottom right. + * + * ## Map pixel coordinate spaces + * Each tile has a pixel coordinate space. It's just the tile units scaled so that one unit is + * whatever counts as 1 pixel at the current zoom. + * This space is used for pitch-alignment=map, rotation-alignment=map + * + * ## Rotated map pixel coordinate spaces + * Like the above, but rotated so axis of the space are aligned with the viewport instead of the tile. + * This space is used for pitch-alignment=map, rotation-alignment=viewport + * + * ## Viewport pixel coordinate space + * (0, 0) is at the top left of the canvas and (pixelWidth, pixelHeight) is at the bottom right corner + * of the canvas. This space is used for pitch-alignment=viewport + * + * + * # Vertex projection + * It goes roughly like this: + * 1. project the anchor and line from tile units into the correct label coordinate space + * - map pixel space pitch-alignment=map rotation-alignment=map + * - rotated map pixel space pitch-alignment=map rotation-alignment=viewport + * - viewport pixel space pitch-alignment=viewport rotation-alignment=* + * 2. if the label follows a line, find the point along the line that is the correct distance from the anchor. + * 3. add the glyph's corner offset to the point from step 3 + * 4. convert from the label coordinate space to gl coordinates + * + * For horizontal labels we want to do step 1 in the shader for performance reasons (no cpu work). + * This is what `u_label_plane_matrix` is used for. + * For labels aligned with lines we have to steps 1 and 2 on the cpu since we need access to the line geometry. + * This is what `updateLineLabels(...)` does. + * Since the conversion is handled on the cpu we just set `u_label_plane_matrix` to an identity matrix. + * + * Steps 3 and 4 are done in the shaders for all labels. + */ +/* + * Returns a matrix for converting from tile units to the correct label coordinate space. + */ +function getLabelPlaneMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pixelsToTileUnits) { + const m = performance.create(); + if (pitchWithMap) { + performance.scale(m, m, [1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1]); + if (!rotateWithMap) { + performance.rotateZ(m, m, transform.angle); + } + } + else { + performance.multiply(m, transform.labelPlaneMatrix, posMatrix); + } + return m; +} +/* + * Returns a matrix for converting from the correct label coordinate space to gl coords. + */ +function getGlCoordMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pixelsToTileUnits) { + if (pitchWithMap) { + const m = performance.clone(posMatrix); + performance.scale(m, m, [pixelsToTileUnits, pixelsToTileUnits, 1]); + if (!rotateWithMap) { + performance.rotateZ(m, m, -transform.angle); + } + return m; + } + else { + return transform.glCoordMatrix; + } +} +function project(point, matrix, getElevation) { + let pos; + if (getElevation) { // slow because of handle z-index + pos = [point.x, point.y, getElevation(point.x, point.y), 1]; + performance.transformMat4(pos, pos, matrix); + } + else { // fast because of ignore z-index + pos = [point.x, point.y, 0, 1]; + xyTransformMat4(pos, pos, matrix); + } + const w = pos[3]; + return { + point: new performance.Point(pos[0] / w, pos[1] / w), + signedDistanceFromCamera: w + }; +} +function getPerspectiveRatio(cameraToCenterDistance, signedDistanceFromCamera) { + return 0.5 + 0.5 * (cameraToCenterDistance / signedDistanceFromCamera); +} +function isVisible(anchorPos, clippingBuffer) { + const x = anchorPos[0] / anchorPos[3]; + const y = anchorPos[1] / anchorPos[3]; + const inPaddedViewport = (x >= -clippingBuffer[0] && + x <= clippingBuffer[0] && + y >= -clippingBuffer[1] && + y <= clippingBuffer[1]); + return inPaddedViewport; +} +/* + * Update the `dynamicLayoutVertexBuffer` for the buffer with the correct glyph positions for the current map view. + * This is only run on labels that are aligned with lines. Horizontal labels are handled entirely in the shader. + */ +function updateLineLabels(bucket, posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright, rotateToLine, getElevation) { + const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData; + const partiallyEvaluatedSize = performance.evaluateSizeForZoom(sizeData, painter.transform.zoom); + const clippingBuffer = [256 / painter.width * 2 + 1, 256 / painter.height * 2 + 1]; + const dynamicLayoutVertexArray = isText ? + bucket.text.dynamicLayoutVertexArray : + bucket.icon.dynamicLayoutVertexArray; + dynamicLayoutVertexArray.clear(); + const lineVertexArray = bucket.lineVertexArray; + const placedSymbols = isText ? bucket.text.placedSymbolArray : bucket.icon.placedSymbolArray; + const aspectRatio = painter.transform.width / painter.transform.height; + let useVertical = false; + for (let s = 0; s < placedSymbols.length; s++) { + const symbol = placedSymbols.get(s); + // Don't do calculations for vertical glyphs unless the previous symbol was horizontal + // and we determined that vertical glyphs were necessary. + // Also don't do calculations for symbols that are collided and fully faded out + if (symbol.hidden || symbol.writingMode === performance.WritingMode.vertical && !useVertical) { + hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray); + continue; + } + // Awkward... but we're counting on the paired "vertical" symbol coming immediately after its horizontal counterpart + useVertical = false; + let anchorPos; + if (getElevation) { // slow because of handle z-index + anchorPos = [symbol.anchorX, symbol.anchorY, getElevation(symbol.anchorX, symbol.anchorY), 1]; + performance.transformMat4(anchorPos, anchorPos, posMatrix); + } + else { // fast because of ignore z-index + anchorPos = [symbol.anchorX, symbol.anchorY, 0, 1]; + xyTransformMat4(anchorPos, anchorPos, posMatrix); + } + // Don't bother calculating the correct point for invisible labels. + if (!isVisible(anchorPos, clippingBuffer)) { + hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray); + continue; + } + const cameraToAnchorDistance = anchorPos[3]; + const perspectiveRatio = getPerspectiveRatio(painter.transform.cameraToCenterDistance, cameraToAnchorDistance); + const fontSize = performance.evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol); + const pitchScaledFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio; + const tileAnchorPoint = new performance.Point(symbol.anchorX, symbol.anchorY); + const anchorPoint = project(tileAnchorPoint, labelPlaneMatrix, getElevation).point; + const projectionCache = { projections: {}, offsets: {} }; + const placeUnflipped = placeGlyphsAlongLine(symbol, pitchScaledFontSize, false /*unflipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation); + useVertical = placeUnflipped.useVertical; + if (placeUnflipped.notEnoughRoom || useVertical || + (placeUnflipped.needsFlipping && + placeGlyphsAlongLine(symbol, pitchScaledFontSize, true /*flipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation).notEnoughRoom)) { + hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray); + } + } + if (isText) { + bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray); + } + else { + bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray); + } +} +/* + * Place the first and last glyph of a line label, projected to the label plane. + * This function is called both during collision detection (to determine the label's size) + * and during line label rendering (to make sure the label fits on the line geometry with + * the current camera position, which may differ from the position used during collision detection). + * + * Calling this function has the effect of populating the "projectionCache" with all projected + * vertex locations the label will need, making future calls to placeGlyphAlongLine (for all the + * intermediate glyphs) much cheaper. + * + * Returns null if the label can't fit on the geometry + */ +function placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation) { + const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs; + const lineStartIndex = symbol.lineStartIndex; + const lineEndIndex = symbol.lineStartIndex + symbol.lineLength; + const firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex); + const lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1); + const firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!firstPlacedGlyph) + return null; + const lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!lastPlacedGlyph) + return null; + return { first: firstPlacedGlyph, last: lastPlacedGlyph }; +} +function requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRatio) { + if (writingMode === performance.WritingMode.horizontal) { + // On top of choosing whether to flip, choose whether to render this version of the glyphs or the alternate + // vertical glyphs. We can't just filter out vertical glyphs in the horizontal range because the horizontal + // and vertical versions can have slightly different projections which could lead to angles where both or + // neither showed. + const rise = Math.abs(lastPoint.y - firstPoint.y); + const run = Math.abs(lastPoint.x - firstPoint.x) * aspectRatio; + if (rise > run) { + return { useVertical: true }; + } + } + if (writingMode === performance.WritingMode.vertical ? firstPoint.y < lastPoint.y : firstPoint.x > lastPoint.x) { + // Includes "horizontalOnly" case for labels without vertical glyphs + return { needsFlipping: true }; + } + return null; +} +/* +* Place first and last glyph along the line projected to label plane, and if they fit +* iterate through all the intermediate glyphs, calculating their label plane positions +* from the projected line. +* +* Finally, add resulting glyph position calculations to dynamicLayoutVertexArray for +* upload to the GPU +*/ +function placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) { + const fontScale = fontSize / 24; + const lineOffsetX = symbol.lineOffsetX * fontScale; + const lineOffsetY = symbol.lineOffsetY * fontScale; + let placedGlyphs; + if (symbol.numGlyphs > 1) { + const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs; + const lineStartIndex = symbol.lineStartIndex; + const lineEndIndex = symbol.lineStartIndex + symbol.lineLength; + // Place the first and the last glyph in the label first, so we can figure out + // the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode + const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!firstAndLastGlyph) { + return { notEnoughRoom: true }; + } + const firstPoint = project(firstAndLastGlyph.first.point, glCoordMatrix, getElevation).point; + const lastPoint = project(firstAndLastGlyph.last.point, glCoordMatrix, getElevation).point; + if (keepUpright && !flip) { + const orientationChange = requiresOrientationChange(symbol.writingMode, firstPoint, lastPoint, aspectRatio); + if (orientationChange) { + return orientationChange; + } + } + placedGlyphs = [firstAndLastGlyph.first]; + for (let glyphIndex = symbol.glyphStartIndex + 1; glyphIndex < glyphEndIndex - 1; glyphIndex++) { + // Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed + placedGlyphs.push(placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation)); + } + placedGlyphs.push(firstAndLastGlyph.last); + } + else { + // Only a single glyph to place + // So, determine whether to flip based on projected angle of the line segment it's on + if (keepUpright && !flip) { + const a = project(tileAnchorPoint, posMatrix, getElevation).point; + const tileVertexIndex = (symbol.lineStartIndex + symbol.segment + 1); + const tileSegmentEnd = new performance.Point(lineVertexArray.getx(tileVertexIndex), lineVertexArray.gety(tileVertexIndex)); + const projectedVertex = project(tileSegmentEnd, posMatrix, getElevation); + // We know the anchor will be in the viewport, but the end of the line segment may be + // behind the plane of the camera, in which case we can use a point at any arbitrary (closer) + // point on the segment. + const b = (projectedVertex.signedDistanceFromCamera > 0) ? + projectedVertex.point : + projectTruncatedLineSegment(tileAnchorPoint, tileSegmentEnd, a, 1, posMatrix, getElevation); + const orientationChange = requiresOrientationChange(symbol.writingMode, a, b, aspectRatio); + if (orientationChange) { + return orientationChange; + } + } + const singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(symbol.glyphStartIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, symbol.lineStartIndex, symbol.lineStartIndex + symbol.lineLength, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!singleGlyph) + return { notEnoughRoom: true }; + placedGlyphs = [singleGlyph]; + } + for (const glyph of placedGlyphs) { + performance.addDynamicAttributes(dynamicLayoutVertexArray, glyph.point, glyph.angle); + } + return {}; +} +function projectTruncatedLineSegment(previousTilePoint, currentTilePoint, previousProjectedPoint, minimumLength, projectionMatrix, getElevation) { + // We are assuming "previousTilePoint" won't project to a point within one unit of the camera plane + // If it did, that would mean our label extended all the way out from within the viewport to a (very distant) + // point near the plane of the camera. We wouldn't be able to render the label anyway once it crossed the + // plane of the camera. + const projectedUnitVertex = project(previousTilePoint.add(previousTilePoint.sub(currentTilePoint)._unit()), projectionMatrix, getElevation).point; + const projectedUnitSegment = previousProjectedPoint.sub(projectedUnitVertex); + return previousProjectedPoint.add(projectedUnitSegment._mult(minimumLength / projectedUnitSegment.mag())); +} +/** + * Transform a vertex from tile coordinates to label plane coordinates + * @param index - index of vertex to project + * @param projectionArgs - necessary data to project a vertex + * @returns the vertex projected to the label plane + */ +function projectVertexToViewport(index, projectionArgs) { + const { projectionCache, lineVertexArray, labelPlaneMatrix, tileAnchorPoint, distanceFromAnchor, getElevation, previousVertex, direction, absOffsetX } = projectionArgs; + if (projectionCache.projections[index]) { + return projectionCache.projections[index]; + } + const currentVertex = new performance.Point(lineVertexArray.getx(index), lineVertexArray.gety(index)); + const projection = project(currentVertex, labelPlaneMatrix, getElevation); + if (projection.signedDistanceFromCamera > 0) { + projectionCache.projections[index] = projection.point; + return projection.point; + } + // The vertex is behind the plane of the camera, so we can't project it + // Instead, we'll create a vertex along the line that's far enough to include the glyph + const previousLineVertexIndex = index - direction; + const previousTilePoint = distanceFromAnchor === 0 ? + tileAnchorPoint : + new performance.Point(lineVertexArray.getx(previousLineVertexIndex), lineVertexArray.gety(previousLineVertexIndex)); + // Don't cache because the new vertex might not be far enough out for future glyphs on the same segment + return projectTruncatedLineSegment(previousTilePoint, currentVertex, previousVertex, absOffsetX - distanceFromAnchor + 1, labelPlaneMatrix, getElevation); +} +/** + * Calculate the normal vector for a line segment + * @param segmentVector - will be mutated as a tiny optimization + * @param offset - magnitude of resulting vector + * @param direction - direction of line traversal + * @returns a normal vector from the segment, with magnitude equal to offset amount + */ +function transformToOffsetNormal(segmentVector, offset, direction) { + return segmentVector._unit()._perp()._mult(offset * direction); +} +/** + * Construct offset line segments for the current segment and the next segment, then extend/shrink + * the segments until they intersect. If the segments are parallel, then they will touch with no modification. + * + * @param index - Index of the current vertex + * @param prevToCurrentOffsetNormal - Normal vector of the line segment from the previous vertex to the current vertex + * @param currentVertex - Current (non-offset) vertex projected to the label plane + * @param lineStartIndex - Beginning index for the line this label is on + * @param lineEndIndex - End index for the line this label is on + * @param offsetPreviousVertex - The previous vertex projected to the label plane, and then offset along the previous segments normal + * @param lineOffsetY - Magnitude of the offset + * @param projectionArgs - Necessary data for tile-to-label-plane projection + * @returns The point at which the current and next line segments intersect, once offset and extended/shrunk to their meeting point + */ +function findOffsetIntersectionPoint(index, prevToCurrentOffsetNormal, currentVertex, lineStartIndex, lineEndIndex, offsetPreviousVertex, lineOffsetY, projectionArgs) { + const { projectionCache, direction } = projectionArgs; + if (projectionCache.offsets[index]) { + return projectionCache.offsets[index]; + } + const offsetCurrentVertex = currentVertex.add(prevToCurrentOffsetNormal); + if (index + direction < lineStartIndex || index + direction >= lineEndIndex) { + // This is the end of the line, no intersection to calculate + projectionCache.offsets[index] = offsetCurrentVertex; + return offsetCurrentVertex; + } + // Offset the vertices for the next segment + const nextVertex = projectVertexToViewport(index + direction, projectionArgs); + const currentToNextOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction); + const offsetNextSegmentBegin = currentVertex.add(currentToNextOffsetNormal); + const offsetNextSegmentEnd = nextVertex.add(currentToNextOffsetNormal); + // find the intersection of these two lines + // if the lines are parallel, offsetCurrent/offsetNextBegin will touch + projectionCache.offsets[index] = performance.findLineIntersection(offsetPreviousVertex, offsetCurrentVertex, offsetNextSegmentBegin, offsetNextSegmentEnd) || offsetCurrentVertex; + return projectionCache.offsets[index]; +} +/* + * Place a single glyph along its line, projected into the label plane, by iterating outward + * from the anchor point until the distance traversed in the label plane equals the glyph's + * offsetX. Returns null if the glyph can't fit on the line geometry. + */ +function placeGlyphAlongLine(offsetX, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, anchorSegment, lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation) { + const combinedOffsetX = flip ? + offsetX - lineOffsetX : + offsetX + lineOffsetX; + let direction = combinedOffsetX > 0 ? 1 : -1; + let angle = 0; + if (flip) { + // The label needs to be flipped to keep text upright. + // Iterate in the reverse direction. + direction *= -1; + angle = Math.PI; + } + if (direction < 0) + angle += Math.PI; + let currentIndex = direction > 0 ? + lineStartIndex + anchorSegment : + lineStartIndex + anchorSegment + 1; + let currentVertex = anchorPoint; + let previousVertex = anchorPoint; + // offsetPrev and intersectionPoint are analogous to previousVertex and currentVertex + // but if there's a line offset they are calculated in parallel as projection happens + let offsetIntersectionPoint; + let offsetPreviousVertex; + let distanceFromAnchor = 0; + let currentSegmentDistance = 0; + const absOffsetX = Math.abs(combinedOffsetX); + const pathVertices = []; + let currentLineSegment; + while (distanceFromAnchor + currentSegmentDistance <= absOffsetX) { + currentIndex += direction; + // offset does not fit on the projected line + if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex) + return null; + // accumulate values from last iteration + distanceFromAnchor += currentSegmentDistance; + previousVertex = currentVertex; + offsetPreviousVertex = offsetIntersectionPoint; + const projectionArgs = { + projectionCache, + lineVertexArray, + labelPlaneMatrix, + tileAnchorPoint, + distanceFromAnchor, + getElevation, + previousVertex, + direction, + absOffsetX + }; + // find next vertex in viewport space + currentVertex = projectVertexToViewport(currentIndex, projectionArgs); + if (lineOffsetY === 0) { + // Store vertices for collision detection and update current segment geometry + pathVertices.push(previousVertex); + currentLineSegment = currentVertex.sub(previousVertex); + } + else { + // Calculate the offset for this section + let prevToCurrentOffsetNormal; + const prevToCurrent = currentVertex.sub(previousVertex); + if (prevToCurrent.mag() === 0) { + // We are starting with our anchor point directly on the vertex, so look one vertex ahead + // to calculate a normal + const nextVertex = projectVertexToViewport(currentIndex + direction, projectionArgs); + prevToCurrentOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction); + } + else { + prevToCurrentOffsetNormal = transformToOffsetNormal(prevToCurrent, lineOffsetY, direction); + } + // Initialize offsetPrev on our first iteration, after that it will be pre-calculated + if (!offsetPreviousVertex) + offsetPreviousVertex = previousVertex.add(prevToCurrentOffsetNormal); + offsetIntersectionPoint = findOffsetIntersectionPoint(currentIndex, prevToCurrentOffsetNormal, currentVertex, lineStartIndex, lineEndIndex, offsetPreviousVertex, lineOffsetY, projectionArgs); + pathVertices.push(offsetPreviousVertex); + currentLineSegment = offsetIntersectionPoint.sub(offsetPreviousVertex); + } + currentSegmentDistance = currentLineSegment.mag(); + } + // The point is on the current segment. Interpolate to find it. + const segmentInterpolationT = (absOffsetX - distanceFromAnchor) / currentSegmentDistance; + const p = currentLineSegment._mult(segmentInterpolationT)._add(offsetPreviousVertex || previousVertex); + const segmentAngle = angle + Math.atan2(currentVertex.y - previousVertex.y, currentVertex.x - previousVertex.x); + pathVertices.push(p); + return { + point: p, + angle: rotateToLine ? segmentAngle : 0.0, + path: pathVertices + }; +} +const hiddenGlyphAttributes = new Float32Array([-Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0]); +// Hide them by moving them offscreen. We still need to add them to the buffer +// because the dynamic buffer is paired with a static buffer that doesn't get updated. +function hideGlyphs(num, dynamicLayoutVertexArray) { + for (let i = 0; i < num; i++) { + const offset = dynamicLayoutVertexArray.length; + dynamicLayoutVertexArray.resize(offset + 4); + // Since all hidden glyphs have the same attributes, we can build up the array faster with a single call to Float32Array.set + // for each set of four vertices, instead of calling addDynamicAttributes for each vertex. + dynamicLayoutVertexArray.float32.set(hiddenGlyphAttributes, offset * 3); + } +} +// For line label layout, we're not using z output and our w input is always 1 +// This custom matrix transformation ignores those components to make projection faster +function xyTransformMat4(out, a, m) { + const x = a[0], y = a[1]; + out[0] = m[0] * x + m[4] * y + m[12]; + out[1] = m[1] * x + m[5] * y + m[13]; + out[3] = m[3] * x + m[7] * y + m[15]; + return out; +} + +// When a symbol crosses the edge that causes it to be included in +// collision detection, it will cause changes in the symbols around +// it. This constant specifies how many pixels to pad the edge of +// the viewport for collision detection so that the bulk of the changes +// occur offscreen. Making this constant greater increases label +// stability, but it's expensive. +const viewportPadding = 100; +/** + * @internal + * A collision index used to prevent symbols from overlapping. It keep tracks of + * where previous symbols have been placed and is used to check if a new + * symbol overlaps with any previously added symbols. + * + * There are two steps to insertion: first placeCollisionBox/Circles checks if + * there's room for a symbol, then insertCollisionBox/Circles actually puts the + * symbol in the index. The two step process allows paired symbols to be inserted + * together even if they overlap. + */ +class CollisionIndex { + constructor(transform, grid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25), ignoredGrid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25)) { + this.transform = transform; + this.grid = grid; + this.ignoredGrid = ignoredGrid; + this.pitchfactor = Math.cos(transform._pitch) * transform.cameraToCenterDistance; + this.screenRightBoundary = transform.width + viewportPadding; + this.screenBottomBoundary = transform.height + viewportPadding; + this.gridRightBoundary = transform.width + 2 * viewportPadding; + this.gridBottomBoundary = transform.height + 2 * viewportPadding; + this.perspectiveRatioCutoff = 0.6; + } + placeCollisionBox(collisionBox, overlapMode, textPixelRatio, posMatrix, collisionGroupPredicate, getElevation) { + const projectedPoint = this.projectAndGetPerspectiveRatio(posMatrix, collisionBox.anchorPointX, collisionBox.anchorPointY, getElevation); + const tileToViewport = textPixelRatio * projectedPoint.perspectiveRatio; + const tlX = collisionBox.x1 * tileToViewport + projectedPoint.point.x; + const tlY = collisionBox.y1 * tileToViewport + projectedPoint.point.y; + const brX = collisionBox.x2 * tileToViewport + projectedPoint.point.x; + const brY = collisionBox.y2 * tileToViewport + projectedPoint.point.y; + if (!this.isInsideGrid(tlX, tlY, brX, brY) || + (overlapMode !== 'always' && this.grid.hitTest(tlX, tlY, brX, brY, overlapMode, collisionGroupPredicate)) || + projectedPoint.perspectiveRatio < this.perspectiveRatioCutoff) { + return { + box: [], + offscreen: false + }; + } + return { + box: [tlX, tlY, brX, brY], + offscreen: this.isOffscreen(tlX, tlY, brX, brY) + }; + } + placeCollisionCircles(overlapMode, symbol, lineVertexArray, glyphOffsetArray, fontSize, posMatrix, labelPlaneMatrix, labelToScreenMatrix, showCollisionCircles, pitchWithMap, collisionGroupPredicate, circlePixelDiameter, textPixelPadding, getElevation) { + const placedCollisionCircles = []; + const tileUnitAnchorPoint = new performance.Point(symbol.anchorX, symbol.anchorY); + const screenAnchorPoint = project(tileUnitAnchorPoint, posMatrix, getElevation); + const perspectiveRatio = getPerspectiveRatio(this.transform.cameraToCenterDistance, screenAnchorPoint.signedDistanceFromCamera); + const labelPlaneFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio; + const labelPlaneFontScale = labelPlaneFontSize / performance.ONE_EM; + const labelPlaneAnchorPoint = project(tileUnitAnchorPoint, labelPlaneMatrix, getElevation).point; + const projectionCache = { projections: {}, offsets: {} }; + const lineOffsetX = symbol.lineOffsetX * labelPlaneFontScale; + const lineOffsetY = symbol.lineOffsetY * labelPlaneFontScale; + const firstAndLastGlyph = placeFirstAndLastGlyph(labelPlaneFontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, + /*flip*/ false, labelPlaneAnchorPoint, tileUnitAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, false, getElevation); + let collisionDetected = false; + let inGrid = false; + let entirelyOffscreen = true; + if (firstAndLastGlyph) { + const radius = circlePixelDiameter * 0.5 * perspectiveRatio + textPixelPadding; + const screenPlaneMin = new performance.Point(-viewportPadding, -viewportPadding); + const screenPlaneMax = new performance.Point(this.screenRightBoundary, this.screenBottomBoundary); + const interpolator = new PathInterpolator(); + // Construct a projected path from projected line vertices. Anchor points are ignored and removed + const first = firstAndLastGlyph.first; + const last = firstAndLastGlyph.last; + let projectedPath = []; + for (let i = first.path.length - 1; i >= 1; i--) { + projectedPath.push(first.path[i]); + } + for (let i = 1; i < last.path.length; i++) { + projectedPath.push(last.path[i]); + } + // Tolerate a slightly longer distance than one diameter between two adjacent circles + const circleDist = radius * 2.5; + // The path might need to be converted into screen space if a pitched map is used as the label space + if (labelToScreenMatrix) { + const screenSpacePath = projectedPath.map(p => project(p, labelToScreenMatrix, getElevation)); + // Do not try to place collision circles if even of the points is behind the camera. + // This is a plausible scenario with big camera pitch angles + if (screenSpacePath.some(point => point.signedDistanceFromCamera <= 0)) { + projectedPath = []; + } + else { + projectedPath = screenSpacePath.map(p => p.point); + } + } + let segments = []; + if (projectedPath.length > 0) { + // Quickly check if the path is fully inside or outside of the padded collision region. + // For overlapping paths we'll only create collision circles for the visible segments + const minPoint = projectedPath[0].clone(); + const maxPoint = projectedPath[0].clone(); + for (let i = 1; i < projectedPath.length; i++) { + minPoint.x = Math.min(minPoint.x, projectedPath[i].x); + minPoint.y = Math.min(minPoint.y, projectedPath[i].y); + maxPoint.x = Math.max(maxPoint.x, projectedPath[i].x); + maxPoint.y = Math.max(maxPoint.y, projectedPath[i].y); + } + if (minPoint.x >= screenPlaneMin.x && maxPoint.x <= screenPlaneMax.x && + minPoint.y >= screenPlaneMin.y && maxPoint.y <= screenPlaneMax.y) { + // Quad fully visible + segments = [projectedPath]; + } + else if (maxPoint.x < screenPlaneMin.x || minPoint.x > screenPlaneMax.x || + maxPoint.y < screenPlaneMin.y || minPoint.y > screenPlaneMax.y) { + // Not visible + segments = []; + } + else { + segments = performance.clipLine([projectedPath], screenPlaneMin.x, screenPlaneMin.y, screenPlaneMax.x, screenPlaneMax.y); + } + } + for (const seg of segments) { + // interpolate positions for collision circles. Add a small padding to both ends of the segment + interpolator.reset(seg, radius * 0.25); + let numCircles = 0; + if (interpolator.length <= 0.5 * radius) { + numCircles = 1; + } + else { + numCircles = Math.ceil(interpolator.paddedLength / circleDist) + 1; + } + for (let i = 0; i < numCircles; i++) { + const t = i / Math.max(numCircles - 1, 1); + const circlePosition = interpolator.lerp(t); + // add viewport padding to the position and perform initial collision check + const centerX = circlePosition.x + viewportPadding; + const centerY = circlePosition.y + viewportPadding; + placedCollisionCircles.push(centerX, centerY, radius, 0); + const x1 = centerX - radius; + const y1 = centerY - radius; + const x2 = centerX + radius; + const y2 = centerY + radius; + entirelyOffscreen = entirelyOffscreen && this.isOffscreen(x1, y1, x2, y2); + inGrid = inGrid || this.isInsideGrid(x1, y1, x2, y2); + if (overlapMode !== 'always' && this.grid.hitTestCircle(centerX, centerY, radius, overlapMode, collisionGroupPredicate)) { + // Don't early exit if we're showing the debug circles because we still want to calculate + // which circles are in use + collisionDetected = true; + if (!showCollisionCircles) { + return { + circles: [], + offscreen: false, + collisionDetected + }; + } + } + } + } + } + return { + circles: ((!showCollisionCircles && collisionDetected) || !inGrid || perspectiveRatio < this.perspectiveRatioCutoff) ? [] : placedCollisionCircles, + offscreen: entirelyOffscreen, + collisionDetected + }; + } + /** + * Because the geometries in the CollisionIndex are an approximation of the shape of + * symbols on the map, we use the CollisionIndex to look up the symbol part of + * `queryRenderedFeatures`. + */ + queryRenderedSymbols(viewportQueryGeometry) { + if (viewportQueryGeometry.length === 0 || (this.grid.keysLength() === 0 && this.ignoredGrid.keysLength() === 0)) { + return {}; + } + const query = []; + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + for (const point of viewportQueryGeometry) { + const gridPoint = new performance.Point(point.x + viewportPadding, point.y + viewportPadding); + minX = Math.min(minX, gridPoint.x); + minY = Math.min(minY, gridPoint.y); + maxX = Math.max(maxX, gridPoint.x); + maxY = Math.max(maxY, gridPoint.y); + query.push(gridPoint); + } + const features = this.grid.query(minX, minY, maxX, maxY) + .concat(this.ignoredGrid.query(minX, minY, maxX, maxY)); + const seenFeatures = {}; + const result = {}; + for (const feature of features) { + const featureKey = feature.key; + // Skip already seen features. + if (seenFeatures[featureKey.bucketInstanceId] === undefined) { + seenFeatures[featureKey.bucketInstanceId] = {}; + } + if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) { + continue; + } + // Check if query intersects with the feature box + // "Collision Circles" for line labels are treated as boxes here + // Since there's no actual collision taking place, the circle vs. square + // distinction doesn't matter as much, and box geometry is easier + // to work with. + const bbox = [ + new performance.Point(feature.x1, feature.y1), + new performance.Point(feature.x2, feature.y1), + new performance.Point(feature.x2, feature.y2), + new performance.Point(feature.x1, feature.y2) + ]; + if (!performance.polygonIntersectsPolygon(query, bbox)) { + continue; + } + seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true; + if (result[featureKey.bucketInstanceId] === undefined) { + result[featureKey.bucketInstanceId] = []; + } + result[featureKey.bucketInstanceId].push(featureKey.featureIndex); + } + return result; + } + insertCollisionBox(collisionBox, overlapMode, ignorePlacement, bucketInstanceId, featureIndex, collisionGroupID) { + const grid = ignorePlacement ? this.ignoredGrid : this.grid; + const key = { bucketInstanceId, featureIndex, collisionGroupID, overlapMode }; + grid.insert(key, collisionBox[0], collisionBox[1], collisionBox[2], collisionBox[3]); + } + insertCollisionCircles(collisionCircles, overlapMode, ignorePlacement, bucketInstanceId, featureIndex, collisionGroupID) { + const grid = ignorePlacement ? this.ignoredGrid : this.grid; + const key = { bucketInstanceId, featureIndex, collisionGroupID, overlapMode }; + for (let k = 0; k < collisionCircles.length; k += 4) { + grid.insertCircle(key, collisionCircles[k], collisionCircles[k + 1], collisionCircles[k + 2]); + } + } + projectAndGetPerspectiveRatio(posMatrix, x, y, getElevation) { + let p; + if (getElevation) { // slow because of handle z-index + p = [x, y, getElevation(x, y), 1]; + performance.transformMat4(p, p, posMatrix); + } + else { // fast because of ignore z-index + p = [x, y, 0, 1]; + xyTransformMat4(p, p, posMatrix); + } + const a = new performance.Point((((p[0] / p[3] + 1) / 2) * this.transform.width) + viewportPadding, (((-p[1] / p[3] + 1) / 2) * this.transform.height) + viewportPadding); + return { + point: a, + // See perspective ratio comment in symbol_sdf.vertex + // We're doing collision detection in viewport space so we need + // to scale down boxes in the distance + perspectiveRatio: 0.5 + 0.5 * (this.transform.cameraToCenterDistance / p[3]) + }; + } + isOffscreen(x1, y1, x2, y2) { + return x2 < viewportPadding || x1 >= this.screenRightBoundary || y2 < viewportPadding || y1 > this.screenBottomBoundary; + } + isInsideGrid(x1, y1, x2, y2) { + return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary; + } + /* + * Returns a matrix for transforming collision shapes to viewport coordinate space. + * Use this function to render e.g. collision circles on the screen. + * example transformation: clipPos = glCoordMatrix * viewportMatrix * circle_pos + */ + getViewportMatrix() { + const m = performance.identity([]); + performance.translate(m, m, [-viewportPadding, -viewportPadding, 0.0]); + return m; + } +} + +/** + * Converts a pixel value at a the given zoom level to tile units. + * + * The shaders mostly calculate everything in tile units so style + * properties need to be converted from pixels to tile units using this. + * + * For example, a translation by 30 pixels at zoom 6.5 will be a + * translation by pixelsToTileUnits(30, 6.5) tile units. + * + * @returns value in tile units + */ +function pixelsToTileUnits(tile, pixelValue, z) { + return pixelValue * (performance.EXTENT / (tile.tileSize * Math.pow(2, z - tile.tileID.overscaledZ))); +} + +class OpacityState { + constructor(prevState, increment, placed, skipFade) { + if (prevState) { + this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment))); + } + else { + this.opacity = (skipFade && placed) ? 1 : 0; + } + this.placed = placed; + } + isHidden() { + return this.opacity === 0 && !this.placed; + } +} +class JointOpacityState { + constructor(prevState, increment, placedText, placedIcon, skipFade) { + this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade); + this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade); + } + isHidden() { + return this.text.isHidden() && this.icon.isHidden(); + } +} +class JointPlacement { + constructor(text, icon, skipFade) { + this.text = text; + this.icon = icon; + this.skipFade = skipFade; + } +} +class CollisionCircleArray { + constructor() { + this.invProjMatrix = performance.create(); + this.viewportMatrix = performance.create(); + this.circles = []; + } +} +class RetainedQueryData { + constructor(bucketInstanceId, featureIndex, sourceLayerIndex, bucketIndex, tileID) { + this.bucketInstanceId = bucketInstanceId; + this.featureIndex = featureIndex; + this.sourceLayerIndex = sourceLayerIndex; + this.bucketIndex = bucketIndex; + this.tileID = tileID; + } +} +class CollisionGroups { + constructor(crossSourceCollisions) { + this.crossSourceCollisions = crossSourceCollisions; + this.maxGroupID = 0; + this.collisionGroups = {}; + } + get(sourceID) { + // The predicate/groupID mechanism allows for arbitrary grouping, + // but the current interface defines one source == one group when + // crossSourceCollisions == true. + if (!this.crossSourceCollisions) { + if (!this.collisionGroups[sourceID]) { + const nextGroupID = ++this.maxGroupID; + this.collisionGroups[sourceID] = { + ID: nextGroupID, + predicate: (key) => { + return key.collisionGroupID === nextGroupID; + } + }; + } + return this.collisionGroups[sourceID]; + } + else { + return { ID: 0, predicate: null }; + } + } +} +function calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale) { + const { horizontalAlign, verticalAlign } = performance.getAnchorAlignment(anchor); + const shiftX = -(horizontalAlign - 0.5) * width; + const shiftY = -(verticalAlign - 0.5) * height; + return new performance.Point(shiftX + textOffset[0] * textBoxScale, shiftY + textOffset[1] * textBoxScale); +} +function shiftVariableCollisionBox(collisionBox, shiftX, shiftY, rotateWithMap, pitchWithMap, angle) { + const { x1, x2, y1, y2, anchorPointX, anchorPointY } = collisionBox; + const rotatedOffset = new performance.Point(shiftX, shiftY); + if (rotateWithMap) { + rotatedOffset._rotate(pitchWithMap ? angle : -angle); + } + return { + x1: x1 + rotatedOffset.x, + y1: y1 + rotatedOffset.y, + x2: x2 + rotatedOffset.x, + y2: y2 + rotatedOffset.y, + // symbol anchor point stays the same regardless of text-anchor + anchorPointX, + anchorPointY + }; +} +class Placement { + constructor(transform, terrain, fadeDuration, crossSourceCollisions, prevPlacement) { + this.transform = transform.clone(); + this.terrain = terrain; + this.collisionIndex = new CollisionIndex(this.transform); + this.placements = {}; + this.opacities = {}; + this.variableOffsets = {}; + this.stale = false; + this.commitTime = 0; + this.fadeDuration = fadeDuration; + this.retainedQueryData = {}; + this.collisionGroups = new CollisionGroups(crossSourceCollisions); + this.collisionCircleArrays = {}; + this.prevPlacement = prevPlacement; + if (prevPlacement) { + prevPlacement.prevPlacement = undefined; // Only hold on to one placement back + } + this.placedOrientations = {}; + } + getBucketParts(results, styleLayer, tile, sortAcrossTiles) { + const symbolBucket = tile.getBucket(styleLayer); + const bucketFeatureIndex = tile.latestFeatureIndex; + if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0]) + return; + const collisionBoxArray = tile.collisionBoxArray; + const layout = symbolBucket.layers[0].layout; + const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ); + const textPixelRatio = tile.tileSize / performance.EXTENT; + const posMatrix = this.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; + const pixelsToTiles = pixelsToTileUnits(tile, 1, this.transform.zoom); + const textLabelPlaneMatrix = getLabelPlaneMatrix(posMatrix, pitchWithMap, rotateWithMap, this.transform, pixelsToTiles); + let labelToScreenMatrix = null; + if (pitchWithMap) { + const glMatrix = getGlCoordMatrix(posMatrix, pitchWithMap, rotateWithMap, this.transform, pixelsToTiles); + labelToScreenMatrix = performance.multiply([], this.transform.labelPlaneMatrix, glMatrix); + } + // As long as this placement lives, we have to hold onto this bucket's + // matching FeatureIndex/data for querying purposes + this.retainedQueryData[symbolBucket.bucketInstanceId] = new RetainedQueryData(symbolBucket.bucketInstanceId, bucketFeatureIndex, symbolBucket.sourceLayerIndex, symbolBucket.index, tile.tileID); + const parameters = { + bucket: symbolBucket, + layout, + posMatrix, + textLabelPlaneMatrix, + labelToScreenMatrix, + scale, + textPixelRatio, + holdingForFade: tile.holdingForFade(), + collisionBoxArray, + partiallyEvaluatedTextSize: performance.evaluateSizeForZoom(symbolBucket.textSizeData, this.transform.zoom), + collisionGroup: this.collisionGroups.get(symbolBucket.sourceID) + }; + if (sortAcrossTiles) { + for (const range of symbolBucket.sortKeyRanges) { + const { sortKey, symbolInstanceStart, symbolInstanceEnd } = range; + results.push({ sortKey, symbolInstanceStart, symbolInstanceEnd, parameters }); + } + } + else { + results.push({ + symbolInstanceStart: 0, + symbolInstanceEnd: symbolBucket.symbolInstances.length, + parameters + }); + } + } + attemptAnchorPlacement(textAnchorOffset, textBox, width, height, textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix, collisionGroup, textOverlapMode, symbolInstance, bucket, orientation, iconBox, getElevation) { + const anchor = performance.TextAnchorEnum[textAnchorOffset.textAnchor]; + const textOffset = [textAnchorOffset.textOffset0, textAnchorOffset.textOffset1]; + const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale); + const placedGlyphBoxes = this.collisionIndex.placeCollisionBox(shiftVariableCollisionBox(textBox, shift.x, shift.y, rotateWithMap, pitchWithMap, this.transform.angle), textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + if (iconBox) { + const placedIconBoxes = this.collisionIndex.placeCollisionBox(shiftVariableCollisionBox(iconBox, shift.x, shift.y, rotateWithMap, pitchWithMap, this.transform.angle), textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + if (placedIconBoxes.box.length === 0) + return; + } + if (placedGlyphBoxes.box.length > 0) { + let prevAnchor; + // If this label was placed in the previous placement, record the anchor position + // to allow us to animate the transition + if (this.prevPlacement && + this.prevPlacement.variableOffsets[symbolInstance.crossTileID] && + this.prevPlacement.placements[symbolInstance.crossTileID] && + this.prevPlacement.placements[symbolInstance.crossTileID].text) { + prevAnchor = this.prevPlacement.variableOffsets[symbolInstance.crossTileID].anchor; + } + if (symbolInstance.crossTileID === 0) + throw new Error('symbolInstance.crossTileID can\'t be 0'); + this.variableOffsets[symbolInstance.crossTileID] = { + textOffset, + width, + height, + anchor, + textBoxScale, + prevAnchor + }; + this.markUsedJustification(bucket, anchor, symbolInstance, orientation); + if (bucket.allowVerticalPlacement) { + this.markUsedOrientation(bucket, orientation, symbolInstance); + this.placedOrientations[symbolInstance.crossTileID] = orientation; + } + return { shift, placedGlyphBoxes }; + } + } + placeLayerBucketPart(bucketPart, seenCrossTileIDs, showCollisionBoxes) { + const { bucket, layout, posMatrix, textLabelPlaneMatrix, labelToScreenMatrix, textPixelRatio, holdingForFade, collisionBoxArray, partiallyEvaluatedTextSize, collisionGroup } = bucketPart.parameters; + const textOptional = layout.get('text-optional'); + const iconOptional = layout.get('icon-optional'); + const textOverlapMode = performance.getOverlapMode(layout, 'text-overlap', 'text-allow-overlap'); + const textAlwaysOverlap = textOverlapMode === 'always'; + const iconOverlapMode = performance.getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap'); + const iconAlwaysOverlap = iconOverlapMode === 'always'; + const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; + const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const hasIconTextFit = layout.get('icon-text-fit') !== 'none'; + const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y'; + // This logic is similar to the "defaultOpacityState" logic below in updateBucketOpacities + // If we know a symbol is always supposed to show, force it to be marked visible even if + // it wasn't placed into the collision index (because some or all of it was outside the range + // of the collision grid). + // There is a subtle edge case here we're accepting: + // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false + // A's icon is outside the grid, so doesn't get placed + // A's text would be inside grid, but doesn't get placed because of icon-optional: false + // We still show A because of the allow-overlap settings. + // Symbol B has allow-overlap: false, and gets placed where A's text would be + // On panning in, there is a short period when Symbol B and Symbol A will overlap + // This is the reverse of our normal policy of "fade in on pan", but should look like any other + // collision and hopefully not be too noticeable. + // See https://github.com/mapbox/mapbox-gl-js/issues/7172 + const alwaysShowText = textAlwaysOverlap && (iconAlwaysOverlap || !bucket.hasIconData() || iconOptional); + const alwaysShowIcon = iconAlwaysOverlap && (textAlwaysOverlap || !bucket.hasTextData() || textOptional); + if (!bucket.collisionArrays && collisionBoxArray) { + bucket.deserializeCollisionBoxes(collisionBoxArray); + } + const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID; + const getElevation = this.terrain ? (x, y) => this.terrain.getElevation(tileID, x, y) : null; + const placeSymbol = (symbolInstance, collisionArrays) => { + var _a, _b; + if (seenCrossTileIDs[symbolInstance.crossTileID]) + return; + if (holdingForFade) { + // Mark all symbols from this tile as "not placed", but don't add to seenCrossTileIDs, because we don't + // know yet if we have a duplicate in a parent tile that _should_ be placed. + this.placements[symbolInstance.crossTileID] = new JointPlacement(false, false, false); + return; + } + let placeText = false; + let placeIcon = false; + let offscreen = true; + let shift = null; + let placed = { box: null, offscreen: null }; + let placedVerticalText = { box: null, offscreen: null }; + let placedGlyphBoxes = null; + let placedGlyphCircles = null; + let placedIconBoxes = null; + let textFeatureIndex = 0; + let verticalTextFeatureIndex = 0; + let iconFeatureIndex = 0; + if (collisionArrays.textFeatureIndex) { + textFeatureIndex = collisionArrays.textFeatureIndex; + } + else if (symbolInstance.useRuntimeCollisionCircles) { + textFeatureIndex = symbolInstance.featureIndex; + } + if (collisionArrays.verticalTextFeatureIndex) { + verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex; + } + const textBox = collisionArrays.textBox; + if (textBox) { + const updatePreviousOrientationIfNotPlaced = (isPlaced) => { + let previousOrientation = performance.WritingMode.horizontal; + if (bucket.allowVerticalPlacement && !isPlaced && this.prevPlacement) { + const prevPlacedOrientation = this.prevPlacement.placedOrientations[symbolInstance.crossTileID]; + if (prevPlacedOrientation) { + this.placedOrientations[symbolInstance.crossTileID] = prevPlacedOrientation; + previousOrientation = prevPlacedOrientation; + this.markUsedOrientation(bucket, previousOrientation, symbolInstance); + } + } + return previousOrientation; + }; + const placeTextForPlacementModes = (placeHorizontalFn, placeVerticalFn) => { + if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && collisionArrays.verticalTextBox) { + for (const placementMode of bucket.writingModes) { + if (placementMode === performance.WritingMode.vertical) { + placed = placeVerticalFn(); + placedVerticalText = placed; + } + else { + placed = placeHorizontalFn(); + } + if (placed && placed.box && placed.box.length) + break; + } + } + else { + placed = placeHorizontalFn(); + } + }; + const textAnchorOffsetStart = symbolInstance.textAnchorOffsetStartIndex; + const textAnchorOffsetEnd = symbolInstance.textAnchorOffsetEndIndex; + // If start+end indices match, text-variable-anchor is not in play. + if (textAnchorOffsetEnd === textAnchorOffsetStart) { + const placeBox = (collisionTextBox, orientation) => { + const placedFeature = this.collisionIndex.placeCollisionBox(collisionTextBox, textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + if (placedFeature && placedFeature.box && placedFeature.box.length) { + this.markUsedOrientation(bucket, orientation, symbolInstance); + this.placedOrientations[symbolInstance.crossTileID] = orientation; + } + return placedFeature; + }; + const placeHorizontal = () => { + return placeBox(textBox, performance.WritingMode.horizontal); + }; + const placeVertical = () => { + const verticalTextBox = collisionArrays.verticalTextBox; + if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) { + return placeBox(verticalTextBox, performance.WritingMode.vertical); + } + return { box: null, offscreen: null }; + }; + placeTextForPlacementModes(placeHorizontal, placeVertical); + updatePreviousOrientationIfNotPlaced(placed && placed.box && placed.box.length); + } + else { + // If this symbol was in the last placement, prefer placement using same anchor, if it's still available + let prevAnchor = performance.TextAnchorEnum[(_b = (_a = this.prevPlacement) === null || _a === void 0 ? void 0 : _a.variableOffsets[symbolInstance.crossTileID]) === null || _b === void 0 ? void 0 : _b.anchor]; + const placeBoxForVariableAnchors = (collisionTextBox, collisionIconBox, orientation) => { + const width = collisionTextBox.x2 - collisionTextBox.x1; + const height = collisionTextBox.y2 - collisionTextBox.y1; + const textBoxScale = symbolInstance.textBoxScale; + const variableIconBox = hasIconTextFit && (iconOverlapMode === 'never') ? collisionIconBox : null; + let placedBox = { box: [], offscreen: false }; + let placementPasses = (textOverlapMode === 'never') ? 1 : 2; + let overlapMode = 'never'; + if (prevAnchor) { + placementPasses++; + } + for (let pass = 0; pass < placementPasses; pass++) { + for (let i = textAnchorOffsetStart; i < textAnchorOffsetEnd; i++) { + const textAnchorOffset = bucket.textAnchorOffsets.get(i); + if (prevAnchor && textAnchorOffset.textAnchor !== prevAnchor) { + continue; + } + const result = this.attemptAnchorPlacement(textAnchorOffset, collisionTextBox, width, height, textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix, collisionGroup, overlapMode, symbolInstance, bucket, orientation, variableIconBox, getElevation); + if (result) { + placedBox = result.placedGlyphBoxes; + if (placedBox && placedBox.box && placedBox.box.length) { + placeText = true; + shift = result.shift; + return placedBox; + } + } + } + if (prevAnchor) { + prevAnchor = null; + } + else { + overlapMode = textOverlapMode; + } + } + return placedBox; + }; + const placeHorizontal = () => { + return placeBoxForVariableAnchors(textBox, collisionArrays.iconBox, performance.WritingMode.horizontal); + }; + const placeVertical = () => { + const verticalTextBox = collisionArrays.verticalTextBox; + const wasPlaced = placed && placed.box && placed.box.length; + if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) { + return placeBoxForVariableAnchors(verticalTextBox, collisionArrays.verticalIconBox, performance.WritingMode.vertical); + } + return { box: null, offscreen: null }; + }; + placeTextForPlacementModes(placeHorizontal, placeVertical); + if (placed) { + placeText = placed.box; + offscreen = placed.offscreen; + } + const prevOrientation = updatePreviousOrientationIfNotPlaced(placed && placed.box); + // If we didn't get placed, we still need to copy our position from the last placement for + // fade animations + if (!placeText && this.prevPlacement) { + const prevOffset = this.prevPlacement.variableOffsets[symbolInstance.crossTileID]; + if (prevOffset) { + this.variableOffsets[symbolInstance.crossTileID] = prevOffset; + this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, prevOrientation); + } + } + } + } + placedGlyphBoxes = placed; + placeText = placedGlyphBoxes && placedGlyphBoxes.box && placedGlyphBoxes.box.length > 0; + offscreen = placedGlyphBoxes && placedGlyphBoxes.offscreen; + if (symbolInstance.useRuntimeCollisionCircles) { + const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.centerJustifiedTextSymbolIndex); + const fontSize = performance.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol); + const textPixelPadding = layout.get('text-padding'); + const circlePixelDiameter = symbolInstance.collisionCircleDiameter; + placedGlyphCircles = this.collisionIndex.placeCollisionCircles(textOverlapMode, placedSymbol, bucket.lineVertexArray, bucket.glyphOffsetArray, fontSize, posMatrix, textLabelPlaneMatrix, labelToScreenMatrix, showCollisionBoxes, pitchWithMap, collisionGroup.predicate, circlePixelDiameter, textPixelPadding, getElevation); + if (placedGlyphCircles.circles.length && placedGlyphCircles.collisionDetected && !showCollisionBoxes) { + performance.warnOnce('Collisions detected, but collision boxes are not shown'); + } + // If text-overlap is set to 'always', force "placedCircles" to true + // In theory there should always be at least one circle placed + // in this case, but for now quirks in text-anchor + // and text-offset may prevent that from being true. + placeText = textAlwaysOverlap || (placedGlyphCircles.circles.length > 0 && !placedGlyphCircles.collisionDetected); + offscreen = offscreen && placedGlyphCircles.offscreen; + } + if (collisionArrays.iconFeatureIndex) { + iconFeatureIndex = collisionArrays.iconFeatureIndex; + } + if (collisionArrays.iconBox) { + const placeIconFeature = iconBox => { + const shiftedIconBox = hasIconTextFit && shift ? + shiftVariableCollisionBox(iconBox, shift.x, shift.y, rotateWithMap, pitchWithMap, this.transform.angle) : + iconBox; + return this.collisionIndex.placeCollisionBox(shiftedIconBox, iconOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + }; + if (placedVerticalText && placedVerticalText.box && placedVerticalText.box.length && collisionArrays.verticalIconBox) { + placedIconBoxes = placeIconFeature(collisionArrays.verticalIconBox); + placeIcon = placedIconBoxes.box.length > 0; + } + else { + placedIconBoxes = placeIconFeature(collisionArrays.iconBox); + placeIcon = placedIconBoxes.box.length > 0; + } + offscreen = offscreen && placedIconBoxes.offscreen; + } + const iconWithoutText = textOptional || + (symbolInstance.numHorizontalGlyphVertices === 0 && symbolInstance.numVerticalGlyphVertices === 0); + const textWithoutIcon = iconOptional || symbolInstance.numIconVertices === 0; + // Combine the scales for icons and text. + if (!iconWithoutText && !textWithoutIcon) { + placeIcon = placeText = placeIcon && placeText; + } + else if (!textWithoutIcon) { + placeText = placeIcon && placeText; + } + else if (!iconWithoutText) { + placeIcon = placeIcon && placeText; + } + if (placeText && placedGlyphBoxes && placedGlyphBoxes.box) { + if (placedVerticalText && placedVerticalText.box && verticalTextFeatureIndex) { + this.collisionIndex.insertCollisionBox(placedGlyphBoxes.box, textOverlapMode, layout.get('text-ignore-placement'), bucket.bucketInstanceId, verticalTextFeatureIndex, collisionGroup.ID); + } + else { + this.collisionIndex.insertCollisionBox(placedGlyphBoxes.box, textOverlapMode, layout.get('text-ignore-placement'), bucket.bucketInstanceId, textFeatureIndex, collisionGroup.ID); + } + } + if (placeIcon && placedIconBoxes) { + this.collisionIndex.insertCollisionBox(placedIconBoxes.box, iconOverlapMode, layout.get('icon-ignore-placement'), bucket.bucketInstanceId, iconFeatureIndex, collisionGroup.ID); + } + if (placedGlyphCircles) { + if (placeText) { + this.collisionIndex.insertCollisionCircles(placedGlyphCircles.circles, textOverlapMode, layout.get('text-ignore-placement'), bucket.bucketInstanceId, textFeatureIndex, collisionGroup.ID); + } + if (showCollisionBoxes) { + const id = bucket.bucketInstanceId; + let circleArray = this.collisionCircleArrays[id]; + // Group collision circles together by bucket. Circles can't be pushed forward for rendering yet as the symbol placement + // for a bucket is not guaranteed to be complete before the commit-function has been called + if (circleArray === undefined) + circleArray = this.collisionCircleArrays[id] = new CollisionCircleArray(); + for (let i = 0; i < placedGlyphCircles.circles.length; i += 4) { + circleArray.circles.push(placedGlyphCircles.circles[i + 0]); // x + circleArray.circles.push(placedGlyphCircles.circles[i + 1]); // y + circleArray.circles.push(placedGlyphCircles.circles[i + 2]); // radius + circleArray.circles.push(placedGlyphCircles.collisionDetected ? 1 : 0); // collisionDetected-flag + } + } + } + if (symbolInstance.crossTileID === 0) + throw new Error('symbolInstance.crossTileID can\'t be 0'); + if (bucket.bucketInstanceId === 0) + throw new Error('bucket.bucketInstanceId can\'t be 0'); + this.placements[symbolInstance.crossTileID] = new JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded); + seenCrossTileIDs[symbolInstance.crossTileID] = true; + }; + if (zOrderByViewportY) { + if (bucketPart.symbolInstanceStart !== 0) + throw new Error('bucket.bucketInstanceId should be 0'); + const symbolIndexes = bucket.getSortedSymbolIndexes(this.transform.angle); + for (let i = symbolIndexes.length - 1; i >= 0; --i) { + const symbolIndex = symbolIndexes[i]; + placeSymbol(bucket.symbolInstances.get(symbolIndex), bucket.collisionArrays[symbolIndex]); + } + } + else { + for (let i = bucketPart.symbolInstanceStart; i < bucketPart.symbolInstanceEnd; i++) { + placeSymbol(bucket.symbolInstances.get(i), bucket.collisionArrays[i]); + } + } + if (showCollisionBoxes && bucket.bucketInstanceId in this.collisionCircleArrays) { + const circleArray = this.collisionCircleArrays[bucket.bucketInstanceId]; + // Store viewport and inverse projection matrices per bucket + performance.invert(circleArray.invProjMatrix, posMatrix); + circleArray.viewportMatrix = this.collisionIndex.getViewportMatrix(); + } + bucket.justReloaded = false; + } + markUsedJustification(bucket, placedAnchor, symbolInstance, orientation) { + const justifications = { + 'left': symbolInstance.leftJustifiedTextSymbolIndex, + 'center': symbolInstance.centerJustifiedTextSymbolIndex, + 'right': symbolInstance.rightJustifiedTextSymbolIndex + }; + let autoIndex; + if (orientation === performance.WritingMode.vertical) { + autoIndex = symbolInstance.verticalPlacedTextSymbolIndex; + } + else { + autoIndex = justifications[performance.getAnchorJustification(placedAnchor)]; + } + const indexes = [ + symbolInstance.leftJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.rightJustifiedTextSymbolIndex, + symbolInstance.verticalPlacedTextSymbolIndex + ]; + for (const index of indexes) { + if (index >= 0) { + if (autoIndex >= 0 && index !== autoIndex) { + // There are multiple justifications and this one isn't it: shift offscreen + bucket.text.placedSymbolArray.get(index).crossTileID = 0; + } + else { + // Either this is the chosen justification or the justification is hardwired: use this one + bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID; + } + } + } + } + markUsedOrientation(bucket, orientation, symbolInstance) { + const horizontal = (orientation === performance.WritingMode.horizontal || orientation === performance.WritingMode.horizontalOnly) ? orientation : 0; + const vertical = orientation === performance.WritingMode.vertical ? orientation : 0; + const horizontalIndexes = [ + symbolInstance.leftJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.rightJustifiedTextSymbolIndex + ]; + for (const index of horizontalIndexes) { + bucket.text.placedSymbolArray.get(index).placedOrientation = horizontal; + } + if (symbolInstance.verticalPlacedTextSymbolIndex) { + bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).placedOrientation = vertical; + } + } + commit(now) { + this.commitTime = now; + this.zoomAtLastRecencyCheck = this.transform.zoom; + const prevPlacement = this.prevPlacement; + let placementChanged = false; + this.prevZoomAdjustment = prevPlacement ? prevPlacement.zoomAdjustment(this.transform.zoom) : 0; + const increment = prevPlacement ? prevPlacement.symbolFadeChange(now) : 1; + const prevOpacities = prevPlacement ? prevPlacement.opacities : {}; + const prevOffsets = prevPlacement ? prevPlacement.variableOffsets : {}; + const prevOrientations = prevPlacement ? prevPlacement.placedOrientations : {}; + // add the opacities from the current placement, and copy their current values from the previous placement + for (const crossTileID in this.placements) { + const jointPlacement = this.placements[crossTileID]; + const prevOpacity = prevOpacities[crossTileID]; + if (prevOpacity) { + this.opacities[crossTileID] = new JointOpacityState(prevOpacity, increment, jointPlacement.text, jointPlacement.icon); + placementChanged = placementChanged || + jointPlacement.text !== prevOpacity.text.placed || + jointPlacement.icon !== prevOpacity.icon.placed; + } + else { + this.opacities[crossTileID] = new JointOpacityState(null, increment, jointPlacement.text, jointPlacement.icon, jointPlacement.skipFade); + placementChanged = placementChanged || jointPlacement.text || jointPlacement.icon; + } + } + // copy and update values from the previous placement that aren't in the current placement but haven't finished fading + for (const crossTileID in prevOpacities) { + const prevOpacity = prevOpacities[crossTileID]; + if (!this.opacities[crossTileID]) { + const jointOpacity = new JointOpacityState(prevOpacity, increment, false, false); + if (!jointOpacity.isHidden()) { + this.opacities[crossTileID] = jointOpacity; + placementChanged = placementChanged || prevOpacity.text.placed || prevOpacity.icon.placed; + } + } + } + for (const crossTileID in prevOffsets) { + if (!this.variableOffsets[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) { + this.variableOffsets[crossTileID] = prevOffsets[crossTileID]; + } + } + for (const crossTileID in prevOrientations) { + if (!this.placedOrientations[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) { + this.placedOrientations[crossTileID] = prevOrientations[crossTileID]; + } + } + // this.lastPlacementChangeTime is the time of the last commit() that + // resulted in a placement change -- in other words, the start time of + // the last symbol fade animation + if (prevPlacement && prevPlacement.lastPlacementChangeTime === undefined) { + throw new Error('Last placement time for previous placement is not defined'); + } + if (placementChanged) { + this.lastPlacementChangeTime = now; + } + else if (typeof this.lastPlacementChangeTime !== 'number') { + this.lastPlacementChangeTime = prevPlacement ? prevPlacement.lastPlacementChangeTime : now; + } + } + updateLayerOpacities(styleLayer, tiles) { + const seenCrossTileIDs = {}; + for (const tile of tiles) { + const symbolBucket = tile.getBucket(styleLayer); + if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) { + this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray); + } + } + } + updateBucketOpacities(bucket, seenCrossTileIDs, collisionBoxArray) { + if (bucket.hasTextData()) { + bucket.text.opacityVertexArray.clear(); + bucket.text.hasVisibleVertices = false; + } + if (bucket.hasIconData()) { + bucket.icon.opacityVertexArray.clear(); + bucket.icon.hasVisibleVertices = false; + } + if (bucket.hasIconCollisionBoxData()) + bucket.iconCollisionBox.collisionVertexArray.clear(); + if (bucket.hasTextCollisionBoxData()) + bucket.textCollisionBox.collisionVertexArray.clear(); + const layer = bucket.layers[0]; + const layout = layer.layout; + const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true); + const textAllowOverlap = layout.get('text-allow-overlap'); + const iconAllowOverlap = layout.get('icon-allow-overlap'); + const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset'); + const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; + const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const hasIconTextFit = layout.get('icon-text-fit') !== 'none'; + // If allow-overlap is true, we can show symbols before placement runs on them + // But we have to wait for placement if we potentially depend on a paired icon/text + // with allow-overlap: false. + // See https://github.com/mapbox/mapbox-gl-js/issues/7032 + const defaultOpacityState = new JointOpacityState(null, 0, textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || layout.get('icon-optional')), iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || layout.get('text-optional')), true); + if (!bucket.collisionArrays && collisionBoxArray && ((bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()))) { + bucket.deserializeCollisionBoxes(collisionBoxArray); + } + const addOpacities = (iconOrText, numVertices, opacity) => { + for (let i = 0; i < numVertices / 4; i++) { + iconOrText.opacityVertexArray.emplaceBack(opacity); + } + iconOrText.hasVisibleVertices = iconOrText.hasVisibleVertices || (opacity !== PACKED_HIDDEN_OPACITY); + }; + for (let s = 0; s < bucket.symbolInstances.length; s++) { + const symbolInstance = bucket.symbolInstances.get(s); + const { numHorizontalGlyphVertices, numVerticalGlyphVertices, crossTileID } = symbolInstance; + const isDuplicate = seenCrossTileIDs[crossTileID]; + let opacityState = this.opacities[crossTileID]; + if (isDuplicate) { + opacityState = duplicateOpacityState; + } + else if (!opacityState) { + opacityState = defaultOpacityState; + // store the state so that future placements use it as a starting point + this.opacities[crossTileID] = opacityState; + } + seenCrossTileIDs[crossTileID] = true; + const hasText = numHorizontalGlyphVertices > 0 || numVerticalGlyphVertices > 0; + const hasIcon = symbolInstance.numIconVertices > 0; + const placedOrientation = this.placedOrientations[symbolInstance.crossTileID]; + const horizontalHidden = placedOrientation === performance.WritingMode.vertical; + const verticalHidden = placedOrientation === performance.WritingMode.horizontal || placedOrientation === performance.WritingMode.horizontalOnly; + if (hasText) { + const packedOpacity = packOpacity(opacityState.text); + // Vertical text fades in/out on collision the same way as corresponding + // horizontal text. Switch between vertical/horizontal should be instantaneous + const horizontalOpacity = horizontalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity; + addOpacities(bucket.text, numHorizontalGlyphVertices, horizontalOpacity); + const verticalOpacity = verticalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity; + addOpacities(bucket.text, numVerticalGlyphVertices, verticalOpacity); + // If this label is completely faded, mark it so that we don't have to calculate + // its position at render time. If this layer has variable placement, shift the various + // symbol instances appropriately so that symbols from buckets that have yet to be placed + // offset appropriately. + const symbolHidden = opacityState.text.isHidden(); + [ + symbolInstance.rightJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.leftJustifiedTextSymbolIndex + ].forEach(index => { + if (index >= 0) { + bucket.text.placedSymbolArray.get(index).hidden = symbolHidden || horizontalHidden ? 1 : 0; + } + }); + if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) { + bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).hidden = symbolHidden || verticalHidden ? 1 : 0; + } + const prevOffset = this.variableOffsets[symbolInstance.crossTileID]; + if (prevOffset) { + this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, placedOrientation); + } + const prevOrientation = this.placedOrientations[symbolInstance.crossTileID]; + if (prevOrientation) { + this.markUsedJustification(bucket, 'left', symbolInstance, prevOrientation); + this.markUsedOrientation(bucket, prevOrientation, symbolInstance); + } + } + if (hasIcon) { + const packedOpacity = packOpacity(opacityState.icon); + const useHorizontal = !(hasIconTextFit && symbolInstance.verticalPlacedIconSymbolIndex && horizontalHidden); + if (symbolInstance.placedIconSymbolIndex >= 0) { + const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY; + addOpacities(bucket.icon, symbolInstance.numIconVertices, horizontalOpacity); + bucket.icon.placedSymbolArray.get(symbolInstance.placedIconSymbolIndex).hidden = + opacityState.icon.isHidden(); + } + if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) { + const verticalOpacity = !useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY; + addOpacities(bucket.icon, symbolInstance.numVerticalIconVertices, verticalOpacity); + bucket.icon.placedSymbolArray.get(symbolInstance.verticalPlacedIconSymbolIndex).hidden = + opacityState.icon.isHidden(); + } + } + if (bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()) { + const collisionArrays = bucket.collisionArrays[s]; + if (collisionArrays) { + let shift = new performance.Point(0, 0); + if (collisionArrays.textBox || collisionArrays.verticalTextBox) { + let used = true; + if (hasVariablePlacement) { + const variableOffset = this.variableOffsets[crossTileID]; + if (variableOffset) { + // This will show either the currently placed position or the last + // successfully placed position (so you can visualize what collision + // just made the symbol disappear, and the most likely place for the + // symbol to come back) + shift = calculateVariableLayoutShift(variableOffset.anchor, variableOffset.width, variableOffset.height, variableOffset.textOffset, variableOffset.textBoxScale); + if (rotateWithMap) { + shift._rotate(pitchWithMap ? this.transform.angle : -this.transform.angle); + } + } + else { + // No offset -> this symbol hasn't been placed since coming on-screen + // No single box is particularly meaningful and all of them would be too noisy + // Use the center box just to show something's there, but mark it "not used" + used = false; + } + } + if (collisionArrays.textBox) { + updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || horizontalHidden, shift.x, shift.y); + } + if (collisionArrays.verticalTextBox) { + updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || verticalHidden, shift.x, shift.y); + } + } + const verticalIconUsed = Boolean(!verticalHidden && collisionArrays.verticalIconBox); + if (collisionArrays.iconBox) { + updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, verticalIconUsed, hasIconTextFit ? shift.x : 0, hasIconTextFit ? shift.y : 0); + } + if (collisionArrays.verticalIconBox) { + updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, !verticalIconUsed, hasIconTextFit ? shift.x : 0, hasIconTextFit ? shift.y : 0); + } + } + } + } + bucket.sortFeatures(this.transform.angle); + if (this.retainedQueryData[bucket.bucketInstanceId]) { + this.retainedQueryData[bucket.bucketInstanceId].featureSortOrder = bucket.featureSortOrder; + } + if (bucket.hasTextData() && bucket.text.opacityVertexBuffer) { + bucket.text.opacityVertexBuffer.updateData(bucket.text.opacityVertexArray); + } + if (bucket.hasIconData() && bucket.icon.opacityVertexBuffer) { + bucket.icon.opacityVertexBuffer.updateData(bucket.icon.opacityVertexArray); + } + if (bucket.hasIconCollisionBoxData() && bucket.iconCollisionBox.collisionVertexBuffer) { + bucket.iconCollisionBox.collisionVertexBuffer.updateData(bucket.iconCollisionBox.collisionVertexArray); + } + if (bucket.hasTextCollisionBoxData() && bucket.textCollisionBox.collisionVertexBuffer) { + bucket.textCollisionBox.collisionVertexBuffer.updateData(bucket.textCollisionBox.collisionVertexArray); + } + if (bucket.text.opacityVertexArray.length !== bucket.text.layoutVertexArray.length / 4) + throw new Error(`bucket.text.opacityVertexArray.length (= ${bucket.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${bucket.text.layoutVertexArray.length}) / 4`); + if (bucket.icon.opacityVertexArray.length !== bucket.icon.layoutVertexArray.length / 4) + throw new Error(`bucket.icon.opacityVertexArray.length (= ${bucket.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${bucket.icon.layoutVertexArray.length}) / 4`); + // Push generated collision circles to the bucket for debug rendering + if (bucket.bucketInstanceId in this.collisionCircleArrays) { + const instance = this.collisionCircleArrays[bucket.bucketInstanceId]; + bucket.placementInvProjMatrix = instance.invProjMatrix; + bucket.placementViewportMatrix = instance.viewportMatrix; + bucket.collisionCircleArray = instance.circles; + delete this.collisionCircleArrays[bucket.bucketInstanceId]; + } + } + symbolFadeChange(now) { + return this.fadeDuration === 0 ? + 1 : + ((now - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment); + } + zoomAdjustment(zoom) { + // When zooming out quickly, labels can overlap each other. This + // adjustment is used to reduce the interval between placement calculations + // and to reduce the fade duration when zooming out quickly. Discovering the + // collisions more quickly and fading them more quickly reduces the unwanted effect. + return Math.max(0, (this.transform.zoom - zoom) / 1.5); + } + hasTransitions(now) { + return this.stale || + now - this.lastPlacementChangeTime < this.fadeDuration; + } + stillRecent(now, zoom) { + // The adjustment makes placement more frequent when zooming. + // This condition applies the adjustment only after the map has + // stopped zooming. This avoids adding extra jank while zooming. + const durationAdjustment = this.zoomAtLastRecencyCheck === zoom ? + (1 - this.zoomAdjustment(zoom)) : + 1; + this.zoomAtLastRecencyCheck = zoom; + return this.commitTime + this.fadeDuration * durationAdjustment > now; + } + setStale() { + this.stale = true; + } +} +function updateCollisionVertices(collisionVertexArray, placed, notUsed, shiftX, shiftY) { + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); +} +// All four vertices for a glyph will have the same opacity state +// So we pack the opacity into a uint8, and then repeat it four times +// to make a single uint32 that we can upload for each glyph in the +// label. +const shift25 = Math.pow(2, 25); +const shift24 = Math.pow(2, 24); +const shift17 = Math.pow(2, 17); +const shift16 = Math.pow(2, 16); +const shift9 = Math.pow(2, 9); +const shift8 = Math.pow(2, 8); +const shift1 = Math.pow(2, 1); +function packOpacity(opacityState) { + if (opacityState.opacity === 0 && !opacityState.placed) { + return 0; + } + else if (opacityState.opacity === 1 && opacityState.placed) { + return 4294967295; + } + const targetBit = opacityState.placed ? 1 : 0; + const opacityBits = Math.floor(opacityState.opacity * 127); + return opacityBits * shift25 + targetBit * shift24 + + opacityBits * shift17 + targetBit * shift16 + + opacityBits * shift9 + targetBit * shift8 + + opacityBits * shift1 + targetBit; +} +const PACKED_HIDDEN_OPACITY = 0; + +class LayerPlacement { + constructor(styleLayer) { + this._sortAcrossTiles = styleLayer.layout.get('symbol-z-order') !== 'viewport-y' && + !styleLayer.layout.get('symbol-sort-key').isConstant(); + this._currentTileIndex = 0; + this._currentPartIndex = 0; + this._seenCrossTileIDs = {}; + this._bucketParts = []; + } + continuePlacement(tiles, placement, showCollisionBoxes, styleLayer, shouldPausePlacement) { + const bucketParts = this._bucketParts; + while (this._currentTileIndex < tiles.length) { + const tile = tiles[this._currentTileIndex]; + placement.getBucketParts(bucketParts, styleLayer, tile, this._sortAcrossTiles); + this._currentTileIndex++; + if (shouldPausePlacement()) { + return true; + } + } + if (this._sortAcrossTiles) { + this._sortAcrossTiles = false; + bucketParts.sort((a, b) => a.sortKey - b.sortKey); + } + while (this._currentPartIndex < bucketParts.length) { + const bucketPart = bucketParts[this._currentPartIndex]; + placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes); + this._currentPartIndex++; + if (shouldPausePlacement()) { + return true; + } + } + return false; + } +} +class PauseablePlacement { + constructor(transform, terrain, order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, prevPlacement) { + this.placement = new Placement(transform, terrain, fadeDuration, crossSourceCollisions, prevPlacement); + this._currentPlacementIndex = order.length - 1; + this._forceFullPlacement = forceFullPlacement; + this._showCollisionBoxes = showCollisionBoxes; + this._done = false; + } + isDone() { + return this._done; + } + continuePlacement(order, layers, layerTiles) { + const startTime = performance.browser.now(); + const shouldPausePlacement = () => { + return this._forceFullPlacement ? false : (performance.browser.now() - startTime) > 2; + }; + while (this._currentPlacementIndex >= 0) { + const layerId = order[this._currentPlacementIndex]; + const layer = layers[layerId]; + const placementZoom = this.placement.collisionIndex.transform.zoom; + if (layer.type === 'symbol' && + (!layer.minzoom || layer.minzoom <= placementZoom) && + (!layer.maxzoom || layer.maxzoom > placementZoom)) { + if (!this._inProgressLayer) { + this._inProgressLayer = new LayerPlacement(layer); + } + const pausePlacement = this._inProgressLayer.continuePlacement(layerTiles[layer.source], this.placement, this._showCollisionBoxes, layer, shouldPausePlacement); + if (pausePlacement) { + // We didn't finish placing all layers within 2ms, + // but we can keep rendering with a partial placement + // We'll resume here on the next frame + return; + } + delete this._inProgressLayer; + } + this._currentPlacementIndex--; + } + this._done = true; + } + commit(now) { + this.placement.commit(now); + return this.placement; + } +} + +/* + The CrossTileSymbolIndex generally works on the assumption that + a conceptual "unique symbol" can be identified by the text of + the label combined with the anchor point. The goal is to assign + these conceptual "unique symbols" a shared crossTileID that can be + used by Placement to keep fading opacity states consistent and to + deduplicate labels. + + The CrossTileSymbolIndex indexes all the current symbol instances and + their crossTileIDs. When a symbol bucket gets added or updated, the + index assigns a crossTileID to each of it's symbol instances by either + matching it with an existing id or assigning a new one. +*/ +// Round anchor positions to roughly 4 pixel grid +const roundingFactor = 512 / performance.EXTENT / 2; +const KDBUSH_THRESHHOLD = 128; +class TileLayerIndex { + constructor(tileID, symbolInstances, bucketInstanceId) { + this.tileID = tileID; + this.bucketInstanceId = bucketInstanceId; + this._symbolsByKey = {}; + // group the symbolInstances by key + const symbolInstancesByKey = new Map(); + for (let i = 0; i < symbolInstances.length; i++) { + const symbolInstance = symbolInstances.get(i); + const key = symbolInstance.key; + const instances = symbolInstancesByKey.get(key); + if (instances) { + // This tile may have multiple symbol instances with the same key + // Store each one along with its coordinates + instances.push(symbolInstance); + } + else { + symbolInstancesByKey.set(key, [symbolInstance]); + } + } + // index the SymbolInstances in this each bucket + for (const [key, symbols] of symbolInstancesByKey) { + const positions = symbols.map(symbolInstance => ({ x: Math.floor(symbolInstance.anchorX * roundingFactor), y: Math.floor(symbolInstance.anchorY * roundingFactor) })); + const crossTileIDs = symbols.map(v => v.crossTileID); + const entry = { positions, crossTileIDs }; + // once we get too many symbols for a given key, it becomes much faster to index it before queries + if (entry.positions.length > KDBUSH_THRESHHOLD) { + const index = new performance.KDBush(entry.positions.length, 16, Uint16Array); + for (const { x, y } of entry.positions) + index.add(x, y); + index.finish(); + // clear all references to the original positions data + delete entry.positions; + entry.index = index; + } + this._symbolsByKey[key] = entry; + } + } + // Converts the coordinates of the input symbol instance into coordinates that be can compared + // against other symbols in this index. Coordinates are: + // (1) local-tile-based (so after correction we get x,y values relative to our local anchorX/Y) + // (2) converted to the z-scale of this TileLayerIndex + // (3) down-sampled by "roundingFactor" from tile coordinate precision in order to be + // more tolerant of small differences between tiles. + getScaledCoordinates(symbolInstance, childTileID) { + const { x: localX, y: localY, z: localZ } = this.tileID.canonical; + const { x, y, z } = childTileID.canonical; + const zDifference = z - localZ; + const scale = roundingFactor / Math.pow(2, zDifference); + const xWorld = (x * performance.EXTENT + symbolInstance.anchorX) * scale; + const yWorld = (y * performance.EXTENT + symbolInstance.anchorY) * scale; + const xOffset = localX * performance.EXTENT * roundingFactor; + const yOffset = localY * performance.EXTENT * roundingFactor; + const result = { + x: Math.floor(xWorld - xOffset), + y: Math.floor(yWorld - yOffset) + }; + return result; + } + findMatches(symbolInstances, newTileID, zoomCrossTileIDs) { + const tolerance = this.tileID.canonical.z < newTileID.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - newTileID.canonical.z); + for (let i = 0; i < symbolInstances.length; i++) { + const symbolInstance = symbolInstances.get(i); + if (symbolInstance.crossTileID) { + // already has a match, skip + continue; + } + const entry = this._symbolsByKey[symbolInstance.key]; + if (!entry) { + // No symbol with this key in this bucket + continue; + } + const scaledSymbolCoord = this.getScaledCoordinates(symbolInstance, newTileID); + if (entry.index) { + // Return any symbol with the same keys whose coordinates are within 1 + // grid unit. (with a 4px grid, this covers a 12px by 12px area) + const indexes = entry.index.range(scaledSymbolCoord.x - tolerance, scaledSymbolCoord.y - tolerance, scaledSymbolCoord.x + tolerance, scaledSymbolCoord.y + tolerance).sort(); + for (const i of indexes) { + const crossTileID = entry.crossTileIDs[i]; + if (!zoomCrossTileIDs[crossTileID]) { + // Once we've marked ourselves duplicate against this parent symbol, + // don't let any other symbols at the same zoom level duplicate against + // the same parent (see issue #5993) + zoomCrossTileIDs[crossTileID] = true; + symbolInstance.crossTileID = crossTileID; + break; + } + } + } + else if (entry.positions) { + for (let i = 0; i < entry.positions.length; i++) { + const thisTileSymbol = entry.positions[i]; + const crossTileID = entry.crossTileIDs[i]; + // Return any symbol with the same keys whose coordinates are within 1 + // grid unit. (with a 4px grid, this covers a 12px by 12px area) + if (Math.abs(thisTileSymbol.x - scaledSymbolCoord.x) <= tolerance && + Math.abs(thisTileSymbol.y - scaledSymbolCoord.y) <= tolerance && + !zoomCrossTileIDs[crossTileID]) { + // Once we've marked ourselves duplicate against this parent symbol, + // don't let any other symbols at the same zoom level duplicate against + // the same parent (see issue #5993) + zoomCrossTileIDs[crossTileID] = true; + symbolInstance.crossTileID = crossTileID; + break; + } + } + } + } + } + getCrossTileIDsLists() { + return Object.values(this._symbolsByKey).map(({ crossTileIDs }) => crossTileIDs); + } +} +class CrossTileIDs { + constructor() { + this.maxCrossTileID = 0; + } + generate() { + return ++this.maxCrossTileID; + } +} +class CrossTileSymbolLayerIndex { + constructor() { + this.indexes = {}; + this.usedCrossTileIDs = {}; + this.lng = 0; + } + /* + * Sometimes when a user pans across the antimeridian the longitude value gets wrapped. + * To prevent labels from flashing out and in we adjust the tileID values in the indexes + * so that they match the new wrapped version of the map. + */ + handleWrapJump(lng) { + const wrapDelta = Math.round((lng - this.lng) / 360); + if (wrapDelta !== 0) { + for (const zoom in this.indexes) { + const zoomIndexes = this.indexes[zoom]; + const newZoomIndex = {}; + for (const key in zoomIndexes) { + // change the tileID's wrap and add it to a new index + const index = zoomIndexes[key]; + index.tileID = index.tileID.unwrapTo(index.tileID.wrap + wrapDelta); + newZoomIndex[index.tileID.key] = index; + } + this.indexes[zoom] = newZoomIndex; + } + } + this.lng = lng; + } + addBucket(tileID, bucket, crossTileIDs) { + if (this.indexes[tileID.overscaledZ] && + this.indexes[tileID.overscaledZ][tileID.key]) { + if (this.indexes[tileID.overscaledZ][tileID.key].bucketInstanceId === + bucket.bucketInstanceId) { + return false; + } + else { + // We're replacing this bucket with an updated version + // Remove the old bucket's "used crossTileIDs" now so that + // the new bucket can claim them. + // The old index entries themselves stick around until + // 'removeStaleBuckets' is called. + this.removeBucketCrossTileIDs(tileID.overscaledZ, this.indexes[tileID.overscaledZ][tileID.key]); + } + } + for (let i = 0; i < bucket.symbolInstances.length; i++) { + const symbolInstance = bucket.symbolInstances.get(i); + symbolInstance.crossTileID = 0; + } + if (!this.usedCrossTileIDs[tileID.overscaledZ]) { + this.usedCrossTileIDs[tileID.overscaledZ] = {}; + } + const zoomCrossTileIDs = this.usedCrossTileIDs[tileID.overscaledZ]; + for (const zoom in this.indexes) { + const zoomIndexes = this.indexes[zoom]; + if (Number(zoom) > tileID.overscaledZ) { + for (const id in zoomIndexes) { + const childIndex = zoomIndexes[id]; + if (childIndex.tileID.isChildOf(tileID)) { + childIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs); + } + } + } + else { + const parentCoord = tileID.scaledTo(Number(zoom)); + const parentIndex = zoomIndexes[parentCoord.key]; + if (parentIndex) { + parentIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs); + } + } + } + for (let i = 0; i < bucket.symbolInstances.length; i++) { + const symbolInstance = bucket.symbolInstances.get(i); + if (!symbolInstance.crossTileID) { + // symbol did not match any known symbol, assign a new id + symbolInstance.crossTileID = crossTileIDs.generate(); + zoomCrossTileIDs[symbolInstance.crossTileID] = true; + } + } + if (this.indexes[tileID.overscaledZ] === undefined) { + this.indexes[tileID.overscaledZ] = {}; + } + this.indexes[tileID.overscaledZ][tileID.key] = new TileLayerIndex(tileID, bucket.symbolInstances, bucket.bucketInstanceId); + return true; + } + removeBucketCrossTileIDs(zoom, removedBucket) { + for (const crossTileIDs of removedBucket.getCrossTileIDsLists()) { + for (const crossTileID of crossTileIDs) { + delete this.usedCrossTileIDs[zoom][crossTileID]; + } + } + } + removeStaleBuckets(currentIDs) { + let tilesChanged = false; + for (const z in this.indexes) { + const zoomIndexes = this.indexes[z]; + for (const tileKey in zoomIndexes) { + if (!currentIDs[zoomIndexes[tileKey].bucketInstanceId]) { + this.removeBucketCrossTileIDs(z, zoomIndexes[tileKey]); + delete zoomIndexes[tileKey]; + tilesChanged = true; + } + } + } + return tilesChanged; + } +} +class CrossTileSymbolIndex { + constructor() { + this.layerIndexes = {}; + this.crossTileIDs = new CrossTileIDs(); + this.maxBucketInstanceId = 0; + this.bucketsInCurrentPlacement = {}; + } + addLayer(styleLayer, tiles, lng) { + let layerIndex = this.layerIndexes[styleLayer.id]; + if (layerIndex === undefined) { + layerIndex = this.layerIndexes[styleLayer.id] = new CrossTileSymbolLayerIndex(); + } + let symbolBucketsChanged = false; + const currentBucketIDs = {}; + layerIndex.handleWrapJump(lng); + for (const tile of tiles) { + const symbolBucket = tile.getBucket(styleLayer); + if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0]) + continue; + if (!symbolBucket.bucketInstanceId) { + symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId; + } + if (layerIndex.addBucket(tile.tileID, symbolBucket, this.crossTileIDs)) { + symbolBucketsChanged = true; + } + currentBucketIDs[symbolBucket.bucketInstanceId] = true; + } + if (layerIndex.removeStaleBuckets(currentBucketIDs)) { + symbolBucketsChanged = true; + } + return symbolBucketsChanged; + } + pruneUnusedLayers(usedLayers) { + const usedLayerMap = {}; + usedLayers.forEach((usedLayer) => { + usedLayerMap[usedLayer] = true; + }); + for (const layerId in this.layerIndexes) { + if (!usedLayerMap[layerId]) { + delete this.layerIndexes[layerId]; + } + } + } +} + +// We're skipping validation errors with the `source.canvas` identifier in order +// to continue to allow canvas sources to be added at runtime/updated in +// smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424): +const emitValidationErrors = (evented, errors) => performance.emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas')); +const supportedDiffOperations = performance.pick(performance.operations, [ + 'addLayer', + 'removeLayer', + 'setPaintProperty', + 'setLayoutProperty', + 'setFilter', + 'addSource', + 'removeSource', + 'setLayerZoomRange', + 'setLight', + 'setTransition', + 'setGeoJSONSourceData', + 'setGlyphs', + 'setSprite', +]); +const ignoredDiffOperations = performance.pick(performance.operations, [ + 'setCenter', + 'setZoom', + 'setBearing', + 'setPitch' +]); +const empty = performance.emptyStyle(); +/** + * The Style base class + */ +class Style extends performance.Evented { + constructor(map, options = {}) { + super(); + this.map = map; + this.dispatcher = new Dispatcher(getGlobalWorkerPool(), this, map._getMapId()); + this.imageManager = new ImageManager(); + this.imageManager.setEventedParent(this); + this.glyphManager = new GlyphManager(map._requestManager, options.localIdeographFontFamily); + this.lineAtlas = new LineAtlas(256, 512); + this.crossTileSymbolIndex = new CrossTileSymbolIndex(); + this._spritesImagesIds = {}; + this._layers = {}; + this._order = []; + this.sourceCaches = {}; + this.zoomHistory = new performance.ZoomHistory(); + this._loaded = false; + this._availableImages = []; + this._resetUpdates(); + this.dispatcher.broadcast('setReferrer', performance.getReferrer()); + const self = this; + this._rtlTextPluginCallback = Style.registerForPluginStateChange((event) => { + const state = { + pluginStatus: event.pluginStatus, + pluginURL: event.pluginURL + }; + self.dispatcher.broadcast('syncRTLPluginState', state, (err, results) => { + performance.triggerPluginCompletionEvent(err); + if (results) { + const allComplete = results.every((elem) => elem); + if (allComplete) { + for (const id in self.sourceCaches) { + const sourceType = self.sourceCaches[id].getSource().type; + if (sourceType === 'vector' || sourceType === 'geojson') { + // Non-vector sources don't have any symbols buckets to reload when the RTL text plugin loads + // They also load more quickly, so they're more likely to have already displaying tiles + // that would be unnecessarily booted by the plugin load event + self.sourceCaches[id].reload(); // Should be a no-op if the plugin loads before any tiles load + } + } + } + } + }); + }); + this.on('data', (event) => { + if (event.dataType !== 'source' || event.sourceDataType !== 'metadata') { + return; + } + const sourceCache = this.sourceCaches[event.sourceId]; + if (!sourceCache) { + return; + } + const source = sourceCache.getSource(); + if (!source || !source.vectorLayerIds) { + return; + } + for (const layerId in this._layers) { + const layer = this._layers[layerId]; + if (layer.source === source.id) { + this._validateLayer(layer); + } + } + }); + } + loadURL(url, options = {}, previousStyle) { + this.fire(new performance.Event('dataloading', { dataType: 'style' })); + options.validate = typeof options.validate === 'boolean' ? + options.validate : true; + const request = this.map._requestManager.transformRequest(url, ResourceType.Style); + this._request = performance.getJSON(request, (error, json) => { + this._request = null; + if (error) { + this.fire(new performance.ErrorEvent(error)); + } + else if (json) { + this._load(json, options, previousStyle); + } + }); + } + loadJSON(json, options = {}, previousStyle) { + this.fire(new performance.Event('dataloading', { dataType: 'style' })); + this._request = performance.browser.frame(() => { + this._request = null; + options.validate = options.validate !== false; + this._load(json, options, previousStyle); + }); + } + loadEmpty() { + this.fire(new performance.Event('dataloading', { dataType: 'style' })); + this._load(empty, { validate: false }); + } + _load(json, options, previousStyle) { + var _a; + const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json; + if (options.validate && emitValidationErrors(this, performance.validateStyle(nextState))) { + return; + } + this._loaded = true; + this.stylesheet = nextState; + for (const id in nextState.sources) { + this.addSource(id, nextState.sources[id], { validate: false }); + } + if (nextState.sprite) { + this._loadSprite(nextState.sprite); + } + else { + this.imageManager.setLoaded(true); + } + this.glyphManager.setURL(nextState.glyphs); + this._createLayers(); + this.light = new Light(this.stylesheet.light); + this.map.setTerrain((_a = this.stylesheet.terrain) !== null && _a !== void 0 ? _a : null); + this.fire(new performance.Event('data', { dataType: 'style' })); + this.fire(new performance.Event('style.load')); + } + _createLayers() { + const dereferencedLayers = performance.derefLayers(this.stylesheet.layers); + // Broadcast layers to workers first, so that expensive style processing (createStyleLayer) + // can happen in parallel on both main and worker threads. + this.dispatcher.broadcast('setLayers', dereferencedLayers); + this._order = dereferencedLayers.map((layer) => layer.id); + this._layers = {}; + // reset serialization field, to be populated only when needed + this._serializedLayers = null; + for (const layer of dereferencedLayers) { + const styledLayer = performance.createStyleLayer(layer); + styledLayer.setEventedParent(this, { layer: { id: layer.id } }); + this._layers[layer.id] = styledLayer; + } + } + _loadSprite(sprite, isUpdate = false, completion = undefined) { + this.imageManager.setLoaded(false); + this._spriteRequest = loadSprite(sprite, this.map._requestManager, this.map.getPixelRatio(), (err, images) => { + this._spriteRequest = null; + if (err) { + this.fire(new performance.ErrorEvent(err)); + } + else if (images) { + for (const spriteId in images) { + this._spritesImagesIds[spriteId] = []; + // remove old sprite's loaded images (for the same sprite id) that are not in new sprite + const imagesToRemove = this._spritesImagesIds[spriteId] ? this._spritesImagesIds[spriteId].filter(id => !(id in images)) : []; + for (const id of imagesToRemove) { + this.imageManager.removeImage(id); + this._changedImages[id] = true; + } + for (const id in images[spriteId]) { + // don't prefix images of the "default" sprite + const imageId = spriteId === 'default' ? id : `${spriteId}:${id}`; + // save all the sprite's images' ids to be able to delete them in `removeSprite` + this._spritesImagesIds[spriteId].push(imageId); + if (imageId in this.imageManager.images) { + this.imageManager.updateImage(imageId, images[spriteId][id], false); + } + else { + this.imageManager.addImage(imageId, images[spriteId][id]); + } + if (isUpdate) { + this._changedImages[imageId] = true; + } + } + } + } + this.imageManager.setLoaded(true); + this._availableImages = this.imageManager.listImages(); + if (isUpdate) { + this._changed = true; + } + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new performance.Event('data', { dataType: 'style' })); + if (completion) { + completion(err); + } + }); + } + _unloadSprite() { + for (const id of Object.values(this._spritesImagesIds).flat()) { + this.imageManager.removeImage(id); + this._changedImages[id] = true; + } + this._spritesImagesIds = {}; + this._availableImages = this.imageManager.listImages(); + this._changed = true; + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new performance.Event('data', { dataType: 'style' })); + } + _validateLayer(layer) { + const sourceCache = this.sourceCaches[layer.source]; + if (!sourceCache) { + return; + } + const sourceLayer = layer.sourceLayer; + if (!sourceLayer) { + return; + } + const source = sourceCache.getSource(); + if (source.type === 'geojson' || (source.vectorLayerIds && source.vectorLayerIds.indexOf(sourceLayer) === -1)) { + this.fire(new performance.ErrorEvent(new Error(`Source layer "${sourceLayer}" ` + + `does not exist on source "${source.id}" ` + + `as specified by style layer "${layer.id}".`))); + } + } + loaded() { + if (!this._loaded) + return false; + if (Object.keys(this._updatedSources).length) + return false; + for (const id in this.sourceCaches) + if (!this.sourceCaches[id].loaded()) + return false; + if (!this.imageManager.isLoaded()) + return false; + return true; + } + /** + * take an array of string IDs, and based on this._layers, generate an array of LayerSpecification + * @param ids - an array of string IDs, for which serialized layers will be generated. If omitted, all serialized layers will be returned + * @returns generated result + */ + _serializeByIds(ids) { + const serializedLayersDictionary = this._serializedAllLayers(); + if (!ids || ids.length === 0) { + return Object.values(serializedLayersDictionary); + } + const serializedLayers = []; + for (const id of ids) { + // this check will skip all custom layers + if (serializedLayersDictionary[id]) { + serializedLayers.push(serializedLayersDictionary[id]); + } + } + return serializedLayers; + } + /** + * Lazy initialization of this._serializedLayers dictionary and return it + * @returns this._serializedLayers dictionary + */ + _serializedAllLayers() { + let serializedLayers = this._serializedLayers; + if (serializedLayers) { + return serializedLayers; + } + serializedLayers = this._serializedLayers = {}; + const allLayerIds = Object.keys(this._layers); + for (const layerId of allLayerIds) { + const layer = this._layers[layerId]; + if (layer.type !== 'custom') { + serializedLayers[layerId] = layer.serialize(); + } + } + return serializedLayers; + } + hasTransitions() { + if (this.light && this.light.hasTransition()) { + return true; + } + for (const id in this.sourceCaches) { + if (this.sourceCaches[id].hasTransition()) { + return true; + } + } + for (const id in this._layers) { + if (this._layers[id].hasTransition()) { + return true; + } + } + return false; + } + _checkLoaded() { + if (!this._loaded) { + throw new Error('Style is not done loading.'); + } + } + /** + * @internal + * Apply queued style updates in a batch and recalculate zoom-dependent paint properties. + */ + update(parameters) { + if (!this._loaded) { + return; + } + const changed = this._changed; + if (this._changed) { + const updatedIds = Object.keys(this._updatedLayers); + const removedIds = Object.keys(this._removedLayers); + if (updatedIds.length || removedIds.length) { + this._updateWorkerLayers(updatedIds, removedIds); + } + for (const id in this._updatedSources) { + const action = this._updatedSources[id]; + if (action === 'reload') { + this._reloadSource(id); + } + else if (action === 'clear') { + this._clearSource(id); + } + else { + throw new Error(`Invalid action ${action}`); + } + } + this._updateTilesForChangedImages(); + this._updateTilesForChangedGlyphs(); + for (const id in this._updatedPaintProps) { + this._layers[id].updateTransitions(parameters); + } + this.light.updateTransitions(parameters); + this._resetUpdates(); + } + const sourcesUsedBefore = {}; + for (const sourceId in this.sourceCaches) { + const sourceCache = this.sourceCaches[sourceId]; + sourcesUsedBefore[sourceId] = sourceCache.used; + sourceCache.used = false; + } + for (const layerId of this._order) { + const layer = this._layers[layerId]; + layer.recalculate(parameters, this._availableImages); + if (!layer.isHidden(parameters.zoom) && layer.source) { + this.sourceCaches[layer.source].used = true; + } + } + for (const sourceId in sourcesUsedBefore) { + const sourceCache = this.sourceCaches[sourceId]; + if (sourcesUsedBefore[sourceId] !== sourceCache.used) { + sourceCache.fire(new performance.Event('data', { sourceDataType: 'visibility', dataType: 'source', sourceId })); + } + } + this.light.recalculate(parameters); + this.z = parameters.zoom; + if (changed) { + this.fire(new performance.Event('data', { dataType: 'style' })); + } + } + /* + * Apply any queued image changes. + */ + _updateTilesForChangedImages() { + const changedImages = Object.keys(this._changedImages); + if (changedImages.length) { + for (const name in this.sourceCaches) { + this.sourceCaches[name].reloadTilesForDependencies(['icons', 'patterns'], changedImages); + } + this._changedImages = {}; + } + } + _updateTilesForChangedGlyphs() { + if (this._glyphsDidChange) { + for (const name in this.sourceCaches) { + this.sourceCaches[name].reloadTilesForDependencies(['glyphs'], ['']); + } + this._glyphsDidChange = false; + } + } + _updateWorkerLayers(updatedIds, removedIds) { + this.dispatcher.broadcast('updateLayers', { + layers: this._serializeByIds(updatedIds), + removedIds + }); + } + _resetUpdates() { + this._changed = false; + this._updatedLayers = {}; + this._removedLayers = {}; + this._updatedSources = {}; + this._updatedPaintProps = {}; + this._changedImages = {}; + this._glyphsDidChange = false; + } + /** + * Update this style's state to match the given style JSON, performing only + * the necessary mutations. + * + * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec + * diff algorithm produces an operation that is not supported. + * + * @returns true if any changes were made; false otherwise + */ + setState(nextState, options = {}) { + this._checkLoaded(); + const serializedStyle = this.serialize(); + nextState = options.transformStyle ? options.transformStyle(serializedStyle, nextState) : nextState; + if (emitValidationErrors(this, performance.validateStyle(nextState))) + return false; + nextState = performance.clone$1(nextState); + nextState.layers = performance.derefLayers(nextState.layers); + const changes = performance.diffStyles(serializedStyle, nextState) + .filter(op => !(op.command in ignoredDiffOperations)); + if (changes.length === 0) { + return false; + } + const unimplementedOps = changes.filter(op => !(op.command in supportedDiffOperations)); + if (unimplementedOps.length > 0) { + throw new Error(`Unimplemented: ${unimplementedOps.map(op => op.command).join(', ')}.`); + } + for (const op of changes) { + if (op.command === 'setTransition') { + // `transition` is always read directly off of + // `this.stylesheet`, which we update below + continue; + } + this[op.command].apply(this, op.args); + } + this.stylesheet = nextState; + // reset serialization field, to be populated only when needed + this._serializedLayers = null; + return true; + } + addImage(id, image) { + if (this.getImage(id)) { + return this.fire(new performance.ErrorEvent(new Error(`An image named "${id}" already exists.`))); + } + this.imageManager.addImage(id, image); + this._afterImageUpdated(id); + } + updateImage(id, image) { + this.imageManager.updateImage(id, image); + } + getImage(id) { + return this.imageManager.getImage(id); + } + removeImage(id) { + if (!this.getImage(id)) { + return this.fire(new performance.ErrorEvent(new Error(`An image named "${id}" does not exist.`))); + } + this.imageManager.removeImage(id); + this._afterImageUpdated(id); + } + _afterImageUpdated(id) { + this._availableImages = this.imageManager.listImages(); + this._changedImages[id] = true; + this._changed = true; + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new performance.Event('data', { dataType: 'style' })); + } + listImages() { + this._checkLoaded(); + return this.imageManager.listImages(); + } + addSource(id, source, options = {}) { + this._checkLoaded(); + if (this.sourceCaches[id] !== undefined) { + throw new Error(`Source "${id}" already exists.`); + } + if (!source.type) { + throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(source).join(', ')}.`); + } + const builtIns = ['vector', 'raster', 'geojson', 'video', 'image']; + const shouldValidate = builtIns.indexOf(source.type) >= 0; + if (shouldValidate && this._validate(performance.validateStyle.source, `sources.${id}`, source, null, options)) + return; + if (this.map && this.map._collectResourceTiming) + source.collectResourceTiming = true; + const sourceCache = this.sourceCaches[id] = new SourceCache(id, source, this.dispatcher); + sourceCache.style = this; + sourceCache.setEventedParent(this, () => ({ + isSourceLoaded: sourceCache.loaded(), + source: sourceCache.serialize(), + sourceId: id + })); + sourceCache.onAdd(this.map); + this._changed = true; + } + /** + * Remove a source from this stylesheet, given its id. + * @param id - id of the source to remove + * @throws if no source is found with the given ID + * @returns `this`. + */ + removeSource(id) { + this._checkLoaded(); + if (this.sourceCaches[id] === undefined) { + throw new Error('There is no source with this ID'); + } + for (const layerId in this._layers) { + if (this._layers[layerId].source === id) { + return this.fire(new performance.ErrorEvent(new Error(`Source "${id}" cannot be removed while layer "${layerId}" is using it.`))); + } + } + const sourceCache = this.sourceCaches[id]; + delete this.sourceCaches[id]; + delete this._updatedSources[id]; + sourceCache.fire(new performance.Event('data', { sourceDataType: 'metadata', dataType: 'source', sourceId: id })); + sourceCache.setEventedParent(null); + sourceCache.onRemove(this.map); + this._changed = true; + } + /** + * Set the data of a GeoJSON source, given its id. + * @param id - id of the source + * @param data - GeoJSON source + */ + setGeoJSONSourceData(id, data) { + this._checkLoaded(); + if (this.sourceCaches[id] === undefined) + throw new Error(`There is no source with this ID=${id}`); + const geojsonSource = this.sourceCaches[id].getSource(); + if (geojsonSource.type !== 'geojson') + throw new Error(`geojsonSource.type is ${geojsonSource.type}, which is !== 'geojson`); + geojsonSource.setData(data); + this._changed = true; + } + /** + * Get a source by ID. + * @param id - ID of the desired source + * @returns source + */ + getSource(id) { + return this.sourceCaches[id] && this.sourceCaches[id].getSource(); + } + /** + * Add a layer to the map style. The layer will be inserted before the layer with + * ID `before`, or appended if `before` is omitted. + * @param layerObject - The style layer to add. + * @param before - ID of an existing layer to insert before + * @param options - Style setter options. + * @returns `this`. + */ + addLayer(layerObject, before, options = {}) { + this._checkLoaded(); + const id = layerObject.id; + if (this.getLayer(id)) { + this.fire(new performance.ErrorEvent(new Error(`Layer "${id}" already exists on this map.`))); + return; + } + let layer; + if (layerObject.type === 'custom') { + if (emitValidationErrors(this, performance.validateCustomStyleLayer(layerObject))) + return; + layer = performance.createStyleLayer(layerObject); + } + else { + if ('source' in layerObject && typeof layerObject.source === 'object') { + this.addSource(id, layerObject.source); + layerObject = performance.clone$1(layerObject); + layerObject = performance.extend(layerObject, { source: id }); + } + // this layer is not in the style.layers array, so we pass an impossible array index + if (this._validate(performance.validateStyle.layer, `layers.${id}`, layerObject, { arrayIndex: -1 }, options)) + return; + layer = performance.createStyleLayer(layerObject); + this._validateLayer(layer); + layer.setEventedParent(this, { layer: { id } }); + } + const index = before ? this._order.indexOf(before) : this._order.length; + if (before && index === -1) { + this.fire(new performance.ErrorEvent(new Error(`Cannot add layer "${id}" before non-existing layer "${before}".`))); + return; + } + this._order.splice(index, 0, id); + this._layerOrderChanged = true; + this._layers[id] = layer; + if (this._removedLayers[id] && layer.source && layer.type !== 'custom') { + // If, in the current batch, we have already removed this layer + // and we are now re-adding it with a different `type`, then we + // need to clear (rather than just reload) the underlying source's + // tiles. Otherwise, tiles marked 'reloading' will have buckets / + // buffers that are set up for the _previous_ version of this + // layer, causing, e.g.: + // https://github.com/mapbox/mapbox-gl-js/issues/3633 + const removed = this._removedLayers[id]; + delete this._removedLayers[id]; + if (removed.type !== layer.type) { + this._updatedSources[layer.source] = 'clear'; + } + else { + this._updatedSources[layer.source] = 'reload'; + this.sourceCaches[layer.source].pause(); + } + } + this._updateLayer(layer); + if (layer.onAdd) { + layer.onAdd(this.map); + } + } + /** + * Moves a layer to a different z-position. The layer will be inserted before the layer with + * ID `before`, or appended if `before` is omitted. + * @param id - ID of the layer to move + * @param before - ID of an existing layer to insert before + */ + moveLayer(id, before) { + this._checkLoaded(); + this._changed = true; + const layer = this._layers[id]; + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be moved.`))); + return; + } + if (id === before) { + return; + } + const index = this._order.indexOf(id); + this._order.splice(index, 1); + const newIndex = before ? this._order.indexOf(before) : this._order.length; + if (before && newIndex === -1) { + this.fire(new performance.ErrorEvent(new Error(`Cannot move layer "${id}" before non-existing layer "${before}".`))); + return; + } + this._order.splice(newIndex, 0, id); + this._layerOrderChanged = true; + } + /** + * Remove the layer with the given id from the style. + * + * If no such layer exists, an `error` event is fired. + * + * @param id - id of the layer to remove + * @event `error` - Fired if the layer does not exist + */ + removeLayer(id) { + this._checkLoaded(); + const layer = this._layers[id]; + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`Cannot remove non-existing layer "${id}".`))); + return; + } + layer.setEventedParent(null); + const index = this._order.indexOf(id); + this._order.splice(index, 1); + this._layerOrderChanged = true; + this._changed = true; + this._removedLayers[id] = layer; + delete this._layers[id]; + if (this._serializedLayers) { + delete this._serializedLayers[id]; + } + delete this._updatedLayers[id]; + delete this._updatedPaintProps[id]; + if (layer.onRemove) { + layer.onRemove(this.map); + } + } + /** + * Return the style layer object with the given `id`. + * + * @param id - id of the desired layer + * @returns a layer, if one with the given `id` exists + */ + getLayer(id) { + return this._layers[id]; + } + /** + * Return the ids of all layers currently in the style, including custom layers, in order. + * + * @returns ids of layers, in order + */ + getLayersOrder() { + return [...this._order]; + } + /** + * Checks if a specific layer is present within the style. + * + * @param id - the id of the desired layer + * @returns a boolean specifying if the given layer is present + */ + hasLayer(id) { + return id in this._layers; + } + setLayerZoomRange(layerId, minzoom, maxzoom) { + this._checkLoaded(); + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${layerId}".`))); + return; + } + if (layer.minzoom === minzoom && layer.maxzoom === maxzoom) + return; + if (minzoom != null) { + layer.minzoom = minzoom; + } + if (maxzoom != null) { + layer.maxzoom = maxzoom; + } + this._updateLayer(layer); + } + setFilter(layerId, filter, options = {}) { + this._checkLoaded(); + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`Cannot filter non-existing layer "${layerId}".`))); + return; + } + if (performance.deepEqual(layer.filter, filter)) { + return; + } + if (filter === null || filter === undefined) { + layer.filter = undefined; + this._updateLayer(layer); + return; + } + if (this._validate(performance.validateStyle.filter, `layers.${layer.id}.filter`, filter, null, options)) { + return; + } + layer.filter = performance.clone$1(filter); + this._updateLayer(layer); + } + /** + * Get a layer's filter object + * @param layer - the layer to inspect + * @returns the layer's filter, if any + */ + getFilter(layer) { + return performance.clone$1(this.getLayer(layer).filter); + } + setLayoutProperty(layerId, name, value, options = {}) { + this._checkLoaded(); + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`Cannot style non-existing layer "${layerId}".`))); + return; + } + if (performance.deepEqual(layer.getLayoutProperty(name), value)) + return; + layer.setLayoutProperty(name, value, options); + this._updateLayer(layer); + } + /** + * Get a layout property's value from a given layer + * @param layerId - the layer to inspect + * @param name - the name of the layout property + * @returns the property value + */ + getLayoutProperty(layerId, name) { + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`Cannot get style of non-existing layer "${layerId}".`))); + return; + } + return layer.getLayoutProperty(name); + } + setPaintProperty(layerId, name, value, options = {}) { + this._checkLoaded(); + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new performance.ErrorEvent(new Error(`Cannot style non-existing layer "${layerId}".`))); + return; + } + if (performance.deepEqual(layer.getPaintProperty(name), value)) + return; + const requiresRelayout = layer.setPaintProperty(name, value, options); + if (requiresRelayout) { + this._updateLayer(layer); + } + this._changed = true; + this._updatedPaintProps[layerId] = true; + } + getPaintProperty(layer, name) { + return this.getLayer(layer).getPaintProperty(name); + } + setFeatureState(target, state) { + this._checkLoaded(); + const sourceId = target.source; + const sourceLayer = target.sourceLayer; + const sourceCache = this.sourceCaches[sourceId]; + if (sourceCache === undefined) { + this.fire(new performance.ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`))); + return; + } + const sourceType = sourceCache.getSource().type; + if (sourceType === 'geojson' && sourceLayer) { + this.fire(new performance.ErrorEvent(new Error('GeoJSON sources cannot have a sourceLayer parameter.'))); + return; + } + if (sourceType === 'vector' && !sourceLayer) { + this.fire(new performance.ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.'))); + return; + } + if (target.id === undefined) { + this.fire(new performance.ErrorEvent(new Error('The feature id parameter must be provided.'))); + } + sourceCache.setFeatureState(sourceLayer, target.id, state); + } + removeFeatureState(target, key) { + this._checkLoaded(); + const sourceId = target.source; + const sourceCache = this.sourceCaches[sourceId]; + if (sourceCache === undefined) { + this.fire(new performance.ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`))); + return; + } + const sourceType = sourceCache.getSource().type; + const sourceLayer = sourceType === 'vector' ? target.sourceLayer : undefined; + if (sourceType === 'vector' && !sourceLayer) { + this.fire(new performance.ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.'))); + return; + } + if (key && (typeof target.id !== 'string' && typeof target.id !== 'number')) { + this.fire(new performance.ErrorEvent(new Error('A feature id is required to remove its specific state property.'))); + return; + } + sourceCache.removeFeatureState(sourceLayer, target.id, key); + } + getFeatureState(target) { + this._checkLoaded(); + const sourceId = target.source; + const sourceLayer = target.sourceLayer; + const sourceCache = this.sourceCaches[sourceId]; + if (sourceCache === undefined) { + this.fire(new performance.ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`))); + return; + } + const sourceType = sourceCache.getSource().type; + if (sourceType === 'vector' && !sourceLayer) { + this.fire(new performance.ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.'))); + return; + } + if (target.id === undefined) { + this.fire(new performance.ErrorEvent(new Error('The feature id parameter must be provided.'))); + } + return sourceCache.getFeatureState(sourceLayer, target.id); + } + getTransition() { + return performance.extend({ duration: 300, delay: 0 }, this.stylesheet && this.stylesheet.transition); + } + serialize() { + // We return undefined before we're loaded, following the pattern of Map.getStyle() before + // the Style object is initialized. + // Internally, Style._validate() calls Style.serialize() but callers are responsible for + // calling Style._checkLoaded() first if their validation requires the style to be loaded. + if (!this._loaded) + return; + const sources = performance.mapObject(this.sourceCaches, (source) => source.serialize()); + const layers = this._serializeByIds(this._order); + const terrain = this.map.getTerrain() || undefined; + const myStyleSheet = this.stylesheet; + return performance.filterObject({ + version: myStyleSheet.version, + name: myStyleSheet.name, + metadata: myStyleSheet.metadata, + light: myStyleSheet.light, + center: myStyleSheet.center, + zoom: myStyleSheet.zoom, + bearing: myStyleSheet.bearing, + pitch: myStyleSheet.pitch, + sprite: myStyleSheet.sprite, + glyphs: myStyleSheet.glyphs, + transition: myStyleSheet.transition, + sources, + layers, + terrain + }, (value) => { return value !== undefined; }); + } + _updateLayer(layer) { + this._updatedLayers[layer.id] = true; + if (layer.source && !this._updatedSources[layer.source] && + //Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865) + this.sourceCaches[layer.source].getSource().type !== 'raster') { + this._updatedSources[layer.source] = 'reload'; + this.sourceCaches[layer.source].pause(); + } + // upon updating, serilized layer dictionary should be reset. + // When needed, it will be populated with the correct copy again. + this._serializedLayers = null; + this._changed = true; + } + _flattenAndSortRenderedFeatures(sourceResults) { + // Feature order is complicated. + // The order between features in two 2D layers is always determined by layer order. + // The order between features in two 3D layers is always determined by depth. + // The order between a feature in a 2D layer and a 3D layer is tricky: + // Most often layer order determines the feature order in this case. If + // a line layer is above a extrusion layer the line feature will be rendered + // above the extrusion. If the line layer is below the extrusion layer, + // it will be rendered below it. + // + // There is a weird case though. + // You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b + // Each layer has a feature that overlaps the other features. + // The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above. + // The feature in line_layer is rendered above extrusion_layer_a. + // This means that that the line_layer feature is above the extrusion_layer_b feature despite + // it being in an earlier layer. + const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion'; + const layerIndex = {}; + const features3D = []; + for (let l = this._order.length - 1; l >= 0; l--) { + const layerId = this._order[l]; + if (isLayer3D(layerId)) { + layerIndex[layerId] = l; + for (const sourceResult of sourceResults) { + const layerFeatures = sourceResult[layerId]; + if (layerFeatures) { + for (const featureWrapper of layerFeatures) { + features3D.push(featureWrapper); + } + } + } + } + } + features3D.sort((a, b) => { + return b.intersectionZ - a.intersectionZ; + }); + const features = []; + for (let l = this._order.length - 1; l >= 0; l--) { + const layerId = this._order[l]; + if (isLayer3D(layerId)) { + // add all 3D features that are in or above the current layer + for (let i = features3D.length - 1; i >= 0; i--) { + const topmost3D = features3D[i].feature; + if (layerIndex[topmost3D.layer.id] < l) + break; + features.push(topmost3D); + features3D.pop(); + } + } + else { + for (const sourceResult of sourceResults) { + const layerFeatures = sourceResult[layerId]; + if (layerFeatures) { + for (const featureWrapper of layerFeatures) { + features.push(featureWrapper.feature); + } + } + } + } + } + return features; + } + queryRenderedFeatures(queryGeometry, params, transform) { + if (params && params.filter) { + this._validate(performance.validateStyle.filter, 'queryRenderedFeatures.filter', params.filter, null, params); + } + const includedSources = {}; + if (params && params.layers) { + if (!Array.isArray(params.layers)) { + this.fire(new performance.ErrorEvent(new Error('parameters.layers must be an Array.'))); + return []; + } + for (const layerId of params.layers) { + const layer = this._layers[layerId]; + if (!layer) { + // this layer is not in the style.layers array + this.fire(new performance.ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be queried for features.`))); + return []; + } + includedSources[layer.source] = true; + } + } + const sourceResults = []; + params.availableImages = this._availableImages; + // LayerSpecification is serialized StyleLayer, and this casting is safe. + const serializedLayers = this._serializedAllLayers(); + for (const id in this.sourceCaches) { + if (params.layers && !includedSources[id]) + continue; + sourceResults.push(queryRenderedFeatures(this.sourceCaches[id], this._layers, serializedLayers, queryGeometry, params, transform)); + } + if (this.placement) { + // If a placement has run, query against its CollisionIndex + // for symbol results, and treat it as an extra source to merge + sourceResults.push(queryRenderedSymbols(this._layers, serializedLayers, this.sourceCaches, queryGeometry, params, this.placement.collisionIndex, this.placement.retainedQueryData)); + } + return this._flattenAndSortRenderedFeatures(sourceResults); + } + querySourceFeatures(sourceID, params) { + if (params && params.filter) { + this._validate(performance.validateStyle.filter, 'querySourceFeatures.filter', params.filter, null, params); + } + const sourceCache = this.sourceCaches[sourceID]; + return sourceCache ? querySourceFeatures(sourceCache, params) : []; + } + addSourceType(name, SourceType, callback) { + if (getSourceType(name)) { + return callback(new Error(`A source type called "${name}" already exists.`)); + } + setSourceType(name, SourceType); + if (!SourceType.workerSourceURL) { + return callback(null, null); + } + this.dispatcher.broadcast('loadWorkerSource', { + name, + url: SourceType.workerSourceURL + }, callback); + } + getLight() { + return this.light.getLight(); + } + setLight(lightOptions, options = {}) { + this._checkLoaded(); + const light = this.light.getLight(); + let _update = false; + for (const key in lightOptions) { + if (!performance.deepEqual(lightOptions[key], light[key])) { + _update = true; + break; + } + } + if (!_update) + return; + const parameters = { + now: performance.browser.now(), + transition: performance.extend({ + duration: 300, + delay: 0 + }, this.stylesheet.transition) + }; + this.light.setLight(lightOptions, options); + this.light.updateTransitions(parameters); + } + _validate(validate, key, value, props, options = {}) { + if (options && options.validate === false) { + return false; + } + return emitValidationErrors(this, validate.call(performance.validateStyle, performance.extend({ + key, + style: this.serialize(), + value, + styleSpec: performance.v8Spec + }, props))); + } + _remove(mapRemoved = true) { + if (this._request) { + this._request.cancel(); + this._request = null; + } + if (this._spriteRequest) { + this._spriteRequest.cancel(); + this._spriteRequest = null; + } + performance.evented.off('pluginStateChange', this._rtlTextPluginCallback); + for (const layerId in this._layers) { + const layer = this._layers[layerId]; + layer.setEventedParent(null); + } + for (const id in this.sourceCaches) { + const sourceCache = this.sourceCaches[id]; + sourceCache.setEventedParent(null); + sourceCache.onRemove(this.map); + } + this.imageManager.setEventedParent(null); + this.setEventedParent(null); + this.dispatcher.remove(mapRemoved); + } + _clearSource(id) { + this.sourceCaches[id].clearTiles(); + } + _reloadSource(id) { + this.sourceCaches[id].resume(); + this.sourceCaches[id].reload(); + } + _updateSources(transform) { + for (const id in this.sourceCaches) { + this.sourceCaches[id].update(transform, this.map.terrain); + } + } + _generateCollisionBoxes() { + for (const id in this.sourceCaches) { + this._reloadSource(id); + } + } + _updatePlacement(transform, showCollisionBoxes, fadeDuration, crossSourceCollisions, forceFullPlacement = false) { + let symbolBucketsChanged = false; + let placementCommitted = false; + const layerTiles = {}; + for (const layerID of this._order) { + const styleLayer = this._layers[layerID]; + if (styleLayer.type !== 'symbol') + continue; + if (!layerTiles[styleLayer.source]) { + const sourceCache = this.sourceCaches[styleLayer.source]; + layerTiles[styleLayer.source] = sourceCache.getRenderableIds(true) + .map((id) => sourceCache.getTileByID(id)) + .sort((a, b) => (b.tileID.overscaledZ - a.tileID.overscaledZ) || (a.tileID.isLessThan(b.tileID) ? -1 : 1)); + } + const layerBucketsChanged = this.crossTileSymbolIndex.addLayer(styleLayer, layerTiles[styleLayer.source], transform.center.lng); + symbolBucketsChanged = symbolBucketsChanged || layerBucketsChanged; + } + this.crossTileSymbolIndex.pruneUnusedLayers(this._order); + // Anything that changes our "in progress" layer and tile indices requires us + // to start over. When we start over, we do a full placement instead of incremental + // to prevent starvation. + // We need to restart placement to keep layer indices in sync. + // Also force full placement when fadeDuration === 0 to ensure that newly loaded + // tiles will fully display symbols in their first frame + forceFullPlacement = forceFullPlacement || this._layerOrderChanged || fadeDuration === 0; + if (forceFullPlacement || !this.pauseablePlacement || (this.pauseablePlacement.isDone() && !this.placement.stillRecent(performance.browser.now(), transform.zoom))) { + this.pauseablePlacement = new PauseablePlacement(transform, this.map.terrain, this._order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, this.placement); + this._layerOrderChanged = false; + } + if (this.pauseablePlacement.isDone()) { + // the last placement finished running, but the next one hasn’t + // started yet because of the `stillRecent` check immediately + // above, so mark it stale to ensure that we request another + // render frame + this.placement.setStale(); + } + else { + this.pauseablePlacement.continuePlacement(this._order, this._layers, layerTiles); + if (this.pauseablePlacement.isDone()) { + this.placement = this.pauseablePlacement.commit(performance.browser.now()); + placementCommitted = true; + } + if (symbolBucketsChanged) { + // since the placement gets split over multiple frames it is possible + // these buckets were processed before they were changed and so the + // placement is already stale while it is in progress + this.pauseablePlacement.placement.setStale(); + } + } + if (placementCommitted || symbolBucketsChanged) { + for (const layerID of this._order) { + const styleLayer = this._layers[layerID]; + if (styleLayer.type !== 'symbol') + continue; + this.placement.updateLayerOpacities(styleLayer, layerTiles[styleLayer.source]); + } + } + // needsRender is false when we have just finished a placement that didn't change the visibility of any symbols + const needsRerender = !this.pauseablePlacement.isDone() || this.placement.hasTransitions(performance.browser.now()); + return needsRerender; + } + _releaseSymbolFadeTiles() { + for (const id in this.sourceCaches) { + this.sourceCaches[id].releaseSymbolFadeTiles(); + } + } + // Callbacks from web workers + getImages(mapId, params, callback) { + this.imageManager.getImages(params.icons, callback); + // Apply queued image changes before setting the tile's dependencies so that the tile + // is not reloaded unnecessarily. Without this forced update the reload could happen in cases + // like this one: + // - icons contains "my-image" + // - imageManager.getImages(...) triggers `onstyleimagemissing` + // - the user adds "my-image" within the callback + // - addImage adds "my-image" to this._changedImages + // - the next frame triggers a reload of this tile even though it already has the latest version + this._updateTilesForChangedImages(); + const sourceCache = this.sourceCaches[params.source]; + if (sourceCache) { + sourceCache.setDependencies(params.tileID.key, params.type, params.icons); + } + } + getGlyphs(mapId, params, callback) { + this.glyphManager.getGlyphs(params.stacks, callback); + const sourceCache = this.sourceCaches[params.source]; + if (sourceCache) { + // we are not setting stacks as dependencies since for now + // we just need to know which tiles have glyph dependencies + sourceCache.setDependencies(params.tileID.key, params.type, ['']); + } + } + getResource(mapId, params, callback) { + return performance.makeRequest(params, callback); + } + getGlyphsUrl() { + return this.stylesheet.glyphs || null; + } + setGlyphs(glyphsUrl, options = {}) { + this._checkLoaded(); + if (glyphsUrl && this._validate(performance.validateStyle.glyphs, 'glyphs', glyphsUrl, null, options)) { + return; + } + this._glyphsDidChange = true; + this.stylesheet.glyphs = glyphsUrl; + this.glyphManager.entries = {}; + this.glyphManager.setURL(glyphsUrl); + } + /** + * Add a sprite. + * + * @param id - The id of the desired sprite + * @param url - The url to load the desired sprite from + * @param options - The style setter options + * @param completion - The completion handler + */ + addSprite(id, url, options = {}, completion) { + this._checkLoaded(); + const spriteToAdd = [{ id, url }]; + const updatedSprite = [ + ...coerceSpriteToArray(this.stylesheet.sprite), + ...spriteToAdd + ]; + if (this._validate(performance.validateStyle.sprite, 'sprite', updatedSprite, null, options)) + return; + this.stylesheet.sprite = updatedSprite; + this._loadSprite(spriteToAdd, true, completion); + } + /** + * Remove a sprite by its id. When the last sprite is removed, the whole `this.stylesheet.sprite` object becomes + * `undefined`. This falsy `undefined` value later prevents attempts to load the sprite when it's absent. + * + * @param id - the id of the sprite to remove + */ + removeSprite(id) { + this._checkLoaded(); + const internalSpriteRepresentation = coerceSpriteToArray(this.stylesheet.sprite); + if (!internalSpriteRepresentation.find(sprite => sprite.id === id)) { + this.fire(new performance.ErrorEvent(new Error(`Sprite "${id}" doesn't exists on this map.`))); + return; + } + if (this._spritesImagesIds[id]) { + for (const imageId of this._spritesImagesIds[id]) { + this.imageManager.removeImage(imageId); + this._changedImages[imageId] = true; + } + } + internalSpriteRepresentation.splice(internalSpriteRepresentation.findIndex(sprite => sprite.id === id), 1); + this.stylesheet.sprite = internalSpriteRepresentation.length > 0 ? internalSpriteRepresentation : undefined; + delete this._spritesImagesIds[id]; + this._availableImages = this.imageManager.listImages(); + this._changed = true; + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new performance.Event('data', { dataType: 'style' })); + } + /** + * Get the current sprite value. + * + * @returns empty array when no sprite is set; id-url pairs otherwise + */ + getSprite() { + return coerceSpriteToArray(this.stylesheet.sprite); + } + /** + * Set a new value for the style's sprite. + * + * @param sprite - new sprite value + * @param options - style setter options + * @param completion - the completion handler + */ + setSprite(sprite, options = {}, completion) { + this._checkLoaded(); + if (sprite && this._validate(performance.validateStyle.sprite, 'sprite', sprite, null, options)) { + return; + } + this.stylesheet.sprite = sprite; + if (sprite) { + this._loadSprite(sprite, true, completion); + } + else { + this._unloadSprite(); + if (completion) { + completion(null); + } + } + } +} +Style.registerForPluginStateChange = performance.registerForPluginStateChange; + +var posAttributes = performance.createLayout([ + { name: 'a_pos', type: 'Int16', components: 2 } +]); + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var preludeFrag = '#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var preludeVert = '#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var backgroundFrag = 'uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var backgroundVert = 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var backgroundPatternFrag = 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var backgroundPatternVert = 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var circleFrag = 'varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var circleVert = 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var clippingMaskFrag = 'void main() {gl_FragColor=vec4(1.0);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var clippingMaskVert = 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var heatmapFrag = 'uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var heatmapVert = 'uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var heatmapTextureFrag = 'uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var heatmapTextureVert = 'uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var collisionBoxFrag = 'varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var collisionBoxVert = 'attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var collisionCircleFrag = 'varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var collisionCircleVert = 'attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var debugFrag = 'uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var debugVert = 'attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillFrag = '#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillVert = 'attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillOutlineFrag = 'varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillOutlineVert = 'attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillOutlinePatternFrag = 'uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillOutlinePatternVert = 'uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillPatternFrag = '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillPatternVert = 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillExtrusionFrag = 'varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillExtrusionVert = 'uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillExtrusionPatternFrag = 'uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var fillExtrusionPatternVert = 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var hillshadePrepareFrag = '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var hillshadePrepareVert = 'uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var hillshadeFrag = 'uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var hillshadeVert = 'uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var lineFrag = 'uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var lineVert = '\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var lineGradientFrag = 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var lineGradientVert = '\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var linePatternFrag = '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var linePatternVert = '\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var lineSDFFrag = 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var lineSDFVert = '\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var rasterFrag = 'uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var rasterVert = 'uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var symbolIconFrag = 'uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var symbolIconVert = 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var symbolSDFFrag = '#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var symbolSDFVert = 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var symbolTextAndIconFrag = '#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var symbolTextAndIconVert = 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var terrainDepthFrag = 'varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var terrainCoordsFrag = 'precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var terrainFrag = 'uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}'; + +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +var terrainVert = 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}'; + +// Disable Flow annotations here because Flow doesn't support importing GLSL files +const shaders = { + prelude: compile(preludeFrag, preludeVert), + background: compile(backgroundFrag, backgroundVert), + backgroundPattern: compile(backgroundPatternFrag, backgroundPatternVert), + circle: compile(circleFrag, circleVert), + clippingMask: compile(clippingMaskFrag, clippingMaskVert), + heatmap: compile(heatmapFrag, heatmapVert), + heatmapTexture: compile(heatmapTextureFrag, heatmapTextureVert), + collisionBox: compile(collisionBoxFrag, collisionBoxVert), + collisionCircle: compile(collisionCircleFrag, collisionCircleVert), + debug: compile(debugFrag, debugVert), + fill: compile(fillFrag, fillVert), + fillOutline: compile(fillOutlineFrag, fillOutlineVert), + fillOutlinePattern: compile(fillOutlinePatternFrag, fillOutlinePatternVert), + fillPattern: compile(fillPatternFrag, fillPatternVert), + fillExtrusion: compile(fillExtrusionFrag, fillExtrusionVert), + fillExtrusionPattern: compile(fillExtrusionPatternFrag, fillExtrusionPatternVert), + hillshadePrepare: compile(hillshadePrepareFrag, hillshadePrepareVert), + hillshade: compile(hillshadeFrag, hillshadeVert), + line: compile(lineFrag, lineVert), + lineGradient: compile(lineGradientFrag, lineGradientVert), + linePattern: compile(linePatternFrag, linePatternVert), + lineSDF: compile(lineSDFFrag, lineSDFVert), + raster: compile(rasterFrag, rasterVert), + symbolIcon: compile(symbolIconFrag, symbolIconVert), + symbolSDF: compile(symbolSDFFrag, symbolSDFVert), + symbolTextAndIcon: compile(symbolTextAndIconFrag, symbolTextAndIconVert), + terrain: compile(terrainFrag, terrainVert), + terrainDepth: compile(terrainDepthFrag, terrainVert), + terrainCoords: compile(terrainCoordsFrag, terrainVert) +}; +// Expand #pragmas to #ifdefs. +function compile(fragmentSource, vertexSource) { + const re = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g; + const staticAttributes = vertexSource.match(/attribute ([\w]+) ([\w]+)/g); + const fragmentUniforms = fragmentSource.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g); + const vertexUniforms = vertexSource.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g); + const staticUniforms = vertexUniforms ? vertexUniforms.concat(fragmentUniforms) : fragmentUniforms; + const fragmentPragmas = {}; + fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => { + fragmentPragmas[name] = true; + if (operation === 'define') { + return ` +#ifndef HAS_UNIFORM_u_${name} +varying ${precision} ${type} ${name}; +#else +uniform ${precision} ${type} u_${name}; +#endif +`; + } + else /* if (operation === 'initialize') */ { + return ` +#ifdef HAS_UNIFORM_u_${name} + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + }); + vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => { + const attrType = type === 'float' ? 'vec2' : 'vec4'; + const unpackType = name.match(/color/) ? 'color' : attrType; + if (fragmentPragmas[name]) { + if (operation === 'define') { + return ` +#ifndef HAS_UNIFORM_u_${name} +uniform lowp float u_${name}_t; +attribute ${precision} ${attrType} a_${name}; +varying ${precision} ${type} ${name}; +#else +uniform ${precision} ${type} u_${name}; +#endif +`; + } + else /* if (operation === 'initialize') */ { + if (unpackType === 'vec4') { + // vec4 attributes are only used for cross-faded properties, and are not packed + return ` +#ifndef HAS_UNIFORM_u_${name} + ${name} = a_${name}; +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + else { + return ` +#ifndef HAS_UNIFORM_u_${name} + ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t); +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + } + } + else { + if (operation === 'define') { + return ` +#ifndef HAS_UNIFORM_u_${name} +uniform lowp float u_${name}_t; +attribute ${precision} ${attrType} a_${name}; +#else +uniform ${precision} ${type} u_${name}; +#endif +`; + } + else /* if (operation === 'initialize') */ { + if (unpackType === 'vec4') { + // vec4 attributes are only used for cross-faded properties, and are not packed + return ` +#ifndef HAS_UNIFORM_u_${name} + ${precision} ${type} ${name} = a_${name}; +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + else /* */ { + return ` +#ifndef HAS_UNIFORM_u_${name} + ${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t); +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + } + } + }); + return { fragmentSource, vertexSource, staticAttributes, staticUniforms }; +} + +/** + * @internal + * A vertex array object used to pass data to the webgl code + */ +class VertexArrayObject { + constructor() { + this.boundProgram = null; + this.boundLayoutVertexBuffer = null; + this.boundPaintVertexBuffers = []; + this.boundIndexBuffer = null; + this.boundVertexOffset = null; + this.boundDynamicVertexBuffer = null; + this.vao = null; + } + bind(context, program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3) { + this.context = context; + let paintBuffersDiffer = this.boundPaintVertexBuffers.length !== paintVertexBuffers.length; + for (let i = 0; !paintBuffersDiffer && i < paintVertexBuffers.length; i++) { + if (this.boundPaintVertexBuffers[i] !== paintVertexBuffers[i]) { + paintBuffersDiffer = true; + } + } + const isFreshBindRequired = (!this.vao || + this.boundProgram !== program || + this.boundLayoutVertexBuffer !== layoutVertexBuffer || + paintBuffersDiffer || + this.boundIndexBuffer !== indexBuffer || + this.boundVertexOffset !== vertexOffset || + this.boundDynamicVertexBuffer !== dynamicVertexBuffer || + this.boundDynamicVertexBuffer2 !== dynamicVertexBuffer2 || + this.boundDynamicVertexBuffer3 !== dynamicVertexBuffer3); + if (isFreshBindRequired) { + this.freshBind(program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3); + } + else { + context.bindVertexArray.set(this.vao); + if (dynamicVertexBuffer) { + // The buffer may have been updated. Rebind to upload data. + dynamicVertexBuffer.bind(); + } + if (indexBuffer && indexBuffer.dynamicDraw) { + indexBuffer.bind(); + } + if (dynamicVertexBuffer2) { + dynamicVertexBuffer2.bind(); + } + if (dynamicVertexBuffer3) { + dynamicVertexBuffer3.bind(); + } + } + } + freshBind(program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3) { + const numNextAttributes = program.numAttributes; + const context = this.context; + const gl = context.gl; + if (this.vao) + this.destroy(); + this.vao = context.createVertexArray(); + context.bindVertexArray.set(this.vao); + // store the arguments so that we can verify them when the vao is bound again + this.boundProgram = program; + this.boundLayoutVertexBuffer = layoutVertexBuffer; + this.boundPaintVertexBuffers = paintVertexBuffers; + this.boundIndexBuffer = indexBuffer; + this.boundVertexOffset = vertexOffset; + this.boundDynamicVertexBuffer = dynamicVertexBuffer; + this.boundDynamicVertexBuffer2 = dynamicVertexBuffer2; + this.boundDynamicVertexBuffer3 = dynamicVertexBuffer3; + layoutVertexBuffer.enableAttributes(gl, program); + for (const vertexBuffer of paintVertexBuffers) { + vertexBuffer.enableAttributes(gl, program); + } + if (dynamicVertexBuffer) { + dynamicVertexBuffer.enableAttributes(gl, program); + } + if (dynamicVertexBuffer2) { + dynamicVertexBuffer2.enableAttributes(gl, program); + } + if (dynamicVertexBuffer3) { + dynamicVertexBuffer3.enableAttributes(gl, program); + } + layoutVertexBuffer.bind(); + layoutVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); + for (const vertexBuffer of paintVertexBuffers) { + vertexBuffer.bind(); + vertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); + } + if (dynamicVertexBuffer) { + dynamicVertexBuffer.bind(); + dynamicVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); + } + if (indexBuffer) { + indexBuffer.bind(); + } + if (dynamicVertexBuffer2) { + dynamicVertexBuffer2.bind(); + dynamicVertexBuffer2.setVertexAttribPointers(gl, program, vertexOffset); + } + if (dynamicVertexBuffer3) { + dynamicVertexBuffer3.bind(); + dynamicVertexBuffer3.setVertexAttribPointers(gl, program, vertexOffset); + } + context.currentNumAttributes = numNextAttributes; + } + destroy() { + if (this.vao) { + this.context.deleteVertexArray(this.vao); + this.vao = null; + } + } +} + +const terrainPreludeUniforms = (context, locations) => ({ + 'u_depth': new performance.Uniform1i(context, locations.u_depth), + 'u_terrain': new performance.Uniform1i(context, locations.u_terrain), + 'u_terrain_dim': new performance.Uniform1f(context, locations.u_terrain_dim), + 'u_terrain_matrix': new performance.UniformMatrix4f(context, locations.u_terrain_matrix), + 'u_terrain_unpack': new performance.Uniform4f(context, locations.u_terrain_unpack), + 'u_terrain_exaggeration': new performance.Uniform1f(context, locations.u_terrain_exaggeration) +}); +const terrainUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_texture': new performance.Uniform1i(context, locations.u_texture), + 'u_ele_delta': new performance.Uniform1f(context, locations.u_ele_delta) +}); +const terrainDepthUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_ele_delta': new performance.Uniform1f(context, locations.u_ele_delta) +}); +const terrainCoordsUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_texture': new performance.Uniform1i(context, locations.u_texture), + 'u_terrain_coords_id': new performance.Uniform1f(context, locations.u_terrain_coords_id), + 'u_ele_delta': new performance.Uniform1f(context, locations.u_ele_delta) +}); +const terrainUniformValues = (matrix, eleDelta) => ({ + 'u_matrix': matrix, + 'u_texture': 0, + 'u_ele_delta': eleDelta +}); +const terrainDepthUniformValues = (matrix, eleDelta) => ({ + 'u_matrix': matrix, + 'u_ele_delta': eleDelta +}); +const terrainCoordsUniformValues = (matrix, coordsId, eleDelta) => ({ + 'u_matrix': matrix, + 'u_terrain_coords_id': coordsId / 255, + 'u_texture': 0, + 'u_ele_delta': eleDelta +}); + +function getTokenizedAttributesAndUniforms(array) { + const result = []; + for (let i = 0; i < array.length; i++) { + if (array[i] === null) + continue; + const token = array[i].split(' '); + result.push(token.pop()); + } + return result; +} +/** + * @internal + * A webgl program to execute in the GPU space + */ +class Program { + constructor(context, source, configuration, fixedUniforms, showOverdrawInspector, terrain) { + const gl = context.gl; + this.program = gl.createProgram(); + const staticAttrInfo = getTokenizedAttributesAndUniforms(source.staticAttributes); + const dynamicAttrInfo = configuration ? configuration.getBinderAttributes() : []; + const allAttrInfo = staticAttrInfo.concat(dynamicAttrInfo); + const preludeUniformsInfo = shaders.prelude.staticUniforms ? getTokenizedAttributesAndUniforms(shaders.prelude.staticUniforms) : []; + const staticUniformsInfo = source.staticUniforms ? getTokenizedAttributesAndUniforms(source.staticUniforms) : []; + const dynamicUniformsInfo = configuration ? configuration.getBinderUniforms() : []; + // remove duplicate uniforms + const uniformList = preludeUniformsInfo.concat(staticUniformsInfo).concat(dynamicUniformsInfo); + const allUniformsInfo = []; + for (const uniform of uniformList) { + if (allUniformsInfo.indexOf(uniform) < 0) + allUniformsInfo.push(uniform); + } + const defines = configuration ? configuration.defines() : []; + if (showOverdrawInspector) { + defines.push('#define OVERDRAW_INSPECTOR;'); + } + if (terrain) { + defines.push('#define TERRAIN3D;'); + } + const fragmentSource = defines.concat(shaders.prelude.fragmentSource, source.fragmentSource).join('\n'); + const vertexSource = defines.concat(shaders.prelude.vertexSource, source.vertexSource).join('\n'); + const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + if (gl.isContextLost()) { + this.failedToCreate = true; + return; + } + gl.shaderSource(fragmentShader, fragmentSource); + gl.compileShader(fragmentShader); + if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) { + throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`); + } + gl.attachShader(this.program, fragmentShader); + const vertexShader = gl.createShader(gl.VERTEX_SHADER); + if (gl.isContextLost()) { + this.failedToCreate = true; + return; + } + gl.shaderSource(vertexShader, vertexSource); + gl.compileShader(vertexShader); + if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) { + throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`); + } + gl.attachShader(this.program, vertexShader); + this.attributes = {}; + const uniformLocations = {}; + this.numAttributes = allAttrInfo.length; + for (let i = 0; i < this.numAttributes; i++) { + if (allAttrInfo[i]) { + gl.bindAttribLocation(this.program, i, allAttrInfo[i]); + this.attributes[allAttrInfo[i]] = i; + } + } + gl.linkProgram(this.program); + if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) { + throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`); + } + gl.deleteShader(vertexShader); + gl.deleteShader(fragmentShader); + for (let it = 0; it < allUniformsInfo.length; it++) { + const uniform = allUniformsInfo[it]; + if (uniform && !uniformLocations[uniform]) { + const uniformLocation = gl.getUniformLocation(this.program, uniform); + if (uniformLocation) { + uniformLocations[uniform] = uniformLocation; + } + } + } + this.fixedUniforms = fixedUniforms(context, uniformLocations); + this.terrainUniforms = terrainPreludeUniforms(context, uniformLocations); + this.binderUniforms = configuration ? configuration.getUniforms(context, uniformLocations) : []; + } + draw(context, drawMode, depthMode, stencilMode, colorMode, cullFaceMode, uniformValues, terrain, layerID, layoutVertexBuffer, indexBuffer, segments, currentProperties, zoom, configuration, dynamicLayoutBuffer, dynamicLayoutBuffer2, dynamicLayoutBuffer3) { + const gl = context.gl; + if (this.failedToCreate) + return; + context.program.set(this.program); + context.setDepthMode(depthMode); + context.setStencilMode(stencilMode); + context.setColorMode(colorMode); + context.setCullFace(cullFaceMode); + // set variables used by the 3d functions defined in _prelude.vertex.glsl + if (terrain) { + context.activeTexture.set(gl.TEXTURE2); + gl.bindTexture(gl.TEXTURE_2D, terrain.depthTexture); + context.activeTexture.set(gl.TEXTURE3); + gl.bindTexture(gl.TEXTURE_2D, terrain.texture); + for (const name in this.terrainUniforms) { + this.terrainUniforms[name].set(terrain[name]); + } + } + for (const name in this.fixedUniforms) { + this.fixedUniforms[name].set(uniformValues[name]); + } + if (configuration) { + configuration.setUniforms(context, this.binderUniforms, currentProperties, { zoom: zoom }); + } + let primitiveSize = 0; + switch (drawMode) { + case gl.LINES: + primitiveSize = 2; + break; + case gl.TRIANGLES: + primitiveSize = 3; + break; + case gl.LINE_STRIP: + primitiveSize = 1; + break; + } + for (const segment of segments.get()) { + const vaos = segment.vaos || (segment.vaos = {}); + const vao = vaos[layerID] || (vaos[layerID] = new VertexArrayObject()); + vao.bind(context, this, layoutVertexBuffer, configuration ? configuration.getPaintVertexBuffers() : [], indexBuffer, segment.vertexOffset, dynamicLayoutBuffer, dynamicLayoutBuffer2, dynamicLayoutBuffer3); + gl.drawElements(drawMode, segment.primitiveLength * primitiveSize, gl.UNSIGNED_SHORT, segment.primitiveOffset * primitiveSize * 2); + } + } +} + +function patternUniformValues(crossfade, painter, tile) { + const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom); + const numTiles = Math.pow(2, tile.tileID.overscaledZ); + const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles; + const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles); + const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y; + return { + 'u_image': 0, + 'u_texsize': tile.imageAtlasTexture.size, + 'u_scale': [tileRatio, crossfade.fromScale, crossfade.toScale], + 'u_fade': crossfade.t, + // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision. + 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16], + 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF] + }; +} +function bgPatternUniformValues(image, crossfade, painter, tile) { + const imagePosA = painter.imageManager.getPattern(image.from.toString()); + const imagePosB = painter.imageManager.getPattern(image.to.toString()); + const { width, height } = painter.imageManager.getPixelSize(); + const numTiles = Math.pow(2, tile.tileID.overscaledZ); + const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles; + const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles); + const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y; + return { + 'u_image': 0, + 'u_pattern_tl_a': imagePosA.tl, + 'u_pattern_br_a': imagePosA.br, + 'u_pattern_tl_b': imagePosB.tl, + 'u_pattern_br_b': imagePosB.br, + 'u_texsize': [width, height], + 'u_mix': crossfade.t, + 'u_pattern_size_a': imagePosA.displaySize, + 'u_pattern_size_b': imagePosB.displaySize, + 'u_scale_a': crossfade.fromScale, + 'u_scale_b': crossfade.toScale, + 'u_tile_units_to_pixels': 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom), + // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision. + 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16], + 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF] + }; +} + +const fillExtrusionUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_lightpos': new performance.Uniform3f(context, locations.u_lightpos), + 'u_lightintensity': new performance.Uniform1f(context, locations.u_lightintensity), + 'u_lightcolor': new performance.Uniform3f(context, locations.u_lightcolor), + 'u_vertical_gradient': new performance.Uniform1f(context, locations.u_vertical_gradient), + 'u_opacity': new performance.Uniform1f(context, locations.u_opacity) +}); +const fillExtrusionPatternUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_lightpos': new performance.Uniform3f(context, locations.u_lightpos), + 'u_lightintensity': new performance.Uniform1f(context, locations.u_lightintensity), + 'u_lightcolor': new performance.Uniform3f(context, locations.u_lightcolor), + 'u_vertical_gradient': new performance.Uniform1f(context, locations.u_vertical_gradient), + 'u_height_factor': new performance.Uniform1f(context, locations.u_height_factor), + // pattern uniforms + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_pixel_coord_upper': new performance.Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new performance.Uniform2f(context, locations.u_pixel_coord_lower), + 'u_scale': new performance.Uniform3f(context, locations.u_scale), + 'u_fade': new performance.Uniform1f(context, locations.u_fade), + 'u_opacity': new performance.Uniform1f(context, locations.u_opacity) +}); +const fillExtrusionUniformValues = (matrix, painter, shouldUseVerticalGradient, opacity) => { + const light = painter.style.light; + const _lp = light.properties.get('position'); + const lightPos = [_lp.x, _lp.y, _lp.z]; + const lightMat = performance.create$1(); + if (light.properties.get('anchor') === 'viewport') { + performance.fromRotation(lightMat, -painter.transform.angle); + } + performance.transformMat3(lightPos, lightPos, lightMat); + const lightColor = light.properties.get('color'); + return { + 'u_matrix': matrix, + 'u_lightpos': lightPos, + 'u_lightintensity': light.properties.get('intensity'), + 'u_lightcolor': [lightColor.r, lightColor.g, lightColor.b], + 'u_vertical_gradient': +shouldUseVerticalGradient, + 'u_opacity': opacity + }; +}; +const fillExtrusionPatternUniformValues = (matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile) => { + return performance.extend(fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity), patternUniformValues(crossfade, painter, tile), { + 'u_height_factor': -Math.pow(2, coord.overscaledZ) / tile.tileSize / 8 + }); +}; + +const fillUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix) +}); +const fillPatternUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_pixel_coord_upper': new performance.Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new performance.Uniform2f(context, locations.u_pixel_coord_lower), + 'u_scale': new performance.Uniform3f(context, locations.u_scale), + 'u_fade': new performance.Uniform1f(context, locations.u_fade) +}); +const fillOutlineUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_world': new performance.Uniform2f(context, locations.u_world) +}); +const fillOutlinePatternUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_world': new performance.Uniform2f(context, locations.u_world), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_pixel_coord_upper': new performance.Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new performance.Uniform2f(context, locations.u_pixel_coord_lower), + 'u_scale': new performance.Uniform3f(context, locations.u_scale), + 'u_fade': new performance.Uniform1f(context, locations.u_fade) +}); +const fillUniformValues = (matrix) => ({ + 'u_matrix': matrix +}); +const fillPatternUniformValues = (matrix, painter, crossfade, tile) => performance.extend(fillUniformValues(matrix), patternUniformValues(crossfade, painter, tile)); +const fillOutlineUniformValues = (matrix, drawingBufferSize) => ({ + 'u_matrix': matrix, + 'u_world': drawingBufferSize +}); +const fillOutlinePatternUniformValues = (matrix, painter, crossfade, tile, drawingBufferSize) => performance.extend(fillPatternUniformValues(matrix, painter, crossfade, tile), { + 'u_world': drawingBufferSize +}); + +const circleUniforms = (context, locations) => ({ + 'u_camera_to_center_distance': new performance.Uniform1f(context, locations.u_camera_to_center_distance), + 'u_scale_with_map': new performance.Uniform1i(context, locations.u_scale_with_map), + 'u_pitch_with_map': new performance.Uniform1i(context, locations.u_pitch_with_map), + 'u_extrude_scale': new performance.Uniform2f(context, locations.u_extrude_scale), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix) +}); +const circleUniformValues = (painter, coord, tile, layer) => { + const transform = painter.transform; + let pitchWithMap, extrudeScale; + if (layer.paint.get('circle-pitch-alignment') === 'map') { + const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom); + pitchWithMap = true; + extrudeScale = [pixelRatio, pixelRatio]; + } + else { + pitchWithMap = false; + extrudeScale = transform.pixelsToGLUnits; + } + return { + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_scale_with_map': +(layer.paint.get('circle-pitch-scale') === 'map'), + 'u_matrix': painter.translatePosMatrix(coord.posMatrix, tile, layer.paint.get('circle-translate'), layer.paint.get('circle-translate-anchor')), + 'u_pitch_with_map': +(pitchWithMap), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_extrude_scale': extrudeScale + }; +}; + +const collisionUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_camera_to_center_distance': new performance.Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pixels_to_tile_units': new performance.Uniform1f(context, locations.u_pixels_to_tile_units), + 'u_extrude_scale': new performance.Uniform2f(context, locations.u_extrude_scale), + 'u_overscale_factor': new performance.Uniform1f(context, locations.u_overscale_factor) +}); +const collisionCircleUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_inv_matrix': new performance.UniformMatrix4f(context, locations.u_inv_matrix), + 'u_camera_to_center_distance': new performance.Uniform1f(context, locations.u_camera_to_center_distance), + 'u_viewport_size': new performance.Uniform2f(context, locations.u_viewport_size) +}); +const collisionUniformValues = (matrix, transform, tile) => { + const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom); + const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ); + const overscaleFactor = tile.tileID.overscaleFactor(); + return { + 'u_matrix': matrix, + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_pixels_to_tile_units': pixelRatio, + 'u_extrude_scale': [transform.pixelsToGLUnits[0] / (pixelRatio * scale), + transform.pixelsToGLUnits[1] / (pixelRatio * scale)], + 'u_overscale_factor': overscaleFactor + }; +}; +const collisionCircleUniformValues = (matrix, invMatrix, transform) => { + return { + 'u_matrix': matrix, + 'u_inv_matrix': invMatrix, + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_viewport_size': [transform.width, transform.height] + }; +}; + +const debugUniforms = (context, locations) => ({ + 'u_color': new performance.UniformColor(context, locations.u_color), + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_overlay': new performance.Uniform1i(context, locations.u_overlay), + 'u_overlay_scale': new performance.Uniform1f(context, locations.u_overlay_scale) +}); +const debugUniformValues = (matrix, color, scaleRatio = 1) => ({ + 'u_matrix': matrix, + 'u_color': color, + 'u_overlay': 0, + 'u_overlay_scale': scaleRatio +}); + +const clippingMaskUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix) +}); +const clippingMaskUniformValues = (matrix) => ({ + 'u_matrix': matrix +}); + +const heatmapUniforms = (context, locations) => ({ + 'u_extrude_scale': new performance.Uniform1f(context, locations.u_extrude_scale), + 'u_intensity': new performance.Uniform1f(context, locations.u_intensity), + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix) +}); +const heatmapTextureUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_world': new performance.Uniform2f(context, locations.u_world), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_color_ramp': new performance.Uniform1i(context, locations.u_color_ramp), + 'u_opacity': new performance.Uniform1f(context, locations.u_opacity) +}); +const heatmapUniformValues = (matrix, tile, zoom, intensity) => ({ + 'u_matrix': matrix, + 'u_extrude_scale': pixelsToTileUnits(tile, 1, zoom), + 'u_intensity': intensity +}); +const heatmapTextureUniformValues = (painter, layer, textureUnit, colorRampUnit) => { + const matrix = performance.create(); + performance.ortho(matrix, 0, painter.width, painter.height, 0, 0, 1); + const gl = painter.context.gl; + return { + 'u_matrix': matrix, + 'u_world': [gl.drawingBufferWidth, gl.drawingBufferHeight], + 'u_image': textureUnit, + 'u_color_ramp': colorRampUnit, + 'u_opacity': layer.paint.get('heatmap-opacity') + }; +}; + +const hillshadeUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_latrange': new performance.Uniform2f(context, locations.u_latrange), + 'u_light': new performance.Uniform2f(context, locations.u_light), + 'u_shadow': new performance.UniformColor(context, locations.u_shadow), + 'u_highlight': new performance.UniformColor(context, locations.u_highlight), + 'u_accent': new performance.UniformColor(context, locations.u_accent) +}); +const hillshadePrepareUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_dimension': new performance.Uniform2f(context, locations.u_dimension), + 'u_zoom': new performance.Uniform1f(context, locations.u_zoom), + 'u_unpack': new performance.Uniform4f(context, locations.u_unpack) +}); +const hillshadeUniformValues = (painter, tile, layer, coord) => { + const shadow = layer.paint.get('hillshade-shadow-color'); + const highlight = layer.paint.get('hillshade-highlight-color'); + const accent = layer.paint.get('hillshade-accent-color'); + let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180); + // modify azimuthal angle by map rotation if light is anchored at the viewport + if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') { + azimuthal -= painter.transform.angle; + } + const align = !painter.options.moving; + return { + 'u_matrix': coord ? coord.posMatrix : painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align), + 'u_image': 0, + 'u_latrange': getTileLatRange(painter, tile.tileID), + 'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal], + 'u_shadow': shadow, + 'u_highlight': highlight, + 'u_accent': accent + }; +}; +const hillshadeUniformPrepareValues = (tileID, dem) => { + const stride = dem.stride; + const matrix = performance.create(); + // Flip rendering at y axis. + performance.ortho(matrix, 0, performance.EXTENT, -performance.EXTENT, 0, 0, 1); + performance.translate(matrix, matrix, [0, -performance.EXTENT, 0]); + return { + 'u_matrix': matrix, + 'u_image': 1, + 'u_dimension': [stride, stride], + 'u_zoom': tileID.overscaledZ, + 'u_unpack': dem.getUnpackVector() + }; +}; +function getTileLatRange(painter, tileID) { + // for scaling the magnitude of a points slope by its latitude + const tilesAtZoom = Math.pow(2, tileID.canonical.z); + const y = tileID.canonical.y; + return [ + new performance.MercatorCoordinate(0, y / tilesAtZoom).toLngLat().lat, + new performance.MercatorCoordinate(0, (y + 1) / tilesAtZoom).toLngLat().lat + ]; +} + +const lineUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_ratio': new performance.Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_units_to_pixels': new performance.Uniform2f(context, locations.u_units_to_pixels) +}); +const lineGradientUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_ratio': new performance.Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_units_to_pixels': new performance.Uniform2f(context, locations.u_units_to_pixels), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_image_height': new performance.Uniform1f(context, locations.u_image_height) +}); +const linePatternUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_ratio': new performance.Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_units_to_pixels': new performance.Uniform2f(context, locations.u_units_to_pixels), + 'u_scale': new performance.Uniform3f(context, locations.u_scale), + 'u_fade': new performance.Uniform1f(context, locations.u_fade) +}); +const lineSDFUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_ratio': new performance.Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_units_to_pixels': new performance.Uniform2f(context, locations.u_units_to_pixels), + 'u_patternscale_a': new performance.Uniform2f(context, locations.u_patternscale_a), + 'u_patternscale_b': new performance.Uniform2f(context, locations.u_patternscale_b), + 'u_sdfgamma': new performance.Uniform1f(context, locations.u_sdfgamma), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_tex_y_a': new performance.Uniform1f(context, locations.u_tex_y_a), + 'u_tex_y_b': new performance.Uniform1f(context, locations.u_tex_y_b), + 'u_mix': new performance.Uniform1f(context, locations.u_mix) +}); +const lineUniformValues = (painter, tile, layer, coord) => { + const transform = painter.transform; + return { + 'u_matrix': calculateMatrix(painter, tile, layer, coord), + 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_units_to_pixels': [ + 1 / transform.pixelsToGLUnits[0], + 1 / transform.pixelsToGLUnits[1] + ] + }; +}; +const lineGradientUniformValues = (painter, tile, layer, imageHeight, coord) => { + return performance.extend(lineUniformValues(painter, tile, layer, coord), { + 'u_image': 0, + 'u_image_height': imageHeight, + }); +}; +const linePatternUniformValues = (painter, tile, layer, crossfade, coord) => { + const transform = painter.transform; + const tileZoomRatio = calculateTileRatio(tile, transform); + return { + 'u_matrix': calculateMatrix(painter, tile, layer, coord), + 'u_texsize': tile.imageAtlasTexture.size, + // camera zoom ratio + 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_image': 0, + 'u_scale': [tileZoomRatio, crossfade.fromScale, crossfade.toScale], + 'u_fade': crossfade.t, + 'u_units_to_pixels': [ + 1 / transform.pixelsToGLUnits[0], + 1 / transform.pixelsToGLUnits[1] + ] + }; +}; +const lineSDFUniformValues = (painter, tile, layer, dasharray, crossfade, coord) => { + const transform = painter.transform; + const lineAtlas = painter.lineAtlas; + const tileRatio = calculateTileRatio(tile, transform); + const round = layer.layout.get('line-cap') === 'round'; + const posA = lineAtlas.getDash(dasharray.from, round); + const posB = lineAtlas.getDash(dasharray.to, round); + const widthA = posA.width * crossfade.fromScale; + const widthB = posB.width * crossfade.toScale; + return performance.extend(lineUniformValues(painter, tile, layer, coord), { + 'u_patternscale_a': [tileRatio / widthA, -posA.height / 2], + 'u_patternscale_b': [tileRatio / widthB, -posB.height / 2], + 'u_sdfgamma': lineAtlas.width / (Math.min(widthA, widthB) * 256 * painter.pixelRatio) / 2, + 'u_image': 0, + 'u_tex_y_a': posA.y, + 'u_tex_y_b': posB.y, + 'u_mix': crossfade.t + }); +}; +function calculateTileRatio(tile, transform) { + return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom); +} +function calculateMatrix(painter, tile, layer, coord) { + return painter.translatePosMatrix(coord ? coord.posMatrix : tile.tileID.posMatrix, tile, layer.paint.get('line-translate'), layer.paint.get('line-translate-anchor')); +} + +const rasterUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_tl_parent': new performance.Uniform2f(context, locations.u_tl_parent), + 'u_scale_parent': new performance.Uniform1f(context, locations.u_scale_parent), + 'u_buffer_scale': new performance.Uniform1f(context, locations.u_buffer_scale), + 'u_fade_t': new performance.Uniform1f(context, locations.u_fade_t), + 'u_opacity': new performance.Uniform1f(context, locations.u_opacity), + 'u_image0': new performance.Uniform1i(context, locations.u_image0), + 'u_image1': new performance.Uniform1i(context, locations.u_image1), + 'u_brightness_low': new performance.Uniform1f(context, locations.u_brightness_low), + 'u_brightness_high': new performance.Uniform1f(context, locations.u_brightness_high), + 'u_saturation_factor': new performance.Uniform1f(context, locations.u_saturation_factor), + 'u_contrast_factor': new performance.Uniform1f(context, locations.u_contrast_factor), + 'u_spin_weights': new performance.Uniform3f(context, locations.u_spin_weights) +}); +const rasterUniformValues = (matrix, parentTL, parentScaleBy, fade, layer) => ({ + 'u_matrix': matrix, + 'u_tl_parent': parentTL, + 'u_scale_parent': parentScaleBy, + 'u_buffer_scale': 1, + 'u_fade_t': fade.mix, + 'u_opacity': fade.opacity * layer.paint.get('raster-opacity'), + 'u_image0': 0, + 'u_image1': 1, + 'u_brightness_low': layer.paint.get('raster-brightness-min'), + 'u_brightness_high': layer.paint.get('raster-brightness-max'), + 'u_saturation_factor': saturationFactor(layer.paint.get('raster-saturation')), + 'u_contrast_factor': contrastFactor(layer.paint.get('raster-contrast')), + 'u_spin_weights': spinWeights(layer.paint.get('raster-hue-rotate')) +}); +function spinWeights(angle) { + angle *= Math.PI / 180; + const s = Math.sin(angle); + const c = Math.cos(angle); + return [ + (2 * c + 1) / 3, + (-Math.sqrt(3) * s - c + 1) / 3, + (Math.sqrt(3) * s - c + 1) / 3 + ]; +} +function contrastFactor(contrast) { + return contrast > 0 ? + 1 / (1 - contrast) : + 1 + contrast; +} +function saturationFactor(saturation) { + return saturation > 0 ? + 1 - 1 / (1.001 - saturation) : + -saturation; +} + +const symbolIconUniforms = (context, locations) => ({ + 'u_is_size_zoom_constant': new performance.Uniform1i(context, locations.u_is_size_zoom_constant), + 'u_is_size_feature_constant': new performance.Uniform1i(context, locations.u_is_size_feature_constant), + 'u_size_t': new performance.Uniform1f(context, locations.u_size_t), + 'u_size': new performance.Uniform1f(context, locations.u_size), + 'u_camera_to_center_distance': new performance.Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pitch': new performance.Uniform1f(context, locations.u_pitch), + 'u_rotate_symbol': new performance.Uniform1i(context, locations.u_rotate_symbol), + 'u_aspect_ratio': new performance.Uniform1f(context, locations.u_aspect_ratio), + 'u_fade_change': new performance.Uniform1f(context, locations.u_fade_change), + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_label_plane_matrix': new performance.UniformMatrix4f(context, locations.u_label_plane_matrix), + 'u_coord_matrix': new performance.UniformMatrix4f(context, locations.u_coord_matrix), + 'u_is_text': new performance.Uniform1i(context, locations.u_is_text), + 'u_pitch_with_map': new performance.Uniform1i(context, locations.u_pitch_with_map), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_texture': new performance.Uniform1i(context, locations.u_texture) +}); +const symbolSDFUniforms = (context, locations) => ({ + 'u_is_size_zoom_constant': new performance.Uniform1i(context, locations.u_is_size_zoom_constant), + 'u_is_size_feature_constant': new performance.Uniform1i(context, locations.u_is_size_feature_constant), + 'u_size_t': new performance.Uniform1f(context, locations.u_size_t), + 'u_size': new performance.Uniform1f(context, locations.u_size), + 'u_camera_to_center_distance': new performance.Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pitch': new performance.Uniform1f(context, locations.u_pitch), + 'u_rotate_symbol': new performance.Uniform1i(context, locations.u_rotate_symbol), + 'u_aspect_ratio': new performance.Uniform1f(context, locations.u_aspect_ratio), + 'u_fade_change': new performance.Uniform1f(context, locations.u_fade_change), + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_label_plane_matrix': new performance.UniformMatrix4f(context, locations.u_label_plane_matrix), + 'u_coord_matrix': new performance.UniformMatrix4f(context, locations.u_coord_matrix), + 'u_is_text': new performance.Uniform1i(context, locations.u_is_text), + 'u_pitch_with_map': new performance.Uniform1i(context, locations.u_pitch_with_map), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_texture': new performance.Uniform1i(context, locations.u_texture), + 'u_gamma_scale': new performance.Uniform1f(context, locations.u_gamma_scale), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_is_halo': new performance.Uniform1i(context, locations.u_is_halo) +}); +const symbolTextAndIconUniforms = (context, locations) => ({ + 'u_is_size_zoom_constant': new performance.Uniform1i(context, locations.u_is_size_zoom_constant), + 'u_is_size_feature_constant': new performance.Uniform1i(context, locations.u_is_size_feature_constant), + 'u_size_t': new performance.Uniform1f(context, locations.u_size_t), + 'u_size': new performance.Uniform1f(context, locations.u_size), + 'u_camera_to_center_distance': new performance.Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pitch': new performance.Uniform1f(context, locations.u_pitch), + 'u_rotate_symbol': new performance.Uniform1i(context, locations.u_rotate_symbol), + 'u_aspect_ratio': new performance.Uniform1f(context, locations.u_aspect_ratio), + 'u_fade_change': new performance.Uniform1f(context, locations.u_fade_change), + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_label_plane_matrix': new performance.UniformMatrix4f(context, locations.u_label_plane_matrix), + 'u_coord_matrix': new performance.UniformMatrix4f(context, locations.u_coord_matrix), + 'u_is_text': new performance.Uniform1i(context, locations.u_is_text), + 'u_pitch_with_map': new performance.Uniform1i(context, locations.u_pitch_with_map), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_texsize_icon': new performance.Uniform2f(context, locations.u_texsize_icon), + 'u_texture': new performance.Uniform1i(context, locations.u_texture), + 'u_texture_icon': new performance.Uniform1i(context, locations.u_texture_icon), + 'u_gamma_scale': new performance.Uniform1f(context, locations.u_gamma_scale), + 'u_device_pixel_ratio': new performance.Uniform1f(context, locations.u_device_pixel_ratio), + 'u_is_halo': new performance.Uniform1i(context, locations.u_is_halo) +}); +const symbolIconUniformValues = (functionType, size, rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, glCoordMatrix, isText, texSize) => { + const transform = painter.transform; + return { + 'u_is_size_zoom_constant': +(functionType === 'constant' || functionType === 'source'), + 'u_is_size_feature_constant': +(functionType === 'constant' || functionType === 'camera'), + 'u_size_t': size ? size.uSizeT : 0, + 'u_size': size ? size.uSize : 0, + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_pitch': transform.pitch / 360 * 2 * Math.PI, + 'u_rotate_symbol': +rotateInShader, + 'u_aspect_ratio': transform.width / transform.height, + 'u_fade_change': painter.options.fadeDuration ? painter.symbolFadeChange : 1, + 'u_matrix': matrix, + 'u_label_plane_matrix': labelPlaneMatrix, + 'u_coord_matrix': glCoordMatrix, + 'u_is_text': +isText, + 'u_pitch_with_map': +pitchWithMap, + 'u_texsize': texSize, + 'u_texture': 0 + }; +}; +const symbolSDFUniformValues = (functionType, size, rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, glCoordMatrix, isText, texSize, isHalo) => { + const transform = painter.transform; + return performance.extend(symbolIconUniformValues(functionType, size, rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, glCoordMatrix, isText, texSize), { + 'u_gamma_scale': (pitchWithMap ? Math.cos(transform._pitch) * transform.cameraToCenterDistance : 1), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_is_halo': +isHalo + }); +}; +const symbolTextAndIconUniformValues = (functionType, size, rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, glCoordMatrix, texSizeSDF, texSizeIcon) => { + return performance.extend(symbolSDFUniformValues(functionType, size, rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, glCoordMatrix, true, texSizeSDF, true), { + 'u_texsize_icon': texSizeIcon, + 'u_texture_icon': 1 + }); +}; + +const backgroundUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_opacity': new performance.Uniform1f(context, locations.u_opacity), + 'u_color': new performance.UniformColor(context, locations.u_color) +}); +const backgroundPatternUniforms = (context, locations) => ({ + 'u_matrix': new performance.UniformMatrix4f(context, locations.u_matrix), + 'u_opacity': new performance.Uniform1f(context, locations.u_opacity), + 'u_image': new performance.Uniform1i(context, locations.u_image), + 'u_pattern_tl_a': new performance.Uniform2f(context, locations.u_pattern_tl_a), + 'u_pattern_br_a': new performance.Uniform2f(context, locations.u_pattern_br_a), + 'u_pattern_tl_b': new performance.Uniform2f(context, locations.u_pattern_tl_b), + 'u_pattern_br_b': new performance.Uniform2f(context, locations.u_pattern_br_b), + 'u_texsize': new performance.Uniform2f(context, locations.u_texsize), + 'u_mix': new performance.Uniform1f(context, locations.u_mix), + 'u_pattern_size_a': new performance.Uniform2f(context, locations.u_pattern_size_a), + 'u_pattern_size_b': new performance.Uniform2f(context, locations.u_pattern_size_b), + 'u_scale_a': new performance.Uniform1f(context, locations.u_scale_a), + 'u_scale_b': new performance.Uniform1f(context, locations.u_scale_b), + 'u_pixel_coord_upper': new performance.Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new performance.Uniform2f(context, locations.u_pixel_coord_lower), + 'u_tile_units_to_pixels': new performance.Uniform1f(context, locations.u_tile_units_to_pixels) +}); +const backgroundUniformValues = (matrix, opacity, color) => ({ + 'u_matrix': matrix, + 'u_opacity': opacity, + 'u_color': color +}); +const backgroundPatternUniformValues = (matrix, opacity, painter, image, tile, crossfade) => performance.extend(bgPatternUniformValues(image, crossfade, painter, tile), { + 'u_matrix': matrix, + 'u_opacity': opacity +}); + +const programUniforms = { + fillExtrusion: fillExtrusionUniforms, + fillExtrusionPattern: fillExtrusionPatternUniforms, + fill: fillUniforms, + fillPattern: fillPatternUniforms, + fillOutline: fillOutlineUniforms, + fillOutlinePattern: fillOutlinePatternUniforms, + circle: circleUniforms, + collisionBox: collisionUniforms, + collisionCircle: collisionCircleUniforms, + debug: debugUniforms, + clippingMask: clippingMaskUniforms, + heatmap: heatmapUniforms, + heatmapTexture: heatmapTextureUniforms, + hillshade: hillshadeUniforms, + hillshadePrepare: hillshadePrepareUniforms, + line: lineUniforms, + lineGradient: lineGradientUniforms, + linePattern: linePatternUniforms, + lineSDF: lineSDFUniforms, + raster: rasterUniforms, + symbolIcon: symbolIconUniforms, + symbolSDF: symbolSDFUniforms, + symbolTextAndIcon: symbolTextAndIconUniforms, + background: backgroundUniforms, + backgroundPattern: backgroundPatternUniforms, + terrain: terrainUniforms, + terrainDepth: terrainDepthUniforms, + terrainCoords: terrainCoordsUniforms +}; + +/** + * @internal + * an index buffer class + */ +class IndexBuffer { + constructor(context, array, dynamicDraw) { + this.context = context; + const gl = context.gl; + this.buffer = gl.createBuffer(); + this.dynamicDraw = Boolean(dynamicDraw); + // The bound index buffer is part of vertex array object state. We don't want to + // modify whatever VAO happens to be currently bound, so make sure the default + // vertex array provided by the context is bound instead. + this.context.unbindVAO(); + context.bindElementBuffer.set(this.buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW); + if (!this.dynamicDraw) { + delete array.arrayBuffer; + } + } + bind() { + this.context.bindElementBuffer.set(this.buffer); + } + updateData(array) { + const gl = this.context.gl; + if (!this.dynamicDraw) + throw new Error('Attempted to update data while not in dynamic mode.'); + // The right VAO will get this buffer re-bound later in VertexArrayObject#bind + // See https://github.com/mapbox/mapbox-gl-js/issues/5620 + this.context.unbindVAO(); + this.bind(); + gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, array.arrayBuffer); + } + destroy() { + const gl = this.context.gl; + if (this.buffer) { + gl.deleteBuffer(this.buffer); + delete this.buffer; + } + } +} + +/** + * An Enum for AttributeType + */ +const AttributeType = { + Int8: 'BYTE', + Uint8: 'UNSIGNED_BYTE', + Int16: 'SHORT', + Uint16: 'UNSIGNED_SHORT', + Int32: 'INT', + Uint32: 'UNSIGNED_INT', + Float32: 'FLOAT' +}; +/** + * @internal + * The `VertexBuffer` class turns a `StructArray` into a WebGL buffer. Each member of the StructArray's + * Struct type is converted to a WebGL attribute. + */ +class VertexBuffer { + /** + * @param dynamicDraw - Whether this buffer will be repeatedly updated. + */ + constructor(context, array, attributes, dynamicDraw) { + this.length = array.length; + this.attributes = attributes; + this.itemSize = array.bytesPerElement; + this.dynamicDraw = dynamicDraw; + this.context = context; + const gl = context.gl; + this.buffer = gl.createBuffer(); + context.bindVertexBuffer.set(this.buffer); + gl.bufferData(gl.ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW); + if (!this.dynamicDraw) { + delete array.arrayBuffer; + } + } + bind() { + this.context.bindVertexBuffer.set(this.buffer); + } + updateData(array) { + if (array.length !== this.length) + throw new Error(`Length of new data is ${array.length}, which doesn't match current length of ${this.length}`); + const gl = this.context.gl; + this.bind(); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer); + } + enableAttributes(gl, program) { + for (let j = 0; j < this.attributes.length; j++) { + const member = this.attributes[j]; + const attribIndex = program.attributes[member.name]; + if (attribIndex !== undefined) { + gl.enableVertexAttribArray(attribIndex); + } + } + } + /** + * Set the attribute pointers in a WebGL context + * @param gl - The WebGL context + * @param program - The active WebGL program + * @param vertexOffset - Index of the starting vertex of the segment + */ + setVertexAttribPointers(gl, program, vertexOffset) { + for (let j = 0; j < this.attributes.length; j++) { + const member = this.attributes[j]; + const attribIndex = program.attributes[member.name]; + if (attribIndex !== undefined) { + gl.vertexAttribPointer(attribIndex, member.components, gl[AttributeType[member.type]], false, this.itemSize, member.offset + (this.itemSize * (vertexOffset || 0))); + } + } + } + /** + * Destroy the GL buffer bound to the given WebGL context + */ + destroy() { + const gl = this.context.gl; + if (this.buffer) { + gl.deleteBuffer(this.buffer); + delete this.buffer; + } + } +} + +const cache = new WeakMap(); +function isWebGL2(gl) { + var _a; + if (cache.has(gl)) { + return cache.get(gl); + } + else { + const value = (_a = gl.getParameter(gl.VERSION)) === null || _a === void 0 ? void 0 : _a.startsWith('WebGL 2.0'); + cache.set(gl, value); + return value; + } +} + +class BaseValue { + constructor(context) { + this.gl = context.gl; + this.default = this.getDefault(); + this.current = this.default; + this.dirty = false; + } + get() { + return this.current; + } + set(value) { + // overridden in child classes; + } + getDefault() { + return this.default; // overriden in child classes + } + setDefault() { + this.set(this.default); + } +} +class ClearColor extends BaseValue { + getDefault() { + return performance.Color.transparent; + } + set(v) { + const c = this.current; + if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) + return; + this.gl.clearColor(v.r, v.g, v.b, v.a); + this.current = v; + this.dirty = false; + } +} +class ClearDepth extends BaseValue { + getDefault() { + return 1; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.clearDepth(v); + this.current = v; + this.dirty = false; + } +} +class ClearStencil extends BaseValue { + getDefault() { + return 0; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.clearStencil(v); + this.current = v; + this.dirty = false; + } +} +class ColorMask extends BaseValue { + getDefault() { + return [true, true, true, true]; + } + set(v) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) + return; + this.gl.colorMask(v[0], v[1], v[2], v[3]); + this.current = v; + this.dirty = false; + } +} +class DepthMask extends BaseValue { + getDefault() { + return true; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.depthMask(v); + this.current = v; + this.dirty = false; + } +} +class StencilMask extends BaseValue { + getDefault() { + return 0xFF; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.stencilMask(v); + this.current = v; + this.dirty = false; + } +} +class StencilFunc extends BaseValue { + getDefault() { + return { + func: this.gl.ALWAYS, + ref: 0, + mask: 0xFF + }; + } + set(v) { + const c = this.current; + if (v.func === c.func && v.ref === c.ref && v.mask === c.mask && !this.dirty) + return; + this.gl.stencilFunc(v.func, v.ref, v.mask); + this.current = v; + this.dirty = false; + } +} +class StencilOp extends BaseValue { + getDefault() { + const gl = this.gl; + return [gl.KEEP, gl.KEEP, gl.KEEP]; + } + set(v) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && !this.dirty) + return; + this.gl.stencilOp(v[0], v[1], v[2]); + this.current = v; + this.dirty = false; + } +} +class StencilTest extends BaseValue { + getDefault() { + return false; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + if (v) { + gl.enable(gl.STENCIL_TEST); + } + else { + gl.disable(gl.STENCIL_TEST); + } + this.current = v; + this.dirty = false; + } +} +class DepthRange extends BaseValue { + getDefault() { + return [0, 1]; + } + set(v) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && !this.dirty) + return; + this.gl.depthRange(v[0], v[1]); + this.current = v; + this.dirty = false; + } +} +class DepthTest extends BaseValue { + getDefault() { + return false; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + if (v) { + gl.enable(gl.DEPTH_TEST); + } + else { + gl.disable(gl.DEPTH_TEST); + } + this.current = v; + this.dirty = false; + } +} +class DepthFunc extends BaseValue { + getDefault() { + return this.gl.LESS; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.depthFunc(v); + this.current = v; + this.dirty = false; + } +} +class Blend extends BaseValue { + getDefault() { + return false; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + if (v) { + gl.enable(gl.BLEND); + } + else { + gl.disable(gl.BLEND); + } + this.current = v; + this.dirty = false; + } +} +class BlendFunc extends BaseValue { + getDefault() { + const gl = this.gl; + return [gl.ONE, gl.ZERO]; + } + set(v) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && !this.dirty) + return; + this.gl.blendFunc(v[0], v[1]); + this.current = v; + this.dirty = false; + } +} +class BlendColor extends BaseValue { + getDefault() { + return performance.Color.transparent; + } + set(v) { + const c = this.current; + if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) + return; + this.gl.blendColor(v.r, v.g, v.b, v.a); + this.current = v; + this.dirty = false; + } +} +class BlendEquation extends BaseValue { + getDefault() { + return this.gl.FUNC_ADD; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.blendEquation(v); + this.current = v; + this.dirty = false; + } +} +class CullFace extends BaseValue { + getDefault() { + return false; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + if (v) { + gl.enable(gl.CULL_FACE); + } + else { + gl.disable(gl.CULL_FACE); + } + this.current = v; + this.dirty = false; + } +} +class CullFaceSide extends BaseValue { + getDefault() { + return this.gl.BACK; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.cullFace(v); + this.current = v; + this.dirty = false; + } +} +class FrontFace extends BaseValue { + getDefault() { + return this.gl.CCW; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.frontFace(v); + this.current = v; + this.dirty = false; + } +} +class ProgramValue extends BaseValue { + getDefault() { + return null; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.useProgram(v); + this.current = v; + this.dirty = false; + } +} +class ActiveTextureUnit extends BaseValue { + getDefault() { + return this.gl.TEXTURE0; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.gl.activeTexture(v); + this.current = v; + this.dirty = false; + } +} +class Viewport extends BaseValue { + getDefault() { + const gl = this.gl; + return [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]; + } + set(v) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) + return; + this.gl.viewport(v[0], v[1], v[2], v[3]); + this.current = v; + this.dirty = false; + } +} +class BindFramebuffer extends BaseValue { + getDefault() { + return null; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.bindFramebuffer(gl.FRAMEBUFFER, v); + this.current = v; + this.dirty = false; + } +} +class BindRenderbuffer extends BaseValue { + getDefault() { + return null; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.bindRenderbuffer(gl.RENDERBUFFER, v); + this.current = v; + this.dirty = false; + } +} +class BindTexture extends BaseValue { + getDefault() { + return null; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.bindTexture(gl.TEXTURE_2D, v); + this.current = v; + this.dirty = false; + } +} +class BindVertexBuffer extends BaseValue { + getDefault() { + return null; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.bindBuffer(gl.ARRAY_BUFFER, v); + this.current = v; + this.dirty = false; + } +} +class BindElementBuffer extends BaseValue { + getDefault() { + return null; + } + set(v) { + // Always rebind + const gl = this.gl; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, v); + this.current = v; + this.dirty = false; + } +} +class BindVertexArray extends BaseValue { + getDefault() { + return null; + } + set(v) { + var _a; + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + if (isWebGL2(gl)) { + gl.bindVertexArray(v); + } + else { + (_a = gl.getExtension('OES_vertex_array_object')) === null || _a === void 0 ? void 0 : _a.bindVertexArrayOES(v); + } + this.current = v; + this.dirty = false; + } +} +class PixelStoreUnpack extends BaseValue { + getDefault() { + return 4; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.pixelStorei(gl.UNPACK_ALIGNMENT, v); + this.current = v; + this.dirty = false; + } +} +class PixelStoreUnpackPremultiplyAlpha extends BaseValue { + getDefault() { + return false; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, v); + this.current = v; + this.dirty = false; + } +} +class PixelStoreUnpackFlipY extends BaseValue { + getDefault() { + return false; + } + set(v) { + if (v === this.current && !this.dirty) + return; + const gl = this.gl; + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, v); + this.current = v; + this.dirty = false; + } +} +class FramebufferAttachment extends BaseValue { + constructor(context, parent) { + super(context); + this.context = context; + this.parent = parent; + } + getDefault() { + return null; + } +} +class ColorAttachment extends FramebufferAttachment { + setDirty() { + this.dirty = true; + } + set(v) { + if (v === this.current && !this.dirty) + return; + this.context.bindFramebuffer.set(this.parent); + // note: it's possible to attach a renderbuffer to the color + // attachment point, but thus far MBGL only uses textures for color + const gl = this.gl; + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, v, 0); + this.current = v; + this.dirty = false; + } +} +class DepthAttachment extends FramebufferAttachment { + set(v) { + if (v === this.current && !this.dirty) + return; + this.context.bindFramebuffer.set(this.parent); + // note: it's possible to attach a texture to the depth attachment + // point, but thus far MBGL only uses renderbuffers for depth + const gl = this.gl; + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, v); + this.current = v; + this.dirty = false; + } +} +class DepthStencilAttachment extends FramebufferAttachment { + set(v) { + if (v === this.current && !this.dirty) + return; + this.context.bindFramebuffer.set(this.parent); + // note: it's possible to attach a texture to the depth attachment + // point, but thus far MBGL only uses renderbuffers for depth + const gl = this.gl; + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, v); + this.current = v; + this.dirty = false; + } +} + +/** + * @internal + * A framebuffer holder object + */ +class Framebuffer { + constructor(context, width, height, hasDepth, hasStencil) { + this.context = context; + this.width = width; + this.height = height; + const gl = context.gl; + const fbo = this.framebuffer = gl.createFramebuffer(); + this.colorAttachment = new ColorAttachment(context, fbo); + if (hasDepth) { + this.depthAttachment = hasStencil ? new DepthStencilAttachment(context, fbo) : new DepthAttachment(context, fbo); + } + else if (hasStencil) { + throw new Error('Stencil cannot be setted without depth'); + } + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) { + throw new Error('Framebuffer is not complete'); + } + } + destroy() { + const gl = this.context.gl; + const texture = this.colorAttachment.get(); + if (texture) + gl.deleteTexture(texture); + if (this.depthAttachment) { + const renderbuffer = this.depthAttachment.get(); + if (renderbuffer) + gl.deleteRenderbuffer(renderbuffer); + } + gl.deleteFramebuffer(this.framebuffer); + } +} + +const ZERO = 0x0000; +const ONE = 0x0001; +const ONE_MINUS_SRC_ALPHA = 0x0303; +class ColorMode { + constructor(blendFunction, blendColor, mask) { + this.blendFunction = blendFunction; + this.blendColor = blendColor; + this.mask = mask; + } +} +ColorMode.Replace = [ONE, ZERO]; +ColorMode.disabled = new ColorMode(ColorMode.Replace, performance.Color.transparent, [false, false, false, false]); +ColorMode.unblended = new ColorMode(ColorMode.Replace, performance.Color.transparent, [true, true, true, true]); +ColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], performance.Color.transparent, [true, true, true, true]); + +/** + * @internal + * A webgl wrapper class to allow injection, mocking and abstaction + */ +class Context { + constructor(gl) { + var _a, _b; + this.gl = gl; + this.clearColor = new ClearColor(this); + this.clearDepth = new ClearDepth(this); + this.clearStencil = new ClearStencil(this); + this.colorMask = new ColorMask(this); + this.depthMask = new DepthMask(this); + this.stencilMask = new StencilMask(this); + this.stencilFunc = new StencilFunc(this); + this.stencilOp = new StencilOp(this); + this.stencilTest = new StencilTest(this); + this.depthRange = new DepthRange(this); + this.depthTest = new DepthTest(this); + this.depthFunc = new DepthFunc(this); + this.blend = new Blend(this); + this.blendFunc = new BlendFunc(this); + this.blendColor = new BlendColor(this); + this.blendEquation = new BlendEquation(this); + this.cullFace = new CullFace(this); + this.cullFaceSide = new CullFaceSide(this); + this.frontFace = new FrontFace(this); + this.program = new ProgramValue(this); + this.activeTexture = new ActiveTextureUnit(this); + this.viewport = new Viewport(this); + this.bindFramebuffer = new BindFramebuffer(this); + this.bindRenderbuffer = new BindRenderbuffer(this); + this.bindTexture = new BindTexture(this); + this.bindVertexBuffer = new BindVertexBuffer(this); + this.bindElementBuffer = new BindElementBuffer(this); + this.bindVertexArray = new BindVertexArray(this); + this.pixelStoreUnpack = new PixelStoreUnpack(this); + this.pixelStoreUnpackPremultiplyAlpha = new PixelStoreUnpackPremultiplyAlpha(this); + this.pixelStoreUnpackFlipY = new PixelStoreUnpackFlipY(this); + this.extTextureFilterAnisotropic = (gl.getExtension('EXT_texture_filter_anisotropic') || + gl.getExtension('MOZ_EXT_texture_filter_anisotropic') || + gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')); + if (this.extTextureFilterAnisotropic) { + this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT); + } + this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + if (isWebGL2(gl)) { + this.HALF_FLOAT = gl.HALF_FLOAT; + const extColorBufferHalfFloat = gl.getExtension('EXT_color_buffer_half_float'); + this.RGBA16F = (_a = gl.RGBA16F) !== null && _a !== void 0 ? _a : extColorBufferHalfFloat === null || extColorBufferHalfFloat === void 0 ? void 0 : extColorBufferHalfFloat.RGBA16F_EXT; + this.RGB16F = (_b = gl.RGB16F) !== null && _b !== void 0 ? _b : extColorBufferHalfFloat === null || extColorBufferHalfFloat === void 0 ? void 0 : extColorBufferHalfFloat.RGB16F_EXT; + gl.getExtension('EXT_color_buffer_float'); + } + else { + gl.getExtension('EXT_color_buffer_half_float'); + gl.getExtension('OES_texture_half_float_linear'); + const extTextureHalfFloat = gl.getExtension('OES_texture_half_float'); + this.HALF_FLOAT = extTextureHalfFloat === null || extTextureHalfFloat === void 0 ? void 0 : extTextureHalfFloat.HALF_FLOAT_OES; + } + } + setDefault() { + this.unbindVAO(); + this.clearColor.setDefault(); + this.clearDepth.setDefault(); + this.clearStencil.setDefault(); + this.colorMask.setDefault(); + this.depthMask.setDefault(); + this.stencilMask.setDefault(); + this.stencilFunc.setDefault(); + this.stencilOp.setDefault(); + this.stencilTest.setDefault(); + this.depthRange.setDefault(); + this.depthTest.setDefault(); + this.depthFunc.setDefault(); + this.blend.setDefault(); + this.blendFunc.setDefault(); + this.blendColor.setDefault(); + this.blendEquation.setDefault(); + this.cullFace.setDefault(); + this.cullFaceSide.setDefault(); + this.frontFace.setDefault(); + this.program.setDefault(); + this.activeTexture.setDefault(); + this.bindFramebuffer.setDefault(); + this.pixelStoreUnpack.setDefault(); + this.pixelStoreUnpackPremultiplyAlpha.setDefault(); + this.pixelStoreUnpackFlipY.setDefault(); + } + setDirty() { + this.clearColor.dirty = true; + this.clearDepth.dirty = true; + this.clearStencil.dirty = true; + this.colorMask.dirty = true; + this.depthMask.dirty = true; + this.stencilMask.dirty = true; + this.stencilFunc.dirty = true; + this.stencilOp.dirty = true; + this.stencilTest.dirty = true; + this.depthRange.dirty = true; + this.depthTest.dirty = true; + this.depthFunc.dirty = true; + this.blend.dirty = true; + this.blendFunc.dirty = true; + this.blendColor.dirty = true; + this.blendEquation.dirty = true; + this.cullFace.dirty = true; + this.cullFaceSide.dirty = true; + this.frontFace.dirty = true; + this.program.dirty = true; + this.activeTexture.dirty = true; + this.viewport.dirty = true; + this.bindFramebuffer.dirty = true; + this.bindRenderbuffer.dirty = true; + this.bindTexture.dirty = true; + this.bindVertexBuffer.dirty = true; + this.bindElementBuffer.dirty = true; + this.bindVertexArray.dirty = true; + this.pixelStoreUnpack.dirty = true; + this.pixelStoreUnpackPremultiplyAlpha.dirty = true; + this.pixelStoreUnpackFlipY.dirty = true; + } + createIndexBuffer(array, dynamicDraw) { + return new IndexBuffer(this, array, dynamicDraw); + } + createVertexBuffer(array, attributes, dynamicDraw) { + return new VertexBuffer(this, array, attributes, dynamicDraw); + } + createRenderbuffer(storageFormat, width, height) { + const gl = this.gl; + const rbo = gl.createRenderbuffer(); + this.bindRenderbuffer.set(rbo); + gl.renderbufferStorage(gl.RENDERBUFFER, storageFormat, width, height); + this.bindRenderbuffer.set(null); + return rbo; + } + createFramebuffer(width, height, hasDepth, hasStencil) { + return new Framebuffer(this, width, height, hasDepth, hasStencil); + } + clear({ color, depth, stencil }) { + const gl = this.gl; + let mask = 0; + if (color) { + mask |= gl.COLOR_BUFFER_BIT; + this.clearColor.set(color); + this.colorMask.set([true, true, true, true]); + } + if (typeof depth !== 'undefined') { + mask |= gl.DEPTH_BUFFER_BIT; + // Workaround for platforms where clearDepth doesn't seem to work + // without resetting the depthRange. See https://github.com/mapbox/mapbox-gl-js/issues/3437 + this.depthRange.set([0, 1]); + this.clearDepth.set(depth); + this.depthMask.set(true); + } + if (typeof stencil !== 'undefined') { + mask |= gl.STENCIL_BUFFER_BIT; + this.clearStencil.set(stencil); + this.stencilMask.set(0xFF); + } + gl.clear(mask); + } + setCullFace(cullFaceMode) { + if (cullFaceMode.enable === false) { + this.cullFace.set(false); + } + else { + this.cullFace.set(true); + this.cullFaceSide.set(cullFaceMode.mode); + this.frontFace.set(cullFaceMode.frontFace); + } + } + setDepthMode(depthMode) { + if (depthMode.func === this.gl.ALWAYS && !depthMode.mask) { + this.depthTest.set(false); + } + else { + this.depthTest.set(true); + this.depthFunc.set(depthMode.func); + this.depthMask.set(depthMode.mask); + this.depthRange.set(depthMode.range); + } + } + setStencilMode(stencilMode) { + if (stencilMode.test.func === this.gl.ALWAYS && !stencilMode.mask) { + this.stencilTest.set(false); + } + else { + this.stencilTest.set(true); + this.stencilMask.set(stencilMode.mask); + this.stencilOp.set([stencilMode.fail, stencilMode.depthFail, stencilMode.pass]); + this.stencilFunc.set({ + func: stencilMode.test.func, + ref: stencilMode.ref, + mask: stencilMode.test.mask + }); + } + } + setColorMode(colorMode) { + if (performance.deepEqual(colorMode.blendFunction, ColorMode.Replace)) { + this.blend.set(false); + } + else { + this.blend.set(true); + this.blendFunc.set(colorMode.blendFunction); + this.blendColor.set(colorMode.blendColor); + } + this.colorMask.set(colorMode.mask); + } + createVertexArray() { + var _a; + if (isWebGL2(this.gl)) + return this.gl.createVertexArray(); + return (_a = this.gl.getExtension('OES_vertex_array_object')) === null || _a === void 0 ? void 0 : _a.createVertexArrayOES(); + } + deleteVertexArray(x) { + var _a; + if (isWebGL2(this.gl)) + return this.gl.deleteVertexArray(x); + return (_a = this.gl.getExtension('OES_vertex_array_object')) === null || _a === void 0 ? void 0 : _a.deleteVertexArrayOES(x); + } + unbindVAO() { + // Unbinding the VAO prevents other things (custom layers, new buffer creation) from + // unintentionally changing the state of the last VAO used. + this.bindVertexArray.set(null); + } +} + +const ALWAYS$1 = 0x0207; +class DepthMode { + constructor(depthFunc, depthMask, depthRange) { + this.func = depthFunc; + this.mask = depthMask; + this.range = depthRange; + } +} +DepthMode.ReadOnly = false; +DepthMode.ReadWrite = true; +DepthMode.disabled = new DepthMode(ALWAYS$1, DepthMode.ReadOnly, [0, 1]); + +const ALWAYS = 0x0207; +const KEEP = 0x1E00; +class StencilMode { + constructor(test, ref, mask, fail, depthFail, pass) { + this.test = test; + this.ref = ref; + this.mask = mask; + this.fail = fail; + this.depthFail = depthFail; + this.pass = pass; + } +} +StencilMode.disabled = new StencilMode({ func: ALWAYS, mask: 0 }, 0, 0, KEEP, KEEP, KEEP); + +const BACK = 0x0405; +const CCW = 0x0901; +class CullFaceMode { + constructor(enable, mode, frontFace) { + this.enable = enable; + this.mode = mode; + this.frontFace = frontFace; + } +} +CullFaceMode.disabled = new CullFaceMode(false, BACK, CCW); +CullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW); + +let quadTriangles; +function drawCollisionDebug(painter, sourceCache, layer, coords, translate, translateAnchor, isText) { + const context = painter.context; + const gl = context.gl; + const program = painter.useProgram('collisionBox'); + const tileBatches = []; + let circleCount = 0; + let circleOffset = 0; + for (let i = 0; i < coords.length; i++) { + const coord = coords[i]; + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + let posMatrix = coord.posMatrix; + if (translate[0] !== 0 || translate[1] !== 0) { + posMatrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor); + } + const buffers = isText ? bucket.textCollisionBox : bucket.iconCollisionBox; + // Get collision circle data of this bucket + const circleArray = bucket.collisionCircleArray; + if (circleArray.length > 0) { + // We need to know the projection matrix that was used for projecting collision circles to the screen. + // This might vary between buckets as the symbol placement is a continuous process. This matrix is + // required for transforming points from previous screen space to the current one + const invTransform = performance.create(); + const transform = posMatrix; + performance.mul(invTransform, bucket.placementInvProjMatrix, painter.transform.glCoordMatrix); + performance.mul(invTransform, invTransform, bucket.placementViewportMatrix); + tileBatches.push({ + circleArray, + circleOffset, + transform, + invTransform, + coord + }); + circleCount += circleArray.length / 4; // 4 values per circle + circleOffset = circleCount; + } + if (!buffers) + continue; + program.draw(context, gl.LINES, DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled, collisionUniformValues(posMatrix, painter.transform, tile), painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord), layer.id, buffers.layoutVertexBuffer, buffers.indexBuffer, buffers.segments, null, painter.transform.zoom, null, null, buffers.collisionVertexBuffer); + } + if (!isText || !tileBatches.length) { + return; + } + // Render collision circles + const circleProgram = painter.useProgram('collisionCircle'); + // Construct vertex data + const vertexData = new performance.CollisionCircleLayoutArray(); + vertexData.resize(circleCount * 4); + vertexData._trim(); + let vertexOffset = 0; + for (const batch of tileBatches) { + for (let i = 0; i < batch.circleArray.length / 4; i++) { + const circleIdx = i * 4; + const x = batch.circleArray[circleIdx + 0]; + const y = batch.circleArray[circleIdx + 1]; + const radius = batch.circleArray[circleIdx + 2]; + const collision = batch.circleArray[circleIdx + 3]; + // 4 floats per vertex, 4 vertices per quad + vertexData.emplace(vertexOffset++, x, y, radius, collision, 0); + vertexData.emplace(vertexOffset++, x, y, radius, collision, 1); + vertexData.emplace(vertexOffset++, x, y, radius, collision, 2); + vertexData.emplace(vertexOffset++, x, y, radius, collision, 3); + } + } + if (!quadTriangles || quadTriangles.length < circleCount * 2) { + quadTriangles = createQuadTriangles(circleCount); + } + const indexBuffer = context.createIndexBuffer(quadTriangles, true); + const vertexBuffer = context.createVertexBuffer(vertexData, performance.collisionCircleLayout.members, true); + // Render batches + for (const batch of tileBatches) { + const uniforms = collisionCircleUniformValues(batch.transform, batch.invTransform, painter.transform); + circleProgram.draw(context, gl.TRIANGLES, DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled, uniforms, painter.style.map.terrain && painter.style.map.terrain.getTerrainData(batch.coord), layer.id, vertexBuffer, indexBuffer, performance.SegmentVector.simpleSegment(0, batch.circleOffset * 2, batch.circleArray.length, batch.circleArray.length / 2), null, painter.transform.zoom, null, null, null); + } + vertexBuffer.destroy(); + indexBuffer.destroy(); +} +function createQuadTriangles(quadCount) { + const triCount = quadCount * 2; + const array = new performance.QuadTriangleArray(); + array.resize(triCount); + array._trim(); + // Two triangles and 4 vertices per quad. + for (let i = 0; i < triCount; i++) { + const idx = i * 6; + array.uint16[idx + 0] = i * 4 + 0; + array.uint16[idx + 1] = i * 4 + 1; + array.uint16[idx + 2] = i * 4 + 2; + array.uint16[idx + 3] = i * 4 + 2; + array.uint16[idx + 4] = i * 4 + 3; + array.uint16[idx + 5] = i * 4 + 0; + } + return array; +} + +const identityMat4 = performance.identity(new Float32Array(16)); +function drawSymbols(painter, sourceCache, layer, coords, variableOffsets) { + if (painter.renderPass !== 'translucent') + return; + // Disable the stencil test so that labels aren't clipped to tile boundaries. + const stencilMode = StencilMode.disabled; + const colorMode = painter.colorModeForRenderPass(); + const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset'); + //Compute variable-offsets before painting since icons and text data positioning + //depend on each other in this case. + if (hasVariablePlacement) { + updateVariableAnchors(coords, painter, layer, sourceCache, layer.layout.get('text-rotation-alignment'), layer.layout.get('text-pitch-alignment'), variableOffsets); + } + if (layer.paint.get('icon-opacity').constantOr(1) !== 0) { + drawLayerSymbols(painter, sourceCache, layer, coords, false, layer.paint.get('icon-translate'), layer.paint.get('icon-translate-anchor'), layer.layout.get('icon-rotation-alignment'), layer.layout.get('icon-pitch-alignment'), layer.layout.get('icon-keep-upright'), stencilMode, colorMode); + } + if (layer.paint.get('text-opacity').constantOr(1) !== 0) { + drawLayerSymbols(painter, sourceCache, layer, coords, true, layer.paint.get('text-translate'), layer.paint.get('text-translate-anchor'), layer.layout.get('text-rotation-alignment'), layer.layout.get('text-pitch-alignment'), layer.layout.get('text-keep-upright'), stencilMode, colorMode); + } + if (sourceCache.map.showCollisionBoxes) { + drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'), layer.paint.get('text-translate-anchor'), true); + drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'), layer.paint.get('icon-translate-anchor'), false); + } +} +function calculateVariableRenderShift(anchor, width, height, textOffset, textBoxScale, renderTextSize) { + const { horizontalAlign, verticalAlign } = performance.getAnchorAlignment(anchor); + const shiftX = -(horizontalAlign - 0.5) * width; + const shiftY = -(verticalAlign - 0.5) * height; + return new performance.Point((shiftX / textBoxScale + textOffset[0]) * renderTextSize, (shiftY / textBoxScale + textOffset[1]) * renderTextSize); +} +function updateVariableAnchors(coords, painter, layer, sourceCache, rotationAlignment, pitchAlignment, variableOffsets) { + const tr = painter.transform; + const rotateWithMap = rotationAlignment === 'map'; + const pitchWithMap = pitchAlignment === 'map'; + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer); + if (!bucket || !bucket.text || !bucket.text.segments.get().length) + continue; + const sizeData = bucket.textSizeData; + const size = performance.evaluateSizeForZoom(sizeData, tr.zoom); + const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom); + const labelPlaneMatrix = getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale); + const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData(); + if (size) { + const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ); + const getElevation = painter.style.map.terrain ? (x, y) => painter.style.map.terrain.getElevation(coord, x, y) : null; + updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon, getElevation); + } + } +} +function updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, transform, labelPlaneMatrix, posMatrix, tileScale, size, updateTextFitIcon, getElevation) { + const placedSymbols = bucket.text.placedSymbolArray; + const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray; + const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray; + const placedTextShifts = {}; + dynamicTextLayoutVertexArray.clear(); + for (let s = 0; s < placedSymbols.length; s++) { + const symbol = placedSymbols.get(s); + const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation; + const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null; + if (!variableOffset) { + // These symbols are from a justification that is not being used, or a label that wasn't placed + // so we don't need to do the extra math to figure out what incremental shift to apply. + hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray); + } + else { + const tileAnchor = new performance.Point(symbol.anchorX, symbol.anchorY); + const projectedAnchor = project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix, getElevation); + const perspectiveRatio = getPerspectiveRatio(transform.cameraToCenterDistance, projectedAnchor.signedDistanceFromCamera); + let renderTextSize = performance.evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / performance.ONE_EM; + if (pitchWithMap) { + // Go from size in pixels to equivalent size in tile units + renderTextSize *= bucket.tilePixelRatio / tileScale; + } + const { width, height, anchor, textOffset, textBoxScale } = variableOffset; + const shift = calculateVariableRenderShift(anchor, width, height, textOffset, textBoxScale, renderTextSize); + // Usual case is that we take the projected anchor and add the pixel-based shift + // calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent + // tile-unit based shift to the anchor before projecting to the label plane. + const shiftedAnchor = pitchWithMap ? + project(tileAnchor.add(shift), labelPlaneMatrix, getElevation).point : + projectedAnchor.point.add(rotateWithMap ? + shift.rotate(-transform.angle) : + shift); + const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === performance.WritingMode.vertical) ? Math.PI / 2 : 0; + for (let g = 0; g < symbol.numGlyphs; g++) { + performance.addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle); + } + //Only offset horizontal text icons + if (updateTextFitIcon && symbol.associatedIconIndex >= 0) { + placedTextShifts[symbol.associatedIconIndex] = { shiftedAnchor, angle }; + } + } + } + if (updateTextFitIcon) { + dynamicIconLayoutVertexArray.clear(); + const placedIcons = bucket.icon.placedSymbolArray; + for (let i = 0; i < placedIcons.length; i++) { + const placedIcon = placedIcons.get(i); + if (placedIcon.hidden) { + hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray); + } + else { + const shift = placedTextShifts[i]; + if (!shift) { + hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray); + } + else { + for (let g = 0; g < placedIcon.numGlyphs; g++) { + performance.addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle); + } + } + } + } + bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray); + } + bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray); +} +function getSymbolProgramName(isSDF, isText, bucket) { + if (bucket.iconsInText && isText) { + return 'symbolTextAndIcon'; + } + else if (isSDF) { + return 'symbolSDF'; + } + else { + return 'symbolIcon'; + } +} +function drawLayerSymbols(painter, sourceCache, layer, coords, isText, translate, translateAnchor, rotationAlignment, pitchAlignment, keepUpright, stencilMode, colorMode) { + const context = painter.context; + const gl = context.gl; + const tr = painter.transform; + const rotateWithMap = rotationAlignment === 'map'; + const pitchWithMap = pitchAlignment === 'map'; + const alongLine = rotationAlignment !== 'viewport' && layer.layout.get('symbol-placement') !== 'point'; + // Line label rotation happens in `updateLineLabels` + // Pitched point labels are automatically rotated by the labelPlaneMatrix projection + // Unpitched point labels need to have their rotation applied after projection + const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine; + const hasSortKey = !layer.layout.get('symbol-sort-key').isConstant(); + let sortFeaturesByKey = false; + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset'); + const tileRenderState = []; + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + const buffers = isText ? bucket.text : bucket.icon; + if (!buffers || !buffers.segments.get().length || !buffers.hasVisibleVertices) + continue; + const programConfiguration = buffers.programConfigurations.get(layer.id); + const isSDF = isText || bucket.sdfIcons; + const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData; + const transformed = pitchWithMap || tr.pitch !== 0; + const program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration); + const size = performance.evaluateSizeForZoom(sizeData, tr.zoom); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + let texSize; + let texSizeIcon = [0, 0]; + let atlasTexture; + let atlasInterpolation; + let atlasTextureIcon = null; + let atlasInterpolationIcon; + if (isText) { + atlasTexture = tile.glyphAtlasTexture; + atlasInterpolation = gl.LINEAR; + texSize = tile.glyphAtlasTexture.size; + if (bucket.iconsInText) { + texSizeIcon = tile.imageAtlasTexture.size; + atlasTextureIcon = tile.imageAtlasTexture; + const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera'; + atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST; + } + } + else { + const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear; + atlasTexture = tile.imageAtlasTexture; + atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ? + gl.LINEAR : + gl.NEAREST; + texSize = tile.imageAtlasTexture.size; + } + const s = pixelsToTileUnits(tile, 1, painter.transform.zoom); + const labelPlaneMatrix = getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s); + const glCoordMatrix = getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s); + const hasVariableAnchors = hasVariablePlacement && bucket.hasTextData(); + const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && + hasVariableAnchors && + bucket.hasIconData(); + if (alongLine) { + const getElevation = painter.style.map.terrain ? (x, y) => painter.style.map.terrain.getElevation(coord, x, y) : null; + const rotateToLine = layer.layout.get('text-rotation-alignment') === 'map'; + updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright, rotateToLine, getElevation); + } + const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor), uLabelPlaneMatrix = (alongLine || (isText && hasVariablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix, uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true); + const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0; + let uniformValues; + if (isSDF) { + if (!bucket.iconsInText) { + uniformValues = symbolSDFUniformValues(sizeData.kind, size, rotateInShader, pitchWithMap, painter, matrix, uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true); + } + else { + uniformValues = symbolTextAndIconUniformValues(sizeData.kind, size, rotateInShader, pitchWithMap, painter, matrix, uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon); + } + } + else { + uniformValues = symbolIconUniformValues(sizeData.kind, size, rotateInShader, pitchWithMap, painter, matrix, uLabelPlaneMatrix, uglCoordMatrix, isText, texSize); + } + const state = { + program, + buffers, + uniformValues, + atlasTexture, + atlasTextureIcon, + atlasInterpolation, + atlasInterpolationIcon, + isSDF, + hasHalo + }; + if (hasSortKey && bucket.canOverlap) { + sortFeaturesByKey = true; + const oldSegments = buffers.segments.get(); + for (const segment of oldSegments) { + tileRenderState.push({ + segments: new performance.SegmentVector([segment]), + sortKey: segment.sortKey, + state, + terrainData + }); + } + } + else { + tileRenderState.push({ + segments: buffers.segments, + sortKey: 0, + state, + terrainData + }); + } + } + if (sortFeaturesByKey) { + tileRenderState.sort((a, b) => a.sortKey - b.sortKey); + } + for (const segmentState of tileRenderState) { + const state = segmentState.state; + context.activeTexture.set(gl.TEXTURE0); + // @ts-ignore + state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE); + if (state.atlasTextureIcon) { + context.activeTexture.set(gl.TEXTURE1); + if (state.atlasTextureIcon) { + // @ts-ignore + state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE); + } + } + if (state.isSDF) { + const uniformValues = state.uniformValues; + if (state.hasHalo) { + uniformValues['u_is_halo'] = 1; + drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues, segmentState.terrainData); + } + uniformValues['u_is_halo'] = 0; + } + drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues, segmentState.terrainData); + } +} +function drawSymbolElements(buffers, segments, layer, painter, program, depthMode, stencilMode, colorMode, uniformValues, terrainData) { + const context = painter.context; + const gl = context.gl; + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, buffers.layoutVertexBuffer, buffers.indexBuffer, segments, layer.paint, painter.transform.zoom, buffers.programConfigurations.get(layer.id), buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer); +} + +function drawCircles(painter, sourceCache, layer, coords) { + if (painter.renderPass !== 'translucent') + return; + const opacity = layer.paint.get('circle-opacity'); + const strokeWidth = layer.paint.get('circle-stroke-width'); + const strokeOpacity = layer.paint.get('circle-stroke-opacity'); + const sortFeaturesByKey = !layer.layout.get('circle-sort-key').isConstant(); + if (opacity.constantOr(1) === 0 && (strokeWidth.constantOr(1) === 0 || strokeOpacity.constantOr(1) === 0)) { + return; + } + const context = painter.context; + const gl = context.gl; + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + // Turn off stencil testing to allow circles to be drawn across boundaries, + // so that large circles are not clipped to tiles + const stencilMode = StencilMode.disabled; + const colorMode = painter.colorModeForRenderPass(); + const segmentsRenderStates = []; + for (let i = 0; i < coords.length; i++) { + const coord = coords[i]; + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram('circle', programConfiguration); + const layoutVertexBuffer = bucket.layoutVertexBuffer; + const indexBuffer = bucket.indexBuffer; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const uniformValues = circleUniformValues(painter, coord, tile, layer); + const state = { + programConfiguration, + program, + layoutVertexBuffer, + indexBuffer, + uniformValues, + terrainData + }; + if (sortFeaturesByKey) { + const oldSegments = bucket.segments.get(); + for (const segment of oldSegments) { + segmentsRenderStates.push({ + segments: new performance.SegmentVector([segment]), + sortKey: segment.sortKey, + state + }); + } + } + else { + segmentsRenderStates.push({ + segments: bucket.segments, + sortKey: 0, + state + }); + } + } + if (sortFeaturesByKey) { + segmentsRenderStates.sort((a, b) => a.sortKey - b.sortKey); + } + for (const segmentsState of segmentsRenderStates) { + const { programConfiguration, program, layoutVertexBuffer, indexBuffer, uniformValues, terrainData } = segmentsState.state; + const segments = segmentsState.segments; + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, layoutVertexBuffer, indexBuffer, segments, layer.paint, painter.transform.zoom, programConfiguration); + } +} + +function drawHeatmap(painter, sourceCache, layer, coords) { + if (layer.paint.get('heatmap-opacity') === 0) { + return; + } + if (painter.renderPass === 'offscreen') { + const context = painter.context; + const gl = context.gl; + // Allow kernels to be drawn across boundaries, so that + // large kernels are not clipped to tiles + const stencilMode = StencilMode.disabled; + // Turn on additive blending for kernels, which is a key aspect of kernel density estimation formula + const colorMode = new ColorMode([gl.ONE, gl.ONE], performance.Color.transparent, [true, true, true, true]); + bindFramebuffer(context, painter, layer); + context.clear({ color: performance.Color.transparent }); + for (let i = 0; i < coords.length; i++) { + const coord = coords[i]; + // Skip tiles that have uncovered parents to avoid flickering; we don't need + // to use complex tile masking here because the change between zoom levels is subtle, + // so it's fine to simply render the parent until all its 4 children are loaded + if (sourceCache.hasRenderableParent(coord)) + continue; + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram('heatmap', programConfiguration); + const { zoom } = painter.transform; + program.draw(context, gl.TRIANGLES, DepthMode.disabled, stencilMode, colorMode, CullFaceMode.disabled, heatmapUniformValues(coord.posMatrix, tile, zoom, layer.paint.get('heatmap-intensity')), null, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments, layer.paint, painter.transform.zoom, programConfiguration); + } + context.viewport.set([0, 0, painter.width, painter.height]); + } + else if (painter.renderPass === 'translucent') { + painter.context.setColorMode(painter.colorModeForRenderPass()); + renderTextureToMap(painter, layer); + } +} +function bindFramebuffer(context, painter, layer) { + const gl = context.gl; + context.activeTexture.set(gl.TEXTURE1); + // Use a 4x downscaled screen texture for better performance + context.viewport.set([0, 0, painter.width / 4, painter.height / 4]); + let fbo = layer.heatmapFbo; + if (!fbo) { + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + fbo = layer.heatmapFbo = context.createFramebuffer(painter.width / 4, painter.height / 4, false, false); + bindTextureToFramebuffer(context, painter, texture, fbo); + } + else { + gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get()); + context.bindFramebuffer.set(fbo.framebuffer); + } +} +function bindTextureToFramebuffer(context, painter, texture, fbo) { + var _a, _b; + const gl = context.gl; + // Use the higher precision half-float texture where available (producing much smoother looking heatmaps); + // Otherwise, fall back to a low precision texture + const numType = (_a = context.HALF_FLOAT) !== null && _a !== void 0 ? _a : gl.UNSIGNED_BYTE; + const internalFormat = (_b = context.RGBA16F) !== null && _b !== void 0 ? _b : gl.RGBA; + gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, painter.width / 4, painter.height / 4, 0, gl.RGBA, numType, null); + fbo.colorAttachment.set(texture); +} +function renderTextureToMap(painter, layer) { + const context = painter.context; + const gl = context.gl; + // Here we bind two different textures from which we'll sample in drawing + // heatmaps: the kernel texture, prepared in the offscreen pass, and a + // color ramp texture. + const fbo = layer.heatmapFbo; + if (!fbo) + return; + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get()); + context.activeTexture.set(gl.TEXTURE1); + let colorRampTexture = layer.colorRampTexture; + if (!colorRampTexture) { + colorRampTexture = layer.colorRampTexture = new Texture(context, layer.colorRamp, gl.RGBA); + } + colorRampTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + painter.useProgram('heatmapTexture').draw(context, gl.TRIANGLES, DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled, heatmapTextureUniformValues(painter, layer, 0, 1), null, layer.id, painter.viewportBuffer, painter.quadTriangleIndexBuffer, painter.viewportSegments, layer.paint, painter.transform.zoom); +} + +function drawLine(painter, sourceCache, layer, coords) { + if (painter.renderPass !== 'translucent') + return; + const opacity = layer.paint.get('line-opacity'); + const width = layer.paint.get('line-width'); + if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) + return; + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + const colorMode = painter.colorModeForRenderPass(); + const dasharray = layer.paint.get('line-dasharray'); + const patternProperty = layer.paint.get('line-pattern'); + const image = patternProperty.constantOr(1); + const gradient = layer.paint.get('line-gradient'); + const crossfade = layer.getCrossfadeParameters(); + const programId = image ? 'linePattern' : + dasharray ? 'lineSDF' : + gradient ? 'lineGradient' : 'line'; + const context = painter.context; + const gl = context.gl; + let firstTile = true; + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + if (image && !tile.patternsLoaded()) + continue; + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + const programConfiguration = bucket.programConfigurations.get(layer.id); + const prevProgram = painter.context.program.get(); + const program = painter.useProgram(programId, programConfiguration); + const programChanged = firstTile || program.program !== prevProgram; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const constantPattern = patternProperty.constantOr(null); + if (constantPattern && tile.imageAtlas) { + const atlas = tile.imageAtlas; + const posTo = atlas.patternPositions[constantPattern.to.toString()]; + const posFrom = atlas.patternPositions[constantPattern.from.toString()]; + if (posTo && posFrom) + programConfiguration.setConstantPatternPositions(posTo, posFrom); + } + const terrainCoord = terrainData ? coord : null; + const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade, terrainCoord) : + dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade, terrainCoord) : + gradient ? lineGradientUniformValues(painter, tile, layer, bucket.lineClipsArray.length, terrainCoord) : + lineUniformValues(painter, tile, layer, terrainCoord); + if (image) { + context.activeTexture.set(gl.TEXTURE0); + tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + programConfiguration.updatePaintBuffers(crossfade); + } + else if (dasharray && (programChanged || painter.lineAtlas.dirty)) { + context.activeTexture.set(gl.TEXTURE0); + painter.lineAtlas.bind(context); + } + else if (gradient) { + const layerGradient = bucket.gradients[layer.id]; + let gradientTexture = layerGradient.texture; + if (layer.gradientVersion !== layerGradient.version) { + let textureResolution = 256; + if (layer.stepInterpolant) { + const sourceMaxZoom = sourceCache.getSource().maxzoom; + const potentialOverzoom = coord.canonical.z === sourceMaxZoom ? + Math.ceil(1 << (painter.transform.maxZoom - coord.canonical.z)) : 1; + const lineLength = bucket.maxLineLength / performance.EXTENT; + // Logical pixel tile size is 512px, and 1024px right before current zoom + 1 + const maxTilePixelSize = 1024; + // Maximum possible texture coverage heuristic, bound by hardware max texture size + const maxTextureCoverage = lineLength * maxTilePixelSize * potentialOverzoom; + textureResolution = performance.clamp(performance.nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize); + } + layerGradient.gradient = performance.renderColorRamp({ + expression: layer.gradientExpression(), + evaluationKey: 'lineProgress', + resolution: textureResolution, + image: layerGradient.gradient || undefined, + clips: bucket.lineClipsArray + }); + if (layerGradient.texture) { + layerGradient.texture.update(layerGradient.gradient); + } + else { + layerGradient.texture = new Texture(context, layerGradient.gradient, gl.RGBA); + } + layerGradient.version = layer.gradientVersion; + gradientTexture = layerGradient.texture; + } + context.activeTexture.set(gl.TEXTURE0); + gradientTexture.bind(layer.stepInterpolant ? gl.NEAREST : gl.LINEAR, gl.CLAMP_TO_EDGE); + } + program.draw(context, gl.TRIANGLES, depthMode, painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments, layer.paint, painter.transform.zoom, programConfiguration, bucket.layoutVertexBuffer2); + firstTile = false; + // once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic + } +} + +/** + * A simple helper shared by draw_fill and draw_fill_extrusions to find the correct pattern positions AND update program. + * For transtionable properties, especially 'fill-pattern' and 'fill-extrusion-pattern', while rendering certain frames + * tile.imageAtlas has been updated by worker to hold the new pattern only, but rendering code is still looking for the previous image. + * The mismatch was causing setConstantPatternPositions method not being called and pixelRatio was always the + * default of 1, instead of actual values set by original map.addImage. + * + * @param programConfiguration - to be used to set pattern position and device pixel ratio. + * @param propertyName - 'fill-pattern' or 'fill-extrusion-pattern' property key + * @param constantPattern - either 'fill-pattern' or 'fill-extrusion-pattern' property value + * @param tile - current tile being drawn + * @param layer - current layer being rendered + */ +function updatePatternPositionsInProgram(programConfiguration, propertyName, constantPattern, tile, layer) { + if (!constantPattern || !tile || !tile.imageAtlas) { + return; + } + const patternPositions = tile.imageAtlas.patternPositions; + let posTo = patternPositions[constantPattern.to.toString()]; + let posFrom = patternPositions[constantPattern.from.toString()]; + // https://github.com/maplibre/maplibre-gl-js/issues/3377 + if (!posTo && posFrom) + posTo = posFrom; + if (!posFrom && posTo) + posFrom = posTo; + // try again in case patternPositions has been updated by worker + if (!posTo || !posFrom) { + const transitioned = layer.getPaintProperty(propertyName); + posTo = patternPositions[transitioned]; + posFrom = patternPositions[transitioned]; + } + if (posTo && posFrom) { + programConfiguration.setConstantPatternPositions(posTo, posFrom); + } +} + +function drawFill(painter, sourceCache, layer, coords) { + const color = layer.paint.get('fill-color'); + const opacity = layer.paint.get('fill-opacity'); + if (opacity.constantOr(1) === 0) { + return; + } + const colorMode = painter.colorModeForRenderPass(); + const pattern = layer.paint.get('fill-pattern'); + const pass = painter.opaquePassEnabledForLayer() && + (!pattern.constantOr(1) && + color.constantOr(performance.Color.transparent).a === 1 && + opacity.constantOr(0) === 1) ? 'opaque' : 'translucent'; + // Draw fill + if (painter.renderPass === pass) { + const depthMode = painter.depthModeForSublayer(1, painter.renderPass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly); + drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, false); + } + // Draw stroke + if (painter.renderPass === 'translucent' && layer.paint.get('fill-antialias')) { + // If we defined a different color for the fill outline, we are + // going to ignore the bits in 0x07 and just care about the global + // clipping mask. + // Otherwise, we only want to drawFill the antialiased parts that are + // *outside* the current shape. This is important in case the fill + // or stroke color is translucent. If we wouldn't clip to outside + // the current shape, some pixels from the outline stroke overlapped + // the (non-antialiased) fill. + const depthMode = painter.depthModeForSublayer(layer.getPaintProperty('fill-outline-color') ? 2 : 0, DepthMode.ReadOnly); + drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, true); + } +} +function drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, isOutline) { + const gl = painter.context.gl; + const fillPropertyName = 'fill-pattern'; + const patternProperty = layer.paint.get(fillPropertyName); + const image = patternProperty && patternProperty.constantOr(1); + const crossfade = layer.getCrossfadeParameters(); + let drawMode, programName, uniformValues, indexBuffer, segments; + if (!isOutline) { + programName = image ? 'fillPattern' : 'fill'; + drawMode = gl.TRIANGLES; + } + else { + programName = image && !layer.getPaintProperty('fill-outline-color') ? 'fillOutlinePattern' : 'fillOutline'; + drawMode = gl.LINES; + } + const constantPattern = patternProperty.constantOr(null); + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + if (image && !tile.patternsLoaded()) + continue; + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram(programName, programConfiguration); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + if (image) { + painter.context.activeTexture.set(gl.TEXTURE0); + tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + programConfiguration.updatePaintBuffers(crossfade); + } + updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer); + const terrainCoord = terrainData ? coord : null; + const posMatrix = terrainCoord ? terrainCoord.posMatrix : coord.posMatrix; + const tileMatrix = painter.translatePosMatrix(posMatrix, tile, layer.paint.get('fill-translate'), layer.paint.get('fill-translate-anchor')); + if (!isOutline) { + indexBuffer = bucket.indexBuffer; + segments = bucket.segments; + uniformValues = image ? + fillPatternUniformValues(tileMatrix, painter, crossfade, tile) : + fillUniformValues(tileMatrix); + } + else { + indexBuffer = bucket.indexBuffer2; + segments = bucket.segments2; + const drawingBufferSize = [gl.drawingBufferWidth, gl.drawingBufferHeight]; + uniformValues = (programName === 'fillOutlinePattern' && image) ? + fillOutlinePatternUniformValues(tileMatrix, painter, crossfade, tile, drawingBufferSize) : + fillOutlineUniformValues(tileMatrix, drawingBufferSize); + } + program.draw(painter.context, drawMode, depthMode, painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, indexBuffer, segments, layer.paint, painter.transform.zoom, programConfiguration); + } +} + +function drawFillExtrusion(painter, source, layer, coords) { + const opacity = layer.paint.get('fill-extrusion-opacity'); + if (opacity === 0) { + return; + } + if (painter.renderPass === 'translucent') { + const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D); + if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1)) { + const colorMode = painter.colorModeForRenderPass(); + drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode); + } + else { + // Draw transparent buildings in two passes so that only the closest surface is drawn. + // First draw all the extrusions into only the depth buffer. No colors are drawn. + drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, ColorMode.disabled); + // Then draw all the extrusions a second type, only coloring fragments if they have the + // same depth value as the closest fragment in the previous pass. Use the stencil buffer + // to prevent the second draw in cases where we have coincident polygons. + drawExtrusionTiles(painter, source, layer, coords, depthMode, painter.stencilModeFor3D(), painter.colorModeForRenderPass()); + } + } +} +function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMode, colorMode) { + const context = painter.context; + const gl = context.gl; + const fillPropertyName = 'fill-extrusion-pattern'; + const patternProperty = layer.paint.get(fillPropertyName); + const image = patternProperty.constantOr(1); + const crossfade = layer.getCrossfadeParameters(); + const opacity = layer.paint.get('fill-extrusion-opacity'); + const constantPattern = patternProperty.constantOr(null); + for (const coord of coords) { + const tile = source.getTile(coord); + const bucket = tile.getBucket(layer); + if (!bucket) + continue; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration); + if (image) { + painter.context.activeTexture.set(gl.TEXTURE0); + tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + programConfiguration.updatePaintBuffers(crossfade); + } + updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer); + const matrix = painter.translatePosMatrix(coord.posMatrix, tile, layer.paint.get('fill-extrusion-translate'), layer.paint.get('fill-extrusion-translate-anchor')); + const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient'); + const uniformValues = image ? + fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile) : + fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity); + program.draw(context, context.gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments, layer.paint, painter.transform.zoom, programConfiguration, painter.style.map.terrain && bucket.centroidVertexBuffer); + } +} + +function drawHillshade(painter, sourceCache, layer, tileIDs) { + if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') + return; + const context = painter.context; + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + const colorMode = painter.colorModeForRenderPass(); + const [stencilModes, coords] = painter.renderPass === 'translucent' ? + painter.stencilConfigForOverlap(tileIDs) : [{}, tileIDs]; + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + if (typeof tile.needsHillshadePrepare !== 'undefined' && tile.needsHillshadePrepare && painter.renderPass === 'offscreen') { + prepareHillshade(painter, tile, layer, depthMode, StencilMode.disabled, colorMode); + } + else if (painter.renderPass === 'translucent') { + renderHillshade(painter, coord, tile, layer, depthMode, stencilModes[coord.overscaledZ], colorMode); + } + } + context.viewport.set([0, 0, painter.width, painter.height]); +} +function renderHillshade(painter, coord, tile, layer, depthMode, stencilMode, colorMode) { + const context = painter.context; + const gl = context.gl; + const fbo = tile.fbo; + if (!fbo) + return; + const program = painter.useProgram('hillshade'); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get()); + const terrainCoord = terrainData ? coord : null; + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, hillshadeUniformValues(painter, tile, layer, terrainCoord), terrainData, layer.id, painter.rasterBoundsBuffer, painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments); +} +// hillshade rendering is done in two steps. the prepare step first calculates the slope of the terrain in the x and y +// directions for each pixel, and saves those values to a framebuffer texture in the r and g channels. +function prepareHillshade(painter, tile, layer, depthMode, stencilMode, colorMode) { + const context = painter.context; + const gl = context.gl; + const dem = tile.dem; + if (dem && dem.data) { + const tileSize = dem.dim; + const textureStride = dem.stride; + const pixelData = dem.getPixels(); + context.activeTexture.set(gl.TEXTURE1); + context.pixelStoreUnpackPremultiplyAlpha.set(false); + tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride); + if (tile.demTexture) { + const demTexture = tile.demTexture; + demTexture.update(pixelData, { premultiply: false }); + demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE); + } + else { + tile.demTexture = new Texture(context, pixelData, gl.RGBA, { premultiply: false }); + tile.demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE); + } + context.activeTexture.set(gl.TEXTURE0); + let fbo = tile.fbo; + if (!fbo) { + const renderTexture = new Texture(context, { width: tileSize, height: tileSize, data: null }, gl.RGBA); + renderTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + fbo = tile.fbo = context.createFramebuffer(tileSize, tileSize, true, false); + fbo.colorAttachment.set(renderTexture.texture); + } + context.bindFramebuffer.set(fbo.framebuffer); + context.viewport.set([0, 0, tileSize, tileSize]); + painter.useProgram('hillshadePrepare').draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, hillshadeUniformPrepareValues(tile.tileID, dem), null, layer.id, painter.rasterBoundsBuffer, painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments); + tile.needsHillshadePrepare = false; + } +} + +function drawRaster(painter, sourceCache, layer, tileIDs) { + if (painter.renderPass !== 'translucent') + return; + if (layer.paint.get('raster-opacity') === 0) + return; + if (!tileIDs.length) + return; + const context = painter.context; + const gl = context.gl; + const source = sourceCache.getSource(); + const program = painter.useProgram('raster'); + const colorMode = painter.colorModeForRenderPass(); + const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] : + painter.stencilConfigForOverlap(tileIDs); + const minTileZ = coords[coords.length - 1].overscaledZ; + const align = !painter.options.moving; + for (const coord of coords) { + // Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers + // Use gl.LESS to prevent double drawing in areas where tiles overlap. + const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ, layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS); + const tile = sourceCache.getTile(coord); + tile.registerFadeDuration(layer.paint.get('raster-fade-duration')); + const parentTile = sourceCache.findLoadedParent(coord, 0), fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform, painter.style.map.terrain); + let parentScaleBy, parentTL; + const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR; + context.activeTexture.set(gl.TEXTURE0); + tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + context.activeTexture.set(gl.TEXTURE1); + if (parentTile) { + parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ); + parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1]; + } + else { + tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + } + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const terrainCoord = terrainData ? coord : null; + const posMatrix = terrainCoord ? terrainCoord.posMatrix : painter.transform.calculatePosMatrix(coord.toUnwrapped(), align); + const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer); + if (source instanceof ImageSource) { + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, source.boundsBuffer, painter.quadTriangleIndexBuffer, source.boundsSegments); + } + else { + program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, painter.rasterBoundsBuffer, painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments); + } + } +} +function getFadeValues(tile, parentTile, sourceCache, layer, transform, terrain) { + const fadeDuration = layer.paint.get('raster-fade-duration'); + if (!terrain && fadeDuration > 0) { + const now = performance.browser.now(); + const sinceTile = (now - tile.timeAdded) / fadeDuration; + const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1; + const source = sourceCache.getSource(); + const idealZ = transform.coveringZoomLevel({ + tileSize: source.tileSize, + roundZoom: source.roundZoom + }); + // if no parent or parent is older, fade in; if parent is younger, fade out + const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ); + const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : performance.clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1); + // we don't crossfade tiles that were just refreshed upon expiring: + // once they're old enough to pass the crossfading threshold + // (fadeDuration), unset the `refreshedUponExpiration` flag so we don't + // incorrectly fail to crossfade them when zooming + if (tile.refreshedUponExpiration && sinceTile >= 1) + tile.refreshedUponExpiration = false; + if (parentTile) { + return { + opacity: 1, + mix: 1 - childOpacity + }; + } + else { + return { + opacity: childOpacity, + mix: 0 + }; + } + } + else { + return { + opacity: 1, + mix: 0 + }; + } +} + +function drawBackground(painter, sourceCache, layer, coords) { + const color = layer.paint.get('background-color'); + const opacity = layer.paint.get('background-opacity'); + if (opacity === 0) + return; + const context = painter.context; + const gl = context.gl; + const transform = painter.transform; + const tileSize = transform.tileSize; + const image = layer.paint.get('background-pattern'); + if (painter.isPatternMissing(image)) + return; + const pass = (!image && color.a === 1 && opacity === 1 && painter.opaquePassEnabledForLayer()) ? 'opaque' : 'translucent'; + if (painter.renderPass !== pass) + return; + const stencilMode = StencilMode.disabled; + const depthMode = painter.depthModeForSublayer(0, pass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly); + const colorMode = painter.colorModeForRenderPass(); + const program = painter.useProgram(image ? 'backgroundPattern' : 'background'); + const tileIDs = coords ? coords : transform.coveringTiles({ tileSize, terrain: painter.style.map.terrain }); + if (image) { + context.activeTexture.set(gl.TEXTURE0); + painter.imageManager.bind(painter.context); + } + const crossfade = layer.getCrossfadeParameters(); + for (const tileID of tileIDs) { + const matrix = coords ? tileID.posMatrix : painter.transform.calculatePosMatrix(tileID.toUnwrapped()); + const uniformValues = image ? + backgroundPatternUniformValues(matrix, opacity, painter, image, { tileID, tileSize }, crossfade) : + backgroundUniformValues(matrix, opacity, color); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(tileID); + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, uniformValues, terrainData, layer.id, painter.tileExtentBuffer, painter.quadTriangleIndexBuffer, painter.tileExtentSegments); + } +} + +const topColor = new performance.Color(1, 0, 0, 1); +const btmColor = new performance.Color(0, 1, 0, 1); +const leftColor = new performance.Color(0, 0, 1, 1); +const rightColor = new performance.Color(1, 0, 1, 1); +const centerColor = new performance.Color(0, 1, 1, 1); +function drawDebugPadding(painter) { + const padding = painter.transform.padding; + const lineWidth = 3; + // Top + drawHorizontalLine(painter, painter.transform.height - (padding.top || 0), lineWidth, topColor); + // Bottom + drawHorizontalLine(painter, padding.bottom || 0, lineWidth, btmColor); + // Left + drawVerticalLine(painter, padding.left || 0, lineWidth, leftColor); + // Right + drawVerticalLine(painter, painter.transform.width - (padding.right || 0), lineWidth, rightColor); + // Center + const center = painter.transform.centerPoint; + drawCrosshair(painter, center.x, painter.transform.height - center.y, centerColor); +} +function drawCrosshair(painter, x, y, color) { + const size = 20; + const lineWidth = 2; + //Vertical line + drawDebugSSRect(painter, x - lineWidth / 2, y - size / 2, lineWidth, size, color); + //Horizontal line + drawDebugSSRect(painter, x - size / 2, y - lineWidth / 2, size, lineWidth, color); +} +function drawHorizontalLine(painter, y, lineWidth, color) { + drawDebugSSRect(painter, 0, y + lineWidth / 2, painter.transform.width, lineWidth, color); +} +function drawVerticalLine(painter, x, lineWidth, color) { + drawDebugSSRect(painter, x - lineWidth / 2, 0, lineWidth, painter.transform.height, color); +} +function drawDebugSSRect(painter, x, y, width, height, color) { + const context = painter.context; + const gl = context.gl; + gl.enable(gl.SCISSOR_TEST); + gl.scissor(x * painter.pixelRatio, y * painter.pixelRatio, width * painter.pixelRatio, height * painter.pixelRatio); + context.clear({ color }); + gl.disable(gl.SCISSOR_TEST); +} +function drawDebug(painter, sourceCache, coords) { + for (let i = 0; i < coords.length; i++) { + drawDebugTile(painter, sourceCache, coords[i]); + } +} +function drawDebugTile(painter, sourceCache, coord) { + const context = painter.context; + const gl = context.gl; + const posMatrix = coord.posMatrix; + const program = painter.useProgram('debug'); + const depthMode = DepthMode.disabled; + const stencilMode = StencilMode.disabled; + const colorMode = painter.colorModeForRenderPass(); + const id = '$debug'; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + context.activeTexture.set(gl.TEXTURE0); + const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData; + const tileByteLength = (tileRawData && tileRawData.byteLength) || 0; + const tileSizeKb = Math.floor(tileByteLength / 1024); + const tileSize = sourceCache.getTile(coord).tileSize; + const scaleRatio = (512 / Math.min(tileSize, 512) * (coord.overscaledZ / painter.transform.zoom)) * 0.5; + let tileIdText = coord.canonical.toString(); + if (coord.overscaledZ !== coord.canonical.z) { + tileIdText += ` => ${coord.overscaledZ}`; + } + const tileLabel = `${tileIdText} ${tileSizeKb}kB`; + drawTextToOverlay(painter, tileLabel); + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, ColorMode.alphaBlended, CullFaceMode.disabled, debugUniformValues(posMatrix, performance.Color.transparent, scaleRatio), null, id, painter.debugBuffer, painter.quadTriangleIndexBuffer, painter.debugSegments); + program.draw(context, gl.LINE_STRIP, depthMode, stencilMode, colorMode, CullFaceMode.disabled, debugUniformValues(posMatrix, performance.Color.red), terrainData, id, painter.debugBuffer, painter.tileBorderIndexBuffer, painter.debugSegments); +} +function drawTextToOverlay(painter, text) { + painter.initDebugOverlayCanvas(); + const canvas = painter.debugOverlayCanvas; + const gl = painter.context.gl; + const ctx2d = painter.debugOverlayCanvas.getContext('2d'); + ctx2d.clearRect(0, 0, canvas.width, canvas.height); + ctx2d.shadowColor = 'white'; + ctx2d.shadowBlur = 2; + ctx2d.lineWidth = 1.5; + ctx2d.strokeStyle = 'white'; + ctx2d.textBaseline = 'top'; + ctx2d.font = `bold ${36}px Open Sans, sans-serif`; + ctx2d.fillText(text, 5, 5); + ctx2d.strokeText(text, 5, 5); + painter.debugOverlayTexture.update(canvas); + painter.debugOverlayTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); +} +function selectDebugSource(style, zoom) { + // Use vector source with highest maxzoom + // Else use source with highest maxzoom of any type + let selectedSource = null; + const layers = Object.values(style._layers); + const sources = layers.flatMap((layer) => { + if (layer.source && !layer.isHidden(zoom)) { + const sourceCache = style.sourceCaches[layer.source]; + return [sourceCache]; + } + else { + return []; + } + }); + const vectorSources = sources.filter((source) => source.getSource().type === 'vector'); + const otherSources = sources.filter((source) => source.getSource().type !== 'vector'); + const considerSource = (source) => { + if (!selectedSource || (selectedSource.getSource().maxzoom < source.getSource().maxzoom)) { + selectedSource = source; + } + }; + vectorSources.forEach((source) => considerSource(source)); + if (!selectedSource) { + otherSources.forEach((source) => considerSource(source)); + } + return selectedSource; +} + +function drawCustom(painter, sourceCache, layer) { + const context = painter.context; + const implementation = layer.implementation; + if (painter.renderPass === 'offscreen') { + const prerender = implementation.prerender; + if (prerender) { + painter.setCustomLayerDefaults(); + context.setColorMode(painter.colorModeForRenderPass()); + prerender.call(implementation, context.gl, painter.transform.customLayerMatrix()); + context.setDirty(); + painter.setBaseState(); + } + } + else if (painter.renderPass === 'translucent') { + painter.setCustomLayerDefaults(); + context.setColorMode(painter.colorModeForRenderPass()); + context.setStencilMode(StencilMode.disabled); + const depthMode = implementation.renderingMode === '3d' ? + new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D) : + painter.depthModeForSublayer(0, DepthMode.ReadOnly); + context.setDepthMode(depthMode); + implementation.render(context.gl, painter.transform.customLayerMatrix()); + context.setDirty(); + painter.setBaseState(); + context.bindFramebuffer.set(null); + } +} + +/** + * Redraw the Depth Framebuffer + * @param painter - the painter + * @param terrain - the terrain + */ +function drawDepth(painter, terrain) { + const context = painter.context; + const gl = context.gl; + const colorMode = ColorMode.unblended; + const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]); + const mesh = terrain.getTerrainMesh(); + const tiles = terrain.sourceCache.getRenderableTiles(); + const program = painter.useProgram('terrainDepth'); + context.bindFramebuffer.set(terrain.getFramebuffer('depth').framebuffer); + context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]); + context.clear({ color: performance.Color.transparent, depth: 1 }); + for (const tile of tiles) { + const terrainData = terrain.getTerrainData(tile.tileID); + const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const uniformValues = terrainDepthUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom)); + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments); + } + context.bindFramebuffer.set(null); + context.viewport.set([0, 0, painter.width, painter.height]); +} +/** + * Redraw the Coords Framebuffers + * @param painter - the painter + * @param terrain - the terrain + */ +function drawCoords(painter, terrain) { + const context = painter.context; + const gl = context.gl; + const colorMode = ColorMode.unblended; + const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]); + const mesh = terrain.getTerrainMesh(); + const coords = terrain.getCoordsTexture(); + const tiles = terrain.sourceCache.getRenderableTiles(); + // draw tile-coords into framebuffer + const program = painter.useProgram('terrainCoords'); + context.bindFramebuffer.set(terrain.getFramebuffer('coords').framebuffer); + context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]); + context.clear({ color: performance.Color.transparent, depth: 1 }); + terrain.coordsIndex = []; + for (const tile of tiles) { + const terrainData = terrain.getTerrainData(tile.tileID); + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, coords.texture); + const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const uniformValues = terrainCoordsUniformValues(posMatrix, 255 - terrain.coordsIndex.length, terrain.getMeshFrameDelta(painter.transform.zoom)); + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments); + terrain.coordsIndex.push(tile.tileID.key); + } + context.bindFramebuffer.set(null); + context.viewport.set([0, 0, painter.width, painter.height]); +} +function drawTerrain(painter, terrain, tiles) { + const context = painter.context; + const gl = context.gl; + const colorMode = painter.colorModeForRenderPass(); + const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D); + const program = painter.useProgram('terrain'); + const mesh = terrain.getTerrainMesh(); + context.bindFramebuffer.set(null); + context.viewport.set([0, 0, painter.width, painter.height]); + for (const tile of tiles) { + const texture = painter.renderToTexture.getTexture(tile); + const terrainData = terrain.getTerrainData(tile.tileID); + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture.texture); + const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const uniformValues = terrainUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom)); + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments); + } +} + +/** + * @internal + * Initialize a new painter object. + */ +class Painter { + constructor(gl, transform) { + this.context = new Context(gl); + this.transform = transform; + this._tileTextures = {}; + this.terrainFacilitator = { dirty: true, matrix: performance.create(), renderTime: 0 }; + this.setup(); + // Within each layer there are multiple distinct z-planes that can be drawn to. + // This is implemented using the WebGL depth buffer. + this.numSublayers = SourceCache.maxUnderzooming + SourceCache.maxOverzooming + 1; + this.depthEpsilon = 1 / Math.pow(2, 16); + this.crossTileSymbolIndex = new CrossTileSymbolIndex(); + } + /* + * Update the GL viewport, projection matrix, and transforms to compensate + * for a new width and height value. + */ + resize(width, height, pixelRatio) { + this.width = Math.floor(width * pixelRatio); + this.height = Math.floor(height * pixelRatio); + this.pixelRatio = pixelRatio; + this.context.viewport.set([0, 0, this.width, this.height]); + if (this.style) { + for (const layerId of this.style._order) { + this.style._layers[layerId].resize(); + } + } + } + setup() { + const context = this.context; + const tileExtentArray = new performance.PosArray(); + tileExtentArray.emplaceBack(0, 0); + tileExtentArray.emplaceBack(performance.EXTENT, 0); + tileExtentArray.emplaceBack(0, performance.EXTENT); + tileExtentArray.emplaceBack(performance.EXTENT, performance.EXTENT); + this.tileExtentBuffer = context.createVertexBuffer(tileExtentArray, posAttributes.members); + this.tileExtentSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 2); + const debugArray = new performance.PosArray(); + debugArray.emplaceBack(0, 0); + debugArray.emplaceBack(performance.EXTENT, 0); + debugArray.emplaceBack(0, performance.EXTENT); + debugArray.emplaceBack(performance.EXTENT, performance.EXTENT); + this.debugBuffer = context.createVertexBuffer(debugArray, posAttributes.members); + this.debugSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 5); + const rasterBoundsArray = new performance.RasterBoundsArray(); + rasterBoundsArray.emplaceBack(0, 0, 0, 0); + rasterBoundsArray.emplaceBack(performance.EXTENT, 0, performance.EXTENT, 0); + rasterBoundsArray.emplaceBack(0, performance.EXTENT, 0, performance.EXTENT); + rasterBoundsArray.emplaceBack(performance.EXTENT, performance.EXTENT, performance.EXTENT, performance.EXTENT); + this.rasterBoundsBuffer = context.createVertexBuffer(rasterBoundsArray, rasterBoundsAttributes.members); + this.rasterBoundsSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 2); + const viewportArray = new performance.PosArray(); + viewportArray.emplaceBack(0, 0); + viewportArray.emplaceBack(1, 0); + viewportArray.emplaceBack(0, 1); + viewportArray.emplaceBack(1, 1); + this.viewportBuffer = context.createVertexBuffer(viewportArray, posAttributes.members); + this.viewportSegments = performance.SegmentVector.simpleSegment(0, 0, 4, 2); + const tileLineStripIndices = new performance.LineStripIndexArray(); + tileLineStripIndices.emplaceBack(0); + tileLineStripIndices.emplaceBack(1); + tileLineStripIndices.emplaceBack(3); + tileLineStripIndices.emplaceBack(2); + tileLineStripIndices.emplaceBack(0); + this.tileBorderIndexBuffer = context.createIndexBuffer(tileLineStripIndices); + const quadTriangleIndices = new performance.TriangleIndexArray(); + quadTriangleIndices.emplaceBack(0, 1, 2); + quadTriangleIndices.emplaceBack(2, 1, 3); + this.quadTriangleIndexBuffer = context.createIndexBuffer(quadTriangleIndices); + const gl = this.context.gl; + this.stencilClearMode = new StencilMode({ func: gl.ALWAYS, mask: 0 }, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO); + } + /* + * Reset the drawing canvas by clearing the stencil buffer so that we can draw + * new tiles at the same location, while retaining previously drawn pixels. + */ + clearStencil() { + const context = this.context; + const gl = context.gl; + this.nextStencilID = 1; + this.currentStencilSource = undefined; + // As a temporary workaround for https://github.com/mapbox/mapbox-gl-js/issues/5490, + // pending an upstream fix, we draw a fullscreen stencil=0 clipping mask here, + // effectively clearing the stencil buffer: once an upstream patch lands, remove + // this function in favor of context.clear({ stencil: 0x0 }) + const matrix = performance.create(); + performance.ortho(matrix, 0, this.width, this.height, 0, 0, 1); + performance.scale(matrix, matrix, [gl.drawingBufferWidth, gl.drawingBufferHeight, 0]); + this.useProgram('clippingMask').draw(context, gl.TRIANGLES, DepthMode.disabled, this.stencilClearMode, ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(matrix), null, '$clipping', this.viewportBuffer, this.quadTriangleIndexBuffer, this.viewportSegments); + } + _renderTileClippingMasks(layer, tileIDs) { + if (this.currentStencilSource === layer.source || !layer.isTileClipped() || !tileIDs || !tileIDs.length) + return; + this.currentStencilSource = layer.source; + const context = this.context; + const gl = context.gl; + if (this.nextStencilID + tileIDs.length > 256) { + // we'll run out of fresh IDs so we need to clear and start from scratch + this.clearStencil(); + } + context.setColorMode(ColorMode.disabled); + context.setDepthMode(DepthMode.disabled); + const program = this.useProgram('clippingMask'); + this._tileClippingMaskIDs = {}; + for (const tileID of tileIDs) { + const id = this._tileClippingMaskIDs[tileID.key] = this.nextStencilID++; + const terrainData = this.style.map.terrain && this.style.map.terrain.getTerrainData(tileID); + program.draw(context, gl.TRIANGLES, DepthMode.disabled, + // Tests will always pass, and ref value will be written to stencil buffer. + new StencilMode({ func: gl.ALWAYS, mask: 0 }, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE), ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(tileID.posMatrix), terrainData, '$clipping', this.tileExtentBuffer, this.quadTriangleIndexBuffer, this.tileExtentSegments); + } + } + stencilModeFor3D() { + this.currentStencilSource = undefined; + if (this.nextStencilID + 1 > 256) { + this.clearStencil(); + } + const id = this.nextStencilID++; + const gl = this.context.gl; + return new StencilMode({ func: gl.NOTEQUAL, mask: 0xFF }, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE); + } + stencilModeForClipping(tileID) { + const gl = this.context.gl; + return new StencilMode({ func: gl.EQUAL, mask: 0xFF }, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE); + } + /* + * Sort coordinates by Z as drawing tiles is done in Z-descending order. + * All children with the same Z write the same stencil value. Children + * stencil values are greater than parent's. This is used only for raster + * and raster-dem tiles, which are already clipped to tile boundaries, to + * mask area of tile overlapped by children tiles. + * Stencil ref values continue range used in _tileClippingMaskIDs. + * + * Returns [StencilMode for tile overscaleZ map, sortedCoords]. + */ + stencilConfigForOverlap(tileIDs) { + const gl = this.context.gl; + const coords = tileIDs.sort((a, b) => b.overscaledZ - a.overscaledZ); + const minTileZ = coords[coords.length - 1].overscaledZ; + const stencilValues = coords[0].overscaledZ - minTileZ + 1; + if (stencilValues > 1) { + this.currentStencilSource = undefined; + if (this.nextStencilID + stencilValues > 256) { + this.clearStencil(); + } + const zToStencilMode = {}; + for (let i = 0; i < stencilValues; i++) { + zToStencilMode[i + minTileZ] = new StencilMode({ func: gl.GEQUAL, mask: 0xFF }, i + this.nextStencilID, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE); + } + this.nextStencilID += stencilValues; + return [zToStencilMode, coords]; + } + return [{ [minTileZ]: StencilMode.disabled }, coords]; + } + colorModeForRenderPass() { + const gl = this.context.gl; + if (this._showOverdrawInspector) { + const numOverdrawSteps = 8; + const a = 1 / numOverdrawSteps; + return new ColorMode([gl.CONSTANT_COLOR, gl.ONE], new performance.Color(a, a, a, 0), [true, true, true, true]); + } + else if (this.renderPass === 'opaque') { + return ColorMode.unblended; + } + else { + return ColorMode.alphaBlended; + } + } + depthModeForSublayer(n, mask, func) { + if (!this.opaquePassEnabledForLayer()) + return DepthMode.disabled; + const depth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon; + return new DepthMode(func || this.context.gl.LEQUAL, mask, [depth, depth]); + } + /* + * The opaque pass and 3D layers both use the depth buffer. + * Layers drawn above 3D layers need to be drawn using the + * painter's algorithm so that they appear above 3D features. + * This returns true for layers that can be drawn using the + * opaque pass. + */ + opaquePassEnabledForLayer() { + return this.currentLayer < this.opaquePassCutoff; + } + render(style, options) { + this.style = style; + this.options = options; + this.lineAtlas = style.lineAtlas; + this.imageManager = style.imageManager; + this.glyphManager = style.glyphManager; + this.symbolFadeChange = style.placement.symbolFadeChange(performance.browser.now()); + this.imageManager.beginFrame(); + const layerIds = this.style._order; + const sourceCaches = this.style.sourceCaches; + const coordsAscending = {}; + const coordsDescending = {}; + const coordsDescendingSymbol = {}; + for (const id in sourceCaches) { + const sourceCache = sourceCaches[id]; + if (sourceCache.used) { + sourceCache.prepare(this.context); + } + coordsAscending[id] = sourceCache.getVisibleCoordinates(); + coordsDescending[id] = coordsAscending[id].slice().reverse(); + coordsDescendingSymbol[id] = sourceCache.getVisibleCoordinates(true).reverse(); + } + this.opaquePassCutoff = Infinity; + for (let i = 0; i < layerIds.length; i++) { + const layerId = layerIds[i]; + if (this.style._layers[layerId].is3D()) { + this.opaquePassCutoff = i; + break; + } + } + if (this.renderToTexture) { + this.renderToTexture.prepareForRender(this.style, this.transform.zoom); + // this is disabled, because render-to-texture is rendering all layers from bottom to top. + this.opaquePassCutoff = 0; + // update coords/depth-framebuffer on camera movement, or tile reloading + const newTiles = this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime); + if (this.terrainFacilitator.dirty || !performance.equals(this.terrainFacilitator.matrix, this.transform.projMatrix) || newTiles.length) { + performance.copy(this.terrainFacilitator.matrix, this.transform.projMatrix); + this.terrainFacilitator.renderTime = Date.now(); + this.terrainFacilitator.dirty = false; + drawDepth(this, this.style.map.terrain); + drawCoords(this, this.style.map.terrain); + } + } + // Offscreen pass =============================================== + // We first do all rendering that requires rendering to a separate + // framebuffer, and then save those for rendering back to the map + // later: in doing this we avoid doing expensive framebuffer restores. + this.renderPass = 'offscreen'; + for (const layerId of layerIds) { + const layer = this.style._layers[layerId]; + if (!layer.hasOffscreenPass() || layer.isHidden(this.transform.zoom)) + continue; + const coords = coordsDescending[layer.source]; + if (layer.type !== 'custom' && !coords.length) + continue; + this.renderLayer(this, sourceCaches[layer.source], layer, coords); + } + // Rebind the main framebuffer now that all offscreen layers have been rendered: + this.context.bindFramebuffer.set(null); + // Clear buffers in preparation for drawing to the main framebuffer + this.context.clear({ color: options.showOverdrawInspector ? performance.Color.black : performance.Color.transparent, depth: 1 }); + this.clearStencil(); + this._showOverdrawInspector = options.showOverdrawInspector; + this.depthRangeFor3D = [0, 1 - ((style._order.length + 2) * this.numSublayers * this.depthEpsilon)]; + // Opaque pass =============================================== + // Draw opaque layers top-to-bottom first. + if (!this.renderToTexture) { + this.renderPass = 'opaque'; + for (this.currentLayer = layerIds.length - 1; this.currentLayer >= 0; this.currentLayer--) { + const layer = this.style._layers[layerIds[this.currentLayer]]; + const sourceCache = sourceCaches[layer.source]; + const coords = coordsAscending[layer.source]; + this._renderTileClippingMasks(layer, coords); + this.renderLayer(this, sourceCache, layer, coords); + } + } + // Translucent pass =============================================== + // Draw all other layers bottom-to-top. + this.renderPass = 'translucent'; + for (this.currentLayer = 0; this.currentLayer < layerIds.length; this.currentLayer++) { + const layer = this.style._layers[layerIds[this.currentLayer]]; + const sourceCache = sourceCaches[layer.source]; + if (this.renderToTexture && this.renderToTexture.renderLayer(layer)) + continue; + // For symbol layers in the translucent pass, we add extra tiles to the renderable set + // for cross-tile symbol fading. Symbol layers don't use tile clipping, so no need to render + // separate clipping masks + const coords = (layer.type === 'symbol' ? coordsDescendingSymbol : coordsDescending)[layer.source]; + this._renderTileClippingMasks(layer, coordsAscending[layer.source]); + this.renderLayer(this, sourceCache, layer, coords); + } + if (this.options.showTileBoundaries) { + const selectedSource = selectDebugSource(this.style, this.transform.zoom); + if (selectedSource) { + drawDebug(this, selectedSource, selectedSource.getVisibleCoordinates()); + } + } + if (this.options.showPadding) { + drawDebugPadding(this); + } + // Set defaults for most GL values so that anyone using the state after the render + // encounters more expected values. + this.context.setDefault(); + } + renderLayer(painter, sourceCache, layer, coords) { + if (layer.isHidden(this.transform.zoom)) + return; + if (layer.type !== 'background' && layer.type !== 'custom' && !(coords || []).length) + return; + this.id = layer.id; + switch (layer.type) { + case 'symbol': + drawSymbols(painter, sourceCache, layer, coords, this.style.placement.variableOffsets); + break; + case 'circle': + drawCircles(painter, sourceCache, layer, coords); + break; + case 'heatmap': + drawHeatmap(painter, sourceCache, layer, coords); + break; + case 'line': + drawLine(painter, sourceCache, layer, coords); + break; + case 'fill': + drawFill(painter, sourceCache, layer, coords); + break; + case 'fill-extrusion': + drawFillExtrusion(painter, sourceCache, layer, coords); + break; + case 'hillshade': + drawHillshade(painter, sourceCache, layer, coords); + break; + case 'raster': + drawRaster(painter, sourceCache, layer, coords); + break; + case 'background': + drawBackground(painter, sourceCache, layer, coords); + break; + case 'custom': + drawCustom(painter, sourceCache, layer); + break; + } + } + /** + * Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it. + * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units. + * @returns matrix + */ + translatePosMatrix(matrix, tile, translate, translateAnchor, inViewportPixelUnitsUnits) { + if (!translate[0] && !translate[1]) + return matrix; + const angle = inViewportPixelUnitsUnits ? + (translateAnchor === 'map' ? this.transform.angle : 0) : + (translateAnchor === 'viewport' ? -this.transform.angle : 0); + if (angle) { + const sinA = Math.sin(angle); + const cosA = Math.cos(angle); + translate = [ + translate[0] * cosA - translate[1] * sinA, + translate[0] * sinA + translate[1] * cosA + ]; + } + const translation = [ + inViewportPixelUnitsUnits ? translate[0] : pixelsToTileUnits(tile, translate[0], this.transform.zoom), + inViewportPixelUnitsUnits ? translate[1] : pixelsToTileUnits(tile, translate[1], this.transform.zoom), + 0 + ]; + const translatedMatrix = new Float32Array(16); + performance.translate(translatedMatrix, matrix, translation); + return translatedMatrix; + } + saveTileTexture(texture) { + const textures = this._tileTextures[texture.size[0]]; + if (!textures) { + this._tileTextures[texture.size[0]] = [texture]; + } + else { + textures.push(texture); + } + } + getTileTexture(size) { + const textures = this._tileTextures[size]; + return textures && textures.length > 0 ? textures.pop() : null; + } + /** + * Checks whether a pattern image is needed, and if it is, whether it is not loaded. + * + * @returns true if a needed image is missing and rendering needs to be skipped. + */ + isPatternMissing(image) { + if (!image) + return false; + if (!image.from || !image.to) + return true; + const imagePosA = this.imageManager.getPattern(image.from.toString()); + const imagePosB = this.imageManager.getPattern(image.to.toString()); + return !imagePosA || !imagePosB; + } + useProgram(name, programConfiguration) { + this.cache = this.cache || {}; + const key = name + + (programConfiguration ? programConfiguration.cacheKey : '') + + (this._showOverdrawInspector ? '/overdraw' : '') + + (this.style.map.terrain ? '/terrain' : ''); + if (!this.cache[key]) { + this.cache[key] = new Program(this.context, shaders[name], programConfiguration, programUniforms[name], this._showOverdrawInspector, this.style.map.terrain); + } + return this.cache[key]; + } + /* + * Reset some GL state to default values to avoid hard-to-debug bugs + * in custom layers. + */ + setCustomLayerDefaults() { + // Prevent custom layers from unintentionally modify the last VAO used. + // All other state is state is restored on it's own, but for VAOs it's + // simpler to unbind so that we don't have to track the state of VAOs. + this.context.unbindVAO(); + // The default values for this state is meaningful and often expected. + // Leaving this state dirty could cause a lot of confusion for users. + this.context.cullFace.setDefault(); + this.context.activeTexture.setDefault(); + this.context.pixelStoreUnpack.setDefault(); + this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(); + this.context.pixelStoreUnpackFlipY.setDefault(); + } + /* + * Set GL state that is shared by all layers. + */ + setBaseState() { + const gl = this.context.gl; + this.context.cullFace.set(false); + this.context.viewport.set([0, 0, this.width, this.height]); + this.context.blendEquation.set(gl.FUNC_ADD); + } + initDebugOverlayCanvas() { + if (this.debugOverlayCanvas == null) { + this.debugOverlayCanvas = document.createElement('canvas'); + this.debugOverlayCanvas.width = 512; + this.debugOverlayCanvas.height = 512; + const gl = this.context.gl; + this.debugOverlayTexture = new Texture(this.context, this.debugOverlayCanvas, gl.RGBA); + } + } + destroy() { + if (this.debugOverlayTexture) { + this.debugOverlayTexture.destroy(); + } + } + /* + * Return true if drawing buffer size is != from requested size. + * That means that we've reached GL limits somehow. + * Note: drawing buffer size changes only when canvas size changes + */ + overLimit() { + const { drawingBufferWidth, drawingBufferHeight } = this.context.gl; + return this.width !== drawingBufferWidth || this.height !== drawingBufferHeight; + } +} + +class Frustum { + constructor(points, planes) { + this.points = points; + this.planes = planes; + } + static fromInvProjectionMatrix(invProj, worldSize, zoom) { + const clipSpaceCorners = [ + [-1, 1, -1, 1], + [1, 1, -1, 1], + [1, -1, -1, 1], + [-1, -1, -1, 1], + [-1, 1, 1, 1], + [1, 1, 1, 1], + [1, -1, 1, 1], + [-1, -1, 1, 1] + ]; + const scale = Math.pow(2, zoom); + // Transform frustum corner points from clip space to tile space, Z to meters + const frustumCoords = clipSpaceCorners.map(v => { + v = performance.transformMat4([], v, invProj); + const s = 1.0 / v[3] / worldSize * scale; + return performance.mul$1(v, v, [s, s, 1.0 / v[3], s]); + }); + const frustumPlanePointIndices = [ + [0, 1, 2], + [6, 5, 4], + [0, 3, 7], + [2, 1, 5], + [3, 2, 6], + [0, 4, 5] // top + ]; + const frustumPlanes = frustumPlanePointIndices.map((p) => { + const a = performance.sub([], frustumCoords[p[0]], frustumCoords[p[1]]); + const b = performance.sub([], frustumCoords[p[2]], frustumCoords[p[1]]); + const n = performance.normalize([], performance.cross([], a, b)); + const d = -performance.dot(n, frustumCoords[p[1]]); + return n.concat(d); + }); + return new Frustum(frustumCoords, frustumPlanes); + } +} +class Aabb { + constructor(min_, max_) { + this.min = min_; + this.max = max_; + this.center = performance.scale$1([], performance.add([], this.min, this.max), 0.5); + } + quadrant(index) { + const split = [(index % 2) === 0, index < 2]; + const qMin = performance.clone$2(this.min); + const qMax = performance.clone$2(this.max); + for (let axis = 0; axis < split.length; axis++) { + qMin[axis] = split[axis] ? this.min[axis] : this.center[axis]; + qMax[axis] = split[axis] ? this.center[axis] : this.max[axis]; + } + // Elevation is always constant, hence quadrant.max.z = this.max.z + qMax[2] = this.max[2]; + return new Aabb(qMin, qMax); + } + distanceX(point) { + const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]); + return pointOnAabb - point[0]; + } + distanceY(point) { + const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]); + return pointOnAabb - point[1]; + } + // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection, + // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum. + intersects(frustum) { + // Execute separating axis test between two convex objects to find intersections + // Each frustum plane together with 3 major axes define the separating axes + const aabbPoints = [ + [this.min[0], this.min[1], this.min[2], 1], + [this.max[0], this.min[1], this.min[2], 1], + [this.max[0], this.max[1], this.min[2], 1], + [this.min[0], this.max[1], this.min[2], 1], + [this.min[0], this.min[1], this.max[2], 1], + [this.max[0], this.min[1], this.max[2], 1], + [this.max[0], this.max[1], this.max[2], 1], + [this.min[0], this.max[1], this.max[2], 1] + ]; + let fullyInside = true; + for (let p = 0; p < frustum.planes.length; p++) { + const plane = frustum.planes[p]; + let pointsInside = 0; + for (let i = 0; i < aabbPoints.length; i++) { + if (performance.dot$1(plane, aabbPoints[i]) >= 0) { + pointsInside++; + } + } + if (pointsInside === 0) + return 0; + if (pointsInside !== aabbPoints.length) + fullyInside = false; + } + if (fullyInside) + return 2; + for (let axis = 0; axis < 3; axis++) { + let projMin = Number.MAX_VALUE; + let projMax = -Number.MAX_VALUE; + for (let p = 0; p < frustum.points.length; p++) { + const projectedPoint = frustum.points[p][axis] - this.min[axis]; + projMin = Math.min(projMin, projectedPoint); + projMax = Math.max(projMax, projectedPoint); + } + if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) + return 0; + } + return 1; + } +} + +/** + * An `EdgeInset` object represents screen space padding applied to the edges of the viewport. + * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements + * on top of the map and having the vanishing point shift as UI elements resize. + * + * @group Geography and Geometry + */ +class EdgeInsets { + constructor(top = 0, bottom = 0, left = 0, right = 0) { + if (isNaN(top) || top < 0 || + isNaN(bottom) || bottom < 0 || + isNaN(left) || left < 0 || + isNaN(right) || right < 0) { + throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers'); + } + this.top = top; + this.bottom = bottom; + this.left = left; + this.right = right; + } + /** + * Interpolates the inset in-place. + * This maintains the current inset value for any inset not present in `target`. + * @param start - interpolation start + * @param target - interpolation target + * @param t - interpolation step/weight + * @returns the insets + */ + interpolate(start, target, t) { + if (target.top != null && start.top != null) + this.top = performance.interpolate.number(start.top, target.top, t); + if (target.bottom != null && start.bottom != null) + this.bottom = performance.interpolate.number(start.bottom, target.bottom, t); + if (target.left != null && start.left != null) + this.left = performance.interpolate.number(start.left, target.left, t); + if (target.right != null && start.right != null) + this.right = performance.interpolate.number(start.right, target.right, t); + return this; + } + /** + * Utility method that computes the new apprent center or vanishing point after applying insets. + * This is in pixels and with the top left being (0.0) and +y being downwards. + * + * @param width - the width + * @param height - the height + * @returns the point + */ + getCenter(width, height) { + // Clamp insets so they never overflow width/height and always calculate a valid center + const x = performance.clamp((this.left + width - this.right) / 2, 0, width); + const y = performance.clamp((this.top + height - this.bottom) / 2, 0, height); + return new performance.Point(x, y); + } + equals(other) { + return this.top === other.top && + this.bottom === other.bottom && + this.left === other.left && + this.right === other.right; + } + clone() { + return new EdgeInsets(this.top, this.bottom, this.left, this.right); + } + /** + * Returns the current state as json, useful when you want to have a + * read-only representation of the inset. + * + * @returns state as json + */ + toJSON() { + return { + top: this.top, + bottom: this.bottom, + left: this.left, + right: this.right + }; + } +} + +/** + * @internal + * A single transform, generally used for a single tile to be + * scaled, rotated, and zoomed. + */ +class Transform { + constructor(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies) { + this.tileSize = 512; // constant + this.maxValidLatitude = 85.051129; // constant + this._renderWorldCopies = renderWorldCopies === undefined ? true : !!renderWorldCopies; + this._minZoom = minZoom || 0; + this._maxZoom = maxZoom || 22; + this._minPitch = (minPitch === undefined || minPitch === null) ? 0 : minPitch; + this._maxPitch = (maxPitch === undefined || maxPitch === null) ? 60 : maxPitch; + this.setMaxBounds(); + this.width = 0; + this.height = 0; + this._center = new performance.LngLat(0, 0); + this._elevation = 0; + this.zoom = 0; + this.angle = 0; + this._fov = 0.6435011087932844; + this._pitch = 0; + this._unmodified = true; + this._edgeInsets = new EdgeInsets(); + this._posMatrixCache = {}; + this._alignedPosMatrixCache = {}; + this._minEleveationForCurrentTile = 0; + } + clone() { + const clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies); + clone.apply(this); + return clone; + } + apply(that) { + this.tileSize = that.tileSize; + this.latRange = that.latRange; + this.width = that.width; + this.height = that.height; + this._center = that._center; + this._elevation = that._elevation; + this._minEleveationForCurrentTile = that._minEleveationForCurrentTile; + this.zoom = that.zoom; + this.angle = that.angle; + this._fov = that._fov; + this._pitch = that._pitch; + this._unmodified = that._unmodified; + this._edgeInsets = that._edgeInsets.clone(); + this._calcMatrices(); + } + get minZoom() { return this._minZoom; } + set minZoom(zoom) { + if (this._minZoom === zoom) + return; + this._minZoom = zoom; + this.zoom = Math.max(this.zoom, zoom); + } + get maxZoom() { return this._maxZoom; } + set maxZoom(zoom) { + if (this._maxZoom === zoom) + return; + this._maxZoom = zoom; + this.zoom = Math.min(this.zoom, zoom); + } + get minPitch() { return this._minPitch; } + set minPitch(pitch) { + if (this._minPitch === pitch) + return; + this._minPitch = pitch; + this.pitch = Math.max(this.pitch, pitch); + } + get maxPitch() { return this._maxPitch; } + set maxPitch(pitch) { + if (this._maxPitch === pitch) + return; + this._maxPitch = pitch; + this.pitch = Math.min(this.pitch, pitch); + } + get renderWorldCopies() { return this._renderWorldCopies; } + set renderWorldCopies(renderWorldCopies) { + if (renderWorldCopies === undefined) { + renderWorldCopies = true; + } + else if (renderWorldCopies === null) { + renderWorldCopies = false; + } + this._renderWorldCopies = renderWorldCopies; + } + get worldSize() { + return this.tileSize * this.scale; + } + get centerOffset() { + return this.centerPoint._sub(this.size._div(2)); + } + get size() { + return new performance.Point(this.width, this.height); + } + get bearing() { + return -this.angle / Math.PI * 180; + } + set bearing(bearing) { + const b = -performance.wrap(bearing, -180, 180) * Math.PI / 180; + if (this.angle === b) + return; + this._unmodified = false; + this.angle = b; + this._calcMatrices(); + // 2x2 matrix for rotating points + this.rotationMatrix = performance.create$2(); + performance.rotate(this.rotationMatrix, this.rotationMatrix, this.angle); + } + get pitch() { + return this._pitch / Math.PI * 180; + } + set pitch(pitch) { + const p = performance.clamp(pitch, this.minPitch, this.maxPitch) / 180 * Math.PI; + if (this._pitch === p) + return; + this._unmodified = false; + this._pitch = p; + this._calcMatrices(); + } + get fov() { + return this._fov / Math.PI * 180; + } + set fov(fov) { + fov = Math.max(0.01, Math.min(60, fov)); + if (this._fov === fov) + return; + this._unmodified = false; + this._fov = fov / 180 * Math.PI; + this._calcMatrices(); + } + get zoom() { return this._zoom; } + set zoom(zoom) { + const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom); + if (this._zoom === constrainedZoom) + return; + this._unmodified = false; + this._zoom = constrainedZoom; + this.tileZoom = Math.max(0, Math.floor(constrainedZoom)); + this.scale = this.zoomScale(constrainedZoom); + this._constrain(); + this._calcMatrices(); + } + get center() { return this._center; } + set center(center) { + if (center.lat === this._center.lat && center.lng === this._center.lng) + return; + this._unmodified = false; + this._center = center; + this._constrain(); + this._calcMatrices(); + } + get elevation() { return this._elevation; } + set elevation(elevation) { + if (elevation === this._elevation) + return; + this._elevation = elevation; + this._constrain(); + this._calcMatrices(); + } + get padding() { return this._edgeInsets.toJSON(); } + set padding(padding) { + if (this._edgeInsets.equals(padding)) + return; + this._unmodified = false; + //Update edge-insets inplace + this._edgeInsets.interpolate(this._edgeInsets, padding, 1); + this._calcMatrices(); + } + /** + * The center of the screen in pixels with the top-left corner being (0,0) + * and +y axis pointing downwards. This accounts for padding. + */ + get centerPoint() { + return this._edgeInsets.getCenter(this.width, this.height); + } + /** + * Returns if the padding params match + * + * @param padding - the padding to check against + * @returns true if they are equal, false otherwise + */ + isPaddingEqual(padding) { + return this._edgeInsets.equals(padding); + } + /** + * Helper method to update edge-insets in place + * + * @param start - the starting padding + * @param target - the target padding + * @param t - the step/weight + */ + interpolatePadding(start, target, t) { + this._unmodified = false; + this._edgeInsets.interpolate(start, target, t); + this._constrain(); + this._calcMatrices(); + } + /** + * Return a zoom level that will cover all tiles the transform + * @param options - the options + * @returns zoom level An integer zoom level at which all tiles will be visible. + */ + coveringZoomLevel(options) { + const z = (options.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / options.tileSize)); + // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist. + return Math.max(0, z); + } + /** + * Return any "wrapped" copies of a given tile coordinate that are visible + * in the current view. + */ + getVisibleUnwrappedCoordinates(tileID) { + const result = [new performance.UnwrappedTileID(0, tileID)]; + if (this._renderWorldCopies) { + const utl = this.pointCoordinate(new performance.Point(0, 0)); + const utr = this.pointCoordinate(new performance.Point(this.width, 0)); + const ubl = this.pointCoordinate(new performance.Point(this.width, this.height)); + const ubr = this.pointCoordinate(new performance.Point(0, this.height)); + const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x)); + const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x)); + // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources. + // Both sources draw outside the tile boundaries of the tile that "contains them" so we need + // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones. + const extraWorldCopy = 1; + for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) { + if (w === 0) + continue; + result.push(new performance.UnwrappedTileID(w, tileID)); + } + } + return result; + } + /** + * Return all coordinates that could cover this transform for a covering + * zoom level. + * @param options - the options + * @returns OverscaledTileIDs + */ + coveringTiles(options) { + var _a, _b; + let z = this.coveringZoomLevel(options); + const actualZ = z; + if (options.minzoom !== undefined && z < options.minzoom) + return []; + if (options.maxzoom !== undefined && z > options.maxzoom) + z = options.maxzoom; + const cameraCoord = this.pointCoordinate(this.getCameraPoint()); + const centerCoord = performance.MercatorCoordinate.fromLngLat(this.center); + const numTiles = Math.pow(2, z); + const cameraPoint = [numTiles * cameraCoord.x, numTiles * cameraCoord.y, 0]; + const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0]; + const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, z); + // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level + let minZoom = options.minzoom || 0; + // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks + if (!options.terrain && this.pitch <= 60.0 && this._edgeInsets.top < 0.1) + minZoom = z; + // There should always be a certain number of maximum zoom level tiles surrounding the center location in 2D or in front of the camera in 3D + const radiusOfMaxLvlLodInTiles = options.terrain ? 2 / Math.min(this.tileSize, options.tileSize) * this.tileSize : 3; + const newRootTile = (wrap) => { + return { + aabb: new Aabb([wrap * numTiles, 0, 0], [(wrap + 1) * numTiles, numTiles, 0]), + zoom: 0, + x: 0, + y: 0, + wrap, + fullyVisible: false + }; + }; + // Do a depth-first traversal to find visible tiles and proper levels of detail + const stack = []; + const result = []; + const maxZoom = z; + const overscaledZ = options.reparseOverscaled ? actualZ : z; + if (this._renderWorldCopies) { + // Render copy of the globe thrice on both sides + for (let i = 1; i <= 3; i++) { + stack.push(newRootTile(-i)); + stack.push(newRootTile(i)); + } + } + stack.push(newRootTile(0)); + while (stack.length > 0) { + const it = stack.pop(); + const x = it.x; + const y = it.y; + let fullyVisible = it.fullyVisible; + // Visibility of a tile is not required if any of its ancestor if fully inside the frustum + if (!fullyVisible) { + const intersectResult = it.aabb.intersects(cameraFrustum); + if (intersectResult === 0) + continue; + fullyVisible = intersectResult === 2; + } + const refPoint = options.terrain ? cameraPoint : centerPoint; + const distanceX = it.aabb.distanceX(refPoint); + const distanceY = it.aabb.distanceY(refPoint); + const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY)); + // We're using distance based heuristics to determine if a tile should be split into quadrants or not. + // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center. + // Using the fact that a parent node in quadtree is twice the size of its children (per dimension) + // we can define distance thresholds for each relative level: + // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as "offset+2^(k+1)-2" + const distToSplit = radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2; + // Have we reached the target depth or is the tile too far away to be any split further? + if (it.zoom === maxZoom || (longestDim > distToSplit && it.zoom >= minZoom)) { + const dz = maxZoom - it.zoom, dx = cameraPoint[0] - 0.5 - (x << dz), dy = cameraPoint[1] - 0.5 - (y << dz); + result.push({ + tileID: new performance.OverscaledTileID(it.zoom === maxZoom ? overscaledZ : it.zoom, it.wrap, it.zoom, x, y), + distanceSq: performance.sqrLen([centerPoint[0] - 0.5 - x, centerPoint[1] - 0.5 - y]), + // this variable is currently not used, but may be important to reduce the amount of loaded tiles + tileDistanceToCamera: Math.sqrt(dx * dx + dy * dy) + }); + continue; + } + for (let i = 0; i < 4; i++) { + const childX = (x << 1) + (i % 2); + const childY = (y << 1) + (i >> 1); + const childZ = it.zoom + 1; + let quadrant = it.aabb.quadrant(i); + if (options.terrain) { + const tileID = new performance.OverscaledTileID(childZ, it.wrap, childZ, childX, childY); + const minMax = options.terrain.getMinMaxElevation(tileID); + const minElevation = (_a = minMax.minElevation) !== null && _a !== void 0 ? _a : this.elevation; + const maxElevation = (_b = minMax.maxElevation) !== null && _b !== void 0 ? _b : this.elevation; + quadrant = new Aabb([quadrant.min[0], quadrant.min[1], minElevation], [quadrant.max[0], quadrant.max[1], maxElevation]); + } + stack.push({ aabb: quadrant, zoom: childZ, x: childX, y: childY, wrap: it.wrap, fullyVisible }); + } + } + return result.sort((a, b) => a.distanceSq - b.distanceSq).map(a => a.tileID); + } + resize(width, height) { + this.width = width; + this.height = height; + this.pixelsToGLUnits = [2 / width, -2 / height]; + this._constrain(); + this._calcMatrices(); + } + get unmodified() { return this._unmodified; } + zoomScale(zoom) { return Math.pow(2, zoom); } + scaleZoom(scale) { return Math.log(scale) / Math.LN2; } + project(lnglat) { + const lat = performance.clamp(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude); + return new performance.Point(performance.mercatorXfromLng(lnglat.lng) * this.worldSize, performance.mercatorYfromLat(lat) * this.worldSize); + } + unproject(point) { + return new performance.MercatorCoordinate(point.x / this.worldSize, point.y / this.worldSize).toLngLat(); + } + get point() { return this.project(this.center); } + /** + * get the camera position in LngLat and altitudes in meter + * @returns An object with lngLat & altitude. + */ + getCameraPosition() { + const lngLat = this.pointLocation(this.getCameraPoint()); + const altitude = Math.cos(this._pitch) * this.cameraToCenterDistance / this._pixelPerMeter; + return { lngLat, altitude: altitude + this.elevation }; + } + /** + * This method works in combination with freezeElevation activated. + * freezeElevtion is enabled during map-panning because during this the camera should sit in constant height. + * After panning finished, call this method to recalculate the zoomlevel for the current camera-height in current terrain. + * @param terrain - the terrain + */ + recalculateZoom(terrain) { + // find position the camera is looking on + const center = this.pointLocation(this.centerPoint, terrain); + const elevation = terrain.getElevationForLngLatZoom(center, this.tileZoom); + const deltaElevation = this.elevation - elevation; + if (!deltaElevation) + return; + // calculate mercator distance between camera & target + const cameraPosition = this.getCameraPosition(); + const camera = performance.MercatorCoordinate.fromLngLat(cameraPosition.lngLat, cameraPosition.altitude); + const target = performance.MercatorCoordinate.fromLngLat(center, elevation); + const dx = camera.x - target.x, dy = camera.y - target.y, dz = camera.z - target.z; + const distance = Math.sqrt(dx * dx + dy * dy + dz * dz); + // from this distance we calculate the new zoomlevel + const zoom = this.scaleZoom(this.cameraToCenterDistance / distance / this.tileSize); + // update matrices + this._elevation = elevation; + this._center = center; + this.zoom = zoom; + } + setLocationAtPoint(lnglat, point) { + const a = this.pointCoordinate(point); + const b = this.pointCoordinate(this.centerPoint); + const loc = this.locationCoordinate(lnglat); + const newCenter = new performance.MercatorCoordinate(loc.x - (a.x - b.x), loc.y - (a.y - b.y)); + this.center = this.coordinateLocation(newCenter); + if (this._renderWorldCopies) { + this.center = this.center.wrap(); + } + } + /** + * Given a location, return the screen point that corresponds to it + * @param lnglat - location + * @param terrain - optional terrain + * @returns screen point + */ + locationPoint(lnglat, terrain) { + return terrain ? + this.coordinatePoint(this.locationCoordinate(lnglat), terrain.getElevationForLngLatZoom(lnglat, this.tileZoom), this.pixelMatrix3D) : + this.coordinatePoint(this.locationCoordinate(lnglat)); + } + /** + * Given a point on screen, return its lnglat + * @param p - screen point + * @param terrain - optional terrain + * @returns lnglat location + */ + pointLocation(p, terrain) { + return this.coordinateLocation(this.pointCoordinate(p, terrain)); + } + /** + * Given a geographical lnglat, return an unrounded + * coordinate that represents it at this transform's zoom level. + * @param lnglat - the location + * @returns The mercator coordinate + */ + locationCoordinate(lnglat) { + return performance.MercatorCoordinate.fromLngLat(lnglat); + } + /** + * Given a Coordinate, return its geographical position. + * @param coord - mercator coordivates + * @returns lng and lat + */ + coordinateLocation(coord) { + return coord && coord.toLngLat(); + } + /** + * Given a Point, return its mercator coordinate. + * @param p - the point + * @param terrain - optional terrain + * @returns lnglat + */ + pointCoordinate(p, terrain) { + // get point-coordinate from terrain coordinates framebuffer + if (terrain) { + const coordinate = terrain.pointCoordinate(p); + if (coordinate != null) { + return coordinate; + } + } + // calculate point-coordinate on flat earth + const targetZ = 0; + // since we don't know the correct projected z value for the point, + // unproject two points to get a line and then find the point on that + // line with z=0 + const coord0 = [p.x, p.y, 0, 1]; + const coord1 = [p.x, p.y, 1, 1]; + performance.transformMat4(coord0, coord0, this.pixelMatrixInverse); + performance.transformMat4(coord1, coord1, this.pixelMatrixInverse); + const w0 = coord0[3]; + const w1 = coord1[3]; + const x0 = coord0[0] / w0; + const x1 = coord1[0] / w1; + const y0 = coord0[1] / w0; + const y1 = coord1[1] / w1; + const z0 = coord0[2] / w0; + const z1 = coord1[2] / w1; + const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0); + return new performance.MercatorCoordinate(performance.interpolate.number(x0, x1, t) / this.worldSize, performance.interpolate.number(y0, y1, t) / this.worldSize); + } + /** + * Given a coordinate, return the screen point that corresponds to it + * @param coord - the coordinates + * @param elevation - the elevation + * @param pixelMatrix - the pixel matrix + * @returns screen point + */ + coordinatePoint(coord, elevation = 0, pixelMatrix = this.pixelMatrix) { + const p = [coord.x * this.worldSize, coord.y * this.worldSize, elevation, 1]; + performance.transformMat4(p, p, pixelMatrix); + return new performance.Point(p[0] / p[3], p[1] / p[3]); + } + /** + * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not + * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. + * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds. + */ + getBounds() { + const top = Math.max(0, this.height / 2 - this.getHorizon()); + return new LngLatBounds() + .extend(this.pointLocation(new performance.Point(0, top))) + .extend(this.pointLocation(new performance.Point(this.width, top))) + .extend(this.pointLocation(new performance.Point(this.width, this.height))) + .extend(this.pointLocation(new performance.Point(0, this.height))); + } + /** + * Returns the maximum geographical bounds the map is constrained to, or `null` if none set. + * @returns max bounds + */ + getMaxBounds() { + if (!this.latRange || this.latRange.length !== 2 || + !this.lngRange || this.lngRange.length !== 2) + return null; + return new LngLatBounds([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]); + } + /** + * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2), + * multiplied by a static factor to simulate the earth-radius. + * The calculated value is the horizontal line from the camera-height to sea-level. + * @returns Horizon above center in pixels. + */ + getHorizon() { + return Math.tan(Math.PI / 2 - this._pitch) * this.cameraToCenterDistance * 0.85; + } + /** + * Sets or clears the map's geographical constraints. + * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map. + */ + setMaxBounds(bounds) { + if (bounds) { + this.lngRange = [bounds.getWest(), bounds.getEast()]; + this.latRange = [bounds.getSouth(), bounds.getNorth()]; + this._constrain(); + } + else { + this.lngRange = null; + this.latRange = [-this.maxValidLatitude, this.maxValidLatitude]; + } + } + /** + * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map. + * @param unwrappedTileID - the tile ID + */ + calculatePosMatrix(unwrappedTileID, aligned = false) { + const posMatrixKey = unwrappedTileID.key; + const cache = aligned ? this._alignedPosMatrixCache : this._posMatrixCache; + if (cache[posMatrixKey]) { + return cache[posMatrixKey]; + } + const canonical = unwrappedTileID.canonical; + const scale = this.worldSize / this.zoomScale(canonical.z); + const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap; + const posMatrix = performance.identity(new Float64Array(16)); + performance.translate(posMatrix, posMatrix, [unwrappedX * scale, canonical.y * scale, 0]); + performance.scale(posMatrix, posMatrix, [scale / performance.EXTENT, scale / performance.EXTENT, 1]); + performance.multiply(posMatrix, aligned ? this.alignedProjMatrix : this.projMatrix, posMatrix); + cache[posMatrixKey] = new Float32Array(posMatrix); + return cache[posMatrixKey]; + } + customLayerMatrix() { + return this.mercatorMatrix.slice(); + } + _constrain() { + if (!this.center || !this.width || !this.height || this._constraining) + return; + this._constraining = true; + let minY = -90; + let maxY = 90; + let minX = -180; + let maxX = 180; + let sy, sx, x2, y2; + const size = this.size, unmodified = this._unmodified; + if (this.latRange) { + const latRange = this.latRange; + minY = performance.mercatorYfromLat(latRange[1]) * this.worldSize; + maxY = performance.mercatorYfromLat(latRange[0]) * this.worldSize; + sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0; + } + if (this.lngRange) { + const lngRange = this.lngRange; + minX = performance.wrap(performance.mercatorXfromLng(lngRange[0]) * this.worldSize, 0, this.worldSize); + maxX = performance.wrap(performance.mercatorXfromLng(lngRange[1]) * this.worldSize, 0, this.worldSize); + if (maxX < minX) + maxX += this.worldSize; + sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0; + } + const point = this.point; + // how much the map should scale to fit the screen into given latitude/longitude ranges + const s = Math.max(sx || 0, sy || 0); + if (s) { + this.center = this.unproject(new performance.Point(sx ? (maxX + minX) / 2 : point.x, sy ? (maxY + minY) / 2 : point.y)); + this.zoom += this.scaleZoom(s); + this._unmodified = unmodified; + this._constraining = false; + return; + } + if (this.latRange) { + const y = point.y, h2 = size.y / 2; + if (y - h2 < minY) + y2 = minY + h2; + if (y + h2 > maxY) + y2 = maxY - h2; + } + if (this.lngRange) { + const centerX = (minX + maxX) / 2; + const x = performance.wrap(point.x, centerX - this.worldSize / 2, centerX + this.worldSize / 2); + const w2 = size.x / 2; + if (x - w2 < minX) + x2 = minX + w2; + if (x + w2 > maxX) + x2 = maxX - w2; + } + // pan the map if the screen goes off the range + if (x2 !== undefined || y2 !== undefined) { + this.center = this.unproject(new performance.Point(x2 !== undefined ? x2 : point.x, y2 !== undefined ? y2 : point.y)).wrap(); + } + this._unmodified = unmodified; + this._constraining = false; + } + _calcMatrices() { + if (!this.height) + return; + const halfFov = this._fov / 2; + const offset = this.centerOffset; + const x = this.point.x, y = this.point.y; + this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height; + this._pixelPerMeter = performance.mercatorZfromAltitude(1, this.center.lat) * this.worldSize; + let m = performance.identity(new Float64Array(16)); + performance.scale(m, m, [this.width / 2, -this.height / 2, 1]); + performance.translate(m, m, [1, -1, 0]); + this.labelPlaneMatrix = m; + m = performance.identity(new Float64Array(16)); + performance.scale(m, m, [1, -1, 1]); + performance.translate(m, m, [-1, -1, 0]); + performance.scale(m, m, [2 / this.width, 2 / this.height, 1]); + this.glCoordMatrix = m; + // Calculate the camera to sea-level distance in pixel in respect of terrain + const cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch); + // In case of negative minimum elevation (e.g. the dead see, under the sea maps) use a lower plane for calculation + const minElevation = Math.min(this.elevation, this._minEleveationForCurrentTile); + const cameraToLowestPointDistance = cameraToSeaLevelDistance - minElevation * this._pixelPerMeter / Math.cos(this._pitch); + const lowestPlane = minElevation < 0 ? cameraToLowestPointDistance : cameraToSeaLevelDistance; + // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the + // center top point [width/2 + offset.x, 0] in Z units, using the law of sines. + // 1 Z unit is equivalent to 1 horizontal px at the center of the map + // (the distance between[width/2, height/2] and [width/2 + 1, height/2]) + const groundAngle = Math.PI / 2 + this._pitch; + const fovAboveCenter = this._fov * (0.5 + offset.y / this.height); + const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * lowestPlane / Math.sin(performance.clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01)); + // Find the distance from the center point to the horizon + const horizon = this.getHorizon(); + const horizonAngle = Math.atan(horizon / this.cameraToCenterDistance); + const fovCenterToHorizon = 2 * horizonAngle * (0.5 + offset.y / (horizon * 2)); + const topHalfSurfaceDistanceHorizon = Math.sin(fovCenterToHorizon) * lowestPlane / Math.sin(performance.clamp(Math.PI - groundAngle - fovCenterToHorizon, 0.01, Math.PI - 0.01)); + // Calculate z distance of the farthest fragment that should be rendered. + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + const topHalfMinDistance = Math.min(topHalfSurfaceDistance, topHalfSurfaceDistanceHorizon); + const farZ = (Math.cos(Math.PI / 2 - this._pitch) * topHalfMinDistance + lowestPlane) * 1.01; + // The larger the value of nearZ is + // - the more depth precision is available for features (good) + // - clipping starts appearing sooner when the camera is close to 3d features (bad) + // + // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues + // when rendering it's layers using custom layers. This value was experimentally chosen and + // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera. + const nearZ = this.height / 50; + // matrix for conversion from location to GL coordinates (-1 .. 1) + m = new Float64Array(16); + performance.perspective(m, this._fov, this.width / this.height, nearZ, farZ); + // Apply center of perspective offset + m[8] = -offset.x * 2 / this.width; + m[9] = offset.y * 2 / this.height; + performance.scale(m, m, [1, -1, 1]); + performance.translate(m, m, [0, 0, -this.cameraToCenterDistance]); + performance.rotateX(m, m, this._pitch); + performance.rotateZ(m, m, this.angle); + performance.translate(m, m, [-x, -y, 0]); + // The mercatorMatrix can be used to transform points from mercator coordinates + // ([0, 0] nw, [1, 1] se) to GL coordinates. + this.mercatorMatrix = performance.scale([], m, [this.worldSize, this.worldSize, this.worldSize]); + // scale vertically to meters per pixel (inverse of ground resolution): + performance.scale(m, m, [1, 1, this._pixelPerMeter]); + // matrix for conversion from location to screen coordinates in 2D + this.pixelMatrix = performance.multiply(new Float64Array(16), this.labelPlaneMatrix, m); + // matrix for conversion from location to GL coordinates (-1 .. 1) + performance.translate(m, m, [0, 0, -this.elevation]); // elevate camera over terrain + this.projMatrix = m; + this.invProjMatrix = performance.invert([], m); + // matrix for conversion from location to screen coordinates in 2D + this.pixelMatrix3D = performance.multiply(new Float64Array(16), this.labelPlaneMatrix, m); + // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles. + // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional + // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension + // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle + // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that + // it is always <= 0.5 pixels. + const xShift = (this.width % 2) / 2, yShift = (this.height % 2) / 2, angleCos = Math.cos(this.angle), angleSin = Math.sin(this.angle), dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift, dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift; + const alignedM = new Float64Array(m); + performance.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]); + this.alignedProjMatrix = alignedM; + // inverse matrix for conversion from screen coordinaes to location + m = performance.invert(new Float64Array(16), this.pixelMatrix); + if (!m) + throw new Error('failed to invert matrix'); + this.pixelMatrixInverse = m; + this._posMatrixCache = {}; + this._alignedPosMatrixCache = {}; + } + maxPitchScaleFactor() { + // calcMatrices hasn't run yet + if (!this.pixelMatrixInverse) + return 1; + const coord = this.pointCoordinate(new performance.Point(0, 0)); + const p = [coord.x * this.worldSize, coord.y * this.worldSize, 0, 1]; + const topPoint = performance.transformMat4(p, p, this.pixelMatrix); + return topPoint[3] / this.cameraToCenterDistance; + } + /** + * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation` + * as the name for the location under the camera and on the surface of the earth (lng, lat, 0). + * `cameraPoint` is the projected position of the `cameraLocation`. + * + * This point is useful to us because only fill-extrusions that are between `cameraPoint` and + * the query point on the surface of the earth can extend and intersect the query. + * + * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because + * the camera is right above the center of the map. + */ + getCameraPoint() { + const pitch = this._pitch; + const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1); + return this.centerPoint.add(new performance.Point(0, yOffset)); + } + /** + * When the map is pitched, some of the 3D features that intersect a query will not intersect + * the query at the surface of the earth. Instead the feature may be closer and only intersect + * the query because it extrudes into the air. + * @param queryGeometry - For point queries, the line from the query point to the "camera point", + * for other geometries, the envelope of the query geometry and the "camera point" + * @returns a geometry that includes all of the original query as well as all possible ares of the + * screen where the *base* of a visible extrusion could be. + * + */ + getCameraQueryGeometry(queryGeometry) { + const c = this.getCameraPoint(); + if (queryGeometry.length === 1) { + return [queryGeometry[0], c]; + } + else { + let minX = c.x; + let minY = c.y; + let maxX = c.x; + let maxY = c.y; + for (const p of queryGeometry) { + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + return [ + new performance.Point(minX, minY), + new performance.Point(maxX, minY), + new performance.Point(maxX, maxY), + new performance.Point(minX, maxY), + new performance.Point(minX, minY) + ]; + } + } +} + +/** + * Throttle the given function to run at most every `period` milliseconds. + */ +function throttle(fn, time) { + let pending = false; + let timerId = null; + let lastCallContext = null; + let lastCallArgs; + const later = () => { + timerId = null; + if (pending) { + fn.apply(lastCallContext, lastCallArgs); + timerId = setTimeout(later, time); + pending = false; + } + }; + return (...args) => { + pending = true; + lastCallContext = this; + lastCallArgs = args; + if (!timerId) { + later(); + } + return timerId; + }; +} + +/** + * Adds the map's position to its page's location hash. + * Passed as an option to the map object. + * + * @group Markers and Controls + */ +class Hash { + constructor(hashName) { + this._getCurrentHash = () => { + // Get the current hash from location, stripped from its number sign + const hash = window.location.hash.replace('#', ''); + if (this._hashName) { + // Split the parameter-styled hash into parts and find the value we need + let keyval; + hash.split('&').map(part => part.split('=')).forEach(part => { + if (part[0] === this._hashName) { + keyval = part; + } + }); + return (keyval ? keyval[1] || '' : '').split('/'); + } + return hash.split('/'); + }; + this._onHashChange = () => { + const loc = this._getCurrentHash(); + if (loc.length >= 3 && !loc.some(v => isNaN(v))) { + const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this._map.getBearing(); + this._map.jumpTo({ + center: [+loc[2], +loc[1]], + zoom: +loc[0], + bearing, + pitch: +(loc[4] || 0) + }); + return true; + } + return false; + }; + this._updateHashUnthrottled = () => { + // Replace if already present, else append the updated hash string + const location = window.location.href.replace(/(#.+)?$/, this.getHashString()); + try { + window.history.replaceState(window.history.state, null, location); + } + catch (SecurityError) { + // IE11 does not allow this if the page is within an iframe created + // with iframe.contentWindow.document.write(...). + // https://github.com/mapbox/mapbox-gl-js/issues/7410 + } + }; + /** + * Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds. + */ + this._updateHash = throttle(this._updateHashUnthrottled, 30 * 1000 / 100); + this._hashName = hashName && encodeURIComponent(hashName); + } + /** + * Map element to listen for coordinate changes + * + * @param map - The map object + * @returns `this` + */ + addTo(map) { + this._map = map; + addEventListener('hashchange', this._onHashChange, false); + this._map.on('moveend', this._updateHash); + return this; + } + /** + * Removes hash + * + * @returns `this` + */ + remove() { + removeEventListener('hashchange', this._onHashChange, false); + this._map.off('moveend', this._updateHash); + clearTimeout(this._updateHash()); + delete this._map; + return this; + } + getHashString(mapFeedback) { + const center = this._map.getCenter(), zoom = Math.round(this._map.getZoom() * 100) / 100, + // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px + precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10), m = Math.pow(10, precision), lng = Math.round(center.lng * m) / m, lat = Math.round(center.lat * m) / m, bearing = this._map.getBearing(), pitch = this._map.getPitch(); + let hash = ''; + if (mapFeedback) { + // new map feedback site has some constraints that don't allow + // us to use the same hash format as we do for the Map hash option. + hash += `/${lng}/${lat}/${zoom}`; + } + else { + hash += `${zoom}/${lat}/${lng}`; + } + if (bearing || pitch) + hash += (`/${Math.round(bearing * 10) / 10}`); + if (pitch) + hash += (`/${Math.round(pitch)}`); + if (this._hashName) { + const hashName = this._hashName; + let found = false; + const parts = window.location.hash.slice(1).split('&').map(part => { + const key = part.split('=')[0]; + if (key === hashName) { + found = true; + return `${key}=${hash}`; + } + return part; + }).filter(a => a); + if (!found) { + parts.push(`${hashName}=${hash}`); + } + return `#${parts.join('&')}`; + } + return `#${hash}`; + } +} + +const defaultInertiaOptions = { + linearity: 0.3, + easing: performance.bezier(0, 0, 0.3, 1), +}; +const defaultPanInertiaOptions = performance.extend({ + deceleration: 2500, + maxSpeed: 1400 +}, defaultInertiaOptions); +const defaultZoomInertiaOptions = performance.extend({ + deceleration: 20, + maxSpeed: 1400 +}, defaultInertiaOptions); +const defaultBearingInertiaOptions = performance.extend({ + deceleration: 1000, + maxSpeed: 360 +}, defaultInertiaOptions); +const defaultPitchInertiaOptions = performance.extend({ + deceleration: 1000, + maxSpeed: 90 +}, defaultInertiaOptions); +class HandlerInertia { + constructor(map) { + this._map = map; + this.clear(); + } + clear() { + this._inertiaBuffer = []; + } + record(settings) { + this._drainInertiaBuffer(); + this._inertiaBuffer.push({ time: performance.browser.now(), settings }); + } + _drainInertiaBuffer() { + const inertia = this._inertiaBuffer, now = performance.browser.now(), cutoff = 160; //msec + while (inertia.length > 0 && now - inertia[0].time > cutoff) + inertia.shift(); + } + _onMoveEnd(panInertiaOptions) { + this._drainInertiaBuffer(); + if (this._inertiaBuffer.length < 2) { + return; + } + const deltas = { + zoom: 0, + bearing: 0, + pitch: 0, + pan: new performance.Point(0, 0), + pinchAround: undefined, + around: undefined + }; + for (const { settings } of this._inertiaBuffer) { + deltas.zoom += settings.zoomDelta || 0; + deltas.bearing += settings.bearingDelta || 0; + deltas.pitch += settings.pitchDelta || 0; + if (settings.panDelta) + deltas.pan._add(settings.panDelta); + if (settings.around) + deltas.around = settings.around; + if (settings.pinchAround) + deltas.pinchAround = settings.pinchAround; + } + const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1]; + const duration = (lastEntry.time - this._inertiaBuffer[0].time); + const easeOptions = {}; + if (deltas.pan.mag()) { + const result = calculateEasing(deltas.pan.mag(), duration, performance.extend({}, defaultPanInertiaOptions, panInertiaOptions || {})); + easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag()); + easeOptions.center = this._map.transform.center; + extendDuration(easeOptions, result); + } + if (deltas.zoom) { + const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions); + easeOptions.zoom = this._map.transform.zoom + result.amount; + extendDuration(easeOptions, result); + } + if (deltas.bearing) { + const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions); + easeOptions.bearing = this._map.transform.bearing + performance.clamp(result.amount, -179, 179); + extendDuration(easeOptions, result); + } + if (deltas.pitch) { + const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions); + easeOptions.pitch = this._map.transform.pitch + result.amount; + extendDuration(easeOptions, result); + } + if (easeOptions.zoom || easeOptions.bearing) { + const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround; + easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter(); + } + this.clear(); + return performance.extend(easeOptions, { + noMoveStart: true + }); + } +} +// Unfortunately zoom, bearing, etc can't have different durations and easings so +// we need to choose one. We use the longest duration and it's corresponding easing. +function extendDuration(easeOptions, result) { + if (!easeOptions.duration || easeOptions.duration < result.duration) { + easeOptions.duration = result.duration; + easeOptions.easing = result.easing; + } +} +function calculateEasing(amount, inertiaDuration, inertiaOptions) { + const { maxSpeed, linearity, deceleration } = inertiaOptions; + const speed = performance.clamp(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed); + const duration = Math.abs(speed) / (deceleration * linearity); + return { + easing: inertiaOptions.easing, + duration: duration * 1000, + amount: speed * (duration / 2) + }; +} + +/** + * `MapMouseEvent` is the event type for mouse-related map events. + * @example + * ```ts + * // The `click` event is an example of a `MapMouseEvent`. + * // Set up an event listener on the map. + * map.on('click', function(e) { + * // The event object (e) contains information like the + * // coordinates of the point on the map that was clicked. + * console.log('A click event has occurred at ' + e.lngLat); + * }); + * ``` + */ +class MapMouseEvent extends performance.Event { + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the following default map behaviors: + * + * * On `mousedown` events, the behavior of {@link DragPanHandler} + * * On `mousedown` events, the behavior of {@link DragRotateHandler} + * * On `mousedown` events, the behavior of {@link BoxZoomHandler} + * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler} + * + */ + preventDefault() { + this._defaultPrevented = true; + } + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented() { + return this._defaultPrevented; + } + constructor(type, map, originalEvent, data = {}) { + const point = DOM.mousePos(map.getCanvasContainer(), originalEvent); + const lngLat = map.unproject(point); + super(type, performance.extend({ point, lngLat, originalEvent }, data)); + this._defaultPrevented = false; + this.target = map; + } +} +/** + * `MapTouchEvent` is the event type for touch-related map events. + * + * @group Event Related + */ +class MapTouchEvent extends performance.Event { + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the following default map behaviors: + * + * * On `touchstart` events, the behavior of {@link DragPanHandler} + * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler} + * + */ + preventDefault() { + this._defaultPrevented = true; + } + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented() { + return this._defaultPrevented; + } + constructor(type, map, originalEvent) { + const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches; + const points = DOM.touchPos(map.getCanvasContainer(), touches); + const lngLats = points.map((t) => map.unproject(t)); + const point = points.reduce((prev, curr, i, arr) => { + return prev.add(curr.div(arr.length)); + }, new performance.Point(0, 0)); + const lngLat = map.unproject(point); + super(type, { points, point, lngLats, lngLat, originalEvent }); + this._defaultPrevented = false; + } +} +/** + * `MapWheelEvent` is the event type for the `wheel` map event. + * + * @group Event Related + */ +class MapWheelEvent extends performance.Event { + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the behavior of {@link ScrollZoomHandler}. + */ + preventDefault() { + this._defaultPrevented = true; + } + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented() { + return this._defaultPrevented; + } + /** */ + constructor(type, map, originalEvent) { + super(type, { originalEvent }); + this._defaultPrevented = false; + } +} + +class MapEventHandler { + constructor(map, options) { + this._map = map; + this._clickTolerance = options.clickTolerance; + } + reset() { + delete this._mousedownPos; + } + wheel(e) { + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - ScrollZoom + return this._firePreventable(new MapWheelEvent(e.type, this._map, e)); + } + mousedown(e, point) { + this._mousedownPos = point; + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - MousePan + // - MouseRotate + // - MousePitch + // - DblclickHandler + return this._firePreventable(new MapMouseEvent(e.type, this._map, e)); + } + mouseup(e) { + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + click(e, point) { + if (this._mousedownPos && this._mousedownPos.dist(point) >= this._clickTolerance) + return; + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + dblclick(e) { + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - DblClickZoom + return this._firePreventable(new MapMouseEvent(e.type, this._map, e)); + } + mouseover(e) { + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + mouseout(e) { + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + touchstart(e) { + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - TouchPan + // - TouchZoom + // - TouchRotate + // - TouchPitch + // - TapZoom + // - SwipeZoom + return this._firePreventable(new MapTouchEvent(e.type, this._map, e)); + } + touchmove(e) { + this._map.fire(new MapTouchEvent(e.type, this._map, e)); + } + touchend(e) { + this._map.fire(new MapTouchEvent(e.type, this._map, e)); + } + touchcancel(e) { + this._map.fire(new MapTouchEvent(e.type, this._map, e)); + } + _firePreventable(mapEvent) { + this._map.fire(mapEvent); + if (mapEvent.defaultPrevented) { + // returning an object marks the handler as active and resets other handlers + return {}; + } + } + isEnabled() { + return true; + } + isActive() { + return false; + } + enable() { } + disable() { } +} +class BlockableMapEventHandler { + constructor(map) { + this._map = map; + } + reset() { + this._delayContextMenu = false; + this._ignoreContextMenu = true; + delete this._contextMenuEvent; + } + mousemove(e) { + // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + mousedown() { + this._delayContextMenu = true; + this._ignoreContextMenu = false; + } + mouseup() { + this._delayContextMenu = false; + if (this._contextMenuEvent) { + this._map.fire(new MapMouseEvent('contextmenu', this._map, this._contextMenuEvent)); + delete this._contextMenuEvent; + } + } + contextmenu(e) { + if (this._delayContextMenu) { + // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake + this._contextMenuEvent = e; + } + else if (!this._ignoreContextMenu) { + // Windows: contextmenu fired on mouseup, so fire event now + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + // prevent browser context menu when necessary + if (this._map.listens('contextmenu')) { + e.preventDefault(); + } + } + isEnabled() { + return true; + } + isActive() { + return false; + } + enable() { } + disable() { } +} + +/** + * @internal + * Shared utilities for the Handler classes to access the correct camera state. + * If Camera.transformCameraUpdate is specified, the "desired state" of camera may differ from the state used for rendering. + * The handlers need the "desired state" to track accumulated changes. + */ +class TransformProvider { + constructor(map) { + this._map = map; + } + get transform() { + return this._map._requestedCameraState || this._map.transform; + } + get center() { + return { lng: this.transform.center.lng, lat: this.transform.center.lat }; + } + get zoom() { + return this.transform.zoom; + } + get pitch() { + return this.transform.pitch; + } + get bearing() { + return this.transform.bearing; + } + unproject(point) { + return this.transform.pointLocation(performance.Point.convert(point), this._map.terrain); + } +} + +/** + * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box. + * The bounding box is defined by clicking and holding `shift` while dragging the cursor. + * + * @group Handlers + */ +class BoxZoomHandler { + /** @internal */ + constructor(map, options) { + this._map = map; + this._tr = new TransformProvider(map); + this._el = map.getCanvasContainer(); + this._container = map.getContainer(); + this._clickTolerance = options.clickTolerance || 1; + } + /** + * Returns a Boolean indicating whether the "box zoom" interaction is enabled. + * + * @returns `true` if the "box zoom" interaction is enabled. + */ + isEnabled() { + return !!this._enabled; + } + /** + * Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used. + * + * @returns `true` if the "box zoom" interaction is active. + */ + isActive() { + return !!this._active; + } + /** + * Enables the "box zoom" interaction. + * + * @example + * ```ts + * map.boxZoom.enable(); + * ``` + */ + enable() { + if (this.isEnabled()) + return; + this._enabled = true; + } + /** + * Disables the "box zoom" interaction. + * + * @example + * ```ts + * map.boxZoom.disable(); + * ``` + */ + disable() { + if (!this.isEnabled()) + return; + this._enabled = false; + } + mousedown(e, point) { + if (!this.isEnabled()) + return; + if (!(e.shiftKey && e.button === 0)) + return; + DOM.disableDrag(); + this._startPos = this._lastPos = point; + this._active = true; + } + mousemoveWindow(e, point) { + if (!this._active) + return; + const pos = point; + if (this._lastPos.equals(pos) || (!this._box && pos.dist(this._startPos) < this._clickTolerance)) { + return; + } + const p0 = this._startPos; + this._lastPos = pos; + if (!this._box) { + this._box = DOM.create('div', 'maplibregl-boxzoom', this._container); + this._container.classList.add('maplibregl-crosshair'); + this._fireEvent('boxzoomstart', e); + } + const minX = Math.min(p0.x, pos.x), maxX = Math.max(p0.x, pos.x), minY = Math.min(p0.y, pos.y), maxY = Math.max(p0.y, pos.y); + DOM.setTransform(this._box, `translate(${minX}px,${minY}px)`); + this._box.style.width = `${maxX - minX}px`; + this._box.style.height = `${maxY - minY}px`; + } + mouseupWindow(e, point) { + if (!this._active) + return; + if (e.button !== 0) + return; + const p0 = this._startPos, p1 = point; + this.reset(); + DOM.suppressClick(); + if (p0.x === p1.x && p0.y === p1.y) { + this._fireEvent('boxzoomcancel', e); + } + else { + this._map.fire(new performance.Event('boxzoomend', { originalEvent: e })); + return { + cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this._tr.bearing, { linear: true }) + }; + } + } + keydown(e) { + if (!this._active) + return; + if (e.keyCode === 27) { + this.reset(); + this._fireEvent('boxzoomcancel', e); + } + } + reset() { + this._active = false; + this._container.classList.remove('maplibregl-crosshair'); + if (this._box) { + DOM.remove(this._box); + this._box = null; + } + DOM.enableDrag(); + delete this._startPos; + delete this._lastPos; + } + _fireEvent(type, e) { + return this._map.fire(new performance.Event(type, { originalEvent: e })); + } +} + +function indexTouches(touches, points) { + if (touches.length !== points.length) + throw new Error(`The number of touches and points are not equal - touches ${touches.length}, points ${points.length}`); + const obj = {}; + for (let i = 0; i < touches.length; i++) { + obj[touches[i].identifier] = points[i]; + } + return obj; +} + +function getCentroid(points) { + const sum = new performance.Point(0, 0); + for (const point of points) { + sum._add(point); + } + return sum.div(points.length); +} +const MAX_TAP_INTERVAL = 500; +const MAX_TOUCH_TIME = 500; +const MAX_DIST = 30; +class SingleTapRecognizer { + constructor(options) { + this.reset(); + this.numTouches = options.numTouches; + } + reset() { + delete this.centroid; + delete this.startTime; + delete this.touches; + this.aborted = false; + } + touchstart(e, points, mapTouches) { + if (this.centroid || mapTouches.length > this.numTouches) { + this.aborted = true; + } + if (this.aborted) { + return; + } + if (this.startTime === undefined) { + this.startTime = e.timeStamp; + } + if (mapTouches.length === this.numTouches) { + this.centroid = getCentroid(points); + this.touches = indexTouches(mapTouches, points); + } + } + touchmove(e, points, mapTouches) { + if (this.aborted || !this.centroid) + return; + const newTouches = indexTouches(mapTouches, points); + for (const id in this.touches) { + const prevPos = this.touches[id]; + const pos = newTouches[id]; + if (!pos || pos.dist(prevPos) > MAX_DIST) { + this.aborted = true; + } + } + } + touchend(e, points, mapTouches) { + if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) { + this.aborted = true; + } + if (mapTouches.length === 0) { + const centroid = !this.aborted && this.centroid; + this.reset(); + if (centroid) + return centroid; + } + } +} +class TapRecognizer { + constructor(options) { + this.singleTap = new SingleTapRecognizer(options); + this.numTaps = options.numTaps; + this.reset(); + } + reset() { + this.lastTime = Infinity; + delete this.lastTap; + this.count = 0; + this.singleTap.reset(); + } + touchstart(e, points, mapTouches) { + this.singleTap.touchstart(e, points, mapTouches); + } + touchmove(e, points, mapTouches) { + this.singleTap.touchmove(e, points, mapTouches); + } + touchend(e, points, mapTouches) { + const tap = this.singleTap.touchend(e, points, mapTouches); + if (tap) { + const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL; + const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST; + if (!soonEnough || !closeEnough) { + this.reset(); + } + this.count++; + this.lastTime = e.timeStamp; + this.lastTap = tap; + if (this.count === this.numTaps) { + this.reset(); + return tap; + } + } + } +} + +class TapZoomHandler { + constructor(map) { + this._tr = new TransformProvider(map); + this._zoomIn = new TapRecognizer({ + numTouches: 1, + numTaps: 2 + }); + this._zoomOut = new TapRecognizer({ + numTouches: 2, + numTaps: 1 + }); + this.reset(); + } + reset() { + this._active = false; + this._zoomIn.reset(); + this._zoomOut.reset(); + } + touchstart(e, points, mapTouches) { + this._zoomIn.touchstart(e, points, mapTouches); + this._zoomOut.touchstart(e, points, mapTouches); + } + touchmove(e, points, mapTouches) { + this._zoomIn.touchmove(e, points, mapTouches); + this._zoomOut.touchmove(e, points, mapTouches); + } + touchend(e, points, mapTouches) { + const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches); + const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches); + const tr = this._tr; + if (zoomInPoint) { + this._active = true; + e.preventDefault(); + setTimeout(() => this.reset(), 0); + return { + cameraAnimation: (map) => map.easeTo({ + duration: 300, + zoom: tr.zoom + 1, + around: tr.unproject(zoomInPoint) + }, { originalEvent: e }) + }; + } + else if (zoomOutPoint) { + this._active = true; + e.preventDefault(); + setTimeout(() => this.reset(), 0); + return { + cameraAnimation: (map) => map.easeTo({ + duration: 300, + zoom: tr.zoom - 1, + around: tr.unproject(zoomOutPoint) + }, { originalEvent: e }) + }; + } + } + touchcancel() { + this.reset(); + } + enable() { + this._enabled = true; + } + disable() { + this._enabled = false; + this.reset(); + } + isEnabled() { + return this._enabled; + } + isActive() { + return this._active; + } +} + +/** + * A generic class to create handlers for drag events, from both mouse and touch events. + */ +class DragHandler { + constructor(options) { + this._enabled = !!options.enable; + this._moveStateManager = options.moveStateManager; + this._clickTolerance = options.clickTolerance || 1; + this._moveFunction = options.move; + this._activateOnStart = !!options.activateOnStart; + options.assignEvents(this); + this.reset(); + } + reset(e) { + this._active = false; + this._moved = false; + delete this._lastPoint; + this._moveStateManager.endMove(e); + } + _move(...params) { + const move = this._moveFunction(...params); + if (move.bearingDelta || move.pitchDelta || move.around || move.panDelta) { + this._active = true; + return move; + } + } + dragStart(e, point) { + if (!this.isEnabled() || this._lastPoint) + return; + if (!this._moveStateManager.isValidStartEvent(e)) + return; + this._moveStateManager.startMove(e); + this._lastPoint = point['length'] ? point[0] : point; + if (this._activateOnStart && this._lastPoint) + this._active = true; + } + dragMove(e, point) { + if (!this.isEnabled()) + return; + const lastPoint = this._lastPoint; + if (!lastPoint) + return; + e.preventDefault(); + if (!this._moveStateManager.isValidMoveEvent(e)) { + this.reset(e); + return; + } + const movePoint = point['length'] ? point[0] : point; + if (!this._moved && movePoint.dist(lastPoint) < this._clickTolerance) + return; + this._moved = true; + this._lastPoint = movePoint; + return this._move(lastPoint, movePoint); + } + dragEnd(e) { + if (!this.isEnabled() || !this._lastPoint) + return; + if (!this._moveStateManager.isValidEndEvent(e)) + return; + if (this._moved) + DOM.suppressClick(); + this.reset(e); + } + enable() { + this._enabled = true; + } + disable() { + this._enabled = false; + this.reset(); + } + isEnabled() { + return this._enabled; + } + isActive() { + return this._active; + } + getClickTolerance() { + return this._clickTolerance; + } +} + +const LEFT_BUTTON$1 = 0; +const RIGHT_BUTTON$1 = 2; +// the values for each button in MouseEvent.buttons +const BUTTONS_FLAGS = { + [LEFT_BUTTON$1]: 1, + [RIGHT_BUTTON$1]: 2 +}; +function buttonNoLongerPressed(e, button) { + const flag = BUTTONS_FLAGS[button]; + return e.buttons === undefined || (e.buttons & flag) !== flag; +} +class MouseMoveStateManager { + constructor(options) { + this._correctEvent = options.checkCorrectEvent; + } + startMove(e) { + const eventButton = DOM.mouseButton(e); + this._eventButton = eventButton; + } + endMove(_e) { + delete this._eventButton; + } + isValidStartEvent(e) { + return this._correctEvent(e); + } + isValidMoveEvent(e) { + // Some browsers don't fire a `mouseup` when the mouseup occurs outside + // the window or iframe: + // https://github.com/mapbox/mapbox-gl-js/issues/4622 + // + // If the button is no longer pressed during this `mousemove` it may have + // been released outside of the window or iframe. + return !buttonNoLongerPressed(e, this._eventButton); + } + isValidEndEvent(e) { + const eventButton = DOM.mouseButton(e); + return eventButton === this._eventButton; + } +} +class OneFingerTouchMoveStateManager { + constructor() { + this._firstTouch = undefined; + } + _isOneFingerTouch(e) { + return e.targetTouches.length === 1; + } + _isSameTouchEvent(e) { + return e.targetTouches[0].identifier === this._firstTouch; + } + startMove(e) { + const firstTouch = e.targetTouches[0].identifier; + this._firstTouch = firstTouch; + } + endMove(_e) { + delete this._firstTouch; + } + isValidStartEvent(e) { + return this._isOneFingerTouch(e); + } + isValidMoveEvent(e) { + return this._isOneFingerTouch(e) && this._isSameTouchEvent(e); + } + isValidEndEvent(e) { + return this._isOneFingerTouch(e) && this._isSameTouchEvent(e); + } +} + +const LEFT_BUTTON = 0; +const RIGHT_BUTTON = 2; +const assignEvents$1 = (handler) => { + handler.mousedown = handler.dragStart; + handler.mousemoveWindow = handler.dragMove; + handler.mouseup = handler.dragEnd; + handler.contextmenu = function (e) { + e.preventDefault(); + }; +}; +const generateMousePanHandler = ({ enable, clickTolerance, }) => { + const mouseMoveStateManager = new MouseMoveStateManager({ + checkCorrectEvent: (e) => DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey, + }); + return new DragHandler({ + clickTolerance, + move: (lastPoint, point) => ({ around: point, panDelta: point.sub(lastPoint) }), + activateOnStart: true, + moveStateManager: mouseMoveStateManager, + enable, + assignEvents: assignEvents$1, + }); +}; +const generateMouseRotationHandler = ({ enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8 }) => { + const mouseMoveStateManager = new MouseMoveStateManager({ + checkCorrectEvent: (e) => (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) || + (DOM.mouseButton(e) === RIGHT_BUTTON), + }); + return new DragHandler({ + clickTolerance, + move: (lastPoint, point) => ({ bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved }), + // prevent browser context menu when necessary; we don't allow it with rotation + // because we can't discern rotation gesture start from contextmenu on Mac + moveStateManager: mouseMoveStateManager, + enable, + assignEvents: assignEvents$1, + }); +}; +const generateMousePitchHandler = ({ enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5 }) => { + const mouseMoveStateManager = new MouseMoveStateManager({ + checkCorrectEvent: (e) => (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) || + (DOM.mouseButton(e) === RIGHT_BUTTON), + }); + return new DragHandler({ + clickTolerance, + move: (lastPoint, point) => ({ pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved }), + // prevent browser context menu when necessary; we don't allow it with rotation + // because we can't discern rotation gesture start from contextmenu on Mac + moveStateManager: mouseMoveStateManager, + enable, + assignEvents: assignEvents$1, + }); +}; + +class TouchPanHandler { + constructor(options, map) { + this._minTouches = options.cooperativeGestures ? 2 : 1; + this._clickTolerance = options.clickTolerance || 1; + this._map = map; + this.reset(); + } + reset() { + this._active = false; + this._touches = {}; + this._sum = new performance.Point(0, 0); + // Put a delay on the cooperative gesture message so it's less twitchy + setTimeout(() => { + this._cancelCooperativeMessage = false; + }, 200); + } + touchstart(e, points, mapTouches) { + return this._calculateTransform(e, points, mapTouches); + } + touchmove(e, points, mapTouches) { + if (this._map._cooperativeGestures) { + if (this._minTouches === 2 && mapTouches.length < 2 && !this._cancelCooperativeMessage) { + // If coop gesture enabled, show panning info to user + this._map._onCooperativeGesture(e, false, mapTouches.length); + } + else if (!this._cancelCooperativeMessage) { + // If user is successfully navigating, we don't need this warning until the touch resets + this._cancelCooperativeMessage = true; + } + } + if (!this._active || mapTouches.length < this._minTouches) + return; + e.preventDefault(); + return this._calculateTransform(e, points, mapTouches); + } + touchend(e, points, mapTouches) { + this._calculateTransform(e, points, mapTouches); + if (this._active && mapTouches.length < this._minTouches) { + this.reset(); + } + } + touchcancel() { + this.reset(); + } + _calculateTransform(e, points, mapTouches) { + if (mapTouches.length > 0) + this._active = true; + const touches = indexTouches(mapTouches, points); + const touchPointSum = new performance.Point(0, 0); + const touchDeltaSum = new performance.Point(0, 0); + let touchDeltaCount = 0; + for (const identifier in touches) { + const point = touches[identifier]; + const prevPoint = this._touches[identifier]; + if (prevPoint) { + touchPointSum._add(point); + touchDeltaSum._add(point.sub(prevPoint)); + touchDeltaCount++; + touches[identifier] = point; + } + } + this._touches = touches; + if (touchDeltaCount < this._minTouches || !touchDeltaSum.mag()) + return; + const panDelta = touchDeltaSum.div(touchDeltaCount); + this._sum._add(panDelta); + if (this._sum.mag() < this._clickTolerance) + return; + const around = touchPointSum.div(touchDeltaCount); + return { + around, + panDelta + }; + } + enable() { + this._enabled = true; + } + disable() { + this._enabled = false; + this.reset(); + } + isEnabled() { + return this._enabled; + } + isActive() { + return this._active; + } +} + +/** + * The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers + * + * @group Handlers + */ +class TwoFingersTouchHandler { + /** @internal */ + constructor() { + this.reset(); + } + reset() { + this._active = false; + delete this._firstTwoTouches; + } + touchstart(e, points, mapTouches) { + //log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined); + if (this._firstTwoTouches || mapTouches.length < 2) + return; + this._firstTwoTouches = [ + mapTouches[0].identifier, + mapTouches[1].identifier + ]; + // implemented by child classes + this._start([points[0], points[1]]); + } + touchmove(e, points, mapTouches) { + if (!this._firstTwoTouches) + return; + e.preventDefault(); + const [idA, idB] = this._firstTwoTouches; + const a = getTouchById(mapTouches, points, idA); + const b = getTouchById(mapTouches, points, idB); + if (!a || !b) + return; + const pinchAround = this._aroundCenter ? null : a.add(b).div(2); + // implemented by child classes + return this._move([a, b], pinchAround, e); + } + touchend(e, points, mapTouches) { + if (!this._firstTwoTouches) + return; + const [idA, idB] = this._firstTwoTouches; + const a = getTouchById(mapTouches, points, idA); + const b = getTouchById(mapTouches, points, idB); + if (a && b) + return; + if (this._active) + DOM.suppressClick(); + this.reset(); + } + touchcancel() { + this.reset(); + } + /** + * Enables the "drag to pitch" interaction. + * + * @example + * ```ts + * map.touchPitch.enable(); + * ``` + */ + enable(options) { + this._enabled = true; + this._aroundCenter = !!options && options.around === 'center'; + } + /** + * Disables the "drag to pitch" interaction. + * + * @example + * ```ts + * map.touchPitch.disable(); + * ``` + */ + disable() { + this._enabled = false; + this.reset(); + } + /** + * Returns a Boolean indicating whether the "drag to pitch" interaction is enabled. + * + * @returns `true` if the "drag to pitch" interaction is enabled. + */ + isEnabled() { + return this._enabled; + } + /** + * Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to pitch" interaction is active. + */ + isActive() { + return this._active; + } +} +function getTouchById(mapTouches, points, identifier) { + for (let i = 0; i < mapTouches.length; i++) { + if (mapTouches[i].identifier === identifier) + return points[i]; + } +} +/* ZOOM */ +const ZOOM_THRESHOLD = 0.1; +function getZoomDelta(distance, lastDistance) { + return Math.log(distance / lastDistance) / Math.LN2; +} +/** + * The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers + * + * @group Handlers + */ +class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler { + reset() { + super.reset(); + delete this._distance; + delete this._startDistance; + } + _start(points) { + this._startDistance = this._distance = points[0].dist(points[1]); + } + _move(points, pinchAround) { + const lastDistance = this._distance; + this._distance = points[0].dist(points[1]); + if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) + return; + this._active = true; + return { + zoomDelta: getZoomDelta(this._distance, lastDistance), + pinchAround + }; + } +} +/* ROTATE */ +const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle +function getBearingDelta(a, b) { + return a.angleWith(b) * 180 / Math.PI; +} +/** + * The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers + * + * @group Handlers + */ +class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler { + reset() { + super.reset(); + delete this._minDiameter; + delete this._startVector; + delete this._vector; + } + _start(points) { + this._startVector = this._vector = points[0].sub(points[1]); + this._minDiameter = points[0].dist(points[1]); + } + _move(points, pinchAround) { + const lastVector = this._vector; + this._vector = points[0].sub(points[1]); + if (!this._active && this._isBelowThreshold(this._vector)) + return; + this._active = true; + return { + bearingDelta: getBearingDelta(this._vector, lastVector), + pinchAround + }; + } + _isBelowThreshold(vector) { + /* + * The threshold before a rotation actually happens is configured in + * pixels along the circumference of the circle formed by the two fingers. + * This makes the threshold in degrees larger when the fingers are close + * together and smaller when the fingers are far apart. + * + * Use the smallest diameter from the whole gesture to reduce sensitivity + * when pinching in and out. + */ + this._minDiameter = Math.min(this._minDiameter, vector.mag()); + const circumference = Math.PI * this._minDiameter; + const threshold = ROTATION_THRESHOLD / circumference * 360; + const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector); + return Math.abs(bearingDeltaSinceStart) < threshold; + } +} +/* PITCH */ +function isVertical(vector) { + return Math.abs(vector.y) > Math.abs(vector.x); +} +const ALLOWED_SINGLE_TOUCH_TIME = 100; +/** + * The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers. + * + * @group Handlers + */ +class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler { + constructor(map) { + super(); + this._map = map; + } + reset() { + super.reset(); + this._valid = undefined; + delete this._firstMove; + delete this._lastPoints; + } + touchstart(e, points, mapTouches) { + super.touchstart(e, points, mapTouches); + this._currentTouchCount = mapTouches.length; + } + _start(points) { + this._lastPoints = points; + if (isVertical(points[0].sub(points[1]))) { + // fingers are more horizontal than vertical + this._valid = false; + } + } + _move(points, center, e) { + // If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register + if (this._map._cooperativeGestures && this._currentTouchCount < 3) { + return; + } + const vectorA = points[0].sub(this._lastPoints[0]); + const vectorB = points[1].sub(this._lastPoints[1]); + this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp); + if (!this._valid) + return; + this._lastPoints = points; + this._active = true; + const yDeltaAverage = (vectorA.y + vectorB.y) / 2; + const degreesPerPixelMoved = -0.5; + return { + pitchDelta: yDeltaAverage * degreesPerPixelMoved + }; + } + gestureBeginsVertically(vectorA, vectorB, timeStamp) { + if (this._valid !== undefined) + return this._valid; + const threshold = 2; + const movedA = vectorA.mag() >= threshold; + const movedB = vectorB.mag() >= threshold; + // neither finger has moved a meaningful amount, wait + if (!movedA && !movedB) + return; + // One finger has moved and the other has not. + // If enough time has passed, decide it is not a pitch. + if (!movedA || !movedB) { + if (this._firstMove === undefined) { + this._firstMove = timeStamp; + } + if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) { + // still waiting for a movement from the second finger + return undefined; + } + else { + return false; + } + } + const isSameDirection = vectorA.y > 0 === vectorB.y > 0; + return isVertical(vectorA) && isVertical(vectorB) && isSameDirection; + } +} + +const defaultOptions$5 = { + panStep: 100, + bearingStep: 15, + pitchStep: 10 +}; +/** + * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using + * the following keyboard shortcuts: + * + * - `=` / `+`: Increase the zoom level by 1. + * - `Shift-=` / `Shift-+`: Increase the zoom level by 2. + * - `-`: Decrease the zoom level by 1. + * - `Shift--`: Decrease the zoom level by 2. + * - Arrow keys: Pan by 100 pixels. + * - `Shift+⇢`: Increase the rotation by 15 degrees. + * - `Shift+⇠`: Decrease the rotation by 15 degrees. + * - `Shift+⇡`: Increase the pitch by 10 degrees. + * - `Shift+⇣`: Decrease the pitch by 10 degrees. + * + * @group Handlers + */ +class KeyboardHandler { + /** @internal */ + constructor(map) { + this._tr = new TransformProvider(map); + const stepOptions = defaultOptions$5; + this._panStep = stepOptions.panStep; + this._bearingStep = stepOptions.bearingStep; + this._pitchStep = stepOptions.pitchStep; + this._rotationDisabled = false; + } + reset() { + this._active = false; + } + keydown(e) { + if (e.altKey || e.ctrlKey || e.metaKey) + return; + let zoomDir = 0; + let bearingDir = 0; + let pitchDir = 0; + let xDir = 0; + let yDir = 0; + switch (e.keyCode) { + case 61: + case 107: + case 171: + case 187: + zoomDir = 1; + break; + case 189: + case 109: + case 173: + zoomDir = -1; + break; + case 37: + if (e.shiftKey) { + bearingDir = -1; + } + else { + e.preventDefault(); + xDir = -1; + } + break; + case 39: + if (e.shiftKey) { + bearingDir = 1; + } + else { + e.preventDefault(); + xDir = 1; + } + break; + case 38: + if (e.shiftKey) { + pitchDir = 1; + } + else { + e.preventDefault(); + yDir = -1; + } + break; + case 40: + if (e.shiftKey) { + pitchDir = -1; + } + else { + e.preventDefault(); + yDir = 1; + } + break; + default: + return; + } + if (this._rotationDisabled) { + bearingDir = 0; + pitchDir = 0; + } + return { + cameraAnimation: (map) => { + const tr = this._tr; + map.easeTo({ + duration: 300, + easeId: 'keyboardHandler', + easing: easeOut, + zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom, + bearing: tr.bearing + bearingDir * this._bearingStep, + pitch: tr.pitch + pitchDir * this._pitchStep, + offset: [-xDir * this._panStep, -yDir * this._panStep], + center: tr.center + }, { originalEvent: e }); + } + }; + } + /** + * Enables the "keyboard rotate and zoom" interaction. + * + * @example + * ```ts + * map.keyboard.enable(); + * ``` + */ + enable() { + this._enabled = true; + } + /** + * Disables the "keyboard rotate and zoom" interaction. + * + * @example + * ```ts + * map.keyboard.disable(); + * ``` + */ + disable() { + this._enabled = false; + this.reset(); + } + /** + * Returns a Boolean indicating whether the "keyboard rotate and zoom" + * interaction is enabled. + * + * @returns `true` if the "keyboard rotate and zoom" + * interaction is enabled. + */ + isEnabled() { + return this._enabled; + } + /** + * Returns true if the handler is enabled and has detected the start of a + * zoom/rotate gesture. + * + * @returns `true` if the handler is enabled and has detected the + * start of a zoom/rotate gesture. + */ + isActive() { + return this._active; + } + /** + * Disables the "keyboard pan/rotate" interaction, leaving the + * "keyboard zoom" interaction enabled. + * + * @example + * ```ts + * map.keyboard.disableRotation(); + * ``` + */ + disableRotation() { + this._rotationDisabled = true; + } + /** + * Enables the "keyboard pan/rotate" interaction. + * + * @example + * ```ts + * map.keyboard.enable(); + * map.keyboard.enableRotation(); + * ``` + */ + enableRotation() { + this._rotationDisabled = false; + } +} +function easeOut(t) { + return t * (2 - t); +} + +// deltaY value for mouse scroll wheel identification +const wheelZoomDelta = 4.000244140625; +// These magic numbers control the rate of zoom. Trackpad events fire at a greater +// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick +const defaultZoomRate = 1 / 100; +const wheelZoomRate = 1 / 450; +// upper bound on how much we scale the map in any single render frame; this +// is used to limit zoom rate in the case of very fast scrolling +const maxScalePerFrame = 2; +/** + * The `ScrollZoomHandler` allows the user to zoom the map by scrolling. + * + * @group Handlers + */ +class ScrollZoomHandler { + /** @internal */ + constructor(map, triggerRenderFrame) { + this._onTimeout = (initialEvent) => { + this._type = 'wheel'; + this._delta -= this._lastValue; + if (!this._active) { + this._start(initialEvent); + } + }; + this._map = map; + this._tr = new TransformProvider(map); + this._el = map.getCanvasContainer(); + this._triggerRenderFrame = triggerRenderFrame; + this._delta = 0; + this._defaultZoomRate = defaultZoomRate; + this._wheelZoomRate = wheelZoomRate; + } + /** + * Set the zoom rate of a trackpad + * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value. + * @example + * Speed up trackpad zoom + * ```ts + * map.scrollZoom.setZoomRate(1/25); + * ``` + */ + setZoomRate(zoomRate) { + this._defaultZoomRate = zoomRate; + } + /** + * Set the zoom rate of a mouse wheel + * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value. + * @example + * Slow down zoom of mouse wheel + * ```ts + * map.scrollZoom.setWheelZoomRate(1/600); + * ``` + */ + setWheelZoomRate(wheelZoomRate) { + this._wheelZoomRate = wheelZoomRate; + } + /** + * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled. + * @returns `true` if the "scroll to zoom" interaction is enabled. + */ + isEnabled() { + return !!this._enabled; + } + /* + * Active state is turned on and off with every scroll wheel event and is set back to false before the map + * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in + * progress. + */ + isActive() { + return !!this._active || this._finishTimeout !== undefined; + } + isZooming() { + return !!this._zooming; + } + /** + * Enables the "scroll to zoom" interaction. + * + * @param options - Options object. + * @example + * ```ts + * map.scrollZoom.enable(); + * map.scrollZoom.enable({ around: 'center' }) + * ``` + */ + enable(options) { + if (this.isEnabled()) + return; + this._enabled = true; + this._aroundCenter = !!options && options.around === 'center'; + } + /** + * Disables the "scroll to zoom" interaction. + * + * @example + * ```ts + * map.scrollZoom.disable(); + * ``` + */ + disable() { + if (!this.isEnabled()) + return; + this._enabled = false; + } + wheel(e) { + if (!this.isEnabled()) + return; + if (this._map._cooperativeGestures) { + if (e[this._map._metaKey]) { + e.preventDefault(); + } + else { + return; + } + } + let value = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY; + const now = performance.browser.now(), timeDelta = now - (this._lastWheelEventTime || 0); + this._lastWheelEventTime = now; + if (value !== 0 && (value % wheelZoomDelta) === 0) { + // This one is definitely a mouse wheel event. + this._type = 'wheel'; + } + else if (value !== 0 && Math.abs(value) < 4) { + // This one is definitely a trackpad event because it is so small. + this._type = 'trackpad'; + } + else if (timeDelta > 400) { + // This is likely a new scroll action. + this._type = null; + this._lastValue = value; + // Start a timeout in case this was a singular event, and dely it by up to 40ms. + this._timeout = setTimeout(this._onTimeout, 40, e); + } + else if (!this._type) { + // This is a repeating event, but we don't know the type of event just yet. + // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode. + this._type = (Math.abs(timeDelta * value) < 200) ? 'trackpad' : 'wheel'; + // Make sure our delayed event isn't fired again, because we accumulate + // the previous event (which was less than 40ms ago) into this event. + if (this._timeout) { + clearTimeout(this._timeout); + this._timeout = null; + value += this._lastValue; + } + } + // Slow down zoom if shift key is held for more precise zooming + if (e.shiftKey && value) + value = value / 4; + // Only fire the callback if we actually know what type of scrolling device the user uses. + if (this._type) { + this._lastWheelEvent = e; + this._delta -= value; + if (!this._active) { + this._start(e); + } + } + e.preventDefault(); + } + _start(e) { + if (!this._delta) + return; + if (this._frameId) { + this._frameId = null; + } + this._active = true; + if (!this.isZooming()) { + this._zooming = true; + } + if (this._finishTimeout) { + clearTimeout(this._finishTimeout); + delete this._finishTimeout; + } + const pos = DOM.mousePos(this._el, e); + const tr = this._tr; + this._around = performance.LngLat.convert(this._aroundCenter ? tr.center : tr.unproject(pos)); + this._aroundPoint = tr.transform.locationPoint(this._around); + if (!this._frameId) { + this._frameId = true; + this._triggerRenderFrame(); + } + } + renderFrame() { + if (!this._frameId) + return; + this._frameId = null; + if (!this.isActive()) + return; + const tr = this._tr.transform; + // if we've had scroll events since the last render frame, consume the + // accumulated delta, and update the target zoom level accordingly + if (this._delta !== 0) { + // For trackpad events and single mouse wheel ticks, use the default zoom rate + const zoomRate = (this._type === 'wheel' && Math.abs(this._delta) > wheelZoomDelta) ? this._wheelZoomRate : this._defaultZoomRate; + // Scale by sigmoid of scroll wheel delta. + let scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate))); + if (this._delta < 0 && scale !== 0) { + scale = 1 / scale; + } + const fromScale = typeof this._targetZoom === 'number' ? tr.zoomScale(this._targetZoom) : tr.scale; + this._targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale))); + // if this is a mouse wheel, refresh the starting zoom and easing + // function we're using to smooth out the zooming between wheel + // events + if (this._type === 'wheel') { + this._startZoom = tr.zoom; + this._easing = this._smoothOutEasing(200); + } + this._delta = 0; + } + const targetZoom = typeof this._targetZoom === 'number' ? + this._targetZoom : tr.zoom; + const startZoom = this._startZoom; + const easing = this._easing; + let finished = false; + let zoom; + if (this._type === 'wheel' && startZoom && easing) { + const t = Math.min((performance.browser.now() - this._lastWheelEventTime) / 200, 1); + const k = easing(t); + zoom = performance.interpolate.number(startZoom, targetZoom, k); + if (t < 1) { + if (!this._frameId) { + this._frameId = true; + } + } + else { + finished = true; + } + } + else { + zoom = targetZoom; + finished = true; + } + this._active = true; + if (finished) { + this._active = false; + this._finishTimeout = setTimeout(() => { + this._zooming = false; + this._triggerRenderFrame(); + delete this._targetZoom; + delete this._finishTimeout; + }, 200); + } + return { + noInertia: true, + needsRenderFrame: !finished, + zoomDelta: zoom - tr.zoom, + around: this._aroundPoint, + originalEvent: this._lastWheelEvent + }; + } + _smoothOutEasing(duration) { + let easing = performance.defaultEasing; + if (this._prevEase) { + const currentEase = this._prevEase; + const t = (performance.browser.now() - currentEase.start) / currentEase.duration; + const speed = currentEase.easing(t + 0.01) - currentEase.easing(t); + // Quick hack to make new bezier that is continuous with last + const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01; + const y = Math.sqrt(0.27 * 0.27 - x * x); + easing = performance.bezier(x, y, 0.25, 1); + } + this._prevEase = { + start: performance.browser.now(), + duration, + easing + }; + return easing; + } + reset() { + this._active = false; + this._zooming = false; + delete this._targetZoom; + if (this._finishTimeout) { + clearTimeout(this._finishTimeout); + delete this._finishTimeout; + } + } +} + +/** + * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by + * double clicking or double tapping. + * + * @group Handlers + */ +class DoubleClickZoomHandler { + /** @internal */ + constructor(clickZoom, TapZoom) { + this._clickZoom = clickZoom; + this._tapZoom = TapZoom; + } + /** + * Enables the "double click to zoom" interaction. + * + * @example + * ```ts + * map.doubleClickZoom.enable(); + * ``` + */ + enable() { + this._clickZoom.enable(); + this._tapZoom.enable(); + } + /** + * Disables the "double click to zoom" interaction. + * + * @example + * ```ts + * map.doubleClickZoom.disable(); + * ``` + */ + disable() { + this._clickZoom.disable(); + this._tapZoom.disable(); + } + /** + * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled. + * + * @returns `true` if the "double click to zoom" interaction is enabled. + */ + isEnabled() { + return this._clickZoom.isEnabled() && this._tapZoom.isEnabled(); + } + /** + * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used. + * + * @returns `true` if the "double click to zoom" interaction is active. + */ + isActive() { + return this._clickZoom.isActive() || this._tapZoom.isActive(); + } +} + +/** + * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking + * It is used by other handlers + */ +class ClickZoomHandler { + /** @internal */ + constructor(map) { + this._tr = new TransformProvider(map); + this.reset(); + } + reset() { + this._active = false; + } + dblclick(e, point) { + e.preventDefault(); + return { + cameraAnimation: (map) => { + map.easeTo({ + duration: 300, + zoom: this._tr.zoom + (e.shiftKey ? -1 : 1), + around: this._tr.unproject(point) + }, { originalEvent: e }); + } + }; + } + enable() { + this._enabled = true; + } + disable() { + this._enabled = false; + this.reset(); + } + isEnabled() { + return this._enabled; + } + isActive() { + return this._active; + } +} + +class TapDragZoomHandler { + constructor() { + this._tap = new TapRecognizer({ + numTouches: 1, + numTaps: 1 + }); + this.reset(); + } + reset() { + this._active = false; + delete this._swipePoint; + delete this._swipeTouch; + delete this._tapTime; + delete this._tapPoint; + this._tap.reset(); + } + touchstart(e, points, mapTouches) { + if (this._swipePoint) + return; + if (!this._tapTime) { + this._tap.touchstart(e, points, mapTouches); + } + else { + const swipePoint = points[0]; + const soonEnough = e.timeStamp - this._tapTime < MAX_TAP_INTERVAL; + const closeEnough = this._tapPoint.dist(swipePoint) < MAX_DIST; + if (!soonEnough || !closeEnough) { + this.reset(); + } + else if (mapTouches.length > 0) { + this._swipePoint = swipePoint; + this._swipeTouch = mapTouches[0].identifier; + } + } + } + touchmove(e, points, mapTouches) { + if (!this._tapTime) { + this._tap.touchmove(e, points, mapTouches); + } + else if (this._swipePoint) { + if (mapTouches[0].identifier !== this._swipeTouch) { + return; + } + const newSwipePoint = points[0]; + const dist = newSwipePoint.y - this._swipePoint.y; + this._swipePoint = newSwipePoint; + e.preventDefault(); + this._active = true; + return { + zoomDelta: dist / 128 + }; + } + } + touchend(e, points, mapTouches) { + if (!this._tapTime) { + const point = this._tap.touchend(e, points, mapTouches); + if (point) { + this._tapTime = e.timeStamp; + this._tapPoint = point; + } + } + else if (this._swipePoint) { + if (mapTouches.length === 0) { + this.reset(); + } + } + } + touchcancel() { + this.reset(); + } + enable() { + this._enabled = true; + } + disable() { + this._enabled = false; + this.reset(); + } + isEnabled() { + return this._enabled; + } + isActive() { + return this._active; + } +} + +/** + * The `DragPanHandler` allows the user to pan the map by clicking and dragging + * the cursor. + * + * @group Handlers + */ +class DragPanHandler { + /** @internal */ + constructor(el, mousePan, touchPan) { + this._el = el; + this._mousePan = mousePan; + this._touchPan = touchPan; + } + /** + * Enables the "drag to pan" interaction. + * + * @param options - Options object + * @example + * ```ts + * map.dragPan.enable(); + * map.dragPan.enable({ + * linearity: 0.3, + * easing: bezier(0, 0, 0.3, 1), + * maxSpeed: 1400, + * deceleration: 2500, + * }); + * ``` + */ + enable(options) { + this._inertiaOptions = options || {}; + this._mousePan.enable(); + this._touchPan.enable(); + this._el.classList.add('maplibregl-touch-drag-pan'); + } + /** + * Disables the "drag to pan" interaction. + * + * @example + * ```ts + * map.dragPan.disable(); + * ``` + */ + disable() { + this._mousePan.disable(); + this._touchPan.disable(); + this._el.classList.remove('maplibregl-touch-drag-pan'); + } + /** + * Returns a Boolean indicating whether the "drag to pan" interaction is enabled. + * + * @returns `true` if the "drag to pan" interaction is enabled. + */ + isEnabled() { + return this._mousePan.isEnabled() && this._touchPan.isEnabled(); + } + /** + * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to pan" interaction is active. + */ + isActive() { + return this._mousePan.isActive() || this._touchPan.isActive(); + } +} + +/** + * The `DragRotateHandler` allows the user to rotate the map by clicking and + * dragging the cursor while holding the right mouse button or `ctrl` key. + * + * @group Handlers + */ +class DragRotateHandler { + /** @internal */ + constructor(options, mouseRotate, mousePitch) { + this._pitchWithRotate = options.pitchWithRotate; + this._mouseRotate = mouseRotate; + this._mousePitch = mousePitch; + } + /** + * Enables the "drag to rotate" interaction. + * + * @example + * ```ts + * map.dragRotate.enable(); + * ``` + */ + enable() { + this._mouseRotate.enable(); + if (this._pitchWithRotate) + this._mousePitch.enable(); + } + /** + * Disables the "drag to rotate" interaction. + * + * @example + * ```ts + * map.dragRotate.disable(); + * ``` + */ + disable() { + this._mouseRotate.disable(); + this._mousePitch.disable(); + } + /** + * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled. + * + * @returns `true` if the "drag to rotate" interaction is enabled. + */ + isEnabled() { + return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled()); + } + /** + * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to rotate" interaction is active. + */ + isActive() { + return this._mouseRotate.isActive() || this._mousePitch.isActive(); + } +} + +/** + * The `TwoFingersTouchZoomRotateHandler` allows the user to zoom and rotate the map by + * pinching on a touchscreen. + * + * They can zoom with one finger by double tapping and dragging. On the second tap, + * hold the finger down and drag up or down to zoom in or out. + * + * @group Handlers + */ +class TwoFingersTouchZoomRotateHandler { + /** @internal */ + constructor(el, touchZoom, touchRotate, tapDragZoom) { + this._el = el; + this._touchZoom = touchZoom; + this._touchRotate = touchRotate; + this._tapDragZoom = tapDragZoom; + this._rotationDisabled = false; + this._enabled = true; + } + /** + * Enables the "pinch to rotate and zoom" interaction. + * + * @param options - Options object. + * + * @example + * ```ts + * map.touchZoomRotate.enable(); + * map.touchZoomRotate.enable({ around: 'center' }); + * ``` + */ + enable(options) { + this._touchZoom.enable(options); + if (!this._rotationDisabled) + this._touchRotate.enable(options); + this._tapDragZoom.enable(); + this._el.classList.add('maplibregl-touch-zoom-rotate'); + } + /** + * Disables the "pinch to rotate and zoom" interaction. + * + * @example + * ```ts + * map.touchZoomRotate.disable(); + * ``` + */ + disable() { + this._touchZoom.disable(); + this._touchRotate.disable(); + this._tapDragZoom.disable(); + this._el.classList.remove('maplibregl-touch-zoom-rotate'); + } + /** + * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled. + * + * @returns `true` if the "pinch to rotate and zoom" interaction is enabled. + */ + isEnabled() { + return this._touchZoom.isEnabled() && + (this._rotationDisabled || this._touchRotate.isEnabled()) && + this._tapDragZoom.isEnabled(); + } + /** + * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture. + * + * @returns `true` if the handler is active, `false` otherwise + */ + isActive() { + return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive(); + } + /** + * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom" + * interaction enabled. + * + * @example + * ```ts + * map.touchZoomRotate.disableRotation(); + * ``` + */ + disableRotation() { + this._rotationDisabled = true; + this._touchRotate.disable(); + } + /** + * Enables the "pinch to rotate" interaction. + * + * @example + * ```ts + * map.touchZoomRotate.enable(); + * map.touchZoomRotate.enableRotation(); + * ``` + */ + enableRotation() { + this._rotationDisabled = false; + if (this._touchZoom.isEnabled()) + this._touchRotate.enable(); + } +} + +const isMoving = p => p.zoom || p.drag || p.pitch || p.rotate; +class RenderFrameEvent extends performance.Event { +} +function hasChange(result) { + return (result.panDelta && result.panDelta.mag()) || result.zoomDelta || result.bearingDelta || result.pitchDelta; +} +class HandlerManager { + constructor(map, options) { + this.handleWindowEvent = (e) => { + this.handleEvent(e, `${e.type}Window`); + }; + this.handleEvent = (e, eventName) => { + if (e.type === 'blur') { + this.stop(true); + return; + } + this._updatingCamera = true; + const inputEvent = e.type === 'renderFrame' ? undefined : e; + /* + * We don't call e.preventDefault() for any events by default. + * Handlers are responsible for calling it where necessary. + */ + const mergedHandlerResult = { needsRenderFrame: false }; + const eventsInProgress = {}; + const activeHandlers = {}; + const eventTouches = e.touches; + const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined; + const points = mapTouches ? DOM.touchPos(this._el, mapTouches) : DOM.mousePos(this._el, e); + for (const { handlerName, handler, allowed } of this._handlers) { + if (!handler.isEnabled()) + continue; + let data; + if (this._blockedByActive(activeHandlers, allowed, handlerName)) { + handler.reset(); + } + else { + if (handler[eventName || e.type]) { + data = handler[eventName || e.type](e, points, mapTouches); + this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent); + if (data && data.needsRenderFrame) { + this._triggerRenderFrame(); + } + } + } + if (data || handler.isActive()) { + activeHandlers[handlerName] = handler; + } + } + const deactivatedHandlers = {}; + for (const name in this._previousActiveHandlers) { + if (!activeHandlers[name]) { + deactivatedHandlers[name] = inputEvent; + } + } + this._previousActiveHandlers = activeHandlers; + if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) { + this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]); + this._triggerRenderFrame(); + } + if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) { + this._map._stop(true); + } + this._updatingCamera = false; + const { cameraAnimation } = mergedHandlerResult; + if (cameraAnimation) { + this._inertia.clear(); + this._fireEvents({}, {}, true); + this._changes = []; + cameraAnimation(this._map); + } + }; + this._map = map; + this._el = this._map.getCanvasContainer(); + this._handlers = []; + this._handlersById = {}; + this._changes = []; + this._inertia = new HandlerInertia(map); + this._bearingSnap = options.bearingSnap; + this._previousActiveHandlers = {}; + // Track whether map is currently moving, to compute start/move/end events + this._eventsInProgress = {}; + this._addDefaultHandlers(options); + const el = this._el; + this._listeners = [ + // This needs to be `passive: true` so that a double tap fires two + // pairs of touchstart/end events in iOS Safari 13. If this is set to + // `passive: false` then the second pair of events is only fired if + // preventDefault() is called on the first touchstart. Calling preventDefault() + // undesirably prevents click events. + [el, 'touchstart', { passive: true }], + // This needs to be `passive: false` so that scrolls and pinches can be + // prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12. + [el, 'touchmove', { passive: false }], + [el, 'touchend', undefined], + [el, 'touchcancel', undefined], + [el, 'mousedown', undefined], + [el, 'mousemove', undefined], + [el, 'mouseup', undefined], + // Bind window-level event listeners for move and up/end events. In the absence of + // the pointer capture API, which is not supported by all necessary platforms, + // window-level event listeners give us the best shot at capturing events that + // fall outside the map canvas element. Use `{capture: true}` for the move event + // to prevent map move events from being fired during a drag. + [document, 'mousemove', { capture: true }], + [document, 'mouseup', undefined], + [el, 'mouseover', undefined], + [el, 'mouseout', undefined], + [el, 'dblclick', undefined], + [el, 'click', undefined], + [el, 'keydown', { capture: false }], + [el, 'keyup', undefined], + [el, 'wheel', { passive: false }], + [el, 'contextmenu', undefined], + [window, 'blur', undefined] + ]; + for (const [target, type, listenerOptions] of this._listeners) { + DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions); + } + } + destroy() { + for (const [target, type, listenerOptions] of this._listeners) { + DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions); + } + } + _addDefaultHandlers(options) { + const map = this._map; + const el = map.getCanvasContainer(); + this._add('mapEvent', new MapEventHandler(map, options)); + const boxZoom = map.boxZoom = new BoxZoomHandler(map, options); + this._add('boxZoom', boxZoom); + if (options.interactive && options.boxZoom) { + boxZoom.enable(); + } + const tapZoom = new TapZoomHandler(map); + const clickZoom = new ClickZoomHandler(map); + map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom); + this._add('tapZoom', tapZoom); + this._add('clickZoom', clickZoom); + if (options.interactive && options.doubleClickZoom) { + map.doubleClickZoom.enable(); + } + const tapDragZoom = new TapDragZoomHandler(); + this._add('tapDragZoom', tapDragZoom); + const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map); + this._add('touchPitch', touchPitch); + if (options.interactive && options.touchPitch) { + map.touchPitch.enable(options.touchPitch); + } + const mouseRotate = generateMouseRotationHandler(options); + const mousePitch = generateMousePitchHandler(options); + map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch); + this._add('mouseRotate', mouseRotate, ['mousePitch']); + this._add('mousePitch', mousePitch, ['mouseRotate']); + if (options.interactive && options.dragRotate) { + map.dragRotate.enable(); + } + const mousePan = generateMousePanHandler(options); + const touchPan = new TouchPanHandler(options, map); + map.dragPan = new DragPanHandler(el, mousePan, touchPan); + this._add('mousePan', mousePan); + this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']); + if (options.interactive && options.dragPan) { + map.dragPan.enable(options.dragPan); + } + const touchRotate = new TwoFingersTouchRotateHandler(); + const touchZoom = new TwoFingersTouchZoomHandler(); + map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom); + this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']); + this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']); + if (options.interactive && options.touchZoomRotate) { + map.touchZoomRotate.enable(options.touchZoomRotate); + } + const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame()); + this._add('scrollZoom', scrollZoom, ['mousePan']); + if (options.interactive && options.scrollZoom) { + map.scrollZoom.enable(options.scrollZoom); + } + const keyboard = map.keyboard = new KeyboardHandler(map); + this._add('keyboard', keyboard); + if (options.interactive && options.keyboard) { + map.keyboard.enable(); + } + this._add('blockableMapEvent', new BlockableMapEventHandler(map)); + } + _add(handlerName, handler, allowed) { + this._handlers.push({ handlerName, handler, allowed }); + this._handlersById[handlerName] = handler; + } + stop(allowEndAnimation) { + // do nothing if this method was triggered by a gesture update + if (this._updatingCamera) + return; + for (const { handler } of this._handlers) { + handler.reset(); + } + this._inertia.clear(); + this._fireEvents({}, {}, allowEndAnimation); + this._changes = []; + } + isActive() { + for (const { handler } of this._handlers) { + if (handler.isActive()) + return true; + } + return false; + } + isZooming() { + return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming(); + } + isRotating() { + return !!this._eventsInProgress.rotate; + } + isMoving() { + return Boolean(isMoving(this._eventsInProgress)) || this.isZooming(); + } + _blockedByActive(activeHandlers, allowed, myName) { + for (const name in activeHandlers) { + if (name === myName) + continue; + if (!allowed || allowed.indexOf(name) < 0) { + return true; + } + } + return false; + } + _getMapTouches(touches) { + const mapTouches = []; + for (const t of touches) { + const target = t.target; + if (this._el.contains(target)) { + mapTouches.push(t); + } + } + return mapTouches; + } + mergeHandlerResult(mergedHandlerResult, eventsInProgress, handlerResult, name, e) { + if (!handlerResult) + return; + performance.extend(mergedHandlerResult, handlerResult); + const eventData = { handlerName: name, originalEvent: handlerResult.originalEvent || e }; + // track which handler changed which camera property + if (handlerResult.zoomDelta !== undefined) { + eventsInProgress.zoom = eventData; + } + if (handlerResult.panDelta !== undefined) { + eventsInProgress.drag = eventData; + } + if (handlerResult.pitchDelta !== undefined) { + eventsInProgress.pitch = eventData; + } + if (handlerResult.bearingDelta !== undefined) { + eventsInProgress.rotate = eventData; + } + } + _applyChanges() { + const combined = {}; + const combinedEventsInProgress = {}; + const combinedDeactivatedHandlers = {}; + for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) { + if (change.panDelta) + combined.panDelta = (combined.panDelta || new performance.Point(0, 0))._add(change.panDelta); + if (change.zoomDelta) + combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta; + if (change.bearingDelta) + combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta; + if (change.pitchDelta) + combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta; + if (change.around !== undefined) + combined.around = change.around; + if (change.pinchAround !== undefined) + combined.pinchAround = change.pinchAround; + if (change.noInertia) + combined.noInertia = change.noInertia; + performance.extend(combinedEventsInProgress, eventsInProgress); + performance.extend(combinedDeactivatedHandlers, deactivatedHandlers); + } + this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers); + this._changes = []; + } + _updateMapTransform(combinedResult, combinedEventsInProgress, deactivatedHandlers) { + const map = this._map; + const tr = map._getTransformForUpdate(); + const terrain = map.terrain; + if (!hasChange(combinedResult) && !(terrain && this._terrainMovement)) { + return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true); + } + let { panDelta, zoomDelta, bearingDelta, pitchDelta, around, pinchAround } = combinedResult; + if (pinchAround !== undefined) { + around = pinchAround; + } + // stop any ongoing camera animations (easeTo, flyTo) + map._stop(true); + around = around || map.transform.centerPoint; + const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around); + if (bearingDelta) + tr.bearing += bearingDelta; + if (pitchDelta) + tr.pitch += pitchDelta; + if (zoomDelta) + tr.zoom += zoomDelta; + if (!terrain) { + tr.setLocationAtPoint(loc, around); + } + else { + // when 3d-terrain is enabled act a little different: + // - dragging do not drag the picked point itself, instead it drags the map by pixel-delta. + // With this approach it is no longer possible to pick a point from somewhere near + // the horizon to the center in one move. + // So this logic avoids the problem, that in such cases you easily loose orientation. + if (!this._terrainMovement && + (combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) { + // When starting to drag or move, flag it and register moveend to clear flagging + this._terrainMovement = true; + this._map._elevationFreeze = true; + tr.setLocationAtPoint(loc, around); + this._map.once('moveend', () => { + this._map._elevationFreeze = false; + this._terrainMovement = false; + tr.recalculateZoom(map.terrain); + }); + } + else if (combinedEventsInProgress.drag && this._terrainMovement) { + // drag map + tr.center = tr.pointLocation(tr.centerPoint.sub(panDelta)); + } + else { + tr.setLocationAtPoint(loc, around); + } + } + map._applyUpdatedTransform(tr); + this._map._update(); + if (!combinedResult.noInertia) + this._inertia.record(combinedResult); + this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true); + } + _fireEvents(newEventsInProgress, deactivatedHandlers, allowEndAnimation) { + const wasMoving = isMoving(this._eventsInProgress); + const nowMoving = isMoving(newEventsInProgress); + const startEvents = {}; + for (const eventName in newEventsInProgress) { + const { originalEvent } = newEventsInProgress[eventName]; + if (!this._eventsInProgress[eventName]) { + startEvents[`${eventName}start`] = originalEvent; + } + this._eventsInProgress[eventName] = newEventsInProgress[eventName]; + } + // fire start events only after this._eventsInProgress has been updated + if (!wasMoving && nowMoving) { + this._fireEvent('movestart', nowMoving.originalEvent); + } + for (const name in startEvents) { + this._fireEvent(name, startEvents[name]); + } + if (nowMoving) { + this._fireEvent('move', nowMoving.originalEvent); + } + for (const eventName in newEventsInProgress) { + const { originalEvent } = newEventsInProgress[eventName]; + this._fireEvent(eventName, originalEvent); + } + const endEvents = {}; + let originalEndEvent; + for (const eventName in this._eventsInProgress) { + const { handlerName, originalEvent } = this._eventsInProgress[eventName]; + if (!this._handlersById[handlerName].isActive()) { + delete this._eventsInProgress[eventName]; + originalEndEvent = deactivatedHandlers[handlerName] || originalEvent; + endEvents[`${eventName}end`] = originalEndEvent; + } + } + for (const name in endEvents) { + this._fireEvent(name, endEvents[name]); + } + const stillMoving = isMoving(this._eventsInProgress); + if (allowEndAnimation && (wasMoving || nowMoving) && !stillMoving) { + this._updatingCamera = true; + const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions); + const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap; + if (inertialEase && (inertialEase.essential || !performance.browser.prefersReducedMotion)) { + if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) { + inertialEase.bearing = 0; + } + inertialEase.freezeElevation = true; + this._map.easeTo(inertialEase, { originalEvent: originalEndEvent }); + } + else { + this._map.fire(new performance.Event('moveend', { originalEvent: originalEndEvent })); + if (shouldSnapToNorth(this._map.getBearing())) { + this._map.resetNorth(); + } + } + this._updatingCamera = false; + } + } + _fireEvent(type, e) { + this._map.fire(new performance.Event(type, e ? { originalEvent: e } : {})); + } + _requestFrame() { + this._map.triggerRepaint(); + return this._map._renderTaskQueue.add(timeStamp => { + delete this._frameId; + this.handleEvent(new RenderFrameEvent('renderFrame', { timeStamp })); + this._applyChanges(); + }); + } + _triggerRenderFrame() { + if (this._frameId === undefined) { + this._frameId = this._requestFrame(); + } + } +} + +class Camera extends performance.Evented { + constructor(transform, options) { + super(); + // Callback for map._requestRenderFrame + this._renderFrameCallback = () => { + const t = Math.min((performance.browser.now() - this._easeStart) / this._easeOptions.duration, 1); + this._onEaseFrame(this._easeOptions.easing(t)); + // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted + if (t < 1 && this._easeFrameId) { + this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback); + } + else { + this.stop(); + } + }; + this._moving = false; + this._zooming = false; + this.transform = transform; + this._bearingSnap = options.bearingSnap; + this.on('moveend', () => { + delete this._requestedCameraState; + }); + } + /** + * Returns the map's geographical centerpoint. + * + * @returns The map's geographical centerpoint. + * @example + * Return a LngLat object such as `{lng: 0, lat: 0}` + * ```ts + * let center = map.getCenter(); + * // access longitude and latitude values directly + * let {lng, lat} = map.getCenter(); + * ``` + */ + getCenter() { return new performance.LngLat(this.transform.center.lng, this.transform.center.lat); } + /** + * Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param center - The centerpoint to set. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * map.setCenter([-74, 38]); + * ``` + */ + setCenter(center, eventData) { + return this.jumpTo({ center }, eventData); + } + /** + * Pans the map by the specified offset. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param offset - `x` and `y` coordinates by which to pan the map. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + panBy(offset, options, eventData) { + offset = performance.Point.convert(offset).mult(-1); + return this.panTo(this.transform.center, performance.extend({ offset }, options), eventData); + } + /** + * Pans the map to the specified location with an animated transition. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param lnglat - The location to pan the map to. + * @param options - Options describing the destination and animation of the transition. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * map.panTo([-74, 38]); + * // Specify that the panTo animation should last 5000 milliseconds. + * map.panTo([-74, 38], {duration: 5000}); + * ``` + * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/) + */ + panTo(lnglat, options, eventData) { + return this.easeTo(performance.extend({ + center: lnglat + }, options), eventData); + } + /** + * Returns the map's current zoom level. + * + * @returns The map's current zoom level. + * @example + * ```ts + * map.getZoom(); + * ``` + */ + getZoom() { return this.transform.zoom; } + /** + * Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param zoom - The zoom level to set (0-20). + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom to the zoom level 5 without an animated transition + * ```ts + * map.setZoom(5); + * ``` + */ + setZoom(zoom, eventData) { + this.jumpTo({ zoom }, eventData); + return this; + } + /** + * Zooms the map to the specified zoom level, with an animated transition. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param zoom - The zoom level to transition to. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // Zoom to the zoom level 5 without an animated transition + * map.zoomTo(5); + * // Zoom to the zoom level 8 with an animated transition + * map.zoomTo(8, { + * duration: 2000, + * offset: [100, 50] + * }); + * ``` + */ + zoomTo(zoom, options, eventData) { + return this.easeTo(performance.extend({ + zoom + }, options), eventData); + } + /** + * Increases the map's zoom level by 1. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom the map in one level with a custom animation duration + * ```ts + * map.zoomIn({duration: 1000}); + * ``` + */ + zoomIn(options, eventData) { + this.zoomTo(this.getZoom() + 1, options, eventData); + return this; + } + /** + * Decreases the map's zoom level by 1. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom the map out one level with a custom animation offset + * ```ts + * map.zoomOut({offset: [80, 60]}); + * ``` + */ + zoomOut(options, eventData) { + this.zoomTo(this.getZoom() - 1, options, eventData); + return this; + } + /** + * Returns the map's current bearing. The bearing is the compass direction that is "up"; for example, a bearing + * of 90° orients the map so that east is up. + * + * @returns The map's current bearing. + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + getBearing() { return this.transform.bearing; } + /** + * Sets the map's bearing (rotation). The bearing is the compass direction that is "up"; for example, a bearing + * of 90° orients the map so that east is up. + * + * Equivalent to `jumpTo({bearing: bearing})`. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param bearing - The desired bearing. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Rotate the map to 90 degrees + * ```ts + * map.setBearing(90); + * ``` + */ + setBearing(bearing, eventData) { + this.jumpTo({ bearing }, eventData); + return this; + } + /** + * Returns the current padding applied around the map viewport. + * + * @returns The current padding around the map viewport. + */ + getPadding() { return this.transform.padding; } + /** + * Sets the padding in pixels around the viewport. + * + * Equivalent to `jumpTo({padding: padding})`. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param padding - The desired padding. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Sets a left padding of 300px, and a top padding of 50px + * ```ts + * map.setPadding({ left: 300, top: 50 }); + * ``` + */ + setPadding(padding, eventData) { + this.jumpTo({ padding }, eventData); + return this; + } + /** + * Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction + * that is "up"; for example, a bearing of 90° orients the map so that east is up. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param bearing - The desired bearing. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + rotateTo(bearing, options, eventData) { + return this.easeTo(performance.extend({ + bearing + }, options), eventData); + } + /** + * Rotates the map so that north is up (0° bearing), with an animated transition. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + resetNorth(options, eventData) { + this.rotateTo(0, performance.extend({ duration: 1000 }, options), eventData); + return this; + } + /** + * Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + resetNorthPitch(options, eventData) { + this.easeTo(performance.extend({ + bearing: 0, + pitch: 0, + duration: 1000 + }, options), eventData); + return this; + } + /** + * Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the + * `bearingSnap` threshold). + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + snapToNorth(options, eventData) { + if (Math.abs(this.getBearing()) < this._bearingSnap) { + return this.resetNorth(options, eventData); + } + return this; + } + /** + * Returns the map's current pitch (tilt). + * + * @returns The map's current pitch, measured in degrees away from the plane of the screen. + */ + getPitch() { return this.transform.pitch; } + /** + * Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`. + * + * Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`. + * + * @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60). + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + setPitch(pitch, eventData) { + this.jumpTo({ pitch }, eventData); + return this; + } + /** + * @param bounds - Calculate the center for these bounds in the viewport and use + * the highest zoom level up to and including `Map#getMaxZoom()` that fits + * in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0. + * @param options - Options object + * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`. + * If map is unable to fit, method will warn and return undefined. + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * let newCameraTransform = map.cameraForBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + */ + cameraForBounds(bounds, options) { + bounds = LngLatBounds.convert(bounds); + const bearing = options && options.bearing || 0; + return this._cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), bearing, options); + } + /** + * @internal + * Calculate the center of these two points in the viewport and use + * the highest zoom level up to and including `Map#getMaxZoom()` that fits + * the points in the viewport at the specified bearing. + * @param p0 - First point + * @param p1 - Second point + * @param bearing - Desired map bearing at end of animation, in degrees + * @param options - the camera options + * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`. + * If map is unable to fit, method will warn and return undefined. + * @example + * ```ts + * let p0 = [-79, 43]; + * let p1 = [-73, 45]; + * let bearing = 90; + * let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + */ + _cameraForBoxAndBearing(p0, p1, bearing, options) { + const defaultPadding = { + top: 0, + bottom: 0, + right: 0, + left: 0 + }; + options = performance.extend({ + padding: defaultPadding, + offset: [0, 0], + maxZoom: this.transform.maxZoom + }, options); + if (typeof options.padding === 'number') { + const p = options.padding; + options.padding = { + top: p, + bottom: p, + right: p, + left: p + }; + } + options.padding = performance.extend(defaultPadding, options.padding); + const tr = this.transform; + const edgePadding = tr.padding; + // We want to calculate the upper right and lower left of the box defined by p0 and p1 + // in a coordinate system rotate to match the destination bearing. + const p0world = tr.project(performance.LngLat.convert(p0)); + const p1world = tr.project(performance.LngLat.convert(p1)); + const p0rotated = p0world.rotate(-bearing * Math.PI / 180); + const p1rotated = p1world.rotate(-bearing * Math.PI / 180); + const upperRight = new performance.Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y)); + const lowerLeft = new performance.Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y)); + // Calculate zoom: consider the original bbox and padding. + const size = upperRight.sub(lowerLeft); + const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x; + const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y; + if (scaleY < 0 || scaleX < 0) { + performance.warnOnce('Map cannot fit within canvas with the given bounds, padding, and/or offset.'); + return undefined; + } + const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom); + // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding. + const offset = performance.Point.convert(options.offset); + const paddingOffsetX = (options.padding.left - options.padding.right) / 2; + const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2; + const paddingOffset = new performance.Point(paddingOffsetX, paddingOffsetY); + const rotatedPaddingOffset = paddingOffset.rotate(bearing * Math.PI / 180); + const offsetAtInitialZoom = offset.add(rotatedPaddingOffset); + const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom)); + const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom)); + return { + center, + zoom, + bearing + }; + } + /** + * Pans and zooms the map to contain its visible area within the specified geographical bounds. + * This function will also reset the map's bearing to 0 if bearing is nonzero. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param bounds - Center these bounds in the viewport and use the highest + * zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport. + * @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/) + */ + fitBounds(bounds, options, eventData) { + return this._fitInternal(this.cameraForBounds(bounds, options), options, eventData); + } + /** + * Pans, rotates and zooms the map to to fit the box made by points p0 and p1 + * once the map is rotated to the specified bearing. To zoom without rotating, + * pass in the current map bearing. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`. + * + * @param p0 - First point on screen, in pixel coordinates + * @param p1 - Second point on screen, in pixel coordinates + * @param bearing - Desired map bearing at end of animation, in degrees + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * let p0 = [220, 400]; + * let p1 = [500, 900]; + * map.fitScreenCoordinates(p0, p1, map.getBearing(), { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * @see Used by {@link BoxZoomHandler} + */ + fitScreenCoordinates(p0, p1, bearing, options, eventData) { + return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(performance.Point.convert(p0)), this.transform.pointLocation(performance.Point.convert(p1)), bearing, options), options, eventData); + } + _fitInternal(calculatedOptions, options, eventData) { + // cameraForBounds warns + returns undefined if unable to fit: + if (!calculatedOptions) + return this; + options = performance.extend(calculatedOptions, options); + // Explicitly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly. + delete options.padding; + return options.linear ? + this.easeTo(options, eventData) : + this.flyTo(options, eventData); + } + /** + * Changes any combination of center, zoom, bearing, and pitch, without + * an animated transition. The map will retain its current values for any + * details not specified in `options`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // jump to coordinates at current zoom + * map.jumpTo({center: [0, 0]}); + * // jump with zoom, pitch, and bearing options + * map.jumpTo({ + * center: [0, 0], + * zoom: 8, + * pitch: 45, + * bearing: 90 + * }); + * ``` + * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/) + * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/) + */ + jumpTo(options, eventData) { + this.stop(); + const tr = this._getTransformForUpdate(); + let zoomChanged = false, bearingChanged = false, pitchChanged = false; + if ('zoom' in options && tr.zoom !== +options.zoom) { + zoomChanged = true; + tr.zoom = +options.zoom; + } + if (options.center !== undefined) { + tr.center = performance.LngLat.convert(options.center); + } + if ('bearing' in options && tr.bearing !== +options.bearing) { + bearingChanged = true; + tr.bearing = +options.bearing; + } + if ('pitch' in options && tr.pitch !== +options.pitch) { + pitchChanged = true; + tr.pitch = +options.pitch; + } + if (options.padding != null && !tr.isPaddingEqual(options.padding)) { + tr.padding = options.padding; + } + this._applyUpdatedTransform(tr); + this.fire(new performance.Event('movestart', eventData)) + .fire(new performance.Event('move', eventData)); + if (zoomChanged) { + this.fire(new performance.Event('zoomstart', eventData)) + .fire(new performance.Event('zoom', eventData)) + .fire(new performance.Event('zoomend', eventData)); + } + if (bearingChanged) { + this.fire(new performance.Event('rotatestart', eventData)) + .fire(new performance.Event('rotate', eventData)) + .fire(new performance.Event('rotateend', eventData)); + } + if (pitchChanged) { + this.fire(new performance.Event('pitchstart', eventData)) + .fire(new performance.Event('pitch', eventData)) + .fire(new performance.Event('pitchend', eventData)); + } + return this.fire(new performance.Event('moveend', eventData)); + } + /** + * Calculates pitch, zoom and bearing for looking at `newCenter` with the camera position being `newCenter` + * and returns them as {@link CameraOptions}. + * @param from - The camera to look from + * @param altitudeFrom - The altitude of the camera to look from + * @param to - The center to look at + * @param altitudeTo - Optional altitude of the center to look at. If none given the ground height will be used. + * @returns the calculated camera options + */ + calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo = 0) { + const fromMerc = performance.MercatorCoordinate.fromLngLat(from, altitudeFrom); + const toMerc = performance.MercatorCoordinate.fromLngLat(to, altitudeTo); + const dx = toMerc.x - fromMerc.x; + const dy = toMerc.y - fromMerc.y; + const dz = toMerc.z - fromMerc.z; + const distance3D = Math.hypot(dx, dy, dz); + if (distance3D === 0) + throw new Error('Can\'t calculate camera options with same From and To'); + const groundDistance = Math.hypot(dx, dy); + const zoom = this.transform.scaleZoom(this.transform.cameraToCenterDistance / distance3D / this.transform.tileSize); + const bearing = (Math.atan2(dx, -dy) * 180) / Math.PI; + let pitch = (Math.acos(groundDistance / distance3D) * 180) / Math.PI; + pitch = dz < 0 ? 90 - pitch : 90 + pitch; + return { + center: toMerc.toLngLat(), + zoom, + pitch, + bearing + }; + } + /** + * Changes any combination of `center`, `zoom`, `bearing`, `pitch`, and `padding` with an animated transition + * between old and new values. The map will retain its current values for any + * details not specified in `options`. + * + * Note: The transition will happen instantly if the user has enabled + * the `reduced motion` accessibility feature enabled in their operating system, + * unless `options` includes `essential: true`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options describing the destination and animation of the transition. + * Accepts {@link CameraOptions} and {@link AnimationOptions}. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + easeTo(options, eventData) { + this._stop(false, options.easeId); + options = performance.extend({ + offset: [0, 0], + duration: 500, + easing: performance.defaultEasing + }, options); + if (options.animate === false || (!options.essential && performance.browser.prefersReducedMotion)) + options.duration = 0; + const tr = this._getTransformForUpdate(), startZoom = this.getZoom(), startBearing = this.getBearing(), startPitch = this.getPitch(), startPadding = this.getPadding(), zoom = 'zoom' in options ? +options.zoom : startZoom, bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing, pitch = 'pitch' in options ? +options.pitch : startPitch, padding = 'padding' in options ? options.padding : tr.padding; + const offsetAsPoint = performance.Point.convert(options.offset); + let pointAtOffset = tr.centerPoint.add(offsetAsPoint); + const locationAtOffset = tr.pointLocation(pointAtOffset); + const center = performance.LngLat.convert(options.center || locationAtOffset); + this._normalizeCenter(center); + const from = tr.project(locationAtOffset); + const delta = tr.project(center).sub(from); + const finalScale = tr.zoomScale(zoom - startZoom); + let around, aroundPoint; + if (options.around) { + around = performance.LngLat.convert(options.around); + aroundPoint = tr.locationPoint(around); + } + const currently = { + moving: this._moving, + zooming: this._zooming, + rotating: this._rotating, + pitching: this._pitching + }; + this._zooming = this._zooming || (zoom !== startZoom); + this._rotating = this._rotating || (startBearing !== bearing); + this._pitching = this._pitching || (pitch !== startPitch); + this._padding = !tr.isPaddingEqual(padding); + this._easeId = options.easeId; + this._prepareEase(eventData, options.noMoveStart, currently); + if (this.terrain) + this._prepareElevation(center); + this._ease((k) => { + if (this._zooming) { + tr.zoom = performance.interpolate.number(startZoom, zoom, k); + } + if (this._rotating) { + tr.bearing = performance.interpolate.number(startBearing, bearing, k); + } + if (this._pitching) { + tr.pitch = performance.interpolate.number(startPitch, pitch, k); + } + if (this._padding) { + tr.interpolatePadding(startPadding, padding, k); + // When padding is being applied, Transform#centerPoint is changing continuously, + // thus we need to recalculate offsetPoint every frame + pointAtOffset = tr.centerPoint.add(offsetAsPoint); + } + if (this.terrain && !options.freezeElevation) + this._updateElevation(k); + if (around) { + tr.setLocationAtPoint(around, aroundPoint); + } + else { + const scale = tr.zoomScale(tr.zoom - startZoom); + const base = zoom > startZoom ? + Math.min(2, finalScale) : + Math.max(0.5, finalScale); + const speedup = Math.pow(base, 1 - k); + const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale)); + tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset); + } + this._applyUpdatedTransform(tr); + this._fireMoveEvents(eventData); + }, (interruptingEaseId) => { + if (this.terrain) + this._finalizeElevation(); + this._afterEase(eventData, interruptingEaseId); + }, options); + return this; + } + _prepareEase(eventData, noMoveStart, currently = {}) { + this._moving = true; + if (!noMoveStart && !currently.moving) { + this.fire(new performance.Event('movestart', eventData)); + } + if (this._zooming && !currently.zooming) { + this.fire(new performance.Event('zoomstart', eventData)); + } + if (this._rotating && !currently.rotating) { + this.fire(new performance.Event('rotatestart', eventData)); + } + if (this._pitching && !currently.pitching) { + this.fire(new performance.Event('pitchstart', eventData)); + } + } + _prepareElevation(center) { + this._elevationCenter = center; + this._elevationStart = this.transform.elevation; + this._elevationTarget = this.terrain.getElevationForLngLatZoom(center, this.transform.tileZoom); + this._elevationFreeze = true; + } + _updateElevation(k) { + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom); + const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom); + // target terrain updated during flight, slowly move camera to new height + if (k < 1 && elevation !== this._elevationTarget) { + const pitch1 = this._elevationTarget - this._elevationStart; + const pitch2 = (elevation - (pitch1 * k + this._elevationStart)) / (1 - k); + this._elevationStart += k * (pitch1 - pitch2); + this._elevationTarget = elevation; + } + this.transform.elevation = performance.interpolate.number(this._elevationStart, this._elevationTarget, k); + } + _finalizeElevation() { + this._elevationFreeze = false; + this.transform.recalculateZoom(this.terrain); + } + /** + * @internal + * Called when the camera is about to be manipulated. + * If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes. + * This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls. + * It may differ from the state used for rendering (`this.transform`). + * @returns Transform to apply changes to + */ + _getTransformForUpdate() { + if (!this.transformCameraUpdate) + return this.transform; + if (!this._requestedCameraState) { + this._requestedCameraState = this.transform.clone(); + } + return this._requestedCameraState; + } + /** + * @internal + * Called after the camera is done being manipulated. + * @param tr - the requested camera end state + * Call `transformCameraUpdate` if present, and then apply the "approved" changes. + */ + _applyUpdatedTransform(tr) { + if (!this.transformCameraUpdate) + return; + const nextTransform = tr.clone(); + const { center, zoom, pitch, bearing, elevation } = this.transformCameraUpdate(nextTransform); + if (center) + nextTransform.center = center; + if (zoom !== undefined) + nextTransform.zoom = zoom; + if (pitch !== undefined) + nextTransform.pitch = pitch; + if (bearing !== undefined) + nextTransform.bearing = bearing; + if (elevation !== undefined) + nextTransform.elevation = elevation; + this.transform.apply(nextTransform); + } + _fireMoveEvents(eventData) { + this.fire(new performance.Event('move', eventData)); + if (this._zooming) { + this.fire(new performance.Event('zoom', eventData)); + } + if (this._rotating) { + this.fire(new performance.Event('rotate', eventData)); + } + if (this._pitching) { + this.fire(new performance.Event('pitch', eventData)); + } + } + _afterEase(eventData, easeId) { + // if this easing is being stopped to start another easing with + // the same id then don't fire any events to avoid extra start/stop events + if (this._easeId && easeId && this._easeId === easeId) { + return; + } + delete this._easeId; + const wasZooming = this._zooming; + const wasRotating = this._rotating; + const wasPitching = this._pitching; + this._moving = false; + this._zooming = false; + this._rotating = false; + this._pitching = false; + this._padding = false; + if (wasZooming) { + this.fire(new performance.Event('zoomend', eventData)); + } + if (wasRotating) { + this.fire(new performance.Event('rotateend', eventData)); + } + if (wasPitching) { + this.fire(new performance.Event('pitchend', eventData)); + } + this.fire(new performance.Event('moveend', eventData)); + } + /** + * Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that + * evokes flight. The animation seamlessly incorporates zooming and panning to help + * the user maintain her bearings even after traversing a great distance. + * + * Note: The animation will be skipped, and this will behave equivalently to `jumpTo` + * if the user has the `reduced motion` accessibility feature enabled in their operating system, + * unless 'options' includes `essential: true`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options describing the destination and animation of the transition. + * Accepts {@link CameraOptions}, {@link AnimationOptions}, + * and the following additional options. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // fly with default options to null island + * map.flyTo({center: [0, 0], zoom: 9}); + * // using flyTo options + * map.flyTo({ + * center: [0, 0], + * zoom: 9, + * speed: 0.2, + * curve: 1, + * easing(t) { + * return t; + * } + * }); + * ``` + * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/) + * @see [Slowly fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto-options/) + * @see [Fly to a location based on scroll position](https://maplibre.org/maplibre-gl-js/docs/examples/scroll-fly-to/) + */ + flyTo(options, eventData) { + // Fall through to jumpTo if user has set prefers-reduced-motion + if (!options.essential && performance.browser.prefersReducedMotion) { + const coercedOptions = performance.pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']); + return this.jumpTo(coercedOptions, eventData); + } + // This method implements an “optimal path” animation, as detailed in: + // + // Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and panning.” INFOVIS + // ’03. pp. 15–22. . + // + // Where applicable, local variable documentation begins with the associated variable or + // function in van Wijk (2003). + this.stop(); + options = performance.extend({ + offset: [0, 0], + speed: 1.2, + curve: 1.42, + easing: performance.defaultEasing + }, options); + const tr = this._getTransformForUpdate(), startZoom = this.getZoom(), startBearing = this.getBearing(), startPitch = this.getPitch(), startPadding = this.getPadding(); + const zoom = 'zoom' in options ? performance.clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom; + const bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing; + const pitch = 'pitch' in options ? +options.pitch : startPitch; + const padding = 'padding' in options ? options.padding : tr.padding; + const scale = tr.zoomScale(zoom - startZoom); + const offsetAsPoint = performance.Point.convert(options.offset); + let pointAtOffset = tr.centerPoint.add(offsetAsPoint); + const locationAtOffset = tr.pointLocation(pointAtOffset); + const center = performance.LngLat.convert(options.center || locationAtOffset); + this._normalizeCenter(center); + const from = tr.project(locationAtOffset); + const delta = tr.project(center).sub(from); + let rho = options.curve; + // w₀: Initial visible span, measured in pixels at the initial scale. + const w0 = Math.max(tr.width, tr.height), + // w₁: Final visible span, measured in pixels with respect to the initial scale. + w1 = w0 / scale, + // Length of the flight path as projected onto the ground plane, measured in pixels from + // the world image origin at the initial scale. + u1 = delta.mag(); + if ('minZoom' in options) { + const minZoom = performance.clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom); + // wm: Maximum visible span, measured in pixels with respect to the initial + // scale. + const wMax = w0 / tr.zoomScale(minZoom - startZoom); + rho = Math.sqrt(wMax / u1 * 2); + } + // ρ² + const rho2 = rho * rho; + /** + * rᵢ: Returns the zoom-out factor at one end of the animation. + * + * @param descent - `true` for the descent, `false` for the ascent + */ + function zoomOutFactor(descent) { + const b = (w1 * w1 - w0 * w0 + (descent ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (descent ? w1 : w0) * rho2 * u1); + return Math.log(Math.sqrt(b * b + 1) - b); + } + function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; } + function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; } + function tanh(n) { return sinh(n) / cosh(n); } + // r₀: Zoom-out factor during ascent. + const r0 = zoomOutFactor(false); + // w(s): Returns the visible span on the ground, measured in pixels with respect to the + // initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°. + let w = function (s) { + return (cosh(r0) / cosh(r0 + rho * s)); + }; + // u(s): Returns the distance along the flight path as projected onto the ground plane, + // measured in pixels from the world image origin at the initial scale. + let u = function (s) { + return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1; + }; + // S: Total length of the flight path, measured in ρ-screenfuls. + let S = (zoomOutFactor(true) - r0) / rho; + // When u₀ = u₁, the optimal path doesn’t require both ascent and descent. + if (Math.abs(u1) < 0.000001 || !isFinite(S)) { + // Perform a more or less instantaneous transition if the path is too short. + if (Math.abs(w0 - w1) < 0.000001) + return this.easeTo(options, eventData); + const k = w1 < w0 ? -1 : 1; + S = Math.abs(Math.log(w1 / w0)) / rho; + u = function () { return 0; }; + w = function (s) { return Math.exp(k * rho * s); }; + } + if ('duration' in options) { + options.duration = +options.duration; + } + else { + const V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed; + options.duration = 1000 * S / V; + } + if (options.maxDuration && options.duration > options.maxDuration) { + options.duration = 0; + } + this._zooming = true; + this._rotating = (startBearing !== bearing); + this._pitching = (pitch !== startPitch); + this._padding = !tr.isPaddingEqual(padding); + this._prepareEase(eventData, false); + if (this.terrain) + this._prepareElevation(center); + this._ease((k) => { + // s: The distance traveled along the flight path, measured in ρ-screenfuls. + const s = k * S; + const scale = 1 / w(s); + tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale); + if (this._rotating) { + tr.bearing = performance.interpolate.number(startBearing, bearing, k); + } + if (this._pitching) { + tr.pitch = performance.interpolate.number(startPitch, pitch, k); + } + if (this._padding) { + tr.interpolatePadding(startPadding, padding, k); + // When padding is being applied, Transform#centerPoint is changing continuously, + // thus we need to recalculate offsetPoint every frame + pointAtOffset = tr.centerPoint.add(offsetAsPoint); + } + if (this.terrain && !options.freezeElevation) + this._updateElevation(k); + const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(scale)); + tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset); + this._applyUpdatedTransform(tr); + this._fireMoveEvents(eventData); + }, () => { + if (this.terrain) + this._finalizeElevation(); + this._afterEase(eventData); + }, options); + return this; + } + isEasing() { + return !!this._easeFrameId; + } + /** + * Stops any animated transition underway. + * + * @returns `this` + */ + stop() { + return this._stop(); + } + _stop(allowGestures, easeId) { + if (this._easeFrameId) { + this._cancelRenderFrame(this._easeFrameId); + delete this._easeFrameId; + delete this._onEaseFrame; + } + if (this._onEaseEnd) { + // The _onEaseEnd function might emit events which trigger new + // animation, which sets a new _onEaseEnd. Ensure we don't delete + // it unintentionally. + const onEaseEnd = this._onEaseEnd; + delete this._onEaseEnd; + onEaseEnd.call(this, easeId); + } + if (!allowGestures) { + const handlers = this.handlers; + if (handlers) + handlers.stop(false); + } + return this; + } + _ease(frame, finish, options) { + if (options.animate === false || options.duration === 0) { + frame(1); + finish(); + } + else { + this._easeStart = performance.browser.now(); + this._easeOptions = options; + this._onEaseFrame = frame; + this._onEaseEnd = finish; + this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback); + } + } + // convert bearing so that it's numerically close to the current one so that it interpolates properly + _normalizeBearing(bearing, currentBearing) { + bearing = performance.wrap(bearing, -180, 180); + const diff = Math.abs(bearing - currentBearing); + if (Math.abs(bearing - 360 - currentBearing) < diff) + bearing -= 360; + if (Math.abs(bearing + 360 - currentBearing) < diff) + bearing += 360; + return bearing; + } + // If a path crossing the antimeridian would be shorter, extend the final coordinate so that + // interpolating between the two endpoints will cross it. + _normalizeCenter(center) { + const tr = this.transform; + if (!tr.renderWorldCopies || tr.lngRange) + return; + const delta = center.lng - tr.center.lng; + center.lng += + delta > 180 ? -360 : + delta < -180 ? 360 : 0; + } + /** + * Query the current elevation of location. It return null if terrain is not enabled. the elevation is in meters relative to mean sea-level + * @param lngLatLike - [x,y] or LngLat coordinates of the location + * @returns elevation in meters + */ + queryTerrainElevation(lngLatLike) { + if (!this.terrain) { + return null; + } + const elevation = this.terrain.getElevationForLngLatZoom(performance.LngLat.convert(lngLatLike), this.transform.tileZoom); + /** + * Different zoomlevels with different terrain-tiles the elevation-values are not the same. + * map.transform.elevation variable with the center-altitude. + * In maplibre the proj-matrix is translated by this value in negative z-direction. + * So we need to add this value to the elevation to get the correct value. + */ + return elevation - this.transform.elevation; + } +} + +/** + * An `AttributionControl` control presents the map's attribution information. By default, the attribution control is expanded (regardless of map width). + * @group Markers and Controls + * @example + * ```ts + * let map = new maplibregl.Map({attributionControl: false}) + * .addControl(new maplibregl.AttributionControl({ + * compact: true + * })); + * ``` + */ +class AttributionControl { + /** + * @param options - the attribution options + */ + constructor(options = {}) { + this._toggleAttribution = () => { + if (this._container.classList.contains('maplibregl-compact')) { + if (this._container.classList.contains('maplibregl-compact-show')) { + this._container.setAttribute('open', ''); + this._container.classList.remove('maplibregl-compact-show'); + } + else { + this._container.classList.add('maplibregl-compact-show'); + this._container.removeAttribute('open'); + } + } + }; + this._updateData = (e) => { + if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style' || e.type === 'terrain')) { + this._updateAttributions(); + } + }; + this._updateCompact = () => { + if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) { + if (this._compact === false) { + this._container.setAttribute('open', ''); + } + else if (!this._container.classList.contains('maplibregl-compact') && !this._container.classList.contains('maplibregl-attrib-empty')) { + this._container.setAttribute('open', ''); + this._container.classList.add('maplibregl-compact', 'maplibregl-compact-show'); + } + } + else { + this._container.setAttribute('open', ''); + if (this._container.classList.contains('maplibregl-compact')) { + this._container.classList.remove('maplibregl-compact', 'maplibregl-compact-show'); + } + } + }; + this._updateCompactMinimize = () => { + if (this._container.classList.contains('maplibregl-compact')) { + if (this._container.classList.contains('maplibregl-compact-show')) { + this._container.classList.remove('maplibregl-compact-show'); + } + } + }; + this.options = options; + } + getDefaultPosition() { + return 'bottom-right'; + } + /** {@inheritDoc IControl.onAdd} */ + onAdd(map) { + this._map = map; + this._compact = this.options && this.options.compact; + this._container = DOM.create('details', 'maplibregl-ctrl maplibregl-ctrl-attrib'); + this._compactButton = DOM.create('summary', 'maplibregl-ctrl-attrib-button', this._container); + this._compactButton.addEventListener('click', this._toggleAttribution); + this._setElementTitle(this._compactButton, 'ToggleAttribution'); + this._innerContainer = DOM.create('div', 'maplibregl-ctrl-attrib-inner', this._container); + this._updateAttributions(); + this._updateCompact(); + this._map.on('styledata', this._updateData); + this._map.on('sourcedata', this._updateData); + this._map.on('terrain', this._updateData); + this._map.on('resize', this._updateCompact); + this._map.on('drag', this._updateCompactMinimize); + return this._container; + } + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('styledata', this._updateData); + this._map.off('sourcedata', this._updateData); + this._map.off('terrain', this._updateData); + this._map.off('resize', this._updateCompact); + this._map.off('drag', this._updateCompactMinimize); + this._map = undefined; + this._compact = undefined; + this._attribHTML = undefined; + } + _setElementTitle(element, title) { + const str = this._map._getUIString(`AttributionControl.${title}`); + element.title = str; + element.setAttribute('aria-label', str); + } + _updateAttributions() { + if (!this._map.style) + return; + let attributions = []; + if (this.options.customAttribution) { + if (Array.isArray(this.options.customAttribution)) { + attributions = attributions.concat(this.options.customAttribution.map(attribution => { + if (typeof attribution !== 'string') + return ''; + return attribution; + })); + } + else if (typeof this.options.customAttribution === 'string') { + attributions.push(this.options.customAttribution); + } + } + if (this._map.style.stylesheet) { + const stylesheet = this._map.style.stylesheet; + this.styleOwner = stylesheet.owner; + this.styleId = stylesheet.id; + } + const sourceCaches = this._map.style.sourceCaches; + for (const id in sourceCaches) { + const sourceCache = sourceCaches[id]; + if (sourceCache.used || sourceCache.usedForTerrain) { + const source = sourceCache.getSource(); + if (source.attribution && attributions.indexOf(source.attribution) < 0) { + attributions.push(source.attribution); + } + } + } + // remove any entries that are whitespace + attributions = attributions.filter(e => String(e).trim()); + // remove any entries that are substrings of another entry. + // first sort by length so that substrings come first + attributions.sort((a, b) => a.length - b.length); + attributions = attributions.filter((attrib, i) => { + for (let j = i + 1; j < attributions.length; j++) { + if (attributions[j].indexOf(attrib) >= 0) { + return false; + } + } + return true; + }); + // check if attribution string is different to minimize DOM changes + const attribHTML = attributions.join(' | '); + if (attribHTML === this._attribHTML) + return; + this._attribHTML = attribHTML; + if (attributions.length) { + this._innerContainer.innerHTML = attribHTML; + this._container.classList.remove('maplibregl-attrib-empty'); + } + else { + this._container.classList.add('maplibregl-attrib-empty'); + } + this._updateCompact(); + // remove old DOM node from _editLink + this._editLink = null; + } +} + +/** + * A `LogoControl` is a control that adds the watermark. + * + * @group Markers and Controls + * + * @example + * ```ts + * map.addControl(new maplibregl.LogoControl({compact: false})); + * ``` + **/ +class LogoControl { + constructor(options = {}) { + this._updateCompact = () => { + const containerChildren = this._container.children; + if (containerChildren.length) { + const anchor = containerChildren[0]; + if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) { + if (this._compact !== false) { + anchor.classList.add('maplibregl-compact'); + } + } + else { + anchor.classList.remove('maplibregl-compact'); + } + } + }; + this.options = options; + } + getDefaultPosition() { + return 'bottom-left'; + } + /** {@inheritDoc IControl.onAdd} */ + onAdd(map) { + this._map = map; + this._compact = this.options && this.options.compact; + this._container = DOM.create('div', 'maplibregl-ctrl'); + const anchor = DOM.create('a', 'maplibregl-ctrl-logo'); + anchor.target = '_blank'; + anchor.rel = 'noopener nofollow'; + anchor.href = 'https://maplibre.org/'; + anchor.setAttribute('aria-label', this._map._getUIString('LogoControl.Title')); + anchor.setAttribute('rel', 'noopener nofollow'); + this._container.appendChild(anchor); + this._container.style.display = 'block'; + this._map.on('resize', this._updateCompact); + this._updateCompact(); + return this._container; + } + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('resize', this._updateCompact); + this._map = undefined; + this._compact = undefined; + } +} + +class TaskQueue { + constructor() { + this._queue = []; + this._id = 0; + this._cleared = false; + this._currentlyRunning = false; + } + add(callback) { + const id = ++this._id; + const queue = this._queue; + queue.push({ callback, id, cancelled: false }); + return id; + } + remove(id) { + const running = this._currentlyRunning; + const queue = running ? this._queue.concat(running) : this._queue; + for (const task of queue) { + if (task.id === id) { + task.cancelled = true; + return; + } + } + } + run(timeStamp = 0) { + if (this._currentlyRunning) + throw new Error('Attempting to run(), but is already running.'); + const queue = this._currentlyRunning = this._queue; + // Tasks queued by callbacks in the current queue should be executed + // on the next run, not the current run. + this._queue = []; + for (const task of queue) { + if (task.cancelled) + continue; + task.callback(timeStamp); + if (this._cleared) + break; + } + this._cleared = false; + this._currentlyRunning = false; + } + clear() { + if (this._currentlyRunning) { + this._cleared = true; + } + this._queue = []; + } +} + +const defaultLocale = { + 'AttributionControl.ToggleAttribution': 'Toggle attribution', + 'AttributionControl.MapFeedback': 'Map feedback', + 'FullscreenControl.Enter': 'Enter fullscreen', + 'FullscreenControl.Exit': 'Exit fullscreen', + 'GeolocateControl.FindMyLocation': 'Find my location', + 'GeolocateControl.LocationNotAvailable': 'Location not available', + 'LogoControl.Title': 'Mapbox logo', + 'NavigationControl.ResetBearing': 'Reset bearing to north', + 'NavigationControl.ZoomIn': 'Zoom in', + 'NavigationControl.ZoomOut': 'Zoom out', + 'ScaleControl.Feet': 'ft', + 'ScaleControl.Meters': 'm', + 'ScaleControl.Kilometers': 'km', + 'ScaleControl.Miles': 'mi', + 'ScaleControl.NauticalMiles': 'nm', + 'TerrainControl.enableTerrain': 'Enable terrain', + 'TerrainControl.disableTerrain': 'Disable terrain' +}; + +var pos3dAttributes = performance.createLayout([ + { name: 'a_pos3d', type: 'Int16', components: 3 } +]); + +/** + * @internal + * This class is a helper for the Terrain-class, it: + * - loads raster-dem tiles + * - manages all renderToTexture tiles. + * - caches previous rendered tiles. + * - finds all necessary renderToTexture tiles for a OverscaledTileID area + * - finds the corresponding raster-dem tile for OverscaledTileID + */ +class TerrainSourceCache extends performance.Evented { + constructor(sourceCache) { + super(); + this.sourceCache = sourceCache; + this._tiles = {}; + this._renderableTilesKeys = []; + this._sourceTileCache = {}; + this.minzoom = 0; + this.maxzoom = 22; + this.tileSize = 512; + this.deltaZoom = 1; + sourceCache.usedForTerrain = true; + sourceCache.tileSize = this.tileSize * 2 ** this.deltaZoom; + } + destruct() { + this.sourceCache.usedForTerrain = false; + this.sourceCache.tileSize = null; + } + /** + * Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory. + * @param transform - the operation to do + * @param terrain - the terrain + */ + update(transform, terrain) { + // load raster-dem tiles for the current scene. + this.sourceCache.update(transform, terrain); + // create internal render-to-texture tiles for the current scene. + this._renderableTilesKeys = []; + const keys = {}; + for (const tileID of transform.coveringTiles({ + tileSize: this.tileSize, + minzoom: this.minzoom, + maxzoom: this.maxzoom, + reparseOverscaled: false, + terrain + })) { + keys[tileID.key] = true; + this._renderableTilesKeys.push(tileID.key); + if (!this._tiles[tileID.key]) { + tileID.posMatrix = new Float64Array(16); + performance.ortho(tileID.posMatrix, 0, performance.EXTENT, 0, performance.EXTENT, 0, 1); + this._tiles[tileID.key] = new Tile(tileID, this.tileSize); + } + } + // free unused tiles + for (const key in this._tiles) { + if (!keys[key]) + delete this._tiles[key]; + } + } + /** + * Free render to texture cache + * @param tileID - optional, free only corresponding to tileID. + */ + freeRtt(tileID) { + for (const key in this._tiles) { + const tile = this._tiles[key]; + if (!tileID || tile.tileID.equals(tileID) || tile.tileID.isChildOf(tileID) || tileID.isChildOf(tile.tileID)) + tile.rtt = []; + } + } + /** + * get a list of tiles, which are loaded and should be rendered in the current scene + * @returns the renderable tiles + */ + getRenderableTiles() { + return this._renderableTilesKeys.map(key => this.getTileByID(key)); + } + /** + * get terrain tile by the TileID key + * @param id - the tile id + * @returns the tile + */ + getTileByID(id) { + return this._tiles[id]; + } + /** + * Searches for the corresponding current renderable terrain-tiles + * @param tileID - the tile to look for + * @returns the tiles that were found + */ + getTerrainCoords(tileID) { + const coords = {}; + for (const key of this._renderableTilesKeys) { + const _tileID = this._tiles[key].tileID; + if (_tileID.canonical.equals(tileID.canonical)) { + const coord = tileID.clone(); + coord.posMatrix = new Float64Array(16); + performance.ortho(coord.posMatrix, 0, performance.EXTENT, 0, performance.EXTENT, 0, 1); + coords[key] = coord; + } + else if (_tileID.canonical.isChildOf(tileID.canonical)) { + const coord = tileID.clone(); + coord.posMatrix = new Float64Array(16); + const dz = _tileID.canonical.z - tileID.canonical.z; + const dx = _tileID.canonical.x - (_tileID.canonical.x >> dz << dz); + const dy = _tileID.canonical.y - (_tileID.canonical.y >> dz << dz); + const size = performance.EXTENT >> dz; + performance.ortho(coord.posMatrix, 0, size, 0, size, 0, 1); + performance.translate(coord.posMatrix, coord.posMatrix, [-dx * size, -dy * size, 0]); + coords[key] = coord; + } + else if (tileID.canonical.isChildOf(_tileID.canonical)) { + const coord = tileID.clone(); + coord.posMatrix = new Float64Array(16); + const dz = tileID.canonical.z - _tileID.canonical.z; + const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz); + const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz); + const size = performance.EXTENT >> dz; + performance.ortho(coord.posMatrix, 0, performance.EXTENT, 0, performance.EXTENT, 0, 1); + performance.translate(coord.posMatrix, coord.posMatrix, [dx * size, dy * size, 0]); + performance.scale(coord.posMatrix, coord.posMatrix, [1 / (2 ** dz), 1 / (2 ** dz), 0]); + coords[key] = coord; + } + } + return coords; + } + /** + * find the covering raster-dem tile + * @param tileID - the tile to look for + * @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem. + * @returns the tile + */ + getSourceTile(tileID, searchForDEM) { + const source = this.sourceCache._source; + let z = tileID.overscaledZ - this.deltaZoom; + if (z > source.maxzoom) + z = source.maxzoom; + if (z < source.minzoom) + return null; + // cache for tileID to terrain-tileID + if (!this._sourceTileCache[tileID.key]) + this._sourceTileCache[tileID.key] = tileID.scaledTo(z).key; + let tile = this.sourceCache.getTileByID(this._sourceTileCache[tileID.key]); + // during tile-loading phase look if parent tiles (with loaded dem) are available. + if (!(tile && tile.dem) && searchForDEM) + while (z >= source.minzoom && !(tile && tile.dem)) + tile = this.sourceCache.getTileByID(tileID.scaledTo(z--).key); + return tile; + } + /** + * get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers. + * @param time - the time + * @returns the relevant tiles + */ + tilesAfterTime(time = Date.now()) { + return Object.values(this._tiles).filter(t => t.timeAdded >= time); + } +} + +/** + * @internal + * This is the main class which handles most of the 3D Terrain logic. It has the following topics: + * 1) loads raster-dem tiles via the internal sourceCache this.sourceCache + * 2) creates a depth-framebuffer, which is used to calculate the visibility of coordinates + * 3) creates a coords-framebuffer, which is used the get to tile-coordinate for a screen-pixel + * 4) stores all render-to-texture tiles in the this.sourceCache._tiles + * 5) calculates the elevation for a specific tile-coordinate + * 6) creates a terrain-mesh + * + * A note about the GPU resource-usage: + * Framebuffers: + * - one for the depth & coords framebuffer with the size of the map-div. + * - one for rendering a tile to texture with the size of tileSize (= 512x512). + * Textures: + * - one texture for an empty raster-dem tile with size 1x1 + * - one texture for an empty depth-buffer, when terrain is disabled with size 1x1 + * - one texture for an each loaded raster-dem with size of the source.tileSize + * - one texture for the coords-framebuffer with the size of the map-div. + * - one texture for the depth-framebuffer with the size of the map-div. + * - one texture for the encoded tile-coords with the size 2*tileSize (=1024x1024) + * - finally for each render-to-texture tile (= this._tiles) a set of textures + * for each render stack (The stack-concept is documented in painter.ts). + * Normally there exists 1-3 Textures per tile, depending on the stylesheet. + * Each Textures has the size 2*tileSize (= 1024x1024). Also there exists a + * cache of the last 150 newest rendered tiles. + * + */ +class Terrain { + constructor(painter, sourceCache, options) { + this.painter = painter; + this.sourceCache = new TerrainSourceCache(sourceCache); + this.options = options; + this.exaggeration = typeof options.exaggeration === 'number' ? options.exaggeration : 1.0; + this.qualityFactor = 2; + this.meshSize = 128; + this._demMatrixCache = {}; + this.coordsIndex = []; + this._coordsTextureSize = 1024; + } + /** + * get the elevation-value from original dem-data for a given tile-coordinate + * @param tileID - the tile to get elevation for + * @param x - between 0 .. EXTENT + * @param y - between 0 .. EXTENT + * @param extent - optional, default 8192 + * @returns the elevation + */ + getDEMElevation(tileID, x, y, extent = performance.EXTENT) { + var _a; + if (!(x >= 0 && x < extent && y >= 0 && y < extent)) + return 0; + const terrain = this.getTerrainData(tileID); + const dem = (_a = terrain.tile) === null || _a === void 0 ? void 0 : _a.dem; + if (!dem) + return 0; + const pos = performance.transformMat4$1([], [x / extent * performance.EXTENT, y / extent * performance.EXTENT], terrain.u_terrain_matrix); + const coord = [pos[0] * dem.dim, pos[1] * dem.dim]; + // bilinear interpolation + const cx = Math.floor(coord[0]), cy = Math.floor(coord[1]), tx = coord[0] - cx, ty = coord[1] - cy; + return (dem.get(cx, cy) * (1 - tx) * (1 - ty) + + dem.get(cx + 1, cy) * (tx) * (1 - ty) + + dem.get(cx, cy + 1) * (1 - tx) * (ty) + + dem.get(cx + 1, cy + 1) * (tx) * (ty)); + } + /** + * Get the elevation for given {@link LngLat} in respect of exaggeration. + * @param lnglat - the location + * @param zoom - the zoom + * @returns the elevation + */ + getElevationForLngLatZoom(lnglat, zoom) { + const { tileID, mercatorX, mercatorY } = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom); + return this.getElevation(tileID, mercatorX % performance.EXTENT, mercatorY % performance.EXTENT, performance.EXTENT); + } + /** + * Get the elevation for given coordinate in respect of exaggeration. + * @param tileID - the tile id + * @param x - between 0 .. EXTENT + * @param y - between 0 .. EXTENT + * @param extent - optional, default 8192 + * @returns the elevation + */ + getElevation(tileID, x, y, extent = performance.EXTENT) { + return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration; + } + /** + * returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object + * @param tileID - the tile to get the terrain for + * @returns the terrain data to use in the program + */ + getTerrainData(tileID) { + // create empty DEM Objects, which will used while raster-dem tiles are loading. + // creates an empty depth-buffer texture which is needed, during the initialization process of the 3d mesh.. + if (!this._emptyDemTexture) { + const context = this.painter.context; + const image = new performance.RGBAImage({ width: 1, height: 1 }, new Uint8Array(1 * 4)); + this._emptyDepthTexture = new Texture(context, image, context.gl.RGBA, { premultiply: false }); + this._emptyDemUnpack = [0, 0, 0, 0]; + this._emptyDemTexture = new Texture(context, new performance.RGBAImage({ width: 1, height: 1 }), context.gl.RGBA, { premultiply: false }); + this._emptyDemTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE); + this._emptyDemMatrix = performance.identity([]); + } + // find covering dem tile and prepare demTexture + const sourceTile = this.sourceCache.getSourceTile(tileID, true); + if (sourceTile && sourceTile.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) { + const context = this.painter.context; + sourceTile.demTexture = this.painter.getTileTexture(sourceTile.dem.stride); + if (sourceTile.demTexture) + sourceTile.demTexture.update(sourceTile.dem.getPixels(), { premultiply: false }); + else + sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, { premultiply: false }); + sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE); + sourceTile.needsTerrainPrepare = false; + } + // create matrix for lookup in dem data + const matrixKey = sourceTile && (sourceTile + sourceTile.tileID.key) + tileID.key; + if (matrixKey && !this._demMatrixCache[matrixKey]) { + const maxzoom = this.sourceCache.sourceCache._source.maxzoom; + let dz = tileID.canonical.z - sourceTile.tileID.canonical.z; + if (tileID.overscaledZ > tileID.canonical.z) { + if (tileID.canonical.z >= maxzoom) + dz = tileID.canonical.z - maxzoom; + else + performance.warnOnce('cannot calculate elevation if elevation maxzoom > source.maxzoom'); + } + const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz); + const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz); + const demMatrix = performance.fromScaling(new Float64Array(16), [1 / (performance.EXTENT << dz), 1 / (performance.EXTENT << dz), 0]); + performance.translate(demMatrix, demMatrix, [dx * performance.EXTENT, dy * performance.EXTENT, 0]); + this._demMatrixCache[tileID.key] = { matrix: demMatrix, coord: tileID }; + } + // return uniform values & textures + return { + 'u_depth': 2, + 'u_terrain': 3, + 'u_terrain_dim': sourceTile && sourceTile.dem && sourceTile.dem.dim || 1, + 'u_terrain_matrix': matrixKey ? this._demMatrixCache[tileID.key].matrix : this._emptyDemMatrix, + 'u_terrain_unpack': sourceTile && sourceTile.dem && sourceTile.dem.getUnpackVector() || this._emptyDemUnpack, + 'u_terrain_exaggeration': this.exaggeration, + texture: (sourceTile && sourceTile.demTexture || this._emptyDemTexture).texture, + depthTexture: (this._fboDepthTexture || this._emptyDepthTexture).texture, + tile: sourceTile + }; + } + /** + * get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture + * @param texture - the texture + * @returns the frame buffer + */ + getFramebuffer(texture) { + const painter = this.painter; + const width = painter.width / devicePixelRatio; + const height = painter.height / devicePixelRatio; + if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) { + this._fbo.destroy(); + this._fboCoordsTexture.destroy(); + this._fboDepthTexture.destroy(); + delete this._fbo; + delete this._fboDepthTexture; + delete this._fboCoordsTexture; + } + if (!this._fboCoordsTexture) { + this._fboCoordsTexture = new Texture(painter.context, { width, height, data: null }, painter.context.gl.RGBA, { premultiply: false }); + this._fboCoordsTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE); + } + if (!this._fboDepthTexture) { + this._fboDepthTexture = new Texture(painter.context, { width, height, data: null }, painter.context.gl.RGBA, { premultiply: false }); + this._fboDepthTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE); + } + if (!this._fbo) { + this._fbo = painter.context.createFramebuffer(width, height, true, false); + this._fbo.depthAttachment.set(painter.context.createRenderbuffer(painter.context.gl.DEPTH_COMPONENT16, width, height)); + } + this._fbo.colorAttachment.set(texture === 'coords' ? this._fboCoordsTexture.texture : this._fboDepthTexture.texture); + return this._fbo; + } + /** + * create coords texture, needed to grab coordinates from canvas + * encode coords coordinate into 4 bytes: + * - 8 lower bits for x + * - 8 lower bits for y + * - 4 higher bits for x + * - 4 higher bits for y + * - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value + * @returns the texture + */ + getCoordsTexture() { + const context = this.painter.context; + if (this._coordsTexture) + return this._coordsTexture; + const data = new Uint8Array(this._coordsTextureSize * this._coordsTextureSize * 4); + for (let y = 0, i = 0; y < this._coordsTextureSize; y++) + for (let x = 0; x < this._coordsTextureSize; x++, i += 4) { + data[i + 0] = x & 255; + data[i + 1] = y & 255; + data[i + 2] = ((x >> 8) << 4) | (y >> 8); + data[i + 3] = 0; + } + const image = new performance.RGBAImage({ width: this._coordsTextureSize, height: this._coordsTextureSize }, new Uint8Array(data.buffer)); + const texture = new Texture(context, image, context.gl.RGBA, { premultiply: false }); + texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE); + this._coordsTexture = texture; + return texture; + } + /** + * Reads a pixel from the coords-framebuffer and translate this to mercator. + * @param p - Screen-Coordinate + * @returns mercator coordinate for a screen pixel + */ + pointCoordinate(p) { + const rgba = new Uint8Array(4); + const context = this.painter.context, gl = context.gl; + // grab coordinate pixel from coordinates framebuffer + context.bindFramebuffer.set(this.getFramebuffer('coords').framebuffer); + gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba); + context.bindFramebuffer.set(null); + // decode coordinates (encoding see getCoordsTexture) + const x = rgba[0] + ((rgba[2] >> 4) << 8); + const y = rgba[1] + ((rgba[2] & 15) << 8); + const tileID = this.coordsIndex[255 - rgba[3]]; + const tile = tileID && this.sourceCache.getTileByID(tileID); + if (!tile) + return null; + const coordsSize = this._coordsTextureSize; + const worldSize = (1 << tile.tileID.canonical.z) * coordsSize; + const mercatorX = (tile.tileID.canonical.x * coordsSize + x) / worldSize; + return new performance.MercatorCoordinate(this._allowMercatorOverflow(p, mercatorX), (tile.tileID.canonical.y * coordsSize + y) / worldSize, this.getElevation(tile.tileID, x, y, coordsSize)); + } + /** + * create a regular mesh which will be used by all terrain-tiles + * @returns the created regular mesh + */ + getTerrainMesh() { + if (this._mesh) + return this._mesh; + const context = this.painter.context; + const vertexArray = new performance.Pos3dArray(); + const indexArray = new performance.TriangleIndexArray(); + const meshSize = this.meshSize; + const delta = performance.EXTENT / meshSize; + const meshSize2 = meshSize * meshSize; + for (let y = 0; y <= meshSize; y++) + for (let x = 0; x <= meshSize; x++) + vertexArray.emplaceBack(x * delta, y * delta, 0); + for (let y = 0; y < meshSize2; y += meshSize + 1) + for (let x = 0; x < meshSize; x++) { + indexArray.emplaceBack(x + y, meshSize + x + y + 1, meshSize + x + y + 2); + indexArray.emplaceBack(x + y, meshSize + x + y + 2, x + y + 1); + } + // add an extra frame around the mesh to avoid stiching on tile boundaries with different zoomlevels + // first code-block is for top-bottom frame and second for left-right frame + const offsetTop = vertexArray.length, offsetBottom = offsetTop + (meshSize + 1) * 2; + for (const y of [0, 1]) + for (let x = 0; x <= meshSize; x++) + for (const z of [0, 1]) + vertexArray.emplaceBack(x * delta, y * performance.EXTENT, z); + for (let x = 0; x < meshSize * 2; x += 2) { + indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 1, offsetBottom + x + 3); + indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 3, offsetBottom + x + 2); + indexArray.emplaceBack(offsetTop + x, offsetTop + x + 3, offsetTop + x + 1); + indexArray.emplaceBack(offsetTop + x, offsetTop + x + 2, offsetTop + x + 3); + } + const offsetLeft = vertexArray.length, offsetRight = offsetLeft + (meshSize + 1) * 2; + for (const x of [0, 1]) + for (let y = 0; y <= meshSize; y++) + for (const z of [0, 1]) + vertexArray.emplaceBack(x * performance.EXTENT, y * delta, z); + for (let y = 0; y < meshSize * 2; y += 2) { + indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 1, offsetLeft + y + 3); + indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 3, offsetLeft + y + 2); + indexArray.emplaceBack(offsetRight + y, offsetRight + y + 3, offsetRight + y + 1); + indexArray.emplaceBack(offsetRight + y, offsetRight + y + 2, offsetRight + y + 3); + } + this._mesh = { + indexBuffer: context.createIndexBuffer(indexArray), + vertexBuffer: context.createVertexBuffer(vertexArray, pos3dAttributes.members), + segments: performance.SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length) + }; + return this._mesh; + } + /** + * Calculates a height of the frame around the terrain-mesh to avoid stiching between + * tile boundaries in different zoomlevels. + * @param zoom - current zoomlevel + * @returns the elevation delta in meters + */ + getMeshFrameDelta(zoom) { + // divide by 5 is evaluated by trial & error to get a frame in the right height + return 2 * Math.PI * performance.earthRadius / Math.pow(2, zoom) / 5; + } + getMinTileElevationForLngLatZoom(lnglat, zoom) { + var _a; + const { tileID } = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom); + return (_a = this.getMinMaxElevation(tileID).minElevation) !== null && _a !== void 0 ? _a : 0; + } + /** + * Get the minimum and maximum elevation contained in a tile. This includes any + * exaggeration included in the terrain. + * + * @param tileID - ID of the tile to be used as a source for the min/max elevation + * @returns the minimum and maximum elevation found in the tile, including the terrain's + * exaggeration + */ + getMinMaxElevation(tileID) { + const tile = this.getTerrainData(tileID).tile; + const minMax = { minElevation: null, maxElevation: null }; + if (tile && tile.dem) { + minMax.minElevation = tile.dem.min * this.exaggeration; + minMax.maxElevation = tile.dem.max * this.exaggeration; + } + return minMax; + } + _getOverscaledTileIDFromLngLatZoom(lnglat, zoom) { + const mercatorCoordinate = performance.MercatorCoordinate.fromLngLat(lnglat.wrap()); + const worldSize = (1 << zoom) * performance.EXTENT; + const mercatorX = mercatorCoordinate.x * worldSize; + const mercatorY = mercatorCoordinate.y * worldSize; + const tileX = Math.floor(mercatorX / performance.EXTENT), tileY = Math.floor(mercatorY / performance.EXTENT); + const tileID = new performance.OverscaledTileID(zoom, 0, zoom, tileX, tileY); + return { + tileID, + mercatorX, + mercatorY + }; + } + _allowMercatorOverflow(p, mercatorX) { + const inLeftHalf = p.x < (this.painter.width / 2); + let lng = performance.lngFromMercatorX(mercatorX); + const centerLng = this.painter.transform.center.lng; + if ((inLeftHalf && Math.sign(lng) > 0 && Math.sign(centerLng) < 0) || + (!inLeftHalf && Math.sign(lng) < 0 && Math.sign(centerLng) > 0)) { + lng = 360 * Math.sign(centerLng) + lng; + return performance.mercatorXfromLng(lng); + } + return mercatorX; + } +} + +/** + * @internal + * `RenderPool` is a resource pool for textures and framebuffers + */ +class RenderPool { + constructor(_context, _size, _tileSize) { + this._context = _context; + this._size = _size; + this._tileSize = _tileSize; + this._objects = []; + this._recentlyUsed = []; + this._stamp = 0; + } + destruct() { + for (const obj of this._objects) { + obj.texture.destroy(); + obj.fbo.destroy(); + } + } + _createObject(id) { + const fbo = this._context.createFramebuffer(this._tileSize, this._tileSize, true, true); + const texture = new Texture(this._context, { width: this._tileSize, height: this._tileSize, data: null }, this._context.gl.RGBA); + texture.bind(this._context.gl.LINEAR, this._context.gl.CLAMP_TO_EDGE); + fbo.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL, this._tileSize, this._tileSize)); + fbo.colorAttachment.set(texture.texture); + return { id, fbo, texture, stamp: -1, inUse: false }; + } + getObjectForId(id) { + return this._objects[id]; + } + useObject(obj) { + obj.inUse = true; + this._recentlyUsed = this._recentlyUsed.filter(id => obj.id !== id); + this._recentlyUsed.push(obj.id); + } + stampObject(obj) { + obj.stamp = ++this._stamp; + } + getOrCreateFreeObject() { + // check for free existing object + for (const id of this._recentlyUsed) { + if (!this._objects[id].inUse) + return this._objects[id]; + } + if (this._objects.length >= this._size) + throw new Error('No free RenderPool available, call freeAllObjects() required!'); + // create new object + const obj = this._createObject(this._objects.length); + this._objects.push(obj); + return obj; + } + freeObject(obj) { + obj.inUse = false; + } + freeAllObjects() { + for (const obj of this._objects) + this.freeObject(obj); + } + isFull() { + if (this._objects.length < this._size) { + return false; + } + return this._objects.some(o => !o.inUse) === false; + } +} + +/** + * lookup table which layers should rendered to texture + */ +const LAYERS = { + background: true, + fill: true, + line: true, + raster: true, + hillshade: true +}; +/** + * @internal + * A helper class to help define what should be rendered to texture and how + */ +class RenderToTexture { + constructor(painter, terrain) { + this.painter = painter; + this.terrain = terrain; + this.pool = new RenderPool(painter.context, 30, terrain.sourceCache.tileSize * terrain.qualityFactor); + } + destruct() { + this.pool.destruct(); + } + getTexture(tile) { + return this.pool.getObjectForId(tile.rtt[this._stacks.length - 1].id).texture; + } + prepareForRender(style, zoom) { + this._stacks = []; + this._prevType = null; + this._rttTiles = []; + this._renderableTiles = this.terrain.sourceCache.getRenderableTiles(); + this._renderableLayerIds = style._order.filter(id => !style._layers[id].isHidden(zoom)); + this._coordsDescendingInv = {}; + for (const id in style.sourceCaches) { + this._coordsDescendingInv[id] = {}; + const tileIDs = style.sourceCaches[id].getVisibleCoordinates(); + for (const tileID of tileIDs) { + const keys = this.terrain.sourceCache.getTerrainCoords(tileID); + for (const key in keys) { + if (!this._coordsDescendingInv[id][key]) + this._coordsDescendingInv[id][key] = []; + this._coordsDescendingInv[id][key].push(keys[key]); + } + } + } + this._coordsDescendingInvStr = {}; + for (const id of style._order) { + const layer = style._layers[id], source = layer.source; + if (LAYERS[layer.type]) { + if (!this._coordsDescendingInvStr[source]) { + this._coordsDescendingInvStr[source] = {}; + for (const key in this._coordsDescendingInv[source]) + this._coordsDescendingInvStr[source][key] = this._coordsDescendingInv[source][key].map(c => c.key).sort().join(); + } + } + } + // check tiles to render + for (const tile of this._renderableTiles) { + for (const source in this._coordsDescendingInvStr) { + // rerender if there are more coords to render than in the last rendering + const coords = this._coordsDescendingInvStr[source][tile.tileID.key]; + if (coords && coords !== tile.rttCoords[source]) + tile.rtt = []; + } + } + } + /** + * due that switching textures is relatively slow, the render + * layer-by-layer context is not practicable. To bypass this problem + * this lines of code stack all layers and later render all at once. + * Because of the stylesheet possibility to mixing render-to-texture layers + * and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example + * a symbol-layer is in between of fill-layers. + * @param layer - the layer to render + * @returns if true layer is rendered to texture, otherwise false + */ + renderLayer(layer) { + if (layer.isHidden(this.painter.transform.zoom)) + return false; + const type = layer.type; + const painter = this.painter; + const isLastLayer = this._renderableLayerIds[this._renderableLayerIds.length - 1] === layer.id; + // remember background, fill, line & raster layer to render into a stack + if (LAYERS[type]) { + // create a new stack if previous layer was not rendered to texture (f.e. symbols) + if (!this._prevType || !LAYERS[this._prevType]) + this._stacks.push([]); + // push current render-to-texture layer to render-stack + this._prevType = type; + this._stacks[this._stacks.length - 1].push(layer.id); + // rendering is done later, all in once + if (!isLastLayer) + return true; + } + // in case a stack is finished render all collected stack-layers into a texture + if (LAYERS[this._prevType] || (LAYERS[type] && isLastLayer)) { + this._prevType = type; + const stack = this._stacks.length - 1, layers = this._stacks[stack] || []; + for (const tile of this._renderableTiles) { + // if render pool is full draw current tiles to screen and free pool + if (this.pool.isFull()) { + drawTerrain(this.painter, this.terrain, this._rttTiles); + this._rttTiles = []; + this.pool.freeAllObjects(); + } + this._rttTiles.push(tile); + // check for cached PoolObject + if (tile.rtt[stack]) { + const obj = this.pool.getObjectForId(tile.rtt[stack].id); + if (obj.stamp === tile.rtt[stack].stamp) { + this.pool.useObject(obj); + continue; + } + } + // get free PoolObject + const obj = this.pool.getOrCreateFreeObject(); + this.pool.useObject(obj); + this.pool.stampObject(obj); + tile.rtt[stack] = { id: obj.id, stamp: obj.stamp }; + // prepare PoolObject for rendering + painter.context.bindFramebuffer.set(obj.fbo.framebuffer); + painter.context.clear({ color: performance.Color.transparent, stencil: 0 }); + painter.currentStencilSource = undefined; + for (let l = 0; l < layers.length; l++) { + const layer = painter.style._layers[layers[l]]; + const coords = layer.source ? this._coordsDescendingInv[layer.source][tile.tileID.key] : [tile.tileID]; + painter.context.viewport.set([0, 0, obj.fbo.width, obj.fbo.height]); + painter._renderTileClippingMasks(layer, coords); + painter.renderLayer(painter, painter.style.sourceCaches[layer.source], layer, coords); + if (layer.source) + tile.rttCoords[layer.source] = this._coordsDescendingInvStr[layer.source][tile.tileID.key]; + } + } + drawTerrain(this.painter, this.terrain, this._rttTiles); + this._rttTiles = []; + this.pool.freeAllObjects(); + return LAYERS[type]; + } + return false; + } +} + +const version$1 = packageJSON.version; +const defaultMinZoom = -2; +const defaultMaxZoom = 22; +// the default values, but also the valid range +const defaultMinPitch = 0; +const defaultMaxPitch = 60; +// use this variable to check maxPitch for validity +const maxPitchThreshold = 85; +const defaultOptions$4 = { + center: [0, 0], + zoom: 0, + bearing: 0, + pitch: 0, + minZoom: defaultMinZoom, + maxZoom: defaultMaxZoom, + minPitch: defaultMinPitch, + maxPitch: defaultMaxPitch, + interactive: true, + scrollZoom: true, + boxZoom: true, + dragRotate: true, + dragPan: true, + keyboard: true, + doubleClickZoom: true, + touchZoomRotate: true, + touchPitch: true, + cooperativeGestures: undefined, + bearingSnap: 7, + clickTolerance: 3, + pitchWithRotate: true, + hash: false, + attributionControl: true, + maplibreLogo: false, + failIfMajorPerformanceCaveat: false, + preserveDrawingBuffer: false, + trackResize: true, + renderWorldCopies: true, + refreshExpiredTiles: true, + maxTileCacheSize: null, + maxTileCacheZoomLevels: performance.config.MAX_TILE_CACHE_ZOOM_LEVELS, + localIdeographFontFamily: 'sans-serif', + transformRequest: null, + transformCameraUpdate: null, + fadeDuration: 300, + crossSourceCollisions: true, + validateStyle: true, + /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */ + maxCanvasSize: [4096, 4096] +}; +/** + * The `Map` object represents the map on your page. It exposes methods + * and properties that enable you to programmatically change the map, + * and fires events as users interact with it. + * + * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list. + * Then MapLibre GL JS initializes the map on the page and returns your `Map` object. + * + * @group Main + * + * @example + * ```ts + * let map = new maplibregl.Map({ + * container: 'map', + * center: [-122.420679, 37.772537], + * zoom: 13, + * style: style_object, + * hash: true, + * transformRequest: (url, resourceType)=> { + * if(resourceType === 'Source' && url.startsWith('http://myHost')) { + * return { + * url: url.replace('http', 'https'), + * headers: { 'my-custom-header': true}, + * credentials: 'include' // Include cookies for cross-origin requests + * } + * } + * } + * }); + * ``` + * @see [Display a map](https://maplibre.org/maplibre-gl-js/docs/examples/simple-map/) + */ +let Map$1 = class Map extends Camera { + constructor(options) { + performance.PerformanceUtils.mark(performance.PerformanceMarkers.create); + options = performance.extend({}, defaultOptions$4, options); + if (options.minZoom != null && options.maxZoom != null && options.minZoom > options.maxZoom) { + throw new Error('maxZoom must be greater than or equal to minZoom'); + } + if (options.minPitch != null && options.maxPitch != null && options.minPitch > options.maxPitch) { + throw new Error('maxPitch must be greater than or equal to minPitch'); + } + if (options.minPitch != null && options.minPitch < defaultMinPitch) { + throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`); + } + if (options.maxPitch != null && options.maxPitch > maxPitchThreshold) { + throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`); + } + const transform = new Transform(options.minZoom, options.maxZoom, options.minPitch, options.maxPitch, options.renderWorldCopies); + super(transform, { bearingSnap: options.bearingSnap }); + this._cooperativeGesturesOnWheel = (event) => { + this._onCooperativeGesture(event, event[this._metaKey], 1); + }; + this._contextLost = (event) => { + event.preventDefault(); + if (this._frame) { + this._frame.cancel(); + this._frame = null; + } + this.fire(new performance.Event('webglcontextlost', { originalEvent: event })); + }; + this._contextRestored = (event) => { + this._setupPainter(); + this.resize(); + this._update(); + this.fire(new performance.Event('webglcontextrestored', { originalEvent: event })); + }; + this._onMapScroll = (event) => { + if (event.target !== this._container) + return; + // Revert any scroll which would move the canvas outside of the view + this._container.scrollTop = 0; + this._container.scrollLeft = 0; + return false; + }; + this._onWindowOnline = () => { + this._update(); + }; + this._interactive = options.interactive; + this._cooperativeGestures = options.cooperativeGestures; + this._metaKey = navigator.platform.indexOf('Mac') === 0 ? 'metaKey' : 'ctrlKey'; + this._maxTileCacheSize = options.maxTileCacheSize; + this._maxTileCacheZoomLevels = options.maxTileCacheZoomLevels; + this._failIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat; + this._preserveDrawingBuffer = options.preserveDrawingBuffer; + this._antialias = options.antialias; + this._trackResize = options.trackResize; + this._bearingSnap = options.bearingSnap; + this._refreshExpiredTiles = options.refreshExpiredTiles; + this._fadeDuration = options.fadeDuration; + this._crossSourceCollisions = options.crossSourceCollisions; + this._crossFadingFactor = 1; + this._collectResourceTiming = options.collectResourceTiming; + this._renderTaskQueue = new TaskQueue(); + this._controls = []; + this._mapId = performance.uniqueId(); + this._locale = performance.extend({}, defaultLocale, options.locale); + this._clickTolerance = options.clickTolerance; + this._overridePixelRatio = options.pixelRatio; + this._maxCanvasSize = options.maxCanvasSize; + this.transformCameraUpdate = options.transformCameraUpdate; + this._imageQueueHandle = ImageRequest.addThrottleControl(() => this.isMoving()); + this._requestManager = new RequestManager(options.transformRequest); + if (typeof options.container === 'string') { + this._container = document.getElementById(options.container); + if (!this._container) { + throw new Error(`Container '${options.container}' not found.`); + } + } + else if (options.container instanceof HTMLElement) { + this._container = options.container; + } + else { + throw new Error('Invalid type: \'container\' must be a String or HTMLElement.'); + } + if (options.maxBounds) { + this.setMaxBounds(options.maxBounds); + } + this._setupContainer(); + this._setupPainter(); + this.on('move', () => this._update(false)); + this.on('moveend', () => this._update(false)); + this.on('zoom', () => this._update(true)); + this.on('terrain', () => { + this.painter.terrainFacilitator.dirty = true; + this._update(true); + }); + this.once('idle', () => { this._idleTriggered = true; }); + if (typeof window !== 'undefined') { + addEventListener('online', this._onWindowOnline, false); + let initialResizeEventCaptured = false; + const throttledResizeCallback = throttle((entries) => { + if (this._trackResize && !this._removed) { + this.resize(entries)._update(); + } + }, 50); + this._resizeObserver = new ResizeObserver((entries) => { + if (!initialResizeEventCaptured) { + initialResizeEventCaptured = true; + return; + } + throttledResizeCallback(entries); + }); + this._resizeObserver.observe(this._container); + } + this.handlers = new HandlerManager(this, options); + if (this._cooperativeGestures) { + this._setupCooperativeGestures(); + } + const hashName = (typeof options.hash === 'string' && options.hash) || undefined; + this._hash = options.hash && (new Hash(hashName)).addTo(this); + // don't set position from options if set through hash + if (!this._hash || !this._hash._onHashChange()) { + this.jumpTo({ + center: options.center, + zoom: options.zoom, + bearing: options.bearing, + pitch: options.pitch + }); + if (options.bounds) { + this.resize(); + this.fitBounds(options.bounds, performance.extend({}, options.fitBoundsOptions, { duration: 0 })); + } + } + this.resize(); + this._localIdeographFontFamily = options.localIdeographFontFamily; + this._validateStyle = options.validateStyle; + if (options.style) + this.setStyle(options.style, { localIdeographFontFamily: options.localIdeographFontFamily }); + if (options.attributionControl) + this.addControl(new AttributionControl({ customAttribution: options.customAttribution })); + if (options.maplibreLogo) + this.addControl(new LogoControl(), options.logoPosition); + this.on('style.load', () => { + if (this.transform.unmodified) { + this.jumpTo(this.style.stylesheet); + } + }); + this.on('data', (event) => { + this._update(event.dataType === 'style'); + this.fire(new performance.Event(`${event.dataType}data`, event)); + }); + this.on('dataloading', (event) => { + this.fire(new performance.Event(`${event.dataType}dataloading`, event)); + }); + this.on('dataabort', (event) => { + this.fire(new performance.Event('sourcedataabort', event)); + }); + } + /** + * @internal + * Returns a unique number for this map instance which is used for the MapLoadEvent + * to make sure we only fire one event per instantiated map object. + * @returns the uniq map ID + */ + _getMapId() { + return this._mapId; + } + /** + * Adds an {@link IControl} to the map, calling `control.onAdd(this)`. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param control - The {@link IControl} to add. + * @param position - position on the map to which the control will be added. + * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`. + * @returns `this` + * @example + * Add zoom and rotation controls to the map. + * ```ts + * map.addControl(new maplibregl.NavigationControl()); + * ``` + * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/) + */ + addControl(control, position) { + if (position === undefined) { + if (control.getDefaultPosition) { + position = control.getDefaultPosition(); + } + else { + position = 'top-right'; + } + } + if (!control || !control.onAdd) { + return this.fire(new performance.ErrorEvent(new Error('Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.'))); + } + const controlElement = control.onAdd(this); + this._controls.push(control); + const positionContainer = this._controlPositions[position]; + if (position.indexOf('bottom') !== -1) { + positionContainer.insertBefore(controlElement, positionContainer.firstChild); + } + else { + positionContainer.appendChild(controlElement); + } + return this; + } + /** + * Removes the control from the map. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param control - The {@link IControl} to remove. + * @returns `this` + * @example + * ```ts + * // Define a new navigation control. + * let navigation = new maplibregl.NavigationControl(); + * // Add zoom and rotation controls to the map. + * map.addControl(navigation); + * // Remove zoom and rotation controls from the map. + * map.removeControl(navigation); + * ``` + */ + removeControl(control) { + if (!control || !control.onRemove) { + return this.fire(new performance.ErrorEvent(new Error('Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.'))); + } + const ci = this._controls.indexOf(control); + if (ci > -1) + this._controls.splice(ci, 1); + control.onRemove(this); + return this; + } + /** + * Checks if a control exists on the map. + * + * @param control - The {@link IControl} to check. + * @returns true if map contains control. + * @example + * ```ts + * // Define a new navigation control. + * let navigation = new maplibregl.NavigationControl(); + * // Add zoom and rotation controls to the map. + * map.addControl(navigation); + * // Check that the navigation control exists on the map. + * map.hasControl(navigation); + * ``` + */ + hasControl(control) { + return this._controls.indexOf(control) > -1; + } + calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo) { + if (altitudeTo == null && this.terrain) { + altitudeTo = this.terrain.getElevationForLngLatZoom(to, this.transform.tileZoom); + } + return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo); + } + /** + * Resizes the map according to the dimensions of its + * `container` element. + * + * Checks if the map container size changed and updates the map if it has changed. + * This method must be called after the map's `container` is resized programmatically + * or when the map is shown after being initially hidden with CSS. + * + * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`. + * + * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend` + * events that get triggered as a result of resize. This can be useful for differentiating the + * source of an event (for example, user-initiated or programmatically-triggered events). + * @returns `this` + * @example + * Resize the map when the map container is shown after being initially hidden with CSS. + * ```ts + * let mapDiv = document.getElementById('map'); + * if (mapDiv.style.visibility === true) map.resize(); + * ``` + */ + resize(eventData) { + var _a; + const dimensions = this._containerDimensions(); + const width = dimensions[0]; + const height = dimensions[1]; + const clampedPixelRatio = this._getClampedPixelRatio(width, height); + this._resizeCanvas(width, height, clampedPixelRatio); + this.painter.resize(width, height, clampedPixelRatio); + // check if we've reached GL limits, in that case further clamps pixelRatio + if (this.painter.overLimit()) { + const gl = this.painter.context.gl; + // store updated _maxCanvasSize value + this._maxCanvasSize = [gl.drawingBufferWidth, gl.drawingBufferHeight]; + const clampedPixelRatio = this._getClampedPixelRatio(width, height); + this._resizeCanvas(width, height, clampedPixelRatio); + this.painter.resize(width, height, clampedPixelRatio); + } + this.transform.resize(width, height); + (_a = this._requestedCameraState) === null || _a === void 0 ? void 0 : _a.resize(width, height); + const fireMoving = !this._moving; + if (fireMoving) { + this.stop(); + this.fire(new performance.Event('movestart', eventData)) + .fire(new performance.Event('move', eventData)); + } + this.fire(new performance.Event('resize', eventData)); + if (fireMoving) + this.fire(new performance.Event('moveend', eventData)); + return this; + } + /** + * @internal + * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize. + * Internally you should use this and not getPixelRatio(). + */ + _getClampedPixelRatio(width, height) { + const { 0: maxCanvasWidth, 1: maxCanvasHeight } = this._maxCanvasSize; + const pixelRatio = this.getPixelRatio(); + const canvasWidth = width * pixelRatio; + const canvasHeight = height * pixelRatio; + const widthScaleFactor = canvasWidth > maxCanvasWidth ? (maxCanvasWidth / canvasWidth) : 1; + const heightScaleFactor = canvasHeight > maxCanvasHeight ? (maxCanvasHeight / canvasHeight) : 1; + return Math.min(widthScaleFactor, heightScaleFactor) * pixelRatio; + } + /** + * Returns the map's pixel ratio. + * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize. + * @returns The pixel ratio. + */ + getPixelRatio() { + var _a; + return (_a = this._overridePixelRatio) !== null && _a !== void 0 ? _a : devicePixelRatio; + } + /** + * Sets the map's pixel ratio. This allows to override `devicePixelRatio`. + * After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio` + * and its height attribute will be `container.clientHeight * pixelRatio`. + * Set this to null to disable `devicePixelRatio` override. + * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize. + * @param pixelRatio - The pixel ratio. + */ + setPixelRatio(pixelRatio) { + this._overridePixelRatio = pixelRatio; + this.resize(); + } + /** + * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not + * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. + * @returns The geographical bounds of the map as {@link LngLatBounds}. + * @example + * ```ts + * let bounds = map.getBounds(); + * ``` + */ + getBounds() { + return this.transform.getBounds(); + } + /** + * Returns the maximum geographical bounds the map is constrained to, or `null` if none set. + * @returns The map object. + * @example + * ```ts + * let maxBounds = map.getMaxBounds(); + * ``` + */ + getMaxBounds() { + return this.transform.getMaxBounds(); + } + /** + * Sets or clears the map's geographical bounds. + * + * Pan and zoom operations are constrained within these bounds. + * If a pan or zoom is performed that would + * display regions outside these bounds, the map will + * instead display a position and zoom level + * as close as possible to the operation's request while still + * remaining within the bounds. + * + * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds. + * @returns `this` + * @example + * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds. + * ```ts + * let bounds = [ + * [-74.04728, 40.68392], // [west, south] + * [-73.91058, 40.87764] // [east, north] + * ]; + * map.setMaxBounds(bounds); + * ``` + */ + setMaxBounds(bounds) { + this.transform.setMaxBounds(LngLatBounds.convert(bounds)); + return this._update(); + } + /** + * Sets or clears the map's minimum zoom level. + * If the map's current zoom level is lower than the new minimum, + * the map will zoom to the new minimum. + * + * It is not always possible to zoom out and reach the set `minZoom`. + * Other factors such as map height may restrict zooming. For example, + * if the map is 512px tall it will not be possible to zoom below zoom 0 + * no matter what the `minZoom` is set to. + * + * A {@link ErrorEvent} event will be fired if minZoom is out of bounds. + * + * @param minZoom - The minimum zoom level to set (-2 - 24). + * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2). + * @returns `this` + * @example + * ```ts + * map.setMinZoom(12.25); + * ``` + */ + setMinZoom(minZoom) { + minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom; + if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) { + this.transform.minZoom = minZoom; + this._update(); + if (this.getZoom() < minZoom) + this.setZoom(minZoom); + return this; + } + else + throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`); + } + /** + * Returns the map's minimum allowable zoom level. + * + * @returns minZoom + * @example + * ```ts + * let minZoom = map.getMinZoom(); + * ``` + */ + getMinZoom() { return this.transform.minZoom; } + /** + * Sets or clears the map's maximum zoom level. + * If the map's current zoom level is higher than the new maximum, + * the map will zoom to the new maximum. + * + * A {@link ErrorEvent} event will be fired if minZoom is out of bounds. + * + * @param maxZoom - The maximum zoom level to set. + * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22). + * @returns `this` + * @example + * ```ts + * map.setMaxZoom(18.75); + * ``` + */ + setMaxZoom(maxZoom) { + maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom; + if (maxZoom >= this.transform.minZoom) { + this.transform.maxZoom = maxZoom; + this._update(); + if (this.getZoom() > maxZoom) + this.setZoom(maxZoom); + return this; + } + else + throw new Error('maxZoom must be greater than the current minZoom'); + } + /** + * Returns the map's maximum allowable zoom level. + * + * @returns The maxZoom + * @example + * ```ts + * let maxZoom = map.getMaxZoom(); + * ``` + */ + getMaxZoom() { return this.transform.maxZoom; } + /** + * Sets or clears the map's minimum pitch. + * If the map's current pitch is lower than the new minimum, + * the map will pitch to the new minimum. + * + * A {@link ErrorEvent} event will be fired if minPitch is out of bounds. + * + * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0). + * @returns `this` + */ + setMinPitch(minPitch) { + minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch; + if (minPitch < defaultMinPitch) { + throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`); + } + if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) { + this.transform.minPitch = minPitch; + this._update(); + if (this.getPitch() < minPitch) + this.setPitch(minPitch); + return this; + } + else + throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`); + } + /** + * Returns the map's minimum allowable pitch. + * + * @returns The minPitch + */ + getMinPitch() { return this.transform.minPitch; } + /** + * Sets or clears the map's maximum pitch. + * If the map's current pitch is higher than the new maximum, + * the map will pitch to the new maximum. + * + * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds. + * + * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60). + * @returns `this` + */ + setMaxPitch(maxPitch) { + maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch; + if (maxPitch > maxPitchThreshold) { + throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`); + } + if (maxPitch >= this.transform.minPitch) { + this.transform.maxPitch = maxPitch; + this._update(); + if (this.getPitch() > maxPitch) + this.setPitch(maxPitch); + return this; + } + else + throw new Error('maxPitch must be greater than the current minPitch'); + } + /** + * Returns the map's maximum allowable pitch. + * + * @returns The maxPitch + */ + getMaxPitch() { return this.transform.maxPitch; } + /** + * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * @returns The renderWorldCopies + * @example + * ```ts + * let worldCopiesRendered = map.getRenderWorldCopies(); + * ``` + * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/) + */ + getRenderWorldCopies() { return this.transform.renderWorldCopies; } + /** + * Sets the state of `renderWorldCopies`. + * + * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * + * `undefined` is treated as `true`, `null` is treated as `false`. + * @returns `this` + * @example + * ```ts + * map.setRenderWorldCopies(true); + * ``` + * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/) + */ + setRenderWorldCopies(renderWorldCopies) { + this.transform.renderWorldCopies = renderWorldCopies; + return this._update(); + } + /** + * Gets the map's cooperativeGestures option + * + * @returns The gestureOptions + */ + getCooperativeGestures() { + return this._cooperativeGestures; + } + /** + * Sets or clears the map's cooperativeGestures option + * + * @param gestureOptions - If `true` or set to an options object, map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, "drag to pitch" requires a three-finger gesture. + * @returns `this` + */ + setCooperativeGestures(gestureOptions) { + this._cooperativeGestures = gestureOptions; + if (this._cooperativeGestures) { + this._setupCooperativeGestures(); + } + else { + this._destroyCooperativeGestures(); + } + return this; + } + /** + * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`, + * that correspond to the specified geographical location. + * + * @param lnglat - The geographical location to project. + * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`. + * @example + * ```ts + * let coordinate = [-122.420679, 37.772537]; + * let point = map.project(coordinate); + * ``` + */ + project(lnglat) { + return this.transform.locationPoint(performance.LngLat.convert(lnglat), this.style && this.terrain); + } + /** + * Returns a {@link LngLat} representing geographical coordinates that correspond + * to the specified pixel coordinates. + * + * @param point - The pixel coordinates to unproject. + * @returns The {@link LngLat} corresponding to `point`. + * @example + * ```ts + * map.on('click', function(e) { + * // When the map is clicked, get the geographic coordinate. + * let coordinate = map.unproject(e.point); + * }); + * ``` + */ + unproject(point) { + return this.transform.pointLocation(performance.Point.convert(point), this.terrain); + } + /** + * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture. + * @returns true if the map is moving. + * @example + * ```ts + * let isMoving = map.isMoving(); + * ``` + */ + isMoving() { + var _a; + return this._moving || ((_a = this.handlers) === null || _a === void 0 ? void 0 : _a.isMoving()); + } + /** + * Returns true if the map is zooming due to a camera animation or user gesture. + * @returns true if the map is zooming. + * @example + * ```ts + * let isZooming = map.isZooming(); + * ``` + */ + isZooming() { + var _a; + return this._zooming || ((_a = this.handlers) === null || _a === void 0 ? void 0 : _a.isZooming()); + } + /** + * Returns true if the map is rotating due to a camera animation or user gesture. + * @returns true if the map is rotating. + * @example + * ```ts + * map.isRotating(); + * ``` + */ + isRotating() { + var _a; + return this._rotating || ((_a = this.handlers) === null || _a === void 0 ? void 0 : _a.isRotating()); + } + _createDelegatedListener(type, layerId, listener) { + if (type === 'mouseenter' || type === 'mouseover') { + let mousein = false; + const mousemove = (e) => { + const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, { layers: [layerId] }) : []; + if (!features.length) { + mousein = false; + } + else if (!mousein) { + mousein = true; + listener.call(this, new MapMouseEvent(type, this, e.originalEvent, { features })); + } + }; + const mouseout = () => { + mousein = false; + }; + return { layer: layerId, listener, delegates: { mousemove, mouseout } }; + } + else if (type === 'mouseleave' || type === 'mouseout') { + let mousein = false; + const mousemove = (e) => { + const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, { layers: [layerId] }) : []; + if (features.length) { + mousein = true; + } + else if (mousein) { + mousein = false; + listener.call(this, new MapMouseEvent(type, this, e.originalEvent)); + } + }; + const mouseout = (e) => { + if (mousein) { + mousein = false; + listener.call(this, new MapMouseEvent(type, this, e.originalEvent)); + } + }; + return { layer: layerId, listener, delegates: { mousemove, mouseout } }; + } + else { + const delegate = (e) => { + const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, { layers: [layerId] }) : []; + if (features.length) { + // Here we need to mutate the original event, so that preventDefault works as expected. + e.features = features; + listener.call(this, e); + delete e.features; + } + }; + return { layer: layerId, listener, delegates: { [type]: delegate } }; + } + } + on(type, layerIdOrListener, listener) { + if (listener === undefined) { + return super.on(type, layerIdOrListener); + } + const delegatedListener = this._createDelegatedListener(type, layerIdOrListener, listener); + this._delegatedListeners = this._delegatedListeners || {}; + this._delegatedListeners[type] = this._delegatedListeners[type] || []; + this._delegatedListeners[type].push(delegatedListener); + for (const event in delegatedListener.delegates) { + this.on(event, delegatedListener.delegates[event]); + } + return this; + } + once(type, layerIdOrListener, listener) { + if (listener === undefined) { + return super.once(type, layerIdOrListener); + } + const delegatedListener = this._createDelegatedListener(type, layerIdOrListener, listener); + for (const event in delegatedListener.delegates) { + this.once(event, delegatedListener.delegates[event]); + } + return this; + } + off(type, layerIdOrListener, listener) { + if (listener === undefined) { + return super.off(type, layerIdOrListener); + } + const removeDelegatedListener = (delegatedListeners) => { + const listeners = delegatedListeners[type]; + for (let i = 0; i < listeners.length; i++) { + const delegatedListener = listeners[i]; + if (delegatedListener.layer === layerIdOrListener && delegatedListener.listener === listener) { + for (const event in delegatedListener.delegates) { + this.off(event, delegatedListener.delegates[event]); + } + listeners.splice(i, 1); + return this; + } + } + }; + if (this._delegatedListeners && this._delegatedListeners[type]) { + removeDelegatedListener(this._delegatedListeners); + } + return this; + } + /** + * Returns an array of MapGeoJSONFeature objects + * representing visible features that satisfy the query parameters. + * + * @param geometryOrOptions - (optional) The geometry of the query region: + * either a single point or southwest and northeast points describing a bounding box. + * Omitting this parameter (i.e. calling {@link Map#queryRenderedFeatures} with zero arguments, + * or with only a `options` argument) is equivalent to passing a bounding box encompassing the entire + * map viewport. + * The geometryOrOptions can receive a {@link QueryRenderedFeaturesOptions} only to support a situation where the function receives only one parameter which is the options parameter. + * @param options - (optional) Options object. + * + * @returns An array of MapGeoJSONFeature objects. + * + * The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only + * string and numeric property values are supported (i.e. `null`, `Array`, and `Object` values are not supported). + * + * Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object + * representing the style layer to which the feature belongs. Layout and paint properties in this object contain values + * which are fully evaluated for the given zoom level and feature. + * + * Only features that are currently rendered are included. Some features will **not** be included, like: + * + * - Features from layers whose `visibility` property is `"none"`. + * - Features from layers whose zoom range excludes the current zoom level. + * - Symbol features that have been hidden due to text or icon collision. + * + * Features from all other layers are included, including features that may have no visible + * contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to + * 0. + * + * The topmost rendered feature appears first in the returned array, and subsequent features are sorted by + * descending z-order. Features that are rendered multiple times (due to wrapping across the antemeridian at low + * zoom levels) are returned only once (though subject to the following caveat). + * + * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature + * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple + * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. + * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding + * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile + * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple + * tiles due to tile buffering. + * + * @example + * Find all features at a point + * ```ts + * let features = map.queryRenderedFeatures( + * [20, 35], + * { layers: ['my-layer-name'] } + * ); + * ``` + * + * @example + * Find all features within a static bounding box + * ```ts + * let features = map.queryRenderedFeatures( + * [[10, 20], [30, 50]], + * { layers: ['my-layer-name'] } + * ); + * ``` + * + * @example + * Find all features within a bounding box around a point + * ```ts + * let width = 10; + * let height = 20; + * let features = map.queryRenderedFeatures([ + * [point.x - width / 2, point.y - height / 2], + * [point.x + width / 2, point.y + height / 2] + * ], { layers: ['my-layer-name'] }); + * ``` + * + * @example + * Query all rendered features from a single layer + * ```ts + * let features = map.queryRenderedFeatures({ layers: ['my-layer-name'] }); + * ``` + * @see [Get features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/queryrenderedfeatures/) + */ + queryRenderedFeatures(geometryOrOptions, options) { + if (!this.style) { + return []; + } + let queryGeometry; + const isGeometry = geometryOrOptions instanceof performance.Point || Array.isArray(geometryOrOptions); + const geometry = isGeometry ? geometryOrOptions : [[0, 0], [this.transform.width, this.transform.height]]; + options = options || (isGeometry ? {} : geometryOrOptions) || {}; + if (geometry instanceof performance.Point || typeof geometry[0] === 'number') { + queryGeometry = [performance.Point.convert(geometry)]; + } + else { + const tl = performance.Point.convert(geometry[0]); + const br = performance.Point.convert(geometry[1]); + queryGeometry = [tl, new performance.Point(br.x, tl.y), br, new performance.Point(tl.x, br.y), tl]; + } + return this.style.queryRenderedFeatures(queryGeometry, options, this.transform); + } + /** + * Returns an array of MapGeoJSONFeature objects + * representing features within the specified vector tile or GeoJSON source that satisfy the query parameters. + * + * @param sourceId - The ID of the vector tile or GeoJSON source to query. + * @param parameters - The options object. + * @returns An array of MapGeoJSONFeature objects. + * + * In contrast to {@link Map#queryRenderedFeatures}, this function returns all features matching the query parameters, + * whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded + * vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently + * visible viewport. + * + * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature + * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple + * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. + * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding + * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile + * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple + * tiles due to tile buffering. + * + * @example + * Find all features in one source layer in a vector source + * ```ts + * let features = map.querySourceFeatures('your-source-id', { + * sourceLayer: 'your-source-layer' + * }); + * ``` + * + */ + querySourceFeatures(sourceId, parameters) { + return this.style.querySourceFeatures(sourceId, parameters); + } + /** + * Updates the map's MapLibre style object with a new value. + * + * If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style + * against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites + * (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current + * style and the given style are different in any way, the map renderer will force a full update, removing the current style and building + * the given one from scratch. + * + * + * @param style - A JSON object conforming to the schema described in the + * [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), or a URL to such JSON. + * @param options - The options object. + * @returns `this` + * + * @example + * ```ts + * map.setStyle("https://demotiles.maplibre.org/style.json"); + * + * map.setStyle('https://demotiles.maplibre.org/style.json', { + * transformStyle: (previousStyle, nextStyle) => ({ + * ...nextStyle, + * sources: { + * ...nextStyle.sources, + * // copy a source from previous style + * 'osm': previousStyle.sources.osm + * }, + * layers: [ + * // background layer + * nextStyle.layers[0], + * // copy a layer from previous style + * previousStyle.layers[0], + * // other layers from the next style + * ...nextStyle.layers.slice(1).map(layer => { + * // hide the layers we don't need from demotiles style + * if (layer.id.startsWith('geolines')) { + * layer.layout = {...layer.layout || {}, visibility: 'none'}; + * // filter out US polygons + * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) { + * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA']; + * } + * return layer; + * }) + * ] + * }) + * }); + * ``` + */ + setStyle(style, options) { + options = performance.extend({}, { + localIdeographFontFamily: this._localIdeographFontFamily, + validate: this._validateStyle + }, options); + if ((options.diff !== false && options.localIdeographFontFamily === this._localIdeographFontFamily) && this.style && style) { + this._diffStyle(style, options); + return this; + } + else { + this._localIdeographFontFamily = options.localIdeographFontFamily; + return this._updateStyle(style, options); + } + } + /** + * Updates the requestManager's transform request with a new function + * + * @param transformRequest - A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. + * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties + * + * @returns `this` + * + * @example + * ```ts + * map.setTransformRequest((url: string, resourceType: string) => {}); + * ``` + */ + setTransformRequest(transformRequest) { + this._requestManager.setTransformRequest(transformRequest); + return this; + } + _getUIString(key) { + const str = this._locale[key]; + if (str == null) { + throw new Error(`Missing UI string '${key}'`); + } + return str; + } + _updateStyle(style, options) { + // transformStyle relies on having previous style serialized, if it is not loaded yet, delay _updateStyle until previous style is loaded + if (options.transformStyle && this.style && !this.style._loaded) { + this.style.once('style.load', () => this._updateStyle(style, options)); + return; + } + const previousStyle = this.style && options.transformStyle ? this.style.serialize() : undefined; + if (this.style) { + this.style.setEventedParent(null); + // Only release workers when map is getting disposed + this.style._remove(!style); + } + if (!style) { + delete this.style; + return this; + } + else { + this.style = new Style(this, options || {}); + } + this.style.setEventedParent(this, { style: this.style }); + if (typeof style === 'string') { + this.style.loadURL(style, options, previousStyle); + } + else { + this.style.loadJSON(style, options, previousStyle); + } + return this; + } + _lazyInitEmptyStyle() { + if (!this.style) { + this.style = new Style(this, {}); + this.style.setEventedParent(this, { style: this.style }); + this.style.loadEmpty(); + } + } + _diffStyle(style, options) { + if (typeof style === 'string') { + const url = style; + const request = this._requestManager.transformRequest(url, ResourceType.Style); + performance.getJSON(request, (error, json) => { + if (error) { + this.fire(new performance.ErrorEvent(error)); + } + else if (json) { + this._updateDiff(json, options); + } + }); + } + else if (typeof style === 'object') { + this._updateDiff(style, options); + } + } + _updateDiff(style, options) { + try { + if (this.style.setState(style, options)) { + this._update(true); + } + } + catch (e) { + performance.warnOnce(`Unable to perform style diff: ${e.message || e.error || e}. Rebuilding the style from scratch.`); + this._updateStyle(style, options); + } + } + /** + * Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style. + * + * @returns The map's style JSON object. + * + * @example + * ```ts + * let styleJson = map.getStyle(); + * ``` + * + */ + getStyle() { + if (this.style) { + return this.style.serialize(); + } + } + /** + * Returns a Boolean indicating whether the map's style is fully loaded. + * + * @returns A Boolean indicating whether the style is fully loaded. + * + * @example + * ```ts + * let styleLoadStatus = map.isStyleLoaded(); + * ``` + */ + isStyleLoaded() { + if (!this.style) + return performance.warnOnce('There is no style added to the map.'); + return this.style.loaded(); + } + /** + * Adds a source to the map's style. + * + * Events triggered: + * + * Triggers the `source.add` event. + * + * @param id - The ID of the source to add. Must not conflict with existing sources. + * @param source - The source object, conforming to the + * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or + * {@link CanvasSourceSpecification}. + * @returns `this` + * @example + * ```ts + * map.addSource('my-data', { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }); + * ``` + * @example + * ```ts + * map.addSource('my-data', { + * "type": "geojson", + * "data": { + * "type": "Feature", + * "geometry": { + * "type": "Point", + * "coordinates": [-77.0323, 38.9131] + * }, + * "properties": { + * "title": "Mapbox DC", + * "marker-symbol": "monument" + * } + * } + * }); + * ``` + * @see GeoJSON source: [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + */ + addSource(id, source) { + this._lazyInitEmptyStyle(); + this.style.addSource(id, source); + return this._update(true); + } + /** + * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with + * the given ID in the map's style has no outstanding network requests, otherwise `false`. + * + * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID. + * + * @param id - The ID of the source to be checked. + * @returns A Boolean indicating whether the source is loaded. + * @example + * ```ts + * let sourceLoaded = map.isSourceLoaded('bathymetry-data'); + * ``` + */ + isSourceLoaded(id) { + const source = this.style && this.style.sourceCaches[id]; + if (source === undefined) { + this.fire(new performance.ErrorEvent(new Error(`There is no source with ID '${id}'`))); + return; + } + return source.loaded(); + } + /** + * Loads a 3D terrain mesh, based on a "raster-dem" source. + * + * Triggers the `terrain` event. + * + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setTerrain({ source: 'terrain' }); + * ``` + */ + setTerrain(options) { + this.style._checkLoaded(); + // clear event handlers + if (this._terrainDataCallback) + this.style.off('data', this._terrainDataCallback); + if (!options) { + // remove terrain + if (this.terrain) + this.terrain.sourceCache.destruct(); + this.terrain = null; + if (this.painter.renderToTexture) + this.painter.renderToTexture.destruct(); + this.painter.renderToTexture = null; + this.transform._minEleveationForCurrentTile = 0; + this.transform.elevation = 0; + } + else { + // add terrain + const sourceCache = this.style.sourceCaches[options.source]; + if (!sourceCache) + throw new Error(`cannot load terrain, because there exists no source with ID: ${options.source}`); + // Warn once if user is using the same source for hillshade and terrain + for (const index in this.style._layers) { + const thisLayer = this.style._layers[index]; + if (thisLayer.type === 'hillshade' && thisLayer.source === options.source) { + performance.warnOnce('You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.'); + } + } + this.terrain = new Terrain(this.painter, sourceCache, options); + this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain); + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + this._terrainDataCallback = e => { + if (e.dataType === 'style') { + this.terrain.sourceCache.freeRtt(); + } + else if (e.dataType === 'source' && e.tile) { + if (e.sourceId === options.source && !this._elevationFreeze) { + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + } + this.terrain.sourceCache.freeRtt(e.tile.tileID); + } + }; + this.style.on('data', this._terrainDataCallback); + } + this.fire(new performance.Event('terrain', { terrain: options })); + return this; + } + /** + * Get the terrain-options if terrain is loaded + * @returns the TerrainSpecification passed to setTerrain + * @example + * ```ts + * map.getTerrain(); // { source: 'terrain' }; + * ``` + */ + getTerrain() { + var _a, _b; + return (_b = (_a = this.terrain) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null; + } + /** + * Returns a Boolean indicating whether all tiles in the viewport from all sources on + * the style are loaded. + * + * @returns A Boolean indicating whether all tiles are loaded. + * @example + * ```ts + * let tilesLoaded = map.areTilesLoaded(); + * ``` + */ + areTilesLoaded() { + const sources = this.style && this.style.sourceCaches; + for (const id in sources) { + const source = sources[id]; + const tiles = source._tiles; + for (const t in tiles) { + const tile = tiles[t]; + if (!(tile.state === 'loaded' || tile.state === 'errored')) + return false; + } + } + return true; + } + /** + * Adds a [custom source type](#Custom Sources), making it available for use with + * {@link Map#addSource}. + * @param name - The name of the source type; source definition objects use this name in the `{type: ...}` field. + * @param SourceType - A {@link Source} constructor. + * @param callback - Called when the source type is ready or with an error argument if there is an error. + */ + addSourceType(name, SourceType, callback) { + this._lazyInitEmptyStyle(); + return this.style.addSourceType(name, SourceType, callback); + } + /** + * Removes a source from the map's style. + * + * @param id - The ID of the source to remove. + * @returns `this` + * @example + * ```ts + * map.removeSource('bathymetry-data'); + * ``` + */ + removeSource(id) { + this.style.removeSource(id); + return this._update(true); + } + /** + * Returns the source with the specified ID in the map's style. + * + * This method is often used to update a source using the instance members for the relevant + * source type as defined in [Sources](#sources). + * For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates` + * of an image source. + * + * @param id - The ID of the source to get. + * @returns The style source with the specified ID or `undefined` if the ID + * corresponds to no existing sources. + * The shape of the object varies by source type. + * A list of options for each source type is available on the MapLibre Style Specification's + * [Sources](https://maplibre.org/maplibre-style-spec/sources/) page. + * @example + * ```ts + * let sourceObject = map.getSource('points'); + * ``` + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/) + * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + */ + getSource(id) { + return this.style.getSource(id); + } + /** + * Add an image to the style. This image can be displayed on the map like any other icon in the style's + * sprite using the image's ID with + * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image), + * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern), + * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern), + * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern). + * + * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image. + * + * @param id - The ID of the image. + * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data` + * properties with the same format as `ImageData`. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * // If the style's sprite does not already contain an image with ID 'cat', + * // add the image 'cat-icon.png' to the style's sprite with the ID 'cat'. + * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) { + * if (error) throw error; + * if (!map.hasImage('cat')) map.addImage('cat', image); + * }); + * + * // Add a stretchable image that can be used with `icon-text-fit` + * // In this example, the image is 600px wide by 400px high. + * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png', function(error, image) { + * if (error) throw error; + * if (!map.hasImage('border-image')) { + * map.addImage('border-image', image, { + * content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border + * stretchX: [[16, 584]], // stretch everything horizontally except the 16px border + * stretchY: [[16, 384]], // stretch everything vertically except the 16px border + * }); + * } + * }); + * ``` + * @see Use `HTMLImageElement`: [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/) + * @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-generated/) + */ + addImage(id, image, options = {}) { + const { pixelRatio = 1, sdf = false, stretchX, stretchY, content } = options; + this._lazyInitEmptyStyle(); + const version = 0; + if (image instanceof HTMLImageElement || performance.isImageBitmap(image)) { + const { width, height, data } = performance.browser.getImageData(image); + this.style.addImage(id, { data: new performance.RGBAImage({ width, height }, data), pixelRatio, stretchX, stretchY, content, sdf, version }); + } + else if (image.width === undefined || image.height === undefined) { + return this.fire(new performance.ErrorEvent(new Error('Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' + + 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`'))); + } + else { + const { width, height, data } = image; + const userImage = image; + this.style.addImage(id, { + data: new performance.RGBAImage({ width, height }, new Uint8Array(data)), + pixelRatio, + stretchX, + stretchY, + content, + sdf, + version, + userImage + }); + if (userImage.onAdd) { + userImage.onAdd(this, id); + } + return this; + } + } + /** + * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's + * sprite using the image's ID with + * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image), + * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern), + * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern), + * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern). + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the image. + * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data` + * properties with the same format as `ImageData`. + * @returns `this` + * @example + * ```ts + * // If an image with the ID 'cat' already exists in the style's sprite, + * // replace that image with a new image, 'other-cat-icon.png'. + * if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png'); + * ``` + */ + updateImage(id, image) { + const existingImage = this.style.getImage(id); + if (!existingImage) { + return this.fire(new performance.ErrorEvent(new Error('The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.'))); + } + const imageData = (image instanceof HTMLImageElement || performance.isImageBitmap(image)) ? + performance.browser.getImageData(image) : + image; + const { width, height, data } = imageData; + if (width === undefined || height === undefined) { + return this.fire(new performance.ErrorEvent(new Error('Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' + + 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`'))); + } + if (width !== existingImage.data.width || height !== existingImage.data.height) { + return this.fire(new performance.ErrorEvent(new Error('The width and height of the updated image must be that same as the previous version of the image'))); + } + const copy = !(image instanceof HTMLImageElement || performance.isImageBitmap(image)); + existingImage.data.replace(data, copy); + this.style.updateImage(id, existingImage); + return this; + } + /** + * Returns an image, specified by ID, currently available in the map. + * This includes both images from the style's original sprite + * and any images that have been added at runtime using {@link Map#addImage}. + * + * @param id - The ID of the image. + * @returns An image in the map with the specified ID. + * + * @example + * ```ts + * let coffeeShopIcon = map.getImage("coffee_cup"); + * ``` + */ + getImage(id) { + return this.style.getImage(id); + } + /** + * Check whether or not an image with a specific ID exists in the style. This checks both images + * in the style's original sprite and any images + * that have been added at runtime using {@link Map#addImage}. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the image. + * + * @returns A Boolean indicating whether the image exists. + * @example + * Check if an image with the ID 'cat' exists in the style's sprite. + * ```ts + * let catIconExists = map.hasImage('cat'); + * ``` + */ + hasImage(id) { + if (!id) { + this.fire(new performance.ErrorEvent(new Error('Missing required image id'))); + return false; + } + return !!this.style.getImage(id); + } + /** + * Remove an image from a style. This can be an image from the style's original + * sprite or any images + * that have been added at runtime using {@link Map#addImage}. + * + * @param id - The ID of the image. + * + * @example + * ```ts + * // If an image with the ID 'cat' exists in + * // the style's sprite, remove it. + * if (map.hasImage('cat')) map.removeImage('cat'); + * ``` + */ + removeImage(id) { + this.style.removeImage(id); + } + /** + * Load an image from an external URL to be used with {@link Map#addImage}. External + * domains must support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS). + * + * @param url - The URL of the image file. Image file must be in png, webp, or jpg format. + * @param callback - Expecting `callback(error, data)`. Called when the image has loaded or with an error argument if there is an error. + * + * @example + * Load an image from an external URL. + * ```ts + * map.loadImage('http://placekitten.com/50/50', function(error, image) { + * if (error) throw error; + * // Add the loaded image to the style's sprite with the ID 'kitten'. + * map.addImage('kitten', image); + * }); + * ``` + * @see [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/) + */ + loadImage(url, callback) { + ImageRequest.getImage(this._requestManager.transformRequest(url, ResourceType.Image), callback); + } + /** + * Returns an Array of strings containing the IDs of all images currently available in the map. + * This includes both images from the style's original sprite + * and any images that have been added at runtime using {@link Map#addImage}. + * + * @returns An Array of strings containing the names of all sprites/images currently available in the map. + * + * @example + * ```ts + * let allImages = map.listImages(); + * ``` + */ + listImages() { + return this.style.listImages(); + } + /** + * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers) + * to the map's style. + * + * A layer defines how data from a specified source will be styled. Read more about layer types + * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers). + * + * @param layer - The layer to add, + * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or, + * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition. + * The MapLibre Style Specification's layer definition is appropriate for most layers. + * + * @param beforeId - The ID of an existing layer to insert the new layer before, + * resulting in the new layer appearing visually beneath the existing layer. + * If this argument is not specified, the layer will be appended to the end of the layers array + * and appear visually above all other layers. + * + * @returns `this` + * + * @example + * Add a circle layer with a vector source + * ```ts + * map.addLayer({ + * id: 'points-of-interest', + * source: { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }, + * 'source-layer': 'poi_label', + * type: 'circle', + * paint: { + * // MapLibre Style Specification paint properties + * }, + * layout: { + * // MapLibre Style Specification layout properties + * } + * }); + * ``` + * + * @example + * Define a source before using it to create a new layer + * ```ts + * map.addSource('state-data', { + * type: 'geojson', + * data: 'path/to/data.geojson' + * }); + * + * map.addLayer({ + * id: 'states', + * // References the GeoJSON source defined above + * // and does not require a `source-layer` + * source: 'state-data', + * type: 'symbol', + * layout: { + * // Set the label content to the + * // feature's `name` property + * text-field: ['get', 'name'] + * } + * }); + * ``` + * + * @example + * Add a new symbol layer before an existing layer + * ```ts + * map.addLayer({ + * id: 'states', + * // References a source that's already been defined + * source: 'state-data', + * type: 'symbol', + * layout: { + * // Set the label content to the + * // feature's `name` property + * text-field: ['get', 'name'] + * } + * // Add the layer before the existing `cities` layer + * }, 'cities'); + * ``` + * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/) + * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/) + * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/) + */ + addLayer(layer, beforeId) { + this._lazyInitEmptyStyle(); + this.style.addLayer(layer, beforeId); + return this._update(true); + } + /** + * Moves a layer to a different z-position. + * + * @param id - The ID of the layer to move. + * @param beforeId - The ID of an existing layer to insert the new layer before. When viewing the map, the `id` layer will appear beneath the `beforeId` layer. If `beforeId` is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map. + * @returns `this` + * + * @example + * Move a layer with ID 'polygon' before the layer with ID 'country-label'. The `polygon` layer will appear beneath the `country-label` layer on the map. + * ```ts + * map.moveLayer('polygon', 'country-label'); + * ``` + */ + moveLayer(id, beforeId) { + this.style.moveLayer(id, beforeId); + return this._update(true); + } + /** + * Removes the layer with the given ID from the map's style. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the layer to remove + * @returns `this` + * + * @example + * If a layer with ID 'state-data' exists, remove it. + * ```ts + * if (map.getLayer('state-data')) map.removeLayer('state-data'); + * ``` + */ + removeLayer(id) { + this.style.removeLayer(id); + return this._update(true); + } + /** + * Returns the layer with the specified ID in the map's style. + * + * @param id - The ID of the layer to get. + * @returns The layer with the specified ID, or `undefined` + * if the ID corresponds to no existing layers. + * + * @example + * ```ts + * let stateDataLayer = map.getLayer('state-data'); + * ``` + * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/) + * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/) + */ + getLayer(id) { + return this.style.getLayer(id); + } + /** + * Return the ids of all layers currently in the style, including custom layers, in order. + * + * @returns ids of layers, in order + * + * @example + * ```ts + * const orderedLayerIds = map.getLayersOrder(); + * ``` + */ + getLayersOrder() { + return this.style.getLayersOrder(); + } + /** + * Sets the zoom extent for the specified style layer. The zoom extent includes the + * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom) + * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom)) + * at which the layer will be rendered. + * + * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the + * minimum zoom level of the _source layer_ because the data does not exist at those zoom levels. If the minimum + * zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style + * layer will not be rendered at all zoom levels in the zoom range. + * + * @param layerId - The ID of the layer to which the zoom extent will be applied. + * @param minzoom - The minimum zoom to set (0-24). + * @param maxzoom - The maximum zoom to set (0-24). + * @returns `this` + * + * @example + * ```ts + * map.setLayerZoomRange('my-layer', 2, 5); + * ``` + */ + setLayerZoomRange(layerId, minzoom, maxzoom) { + this.style.setLayerZoomRange(layerId, minzoom, maxzoom); + return this._update(true); + } + /** + * Sets the filter for the specified style layer. + * + * Filters control which features a style layer renders from its source. + * Any feature for which the filter expression evaluates to `true` will be + * rendered on the map. Those that are false will be hidden. + * + * Use `setFilter` to show a subset of your source data. + * + * To clear the filter, pass `null` or `undefined` as the second parameter. + * + * @param layerId - The ID of the layer to which the filter will be applied. + * @param filter - The filter, conforming to the MapLibre Style Specification's + * [filter definition](https://maplibre.org/maplibre-style-spec/layers/#filter). If `null` or `undefined` is provided, the function removes any existing filter from the layer. + * @param options - Options object. + * @returns `this` + * + * @example + * Display only features with the 'name' property 'USA' + * ```ts + * map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']); + * ``` + * @example + * Display only features with five or more 'available-spots' + * ```ts + * map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]); + * ``` + * @example + * Remove the filter for the 'bike-docks' style layer + * ```ts + * map.setFilter('bike-docks', null); + * ``` + * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/) + */ + setFilter(layerId, filter, options = {}) { + this.style.setFilter(layerId, filter, options); + return this._update(true); + } + /** + * Returns the filter applied to the specified style layer. + * + * @param layerId - The ID of the style layer whose filter to get. + * @returns The layer's filter. + */ + getFilter(layerId) { + return this.style.getFilter(layerId); + } + /** + * Sets the value of a paint property in the specified style layer. + * + * @param layerId - The ID of the layer to set the paint property in. + * @param name - The name of the paint property to set. + * @param value - The value of the paint property to set. + * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/). + * Pass `null` to unset the existing value. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setPaintProperty('my-layer', 'fill-color', '#faafee'); + * ``` + * @see [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/) + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + setPaintProperty(layerId, name, value, options = {}) { + this.style.setPaintProperty(layerId, name, value, options); + return this._update(true); + } + /** + * Returns the value of a paint property in the specified style layer. + * + * @param layerId - The ID of the layer to get the paint property from. + * @param name - The name of a paint property to get. + * @returns The value of the specified paint property. + */ + getPaintProperty(layerId, name) { + return this.style.getPaintProperty(layerId, name); + } + /** + * Sets the value of a layout property in the specified style layer. + * + * @param layerId - The ID of the layer to set the layout property in. + * @param name - The name of the layout property to set. + * @param value - The value of the layout property. Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/). + * @param options - The options object. + * @returns `this` + * @example + * ```ts + * map.setLayoutProperty('my-layer', 'visibility', 'none'); + * ``` + */ + setLayoutProperty(layerId, name, value, options = {}) { + this.style.setLayoutProperty(layerId, name, value, options); + return this._update(true); + } + /** + * Returns the value of a layout property in the specified style layer. + * + * @param layerId - The ID of the layer to get the layout property from. + * @param name - The name of the layout property to get. + * @returns The value of the specified layout property. + */ + getLayoutProperty(layerId, name) { + return this.style.getLayoutProperty(layerId, name); + } + /** + * Sets the value of the style's glyphs property. + * + * @param glyphsUrl - Glyph URL to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/glyphs/). + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setGlyphs('https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'); + * ``` + */ + setGlyphs(glyphsUrl, options = {}) { + this._lazyInitEmptyStyle(); + this.style.setGlyphs(glyphsUrl, options); + return this._update(true); + } + /** + * Returns the value of the style's glyphs URL + * + * @returns glyphs Style's glyphs url + */ + getGlyphs() { + return this.style.getGlyphsUrl(); + } + /** + * Adds a sprite to the map's style. Fires the `style` event. + * + * @param id - The ID of the sprite to add. Must not conflict with existing sprites. + * @param url - The URL to load the sprite from + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.addSprite('sprite-two', 'http://example.com/sprite-two'); + * ``` + */ + addSprite(id, url, options = {}) { + this._lazyInitEmptyStyle(); + this.style.addSprite(id, url, options, (err) => { + if (!err) { + this._update(true); + } + }); + return this; + } + /** + * Removes the sprite from the map's style. Fires the `style` event. + * + * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be "default". + * @returns `this` + * @example + * ```ts + * map.removeSprite('sprite-two'); + * map.removeSprite('default'); + * ``` + */ + removeSprite(id) { + this._lazyInitEmptyStyle(); + this.style.removeSprite(id); + return this._update(true); + } + /** + * Returns the as-is value of the style's sprite. + * + * @returns style's sprite list of id-url pairs + */ + getSprite() { + return this.style.getSprite(); + } + /** + * Sets the value of the style's sprite property. + * + * @param spriteUrl - Sprite URL to set. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setSprite('YOUR_SPRITE_URL'); + * ``` + */ + setSprite(spriteUrl, options = {}) { + this._lazyInitEmptyStyle(); + this.style.setSprite(spriteUrl, options, (err) => { + if (!err) { + this._update(true); + } + }); + return this; + } + /** + * Sets the any combination of light values. + * + * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light). + * @param options - Options object. + * @returns `this` + * + * @example + * ```ts + * let layerVisibility = map.getLayoutProperty('my-layer', 'visibility'); + * ``` + */ + setLight(light, options = {}) { + this._lazyInitEmptyStyle(); + this.style.setLight(light, options); + return this._update(true); + } + /** + * Returns the value of the light object. + * + * @returns light Light properties of the style. + */ + getLight() { + return this.style.getLight(); + } + /** + * Sets the `state` of a feature. + * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime. + * When using this method, the `state` object is merged with any existing key-value pairs in the feature's state. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * This method can only be used with sources that have a `feature.id` attribute. The `feature.id` attribute can be defined in three ways: + * - For vector or GeoJSON sources, including an `id` attribute in the original data file. + * - For vector or GeoJSON sources, using the [`promoteId`](https://maplibre.org/maplibre-style-spec/sources/#vector-promoteId) option at the time the source is defined. + * - For GeoJSON sources, using the [`generateId`](https://maplibre.org/maplibre-style-spec/sources/#geojson-generateId) option to auto-assign an `id` based on the feature's index in the source data. If you change feature data using `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values. + * + * _Note: You can use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) to access the values in a feature's state object for the purposes of styling._ + * + * @param feature - Feature identifier. Feature objects returned from + * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @param state - A set of key-value pairs. The values should be valid JSON types. + * @returns `this` + * + * @example + * ```ts + * // When the mouse moves over the `my-layer` layer, update + * // the feature state for the feature under the mouse + * map.on('mousemove', 'my-layer', function(e) { + * if (e.features.length > 0) { + * map.setFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id, + * }, { + * hover: true + * }); + * } + * }); + * ``` + * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + */ + setFeatureState(feature, state) { + this.style.setFeatureState(feature, state); + return this._update(); + } + /** + * Removes the `state` of a feature, setting it back to the default behavior. + * If only a `target.source` is specified, it will remove the state for all features from that source. + * If `target.id` is also specified, it will remove all keys for that feature's state. + * If `key` is also specified, it removes only that key from that feature's state. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * @param target - Identifier of where to remove state. It can be a source, a feature, or a specific key of feature. + * Feature objects returned from {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @param key - (optional) The key in the feature state to reset. + * @returns `this` + * @example + * Reset the entire state object for all features in the `my-source` source + * ```ts + * map.removeFeatureState({ + * source: 'my-source' + * }); + * ``` + * + * @example + * When the mouse leaves the `my-layer` layer, + * reset the entire state object for the + * feature under the mouse + * ```ts + * map.on('mouseleave', 'my-layer', function(e) { + * map.removeFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }); + * }); + * ``` + * + * @example + * When the mouse leaves the `my-layer` layer, + * reset only the `hover` key-value pair in the + * state for the feature under the mouse + * ```ts + * map.on('mouseleave', 'my-layer', function(e) { + * map.removeFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }, 'hover'); + * }); + * ``` + */ + removeFeatureState(target, key) { + this.style.removeFeatureState(target, key); + return this._update(); + } + /** + * Gets the `state` of a feature. + * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * _Note: To access the values in a feature's state object for the purposes of styling the feature, use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state)._ + * + * @param feature - Feature identifier. Feature objects returned from + * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @returns The state of the feature: a set of key-value pairs that was assigned to the feature at runtime. + * + * @example + * When the mouse moves over the `my-layer` layer, + * get the feature state for the feature under the mouse + * ```ts + * map.on('mousemove', 'my-layer', function(e) { + * if (e.features.length > 0) { + * map.getFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }); + * } + * }); + * ``` + */ + getFeatureState(feature) { + return this.style.getFeatureState(feature); + } + /** + * Returns the map's containing HTML element. + * + * @returns The map's container. + */ + getContainer() { + return this._container; + } + /** + * Returns the HTML element containing the map's `` element. + * + * If you want to add non-GL overlays to the map, you should append them to this element. + * + * This is the element to which event bindings for map interactivity (such as panning and zooming) are + * attached. It will receive bubbled events from child elements such as the ``, but not from + * map controls. + * + * @returns The container of the map's ``. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + getCanvasContainer() { + return this._canvasContainer; + } + /** + * Returns the map's `` element. + * + * @returns The map's `` element. + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + getCanvas() { + return this._canvas; + } + _containerDimensions() { + let width = 0; + let height = 0; + if (this._container) { + width = this._container.clientWidth || 400; + height = this._container.clientHeight || 300; + } + return [width, height]; + } + _setupContainer() { + const container = this._container; + container.classList.add('maplibregl-map'); + const canvasContainer = this._canvasContainer = DOM.create('div', 'maplibregl-canvas-container', container); + if (this._interactive) { + canvasContainer.classList.add('maplibregl-interactive'); + } + this._canvas = DOM.create('canvas', 'maplibregl-canvas', canvasContainer); + this._canvas.addEventListener('webglcontextlost', this._contextLost, false); + this._canvas.addEventListener('webglcontextrestored', this._contextRestored, false); + this._canvas.setAttribute('tabindex', '0'); + this._canvas.setAttribute('aria-label', 'Map'); + this._canvas.setAttribute('role', 'region'); + const dimensions = this._containerDimensions(); + const clampedPixelRatio = this._getClampedPixelRatio(dimensions[0], dimensions[1]); + this._resizeCanvas(dimensions[0], dimensions[1], clampedPixelRatio); + const controlContainer = this._controlContainer = DOM.create('div', 'maplibregl-control-container', container); + const positions = this._controlPositions = {}; + ['top-left', 'top-right', 'bottom-left', 'bottom-right'].forEach((positionName) => { + positions[positionName] = DOM.create('div', `maplibregl-ctrl-${positionName} `, controlContainer); + }); + this._container.addEventListener('scroll', this._onMapScroll, false); + } + _setupCooperativeGestures() { + const container = this._container; + this._cooperativeGesturesScreen = DOM.create('div', 'maplibregl-cooperative-gesture-screen', container); + let desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.windowsHelpText ? this._cooperativeGestures.windowsHelpText : 'Use Ctrl + scroll to zoom the map'; + if (navigator.platform.indexOf('Mac') === 0) { + desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.macHelpText ? this._cooperativeGestures.macHelpText : 'Use ⌘ + scroll to zoom the map'; + } + const mobileMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.mobileHelpText ? this._cooperativeGestures.mobileHelpText : 'Use two fingers to move the map'; + this._cooperativeGesturesScreen.innerHTML = ` +
${desktopMessage}
+
${mobileMessage}
+ `; + // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures + this._cooperativeGesturesScreen.setAttribute('aria-hidden', 'true'); + // Add event to canvas container since gesture container is pointer-events: none + this._canvasContainer.addEventListener('wheel', this._cooperativeGesturesOnWheel, false); + // Add a cooperative gestures class (enable touch-action: pan-x pan-y;) + this._canvasContainer.classList.add('maplibregl-cooperative-gestures'); + } + _destroyCooperativeGestures() { + DOM.remove(this._cooperativeGesturesScreen); + this._canvasContainer.removeEventListener('wheel', this._cooperativeGesturesOnWheel, false); + this._canvasContainer.classList.remove('maplibregl-cooperative-gestures'); + } + _resizeCanvas(width, height, pixelRatio) { + // Request the required canvas size taking the pixelratio into account. + this._canvas.width = Math.floor(pixelRatio * width); + this._canvas.height = Math.floor(pixelRatio * height); + // Maintain the same canvas size, potentially downscaling it for HiDPI displays + this._canvas.style.width = `${width}px`; + this._canvas.style.height = `${height}px`; + } + _setupPainter() { + const attributes = { + alpha: true, + stencil: true, + depth: true, + failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat, + preserveDrawingBuffer: this._preserveDrawingBuffer, + antialias: this._antialias || false + }; + let webglcontextcreationerrorDetailObject = null; + this._canvas.addEventListener('webglcontextcreationerror', (args) => { + webglcontextcreationerrorDetailObject = { requestedAttributes: attributes }; + if (args) { + webglcontextcreationerrorDetailObject.statusMessage = args.statusMessage; + webglcontextcreationerrorDetailObject.type = args.type; + } + }, { once: true }); + const gl = this._canvas.getContext('webgl2', attributes) || + this._canvas.getContext('webgl', attributes); + if (!gl) { + const msg = 'Failed to initialize WebGL'; + if (webglcontextcreationerrorDetailObject) { + webglcontextcreationerrorDetailObject.message = msg; + throw new Error(JSON.stringify(webglcontextcreationerrorDetailObject)); + } + else { + throw new Error(msg); + } + } + this.painter = new Painter(gl, this.transform); + webpSupported.testSupport(gl); + } + _onCooperativeGesture(event, metaPress, touches) { + if (!metaPress && touches < 2) { + // Alert user how to scroll/pan + this._cooperativeGesturesScreen.classList.add('maplibregl-show'); + setTimeout(() => { + this._cooperativeGesturesScreen.classList.remove('maplibregl-show'); + }, 100); + } + return false; + } + /** + * Returns a Boolean indicating whether the map is fully loaded. + * + * Returns `false` if the style is not yet fully loaded, + * or if there has been a change to the sources or style that + * has not yet fully loaded. + * + * @returns A Boolean indicating whether the map is fully loaded. + */ + loaded() { + return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded(); + } + /** + * @internal + * Update this map's style and sources, and re-render the map. + * + * @param updateStyle - mark the map's style for reprocessing as + * well as its sources + * @returns `this` + */ + _update(updateStyle) { + if (!this.style || !this.style._loaded) + return this; + this._styleDirty = this._styleDirty || updateStyle; + this._sourcesDirty = true; + this.triggerRepaint(); + return this; + } + /** + * @internal + * Request that the given callback be executed during the next render + * frame. Schedule a render frame if one is not already scheduled. + * + * @returns An id that can be used to cancel the callback + */ + _requestRenderFrame(callback) { + this._update(); + return this._renderTaskQueue.add(callback); + } + _cancelRenderFrame(id) { + this._renderTaskQueue.remove(id); + } + /** + * @internal + * Call when a (re-)render of the map is required: + * - The style has changed (`setPaintProperty()`, etc.) + * - Source data has changed (e.g. tiles have finished loading) + * - The map has is moving (or just finished moving) + * - A transition is in progress + * + * @param paintStartTimeStamp - The time when the animation frame began executing. + * + * @returns `this` + */ + _render(paintStartTimeStamp) { + const fadeDuration = this._idleTriggered ? this._fadeDuration : 0; + // A custom layer may have used the context asynchronously. Mark the state as dirty. + this.painter.context.setDirty(); + this.painter.setBaseState(); + this._renderTaskQueue.run(paintStartTimeStamp); + // A task queue callback may have fired a user event which may have removed the map + if (this._removed) + return; + let crossFading = false; + // If the style has changed, the map is being zoomed, or a transition or fade is in progress: + // - Apply style changes (in a batch) + // - Recalculate paint properties. + if (this.style && this._styleDirty) { + this._styleDirty = false; + const zoom = this.transform.zoom; + const now = performance.browser.now(); + this.style.zoomHistory.update(zoom, now); + const parameters = new performance.EvaluationParameters(zoom, { + now, + fadeDuration, + zoomHistory: this.style.zoomHistory, + transition: this.style.getTransition() + }); + const factor = parameters.crossFadingFactor(); + if (factor !== 1 || factor !== this._crossFadingFactor) { + crossFading = true; + this._crossFadingFactor = factor; + } + this.style.update(parameters); + } + // If we are in _render for any reason other than an in-progress paint + // transition, update source caches to check for and load any tiles we + // need for the current transform + if (this.style && this._sourcesDirty) { + this._sourcesDirty = false; + this.style._updateSources(this.transform); + } + // update terrain stuff + if (this.terrain) { + this.terrain.sourceCache.update(this.transform, this.terrain); + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + if (!this._elevationFreeze) { + this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + } + } + else { + this.transform._minEleveationForCurrentTile = 0; + this.transform.elevation = 0; + } + this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions); + // Actually draw + this.painter.render(this.style, { + showTileBoundaries: this.showTileBoundaries, + showOverdrawInspector: this._showOverdrawInspector, + rotating: this.isRotating(), + zooming: this.isZooming(), + moving: this.isMoving(), + fadeDuration, + showPadding: this.showPadding, + }); + this.fire(new performance.Event('render')); + if (this.loaded() && !this._loaded) { + this._loaded = true; + performance.PerformanceUtils.mark(performance.PerformanceMarkers.load); + this.fire(new performance.Event('load')); + } + if (this.style && (this.style.hasTransitions() || crossFading)) { + this._styleDirty = true; + } + if (this.style && !this._placementDirty) { + // Since no fade operations are in progress, we can release + // all tiles held for fading. If we didn't do this, the tiles + // would just sit in the SourceCaches until the next render + this.style._releaseSymbolFadeTiles(); + } + // Schedule another render frame if it's needed. + // + // Even though `_styleDirty` and `_sourcesDirty` are reset in this + // method, synchronous events fired during Style#update or + // Style#_updateSources could have caused them to be set again. + const somethingDirty = this._sourcesDirty || this._styleDirty || this._placementDirty; + if (somethingDirty || this._repaint) { + this.triggerRepaint(); + } + else if (!this.isMoving() && this.loaded()) { + this.fire(new performance.Event('idle')); + } + if (this._loaded && !this._fullyLoaded && !somethingDirty) { + this._fullyLoaded = true; + performance.PerformanceUtils.mark(performance.PerformanceMarkers.fullLoad); + } + return this; + } + /** + * Force a synchronous redraw of the map. + * @returns `this` + * @example + * ```ts + * map.redraw(); + * ``` + */ + redraw() { + if (this.style) { + // cancel the scheduled update + if (this._frame) { + this._frame.cancel(); + this._frame = null; + } + this._render(0); + } + return this; + } + /** + * Clean up and release all internal resources associated with this map. + * + * This includes DOM elements, event bindings, web workers, and WebGL resources. + * + * Use this method when you are done using the map and wish to ensure that it no + * longer consumes browser resources. Afterwards, you must not call any other + * methods on the map. + */ + remove() { + var _a; + if (this._hash) + this._hash.remove(); + for (const control of this._controls) + control.onRemove(this); + this._controls = []; + if (this._frame) { + this._frame.cancel(); + this._frame = null; + } + this._renderTaskQueue.clear(); + this.painter.destroy(); + this.handlers.destroy(); + delete this.handlers; + this.setStyle(null); + if (typeof window !== 'undefined') { + removeEventListener('online', this._onWindowOnline, false); + } + ImageRequest.removeThrottleControl(this._imageQueueHandle); + (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect(); + const extension = this.painter.context.gl.getExtension('WEBGL_lose_context'); + if (extension) + extension.loseContext(); + this._canvas.removeEventListener('webglcontextrestored', this._contextRestored, false); + this._canvas.removeEventListener('webglcontextlost', this._contextLost, false); + DOM.remove(this._canvasContainer); + DOM.remove(this._controlContainer); + if (this._cooperativeGestures) { + this._destroyCooperativeGestures(); + } + this._container.classList.remove('maplibregl-map'); + performance.PerformanceUtils.clearMetrics(); + this._removed = true; + this.fire(new performance.Event('remove')); + } + /** + * Trigger the rendering of a single frame. Use this method with custom layers to + * repaint the map when the layer changes. Calling this multiple times before the + * next frame is rendered will still result in only a single frame being rendered. + * @example + * ```ts + * map.triggerRepaint(); + * ``` + * @see [Add a 3D model](https://maplibre.org/maplibre-gl-js/docs/examples/add-3d-model/) + * @see [Add an animated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/) + */ + triggerRepaint() { + if (this.style && !this._frame) { + this._frame = performance.browser.frame((paintStartTimeStamp) => { + performance.PerformanceUtils.frame(paintStartTimeStamp); + this._frame = null; + this._render(paintStartTimeStamp); + }); + } + } + /** + * Gets and sets a Boolean indicating whether the map will render an outline + * around each tile and the tile ID. These tile boundaries are useful for + * debugging. + * + * The uncompressed file size of the first vector source is drawn in the top left + * corner of each tile, next to the tile ID. + * + * @example + * ```ts + * map.showTileBoundaries = true; + * ``` + */ + get showTileBoundaries() { return !!this._showTileBoundaries; } + set showTileBoundaries(value) { + if (this._showTileBoundaries === value) + return; + this._showTileBoundaries = value; + this._update(); + } + /** + * Gets and sets a Boolean indicating whether the map will visualize + * the padding offsets. + */ + get showPadding() { return !!this._showPadding; } + set showPadding(value) { + if (this._showPadding === value) + return; + this._showPadding = value; + this._update(); + } + /** + * Gets and sets a Boolean indicating whether the map will render boxes + * around all symbols in the data source, revealing which symbols + * were rendered or which were hidden due to collisions. + * This information is useful for debugging. + */ + get showCollisionBoxes() { return !!this._showCollisionBoxes; } + set showCollisionBoxes(value) { + if (this._showCollisionBoxes === value) + return; + this._showCollisionBoxes = value; + if (value) { + // When we turn collision boxes on we have to generate them for existing tiles + // When we turn them off, there's no cost to leaving existing boxes in place + this.style._generateCollisionBoxes(); + } + else { + // Otherwise, call an update to remove collision boxes + this._update(); + } + } + /** + * Gets and sets a Boolean indicating whether the map should color-code + * each fragment to show how many times it has been shaded. + * White fragments have been shaded 8 or more times. + * Black fragments have been shaded 0 times. + * This information is useful for debugging. + */ + get showOverdrawInspector() { return !!this._showOverdrawInspector; } + set showOverdrawInspector(value) { + if (this._showOverdrawInspector === value) + return; + this._showOverdrawInspector = value; + this._update(); + } + /** + * Gets and sets a Boolean indicating whether the map will + * continuously repaint. This information is useful for analyzing performance. + */ + get repaint() { return !!this._repaint; } + set repaint(value) { + if (this._repaint !== value) { + this._repaint = value; + this.triggerRepaint(); + } + } + // show vertices + get vertices() { return !!this._vertices; } + set vertices(value) { this._vertices = value; this._update(); } + /** + * Returns the package version of the library + * @returns Package version of the library + */ + get version() { + return version$1; + } + /** + * Returns the elevation for the point where the camera is looking. + * This value corresponds to: + * "meters above sea level" * "exaggeration" + * @returns The elevation. + */ + getCameraTargetElevation() { + return this.transform.elevation; + } +}; + +const assignEvents = (handler) => { + handler.touchstart = handler.dragStart; + handler.touchmoveWindow = handler.dragMove; + handler.touchend = handler.dragEnd; +}; +const generateOneFingerTouchRotationHandler = ({ enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8 }) => { + const touchMoveStateManager = new OneFingerTouchMoveStateManager(); + return new DragHandler({ + clickTolerance, + move: (lastPoint, point) => ({ bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved }), + moveStateManager: touchMoveStateManager, + enable, + assignEvents, + }); +}; +const generateOneFingerTouchPitchHandler = ({ enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5 }) => { + const touchMoveStateManager = new OneFingerTouchMoveStateManager(); + return new DragHandler({ + clickTolerance, + move: (lastPoint, point) => ({ pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved }), + moveStateManager: touchMoveStateManager, + enable, + assignEvents, + }); +}; + +const defaultOptions$3 = { + showCompass: true, + showZoom: true, + visualizePitch: false +}; +/** + * A `NavigationControl` control contains zoom buttons and a compass. + * + * @group Markers and Controls + * + * @example + * ```ts + * let nav = new maplibregl.NavigationControl(); + * map.addControl(nav, 'top-left'); + * ``` + * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/) + */ +class NavigationControl { + /** + * @param options - the control's options + */ + constructor(options) { + this._updateZoomButtons = () => { + const zoom = this._map.getZoom(); + const isMax = zoom === this._map.getMaxZoom(); + const isMin = zoom === this._map.getMinZoom(); + this._zoomInButton.disabled = isMax; + this._zoomOutButton.disabled = isMin; + this._zoomInButton.setAttribute('aria-disabled', isMax.toString()); + this._zoomOutButton.setAttribute('aria-disabled', isMin.toString()); + }; + this._rotateCompassArrow = () => { + const rotate = this.options.visualizePitch ? + `scale(${1 / Math.pow(Math.cos(this._map.transform.pitch * (Math.PI / 180)), 0.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle * (180 / Math.PI)}deg)` : + `rotate(${this._map.transform.angle * (180 / Math.PI)}deg)`; + this._compassIcon.style.transform = rotate; + }; + this._setButtonTitle = (button, title) => { + const str = this._map._getUIString(`NavigationControl.${title}`); + button.title = str; + button.setAttribute('aria-label', str); + }; + this.options = performance.extend({}, defaultOptions$3, options); + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + this._container.addEventListener('contextmenu', (e) => e.preventDefault()); + if (this.options.showZoom) { + this._zoomInButton = this._createButton('maplibregl-ctrl-zoom-in', (e) => this._map.zoomIn({}, { originalEvent: e })); + DOM.create('span', 'maplibregl-ctrl-icon', this._zoomInButton).setAttribute('aria-hidden', 'true'); + this._zoomOutButton = this._createButton('maplibregl-ctrl-zoom-out', (e) => this._map.zoomOut({}, { originalEvent: e })); + DOM.create('span', 'maplibregl-ctrl-icon', this._zoomOutButton).setAttribute('aria-hidden', 'true'); + } + if (this.options.showCompass) { + this._compass = this._createButton('maplibregl-ctrl-compass', (e) => { + if (this.options.visualizePitch) { + this._map.resetNorthPitch({}, { originalEvent: e }); + } + else { + this._map.resetNorth({}, { originalEvent: e }); + } + }); + this._compassIcon = DOM.create('span', 'maplibregl-ctrl-icon', this._compass); + this._compassIcon.setAttribute('aria-hidden', 'true'); + } + } + onAdd(map) { + this._map = map; + if (this.options.showZoom) { + this._setButtonTitle(this._zoomInButton, 'ZoomIn'); + this._setButtonTitle(this._zoomOutButton, 'ZoomOut'); + this._map.on('zoom', this._updateZoomButtons); + this._updateZoomButtons(); + } + if (this.options.showCompass) { + this._setButtonTitle(this._compass, 'ResetBearing'); + if (this.options.visualizePitch) { + this._map.on('pitch', this._rotateCompassArrow); + } + this._map.on('rotate', this._rotateCompassArrow); + this._rotateCompassArrow(); + this._handler = new MouseRotateWrapper(this._map, this._compass, this.options.visualizePitch); + } + return this._container; + } + onRemove() { + DOM.remove(this._container); + if (this.options.showZoom) { + this._map.off('zoom', this._updateZoomButtons); + } + if (this.options.showCompass) { + if (this.options.visualizePitch) { + this._map.off('pitch', this._rotateCompassArrow); + } + this._map.off('rotate', this._rotateCompassArrow); + this._handler.off(); + delete this._handler; + } + delete this._map; + } + _createButton(className, fn) { + const a = DOM.create('button', className, this._container); + a.type = 'button'; + a.addEventListener('click', fn); + return a; + } +} +class MouseRotateWrapper { + constructor(map, element, pitch = false) { + this.mousedown = (e) => { + this.startMouse(performance.extend({}, e, { ctrlKey: true, preventDefault: () => e.preventDefault() }), DOM.mousePos(this.element, e)); + DOM.addEventListener(window, 'mousemove', this.mousemove); + DOM.addEventListener(window, 'mouseup', this.mouseup); + }; + this.mousemove = (e) => { + this.moveMouse(e, DOM.mousePos(this.element, e)); + }; + this.mouseup = (e) => { + this.mouseRotate.dragEnd(e); + if (this.mousePitch) + this.mousePitch.dragEnd(e); + this.offTemp(); + }; + this.touchstart = (e) => { + if (e.targetTouches.length !== 1) { + this.reset(); + } + else { + this._startPos = this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0]; + this.startTouch(e, this._startPos); + DOM.addEventListener(window, 'touchmove', this.touchmove, { passive: false }); + DOM.addEventListener(window, 'touchend', this.touchend); + } + }; + this.touchmove = (e) => { + if (e.targetTouches.length !== 1) { + this.reset(); + } + else { + this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0]; + this.moveTouch(e, this._lastPos); + } + }; + this.touchend = (e) => { + if (e.targetTouches.length === 0 && + this._startPos && + this._lastPos && + this._startPos.dist(this._lastPos) < this._clickTolerance) { + this.element.click(); + } + delete this._startPos; + delete this._lastPos; + this.offTemp(); + }; + this.reset = () => { + this.mouseRotate.reset(); + if (this.mousePitch) + this.mousePitch.reset(); + this.touchRotate.reset(); + if (this.touchPitch) + this.touchPitch.reset(); + delete this._startPos; + delete this._lastPos; + this.offTemp(); + }; + this._clickTolerance = 10; + const mapRotateTolerance = map.dragRotate._mouseRotate.getClickTolerance(); + const mapPitchTolerance = map.dragRotate._mousePitch.getClickTolerance(); + this.element = element; + this.mouseRotate = generateMouseRotationHandler({ clickTolerance: mapRotateTolerance, enable: true }); + this.touchRotate = generateOneFingerTouchRotationHandler({ clickTolerance: mapRotateTolerance, enable: true }); + this.map = map; + if (pitch) { + this.mousePitch = generateMousePitchHandler({ clickTolerance: mapPitchTolerance, enable: true }); + this.touchPitch = generateOneFingerTouchPitchHandler({ clickTolerance: mapPitchTolerance, enable: true }); + } + DOM.addEventListener(element, 'mousedown', this.mousedown); + DOM.addEventListener(element, 'touchstart', this.touchstart, { passive: false }); + DOM.addEventListener(element, 'touchcancel', this.reset); + } + startMouse(e, point) { + this.mouseRotate.dragStart(e, point); + if (this.mousePitch) + this.mousePitch.dragStart(e, point); + DOM.disableDrag(); + } + startTouch(e, point) { + this.touchRotate.dragStart(e, point); + if (this.touchPitch) + this.touchPitch.dragStart(e, point); + DOM.disableDrag(); + } + moveMouse(e, point) { + const map = this.map; + const { bearingDelta } = this.mouseRotate.dragMove(e, point) || {}; + if (bearingDelta) + map.setBearing(map.getBearing() + bearingDelta); + if (this.mousePitch) { + const { pitchDelta } = this.mousePitch.dragMove(e, point) || {}; + if (pitchDelta) + map.setPitch(map.getPitch() + pitchDelta); + } + } + moveTouch(e, point) { + const map = this.map; + const { bearingDelta } = this.touchRotate.dragMove(e, point) || {}; + if (bearingDelta) + map.setBearing(map.getBearing() + bearingDelta); + if (this.touchPitch) { + const { pitchDelta } = this.touchPitch.dragMove(e, point) || {}; + if (pitchDelta) + map.setPitch(map.getPitch() + pitchDelta); + } + } + off() { + const element = this.element; + DOM.removeEventListener(element, 'mousedown', this.mousedown); + DOM.removeEventListener(element, 'touchstart', this.touchstart, { passive: false }); + DOM.removeEventListener(window, 'touchmove', this.touchmove, { passive: false }); + DOM.removeEventListener(window, 'touchend', this.touchend); + DOM.removeEventListener(element, 'touchcancel', this.reset); + this.offTemp(); + } + offTemp() { + DOM.enableDrag(); + DOM.removeEventListener(window, 'mousemove', this.mousemove); + DOM.removeEventListener(window, 'mouseup', this.mouseup); + DOM.removeEventListener(window, 'touchmove', this.touchmove, { passive: false }); + DOM.removeEventListener(window, 'touchend', this.touchend); + } +} + +let supportsGeolocation; +function checkGeolocationSupport(callback, forceRecalculation = false) { + if (supportsGeolocation !== undefined && !forceRecalculation) { + callback(supportsGeolocation); + } + else if (window.navigator.permissions !== undefined) { + // navigator.permissions has incomplete browser support + // http://caniuse.com/#feat=permissions-api + // Test for the case where a browser disables Geolocation because of an + // insecure origin + window.navigator.permissions.query({ name: 'geolocation' }).then((p) => { + supportsGeolocation = p.state !== 'denied'; + callback(supportsGeolocation); + }).catch(() => { + // Fix for iOS16 which rejects query but still supports geolocation + supportsGeolocation = !!window.navigator.geolocation; + callback(supportsGeolocation); + }); + } + else { + supportsGeolocation = !!window.navigator.geolocation; + callback(supportsGeolocation); + } +} + +/** + * Given a LngLat, prior projected position, and a transform, return a new LngLat shifted + * n × 360° east or west for some n ≥ 0 such that: + * + * * the projected location of the result is on screen, if possible, and secondarily: + * * the difference between the projected location of the result and the prior position + * is minimized. + * + * The object is to preserve perceived object constancy for Popups and Markers as much as + * possible; they should avoid shifting large distances across the screen, even when the + * map center changes by ±360° due to automatic wrapping, and when about to go off screen, + * should wrap just enough to avoid doing so. + */ +function smartWrap(lngLat, priorPos, transform) { + lngLat = new performance.LngLat(lngLat.lng, lngLat.lat); + // First, try shifting one world in either direction, and see if either is closer to the + // prior position. This preserves object constancy when the map center is auto-wrapped + // during animations. + if (priorPos) { + const left = new performance.LngLat(lngLat.lng - 360, lngLat.lat); + const right = new performance.LngLat(lngLat.lng + 360, lngLat.lat); + const delta = transform.locationPoint(lngLat).distSqr(priorPos); + if (transform.locationPoint(left).distSqr(priorPos) < delta) { + lngLat = left; + } + else if (transform.locationPoint(right).distSqr(priorPos) < delta) { + lngLat = right; + } + } + // Second, wrap toward the center until the new position is on screen, or we can't get + // any closer. + while (Math.abs(lngLat.lng - transform.center.lng) > 180) { + const pos = transform.locationPoint(lngLat); + if (pos.x >= 0 && pos.y >= 0 && pos.x <= transform.width && pos.y <= transform.height) { + break; + } + if (lngLat.lng > transform.center.lng) { + lngLat.lng -= 360; + } + else { + lngLat.lng += 360; + } + } + return lngLat; +} + +const anchorTranslate = { + 'center': 'translate(-50%,-50%)', + 'top': 'translate(-50%,0)', + 'top-left': 'translate(0,0)', + 'top-right': 'translate(-100%,0)', + 'bottom': 'translate(-50%,-100%)', + 'bottom-left': 'translate(0,-100%)', + 'bottom-right': 'translate(-100%,-100%)', + 'left': 'translate(0,-50%)', + 'right': 'translate(-100%,-50%)' +}; +function applyAnchorClass(element, anchor, prefix) { + const classList = element.classList; + for (const key in anchorTranslate) { + classList.remove(`maplibregl-${prefix}-anchor-${key}`); + } + classList.add(`maplibregl-${prefix}-anchor-${anchor}`); +} + +/** + * Creates a marker component + * + * @group Markers and Controls + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([30.5, 50.5]) + * .addTo(map); + * ``` + * + * @example + * Set options + * ```ts + * let marker = new maplibregl.Marker({ + * color: "#FFFFFF", + * draggable: true + * }).setLngLat([30.5, 50.5]) + * .addTo(map); + * ``` + * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/) + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + * + * ### Events + * + * @event `dragstart` Fired when dragging starts, `marker` object that is being dragged + * + * @event `drag` Fired while dragging. `marker` object that is being dragged + * + * @event `dragend` Fired when the marker is finished being dragged, `marker` object that was dragged + */ +class Marker extends performance.Evented { + /** + * @param options - the options + */ + constructor(options) { + super(); + this._onKeyPress = (e) => { + const code = e.code; + const legacyCode = e.charCode || e.keyCode; + if ((code === 'Space') || (code === 'Enter') || + (legacyCode === 32) || (legacyCode === 13) // space or enter + ) { + this.togglePopup(); + } + }; + this._onMapClick = (e) => { + const targetElement = e.originalEvent.target; + const element = this._element; + if (this._popup && (targetElement === element || element.contains(targetElement))) { + this.togglePopup(); + } + }; + this._update = (e) => { + if (!this._map) + return; + const isFullyLoaded = this._map.loaded() && !this._map.isMoving(); + if ((e === null || e === void 0 ? void 0 : e.type) === 'terrain' || ((e === null || e === void 0 ? void 0 : e.type) === 'render' && !isFullyLoaded)) { + this._map.once('render', this._update); + } + if (this._map.transform.renderWorldCopies) { + this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform); + } + this._pos = this._map.project(this._lngLat)._add(this._offset); + let rotation = ''; + if (this._rotationAlignment === 'viewport' || this._rotationAlignment === 'auto') { + rotation = `rotateZ(${this._rotation}deg)`; + } + else if (this._rotationAlignment === 'map') { + rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`; + } + let pitch = ''; + if (this._pitchAlignment === 'viewport' || this._pitchAlignment === 'auto') { + pitch = 'rotateX(0deg)'; + } + else if (this._pitchAlignment === 'map') { + pitch = `rotateX(${this._map.getPitch()}deg)`; + } + // because rounding the coordinates at every `move` event causes stuttered zooming + // we only round them when _update is called with `moveend` or when its called with + // no arguments (when the Marker is initialized or Marker#setLngLat is invoked). + if (!e || e.type === 'moveend') { + this._pos = this._pos.round(); + } + DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`); + // in case of 3D, ask the terrain coords-framebuffer for this pos and check if the marker is visible + // call this logic in setTimeout with a timeout of 100ms to save performance in map-movement + if (this._map.terrain && !this._opacityTimeout) + this._opacityTimeout = setTimeout(() => { + const lnglat = this._map.unproject(this._pos); + const metresPerPixel = 40075016.686 * Math.abs(Math.cos(this._lngLat.lat * Math.PI / 180)) / Math.pow(2, this._map.transform.tileZoom + 8); + this._element.style.opacity = lnglat.distanceTo(this._lngLat) > metresPerPixel * 20 ? '0.2' : '1.0'; + this._opacityTimeout = null; + }, 100); + }; + this._onMove = (e) => { + if (!this._isDragging) { + const clickTolerance = this._clickTolerance || this._map._clickTolerance; + this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance; + } + if (!this._isDragging) + return; + this._pos = e.point.sub(this._positionDelta); + this._lngLat = this._map.unproject(this._pos); + this.setLngLat(this._lngLat); + // suppress click event so that popups don't toggle on drag + this._element.style.pointerEvents = 'none'; + // make sure dragstart only fires on the first move event after mousedown. + // this can't be on mousedown because that event doesn't necessarily + // imply that a drag is about to happen. + if (this._state === 'pending') { + this._state = 'active'; + this.fire(new performance.Event('dragstart')); + } + this.fire(new performance.Event('drag')); + }; + this._onUp = () => { + // revert to normal pointer event handling + this._element.style.pointerEvents = 'auto'; + this._positionDelta = null; + this._pointerdownPos = null; + this._isDragging = false; + this._map.off('mousemove', this._onMove); + this._map.off('touchmove', this._onMove); + // only fire dragend if it was preceded by at least one drag event + if (this._state === 'active') { + this.fire(new performance.Event('dragend')); + } + this._state = 'inactive'; + }; + this._addDragHandler = (e) => { + if (this._element.contains(e.originalEvent.target)) { + e.preventDefault(); + // We need to calculate the pixel distance between the click point + // and the marker position, with the offset accounted for. Then we + // can subtract this distance from the mousemove event's position + // to calculate the new marker position. + // If we don't do this, the marker 'jumps' to the click position + // creating a jarring UX effect. + this._positionDelta = e.point.sub(this._pos).add(this._offset); + this._pointerdownPos = e.point; + this._state = 'pending'; + this._map.on('mousemove', this._onMove); + this._map.on('touchmove', this._onMove); + this._map.once('mouseup', this._onUp); + this._map.once('touchend', this._onUp); + } + }; + this._anchor = options && options.anchor || 'center'; + this._color = options && options.color || '#3FB1CE'; + this._scale = options && options.scale || 1; + this._draggable = options && options.draggable || false; + this._clickTolerance = options && options.clickTolerance || 0; + this._isDragging = false; + this._state = 'inactive'; + this._rotation = options && options.rotation || 0; + this._rotationAlignment = options && options.rotationAlignment || 'auto'; + this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment; + if (!options || !options.element) { + this._defaultMarker = true; + this._element = DOM.create('div'); + this._element.setAttribute('aria-label', 'Map marker'); + // create default map marker SVG + const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg'); + const defaultHeight = 41; + const defaultWidth = 27; + svg.setAttributeNS(null, 'display', 'block'); + svg.setAttributeNS(null, 'height', `${defaultHeight}px`); + svg.setAttributeNS(null, 'width', `${defaultWidth}px`); + svg.setAttributeNS(null, 'viewBox', `0 0 ${defaultWidth} ${defaultHeight}`); + const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + markerLarge.setAttributeNS(null, 'stroke', 'none'); + markerLarge.setAttributeNS(null, 'stroke-width', '1'); + markerLarge.setAttributeNS(null, 'fill', 'none'); + markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd'); + const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + page1.setAttributeNS(null, 'fill-rule', 'nonzero'); + const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)'); + shadow.setAttributeNS(null, 'fill', '#000000'); + const ellipses = [ + { 'rx': '10.5', 'ry': '5.25002273' }, + { 'rx': '10.5', 'ry': '5.25002273' }, + { 'rx': '9.5', 'ry': '4.77275007' }, + { 'rx': '8.5', 'ry': '4.29549936' }, + { 'rx': '7.5', 'ry': '3.81822308' }, + { 'rx': '6.5', 'ry': '3.34094679' }, + { 'rx': '5.5', 'ry': '2.86367051' }, + { 'rx': '4.5', 'ry': '2.38636864' } + ]; + for (const data of ellipses) { + const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse'); + ellipse.setAttributeNS(null, 'opacity', '0.04'); + ellipse.setAttributeNS(null, 'cx', '10.5'); + ellipse.setAttributeNS(null, 'cy', '5.80029008'); + ellipse.setAttributeNS(null, 'rx', data['rx']); + ellipse.setAttributeNS(null, 'ry', data['ry']); + shadow.appendChild(ellipse); + } + const background = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + background.setAttributeNS(null, 'fill', this._color); + const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path'); + bgPath.setAttributeNS(null, 'd', 'M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z'); + background.appendChild(bgPath); + const border = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + border.setAttributeNS(null, 'opacity', '0.25'); + border.setAttributeNS(null, 'fill', '#000000'); + const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path'); + borderPath.setAttributeNS(null, 'd', 'M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z'); + border.appendChild(borderPath); + const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)'); + maki.setAttributeNS(null, 'fill', '#FFFFFF'); + const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)'); + const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle'); + circle1.setAttributeNS(null, 'fill', '#000000'); + circle1.setAttributeNS(null, 'opacity', '0.25'); + circle1.setAttributeNS(null, 'cx', '5.5'); + circle1.setAttributeNS(null, 'cy', '5.5'); + circle1.setAttributeNS(null, 'r', '5.4999962'); + const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle'); + circle2.setAttributeNS(null, 'fill', '#FFFFFF'); + circle2.setAttributeNS(null, 'cx', '5.5'); + circle2.setAttributeNS(null, 'cy', '5.5'); + circle2.setAttributeNS(null, 'r', '5.4999962'); + circleContainer.appendChild(circle1); + circleContainer.appendChild(circle2); + page1.appendChild(shadow); + page1.appendChild(background); + page1.appendChild(border); + page1.appendChild(maki); + page1.appendChild(circleContainer); + svg.appendChild(page1); + svg.setAttributeNS(null, 'height', `${defaultHeight * this._scale}px`); + svg.setAttributeNS(null, 'width', `${defaultWidth * this._scale}px`); + this._element.appendChild(svg); + // if no element and no offset option given apply an offset for the default marker + // the -14 as the y value of the default marker offset was determined as follows + // + // the marker tip is at the center of the shadow ellipse from the default svg + // the y value of the center of the shadow ellipse relative to the svg top left is "shadow transform translate-y (29.0) + ellipse cy (5.80029008)" + // offset to the svg center "height (41 / 2)" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14 + // negative is used to move the marker up from the center so the tip is at the Marker lngLat + this._offset = performance.Point.convert(options && options.offset || [0, -14]); + } + else { + this._element = options.element; + this._offset = performance.Point.convert(options && options.offset || [0, 0]); + } + this._element.classList.add('maplibregl-marker'); + this._element.addEventListener('dragstart', (e) => { + e.preventDefault(); + }); + this._element.addEventListener('mousedown', (e) => { + // prevent focusing on click + e.preventDefault(); + }); + applyAnchorClass(this._element, this._anchor, 'marker'); + if (options && options.className) { + for (const name of options.className.split(' ')) { + this._element.classList.add(name); + } + } + this._popup = null; + } + /** + * Attaches the `Marker` to a `Map` object. + * @param map - The MapLibre GL JS map to add the marker to. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([30.5, 50.5]) + * .addTo(map); // add the marker to the map + * ``` + */ + addTo(map) { + this.remove(); + this._map = map; + map.getCanvasContainer().appendChild(this._element); + map.on('move', this._update); + map.on('moveend', this._update); + map.on('terrain', this._update); + this.setDraggable(this._draggable); + this._update(); + // If we attached the `click` listener to the marker element, the popup + // would close once the event propagated to `map` due to the + // `Popup#_onClickClose` listener. + this._map.on('click', this._onMapClick); + return this; + } + /** + * Removes the marker from a map + * @example + * ```ts + * let marker = new maplibregl.Marker().addTo(map); + * marker.remove(); + * ``` + * @returns `this` + */ + remove() { + if (this._opacityTimeout) { + clearTimeout(this._opacityTimeout); + delete this._opacityTimeout; + } + if (this._map) { + this._map.off('click', this._onMapClick); + this._map.off('move', this._update); + this._map.off('moveend', this._update); + this._map.off('mousedown', this._addDragHandler); + this._map.off('touchstart', this._addDragHandler); + this._map.off('mouseup', this._onUp); + this._map.off('touchend', this._onUp); + this._map.off('mousemove', this._onMove); + this._map.off('touchmove', this._onMove); + delete this._map; + } + DOM.remove(this._element); + if (this._popup) + this._popup.remove(); + return this; + } + /** + * Get the marker's geographical location. + * + * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously + * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep + * the marker on screen. + * + * @returns A {@link LngLat} describing the marker's location. + * @example + * ```ts + * // Store the marker's longitude and latitude coordinates in a variable + * let lngLat = marker.getLngLat(); + * // Print the marker's longitude and latitude values in the console + * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat ) + * ``` + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + getLngLat() { + return this._lngLat; + } + /** + * Set the marker's geographical position and move it. + * @param lnglat - A {@link LngLat} describing where the marker should be located. + * @returns `this` + * @example + * Create a new marker, set the longitude and latitude, and add it to the map + * ```ts + * new maplibregl.Marker() + * .setLngLat([-65.017, -16.457]) + * .addTo(map); + * ``` + * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/) + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + setLngLat(lnglat) { + this._lngLat = performance.LngLat.convert(lnglat); + this._pos = null; + if (this._popup) + this._popup.setLngLat(this._lngLat); + this._update(); + return this; + } + /** + * Returns the `Marker`'s HTML element. + * @returns element + */ + getElement() { + return this._element; + } + /** + * Binds a {@link Popup} to the {@link Marker}. + * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup + * set on this {@link Marker} instance is unset. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) // add popup + * .addTo(map); + * ``` + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + */ + setPopup(popup) { + if (this._popup) { + this._popup.remove(); + this._popup = null; + this._element.removeEventListener('keypress', this._onKeyPress); + if (!this._originalTabIndex) { + this._element.removeAttribute('tabindex'); + } + } + if (popup) { + if (!('offset' in popup.options)) { + const markerHeight = 41 - (5.8 / 2); + const markerRadius = 13.5; + const linearOffset = Math.abs(markerRadius) / Math.SQRT2; + popup.options.offset = this._defaultMarker ? { + 'top': [0, 0], + 'top-left': [0, 0], + 'top-right': [0, 0], + 'bottom': [0, -markerHeight], + 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + 'left': [markerRadius, (markerHeight - markerRadius) * -1], + 'right': [-markerRadius, (markerHeight - markerRadius) * -1] + } : this._offset; + } + this._popup = popup; + if (this._lngLat) + this._popup.setLngLat(this._lngLat); + this._originalTabIndex = this._element.getAttribute('tabindex'); + if (!this._originalTabIndex) { + this._element.setAttribute('tabindex', '0'); + } + this._element.addEventListener('keypress', this._onKeyPress); + } + return this; + } + /** + * Returns the {@link Popup} instance that is bound to the {@link Marker}. + * @returns popup + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * console.log(marker.getPopup()); // return the popup instance + * ``` + */ + getPopup() { + return this._popup; + } + /** + * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * marker.togglePopup(); // toggle popup open or closed + * ``` + */ + togglePopup() { + const popup = this._popup; + if (!popup) + return this; + else if (popup.isOpen()) + popup.remove(); + else + popup.addTo(this._map); + return this; + } + /** + * Get the marker's offset. + * @returns The marker's screen coordinates in pixels. + */ + getOffset() { + return this._offset; + } + /** + * Sets the offset of the marker + * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up. + * @returns `this` + */ + setOffset(offset) { + this._offset = performance.Point.convert(offset); + this._update(); + return this; + } + /** + * Adds a CSS class to the marker element. + * + * @param className - on-empty string with CSS class name to add to marker element + * + * @example + * ``` + * let marker = new maplibregl.Marker() + * marker.addClassName('some-class') + * ``` + */ + addClassName(className) { + this._element.classList.add(className); + } + /** + * Removes a CSS class from the marker element. + * + * @param className - Non-empty string with CSS class name to remove from marker element + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * marker.removeClassName('some-class') + * ``` + */ + removeClassName(className) { + this._element.classList.remove(className); + } + /** + * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class. + * + * @param className - Non-empty string with CSS class name to add/remove + * + * @returns if the class was removed return false, if class was added, then return true + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * marker.toggleClassName('toggleClass') + * ``` + */ + toggleClassName(className) { + return this._element.classList.toggle(className); + } + /** + * Sets the `draggable` property and functionality of the marker + * @param shouldBeDraggable - Turns drag functionality on/off + * @returns `this` + */ + setDraggable(shouldBeDraggable) { + this._draggable = !!shouldBeDraggable; // convert possible undefined value to false + // handle case where map may not exist yet + // e.g. when setDraggable is called before addTo + if (this._map) { + if (shouldBeDraggable) { + this._map.on('mousedown', this._addDragHandler); + this._map.on('touchstart', this._addDragHandler); + } + else { + this._map.off('mousedown', this._addDragHandler); + this._map.off('touchstart', this._addDragHandler); + } + } + return this; + } + /** + * Returns true if the marker can be dragged + * @returns True if the marker is draggable. + */ + isDraggable() { + return this._draggable; + } + /** + * Sets the `rotation` property of the marker. + * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting. + * @returns `this` + */ + setRotation(rotation) { + this._rotation = rotation || 0; + this._update(); + return this; + } + /** + * Returns the current rotation angle of the marker (in degrees). + * @returns The current rotation angle of the marker. + */ + getRotation() { + return this._rotation; + } + /** + * Sets the `rotationAlignment` property of the marker. + * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto' + * @returns `this` + */ + setRotationAlignment(alignment) { + this._rotationAlignment = alignment || 'auto'; + this._update(); + return this; + } + /** + * Returns the current `rotationAlignment` property of the marker. + * @returns The current rotational alignment of the marker. + */ + getRotationAlignment() { + return this._rotationAlignment; + } + /** + * Sets the `pitchAlignment` property of the marker. + * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`. + * @returns `this` + */ + setPitchAlignment(alignment) { + this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment; + this._update(); + return this; + } + /** + * Returns the current `pitchAlignment` property of the marker. + * @returns The current pitch alignment of the marker in degrees. + */ + getPitchAlignment() { + return this._pitchAlignment; + } +} + +const defaultOptions$2 = { + positionOptions: { + enableHighAccuracy: false, + maximumAge: 0, + timeout: 6000 /* 6 sec */ + }, + fitBoundsOptions: { + maxZoom: 15 + }, + trackUserLocation: false, + showAccuracyCircle: true, + showUserLocation: true +}; +let numberOfWatches = 0; +let noTimeout = false; +/** + * A `GeolocateControl` control provides a button that uses the browser's geolocation + * API to locate the user on the map. + * + * Not all browsers support geolocation, + * and some users may disable the feature. Geolocation support for modern + * browsers including Chrome requires sites to be served over HTTPS. If + * geolocation support is not available, the GeolocateControl will show + * as disabled. + * + * The zoom level applied will depend on the accuracy of the geolocation provided by the device. + * + * The GeolocateControl has two modes. If `trackUserLocation` is `false` (default) the control acts as a button, which when pressed will set the map's camera to target the user location. If the user moves, the map won't update. This is most suited for the desktop. If `trackUserLocation` is `true` the control acts as a toggle button that when active the user's location is actively monitored for changes. In this mode the GeolocateControl has three interaction states: + * * active - the map's camera automatically updates as the user's location changes, keeping the location dot in the center. Initial state and upon clicking the `GeolocateControl` button. + * * passive - the user's location dot automatically updates, but the map's camera does not. Occurs upon the user initiating a map movement. + * * disabled - occurs if Geolocation is not available, disabled or denied. + * + * These interaction states can't be controlled programmatically, rather they are set based on user interactions. + * @group Markers and Controls + * + * @example + * ```ts + * map.addControl(new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * })); + * ``` + * @see [Locate the user](https://maplibre.org/maplibre-gl-js/docs/examples/locate-user/) + * + * ### Events + * + * @event `trackuserlocationend` - Fired when the Geolocate Control changes to the background state, which happens when a user changes the camera during an active position lock. This only applies when trackUserLocation is true. In the background state, the dot on the map will update with location updates but the camera will not. + * + * @event `trackuserlocationstart` - Fired when the Geolocate Control changes to the active lock state, which happens either upon first obtaining a successful Geolocation API position for the user (a geolocate event will follow), or the user clicks the geolocate button when in the background state which uses the last known position to recenter the map and enter active lock state (no geolocate event will follow unless the users's location changes). + * + * @event `geolocate` - Fired on each Geolocation API position update which returned as success. + * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition). + * + * @event `error` - Fired on each Geolocation API position update which returned as an error. + * `data` - The returned [PositionError](https://developer.mozilla.org/en-US/docs/Web/API/PositionError) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition). + * + * @event `outofmaxbounds` Fired on each Geolocation API position update which returned as success but user position is out of map maxBounds. + * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition). + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when a trackuserlocationend event occurs. + * geolocate.on('trackuserlocationend', function() { + * console.log('A trackuserlocationend event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when a trackuserlocationstart event occurs. + * geolocate.on('trackuserlocationstart', function() { + * console.log('A trackuserlocationstart event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when a geolocate event occurs. + * geolocate.on('geolocate', function() { + * console.log('A geolocate event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when an error event occurs. + * geolocate.on('error', function() { + * console.log('An error event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when an outofmaxbounds event occurs. + * geolocate.on('outofmaxbounds', function() { + * console.log('An outofmaxbounds event has occurred.') + * }); + * ``` + */ +class GeolocateControl extends performance.Evented { + constructor(options) { + super(); + /** + * When the Geolocation API returns a new location, update the GeolocateControl. + * + * @param position - the Geolocation API Position + */ + this._onSuccess = (position) => { + if (!this._map) { + // control has since been removed + return; + } + if (this._isOutOfMapMaxBounds(position)) { + this._setErrorState(); + this.fire(new performance.Event('outofmaxbounds', position)); + this._updateMarker(); + this._finish(); + return; + } + if (this.options.trackUserLocation) { + // keep a record of the position so that if the state is BACKGROUND and the user + // clicks the button, we can move to ACTIVE_LOCK immediately without waiting for + // watchPosition to trigger _onSuccess + this._lastKnownPosition = position; + switch (this._watchState) { + case 'WAITING_ACTIVE': + case 'ACTIVE_LOCK': + case 'ACTIVE_ERROR': + this._watchState = 'ACTIVE_LOCK'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active'); + break; + case 'BACKGROUND': + case 'BACKGROUND_ERROR': + this._watchState = 'BACKGROUND'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background'); + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + } + // if showUserLocation and the watch state isn't off then update the marker location + if (this.options.showUserLocation && this._watchState !== 'OFF') { + this._updateMarker(position); + } + // if in normal mode (not watch mode), or if in watch mode and the state is active watch + // then update the camera + if (!this.options.trackUserLocation || this._watchState === 'ACTIVE_LOCK') { + this._updateCamera(position); + } + if (this.options.showUserLocation) { + this._dotElement.classList.remove('maplibregl-user-location-dot-stale'); + } + this.fire(new performance.Event('geolocate', position)); + this._finish(); + }; + /** + * Update the camera location to center on the current position + * + * @param position - the Geolocation API Position + */ + this._updateCamera = (position) => { + const center = new performance.LngLat(position.coords.longitude, position.coords.latitude); + const radius = position.coords.accuracy; + const bearing = this._map.getBearing(); + const options = performance.extend({ bearing }, this.options.fitBoundsOptions); + const newBounds = LngLatBounds.fromLngLat(center, radius); + this._map.fitBounds(newBounds, options, { + geolocateSource: true // tag this camera change so it won't cause the control to change to background state + }); + }; + /** + * Update the user location dot Marker to the current position + * + * @param position - the Geolocation API Position + */ + this._updateMarker = (position) => { + if (position) { + const center = new performance.LngLat(position.coords.longitude, position.coords.latitude); + this._accuracyCircleMarker.setLngLat(center).addTo(this._map); + this._userLocationDotMarker.setLngLat(center).addTo(this._map); + this._accuracy = position.coords.accuracy; + if (this.options.showUserLocation && this.options.showAccuracyCircle) { + this._updateCircleRadius(); + } + } + else { + this._userLocationDotMarker.remove(); + this._accuracyCircleMarker.remove(); + } + }; + this._onZoom = () => { + if (this.options.showUserLocation && this.options.showAccuracyCircle) { + this._updateCircleRadius(); + } + }; + this._onError = (error) => { + if (!this._map) { + // control has since been removed + return; + } + if (this.options.trackUserLocation) { + if (error.code === 1) { + // PERMISSION_DENIED + this._watchState = 'OFF'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error'); + this._geolocateButton.disabled = true; + const title = this._map._getUIString('GeolocateControl.LocationNotAvailable'); + this._geolocateButton.title = title; + this._geolocateButton.setAttribute('aria-label', title); + if (this._geolocationWatchID !== undefined) { + this._clearWatch(); + } + } + else if (error.code === 3 && noTimeout) { + // this represents a forced error state + // this was triggered to force immediate geolocation when a watch is already present + // see https://github.com/mapbox/mapbox-gl-js/issues/8214 + // and https://w3c.github.io/geolocation-api/#example-5-forcing-the-user-agent-to-return-a-fresh-cached-position + return; + } + else { + this._setErrorState(); + } + } + if (this._watchState !== 'OFF' && this.options.showUserLocation) { + this._dotElement.classList.add('maplibregl-user-location-dot-stale'); + } + this.fire(new performance.Event('error', error)); + this._finish(); + }; + this._finish = () => { + if (this._timeoutId) { + clearTimeout(this._timeoutId); + } + this._timeoutId = undefined; + }; + this._setupUI = (supported) => { + // this method is called asynchronously during onAdd + // the control could have been removed before reaching here + if (!this._map) { + return; + } + this._container.addEventListener('contextmenu', (e) => e.preventDefault()); + this._geolocateButton = DOM.create('button', 'maplibregl-ctrl-geolocate', this._container); + DOM.create('span', 'maplibregl-ctrl-icon', this._geolocateButton).setAttribute('aria-hidden', 'true'); + this._geolocateButton.type = 'button'; + if (supported === false) { + performance.warnOnce('Geolocation support is not available so the GeolocateControl will be disabled.'); + const title = this._map._getUIString('GeolocateControl.LocationNotAvailable'); + this._geolocateButton.disabled = true; + this._geolocateButton.title = title; + this._geolocateButton.setAttribute('aria-label', title); + } + else { + const title = this._map._getUIString('GeolocateControl.FindMyLocation'); + this._geolocateButton.title = title; + this._geolocateButton.setAttribute('aria-label', title); + } + if (this.options.trackUserLocation) { + this._geolocateButton.setAttribute('aria-pressed', 'false'); + this._watchState = 'OFF'; + } + // when showUserLocation is enabled, keep the Geolocate button disabled until the device location marker is setup on the map + if (this.options.showUserLocation) { + this._dotElement = DOM.create('div', 'maplibregl-user-location-dot'); + this._userLocationDotMarker = new Marker({ element: this._dotElement }); + this._circleElement = DOM.create('div', 'maplibregl-user-location-accuracy-circle'); + this._accuracyCircleMarker = new Marker({ element: this._circleElement, pitchAlignment: 'map' }); + if (this.options.trackUserLocation) + this._watchState = 'OFF'; + this._map.on('zoom', this._onZoom); + } + this._geolocateButton.addEventListener('click', this.trigger.bind(this)); + this._setup = true; + // when the camera is changed (and it's not as a result of the Geolocation Control) change + // the watch mode to background watch, so that the marker is updated but not the camera. + if (this.options.trackUserLocation) { + this._map.on('movestart', (event) => { + const fromResize = event.originalEvent && event.originalEvent.type === 'resize'; + if (!event.geolocateSource && this._watchState === 'ACTIVE_LOCK' && !fromResize) { + this._watchState = 'BACKGROUND'; + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this.fire(new performance.Event('trackuserlocationend')); + } + }); + } + }; + this.options = performance.extend({}, defaultOptions$2, options); + } + /** {@inheritDoc IControl.onAdd} */ + onAdd(map) { + this._map = map; + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + checkGeolocationSupport(this._setupUI); + return this._container; + } + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + // clear the geolocation watch if exists + if (this._geolocationWatchID !== undefined) { + window.navigator.geolocation.clearWatch(this._geolocationWatchID); + this._geolocationWatchID = undefined; + } + // clear the markers from the map + if (this.options.showUserLocation && this._userLocationDotMarker) { + this._userLocationDotMarker.remove(); + } + if (this.options.showAccuracyCircle && this._accuracyCircleMarker) { + this._accuracyCircleMarker.remove(); + } + DOM.remove(this._container); + this._map.off('zoom', this._onZoom); + this._map = undefined; + numberOfWatches = 0; + noTimeout = false; + } + /** + * Check if the Geolocation API Position is outside the map's maxbounds. + * + * @param position - the Geolocation API Position + * @returns `true` if position is outside the map's maxbounds, otherwise returns `false`. + */ + _isOutOfMapMaxBounds(position) { + const bounds = this._map.getMaxBounds(); + const coordinates = position.coords; + return bounds && (coordinates.longitude < bounds.getWest() || + coordinates.longitude > bounds.getEast() || + coordinates.latitude < bounds.getSouth() || + coordinates.latitude > bounds.getNorth()); + } + _setErrorState() { + switch (this._watchState) { + case 'WAITING_ACTIVE': + this._watchState = 'ACTIVE_ERROR'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error'); + break; + case 'ACTIVE_LOCK': + this._watchState = 'ACTIVE_ERROR'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + // turn marker grey + break; + case 'BACKGROUND': + this._watchState = 'BACKGROUND_ERROR'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + // turn marker grey + break; + case 'ACTIVE_ERROR': + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + } + _updateCircleRadius() { + const bounds = this._map.getBounds(); + const southEastPoint = bounds.getSouthEast(); + const northEastPoint = bounds.getNorthEast(); + const mapHeightInMeters = southEastPoint.distanceTo(northEastPoint); + const mapHeightInPixels = this._map._container.clientHeight; + const circleDiameter = Math.ceil(2 * (this._accuracy / (mapHeightInMeters / mapHeightInPixels))); + this._circleElement.style.width = `${circleDiameter}px`; + this._circleElement.style.height = `${circleDiameter}px`; + } + /** + * Programmatically request and move the map to the user's location. + * + * @returns `false` if called before control was added to a map, otherwise returns `true`. + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * map.on('load', function() { + * geolocate.trigger(); + * }); + * ``` + */ + trigger() { + if (!this._setup) { + performance.warnOnce('Geolocate control triggered before added to a map'); + return false; + } + if (this.options.trackUserLocation) { + // update watchState and do any outgoing state cleanup + switch (this._watchState) { + case 'OFF': + // turn on the Geolocate Control + this._watchState = 'WAITING_ACTIVE'; + this.fire(new performance.Event('trackuserlocationstart')); + break; + case 'WAITING_ACTIVE': + case 'ACTIVE_LOCK': + case 'ACTIVE_ERROR': + case 'BACKGROUND_ERROR': + // turn off the Geolocate Control + numberOfWatches--; + noTimeout = false; + this._watchState = 'OFF'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error'); + this.fire(new performance.Event('trackuserlocationend')); + break; + case 'BACKGROUND': + this._watchState = 'ACTIVE_LOCK'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + // set camera to last known location + if (this._lastKnownPosition) + this._updateCamera(this._lastKnownPosition); + this.fire(new performance.Event('trackuserlocationstart')); + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + // incoming state setup + switch (this._watchState) { + case 'WAITING_ACTIVE': + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active'); + break; + case 'ACTIVE_LOCK': + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active'); + break; + case 'OFF': + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + // manage geolocation.watchPosition / geolocation.clearWatch + if (this._watchState === 'OFF' && this._geolocationWatchID !== undefined) { + // clear watchPosition as we've changed to an OFF state + this._clearWatch(); + } + else if (this._geolocationWatchID === undefined) { + // enable watchPosition since watchState is not OFF and there is no watchPosition already running + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.setAttribute('aria-pressed', 'true'); + numberOfWatches++; + let positionOptions; + if (numberOfWatches > 1) { + positionOptions = { maximumAge: 600000, timeout: 0 }; + noTimeout = true; + } + else { + positionOptions = this.options.positionOptions; + noTimeout = false; + } + this._geolocationWatchID = window.navigator.geolocation.watchPosition(this._onSuccess, this._onError, positionOptions); + } + } + else { + window.navigator.geolocation.getCurrentPosition(this._onSuccess, this._onError, this.options.positionOptions); + // This timeout ensures that we still call finish() even if + // the user declines to share their location in Firefox + this._timeoutId = setTimeout(this._finish, 10000 /* 10sec */); + } + return true; + } + _clearWatch() { + window.navigator.geolocation.clearWatch(this._geolocationWatchID); + this._geolocationWatchID = undefined; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.setAttribute('aria-pressed', 'false'); + if (this.options.showUserLocation) { + this._updateMarker(null); + } + } +} + +const defaultOptions$1 = { + maxWidth: 100, + unit: 'metric' +}; +/** + * A `ScaleControl` control displays the ratio of a distance on the map to the corresponding distance on the ground. + * + * @group Markers and Controls + * + * @example + * ```ts + * let scale = new maplibregl.ScaleControl({ + * maxWidth: 80, + * unit: 'imperial' + * }); + * map.addControl(scale); + * + * scale.setUnit('metric'); + * ``` + */ +class ScaleControl { + constructor(options) { + this._onMove = () => { + updateScale(this._map, this._container, this.options); + }; + /** + * Set the scale's unit of the distance + * + * @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`). + */ + this.setUnit = (unit) => { + this.options.unit = unit; + updateScale(this._map, this._container, this.options); + }; + this.options = performance.extend({}, defaultOptions$1, options); + } + getDefaultPosition() { + return 'bottom-left'; + } + /** {@inheritDoc IControl.onAdd} */ + onAdd(map) { + this._map = map; + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-scale', map.getContainer()); + this._map.on('move', this._onMove); + this._onMove(); + return this._container; + } + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('move', this._onMove); + this._map = undefined; + } +} +function updateScale(map, container, options) { + // A horizontal scale is imagined to be present at center of the map + // container with maximum length (Default) as 100px. + // Using spherical law of cosines approximation, the real distance is + // found between the two coordinates. + const maxWidth = options && options.maxWidth || 100; + const y = map._container.clientHeight / 2; + const left = map.unproject([0, y]); + const right = map.unproject([maxWidth, y]); + const maxMeters = left.distanceTo(right); + // The real distance corresponding to 100px scale length is rounded off to + // near pretty number and the scale length for the same is found out. + // Default unit of the scale is based on User's locale. + if (options && options.unit === 'imperial') { + const maxFeet = 3.2808 * maxMeters; + if (maxFeet > 5280) { + const maxMiles = maxFeet / 5280; + setScale(container, maxWidth, maxMiles, map._getUIString('ScaleControl.Miles')); + } + else { + setScale(container, maxWidth, maxFeet, map._getUIString('ScaleControl.Feet')); + } + } + else if (options && options.unit === 'nautical') { + const maxNauticals = maxMeters / 1852; + setScale(container, maxWidth, maxNauticals, map._getUIString('ScaleControl.NauticalMiles')); + } + else if (maxMeters >= 1000) { + setScale(container, maxWidth, maxMeters / 1000, map._getUIString('ScaleControl.Kilometers')); + } + else { + setScale(container, maxWidth, maxMeters, map._getUIString('ScaleControl.Meters')); + } +} +function setScale(container, maxWidth, maxDistance, unit) { + const distance = getRoundNum(maxDistance); + const ratio = distance / maxDistance; + container.style.width = `${maxWidth * ratio}px`; + container.innerHTML = `${distance} ${unit}`; +} +function getDecimalRoundNum(d) { + const multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10)); + return Math.round(d * multiplier) / multiplier; +} +function getRoundNum(num) { + const pow10 = Math.pow(10, (`${Math.floor(num)}`).length - 1); + let d = num / pow10; + d = d >= 10 ? 10 : + d >= 5 ? 5 : + d >= 3 ? 3 : + d >= 2 ? 2 : + d >= 1 ? 1 : getDecimalRoundNum(d); + return pow10 * d; +} + +/** + * A `FullscreenControl` control contains a button for toggling the map in and out of fullscreen mode. + * When [requestFullscreen](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen) is not supported, fullscreen is handled via CSS properties. + * The map's `cooperativeGestures` option is temporarily disabled while the map + * is in fullscreen mode, and is restored when the map exist fullscreen mode. + * + * @group Markers and Controls + * @param options - the full screen control options + * + * @example + * ```ts + * map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')})); + * ``` + * @see [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/) + * + * ### Events + * + * @event `fullscreenstart` - Fired when fullscreen mode has started + * + * @event `fullscreenend` - Fired when fullscreen mode has ended + */ +class FullscreenControl extends performance.Evented { + constructor(options = {}) { + super(); + this._onFullscreenChange = () => { + const fullscreenElement = window.document.fullscreenElement || + window.document.mozFullScreenElement || + window.document.webkitFullscreenElement || + window.document.msFullscreenElement; + if ((fullscreenElement === this._container) !== this._fullscreen) { + this._handleFullscreenChange(); + } + }; + this._onClickFullscreen = () => { + if (this._isFullscreen()) { + this._exitFullscreen(); + } + else { + this._requestFullscreen(); + } + }; + this._fullscreen = false; + if (options && options.container) { + if (options.container instanceof HTMLElement) { + this._container = options.container; + } + else { + performance.warnOnce('Full screen control \'container\' must be a DOM element.'); + } + } + if ('onfullscreenchange' in document) { + this._fullscreenchange = 'fullscreenchange'; + } + else if ('onmozfullscreenchange' in document) { + this._fullscreenchange = 'mozfullscreenchange'; + } + else if ('onwebkitfullscreenchange' in document) { + this._fullscreenchange = 'webkitfullscreenchange'; + } + else if ('onmsfullscreenchange' in document) { + this._fullscreenchange = 'MSFullscreenChange'; + } + } + /** {@inheritDoc IControl.onAdd} */ + onAdd(map) { + this._map = map; + if (!this._container) + this._container = this._map.getContainer(); + this._controlContainer = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + this._setupUI(); + return this._controlContainer; + } + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._controlContainer); + this._map = null; + window.document.removeEventListener(this._fullscreenchange, this._onFullscreenChange); + } + _setupUI() { + const button = this._fullscreenButton = DOM.create('button', (('maplibregl-ctrl-fullscreen')), this._controlContainer); + DOM.create('span', 'maplibregl-ctrl-icon', button).setAttribute('aria-hidden', 'true'); + button.type = 'button'; + this._updateTitle(); + this._fullscreenButton.addEventListener('click', this._onClickFullscreen); + window.document.addEventListener(this._fullscreenchange, this._onFullscreenChange); + } + _updateTitle() { + const title = this._getTitle(); + this._fullscreenButton.setAttribute('aria-label', title); + this._fullscreenButton.title = title; + } + _getTitle() { + return this._map._getUIString(this._isFullscreen() ? 'FullscreenControl.Exit' : 'FullscreenControl.Enter'); + } + _isFullscreen() { + return this._fullscreen; + } + _handleFullscreenChange() { + this._fullscreen = !this._fullscreen; + this._fullscreenButton.classList.toggle('maplibregl-ctrl-shrink'); + this._fullscreenButton.classList.toggle('maplibregl-ctrl-fullscreen'); + this._updateTitle(); + if (this._fullscreen) { + this.fire(new performance.Event('fullscreenstart')); + if (this._map._cooperativeGestures) { + this._prevCooperativeGestures = this._map._cooperativeGestures; + this._map.setCooperativeGestures(); + } + } + else { + this.fire(new performance.Event('fullscreenend')); + if (this._prevCooperativeGestures) { + this._map.setCooperativeGestures(this._prevCooperativeGestures); + delete this._prevCooperativeGestures; + } + } + } + _exitFullscreen() { + if (window.document.exitFullscreen) { + window.document.exitFullscreen(); + } + else if (window.document.mozCancelFullScreen) { + window.document.mozCancelFullScreen(); + } + else if (window.document.msExitFullscreen) { + window.document.msExitFullscreen(); + } + else if (window.document.webkitCancelFullScreen) { + window.document.webkitCancelFullScreen(); + } + else { + this._togglePseudoFullScreen(); + } + } + _requestFullscreen() { + if (this._container.requestFullscreen) { + this._container.requestFullscreen(); + } + else if (this._container.mozRequestFullScreen) { + this._container.mozRequestFullScreen(); + } + else if (this._container.msRequestFullscreen) { + this._container.msRequestFullscreen(); + } + else if (this._container.webkitRequestFullscreen) { + this._container.webkitRequestFullscreen(); + } + else { + this._togglePseudoFullScreen(); + } + } + _togglePseudoFullScreen() { + this._container.classList.toggle('maplibregl-pseudo-fullscreen'); + this._handleFullscreenChange(); + this._map.resize(); + } +} + +/** + * A `TerrainControl` control contains a button for turning the terrain on and off. + * + * @group Markers and Controls + * + * @example + * ```ts + * let map = new maplibregl.Map({TerrainControl: false}) + * .addControl(new maplibregl.TerrainControl({ + * source: "terrain" + * })); + * ``` + */ +class TerrainControl { + constructor(options) { + this._toggleTerrain = () => { + if (this._map.getTerrain()) { + this._map.setTerrain(null); + } + else { + this._map.setTerrain(this.options); + } + this._updateTerrainIcon(); + }; + this._updateTerrainIcon = () => { + this._terrainButton.classList.remove('maplibregl-ctrl-terrain'); + this._terrainButton.classList.remove('maplibregl-ctrl-terrain-enabled'); + if (this._map.terrain) { + this._terrainButton.classList.add('maplibregl-ctrl-terrain-enabled'); + this._terrainButton.title = this._map._getUIString('TerrainControl.disableTerrain'); + } + else { + this._terrainButton.classList.add('maplibregl-ctrl-terrain'); + this._terrainButton.title = this._map._getUIString('TerrainControl.enableTerrain'); + } + }; + this.options = options; + } + /** {@inheritDoc IControl.onAdd} */ + onAdd(map) { + this._map = map; + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + this._terrainButton = DOM.create('button', 'maplibregl-ctrl-terrain', this._container); + DOM.create('span', 'maplibregl-ctrl-icon', this._terrainButton).setAttribute('aria-hidden', 'true'); + this._terrainButton.type = 'button'; + this._terrainButton.addEventListener('click', this._toggleTerrain); + this._updateTerrainIcon(); + this._map.on('terrain', this._updateTerrainIcon); + return this._container; + } + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('terrain', this._updateTerrainIcon); + this._map = undefined; + } +} + +const defaultOptions = { + closeButton: true, + closeOnClick: true, + focusAfterOpen: true, + className: '', + maxWidth: '240px' +}; +const focusQuerySelector = [ + 'a[href]', + '[tabindex]:not([tabindex=\'-1\'])', + '[contenteditable]:not([contenteditable=\'false\'])', + 'button:not([disabled])', + 'input:not([disabled])', + 'select:not([disabled])', + 'textarea:not([disabled])', +].join(', '); +/** + * A popup component. + * + * @group Markers and Controls + * + * + * @example + * Create a popup + * ```ts + * let popup = new maplibregl.Popup(); + * // Set an event listener that will fire + * // any time the popup is opened + * popup.on('open', function(){ + * console.log('popup was opened'); + * }); + * ``` + * + * @example + * Create a popup + * ```ts + * let popup = new maplibregl.Popup(); + * // Set an event listener that will fire + * // any time the popup is closed + * popup.on('close', function(){ + * console.log('popup was closed'); + * }); + * ``` + * + * @example + * ```ts + * let markerHeight = 50, markerRadius = 10, linearOffset = 25; + * let popupOffsets = { + * 'top': [0, 0], + * 'top-left': [0,0], + * 'top-right': [0,0], + * 'bottom': [0, -markerHeight], + * 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + * 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + * 'left': [markerRadius, (markerHeight - markerRadius) * -1], + * 'right': [-markerRadius, (markerHeight - markerRadius) * -1] + * }; + * let popup = new maplibregl.Popup({offset: popupOffsets, className: 'my-class'}) + * .setLngLat(e.lngLat) + * .setHTML("

Hello World!

") + * .setMaxWidth("300px") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + * + * ### Events + * + * @event `open` Fired when the popup is opened manually or programmatically. `popup` object that was opened + * + * @event `close` Fired when the popup is closed manually or programmatically. `popup` object that was closed + */ +class Popup extends performance.Evented { + constructor(options) { + super(); + /** + * Removes the popup from the map it has been added to. + * + * @example + * ```ts + * let popup = new maplibregl.Popup().addTo(map); + * popup.remove(); + * ``` + * @returns `this` + */ + this.remove = () => { + if (this._content) { + DOM.remove(this._content); + } + if (this._container) { + DOM.remove(this._container); + delete this._container; + } + if (this._map) { + this._map.off('move', this._update); + this._map.off('move', this._onClose); + this._map.off('click', this._onClose); + this._map.off('remove', this.remove); + this._map.off('mousemove', this._onMouseMove); + this._map.off('mouseup', this._onMouseUp); + this._map.off('drag', this._onDrag); + delete this._map; + } + this.fire(new performance.Event('close')); + return this; + }; + this._onMouseUp = (event) => { + this._update(event.point); + }; + this._onMouseMove = (event) => { + this._update(event.point); + }; + this._onDrag = (event) => { + this._update(event.point); + }; + this._update = (cursor) => { + const hasPosition = this._lngLat || this._trackPointer; + if (!this._map || !hasPosition || !this._content) { + return; + } + if (!this._container) { + this._container = DOM.create('div', 'maplibregl-popup', this._map.getContainer()); + this._tip = DOM.create('div', 'maplibregl-popup-tip', this._container); + this._container.appendChild(this._content); + if (this.options.className) { + for (const name of this.options.className.split(' ')) { + this._container.classList.add(name); + } + } + if (this._trackPointer) { + this._container.classList.add('maplibregl-popup-track-pointer'); + } + } + if (this.options.maxWidth && this._container.style.maxWidth !== this.options.maxWidth) { + this._container.style.maxWidth = this.options.maxWidth; + } + if (this._map.transform.renderWorldCopies && !this._trackPointer) { + this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform); + } + if (this._trackPointer && !cursor) + return; + const pos = this._pos = this._trackPointer && cursor ? cursor : this._map.project(this._lngLat); + let anchor = this.options.anchor; + const offset = normalizeOffset(this.options.offset); + if (!anchor) { + const width = this._container.offsetWidth; + const height = this._container.offsetHeight; + let anchorComponents; + if (pos.y + offset.bottom.y < height) { + anchorComponents = ['top']; + } + else if (pos.y > this._map.transform.height - height) { + anchorComponents = ['bottom']; + } + else { + anchorComponents = []; + } + if (pos.x < width / 2) { + anchorComponents.push('left'); + } + else if (pos.x > this._map.transform.width - width / 2) { + anchorComponents.push('right'); + } + if (anchorComponents.length === 0) { + anchor = 'bottom'; + } + else { + anchor = anchorComponents.join('-'); + } + } + const offsetedPos = pos.add(offset[anchor]).round(); + DOM.setTransform(this._container, `${anchorTranslate[anchor]} translate(${offsetedPos.x}px,${offsetedPos.y}px)`); + applyAnchorClass(this._container, anchor, 'popup'); + }; + this._onClose = () => { + this.remove(); + }; + this.options = performance.extend(Object.create(defaultOptions), options); + } + /** + * Adds the popup to a map. + * + * @param map - The MapLibre GL JS map to add the popup to. + * @returns `this` + * @example + * ```ts + * new maplibregl.Popup() + * .setLngLat([0, 0]) + * .setHTML("

Null Island

") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Show polygon information on click](https://maplibre.org/maplibre-gl-js/docs/examples/polygon-popup-on-click/) + */ + addTo(map) { + if (this._map) + this.remove(); + this._map = map; + if (this.options.closeOnClick) { + this._map.on('click', this._onClose); + } + if (this.options.closeOnMove) { + this._map.on('move', this._onClose); + } + this._map.on('remove', this.remove); + this._update(); + this._focusFirstElement(); + if (this._trackPointer) { + this._map.on('mousemove', this._onMouseMove); + this._map.on('mouseup', this._onMouseUp); + if (this._container) { + this._container.classList.add('maplibregl-popup-track-pointer'); + } + this._map._canvasContainer.classList.add('maplibregl-track-pointer'); + } + else { + this._map.on('move', this._update); + } + this.fire(new performance.Event('open')); + return this; + } + /** + * @returns `true` if the popup is open, `false` if it is closed. + */ + isOpen() { + return !!this._map; + } + /** + * Returns the geographical location of the popup's anchor. + * + * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously + * set by `setLngLat` because `Popup` wraps the anchor longitude across copies of the world to keep + * the popup on screen. + * + * @returns The geographical location of the popup's anchor. + */ + getLngLat() { + return this._lngLat; + } + /** + * Sets the geographical location of the popup's anchor, and moves the popup to it. Replaces trackPointer() behavior. + * + * @param lnglat - The geographical location to set as the popup's anchor. + * @returns `this` + */ + setLngLat(lnglat) { + this._lngLat = performance.LngLat.convert(lnglat); + this._pos = null; + this._trackPointer = false; + this._update(); + if (this._map) { + this._map.on('move', this._update); + this._map.off('mousemove', this._onMouseMove); + if (this._container) { + this._container.classList.remove('maplibregl-popup-track-pointer'); + } + this._map._canvasContainer.classList.remove('maplibregl-track-pointer'); + } + return this; + } + /** + * Tracks the popup anchor to the cursor position on screens with a pointer device (it will be hidden on touchscreens). Replaces the `setLngLat` behavior. + * For most use cases, set `closeOnClick` and `closeButton` to `false`. + * @example + * ```ts + * let popup = new maplibregl.Popup({ closeOnClick: false, closeButton: false }) + * .setHTML("

Hello World!

") + * .trackPointer() + * .addTo(map); + * ``` + * @returns `this` + */ + trackPointer() { + this._trackPointer = true; + this._pos = null; + this._update(); + if (this._map) { + this._map.off('move', this._update); + this._map.on('mousemove', this._onMouseMove); + this._map.on('drag', this._onDrag); + if (this._container) { + this._container.classList.add('maplibregl-popup-track-pointer'); + } + this._map._canvasContainer.classList.add('maplibregl-track-pointer'); + } + return this; + } + /** + * Returns the `Popup`'s HTML element. + * @example + * Change the `Popup` element's font size + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat([-96, 37.8]) + * .setHTML("

Hello World!

") + * .addTo(map); + * let popupElem = popup.getElement(); + * popupElem.style.fontSize = "25px"; + * ``` + * @returns element + */ + getElement() { + return this._container; + } + /** + * Sets the popup's content to a string of text. + * + * This function creates a [Text](https://developer.mozilla.org/en-US/docs/Web/API/Text) node in the DOM, + * so it cannot insert raw HTML. Use this method for security against XSS + * if the popup content is user-provided. + * + * @param text - Textual content for the popup. + * @returns `this` + * @example + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setText('Hello, world!') + * .addTo(map); + * ``` + */ + setText(text) { + return this.setDOMContent(document.createTextNode(text)); + } + /** + * Sets the popup's content to the HTML provided as a string. + * + * This method does not perform HTML filtering or sanitization, and must be + * used only with trusted content. Consider {@link Popup#setText} if + * the content is an untrusted text string. + * + * @param html - A string representing HTML content for the popup. + * @returns `this` + * @example + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setHTML("

Hello World!

") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + */ + setHTML(html) { + const frag = document.createDocumentFragment(); + const temp = document.createElement('body'); + let child; + temp.innerHTML = html; + while (true) { + child = temp.firstChild; + if (!child) + break; + frag.appendChild(child); + } + return this.setDOMContent(frag); + } + /** + * Returns the popup's maximum width. + * + * @returns The maximum width of the popup. + */ + getMaxWidth() { + var _a; + return (_a = this._container) === null || _a === void 0 ? void 0 : _a.style.maxWidth; + } + /** + * Sets the popup's maximum width. This is setting the CSS property `max-width`. + * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width + * + * @param maxWidth - A string representing the value for the maximum width. + * @returns `this` + */ + setMaxWidth(maxWidth) { + this.options.maxWidth = maxWidth; + this._update(); + return this; + } + /** + * Sets the popup's content to the element provided as a DOM node. + * + * @param htmlNode - A DOM node to be used as content for the popup. + * @returns `this` + * @example + * Create an element with the popup content + * ```ts + * let div = document.createElement('div'); + * div.innerHTML = 'Hello, world!'; + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setDOMContent(div) + * .addTo(map); + * ``` + */ + setDOMContent(htmlNode) { + if (this._content) { + // Clear out children first. + while (this._content.hasChildNodes()) { + if (this._content.firstChild) { + this._content.removeChild(this._content.firstChild); + } + } + } + else { + this._content = DOM.create('div', 'maplibregl-popup-content', this._container); + } + // The close button should be the last tabbable element inside the popup for a good keyboard UX. + this._content.appendChild(htmlNode); + this._createCloseButton(); + this._update(); + this._focusFirstElement(); + return this; + } + /** + * Adds a CSS class to the popup container element. + * + * @param className - Non-empty string with CSS class name to add to popup container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.addClassName('some-class') + * ``` + */ + addClassName(className) { + if (this._container) { + this._container.classList.add(className); + } + } + /** + * Removes a CSS class from the popup container element. + * + * @param className - Non-empty string with CSS class name to remove from popup container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.removeClassName('some-class') + * ``` + */ + removeClassName(className) { + if (this._container) { + this._container.classList.remove(className); + } + } + /** + * Sets the popup's offset. + * + * @param offset - Sets the popup's offset. + * @returns `this` + */ + setOffset(offset) { + this.options.offset = offset; + this._update(); + return this; + } + /** + * Add or remove the given CSS class on the popup container, depending on whether the container currently has that class. + * + * @param className - Non-empty string with CSS class name to add/remove + * + * @returns if the class was removed return false, if class was added, then return true, undefined if there is no container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.toggleClassName('toggleClass') + * ``` + */ + toggleClassName(className) { + if (this._container) { + return this._container.classList.toggle(className); + } + } + _createCloseButton() { + if (this.options.closeButton) { + this._closeButton = DOM.create('button', 'maplibregl-popup-close-button', this._content); + this._closeButton.type = 'button'; + this._closeButton.setAttribute('aria-label', 'Close popup'); + this._closeButton.innerHTML = '×'; + this._closeButton.addEventListener('click', this._onClose); + } + } + _focusFirstElement() { + if (!this.options.focusAfterOpen || !this._container) + return; + const firstFocusable = this._container.querySelector(focusQuerySelector); + if (firstFocusable) + firstFocusable.focus(); + } +} +function normalizeOffset(offset) { + if (!offset) { + return normalizeOffset(new performance.Point(0, 0)); + } + else if (typeof offset === 'number') { + // input specifies a radius from which to calculate offsets at all positions + const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2); + return { + 'center': new performance.Point(0, 0), + 'top': new performance.Point(0, offset), + 'top-left': new performance.Point(cornerOffset, cornerOffset), + 'top-right': new performance.Point(-cornerOffset, cornerOffset), + 'bottom': new performance.Point(0, -offset), + 'bottom-left': new performance.Point(cornerOffset, -cornerOffset), + 'bottom-right': new performance.Point(-cornerOffset, -cornerOffset), + 'left': new performance.Point(offset, 0), + 'right': new performance.Point(-offset, 0) + }; + } + else if (offset instanceof performance.Point || Array.isArray(offset)) { + // input specifies a single offset to be applied to all positions + const convertedOffset = performance.Point.convert(offset); + return { + 'center': convertedOffset, + 'top': convertedOffset, + 'top-left': convertedOffset, + 'top-right': convertedOffset, + 'bottom': convertedOffset, + 'bottom-left': convertedOffset, + 'bottom-right': convertedOffset, + 'left': convertedOffset, + 'right': convertedOffset + }; + } + else { + // input specifies an offset per position + return { + 'center': performance.Point.convert(offset['center'] || [0, 0]), + 'top': performance.Point.convert(offset['top'] || [0, 0]), + 'top-left': performance.Point.convert(offset['top-left'] || [0, 0]), + 'top-right': performance.Point.convert(offset['top-right'] || [0, 0]), + 'bottom': performance.Point.convert(offset['bottom'] || [0, 0]), + 'bottom-left': performance.Point.convert(offset['bottom-left'] || [0, 0]), + 'bottom-right': performance.Point.convert(offset['bottom-right'] || [0, 0]), + 'left': performance.Point.convert(offset['left'] || [0, 0]), + 'right': performance.Point.convert(offset['right'] || [0, 0]) + }; + } +} + +/** + * This is a private namespace for utility functions that will get automatically stripped + * out in production builds. + */ +const Debug = { + extend(dest, ...sources) { + return performance.extend(dest, ...sources); + }, + run(fn) { + fn(); + }, + logToElement(message, overwrite = false, id = 'log') { + const el = window.document.getElementById(id); + if (el) { + if (overwrite) + el.innerHTML = ''; + el.innerHTML += `
${message}`; + } + } +}; + +const version = packageJSON.version; +/** + * `maplibregl` is the global object that allows configurations that are not specific to a map instance + * + * @group Main + */ +class MapLibreGL { + /** + * Returns the package version of the library + * @returns Package version of the library + */ + static get version() { + return version; + } + /** + * Gets and sets the number of web workers instantiated on a page with GL JS maps. + * By default, workerCount is 1 except for Safari browser where it is set to half the number of CPU cores (capped at 3). + * Make sure to set this property before creating any map instances for it to have effect. + * + * @returns Number of workers currently configured. + * @example + * ```ts + * maplibregl.workerCount = 2; + * ``` + */ + static get workerCount() { + return WorkerPool.workerCount; + } + static set workerCount(count) { + WorkerPool.workerCount = count; + } + /** + * Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel, + * which affects performance in raster-heavy maps. 16 by default. + * + * @returns Number of parallel requests currently configured. + * @example + * ```ts + * maplibregl.maxParallelImageRequests = 10; + * ``` + */ + static get maxParallelImageRequests() { + return performance.config.MAX_PARALLEL_IMAGE_REQUESTS; + } + static set maxParallelImageRequests(numRequests) { + performance.config.MAX_PARALLEL_IMAGE_REQUESTS = numRequests; + } + static get workerUrl() { + return performance.config.WORKER_URL; + } + static set workerUrl(value) { + performance.config.WORKER_URL = value; + } + /** + * Sets a custom load tile function that will be called when using a source that starts with a custom url schema. + * The example below will be triggered for custom:// urls defined in the sources list in the style definitions. + * The function passed will receive the request parameters and should call the callback with the resulting request, + * for example a pbf vector tile, non-compressed, represented as ArrayBuffer. + * + * @param customProtocol - the protocol to hook, for example 'custom' + * @param loadFn - the function to use when trying to fetch a tile specified by the customProtocol + * @example + * This will fetch a file using the fetch API (this is obviously a non interesting example...) + * ```ts + * maplibregl.addProtocol('custom', (params, callback) => { + fetch(`https://${params.url.split("://")[1]}`) + .then(t => { + if (t.status == 200) { + t.arrayBuffer().then(arr => { + callback(null, arr, null, null); + }); + } else { + callback(new Error(`Tile fetch error: ${t.statusText}`)); + } + }) + .catch(e => { + callback(new Error(e)); + }); + return { cancel: () => { } }; + }); + * // the following is an example of a way to return an error when trying to load a tile + * maplibregl.addProtocol('custom2', (params, callback) => { + * callback(new Error('someErrorMessage')); + * return { cancel: () => { } }; + * }); + * ``` + */ + static addProtocol(customProtocol, loadFn) { + performance.config.REGISTERED_PROTOCOLS[customProtocol] = loadFn; + } + /** + * Removes a previously added protocol + * + * @param customProtocol - the custom protocol to remove registration for + * @example + * ```ts + * maplibregl.removeProtocol('custom'); + * ``` + */ + static removeProtocol(customProtocol) { + delete performance.config.REGISTERED_PROTOCOLS[customProtocol]; + } +} +MapLibreGL.Map = Map$1; +MapLibreGL.NavigationControl = NavigationControl; +MapLibreGL.GeolocateControl = GeolocateControl; +MapLibreGL.AttributionControl = AttributionControl; +MapLibreGL.LogoControl = LogoControl; +MapLibreGL.ScaleControl = ScaleControl; +MapLibreGL.FullscreenControl = FullscreenControl; +MapLibreGL.TerrainControl = TerrainControl; +MapLibreGL.Popup = Popup; +MapLibreGL.Marker = Marker; +MapLibreGL.Style = Style; +MapLibreGL.LngLat = performance.LngLat; +MapLibreGL.LngLatBounds = LngLatBounds; +MapLibreGL.Point = performance.Point; +MapLibreGL.MercatorCoordinate = performance.MercatorCoordinate; +MapLibreGL.Evented = performance.Evented; +MapLibreGL.AJAXError = performance.AJAXError; +MapLibreGL.config = performance.config; +MapLibreGL.CanvasSource = CanvasSource; +MapLibreGL.GeoJSONSource = GeoJSONSource; +MapLibreGL.ImageSource = ImageSource; +MapLibreGL.RasterDEMTileSource = RasterDEMTileSource; +MapLibreGL.RasterTileSource = RasterTileSource; +MapLibreGL.VectorTileSource = VectorTileSource; +MapLibreGL.VideoSource = VideoSource; +/** + * Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text). + * Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. + * + * @param pluginURL - URL pointing to the Mapbox RTL text plugin source. + * @param callback - Called with an error argument if there is an error. + * @param lazy - If set to `true`, mapboxgl will defer loading the plugin until rtl text is encountered, + * rtl text will then be rendered only after the plugin finishes loading. + * @example + * ```ts + * maplibregl.setRTLTextPlugin('https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.js'); + * ``` + * @see [Add support for right-to-left scripts](https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/) + */ +MapLibreGL.setRTLTextPlugin = performance.setRTLTextPlugin; +/** + * Gets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) status. + * The status can be `unavailable` (i.e. not requested or removed), `loading`, `loaded` or `error`. + * If the status is `loaded` and the plugin is requested again, an error will be thrown. + * + * @example + * ```ts + * const pluginStatus = maplibregl.getRTLTextPluginStatus(); + * ``` + */ +MapLibreGL.getRTLTextPluginStatus = performance.getRTLTextPluginStatus; +/** + * Initializes resources like WebWorkers that can be shared across maps to lower load + * times in some situations. `maplibregl.workerUrl` and `maplibregl.workerCount`, if being + * used, must be set before `prewarm()` is called to have an effect. + * + * By default, the lifecycle of these resources is managed automatically, and they are + * lazily initialized when a Map is first created. By invoking `prewarm()`, these + * resources will be created ahead of time, and will not be cleared when the last Map + * is removed from the page. This allows them to be re-used by new Map instances that + * are created later. They can be manually cleared by calling + * `maplibregl.clearPrewarmedResources()`. This is only necessary if your web page remains + * active but stops using maps altogether. + * + * This is primarily useful when using GL-JS maps in a single page app, wherein a user + * would navigate between various views that can cause Map instances to constantly be + * created and destroyed. + * + * @example + * ```ts + * maplibregl.prewarm() + * ``` + */ +MapLibreGL.prewarm = prewarm; +/** + * Clears up resources that have previously been created by `maplibregl.prewarm()`. + * Note that this is typically not necessary. You should only call this function + * if you expect the user of your app to not return to a Map view at any point + * in your application. + * + * @example + * ```ts + * maplibregl.clearPrewarmedResources() + * ``` + */ +MapLibreGL.clearPrewarmedResources = clearPrewarmedResources; +//This gets automatically stripped out in production builds. +Debug.extend(MapLibreGL, { isSafari: performance.isSafari, getPerformanceMetrics: performance.PerformanceUtils.getPerformanceMetrics }); + +return MapLibreGL; + +})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl-dev.js.map diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl-dev.js.map b/web/libraries/maplibre-gl/dist/maplibre-gl-dev.js.map new file mode 100644 index 00000000..7145d8c9 --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl-dev.js.map @@ -0,0 +1 @@ +{"version":3,"file":"maplibre-gl-dev.js","sources":["../node_modules/tslib/tslib.es6.js","../node_modules/@mapbox/point-geometry/index.js","../node_modules/@mapbox/unitbezier/index.js","../src/util/offscreen_canvas_supported.ts","../src/util/offscreen_canvas_distorted.ts","../src/util/util.ts","../src/util/browser.ts","../src/util/config.ts","../src/util/ajax.ts","../src/util/evented.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.mjs","../src/style/validate_style.ts","../src/util/transferable_grid_index.ts","../src/util/web_worker_transfer.ts","../src/style/zoom_history.ts","../src/util/is_char_in_unicode_block.ts","../src/util/script_detection.ts","../src/source/rtl_text_plugin.ts","../src/style/evaluation_parameters.ts","../src/style/properties.ts","../src/style/style_layer.ts","../src/util/struct_array.ts","../src/data/array_types.g.ts","../src/data/bucket/circle_attributes.ts","../src/data/segment.ts","../src/shaders/encode_attribute.ts","../src/data/bucket/pattern_attributes.ts","../node_modules/murmurhash-js/murmurhash3_gc.js","../node_modules/murmurhash-js/murmurhash2_gc.js","../node_modules/murmurhash-js/index.js","../src/data/feature_position_map.ts","../src/render/uniform_binding.ts","../src/data/program_configuration.ts","../src/data/extent.ts","../src/data/load_geometry.ts","../src/data/evaluation_feature.ts","../src/data/bucket/circle_bucket.ts","../src/util/intersection_tests.ts","../src/style/query_utils.ts","../src/style/style_layer/circle_style_layer_properties.g.ts","../node_modules/gl-matrix/esm/common.js","../node_modules/gl-matrix/esm/mat2.js","../node_modules/gl-matrix/esm/mat2d.js","../node_modules/gl-matrix/esm/mat3.js","../node_modules/gl-matrix/esm/mat4.js","../node_modules/gl-matrix/esm/vec3.js","../node_modules/gl-matrix/esm/vec4.js","../node_modules/gl-matrix/esm/quat.js","../node_modules/gl-matrix/esm/quat2.js","../node_modules/gl-matrix/esm/vec2.js","../src/style/style_layer/circle_style_layer.ts","../src/data/bucket/heatmap_bucket.ts","../src/style/style_layer/heatmap_style_layer_properties.g.ts","../src/util/image.ts","../src/util/color_ramp.ts","../src/style/style_layer/heatmap_style_layer.ts","../src/style/style_layer/hillshade_style_layer_properties.g.ts","../src/style/style_layer/hillshade_style_layer.ts","../src/data/bucket/fill_attributes.ts","../node_modules/earcut/src/earcut.js","../node_modules/quickselect/index.js","../src/util/classify_rings.ts","../src/data/bucket/pattern_bucket_features.ts","../src/data/bucket/fill_bucket.ts","../src/style/style_layer/fill_style_layer_properties.g.ts","../src/style/style_layer/fill_style_layer.ts","../src/data/bucket/fill_extrusion_attributes.ts","../node_modules/@mapbox/vector-tile/lib/vectortilefeature.js","../node_modules/@mapbox/vector-tile/lib/vectortilelayer.js","../node_modules/@mapbox/vector-tile/lib/vectortile.js","../node_modules/@mapbox/vector-tile/index.js","../src/data/bucket/fill_extrusion_bucket.ts","../src/style/style_layer/fill_extrusion_style_layer_properties.g.ts","../src/style/style_layer/fill_extrusion_style_layer.ts","../src/data/bucket/line_attributes.ts","../src/data/bucket/line_attributes_ext.ts","../src/data/bucket/line_bucket.ts","../src/style/style_layer/line_style_layer_properties.g.ts","../src/style/style_layer/line_style_layer.ts","../src/data/bucket/symbol_attributes.ts","../src/symbol/transform_text.ts","../src/symbol/merge_lines.ts","../src/util/verticalize_punctuation.ts","../src/symbol/one_em.ts","../node_modules/ieee754/index.js","../node_modules/pbf/index.js","../src/style/parse_glyph_pbf.ts","../node_modules/potpack/index.js","../src/render/image_atlas.ts","../src/symbol/shaping.ts","../src/symbol/symbol_size.ts","../src/style/style_layer/overlap_mode.ts","../src/data/bucket/symbol_bucket.ts","../src/util/resolve_tokens.ts","../src/style/style_layer/symbol_style_layer_properties.g.ts","../src/style/format_section_override.ts","../src/style/style_layer/symbol_style_layer.ts","../src/style/style_layer/background_style_layer_properties.g.ts","../src/style/style_layer/background_style_layer.ts","../src/style/style_layer/raster_style_layer_properties.g.ts","../src/style/style_layer/raster_style_layer.ts","../src/style/style_layer/custom_style_layer.ts","../src/style/create_style_layer.ts","../src/util/throttled_invoker.ts","../src/util/actor.ts","../src/geo/lng_lat.ts","../src/geo/mercator_coordinate.ts","../node_modules/@mapbox/whoots-js/index.mjs","../src/source/tile_id.ts","../src/data/dem_data.ts","../src/util/dictionary_coder.ts","../src/util/vectortile_to_geojson.ts","../src/data/feature_index.ts","../src/symbol/clip_line.ts","../src/symbol/anchor.ts","../src/symbol/check_max_angle.ts","../src/symbol/get_anchors.ts","../src/symbol/quads.ts","../src/symbol/collision_feature.ts","../node_modules/tinyqueue/index.js","../src/util/find_pole_of_inaccessibility.ts","../src/style/style_layer/variable_text_anchor.ts","../src/symbol/symbol_layout.ts","../node_modules/kdbush/index.js","../src/util/performance.ts","../src/style/style_layer_index.ts","../src/render/glyph_atlas.ts","../src/source/worker_tile.ts","../src/source/vector_tile_worker_source.ts","../src/source/raster_dem_tile_worker_source.ts","../node_modules/@mapbox/geojson-rewind/index.js","../src/source/geojson_wrapper.ts","../node_modules/vt-pbf/lib/geojson_wrapper.js","../node_modules/vt-pbf/index.js","../node_modules/supercluster/index.js","../node_modules/geojson-vt/src/simplify.js","../node_modules/geojson-vt/src/feature.js","../node_modules/geojson-vt/src/convert.js","../node_modules/geojson-vt/src/clip.js","../node_modules/geojson-vt/src/wrap.js","../node_modules/geojson-vt/src/transform.js","../node_modules/geojson-vt/src/tile.js","../node_modules/geojson-vt/src/index.js","../src/source/geojson_source_diff.ts","../src/source/geojson_worker_source.ts","../src/source/worker.ts","../src/util/dom.ts","../src/util/webp_supported.ts","../src/util/image_request.ts","../src/util/request_manager.ts","../src/util/style.ts","../src/style/load_sprite.ts","../src/render/texture.ts","../src/style/style_image.ts","../src/render/image_manager.ts","../src/style/load_glyph_range.ts","../node_modules/@mapbox/tiny-sdf/index.js","../src/render/glyph_manager.ts","../src/style/light.ts","../src/render/line_atlas.ts","../src/util/dispatcher.ts","../src/source/load_tilejson.ts","../src/geo/lng_lat_bounds.ts","../src/source/tile_bounds.ts","../src/source/vector_tile_source.ts","../src/source/raster_tile_source.ts","../src/source/raster_dem_tile_source.ts","../src/source/geojson_source.ts","../src/data/raster_bounds_attributes.ts","../src/source/image_source.ts","../src/source/video_source.ts","../src/source/canvas_source.ts","../src/source/source.ts","../src/source/query_features.ts","../src/data/bucket.ts","../src/source/tile.ts","../src/source/tile_cache.ts","../src/source/source_state.ts","../src/source/source_cache.ts","../src/util/web_worker.ts","../src/util/worker_pool.ts","../src/util/global_worker_pool.ts","../src/symbol/path_interpolator.ts","../src/symbol/grid_index.ts","../src/symbol/projection.ts","../src/symbol/collision_index.ts","../src/source/pixels_to_tile_units.ts","../src/symbol/placement.ts","../src/style/pauseable_placement.ts","../src/symbol/cross_tile_symbol_index.ts","../src/style/style.ts","../src/data/pos_attributes.ts","../src/shaders/_prelude.fragment.glsl.g.ts","../src/shaders/_prelude.vertex.glsl.g.ts","../src/shaders/background.fragment.glsl.g.ts","../src/shaders/background.vertex.glsl.g.ts","../src/shaders/background_pattern.fragment.glsl.g.ts","../src/shaders/background_pattern.vertex.glsl.g.ts","../src/shaders/circle.fragment.glsl.g.ts","../src/shaders/circle.vertex.glsl.g.ts","../src/shaders/clipping_mask.fragment.glsl.g.ts","../src/shaders/clipping_mask.vertex.glsl.g.ts","../src/shaders/heatmap.fragment.glsl.g.ts","../src/shaders/heatmap.vertex.glsl.g.ts","../src/shaders/heatmap_texture.fragment.glsl.g.ts","../src/shaders/heatmap_texture.vertex.glsl.g.ts","../src/shaders/collision_box.fragment.glsl.g.ts","../src/shaders/collision_box.vertex.glsl.g.ts","../src/shaders/collision_circle.fragment.glsl.g.ts","../src/shaders/collision_circle.vertex.glsl.g.ts","../src/shaders/debug.fragment.glsl.g.ts","../src/shaders/debug.vertex.glsl.g.ts","../src/shaders/fill.fragment.glsl.g.ts","../src/shaders/fill.vertex.glsl.g.ts","../src/shaders/fill_outline.fragment.glsl.g.ts","../src/shaders/fill_outline.vertex.glsl.g.ts","../src/shaders/fill_outline_pattern.fragment.glsl.g.ts","../src/shaders/fill_outline_pattern.vertex.glsl.g.ts","../src/shaders/fill_pattern.fragment.glsl.g.ts","../src/shaders/fill_pattern.vertex.glsl.g.ts","../src/shaders/fill_extrusion.fragment.glsl.g.ts","../src/shaders/fill_extrusion.vertex.glsl.g.ts","../src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts","../src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts","../src/shaders/hillshade_prepare.fragment.glsl.g.ts","../src/shaders/hillshade_prepare.vertex.glsl.g.ts","../src/shaders/hillshade.fragment.glsl.g.ts","../src/shaders/hillshade.vertex.glsl.g.ts","../src/shaders/line.fragment.glsl.g.ts","../src/shaders/line.vertex.glsl.g.ts","../src/shaders/line_gradient.fragment.glsl.g.ts","../src/shaders/line_gradient.vertex.glsl.g.ts","../src/shaders/line_pattern.fragment.glsl.g.ts","../src/shaders/line_pattern.vertex.glsl.g.ts","../src/shaders/line_sdf.fragment.glsl.g.ts","../src/shaders/line_sdf.vertex.glsl.g.ts","../src/shaders/raster.fragment.glsl.g.ts","../src/shaders/raster.vertex.glsl.g.ts","../src/shaders/symbol_icon.fragment.glsl.g.ts","../src/shaders/symbol_icon.vertex.glsl.g.ts","../src/shaders/symbol_sdf.fragment.glsl.g.ts","../src/shaders/symbol_sdf.vertex.glsl.g.ts","../src/shaders/symbol_text_and_icon.fragment.glsl.g.ts","../src/shaders/symbol_text_and_icon.vertex.glsl.g.ts","../src/shaders/terrain_depth.fragment.glsl.g.ts","../src/shaders/terrain_coords.fragment.glsl.g.ts","../src/shaders/terrain.fragment.glsl.g.ts","../src/shaders/terrain.vertex.glsl.g.ts","../src/shaders/shaders.ts","../src/render/vertex_array_object.ts","../src/render/program/terrain_program.ts","../src/render/program.ts","../src/render/program/pattern.ts","../src/render/program/fill_extrusion_program.ts","../src/render/program/fill_program.ts","../src/render/program/circle_program.ts","../src/render/program/collision_program.ts","../src/render/program/debug_program.ts","../src/render/program/clipping_mask_program.ts","../src/render/program/heatmap_program.ts","../src/render/program/hillshade_program.ts","../src/render/program/line_program.ts","../src/render/program/raster_program.ts","../src/render/program/symbol_program.ts","../src/render/program/background_program.ts","../src/render/program/program_uniforms.ts","../src/gl/index_buffer.ts","../src/gl/vertex_buffer.ts","../src/gl/webgl2.ts","../src/gl/value.ts","../src/gl/framebuffer.ts","../src/gl/color_mode.ts","../src/gl/context.ts","../src/gl/depth_mode.ts","../src/gl/stencil_mode.ts","../src/gl/cull_face_mode.ts","../src/render/draw_collision_debug.ts","../src/render/draw_symbol.ts","../src/render/draw_circle.ts","../src/render/draw_heatmap.ts","../src/render/draw_line.ts","../src/render/update_pattern_positions_in_program.ts","../src/render/draw_fill.ts","../src/render/draw_fill_extrusion.ts","../src/render/draw_hillshade.ts","../src/render/draw_raster.ts","../src/render/draw_background.ts","../src/render/draw_debug.ts","../src/render/draw_custom.ts","../src/render/draw_terrain.ts","../src/render/painter.ts","../src/util/primitives.ts","../src/geo/edge_insets.ts","../src/geo/transform.ts","../src/util/throttle.ts","../src/ui/hash.ts","../src/ui/handler_inertia.ts","../src/ui/events.ts","../src/ui/handler/map_event.ts","../src/ui/handler/transform-provider.ts","../src/ui/handler/box_zoom.ts","../src/ui/handler/handler_util.ts","../src/ui/handler/tap_recognizer.ts","../src/ui/handler/tap_zoom.ts","../src/ui/handler/drag_handler.ts","../src/ui/handler/drag_move_state_manager.ts","../src/ui/handler/mouse.ts","../src/ui/handler/touch_pan.ts","../src/ui/handler/two_fingers_touch.ts","../src/ui/handler/keyboard.ts","../src/ui/handler/scroll_zoom.ts","../src/ui/handler/shim/dblclick_zoom.ts","../src/ui/handler/click_zoom.ts","../src/ui/handler/tap_drag_zoom.ts","../src/ui/handler/shim/drag_pan.ts","../src/ui/handler/shim/drag_rotate.ts","../src/ui/handler/shim/two_fingers_touch.ts","../src/ui/handler_manager.ts","../src/ui/camera.ts","../src/ui/control/attribution_control.ts","../src/ui/control/logo_control.ts","../src/util/task_queue.ts","../src/ui/default_locale.ts","../src/data/pos3d_attributes.ts","../src/source/terrain_source_cache.ts","../src/render/terrain.ts","../src/gl/render_pool.ts","../src/render/render_to_texture.ts","../src/ui/map.ts","../src/ui/handler/one_finger_touch_drag.ts","../src/ui/control/navigation_control.ts","../src/util/geolocation_support.ts","../src/util/smart_wrap.ts","../src/ui/anchor.ts","../src/ui/marker.ts","../src/ui/control/geolocate_control.ts","../src/ui/control/scale_control.ts","../src/ui/control/fullscreen_control.ts","../src/ui/control/terrain_control.ts","../src/ui/popup.ts","../src/util/debug.ts","../src/index.ts","../build/rollup/maplibregl.js"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","'use strict';\n\nmodule.exports = Point;\n\n/**\n * A standalone point geometry with useful accessor, comparison, and\n * modification methods.\n *\n * @class Point\n * @param {Number} x the x-coordinate. this could be longitude or screen\n * pixels, or any other sort of unit.\n * @param {Number} y the y-coordinate. this could be latitude or screen\n * pixels, or any other sort of unit.\n * @example\n * var point = new Point(-77, 38);\n */\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n}\n\nPoint.prototype = {\n\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone: function() { return new Point(this.x, this.y); },\n\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add: function(p) { return this.clone()._add(p); },\n\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub: function(p) { return this.clone()._sub(p); },\n\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint: function(p) { return this.clone()._multByPoint(p); },\n\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint: function(p) { return this.clone()._divByPoint(p); },\n\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n mult: function(k) { return this.clone()._mult(k); },\n\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n div: function(k) { return this.clone()._div(k); },\n\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate: function(a) { return this.clone()._rotate(a); },\n\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); },\n\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {Array} m transformation matrix\n * @return {Point} output point\n */\n matMult: function(m) { return this.clone()._matMult(m); },\n\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit: function() { return this.clone()._unit(); },\n\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp: function() { return this.clone()._perp(); },\n\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round: function() { return this.clone()._round(); },\n\n /**\n * Return the magitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {Number} magnitude\n */\n mag: function() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals: function(other) {\n return this.x === other.x &&\n this.y === other.y;\n },\n\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {Number} distance\n */\n dist: function(p) {\n return Math.sqrt(this.distSqr(p));\n },\n\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {Number} distance\n */\n distSqr: function(p) {\n var dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {Number} angle\n */\n angle: function() {\n return Math.atan2(this.y, this.x);\n },\n\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleTo: function(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleWith: function(b) {\n return this.angleWithSep(b.x, b.y);\n },\n\n /*\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(θ) for θ.\n * @param {Number} x the x-coordinate\n * @param {Number} y the y-coordinate\n * @return {Number} the angle in radians\n */\n angleWithSep: function(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y);\n },\n\n _matMult: function(m) {\n var x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _add: function(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n\n _sub: function(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n\n _mult: function(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n\n _div: function(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n\n _multByPoint: function(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n\n _divByPoint: function(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n\n _unit: function() {\n this._div(this.mag());\n return this;\n },\n\n _perp: function() {\n var y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n\n _rotate: function(angle) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _rotateAround: function(angle, p) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n\n _round: function() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n }\n};\n\n/**\n * Construct a point from an array if necessary, otherwise if the input\n * is already a Point, or an unknown type, return it unchanged\n * @param {Array|Point|*} a any kind of input value\n * @return {Point} constructed point, or passed-through value.\n * @example\n * // this\n * var point = Point.convert([0, 1]);\n * // is equivalent to\n * var point = new Point(0, 1);\n */\nPoint.convert = function (a) {\n if (a instanceof Point) {\n return a;\n }\n if (Array.isArray(a)) {\n return new Point(a[0], a[1]);\n }\n return a;\n};\n","'use strict';\n\nmodule.exports = UnitBezier;\n\nfunction UnitBezier(p1x, p1y, p2x, p2y) {\n // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n this.cx = 3.0 * p1x;\n this.bx = 3.0 * (p2x - p1x) - this.cx;\n this.ax = 1.0 - this.cx - this.bx;\n\n this.cy = 3.0 * p1y;\n this.by = 3.0 * (p2y - p1y) - this.cy;\n this.ay = 1.0 - this.cy - this.by;\n\n this.p1x = p1x;\n this.p1y = p1y;\n this.p2x = p2x;\n this.p2y = p2y;\n}\n\nUnitBezier.prototype = {\n sampleCurveX: function (t) {\n // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n return ((this.ax * t + this.bx) * t + this.cx) * t;\n },\n\n sampleCurveY: function (t) {\n return ((this.ay * t + this.by) * t + this.cy) * t;\n },\n\n sampleCurveDerivativeX: function (t) {\n return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n },\n\n solveCurveX: function (x, epsilon) {\n if (epsilon === undefined) epsilon = 1e-6;\n\n if (x < 0.0) return 0.0;\n if (x > 1.0) return 1.0;\n\n var t = x;\n\n // First try a few iterations of Newton's method - normally very fast.\n for (var i = 0; i < 8; i++) {\n var x2 = this.sampleCurveX(t) - x;\n if (Math.abs(x2) < epsilon) return t;\n\n var d2 = this.sampleCurveDerivativeX(t);\n if (Math.abs(d2) < 1e-6) break;\n\n t = t - x2 / d2;\n }\n\n // Fall back to the bisection method for reliability.\n var t0 = 0.0;\n var t1 = 1.0;\n t = x;\n\n for (i = 0; i < 20; i++) {\n x2 = this.sampleCurveX(t);\n if (Math.abs(x2 - x) < epsilon) break;\n\n if (x > x2) {\n t0 = t;\n } else {\n t1 = t;\n }\n\n t = (t1 - t0) * 0.5 + t0;\n }\n\n return t;\n },\n\n solve: function (x, epsilon) {\n return this.sampleCurveY(this.solveCurveX(x, epsilon));\n }\n};\n","let supportsOffscreenCanvas: boolean;\n\nexport function offscreenCanvasSupported(): boolean {\n if (supportsOffscreenCanvas == null) {\n supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&\n new OffscreenCanvas(1, 1).getContext('2d') &&\n typeof createImageBitmap === 'function';\n }\n\n return supportsOffscreenCanvas;\n}\n","import {offscreenCanvasSupported} from './offscreen_canvas_supported';\n\nlet offscreenCanvasDistorted: boolean;\n\n/**\n * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185).\n * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false\n * if they don't match.\n *\n * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise.\n */\nexport function isOffscreenCanvasDistorted(): boolean {\n if (offscreenCanvasDistorted == null) {\n offscreenCanvasDistorted = false;\n if (offscreenCanvasSupported()) {\n const size = 5;\n const canvas = new OffscreenCanvas(size, size);\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (context) {\n // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel):\n // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...]\n for (let i = 0; i < size * size; i++) {\n const base = i * 4;\n context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;\n context.fillRect(i % size, Math.floor(i / size), 1, 1);\n }\n const data = context.getImageData(0, 0, size, size).data;\n for (let i = 0; i < size * size * 4; i++) {\n if (i % 4 !== 3 && data[i] !== i) {\n offscreenCanvasDistorted = true;\n break;\n }\n }\n }\n }\n }\n\n return offscreenCanvasDistorted || false;\n}\n","import Point from '@mapbox/point-geometry';\nimport UnitBezier from '@mapbox/unitbezier';\nimport type {Callback} from '../types/callback';\nimport {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted';\nimport type {Size} from './image';\n\n/**\n * Given a value `t` that varies between 0 and 1, return\n * an interpolation function that eases between 0 and 1 in a pleasing\n * cubic in-out fashion.\n */\nexport function easeCubicInOut(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n const t2 = t * t,\n t3 = t2 * t;\n return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75);\n}\n\n/**\n * Given given (x, y), (x1, y1) control points for a bezier curve,\n * return a function that interpolates along that curve.\n *\n * @param p1x - control point 1 x coordinate\n * @param p1y - control point 1 y coordinate\n * @param p2x - control point 2 x coordinate\n * @param p2y - control point 2 y coordinate\n */\nexport function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {\n const bezier = new UnitBezier(p1x, p1y, p2x, p2y);\n return function(t: number) {\n return bezier.solve(t);\n };\n}\n\n/**\n * A default bezier-curve powered easing function with\n * control points (0.25, 0.1) and (0.25, 1)\n */\nexport const defaultEasing = bezier(0.25, 0.1, 0.25, 1);\n\n/**\n * constrain n to the given range via min + max\n *\n * @param n - value\n * @param min - the minimum value to be returned\n * @param max - the maximum value to be returned\n * @returns the clamped value\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/**\n * constrain n to the given range, excluding the minimum, via modular arithmetic\n *\n * @param n - value\n * @param min - the minimum value to be returned, exclusive\n * @param max - the maximum value to be returned, inclusive\n * @returns constrained number\n */\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((n - min) % d + d) % d + min;\n return (w === min) ? max : w;\n}\n\n/**\n * Call an asynchronous function on an array of arguments,\n * calling `callback` with the completed results of all calls.\n *\n * @param array - input to each call of the async function.\n * @param fn - an async function with signature (data, callback)\n * @param callback - a callback run after all async work is done.\n * called with an array, containing the results of each async call.\n */\nexport function asyncAll(\n array: Array,\n fn: (item: Item, fnCallback: Callback) => void,\n callback: Callback>\n) {\n if (!array.length) { return callback(null, []); }\n let remaining = array.length;\n const results = new Array(array.length);\n let error = null;\n array.forEach((item, i) => {\n fn(item, (err, result) => {\n if (err) error = err;\n results[i] = (result as any as Result); // https://github.com/facebook/flow/issues/2123\n if (--remaining === 0) callback(error, results);\n });\n });\n}\n\n/**\n * Compute the difference between the keys in one object and the keys\n * in another object.\n *\n * @returns keys difference\n */\nexport function keysDifference(\n obj: {[key: string]: S},\n other: {[key: string]: T}\n): Array {\n const difference = [];\n for (const i in obj) {\n if (!(i in other)) {\n difference.push(i);\n }\n }\n return difference;\n}\n\n/**\n * Given a destination object and optionally many source objects,\n * copy all properties from the source objects into the destination.\n * The last source object given overrides properties from previous\n * source objects.\n *\n * @param dest - destination object\n * @param sources - sources from which properties are pulled\n */\nexport function extend(dest: any, ...sources: Array): any {\n for (const src of sources) {\n for (const k in src) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n/**\n * Given an object and a number of properties as strings, return version\n * of that object with only those properties.\n *\n * @param src - the object\n * @param properties - an array of property names chosen\n * to appear on the resulting object.\n * @returns object with limited properties.\n * @example\n * ```ts\n * let foo = { name: 'Charlie', age: 10 };\n * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' }\n * ```\n */\nexport function pick(src: any, properties: Array): any {\n const result = {};\n for (let i = 0; i < properties.length; i++) {\n const k = properties[i];\n if (k in src) {\n result[k] = src[k];\n }\n }\n return result;\n}\n\nlet id = 1;\n\n/**\n * Return a unique numeric id, starting at 1 and incrementing with\n * each call.\n *\n * @returns unique numeric id.\n */\nexport function uniqueId(): number {\n return id++;\n}\n\n/**\n * Return whether a given value is a power of two\n */\nexport function isPowerOfTwo(value: number): boolean {\n return (Math.log(value) / Math.LN2) % 1 === 0;\n}\n\n/**\n * Return the next power of two, or the input value if already a power of two\n */\nexport function nextPowerOfTwo(value: number): number {\n if (value <= 1) return 1;\n return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/**\n * Create an object by mapping all the values of an existing object while\n * preserving their keys.\n */\nexport function mapObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n output[key] = iterator.call(context || this, input[key], key, input);\n }\n return output;\n}\n\n/**\n * Create an object by filtering out values of an existing object.\n */\nexport function filterObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n if (iterator.call(context || this, input[key], key, input)) {\n output[key] = input[key];\n }\n }\n return output;\n}\n\n/**\n * Deeply compares two object literals.\n * @param a - first object literal to be compared\n * @param b - second object literal to be compared\n * @returns true if the two object literals are deeply equal, false otherwise\n */\nexport function deepEqual(a?: unknown | null, b?: unknown | null): boolean {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object')) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key])) return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * Deeply clones two objects.\n */\nexport function clone(input: T): T {\n if (Array.isArray(input)) {\n return input.map(clone) as any as T;\n } else if (typeof input === 'object' && input) {\n return mapObject(input, clone) as any as T;\n } else {\n return input;\n }\n}\n\n/**\n * Check if two arrays have at least one common element.\n */\nexport function arraysIntersect(a: Array, b: Array): boolean {\n for (let l = 0; l < a.length; l++) {\n if (b.indexOf(a[l]) >= 0) return true;\n }\n return false;\n}\n\n/**\n * Print a warning message to the console and ensure duplicate warning messages\n * are not printed.\n */\nconst warnOnceHistory: {[key: string]: boolean} = {};\n\nexport function warnOnce(message: string): void {\n if (!warnOnceHistory[message]) {\n // console isn't defined in some WebWorkers, see #2558\n if (typeof console !== 'undefined') console.warn(message);\n warnOnceHistory[message] = true;\n }\n}\n\n/**\n * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order\n *\n * @returns true for a counter clockwise set of points\n */\n// http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/\nexport function isCounterClockwise(a: Point, b: Point, c: Point): boolean {\n return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x);\n}\n\n/**\n * For two lines a and b in 2d space, defined by any two points along the lines,\n * find the intersection point, or return null if the lines are parallel\n *\n * @param a1 - First point on line a\n * @param a2 - Second point on line a\n * @param b1 - First point on line b\n * @param b2 - Second point on line b\n *\n * @returns the intersection point of the two lines or null if they are parallel\n */\nexport function findLineIntersection(a1: Point, a2: Point, b1: Point, b2: Point): Point | null {\n const aDeltaY = a2.y - a1.y;\n const aDeltaX = a2.x - a1.x;\n const bDeltaY = b2.y - b1.y;\n const bDeltaX = b2.x - b1.x;\n\n const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY);\n\n if (denominator === 0) {\n // Lines are parallel\n return null;\n }\n\n const originDeltaY = a1.y - b1.y;\n const originDeltaX = a1.x - b1.x;\n const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator;\n\n // Find intersection by projecting out from origin of first segment\n return new Point(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY));\n}\n\n/**\n * Returns the signed area for the polygon ring. Positive areas are exterior rings and\n * have a clockwise winding. Negative areas are interior rings and have a counter clockwise\n * ordering.\n *\n * @param ring - Exterior or interior ring\n */\nexport function calculateSignedArea(ring: Array): number {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\n/**\n * Detects closed polygons, first + last point are equal\n *\n * @param points - array of points\n * @returns `true` if the points are a closed polygon\n */\nexport function isClosedPolygon(points: Array): boolean {\n // If it is 2 points that are the same then it is a point\n // If it is 3 points with start and end the same then it is a line\n if (points.length < 4)\n return false;\n\n const p1 = points[0];\n const p2 = points[points.length - 1];\n\n if (Math.abs(p1.x - p2.x) > 0 ||\n Math.abs(p1.y - p2.y) > 0) {\n return false;\n }\n\n // polygon simplification can produce polygons with zero area and more than 3 points\n return Math.abs(calculateSignedArea(points)) > 0.01;\n}\n\n/**\n * Converts spherical coordinates to cartesian coordinates.\n *\n * @param spherical - Spherical coordinates, in [radial, azimuthal, polar]\n * @returns cartesian coordinates in [x, y, z]\n */\n\nexport function sphericalToCartesian([r, azimuthal, polar]: [number, number, number]): {\n x: number;\n y: number;\n z: number;\n} {\n // We abstract \"north\"/\"up\" (compass-wise) to be 0° when really this is 90° (π/2):\n // correct for that here\n azimuthal += 90;\n\n // Convert azimuthal and polar angles to radians\n azimuthal *= Math.PI / 180;\n polar *= Math.PI / 180;\n\n return {\n x: r * Math.cos(azimuthal) * Math.sin(polar),\n y: r * Math.sin(azimuthal) * Math.sin(polar),\n z: r * Math.cos(polar)\n };\n}\n\n/**\n * Returns true if the when run in the web-worker context.\n *\n * @returns `true` if the when run in the web-worker context.\n */\nexport function isWorker(): boolean {\n // @ts-ignore\n return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;\n}\n\n/**\n * Parses data from 'Cache-Control' headers.\n *\n * @param cacheControl - Value of 'Cache-Control' header\n * @returns object containing parsed header info.\n */\n\nexport function parseCacheControl(cacheControl: string): any {\n // Taken from [Wreck](https://github.com/hapijs/wreck)\n const re = /(?:^|(?:\\s*\\,\\s*))([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)(?:\\=(?:([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)|(?:\\\"((?:[^\"\\\\]|\\\\.)*)\\\")))?/g;\n\n const header = {};\n cacheControl.replace(re, ($0, $1, $2, $3) => {\n const value = $2 || $3;\n header[$1] = value ? value.toLowerCase() : true;\n return '';\n });\n\n if (header['max-age']) {\n const maxAge = parseInt(header['max-age'], 10);\n if (isNaN(maxAge)) delete header['max-age'];\n else header['max-age'] = maxAge;\n }\n\n return header;\n}\n\nlet _isSafari = null;\n\n/**\n * Returns true when run in WebKit derived browsers.\n * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to\n * transfer data between WebWorkers and the main thread.\n * https://github.com/mapbox/mapbox-gl-js/issues/8771\n *\n * This should be removed once the underlying Safari issue is fixed.\n *\n * @param scope - Since this function is used both on the main thread and WebWorker context,\n * let the calling scope pass in the global scope object.\n * @returns `true` when run in WebKit derived browsers.\n */\nexport function isSafari(scope: any): boolean {\n if (_isSafari == null) {\n const userAgent = scope.navigator ? scope.navigator.userAgent : null;\n _isSafari = !!scope.safari ||\n !!(userAgent && (/\\b(iPad|iPhone|iPod)\\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome'))));\n }\n return _isSafari;\n}\n\nexport function storageAvailable(type: string): boolean {\n try {\n const storage = window[type];\n storage.setItem('_mapbox_test_', 1);\n storage.removeItem('_mapbox_test_');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n//Unicode compliant base64 encoder for strings\nexport function b64EncodeUnicode(str: string) {\n return btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,\n (match, p1) => {\n return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line\n }\n )\n );\n}\n\n// Unicode compliant decoder for base64-encoded strings\nexport function b64DecodeUnicode(str: string) {\n return decodeURIComponent(atob(str).split('').map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line\n }).join(''));\n}\n\nexport function isImageBitmap(image: any): image is ImageBitmap {\n return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;\n}\n\n/**\n * Converts an ArrayBuffer to an ImageBitmap.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image bitmap (when no error) as the second\n */\nexport function arrayBufferToImageBitmap(data: ArrayBuffer, callback: (err?: Error | null, image?: ImageBitmap | null) => void) {\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n createImageBitmap(blob).then((imgBitmap) => {\n callback(null, imgBitmap);\n }).catch((e) => {\n callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));\n });\n}\n\nconst transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';\n\n/**\n * Converts an ArrayBuffer to an HTMLImageElement.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image element (when no error) as the second\n */\nexport function arrayBufferToImage(data: ArrayBuffer, callback: (err?: Error | null, image?: HTMLImageElement | null) => void) {\n const img: HTMLImageElement = new Image();\n img.onload = () => {\n callback(null, img);\n URL.revokeObjectURL(img.src);\n // prevent image dataURI memory leak in Safari;\n // but don't free the image immediately because it might be uploaded in the next frame\n // https://github.com/mapbox/mapbox-gl-js/issues/10226\n img.onload = null;\n window.requestAnimationFrame(() => { img.src = transparentPngUrl; });\n };\n img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;\n}\n\n/**\n * Computes the webcodecs VideoFrame API options to select a rectangle out of\n * an image and write it into the destination rectangle.\n *\n * Rect (x/y/width/height) select the overlapping rectangle from the source image\n * and layout (offset/stride) write that overlapping rectangle to the correct place\n * in the destination image.\n *\n * Offset is the byte offset in the dest image that the first pixel appears at\n * and stride is the number of bytes to the start of the next row:\n * ┌───────────┐\n * │ dest │\n * │ ┌───┼───────┐\n * │offset→│▓▓▓│ source│\n * │ │▓▓▓│ │\n * │ └───┼───────┘\n * │stride ⇠╌╌╌│\n * │╌╌╌╌╌╌→ │\n * └───────────┘\n *\n * @param image - source image containing a width and height attribute\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns the layout and rect options to pass into VideoFrame API\n */\nfunction computeVideoFrameParameters(image: Size, x: number, y: number, width: number, height: number): VideoFrameCopyToOptions {\n const destRowOffset = Math.max(-x, 0) * 4;\n const firstSourceRow = Math.max(0, y);\n const firstDestRow = firstSourceRow - y;\n const offset = firstDestRow * width * 4 + destRowOffset;\n const stride = width * 4;\n\n const sourceLeft = Math.max(0, x);\n const sourceTop = Math.max(0, y);\n const sourceRight = Math.min(image.width, x + width);\n const sourceBottom = Math.min(image.height, y + height);\n return {\n rect: {\n x: sourceLeft,\n y: sourceTop,\n width: sourceRight - sourceLeft,\n height: sourceBottom - sourceTop\n },\n layout: [{offset, stride}]\n };\n}\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport async function readImageUsingVideoFrame(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (typeof VideoFrame === 'undefined') {\n throw new Error('VideoFrame not supported');\n }\n const frame = new VideoFrame(image, {timestamp: 0});\n try {\n const format = frame?.format;\n if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {\n throw new Error(`Unrecognized format ${format}`);\n }\n const swapBR = format.startsWith('BGR');\n const result = new Uint8ClampedArray(width * height * 4);\n await frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));\n if (swapBR) {\n for (let i = 0; i < result.length; i += 4) {\n const tmp = result[i];\n result[i] = result[i + 2];\n result[i + 2] = tmp;\n }\n }\n return result;\n } finally {\n frame.close();\n }\n}\n\nlet offscreenCanvas: OffscreenCanvas;\nlet offscreenCanvasContext: OffscreenCanvasRenderingContext2D;\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport function readImageDataUsingOffscreenCanvas(\n imgBitmap: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Uint8ClampedArray {\n const origWidth = imgBitmap.width;\n const origHeight = imgBitmap.height;\n // Lazily initialize OffscreenCanvas\n if (!offscreenCanvas || !offscreenCanvasContext) {\n // Dem tiles are typically 256x256\n offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);\n offscreenCanvasContext = offscreenCanvas.getContext('2d', {willReadFrequently: true});\n }\n\n offscreenCanvas.width = origWidth;\n offscreenCanvas.height = origHeight;\n\n offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);\n const imgData = offscreenCanvasContext.getImageData(x, y, width, height);\n offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);\n return imgData.data;\n}\n\n/**\n * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and\n * the browser is mangling OffscreenCanvas getImageData results.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image\n */\nexport async function getImageData(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (isOffscreenCanvasDistorted()) {\n try {\n return await readImageUsingVideoFrame(image, x, y, width, height);\n } catch (e) {\n // fall back to OffscreenCanvas\n }\n }\n return readImageDataUsingOffscreenCanvas(image, x, y, width, height);\n}\n","import type {Cancelable} from '../types/cancelable';\n\nconst now = typeof performance !== 'undefined' && performance && performance.now ?\n performance.now.bind(performance) :\n Date.now.bind(Date);\n\nlet linkEl;\n\nlet reducedMotionQuery: MediaQueryList;\n\n/** */\nexport const browser = {\n /**\n * Provides a function that outputs milliseconds: either performance.now()\n * or a fallback to Date.now()\n */\n now,\n\n frame(fn: (paintStartTimestamp: number) => void): Cancelable {\n const frame = requestAnimationFrame(fn);\n return {cancel: () => cancelAnimationFrame(frame)};\n },\n\n getImageData(img: HTMLImageElement | ImageBitmap, padding: number = 0): ImageData {\n const context = this.getImageCanvasContext(img);\n return context.getImageData(-padding, -padding, img.width as number + 2 * padding, img.height as number + 2 * padding);\n },\n\n getImageCanvasContext(img: HTMLImageElement | ImageBitmap): CanvasRenderingContext2D {\n const canvas = window.document.createElement('canvas') as HTMLCanvasElement;\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (!context) {\n throw new Error('failed to create canvas 2d context');\n }\n canvas.width = img.width as number;\n canvas.height = img.height as number;\n context.drawImage(img, 0, 0, img.width as number, img.height as number);\n return context;\n },\n\n resolveURL(path: string) {\n if (!linkEl) linkEl = document.createElement('a');\n linkEl.href = path;\n return linkEl.href;\n },\n\n hardwareConcurrency: typeof navigator !== 'undefined' && navigator.hardwareConcurrency || 4,\n\n get prefersReducedMotion(): boolean {\n // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util'\n if (!matchMedia) return false;\n //Lazily initialize media query\n if (reducedMotionQuery == null) {\n reducedMotionQuery = matchMedia('(prefers-reduced-motion: reduce)');\n }\n return reducedMotionQuery.matches;\n },\n};\n","import type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from './ajax';\n\n/**\n * This is a global config object used to store the configuration\n * It is available in the workers as well.\n * Only serializable data should be stored in it.\n */\ntype Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: number;\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number;\n MAX_TILE_CACHE_ZOOM_LEVELS: number;\n REGISTERED_PROTOCOLS: {[x: string]: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable};\n WORKER_URL: string;\n};\n\nexport const config: Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: 16,\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8,\n MAX_TILE_CACHE_ZOOM_LEVELS: 5,\n REGISTERED_PROTOCOLS: {},\n WORKER_URL: ''\n};\n","import {extend, warnOnce, isWorker} from './util';\nimport {config} from './config';\n\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\n/**\n * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks.\n * @example\n * ```ts\n * // use transformRequest to modify requests that begin with `http://myHost`\n * transformRequest: function(url, resourceType) {\n * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true },\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * ```\n */\nexport type RequestParameters = {\n /**\n * The URL to be requested.\n */\n url: string;\n /**\n * The headers to be sent with the request.\n */\n headers?: any;\n /**\n * Request method `'GET' | 'POST' | 'PUT'`.\n */\n method?: 'GET' | 'POST' | 'PUT';\n /**\n * Request body.\n */\n body?: string;\n /**\n * Response body type to be returned `'string' | 'json' | 'arrayBuffer'`.\n */\n type?: 'string' | 'json' | 'arrayBuffer' | 'image';\n /**\n * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests.\n */\n credentials?: 'same-origin' | 'include';\n /**\n * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events.\n */\n collectResourceTiming?: boolean;\n /**\n * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)\n */\n cache?: RequestCache;\n};\n\n/**\n * The response callback used in various places\n */\nexport type ResponseCallback = (\n error?: Error | null,\n data?: T | null,\n cacheControl?: string | null,\n expires?: string | null\n) => void;\n\n/**\n * An error thrown when a HTTP request results in an error response.\n */\nexport class AJAXError extends Error {\n /**\n * The response's HTTP status code.\n */\n status: number;\n\n /**\n * The response's HTTP status text.\n */\n statusText: string;\n\n /**\n * The request's URL.\n */\n url: string;\n\n /**\n * The response's body.\n */\n body: Blob;\n\n /**\n * @param status - The response's HTTP status code.\n * @param statusText - The response's HTTP status text.\n * @param url - The request's URL.\n * @param body - The response's body.\n */\n constructor(status: number, statusText: string, url: string, body: Blob) {\n super(`AJAXError: ${statusText} (${status}): ${url}`);\n this.status = status;\n this.statusText = statusText;\n this.url = url;\n this.body = body;\n }\n}\n\n// Ensure that we're sending the correct referrer from blob URL worker bundles.\n// For files loaded from the local file system, `location.origin` will be set\n// to the string(!) \"null\" (Firefox), or \"file://\" (Chrome, Safari, Edge, IE),\n// and we will set an empty referrer. Otherwise, we're using the document's URL.\n/* global self */\nexport const getReferrer = isWorker() ?\n () => (self as any).worker && (self as any).worker.referrer :\n () => (window.location.protocol === 'blob:' ? window.parent : window).location.href;\n\nexport const getProtocolAction = url => config.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))];\n\n// Determines whether a URL is a file:// URL. This is obviously the case if it begins\n// with file://. Relative URLs are also file:// URLs iff the original document was loaded\n// via a file:// URL.\nconst isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\\w+:/.test(url));\n\nfunction makeFetchRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const controller = new AbortController();\n const request = new Request(requestParameters.url, {\n method: requestParameters.method || 'GET',\n body: requestParameters.body,\n credentials: requestParameters.credentials,\n headers: requestParameters.headers,\n cache: requestParameters.cache,\n referrer: getReferrer(),\n signal: controller.signal\n });\n let complete = false;\n let aborted = false;\n\n if (requestParameters.type === 'json') {\n request.headers.set('Accept', 'application/json');\n }\n\n const validateOrFetch = (err, cachedResponse?, responseIsFresh?) => {\n if (aborted) return;\n\n if (err) {\n // Do fetch in case of cache error.\n // HTTP pages in Edge trigger a security error that can be ignored.\n if (err.message !== 'SecurityError') {\n warnOnce(err);\n }\n }\n\n if (cachedResponse && responseIsFresh) {\n return finishRequest(cachedResponse);\n }\n\n if (cachedResponse) {\n // We can't do revalidation with 'If-None-Match' because then the\n // request doesn't have simple cors headers.\n }\n\n fetch(request).then(response => {\n if (response.ok) {\n return finishRequest(response);\n\n } else {\n return response.blob().then(body => callback(new AJAXError(response.status, response.statusText, requestParameters.url, body)));\n }\n }).catch(error => {\n if (error.code === 20) {\n // silence expected AbortError\n return;\n }\n callback(new Error(error.message));\n });\n };\n\n const finishRequest = (response) => {\n (\n (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') ? response.arrayBuffer() :\n requestParameters.type === 'json' ? response.json() :\n response.text()\n ).then(result => {\n if (aborted) return;\n complete = true;\n callback(null, result, response.headers.get('Cache-Control'), response.headers.get('Expires'));\n }).catch(err => {\n if (!aborted) callback(new Error(err.message));\n });\n };\n\n validateOrFetch(null, null);\n\n return {cancel: () => {\n aborted = true;\n if (!complete) controller.abort();\n }};\n}\n\nfunction makeXMLHttpRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const xhr: XMLHttpRequest = new XMLHttpRequest();\n\n xhr.open(requestParameters.method || 'GET', requestParameters.url, true);\n if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') {\n xhr.responseType = 'arraybuffer';\n }\n for (const k in requestParameters.headers) {\n xhr.setRequestHeader(k, requestParameters.headers[k]);\n }\n if (requestParameters.type === 'json') {\n xhr.responseType = 'text';\n xhr.setRequestHeader('Accept', 'application/json');\n }\n xhr.withCredentials = requestParameters.credentials === 'include';\n xhr.onerror = () => {\n callback(new Error(xhr.statusText));\n };\n xhr.onload = () => {\n if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) {\n let data: unknown = xhr.response;\n if (requestParameters.type === 'json') {\n // We're manually parsing JSON here to get better error messages.\n try {\n data = JSON.parse(xhr.response);\n } catch (err) {\n return callback(err);\n }\n }\n callback(null, data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires'));\n } else {\n const body = new Blob([xhr.response], {type: xhr.getResponseHeader('Content-Type')});\n callback(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body));\n }\n };\n xhr.send(requestParameters.body);\n return {cancel: () => xhr.abort()};\n}\n\nexport const makeRequest = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n // We're trying to use the Fetch API if possible. However, in some situations we can't use it:\n // - IE11 doesn't support it at all. In this case, we dispatch the request to the main thread so\n // that we can get an accruate referrer header.\n // - Safari exposes window.AbortController, but it doesn't work actually abort any requests in\n // some versions (see https://bugs.webkit.org/show_bug.cgi?id=174980#c2)\n // - Requests for resources with the file:// URI scheme don't work with the Fetch API either. In\n // this case we unconditionally use XHR on the current thread since referrers don't matter.\n if (/:\\/\\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) {\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n return (self as any).worker.actor.send('getResource', requestParameters, callback);\n }\n if (!isWorker()) {\n const action = getProtocolAction(requestParameters.url) || makeFetchRequest;\n return action(requestParameters, callback);\n }\n }\n if (!isFileURL(requestParameters.url)) {\n if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) {\n return makeFetchRequest(requestParameters, callback);\n }\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n const queueOnMainThread = true;\n return (self as any).worker.actor.send('getResource', requestParameters, callback, undefined, queueOnMainThread);\n }\n }\n return makeXMLHttpRequest(requestParameters, callback);\n};\n\nexport const getJSON = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'json'}), callback);\n};\n\nexport const getArrayBuffer = function(\n requestParameters: RequestParameters,\n callback: ResponseCallback\n): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), callback);\n};\n\nexport const postData = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {method: 'POST'}), callback);\n};\n\nexport function sameOrigin(inComingUrl: string) {\n // URL class should be available everywhere\n // https://developer.mozilla.org/en-US/docs/Web/API/URL\n // In addtion, a relative URL \"/foo\" or \"./foo\" will throw exception in its ctor,\n // try-catch is expansive so just use a heuristic check to avoid it\n // also check data URL\n if (!inComingUrl ||\n inComingUrl.indexOf('://') <= 0 || // relative URL\n inComingUrl.indexOf('data:image/') === 0 || // data image URL\n inComingUrl.indexOf('blob:') === 0) { // blob\n return true;\n }\n const urlObj = new URL(inComingUrl);\n const locationObj = window.location;\n return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host;\n}\n/**\n * A type used to store the tile's expiration date and cache control definition\n */\nexport type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null};\nexport const getVideo = function(urls: Array, callback: Callback): Cancelable {\n const video: HTMLVideoElement = window.document.createElement('video');\n video.muted = true;\n video.onloadstart = function() {\n callback(null, video);\n };\n for (let i = 0; i < urls.length; i++) {\n const s: HTMLSourceElement = window.document.createElement('source');\n if (!sameOrigin(urls[i])) {\n video.crossOrigin = 'Anonymous';\n }\n s.src = urls[i];\n video.appendChild(s);\n }\n return {cancel: () => {}};\n};\n","import {extend} from './util';\n\n/**\n * A listener method used as a callback to events\n */\nexport type Listener = (a: any) => any;\n\ntype Listeners = {[_: string]: Array};\n\nfunction _addEventListener(type: string, listener: Listener, listenerList: Listeners) {\n const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;\n if (!listenerExists) {\n listenerList[type] = listenerList[type] || [];\n listenerList[type].push(listener);\n }\n}\n\nfunction _removeEventListener(type: string, listener: Listener, listenerList: Listeners) {\n if (listenerList && listenerList[type]) {\n const index = listenerList[type].indexOf(listener);\n if (index !== -1) {\n listenerList[type].splice(index, 1);\n }\n }\n}\n\n/**\n * The event class\n */\nexport class Event {\n readonly type: string;\n\n constructor(type: string, data: any = {}) {\n extend(this, data);\n this.type = type;\n }\n}\n\ninterface ErrorLike {\n message: string;\n}\n\n/**\n * An error event\n */\nexport class ErrorEvent extends Event {\n error: ErrorLike;\n\n constructor(error: ErrorLike, data: any = {}) {\n super('error', extend({error}, data));\n }\n}\n\n/**\n * Methods mixed in to other classes for event capabilities.\n *\n * @group Event Related\n */\nexport class Evented {\n _listeners: Listeners;\n _oneTimeListeners: Listeners;\n _eventedParent: Evented;\n _eventedParentData: any | (() => any);\n\n /**\n * Adds a listener to a specified event type.\n *\n * @param type - The event type to add a listen for.\n * @param listener - The function to be called when the event is fired.\n * The listener function is called with the data object passed to `fire`,\n * extended with `target` and `type` properties.\n * @returns `this`\n */\n on(type: string, listener: Listener): this {\n this._listeners = this._listeners || {};\n _addEventListener(type, listener, this._listeners);\n\n return this;\n }\n\n /**\n * Removes a previously registered event listener.\n *\n * @param type - The event type to remove listeners for.\n * @param listener - The listener function to remove.\n * @returns `this`\n */\n off(type: string, listener: Listener) {\n _removeEventListener(type, listener, this._listeners);\n _removeEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type.\n *\n * The listener will be called first time the event fires after the listener is registered.\n *\n * @param type - The event type to listen for.\n * @param listener - The function to be called when the event is fired the first time.\n * @returns `this` or a promise if a listener is not provided\n */\n once(type: string, listener?: Listener): this | Promise {\n if (!listener) {\n return new Promise((resolve) => this.once(type, resolve));\n }\n this._oneTimeListeners = this._oneTimeListeners || {};\n _addEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n fire(event: Event | string, properties?: any) {\n // Compatibility with (type: string, properties: Object) signature from previous versions.\n // See https://github.com/mapbox/mapbox-gl-js/issues/6522,\n // https://github.com/mapbox/mapbox-gl-draw/issues/766\n if (typeof event === 'string') {\n event = new Event(event, properties || {});\n }\n\n const type = event.type;\n\n if (this.listens(type)) {\n (event as any).target = this;\n\n // make sure adding or removing listeners inside other listeners won't cause an infinite loop\n const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];\n for (const listener of listeners) {\n listener.call(this, event);\n }\n\n const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];\n for (const listener of oneTimeListeners) {\n _removeEventListener(type, listener, this._oneTimeListeners);\n listener.call(this, event);\n }\n\n const parent = this._eventedParent;\n if (parent) {\n extend(\n event,\n typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData\n );\n parent.fire(event);\n }\n\n // To ensure that no error events are dropped, print them to the\n // console if they have no listeners.\n } else if (event instanceof ErrorEvent) {\n console.error(event.error);\n }\n\n return this;\n }\n\n /**\n * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.\n *\n * @param type - The event type\n * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise\n */\n listens(type: string): boolean {\n return (\n (this._listeners && this._listeners[type] && this._listeners[type].length > 0) ||\n (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) ||\n (this._eventedParent && this._eventedParent.listens(type))\n );\n }\n\n /**\n * Bubble all events fired by this instance of Evented to this parent instance of Evented.\n * @returns `this`\n */\n setEventedParent(parent?: Evented | null, data?: any | (() => any)) {\n this._eventedParent = parent;\n this._eventedParentData = data;\n\n return this;\n }\n}\n","import UnitBezier from '@mapbox/unitbezier';\n\nvar $version = 8;\nvar $root = {\n\tversion: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: [\n\t\t\t8\n\t\t]\n\t},\n\tname: {\n\t\ttype: \"string\"\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tcenter: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\"\n\t},\n\tzoom: {\n\t\ttype: \"number\"\n\t},\n\tbearing: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\"\n\t},\n\tpitch: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"degrees\"\n\t},\n\tlight: {\n\t\ttype: \"light\"\n\t},\n\tterrain: {\n\t\ttype: \"terrain\"\n\t},\n\tsources: {\n\t\trequired: true,\n\t\ttype: \"sources\"\n\t},\n\tsprite: {\n\t\ttype: \"sprite\"\n\t},\n\tglyphs: {\n\t\ttype: \"string\"\n\t},\n\ttransition: {\n\t\ttype: \"transition\"\n\t},\n\tlayers: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"layer\"\n\t}\n};\nvar sources = {\n\t\"*\": {\n\t\ttype: \"source\"\n\t}\n};\nvar source = [\n\t\"source_vector\",\n\t\"source_raster\",\n\t\"source_raster_dem\",\n\t\"source_geojson\",\n\t\"source_video\",\n\t\"source_image\"\n];\nvar source_vector = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvector: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\traster: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster_dem = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\t\"raster-dem\": {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tencoding: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tterrarium: {\n\t\t\t},\n\t\t\tmapbox: {\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"mapbox\"\n\t},\n\tredFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tblueFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tgreenFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tbaseShift: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_geojson = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tgeojson: {\n\t\t\t}\n\t\t}\n\t},\n\tdata: {\n\t\trequired: true,\n\t\ttype: \"*\"\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 18\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tbuffer: {\n\t\ttype: \"number\",\n\t\t\"default\": 128,\n\t\tmaximum: 512,\n\t\tminimum: 0\n\t},\n\tfilter: {\n\t\ttype: \"*\"\n\t},\n\ttolerance: {\n\t\ttype: \"number\",\n\t\t\"default\": 0.375\n\t},\n\tcluster: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tclusterRadius: {\n\t\ttype: \"number\",\n\t\t\"default\": 50,\n\t\tminimum: 0\n\t},\n\tclusterMaxZoom: {\n\t\ttype: \"number\"\n\t},\n\tclusterMinPoints: {\n\t\ttype: \"number\"\n\t},\n\tclusterProperties: {\n\t\ttype: \"*\"\n\t},\n\tlineMetrics: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tgenerateId: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t}\n};\nvar source_video = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvideo: {\n\t\t\t}\n\t\t}\n\t},\n\turls: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar source_image = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\timage: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\trequired: true,\n\t\ttype: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar layer = {\n\tid: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tfill: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\tsymbol: {\n\t\t\t},\n\t\t\tcircle: {\n\t\t\t},\n\t\t\theatmap: {\n\t\t\t},\n\t\t\t\"fill-extrusion\": {\n\t\t\t},\n\t\t\traster: {\n\t\t\t},\n\t\t\thillshade: {\n\t\t\t},\n\t\t\tbackground: {\n\t\t\t}\n\t\t},\n\t\trequired: true\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tsource: {\n\t\ttype: \"string\"\n\t},\n\t\"source-layer\": {\n\t\ttype: \"string\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tfilter: {\n\t\ttype: \"filter\"\n\t},\n\tlayout: {\n\t\ttype: \"layout\"\n\t},\n\tpaint: {\n\t\ttype: \"paint\"\n\t}\n};\nvar layout = [\n\t\"layout_fill\",\n\t\"layout_line\",\n\t\"layout_circle\",\n\t\"layout_heatmap\",\n\t\"layout_fill-extrusion\",\n\t\"layout_symbol\",\n\t\"layout_raster\",\n\t\"layout_hillshade\",\n\t\"layout_background\"\n];\nvar layout_background = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_fill = {\n\t\"fill-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_circle = {\n\t\"circle-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_heatmap = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_line = {\n\t\"line-cap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbutt: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tsquare: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"butt\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-join\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbevel: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tmiter: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"miter\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-miter-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"miter\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-round-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.05,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"round\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_symbol = {\n\t\"symbol-placement\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tpoint: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\t\"line-center\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"point\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 250,\n\t\tminimum: 1,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"symbol-placement\": \"line\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-avoid-edges\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"symbol-z-order\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\t\"viewport-y\": {\n\t\t\t},\n\t\t\tsource: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"!\": \"icon-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tunits: \"factor of the original icon size\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-text-fit\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\twidth: {\n\t\t\t},\n\t\t\theight: {\n\t\t\t},\n\t\t\tboth: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-text-fit-padding\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"icon-text-fit\": [\n\t\t\t\t\t\"both\",\n\t\t\t\t\t\"width\",\n\t\t\t\t\t\"height\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-image\": {\n\t\ttype: \"resolvedImage\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-padding\": {\n\t\ttype: \"padding\",\n\t\t\"default\": [\n\t\t\t2\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"icon-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\t\"viewport-glyph\": {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-field\": {\n\t\ttype: \"formatted\",\n\t\t\"default\": \"\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-font\": {\n\t\ttype: \"array\",\n\t\tvalue: \"string\",\n\t\t\"default\": [\n\t\t\t\"Open Sans Regular\",\n\t\t\t\"Arial Unicode MS Regular\"\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 16,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 10,\n\t\tminimum: 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-line-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.2,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-letter-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-justify\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-radial-offset\": {\n\t\ttype: \"number\",\n\t\tunits: \"ems\",\n\t\t\"default\": 0,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\t\"property-type\": \"data-driven\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t}\n\t},\n\t\"text-variable-anchor\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-variable-anchor-offset\": {\n\t\ttype: \"variableAnchorOffsetCollection\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-variable-anchor\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-angle\": {\n\t\ttype: \"number\",\n\t\t\"default\": 45,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-writing-mode\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\thorizontal: {\n\t\t\t},\n\t\t\tvertical: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-padding\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"text-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-transform\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\tuppercase: {\n\t\t\t},\n\t\t\tlowercase: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tunits: \"ems\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-radial-offset\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_raster = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_hillshade = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar filter = {\n\ttype: \"array\",\n\tvalue: \"*\"\n};\nvar filter_operator = {\n\ttype: \"enum\",\n\tvalues: {\n\t\t\"==\": {\n\t\t},\n\t\t\"!=\": {\n\t\t},\n\t\t\">\": {\n\t\t},\n\t\t\">=\": {\n\t\t},\n\t\t\"<\": {\n\t\t},\n\t\t\"<=\": {\n\t\t},\n\t\t\"in\": {\n\t\t},\n\t\t\"!in\": {\n\t\t},\n\t\tall: {\n\t\t},\n\t\tany: {\n\t\t},\n\t\tnone: {\n\t\t},\n\t\thas: {\n\t\t},\n\t\t\"!has\": {\n\t\t},\n\t\twithin: {\n\t\t}\n\t}\n};\nvar geometry_type = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tPoint: {\n\t\t},\n\t\tLineString: {\n\t\t},\n\t\tPolygon: {\n\t\t}\n\t}\n};\nvar function_stop = {\n\ttype: \"array\",\n\tminimum: 0,\n\tmaximum: 24,\n\tvalue: [\n\t\t\"number\",\n\t\t\"color\"\n\t],\n\tlength: 2\n};\nvar expression$1 = {\n\ttype: \"array\",\n\tvalue: \"*\",\n\tminimum: 1\n};\nvar light = {\n\tanchor: {\n\t\ttype: \"enum\",\n\t\t\"default\": \"viewport\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tposition: {\n\t\ttype: \"array\",\n\t\t\"default\": [\n\t\t\t1.15,\n\t\t\t210,\n\t\t\t30\n\t\t],\n\t\tlength: 3,\n\t\tvalue: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tcolor: {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\tintensity: {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar terrain = {\n\tsource: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\texaggeration: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\t\"default\": 1\n\t}\n};\nvar paint = [\n\t\"paint_fill\",\n\t\"paint_line\",\n\t\"paint_circle\",\n\t\"paint_heatmap\",\n\t\"paint_fill-extrusion\",\n\t\"paint_symbol\",\n\t\"paint_raster\",\n\t\"paint_hillshade\",\n\t\"paint_background\"\n];\nvar paint_fill = {\n\t\"fill-antialias\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-outline-color\": {\n\t\ttype: \"color\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fill-antialias\": true\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t}\n};\nvar paint_line = {\n\t\"line-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"line-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-gap-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-offset\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-dasharray\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"line widths\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"line-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-gradient\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-dasharray\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"geojson\",\n\t\t\t\thas: {\n\t\t\t\t\tlineMetrics: true\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"line-progress\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n};\nvar paint_circle = {\n\t\"circle-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 5,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"circle-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-scale\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-stroke-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t}\n};\nvar paint_heatmap = {\n\t\"heatmap-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 30,\n\t\tminimum: 1,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-weight\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-intensity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"heatmap-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": [\n\t\t\t\"interpolate\",\n\t\t\t[\n\t\t\t\t\"linear\"\n\t\t\t],\n\t\t\t[\n\t\t\t\t\"heatmap-density\"\n\t\t\t],\n\t\t\t0,\n\t\t\t\"rgba(0, 0, 255, 0)\",\n\t\t\t0.1,\n\t\t\t\"royalblue\",\n\t\t\t0.3,\n\t\t\t\"cyan\",\n\t\t\t0.5,\n\t\t\t\"lime\",\n\t\t\t0.7,\n\t\t\t\"yellow\",\n\t\t\t1,\n\t\t\t\"red\"\n\t\t],\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"heatmap-density\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t},\n\t\"heatmap-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_symbol = {\n\t\"icon-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"icon-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\toverridable: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"text-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_raster = {\n\t\"raster-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-hue-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\ttransition: true,\n\t\tunits: \"degrees\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-min\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-max\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-saturation\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-contrast\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-resampling\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tlinear: {\n\t\t\t},\n\t\t\tnearest: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"linear\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-fade-duration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\tunits: \"milliseconds\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_hillshade = {\n\t\"hillshade-illumination-direction\": {\n\t\ttype: \"number\",\n\t\t\"default\": 335,\n\t\tminimum: 0,\n\t\tmaximum: 359,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-exaggeration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-shadow-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-highlight-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#FFFFFF\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-accent-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_background = {\n\t\"background-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"background-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"background-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"background-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar transition = {\n\tduration: {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t},\n\tdelay: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t}\n};\nvar promoteId = {\n\t\"*\": {\n\t\ttype: \"string\"\n\t}\n};\nvar v8Spec = {\n\t$version: $version,\n\t$root: $root,\n\tsources: sources,\n\tsource: source,\n\tsource_vector: source_vector,\n\tsource_raster: source_raster,\n\tsource_raster_dem: source_raster_dem,\n\tsource_geojson: source_geojson,\n\tsource_video: source_video,\n\tsource_image: source_image,\n\tlayer: layer,\n\tlayout: layout,\n\tlayout_background: layout_background,\n\tlayout_fill: layout_fill,\n\tlayout_circle: layout_circle,\n\tlayout_heatmap: layout_heatmap,\n\t\"layout_fill-extrusion\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n},\n\tlayout_line: layout_line,\n\tlayout_symbol: layout_symbol,\n\tlayout_raster: layout_raster,\n\tlayout_hillshade: layout_hillshade,\n\tfilter: filter,\n\tfilter_operator: filter_operator,\n\tgeometry_type: geometry_type,\n\t\"function\": {\n\texpression: {\n\t\ttype: \"expression\"\n\t},\n\tstops: {\n\t\ttype: \"array\",\n\t\tvalue: \"function_stop\"\n\t},\n\tbase: {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0\n\t},\n\tproperty: {\n\t\ttype: \"string\",\n\t\t\"default\": \"$zoom\"\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tidentity: {\n\t\t\t},\n\t\t\texponential: {\n\t\t\t},\n\t\t\tinterval: {\n\t\t\t},\n\t\t\tcategorical: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"exponential\"\n\t},\n\tcolorSpace: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\trgb: {\n\t\t\t},\n\t\t\tlab: {\n\t\t\t},\n\t\t\thcl: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"rgb\"\n\t},\n\t\"default\": {\n\t\ttype: \"*\",\n\t\trequired: false\n\t}\n},\n\tfunction_stop: function_stop,\n\texpression: expression$1,\n\tlight: light,\n\tterrain: terrain,\n\tpaint: paint,\n\tpaint_fill: paint_fill,\n\t\"paint_fill-extrusion\": {\n\t\"fill-extrusion-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-extrusion-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-extrusion-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"fill-extrusion-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-base\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"fill-extrusion-height\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-vertical-gradient\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tpaint_line: paint_line,\n\tpaint_circle: paint_circle,\n\tpaint_heatmap: paint_heatmap,\n\tpaint_symbol: paint_symbol,\n\tpaint_raster: paint_raster,\n\tpaint_hillshade: paint_hillshade,\n\tpaint_background: paint_background,\n\ttransition: transition,\n\t\"property-type\": {\n\t\"data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded-data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"color-ramp\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"data-constant\": {\n\t\ttype: \"property-type\"\n\t},\n\tconstant: {\n\t\ttype: \"property-type\"\n\t}\n},\n\tpromoteId: promoteId\n};\n\nconst refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\n\nfunction deref(layer, parent) {\n const result = {};\n for (const k in layer) {\n if (k !== 'ref') {\n result[k] = layer[k];\n }\n }\n refProperties.forEach((k) => {\n if (k in parent) {\n result[k] = parent[k];\n }\n });\n return result;\n}\n/**\n * Given an array of layers, some of which may contain `ref` properties\n * whose value is the `id` of another property, return a new array where\n * such layers have been augmented with the 'type', 'source', etc. properties\n * from the parent layer, and the `ref` property has been removed.\n *\n * The input is not modified. The output may contain references to portions\n * of the input.\n *\n * @private\n * @param {Array} layers\n * @returns {Array}\n */\nfunction derefLayers(layers) {\n layers = layers.slice();\n const map = Object.create(null);\n for (let i = 0; i < layers.length; i++) {\n map[layers[i].id] = layers[i];\n }\n for (let i = 0; i < layers.length; i++) {\n if ('ref' in layers[i]) {\n layers[i] = deref(layers[i], map[layers[i].ref]);\n }\n }\n return layers;\n}\n\n/**\n * Deeply compares two object literals.\n *\n * @private\n */\nfunction deepEqual(a, b) {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object'))\n return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length)\n return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a === b;\n}\n\nconst operations = {\n /*\n * { command: 'setStyle', args: [stylesheet] }\n */\n setStyle: 'setStyle',\n /*\n * { command: 'addLayer', args: [layer, 'beforeLayerId'] }\n */\n addLayer: 'addLayer',\n /*\n * { command: 'removeLayer', args: ['layerId'] }\n */\n removeLayer: 'removeLayer',\n /*\n * { command: 'setPaintProperty', args: ['layerId', 'prop', value] }\n */\n setPaintProperty: 'setPaintProperty',\n /*\n * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }\n */\n setLayoutProperty: 'setLayoutProperty',\n /*\n * { command: 'setFilter', args: ['layerId', filter] }\n */\n setFilter: 'setFilter',\n /*\n * { command: 'addSource', args: ['sourceId', source] }\n */\n addSource: 'addSource',\n /*\n * { command: 'removeSource', args: ['sourceId'] }\n */\n removeSource: 'removeSource',\n /*\n * { command: 'setGeoJSONSourceData', args: ['sourceId', data] }\n */\n setGeoJSONSourceData: 'setGeoJSONSourceData',\n /*\n * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }\n */\n setLayerZoomRange: 'setLayerZoomRange',\n /*\n * { command: 'setLayerProperty', args: ['layerId', 'prop', value] }\n */\n setLayerProperty: 'setLayerProperty',\n /*\n * { command: 'setCenter', args: [[lon, lat]] }\n */\n setCenter: 'setCenter',\n /*\n * { command: 'setZoom', args: [zoom] }\n */\n setZoom: 'setZoom',\n /*\n * { command: 'setBearing', args: [bearing] }\n */\n setBearing: 'setBearing',\n /*\n * { command: 'setPitch', args: [pitch] }\n */\n setPitch: 'setPitch',\n /*\n * { command: 'setSprite', args: ['spriteUrl'] }\n */\n setSprite: 'setSprite',\n /*\n * { command: 'setGlyphs', args: ['glyphsUrl'] }\n */\n setGlyphs: 'setGlyphs',\n /*\n * { command: 'setTransition', args: [transition] }\n */\n setTransition: 'setTransition',\n /*\n * { command: 'setLighting', args: [lightProperties] }\n */\n setLight: 'setLight'\n};\nfunction addSource(sourceId, after, commands) {\n commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] });\n}\nfunction removeSource(sourceId, commands, sourcesRemoved) {\n commands.push({ command: operations.removeSource, args: [sourceId] });\n sourcesRemoved[sourceId] = true;\n}\nfunction updateSource(sourceId, after, commands, sourcesRemoved) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\nfunction canUpdateGeoJSON(before, after, sourceId) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\nfunction diffSources(before, after, commands, sourcesRemoved) {\n before = before || {};\n after = after || {};\n let sourceId;\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n }\n else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {\n commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] });\n }\n else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\nfunction diffLayerPropertyChanges(before, after, commands, layerId, klass, command) {\n before = before || {};\n after = after || {};\n let prop;\n for (prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n for (prop in after) {\n if (!Object.prototype.hasOwnProperty.call(after, prop) || Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n}\nfunction pluckId(layer) {\n return layer.id;\n}\nfunction indexById(group, layer) {\n group[layer.id] = layer;\n return group;\n}\nfunction diffLayers(before, after, commands) {\n before = before || [];\n after = after || [];\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;\n // remove layers\n for (i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.indexOf(layerId, d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n // add/reorder layers\n for (i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n if (tracker[tracker.length - 1 - i] === layerId)\n continue;\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n commands.push({ command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId] });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n // update layers\n for (i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer))\n continue;\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n commands.push({ command: operations.addLayer, args: [afterLayer, insertBeforeLayerId] });\n continue;\n }\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);\n diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n commands.push({ command: operations.setFilter, args: [layerId, afterLayer.filter] });\n }\n if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) || !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) {\n commands.push({ command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] });\n }\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n for (prop in afterLayer) {\n if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) || Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n }\n}\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nfunction diffStyles(before, after) {\n if (!before)\n return [{ command: operations.setStyle, args: [after] }];\n let commands = [];\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{ command: operations.setStyle, args: [after] }];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({ command: operations.setCenter, args: [after.center] });\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({ command: operations.setZoom, args: [after.zoom] });\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({ command: operations.setBearing, args: [after.bearing] });\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({ command: operations.setPitch, args: [after.pitch] });\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({ command: operations.setSprite, args: [after.sprite] });\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({ command: operations.setGlyphs, args: [after.glyphs] });\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({ command: operations.setTransition, args: [after.transition] });\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({ command: operations.setLight, args: [after.light] });\n }\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if (sourcesRemoved[layer.source]) {\n commands.push({ command: operations.removeLayer, args: [layer.id] });\n }\n else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n }\n catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{ command: operations.setStyle, args: [after] }];\n }\n return commands;\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ValidationError {\n constructor(key, value, message, identifier) {\n this.message = (key ? `${key}: ` : '') + message;\n if (identifier)\n this.identifier = identifier;\n if (value !== null && value !== undefined && value.__line__) {\n this.line = value.__line__;\n }\n }\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ParsingError {\n constructor(error) {\n this.error = error;\n this.message = error.message;\n const match = error.message.match(/line (\\d+)/);\n this.line = match ? parseInt(match[1], 10) : 0;\n }\n}\n\nfunction extendBy(output, ...inputs) {\n for (const input of inputs) {\n for (const k in input) {\n output[k] = input[k];\n }\n }\n return output;\n}\n\nclass ExpressionParsingError extends Error {\n constructor(key, message) {\n super(message);\n this.message = message;\n this.key = key;\n }\n}\n\n/**\n * Tracks `let` bindings during expression parsing.\n * @private\n */\nclass Scope {\n constructor(parent, bindings = []) {\n this.parent = parent;\n this.bindings = {};\n for (const [name, expression] of bindings) {\n this.bindings[name] = expression;\n }\n }\n concat(bindings) {\n return new Scope(this, bindings);\n }\n get(name) {\n if (this.bindings[name]) {\n return this.bindings[name];\n }\n if (this.parent) {\n return this.parent.get(name);\n }\n throw new Error(`${name} not found in scope.`);\n }\n has(name) {\n if (this.bindings[name])\n return true;\n return this.parent ? this.parent.has(name) : false;\n }\n}\n\nconst NullType = { kind: 'null' };\nconst NumberType = { kind: 'number' };\nconst StringType = { kind: 'string' };\nconst BooleanType = { kind: 'boolean' };\nconst ColorType = { kind: 'color' };\nconst ObjectType = { kind: 'object' };\nconst ValueType = { kind: 'value' };\nconst ErrorType = { kind: 'error' };\nconst CollatorType = { kind: 'collator' };\nconst FormattedType = { kind: 'formatted' };\nconst PaddingType = { kind: 'padding' };\nconst ResolvedImageType = { kind: 'resolvedImage' };\nconst VariableAnchorOffsetCollectionType = { kind: 'variableAnchorOffsetCollection' };\nfunction array$1(itemType, N) {\n return {\n kind: 'array',\n itemType,\n N\n };\n}\nfunction toString$1(type) {\n if (type.kind === 'array') {\n const itemType = toString$1(type.itemType);\n return typeof type.N === 'number' ?\n `array<${itemType}, ${type.N}>` :\n type.itemType.kind === 'value' ? 'array' : `array<${itemType}>`;\n }\n else {\n return type.kind;\n }\n}\nconst valueMemberTypes = [\n NullType,\n NumberType,\n StringType,\n BooleanType,\n ColorType,\n FormattedType,\n ObjectType,\n array$1(ValueType),\n PaddingType,\n ResolvedImageType,\n VariableAnchorOffsetCollectionType\n];\n/**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message.\n * @private\n */\nfunction checkSubtype(expected, t) {\n if (t.kind === 'error') {\n // Error is a subtype of every type\n return null;\n }\n else if (expected.kind === 'array') {\n if (t.kind === 'array' &&\n ((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) &&\n (typeof expected.N !== 'number' || expected.N === t.N)) {\n return null;\n }\n }\n else if (expected.kind === t.kind) {\n return null;\n }\n else if (expected.kind === 'value') {\n for (const memberType of valueMemberTypes) {\n if (!checkSubtype(memberType, t)) {\n return null;\n }\n }\n }\n return `Expected ${toString$1(expected)} but found ${toString$1(t)} instead.`;\n}\nfunction isValidType(provided, allowedTypes) {\n return allowedTypes.some(t => t.kind === provided.kind);\n}\nfunction isValidNativeType(provided, allowedTypes) {\n return allowedTypes.some(t => {\n if (t === 'null') {\n return provided === null;\n }\n else if (t === 'array') {\n return Array.isArray(provided);\n }\n else if (t === 'object') {\n return provided && !Array.isArray(provided) && typeof provided === 'object';\n }\n else {\n return t === typeof provided;\n }\n });\n}\n/**\n * Verify whether the specified type is of the same type as the specified sample.\n *\n * @param provided Type to verify\n * @param sample Sample type to reference\n * @returns `true` if both objects are of the same type, `false` otherwise\n * @example basic types\n * if (verifyType(outputType, ValueType)) {\n * // type narrowed to:\n * outputType.kind; // 'value'\n * }\n * @example array types\n * if (verifyType(outputType, array(NumberType))) {\n * // type narrowed to:\n * outputType.kind; // 'array'\n * outputType.itemType; // NumberTypeT\n * outputType.itemType.kind; // 'number'\n * }\n */\nfunction verifyType(provided, sample) {\n if (provided.kind === 'array' && sample.kind === 'array') {\n return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number';\n }\n return provided.kind === sample.kind;\n}\n\n// See https://observablehq.com/@mbostock/lab-and-rgb\nconst Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;\nfunction constrainAngle(angle) {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\nfunction rgbToLab([r, g, b, alpha]) {\n r = rgb2xyz(r);\n g = rgb2xyz(g);\n b = rgb2xyz(b);\n let x, z;\n const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn);\n if (r === g && g === b) {\n x = z = y;\n }\n else {\n x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);\n z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);\n }\n const l = 116 * y - 16;\n return [(l < 0) ? 0 : l, 500 * (x - y), 200 * (y - z), alpha];\n}\nfunction rgb2xyz(x) {\n return (x <= 0.04045) ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);\n}\nfunction xyz2lab(t) {\n return (t > t3) ? Math.pow(t, 1 / 3) : t / t2 + t0;\n}\nfunction labToRgb([l, a, b, alpha]) {\n let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200;\n y = Yn * lab2xyz(y);\n x = Xn * lab2xyz(x);\n z = Zn * lab2xyz(z);\n return [\n xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z),\n xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),\n xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),\n alpha,\n ];\n}\nfunction xyz2rgb(x) {\n x = (x <= 0.00304) ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;\n return (x < 0) ? 0 : (x > 1) ? 1 : x; // clip to 0..1 range\n}\nfunction lab2xyz(t) {\n return (t > t1) ? t * t * t : t2 * (t - t0);\n}\nfunction rgbToHcl(rgbColor) {\n const [l, a, b, alpha] = rgbToLab(rgbColor);\n const c = Math.sqrt(a * a + b * b);\n const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN;\n return [h, c, l, alpha];\n}\nfunction hclToRgb([h, c, l, alpha]) {\n h = isNaN(h) ? 0 : h * deg2rad;\n return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]);\n}\n// https://drafts.csswg.org/css-color-4/#hsl-to-rgb\nfunction hslToRgb([h, s, l, alpha]) {\n h = constrainAngle(h);\n s /= 100;\n l /= 100;\n function f(n) {\n const k = (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n return [f(0), f(8), f(4), alpha];\n}\n\n/**\n * CSS color parser compliant with CSS Color 4 Specification.\n * Supports: named colors, `transparent` keyword, all rgb hex notations,\n * rgb(), rgba(), hsl() and hsla() functions.\n * Does not round the parsed values to integers from the range 0..255.\n *\n * Syntax:\n *\n * = | \n * = | \n *\n * rgb() = rgb( {3} [ / ]? ) | rgb( {3} [ / ]? )\n * rgb() = rgb( #{3} , ? ) | rgb( #{3} , ? )\n *\n * hsl() = hsl( [ / ]? )\n * hsl() = hsl( , , , ? )\n *\n * Caveats:\n * - - with optional `deg` suffix; `grad`, `rad`, `turn` are not supported\n * - `none` keyword is not supported\n * - comments inside rgb()/hsl() are not supported\n * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb()\n * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl()\n *\n * @param input CSS color string to parse.\n * @returns Color in sRGB color space, with `red`, `green`, `blue`\n * and `alpha` channels normalized to the range 0..1,\n * or `undefined` if the input is not a valid color string.\n */\nfunction parseCssColor(input) {\n input = input.toLowerCase().trim();\n if (input === 'transparent') {\n return [0, 0, 0, 0];\n }\n // 'white', 'black', 'blue'\n const namedColorsMatch = namedColors[input];\n if (namedColorsMatch) {\n const [r, g, b] = namedColorsMatch;\n return [r / 255, g / 255, b / 255, 1];\n }\n // #f0c, #f0cf, #ff00cc, #ff00ccff\n if (input.startsWith('#')) {\n const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n if (hexRegexp.test(input)) {\n const step = input.length < 6 ? 1 : 2;\n let i = 1;\n return [\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i + step) || 'ff'),\n ];\n }\n }\n // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6)\n if (input.startsWith('rgb')) {\n const rgbRegExp = /^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const rgbMatch = input.match(rgbRegExp);\n if (rgbMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n r, // \n rp, // % (optional)\n f1, // , (optional)\n g, // \n gp, // % (optional)\n f2, // , (optional)\n b, // \n bp, // % (optional)\n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = rgbMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const valFormat = [rp, gp, bp].join('');\n const maxValue = (valFormat === '%%%') ? 100 :\n (valFormat === '') ? 255 : 0;\n if (maxValue) {\n const rgba = [\n clamp(+r / maxValue, 0, 1),\n clamp(+g / maxValue, 0, 1),\n clamp(+b / maxValue, 0, 1),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(rgba)) {\n return rgba;\n }\n // invalid numbers\n }\n // values must be all numbers or all percentages\n }\n return; // comma optional syntax requires no commas at all\n }\n }\n // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%)\n const hslRegExp = /^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const hslMatch = input.match(hslRegExp);\n if (hslMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n h, // \n f1, // , (optional)\n s, // \n f2, // , (optional)\n l, // \n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = hslMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const hsla = [\n +h,\n clamp(+s, 0, 100),\n clamp(+l, 0, 100),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(hsla)) {\n return hslToRgb(hsla);\n }\n // invalid numbers\n }\n // comma optional syntax requires no commas at all\n }\n}\nfunction parseHex(hex) {\n return parseInt(hex.padEnd(2, hex), 16) / 255;\n}\nfunction parseAlpha(a, asPercentage) {\n return clamp(asPercentage ? (a / 100) : a, 0, 1);\n}\nfunction clamp(n, min, max) {\n return Math.min(Math.max(min, n), max);\n}\n/**\n * The regular expression for numeric values is not super specific, and it may\n * happen that it will accept a value that is not a valid number. In order to\n * detect and eliminate such values this function exists.\n *\n * @param array Array of uncertain numbers.\n * @returns `true` if the specified array contains only valid numbers, `false` otherwise.\n */\nfunction validateNumbers(array) {\n return !array.some(Number.isNaN);\n}\n/**\n * To generate:\n * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors}\n * - run in the console:\n * @example\n * copy(`{\\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\\s+/).join(', ')}],`).join('\\n')}\\n}`);\n */\nconst namedColors = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n\n/**\n * Color representation used by WebGL.\n * Defined in sRGB color space and pre-blended with alpha.\n * @private\n */\nclass Color {\n /**\n * @param r Red component premultiplied by `alpha` 0..1\n * @param g Green component premultiplied by `alpha` 0..1\n * @param b Blue component premultiplied by `alpha` 0..1\n * @param [alpha=1] Alpha component 0..1\n * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already\n * been multiplied by alpha. If `true` nothing happens if `false` then they will\n * be multiplied automatically.\n */\n constructor(r, g, b, alpha = 1, premultiplied = true) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = alpha;\n if (!premultiplied) {\n this.r *= alpha;\n this.g *= alpha;\n this.b *= alpha;\n if (!alpha) {\n // alpha = 0 erases completely rgb channels. This behavior is not desirable\n // if this particular color is later used in color interpolation.\n // Because of that, a reference to original color is saved.\n this.overwriteGetter('rgb', [r, g, b, alpha]);\n }\n }\n }\n /**\n * Parses CSS color strings and converts colors to sRGB color space if needed.\n * Officially supported color formats:\n * - keyword, e.g. 'aquamarine' or 'steelblue'\n * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'\n * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'\n * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'\n *\n * @param input CSS color string to parse.\n * @returns A `Color` instance, or `undefined` if the input is not a valid color string.\n */\n static parse(input) {\n // in zoom-and-property function input could be an instance of Color class\n if (input instanceof Color) {\n return input;\n }\n if (typeof input !== 'string') {\n return;\n }\n const rgba = parseCssColor(input);\n if (rgba) {\n return new Color(...rgba, false);\n }\n }\n /**\n * Used in color interpolation and by 'to-rgba' expression.\n *\n * @returns Gien color, with reversed alpha blending, in sRGB color space.\n */\n get rgb() {\n const { r, g, b, a } = this;\n const f = a || Infinity; // reverse alpha blending factor\n return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]);\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in HCL color space.\n */\n get hcl() {\n return this.overwriteGetter('hcl', rgbToHcl(this.rgb));\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in LAB color space.\n */\n get lab() {\n return this.overwriteGetter('lab', rgbToLab(this.rgb));\n }\n /**\n * Lazy getter pattern. When getter is called for the first time lazy value\n * is calculated and then overwrites getter function in given object instance.\n *\n * @example:\n * const redColor = Color.parse('red');\n * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate\n * // the value of red in HCL space and invoke this `overwriteGetter` function\n * // which in turn will set a field with a key 'hcl' in the `redColor` object.\n * // In other words it will override `get hcl()` from its `Color` prototype\n * // with its own property: hcl = [calculated red value in hcl].\n * let y = redColor.hcl; // next call will no longer invoke getter but simply\n * // return the previously calculated value\n * x === y; // true - `x` is exactly the same object as `y`\n *\n * @param getterKey Getter key\n * @param lazyValue Lazily calculated value to be memoized by current instance\n * @private\n */\n overwriteGetter(getterKey, lazyValue) {\n Object.defineProperty(this, getterKey, { value: lazyValue });\n return lazyValue;\n }\n /**\n * Used by 'to-string' expression.\n *\n * @returns Serialized color in format `rgba(r,g,b,a)`\n * where r,g,b are numbers within 0..255 and alpha is number within 1..0\n *\n * @example\n * var purple = new Color.parse('purple');\n * purple.toString; // = \"rgba(128,0,128,1)\"\n * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');\n * translucentGreen.toString(); // = \"rgba(26,207,26,0.73)\"\n */\n toString() {\n const [r, g, b, a] = this.rgb;\n return `rgba(${[r, g, b].map(n => Math.round(n * 255)).join(',')},${a})`;\n }\n}\nColor.black = new Color(0, 0, 0, 1);\nColor.white = new Color(1, 1, 1, 1);\nColor.transparent = new Color(0, 0, 0, 0);\nColor.red = new Color(1, 0, 0, 1);\n\n// Flow type declarations for Intl cribbed from\n// https://github.com/facebook/flow/issues/1270\nclass Collator {\n constructor(caseSensitive, diacriticSensitive, locale) {\n if (caseSensitive)\n this.sensitivity = diacriticSensitive ? 'variant' : 'case';\n else\n this.sensitivity = diacriticSensitive ? 'accent' : 'base';\n this.locale = locale;\n this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: 'search' });\n }\n compare(lhs, rhs) {\n return this.collator.compare(lhs, rhs);\n }\n resolvedLocale() {\n // We create a Collator without \"usage: search\" because we don't want\n // the search options encoded in our result (e.g. \"en-u-co-search\")\n return new Intl.Collator(this.locale ? this.locale : [])\n .resolvedOptions().locale;\n }\n}\n\nclass FormattedSection {\n constructor(text, image, scale, fontStack, textColor) {\n this.text = text;\n this.image = image;\n this.scale = scale;\n this.fontStack = fontStack;\n this.textColor = textColor;\n }\n}\nclass Formatted {\n constructor(sections) {\n this.sections = sections;\n }\n static fromString(unformatted) {\n return new Formatted([new FormattedSection(unformatted, null, null, null, null)]);\n }\n isEmpty() {\n if (this.sections.length === 0)\n return true;\n return !this.sections.some(section => section.text.length !== 0 ||\n (section.image && section.image.name.length !== 0));\n }\n static factory(text) {\n if (text instanceof Formatted) {\n return text;\n }\n else {\n return Formatted.fromString(text);\n }\n }\n toString() {\n if (this.sections.length === 0)\n return '';\n return this.sections.map(section => section.text).join('');\n }\n}\n\n/**\n * A set of four numbers representing padding around a box. Create instances from\n * bare arrays or numeric values using the static method `Padding.parse`.\n * @private\n */\nclass Padding {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric padding values\n * @param input A padding value\n * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value.\n */\n static parse(input) {\n if (input instanceof Padding) {\n return input;\n }\n // Backwards compatibility: bare number is treated the same as array with single value.\n // Padding applies to all four sides.\n if (typeof input === 'number') {\n return new Padding([input, input, input, input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n if (input.length < 1 || input.length > 4) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n // Expand shortcut properties into explicit 4-sided values\n switch (input.length) {\n case 1:\n input = [input[0], input[0], input[0], input[0]];\n break;\n case 2:\n input = [input[0], input[1], input[0], input[1]];\n break;\n case 3:\n input = [input[0], input[1], input[2], input[1]];\n break;\n }\n return new Padding(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\n/** Set of valid anchor positions, as a set for validation */\nconst anchors = new Set(['center', 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right']);\n/**\n * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from\n * bare arrays using the static method `VariableAnchorOffsetCollection.parse`.\n * @private\n */\nclass VariableAnchorOffsetCollection {\n constructor(values) {\n this.values = values.slice();\n }\n static parse(input) {\n if (input instanceof VariableAnchorOffsetCollection) {\n return input;\n }\n if (!Array.isArray(input) ||\n input.length < 1 ||\n input.length % 2 !== 0) {\n return undefined;\n }\n for (let i = 0; i < input.length; i += 2) {\n // Elements in even positions should be anchor positions; Elements in odd positions should be offset values\n const anchorValue = input[i];\n const offsetValue = input[i + 1];\n if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) {\n return undefined;\n }\n if (!Array.isArray(offsetValue) || offsetValue.length !== 2 || typeof offsetValue[0] !== 'number' || typeof offsetValue[1] !== 'number') {\n return undefined;\n }\n }\n return new VariableAnchorOffsetCollection(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\nclass ResolvedImage {\n constructor(options) {\n this.name = options.name;\n this.available = options.available;\n }\n toString() {\n return this.name;\n }\n static fromString(name) {\n if (!name)\n return null; // treat empty values as no image\n return new ResolvedImage({ name, available: false });\n }\n}\n\nfunction validateRGBA(r, g, b, a) {\n if (!(typeof r === 'number' && r >= 0 && r <= 255 &&\n typeof g === 'number' && g >= 0 && g <= 255 &&\n typeof b === 'number' && b >= 0 && b <= 255)) {\n const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];\n return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;\n }\n if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) {\n return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;\n }\n return null;\n}\nfunction isValue(mixed) {\n if (mixed === null ||\n typeof mixed === 'string' ||\n typeof mixed === 'boolean' ||\n typeof mixed === 'number' ||\n mixed instanceof Color ||\n mixed instanceof Collator ||\n mixed instanceof Formatted ||\n mixed instanceof Padding ||\n mixed instanceof VariableAnchorOffsetCollection ||\n mixed instanceof ResolvedImage) {\n return true;\n }\n else if (Array.isArray(mixed)) {\n for (const item of mixed) {\n if (!isValue(item)) {\n return false;\n }\n }\n return true;\n }\n else if (typeof mixed === 'object') {\n for (const key in mixed) {\n if (!isValue(mixed[key])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\nfunction typeOf(value) {\n if (value === null) {\n return NullType;\n }\n else if (typeof value === 'string') {\n return StringType;\n }\n else if (typeof value === 'boolean') {\n return BooleanType;\n }\n else if (typeof value === 'number') {\n return NumberType;\n }\n else if (value instanceof Color) {\n return ColorType;\n }\n else if (value instanceof Collator) {\n return CollatorType;\n }\n else if (value instanceof Formatted) {\n return FormattedType;\n }\n else if (value instanceof Padding) {\n return PaddingType;\n }\n else if (value instanceof VariableAnchorOffsetCollection) {\n return VariableAnchorOffsetCollectionType;\n }\n else if (value instanceof ResolvedImage) {\n return ResolvedImageType;\n }\n else if (Array.isArray(value)) {\n const length = value.length;\n let itemType;\n for (const item of value) {\n const t = typeOf(item);\n if (!itemType) {\n itemType = t;\n }\n else if (itemType === t) {\n continue;\n }\n else {\n itemType = ValueType;\n break;\n }\n }\n return array$1(itemType || ValueType, length);\n }\n else {\n return ObjectType;\n }\n}\nfunction toString(value) {\n const type = typeof value;\n if (value === null) {\n return '';\n }\n else if (type === 'string' || type === 'number' || type === 'boolean') {\n return String(value);\n }\n else if (value instanceof Color || value instanceof Formatted || value instanceof Padding || value instanceof VariableAnchorOffsetCollection || value instanceof ResolvedImage) {\n return value.toString();\n }\n else {\n return JSON.stringify(value);\n }\n}\n\nclass Literal {\n constructor(type, value) {\n this.type = type;\n this.value = value;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (!isValue(args[1]))\n return context.error('invalid value');\n const value = args[1];\n let type = typeOf(value);\n // special case: infer the item type if possible for zero-length arrays\n const expected = context.expectedType;\n if (type.kind === 'array' &&\n type.N === 0 &&\n expected &&\n expected.kind === 'array' &&\n (typeof expected.N !== 'number' || expected.N === 0)) {\n type = expected;\n }\n return new Literal(type, value);\n }\n evaluate() {\n return this.value;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass RuntimeError {\n constructor(message) {\n this.name = 'ExpressionEvaluationError';\n this.message = message;\n }\n toJSON() {\n return this.message;\n }\n}\n\nconst types$1 = {\n string: StringType,\n number: NumberType,\n boolean: BooleanType,\n object: ObjectType\n};\nclass Assertion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n let i = 1;\n let type;\n const name = args[0];\n if (name === 'array') {\n let itemType;\n if (args.length > 2) {\n const type = args[1];\n if (typeof type !== 'string' || !(type in types$1) || type === 'object')\n return context.error('The item type argument of \"array\" must be one of string, number, boolean', 1);\n itemType = types$1[type];\n i++;\n }\n else {\n itemType = ValueType;\n }\n let N;\n if (args.length > 3) {\n if (args[2] !== null &&\n (typeof args[2] !== 'number' ||\n args[2] < 0 ||\n args[2] !== Math.floor(args[2]))) {\n return context.error('The length argument to \"array\" must be a positive integer literal', 2);\n }\n N = args[2];\n i++;\n }\n type = array$1(itemType, N);\n }\n else {\n if (!types$1[name])\n throw new Error(`Types doesn't contain name = ${name}`);\n type = types$1[name];\n }\n const parsed = [];\n for (; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Assertion(type, parsed);\n }\n evaluate(ctx) {\n for (let i = 0; i < this.args.length; i++) {\n const value = this.args[i].evaluate(ctx);\n const error = checkSubtype(this.type, typeOf(value));\n if (!error) {\n return value;\n }\n else if (i === this.args.length - 1) {\n throw new RuntimeError(`Expected value to be of type ${toString$1(this.type)}, but found ${toString$1(typeOf(value))} instead.`);\n }\n }\n throw new Error();\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst types = {\n 'to-boolean': BooleanType,\n 'to-color': ColorType,\n 'to-number': NumberType,\n 'to-string': StringType\n};\n/**\n * Special form for error-coalescing coercion expressions \"to-number\",\n * \"to-color\". Since these coercions can fail at runtime, they accept multiple\n * arguments, only evaluating one at a time until one succeeds.\n *\n * @private\n */\nclass Coercion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n const name = args[0];\n if (!types[name])\n throw new Error(`Can't parse ${name} as it is not part of the known types`);\n if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2)\n return context.error('Expected one argument.');\n const type = types[name];\n const parsed = [];\n for (let i = 1; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Coercion(type, parsed);\n }\n evaluate(ctx) {\n switch (this.type.kind) {\n case 'boolean':\n return Boolean(this.args[0].evaluate(ctx));\n case 'color': {\n let input;\n let error;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n error = null;\n if (input instanceof Color) {\n return input;\n }\n else if (typeof input === 'string') {\n const c = ctx.parseColor(input);\n if (c)\n return c;\n }\n else if (Array.isArray(input)) {\n if (input.length < 3 || input.length > 4) {\n error = `Invalid rbga value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`;\n }\n else {\n error = validateRGBA(input[0], input[1], input[2], input[3]);\n }\n if (!error) {\n return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);\n }\n }\n }\n throw new RuntimeError(error || `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'padding': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const pad = Padding.parse(input);\n if (pad) {\n return pad;\n }\n }\n throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'variableAnchorOffsetCollection': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const coll = VariableAnchorOffsetCollection.parse(input);\n if (coll) {\n return coll;\n }\n }\n throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'number': {\n let value = null;\n for (const arg of this.args) {\n value = arg.evaluate(ctx);\n if (value === null)\n return 0;\n const num = Number(value);\n if (isNaN(num))\n continue;\n return num;\n }\n throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`);\n }\n case 'formatted':\n // There is no explicit 'to-formatted' but this coercion can be implicitly\n // created by properties that expect the 'formatted' type.\n return Formatted.fromString(toString(this.args[0].evaluate(ctx)));\n case 'resolvedImage':\n return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx)));\n default:\n return toString(this.args[0].evaluate(ctx));\n }\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\nclass EvaluationContext {\n constructor() {\n this.globals = null;\n this.feature = null;\n this.featureState = null;\n this.formattedSection = null;\n this._parseColorCache = {};\n this.availableImages = null;\n this.canonical = null;\n }\n id() {\n return this.feature && 'id' in this.feature ? this.feature.id : null;\n }\n geometryType() {\n return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;\n }\n geometry() {\n return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n }\n canonicalID() {\n return this.canonical;\n }\n properties() {\n return this.feature && this.feature.properties || {};\n }\n parseColor(input) {\n let cached = this._parseColorCache[input];\n if (!cached) {\n cached = this._parseColorCache[input] = Color.parse(input);\n }\n return cached;\n }\n}\n\n/**\n * State associated parsing at a given point in an expression tree.\n * @private\n */\nclass ParsingContext {\n constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) {\n this.registry = registry;\n this.path = path;\n this.key = path.map(part => `[${part}]`).join('');\n this.scope = scope;\n this.errors = errors;\n this.expectedType = expectedType;\n this._isConstant = isConstantFunc;\n }\n /**\n * @param expr the JSON expression to parse\n * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed\n * @param options\n * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.\n * @private\n */\n parse(expr, index, expectedType, bindings, options = {}) {\n if (index) {\n return this.concat(index, expectedType, bindings)._parse(expr, options);\n }\n return this._parse(expr, options);\n }\n _parse(expr, options) {\n if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {\n expr = ['literal', expr];\n }\n function annotate(parsed, type, typeAnnotation) {\n if (typeAnnotation === 'assert') {\n return new Assertion(type, [parsed]);\n }\n else if (typeAnnotation === 'coerce') {\n return new Coercion(type, [parsed]);\n }\n else {\n return parsed;\n }\n }\n if (Array.isArray(expr)) {\n if (expr.length === 0) {\n return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');\n }\n const op = expr[0];\n if (typeof op !== 'string') {\n this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use [\"literal\", [...]].`, 0);\n return null;\n }\n const Expr = this.registry[op];\n if (Expr) {\n let parsed = Expr.parse(expr, this);\n if (!parsed)\n return null;\n if (this.expectedType) {\n const expected = this.expectedType;\n const actual = parsed.type;\n // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.\n // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.\n // Otherwise, we do static type-checking.\n //\n // These behaviors are overridable for:\n // * The \"coalesce\" operator, which needs to omit type annotations.\n // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.\n //\n if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');\n }\n else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'padding' && (actual.kind === 'value' || actual.kind === 'number' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'variableAnchorOffsetCollection' && (actual.kind === 'value' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (this.checkSubtype(expected, actual)) {\n return null;\n }\n }\n // If an expression's arguments are all literals, we can evaluate\n // it immediately and replace it with a literal value in the\n // parsed/compiled result. Expressions that expect an image should\n // not be resolved here so we can later get the available images.\n if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && this._isConstant(parsed)) {\n const ec = new EvaluationContext();\n try {\n parsed = new Literal(parsed.type, parsed.evaluate(ec));\n }\n catch (e) {\n this.error(e.message);\n return null;\n }\n }\n return parsed;\n }\n return this.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n else if (typeof expr === 'undefined') {\n return this.error('\\'undefined\\' value invalid. Use null instead.');\n }\n else if (typeof expr === 'object') {\n return this.error('Bare objects invalid. Use [\"literal\", {...}] instead.');\n }\n else {\n return this.error(`Expected an array, but found ${typeof expr} instead.`);\n }\n }\n /**\n * Returns a copy of this context suitable for parsing the subexpression at\n * index `index`, optionally appending to 'let' binding map.\n *\n * Note that `errors` property, intended for collecting errors while\n * parsing, is copied by reference rather than cloned.\n * @private\n */\n concat(index, expectedType, bindings) {\n const path = typeof index === 'number' ? this.path.concat(index) : this.path;\n const scope = bindings ? this.scope.concat(bindings) : this.scope;\n return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors);\n }\n /**\n * Push a parsing (or type checking) error into the `this.errors`\n * @param error The message\n * @param keys Optionally specify the source of the error at a child\n * of the current expression at `this.key`.\n * @private\n */\n error(error, ...keys) {\n const key = `${this.key}${keys.map(k => `[${k}]`).join('')}`;\n this.errors.push(new ExpressionParsingError(key, error));\n }\n /**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message and also pushes it to `this.errors`.\n * @param expected The expected type\n * @param t The actual type\n * @returns null if `t` is a subtype of `expected`; otherwise returns an error message\n */\n checkSubtype(expected, t) {\n const error = checkSubtype(expected, t);\n if (error)\n this.error(error);\n return error;\n }\n}\n\nclass CollatorExpression {\n constructor(caseSensitive, diacriticSensitive, locale) {\n this.type = CollatorType;\n this.locale = locale;\n this.caseSensitive = caseSensitive;\n this.diacriticSensitive = diacriticSensitive;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error('Expected one argument.');\n const options = args[1];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('Collator options argument must be an object.');\n const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);\n if (!caseSensitive)\n return null;\n const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);\n if (!diacriticSensitive)\n return null;\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n return new CollatorExpression(caseSensitive, diacriticSensitive, locale);\n }\n evaluate(ctx) {\n return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);\n }\n eachChild(fn) {\n fn(this.caseSensitive);\n fn(this.diacriticSensitive);\n if (this.locale) {\n fn(this.locale);\n }\n }\n outputDefined() {\n // Technically the set of possible outputs is the combinatoric set of Collators produced\n // by all possible outputs of locale/caseSensitive/diacriticSensitive\n // But for the primary use of Collators in comparison operators, we ignore the Collator's\n // possible outputs anyway, so we can get away with leaving this false for now.\n return false;\n }\n}\n\nconst EXTENT = 8192;\nfunction updateBBox(bbox, coord) {\n bbox[0] = Math.min(bbox[0], coord[0]);\n bbox[1] = Math.min(bbox[1], coord[1]);\n bbox[2] = Math.max(bbox[2], coord[0]);\n bbox[3] = Math.max(bbox[3], coord[1]);\n}\nfunction mercatorXfromLng(lng) {\n return (180 + lng) / 360;\n}\nfunction mercatorYfromLat(lat) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\nfunction boxWithinBox(bbox1, bbox2) {\n if (bbox1[0] <= bbox2[0])\n return false;\n if (bbox1[2] >= bbox2[2])\n return false;\n if (bbox1[1] <= bbox2[1])\n return false;\n if (bbox1[3] >= bbox2[3])\n return false;\n return true;\n}\nfunction getTileCoordinates(p, canonical) {\n const x = mercatorXfromLng(p[0]);\n const y = mercatorYfromLat(p[1]);\n const tilesAtZoom = Math.pow(2, canonical.z);\n return [Math.round(x * tilesAtZoom * EXTENT), Math.round(y * tilesAtZoom * EXTENT)];\n}\nfunction onBoundary(p, p1, p2) {\n const x1 = p[0] - p1[0];\n const y1 = p[1] - p1[1];\n const x2 = p[0] - p2[0];\n const y2 = p[1] - p2[1];\n return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);\n}\nfunction rayIntersect(p, p1, p2) {\n return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]);\n}\n// ray casting algorithm for detecting if point is in polygon\nfunction pointWithinPolygon(point, rings) {\n let inside = false;\n for (let i = 0, len = rings.length; i < len; i++) {\n const ring = rings[i];\n for (let j = 0, len2 = ring.length; j < len2 - 1; j++) {\n if (onBoundary(point, ring[j], ring[j + 1]))\n return false;\n if (rayIntersect(point, ring[j], ring[j + 1]))\n inside = !inside;\n }\n }\n return inside;\n}\nfunction pointWithinPolygons(point, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (pointWithinPolygon(point, polygons[i]))\n return true;\n }\n return false;\n}\nfunction perp(v1, v2) {\n return (v1[0] * v2[1] - v1[1] * v2[0]);\n}\n// check if p1 and p2 are in different sides of line segment q1->q2\nfunction twoSided(p1, p2, q1, q2) {\n // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)\n const x1 = p1[0] - q1[0];\n const y1 = p1[1] - q1[1];\n const x2 = p2[0] - q1[0];\n const y2 = p2[1] - q1[1];\n const x3 = q2[0] - q1[0];\n const y3 = q2[1] - q1[1];\n const det1 = (x1 * y3 - x3 * y1);\n const det2 = (x2 * y3 - x3 * y2);\n if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0))\n return true;\n return false;\n}\n// a, b are end points for line segment1, c and d are end points for line segment2\nfunction lineIntersectLine(a, b, c, d) {\n // check if two segments are parallel or not\n // precondition is end point a, b is inside polygon, if line a->b is\n // parallel to polygon edge c->d, then a->b won't intersect with c->d\n const vectorP = [b[0] - a[0], b[1] - a[1]];\n const vectorQ = [d[0] - c[0], d[1] - c[1]];\n if (perp(vectorQ, vectorP) === 0)\n return false;\n // If lines are intersecting with each other, the relative location should be:\n // a and b lie in different sides of segment c->d\n // c and d lie in different sides of segment a->b\n if (twoSided(a, b, c, d) && twoSided(c, d, a, b))\n return true;\n return false;\n}\nfunction lineIntersectPolygon(p1, p2, polygon) {\n for (const ring of polygon) {\n // loop through every edge of the ring\n for (let j = 0; j < ring.length - 1; ++j) {\n if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) {\n return true;\n }\n }\n }\n return false;\n}\nfunction lineStringWithinPolygon(line, polygon) {\n // First, check if geometry points of line segments are all inside polygon\n for (let i = 0; i < line.length; ++i) {\n if (!pointWithinPolygon(line[i], polygon)) {\n return false;\n }\n }\n // Second, check if there is line segment intersecting polygon edge\n for (let i = 0; i < line.length - 1; ++i) {\n if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {\n return false;\n }\n }\n return true;\n}\nfunction lineStringWithinPolygons(line, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (lineStringWithinPolygon(line, polygons[i]))\n return true;\n }\n return false;\n}\nfunction getTilePolygon(coordinates, bbox, canonical) {\n const polygon = [];\n for (let i = 0; i < coordinates.length; i++) {\n const ring = [];\n for (let j = 0; j < coordinates[i].length; j++) {\n const coord = getTileCoordinates(coordinates[i][j], canonical);\n updateBBox(bbox, coord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n return polygon;\n}\nfunction getTilePolygons(coordinates, bbox, canonical) {\n const polygons = [];\n for (let i = 0; i < coordinates.length; i++) {\n const polygon = getTilePolygon(coordinates[i], bbox, canonical);\n polygons.push(polygon);\n }\n return polygons;\n}\nfunction updatePoint(p, bbox, polyBBox, worldSize) {\n if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {\n const halfWorldSize = worldSize * 0.5;\n let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0;\n if (shift === 0) {\n shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0;\n }\n p[0] += shift;\n }\n updateBBox(bbox, p);\n}\nfunction resetBBox(bbox) {\n bbox[0] = bbox[1] = Infinity;\n bbox[2] = bbox[3] = -Infinity;\n}\nfunction getTilePoints(geometry, pointBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tilePoints = [];\n for (const points of geometry) {\n for (const point of points) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updatePoint(p, pointBBox, polyBBox, worldSize);\n tilePoints.push(p);\n }\n }\n return tilePoints;\n}\nfunction getTileLines(geometry, lineBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tileLines = [];\n for (const line of geometry) {\n const tileLine = [];\n for (const point of line) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updateBBox(lineBBox, p);\n tileLine.push(p);\n }\n tileLines.push(tileLine);\n }\n if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {\n resetBBox(lineBBox);\n for (const line of tileLines) {\n for (const p of line) {\n updatePoint(p, lineBBox, polyBBox, worldSize);\n }\n }\n }\n return tileLines;\n}\nfunction pointsWithinPolygons(ctx, polygonGeometry) {\n const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygon(point, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygons(point, tilePolygons))\n return false;\n }\n }\n return true;\n}\nfunction linesWithinPolygons(ctx, polygonGeometry) {\n const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygon(line, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygons(line, tilePolygons))\n return false;\n }\n }\n return true;\n}\nclass Within {\n constructor(geojson, geometries) {\n this.type = BooleanType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n for (let i = 0; i < geojson.features.length; ++i) {\n const type = geojson.features[i].geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.features[i].geometry);\n }\n }\n }\n else if (geojson.type === 'Feature') {\n const type = geojson.geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.geometry);\n }\n }\n else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {\n return new Within(geojson, geojson);\n }\n }\n return context.error('\\'within\\' expression requires valid geojson object that contains polygon geometry type.');\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointsWithinPolygons(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return linesWithinPolygons(ctx, this.geometries);\n }\n }\n return false;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass Var {\n constructor(name, boundExpression) {\n this.type = boundExpression.type;\n this.name = name;\n this.boundExpression = boundExpression;\n }\n static parse(args, context) {\n if (args.length !== 2 || typeof args[1] !== 'string')\n return context.error('\\'var\\' expression requires exactly one string literal argument.');\n const name = args[1];\n if (!context.scope.has(name)) {\n return context.error(`Unknown variable \"${name}\". Make sure \"${name}\" has been bound in an enclosing \"let\" expression before using it.`, 1);\n }\n return new Var(name, context.scope.get(name));\n }\n evaluate(ctx) {\n return this.boundExpression.evaluate(ctx);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nclass CompoundExpression {\n constructor(name, type, evaluate, args) {\n this.name = name;\n this.type = type;\n this._evaluate = evaluate;\n this.args = args;\n }\n evaluate(ctx) {\n return this._evaluate(ctx, this.args);\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return false;\n }\n static parse(args, context) {\n const op = args[0];\n const definition = CompoundExpression.definitions[op];\n if (!definition) {\n return context.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n // Now check argument types against each signature\n const type = Array.isArray(definition) ?\n definition[0] : definition.type;\n const availableOverloads = Array.isArray(definition) ?\n [[definition[1], definition[2]]] :\n definition.overloads;\n const overloads = availableOverloads.filter(([signature]) => (!Array.isArray(signature) || // varags\n signature.length === args.length - 1 // correct param count\n ));\n let signatureContext = null;\n for (const [params, evaluate] of overloads) {\n // Use a fresh context for each attempted signature so that, if\n // we eventually succeed, we haven't polluted `context.errors`.\n signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope);\n // First parse all the args, potentially coercing to the\n // types expected by this overload.\n const parsedArgs = [];\n let argParseFailed = false;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n const expectedType = Array.isArray(params) ?\n params[i - 1] :\n params.type;\n const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);\n if (!parsed) {\n argParseFailed = true;\n break;\n }\n parsedArgs.push(parsed);\n }\n if (argParseFailed) {\n // Couldn't coerce args of this overload to expected type, move\n // on to next one.\n continue;\n }\n if (Array.isArray(params)) {\n if (params.length !== parsedArgs.length) {\n signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);\n continue;\n }\n }\n for (let i = 0; i < parsedArgs.length; i++) {\n const expected = Array.isArray(params) ? params[i] : params.type;\n const arg = parsedArgs[i];\n signatureContext.concat(i + 1).checkSubtype(expected, arg.type);\n }\n if (signatureContext.errors.length === 0) {\n return new CompoundExpression(op, type, evaluate, parsedArgs);\n }\n }\n if (overloads.length === 1) {\n context.errors.push(...signatureContext.errors);\n }\n else {\n const expected = overloads.length ? overloads : availableOverloads;\n const signatures = expected\n .map(([params]) => stringifySignature(params))\n .join(' | ');\n const actualTypes = [];\n // For error message, re-parse arguments without trying to\n // apply any coercions\n for (let i = 1; i < args.length; i++) {\n const parsed = context.parse(args[i], 1 + actualTypes.length);\n if (!parsed)\n return null;\n actualTypes.push(toString$1(parsed.type));\n }\n context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);\n }\n return null;\n }\n static register(registry, definitions) {\n CompoundExpression.definitions = definitions;\n for (const name in definitions) {\n registry[name] = CompoundExpression;\n }\n }\n}\nfunction stringifySignature(signature) {\n if (Array.isArray(signature)) {\n return `(${signature.map(toString$1).join(', ')})`;\n }\n else {\n return `(${toString$1(signature.type)}...)`;\n }\n}\nfunction isExpressionConstant(expression) {\n if (expression instanceof Var) {\n return isExpressionConstant(expression.boundExpression);\n }\n else if (expression instanceof CompoundExpression && expression.name === 'error') {\n return false;\n }\n else if (expression instanceof CollatorExpression) {\n // Although the results of a Collator expression with fixed arguments\n // generally shouldn't change between executions, we can't serialize them\n // as constant expressions because results change based on environment.\n return false;\n }\n else if (expression instanceof Within) {\n return false;\n }\n const isTypeAnnotation = expression instanceof Coercion ||\n expression instanceof Assertion;\n let childrenConstant = true;\n expression.eachChild(child => {\n // We can _almost_ assume that if `expressions` children are constant,\n // they would already have been evaluated to Literal values when they\n // were parsed. Type annotations are the exception, because they might\n // have been inferred and added after a child was parsed.\n // So we recurse into isConstant() for the children of type annotations,\n // but otherwise simply check whether they are Literals.\n if (isTypeAnnotation) {\n childrenConstant = childrenConstant && isExpressionConstant(child);\n }\n else {\n childrenConstant = childrenConstant && child instanceof Literal;\n }\n });\n if (!childrenConstant) {\n return false;\n }\n return isFeatureConstant(expression) &&\n isGlobalPropertyConstant(expression, ['zoom', 'heatmap-density', 'line-progress', 'accumulated', 'is-supported-script']);\n}\nfunction isFeatureConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'get' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'feature-state') {\n return false;\n }\n else if (e.name === 'has' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'properties' ||\n e.name === 'geometry-type' ||\n e.name === 'id') {\n return false;\n }\n else if (/^filter-/.test(e.name)) {\n return false;\n }\n }\n if (e instanceof Within) {\n return false;\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isFeatureConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isStateConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'feature-state') {\n return false;\n }\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isStateConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isGlobalPropertyConstant(e, properties) {\n if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isGlobalPropertyConstant(arg, properties)) {\n result = false;\n }\n });\n return result;\n}\n\n/**\n * Returns the index of the last stop <= input, or 0 if it doesn't exist.\n * @private\n */\nfunction findStopLessThanOrEqualTo(stops, input) {\n const lastIndex = stops.length - 1;\n let lowerIndex = 0;\n let upperIndex = lastIndex;\n let currentIndex = 0;\n let currentValue, nextValue;\n while (lowerIndex <= upperIndex) {\n currentIndex = Math.floor((lowerIndex + upperIndex) / 2);\n currentValue = stops[currentIndex];\n nextValue = stops[currentIndex + 1];\n if (currentValue <= input) {\n if (currentIndex === lastIndex || input < nextValue) { // Search complete\n return currentIndex;\n }\n lowerIndex = currentIndex + 1;\n }\n else if (currentValue > input) {\n upperIndex = currentIndex - 1;\n }\n else {\n throw new RuntimeError('Input is not a number.');\n }\n }\n return 0;\n}\n\nclass Step {\n constructor(type, input, stops) {\n this.type = type;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static parse(args, context) {\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n const input = context.parse(args[1], 1, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 1; i < args.length; i += 2) {\n const label = i === 1 ? -Infinity : args[i];\n const value = args[i + 1];\n const labelKey = i;\n const valueKey = i + 1;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"step\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n return new Step(outputType, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n return outputs[index].evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n\n/**\n * Checks whether the specified color space is one of the supported interpolation color spaces.\n *\n * @param colorSpace Color space key to verify.\n * @returns `true` if the specified color space is one of the supported\n * interpolation color spaces, `false` otherwise\n */\nfunction isSupportedInterpolationColorSpace(colorSpace) {\n return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab';\n}\n/**\n * @param interpolationType Interpolation type\n * @returns interpolation fn\n * @deprecated use `interpolate[type]` instead\n */\nconst interpolateFactory = (interpolationType) => {\n switch (interpolationType) {\n case 'number': return number;\n case 'color': return color;\n case 'array': return array;\n case 'padding': return padding;\n case 'variableAnchorOffsetCollection': return variableAnchorOffsetCollection;\n }\n};\nfunction number(from, to, t) {\n return from + t * (to - from);\n}\nfunction color(from, to, t, spaceKey = 'rgb') {\n switch (spaceKey) {\n case 'rgb': {\n const [r, g, b, alpha] = array(from.rgb, to.rgb, t);\n return new Color(r, g, b, alpha, false);\n }\n case 'hcl': {\n const [hue0, chroma0, light0, alphaF] = from.hcl;\n const [hue1, chroma1, light1, alphaT] = to.hcl;\n // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js\n let hue, chroma;\n if (!isNaN(hue0) && !isNaN(hue1)) {\n let dh = hue1 - hue0;\n if (hue1 > hue0 && dh > 180) {\n dh -= 360;\n }\n else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh += 360;\n }\n hue = hue0 + t * dh;\n }\n else if (!isNaN(hue0)) {\n hue = hue0;\n if (light1 === 1 || light1 === 0)\n chroma = chroma0;\n }\n else if (!isNaN(hue1)) {\n hue = hue1;\n if (light0 === 1 || light0 === 0)\n chroma = chroma1;\n }\n else {\n hue = NaN;\n }\n const [r, g, b, alpha] = hclToRgb([\n hue,\n chroma !== null && chroma !== void 0 ? chroma : number(chroma0, chroma1, t),\n number(light0, light1, t),\n number(alphaF, alphaT, t),\n ]);\n return new Color(r, g, b, alpha, false);\n }\n case 'lab': {\n const [r, g, b, alpha] = labToRgb(array(from.lab, to.lab, t));\n return new Color(r, g, b, alpha, false);\n }\n }\n}\nfunction array(from, to, t) {\n return from.map((d, i) => {\n return number(d, to[i], t);\n });\n}\nfunction padding(from, to, t) {\n return new Padding(array(from.values, to.values, t));\n}\nfunction variableAnchorOffsetCollection(from, to, t) {\n const fromValues = from.values;\n const toValues = to.values;\n if (fromValues.length !== toValues.length) {\n throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`);\n }\n const output = [];\n for (let i = 0; i < fromValues.length; i += 2) {\n // Anchor entries must match\n if (fromValues[i] !== toValues[i]) {\n throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`);\n }\n output.push(fromValues[i]);\n // Interpolate the offset values for each anchor\n const [fx, fy] = fromValues[i + 1];\n const [tx, ty] = toValues[i + 1];\n output.push([number(fx, tx, t), number(fy, ty, t)]);\n }\n return new VariableAnchorOffsetCollection(output);\n}\nconst interpolate = {\n number,\n color,\n array,\n padding,\n variableAnchorOffsetCollection\n};\n\nclass Interpolate {\n constructor(type, operator, interpolation, input, stops) {\n this.type = type;\n this.operator = operator;\n this.interpolation = interpolation;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static interpolationFactor(interpolation, input, lower, upper) {\n let t = 0;\n if (interpolation.name === 'exponential') {\n t = exponentialInterpolation(input, interpolation.base, lower, upper);\n }\n else if (interpolation.name === 'linear') {\n t = exponentialInterpolation(input, 1, lower, upper);\n }\n else if (interpolation.name === 'cubic-bezier') {\n const c = interpolation.controlPoints;\n const ub = new UnitBezier(c[0], c[1], c[2], c[3]);\n t = ub.solve(exponentialInterpolation(input, 1, lower, upper));\n }\n return t;\n }\n static parse(args, context) {\n let [operator, interpolation, input, ...rest] = args;\n if (!Array.isArray(interpolation) || interpolation.length === 0) {\n return context.error('Expected an interpolation type expression.', 1);\n }\n if (interpolation[0] === 'linear') {\n interpolation = { name: 'linear' };\n }\n else if (interpolation[0] === 'exponential') {\n const base = interpolation[1];\n if (typeof base !== 'number')\n return context.error('Exponential interpolation requires a numeric base.', 1, 1);\n interpolation = {\n name: 'exponential',\n base\n };\n }\n else if (interpolation[0] === 'cubic-bezier') {\n const controlPoints = interpolation.slice(1);\n if (controlPoints.length !== 4 ||\n controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)) {\n return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);\n }\n interpolation = {\n name: 'cubic-bezier',\n controlPoints: controlPoints\n };\n }\n else {\n return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);\n }\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n input = context.parse(input, 2, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {\n outputType = ColorType;\n }\n else if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 0; i < rest.length; i += 2) {\n const label = rest[i];\n const value = rest[i + 1];\n const labelKey = i + 3;\n const valueKey = i + 4;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"interpolate\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n if (!verifyType(outputType, NumberType) &&\n !verifyType(outputType, ColorType) &&\n !verifyType(outputType, PaddingType) &&\n !verifyType(outputType, VariableAnchorOffsetCollectionType) &&\n !verifyType(outputType, array$1(NumberType))) {\n return context.error(`Type ${toString$1(outputType)} is not interpolatable.`);\n }\n return new Interpolate(outputType, operator, interpolation, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n const lower = labels[index];\n const upper = labels[index + 1];\n const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);\n const outputLower = outputs[index].evaluate(ctx);\n const outputUpper = outputs[index + 1].evaluate(ctx);\n switch (this.operator) {\n case 'interpolate':\n return interpolate[this.type.kind](outputLower, outputUpper, t);\n case 'interpolate-hcl':\n return interpolate.color(outputLower, outputUpper, t, 'hcl');\n case 'interpolate-lab':\n return interpolate.color(outputLower, outputUpper, t, 'lab');\n }\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n*/\nfunction exponentialInterpolation(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass Coalesce {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expectected at least one argument.');\n }\n let outputType = null;\n const expectedType = context.expectedType;\n if (expectedType && expectedType.kind !== 'value') {\n outputType = expectedType;\n }\n const parsedArgs = [];\n for (const arg of args.slice(1)) {\n const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' });\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n parsedArgs.push(parsed);\n }\n if (!outputType)\n throw new Error('No output type');\n // Above, we parse arguments without inferred type annotation so that\n // they don't produce a runtime error for `null` input, which would\n // preempt the desired null-coalescing behavior.\n // Thus, if any of our arguments would have needed an annotation, we\n // need to wrap the enclosing coalesce expression with it instead.\n const needsAnnotation = expectedType &&\n parsedArgs.some(arg => checkSubtype(expectedType, arg.type));\n return needsAnnotation ?\n new Coalesce(ValueType, parsedArgs) :\n new Coalesce(outputType, parsedArgs);\n }\n evaluate(ctx) {\n let result = null;\n let argCount = 0;\n let requestedImageName;\n for (const arg of this.args) {\n argCount++;\n result = arg.evaluate(ctx);\n // we need to keep track of the first requested image in a coalesce statement\n // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire\n if (result && result instanceof ResolvedImage && !result.available) {\n if (!requestedImageName) {\n requestedImageName = result.name;\n }\n result = null;\n if (argCount === this.args.length) {\n result = requestedImageName;\n }\n }\n if (result !== null)\n break;\n }\n return result;\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nclass Let {\n constructor(bindings, result) {\n this.type = result.type;\n this.bindings = [].concat(bindings);\n this.result = result;\n }\n evaluate(ctx) {\n return this.result.evaluate(ctx);\n }\n eachChild(fn) {\n for (const binding of this.bindings) {\n fn(binding[1]);\n }\n fn(this.result);\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);\n const bindings = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const name = args[i];\n if (typeof name !== 'string') {\n return context.error(`Expected string, but found ${typeof name} instead.`, i);\n }\n if (/[^a-zA-Z0-9_]/.test(name)) {\n return context.error('Variable names must contain only alphanumeric characters or \\'_\\'.', i);\n }\n const value = context.parse(args[i + 1], i + 1);\n if (!value)\n return null;\n bindings.push([name, value]);\n }\n const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);\n if (!result)\n return null;\n return new Let(bindings, result);\n }\n outputDefined() {\n return this.result.outputDefined();\n }\n}\n\nclass At {\n constructor(type, index, input) {\n this.type = type;\n this.index = index;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n const index = context.parse(args[1], 1, NumberType);\n const input = context.parse(args[2], 2, array$1(context.expectedType || ValueType));\n if (!index || !input)\n return null;\n const t = input.type;\n return new At(t.itemType, index, input);\n }\n evaluate(ctx) {\n const index = this.index.evaluate(ctx);\n const array = this.input.evaluate(ctx);\n if (index < 0) {\n throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);\n }\n if (index >= array.length) {\n throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);\n }\n if (index !== Math.floor(index)) {\n throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);\n }\n return array[index];\n }\n eachChild(fn) {\n fn(this.index);\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nclass In {\n constructor(needle, haystack) {\n this.type = BooleanType;\n this.needle = needle;\n this.haystack = haystack;\n }\n static parse(args, context) {\n if (args.length !== 3) {\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n return new In(needle, haystack);\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!haystack)\n return false;\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n return haystack.indexOf(needle) >= 0;\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n }\n outputDefined() {\n return true;\n }\n}\n\nclass IndexOf {\n constructor(needle, haystack, fromIndex) {\n this.type = NumberType;\n this.needle = needle;\n this.haystack = haystack;\n this.fromIndex = fromIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n if (args.length === 4) {\n const fromIndex = context.parse(args[3], 3, NumberType);\n if (!fromIndex)\n return null;\n return new IndexOf(needle, haystack, fromIndex);\n }\n else {\n return new IndexOf(needle, haystack);\n }\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n if (this.fromIndex) {\n const fromIndex = this.fromIndex.evaluate(ctx);\n return haystack.indexOf(needle, fromIndex);\n }\n return haystack.indexOf(needle);\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n if (this.fromIndex) {\n fn(this.fromIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass Match {\n constructor(inputType, outputType, input, cases, outputs, otherwise) {\n this.inputType = inputType;\n this.type = outputType;\n this.input = input;\n this.cases = cases;\n this.outputs = outputs;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 5)\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 1)\n return context.error('Expected an even number of arguments.');\n let inputType;\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const cases = {};\n const outputs = [];\n for (let i = 2; i < args.length - 1; i += 2) {\n let labels = args[i];\n const value = args[i + 1];\n if (!Array.isArray(labels)) {\n labels = [labels];\n }\n const labelContext = context.concat(i);\n if (labels.length === 0) {\n return labelContext.error('Expected at least one branch label.');\n }\n for (const label of labels) {\n if (typeof label !== 'number' && typeof label !== 'string') {\n return labelContext.error('Branch labels must be numbers or strings.');\n }\n else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {\n return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);\n }\n else if (typeof label === 'number' && Math.floor(label) !== label) {\n return labelContext.error('Numeric branch labels must be integer values.');\n }\n else if (!inputType) {\n inputType = typeOf(label);\n }\n else if (labelContext.checkSubtype(inputType, typeOf(label))) {\n return null;\n }\n if (typeof cases[String(label)] !== 'undefined') {\n return labelContext.error('Branch labels must be unique.');\n }\n cases[String(label)] = outputs.length;\n }\n const result = context.parse(value, i, outputType);\n if (!result)\n return null;\n outputType = outputType || result.type;\n outputs.push(result);\n }\n const input = context.parse(args[1], 1, ValueType);\n if (!input)\n return null;\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {\n return null;\n }\n return new Match(inputType, outputType, input, cases, outputs, otherwise);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;\n return output.evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n this.outputs.forEach(fn);\n fn(this.otherwise);\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Case {\n constructor(type, branches, otherwise) {\n this.type = type;\n this.branches = branches;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 0)\n return context.error('Expected an odd number of arguments.');\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const branches = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const test = context.parse(args[i], i, BooleanType);\n if (!test)\n return null;\n const result = context.parse(args[i + 1], i + 1, outputType);\n if (!result)\n return null;\n branches.push([test, result]);\n outputType = outputType || result.type;\n }\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (!outputType)\n throw new Error('Can\\'t infer output type');\n return new Case(outputType, branches, otherwise);\n }\n evaluate(ctx) {\n for (const [test, expression] of this.branches) {\n if (test.evaluate(ctx)) {\n return expression.evaluate(ctx);\n }\n }\n return this.otherwise.evaluate(ctx);\n }\n eachChild(fn) {\n for (const [test, expression] of this.branches) {\n fn(test);\n fn(expression);\n }\n fn(this.otherwise);\n }\n outputDefined() {\n return this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Slice {\n constructor(type, input, beginIndex, endIndex) {\n this.type = type;\n this.input = input;\n this.beginIndex = beginIndex;\n this.endIndex = endIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const input = context.parse(args[1], 1, ValueType);\n const beginIndex = context.parse(args[2], 2, NumberType);\n if (!input || !beginIndex)\n return null;\n if (!isValidType(input.type, [array$1(ValueType), StringType, ValueType])) {\n return context.error(`Expected first argument to be of type array or string, but found ${toString$1(input.type)} instead`);\n }\n if (args.length === 4) {\n const endIndex = context.parse(args[3], 3, NumberType);\n if (!endIndex)\n return null;\n return new Slice(input.type, input, beginIndex, endIndex);\n }\n else {\n return new Slice(input.type, input, beginIndex);\n }\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const beginIndex = this.beginIndex.evaluate(ctx);\n if (!isValidNativeType(input, ['string', 'array'])) {\n throw new RuntimeError(`Expected first argument to be of type array or string, but found ${toString$1(typeOf(input))} instead.`);\n }\n if (this.endIndex) {\n const endIndex = this.endIndex.evaluate(ctx);\n return input.slice(beginIndex, endIndex);\n }\n return input.slice(beginIndex);\n }\n eachChild(fn) {\n fn(this.input);\n fn(this.beginIndex);\n if (this.endIndex) {\n fn(this.endIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nfunction isComparableType(op, type) {\n if (op === '==' || op === '!=') {\n // equality operator\n return type.kind === 'boolean' ||\n type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'null' ||\n type.kind === 'value';\n }\n else {\n // ordering operator\n return type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'value';\n }\n}\nfunction eq(ctx, a, b) { return a === b; }\nfunction neq(ctx, a, b) { return a !== b; }\nfunction lt(ctx, a, b) { return a < b; }\nfunction gt(ctx, a, b) { return a > b; }\nfunction lteq(ctx, a, b) { return a <= b; }\nfunction gteq(ctx, a, b) { return a >= b; }\nfunction eqCollate(ctx, a, b, c) { return c.compare(a, b) === 0; }\nfunction neqCollate(ctx, a, b, c) { return !eqCollate(ctx, a, b, c); }\nfunction ltCollate(ctx, a, b, c) { return c.compare(a, b) < 0; }\nfunction gtCollate(ctx, a, b, c) { return c.compare(a, b) > 0; }\nfunction lteqCollate(ctx, a, b, c) { return c.compare(a, b) <= 0; }\nfunction gteqCollate(ctx, a, b, c) { return c.compare(a, b) >= 0; }\n/**\n * Special form for comparison operators, implementing the signatures:\n * - (T, T, ?Collator) => boolean\n * - (T, value, ?Collator) => boolean\n * - (value, T, ?Collator) => boolean\n *\n * For inequalities, T must be either value, string, or number. For ==/!=, it\n * can also be boolean or null.\n *\n * Equality semantics are equivalent to Javascript's strict equality (===/!==)\n * -- i.e., when the arguments' types don't match, == evaluates to false, != to\n * true.\n *\n * When types don't match in an ordering comparison, a runtime error is thrown.\n *\n * @private\n */\nfunction makeComparison(op, compareBasic, compareWithCollator) {\n const isOrderComparison = op !== '==' && op !== '!=';\n return class Comparison {\n constructor(lhs, rhs, collator) {\n this.type = BooleanType;\n this.lhs = lhs;\n this.rhs = rhs;\n this.collator = collator;\n this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';\n }\n static parse(args, context) {\n if (args.length !== 3 && args.length !== 4)\n return context.error('Expected two or three arguments.');\n const op = args[0];\n let lhs = context.parse(args[1], 1, ValueType);\n if (!lhs)\n return null;\n if (!isComparableType(op, lhs.type)) {\n return context.concat(1).error(`\"${op}\" comparisons are not supported for type '${toString$1(lhs.type)}'.`);\n }\n let rhs = context.parse(args[2], 2, ValueType);\n if (!rhs)\n return null;\n if (!isComparableType(op, rhs.type)) {\n return context.concat(2).error(`\"${op}\" comparisons are not supported for type '${toString$1(rhs.type)}'.`);\n }\n if (lhs.type.kind !== rhs.type.kind &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`);\n }\n if (isOrderComparison) {\n // typing rules specific to less/greater than operators\n if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {\n // (value, T)\n lhs = new Assertion(rhs.type, [lhs]);\n }\n else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {\n // (T, value)\n rhs = new Assertion(lhs.type, [rhs]);\n }\n }\n let collator = null;\n if (args.length === 4) {\n if (lhs.type.kind !== 'string' &&\n rhs.type.kind !== 'string' &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error('Cannot use collator to compare non-string types.');\n }\n collator = context.parse(args[3], 3, CollatorType);\n if (!collator)\n return null;\n }\n return new Comparison(lhs, rhs, collator);\n }\n evaluate(ctx) {\n const lhs = this.lhs.evaluate(ctx);\n const rhs = this.rhs.evaluate(ctx);\n if (isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n // check that type is string or number, and equal\n if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {\n throw new RuntimeError(`Expected arguments for \"${op}\" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`);\n }\n }\n if (this.collator && !isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n if (lt.kind !== 'string' || rt.kind !== 'string') {\n return compareBasic(ctx, lhs, rhs);\n }\n }\n return this.collator ?\n compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) :\n compareBasic(ctx, lhs, rhs);\n }\n eachChild(fn) {\n fn(this.lhs);\n fn(this.rhs);\n if (this.collator) {\n fn(this.collator);\n }\n }\n outputDefined() {\n return true;\n }\n };\n}\nconst Equals = makeComparison('==', eq, eqCollate);\nconst NotEquals = makeComparison('!=', neq, neqCollate);\nconst LessThan = makeComparison('<', lt, ltCollate);\nconst GreaterThan = makeComparison('>', gt, gtCollate);\nconst LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);\nconst GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);\n\nclass NumberFormat {\n constructor(number, locale, currency, minFractionDigits, maxFractionDigits) {\n this.type = StringType;\n this.number = number;\n this.locale = locale;\n this.currency = currency;\n this.minFractionDigits = minFractionDigits;\n this.maxFractionDigits = maxFractionDigits;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error('Expected two arguments.');\n const number = context.parse(args[1], 1, NumberType);\n if (!number)\n return null;\n const options = args[2];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('NumberFormat options argument must be an object.');\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n let currency = null;\n if (options['currency']) {\n currency = context.parse(options['currency'], 1, StringType);\n if (!currency)\n return null;\n }\n let minFractionDigits = null;\n if (options['min-fraction-digits']) {\n minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);\n if (!minFractionDigits)\n return null;\n }\n let maxFractionDigits = null;\n if (options['max-fraction-digits']) {\n maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);\n if (!maxFractionDigits)\n return null;\n }\n return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);\n }\n evaluate(ctx) {\n return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {\n style: this.currency ? 'currency' : 'decimal',\n currency: this.currency ? this.currency.evaluate(ctx) : undefined,\n minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,\n maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,\n }).format(this.number.evaluate(ctx));\n }\n eachChild(fn) {\n fn(this.number);\n if (this.locale) {\n fn(this.locale);\n }\n if (this.currency) {\n fn(this.currency);\n }\n if (this.minFractionDigits) {\n fn(this.minFractionDigits);\n }\n if (this.maxFractionDigits) {\n fn(this.maxFractionDigits);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass FormatExpression {\n constructor(sections) {\n this.type = FormattedType;\n this.sections = sections;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n const firstArg = args[1];\n if (!Array.isArray(firstArg) && typeof firstArg === 'object') {\n return context.error('First argument must be an image or text section.');\n }\n const sections = [];\n let nextTokenMayBeObject = false;\n for (let i = 1; i <= args.length - 1; ++i) {\n const arg = args[i];\n if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) {\n nextTokenMayBeObject = false;\n let scale = null;\n if (arg['font-scale']) {\n scale = context.parse(arg['font-scale'], 1, NumberType);\n if (!scale)\n return null;\n }\n let font = null;\n if (arg['text-font']) {\n font = context.parse(arg['text-font'], 1, array$1(StringType));\n if (!font)\n return null;\n }\n let textColor = null;\n if (arg['text-color']) {\n textColor = context.parse(arg['text-color'], 1, ColorType);\n if (!textColor)\n return null;\n }\n const lastExpression = sections[sections.length - 1];\n lastExpression.scale = scale;\n lastExpression.font = font;\n lastExpression.textColor = textColor;\n }\n else {\n const content = context.parse(args[i], 1, ValueType);\n if (!content)\n return null;\n const kind = content.type.kind;\n if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage')\n return context.error('Formatted text type must be \\'string\\', \\'value\\', \\'image\\' or \\'null\\'.');\n nextTokenMayBeObject = true;\n sections.push({ content, scale: null, font: null, textColor: null });\n }\n }\n return new FormatExpression(sections);\n }\n evaluate(ctx) {\n const evaluateSection = section => {\n const evaluatedContent = section.content.evaluate(ctx);\n if (typeOf(evaluatedContent) === ResolvedImageType) {\n return new FormattedSection('', evaluatedContent, null, null, null);\n }\n return new FormattedSection(toString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null);\n };\n return new Formatted(this.sections.map(evaluateSection));\n }\n eachChild(fn) {\n for (const section of this.sections) {\n fn(section.content);\n if (section.scale) {\n fn(section.scale);\n }\n if (section.font) {\n fn(section.font);\n }\n if (section.textColor) {\n fn(section.textColor);\n }\n }\n }\n outputDefined() {\n // Technically the combinatoric set of all children\n // Usually, this.text will be undefined anyway\n return false;\n }\n}\n\nclass ImageExpression {\n constructor(input) {\n this.type = ResolvedImageType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error('Expected two arguments.');\n }\n const name = context.parse(args[1], 1, StringType);\n if (!name)\n return context.error('No image name provided.');\n return new ImageExpression(name);\n }\n evaluate(ctx) {\n const evaluatedImageName = this.input.evaluate(ctx);\n const value = ResolvedImage.fromString(evaluatedImageName);\n if (value && ctx.availableImages)\n value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;\n return value;\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n // The output of image is determined by the list of available images in the evaluation context\n return false;\n }\n}\n\nclass Length {\n constructor(input) {\n this.type = NumberType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n const input = context.parse(args[1], 1);\n if (!input)\n return null;\n if (input.type.kind !== 'array' && input.type.kind !== 'string' && input.type.kind !== 'value')\n return context.error(`Expected argument of type string or array, but found ${toString$1(input.type)} instead.`);\n return new Length(input);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n if (typeof input === 'string') {\n return input.length;\n }\n else if (Array.isArray(input)) {\n return input.length;\n }\n else {\n throw new RuntimeError(`Expected value to be of type string or array, but found ${toString$1(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nconst expressions = {\n // special forms\n '==': Equals,\n '!=': NotEquals,\n '>': GreaterThan,\n '<': LessThan,\n '>=': GreaterThanOrEqual,\n '<=': LessThanOrEqual,\n 'array': Assertion,\n 'at': At,\n 'boolean': Assertion,\n 'case': Case,\n 'coalesce': Coalesce,\n 'collator': CollatorExpression,\n 'format': FormatExpression,\n 'image': ImageExpression,\n 'in': In,\n 'index-of': IndexOf,\n 'interpolate': Interpolate,\n 'interpolate-hcl': Interpolate,\n 'interpolate-lab': Interpolate,\n 'length': Length,\n 'let': Let,\n 'literal': Literal,\n 'match': Match,\n 'number': Assertion,\n 'number-format': NumberFormat,\n 'object': Assertion,\n 'slice': Slice,\n 'step': Step,\n 'string': Assertion,\n 'to-boolean': Coercion,\n 'to-color': Coercion,\n 'to-number': Coercion,\n 'to-string': Coercion,\n 'var': Var,\n 'within': Within\n};\nfunction rgba(ctx, [r, g, b, a]) {\n r = r.evaluate(ctx);\n g = g.evaluate(ctx);\n b = b.evaluate(ctx);\n const alpha = a ? a.evaluate(ctx) : 1;\n const error = validateRGBA(r, g, b, alpha);\n if (error)\n throw new RuntimeError(error);\n return new Color(r / 255, g / 255, b / 255, alpha, false);\n}\nfunction has(key, obj) {\n return key in obj;\n}\nfunction get(key, obj) {\n const v = obj[key];\n return typeof v === 'undefined' ? null : v;\n}\nfunction binarySearch(v, a, i, j) {\n while (i <= j) {\n const m = (i + j) >> 1;\n if (a[m] === v)\n return true;\n if (a[m] > v)\n j = m - 1;\n else\n i = m + 1;\n }\n return false;\n}\nfunction varargs(type) {\n return { type };\n}\nCompoundExpression.register(expressions, {\n 'error': [\n ErrorType,\n [StringType],\n (ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); }\n ],\n 'typeof': [\n StringType,\n [ValueType],\n (ctx, [v]) => toString$1(typeOf(v.evaluate(ctx)))\n ],\n 'to-rgba': [\n array$1(NumberType, 4),\n [ColorType],\n (ctx, [v]) => {\n const [r, g, b, a] = v.evaluate(ctx).rgb;\n return [r * 255, g * 255, b * 255, a];\n },\n ],\n 'rgb': [\n ColorType,\n [NumberType, NumberType, NumberType],\n rgba\n ],\n 'rgba': [\n ColorType,\n [NumberType, NumberType, NumberType, NumberType],\n rgba\n ],\n 'has': {\n type: BooleanType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'get': {\n type: ValueType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'feature-state': [\n ValueType,\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})\n ],\n 'properties': [\n ObjectType,\n [],\n (ctx) => ctx.properties()\n ],\n 'geometry-type': [\n StringType,\n [],\n (ctx) => ctx.geometryType()\n ],\n 'id': [\n ValueType,\n [],\n (ctx) => ctx.id()\n ],\n 'zoom': [\n NumberType,\n [],\n (ctx) => ctx.globals.zoom\n ],\n 'heatmap-density': [\n NumberType,\n [],\n (ctx) => ctx.globals.heatmapDensity || 0\n ],\n 'line-progress': [\n NumberType,\n [],\n (ctx) => ctx.globals.lineProgress || 0\n ],\n 'accumulated': [\n ValueType,\n [],\n (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated\n ],\n '+': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 0;\n for (const arg of args) {\n result += arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '*': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 1;\n for (const arg of args) {\n result *= arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '-': {\n type: NumberType,\n overloads: [\n [\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)\n ], [\n [NumberType],\n (ctx, [a]) => -a.evaluate(ctx)\n ]\n ]\n },\n '/': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)\n ],\n '%': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)\n ],\n 'ln2': [\n NumberType,\n [],\n () => Math.LN2\n ],\n 'pi': [\n NumberType,\n [],\n () => Math.PI\n ],\n 'e': [\n NumberType,\n [],\n () => Math.E\n ],\n '^': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))\n ],\n 'sqrt': [\n NumberType,\n [NumberType],\n (ctx, [x]) => Math.sqrt(x.evaluate(ctx))\n ],\n 'log10': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10\n ],\n 'ln': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx))\n ],\n 'log2': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2\n ],\n 'sin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.sin(n.evaluate(ctx))\n ],\n 'cos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.cos(n.evaluate(ctx))\n ],\n 'tan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.tan(n.evaluate(ctx))\n ],\n 'asin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.asin(n.evaluate(ctx))\n ],\n 'acos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.acos(n.evaluate(ctx))\n ],\n 'atan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.atan(n.evaluate(ctx))\n ],\n 'min': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'max': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'abs': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.abs(n.evaluate(ctx))\n ],\n 'round': [\n NumberType,\n [NumberType],\n (ctx, [n]) => {\n const v = n.evaluate(ctx);\n // Javascript's Math.round() rounds towards +Infinity for halfway\n // values, even when they're negative. It's more common to round\n // away from 0 (e.g., this is what python and C++ do)\n return v < 0 ? -Math.round(-v) : Math.round(v);\n }\n ],\n 'floor': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.floor(n.evaluate(ctx))\n ],\n 'ceil': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.ceil(n.evaluate(ctx))\n ],\n 'filter-==': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => ctx.properties()[k.value] === v.value\n ],\n 'filter-id-==': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => ctx.id() === v.value\n ],\n 'filter-type-==': [\n BooleanType,\n [StringType],\n (ctx, [v]) => ctx.geometryType() === v.value\n ],\n 'filter-<': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter-id-<': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter->': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-id->': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-<=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter-id-<=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter->=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-id->=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-has': [\n BooleanType,\n [ValueType],\n (ctx, [k]) => k.value in ctx.properties()\n ],\n 'filter-has-id': [\n BooleanType,\n [],\n (ctx) => (ctx.id() !== null && ctx.id() !== undefined)\n ],\n 'filter-type-in': [\n BooleanType,\n [array$1(StringType)],\n (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0\n ],\n 'filter-id-in': [\n BooleanType,\n [array$1(ValueType)],\n (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0\n ],\n 'filter-in-small': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is an array literal\n (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0\n ],\n 'filter-in-large': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is a array literal with values sorted in ascending order and of a single type\n (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)\n ],\n 'all': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (!arg.evaluate(ctx))\n return false;\n }\n return true;\n }\n ]\n ]\n },\n 'any': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (arg.evaluate(ctx))\n return true;\n }\n return false;\n }\n ]\n ]\n },\n '!': [\n BooleanType,\n [BooleanType],\n (ctx, [b]) => !b.evaluate(ctx)\n ],\n 'is-supported-script': [\n BooleanType,\n [StringType],\n // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant\n (ctx, [s]) => {\n const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;\n if (isSupportedScript) {\n return isSupportedScript(s.evaluate(ctx));\n }\n return true;\n }\n ],\n 'upcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toUpperCase()\n ],\n 'downcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toLowerCase()\n ],\n 'concat': [\n StringType,\n varargs(ValueType),\n (ctx, args) => args.map(arg => toString(arg.evaluate(ctx))).join('')\n ],\n 'resolved-locale': [\n StringType,\n [CollatorType],\n (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()\n ]\n});\n\nfunction success(value) {\n return { result: 'success', value };\n}\nfunction error(value) {\n return { result: 'error', value };\n}\n\nfunction supportsPropertyExpression(spec) {\n return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven';\n}\nfunction supportsZoomExpression(spec) {\n return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;\n}\nfunction supportsInterpolation(spec) {\n return !!spec.expression && spec.expression.interpolated;\n}\n\nfunction getType(val) {\n if (val instanceof Number) {\n return 'number';\n }\n else if (val instanceof String) {\n return 'string';\n }\n else if (val instanceof Boolean) {\n return 'boolean';\n }\n else if (Array.isArray(val)) {\n return 'array';\n }\n else if (val === null) {\n return 'null';\n }\n else {\n return typeof val;\n }\n}\n\nfunction isFunction(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\nfunction identityFunction(x) {\n return x;\n}\nfunction createFunction(parameters, propertySpec) {\n const isColor = propertySpec.type === 'color';\n const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');\n if (isColor || propertySpec.type === 'padding') {\n const parseFn = isColor ? Color.parse : Padding.parse;\n parameters = extendBy({}, parameters);\n if (parameters.stops) {\n parameters.stops = parameters.stops.map((stop) => {\n return [stop[0], parseFn(stop[1])];\n });\n }\n if (parameters.default) {\n parameters.default = parseFn(parameters.default);\n }\n else {\n parameters.default = parseFn(propertySpec.default);\n }\n }\n if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) {\n throw new Error(`Unknown color space: \"${parameters.colorSpace}\"`);\n }\n let innerFun;\n let hashedStops;\n let categoricalKeyType;\n if (type === 'exponential') {\n innerFun = evaluateExponentialFunction;\n }\n else if (type === 'interval') {\n innerFun = evaluateIntervalFunction;\n }\n else if (type === 'categorical') {\n innerFun = evaluateCategoricalFunction;\n // For categorical functions, generate an Object as a hashmap of the stops for fast searching\n hashedStops = Object.create(null);\n for (const stop of parameters.stops) {\n hashedStops[stop[0]] = stop[1];\n }\n // Infer key type based on first stop key-- used to encforce strict type checking later\n categoricalKeyType = typeof parameters.stops[0][0];\n }\n else if (type === 'identity') {\n innerFun = evaluateIdentityFunction;\n }\n else {\n throw new Error(`Unknown function type \"${type}\"`);\n }\n if (zoomAndFeatureDependent) {\n const featureFunctions = {};\n const zoomStops = [];\n for (let s = 0; s < parameters.stops.length; s++) {\n const stop = parameters.stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctions[zoom] === undefined) {\n featureFunctions[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n stops: []\n };\n zoomStops.push(zoom);\n }\n featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);\n }\n const featureFunctionStops = [];\n for (const z of zoomStops) {\n featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);\n }\n const interpolationType = { name: 'linear' };\n return {\n kind: 'composite',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: featureFunctionStops.map(s => s[0]),\n evaluate({ zoom }, properties) {\n return evaluateExponentialFunction({\n stops: featureFunctionStops,\n base: parameters.base\n }, propertySpec, zoom).evaluate(zoom, properties);\n }\n };\n }\n else if (zoomDependent) {\n const interpolationType = type === 'exponential' ?\n { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 } : null;\n return {\n kind: 'camera',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: parameters.stops.map(s => s[0]),\n evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)\n };\n }\n else {\n return {\n kind: 'source',\n evaluate(_, feature) {\n const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;\n if (value === undefined) {\n return coalesce$1(parameters.default, propertySpec.default);\n }\n return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);\n }\n };\n }\n}\nfunction coalesce$1(a, b, c) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n if (c !== undefined)\n return c;\n}\nfunction evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {\n const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input\n return coalesce$1(evaluated, parameters.default, propertySpec.default);\n}\nfunction evaluateIntervalFunction(parameters, propertySpec, input) {\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n return parameters.stops[index][1];\n}\nfunction evaluateExponentialFunction(parameters, propertySpec, input) {\n const base = parameters.base !== undefined ? parameters.base : 1;\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);\n const outputLower = parameters.stops[index][1];\n const outputUpper = parameters.stops[index + 1][1];\n const interp = interpolate[propertySpec.type] || identityFunction;\n if (typeof outputLower.evaluate === 'function') {\n return {\n evaluate(...args) {\n const evaluatedLower = outputLower.evaluate.apply(undefined, args);\n const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);\n // Special case for fill-outline-color, which has no spec default.\n if (evaluatedLower === undefined || evaluatedUpper === undefined) {\n return undefined;\n }\n return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace);\n }\n };\n }\n return interp(outputLower, outputUpper, t, parameters.colorSpace);\n}\nfunction evaluateIdentityFunction(parameters, propertySpec, input) {\n switch (propertySpec.type) {\n case 'color':\n input = Color.parse(input);\n break;\n case 'formatted':\n input = Formatted.fromString(input.toString());\n break;\n case 'resolvedImage':\n input = ResolvedImage.fromString(input.toString());\n break;\n case 'padding':\n input = Padding.parse(input);\n break;\n default:\n if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {\n input = undefined;\n }\n }\n return coalesce$1(input, parameters.default, propertySpec.default);\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n *\n * How it works:\n * Two consecutive stop values define a (scaled and shifted) exponential\n * function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction interpolationFactor(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass StyleExpression {\n constructor(expression, propertySpec) {\n this.expression = expression;\n this._warningHistory = {};\n this._evaluator = new EvaluationContext();\n this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;\n this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature;\n this._evaluator.featureState = featureState;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection;\n return this.expression.evaluate(this._evaluator);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature || null;\n this._evaluator.featureState = featureState || null;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection || null;\n try {\n const val = this.expression.evaluate(this._evaluator);\n // eslint-disable-next-line no-self-compare\n if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {\n return this._defaultValue;\n }\n if (this._enumValues && !(val in this._enumValues)) {\n throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);\n }\n return val;\n }\n catch (e) {\n if (!this._warningHistory[e.message]) {\n this._warningHistory[e.message] = true;\n if (typeof console !== 'undefined') {\n console.warn(e.message);\n }\n }\n return this._defaultValue;\n }\n }\n}\nfunction isExpression(expression) {\n return Array.isArray(expression) && expression.length > 0 &&\n typeof expression[0] === 'string' && expression[0] in expressions;\n}\n/**\n * Parse and typecheck the given style spec JSON expression. If\n * options.defaultValue is provided, then the resulting StyleExpression's\n * `evaluate()` method will handle errors by logging a warning (once per\n * message) and returning the default value. Otherwise, it will throw\n * evaluation errors.\n *\n * @private\n */\nfunction createExpression(expression, propertySpec) {\n const parser = new ParsingContext(expressions, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined);\n // For string-valued properties, coerce to string at the top level rather than asserting.\n const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);\n if (!parsed) {\n return error(parser.errors);\n }\n return success(new StyleExpression(parsed, propertySpec));\n}\nclass ZoomConstantExpression {\n constructor(kind, expression) {\n this.kind = kind;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'constant' && !isStateConstant(expression.expression);\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n}\nclass ZoomDependentExpression {\n constructor(kind, expression, zoomStops, interpolationType) {\n this.kind = kind;\n this.zoomStops = zoomStops;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'camera' && !isStateConstant(expression.expression);\n this.interpolationType = interpolationType;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n interpolationFactor(input, lower, upper) {\n if (this.interpolationType) {\n return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);\n }\n else {\n return 0;\n }\n }\n}\nfunction isZoomExpression(expression) {\n return expression._styleExpression !== undefined;\n}\nfunction createPropertyExpression(expressionInput, propertySpec) {\n const expression = createExpression(expressionInput, propertySpec);\n if (expression.result === 'error') {\n return expression;\n }\n const parsed = expression.value.expression;\n const isFeatureConstantResult = isFeatureConstant(parsed);\n if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'data expressions not supported')]);\n }\n const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']);\n if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'zoom expressions not supported')]);\n }\n const zoomCurve = findZoomCurve(parsed);\n if (!zoomCurve && !isZoomConstant) {\n return error([new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.')]);\n }\n else if (zoomCurve instanceof ExpressionParsingError) {\n return error([zoomCurve]);\n }\n else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {\n return error([new ExpressionParsingError('', '\"interpolate\" expressions cannot be used with this property')]);\n }\n if (!zoomCurve) {\n return success(isFeatureConstantResult ?\n new ZoomConstantExpression('constant', expression.value) :\n new ZoomConstantExpression('source', expression.value));\n }\n const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;\n return success(isFeatureConstantResult ?\n new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType) :\n new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType));\n}\n// serialization wrapper for old-style stop functions normalized to the\n// expression interface\nclass StylePropertyFunction {\n constructor(parameters, specification) {\n this._parameters = parameters;\n this._specification = specification;\n extendBy(this, createFunction(this._parameters, this._specification));\n }\n static deserialize(serialized) {\n return new StylePropertyFunction(serialized._parameters, serialized._specification);\n }\n static serialize(input) {\n return {\n _parameters: input._parameters,\n _specification: input._specification\n };\n }\n}\nfunction normalizePropertyExpression(value, specification) {\n if (isFunction(value)) {\n return new StylePropertyFunction(value, specification);\n }\n else if (isExpression(value)) {\n const expression = createPropertyExpression(value, specification);\n if (expression.result === 'error') {\n // this should have been caught in validation\n throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n return expression.value;\n }\n else {\n let constant = value;\n if (specification.type === 'color' && typeof value === 'string') {\n constant = Color.parse(value);\n }\n else if (specification.type === 'padding' && (typeof value === 'number' || Array.isArray(value))) {\n constant = Padding.parse(value);\n }\n else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) {\n constant = VariableAnchorOffsetCollection.parse(value);\n }\n return {\n kind: 'constant',\n evaluate: () => constant\n };\n }\n}\n// Zoom-dependent expressions may only use [\"zoom\"] as the input to a top-level \"step\" or \"interpolate\"\n// expression (collectively referred to as a \"curve\"). The curve may be wrapped in one or more \"let\" or\n// \"coalesce\" expressions.\nfunction findZoomCurve(expression) {\n let result = null;\n if (expression instanceof Let) {\n result = findZoomCurve(expression.result);\n }\n else if (expression instanceof Coalesce) {\n for (const arg of expression.args) {\n result = findZoomCurve(arg);\n if (result) {\n break;\n }\n }\n }\n else if ((expression instanceof Step || expression instanceof Interpolate) &&\n expression.input instanceof CompoundExpression &&\n expression.input.name === 'zoom') {\n result = expression;\n }\n if (result instanceof ExpressionParsingError) {\n return result;\n }\n expression.eachChild((child) => {\n const childResult = findZoomCurve(child);\n if (childResult instanceof ExpressionParsingError) {\n result = childResult;\n }\n else if (!result && childResult) {\n result = new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.');\n }\n else if (result && childResult && result !== childResult) {\n result = new ExpressionParsingError('', 'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.');\n }\n });\n return result;\n}\nfunction getExpectedType(spec) {\n const types = {\n color: ColorType,\n string: StringType,\n number: NumberType,\n enum: StringType,\n boolean: BooleanType,\n formatted: FormattedType,\n padding: PaddingType,\n resolvedImage: ResolvedImageType,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType\n };\n if (spec.type === 'array') {\n return array$1(types[spec.value] || ValueType, spec.length);\n }\n return types[spec.type];\n}\nfunction getDefaultValue(spec) {\n if (spec.type === 'color' && isFunction(spec.default)) {\n // Special case for heatmap-color: it uses the 'default:' to define a\n // default color ramp, but createExpression expects a simple value to fall\n // back to in case of runtime errors\n return new Color(0, 0, 0, 0);\n }\n else if (spec.type === 'color') {\n return Color.parse(spec.default) || null;\n }\n else if (spec.type === 'padding') {\n return Padding.parse(spec.default) || null;\n }\n else if (spec.type === 'variableAnchorOffsetCollection') {\n return VariableAnchorOffsetCollection.parse(spec.default) || null;\n }\n else if (spec.default === undefined) {\n return null;\n }\n else {\n return spec.default;\n }\n}\n\nfunction isExpressionFilter(filter) {\n if (filter === true || filter === false) {\n return true;\n }\n if (!Array.isArray(filter) || filter.length === 0) {\n return false;\n }\n switch (filter[0]) {\n case 'has':\n return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';\n case 'in':\n return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2]));\n case '!in':\n case '!has':\n case 'none':\n return false;\n case '==':\n case '!=':\n case '>':\n case '>=':\n case '<':\n case '<=':\n return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2]));\n case 'any':\n case 'all':\n for (const f of filter.slice(1)) {\n if (!isExpressionFilter(f) && typeof f !== 'boolean') {\n return false;\n }\n }\n return true;\n default:\n return true;\n }\n}\nconst filterSpec = {\n 'type': 'boolean',\n 'default': false,\n 'transition': false,\n 'property-type': 'data-driven',\n 'expression': {\n 'interpolated': false,\n 'parameters': ['zoom', 'feature']\n }\n};\n/**\n * Given a filter expressed as nested arrays, return a new function\n * that evaluates whether a given feature (with a .properties or .tags property)\n * passes its test.\n *\n * @private\n * @param {Array} filter MapLibre filter\n * @returns {Function} filter-evaluating function\n */\nfunction createFilter(filter) {\n if (filter === null || filter === undefined) {\n return { filter: () => true, needGeometry: false };\n }\n if (!isExpressionFilter(filter)) {\n filter = convertFilter$1(filter);\n }\n const compiled = createExpression(filter, filterSpec);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n else {\n const needGeometry = geometryNeeded(filter);\n return { filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical),\n needGeometry };\n }\n}\n// Comparison function to sort numbers and strings\nfunction compare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\nfunction geometryNeeded(filter) {\n if (!Array.isArray(filter))\n return false;\n if (filter[0] === 'within')\n return true;\n for (let index = 1; index < filter.length; index++) {\n if (geometryNeeded(filter[index]))\n return true;\n }\n return false;\n}\nfunction convertFilter$1(filter) {\n if (!filter)\n return true;\n const op = filter[0];\n if (filter.length <= 1)\n return (op !== 'any');\n const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') :\n op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) :\n op === '<' ||\n op === '>' ||\n op === '<=' ||\n op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) :\n op === 'any' ? convertDisjunctionOp(filter.slice(1)) :\n op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) :\n op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) :\n op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) :\n op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) :\n op === 'has' ? convertHasOp$1(filter[1]) :\n op === '!has' ? convertNegation(convertHasOp$1(filter[1])) :\n op === 'within' ? filter :\n true;\n return converted;\n}\nfunction convertComparisonOp$1(property, value, op) {\n switch (property) {\n case '$type':\n return [`filter-type-${op}`, value];\n case '$id':\n return [`filter-id-${op}`, value];\n default:\n return [`filter-${op}`, property, value];\n }\n}\nfunction convertDisjunctionOp(filters) {\n return ['any'].concat(filters.map(convertFilter$1));\n}\nfunction convertInOp$1(property, values) {\n if (values.length === 0) {\n return false;\n }\n switch (property) {\n case '$type':\n return ['filter-type-in', ['literal', values]];\n case '$id':\n return ['filter-id-in', ['literal', values]];\n default:\n if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) {\n return ['filter-in-large', property, ['literal', values.sort(compare)]];\n }\n else {\n return ['filter-in-small', property, ['literal', values]];\n }\n }\n}\nfunction convertHasOp$1(property) {\n switch (property) {\n case '$type':\n return true;\n case '$id':\n return ['filter-has-id'];\n default:\n return ['filter-has', property];\n }\n}\nfunction convertNegation(filter) {\n return ['!', filter];\n}\n\n/*\n * Convert the given filter to an expression, storing the expected types for\n * any feature properties referenced in expectedTypes.\n *\n * These expected types are needed in order to construct preflight type checks\n * needed for handling 'any' filters. A preflight type check is necessary in\n * order to mimic legacy filters' semantics around expected type mismatches.\n * For example, consider the legacy filter:\n *\n * [\"any\", [\"all\", [\">\", \"y\", 0], [\">\", \"y\", 0]], [\">\", \"x\", 0]]\n *\n * Naively, we might convert this to the expression:\n *\n * [\"any\", [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]], [\">\", [\"get\", \"x\"], 0]]\n *\n * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the\n * [\">\", [\"get\", \"y\"], 0] would cause an evaluation error, leading to the\n * entire filter returning false. Legacy filter semantics, though, ask for\n * [\">\", \"y\", 0] to simply return `false` when `y` is of the wrong type,\n * allowing the subsequent terms of the outer \"any\" expression to be evaluated\n * (resulting, in this case, in a `true` value, because x > 0).\n *\n * We account for this by inserting a preflight type-checking expression before\n * each \"any\" term, allowing us to avoid evaluating the actual converted filter\n * if any type mismatches would cause it to produce an evalaution error:\n *\n * [\"any\",\n * [\"case\",\n * [\"all\", [\"==\", [\"typeof\", [\"get\", \"y\"]], \"number\"], [\"==\", [\"typeof\", [\"get\", \"z\"], \"number]],\n * [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]],\n * false\n * ],\n * [\"case\",\n * [\"==\", [\"typeof\", [\"get\", \"x\"], \"number\"]],\n * [\">\", [\"get\", \"x\"], 0],\n * false\n * ]\n * ]\n *\n * An alternative, possibly more direct approach would be to use type checks\n * in the conversion of each comparison operator, so that the converted version\n * of each individual ==, >=, etc. would mimic the legacy filter semantics. The\n * downside of this approach is that it can lead to many more type checks than\n * would otherwise be necessary: outside the context of an \"any\" expression,\n * bailing out due to a runtime type error (expression semantics) and returning\n * false (legacy filter semantics) are equivalent: they cause the filter to\n * produce a `false` result.\n */\nfunction convertFilter(filter, expectedTypes = {}) {\n if (isExpressionFilter(filter))\n return filter;\n if (!filter)\n return true;\n const legacyFilter = filter;\n const legacyOp = legacyFilter[0];\n if (filter.length <= 1)\n return (legacyOp !== 'any');\n switch (legacyOp) {\n case '==':\n case '!=':\n case '<':\n case '>':\n case '<=':\n case '>=': {\n const [, property, value] = filter;\n return convertComparisonOp(property, value, legacyOp, expectedTypes);\n }\n case 'any': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => {\n const types = {};\n const child = convertFilter(f, types);\n const typechecks = runtimeTypeChecks(types);\n return typechecks === true ? child : ['case', typechecks, child, false];\n });\n return ['any', ...children];\n }\n case 'all': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map(f => convertFilter(f, expectedTypes));\n return children.length > 1 ? ['all', ...children] : children[0];\n }\n case 'none': {\n const [, ...conditions] = legacyFilter;\n return ['!', convertFilter(['any', ...conditions], {})];\n }\n case 'in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values);\n }\n case '!in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values, true);\n }\n case 'has':\n return convertHasOp(legacyFilter[1]);\n case '!has':\n return ['!', convertHasOp(legacyFilter[1])];\n default:\n return true;\n }\n}\n// Given a set of feature properties and an expected type for each one,\n// construct an boolean expression that tests whether each property has the\n// right type.\n// E.g.: for {name: 'string', population: 'number'}, return\n// [ 'all',\n// ['==', ['typeof', ['get', 'name'], 'string']],\n// ['==', ['typeof', ['get', 'population'], 'number]]\n// ]\nfunction runtimeTypeChecks(expectedTypes) {\n const conditions = [];\n for (const property in expectedTypes) {\n const get = property === '$id' ? ['id'] : ['get', property];\n conditions.push(['==', ['typeof', get], expectedTypes[property]]);\n }\n if (conditions.length === 0)\n return true;\n if (conditions.length === 1)\n return conditions[0];\n return ['all', ...conditions];\n}\nfunction convertComparisonOp(property, value, op, expectedTypes) {\n let get;\n if (property === '$type') {\n return [op, ['geometry-type'], value];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n if (expectedTypes && value !== null) {\n const type = typeof value;\n expectedTypes[property] = type;\n }\n if (op === '==' && property !== '$id' && value === null) {\n return [\n 'all',\n ['has', property],\n ['==', get, null]\n ];\n }\n else if (op === '!=' && property !== '$id' && value === null) {\n return [\n 'any',\n ['!', ['has', property]],\n ['!=', get, null]\n ];\n }\n return [op, get, value];\n}\nfunction convertInOp(property, values, negate = false) {\n if (values.length === 0)\n return negate;\n let get;\n if (property === '$type') {\n get = ['geometry-type'];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n // Determine if the list of values to be searched is homogenously typed.\n // If so (and if the type is string or number), then we can use a\n // [match, input, [...values], true, false] construction rather than a\n // bunch of `==` tests.\n let uniformTypes = true;\n const type = typeof values[0];\n for (const value of values) {\n if (typeof value !== type) {\n uniformTypes = false;\n break;\n }\n }\n if (uniformTypes && (type === 'string' || type === 'number')) {\n // Match expressions must have unique values.\n const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);\n return ['match', get, uniqueValues, !negate, negate];\n }\n if (negate) {\n return ['all', ...values.map(v => ['!=', get, v])];\n }\n else {\n return ['any', ...values.map(v => ['==', get, v])];\n }\n}\nfunction convertHasOp(property) {\n if (property === '$type') {\n return true;\n }\n else if (property === '$id') {\n return ['!=', ['id'], null];\n }\n else {\n return ['has', property];\n }\n}\n\nfunction convertLiteral(value) {\n return typeof value === 'object' ? ['literal', value] : value;\n}\nfunction convertFunction(parameters, propertySpec) {\n let stops = parameters.stops;\n if (!stops) {\n // identity function\n return convertIdentityFunction(parameters, propertySpec);\n }\n const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n stops = stops.map((stop) => {\n if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {\n return [stop[0], convertTokenString(stop[1])];\n }\n return [stop[0], convertLiteral(stop[1])];\n });\n if (zoomAndFeatureDependent) {\n return convertZoomAndPropertyFunction(parameters, propertySpec, stops);\n }\n else if (zoomDependent) {\n return convertZoomFunction(parameters, propertySpec, stops);\n }\n else {\n return convertPropertyFunction(parameters, propertySpec, stops);\n }\n}\nfunction convertIdentityFunction(parameters, propertySpec) {\n const get = ['get', parameters.property];\n if (parameters.default === undefined) {\n // By default, expressions for string-valued properties get coerced. To preserve\n // legacy function semantics, insert an explicit assertion instead.\n return propertySpec.type === 'string' ? ['string', get] : get;\n }\n else if (propertySpec.type === 'enum') {\n return [\n 'match',\n get,\n Object.keys(propertySpec.values),\n get,\n parameters.default\n ];\n }\n else {\n const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];\n if (propertySpec.type === 'array') {\n expression.splice(1, 0, propertySpec.value, propertySpec.length || null);\n }\n return expression;\n }\n}\nfunction getInterpolateOperator(parameters) {\n switch (parameters.colorSpace) {\n case 'hcl': return 'interpolate-hcl';\n case 'lab': return 'interpolate-lab';\n default: return 'interpolate';\n }\n}\nfunction convertZoomAndPropertyFunction(parameters, propertySpec, stops) {\n const featureFunctionParameters = {};\n const featureFunctionStops = {};\n const zoomStops = [];\n for (let s = 0; s < stops.length; s++) {\n const stop = stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctionParameters[zoom] === undefined) {\n featureFunctionParameters[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n };\n featureFunctionStops[zoom] = [];\n zoomStops.push(zoom);\n }\n featureFunctionStops[zoom].push([stop[0].value, stop[1]]);\n }\n // the interpolation type for the zoom dimension of a zoom-and-property\n // function is determined directly from the style property specification\n // for which it's being used: linear for interpolatable properties, step\n // otherwise.\n const functionType = getFunctionType({}, propertySpec);\n if (functionType === 'exponential') {\n const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, false);\n }\n return expression;\n }\n else {\n const expression = ['step', ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, true);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n }\n}\nfunction coalesce(a, b) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n}\nfunction getFallback(parameters, propertySpec) {\n const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));\n /*\n * Some fields with type: resolvedImage have an undefined default.\n * Because undefined is an invalid value for resolvedImage, set fallback to\n * an empty string instead of undefined to ensure output\n * passes validation.\n */\n if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {\n return '';\n }\n return defaultValue;\n}\nfunction convertPropertyFunction(parameters, propertySpec, stops) {\n const type = getFunctionType(parameters, propertySpec);\n const get = ['get', parameters.property];\n if (type === 'categorical' && typeof stops[0][0] === 'boolean') {\n const expression = ['case'];\n for (const stop of stops) {\n expression.push(['==', get, stop[0]], stop[1]);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'categorical') {\n const expression = ['match', get];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'interval') {\n const expression = ['step', ['number', get]];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], true);\n }\n fixupDegenerateStepCurve(expression);\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n const expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n ['number', get]\n ];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else {\n throw new Error(`Unknown property function type ${type}`);\n }\n}\nfunction convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) {\n const type = getFunctionType(parameters, propertySpec);\n let expression;\n let isStep = false;\n if (type === 'interval') {\n expression = ['step', input];\n isStep = true;\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n expression = [getInterpolateOperator(parameters), base === 1 ? ['linear'] : ['exponential', base], input];\n }\n else {\n throw new Error(`Unknown zoom function type \"${type}\"`);\n }\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], isStep);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n}\nfunction fixupDegenerateStepCurve(expression) {\n // degenerate step curve (i.e. a constant function): add a noop stop\n if (expression[0] === 'step' && expression.length === 3) {\n expression.push(0);\n expression.push(expression[3]);\n }\n}\nfunction appendStopPair(curve, input, output, isStep) {\n // Skip duplicate stop values. They were not validated for functions, but they are for expressions.\n // https://github.com/mapbox/mapbox-gl-js/issues/4107\n if (curve.length > 3 && input === curve[curve.length - 2]) {\n return;\n }\n // step curves don't get the first input value, as it is redundant.\n if (!(isStep && curve.length === 2)) {\n curve.push(input);\n }\n curve.push(output);\n}\nfunction getFunctionType(parameters, propertySpec) {\n if (parameters.type) {\n return parameters.type;\n }\n else {\n return propertySpec.expression.interpolated ? 'exponential' : 'interval';\n }\n}\n// \"String with {name} token\" => [\"concat\", \"String with \", [\"get\", \"name\"], \" token\"]\nfunction convertTokenString(s) {\n const result = ['concat'];\n const re = /{([^{}]+)}/g;\n let pos = 0;\n for (let match = re.exec(s); match !== null; match = re.exec(s)) {\n const literal = s.slice(pos, re.lastIndex - match[0].length);\n pos = re.lastIndex;\n if (literal.length > 0)\n result.push(literal);\n result.push(['get', match[1]]);\n }\n if (result.length === 1) {\n return s;\n }\n if (pos < s.length) {\n result.push(s.slice(pos));\n }\n else if (result.length === 2) {\n return ['to-string', result[1]];\n }\n return result;\n}\n\nfunction getPropertyReference(propertyName) {\n for (let i = 0; i < v8Spec.layout.length; i++) {\n for (const key in v8Spec[v8Spec.layout[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.layout[i]][key];\n }\n }\n for (let i = 0; i < v8Spec.paint.length; i++) {\n for (const key in v8Spec[v8Spec.paint[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.paint[i]][key];\n }\n }\n return null;\n}\nfunction eachSource(style, callback) {\n for (const k in style.sources) {\n callback(style.sources[k]);\n }\n}\nfunction eachLayer(style, callback) {\n for (const layer of style.layers) {\n callback(layer);\n }\n}\nfunction eachProperty(style, options, callback) {\n function inner(layer, propertyType) {\n const properties = layer[propertyType];\n if (!properties)\n return;\n Object.keys(properties).forEach((key) => {\n callback({\n path: [layer.id, propertyType, key],\n key,\n value: properties[key],\n reference: getPropertyReference(key),\n set(x) {\n properties[key] = x;\n }\n });\n });\n }\n eachLayer(style, (layer) => {\n if (options.paint) {\n inner(layer, 'paint');\n }\n if (options.layout) {\n inner(layer, 'layout');\n }\n });\n}\n\nfunction stringify(obj) {\n const type = typeof obj;\n if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null)\n return JSON.stringify(obj);\n if (Array.isArray(obj)) {\n let str = '[';\n for (const val of obj) {\n str += `${stringify(val)},`;\n }\n return `${str}]`;\n }\n const keys = Object.keys(obj).sort();\n let str = '{';\n for (let i = 0; i < keys.length; i++) {\n str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`;\n }\n return `${str}}`;\n}\nfunction getKey(layer) {\n let key = '';\n for (const k of refProperties) {\n key += `/${stringify(layer[k])}`;\n }\n return key;\n}\n/**\n * Given an array of layers, return an array of arrays of layers where all\n * layers in each group have identical layout-affecting properties. These\n * are the properties that were formerly used by explicit `ref` mechanism\n * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n * 'filter', and 'layout'.\n *\n * The input is not modified. The output layers are references to the\n * input layers.\n *\n * @private\n * @param {Array} layers\n * @param {Object} [cachedKeys] - an object to keep already calculated keys.\n * @returns {Array>}\n */\nfunction groupByLayout(layers, cachedKeys) {\n const groups = {};\n for (let i = 0; i < layers.length; i++) {\n const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);\n // update the cache if there is one\n if (cachedKeys)\n cachedKeys[layers[i].id] = k;\n let group = groups[k];\n if (!group) {\n group = groups[k] = [];\n }\n group.push(layers[i]);\n }\n const result = [];\n for (const k in groups) {\n result.push(groups[k]);\n }\n return result;\n}\n\nfunction emptyStyle() {\n const style = {};\n const version = v8Spec['$version'];\n for (const styleKey in v8Spec['$root']) {\n const spec = v8Spec['$root'][styleKey];\n if (spec.required) {\n let value = null;\n if (styleKey === 'version') {\n value = version;\n }\n else {\n if (spec.type === 'array') {\n value = [];\n }\n else {\n value = {};\n }\n }\n if (value != null) {\n style[styleKey] = value;\n }\n }\n }\n return style;\n}\n\nfunction validateConstants(options) {\n const key = options.key;\n const constants = options.value;\n if (constants) {\n return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];\n }\n else {\n return [];\n }\n}\n\n// Turn jsonlint-lines-primitives objects into primitive objects\nfunction unbundle(value) {\n if (value instanceof Number || value instanceof String || value instanceof Boolean) {\n return value.valueOf();\n }\n else {\n return value;\n }\n}\nfunction deepUnbundle(value) {\n if (Array.isArray(value)) {\n return value.map(deepUnbundle);\n }\n else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {\n const unbundledValue = {};\n for (const key in value) {\n unbundledValue[key] = deepUnbundle(value[key]);\n }\n return unbundledValue;\n }\n return unbundle(value);\n}\n\nfunction validateObject(options) {\n const key = options.key;\n const object = options.value;\n const elementSpecs = options.valueSpec || {};\n const elementValidators = options.objectElementValidators || {};\n const style = options.style;\n const styleSpec = options.styleSpec;\n const validateSpec = options.validateSpec;\n let errors = [];\n const type = getType(object);\n if (type !== 'object') {\n return [new ValidationError(key, object, `object expected, ${type} found`)];\n }\n for (const objectKey in object) {\n const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'\n const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];\n let validateElement;\n if (elementValidators[elementSpecKey]) {\n validateElement = elementValidators[elementSpecKey];\n }\n else if (elementSpecs[elementSpecKey]) {\n validateElement = validateSpec;\n }\n else if (elementValidators['*']) {\n validateElement = elementValidators['*'];\n }\n else if (elementSpecs['*']) {\n validateElement = validateSpec;\n }\n else {\n errors.push(new ValidationError(key, object[objectKey], `unknown property \"${objectKey}\"`));\n continue;\n }\n errors = errors.concat(validateElement({\n key: (key ? `${key}.` : key) + objectKey,\n value: object[objectKey],\n valueSpec: elementSpec,\n style,\n styleSpec,\n object,\n objectKey,\n validateSpec,\n }, object));\n }\n for (const elementSpecKey in elementSpecs) {\n // Don't check `required` when there's a custom validator for that property.\n if (elementValidators[elementSpecKey]) {\n continue;\n }\n if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {\n errors.push(new ValidationError(key, object, `missing required property \"${elementSpecKey}\"`));\n }\n }\n return errors;\n}\n\nfunction validateArray(options) {\n const array = options.value;\n const arraySpec = options.valueSpec;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const key = options.key;\n const validateArrayElement = options.arrayElementValidator || validateSpec;\n if (getType(array) !== 'array') {\n return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];\n }\n if (arraySpec.length && array.length !== arraySpec.length) {\n return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)];\n }\n if (arraySpec['min-length'] && array.length < arraySpec['min-length']) {\n return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)];\n }\n let arrayElementSpec = {\n 'type': arraySpec.value,\n 'values': arraySpec.values\n };\n if (styleSpec.$version < 7) {\n arrayElementSpec['function'] = arraySpec.function;\n }\n if (getType(arraySpec.value) === 'object') {\n arrayElementSpec = arraySpec.value;\n }\n let errors = [];\n for (let i = 0; i < array.length; i++) {\n errors = errors.concat(validateArrayElement({\n array,\n arrayIndex: i,\n value: array[i],\n valueSpec: arrayElementSpec,\n validateSpec: options.validateSpec,\n style,\n styleSpec,\n key: `${key}[${i}]`\n }));\n }\n return errors;\n}\n\nfunction validateNumber(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n let type = getType(value);\n // eslint-disable-next-line no-self-compare\n if (type === 'number' && value !== value) {\n type = 'NaN';\n }\n if (type !== 'number') {\n return [new ValidationError(key, value, `number expected, ${type} found`)];\n }\n if ('minimum' in valueSpec && value < valueSpec.minimum) {\n return [new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)];\n }\n if ('maximum' in valueSpec && value > valueSpec.maximum) {\n return [new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)];\n }\n return [];\n}\n\nfunction validateFunction(options) {\n const functionValueSpec = options.valueSpec;\n const functionType = unbundle(options.value.type);\n let stopKeyType;\n let stopDomainValues = {};\n let previousStopDomainValue;\n let previousStopDomainZoom;\n const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;\n const isPropertyFunction = !isZoomFunction;\n const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' &&\n getType(options.value.stops[0]) === 'array' &&\n getType(options.value.stops[0][0]) === 'object';\n const errors = validateObject({\n key: options.key,\n value: options.value,\n valueSpec: options.styleSpec.function,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n stops: validateFunctionStops,\n default: validateFunctionDefault\n }\n });\n if (functionType === 'identity' && isZoomFunction) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"property\"'));\n }\n if (functionType !== 'identity' && !options.value.stops) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"stops\"'));\n }\n if (functionType === 'exponential' && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported'));\n }\n if (options.styleSpec.$version >= 8) {\n if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'property functions not supported'));\n }\n else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));\n }\n }\n if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) {\n errors.push(new ValidationError(options.key, options.value, '\"property\" property is required'));\n }\n return errors;\n function validateFunctionStops(options) {\n if (functionType === 'identity') {\n return [new ValidationError(options.key, options.value, 'identity function may not have a \"stops\" property')];\n }\n let errors = [];\n const value = options.value;\n errors = errors.concat(validateArray({\n key: options.key,\n value,\n valueSpec: options.valueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n arrayElementValidator: validateFunctionStop\n }));\n if (getType(value) === 'array' && value.length === 0) {\n errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));\n }\n return errors;\n }\n function validateFunctionStop(options) {\n let errors = [];\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n if (value.length !== 2) {\n return [new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)];\n }\n if (isZoomAndPropertyFunction) {\n if (getType(value[0]) !== 'object') {\n return [new ValidationError(key, value, `object expected, ${getType(value[0])} found`)];\n }\n if (value[0].zoom === undefined) {\n return [new ValidationError(key, value, 'object stop key must have zoom')];\n }\n if (value[0].value === undefined) {\n return [new ValidationError(key, value, 'object stop key must have value')];\n }\n if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {\n return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')];\n }\n if (unbundle(value[0].zoom) !== previousStopDomainZoom) {\n previousStopDomainZoom = unbundle(value[0].zoom);\n previousStopDomainValue = undefined;\n stopDomainValues = {};\n }\n errors = errors.concat(validateObject({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: { zoom: {} },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue }\n }));\n }\n else {\n errors = errors.concat(validateStopDomainValue({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: {},\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }, value));\n }\n if (isExpression(deepUnbundle(value[1]))) {\n return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]);\n }\n return errors.concat(options.validateSpec({\n key: `${key}[1]`,\n value: value[1],\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n function validateStopDomainValue(options, stop) {\n const type = getType(options.value);\n const value = unbundle(options.value);\n const reportValue = options.value !== null ? options.value : stop;\n if (!stopKeyType) {\n stopKeyType = type;\n }\n else if (type !== stopKeyType) {\n return [new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)];\n }\n if (type !== 'number' && type !== 'string' && type !== 'boolean') {\n return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];\n }\n if (type !== 'number' && functionType !== 'categorical') {\n let message = `number expected, ${type} found`;\n if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {\n message += '\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.';\n }\n return [new ValidationError(options.key, reportValue, message)];\n }\n if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) {\n return [new ValidationError(options.key, reportValue, `integer expected, found ${value}`)];\n }\n if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];\n }\n else {\n previousStopDomainValue = value;\n }\n if (functionType === 'categorical' && value in stopDomainValues) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];\n }\n else {\n stopDomainValues[value] = true;\n }\n return [];\n }\n function validateFunctionDefault(options) {\n return options.validateSpec({\n key: options.key,\n value: options.value,\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n });\n }\n}\n\nfunction validateExpression(options) {\n const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);\n if (expression.result === 'error') {\n return expression.value.map((error) => {\n return new ValidationError(`${options.key}${error.key}`, options.value, error.message);\n });\n }\n const expressionObj = expression.value.expression || expression.value._styleExpression.expression;\n if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&\n !expressionObj.outputDefined()) {\n return [new ValidationError(options.key, options.value, `Invalid data expression for \"${options.propertyKey}\". Output values must be contained as literals within the expression.`)];\n }\n if (options.expressionContext === 'property' && options.propertyType === 'layout' &&\n (!isStateConstant(expressionObj))) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with layout properties.')];\n }\n if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with filters.')];\n }\n if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {\n if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {\n return [new ValidationError(options.key, options.value, '\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.')];\n }\n if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')];\n }\n }\n return [];\n}\n\nfunction validateBoolean(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'boolean') {\n return [new ValidationError(key, value, `boolean expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateColor(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `color expected, ${type} found`)];\n }\n if (!Color.parse(String(value))) { // cast String object to string primitive\n return [new ValidationError(key, value, `color expected, \"${value}\" found`)];\n }\n return [];\n}\n\nfunction validateEnum(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n const errors = [];\n if (Array.isArray(valueSpec.values)) { // <=v7\n if (valueSpec.values.indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n else { // >=v8\n if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n return errors;\n}\n\nfunction validateFilter(options) {\n if (isExpressionFilter(deepUnbundle(options.value))) {\n return validateExpression(extendBy({}, options, {\n expressionContext: 'filter',\n valueSpec: { value: 'boolean' }\n }));\n }\n else {\n return validateNonExpressionFilter(options);\n }\n}\nfunction validateNonExpressionFilter(options) {\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n const styleSpec = options.styleSpec;\n let type;\n let errors = [];\n if (value.length < 1) {\n return [new ValidationError(key, value, 'filter array must have at least 1 element')];\n }\n errors = errors.concat(validateEnum({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: styleSpec.filter_operator,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n switch (unbundle(value[0])) {\n case '<':\n case '<=':\n case '>':\n case '>=':\n if (value.length >= 2 && unbundle(value[1]) === '$type') {\n errors.push(new ValidationError(key, value, `\"$type\" cannot be use with operator \"${value[0]}\"`));\n }\n /* falls through */\n case '==':\n case '!=':\n if (value.length !== 3) {\n errors.push(new ValidationError(key, value, `filter array for operator \"${value[0]}\" must have 3 elements`));\n }\n /* falls through */\n case 'in':\n case '!in':\n if (value.length >= 2) {\n type = getType(value[1]);\n if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n }\n for (let i = 2; i < value.length; i++) {\n type = getType(value[i]);\n if (unbundle(value[1]) === '$type') {\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec.geometry_type,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));\n }\n }\n break;\n case 'any':\n case 'all':\n case 'none':\n for (let i = 1; i < value.length; i++) {\n errors = errors.concat(validateNonExpressionFilter({\n key: `${key}[${i}]`,\n value: value[i],\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n break;\n case 'has':\n case '!has':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n break;\n case 'within':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'object') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`));\n }\n break;\n }\n return errors;\n}\n\nfunction validateProperty(options, propertyType) {\n const key = options.key;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const value = options.value;\n const propertyKey = options.objectKey;\n const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];\n if (!layerSpec)\n return [];\n const transitionMatch = propertyKey.match(/^(.*)-transition$/);\n if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {\n return validateSpec({\n key,\n value,\n valueSpec: styleSpec.transition,\n style,\n styleSpec\n });\n }\n const valueSpec = options.valueSpec || layerSpec[propertyKey];\n if (!valueSpec) {\n return [new ValidationError(key, value, `unknown property \"${propertyKey}\"`)];\n }\n let tokenMatch;\n if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {\n return [new ValidationError(key, value, `\"${propertyKey}\" does not support interpolation syntax\\n` +\n `Use an identity property function instead: \\`{ \"type\": \"identity\", \"property\": ${JSON.stringify(tokenMatch[1])} }\\`.`)];\n }\n const errors = [];\n if (options.layerType === 'symbol') {\n if (propertyKey === 'text-field' && style && !style.glyphs) {\n errors.push(new ValidationError(key, value, 'use of \"text-field\" requires a style \"glyphs\" property'));\n }\n if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') {\n errors.push(new ValidationError(key, value, '\"text-font\" does not support identity functions'));\n }\n }\n return errors.concat(validateSpec({\n key: options.key,\n value,\n valueSpec,\n style,\n styleSpec,\n expressionContext: 'property',\n propertyType,\n propertyKey\n }));\n}\n\nfunction validatePaintProperty(options) {\n return validateProperty(options, 'paint');\n}\n\nfunction validateLayoutProperty(options) {\n return validateProperty(options, 'layout');\n}\n\nfunction validateLayer(options) {\n let errors = [];\n const layer = options.value;\n const key = options.key;\n const style = options.style;\n const styleSpec = options.styleSpec;\n if (!layer.type && !layer.ref) {\n errors.push(new ValidationError(key, layer, 'either \"type\" or \"ref\" is required'));\n }\n let type = unbundle(layer.type);\n const ref = unbundle(layer.ref);\n if (layer.id) {\n const layerId = unbundle(layer.id);\n for (let i = 0; i < options.arrayIndex; i++) {\n const otherLayer = style.layers[i];\n if (unbundle(otherLayer.id) === layerId) {\n errors.push(new ValidationError(key, layer.id, `duplicate layer id \"${layer.id}\", previously used at line ${otherLayer.id.__line__}`));\n }\n }\n }\n if ('ref' in layer) {\n ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => {\n if (p in layer) {\n errors.push(new ValidationError(key, layer[p], `\"${p}\" is prohibited for ref layers`));\n }\n });\n let parent;\n style.layers.forEach((layer) => {\n if (unbundle(layer.id) === ref)\n parent = layer;\n });\n if (!parent) {\n errors.push(new ValidationError(key, layer.ref, `ref layer \"${ref}\" not found`));\n }\n else if (parent.ref) {\n errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));\n }\n else {\n type = unbundle(parent.type);\n }\n }\n else if (type !== 'background') {\n if (!layer.source) {\n errors.push(new ValidationError(key, layer, 'missing required property \"source\"'));\n }\n else {\n const source = style.sources && style.sources[layer.source];\n const sourceType = source && unbundle(source.type);\n if (!source) {\n errors.push(new ValidationError(key, layer.source, `source \"${layer.source}\" not found`));\n }\n else if (sourceType === 'vector' && type === 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'hillshade') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType === 'raster' && type !== 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a vector source`));\n }\n else if (sourceType === 'vector' && !layer['source-layer']) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" must specify a \"source-layer\"`));\n }\n else if (sourceType === 'raster-dem' && type !== 'hillshade') {\n errors.push(new ValidationError(key, layer.source, 'raster-dem source can only be used with layer type \\'hillshade\\'.'));\n }\n else if (type === 'line' && layer.paint && layer.paint['line-gradient'] &&\n (sourceType !== 'geojson' || !source.lineMetrics)) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`));\n }\n }\n }\n errors = errors.concat(validateObject({\n key,\n value: layer,\n valueSpec: styleSpec.layer,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'() {\n return [];\n },\n // We don't want to enforce the spec's `\"requires\": true` for backward compatibility with refs;\n // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772.\n type() {\n return options.validateSpec({\n key: `${key}.type`,\n value: layer.type,\n valueSpec: styleSpec.layer.type,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n object: layer,\n objectKey: 'type'\n });\n },\n filter: validateFilter,\n layout(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validateLayoutProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n },\n paint(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validatePaintProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n }\n }\n }));\n return errors;\n}\n\nfunction validateString(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `string expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateRasterDEMSource(options) {\n var _a;\n const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';\n const rasterDEM = options.value;\n const styleSpec = options.styleSpec;\n const rasterDEMSpec = styleSpec.source_raster_dem;\n const style = options.style;\n let errors = [];\n const rootType = getType(rasterDEM);\n if (rasterDEM === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));\n return errors;\n }\n const encoding = unbundle(rasterDEM.encoding);\n const isCustomEncoding = encoding === 'custom';\n const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];\n const encodingName = options.value.encoding ? `\"${options.value.encoding}\"` : 'Default';\n for (const key in rasterDEM) {\n if (!isCustomEncoding && customEncodingKeys.includes(key)) {\n errors.push(new ValidationError(key, rasterDEM[key], `In \"${sourceName}\": \"${key}\" is only valid when \"encoding\" is set to \"custom\". ${encodingName} encoding found`));\n }\n else if (rasterDEMSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: rasterDEM[key],\n valueSpec: rasterDEMSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors.push(new ValidationError(key, rasterDEM[key], `unknown property \"${key}\"`));\n }\n }\n return errors;\n}\n\nconst objectElementValidators = {\n promoteId: validatePromoteId\n};\nfunction validateSource(options) {\n const value = options.value;\n const key = options.key;\n const styleSpec = options.styleSpec;\n const style = options.style;\n const validateSpec = options.validateSpec;\n if (!value.type) {\n return [new ValidationError(key, value, '\"type\" is required')];\n }\n const type = unbundle(value.type);\n let errors;\n switch (type) {\n case 'vector':\n case 'raster':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec[`source_${type.replace('-', '_')}`],\n style: options.style,\n styleSpec,\n objectElementValidators,\n validateSpec,\n });\n return errors;\n case 'raster-dem':\n errors = validateRasterDEMSource({\n sourceName: key,\n value,\n style: options.style,\n styleSpec,\n validateSpec,\n });\n return errors;\n case 'geojson':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec.source_geojson,\n style,\n styleSpec,\n validateSpec,\n objectElementValidators\n });\n if (value.cluster) {\n for (const prop in value.clusterProperties) {\n const [operator, mapExpr] = value.clusterProperties[prop];\n const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator;\n errors.push(...validateExpression({\n key: `${key}.${prop}.map`,\n value: mapExpr,\n validateSpec,\n expressionContext: 'cluster-map'\n }));\n errors.push(...validateExpression({\n key: `${key}.${prop}.reduce`,\n value: reduceExpr,\n validateSpec,\n expressionContext: 'cluster-reduce'\n }));\n }\n }\n return errors;\n case 'video':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_video,\n style,\n validateSpec,\n styleSpec\n });\n case 'image':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_image,\n style,\n validateSpec,\n styleSpec\n });\n case 'canvas':\n return [new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')];\n default:\n return validateEnum({\n key: `${key}.type`,\n value: value.type,\n valueSpec: { values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image'] },\n style,\n validateSpec,\n styleSpec\n });\n }\n}\nfunction validatePromoteId({ key, value }) {\n if (getType(value) === 'string') {\n return validateString({ key, value });\n }\n else {\n const errors = [];\n for (const prop in value) {\n errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] }));\n }\n return errors;\n }\n}\n\nfunction validateLight(options) {\n const light = options.value;\n const styleSpec = options.styleSpec;\n const lightSpec = styleSpec.light;\n const style = options.style;\n let errors = [];\n const rootType = getType(light);\n if (light === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in light) {\n const transitionMatch = key.match(/^(.*)-transition$/);\n if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: styleSpec.transition,\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else if (lightSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: lightSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, light[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateTerrain(options) {\n const terrain = options.value;\n const styleSpec = options.styleSpec;\n const terrainSpec = styleSpec.terrain;\n const style = options.style;\n let errors = [];\n const rootType = getType(terrain);\n if (terrain === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in terrain) {\n if (terrainSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: terrain[key],\n valueSpec: terrainSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, terrain[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateFormatted(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validateImage(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validatePadding(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1 || value.length > 4) {\n return [new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)];\n }\n const arrayElementSpec = {\n type: 'number'\n };\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateVariableAnchorOffsetCollection(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n const styleSpec = options.styleSpec;\n if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) {\n return [new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')];\n }\n let errors = [];\n for (let i = 0; i < value.length; i += 2) {\n // Elements in even positions should be values from text-anchor enum\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec['layout_symbol']['text-anchor']\n }));\n // Elements in odd positions should be points (2-element numeric arrays)\n errors = errors.concat(validateArray({\n key: `${key}[${i + 1}]`,\n value: value[i + 1],\n valueSpec: {\n length: 2,\n value: 'number'\n },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec\n }));\n }\n return errors;\n}\n\nfunction validateSprite(options) {\n let errors = [];\n const sprite = options.value;\n const key = options.key;\n if (!Array.isArray(sprite)) {\n return validateString({\n key,\n value: sprite\n });\n }\n else {\n const allSpriteIds = [];\n const allSpriteURLs = [];\n for (const i in sprite) {\n if (sprite[i].id && allSpriteIds.includes(sprite[i].id))\n errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`));\n allSpriteIds.push(sprite[i].id);\n if (sprite[i].url && allSpriteURLs.includes(sprite[i].url))\n errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`));\n allSpriteURLs.push(sprite[i].url);\n const pairSpec = {\n id: {\n type: 'string',\n required: true,\n },\n url: {\n type: 'string',\n required: true,\n }\n };\n errors = errors.concat(validateObject({\n key: `${key}[${i}]`,\n value: sprite[i],\n valueSpec: pairSpec,\n validateSpec: options.validateSpec,\n }));\n }\n return errors;\n }\n}\n\nconst VALIDATORS = {\n '*'() {\n return [];\n },\n 'array': validateArray,\n 'boolean': validateBoolean,\n 'number': validateNumber,\n 'color': validateColor,\n 'constants': validateConstants,\n 'enum': validateEnum,\n 'filter': validateFilter,\n 'function': validateFunction,\n 'layer': validateLayer,\n 'object': validateObject,\n 'source': validateSource,\n 'light': validateLight,\n 'terrain': validateTerrain,\n 'string': validateString,\n 'formatted': validateFormatted,\n 'resolvedImage': validateImage,\n 'padding': validatePadding,\n 'variableAnchorOffsetCollection': validateVariableAnchorOffsetCollection,\n 'sprite': validateSprite,\n};\n// Main recursive validation function. Tracks:\n//\n// - key: string representing location of validation in style tree. Used only\n// for more informative error reporting.\n// - value: current value from style being evaluated. May be anything from a\n// high level object that needs to be descended into deeper or a simple\n// scalar value.\n// - valueSpec: current spec being evaluated. Tracks value.\n// - styleSpec: current full spec being evaluated.\nfunction validate(options) {\n const value = options.value;\n const valueSpec = options.valueSpec;\n const styleSpec = options.styleSpec;\n options.validateSpec = validate;\n if (valueSpec.expression && isFunction(unbundle(value))) {\n return validateFunction(options);\n }\n else if (valueSpec.expression && isExpression(deepUnbundle(value))) {\n return validateExpression(options);\n }\n else if (valueSpec.type && VALIDATORS[valueSpec.type]) {\n return VALIDATORS[valueSpec.type](options);\n }\n else {\n const valid = validateObject(extendBy({}, options, {\n valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec\n }));\n return valid;\n }\n}\n\nfunction validateGlyphsUrl(options) {\n const value = options.value;\n const key = options.key;\n const errors = validateString(options);\n if (errors.length)\n return errors;\n if (value.indexOf('{fontstack}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{fontstack}\" token'));\n }\n if (value.indexOf('{range}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{range}\" token'));\n }\n return errors;\n}\n\n/**\n * Validate a MapLibre style against the style specification. This entrypoint,\n * `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as\n * small a browserify bundle as possible by omitting unnecessary functionality\n * and legacy style specifications.\n *\n * @private\n * @param {Object} style The style to be validated.\n * @param {Object} [styleSpec] The style specification to validate against.\n * If omitted, the latest style spec is used.\n * @returns {Array}\n * @example\n * var validate = require('maplibre-gl-style-spec/lib/validate_style.min');\n * var errors = validate(style);\n */\nfunction validateStyleMin(style, styleSpec = v8Spec) {\n let errors = [];\n errors = errors.concat(validate({\n key: '',\n value: style,\n valueSpec: styleSpec.$root,\n styleSpec,\n style,\n validateSpec: validate,\n objectElementValidators: {\n glyphs: validateGlyphsUrl,\n '*'() {\n return [];\n }\n }\n }));\n if (style['constants']) {\n errors = errors.concat(validateConstants({\n key: 'constants',\n value: style['constants'],\n style,\n styleSpec,\n validateSpec: validate,\n }));\n }\n return sortErrors(errors);\n}\nvalidateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource));\nvalidateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite));\nvalidateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl));\nvalidateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight));\nvalidateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain));\nvalidateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer));\nvalidateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter));\nvalidateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty));\nvalidateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty));\nfunction injectValidateSpec(validator) {\n return function (options) {\n return validator({\n ...options,\n validateSpec: validate,\n });\n };\n}\nfunction sortErrors(errors) {\n return [].concat(errors).sort((a, b) => {\n return a.line - b.line;\n });\n}\nfunction wrapCleanErrors(inner) {\n return function (...args) {\n return sortErrors(inner.apply(this, args));\n };\n}\n\nconst v8 = v8Spec;\nconst expression = {\n StyleExpression,\n StylePropertyFunction,\n ZoomConstantExpression,\n ZoomDependentExpression,\n createExpression,\n createPropertyExpression,\n isExpression,\n isExpressionFilter,\n isZoomExpression,\n normalizePropertyExpression,\n};\nconst styleFunction = {\n convertFunction,\n createFunction,\n isFunction\n};\nconst visit = { eachLayer, eachProperty, eachSource };\n\nexport { Color, ColorType, CompoundExpression, EvaluationContext, FormatExpression, Formatted, FormattedSection, FormattedType, Interpolate, Literal, NullType, Padding, ParsingError, ResolvedImage, Step, StyleExpression, StylePropertyFunction, ValidationError, VariableAnchorOffsetCollection, ZoomConstantExpression, ZoomDependentExpression, convertFilter, convertFunction, createExpression, createFunction, createPropertyExpression, derefLayers, diffStyles as diff, emptyStyle, expression, expressions, createFilter as featureFilter, styleFunction as function, groupByLayout, interpolateFactory, interpolate as interpolates, isExpression, isFunction, isZoomExpression, v8Spec as latest, normalizePropertyExpression, operations, supportsPropertyExpression, toString$1 as toString, typeOf, v8, validateStyleMin, visit };\n//# sourceMappingURL=index.mjs.map\n","import {validateStyleMin} from '@maplibre/maplibre-gl-style-spec';\nimport {ErrorEvent} from '../util/evented';\n\nimport type {Evented} from '../util/evented';\n\ntype ValidationError = {\n message: string;\n line: number;\n identifier?: string;\n};\n\nexport type Validator = (a: any) => ReadonlyArray;\n\ntype ValidateStyle = {\n source: Validator;\n sprite: Validator;\n glyphs: Validator;\n layer: Validator;\n light: Validator;\n terrain: Validator;\n filter: Validator;\n paintProperty: Validator;\n layoutProperty: Validator;\n (b: any, a?: any | null): ReadonlyArray;\n};\n\nexport const validateStyle = (validateStyleMin as unknown as ValidateStyle);\n\nexport const validateSource = validateStyle.source;\nexport const validateLight = validateStyle.light;\nexport const validateTerrain = validateStyle.terrain;\nexport const validateFilter = validateStyle.filter;\nexport const validatePaintProperty = validateStyle.paintProperty;\nexport const validateLayoutProperty = validateStyle.layoutProperty;\n\nexport function emitValidationErrors(\n emitter: Evented,\n errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n }> | null\n): boolean {\n let hasErrors = false;\n if (errors && errors.length) {\n for (const error of errors) {\n emitter.fire(new ErrorEvent(new Error(error.message)));\n hasErrors = true;\n }\n }\n return hasErrors;\n}\n","/*\nThis file was copied from https://github.com/mapbox/grid-index and was\nmigrated from JavaScript to TypeScript.\n\nCopyright (c) 2016, Mapbox\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n*/\n\nconst NUM_PARAMS = 3;\n\nexport type SerializedGrid = {\n buffer: ArrayBuffer;\n};\n\nexport class TransferableGridIndex {\n cells: number[][];\n arrayBuffer: ArrayBuffer;\n d: number;\n keys: number[];\n bboxes: number[];\n n: number;\n extent: number;\n padding: number;\n scale: any;\n uid: number;\n min: number;\n max: number;\n\n constructor(extent: number | ArrayBuffer, n?: number, padding?: number) {\n const cells = this.cells = [];\n\n if (extent instanceof ArrayBuffer) {\n this.arrayBuffer = extent;\n const array = new Int32Array(this.arrayBuffer);\n extent = array[0];\n n = array[1];\n padding = array[2];\n\n this.d = n + 2 * padding;\n for (let k = 0; k < this.d * this.d; k++) {\n const start = array[NUM_PARAMS + k];\n const end = array[NUM_PARAMS + k + 1];\n cells.push(start === end ? null : array.subarray(start, end));\n }\n const keysOffset = array[NUM_PARAMS + cells.length];\n const bboxesOffset = array[NUM_PARAMS + cells.length + 1];\n this.keys = array.subarray(keysOffset, bboxesOffset) as any as number[];\n this.bboxes = array.subarray(bboxesOffset) as any as number[];\n\n this.insert = this._insertReadonly;\n\n } else {\n this.d = n + 2 * padding;\n for (let i = 0; i < this.d * this.d; i++) {\n cells.push([]);\n }\n this.keys = [];\n this.bboxes = [];\n }\n\n this.n = n;\n this.extent = extent;\n this.padding = padding;\n this.scale = n / extent;\n this.uid = 0;\n\n const p = (padding / n) * extent;\n this.min = -p;\n this.max = extent + p;\n }\n\n insert(key: number, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined);\n this.keys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n _insertReadonly() {\n throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.');\n }\n\n _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.cells[cellIndex].push(uid);\n }\n\n query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[] {\n const min = this.min;\n const max = this.max;\n if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) {\n // We use `Array#slice` because `this.keys` may be a `Int32Array` and\n // some browsers (Safari and IE) do not support `TypedArray#slice`\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility\n return Array.prototype.slice.call(this.keys);\n\n } else {\n const result = [];\n const seenUids = {};\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest);\n return result;\n }\n }\n\n _queryCell(x1: number, y1: number, x2: number, y2:number, cellIndex:number, result, seenUids, intersectionTest: Function) {\n const cell = this.cells[cellIndex];\n if (cell !== null) {\n const keys = this.keys;\n const bboxes = this.bboxes;\n for (let u = 0; u < cell.length; u++) {\n const uid = cell[u];\n if (seenUids[uid] === undefined) {\n const offset = uid * 4;\n if (intersectionTest ?\n intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) :\n ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]))) {\n seenUids[uid] = true;\n result.push(keys[uid]);\n } else {\n seenUids[uid] = false;\n }\n }\n }\n }\n }\n\n _forEachCell(x1: number, y1: number, x2:number, y2:number, fn: Function, arg1, arg2, intersectionTest) {\n const cx1 = this._convertToCellCoord(x1);\n const cy1 = this._convertToCellCoord(y1);\n const cx2 = this._convertToCellCoord(x2);\n const cy2 = this._convertToCellCoord(y2);\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.d * y + x;\n if (intersectionTest && !intersectionTest(\n this._convertFromCellCoord(x),\n this._convertFromCellCoord(y),\n this._convertFromCellCoord(x + 1),\n this._convertFromCellCoord(y + 1))) continue;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) return;\n }\n }\n }\n\n _convertFromCellCoord (x) {\n return (x - this.padding) / this.scale;\n }\n\n _convertToCellCoord(x) {\n return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding));\n }\n\n toArrayBuffer(): ArrayBuffer {\n if (this.arrayBuffer) return this.arrayBuffer;\n\n const cells = this.cells;\n\n const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1;\n let totalCellLength = 0;\n for (let i = 0; i < this.cells.length; i++) {\n totalCellLength += this.cells[i].length;\n }\n\n const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length);\n array[0] = this.extent;\n array[1] = this.n;\n array[2] = this.padding;\n\n let offset = metadataLength;\n for (let k = 0; k < cells.length; k++) {\n const cell = cells[k];\n array[NUM_PARAMS + k] = offset;\n array.set(cell, offset);\n offset += cell.length;\n }\n\n array[NUM_PARAMS + cells.length] = offset;\n array.set(this.keys, offset);\n offset += this.keys.length;\n\n array[NUM_PARAMS + cells.length + 1] = offset;\n array.set(this.bboxes, offset);\n offset += this.bboxes.length;\n\n return array.buffer;\n }\n\n public static serialize(grid: TransferableGridIndex, transferables?: Array): SerializedGrid {\n const buffer = grid.toArrayBuffer();\n if (transferables) {\n transferables.push(buffer);\n }\n return {buffer};\n }\n\n public static deserialize(serialized: SerializedGrid): TransferableGridIndex {\n return new TransferableGridIndex(serialized.buffer);\n }\n}\n","import {TransferableGridIndex} from './transferable_grid_index';\nimport {Color, CompoundExpression, expressions, ResolvedImage, StylePropertyFunction,\n StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport {AJAXError} from './ajax';\n\nimport type {Transferable} from '../types/transferable';\nimport {isImageBitmap} from './util';\n\ntype SerializedObject = {\n [_: string]: S;\n};\n\nexport type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array | SerializedObject;\n\ntype Registry = {\n [_: string]: {\n klass: {\n new (...args: any): any;\n deserialize?: (input: Serialized) => unknown;\n };\n omit: ReadonlyArray;\n shallow: ReadonlyArray;\n };\n};\n\n/**\n * Register options\n */\ntype RegisterOptions = {\n /**\n * List of properties to omit from serialization (e.g., cached/computed properties)\n */\n omit?: ReadonlyArray;\n /**\n * List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize().\n */\n shallow?: ReadonlyArray;\n};\n\nconst registry: Registry = {};\n\n/**\n * Register the given class as serializable.\n *\n * @param options - the registration options\n */\nexport function register(\n name: string,\n klass: {\n new (...args: any): T;\n },\n options: RegisterOptions = {}\n) {\n if (registry[name]) throw new Error(`${name} is already registered.`);\n ((Object.defineProperty as any))(klass, '_classRegistryKey', {\n value: name,\n writeable: false\n });\n registry[name] = {\n klass,\n omit: options.omit as ReadonlyArray || [],\n shallow: options.shallow as ReadonlyArray || []\n };\n}\n\nregister('Object', Object);\nregister('TransferableGridIndex', TransferableGridIndex);\n\nregister('Color', Color);\nregister('Error', Error);\nregister('AJAXError', AJAXError);\nregister('ResolvedImage', ResolvedImage);\n\nregister('StylePropertyFunction', StylePropertyFunction);\nregister('StyleExpression', StyleExpression, {omit: ['_evaluator']});\n\nregister('ZoomDependentExpression', ZoomDependentExpression);\nregister('ZoomConstantExpression', ZoomConstantExpression);\nregister('CompoundExpression', CompoundExpression, {omit: ['_evaluate']});\nfor (const name in expressions) {\n if ((expressions[name] as any)._classRegistryKey) continue;\n register(`Expression_${name}`, expressions[name]);\n}\n\nfunction isArrayBuffer(value: any): value is ArrayBuffer {\n return value && typeof ArrayBuffer !== 'undefined' &&\n (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer'));\n}\n\n/**\n * Serialize the given object for transfer to or from a web worker.\n *\n * For non-builtin types, recursively serialize each property (possibly\n * omitting certain properties - see register()), and package the result along\n * with the constructor's `name` so that the appropriate constructor can be\n * looked up in `deserialize()`.\n *\n * If a `transferables` array is provided, add any transferable objects (i.e.,\n * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed,\n * this should happen in the client code, before using serialize().)\n */\nexport function serialize(input: unknown, transferables?: Array | null): Serialized {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob) {\n return input;\n }\n\n if (isArrayBuffer(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (isImageBitmap(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (ArrayBuffer.isView(input)) {\n const view = input;\n if (transferables) {\n transferables.push(view.buffer);\n }\n return view;\n }\n\n if (input instanceof ImageData) {\n if (transferables) {\n transferables.push(input.data.buffer);\n }\n return input;\n }\n\n if (Array.isArray(input)) {\n const serialized: Array = [];\n for (const item of input) {\n serialized.push(serialize(item, transferables));\n }\n return serialized;\n }\n\n if (typeof input === 'object') {\n const klass = (input.constructor as any);\n const name = klass._classRegistryKey;\n if (!name) {\n throw new Error('can\\'t serialize object of unregistered class');\n }\n if (!registry[name]) throw new Error(`${name} is not registered.`);\n\n const properties: SerializedObject = klass.serialize ?\n // (Temporary workaround) allow a class to provide static\n // `serialize()` and `deserialize()` methods to bypass the generic\n // approach.\n // This temporary workaround lets us use the generic serialization\n // approach for objects whose members include instances of dynamic\n // StructArray types. Once we refactor StructArray to be static,\n // we can remove this complexity.\n (klass.serialize(input, transferables) as SerializedObject) : {};\n\n if (!klass.serialize) {\n for (const key in input) {\n if (!input.hasOwnProperty(key)) continue; // eslint-disable-line no-prototype-builtins\n if (registry[name].omit.indexOf(key) >= 0) continue;\n const property = input[key];\n properties[key] = registry[name].shallow.indexOf(key) >= 0 ?\n property :\n serialize(property, transferables);\n }\n if (input instanceof Error) {\n properties.message = input.message;\n }\n } else {\n if (transferables && properties === transferables[transferables.length - 1]) {\n throw new Error('statically serialized object won\\'t survive transfer of $name property');\n }\n }\n\n if (properties.$name) {\n throw new Error('$name property is reserved for worker serialization logic.');\n }\n if (name !== 'Object') {\n properties.$name = name;\n }\n\n return properties;\n }\n\n throw new Error(`can't serialize object of type ${typeof input}`);\n}\n\nexport function deserialize(input: Serialized): unknown {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob ||\n isArrayBuffer(input) ||\n isImageBitmap(input) ||\n ArrayBuffer.isView(input) ||\n input instanceof ImageData) {\n return input;\n }\n\n if (Array.isArray(input)) {\n return input.map(deserialize);\n }\n\n if (typeof input === 'object') {\n const name = input.$name || 'Object';\n if (!registry[name]) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n const {klass} = registry[name];\n if (!klass) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n\n if (klass.deserialize) {\n return klass.deserialize(input);\n }\n\n const result = Object.create(klass.prototype);\n\n for (const key of Object.keys(input)) {\n if (key === '$name') continue;\n const value = (input as SerializedObject)[key];\n result[key] = registry[name].shallow.indexOf(key) >= 0 ? value : deserialize(value);\n }\n\n return result;\n }\n\n throw new Error(`can't deserialize object of type ${typeof input}`);\n}\n","export class ZoomHistory {\n lastZoom: number;\n lastFloorZoom: number;\n lastIntegerZoom: number;\n lastIntegerZoomTime: number;\n first: boolean;\n\n constructor() {\n this.first = true;\n }\n\n update(z: number, now: number) {\n const floorZ = Math.floor(z);\n\n if (this.first) {\n this.first = false;\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = 0;\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n if (this.lastFloorZoom > floorZ) {\n this.lastIntegerZoom = floorZ + 1;\n this.lastIntegerZoomTime = now;\n } else if (this.lastFloorZoom < floorZ) {\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = now;\n }\n\n if (z !== this.lastZoom) {\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n return false;\n }\n}\n","// The following table comes from .\n// Keep it synchronized with .\n\ntype UnicodeBlockLookup = {[key: string]: (char: number) => boolean};\n\nexport const unicodeBlockLookup: UnicodeBlockLookup = {\n // 'Basic Latin': (char) => char >= 0x0000 && char <= 0x007F,\n 'Latin-1 Supplement': (char) => char >= 0x0080 && char <= 0x00FF,\n // 'Latin Extended-A': (char) => char >= 0x0100 && char <= 0x017F,\n // 'Latin Extended-B': (char) => char >= 0x0180 && char <= 0x024F,\n // 'IPA Extensions': (char) => char >= 0x0250 && char <= 0x02AF,\n // 'Spacing Modifier Letters': (char) => char >= 0x02B0 && char <= 0x02FF,\n // 'Combining Diacritical Marks': (char) => char >= 0x0300 && char <= 0x036F,\n // 'Greek and Coptic': (char) => char >= 0x0370 && char <= 0x03FF,\n // 'Cyrillic': (char) => char >= 0x0400 && char <= 0x04FF,\n // 'Cyrillic Supplement': (char) => char >= 0x0500 && char <= 0x052F,\n // 'Armenian': (char) => char >= 0x0530 && char <= 0x058F,\n //'Hebrew': (char) => char >= 0x0590 && char <= 0x05FF,\n 'Arabic': (char) => char >= 0x0600 && char <= 0x06FF,\n //'Syriac': (char) => char >= 0x0700 && char <= 0x074F,\n 'Arabic Supplement': (char) => char >= 0x0750 && char <= 0x077F,\n // 'Thaana': (char) => char >= 0x0780 && char <= 0x07BF,\n // 'NKo': (char) => char >= 0x07C0 && char <= 0x07FF,\n // 'Samaritan': (char) => char >= 0x0800 && char <= 0x083F,\n // 'Mandaic': (char) => char >= 0x0840 && char <= 0x085F,\n // 'Syriac Supplement': (char) => char >= 0x0860 && char <= 0x086F,\n 'Arabic Extended-A': (char) => char >= 0x08A0 && char <= 0x08FF,\n // 'Devanagari': (char) => char >= 0x0900 && char <= 0x097F,\n // 'Bengali': (char) => char >= 0x0980 && char <= 0x09FF,\n // 'Gurmukhi': (char) => char >= 0x0A00 && char <= 0x0A7F,\n // 'Gujarati': (char) => char >= 0x0A80 && char <= 0x0AFF,\n // 'Oriya': (char) => char >= 0x0B00 && char <= 0x0B7F,\n // 'Tamil': (char) => char >= 0x0B80 && char <= 0x0BFF,\n // 'Telugu': (char) => char >= 0x0C00 && char <= 0x0C7F,\n // 'Kannada': (char) => char >= 0x0C80 && char <= 0x0CFF,\n // 'Malayalam': (char) => char >= 0x0D00 && char <= 0x0D7F,\n // 'Sinhala': (char) => char >= 0x0D80 && char <= 0x0DFF,\n // 'Thai': (char) => char >= 0x0E00 && char <= 0x0E7F,\n // 'Lao': (char) => char >= 0x0E80 && char <= 0x0EFF,\n // 'Tibetan': (char) => char >= 0x0F00 && char <= 0x0FFF,\n // 'Myanmar': (char) => char >= 0x1000 && char <= 0x109F,\n // 'Georgian': (char) => char >= 0x10A0 && char <= 0x10FF,\n 'Hangul Jamo': (char) => char >= 0x1100 && char <= 0x11FF,\n // 'Ethiopic': (char) => char >= 0x1200 && char <= 0x137F,\n // 'Ethiopic Supplement': (char) => char >= 0x1380 && char <= 0x139F,\n // 'Cherokee': (char) => char >= 0x13A0 && char <= 0x13FF,\n 'Unified Canadian Aboriginal Syllabics': (char) => char >= 0x1400 && char <= 0x167F,\n // 'Ogham': (char) => char >= 0x1680 && char <= 0x169F,\n // 'Runic': (char) => char >= 0x16A0 && char <= 0x16FF,\n // 'Tagalog': (char) => char >= 0x1700 && char <= 0x171F,\n // 'Hanunoo': (char) => char >= 0x1720 && char <= 0x173F,\n // 'Buhid': (char) => char >= 0x1740 && char <= 0x175F,\n // 'Tagbanwa': (char) => char >= 0x1760 && char <= 0x177F,\n 'Khmer': (char) => char >= 0x1780 && char <= 0x17FF,\n // 'Mongolian': (char) => char >= 0x1800 && char <= 0x18AF,\n 'Unified Canadian Aboriginal Syllabics Extended': (char) => char >= 0x18B0 && char <= 0x18FF,\n // 'Limbu': (char) => char >= 0x1900 && char <= 0x194F,\n // 'Tai Le': (char) => char >= 0x1950 && char <= 0x197F,\n // 'New Tai Lue': (char) => char >= 0x1980 && char <= 0x19DF,\n // 'Khmer Symbols': (char) => char >= 0x19E0 && char <= 0x19FF,\n // 'Buginese': (char) => char >= 0x1A00 && char <= 0x1A1F,\n // 'Tai Tham': (char) => char >= 0x1A20 && char <= 0x1AAF,\n // 'Combining Diacritical Marks Extended': (char) => char >= 0x1AB0 && char <= 0x1AFF,\n // 'Balinese': (char) => char >= 0x1B00 && char <= 0x1B7F,\n // 'Sundanese': (char) => char >= 0x1B80 && char <= 0x1BBF,\n // 'Batak': (char) => char >= 0x1BC0 && char <= 0x1BFF,\n // 'Lepcha': (char) => char >= 0x1C00 && char <= 0x1C4F,\n // 'Ol Chiki': (char) => char >= 0x1C50 && char <= 0x1C7F,\n // 'Cyrillic Extended-C': (char) => char >= 0x1C80 && char <= 0x1C8F,\n // 'Georgian Extended': (char) => char >= 0x1C90 && char <= 0x1CBF,\n // 'Sundanese Supplement': (char) => char >= 0x1CC0 && char <= 0x1CCF,\n // 'Vedic Extensions': (char) => char >= 0x1CD0 && char <= 0x1CFF,\n // 'Phonetic Extensions': (char) => char >= 0x1D00 && char <= 0x1D7F,\n // 'Phonetic Extensions Supplement': (char) => char >= 0x1D80 && char <= 0x1DBF,\n // 'Combining Diacritical Marks Supplement': (char) => char >= 0x1DC0 && char <= 0x1DFF,\n // 'Latin Extended Additional': (char) => char >= 0x1E00 && char <= 0x1EFF,\n // 'Greek Extended': (char) => char >= 0x1F00 && char <= 0x1FFF,\n 'General Punctuation': (char) => char >= 0x2000 && char <= 0x206F,\n // 'Superscripts and Subscripts': (char) => char >= 0x2070 && char <= 0x209F,\n // 'Currency Symbols': (char) => char >= 0x20A0 && char <= 0x20CF,\n // 'Combining Diacritical Marks for Symbols': (char) => char >= 0x20D0 && char <= 0x20FF,\n 'Letterlike Symbols': (char) => char >= 0x2100 && char <= 0x214F,\n 'Number Forms': (char) => char >= 0x2150 && char <= 0x218F,\n // 'Arrows': (char) => char >= 0x2190 && char <= 0x21FF,\n // 'Mathematical Operators': (char) => char >= 0x2200 && char <= 0x22FF,\n 'Miscellaneous Technical': (char) => char >= 0x2300 && char <= 0x23FF,\n 'Control Pictures': (char) => char >= 0x2400 && char <= 0x243F,\n 'Optical Character Recognition': (char) => char >= 0x2440 && char <= 0x245F,\n 'Enclosed Alphanumerics': (char) => char >= 0x2460 && char <= 0x24FF,\n // 'Box Drawing': (char) => char >= 0x2500 && char <= 0x257F,\n // 'Block Elements': (char) => char >= 0x2580 && char <= 0x259F,\n 'Geometric Shapes': (char) => char >= 0x25A0 && char <= 0x25FF,\n 'Miscellaneous Symbols': (char) => char >= 0x2600 && char <= 0x26FF,\n // 'Dingbats': (char) => char >= 0x2700 && char <= 0x27BF,\n // 'Miscellaneous Mathematical Symbols-A': (char) => char >= 0x27C0 && char <= 0x27EF,\n // 'Supplemental Arrows-A': (char) => char >= 0x27F0 && char <= 0x27FF,\n // 'Braille Patterns': (char) => char >= 0x2800 && char <= 0x28FF,\n // 'Supplemental Arrows-B': (char) => char >= 0x2900 && char <= 0x297F,\n // 'Miscellaneous Mathematical Symbols-B': (char) => char >= 0x2980 && char <= 0x29FF,\n // 'Supplemental Mathematical Operators': (char) => char >= 0x2A00 && char <= 0x2AFF,\n 'Miscellaneous Symbols and Arrows': (char) => char >= 0x2B00 && char <= 0x2BFF,\n // 'Glagolitic': (char) => char >= 0x2C00 && char <= 0x2C5F,\n // 'Latin Extended-C': (char) => char >= 0x2C60 && char <= 0x2C7F,\n // 'Coptic': (char) => char >= 0x2C80 && char <= 0x2CFF,\n // 'Georgian Supplement': (char) => char >= 0x2D00 && char <= 0x2D2F,\n // 'Tifinagh': (char) => char >= 0x2D30 && char <= 0x2D7F,\n // 'Ethiopic Extended': (char) => char >= 0x2D80 && char <= 0x2DDF,\n // 'Cyrillic Extended-A': (char) => char >= 0x2DE0 && char <= 0x2DFF,\n // 'Supplemental Punctuation': (char) => char >= 0x2E00 && char <= 0x2E7F,\n 'CJK Radicals Supplement': (char) => char >= 0x2E80 && char <= 0x2EFF,\n 'Kangxi Radicals': (char) => char >= 0x2F00 && char <= 0x2FDF,\n 'Ideographic Description Characters': (char) => char >= 0x2FF0 && char <= 0x2FFF,\n 'CJK Symbols and Punctuation': (char) => char >= 0x3000 && char <= 0x303F,\n 'Hiragana': (char) => char >= 0x3040 && char <= 0x309F,\n 'Katakana': (char) => char >= 0x30A0 && char <= 0x30FF,\n 'Bopomofo': (char) => char >= 0x3100 && char <= 0x312F,\n 'Hangul Compatibility Jamo': (char) => char >= 0x3130 && char <= 0x318F,\n 'Kanbun': (char) => char >= 0x3190 && char <= 0x319F,\n 'Bopomofo Extended': (char) => char >= 0x31A0 && char <= 0x31BF,\n 'CJK Strokes': (char) => char >= 0x31C0 && char <= 0x31EF,\n 'Katakana Phonetic Extensions': (char) => char >= 0x31F0 && char <= 0x31FF,\n 'Enclosed CJK Letters and Months': (char) => char >= 0x3200 && char <= 0x32FF,\n 'CJK Compatibility': (char) => char >= 0x3300 && char <= 0x33FF,\n 'CJK Unified Ideographs Extension A': (char) => char >= 0x3400 && char <= 0x4DBF,\n 'Yijing Hexagram Symbols': (char) => char >= 0x4DC0 && char <= 0x4DFF,\n 'CJK Unified Ideographs': (char) => char >= 0x4E00 && char <= 0x9FFF,\n 'Yi Syllables': (char) => char >= 0xA000 && char <= 0xA48F,\n 'Yi Radicals': (char) => char >= 0xA490 && char <= 0xA4CF,\n // 'Lisu': (char) => char >= 0xA4D0 && char <= 0xA4FF,\n // 'Vai': (char) => char >= 0xA500 && char <= 0xA63F,\n // 'Cyrillic Extended-B': (char) => char >= 0xA640 && char <= 0xA69F,\n // 'Bamum': (char) => char >= 0xA6A0 && char <= 0xA6FF,\n // 'Modifier Tone Letters': (char) => char >= 0xA700 && char <= 0xA71F,\n // 'Latin Extended-D': (char) => char >= 0xA720 && char <= 0xA7FF,\n // 'Syloti Nagri': (char) => char >= 0xA800 && char <= 0xA82F,\n // 'Common Indic Number Forms': (char) => char >= 0xA830 && char <= 0xA83F,\n // 'Phags-pa': (char) => char >= 0xA840 && char <= 0xA87F,\n // 'Saurashtra': (char) => char >= 0xA880 && char <= 0xA8DF,\n // 'Devanagari Extended': (char) => char >= 0xA8E0 && char <= 0xA8FF,\n // 'Kayah Li': (char) => char >= 0xA900 && char <= 0xA92F,\n // 'Rejang': (char) => char >= 0xA930 && char <= 0xA95F,\n 'Hangul Jamo Extended-A': (char) => char >= 0xA960 && char <= 0xA97F,\n // 'Javanese': (char) => char >= 0xA980 && char <= 0xA9DF,\n // 'Myanmar Extended-B': (char) => char >= 0xA9E0 && char <= 0xA9FF,\n // 'Cham': (char) => char >= 0xAA00 && char <= 0xAA5F,\n // 'Myanmar Extended-A': (char) => char >= 0xAA60 && char <= 0xAA7F,\n // 'Tai Viet': (char) => char >= 0xAA80 && char <= 0xAADF,\n // 'Meetei Mayek Extensions': (char) => char >= 0xAAE0 && char <= 0xAAFF,\n // 'Ethiopic Extended-A': (char) => char >= 0xAB00 && char <= 0xAB2F,\n // 'Latin Extended-E': (char) => char >= 0xAB30 && char <= 0xAB6F,\n // 'Cherokee Supplement': (char) => char >= 0xAB70 && char <= 0xABBF,\n // 'Meetei Mayek': (char) => char >= 0xABC0 && char <= 0xABFF,\n 'Hangul Syllables': (char) => char >= 0xAC00 && char <= 0xD7AF,\n 'Hangul Jamo Extended-B': (char) => char >= 0xD7B0 && char <= 0xD7FF,\n // 'High Surrogates': (char) => char >= 0xD800 && char <= 0xDB7F,\n // 'High Private Use Surrogates': (char) => char >= 0xDB80 && char <= 0xDBFF,\n // 'Low Surrogates': (char) => char >= 0xDC00 && char <= 0xDFFF,\n 'Private Use Area': (char) => char >= 0xE000 && char <= 0xF8FF,\n 'CJK Compatibility Ideographs': (char) => char >= 0xF900 && char <= 0xFAFF,\n // 'Alphabetic Presentation Forms': (char) => char >= 0xFB00 && char <= 0xFB4F,\n 'Arabic Presentation Forms-A': (char) => char >= 0xFB50 && char <= 0xFDFF,\n // 'Variation Selectors': (char) => char >= 0xFE00 && char <= 0xFE0F,\n 'Vertical Forms': (char) => char >= 0xFE10 && char <= 0xFE1F,\n // 'Combining Half Marks': (char) => char >= 0xFE20 && char <= 0xFE2F,\n 'CJK Compatibility Forms': (char) => char >= 0xFE30 && char <= 0xFE4F,\n 'Small Form Variants': (char) => char >= 0xFE50 && char <= 0xFE6F,\n 'Arabic Presentation Forms-B': (char) => char >= 0xFE70 && char <= 0xFEFF,\n 'Halfwidth and Fullwidth Forms': (char) => char >= 0xFF00 && char <= 0xFFEF\n // 'Specials': (char) => char >= 0xFFF0 && char <= 0xFFFF,\n // 'Linear B Syllabary': (char) => char >= 0x10000 && char <= 0x1007F,\n // 'Linear B Ideograms': (char) => char >= 0x10080 && char <= 0x100FF,\n // 'Aegean Numbers': (char) => char >= 0x10100 && char <= 0x1013F,\n // 'Ancient Greek Numbers': (char) => char >= 0x10140 && char <= 0x1018F,\n // 'Ancient Symbols': (char) => char >= 0x10190 && char <= 0x101CF,\n // 'Phaistos Disc': (char) => char >= 0x101D0 && char <= 0x101FF,\n // 'Lycian': (char) => char >= 0x10280 && char <= 0x1029F,\n // 'Carian': (char) => char >= 0x102A0 && char <= 0x102DF,\n // 'Coptic Epact Numbers': (char) => char >= 0x102E0 && char <= 0x102FF,\n // 'Old Italic': (char) => char >= 0x10300 && char <= 0x1032F,\n // 'Gothic': (char) => char >= 0x10330 && char <= 0x1034F,\n // 'Old Permic': (char) => char >= 0x10350 && char <= 0x1037F,\n // 'Ugaritic': (char) => char >= 0x10380 && char <= 0x1039F,\n // 'Old Persian': (char) => char >= 0x103A0 && char <= 0x103DF,\n // 'Deseret': (char) => char >= 0x10400 && char <= 0x1044F,\n // 'Shavian': (char) => char >= 0x10450 && char <= 0x1047F,\n // 'Osmanya': (char) => char >= 0x10480 && char <= 0x104AF,\n // 'Osage': (char) => char >= 0x104B0 && char <= 0x104FF,\n // 'Elbasan': (char) => char >= 0x10500 && char <= 0x1052F,\n // 'Caucasian Albanian': (char) => char >= 0x10530 && char <= 0x1056F,\n // 'Linear A': (char) => char >= 0x10600 && char <= 0x1077F,\n // 'Cypriot Syllabary': (char) => char >= 0x10800 && char <= 0x1083F,\n // 'Imperial Aramaic': (char) => char >= 0x10840 && char <= 0x1085F,\n // 'Palmyrene': (char) => char >= 0x10860 && char <= 0x1087F,\n // 'Nabataean': (char) => char >= 0x10880 && char <= 0x108AF,\n // 'Hatran': (char) => char >= 0x108E0 && char <= 0x108FF,\n // 'Phoenician': (char) => char >= 0x10900 && char <= 0x1091F,\n // 'Lydian': (char) => char >= 0x10920 && char <= 0x1093F,\n // 'Meroitic Hieroglyphs': (char) => char >= 0x10980 && char <= 0x1099F,\n // 'Meroitic Cursive': (char) => char >= 0x109A0 && char <= 0x109FF,\n // 'Kharoshthi': (char) => char >= 0x10A00 && char <= 0x10A5F,\n // 'Old South Arabian': (char) => char >= 0x10A60 && char <= 0x10A7F,\n // 'Old North Arabian': (char) => char >= 0x10A80 && char <= 0x10A9F,\n // 'Manichaean': (char) => char >= 0x10AC0 && char <= 0x10AFF,\n // 'Avestan': (char) => char >= 0x10B00 && char <= 0x10B3F,\n // 'Inscriptional Parthian': (char) => char >= 0x10B40 && char <= 0x10B5F,\n // 'Inscriptional Pahlavi': (char) => char >= 0x10B60 && char <= 0x10B7F,\n // 'Psalter Pahlavi': (char) => char >= 0x10B80 && char <= 0x10BAF,\n // 'Old Turkic': (char) => char >= 0x10C00 && char <= 0x10C4F,\n // 'Old Hungarian': (char) => char >= 0x10C80 && char <= 0x10CFF,\n // 'Hanifi Rohingya': (char) => char >= 0x10D00 && char <= 0x10D3F,\n // 'Rumi Numeral Symbols': (char) => char >= 0x10E60 && char <= 0x10E7F,\n // 'Old Sogdian': (char) => char >= 0x10F00 && char <= 0x10F2F,\n // 'Sogdian': (char) => char >= 0x10F30 && char <= 0x10F6F,\n // 'Elymaic': (char) => char >= 0x10FE0 && char <= 0x10FFF,\n // 'Brahmi': (char) => char >= 0x11000 && char <= 0x1107F,\n // 'Kaithi': (char) => char >= 0x11080 && char <= 0x110CF,\n // 'Sora Sompeng': (char) => char >= 0x110D0 && char <= 0x110FF,\n // 'Chakma': (char) => char >= 0x11100 && char <= 0x1114F,\n // 'Mahajani': (char) => char >= 0x11150 && char <= 0x1117F,\n // 'Sharada': (char) => char >= 0x11180 && char <= 0x111DF,\n // 'Sinhala Archaic Numbers': (char) => char >= 0x111E0 && char <= 0x111FF,\n // 'Khojki': (char) => char >= 0x11200 && char <= 0x1124F,\n // 'Multani': (char) => char >= 0x11280 && char <= 0x112AF,\n // 'Khudawadi': (char) => char >= 0x112B0 && char <= 0x112FF,\n // 'Grantha': (char) => char >= 0x11300 && char <= 0x1137F,\n // 'Newa': (char) => char >= 0x11400 && char <= 0x1147F,\n // 'Tirhuta': (char) => char >= 0x11480 && char <= 0x114DF,\n // 'Siddham': (char) => char >= 0x11580 && char <= 0x115FF,\n // 'Modi': (char) => char >= 0x11600 && char <= 0x1165F,\n // 'Mongolian Supplement': (char) => char >= 0x11660 && char <= 0x1167F,\n // 'Takri': (char) => char >= 0x11680 && char <= 0x116CF,\n // 'Ahom': (char) => char >= 0x11700 && char <= 0x1173F,\n // 'Dogra': (char) => char >= 0x11800 && char <= 0x1184F,\n // 'Warang Citi': (char) => char >= 0x118A0 && char <= 0x118FF,\n // 'Nandinagari': (char) => char >= 0x119A0 && char <= 0x119FF,\n // 'Zanabazar Square': (char) => char >= 0x11A00 && char <= 0x11A4F,\n // 'Soyombo': (char) => char >= 0x11A50 && char <= 0x11AAF,\n // 'Pau Cin Hau': (char) => char >= 0x11AC0 && char <= 0x11AFF,\n // 'Bhaiksuki': (char) => char >= 0x11C00 && char <= 0x11C6F,\n // 'Marchen': (char) => char >= 0x11C70 && char <= 0x11CBF,\n // 'Masaram Gondi': (char) => char >= 0x11D00 && char <= 0x11D5F,\n // 'Gunjala Gondi': (char) => char >= 0x11D60 && char <= 0x11DAF,\n // 'Makasar': (char) => char >= 0x11EE0 && char <= 0x11EFF,\n // 'Tamil Supplement': (char) => char >= 0x11FC0 && char <= 0x11FFF,\n // 'Cuneiform': (char) => char >= 0x12000 && char <= 0x123FF,\n // 'Cuneiform Numbers and Punctuation': (char) => char >= 0x12400 && char <= 0x1247F,\n // 'Early Dynastic Cuneiform': (char) => char >= 0x12480 && char <= 0x1254F,\n // 'Egyptian Hieroglyphs': (char) => char >= 0x13000 && char <= 0x1342F,\n // 'Egyptian Hieroglyph Format Controls': (char) => char >= 0x13430 && char <= 0x1343F,\n // 'Anatolian Hieroglyphs': (char) => char >= 0x14400 && char <= 0x1467F,\n // 'Bamum Supplement': (char) => char >= 0x16800 && char <= 0x16A3F,\n // 'Mro': (char) => char >= 0x16A40 && char <= 0x16A6F,\n // 'Bassa Vah': (char) => char >= 0x16AD0 && char <= 0x16AFF,\n // 'Pahawh Hmong': (char) => char >= 0x16B00 && char <= 0x16B8F,\n // 'Medefaidrin': (char) => char >= 0x16E40 && char <= 0x16E9F,\n // 'Miao': (char) => char >= 0x16F00 && char <= 0x16F9F,\n // 'Ideographic Symbols and Punctuation': (char) => char >= 0x16FE0 && char <= 0x16FFF,\n // 'Tangut': (char) => char >= 0x17000 && char <= 0x187FF,\n // 'Tangut Components': (char) => char >= 0x18800 && char <= 0x18AFF,\n // 'Kana Supplement': (char) => char >= 0x1B000 && char <= 0x1B0FF,\n // 'Kana Extended-A': (char) => char >= 0x1B100 && char <= 0x1B12F,\n // 'Small Kana Extension': (char) => char >= 0x1B130 && char <= 0x1B16F,\n // 'Nushu': (char) => char >= 0x1B170 && char <= 0x1B2FF,\n // 'Duployan': (char) => char >= 0x1BC00 && char <= 0x1BC9F,\n // 'Shorthand Format Controls': (char) => char >= 0x1BCA0 && char <= 0x1BCAF,\n // 'Byzantine Musical Symbols': (char) => char >= 0x1D000 && char <= 0x1D0FF,\n // 'Musical Symbols': (char) => char >= 0x1D100 && char <= 0x1D1FF,\n // 'Ancient Greek Musical Notation': (char) => char >= 0x1D200 && char <= 0x1D24F,\n // 'Mayan Numerals': (char) => char >= 0x1D2E0 && char <= 0x1D2FF,\n // 'Tai Xuan Jing Symbols': (char) => char >= 0x1D300 && char <= 0x1D35F,\n // 'Counting Rod Numerals': (char) => char >= 0x1D360 && char <= 0x1D37F,\n // 'Mathematical Alphanumeric Symbols': (char) => char >= 0x1D400 && char <= 0x1D7FF,\n // 'Sutton SignWriting': (char) => char >= 0x1D800 && char <= 0x1DAAF,\n // 'Glagolitic Supplement': (char) => char >= 0x1E000 && char <= 0x1E02F,\n // 'Nyiakeng Puachue Hmong': (char) => char >= 0x1E100 && char <= 0x1E14F,\n // 'Wancho': (char) => char >= 0x1E2C0 && char <= 0x1E2FF,\n // 'Mende Kikakui': (char) => char >= 0x1E800 && char <= 0x1E8DF,\n // 'Adlam': (char) => char >= 0x1E900 && char <= 0x1E95F,\n // 'Indic Siyaq Numbers': (char) => char >= 0x1EC70 && char <= 0x1ECBF,\n // 'Ottoman Siyaq Numbers': (char) => char >= 0x1ED00 && char <= 0x1ED4F,\n // 'Arabic Mathematical Alphabetic Symbols': (char) => char >= 0x1EE00 && char <= 0x1EEFF,\n // 'Mahjong Tiles': (char) => char >= 0x1F000 && char <= 0x1F02F,\n // 'Domino Tiles': (char) => char >= 0x1F030 && char <= 0x1F09F,\n // 'Playing Cards': (char) => char >= 0x1F0A0 && char <= 0x1F0FF,\n // 'Enclosed Alphanumeric Supplement': (char) => char >= 0x1F100 && char <= 0x1F1FF,\n // 'Enclosed Ideographic Supplement': (char) => char >= 0x1F200 && char <= 0x1F2FF,\n // 'Miscellaneous Symbols and Pictographs': (char) => char >= 0x1F300 && char <= 0x1F5FF,\n // 'Emoticons': (char) => char >= 0x1F600 && char <= 0x1F64F,\n // 'Ornamental Dingbats': (char) => char >= 0x1F650 && char <= 0x1F67F,\n // 'Transport and Map Symbols': (char) => char >= 0x1F680 && char <= 0x1F6FF,\n // 'Alchemical Symbols': (char) => char >= 0x1F700 && char <= 0x1F77F,\n // 'Geometric Shapes Extended': (char) => char >= 0x1F780 && char <= 0x1F7FF,\n // 'Supplemental Arrows-C': (char) => char >= 0x1F800 && char <= 0x1F8FF,\n // 'Supplemental Symbols and Pictographs': (char) => char >= 0x1F900 && char <= 0x1F9FF,\n // 'Chess Symbols': (char) => char >= 0x1FA00 && char <= 0x1FA6F,\n // 'Symbols and Pictographs Extended-A': (char) => char >= 0x1FA70 && char <= 0x1FAFF,\n // 'CJK Unified Ideographs Extension B': (char) => char >= 0x20000 && char <= 0x2A6DF,\n // 'CJK Unified Ideographs Extension C': (char) => char >= 0x2A700 && char <= 0x2B73F,\n // 'CJK Unified Ideographs Extension D': (char) => char >= 0x2B740 && char <= 0x2B81F,\n // 'CJK Unified Ideographs Extension E': (char) => char >= 0x2B820 && char <= 0x2CEAF,\n // 'CJK Unified Ideographs Extension F': (char) => char >= 0x2CEB0 && char <= 0x2EBEF,\n // 'CJK Compatibility Ideographs Supplement': (char) => char >= 0x2F800 && char <= 0x2FA1F,\n // 'Tags': (char) => char >= 0xE0000 && char <= 0xE007F,\n // 'Variation Selectors Supplement': (char) => char >= 0xE0100 && char <= 0xE01EF,\n // 'Supplementary Private Use Area-A': (char) => char >= 0xF0000 && char <= 0xFFFFF,\n // 'Supplementary Private Use Area-B': (char) => char >= 0x100000 && char <= 0x10FFFF,\n};\n","/* eslint-disable new-cap */\n\nimport {unicodeBlockLookup as isChar} from './is_char_in_unicode_block';\n\nexport function allowsIdeographicBreaking(chars: string) {\n for (const char of chars) {\n if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function allowsVerticalWritingMode(chars: string) {\n for (const char of chars) {\n if (charHasUprightVerticalOrientation(char.charCodeAt(0))) return true;\n }\n return false;\n}\n\nexport function allowsLetterSpacing(chars: string) {\n for (const char of chars) {\n if (!charAllowsLetterSpacing(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function charAllowsLetterSpacing(char: number) {\n if (isChar['Arabic'](char)) return false;\n if (isChar['Arabic Supplement'](char)) return false;\n if (isChar['Arabic Extended-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-B'](char)) return false;\n\n return true;\n}\n\nexport function charAllowsIdeographicBreaking(char: number) {\n // Return early for characters outside all ideographic ranges.\n if (char < 0x2E80) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n\n return false;\n}\n\n// The following logic comes from\n// .\n// Keep it synchronized with\n// .\n// The data file denotes with “U” or “Tu” any codepoint that may be drawn\n// upright in vertical text but does not distinguish between upright and\n// “neutral” characters.\n\n// Blocks in the Unicode supplementary planes are excluded from this module due\n// to .\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * upright orientation.\n *\n * A character has upright orientation if it is drawn upright (unrotated)\n * whether the line is oriented horizontally or vertically, even if both\n * adjacent characters can be rotated. For example, a Chinese character is\n * always drawn upright. An uprightly oriented character causes an adjacent\n * “neutral” character to be drawn upright as well.\n */\nexport function charHasUprightVerticalOrientation(char: number) {\n if (char === 0x02EA /* modifier letter yin departing tone mark */ ||\n char === 0x02EB /* modifier letter yang departing tone mark */) {\n return true;\n }\n\n // Return early for characters outside all ranges whose characters remain\n // upright in vertical writing mode.\n if (char < 0x1100) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) {\n if (!((char >= 0xFE49 /* dashed overline */ && char <= 0xFE4F) /* wavy low line */)) {\n return true;\n }\n }\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) {\n if (!((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) &&\n !((char >= 0x3014 /* left tortoise shell bracket */ && char <= 0x301F) /* low double prime quotation mark */) &&\n char !== 0x3030 /* wavy dash */) {\n return true;\n }\n }\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Hangul Compatibility Jamo'](char)) return true;\n if (isChar['Hangul Jamo Extended-A'](char)) return true;\n if (isChar['Hangul Jamo Extended-B'](char)) return true;\n if (isChar['Hangul Jamo'](char)) return true;\n if (isChar['Hangul Syllables'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kanbun'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) {\n if (char !== 0x30FC /* katakana-hiragana prolonged sound mark */) {\n return true;\n }\n }\n if (isChar['Halfwidth and Fullwidth Forms'](char)) {\n if (char !== 0xFF08 /* fullwidth left parenthesis */ &&\n char !== 0xFF09 /* fullwidth right parenthesis */ &&\n char !== 0xFF0D /* fullwidth hyphen-minus */ &&\n !((char >= 0xFF1A /* fullwidth colon */ && char <= 0xFF1E) /* fullwidth greater-than sign */) &&\n char !== 0xFF3B /* fullwidth left square bracket */ &&\n char !== 0xFF3D /* fullwidth right square bracket */ &&\n char !== 0xFF3F /* fullwidth low line */ &&\n !(char >= 0xFF5B /* fullwidth left curly bracket */ && char <= 0xFFDF) &&\n char !== 0xFFE3 /* fullwidth macron */ &&\n !(char >= 0xFFE8 /* halfwidth forms light vertical */ && char <= 0xFFEF)) {\n return true;\n }\n }\n if (isChar['Small Form Variants'](char)) {\n if (!((char >= 0xFE58 /* small em dash */ && char <= 0xFE5E) /* small right tortoise shell bracket */) &&\n !((char >= 0xFE63 /* small hyphen-minus */ && char <= 0xFE66) /* small equals sign */)) {\n return true;\n }\n }\n if (isChar['Unified Canadian Aboriginal Syllabics'](char)) return true;\n if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yijing Hexagram Symbols'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * neutral orientation.\n *\n * A character has neutral orientation if it may be drawn rotated or unrotated\n * when the line is oriented vertically, depending on the orientation of the\n * adjacent characters. For example, along a verticlly oriented line, the vulgar\n * fraction ½ is drawn upright among Chinese characters but rotated among Latin\n * letters. A neutrally oriented character does not influence whether an\n * adjacent character is drawn upright or rotated.\n */\nexport function charHasNeutralVerticalOrientation(char: number) {\n if (isChar['Latin-1 Supplement'](char)) {\n if (char === 0x00A7 /* section sign */ ||\n char === 0x00A9 /* copyright sign */ ||\n char === 0x00AE /* registered sign */ ||\n char === 0x00B1 /* plus-minus sign */ ||\n char === 0x00BC /* vulgar fraction one quarter */ ||\n char === 0x00BD /* vulgar fraction one half */ ||\n char === 0x00BE /* vulgar fraction three quarters */ ||\n char === 0x00D7 /* multiplication sign */ ||\n char === 0x00F7 /* division sign */) {\n return true;\n }\n }\n if (isChar['General Punctuation'](char)) {\n if (char === 0x2016 /* double vertical line */ ||\n char === 0x2020 /* dagger */ ||\n char === 0x2021 /* double dagger */ ||\n char === 0x2030 /* per mille sign */ ||\n char === 0x2031 /* per ten thousand sign */ ||\n char === 0x203B /* reference mark */ ||\n char === 0x203C /* double exclamation mark */ ||\n char === 0x2042 /* asterism */ ||\n char === 0x2047 /* double question mark */ ||\n char === 0x2048 /* question exclamation mark */ ||\n char === 0x2049 /* exclamation question mark */ ||\n char === 0x2051 /* two asterisks aligned vertically */) {\n return true;\n }\n }\n if (isChar['Letterlike Symbols'](char)) return true;\n if (isChar['Number Forms'](char)) return true;\n if (isChar['Miscellaneous Technical'](char)) {\n if ((char >= 0x2300 /* diameter sign */ && char <= 0x2307 /* wavy line */) ||\n (char >= 0x230C /* bottom right crop */ && char <= 0x231F /* bottom right corner */) ||\n (char >= 0x2324 /* up arrowhead between two horizontal bars */ && char <= 0x2328 /* keyboard */) ||\n char === 0x232B /* erase to the left */ ||\n (char >= 0x237D /* shouldered open box */ && char <= 0x239A /* clear screen symbol */) ||\n (char >= 0x23BE /* dentistry symbol light vertical and top right */ && char <= 0x23CD /* square foot */) ||\n char === 0x23CF /* eject symbol */ ||\n (char >= 0x23D1 /* metrical breve */ && char <= 0x23DB /* fuse */) ||\n (char >= 0x23E2 /* white trapezium */ && char <= 0x23FF)) {\n return true;\n }\n }\n if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) return true;\n if (isChar['Optical Character Recognition'](char)) return true;\n if (isChar['Enclosed Alphanumerics'](char)) return true;\n if (isChar['Geometric Shapes'](char)) return true;\n if (isChar['Miscellaneous Symbols'](char)) {\n if (!((char >= 0x261A /* black left pointing index */ && char <= 0x261F) /* white down pointing index */)) {\n return true;\n }\n }\n if (isChar['Miscellaneous Symbols and Arrows'](char)) {\n if ((char >= 0x2B12 /* square with top half black */ && char <= 0x2B2F /* white vertical ellipse */) ||\n (char >= 0x2B50 /* white medium star */ && char <= 0x2B59 /* heavy circled saltire */) ||\n (char >= 0x2BB8 /* upwards white arrow from bar with horizontal bar */ && char <= 0x2BEB)) {\n return true;\n }\n }\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Private Use Area'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['Small Form Variants'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n\n if (char === 0x221E /* infinity */ ||\n char === 0x2234 /* therefore */ ||\n char === 0x2235 /* because */ ||\n (char >= 0x2700 /* black safety scissors */ && char <= 0x2767 /* rotated floral heart bullet */) ||\n (char >= 0x2776 /* dingbat negative circled digit one */ && char <= 0x2793 /* dingbat negative circled sans-serif number ten */) ||\n char === 0xFFFC /* object replacement character */ ||\n char === 0xFFFD /* replacement character */) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * rotated orientation.\n *\n * A character has rotated orientation if it is drawn rotated when the line is\n * oriented vertically, even if both adjacent characters are upright. For\n * example, a Latin letter is drawn rotated along a vertical line. A rotated\n * character causes an adjacent “neutral” character to be drawn rotated as well.\n */\nexport function charHasRotatedVerticalOrientation(char: number) {\n return !(charHasUprightVerticalOrientation(char) ||\n charHasNeutralVerticalOrientation(char));\n}\n\nexport function charInComplexShapingScript(char: number) {\n return isChar['Arabic'](char) ||\n isChar['Arabic Supplement'](char) ||\n isChar['Arabic Extended-A'](char) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInRTLScript(char: number) {\n // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts\n return (char >= 0x0590 && char <= 0x08FF) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInSupportedScript(char: number, canRenderRTL: boolean) {\n // This is a rough heuristic: whether we \"can render\" a script\n // actually depends on the properties of the font being used\n // and whether differences from the ideal rendering are considered\n // semantically significant.\n\n // Even in Latin script, we \"can't render\" combinations such as the fi\n // ligature, but we don't consider that semantically significant.\n if (!canRenderRTL && charInRTLScript(char)) {\n return false;\n }\n if ((char >= 0x0900 && char <= 0x0DFF) ||\n // Main blocks for Indic scripts and Sinhala\n (char >= 0x0F00 && char <= 0x109F) ||\n // Main blocks for Tibetan and Myanmar\n isChar['Khmer'](char)) {\n // These blocks cover common scripts that require\n // complex text shaping, based on unicode script metadata:\n // http://www.unicode.org/repos/cldr/trunk/common/properties/scriptMetadata.txt\n // where \"Web Rank <= 32\" \"Shaping Required = YES\"\n return false;\n }\n return true;\n}\n\nexport function stringContainsRTLText(chars: string): boolean {\n for (const char of chars) {\n if (charInRTLScript(char.charCodeAt(0))) {\n return true;\n }\n }\n return false;\n}\n\nexport function isStringInSupportedScript(chars: string, canRenderRTL: boolean) {\n for (const char of chars) {\n if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {\n return false;\n }\n }\n return true;\n}\n","import {getArrayBuffer} from '../util/ajax';\nimport {browser} from '../util/browser';\nimport {Event, Evented} from '../util/evented';\nimport {isWorker} from '../util/util';\n\nconst status = {\n unavailable: 'unavailable', // Not loaded\n deferred: 'deferred', // The plugin URL has been specified, but loading has been deferred\n loading: 'loading', // request in-flight\n loaded: 'loaded',\n error: 'error'\n};\n\nexport type PluginState = {\n pluginStatus: typeof status[keyof typeof status];\n pluginURL: string;\n};\n\n/**\n * An error callback\n */\ntype ErrorCallback = (error?: Error | null) => void;\ntype PluginStateSyncCallback = (state: PluginState) => void;\nlet _completionCallback = null;\n\n//Variables defining the current state of the plugin\nlet pluginStatus = status.unavailable;\nlet pluginURL = null;\n\nexport const triggerPluginCompletionEvent = function(error: Error | string) {\n // NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin\n if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) {\n pluginStatus = status.error;\n }\n\n if (_completionCallback) {\n _completionCallback(error);\n }\n};\n\nfunction sendPluginStateToWorker() {\n evented.fire(new Event('pluginStateChange', {pluginStatus, pluginURL}));\n}\n\nexport const evented = new Evented();\n\nexport const getRTLTextPluginStatus = function () {\n return pluginStatus;\n};\n\nexport const registerForPluginStateChange = function(callback: PluginStateSyncCallback) {\n // Do an initial sync of the state\n callback({pluginStatus, pluginURL});\n // Listen for all future state changes\n evented.on('pluginStateChange', callback);\n return callback;\n};\n\nexport const clearRTLTextPlugin = function() {\n pluginStatus = status.unavailable;\n pluginURL = null;\n _completionCallback = null;\n};\n\nexport const setRTLTextPlugin = function(url: string, callback: ErrorCallback, deferred: boolean = false) {\n if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) {\n throw new Error('setRTLTextPlugin cannot be called multiple times.');\n }\n pluginURL = browser.resolveURL(url);\n pluginStatus = status.deferred;\n _completionCallback = callback;\n sendPluginStateToWorker();\n\n //Start downloading the plugin immediately if not intending to lazy-load\n if (!deferred) {\n downloadRTLTextPlugin();\n }\n};\n\nexport const downloadRTLTextPlugin = function() {\n if (pluginStatus !== status.deferred || !pluginURL) {\n throw new Error('rtl-text-plugin cannot be downloaded unless a pluginURL is specified');\n }\n pluginStatus = status.loading;\n sendPluginStateToWorker();\n if (pluginURL) {\n getArrayBuffer({url: pluginURL}, (error) => {\n if (error) {\n triggerPluginCompletionEvent(error);\n } else {\n pluginStatus = status.loaded;\n sendPluginStateToWorker();\n }\n });\n }\n};\n\nexport const plugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n isLoaded: () => boolean;\n isLoading: () => boolean;\n setState: (state: PluginState) => void;\n isParsed: () => boolean;\n getPluginURL: () => string;\n} = {\n applyArabicShaping: null,\n processBidirectionalText: null,\n processStyledBidirectionalText: null,\n isLoaded() {\n return pluginStatus === status.loaded || // Main Thread: loaded if the completion callback returned successfully\n plugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled\n },\n isLoading() { // Main Thread Only: query the loading status, this function does not return the correct value in the worker context.\n return pluginStatus === status.loading;\n },\n setState(state: PluginState) { // Worker thread only: this tells the worker threads that the plugin is available on the Main thread\n if (!isWorker()) throw new Error('Cannot set the state of the rtl-text-plugin when not in the web-worker context');\n\n pluginStatus = state.pluginStatus;\n pluginURL = state.pluginURL;\n },\n isParsed(): boolean {\n if (!isWorker()) throw new Error('rtl-text-plugin is only parsed on the worker-threads');\n\n return plugin.applyArabicShaping != null &&\n plugin.processBidirectionalText != null &&\n plugin.processStyledBidirectionalText != null;\n },\n getPluginURL(): string {\n if (!isWorker()) throw new Error('rtl-text-plugin url can only be queried from the worker threads');\n return pluginURL;\n }\n};\n\nexport const lazyLoadRTLTextPlugin = function() {\n if (!plugin.isLoading() &&\n !plugin.isLoaded() &&\n getRTLTextPluginStatus() === 'deferred'\n ) {\n downloadRTLTextPlugin();\n }\n};\n","import {ZoomHistory} from './zoom_history';\nimport {isStringInSupportedScript} from '../util/script_detection';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {TransitionSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CrossfadeParameters = {\n fromScale: number;\n toScale: number;\n t: number;\n};\n\n/**\n * @internal\n * A parameter that can be evaluated to a value\n */\nexport class EvaluationParameters {\n zoom: number;\n now: number;\n fadeDuration: number;\n zoomHistory: ZoomHistory;\n transition: TransitionSpecification;\n\n // \"options\" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate\n constructor(zoom: number, options?: any) {\n this.zoom = zoom;\n\n if (options) {\n this.now = options.now;\n this.fadeDuration = options.fadeDuration;\n this.zoomHistory = options.zoomHistory;\n this.transition = options.transition;\n } else {\n this.now = 0;\n this.fadeDuration = 0;\n this.zoomHistory = new ZoomHistory();\n this.transition = {};\n }\n }\n\n isSupportedScript(str: string): boolean {\n return isStringInSupportedScript(str, rtlTextPlugin.isLoaded());\n }\n\n crossFadingFactor() {\n if (this.fadeDuration === 0) {\n return 1;\n } else {\n return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);\n }\n }\n\n getCrossfadeParameters(): CrossfadeParameters {\n const z = this.zoom;\n const fraction = z - Math.floor(z);\n const t = this.crossFadingFactor();\n\n return z > this.zoomHistory.lastIntegerZoom ?\n {fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t} :\n {fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction};\n }\n}\n","import {clone, extend, easeCubicInOut} from '../util/util';\nimport {interpolates, Color, StylePropertySpecification, normalizePropertyExpression,\n Feature,\n FeatureState,\n StylePropertyExpression,\n SourceExpression,\n CompositeExpression, TransitionSpecification,\n PropertyValueSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from './evaluation_parameters';\n\nimport {CanonicalTileID} from '../source/tile_id';\n\ntype TimePoint = number;\n\n/**\n * A from-to type\n */\nexport type CrossFaded = {\n to: T;\n from: T;\n};\n\n/**\n * @internal\n * Implementations of the `Property` interface:\n *\n * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value,\n * the default value, etc. This comes from the style specification JSON.\n * * Define behavior that needs to be polymorphic across different properties: \"possibly evaluating\"\n * an input value (see below), and interpolating between two possibly-evaluted values.\n *\n * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`).\n * The type `R` is the intermediate \"possibly evaluated\" value type. See below.\n *\n * There are two main implementations of the interface -- one for properties that allow data-driven values,\n * and one for properties that don't. There are a few \"special case\" implementations as well: one for properties\n * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`,\n * and one for `light-position`.\n */\nexport interface Property {\n specification: StylePropertySpecification;\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R;\n interpolate(a: R, b: R, t: number): R;\n}\n\n/**\n * @internal\n * `PropertyValue` represents the value part of a property key-value unit. It's used to represent both\n * paint and layout property values, and regardless of whether or not their property supports data-driven\n * expressions.\n *\n * `PropertyValue` stores the raw input value as seen in a style or a runtime styling API call, i.e. one of the\n * following:\n *\n * * A constant value of the type appropriate for the property\n * * A function which produces a value of that type (but functions are quasi-deprecated in favor of expressions)\n * * An expression which produces a value of that type\n * * \"undefined\"/\"not present\", in which case the property is assumed to take on its default value.\n *\n * In addition to storing the original input value, `PropertyValue` also stores a normalized representation,\n * effectively treating functions as if they are expressions, and constant or default values as if they are\n * (constant) expressions.\n */\nexport class PropertyValue {\n property: Property;\n value: PropertyValueSpecification | void;\n expression: StylePropertyExpression;\n\n constructor(property: Property, value: PropertyValueSpecification | void) {\n this.property = property;\n this.value = value;\n this.expression = normalizePropertyExpression(value === undefined ? property.specification.default : value, property.specification);\n }\n\n isDataDriven(): boolean {\n return this.expression.kind === 'source' || this.expression.kind === 'composite';\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R {\n return this.property.possiblyEvaluate(this, parameters, canonical, availableImages);\n }\n}\n\nexport type TransitionParameters = {\n now: TimePoint;\n transition: TransitionSpecification;\n};\n\n/**\n * @internal\n * Paint properties are _transitionable_: they can change in a fluid manner, interpolating or cross-fading between\n * old and new value. The duration of the transition, and the delay before it begins, is configurable.\n *\n * `TransitionablePropertyValue` is a compositional class that stores both the property value and that transition\n * configuration.\n *\n * A `TransitionablePropertyValue` can calculate the next step in the evaluation chain for paint property values:\n * `TransitioningPropertyValue`.\n */\nclass TransitionablePropertyValue {\n property: Property;\n value: PropertyValue;\n transition: TransitionSpecification | void;\n\n constructor(property: Property) {\n this.property = property;\n this.value = new PropertyValue(property, undefined);\n }\n\n transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, prior,\n extend({}, parameters.transition, this.transition), parameters.now);\n }\n\n untransitioned(): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, null, {}, 0);\n }\n}\n\n/**\n * @internal\n * `Transitionable` stores a map of all (property name, `TransitionablePropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the `TransitioningPropertyValue`s for all of them at once, producing a\n * `Transitioning` instance for the same set of properties.\n */\nexport class Transitionable {\n _properties: Properties;\n _values: {[K in keyof Props]: TransitionablePropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitionablePropertyValues) as any);\n }\n\n getValue(name: S): PropertyValueSpecification | void {\n return clone(this._values[name].value.value);\n }\n\n setValue(name: S, value: PropertyValueSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n // Note that we do not _remove_ an own property in the case where a value is being reset\n // to the default: the transition might still be non-default.\n this._values[name].value = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value));\n }\n\n getTransition(name: S): TransitionSpecification | void {\n return clone(this._values[name].transition);\n }\n\n setTransition(name: S, value: TransitionSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n this._values[name].transition = clone(value) || undefined;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n\n const transition = this.getTransition(property as keyof Props);\n if (transition !== undefined) {\n result[`${property}-transition`] = transition;\n }\n }\n return result;\n }\n\n transitioned(parameters: TransitionParameters, prior: Transitioning): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].transitioned(parameters, prior._values[property]);\n }\n return result;\n }\n\n untransitioned(): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].untransitioned();\n }\n return result;\n }\n}\n\n/**\n * @internal\n * `TransitioningPropertyValue` implements the first of two intermediate steps in the evaluation chain of a paint\n * property value. In this step, transitions between old and new values are handled: as long as the transition is in\n * progress, `TransitioningPropertyValue` maintains a reference to the prior value, and interpolates between it and\n * the new value based on the current time and the configured transition duration and delay. The product is the next\n * step in the evaluation chain: the \"possibly evaluated\" result type `R`. See below for more on this concept.\n */\nclass TransitioningPropertyValue {\n property: Property;\n value: PropertyValue;\n prior: TransitioningPropertyValue;\n begin: TimePoint;\n end: TimePoint;\n\n constructor(property: Property,\n value: PropertyValue,\n prior: TransitioningPropertyValue,\n transition: TransitionSpecification,\n now: TimePoint) {\n this.property = property;\n this.value = value;\n this.begin = now + transition.delay || 0;\n this.end = this.begin + transition.duration || 0;\n if (property.specification.transition && (transition.delay || transition.duration)) {\n this.prior = prior;\n }\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical: CanonicalTileID,\n availableImages: Array\n ): R {\n const now = parameters.now || 0;\n const finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages);\n const prior = this.prior;\n if (!prior) {\n // No prior value.\n return finalValue;\n } else if (now > this.end) {\n // Transition from prior value is now complete.\n this.prior = null;\n return finalValue;\n } else if (this.value.isDataDriven()) {\n // Transitions to data-driven properties are not supported.\n // We snap immediately to the data-driven value so that, when we perform layout,\n // we see the data-driven function and can use it to populate vertex buffers.\n this.prior = null;\n return finalValue;\n } else if (now < this.begin) {\n // Transition hasn't started yet.\n return prior.possiblyEvaluate(parameters, canonical, availableImages);\n } else {\n // Interpolate between recursively-calculated prior value and final.\n const t = (now - this.begin) / (this.end - this.begin);\n return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t));\n }\n }\n}\n\n/**\n * @internal\n * `Transitioning` stores a map of all (property name, `TransitioningPropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Transitioning {\n _properties: Properties;\n _values: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitioningPropertyValues) as any);\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n\n hasTransition() {\n for (const property of Object.keys(this._values)) {\n if (this._values[property].prior) {\n return true;\n }\n }\n return false;\n }\n}\n\n// ------- Layout -------\n\n/**\n * Because layout properties are not transitionable, they have a simpler representation and evaluation chain than\n * paint properties: `PropertyValue`s are possibly evaluated, producing possibly evaluated values, which are then\n * fully evaluated.\n *\n * `Layout` stores a map of all (property name, `PropertyValue`) pairs for layout properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Layout {\n _properties: Properties;\n _values: {[K in keyof Props]: PropertyValue>};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultPropertyValues) as any);\n }\n\n hasValue(name: S) {\n return this._values[name].value !== undefined;\n }\n\n getValue(name: S) {\n return clone(this._values[name].value);\n }\n\n setValue(name: S, value: any) {\n this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value)) as any;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n }\n return result;\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n}\n\n// ------- PossiblyEvaluated -------\n\n/**\n * \"Possibly evaluated value\" is an intermediate stage in the evaluation chain for both paint and layout property\n * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code\n * which uses data-driven property values must assume that the value is dependent on feature data, and request that it\n * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation\n * will not actually depend on the feature, and we can benefit from returning the prior result of having done the\n * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and \"global\" parameters\n * such as current zoom level.\n *\n * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or\n * camera expression, then the \"possibly evaluated\" result is a constant value. Otherwise, the input value was either\n * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate\n * the source and composite cases because they are handled differently when generating GL attributes, buffers, and\n * uniforms.\n *\n * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that\n * do not allow data-driven values. For such properties, we know that the \"possibly evaluated\" result is always a constant\n * scalar value. See below.\n */\ntype PossiblyEvaluatedValue = {\n kind: 'constant';\n value: T;\n} | SourceExpression | CompositeExpression;\n\n/**\n * @internal\n * `PossiblyEvaluatedPropertyValue` is used for data-driven paint and layout property values. It holds a\n * `PossiblyEvaluatedValue` and the `GlobalProperties` that were used to generate it. You're not allowed to supply\n * a different set of `GlobalProperties` when performing the final evaluation because they would be ignored in the\n * case where the input value was a constant or camera function.\n */\nexport class PossiblyEvaluatedPropertyValue {\n property: DataDrivenProperty;\n value: PossiblyEvaluatedValue;\n parameters: EvaluationParameters;\n\n constructor(property: DataDrivenProperty, value: PossiblyEvaluatedValue, parameters: EvaluationParameters) {\n this.property = property;\n this.value = value;\n this.parameters = parameters;\n }\n\n isConstant(): boolean {\n return this.value.kind === 'constant';\n }\n\n constantOr(value: T): T {\n if (this.value.kind === 'constant') {\n return this.value.value;\n } else {\n return value;\n }\n }\n\n evaluate(\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages);\n }\n}\n\n/**\n * @internal\n * `PossiblyEvaluated` stores a map of all (property name, `R`) pairs for paint or layout properties of a\n * given layer type.\n */\nexport class PossiblyEvaluated {\n _properties: Properties;\n _values: PossibleEvaluatedProps;\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = Object.create(properties.defaultPossiblyEvaluatedValues);\n }\n\n get(name: S): PossibleEvaluatedProps[S] {\n return this._values[name];\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that do not permit data-driven (source or composite) expressions.\n * This restriction allows us to declare statically that the result of possibly evaluating this kind of property\n * is in fact always the scalar type `T`, and can be used without further evaluating the value on a per-feature basis.\n */\nexport class DataConstantProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters): T {\n if (value.isDataDriven()) throw new Error('Value should not be data driven');\n return value.expression.evaluate(parameters);\n }\n\n interpolate(a: T, b: T, t: number): T {\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n return interpolationFn(a, b, t);\n } else {\n return a;\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that permit data-driven (source or composite) expressions.\n * The result of possibly evaluating this kind of property is `PossiblyEvaluatedPropertyValue`; obtaining\n * a scalar value `T` requires further evaluation on a per-feature basis.\n */\nexport class DataDrivenProperty implements Property> {\n specification: StylePropertySpecification;\n overrides: any;\n\n constructor(specification: StylePropertySpecification, overrides?: any) {\n this.specification = specification;\n this.overrides = overrides;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue {\n if (value.expression.kind === 'constant' || value.expression.kind === 'camera') {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: value.expression.evaluate(parameters, null, {}, canonical, availableImages)}, parameters);\n } else {\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n interpolate(\n a: PossiblyEvaluatedPropertyValue,\n b: PossiblyEvaluatedPropertyValue,\n t: number\n ): PossiblyEvaluatedPropertyValue {\n // If either possibly-evaluated value is non-constant, give up: we aren't able to interpolate data-driven values.\n if (a.value.kind !== 'constant' || b.value.kind !== 'constant') {\n return a;\n }\n\n // Special case hack solely for fill-outline-color. The undefined value is subsequently handled in\n // FillStyleLayer#recalculate, which sets fill-outline-color to the fill-color value if the former\n // is a PossiblyEvaluatedPropertyValue containing a constant undefined value. In addition to the\n // return value here, the other source of a PossiblyEvaluatedPropertyValue containing a constant\n // undefined value is the \"default value\" for fill-outline-color held in\n // `Properties#defaultPossiblyEvaluatedValues`, which serves as the prototype of\n // `PossiblyEvaluated#_values`.\n if (a.value.value === undefined || b.value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, a.parameters);\n }\n\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n const interpolatedValue = interpolationFn(a.value.value, b.value.value, t);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: interpolatedValue}, a.parameters);\n } else {\n return a;\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue,\n parameters: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return value.evaluate(parameters, feature, featureState, canonical, availableImages);\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for data driven `line-pattern` which are transitioned by cross-fading\n * rather than interpolation.\n */\n\nexport class CrossFadedDataDrivenProperty extends DataDrivenProperty> {\n\n possiblyEvaluate(\n value: PropertyValue, PossiblyEvaluatedPropertyValue>>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue> {\n if (value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, parameters);\n } else if (value.expression.kind === 'constant') {\n const evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n const isImageExpression = value.property.specification.type as any === 'resolvedImage';\n const constantValue = isImageExpression && typeof evaluatedValue !== 'string' ? evaluatedValue.name : evaluatedValue;\n const constant = this._calculate(constantValue, constantValue, constantValue, parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: constant}, parameters);\n } else if (value.expression.kind === 'camera') {\n const cameraVal = this._calculate(\n value.expression.evaluate({zoom: parameters.zoom - 1.0}),\n value.expression.evaluate({zoom: parameters.zoom}),\n value.expression.evaluate({zoom: parameters.zoom + 1.0}),\n parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: cameraVal}, parameters);\n } else {\n // source or composite expression\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue>,\n globals: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.kind === 'source') {\n const constant = value.evaluate(globals, feature, featureState, canonical, availableImages);\n return this._calculate(constant, constant, constant, globals);\n } else if (value.kind === 'composite') {\n return this._calculate(\n value.evaluate({zoom: Math.floor(globals.zoom) - 1.0}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom)}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom) + 1.0}, feature, featureState),\n globals);\n } else {\n return value.value;\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue> {\n return a;\n }\n}\n/**\n * @internal\n * An implementation of `Property` for `*-pattern` and `line-dasharray`, which are transitioned by cross-fading\n * rather than interpolation.\n */\nexport class CrossFadedProperty implements Property> {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.value === undefined) {\n return undefined;\n } else if (value.expression.kind === 'constant') {\n const constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n return this._calculate(constant, constant, constant, parameters);\n } else {\n return this._calculate(\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1.0), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1.0), parameters)),\n parameters);\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a?: CrossFaded | null): CrossFaded {\n return a;\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for `heatmap-color` and `line-gradient`. Interpolation is a no-op, and\n * evaluation returns a boolean value in order to indicate its presence, but the real\n * evaluation happens in StyleLayer classes.\n */\n\nexport class ColorRampProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): boolean {\n return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n }\n\n interpolate(): boolean { return false; }\n}\n\n/**\n * @internal\n * `Properties` holds objects containing default values for the layout or paint property set of a given\n * layer type. These objects are immutable, and they are used as the prototypes for the `_values` members of\n * `Transitionable`, `Transitioning`, `Layout`, and `PossiblyEvaluated`. This allows these classes to avoid\n * doing work in the common case where a property has no explicit value set and should be considered to take\n * on the default value: using `for (const property of Object.keys(this._values))`, they can iterate over\n * only the _own_ properties of `_values`, skipping repeated calculation of transitions and possible/final\n * evaluations for defaults, the result of which will always be the same.\n */\nexport class Properties {\n properties: Props;\n defaultPropertyValues: {[K in keyof Props]: PropertyValue};\n defaultTransitionablePropertyValues: {[K in keyof Props]: TransitionablePropertyValue};\n defaultTransitioningPropertyValues: {[K in keyof Props]: TransitioningPropertyValue};\n defaultPossiblyEvaluatedValues: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n overridableProperties: Array;\n\n constructor(properties: Props) {\n this.properties = properties;\n this.defaultPropertyValues = ({} as any);\n this.defaultTransitionablePropertyValues = ({} as any);\n this.defaultTransitioningPropertyValues = ({} as any);\n this.defaultPossiblyEvaluatedValues = ({} as any);\n this.overridableProperties = ([] as any);\n\n for (const property in properties) {\n const prop = properties[property] as any;\n if (prop.specification.overridable) {\n this.overridableProperties.push(property);\n }\n const defaultPropertyValue = this.defaultPropertyValues[property] =\n new PropertyValue(prop, undefined);\n const defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] =\n new TransitionablePropertyValue(prop);\n this.defaultTransitioningPropertyValues[property] =\n defaultTransitionablePropertyValue.untransitioned();\n this.defaultPossiblyEvaluatedValues[property] =\n defaultPropertyValue.possiblyEvaluate({} as any);\n }\n }\n}\n\nregister('DataDrivenProperty', DataDrivenProperty);\nregister('DataConstantProperty', DataConstantProperty);\nregister('CrossFadedDataDrivenProperty', CrossFadedDataDrivenProperty);\nregister('CrossFadedProperty', CrossFadedProperty);\nregister('ColorRampProperty', ColorRampProperty);\n","import {filterObject} from '../util/util';\n\nimport {latest as styleSpec, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {\n validateStyle,\n validateLayoutProperty,\n validatePaintProperty,\n emitValidationErrors\n} from './validate_style';\nimport {Evented} from '../util/evented';\nimport {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties';\n\nimport type {Bucket} from '../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureFilter, FeatureState,\n LayerSpecification,\n FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {TransitionParameters, PropertyValue} from './properties';\nimport {EvaluationParameters} from './evaluation_parameters';\nimport type {CrossfadeParameters} from './evaluation_parameters';\n\nimport type {Transform} from '../geo/transform';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Map} from '../ui/map';\nimport type {StyleSetterOptions} from './style';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nconst TRANSITION_SUFFIX = '-transition';\n\n/**\n * A base class for style layers\n */\nexport abstract class StyleLayer extends Evented {\n id: string;\n metadata: unknown;\n type: LayerSpecification['type'] | CustomLayerInterface['type'];\n source: string;\n sourceLayer: string;\n minzoom: number;\n maxzoom: number;\n filter: FilterSpecification | void;\n visibility: 'visible' | 'none' | void;\n _crossfadeParameters: CrossfadeParameters;\n\n _unevaluatedLayout: Layout;\n readonly layout: unknown;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n readonly paint: unknown;\n\n _featureFilter: FeatureFilter;\n\n readonly onAdd: ((map: Map) => void);\n readonly onRemove: ((map: Map) => void);\n\n queryRadius?(bucket: Bucket): number;\n queryIntersectsFeature?(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number;\n\n constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{\n layout?: Properties;\n paint?: Properties;\n }>) {\n super();\n\n this.id = layer.id;\n this.type = layer.type;\n this._featureFilter = {filter: () => true, needGeometry: false};\n\n if (layer.type === 'custom') return;\n\n layer = (layer as any as LayerSpecification);\n\n this.metadata = layer.metadata;\n this.minzoom = layer.minzoom;\n this.maxzoom = layer.maxzoom;\n\n if (layer.type !== 'background') {\n this.source = layer.source;\n this.sourceLayer = layer['source-layer'];\n this.filter = layer.filter;\n }\n\n if (properties.layout) {\n this._unevaluatedLayout = new Layout(properties.layout);\n }\n\n if (properties.paint) {\n this._transitionablePaint = new Transitionable(properties.paint);\n\n for (const property in layer.paint) {\n this.setPaintProperty(property, layer.paint[property], {validate: false});\n }\n for (const property in layer.layout) {\n this.setLayoutProperty(property, layer.layout[property], {validate: false});\n }\n\n this._transitioningPaint = this._transitionablePaint.untransitioned();\n //$FlowFixMe\n this.paint = new PossiblyEvaluated(properties.paint);\n }\n }\n\n getCrossfadeParameters() {\n return this._crossfadeParameters;\n }\n\n getLayoutProperty(name: string) {\n if (name === 'visibility') {\n return this.visibility;\n }\n\n return this._unevaluatedLayout.getValue(name);\n }\n\n setLayoutProperty(name: string, value: any, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.layout.${name}`;\n if (this._validate(validateLayoutProperty, key, name, value, options)) {\n return;\n }\n }\n\n if (name === 'visibility') {\n this.visibility = value;\n return;\n }\n\n this._unevaluatedLayout.setValue(name, value);\n }\n\n getPaintProperty(name: string) {\n if (name.endsWith(TRANSITION_SUFFIX)) {\n return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length));\n } else {\n return this._transitionablePaint.getValue(name);\n }\n }\n\n setPaintProperty(name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.paint.${name}`;\n if (this._validate(validatePaintProperty, key, name, value, options)) {\n return false;\n }\n }\n\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), (value as any) || undefined);\n return false;\n } else {\n const transitionable = this._transitionablePaint._values[name];\n const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven';\n const wasDataDriven = transitionable.value.isDataDriven();\n const oldValue = transitionable.value;\n\n this._transitionablePaint.setValue(name, value);\n this._handleSpecialPaintPropertyUpdate(name);\n\n const newValue = this._transitionablePaint._values[name].value;\n const isDataDriven = newValue.isDataDriven();\n\n // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas\n // so a call to _updateLayer is necessary, and we return true from this function so it gets called in\n // Style#setPaintProperty\n return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name, oldValue, newValue);\n }\n }\n\n _handleSpecialPaintPropertyUpdate(_: string) {\n // No-op; can be overridden by derived classes.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n // No-op; can be overridden by derived classes.\n return false;\n }\n\n isHidden(zoom: number) {\n if (this.minzoom && zoom < this.minzoom) return true;\n if (this.maxzoom && zoom >= this.maxzoom) return true;\n return this.visibility === 'none';\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint);\n }\n\n hasTransition() {\n return this._transitioningPaint.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n if (parameters.getCrossfadeParameters) {\n this._crossfadeParameters = parameters.getCrossfadeParameters();\n }\n\n if (this._unevaluatedLayout) {\n (this as any).layout = this._unevaluatedLayout.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n (this as any).paint = this._transitioningPaint.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n serialize(): LayerSpecification {\n const output: LayerSpecification = {\n 'id': this.id,\n 'type': this.type as LayerSpecification['type'],\n 'source': this.source,\n 'source-layer': this.sourceLayer,\n 'metadata': this.metadata,\n 'minzoom': this.minzoom,\n 'maxzoom': this.maxzoom,\n 'filter': this.filter as FilterSpecification,\n 'layout': this._unevaluatedLayout && this._unevaluatedLayout.serialize(),\n 'paint': this._transitionablePaint && this._transitionablePaint.serialize()\n };\n\n if (this.visibility) {\n output.layout = output.layout || {};\n output.layout.visibility = this.visibility;\n }\n\n return filterObject(output, (value, key) => {\n return value !== undefined &&\n !(key === 'layout' && !Object.keys(value).length) &&\n !(key === 'paint' && !Object.keys(value).length);\n });\n }\n\n _validate(validate: Function, key: string, name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, {\n key,\n layerType: this.type,\n objectKey: name,\n value,\n styleSpec,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true}\n }));\n }\n\n is3D() {\n return false;\n }\n\n isTileClipped() {\n return false;\n }\n\n hasOffscreenPass() {\n return false;\n }\n\n resize() {\n // noop\n }\n\n isStateDependent() {\n for (const property in (this as any).paint._values) {\n const value = (this as any).paint.get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n\n if ((value.value.kind === 'source' || value.value.kind === 'composite') &&\n value.value.isStateDependent) {\n return true;\n }\n }\n return false;\n }\n}\n","// Note: all \"sizes\" are measured in bytes\n\nimport type {Transferable} from '../types/transferable';\n\n/**\n * @internal\n * A view type size\n */\nconst viewTypes = {\n 'Int8': Int8Array,\n 'Uint8': Uint8Array,\n 'Int16': Int16Array,\n 'Uint16': Uint16Array,\n 'Int32': Int32Array,\n 'Uint32': Uint32Array,\n 'Float32': Float32Array\n};\n\n/**\n * @internal\n * A view type size\n */\nexport type ViewType = keyof typeof viewTypes;\n\n/** @internal */\nclass Struct {\n _pos1: number;\n _pos2: number;\n _pos4: number;\n _pos8: number;\n readonly _structArray: StructArray;\n\n // The following properties are defined on the prototype of sub classes.\n size: number;\n\n /**\n * @param structArray - The StructArray the struct is stored in\n * @param index - The index of the struct in the StructArray.\n */\n constructor(structArray: StructArray, index: number) {\n (this as any)._structArray = structArray;\n this._pos1 = index * this.size;\n this._pos2 = this._pos1 / 2;\n this._pos4 = this._pos1 / 4;\n this._pos8 = this._pos1 / 8;\n }\n}\n\nconst DEFAULT_CAPACITY = 128;\nconst RESIZE_MULTIPLIER = 5;\n\n/**\n * @internal\n * A struct array memeber\n */\nexport type StructArrayMember = {\n name: string;\n type: ViewType;\n components: number;\n offset: number;\n};\n\nexport type StructArrayLayout = {\n members: Array;\n size: number;\n alignment: number;\n};\n\n/**\n * An array that can be desialized\n */\nexport type SerializedStructArray = {\n length: number;\n arrayBuffer: ArrayBuffer;\n};\n\n/**\n * @internal\n * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray`\n * making it behave like an array of typed structs.\n *\n * Conceptually, a StructArray is comprised of elements, i.e., instances of its\n * associated struct type. Each particular struct type, together with an\n * alignment size, determines the memory layout of a StructArray whose elements\n * are of that type. Thus, for each such layout that we need, we have\n * a corresponding StructArrayLayout class, inheriting from StructArray and\n * implementing `emplaceBack()` and `_refreshViews()`.\n *\n * In some cases, where we need to access particular elements of a StructArray,\n * we implement a more specific subclass that inherits from one of the\n * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured\n * object whose properties are proxies into the underlying memory space for the\n * i-th element. This affords the convience of working with (seemingly) plain\n * Javascript objects without the overhead of serializing/deserializing them\n * into ArrayBuffers for efficient web worker transfer.\n */\nabstract class StructArray {\n capacity: number;\n length: number;\n isTransferred: boolean;\n arrayBuffer: ArrayBuffer;\n uint8: Uint8Array;\n\n // The following properties are defined on the prototype.\n members: Array;\n bytesPerElement: number;\n abstract emplaceBack(...v: number[]);\n abstract emplace(i: number, ...v: number[]);\n\n constructor() {\n this.isTransferred = false;\n this.capacity = -1;\n this.resize(0);\n }\n\n /**\n * Serialize a StructArray instance. Serializes both the raw data and the\n * metadata needed to reconstruct the StructArray base class during\n * deserialization.\n */\n static serialize(array: StructArray, transferables?: Array): SerializedStructArray {\n\n array._trim();\n\n if (transferables) {\n array.isTransferred = true;\n transferables.push(array.arrayBuffer);\n }\n\n return {\n length: array.length,\n arrayBuffer: array.arrayBuffer,\n };\n }\n\n static deserialize(input: SerializedStructArray) {\n const structArray = Object.create(this.prototype);\n structArray.arrayBuffer = input.arrayBuffer;\n structArray.length = input.length;\n structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;\n structArray._refreshViews();\n return structArray;\n }\n\n /**\n * Resize the array to discard unused capacity.\n */\n _trim() {\n if (this.length !== this.capacity) {\n this.capacity = this.length;\n this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement);\n this._refreshViews();\n }\n }\n\n /**\n * Resets the length of the array to 0 without de-allocating capcacity.\n */\n clear() {\n this.length = 0;\n }\n\n /**\n * Resize the array.\n * If `n` is greater than the current length then additional elements with undefined values are added.\n * If `n` is less than the current length then the array will be reduced to the first `n` elements.\n * @param n - The new size of the array.\n */\n resize(n: number) {\n this.reserve(n);\n this.length = n;\n }\n\n /**\n * Indicate a planned increase in size, so that any necessary allocation may\n * be done once, ahead of time.\n * @param n - The expected size of the array.\n */\n reserve(n: number) {\n if (n > this.capacity) {\n this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY);\n this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);\n\n const oldUint8Array = this.uint8;\n this._refreshViews();\n if (oldUint8Array) this.uint8.set(oldUint8Array);\n }\n }\n\n /**\n * Create TypedArray views for the current ArrayBuffer.\n */\n _refreshViews() {\n throw new Error('_refreshViews() must be implemented by each concrete StructArray layout');\n }\n}\n\n/**\n * Given a list of member fields, create a full StructArrayLayout, in\n * particular calculating the correct byte offset for each field. This data\n * is used at build time to generate StructArrayLayout_*#emplaceBack() and\n * other accessors, and at runtime for binding vertex buffer attributes.\n */\nfunction createLayout(\n members: Array<{\n name: string;\n type: ViewType;\n readonly components?: number;\n }>,\n alignment: number = 1\n): StructArrayLayout {\n\n let offset = 0;\n let maxSize = 0;\n const layoutMembers = members.map((member) => {\n const typeSize = sizeOf(member.type);\n const memberOffset = offset = align(offset, Math.max(alignment, typeSize));\n const components = member.components || 1;\n\n maxSize = Math.max(maxSize, typeSize);\n offset += typeSize * components;\n\n return {\n name: member.name,\n type: member.type,\n components,\n offset: memberOffset,\n };\n });\n\n const size = align(offset, Math.max(maxSize, alignment));\n\n return {\n members: layoutMembers,\n size,\n alignment\n };\n}\n\nfunction sizeOf(type: ViewType): number {\n return viewTypes[type].BYTES_PER_ELEMENT;\n}\n\nfunction align(offset: number, size: number): number {\n return Math.ceil(offset / size) * size;\n}\n\nexport {StructArray, Struct, viewTypes, createLayout};\n","// This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`.\n\nimport {Struct, StructArray} from '../util/struct_array';\nimport {register} from '../util/web_worker_transfer';\nimport Point from '@mapbox/point-geometry';\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n *\n */\nclass StructArrayLayout2i4 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2i4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2i4', StructArrayLayout2i4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[3]\n *\n */\nclass StructArrayLayout3i6 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3i6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3i6', StructArrayLayout3i6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n *\n */\nclass StructArrayLayout4i8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o2 = i * 4;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4i8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout4i8', StructArrayLayout4i8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[4]\n *\n */\nclass StructArrayLayout2i4i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i4i12', StructArrayLayout2i4i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint8[4]\n *\n */\nclass StructArrayLayout2i4ub8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 4;\n const o1 = i * 8;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint8[o1 + 4] = v2;\n this.uint8[o1 + 5] = v3;\n this.uint8[o1 + 6] = v4;\n this.uint8[o1 + 7] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4ub8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n *\n */\nclass StructArrayLayout2f8 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o4 = i * 2;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2f8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2f8', StructArrayLayout2f8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[10]\n *\n */\nclass StructArrayLayout10ui20 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const o2 = i * 10;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n return i;\n }\n}\n\nStructArrayLayout10ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout10ui20', StructArrayLayout10ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n * [8]: Uint16[4]\n * [16]: Int16[4]\n *\n */\nclass StructArrayLayout4i4ui4i24 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const o2 = i * 12;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.int16[o2 + 8] = v8;\n this.int16[o2 + 9] = v9;\n this.int16[o2 + 10] = v10;\n this.int16[o2 + 11] = v11;\n return i;\n }\n}\n\nStructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24;\nregister('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[3]\n *\n */\nclass StructArrayLayout3f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 3;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout3f12', StructArrayLayout3f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n *\n */\nclass StructArrayLayout1ul4 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.uint32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ul4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1ul4', StructArrayLayout1ul4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[6]\n * [12]: Uint32[1]\n * [16]: Uint16[2]\n *\n */\nclass StructArrayLayout6i1ul2ui20 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const o2 = i * 10;\n const o4 = i * 5;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.uint32[o4 + 3] = v6;\n this.uint16[o2 + 8] = v7;\n this.uint16[o2 + 9] = v8;\n return i;\n }\n}\n\nStructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[2]\n * [8]: Int16[2]\n *\n */\nclass StructArrayLayout2i2i2i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i2i2i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n * [8]: Float32[1]\n * [12]: Int16[2]\n *\n */\nclass StructArrayLayout2f1f2i16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number) {\n const o4 = i * 4;\n const o2 = i * 8;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.int16[o2 + 6] = v3;\n this.int16[o2 + 7] = v4;\n return i;\n }\n}\n\nStructArrayLayout2f1f2i16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint8[2]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout2ub2f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o1 = i * 12;\n const o4 = i * 3;\n this.uint8[o1 + 0] = v0;\n this.uint8[o1 + 1] = v1;\n this.float32[o4 + 1] = v2;\n this.float32[o4 + 2] = v3;\n return i;\n }\n}\n\nStructArrayLayout2ub2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[3]\n *\n */\nclass StructArrayLayout3ui6 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3ui6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3ui6', StructArrayLayout3ui6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint16[2]\n * [8]: Uint32[3]\n * [20]: Uint16[3]\n * [28]: Float32[2]\n * [36]: Uint8[3]\n * [40]: Uint32[1]\n * [44]: Int16[1]\n *\n */\nclass StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const o2 = i * 24;\n const o4 = i * 12;\n const o1 = i * 48;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint32[o4 + 2] = v4;\n this.uint32[o4 + 3] = v5;\n this.uint32[o4 + 4] = v6;\n this.uint16[o2 + 10] = v7;\n this.uint16[o2 + 11] = v8;\n this.uint16[o2 + 12] = v9;\n this.float32[o4 + 7] = v10;\n this.float32[o4 + 8] = v11;\n this.uint8[o1 + 36] = v12;\n this.uint8[o1 + 37] = v13;\n this.uint8[o1 + 38] = v14;\n this.uint32[o4 + 10] = v15;\n this.int16[o2 + 22] = v16;\n return i;\n }\n}\n\nStructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48;\nregister('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[8]\n * [16]: Uint16[15]\n * [48]: Uint32[1]\n * [52]: Float32[2]\n * [60]: Uint16[2]\n *\n */\nclass StructArrayLayout8i15ui1ul2f2ui64 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const o2 = i * 32;\n const o4 = i * 16;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.int16[o2 + 6] = v6;\n this.int16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n this.uint16[o2 + 10] = v10;\n this.uint16[o2 + 11] = v11;\n this.uint16[o2 + 12] = v12;\n this.uint16[o2 + 13] = v13;\n this.uint16[o2 + 14] = v14;\n this.uint16[o2 + 15] = v15;\n this.uint16[o2 + 16] = v16;\n this.uint16[o2 + 17] = v17;\n this.uint16[o2 + 18] = v18;\n this.uint16[o2 + 19] = v19;\n this.uint16[o2 + 20] = v20;\n this.uint16[o2 + 21] = v21;\n this.uint16[o2 + 22] = v22;\n this.uint32[o4 + 12] = v23;\n this.float32[o4 + 13] = v24;\n this.float32[o4 + 14] = v25;\n this.uint16[o2 + 30] = v26;\n this.uint16[o2 + 31] = v27;\n return i;\n }\n}\n\nStructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64;\nregister('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[1]\n *\n */\nclass StructArrayLayout1f4 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.float32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1f4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1f4', StructArrayLayout1f4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout1ui2f12 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 6;\n const o4 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ui2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n * [4]: Uint16[2]\n *\n */\nclass StructArrayLayout1ul2ui8 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 2;\n const o2 = i * 4;\n this.uint32[o4 + 0] = v0;\n this.uint16[o2 + 2] = v1;\n this.uint16[o2 + 3] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ul2ui8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[2]\n *\n */\nclass StructArrayLayout2ui4 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2ui4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2ui4', StructArrayLayout2ui4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n *\n */\nclass StructArrayLayout1ui2 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o2 = i * 1;\n this.uint16[o2 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ui2.prototype.bytesPerElement = 2;\nregister('StructArrayLayout1ui2', StructArrayLayout1ui2);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[4]\n *\n */\nclass StructArrayLayout4f16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o4 = i * 4;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.float32[o4 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4f16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout4f16', StructArrayLayout4f16);\n\n/** @internal */\nclass CollisionBoxStruct extends Struct {\n _structArray: CollisionBoxArray;\n get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorPointY() { return this._structArray.int16[this._pos2 + 1]; }\n get x1() { return this._structArray.int16[this._pos2 + 2]; }\n get y1() { return this._structArray.int16[this._pos2 + 3]; }\n get x2() { return this._structArray.int16[this._pos2 + 4]; }\n get y2() { return this._structArray.int16[this._pos2 + 5]; }\n get featureIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 8]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); }\n}\n\nCollisionBoxStruct.prototype.size = 20;\n\nexport type CollisionBox = CollisionBoxStruct;\n\n/** @internal */\nexport class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {\n /**\n * Return the CollisionBoxStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): CollisionBoxStruct {\n return new CollisionBoxStruct(this, index);\n }\n}\n\nregister('CollisionBoxArray', CollisionBoxArray);\n\n/** @internal */\nclass PlacedSymbolStruct extends Struct {\n _structArray: PlacedSymbolArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get glyphStartIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get numGlyphs() { return this._structArray.uint16[this._pos2 + 3]; }\n get vertexStartIndex() { return this._structArray.uint32[this._pos4 + 2]; }\n get lineStartIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get lineLength() { return this._structArray.uint32[this._pos4 + 4]; }\n get segment() { return this._structArray.uint16[this._pos2 + 10]; }\n get lowerSize() { return this._structArray.uint16[this._pos2 + 11]; }\n get upperSize() { return this._structArray.uint16[this._pos2 + 12]; }\n get lineOffsetX() { return this._structArray.float32[this._pos4 + 7]; }\n get lineOffsetY() { return this._structArray.float32[this._pos4 + 8]; }\n get writingMode() { return this._structArray.uint8[this._pos1 + 36]; }\n get placedOrientation() { return this._structArray.uint8[this._pos1 + 37]; }\n set placedOrientation(x: number) { this._structArray.uint8[this._pos1 + 37] = x; }\n get hidden() { return this._structArray.uint8[this._pos1 + 38]; }\n set hidden(x: number) { this._structArray.uint8[this._pos1 + 38] = x; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 10]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 10] = x; }\n get associatedIconIndex() { return this._structArray.int16[this._pos2 + 22]; }\n}\n\nPlacedSymbolStruct.prototype.size = 48;\n\nexport type PlacedSymbol = PlacedSymbolStruct;\n\n/** @internal */\nexport class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 {\n /**\n * Return the PlacedSymbolStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): PlacedSymbolStruct {\n return new PlacedSymbolStruct(this, index);\n }\n}\n\nregister('PlacedSymbolArray', PlacedSymbolArray);\n\n/** @internal */\nclass SymbolInstanceStruct extends Struct {\n _structArray: SymbolInstanceArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get rightJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 2]; }\n get centerJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 3]; }\n get leftJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 4]; }\n get verticalPlacedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 5]; }\n get placedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 6]; }\n get verticalPlacedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 7]; }\n get key() { return this._structArray.uint16[this._pos2 + 8]; }\n get textBoxStartIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get textBoxEndIndex() { return this._structArray.uint16[this._pos2 + 10]; }\n get verticalTextBoxStartIndex() { return this._structArray.uint16[this._pos2 + 11]; }\n get verticalTextBoxEndIndex() { return this._structArray.uint16[this._pos2 + 12]; }\n get iconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 13]; }\n get iconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 14]; }\n get verticalIconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 15]; }\n get verticalIconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 16]; }\n get featureIndex() { return this._structArray.uint16[this._pos2 + 17]; }\n get numHorizontalGlyphVertices() { return this._structArray.uint16[this._pos2 + 18]; }\n get numVerticalGlyphVertices() { return this._structArray.uint16[this._pos2 + 19]; }\n get numIconVertices() { return this._structArray.uint16[this._pos2 + 20]; }\n get numVerticalIconVertices() { return this._structArray.uint16[this._pos2 + 21]; }\n get useRuntimeCollisionCircles() { return this._structArray.uint16[this._pos2 + 22]; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 12] = x; }\n get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; }\n get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; }\n get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; }\n get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; }\n}\n\nSymbolInstanceStruct.prototype.size = 64;\n\nexport type SymbolInstance = SymbolInstanceStruct;\n\n/** @internal */\nexport class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 {\n /**\n * Return the SymbolInstanceStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): SymbolInstanceStruct {\n return new SymbolInstanceStruct(this, index);\n }\n}\n\nregister('SymbolInstanceArray', SymbolInstanceArray);\n\n/** @internal */\nexport class GlyphOffsetArray extends StructArrayLayout1f4 {\n getoffsetX(index: number) { return this.float32[index * 1 + 0]; }\n}\n\nregister('GlyphOffsetArray', GlyphOffsetArray);\n\n/** @internal */\nexport class SymbolLineVertexArray extends StructArrayLayout3i6 {\n getx(index: number) { return this.int16[index * 3 + 0]; }\n gety(index: number) { return this.int16[index * 3 + 1]; }\n gettileUnitDistanceFromAnchor(index: number) { return this.int16[index * 3 + 2]; }\n}\n\nregister('SymbolLineVertexArray', SymbolLineVertexArray);\n\n/** @internal */\nclass TextAnchorOffsetStruct extends Struct {\n _structArray: TextAnchorOffsetArray;\n get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; }\n get textOffset0() { return this._structArray.float32[this._pos4 + 1]; }\n get textOffset1() { return this._structArray.float32[this._pos4 + 2]; }\n}\n\nTextAnchorOffsetStruct.prototype.size = 12;\n\nexport type TextAnchorOffset = TextAnchorOffsetStruct;\n\n/** @internal */\nexport class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 {\n /**\n * Return the TextAnchorOffsetStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): TextAnchorOffsetStruct {\n return new TextAnchorOffsetStruct(this, index);\n }\n}\n\nregister('TextAnchorOffsetArray', TextAnchorOffsetArray);\n\n/** @internal */\nclass FeatureIndexStruct extends Struct {\n _structArray: FeatureIndexArray;\n get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 3]; }\n}\n\nFeatureIndexStruct.prototype.size = 8;\n\nexport type FeatureIndex = FeatureIndexStruct;\n\n/** @internal */\nexport class FeatureIndexArray extends StructArrayLayout1ul2ui8 {\n /**\n * Return the FeatureIndexStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): FeatureIndexStruct {\n return new FeatureIndexStruct(this, index);\n }\n}\n\nregister('FeatureIndexArray', FeatureIndexArray);\n\nexport class PosArray extends StructArrayLayout2i4 {}\nexport class Pos3dArray extends StructArrayLayout3i6 {}\nexport class RasterBoundsArray extends StructArrayLayout4i8 {}\nexport class CircleLayoutArray extends StructArrayLayout2i4 {}\nexport class FillLayoutArray extends StructArrayLayout2i4 {}\nexport class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 {}\nexport class HeatmapLayoutArray extends StructArrayLayout2i4 {}\nexport class LineLayoutArray extends StructArrayLayout2i4ub8 {}\nexport class LineExtLayoutArray extends StructArrayLayout2f8 {}\nexport class PatternLayoutArray extends StructArrayLayout10ui20 {}\nexport class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 {}\nexport class SymbolDynamicLayoutArray extends StructArrayLayout3f12 {}\nexport class SymbolOpacityArray extends StructArrayLayout1ul4 {}\nexport class CollisionBoxLayoutArray extends StructArrayLayout2i2i2i12 {}\nexport class CollisionCircleLayoutArray extends StructArrayLayout2f1f2i16 {}\nexport class CollisionVertexArray extends StructArrayLayout2ub2f12 {}\nexport class QuadTriangleArray extends StructArrayLayout3ui6 {}\nexport class TriangleIndexArray extends StructArrayLayout3ui6 {}\nexport class LineIndexArray extends StructArrayLayout2ui4 {}\nexport class LineStripIndexArray extends StructArrayLayout1ui2 {}\nexport {\n StructArrayLayout2i4,\n StructArrayLayout3i6,\n StructArrayLayout4i8,\n StructArrayLayout2i4i12,\n StructArrayLayout2i4ub8,\n StructArrayLayout2f8,\n StructArrayLayout10ui20,\n StructArrayLayout4i4ui4i24,\n StructArrayLayout3f12,\n StructArrayLayout1ul4,\n StructArrayLayout6i1ul2ui20,\n StructArrayLayout2i2i2i12,\n StructArrayLayout2f1f2i16,\n StructArrayLayout2ub2f12,\n StructArrayLayout3ui6,\n StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48,\n StructArrayLayout8i15ui1ul2f2ui64,\n StructArrayLayout1f4,\n StructArrayLayout1ui2f12,\n StructArrayLayout1ul2ui8,\n StructArrayLayout2ui4,\n StructArrayLayout1ui2,\n StructArrayLayout4f16\n};\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","import {warnOnce} from '../util/util';\n\nimport {register} from '../util/web_worker_transfer';\n\nimport type {VertexArrayObject} from '../render/vertex_array_object';\nimport type {StructArray} from '../util/struct_array';\n\n/**\n * @internal\n * A single segment of a vector\n */\nexport type Segment = {\n sortKey?: number;\n vertexOffset: number;\n primitiveOffset: number;\n vertexLength: number;\n primitiveLength: number;\n vaos: {[_: string]: VertexArrayObject};\n};\n\n/**\n * @internal\n * Used for calculations on vector segments\n */\nexport class SegmentVector {\n static MAX_VERTEX_ARRAY_LENGTH: number;\n segments: Array;\n\n constructor(segments: Array = []) {\n this.segments = segments;\n }\n\n prepareSegment(\n numVertices: number,\n layoutVertexArray: StructArray,\n indexArray: StructArray,\n sortKey?: number\n ): Segment {\n let segment: Segment = this.segments[this.segments.length - 1];\n if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`);\n if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) {\n segment = ({\n vertexOffset: layoutVertexArray.length,\n primitiveOffset: indexArray.length,\n vertexLength: 0,\n primitiveLength: 0\n } as any);\n if (sortKey !== undefined) segment.sortKey = sortKey;\n this.segments.push(segment);\n }\n return segment;\n }\n\n get() {\n return this.segments;\n }\n\n destroy() {\n for (const segment of this.segments) {\n for (const k in segment.vaos) {\n segment.vaos[k].destroy();\n }\n }\n }\n\n static simpleSegment(\n vertexOffset: number,\n primitiveOffset: number,\n vertexLength: number,\n primitiveLength: number\n ): SegmentVector {\n return new SegmentVector([{\n vertexOffset,\n primitiveOffset,\n vertexLength,\n primitiveLength,\n vaos: {},\n sortKey: 0\n }]);\n }\n}\n\n/**\n * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit\n * addressing of vertex buffers.\n */\nSegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1;\n\nregister('SegmentVector', SegmentVector);\n","import {clamp} from '../util/util';\n\n/**\n * Packs two numbers, interpreted as 8-bit unsigned integers, into a single\n * float. Unpack them in the shader using the `unpack_float()` function,\n * defined in _prelude.vertex.glsl\n */\nexport function packUint8ToFloat(a: number, b: number) {\n // coerce a and b to 8-bit ints\n a = clamp(Math.floor(a), 0, 255);\n b = clamp(Math.floor(b), 0, 255);\n return 256 * a + b;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const patternAttributes = createLayout([\n // [tl.x, tl.y, br.x, br.y]\n {name: 'a_pattern_from', components: 4, type: 'Uint16'},\n {name: 'a_pattern_to', components: 4, type: 'Uint16'},\n {name: 'a_pixel_ratio_from', components: 1, type: 'Uint16'},\n {name: 'a_pixel_ratio_to', components: 1, type: 'Uint16'},\n]);\n","/**\n * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} key ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash \n */\n\nfunction murmurhash3_32_gc(key, seed) {\n\tvar remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;\n\t\n\tremainder = key.length & 3; // key.length % 4\n\tbytes = key.length - remainder;\n\th1 = seed;\n\tc1 = 0xcc9e2d51;\n\tc2 = 0x1b873593;\n\ti = 0;\n\t\n\twhile (i < bytes) {\n\t \tk1 = \n\t \t ((key.charCodeAt(i) & 0xff)) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 8) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 16) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 24);\n\t\t++i;\n\t\t\n\t\tk1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;\n\n\t\th1 ^= k1;\n h1 = (h1 << 13) | (h1 >>> 19);\n\t\th1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;\n\t\th1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));\n\t}\n\t\n\tk1 = 0;\n\t\n\tswitch (remainder) {\n\t\tcase 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;\n\t\tcase 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;\n\t\tcase 1: k1 ^= (key.charCodeAt(i) & 0xff);\n\t\t\n\t\tk1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;\n\t\th1 ^= k1;\n\t}\n\t\n\th1 ^= key.length;\n\n\th1 ^= h1 >>> 16;\n\th1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;\n\th1 ^= h1 >>> 13;\n\th1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;\n\th1 ^= h1 >>> 16;\n\n\treturn h1 >>> 0;\n}\n\nif(typeof module !== \"undefined\") {\n module.exports = murmurhash3_32_gc\n}","/**\n * JS Implementation of MurmurHash2\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} str ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash\n */\n\nfunction murmurhash2_32_gc(str, seed) {\n var\n l = str.length,\n h = seed ^ l,\n i = 0,\n k;\n \n while (l >= 4) {\n \tk = \n \t ((str.charCodeAt(i) & 0xff)) |\n \t ((str.charCodeAt(++i) & 0xff) << 8) |\n \t ((str.charCodeAt(++i) & 0xff) << 16) |\n \t ((str.charCodeAt(++i) & 0xff) << 24);\n \n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n k ^= k >>> 24;\n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\n\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;\n\n l -= 4;\n ++i;\n }\n \n switch (l) {\n case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n case 1: h ^= (str.charCodeAt(i) & 0xff);\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n }\n\n h ^= h >>> 13;\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n h ^= h >>> 15;\n\n return h >>> 0;\n}\n\nif(typeof module !== undefined) {\n module.exports = murmurhash2_32_gc\n}\n","var murmur3 = require(\"./murmurhash3_gc.js\")\nvar murmur2 = require(\"./murmurhash2_gc.js\")\n\nmodule.exports = murmur3\nmodule.exports.murmur3 = murmur3\nmodule.exports.murmur2 = murmur2\n","import murmur3 from 'murmurhash-js';\nimport {register} from '../util/web_worker_transfer';\n\ntype SerializedFeaturePositionMap = {\n ids: Float64Array;\n positions: Uint32Array;\n};\n\ntype FeaturePosition = {\n index: number;\n start: number;\n end: number;\n};\n\n// A transferable data structure that maps feature ids to their indices and buffer offsets\nexport class FeaturePositionMap {\n ids: Array;\n positions: Array;\n indexed: boolean;\n\n constructor() {\n this.ids = [];\n this.positions = [];\n this.indexed = false;\n }\n\n add(id: unknown, index: number, start: number, end: number) {\n this.ids.push(getNumericId(id));\n this.positions.push(index, start, end);\n }\n\n getPositions(id: unknown): Array {\n if (!this.indexed) throw new Error('Trying to get index, but feature positions are not indexed');\n\n const intId = getNumericId(id);\n\n // binary search for the first occurrence of id in this.ids;\n // relies on ids/positions being sorted by id, which happens in serialization\n let i = 0;\n let j = this.ids.length - 1;\n while (i < j) {\n const m = (i + j) >> 1;\n if (this.ids[m] >= intId) {\n j = m;\n } else {\n i = m + 1;\n }\n }\n const positions = [];\n while (this.ids[i] === intId) {\n const index = this.positions[3 * i];\n const start = this.positions[3 * i + 1];\n const end = this.positions[3 * i + 2];\n positions.push({index, start, end});\n i++;\n }\n return positions;\n }\n\n static serialize(map: FeaturePositionMap, transferables: Array): SerializedFeaturePositionMap {\n const ids = new Float64Array(map.ids);\n const positions = new Uint32Array(map.positions);\n\n sort(ids, positions, 0, ids.length - 1);\n\n if (transferables) {\n transferables.push(ids.buffer, positions.buffer);\n }\n\n return {ids, positions};\n }\n\n static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap {\n const map = new FeaturePositionMap();\n // after transferring, we only use these arrays statically (no pushes),\n // so TypedArray vs Array distinction that flow points out doesn't matter\n map.ids = (obj.ids as any);\n map.positions = (obj.positions as any);\n map.indexed = true;\n return map;\n }\n}\n\nfunction getNumericId(value: unknown) {\n const numValue = +value;\n if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) {\n return numValue;\n }\n return murmur3(String(value));\n}\n\n// custom quicksort that sorts ids, indices and offsets together (by ids)\n// uses Hoare partitioning & manual tail call optimization to avoid worst case scenarios\nfunction sort(ids, positions, left, right) {\n while (left < right) {\n const pivot = ids[(left + right) >> 1];\n let i = left - 1;\n let j = right + 1;\n\n while (true) {\n do i++; while (ids[i] < pivot);\n do j--; while (ids[j] > pivot);\n if (i >= j) break;\n swap(ids, i, j);\n swap(positions, 3 * i, 3 * j);\n swap(positions, 3 * i + 1, 3 * j + 1);\n swap(positions, 3 * i + 2, 3 * j + 2);\n }\n\n if (j - left < right - j) {\n sort(ids, positions, left, j);\n left = j + 1;\n } else {\n sort(ids, positions, j + 1, right);\n right = j;\n }\n }\n}\n\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nregister('FeaturePositionMap', FeaturePositionMap);\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Context} from '../gl/context';\nimport {mat4, vec2, vec3, vec4} from 'gl-matrix';\n\ntype $ObjMap any> = {\n [K in keyof T]: F extends (v: T[K]) => infer R ? R : never;\n};\n\nexport type UniformValues = $ObjMap(u: Uniform) => V>;\nexport type UniformLocations = {[_: string]: WebGLUniformLocation};\n\n/**\n * @internal\n * A base uniform abstract class\n */\nabstract class Uniform {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n location: WebGLUniformLocation;\n current: T;\n\n constructor(context: Context, location: WebGLUniformLocation) {\n this.gl = context.gl;\n this.location = location;\n }\n\n abstract set(v: T): void;\n}\n\nclass Uniform1i extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1i(this.location, v);\n }\n }\n}\n\nclass Uniform1f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1f(this.location, v);\n }\n }\n}\n\nclass Uniform2f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0];\n }\n\n set(v: vec2): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1]) {\n this.current = v;\n this.gl.uniform2f(this.location, v[0], v[1]);\n }\n }\n}\n\nclass Uniform3f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0];\n }\n\n set(v: vec3): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) {\n this.current = v;\n this.gl.uniform3f(this.location, v[0], v[1], v[2]);\n }\n }\n}\n\nclass Uniform4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0, 0];\n }\n\n set(v: vec4): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] ||\n v[2] !== this.current[2] || v[3] !== this.current[3]) {\n this.current = v;\n this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]);\n }\n }\n}\n\nclass UniformColor extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = Color.transparent;\n }\n\n set(v: Color): void {\n if (v.r !== this.current.r || v.g !== this.current.g ||\n v.b !== this.current.b || v.a !== this.current.a) {\n this.current = v;\n this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a);\n }\n }\n}\n\nconst emptyMat4 = new Float32Array(16) as mat4;\nclass UniformMatrix4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = emptyMat4;\n }\n\n set(v: mat4): void {\n // The vast majority of matrix comparisons that will trip this set\n // happen at i=12 or i=0, so we check those first to avoid lots of\n // unnecessary iteration:\n if (v[12] !== this.current[12] || v[0] !== this.current[0]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n return;\n }\n for (let i = 1; i < 16; i++) {\n if (v[i] !== this.current[i]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n break;\n }\n }\n }\n}\n\nexport {\n Uniform,\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n Uniform4f,\n UniformColor,\n UniformMatrix4f\n};\n\n/**\n * @internal\n * A uniform bindings\n */\nexport type UniformBindings = {[_: string]: Uniform};\n","import {packUint8ToFloat} from '../shaders/encode_attribute';\nimport {Color, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types.g';\nimport {clamp} from '../util/util';\nimport {patternAttributes} from './bucket/pattern_attributes';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {FeaturePositionMap} from './feature_position_map';\nimport {Uniform, Uniform1f, UniformColor, Uniform4f} from '../render/uniform_binding';\n\nimport type {UniformLocations} from '../render/uniform_binding';\n\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Context} from '../gl/context';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {CrossfadeParameters} from '../style/evaluation_parameters';\nimport type {StructArray, StructArrayMember} from '../util/struct_array';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {\n Feature,\n FeatureState,\n GlobalProperties,\n SourceExpression,\n CompositeExpression,\n FormattedSection\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureStates} from '../source/source_state';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type BinderUniform = {\n name: string;\n property: string;\n binding: Uniform;\n};\n\nfunction packColor(color: Color): [number, number] {\n return [\n packUint8ToFloat(255 * color.r, 255 * color.g),\n packUint8ToFloat(255 * color.b, 255 * color.a)\n ];\n}\n\n/**\n * `Binder` is the interface definition for the strategies for constructing,\n * uploading, and binding paint property data as GLSL attributes. Most style-\n * spec properties have a 1:1 relationship to shader attribute/uniforms, but\n * some require multiple values per feature to be passed to the GPU, and in\n * those cases we bind multiple attributes/uniforms.\n *\n * It has three implementations, one for each of the three strategies we use:\n *\n * * For _constant_ properties -- those whose value is a constant, or the constant\n * result of evaluating a camera expression at a particular camera position -- we\n * don't need a vertex attribute buffer, and instead use a uniform.\n * * For data expressions, we use a vertex buffer with a single attribute value,\n * the evaluated result of the source function for the given feature.\n * * For composite expressions, we use a vertex buffer with two attributes: min and\n * max values covering the range of zooms at which we expect the tile to be\n * displayed. These values are calculated by evaluating the composite expression for\n * the given feature at strategically chosen zoom levels. In addition to this\n * attribute data, we also use a uniform value which the shader uses to interpolate\n * between the min and max value at the final displayed zoom level. The use of a\n * uniform allows us to cheaply update the value on every frame.\n *\n * Note that the shader source varies depending on whether we're using a uniform or\n * attribute. We dynamically compile shaders at runtime to accommodate this.\n */\ninterface AttributeBinder {\n populatePaintArray(\n length: number,\n feature: Feature,\n imagePositions: {[_: string]: ImagePosition},\n canonical?: CanonicalTileID,\n formattedSection?: FormattedSection\n ): void;\n updatePaintArray(\n start: number,\n length: number,\n feature: Feature,\n featureState: FeatureState,\n imagePositions: {[_: string]: ImagePosition}\n ): void;\n upload(a: Context): void;\n destroy(): void;\n}\n\ninterface UniformBinder {\n uniformNames: Array;\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue,\n uniformName: string\n ): void;\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial>;\n}\n\nclass ConstantBinder implements UniformBinder {\n value: unknown;\n type: string;\n uniformNames: Array;\n\n constructor(value: unknown, names: Array, type: string) {\n this.value = value;\n this.uniformNames = names.map(name => `u_${name}`);\n this.type = type;\n }\n\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue\n ): void {\n uniform.set(currentValue.constantOr(this.value));\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Partial> {\n return (this.type === 'color') ?\n new UniformColor(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedConstantBinder implements UniformBinder {\n uniformNames: Array;\n patternFrom: Array;\n patternTo: Array;\n pixelRatioFrom: number;\n pixelRatioTo: number;\n\n constructor(value: unknown, names: Array) {\n this.uniformNames = names.map(name => `u_${name}`);\n this.patternFrom = null;\n this.patternTo = null;\n this.pixelRatioFrom = 1.0;\n this.pixelRatioTo = 1.0;\n }\n\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n this.pixelRatioFrom = posFrom.pixelRatio;\n this.pixelRatioTo = posTo.pixelRatio;\n this.patternFrom = posFrom.tlbr;\n this.patternTo = posTo.tlbr;\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties, currentValue: PossiblyEvaluatedPropertyValue, uniformName: string) {\n const pos =\n uniformName === 'u_pattern_to' ? this.patternTo :\n uniformName === 'u_pattern_from' ? this.patternFrom :\n uniformName === 'u_pixel_ratio_to' ? this.pixelRatioTo :\n uniformName === 'u_pixel_ratio_from' ? this.pixelRatioFrom : null;\n if (pos) uniform.set(pos);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial> {\n return name.substr(0, 9) === 'u_pattern' ?\n new Uniform4f(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass SourceExpressionBinder implements AttributeBinder {\n expression: SourceExpression;\n type: string;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: SourceExpression, names: Array, type: string, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.type = type;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 2 : 1,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const start = this.paintVertexArray.length;\n const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection);\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, value);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const value = this.expression.evaluate({zoom: 0}, feature, featureState);\n this._setPaintValue(start, end, value);\n }\n\n _setPaintValue(start, end, value) {\n if (this.type === 'color') {\n const color = packColor(value);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, color[0], color[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, value);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(value));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n}\n\nclass CompositeExpressionBinder implements AttributeBinder, UniformBinder {\n expression: CompositeExpression;\n uniformNames: Array;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: CompositeExpression, names: Array, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.uniformNames = names.map(name => `u_${name}_t`);\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 4 : 2,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection);\n const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection);\n const start = this.paintVertexArray.length;\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, min, max);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const min = this.expression.evaluate({zoom: this.zoom}, feature, featureState);\n const max = this.expression.evaluate({zoom: this.zoom + 1}, feature, featureState);\n this._setPaintValue(start, end, min, max);\n }\n\n _setPaintValue(start, end, min, max) {\n if (this.type === 'color') {\n const minColor = packColor(min);\n const maxColor = packColor(max);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, min, max);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties): void {\n const currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom;\n const factor = clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1);\n uniform.set(factor);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Uniform1f {\n return new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedCompositeBinder implements AttributeBinder {\n expression: CompositeExpression;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n layerId: string;\n\n zoomInPaintVertexArray: StructArray;\n zoomOutPaintVertexArray: StructArray;\n zoomInPaintVertexBuffer: VertexBuffer;\n zoomOutPaintVertexBuffer: VertexBuffer;\n paintVertexAttributes: Array;\n\n constructor(expression: CompositeExpression, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }, layerId: string) {\n this.expression = expression;\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.layerId = layerId;\n\n this.zoomInPaintVertexArray = new PaintVertexArray();\n this.zoomOutPaintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}) {\n const start = this.zoomInPaintVertexArray.length;\n this.zoomInPaintVertexArray.resize(length);\n this.zoomOutPaintVertexArray.resize(length);\n this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}) {\n this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n _setPaintValues(start, end, patterns, positions) {\n if (!positions || !patterns) return;\n\n const {min, mid, max} = patterns;\n const imageMin = positions[min];\n const imageMid = positions[mid];\n const imageMax = positions[max];\n if (!imageMin || !imageMid || !imageMax) return;\n\n // We populate two paint arrays because, for cross-faded properties, we don't know which direction\n // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass\n // unnecessary vertex data to the shaders, we determine which to upload at draw time.\n for (let i = start; i < end; i++) {\n this.zoomInPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1],\n imageMid.pixelRatio,\n imageMin.pixelRatio,\n );\n this.zoomOutPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1],\n imageMid.pixelRatio,\n imageMax.pixelRatio,\n );\n }\n }\n\n upload(context: Context) {\n if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) {\n this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n }\n }\n\n destroy() {\n if (this.zoomOutPaintVertexBuffer) this.zoomOutPaintVertexBuffer.destroy();\n if (this.zoomInPaintVertexBuffer) this.zoomInPaintVertexBuffer.destroy();\n }\n}\n\n/**\n * @internal\n * ProgramConfiguration contains the logic for binding style layer properties and tile\n * layer feature data into GL program uniforms and vertex attributes.\n *\n * Non-data-driven property values are bound to shader uniforms. Data-driven property\n * values are bound to vertex attributes. In order to support a uniform GLSL syntax over\n * both, [Mapbox GL Shaders](https://github.com/mapbox/mapbox-gl-shaders) defines a `#pragma`\n * abstraction, which ProgramConfiguration is responsible for implementing. At runtime,\n * it examines the attributes of a particular layer, combines this with fixed knowledge\n * about how layers of the particular type are implemented, and determines which uniforms\n * and vertex attributes will be required. It can then substitute the appropriate text\n * into the shader source code, create and link a program, and bind the uniforms and\n * vertex attributes in preparation for drawing.\n *\n * When a vector tile is parsed, this same configuration information is used to\n * populate the attribute buffers needed for data-driven styling using the zoom\n * level and feature property data.\n */\nexport class ProgramConfiguration {\n binders: {[_: string]: AttributeBinder | UniformBinder};\n cacheKey: string;\n\n _buffers: Array;\n\n constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean) {\n this.binders = {};\n this._buffers = [];\n\n const keys = [];\n\n for (const property in layer.paint._values) {\n if (!filterProperties(property)) continue;\n const value = (layer.paint as any).get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n const names = paintAttributeNames(property, layer.type);\n const expression = value.value;\n const type = value.property.specification.type;\n const useIntegerZoom = (value.property as any).useIntegerZoom;\n const propType = value.property.specification['property-type'];\n const isCrossFaded = propType === 'cross-faded' || propType === 'cross-faded-data-driven';\n\n if (expression.kind === 'constant') {\n this.binders[property] = isCrossFaded ?\n new CrossFadedConstantBinder(expression.value, names) :\n new ConstantBinder(expression.value, names, type);\n keys.push(`/u_${property}`);\n\n } else if (expression.kind === 'source' || isCrossFaded) {\n const StructArrayLayout = layoutType(property, type, 'source');\n this.binders[property] = isCrossFaded ?\n new CrossFadedCompositeBinder(expression as CompositeExpression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) :\n new SourceExpressionBinder(expression as SourceExpression, names, type, StructArrayLayout);\n keys.push(`/a_${property}`);\n\n } else {\n const StructArrayLayout = layoutType(property, type, 'composite');\n this.binders[property] = new CompositeExpressionBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout);\n keys.push(`/z_${property}`);\n }\n }\n\n this.cacheKey = keys.sort().join('');\n }\n\n getMaxValue(property: string): number {\n const binder = this.binders[property];\n return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0;\n }\n\n populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n (binder as AttributeBinder).populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection);\n }\n }\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof CrossFadedConstantBinder)\n binder.setConstantPatternPositions(posTo, posFrom);\n }\n }\n\n updatePaintArrays(\n featureStates: FeatureStates,\n featureMap: FeaturePositionMap,\n vtLayer: VectorTileLayer,\n layer: TypedStyleLayer,\n imagePositions: {[_: string]: ImagePosition}\n ): boolean {\n let dirty: boolean = false;\n for (const id in featureStates) {\n const positions = featureMap.getPositions(id);\n\n for (const pos of positions) {\n const feature = vtLayer.feature(pos.index);\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ||\n binder instanceof CrossFadedCompositeBinder) && (binder as any).expression.isStateDependent === true) {\n //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255\n const value = (layer.paint as any).get(property);\n (binder as any).expression = value.value;\n (binder as AttributeBinder).updatePaintArray(pos.start, pos.end, feature, featureStates[id], imagePositions);\n dirty = true;\n }\n }\n }\n }\n return dirty;\n }\n\n defines(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {\n result.push(...binder.uniformNames.map(name => `#define HAS_UNIFORM_${name}`));\n }\n }\n return result;\n }\n\n getBinderAttributes(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) {\n for (let i = 0; i < binder.paintVertexAttributes.length; i++) {\n result.push(binder.paintVertexAttributes[i].name);\n }\n } else if (binder instanceof CrossFadedCompositeBinder) {\n for (let i = 0; i < patternAttributes.members.length; i++) {\n result.push(patternAttributes.members[i].name);\n }\n }\n }\n return result;\n }\n\n getBinderUniforms(): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const uniformName of binder.uniformNames) {\n uniforms.push(uniformName);\n }\n }\n }\n return uniforms;\n }\n\n getPaintVertexBuffers(): Array {\n return this._buffers;\n }\n\n getUniforms(context: Context, locations: UniformLocations): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const name of binder.uniformNames) {\n if (locations[name]) {\n const binding = binder.getBinding(context, locations[name], name);\n uniforms.push({name, property, binding});\n }\n }\n }\n }\n return uniforms;\n }\n\n setUniforms(\n context: Context,\n binderUniforms: Array,\n properties: any,\n globals: GlobalProperties\n ) {\n // Uniform state bindings are owned by the Program, but we set them\n // from within the ProgramConfiguraton's binder members.\n for (const {name, property, binding} of binderUniforms) {\n (this.binders[property] as any).setUniform(binding, globals, properties.get(property), name);\n }\n }\n\n updatePaintBuffers(crossfade?: CrossfadeParameters) {\n this._buffers = [];\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (crossfade && binder instanceof CrossFadedCompositeBinder) {\n const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;\n if (patternVertexBuffer) this._buffers.push(patternVertexBuffer);\n\n } else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) {\n this._buffers.push(binder.paintVertexBuffer);\n }\n }\n }\n\n upload(context: Context) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.upload(context);\n }\n this.updatePaintBuffers();\n }\n\n destroy() {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.destroy();\n }\n }\n}\n\nexport class ProgramConfigurationSet {\n programConfigurations: {[_: string]: ProgramConfiguration};\n needsUpload: boolean;\n _featureMap: FeaturePositionMap;\n _bufferOffset: number;\n\n constructor(layers: ReadonlyArray, zoom: number, filterProperties: (_: string) => boolean = () => true) {\n this.programConfigurations = {};\n for (const layer of layers) {\n this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties);\n }\n this.needsUpload = false;\n this._featureMap = new FeaturePositionMap();\n this._bufferOffset = 0;\n }\n\n populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[_: string]: ImagePosition}, canonical: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const key in this.programConfigurations) {\n this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection);\n }\n\n if (feature.id !== undefined) {\n this._featureMap.add(feature.id, index, this._bufferOffset, length);\n }\n this._bufferOffset = length;\n\n this.needsUpload = true;\n }\n\n updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: ReadonlyArray, imagePositions: {[_: string]: ImagePosition}) {\n for (const layer of layers) {\n this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload;\n }\n }\n\n get(layerId: string) {\n return this.programConfigurations[layerId];\n }\n\n upload(context: Context) {\n if (!this.needsUpload) return;\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].upload(context);\n }\n this.needsUpload = false;\n }\n\n destroy() {\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].destroy();\n }\n }\n}\n\nfunction paintAttributeNames(property, type) {\n const attributeNameExceptions = {\n 'text-opacity': ['opacity'],\n 'icon-opacity': ['opacity'],\n 'text-color': ['fill_color'],\n 'icon-color': ['fill_color'],\n 'text-halo-color': ['halo_color'],\n 'icon-halo-color': ['halo_color'],\n 'text-halo-blur': ['halo_blur'],\n 'icon-halo-blur': ['halo_blur'],\n 'text-halo-width': ['halo_width'],\n 'icon-halo-width': ['halo_width'],\n 'line-gap-width': ['gapwidth'],\n 'line-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-extrusion-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n };\n\n return attributeNameExceptions[property] || [property.replace(`${type}-`, '').replace(/-/g, '_')];\n}\n\nfunction getLayoutException(property) {\n const propertyExceptions = {\n 'line-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-extrusion-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n }\n };\n\n return propertyExceptions[property];\n}\n\nfunction layoutType(property, type, binderType) {\n const defaultLayouts = {\n 'color': {\n 'source': StructArrayLayout2f8,\n 'composite': StructArrayLayout4f16\n },\n 'number': {\n 'source': StructArrayLayout1f4,\n 'composite': StructArrayLayout2f8\n }\n };\n\n const layoutException = getLayoutException(property);\n return layoutException && layoutException[binderType] || defaultLayouts[type][binderType];\n}\n\nregister('ConstantBinder', ConstantBinder);\nregister('CrossFadedConstantBinder', CrossFadedConstantBinder);\nregister('SourceExpressionBinder', SourceExpressionBinder);\nregister('CrossFadedCompositeBinder', CrossFadedCompositeBinder);\nregister('CompositeExpressionBinder', CompositeExpressionBinder);\nregister('ProgramConfiguration', ProgramConfiguration, {omit: ['_buffers']});\nregister('ProgramConfigurationSet', ProgramConfigurationSet);\n","/**\n * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of\n * all source features normalized to this extent upon load.\n *\n * The value is a consequence of the following:\n *\n * * Vertex buffer store positions as signed 16 bit integers.\n * * One bit is lost for signedness to support tile buffers.\n * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.\n * * One bit is lost to support features extending past the extent on the right edge of the tile.\n * * This leaves us with 2^13 = 8192\n */\nexport const EXTENT = 8192;\n","import {warnOnce, clamp} from '../util/util';\n\nimport {EXTENT} from './extent';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n// These bounds define the minimum and maximum supported coordinate values.\n// While visible coordinates are within [0, EXTENT], tiles may theoretically\n// contain coordinates within [-Infinity, Infinity]. Our range is limited by the\n// number of bits used to represent the coordinate.\nconst BITS = 15;\nconst MAX = Math.pow(2, BITS - 1) - 1;\nconst MIN = -MAX - 1;\n\n/**\n * Loads a geometry from a VectorTileFeature and scales it to the common extent\n * used internally.\n * @param feature - the vector tile feature to load\n */\nexport function loadGeometry(feature: VectorTileFeature): Array> {\n const scale = EXTENT / feature.extent;\n const geometry = feature.loadGeometry();\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n for (let p = 0; p < ring.length; p++) {\n const point = ring[p];\n // round here because mapbox-gl-native uses integers to represent\n // points and we need to do the same to avoid renering differences.\n const x = Math.round(point.x * scale);\n const y = Math.round(point.y * scale);\n\n point.x = clamp(x, MIN, MAX);\n point.y = clamp(y, MIN, MAX);\n\n if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) {\n // warn when exceeding allowed extent except for the 1-px-off case\n // https://github.com/mapbox/mapbox-gl-js/issues/8992\n warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size');\n }\n }\n }\n return geometry;\n}\n","import {loadGeometry} from './load_geometry';\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\n\ntype EvaluationFeature = Feature & { geometry: Array> };\n/**\n * Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which\n * will be loaded based on necessity.\n * @param feature - the feature to evaluate\n * @param needGeometry - if set to true this will load the geometry\n */\nexport function toEvaluationFeature(feature: VectorTileFeature, needGeometry: boolean): EvaluationFeature {\n return {type: feature.type,\n id: feature.id,\n properties: feature.properties,\n geometry: needGeometry ? loadGeometry(feature) : []};\n}\n","import {CircleLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './circle_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EXTENT} from '../extent';\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nfunction addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {\n layoutVertexArray.emplaceBack(\n (x * 2) + ((extrudeX + 1) / 2),\n (y * 2) + ((extrudeY + 1) / 2));\n}\n\n/**\n * @internal\n * Circles are represented by two triangles.\n *\n * Each corner has a pos that is the center of the circle and an extrusion\n * vector that is where it points.\n */\nexport class CircleBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layerIds: Array;\n layers: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: CircleLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new CircleLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.segments = new SegmentVector();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const styleLayer = this.layers[0];\n const bucketFeatures: BucketFeature[] = [];\n let circleSortKey = null;\n let sortFeaturesByKey = false;\n\n // Heatmap layers are handled in this bucket and have no evaluated properties, so we check our access\n if (styleLayer.type === 'circle') {\n circleSortKey = (styleLayer as CircleStyleLayer).layout.get('circle-sort-key');\n sortFeaturesByKey = !circleSortKey.isConstant();\n }\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n circleSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n const feature = features[index].feature;\n\n this.addFeature(bucketFeature, geometry, index, canonical);\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID) {\n for (const ring of geometry) {\n for (const point of ring) {\n const x = point.x;\n const y = point.y;\n\n // Do not include points that are outside the tile boundaries.\n if (x < 0 || x >= EXTENT || y < 0 || y >= EXTENT) continue;\n\n // this geometry will be of the Point type, and we'll derive\n // two triangles from it.\n //\n // ┌─────────┐\n // │ 3 2 │\n // │ │\n // │ 0 1 │\n // └─────────┘\n\n const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey);\n const index = segment.vertexLength;\n\n addCircleVertex(this.layoutVertexArray, x, y, -1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, 1);\n addCircleVertex(this.layoutVertexArray, x, y, -1, 1);\n\n this.indexArray.emplaceBack(index, index + 1, index + 2);\n this.indexArray.emplaceBack(index, index + 3, index + 2);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical);\n }\n}\n\nregister('CircleBucket', CircleBucket, {omit: ['layers']});\n","import {isCounterClockwise} from './util';\n\nimport Point from '@mapbox/point-geometry';\n\nexport {polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox};\n\ntype Line = Array;\ntype MultiLine = Array;\ntype Ring = Array;\ntype Polygon = Array;\ntype MultiPolygon = Array;\n\nfunction polygonIntersectsPolygon(polygonA: Polygon, polygonB: Polygon) {\n for (let i = 0; i < polygonA.length; i++) {\n if (polygonContainsPoint(polygonB, polygonA[i])) return true;\n }\n\n for (let i = 0; i < polygonB.length; i++) {\n if (polygonContainsPoint(polygonA, polygonB[i])) return true;\n }\n\n if (lineIntersectsLine(polygonA, polygonB)) return true;\n\n return false;\n}\n\nfunction polygonIntersectsBufferedPoint(polygon: Polygon, point: Point, radius: number) {\n if (polygonContainsPoint(polygon, point)) return true;\n if (pointIntersectsBufferedLine(point, polygon, radius)) return true;\n return false;\n}\n\nfunction polygonIntersectsMultiPolygon(polygon: Polygon, multiPolygon: MultiPolygon) {\n\n if (polygon.length === 1) {\n return multiPolygonContainsPoint(multiPolygon, polygon[0]);\n }\n\n for (let m = 0; m < multiPolygon.length; m++) {\n const ring = multiPolygon[m];\n for (let n = 0; n < ring.length; n++) {\n if (polygonContainsPoint(polygon, ring[n])) return true;\n }\n }\n\n for (let i = 0; i < polygon.length; i++) {\n if (multiPolygonContainsPoint(multiPolygon, polygon[i])) return true;\n }\n\n for (let k = 0; k < multiPolygon.length; k++) {\n if (lineIntersectsLine(polygon, multiPolygon[k])) return true;\n }\n\n return false;\n}\n\nfunction polygonIntersectsBufferedMultiLine(polygon: Polygon, multiLine: MultiLine, radius: number) {\n for (let i = 0; i < multiLine.length; i++) {\n const line = multiLine[i];\n\n if (polygon.length >= 3) {\n for (let k = 0; k < line.length; k++) {\n if (polygonContainsPoint(polygon, line[k])) return true;\n }\n }\n\n if (lineIntersectsBufferedLine(polygon, line, radius)) return true;\n }\n return false;\n}\n\nfunction lineIntersectsBufferedLine(lineA: Line, lineB: Line, radius: number) {\n\n if (lineA.length > 1) {\n if (lineIntersectsLine(lineA, lineB)) return true;\n\n // Check whether any point in either line is within radius of the other line\n for (let j = 0; j < lineB.length; j++) {\n if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) return true;\n }\n }\n\n for (let k = 0; k < lineA.length; k++) {\n if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) return true;\n }\n\n return false;\n}\n\nfunction lineIntersectsLine(lineA: Line, lineB: Line) {\n if (lineA.length === 0 || lineB.length === 0) return false;\n for (let i = 0; i < lineA.length - 1; i++) {\n const a0 = lineA[i];\n const a1 = lineA[i + 1];\n for (let j = 0; j < lineB.length - 1; j++) {\n const b0 = lineB[j];\n const b1 = lineB[j + 1];\n if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) return true;\n }\n }\n return false;\n}\n\nfunction lineSegmentIntersectsLineSegment(a0: Point, a1: Point, b0: Point, b1: Point) {\n return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) &&\n isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1);\n}\n\nfunction pointIntersectsBufferedLine(p: Point, line: Line, radius: number) {\n const radiusSquared = radius * radius;\n\n if (line.length === 1) return p.distSqr(line[0]) < radiusSquared;\n\n for (let i = 1; i < line.length; i++) {\n // Find line segments that have a distance <= radius^2 to p\n // In that case, we treat the line as \"containing point p\".\n const v = line[i - 1], w = line[i];\n if (distToSegmentSquared(p, v, w) < radiusSquared) return true;\n }\n return false;\n}\n\n// Code from http://stackoverflow.com/a/1501725/331379.\nfunction distToSegmentSquared(p: Point, v: Point, w: Point) {\n const l2 = v.distSqr(w);\n if (l2 === 0) return p.distSqr(v);\n const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;\n if (t < 0) return p.distSqr(v);\n if (t > 1) return p.distSqr(w);\n return p.distSqr(w.sub(v)._mult(t)._add(v));\n}\n\n// point in polygon ray casting algorithm\nfunction multiPolygonContainsPoint(rings: Array, p: Point) {\n let c = false,\n ring, p1, p2;\n\n for (let k = 0; k < rings.length; k++) {\n ring = rings[k];\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n }\n return c;\n}\n\nfunction polygonContainsPoint(ring: Ring, p: Point) {\n let c = false;\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const p1 = ring[i];\n const p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n return c;\n}\n\nfunction polygonIntersectsBox(ring: Ring, boxX1: number, boxY1: number, boxX2: number, boxY2: number) {\n for (const p of ring) {\n if (boxX1 <= p.x &&\n boxY1 <= p.y &&\n boxX2 >= p.x &&\n boxY2 >= p.y) return true;\n }\n\n const corners = [\n new Point(boxX1, boxY1),\n new Point(boxX1, boxY2),\n new Point(boxX2, boxY2),\n new Point(boxX2, boxY1)];\n\n if (ring.length > 2) {\n for (const corner of corners) {\n if (polygonContainsPoint(ring, corner)) return true;\n }\n }\n\n for (let i = 0; i < ring.length - 1; i++) {\n const p1 = ring[i];\n const p2 = ring[i + 1];\n if (edgeIntersectsBox(p1, p2, corners)) return true;\n }\n\n return false;\n}\n\nfunction edgeIntersectsBox(e1: Point, e2: Point, corners: Array) {\n const tl = corners[0];\n const br = corners[2];\n // the edge and box do not intersect in either the x or y dimensions\n if (((e1.x < tl.x) && (e2.x < tl.x)) ||\n ((e1.x > br.x) && (e2.x > br.x)) ||\n ((e1.y < tl.y) && (e2.y < tl.y)) ||\n ((e1.y > br.y) && (e2.y > br.y))) return false;\n\n // check if all corners of the box are on the same side of the edge\n const dir = isCounterClockwise(e1, e2, corners[0]);\n return dir !== isCounterClockwise(e1, e2, corners[1]) ||\n dir !== isCounterClockwise(e1, e2, corners[2]) ||\n dir !== isCounterClockwise(e1, e2, corners[3]);\n}\n","import Point from '@mapbox/point-geometry';\n\nimport type {PossiblyEvaluatedPropertyValue} from './properties';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {LineBucket} from '../data/bucket/line_bucket';\n\nexport function getMaximumPaintValue(\n property: string,\n layer: StyleLayer,\n bucket: CircleBucket | LineBucket\n): number {\n const value = ((layer.paint as any).get(property) as PossiblyEvaluatedPropertyValue).value;\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return bucket.programConfigurations.get(layer.id).getMaxValue(property);\n }\n}\n\nexport function translateDistance(translate: [number, number]) {\n return Math.sqrt(translate[0] * translate[0] + translate[1] * translate[1]);\n}\n\nexport function translate(queryGeometry: Array,\n translate: [number, number],\n translateAnchor: 'viewport' | 'map',\n bearing: number,\n pixelsToTileUnits: number) {\n if (!translate[0] && !translate[1]) {\n return queryGeometry;\n }\n const pt = Point.convert(translate)._mult(pixelsToTileUnits);\n\n if (translateAnchor === 'viewport') {\n pt._rotate(-bearing);\n }\n\n const translated = [];\n for (let i = 0; i < queryGeometry.length; i++) {\n const point = queryGeometry[i];\n translated.push(point.sub(pt));\n }\n return translated;\n}\n\nexport function offsetLine(rings: Array>, offset: number) {\n const newRings: Array> = [];\n for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {\n const ring = rings[ringIndex];\n const newRing: Array = [];\n for (let index = 0; index < ring.length; index++) {\n const a = ring[index - 1];\n const b = ring[index];\n const c = ring[index + 1];\n const aToB = index === 0 ? new Point(0, 0) : b.sub(a)._unit()._perp();\n const bToC = index === ring.length - 1 ? new Point(0, 0) : c.sub(b)._unit()._perp();\n const extrude = aToB._add(bToC)._unit();\n\n const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;\n if (cosHalfAngle !== 0) {\n extrude._mult(1 / cosHalfAngle);\n }\n\n newRing.push(extrude._mult(offset)._add(b));\n }\n newRings.push(newRing);\n }\n return newRings;\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CircleLayoutProps = {\n \"circle-sort-key\": DataDrivenProperty,\n};\n\nexport type CircleLayoutPropsPossiblyEvaluated = {\n \"circle-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"circle-sort-key\": new DataDrivenProperty(styleSpec[\"layout_circle\"][\"circle-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type CirclePaintProps = {\n \"circle-radius\": DataDrivenProperty,\n \"circle-color\": DataDrivenProperty,\n \"circle-blur\": DataDrivenProperty,\n \"circle-opacity\": DataDrivenProperty,\n \"circle-translate\": DataConstantProperty<[number, number]>,\n \"circle-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-scale\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-stroke-width\": DataDrivenProperty,\n \"circle-stroke-color\": DataDrivenProperty,\n \"circle-stroke-opacity\": DataDrivenProperty,\n};\n\nexport type CirclePaintPropsPossiblyEvaluated = {\n \"circle-radius\": PossiblyEvaluatedPropertyValue,\n \"circle-color\": PossiblyEvaluatedPropertyValue,\n \"circle-blur\": PossiblyEvaluatedPropertyValue,\n \"circle-opacity\": PossiblyEvaluatedPropertyValue,\n \"circle-translate\": [number, number],\n \"circle-translate-anchor\": \"map\" | \"viewport\",\n \"circle-pitch-scale\": \"map\" | \"viewport\",\n \"circle-pitch-alignment\": \"map\" | \"viewport\",\n \"circle-stroke-width\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-color\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-opacity\": PossiblyEvaluatedPropertyValue,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"circle-radius\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-radius\"] as any as StylePropertySpecification),\n \"circle-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-color\"] as any as StylePropertySpecification),\n \"circle-blur\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-blur\"] as any as StylePropertySpecification),\n \"circle-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-opacity\"] as any as StylePropertySpecification),\n \"circle-translate\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate\"] as any as StylePropertySpecification),\n \"circle-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate-anchor\"] as any as StylePropertySpecification),\n \"circle-pitch-scale\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-scale\"] as any as StylePropertySpecification),\n \"circle-pitch-alignment\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-alignment\"] as any as StylePropertySpecification),\n \"circle-stroke-width\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-width\"] as any as StylePropertySpecification),\n \"circle-stroke-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-color\"] as any as StylePropertySpecification),\n \"circle-stroke-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","/**\n * Common utilities\n * @module glMatrix\n */\n// Configuration Constants\nexport var EPSILON = 0.000001;\nexport var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;\nexport var RANDOM = Math.random;\n/**\n * Sets the type of array used when creating new vectors and matrices\n *\n * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array\n */\n\nexport function setMatrixArrayType(type) {\n ARRAY_TYPE = type;\n}\nvar degree = Math.PI / 180;\n/**\n * Convert Degree To Radian\n *\n * @param {Number} a Angle in Degrees\n */\n\nexport function toRadian(a) {\n return a * degree;\n}\n/**\n * Tests whether or not the arguments have approximately the same value, within an absolute\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\n * than or equal to 1.0, and a relative tolerance is used for larger values)\n *\n * @param {Number} a The first number to test.\n * @param {Number} b The second number to test.\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\n */\n\nexport function equals(a, b) {\n return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));\n}\nif (!Math.hypot) Math.hypot = function () {\n var y = 0,\n i = arguments.length;\n\n while (i--) {\n y += arguments[i] * arguments[i];\n }\n\n return Math.sqrt(y);\n};","import * as glMatrix from \"./common.js\";\n/**\n * 2x2 Matrix\n * @module mat2\n */\n\n/**\n * Creates a new identity mat2\n *\n * @returns {mat2} a new 2x2 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n }\n\n out[0] = 1;\n out[3] = 1;\n return out;\n}\n/**\n * Creates a new mat2 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat2} a matrix to clone\n * @returns {mat2} a new 2x2 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Copy the values from one mat2 to another\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set a mat2 to the identity matrix\n *\n * @param {mat2} out the receiving matrix\n * @returns {mat2} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n}\n/**\n * Create a new mat2 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out A new 2x2 matrix\n */\n\nexport function fromValues(m00, m01, m10, m11) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n/**\n * Set the components of a mat2 to the given values\n *\n * @param {mat2} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out\n */\n\nexport function set(out, m00, m01, m10, m11) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n/**\n * Transpose the values of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache\n // some values\n if (out === a) {\n var a1 = a[1];\n out[1] = a[2];\n out[2] = a1;\n } else {\n out[0] = a[0];\n out[1] = a[2];\n out[2] = a[1];\n out[3] = a[3];\n }\n\n return out;\n}\n/**\n * Inverts a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function invert(out, a) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3]; // Calculate the determinant\n\n var det = a0 * a3 - a2 * a1;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = a3 * det;\n out[1] = -a1 * det;\n out[2] = -a2 * det;\n out[3] = a0 * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function adjoint(out, a) {\n // Caching this value is nessecary if out == a\n var a0 = a[0];\n out[0] = a[3];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a0;\n return out;\n}\n/**\n * Calculates the determinant of a mat2\n *\n * @param {ReadonlyMat2} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n return a[0] * a[3] - a[2] * a[1];\n}\n/**\n * Multiplies two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function multiply(out, a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = a0 * b0 + a2 * b1;\n out[1] = a1 * b0 + a3 * b1;\n out[2] = a0 * b2 + a2 * b3;\n out[3] = a1 * b2 + a3 * b3;\n return out;\n}\n/**\n * Rotates a mat2 by the given angle\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\n\nexport function rotate(out, a, rad) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = a0 * c + a2 * s;\n out[1] = a1 * c + a3 * s;\n out[2] = a0 * -s + a2 * c;\n out[3] = a1 * -s + a3 * c;\n return out;\n}\n/**\n * Scales the mat2 by the dimensions in the given vec2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to rotate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat2} out\n **/\n\nexport function scale(out, a, v) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var v0 = v[0],\n v1 = v[1];\n out[0] = a0 * v0;\n out[1] = a1 * v0;\n out[2] = a2 * v1;\n out[3] = a3 * v1;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.rotate(dest, dest, rad);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = -s;\n out[3] = c;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.scale(dest, dest, vec);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat2} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = v[1];\n return out;\n}\n/**\n * Returns a string representation of a mat2\n *\n * @param {ReadonlyMat2} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat2(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat2\n *\n * @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3]);\n}\n/**\n * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix\n * @param {ReadonlyMat2} L the lower triangular matrix\n * @param {ReadonlyMat2} D the diagonal matrix\n * @param {ReadonlyMat2} U the upper triangular matrix\n * @param {ReadonlyMat2} a the input matrix to factorize\n */\n\nexport function LDU(L, D, U, a) {\n L[2] = a[2] / a[0];\n U[0] = a[0];\n U[1] = a[1];\n U[3] = a[3] - L[2] * U[1];\n return [L, D, U];\n}\n/**\n * Adds two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat2} a The first matrix.\n * @param {ReadonlyMat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat2} a The first matrix.\n * @param {ReadonlyMat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat2} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two mat2's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat2} out the receiving vector\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat2} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Alias for {@link mat2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat2.subtract}\n * @function\n */\n\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n/**\n * 2x3 Matrix\n * @module mat2d\n * @description\n * A mat2d contains six elements defined as:\n *
\n * [a, b,\n *  c, d,\n *  tx, ty]\n * 
\n * This is a short form for the 3x3 matrix:\n *
\n * [a, b, 0,\n *  c, d, 0,\n *  tx, ty, 1]\n * 
\n * The last column is ignored so the array is shorter and operations are faster.\n */\n\n/**\n * Creates a new identity mat2d\n *\n * @returns {mat2d} a new 2x3 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(6);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[4] = 0;\n out[5] = 0;\n }\n\n out[0] = 1;\n out[3] = 1;\n return out;\n}\n/**\n * Creates a new mat2d initialized with values from an existing matrix\n *\n * @param {ReadonlyMat2d} a matrix to clone\n * @returns {mat2d} a new 2x3 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(6);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n return out;\n}\n/**\n * Copy the values from one mat2d to another\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the source matrix\n * @returns {mat2d} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n return out;\n}\n/**\n * Set a mat2d to the identity matrix\n *\n * @param {mat2d} out the receiving matrix\n * @returns {mat2d} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = 0;\n out[5] = 0;\n return out;\n}\n/**\n * Create a new mat2d with the given values\n *\n * @param {Number} a Component A (index 0)\n * @param {Number} b Component B (index 1)\n * @param {Number} c Component C (index 2)\n * @param {Number} d Component D (index 3)\n * @param {Number} tx Component TX (index 4)\n * @param {Number} ty Component TY (index 5)\n * @returns {mat2d} A new mat2d\n */\n\nexport function fromValues(a, b, c, d, tx, ty) {\n var out = new glMatrix.ARRAY_TYPE(6);\n out[0] = a;\n out[1] = b;\n out[2] = c;\n out[3] = d;\n out[4] = tx;\n out[5] = ty;\n return out;\n}\n/**\n * Set the components of a mat2d to the given values\n *\n * @param {mat2d} out the receiving matrix\n * @param {Number} a Component A (index 0)\n * @param {Number} b Component B (index 1)\n * @param {Number} c Component C (index 2)\n * @param {Number} d Component D (index 3)\n * @param {Number} tx Component TX (index 4)\n * @param {Number} ty Component TY (index 5)\n * @returns {mat2d} out\n */\n\nexport function set(out, a, b, c, d, tx, ty) {\n out[0] = a;\n out[1] = b;\n out[2] = c;\n out[3] = d;\n out[4] = tx;\n out[5] = ty;\n return out;\n}\n/**\n * Inverts a mat2d\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the source matrix\n * @returns {mat2d} out\n */\n\nexport function invert(out, a) {\n var aa = a[0],\n ab = a[1],\n ac = a[2],\n ad = a[3];\n var atx = a[4],\n aty = a[5];\n var det = aa * ad - ab * ac;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = ad * det;\n out[1] = -ab * det;\n out[2] = -ac * det;\n out[3] = aa * det;\n out[4] = (ac * aty - ad * atx) * det;\n out[5] = (ab * atx - aa * aty) * det;\n return out;\n}\n/**\n * Calculates the determinant of a mat2d\n *\n * @param {ReadonlyMat2d} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n return a[0] * a[3] - a[1] * a[2];\n}\n/**\n * Multiplies two mat2d's\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the first operand\n * @param {ReadonlyMat2d} b the second operand\n * @returns {mat2d} out\n */\n\nexport function multiply(out, a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5];\n out[0] = a0 * b0 + a2 * b1;\n out[1] = a1 * b0 + a3 * b1;\n out[2] = a0 * b2 + a2 * b3;\n out[3] = a1 * b2 + a3 * b3;\n out[4] = a0 * b4 + a2 * b5 + a4;\n out[5] = a1 * b4 + a3 * b5 + a5;\n return out;\n}\n/**\n * Rotates a mat2d by the given angle\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2d} out\n */\n\nexport function rotate(out, a, rad) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5];\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = a0 * c + a2 * s;\n out[1] = a1 * c + a3 * s;\n out[2] = a0 * -s + a2 * c;\n out[3] = a1 * -s + a3 * c;\n out[4] = a4;\n out[5] = a5;\n return out;\n}\n/**\n * Scales the mat2d by the dimensions in the given vec2\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to translate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat2d} out\n **/\n\nexport function scale(out, a, v) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5];\n var v0 = v[0],\n v1 = v[1];\n out[0] = a0 * v0;\n out[1] = a1 * v0;\n out[2] = a2 * v1;\n out[3] = a3 * v1;\n out[4] = a4;\n out[5] = a5;\n return out;\n}\n/**\n * Translates the mat2d by the dimensions in the given vec2\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to translate\n * @param {ReadonlyVec2} v the vec2 to translate the matrix by\n * @returns {mat2d} out\n **/\n\nexport function translate(out, a, v) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5];\n var v0 = v[0],\n v1 = v[1];\n out[0] = a0;\n out[1] = a1;\n out[2] = a2;\n out[3] = a3;\n out[4] = a0 * v0 + a2 * v1 + a4;\n out[5] = a1 * v0 + a3 * v1 + a5;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat2d.identity(dest);\n * mat2d.rotate(dest, dest, rad);\n *\n * @param {mat2d} out mat2d receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2d} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = -s;\n out[3] = c;\n out[4] = 0;\n out[5] = 0;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat2d.identity(dest);\n * mat2d.scale(dest, dest, vec);\n *\n * @param {mat2d} out mat2d receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat2d} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = v[1];\n out[4] = 0;\n out[5] = 0;\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat2d.identity(dest);\n * mat2d.translate(dest, dest, vec);\n *\n * @param {mat2d} out mat2d receiving operation result\n * @param {ReadonlyVec2} v Translation vector\n * @returns {mat2d} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = v[0];\n out[5] = v[1];\n return out;\n}\n/**\n * Returns a string representation of a mat2d\n *\n * @param {ReadonlyMat2d} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat2d(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat2d\n *\n * @param {ReadonlyMat2d} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], 1);\n}\n/**\n * Adds two mat2d's\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the first operand\n * @param {ReadonlyMat2d} b the second operand\n * @returns {mat2d} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the first operand\n * @param {ReadonlyMat2d} b the second operand\n * @returns {mat2d} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat2d} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat2d} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n return out;\n}\n/**\n * Adds two mat2d's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat2d} out the receiving vector\n * @param {ReadonlyMat2d} a the first operand\n * @param {ReadonlyMat2d} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat2d} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat2d} a The first matrix.\n * @param {ReadonlyMat2d} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat2d} a The first matrix.\n * @param {ReadonlyMat2d} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5));\n}\n/**\n * Alias for {@link mat2d.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat2d.subtract}\n * @function\n */\n\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n/**\n * 3x3 Matrix\n * @module mat3\n */\n\n/**\n * Creates a new identity mat3\n *\n * @returns {mat3} a new 3x3 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(9);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n }\n\n out[0] = 1;\n out[4] = 1;\n out[8] = 1;\n return out;\n}\n/**\n * Copies the upper-left 3x3 values into the given mat3.\n *\n * @param {mat3} out the receiving 3x3 matrix\n * @param {ReadonlyMat4} a the source 4x4 matrix\n * @returns {mat3} out\n */\n\nexport function fromMat4(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[4];\n out[4] = a[5];\n out[5] = a[6];\n out[6] = a[8];\n out[7] = a[9];\n out[8] = a[10];\n return out;\n}\n/**\n * Creates a new mat3 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat3} a matrix to clone\n * @returns {mat3} a new 3x3 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(9);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Copy the values from one mat3 to another\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Create a new mat3 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} A new mat3\n */\n\nexport function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n var out = new glMatrix.ARRAY_TYPE(9);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n/**\n * Set the components of a mat3 to the given values\n *\n * @param {mat3} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} out\n */\n\nexport function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n/**\n * Set a mat3 to the identity matrix\n *\n * @param {mat3} out the receiving matrix\n * @returns {mat3} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a12 = a[5];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a01;\n out[5] = a[7];\n out[6] = a02;\n out[7] = a12;\n } else {\n out[0] = a[0];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a[1];\n out[4] = a[4];\n out[5] = a[7];\n out[6] = a[2];\n out[7] = a[5];\n out[8] = a[8];\n }\n\n return out;\n}\n/**\n * Inverts a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n var b01 = a22 * a11 - a12 * a21;\n var b11 = -a22 * a10 + a12 * a20;\n var b21 = a21 * a10 - a11 * a20; // Calculate the determinant\n\n var det = a00 * b01 + a01 * b11 + a02 * b21;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = b01 * det;\n out[1] = (-a22 * a01 + a02 * a21) * det;\n out[2] = (a12 * a01 - a02 * a11) * det;\n out[3] = b11 * det;\n out[4] = (a22 * a00 - a02 * a20) * det;\n out[5] = (-a12 * a00 + a02 * a10) * det;\n out[6] = b21 * det;\n out[7] = (-a21 * a00 + a01 * a20) * det;\n out[8] = (a11 * a00 - a01 * a10) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n out[0] = a11 * a22 - a12 * a21;\n out[1] = a02 * a21 - a01 * a22;\n out[2] = a01 * a12 - a02 * a11;\n out[3] = a12 * a20 - a10 * a22;\n out[4] = a00 * a22 - a02 * a20;\n out[5] = a02 * a10 - a00 * a12;\n out[6] = a10 * a21 - a11 * a20;\n out[7] = a01 * a20 - a00 * a21;\n out[8] = a00 * a11 - a01 * a10;\n return out;\n}\n/**\n * Calculates the determinant of a mat3\n *\n * @param {ReadonlyMat3} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);\n}\n/**\n * Multiplies two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n var b00 = b[0],\n b01 = b[1],\n b02 = b[2];\n var b10 = b[3],\n b11 = b[4],\n b12 = b[5];\n var b20 = b[6],\n b21 = b[7],\n b22 = b[8];\n out[0] = b00 * a00 + b01 * a10 + b02 * a20;\n out[1] = b00 * a01 + b01 * a11 + b02 * a21;\n out[2] = b00 * a02 + b01 * a12 + b02 * a22;\n out[3] = b10 * a00 + b11 * a10 + b12 * a20;\n out[4] = b10 * a01 + b11 * a11 + b12 * a21;\n out[5] = b10 * a02 + b11 * a12 + b12 * a22;\n out[6] = b20 * a00 + b21 * a10 + b22 * a20;\n out[7] = b20 * a01 + b21 * a11 + b22 * a21;\n out[8] = b20 * a02 + b21 * a12 + b22 * a22;\n return out;\n}\n/**\n * Translate a mat3 by the given vector\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to translate\n * @param {ReadonlyVec2} v vector to translate by\n * @returns {mat3} out\n */\n\nexport function translate(out, a, v) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a10 = a[3],\n a11 = a[4],\n a12 = a[5],\n a20 = a[6],\n a21 = a[7],\n a22 = a[8],\n x = v[0],\n y = v[1];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a10;\n out[4] = a11;\n out[5] = a12;\n out[6] = x * a00 + y * a10 + a20;\n out[7] = x * a01 + y * a11 + a21;\n out[8] = x * a02 + y * a12 + a22;\n return out;\n}\n/**\n * Rotates a mat3 by the given angle\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\n\nexport function rotate(out, a, rad) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a10 = a[3],\n a11 = a[4],\n a12 = a[5],\n a20 = a[6],\n a21 = a[7],\n a22 = a[8],\n s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c * a00 + s * a10;\n out[1] = c * a01 + s * a11;\n out[2] = c * a02 + s * a12;\n out[3] = c * a10 - s * a00;\n out[4] = c * a11 - s * a01;\n out[5] = c * a12 - s * a02;\n out[6] = a20;\n out[7] = a21;\n out[8] = a22;\n return out;\n}\n/**\n * Scales the mat3 by the dimensions in the given vec2\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat3} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1];\n out[0] = x * a[0];\n out[1] = x * a[1];\n out[2] = x * a[2];\n out[3] = y * a[3];\n out[4] = y * a[4];\n out[5] = y * a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.translate(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Translation vector\n * @returns {mat3} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = v[0];\n out[7] = v[1];\n out[8] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.rotate(dest, dest, rad);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = -s;\n out[4] = c;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.scale(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat3} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = v[1];\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Copies the values from a mat2d into a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to copy\n * @returns {mat3} out\n **/\n\nexport function fromMat2d(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = 0;\n out[3] = a[2];\n out[4] = a[3];\n out[5] = 0;\n out[6] = a[4];\n out[7] = a[5];\n out[8] = 1;\n return out;\n}\n/**\n * Calculates a 3x3 matrix from the given quaternion\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat3} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[3] = yx - wz;\n out[6] = zx + wy;\n out[1] = yx + wz;\n out[4] = 1 - xx - zz;\n out[7] = zy - wx;\n out[2] = zx - wy;\n out[5] = zy + wx;\n out[8] = 1 - xx - yy;\n return out;\n}\n/**\n * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from\n *\n * @returns {mat3} out\n */\n\nexport function normalFromMat4(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n return out;\n}\n/**\n * Generates a 2D projection matrix with the given bounds\n *\n * @param {mat3} out mat3 frustum matrix will be written into\n * @param {number} width Width of your gl context\n * @param {number} height Height of gl context\n * @returns {mat3} out\n */\n\nexport function projection(out, width, height) {\n out[0] = 2 / width;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = -2 / height;\n out[5] = 0;\n out[6] = -1;\n out[7] = 1;\n out[8] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat3\n *\n * @param {ReadonlyMat3} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat3\n *\n * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);\n}\n/**\n * Adds two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat3} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n return out;\n}\n/**\n * Adds two mat3's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat3} out the receiving vector\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat3} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7],\n a8 = a[8];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));\n}\n/**\n * Alias for {@link mat3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat3.subtract}\n * @function\n */\n\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n/**\n * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.\n * @module mat4\n */\n\n/**\n * Creates a new identity mat4\n *\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(16);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n }\n\n out[0] = 1;\n out[5] = 1;\n out[10] = 1;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat4} a matrix to clone\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Copy the values from one mat4 to another\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Create a new mat4 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} A new mat4\n */\n\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set the components of a mat4 to the given values\n *\n * @param {mat4} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} out\n */\n\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set a mat4 to the identity matrix\n *\n * @param {mat4} out the receiving matrix\n * @returns {mat4} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a12 = a[6],\n a13 = a[7];\n var a23 = a[11];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a01;\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a02;\n out[9] = a12;\n out[11] = a[14];\n out[12] = a03;\n out[13] = a13;\n out[14] = a23;\n } else {\n out[0] = a[0];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a[1];\n out[5] = a[5];\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a[2];\n out[9] = a[6];\n out[10] = a[10];\n out[11] = a[14];\n out[12] = a[3];\n out[13] = a[7];\n out[14] = a[11];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Inverts a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22);\n out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\n out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12);\n out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\n out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\n out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22);\n out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\n out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12);\n out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21);\n out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\n out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11);\n out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\n out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\n out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21);\n out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\n out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11);\n return out;\n}\n/**\n * Calculates the determinant of a mat4\n *\n * @param {ReadonlyMat4} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n}\n/**\n * Multiplies two mat4s\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15]; // Cache only the current line of the second matrix\n\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[4];\n b1 = b[5];\n b2 = b[6];\n b3 = b[7];\n out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[8];\n b1 = b[9];\n b2 = b[10];\n b3 = b[11];\n out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[12];\n b1 = b[13];\n b2 = b[14];\n b3 = b[15];\n out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n return out;\n}\n/**\n * Translate a mat4 by the given vector\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to translate\n * @param {ReadonlyVec3} v vector to translate by\n * @returns {mat4} out\n */\n\nexport function translate(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n\n if (a === out) {\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n } else {\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a03;\n out[4] = a10;\n out[5] = a11;\n out[6] = a12;\n out[7] = a13;\n out[8] = a20;\n out[9] = a21;\n out[10] = a22;\n out[11] = a23;\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\n }\n\n return out;\n}\n/**\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {ReadonlyVec3} v the vec3 to scale the matrix by\n * @returns {mat4} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n out[0] = a[0] * x;\n out[1] = a[1] * x;\n out[2] = a[2] * x;\n out[3] = a[3] * x;\n out[4] = a[4] * y;\n out[5] = a[5] * y;\n out[6] = a[6] * y;\n out[7] = a[7] * y;\n out[8] = a[8] * z;\n out[9] = a[9] * z;\n out[10] = a[10] * z;\n out[11] = a[11] * z;\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Rotates a mat4 by the given angle around the given axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function rotate(out, a, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n var b00, b01, b02;\n var b10, b11, b12;\n var b20, b21, b22;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c;\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11]; // Construct the elements of the rotation matrix\n\n b00 = x * x * t + c;\n b01 = y * x * t + z * s;\n b02 = z * x * t - y * s;\n b10 = x * y * t - z * s;\n b11 = y * y * t + c;\n b12 = z * y * t + x * s;\n b20 = x * z * t + y * s;\n b21 = y * z * t - x * s;\n b22 = z * z * t + c; // Perform rotation-specific matrix multiplication\n\n out[0] = a00 * b00 + a10 * b01 + a20 * b02;\n out[1] = a01 * b00 + a11 * b01 + a21 * b02;\n out[2] = a02 * b00 + a12 * b01 + a22 * b02;\n out[3] = a03 * b00 + a13 * b01 + a23 * b02;\n out[4] = a00 * b10 + a10 * b11 + a20 * b12;\n out[5] = a01 * b10 + a11 * b11 + a21 * b12;\n out[6] = a02 * b10 + a12 * b11 + a22 * b12;\n out[7] = a03 * b10 + a13 * b11 + a23 * b12;\n out[8] = a00 * b20 + a10 * b21 + a20 * b22;\n out[9] = a01 * b20 + a11 * b21 + a21 * b22;\n out[10] = a02 * b20 + a12 * b21 + a22 * b22;\n out[11] = a03 * b20 + a13 * b21 + a23 * b22;\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the X axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateX(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[4] = a10 * c + a20 * s;\n out[5] = a11 * c + a21 * s;\n out[6] = a12 * c + a22 * s;\n out[7] = a13 * c + a23 * s;\n out[8] = a20 * c - a10 * s;\n out[9] = a21 * c - a11 * s;\n out[10] = a22 * c - a12 * s;\n out[11] = a23 * c - a13 * s;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Y axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateY(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c - a20 * s;\n out[1] = a01 * c - a21 * s;\n out[2] = a02 * c - a22 * s;\n out[3] = a03 * c - a23 * s;\n out[8] = a00 * s + a20 * c;\n out[9] = a01 * s + a21 * c;\n out[10] = a02 * s + a22 * c;\n out[11] = a03 * s + a23 * c;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Z axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateZ(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c + a10 * s;\n out[1] = a01 * c + a11 * s;\n out[2] = a02 * c + a12 * s;\n out[3] = a03 * c + a13 * s;\n out[4] = a10 * c - a00 * s;\n out[5] = a11 * c - a01 * s;\n out[6] = a12 * c - a02 * s;\n out[7] = a13 * c - a03 * s;\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.scale(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = v[1];\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = v[2];\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle around a given axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotate(dest, dest, rad, axis);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function fromRotation(out, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c; // Perform rotation-specific matrix multiplication\n\n out[0] = x * x * t + c;\n out[1] = y * x * t + z * s;\n out[2] = z * x * t - y * s;\n out[3] = 0;\n out[4] = x * y * t - z * s;\n out[5] = y * y * t + c;\n out[6] = z * y * t + x * s;\n out[7] = 0;\n out[8] = x * z * t + y * s;\n out[9] = y * z * t - x * s;\n out[10] = z * z * t + c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the X axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateX(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromXRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = c;\n out[6] = s;\n out[7] = 0;\n out[8] = 0;\n out[9] = -s;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Y axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateY(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromYRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = 0;\n out[2] = -s;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = s;\n out[9] = 0;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Z axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateZ(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromZRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = 0;\n out[4] = -s;\n out[5] = c;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation and vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslation(out, q, v) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 from a dual quat.\n *\n * @param {mat4} out Matrix\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @returns {mat4} mat4 receiving operation result\n */\n\nexport function fromQuat2(out, a) {\n var translation = new glMatrix.ARRAY_TYPE(3);\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7];\n var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense\n\n if (magnitude > 0) {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\n } else {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n }\n\n fromRotationTranslation(out, a, translation);\n return out;\n}\n/**\n * Returns the translation vector component of a transformation\n * matrix. If a matrix is built with fromRotationTranslation,\n * the returned vector will be the same as the translation vector\n * originally supplied.\n * @param {vec3} out Vector to receive translation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getTranslation(out, mat) {\n out[0] = mat[12];\n out[1] = mat[13];\n out[2] = mat[14];\n return out;\n}\n/**\n * Returns the scaling factor component of a transformation\n * matrix. If a matrix is built with fromRotationTranslationScale\n * with a normalized Quaternion paramter, the returned vector will be\n * the same as the scaling vector\n * originally supplied.\n * @param {vec3} out Vector to receive scaling factor component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getScaling(out, mat) {\n var m11 = mat[0];\n var m12 = mat[1];\n var m13 = mat[2];\n var m21 = mat[4];\n var m22 = mat[5];\n var m23 = mat[6];\n var m31 = mat[8];\n var m32 = mat[9];\n var m33 = mat[10];\n out[0] = Math.hypot(m11, m12, m13);\n out[1] = Math.hypot(m21, m22, m23);\n out[2] = Math.hypot(m31, m32, m33);\n return out;\n}\n/**\n * Returns a quaternion representing the rotational component\n * of a transformation matrix. If a matrix is built with\n * fromRotationTranslation, the returned quaternion will be the\n * same as the quaternion originally supplied.\n * @param {quat} out Quaternion to receive the rotation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {quat} out\n */\n\nexport function getRotation(out, mat) {\n var scaling = new glMatrix.ARRAY_TYPE(3);\n getScaling(scaling, mat);\n var is1 = 1 / scaling[0];\n var is2 = 1 / scaling[1];\n var is3 = 1 / scaling[2];\n var sm11 = mat[0] * is1;\n var sm12 = mat[1] * is2;\n var sm13 = mat[2] * is3;\n var sm21 = mat[4] * is1;\n var sm22 = mat[5] * is2;\n var sm23 = mat[6] * is3;\n var sm31 = mat[8] * is1;\n var sm32 = mat[9] * is2;\n var sm33 = mat[10] * is3;\n var trace = sm11 + sm22 + sm33;\n var S = 0;\n\n if (trace > 0) {\n S = Math.sqrt(trace + 1.0) * 2;\n out[3] = 0.25 * S;\n out[0] = (sm23 - sm32) / S;\n out[1] = (sm31 - sm13) / S;\n out[2] = (sm12 - sm21) / S;\n } else if (sm11 > sm22 && sm11 > sm33) {\n S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n out[3] = (sm23 - sm32) / S;\n out[0] = 0.25 * S;\n out[1] = (sm12 + sm21) / S;\n out[2] = (sm31 + sm13) / S;\n } else if (sm22 > sm33) {\n S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n out[3] = (sm31 - sm13) / S;\n out[0] = (sm12 + sm21) / S;\n out[1] = 0.25 * S;\n out[2] = (sm23 + sm32) / S;\n } else {\n S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n out[3] = (sm12 - sm21) / S;\n out[0] = (sm31 + sm13) / S;\n out[1] = (sm23 + sm32) / S;\n out[2] = 0.25 * S;\n }\n\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScale(out, q, v, s) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n out[0] = (1 - (yy + zz)) * sx;\n out[1] = (xy + wz) * sx;\n out[2] = (xz - wy) * sx;\n out[3] = 0;\n out[4] = (xy - wz) * sy;\n out[5] = (1 - (xx + zz)) * sy;\n out[6] = (yz + wx) * sy;\n out[7] = 0;\n out[8] = (xz + wy) * sz;\n out[9] = (yz - wx) * sz;\n out[10] = (1 - (xx + yy)) * sz;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * mat4.translate(dest, origin);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n * mat4.translate(dest, negativeOrigin);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @param {ReadonlyVec3} o The origin vector around which to scale and rotate\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n var ox = o[0];\n var oy = o[1];\n var oz = o[2];\n var out0 = (1 - (yy + zz)) * sx;\n var out1 = (xy + wz) * sx;\n var out2 = (xz - wy) * sx;\n var out4 = (xy - wz) * sy;\n var out5 = (1 - (xx + zz)) * sy;\n var out6 = (yz + wx) * sy;\n var out8 = (xz + wy) * sz;\n var out9 = (yz - wx) * sz;\n var out10 = (1 - (xx + yy)) * sz;\n out[0] = out0;\n out[1] = out1;\n out[2] = out2;\n out[3] = 0;\n out[4] = out4;\n out[5] = out5;\n out[6] = out6;\n out[7] = 0;\n out[8] = out8;\n out[9] = out9;\n out[10] = out10;\n out[11] = 0;\n out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\n out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\n out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\n out[15] = 1;\n return out;\n}\n/**\n * Calculates a 4x4 matrix from the given quaternion\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat4} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[1] = yx + wz;\n out[2] = zx - wy;\n out[3] = 0;\n out[4] = yx - wz;\n out[5] = 1 - xx - zz;\n out[6] = zy + wx;\n out[7] = 0;\n out[8] = zx + wy;\n out[9] = zy - wx;\n out[10] = 1 - xx - yy;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a frustum matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Number} left Left bound of the frustum\n * @param {Number} right Right bound of the frustum\n * @param {Number} bottom Bottom bound of the frustum\n * @param {Number} top Top bound of the frustum\n * @param {Number} near Near bound of the frustum\n * @param {Number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function frustum(out, left, right, bottom, top, near, far) {\n var rl = 1 / (right - left);\n var tb = 1 / (top - bottom);\n var nf = 1 / (near - far);\n out[0] = near * 2 * rl;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = near * 2 * tb;\n out[6] = 0;\n out[7] = 0;\n out[8] = (right + left) * rl;\n out[9] = (top + bottom) * tb;\n out[10] = (far + near) * nf;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[14] = far * near * 2 * nf;\n out[15] = 0;\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveNO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = (far + near) * nf;\n out[14] = 2 * far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -2 * near;\n }\n\n return out;\n}\n/**\n * Alias for {@link mat4.perspectiveNO}\n * @function\n */\n\nexport var perspective = perspectiveNO;\n/**\n * Generates a perspective projection matrix suitable for WebGPU with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveZO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = far * nf;\n out[14] = far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -near;\n }\n\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given field of view.\n * This is primarily useful for generating projection matrices to be used\n * with the still experiemental WebVR API.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\n var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);\n var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);\n var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);\n var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);\n var xScale = 2.0 / (leftTan + rightTan);\n var yScale = 2.0 / (upTan + downTan);\n out[0] = xScale;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n out[4] = 0.0;\n out[5] = yScale;\n out[6] = 0.0;\n out[7] = 0.0;\n out[8] = -((leftTan - rightTan) * xScale * 0.5);\n out[9] = (upTan - downTan) * yScale * 0.5;\n out[10] = far / (near - far);\n out[11] = -1.0;\n out[12] = 0.0;\n out[13] = 0.0;\n out[14] = far * near / (near - far);\n out[15] = 0.0;\n return out;\n}\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoNO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 2 * nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = (far + near) * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Alias for {@link mat4.orthoNO}\n * @function\n */\n\nexport var ortho = orthoNO;\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoZO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = near * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a look-at matrix with the given eye position, focal point, and up axis.\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function lookAt(out, eye, center, up) {\n var x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\n var eyex = eye[0];\n var eyey = eye[1];\n var eyez = eye[2];\n var upx = up[0];\n var upy = up[1];\n var upz = up[2];\n var centerx = center[0];\n var centery = center[1];\n var centerz = center[2];\n\n if (Math.abs(eyex - centerx) < glMatrix.EPSILON && Math.abs(eyey - centery) < glMatrix.EPSILON && Math.abs(eyez - centerz) < glMatrix.EPSILON) {\n return identity(out);\n }\n\n z0 = eyex - centerx;\n z1 = eyey - centery;\n z2 = eyez - centerz;\n len = 1 / Math.hypot(z0, z1, z2);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n x0 = upy * z2 - upz * z1;\n x1 = upz * z0 - upx * z2;\n x2 = upx * z1 - upy * z0;\n len = Math.hypot(x0, x1, x2);\n\n if (!len) {\n x0 = 0;\n x1 = 0;\n x2 = 0;\n } else {\n len = 1 / len;\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n y0 = z1 * x2 - z2 * x1;\n y1 = z2 * x0 - z0 * x2;\n y2 = z0 * x1 - z1 * x0;\n len = Math.hypot(y0, y1, y2);\n\n if (!len) {\n y0 = 0;\n y1 = 0;\n y2 = 0;\n } else {\n len = 1 / len;\n y0 *= len;\n y1 *= len;\n y2 *= len;\n }\n\n out[0] = x0;\n out[1] = y0;\n out[2] = z0;\n out[3] = 0;\n out[4] = x1;\n out[5] = y1;\n out[6] = z1;\n out[7] = 0;\n out[8] = x2;\n out[9] = y2;\n out[10] = z2;\n out[11] = 0;\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n out[15] = 1;\n return out;\n}\n/**\n * Generates a matrix that makes something look at something else.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function targetTo(out, eye, target, up) {\n var eyex = eye[0],\n eyey = eye[1],\n eyez = eye[2],\n upx = up[0],\n upy = up[1],\n upz = up[2];\n var z0 = eyex - target[0],\n z1 = eyey - target[1],\n z2 = eyez - target[2];\n var len = z0 * z0 + z1 * z1 + z2 * z2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n }\n\n var x0 = upy * z2 - upz * z1,\n x1 = upz * z0 - upx * z2,\n x2 = upx * z1 - upy * z0;\n len = x0 * x0 + x1 * x1 + x2 * x2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n out[0] = x0;\n out[1] = x1;\n out[2] = x2;\n out[3] = 0;\n out[4] = z1 * x2 - z2 * x1;\n out[5] = z2 * x0 - z0 * x2;\n out[6] = z0 * x1 - z1 * x0;\n out[7] = 0;\n out[8] = z0;\n out[9] = z1;\n out[10] = z2;\n out[11] = 0;\n out[12] = eyex;\n out[13] = eyey;\n out[14] = eyez;\n out[15] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat4\n *\n * @param {ReadonlyMat4} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \", \" + a[9] + \", \" + a[10] + \", \" + a[11] + \", \" + a[12] + \", \" + a[13] + \", \" + a[14] + \", \" + a[15] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat4\n *\n * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);\n}\n/**\n * Adds two mat4's\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n out[9] = a[9] + b[9];\n out[10] = a[10] + b[10];\n out[11] = a[11] + b[11];\n out[12] = a[12] + b[12];\n out[13] = a[13] + b[13];\n out[14] = a[14] + b[14];\n out[15] = a[15] + b[15];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n out[9] = a[9] - b[9];\n out[10] = a[10] - b[10];\n out[11] = a[11] - b[11];\n out[12] = a[12] - b[12];\n out[13] = a[13] - b[13];\n out[14] = a[14] - b[14];\n out[15] = a[15] - b[15];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat4} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n out[9] = a[9] * b;\n out[10] = a[10] * b;\n out[11] = a[11] * b;\n out[12] = a[12] * b;\n out[13] = a[13] * b;\n out[14] = a[14] * b;\n out[15] = a[15] * b;\n return out;\n}\n/**\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat4} out the receiving vector\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat4} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n out[9] = a[9] + b[9] * scale;\n out[10] = a[10] + b[10] * scale;\n out[11] = a[11] + b[11] * scale;\n out[12] = a[12] + b[12] * scale;\n out[13] = a[13] + b[13] * scale;\n out[14] = a[14] + b[14] * scale;\n out[15] = a[15] + b[15] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7];\n var a8 = a[8],\n a9 = a[9],\n a10 = a[10],\n a11 = a[11];\n var a12 = a[12],\n a13 = a[13],\n a14 = a[14],\n a15 = a[15];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n var b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7];\n var b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11];\n var b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15));\n}\n/**\n * Alias for {@link mat4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat4.subtract}\n * @function\n */\n\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n/**\n * 3 Dimensional Vector\n * @module vec3\n */\n\n/**\n * Creates a new, empty vec3\n *\n * @returns {vec3} a new 3D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(3);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec3 initialized with values from an existing vector\n *\n * @param {ReadonlyVec3} a vector to clone\n * @returns {vec3} a new 3D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Calculates the length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Creates a new vec3 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} a new 3D vector\n */\n\nexport function fromValues(x, y, z) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Copy the values from one vec3 to another\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the source vector\n * @returns {vec3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Set the components of a vec3 to the given values\n *\n * @param {vec3} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} out\n */\n\nexport function set(out, x, y, z) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Adds two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n return out;\n}\n/**\n * Multiplies two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n return out;\n}\n/**\n * Divides two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n return out;\n}\n/**\n * Math.ceil the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to ceil\n * @returns {vec3} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n return out;\n}\n/**\n * Math.floor the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to floor\n * @returns {vec3} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n return out;\n}\n/**\n * Returns the minimum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n return out;\n}\n/**\n * Returns the maximum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n return out;\n}\n/**\n * Math.round the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to round\n * @returns {vec3} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n return out;\n}\n/**\n * Scales a vec3 by a scalar number\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec3} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n return out;\n}\n/**\n * Adds two vec3's after scaling the second operand by a scalar value\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec3} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Calculates the squared euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Calculates the squared length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Negates the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to negate\n * @returns {vec3} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to invert\n * @returns {vec3} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n return out;\n}\n/**\n * Normalize a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to normalize\n * @returns {vec3} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var len = x * x + y * y + z * z;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n out[2] = a[2] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n/**\n * Computes the cross product of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2];\n var bx = b[0],\n by = b[1],\n bz = b[2];\n out[0] = ay * bz - az * by;\n out[1] = az * bx - ax * bz;\n out[2] = ax * by - ay * bx;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n return out;\n}\n/**\n * Performs a hermite interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function hermite(out, a, b, c, d, t) {\n var factorTimes2 = t * t;\n var factor1 = factorTimes2 * (2 * t - 3) + 1;\n var factor2 = factorTimes2 * (t - 2) + t;\n var factor3 = factorTimes2 * (t - 1);\n var factor4 = factorTimes2 * (3 - 2 * t);\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Performs a bezier interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function bezier(out, a, b, c, d, t) {\n var inverseFactor = 1 - t;\n var inverseFactorTimesTwo = inverseFactor * inverseFactor;\n var factorTimes2 = t * t;\n var factor1 = inverseFactorTimesTwo * inverseFactor;\n var factor2 = 3 * t * inverseFactorTimesTwo;\n var factor3 = 3 * factorTimes2 * inverseFactor;\n var factor4 = factorTimes2 * t;\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec3} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec3} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n var z = glMatrix.RANDOM() * 2.0 - 1.0;\n var zScale = Math.sqrt(1.0 - z * z) * scale;\n out[0] = Math.cos(r) * zScale;\n out[1] = Math.sin(r) * zScale;\n out[2] = z * scale;\n return out;\n}\n/**\n * Transforms the vec3 with a mat4.\n * 4th vector component is implicitly '1'\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var w = m[3] * x + m[7] * y + m[11] * z + m[15];\n w = w || 1.0;\n out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n return out;\n}\n/**\n * Transforms the vec3 with a mat3.\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat3} m the 3x3 matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n out[0] = x * m[0] + y * m[3] + z * m[6];\n out[1] = x * m[1] + y * m[4] + z * m[7];\n out[2] = x * m[2] + y * m[5] + z * m[8];\n return out;\n}\n/**\n * Transforms the vec3 with a quat\n * Can also be used for dual quaternions. (Multiply it with the real part)\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec3} out\n */\n\nexport function transformQuat(out, a, q) {\n // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3];\n var x = a[0],\n y = a[1],\n z = a[2]; // var qvec = [qx, qy, qz];\n // var uv = vec3.cross([], qvec, a);\n\n var uvx = qy * z - qz * y,\n uvy = qz * x - qx * z,\n uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv);\n\n var uuvx = qy * uvz - qz * uvy,\n uuvy = qz * uvx - qx * uvz,\n uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w);\n\n var w2 = qw * 2;\n uvx *= w2;\n uvy *= w2;\n uvz *= w2; // vec3.scale(uuv, uuv, 2);\n\n uuvx *= 2;\n uuvy *= 2;\n uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv));\n\n out[0] = x + uvx + uuvx;\n out[1] = y + uvy + uuvy;\n out[2] = z + uvz + uuvz;\n return out;\n}\n/**\n * Rotate a 3D vector around the x-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateX(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the y-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateY(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the z-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateZ(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2]; //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Get the angle between two 3D vectors\n * @param {ReadonlyVec3} a The first operand\n * @param {ReadonlyVec3} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2],\n bx = b[0],\n by = b[1],\n bz = b[2],\n mag1 = Math.sqrt(ax * ax + ay * ay + az * az),\n mag2 = Math.sqrt(bx * bx + by * by + bz * bz),\n mag = mag1 * mag2,\n cosine = mag && dot(a, b) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec3 to zero\n *\n * @param {vec3} out the receiving vector\n * @returns {vec3} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec3} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));\n}\n/**\n * Alias for {@link vec3.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec3.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec3.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec3.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec3.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec3.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec3s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 3;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n }\n\n return a;\n };\n}();","import * as glMatrix from \"./common.js\";\n/**\n * 4 Dimensional Vector\n * @module vec4\n */\n\n/**\n * Creates a new, empty vec4\n *\n * @returns {vec4} a new 4D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec4 initialized with values from an existing vector\n *\n * @param {ReadonlyVec4} a vector to clone\n * @returns {vec4} a new 4D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Creates a new vec4 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} a new 4D vector\n */\n\nexport function fromValues(x, y, z, w) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Copy the values from one vec4 to another\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the source vector\n * @returns {vec4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to the given values\n *\n * @param {vec4} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} out\n */\n\nexport function set(out, x, y, z, w) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Adds two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Multiplies two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n out[3] = a[3] * b[3];\n return out;\n}\n/**\n * Divides two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n out[3] = a[3] / b[3];\n return out;\n}\n/**\n * Math.ceil the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to ceil\n * @returns {vec4} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n out[3] = Math.ceil(a[3]);\n return out;\n}\n/**\n * Math.floor the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to floor\n * @returns {vec4} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n out[3] = Math.floor(a[3]);\n return out;\n}\n/**\n * Returns the minimum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n out[3] = Math.min(a[3], b[3]);\n return out;\n}\n/**\n * Returns the maximum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n out[3] = Math.max(a[3], b[3]);\n return out;\n}\n/**\n * Math.round the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to round\n * @returns {vec4} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n out[3] = Math.round(a[3]);\n return out;\n}\n/**\n * Scales a vec4 by a scalar number\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec4} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two vec4's after scaling the second operand by a scalar value\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec4} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Calculates the length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Negates the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to negate\n * @returns {vec4} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = -a[3];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to invert\n * @returns {vec4} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n out[3] = 1.0 / a[3];\n return out;\n}\n/**\n * Normalize a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to normalize\n * @returns {vec4} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n var len = x * x + y * y + z * z + w * w;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = x * len;\n out[1] = y * len;\n out[2] = z * len;\n out[3] = w * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n/**\n * Returns the cross-product of three vectors in a 4-dimensional space\n *\n * @param {ReadonlyVec4} result the receiving vector\n * @param {ReadonlyVec4} U the first vector\n * @param {ReadonlyVec4} V the second vector\n * @param {ReadonlyVec4} W the third vector\n * @returns {vec4} result\n */\n\nexport function cross(out, u, v, w) {\n var A = v[0] * w[1] - v[1] * w[0],\n B = v[0] * w[2] - v[2] * w[0],\n C = v[0] * w[3] - v[3] * w[0],\n D = v[1] * w[2] - v[2] * w[1],\n E = v[1] * w[3] - v[3] * w[1],\n F = v[2] * w[3] - v[3] * w[2];\n var G = u[0];\n var H = u[1];\n var I = u[2];\n var J = u[3];\n out[0] = H * F - I * E + J * D;\n out[1] = -(G * F) + I * C - J * B;\n out[2] = G * E - H * C + J * A;\n out[3] = -(G * D) + H * B - I * A;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec4} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n var aw = a[3];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n out[3] = aw + t * (b[3] - aw);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec4} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec4} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a\n // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.\n // http://projecteuclid.org/euclid.aoms/1177692644;\n\n var v1, v2, v3, v4;\n var s1, s2;\n\n do {\n v1 = glMatrix.RANDOM() * 2 - 1;\n v2 = glMatrix.RANDOM() * 2 - 1;\n s1 = v1 * v1 + v2 * v2;\n } while (s1 >= 1);\n\n do {\n v3 = glMatrix.RANDOM() * 2 - 1;\n v4 = glMatrix.RANDOM() * 2 - 1;\n s2 = v3 * v3 + v4 * v4;\n } while (s2 >= 1);\n\n var d = Math.sqrt((1 - s1) / s2);\n out[0] = scale * v1;\n out[1] = scale * v2;\n out[2] = scale * v3 * d;\n out[3] = scale * v4 * d;\n return out;\n}\n/**\n * Transforms the vec4 with a mat4.\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec4} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2],\n w = a[3];\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n return out;\n}\n/**\n * Transforms the vec4 with a quat\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec4} out\n */\n\nexport function transformQuat(out, a, q) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3]; // calculate quat * vec\n\n var ix = qw * x + qy * z - qz * y;\n var iy = qw * y + qz * x - qx * z;\n var iz = qw * z + qx * y - qy * x;\n var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat\n\n out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to zero\n *\n * @param {vec4} out the receiving vector\n * @returns {vec4} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec4} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Alias for {@link vec4.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec4.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec4.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec4.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec4.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec4.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec4s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 4;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n vec[3] = a[i + 3];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n a[i + 3] = vec[3];\n }\n\n return a;\n };\n}();","import * as glMatrix from \"./common.js\";\nimport * as mat3 from \"./mat3.js\";\nimport * as vec3 from \"./vec3.js\";\nimport * as vec4 from \"./vec4.js\";\n/**\n * Quaternion\n * @module quat\n */\n\n/**\n * Creates a new identity quat\n *\n * @returns {quat} a new quaternion\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n\n out[3] = 1;\n return out;\n}\n/**\n * Set a quat to the identity quaternion\n *\n * @param {quat} out the receiving quaternion\n * @returns {quat} out\n */\n\nexport function identity(out) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n}\n/**\n * Sets a quat from the given angle and rotation axis,\n * then returns it.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyVec3} axis the axis around which to rotate\n * @param {Number} rad the angle in radians\n * @returns {quat} out\n **/\n\nexport function setAxisAngle(out, axis, rad) {\n rad = rad * 0.5;\n var s = Math.sin(rad);\n out[0] = s * axis[0];\n out[1] = s * axis[1];\n out[2] = s * axis[2];\n out[3] = Math.cos(rad);\n return out;\n}\n/**\n * Gets the rotation axis and angle for a given\n * quaternion. If a quaternion is created with\n * setAxisAngle, this method will return the same\n * values as providied in the original parameter list\n * OR functionally equivalent values.\n * Example: The quaternion formed by axis [0, 0, 1] and\n * angle -90 is the same as the quaternion formed by\n * [0, 0, 1] and 270. This method favors the latter.\n * @param {vec3} out_axis Vector receiving the axis of rotation\n * @param {ReadonlyQuat} q Quaternion to be decomposed\n * @return {Number} Angle, in radians, of the rotation\n */\n\nexport function getAxisAngle(out_axis, q) {\n var rad = Math.acos(q[3]) * 2.0;\n var s = Math.sin(rad / 2.0);\n\n if (s > glMatrix.EPSILON) {\n out_axis[0] = q[0] / s;\n out_axis[1] = q[1] / s;\n out_axis[2] = q[2] / s;\n } else {\n // If s is zero, return any axis (no rotation - axis does not matter)\n out_axis[0] = 1;\n out_axis[1] = 0;\n out_axis[2] = 0;\n }\n\n return rad;\n}\n/**\n * Gets the angular distance between two unit quaternions\n *\n * @param {ReadonlyQuat} a Origin unit quaternion\n * @param {ReadonlyQuat} b Destination unit quaternion\n * @return {Number} Angle, in radians, between the two quaternions\n */\n\nexport function getAngle(a, b) {\n var dotproduct = dot(a, b);\n return Math.acos(2 * dotproduct * dotproduct - 1);\n}\n/**\n * Multiplies two quat's\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a the first operand\n * @param {ReadonlyQuat} b the second operand\n * @returns {quat} out\n */\n\nexport function multiply(out, a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n var bx = b[0],\n by = b[1],\n bz = b[2],\n bw = b[3];\n out[0] = ax * bw + aw * bx + ay * bz - az * by;\n out[1] = ay * bw + aw * by + az * bx - ax * bz;\n out[2] = az * bw + aw * bz + ax * by - ay * bx;\n out[3] = aw * bw - ax * bx - ay * by - az * bz;\n return out;\n}\n/**\n * Rotates a quaternion by the given angle about the X axis\n *\n * @param {quat} out quat receiving operation result\n * @param {ReadonlyQuat} a quat to rotate\n * @param {number} rad angle (in radians) to rotate\n * @returns {quat} out\n */\n\nexport function rotateX(out, a, rad) {\n rad *= 0.5;\n var ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n var bx = Math.sin(rad),\n bw = Math.cos(rad);\n out[0] = ax * bw + aw * bx;\n out[1] = ay * bw + az * bx;\n out[2] = az * bw - ay * bx;\n out[3] = aw * bw - ax * bx;\n return out;\n}\n/**\n * Rotates a quaternion by the given angle about the Y axis\n *\n * @param {quat} out quat receiving operation result\n * @param {ReadonlyQuat} a quat to rotate\n * @param {number} rad angle (in radians) to rotate\n * @returns {quat} out\n */\n\nexport function rotateY(out, a, rad) {\n rad *= 0.5;\n var ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n var by = Math.sin(rad),\n bw = Math.cos(rad);\n out[0] = ax * bw - az * by;\n out[1] = ay * bw + aw * by;\n out[2] = az * bw + ax * by;\n out[3] = aw * bw - ay * by;\n return out;\n}\n/**\n * Rotates a quaternion by the given angle about the Z axis\n *\n * @param {quat} out quat receiving operation result\n * @param {ReadonlyQuat} a quat to rotate\n * @param {number} rad angle (in radians) to rotate\n * @returns {quat} out\n */\n\nexport function rotateZ(out, a, rad) {\n rad *= 0.5;\n var ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n var bz = Math.sin(rad),\n bw = Math.cos(rad);\n out[0] = ax * bw + ay * bz;\n out[1] = ay * bw - ax * bz;\n out[2] = az * bw + aw * bz;\n out[3] = aw * bw - az * bz;\n return out;\n}\n/**\n * Calculates the W component of a quat from the X, Y, and Z components.\n * Assumes that quaternion is 1 unit in length.\n * Any existing W component will be ignored.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quat to calculate W component of\n * @returns {quat} out\n */\n\nexport function calculateW(out, a) {\n var x = a[0],\n y = a[1],\n z = a[2];\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));\n return out;\n}\n/**\n * Calculate the exponential of a unit quaternion.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quat to calculate the exponential of\n * @returns {quat} out\n */\n\nexport function exp(out, a) {\n var x = a[0],\n y = a[1],\n z = a[2],\n w = a[3];\n var r = Math.sqrt(x * x + y * y + z * z);\n var et = Math.exp(w);\n var s = r > 0 ? et * Math.sin(r) / r : 0;\n out[0] = x * s;\n out[1] = y * s;\n out[2] = z * s;\n out[3] = et * Math.cos(r);\n return out;\n}\n/**\n * Calculate the natural logarithm of a unit quaternion.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quat to calculate the exponential of\n * @returns {quat} out\n */\n\nexport function ln(out, a) {\n var x = a[0],\n y = a[1],\n z = a[2],\n w = a[3];\n var r = Math.sqrt(x * x + y * y + z * z);\n var t = r > 0 ? Math.atan2(r, w) / r : 0;\n out[0] = x * t;\n out[1] = y * t;\n out[2] = z * t;\n out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w);\n return out;\n}\n/**\n * Calculate the scalar power of a unit quaternion.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quat to calculate the exponential of\n * @param {Number} b amount to scale the quaternion by\n * @returns {quat} out\n */\n\nexport function pow(out, a, b) {\n ln(out, a);\n scale(out, out, b);\n exp(out, out);\n return out;\n}\n/**\n * Performs a spherical linear interpolation between two quat\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a the first operand\n * @param {ReadonlyQuat} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat} out\n */\n\nexport function slerp(out, a, b, t) {\n // benchmarks:\n // http://jsperf.com/quaternion-slerp-implementations\n var ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n var bx = b[0],\n by = b[1],\n bz = b[2],\n bw = b[3];\n var omega, cosom, sinom, scale0, scale1; // calc cosine\n\n cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)\n\n if (cosom < 0.0) {\n cosom = -cosom;\n bx = -bx;\n by = -by;\n bz = -bz;\n bw = -bw;\n } // calculate coefficients\n\n\n if (1.0 - cosom > glMatrix.EPSILON) {\n // standard case (slerp)\n omega = Math.acos(cosom);\n sinom = Math.sin(omega);\n scale0 = Math.sin((1.0 - t) * omega) / sinom;\n scale1 = Math.sin(t * omega) / sinom;\n } else {\n // \"from\" and \"to\" quaternions are very close\n // ... so we can do a linear interpolation\n scale0 = 1.0 - t;\n scale1 = t;\n } // calculate final values\n\n\n out[0] = scale0 * ax + scale1 * bx;\n out[1] = scale0 * ay + scale1 * by;\n out[2] = scale0 * az + scale1 * bz;\n out[3] = scale0 * aw + scale1 * bw;\n return out;\n}\n/**\n * Generates a random unit quaternion\n *\n * @param {quat} out the receiving quaternion\n * @returns {quat} out\n */\n\nexport function random(out) {\n // Implementation of http://planning.cs.uiuc.edu/node198.html\n // TODO: Calling random 3 times is probably not the fastest solution\n var u1 = glMatrix.RANDOM();\n var u2 = glMatrix.RANDOM();\n var u3 = glMatrix.RANDOM();\n var sqrt1MinusU1 = Math.sqrt(1 - u1);\n var sqrtU1 = Math.sqrt(u1);\n out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2);\n out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2);\n out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3);\n out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3);\n return out;\n}\n/**\n * Calculates the inverse of a quat\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quat to calculate inverse of\n * @returns {quat} out\n */\n\nexport function invert(out, a) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;\n var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0\n\n out[0] = -a0 * invDot;\n out[1] = -a1 * invDot;\n out[2] = -a2 * invDot;\n out[3] = a3 * invDot;\n return out;\n}\n/**\n * Calculates the conjugate of a quat\n * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quat to calculate conjugate of\n * @returns {quat} out\n */\n\nexport function conjugate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Creates a quaternion from the given 3x3 rotation matrix.\n *\n * NOTE: The resultant quaternion is not normalized, so you should be sure\n * to renormalize the quaternion yourself where necessary.\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyMat3} m rotation matrix\n * @returns {quat} out\n * @function\n */\n\nexport function fromMat3(out, m) {\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n // article \"Quaternion Calculus and Fast Animation\".\n var fTrace = m[0] + m[4] + m[8];\n var fRoot;\n\n if (fTrace > 0.0) {\n // |w| > 1/2, may as well choose w > 1/2\n fRoot = Math.sqrt(fTrace + 1.0); // 2w\n\n out[3] = 0.5 * fRoot;\n fRoot = 0.5 / fRoot; // 1/(4w)\n\n out[0] = (m[5] - m[7]) * fRoot;\n out[1] = (m[6] - m[2]) * fRoot;\n out[2] = (m[1] - m[3]) * fRoot;\n } else {\n // |w| <= 1/2\n var i = 0;\n if (m[4] > m[0]) i = 1;\n if (m[8] > m[i * 3 + i]) i = 2;\n var j = (i + 1) % 3;\n var k = (i + 2) % 3;\n fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);\n out[i] = 0.5 * fRoot;\n fRoot = 0.5 / fRoot;\n out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;\n out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;\n out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;\n }\n\n return out;\n}\n/**\n * Creates a quaternion from the given euler angle x, y, z.\n *\n * @param {quat} out the receiving quaternion\n * @param {x} Angle to rotate around X axis in degrees.\n * @param {y} Angle to rotate around Y axis in degrees.\n * @param {z} Angle to rotate around Z axis in degrees.\n * @returns {quat} out\n * @function\n */\n\nexport function fromEuler(out, x, y, z) {\n var halfToRad = 0.5 * Math.PI / 180.0;\n x *= halfToRad;\n y *= halfToRad;\n z *= halfToRad;\n var sx = Math.sin(x);\n var cx = Math.cos(x);\n var sy = Math.sin(y);\n var cy = Math.cos(y);\n var sz = Math.sin(z);\n var cz = Math.cos(z);\n out[0] = sx * cy * cz - cx * sy * sz;\n out[1] = cx * sy * cz + sx * cy * sz;\n out[2] = cx * cy * sz - sx * sy * cz;\n out[3] = cx * cy * cz + sx * sy * sz;\n return out;\n}\n/**\n * Returns a string representation of a quatenion\n *\n * @param {ReadonlyQuat} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"quat(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Creates a new quat initialized with values from an existing quaternion\n *\n * @param {ReadonlyQuat} a quaternion to clone\n * @returns {quat} a new quaternion\n * @function\n */\n\nexport var clone = vec4.clone;\n/**\n * Creates a new quat initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {quat} a new quaternion\n * @function\n */\n\nexport var fromValues = vec4.fromValues;\n/**\n * Copy the values from one quat to another\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a the source quaternion\n * @returns {quat} out\n * @function\n */\n\nexport var copy = vec4.copy;\n/**\n * Set the components of a quat to the given values\n *\n * @param {quat} out the receiving quaternion\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {quat} out\n * @function\n */\n\nexport var set = vec4.set;\n/**\n * Adds two quat's\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a the first operand\n * @param {ReadonlyQuat} b the second operand\n * @returns {quat} out\n * @function\n */\n\nexport var add = vec4.add;\n/**\n * Alias for {@link quat.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Scales a quat by a scalar number\n *\n * @param {quat} out the receiving vector\n * @param {ReadonlyQuat} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {quat} out\n * @function\n */\n\nexport var scale = vec4.scale;\n/**\n * Calculates the dot product of two quat's\n *\n * @param {ReadonlyQuat} a the first operand\n * @param {ReadonlyQuat} b the second operand\n * @returns {Number} dot product of a and b\n * @function\n */\n\nexport var dot = vec4.dot;\n/**\n * Performs a linear interpolation between two quat's\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a the first operand\n * @param {ReadonlyQuat} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat} out\n * @function\n */\n\nexport var lerp = vec4.lerp;\n/**\n * Calculates the length of a quat\n *\n * @param {ReadonlyQuat} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport var length = vec4.length;\n/**\n * Alias for {@link quat.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Calculates the squared length of a quat\n *\n * @param {ReadonlyQuat} a vector to calculate squared length of\n * @returns {Number} squared length of a\n * @function\n */\n\nexport var squaredLength = vec4.squaredLength;\n/**\n * Alias for {@link quat.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Normalize a quat\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a quaternion to normalize\n * @returns {quat} out\n * @function\n */\n\nexport var normalize = vec4.normalize;\n/**\n * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyQuat} a The first quaternion.\n * @param {ReadonlyQuat} b The second quaternion.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport var exactEquals = vec4.exactEquals;\n/**\n * Returns whether or not the quaternions have approximately the same elements in the same position.\n *\n * @param {ReadonlyQuat} a The first vector.\n * @param {ReadonlyQuat} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport var equals = vec4.equals;\n/**\n * Sets a quaternion to represent the shortest rotation from one\n * vector to another.\n *\n * Both vectors are assumed to be unit length.\n *\n * @param {quat} out the receiving quaternion.\n * @param {ReadonlyVec3} a the initial vector\n * @param {ReadonlyVec3} b the destination vector\n * @returns {quat} out\n */\n\nexport var rotationTo = function () {\n var tmpvec3 = vec3.create();\n var xUnitVec3 = vec3.fromValues(1, 0, 0);\n var yUnitVec3 = vec3.fromValues(0, 1, 0);\n return function (out, a, b) {\n var dot = vec3.dot(a, b);\n\n if (dot < -0.999999) {\n vec3.cross(tmpvec3, xUnitVec3, a);\n if (vec3.len(tmpvec3) < 0.000001) vec3.cross(tmpvec3, yUnitVec3, a);\n vec3.normalize(tmpvec3, tmpvec3);\n setAxisAngle(out, tmpvec3, Math.PI);\n return out;\n } else if (dot > 0.999999) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n } else {\n vec3.cross(tmpvec3, a, b);\n out[0] = tmpvec3[0];\n out[1] = tmpvec3[1];\n out[2] = tmpvec3[2];\n out[3] = 1 + dot;\n return normalize(out, out);\n }\n };\n}();\n/**\n * Performs a spherical linear interpolation with two control points\n *\n * @param {quat} out the receiving quaternion\n * @param {ReadonlyQuat} a the first operand\n * @param {ReadonlyQuat} b the second operand\n * @param {ReadonlyQuat} c the third operand\n * @param {ReadonlyQuat} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat} out\n */\n\nexport var sqlerp = function () {\n var temp1 = create();\n var temp2 = create();\n return function (out, a, b, c, d, t) {\n slerp(temp1, a, d, t);\n slerp(temp2, b, c, t);\n slerp(out, temp1, temp2, 2 * t * (1 - t));\n return out;\n };\n}();\n/**\n * Sets the specified quaternion with values corresponding to the given\n * axes. Each axis is a vec3 and is expected to be unit length and\n * perpendicular to all other specified axes.\n *\n * @param {ReadonlyVec3} view the vector representing the viewing direction\n * @param {ReadonlyVec3} right the vector representing the local \"right\" direction\n * @param {ReadonlyVec3} up the vector representing the local \"up\" direction\n * @returns {quat} out\n */\n\nexport var setAxes = function () {\n var matr = mat3.create();\n return function (out, view, right, up) {\n matr[0] = right[0];\n matr[3] = right[1];\n matr[6] = right[2];\n matr[1] = up[0];\n matr[4] = up[1];\n matr[7] = up[2];\n matr[2] = -view[0];\n matr[5] = -view[1];\n matr[8] = -view[2];\n return normalize(out, fromMat3(out, matr));\n };\n}();","import * as glMatrix from \"./common.js\";\nimport * as quat from \"./quat.js\";\nimport * as mat4 from \"./mat4.js\";\n/**\n * Dual Quaternion
\n * Format: [real, dual]
\n * Quaternion format: XYZW
\n * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.
\n * @module quat2\n */\n\n/**\n * Creates a new identity dual quat\n *\n * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation]\n */\n\nexport function create() {\n var dq = new glMatrix.ARRAY_TYPE(8);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n dq[0] = 0;\n dq[1] = 0;\n dq[2] = 0;\n dq[4] = 0;\n dq[5] = 0;\n dq[6] = 0;\n dq[7] = 0;\n }\n\n dq[3] = 1;\n return dq;\n}\n/**\n * Creates a new quat initialized with values from an existing quaternion\n *\n * @param {ReadonlyQuat2} a dual quaternion to clone\n * @returns {quat2} new dual quaternion\n * @function\n */\n\nexport function clone(a) {\n var dq = new glMatrix.ARRAY_TYPE(8);\n dq[0] = a[0];\n dq[1] = a[1];\n dq[2] = a[2];\n dq[3] = a[3];\n dq[4] = a[4];\n dq[5] = a[5];\n dq[6] = a[6];\n dq[7] = a[7];\n return dq;\n}\n/**\n * Creates a new dual quat initialized with the given values\n *\n * @param {Number} x1 X component\n * @param {Number} y1 Y component\n * @param {Number} z1 Z component\n * @param {Number} w1 W component\n * @param {Number} x2 X component\n * @param {Number} y2 Y component\n * @param {Number} z2 Z component\n * @param {Number} w2 W component\n * @returns {quat2} new dual quaternion\n * @function\n */\n\nexport function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) {\n var dq = new glMatrix.ARRAY_TYPE(8);\n dq[0] = x1;\n dq[1] = y1;\n dq[2] = z1;\n dq[3] = w1;\n dq[4] = x2;\n dq[5] = y2;\n dq[6] = z2;\n dq[7] = w2;\n return dq;\n}\n/**\n * Creates a new dual quat from the given values (quat and translation)\n *\n * @param {Number} x1 X component\n * @param {Number} y1 Y component\n * @param {Number} z1 Z component\n * @param {Number} w1 W component\n * @param {Number} x2 X component (translation)\n * @param {Number} y2 Y component (translation)\n * @param {Number} z2 Z component (translation)\n * @returns {quat2} new dual quaternion\n * @function\n */\n\nexport function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) {\n var dq = new glMatrix.ARRAY_TYPE(8);\n dq[0] = x1;\n dq[1] = y1;\n dq[2] = z1;\n dq[3] = w1;\n var ax = x2 * 0.5,\n ay = y2 * 0.5,\n az = z2 * 0.5;\n dq[4] = ax * w1 + ay * z1 - az * y1;\n dq[5] = ay * w1 + az * x1 - ax * z1;\n dq[6] = az * w1 + ax * y1 - ay * x1;\n dq[7] = -ax * x1 - ay * y1 - az * z1;\n return dq;\n}\n/**\n * Creates a dual quat from a quaternion and a translation\n *\n * @param {ReadonlyQuat2} dual quaternion receiving operation result\n * @param {ReadonlyQuat} q a normalized quaternion\n * @param {ReadonlyVec3} t tranlation vector\n * @returns {quat2} dual quaternion receiving operation result\n * @function\n */\n\nexport function fromRotationTranslation(out, q, t) {\n var ax = t[0] * 0.5,\n ay = t[1] * 0.5,\n az = t[2] * 0.5,\n bx = q[0],\n by = q[1],\n bz = q[2],\n bw = q[3];\n out[0] = bx;\n out[1] = by;\n out[2] = bz;\n out[3] = bw;\n out[4] = ax * bw + ay * bz - az * by;\n out[5] = ay * bw + az * bx - ax * bz;\n out[6] = az * bw + ax * by - ay * bx;\n out[7] = -ax * bx - ay * by - az * bz;\n return out;\n}\n/**\n * Creates a dual quat from a translation\n *\n * @param {ReadonlyQuat2} dual quaternion receiving operation result\n * @param {ReadonlyVec3} t translation vector\n * @returns {quat2} dual quaternion receiving operation result\n * @function\n */\n\nexport function fromTranslation(out, t) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = t[0] * 0.5;\n out[5] = t[1] * 0.5;\n out[6] = t[2] * 0.5;\n out[7] = 0;\n return out;\n}\n/**\n * Creates a dual quat from a quaternion\n *\n * @param {ReadonlyQuat2} dual quaternion receiving operation result\n * @param {ReadonlyQuat} q the quaternion\n * @returns {quat2} dual quaternion receiving operation result\n * @function\n */\n\nexport function fromRotation(out, q) {\n out[0] = q[0];\n out[1] = q[1];\n out[2] = q[2];\n out[3] = q[3];\n out[4] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n return out;\n}\n/**\n * Creates a new dual quat from a matrix (4x4)\n *\n * @param {quat2} out the dual quaternion\n * @param {ReadonlyMat4} a the matrix\n * @returns {quat2} dual quat receiving operation result\n * @function\n */\n\nexport function fromMat4(out, a) {\n //TODO Optimize this\n var outer = quat.create();\n mat4.getRotation(outer, a);\n var t = new glMatrix.ARRAY_TYPE(3);\n mat4.getTranslation(t, a);\n fromRotationTranslation(out, outer, t);\n return out;\n}\n/**\n * Copy the values from one dual quat to another\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the source dual quaternion\n * @returns {quat2} out\n * @function\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n return out;\n}\n/**\n * Set a dual quat to the identity dual quaternion\n *\n * @param {quat2} out the receiving quaternion\n * @returns {quat2} out\n */\n\nexport function identity(out) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n out[4] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n return out;\n}\n/**\n * Set the components of a dual quat to the given values\n *\n * @param {quat2} out the receiving quaternion\n * @param {Number} x1 X component\n * @param {Number} y1 Y component\n * @param {Number} z1 Z component\n * @param {Number} w1 W component\n * @param {Number} x2 X component\n * @param {Number} y2 Y component\n * @param {Number} z2 Z component\n * @param {Number} w2 W component\n * @returns {quat2} out\n * @function\n */\n\nexport function set(out, x1, y1, z1, w1, x2, y2, z2, w2) {\n out[0] = x1;\n out[1] = y1;\n out[2] = z1;\n out[3] = w1;\n out[4] = x2;\n out[5] = y2;\n out[6] = z2;\n out[7] = w2;\n return out;\n}\n/**\n * Gets the real part of a dual quat\n * @param {quat} out real part\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @return {quat} real part\n */\n\nexport var getReal = quat.copy;\n/**\n * Gets the dual part of a dual quat\n * @param {quat} out dual part\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @return {quat} dual part\n */\n\nexport function getDual(out, a) {\n out[0] = a[4];\n out[1] = a[5];\n out[2] = a[6];\n out[3] = a[7];\n return out;\n}\n/**\n * Set the real component of a dual quat to the given quaternion\n *\n * @param {quat2} out the receiving quaternion\n * @param {ReadonlyQuat} q a quaternion representing the real part\n * @returns {quat2} out\n * @function\n */\n\nexport var setReal = quat.copy;\n/**\n * Set the dual component of a dual quat to the given quaternion\n *\n * @param {quat2} out the receiving quaternion\n * @param {ReadonlyQuat} q a quaternion representing the dual part\n * @returns {quat2} out\n * @function\n */\n\nexport function setDual(out, q) {\n out[4] = q[0];\n out[5] = q[1];\n out[6] = q[2];\n out[7] = q[3];\n return out;\n}\n/**\n * Gets the translation of a normalized dual quat\n * @param {vec3} out translation\n * @param {ReadonlyQuat2} a Dual Quaternion to be decomposed\n * @return {vec3} translation\n */\n\nexport function getTranslation(out, a) {\n var ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3];\n out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n return out;\n}\n/**\n * Translates a dual quat by the given vector\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the dual quaternion to translate\n * @param {ReadonlyVec3} v vector to translate by\n * @returns {quat2} out\n */\n\nexport function translate(out, a, v) {\n var ax1 = a[0],\n ay1 = a[1],\n az1 = a[2],\n aw1 = a[3],\n bx1 = v[0] * 0.5,\n by1 = v[1] * 0.5,\n bz1 = v[2] * 0.5,\n ax2 = a[4],\n ay2 = a[5],\n az2 = a[6],\n aw2 = a[7];\n out[0] = ax1;\n out[1] = ay1;\n out[2] = az1;\n out[3] = aw1;\n out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2;\n out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2;\n out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2;\n out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2;\n return out;\n}\n/**\n * Rotates a dual quat around the X axis\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the dual quaternion to rotate\n * @param {number} rad how far should the rotation be\n * @returns {quat2} out\n */\n\nexport function rotateX(out, a, rad) {\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\n az1 = az * bw + aw * bz + ax * by - ay * bx,\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\n quat.rotateX(out, a, rad);\n bx = out[0];\n by = out[1];\n bz = out[2];\n bw = out[3];\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n return out;\n}\n/**\n * Rotates a dual quat around the Y axis\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the dual quaternion to rotate\n * @param {number} rad how far should the rotation be\n * @returns {quat2} out\n */\n\nexport function rotateY(out, a, rad) {\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\n az1 = az * bw + aw * bz + ax * by - ay * bx,\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\n quat.rotateY(out, a, rad);\n bx = out[0];\n by = out[1];\n bz = out[2];\n bw = out[3];\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n return out;\n}\n/**\n * Rotates a dual quat around the Z axis\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the dual quaternion to rotate\n * @param {number} rad how far should the rotation be\n * @returns {quat2} out\n */\n\nexport function rotateZ(out, a, rad) {\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7],\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\n az1 = az * bw + aw * bz + ax * by - ay * bx,\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\n quat.rotateZ(out, a, rad);\n bx = out[0];\n by = out[1];\n bz = out[2];\n bw = out[3];\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n return out;\n}\n/**\n * Rotates a dual quat by a given quaternion (a * q)\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the dual quaternion to rotate\n * @param {ReadonlyQuat} q quaternion to rotate by\n * @returns {quat2} out\n */\n\nexport function rotateByQuatAppend(out, a, q) {\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3],\n ax = a[0],\n ay = a[1],\n az = a[2],\n aw = a[3];\n out[0] = ax * qw + aw * qx + ay * qz - az * qy;\n out[1] = ay * qw + aw * qy + az * qx - ax * qz;\n out[2] = az * qw + aw * qz + ax * qy - ay * qx;\n out[3] = aw * qw - ax * qx - ay * qy - az * qz;\n ax = a[4];\n ay = a[5];\n az = a[6];\n aw = a[7];\n out[4] = ax * qw + aw * qx + ay * qz - az * qy;\n out[5] = ay * qw + aw * qy + az * qx - ax * qz;\n out[6] = az * qw + aw * qz + ax * qy - ay * qx;\n out[7] = aw * qw - ax * qx - ay * qy - az * qz;\n return out;\n}\n/**\n * Rotates a dual quat by a given quaternion (q * a)\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat} q quaternion to rotate by\n * @param {ReadonlyQuat2} a the dual quaternion to rotate\n * @returns {quat2} out\n */\n\nexport function rotateByQuatPrepend(out, q, a) {\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3],\n bx = a[0],\n by = a[1],\n bz = a[2],\n bw = a[3];\n out[0] = qx * bw + qw * bx + qy * bz - qz * by;\n out[1] = qy * bw + qw * by + qz * bx - qx * bz;\n out[2] = qz * bw + qw * bz + qx * by - qy * bx;\n out[3] = qw * bw - qx * bx - qy * by - qz * bz;\n bx = a[4];\n by = a[5];\n bz = a[6];\n bw = a[7];\n out[4] = qx * bw + qw * bx + qy * bz - qz * by;\n out[5] = qy * bw + qw * by + qz * bx - qx * bz;\n out[6] = qz * bw + qw * bz + qx * by - qy * bx;\n out[7] = qw * bw - qx * bx - qy * by - qz * bz;\n return out;\n}\n/**\n * Rotates a dual quat around a given axis. Does the normalisation automatically\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the dual quaternion to rotate\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @param {Number} rad how far the rotation should be\n * @returns {quat2} out\n */\n\nexport function rotateAroundAxis(out, a, axis, rad) {\n //Special case for rad = 0\n if (Math.abs(rad) < glMatrix.EPSILON) {\n return copy(out, a);\n }\n\n var axisLength = Math.hypot(axis[0], axis[1], axis[2]);\n rad = rad * 0.5;\n var s = Math.sin(rad);\n var bx = s * axis[0] / axisLength;\n var by = s * axis[1] / axisLength;\n var bz = s * axis[2] / axisLength;\n var bw = Math.cos(rad);\n var ax1 = a[0],\n ay1 = a[1],\n az1 = a[2],\n aw1 = a[3];\n out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\n out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\n out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\n out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\n var ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7];\n out[4] = ax * bw + aw * bx + ay * bz - az * by;\n out[5] = ay * bw + aw * by + az * bx - ax * bz;\n out[6] = az * bw + aw * bz + ax * by - ay * bx;\n out[7] = aw * bw - ax * bx - ay * by - az * bz;\n return out;\n}\n/**\n * Adds two dual quat's\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the first operand\n * @param {ReadonlyQuat2} b the second operand\n * @returns {quat2} out\n * @function\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n return out;\n}\n/**\n * Multiplies two dual quat's\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a the first operand\n * @param {ReadonlyQuat2} b the second operand\n * @returns {quat2} out\n */\n\nexport function multiply(out, a, b) {\n var ax0 = a[0],\n ay0 = a[1],\n az0 = a[2],\n aw0 = a[3],\n bx1 = b[4],\n by1 = b[5],\n bz1 = b[6],\n bw1 = b[7],\n ax1 = a[4],\n ay1 = a[5],\n az1 = a[6],\n aw1 = a[7],\n bx0 = b[0],\n by0 = b[1],\n bz0 = b[2],\n bw0 = b[3];\n out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0;\n out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;\n out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0;\n out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0;\n out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0;\n out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0;\n out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0;\n out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0;\n return out;\n}\n/**\n * Alias for {@link quat2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Scales a dual quat by a scalar number\n *\n * @param {quat2} out the receiving dual quat\n * @param {ReadonlyQuat2} a the dual quat to scale\n * @param {Number} b amount to scale the dual quat by\n * @returns {quat2} out\n * @function\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n return out;\n}\n/**\n * Calculates the dot product of two dual quat's (The dot product of the real parts)\n *\n * @param {ReadonlyQuat2} a the first operand\n * @param {ReadonlyQuat2} b the second operand\n * @returns {Number} dot product of a and b\n * @function\n */\n\nexport var dot = quat.dot;\n/**\n * Performs a linear interpolation between two dual quats's\n * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5)\n *\n * @param {quat2} out the receiving dual quat\n * @param {ReadonlyQuat2} a the first operand\n * @param {ReadonlyQuat2} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {quat2} out\n */\n\nexport function lerp(out, a, b, t) {\n var mt = 1 - t;\n if (dot(a, b) < 0) t = -t;\n out[0] = a[0] * mt + b[0] * t;\n out[1] = a[1] * mt + b[1] * t;\n out[2] = a[2] * mt + b[2] * t;\n out[3] = a[3] * mt + b[3] * t;\n out[4] = a[4] * mt + b[4] * t;\n out[5] = a[5] * mt + b[5] * t;\n out[6] = a[6] * mt + b[6] * t;\n out[7] = a[7] * mt + b[7] * t;\n return out;\n}\n/**\n * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a dual quat to calculate inverse of\n * @returns {quat2} out\n */\n\nexport function invert(out, a) {\n var sqlen = squaredLength(a);\n out[0] = -a[0] / sqlen;\n out[1] = -a[1] / sqlen;\n out[2] = -a[2] / sqlen;\n out[3] = a[3] / sqlen;\n out[4] = -a[4] / sqlen;\n out[5] = -a[5] / sqlen;\n out[6] = -a[6] / sqlen;\n out[7] = a[7] / sqlen;\n return out;\n}\n/**\n * Calculates the conjugate of a dual quat\n * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result.\n *\n * @param {quat2} out the receiving quaternion\n * @param {ReadonlyQuat2} a quat to calculate conjugate of\n * @returns {quat2} out\n */\n\nexport function conjugate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a[3];\n out[4] = -a[4];\n out[5] = -a[5];\n out[6] = -a[6];\n out[7] = a[7];\n return out;\n}\n/**\n * Calculates the length of a dual quat\n *\n * @param {ReadonlyQuat2} a dual quat to calculate length of\n * @returns {Number} length of a\n * @function\n */\n\nexport var length = quat.length;\n/**\n * Alias for {@link quat2.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Calculates the squared length of a dual quat\n *\n * @param {ReadonlyQuat2} a dual quat to calculate squared length of\n * @returns {Number} squared length of a\n * @function\n */\n\nexport var squaredLength = quat.squaredLength;\n/**\n * Alias for {@link quat2.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Normalize a dual quat\n *\n * @param {quat2} out the receiving dual quaternion\n * @param {ReadonlyQuat2} a dual quaternion to normalize\n * @returns {quat2} out\n * @function\n */\n\nexport function normalize(out, a) {\n var magnitude = squaredLength(a);\n\n if (magnitude > 0) {\n magnitude = Math.sqrt(magnitude);\n var a0 = a[0] / magnitude;\n var a1 = a[1] / magnitude;\n var a2 = a[2] / magnitude;\n var a3 = a[3] / magnitude;\n var b0 = a[4];\n var b1 = a[5];\n var b2 = a[6];\n var b3 = a[7];\n var a_dot_b = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3;\n out[0] = a0;\n out[1] = a1;\n out[2] = a2;\n out[3] = a3;\n out[4] = (b0 - a0 * a_dot_b) / magnitude;\n out[5] = (b1 - a1 * a_dot_b) / magnitude;\n out[6] = (b2 - a2 * a_dot_b) / magnitude;\n out[7] = (b3 - a3 * a_dot_b) / magnitude;\n }\n\n return out;\n}\n/**\n * Returns a string representation of a dual quatenion\n *\n * @param {ReadonlyQuat2} a dual quaternion to represent as a string\n * @returns {String} string representation of the dual quat\n */\n\nexport function str(a) {\n return \"quat2(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \")\";\n}\n/**\n * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyQuat2} a the first dual quaternion.\n * @param {ReadonlyQuat2} b the second dual quaternion.\n * @returns {Boolean} true if the dual quaternions are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7];\n}\n/**\n * Returns whether or not the dual quaternions have approximately the same elements in the same position.\n *\n * @param {ReadonlyQuat2} a the first dual quat.\n * @param {ReadonlyQuat2} b the second dual quat.\n * @returns {Boolean} true if the dual quats are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7));\n}","import * as glMatrix from \"./common.js\";\n/**\n * 2 Dimensional Vector\n * @module vec2\n */\n\n/**\n * Creates a new, empty vec2\n *\n * @returns {vec2} a new 2D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(2);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec2 initialized with values from an existing vector\n *\n * @param {ReadonlyVec2} a vector to clone\n * @returns {vec2} a new 2D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(2);\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n/**\n * Creates a new vec2 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} a new 2D vector\n */\n\nexport function fromValues(x, y) {\n var out = new glMatrix.ARRAY_TYPE(2);\n out[0] = x;\n out[1] = y;\n return out;\n}\n/**\n * Copy the values from one vec2 to another\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the source vector\n * @returns {vec2} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n/**\n * Set the components of a vec2 to the given values\n *\n * @param {vec2} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} out\n */\n\nexport function set(out, x, y) {\n out[0] = x;\n out[1] = y;\n return out;\n}\n/**\n * Adds two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n return out;\n}\n/**\n * Multiplies two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n return out;\n}\n/**\n * Divides two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n return out;\n}\n/**\n * Math.ceil the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to ceil\n * @returns {vec2} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n return out;\n}\n/**\n * Math.floor the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to floor\n * @returns {vec2} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n return out;\n}\n/**\n * Returns the minimum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n return out;\n}\n/**\n * Returns the maximum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n return out;\n}\n/**\n * Math.round the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to round\n * @returns {vec2} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n return out;\n}\n/**\n * Scales a vec2 by a scalar number\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec2} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n return out;\n}\n/**\n * Adds two vec2's after scaling the second operand by a scalar value\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec2} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return Math.hypot(x, y);\n}\n/**\n * Calculates the squared euclidian distance between two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return x * x + y * y;\n}\n/**\n * Calculates the length of a vec2\n *\n * @param {ReadonlyVec2} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0],\n y = a[1];\n return Math.hypot(x, y);\n}\n/**\n * Calculates the squared length of a vec2\n *\n * @param {ReadonlyVec2} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0],\n y = a[1];\n return x * x + y * y;\n}\n/**\n * Negates the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to negate\n * @returns {vec2} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to invert\n * @returns {vec2} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n return out;\n}\n/**\n * Normalize a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to normalize\n * @returns {vec2} out\n */\n\nexport function normalize(out, a) {\n var x = a[0],\n y = a[1];\n var len = x * x + y * y;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1];\n}\n/**\n * Computes the cross product of two vec2's\n * Note that the cross product must by definition produce a 3D vector\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var z = a[0] * b[1] - a[1] * b[0];\n out[0] = out[1] = 0;\n out[2] = z;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec2} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0],\n ay = a[1];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec2} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec2} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n out[0] = Math.cos(r) * scale;\n out[1] = Math.sin(r) * scale;\n return out;\n}\n/**\n * Transforms the vec2 with a mat2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat2} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat2(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y;\n out[1] = m[1] * x + m[3] * y;\n return out;\n}\n/**\n * Transforms the vec2 with a mat2d\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat2d} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat2d(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y + m[4];\n out[1] = m[1] * x + m[3] * y + m[5];\n return out;\n}\n/**\n * Transforms the vec2 with a mat3\n * 3rd vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat3} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[3] * y + m[6];\n out[1] = m[1] * x + m[4] * y + m[7];\n return out;\n}\n/**\n * Transforms the vec2 with a mat4\n * 3rd vector component is implicitly '0'\n * 4th vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0];\n var y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n return out;\n}\n/**\n * Rotate a 2D vector\n * @param {vec2} out The receiving vec2\n * @param {ReadonlyVec2} a The vec2 point to rotate\n * @param {ReadonlyVec2} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec2} out\n */\n\nexport function rotate(out, a, b, rad) {\n //Translate point to the origin\n var p0 = a[0] - b[0],\n p1 = a[1] - b[1],\n sinC = Math.sin(rad),\n cosC = Math.cos(rad); //perform rotation and translate to correct position\n\n out[0] = p0 * cosC - p1 * sinC + b[0];\n out[1] = p0 * sinC + p1 * cosC + b[1];\n return out;\n}\n/**\n * Get the angle between two 2D vectors\n * @param {ReadonlyVec2} a The first operand\n * @param {ReadonlyVec2} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var x1 = a[0],\n y1 = a[1],\n x2 = b[0],\n y2 = b[1],\n // mag is the product of the magnitudes of a and b\n mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2),\n // mag &&.. short circuits if mag == 0\n cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1\n\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec2 to zero\n *\n * @param {vec2} out the receiving vector\n * @returns {vec2} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec2} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec2(\" + a[0] + \", \" + a[1] + \")\";\n}\n/**\n * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec2} a The first vector.\n * @param {ReadonlyVec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec2} a The first vector.\n * @param {ReadonlyVec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1];\n var b0 = b[0],\n b1 = b[1];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));\n}\n/**\n * Alias for {@link vec2.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec2.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec2.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec2.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec2.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec2.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec2s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 2;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n }\n\n return a;\n };\n}();","import {StyleLayer} from '../style_layer';\n\nimport {CircleBucket} from '../../data/bucket/circle_bucket';\nimport {polygonIntersectsBufferedPoint} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate} from '../query_utils';\nimport properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../../geo/transform';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties.g';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n/**\n * A style layer that defines a circle\n */\nexport class CircleStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new CircleBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const circleBucket: CircleBucket = (bucket as any);\n return getMaximumPaintValue('circle-radius', this, circleBucket) +\n getMaximumPaintValue('circle-stroke-width', this, circleBucket) +\n translateDistance(this.paint.get('circle-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('circle-translate'),\n this.paint.get('circle-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const radius = this.paint.get('circle-radius').evaluate(feature, featureState);\n const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState);\n const size = radius + stroke;\n\n // For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile\n // // Otherwise, compare geometry in the plane of the viewport\n // // A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance\n // // A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance\n const alignWithMap = this.paint.get('circle-pitch-alignment') === 'map';\n const transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry(translatedPolygon, pixelPosMatrix);\n const transformedSize = alignWithMap ? size * pixelsToTileUnits : size;\n\n for (const ring of geometry) {\n for (const point of ring) {\n\n const transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix);\n\n let adjustedSize = transformedSize;\n const projectedCenter = vec4.transformMat4([] as any, [point.x, point.y, 0, 1], pixelPosMatrix);\n if (this.paint.get('circle-pitch-scale') === 'viewport' && this.paint.get('circle-pitch-alignment') === 'map') {\n adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance;\n } else if (this.paint.get('circle-pitch-scale') === 'map' && this.paint.get('circle-pitch-alignment') === 'viewport') {\n adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3];\n }\n\n if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) return true;\n }\n }\n\n return false;\n }\n}\n\nfunction projectPoint(p: Point, pixelPosMatrix: mat4) {\n const point = vec4.transformMat4([] as any, [p.x, p.y, 0, 1], pixelPosMatrix);\n return new Point(point[0] / point[3], point[1] / point[3]);\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4) {\n return queryGeometry.map((p) => {\n return projectPoint(p, pixelPosMatrix);\n });\n}\n","import {CircleBucket} from './circle_bucket';\nimport {register} from '../../util/web_worker_transfer';\n\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport class HeatmapBucket extends CircleBucket {\n // Needed for flow to accept omit: ['layers'] below, due to\n // https://github.com/facebook/flow/issues/4262\n layers: Array;\n}\n\nregister('HeatmapBucket', HeatmapBucket, {omit: ['layers']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HeatmapPaintProps = {\n \"heatmap-radius\": DataDrivenProperty,\n \"heatmap-weight\": DataDrivenProperty,\n \"heatmap-intensity\": DataConstantProperty,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": DataConstantProperty,\n};\n\nexport type HeatmapPaintPropsPossiblyEvaluated = {\n \"heatmap-radius\": PossiblyEvaluatedPropertyValue,\n \"heatmap-weight\": PossiblyEvaluatedPropertyValue,\n \"heatmap-intensity\": number,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"heatmap-radius\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-radius\"] as any as StylePropertySpecification),\n \"heatmap-weight\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-weight\"] as any as StylePropertySpecification),\n \"heatmap-intensity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-intensity\"] as any as StylePropertySpecification),\n \"heatmap-color\": new ColorRampProperty(styleSpec[\"paint_heatmap\"][\"heatmap-color\"] as any as StylePropertySpecification),\n \"heatmap-opacity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {register} from './web_worker_transfer';\n\nexport type Size = {\n width: number;\n height: number;\n};\n\ntype Point2D = {\n x: number;\n y: number;\n};\n\nfunction createImage(image: any, {\n width,\n height\n}: Size, channels: number, data?: Uint8Array | Uint8ClampedArray) {\n if (!data) {\n data = new Uint8Array(width * height * channels);\n } else if (data instanceof Uint8ClampedArray) {\n data = new Uint8Array(data.buffer);\n } else if (data.length !== width * height * channels) {\n throw new RangeError(`mismatched image size. expected: ${data.length} but got: ${width * height * channels}`);\n }\n image.width = width;\n image.height = height;\n image.data = data;\n return image;\n}\n\nfunction resizeImage(image: any, {\n width,\n height\n}: Size, channels: number) {\n if (width === image.width && height === image.height) {\n return;\n }\n\n const newImage = createImage({}, {width, height}, channels);\n\n copyImage(image, newImage, {x: 0, y: 0}, {x: 0, y: 0}, {\n width: Math.min(image.width, width),\n height: Math.min(image.height, height)\n }, channels);\n\n image.width = width;\n image.height = height;\n image.data = newImage.data;\n}\n\nfunction copyImage(srcImg: any, dstImg: any, srcPt: Point2D, dstPt: Point2D, size: Size, channels: number) {\n if (size.width === 0 || size.height === 0) {\n return dstImg;\n }\n\n if (size.width > srcImg.width ||\n size.height > srcImg.height ||\n srcPt.x > srcImg.width - size.width ||\n srcPt.y > srcImg.height - size.height) {\n throw new RangeError('out of range source coordinates for image copy');\n }\n\n if (size.width > dstImg.width ||\n size.height > dstImg.height ||\n dstPt.x > dstImg.width - size.width ||\n dstPt.y > dstImg.height - size.height) {\n throw new RangeError('out of range destination coordinates for image copy');\n }\n\n const srcData = srcImg.data;\n const dstData = dstImg.data;\n\n if (srcData === dstData) throw new Error('srcData equals dstData, so image is already copied');\n\n for (let y = 0; y < size.height; y++) {\n const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels;\n const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels;\n for (let i = 0; i < size.width * channels; i++) {\n dstData[dstOffset + i] = srcData[srcOffset + i];\n }\n }\n return dstImg;\n}\n\n/**\n * @internal\n * An image with alpha color value\n */\nexport class AlphaImage {\n width: number;\n height: number;\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 1, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 1);\n }\n\n clone() {\n return new AlphaImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 1);\n }\n}\n\n/**\n * An object to store image data not premultiplied, because ImageData is not premultiplied.\n * UNPACK_PREMULTIPLY_ALPHA_WEBGL must be used when uploading to a texture.\n */\nexport class RGBAImage {\n width: number;\n height: number;\n\n /**\n * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers.\n */\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 4, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 4);\n }\n\n replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean) {\n if (copy) {\n this.data.set(data);\n } else if (data instanceof Uint8ClampedArray) {\n this.data = new Uint8Array(data.buffer);\n } else {\n this.data = data;\n }\n }\n\n clone() {\n return new RGBAImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 4);\n }\n}\n\nregister('AlphaImage', AlphaImage);\nregister('RGBAImage', RGBAImage);\n","import {RGBAImage} from './image';\nimport {isPowerOfTwo} from './util';\n\nimport type {StylePropertyExpression} from '@maplibre/maplibre-gl-style-spec';\n\nexport type ColorRampParams = {\n expression: StylePropertyExpression;\n evaluationKey: string;\n resolution?: number;\n image?: RGBAImage;\n clips?: Array;\n};\n\n/**\n * Given an expression that should evaluate to a color ramp,\n * return a RGBA image representing that ramp expression.\n */\nexport function renderColorRamp(params: ColorRampParams): RGBAImage {\n const evaluationGlobals = {};\n const width = params.resolution || 256;\n const height = params.clips ? params.clips.length : 1;\n const image = params.image || new RGBAImage({width, height});\n\n if (!isPowerOfTwo(width)) throw new Error(`width is not a power of 2 - ${width}`);\n\n const renderPixel = (stride, index, progress) => {\n evaluationGlobals[params.evaluationKey] = progress;\n const pxColor = params.expression.evaluate(evaluationGlobals as any);\n // the colors are being unpremultiplied because Color uses\n // premultiplied values, and the Texture class expects unpremultiplied ones\n image.data[stride + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a);\n image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a);\n image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a);\n image.data[stride + index + 3] = Math.floor(pxColor.a * 255);\n };\n\n if (!params.clips) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n const progress = i / (width - 1);\n\n renderPixel(0, j, progress);\n }\n } else {\n for (let clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n // Remap progress between clips\n const progress = i / (width - 1);\n const {start, end} = params.clips[clip];\n const evaluationProgress = start * (1 - progress) + end * progress;\n renderPixel(stride, j, evaluationProgress);\n }\n }\n }\n\n return image;\n}\n","import {StyleLayer} from '../style_layer';\n\nimport {HeatmapBucket} from '../../data/bucket/heatmap_bucket';\nimport {RGBAImage} from '../../util/image';\nimport properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties.g';\nimport {renderColorRamp} from '../../util/color_ramp';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {Texture} from '../../render/texture';\nimport type {Framebuffer} from '../../gl/framebuffer';\nimport type {HeatmapPaintProps} from './heatmap_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A style layer that defines a heatmap\n */\nexport class HeatmapStyleLayer extends StyleLayer {\n\n heatmapFbo: Framebuffer;\n colorRamp: RGBAImage;\n colorRampTexture: Texture;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n createBucket(options: any) {\n return new HeatmapBucket(options);\n }\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n\n // make sure color ramp texture is generated for default heatmap color too\n this._updateColorRamp();\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'heatmap-color') {\n this._updateColorRamp();\n }\n }\n\n _updateColorRamp() {\n const expression = this._transitionablePaint._values['heatmap-color'].value.expression;\n this.colorRamp = renderColorRamp({\n expression,\n evaluationKey: 'heatmapDensity',\n image: this.colorRamp\n });\n this.colorRampTexture = null;\n }\n\n resize() {\n if (this.heatmapFbo) {\n this.heatmapFbo.destroy();\n this.heatmapFbo = null;\n }\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n return false;\n }\n\n hasOffscreenPass() {\n return this.paint.get('heatmap-opacity') !== 0 && this.visibility !== 'none';\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HillshadePaintProps = {\n \"hillshade-illumination-direction\": DataConstantProperty,\n \"hillshade-illumination-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"hillshade-exaggeration\": DataConstantProperty,\n \"hillshade-shadow-color\": DataConstantProperty,\n \"hillshade-highlight-color\": DataConstantProperty,\n \"hillshade-accent-color\": DataConstantProperty,\n};\n\nexport type HillshadePaintPropsPossiblyEvaluated = {\n \"hillshade-illumination-direction\": number,\n \"hillshade-illumination-anchor\": \"map\" | \"viewport\",\n \"hillshade-exaggeration\": number,\n \"hillshade-shadow-color\": Color,\n \"hillshade-highlight-color\": Color,\n \"hillshade-accent-color\": Color,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"hillshade-illumination-direction\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-direction\"] as any as StylePropertySpecification),\n \"hillshade-illumination-anchor\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-anchor\"] as any as StylePropertySpecification),\n \"hillshade-exaggeration\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-exaggeration\"] as any as StylePropertySpecification),\n \"hillshade-shadow-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-shadow-color\"] as any as StylePropertySpecification),\n \"hillshade-highlight-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-highlight-color\"] as any as StylePropertySpecification),\n \"hillshade-accent-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-accent-color\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {HillshadePaintPropsPossiblyEvaluated} from './hillshade_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {HillshadePaintProps} from './hillshade_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class HillshadeStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n hasOffscreenPass() {\n return this.paint.get('hillshade-exaggeration') !== 0 && this.visibility !== 'none';\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nmodule.exports = earcut;\nmodule.exports.default = earcut;\n\nfunction earcut(data, holeIndices, dim) {\n\n dim = dim || 2;\n\n var hasHoles = holeIndices && holeIndices.length,\n outerLen = hasHoles ? holeIndices[0] * dim : data.length,\n outerNode = linkedList(data, 0, outerLen, dim, true),\n triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n var minX, minY, maxX, maxY, x, y, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = maxX = data[0];\n minY = maxY = data[1];\n\n for (var i = dim; i < outerLen; i += dim) {\n x = data[i];\n y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n var i, last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n } else {\n for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n var p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n var stop = ear,\n prev, next;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n prev = ear.prev;\n next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n // cut off the triangle\n triangles.push(prev.i / dim | 0);\n triangles.push(ear.i / dim | 0);\n triangles.push(next.i / dim | 0);\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n var p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n // z-order range for the current triangle bbox;\n var minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n var p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles, dim) {\n var p = start;\n do {\n var a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i / dim | 0);\n triangles.push(p.i / dim | 0);\n triangles.push(b.i / dim | 0);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n var a = start;\n do {\n var b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n var c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n var queue = [],\n i, len, start, end, list;\n\n for (i = 0, len = holeIndices.length; i < len; i++) {\n start = holeIndices[i] * dim;\n end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareX);\n\n // process holes from left to right\n for (i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareX(a, b) {\n return a.x - b.x;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and and link it\nfunction eliminateHole(hole, outerNode) {\n var bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n var bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n var p = outerNode,\n hx = hole.x,\n hy = hole.y,\n qx = -Infinity,\n m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n do {\n if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n var stop = m,\n mx = m.x,\n my = m.y,\n tanMin = Infinity,\n tan;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n var p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n var i, p, q, e, tail, numMerges, pSize, qSize,\n inSize = 1;\n\n do {\n p = list;\n list = null;\n tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n q = p;\n pSize = 0;\n for (i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n var p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n var o1 = sign(area(p1, q1, p2));\n var o2 = sign(area(p1, q1, q2));\n var o3 = sign(area(p2, q2, p1));\n var o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n var p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n var p = a,\n inside = false,\n px = (a.x + b.x) / 2,\n py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n var a2 = new Node(a.i, a.x, a.y),\n b2 = new Node(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n var p = new Node(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n // vertex index in coordinates array\n this.i = i;\n\n // vertex coordinates\n this.x = x;\n this.y = y;\n\n // previous and next vertex nodes in a polygon ring\n this.prev = null;\n this.next = null;\n\n // z-order curve value\n this.z = 0;\n\n // previous and next nodes in z-order\n this.prevZ = null;\n this.nextZ = null;\n\n // indicates whether this is a steiner point\n this.steiner = false;\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nearcut.deviation = function (data, holeIndices, dim, triangles) {\n var hasHoles = holeIndices && holeIndices.length;\n var outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (var i = 0, len = holeIndices.length; i < len; i++) {\n var start = holeIndices[i] * dim;\n var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n var trianglesArea = 0;\n for (i = 0; i < triangles.length; i += 3) {\n var a = triangles[i] * dim;\n var b = triangles[i + 1] * dim;\n var c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n};\n\nfunction signedArea(data, start, end, dim) {\n var sum = 0;\n for (var i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nearcut.flatten = function (data) {\n var dim = data[0][0].length,\n result = {vertices: [], holes: [], dimensions: dim},\n holeIndex = 0;\n\n for (var i = 0; i < data.length; i++) {\n for (var j = 0; j < data[i].length; j++) {\n for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);\n }\n if (i > 0) {\n holeIndex += data[i - 1].length;\n result.holes.push(holeIndex);\n }\n }\n return result;\n};\n","\nexport default function quickselect(arr, k, left, right, compare) {\n quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);\n}\n\nfunction quickselectStep(arr, k, left, right, compare) {\n\n while (right > left) {\n if (right - left > 600) {\n var n = right - left + 1;\n var m = k - left + 1;\n var z = Math.log(n);\n var s = 0.5 * Math.exp(2 * z / 3);\n var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselectStep(arr, k, newLeft, newRight, compare);\n }\n\n var t = arr[k];\n var i = left;\n var j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\nfunction swap(arr, i, j) {\n var tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import quickselect from 'quickselect';\n\nimport {calculateSignedArea} from './util';\n\nimport type Point from '@mapbox/point-geometry';\n\n// classifies an array of rings into polygons with outer rings and holes\nexport function classifyRings(rings: Array>, maxRings: number) {\n const len = rings.length;\n\n if (len <= 1) return [rings];\n\n const polygons = [];\n let polygon,\n ccw;\n\n for (let i = 0; i < len; i++) {\n const area = calculateSignedArea(rings[i]);\n if (area === 0) continue;\n\n (rings[i] as any).area = Math.abs(area);\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n (polygon as any).push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n // Earcut performance degrades with the # of rings in a polygon. For this\n // reason, we limit strip out all but the `maxRings` largest rings.\n if (maxRings > 1) {\n for (let j = 0; j < polygons.length; j++) {\n if (polygons[j].length <= maxRings) continue;\n quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);\n polygons[j] = polygons[j].slice(0, maxRings);\n }\n }\n\n return polygons;\n}\n\nfunction compareAreas(a, b) {\n return b.area - a.area;\n}\n","import type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\n\nimport type {\n BucketFeature,\n PopulateParameters\n} from '../bucket';\nimport {PossiblyEvaluated} from '../../style/properties';\n\ntype PatternStyleLayers = Array | Array | Array;\n\nexport function hasPattern(type: string, layers: PatternStyleLayers, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n let hasPattern = false;\n\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n if (!patternProperty.isConstant()) {\n hasPattern = true;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern) {\n hasPattern = true;\n patterns[constantPattern.to] = true;\n patterns[constantPattern.from] = true;\n }\n }\n\n return hasPattern;\n}\n\nexport function addPatternDependencies(type: string, layers: PatternStyleLayers, patternFeature: BucketFeature, zoom: number, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n\n const patternPropertyValue = patternProperty.value;\n if (patternPropertyValue.kind !== 'constant') {\n let min = patternPropertyValue.evaluate({zoom: zoom - 1}, patternFeature, {}, options.availableImages);\n let mid = patternPropertyValue.evaluate({zoom}, patternFeature, {}, options.availableImages);\n let max = patternPropertyValue.evaluate({zoom: zoom + 1}, patternFeature, {}, options.availableImages);\n min = min && min.name ? min.name : min;\n mid = mid && mid.name ? mid.name : mid;\n max = max && max.name ? max.name : max;\n // add to patternDependencies\n patterns[min] = true;\n patterns[mid] = true;\n patterns[max] = true;\n\n // save for layout\n patternFeature.patterns[layer.id] = {min, mid, max};\n }\n }\n return patternFeature;\n}\n","import {FillLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './fill_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {LineIndexArray, TriangleIndexArray} from '../index_array_type';\nimport earcut from 'earcut';\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport class FillBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n\n layoutVertexArray: FillLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n indexArray2: LineIndexArray;\n indexBuffer2: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n segments2: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n\n this.layoutVertexArray = new FillLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.indexArray2 = new LineIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.segments2 = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('fill', this.layers, options);\n const fillSortKey = this.layers[0].layout.get('fill-sort-key');\n const sortFeaturesByKey = !fillSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternFeature = addPatternDependencies('fill', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending(): boolean {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.indexBuffer2 = context.createIndexBuffer(this.indexArray2);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.indexBuffer2.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.segments2.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n\n const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n const triangleIndex = triangleSegment.vertexLength;\n\n const flattened = [];\n const holeIndices = [];\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2);\n const lineIndex = lineSegment.vertexLength;\n\n this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y);\n this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex);\n flattened.push(ring[0].x);\n flattened.push(ring[0].y);\n\n for (let i = 1; i < ring.length; i++) {\n this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y);\n this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);\n flattened.push(ring[i].x);\n flattened.push(ring[i].y);\n }\n\n lineSegment.vertexLength += ring.length;\n lineSegment.primitiveLength += ring.length;\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let i = 0; i < indices.length; i += 3) {\n this.indexArray.emplaceBack(\n triangleIndex + indices[i],\n triangleIndex + indices[i + 1],\n triangleIndex + indices[i + 2]);\n }\n\n triangleSegment.vertexLength += numVertices;\n triangleSegment.primitiveLength += indices.length / 3;\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillBucket', FillBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FillLayoutProps = {\n \"fill-sort-key\": DataDrivenProperty,\n};\n\nexport type FillLayoutPropsPossiblyEvaluated = {\n \"fill-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"fill-sort-key\": new DataDrivenProperty(styleSpec[\"layout_fill\"][\"fill-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type FillPaintProps = {\n \"fill-antialias\": DataConstantProperty,\n \"fill-opacity\": DataDrivenProperty,\n \"fill-color\": DataDrivenProperty,\n \"fill-outline-color\": DataDrivenProperty,\n \"fill-translate\": DataConstantProperty<[number, number]>,\n \"fill-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-pattern\": CrossFadedDataDrivenProperty,\n};\n\nexport type FillPaintPropsPossiblyEvaluated = {\n \"fill-antialias\": boolean,\n \"fill-opacity\": PossiblyEvaluatedPropertyValue,\n \"fill-color\": PossiblyEvaluatedPropertyValue,\n \"fill-outline-color\": PossiblyEvaluatedPropertyValue,\n \"fill-translate\": [number, number],\n \"fill-translate-anchor\": \"map\" | \"viewport\",\n \"fill-pattern\": PossiblyEvaluatedPropertyValue>,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-antialias\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-antialias\"] as any as StylePropertySpecification),\n \"fill-opacity\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-opacity\"] as any as StylePropertySpecification),\n \"fill-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-color\"] as any as StylePropertySpecification),\n \"fill-outline-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-outline-color\"] as any as StylePropertySpecification),\n \"fill-translate\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate\"] as any as StylePropertySpecification),\n \"fill-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-pattern\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillBucket} from '../../data/bucket/fill_bucket';\nimport {polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\n\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class FillStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n const outlineColor = this.paint._values['fill-outline-color'];\n if (outlineColor.value.kind === 'constant' && outlineColor.value.value === undefined) {\n this.paint._values['fill-outline-color'] = this.paint._values['fill-color'];\n }\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-translate'),\n this.paint.get('fill-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n return polygonIntersectsMultiPolygon(translatedPolygon, geometry);\n }\n\n isTileClipped() {\n return true;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_normal_ed', components: 4, type: 'Int16'},\n], 4);\n\nexport const centroidAttributes = createLayout([\n {name: 'a_centroid', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nvar Point = require('@mapbox/point-geometry');\n\nmodule.exports = VectorTileFeature;\n\nfunction VectorTileFeature(pbf, end, extent, keys, values) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n\n pbf.readFields(readFeature, this, end);\n}\n\nfunction readFeature(tag, feature, pbf) {\n if (tag == 1) feature.id = pbf.readVarint();\n else if (tag == 2) readTag(pbf, feature);\n else if (tag == 3) feature.type = pbf.readVarint();\n else if (tag == 4) feature._geometry = pbf.pos;\n}\n\nfunction readTag(pbf, feature) {\n var end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var key = feature._keys[pbf.readVarint()],\n value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n\nVectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\nVectorTileFeature.prototype.loadGeometry = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n lines = [],\n line;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) { // moveTo\n if (line) lines.push(line);\n line = [];\n }\n\n line.push(new Point(x, y));\n\n } else if (cmd === 7) {\n\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].clone()); // closePolygon\n }\n\n } else {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n if (line) lines.push(line);\n\n return lines;\n};\n\nVectorTileFeature.prototype.bbox = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n x1 = Infinity,\n x2 = -Infinity,\n y1 = Infinity,\n y2 = -Infinity;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n\n } else if (cmd !== 7) {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n return [x1, y1, x2, y2];\n};\n\nVectorTileFeature.prototype.toGeoJSON = function(x, y, z) {\n var size = this.extent * Math.pow(2, z),\n x0 = this.extent * x,\n y0 = this.extent * y,\n coords = this.loadGeometry(),\n type = VectorTileFeature.types[this.type],\n i, j;\n\n function project(line) {\n for (var j = 0; j < line.length; j++) {\n var p = line[j], y2 = 180 - (p.y + y0) * 360 / size;\n line[j] = [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90\n ];\n }\n }\n\n switch (this.type) {\n case 1:\n var points = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n project(coords);\n break;\n\n case 2:\n for (i = 0; i < coords.length; i++) {\n project(coords[i]);\n }\n break;\n\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n project(coords[i][j]);\n }\n }\n break;\n }\n\n if (coords.length === 1) {\n coords = coords[0];\n } else {\n type = 'Multi' + type;\n }\n\n var result = {\n type: \"Feature\",\n geometry: {\n type: type,\n coordinates: coords\n },\n properties: this.properties\n };\n\n if ('id' in this) {\n result.id = this.id;\n }\n\n return result;\n};\n\n// classifies an array of rings into polygons with outer rings and holes\n\nfunction classifyRings(rings) {\n var len = rings.length;\n\n if (len <= 1) return [rings];\n\n var polygons = [],\n polygon,\n ccw;\n\n for (var i = 0; i < len; i++) {\n var area = signedArea(rings[i]);\n if (area === 0) continue;\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n return polygons;\n}\n\nfunction signedArea(ring) {\n var sum = 0;\n for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n","'use strict';\n\nvar VectorTileFeature = require('./vectortilefeature.js');\n\nmodule.exports = VectorTileLayer;\n\nfunction VectorTileLayer(pbf, end) {\n // Public\n this.version = 1;\n this.name = null;\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n}\n\nfunction readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n}\n\nfunction readValueMessage(pbf) {\n var value = null,\n end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var tag = pbf.readVarint() >> 3;\n\n value = tag === 1 ? pbf.readString() :\n tag === 2 ? pbf.readFloat() :\n tag === 3 ? pbf.readDouble() :\n tag === 4 ? pbf.readVarint64() :\n tag === 5 ? pbf.readVarint() :\n tag === 6 ? pbf.readSVarint() :\n tag === 7 ? pbf.readBoolean() : null;\n }\n\n return value;\n}\n\n// return feature `i` from this layer as a `VectorTileFeature`\nVectorTileLayer.prototype.feature = function(i) {\n if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');\n\n this._pbf.pos = this._features[i];\n\n var end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n};\n","'use strict';\n\nvar VectorTileLayer = require('./vectortilelayer');\n\nmodule.exports = VectorTile;\n\nfunction VectorTile(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n}\n\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n}\n\n","module.exports.VectorTile = require('./lib/vectortile.js');\nmodule.exports.VectorTileFeature = require('./lib/vectortilefeature.js');\nmodule.exports.VectorTileLayer = require('./lib/vectortilelayer.js');\n","import {FillExtrusionLayoutArray, PosArray} from '../array_types.g';\n\nimport {members as layoutAttributes, centroidAttributes} from './fill_extrusion_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport earcut from 'earcut';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\n\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nconst FACTOR = Math.pow(2, 13);\n\nfunction addVertex(vertexArray, x, y, nx, ny, nz, t, e) {\n vertexArray.emplaceBack(\n // a_pos\n x,\n y,\n // a_normal_ed: 3-component normal and 1-component edgedistance\n Math.floor(nx * FACTOR) * 2 + t,\n ny * FACTOR * 2,\n nz * FACTOR * 2,\n // edgedistance (used for wrapping patterns around extrusion sides)\n Math.round(e)\n );\n}\n\nexport class FillExtrusionBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: FillExtrusionLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n centroidVertexArray: PosArray;\n centroidVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n features: Array;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new FillExtrusionLayoutArray();\n this.centroidVertexArray = new PosArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.features = [];\n this.hasPattern = hasPattern('fill-extrusion', this.layers, options);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const bucketFeature: BucketFeature = {\n id,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n properties: feature.properties,\n type: feature.type,\n patterns: {}\n };\n\n if (this.hasPattern) {\n this.features.push(addPatternDependencies('fill-extrusion', this.layers, bucketFeature, this.zoom, options));\n } else {\n this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {});\n }\n\n options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);\n }\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.features) {\n const {geometry} = feature;\n this.addFeature(feature, geometry, feature.index, canonical, imagePositions);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.centroidVertexBuffer.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const centroid = {x: 0, y: 0, vertexCount: 0};\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n let segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (isEntirelyOutside(ring)) {\n continue;\n }\n\n let edgeDistance = 0;\n\n for (let p = 0; p < ring.length; p++) {\n const p1 = ring[p];\n\n if (p >= 1) {\n const p2 = ring[p - 1];\n\n if (!isBoundaryEdge(p1, p2)) {\n if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n }\n\n const perp = p1.sub(p2)._perp()._unit();\n const dist = p2.dist(p1);\n if (edgeDistance + dist > 32768) edgeDistance = 0;\n\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p1.x;\n centroid.y += 2 * p1.y;\n centroid.vertexCount += 2;\n\n edgeDistance += dist;\n\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p2.x;\n centroid.y += 2 * p2.y;\n centroid.vertexCount += 2;\n\n const bottomRight = segment.vertexLength;\n\n // ┌──────┐\n // │ 0 1 │ Counter-clockwise winding order.\n // │ │ Triangle 1: 0 => 2 => 1\n // │ 2 3 │ Triangle 2: 1 => 2 => 3\n // └──────┘\n this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);\n this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n }\n\n }\n\n if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n }\n\n //Only triangulate and draw the area of the feature if it is a polygon\n //Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined\n if (vectorTileFeatureTypes[feature.type] !== 'Polygon')\n continue;\n\n const flattened = [];\n const holeIndices = [];\n const triangleIndex = segment.vertexLength;\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n\n addVertex(this.layoutVertexArray, p.x, p.y, 0, 0, 1, 1, 0);\n centroid.x += p.x;\n centroid.y += p.y;\n centroid.vertexCount += 1;\n\n flattened.push(p.x);\n flattened.push(p.y);\n }\n\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let j = 0; j < indices.length; j += 3) {\n // Counter-clockwise winding order.\n this.indexArray.emplaceBack(\n triangleIndex + indices[j],\n triangleIndex + indices[j + 2],\n triangleIndex + indices[j + 1]);\n }\n\n segment.primitiveLength += indices.length / 3;\n segment.vertexLength += numVertices;\n }\n\n // remember polygon centroid to calculate elevation in GPU\n for (let i = 0; i < centroid.vertexCount; i++) {\n this.centroidVertexArray.emplaceBack(\n Math.floor(centroid.x / centroid.vertexCount),\n Math.floor(centroid.y / centroid.vertexCount)\n );\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillExtrusionBucket', FillExtrusionBucket, {omit: ['layers', 'features']});\n\nfunction isBoundaryEdge(p1, p2) {\n return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) ||\n (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT));\n}\n\nfunction isEntirelyOutside(ring) {\n return ring.every(p => p.x < 0) ||\n ring.every(p => p.x > EXTENT) ||\n ring.every(p => p.y < 0) ||\n ring.every(p => p.y > EXTENT);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type FillExtrusionPaintProps = {\n \"fill-extrusion-opacity\": DataConstantProperty,\n \"fill-extrusion-color\": DataDrivenProperty,\n \"fill-extrusion-translate\": DataConstantProperty<[number, number]>,\n \"fill-extrusion-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-extrusion-pattern\": CrossFadedDataDrivenProperty,\n \"fill-extrusion-height\": DataDrivenProperty,\n \"fill-extrusion-base\": DataDrivenProperty,\n \"fill-extrusion-vertical-gradient\": DataConstantProperty,\n};\n\nexport type FillExtrusionPaintPropsPossiblyEvaluated = {\n \"fill-extrusion-opacity\": number,\n \"fill-extrusion-color\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-translate\": [number, number],\n \"fill-extrusion-translate-anchor\": \"map\" | \"viewport\",\n \"fill-extrusion-pattern\": PossiblyEvaluatedPropertyValue>,\n \"fill-extrusion-height\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-base\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-vertical-gradient\": boolean,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-extrusion-opacity\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-opacity\"] as any as StylePropertySpecification),\n \"fill-extrusion-color\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-color\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-extrusion-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-pattern\"] as any as StylePropertySpecification),\n \"fill-extrusion-height\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-height\"] as any as StylePropertySpecification),\n \"fill-extrusion-base\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-base\"] as any as StylePropertySpecification),\n \"fill-extrusion-vertical-gradient\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-vertical-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillExtrusionBucket} from '../../data/bucket/fill_extrusion_bucket';\nimport {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class Point3D extends Point {\n z: number;\n}\n\nexport class FillExtrusionStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillExtrusionBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-extrusion-translate'));\n }\n\n is3D(): boolean {\n return true;\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number {\n\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-extrusion-translate'),\n this.paint.get('fill-extrusion-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n\n const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState);\n const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState);\n\n const projectedQueryGeometry = projectQueryGeometry(translatedPolygon, pixelPosMatrix, transform, 0);\n\n const projected = projectExtrusion(geometry, base, height, pixelPosMatrix);\n const projectedBase = projected[0];\n const projectedTop = projected[1];\n return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry);\n }\n}\n\nfunction dot(a, b) {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function getIntersectionDistance(projectedQueryGeometry: Array, projectedFace: Array) {\n\n if (projectedQueryGeometry.length === 1) {\n // For point queries calculate the z at which the point intersects the face\n // using barycentric coordinates.\n\n // Find the barycentric coordinates of the projected point within the first\n // triangle of the face, using only the xy plane. It doesn't matter if the\n // point is outside the first triangle because all the triangles in the face\n // are in the same plane.\n //\n // Check whether points are coincident and use other points if they are.\n let i = 0;\n const a = projectedFace[i++];\n let b;\n while (!b || a.equals(b)) {\n b = projectedFace[i++];\n if (!b) return Infinity;\n }\n\n // Loop until point `c` is not colinear with points `a` and `b`.\n for (; i < projectedFace.length; i++) {\n const c = projectedFace[i];\n\n const p = projectedQueryGeometry[0];\n\n const ab = b.sub(a);\n const ac = c.sub(a);\n const ap = p.sub(a);\n\n const dotABAB = dot(ab, ab);\n const dotABAC = dot(ab, ac);\n const dotACAC = dot(ac, ac);\n const dotAPAB = dot(ap, ab);\n const dotAPAC = dot(ap, ac);\n const denom = dotABAB * dotACAC - dotABAC * dotABAC;\n\n const v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom;\n const w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom;\n const u = 1 - v - w;\n\n // Use the barycentric weighting along with the original triangle z coordinates to get the point of intersection.\n const distance = a.z * u + b.z * v + c.z * w;\n\n if (isFinite(distance)) return distance;\n }\n\n return Infinity;\n\n } else {\n // The counts as closest is less clear when the query is a box. This\n // returns the distance to the nearest point on the face, whether it is\n // within the query or not. It could be more correct to return the\n // distance to the closest point within the query box but this would be\n // more complicated and expensive to calculate with little benefit.\n let closestDistance = Infinity;\n for (const p of projectedFace) {\n closestDistance = Math.min(closestDistance, p.z);\n }\n return closestDistance;\n }\n}\n\nfunction checkIntersection(projectedBase: Array>, projectedTop: Array>, projectedQueryGeometry: Array) {\n let closestDistance = Infinity;\n\n if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) {\n closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]);\n }\n\n for (let r = 0; r < projectedTop.length; r++) {\n const ringTop = projectedTop[r];\n const ringBase = projectedBase[r];\n for (let p = 0; p < ringTop.length - 1; p++) {\n const topA = ringTop[p];\n const topB = ringTop[p + 1];\n const baseA = ringBase[p];\n const baseB = ringBase[p + 1];\n const face = [topA, topB, baseB, baseA, topA];\n if (polygonIntersectsPolygon(projectedQueryGeometry, face)) {\n closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face));\n }\n }\n }\n\n return closestDistance === Infinity ? false : closestDistance;\n}\n\n/*\n * Project the geometry using matrix `m`. This is essentially doing\n * `vec4.transformMat4([], [p.x, p.y, z, 1], m)` but the multiplication\n * is inlined so that parts of the projection that are the same across\n * different points can only be done once. This produced a measurable\n * performance improvement.\n */\nfunction projectExtrusion(geometry: Array>, zBase: number, zTop: number, m: mat4): [Array>, Array>] {\n const projectedBase = [] as Array>;\n const projectedTop = [] as Array>;\n const baseXZ = m[8] * zBase;\n const baseYZ = m[9] * zBase;\n const baseZZ = m[10] * zBase;\n const baseWZ = m[11] * zBase;\n const topXZ = m[8] * zTop;\n const topYZ = m[9] * zTop;\n const topZZ = m[10] * zTop;\n const topWZ = m[11] * zTop;\n\n for (const r of geometry) {\n const ringBase = [] as Array;\n const ringTop = [] as Array;\n for (const p of r) {\n const x = p.x;\n const y = p.y;\n\n const sX = m[0] * x + m[4] * y + m[12];\n const sY = m[1] * x + m[5] * y + m[13];\n const sZ = m[2] * x + m[6] * y + m[14];\n const sW = m[3] * x + m[7] * y + m[15];\n\n const baseX = sX + baseXZ;\n const baseY = sY + baseYZ;\n const baseZ = sZ + baseZZ;\n const baseW = sW + baseWZ;\n\n const topX = sX + topXZ;\n const topY = sY + topYZ;\n const topZ = sZ + topZZ;\n const topW = sW + topWZ;\n\n const b = new Point(baseX / baseW, baseY / baseW) as Point3D;\n b.z = baseZ / baseW;\n ringBase.push(b);\n\n const t = new Point(topX / topW, topY / topW) as Point3D;\n t.z = topZ / topW;\n ringTop.push(t);\n }\n projectedBase.push(ringBase);\n projectedTop.push(ringTop);\n }\n return [projectedBase, projectedTop];\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4, transform: Transform, z: number) {\n const projectedQueryGeometry = [];\n for (const p of queryGeometry) {\n const v = [p.x, p.y, z, 1] as vec4;\n vec4.transformMat4(v, v, pixelPosMatrix);\n projectedQueryGeometry.push(new Point(v[0] / v[3], v[1] / v[3]));\n }\n return projectedQueryGeometry;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributes = createLayout([\n {name: 'a_pos_normal', components: 2, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint8'}\n], 4);\n\nexport const {members, size, alignment} = lineLayoutAttributes;\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributesExt = createLayout([\n {name: 'a_uv_x', components: 1, type: 'Float32'},\n {name: 'a_split_index', components: 1, type: 'Float32'},\n]);\n\nexport const {members, size, alignment} = lineLayoutAttributesExt;\n","import {LineLayoutArray, LineExtLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './line_attributes';\nimport {members as layoutAttributesExt} from './line_attributes_ext';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Segment} from '../segment';\nimport {RGBAImage} from '../../util/image';\nimport type {Context} from '../../gl/context';\nimport type {Texture} from '../../render/texture';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\n// NOTE ON EXTRUDE SCALE:\n// scale the extrusion vector so that the normal length is this value.\n// contains the \"texture\" normals (-1..1). this is distinct from the extrude\n// normals for line joins, because the x-value remains 0 for the texture\n// normal array, while the extrude normal actually moves the vertex to create\n// the acute/bevelled line join.\nconst EXTRUDE_SCALE = 63;\n\n/*\n * Sharp corners cause dashed lines to tilt because the distance along the line\n * is the same at both the inner and outer corners. To improve the appearance of\n * dashed lines we add extra points near sharp corners so that a smaller part\n * of the line is tilted.\n *\n * COS_HALF_SHARP_CORNER controls how sharp a corner has to be for us to add an\n * extra vertex. The default is 75 degrees.\n *\n * The newly created vertices are placed SHARP_CORNER_OFFSET pixels from the corner.\n */\nconst COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180));\nconst SHARP_CORNER_OFFSET = 15;\n\n// Angle per triangle for approximating round line joins.\nconst DEG_PER_TRIANGLE = 20;\n\n// The number of bits that is used to store the line distance in the buffer.\nconst LINE_DISTANCE_BUFFER_BITS = 15;\n\n// We don't have enough bits for the line distance as we'd like to have, so\n// use this value to scale the line distance (in tile units) down to a smaller\n// value. This lets us store longer distances while sacrificing precision.\nconst LINE_DISTANCE_SCALE = 1 / 2;\n\n// The maximum line distance, in tile units, that fits in the buffer.\nconst MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE;\n\ntype LineClips = {\n start: number;\n end: number;\n};\n\ntype GradientTexture = {\n texture?: Texture;\n gradient?: RGBAImage;\n version?: number;\n};\n\n/**\n * @internal\n * Line bucket class\n */\nexport class LineBucket implements Bucket {\n distance: number;\n totalDistance: number;\n maxLineLength: number;\n scaledDistance: number;\n lineClips?: LineClips;\n\n e1: number;\n e2: number;\n\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n gradients: {[x: string]: GradientTexture};\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n lineClipsArray: Array;\n\n layoutVertexArray: LineLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n layoutVertexArray2: LineExtLayoutArray;\n layoutVertexBuffer2: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n this.lineClipsArray = [];\n this.gradients = {};\n this.layers.forEach(layer => {\n this.gradients[layer.id] = {};\n });\n\n this.layoutVertexArray = new LineLayoutArray();\n this.layoutVertexArray2 = new LineExtLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.maxLineLength = 0;\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('line', this.layers, options);\n const lineSortKey = this.layers[0].layout.get('line-sort-key');\n const sortFeaturesByKey = !lineSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n lineSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => {\n return (a.sortKey) - (b.sortKey);\n });\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternBucketFeature = addPatternDependencies('line', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternBucketFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n if (this.layoutVertexArray2.length !== 0) {\n this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, layoutAttributesExt);\n }\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n lineFeatureClips(feature: BucketFeature): LineClips | undefined {\n if (!!feature.properties && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_start') && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_end')) {\n const start = +feature.properties['mapbox_clip_start'];\n const end = +feature.properties['mapbox_clip_end'];\n return {start, end};\n }\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const layout = this.layers[0].layout;\n const join = layout.get('line-join').evaluate(feature, {});\n const cap = layout.get('line-cap');\n const miterLimit = layout.get('line-miter-limit');\n const roundLimit = layout.get('line-round-limit');\n this.lineClips = this.lineFeatureClips(feature);\n\n for (const line of geometry) {\n this.addLine(line, feature, join, cap, miterLimit, roundLimit);\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n\n addLine(vertices: Array, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number) {\n this.distance = 0;\n this.scaledDistance = 0;\n this.totalDistance = 0;\n\n if (this.lineClips) {\n this.lineClipsArray.push(this.lineClips);\n // Calculate the total distance, in tile units, of this tiled line feature\n for (let i = 0; i < vertices.length - 1; i++) {\n this.totalDistance += vertices[i].dist(vertices[i + 1]);\n }\n this.updateScaledDistance();\n this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);\n }\n\n const isPolygon = vectorTileFeatureTypes[feature.type] === 'Polygon';\n\n // If the line has duplicate vertices at the ends, adjust start/length to remove them.\n let len = vertices.length;\n while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) {\n len--;\n }\n let first = 0;\n while (first < len - 1 && vertices[first].equals(vertices[first + 1])) {\n first++;\n }\n\n // Ignore invalid geometry.\n if (len < (isPolygon ? 3 : 2)) return;\n\n if (join === 'bevel') miterLimit = 1.05;\n\n const sharpCornerOffset = this.overscaling <= 16 ?\n SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) :\n 0;\n\n // we could be more precise, but it would only save a negligible amount of space\n const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray);\n\n let currentVertex: Point;\n let prevVertex: Point;\n let nextVertex: Point;\n let prevNormal: Point;\n let nextNormal: Point;\n\n // the last two vertices added\n this.e1 = this.e2 = -1;\n\n if (isPolygon) {\n currentVertex = vertices[len - 2];\n nextNormal = vertices[first].sub(currentVertex)._unit()._perp();\n }\n\n for (let i = first; i < len; i++) {\n\n nextVertex = i === len - 1 ?\n (isPolygon ? vertices[first + 1] : undefined) : // if it's a polygon, treat the last vertex like the first\n vertices[i + 1]; // just the next vertex\n\n // if two consecutive vertices exist, skip the current one\n if (nextVertex && vertices[i].equals(nextVertex)) continue;\n\n if (nextNormal) prevNormal = nextNormal;\n if (currentVertex) prevVertex = currentVertex;\n\n currentVertex = vertices[i];\n\n // Calculate the normal towards the next vertex in this line. In case\n // there is no next vertex, pretend that the line is continuing straight,\n // meaning that we are just using the previous normal.\n nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal;\n\n // If we still don't have a previous normal, this is the beginning of a\n // non-closed line, so we're doing a straight \"join\".\n prevNormal = prevNormal || nextNormal;\n\n // Determine the normal of the join extrusion. It is the angle bisector\n // of the segments between the previous line and the next line.\n // In the case of 180° angles, the prev and next normals cancel each other out:\n // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be\n // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle\n // below will also become 0 and miterLength will become Infinity.\n let joinNormal = prevNormal.add(nextNormal);\n if (joinNormal.x !== 0 || joinNormal.y !== 0) {\n joinNormal._unit();\n }\n /* joinNormal prevNormal\n * ↖ ↑\n * .________. prevVertex\n * |\n * nextNormal ← | currentVertex\n * |\n * nextVertex !\n *\n */\n\n // calculate cosines of the angle (and its half) using dot product\n const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y;\n const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y;\n\n // Calculate the length of the miter (the ratio of the miter to the width)\n // as the inverse of cosine of the angle between next and join normals\n const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity;\n\n // approximate angle from cosine\n const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle);\n\n const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex;\n const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0;\n\n if (isSharpCorner && i > first) {\n const prevSegmentLength = currentVertex.dist(prevVertex);\n if (prevSegmentLength > 2 * sharpCornerOffset) {\n const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round());\n this.updateDistance(prevVertex, newPrevVertex);\n this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment);\n prevVertex = newPrevVertex;\n }\n }\n\n // The join if a middle vertex, otherwise the cap.\n const middleVertex = prevVertex && nextVertex;\n let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap;\n\n if (middleVertex && currentJoin === 'round') {\n if (miterLength < roundLimit) {\n currentJoin = 'miter';\n } else if (miterLength <= 2) {\n currentJoin = 'fakeround';\n }\n }\n\n if (currentJoin === 'miter' && miterLength > miterLimit) {\n currentJoin = 'bevel';\n }\n\n if (currentJoin === 'bevel') {\n // The maximum extrude length is 128 / 63 = 2 times the width of the line\n // so if miterLength >= 2 we need to draw a different type of bevel here.\n if (miterLength > 2) currentJoin = 'flipbevel';\n\n // If the miterLength is really small and the line bevel wouldn't be visible,\n // just draw a miter join to save a triangle.\n if (miterLength < miterLimit) currentJoin = 'miter';\n }\n\n // Calculate how far along the line the currentVertex is\n if (prevVertex) this.updateDistance(prevVertex, currentVertex);\n\n if (currentJoin === 'miter') {\n\n joinNormal._mult(miterLength);\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n\n } else if (currentJoin === 'flipbevel') {\n // miter is too big, flip the direction to make a beveled join\n\n if (miterLength > 100) {\n // Almost parallel lines\n joinNormal = nextNormal.mult(-1);\n\n } else {\n const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag();\n joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1));\n }\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment);\n\n } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') {\n const offset = -Math.sqrt(miterLength * miterLength - 1);\n const offsetA = lineTurnsLeft ? offset : 0;\n const offsetB = lineTurnsLeft ? 0 : offset;\n\n // Close previous segment with a bevel\n if (prevVertex) {\n this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment);\n }\n\n if (currentJoin === 'fakeround') {\n // The join angle is sharp enough that a round join would be visible.\n // Bevel joins fill the gap between segments with a single pie slice triangle.\n // Create a round join by adding multiple pie slices. The join isn't actually round, but\n // it looks like it is at the sizes we render lines at.\n\n // pick the number of triangles for approximating round join by based on the angle between normals\n const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE);\n\n for (let m = 1; m < n; m++) {\n let t = m / n;\n if (t !== 0.5) {\n // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp\n const t2 = t - 0.5;\n const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519));\n const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638);\n t = t + t * t2 * (t - 1) * (A * t2 * t2 + B);\n }\n const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1);\n this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment);\n }\n }\n\n if (nextVertex) {\n // Start next segment\n this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment);\n }\n\n } else if (currentJoin === 'butt') {\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap\n\n } else if (currentJoin === 'square') {\n const offset = prevVertex ? 1 : -1; // closing or starting square cap\n this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment);\n\n } else if (currentJoin === 'round') {\n\n if (prevVertex) {\n // Close previous segment with butt\n this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment);\n\n // Add round cap or linejoin at end of segment\n this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true);\n }\n if (nextVertex) {\n // Add round cap before first segment\n this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true);\n\n // Start next segment with a butt\n this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment);\n }\n }\n\n if (isSharpCorner && i < len - 1) {\n const nextSegmentLength = currentVertex.dist(nextVertex);\n if (nextSegmentLength > 2 * sharpCornerOffset) {\n const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round());\n this.updateDistance(currentVertex, newCurrentVertex);\n this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment);\n currentVertex = newCurrentVertex;\n }\n }\n }\n }\n\n /**\n * Add two vertices to the buffers.\n *\n * @param p - the line vertex to add buffer vertices for\n * @param normal - vertex normal\n * @param endLeft - extrude to shift the left vertex along the line\n * @param endRight - extrude to shift the left vertex along the line\n * @param segment - the segment object to add the vertex to\n * @param round - whether this is a round cap\n */\n addCurrentVertex(p: Point, normal: Point, endLeft: number, endRight: number, segment: Segment, round: boolean = false) {\n // left and right extrude vectors, perpendicularly shifted by endLeft/endRight\n const leftX = normal.x + normal.y * endLeft;\n const leftY = normal.y - normal.x * endLeft;\n const rightX = -normal.x + normal.y * endRight;\n const rightY = -normal.y - normal.x * endRight;\n\n this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment);\n this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment);\n\n // There is a maximum \"distance along the line\" that we can store in the buffers.\n // When we get close to the distance, reset it to zero and add the vertex again with\n // a distance of zero. The max distance is determined by the number of bits we allocate\n // to `linesofar`.\n if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) {\n this.distance = 0;\n this.updateScaledDistance();\n this.addCurrentVertex(p, normal, endLeft, endRight, segment, round);\n }\n }\n\n addHalfVertex({x, y}: Point, extrudeX: number, extrudeY: number, round: boolean, up: boolean, dir: number, segment: Segment) {\n const totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance;\n // scale down so that we can store longer distances while sacrificing precision.\n const linesofarScaled = totalDistance * LINE_DISTANCE_SCALE;\n\n this.layoutVertexArray.emplaceBack(\n // a_pos_normal\n // Encode round/up the least significant bits\n (x << 1) + (round ? 1 : 0),\n (y << 1) + (up ? 1 : 0),\n // a_data\n // add 128 to store a byte in an unsigned byte\n Math.round(EXTRUDE_SCALE * extrudeX) + 128,\n Math.round(EXTRUDE_SCALE * extrudeY) + 128,\n // Encode the -1/0/1 direction value into the first two bits of .z of a_data.\n // Combine it with the lower 6 bits of `linesofarScaled` (shifted by 2 bits to make\n // room for the direction value). The upper 8 bits of `linesofarScaled` are placed in\n // the `w` component.\n ((dir === 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofarScaled & 0x3F) << 2),\n linesofarScaled >> 6);\n\n // Constructs a second vertex buffer with higher precision line progress\n if (this.lineClips) {\n const progressRealigned = this.scaledDistance - this.lineClips.start;\n const endClipRealigned = this.lineClips.end - this.lineClips.start;\n const uvX = progressRealigned / endClipRealigned;\n this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length);\n }\n\n const e = segment.vertexLength++;\n if (this.e1 >= 0 && this.e2 >= 0) {\n this.indexArray.emplaceBack(this.e1, this.e2, e);\n segment.primitiveLength++;\n }\n if (up) {\n this.e2 = e;\n } else {\n this.e1 = e;\n }\n }\n\n updateScaledDistance() {\n // Knowing the ratio of the full linestring covered by this tiled feature, as well\n // as the total distance (in tile units) of this tiled feature, and the distance\n // (in tile units) of the current vertex, we can determine the relative distance\n // of this vertex along the full linestring feature and scale it to [0, 2^15)\n this.scaledDistance = this.lineClips ?\n this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance :\n this.distance;\n }\n\n updateDistance(prev: Point, next: Point) {\n this.distance += prev.dist(next);\n this.updateScaledDistance();\n }\n}\n\nregister('LineBucket', LineBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LineLayoutProps = {\n \"line-cap\": DataConstantProperty<\"butt\" | \"round\" | \"square\">,\n \"line-join\": DataDrivenProperty<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": DataConstantProperty,\n \"line-round-limit\": DataConstantProperty,\n \"line-sort-key\": DataDrivenProperty,\n};\n\nexport type LineLayoutPropsPossiblyEvaluated = {\n \"line-cap\": \"butt\" | \"round\" | \"square\",\n \"line-join\": PossiblyEvaluatedPropertyValue<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": number,\n \"line-round-limit\": number,\n \"line-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"line-cap\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-cap\"] as any as StylePropertySpecification),\n \"line-join\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-join\"] as any as StylePropertySpecification),\n \"line-miter-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-miter-limit\"] as any as StylePropertySpecification),\n \"line-round-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-round-limit\"] as any as StylePropertySpecification),\n \"line-sort-key\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type LinePaintProps = {\n \"line-opacity\": DataDrivenProperty,\n \"line-color\": DataDrivenProperty,\n \"line-translate\": DataConstantProperty<[number, number]>,\n \"line-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"line-width\": DataDrivenProperty,\n \"line-gap-width\": DataDrivenProperty,\n \"line-offset\": DataDrivenProperty,\n \"line-blur\": DataDrivenProperty,\n \"line-dasharray\": CrossFadedProperty>,\n \"line-pattern\": CrossFadedDataDrivenProperty,\n \"line-gradient\": ColorRampProperty,\n};\n\nexport type LinePaintPropsPossiblyEvaluated = {\n \"line-opacity\": PossiblyEvaluatedPropertyValue,\n \"line-color\": PossiblyEvaluatedPropertyValue,\n \"line-translate\": [number, number],\n \"line-translate-anchor\": \"map\" | \"viewport\",\n \"line-width\": PossiblyEvaluatedPropertyValue,\n \"line-gap-width\": PossiblyEvaluatedPropertyValue,\n \"line-offset\": PossiblyEvaluatedPropertyValue,\n \"line-blur\": PossiblyEvaluatedPropertyValue,\n \"line-dasharray\": CrossFaded>,\n \"line-pattern\": PossiblyEvaluatedPropertyValue>,\n \"line-gradient\": ColorRampProperty,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"line-opacity\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-opacity\"] as any as StylePropertySpecification),\n \"line-color\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-color\"] as any as StylePropertySpecification),\n \"line-translate\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate\"] as any as StylePropertySpecification),\n \"line-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate-anchor\"] as any as StylePropertySpecification),\n \"line-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-width\"] as any as StylePropertySpecification),\n \"line-gap-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-gap-width\"] as any as StylePropertySpecification),\n \"line-offset\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-offset\"] as any as StylePropertySpecification),\n \"line-blur\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-blur\"] as any as StylePropertySpecification),\n \"line-dasharray\": new CrossFadedProperty(styleSpec[\"paint_line\"][\"line-dasharray\"] as any as StylePropertySpecification),\n \"line-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_line\"][\"line-pattern\"] as any as StylePropertySpecification),\n \"line-gradient\": new ColorRampProperty(styleSpec[\"paint_line\"][\"line-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import Point from '@mapbox/point-geometry';\n\nimport {StyleLayer} from '../style_layer';\nimport {LineBucket} from '../../data/bucket/line_bucket';\nimport {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate, offsetLine} from '../query_utils';\nimport properties, {LineLayoutPropsPossiblyEvaluated, LinePaintPropsPossiblyEvaluated} from './line_style_layer_properties.g';\nimport {extend} from '../../util/util';\nimport {EvaluationParameters} from '../evaluation_parameters';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties';\n\nimport {isZoomExpression, Step} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {LineLayoutProps, LinePaintProps} from './line_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class LineFloorwidthProperty extends DataDrivenProperty {\n useIntegerZoom: true;\n\n possiblyEvaluate(value, parameters) {\n parameters = new EvaluationParameters(Math.floor(parameters.zoom), {\n now: parameters.now,\n fadeDuration: parameters.fadeDuration,\n zoomHistory: parameters.zoomHistory,\n transition: parameters.transition\n });\n return super.possiblyEvaluate(value, parameters);\n }\n\n evaluate(value, globals, feature, featureState) {\n globals = extend({}, globals, {zoom: Math.floor(globals.zoom)});\n return super.evaluate(value, globals, feature, featureState);\n }\n}\n\nlet lineFloorwidthProperty: LineFloorwidthProperty;\n\nexport class LineStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n gradientVersion: number;\n stepInterpolant: boolean;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n this.gradientVersion = 0;\n if (!lineFloorwidthProperty) {\n lineFloorwidthProperty =\n new LineFloorwidthProperty(properties.paint.properties['line-width'].specification);\n lineFloorwidthProperty.useIntegerZoom = true;\n }\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'line-gradient') {\n const expression = this.gradientExpression();\n if (isZoomExpression(expression)) {\n this.stepInterpolant = expression._styleExpression.expression instanceof Step;\n } else {\n this.stepInterpolant = false;\n }\n this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;\n }\n }\n\n gradientExpression() {\n return this._transitionablePaint._values['line-gradient'].value.expression;\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n (this.paint._values as any)['line-floorwidth'] =\n lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values['line-width'].value, parameters);\n }\n\n createBucket(parameters: BucketParameters) {\n return new LineBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const lineBucket: LineBucket = (bucket as any);\n const width = getLineWidth(\n getMaximumPaintValue('line-width', this, lineBucket),\n getMaximumPaintValue('line-gap-width', this, lineBucket));\n const offset = getMaximumPaintValue('line-offset', this, lineBucket);\n return width / 2 + Math.abs(offset) + translateDistance(this.paint.get('line-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('line-translate'),\n this.paint.get('line-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const halfWidth = pixelsToTileUnits / 2 * getLineWidth(\n this.paint.get('line-width').evaluate(feature, featureState),\n this.paint.get('line-gap-width').evaluate(feature, featureState));\n const lineOffset = this.paint.get('line-offset').evaluate(feature, featureState);\n if (lineOffset) {\n geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits);\n }\n\n return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth);\n }\n\n isTileClipped() {\n return true;\n }\n}\n\nfunction getLineWidth(lineWidth, lineGapWidth) {\n if (lineGapWidth > 0) {\n return lineGapWidth + 2 * lineWidth;\n } else {\n return lineWidth;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const symbolLayoutAttributes = createLayout([\n {name: 'a_pos_offset', components: 4, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint16'},\n {name: 'a_pixeloffset', components: 4, type: 'Int16'}\n], 4);\n\nexport const dynamicLayoutAttributes = createLayout([\n {name: 'a_projected_pos', components: 3, type: 'Float32'}\n], 4);\n\nexport const placementOpacityAttributes = createLayout([\n {name: 'a_fade_opacity', components: 1, type: 'Uint32'}\n], 4);\n\nexport const collisionVertexAttributes = createLayout([\n {name: 'a_placed', components: 2, type: 'Uint8'},\n {name: 'a_shift', components: 2, type: 'Float32'}\n]);\n\nexport const collisionBox = createLayout([\n // the box is centered around the anchor point\n {type: 'Int16', name: 'anchorPointX'},\n {type: 'Int16', name: 'anchorPointY'},\n\n // distances to the edges from the anchor\n {type: 'Int16', name: 'x1'},\n {type: 'Int16', name: 'y1'},\n {type: 'Int16', name: 'x2'},\n {type: 'Int16', name: 'y2'},\n\n // the index of the feature in the original vectortile\n {type: 'Uint32', name: 'featureIndex'},\n // the source layer the feature appears in\n {type: 'Uint16', name: 'sourceLayerIndex'},\n // the bucket the feature appears in\n {type: 'Uint16', name: 'bucketIndex'},\n]);\n\nexport const collisionBoxLayout = createLayout([ // used to render collision boxes for debugging purposes\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_anchor_pos', components: 2, type: 'Int16'},\n {name: 'a_extrude', components: 2, type: 'Int16'}\n], 4);\n\nexport const collisionCircleLayout = createLayout([ // used to render collision circles for debugging purposes\n {name: 'a_pos', components: 2, type: 'Float32'},\n {name: 'a_radius', components: 1, type: 'Float32'},\n {name: 'a_flags', components: 2, type: 'Int16'}\n], 4);\n\nexport const quadTriangle = createLayout([\n {name: 'triangle', components: 3, type: 'Uint16'},\n]);\n\nexport const placement = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Uint16', name: 'glyphStartIndex'},\n {type: 'Uint16', name: 'numGlyphs'},\n {type: 'Uint32', name: 'vertexStartIndex'},\n {type: 'Uint32', name: 'lineStartIndex'},\n {type: 'Uint32', name: 'lineLength'},\n {type: 'Uint16', name: 'segment'},\n {type: 'Uint16', name: 'lowerSize'},\n {type: 'Uint16', name: 'upperSize'},\n {type: 'Float32', name: 'lineOffsetX'},\n {type: 'Float32', name: 'lineOffsetY'},\n {type: 'Uint8', name: 'writingMode'},\n {type: 'Uint8', name: 'placedOrientation'},\n {type: 'Uint8', name: 'hidden'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Int16', name: 'associatedIconIndex'}\n]);\n\nexport const symbolInstance = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Int16', name: 'rightJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'centerJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'leftJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedTextSymbolIndex'},\n {type: 'Int16', name: 'placedIconSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedIconSymbolIndex'},\n {type: 'Uint16', name: 'key'},\n {type: 'Uint16', name: 'textBoxStartIndex'},\n {type: 'Uint16', name: 'textBoxEndIndex'},\n {type: 'Uint16', name: 'verticalTextBoxStartIndex'},\n {type: 'Uint16', name: 'verticalTextBoxEndIndex'},\n {type: 'Uint16', name: 'iconBoxStartIndex'},\n {type: 'Uint16', name: 'iconBoxEndIndex'},\n {type: 'Uint16', name: 'verticalIconBoxStartIndex'},\n {type: 'Uint16', name: 'verticalIconBoxEndIndex'},\n {type: 'Uint16', name: 'featureIndex'},\n {type: 'Uint16', name: 'numHorizontalGlyphVertices'},\n {type: 'Uint16', name: 'numVerticalGlyphVertices'},\n {type: 'Uint16', name: 'numIconVertices'},\n {type: 'Uint16', name: 'numVerticalIconVertices'},\n {type: 'Uint16', name: 'useRuntimeCollisionCircles'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Float32', name: 'textBoxScale'},\n {type: 'Float32', name: 'collisionCircleDiameter'},\n {type: 'Uint16', name: 'textAnchorOffsetStartIndex'},\n {type: 'Uint16', name: 'textAnchorOffsetEndIndex'}\n]);\n\nexport const glyphOffset = createLayout([\n {type: 'Float32', name: 'offsetX'}\n]);\n\nexport const lineVertex = createLayout([\n {type: 'Int16', name: 'x'},\n {type: 'Int16', name: 'y'},\n {type: 'Int16', name: 'tileUnitDistanceFromAnchor'}\n]);\n\nexport const textAnchorOffset = createLayout([\n {type: 'Uint16', name: 'textAnchor'},\n {type: 'Float32', components: 2, name: 'textOffset'}\n]);\n","import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport {Formatted} from '@maplibre/maplibre-gl-style-spec';\n\nfunction transformTextInternal(text: string, layer: SymbolStyleLayer, feature: Feature) {\n const transform = layer.layout.get('text-transform').evaluate(feature, {});\n if (transform === 'uppercase') {\n text = text.toLocaleUpperCase();\n } else if (transform === 'lowercase') {\n text = text.toLocaleLowerCase();\n }\n\n if (rtlTextPlugin.applyArabicShaping) {\n text = rtlTextPlugin.applyArabicShaping(text);\n }\n\n return text;\n}\n\nexport function transformText(text: Formatted, layer: SymbolStyleLayer, feature: Feature): Formatted {\n text.sections.forEach(section => {\n section.text = transformTextInternal(section.text, layer, feature);\n });\n return text;\n}\n","import type {SymbolFeature} from '../data/bucket/symbol_bucket';\n\nexport function mergeLines(features: Array): Array {\n const leftIndex: {[_: string]: number} = {};\n const rightIndex: {[_: string]: number} = {};\n const mergedFeatures = [];\n let mergedIndex = 0;\n\n function add(k) {\n mergedFeatures.push(features[k]);\n mergedIndex++;\n }\n\n function mergeFromRight(leftKey: string, rightKey: string, geom) {\n const i = rightIndex[leftKey];\n delete rightIndex[leftKey];\n rightIndex[rightKey] = i;\n\n mergedFeatures[i].geometry[0].pop();\n mergedFeatures[i].geometry[0] = mergedFeatures[i].geometry[0].concat(geom[0]);\n return i;\n }\n\n function mergeFromLeft(leftKey: string, rightKey: string, geom) {\n const i = leftIndex[rightKey];\n delete leftIndex[rightKey];\n leftIndex[leftKey] = i;\n\n mergedFeatures[i].geometry[0].shift();\n mergedFeatures[i].geometry[0] = geom[0].concat(mergedFeatures[i].geometry[0]);\n return i;\n }\n\n function getKey(text, geom, onRight?) {\n const point = onRight ? geom[0][geom[0].length - 1] : geom[0][0];\n return `${text}:${point.x}:${point.y}`;\n }\n\n for (let k = 0; k < features.length; k++) {\n const feature = features[k];\n const geom = feature.geometry;\n const text = feature.text ? feature.text.toString() : null;\n\n if (!text) {\n add(k);\n continue;\n }\n\n const leftKey = getKey(text, geom),\n rightKey = getKey(text, geom, true);\n\n if ((leftKey in rightIndex) && (rightKey in leftIndex) && (rightIndex[leftKey] !== leftIndex[rightKey])) {\n // found lines with the same text adjacent to both ends of the current line, merge all three\n const j = mergeFromLeft(leftKey, rightKey, geom);\n const i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry);\n\n delete leftIndex[leftKey];\n delete rightIndex[rightKey];\n\n rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i;\n mergedFeatures[j].geometry = null;\n\n } else if (leftKey in rightIndex) {\n // found mergeable line adjacent to the start of the current line, merge\n mergeFromRight(leftKey, rightKey, geom);\n\n } else if (rightKey in leftIndex) {\n // found mergeable line adjacent to the end of the current line, merge\n mergeFromLeft(leftKey, rightKey, geom);\n\n } else {\n // no adjacent lines, add as a new item\n add(k);\n leftIndex[leftKey] = mergedIndex - 1;\n rightIndex[rightKey] = mergedIndex - 1;\n }\n }\n\n return mergedFeatures.filter((f) => f.geometry);\n}\n","import {charHasRotatedVerticalOrientation} from './script_detection';\n\nexport const verticalizedCharacterMap = {\n '!': '︕',\n '#': '#',\n '$': '$',\n '%': '%',\n '&': '&',\n '(': '︵',\n ')': '︶',\n '*': '*',\n '+': '+',\n ',': '︐',\n '-': '︲',\n '.': '・',\n '/': '/',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '=': '=',\n '>': '﹀',\n '?': '︖',\n '@': '@',\n '[': '﹇',\n '\\\\': '\',\n ']': '﹈',\n '^': '^',\n '_': '︳',\n '`': '`',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '~': '~',\n '¢': '¢',\n '£': '£',\n '¥': '¥',\n '¦': '¦',\n '¬': '¬',\n '¯': ' ̄',\n '–': '︲',\n '—': '︱',\n '‘': '﹃',\n '’': '﹄',\n '“': '﹁',\n '”': '﹂',\n '…': '︙',\n '‧': '・',\n '₩': '₩',\n '、': '︑',\n '。': '︒',\n '〈': '︿',\n '〉': '﹀',\n '《': '︽',\n '》': '︾',\n '「': '﹁',\n '」': '﹂',\n '『': '﹃',\n '』': '﹄',\n '【': '︻',\n '】': '︼',\n '〔': '︹',\n '〕': '︺',\n '〖': '︗',\n '〗': '︘',\n '!': '︕',\n '(': '︵',\n ')': '︶',\n ',': '︐',\n '-': '︲',\n '.': '・',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '>': '﹀',\n '?': '︖',\n '[': '﹇',\n ']': '﹈',\n '_': '︳',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '⦅': '︵',\n '⦆': '︶',\n '。': '︒',\n '「': '﹁',\n '」': '﹂'\n};\n\nexport function verticalizePunctuation(input: string) {\n let output = '';\n\n for (let i = 0; i < input.length; i++) {\n const nextCharCode = input.charCodeAt(i + 1) || null;\n const prevCharCode = input.charCodeAt(i - 1) || null;\n\n const canReplacePunctuation = (\n (!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) &&\n (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]])\n );\n\n if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) {\n output += verticalizedCharacterMap[input[i]];\n } else {\n output += input[i];\n }\n }\n\n return output;\n}\n\n","// ONE_EM constant used to go between \"em\" units used in style spec and \"points\" used internally for layout\n\nexport default 24;\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","'use strict';\n\nmodule.exports = Pbf;\n\nvar ieee754 = require('ieee754');\n\nfunction Pbf(buf) {\n this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n}\n\nPbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum\nPbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64\nPbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields\nPbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32\n\nvar SHIFT_LEFT_32 = (1 << 16) * (1 << 16),\n SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n\n// Threshold chosen based on both benchmarking and knowledge about browser string\n// data structures (which currently switch structure types at 12 bytes or more)\nvar TEXT_DECODER_MIN_LENGTH = 12;\nvar utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');\n\nPbf.prototype = {\n\n destroy: function() {\n this.buf = null;\n },\n\n // === READING =================================================================\n\n readFields: function(readField, result, end) {\n end = end || this.length;\n\n while (this.pos < end) {\n var val = this.readVarint(),\n tag = val >> 3,\n startPos = this.pos;\n\n this.type = val & 0x7;\n readField(tag, result, this);\n\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n },\n\n readMessage: function(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n },\n\n readFixed32: function() {\n var val = readUInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n readSFixed32: function() {\n var val = readInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n\n readFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readSFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readFloat: function() {\n var val = ieee754.read(this.buf, this.pos, true, 23, 4);\n this.pos += 4;\n return val;\n },\n\n readDouble: function() {\n var val = ieee754.read(this.buf, this.pos, true, 52, 8);\n this.pos += 8;\n return val;\n },\n\n readVarint: function(isSigned) {\n var buf = this.buf,\n val, b;\n\n b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;\n b = buf[this.pos]; val |= (b & 0x0f) << 28;\n\n return readVarintRemainder(val, isSigned, this);\n },\n\n readVarint64: function() { // for compatibility with v2.0.1\n return this.readVarint(true);\n },\n\n readSVarint: function() {\n var num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding\n },\n\n readBoolean: function() {\n return Boolean(this.readVarint());\n },\n\n readString: function() {\n var end = this.readVarint() + this.pos;\n var pos = this.pos;\n this.pos = end;\n\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n // longer strings are fast with the built-in browser TextDecoder API\n return readUtf8TextDecoder(this.buf, pos, end);\n }\n // short strings are fast with our custom implementation\n return readUtf8(this.buf, pos, end);\n },\n\n readBytes: function() {\n var end = this.readVarint() + this.pos,\n buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n },\n\n // verbose for performance reasons; doesn't affect gzipped size\n\n readPackedVarint: function(arr, isSigned) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n },\n readPackedSVarint: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n },\n readPackedBoolean: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n },\n readPackedFloat: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n },\n readPackedDouble: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n },\n readPackedFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n },\n readPackedSFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n },\n readPackedFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n },\n readPackedSFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n },\n\n skip: function(val) {\n var type = val & 0x7;\n if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}\n else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;\n else if (type === Pbf.Fixed32) this.pos += 4;\n else if (type === Pbf.Fixed64) this.pos += 8;\n else throw new Error('Unimplemented type: ' + type);\n },\n\n // === WRITING =================================================================\n\n writeTag: function(tag, type) {\n this.writeVarint((tag << 3) | type);\n },\n\n realloc: function(min) {\n var length = this.length || 16;\n\n while (length < this.pos + min) length *= 2;\n\n if (length !== this.length) {\n var buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.length = length;\n }\n },\n\n finish: function() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n },\n\n writeFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeSFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeSFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeVarint: function(val) {\n val = +val || 0;\n\n if (val > 0xfffffff || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n\n this.realloc(4);\n\n this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = (val >>> 7) & 0x7f;\n },\n\n writeSVarint: function(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n },\n\n writeBoolean: function(val) {\n this.writeVarint(Boolean(val));\n },\n\n writeString: function(str) {\n str = String(str);\n this.realloc(str.length * 4);\n\n this.pos++; // reserve 1 byte for short string length\n\n var startPos = this.pos;\n // write the string directly to the buffer and see how much was written\n this.pos = writeUtf8(this.buf, str, this.pos);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeFloat: function(val) {\n this.realloc(4);\n ieee754.write(this.buf, val, this.pos, true, 23, 4);\n this.pos += 4;\n },\n\n writeDouble: function(val) {\n this.realloc(8);\n ieee754.write(this.buf, val, this.pos, true, 52, 8);\n this.pos += 8;\n },\n\n writeBytes: function(buffer) {\n var len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n },\n\n writeRawMessage: function(fn, obj) {\n this.pos++; // reserve 1 byte for short message length\n\n // write the message directly to the buffer and see how much was written\n var startPos = this.pos;\n fn(obj, this);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeMessage: function(tag, fn, obj) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeRawMessage(fn, obj);\n },\n\n writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },\n writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },\n writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },\n writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },\n writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },\n writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },\n writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },\n writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },\n writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },\n\n writeBytesField: function(tag, buffer) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeBytes(buffer);\n },\n writeFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFixed32(val);\n },\n writeSFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeSFixed32(val);\n },\n writeFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeFixed64(val);\n },\n writeSFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeSFixed64(val);\n },\n writeVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeVarint(val);\n },\n writeSVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeSVarint(val);\n },\n writeStringField: function(tag, str) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeString(str);\n },\n writeFloatField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFloat(val);\n },\n writeDoubleField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeDouble(val);\n },\n writeBooleanField: function(tag, val) {\n this.writeVarintField(tag, Boolean(val));\n }\n};\n\nfunction readVarintRemainder(l, s, p) {\n var buf = p.buf,\n h, b;\n\n b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);\n\n throw new Error('Expected varint not more than 10 bytes');\n}\n\nfunction readPackedEnd(pbf) {\n return pbf.type === Pbf.Bytes ?\n pbf.readVarint() + pbf.pos : pbf.pos + 1;\n}\n\nfunction toNum(low, high, isSigned) {\n if (isSigned) {\n return high * 0x100000000 + (low >>> 0);\n }\n\n return ((high >>> 0) * 0x100000000) + (low >>> 0);\n}\n\nfunction writeBigVarint(val, pbf) {\n var low, high;\n\n if (val >= 0) {\n low = (val % 0x100000000) | 0;\n high = (val / 0x100000000) | 0;\n } else {\n low = ~(-val % 0x100000000);\n high = ~(-val / 0x100000000);\n\n if (low ^ 0xffffffff) {\n low = (low + 1) | 0;\n } else {\n low = 0;\n high = (high + 1) | 0;\n }\n }\n\n if (val >= 0x10000000000000000 || val < -0x10000000000000000) {\n throw new Error('Given varint doesn\\'t fit into 10 bytes');\n }\n\n pbf.realloc(10);\n\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n}\n\nfunction writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos] = low & 0x7f;\n}\n\nfunction writeBigVarintHigh(high, pbf) {\n var lsb = (high & 0x07) << 4;\n\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f;\n}\n\nfunction makeRoomForExtraLength(startPos, len, pbf) {\n var extraLen =\n len <= 0x3fff ? 1 :\n len <= 0x1fffff ? 2 :\n len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n\n // if 1 byte isn't enough for encoding message length, shift the data to the right\n pbf.realloc(extraLen);\n for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n}\n\nfunction writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }\nfunction writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }\nfunction writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }\nfunction writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }\nfunction writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }\nfunction writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }\nfunction writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }\nfunction writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }\nfunction writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }\n\n// Buffer code below from https://github.com/feross/buffer, MIT-licensed\n\nfunction readUInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] * 0x1000000);\n}\n\nfunction writeInt32(buf, val, pos) {\n buf[pos] = val;\n buf[pos + 1] = (val >>> 8);\n buf[pos + 2] = (val >>> 16);\n buf[pos + 3] = (val >>> 24);\n}\n\nfunction readInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] << 24);\n}\n\nfunction readUtf8(buf, pos, end) {\n var str = '';\n var i = pos;\n\n while (i < end) {\n var b0 = buf[i];\n var c = null; // codepoint\n var bytesPerSequence =\n b0 > 0xEF ? 4 :\n b0 > 0xDF ? 3 :\n b0 > 0xBF ? 2 : 1;\n\n if (i + bytesPerSequence > end) break;\n\n var b1, b2, b3;\n\n if (bytesPerSequence === 1) {\n if (b0 < 0x80) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 0xC0) === 0x80) {\n c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);\n if (c <= 0x7F) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);\n if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);\n if (c <= 0xFFFF || c >= 0x110000) {\n c = null;\n }\n }\n }\n\n if (c === null) {\n c = 0xFFFD;\n bytesPerSequence = 1;\n\n } else if (c > 0xFFFF) {\n c -= 0x10000;\n str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);\n c = 0xDC00 | c & 0x3FF;\n }\n\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n\n return str;\n}\n\nfunction readUtf8TextDecoder(buf, pos, end) {\n return utf8TextDecoder.decode(buf.subarray(pos, end));\n}\n\nfunction writeUtf8(buf, str, pos) {\n for (var i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i); // code point\n\n if (c > 0xD7FF && c < 0xE000) {\n if (lead) {\n if (c < 0xDC00) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = c;\n continue;\n } else {\n c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;\n lead = null;\n }\n } else {\n if (c > 0xDBFF || (i + 1 === str.length)) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = null;\n }\n\n if (c < 0x80) {\n buf[pos++] = c;\n } else {\n if (c < 0x800) {\n buf[pos++] = c >> 0x6 | 0xC0;\n } else {\n if (c < 0x10000) {\n buf[pos++] = c >> 0xC | 0xE0;\n } else {\n buf[pos++] = c >> 0x12 | 0xF0;\n buf[pos++] = c >> 0xC & 0x3F | 0x80;\n }\n buf[pos++] = c >> 0x6 & 0x3F | 0x80;\n }\n buf[pos++] = c & 0x3F | 0x80;\n }\n }\n return pos;\n}\n","import {AlphaImage} from '../util/image';\n\nimport Protobuf from 'pbf';\nconst border = 3;\n\nimport type {StyleGlyph} from './style_glyph';\n\nfunction readFontstacks(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 1) {\n pbf.readMessage(readFontstack, glyphs);\n }\n}\n\nfunction readFontstack(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 3) {\n const {id, bitmap, width, height, left, top, advance} = pbf.readMessage(readGlyph, {});\n glyphs.push({\n id,\n bitmap: new AlphaImage({\n width: width + 2 * border,\n height: height + 2 * border\n }, bitmap),\n metrics: {width, height, left, top, advance}\n });\n }\n}\n\nfunction readGlyph(tag: number, glyph: any, pbf: Protobuf) {\n if (tag === 1) glyph.id = pbf.readVarint();\n else if (tag === 2) glyph.bitmap = pbf.readBytes();\n else if (tag === 3) glyph.width = pbf.readVarint();\n else if (tag === 4) glyph.height = pbf.readVarint();\n else if (tag === 5) glyph.left = pbf.readSVarint();\n else if (tag === 6) glyph.top = pbf.readSVarint();\n else if (tag === 7) glyph.advance = pbf.readVarint();\n}\n\nexport function parseGlyphPbf(data: ArrayBuffer | Uint8Array): Array {\n return new Protobuf(data).readFields(readFontstacks, []);\n}\n\nexport const GLYPH_PBF_BORDER = border;\n","\nexport default function potpack(boxes) {\n\n // calculate total box area and maximum box width\n let area = 0;\n let maxWidth = 0;\n\n for (const box of boxes) {\n area += box.w * box.h;\n maxWidth = Math.max(maxWidth, box.w);\n }\n\n // sort the boxes for insertion by height, descending\n boxes.sort((a, b) => b.h - a.h);\n\n // aim for a squarish resulting container,\n // slightly adjusted for sub-100% space utilization\n const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth);\n\n // start with a single empty space, unbounded at the bottom\n const spaces = [{x: 0, y: 0, w: startWidth, h: Infinity}];\n\n let width = 0;\n let height = 0;\n\n for (const box of boxes) {\n // look through spaces backwards so that we check smaller spaces first\n for (let i = spaces.length - 1; i >= 0; i--) {\n const space = spaces[i];\n\n // look for empty spaces that can accommodate the current box\n if (box.w > space.w || box.h > space.h) continue;\n\n // found the space; add the box to its top-left corner\n // |-------|-------|\n // | box | |\n // |_______| |\n // | space |\n // |_______________|\n box.x = space.x;\n box.y = space.y;\n\n height = Math.max(height, box.y + box.h);\n width = Math.max(width, box.x + box.w);\n\n if (box.w === space.w && box.h === space.h) {\n // space matches the box exactly; remove it\n const last = spaces.pop();\n if (i < spaces.length) spaces[i] = last;\n\n } else if (box.h === space.h) {\n // space matches the box height; update it accordingly\n // |-------|---------------|\n // | box | updated space |\n // |_______|_______________|\n space.x += box.w;\n space.w -= box.w;\n\n } else if (box.w === space.w) {\n // space matches the box width; update it accordingly\n // |---------------|\n // | box |\n // |_______________|\n // | updated space |\n // |_______________|\n space.y += box.h;\n space.h -= box.h;\n\n } else {\n // otherwise the box splits the space into two spaces\n // |-------|-----------|\n // | box | new space |\n // |_______|___________|\n // | updated space |\n // |___________________|\n spaces.push({\n x: space.x + box.w,\n y: space.y,\n w: space.w - box.w,\n h: box.h\n });\n space.y += box.h;\n space.h -= box.h;\n }\n break;\n }\n }\n\n return {\n w: width, // container width\n h: height, // container height\n fill: (area / (width * height)) || 0 // space utilization\n };\n}\n","/* eslint-disable key-spacing */\nimport {RGBAImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {ImageManager} from './image_manager';\nimport type {Texture} from './texture';\nimport type {Rect} from './glyph_atlas';\n\nconst IMAGE_PADDING: number = 1;\nexport {IMAGE_PADDING};\n\nexport class ImagePosition {\n paddedRect: Rect;\n pixelRatio: number;\n version: number;\n stretchY: Array<[number, number]>;\n stretchX: Array<[number, number]>;\n content: [number, number, number, number];\n\n constructor(paddedRect: Rect, {\n pixelRatio,\n version,\n stretchX,\n stretchY,\n content\n }: StyleImage) {\n this.paddedRect = paddedRect;\n this.pixelRatio = pixelRatio;\n this.stretchX = stretchX;\n this.stretchY = stretchY;\n this.content = content;\n this.version = version;\n }\n\n get tl(): [number, number] {\n return [\n this.paddedRect.x + IMAGE_PADDING,\n this.paddedRect.y + IMAGE_PADDING\n ];\n }\n\n get br(): [number, number] {\n return [\n this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING,\n this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING\n ];\n }\n\n get tlbr(): Array {\n return this.tl.concat(this.br);\n }\n\n get displaySize(): [number, number] {\n return [\n (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio,\n (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio\n ];\n }\n}\n\n/**\n * @internal\n * A class holding all the images\n */\nexport class ImageAtlas {\n image: RGBAImage;\n iconPositions: {[_: string]: ImagePosition};\n patternPositions: {[_: string]: ImagePosition};\n haveRenderCallbacks: Array;\n uploaded: boolean;\n\n constructor(icons: {[_: string]: StyleImage}, patterns: {[_: string]: StyleImage}) {\n const iconPositions = {}, patternPositions = {};\n this.haveRenderCallbacks = [];\n\n const bins = [];\n\n this.addImages(icons, iconPositions, bins);\n this.addImages(patterns, patternPositions, bins);\n\n const {w, h} = potpack(bins);\n const image = new RGBAImage({width: w || 1, height: h || 1});\n\n for (const id in icons) {\n const src = icons[id];\n const bin = iconPositions[id].paddedRect;\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: bin.x + IMAGE_PADDING, y: bin.y + IMAGE_PADDING}, src.data);\n }\n\n for (const id in patterns) {\n const src = patterns[id];\n const bin = patternPositions[id].paddedRect;\n const x = bin.x + IMAGE_PADDING,\n y = bin.y + IMAGE_PADDING,\n w = src.data.width,\n h = src.data.height;\n\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y}, src.data);\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src.data, image, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src.data, image, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.image = image;\n this.iconPositions = iconPositions;\n this.patternPositions = patternPositions;\n }\n\n addImages(images: {[_: string]: StyleImage}, positions: {[_: string]: ImagePosition}, bins: Array) {\n for (const id in images) {\n const src = images[id];\n const bin = {\n x: 0,\n y: 0,\n w: src.data.width + 2 * IMAGE_PADDING,\n h: src.data.height + 2 * IMAGE_PADDING,\n };\n bins.push(bin);\n positions[id] = new ImagePosition(bin, src);\n\n if (src.hasRenderCallback) {\n this.haveRenderCallbacks.push(id);\n }\n }\n }\n\n patchUpdatedImages(imageManager: ImageManager, texture: Texture) {\n imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks);\n for (const name in imageManager.updatedImages) {\n this.patchUpdatedImage(this.iconPositions[name], imageManager.getImage(name), texture);\n this.patchUpdatedImage(this.patternPositions[name], imageManager.getImage(name), texture);\n }\n }\n\n patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture) {\n if (!position || !image) return;\n\n if (position.version === image.version) return;\n\n position.version = image.version;\n const [x, y] = position.tl;\n texture.update(image.data, undefined, {x, y});\n }\n\n}\n\nregister('ImagePosition', ImagePosition);\nregister('ImageAtlas', ImageAtlas);\n","import {\n charHasUprightVerticalOrientation,\n charAllowsIdeographicBreaking,\n charInComplexShapingScript\n} from '../util/script_detection';\nimport {verticalizePunctuation} from '../util/verticalize_punctuation';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\nimport ONE_EM from './one_em';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleGlyph, GlyphMetrics} from '../style/style_glyph';\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\nimport type {ImagePosition} from '../render/image_atlas';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {Rect, GlyphPosition} from '../render/glyph_atlas';\nimport {Formatted, FormattedSection} from '@maplibre/maplibre-gl-style-spec';\n\nenum WritingMode {\n none = 0,\n horizontal = 1,\n vertical = 2,\n horizontalOnly = 3\n}\n\nconst SHAPING_DEFAULT_OFFSET = -17;\nexport {shapeText, shapeIcon, fitIconToText, getAnchorAlignment, WritingMode, SHAPING_DEFAULT_OFFSET};\n\n// The position of a glyph relative to the text's anchor point.\nexport type PositionedGlyph = {\n glyph: number;\n imageName: string | null;\n x: number;\n y: number;\n vertical: boolean;\n scale: number;\n fontStack: string;\n sectionIndex: number;\n metrics: GlyphMetrics;\n rect: Rect | null;\n};\n\nexport type PositionedLine = {\n positionedGlyphs: Array;\n lineOffset: number;\n};\n\n// A collection of positioned glyphs and some metadata\nexport type Shaping = {\n positionedLines: Array;\n top: number;\n bottom: number;\n left: number;\n right: number;\n writingMode: WritingMode.horizontal | WritingMode.vertical;\n text: string;\n iconsInText: boolean;\n verticalizable: boolean;\n};\n\nfunction isEmpty(positionedLines: Array) {\n for (const line of positionedLines) {\n if (line.positionedGlyphs.length !== 0) {\n return false;\n }\n }\n return true;\n}\n\nexport type SymbolAnchor = 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\nexport type TextJustify = 'left' | 'center' | 'right';\n\n// Max number of images in label is 6401 U+E000–U+F8FF that covers\n// Basic Multilingual Plane Unicode Private Use Area (PUA).\nconst PUAbegin = 0xE000;\nconst PUAend = 0xF8FF;\n\nclass SectionOptions {\n // Text options\n scale: number;\n fontStack: string;\n // Image options\n imageName: string | null;\n\n constructor() {\n this.scale = 1.0;\n this.fontStack = '';\n this.imageName = null;\n }\n\n static forText(scale: number | null, fontStack: string) {\n const textOptions = new SectionOptions();\n textOptions.scale = scale || 1;\n textOptions.fontStack = fontStack;\n return textOptions;\n }\n\n static forImage(imageName: string) {\n const imageOptions = new SectionOptions();\n imageOptions.imageName = imageName;\n return imageOptions;\n }\n\n}\n\nclass TaggedString {\n text: string;\n sectionIndex: Array; // maps each character in 'text' to its corresponding entry in 'sections'\n sections: Array;\n imageSectionID: number | null;\n\n constructor() {\n this.text = '';\n this.sectionIndex = [];\n this.sections = [];\n this.imageSectionID = null;\n }\n\n static fromFeature(text: Formatted, defaultFontStack: string) {\n const result = new TaggedString();\n for (let i = 0; i < text.sections.length; i++) {\n const section = text.sections[i];\n if (!section.image) {\n result.addTextSection(section, defaultFontStack);\n } else {\n result.addImageSection(section);\n }\n }\n return result;\n }\n\n length(): number {\n return this.text.length;\n }\n\n getSection(index: number): SectionOptions {\n return this.sections[this.sectionIndex[index]];\n }\n\n getSectionIndex(index: number): number {\n return this.sectionIndex[index];\n }\n\n getCharCode(index: number): number {\n return this.text.charCodeAt(index);\n }\n\n verticalizePunctuation() {\n this.text = verticalizePunctuation(this.text);\n }\n\n trim() {\n let beginningWhitespace = 0;\n for (let i = 0;\n i < this.text.length && whitespace[this.text.charCodeAt(i)];\n i++) {\n beginningWhitespace++;\n }\n let trailingWhitespace = this.text.length;\n for (let i = this.text.length - 1;\n i >= 0 && i >= beginningWhitespace && whitespace[this.text.charCodeAt(i)];\n i--) {\n trailingWhitespace--;\n }\n this.text = this.text.substring(beginningWhitespace, trailingWhitespace);\n this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace);\n }\n\n substring(start: number, end: number): TaggedString {\n const substring = new TaggedString();\n substring.text = this.text.substring(start, end);\n substring.sectionIndex = this.sectionIndex.slice(start, end);\n substring.sections = this.sections;\n return substring;\n }\n\n toString(): string {\n return this.text;\n }\n\n getMaxScale() {\n return this.sectionIndex.reduce((max, index) => Math.max(max, this.sections[index].scale), 0);\n }\n\n addTextSection(section: FormattedSection, defaultFontStack: string) {\n this.text += section.text;\n this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack));\n const index = this.sections.length - 1;\n for (let i = 0; i < section.text.length; ++i) {\n this.sectionIndex.push(index);\n }\n }\n\n addImageSection(section: FormattedSection) {\n const imageName = section.image ? section.image.name : '';\n if (imageName.length === 0) {\n warnOnce('Can\\'t add FormattedSection with an empty image.');\n return;\n }\n\n const nextImageSectionCharCode = this.getNextImageSectionCharCode();\n if (!nextImageSectionCharCode) {\n warnOnce(`Reached maximum number of images ${PUAend - PUAbegin + 2}`);\n return;\n }\n\n this.text += String.fromCharCode(nextImageSectionCharCode);\n this.sections.push(SectionOptions.forImage(imageName));\n this.sectionIndex.push(this.sections.length - 1);\n }\n\n getNextImageSectionCharCode(): number | null {\n if (!this.imageSectionID) {\n this.imageSectionID = PUAbegin;\n return this.imageSectionID;\n }\n\n if (this.imageSectionID >= PUAend) return null;\n return ++this.imageSectionID;\n }\n}\n\nfunction breakLines(input: TaggedString, lineBreakPoints: Array): Array {\n const lines = [];\n const text = input.text;\n let start = 0;\n for (const lineBreak of lineBreakPoints) {\n lines.push(input.substring(start, lineBreak));\n start = lineBreak;\n }\n\n if (start < text.length) {\n lines.push(input.substring(start, text.length));\n }\n return lines;\n}\n\nfunction shapeText(\n text: Formatted,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n defaultFontStack: string,\n maxWidth: number,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n spacing: number,\n translate: [number, number],\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n allowVerticalPlacement: boolean,\n symbolPlacement: string,\n layoutTextSize: number,\n layoutTextSizeThisZoom: number\n): Shaping | false {\n const logicalInput = TaggedString.fromFeature(text, defaultFontStack);\n\n if (writingMode === WritingMode.vertical) {\n logicalInput.verticalizePunctuation();\n }\n\n let lines: Array;\n\n const {processBidirectionalText, processStyledBidirectionalText} = rtlTextPlugin;\n if (processBidirectionalText && logicalInput.sections.length === 1) {\n // Bidi doesn't have to be style-aware\n lines = [];\n const untaggedLines =\n processBidirectionalText(logicalInput.toString(),\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of untaggedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line;\n taggedLine.sections = logicalInput.sections;\n for (let i = 0; i < line.length; i++) {\n taggedLine.sectionIndex.push(0);\n }\n lines.push(taggedLine);\n }\n } else if (processStyledBidirectionalText) {\n // Need version of mapbox-gl-rtl-text with style support for combining RTL text\n // with formatting\n lines = [];\n const processedLines =\n processStyledBidirectionalText(logicalInput.text,\n logicalInput.sectionIndex,\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of processedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line[0];\n taggedLine.sectionIndex = line[1];\n taggedLine.sections = logicalInput.sections;\n lines.push(taggedLine);\n }\n } else {\n lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n }\n\n const positionedLines = [];\n const shaping = {\n positionedLines,\n text: logicalInput.toString(),\n top: translate[1],\n bottom: translate[1],\n left: translate[0],\n right: translate[0],\n writingMode,\n iconsInText: false,\n verticalizable: false\n };\n\n shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom);\n if (isEmpty(positionedLines)) return false;\n\n return shaping;\n}\n\n// using computed properties due to https://github.com/facebook/flow/issues/380\n/* eslint no-useless-computed-key: 0 */\n\nconst whitespace: {\n [_: number]: boolean;\n} = {\n [0x09]: true, // tab\n [0x0a]: true, // newline\n [0x0b]: true, // vertical tab\n [0x0c]: true, // form feed\n [0x0d]: true, // carriage return\n [0x20]: true, // space\n};\n\nconst breakable: {\n [_: number]: boolean;\n} = {\n [0x0a]: true, // newline\n [0x20]: true, // space\n [0x26]: true, // ampersand\n [0x28]: true, // left parenthesis\n [0x29]: true, // right parenthesis\n [0x2b]: true, // plus sign\n [0x2d]: true, // hyphen-minus\n [0x2f]: true, // solidus\n [0xad]: true, // soft hyphen\n [0xb7]: true, // middle dot\n [0x200b]: true, // zero-width space\n [0x2010]: true, // hyphen\n [0x2013]: true, // en dash\n [0x2027]: true // interpunct\n // Many other characters may be reasonable breakpoints\n // Consider \"neutral orientation\" characters at scriptDetection.charHasNeutralVerticalOrientation\n // See https://github.com/mapbox/mapbox-gl-js/issues/3658\n};\n\nfunction getGlyphAdvance(\n codePoint: number,\n section: SectionOptions,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n spacing: number,\n layoutTextSize: number\n): number {\n if (!section.imageName) {\n const positions = glyphMap[section.fontStack];\n const glyph = positions && positions[codePoint];\n if (!glyph) return 0;\n return glyph.metrics.advance * section.scale + spacing;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) return 0;\n return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing;\n }\n}\n\nfunction determineAverageLineWidth(logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n layoutTextSize: number) {\n let totalWidth = 0;\n\n for (let index = 0; index < logicalInput.length(); index++) {\n const section = logicalInput.getSection(index);\n totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize);\n }\n\n const lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth));\n return totalWidth / lineCount;\n}\n\nfunction calculateBadness(lineWidth: number,\n targetWidth: number,\n penalty: number,\n isLastBreak: boolean) {\n const raggedness = Math.pow(lineWidth - targetWidth, 2);\n if (isLastBreak) {\n // Favor finals lines shorter than average over longer than average\n if (lineWidth < targetWidth) {\n return raggedness / 2;\n } else {\n return raggedness * 2;\n }\n }\n\n return raggedness + Math.abs(penalty) * penalty;\n}\n\nfunction calculatePenalty(codePoint: number, nextCodePoint: number, penalizableIdeographicBreak: boolean) {\n let penalty = 0;\n // Force break on newline\n if (codePoint === 0x0a) {\n penalty -= 10000;\n }\n // Penalize breaks between characters that allow ideographic breaking because\n // they are less preferable than breaks at spaces (or zero width spaces).\n if (penalizableIdeographicBreak) {\n penalty += 150;\n }\n\n // Penalize open parenthesis at end of line\n if (codePoint === 0x28 || codePoint === 0xff08) {\n penalty += 50;\n }\n\n // Penalize close parenthesis at beginning of line\n if (nextCodePoint === 0x29 || nextCodePoint === 0xff09) {\n penalty += 50;\n }\n return penalty;\n}\n\ntype Break = {\n index: number;\n x: number;\n priorBreak: Break;\n badness: number;\n};\n\nfunction evaluateBreak(\n breakIndex: number,\n breakX: number,\n targetWidth: number,\n potentialBreaks: Array,\n penalty: number,\n isLastBreak: boolean\n): Break {\n // We could skip evaluating breaks where the line length (breakX - priorBreak.x) > maxWidth\n // ...but in fact we allow lines longer than maxWidth (if there's no break points)\n // ...and when targetWidth and maxWidth are close, strictly enforcing maxWidth can give\n // more lopsided results.\n\n let bestPriorBreak: Break = null;\n let bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak);\n\n for (const potentialBreak of potentialBreaks) {\n const lineWidth = breakX - potentialBreak.x;\n const breakBadness =\n calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness;\n if (breakBadness <= bestBreakBadness) {\n bestPriorBreak = potentialBreak;\n bestBreakBadness = breakBadness;\n }\n }\n\n return {\n index: breakIndex,\n x: breakX,\n priorBreak: bestPriorBreak,\n badness: bestBreakBadness\n };\n}\n\nfunction leastBadBreaks(lastLineBreak?: Break | null): Array {\n if (!lastLineBreak) {\n return [];\n }\n return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index);\n}\n\nfunction determineLineBreaks(\n logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n symbolPlacement: string,\n layoutTextSize: number\n): Array {\n if (symbolPlacement !== 'point')\n return [];\n\n if (!logicalInput)\n return [];\n\n const potentialLineBreaks = [];\n const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize);\n\n const hasServerSuggestedBreakpoints = logicalInput.text.indexOf('\\u200b') >= 0;\n\n let currentX = 0;\n\n for (let i = 0; i < logicalInput.length(); i++) {\n const section = logicalInput.getSection(i);\n const codePoint = logicalInput.getCharCode(i);\n if (!whitespace[codePoint]) currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize);\n\n // Ideographic characters, spaces, and word-breaking punctuation that often appear without\n // surrounding spaces.\n if ((i < logicalInput.length() - 1)) {\n const ideographicBreak = charAllowsIdeographicBreaking(codePoint);\n if (breakable[codePoint] || ideographicBreak || section.imageName) {\n\n potentialLineBreaks.push(\n evaluateBreak(\n i + 1,\n currentX,\n targetWidth,\n potentialLineBreaks,\n calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints),\n false));\n }\n }\n }\n\n return leastBadBreaks(\n evaluateBreak(\n logicalInput.length(),\n currentX,\n targetWidth,\n potentialLineBreaks,\n 0,\n true));\n}\n\nfunction getAnchorAlignment(anchor: SymbolAnchor) {\n let horizontalAlign = 0.5, verticalAlign = 0.5;\n\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n horizontalAlign = 1;\n break;\n case 'left':\n case 'top-left':\n case 'bottom-left':\n horizontalAlign = 0;\n break;\n }\n\n switch (anchor) {\n case 'bottom':\n case 'bottom-right':\n case 'bottom-left':\n verticalAlign = 1;\n break;\n case 'top':\n case 'top-right':\n case 'top-left':\n verticalAlign = 0;\n break;\n }\n\n return {horizontalAlign, verticalAlign};\n}\n\nfunction shapeLines(shaping: Shaping,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n lines: Array,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n spacing: number,\n allowVerticalPlacement: boolean,\n layoutTextSizeThisZoom: number) {\n\n let x = 0;\n let y = SHAPING_DEFAULT_OFFSET;\n\n let maxLineLength = 0;\n let maxLineHeight = 0;\n\n const justify =\n textJustify === 'right' ? 1 :\n textJustify === 'left' ? 0 : 0.5;\n\n let lineIndex = 0;\n for (const line of lines) {\n line.trim();\n\n const lineMaxScale = line.getMaxScale();\n const maxLineOffset = (lineMaxScale - 1) * ONE_EM;\n const positionedLine = {positionedGlyphs: [], lineOffset: 0};\n shaping.positionedLines[lineIndex] = positionedLine;\n const positionedGlyphs = positionedLine.positionedGlyphs;\n let lineOffset = 0.0;\n\n if (!line.length()) {\n y += lineHeight; // Still need a line feed after empty line\n ++lineIndex;\n continue;\n }\n\n for (let i = 0; i < line.length(); i++) {\n const section = line.getSection(i);\n const sectionIndex = line.getSectionIndex(i);\n const codePoint = line.getCharCode(i);\n let baselineOffset = 0.0;\n let metrics = null;\n let rect = null;\n let imageName = null;\n let verticalAdvance = ONE_EM;\n const vertical = !(writingMode === WritingMode.horizontal ||\n // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled.\n (!allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint)) ||\n // If vertical placement is enabled, don't verticalize glyphs that\n // are from complex text layout script, or whitespaces.\n (allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint))));\n\n if (!section.imageName) {\n const positions = glyphPositions[section.fontStack];\n const glyphPosition = positions && positions[codePoint];\n if (glyphPosition && glyphPosition.rect) {\n rect = glyphPosition.rect;\n metrics = glyphPosition.metrics;\n } else {\n const glyphs = glyphMap[section.fontStack];\n const glyph = glyphs && glyphs[codePoint];\n if (!glyph) continue;\n metrics = glyph.metrics;\n }\n\n // We don't know the baseline, but since we're laying out\n // at 24 points, we can calculate how much it will move when\n // we scale up or down.\n baselineOffset = (lineMaxScale - section.scale) * ONE_EM;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) continue;\n imageName = section.imageName;\n shaping.iconsInText = shaping.iconsInText || true;\n rect = imagePosition.paddedRect;\n const size = imagePosition.displaySize;\n // If needed, allow to set scale factor for an image using\n // alias \"image-scale\" that could be alias for \"font-scale\"\n // when FormattedSection is an image section.\n section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom;\n\n metrics = {width: size[0],\n height: size[1],\n left: IMAGE_PADDING,\n top: -GLYPH_PBF_BORDER,\n advance: vertical ? size[1] : size[0]};\n\n // Difference between one EM and an image size.\n // Aligns bottom of an image to a baseline level.\n const imageOffset = ONE_EM - size[1] * section.scale;\n baselineOffset = maxLineOffset + imageOffset;\n verticalAdvance = metrics.advance;\n\n // Difference between height of an image and one EM at max line scale.\n // Pushes current line down if an image size is over 1 EM at max line scale.\n const offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale :\n size[1] * section.scale - ONE_EM * lineMaxScale;\n if (offset > 0 && offset > lineOffset) {\n lineOffset = offset;\n }\n }\n\n if (!vertical) {\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += metrics.advance * section.scale + spacing;\n } else {\n shaping.verticalizable = true;\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += verticalAdvance * section.scale + spacing;\n }\n }\n\n // Only justify if we placed at least one glyph\n if (positionedGlyphs.length !== 0) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset);\n }\n\n x = 0;\n const currentLineHeight = lineHeight * lineMaxScale + lineOffset;\n positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset);\n y += currentLineHeight;\n maxLineHeight = Math.max(currentLineHeight, maxLineHeight);\n ++lineIndex;\n }\n\n // Calculate the bounding box and justify / align text block.\n const height = y - SHAPING_DEFAULT_OFFSET;\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(textAnchor);\n align(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length);\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top + height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\n// justify right = 1, left = 0, center = 0.5\nfunction justifyLine(positionedGlyphs: Array,\n start: number,\n end: number,\n justify: 1 | 0 | 0.5,\n lineOffset: number) {\n if (!justify && !lineOffset)\n return;\n\n const lastPositionedGlyph = positionedGlyphs[end];\n const lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale;\n const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;\n\n for (let j = start; j <= end; j++) {\n positionedGlyphs[j].x -= lineIndent;\n positionedGlyphs[j].y += lineOffset;\n }\n}\n\nfunction align(positionedLines: Array,\n justify: number,\n horizontalAlign: number,\n verticalAlign: number,\n maxLineLength: number,\n maxLineHeight: number,\n lineHeight: number,\n blockHeight: number,\n lineCount: number) {\n const shiftX = (justify - horizontalAlign) * maxLineLength;\n let shiftY = 0;\n\n if (maxLineHeight !== lineHeight) {\n shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET;\n } else {\n shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;\n }\n\n for (const line of positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n positionedGlyph.x += shiftX;\n positionedGlyph.y += shiftY;\n }\n }\n}\n\nexport type PositionedIcon = {\n image: ImagePosition;\n top: number;\n bottom: number;\n left: number;\n right: number;\n collisionPadding?: [number, number, number, number];\n};\n\nfunction shapeIcon(\n image: ImagePosition,\n iconOffset: [number, number],\n iconAnchor: SymbolAnchor\n): PositionedIcon {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(iconAnchor);\n const dx = iconOffset[0];\n const dy = iconOffset[1];\n const x1 = dx - image.displaySize[0] * horizontalAlign;\n const x2 = x1 + image.displaySize[0];\n const y1 = dy - image.displaySize[1] * verticalAlign;\n const y2 = y1 + image.displaySize[1];\n return {image, top: y1, bottom: y2, left: x1, right: x2};\n}\n\nfunction fitIconToText(\n shapedIcon: PositionedIcon,\n shapedText: Shaping,\n textFit: string,\n padding: [number, number, number, number],\n iconOffset: [number, number],\n fontScale: number\n): PositionedIcon {\n\n const image = shapedIcon.image;\n\n let collisionPadding;\n if (image.content) {\n const content = image.content;\n const pixelRatio = image.pixelRatio || 1;\n collisionPadding = [\n content[0] / pixelRatio,\n content[1] / pixelRatio,\n image.displaySize[0] - content[2] / pixelRatio,\n image.displaySize[1] - content[3] / pixelRatio\n ];\n }\n\n // We don't respect the icon-anchor, because icon-text-fit is set. Instead,\n // the icon will be centered on the text, then stretched in the given\n // dimensions.\n\n const textLeft = shapedText.left * fontScale;\n const textRight = shapedText.right * fontScale;\n\n let top, right, bottom, left;\n if (textFit === 'width' || textFit === 'both') {\n // Stretched horizontally to the text width\n left = iconOffset[0] + textLeft - padding[3];\n right = iconOffset[0] + textRight + padding[1];\n } else {\n // Centered on the text\n left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2;\n right = left + image.displaySize[0];\n }\n\n const textTop = shapedText.top * fontScale;\n const textBottom = shapedText.bottom * fontScale;\n if (textFit === 'height' || textFit === 'both') {\n // Stretched vertically to the text height\n top = iconOffset[1] + textTop - padding[0];\n bottom = iconOffset[1] + textBottom + padding[2];\n } else {\n // Centered on the text\n top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2;\n bottom = top + image.displaySize[1];\n }\n\n return {image, top, right, bottom, left, collisionPadding};\n}\n","import {Interpolate, interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {clamp} from '../util/util';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\n\nimport type {PropertyValue, PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport type {InterpolationType} from '@maplibre/maplibre-gl-style-spec';\n\nconst MAX_GLYPH_ICON_SIZE = 255;\nconst SIZE_PACK_FACTOR = 128;\nconst MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;\n\nexport {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR, MAX_GLYPH_ICON_SIZE, MAX_PACKED_SIZE};\n\nexport type SizeData = {\n kind: 'constant';\n layoutSize: number;\n} | {\n kind: 'source';\n} | {\n kind: 'camera';\n minZoom: number;\n maxZoom: number;\n minSize: number;\n maxSize: number;\n interpolationType: InterpolationType;\n} | {\n kind: 'composite';\n minZoom: number;\n maxZoom: number;\n interpolationType: InterpolationType;\n};\n\nexport type EvaluatedZoomSize = {uSizeT: number; uSize: number};\n\n// For {text,icon}-size, get the bucket-level data that will be needed by\n// the painter to set symbol-size-related uniforms\nfunction getSizeData(\n tileZoom: number,\n value: PropertyValue>\n): SizeData {\n const {expression} = value;\n\n if (expression.kind === 'constant') {\n const layoutSize = expression.evaluate(new EvaluationParameters(tileZoom + 1));\n return {kind: 'constant', layoutSize};\n\n } else if (expression.kind === 'source') {\n return {kind: 'source'};\n\n } else {\n const {zoomStops, interpolationType} = expression;\n\n // calculate covering zoom stops for zoom-dependent values\n let lower = 0;\n while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) lower++;\n lower = Math.max(0, lower - 1);\n let upper = lower;\n while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) upper++;\n upper = Math.min(zoomStops.length - 1, upper);\n\n const minZoom = zoomStops[lower];\n const maxZoom = zoomStops[upper];\n\n // We'd like to be able to use CameraExpression or CompositeExpression in these\n // return types rather than ExpressionSpecification, but the former are not\n // transferrable across Web Worker boundaries.\n if (expression.kind === 'composite') {\n return {kind: 'composite', minZoom, maxZoom, interpolationType};\n }\n\n // for camera functions, also save off the function values\n // evaluated at the covering zoom levels\n const minSize = expression.evaluate(new EvaluationParameters(minZoom));\n const maxSize = expression.evaluate(new EvaluationParameters(maxZoom));\n\n return {kind: 'camera', minZoom, maxZoom, minSize, maxSize, interpolationType};\n }\n}\n\nfunction evaluateSizeForFeature(sizeData: SizeData,\n {\n uSize,\n uSizeT\n }: {\n uSize: number;\n uSizeT: number;\n },\n {\n lowerSize,\n upperSize\n }: {\n lowerSize: number;\n upperSize: number;\n }): number {\n if (sizeData.kind === 'source') {\n return lowerSize / SIZE_PACK_FACTOR;\n } else if (sizeData.kind === 'composite') {\n return interpolates.number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT);\n }\n return uSize;\n}\n\nfunction evaluateSizeForZoom(sizeData: SizeData, zoom: number): EvaluatedZoomSize {\n let uSizeT = 0;\n let uSize = 0;\n\n if (sizeData.kind === 'constant') {\n uSize = sizeData.layoutSize;\n\n } else if (sizeData.kind !== 'source') {\n const {interpolationType, minZoom, maxZoom} = sizeData;\n\n // Even though we could get the exact value of the camera function\n // at z = tr.zoom, we intentionally do not: instead, we interpolate\n // between the camera function values at a pair of zoom stops covering\n // [tileZoom, tileZoom + 1] in order to be consistent with this\n // restriction on composite functions\n const t = !interpolationType ? 0 : clamp(\n Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1);\n\n if (sizeData.kind === 'camera') {\n uSize = interpolates.number(sizeData.minSize, sizeData.maxSize, t);\n } else {\n uSizeT = t;\n }\n }\n\n return {uSizeT, uSize};\n}\n","import {SymbolLayoutPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\nimport type {SymbolLayoutProps} from './symbol_style_layer_properties.g';\nimport {PossiblyEvaluated} from '../properties';\n\n/**\n * The overlap mode for properties like `icon-overlap`and `text-overlap`\n */\nexport type OverlapMode = 'never' | 'always' | 'cooperative';\n\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap', allowOverlapProp: 'icon-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'text-overlap', allowOverlapProp: 'text-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap' | 'text-overlap', allowOverlapProp: 'icon-allow-overlap' | 'text-allow-overlap'): OverlapMode {\n let result: OverlapMode = 'never';\n const overlap = layout.get(overlapProp);\n\n if (overlap) {\n // if -overlap is set, use it\n result = overlap;\n } else if (layout.get(allowOverlapProp)) {\n // fall back to -allow-overlap, with false='never', true='always'\n result = 'always';\n }\n\n return result;\n}\n","import {\n symbolLayoutAttributes,\n collisionVertexAttributes,\n collisionBoxLayout,\n dynamicLayoutAttributes,\n} from './symbol_attributes';\n\nimport {SymbolLayoutArray,\n SymbolDynamicLayoutArray,\n SymbolOpacityArray,\n CollisionBoxLayoutArray,\n CollisionVertexArray,\n PlacedSymbolArray,\n SymbolInstanceArray,\n GlyphOffsetArray,\n SymbolLineVertexArray,\n TextAnchorOffsetArray\n} from '../array_types.g';\n\nimport Point from '@mapbox/point-geometry';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray, LineIndexArray} from '../index_array_type';\nimport {transformText} from '../../symbol/transform_text';\nimport {mergeLines} from '../../symbol/merge_lines';\nimport {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';\nimport {WritingMode} from '../../symbol/shaping';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {verticalizedCharacterMap} from '../../util/verticalize_punctuation';\nimport {Anchor} from '../../symbol/anchor';\nimport {getSizeData, MAX_PACKED_SIZE} from '../../symbol/symbol_size';\n\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\nimport {Formatted, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';\nimport {mat4} from 'gl-matrix';\nimport {getOverlapMode} from '../../style/style_layer/overlap_mode';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types.g';\nimport type {StructArray, StructArrayMember, ViewType} from '../../util/struct_array';\nimport type {SymbolStyleLayer} from '../../style/style_layer/symbol_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {SymbolQuad} from '../../symbol/quads';\nimport type {SizeData} from '../../symbol/symbol_size';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type SingleCollisionBox = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n anchorPointX: number;\n anchorPointY: number;\n};\n\nexport type CollisionArrays = {\n textBox?: SingleCollisionBox;\n verticalTextBox?: SingleCollisionBox;\n iconBox?: SingleCollisionBox;\n verticalIconBox?: SingleCollisionBox;\n textFeatureIndex?: number;\n verticalTextFeatureIndex?: number;\n iconFeatureIndex?: number;\n verticalIconFeatureIndex?: number;\n};\n\nexport type SymbolFeature = {\n sortKey: number | void;\n text: Formatted | void;\n icon: ResolvedImage;\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 'Unknown' | 'Point' | 'LineString' | 'Polygon';\n id?: any;\n};\n\nexport type SortKeyRange = {\n sortKey: number;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n};\n\n// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them\n// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph\n// 7 bits are for the current opacity, and the lowest bit is the target opacity\n\n// actually defined in symbol_attributes.js\n// const placementOpacityAttributes = [\n// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }\n// ];\nconst shaderOpacityAttributes = [\n {name: 'a_fade_opacity', components: 1, type: 'Uint8' as ViewType, offset: 0}\n];\n\nfunction addVertex(\n array: StructArray,\n anchorX: number,\n anchorY: number,\n ox: number,\n oy: number,\n tx: number,\n ty: number,\n sizeVertex: number,\n isSDF: boolean,\n pixelOffsetX: number,\n pixelOffsetY: number,\n minFontScaleX: number,\n minFontScaleY: number\n) {\n const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;\n const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;\n array.emplaceBack(\n // a_pos_offset\n anchorX,\n anchorY,\n Math.round(ox * 32),\n Math.round(oy * 32),\n\n // a_data\n tx, // x coordinate of symbol on glyph atlas texture\n ty, // y coordinate of symbol on glyph atlas texture\n (aSizeX << 1) + (isSDF ? 1 : 0),\n aSizeY,\n pixelOffsetX * 16,\n pixelOffsetY * 16,\n minFontScaleX * 256,\n minFontScaleY * 256\n );\n}\n\nfunction addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) {\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n}\n\nfunction containsRTLText(formattedText: Formatted): boolean {\n for (const section of formattedText.sections) {\n if (stringContainsRTLText(section.text)) {\n return true;\n }\n }\n return false;\n}\n\nexport class SymbolBuffers {\n layoutVertexArray: SymbolLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n\n dynamicLayoutVertexArray: SymbolDynamicLayoutArray;\n dynamicLayoutVertexBuffer: VertexBuffer;\n\n opacityVertexArray: SymbolOpacityArray;\n opacityVertexBuffer: VertexBuffer;\n hasVisibleVertices: boolean;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n placedSymbolArray: PlacedSymbolArray;\n\n constructor(programConfigurations: ProgramConfigurationSet) {\n this.layoutVertexArray = new SymbolLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = programConfigurations;\n this.segments = new SegmentVector();\n this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();\n this.opacityVertexArray = new SymbolOpacityArray();\n this.hasVisibleVertices = false;\n this.placedSymbolArray = new PlacedSymbolArray();\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 &&\n this.indexArray.length === 0 &&\n this.dynamicLayoutVertexArray.length === 0 &&\n this.opacityVertexArray.length === 0;\n }\n\n upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) {\n if (this.isEmpty()) {\n return;\n }\n\n if (upload) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);\n this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);\n this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);\n this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);\n // This is a performance hack so that we can write to opacityVertexArray with uint32s\n // even though the shaders read uint8s\n this.opacityVertexBuffer.itemSize = 1;\n }\n if (upload || update) {\n this.programConfigurations.upload(context);\n }\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.dynamicLayoutVertexBuffer.destroy();\n this.opacityVertexBuffer.destroy();\n }\n}\n\nregister('SymbolBuffers', SymbolBuffers);\n\nclass CollisionBuffers {\n layoutVertexArray: StructArray;\n layoutAttributes: Array;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray | LineIndexArray;\n indexBuffer: IndexBuffer;\n\n segments: SegmentVector;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n constructor(LayoutArray: {\n new (...args: any): StructArray;\n },\n layoutAttributes: Array,\n IndexArray: {\n new (...args: any): TriangleIndexArray | LineIndexArray;\n }) {\n this.layoutVertexArray = new LayoutArray();\n this.layoutAttributes = layoutAttributes;\n this.indexArray = new IndexArray();\n this.segments = new SegmentVector();\n this.collisionVertexArray = new CollisionVertexArray();\n }\n\n upload(context: Context) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.segments.destroy();\n this.collisionVertexBuffer.destroy();\n }\n}\n\nregister('CollisionBuffers', CollisionBuffers);\n\n/**\n * @internal\n * Unlike other buckets, which simply implement #addFeature with type-specific\n * logic for (essentially) triangulating feature geometries, SymbolBucket\n * requires specialized behavior:\n *\n * 1. WorkerTile#parse(), the logical owner of the bucket creation process,\n * calls SymbolBucket#populate(), which resolves text and icon tokens on\n * each feature, adds each glyphs and symbols needed to the passed-in\n * collections options.glyphDependencies and options.iconDependencies, and\n * stores the feature data for use in subsequent step (this.features).\n *\n * 2. WorkerTile asynchronously requests from the main thread all of the glyphs\n * and icons needed (by this bucket and any others). When glyphs and icons\n * have been received, the WorkerTile creates a CollisionIndex and invokes:\n *\n * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and\n * layout on a Symbol Bucket. This step populates:\n * `this.symbolInstances`: metadata on generated symbols\n * `this.collisionBoxArray`: collision data for use by foreground\n * `this.text`: SymbolBuffers for text symbols\n * `this.icons`: SymbolBuffers for icons\n * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes\n * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes\n * The results are sent to the foreground for rendering\n *\n * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,\n * and uses the CollisionIndex along with current camera settings to determine\n * which symbols can actually show on the map. Collided symbols are hidden\n * using a dynamic \"OpacityVertexArray\".\n */\nexport class SymbolBucket implements Bucket {\n static MAX_GLYPHS: number;\n static addDynamicAttributes: typeof addDynamicAttributes;\n\n collisionBoxArray: CollisionBoxArray;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n index: number;\n sdfIcons: boolean;\n iconsInText: boolean;\n iconsNeedLinear: boolean;\n bucketInstanceId: number;\n justReloaded: boolean;\n hasPattern: boolean;\n\n textSizeData: SizeData;\n iconSizeData: SizeData;\n\n glyphOffsetArray: GlyphOffsetArray;\n lineVertexArray: SymbolLineVertexArray;\n features: Array;\n symbolInstances: SymbolInstanceArray;\n textAnchorOffsets: TextAnchorOffsetArray;\n collisionArrays: Array;\n sortKeyRanges: Array;\n pixelRatio: number;\n tilePixelRatio: number;\n compareText: {[_: string]: Array};\n fadeStartTime: number;\n sortFeaturesByKey: boolean;\n sortFeaturesByY: boolean;\n canOverlap: boolean;\n sortedAngle: number;\n featureSortOrder: Array;\n\n collisionCircleArray: Array;\n placementInvProjMatrix: mat4;\n placementViewportMatrix: mat4;\n\n text: SymbolBuffers;\n icon: SymbolBuffers;\n textCollisionBox: CollisionBuffers;\n iconCollisionBox: CollisionBuffers;\n uploaded: boolean;\n sourceLayerIndex: number;\n sourceID: string;\n symbolInstanceIndexes: Array;\n writingModes: WritingMode[];\n allowVerticalPlacement: boolean;\n hasRTLText: boolean;\n\n constructor(options: BucketParameters) {\n this.collisionBoxArray = options.collisionBoxArray;\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.pixelRatio = options.pixelRatio;\n this.sourceLayerIndex = options.sourceLayerIndex;\n this.hasPattern = false;\n this.hasRTLText = false;\n this.sortKeyRanges = [];\n\n this.collisionCircleArray = [];\n this.placementInvProjMatrix = mat4.identity([] as any);\n this.placementViewportMatrix = mat4.identity([] as any);\n\n const layer = this.layers[0];\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);\n this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);\n\n const layout = this.layers[0].layout;\n const sortKey = layout.get('symbol-sort-key');\n const zOrder = layout.get('symbol-z-order');\n this.canOverlap =\n getOverlapMode(layout, 'text-overlap', 'text-allow-overlap') !== 'never' ||\n getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap') !== 'never' ||\n layout.get('text-ignore-placement') ||\n layout.get('icon-ignore-placement');\n this.sortFeaturesByKey = zOrder !== 'viewport-y' && !sortKey.isConstant();\n const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey);\n this.sortFeaturesByY = zOrderByViewportY && this.canOverlap;\n\n if (layout.get('symbol-placement') === 'point') {\n this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]);\n }\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n\n this.sourceID = options.sourceID;\n }\n\n createArrays() {\n this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property)));\n this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property)));\n\n this.glyphOffsetArray = new GlyphOffsetArray();\n this.lineVertexArray = new SymbolLineVertexArray();\n this.symbolInstances = new SymbolInstanceArray();\n this.textAnchorOffsets = new TextAnchorOffsetArray();\n }\n\n calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {\n for (let i = 0; i < text.length; i++) {\n stack[text.charCodeAt(i)] = true;\n if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {\n const verticalChar = verticalizedCharacterMap[text.charAt(i)];\n if (verticalChar) {\n stack[verticalChar.charCodeAt(0)] = true;\n }\n }\n }\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const layer = this.layers[0];\n const layout = layer.layout;\n\n const textFont = layout.get('text-font');\n const textField = layout.get('text-field');\n const iconImage = layout.get('icon-image');\n const hasText =\n (textField.value.kind !== 'constant' ||\n (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) ||\n textField.value.value.toString().length > 0) &&\n (textFont.value.kind !== 'constant' || textFont.value.value.length > 0);\n // we should always resolve the icon-image value if the property was defined in the style\n // this allows us to fire the styleimagemissing event if image evaluation returns null\n // the only way to distinguish between null returned from a coalesce statement with no valid images\n // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object\n const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;\n const symbolSortKey = layout.get('symbol-sort-key');\n\n this.features = [];\n\n if (!hasText && !hasIcon) {\n return;\n }\n\n const icons = options.iconDependencies;\n const stacks = options.glyphDependencies;\n const availableImages = options.availableImages;\n const globalProperties = new EvaluationParameters(this.zoom);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n\n const needGeometry = layer._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {\n continue;\n }\n\n if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature);\n\n let text: Formatted | void;\n if (hasText) {\n // Expression evaluation will automatically coerce to Formatted\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages);\n const formattedText = Formatted.factory(resolvedTokens);\n if (containsRTLText(formattedText)) {\n this.hasRTLText = true;\n }\n if (\n !this.hasRTLText || // non-rtl text so can proceed safely\n getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping\n this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text\n ) {\n text = transformText(formattedText, layer, evaluationFeature);\n }\n }\n\n let icon: ResolvedImage;\n if (hasIcon) {\n // Expression evaluation will automatically coerce to Image\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages);\n if (resolvedTokens instanceof ResolvedImage) {\n icon = resolvedTokens;\n } else {\n icon = ResolvedImage.fromString(resolvedTokens);\n }\n }\n\n if (!text && !icon) {\n continue;\n }\n const sortKey = this.sortFeaturesByKey ?\n symbolSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const symbolFeature: SymbolFeature = {\n id,\n text,\n icon,\n index,\n sourceLayerIndex,\n geometry: evaluationFeature.geometry,\n properties: feature.properties,\n type: vectorTileFeatureTypes[feature.type],\n sortKey\n };\n this.features.push(symbolFeature);\n\n if (icon) {\n icons[icon.name] = true;\n }\n\n if (text) {\n const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;\n for (const section of text.sections) {\n if (!section.image) {\n const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());\n const sectionFont = section.fontStack || fontStack;\n const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};\n this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);\n } else {\n // Add section image to the list of dependencies.\n icons[section.image.name] = true;\n }\n }\n }\n }\n\n if (layout.get('symbol-placement') === 'line') {\n // Merge adjacent lines with the same text to improve labelling.\n // It's better to place labels on one long line than on many short segments.\n this.features = mergeLines(this.features);\n }\n\n if (this.sortFeaturesByKey) {\n this.features.sort((a, b) => {\n // a.sortKey is always a number when sortFeaturesByKey is true\n return (a.sortKey as number) - (b.sortKey as number);\n });\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n }\n\n isEmpty() {\n // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created.\n // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary.\n return this.symbolInstances.length === 0 && !this.hasRTLText;\n }\n\n uploadPending() {\n return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded && this.hasDebugData()) {\n this.textCollisionBox.upload(context);\n this.iconCollisionBox.upload(context);\n }\n this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);\n this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);\n this.uploaded = true;\n }\n\n destroyDebugData() {\n this.textCollisionBox.destroy();\n this.iconCollisionBox.destroy();\n }\n\n destroy() {\n this.text.destroy();\n this.icon.destroy();\n\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n }\n\n addToLineVertexArray(anchor: Anchor, line: any) {\n const lineStartIndex = this.lineVertexArray.length;\n if (anchor.segment !== undefined) {\n let sumForwardLength = anchor.dist(line[anchor.segment + 1]);\n let sumBackwardLength = anchor.dist(line[anchor.segment]);\n const vertices = {};\n for (let i = anchor.segment + 1; i < line.length; i++) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};\n if (i < line.length - 1) {\n sumForwardLength += line[i + 1].dist(line[i]);\n }\n }\n for (let i = anchor.segment || 0; i >= 0; i--) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};\n if (i > 0) {\n sumBackwardLength += line[i - 1].dist(line[i]);\n }\n }\n for (let i = 0; i < line.length; i++) {\n const vertex = vertices[i];\n this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);\n }\n }\n return {\n lineStartIndex,\n lineLength: this.lineVertexArray.length - lineStartIndex\n };\n }\n\n addSymbols(arrays: SymbolBuffers,\n quads: Array,\n sizeVertex: any,\n lineOffset: [number, number],\n alongLine: boolean,\n feature: SymbolFeature,\n writingMode: WritingMode,\n labelAnchor: Anchor,\n lineStartIndex: number,\n lineLength: number,\n associatedIconIndex: number,\n canonical: CanonicalTileID) {\n const indexArray = arrays.indexArray;\n const layoutVertexArray = arrays.layoutVertexArray;\n\n const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey as number : undefined);\n const glyphOffsetArrayStart = this.glyphOffsetArray.length;\n const vertexStartIndex = segment.vertexLength;\n\n const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0;\n\n const sections = feature.text && feature.text.sections;\n\n for (let i = 0; i < quads.length; i++) {\n const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i];\n const index = segment.vertexLength;\n\n const y = glyphOffset[1];\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n\n addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);\n\n indexArray.emplaceBack(index, index + 1, index + 2);\n indexArray.emplaceBack(index + 1, index + 2, index + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n\n this.glyphOffsetArray.emplaceBack(glyphOffset[0]);\n\n if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {\n arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);\n }\n }\n\n arrays.placedSymbolArray.emplaceBack(\n labelAnchor.x, labelAnchor.y,\n glyphOffsetArrayStart,\n this.glyphOffsetArray.length - glyphOffsetArrayStart,\n vertexStartIndex,\n lineStartIndex,\n lineLength,\n labelAnchor.segment,\n sizeVertex ? sizeVertex[0] : 0,\n sizeVertex ? sizeVertex[1] : 0,\n lineOffset[0], lineOffset[1],\n writingMode,\n // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed\n 0,\n false as unknown as number,\n // The crossTileID is only filled/used on the foreground for dynamic text anchors\n 0,\n associatedIconIndex\n );\n }\n\n _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) {\n collisionVertexArray.emplaceBack(0, 0);\n return layoutVertexArray.emplaceBack(\n // pos\n point.x,\n point.y,\n // a_anchor_pos\n anchorX,\n anchorY,\n // extrude\n Math.round(extrude.x),\n Math.round(extrude.y));\n }\n\n addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance) {\n const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);\n const index = segment.vertexLength;\n\n const layoutVertexArray = arrays.layoutVertexArray;\n const collisionVertexArray = arrays.collisionVertexArray;\n\n const anchorX = symbolInstance.anchorX;\n const anchorY = symbolInstance.anchorY;\n\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2));\n\n segment.vertexLength += 4;\n\n const indexArray = arrays.indexArray as LineIndexArray;\n indexArray.emplaceBack(index, index + 1);\n indexArray.emplaceBack(index + 1, index + 2);\n indexArray.emplaceBack(index + 2, index + 3);\n indexArray.emplaceBack(index + 3, index);\n\n segment.primitiveLength += 4;\n }\n\n addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {\n for (let b = startIndex; b < endIndex; b++) {\n const box: CollisionBox = this.collisionBoxArray.get(b);\n const x1 = box.x1;\n const y1 = box.y1;\n const x2 = box.x2;\n const y2 = box.y2;\n\n this.addCollisionDebugVertices(x1, y1, x2, y2,\n isText ? this.textCollisionBox : this.iconCollisionBox,\n box.anchorPoint, symbolInstance);\n }\n }\n\n generateCollisionDebugBuffers() {\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n\n this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false);\n this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false);\n }\n }\n\n // These flat arrays are meant to be quicker to iterate over than the source\n // CollisionBoxArray\n _deserializeCollisionBoxesForSymbol(\n collisionBoxArray: CollisionBoxArray,\n textStartIndex: number,\n textEndIndex: number,\n verticalTextStartIndex: number,\n verticalTextEndIndex: number,\n iconStartIndex: number,\n iconEndIndex: number,\n verticalIconStartIndex: number,\n verticalIconEndIndex: number\n ): CollisionArrays {\n\n const collisionArrays = {} as CollisionArrays;\n for (let k = textStartIndex; k < textEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.textFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalTextFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = iconStartIndex; k < iconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.iconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalIconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n return collisionArrays;\n }\n\n deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) {\n this.collisionArrays = [];\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(\n collisionBoxArray,\n symbolInstance.textBoxStartIndex,\n symbolInstance.textBoxEndIndex,\n symbolInstance.verticalTextBoxStartIndex,\n symbolInstance.verticalTextBoxEndIndex,\n symbolInstance.iconBoxStartIndex,\n symbolInstance.iconBoxEndIndex,\n symbolInstance.verticalIconBoxStartIndex,\n symbolInstance.verticalIconBoxEndIndex\n ));\n }\n }\n\n hasTextData() {\n return this.text.segments.get().length > 0;\n }\n\n hasIconData() {\n return this.icon.segments.get().length > 0;\n }\n\n hasDebugData() {\n return this.textCollisionBox && this.iconCollisionBox;\n }\n\n hasTextCollisionBoxData() {\n return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;\n }\n\n hasIconCollisionBoxData() {\n return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;\n }\n\n addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) {\n const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);\n\n const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;\n for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {\n iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);\n iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);\n }\n }\n\n getSortedSymbolIndexes(angle: number) {\n if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) {\n return this.symbolInstanceIndexes;\n }\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n const rotatedYs = [];\n const featureIndexes = [];\n const result = [];\n\n for (let i = 0; i < this.symbolInstances.length; ++i) {\n result.push(i);\n const symbolInstance = this.symbolInstances.get(i);\n rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);\n featureIndexes.push(symbolInstance.featureIndex);\n }\n\n result.sort((aIndex, bIndex) => {\n return (rotatedYs[aIndex] - rotatedYs[bIndex]) ||\n (featureIndexes[bIndex] - featureIndexes[aIndex]);\n });\n\n return result;\n }\n\n addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) {\n const last = this.sortKeyRanges[this.sortKeyRanges.length - 1];\n if (last && last.sortKey === sortKey) {\n last.symbolInstanceEnd = symbolInstanceIndex + 1;\n } else {\n this.sortKeyRanges.push({\n sortKey,\n symbolInstanceStart: symbolInstanceIndex,\n symbolInstanceEnd: symbolInstanceIndex + 1\n });\n }\n }\n\n sortFeatures(angle: number) {\n if (!this.sortFeaturesByY) return;\n if (this.sortedAngle === angle) return;\n\n // The current approach to sorting doesn't sort across segments so don't try.\n // Sorting within segments separately seemed not to be worth the complexity.\n if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return;\n\n // If the symbols are allowed to overlap sort them by their vertical screen position.\n // The index array buffer is rewritten to reference the (unchanged) vertices in the\n // sorted order.\n\n // To avoid sorting the actual symbolInstance array we sort an array of indexes.\n this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);\n this.sortedAngle = angle;\n\n this.text.indexArray.clear();\n this.icon.indexArray.clear();\n\n this.featureSortOrder = [];\n\n for (const i of this.symbolInstanceIndexes) {\n const symbolInstance = this.symbolInstances.get(i);\n this.featureSortOrder.push(symbolInstance.featureIndex);\n\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach((index, i, array) => {\n // Only add a given index the first time it shows up,\n // to avoid duplicate opacity entries when multiple justifications\n // share the same glyphs.\n if (index >= 0 && array.indexOf(index) === i) {\n this.addIndicesForPlacedSymbol(this.text, index);\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex);\n }\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex);\n }\n }\n\n if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray);\n if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray);\n }\n}\n\nregister('SymbolBucket', SymbolBucket, {\n omit: ['layers', 'collisionBoxArray', 'features', 'compareText']\n});\n\n// this constant is based on the size of StructArray indexes used in a symbol\n// bucket--namely, glyphOffsetArrayStart\n// eg the max valid UInt16 is 65,535\n// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation\n// lineStartIndex and textBoxStartIndex could potentially be concerns\n// but we expect there to be many fewer boxes/lines than glyphs\nSymbolBucket.MAX_GLYPHS = 65535;\n\nSymbolBucket.addDynamicAttributes = addDynamicAttributes;\n\nexport {addDynamicAttributes};\n","/**\n * Replace tokens in a string template with values in an object\n *\n * @param properties - a key/value relationship between tokens and replacements\n * @param text - the template string\n * @returns the template with tokens replaced\n */\nexport function resolveTokens(\n properties: {\n readonly [x: string]: unknown;\n } | null,\n text: string\n): string {\n return text.replace(/{([^{}]+)}/g, (match, key: string) => {\n return properties && key in properties ? String(properties[key]) : '';\n });\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n ColorType\n } from '@maplibre/maplibre-gl-style-spec';\n \nexport type SymbolLayoutProps = {\n \"symbol-placement\": DataConstantProperty<\"point\" | \"line\" | \"line-center\">,\n \"symbol-spacing\": DataConstantProperty,\n \"symbol-avoid-edges\": DataConstantProperty,\n \"symbol-sort-key\": DataDrivenProperty,\n \"symbol-z-order\": DataConstantProperty<\"auto\" | \"viewport-y\" | \"source\">,\n \"icon-allow-overlap\": DataConstantProperty,\n \"icon-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"icon-ignore-placement\": DataConstantProperty,\n \"icon-optional\": DataConstantProperty,\n \"icon-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"icon-size\": DataDrivenProperty,\n \"icon-text-fit\": DataConstantProperty<\"none\" | \"width\" | \"height\" | \"both\">,\n \"icon-text-fit-padding\": DataConstantProperty<[number, number, number, number]>,\n \"icon-image\": DataDrivenProperty,\n \"icon-rotate\": DataDrivenProperty,\n \"icon-padding\": DataDrivenProperty,\n \"icon-keep-upright\": DataConstantProperty,\n \"icon-offset\": DataDrivenProperty<[number, number]>,\n \"icon-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\">,\n \"text-field\": DataDrivenProperty,\n \"text-font\": DataDrivenProperty>,\n \"text-size\": DataDrivenProperty,\n \"text-max-width\": DataDrivenProperty,\n \"text-line-height\": DataConstantProperty,\n \"text-letter-spacing\": DataDrivenProperty,\n \"text-justify\": DataDrivenProperty<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": DataDrivenProperty,\n \"text-variable-anchor\": DataConstantProperty>,\n \"text-variable-anchor-offset\": DataDrivenProperty,\n \"text-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": DataConstantProperty,\n \"text-writing-mode\": DataConstantProperty>,\n \"text-rotate\": DataDrivenProperty,\n \"text-padding\": DataConstantProperty,\n \"text-keep-upright\": DataConstantProperty,\n \"text-transform\": DataDrivenProperty<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": DataDrivenProperty<[number, number]>,\n \"text-allow-overlap\": DataConstantProperty,\n \"text-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"text-ignore-placement\": DataConstantProperty,\n \"text-optional\": DataConstantProperty,\n};\n\nexport type SymbolLayoutPropsPossiblyEvaluated = {\n \"symbol-placement\": \"point\" | \"line\" | \"line-center\",\n \"symbol-spacing\": number,\n \"symbol-avoid-edges\": boolean,\n \"symbol-sort-key\": PossiblyEvaluatedPropertyValue,\n \"symbol-z-order\": \"auto\" | \"viewport-y\" | \"source\",\n \"icon-allow-overlap\": boolean,\n \"icon-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"icon-ignore-placement\": boolean,\n \"icon-optional\": boolean,\n \"icon-rotation-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"icon-size\": PossiblyEvaluatedPropertyValue,\n \"icon-text-fit\": \"none\" | \"width\" | \"height\" | \"both\",\n \"icon-text-fit-padding\": [number, number, number, number],\n \"icon-image\": PossiblyEvaluatedPropertyValue,\n \"icon-rotate\": PossiblyEvaluatedPropertyValue,\n \"icon-padding\": PossiblyEvaluatedPropertyValue,\n \"icon-keep-upright\": boolean,\n \"icon-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"icon-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-rotation-alignment\": \"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\",\n \"text-field\": PossiblyEvaluatedPropertyValue,\n \"text-font\": PossiblyEvaluatedPropertyValue>,\n \"text-size\": PossiblyEvaluatedPropertyValue,\n \"text-max-width\": PossiblyEvaluatedPropertyValue,\n \"text-line-height\": number,\n \"text-letter-spacing\": PossiblyEvaluatedPropertyValue,\n \"text-justify\": PossiblyEvaluatedPropertyValue<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": PossiblyEvaluatedPropertyValue,\n \"text-variable-anchor\": Array<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-variable-anchor-offset\": PossiblyEvaluatedPropertyValue,\n \"text-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": number,\n \"text-writing-mode\": Array<\"horizontal\" | \"vertical\">,\n \"text-rotate\": PossiblyEvaluatedPropertyValue,\n \"text-padding\": number,\n \"text-keep-upright\": boolean,\n \"text-transform\": PossiblyEvaluatedPropertyValue<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"text-allow-overlap\": boolean,\n \"text-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"text-ignore-placement\": boolean,\n \"text-optional\": boolean,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"symbol-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-placement\"] as any as StylePropertySpecification),\n \"symbol-spacing\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-spacing\"] as any as StylePropertySpecification),\n \"symbol-avoid-edges\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-avoid-edges\"] as any as StylePropertySpecification),\n \"symbol-sort-key\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"symbol-sort-key\"] as any as StylePropertySpecification),\n \"symbol-z-order\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-z-order\"] as any as StylePropertySpecification),\n \"icon-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-allow-overlap\"] as any as StylePropertySpecification),\n \"icon-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-overlap\"] as any as StylePropertySpecification),\n \"icon-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-ignore-placement\"] as any as StylePropertySpecification),\n \"icon-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-optional\"] as any as StylePropertySpecification),\n \"icon-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-rotation-alignment\"] as any as StylePropertySpecification),\n \"icon-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-size\"] as any as StylePropertySpecification),\n \"icon-text-fit\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit\"] as any as StylePropertySpecification),\n \"icon-text-fit-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit-padding\"] as any as StylePropertySpecification),\n \"icon-image\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-image\"] as any as StylePropertySpecification),\n \"icon-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-rotate\"] as any as StylePropertySpecification),\n \"icon-padding\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-padding\"] as any as StylePropertySpecification),\n \"icon-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-keep-upright\"] as any as StylePropertySpecification),\n \"icon-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-offset\"] as any as StylePropertySpecification),\n \"icon-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-anchor\"] as any as StylePropertySpecification),\n \"icon-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-rotation-alignment\"] as any as StylePropertySpecification),\n \"text-field\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-field\"] as any as StylePropertySpecification),\n \"text-font\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-font\"] as any as StylePropertySpecification),\n \"text-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-size\"] as any as StylePropertySpecification),\n \"text-max-width\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-max-width\"] as any as StylePropertySpecification),\n \"text-line-height\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-line-height\"] as any as StylePropertySpecification),\n \"text-letter-spacing\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-letter-spacing\"] as any as StylePropertySpecification),\n \"text-justify\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-justify\"] as any as StylePropertySpecification),\n \"text-radial-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-radial-offset\"] as any as StylePropertySpecification),\n \"text-variable-anchor\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor\"] as any as StylePropertySpecification),\n \"text-variable-anchor-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor-offset\"] as any as StylePropertySpecification),\n \"text-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-anchor\"] as any as StylePropertySpecification),\n \"text-max-angle\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-max-angle\"] as any as StylePropertySpecification),\n \"text-writing-mode\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-writing-mode\"] as any as StylePropertySpecification),\n \"text-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-rotate\"] as any as StylePropertySpecification),\n \"text-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-padding\"] as any as StylePropertySpecification),\n \"text-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-keep-upright\"] as any as StylePropertySpecification),\n \"text-transform\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-transform\"] as any as StylePropertySpecification),\n \"text-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-offset\"] as any as StylePropertySpecification),\n \"text-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-allow-overlap\"] as any as StylePropertySpecification),\n \"text-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-overlap\"] as any as StylePropertySpecification),\n \"text-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-ignore-placement\"] as any as StylePropertySpecification),\n \"text-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-optional\"] as any as StylePropertySpecification),\n});\n\nexport type SymbolPaintProps = {\n \"icon-opacity\": DataDrivenProperty,\n \"icon-color\": DataDrivenProperty,\n \"icon-halo-color\": DataDrivenProperty,\n \"icon-halo-width\": DataDrivenProperty,\n \"icon-halo-blur\": DataDrivenProperty,\n \"icon-translate\": DataConstantProperty<[number, number]>,\n \"icon-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"text-opacity\": DataDrivenProperty,\n \"text-color\": DataDrivenProperty,\n \"text-halo-color\": DataDrivenProperty,\n \"text-halo-width\": DataDrivenProperty,\n \"text-halo-blur\": DataDrivenProperty,\n \"text-translate\": DataConstantProperty<[number, number]>,\n \"text-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n};\n\nexport type SymbolPaintPropsPossiblyEvaluated = {\n \"icon-opacity\": PossiblyEvaluatedPropertyValue,\n \"icon-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-width\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"icon-translate\": [number, number],\n \"icon-translate-anchor\": \"map\" | \"viewport\",\n \"text-opacity\": PossiblyEvaluatedPropertyValue,\n \"text-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-width\": PossiblyEvaluatedPropertyValue,\n \"text-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"text-translate\": [number, number],\n \"text-translate-anchor\": \"map\" | \"viewport\",\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"icon-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-opacity\"] as any as StylePropertySpecification),\n \"icon-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-color\"] as any as StylePropertySpecification),\n \"icon-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-color\"] as any as StylePropertySpecification),\n \"icon-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-width\"] as any as StylePropertySpecification),\n \"icon-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-blur\"] as any as StylePropertySpecification),\n \"icon-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate\"] as any as StylePropertySpecification),\n \"icon-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate-anchor\"] as any as StylePropertySpecification),\n \"text-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-opacity\"] as any as StylePropertySpecification),\n \"text-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-color\"] as any as StylePropertySpecification, { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }),\n \"text-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-color\"] as any as StylePropertySpecification),\n \"text-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-width\"] as any as StylePropertySpecification),\n \"text-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-blur\"] as any as StylePropertySpecification),\n \"text-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate\"] as any as StylePropertySpecification),\n \"text-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate-anchor\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import type {Expression, EvaluationContext, Type, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {NullType} from '@maplibre/maplibre-gl-style-spec';\nimport {PossiblyEvaluatedPropertyValue} from './properties';\nimport {register} from '../util/web_worker_transfer';\n\n// This is an internal expression class. It is only used in GL JS and\n// has GL JS dependencies which can break the standalone style-spec module\nexport class FormatSectionOverride implements Expression {\n type: Type;\n defaultValue: PossiblyEvaluatedPropertyValue;\n\n constructor(defaultValue: PossiblyEvaluatedPropertyValue) {\n if (defaultValue.property.overrides === undefined) throw new Error('overrides must be provided to instantiate FormatSectionOverride class');\n this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType;\n this.defaultValue = defaultValue;\n }\n\n evaluate(ctx: EvaluationContext) {\n if (ctx.formattedSection) {\n const overrides = this.defaultValue.property.overrides;\n if (overrides && overrides.hasOverride(ctx.formattedSection)) {\n return overrides.getOverride(ctx.formattedSection);\n }\n }\n\n if (ctx.feature && ctx.featureState) {\n return this.defaultValue.evaluate(ctx.feature, ctx.featureState);\n }\n\n return this.defaultValue.property.specification.default;\n }\n\n eachChild(fn: (_: Expression) => void) {\n if (!this.defaultValue.isConstant()) {\n const expr: ZoomConstantExpression<'source'> = (this.defaultValue.value as any);\n fn(expr._styleExpression.expression);\n }\n }\n\n // Cannot be statically evaluated, as the output depends on the evaluation context.\n outputDefined() {\n return false;\n }\n\n serialize() {\n return null;\n }\n}\n\nregister('FormatSectionOverride', FormatSectionOverride, {omit: ['defaultValue']});\n","import {StyleLayer} from '../style_layer';\n\nimport {SymbolBucket, SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {resolveTokens} from '../../util/resolve_tokens';\nimport properties, {SymbolLayoutPropsPossiblyEvaluated, SymbolPaintPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\n\nimport {\n Transitionable,\n Transitioning,\n Layout,\n PossiblyEvaluated,\n PossiblyEvaluatedPropertyValue,\n PropertyValue\n} from '../properties';\n\nimport {\n isExpression,\n StyleExpression,\n ZoomConstantExpression,\n ZoomDependentExpression,\n FormattedType,\n typeOf,\n Formatted,\n FormatExpression,\n Literal} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BucketParameters} from '../../data/bucket';\nimport type {SymbolLayoutProps, SymbolPaintProps} from './symbol_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Expression, Feature, SourceExpression, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport {FormatSectionOverride} from '../format_section_override';\n\nexport class SymbolStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n if (this.layout.get('icon-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['icon-rotation-alignment'] = 'map';\n } else {\n this.layout._values['icon-rotation-alignment'] = 'viewport';\n }\n }\n\n if (this.layout.get('text-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['text-rotation-alignment'] = 'map';\n } else {\n this.layout._values['text-rotation-alignment'] = 'viewport';\n }\n }\n\n // If unspecified, `*-pitch-alignment` inherits `*-rotation-alignment`\n if (this.layout.get('text-pitch-alignment') === 'auto') {\n this.layout._values['text-pitch-alignment'] = this.layout.get('text-rotation-alignment') === 'map' ? 'map' : 'viewport';\n }\n if (this.layout.get('icon-pitch-alignment') === 'auto') {\n this.layout._values['icon-pitch-alignment'] = this.layout.get('icon-rotation-alignment');\n }\n\n if (this.layout.get('symbol-placement') === 'point') {\n const writingModes = this.layout.get('text-writing-mode');\n if (writingModes) {\n // remove duplicates, preserving order\n const deduped = [];\n for (const m of writingModes) {\n if (deduped.indexOf(m) < 0) deduped.push(m);\n }\n this.layout._values['text-writing-mode'] = deduped;\n } else {\n this.layout._values['text-writing-mode'] = ['horizontal'];\n }\n }\n\n this._setPaintOverrides();\n }\n\n getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array) {\n const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages);\n const unevaluated = this._unevaluatedLayout._values[name];\n if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) {\n return resolveTokens(feature.properties, value);\n }\n\n return value;\n }\n\n createBucket(parameters: BucketParameters) {\n return new SymbolBucket(parameters);\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n throw new Error('Should take a different path in FeatureIndex');\n }\n\n _setPaintOverrides() {\n for (const overridable of properties.paint.overridableProperties) {\n if (!SymbolStyleLayer.hasPaintOverride(this.layout, overridable)) {\n continue;\n }\n const overriden = this.paint.get(overridable as keyof SymbolPaintPropsPossiblyEvaluated) as PossiblyEvaluatedPropertyValue;\n const override = new FormatSectionOverride(overriden);\n const styleExpression = new StyleExpression(override, overriden.property.specification);\n let expression = null;\n if (overriden.value.kind === 'constant' || overriden.value.kind === 'source') {\n expression = new ZoomConstantExpression('source', styleExpression) as SourceExpression;\n } else {\n expression = new ZoomDependentExpression('composite',\n styleExpression,\n overriden.value.zoomStops);\n }\n this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property,\n expression,\n overriden.parameters);\n }\n }\n\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) {\n return false;\n }\n return SymbolStyleLayer.hasPaintOverride(this.layout, name);\n }\n\n static hasPaintOverride(layout: PossiblyEvaluated, propertyName: string): boolean {\n const textField = layout.get('text-field');\n const property = properties.paint.properties[propertyName];\n let hasOverrides = false;\n\n const checkSections = (sections) => {\n for (const section of sections) {\n if (property.overrides && property.overrides.hasOverride(section)) {\n hasOverrides = true;\n return;\n }\n }\n };\n\n if (textField.value.kind === 'constant' && textField.value.value instanceof Formatted) {\n checkSections(textField.value.value.sections);\n } else if (textField.value.kind === 'source') {\n\n const checkExpression = (expression: Expression) => {\n if (hasOverrides) return;\n\n if (expression instanceof Literal && typeOf(expression.value) === FormattedType) {\n const formatted: Formatted = (expression.value as any);\n checkSections(formatted.sections);\n } else if (expression instanceof FormatExpression) {\n checkSections(expression.sections);\n } else {\n expression.eachChild(checkExpression);\n }\n };\n\n const expr: ZoomConstantExpression<'source'> = (textField.value as any);\n if (expr._styleExpression) {\n checkExpression(expr._styleExpression.expression);\n }\n }\n\n return hasOverrides;\n }\n}\n\nexport type SymbolPadding = [number, number, number, number];\n\nexport function getIconPadding(layout: PossiblyEvaluated, feature: SymbolFeature, canonical: CanonicalTileID, pixelRatio = 1): SymbolPadding {\n // Support text-padding in addition to icon-padding? Unclear how to apply asymmetric text-padding to the radius for collision circles.\n const result = layout.get('icon-padding').evaluate(feature, {}, canonical);\n const values = result && result.values;\n\n return [\n values[0] * pixelRatio,\n values[1] * pixelRatio,\n values[2] * pixelRatio,\n values[3] * pixelRatio,\n ];\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type BackgroundPaintProps = {\n \"background-color\": DataConstantProperty,\n \"background-pattern\": CrossFadedProperty,\n \"background-opacity\": DataConstantProperty,\n};\n\nexport type BackgroundPaintPropsPossiblyEvaluated = {\n \"background-color\": Color,\n \"background-pattern\": CrossFaded,\n \"background-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"background-color\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-color\"] as any as StylePropertySpecification),\n \"background-pattern\": new CrossFadedProperty(styleSpec[\"paint_background\"][\"background-pattern\"] as any as StylePropertySpecification),\n \"background-opacity\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {BackgroundPaintProps} from './background_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class BackgroundStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type RasterPaintProps = {\n \"raster-opacity\": DataConstantProperty,\n \"raster-hue-rotate\": DataConstantProperty,\n \"raster-brightness-min\": DataConstantProperty,\n \"raster-brightness-max\": DataConstantProperty,\n \"raster-saturation\": DataConstantProperty,\n \"raster-contrast\": DataConstantProperty,\n \"raster-resampling\": DataConstantProperty<\"linear\" | \"nearest\">,\n \"raster-fade-duration\": DataConstantProperty,\n};\n\nexport type RasterPaintPropsPossiblyEvaluated = {\n \"raster-opacity\": number,\n \"raster-hue-rotate\": number,\n \"raster-brightness-min\": number,\n \"raster-brightness-max\": number,\n \"raster-saturation\": number,\n \"raster-contrast\": number,\n \"raster-resampling\": \"linear\" | \"nearest\",\n \"raster-fade-duration\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"raster-opacity\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-opacity\"] as any as StylePropertySpecification),\n \"raster-hue-rotate\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-hue-rotate\"] as any as StylePropertySpecification),\n \"raster-brightness-min\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-min\"] as any as StylePropertySpecification),\n \"raster-brightness-max\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-max\"] as any as StylePropertySpecification),\n \"raster-saturation\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-saturation\"] as any as StylePropertySpecification),\n \"raster-contrast\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-contrast\"] as any as StylePropertySpecification),\n \"raster-resampling\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-resampling\"] as any as StylePropertySpecification),\n \"raster-fade-duration\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-fade-duration\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {RasterPaintPropsPossiblyEvaluated} from './raster_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {RasterPaintProps} from './raster_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class RasterStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","import {StyleLayer} from '../style_layer';\nimport type {Map} from '../../ui/map';\nimport {mat4} from 'gl-matrix';\nimport {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * @param gl - The map's gl context.\n * @param matrix - The map's camera matrix. It projects spherical mercator\n * coordinates to gl coordinates. The spherical mercator coordinate `[0, 0]` represents the\n * top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When\n * the `renderingMode` is `\"3d\"`, the z coordinate is conformal. A box with identical x, y, and z\n * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate.fromLngLat}\n * can be used to project a `LngLat` to a mercator coordinate.\n */\ntype CustomRenderMethod = (gl: WebGLRenderingContext|WebGL2RenderingContext, matrix: mat4) => void;\n\n/**\n * Interface for custom style layers. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Custom layers allow a user to render directly into the map's GL context using the map's camera.\n * These layers can be added between any regular layers using {@link Map#addLayer}.\n *\n * Custom layers must have a unique `id` and must have the `type` of `\"custom\"`.\n * They must implement `render` and may implement `prerender`, `onAdd` and `onRemove`.\n * They can trigger rendering using {@link Map#triggerRepaint}\n * and they should appropriately handle {@link MapContextEvent} with `webglcontextlost` and `webglcontextrestored`.\n *\n * The `renderingMode` property controls whether the layer is treated as a `\"2d\"` or `\"3d\"` map layer. Use:\n * - `\"renderingMode\": \"3d\"` to use the depth buffer and share it with other layers\n * - `\"renderingMode\": \"2d\"` to add a layer with no depth. If you need to use the depth buffer for a `\"2d\"` layer you must use an offscreen\n * framebuffer and {@link CustomLayerInterface#prerender}\n *\n * @example\n * Custom layer implemented as ES6 class\n * ```ts\n * class NullIslandLayer {\n * constructor() {\n * this.id = 'null-island';\n * this.type = 'custom';\n * this.renderingMode = '2d';\n * }\n *\n * onAdd(map, gl) {\n * const vertexSource = `\n * uniform mat4 u_matrix;\n * void main() {\n * gl_Position = u_matrix * vec4(0.5, 0.5, 0.0, 1.0);\n * gl_PointSize = 20.0;\n * }`;\n *\n * const fragmentSource = `\n * void main() {\n * fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n * }`;\n *\n * const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n * gl.shaderSource(vertexShader, vertexSource);\n * gl.compileShader(vertexShader);\n * const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n * gl.shaderSource(fragmentShader, fragmentSource);\n * gl.compileShader(fragmentShader);\n *\n * this.program = gl.createProgram();\n * gl.attachShader(this.program, vertexShader);\n * gl.attachShader(this.program, fragmentShader);\n * gl.linkProgram(this.program);\n * }\n *\n * render(gl, matrix) {\n * gl.useProgram(this.program);\n * gl.uniformMatrix4fv(gl.getUniformLocation(this.program, \"u_matrix\"), false, matrix);\n * gl.drawArrays(gl.POINTS, 0, 1);\n * }\n * }\n *\n * map.on('load', function() {\n * map.addLayer(new NullIslandLayer());\n * });\n * ```\n */\nexport interface CustomLayerInterface {\n /**\n * A unique layer id.\n */\n id: string;\n /**\n * The layer's type. Must be `\"custom\"`.\n */\n type: 'custom';\n /**\n * Either `\"2d\"` or `\"3d\"`. Defaults to `\"2d\"`.\n */\n renderingMode?: '2d' | '3d';\n /**\n * Called during a render frame allowing the layer to draw into the GL context.\n *\n * The layer can assume blending and depth state is set to allow the layer to properly\n * blend and clip other layers. The layer cannot make any other assumptions about the\n * current GL state.\n *\n * If the layer needs to render to a texture, it should implement the `prerender` method\n * to do this and only use the `render` method for drawing directly into the main framebuffer.\n *\n * The blend function is set to `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. This expects\n * colors to be provided in premultiplied alpha form where the `r`, `g` and `b` values are already\n * multiplied by the `a` value. If you are unable to provide colors in premultiplied form you\n * may want to change the blend function to\n * `gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`.\n */\n render: CustomRenderMethod;\n /**\n * Optional method called during a render frame to allow a layer to prepare resources or render into a texture.\n *\n * The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering.\n */\n prerender?: CustomRenderMethod;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This\n * gives the layer a chance to initialize gl resources and register event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onAdd?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n /**\n * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This\n * gives the layer a chance to clean up gl resources and event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onRemove?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n}\n\nexport function validateCustomStyleLayer(layerObject: CustomLayerInterface) {\n const errors = [];\n const id = layerObject.id;\n\n if (id === undefined) {\n errors.push({\n message: `layers.${id}: missing required property \"id\"`\n });\n }\n\n if (layerObject.render === undefined) {\n errors.push({\n message: `layers.${id}: missing required method \"render\"`\n });\n }\n\n if (layerObject.renderingMode &&\n layerObject.renderingMode !== '2d' &&\n layerObject.renderingMode !== '3d') {\n errors.push({\n message: `layers.${id}: property \"renderingMode\" must be either \"2d\" or \"3d\"`\n });\n }\n\n return errors;\n}\n\nexport class CustomStyleLayer extends StyleLayer {\n\n implementation: CustomLayerInterface;\n\n constructor(implementation: CustomLayerInterface) {\n super(implementation, {});\n this.implementation = implementation;\n }\n\n is3D() {\n return this.implementation.renderingMode === '3d';\n }\n\n hasOffscreenPass() {\n return this.implementation.prerender !== undefined;\n }\n\n recalculate() {}\n updateTransitions() {}\n hasTransition() { return false; }\n\n serialize(): LayerSpecification {\n throw new Error('Custom layers cannot be serialized');\n }\n\n onAdd = (map: Map) => {\n if (this.implementation.onAdd) {\n this.implementation.onAdd(map, map.painter.context.gl);\n }\n };\n\n onRemove = (map: Map) => {\n if (this.implementation.onRemove) {\n this.implementation.onRemove(map, map.painter.context.gl);\n }\n };\n}\n","import {CircleStyleLayer} from './style_layer/circle_style_layer';\nimport {HeatmapStyleLayer} from './style_layer/heatmap_style_layer';\nimport {HillshadeStyleLayer} from './style_layer/hillshade_style_layer';\nimport {FillStyleLayer} from './style_layer/fill_style_layer';\nimport {FillExtrusionStyleLayer} from './style_layer/fill_extrusion_style_layer';\nimport {LineStyleLayer} from './style_layer/line_style_layer';\nimport {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport {BackgroundStyleLayer} from './style_layer/background_style_layer';\nimport {RasterStyleLayer} from './style_layer/raster_style_layer';\nimport {CustomStyleLayer, type CustomLayerInterface} from './style_layer/custom_style_layer';\n\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) {\n if (layer.type === 'custom') {\n return new CustomStyleLayer(layer);\n }\n switch (layer.type) {\n case 'background':\n return new BackgroundStyleLayer(layer);\n case 'circle':\n return new CircleStyleLayer(layer);\n case 'fill':\n return new FillStyleLayer(layer);\n case 'fill-extrusion':\n return new FillExtrusionStyleLayer(layer);\n case 'heatmap':\n return new HeatmapStyleLayer(layer);\n case 'hillshade':\n return new HillshadeStyleLayer(layer);\n case 'line':\n return new LineStyleLayer(layer);\n case 'raster':\n return new RasterStyleLayer(layer);\n case 'symbol':\n return new SymbolStyleLayer(layer);\n }\n}\n\n","/**\n * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests\n * are ignored until the function was actually invoked.\n */\nexport class ThrottledInvoker {\n _channel: MessageChannel;\n _triggered: boolean;\n _callback: Function;\n\n constructor(callback: Function) {\n this._callback = callback;\n this._triggered = false;\n if (typeof MessageChannel !== 'undefined') {\n this._channel = new MessageChannel();\n this._channel.port2.onmessage = () => {\n this._triggered = false;\n this._callback();\n };\n }\n }\n\n trigger() {\n if (!this._triggered) {\n this._triggered = true;\n if (this._channel) {\n this._channel.port1.postMessage(true);\n } else {\n setTimeout(() => {\n this._triggered = false;\n this._callback();\n }, 0);\n }\n }\n }\n\n remove() {\n delete this._channel;\n this._callback = () => {};\n }\n}\n","import {isWorker} from './util';\nimport {serialize, deserialize, Serialized} from './web_worker_transfer';\nimport {ThrottledInvoker} from './throttled_invoker';\n\nimport type {Transferable} from '../types/transferable';\nimport type {Cancelable} from '../types/cancelable';\nimport type {WorkerSource} from '../source/worker_source';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {Callback} from '../types/callback';\nimport type {StyleGlyph} from '../style/style_glyph';\n\nexport interface ActorTarget {\n addEventListener: typeof window.addEventListener;\n removeEventListener: typeof window.removeEventListener;\n postMessage: typeof window.postMessage;\n terminate?: () => void;\n}\n\nexport interface WorkerSourceProvider {\n getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource;\n}\n\nexport interface GlyphsProvider {\n getGlyphs(mapId: string, params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n );\n}\n\nexport type MessageType = '' | '' |\n'geojson.getClusterExpansionZoom' | 'geojson.getClusterChildren' | 'geojson.getClusterLeaves' | 'geojson.loadData' |\n'removeSource' | 'loadWorkerSource' | 'loadDEMTile' | 'removeDEMTile' |\n'removeTile' | 'reloadTile' | 'abortTile' | 'loadTile' | 'getTile' |\n'getGlyphs' | 'getImages' | 'setImages' |\n'syncRTLPluginState' | 'setReferrer' | 'setLayers' | 'updateLayers';\n\nexport type MessageData = {\n id: string;\n type: MessageType;\n data?: Serialized;\n targetMapId?: string | number | null;\n mustQueue?: boolean;\n error?: Serialized | null;\n hasCallback?: boolean;\n sourceMapId: string | number | null;\n}\n\nexport type Message = {\n data: MessageData;\n}\n\n/**\n * An implementation of the [Actor design pattern](http://en.wikipedia.org/wiki/Actor_model)\n * that maintains the relationship between asynchronous tasks and the objects\n * that spin them off - in this case, tasks like parsing parts of styles,\n * owned by the styles\n */\nexport class Actor {\n target: ActorTarget;\n parent: WorkerSourceProvider | GlyphsProvider;\n mapId: string | number | null;\n callbacks: { [x: number]: Function};\n name: string;\n tasks: { [x: number]: MessageData };\n taskQueue: Array;\n cancelCallbacks: { [x: number]: () => void };\n invoker: ThrottledInvoker;\n globalScope: ActorTarget;\n\n /**\n * @param target - The target\n * @param parent - The parent\n * @param mapId - A unique identifier for the Map instance using this Actor.\n */\n constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number) {\n this.target = target;\n this.parent = parent;\n this.mapId = mapId;\n this.callbacks = {};\n this.tasks = {};\n this.taskQueue = [];\n this.cancelCallbacks = {};\n this.invoker = new ThrottledInvoker(this.process);\n this.target.addEventListener('message', this.receive, false);\n this.globalScope = isWorker() ? target : window;\n }\n\n /**\n * Sends a message from a main-thread map to a Worker or from a Worker back to\n * a main-thread map instance.\n *\n * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource.\n * @param targetMapId - A particular mapId to which to send this message.\n */\n send(\n type: MessageType,\n data: unknown,\n callback?: Function | null,\n targetMapId?: string | null,\n mustQueue: boolean = false\n ): Cancelable {\n // We're using a string ID instead of numbers because they are being used as object keys\n // anyway, and thus stringified implicitly. We use random IDs because an actor may receive\n // message from multiple other actors which could run in different execution context. A\n // linearly increasing ID could produce collisions.\n const id = Math.round((Math.random() * 1e18)).toString(36).substring(0, 10);\n if (callback) {\n this.callbacks[id] = callback;\n }\n const buffers: Array = [];\n const message: MessageData = {\n id,\n type,\n hasCallback: !!callback,\n targetMapId,\n mustQueue,\n sourceMapId: this.mapId,\n data: serialize(data, buffers)\n };\n\n this.target.postMessage(message, {transfer: buffers});\n return {\n cancel: () => {\n if (callback) {\n // Set the callback to null so that it never fires after the request is aborted.\n delete this.callbacks[id];\n }\n const cancelMessage: MessageData = {\n id,\n type: '',\n targetMapId,\n sourceMapId: this.mapId\n };\n this.target.postMessage(cancelMessage);\n }\n };\n }\n\n receive = (message: Message) => {\n const data = message.data;\n const id = data.id;\n\n if (!id) {\n return;\n }\n\n if (data.targetMapId && this.mapId !== data.targetMapId) {\n return;\n }\n\n if (data.type === '') {\n // Remove the original request from the queue. This is only possible if it\n // hasn't been kicked off yet. The id will remain in the queue, but because\n // there is no associated task, it will be dropped once it's time to execute it.\n delete this.tasks[id];\n const cancel = this.cancelCallbacks[id];\n delete this.cancelCallbacks[id];\n if (cancel) {\n cancel();\n }\n } else {\n if (isWorker() || data.mustQueue) {\n // In workers, store the tasks that we need to process before actually processing them. This\n // is necessary because we want to keep receiving messages, and in particular,\n // messages. Some tasks may take a while in the worker thread, so before\n // executing the next task in our queue, postMessage preempts this and \n // messages can be processed. We're using a MessageChannel object to get throttle the\n // process() flow to one at a time.\n this.tasks[id] = data;\n this.taskQueue.push(id);\n this.invoker.trigger();\n } else {\n // In the main thread, process messages immediately so that other work does not slip in\n // between getting partial data back from workers.\n this.processTask(id, data);\n }\n }\n };\n\n process = () => {\n if (!this.taskQueue.length) {\n return;\n }\n const id = this.taskQueue.shift();\n const task = this.tasks[id];\n delete this.tasks[id];\n // Schedule another process call if we know there's more to process _before_ invoking the\n // current task. This is necessary so that processing continues even if the current task\n // doesn't execute successfully.\n if (this.taskQueue.length) {\n this.invoker.trigger();\n }\n if (!task) {\n // If the task ID doesn't have associated task data anymore, it was canceled.\n return;\n }\n\n this.processTask(id, task);\n };\n\n processTask(id: string, task: MessageData) {\n if (task.type === '') {\n // The done() function in the counterpart has been called, and we are now\n // firing the callback in the originating actor, if there is one.\n const callback = this.callbacks[id];\n delete this.callbacks[id];\n if (callback) {\n // If we get a response, but don't have a callback, the request was canceled.\n if (task.error) {\n callback(deserialize(task.error));\n } else {\n callback(null, deserialize(task.data));\n }\n }\n } else {\n let completed = false;\n const buffers: Array = [];\n const done = task.hasCallback ? (err: Error, data?: any) => {\n completed = true;\n delete this.cancelCallbacks[id];\n const responseMessage: MessageData = {\n id,\n type: '',\n sourceMapId: this.mapId,\n error: err ? serialize(err) : null,\n data: serialize(data, buffers)\n };\n this.target.postMessage(responseMessage, {transfer: buffers});\n } : (_) => {\n completed = true;\n };\n\n let callback: Cancelable = null;\n const params = deserialize(task.data);\n if (this.parent[task.type]) {\n // task.type == 'loadTile', 'removeTile', etc.\n callback = this.parent[task.type](task.sourceMapId, params, done);\n } else if ('getWorkerSource' in this.parent) {\n // task.type == sourcetype.method\n const keys = task.type.split('.');\n const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], (params as any).source);\n callback = scope[keys[1]](params, done);\n } else {\n // No function was found.\n done(new Error(`Could not find function ${task.type}`));\n }\n\n if (!completed && callback && callback.cancel) {\n // Allows canceling the task as long as it hasn't been completed yet.\n this.cancelCallbacks[id] = callback.cancel;\n }\n }\n }\n\n remove() {\n this.invoker.remove();\n this.target.removeEventListener('message', this.receive, false);\n }\n}\n","import {wrap} from '../util/util';\n\n/*\n* Approximate radius of the earth in meters.\n* Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84\n* 6371008.8 is one published \"average radius\" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4\n*/\nexport const earthRadius = 6371008.8;\n\n/**\n * A {@link LngLat} object, an array of two numbers representing longitude and latitude,\n * or an object with `lng` and `lat` or `lon` and `lat` properties.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLat(-122.420679, 37.772537);\n * let v2 = [-122.420679, 37.772537];\n * let v3 = {lon: -122.420679, lat: 37.772537};\n * ```\n */\nexport type LngLatLike = LngLat | {\n lng: number;\n lat: number;\n} | {\n lon: number;\n lat: number;\n} | [number, number];\n\n/**\n * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.\n * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).\n *\n * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the\n * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).\n *\n * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option\n * can also accept an `Array` of two numbers and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-123.9749, 40.7736);\n * ll.lng; // = -123.9749\n * ```\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\nexport class LngLat {\n lng: number;\n lat: number;\n\n /**\n * @param lng - Longitude, measured in degrees.\n * @param lat - Latitude, measured in degrees.\n */\n constructor(lng: number, lat: number) {\n if (isNaN(lng) || isNaN(lat)) {\n throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);\n }\n this.lng = +lng;\n this.lat = +lat;\n if (this.lat > 90 || this.lat < -90) {\n throw new Error('Invalid LngLat latitude value: must be between -90 and 90');\n }\n }\n\n /**\n * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).\n *\n * @returns The wrapped `LngLat` object.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(286.0251, 40.7736);\n * let wrapped = ll.wrap();\n * wrapped.lng; // = -73.9749\n * ```\n */\n wrap() {\n return new LngLat(wrap(this.lng, -180, 180), this.lat);\n }\n\n /**\n * Returns the coordinates represented as an array of two numbers.\n *\n * @returns The coordinates represented as an array of longitude and latitude.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toArray(); // = [-73.9749, 40.7736]\n * ```\n */\n toArray(): [number, number] {\n return [this.lng, this.lat];\n }\n\n /**\n * Returns the coordinates represent as a string.\n *\n * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toString(); // = \"LngLat(-73.9749, 40.7736)\"\n * ```\n */\n toString(): string {\n return `LngLat(${this.lng}, ${this.lat})`;\n }\n\n /**\n * Returns the approximate distance between a pair of coordinates in meters\n * Uses the Haversine Formula (from R.W. Sinnott, \"Virtues of the Haversine\", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)\n *\n * @param lngLat - coordinates to compute the distance to\n * @returns Distance in meters between the two coordinates.\n * @example\n * ```ts\n * let new_york = new maplibregl.LngLat(-74.0060, 40.7128);\n * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522);\n * new_york.distanceTo(los_angeles); // = 3935751.690893987, \"true distance\" using a non-spherical approximation is ~3966km\n * ```\n */\n distanceTo(lngLat: LngLat): number {\n const rad = Math.PI / 180;\n const lat1 = this.lat * rad;\n const lat2 = lngLat.lat * rad;\n const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);\n\n const maxMeters = earthRadius * Math.acos(Math.min(a, 1));\n return maxMeters;\n }\n\n /**\n * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties\n * to a `LngLat` object.\n *\n * If a `LngLat` object is passed in, the function returns it unchanged.\n *\n * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.\n * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.\n * @example\n * ```ts\n * let arr = [-73.9749, 40.7736];\n * let ll = maplibregl.LngLat.convert(arr);\n * ll; // = LngLat {lng: -73.9749, lat: 40.7736}\n * ```\n */\n static convert(input: LngLatLike): LngLat {\n if (input instanceof LngLat) {\n return input;\n }\n if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {\n return new LngLat(Number(input[0]), Number(input[1]));\n }\n if (!Array.isArray(input) && typeof input === 'object' && input !== null) {\n return new LngLat(\n // flow can't refine this to have one of lng or lat, so we have to cast to any\n Number('lng' in input ? (input as any).lng : (input as any).lon),\n Number(input.lat)\n );\n }\n throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]');\n }\n}\n","import {LngLat, earthRadius} from '../geo/lng_lat';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport {IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/*\n * The average circumference of the world in meters.\n */\nconst earthCircumfrence = 2 * Math.PI * earthRadius; // meters\n\n/*\n * The circumference at a line of latitude in meters.\n */\nfunction circumferenceAtLatitude(latitude: number) {\n return earthCircumfrence * Math.cos(latitude * Math.PI / 180);\n}\n\nexport function mercatorXfromLng(lng: number) {\n return (180 + lng) / 360;\n}\n\nexport function mercatorYfromLat(lat: number) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\n\nexport function mercatorZfromAltitude(altitude: number, lat: number) {\n return altitude / circumferenceAtLatitude(lat);\n}\n\nexport function lngFromMercatorX(x: number) {\n return x * 360 - 180;\n}\n\nexport function latFromMercatorY(y: number) {\n const y2 = 180 - y * 360;\n return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;\n}\n\nexport function altitudeFromMercatorZ(z: number, y: number) {\n return z * circumferenceAtLatitude(latFromMercatorY(y));\n}\n\n/**\n * Determine the Mercator scale factor for a given latitude, see\n * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor\n *\n * At the equator the scale factor will be 1, which increases at higher latitudes.\n *\n * @param lat - Latitude\n * @returns scale factor\n */\nexport function mercatorScale(lat: number) {\n return 1 / Math.cos(lat * Math.PI / 180);\n}\n\n/**\n * A `MercatorCoordinate` object represents a projected three dimensional position.\n *\n * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:\n * - the size of 1 unit is the width of the projected world instead of the \"mercator meter\"\n * - the origin of the coordinate space is at the north-west corner instead of the middle\n *\n * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and\n * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with\n * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think\n * of the coordinate space as the `0/0/0` tile with an extent of `1`.\n *\n * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let nullIsland = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * ```\n * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/)\n */\nexport class MercatorCoordinate implements IMercatorCoordinate {\n x: number;\n y: number;\n z: number;\n\n /**\n * @param x - The x component of the position.\n * @param y - The y component of the position.\n * @param z - The z component of the position.\n */\n constructor(x: number, y: number, z: number = 0) {\n this.x = +x;\n this.y = +y;\n this.z = +z;\n }\n\n /**\n * Project a `LngLat` to a `MercatorCoordinate`.\n *\n * @param lngLatLike - The location to project.\n * @param altitude - The altitude in meters of the position.\n * @returns The projected mercator coordinate.\n * @example\n * ```ts\n * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);\n * coord; // MercatorCoordinate(0.5, 0.5, 0)\n * ```\n */\n static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0): MercatorCoordinate {\n const lngLat = LngLat.convert(lngLatLike);\n\n return new MercatorCoordinate(\n mercatorXfromLng(lngLat.lng),\n mercatorYfromLat(lngLat.lat),\n mercatorZfromAltitude(altitude, lngLat.lat));\n }\n\n /**\n * Returns the `LngLat` for the coordinate.\n *\n * @returns The `LngLat` object.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * let lngLat = coord.toLngLat(); // LngLat(0, 0)\n * ```\n */\n toLngLat() {\n return new LngLat(\n lngFromMercatorX(this.x),\n latFromMercatorY(this.y));\n }\n\n /**\n * Returns the altitude in meters of the coordinate.\n *\n * @returns The altitude in meters.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02);\n * coord.toAltitude(); // 6914.281956295339\n * ```\n */\n toAltitude(): number {\n return altitudeFromMercatorZ(this.z, this.y);\n }\n\n /**\n * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.\n *\n * For coordinates in real world units using meters, this naturally provides the scale\n * to transform into `MercatorCoordinate`s.\n *\n * @returns Distance of 1 meter in `MercatorCoordinate` units.\n */\n meterInMercatorCoordinateUnits(): number {\n // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude\n return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));\n }\n}\n","export { getURL, getTileBBox, getMercCoords };\n\n\n/**\n * getURL\n *\n * @param {String} baseUrl Base url of the WMS server\n * @param {String} layer Layer name\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @param {Object} [options]\n * @param {String} [options.format='image/png']\n * @param {String} [options.service='WMS']\n * @param {String} [options.version='1.1.1']\n * @param {String} [options.request='GetMap']\n * @param {String} [options.srs='EPSG:3857']\n * @param {Number} [options.width='256']\n * @param {Number} [options.height='256']\n * @returns {String} url\n * @example\n * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';\n * var layer = 'Natural2015';\n * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19);\n */\nfunction getURL(baseUrl, layer, x, y, z, options) {\n options = options || {};\n\n var url = baseUrl + '?' + [\n 'bbox=' + getTileBBox(x, y, z),\n 'format=' + (options.format || 'image/png'),\n 'service=' + (options.service || 'WMS'),\n 'version=' + (options.version || '1.1.1'),\n 'request=' + (options.request || 'GetMap'),\n 'srs=' + (options.srs || 'EPSG:3857'),\n 'width=' + (options.width || 256),\n 'height=' + (options.height || 256),\n 'layers=' + layer\n ].join('&');\n\n return url;\n}\n\n\n/**\n * getTileBBox\n *\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @returns {String} String of the bounding box\n */\nfunction getTileBBox(x, y, z) {\n // for Google/OSM tile scheme we need to alter the y\n y = (Math.pow(2, z) - y - 1);\n\n var min = getMercCoords(x * 256, y * 256, z),\n max = getMercCoords((x + 1) * 256, (y + 1) * 256, z);\n\n return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1];\n}\n\n\n/**\n * getMercCoords\n *\n * @param {Number} x Pixel coordinate x\n * @param {Number} y Pixel coordinate y\n * @param {Number} z Tile zoom\n * @returns {Array} [x, y]\n */\nfunction getMercCoords(x, y, z) {\n var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z),\n merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0),\n merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0);\n\n return [merc_x, merc_y];\n}\n","import {getTileBBox} from '@mapbox/whoots-js';\nimport {EXTENT} from '../data/extent';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {register} from '../util/web_worker_transfer';\nimport {mat4} from 'gl-matrix';\nimport {ICanonicalTileID, IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A canonical way to define a tile ID\n */\nexport class CanonicalTileID implements ICanonicalTileID {\n z: number;\n x: number;\n y: number;\n key: string;\n\n constructor(z: number, x: number, y: number) {\n\n if (z < 0 || z > 25 || y < 0 || y >= Math.pow(2, z) || x < 0 || x >= Math.pow(2, z)) {\n throw new Error(`x=${x}, y=${y}, z=${z} outside of bounds. 0<=x<${Math.pow(2, z)}, 0<=y<${Math.pow(2, z)} 0<=z<=25 `);\n }\n\n this.z = z;\n this.x = x;\n this.y = y;\n this.key = calculateKey(0, z, z, x, y);\n }\n\n equals(id: ICanonicalTileID) {\n return this.z === id.z && this.x === id.x && this.y === id.y;\n }\n\n // given a list of urls, choose a url template and return a tile URL\n url(urls: Array, pixelRatio: number, scheme?: string | null) {\n const bbox = getTileBBox(this.x, this.y, this.z);\n const quadkey = getQuadkey(this.z, this.x, this.y);\n\n return urls[(this.x + this.y) % urls.length]\n .replace(/{prefix}/g, (this.x % 16).toString(16) + (this.y % 16).toString(16))\n .replace(/{z}/g, String(this.z))\n .replace(/{x}/g, String(this.x))\n .replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))\n .replace(/{ratio}/g, pixelRatio > 1 ? '@2x' : '')\n .replace(/{quadkey}/g, quadkey)\n .replace(/{bbox-epsg-3857}/g, bbox);\n }\n\n isChildOf(parent: ICanonicalTileID) {\n const dz = this.z - parent.z;\n return dz > 0 && parent.x === (this.x >> dz) && parent.y === (this.y >> dz);\n }\n\n getTilePoint(coord: IMercatorCoordinate) {\n const tilesAtZoom = Math.pow(2, this.z);\n return new Point(\n (coord.x * tilesAtZoom - this.x) * EXTENT,\n (coord.y * tilesAtZoom - this.y) * EXTENT);\n }\n\n toString() {\n return `${this.z}/${this.x}/${this.y}`;\n }\n}\n\n/**\n * @internal\n * An unwrapped tile identifier\n */\nexport class UnwrappedTileID {\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n\n constructor(wrap: number, canonical: CanonicalTileID) {\n this.wrap = wrap;\n this.canonical = canonical;\n this.key = calculateKey(wrap, canonical.z, canonical.z, canonical.x, canonical.y);\n }\n}\n\n/**\n * An overscaled tile identifier\n */\nexport class OverscaledTileID {\n overscaledZ: number;\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n posMatrix: mat4;\n\n constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number) {\n if (overscaledZ < z) throw new Error(`overscaledZ should be >= z; overscaledZ = ${overscaledZ}; z = ${z}`);\n this.overscaledZ = overscaledZ;\n this.wrap = wrap;\n this.canonical = new CanonicalTileID(z, +x, +y);\n this.key = calculateKey(wrap, overscaledZ, z, x, y);\n }\n\n clone() {\n return new OverscaledTileID(this.overscaledZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n equals(id: OverscaledTileID) {\n return this.overscaledZ === id.overscaledZ && this.wrap === id.wrap && this.canonical.equals(id.canonical);\n }\n\n scaledTo(targetZ: number) {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return new OverscaledTileID(targetZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return new OverscaledTileID(targetZ, this.wrap, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n /*\n * calculateScaledKey is an optimization:\n * when withWrap == true, implements the same as this.scaledTo(z).key,\n * when withWrap == false, implements the same as this.scaledTo(z).wrapped().key.\n */\n calculateScaledKey(targetZ: number, withWrap: boolean): string {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return calculateKey(this.wrap * +withWrap, targetZ, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return calculateKey(this.wrap * +withWrap, targetZ, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n isChildOf(parent: OverscaledTileID) {\n if (parent.wrap !== this.wrap) {\n // We can't be a child if we're in a different world copy\n return false;\n }\n const zDifference = this.canonical.z - parent.canonical.z;\n // We're first testing for z == 0, to avoid a 32 bit shift, which is undefined.\n return parent.overscaledZ === 0 || (\n parent.overscaledZ < this.overscaledZ &&\n parent.canonical.x === (this.canonical.x >> zDifference) &&\n parent.canonical.y === (this.canonical.y >> zDifference));\n }\n\n children(sourceMaxZoom: number) {\n if (this.overscaledZ >= sourceMaxZoom) {\n // return a single tile coord representing a an overscaled tile\n return [new OverscaledTileID(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)];\n }\n\n const z = this.canonical.z + 1;\n const x = this.canonical.x * 2;\n const y = this.canonical.y * 2;\n return [\n new OverscaledTileID(z, this.wrap, z, x, y),\n new OverscaledTileID(z, this.wrap, z, x + 1, y),\n new OverscaledTileID(z, this.wrap, z, x, y + 1),\n new OverscaledTileID(z, this.wrap, z, x + 1, y + 1)\n ];\n }\n\n isLessThan(rhs: OverscaledTileID) {\n if (this.wrap < rhs.wrap) return true;\n if (this.wrap > rhs.wrap) return false;\n\n if (this.overscaledZ < rhs.overscaledZ) return true;\n if (this.overscaledZ > rhs.overscaledZ) return false;\n\n if (this.canonical.x < rhs.canonical.x) return true;\n if (this.canonical.x > rhs.canonical.x) return false;\n\n if (this.canonical.y < rhs.canonical.y) return true;\n return false;\n }\n\n wrapped() {\n return new OverscaledTileID(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n unwrapTo(wrap: number) {\n return new OverscaledTileID(this.overscaledZ, wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n overscaleFactor() {\n return Math.pow(2, this.overscaledZ - this.canonical.z);\n }\n\n toUnwrapped() {\n return new UnwrappedTileID(this.wrap, this.canonical);\n }\n\n toString() {\n return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`;\n }\n\n getTilePoint(coord: MercatorCoordinate) {\n return this.canonical.getTilePoint(new MercatorCoordinate(coord.x - this.wrap, coord.y));\n }\n}\n\nfunction calculateKey(wrap: number, overscaledZ: number, z: number, x: number, y: number): string {\n wrap *= 2;\n if (wrap < 0) wrap = wrap * -1 - 1;\n const dim = 1 << z;\n return (dim * dim * wrap + dim * y + x).toString(36) + z.toString(36) + overscaledZ.toString(36);\n}\n\nfunction getQuadkey(z, x, y) {\n let quadkey = '', mask;\n for (let i = z; i > 0; i--) {\n mask = 1 << (i - 1);\n quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0));\n }\n return quadkey;\n}\n\nregister('CanonicalTileID', CanonicalTileID);\nregister('OverscaledTileID', OverscaledTileID, {omit: ['posMatrix']});\n","import {RGBAImage} from '../util/image';\n\nimport {warnOnce} from '../util/util';\nimport {register} from '../util/web_worker_transfer';\n\n// DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders\n// data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially\n// loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the\n// elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of\n// integer overflow when creating the texture used in the hillshadePrepare step.\n\n// DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8\n// surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a\n// tile's edge without backfilling from neighboring tiles.\n\nexport type DEMEncoding = 'mapbox' | 'terrarium' | 'custom'\n\nexport class DEMData {\n uid: string;\n data: Uint32Array;\n stride: number;\n dim: number;\n min: number;\n max: number;\n redFactor: number;\n greenFactor: number;\n blueFactor: number;\n baseShift: number;\n\n // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride\n // and dim is calculated as stride - 2.\n constructor(uid: string, data: RGBAImage, encoding: DEMEncoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {\n this.uid = uid;\n if (data.height !== data.width) throw new RangeError('DEM tiles must be square');\n if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {\n warnOnce(`\"${encoding}\" is not a valid encoding type. Valid types include \"mapbox\", \"terrarium\" and \"custom\".`);\n return;\n }\n this.stride = data.height;\n const dim = this.dim = data.height - 2;\n this.data = new Uint32Array(data.data.buffer);\n switch (encoding) {\n case 'terrarium':\n // unpacking formula for mapzen terrarium:\n // https://aws.amazon.com/public-datasets/terrain/\n this.redFactor = 256.0;\n this.greenFactor = 1.0;\n this.blueFactor = 1.0 / 256.0;\n this.baseShift = 32768.0;\n break;\n case 'custom':\n this.redFactor = redFactor;\n this.greenFactor = greenFactor;\n this.blueFactor = blueFactor;\n this.baseShift = baseShift;\n break;\n case 'mapbox':\n default:\n // unpacking formula for mapbox.terrain-rgb:\n // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb\n this.redFactor = 6553.6;\n this.greenFactor = 25.6;\n this.blueFactor = 0.1;\n this.baseShift = 10000.0;\n break;\n }\n\n // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image\n // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring\n // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder\n for (let x = 0; x < dim; x++) {\n // left vertical border\n this.data[this._idx(-1, x)] = this.data[this._idx(0, x)];\n // right vertical border\n this.data[this._idx(dim, x)] = this.data[this._idx(dim - 1, x)];\n // left horizontal border\n this.data[this._idx(x, -1)] = this.data[this._idx(x, 0)];\n // right horizontal border\n this.data[this._idx(x, dim)] = this.data[this._idx(x, dim - 1)];\n }\n // corners\n this.data[this._idx(-1, -1)] = this.data[this._idx(0, 0)];\n this.data[this._idx(dim, -1)] = this.data[this._idx(dim - 1, 0)];\n this.data[this._idx(-1, dim)] = this.data[this._idx(0, dim - 1)];\n this.data[this._idx(dim, dim)] = this.data[this._idx(dim - 1, dim - 1)];\n\n // calculate min/max values\n this.min = Number.MAX_SAFE_INTEGER;\n this.max = Number.MIN_SAFE_INTEGER;\n for (let x = 0; x < dim; x++) {\n for (let y = 0; y < dim; y++) {\n const ele = this.get(x, y);\n if (ele > this.max) this.max = ele;\n if (ele < this.min) this.min = ele;\n }\n }\n }\n\n get(x: number, y: number) {\n const pixels = new Uint8Array(this.data.buffer);\n const index = this._idx(x, y) * 4;\n return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);\n }\n\n getUnpackVector() {\n return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];\n }\n\n _idx(x: number, y: number) {\n if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) throw new RangeError('out of range source coordinates for DEM data');\n return (y + 1) * this.stride + (x + 1);\n }\n\n unpack(r: number, g: number, b: number) {\n return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);\n }\n\n getPixels() {\n return new RGBAImage({width: this.stride, height: this.stride}, new Uint8Array(this.data.buffer));\n }\n\n backfillBorder(borderTile: DEMData, dx: number, dy: number) {\n if (this.dim !== borderTile.dim) throw new Error('dem dimension mismatch');\n\n let xMin = dx * this.dim,\n xMax = dx * this.dim + this.dim,\n yMin = dy * this.dim,\n yMax = dy * this.dim + this.dim;\n\n switch (dx) {\n case -1:\n xMin = xMax - 1;\n break;\n case 1:\n xMax = xMin + 1;\n break;\n }\n\n switch (dy) {\n case -1:\n yMin = yMax - 1;\n break;\n case 1:\n yMax = yMin + 1;\n break;\n }\n\n const ox = -dx * this.dim;\n const oy = -dy * this.dim;\n for (let y = yMin; y < yMax; y++) {\n for (let x = xMin; x < xMax; x++) {\n this.data[this._idx(x, y)] = borderTile.data[this._idx(x + ox, y + oy)];\n }\n }\n }\n}\n\nregister('DEMData', DEMData);\n","export class DictionaryCoder {\n _stringToNumber: {[_: string]: number};\n _numberToString: Array;\n\n constructor(strings: Array) {\n this._stringToNumber = {};\n this._numberToString = [];\n for (let i = 0; i < strings.length; i++) {\n const string = strings[i];\n this._stringToNumber[string] = i;\n this._numberToString[i] = string;\n }\n }\n\n encode(string: string) {\n return this._stringToNumber[string];\n }\n\n decode(n: number) {\n if (n >= this._numberToString.length) throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`);\n return this._numberToString[n];\n }\n}\n","import type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveKeys = T extends T ? keyof T : never;\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveOmit> = T extends unknown\n ? Omit\n : never;\n\n/**\n * An extended geojson feature used by the events to return data to the listener\n */\nexport type MapGeoJSONFeature = GeoJSONFeature & {\n layer: DistributiveOmit & {source: string};\n source: string;\n sourceLayer?: string;\n state: { [key: string]: any };\n}\n\n/**\n * A geojson feature\n */\nexport class GeoJSONFeature {\n type: 'Feature';\n _geometry: GeoJSON.Geometry;\n properties: { [name: string]: any };\n id: number | string | undefined;\n\n _vectorTileFeature: VectorTileFeature;\n\n constructor(vectorTileFeature: VectorTileFeature, z: number, x: number, y: number, id: string | number | undefined) {\n this.type = 'Feature';\n\n this._vectorTileFeature = vectorTileFeature;\n (vectorTileFeature as any)._z = z;\n (vectorTileFeature as any)._x = x;\n (vectorTileFeature as any)._y = y;\n\n this.properties = vectorTileFeature.properties;\n this.id = id;\n }\n\n get geometry(): GeoJSON.Geometry {\n if (this._geometry === undefined) {\n this._geometry = this._vectorTileFeature.toGeoJSON(\n (this._vectorTileFeature as any)._x,\n (this._vectorTileFeature as any)._y,\n (this._vectorTileFeature as any)._z).geometry;\n }\n return this._geometry;\n }\n\n set geometry(g: GeoJSON.Geometry) {\n this._geometry = g;\n }\n\n toJSON() {\n const json: any = {\n geometry: this.geometry\n };\n for (const i in this) {\n if (i === '_geometry' || i === '_vectorTileFeature') continue;\n json[i] = (this)[i];\n }\n return json;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {loadGeometry} from './load_geometry';\nimport {toEvaluationFeature} from './evaluation_feature';\nimport {EXTENT} from './extent';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {TransferableGridIndex} from '../util/transferable_grid_index';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {arraysIntersect, mapObject, extend} from '../util/util';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {polygonIntersectsBox} from '../util/intersection_tests';\nimport {PossiblyEvaluated} from '../style/properties';\nimport {FeatureIndexArray} from './array_types.g';\nimport {mat4} from 'gl-matrix';\n\nimport type {StyleLayer} from '../style/style_layer';\nimport type {FeatureFilter, FeatureState, FilterSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\n\ntype QueryParameters = {\n scale: number;\n pixelPosMatrix: mat4;\n transform: Transform;\n tileSize: number;\n queryGeometry: Array;\n cameraQueryGeometry: Array;\n queryPadding: number;\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n };\n};\n\n/**\n * @internal\n * An in memory index class to allow fast interaction with features\n */\nexport class FeatureIndex {\n tileID: OverscaledTileID;\n x: number;\n y: number;\n z: number;\n grid: TransferableGridIndex;\n grid3D: TransferableGridIndex;\n featureIndexArray: FeatureIndexArray;\n promoteId?: PromoteIdSpecification;\n\n rawTileData: ArrayBuffer;\n bucketLayerIDs: Array>;\n\n vtLayers: {[_: string]: VectorTileLayer};\n sourceLayerCoder: DictionaryCoder;\n\n constructor(tileID: OverscaledTileID, promoteId?: PromoteIdSpecification | null) {\n this.tileID = tileID;\n this.x = tileID.canonical.x;\n this.y = tileID.canonical.y;\n this.z = tileID.canonical.z;\n this.grid = new TransferableGridIndex(EXTENT, 16, 0);\n this.grid3D = new TransferableGridIndex(EXTENT, 16, 0);\n this.featureIndexArray = new FeatureIndexArray();\n this.promoteId = promoteId;\n }\n\n insert(feature: VectorTileFeature, geometry: Array>, featureIndex: number, sourceLayerIndex: number, bucketIndex: number, is3D?: boolean) {\n const key = this.featureIndexArray.length;\n this.featureIndexArray.emplaceBack(featureIndex, sourceLayerIndex, bucketIndex);\n\n const grid = is3D ? this.grid3D : this.grid;\n\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n bbox[0] = Math.min(bbox[0], p.x);\n bbox[1] = Math.min(bbox[1], p.y);\n bbox[2] = Math.max(bbox[2], p.x);\n bbox[3] = Math.max(bbox[3], p.y);\n }\n\n if (bbox[0] < EXTENT &&\n bbox[1] < EXTENT &&\n bbox[2] >= 0 &&\n bbox[3] >= 0) {\n grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]);\n }\n }\n }\n\n loadVTLayers(): {[_: string]: VectorTileLayer} {\n if (!this.vtLayers) {\n this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers;\n this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']);\n }\n return this.vtLayers;\n }\n\n // Finds non-symbol features in this tile at a particular position.\n query(\n args: QueryParameters,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n this.loadVTLayers();\n\n const params = args.params || {} as { filter: any; layers: string[]; availableImages: string[] },\n pixelsToTileUnits = EXTENT / args.tileSize / args.scale,\n filter = featureFilter(params.filter);\n\n const queryGeometry = args.queryGeometry;\n const queryPadding = args.queryPadding * pixelsToTileUnits;\n\n const bounds = getBounds(queryGeometry);\n const matching = this.grid.query(bounds.minX - queryPadding, bounds.minY - queryPadding, bounds.maxX + queryPadding, bounds.maxY + queryPadding);\n\n const cameraBounds = getBounds(args.cameraQueryGeometry);\n const matching3D = this.grid3D.query(\n cameraBounds.minX - queryPadding, cameraBounds.minY - queryPadding, cameraBounds.maxX + queryPadding, cameraBounds.maxY + queryPadding,\n (bx1, by1, bx2, by2) => {\n return polygonIntersectsBox(args.cameraQueryGeometry, bx1 - queryPadding, by1 - queryPadding, bx2 + queryPadding, by2 + queryPadding);\n });\n\n for (const key of matching3D) {\n matching.push(key);\n }\n\n matching.sort(topDownFeatureComparator);\n\n const result = {};\n let previousIndex;\n for (let k = 0; k < matching.length; k++) {\n const index = matching[k];\n\n // don't check the same feature more than once\n if (index === previousIndex) continue;\n previousIndex = index;\n\n const match = this.featureIndexArray.get(index);\n let featureGeometry = null;\n this.loadMatchingFeature(\n result,\n match.bucketIndex,\n match.sourceLayerIndex,\n match.featureIndex,\n filter,\n params.layers,\n params.availableImages,\n styleLayers,\n serializedLayers,\n sourceFeatureState,\n (feature: VectorTileFeature, styleLayer: StyleLayer, featureState: FeatureState) => {\n if (!featureGeometry) {\n featureGeometry = loadGeometry(feature);\n }\n\n return styleLayer.queryIntersectsFeature(queryGeometry, feature, featureState, featureGeometry, this.z, args.transform, pixelsToTileUnits, args.pixelPosMatrix);\n }\n );\n }\n\n return result;\n }\n\n loadMatchingFeature(\n result: {\n [_: string]: Array<{\n featureIndex: number;\n feature: GeoJSONFeature;\n intersectionZ?: boolean | number;\n }>;\n },\n bucketIndex: number,\n sourceLayerIndex: number,\n featureIndex: number,\n filter: FeatureFilter,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState?: SourceFeatureState,\n intersectionTest?: (\n feature: VectorTileFeature,\n styleLayer: StyleLayer,\n featureState: any,\n id: string | number | void\n ) => boolean | number) {\n\n const layerIDs = this.bucketLayerIDs[bucketIndex];\n if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs))\n return;\n\n const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);\n const sourceLayer = this.vtLayers[sourceLayerName];\n const feature = sourceLayer.feature(featureIndex);\n\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) {\n return;\n }\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n return;\n }\n\n const id = this.getId(feature, sourceLayerName);\n\n for (let l = 0; l < layerIDs.length; l++) {\n const layerID = layerIDs[l];\n\n if (filterLayerIDs && filterLayerIDs.indexOf(layerID) < 0) {\n continue;\n }\n\n const styleLayer = styleLayers[layerID];\n\n if (!styleLayer) continue;\n\n let featureState = {};\n if (id && sourceFeatureState) {\n // `feature-state` expression evaluation requires feature state to be available\n featureState = sourceFeatureState.getState(styleLayer.sourceLayer || '_geojsonTileLayer', id);\n }\n\n const serializedLayer = extend({}, serializedLayers[layerID]);\n\n serializedLayer.paint = evaluateProperties(serializedLayer.paint, styleLayer.paint, feature, featureState, availableImages);\n serializedLayer.layout = evaluateProperties(serializedLayer.layout, styleLayer.layout, feature, featureState, availableImages);\n\n const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer, featureState);\n if (!intersectionZ) {\n // Only applied for non-symbol features\n continue;\n }\n\n const geojsonFeature = new GeoJSONFeature(feature, this.z, this.x, this.y, id) as MapGeoJSONFeature;\n geojsonFeature.layer = serializedLayer;\n let layerResult = result[layerID];\n if (layerResult === undefined) {\n layerResult = result[layerID] = [];\n }\n layerResult.push({featureIndex, feature: geojsonFeature, intersectionZ});\n }\n }\n\n // Given a set of symbol indexes that have already been looked up,\n // return a matching set of GeoJSONFeatures\n lookupSymbolFeatures(symbolFeatureIndexes: Array,\n serializedLayers: {[_: string]: StyleLayer},\n bucketIndex: number,\n sourceLayerIndex: number,\n filterSpec: FilterSpecification,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer}) {\n const result = {};\n this.loadVTLayers();\n\n const filter = featureFilter(filterSpec);\n\n for (const symbolFeatureIndex of symbolFeatureIndexes) {\n this.loadMatchingFeature(\n result,\n bucketIndex,\n sourceLayerIndex,\n symbolFeatureIndex,\n filter,\n filterLayerIDs,\n availableImages,\n styleLayers,\n serializedLayers\n );\n\n }\n return result;\n }\n\n hasLayer(id: string) {\n for (const layerIDs of this.bucketLayerIDs) {\n for (const layerID of layerIDs) {\n if (id === layerID) return true;\n }\n }\n\n return false;\n }\n\n getId(feature: VectorTileFeature, sourceLayerId: string): string | number {\n let id: string | number = feature.id;\n if (this.promoteId) {\n const propName = typeof this.promoteId === 'string' ? this.promoteId : this.promoteId[sourceLayerId];\n id = feature.properties[propName] as string | number;\n if (typeof id === 'boolean') id = Number(id);\n }\n return id;\n }\n}\n\nregister(\n 'FeatureIndex',\n FeatureIndex,\n {omit: ['rawTileData', 'sourceLayerCoder']}\n);\n\nfunction evaluateProperties(serializedProperties, styleLayerProperties, feature, featureState, availableImages) {\n return mapObject(serializedProperties, (property, key) => {\n const prop = styleLayerProperties instanceof PossiblyEvaluated ? styleLayerProperties.get(key) : null;\n return prop && prop.evaluate ? prop.evaluate(feature, featureState, availableImages) : prop;\n });\n}\n\nfunction getBounds(geometry: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const p of geometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return {minX, minY, maxX, maxY};\n}\n\nfunction topDownFeatureComparator(a, b) {\n return b - a;\n}\n","import Point from '@mapbox/point-geometry';\n\n/**\n * Returns the part of a multiline that intersects with the provided rectangular box.\n *\n * @param lines - the lines to check\n * @param x1 - the left edge of the box\n * @param y1 - the top edge of the box\n * @param x2 - the right edge of the box\n * @param y2 - the bottom edge of the box\n * @returns lines\n */\nexport function clipLine(lines: Array>, x1: number, y1: number, x2: number, y2: number): Array> {\n const clippedLines = [];\n\n for (let l = 0; l < lines.length; l++) {\n const line = lines[l];\n let clippedLine;\n\n for (let i = 0; i < line.length - 1; i++) {\n let p0 = line[i];\n let p1 = line[i + 1];\n\n if (p0.x < x1 && p1.x < x1) {\n continue;\n } else if (p0.x < x1) {\n p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x < x1) {\n p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y < y1 && p1.y < y1) {\n continue;\n } else if (p0.y < y1) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n } else if (p1.y < y1) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n }\n\n if (p0.x >= x2 && p1.x >= x2) {\n continue;\n } else if (p0.x >= x2) {\n p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x >= x2) {\n p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y >= y2 && p1.y >= y2) {\n continue;\n } else if (p0.y >= y2) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n } else if (p1.y >= y2) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n }\n\n if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) {\n clippedLine = [p0];\n clippedLines.push(clippedLine);\n }\n\n clippedLine.push(p1);\n }\n }\n\n return clippedLines;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {register} from '../util/web_worker_transfer';\n\nexport class Anchor extends Point {\n angle: any;\n segment?: number;\n\n constructor(x: number, y: number, angle: number, segment?: number) {\n super(x, y);\n this.angle = angle;\n if (segment !== undefined) {\n this.segment = segment;\n }\n }\n\n clone() {\n return new Anchor(this.x, this.y, this.angle, this.segment);\n }\n}\n\nregister('Anchor', Anchor);\n","import type Point from '@mapbox/point-geometry';\nimport type {Anchor} from './anchor';\n\n/**\n * Labels placed around really sharp angles aren't readable. Check if any\n * part of the potential label has a combined angle that is too big.\n *\n * @param line - The line to check\n * @param anchor - The point on the line around which the label is anchored.\n * @param labelLength - The length of the label in geometry units.\n * @param windowSize - The check fails if the combined angles within a part of the line that is `windowSize` long is too big.\n * @param maxAngle - The maximum combined angle that any window along the label is allowed to have.\n *\n * @returns whether the label should be placed\n */\nexport function checkMaxAngle(line: Array, anchor: Anchor, labelLength: number, windowSize: number, maxAngle: number) {\n\n // horizontal labels and labels with length 0 always pass\n if (anchor.segment === undefined || labelLength === 0) return true;\n\n let p = anchor;\n let index = anchor.segment + 1;\n let anchorDistance = 0;\n\n // move backwards along the line to the first segment the label appears on\n while (anchorDistance > -labelLength / 2) {\n index--;\n\n // there isn't enough room for the label after the beginning of the line\n if (index < 0) return false;\n\n anchorDistance -= line[index].dist(p);\n p = line[index];\n }\n\n anchorDistance += line[index].dist(line[index + 1]);\n index++;\n\n // store recent corners and their total angle difference\n const recentCorners = [];\n let recentAngleDelta = 0;\n\n // move forwards by the length of the label and check angles along the way\n while (anchorDistance < labelLength / 2) {\n const prev = line[index - 1];\n const current = line[index];\n const next = line[index + 1];\n\n // there isn't enough room for the label before the end of the line\n if (!next) return false;\n\n let angleDelta = prev.angleTo(current) - current.angleTo(next);\n // restrict angle to -pi..pi range\n angleDelta = Math.abs(((angleDelta + 3 * Math.PI) % (Math.PI * 2)) - Math.PI);\n\n recentCorners.push({\n distance: anchorDistance,\n angleDelta\n });\n recentAngleDelta += angleDelta;\n\n // remove corners that are far enough away from the list of recent anchors\n while (anchorDistance - recentCorners[0].distance > windowSize) {\n recentAngleDelta -= recentCorners.shift().angleDelta;\n }\n\n // the sum of angles within the window area exceeds the maximum allowed value. check fails.\n if (recentAngleDelta > maxAngle) return false;\n\n index++;\n anchorDistance += current.dist(next);\n }\n\n // no part of the line had an angle greater than the maximum allowed. check passes.\n return true;\n}\n","import {interpolates} from '@maplibre/maplibre-gl-style-spec';\n\nimport {Anchor} from '../symbol/anchor';\nimport {checkMaxAngle} from './check_max_angle';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {Shaping, PositionedIcon} from './shaping';\n\nexport {getAnchors, getCenterAnchor};\n\nfunction getLineLength(line: Array): number {\n let lineLength = 0;\n for (let k = 0; k < line.length - 1; k++) {\n lineLength += line[k].dist(line[k + 1]);\n }\n return lineLength;\n}\n\nfunction getAngleWindowSize(\n shapedText: Shaping,\n glyphSize: number,\n boxScale: number\n): number {\n return shapedText ?\n 3 / 5 * glyphSize * boxScale :\n 0;\n}\n\nfunction getShapedLabelLength(shapedText?: Shaping | null, shapedIcon?: PositionedIcon | null): number {\n return Math.max(\n shapedText ? shapedText.right - shapedText.left : 0,\n shapedIcon ? shapedIcon.right - shapedIcon.left : 0);\n}\n\nfunction getCenterAnchor(line: Array,\n maxAngle: number,\n shapedText: Shaping,\n shapedIcon: PositionedIcon,\n glyphSize: number,\n boxScale: number) {\n const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);\n const labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale;\n\n let prevDistance = 0;\n const centerDistance = getLineLength(line) / 2;\n\n for (let i = 0; i < line.length - 1; i++) {\n\n const a = line[i],\n b = line[i + 1];\n\n const segmentDistance = a.dist(b);\n\n if (prevDistance + segmentDistance > centerDistance) {\n // The center is on this segment\n const t = (centerDistance - prevDistance) / segmentDistance,\n x = interpolates.number(a.x, b.x, t),\n y = interpolates.number(a.y, b.y, t);\n\n const anchor = new Anchor(x, y, b.angleTo(a), i);\n anchor._round();\n if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {\n return anchor;\n } else {\n return;\n }\n }\n\n prevDistance += segmentDistance;\n }\n}\n\nfunction getAnchors(line: Array,\n spacing: number,\n maxAngle: number,\n shapedText: Shaping,\n shapedIcon: PositionedIcon,\n glyphSize: number,\n boxScale: number,\n overscaling: number,\n tileExtent: number) {\n\n // Resample a line to get anchor points for labels and check that each\n // potential label passes text-max-angle check and has enough froom to fit\n // on the line.\n\n const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);\n const shapedLabelLength = getShapedLabelLength(shapedText, shapedIcon);\n const labelLength = shapedLabelLength * boxScale;\n\n // Is the line continued from outside the tile boundary?\n const isLineContinued = line[0].x === 0 || line[0].x === tileExtent || line[0].y === 0 || line[0].y === tileExtent;\n\n // Is the label long, relative to the spacing?\n // If so, adjust the spacing so there is always a minimum space of `spacing / 4` between label edges.\n if (spacing - labelLength < spacing / 4) {\n spacing = labelLength + spacing / 4;\n }\n\n // Offset the first anchor by:\n // Either half the label length plus a fixed extra offset if the line is not continued\n // Or half the spacing if the line is continued.\n\n // For non-continued lines, add a bit of fixed extra offset to avoid collisions at T intersections.\n const fixedExtraOffset = glyphSize * 2;\n\n const offset = !isLineContinued ?\n ((shapedLabelLength / 2 + fixedExtraOffset) * boxScale * overscaling) % spacing :\n (spacing / 2 * overscaling) % spacing;\n\n return resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, false, tileExtent);\n}\n\nfunction resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, placeAtMiddle, tileExtent) {\n\n const halfLabelLength = labelLength / 2;\n const lineLength = getLineLength(line);\n\n let distance = 0,\n markedDistance = offset - spacing;\n\n let anchors = [];\n\n for (let i = 0; i < line.length - 1; i++) {\n\n const a = line[i],\n b = line[i + 1];\n\n const segmentDist = a.dist(b),\n angle = b.angleTo(a);\n\n while (markedDistance + spacing < distance + segmentDist) {\n markedDistance += spacing;\n\n const t = (markedDistance - distance) / segmentDist,\n x = interpolates.number(a.x, b.x, t),\n y = interpolates.number(a.y, b.y, t);\n\n // Check that the point is within the tile boundaries and that\n // the label would fit before the beginning and end of the line\n // if placed at this point.\n if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent &&\n markedDistance - halfLabelLength >= 0 &&\n markedDistance + halfLabelLength <= lineLength) {\n const anchor = new Anchor(x, y, angle, i);\n anchor._round();\n\n if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {\n anchors.push(anchor);\n }\n }\n }\n\n distance += segmentDist;\n }\n\n if (!placeAtMiddle && !anchors.length && !isLineContinued) {\n // The first attempt at finding anchors at which labels can be placed failed.\n // Try again, but this time just try placing one anchor at the middle of the line.\n // This has the most effect for short lines in overscaled tiles, since the\n // initial offset used in overscaled tiles is calculated to align labels with positions in\n // parent tiles instead of placing the label as close to the beginning as possible.\n anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, true, tileExtent);\n }\n\n return anchors;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\n\nimport type {Anchor} from './anchor';\nimport type {PositionedIcon, Shaping} from './shaping';\nimport {SHAPING_DEFAULT_OFFSET} from './shaping';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport type {StyleImage} from '../style/style_image';\nimport ONE_EM from './one_em';\nimport {Rect} from '../render/glyph_atlas';\n\n/**\n * A textured quad for rendering a single icon or glyph.\n *\n * The zoom range the glyph can be shown is defined by minScale and maxScale.\n *\n * @param tl - The offset of the top left corner from the anchor.\n * @param tr - The offset of the top right corner from the anchor.\n * @param bl - The offset of the bottom left corner from the anchor.\n * @param br - The offset of the bottom right corner from the anchor.\n * @param tex - The texture coordinates.\n */\nexport type SymbolQuad = {\n tl: Point;\n tr: Point;\n bl: Point;\n br: Point;\n tex: {\n x: number;\n y: number;\n w: number;\n h: number;\n };\n pixelOffsetTL: Point;\n pixelOffsetBR: Point;\n writingMode: any | void;\n glyphOffset: [number, number];\n sectionIndex: number;\n isSDF: boolean;\n minFontScaleX: number;\n minFontScaleY: number;\n};\n\n// If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual\n// pixels. The quad needs to be padded to account for this, otherwise they'll look slightly clipped\n// on one edge in some cases.\nconst border = IMAGE_PADDING;\n\n/**\n * Create the quads used for rendering an icon.\n */\nexport function getIconQuads(\n shapedIcon: PositionedIcon,\n iconRotate: number,\n isSDFIcon: boolean,\n hasIconTextFit: boolean\n): Array {\n const quads = [];\n\n const image = shapedIcon.image;\n const pixelRatio = image.pixelRatio;\n const imageWidth = image.paddedRect.w - 2 * border;\n const imageHeight = image.paddedRect.h - 2 * border;\n\n const iconWidth = shapedIcon.right - shapedIcon.left;\n const iconHeight = shapedIcon.bottom - shapedIcon.top;\n\n const stretchX = image.stretchX || [[0, imageWidth]];\n const stretchY = image.stretchY || [[0, imageHeight]];\n\n const reduceRanges = (sum, range) => sum + range[1] - range[0];\n const stretchWidth = stretchX.reduce(reduceRanges, 0);\n const stretchHeight = stretchY.reduce(reduceRanges, 0);\n const fixedWidth = imageWidth - stretchWidth;\n const fixedHeight = imageHeight - stretchHeight;\n\n let stretchOffsetX = 0;\n let stretchContentWidth = stretchWidth;\n let stretchOffsetY = 0;\n let stretchContentHeight = stretchHeight;\n let fixedOffsetX = 0;\n let fixedContentWidth = fixedWidth;\n let fixedOffsetY = 0;\n let fixedContentHeight = fixedHeight;\n\n if (image.content && hasIconTextFit) {\n const content = image.content;\n stretchOffsetX = sumWithinRange(stretchX, 0, content[0]);\n stretchOffsetY = sumWithinRange(stretchY, 0, content[1]);\n stretchContentWidth = sumWithinRange(stretchX, content[0], content[2]);\n stretchContentHeight = sumWithinRange(stretchY, content[1], content[3]);\n fixedOffsetX = content[0] - stretchOffsetX;\n fixedOffsetY = content[1] - stretchOffsetY;\n fixedContentWidth = content[2] - content[0] - stretchContentWidth;\n fixedContentHeight = content[3] - content[1] - stretchContentHeight;\n }\n\n const makeBox = (left, top, right, bottom) => {\n\n const leftEm = getEmOffset(left.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);\n const leftPx = getPxOffset(left.fixed - fixedOffsetX, fixedContentWidth, left.stretch, stretchWidth);\n\n const topEm = getEmOffset(top.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);\n const topPx = getPxOffset(top.fixed - fixedOffsetY, fixedContentHeight, top.stretch, stretchHeight);\n\n const rightEm = getEmOffset(right.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);\n const rightPx = getPxOffset(right.fixed - fixedOffsetX, fixedContentWidth, right.stretch, stretchWidth);\n\n const bottomEm = getEmOffset(bottom.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);\n const bottomPx = getPxOffset(bottom.fixed - fixedOffsetY, fixedContentHeight, bottom.stretch, stretchHeight);\n\n const tl = new Point(leftEm, topEm);\n const tr = new Point(rightEm, topEm);\n const br = new Point(rightEm, bottomEm);\n const bl = new Point(leftEm, bottomEm);\n const pixelOffsetTL = new Point(leftPx / pixelRatio, topPx / pixelRatio);\n const pixelOffsetBR = new Point(rightPx / pixelRatio, bottomPx / pixelRatio);\n\n const angle = iconRotate * Math.PI / 180;\n\n if (angle) {\n const sin = Math.sin(angle),\n cos = Math.cos(angle),\n matrix = [cos, -sin, sin, cos];\n\n tl._matMult(matrix);\n tr._matMult(matrix);\n bl._matMult(matrix);\n br._matMult(matrix);\n }\n\n const x1 = left.stretch + left.fixed;\n const x2 = right.stretch + right.fixed;\n const y1 = top.stretch + top.fixed;\n const y2 = bottom.stretch + bottom.fixed;\n\n const subRect = {\n x: image.paddedRect.x + border + x1,\n y: image.paddedRect.y + border + y1,\n w: x2 - x1,\n h: y2 - y1\n };\n\n const minFontScaleX = fixedContentWidth / pixelRatio / iconWidth;\n const minFontScaleY = fixedContentHeight / pixelRatio / iconHeight;\n\n // Icon quad is padded, so texture coordinates also need to be padded.\n return {tl, tr, bl, br, tex: subRect, writingMode: undefined, glyphOffset: [0, 0], sectionIndex: 0, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, isSDF: isSDFIcon};\n };\n\n if (!hasIconTextFit || (!image.stretchX && !image.stretchY)) {\n quads.push(makeBox(\n {fixed: 0, stretch: -1},\n {fixed: 0, stretch: -1},\n {fixed: 0, stretch: imageWidth + 1},\n {fixed: 0, stretch: imageHeight + 1}));\n } else {\n const xCuts = stretchZonesToCuts(stretchX, fixedWidth, stretchWidth);\n const yCuts = stretchZonesToCuts(stretchY, fixedHeight, stretchHeight);\n\n for (let xi = 0; xi < xCuts.length - 1; xi++) {\n const x1 = xCuts[xi];\n const x2 = xCuts[xi + 1];\n for (let yi = 0; yi < yCuts.length - 1; yi++) {\n const y1 = yCuts[yi];\n const y2 = yCuts[yi + 1];\n quads.push(makeBox(x1, y1, x2, y2));\n }\n }\n }\n\n return quads;\n}\n\nfunction sumWithinRange(ranges, min, max) {\n let sum = 0;\n for (const range of ranges) {\n sum += Math.max(min, Math.min(max, range[1])) - Math.max(min, Math.min(max, range[0]));\n }\n return sum;\n}\n\nfunction stretchZonesToCuts(stretchZones, fixedSize, stretchSize) {\n const cuts = [{fixed: -border, stretch: 0}];\n\n for (const [c1, c2] of stretchZones) {\n const last = cuts[cuts.length - 1];\n cuts.push({\n fixed: c1 - last.stretch,\n stretch: last.stretch\n });\n cuts.push({\n fixed: c1 - last.stretch,\n stretch: last.stretch + (c2 - c1)\n });\n }\n cuts.push({\n fixed: fixedSize + border,\n stretch: stretchSize\n });\n return cuts;\n}\n\nfunction getEmOffset(stretchOffset, stretchSize, iconSize, iconOffset) {\n return stretchOffset / stretchSize * iconSize + iconOffset;\n}\n\nfunction getPxOffset(fixedOffset, fixedSize, stretchOffset, stretchSize) {\n return fixedOffset - fixedSize * stretchOffset / stretchSize;\n}\n\n/**\n * Create the quads used for rendering a text label.\n */\nexport function getGlyphQuads(\n anchor: Anchor,\n shaping: Shaping,\n textOffset: [number, number],\n layer: SymbolStyleLayer,\n alongLine: boolean,\n feature: Feature,\n imageMap: {[_: string]: StyleImage},\n allowVerticalPlacement: boolean\n): Array {\n\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}) * Math.PI / 180;\n const quads = [];\n\n for (const line of shaping.positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n if (!positionedGlyph.rect) continue;\n const textureRect: Rect = positionedGlyph.rect || {} as Rect;\n\n // The rects have an additional buffer that is not included in their size.\n const glyphPadding = 1.0;\n let rectBuffer = GLYPH_PBF_BORDER + glyphPadding;\n let isSDF = true;\n let pixelRatio = 1.0;\n let lineOffset = 0.0;\n\n const rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical;\n const halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2;\n\n // Align images and scaled glyphs in the middle of a vertical line.\n if (allowVerticalPlacement && shaping.verticalizable) {\n const scaledGlyphOffset = (positionedGlyph.scale - 1) * ONE_EM;\n const imageOffset = (ONE_EM - positionedGlyph.metrics.width * positionedGlyph.scale) / 2;\n lineOffset = line.lineOffset / 2 - (positionedGlyph.imageName ? -imageOffset : scaledGlyphOffset);\n }\n\n if (positionedGlyph.imageName) {\n const image = imageMap[positionedGlyph.imageName];\n isSDF = image.sdf;\n pixelRatio = image.pixelRatio;\n rectBuffer = IMAGE_PADDING / pixelRatio;\n }\n\n const glyphOffset = alongLine ?\n [positionedGlyph.x + halfAdvance, positionedGlyph.y] :\n [0, 0];\n\n let builtInOffset: [number, number] = alongLine ?\n [0, 0] :\n [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1] - lineOffset];\n\n let verticalizedLabelOffset = [0, 0] as [number, number];\n if (rotateVerticalGlyph) {\n // Vertical POI labels that are rotated 90deg CW and whose glyphs must preserve upright orientation\n // need to be rotated 90deg CCW. After a quad is rotated, it is translated to the original built-in offset.\n verticalizedLabelOffset = builtInOffset;\n builtInOffset = [0, 0];\n }\n\n const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1;\n\n const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];\n const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1];\n const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio;\n const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio;\n\n const tl = new Point(x1, y1);\n const tr = new Point(x2, y1);\n const bl = new Point(x1, y2);\n const br = new Point(x2, y2);\n\n if (rotateVerticalGlyph) {\n // Vertical-supporting glyphs are laid out in 24x24 point boxes (1 square em)\n // In horizontal orientation, the y values for glyphs are below the midline\n // and we use a \"yOffset\" of -17 to pull them up to the middle.\n // By rotating counter-clockwise around the point at the center of the left\n // edge of a 24x24 layout box centered below the midline, we align the center\n // of the glyphs with the horizontal midline, so the yOffset is no longer\n // necessary, but we also pull the glyph to the left along the x axis.\n // The y coordinate includes baseline yOffset, thus needs to be accounted\n // for when glyph is rotated and translated.\n const center = new Point(-halfAdvance, halfAdvance - SHAPING_DEFAULT_OFFSET);\n const verticalRotation = -Math.PI / 2;\n\n // xHalfWidthOffsetCorrection is a difference between full-width and half-width\n // advance, should be 0 for full-width glyphs and will pull up half-width glyphs.\n const xHalfWidthOffsetCorrection = ONE_EM / 2 - halfAdvance;\n const yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0.0;\n const halfWidthOffsetCorrection = new Point(5 - SHAPING_DEFAULT_OFFSET - xHalfWidthOffsetCorrection, -yImageOffsetCorrection);\n const verticalOffsetCorrection = new Point(...verticalizedLabelOffset);\n tl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n tr._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n bl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n br._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n }\n\n if (textRotate) {\n const sin = Math.sin(textRotate),\n cos = Math.cos(textRotate),\n matrix = [cos, -sin, sin, cos];\n\n tl._matMult(matrix);\n tr._matMult(matrix);\n bl._matMult(matrix);\n br._matMult(matrix);\n }\n\n const pixelOffsetTL = new Point(0, 0);\n const pixelOffsetBR = new Point(0, 0);\n const minFontScaleX = 0;\n const minFontScaleY = 0;\n quads.push({tl, tr, bl, br, tex: textureRect, writingMode: shaping.writingMode, glyphOffset, sectionIndex: positionedGlyph.sectionIndex, isSDF, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY});\n }\n }\n\n return quads;\n}\n","import type {CollisionBoxArray} from '../data/array_types.g';\nimport Point from '@mapbox/point-geometry';\nimport type {Anchor} from './anchor';\nimport {SymbolPadding} from '../style/style_layer/symbol_style_layer';\n\n/**\n * A CollisionFeature represents the area of the tile covered by a single label.\n * It is used with CollisionIndex to check if the label overlaps with any\n * previous labels. A CollisionFeature is mostly just a set of CollisionBox\n * objects.\n */\nexport class CollisionFeature {\n boxStartIndex: number;\n boxEndIndex: number;\n circleDiameter: number;\n\n /**\n * Create a CollisionFeature, adding its collision box data to the given collisionBoxArray in the process.\n * For line aligned labels a collision circle diameter is computed instead.\n *\n * @param anchor - The point along the line around which the label is anchored.\n * @param shaped - The text or icon shaping results.\n * @param boxScale - A magic number used to convert from glyph metrics units to geometry units.\n * @param padding - The amount of padding to add around the label edges.\n * @param alignLine - Whether the label is aligned with the line or the viewport.\n */\n constructor(collisionBoxArray: CollisionBoxArray,\n anchor: Anchor,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n shaped: any,\n boxScale: number,\n padding: SymbolPadding,\n alignLine: boolean,\n rotate: number) {\n\n this.boxStartIndex = collisionBoxArray.length;\n\n if (alignLine) {\n // Compute height of the shape in glyph metrics and apply collision padding.\n // Note that the pixel based 'text-padding' is applied at runtime\n let top = shaped.top;\n let bottom = shaped.bottom;\n const collisionPadding = shaped.collisionPadding;\n\n if (collisionPadding) {\n top -= collisionPadding[1];\n bottom += collisionPadding[3];\n }\n\n let height = bottom - top;\n\n if (height > 0) {\n // set minimum box height to avoid very many small labels\n height = Math.max(10, height);\n this.circleDiameter = height;\n }\n } else {\n // margin is in CSS order: [top, right, bottom, left]\n let y1 = shaped.top * boxScale - padding[0];\n let y2 = shaped.bottom * boxScale + padding[2];\n let x1 = shaped.left * boxScale - padding[3];\n let x2 = shaped.right * boxScale + padding[1];\n\n const collisionPadding = shaped.collisionPadding;\n if (collisionPadding) {\n x1 -= collisionPadding[0] * boxScale;\n y1 -= collisionPadding[1] * boxScale;\n x2 += collisionPadding[2] * boxScale;\n y2 += collisionPadding[3] * boxScale;\n }\n\n if (rotate) {\n // Account for *-rotate in point collision boxes\n // See https://github.com/mapbox/mapbox-gl-js/issues/6075\n // Doesn't account for icon-text-fit\n\n const tl = new Point(x1, y1);\n const tr = new Point(x2, y1);\n const bl = new Point(x1, y2);\n const br = new Point(x2, y2);\n\n const rotateRadians = rotate * Math.PI / 180;\n\n tl._rotate(rotateRadians);\n tr._rotate(rotateRadians);\n bl._rotate(rotateRadians);\n br._rotate(rotateRadians);\n\n // Collision features require an \"on-axis\" geometry,\n // so take the envelope of the rotated geometry\n // (may be quite large for wide labels rotated 45 degrees)\n x1 = Math.min(tl.x, tr.x, bl.x, br.x);\n x2 = Math.max(tl.x, tr.x, bl.x, br.x);\n y1 = Math.min(tl.y, tr.y, bl.y, br.y);\n y2 = Math.max(tl.y, tr.y, bl.y, br.y);\n }\n collisionBoxArray.emplaceBack(anchor.x, anchor.y, x1, y1, x2, y2, featureIndex, sourceLayerIndex, bucketIndex);\n }\n\n this.boxEndIndex = collisionBoxArray.length;\n }\n}\n","\nexport default class TinyQueue {\n constructor(data = [], compare = defaultCompare) {\n this.data = data;\n this.length = this.data.length;\n this.compare = compare;\n\n if (this.length > 0) {\n for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);\n }\n }\n\n push(item) {\n this.data.push(item);\n this.length++;\n this._up(this.length - 1);\n }\n\n pop() {\n if (this.length === 0) return undefined;\n\n const top = this.data[0];\n const bottom = this.data.pop();\n this.length--;\n\n if (this.length > 0) {\n this.data[0] = bottom;\n this._down(0);\n }\n\n return top;\n }\n\n peek() {\n return this.data[0];\n }\n\n _up(pos) {\n const {data, compare} = this;\n const item = data[pos];\n\n while (pos > 0) {\n const parent = (pos - 1) >> 1;\n const current = data[parent];\n if (compare(item, current) >= 0) break;\n data[pos] = current;\n pos = parent;\n }\n\n data[pos] = item;\n }\n\n _down(pos) {\n const {data, compare} = this;\n const halfLength = this.length >> 1;\n const item = data[pos];\n\n while (pos < halfLength) {\n let left = (pos << 1) + 1;\n let best = data[left];\n const right = left + 1;\n\n if (right < this.length && compare(data[right], best) < 0) {\n left = right;\n best = data[right];\n }\n if (compare(best, item) >= 0) break;\n\n data[pos] = best;\n pos = left;\n }\n\n data[pos] = item;\n }\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import Queue from 'tinyqueue';\n\nimport Point from '@mapbox/point-geometry';\nimport {distToSegmentSquared} from './intersection_tests';\n\n/**\n * Finds an approximation of a polygon's Pole Of Inaccessibiliy https://en.wikipedia.org/wiki/Pole_of_inaccessibility\n * This is a copy of http://github.com/mapbox/polylabel adapted to use Points\n *\n * @param polygonRings - first item in array is the outer ring followed optionally by the list of holes, should be an element of the result of util/classify_rings\n * @param precision - Specified in input coordinate units. If 0 returns after first run, if `> 0` repeatedly narrows the search space until the radius of the area searched for the best pole is less than precision\n * @param debug - Print some statistics to the console during execution\n * @returns Pole of Inaccessibiliy.\n */\nexport function findPoleOfInaccessibility(\n polygonRings: Array>,\n precision: number = 1,\n debug: boolean = false\n): Point {\n // find the bounding box of the outer ring\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n const outerRing = polygonRings[0];\n for (let i = 0; i < outerRing.length; i++) {\n const p = outerRing[i];\n if (!i || p.x < minX) minX = p.x;\n if (!i || p.y < minY) minY = p.y;\n if (!i || p.x > maxX) maxX = p.x;\n if (!i || p.y > maxY) maxY = p.y;\n }\n\n const width = maxX - minX;\n const height = maxY - minY;\n const cellSize = Math.min(width, height);\n let h = cellSize / 2;\n\n // a priority queue of cells in order of their \"potential\" (max distance to polygon)\n const cellQueue = new Queue([], compareMax);\n\n if (cellSize === 0) return new Point(minX, minY);\n\n // cover polygon with initial cells\n for (let x = minX; x < maxX; x += cellSize) {\n for (let y = minY; y < maxY; y += cellSize) {\n cellQueue.push(new Cell(x + h, y + h, h, polygonRings));\n }\n }\n\n // take centroid as the first best guess\n let bestCell = getCentroidCell(polygonRings);\n let numProbes = cellQueue.length;\n\n while (cellQueue.length) {\n // pick the most promising cell from the queue\n const cell = cellQueue.pop();\n\n // update the best cell if we found a better one\n if (cell.d > bestCell.d || !bestCell.d) {\n bestCell = cell;\n if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes);\n }\n\n // do not drill down further if there's no chance of a better solution\n if (cell.max - bestCell.d <= precision) continue;\n\n // split the cell into four cells\n h = cell.h / 2;\n cellQueue.push(new Cell(cell.p.x - h, cell.p.y - h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x + h, cell.p.y - h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x - h, cell.p.y + h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x + h, cell.p.y + h, h, polygonRings));\n numProbes += 4;\n }\n\n if (debug) {\n console.log(`num probes: ${numProbes}`);\n console.log(`best distance: ${bestCell.d}`);\n }\n\n return bestCell.p;\n}\n\nfunction compareMax(a, b) {\n return b.max - a.max;\n}\n\nfunction Cell(x, y, h, polygon) {\n this.p = new Point(x, y);\n this.h = h; // half the cell size\n this.d = pointToPolygonDist(this.p, polygon); // distance from cell center to polygon\n this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell\n}\n\n// signed distance from point to polygon outline (negative if point is outside)\nfunction pointToPolygonDist(p, polygon) {\n let inside = false;\n let minDistSq = Infinity;\n\n for (let k = 0; k < polygon.length; k++) {\n const ring = polygon[k];\n\n for (let i = 0, len = ring.length, j = len - 1; i < len; j = i++) {\n const a = ring[i];\n const b = ring[j];\n\n if ((a.y > p.y !== b.y > p.y) &&\n (p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x)) inside = !inside;\n\n minDistSq = Math.min(minDistSq, distToSegmentSquared(p, a, b));\n }\n }\n\n return (inside ? 1 : -1) * Math.sqrt(minDistSq);\n}\n\n// get polygon centroid\nfunction getCentroidCell(polygon) {\n let area = 0;\n let x = 0;\n let y = 0;\n const points = polygon[0];\n for (let i = 0, len = points.length, j = len - 1; i < len; j = i++) {\n const a = points[i];\n const b = points[j];\n const f = a.x * b.y - b.x * a.y;\n x += (a.x + b.x) * f;\n y += (a.y + b.y) * f;\n area += f * 3;\n }\n return new Cell(x / area, y / area, 0, polygon);\n}\n","import {VariableAnchorOffsetCollection, VariableAnchorOffsetCollectionSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {CanonicalTileID} from '../../source/tile_id';\nimport ONE_EM from '../../symbol/one_em';\nimport {SymbolStyleLayer} from './symbol_style_layer';\n\nexport enum TextAnchorEnum {\n 'center' = 1,\n 'left' = 2,\n 'right' = 3,\n 'top' = 4,\n 'bottom' = 5,\n 'top-left' = 6,\n 'top-right' = 7,\n 'bottom-left' = 8,\n 'bottom-right' = 9\n}\n\nexport type TextAnchor = keyof typeof TextAnchorEnum;\n\n// The radial offset is to the edge of the text box\n// In the horizontal direction, the edge of the text box is where glyphs start\n// But in the vertical direction, the glyphs appear to \"start\" at the baseline\n// We don't actually load baseline data, but we assume an offset of ONE_EM - 17\n// (see \"yOffset\" in shaping.js)\nconst baselineOffset = 7;\nexport const INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY;\n\nexport function evaluateVariableOffset(anchor: TextAnchor, offset: [number, number]): [number, number] {\n\n function fromRadialOffset(anchor: TextAnchor, radialOffset: number): [number, number] {\n let x = 0, y = 0;\n if (radialOffset < 0) radialOffset = 0; // Ignore negative offset.\n // solve for r where r^2 + r^2 = radialOffset^2\n const hypotenuse = radialOffset / Math.SQRT2;\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n y = hypotenuse - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n y = -hypotenuse + baselineOffset;\n break;\n case 'bottom':\n y = -radialOffset + baselineOffset;\n break;\n case 'top':\n y = radialOffset - baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n x = -hypotenuse;\n break;\n case 'top-left':\n case 'bottom-left':\n x = hypotenuse;\n break;\n case 'left':\n x = radialOffset;\n break;\n case 'right':\n x = -radialOffset;\n break;\n }\n\n return [x, y];\n }\n\n function fromTextOffset(anchor: TextAnchor, offsetX: number, offsetY: number): [number, number] {\n let x = 0, y = 0;\n // Use absolute offset values.\n offsetX = Math.abs(offsetX);\n offsetY = Math.abs(offsetY);\n\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n case 'top':\n y = offsetY - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n case 'bottom':\n y = -offsetY + baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n case 'right':\n x = -offsetX;\n break;\n case 'top-left':\n case 'bottom-left':\n case 'left':\n x = offsetX;\n break;\n }\n\n return [x, y];\n }\n\n return (offset[1] !== INVALID_TEXT_OFFSET) ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]);\n}\n\n// Helper to support both text-variable-anchor and text-variable-anchor-offset. Offset values converted from EMs to PXs\nexport function getTextVariableAnchorOffset(layer: SymbolStyleLayer, feature: SymbolFeature, canonical: CanonicalTileID): VariableAnchorOffsetCollection | null {\n const layout = layer.layout;\n // If style specifies text-variable-anchor-offset, just return it\n const variableAnchorOffset = layout.get('text-variable-anchor-offset')?.evaluate(feature, {}, canonical);\n\n if (variableAnchorOffset) {\n const sourceValues = variableAnchorOffset.values;\n const destValues: VariableAnchorOffsetCollectionSpecification = [];\n\n // Convert offsets from EM to PX, and apply baseline shift\n for (let i = 0; i < sourceValues.length; i += 2) {\n const anchor = destValues[i] = sourceValues[i] as TextAnchor;\n const offset = (sourceValues[i + 1] as [number, number]).map(t => t * ONE_EM) as [number, number];\n\n if (anchor.startsWith('top')) {\n offset[1] -= baselineOffset;\n } else if (anchor.startsWith('bottom')) {\n offset[1] += baselineOffset;\n }\n\n destValues[i + 1] = offset;\n }\n\n return new VariableAnchorOffsetCollection(destValues);\n }\n\n // If style specifies text-variable-anchor, convert to the new format\n const variableAnchor = layout.get('text-variable-anchor');\n\n if (variableAnchor) {\n let textOffset: [number, number];\n const unevaluatedLayout = layer._unevaluatedLayout;\n\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n if (unevaluatedLayout.getValue('text-radial-offset') !== undefined) {\n textOffset = [layout.get('text-radial-offset').evaluate(feature, {}, canonical) * ONE_EM, INVALID_TEXT_OFFSET];\n } else {\n textOffset = layout.get('text-offset').evaluate(feature, {}, canonical).map(t => t * ONE_EM) as [number, number];\n }\n\n const anchorOffsets: VariableAnchorOffsetCollectionSpecification = [];\n\n for (const anchor of variableAnchor) {\n anchorOffsets.push(anchor, evaluateVariableOffset(anchor, textOffset));\n }\n\n return new VariableAnchorOffsetCollection(anchorOffsets);\n }\n\n return null;\n}\n","import {Anchor} from './anchor';\n\nimport {getAnchors, getCenterAnchor} from './get_anchors';\nimport {clipLine} from './clip_line';\nimport {shapeText, shapeIcon, WritingMode, fitIconToText} from './shaping';\nimport {getGlyphQuads, getIconQuads} from './quads';\nimport {CollisionFeature} from './collision_feature';\nimport {warnOnce} from '../util/util';\nimport {\n allowsVerticalWritingMode,\n allowsLetterSpacing\n} from '../util/script_detection';\nimport {findPoleOfInaccessibility} from '../util/find_pole_of_inaccessibility';\nimport {classifyRings} from '../util/classify_rings';\nimport {EXTENT} from '../data/extent';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SIZE_PACK_FACTOR, MAX_PACKED_SIZE, MAX_GLYPH_ICON_SIZE} from './symbol_size';\nimport ONE_EM from './one_em';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Shaping, PositionedIcon, TextJustify} from './shaping';\nimport type {CollisionBoxArray, TextAnchorOffsetArray} from '../data/array_types.g';\nimport type {SymbolFeature} from '../data/bucket/symbol_bucket';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {GlyphPosition} from '../render/glyph_atlas';\nimport type {PossiblyEvaluatedPropertyValue} from '../style/properties';\n\nimport Point from '@mapbox/point-geometry';\nimport murmur3 from 'murmurhash-js';\nimport {getIconPadding, SymbolPadding} from '../style/style_layer/symbol_style_layer';\nimport {VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {getTextVariableAnchorOffset, evaluateVariableOffset, INVALID_TEXT_OFFSET, TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\n// The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and\n// `icon-size` at up to three:\n//\n// 1. `text-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `text-size`\n// expressions, and to calculate the box dimensions for icon-text-fit.\n// 2. `icon-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `icon-size`\n// expressions.\n// 3. `text-size` and `icon-size` at the zoom level of the bucket, plus one. Used to calculate collision boxes.\n// 4. `text-size` at zoom level 18. Used for something line-symbol-placement-related.\n// 5. For composite `*-size` expressions: two zoom levels of curve stops that \"cover\" the zoom level of the\n// bucket. These go into a vertex buffer and are used by the shader to interpolate the size at render time.\n//\n// (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below.\n//\ntype Sizes = {\n layoutTextSize: PossiblyEvaluatedPropertyValue; // (3),\n layoutIconSize: PossiblyEvaluatedPropertyValue; // (3),\n textMaxSize: PossiblyEvaluatedPropertyValue; // (4),\n compositeTextSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5),\n compositeIconSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5)\n};\n\ntype ShapedTextOrientations = {\n vertical: Shaping | false;\n horizontal: Record;\n};\n\nexport function performSymbolLayout(args: {\n bucket: SymbolBucket;\n glyphMap: {\n [_: string]: {\n [x: number]: StyleGlyph;\n };\n };\n glyphPositions: {\n [_: string]: {\n [x: number]: GlyphPosition;\n };\n };\n imageMap: {[_: string]: StyleImage};\n imagePositions: {[_: string]: ImagePosition};\n showCollisionBoxes: boolean;\n canonical: CanonicalTileID;\n}) {\n args.bucket.createArrays();\n\n const tileSize = 512 * args.bucket.overscaling;\n args.bucket.tilePixelRatio = EXTENT / tileSize;\n args.bucket.compareText = {};\n args.bucket.iconsNeedLinear = false;\n\n const layer = args.bucket.layers[0];\n const layout = layer.layout;\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n const sizes: Sizes = {\n // Filled in below, if *SizeData.kind is 'composite'\n // compositeIconSizes: undefined,\n // compositeTextSizes: undefined,\n layoutIconSize: unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n layoutTextSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n textMaxSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18))\n } as Sizes;\n\n if (args.bucket.textSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.textSizeData;\n sizes.compositeTextSizes = [\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n if (args.bucket.iconSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.iconSizeData;\n sizes.compositeIconSizes = [\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n const lineHeight = layout.get('text-line-height') * ONE_EM;\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n const keepUpright = layout.get('text-keep-upright');\n const textSize = layout.get('text-size');\n\n for (const feature of args.bucket.features) {\n const fontstack = layout.get('text-font').evaluate(feature, {}, args.canonical).join(',');\n const layoutTextSizeThisZoom = textSize.evaluate(feature, {}, args.canonical);\n const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, args.canonical);\n const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, args.canonical);\n\n const shapedTextOrientations: ShapedTextOrientations = {\n horizontal: {} as Record,\n vertical: undefined\n };\n const text = feature.text;\n let textOffset: [number, number] = [0, 0];\n if (text) {\n const unformattedText = text.toString();\n const spacing = layout.get('text-letter-spacing').evaluate(feature, {}, args.canonical) * ONE_EM;\n const spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0;\n\n const textAnchor = layout.get('text-anchor').evaluate(feature, {}, args.canonical);\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, args.canonical);\n\n if (!variableAnchorOffset) {\n const radialOffset = layout.get('text-radial-offset').evaluate(feature, {}, args.canonical);\n // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector\n // is calculated at placement time instead of layout time\n if (radialOffset) {\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n textOffset = evaluateVariableOffset(textAnchor, [radialOffset * ONE_EM, INVALID_TEXT_OFFSET]);\n } else {\n textOffset = (layout.get('text-offset').evaluate(feature, {}, args.canonical).map(t => t * ONE_EM) as [number, number]);\n }\n }\n\n let textJustify = textAlongLine ?\n 'center' :\n layout.get('text-justify').evaluate(feature, {}, args.canonical);\n\n const symbolPlacement = layout.get('symbol-placement');\n const maxWidth = symbolPlacement === 'point' ?\n layout.get('text-max-width').evaluate(feature, {}, args.canonical) * ONE_EM :\n 0;\n\n const addVerticalShapingForPointLabelIfNeeded = () => {\n if (args.bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) {\n // Vertical POI label placement is meant to be used for scripts that support vertical\n // writing mode, thus, default left justification is used. If Latin\n // scripts would need to be supported, this should take into account other justifications.\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor,\n 'left', spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n };\n\n // If this layer uses text-variable-anchor, generate shapings for all justification possibilities.\n if (!textAlongLine && variableAnchorOffset) {\n const justifications = new Set();\n\n if (textJustify === 'auto') {\n for (let i = 0; i < variableAnchorOffset.values.length; i += 2) {\n justifications.add(getAnchorJustification(variableAnchorOffset.values[i] as TextAnchor));\n }\n } else {\n justifications.add(textJustify);\n }\n\n let singleLine = false;\n for (const justification of justifications) {\n if (shapedTextOrientations.horizontal[justification]) continue;\n if (singleLine) {\n // If the shaping for the first justification was only a single line, we\n // can re-use it for the other justifications\n shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0];\n } else {\n // If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply\n // the offsets for the anchor in the placement step.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, 'center',\n justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) {\n shapedTextOrientations.horizontal[justification] = shaping;\n singleLine = shaping.positionedLines.length === 1;\n }\n }\n }\n\n addVerticalShapingForPointLabelIfNeeded();\n } else {\n if (textJustify === 'auto') {\n textJustify = getAnchorJustification(textAnchor);\n }\n\n // Horizontal point or line label.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed,\n textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) shapedTextOrientations.horizontal[textJustify] = shaping;\n\n // Vertical point label (if allowVerticalPlacement is enabled).\n addVerticalShapingForPointLabelIfNeeded();\n\n // Verticalized line label.\n if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) {\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify,\n spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n }\n }\n\n let shapedIcon;\n let isSDFIcon = false;\n if (feature.icon && feature.icon.name) {\n const image = args.imageMap[feature.icon.name];\n if (image) {\n shapedIcon = shapeIcon(\n args.imagePositions[feature.icon.name],\n layout.get('icon-offset').evaluate(feature, {}, args.canonical),\n layout.get('icon-anchor').evaluate(feature, {}, args.canonical));\n // null/undefined SDF property treated same as default (false)\n isSDFIcon = !!image.sdf;\n if (args.bucket.sdfIcons === undefined) {\n args.bucket.sdfIcons = isSDFIcon;\n } else if (args.bucket.sdfIcons !== isSDFIcon) {\n warnOnce('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer');\n }\n if (image.pixelRatio !== args.bucket.pixelRatio) {\n args.bucket.iconsNeedLinear = true;\n } else if (layout.get('icon-rotate').constantOr(1) !== 0) {\n args.bucket.iconsNeedLinear = true;\n }\n }\n }\n\n const shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical;\n args.bucket.iconsInText = shapedText ? shapedText.iconsInText : false;\n if (shapedText || shapedIcon) {\n addFeature(args.bucket, feature, shapedTextOrientations, shapedIcon, args.imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, args.canonical);\n }\n }\n\n if (args.showCollisionBoxes) {\n args.bucket.generateCollisionDebugBuffers();\n }\n}\n\n// Choose the justification that matches the direction of the TextAnchor\nexport function getAnchorJustification(anchor: TextAnchor): TextJustify {\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n return 'right';\n case 'left':\n case 'top-left':\n case 'bottom-left':\n return 'left';\n }\n return 'center';\n}\n\n/**\n * Given a feature and its shaped text and icon data, add a 'symbol\n * instance' for each _possible_ placement of the symbol feature.\n * (At render timePlaceSymbols#place() selects which of these instances to\n * show or hide based on collisions with symbols in other layers.)\n */\nfunction addFeature(bucket: SymbolBucket,\n feature: SymbolFeature,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon,\n imageMap: {[_: string]: StyleImage},\n sizes: Sizes,\n layoutTextSize: number,\n layoutIconSize: number,\n textOffset: [number, number],\n isSDFIcon: boolean, canonical: CanonicalTileID) {\n // To reduce the number of labels that jump around when zooming we need\n // to use a text-size value that is the same for all zoom levels.\n // bucket calculates text-size at a high zoom level so that all tiles can\n // use the same value when calculating anchor positions.\n let textMaxSize = sizes.textMaxSize.evaluate(feature, {});\n if (textMaxSize === undefined) {\n textMaxSize = layoutTextSize;\n }\n const layout = bucket.layers[0].layout;\n const iconOffset = layout.get('icon-offset').evaluate(feature, {}, canonical);\n const defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal);\n const glyphSize = 24,\n fontScale = layoutTextSize / glyphSize,\n textBoxScale = bucket.tilePixelRatio * fontScale,\n textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize,\n iconBoxScale = bucket.tilePixelRatio * layoutIconSize,\n symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing'),\n textPadding = layout.get('text-padding') * bucket.tilePixelRatio,\n iconPadding = getIconPadding(layout, feature, canonical, bucket.tilePixelRatio),\n textMaxAngle = layout.get('text-max-angle') / 180 * Math.PI,\n textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point',\n iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point',\n symbolPlacement = layout.get('symbol-placement'),\n textRepeatDistance = symbolMinDistance / 2;\n\n const iconTextFit = layout.get('icon-text-fit');\n let verticallyShapedIcon;\n // Adjust shaped icon size when icon-text-fit is used.\n if (shapedIcon && iconTextFit !== 'none') {\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n if (defaultHorizontalShaping) {\n shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n }\n\n const addSymbolAtAnchor = (line, anchor) => {\n if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) {\n // Symbol layers are drawn across tile boundaries, We filter out symbols\n // outside our tile boundaries (which may be included in vector tile buffers)\n // to prevent double-drawing symbols.\n return;\n }\n\n addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0],\n bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index,\n textBoxScale, [textPadding, textPadding, textPadding, textPadding], textAlongLine, textOffset,\n iconBoxScale, iconPadding, iconAlongLine, iconOffset,\n feature, sizes, isSDFIcon, canonical, layoutTextSize);\n };\n\n if (symbolPlacement === 'line') {\n for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) {\n const anchors = getAnchors(\n line,\n symbolMinDistance,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale,\n bucket.overscaling,\n EXTENT\n );\n for (const anchor of anchors) {\n const shapedText = defaultHorizontalShaping;\n if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (symbolPlacement === 'line-center') {\n // No clipping, multiple lines per feature are allowed\n // \"lines\" with only one point are ignored as in clipLines\n for (const line of feature.geometry) {\n if (line.length > 1) {\n const anchor = getCenterAnchor(\n line,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale);\n if (anchor) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (feature.type === 'Polygon') {\n for (const polygon of classifyRings(feature.geometry, 0)) {\n // 16 here represents 2 pixels\n const poi = findPoleOfInaccessibility(polygon, 16);\n addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0));\n }\n } else if (feature.type === 'LineString') {\n // https://github.com/mapbox/mapbox-gl-js/issues/3808\n for (const line of feature.geometry) {\n addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0));\n }\n } else if (feature.type === 'Point') {\n for (const points of feature.geometry) {\n for (const point of points) {\n addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0));\n }\n }\n }\n}\n\nfunction addTextVariableAnchorOffsets(textAnchorOffsets: TextAnchorOffsetArray, variableAnchorOffset: VariableAnchorOffsetCollection): [number, number] {\n const startIndex = textAnchorOffsets.length;\n const values = variableAnchorOffset?.values;\n\n if (values?.length > 0) {\n for (let i = 0; i < values.length; i += 2) {\n const anchor = TextAnchorEnum[values[i] as TextAnchor];\n const offset = values[i + 1] as [number, number];\n\n textAnchorOffsets.emplaceBack(anchor, offset[0], offset[1]);\n }\n }\n\n return [startIndex, textAnchorOffsets.length];\n}\n\nfunction addTextVertices(bucket: SymbolBucket,\n anchor: Point,\n shapedText: Shaping,\n imageMap: {[_: string]: StyleImage},\n layer: SymbolStyleLayer,\n textAlongLine: boolean,\n feature: SymbolFeature,\n textOffset: [number, number],\n lineArray: {\n lineStartIndex: number;\n lineLength: number;\n },\n writingMode: WritingMode,\n placementTypes: Array<'vertical' | 'center' | 'left' | 'right'>,\n placedTextSymbolIndices: {[_: string]: number},\n placedIconIndex: number,\n sizes: Sizes,\n canonical: CanonicalTileID) {\n const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset,\n layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement);\n\n const sizeData = bucket.textSizeData;\n let textSizeData = null;\n\n if (sizeData.kind === 'source') {\n textSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {})\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n textSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical)\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.text,\n glyphQuads,\n textSizeData,\n textOffset,\n textAlongLine,\n feature,\n writingMode,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n placedIconIndex,\n canonical);\n\n // The placedSymbolArray is used at render time in drawTileSymbols\n // These indices allow access to the array at collision detection time\n for (const placementType of placementTypes) {\n placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1;\n }\n\n return glyphQuads.length * 4;\n}\n\nfunction getDefaultHorizontalShaping(\n horizontalShaping: Record\n): Shaping | null {\n // We don't care which shaping we get because this is used for collision purposes\n // and all the justifications have the same collision box\n for (const justification in horizontalShaping) {\n return horizontalShaping[justification];\n }\n return null;\n}\n\n/**\n * Add a single label & icon placement.\n */\nfunction addSymbol(bucket: SymbolBucket,\n anchor: Anchor,\n line: Array,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon | void,\n imageMap: {[_: string]: StyleImage},\n verticallyShapedIcon: PositionedIcon | void,\n layer: SymbolStyleLayer,\n collisionBoxArray: CollisionBoxArray,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n textBoxScale: number,\n textPadding: SymbolPadding,\n textAlongLine: boolean,\n textOffset: [number, number],\n iconBoxScale: number,\n iconPadding: SymbolPadding,\n iconAlongLine: boolean,\n iconOffset: [number, number],\n feature: SymbolFeature,\n sizes: Sizes,\n isSDFIcon: boolean,\n canonical: CanonicalTileID,\n layoutTextSize: number) {\n const lineArray = bucket.addToLineVertexArray(anchor, line);\n\n let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature;\n\n let numIconVertices = 0;\n let numVerticalIconVertices = 0;\n let numHorizontalGlyphVertices = 0;\n let numVerticalGlyphVertices = 0;\n let placedIconSymbolIndex = -1;\n let verticalPlacedIconSymbolIndex = -1;\n const placedTextSymbolIndices: {[k: string]: number} = {};\n let key = murmur3('');\n\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n const textRotation = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n const verticalTextRotation = textRotation + 90.0;\n const verticalShaping = shapedTextOrientations.vertical;\n verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation);\n\n if (verticallyShapedIcon) {\n verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation);\n }\n }\n\n //Place icon first, so text can have a reference to its index in the placed symbol array.\n //Text symbols can lazily shift at render-time because of variable anchor placement.\n //If the style specifies an `icon-text-fit` then the icon would have to shift along with it.\n // For more info check `updateVariableAnchors` in `draw_symbol.js` .\n if (shapedIcon) {\n const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {});\n const hasIconTextFit = layer.layout.get('icon-text-fit') !== 'none';\n const iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit);\n const verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : undefined;\n iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/false, iconRotate);\n\n numIconVertices = iconQuads.length * 4;\n\n const sizeData = bucket.iconSizeData;\n let iconSizeData = null;\n\n if (sizeData.kind === 'source') {\n iconSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {})\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n iconSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical)\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.icon,\n iconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.none,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n\n if (verticalIconQuads) {\n numVerticalIconVertices = verticalIconQuads.length * 4;\n\n bucket.addSymbols(\n bucket.icon,\n verticalIconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.vertical,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n }\n }\n\n const justifications = Object.keys(shapedTextOrientations.horizontal) as TextJustify[];\n for (const justification of justifications) {\n const shaping = shapedTextOrientations.horizontal[justification];\n\n if (!textCollisionFeature) {\n key = murmur3(shaping.text);\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature\n // We're counting on all versions having similar dimensions\n textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate);\n }\n\n const singleLine = shaping.positionedLines.length === 1;\n numHorizontalGlyphVertices += addTextVertices(\n bucket, anchor, shaping, imageMap, layer, textAlongLine, feature, textOffset, lineArray,\n shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly,\n singleLine ? justifications : [justification],\n placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical);\n\n if (singleLine) {\n break;\n }\n }\n\n if (shapedTextOrientations.vertical) {\n numVerticalGlyphVertices += addTextVertices(\n bucket, anchor, shapedTextOrientations.vertical, imageMap, layer, textAlongLine, feature,\n textOffset, lineArray, WritingMode.vertical, ['vertical'], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical);\n }\n\n const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n // Check if runtime collision circles should be used for any of the collision features.\n // It is enough to choose the tallest feature shape as circles are always placed on a line.\n // All measurements are in glyph metrics and later converted into pixels using proper font size \"layoutTextSize\"\n let collisionCircleDiameter = -1;\n\n const getCollisionCircleHeight = (feature: CollisionFeature, prevHeight: number): number => {\n if (feature && feature.circleDiameter)\n return Math.max(feature.circleDiameter, prevHeight);\n return prevHeight;\n };\n\n collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter);\n const useRuntimeCollisionCircles = (collisionCircleDiameter > -1) ? 1 : 0;\n\n // Convert circle collision height into pixels\n if (useRuntimeCollisionCircles)\n collisionCircleDiameter *= layoutTextSize / ONE_EM;\n\n if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) warnOnce(\n 'Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907'\n );\n\n if (feature.sortKey !== undefined) {\n bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey as number);\n }\n\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, canonical);\n const [textAnchorOffsetStartIndex, textAnchorOffsetEndIndex] = addTextVariableAnchorOffsets(bucket.textAnchorOffsets, variableAnchorOffset);\n\n bucket.symbolInstances.emplaceBack(\n anchor.x,\n anchor.y,\n placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1,\n placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1,\n placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1,\n placedTextSymbolIndices.vertical || -1,\n placedIconSymbolIndex,\n verticalPlacedIconSymbolIndex,\n key,\n textBoxStartIndex,\n textBoxEndIndex,\n verticalTextBoxStartIndex,\n verticalTextBoxEndIndex,\n iconBoxStartIndex,\n iconBoxEndIndex,\n verticalIconBoxStartIndex,\n verticalIconBoxEndIndex,\n featureIndex,\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n numIconVertices,\n numVerticalIconVertices,\n useRuntimeCollisionCircles,\n 0,\n textBoxScale,\n collisionCircleDiameter,\n textAnchorOffsetStartIndex,\n textAnchorOffsetEndIndex);\n}\n\nfunction anchorIsTooClose(bucket: SymbolBucket, text: string, repeatDistance: number, anchor: Point) {\n const compareText = bucket.compareText;\n if (!(text in compareText)) {\n compareText[text] = [];\n } else {\n const otherAnchors = compareText[text];\n for (let k = otherAnchors.length - 1; k >= 0; k--) {\n if (anchor.dist(otherAnchors[k]) < repeatDistance) {\n // If it's within repeatDistance of one anchor, stop looking\n return true;\n }\n }\n }\n // If anchor is not within repeatDistance of any other anchor, add to array\n compareText[text].push(anchor);\n return false;\n}\n","\nconst ARRAY_TYPES = [\n Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n];\n\n/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */\n\nconst VERSION = 1; // serialized format version\nconst HEADER_SIZE = 8;\n\nexport default class KDBush {\n\n /**\n * Creates an index from raw `ArrayBuffer` data.\n * @param {ArrayBuffer} data\n */\n static from(data) {\n if (!(data instanceof ArrayBuffer)) {\n throw new Error('Data must be an instance of ArrayBuffer.');\n }\n const [magic, versionAndType] = new Uint8Array(data, 0, 2);\n if (magic !== 0xdb) {\n throw new Error('Data does not appear to be in a KDBush format.');\n }\n const version = versionAndType >> 4;\n if (version !== VERSION) {\n throw new Error(`Got v${version} data when expected v${VERSION}.`);\n }\n const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];\n if (!ArrayType) {\n throw new Error('Unrecognized array type.');\n }\n const [nodeSize] = new Uint16Array(data, 2, 1);\n const [numItems] = new Uint32Array(data, 4, 1);\n\n return new KDBush(numItems, nodeSize, ArrayType, data);\n }\n\n /**\n * Creates an index that will hold a given number of items.\n * @param {number} numItems\n * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).\n * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).\n * @param {ArrayBuffer} [data] (For internal use only)\n */\n constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) {\n if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`);\n\n this.numItems = +numItems;\n this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);\n this.ArrayType = ArrayType;\n this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;\n\n const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);\n const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;\n const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;\n const padCoords = (8 - idsByteSize % 8) % 8;\n\n if (arrayTypeIndex < 0) {\n throw new Error(`Unexpected typed array class: ${ArrayType}.`);\n }\n\n if (data && (data instanceof ArrayBuffer)) { // reconstruct an index from a buffer\n this.data = data;\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = numItems * 2;\n this._finished = true;\n } else { // initialize a new index\n this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = 0;\n this._finished = false;\n\n // set header\n new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);\n new Uint16Array(this.data, 2, 1)[0] = nodeSize;\n new Uint32Array(this.data, 4, 1)[0] = numItems;\n }\n }\n\n /**\n * Add a point to the index.\n * @param {number} x\n * @param {number} y\n * @returns {number} An incremental index associated with the added item (starting from `0`).\n */\n add(x, y) {\n const index = this._pos >> 1;\n this.ids[index] = index;\n this.coords[this._pos++] = x;\n this.coords[this._pos++] = y;\n return index;\n }\n\n /**\n * Perform indexing of the added points.\n */\n finish() {\n const numAdded = this._pos >> 1;\n if (numAdded !== this.numItems) {\n throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);\n }\n // kd-sort both arrays for efficient search\n sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);\n\n this._finished = true;\n return this;\n }\n\n /**\n * Search the index for items within a given bounding box.\n * @param {number} minX\n * @param {number} minY\n * @param {number} maxX\n * @param {number} maxY\n * @returns {number[]} An array of indices correponding to the found items.\n */\n range(minX, minY, maxX, maxY) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n\n // recursively search for items in range in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n const x = coords[2 * i];\n const y = coords[2 * i + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? minX <= x : minY <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? maxX >= x : maxY >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n\n /**\n * Search the index for items within a given radius.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @returns {number[]} An array of indices correponding to the found items.\n */\n within(qx, qy, r) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n const r2 = r * r;\n\n // recursively search for items within radius in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? qx - r <= x : qy - r <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? qx + r >= x : qy + r >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} nodeSize\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction sort(ids, coords, nodeSize, left, right, axis) {\n if (right - left <= nodeSize) return;\n\n const m = (left + right) >> 1; // middle index\n\n // sort ids and coords around the middle index so that the halves lie\n // either left/right or top/bottom correspondingly (taking turns)\n select(ids, coords, m, left, right, axis);\n\n // recursively kd-sort first half and second half on the opposite axis\n sort(ids, coords, nodeSize, left, m - 1, 1 - axis);\n sort(ids, coords, nodeSize, m + 1, right, 1 - axis);\n}\n\n/**\n * Custom Floyd-Rivest selection algorithm: sort ids and coords so that\n * [left..k-1] items are smaller than k-th item (on either x or y axis)\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} k\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction select(ids, coords, k, left, right, axis) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n select(ids, coords, k, newLeft, newRight, axis);\n }\n\n const t = coords[2 * k + axis];\n let i = left;\n let j = right;\n\n swapItem(ids, coords, left, k);\n if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);\n\n while (i < j) {\n swapItem(ids, coords, i, j);\n i++;\n j--;\n while (coords[2 * i + axis] < t) i++;\n while (coords[2 * j + axis] > t) j--;\n }\n\n if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);\n else {\n j++;\n swapItem(ids, coords, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} i\n * @param {number} j\n */\nfunction swapItem(ids, coords, i, j) {\n swap(ids, i, j);\n swap(coords, 2 * i, 2 * j);\n swap(coords, 2 * i + 1, 2 * j + 1);\n}\n\n/**\n * @param {InstanceType} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @param {number} ax\n * @param {number} ay\n * @param {number} bx\n * @param {number} by\n */\nfunction sqDist(ax, ay, bx, by) {\n const dx = ax - bx;\n const dy = ay - by;\n return dx * dx + dy * dy;\n}\n","import type {RequestParameters} from '../util/ajax';\n\nexport type PerformanceMetrics = {\n loadTime: number;\n fullLoadTime: number;\n fps: number;\n percentDroppedFrames: number;\n totalFrames: number;\n};\n\nexport enum PerformanceMarkers {\n create = 'create',\n load = 'load',\n fullLoad = 'fullLoad'\n}\n\nlet lastFrameTime = null;\nlet frameTimes = [];\n\nconst minFramerateTarget = 60;\nconst frameTimeTarget = 1000 / minFramerateTarget;\n\nconst loadTimeKey = 'loadTime';\nconst fullLoadTimeKey = 'fullLoadTime';\n\nexport const PerformanceUtils = {\n mark(marker: PerformanceMarkers) {\n performance.mark(marker);\n },\n frame(timestamp: number) {\n const currTimestamp = timestamp;\n if (lastFrameTime != null) {\n const frameTime = currTimestamp - lastFrameTime;\n frameTimes.push(frameTime);\n }\n lastFrameTime = currTimestamp;\n },\n clearMetrics() {\n lastFrameTime = null;\n frameTimes = [];\n performance.clearMeasures(loadTimeKey);\n performance.clearMeasures(fullLoadTimeKey);\n\n for (const marker in PerformanceMarkers) {\n performance.clearMarks(PerformanceMarkers[marker]);\n }\n },\n\n getPerformanceMetrics(): PerformanceMetrics {\n performance.measure(loadTimeKey, PerformanceMarkers.create, PerformanceMarkers.load);\n performance.measure(fullLoadTimeKey, PerformanceMarkers.create, PerformanceMarkers.fullLoad);\n const loadTime = performance.getEntriesByName(loadTimeKey)[0].duration;\n const fullLoadTime = performance.getEntriesByName(fullLoadTimeKey)[0].duration;\n const totalFrames = frameTimes.length;\n\n const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;\n const fps = 1 / avgFrameTime;\n\n // count frames that missed our framerate target\n const droppedFrames = frameTimes\n .filter((frameTime) => frameTime > frameTimeTarget)\n .reduce((acc, curr) => {\n return acc + (curr - frameTimeTarget) / frameTimeTarget;\n }, 0);\n const percentDroppedFrames = (droppedFrames / (totalFrames + droppedFrames)) * 100;\n\n return {\n loadTime,\n fullLoadTime,\n fps,\n percentDroppedFrames,\n totalFrames\n };\n }\n};\n\n/**\n * @internal\n * Safe wrapper for the performance resource timing API in web workers with graceful degradation\n */\nexport class RequestPerformance {\n _marks: {\n start: string;\n end: string;\n measure: string;\n };\n\n constructor (request: RequestParameters) {\n this._marks = {\n start: [request.url, 'start'].join('#'),\n end: [request.url, 'end'].join('#'),\n measure: request.url.toString()\n };\n\n performance.mark(this._marks.start);\n }\n\n finish() {\n performance.mark(this._marks.end);\n let resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // fallback if web worker implementation of perf.getEntriesByName returns empty\n if (resourceTimingData.length === 0) {\n performance.measure(this._marks.measure, this._marks.start, this._marks.end);\n resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // cleanup\n performance.clearMarks(this._marks.start);\n performance.clearMarks(this._marks.end);\n performance.clearMeasures(this._marks.measure);\n }\n\n return resourceTimingData;\n }\n}\n\nexport default performance;\n","import {StyleLayer} from './style_layer';\nimport {createStyleLayer} from './create_style_layer';\n\nimport {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {TypedStyleLayer} from './style_layer/typed_style_layer';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LayerConfigs = {[_: string]: LayerSpecification};\nexport type Family = Array;\n\nexport class StyleLayerIndex {\n familiesBySource: {\n [source: string]: {\n [sourceLayer: string]: Array>;\n };\n };\n keyCache: {[source: string]: string};\n\n _layerConfigs: LayerConfigs;\n _layers: {[_: string]: StyleLayer};\n\n constructor(layerConfigs?: Array | null) {\n this.keyCache = {};\n if (layerConfigs) {\n this.replace(layerConfigs);\n }\n }\n\n replace(layerConfigs: Array) {\n this._layerConfigs = {};\n this._layers = {};\n this.update(layerConfigs, []);\n }\n\n update(layerConfigs: Array, removedIds: Array) {\n for (const layerConfig of layerConfigs) {\n this._layerConfigs[layerConfig.id] = layerConfig;\n\n const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig);\n layer._featureFilter = featureFilter(layer.filter);\n if (this.keyCache[layerConfig.id])\n delete this.keyCache[layerConfig.id];\n }\n for (const id of removedIds) {\n delete this.keyCache[id];\n delete this._layerConfigs[id];\n delete this._layers[id];\n }\n\n this.familiesBySource = {};\n\n const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache);\n\n for (const layerConfigs of groups) {\n const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]);\n\n const layer = layers[0];\n if (layer.visibility === 'none') {\n continue;\n }\n\n const sourceId = layer.source || '';\n let sourceGroup = this.familiesBySource[sourceId];\n if (!sourceGroup) {\n sourceGroup = this.familiesBySource[sourceId] = {};\n }\n\n const sourceLayerId = layer.sourceLayer || '_geojsonTileLayer';\n let sourceLayerFamilies = sourceGroup[sourceLayerId];\n if (!sourceLayerFamilies) {\n sourceLayerFamilies = sourceGroup[sourceLayerId] = [];\n }\n\n sourceLayerFamilies.push(layers);\n }\n }\n}\n","import {AlphaImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {GlyphMetrics, StyleGlyph} from '../style/style_glyph';\n\nconst padding = 1;\n\n/**\n * A rectangle type with postion, width and height.\n */\nexport type Rect = {\n x: number;\n y: number;\n w: number;\n h: number;\n};\n\n/**\n * The glyph's position\n */\nexport type GlyphPosition = {\n rect: Rect;\n metrics: GlyphMetrics;\n};\n\n/**\n * The glyphs' positions\n */\nexport type GlyphPositions = {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n};\n\nexport class GlyphAtlas {\n image: AlphaImage;\n positions: GlyphPositions;\n\n constructor(stacks: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n }) {\n const positions = {};\n const bins = [];\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n const stackPositions = positions[stack] = {};\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n\n const bin = {\n x: 0,\n y: 0,\n w: src.bitmap.width + 2 * padding,\n h: src.bitmap.height + 2 * padding\n };\n bins.push(bin);\n stackPositions[id] = {rect: bin, metrics: src.metrics};\n }\n }\n\n const {w, h} = potpack(bins);\n const image = new AlphaImage({width: w || 1, height: h || 1});\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n const bin = positions[stack][id].rect;\n AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);\n }\n }\n\n this.image = image;\n this.positions = positions;\n }\n}\n\nregister('GlyphAtlas', GlyphAtlas);\n","import {FeatureIndex} from '../data/feature_index';\nimport {performSymbolLayout} from '../symbol/symbol_layout';\nimport {CollisionBoxArray} from '../data/array_types.g';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {LineBucket} from '../data/bucket/line_bucket';\nimport {FillBucket} from '../data/bucket/fill_bucket';\nimport {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';\nimport {warnOnce, mapObject} from '../util/util';\nimport {ImageAtlas} from '../render/image_atlas';\nimport {GlyphAtlas} from '../render/glyph_atlas';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {OverscaledTileID} from './tile_id';\n\nimport type {Bucket} from '../data/bucket';\nimport type {Actor} from '../util/actor';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {\n WorkerTileParameters,\n WorkerTileCallback,\n} from '../source/worker_source';\nimport type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {VectorTile} from '@mapbox/vector-tile';\nimport {Cancelable} from '../types/cancelable';\n\nexport class WorkerTile {\n tileID: OverscaledTileID;\n uid: string;\n zoom: number;\n pixelRatio: number;\n tileSize: number;\n source: string;\n promoteId: PromoteIdSpecification;\n overscaling: number;\n showCollisionBoxes: boolean;\n collectResourceTiming: boolean;\n returnDependencies: boolean;\n\n status: 'parsing' | 'done';\n data: VectorTile;\n collisionBoxArray: CollisionBoxArray;\n\n abort: (() => void);\n vectorTile: VectorTile;\n inFlightDependencies: Cancelable[];\n dependencySentinel: number;\n\n constructor(params: WorkerTileParameters) {\n this.tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y);\n this.uid = params.uid;\n this.zoom = params.zoom;\n this.pixelRatio = params.pixelRatio;\n this.tileSize = params.tileSize;\n this.source = params.source;\n this.overscaling = this.tileID.overscaleFactor();\n this.showCollisionBoxes = params.showCollisionBoxes;\n this.collectResourceTiming = !!params.collectResourceTiming;\n this.returnDependencies = !!params.returnDependencies;\n this.promoteId = params.promoteId;\n this.inFlightDependencies = [];\n this.dependencySentinel = -1;\n }\n\n parse(data: VectorTile, layerIndex: StyleLayerIndex, availableImages: Array, actor: Actor, callback: WorkerTileCallback) {\n this.status = 'parsing';\n this.data = data;\n\n this.collisionBoxArray = new CollisionBoxArray();\n const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort());\n\n const featureIndex = new FeatureIndex(this.tileID, this.promoteId);\n featureIndex.bucketLayerIDs = [];\n\n const buckets: {[_: string]: Bucket} = {};\n\n const options = {\n featureIndex,\n iconDependencies: {},\n patternDependencies: {},\n glyphDependencies: {},\n availableImages\n };\n\n const layerFamilies = layerIndex.familiesBySource[this.source];\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer = data.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n if (sourceLayer.version === 1) {\n warnOnce(`Vector tile source \"${this.source}\" layer \"${sourceLayerId}\" ` +\n 'does not use vector tile spec v2 and therefore may have some rendering errors.');\n }\n\n const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId);\n const features = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature = sourceLayer.feature(index);\n const id = featureIndex.getId(feature, sourceLayerId);\n features.push({feature, id, index, sourceLayerIndex});\n }\n\n for (const family of layerFamilies[sourceLayerId]) {\n const layer = family[0];\n\n if (layer.source !== this.source) {\n warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`);\n }\n if (layer.minzoom && this.zoom < Math.floor(layer.minzoom)) continue;\n if (layer.maxzoom && this.zoom >= layer.maxzoom) continue;\n if (layer.visibility === 'none') continue;\n\n recalculateLayers(family, this.zoom, availableImages);\n\n const bucket = buckets[layer.id] = layer.createBucket({\n index: featureIndex.bucketLayerIDs.length,\n layers: family,\n zoom: this.zoom,\n pixelRatio: this.pixelRatio,\n overscaling: this.overscaling,\n collisionBoxArray: this.collisionBoxArray,\n sourceLayerIndex,\n sourceID: this.source\n });\n\n bucket.populate(features, options, this.tileID.canonical);\n featureIndex.bucketLayerIDs.push(family.map((l) => l.id));\n }\n }\n\n let error: Error;\n let glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n };\n let iconMap: {[_: string]: StyleImage};\n let patternMap: {[_: string]: StyleImage};\n\n const stacks = mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number));\n\n this.inFlightDependencies.forEach((request) => request?.cancel());\n this.inFlightDependencies = [];\n\n // cancelling seems to be not sufficient, we seems to still manage to get a callback hit, so use a sentinel to drop stale results\n const dependencySentinel = ++this.dependencySentinel;\n if (Object.keys(stacks).length) {\n this.inFlightDependencies.push(actor.send('getGlyphs', {uid: this.uid, stacks, source: this.source, tileID: this.tileID, type: 'glyphs'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n glyphMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n glyphMap = {};\n }\n\n const icons = Object.keys(options.iconDependencies);\n if (icons.length) {\n this.inFlightDependencies.push(actor.send('getImages', {icons, source: this.source, tileID: this.tileID, type: 'icons'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n iconMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n iconMap = {};\n }\n\n const patterns = Object.keys(options.patternDependencies);\n if (patterns.length) {\n this.inFlightDependencies.push(actor.send('getImages', {icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n patternMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n patternMap = {};\n }\n\n maybePrepare.call(this);\n\n function maybePrepare() {\n if (error) {\n return callback(error);\n } else if (glyphMap && iconMap && patternMap) {\n const glyphAtlas = new GlyphAtlas(glyphMap);\n const imageAtlas = new ImageAtlas(iconMap, patternMap);\n\n for (const key in buckets) {\n const bucket = buckets[key];\n if (bucket instanceof SymbolBucket) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n performSymbolLayout({\n bucket,\n glyphMap,\n glyphPositions: glyphAtlas.positions,\n imageMap: iconMap,\n imagePositions: imageAtlas.iconPositions,\n showCollisionBoxes: this.showCollisionBoxes,\n canonical: this.tileID.canonical\n });\n } else if (bucket.hasPattern &&\n (bucket instanceof LineBucket ||\n bucket instanceof FillBucket ||\n bucket instanceof FillExtrusionBucket)) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions);\n }\n }\n\n this.status = 'done';\n callback(null, {\n buckets: Object.values(buckets).filter(b => !b.isEmpty()),\n featureIndex,\n collisionBoxArray: this.collisionBoxArray,\n glyphAtlasImage: glyphAtlas.image,\n imageAtlas,\n // Only used for benchmarking:\n glyphMap: this.returnDependencies ? glyphMap : null,\n iconMap: this.returnDependencies ? iconMap : null,\n glyphPositions: this.returnDependencies ? glyphAtlas.positions : null\n });\n }\n }\n }\n}\n\nfunction recalculateLayers(layers: ReadonlyArray, zoom: number, availableImages: Array) {\n // Layers are shared and may have been used by a WorkerTile with a different zoom.\n const parameters = new EvaluationParameters(zoom);\n for (const layer of layers) {\n layer.recalculate(parameters, availableImages);\n }\n}\n","import {ExpiryData, getArrayBuffer} from '../util/ajax';\n\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {WorkerTile} from './worker_tile';\nimport {extend} from '../util/util';\nimport {RequestPerformance} from '../util/performance';\n\nimport type {\n WorkerSource,\n WorkerTileParameters,\n WorkerTileCallback,\n TileParameters\n} from '../source/worker_source';\n\nimport type {Actor} from '../util/actor';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\nimport type {Callback} from '../types/callback';\nimport type {VectorTile} from '@mapbox/vector-tile';\n\nexport type LoadVectorTileResult = {\n vectorTile: VectorTile;\n rawData: ArrayBuffer;\n resourceTiming?: Array;\n} & ExpiryData;\n\ntype FetchingState = {\n rawTileData: ArrayBuffer;\n cacheControl: ExpiryData;\n resourceTiming: any;\n}\n\n/**\n * The callback when finished loading vector data\n */\nexport type LoadVectorDataCallback = Callback;\n\nexport type AbortVectorData = () => void;\nexport type LoadVectorData = (params: WorkerTileParameters, callback: LoadVectorDataCallback) => AbortVectorData | void;\n\n/**\n * Loads a vector tile\n */\nfunction loadVectorTile(params: WorkerTileParameters, callback: LoadVectorDataCallback) {\n const request = getArrayBuffer(params.request, (err?: Error | null, data?: ArrayBuffer | null, cacheControl?: string | null, expires?: string | null) => {\n if (err) {\n callback(err);\n } else if (data) {\n try {\n const vectorTile = new vt.VectorTile(new Protobuf(data));\n callback(null, {\n vectorTile,\n rawData: data,\n cacheControl,\n expires\n });\n } catch (ex) {\n const bytes = new Uint8Array(data);\n const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;\n let errorMessage = `Unable to parse the tile at ${params.request.url}, `;\n if (isGzipped) {\n errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';\n } else {\n errorMessage += `got error: ${ex.messge}`;\n }\n callback(new Error(errorMessage));\n }\n }\n });\n return () => {\n request.cancel();\n callback();\n };\n}\n\n/**\n * The {@link WorkerSource} implementation that supports {@link VectorTileSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory VectorTile\n * representation. To do so, create it with\n * `new VectorTileWorkerSource(actor, styleLayers, customLoadVectorDataFunction)`.\n */\nexport class VectorTileWorkerSource implements WorkerSource {\n actor: Actor;\n layerIndex: StyleLayerIndex;\n availableImages: Array;\n loadVectorData: LoadVectorData;\n fetching: {[_: string]: FetchingState };\n loading: {[_: string]: WorkerTile};\n loaded: {[_: string]: WorkerTile};\n\n /**\n * @param loadVectorData - Optional method for custom loading of a VectorTile\n * object based on parameters passed from the main-thread Source. See\n * {@link VectorTileWorkerSource#loadTile}. The default implementation simply\n * loads the pbf at `params.url`.\n */\n constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadVectorData?: LoadVectorData | null) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.loadVectorData = loadVectorData || loadVectorTile;\n this.fetching = {};\n this.loading = {};\n this.loaded = {};\n }\n\n /**\n * Implements {@link WorkerSource#loadTile}. Delegates to\n * {@link VectorTileWorkerSource#loadVectorData} (which by default expects\n * a `params.url` property) for fetching and producing a VectorTile object.\n */\n loadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const uid = params.uid;\n\n if (!this.loading)\n this.loading = {};\n\n const perf = (params && params.request && params.request.collectResourceTiming) ?\n new RequestPerformance(params.request) : false;\n\n const workerTile = this.loading[uid] = new WorkerTile(params);\n workerTile.abort = this.loadVectorData(params, (err, response) => {\n delete this.loading[uid];\n\n if (err || !response) {\n workerTile.status = 'done';\n this.loaded[uid] = workerTile;\n return callback(err);\n }\n\n const rawTileData = response.rawData;\n const cacheControl = {} as ExpiryData;\n if (response.expires) cacheControl.expires = response.expires;\n if (response.cacheControl) cacheControl.cacheControl = response.cacheControl;\n\n const resourceTiming = {} as {resourceTiming: any};\n if (perf) {\n const resourceTimingData = perf.finish();\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n if (resourceTimingData)\n resourceTiming.resourceTiming = JSON.parse(JSON.stringify(resourceTimingData));\n }\n\n workerTile.vectorTile = response.vectorTile;\n workerTile.parse(response.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => {\n delete this.fetching[uid];\n if (err || !result) return callback(err);\n\n // Transferring a copy of rawTileData because the worker needs to retain its copy.\n callback(null, extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming));\n });\n\n this.loaded = this.loaded || {};\n this.loaded[uid] = workerTile;\n // keep the original fetching state so that reload tile can pick it up if the original parse is cancelled by reloads' parse\n this.fetching[uid] = {rawTileData, cacheControl, resourceTiming};\n }) as AbortVectorData;\n }\n\n /**\n * Implements {@link WorkerSource#reloadTile}.\n */\n reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded;\n const uid = params.uid;\n if (loaded && loaded[uid]) {\n const workerTile = loaded[uid];\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n if (workerTile.status === 'parsing') {\n workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => {\n if (err || !result) return callback(err, result);\n\n // if we have cancelled the original parse, make sure to pass the rawTileData from the original fetch\n let parseResult;\n if (this.fetching[uid]) {\n const {rawTileData, cacheControl, resourceTiming} = this.fetching[uid];\n delete this.fetching[uid];\n parseResult = extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming);\n } else {\n parseResult = result;\n }\n\n callback(null, parseResult);\n });\n } else if (workerTile.status === 'done') {\n // if there was no vector tile data on the initial load, don't try and re-parse tile\n if (workerTile.vectorTile) {\n workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, callback);\n } else {\n callback();\n }\n }\n }\n }\n\n /**\n * Implements {@link WorkerSource#abortTile}.\n *\n * @param params - The tile parameters\n * @param callback - The callback\n */\n abortTile(params: TileParameters, callback: WorkerTileCallback) {\n const loading = this.loading,\n uid = params.uid;\n if (loading && loading[uid] && loading[uid].abort) {\n loading[uid].abort();\n delete loading[uid];\n }\n callback();\n }\n\n /**\n * Implements {@link WorkerSource#removeTile}.\n *\n * @param params - The tile parameters\n * @param callback - The callback\n */\n removeTile(params: TileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded && loaded[uid]) {\n delete loaded[uid];\n }\n callback();\n }\n}\n","import {DEMData} from '../data/dem_data';\nimport {RGBAImage} from '../util/image';\nimport type {Actor} from '../util/actor';\nimport type {\n WorkerDEMTileParameters,\n WorkerDEMTileCallback,\n TileParameters\n} from './worker_source';\nimport {getImageData, isImageBitmap} from '../util/util';\n\nexport class RasterDEMTileWorkerSource {\n actor: Actor;\n loaded: {[_: string]: DEMData};\n\n constructor() {\n this.loaded = {};\n }\n\n async loadTile(params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) {\n const {uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift} = params;\n const width = rawImageData.width + 2;\n const height = rawImageData.height + 2;\n const imagePixels: RGBAImage = isImageBitmap(rawImageData) ?\n new RGBAImage({width, height}, await getImageData(rawImageData, -1, -1, width, height)) :\n rawImageData;\n const dem = new DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);\n this.loaded = this.loaded || {};\n this.loaded[uid] = dem;\n callback(null, dem);\n }\n\n removeTile(params: TileParameters) {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded && loaded[uid]) {\n delete loaded[uid];\n }\n }\n}\n","\nmodule.exports = rewind;\n\nfunction rewind(gj, outer) {\n var type = gj && gj.type, i;\n\n if (type === 'FeatureCollection') {\n for (i = 0; i < gj.features.length; i++) rewind(gj.features[i], outer);\n\n } else if (type === 'GeometryCollection') {\n for (i = 0; i < gj.geometries.length; i++) rewind(gj.geometries[i], outer);\n\n } else if (type === 'Feature') {\n rewind(gj.geometry, outer);\n\n } else if (type === 'Polygon') {\n rewindRings(gj.coordinates, outer);\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < gj.coordinates.length; i++) rewindRings(gj.coordinates[i], outer);\n }\n\n return gj;\n}\n\nfunction rewindRings(rings, outer) {\n if (rings.length === 0) return;\n\n rewindRing(rings[0], outer);\n for (var i = 1; i < rings.length; i++) {\n rewindRing(rings[i], !outer);\n }\n}\n\nfunction rewindRing(ring, dir) {\n var area = 0, err = 0;\n for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {\n var k = (ring[i][0] - ring[j][0]) * (ring[j][1] + ring[i][1]);\n var m = area + k;\n err += Math.abs(area) >= Math.abs(k) ? area - m + k : k - m + area;\n area = m;\n }\n if (area + err >= 0 !== !!dir) ring.reverse();\n}\n","import Point from '@mapbox/point-geometry';\n\nimport mvt from '@mapbox/vector-tile';\nimport type {VectorTileFeature, VectorTileLayer, VectorTile} from '@mapbox/vector-tile';\nconst toGeoJSON = mvt.VectorTileFeature.prototype.toGeoJSON;\nimport {EXTENT} from '../data/extent';\nimport type {TileFeature, AnyProps} from 'supercluster';\nimport type {Feature as GeoJSONVTFeature} from 'geojson-vt';\n\nexport type Feature = TileFeature | GeoJSONVTFeature;\n\nclass FeatureWrapper implements VectorTileFeature {\n _feature: Feature;\n\n extent: number;\n type: Feature['type'];\n id: number;\n properties: {[_: string]: string | number | boolean};\n\n constructor(feature: Feature) {\n this._feature = feature;\n\n this.extent = EXTENT;\n this.type = feature.type;\n this.properties = feature.tags;\n\n // If the feature has a top-level `id` property, copy it over, but only\n // if it can be coerced to an integer, because this wrapper is used for\n // serializing geojson feature data into vector tile PBF data, and the\n // vector tile spec only supports integer values for feature ids --\n // allowing non-integer values here results in a non-compliant PBF\n // that causes an exception when it is parsed with vector-tile-js\n if ('id' in feature && !isNaN(feature.id as any)) {\n this.id = parseInt(feature.id, 10);\n }\n }\n\n loadGeometry() {\n if (this._feature.type === 1) {\n const geometry = [];\n for (const point of this._feature.geometry) {\n geometry.push([new Point(point[0], point[1])]);\n }\n return geometry;\n } else {\n const geometry = [];\n for (const ring of this._feature.geometry) {\n const newRing = [];\n for (const point of ring) {\n newRing.push(new Point(point[0], point[1]));\n }\n geometry.push(newRing);\n }\n return geometry;\n }\n }\n\n toGeoJSON(x: number, y: number, z: number) {\n return toGeoJSON.call(this, x, y, z);\n }\n}\n\nexport class GeoJSONWrapper implements VectorTile, VectorTileLayer {\n layers: {[_: string]: VectorTileLayer};\n name: string;\n extent: number;\n length: number;\n _features: Array;\n\n constructor(features: Array) {\n this.layers = {'_geojsonTileLayer': this};\n this.name = '_geojsonTileLayer';\n this.extent = EXTENT;\n this.length = features.length;\n this._features = features;\n }\n\n feature(i: number): VectorTileFeature {\n return new FeatureWrapper(this._features[i]);\n }\n}\n","'use strict'\n\nvar Point = require('@mapbox/point-geometry')\nvar VectorTileFeature = require('@mapbox/vector-tile').VectorTileFeature\n\nmodule.exports = GeoJSONWrapper\n\n// conform to vectortile api\nfunction GeoJSONWrapper (features, options) {\n this.options = options || {}\n this.features = features\n this.length = features.length\n}\n\nGeoJSONWrapper.prototype.feature = function (i) {\n return new FeatureWrapper(this.features[i], this.options.extent)\n}\n\nfunction FeatureWrapper (feature, extent) {\n this.id = typeof feature.id === 'number' ? feature.id : undefined\n this.type = feature.type\n this.rawGeometry = feature.type === 1 ? [feature.geometry] : feature.geometry\n this.properties = feature.tags\n this.extent = extent || 4096\n}\n\nFeatureWrapper.prototype.loadGeometry = function () {\n var rings = this.rawGeometry\n this.geometry = []\n\n for (var i = 0; i < rings.length; i++) {\n var ring = rings[i]\n var newRing = []\n for (var j = 0; j < ring.length; j++) {\n newRing.push(new Point(ring[j][0], ring[j][1]))\n }\n this.geometry.push(newRing)\n }\n return this.geometry\n}\n\nFeatureWrapper.prototype.bbox = function () {\n if (!this.geometry) this.loadGeometry()\n\n var rings = this.geometry\n var x1 = Infinity\n var x2 = -Infinity\n var y1 = Infinity\n var y2 = -Infinity\n\n for (var i = 0; i < rings.length; i++) {\n var ring = rings[i]\n\n for (var j = 0; j < ring.length; j++) {\n var coord = ring[j]\n\n x1 = Math.min(x1, coord.x)\n x2 = Math.max(x2, coord.x)\n y1 = Math.min(y1, coord.y)\n y2 = Math.max(y2, coord.y)\n }\n }\n\n return [x1, y1, x2, y2]\n}\n\nFeatureWrapper.prototype.toGeoJSON = VectorTileFeature.prototype.toGeoJSON\n","var Pbf = require('pbf')\nvar GeoJSONWrapper = require('./lib/geojson_wrapper')\n\nmodule.exports = fromVectorTileJs\nmodule.exports.fromVectorTileJs = fromVectorTileJs\nmodule.exports.fromGeojsonVt = fromGeojsonVt\nmodule.exports.GeoJSONWrapper = GeoJSONWrapper\n\n/**\n * Serialize a vector-tile-js-created tile to pbf\n *\n * @param {Object} tile\n * @return {Buffer} uncompressed, pbf-serialized tile data\n */\nfunction fromVectorTileJs (tile) {\n var out = new Pbf()\n writeTile(tile, out)\n return out.finish()\n}\n\n/**\n * Serialized a geojson-vt-created tile to pbf.\n *\n * @param {Object} layers - An object mapping layer names to geojson-vt-created vector tile objects\n * @param {Object} [options] - An object specifying the vector-tile specification version and extent that were used to create `layers`.\n * @param {Number} [options.version=1] - Version of vector-tile spec used\n * @param {Number} [options.extent=4096] - Extent of the vector tile\n * @return {Buffer} uncompressed, pbf-serialized tile data\n */\nfunction fromGeojsonVt (layers, options) {\n options = options || {}\n var l = {}\n for (var k in layers) {\n l[k] = new GeoJSONWrapper(layers[k].features, options)\n l[k].name = k\n l[k].version = options.version\n l[k].extent = options.extent\n }\n return fromVectorTileJs({ layers: l })\n}\n\nfunction writeTile (tile, pbf) {\n for (var key in tile.layers) {\n pbf.writeMessage(3, writeLayer, tile.layers[key])\n }\n}\n\nfunction writeLayer (layer, pbf) {\n pbf.writeVarintField(15, layer.version || 1)\n pbf.writeStringField(1, layer.name || '')\n pbf.writeVarintField(5, layer.extent || 4096)\n\n var i\n var context = {\n keys: [],\n values: [],\n keycache: {},\n valuecache: {}\n }\n\n for (i = 0; i < layer.length; i++) {\n context.feature = layer.feature(i)\n pbf.writeMessage(2, writeFeature, context)\n }\n\n var keys = context.keys\n for (i = 0; i < keys.length; i++) {\n pbf.writeStringField(3, keys[i])\n }\n\n var values = context.values\n for (i = 0; i < values.length; i++) {\n pbf.writeMessage(4, writeValue, values[i])\n }\n}\n\nfunction writeFeature (context, pbf) {\n var feature = context.feature\n\n if (feature.id !== undefined) {\n pbf.writeVarintField(1, feature.id)\n }\n\n pbf.writeMessage(2, writeProperties, context)\n pbf.writeVarintField(3, feature.type)\n pbf.writeMessage(4, writeGeometry, feature)\n}\n\nfunction writeProperties (context, pbf) {\n var feature = context.feature\n var keys = context.keys\n var values = context.values\n var keycache = context.keycache\n var valuecache = context.valuecache\n\n for (var key in feature.properties) {\n var value = feature.properties[key]\n\n var keyIndex = keycache[key]\n if (value === null) continue // don't encode null value properties\n\n if (typeof keyIndex === 'undefined') {\n keys.push(key)\n keyIndex = keys.length - 1\n keycache[key] = keyIndex\n }\n pbf.writeVarint(keyIndex)\n\n var type = typeof value\n if (type !== 'string' && type !== 'boolean' && type !== 'number') {\n value = JSON.stringify(value)\n }\n var valueKey = type + ':' + value\n var valueIndex = valuecache[valueKey]\n if (typeof valueIndex === 'undefined') {\n values.push(value)\n valueIndex = values.length - 1\n valuecache[valueKey] = valueIndex\n }\n pbf.writeVarint(valueIndex)\n }\n}\n\nfunction command (cmd, length) {\n return (length << 3) + (cmd & 0x7)\n}\n\nfunction zigzag (num) {\n return (num << 1) ^ (num >> 31)\n}\n\nfunction writeGeometry (feature, pbf) {\n var geometry = feature.loadGeometry()\n var type = feature.type\n var x = 0\n var y = 0\n var rings = geometry.length\n for (var r = 0; r < rings; r++) {\n var ring = geometry[r]\n var count = 1\n if (type === 1) {\n count = ring.length\n }\n pbf.writeVarint(command(1, count)) // moveto\n // do not write polygon closing path as lineto\n var lineCount = type === 3 ? ring.length - 1 : ring.length\n for (var i = 0; i < lineCount; i++) {\n if (i === 1 && type !== 1) {\n pbf.writeVarint(command(2, lineCount - 1)) // lineto\n }\n var dx = ring[i].x - x\n var dy = ring[i].y - y\n pbf.writeVarint(zigzag(dx))\n pbf.writeVarint(zigzag(dy))\n x += dx\n y += dy\n }\n if (type === 3) {\n pbf.writeVarint(command(7, 1)) // closepath\n }\n }\n}\n\nfunction writeValue (value, pbf) {\n var type = typeof value\n if (type === 'string') {\n pbf.writeStringField(1, value)\n } else if (type === 'boolean') {\n pbf.writeBooleanField(7, value)\n } else if (type === 'number') {\n if (value % 1 !== 0) {\n pbf.writeDoubleField(3, value)\n } else if (value < 0) {\n pbf.writeSVarintField(6, value)\n } else {\n pbf.writeVarintField(5, value)\n }\n }\n}\n","\nimport KDBush from 'kdbush';\n\nconst defaultOptions = {\n minZoom: 0, // min zoom to generate clusters on\n maxZoom: 16, // max zoom level to cluster the points on\n minPoints: 2, // minimum points to form a cluster\n radius: 40, // cluster radius in pixels\n extent: 512, // tile extent (radius is calculated relative to it)\n nodeSize: 64, // size of the KD-tree leaf node, affects performance\n log: false, // whether to log timing info\n\n // whether to generate numeric ids for input features (in vector tiles)\n generateId: false,\n\n // a reduce function for calculating custom cluster properties\n reduce: null, // (accumulated, props) => { accumulated.sum += props.sum; }\n\n // properties to use for individual points when running the reducer\n map: props => props // props => ({sum: props.my_value})\n};\n\nconst fround = Math.fround || (tmp => ((x) => { tmp[0] = +x; return tmp[0]; }))(new Float32Array(1));\n\nconst OFFSET_ZOOM = 2;\nconst OFFSET_ID = 3;\nconst OFFSET_PARENT = 4;\nconst OFFSET_NUM = 5;\nconst OFFSET_PROP = 6;\n\nexport default class Supercluster {\n constructor(options) {\n this.options = Object.assign(Object.create(defaultOptions), options);\n this.trees = new Array(this.options.maxZoom + 1);\n this.stride = this.options.reduce ? 7 : 6;\n this.clusterProps = [];\n }\n\n load(points) {\n const {log, minZoom, maxZoom} = this.options;\n\n if (log) console.time('total time');\n\n const timerId = `prepare ${ points.length } points`;\n if (log) console.time(timerId);\n\n this.points = points;\n\n // generate a cluster object for each point and index input points into a KD-tree\n const data = [];\n\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n if (!p.geometry) continue;\n\n const [lng, lat] = p.geometry.coordinates;\n const x = fround(lngX(lng));\n const y = fround(latY(lat));\n // store internal point/cluster data in flat numeric arrays for performance\n data.push(\n x, y, // projected point coordinates\n Infinity, // the last zoom the point was processed at\n i, // index of the source feature in the original input array\n -1, // parent cluster id\n 1 // number of points in a cluster\n );\n if (this.options.reduce) data.push(0); // noop\n }\n let tree = this.trees[maxZoom + 1] = this._createTree(data);\n\n if (log) console.timeEnd(timerId);\n\n // cluster points on max zoom, then cluster the results on previous zoom, etc.;\n // results in a cluster hierarchy across zoom levels\n for (let z = maxZoom; z >= minZoom; z--) {\n const now = +Date.now();\n\n // create a new set of clusters for the zoom and index them with a KD-tree\n tree = this.trees[z] = this._createTree(this._cluster(tree, z));\n\n if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, +Date.now() - now);\n }\n\n if (log) console.timeEnd('total time');\n\n return this;\n }\n\n getClusters(bbox, zoom) {\n let minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180;\n const minLat = Math.max(-90, Math.min(90, bbox[1]));\n let maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180;\n const maxLat = Math.max(-90, Math.min(90, bbox[3]));\n\n if (bbox[2] - bbox[0] >= 360) {\n minLng = -180;\n maxLng = 180;\n } else if (minLng > maxLng) {\n const easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom);\n const westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom);\n return easternHem.concat(westernHem);\n }\n\n const tree = this.trees[this._limitZoom(zoom)];\n const ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat));\n const data = tree.data;\n const clusters = [];\n for (const id of ids) {\n const k = this.stride * id;\n clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n return clusters;\n }\n\n getChildren(clusterId) {\n const originId = this._getOriginId(clusterId);\n const originZoom = this._getOriginZoom(clusterId);\n const errorMsg = 'No cluster with the specified id.';\n\n const tree = this.trees[originZoom];\n if (!tree) throw new Error(errorMsg);\n\n const data = tree.data;\n if (originId * this.stride >= data.length) throw new Error(errorMsg);\n\n const r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1));\n const x = data[originId * this.stride];\n const y = data[originId * this.stride + 1];\n const ids = tree.within(x, y, r);\n const children = [];\n for (const id of ids) {\n const k = id * this.stride;\n if (data[k + OFFSET_PARENT] === clusterId) {\n children.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n }\n\n if (children.length === 0) throw new Error(errorMsg);\n\n return children;\n }\n\n getLeaves(clusterId, limit, offset) {\n limit = limit || 10;\n offset = offset || 0;\n\n const leaves = [];\n this._appendLeaves(leaves, clusterId, limit, offset, 0);\n\n return leaves;\n }\n\n getTile(z, x, y) {\n const tree = this.trees[this._limitZoom(z)];\n const z2 = Math.pow(2, z);\n const {extent, radius} = this.options;\n const p = radius / extent;\n const top = (y - p) / z2;\n const bottom = (y + 1 + p) / z2;\n\n const tile = {\n features: []\n };\n\n this._addTileFeatures(\n tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom),\n tree.data, x, y, z2, tile);\n\n if (x === 0) {\n this._addTileFeatures(\n tree.range(1 - p / z2, top, 1, bottom),\n tree.data, z2, y, z2, tile);\n }\n if (x === z2 - 1) {\n this._addTileFeatures(\n tree.range(0, top, p / z2, bottom),\n tree.data, -1, y, z2, tile);\n }\n\n return tile.features.length ? tile : null;\n }\n\n getClusterExpansionZoom(clusterId) {\n let expansionZoom = this._getOriginZoom(clusterId) - 1;\n while (expansionZoom <= this.options.maxZoom) {\n const children = this.getChildren(clusterId);\n expansionZoom++;\n if (children.length !== 1) break;\n clusterId = children[0].properties.cluster_id;\n }\n return expansionZoom;\n }\n\n _appendLeaves(result, clusterId, limit, offset, skipped) {\n const children = this.getChildren(clusterId);\n\n for (const child of children) {\n const props = child.properties;\n\n if (props && props.cluster) {\n if (skipped + props.point_count <= offset) {\n // skip the whole cluster\n skipped += props.point_count;\n } else {\n // enter the cluster\n skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped);\n // exit the cluster\n }\n } else if (skipped < offset) {\n // skip a single point\n skipped++;\n } else {\n // add a single point\n result.push(child);\n }\n if (result.length === limit) break;\n }\n\n return skipped;\n }\n\n _createTree(data) {\n const tree = new KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array);\n for (let i = 0; i < data.length; i += this.stride) tree.add(data[i], data[i + 1]);\n tree.finish();\n tree.data = data;\n return tree;\n }\n\n _addTileFeatures(ids, data, x, y, z2, tile) {\n for (const i of ids) {\n const k = i * this.stride;\n const isCluster = data[k + OFFSET_NUM] > 1;\n\n let tags, px, py;\n if (isCluster) {\n tags = getClusterProperties(data, k, this.clusterProps);\n px = data[k];\n py = data[k + 1];\n } else {\n const p = this.points[data[k + OFFSET_ID]];\n tags = p.properties;\n const [lng, lat] = p.geometry.coordinates;\n px = lngX(lng);\n py = latY(lat);\n }\n\n const f = {\n type: 1,\n geometry: [[\n Math.round(this.options.extent * (px * z2 - x)),\n Math.round(this.options.extent * (py * z2 - y))\n ]],\n tags\n };\n\n // assign id\n let id;\n if (isCluster || this.options.generateId) {\n // optionally generate id for points\n id = data[k + OFFSET_ID];\n } else {\n // keep id if already assigned\n id = this.points[data[k + OFFSET_ID]].id;\n }\n\n if (id !== undefined) f.id = id;\n\n tile.features.push(f);\n }\n }\n\n _limitZoom(z) {\n return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1));\n }\n\n _cluster(tree, zoom) {\n const {radius, extent, reduce, minPoints} = this.options;\n const r = radius / (extent * Math.pow(2, zoom));\n const data = tree.data;\n const nextData = [];\n const stride = this.stride;\n\n // loop through each point\n for (let i = 0; i < data.length; i += stride) {\n // if we've already visited the point at this zoom level, skip it\n if (data[i + OFFSET_ZOOM] <= zoom) continue;\n data[i + OFFSET_ZOOM] = zoom;\n\n // find all nearby points\n const x = data[i];\n const y = data[i + 1];\n const neighborIds = tree.within(data[i], data[i + 1], r);\n\n const numPointsOrigin = data[i + OFFSET_NUM];\n let numPoints = numPointsOrigin;\n\n // count the number of points in a potential cluster\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n // filter out neighbors that are already processed\n if (data[k + OFFSET_ZOOM] > zoom) numPoints += data[k + OFFSET_NUM];\n }\n\n // if there were neighbors to merge, and there are enough points to form a cluster\n if (numPoints > numPointsOrigin && numPoints >= minPoints) {\n let wx = x * numPointsOrigin;\n let wy = y * numPointsOrigin;\n\n let clusterProperties;\n let clusterPropIndex = -1;\n\n // encode both zoom and point index on which the cluster originated -- offset by total length of features\n const id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length;\n\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice)\n\n const numPoints2 = data[k + OFFSET_NUM];\n wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center\n wy += data[k + 1] * numPoints2;\n\n data[k + OFFSET_PARENT] = id;\n\n if (reduce) {\n if (!clusterProperties) {\n clusterProperties = this._map(data, i, true);\n clusterPropIndex = this.clusterProps.length;\n this.clusterProps.push(clusterProperties);\n }\n reduce(clusterProperties, this._map(data, k));\n }\n }\n\n data[i + OFFSET_PARENT] = id;\n nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints);\n if (reduce) nextData.push(clusterPropIndex);\n\n } else { // left points as unclustered\n for (let j = 0; j < stride; j++) nextData.push(data[i + j]);\n\n if (numPoints > 1) {\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom;\n for (let j = 0; j < stride; j++) nextData.push(data[k + j]);\n }\n }\n }\n }\n\n return nextData;\n }\n\n // get index of the point from which the cluster originated\n _getOriginId(clusterId) {\n return (clusterId - this.points.length) >> 5;\n }\n\n // get zoom of the point from which the cluster originated\n _getOriginZoom(clusterId) {\n return (clusterId - this.points.length) % 32;\n }\n\n _map(data, i, clone) {\n if (data[i + OFFSET_NUM] > 1) {\n const props = this.clusterProps[data[i + OFFSET_PROP]];\n return clone ? Object.assign({}, props) : props;\n }\n const original = this.points[data[i + OFFSET_ID]].properties;\n const result = this.options.map(original);\n return clone && result === original ? Object.assign({}, result) : result;\n }\n}\n\nfunction getClusterJSON(data, i, clusterProps) {\n return {\n type: 'Feature',\n id: data[i + OFFSET_ID],\n properties: getClusterProperties(data, i, clusterProps),\n geometry: {\n type: 'Point',\n coordinates: [xLng(data[i]), yLat(data[i + 1])]\n }\n };\n}\n\nfunction getClusterProperties(data, i, clusterProps) {\n const count = data[i + OFFSET_NUM];\n const abbrev =\n count >= 10000 ? `${Math.round(count / 1000) }k` :\n count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count;\n const propIndex = data[i + OFFSET_PROP];\n const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]);\n return Object.assign(properties, {\n cluster: true,\n cluster_id: data[i + OFFSET_ID],\n point_count: count,\n point_count_abbreviated: abbrev\n });\n}\n\n// longitude/latitude to spherical mercator in [0..1] range\nfunction lngX(lng) {\n return lng / 360 + 0.5;\n}\nfunction latY(lat) {\n const sin = Math.sin(lat * Math.PI / 180);\n const y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);\n return y < 0 ? 0 : y > 1 ? 1 : y;\n}\n\n// spherical mercator to longitude/latitude\nfunction xLng(x) {\n return (x - 0.5) * 360;\n}\nfunction yLat(y) {\n const y2 = (180 - y * 360) * Math.PI / 180;\n return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90;\n}\n","\n// calculate simplification data using optimized Douglas-Peucker algorithm\n\nexport default function simplify(coords, first, last, sqTolerance) {\n var maxSqDist = sqTolerance;\n var mid = (last - first) >> 1;\n var minPosToMid = last - first;\n var index;\n\n var ax = coords[first];\n var ay = coords[first + 1];\n var bx = coords[last];\n var by = coords[last + 1];\n\n for (var i = first + 3; i < last; i += 3) {\n var d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n\n } else if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n var posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n\n if (maxSqDist > sqTolerance) {\n if (index - first > 3) simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3) simplify(coords, index, last, sqTolerance);\n }\n}\n\n// square distance from a point to a segment\nfunction getSqSegDist(px, py, x, y, bx, by) {\n\n var dx = bx - x;\n var dy = by - y;\n\n if (dx !== 0 || dy !== 0) {\n\n var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n\n if (t > 1) {\n x = bx;\n y = by;\n\n } else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n\n dx = px - x;\n dy = py - y;\n\n return dx * dx + dy * dy;\n}\n","\nexport default function createFeature(id, type, geom, tags) {\n var feature = {\n id: typeof id === 'undefined' ? null : id,\n type: type,\n geometry: geom,\n tags: tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n calcBBox(feature);\n return feature;\n}\n\nfunction calcBBox(feature) {\n var geom = feature.geometry;\n var type = feature.type;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n\n } else if (type === 'Polygon' || type === 'MultiLineString') {\n for (var i = 0; i < geom.length; i++) {\n calcLineBBox(feature, geom[i]);\n }\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < geom.length; i++) {\n for (var j = 0; j < geom[i].length; j++) {\n calcLineBBox(feature, geom[i][j]);\n }\n }\n }\n}\n\nfunction calcLineBBox(feature, geom) {\n for (var i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n","\nimport simplify from './simplify';\nimport createFeature from './feature';\n\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\n\nexport default function convert(data, options) {\n var features = [];\n if (data.type === 'FeatureCollection') {\n for (var i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n\n } else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n\n } else {\n // single geometry or a geometry collection\n convertFeature(features, {geometry: data}, options);\n }\n\n return features;\n}\n\nfunction convertFeature(features, geojson, options, index) {\n if (!geojson.geometry) return;\n\n var coords = geojson.geometry.coordinates;\n var type = geojson.geometry.type;\n var tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n var geometry = [];\n var id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n } else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n\n } else if (type === 'MultiPoint') {\n for (var i = 0; i < coords.length; i++) {\n convertPoint(coords[i], geometry);\n }\n\n } else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n\n } else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (i = 0; i < coords.length; i++) {\n geometry = [];\n convertLine(coords[i], geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n } else {\n convertLines(coords, geometry, tolerance, false);\n }\n\n } else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < coords.length; i++) {\n var polygon = [];\n convertLines(coords[i], polygon, tolerance, true);\n geometry.push(polygon);\n }\n } else if (type === 'GeometryCollection') {\n for (i = 0; i < geojson.geometry.geometries.length; i++) {\n convertFeature(features, {\n id: id,\n geometry: geojson.geometry.geometries[i],\n properties: geojson.properties\n }, options, index);\n }\n return;\n } else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\n\nfunction convertPoint(coords, out) {\n out.push(projectX(coords[0]));\n out.push(projectY(coords[1]));\n out.push(0);\n}\n\nfunction convertLine(ring, out, tolerance, isPolygon) {\n var x0, y0;\n var size = 0;\n\n for (var j = 0; j < ring.length; j++) {\n var x = projectX(ring[j][0]);\n var y = projectY(ring[j][1]);\n\n out.push(x);\n out.push(y);\n out.push(0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n var last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings, out, tolerance, isPolygon) {\n for (var i = 0; i < rings.length; i++) {\n var geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\nfunction projectX(x) {\n return x / 360 + 0.5;\n}\n\nfunction projectY(y) {\n var sin = Math.sin(y * Math.PI / 180);\n var y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n","\nimport createFeature from './feature';\n\n/* clip features between two axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n */\n\nexport default function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {\n\n k1 /= scale;\n k2 /= scale;\n\n if (minAll >= k1 && maxAll < k2) return features; // trivial accept\n else if (maxAll < k1 || minAll >= k2) return null; // trivial reject\n\n var clipped = [];\n\n for (var i = 0; i < features.length; i++) {\n\n var feature = features[i];\n var geometry = feature.geometry;\n var type = feature.type;\n\n var min = axis === 0 ? feature.minX : feature.minY;\n var max = axis === 0 ? feature.maxX : feature.maxY;\n\n if (min >= k1 && max < k2) { // trivial accept\n clipped.push(feature);\n continue;\n } else if (max < k1 || min >= k2) { // trivial reject\n continue;\n }\n\n var newGeometry = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n clipPoints(geometry, newGeometry, k1, k2, axis);\n\n } else if (type === 'LineString') {\n clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);\n\n } else if (type === 'MultiLineString') {\n clipLines(geometry, newGeometry, k1, k2, axis, false);\n\n } else if (type === 'Polygon') {\n clipLines(geometry, newGeometry, k1, k2, axis, true);\n\n } else if (type === 'MultiPolygon') {\n for (var j = 0; j < geometry.length; j++) {\n var polygon = [];\n clipLines(geometry[j], polygon, k1, k2, axis, true);\n if (polygon.length) {\n newGeometry.push(polygon);\n }\n }\n }\n\n if (newGeometry.length) {\n if (options.lineMetrics && type === 'LineString') {\n for (j = 0; j < newGeometry.length; j++) {\n clipped.push(createFeature(feature.id, type, newGeometry[j], feature.tags));\n }\n continue;\n }\n\n if (type === 'LineString' || type === 'MultiLineString') {\n if (newGeometry.length === 1) {\n type = 'LineString';\n newGeometry = newGeometry[0];\n } else {\n type = 'MultiLineString';\n }\n }\n if (type === 'Point' || type === 'MultiPoint') {\n type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';\n }\n\n clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n }\n\n return clipped.length ? clipped : null;\n}\n\nfunction clipPoints(geom, newGeom, k1, k2, axis) {\n for (var i = 0; i < geom.length; i += 3) {\n var a = geom[i + axis];\n\n if (a >= k1 && a <= k2) {\n newGeom.push(geom[i]);\n newGeom.push(geom[i + 1]);\n newGeom.push(geom[i + 2]);\n }\n }\n}\n\nfunction clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {\n\n var slice = newSlice(geom);\n var intersect = axis === 0 ? intersectX : intersectY;\n var len = geom.start;\n var segLen, t;\n\n for (var i = 0; i < geom.length - 3; i += 3) {\n var ax = geom[i];\n var ay = geom[i + 1];\n var az = geom[i + 2];\n var bx = geom[i + 3];\n var by = geom[i + 4];\n var a = axis === 0 ? ax : ay;\n var b = axis === 0 ? bx : by;\n var exited = false;\n\n if (trackMetrics) segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n\n if (a < k1) {\n // ---|--> | (line enters the clip region from the left)\n if (b > k1) {\n t = intersect(slice, ax, ay, bx, by, k1);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else if (a > k2) {\n // | <--|--- (line enters the clip region from the right)\n if (b < k2) {\n t = intersect(slice, ax, ay, bx, by, k2);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else {\n addPoint(slice, ax, ay, az);\n }\n if (b < k1 && a >= k1) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, k1);\n exited = true;\n }\n if (b > k2 && a <= k2) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, k2);\n exited = true;\n }\n\n if (!isPolygon && exited) {\n if (trackMetrics) slice.end = len + segLen * t;\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n\n if (trackMetrics) len += segLen;\n }\n\n // add the last point\n var last = geom.length - 3;\n ax = geom[last];\n ay = geom[last + 1];\n az = geom[last + 2];\n a = axis === 0 ? ax : ay;\n if (a >= k1 && a <= k2) addPoint(slice, ax, ay, az);\n\n // close the polygon if its endpoints are not the same after clipping\n last = slice.length - 3;\n if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {\n addPoint(slice, slice[0], slice[1], slice[2]);\n }\n\n // add the final slice\n if (slice.length) {\n newGeom.push(slice);\n }\n}\n\nfunction newSlice(line) {\n var slice = [];\n slice.size = line.size;\n slice.start = line.start;\n slice.end = line.end;\n return slice;\n}\n\nfunction clipLines(geom, newGeom, k1, k2, axis, isPolygon) {\n for (var i = 0; i < geom.length; i++) {\n clipLine(geom[i], newGeom, k1, k2, axis, isPolygon, false);\n }\n}\n\nfunction addPoint(out, x, y, z) {\n out.push(x);\n out.push(y);\n out.push(z);\n}\n\nfunction intersectX(out, ax, ay, bx, by, x) {\n var t = (x - ax) / (bx - ax);\n out.push(x);\n out.push(ay + (by - ay) * t);\n out.push(1);\n return t;\n}\n\nfunction intersectY(out, ax, ay, bx, by, y) {\n var t = (y - ay) / (by - ay);\n out.push(ax + (bx - ax) * t);\n out.push(y);\n out.push(1);\n return t;\n}\n","\nimport clip from './clip';\nimport createFeature from './feature';\n\nexport default function wrap(features, options) {\n var buffer = options.buffer / options.extent;\n var merged = features;\n var left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy\n var right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy\n\n if (left || right) {\n merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy\n\n if (left) merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n if (right) merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n }\n\n return merged;\n}\n\nfunction shiftFeatureCoords(features, offset) {\n var newFeatures = [];\n\n for (var i = 0; i < features.length; i++) {\n var feature = features[i],\n type = feature.type;\n\n var newGeometry;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n newGeometry = shiftCoords(feature.geometry, offset);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n newGeometry = [];\n for (var j = 0; j < feature.geometry.length; j++) {\n newGeometry.push(shiftCoords(feature.geometry[j], offset));\n }\n } else if (type === 'MultiPolygon') {\n newGeometry = [];\n for (j = 0; j < feature.geometry.length; j++) {\n var newPolygon = [];\n for (var k = 0; k < feature.geometry[j].length; k++) {\n newPolygon.push(shiftCoords(feature.geometry[j][k], offset));\n }\n newGeometry.push(newPolygon);\n }\n }\n\n newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n\n return newFeatures;\n}\n\nfunction shiftCoords(points, offset) {\n var newPoints = [];\n newPoints.size = points.size;\n\n if (points.start !== undefined) {\n newPoints.start = points.start;\n newPoints.end = points.end;\n }\n\n for (var i = 0; i < points.length; i += 3) {\n newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);\n }\n return newPoints;\n}\n","\n// Transforms the coordinates of each feature in the given tile from\n// mercator-projected space into (extent x extent) tile space.\nexport default function transformTile(tile, extent) {\n if (tile.transformed) return tile;\n\n var z2 = 1 << tile.z,\n tx = tile.x,\n ty = tile.y,\n i, j, k;\n\n for (i = 0; i < tile.features.length; i++) {\n var feature = tile.features[i],\n geom = feature.geometry,\n type = feature.type;\n\n feature.geometry = [];\n\n if (type === 1) {\n for (j = 0; j < geom.length; j += 2) {\n feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));\n }\n } else {\n for (j = 0; j < geom.length; j++) {\n var ring = [];\n for (k = 0; k < geom[j].length; k += 2) {\n ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));\n }\n feature.geometry.push(ring);\n }\n }\n }\n\n tile.transformed = true;\n\n return tile;\n}\n\nfunction transformPoint(x, y, extent, z2, tx, ty) {\n return [\n Math.round(extent * (x * z2 - tx)),\n Math.round(extent * (y * z2 - ty))];\n}\n","\nexport default function createTile(features, z, tx, ty, options) {\n var tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n var tile = {\n features: [],\n numPoints: 0,\n numSimplified: 0,\n numFeatures: 0,\n source: null,\n x: tx,\n y: ty,\n z: z,\n transformed: false,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0\n };\n for (var i = 0; i < features.length; i++) {\n tile.numFeatures++;\n addFeature(tile, features[i], tolerance, options);\n\n var minX = features[i].minX;\n var minY = features[i].minY;\n var maxX = features[i].maxX;\n var maxY = features[i].maxY;\n\n if (minX < tile.minX) tile.minX = minX;\n if (minY < tile.minY) tile.minY = minY;\n if (maxX > tile.maxX) tile.maxX = maxX;\n if (maxY > tile.maxY) tile.maxY = maxY;\n }\n return tile;\n}\n\nfunction addFeature(tile, feature, tolerance, options) {\n\n var geom = feature.geometry,\n type = feature.type,\n simplified = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n for (var i = 0; i < geom.length; i += 3) {\n simplified.push(geom[i]);\n simplified.push(geom[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n\n } else if (type === 'LineString') {\n addLine(simplified, geom, tile, tolerance, false, false);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n for (i = 0; i < geom.length; i++) {\n addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);\n }\n\n } else if (type === 'MultiPolygon') {\n\n for (var k = 0; k < geom.length; k++) {\n var polygon = geom[k];\n for (i = 0; i < polygon.length; i++) {\n addLine(simplified, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n }\n\n if (simplified.length) {\n var tags = feature.tags || null;\n if (type === 'LineString' && options.lineMetrics) {\n tags = {};\n for (var key in feature.tags) tags[key] = feature.tags[key];\n tags['mapbox_clip_start'] = geom.start / geom.size;\n tags['mapbox_clip_end'] = geom.end / geom.size;\n }\n var tileFeature = {\n geometry: simplified,\n type: type === 'Polygon' || type === 'MultiPolygon' ? 3 :\n type === 'LineString' || type === 'MultiLineString' ? 2 : 1,\n tags: tags\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n }\n}\n\nfunction addLine(result, geom, tile, tolerance, isPolygon, isOuter) {\n var sqTolerance = tolerance * tolerance;\n\n if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) {\n tile.numPoints += geom.length / 3;\n return;\n }\n\n var ring = [];\n\n for (var i = 0; i < geom.length; i += 3) {\n if (tolerance === 0 || geom[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom[i]);\n ring.push(geom[i + 1]);\n }\n tile.numPoints++;\n }\n\n if (isPolygon) rewind(ring, isOuter);\n\n result.push(ring);\n}\n\nfunction rewind(ring, clockwise) {\n var area = 0;\n for (var i = 0, len = ring.length, j = len - 2; i < len; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n if (area > 0 === clockwise) {\n for (i = 0, len = ring.length; i < len / 2; i += 2) {\n var x = ring[i];\n var y = ring[i + 1];\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n }\n}\n","\nimport convert from './convert'; // GeoJSON conversion and preprocessing\nimport clip from './clip'; // stripe clipping algorithm\nimport wrap from './wrap'; // date line processing\nimport transform from './transform'; // coordinate transformation\nimport createTile from './tile'; // final simplified tile generation\n\nexport default function geojsonvt(data, options) {\n return new GeoJSONVT(data, options);\n}\n\nfunction GeoJSONVT(data, options) {\n options = this.options = extend(Object.create(this.options), options);\n\n var debug = options.debug;\n\n if (debug) console.time('preprocess data');\n\n if (options.maxZoom < 0 || options.maxZoom > 24) throw new Error('maxZoom should be in the 0-24 range');\n if (options.promoteId && options.generateId) throw new Error('promoteId and generateId cannot be used together.');\n\n var features = convert(data, options);\n\n this.tiles = {};\n this.tileCoords = [];\n\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n this.stats = {};\n this.total = 0;\n }\n\n features = wrap(features, options);\n\n // start slicing from the top tile down\n if (features.length) this.splitTile(features, 0, 0, 0);\n\n if (debug) {\n if (features.length) console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n}\n\nGeoJSONVT.prototype.options = {\n maxZoom: 14, // max zoom to preserve detail on\n indexMaxZoom: 5, // max zoom in the tile index\n indexMaxPoints: 100000, // max number of points per tile in the tile index\n tolerance: 3, // simplification tolerance (higher means simpler)\n extent: 4096, // tile extent\n buffer: 64, // tile buffer on each side\n lineMetrics: false, // whether to calculate line metrics\n promoteId: null, // name of a feature property to be promoted to feature.id\n generateId: false, // whether to generate feature ids. Cannot be used with promoteId\n debug: 0 // logging level (0, 1 or 2)\n};\n\nGeoJSONVT.prototype.splitTile = function (features, z, x, y, cz, cx, cy) {\n\n var stack = [features, z, x, y],\n options = this.options,\n debug = options.debug;\n\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop();\n x = stack.pop();\n z = stack.pop();\n features = stack.pop();\n\n var z2 = 1 << z,\n id = toID(z, x, y),\n tile = this.tiles[id];\n\n if (!tile) {\n if (debug > 1) console.time('creation');\n\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({z: z, x: x, y: y});\n\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)',\n z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n var key = 'z' + z;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n\n // if it's the first-pass tiling\n if (!cz) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;\n\n // if a drilldown to a specific tile\n } else {\n // stop tiling if we reached base zoom or our target tile zoom\n if (z === options.maxZoom || z === cz) continue;\n\n // stop tiling if it's not an ancestor of the target tile\n var m = 1 << (cz - z);\n if (x !== Math.floor(cx / m) || y !== Math.floor(cy / m)) continue;\n }\n\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n\n if (features.length === 0) continue;\n\n if (debug > 1) console.time('clipping');\n\n // values we'll use for clipping\n var k1 = 0.5 * options.buffer / options.extent,\n k2 = 0.5 - k1,\n k3 = 0.5 + k1,\n k4 = 1 + k1,\n tl, bl, tr, br, left, right;\n\n tl = bl = tr = br = null;\n\n left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);\n right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);\n features = null;\n\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n left = null;\n }\n\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n right = null;\n }\n\n if (debug > 1) console.timeEnd('clipping');\n\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n};\n\nGeoJSONVT.prototype.getTile = function (z, x, y) {\n var options = this.options,\n extent = options.extent,\n debug = options.debug;\n\n if (z < 0 || z > 24) return null;\n\n var z2 = 1 << z;\n x = ((x % z2) + z2) % z2; // wrap tile x coordinate\n\n var id = toID(z, x, y);\n if (this.tiles[id]) return transform(this.tiles[id], extent);\n\n if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y);\n\n var z0 = z,\n x0 = x,\n y0 = y,\n parent;\n\n while (!parent && z0 > 0) {\n z0--;\n x0 = Math.floor(x0 / 2);\n y0 = Math.floor(y0 / 2);\n parent = this.tiles[toID(z0, x0, y0)];\n }\n\n if (!parent || !parent.source) return null;\n\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n\n if (debug > 1) console.time('drilling down');\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) console.timeEnd('drilling down');\n\n return this.tiles[id] ? transform(this.tiles[id], extent) : null;\n};\n\nfunction toID(z, x, y) {\n return (((1 << z) * y + x) * 32) + z;\n}\n\nfunction extend(dest, src) {\n for (var i in src) dest[i] = src[i];\n return dest;\n}\n","/**\n * A way to indentify a feature, either by string or by number\n */\nexport type GeoJSONFeatureId = number | string;\n\n/**\n * The geojson source diff object\n */\nexport type GeoJSONSourceDiff = {\n /**\n * When set to `true` it will remove all features\n */\n removeAll?: boolean;\n /**\n * An array of features IDs to remove\n */\n remove?: Array;\n /**\n * An array of features to add\n */\n add?: Array;\n /**\n * An array of update objects\n */\n update?: Array;\n}\n\n/**\n * A geojson feature diff object\n */\nexport type GeoJSONFeatureDiff = {\n /**\n * The feature ID\n */\n id: GeoJSONFeatureId;\n /**\n * If it's a new geometry, place it here\n */\n newGeometry?: GeoJSON.Geometry;\n /**\n * Setting to `true` will remove all preperties\n */\n removeAllProperties?: boolean;\n /**\n * The properties keys to remove\n */\n removeProperties?: Array;\n /**\n * The properties to add or update along side their values\n */\n addOrUpdateProperties?: Array<{key: string; value: any}>;\n}\n\nexport type UpdateableGeoJSON = GeoJSON.Feature | GeoJSON.FeatureCollection | undefined;\n\nfunction getFeatureId(feature: GeoJSON.Feature, promoteId?: string): GeoJSONFeatureId | undefined {\n return promoteId ? feature.properties[promoteId] : feature.id;\n}\n\nexport function isUpdateableGeoJSON(data: GeoJSON.GeoJSON | undefined, promoteId?: string): data is UpdateableGeoJSON {\n // null can be updated\n if (data == null) {\n return true;\n }\n\n // a single feature with an id can be updated, need to explicitly check against null because 0 is a valid feature id that is falsy\n if (data.type === 'Feature') {\n return getFeatureId(data, promoteId) != null;\n }\n\n // a feature collection can be updated if every feature has an id, and the ids are all unique\n // this prevents us from silently dropping features if ids get reused\n if (data.type === 'FeatureCollection') {\n const seenIds = new Set();\n for (const feature of data.features) {\n const id = getFeatureId(feature, promoteId);\n if (id == null) {\n return false;\n }\n\n if (seenIds.has(id)) {\n return false;\n }\n\n seenIds.add(id);\n }\n\n return true;\n }\n\n return false;\n}\n\nexport function toUpdateable(data: UpdateableGeoJSON, promoteId?: string) {\n const result = new Map();\n if (data == null) {\n // empty result\n } else if (data.type === 'Feature') {\n result.set(getFeatureId(data, promoteId)!, data);\n } else {\n for (const feature of data.features) {\n result.set(getFeatureId(feature, promoteId)!, feature);\n }\n }\n\n return result;\n}\n\n// mutates updateable\nexport function applySourceDiff(updateable: Map, diff: GeoJSONSourceDiff, promoteId?: string): void {\n if (diff.removeAll) {\n updateable.clear();\n }\n\n if (diff.remove) {\n for (const id of diff.remove) {\n updateable.delete(id);\n }\n }\n\n if (diff.add) {\n for (const feature of diff.add) {\n const id = getFeatureId(feature, promoteId);\n\n if (id != null) {\n updateable.set(id, feature);\n }\n }\n }\n\n if (diff.update) {\n for (const update of diff.update) {\n let feature = updateable.get(update.id);\n\n if (feature == null) {\n continue;\n }\n\n // be careful to clone the feature and/or properties objects to avoid mutating our input\n const cloneFeature = update.newGeometry || update.removeAllProperties;\n // note: removeAllProperties gives us a new properties object, so we can skip the clone step\n const cloneProperties = !update.removeAllProperties && (update.removeProperties?.length > 0 || update.addOrUpdateProperties?.length > 0);\n if (cloneFeature || cloneProperties) {\n feature = {...feature};\n updateable.set(update.id, feature);\n if (cloneProperties) {\n feature.properties = {...feature.properties};\n }\n }\n\n if (update.newGeometry) {\n feature.geometry = update.newGeometry;\n }\n\n if (update.removeAllProperties) {\n feature.properties = {};\n } else if (update.removeProperties?.length > 0) {\n for (const prop of update.removeProperties) {\n if (Object.prototype.hasOwnProperty.call(feature.properties, prop)) {\n delete feature.properties[prop];\n }\n }\n }\n\n if (update.addOrUpdateProperties?.length > 0) {\n for (const {key, value} of update.addOrUpdateProperties) {\n feature.properties[key] = value;\n }\n }\n }\n }\n}\n","import {getJSON} from '../util/ajax';\n\nimport {RequestPerformance} from '../util/performance';\nimport rewind from '@mapbox/geojson-rewind';\nimport {GeoJSONWrapper} from './geojson_wrapper';\nimport vtpbf from 'vt-pbf';\nimport Supercluster, {type Options as SuperclusterOptions, type ClusterProperties} from 'supercluster';\nimport geojsonvt, {type Options as GeoJSONVTOptions} from 'geojson-vt';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source';\nimport {createExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {\n WorkerTileParameters,\n WorkerTileCallback,\n} from '../source/worker_source';\n\nimport type {Actor} from '../util/actor';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\n\nimport type {LoadVectorDataCallback} from './vector_tile_worker_source';\nimport type {RequestParameters, ResponseCallback} from '../util/ajax';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport {isUpdateableGeoJSON, type GeoJSONSourceDiff, applySourceDiff, toUpdateable, GeoJSONFeatureId} from './geojson_source_diff';\n\nexport type LoadGeoJSONParameters = {\n request?: RequestParameters;\n /**\n * Literal GeoJSON data. Must be provided if `request.url` is not.\n */\n data?: string;\n dataDiff?: GeoJSONSourceDiff;\n source: string;\n cluster: boolean;\n superclusterOptions?: SuperclusterOptions;\n geojsonVtOptions?: GeoJSONVTOptions;\n clusterProperties?: ClusterProperties;\n filter?: Array;\n promoteId?: string;\n};\n\nexport type LoadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback) => Cancelable;\n\ntype GeoJSONIndex = ReturnType | Supercluster;\n\n/**\n * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory GeoJSON\n * representation. To do so, create it with\n * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.\n * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).\n */\nexport class GeoJSONWorkerSource extends VectorTileWorkerSource {\n _pendingCallback: Callback<{\n resourceTiming?: {[_: string]: Array};\n abandoned?: boolean;\n }>;\n _pendingRequest: Cancelable;\n _geoJSONIndex: GeoJSONIndex;\n _dataUpdateable = new Map();\n\n /**\n * @param loadGeoJSON - Optional method for custom loading/parsing of\n * GeoJSON based on parameters passed from the main-thread Source.\n * See {@link GeoJSONWorkerSource#loadGeoJSON}.\n */\n constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadGeoJSON?: LoadGeoJSON | null) {\n super(actor, layerIndex, availableImages);\n this.loadVectorData = this.loadGeoJSONTile;\n if (loadGeoJSON) {\n this.loadGeoJSON = loadGeoJSON;\n }\n }\n\n loadGeoJSONTile(params: WorkerTileParameters, callback: LoadVectorDataCallback): (() => void) | void {\n const canonical = params.tileID.canonical;\n\n if (!this._geoJSONIndex) {\n return callback(null, null); // we couldn't load the file\n }\n\n const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);\n if (!geoJSONTile) {\n return callback(null, null); // nothing in the given tile\n }\n\n const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features);\n // Encode the geojson-vt tile into binary vector tile form. This\n // is a convenience that allows `FeatureIndex` to operate the same way\n // across `VectorTileSource` and `GeoJSONSource` data.\n let pbf = vtpbf(geojsonWrapper);\n if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {\n // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)\n pbf = new Uint8Array(pbf);\n }\n\n callback(null, {\n vectorTile: geojsonWrapper,\n rawData: pbf.buffer\n });\n }\n\n /**\n * Fetches (if appropriate), parses, and index geojson data into tiles. This\n * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}\n * can correctly serve up tiles.\n *\n * Defers to {@link GeoJSONWorkerSource#loadGeoJSON} for the fetching/parsing,\n * expecting `callback(error, data)` to be called with either an error or a\n * parsed GeoJSON object.\n *\n * When a `loadData` request comes in while a previous one is being processed,\n * the previous one is aborted.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n */\n loadData(params: LoadGeoJSONParameters, callback: Callback<{\n resourceTiming?: {[_: string]: Array};\n abandoned?: boolean;\n }>) {\n this._pendingRequest?.cancel();\n if (this._pendingCallback) {\n // Tell the foreground the previous call has been abandoned\n this._pendingCallback(null, {abandoned: true});\n }\n\n const perf = (params && params.request && params.request.collectResourceTiming) ?\n new RequestPerformance(params.request) : false;\n\n this._pendingCallback = callback;\n this._pendingRequest = this.loadGeoJSON(params, (err?: Error | null, data?: any | null) => {\n delete this._pendingCallback;\n delete this._pendingRequest;\n\n if (err || !data) {\n return callback(err);\n } else if (typeof data !== 'object') {\n return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n } else {\n rewind(data, true);\n\n try {\n if (params.filter) {\n const compiled = createExpression(params.filter, {type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false} as any);\n if (compiled.result === 'error')\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n\n const features = data.features.filter(feature => compiled.value.evaluate({zoom: 0}, feature));\n data = {type: 'FeatureCollection', features};\n }\n\n this._geoJSONIndex = params.cluster ?\n new Supercluster(getSuperclusterOptions(params)).load(data.features) :\n geojsonvt(data, params.geojsonVtOptions);\n } catch (err) {\n return callback(err);\n }\n\n this.loaded = {};\n\n const result = {} as { resourceTiming: any };\n if (perf) {\n const resourceTimingData = perf.finish();\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n if (resourceTimingData) {\n result.resourceTiming = {};\n result.resourceTiming[params.source] = JSON.parse(JSON.stringify(resourceTimingData));\n }\n }\n callback(null, result);\n }\n });\n }\n\n /**\n * Implements {@link WorkerSource#reloadTile}.\n *\n * If the tile is loaded, uses the implementation in VectorTileWorkerSource.\n * Otherwise, such as after a setData() call, we load the tile fresh.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n */\n reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded,\n uid = params.uid;\n\n if (loaded && loaded[uid]) {\n return super.reloadTile(params, callback);\n } else {\n return this.loadTile(params, callback);\n }\n }\n\n /**\n * Fetch and parse GeoJSON according to the given params. Calls `callback`\n * with `(err, data)`, where `data` is a parsed GeoJSON object.\n *\n * GeoJSON is loaded and parsed from `params.url` if it exists, or else\n * expected as a literal (string or object) `params.data`.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n * @returns A Cancelable object.\n */\n loadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback): Cancelable => {\n const {promoteId} = params;\n // Because of same origin issues, urls must either include an explicit\n // origin or absolute path.\n // ie: /foo/bar.json or http://example.com/bar.json\n // but not ../foo/bar.json\n if (params.request) {\n return getJSON(params.request, (\n error?: Error,\n data?: any,\n cacheControl?: string,\n expires?: string\n ) => {\n this._dataUpdateable = isUpdateableGeoJSON(data, promoteId) ? toUpdateable(data, promoteId) : undefined;\n callback(error, data, cacheControl, expires);\n });\n } else if (typeof params.data === 'string') {\n try {\n const parsed = JSON.parse(params.data);\n this._dataUpdateable = isUpdateableGeoJSON(parsed, promoteId) ? toUpdateable(parsed, promoteId) : undefined;\n callback(null, parsed);\n } catch (e) {\n callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n }\n } else if (params.dataDiff) {\n if (this._dataUpdateable) {\n applySourceDiff(this._dataUpdateable, params.dataDiff, promoteId);\n callback(null, {type: 'FeatureCollection', features: Array.from(this._dataUpdateable.values())});\n } else {\n callback(new Error(`Cannot update existing geojson data in ${params.source}`));\n }\n } else {\n callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n }\n\n return {cancel: () => {}};\n };\n\n removeSource(params: {\n source: string;\n }, callback: WorkerTileCallback) {\n if (this._pendingCallback) {\n // Don't leak callbacks\n this._pendingCallback(null, {abandoned: true});\n }\n callback();\n }\n\n getClusterExpansionZoom(params: {\n clusterId: number;\n }, callback: Callback) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getClusterExpansionZoom(params.clusterId));\n } catch (e) {\n callback(e);\n }\n }\n\n getClusterChildren(params: {\n clusterId: number;\n }, callback: Callback>) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getChildren(params.clusterId));\n } catch (e) {\n callback(e);\n }\n }\n\n getClusterLeaves(params: {\n clusterId: number;\n limit: number;\n offset: number;\n }, callback: Callback>) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getLeaves(params.clusterId, params.limit, params.offset));\n } catch (e) {\n callback(e);\n }\n }\n}\n\nfunction getSuperclusterOptions({superclusterOptions, clusterProperties}: LoadGeoJSONParameters) {\n if (!clusterProperties || !superclusterOptions) return superclusterOptions;\n\n const mapExpressions = {};\n const reduceExpressions = {};\n const globals = {accumulated: null, zoom: 0};\n const feature = {properties: null};\n const propertyNames = Object.keys(clusterProperties);\n\n for (const key of propertyNames) {\n const [operator, mapExpression] = clusterProperties[key];\n\n const mapExpressionParsed = createExpression(mapExpression);\n const reduceExpressionParsed = createExpression(\n typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator);\n\n mapExpressions[key] = mapExpressionParsed.value;\n reduceExpressions[key] = reduceExpressionParsed.value;\n }\n\n superclusterOptions.map = (pointProperties) => {\n feature.properties = pointProperties;\n const properties = {};\n for (const key of propertyNames) {\n properties[key] = mapExpressions[key].evaluate(globals, feature);\n }\n return properties;\n };\n superclusterOptions.reduce = (accumulated, clusterProperties) => {\n feature.properties = clusterProperties;\n for (const key of propertyNames) {\n globals.accumulated = accumulated[key];\n accumulated[key] = reduceExpressions[key].evaluate(globals, feature);\n }\n };\n\n return superclusterOptions;\n}\n","import {Actor, ActorTarget} from '../util/actor';\nimport {StyleLayerIndex} from '../style/style_layer_index';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source';\nimport {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source';\nimport {GeoJSONWorkerSource} from './geojson_worker_source';\nimport {plugin as globalRTLTextPlugin} from './rtl_text_plugin';\nimport {isWorker} from '../util/util';\n\nimport type {\n WorkerSource,\n WorkerTileParameters,\n WorkerDEMTileParameters,\n WorkerTileCallback,\n WorkerDEMTileCallback,\n TileParameters\n} from '../source/worker_source';\n\nimport type {WorkerGlobalScopeInterface} from '../util/web_worker';\nimport type {Callback} from '../types/callback';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {PluginState} from './rtl_text_plugin';\n\n/**\n * The Worker class responsidble for background thread related execution\n */\nexport default class Worker {\n self: WorkerGlobalScopeInterface & ActorTarget;\n actor: Actor;\n layerIndexes: {[_: string]: StyleLayerIndex};\n availableImages: {[_: string]: Array};\n workerSourceTypes: {\n [_: string]: {\n new (...args: any): WorkerSource;\n };\n };\n workerSources: {\n [_: string]: {\n [_: string]: {\n [_: string]: WorkerSource;\n };\n };\n };\n demWorkerSources: {\n [_: string]: {\n [_: string]: RasterDEMTileWorkerSource;\n };\n };\n referrer: string;\n\n constructor(self: WorkerGlobalScopeInterface & ActorTarget) {\n this.self = self;\n this.actor = new Actor(self, this);\n\n this.layerIndexes = {};\n this.availableImages = {};\n\n this.workerSourceTypes = {\n vector: VectorTileWorkerSource,\n geojson: GeoJSONWorkerSource\n };\n\n // [mapId][sourceType][sourceName] => worker source instance\n this.workerSources = {};\n this.demWorkerSources = {};\n\n this.self.registerWorkerSource = (name: string, WorkerSource: {\n new (...args: any): WorkerSource;\n }) => {\n if (this.workerSourceTypes[name]) {\n throw new Error(`Worker source with name \"${name}\" already registered.`);\n }\n this.workerSourceTypes[name] = WorkerSource;\n };\n\n // This is invoked by the RTL text plugin when the download via the `importScripts` call has finished, and the code has been parsed.\n this.self.registerRTLTextPlugin = (rtlTextPlugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText?: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n }) => {\n if (globalRTLTextPlugin.isParsed()) {\n throw new Error('RTL text plugin already registered.');\n }\n globalRTLTextPlugin['applyArabicShaping'] = rtlTextPlugin.applyArabicShaping;\n globalRTLTextPlugin['processBidirectionalText'] = rtlTextPlugin.processBidirectionalText;\n globalRTLTextPlugin['processStyledBidirectionalText'] = rtlTextPlugin.processStyledBidirectionalText;\n };\n }\n\n setReferrer(mapID: string, referrer: string) {\n this.referrer = referrer;\n }\n\n setImages(mapId: string, images: Array, callback: WorkerTileCallback) {\n this.availableImages[mapId] = images;\n for (const workerSource in this.workerSources[mapId]) {\n const ws = this.workerSources[mapId][workerSource];\n for (const source in ws) {\n ws[source].availableImages = images;\n }\n }\n callback();\n }\n\n setLayers(mapId: string, layers: Array, callback: WorkerTileCallback) {\n this.getLayerIndex(mapId).replace(layers);\n callback();\n }\n\n updateLayers(mapId: string, params: {\n layers: Array;\n removedIds: Array;\n }, callback: WorkerTileCallback) {\n this.getLayerIndex(mapId).update(params.layers, params.removedIds);\n callback();\n }\n\n loadTile(mapId: string, params: WorkerTileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).loadTile(params, callback);\n }\n\n loadDEMTile(mapId: string, params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) {\n this.getDEMWorkerSource(mapId, params.source).loadTile(params, callback);\n }\n\n reloadTile(mapId: string, params: WorkerTileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).reloadTile(params, callback);\n }\n\n abortTile(mapId: string, params: TileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).abortTile(params, callback);\n }\n\n removeTile(mapId: string, params: TileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).removeTile(params, callback);\n }\n\n removeDEMTile(mapId: string, params: TileParameters) {\n this.getDEMWorkerSource(mapId, params.source).removeTile(params);\n }\n\n removeSource(mapId: string, params: {\n source: string;\n } & {\n type: string;\n }, callback: WorkerTileCallback) {\n\n if (!this.workerSources[mapId] ||\n !this.workerSources[mapId][params.type] ||\n !this.workerSources[mapId][params.type][params.source]) {\n return;\n }\n\n const worker = this.workerSources[mapId][params.type][params.source];\n delete this.workerSources[mapId][params.type][params.source];\n\n if (worker.removeSource !== undefined) {\n worker.removeSource(params, callback);\n } else {\n callback();\n }\n }\n\n /**\n * Load a {@link WorkerSource} script at params.url. The script is run\n * (using importScripts) with `registerWorkerSource` in scope, which is a\n * function taking `(name, workerSourceObject)`.\n */\n loadWorkerSource(map: string, params: {\n url: string;\n }, callback: Callback) {\n try {\n this.self.importScripts(params.url);\n callback();\n } catch (e) {\n callback(e.toString());\n }\n }\n\n syncRTLPluginState(map: string, state: PluginState, callback: Callback) {\n try {\n globalRTLTextPlugin.setState(state);\n const pluginURL = globalRTLTextPlugin.getPluginURL();\n if (\n globalRTLTextPlugin.isLoaded() &&\n !globalRTLTextPlugin.isParsed() &&\n pluginURL != null // Not possible when `isLoaded` is true, but keeps flow happy\n ) {\n this.self.importScripts(pluginURL);\n const complete = globalRTLTextPlugin.isParsed();\n const error = complete ? undefined : new Error(`RTL Text Plugin failed to import scripts from ${pluginURL}`);\n callback(error, complete);\n }\n } catch (e) {\n callback(e.toString());\n }\n }\n\n getAvailableImages(mapId: string) {\n let availableImages = this.availableImages[mapId];\n\n if (!availableImages) {\n availableImages = [];\n }\n\n return availableImages;\n }\n\n getLayerIndex(mapId: string) {\n let layerIndexes = this.layerIndexes[mapId];\n if (!layerIndexes) {\n layerIndexes = this.layerIndexes[mapId] = new StyleLayerIndex();\n }\n return layerIndexes;\n }\n\n getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource {\n if (!this.workerSources[mapId])\n this.workerSources[mapId] = {};\n if (!this.workerSources[mapId][sourceType])\n this.workerSources[mapId][sourceType] = {};\n\n if (!this.workerSources[mapId][sourceType][sourceName]) {\n // use a wrapped actor so that we can attach a target mapId param\n // to any messages invoked by the WorkerSource\n const actor = {\n send: (type, data, callback) => {\n this.actor.send(type, data, callback, mapId);\n }\n };\n this.workerSources[mapId][sourceType][sourceName] = new (this.workerSourceTypes[sourceType] as any)((actor as any), this.getLayerIndex(mapId), this.getAvailableImages(mapId));\n }\n\n return this.workerSources[mapId][sourceType][sourceName];\n }\n\n getDEMWorkerSource(mapId: string, source: string) {\n if (!this.demWorkerSources[mapId])\n this.demWorkerSources[mapId] = {};\n\n if (!this.demWorkerSources[mapId][source]) {\n this.demWorkerSources[mapId][source] = new RasterDEMTileWorkerSource();\n }\n\n return this.demWorkerSources[mapId][source];\n }\n}\n\nif (isWorker()) {\n (self as any).worker = new Worker(self as any);\n}\n","import Point from '@mapbox/point-geometry';\n\nexport class DOM {\n private static readonly docStyle = typeof window !== 'undefined' && window.document && window.document.documentElement.style;\n\n private static userSelect: string;\n\n private static selectProp = DOM.testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);\n\n private static transformProp = DOM.testProp(['transform', 'WebkitTransform']);\n\n private static testProp(props: string[]): string {\n if (!DOM.docStyle) return props[0];\n for (let i = 0; i < props.length; i++) {\n if (props[i] in DOM.docStyle) {\n return props[i];\n }\n }\n return props[0];\n }\n\n public static create(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K] {\n const el = window.document.createElement(tagName);\n if (className !== undefined) el.className = className;\n if (container) container.appendChild(el);\n return el;\n }\n\n public static createNS(namespaceURI: string, tagName: string) {\n const el = window.document.createElementNS(namespaceURI, tagName);\n return el;\n }\n\n public static disableDrag() {\n if (DOM.docStyle && DOM.selectProp) {\n DOM.userSelect = DOM.docStyle[DOM.selectProp];\n DOM.docStyle[DOM.selectProp] = 'none';\n }\n }\n\n public static enableDrag() {\n if (DOM.docStyle && DOM.selectProp) {\n DOM.docStyle[DOM.selectProp] = DOM.userSelect;\n }\n }\n\n public static setTransform(el: HTMLElement, value: string) {\n el.style[DOM.transformProp] = value;\n }\n\n public static addEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: {\n passive?: boolean;\n capture?: boolean;\n } = {}) {\n if ('passive' in options) {\n target.addEventListener(type, callback, options);\n } else {\n target.addEventListener(type, callback, options.capture);\n }\n }\n\n public static removeEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: {\n passive?: boolean;\n capture?: boolean;\n } = {}) {\n if ('passive' in options) {\n target.removeEventListener(type, callback, options);\n } else {\n target.removeEventListener(type, callback, options.capture);\n }\n }\n\n // Suppress the next click, but only if it's immediate.\n private static suppressClickInternal(e) {\n e.preventDefault();\n e.stopPropagation();\n window.removeEventListener('click', DOM.suppressClickInternal, true);\n }\n\n public static suppressClick() {\n window.addEventListener('click', DOM.suppressClickInternal, true);\n window.setTimeout(() => {\n window.removeEventListener('click', DOM.suppressClickInternal, true);\n }, 0);\n }\n\n public static mousePos(el: HTMLElement, e: MouseEvent | Touch) {\n const rect = el.getBoundingClientRect();\n return new Point(\n e.clientX - rect.left - el.clientLeft,\n e.clientY - rect.top - el.clientTop\n );\n }\n\n public static touchPos(el: HTMLElement, touches: TouchList) {\n const rect = el.getBoundingClientRect();\n const points: Point[] = [];\n for (let i = 0; i < touches.length; i++) {\n points.push(new Point(\n touches[i].clientX - rect.left - el.clientLeft,\n touches[i].clientY - rect.top - el.clientTop\n ));\n }\n return points;\n }\n\n public static mouseButton(e: MouseEvent) {\n return e.button;\n }\n\n public static remove(node: HTMLElement) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n}\n","export const webpSupported = {\n supported: false,\n testSupport\n};\n\nlet glForTesting: WebGLRenderingContext|WebGL2RenderingContext;\nlet webpCheckComplete = false;\nlet webpImgTest;\nlet webpImgTestOnloadComplete = false;\n\nif (typeof document !== 'undefined') {\n webpImgTest = document.createElement('img');\n webpImgTest.onload = function() {\n if (glForTesting) testWebpTextureUpload(glForTesting);\n glForTesting = null;\n webpImgTestOnloadComplete = true;\n };\n webpImgTest.onerror = function() {\n webpCheckComplete = true;\n glForTesting = null;\n };\n webpImgTest.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=';\n}\n\nfunction testSupport(gl: WebGLRenderingContext | WebGL2RenderingContext) {\n if (webpCheckComplete || !webpImgTest) return;\n\n // HTMLImageElement.complete is set when an image is done loading it's source\n // regardless of whether the load was successful or not.\n // It's possible for an error to set HTMLImageElement.complete to true which would trigger\n // testWebpTextureUpload and mistakenly set exported.supported to true in browsers which don't support webp\n // To avoid this, we set a flag in the image's onload handler and only call testWebpTextureUpload\n // after a successful image load event.\n if (webpImgTestOnloadComplete) {\n testWebpTextureUpload(gl);\n } else {\n glForTesting = gl;\n\n }\n}\n\nfunction testWebpTextureUpload(gl: WebGLRenderingContext|WebGL2RenderingContext) {\n // Edge 18 supports WebP but not uploading a WebP image to a gl texture\n // Test support for this before allowing WebP images.\n // https://github.com/mapbox/mapbox-gl-js/issues/7671\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n\n try {\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, webpImgTest);\n\n // The error does not get triggered in Edge if the context is lost\n if (gl.isContextLost()) return;\n\n webpSupported.supported = true;\n } catch (e) {\n // Catch \"Unspecified Error.\" in Edge 18.\n }\n\n gl.deleteTexture(texture);\n\n webpCheckComplete = true;\n}\n","import type {Cancelable} from '../types/cancelable';\nimport {RequestParameters, ExpiryData, makeRequest, sameOrigin, getProtocolAction} from './ajax';\nimport type {Callback} from '../types/callback';\n\nimport {arrayBufferToImageBitmap, arrayBufferToImage, extend, isWorker, isImageBitmap} from './util';\nimport {webpSupported} from './webp_supported';\nimport {config} from './config';\n\n/**\n * The callback that is being called after an image was fetched\n */\nexport type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void;\n\ntype ImageQueueThrottleControlCallback = () => boolean;\n\nexport type ImageRequestQueueItem = Cancelable & {\n requestParameters: RequestParameters;\n supportImageRefresh: boolean;\n callback: GetImageCallback;\n cancelled: boolean;\n completed: boolean;\n innerRequest?: Cancelable;\n}\n\ntype ImageQueueThrottleCallbackDictionary = {\n [Key: number]: ImageQueueThrottleControlCallback;\n}\n\ntype HTMLImageElementWithPriority = HTMLImageElement &\n{\n // fetchPriority is experimental property supported on Chromium browsers from Version 102\n // By default images are downloaded with priority low, whereas fetch request downloads with priority high\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority\n fetchPriority?: 'auto' | 'high' | 'low';\n};\n\n/**\n * By default, the image queue is self driven, meaning as soon as one requested item is processed,\n * it will move on to next one as quickly as it can while limiting\n * the number of concurrent requests to MAX_PARALLEL_IMAGE_REQUESTS. The default behavior\n * ensures that static views of the map can be rendered with minimal delay.\n *\n * However, the default behavior can prevent dynamic views of the map from rendering\n * smoothly in that many requests can finish in one render frame, putting too much pressure on GPU.\n *\n * When the view of the map is moving dynamically, smoother frame rates can be achieved\n * by throttling the number of items processed by the queue per frame. This can be\n * accomplished by using {@link addThrottleControl} to allow the caller to\n * use a lambda function to determine when the queue should be throttled (e.g. when isMoving())\n * and manually calling {@link processQueue} in the render loop.\n */\nexport namespace ImageRequest {\n let imageRequestQueue : ImageRequestQueueItem[];\n let currentParallelImageRequests:number;\n\n let throttleControlCallbackHandleCounter: number;\n let throttleControlCallbacks: ImageQueueThrottleCallbackDictionary;\n\n /**\n * Reset the image request queue, removing all pending requests.\n */\n export const resetRequestQueue = (): void => {\n imageRequestQueue = [];\n currentParallelImageRequests = 0;\n throttleControlCallbackHandleCounter = 0;\n throttleControlCallbacks = {};\n };\n\n /**\n * Install a callback to control when image queue throttling is desired.\n * (e.g. when the map view is moving)\n * @param callback - The callback function to install\n * @returns handle that identifies the installed callback.\n */\n export const addThrottleControl = (callback: ImageQueueThrottleControlCallback): number => {\n const handle = throttleControlCallbackHandleCounter++;\n throttleControlCallbacks[handle] = callback;\n return handle;\n };\n\n /**\n * Remove a previously installed callback by passing in the handle returned\n * by {@link addThrottleControl}.\n * @param callbackHandle - The handle for the callback to remove.\n */\n export const removeThrottleControl = (callbackHandle: number): void => {\n delete throttleControlCallbacks[callbackHandle];\n // Try updating the queue\n processQueue();\n };\n\n /**\n * Check to see if any of the installed callbacks are requesting the queue\n * to be throttled.\n * @returns `true` if any callback is causing the queue to be throttled.\n */\n const isThrottled = (): boolean => {\n const allControlKeys = Object.keys(throttleControlCallbacks);\n let throttleingRequested = false;\n if (allControlKeys.length > 0) {\n for (const key of allControlKeys) {\n throttleingRequested = throttleControlCallbacks[key]();\n if (throttleingRequested) {\n break;\n }\n }\n }\n return throttleingRequested;\n };\n\n /**\n * Request to load an image.\n * @param requestParameters - Request parameters.\n * @param callback - Callback to issue when the request completes.\n * @param supportImageRefresh - `true`, if the image request need to support refresh based on cache headers.\n * @returns Cancelable request.\n */\n export const getImage = (\n requestParameters: RequestParameters,\n callback: GetImageCallback,\n supportImageRefresh: boolean = true\n ): ImageRequestQueueItem => {\n if (webpSupported.supported) {\n if (!requestParameters.headers) {\n requestParameters.headers = {};\n }\n requestParameters.headers.accept = 'image/webp,*/*';\n }\n\n const request:ImageRequestQueueItem = {\n requestParameters,\n supportImageRefresh,\n callback,\n cancelled: false,\n completed: false,\n cancel: () => {\n if (!request.completed && !request.cancelled) {\n request.cancelled = true;\n\n // Only reduce currentParallelImageRequests, if the image request was issued.\n if (request.innerRequest) {\n request.innerRequest.cancel();\n currentParallelImageRequests--;\n }\n\n // in the case of cancelling, it WILL move on\n processQueue();\n }\n }\n };\n\n imageRequestQueue.push(request);\n processQueue();\n return request;\n };\n\n const arrayBufferToCanvasImageSource = (data: ArrayBuffer, callback: Callback) => {\n const imageBitmapSupported = typeof createImageBitmap === 'function';\n if (imageBitmapSupported) {\n arrayBufferToImageBitmap(data, callback);\n } else {\n arrayBufferToImage(data, callback);\n }\n };\n\n const doImageRequest = (itemInQueue: ImageRequestQueueItem): Cancelable => {\n const {requestParameters, supportImageRefresh, callback} = itemInQueue;\n extend(requestParameters, {type: 'image'});\n\n // - If refreshExpiredTiles is false, then we can use HTMLImageElement to download raster images.\n // - Fetch/XHR (via MakeRequest API) will be used to download images for following scenarios:\n // 1. Style image sprite will had a issue with HTMLImageElement as described\n // here: https://github.com/mapbox/mapbox-gl-js/issues/1470\n // 2. If refreshExpiredTiles is true (default), then in order to read the image cache header,\n // fetch/XHR request will be required\n // - For any special case handling like use of AddProtocol, worker initiated request or additional headers\n // let makeRequest handle it.\n // - HtmlImageElement request automatically adds accept header for all the browser supported images\n const canUseHTMLImageElement = supportImageRefresh === false &&\n !isWorker() &&\n !getProtocolAction(requestParameters.url) &&\n (!requestParameters.headers ||\n Object.keys(requestParameters.headers).reduce((acc, item) => acc && item === 'accept', true));\n\n const action = canUseHTMLImageElement ? getImageUsingHtmlImage : makeRequest;\n return action(\n requestParameters,\n (err?: Error | null,\n data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null,\n cacheControl?: string | null,\n expires?: string | null) => {\n onImageResponse(itemInQueue, callback, err, data, cacheControl, expires);\n });\n };\n\n const onImageResponse = (\n itemInQueue: ImageRequestQueueItem,\n callback:GetImageCallback,\n err?: Error | null,\n data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null,\n cacheControl?: string | null,\n expires?: string | null): void => {\n if (err) {\n callback(err);\n } else if (data instanceof HTMLImageElement || isImageBitmap(data)) {\n // User using addProtocol can directly return HTMLImageElement/ImageBitmap type\n // If HtmlImageElement is used to get image then response type will be HTMLImageElement\n callback(null, data);\n } else if (data) {\n const decoratedCallback = (imgErr?: Error | null, imgResult?: CanvasImageSource | null) => {\n if (imgErr != null) {\n callback(imgErr);\n } else if (imgResult != null) {\n callback(null, imgResult as (HTMLImageElement | ImageBitmap), {cacheControl, expires});\n }\n };\n arrayBufferToCanvasImageSource(data, decoratedCallback);\n }\n if (!itemInQueue.cancelled) {\n itemInQueue.completed = true;\n currentParallelImageRequests--;\n\n processQueue();\n }\n };\n\n /**\n * Process some number of items in the image request queue.\n */\n const processQueue = (): void => {\n\n const maxImageRequests = isThrottled() ?\n config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME :\n config.MAX_PARALLEL_IMAGE_REQUESTS;\n\n // limit concurrent image loads to help with raster sources performance on big screens\n for (let numImageRequests = currentParallelImageRequests;\n numImageRequests < maxImageRequests && imageRequestQueue.length > 0;\n numImageRequests++) {\n\n const topItemInQueue: ImageRequestQueueItem = imageRequestQueue.shift();\n if (topItemInQueue.cancelled) {\n numImageRequests--;\n continue;\n }\n\n const innerRequest = doImageRequest(topItemInQueue);\n\n currentParallelImageRequests++;\n\n topItemInQueue.innerRequest = innerRequest;\n }\n };\n\n const getImageUsingHtmlImage = (requestParameters: RequestParameters, callback: GetImageCallback): Cancelable => {\n const image = new Image() as HTMLImageElementWithPriority;\n const url = requestParameters.url;\n let requestCancelled = false;\n const credentials = requestParameters.credentials;\n if (credentials && credentials === 'include') {\n image.crossOrigin = 'use-credentials';\n } else if ((credentials && credentials === 'same-origin') || !sameOrigin(url)) {\n image.crossOrigin = 'anonymous';\n }\n\n image.fetchPriority = 'high';\n image.onload = () => {\n callback(null, image);\n image.onerror = image.onload = null;\n };\n image.onerror = () => {\n if (!requestCancelled) {\n callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n }\n image.onerror = image.onload = null;\n };\n image.src = url;\n return {\n cancel: () => {\n requestCancelled = true;\n // Set src to '' to actually cancel the request\n image.src = '';\n }\n };\n };\n}\n\nImageRequest.resetRequestQueue();\n","import type {RequestParameters} from './ajax';\n\n/**\n * A type of MapLibre resource.\n */\nexport const enum ResourceType {\n Glyphs = 'Glyphs',\n Image = 'Image',\n Source = 'Source',\n SpriteImage = 'SpriteImage',\n SpriteJSON = 'SpriteJSON',\n Style = 'Style',\n Tile = 'Tile',\n Unknown = 'Unknown',\n}\n\n/**\n * This function is used to tranform a request.\n * It is used just before executing the relevant request.\n */\nexport type RequestTransformFunction = (url: string, resourceType?: ResourceType) => RequestParameters | undefined;\n\ntype UrlObject = {\n protocol: string;\n authority: string;\n path: string;\n params: Array;\n};\n\nexport class RequestManager {\n _transformRequestFn: RequestTransformFunction;\n\n constructor(transformRequestFn?: RequestTransformFunction) {\n this._transformRequestFn = transformRequestFn;\n }\n\n transformRequest(url: string, type: ResourceType) {\n if (this._transformRequestFn) {\n return this._transformRequestFn(url, type) || {url};\n }\n\n return {url};\n }\n\n normalizeSpriteURL(url: string, format: string, extension: string): string {\n const urlObject = parseUrl(url);\n urlObject.path += `${format}${extension}`;\n return formatUrl(urlObject);\n }\n\n setTransformRequest(transformRequest: RequestTransformFunction) {\n this._transformRequestFn = transformRequest;\n }\n}\n\nconst urlRe = /^(\\w+):\\/\\/([^/?]*)(\\/[^?]+)?\\??(.+)?/;\n\nfunction parseUrl(url: string): UrlObject {\n const parts = url.match(urlRe);\n if (!parts) {\n throw new Error(`Unable to parse URL \"${url}\"`);\n }\n return {\n protocol: parts[1],\n authority: parts[2],\n path: parts[3] || '/',\n params: parts[4] ? parts[4].split('&') : []\n };\n}\n\nfunction formatUrl(obj: UrlObject): string {\n const params = obj.params.length ? `?${obj.params.join('&')}` : '';\n return `${obj.protocol}://${obj.authority}${obj.path}${params}`;\n}\n","import {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * Takes a SpriteSpecification value and returns it in its array form. If `undefined` is passed as an input value, an\n * empty array is returned.\n * duplicated entries with identical id/url will be removed in returned array\n * @param sprite - optional sprite to coerce\n * @returns an empty array in case `undefined` is passed; id-url pairs otherwise\n */\nexport function coerceSpriteToArray(sprite?: SpriteSpecification): {id: string; url: string}[] {\n const resultArray: {id: string; url: string}[] = [];\n\n if (typeof sprite === 'string') {\n resultArray.push({id: 'default', url: sprite});\n } else if (sprite && sprite.length > 0) {\n const dedupArray: string[] = [];\n for (const {id, url} of sprite) {\n const key = `${id}${url}`;\n if (dedupArray.indexOf(key) === -1) {\n dedupArray.push(key);\n resultArray.push({id, url});\n }\n }\n }\n\n return resultArray;\n\n}\n","import {getJSON} from '../util/ajax';\nimport {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\n\nimport {browser} from '../util/browser';\nimport {coerceSpriteToArray} from '../util/style';\n\nimport type {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {StyleImage} from './style_image';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\nexport function loadSprite(\n originalSprite: SpriteSpecification,\n requestManager: RequestManager,\n pixelRatio: number,\n callback: Callback<{[spriteName: string]: {[id: string]: StyleImage}}>\n): Cancelable {\n const spriteArray = coerceSpriteToArray(originalSprite);\n const spriteArrayLength = spriteArray.length;\n const format = pixelRatio > 1 ? '@2x' : '';\n\n const combinedRequestsMap: {[requestKey: string]: Cancelable} = {};\n const jsonsMap: {[id: string]: any} = {};\n const imagesMap: {[id: string]: (HTMLImageElement | ImageBitmap)} = {};\n\n for (const {id, url} of spriteArray) {\n const jsonRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.json'), ResourceType.SpriteJSON);\n const jsonRequestKey = `${id}_${jsonRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique\n combinedRequestsMap[jsonRequestKey] = getJSON(jsonRequestParameters, (err?: Error | null, data?: any | null) => {\n delete combinedRequestsMap[jsonRequestKey];\n jsonsMap[id] = data;\n doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength);\n });\n\n const imageRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.png'), ResourceType.SpriteImage);\n const imageRequestKey = `${id}_${imageRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique\n combinedRequestsMap[imageRequestKey] = ImageRequest.getImage(imageRequestParameters, (err, img) => {\n delete combinedRequestsMap[imageRequestKey];\n imagesMap[id] = img;\n doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength);\n });\n }\n\n return {\n cancel() {\n for (const requst of Object.values(combinedRequestsMap)) {\n requst.cancel();\n }\n }\n };\n}\n\n/**\n * @param callbackFunc - the callback function (both erro and success)\n * @param jsonsMap - JSON data map\n * @param imagesMap - image data map\n * @param err - error object\n * @param expectedResultCounter - number of expected JSON or Image results when everything is finished, respectively.\n */\nfunction doOnceCompleted(\n callbackFunc:Callback<{[spriteName: string]: {[id: string]: StyleImage}}>,\n jsonsMap:{[id: string]: any},\n imagesMap:{[id: string]: (HTMLImageElement | ImageBitmap)},\n err: Error,\n expectedResultCounter: number): void {\n\n if (err) {\n callbackFunc(err);\n return;\n }\n\n if (expectedResultCounter !== Object.values(jsonsMap).length || expectedResultCounter !== Object.values(imagesMap).length) {\n // not done yet, nothing to do\n return;\n }\n\n const result = {} as {[spriteName: string]: {[id: string]: StyleImage}};\n for (const spriteName in jsonsMap) {\n result[spriteName] = {};\n\n const context = browser.getImageCanvasContext(imagesMap[spriteName]);\n const json = jsonsMap[spriteName];\n\n for (const id in json) {\n const {width, height, x, y, sdf, pixelRatio, stretchX, stretchY, content} = json[id];\n const spriteData = {width, height, x, y, context};\n result[spriteName][id] = {data: null, pixelRatio, sdf, stretchX, stretchY, content, spriteData};\n }\n }\n\n callbackFunc(null, result);\n}\n","import type {Context} from '../gl/context';\nimport type {RGBAImage, AlphaImage} from '../util/image';\nimport {isImageBitmap} from '../util/util';\n\nexport type TextureFormat = WebGLRenderingContextBase['RGBA'] | WebGLRenderingContextBase['ALPHA'];\nexport type TextureFilter = WebGLRenderingContextBase['LINEAR'] | WebGLRenderingContextBase['LINEAR_MIPMAP_NEAREST'] | WebGLRenderingContextBase['NEAREST'];\nexport type TextureWrap = WebGLRenderingContextBase['REPEAT'] | WebGLRenderingContextBase['CLAMP_TO_EDGE'] | WebGLRenderingContextBase['MIRRORED_REPEAT'];\n\ntype EmptyImage = {\n width: number;\n height: number;\n data: null;\n};\n\ntype DataTextureImage = RGBAImage | AlphaImage | EmptyImage;\nexport type TextureImage = TexImageSource | DataTextureImage;\n\n/**\n * @internal\n * A `Texture` GL related object\n */\nexport class Texture {\n context: Context;\n size: [number, number];\n texture: WebGLTexture;\n format: TextureFormat;\n filter: TextureFilter;\n wrap: TextureWrap;\n useMipmap: boolean;\n\n constructor(context: Context, image: TextureImage, format: TextureFormat, options?: {\n premultiply?: boolean;\n useMipmap?: boolean;\n } | null) {\n this.context = context;\n this.format = format;\n this.texture = context.gl.createTexture();\n this.update(image, options);\n }\n\n update(image: TextureImage, options?: {\n premultiply?: boolean;\n useMipmap?: boolean;\n } | null, position?: {\n x: number;\n y: number;\n }) {\n const {width, height} = image as {width: number; height: number};\n const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position;\n const {context} = this;\n const {gl} = context;\n\n this.useMipmap = Boolean(options && options.useMipmap);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n context.pixelStoreUnpackFlipY.set(false);\n context.pixelStoreUnpack.set(1);\n context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl.RGBA && (!options || options.premultiply !== false));\n\n if (resize) {\n this.size = [width, height];\n\n if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image);\n } else {\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);\n }\n\n } else {\n const {x, y} = position || {x: 0, y: 0};\n if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image);\n } else {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);\n }\n }\n\n if (this.useMipmap && this.isSizePowerOfTwo()) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n }\n\n bind(filter: TextureFilter, wrap: TextureWrap, minFilter?: TextureFilter | null) {\n const {context} = this;\n const {gl} = context;\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n if (minFilter === gl.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) {\n minFilter = gl.LINEAR;\n }\n\n if (filter !== this.filter) {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || filter);\n this.filter = filter;\n }\n\n if (wrap !== this.wrap) {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);\n this.wrap = wrap;\n }\n }\n\n isSizePowerOfTwo() {\n return this.size[0] === this.size[1] && (Math.log(this.size[0]) / Math.LN2) % 1 === 0;\n }\n\n destroy() {\n const {gl} = this.context;\n gl.deleteTexture(this.texture);\n this.texture = null;\n }\n}\n","import {RGBAImage} from '../util/image';\n\nimport type {Map} from '../ui/map';\n\n/**\n * The sprite data\n */\nexport type SpriteOnDemandStyleImage = {\n width: number;\n height: number;\n x: number;\n y: number;\n context: CanvasRenderingContext2D;\n};\n\n/**\n * The style's image metadata\n */\nexport type StyleImageData = {\n data: RGBAImage;\n version?: number;\n hasRenderCallback?: boolean;\n userImage?: StyleImageInterface;\n spriteData?: SpriteOnDemandStyleImage;\n};\n\n/**\n * The style's image metadata\n */\nexport type StyleImageMetadata = {\n /**\n * The ratio of pixels in the image to physical pixels on the screen\n */\n pixelRatio: number;\n /**\n * Whether the image should be interpreted as an SDF image\n */\n sdf: boolean;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally.\n */\n stretchX?: Array<[number, number]>;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically.\n */\n stretchY?: Array<[number, number]>;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`.\n */\n content?: [number, number, number, number];\n};\n\n/**\n * the style's image, including data and metedata\n */\nexport type StyleImage = StyleImageData & StyleImageMetadata;\n\n/**\n * Interface for dynamically generated style images. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Images implementing this interface can be redrawn for every frame. They can be used to animate\n * icons and patterns or make them respond to user input. Style images can implement a\n * {@link StyleImageInterface#render} method. The method is called every frame and\n * can be used to update the image.\n *\n * @see [Add an animated icon to the map.](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/)\n *\n * @example\n * ```ts\n * let flashingSquare = {\n * width: 64,\n * height: 64,\n * data: new Uint8Array(64 * 64 * 4),\n *\n * onAdd: function(map) {\n * this.map = map;\n * },\n *\n * render: function() {\n * // keep repainting while the icon is on the map\n * this.map.triggerRepaint();\n *\n * // alternate between black and white based on the time\n * let value = Math.round(Date.now() / 1000) % 2 === 0 ? 255 : 0;\n *\n * // check if image needs to be changed\n * if (value !== this.previousValue) {\n * this.previousValue = value;\n *\n * let bytesPerPixel = 4;\n * for (let x = 0; x < this.width; x++) {\n * for (let y = 0; y < this.height; y++) {\n * let offset = (y * this.width + x) * bytesPerPixel;\n * this.data[offset + 0] = value;\n * this.data[offset + 1] = value;\n * this.data[offset + 2] = value;\n * this.data[offset + 3] = 255;\n * }\n * }\n *\n * // return true to indicate that the image changed\n * return true;\n * }\n * }\n * }\n *\n * map.addImage('flashing_square', flashingSquare);\n * ```\n */\n\nexport interface StyleImageInterface {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n /**\n * This method is called once before every frame where the icon will be used.\n * The method can optionally update the image's `data` member with a new image.\n *\n * If the method updates the image it must return `true` to commit the change.\n * If the method returns `false` or nothing the image is assumed to not have changed.\n *\n * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update\n * the image instead of implementing this method.\n *\n * @returns `true` if this method updated the image. `false` if the image was not changed.\n */\n render?: () => boolean;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addImage}.\n *\n * @param map - The Map this custom layer was just added to.\n */\n onAdd?: (map: Map, id: string) => void;\n /**\n * Optional method called when the icon is removed from the map with {@link Map#removeImage}.\n * This gives the image a chance to clean up resources and event listeners.\n */\n onRemove?: () => void;\n}\n\nexport function renderStyleImage(image: StyleImage) {\n const {userImage} = image;\n if (userImage && userImage.render) {\n const updated = userImage.render();\n if (updated) {\n image.data.replace(new Uint8Array(userImage.data.buffer));\n return true;\n }\n }\n return false;\n}\n","/* eslint-disable key-spacing */\nimport potpack from 'potpack';\n\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {RGBAImage} from '../util/image';\nimport {ImagePosition} from './image_atlas';\nimport {Texture} from './texture';\nimport {renderStyleImage} from '../style/style_image';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {Context} from '../gl/context';\nimport type {PotpackBox} from 'potpack';\nimport type {Callback} from '../types/callback';\n\ntype Pattern = {\n bin: PotpackBox;\n position: ImagePosition;\n};\n\n// When copied into the atlas texture, image data is padded by one pixel on each side. Icon\n// images are padded with fully transparent pixels, while pattern images are padded with a\n// copy of the image data wrapped from the opposite side. In both cases, this ensures the\n// correct behavior of GL_LINEAR texture sampling mode.\nconst padding = 1;\n\n/*\n ImageManager does three things:\n\n 1. Tracks requests for icon images from tile workers and sends responses when the requests are fulfilled.\n 2. Builds a texture atlas for pattern images.\n 3. Rerenders renderable images once per frame\n\n These are disparate responsibilities and should eventually be handled by different classes. When we implement\n data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time\n to refactor this.\n*/\nexport class ImageManager extends Evented {\n images: {[_: string]: StyleImage};\n updatedImages: {[_: string]: boolean};\n callbackDispatchedThisFrame: {[_: string]: boolean};\n loaded: boolean;\n requestors: Array<{\n ids: Array;\n callback: Callback<{[_: string]: StyleImage}>;\n }>;\n\n patterns: {[_: string]: Pattern};\n atlasImage: RGBAImage;\n atlasTexture: Texture;\n dirty: boolean;\n\n constructor() {\n super();\n this.images = {};\n this.updatedImages = {};\n this.callbackDispatchedThisFrame = {};\n this.loaded = false;\n this.requestors = [];\n\n this.patterns = {};\n this.atlasImage = new RGBAImage({width: 1, height: 1});\n this.dirty = true;\n }\n\n isLoaded() {\n return this.loaded;\n }\n\n setLoaded(loaded: boolean) {\n if (this.loaded === loaded) {\n return;\n }\n\n this.loaded = loaded;\n\n if (loaded) {\n for (const {ids, callback} of this.requestors) {\n this._notify(ids, callback);\n }\n this.requestors = [];\n }\n }\n\n getImage(id: string): StyleImage {\n const image = this.images[id];\n\n // Extract sprite image data on demand\n if (image && !image.data && image.spriteData) {\n const spriteData = image.spriteData;\n image.data = new RGBAImage({\n width: spriteData.width,\n height: spriteData.height\n }, spriteData.context.getImageData(\n spriteData.x,\n spriteData.y,\n spriteData.width,\n spriteData.height).data);\n image.spriteData = null;\n }\n\n return image;\n }\n\n addImage(id: string, image: StyleImage) {\n if (this.images[id]) throw new Error(`Image id ${id} already exist, use updateImage instead`);\n if (this._validate(id, image)) {\n this.images[id] = image;\n }\n }\n\n _validate(id: string, image: StyleImage) {\n let valid = true;\n const data = image.data || image.spriteData;\n if (!this._validateStretch(image.stretchX, data && data.width)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"stretchX\" value`)));\n valid = false;\n }\n if (!this._validateStretch(image.stretchY, data && data.height)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"stretchY\" value`)));\n valid = false;\n }\n if (!this._validateContent(image.content, image)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"content\" value`)));\n valid = false;\n }\n return valid;\n }\n\n _validateStretch(stretch: Array<[number, number]>, size: number) {\n if (!stretch) return true;\n let last = 0;\n for (const part of stretch) {\n if (part[0] < last || part[1] < part[0] || size < part[1]) return false;\n last = part[1];\n }\n return true;\n }\n\n _validateContent(content: [number, number, number, number], image: StyleImage) {\n if (!content) return true;\n if (content.length !== 4) return false;\n const spriteData = image.spriteData;\n const width = (spriteData && spriteData.width) || image.data.width;\n const height = (spriteData && spriteData.height) || image.data.height;\n if (content[0] < 0 || width < content[0]) return false;\n if (content[1] < 0 || height < content[1]) return false;\n if (content[2] < 0 || width < content[2]) return false;\n if (content[3] < 0 || height < content[3]) return false;\n if (content[2] < content[0]) return false;\n if (content[3] < content[1]) return false;\n return true;\n }\n\n updateImage(id: string, image: StyleImage, validate = true) {\n const oldImage = this.getImage(id);\n if (validate && (oldImage.data.width !== image.data.width || oldImage.data.height !== image.data.height)) {\n throw new Error(`size mismatch between old image (${oldImage.data.width}x${oldImage.data.height}) and new image (${image.data.width}x${image.data.height}).`);\n }\n image.version = oldImage.version + 1;\n this.images[id] = image;\n this.updatedImages[id] = true;\n }\n\n removeImage(id: string) {\n const image = this.images[id];\n delete this.images[id];\n delete this.patterns[id];\n\n if (image.userImage && image.userImage.onRemove) {\n image.userImage.onRemove();\n }\n }\n\n listImages(): Array {\n return Object.keys(this.images);\n }\n\n getImages(ids: Array, callback: Callback<{[_: string]: StyleImage}>) {\n // If the sprite has been loaded, or if all the icon dependencies are already present\n // (i.e. if they've been added via runtime styling), then notify the requestor immediately.\n // Otherwise, delay notification until the sprite is loaded. At that point, if any of the\n // dependencies are still unavailable, we'll just assume they are permanently missing.\n let hasAllDependencies = true;\n if (!this.isLoaded()) {\n for (const id of ids) {\n if (!this.images[id]) {\n hasAllDependencies = false;\n }\n }\n }\n if (this.isLoaded() || hasAllDependencies) {\n this._notify(ids, callback);\n } else {\n this.requestors.push({ids, callback});\n }\n }\n\n _notify(ids: Array, callback: Callback<{[_: string]: StyleImage}>) {\n const response = {};\n\n for (const id of ids) {\n let image = this.getImage(id);\n\n if (!image) {\n this.fire(new Event('styleimagemissing', {id}));\n //Try to acquire image again in case styleimagemissing has populated it\n image = this.getImage(id);\n }\n\n if (image) {\n // Clone the image so that our own copy of its ArrayBuffer doesn't get transferred.\n response[id] = {\n data: image.data.clone(),\n pixelRatio: image.pixelRatio,\n sdf: image.sdf,\n version: image.version,\n stretchX: image.stretchX,\n stretchY: image.stretchY,\n content: image.content,\n hasRenderCallback: Boolean(image.userImage && image.userImage.render)\n };\n } else {\n warnOnce(`Image \"${id}\" could not be loaded. Please make sure you have added the image with map.addImage() or a \"sprite\" property in your style. You can provide missing images by listening for the \"styleimagemissing\" map event.`);\n }\n }\n\n callback(null, response);\n }\n\n // Pattern stuff\n\n getPixelSize() {\n const {width, height} = this.atlasImage;\n return {width, height};\n }\n\n getPattern(id: string): ImagePosition {\n const pattern = this.patterns[id];\n\n const image = this.getImage(id);\n if (!image) {\n return null;\n }\n\n if (pattern && pattern.position.version === image.version) {\n return pattern.position;\n }\n\n if (!pattern) {\n const w = image.data.width + padding * 2;\n const h = image.data.height + padding * 2;\n const bin = {w, h, x: 0, y: 0};\n const position = new ImagePosition(bin, image);\n this.patterns[id] = {bin, position};\n } else {\n pattern.position.version = image.version;\n }\n\n this._updatePatternAtlas();\n\n return this.patterns[id].position;\n }\n\n bind(context: Context) {\n const gl = context.gl;\n if (!this.atlasTexture) {\n this.atlasTexture = new Texture(context, this.atlasImage, gl.RGBA);\n } else if (this.dirty) {\n this.atlasTexture.update(this.atlasImage);\n this.dirty = false;\n }\n\n this.atlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n _updatePatternAtlas() {\n const bins = [];\n for (const id in this.patterns) {\n bins.push(this.patterns[id].bin);\n }\n\n const {w, h} = potpack(bins);\n\n const dst = this.atlasImage;\n dst.resize({width: w || 1, height: h || 1});\n\n for (const id in this.patterns) {\n const {bin} = this.patterns[id];\n const x = bin.x + padding;\n const y = bin.y + padding;\n const src = this.getImage(id).data;\n const w = src.width;\n const h = src.height;\n\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y}, {width: w, height: h});\n\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src, dst, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src, dst, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.dirty = true;\n }\n\n beginFrame() {\n this.callbackDispatchedThisFrame = {};\n }\n\n dispatchRenderCallbacks(ids: Array) {\n for (const id of ids) {\n\n // the callback for the image was already dispatched for a different frame\n if (this.callbackDispatchedThisFrame[id]) continue;\n this.callbackDispatchedThisFrame[id] = true;\n\n const image = this.getImage(id);\n if (!image) warnOnce(`Image with ID: \"${id}\" was not found`);\n\n const updated = renderStyleImage(image);\n if (updated) {\n this.updateImage(id, image);\n }\n }\n }\n}\n","import {getArrayBuffer} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\n\nimport {parseGlyphPbf} from './parse_glyph_pbf';\n\nimport type {StyleGlyph} from './style_glyph';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\n\nexport function loadGlyphRange(fontstack: string,\n range: number,\n urlTemplate: string,\n requestManager: RequestManager,\n callback: Callback<{\n [_: number]: StyleGlyph | null;\n }>) {\n const begin = range * 256;\n const end = begin + 255;\n\n const request = requestManager.transformRequest(\n urlTemplate.replace('{fontstack}', fontstack).replace('{range}', `${begin}-${end}`),\n ResourceType.Glyphs\n );\n\n getArrayBuffer(request, (err?: Error | null, data?: ArrayBuffer | null) => {\n if (err) {\n callback(err);\n } else if (data) {\n const glyphs = {};\n\n for (const glyph of parseGlyphPbf(data)) {\n glyphs[glyph.id] = glyph;\n }\n\n callback(null, glyphs);\n }\n });\n}\n","const INF = 1e20;\n\nexport default class TinySDF {\n constructor({\n fontSize = 24,\n buffer = 3,\n radius = 8,\n cutoff = 0.25,\n fontFamily = 'sans-serif',\n fontWeight = 'normal',\n fontStyle = 'normal'\n } = {}) {\n this.buffer = buffer;\n this.cutoff = cutoff;\n this.radius = radius;\n\n // make the canvas size big enough to both have the specified buffer around the glyph\n // for \"halo\", and account for some glyphs possibly being larger than their font size\n const size = this.size = fontSize + buffer * 4;\n\n const canvas = this._createCanvas(size);\n const ctx = this.ctx = canvas.getContext('2d', {willReadFrequently: true});\n ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;\n\n ctx.textBaseline = 'alphabetic';\n ctx.textAlign = 'left'; // Necessary so that RTL text doesn't have different alignment\n ctx.fillStyle = 'black';\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(size * size);\n this.gridInner = new Float64Array(size * size);\n this.f = new Float64Array(size);\n this.z = new Float64Array(size + 1);\n this.v = new Uint16Array(size);\n }\n\n _createCanvas(size) {\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = size;\n return canvas;\n }\n\n draw(char) {\n const {\n width: glyphAdvance,\n actualBoundingBoxAscent,\n actualBoundingBoxDescent,\n actualBoundingBoxLeft,\n actualBoundingBoxRight\n } = this.ctx.measureText(char);\n\n // The integer/pixel part of the top alignment is encoded in metrics.glyphTop\n // The remainder is implicitly encoded in the rasterization\n const glyphTop = Math.ceil(actualBoundingBoxAscent);\n const glyphLeft = 0;\n\n // If the glyph overflows the canvas size, it will be clipped at the bottom/right\n const glyphWidth = Math.max(0, Math.min(this.size - this.buffer, Math.ceil(actualBoundingBoxRight - actualBoundingBoxLeft)));\n const glyphHeight = Math.min(this.size - this.buffer, glyphTop + Math.ceil(actualBoundingBoxDescent));\n\n const width = glyphWidth + 2 * this.buffer;\n const height = glyphHeight + 2 * this.buffer;\n\n const len = Math.max(width * height, 0);\n const data = new Uint8ClampedArray(len);\n const glyph = {data, width, height, glyphWidth, glyphHeight, glyphTop, glyphLeft, glyphAdvance};\n if (glyphWidth === 0 || glyphHeight === 0) return glyph;\n\n const {ctx, buffer, gridInner, gridOuter} = this;\n ctx.clearRect(buffer, buffer, glyphWidth, glyphHeight);\n ctx.fillText(char, buffer, buffer + glyphTop);\n const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight);\n\n // Initialize grids outside the glyph range to alpha 0\n gridOuter.fill(INF, 0, len);\n gridInner.fill(0, 0, len);\n\n for (let y = 0; y < glyphHeight; y++) {\n for (let x = 0; x < glyphWidth; x++) {\n const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 255; // alpha value\n if (a === 0) continue; // empty pixels\n\n const j = (y + buffer) * width + x + buffer;\n\n if (a === 1) { // fully drawn pixels\n gridOuter[j] = 0;\n gridInner[j] = INF;\n\n } else { // aliased pixels\n const d = 0.5 - a;\n gridOuter[j] = d > 0 ? d * d : 0;\n gridInner[j] = d < 0 ? d * d : 0;\n }\n }\n }\n\n edt(gridOuter, 0, 0, width, height, width, this.f, this.v, this.z);\n edt(gridInner, buffer, buffer, glyphWidth, glyphHeight, width, this.f, this.v, this.z);\n\n for (let i = 0; i < len; i++) {\n const d = Math.sqrt(gridOuter[i]) - Math.sqrt(gridInner[i]);\n data[i] = Math.round(255 - 255 * (d / this.radius + this.cutoff));\n }\n\n return glyph;\n }\n}\n\n// 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nfunction edt(data, x0, y0, width, height, gridSize, f, v, z) {\n for (let x = x0; x < x0 + width; x++) edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z);\n for (let y = y0; y < y0 + height; y++) edt1d(data, y * gridSize + x0, 1, width, f, v, z);\n}\n\n// 1D squared distance transform\nfunction edt1d(grid, offset, stride, length, f, v, z) {\n v[0] = 0;\n z[0] = -INF;\n z[1] = INF;\n f[0] = grid[offset];\n\n for (let q = 1, k = 0, s = 0; q < length; q++) {\n f[q] = grid[offset + q * stride];\n const q2 = q * q;\n do {\n const r = v[k];\n s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2;\n } while (s <= z[k] && --k > -1);\n\n k++;\n v[k] = q;\n z[k] = s;\n z[k + 1] = INF;\n }\n\n for (let q = 0, k = 0; q < length; q++) {\n while (z[k + 1] < q) k++;\n const r = v[k];\n const qr = q - r;\n grid[offset + q * stride] = f[r] + qr * qr;\n }\n}\n","import {loadGlyphRange} from '../style/load_glyph_range';\n\nimport TinySDF from '@mapbox/tiny-sdf';\nimport {unicodeBlockLookup} from '../util/is_char_in_unicode_block';\nimport {asyncAll} from '../util/util';\nimport {AlphaImage} from '../util/image';\n\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\n\ntype Entry = {\n // null means we've requested the range, but the glyph wasn't included in the result.\n glyphs: {\n [id: number]: StyleGlyph | null;\n };\n requests: {\n [range: number]: Array>;\n };\n ranges: {\n [range: number]: boolean | null;\n };\n tinySDF?: TinySDF;\n};\n\nexport class GlyphManager {\n requestManager: RequestManager;\n localIdeographFontFamily: string;\n entries: {\n [_: string]: Entry;\n };\n url: string;\n\n // exposed as statics to enable stubbing in unit tests\n static loadGlyphRange = loadGlyphRange;\n static TinySDF = TinySDF;\n\n constructor(requestManager: RequestManager, localIdeographFontFamily?: string | null) {\n this.requestManager = requestManager;\n this.localIdeographFontFamily = localIdeographFontFamily;\n this.entries = {};\n }\n\n setURL(url?: string | null) {\n this.url = url;\n }\n\n getGlyphs(glyphs: {\n [stack: string]: Array;\n }, callback: Callback<{\n [stack: string]: {\n [id: number]: StyleGlyph;\n };\n }>) {\n const all = [];\n\n for (const stack in glyphs) {\n for (const id of glyphs[stack]) {\n all.push({stack, id});\n }\n }\n\n asyncAll(all, ({stack, id}, callback: Callback<{\n stack: string;\n id: number;\n glyph: StyleGlyph;\n }>) => {\n let entry = this.entries[stack];\n if (!entry) {\n entry = this.entries[stack] = {\n glyphs: {},\n requests: {},\n ranges: {}\n };\n }\n\n let glyph = entry.glyphs[id];\n if (glyph !== undefined) {\n callback(null, {stack, id, glyph});\n return;\n }\n\n glyph = this._tinySDF(entry, stack, id);\n if (glyph) {\n entry.glyphs[id] = glyph;\n callback(null, {stack, id, glyph});\n return;\n }\n\n const range = Math.floor(id / 256);\n if (range * 256 > 65535) {\n callback(new Error('glyphs > 65535 not supported'));\n return;\n }\n\n if (entry.ranges[range]) {\n callback(null, {stack, id, glyph});\n return;\n }\n\n if (!this.url) {\n callback(new Error('glyphsUrl is not set'));\n return;\n }\n\n let requests = entry.requests[range];\n if (!requests) {\n requests = entry.requests[range] = [];\n GlyphManager.loadGlyphRange(stack, range, this.url, this.requestManager,\n (err, response?: {\n [_: number]: StyleGlyph | null;\n } | null) => {\n if (response) {\n for (const id in response) {\n if (!this._doesCharSupportLocalGlyph(+id)) {\n entry.glyphs[+id] = response[+id];\n }\n }\n entry.ranges[range] = true;\n }\n for (const cb of requests) {\n cb(err, response);\n }\n delete entry.requests[range];\n });\n }\n\n requests.push((err, result?: {\n [_: number]: StyleGlyph | null;\n } | null) => {\n if (err) {\n callback(err);\n } else if (result) {\n callback(null, {stack, id, glyph: result[id] || null});\n }\n });\n }, (err, glyphs?: Array<{\n stack: string;\n id: number;\n glyph: StyleGlyph;\n }> | null) => {\n if (err) {\n callback(err);\n } else if (glyphs) {\n const result = {};\n\n for (const {stack, id, glyph} of glyphs) {\n // Clone the glyph so that our own copy of its ArrayBuffer doesn't get transferred.\n (result[stack] || (result[stack] = {}))[id] = glyph && {\n id: glyph.id,\n bitmap: glyph.bitmap.clone(),\n metrics: glyph.metrics\n };\n }\n\n callback(null, result);\n }\n });\n }\n\n _doesCharSupportLocalGlyph(id: number): boolean {\n /* eslint-disable new-cap */\n return !!this.localIdeographFontFamily &&\n (unicodeBlockLookup['CJK Unified Ideographs'](id) ||\n unicodeBlockLookup['Hangul Syllables'](id) ||\n unicodeBlockLookup['Hiragana'](id) ||\n unicodeBlockLookup['Katakana'](id));\n /* eslint-enable new-cap */\n }\n\n _tinySDF(entry: Entry, stack: string, id: number): StyleGlyph {\n const fontFamily = this.localIdeographFontFamily;\n if (!fontFamily) {\n return;\n }\n\n if (!this._doesCharSupportLocalGlyph(id)) {\n return;\n }\n\n // Client-generated glyphs are rendered at 2x texture scale,\n // because CJK glyphs are more detailed than others.\n const textureScale = 2;\n\n let tinySDF = entry.tinySDF;\n if (!tinySDF) {\n let fontWeight = '400';\n if (/bold/i.test(stack)) {\n fontWeight = '900';\n } else if (/medium/i.test(stack)) {\n fontWeight = '500';\n } else if (/light/i.test(stack)) {\n fontWeight = '200';\n }\n tinySDF = entry.tinySDF = new GlyphManager.TinySDF({\n fontSize: 24 * textureScale,\n buffer: 3 * textureScale,\n radius: 8 * textureScale,\n cutoff: 0.25,\n fontFamily,\n fontWeight\n });\n }\n\n const char = tinySDF.draw(String.fromCharCode(id));\n\n /**\n * TinySDF's \"top\" is the distance from the alphabetic baseline to the top of the glyph.\n * Server-generated fonts specify \"top\" relative to an origin above the em box (the origin\n * comes from FreeType, but I'm unclear on exactly how it's derived)\n * ref: https://github.com/mapbox/sdf-glyph-foundry\n *\n * Server fonts don't yet include baseline information, so we can't line up exactly with them\n * (and they don't line up with each other)\n * ref: https://github.com/mapbox/node-fontnik/pull/160\n *\n * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment\n * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode)\n */\n const topAdjustment = 27.5;\n\n const leftAdjustment = 0.5;\n\n return {\n id,\n bitmap: new AlphaImage({width: char.width || 30 * textureScale, height: char.height || 30 * textureScale}, char.data),\n metrics: {\n width: char.glyphWidth / textureScale || 24,\n height: char.glyphHeight / textureScale || 24,\n left: (char.glyphLeft / textureScale + leftAdjustment) || 0,\n top: char.glyphTop / textureScale - topAdjustment || -8,\n advance: char.glyphAdvance / textureScale || 24,\n isDoubleResolution: true\n }\n };\n }\n}\n","import {interpolates, Color, latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {extend, sphericalToCartesian} from '../util/util';\nimport {Evented} from '../util/evented';\nimport {\n validateStyle,\n validateLight,\n emitValidationErrors\n} from './validate_style';\n\nimport type {StylePropertySpecification, LightSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {EvaluationParameters} from './evaluation_parameters';\nimport type {StyleSetterOptions} from '../style/style';\nimport {Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty} from './properties';\n\nimport type {\n Property,\n PropertyValue,\n TransitionParameters\n} from './properties';\n\ntype LightPosition = {\n x: number;\n y: number;\n z: number;\n};\n\nclass LightPositionProperty implements Property<[number, number, number], LightPosition> {\n specification: StylePropertySpecification;\n\n constructor() {\n this.specification = styleSpec.light.position as StylePropertySpecification;\n }\n\n possiblyEvaluate(\n value: PropertyValue<[number, number, number], LightPosition>,\n parameters: EvaluationParameters\n ): LightPosition {\n return sphericalToCartesian(value.expression.evaluate(parameters));\n }\n\n interpolate(a: LightPosition, b: LightPosition, t: number): LightPosition {\n return {\n x: interpolates.number(a.x, b.x, t),\n y: interpolates.number(a.y, b.y, t),\n z: interpolates.number(a.z, b.z, t),\n };\n }\n}\n\ntype Props = {\n 'anchor': DataConstantProperty<'map' | 'viewport'>;\n 'position': LightPositionProperty;\n 'color': DataConstantProperty;\n 'intensity': DataConstantProperty;\n};\n\ntype PropsPossiblyEvaluated = {\n 'anchor': 'map' | 'viewport';\n 'position': LightPosition;\n 'color': Color;\n 'intensity': number;\n};\n\nconst TRANSITION_SUFFIX = '-transition';\n\nlet lightProperties: Properties;\n\n/*\n * Represents the light used to light extruded features.\n */\nexport class Light extends Evented {\n _transitionable: Transitionable;\n _transitioning: Transitioning;\n properties: PossiblyEvaluated;\n\n constructor(lightOptions?: LightSpecification) {\n super();\n lightProperties = lightProperties || new Properties({\n 'anchor': new DataConstantProperty(styleSpec.light.anchor as StylePropertySpecification),\n 'position': new LightPositionProperty(),\n 'color': new DataConstantProperty(styleSpec.light.color as StylePropertySpecification),\n 'intensity': new DataConstantProperty(styleSpec.light.intensity as StylePropertySpecification),\n });\n this._transitionable = new Transitionable(lightProperties);\n this.setLight(lightOptions);\n this._transitioning = this._transitionable.untransitioned();\n }\n\n getLight(): LightSpecification {\n return this._transitionable.serialize();\n }\n\n setLight(light?: LightSpecification, options: StyleSetterOptions = {}) {\n if (this._validate(validateLight, light, options)) {\n return;\n }\n\n for (const name in light) {\n const value = light[name];\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionable.setTransition(name.slice(0, -TRANSITION_SUFFIX.length) as keyof Props, value);\n } else {\n this._transitionable.setValue(name as keyof Props, value);\n }\n }\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioning = this._transitionable.transitioned(parameters, this._transitioning);\n }\n\n hasTransition() {\n return this._transitioning.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters) {\n this.properties = this._transitioning.possiblyEvaluate(parameters);\n }\n\n _validate(validate: Function, value: unknown, options?: {\n validate?: boolean;\n }) {\n if (options && options.validate === false) {\n return false;\n }\n\n return emitValidationErrors(this, validate.call(validateStyle, extend({\n value,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true},\n styleSpec\n })));\n }\n}\n","import {warnOnce} from '../util/util';\n\nimport type {Context} from '../gl/context';\n\n/**\n * A dash entry\n */\ntype DashEntry = {\n y: number;\n height: number;\n width: number;\n}\n\n/**\n * @internal\n * A LineAtlas lets us reuse rendered dashed lines\n * by writing many of them to a texture and then fetching their positions\n * using {@link LineAtlas#getDash}.\n *\n * @param width - the width\n * @param height - the height\n */\nexport class LineAtlas {\n width: number;\n height: number;\n nextRow: number;\n bytes: number;\n data: Uint8Array;\n dashEntry: {[_: string]: DashEntry};\n dirty: boolean;\n texture: WebGLTexture;\n\n constructor(width: number, height: number) {\n this.width = width;\n this.height = height;\n this.nextRow = 0;\n\n this.data = new Uint8Array(this.width * this.height);\n\n this.dashEntry = {};\n }\n\n /**\n * Get or create a dash line pattern.\n *\n * @param dasharray - the key (represented by numbers) to get the dash texture\n * @param round - whether to add circle caps in between dash segments\n * @returns position of dash texture in {@link DashEntry}\n */\n getDash(dasharray: Array, round: boolean) {\n const key = dasharray.join(',') + String(round);\n\n if (!this.dashEntry[key]) {\n this.dashEntry[key] = this.addDash(dasharray, round);\n }\n return this.dashEntry[key];\n }\n\n getDashRanges(dasharray: Array, lineAtlasWidth: number, stretch: number) {\n // If dasharray has an odd length, both the first and last parts\n // are dashes and should be joined seamlessly.\n const oddDashArray = dasharray.length % 2 === 1;\n\n const ranges = [];\n\n let left = oddDashArray ? -dasharray[dasharray.length - 1] * stretch : 0;\n let right = dasharray[0] * stretch;\n let isDash = true;\n\n ranges.push({left, right, isDash, zeroLength: dasharray[0] === 0});\n\n let currentDashLength = dasharray[0];\n for (let i = 1; i < dasharray.length; i++) {\n isDash = !isDash;\n\n const dashLength = dasharray[i];\n left = currentDashLength * stretch;\n currentDashLength += dashLength;\n right = currentDashLength * stretch;\n\n ranges.push({left, right, isDash, zeroLength: dashLength === 0});\n }\n\n return ranges;\n }\n\n addRoundDash(ranges: any, stretch: number, n: number) {\n const halfStretch = stretch / 2;\n\n for (let y = -n; y <= n; y++) {\n const row = this.nextRow + n + y;\n const index = this.width * row;\n let currIndex = 0;\n let range = ranges[currIndex];\n\n for (let x = 0; x < this.width; x++) {\n if (x / range.right > 1) { range = ranges[++currIndex]; }\n\n const distLeft = Math.abs(x - range.left);\n const distRight = Math.abs(x - range.right);\n const minDist = Math.min(distLeft, distRight);\n let signedDistance;\n\n const distMiddle = y / n * (halfStretch + 1);\n if (range.isDash) {\n const distEdge = halfStretch - Math.abs(distMiddle);\n signedDistance = Math.sqrt(minDist * minDist + distEdge * distEdge);\n } else {\n signedDistance = halfStretch - Math.sqrt(minDist * minDist + distMiddle * distMiddle);\n }\n\n this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128));\n }\n }\n }\n\n addRegularDash(ranges: any) {\n\n // Collapse any zero-length range\n // Collapse neighbouring same-type parts into a single part\n for (let i = ranges.length - 1; i >= 0; --i) {\n const part = ranges[i];\n const next = ranges[i + 1];\n if (part.zeroLength) {\n ranges.splice(i, 1);\n } else if (next && next.isDash === part.isDash) {\n next.left = part.left;\n ranges.splice(i, 1);\n }\n }\n\n // Combine the first and last parts if possible\n const first = ranges[0];\n const last = ranges[ranges.length - 1];\n if (first.isDash === last.isDash) {\n first.left = last.left - this.width;\n last.right = first.right + this.width;\n }\n\n const index = this.width * this.nextRow;\n let currIndex = 0;\n let range = ranges[currIndex];\n\n for (let x = 0; x < this.width; x++) {\n if (x / range.right > 1) {\n range = ranges[++currIndex];\n }\n\n const distLeft = Math.abs(x - range.left);\n const distRight = Math.abs(x - range.right);\n\n const minDist = Math.min(distLeft, distRight);\n const signedDistance = range.isDash ? minDist : -minDist;\n\n this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128));\n }\n }\n\n addDash(dasharray: Array, round: boolean): DashEntry {\n const n = round ? 7 : 0;\n const height = 2 * n + 1;\n\n if (this.nextRow + height > this.height) {\n warnOnce('LineAtlas out of space');\n return null;\n }\n\n let length = 0;\n for (let i = 0; i < dasharray.length; i++) { length += dasharray[i]; }\n\n if (length !== 0) {\n const stretch = this.width / length;\n const ranges = this.getDashRanges(dasharray, this.width, stretch);\n\n if (round) {\n this.addRoundDash(ranges, stretch, n);\n } else {\n this.addRegularDash(ranges);\n }\n }\n\n const dashEntry = {\n y: (this.nextRow + n + 0.5) / this.height,\n height: 2 * n / this.height,\n width: length\n };\n\n this.nextRow += height;\n this.dirty = true;\n\n return dashEntry;\n }\n\n bind(context: Context) {\n const gl = context.gl;\n if (!this.texture) {\n this.texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, this.width, this.height, 0, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);\n\n } else {\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n if (this.dirty) {\n this.dirty = false;\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);\n }\n }\n }\n}\n","import {asyncAll} from './util';\nimport {Actor, GlyphsProvider, MessageType} from './actor';\n\nimport type {WorkerPool} from './worker_pool';\nimport type {WorkerSource} from '../source/worker_source'; /* eslint-disable-line */ // this is used for the docs' import\n/**\n * Responsible for sending messages from a {@link Source} to an associated\n * {@link WorkerSource}.\n */\nexport class Dispatcher {\n workerPool: WorkerPool;\n actors: Array;\n currentActor: number;\n id: string | number;\n\n constructor(workerPool: WorkerPool, parent: GlyphsProvider, mapId: string | number) {\n this.workerPool = workerPool;\n this.actors = [];\n this.currentActor = 0;\n this.id = mapId;\n const workers = this.workerPool.acquire(mapId);\n for (let i = 0; i < workers.length; i++) {\n const worker = workers[i];\n const actor = new Actor(worker, parent, mapId);\n actor.name = `Worker ${i}`;\n this.actors.push(actor);\n }\n if (!this.actors.length) throw new Error('No actors found');\n }\n\n /**\n * Broadcast a message to all Workers.\n */\n broadcast(type: MessageType, data: unknown, cb?: (...args: any[]) => any) {\n cb = cb || function () {};\n asyncAll(this.actors, (actor, done) => {\n actor.send(type, data, done);\n }, cb);\n }\n\n /**\n * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion.\n * @returns An actor object backed by a web worker for processing messages.\n */\n getActor(): Actor {\n this.currentActor = (this.currentActor + 1) % this.actors.length;\n return this.actors[this.currentActor];\n }\n\n remove(mapRemoved: boolean = true) {\n this.actors.forEach((actor) => { actor.remove(); });\n this.actors = [];\n if (mapRemoved) this.workerPool.release(this.id);\n }\n}\n","import {pick, extend} from '../util/util';\n\nimport {getJSON} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\n\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\nimport type {TileJSON} from '../types/tilejson';\nimport type {Cancelable} from '../types/cancelable';\nimport type {RasterDEMSourceSpecification, RasterSourceSpecification, VectorSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function loadTileJson(\n options: RasterSourceSpecification | RasterDEMSourceSpecification | VectorSourceSpecification,\n requestManager: RequestManager,\n callback: Callback\n): Cancelable {\n const loaded = function(err: Error, tileJSON: any) {\n if (err) {\n return callback(err);\n } else if (tileJSON) {\n const result: any = pick(\n // explicit source options take precedence over TileJSON\n extend(tileJSON, options),\n ['tiles', 'minzoom', 'maxzoom', 'attribution', 'bounds', 'scheme', 'tileSize', 'encoding']\n );\n\n if (tileJSON.vector_layers) {\n result.vectorLayers = tileJSON.vector_layers;\n result.vectorLayerIds = result.vectorLayers.map((layer) => { return layer.id; });\n }\n\n callback(null, result);\n }\n };\n\n if (options.url) {\n return getJSON(requestManager.transformRequest(options.url, ResourceType.Source), loaded);\n } else {\n return browser.frame(() => loaded(null, options));\n }\n}\n","import {LngLat} from './lng_lat';\nimport type {LngLatLike} from './lng_lat';\n\n/**\n * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,\n * or an array of numbers in [west, south, east, north] order.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLatBounds(\n * new maplibregl.LngLat(-73.9876, 40.7661),\n * new maplibregl.LngLat(-73.9397, 40.8002)\n * );\n * let v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])\n * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];\n * ```\n */\nexport type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];\n\n/**\n * A `LngLatBounds` object represents a geographical bounding box,\n * defined by its southwest and northeast points in longitude and latitude.\n *\n * If no arguments are provided to the constructor, a `null` bounding box is created.\n *\n * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option\n * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatBoundsLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let sw = new maplibregl.LngLat(-73.9876, 40.7661);\n * let ne = new maplibregl.LngLat(-73.9397, 40.8002);\n * let llb = new maplibregl.LngLatBounds(sw, ne);\n * ```\n */\nexport class LngLatBounds {\n _ne: LngLat;\n _sw: LngLat;\n\n /**\n * @param sw - The southwest corner of the bounding box.\n * OR array of 4 numbers in the order of west, south, east, north\n * OR array of 2 LngLatLike: [sw,ne]\n * @param ne - The northeast corner of the bounding box.\n * @example\n * ```ts\n * let sw = new maplibregl.LngLat(-73.9876, 40.7661);\n * let ne = new maplibregl.LngLat(-73.9397, 40.8002);\n * let llb = new maplibregl.LngLatBounds(sw, ne);\n * ```\n * OR\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);\n * ```\n * OR\n * ```ts\n * let llb = new maplibregl.LngLatBounds([sw, ne]);\n * ```\n */\n constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike) {\n if (!sw) {\n // noop\n } else if (ne) {\n this.setSouthWest(sw).setNorthEast(ne);\n } else if (Array.isArray(sw)) {\n if (sw.length === 4) {\n // 4 element array: west, south, east, north\n this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);\n } else {\n this.setSouthWest(sw[0] as LngLatLike).setNorthEast(sw[1] as LngLatLike);\n }\n }\n }\n\n /**\n * Set the northeast corner of the bounding box\n *\n * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box.\n * @returns `this`\n */\n setNorthEast(ne: LngLatLike): this {\n this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);\n return this;\n }\n\n /**\n * Set the southwest corner of the bounding box\n *\n * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box.\n * @returns `this`\n */\n setSouthWest(sw: LngLatLike): this {\n this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);\n return this;\n }\n\n /**\n * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.\n *\n * @param obj - object to extend to\n * @returns `this`\n */\n extend(obj: LngLatLike | LngLatBoundsLike): this {\n const sw = this._sw,\n ne = this._ne;\n let sw2, ne2;\n\n if (obj instanceof LngLat) {\n sw2 = obj;\n ne2 = obj;\n\n } else if (obj instanceof LngLatBounds) {\n sw2 = obj._sw;\n ne2 = obj._ne;\n\n if (!sw2 || !ne2) return this;\n\n } else {\n if (Array.isArray(obj)) {\n if (obj.length === 4 || (obj as any[]).every(Array.isArray)) {\n const lngLatBoundsObj = (obj as any as LngLatBoundsLike);\n return this.extend(LngLatBounds.convert(lngLatBoundsObj));\n } else {\n const lngLatObj = (obj as any as LngLatLike);\n return this.extend(LngLat.convert(lngLatObj));\n }\n\n } else if (obj && ('lng' in obj || 'lon' in obj) && 'lat' in obj) {\n return this.extend(LngLat.convert(obj));\n }\n\n return this;\n }\n\n if (!sw && !ne) {\n this._sw = new LngLat(sw2.lng, sw2.lat);\n this._ne = new LngLat(ne2.lng, ne2.lat);\n\n } else {\n sw.lng = Math.min(sw2.lng, sw.lng);\n sw.lat = Math.min(sw2.lat, sw.lat);\n ne.lng = Math.max(ne2.lng, ne.lng);\n ne.lat = Math.max(ne2.lat, ne.lat);\n }\n\n return this;\n }\n\n /**\n * Returns the geographical coordinate equidistant from the bounding box's corners.\n *\n * @returns The bounding box's center.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}\n * ```\n */\n getCenter(): LngLat {\n return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);\n }\n\n /**\n * Returns the southwest corner of the bounding box.\n *\n * @returns The southwest corner of the bounding box.\n */\n getSouthWest(): LngLat { return this._sw; }\n\n /**\n * Returns the northeast corner of the bounding box.\n *\n * @returns The northeast corner of the bounding box.\n */\n getNorthEast(): LngLat { return this._ne; }\n\n /**\n * Returns the northwest corner of the bounding box.\n *\n * @returns The northwest corner of the bounding box.\n */\n getNorthWest(): LngLat { return new LngLat(this.getWest(), this.getNorth()); }\n\n /**\n * Returns the southeast corner of the bounding box.\n *\n * @returns The southeast corner of the bounding box.\n */\n getSouthEast(): LngLat { return new LngLat(this.getEast(), this.getSouth()); }\n\n /**\n * Returns the west edge of the bounding box.\n *\n * @returns The west edge of the bounding box.\n */\n getWest(): number { return this._sw.lng; }\n\n /**\n * Returns the south edge of the bounding box.\n *\n * @returns The south edge of the bounding box.\n */\n getSouth(): number { return this._sw.lat; }\n\n /**\n * Returns the east edge of the bounding box.\n *\n * @returns The east edge of the bounding box.\n */\n getEast(): number { return this._ne.lng; }\n\n /**\n * Returns the north edge of the bounding box.\n *\n * @returns The north edge of the bounding box.\n */\n getNorth(): number { return this._ne.lat; }\n\n /**\n * Returns the bounding box represented as an array.\n *\n * @returns The bounding box represented as an array, consisting of the\n * southwest and northeast coordinates of the bounding represented as arrays of numbers.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]\n * ```\n */\n toArray() {\n return [this._sw.toArray(), this._ne.toArray()];\n }\n\n /**\n * Return the bounding box represented as a string.\n *\n * @returns The bounding box represents as a string of the format\n * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.toString(); // = \"LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))\"\n * ```\n */\n toString() {\n return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;\n }\n\n /**\n * Check if the bounding box is an empty/`null`-type box.\n *\n * @returns True if bounds have been defined, otherwise false.\n */\n isEmpty() {\n return !(this._sw && this._ne);\n }\n\n /**\n * Check if the point is within the bounding box.\n *\n * @param lnglat - geographic point to check against.\n * @returns `true` if the point is within the bounding box.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds(\n * new maplibregl.LngLat(-73.9876, 40.7661),\n * new maplibregl.LngLat(-73.9397, 40.8002)\n * );\n *\n * let ll = new maplibregl.LngLat(-73.9567, 40.7789);\n *\n * console.log(llb.contains(ll)); // = true\n * ```\n */\n contains(lnglat: LngLatLike) {\n const {lng, lat} = LngLat.convert(lnglat);\n\n const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat;\n let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng;\n if (this._sw.lng > this._ne.lng) { // wrapped coordinates\n containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng;\n }\n\n return containsLatitude && containsLongitude;\n }\n\n /**\n * Converts an array to a `LngLatBounds` object.\n *\n * If a `LngLatBounds` object is passed in, the function returns it unchanged.\n *\n * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.\n *\n * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return.\n * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.\n * @example\n * ```ts\n * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];\n * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}\n * ```\n */\n static convert(input: LngLatBoundsLike | null): LngLatBounds {\n if (input instanceof LngLatBounds) return input;\n if (!input) return input as null;\n return new LngLatBounds(input);\n }\n\n /**\n * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.\n *\n * @param center - center coordinates of the new bounds.\n * @param radius - Distance in meters from the coordinates to extend the bounds.\n * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`.\n * @example\n * ```ts\n * let center = new maplibregl.LngLat(-73.9749, 40.7736);\n * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]\n * ```\n */\n static fromLngLat(center: LngLat, radius:number = 0): LngLatBounds {\n const earthCircumferenceInMetersAtEquator = 40075017;\n const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator,\n lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * center.lat);\n\n return new LngLatBounds(new LngLat(center.lng - lngAccuracy, center.lat - latAccuracy),\n new LngLat(center.lng + lngAccuracy, center.lat + latAccuracy));\n }\n}\n","import {LngLatBounds, LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport {mercatorXfromLng, mercatorYfromLat} from '../geo/mercator_coordinate';\n\nimport type {CanonicalTileID} from './tile_id';\n\nexport class TileBounds {\n bounds: LngLatBounds;\n minzoom: number;\n maxzoom: number;\n\n constructor(bounds: [number, number, number, number], minzoom?: number | null, maxzoom?: number | null) {\n this.bounds = LngLatBounds.convert(this.validateBounds(bounds));\n this.minzoom = minzoom || 0;\n this.maxzoom = maxzoom || 24;\n }\n\n validateBounds(bounds: [number, number, number, number]): LngLatBoundsLike {\n // make sure the bounds property contains valid longitude and latitudes\n if (!Array.isArray(bounds) || bounds.length !== 4) return [-180, -90, 180, 90];\n return [Math.max(-180, bounds[0]), Math.max(-90, bounds[1]), Math.min(180, bounds[2]), Math.min(90, bounds[3])];\n }\n\n contains(tileID: CanonicalTileID) {\n const worldSize = Math.pow(2, tileID.z);\n const level = {\n minX: Math.floor(mercatorXfromLng(this.bounds.getWest()) * worldSize),\n minY: Math.floor(mercatorYfromLat(this.bounds.getNorth()) * worldSize),\n maxX: Math.ceil(mercatorXfromLng(this.bounds.getEast()) * worldSize),\n maxY: Math.ceil(mercatorYfromLat(this.bounds.getSouth()) * worldSize)\n };\n const hit = tileID.x >= level.minX && tileID.x < level.maxX && tileID.y >= level.minY && tileID.y < level.maxY;\n return hit;\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\n\nimport {extend, pick} from '../util/util';\nimport {loadTileJson} from './load_tilejson';\nimport {TileBounds} from './tile_bounds';\nimport {ResourceType} from '../util/request_manager';\n\nimport type {Source} from './source';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport type {VectorSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type VectorTileSourceOptions = VectorSourceSpecification & {\n collectResourceTiming?: boolean;\n}\n\n/**\n * A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/).\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'vector',\n * tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],\n * minzoom: 6,\n * maxzoom: 14\n * });\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setUrl(\"https://demotiles.maplibre.org/tiles/tiles.json\");\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);\n * ```\n * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)\n */\nexport class VectorTileSource extends Evented implements Source {\n type: 'vector';\n id: string;\n minzoom: number;\n maxzoom: number;\n url: string;\n scheme: string;\n tileSize: number;\n promoteId: PromoteIdSpecification;\n\n _options: VectorSourceSpecification;\n _collectResourceTiming: boolean;\n dispatcher: Dispatcher;\n map: Map;\n bounds: [number, number, number, number];\n tiles: Array;\n tileBounds: TileBounds;\n reparseOverscaled: boolean;\n isTileClipped: boolean;\n _tileJSONRequest: Cancelable;\n _loaded: boolean;\n\n constructor(id: string, options: VectorTileSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n\n this.type = 'vector';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.scheme = 'xyz';\n this.tileSize = 512;\n this.reparseOverscaled = true;\n this.isTileClipped = true;\n this._loaded = false;\n\n extend(this, pick(options, ['url', 'scheme', 'tileSize', 'promoteId']));\n this._options = extend({type: 'vector'}, options);\n\n this._collectResourceTiming = options.collectResourceTiming;\n\n if (this.tileSize !== 512) {\n throw new Error('vector tile sources must have a tileSize of 512');\n }\n\n this.setEventedParent(eventedParent);\n }\n\n load = () => {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {\n this._tileJSONRequest = null;\n this._loaded = true;\n this.map.style.sourceCaches[this.id].clearTiles();\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (tileJSON) {\n extend(this, tileJSON);\n if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);\n\n // `content` is included here to prevent a race condition where `Style#_updateSources` is called\n // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives\n // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n }\n });\n };\n\n loaded(): boolean {\n return this._loaded;\n }\n\n hasTile(tileID: OverscaledTileID) {\n return !this.tileBounds || this.tileBounds.contains(tileID.canonical);\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n setSourceProperty(callback: Function) {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n }\n\n callback();\n\n this.load();\n }\n\n /**\n * Sets the source `tiles` property and re-renders the map.\n *\n * @param tiles - An array of one or more tile source URLs, as in the TileJSON spec.\n * @returns `this`\n */\n setTiles(tiles: Array): this {\n this.setSourceProperty(() => {\n this._options.tiles = tiles;\n });\n\n return this;\n }\n\n /**\n * Sets the source `url` property and re-renders the map.\n *\n * @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`.\n * @returns `this`\n */\n setUrl(url: string): this {\n this.setSourceProperty(() => {\n this.url = url;\n this._options.url = url;\n });\n\n return this;\n }\n\n onRemove() {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n this._tileJSONRequest = null;\n }\n }\n\n serialize = (): VectorSourceSpecification => {\n return extend({}, this._options);\n };\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n const params = {\n request: this.map._requestManager.transformRequest(url, ResourceType.Tile),\n uid: tile.uid,\n tileID: tile.tileID,\n zoom: tile.tileID.overscaledZ,\n tileSize: this.tileSize * tile.tileID.overscaleFactor(),\n type: this.type,\n source: this.id,\n pixelRatio: this.map.getPixelRatio(),\n showCollisionBoxes: this.map.showCollisionBoxes,\n promoteId: this.promoteId\n };\n params.request.collectResourceTiming = this._collectResourceTiming;\n\n if (!tile.actor || tile.state === 'expired') {\n tile.actor = this.dispatcher.getActor();\n tile.request = tile.actor.send('loadTile', params, done.bind(this));\n } else if (tile.state === 'loading') {\n // schedule tile reloading after it has been loaded\n tile.reloadCallback = callback;\n } else {\n tile.request = tile.actor.send('reloadTile', params, done.bind(this));\n }\n\n function done(err, data) {\n delete tile.request;\n\n if (tile.aborted)\n return callback(null);\n\n if (err && err.status !== 404) {\n return callback(err);\n }\n\n if (data && data.resourceTiming)\n tile.resourceTiming = data.resourceTiming;\n\n if (this.map._refreshExpiredTiles && data) tile.setExpiryData(data);\n tile.loadVectorData(data, this.map.painter);\n\n callback(null);\n\n if (tile.reloadCallback) {\n this.loadTile(tile, tile.reloadCallback);\n tile.reloadCallback = null;\n }\n }\n }\n\n abortTile(tile: Tile) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n if (tile.actor) {\n tile.actor.send('abortTile', {uid: tile.uid, type: this.type, source: this.id}, undefined);\n }\n }\n\n unloadTile(tile: Tile) {\n tile.unloadVectorData();\n if (tile.actor) {\n tile.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}, undefined);\n }\n }\n\n hasTransition() {\n return false;\n }\n}\n","import {extend, pick} from '../util/util';\n\nimport {ImageRequest} from '../util/image_request';\n\nimport {ResourceType} from '../util/request_manager';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {loadTileJson} from './load_tilejson';\nimport {TileBounds} from './tile_bounds';\nimport {Texture} from '../render/texture';\n\nimport type {Source} from './source';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport type {\n RasterSourceSpecification,\n RasterDEMSourceSpecification\n} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A source containing raster tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('raster-source', {\n * 'type': 'raster',\n * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'],\n * 'tileSize': 256,\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('wms-test-source', {\n * 'type': 'raster',\n * // use the tiles option to specify a WMS tile source URL\n * 'tiles': [\n * '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'\n * ],\n * 'tileSize': 256\n * });\n * ```\n * @see [Add a raster tile source](https://maplibre.org/maplibre-gl-js/docs/examples/map-tiles/)\n * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/)\n * @see [Display a satellite map](https://maplibre.org/maplibre-gl-js/docs/examples/satellite-map/)\n */\nexport class RasterTileSource extends Evented implements Source {\n type: 'raster' | 'raster-dem';\n id: string;\n minzoom: number;\n maxzoom: number;\n url: string;\n scheme: string;\n tileSize: number;\n\n bounds: [number, number, number, number];\n tileBounds: TileBounds;\n roundZoom: boolean;\n dispatcher: Dispatcher;\n map: Map;\n tiles: Array;\n\n _loaded: boolean;\n _options: RasterSourceSpecification | RasterDEMSourceSpecification;\n _tileJSONRequest: Cancelable;\n\n constructor(id: string, options: RasterSourceSpecification | RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n this.setEventedParent(eventedParent);\n\n this.type = 'raster';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.roundZoom = true;\n this.scheme = 'xyz';\n this.tileSize = 512;\n this._loaded = false;\n\n this._options = extend({type: 'raster'}, options);\n extend(this, pick(options, ['url', 'scheme', 'tileSize']));\n }\n\n load() {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {\n this._tileJSONRequest = null;\n this._loaded = true;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (tileJSON) {\n extend(this, tileJSON);\n if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);\n\n // `content` is included here to prevent a race condition where `Style#_updateSources` is called\n // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives\n // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n }\n });\n }\n\n loaded(): boolean {\n return this._loaded;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n onRemove() {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n this._tileJSONRequest = null;\n }\n }\n\n setSourceProperty(callback: Function) {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n }\n\n callback();\n\n this.load();\n }\n\n /**\n * Sets the source `tiles` property and re-renders the map.\n *\n * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/)\n * @returns `this`\n */\n setTiles(tiles: Array): this {\n this.setSourceProperty(() => {\n this._options.tiles = tiles;\n });\n\n return this;\n }\n\n serialize() {\n return extend({}, this._options);\n }\n\n hasTile(tileID: OverscaledTileID) {\n return !this.tileBounds || this.tileBounds.contains(tileID.canonical);\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), (err, img, expiry) => {\n delete tile.request;\n\n if (tile.aborted) {\n tile.state = 'unloaded';\n callback(null);\n } else if (err) {\n tile.state = 'errored';\n callback(err);\n } else if (img) {\n if (this.map._refreshExpiredTiles && expiry) tile.setExpiryData(expiry);\n\n const context = this.map.painter.context;\n const gl = context.gl;\n tile.texture = this.map.painter.getTileTexture(img.width);\n if (tile.texture) {\n tile.texture.update(img, {useMipmap: true});\n } else {\n tile.texture = new Texture(context, img, gl.RGBA, {useMipmap: true});\n tile.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n\n if (context.extTextureFilterAnisotropic) {\n gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax);\n }\n }\n\n tile.state = 'loaded';\n\n callback(null);\n }\n }, this.map._refreshExpiredTiles);\n }\n\n abortTile(tile: Tile, callback: Callback) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n callback();\n }\n\n unloadTile(tile: Tile, callback: Callback) {\n if (tile.texture) this.map.painter.saveTileTexture(tile.texture);\n callback();\n }\n\n hasTransition() {\n return false;\n }\n}\n","import {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\nimport {extend, isImageBitmap, readImageUsingVideoFrame} from '../util/util';\nimport {Evented} from '../util/evented';\nimport {browser} from '../util/browser';\nimport {offscreenCanvasSupported} from '../util/offscreen_canvas_supported';\nimport {OverscaledTileID} from './tile_id';\nimport {RasterTileSource} from './raster_tile_source';\n// ensure DEMData is registered for worker transfer on main thread:\nimport '../data/dem_data';\nimport type {DEMEncoding} from '../data/dem_data';\n\nimport type {Source} from './source';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {RasterDEMSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {ExpiryData} from '../util/ajax';\nimport {isOffscreenCanvasDistorted} from '../util/offscreen_canvas_distorted';\nimport {RGBAImage} from '../util/image';\n\n/**\n * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n * This source can be used to show hillshading and 3D terrain\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('raster-dem-source', {\n * type: 'raster-dem',\n * url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',\n * tileSize: 256\n * });\n * ```\n * @see [3D Terrain](https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/)\n */\nexport class RasterDEMTileSource extends RasterTileSource implements Source {\n encoding: DEMEncoding;\n redFactor?: number;\n greenFactor?: number;\n blueFactor?: number;\n baseShift?: number;\n\n constructor(id: string, options: RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n this.type = 'raster-dem';\n this.maxzoom = 22;\n this._options = extend({type: 'raster-dem'}, options);\n this.encoding = options.encoding || 'mapbox';\n this.redFactor = options.redFactor;\n this.greenFactor = options.greenFactor;\n this.blueFactor = options.blueFactor;\n this.baseShift = options.baseShift;\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n const request = this.map._requestManager.transformRequest(url, ResourceType.Tile);\n tile.neighboringTiles = this._getNeighboringTiles(tile.tileID);\n tile.request = ImageRequest.getImage(request, async (err: Error, img: (HTMLImageElement | ImageBitmap), expiry: ExpiryData) => {\n delete tile.request;\n if (tile.aborted) {\n tile.state = 'unloaded';\n callback(null);\n } else if (err) {\n tile.state = 'errored';\n callback(err);\n } else if (img) {\n if (this.map._refreshExpiredTiles) tile.setExpiryData(expiry);\n const transfer = isImageBitmap(img) && offscreenCanvasSupported();\n const rawImageData = transfer ? img : await readImageNow(img);\n const params = {\n uid: tile.uid,\n coord: tile.tileID,\n source: this.id,\n rawImageData,\n encoding: this.encoding,\n redFactor: this.redFactor,\n greenFactor: this.greenFactor,\n blueFactor: this.blueFactor,\n baseShift: this.baseShift\n };\n\n if (!tile.actor || tile.state === 'expired') {\n tile.actor = this.dispatcher.getActor();\n tile.actor.send('loadDEMTile', params, done);\n }\n }\n }, this.map._refreshExpiredTiles);\n\n async function readImageNow(img: ImageBitmap | HTMLImageElement): Promise {\n if (typeof VideoFrame !== 'undefined' && isOffscreenCanvasDistorted()) {\n const width = img.width + 2;\n const height = img.height + 2;\n try {\n return new RGBAImage({width, height}, await readImageUsingVideoFrame(img, -1, -1, width, height));\n } catch (e) {\n // fall-back to browser canvas decoding\n }\n }\n return browser.getImageData(img, 1);\n }\n\n function done(err, data) {\n if (err) {\n tile.state = 'errored';\n callback(err);\n }\n\n if (data) {\n tile.dem = data;\n tile.needsHillshadePrepare = true;\n tile.needsTerrainPrepare = true;\n tile.state = 'loaded';\n callback(null);\n }\n }\n }\n\n _getNeighboringTiles(tileID: OverscaledTileID) {\n const canonical = tileID.canonical;\n const dim = Math.pow(2, canonical.z);\n\n const px = (canonical.x - 1 + dim) % dim;\n const pxw = canonical.x === 0 ? tileID.wrap - 1 : tileID.wrap;\n const nx = (canonical.x + 1 + dim) % dim;\n const nxw = canonical.x + 1 === dim ? tileID.wrap + 1 : tileID.wrap;\n\n const neighboringTiles = {};\n // add adjacent tiles\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y).key] = {backfilled: false};\n\n // Add upper neighboringTiles\n if (canonical.y > 0) {\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y - 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y - 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y - 1).key] = {backfilled: false};\n }\n // Add lower neighboringTiles\n if (canonical.y + 1 < dim) {\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y + 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y + 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y + 1).key] = {backfilled: false};\n }\n\n return neighboringTiles;\n }\n\n unloadTile(tile: Tile) {\n if (tile.demTexture) this.map.painter.saveTileTexture(tile.demTexture);\n if (tile.fbo) {\n tile.fbo.destroy();\n delete tile.fbo;\n }\n if (tile.dem) delete tile.dem;\n delete tile.neighboringTiles;\n\n tile.state = 'unloaded';\n if (tile.actor) {\n tile.actor.send('removeDEMTile', {uid: tile.uid, source: this.id});\n }\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\n\nimport {extend} from '../util/util';\nimport {EXTENT} from '../data/extent';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\n\nimport type {Source} from './source';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Actor} from '../util/actor';\nimport type {Callback} from '../types/callback';\nimport type {GeoJSONSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {GeoJSONSourceDiff} from './geojson_source_diff';\nimport type {Options, ClusterProperties} from 'supercluster';\n\nexport type GeoJSONSourceOptions = GeoJSONSourceSpecification & {\n workerOptions?: WorkerOptions;\n collectResourceTiming?: boolean;\n}\n\nexport type GeoJsonSourceOptions = {\n data?: GeoJSON.GeoJSON | string | undefined;\n cluster?: boolean;\n clusterMaxZoom?: number;\n clusterRadius?: number;\n clusterMinPoints?: number;\n generateId?: boolean;\n}\nexport type WorkerOptions = {\n source?: string;\n cluster?: boolean;\n geojsonVtOptions?: {\n buffer?: number;\n tolerance?: number;\n extent?: number;\n maxZoom?: number;\n linemetrics?: boolean;\n generateId?: boolean;\n };\n superclusterOptions?: Options;\n clusterProperties?: ClusterProperties;\n fliter?: any;\n promoteId?: any;\n collectResourceTiming?: boolean;\n}\n\n/**\n * The cluster options to set\n */\nexport type SetClusterOptions = {\n /**\n * Whether or not to cluster\n */\n cluster?: boolean;\n /**\n * The cluster's max zoom\n */\n clusterMaxZoom?: number;\n /**\n * The cluster's radius\n */\n clusterRadius?: number;\n}\n\n/**\n * A source containing GeoJSON.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-geojson) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'geojson',\n * data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'geojson',\n * data: {\n * \"type\": \"FeatureCollection\",\n * \"features\": [{\n * \"type\": \"Feature\",\n * \"properties\": {},\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [\n * -76.53063297271729,\n * 39.18174077994108\n * ]\n * }\n * }]\n * }\n * });\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setData({\n * \"type\": \"FeatureCollection\",\n * \"features\": [{\n * \"type\": \"Feature\",\n * \"properties\": { \"name\": \"Null Island\" },\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [ 0, 0 ]\n * }\n * }]\n * });\n * ```\n * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)\n * @see [Add a GeoJSON line](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-line/)\n * @see [Create a heatmap from points](https://maplibre.org/maplibre-gl-js/docs/examples/heatmap/)\n * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)\n */\nexport class GeoJSONSource extends Evented implements Source {\n type: 'geojson';\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution: string;\n promoteId: PromoteIdSpecification;\n\n isTileClipped: boolean;\n reparseOverscaled: boolean;\n _data: GeoJSON.GeoJSON | string | undefined;\n _options: GeoJsonSourceOptions;\n workerOptions: WorkerOptions;\n map: Map;\n actor: Actor;\n _pendingLoads: number;\n _collectResourceTiming: boolean;\n _removed: boolean;\n\n /** @internal */\n constructor(id: string, options: GeoJSONSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n\n this.id = id;\n\n // `type` is a property rather than a constant to make it easy for 3rd\n // parties to use GeoJSONSource to build their own source types.\n this.type = 'geojson';\n\n this.minzoom = 0;\n this.maxzoom = 18;\n this.tileSize = 512;\n this.isTileClipped = true;\n this.reparseOverscaled = true;\n this._removed = false;\n this._pendingLoads = 0;\n\n this.actor = dispatcher.getActor();\n this.setEventedParent(eventedParent);\n\n this._data = (options.data as any);\n this._options = extend({}, options);\n\n this._collectResourceTiming = options.collectResourceTiming;\n\n if (options.maxzoom !== undefined) this.maxzoom = options.maxzoom;\n if (options.type) this.type = options.type;\n if (options.attribution) this.attribution = options.attribution;\n this.promoteId = options.promoteId;\n\n const scale = EXTENT / this.tileSize;\n\n // sent to the worker, along with `url: ...` or `data: literal geojson`,\n // so that it can load/parse/index the geojson data\n // extending with `options.workerOptions` helps to make it easy for\n // third-party sources to hack/reuse GeoJSONSource.\n this.workerOptions = extend({\n source: this.id,\n cluster: options.cluster || false,\n geojsonVtOptions: {\n buffer: (options.buffer !== undefined ? options.buffer : 128) * scale,\n tolerance: (options.tolerance !== undefined ? options.tolerance : 0.375) * scale,\n extent: EXTENT,\n maxZoom: this.maxzoom,\n lineMetrics: options.lineMetrics || false,\n generateId: options.generateId || false\n },\n superclusterOptions: {\n maxZoom: options.clusterMaxZoom !== undefined ? options.clusterMaxZoom : this.maxzoom - 1,\n minPoints: Math.max(2, options.clusterMinPoints || 2),\n extent: EXTENT,\n radius: (options.clusterRadius || 50) * scale,\n log: false,\n generateId: options.generateId || false\n },\n clusterProperties: options.clusterProperties,\n filter: options.filter\n }, options.workerOptions);\n\n // send the promoteId to the worker to have more flexible updates, but only if it is a string\n if (typeof this.promoteId === 'string') {\n this.workerOptions.promoteId = this.promoteId;\n }\n }\n\n load = () => {\n this._updateWorkerData();\n };\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n /**\n * Sets the GeoJSON data and re-renders the map.\n *\n * @param data - A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files.\n * @returns `this`\n */\n setData(data: GeoJSON.GeoJSON | string): this {\n this._data = data;\n this._updateWorkerData();\n\n return this;\n }\n\n /**\n * Updates the source's GeoJSON, and re-renders the map.\n *\n * For sources with lots of features, this method can be used to make updates more quickly.\n *\n * This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature,\n * or by using the promoteId option to specify which property should be used as the ID.\n *\n * It is an error to call updateData on a source that did not have unique IDs for each of its features already.\n *\n * Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error.\n *\n * @param diff - The changes that need to be applied.\n * @returns `this`\n */\n updateData(diff: GeoJSONSourceDiff): this {\n this._updateWorkerData(diff);\n\n return this;\n }\n\n /**\n * To disable/enable clustering on the source options\n * @param options - The options to set\n * @returns `this`\n * @example\n * ```ts\n * map.getSource('some id').setClusterOptions({cluster: false});\n * map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14});\n * ```\n */\n setClusterOptions(options: SetClusterOptions): this {\n this.workerOptions.cluster = options.cluster;\n if (options) {\n if (options.clusterRadius !== undefined) this.workerOptions.superclusterOptions.radius = options.clusterRadius;\n if (options.clusterMaxZoom !== undefined) this.workerOptions.superclusterOptions.maxZoom = options.clusterMaxZoom;\n }\n this._updateWorkerData();\n return this;\n }\n\n /**\n * For clustered sources, fetches the zoom at which the given cluster expands.\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param callback - A callback to be called when the zoom value is retrieved (`(error, zoom) => { ... }`).\n * @returns `this`\n */\n getClusterExpansionZoom(clusterId: number, callback: Callback): this {\n this.actor.send('geojson.getClusterExpansionZoom', {clusterId, source: this.id}, callback);\n return this;\n }\n\n /**\n * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`).\n * @returns `this`\n */\n getClusterChildren(clusterId: number, callback: Callback>): this {\n this.actor.send('geojson.getClusterChildren', {clusterId, source: this.id}, callback);\n return this;\n }\n\n /**\n * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param limit - The maximum number of features to return.\n * @param offset - The number of features to skip (e.g. for pagination).\n * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`).\n * @returns `this`\n * @example\n * Retrieve cluster leaves on click\n * ```ts\n * map.on('click', 'clusters', function(e) {\n * let features = map.queryRenderedFeatures(e.point, {\n * layers: ['clusters']\n * });\n *\n * let clusterId = features[0].properties.cluster_id;\n * let pointCount = features[0].properties.point_count;\n * let clusterSource = map.getSource('clusters');\n *\n * clusterSource.getClusterLeaves(clusterId, pointCount, 0, function(error, features) {\n * // Print cluster leaves in the console\n * console.log('Cluster leaves:', error, features);\n * })\n * });\n * ```\n */\n getClusterLeaves(clusterId: number, limit: number, offset: number, callback: Callback>): this {\n this.actor.send('geojson.getClusterLeaves', {\n source: this.id,\n clusterId,\n limit,\n offset\n }, callback);\n return this;\n }\n\n /**\n * Responsible for invoking WorkerSource's geojson.loadData target, which\n * handles loading the geojson data and preparing to serve it up as tiles,\n * using geojson-vt or supercluster as appropriate.\n * @param diff - the diff object\n */\n _updateWorkerData(diff?: GeoJSONSourceDiff) {\n const options = extend({}, this.workerOptions);\n if (diff) {\n options.dataDiff = diff;\n } else if (typeof this._data === 'string') {\n options.request = this.map._requestManager.transformRequest(browser.resolveURL(this._data as string), ResourceType.Source);\n options.request.collectResourceTiming = this._collectResourceTiming;\n } else {\n options.data = JSON.stringify(this._data);\n }\n\n this._pendingLoads++;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n\n // target {this.type}.loadData rather than literally geojson.loadData,\n // so that other geojson-like source types can easily reuse this\n // implementation\n this.actor.send(`${this.type}.loadData`, options, (err, result) => {\n this._pendingLoads--;\n\n if (this._removed || (result && result.abandoned)) {\n this.fire(new Event('dataabort', {dataType: 'source'}));\n return;\n }\n\n let resourceTiming = null;\n if (result && result.resourceTiming && result.resourceTiming[this.id])\n resourceTiming = result.resourceTiming[this.id].slice(0);\n\n if (err) {\n this.fire(new ErrorEvent(err));\n return;\n }\n\n const data: any = {dataType: 'source'};\n if (this._collectResourceTiming && resourceTiming && resourceTiming.length > 0)\n extend(data, {resourceTiming});\n\n // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache\n // know its ok to start requesting tiles.\n this.fire(new Event('data', {...data, sourceDataType: 'metadata'}));\n this.fire(new Event('data', {...data, sourceDataType: 'content'}));\n });\n }\n\n loaded(): boolean {\n return this._pendingLoads === 0;\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const message = !tile.actor ? 'loadTile' : 'reloadTile';\n tile.actor = this.actor;\n const params = {\n type: this.type,\n uid: tile.uid,\n tileID: tile.tileID,\n zoom: tile.tileID.overscaledZ,\n maxZoom: this.maxzoom,\n tileSize: this.tileSize,\n source: this.id,\n pixelRatio: this.map.getPixelRatio(),\n showCollisionBoxes: this.map.showCollisionBoxes,\n promoteId: this.promoteId\n };\n\n tile.request = this.actor.send(message, params, (err, data) => {\n delete tile.request;\n tile.unloadVectorData();\n\n if (tile.aborted) {\n return callback(null);\n }\n\n if (err) {\n return callback(err);\n }\n\n tile.loadVectorData(data, this.map.painter, message === 'reloadTile');\n\n return callback(null);\n });\n }\n\n abortTile(tile: Tile) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n tile.aborted = true;\n }\n\n unloadTile(tile: Tile) {\n tile.unloadVectorData();\n this.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id});\n }\n\n onRemove() {\n this._removed = true;\n this.actor.send('removeSource', {type: this.type, source: this.id});\n }\n\n serialize = (): GeoJSONSourceSpecification => {\n return extend({}, this._options, {\n type: this.type,\n data: this._data\n });\n };\n\n hasTransition() {\n return false;\n }\n}\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos', type: 'Int16', components: 2},\n {name: 'a_texture_pos', type: 'Int16', components: 2}\n]);\n","import {CanonicalTileID} from './tile_id';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\nimport {EXTENT} from '../data/extent';\nimport {RasterBoundsArray} from '../data/array_types.g';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\n\nimport type {Source} from './source';\nimport type {CanvasSourceSpecification} from './canvas_source';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {\n ImageSourceSpecification,\n VideoSourceSpecification\n} from '@maplibre/maplibre-gl-style-spec';\nimport {Cancelable} from '../types/cancelable';\n\n/**\n * Four geographical coordinates,\n * represented as arrays of longitude and latitude numbers, which define the corners of the image.\n * The coordinates start at the top left corner of the image and proceed in clockwise order.\n * They do not have to represent a rectangle.\n */\nexport type Coordinates = [[number, number], [number, number], [number, number], [number, number]];\n\n/**\n * The options object for the {@link ImageSource#updateImage} method\n */\nexport type UpdateImageOptions = {\n /**\n * Required image URL.\n */\n url: string;\n /**\n * The image coordinates\n */\n coordinates?: Coordinates;\n}\n\n/**\n * A data source containing an image.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-image) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'image',\n * url: 'https://www.maplibre.org/images/foo.png',\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update coordinates\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * // update url and coordinates simultaneously\n * mySource.updateImage({\n * url: 'https://www.maplibre.org/images/bar.png',\n * coordinates: [\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]\n * })\n *\n * map.removeSource('some id'); // remove\n * ```\n */\nexport class ImageSource extends Evented implements Source {\n type: string;\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n url: string;\n\n coordinates: Coordinates;\n tiles: {[_: string]: Tile};\n options: any;\n dispatcher: Dispatcher;\n map: Map;\n texture: Texture | null;\n image: HTMLImageElement | ImageBitmap;\n tileID: CanonicalTileID;\n _boundsArray: RasterBoundsArray;\n boundsBuffer: VertexBuffer;\n boundsSegments: SegmentVector;\n _loaded: boolean;\n _request: Cancelable;\n\n /** @internal */\n constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n this.coordinates = options.coordinates;\n\n this.type = 'image';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.tileSize = 512;\n this.tiles = {};\n this._loaded = false;\n\n this.setEventedParent(eventedParent);\n\n this.options = options;\n }\n\n load = (newCoordinates?: Coordinates, successCallback?: () => void) => {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n\n this.url = this.options.url;\n\n this._request = ImageRequest.getImage(this.map._requestManager.transformRequest(this.url, ResourceType.Image), (err, image) => {\n this._request = null;\n this._loaded = true;\n\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (image) {\n this.image = image;\n if (newCoordinates) {\n this.coordinates = newCoordinates;\n }\n if (successCallback) {\n successCallback();\n }\n this._finishLoading();\n }\n });\n };\n\n loaded(): boolean {\n return this._loaded;\n }\n\n /**\n * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing,\n * set the `raster-fade-duration` paint property on the raster layer to 0.\n *\n * @param options - The options object.\n * @returns `this`\n */\n updateImage(options: UpdateImageOptions): this {\n if (!options.url) {\n return this;\n }\n\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n\n this.options.url = options.url;\n this.load(options.coordinates, () => { this.texture = null; });\n return this;\n }\n\n _finishLoading() {\n if (this.map) {\n this.setCoordinates(this.coordinates);\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n }\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n onRemove() {\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n }\n\n /**\n * Sets the image's coordinates and re-renders the map.\n *\n * @param coordinates - Four geographical coordinates,\n * represented as arrays of longitude and latitude numbers, which define the corners of the image.\n * The coordinates start at the top left corner of the image and proceed in clockwise order.\n * They do not have to represent a rectangle.\n * @returns `this`\n */\n setCoordinates(coordinates: Coordinates): this {\n this.coordinates = coordinates;\n\n // Calculate which mercator tile is suitable for rendering the video in\n // and create a buffer with the corner coordinates. These coordinates\n // may be outside the tile, because raster tiles aren't clipped when rendering.\n\n // transform the geo coordinates into (zoom 0) tile space coordinates\n const cornerCoords = coordinates.map(MercatorCoordinate.fromLngLat);\n\n // Compute the coordinates of the tile we'll use to hold this image's\n // render data\n this.tileID = getCoordinatesCenterTileID(cornerCoords);\n\n // Constrain min/max zoom to our tile's zoom level in order to force\n // SourceCache to request this tile (no matter what the map's zoom\n // level)\n this.minzoom = this.maxzoom = this.tileID.z;\n\n // Transform the corner coordinates into the coordinate space of our\n // tile.\n const tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round());\n\n this._boundsArray = new RasterBoundsArray();\n this._boundsArray.emplaceBack(tileCoords[0].x, tileCoords[0].y, 0, 0);\n this._boundsArray.emplaceBack(tileCoords[1].x, tileCoords[1].y, EXTENT, 0);\n this._boundsArray.emplaceBack(tileCoords[3].x, tileCoords[3].y, 0, EXTENT);\n this._boundsArray.emplaceBack(tileCoords[2].x, tileCoords[2].y, EXTENT, EXTENT);\n\n if (this.boundsBuffer) {\n this.boundsBuffer.destroy();\n delete this.boundsBuffer;\n }\n\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n return this;\n }\n\n prepare = () => {\n if (Object.keys(this.tiles).length === 0 || !this.image) {\n return;\n }\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.image, gl.RGBA);\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n loadTile(tile: Tile, callback: Callback) {\n // We have a single tile -- whose coordinates are this.tileID -- that\n // covers the image we want to render. If that's the one being\n // requested, set it up with the image; otherwise, mark the tile as\n // `errored` to indicate that we have no data for it.\n // If the world wraps, we may have multiple \"wrapped\" copies of the\n // single tile.\n if (this.tileID && this.tileID.equals(tile.tileID.canonical)) {\n this.tiles[String(tile.tileID.wrap)] = tile;\n tile.buckets = {};\n callback(null);\n } else {\n tile.state = 'errored';\n callback(null);\n }\n }\n\n serialize = (): ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification => {\n return {\n type: 'image',\n url: this.options.url,\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return false;\n }\n}\n\n/**\n * Given a list of coordinates, get their center as a coordinate.\n *\n * @returns centerpoint\n * @internal\n */\nexport function getCoordinatesCenterTileID(coords: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const coord of coords) {\n minX = Math.min(minX, coord.x);\n minY = Math.min(minY, coord.y);\n maxX = Math.max(maxX, coord.x);\n maxY = Math.max(maxY, coord.y);\n }\n\n const dx = maxX - minX;\n const dy = maxY - minY;\n const dMax = Math.max(dx, dy);\n const zoom = Math.max(0, Math.floor(-Math.log(dMax) / Math.LN2));\n const tilesAtZoom = Math.pow(2, zoom);\n\n return new CanonicalTileID(\n zoom,\n Math.floor((minX + maxX) / 2 * tilesAtZoom),\n Math.floor((minY + maxY) / 2 * tilesAtZoom));\n}\n","import {getVideo} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\n\nimport {ImageSource} from './image_source';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {Event, ErrorEvent} from '../util/evented';\nimport {ValidationError} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Evented} from '../util/evented';\nimport type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A data source containing video.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-video) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'video',\n * url: [\n * 'https://www.mapbox.com/blog/assets/baltimore-smoke.mp4',\n * 'https://www.mapbox.com/blog/assets/baltimore-smoke.webm'\n * ],\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * map.removeSource('some id'); // remove\n * ```\n * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)\n *\n * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.\n * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,\n * set the layer's `raster-fade-duration` property to `0`.\n */\nexport class VideoSource extends ImageSource {\n options: VideoSourceSpecification;\n urls: Array;\n video: HTMLVideoElement;\n roundZoom: boolean;\n\n constructor(id: string, options: VideoSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n this.roundZoom = true;\n this.type = 'video';\n this.options = options;\n }\n\n load = () => {\n this._loaded = false;\n const options = this.options;\n\n this.urls = [];\n for (const url of options.urls) {\n this.urls.push(this.map._requestManager.transformRequest(url, ResourceType.Source).url);\n }\n\n getVideo(this.urls, (err, video) => {\n this._loaded = true;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (video) {\n this.video = video;\n this.video.loop = true;\n\n // Start repainting when video starts playing. hasTransition() will then return\n // true to trigger additional frames as long as the videos continues playing.\n this.video.addEventListener('playing', () => {\n this.map.triggerRepaint();\n });\n\n if (this.map) {\n this.video.play();\n }\n\n this._finishLoading();\n }\n });\n };\n\n /**\n * Pauses the video.\n */\n pause() {\n if (this.video) {\n this.video.pause();\n }\n }\n\n /**\n * Plays the video.\n */\n play() {\n if (this.video) {\n this.video.play();\n }\n }\n\n /**\n * Sets playback to a timestamp, in seconds.\n */\n seek(seconds: number) {\n if (this.video) {\n const seekableRange = this.video.seekable;\n if (seconds < seekableRange.start(0) || seconds > seekableRange.end(0)) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`, null, `Playback for this video can be set only between the ${seekableRange.start(0)} and ${seekableRange.end(0)}-second mark.`)));\n } else this.video.currentTime = seconds;\n }\n }\n\n /**\n * Returns the HTML `video` element.\n *\n * @returns The HTML `video` element.\n */\n getVideo(): HTMLVideoElement {\n return this.video;\n }\n\n onAdd(map: Map) {\n if (this.map) return;\n this.map = map;\n this.load();\n if (this.video) {\n this.video.play();\n this.setCoordinates(this.coordinates);\n }\n }\n\n /**\n * Sets the video's coordinates and re-renders the map.\n *\n * @returns `this`\n */\n prepare = (): this => {\n if (Object.keys(this.tiles).length === 0 || this.video.readyState < 2) {\n return; // not enough data for current position\n }\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.video, gl.RGBA);\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n } else if (!this.video.paused) {\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, this.video);\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n serialize = (): VideoSourceSpecification => {\n return {\n type: 'video',\n urls: this.urls,\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return this.video && !this.video.paused;\n }\n}\n","import {ImageSource} from './image_source';\n\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {Event, ErrorEvent} from '../util/evented';\nimport {ValidationError} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Evented} from '../util/evented';\n\n/**\n * Options to add a canvas source type to the map.\n */\nexport type CanvasSourceSpecification = {\n /**\n * Source type. Must be `\"canvas\"`.\n */\n type: 'canvas';\n /**\n * Four geographical coordinates denoting where to place the corners of the canvas, specified in `[longitude, latitude]` pairs.\n */\n coordinates: [[number, number], [number, number], [number, number], [number, number]];\n /**\n * Whether the canvas source is animated. If the canvas is static (i.e. pixels do not need to be re-read on every frame), `animate` should be set to `false` to improve performance.\n * @defaultValue true\n */\n animate?: boolean;\n /**\n * Canvas source from which to read pixels. Can be a string representing the ID of the canvas element, or the `HTMLCanvasElement` itself.\n */\n canvas?: string | HTMLCanvasElement;\n};\n\n/**\n * A data source containing the contents of an HTML canvas. See {@link CanvasSourceSpecification} for detailed documentation of options.\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'canvas',\n * canvas: 'idOfMyHTMLCanvas',\n * animate: true,\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * map.removeSource('some id'); // remove\n * ```\n */\nexport class CanvasSource extends ImageSource {\n options: CanvasSourceSpecification;\n animate: boolean;\n canvas: HTMLCanvasElement;\n width: number;\n height: number;\n /**\n * Enables animation. The image will be copied from the canvas to the map on each frame.\n */\n play: () => void;\n /**\n * Disables animation. The map will display a static copy of the canvas image.\n */\n pause: () => void;\n _playing: boolean;\n\n /** @internal */\n constructor(id: string, options: CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n\n // We build in some validation here, since canvas sources aren't included in the style spec:\n if (!options.coordinates) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property \"coordinates\"')));\n } else if (!Array.isArray(options.coordinates) || options.coordinates.length !== 4 ||\n options.coordinates.some(c => !Array.isArray(c) || c.length !== 2 || c.some(l => typeof l !== 'number'))) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '\"coordinates\" property must be an array of 4 longitude/latitude array pairs')));\n }\n\n if (options.animate && typeof options.animate !== 'boolean') {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'optional \"animate\" property must be a boolean value')));\n }\n\n if (!options.canvas) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property \"canvas\"')));\n } else if (typeof options.canvas !== 'string' && !(options.canvas instanceof HTMLCanvasElement)) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '\"canvas\" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance')));\n }\n\n this.options = options;\n this.animate = options.animate !== undefined ? options.animate : true;\n }\n\n load = () => {\n this._loaded = true;\n if (!this.canvas) {\n this.canvas = (this.options.canvas instanceof HTMLCanvasElement) ?\n this.options.canvas :\n document.getElementById(this.options.canvas) as HTMLCanvasElement;\n // cast to HTMLCanvasElement in else of ternary\n // should we do a safety check and throw if it's not actually HTMLCanvasElement?\n }\n this.width = this.canvas.width;\n this.height = this.canvas.height;\n\n if (this._hasInvalidDimensions()) {\n this.fire(new ErrorEvent(new Error('Canvas dimensions cannot be less than or equal to zero.')));\n return;\n }\n\n this.play = function() {\n this._playing = true;\n this.map.triggerRepaint();\n };\n\n this.pause = function() {\n if (this._playing) {\n this.prepare();\n this._playing = false;\n }\n };\n\n this._finishLoading();\n };\n\n /**\n * Returns the HTML `canvas` element.\n *\n * @returns The HTML `canvas` element.\n */\n getCanvas(): HTMLCanvasElement {\n return this.canvas;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n if (this.canvas) {\n if (this.animate) this.play();\n }\n }\n\n onRemove() {\n this.pause();\n }\n\n prepare = () => {\n let resize = false;\n if (this.canvas.width !== this.width) {\n this.width = this.canvas.width;\n resize = true;\n }\n if (this.canvas.height !== this.height) {\n this.height = this.canvas.height;\n resize = true;\n }\n\n if (this._hasInvalidDimensions()) return;\n\n if (Object.keys(this.tiles).length === 0) return; // not enough data for current position\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.canvas, gl.RGBA, {premultiply: true});\n } else if (resize || this._playing) {\n this.texture.update(this.canvas, {premultiply: true});\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n serialize = (): CanvasSourceSpecification => {\n return {\n type: 'canvas',\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return this._playing;\n }\n\n _hasInvalidDimensions() {\n for (const x of [this.canvas.width, this.canvas.height]) {\n if (isNaN(x) || x <= 0) return true;\n }\n return false;\n }\n}\n","import {VectorTileSource} from '../source/vector_tile_source';\nimport {RasterTileSource} from '../source/raster_tile_source';\nimport {RasterDEMTileSource} from '../source/raster_dem_tile_source';\nimport {GeoJSONSource} from '../source/geojson_source';\nimport {VideoSource} from '../source/video_source';\nimport {ImageSource} from '../source/image_source';\nimport {CanvasSource} from '../source/canvas_source';\n\nimport type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Event, Evented} from '../util/evented';\nimport type {Map} from '../ui/map';\nimport type {Tile} from './tile';\nimport type {OverscaledTileID, CanonicalTileID} from './tile_id';\nimport type {Callback} from '../types/callback';\nimport type {CanvasSourceSpecification} from '../source/canvas_source';\n\nconst registeredSources = {} as {[key:string]: SourceClass};\n\n/**\n * The `Source` interface must be implemented by each source type, including \"core\" types (`vector`, `raster`,\n * `video`, etc.) and all custom, third-party types.\n *\n * @event `data` - Fired with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata\n * has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}`\n * to indicate that the source data has changed, so that any current caches should be flushed.\n *\n * @group Sources\n */\nexport interface Source {\n readonly type: string;\n /**\n * The id for the source. Must not be used by any existing source.\n */\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution?: string;\n /**\n * `true` if zoom levels are rounded to the nearest integer in the source data, `false` if they are floor-ed to the nearest integer.\n */\n roundZoom?: boolean;\n /**\n * `false` if tiles can be drawn outside their boundaries, `true` if they cannot.\n */\n isTileClipped?: boolean;\n tileID?: CanonicalTileID;\n /**\n * `true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not.\n */\n reparseOverscaled?: boolean;\n vectorLayerIds?: Array;\n hasTransition(): boolean;\n loaded(): boolean;\n fire(event: Event): unknown;\n readonly onAdd?: (map: Map) => void;\n readonly onRemove?: (map: Map) => void;\n loadTile(tile: Tile, callback: Callback): void;\n readonly hasTile?: (tileID: OverscaledTileID) => boolean;\n readonly abortTile?: (tile: Tile, callback: Callback) => void;\n readonly unloadTile?: (tile: Tile, callback: Callback) => void;\n /**\n * @returns A plain (stringifiable) JS object representing the current state of the source.\n * Creating a source using the returned object as the `options` should result in a Source that is\n * equivalent to this one.\n */\n serialize(): any;\n readonly prepare?: () => void;\n}\n\n/**\n * A supporting type to the source definition\n */\ntype SourceStatics = {\n /*\n * An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource}\n * implementation for this Source type by calling `self.registerWorkerSource(workerSource: WorkerSource)`.\n */\n workerSourceURL?: URL;\n};\n\n/**\n * A general definition of a {@link Source} class for factory usage\n */\nexport type SourceClass = {\n new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source;\n} & SourceStatics;\n\n/**\n * Creates a tiled data source instance given an options object.\n *\n * @param id - The id for the source. Must not be used by any existing source.\n * @param specification - Source options, specific to the source type (except for `options.type`, which is always required).\n * @param source - A source definition object compliant with\n * [`maplibre-gl-style-spec`](https://maplibre.org/maplibre-style-spec/#sources) or, for a third-party source type,\n * with that type's requirements.\n * @param dispatcher - A {@link Dispatcher} instance, which can be used to send messages to the workers.\n * @returns a newly created source\n */\nexport const create = (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source => {\n\n const Class = getSourceType(specification.type);\n const source = new Class(id, specification, dispatcher, eventedParent);\n\n if (source.id !== id) {\n throw new Error(`Expected Source id to be ${id} instead of ${source.id}`);\n }\n\n return source;\n};\n\nexport const getSourceType = (name: string): SourceClass => {\n switch (name) {\n case 'geojson':\n return GeoJSONSource;\n case 'image':\n return ImageSource;\n case 'raster':\n return RasterTileSource;\n case 'raster-dem':\n return RasterDEMTileSource;\n case 'vector':\n return VectorTileSource;\n case 'video':\n return VideoSource;\n case 'canvas':\n return CanvasSource;\n }\n return registeredSources[name];\n};\n\nexport const setSourceType = (name: string, type: SourceClass) => {\n registeredSources[name] = type;\n};\n\nexport interface Actor {\n send(type: string, data: any, callback: Callback): void;\n}\n","import type {SourceCache} from './source_cache';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CollisionIndex} from '../symbol/collision_index';\nimport type {Transform} from '../geo/transform';\nimport type {RetainedQueryData} from '../symbol/placement';\nimport type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type Point from '@mapbox/point-geometry';\nimport {mat4} from 'gl-matrix';\n\n/**\n * Options to pass to query the map for the rendered features\n */\nexport type QueryRenderedFeaturesOptions = {\n /**\n * An array of [style layer IDs](https://maplibre.org/maplibre-style-spec/#layer-id) for the query to inspect.\n * Only features within these layers will be returned. If this parameter is undefined, all layers will be checked.\n */\n layers?: Array;\n /**\n * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) to limit query results.\n */\n filter?: FilterSpecification;\n /**\n * An array of string representing the available images\n */\n availableImages?: Array;\n /**\n * Whether to check if the [options.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n */\n validate?: boolean;\n};\n\n/**\n * The options object related to the {@link Map#queryRenderedFeatures} method\n */\nexport type QuerySourceFeatureOptions = {\n /**\n * The name of the source layer to query. *For vector tile sources, this parameter is required.* For GeoJSON sources, it is ignored.\n */\n sourceLayer?: string;\n /**\n * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter)\n * to limit query results.\n */\n filter?: FilterSpecification;\n /**\n * Whether to check if the [parameters.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n * @defaultValue true\n */\n validate?: boolean;\n}\n\n/*\n * Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates.\n */\nfunction getPixelPosMatrix(transform, tileID) {\n const t = mat4.create();\n mat4.translate(t, t, [1, 1, 0]);\n mat4.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]);\n return mat4.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped()));\n}\n\nfunction queryIncludes3DLayer(layers: Array, styleLayers: {[_: string]: StyleLayer}, sourceID: string) {\n if (layers) {\n for (const layerID of layers) {\n const layer = styleLayers[layerID];\n if (layer && layer.source === sourceID && layer.type === 'fill-extrusion') {\n return true;\n }\n }\n } else {\n for (const key in styleLayers) {\n const layer = styleLayers[key];\n if (layer.source === sourceID && layer.type === 'fill-extrusion') {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function queryRenderedFeatures(\n sourceCache: SourceCache,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n queryGeometry: Array,\n params: QueryRenderedFeaturesOptions,\n transform: Transform\n): { [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> } {\n\n const has3DLayer = queryIncludes3DLayer(params && params.layers, styleLayers, sourceCache.id);\n const maxPitchScaleFactor = transform.maxPitchScaleFactor();\n const tilesIn = sourceCache.tilesIn(queryGeometry, maxPitchScaleFactor, has3DLayer);\n\n tilesIn.sort(sortTilesIn);\n const renderedFeatureLayers = [];\n for (const tileIn of tilesIn) {\n renderedFeatureLayers.push({\n wrappedTileID: tileIn.tileID.wrapped().key,\n queryResults: tileIn.tile.queryRenderedFeatures(\n styleLayers,\n serializedLayers,\n sourceCache._state,\n tileIn.queryGeometry,\n tileIn.cameraQueryGeometry,\n tileIn.scale,\n params,\n transform,\n maxPitchScaleFactor,\n getPixelPosMatrix(sourceCache.transform, tileIn.tileID))\n });\n }\n\n const result = mergeRenderedFeatureLayers(renderedFeatureLayers);\n\n // Merge state from SourceCache into the results\n for (const layerID in result) {\n result[layerID].forEach((featureWrapper) => {\n const feature = featureWrapper.feature as MapGeoJSONFeature;\n const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id);\n feature.source = feature.layer.source;\n if (feature.layer['source-layer']) {\n feature.sourceLayer = feature.layer['source-layer'];\n }\n feature.state = state;\n });\n }\n return result;\n}\n\nexport function queryRenderedSymbols(styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: StyleLayer},\n sourceCaches: {[_: string]: SourceCache},\n queryGeometry: Array,\n params: QueryRenderedFeaturesOptions,\n collisionIndex: CollisionIndex,\n retainedQueryData: {\n [_: number]: RetainedQueryData;\n }) {\n const result = {};\n const renderedSymbols = collisionIndex.queryRenderedSymbols(queryGeometry);\n const bucketQueryData = [];\n for (const bucketInstanceId of Object.keys(renderedSymbols).map(Number)) {\n bucketQueryData.push(retainedQueryData[bucketInstanceId]);\n }\n bucketQueryData.sort(sortTilesIn);\n\n for (const queryData of bucketQueryData) {\n const bucketSymbols = queryData.featureIndex.lookupSymbolFeatures(\n renderedSymbols[queryData.bucketInstanceId],\n serializedLayers,\n queryData.bucketIndex,\n queryData.sourceLayerIndex,\n params.filter,\n params.layers,\n params.availableImages,\n styleLayers);\n\n for (const layerID in bucketSymbols) {\n const resultFeatures = result[layerID] = result[layerID] || [];\n const layerSymbols = bucketSymbols[layerID];\n layerSymbols.sort((a, b) => {\n // Match topDownFeatureComparator from FeatureIndex, but using\n // most recent sorting of features from bucket.sortFeatures\n const featureSortOrder = queryData.featureSortOrder;\n if (featureSortOrder) {\n // queryRenderedSymbols documentation says we'll return features in\n // \"top-to-bottom\" rendering order (aka last-to-first).\n // Actually there can be multiple symbol instances per feature, so\n // we sort each feature based on the first matching symbol instance.\n const sortedA = featureSortOrder.indexOf(a.featureIndex);\n const sortedB = featureSortOrder.indexOf(b.featureIndex);\n return sortedB - sortedA;\n } else {\n // Bucket hasn't been re-sorted based on angle, so use the\n // reverse of the order the features appeared in the data.\n return b.featureIndex - a.featureIndex;\n }\n });\n for (const symbolFeature of layerSymbols) {\n resultFeatures.push(symbolFeature);\n }\n }\n }\n\n // Merge state from SourceCache into the results\n for (const layerName in result) {\n result[layerName].forEach((featureWrapper) => {\n const feature = featureWrapper.feature;\n const layer = styleLayers[layerName];\n const sourceCache = sourceCaches[layer.source];\n const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id);\n feature.source = feature.layer.source;\n if (feature.layer['source-layer']) {\n feature.sourceLayer = feature.layer['source-layer'];\n }\n feature.state = state;\n });\n }\n return result;\n}\n\nexport function querySourceFeatures(sourceCache: SourceCache, params: QuerySourceFeatureOptions) {\n const tiles = sourceCache.getRenderableIds().map((id) => {\n return sourceCache.getTileByID(id);\n });\n\n const result = [];\n\n const dataTiles = {};\n for (let i = 0; i < tiles.length; i++) {\n const tile = tiles[i];\n const dataID = tile.tileID.canonical.key;\n if (!dataTiles[dataID]) {\n dataTiles[dataID] = true;\n tile.querySourceFeatures(result, params);\n }\n }\n\n return result;\n}\n\nfunction sortTilesIn(a, b) {\n const idA = a.tileID;\n const idB = b.tileID;\n return (idA.overscaledZ - idB.overscaledZ) || (idA.canonical.y - idB.canonical.y) || (idA.wrap - idB.wrap) || (idA.canonical.x - idB.canonical.x);\n}\n\nfunction mergeRenderedFeatureLayers(tiles) {\n // Merge results from all tiles, but if two tiles share the same\n // wrapped ID, don't duplicate features between the two tiles\n const result = {};\n const wrappedIDLayerMap = {};\n for (const tile of tiles) {\n const queryResults = tile.queryResults;\n const wrappedID = tile.wrappedTileID;\n const wrappedIDLayers = wrappedIDLayerMap[wrappedID] = wrappedIDLayerMap[wrappedID] || {};\n for (const layerID in queryResults) {\n const tileFeatures = queryResults[layerID];\n const wrappedIDFeatures = wrappedIDLayers[layerID] = wrappedIDLayers[layerID] || {};\n const resultFeatures = result[layerID] = result[layerID] || [];\n for (const tileFeature of tileFeatures) {\n if (!wrappedIDFeatures[tileFeature.featureIndex]) {\n wrappedIDFeatures[tileFeature.featureIndex] = true;\n resultFeatures.push(tileFeature);\n }\n }\n }\n }\n return result;\n}\n","import type {CollisionBoxArray} from './array_types.g';\nimport type {Style} from '../style/style';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {FeatureIndex} from './feature_index';\nimport type {Context} from '../gl/context';\nimport type {FeatureStates} from '../source/source_state';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\nimport Point from '@mapbox/point-geometry';\n\nexport type BucketParameters = {\n index: number;\n layers: Array;\n zoom: number;\n pixelRatio: number;\n overscaling: number;\n collisionBoxArray: CollisionBoxArray;\n sourceLayerIndex: number;\n sourceID: string;\n};\n\nexport type PopulateParameters = {\n featureIndex: FeatureIndex;\n iconDependencies: {};\n patternDependencies: {};\n glyphDependencies: {};\n availableImages: Array;\n};\n\nexport type IndexedFeature = {\n feature: VectorTileFeature;\n id: number | string;\n index: number;\n sourceLayerIndex: number;\n};\n\nexport type BucketFeature = {\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 0 | 1 | 2 | 3;\n id?: any;\n readonly patterns: {\n [_: string]: {\n 'min': string;\n 'mid': string;\n 'max': string;\n };\n };\n sortKey?: number;\n};\n\n/**\n * The `Bucket` interface is the single point of knowledge about turning vector\n * tiles into WebGL buffers.\n *\n * `Bucket` is an abstract interface. An implementation exists for each style layer type.\n * Create a bucket via the `StyleLayer#createBucket` method.\n *\n * The concrete bucket types, using layout options from the style layer,\n * transform feature geometries into vertex and index data for use by the\n * vertex shader. They also (via `ProgramConfiguration`) use feature\n * properties and the zoom level to populate the attributes needed for\n * data-driven styling.\n *\n * Buckets are designed to be built on a worker thread and then serialized and\n * transferred back to the main thread for rendering. On the worker side, a\n * bucket's vertex, index, and attribute data is stored in `bucket.arrays: ArrayGroup`.\n * When a bucket's data is serialized and sent back to the main thread,\n * is gets deserialized (using `new Bucket(serializedBucketData)`, with\n * the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups\n * hold the same data as ArrayGroups, but are tuned for consumption by WebGL.\n */\nexport interface Bucket {\n layerIds: Array;\n hasPattern: boolean;\n readonly layers: Array;\n readonly stateDependentLayers: Array;\n readonly stateDependentLayerIds: Array;\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void;\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}): void;\n isEmpty(): boolean;\n upload(context: Context): void;\n uploadPending(): boolean;\n /**\n * Release the WebGL resources associated with the buffers. Note that because\n * buckets are shared between layers having the same layout properties, they\n * must be destroyed in groups (all buckets for a tile, or all symbol buckets).\n */\n destroy(): void;\n}\n\nexport function deserialize(input: Array, style: Style): {[_: string]: Bucket} {\n const output = {};\n\n // Guard against the case where the map's style has been set to null while\n // this bucket has been parsing.\n if (!style) return output;\n\n for (const bucket of input) {\n const layers = bucket.layerIds\n .map((id) => style.getLayer(id))\n .filter(Boolean);\n\n if (layers.length === 0) {\n continue;\n }\n\n // look up StyleLayer objects from layer ids (since we don't\n // want to waste time serializing/copying them from the worker)\n (bucket as any).layers = layers;\n if (bucket.stateDependentLayerIds) {\n (bucket as any).stateDependentLayers = bucket.stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]);\n }\n for (const layer of layers) {\n output[layer.id] = bucket;\n }\n }\n\n return output;\n}\n","import {uniqueId, parseCacheControl} from '../util/util';\nimport {deserialize as deserializeBucket} from '../data/bucket';\nimport '../data/feature_index';\nimport type {FeatureIndex} from '../data/feature_index';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {CollisionBoxArray} from '../data/array_types.g';\nimport {Texture} from '../render/texture';\nimport {browser} from '../util/browser';\nimport {toEvaluationFeature} from '../data/evaluation_feature';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {lazyLoadRTLTextPlugin} from './rtl_text_plugin';\n\nconst CLOCK_SKEW_RETRY_TIMEOUT = 30000;\n\nimport type {Bucket} from '../data/bucket';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {WorkerTileResult} from './worker_source';\nimport type {Actor} from '../util/actor';\nimport type {DEMData} from '../data/dem_data';\nimport type {AlphaImage} from '../util/image';\nimport type {ImageAtlas} from '../render/image_atlas';\nimport type {ImageManager} from '../render/image_manager';\nimport type {Context} from '../gl/context';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Framebuffer} from '../gl/framebuffer';\nimport type {Transform} from '../geo/transform';\nimport type {LayerFeatureStates} from './source_state';\nimport type {Cancelable} from '../types/cancelable';\nimport type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type Point from '@mapbox/point-geometry';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\nimport {ExpiryData} from '../util/ajax';\n\n/**\n * The tile's state, can be:\n * - `loading` Tile data is in the process of loading.\n * - `loaded` Tile data has been loaded. Tile can be rendered.\n * - `reloading` Tile data has been loaded and is being updated. Tile can be rendered.\n * - `unloaded` Tile data has been deleted.\n * - `errored` Tile data was not loaded because of an error.\n * - `expired` Tile data was previously loaded, but has expired per its HTTP headers and is in the process of refreshing.\n */\nexport type TileState = 'loading' | 'loaded' | 'reloading' | 'unloaded' | 'errored' | 'expired';\n\n/**\n * @internal\n * A tile object is the combination of a Coordinate, which defines\n * its place, as well as a unique ID and data tracking for its content\n */\nexport class Tile {\n tileID: OverscaledTileID;\n uid: number;\n uses: number;\n tileSize: number;\n buckets: {[_: string]: Bucket};\n latestFeatureIndex: FeatureIndex;\n latestRawTileData: ArrayBuffer;\n imageAtlas: ImageAtlas;\n imageAtlasTexture: Texture;\n glyphAtlasImage: AlphaImage;\n glyphAtlasTexture: Texture;\n expirationTime: any;\n expiredRequestCount: number;\n state: TileState;\n timeAdded: number = 0;\n fadeEndTime: number = 0;\n collisionBoxArray: CollisionBoxArray;\n redoWhenDone: boolean;\n showCollisionBoxes: boolean;\n placementSource: any;\n actor: Actor;\n vtLayers: {[_: string]: VectorTileLayer};\n\n neighboringTiles: any;\n dem: DEMData;\n demMatrix: mat4;\n aborted: boolean;\n needsHillshadePrepare: boolean;\n needsTerrainPrepare: boolean;\n request: Cancelable;\n texture: any;\n fbo: Framebuffer;\n demTexture: Texture;\n refreshedUponExpiration: boolean;\n reloadCallback: any;\n resourceTiming: Array;\n queryPadding: number;\n\n symbolFadeHoldUntil: number;\n hasSymbolBuckets: boolean;\n hasRTLText: boolean;\n dependencies: any;\n rtt: Array<{id: number; stamp: number}>;\n rttCoords: {[_:string]: string};\n\n /**\n * @param tileID - the tile ID\n * @param size - The tile size\n */\n constructor(tileID: OverscaledTileID, size: number) {\n this.tileID = tileID;\n this.uid = uniqueId();\n this.uses = 0;\n this.tileSize = size;\n this.buckets = {};\n this.expirationTime = null;\n this.queryPadding = 0;\n this.hasSymbolBuckets = false;\n this.hasRTLText = false;\n this.dependencies = {};\n this.rtt = [];\n this.rttCoords = {};\n\n // Counts the number of times a response was already expired when\n // received. We're using this to add a delay when making a new request\n // so we don't have to keep retrying immediately in case of a server\n // serving expired tiles.\n this.expiredRequestCount = 0;\n\n this.state = 'loading';\n }\n\n registerFadeDuration(duration: number) {\n const fadeEndTime = duration + this.timeAdded;\n\n if (fadeEndTime < this.fadeEndTime) {\n return;\n }\n\n this.fadeEndTime = fadeEndTime;\n }\n\n wasRequested() {\n return this.state === 'errored' || this.state === 'loaded' || this.state === 'reloading';\n }\n\n clearTextures(painter: any) {\n if (this.demTexture) painter.saveTileTexture(this.demTexture);\n this.demTexture = null;\n }\n\n /**\n * Given a data object with a 'buffers' property, load it into\n * this tile's elementGroups and buffers properties and set loaded\n * to true. If the data is null, like in the case of an empty\n * GeoJSON tile, no-op but still set loaded to true.\n * @param data - The data from the worker\n * @param painter - the painter\n * @param justReloaded - `true` to just reload\n */\n loadVectorData(data: WorkerTileResult, painter: any, justReloaded?: boolean | null) {\n if (this.hasData()) {\n this.unloadVectorData();\n }\n\n this.state = 'loaded';\n\n // empty GeoJSON tile\n if (!data) {\n this.collisionBoxArray = new CollisionBoxArray();\n return;\n }\n\n if (data.featureIndex) {\n this.latestFeatureIndex = data.featureIndex;\n if (data.rawTileData) {\n // Only vector tiles have rawTileData, and they won't update it for\n // 'reloadTile'\n this.latestRawTileData = data.rawTileData;\n this.latestFeatureIndex.rawTileData = data.rawTileData;\n } else if (this.latestRawTileData) {\n // If rawTileData hasn't updated, hold onto a pointer to the last\n // one we received\n this.latestFeatureIndex.rawTileData = this.latestRawTileData;\n }\n }\n this.collisionBoxArray = data.collisionBoxArray;\n this.buckets = deserializeBucket(data.buckets, painter.style);\n\n this.hasSymbolBuckets = false;\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket instanceof SymbolBucket) {\n this.hasSymbolBuckets = true;\n if (justReloaded) {\n bucket.justReloaded = true;\n } else {\n break;\n }\n }\n }\n\n this.hasRTLText = false;\n if (this.hasSymbolBuckets) {\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket instanceof SymbolBucket) {\n if (bucket.hasRTLText) {\n this.hasRTLText = true;\n lazyLoadRTLTextPlugin();\n break;\n }\n }\n }\n }\n\n this.queryPadding = 0;\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(id).queryRadius(bucket));\n }\n\n if (data.imageAtlas) {\n this.imageAtlas = data.imageAtlas;\n }\n if (data.glyphAtlasImage) {\n this.glyphAtlasImage = data.glyphAtlasImage;\n }\n }\n\n /**\n * Release any data or WebGL resources referenced by this tile.\n */\n unloadVectorData() {\n for (const id in this.buckets) {\n this.buckets[id].destroy();\n }\n this.buckets = {};\n\n if (this.imageAtlasTexture) {\n this.imageAtlasTexture.destroy();\n }\n\n if (this.imageAtlas) {\n this.imageAtlas = null;\n }\n\n if (this.glyphAtlasTexture) {\n this.glyphAtlasTexture.destroy();\n }\n\n this.latestFeatureIndex = null;\n this.state = 'unloaded';\n }\n\n getBucket(layer: StyleLayer) {\n return this.buckets[layer.id];\n }\n\n upload(context: Context) {\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket.uploadPending()) {\n bucket.upload(context);\n }\n }\n\n const gl = context.gl;\n if (this.imageAtlas && !this.imageAtlas.uploaded) {\n this.imageAtlasTexture = new Texture(context, this.imageAtlas.image, gl.RGBA);\n this.imageAtlas.uploaded = true;\n }\n\n if (this.glyphAtlasImage) {\n this.glyphAtlasTexture = new Texture(context, this.glyphAtlasImage, gl.ALPHA);\n this.glyphAtlasImage = null;\n }\n }\n\n prepare(imageManager: ImageManager) {\n if (this.imageAtlas) {\n this.imageAtlas.patchUpdatedImages(imageManager, this.imageAtlasTexture);\n }\n }\n\n // Queries non-symbol features rendered for this tile.\n // Symbol features are queried globally\n queryRenderedFeatures(\n layers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState,\n queryGeometry: Array,\n cameraQueryGeometry: Array,\n scale: number,\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n },\n transform: Transform,\n maxPitchScaleFactor: number,\n pixelPosMatrix: mat4\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData)\n return {};\n\n return this.latestFeatureIndex.query({\n queryGeometry,\n cameraQueryGeometry,\n scale,\n tileSize: this.tileSize,\n pixelPosMatrix,\n transform,\n params,\n queryPadding: this.queryPadding * maxPitchScaleFactor\n }, layers, serializedLayers, sourceFeatureState);\n }\n\n querySourceFeatures(result: Array, params?: {\n sourceLayer?: string;\n filter?: FilterSpecification;\n validate?: boolean;\n }) {\n const featureIndex = this.latestFeatureIndex;\n if (!featureIndex || !featureIndex.rawTileData) return;\n\n const vtLayers = featureIndex.loadVTLayers();\n\n const sourceLayer = params && params.sourceLayer ? params.sourceLayer : '';\n const layer = vtLayers._geojsonTileLayer || vtLayers[sourceLayer];\n\n if (!layer) return;\n\n const filter = featureFilter(params && params.filter);\n const {z, x, y} = this.tileID.canonical;\n const coord = {z, x, y};\n\n for (let i = 0; i < layer.length; i++) {\n const feature = layer.feature(i);\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) continue;\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n continue;\n }\n const id = featureIndex.getId(feature, sourceLayer);\n const geojsonFeature = new GeoJSONFeature(feature, z, x, y, id);\n (geojsonFeature as any).tile = coord;\n result.push(geojsonFeature);\n }\n }\n\n hasData() {\n return this.state === 'loaded' || this.state === 'reloading' || this.state === 'expired';\n }\n\n patternsLoaded() {\n return this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;\n }\n\n setExpiryData(data: ExpiryData) {\n const prior = this.expirationTime;\n\n if (data.cacheControl) {\n const parsedCC = parseCacheControl(data.cacheControl);\n if (parsedCC['max-age']) this.expirationTime = Date.now() + parsedCC['max-age'] * 1000;\n } else if (data.expires) {\n this.expirationTime = new Date(data.expires).getTime();\n }\n\n if (this.expirationTime) {\n const now = Date.now();\n let isExpired = false;\n\n if (this.expirationTime > now) {\n isExpired = false;\n } else if (!prior) {\n isExpired = true;\n } else if (this.expirationTime < prior) {\n // Expiring date is going backwards:\n // fall back to exponential backoff\n isExpired = true;\n\n } else {\n const delta = this.expirationTime - prior;\n\n if (!delta) {\n // Server is serving the same expired resource over and over: fall\n // back to exponential backoff.\n isExpired = true;\n\n } else {\n // Assume that either the client or the server clock is wrong and\n // try to interpolate a valid expiration date (from the client POV)\n // observing a minimum timeout.\n this.expirationTime = now + Math.max(delta, CLOCK_SKEW_RETRY_TIMEOUT);\n\n }\n }\n\n if (isExpired) {\n this.expiredRequestCount++;\n this.state = 'expired';\n } else {\n this.expiredRequestCount = 0;\n }\n }\n }\n\n getExpiryTimeout() {\n if (this.expirationTime) {\n if (this.expiredRequestCount) {\n return 1000 * (1 << Math.min(this.expiredRequestCount - 1, 31));\n } else {\n // Max value for `setTimeout` implementations is a 32 bit integer; cap this accordingly\n return Math.min(this.expirationTime - new Date().getTime(), Math.pow(2, 31) - 1);\n }\n }\n }\n\n setFeatureState(states: LayerFeatureStates, painter: any) {\n if (!this.latestFeatureIndex ||\n !this.latestFeatureIndex.rawTileData ||\n Object.keys(states).length === 0) {\n return;\n }\n\n const vtLayers = this.latestFeatureIndex.loadVTLayers();\n\n for (const id in this.buckets) {\n if (!painter.style.hasLayer(id)) continue;\n\n const bucket = this.buckets[id];\n // Buckets are grouped by common source-layer\n const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer';\n const sourceLayer = vtLayers[sourceLayerId];\n const sourceLayerStates = states[sourceLayerId];\n if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) continue;\n\n bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {});\n const layer = painter && painter.style && painter.style.getLayer(id);\n if (layer) {\n this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket));\n }\n }\n }\n\n holdingForFade(): boolean {\n return this.symbolFadeHoldUntil !== undefined;\n }\n\n symbolFadeFinished(): boolean {\n return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < browser.now();\n }\n\n clearFadeHold() {\n this.symbolFadeHoldUntil = undefined;\n }\n\n setHoldDuration(duration: number) {\n this.symbolFadeHoldUntil = browser.now() + duration;\n }\n\n setDependencies(namespace: string, dependencies: Array) {\n const index = {};\n for (const dep of dependencies) {\n index[dep] = true;\n }\n this.dependencies[namespace] = index;\n }\n\n hasDependency(namespaces: Array, keys: Array) {\n for (const namespace of namespaces) {\n const dependencies = this.dependencies[namespace];\n if (dependencies) {\n for (const key of keys) {\n if (dependencies[key]) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}\n","import {OverscaledTileID} from './tile_id';\nimport type {Tile} from './tile';\n\n/**\n * @internal\n * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms)\n * with hash lookup made possible by keeping a list of keys in parallel to\n * an array of dictionary of values\n */\nexport class TileCache {\n max: number;\n data: {\n [key: string]: Array<{\n value: Tile;\n timeout: ReturnType;\n }>;\n };\n order: Array;\n onRemove: (element: Tile) => void;\n /**\n * @param max - number of permitted values\n * @param onRemove - callback called with items when they expire\n */\n constructor(max: number, onRemove: (element: Tile) => void) {\n this.max = max;\n this.onRemove = onRemove;\n this.reset();\n }\n\n /**\n * Clear the cache\n *\n * @returns this cache\n */\n reset() {\n for (const key in this.data) {\n for (const removedData of this.data[key]) {\n if (removedData.timeout) clearTimeout(removedData.timeout);\n this.onRemove(removedData.value);\n }\n }\n\n this.data = {};\n this.order = [];\n\n return this;\n }\n\n /**\n * Add a key, value combination to the cache, trimming its size if this pushes\n * it over max length.\n *\n * @param tileID - lookup key for the item\n * @param data - tile data\n *\n * @returns this cache\n */\n add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void) {\n const key = tileID.wrapped().key;\n if (this.data[key] === undefined) {\n this.data[key] = [];\n }\n\n const dataWrapper = {\n value: data,\n timeout: undefined\n };\n\n if (expiryTimeout !== undefined) {\n dataWrapper.timeout = setTimeout(() => {\n this.remove(tileID, dataWrapper);\n }, expiryTimeout as number);\n }\n\n this.data[key].push(dataWrapper);\n this.order.push(key);\n\n if (this.order.length > this.max) {\n const removedData = this._getAndRemoveByKey(this.order[0]);\n if (removedData) this.onRemove(removedData);\n }\n\n return this;\n }\n\n /**\n * Determine whether the value attached to `key` is present\n *\n * @param tileID - the key to be looked-up\n * @returns whether the cache has this value\n */\n has(tileID: OverscaledTileID): boolean {\n return tileID.wrapped().key in this.data;\n }\n\n /**\n * Get the value attached to a specific key and remove data from cache.\n * If the key is not found, returns `null`\n *\n * @param tileID - the key to look up\n * @returns the tile data, or null if it isn't found\n */\n getAndRemove(tileID: OverscaledTileID): Tile {\n if (!this.has(tileID)) { return null; }\n return this._getAndRemoveByKey(tileID.wrapped().key);\n }\n\n /*\n * Get and remove the value with the specified key.\n */\n _getAndRemoveByKey(key: string): Tile {\n const data = this.data[key].shift();\n if (data.timeout) clearTimeout(data.timeout);\n\n if (this.data[key].length === 0) {\n delete this.data[key];\n }\n this.order.splice(this.order.indexOf(key), 1);\n\n return data.value;\n }\n\n /*\n * Get the value with the specified (wrapped tile) key.\n */\n getByKey(key: string): Tile {\n const data = this.data[key];\n return data ? data[0].value : null;\n }\n\n /**\n * Get the value attached to a specific key without removing data\n * from the cache. If the key is not found, returns `null`\n *\n * @param tileID - the key to look up\n * @returns the tile data, or null if it isn't found\n */\n get(tileID: OverscaledTileID): Tile {\n if (!this.has(tileID)) { return null; }\n\n const data = this.data[tileID.wrapped().key][0];\n return data.value;\n }\n\n /**\n * Remove a key/value combination from the cache.\n *\n * @param tileID - the key for the pair to delete\n * @param value - If a value is provided, remove that exact version of the value.\n * @returns this cache\n */\n remove(tileID: OverscaledTileID, value?: {\n value: Tile;\n timeout: ReturnType;\n }) {\n if (!this.has(tileID)) { return this; }\n const key = tileID.wrapped().key;\n\n const dataIndex = value === undefined ? 0 : this.data[key].indexOf(value);\n const data = this.data[key][dataIndex];\n this.data[key].splice(dataIndex, 1);\n if (data.timeout) clearTimeout(data.timeout);\n if (this.data[key].length === 0) {\n delete this.data[key];\n }\n this.onRemove(data.value);\n this.order.splice(this.order.indexOf(key), 1);\n\n return this;\n }\n\n /**\n * Change the max size of the cache.\n *\n * @param max - the max size of the cache\n * @returns this cache\n */\n setMaxSize(max: number): TileCache {\n this.max = max;\n\n while (this.order.length > this.max) {\n const removedData = this._getAndRemoveByKey(this.order[0]);\n if (removedData) this.onRemove(removedData);\n }\n\n return this;\n }\n\n /**\n * Remove entries that do not pass a filter function. Used for removing\n * stale tiles from the cache.\n *\n * @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out.\n */\n filter(filterFn: (tile: Tile) => boolean) {\n const removed = [];\n for (const key in this.data) {\n for (const entry of this.data[key]) {\n if (!filterFn(entry.value)) {\n removed.push(entry);\n }\n }\n }\n for (const r of removed) {\n this.remove(r.value.tileID, r);\n }\n }\n}\n","import {extend} from '../util/util';\nimport {Tile} from './tile';\nimport type {FeatureState} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FeatureStates = {[featureId: string]: FeatureState};\nexport type LayerFeatureStates = {[layer: string]: FeatureStates};\n\n/**\n * @internal\n * SourceFeatureState manages the state and pending changes\n * to features in a source, separated by source layer.\n * stateChanges and deletedStates batch all changes to the tile (updates and removes, respectively)\n * between coalesce() events. addFeatureState() and removeFeatureState() also update their counterpart's\n * list of changes, such that coalesce() can apply the proper state changes while agnostic to the order of operations.\n * In deletedStates, all null's denote complete removal of state at that scope\n*/\nexport class SourceFeatureState {\n state: LayerFeatureStates;\n stateChanges: LayerFeatureStates;\n deletedStates: {};\n\n constructor() {\n this.state = {};\n this.stateChanges = {};\n this.deletedStates = {};\n }\n\n updateState(sourceLayer: string, featureId: number | string, newState: any) {\n const feature = String(featureId);\n this.stateChanges[sourceLayer] = this.stateChanges[sourceLayer] || {};\n this.stateChanges[sourceLayer][feature] = this.stateChanges[sourceLayer][feature] || {};\n extend(this.stateChanges[sourceLayer][feature], newState);\n\n if (this.deletedStates[sourceLayer] === null) {\n this.deletedStates[sourceLayer] = {};\n for (const ft in this.state[sourceLayer]) {\n if (ft !== feature) this.deletedStates[sourceLayer][ft] = null;\n }\n } else {\n const featureDeletionQueued = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] === null;\n if (featureDeletionQueued) {\n this.deletedStates[sourceLayer][feature] = {};\n for (const prop in this.state[sourceLayer][feature]) {\n if (!newState[prop]) this.deletedStates[sourceLayer][feature][prop] = null;\n }\n } else {\n for (const key in newState) {\n const deletionInQueue = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] && this.deletedStates[sourceLayer][feature][key] === null;\n if (deletionInQueue) delete this.deletedStates[sourceLayer][feature][key];\n }\n }\n }\n }\n\n removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string) {\n const sourceLayerDeleted = this.deletedStates[sourceLayer] === null;\n if (sourceLayerDeleted) return;\n\n const feature = String(featureId);\n\n this.deletedStates[sourceLayer] = this.deletedStates[sourceLayer] || {};\n\n if (key && featureId !== undefined) {\n if (this.deletedStates[sourceLayer][feature] !== null) {\n this.deletedStates[sourceLayer][feature] = this.deletedStates[sourceLayer][feature] || {};\n this.deletedStates[sourceLayer][feature][key] = null;\n }\n } else if (featureId !== undefined) {\n const updateInQueue = this.stateChanges[sourceLayer] && this.stateChanges[sourceLayer][feature];\n if (updateInQueue) {\n this.deletedStates[sourceLayer][feature] = {};\n for (key in this.stateChanges[sourceLayer][feature]) this.deletedStates[sourceLayer][feature][key] = null;\n\n } else {\n this.deletedStates[sourceLayer][feature] = null;\n }\n } else {\n this.deletedStates[sourceLayer] = null;\n }\n\n }\n\n getState(sourceLayer: string, featureId: number | string) {\n const feature = String(featureId);\n const base = this.state[sourceLayer] || {};\n const changes = this.stateChanges[sourceLayer] || {};\n\n const reconciledState = extend({}, base[feature], changes[feature]);\n\n //return empty object if the whole source layer is awaiting deletion\n if (this.deletedStates[sourceLayer] === null) return {};\n else if (this.deletedStates[sourceLayer]) {\n const featureDeletions = this.deletedStates[sourceLayer][featureId];\n if (featureDeletions === null) return {};\n for (const prop in featureDeletions) delete reconciledState[prop];\n }\n return reconciledState;\n }\n\n initializeTileState(tile: Tile, painter: any) {\n tile.setFeatureState(this.state, painter);\n }\n\n coalesceChanges(tiles: {\n [_ in any]: Tile;\n }, painter: any) {\n //track changes with full state objects, but only for features that got modified\n const featuresChanged: LayerFeatureStates = {};\n\n for (const sourceLayer in this.stateChanges) {\n this.state[sourceLayer] = this.state[sourceLayer] || {};\n const layerStates = {};\n for (const feature in this.stateChanges[sourceLayer]) {\n if (!this.state[sourceLayer][feature]) this.state[sourceLayer][feature] = {};\n extend(this.state[sourceLayer][feature], this.stateChanges[sourceLayer][feature]);\n layerStates[feature] = this.state[sourceLayer][feature];\n }\n featuresChanged[sourceLayer] = layerStates;\n }\n\n for (const sourceLayer in this.deletedStates) {\n this.state[sourceLayer] = this.state[sourceLayer] || {};\n const layerStates = {};\n\n if (this.deletedStates[sourceLayer] === null) {\n for (const ft in this.state[sourceLayer]) {\n layerStates[ft] = {};\n this.state[sourceLayer][ft] = {};\n }\n } else {\n for (const feature in this.deletedStates[sourceLayer]) {\n const deleteWholeFeatureState = this.deletedStates[sourceLayer][feature] === null;\n if (deleteWholeFeatureState) this.state[sourceLayer][feature] = {};\n else {\n for (const key of Object.keys(this.deletedStates[sourceLayer][feature])) {\n delete this.state[sourceLayer][feature][key];\n }\n }\n layerStates[feature] = this.state[sourceLayer][feature];\n }\n }\n\n featuresChanged[sourceLayer] = featuresChanged[sourceLayer] || {};\n extend(featuresChanged[sourceLayer], layerStates);\n }\n\n this.stateChanges = {};\n this.deletedStates = {};\n\n if (Object.keys(featuresChanged).length === 0) return;\n\n for (const id in tiles) {\n const tile = tiles[id];\n tile.setFeatureState(featuresChanged, painter);\n }\n }\n}\n","import {create as createSource} from './source';\n\nimport {Tile} from './tile';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {TileCache} from './tile_cache';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {keysDifference} from '../util/util';\nimport {EXTENT} from '../data/extent';\nimport {Context} from '../gl/context';\nimport Point from '@mapbox/point-geometry';\nimport {browser} from '../util/browser';\nimport {OverscaledTileID} from './tile_id';\nimport {SourceFeatureState} from './source_state';\n\nimport type {Source} from './source';\nimport type {Map} from '../ui/map';\nimport type {Style} from '../style/style';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Transform} from '../geo/transform';\nimport type {TileState} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {MapSourceDataEvent} from '../ui/events';\nimport {Terrain} from '../render/terrain';\nimport {config} from '../util/config';\n\n/**\n * @internal\n * `SourceCache` is responsible for\n *\n * - creating an instance of `Source`\n * - forwarding events from `Source`\n * - caching tiles loaded from an instance of `Source`\n * - loading the tiles needed to render a given viewport\n * - unloading the cached tiles not needed to render a given viewport\n */\nexport class SourceCache extends Evented {\n id: string;\n dispatcher: Dispatcher;\n map: Map;\n style: Style;\n\n _source: Source;\n _sourceLoaded: boolean;\n _sourceErrored: boolean;\n _tiles: {[_: string]: Tile};\n _prevLng: number;\n _cache: TileCache;\n _timers: {\n [_ in any]: ReturnType;\n };\n _cacheTimers: {\n [_ in any]: ReturnType;\n };\n _maxTileCacheSize: number;\n _maxTileCacheZoomLevels: number;\n _paused: boolean;\n _shouldReloadOnResume: boolean;\n _coveredTiles: {[_: string]: boolean};\n transform: Transform;\n terrain: Terrain;\n used: boolean;\n usedForTerrain: boolean;\n tileSize: number;\n _state: SourceFeatureState;\n _loadedParentTiles: {[_: string]: Tile};\n _didEmitContent: boolean;\n _updated: boolean;\n\n static maxUnderzooming: number;\n static maxOverzooming: number;\n\n constructor(id: string, options: SourceSpecification, dispatcher: Dispatcher) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n\n this.on('data', (e: MapSourceDataEvent) => {\n // this._sourceLoaded signifies that the TileJSON is loaded if applicable.\n // if the source type does not come with a TileJSON, the flag signifies the\n // source data has loaded (i.e geojson has been tiled on the worker and is ready)\n if (e.dataType === 'source' && e.sourceDataType === 'metadata') this._sourceLoaded = true;\n\n // for sources with mutable data, this event fires when the underlying data\n // to a source is changed. (i.e. GeoJSONSource#setData and ImageSource#serCoordinates)\n if (this._sourceLoaded && !this._paused && e.dataType === 'source' && e.sourceDataType === 'content') {\n this.reload();\n if (this.transform) {\n this.update(this.transform, this.terrain);\n }\n\n this._didEmitContent = true;\n }\n });\n\n this.on('dataloading', () => {\n this._sourceErrored = false;\n });\n\n this.on('error', () => {\n // Only set _sourceErrored if the source does not have pending loads.\n this._sourceErrored = this._source.loaded();\n });\n\n this._source = createSource(id, options, dispatcher, this);\n\n this._tiles = {};\n this._cache = new TileCache(0, this._unloadTile.bind(this));\n this._timers = {};\n this._cacheTimers = {};\n this._maxTileCacheSize = null;\n this._maxTileCacheZoomLevels = null;\n this._loadedParentTiles = {};\n\n this._coveredTiles = {};\n this._state = new SourceFeatureState();\n this._didEmitContent = false;\n this._updated = false;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this._maxTileCacheSize = map ? map._maxTileCacheSize : null;\n this._maxTileCacheZoomLevels = map ? map._maxTileCacheZoomLevels : null;\n if (this._source && this._source.onAdd) {\n this._source.onAdd(map);\n }\n }\n\n onRemove(map: Map) {\n this.clearTiles();\n if (this._source && this._source.onRemove) {\n this._source.onRemove(map);\n }\n }\n\n /**\n * Return true if no tile data is pending, tiles will not change unless\n * an additional API call is received.\n */\n loaded(): boolean {\n if (this._sourceErrored) { return true; }\n if (!this._sourceLoaded) { return false; }\n if (!this._source.loaded()) { return false; }\n if ((this.used !== undefined || this.usedForTerrain !== undefined) && !this.used && !this.usedForTerrain) { return true; }\n // do not consider as loaded if the update hasn't been called yet (we do not know if we will have any tiles to fetch)\n if (!this._updated) { return false; }\n\n for (const t in this._tiles) {\n const tile = this._tiles[t];\n if (tile.state !== 'loaded' && tile.state !== 'errored')\n return false;\n }\n return true;\n }\n\n getSource(): Source {\n return this._source;\n }\n\n pause() {\n this._paused = true;\n }\n\n resume() {\n if (!this._paused) return;\n const shouldReload = this._shouldReloadOnResume;\n this._paused = false;\n this._shouldReloadOnResume = false;\n if (shouldReload) this.reload();\n if (this.transform) this.update(this.transform, this.terrain);\n }\n\n _loadTile(tile: Tile, callback: Callback) {\n return this._source.loadTile(tile, callback);\n }\n\n _unloadTile(tile: Tile) {\n if (this._source.unloadTile)\n return this._source.unloadTile(tile, () => {});\n }\n\n _abortTile(tile: Tile) {\n if (this._source.abortTile)\n this._source.abortTile(tile, () => {});\n\n this._source.fire(new Event('dataabort', {tile, coord: tile.tileID, dataType: 'source'}));\n }\n\n serialize() {\n return this._source.serialize();\n }\n\n prepare(context: Context) {\n if (this._source.prepare) {\n this._source.prepare();\n }\n\n this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null);\n for (const i in this._tiles) {\n const tile = this._tiles[i];\n tile.upload(context);\n tile.prepare(this.map.style.imageManager);\n }\n }\n\n /**\n * Return all tile ids ordered with z-order, and cast to numbers\n */\n getIds(): Array {\n return (Object.values(this._tiles) as any).map((tile: Tile) => tile.tileID).sort(compareTileId).map(id => id.key);\n }\n\n getRenderableIds(symbolLayer?: boolean): Array {\n const renderables: Array = [];\n for (const id in this._tiles) {\n if (this._isIdRenderable(id, symbolLayer)) renderables.push(this._tiles[id]);\n }\n if (symbolLayer) {\n return renderables.sort((a_: Tile, b_: Tile) => {\n const a = a_.tileID;\n const b = b_.tileID;\n const rotatedA = (new Point(a.canonical.x, a.canonical.y))._rotate(this.transform.angle);\n const rotatedB = (new Point(b.canonical.x, b.canonical.y))._rotate(this.transform.angle);\n return a.overscaledZ - b.overscaledZ || rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x;\n }).map(tile => tile.tileID.key);\n }\n return renderables.map(tile => tile.tileID).sort(compareTileId).map(id => id.key);\n }\n\n hasRenderableParent(tileID: OverscaledTileID) {\n const parentTile = this.findLoadedParent(tileID, 0);\n if (parentTile) {\n return this._isIdRenderable(parentTile.tileID.key);\n }\n return false;\n }\n\n _isIdRenderable(id: string, symbolLayer?: boolean) {\n return this._tiles[id] && this._tiles[id].hasData() &&\n !this._coveredTiles[id] && (symbolLayer || !this._tiles[id].holdingForFade());\n }\n\n reload() {\n if (this._paused) {\n this._shouldReloadOnResume = true;\n return;\n }\n\n this._cache.reset();\n\n for (const i in this._tiles) {\n if (this._tiles[i].state !== 'errored') this._reloadTile(i, 'reloading');\n }\n }\n\n _reloadTile(id: string, state: TileState) {\n const tile = this._tiles[id];\n\n // this potentially does not address all underlying\n // issues https://github.com/mapbox/mapbox-gl-js/issues/4252\n // - hard to tell without repro steps\n if (!tile) return;\n\n // The difference between \"loading\" tiles and \"reloading\" or \"expired\"\n // tiles is that \"reloading\"/\"expired\" tiles are \"renderable\".\n // Therefore, a \"loading\" tile cannot become a \"reloading\" tile without\n // first becoming a \"loaded\" tile.\n if (tile.state !== 'loading') {\n tile.state = state;\n }\n\n this._loadTile(tile, this._tileLoaded.bind(this, tile, id, state));\n }\n\n _tileLoaded(tile: Tile, id: string, previousState: TileState, err?: Error | null) {\n if (err) {\n tile.state = 'errored';\n if ((err as any).status !== 404) this._source.fire(new ErrorEvent(err, {tile}));\n // continue to try loading parent/children tiles if a tile doesn't exist (404)\n else this.update(this.transform, this.terrain);\n return;\n }\n\n tile.timeAdded = browser.now();\n if (previousState === 'expired') tile.refreshedUponExpiration = true;\n this._setTileReloadTimer(id, tile);\n if (this.getSource().type === 'raster-dem' && tile.dem) this._backfillDEM(tile);\n this._state.initializeTileState(tile, this.map ? this.map.painter : null);\n\n if (!tile.aborted) {\n this._source.fire(new Event('data', {dataType: 'source', tile, coord: tile.tileID}));\n }\n }\n\n /**\n * For raster terrain source, backfill DEM to eliminate visible tile boundaries\n */\n _backfillDEM(tile: Tile) {\n const renderables = this.getRenderableIds();\n for (let i = 0; i < renderables.length; i++) {\n const borderId = renderables[i];\n if (tile.neighboringTiles && tile.neighboringTiles[borderId]) {\n const borderTile = this.getTileByID(borderId);\n fillBorder(tile, borderTile);\n fillBorder(borderTile, tile);\n }\n }\n\n function fillBorder(tile, borderTile) {\n tile.needsHillshadePrepare = true;\n tile.needsTerrainPrepare = true;\n let dx = borderTile.tileID.canonical.x - tile.tileID.canonical.x;\n const dy = borderTile.tileID.canonical.y - tile.tileID.canonical.y;\n const dim = Math.pow(2, tile.tileID.canonical.z);\n const borderId = borderTile.tileID.key;\n if (dx === 0 && dy === 0) return;\n\n if (Math.abs(dy) > 1) {\n return;\n }\n if (Math.abs(dx) > 1) {\n // Adjust the delta coordinate for world wraparound.\n if (Math.abs(dx + dim) === 1) {\n dx += dim;\n } else if (Math.abs(dx - dim) === 1) {\n dx -= dim;\n }\n }\n if (!borderTile.dem || !tile.dem) return;\n tile.dem.backfillBorder(borderTile.dem, dx, dy);\n if (tile.neighboringTiles && tile.neighboringTiles[borderId])\n tile.neighboringTiles[borderId].backfilled = true;\n }\n }\n /**\n * Get a specific tile by TileID\n */\n getTile(tileID: OverscaledTileID): Tile {\n return this.getTileByID(tileID.key);\n }\n\n /**\n * Get a specific tile by id\n */\n getTileByID(id: string): Tile {\n return this._tiles[id];\n }\n\n /**\n * For a given set of tiles, retain children that are loaded and have a zoom\n * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive)\n */\n _retainLoadedChildren(\n idealTiles: {\n [_ in any]: OverscaledTileID;\n },\n zoom: number,\n maxCoveringZoom: number,\n retain: {\n [_ in any]: OverscaledTileID;\n }\n ) {\n for (const id in this._tiles) {\n let tile = this._tiles[id];\n\n // only consider renderable tiles up to maxCoveringZoom\n if (retain[id] ||\n !tile.hasData() ||\n tile.tileID.overscaledZ <= zoom ||\n tile.tileID.overscaledZ > maxCoveringZoom\n ) continue;\n\n // loop through parents and retain the topmost loaded one if found\n let topmostLoadedID = tile.tileID;\n while (tile && tile.tileID.overscaledZ > zoom + 1) {\n const parentID = tile.tileID.scaledTo(tile.tileID.overscaledZ - 1);\n\n tile = this._tiles[parentID.key];\n\n if (tile && tile.hasData()) {\n topmostLoadedID = parentID;\n }\n }\n\n // loop through ancestors of the topmost loaded child to see if there's one that needed it\n let tileID = topmostLoadedID;\n while (tileID.overscaledZ > zoom) {\n tileID = tileID.scaledTo(tileID.overscaledZ - 1);\n\n if (idealTiles[tileID.key]) {\n // found a parent that needed a loaded child; retain that child\n retain[topmostLoadedID.key] = topmostLoadedID;\n break;\n }\n }\n }\n }\n\n /**\n * Find a loaded parent of the given tile (up to minCoveringZoom)\n */\n findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): Tile {\n if (tileID.key in this._loadedParentTiles) {\n const parent = this._loadedParentTiles[tileID.key];\n if (parent && parent.tileID.overscaledZ >= minCoveringZoom) {\n return parent;\n } else {\n return null;\n }\n }\n for (let z = tileID.overscaledZ - 1; z >= minCoveringZoom; z--) {\n const parentTileID = tileID.scaledTo(z);\n const tile = this._getLoadedTile(parentTileID);\n if (tile) {\n return tile;\n }\n }\n }\n\n _getLoadedTile(tileID: OverscaledTileID): Tile {\n const tile = this._tiles[tileID.key];\n if (tile && tile.hasData()) {\n return tile;\n }\n // TileCache ignores wrap in lookup.\n const cachedTile = this._cache.getByKey(tileID.wrapped().key);\n return cachedTile;\n }\n\n /**\n * Resizes the tile cache based on the current viewport's size\n * or the maxTileCacheSize option passed during map creation\n *\n * Larger viewports use more tiles and need larger caches. Larger viewports\n * are more likely to be found on devices with more memory and on pages where\n * the map is more important.\n */\n updateCacheSize(transform: Transform) {\n const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1;\n const heightInTiles = Math.ceil(transform.height / this._source.tileSize) + 1;\n const approxTilesInView = widthInTiles * heightInTiles;\n const commonZoomRange = this._maxTileCacheZoomLevels === null ?\n config.MAX_TILE_CACHE_ZOOM_LEVELS : this._maxTileCacheZoomLevels;\n const viewDependentMaxSize = Math.floor(approxTilesInView * commonZoomRange);\n const maxSize = typeof this._maxTileCacheSize === 'number' ?\n Math.min(this._maxTileCacheSize, viewDependentMaxSize) : viewDependentMaxSize;\n\n this._cache.setMaxSize(maxSize);\n }\n\n handleWrapJump(lng: number) {\n // On top of the regular z/x/y values, TileIDs have a `wrap` value that specify\n // which cppy of the world the tile belongs to. For example, at `lng: 10` you\n // might render z/x/y/0 while at `lng: 370` you would render z/x/y/1.\n //\n // When lng values get wrapped (going from `lng: 370` to `long: 10`) you expect\n // to see the same thing on the screen (370 degrees and 10 degrees is the same\n // place in the world) but all the TileIDs will have different wrap values.\n //\n // In order to make this transition seamless, we calculate the rounded difference of\n // \"worlds\" between the last frame and the current frame. If the map panned by\n // a world, then we can assign all the tiles new TileIDs with updated wrap values.\n // For example, assign z/x/y/1 a new id: z/x/y/0. It is the same tile, just rendered\n // in a different position.\n //\n // This enables us to reuse the tiles at more ideal locations and prevent flickering.\n const prevLng = this._prevLng === undefined ? lng : this._prevLng;\n const lngDifference = lng - prevLng;\n const worldDifference = lngDifference / 360;\n const wrapDelta = Math.round(worldDifference);\n this._prevLng = lng;\n\n if (wrapDelta) {\n const tiles: {[_: string]: Tile} = {};\n for (const key in this._tiles) {\n const tile = this._tiles[key];\n tile.tileID = tile.tileID.unwrapTo(tile.tileID.wrap + wrapDelta);\n tiles[tile.tileID.key] = tile;\n }\n this._tiles = tiles;\n\n // Reset tile reload timers\n for (const id in this._timers) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n this._setTileReloadTimer(id, tile);\n }\n }\n }\n\n /**\n * Removes tiles that are outside the viewport and adds new tiles that\n * are inside the viewport.\n */\n update(transform: Transform, terrain?: Terrain) {\n this.transform = transform;\n this.terrain = terrain;\n if (!this._sourceLoaded || this._paused) { return; }\n\n this.updateCacheSize(transform);\n this.handleWrapJump(this.transform.center.lng);\n\n // Covered is a list of retained tiles who's areas are fully covered by other,\n // better, retained tiles. They are not drawn separately.\n this._coveredTiles = {};\n\n let idealTileIDs;\n if (!this.used && !this.usedForTerrain) {\n idealTileIDs = [];\n } else if (this._source.tileID) {\n idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID)\n .map((unwrapped) => new OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y));\n } else {\n idealTileIDs = transform.coveringTiles({\n tileSize: this.usedForTerrain ? this.tileSize : this._source.tileSize,\n minzoom: this._source.minzoom,\n maxzoom: this._source.maxzoom,\n roundZoom: this.usedForTerrain ? false : this._source.roundZoom,\n reparseOverscaled: this._source.reparseOverscaled,\n terrain\n });\n\n if (this._source.hasTile) {\n idealTileIDs = idealTileIDs.filter((coord) => (this._source.hasTile as any)(coord));\n }\n }\n\n // Determine the overzooming/underzooming amounts.\n const zoom = transform.coveringZoomLevel(this._source);\n const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);\n const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);\n\n // When sourcecache is used for terrain also load parent tiles to avoid flickering when zooming out\n if (this.usedForTerrain) {\n const parents = {};\n for (const tileID of idealTileIDs) {\n if (tileID.canonical.z > this._source.minzoom) {\n const parent = tileID.scaledTo(tileID.canonical.z - 1);\n parents[parent.key] = parent;\n // load very low zoom to calculate tile visibility in transform.coveringTiles and high zoomlevels correct\n const parent2 = tileID.scaledTo(Math.max(this._source.minzoom, Math.min(tileID.canonical.z, 5)));\n parents[parent2.key] = parent2;\n }\n }\n idealTileIDs = idealTileIDs.concat(Object.values(parents));\n }\n\n const noPendingDataEmissions = idealTileIDs.length === 0 && !this._updated && this._didEmitContent;\n this._updated = true;\n // if we won't have any tiles to fetch and content is already emitted\n // there will be no more data emissions, so we need to emit the event with isSourceLoaded = true\n if (noPendingDataEmissions) {\n this.fire(new Event('data', {sourceDataType: 'idle', dataType: 'source', sourceId: this.id}));\n }\n\n // Retain is a list of tiles that we shouldn't delete, even if they are not\n // the most ideal tile for the current viewport. This may include tiles like\n // parent or child tiles that are *already* loaded.\n const retain = this._updateRetainedTiles(idealTileIDs, zoom);\n\n if (isRasterType(this._source.type)) {\n const parentsForFading: {[_: string]: OverscaledTileID} = {};\n const fadingTiles = {};\n const ids = Object.keys(retain);\n const now = browser.now();\n for (const id of ids) {\n const tileID = retain[id];\n\n const tile = this._tiles[id];\n\n // when fadeEndTime is 0, the tile is created but registerFadeDuration\n // has not been called, therefore must be kept in fadingTiles dictionary\n // for next round of rendering\n if (!tile || (tile.fadeEndTime !== 0 && tile.fadeEndTime <= now)) {\n continue;\n }\n\n // if the tile is loaded but still fading in, find parents to cross-fade with it\n const parentTile = this.findLoadedParent(tileID, minCoveringZoom);\n if (parentTile) {\n this._addTile(parentTile.tileID);\n parentsForFading[parentTile.tileID.key] = parentTile.tileID;\n }\n\n fadingTiles[id] = tileID;\n }\n\n // for tiles that are still fading in, also find children to cross-fade with\n this._retainLoadedChildren(fadingTiles, zoom, maxCoveringZoom, retain);\n\n for (const id in parentsForFading) {\n if (!retain[id]) {\n // If a tile is only needed for fading, mark it as covered so that it isn't rendered on it's own.\n this._coveredTiles[id] = true;\n retain[id] = parentsForFading[id];\n }\n }\n\n // disable fading logic in terrain3D mode to avoid rendering two tiles on the same place\n if (terrain) {\n const idealRasterTileIDs: {[_: string]: OverscaledTileID} = {};\n const missingTileIDs: {[_: string]: OverscaledTileID} = {};\n for (const tileID of idealTileIDs) {\n if (this._tiles[tileID.key].hasData())\n idealRasterTileIDs[tileID.key] = tileID;\n else\n missingTileIDs[tileID.key] = tileID;\n }\n // search for a complete set of children for each missing tile\n for (const key in missingTileIDs) {\n const children = missingTileIDs[key].children(this._source.maxzoom);\n if (this._tiles[children[0].key] && this._tiles[children[1].key] && this._tiles[children[2].key] && this._tiles[children[3].key]) {\n idealRasterTileIDs[children[0].key] = retain[children[0].key] = children[0];\n idealRasterTileIDs[children[1].key] = retain[children[1].key] = children[1];\n idealRasterTileIDs[children[2].key] = retain[children[2].key] = children[2];\n idealRasterTileIDs[children[3].key] = retain[children[3].key] = children[3];\n delete missingTileIDs[key];\n }\n }\n // search for parent for each missing tile\n for (const key in missingTileIDs) {\n const parent = this.findLoadedParent(missingTileIDs[key], this._source.minzoom);\n if (parent) {\n idealRasterTileIDs[parent.tileID.key] = retain[parent.tileID.key] = parent.tileID;\n // remove idealTiles which would be rendered twice\n for (const key in idealRasterTileIDs) {\n if (idealRasterTileIDs[key].isChildOf(parent.tileID)) delete idealRasterTileIDs[key];\n }\n }\n }\n // cover all tiles which are not needed\n for (const key in this._tiles) {\n if (!idealRasterTileIDs[key]) this._coveredTiles[key] = true;\n }\n }\n }\n\n for (const retainedId in retain) {\n // Make sure retained tiles always clear any existing fade holds\n // so that if they're removed again their fade timer starts fresh.\n this._tiles[retainedId].clearFadeHold();\n }\n\n // Remove the tiles we don't need anymore.\n const remove = keysDifference(this._tiles, retain);\n for (const tileID of remove) {\n const tile = this._tiles[tileID];\n if (tile.hasSymbolBuckets && !tile.holdingForFade()) {\n tile.setHoldDuration(this.map._fadeDuration);\n } else if (!tile.hasSymbolBuckets || tile.symbolFadeFinished()) {\n this._removeTile(tileID);\n }\n }\n\n // Construct a cache of loaded parents\n this._updateLoadedParentTileCache();\n }\n\n releaseSymbolFadeTiles() {\n for (const id in this._tiles) {\n if (this._tiles[id].holdingForFade()) {\n this._removeTile(id);\n }\n }\n }\n\n _updateRetainedTiles(idealTileIDs: Array, zoom: number): {[_: string]: OverscaledTileID} {\n const retain: {[_: string]: OverscaledTileID} = {};\n const checked: {[_: string]: boolean} = {};\n const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);\n const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);\n\n const missingTiles = {};\n for (const tileID of idealTileIDs) {\n const tile = this._addTile(tileID);\n\n // retain the tile even if it's not loaded because it's an ideal tile.\n retain[tileID.key] = tileID;\n\n if (tile.hasData()) continue;\n\n if (zoom < this._source.maxzoom) {\n // save missing tiles that potentially have loaded children\n missingTiles[tileID.key] = tileID;\n }\n }\n\n // retain any loaded children of ideal tiles up to maxCoveringZoom\n this._retainLoadedChildren(missingTiles, zoom, maxCoveringZoom, retain);\n\n for (const tileID of idealTileIDs) {\n let tile = this._tiles[tileID.key];\n\n if (tile.hasData()) continue;\n\n // The tile we require is not yet loaded or does not exist;\n // Attempt to find children that fully cover it.\n\n if (zoom + 1 > this._source.maxzoom) {\n // We're looking for an overzoomed child tile.\n const childCoord = tileID.children(this._source.maxzoom)[0];\n const childTile = this.getTile(childCoord);\n if (!!childTile && childTile.hasData()) {\n retain[childCoord.key] = childCoord;\n continue; // tile is covered by overzoomed child\n }\n } else {\n // check if all 4 immediate children are loaded (i.e. the missing ideal tile is covered)\n const children = tileID.children(this._source.maxzoom);\n\n if (retain[children[0].key] &&\n retain[children[1].key] &&\n retain[children[2].key] &&\n retain[children[3].key]) continue; // tile is covered by children\n }\n\n // We couldn't find child tiles that entirely cover the ideal tile; look for parents now.\n\n // As we ascend up the tile pyramid of the ideal tile, we check whether the parent\n // tile has been previously requested (and errored because we only loop over tiles with no data)\n // in order to determine if we need to request its parent.\n let parentWasRequested = tile.wasRequested();\n\n for (let overscaledZ = tileID.overscaledZ - 1; overscaledZ >= minCoveringZoom; --overscaledZ) {\n const parentId = tileID.scaledTo(overscaledZ);\n\n // Break parent tile ascent if this route has been previously checked by another child.\n if (checked[parentId.key]) break;\n checked[parentId.key] = true;\n\n tile = this.getTile(parentId);\n if (!tile && parentWasRequested) {\n tile = this._addTile(parentId);\n }\n if (tile) {\n const hasData = tile.hasData();\n if (parentWasRequested || hasData) {\n retain[parentId.key] = parentId;\n }\n // Save the current values, since they're the parent of the next iteration\n // of the parent tile ascent loop.\n parentWasRequested = tile.wasRequested();\n if (hasData) break;\n }\n }\n }\n\n return retain;\n }\n\n _updateLoadedParentTileCache() {\n this._loadedParentTiles = {};\n\n for (const tileKey in this._tiles) {\n const path = [];\n let parentTile: Tile;\n let currentId = this._tiles[tileKey].tileID;\n\n // Find the closest loaded ancestor by traversing the tile tree towards the root and\n // caching results along the way\n while (currentId.overscaledZ > 0) {\n\n // Do we have a cached result from previous traversals?\n if (currentId.key in this._loadedParentTiles) {\n parentTile = this._loadedParentTiles[currentId.key];\n break;\n }\n\n path.push(currentId.key);\n\n // Is the parent loaded?\n const parentId = currentId.scaledTo(currentId.overscaledZ - 1);\n parentTile = this._getLoadedTile(parentId);\n if (parentTile) {\n break;\n }\n\n currentId = parentId;\n }\n\n // Cache the result of this traversal to all newly visited tiles\n for (const key of path) {\n this._loadedParentTiles[key] = parentTile;\n }\n }\n }\n\n /**\n * Add a tile, given its coordinate, to the pyramid.\n */\n _addTile(tileID: OverscaledTileID): Tile {\n let tile = this._tiles[tileID.key];\n if (tile)\n return tile;\n\n tile = this._cache.getAndRemove(tileID);\n if (tile) {\n this._setTileReloadTimer(tileID.key, tile);\n // set the tileID because the cached tile could have had a different wrap value\n tile.tileID = tileID;\n this._state.initializeTileState(tile, this.map ? this.map.painter : null);\n if (this._cacheTimers[tileID.key]) {\n clearTimeout(this._cacheTimers[tileID.key]);\n delete this._cacheTimers[tileID.key];\n this._setTileReloadTimer(tileID.key, tile);\n }\n }\n\n const cached = tile;\n\n if (!tile) {\n tile = new Tile(tileID, this._source.tileSize * tileID.overscaleFactor());\n this._loadTile(tile, this._tileLoaded.bind(this, tile, tileID.key, tile.state));\n }\n\n tile.uses++;\n this._tiles[tileID.key] = tile;\n if (!cached) {\n this._source.fire(new Event('dataloading', {tile, coord: tile.tileID, dataType: 'source'}));\n }\n\n return tile;\n }\n\n _setTileReloadTimer(id: string, tile: Tile) {\n if (id in this._timers) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n\n const expiryTimeout = tile.getExpiryTimeout();\n if (expiryTimeout) {\n this._timers[id] = setTimeout(() => {\n this._reloadTile(id, 'expired');\n delete this._timers[id];\n }, expiryTimeout);\n }\n }\n\n /**\n * Remove a tile, given its id, from the pyramid\n */\n _removeTile(id: string) {\n const tile = this._tiles[id];\n if (!tile)\n return;\n\n tile.uses--;\n delete this._tiles[id];\n if (this._timers[id]) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n\n if (tile.uses > 0)\n return;\n\n if (tile.hasData() && tile.state !== 'reloading') {\n this._cache.add(tile.tileID, tile, tile.getExpiryTimeout());\n } else {\n tile.aborted = true;\n this._abortTile(tile);\n this._unloadTile(tile);\n }\n }\n\n /**\n * Remove all tiles from this pyramid\n */\n clearTiles() {\n this._shouldReloadOnResume = false;\n this._paused = false;\n\n for (const id in this._tiles)\n this._removeTile(id);\n\n this._cache.reset();\n }\n\n /**\n * Search through our current tiles and attempt to find the tiles that\n * cover the given bounds.\n * @param pointQueryGeometry - coordinates of the corners of bounding rectangle\n * @returns result items have `{tile, minX, maxX, minY, maxY}`, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile.\n */\n tilesIn(pointQueryGeometry: Array, maxPitchScaleFactor: number, has3DLayer: boolean): any[] {\n\n const tileResults = [];\n\n const transform = this.transform;\n if (!transform) return tileResults;\n\n const cameraPointQueryGeometry = has3DLayer ?\n transform.getCameraQueryGeometry(pointQueryGeometry) :\n pointQueryGeometry;\n\n const queryGeometry = pointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain));\n const cameraQueryGeometry = cameraPointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain));\n\n const ids = this.getIds();\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const p of cameraQueryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n\n for (let i = 0; i < ids.length; i++) {\n const tile = this._tiles[ids[i]];\n if (tile.holdingForFade()) {\n // Tiles held for fading are covered by tiles that are closer to ideal\n continue;\n }\n const tileID = tile.tileID;\n const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);\n const queryPadding = maxPitchScaleFactor * tile.queryPadding * EXTENT / tile.tileSize / scale;\n\n const tileSpaceBounds = [\n tileID.getTilePoint(new MercatorCoordinate(minX, minY)),\n tileID.getTilePoint(new MercatorCoordinate(maxX, maxY))\n ];\n\n if (tileSpaceBounds[0].x - queryPadding < EXTENT && tileSpaceBounds[0].y - queryPadding < EXTENT &&\n tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) {\n\n const tileSpaceQueryGeometry: Array = queryGeometry.map((c) => tileID.getTilePoint(c));\n const tileSpaceCameraQueryGeometry = cameraQueryGeometry.map((c) => tileID.getTilePoint(c));\n\n tileResults.push({\n tile,\n tileID,\n queryGeometry: tileSpaceQueryGeometry,\n cameraQueryGeometry: tileSpaceCameraQueryGeometry,\n scale\n });\n }\n }\n\n return tileResults;\n }\n\n getVisibleCoordinates(symbolLayer?: boolean): Array {\n const coords = this.getRenderableIds(symbolLayer).map((id) => this._tiles[id].tileID);\n for (const coord of coords) {\n coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped());\n }\n return coords;\n }\n\n hasTransition() {\n if (this._source.hasTransition()) {\n return true;\n }\n\n if (isRasterType(this._source.type)) {\n const now = browser.now();\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n if (tile.fadeEndTime >= now) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Set the value of a particular state for a feature\n */\n setFeatureState(sourceLayer: string, featureId: number | string, state: any) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n this._state.updateState(sourceLayer, featureId, state);\n }\n\n /**\n * Resets the value of a particular state key for a feature\n */\n removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n this._state.removeFeatureState(sourceLayer, featureId, key);\n }\n\n /**\n * Get the entire state object for a feature\n */\n getFeatureState(sourceLayer: string, featureId: number | string) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n return this._state.getState(sourceLayer, featureId);\n }\n\n /**\n * Sets the set of keys that the tile depends on. This allows tiles to\n * be reloaded when their dependencies change.\n */\n setDependencies(tileKey: string, namespace: string, dependencies: Array) {\n const tile = this._tiles[tileKey];\n if (tile) {\n tile.setDependencies(namespace, dependencies);\n }\n }\n\n /**\n * Reloads all tiles that depend on the given keys.\n */\n reloadTilesForDependencies(namespaces: Array, keys: Array) {\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n if (tile.hasDependency(namespaces, keys)) {\n this._reloadTile(id, 'reloading');\n }\n }\n this._cache.filter(tile => !tile.hasDependency(namespaces, keys));\n }\n}\n\nSourceCache.maxOverzooming = 10;\nSourceCache.maxUnderzooming = 3;\n\nfunction compareTileId(a: OverscaledTileID, b: OverscaledTileID): number {\n // Different copies of the world are sorted based on their distance to the center.\n // Wrap values are converted to unsigned distances by reserving odd number for copies\n // with negative wrap and even numbers for copies with positive wrap.\n const aWrap = Math.abs(a.wrap * 2) - +(a.wrap < 0);\n const bWrap = Math.abs(b.wrap * 2) - +(b.wrap < 0);\n return a.overscaledZ - b.overscaledZ || bWrap - aWrap || b.canonical.y - a.canonical.y || b.canonical.x - a.canonical.x;\n}\n\nfunction isRasterType(type) {\n return type === 'raster' || type === 'image' || type === 'video';\n}\n","import {config} from './config';\n\nimport type {WorkerSource} from '../source/worker_source';\n\nexport interface WorkerGlobalScopeInterface {\n importScripts(...urls: Array): void;\n registerWorkerSource: (\n b: string,\n a: {\n new(...args: any): WorkerSource;\n }\n ) => void;\n registerRTLTextPlugin: (_: any) => void;\n}\n\nexport function workerFactory() {\n return new Worker(config.WORKER_URL);\n}\n","import {workerFactory} from './web_worker';\nimport {browser} from './browser';\nimport {isSafari} from './util';\nimport {ActorTarget} from './actor';\n\nexport const PRELOAD_POOL_ID = 'mapboxgl_preloaded_worker_pool';\n\n/**\n * Constructs a worker pool.\n */\nexport class WorkerPool {\n static workerCount: number;\n\n active: {\n [_ in number | string]: boolean;\n };\n workers: Array;\n\n constructor() {\n this.active = {};\n }\n\n acquire(mapId: number | string): Array {\n if (!this.workers) {\n // Lazily look up the value of mapboxgl.workerCount so that\n // client code has had a chance to set it.\n this.workers = [];\n while (this.workers.length < WorkerPool.workerCount) {\n this.workers.push(workerFactory());\n }\n }\n\n this.active[mapId] = true;\n return this.workers.slice();\n }\n\n release(mapId: number | string) {\n delete this.active[mapId];\n if (this.numActive() === 0) {\n this.workers.forEach((w) => {\n w.terminate();\n });\n this.workers = null;\n }\n }\n\n isPreloaded(): boolean {\n return !!this.active[PRELOAD_POOL_ID];\n }\n\n numActive(): number {\n return Object.keys(this.active).length;\n }\n}\n\n// Based on results from A/B testing: https://github.com/maplibre/maplibre-gl-js/pull/2354\nconst availableLogicalProcessors = Math.floor(browser.hardwareConcurrency / 2);\nWorkerPool.workerCount = isSafari(globalThis) ? Math.max(Math.min(availableLogicalProcessors, 3), 1) : 1;\n","import {WorkerPool, PRELOAD_POOL_ID} from './worker_pool';\n\nlet globalWorkerPool;\n\n/**\n * Creates (if necessary) and returns the single, global WorkerPool instance\n * to be shared across each Map\n */\nexport function getGlobalWorkerPool() {\n if (!globalWorkerPool) {\n globalWorkerPool = new WorkerPool();\n }\n return globalWorkerPool;\n}\n\nexport function prewarm() {\n const workerPool = getGlobalWorkerPool();\n workerPool.acquire(PRELOAD_POOL_ID);\n}\n\nexport function clearPrewarmedResources() {\n const pool = globalWorkerPool;\n if (pool) {\n // Remove the pool only if all maps that referenced the preloaded global worker pool have been removed.\n if (pool.isPreloaded() && pool.numActive() === 1) {\n pool.release(PRELOAD_POOL_ID);\n globalWorkerPool = null;\n } else {\n console.warn('Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()');\n }\n }\n}\n","import {clamp} from '../util/util';\nimport Point from '@mapbox/point-geometry';\n\nexport class PathInterpolator {\n points: Array;\n length: number;\n paddedLength: number;\n padding: number;\n _distances: Array;\n\n constructor(points_?: Array | null, padding_?: number | null) {\n this.reset(points_, padding_);\n }\n\n reset(points_?: Array | null, padding_?: number | null) {\n this.points = points_ || [];\n\n // Compute cumulative distance from first point to every other point in the segment.\n // Last entry in the array is total length of the path\n this._distances = [0.0];\n\n for (let i = 1; i < this.points.length; i++) {\n this._distances[i] = this._distances[i - 1] + this.points[i].dist(this.points[i - 1]);\n }\n\n this.length = this._distances[this._distances.length - 1];\n this.padding = Math.min(padding_ || 0, this.length * 0.5);\n this.paddedLength = this.length - this.padding * 2.0;\n }\n\n lerp(t: number): Point {\n if (this.points.length === 1) {\n return this.points[0];\n }\n\n t = clamp(t, 0, 1);\n\n // Find the correct segment [p0, p1] where p0 <= x < p1\n let currentIndex = 1;\n let distOfCurrentIdx = this._distances[currentIndex];\n const distToTarget = t * this.paddedLength + this.padding;\n\n while (distOfCurrentIdx < distToTarget && currentIndex < this._distances.length) {\n distOfCurrentIdx = this._distances[++currentIndex];\n }\n\n // Interpolate between the two points of the segment\n const idxOfPrevPoint = currentIndex - 1;\n const distOfPrevIdx = this._distances[idxOfPrevPoint];\n const segmentLength = distOfCurrentIdx - distOfPrevIdx;\n const segmentT = segmentLength > 0 ? (distToTarget - distOfPrevIdx) / segmentLength : 0;\n\n return this.points[idxOfPrevPoint].mult(1.0 - segmentT).add(this.points[currentIndex].mult(segmentT));\n }\n}\n","import type {OverlapMode} from '../style/style_layer/overlap_mode';\n\ntype QueryArgs = {\n hitTest: boolean;\n overlapMode?: OverlapMode;\n circle?: {\n x: number;\n y: number;\n radius: number;\n };\n seenUids: {\n box: {\n [_: number]: boolean;\n };\n circle: {\n [_: number]: boolean;\n };\n };\n};\n\ntype QueryResult = {\n key: T;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n};\n\n/**\n * A key for the grid\n */\nexport type GridKey = {\n overlapMode?: OverlapMode;\n}\n\nfunction overlapAllowed(overlapA: OverlapMode, overlapB: OverlapMode): boolean {\n let allowed = true;\n\n if (overlapA === 'always') {\n // symbol A using 'always' overlap - allowed to overlap anything.\n } else if (overlapA === 'never' || overlapB === 'never') {\n // symbol A using 'never' overlap - can't overlap anything\n // symbol A using 'cooperative' overlap - can overlap 'always' or 'cooperative' symbol; can't overlap 'never'\n allowed = false;\n }\n\n return allowed;\n}\n\n/**\n * @internal\n * GridIndex is a data structure for testing the intersection of\n * circles and rectangles in a 2d plane.\n * It is optimized for rapid insertion and querying.\n * GridIndex splits the plane into a set of \"cells\" and keeps track\n * of which geometries intersect with each cell. At query time,\n * full geometry comparisons are only done for items that share\n * at least one cell. As long as the geometries are relatively\n * uniformly distributed across the plane, this greatly reduces\n * the number of comparisons necessary.\n */\nexport class GridIndex {\n circleKeys: Array;\n boxKeys: Array;\n boxCells: Array>;\n circleCells: Array>;\n bboxes: Array;\n circles: Array;\n xCellCount: number;\n yCellCount: number;\n width: number;\n height: number;\n xScale: number;\n yScale: number;\n boxUid: number;\n circleUid: number;\n\n constructor (width: number, height: number, cellSize: number) {\n const boxCells = this.boxCells = [];\n const circleCells = this.circleCells = [];\n\n // More cells -> fewer geometries to check per cell, but items tend\n // to be split across more cells.\n // Sweet spot allows most small items to fit in one cell\n this.xCellCount = Math.ceil(width / cellSize);\n this.yCellCount = Math.ceil(height / cellSize);\n\n for (let i = 0; i < this.xCellCount * this.yCellCount; i++) {\n boxCells.push([]);\n circleCells.push([]);\n }\n this.circleKeys = [];\n this.boxKeys = [];\n this.bboxes = [];\n this.circles = [];\n\n this.width = width;\n this.height = height;\n this.xScale = this.xCellCount / width;\n this.yScale = this.yCellCount / height;\n this.boxUid = 0;\n this.circleUid = 0;\n }\n\n keysLength() {\n return this.boxKeys.length + this.circleKeys.length;\n }\n\n insert(key: T, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertBoxCell, this.boxUid++);\n this.boxKeys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n insertCircle(key: T, x: number, y: number, radius: number) {\n // Insert circle into grid for all cells in the circumscribing square\n // It's more than necessary (by a factor of 4/PI), but fast to insert\n this._forEachCell(x - radius, y - radius, x + radius, y + radius, this._insertCircleCell, this.circleUid++);\n this.circleKeys.push(key);\n this.circles.push(x);\n this.circles.push(y);\n this.circles.push(radius);\n }\n\n private _insertBoxCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.boxCells[cellIndex].push(uid);\n }\n\n private _insertCircleCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.circleCells[cellIndex].push(uid);\n }\n\n private _query(x1: number, y1: number, x2: number, y2: number, hitTest: boolean, overlapMode: OverlapMode, predicate?: (key: T) => boolean): Array> {\n if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {\n return [];\n }\n const result: Array> = [];\n if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {\n if (hitTest) {\n // Covers the entire grid, so collides with everything\n return [{\n key: null,\n x1,\n y1,\n x2,\n y2\n }];\n }\n for (let boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {\n result.push({\n key: this.boxKeys[boxUid],\n x1: this.bboxes[boxUid * 4],\n y1: this.bboxes[boxUid * 4 + 1],\n x2: this.bboxes[boxUid * 4 + 2],\n y2: this.bboxes[boxUid * 4 + 3]\n });\n }\n for (let circleUid = 0; circleUid < this.circleKeys.length; circleUid++) {\n const x = this.circles[circleUid * 3];\n const y = this.circles[circleUid * 3 + 1];\n const radius = this.circles[circleUid * 3 + 2];\n result.push({\n key: this.circleKeys[circleUid],\n x1: x - radius,\n y1: y - radius,\n x2: x + radius,\n y2: y + radius\n });\n }\n } else {\n const queryArgs: QueryArgs = {\n hitTest,\n overlapMode,\n seenUids: {box: {}, circle: {}}\n };\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, queryArgs, predicate);\n }\n\n return result;\n }\n\n query(x1: number, y1: number, x2: number, y2: number): Array> {\n return this._query(x1, y1, x2, y2, false, null);\n }\n\n hitTest(x1: number, y1: number, x2: number, y2: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean {\n return this._query(x1, y1, x2, y2, true, overlapMode, predicate).length > 0;\n }\n\n hitTestCircle(x: number, y: number, radius: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean {\n // Insert circle into grid for all cells in the circumscribing square\n // It's more than necessary (by a factor of 4/PI), but fast to insert\n const x1 = x - radius;\n const x2 = x + radius;\n const y1 = y - radius;\n const y2 = y + radius;\n if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {\n return false;\n }\n\n // Box query early exits if the bounding box is larger than the grid, but we don't do\n // the equivalent calculation for circle queries because early exit is less likely\n // and the calculation is more expensive\n const result: boolean[] = [];\n const queryArgs: QueryArgs = {\n hitTest: true,\n overlapMode,\n circle: {x, y, radius},\n seenUids: {box: {}, circle: {}}\n };\n this._forEachCell(x1, y1, x2, y2, this._queryCellCircle, result, queryArgs, predicate);\n return result.length > 0;\n }\n\n private _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array>, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean {\n const {seenUids, hitTest, overlapMode} = queryArgs;\n const boxCell = this.boxCells[cellIndex];\n\n if (boxCell !== null) {\n const bboxes = this.bboxes;\n for (const boxUid of boxCell) {\n if (!seenUids.box[boxUid]) {\n seenUids.box[boxUid] = true;\n const offset = boxUid * 4;\n const key = this.boxKeys[boxUid];\n\n if ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]) &&\n (!predicate || predicate(key))) {\n if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push({\n key,\n x1: bboxes[offset],\n y1: bboxes[offset + 1],\n x2: bboxes[offset + 2],\n y2: bboxes[offset + 3]\n });\n if (hitTest) {\n // true return value stops the query after first match\n return true;\n }\n }\n }\n }\n }\n }\n const circleCell = this.circleCells[cellIndex];\n if (circleCell !== null) {\n const circles = this.circles;\n for (const circleUid of circleCell) {\n if (!seenUids.circle[circleUid]) {\n seenUids.circle[circleUid] = true;\n const offset = circleUid * 3;\n const key = this.circleKeys[circleUid];\n\n if (this._circleAndRectCollide(\n circles[offset],\n circles[offset + 1],\n circles[offset + 2],\n x1,\n y1,\n x2,\n y2) &&\n (!predicate || predicate(key))) {\n if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) {\n const x = circles[offset];\n const y = circles[offset + 1];\n const radius = circles[offset + 2];\n result.push({\n key,\n x1: x - radius,\n y1: y - radius,\n x2: x + radius,\n y2: y + radius\n });\n if (hitTest) {\n // true return value stops the query after first match\n return true;\n }\n }\n }\n }\n }\n }\n\n // false return to continue query\n return false;\n }\n\n private _queryCellCircle(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean {\n const {circle, seenUids, overlapMode} = queryArgs;\n const boxCell = this.boxCells[cellIndex];\n\n if (boxCell !== null) {\n const bboxes = this.bboxes;\n for (const boxUid of boxCell) {\n if (!seenUids.box[boxUid]) {\n seenUids.box[boxUid] = true;\n const offset = boxUid * 4;\n const key = this.boxKeys[boxUid];\n if (this._circleAndRectCollide(\n circle.x,\n circle.y,\n circle.radius,\n bboxes[offset + 0],\n bboxes[offset + 1],\n bboxes[offset + 2],\n bboxes[offset + 3]) &&\n (!predicate || predicate(key)) &&\n !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push(true);\n return true;\n }\n }\n }\n }\n\n const circleCell = this.circleCells[cellIndex];\n if (circleCell !== null) {\n const circles = this.circles;\n for (const circleUid of circleCell) {\n if (!seenUids.circle[circleUid]) {\n seenUids.circle[circleUid] = true;\n const offset = circleUid * 3;\n const key = this.circleKeys[circleUid];\n if (this._circlesCollide(\n circles[offset],\n circles[offset + 1],\n circles[offset + 2],\n circle.x,\n circle.y,\n circle.radius) &&\n (!predicate || predicate(key)) &&\n !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push(true);\n return true;\n }\n }\n }\n }\n }\n\n private _forEachCell(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n fn: (x1: number, y1: number, x2: number, y2: number, cellIndex: number, arg1: TArg, arg2?: QueryArgs, predicate?: (key: T) => boolean) => boolean | void,\n arg1: TArg,\n arg2?: QueryArgs,\n predicate?: (key: T) => boolean) {\n const cx1 = this._convertToXCellCoord(x1);\n const cy1 = this._convertToYCellCoord(y1);\n const cx2 = this._convertToXCellCoord(x2);\n const cy2 = this._convertToYCellCoord(y2);\n\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.xCellCount * y + x;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) return;\n }\n }\n }\n\n private _convertToXCellCoord(x: number) {\n return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale)));\n }\n\n private _convertToYCellCoord(y: number) {\n return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));\n }\n\n private _circlesCollide(x1: number, y1: number, r1: number, x2: number, y2: number, r2: number): boolean {\n const dx = x2 - x1;\n const dy = y2 - y1;\n const bothRadii = r1 + r2;\n return (bothRadii * bothRadii) > (dx * dx + dy * dy);\n }\n\n private _circleAndRectCollide(\n circleX: number,\n circleY: number,\n radius: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number\n ): boolean {\n const halfRectWidth = (x2 - x1) / 2;\n const distX = Math.abs(circleX - (x1 + halfRectWidth));\n if (distX > (halfRectWidth + radius)) {\n return false;\n }\n\n const halfRectHeight = (y2 - y1) / 2;\n const distY = Math.abs(circleY - (y1 + halfRectHeight));\n if (distY > (halfRectHeight + radius)) {\n return false;\n }\n\n if (distX <= halfRectWidth || distY <= halfRectHeight) {\n return true;\n }\n\n const dx = distX - halfRectWidth;\n const dy = distY - halfRectHeight;\n return (dx * dx + dy * dy <= (radius * radius));\n }\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {mat4, vec4} from 'gl-matrix';\nimport * as symbolSize from './symbol_size';\nimport {addDynamicAttributes} from '../data/bucket/symbol_bucket';\n\nimport type {Painter} from '../render/painter';\nimport type {Transform} from '../geo/transform';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport type {\n GlyphOffsetArray,\n SymbolLineVertexArray,\n SymbolDynamicLayoutArray\n} from '../data/array_types.g';\nimport {WritingMode} from '../symbol/shaping';\nimport {findLineIntersection} from '../util/util';\n\nexport {updateLineLabels, hideGlyphs, getLabelPlaneMatrix, getGlCoordMatrix, project, getPerspectiveRatio, placeFirstAndLastGlyph, placeGlyphAlongLine, xyTransformMat4, projectVertexToViewport, findOffsetIntersectionPoint, transformToOffsetNormal};\n\n/*\n * # Overview of coordinate spaces\n *\n * ## Tile coordinate spaces\n * Each label has an anchor. Some labels have corresponding line geometries.\n * The points for both anchors and lines are stored in tile units. Each tile has it's own\n * coordinate space going from (0, 0) at the top left to (EXTENT, EXTENT) at the bottom right.\n *\n * ## GL coordinate space\n * At the end of everything, the vertex shader needs to produce a position in GL coordinate space,\n * which is (-1, 1) at the top left and (1, -1) in the bottom right.\n *\n * ## Map pixel coordinate spaces\n * Each tile has a pixel coordinate space. It's just the tile units scaled so that one unit is\n * whatever counts as 1 pixel at the current zoom.\n * This space is used for pitch-alignment=map, rotation-alignment=map\n *\n * ## Rotated map pixel coordinate spaces\n * Like the above, but rotated so axis of the space are aligned with the viewport instead of the tile.\n * This space is used for pitch-alignment=map, rotation-alignment=viewport\n *\n * ## Viewport pixel coordinate space\n * (0, 0) is at the top left of the canvas and (pixelWidth, pixelHeight) is at the bottom right corner\n * of the canvas. This space is used for pitch-alignment=viewport\n *\n *\n * # Vertex projection\n * It goes roughly like this:\n * 1. project the anchor and line from tile units into the correct label coordinate space\n * - map pixel space pitch-alignment=map rotation-alignment=map\n * - rotated map pixel space pitch-alignment=map rotation-alignment=viewport\n * - viewport pixel space pitch-alignment=viewport rotation-alignment=*\n * 2. if the label follows a line, find the point along the line that is the correct distance from the anchor.\n * 3. add the glyph's corner offset to the point from step 3\n * 4. convert from the label coordinate space to gl coordinates\n *\n * For horizontal labels we want to do step 1 in the shader for performance reasons (no cpu work).\n * This is what `u_label_plane_matrix` is used for.\n * For labels aligned with lines we have to steps 1 and 2 on the cpu since we need access to the line geometry.\n * This is what `updateLineLabels(...)` does.\n * Since the conversion is handled on the cpu we just set `u_label_plane_matrix` to an identity matrix.\n *\n * Steps 3 and 4 are done in the shaders for all labels.\n */\n\n/*\n * Returns a matrix for converting from tile units to the correct label coordinate space.\n */\nfunction getLabelPlaneMatrix(posMatrix: mat4,\n pitchWithMap: boolean,\n rotateWithMap: boolean,\n transform: Transform,\n pixelsToTileUnits: number) {\n const m = mat4.create();\n if (pitchWithMap) {\n mat4.scale(m, m, [1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1]);\n if (!rotateWithMap) {\n mat4.rotateZ(m, m, transform.angle);\n }\n } else {\n mat4.multiply(m, transform.labelPlaneMatrix, posMatrix);\n }\n return m;\n}\n\n/*\n * Returns a matrix for converting from the correct label coordinate space to gl coords.\n */\nfunction getGlCoordMatrix(posMatrix: mat4,\n pitchWithMap: boolean,\n rotateWithMap: boolean,\n transform: Transform,\n pixelsToTileUnits: number) {\n if (pitchWithMap) {\n const m = mat4.clone(posMatrix);\n mat4.scale(m, m, [pixelsToTileUnits, pixelsToTileUnits, 1]);\n if (!rotateWithMap) {\n mat4.rotateZ(m, m, -transform.angle);\n }\n return m;\n } else {\n return transform.glCoordMatrix;\n }\n}\n\nfunction project(point: Point, matrix: mat4, getElevation?: (x: number, y: number) => number) {\n let pos;\n if (getElevation) { // slow because of handle z-index\n pos = [point.x, point.y, getElevation(point.x, point.y), 1] as vec4;\n vec4.transformMat4(pos, pos, matrix);\n } else { // fast because of ignore z-index\n pos = [point.x, point.y, 0, 1] as vec4;\n xyTransformMat4(pos, pos, matrix);\n }\n const w = pos[3];\n return {\n point: new Point(pos[0] / w, pos[1] / w),\n signedDistanceFromCamera: w\n };\n}\n\nfunction getPerspectiveRatio(cameraToCenterDistance: number, signedDistanceFromCamera: number): number {\n return 0.5 + 0.5 * (cameraToCenterDistance / signedDistanceFromCamera);\n}\n\nfunction isVisible(anchorPos: vec4,\n clippingBuffer: [number, number]) {\n const x = anchorPos[0] / anchorPos[3];\n const y = anchorPos[1] / anchorPos[3];\n const inPaddedViewport = (\n x >= -clippingBuffer[0] &&\n x <= clippingBuffer[0] &&\n y >= -clippingBuffer[1] &&\n y <= clippingBuffer[1]);\n return inPaddedViewport;\n}\n\n/*\n * Update the `dynamicLayoutVertexBuffer` for the buffer with the correct glyph positions for the current map view.\n * This is only run on labels that are aligned with lines. Horizontal labels are handled entirely in the shader.\n */\nfunction updateLineLabels(bucket: SymbolBucket,\n posMatrix: mat4,\n painter: Painter,\n isText: boolean,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n pitchWithMap: boolean,\n keepUpright: boolean,\n rotateToLine: boolean,\n getElevation: (x: number, y: number) => number) {\n\n const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;\n const partiallyEvaluatedSize = symbolSize.evaluateSizeForZoom(sizeData, painter.transform.zoom);\n\n const clippingBuffer: [number, number] = [256 / painter.width * 2 + 1, 256 / painter.height * 2 + 1];\n\n const dynamicLayoutVertexArray = isText ?\n bucket.text.dynamicLayoutVertexArray :\n bucket.icon.dynamicLayoutVertexArray;\n dynamicLayoutVertexArray.clear();\n\n const lineVertexArray = bucket.lineVertexArray;\n const placedSymbols = isText ? bucket.text.placedSymbolArray : bucket.icon.placedSymbolArray;\n\n const aspectRatio = painter.transform.width / painter.transform.height;\n\n let useVertical = false;\n\n for (let s = 0; s < placedSymbols.length; s++) {\n const symbol = placedSymbols.get(s);\n\n // Don't do calculations for vertical glyphs unless the previous symbol was horizontal\n // and we determined that vertical glyphs were necessary.\n // Also don't do calculations for symbols that are collided and fully faded out\n if (symbol.hidden || symbol.writingMode === WritingMode.vertical && !useVertical) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n continue;\n }\n // Awkward... but we're counting on the paired \"vertical\" symbol coming immediately after its horizontal counterpart\n useVertical = false;\n\n let anchorPos;\n if (getElevation) { // slow because of handle z-index\n anchorPos = [symbol.anchorX, symbol.anchorY, getElevation(symbol.anchorX, symbol.anchorY), 1] as vec4;\n vec4.transformMat4(anchorPos, anchorPos, posMatrix);\n } else { // fast because of ignore z-index\n anchorPos = [symbol.anchorX, symbol.anchorY, 0, 1] as vec4;\n xyTransformMat4(anchorPos, anchorPos, posMatrix);\n }\n\n // Don't bother calculating the correct point for invisible labels.\n if (!isVisible(anchorPos, clippingBuffer)) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n continue;\n }\n\n const cameraToAnchorDistance = anchorPos[3];\n const perspectiveRatio = getPerspectiveRatio(painter.transform.cameraToCenterDistance, cameraToAnchorDistance);\n\n const fontSize = symbolSize.evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol);\n const pitchScaledFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;\n\n const tileAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);\n const anchorPoint = project(tileAnchorPoint, labelPlaneMatrix, getElevation).point;\n const projectionCache = {projections: {}, offsets: {}};\n\n const placeUnflipped: any = placeGlyphsAlongLine(symbol, pitchScaledFontSize, false /*unflipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix,\n bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation);\n\n useVertical = placeUnflipped.useVertical;\n\n if (placeUnflipped.notEnoughRoom || useVertical ||\n (placeUnflipped.needsFlipping &&\n (placeGlyphsAlongLine(symbol, pitchScaledFontSize, true /*flipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix,\n bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) as any).notEnoughRoom)) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n }\n }\n\n if (isText) {\n bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray);\n } else {\n bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray);\n }\n}\n\ntype FirstAndLastGlyphPlacement = {\n first: PlacedGlyph;\n last: PlacedGlyph;\n} | null;\n\n/*\n * Place the first and last glyph of a line label, projected to the label plane.\n * This function is called both during collision detection (to determine the label's size)\n * and during line label rendering (to make sure the label fits on the line geometry with\n * the current camera position, which may differ from the position used during collision detection).\n *\n * Calling this function has the effect of populating the \"projectionCache\" with all projected\n * vertex locations the label will need, making future calls to placeGlyphAlongLine (for all the\n * intermediate glyphs) much cheaper.\n *\n * Returns null if the label can't fit on the geometry\n */\nfunction placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffsetArray, lineOffsetX: number, lineOffsetY: number, flip: boolean, anchorPoint: Point, tileAnchorPoint: Point, symbol: any, lineVertexArray: SymbolLineVertexArray, labelPlaneMatrix: mat4, projectionCache: ProjectionCache, rotateToLine: boolean, getElevation: (x: number, y: number) => number): FirstAndLastGlyphPlacement {\n const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;\n const lineStartIndex = symbol.lineStartIndex;\n const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;\n\n const firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex);\n const lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1);\n\n const firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!firstPlacedGlyph)\n return null;\n\n const lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!lastPlacedGlyph)\n return null;\n\n return {first: firstPlacedGlyph, last: lastPlacedGlyph};\n}\n\nfunction requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRatio) {\n if (writingMode === WritingMode.horizontal) {\n // On top of choosing whether to flip, choose whether to render this version of the glyphs or the alternate\n // vertical glyphs. We can't just filter out vertical glyphs in the horizontal range because the horizontal\n // and vertical versions can have slightly different projections which could lead to angles where both or\n // neither showed.\n const rise = Math.abs(lastPoint.y - firstPoint.y);\n const run = Math.abs(lastPoint.x - firstPoint.x) * aspectRatio;\n if (rise > run) {\n return {useVertical: true};\n }\n }\n\n if (writingMode === WritingMode.vertical ? firstPoint.y < lastPoint.y : firstPoint.x > lastPoint.x) {\n // Includes \"horizontalOnly\" case for labels without vertical glyphs\n return {needsFlipping: true};\n }\n\n return null;\n}\n\n/*\n* Place first and last glyph along the line projected to label plane, and if they fit\n* iterate through all the intermediate glyphs, calculating their label plane positions\n* from the projected line.\n*\n* Finally, add resulting glyph position calculations to dynamicLayoutVertexArray for\n* upload to the GPU\n*/\nfunction placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) {\n const fontScale = fontSize / 24;\n const lineOffsetX = symbol.lineOffsetX * fontScale;\n const lineOffsetY = symbol.lineOffsetY * fontScale;\n\n let placedGlyphs;\n if (symbol.numGlyphs > 1) {\n const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;\n const lineStartIndex = symbol.lineStartIndex;\n const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;\n\n // Place the first and the last glyph in the label first, so we can figure out\n // the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode\n const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!firstAndLastGlyph) {\n return {notEnoughRoom: true};\n }\n const firstPoint = project(firstAndLastGlyph.first.point, glCoordMatrix, getElevation).point;\n const lastPoint = project(firstAndLastGlyph.last.point, glCoordMatrix, getElevation).point;\n\n if (keepUpright && !flip) {\n const orientationChange = requiresOrientationChange(symbol.writingMode, firstPoint, lastPoint, aspectRatio);\n if (orientationChange) {\n return orientationChange;\n }\n }\n\n placedGlyphs = [firstAndLastGlyph.first];\n for (let glyphIndex = symbol.glyphStartIndex + 1; glyphIndex < glyphEndIndex - 1; glyphIndex++) {\n // Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed\n placedGlyphs.push(placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation));\n }\n placedGlyphs.push(firstAndLastGlyph.last);\n } else {\n // Only a single glyph to place\n // So, determine whether to flip based on projected angle of the line segment it's on\n if (keepUpright && !flip) {\n const a = project(tileAnchorPoint, posMatrix, getElevation).point;\n const tileVertexIndex = (symbol.lineStartIndex + symbol.segment + 1);\n const tileSegmentEnd = new Point(lineVertexArray.getx(tileVertexIndex), lineVertexArray.gety(tileVertexIndex));\n const projectedVertex = project(tileSegmentEnd, posMatrix, getElevation);\n // We know the anchor will be in the viewport, but the end of the line segment may be\n // behind the plane of the camera, in which case we can use a point at any arbitrary (closer)\n // point on the segment.\n const b = (projectedVertex.signedDistanceFromCamera > 0) ?\n projectedVertex.point :\n projectTruncatedLineSegment(tileAnchorPoint, tileSegmentEnd, a, 1, posMatrix, getElevation);\n\n const orientationChange = requiresOrientationChange(symbol.writingMode, a, b, aspectRatio);\n if (orientationChange) {\n return orientationChange;\n }\n }\n const singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(symbol.glyphStartIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n symbol.lineStartIndex, symbol.lineStartIndex + symbol.lineLength, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!singleGlyph)\n return {notEnoughRoom: true};\n\n placedGlyphs = [singleGlyph];\n }\n\n for (const glyph of placedGlyphs) {\n addDynamicAttributes(dynamicLayoutVertexArray, glyph.point, glyph.angle);\n }\n return {};\n}\n\nfunction projectTruncatedLineSegment(previousTilePoint: Point, currentTilePoint: Point, previousProjectedPoint: Point, minimumLength: number, projectionMatrix: mat4, getElevation: (x: number, y: number) => number) {\n // We are assuming \"previousTilePoint\" won't project to a point within one unit of the camera plane\n // If it did, that would mean our label extended all the way out from within the viewport to a (very distant)\n // point near the plane of the camera. We wouldn't be able to render the label anyway once it crossed the\n // plane of the camera.\n const projectedUnitVertex = project(previousTilePoint.add(previousTilePoint.sub(currentTilePoint)._unit()), projectionMatrix, getElevation).point;\n const projectedUnitSegment = previousProjectedPoint.sub(projectedUnitVertex);\n\n return previousProjectedPoint.add(projectedUnitSegment._mult(minimumLength / projectedUnitSegment.mag()));\n}\n\ntype IndexToPointCache = { [lineIndex: number]: Point };\n\n/**\n * We calculate label-plane projected points for line vertices as we place glyphs along the line\n * Since we will use the same vertices for potentially many glyphs, cache the results for this bucket\n * over the course of the render. Each vertex location also potentially has one offset equivalent\n * for us to hold onto. The vertex indices are per-symbol-bucket.\n */\ntype ProjectionCache = {\n /**\n * tile-unit vertices projected into label-plane units\n */\n projections: IndexToPointCache;\n /**\n * label-plane vertices which have been shifted to follow an offset line\n */\n offsets: IndexToPointCache;\n};\n\n/**\n * Arguments necessary to project a vertex to the label plane\n */\ntype ProjectionArgs = {\n /**\n * Used to cache results, save cost if projecting the same vertex multiple times\n */\n projectionCache: ProjectionCache;\n /**\n * The array of tile-unit vertices transferred from worker\n */\n lineVertexArray: SymbolLineVertexArray;\n /**\n * Label plane projection matrix\n */\n labelPlaneMatrix: mat4;\n /**\n * Function to get elevation at a point\n * @param x - the x coordinate\n * @param y - the y coordinate\n */\n getElevation: (x: number, y: number) => number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n tileAnchorPoint: Point;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n distanceFromAnchor: number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n previousVertex: Point;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n direction: number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n absOffsetX: number;\n};\n\n/**\n * Transform a vertex from tile coordinates to label plane coordinates\n * @param index - index of vertex to project\n * @param projectionArgs - necessary data to project a vertex\n * @returns the vertex projected to the label plane\n */\nfunction projectVertexToViewport(index: number, projectionArgs: ProjectionArgs): Point {\n const {projectionCache, lineVertexArray, labelPlaneMatrix, tileAnchorPoint, distanceFromAnchor, getElevation, previousVertex, direction, absOffsetX} = projectionArgs;\n if (projectionCache.projections[index]) {\n return projectionCache.projections[index];\n }\n const currentVertex = new Point(lineVertexArray.getx(index), lineVertexArray.gety(index));\n const projection = project(currentVertex, labelPlaneMatrix, getElevation);\n if (projection.signedDistanceFromCamera > 0) {\n projectionCache.projections[index] = projection.point;\n return projection.point;\n }\n\n // The vertex is behind the plane of the camera, so we can't project it\n // Instead, we'll create a vertex along the line that's far enough to include the glyph\n const previousLineVertexIndex = index - direction;\n const previousTilePoint = distanceFromAnchor === 0 ?\n tileAnchorPoint :\n new Point(lineVertexArray.getx(previousLineVertexIndex), lineVertexArray.gety(previousLineVertexIndex));\n // Don't cache because the new vertex might not be far enough out for future glyphs on the same segment\n return projectTruncatedLineSegment(previousTilePoint, currentVertex, previousVertex, absOffsetX - distanceFromAnchor + 1, labelPlaneMatrix, getElevation);\n}\n\n/**\n * Calculate the normal vector for a line segment\n * @param segmentVector - will be mutated as a tiny optimization\n * @param offset - magnitude of resulting vector\n * @param direction - direction of line traversal\n * @returns a normal vector from the segment, with magnitude equal to offset amount\n */\nfunction transformToOffsetNormal(segmentVector: Point, offset: number, direction: number): Point {\n return segmentVector._unit()._perp()._mult(offset * direction);\n}\n\n/**\n * Construct offset line segments for the current segment and the next segment, then extend/shrink\n * the segments until they intersect. If the segments are parallel, then they will touch with no modification.\n *\n * @param index - Index of the current vertex\n * @param prevToCurrentOffsetNormal - Normal vector of the line segment from the previous vertex to the current vertex\n * @param currentVertex - Current (non-offset) vertex projected to the label plane\n * @param lineStartIndex - Beginning index for the line this label is on\n * @param lineEndIndex - End index for the line this label is on\n * @param offsetPreviousVertex - The previous vertex projected to the label plane, and then offset along the previous segments normal\n * @param lineOffsetY - Magnitude of the offset\n * @param projectionArgs - Necessary data for tile-to-label-plane projection\n * @returns The point at which the current and next line segments intersect, once offset and extended/shrunk to their meeting point\n */\nfunction findOffsetIntersectionPoint(index: number, prevToCurrentOffsetNormal: Point, currentVertex: Point, lineStartIndex: number, lineEndIndex: number, offsetPreviousVertex: Point, lineOffsetY: number, projectionArgs: ProjectionArgs) {\n const {projectionCache, direction} = projectionArgs;\n if (projectionCache.offsets[index]) {\n return projectionCache.offsets[index];\n }\n\n const offsetCurrentVertex = currentVertex.add(prevToCurrentOffsetNormal);\n\n if (index + direction < lineStartIndex || index + direction >= lineEndIndex) {\n // This is the end of the line, no intersection to calculate\n projectionCache.offsets[index] = offsetCurrentVertex;\n return offsetCurrentVertex;\n }\n // Offset the vertices for the next segment\n const nextVertex = projectVertexToViewport(index + direction, projectionArgs);\n const currentToNextOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction);\n const offsetNextSegmentBegin = currentVertex.add(currentToNextOffsetNormal);\n const offsetNextSegmentEnd = nextVertex.add(currentToNextOffsetNormal);\n\n // find the intersection of these two lines\n // if the lines are parallel, offsetCurrent/offsetNextBegin will touch\n projectionCache.offsets[index] = findLineIntersection(offsetPreviousVertex, offsetCurrentVertex, offsetNextSegmentBegin, offsetNextSegmentEnd) || offsetCurrentVertex;\n\n return projectionCache.offsets[index];\n}\n\n/**\n * Placed Glyph type\n */\ntype PlacedGlyph = {\n /**\n * The point at which the glyph should be placed, in label plane coordinates\n */\n point: Point;\n /**\n * The angle at which the glyph should be placed\n */\n angle: number;\n /**\n * The label-plane path used to reach this glyph: used only for collision detection\n */\n path: Array;\n};\n\n/*\n * Place a single glyph along its line, projected into the label plane, by iterating outward\n * from the anchor point until the distance traversed in the label plane equals the glyph's\n * offsetX. Returns null if the glyph can't fit on the line geometry.\n */\nfunction placeGlyphAlongLine(\n offsetX: number,\n lineOffsetX: number,\n lineOffsetY: number,\n flip: boolean,\n anchorPoint: Point,\n tileAnchorPoint: Point,\n anchorSegment: number,\n lineStartIndex: number,\n lineEndIndex: number,\n lineVertexArray: SymbolLineVertexArray,\n labelPlaneMatrix: mat4,\n projectionCache: ProjectionCache,\n rotateToLine: boolean,\n getElevation: (x: number, y: number) => number): PlacedGlyph | null {\n\n const combinedOffsetX = flip ?\n offsetX - lineOffsetX :\n offsetX + lineOffsetX;\n\n let direction = combinedOffsetX > 0 ? 1 : -1;\n\n let angle = 0;\n if (flip) {\n // The label needs to be flipped to keep text upright.\n // Iterate in the reverse direction.\n direction *= -1;\n angle = Math.PI;\n }\n\n if (direction < 0) angle += Math.PI;\n\n let currentIndex = direction > 0 ?\n lineStartIndex + anchorSegment :\n lineStartIndex + anchorSegment + 1;\n\n let currentVertex = anchorPoint;\n let previousVertex = anchorPoint;\n\n // offsetPrev and intersectionPoint are analogous to previousVertex and currentVertex\n // but if there's a line offset they are calculated in parallel as projection happens\n let offsetIntersectionPoint: Point;\n let offsetPreviousVertex: Point;\n\n let distanceFromAnchor = 0;\n let currentSegmentDistance = 0;\n const absOffsetX = Math.abs(combinedOffsetX);\n const pathVertices: Array = [];\n\n let currentLineSegment: Point;\n while (distanceFromAnchor + currentSegmentDistance <= absOffsetX) {\n currentIndex += direction;\n\n // offset does not fit on the projected line\n if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex)\n return null;\n\n // accumulate values from last iteration\n distanceFromAnchor += currentSegmentDistance;\n previousVertex = currentVertex;\n offsetPreviousVertex = offsetIntersectionPoint;\n\n const projectionArgs: ProjectionArgs = {\n projectionCache,\n lineVertexArray,\n labelPlaneMatrix,\n tileAnchorPoint,\n distanceFromAnchor,\n getElevation,\n previousVertex,\n direction,\n absOffsetX\n };\n\n // find next vertex in viewport space\n currentVertex = projectVertexToViewport(currentIndex, projectionArgs);\n if (lineOffsetY === 0) {\n // Store vertices for collision detection and update current segment geometry\n pathVertices.push(previousVertex);\n currentLineSegment = currentVertex.sub(previousVertex);\n } else {\n // Calculate the offset for this section\n let prevToCurrentOffsetNormal;\n const prevToCurrent = currentVertex.sub(previousVertex);\n if (prevToCurrent.mag() === 0) {\n // We are starting with our anchor point directly on the vertex, so look one vertex ahead\n // to calculate a normal\n const nextVertex = projectVertexToViewport(currentIndex + direction, projectionArgs);\n prevToCurrentOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction);\n } else {\n prevToCurrentOffsetNormal = transformToOffsetNormal(prevToCurrent, lineOffsetY, direction);\n }\n // Initialize offsetPrev on our first iteration, after that it will be pre-calculated\n if (!offsetPreviousVertex)\n offsetPreviousVertex = previousVertex.add(prevToCurrentOffsetNormal);\n\n offsetIntersectionPoint = findOffsetIntersectionPoint(currentIndex, prevToCurrentOffsetNormal, currentVertex, lineStartIndex, lineEndIndex, offsetPreviousVertex, lineOffsetY, projectionArgs);\n\n pathVertices.push(offsetPreviousVertex);\n currentLineSegment = offsetIntersectionPoint.sub(offsetPreviousVertex);\n }\n currentSegmentDistance = currentLineSegment.mag();\n }\n\n // The point is on the current segment. Interpolate to find it.\n const segmentInterpolationT = (absOffsetX - distanceFromAnchor) / currentSegmentDistance;\n const p = currentLineSegment._mult(segmentInterpolationT)._add(offsetPreviousVertex || previousVertex);\n\n const segmentAngle = angle + Math.atan2(currentVertex.y - previousVertex.y, currentVertex.x - previousVertex.x);\n\n pathVertices.push(p);\n\n return {\n point: p,\n angle: rotateToLine ? segmentAngle : 0.0,\n path: pathVertices\n };\n}\n\nconst hiddenGlyphAttributes = new Float32Array([-Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0]);\n\n// Hide them by moving them offscreen. We still need to add them to the buffer\n// because the dynamic buffer is paired with a static buffer that doesn't get updated.\nfunction hideGlyphs(num: number, dynamicLayoutVertexArray: SymbolDynamicLayoutArray) {\n for (let i = 0; i < num; i++) {\n const offset = dynamicLayoutVertexArray.length;\n dynamicLayoutVertexArray.resize(offset + 4);\n // Since all hidden glyphs have the same attributes, we can build up the array faster with a single call to Float32Array.set\n // for each set of four vertices, instead of calling addDynamicAttributes for each vertex.\n dynamicLayoutVertexArray.float32.set(hiddenGlyphAttributes, offset * 3);\n }\n}\n\n// For line label layout, we're not using z output and our w input is always 1\n// This custom matrix transformation ignores those components to make projection faster\nfunction xyTransformMat4(out: vec4, a: vec4, m: mat4) {\n const x = a[0], y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n out[3] = m[3] * x + m[7] * y + m[15];\n return out;\n}\n","import Point from '@mapbox/point-geometry';\nimport {clipLine} from './clip_line';\nimport {PathInterpolator} from './path_interpolator';\n\nimport * as intersectionTests from '../util/intersection_tests';\nimport {GridIndex} from './grid_index';\nimport {mat4, vec4} from 'gl-matrix';\nimport ONE_EM from '../symbol/one_em';\n\nimport * as projection from '../symbol/projection';\n\nimport type {Transform} from '../geo/transform';\nimport type {SingleCollisionBox} from '../data/bucket/symbol_bucket';\nimport type {\n GlyphOffsetArray,\n SymbolLineVertexArray\n} from '../data/array_types.g';\nimport type {OverlapMode} from '../style/style_layer/overlap_mode';\n\n// When a symbol crosses the edge that causes it to be included in\n// collision detection, it will cause changes in the symbols around\n// it. This constant specifies how many pixels to pad the edge of\n// the viewport for collision detection so that the bulk of the changes\n// occur offscreen. Making this constant greater increases label\n// stability, but it's expensive.\nconst viewportPadding = 100;\n\nexport type FeatureKey = {\n bucketInstanceId: number;\n featureIndex: number;\n collisionGroupID: number;\n overlapMode: OverlapMode;\n};\n\n/**\n * @internal\n * A collision index used to prevent symbols from overlapping. It keep tracks of\n * where previous symbols have been placed and is used to check if a new\n * symbol overlaps with any previously added symbols.\n *\n * There are two steps to insertion: first placeCollisionBox/Circles checks if\n * there's room for a symbol, then insertCollisionBox/Circles actually puts the\n * symbol in the index. The two step process allows paired symbols to be inserted\n * together even if they overlap.\n */\nexport class CollisionIndex {\n grid: GridIndex;\n ignoredGrid: GridIndex;\n transform: Transform;\n pitchfactor: number;\n screenRightBoundary: number;\n screenBottomBoundary: number;\n gridRightBoundary: number;\n gridBottomBoundary: number;\n\n // With perspectiveRatio the fontsize is calculated for tilted maps (near = bigger, far = smaller).\n // The cutoff defines a threshold to no longer render labels near the horizon.\n perspectiveRatioCutoff: number;\n\n constructor(\n transform: Transform,\n grid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25),\n ignoredGrid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25)\n ) {\n this.transform = transform;\n\n this.grid = grid;\n this.ignoredGrid = ignoredGrid;\n this.pitchfactor = Math.cos(transform._pitch) * transform.cameraToCenterDistance;\n\n this.screenRightBoundary = transform.width + viewportPadding;\n this.screenBottomBoundary = transform.height + viewportPadding;\n this.gridRightBoundary = transform.width + 2 * viewportPadding;\n this.gridBottomBoundary = transform.height + 2 * viewportPadding;\n\n this.perspectiveRatioCutoff = 0.6;\n }\n\n placeCollisionBox(\n collisionBox: SingleCollisionBox,\n overlapMode: OverlapMode,\n textPixelRatio: number,\n posMatrix: mat4,\n collisionGroupPredicate?: (key: FeatureKey) => boolean,\n getElevation?: (x: number, y: number) => number\n ): {\n box: Array;\n offscreen: boolean;\n } {\n const projectedPoint = this.projectAndGetPerspectiveRatio(posMatrix, collisionBox.anchorPointX, collisionBox.anchorPointY, getElevation);\n const tileToViewport = textPixelRatio * projectedPoint.perspectiveRatio;\n const tlX = collisionBox.x1 * tileToViewport + projectedPoint.point.x;\n const tlY = collisionBox.y1 * tileToViewport + projectedPoint.point.y;\n const brX = collisionBox.x2 * tileToViewport + projectedPoint.point.x;\n const brY = collisionBox.y2 * tileToViewport + projectedPoint.point.y;\n\n if (!this.isInsideGrid(tlX, tlY, brX, brY) ||\n (overlapMode !== 'always' && this.grid.hitTest(tlX, tlY, brX, brY, overlapMode, collisionGroupPredicate)) ||\n projectedPoint.perspectiveRatio < this.perspectiveRatioCutoff) {\n return {\n box: [],\n offscreen: false\n };\n }\n\n return {\n box: [tlX, tlY, brX, brY],\n offscreen: this.isOffscreen(tlX, tlY, brX, brY)\n };\n }\n\n placeCollisionCircles(\n overlapMode: OverlapMode,\n symbol: any,\n lineVertexArray: SymbolLineVertexArray,\n glyphOffsetArray: GlyphOffsetArray,\n fontSize: number,\n posMatrix: mat4,\n labelPlaneMatrix: mat4,\n labelToScreenMatrix: mat4,\n showCollisionCircles: boolean,\n pitchWithMap: boolean,\n collisionGroupPredicate: (key: FeatureKey) => boolean,\n circlePixelDiameter: number,\n textPixelPadding: number,\n getElevation: (x: number, y: number) => number\n ): {\n circles: Array;\n offscreen: boolean;\n collisionDetected: boolean;\n } {\n const placedCollisionCircles = [];\n\n const tileUnitAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);\n const screenAnchorPoint = projection.project(tileUnitAnchorPoint, posMatrix, getElevation);\n const perspectiveRatio = projection.getPerspectiveRatio(this.transform.cameraToCenterDistance, screenAnchorPoint.signedDistanceFromCamera);\n const labelPlaneFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;\n const labelPlaneFontScale = labelPlaneFontSize / ONE_EM;\n\n const labelPlaneAnchorPoint = projection.project(tileUnitAnchorPoint, labelPlaneMatrix, getElevation).point;\n\n const projectionCache = {projections: {}, offsets: {}};\n const lineOffsetX = symbol.lineOffsetX * labelPlaneFontScale;\n const lineOffsetY = symbol.lineOffsetY * labelPlaneFontScale;\n\n const firstAndLastGlyph = projection.placeFirstAndLastGlyph(\n labelPlaneFontScale,\n glyphOffsetArray,\n lineOffsetX,\n lineOffsetY,\n /*flip*/ false,\n labelPlaneAnchorPoint,\n tileUnitAnchorPoint,\n symbol,\n lineVertexArray,\n labelPlaneMatrix,\n projectionCache,\n false,\n getElevation);\n\n let collisionDetected = false;\n let inGrid = false;\n let entirelyOffscreen = true;\n\n if (firstAndLastGlyph) {\n const radius = circlePixelDiameter * 0.5 * perspectiveRatio + textPixelPadding;\n const screenPlaneMin = new Point(-viewportPadding, -viewportPadding);\n const screenPlaneMax = new Point(this.screenRightBoundary, this.screenBottomBoundary);\n const interpolator = new PathInterpolator();\n\n // Construct a projected path from projected line vertices. Anchor points are ignored and removed\n const first = firstAndLastGlyph.first;\n const last = firstAndLastGlyph.last;\n\n let projectedPath = [];\n for (let i = first.path.length - 1; i >= 1; i--) {\n projectedPath.push(first.path[i]);\n }\n for (let i = 1; i < last.path.length; i++) {\n projectedPath.push(last.path[i]);\n }\n\n // Tolerate a slightly longer distance than one diameter between two adjacent circles\n const circleDist = radius * 2.5;\n\n // The path might need to be converted into screen space if a pitched map is used as the label space\n if (labelToScreenMatrix) {\n const screenSpacePath = projectedPath.map(p => projection.project(p, labelToScreenMatrix, getElevation));\n\n // Do not try to place collision circles if even of the points is behind the camera.\n // This is a plausible scenario with big camera pitch angles\n if (screenSpacePath.some(point => point.signedDistanceFromCamera <= 0)) {\n projectedPath = [];\n } else {\n projectedPath = screenSpacePath.map(p => p.point);\n }\n }\n\n let segments = [];\n\n if (projectedPath.length > 0) {\n // Quickly check if the path is fully inside or outside of the padded collision region.\n // For overlapping paths we'll only create collision circles for the visible segments\n const minPoint = projectedPath[0].clone();\n const maxPoint = projectedPath[0].clone();\n\n for (let i = 1; i < projectedPath.length; i++) {\n minPoint.x = Math.min(minPoint.x, projectedPath[i].x);\n minPoint.y = Math.min(minPoint.y, projectedPath[i].y);\n maxPoint.x = Math.max(maxPoint.x, projectedPath[i].x);\n maxPoint.y = Math.max(maxPoint.y, projectedPath[i].y);\n }\n\n if (minPoint.x >= screenPlaneMin.x && maxPoint.x <= screenPlaneMax.x &&\n minPoint.y >= screenPlaneMin.y && maxPoint.y <= screenPlaneMax.y) {\n // Quad fully visible\n segments = [projectedPath];\n } else if (maxPoint.x < screenPlaneMin.x || minPoint.x > screenPlaneMax.x ||\n maxPoint.y < screenPlaneMin.y || minPoint.y > screenPlaneMax.y) {\n // Not visible\n segments = [];\n } else {\n segments = clipLine([projectedPath], screenPlaneMin.x, screenPlaneMin.y, screenPlaneMax.x, screenPlaneMax.y);\n }\n }\n\n for (const seg of segments) {\n // interpolate positions for collision circles. Add a small padding to both ends of the segment\n interpolator.reset(seg, radius * 0.25);\n\n let numCircles = 0;\n\n if (interpolator.length <= 0.5 * radius) {\n numCircles = 1;\n } else {\n numCircles = Math.ceil(interpolator.paddedLength / circleDist) + 1;\n }\n\n for (let i = 0; i < numCircles; i++) {\n const t = i / Math.max(numCircles - 1, 1);\n const circlePosition = interpolator.lerp(t);\n\n // add viewport padding to the position and perform initial collision check\n const centerX = circlePosition.x + viewportPadding;\n const centerY = circlePosition.y + viewportPadding;\n\n placedCollisionCircles.push(centerX, centerY, radius, 0);\n\n const x1 = centerX - radius;\n const y1 = centerY - radius;\n const x2 = centerX + radius;\n const y2 = centerY + radius;\n\n entirelyOffscreen = entirelyOffscreen && this.isOffscreen(x1, y1, x2, y2);\n inGrid = inGrid || this.isInsideGrid(x1, y1, x2, y2);\n\n if (overlapMode !== 'always' && this.grid.hitTestCircle(centerX, centerY, radius, overlapMode, collisionGroupPredicate)) {\n // Don't early exit if we're showing the debug circles because we still want to calculate\n // which circles are in use\n collisionDetected = true;\n if (!showCollisionCircles) {\n return {\n circles: [],\n offscreen: false,\n collisionDetected\n };\n }\n }\n }\n }\n }\n\n return {\n circles: ((!showCollisionCircles && collisionDetected) || !inGrid || perspectiveRatio < this.perspectiveRatioCutoff) ? [] : placedCollisionCircles,\n offscreen: entirelyOffscreen,\n collisionDetected\n };\n }\n\n /**\n * Because the geometries in the CollisionIndex are an approximation of the shape of\n * symbols on the map, we use the CollisionIndex to look up the symbol part of\n * `queryRenderedFeatures`.\n */\n queryRenderedSymbols(viewportQueryGeometry: Array) {\n if (viewportQueryGeometry.length === 0 || (this.grid.keysLength() === 0 && this.ignoredGrid.keysLength() === 0)) {\n return {};\n }\n\n const query = [];\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const point of viewportQueryGeometry) {\n const gridPoint = new Point(point.x + viewportPadding, point.y + viewportPadding);\n minX = Math.min(minX, gridPoint.x);\n minY = Math.min(minY, gridPoint.y);\n maxX = Math.max(maxX, gridPoint.x);\n maxY = Math.max(maxY, gridPoint.y);\n query.push(gridPoint);\n }\n\n const features = this.grid.query(minX, minY, maxX, maxY)\n .concat(this.ignoredGrid.query(minX, minY, maxX, maxY));\n\n const seenFeatures = {};\n const result = {};\n\n for (const feature of features) {\n const featureKey = feature.key;\n // Skip already seen features.\n if (seenFeatures[featureKey.bucketInstanceId] === undefined) {\n seenFeatures[featureKey.bucketInstanceId] = {};\n }\n if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) {\n continue;\n }\n\n // Check if query intersects with the feature box\n // \"Collision Circles\" for line labels are treated as boxes here\n // Since there's no actual collision taking place, the circle vs. square\n // distinction doesn't matter as much, and box geometry is easier\n // to work with.\n const bbox = [\n new Point(feature.x1, feature.y1),\n new Point(feature.x2, feature.y1),\n new Point(feature.x2, feature.y2),\n new Point(feature.x1, feature.y2)\n ];\n if (!intersectionTests.polygonIntersectsPolygon(query, bbox)) {\n continue;\n }\n\n seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true;\n if (result[featureKey.bucketInstanceId] === undefined) {\n result[featureKey.bucketInstanceId] = [];\n }\n result[featureKey.bucketInstanceId].push(featureKey.featureIndex);\n }\n\n return result;\n }\n\n insertCollisionBox(collisionBox: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) {\n const grid = ignorePlacement ? this.ignoredGrid : this.grid;\n\n const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode};\n grid.insert(key, collisionBox[0], collisionBox[1], collisionBox[2], collisionBox[3]);\n }\n\n insertCollisionCircles(collisionCircles: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) {\n const grid = ignorePlacement ? this.ignoredGrid : this.grid;\n\n const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode};\n for (let k = 0; k < collisionCircles.length; k += 4) {\n grid.insertCircle(key, collisionCircles[k], collisionCircles[k + 1], collisionCircles[k + 2]);\n }\n }\n\n projectAndGetPerspectiveRatio(posMatrix: mat4, x: number, y: number, getElevation?: (x: number, y: number) => number) {\n let p;\n if (getElevation) { // slow because of handle z-index\n p = [x, y, getElevation(x, y), 1] as vec4;\n vec4.transformMat4(p, p, posMatrix);\n } else { // fast because of ignore z-index\n p = [x, y, 0, 1] as vec4;\n projection.xyTransformMat4(p, p, posMatrix);\n }\n const a = new Point(\n (((p[0] / p[3] + 1) / 2) * this.transform.width) + viewportPadding,\n (((-p[1] / p[3] + 1) / 2) * this.transform.height) + viewportPadding\n );\n return {\n point: a,\n // See perspective ratio comment in symbol_sdf.vertex\n // We're doing collision detection in viewport space so we need\n // to scale down boxes in the distance\n perspectiveRatio: 0.5 + 0.5 * (this.transform.cameraToCenterDistance / p[3])\n };\n }\n\n isOffscreen(x1: number, y1: number, x2: number, y2: number) {\n return x2 < viewportPadding || x1 >= this.screenRightBoundary || y2 < viewportPadding || y1 > this.screenBottomBoundary;\n }\n\n isInsideGrid(x1: number, y1: number, x2: number, y2: number) {\n return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary;\n }\n\n /*\n * Returns a matrix for transforming collision shapes to viewport coordinate space.\n * Use this function to render e.g. collision circles on the screen.\n * example transformation: clipPos = glCoordMatrix * viewportMatrix * circle_pos\n */\n getViewportMatrix() {\n const m = mat4.identity([] as any);\n mat4.translate(m, m, [-viewportPadding, -viewportPadding, 0.0]);\n return m;\n }\n}\n","import {EXTENT} from '../data/extent';\n\nimport type {OverscaledTileID} from './tile_id';\n\n/**\n * Converts a pixel value at a the given zoom level to tile units.\n *\n * The shaders mostly calculate everything in tile units so style\n * properties need to be converted from pixels to tile units using this.\n *\n * For example, a translation by 30 pixels at zoom 6.5 will be a\n * translation by pixelsToTileUnits(30, 6.5) tile units.\n *\n * @returns value in tile units\n */\nexport function pixelsToTileUnits(\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n },\n pixelValue: number,\n z: number\n): number {\n return pixelValue * (EXTENT / (tile.tileSize * Math.pow(2, z - tile.tileID.overscaledZ)));\n}\n","import {CollisionIndex} from './collision_index';\nimport type {FeatureKey} from './collision_index';\nimport {EXTENT} from '../data/extent';\nimport * as symbolSize from './symbol_size';\nimport * as projection from './projection';\nimport {getAnchorJustification} from './symbol_layout';\nimport {getAnchorAlignment, WritingMode} from './shaping';\nimport {mat4} from 'gl-matrix';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport Point from '@mapbox/point-geometry';\nimport type {Transform} from '../geo/transform';\nimport type {StyleLayer} from '../style/style_layer';\nimport {PossiblyEvaluated} from '../style/properties';\nimport type {SymbolLayoutProps, SymbolLayoutPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties.g';\nimport {getOverlapMode, OverlapMode} from '../style/style_layer/overlap_mode';\n\nimport type {Tile} from '../source/tile';\nimport {SymbolBucket, CollisionArrays, SingleCollisionBox} from '../data/bucket/symbol_bucket';\n\nimport type {CollisionBoxArray, CollisionVertexArray, SymbolInstance, TextAnchorOffset} from '../data/array_types.g';\nimport type {FeatureIndex} from '../data/feature_index';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {Terrain} from '../render/terrain';\nimport {warnOnce} from '../util/util';\nimport {TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\nclass OpacityState {\n opacity: number;\n placed: boolean;\n constructor(prevState: OpacityState, increment: number, placed: boolean, skipFade?: boolean | null) {\n if (prevState) {\n this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment)));\n } else {\n this.opacity = (skipFade && placed) ? 1 : 0;\n }\n this.placed = placed;\n }\n isHidden() {\n return this.opacity === 0 && !this.placed;\n }\n}\n\nclass JointOpacityState {\n text: OpacityState;\n icon: OpacityState;\n constructor(prevState: JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null) {\n this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade);\n this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade);\n }\n isHidden() {\n return this.text.isHidden() && this.icon.isHidden();\n }\n}\n\nclass JointPlacement {\n text: boolean;\n icon: boolean;\n // skipFade = outside viewport, but within CollisionIndex::viewportPadding px of the edge\n // Because these symbols aren't onscreen yet, we can skip the \"fade in\" animation,\n // and if a subsequent viewport change brings them into view, they'll be fully\n // visible right away.\n skipFade: boolean;\n constructor(text: boolean, icon: boolean, skipFade: boolean) {\n this.text = text;\n this.icon = icon;\n this.skipFade = skipFade;\n }\n}\n\nclass CollisionCircleArray {\n // Stores collision circles and placement matrices of a bucket for debug rendering.\n invProjMatrix: mat4;\n viewportMatrix: mat4;\n circles: Array;\n\n constructor() {\n this.invProjMatrix = mat4.create();\n this.viewportMatrix = mat4.create();\n this.circles = [];\n }\n}\n\nexport class RetainedQueryData {\n bucketInstanceId: number;\n featureIndex: FeatureIndex;\n sourceLayerIndex: number;\n bucketIndex: number;\n tileID: OverscaledTileID;\n featureSortOrder: Array;\n constructor(bucketInstanceId: number,\n featureIndex: FeatureIndex,\n sourceLayerIndex: number,\n bucketIndex: number,\n tileID: OverscaledTileID) {\n this.bucketInstanceId = bucketInstanceId;\n this.featureIndex = featureIndex;\n this.sourceLayerIndex = sourceLayerIndex;\n this.bucketIndex = bucketIndex;\n this.tileID = tileID;\n }\n}\n\ntype CollisionGroup = {\n ID: number;\n predicate?: (key: FeatureKey) => boolean;\n};\n\nclass CollisionGroups {\n collisionGroups: {[groupName: string]: CollisionGroup};\n maxGroupID: number;\n crossSourceCollisions: boolean;\n\n constructor(crossSourceCollisions: boolean) {\n this.crossSourceCollisions = crossSourceCollisions;\n this.maxGroupID = 0;\n this.collisionGroups = {};\n }\n\n get(sourceID: string) {\n // The predicate/groupID mechanism allows for arbitrary grouping,\n // but the current interface defines one source == one group when\n // crossSourceCollisions == true.\n if (!this.crossSourceCollisions) {\n if (!this.collisionGroups[sourceID]) {\n const nextGroupID = ++this.maxGroupID;\n this.collisionGroups[sourceID] = {\n ID: nextGroupID,\n predicate: (key) => {\n return key.collisionGroupID === nextGroupID;\n }\n };\n }\n return this.collisionGroups[sourceID];\n } else {\n return {ID: 0, predicate: null};\n }\n }\n}\n\nfunction calculateVariableLayoutShift(\n anchor: TextAnchor,\n width: number,\n height: number,\n textOffset: [number, number],\n textBoxScale: number\n): Point {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);\n const shiftX = -(horizontalAlign - 0.5) * width;\n const shiftY = -(verticalAlign - 0.5) * height;\n return new Point(\n shiftX + textOffset[0] * textBoxScale,\n shiftY + textOffset[1] * textBoxScale\n );\n}\n\nfunction shiftVariableCollisionBox(collisionBox: SingleCollisionBox,\n shiftX: number, shiftY: number,\n rotateWithMap: boolean, pitchWithMap: boolean,\n angle: number) {\n const {x1, x2, y1, y2, anchorPointX, anchorPointY} = collisionBox;\n const rotatedOffset = new Point(shiftX, shiftY);\n if (rotateWithMap) {\n rotatedOffset._rotate(pitchWithMap ? angle : -angle);\n }\n return {\n x1: x1 + rotatedOffset.x,\n y1: y1 + rotatedOffset.y,\n x2: x2 + rotatedOffset.x,\n y2: y2 + rotatedOffset.y,\n // symbol anchor point stays the same regardless of text-anchor\n anchorPointX,\n anchorPointY\n };\n}\n\nexport type VariableOffset = {\n textOffset: [number, number];\n width: number;\n height: number;\n anchor: TextAnchor;\n textBoxScale: number;\n prevAnchor?: TextAnchor;\n};\n\ntype TileLayerParameters = {\n bucket: SymbolBucket;\n layout: PossiblyEvaluated;\n posMatrix: mat4;\n textLabelPlaneMatrix: mat4;\n labelToScreenMatrix: mat4;\n scale: number;\n textPixelRatio: number;\n holdingForFade: boolean;\n collisionBoxArray: CollisionBoxArray;\n partiallyEvaluatedTextSize: {\n uSize: number;\n uSizeT: number;\n };\n collisionGroup: CollisionGroup;\n};\n\nexport type BucketPart = {\n sortKey?: number | void;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n parameters: TileLayerParameters;\n};\n\nexport type CrossTileID = string | number;\n\nexport class Placement {\n transform: Transform;\n terrain: Terrain;\n collisionIndex: CollisionIndex;\n placements: {\n [_ in CrossTileID]: JointPlacement;\n };\n opacities: {\n [_ in CrossTileID]: JointOpacityState;\n };\n variableOffsets: {\n [_ in CrossTileID]: VariableOffset;\n };\n placedOrientations: {\n [_ in CrossTileID]: number;\n };\n commitTime: number;\n prevZoomAdjustment: number;\n lastPlacementChangeTime: number;\n stale: boolean;\n fadeDuration: number;\n retainedQueryData: {\n [_: number]: RetainedQueryData;\n };\n collisionGroups: CollisionGroups;\n prevPlacement: Placement;\n zoomAtLastRecencyCheck: number;\n collisionCircleArrays: {\n [k in any]: CollisionCircleArray;\n };\n\n constructor(transform: Transform, terrain: Terrain, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement) {\n this.transform = transform.clone();\n this.terrain = terrain;\n this.collisionIndex = new CollisionIndex(this.transform);\n this.placements = {};\n this.opacities = {};\n this.variableOffsets = {};\n this.stale = false;\n this.commitTime = 0;\n this.fadeDuration = fadeDuration;\n this.retainedQueryData = {};\n this.collisionGroups = new CollisionGroups(crossSourceCollisions);\n this.collisionCircleArrays = {};\n\n this.prevPlacement = prevPlacement;\n if (prevPlacement) {\n prevPlacement.prevPlacement = undefined; // Only hold on to one placement back\n }\n\n this.placedOrientations = {};\n }\n\n getBucketParts(results: Array, styleLayer: StyleLayer, tile: Tile, sortAcrossTiles: boolean) {\n const symbolBucket = (tile.getBucket(styleLayer) as SymbolBucket);\n const bucketFeatureIndex = tile.latestFeatureIndex;\n if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0])\n return;\n\n const collisionBoxArray = tile.collisionBoxArray;\n\n const layout = symbolBucket.layers[0].layout;\n\n const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ);\n const textPixelRatio = tile.tileSize / EXTENT;\n\n const posMatrix = this.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pixelsToTiles = pixelsToTileUnits(tile, 1, this.transform.zoom);\n\n const textLabelPlaneMatrix = projection.getLabelPlaneMatrix(posMatrix,\n pitchWithMap,\n rotateWithMap,\n this.transform,\n pixelsToTiles);\n\n let labelToScreenMatrix = null;\n\n if (pitchWithMap) {\n const glMatrix = projection.getGlCoordMatrix(\n posMatrix,\n pitchWithMap,\n rotateWithMap,\n this.transform,\n pixelsToTiles);\n\n labelToScreenMatrix = mat4.multiply([] as any, this.transform.labelPlaneMatrix, glMatrix);\n }\n\n // As long as this placement lives, we have to hold onto this bucket's\n // matching FeatureIndex/data for querying purposes\n this.retainedQueryData[symbolBucket.bucketInstanceId] = new RetainedQueryData(\n symbolBucket.bucketInstanceId,\n bucketFeatureIndex,\n symbolBucket.sourceLayerIndex,\n symbolBucket.index,\n tile.tileID\n );\n\n const parameters = {\n bucket: symbolBucket,\n layout,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n scale,\n textPixelRatio,\n holdingForFade: tile.holdingForFade(),\n collisionBoxArray,\n partiallyEvaluatedTextSize: symbolSize.evaluateSizeForZoom(symbolBucket.textSizeData, this.transform.zoom),\n collisionGroup: this.collisionGroups.get(symbolBucket.sourceID)\n };\n\n if (sortAcrossTiles) {\n for (const range of symbolBucket.sortKeyRanges) {\n const {sortKey, symbolInstanceStart, symbolInstanceEnd} = range;\n results.push({sortKey, symbolInstanceStart, symbolInstanceEnd, parameters});\n }\n } else {\n results.push({\n symbolInstanceStart: 0,\n symbolInstanceEnd: symbolBucket.symbolInstances.length,\n parameters\n });\n }\n }\n\n attemptAnchorPlacement(\n textAnchorOffset: TextAnchorOffset,\n textBox: SingleCollisionBox,\n width: number,\n height: number,\n textBoxScale: number,\n rotateWithMap: boolean,\n pitchWithMap: boolean,\n textPixelRatio: number,\n posMatrix: mat4,\n collisionGroup: CollisionGroup,\n textOverlapMode: OverlapMode,\n symbolInstance: SymbolInstance,\n bucket: SymbolBucket,\n orientation: number,\n iconBox?: SingleCollisionBox | null,\n getElevation?: (x: number, y: number) => number\n ): {\n shift: Point;\n placedGlyphBoxes: {\n box: Array;\n offscreen: boolean;\n };\n } {\n\n const anchor = TextAnchorEnum[textAnchorOffset.textAnchor] as TextAnchor;\n const textOffset = [textAnchorOffset.textOffset0, textAnchorOffset.textOffset1] as [number, number];\n const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale);\n\n const placedGlyphBoxes = this.collisionIndex.placeCollisionBox(\n shiftVariableCollisionBox(\n textBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle),\n textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n\n if (iconBox) {\n const placedIconBoxes = this.collisionIndex.placeCollisionBox(\n shiftVariableCollisionBox(\n iconBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle),\n textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n if (placedIconBoxes.box.length === 0) return;\n }\n\n if (placedGlyphBoxes.box.length > 0) {\n let prevAnchor;\n // If this label was placed in the previous placement, record the anchor position\n // to allow us to animate the transition\n if (this.prevPlacement &&\n this.prevPlacement.variableOffsets[symbolInstance.crossTileID] &&\n this.prevPlacement.placements[symbolInstance.crossTileID] &&\n this.prevPlacement.placements[symbolInstance.crossTileID].text) {\n prevAnchor = this.prevPlacement.variableOffsets[symbolInstance.crossTileID].anchor;\n }\n if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\\'t be 0');\n this.variableOffsets[symbolInstance.crossTileID] = {\n textOffset,\n width,\n height,\n anchor,\n textBoxScale,\n prevAnchor\n };\n this.markUsedJustification(bucket, anchor, symbolInstance, orientation);\n\n if (bucket.allowVerticalPlacement) {\n this.markUsedOrientation(bucket, orientation, symbolInstance);\n this.placedOrientations[symbolInstance.crossTileID] = orientation;\n }\n\n return {shift, placedGlyphBoxes};\n }\n }\n\n placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: {\n [k in string | number]: boolean;\n }, showCollisionBoxes: boolean) {\n\n const {\n bucket,\n layout,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n textPixelRatio,\n holdingForFade,\n collisionBoxArray,\n partiallyEvaluatedTextSize,\n collisionGroup\n } = bucketPart.parameters;\n\n const textOptional = layout.get('text-optional');\n const iconOptional = layout.get('icon-optional');\n const textOverlapMode = getOverlapMode(layout, 'text-overlap', 'text-allow-overlap');\n const textAlwaysOverlap = textOverlapMode === 'always';\n const iconOverlapMode = getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap');\n const iconAlwaysOverlap = iconOverlapMode === 'always';\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const hasIconTextFit = layout.get('icon-text-fit') !== 'none';\n const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y';\n\n // This logic is similar to the \"defaultOpacityState\" logic below in updateBucketOpacities\n // If we know a symbol is always supposed to show, force it to be marked visible even if\n // it wasn't placed into the collision index (because some or all of it was outside the range\n // of the collision grid).\n // There is a subtle edge case here we're accepting:\n // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false\n // A's icon is outside the grid, so doesn't get placed\n // A's text would be inside grid, but doesn't get placed because of icon-optional: false\n // We still show A because of the allow-overlap settings.\n // Symbol B has allow-overlap: false, and gets placed where A's text would be\n // On panning in, there is a short period when Symbol B and Symbol A will overlap\n // This is the reverse of our normal policy of \"fade in on pan\", but should look like any other\n // collision and hopefully not be too noticeable.\n // See https://github.com/mapbox/mapbox-gl-js/issues/7172\n const alwaysShowText = textAlwaysOverlap && (iconAlwaysOverlap || !bucket.hasIconData() || iconOptional);\n const alwaysShowIcon = iconAlwaysOverlap && (textAlwaysOverlap || !bucket.hasTextData() || textOptional);\n\n if (!bucket.collisionArrays && collisionBoxArray) {\n bucket.deserializeCollisionBoxes(collisionBoxArray);\n }\n\n const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID;\n const getElevation = this.terrain ? (x: number, y: number) => this.terrain.getElevation(tileID, x, y) : null;\n\n const placeSymbol = (symbolInstance: SymbolInstance, collisionArrays: CollisionArrays) => {\n if (seenCrossTileIDs[symbolInstance.crossTileID]) return;\n if (holdingForFade) {\n // Mark all symbols from this tile as \"not placed\", but don't add to seenCrossTileIDs, because we don't\n // know yet if we have a duplicate in a parent tile that _should_ be placed.\n this.placements[symbolInstance.crossTileID] = new JointPlacement(false, false, false);\n return;\n }\n\n let placeText = false;\n let placeIcon = false;\n let offscreen = true;\n let shift = null;\n\n let placed = {box: null, offscreen: null};\n let placedVerticalText = {box: null, offscreen: null};\n\n let placedGlyphBoxes = null;\n let placedGlyphCircles = null;\n let placedIconBoxes = null;\n let textFeatureIndex = 0;\n let verticalTextFeatureIndex = 0;\n let iconFeatureIndex = 0;\n\n if (collisionArrays.textFeatureIndex) {\n textFeatureIndex = collisionArrays.textFeatureIndex;\n } else if (symbolInstance.useRuntimeCollisionCircles) {\n textFeatureIndex = symbolInstance.featureIndex;\n }\n if (collisionArrays.verticalTextFeatureIndex) {\n verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex;\n }\n\n const textBox = collisionArrays.textBox;\n if (textBox) {\n\n const updatePreviousOrientationIfNotPlaced = (isPlaced) => {\n let previousOrientation = WritingMode.horizontal;\n if (bucket.allowVerticalPlacement && !isPlaced && this.prevPlacement) {\n const prevPlacedOrientation = this.prevPlacement.placedOrientations[symbolInstance.crossTileID];\n if (prevPlacedOrientation) {\n this.placedOrientations[symbolInstance.crossTileID] = prevPlacedOrientation;\n previousOrientation = prevPlacedOrientation;\n this.markUsedOrientation(bucket, previousOrientation, symbolInstance);\n }\n }\n return previousOrientation;\n };\n\n const placeTextForPlacementModes = (placeHorizontalFn, placeVerticalFn) => {\n if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && collisionArrays.verticalTextBox) {\n for (const placementMode of bucket.writingModes) {\n if (placementMode === WritingMode.vertical) {\n placed = placeVerticalFn();\n placedVerticalText = placed;\n } else {\n placed = placeHorizontalFn();\n }\n if (placed && placed.box && placed.box.length) break;\n }\n } else {\n placed = placeHorizontalFn();\n }\n };\n\n const textAnchorOffsetStart = symbolInstance.textAnchorOffsetStartIndex;\n const textAnchorOffsetEnd = symbolInstance.textAnchorOffsetEndIndex;\n\n // If start+end indices match, text-variable-anchor is not in play.\n if (textAnchorOffsetEnd === textAnchorOffsetStart) {\n const placeBox = (collisionTextBox, orientation) => {\n const placedFeature = this.collisionIndex.placeCollisionBox(\n collisionTextBox,\n textOverlapMode,\n textPixelRatio,\n posMatrix,\n collisionGroup.predicate,\n getElevation\n );\n if (placedFeature && placedFeature.box && placedFeature.box.length) {\n this.markUsedOrientation(bucket, orientation, symbolInstance);\n this.placedOrientations[symbolInstance.crossTileID] = orientation;\n }\n return placedFeature;\n };\n\n const placeHorizontal = () => {\n return placeBox(textBox, WritingMode.horizontal);\n };\n\n const placeVertical = () => {\n const verticalTextBox = collisionArrays.verticalTextBox;\n if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {\n return placeBox(verticalTextBox, WritingMode.vertical);\n }\n return {box: null, offscreen: null};\n };\n\n placeTextForPlacementModes(placeHorizontal, placeVertical);\n updatePreviousOrientationIfNotPlaced(placed && placed.box && placed.box.length);\n\n } else {\n // If this symbol was in the last placement, prefer placement using same anchor, if it's still available\n let prevAnchor = TextAnchorEnum[this.prevPlacement?.variableOffsets[symbolInstance.crossTileID]?.anchor];\n\n const placeBoxForVariableAnchors = (collisionTextBox, collisionIconBox, orientation) => {\n const width = collisionTextBox.x2 - collisionTextBox.x1;\n const height = collisionTextBox.y2 - collisionTextBox.y1;\n const textBoxScale = symbolInstance.textBoxScale;\n const variableIconBox = hasIconTextFit && (iconOverlapMode === 'never') ? collisionIconBox : null;\n\n let placedBox: {\n box: Array;\n offscreen: boolean;\n } = {box: [], offscreen: false};\n let placementPasses = (textOverlapMode === 'never') ? 1 : 2;\n let overlapMode: OverlapMode = 'never';\n\n if (prevAnchor) {\n placementPasses++;\n }\n\n for (let pass = 0; pass < placementPasses; pass++) {\n for (let i = textAnchorOffsetStart; i < textAnchorOffsetEnd; i++) {\n const textAnchorOffset = bucket.textAnchorOffsets.get(i);\n\n if (prevAnchor && textAnchorOffset.textAnchor !== prevAnchor) {\n continue;\n }\n\n const result = this.attemptAnchorPlacement(\n textAnchorOffset, collisionTextBox, width, height,\n textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix,\n collisionGroup, overlapMode, symbolInstance, bucket, orientation, variableIconBox, getElevation);\n\n if (result) {\n placedBox = result.placedGlyphBoxes;\n if (placedBox && placedBox.box && placedBox.box.length) {\n placeText = true;\n shift = result.shift;\n return placedBox;\n }\n }\n }\n\n if (prevAnchor) {\n prevAnchor = null;\n } else {\n overlapMode = textOverlapMode;\n }\n }\n\n return placedBox;\n };\n\n const placeHorizontal = () => {\n return placeBoxForVariableAnchors(textBox, collisionArrays.iconBox, WritingMode.horizontal);\n };\n\n const placeVertical = () => {\n const verticalTextBox = collisionArrays.verticalTextBox;\n const wasPlaced = placed && placed.box && placed.box.length;\n if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {\n return placeBoxForVariableAnchors(verticalTextBox, collisionArrays.verticalIconBox, WritingMode.vertical);\n }\n return {box: null, offscreen: null};\n };\n\n placeTextForPlacementModes(placeHorizontal, placeVertical);\n\n if (placed) {\n placeText = placed.box;\n offscreen = placed.offscreen;\n }\n\n const prevOrientation = updatePreviousOrientationIfNotPlaced(placed && placed.box);\n\n // If we didn't get placed, we still need to copy our position from the last placement for\n // fade animations\n if (!placeText && this.prevPlacement) {\n const prevOffset = this.prevPlacement.variableOffsets[symbolInstance.crossTileID];\n if (prevOffset) {\n this.variableOffsets[symbolInstance.crossTileID] = prevOffset;\n this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, prevOrientation);\n }\n }\n\n }\n }\n\n placedGlyphBoxes = placed;\n placeText = placedGlyphBoxes && placedGlyphBoxes.box && placedGlyphBoxes.box.length > 0;\n\n offscreen = placedGlyphBoxes && placedGlyphBoxes.offscreen;\n\n if (symbolInstance.useRuntimeCollisionCircles) {\n const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.centerJustifiedTextSymbolIndex);\n const fontSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol);\n\n const textPixelPadding = layout.get('text-padding');\n const circlePixelDiameter = symbolInstance.collisionCircleDiameter;\n\n placedGlyphCircles = this.collisionIndex.placeCollisionCircles(\n textOverlapMode,\n placedSymbol,\n bucket.lineVertexArray,\n bucket.glyphOffsetArray,\n fontSize,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n showCollisionBoxes,\n pitchWithMap,\n collisionGroup.predicate,\n circlePixelDiameter,\n textPixelPadding,\n getElevation\n );\n\n if (placedGlyphCircles.circles.length && placedGlyphCircles.collisionDetected && !showCollisionBoxes) {\n warnOnce('Collisions detected, but collision boxes are not shown');\n }\n\n // If text-overlap is set to 'always', force \"placedCircles\" to true\n // In theory there should always be at least one circle placed\n // in this case, but for now quirks in text-anchor\n // and text-offset may prevent that from being true.\n placeText = textAlwaysOverlap || (placedGlyphCircles.circles.length > 0 && !placedGlyphCircles.collisionDetected);\n offscreen = offscreen && placedGlyphCircles.offscreen;\n }\n\n if (collisionArrays.iconFeatureIndex) {\n iconFeatureIndex = collisionArrays.iconFeatureIndex;\n }\n\n if (collisionArrays.iconBox) {\n const placeIconFeature = iconBox => {\n const shiftedIconBox = hasIconTextFit && shift ?\n shiftVariableCollisionBox(\n iconBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle) :\n iconBox;\n return this.collisionIndex.placeCollisionBox(shiftedIconBox,\n iconOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n };\n\n if (placedVerticalText && placedVerticalText.box && placedVerticalText.box.length && collisionArrays.verticalIconBox) {\n placedIconBoxes = placeIconFeature(collisionArrays.verticalIconBox);\n placeIcon = placedIconBoxes.box.length > 0;\n } else {\n placedIconBoxes = placeIconFeature(collisionArrays.iconBox);\n placeIcon = placedIconBoxes.box.length > 0;\n }\n offscreen = offscreen && placedIconBoxes.offscreen;\n }\n\n const iconWithoutText = textOptional ||\n (symbolInstance.numHorizontalGlyphVertices === 0 && symbolInstance.numVerticalGlyphVertices === 0);\n const textWithoutIcon = iconOptional || symbolInstance.numIconVertices === 0;\n\n // Combine the scales for icons and text.\n if (!iconWithoutText && !textWithoutIcon) {\n placeIcon = placeText = placeIcon && placeText;\n } else if (!textWithoutIcon) {\n placeText = placeIcon && placeText;\n } else if (!iconWithoutText) {\n placeIcon = placeIcon && placeText;\n }\n\n if (placeText && placedGlyphBoxes && placedGlyphBoxes.box) {\n if (placedVerticalText && placedVerticalText.box && verticalTextFeatureIndex) {\n this.collisionIndex.insertCollisionBox(\n placedGlyphBoxes.box,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n verticalTextFeatureIndex,\n collisionGroup.ID);\n } else {\n this.collisionIndex.insertCollisionBox(\n placedGlyphBoxes.box,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n textFeatureIndex,\n collisionGroup.ID);\n }\n\n }\n if (placeIcon && placedIconBoxes) {\n this.collisionIndex.insertCollisionBox(\n placedIconBoxes.box,\n iconOverlapMode,\n layout.get('icon-ignore-placement'),\n bucket.bucketInstanceId,\n iconFeatureIndex,\n collisionGroup.ID);\n }\n if (placedGlyphCircles) {\n if (placeText) {\n this.collisionIndex.insertCollisionCircles(\n placedGlyphCircles.circles,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n textFeatureIndex,\n collisionGroup.ID);\n }\n\n if (showCollisionBoxes) {\n const id = bucket.bucketInstanceId;\n let circleArray = this.collisionCircleArrays[id];\n\n // Group collision circles together by bucket. Circles can't be pushed forward for rendering yet as the symbol placement\n // for a bucket is not guaranteed to be complete before the commit-function has been called\n if (circleArray === undefined)\n circleArray = this.collisionCircleArrays[id] = new CollisionCircleArray();\n\n for (let i = 0; i < placedGlyphCircles.circles.length; i += 4) {\n circleArray.circles.push(placedGlyphCircles.circles[i + 0]); // x\n circleArray.circles.push(placedGlyphCircles.circles[i + 1]); // y\n circleArray.circles.push(placedGlyphCircles.circles[i + 2]); // radius\n circleArray.circles.push(placedGlyphCircles.collisionDetected ? 1 : 0); // collisionDetected-flag\n }\n }\n }\n\n if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\\'t be 0');\n if (bucket.bucketInstanceId === 0) throw new Error('bucket.bucketInstanceId can\\'t be 0');\n\n this.placements[symbolInstance.crossTileID] = new JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded);\n seenCrossTileIDs[symbolInstance.crossTileID] = true;\n };\n\n if (zOrderByViewportY) {\n if (bucketPart.symbolInstanceStart !== 0) throw new Error('bucket.bucketInstanceId should be 0');\n const symbolIndexes = bucket.getSortedSymbolIndexes(this.transform.angle);\n for (let i = symbolIndexes.length - 1; i >= 0; --i) {\n const symbolIndex = symbolIndexes[i];\n placeSymbol(bucket.symbolInstances.get(symbolIndex), bucket.collisionArrays[symbolIndex]);\n }\n } else {\n for (let i = bucketPart.symbolInstanceStart; i < bucketPart.symbolInstanceEnd; i++) {\n placeSymbol(bucket.symbolInstances.get(i), bucket.collisionArrays[i]);\n }\n }\n\n if (showCollisionBoxes && bucket.bucketInstanceId in this.collisionCircleArrays) {\n const circleArray = this.collisionCircleArrays[bucket.bucketInstanceId];\n\n // Store viewport and inverse projection matrices per bucket\n mat4.invert(circleArray.invProjMatrix, posMatrix);\n circleArray.viewportMatrix = this.collisionIndex.getViewportMatrix();\n }\n\n bucket.justReloaded = false;\n }\n\n markUsedJustification(bucket: SymbolBucket, placedAnchor: TextAnchor, symbolInstance: SymbolInstance, orientation: number) {\n const justifications = {\n 'left': symbolInstance.leftJustifiedTextSymbolIndex,\n 'center': symbolInstance.centerJustifiedTextSymbolIndex,\n 'right': symbolInstance.rightJustifiedTextSymbolIndex\n };\n\n let autoIndex;\n if (orientation === WritingMode.vertical) {\n autoIndex = symbolInstance.verticalPlacedTextSymbolIndex;\n } else {\n autoIndex = justifications[getAnchorJustification(placedAnchor)];\n }\n\n const indexes = [\n symbolInstance.leftJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.verticalPlacedTextSymbolIndex\n ];\n\n for (const index of indexes) {\n if (index >= 0) {\n if (autoIndex >= 0 && index !== autoIndex) {\n // There are multiple justifications and this one isn't it: shift offscreen\n bucket.text.placedSymbolArray.get(index).crossTileID = 0;\n } else {\n // Either this is the chosen justification or the justification is hardwired: use this one\n bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID;\n }\n }\n }\n }\n\n markUsedOrientation(bucket: SymbolBucket, orientation: number, symbolInstance: SymbolInstance) {\n const horizontal = (orientation === WritingMode.horizontal || orientation === WritingMode.horizontalOnly) ? orientation : 0;\n const vertical = orientation === WritingMode.vertical ? orientation : 0;\n\n const horizontalIndexes = [\n symbolInstance.leftJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.rightJustifiedTextSymbolIndex\n ];\n\n for (const index of horizontalIndexes) {\n bucket.text.placedSymbolArray.get(index).placedOrientation = horizontal;\n }\n\n if (symbolInstance.verticalPlacedTextSymbolIndex) {\n bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).placedOrientation = vertical;\n }\n }\n\n commit(now: number): void {\n this.commitTime = now;\n this.zoomAtLastRecencyCheck = this.transform.zoom;\n\n const prevPlacement = this.prevPlacement;\n let placementChanged = false;\n\n this.prevZoomAdjustment = prevPlacement ? prevPlacement.zoomAdjustment(this.transform.zoom) : 0;\n const increment = prevPlacement ? prevPlacement.symbolFadeChange(now) : 1;\n\n const prevOpacities = prevPlacement ? prevPlacement.opacities : {};\n const prevOffsets = prevPlacement ? prevPlacement.variableOffsets : {};\n const prevOrientations = prevPlacement ? prevPlacement.placedOrientations : {};\n\n // add the opacities from the current placement, and copy their current values from the previous placement\n for (const crossTileID in this.placements) {\n const jointPlacement = this.placements[crossTileID];\n const prevOpacity = prevOpacities[crossTileID];\n if (prevOpacity) {\n this.opacities[crossTileID] = new JointOpacityState(prevOpacity, increment, jointPlacement.text, jointPlacement.icon);\n placementChanged = placementChanged ||\n jointPlacement.text !== prevOpacity.text.placed ||\n jointPlacement.icon !== prevOpacity.icon.placed;\n } else {\n this.opacities[crossTileID] = new JointOpacityState(null, increment, jointPlacement.text, jointPlacement.icon, jointPlacement.skipFade);\n placementChanged = placementChanged || jointPlacement.text || jointPlacement.icon;\n }\n }\n\n // copy and update values from the previous placement that aren't in the current placement but haven't finished fading\n for (const crossTileID in prevOpacities) {\n const prevOpacity = prevOpacities[crossTileID];\n if (!this.opacities[crossTileID]) {\n const jointOpacity = new JointOpacityState(prevOpacity, increment, false, false);\n if (!jointOpacity.isHidden()) {\n this.opacities[crossTileID] = jointOpacity;\n placementChanged = placementChanged || prevOpacity.text.placed || prevOpacity.icon.placed;\n }\n }\n }\n for (const crossTileID in prevOffsets) {\n if (!this.variableOffsets[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {\n this.variableOffsets[crossTileID] = prevOffsets[crossTileID];\n }\n }\n\n for (const crossTileID in prevOrientations) {\n if (!this.placedOrientations[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {\n this.placedOrientations[crossTileID] = prevOrientations[crossTileID];\n }\n }\n\n // this.lastPlacementChangeTime is the time of the last commit() that\n // resulted in a placement change -- in other words, the start time of\n // the last symbol fade animation\n if (prevPlacement && prevPlacement.lastPlacementChangeTime === undefined) {\n throw new Error('Last placement time for previous placement is not defined');\n }\n if (placementChanged) {\n this.lastPlacementChangeTime = now;\n } else if (typeof this.lastPlacementChangeTime !== 'number') {\n this.lastPlacementChangeTime = prevPlacement ? prevPlacement.lastPlacementChangeTime : now;\n }\n }\n\n updateLayerOpacities(styleLayer: StyleLayer, tiles: Array) {\n const seenCrossTileIDs = {};\n for (const tile of tiles) {\n const symbolBucket = tile.getBucket(styleLayer) as SymbolBucket;\n if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) {\n this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray);\n }\n }\n }\n\n updateBucketOpacities(bucket: SymbolBucket, seenCrossTileIDs: {\n [k in string | number]: boolean;\n }, collisionBoxArray?: CollisionBoxArray | null) {\n if (bucket.hasTextData()) {\n bucket.text.opacityVertexArray.clear();\n bucket.text.hasVisibleVertices = false;\n }\n if (bucket.hasIconData()) {\n bucket.icon.opacityVertexArray.clear();\n bucket.icon.hasVisibleVertices = false;\n }\n if (bucket.hasIconCollisionBoxData()) bucket.iconCollisionBox.collisionVertexArray.clear();\n if (bucket.hasTextCollisionBoxData()) bucket.textCollisionBox.collisionVertexArray.clear();\n\n const layer = bucket.layers[0];\n const layout = layer.layout;\n const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true);\n const textAllowOverlap = layout.get('text-allow-overlap');\n const iconAllowOverlap = layout.get('icon-allow-overlap');\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const hasIconTextFit = layout.get('icon-text-fit') !== 'none';\n // If allow-overlap is true, we can show symbols before placement runs on them\n // But we have to wait for placement if we potentially depend on a paired icon/text\n // with allow-overlap: false.\n // See https://github.com/mapbox/mapbox-gl-js/issues/7032\n const defaultOpacityState = new JointOpacityState(null, 0,\n textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || layout.get('icon-optional')),\n iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || layout.get('text-optional')),\n true);\n\n if (!bucket.collisionArrays && collisionBoxArray && ((bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()))) {\n bucket.deserializeCollisionBoxes(collisionBoxArray);\n }\n\n const addOpacities = (iconOrText, numVertices: number, opacity: number) => {\n for (let i = 0; i < numVertices / 4; i++) {\n iconOrText.opacityVertexArray.emplaceBack(opacity);\n }\n iconOrText.hasVisibleVertices = iconOrText.hasVisibleVertices || (opacity !== PACKED_HIDDEN_OPACITY);\n };\n\n for (let s = 0; s < bucket.symbolInstances.length; s++) {\n const symbolInstance = bucket.symbolInstances.get(s);\n const {\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n crossTileID\n } = symbolInstance;\n\n const isDuplicate = seenCrossTileIDs[crossTileID];\n\n let opacityState = this.opacities[crossTileID];\n if (isDuplicate) {\n opacityState = duplicateOpacityState;\n } else if (!opacityState) {\n opacityState = defaultOpacityState;\n // store the state so that future placements use it as a starting point\n this.opacities[crossTileID] = opacityState;\n }\n\n seenCrossTileIDs[crossTileID] = true;\n\n const hasText = numHorizontalGlyphVertices > 0 || numVerticalGlyphVertices > 0;\n const hasIcon = symbolInstance.numIconVertices > 0;\n\n const placedOrientation = this.placedOrientations[symbolInstance.crossTileID];\n const horizontalHidden = placedOrientation === WritingMode.vertical;\n const verticalHidden = placedOrientation === WritingMode.horizontal || placedOrientation === WritingMode.horizontalOnly;\n\n if (hasText) {\n const packedOpacity = packOpacity(opacityState.text);\n // Vertical text fades in/out on collision the same way as corresponding\n // horizontal text. Switch between vertical/horizontal should be instantaneous\n const horizontalOpacity = horizontalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;\n addOpacities(bucket.text, numHorizontalGlyphVertices, horizontalOpacity);\n const verticalOpacity = verticalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;\n addOpacities(bucket.text, numVerticalGlyphVertices, verticalOpacity);\n\n // If this label is completely faded, mark it so that we don't have to calculate\n // its position at render time. If this layer has variable placement, shift the various\n // symbol instances appropriately so that symbols from buckets that have yet to be placed\n // offset appropriately.\n const symbolHidden = opacityState.text.isHidden();\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach(index => {\n if (index >= 0) {\n bucket.text.placedSymbolArray.get(index).hidden = symbolHidden || horizontalHidden ? 1 : 0;\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).hidden = symbolHidden || verticalHidden ? 1 : 0;\n }\n\n const prevOffset = this.variableOffsets[symbolInstance.crossTileID];\n if (prevOffset) {\n this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, placedOrientation);\n }\n\n const prevOrientation = this.placedOrientations[symbolInstance.crossTileID];\n if (prevOrientation) {\n this.markUsedJustification(bucket, 'left', symbolInstance, prevOrientation);\n this.markUsedOrientation(bucket, prevOrientation, symbolInstance);\n }\n }\n\n if (hasIcon) {\n const packedOpacity = packOpacity(opacityState.icon);\n\n const useHorizontal = !(hasIconTextFit && symbolInstance.verticalPlacedIconSymbolIndex && horizontalHidden);\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;\n addOpacities(bucket.icon, symbolInstance.numIconVertices, horizontalOpacity);\n bucket.icon.placedSymbolArray.get(symbolInstance.placedIconSymbolIndex).hidden =\n (opacityState.icon.isHidden() as any);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n const verticalOpacity = !useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;\n addOpacities(bucket.icon, symbolInstance.numVerticalIconVertices, verticalOpacity);\n bucket.icon.placedSymbolArray.get(symbolInstance.verticalPlacedIconSymbolIndex).hidden =\n (opacityState.icon.isHidden() as any);\n }\n }\n\n if (bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()) {\n const collisionArrays = bucket.collisionArrays[s];\n if (collisionArrays) {\n let shift = new Point(0, 0);\n if (collisionArrays.textBox || collisionArrays.verticalTextBox) {\n let used = true;\n if (hasVariablePlacement) {\n const variableOffset = this.variableOffsets[crossTileID];\n if (variableOffset) {\n // This will show either the currently placed position or the last\n // successfully placed position (so you can visualize what collision\n // just made the symbol disappear, and the most likely place for the\n // symbol to come back)\n shift = calculateVariableLayoutShift(variableOffset.anchor,\n variableOffset.width,\n variableOffset.height,\n variableOffset.textOffset,\n variableOffset.textBoxScale);\n if (rotateWithMap) {\n shift._rotate(pitchWithMap ? this.transform.angle : -this.transform.angle);\n }\n } else {\n // No offset -> this symbol hasn't been placed since coming on-screen\n // No single box is particularly meaningful and all of them would be too noisy\n // Use the center box just to show something's there, but mark it \"not used\"\n used = false;\n }\n }\n\n if (collisionArrays.textBox) {\n updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || horizontalHidden, shift.x, shift.y);\n }\n if (collisionArrays.verticalTextBox) {\n updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || verticalHidden, shift.x, shift.y);\n }\n }\n\n const verticalIconUsed = Boolean(!verticalHidden && collisionArrays.verticalIconBox);\n\n if (collisionArrays.iconBox) {\n updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, verticalIconUsed,\n hasIconTextFit ? shift.x : 0,\n hasIconTextFit ? shift.y : 0);\n }\n\n if (collisionArrays.verticalIconBox) {\n updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, !verticalIconUsed,\n hasIconTextFit ? shift.x : 0,\n hasIconTextFit ? shift.y : 0);\n }\n }\n }\n }\n\n bucket.sortFeatures(this.transform.angle);\n if (this.retainedQueryData[bucket.bucketInstanceId]) {\n this.retainedQueryData[bucket.bucketInstanceId].featureSortOrder = bucket.featureSortOrder;\n }\n\n if (bucket.hasTextData() && bucket.text.opacityVertexBuffer) {\n bucket.text.opacityVertexBuffer.updateData(bucket.text.opacityVertexArray);\n }\n if (bucket.hasIconData() && bucket.icon.opacityVertexBuffer) {\n bucket.icon.opacityVertexBuffer.updateData(bucket.icon.opacityVertexArray);\n }\n if (bucket.hasIconCollisionBoxData() && bucket.iconCollisionBox.collisionVertexBuffer) {\n bucket.iconCollisionBox.collisionVertexBuffer.updateData(bucket.iconCollisionBox.collisionVertexArray);\n }\n if (bucket.hasTextCollisionBoxData() && bucket.textCollisionBox.collisionVertexBuffer) {\n bucket.textCollisionBox.collisionVertexBuffer.updateData(bucket.textCollisionBox.collisionVertexArray);\n }\n\n if (bucket.text.opacityVertexArray.length !== bucket.text.layoutVertexArray.length / 4) throw new Error(`bucket.text.opacityVertexArray.length (= ${bucket.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${bucket.text.layoutVertexArray.length}) / 4`);\n if (bucket.icon.opacityVertexArray.length !== bucket.icon.layoutVertexArray.length / 4) throw new Error(`bucket.icon.opacityVertexArray.length (= ${bucket.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${bucket.icon.layoutVertexArray.length}) / 4`);\n\n // Push generated collision circles to the bucket for debug rendering\n if (bucket.bucketInstanceId in this.collisionCircleArrays) {\n const instance = this.collisionCircleArrays[bucket.bucketInstanceId];\n\n bucket.placementInvProjMatrix = instance.invProjMatrix;\n bucket.placementViewportMatrix = instance.viewportMatrix;\n bucket.collisionCircleArray = instance.circles;\n\n delete this.collisionCircleArrays[bucket.bucketInstanceId];\n }\n }\n\n symbolFadeChange(now: number) {\n return this.fadeDuration === 0 ?\n 1 :\n ((now - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment);\n }\n\n zoomAdjustment(zoom: number) {\n // When zooming out quickly, labels can overlap each other. This\n // adjustment is used to reduce the interval between placement calculations\n // and to reduce the fade duration when zooming out quickly. Discovering the\n // collisions more quickly and fading them more quickly reduces the unwanted effect.\n return Math.max(0, (this.transform.zoom - zoom) / 1.5);\n }\n\n hasTransitions(now: number) {\n return this.stale ||\n now - this.lastPlacementChangeTime < this.fadeDuration;\n }\n\n stillRecent(now: number, zoom: number) {\n // The adjustment makes placement more frequent when zooming.\n // This condition applies the adjustment only after the map has\n // stopped zooming. This avoids adding extra jank while zooming.\n const durationAdjustment = this.zoomAtLastRecencyCheck === zoom ?\n (1 - this.zoomAdjustment(zoom)) :\n 1;\n this.zoomAtLastRecencyCheck = zoom;\n\n return this.commitTime + this.fadeDuration * durationAdjustment > now;\n }\n\n setStale() {\n this.stale = true;\n }\n}\n\nfunction updateCollisionVertices(collisionVertexArray: CollisionVertexArray, placed: boolean, notUsed: boolean | number, shiftX?: number, shiftY?: number) {\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n}\n\n// All four vertices for a glyph will have the same opacity state\n// So we pack the opacity into a uint8, and then repeat it four times\n// to make a single uint32 that we can upload for each glyph in the\n// label.\nconst shift25 = Math.pow(2, 25);\nconst shift24 = Math.pow(2, 24);\nconst shift17 = Math.pow(2, 17);\nconst shift16 = Math.pow(2, 16);\nconst shift9 = Math.pow(2, 9);\nconst shift8 = Math.pow(2, 8);\nconst shift1 = Math.pow(2, 1);\nfunction packOpacity(opacityState: OpacityState): number {\n if (opacityState.opacity === 0 && !opacityState.placed) {\n return 0;\n } else if (opacityState.opacity === 1 && opacityState.placed) {\n return 4294967295;\n }\n const targetBit = opacityState.placed ? 1 : 0;\n const opacityBits = Math.floor(opacityState.opacity * 127);\n return opacityBits * shift25 + targetBit * shift24 +\n opacityBits * shift17 + targetBit * shift16 +\n opacityBits * shift9 + targetBit * shift8 +\n opacityBits * shift1 + targetBit;\n}\n\nconst PACKED_HIDDEN_OPACITY = 0;\n","import {browser} from '../util/browser';\n\nimport {Placement} from '../symbol/placement';\n\nimport type {Transform} from '../geo/transform';\nimport type {StyleLayer} from './style_layer';\nimport type {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport type {Tile} from '../source/tile';\nimport type {BucketPart} from '../symbol/placement';\nimport {Terrain} from '../render/terrain';\n\nclass LayerPlacement {\n _sortAcrossTiles: boolean;\n _currentTileIndex: number;\n _currentPartIndex: number;\n _seenCrossTileIDs: {\n [k in string | number]: boolean;\n };\n _bucketParts: Array;\n\n constructor(styleLayer: SymbolStyleLayer) {\n this._sortAcrossTiles = styleLayer.layout.get('symbol-z-order') !== 'viewport-y' &&\n !styleLayer.layout.get('symbol-sort-key').isConstant();\n\n this._currentTileIndex = 0;\n this._currentPartIndex = 0;\n this._seenCrossTileIDs = {};\n this._bucketParts = [];\n }\n\n continuePlacement(tiles: Array, placement: Placement, showCollisionBoxes: boolean, styleLayer: StyleLayer, shouldPausePlacement: () => boolean) {\n\n const bucketParts = this._bucketParts;\n\n while (this._currentTileIndex < tiles.length) {\n const tile = tiles[this._currentTileIndex];\n placement.getBucketParts(bucketParts, styleLayer, tile, this._sortAcrossTiles);\n\n this._currentTileIndex++;\n if (shouldPausePlacement()) {\n return true;\n }\n }\n\n if (this._sortAcrossTiles) {\n this._sortAcrossTiles = false;\n bucketParts.sort((a, b) => (a.sortKey as any as number) - (b.sortKey as any as number));\n }\n\n while (this._currentPartIndex < bucketParts.length) {\n const bucketPart = bucketParts[this._currentPartIndex];\n placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes);\n\n this._currentPartIndex++;\n if (shouldPausePlacement()) {\n return true;\n }\n }\n return false;\n }\n}\n\nexport class PauseablePlacement {\n placement: Placement;\n _done: boolean;\n _currentPlacementIndex: number;\n _forceFullPlacement: boolean;\n _showCollisionBoxes: boolean;\n _inProgressLayer: LayerPlacement;\n\n constructor(\n transform: Transform,\n terrain: Terrain,\n order: Array,\n forceFullPlacement: boolean,\n showCollisionBoxes: boolean,\n fadeDuration: number,\n crossSourceCollisions: boolean,\n prevPlacement?: Placement\n ) {\n this.placement = new Placement(transform, terrain, fadeDuration, crossSourceCollisions, prevPlacement);\n this._currentPlacementIndex = order.length - 1;\n this._forceFullPlacement = forceFullPlacement;\n this._showCollisionBoxes = showCollisionBoxes;\n this._done = false;\n }\n\n isDone() {\n return this._done;\n }\n\n continuePlacement(\n order: Array,\n layers: {[_: string]: StyleLayer},\n layerTiles: {[_: string]: Array}\n ) {\n const startTime = browser.now();\n\n const shouldPausePlacement = () => {\n return this._forceFullPlacement ? false : (browser.now() - startTime) > 2;\n };\n\n while (this._currentPlacementIndex >= 0) {\n const layerId = order[this._currentPlacementIndex];\n const layer = layers[layerId];\n const placementZoom = this.placement.collisionIndex.transform.zoom;\n if (layer.type === 'symbol' &&\n (!layer.minzoom || layer.minzoom <= placementZoom) &&\n (!layer.maxzoom || layer.maxzoom > placementZoom)) {\n\n if (!this._inProgressLayer) {\n this._inProgressLayer = new LayerPlacement(layer as any as SymbolStyleLayer);\n }\n\n const pausePlacement = this._inProgressLayer.continuePlacement(layerTiles[layer.source], this.placement, this._showCollisionBoxes, layer, shouldPausePlacement);\n\n if (pausePlacement) {\n // We didn't finish placing all layers within 2ms,\n // but we can keep rendering with a partial placement\n // We'll resume here on the next frame\n return;\n }\n\n delete this._inProgressLayer;\n }\n\n this._currentPlacementIndex--;\n }\n\n this._done = true;\n }\n\n commit(now: number) {\n this.placement.commit(now);\n return this.placement;\n }\n}\n","import KDBush from 'kdbush';\nimport {EXTENT} from '../data/extent';\n\nimport {SymbolInstanceArray} from '../data/array_types.g';\n\nimport type {SymbolInstance} from '../data/array_types.g';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {Tile} from '../source/tile';\n\n/*\n The CrossTileSymbolIndex generally works on the assumption that\n a conceptual \"unique symbol\" can be identified by the text of\n the label combined with the anchor point. The goal is to assign\n these conceptual \"unique symbols\" a shared crossTileID that can be\n used by Placement to keep fading opacity states consistent and to\n deduplicate labels.\n\n The CrossTileSymbolIndex indexes all the current symbol instances and\n their crossTileIDs. When a symbol bucket gets added or updated, the\n index assigns a crossTileID to each of it's symbol instances by either\n matching it with an existing id or assigning a new one.\n*/\n\n// Round anchor positions to roughly 4 pixel grid\nconst roundingFactor = 512 / EXTENT / 2;\n\nexport const KDBUSH_THRESHHOLD = 128;\n\ninterface SymbolsByKeyEntry {\n index?: KDBush;\n positions?: {x: number; y: number}[];\n crossTileIDs: number[];\n}\n\nclass TileLayerIndex {\n _symbolsByKey: Record = {};\n\n constructor(public tileID: OverscaledTileID, symbolInstances: SymbolInstanceArray, public bucketInstanceId: number) {\n // group the symbolInstances by key\n const symbolInstancesByKey = new Map();\n for (let i = 0; i < symbolInstances.length; i++) {\n const symbolInstance = symbolInstances.get(i);\n const key = symbolInstance.key;\n const instances = symbolInstancesByKey.get(key);\n if (instances) {\n // This tile may have multiple symbol instances with the same key\n // Store each one along with its coordinates\n instances.push(symbolInstance);\n } else {\n symbolInstancesByKey.set(key, [symbolInstance]);\n }\n }\n\n // index the SymbolInstances in this each bucket\n for (const [key, symbols] of symbolInstancesByKey) {\n const positions = symbols.map(symbolInstance => ({x: Math.floor(symbolInstance.anchorX * roundingFactor), y: Math.floor(symbolInstance.anchorY * roundingFactor)}));\n const crossTileIDs = symbols.map(v => v.crossTileID);\n const entry: SymbolsByKeyEntry = {positions, crossTileIDs};\n\n // once we get too many symbols for a given key, it becomes much faster to index it before queries\n if (entry.positions.length > KDBUSH_THRESHHOLD) {\n\n const index = new KDBush(entry.positions.length, 16, Uint16Array);\n for (const {x, y} of entry.positions) index.add(x, y);\n index.finish();\n\n // clear all references to the original positions data\n delete entry.positions;\n entry.index = index;\n }\n\n this._symbolsByKey[key] = entry;\n }\n }\n\n // Converts the coordinates of the input symbol instance into coordinates that be can compared\n // against other symbols in this index. Coordinates are:\n // (1) local-tile-based (so after correction we get x,y values relative to our local anchorX/Y)\n // (2) converted to the z-scale of this TileLayerIndex\n // (3) down-sampled by \"roundingFactor\" from tile coordinate precision in order to be\n // more tolerant of small differences between tiles.\n getScaledCoordinates(symbolInstance: SymbolInstance, childTileID: OverscaledTileID): {x: number; y: number} {\n const {x: localX, y: localY, z: localZ} = this.tileID.canonical;\n const {x, y, z} = childTileID.canonical;\n\n const zDifference = z - localZ;\n const scale = roundingFactor / Math.pow(2, zDifference);\n const xWorld = (x * EXTENT + symbolInstance.anchorX) * scale;\n const yWorld = (y * EXTENT + symbolInstance.anchorY) * scale;\n const xOffset = localX * EXTENT * roundingFactor;\n const yOffset = localY * EXTENT * roundingFactor;\n const result = {\n x: Math.floor(xWorld - xOffset),\n y: Math.floor(yWorld - yOffset)\n };\n\n return result;\n }\n\n findMatches(symbolInstances: SymbolInstanceArray, newTileID: OverscaledTileID, zoomCrossTileIDs: {\n [crossTileID: number]: boolean;\n }) {\n const tolerance = this.tileID.canonical.z < newTileID.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - newTileID.canonical.z);\n\n for (let i = 0; i < symbolInstances.length; i++) {\n const symbolInstance = symbolInstances.get(i);\n if (symbolInstance.crossTileID) {\n // already has a match, skip\n continue;\n }\n\n const entry = this._symbolsByKey[symbolInstance.key];\n if (!entry) {\n // No symbol with this key in this bucket\n continue;\n }\n\n const scaledSymbolCoord = this.getScaledCoordinates(symbolInstance, newTileID);\n\n if (entry.index) {\n // Return any symbol with the same keys whose coordinates are within 1\n // grid unit. (with a 4px grid, this covers a 12px by 12px area)\n const indexes = entry.index.range(\n scaledSymbolCoord.x - tolerance,\n scaledSymbolCoord.y - tolerance,\n scaledSymbolCoord.x + tolerance,\n scaledSymbolCoord.y + tolerance).sort();\n\n for (const i of indexes) {\n const crossTileID = entry.crossTileIDs[i];\n\n if (!zoomCrossTileIDs[crossTileID]) {\n // Once we've marked ourselves duplicate against this parent symbol,\n // don't let any other symbols at the same zoom level duplicate against\n // the same parent (see issue #5993)\n zoomCrossTileIDs[crossTileID] = true;\n symbolInstance.crossTileID = crossTileID;\n break;\n }\n }\n } else if (entry.positions) {\n for (let i = 0; i < entry.positions.length; i++) {\n const thisTileSymbol = entry.positions[i];\n const crossTileID = entry.crossTileIDs[i];\n\n // Return any symbol with the same keys whose coordinates are within 1\n // grid unit. (with a 4px grid, this covers a 12px by 12px area)\n if (Math.abs(thisTileSymbol.x - scaledSymbolCoord.x) <= tolerance &&\n Math.abs(thisTileSymbol.y - scaledSymbolCoord.y) <= tolerance &&\n !zoomCrossTileIDs[crossTileID]) {\n // Once we've marked ourselves duplicate against this parent symbol,\n // don't let any other symbols at the same zoom level duplicate against\n // the same parent (see issue #5993)\n zoomCrossTileIDs[crossTileID] = true;\n symbolInstance.crossTileID = crossTileID;\n break;\n }\n }\n }\n }\n }\n\n getCrossTileIDsLists() {\n return Object.values(this._symbolsByKey).map(({crossTileIDs}) => crossTileIDs);\n }\n}\n\nclass CrossTileIDs {\n maxCrossTileID: number;\n constructor() {\n this.maxCrossTileID = 0;\n }\n generate() {\n return ++this.maxCrossTileID;\n }\n}\n\nclass CrossTileSymbolLayerIndex {\n indexes: {\n [zoom in string | number]: {\n [tileId in string | number]: TileLayerIndex;\n };\n };\n usedCrossTileIDs: {\n [zoom in string | number]: {\n [crossTileID: number]: boolean;\n };\n };\n lng: number;\n\n constructor() {\n this.indexes = {};\n this.usedCrossTileIDs = {};\n this.lng = 0;\n }\n\n /*\n * Sometimes when a user pans across the antimeridian the longitude value gets wrapped.\n * To prevent labels from flashing out and in we adjust the tileID values in the indexes\n * so that they match the new wrapped version of the map.\n */\n handleWrapJump(lng: number) {\n const wrapDelta = Math.round((lng - this.lng) / 360);\n if (wrapDelta !== 0) {\n for (const zoom in this.indexes) {\n const zoomIndexes = this.indexes[zoom];\n const newZoomIndex = {};\n for (const key in zoomIndexes) {\n // change the tileID's wrap and add it to a new index\n const index = zoomIndexes[key];\n index.tileID = index.tileID.unwrapTo(index.tileID.wrap + wrapDelta);\n newZoomIndex[index.tileID.key] = index;\n }\n this.indexes[zoom] = newZoomIndex;\n }\n }\n this.lng = lng;\n }\n\n addBucket(tileID: OverscaledTileID, bucket: SymbolBucket, crossTileIDs: CrossTileIDs) {\n if (this.indexes[tileID.overscaledZ] &&\n this.indexes[tileID.overscaledZ][tileID.key]) {\n if (this.indexes[tileID.overscaledZ][tileID.key].bucketInstanceId ===\n bucket.bucketInstanceId) {\n return false;\n } else {\n // We're replacing this bucket with an updated version\n // Remove the old bucket's \"used crossTileIDs\" now so that\n // the new bucket can claim them.\n // The old index entries themselves stick around until\n // 'removeStaleBuckets' is called.\n this.removeBucketCrossTileIDs(tileID.overscaledZ,\n this.indexes[tileID.overscaledZ][tileID.key]);\n }\n }\n\n for (let i = 0; i < bucket.symbolInstances.length; i++) {\n const symbolInstance = bucket.symbolInstances.get(i);\n symbolInstance.crossTileID = 0;\n }\n\n if (!this.usedCrossTileIDs[tileID.overscaledZ]) {\n this.usedCrossTileIDs[tileID.overscaledZ] = {};\n }\n const zoomCrossTileIDs = this.usedCrossTileIDs[tileID.overscaledZ];\n\n for (const zoom in this.indexes) {\n const zoomIndexes = this.indexes[zoom];\n if (Number(zoom) > tileID.overscaledZ) {\n for (const id in zoomIndexes) {\n const childIndex = zoomIndexes[id];\n if (childIndex.tileID.isChildOf(tileID)) {\n childIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs);\n }\n }\n } else {\n const parentCoord = tileID.scaledTo(Number(zoom));\n const parentIndex = zoomIndexes[parentCoord.key];\n if (parentIndex) {\n parentIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs);\n }\n }\n }\n\n for (let i = 0; i < bucket.symbolInstances.length; i++) {\n const symbolInstance = bucket.symbolInstances.get(i);\n if (!symbolInstance.crossTileID) {\n // symbol did not match any known symbol, assign a new id\n symbolInstance.crossTileID = crossTileIDs.generate();\n zoomCrossTileIDs[symbolInstance.crossTileID] = true;\n }\n }\n\n if (this.indexes[tileID.overscaledZ] === undefined) {\n this.indexes[tileID.overscaledZ] = {};\n }\n this.indexes[tileID.overscaledZ][tileID.key] = new TileLayerIndex(tileID, bucket.symbolInstances, bucket.bucketInstanceId);\n\n return true;\n }\n\n removeBucketCrossTileIDs(zoom: string | number, removedBucket: TileLayerIndex) {\n for (const crossTileIDs of removedBucket.getCrossTileIDsLists()) {\n for (const crossTileID of crossTileIDs) {\n delete this.usedCrossTileIDs[zoom][crossTileID];\n }\n }\n }\n\n removeStaleBuckets(currentIDs: {\n [k in string | number]: boolean;\n }) {\n let tilesChanged = false;\n for (const z in this.indexes) {\n const zoomIndexes = this.indexes[z];\n for (const tileKey in zoomIndexes) {\n if (!currentIDs[zoomIndexes[tileKey].bucketInstanceId]) {\n this.removeBucketCrossTileIDs(z, zoomIndexes[tileKey]);\n delete zoomIndexes[tileKey];\n tilesChanged = true;\n }\n }\n }\n return tilesChanged;\n }\n}\n\nexport class CrossTileSymbolIndex {\n layerIndexes: {[layerId: string]: CrossTileSymbolLayerIndex};\n crossTileIDs: CrossTileIDs;\n maxBucketInstanceId: number;\n bucketsInCurrentPlacement: {[_: number]: boolean};\n\n constructor() {\n this.layerIndexes = {};\n this.crossTileIDs = new CrossTileIDs();\n this.maxBucketInstanceId = 0;\n this.bucketsInCurrentPlacement = {};\n }\n\n addLayer(styleLayer: StyleLayer, tiles: Array, lng: number) {\n let layerIndex = this.layerIndexes[styleLayer.id];\n if (layerIndex === undefined) {\n layerIndex = this.layerIndexes[styleLayer.id] = new CrossTileSymbolLayerIndex();\n }\n\n let symbolBucketsChanged = false;\n const currentBucketIDs = {};\n\n layerIndex.handleWrapJump(lng);\n\n for (const tile of tiles) {\n const symbolBucket = (tile.getBucket(styleLayer) as any as SymbolBucket);\n if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0])\n continue;\n\n if (!symbolBucket.bucketInstanceId) {\n symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId;\n }\n\n if (layerIndex.addBucket(tile.tileID, symbolBucket, this.crossTileIDs)) {\n symbolBucketsChanged = true;\n }\n currentBucketIDs[symbolBucket.bucketInstanceId] = true;\n }\n\n if (layerIndex.removeStaleBuckets(currentBucketIDs)) {\n symbolBucketsChanged = true;\n }\n\n return symbolBucketsChanged;\n }\n\n pruneUnusedLayers(usedLayers: Array) {\n const usedLayerMap = {};\n usedLayers.forEach((usedLayer) => {\n usedLayerMap[usedLayer] = true;\n });\n for (const layerId in this.layerIndexes) {\n if (!usedLayerMap[layerId]) {\n delete this.layerIndexes[layerId];\n }\n }\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\nimport {StyleLayer} from './style_layer';\nimport {createStyleLayer} from './create_style_layer';\nimport {loadSprite} from './load_sprite';\nimport {ImageManager} from '../render/image_manager';\nimport {GlyphManager} from '../render/glyph_manager';\nimport {Light} from './light';\nimport {LineAtlas} from '../render/line_atlas';\nimport {pick, clone, extend, deepEqual, filterObject, mapObject} from '../util/util';\nimport {coerceSpriteToArray} from '../util/style';\nimport {getJSON, getReferrer, makeRequest} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\nimport {Dispatcher} from '../util/dispatcher';\nimport {validateStyle, emitValidationErrors as _emitValidationErrors} from './validate_style';\nimport {getSourceType, setSourceType, Source} from '../source/source';\nimport type {SourceClass} from '../source/source';\nimport {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions, queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures} from '../source/query_features';\nimport {SourceCache} from '../source/source_cache';\nimport {GeoJSONSource} from '../source/geojson_source';\nimport {latest as styleSpec, derefLayers as deref, emptyStyle, diff as diffStyles, operations as diffOperations} from '@maplibre/maplibre-gl-style-spec';\nimport {getGlobalWorkerPool} from '../util/global_worker_pool';\nimport {\n registerForPluginStateChange,\n evented as rtlTextPluginEvented,\n triggerPluginCompletionEvent\n} from '../source/rtl_text_plugin';\nimport {PauseablePlacement} from './pauseable_placement';\nimport {ZoomHistory} from './zoom_history';\nimport {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';\nimport {validateCustomStyleLayer} from './style_layer/custom_style_layer';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\n\n// We're skipping validation errors with the `source.canvas` identifier in order\n// to continue to allow canvas sources to be added at runtime/updated in\n// smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424):\nconst emitValidationErrors = (evented: Evented, errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n}> | null) =>\n _emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas'));\n\nimport type {Map} from '../ui/map';\nimport type {Transform} from '../geo/transform';\nimport type {StyleImage} from './style_image';\nimport type {StyleGlyph} from './style_glyph';\nimport type {Callback} from '../types/callback';\nimport type {EvaluationParameters} from './evaluation_parameters';\nimport type {Placement} from '../symbol/placement';\nimport type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from '../util/ajax';\nimport type {\n LayerSpecification,\n FilterSpecification,\n StyleSpecification,\n LightSpecification,\n SourceSpecification,\n SpriteSpecification,\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Validator} from './validate_style';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nconst supportedDiffOperations = pick(diffOperations, [\n 'addLayer',\n 'removeLayer',\n 'setPaintProperty',\n 'setLayoutProperty',\n 'setFilter',\n 'addSource',\n 'removeSource',\n 'setLayerZoomRange',\n 'setLight',\n 'setTransition',\n 'setGeoJSONSourceData',\n 'setGlyphs',\n 'setSprite',\n]);\n\nconst ignoredDiffOperations = pick(diffOperations, [\n 'setCenter',\n 'setZoom',\n 'setBearing',\n 'setPitch'\n]);\n\nconst empty = emptyStyle() as StyleSpecification;\n/**\n * A feature identifier that is bound to a source\n */\nexport type FeatureIdentifier = {\n /**\n * Unique id of the feature.\n */\n id?: string | number | undefined;\n /**\n * The id of the vector or GeoJSON source for the feature.\n */\n source: string;\n /**\n * *For vector tile sources, `sourceLayer` is required.*\n */\n sourceLayer?: string | undefined;\n};\n\n/**\n * The options object related to the {@link Map}'s style related methods\n */\nexport type StyleOptions = {\n /**\n * If false, style validation will be skipped. Useful in production environment.\n */\n validate?: boolean;\n /**\n * Defines a CSS\n * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.\n * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).\n * Set to `false`, to enable font settings from the map's style for these glyph ranges.\n * Forces a full update.\n */\n localIdeographFontFamily?: string;\n};\n\n/**\n * Supporting type to add validation to another style related type\n */\nexport type StyleSetterOptions = {\n /**\n * Whether to check if the filter conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n */\n validate?: boolean;\n};\n\n/**\n * Part of {@link Map#setStyle} options, transformStyle is a convenience function that allows to modify a style after it is fetched but before it is committed to the map state\n * this function exposes previous and next styles, it can be commonly used to support a range of functionalities like:\n * when previous style carries certain 'state' that needs to be carried over to a new style gracefully\n * when a desired style is a certain combination of previous and incoming style\n * when an incoming style requires modification based on external state\n *\n * @param previousStyle - The current style.\n * @param nextStyle - The next style.\n * @returns resulting style that will to be applied to the map\n *\n * @example\n * ```ts\n * map.setStyle('https://demotiles.maplibre.org/style.json', {\n * transformStyle: (previousStyle, nextStyle) => ({\n * ...nextStyle,\n * sources: {\n * ...nextStyle.sources,\n * // copy a source from previous style\n * 'osm': previousStyle.sources.osm\n * },\n * layers: [\n * // background layer\n * nextStyle.layers[0],\n * // copy a layer from previous style\n * previousStyle.layers[0],\n * // other layers from the next style\n * ...nextStyle.layers.slice(1).map(layer => {\n * // hide the layers we don't need from demotiles style\n * if (layer.id.startsWith('geolines')) {\n * layer.layout = {...layer.layout || {}, visibility: 'none'};\n * // filter out US polygons\n * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {\n * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];\n * }\n * return layer;\n * })\n * ]\n * })\n * });\n * ```\n */\nexport type TransformStyleFunction = (previous: StyleSpecification | undefined, next: StyleSpecification) => StyleSpecification;\n\n/**\n * The options object related to the {@link Map}'s style related methods\n */\nexport type StyleSwapOptions = {\n /**\n * If false, force a 'full' update, removing the current style\n * and building the given one instead of attempting a diff-based update.\n */\n diff?: boolean;\n /**\n * TransformStyleFunction is a convenience function\n * that allows to modify a style after it is fetched but before it is committed to the map state. Refer to {@link TransformStyleFunction}.\n */\n transformStyle?: TransformStyleFunction;\n}\n\n/**\n * Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification}\n * or a {@link CustomLayerInterface}, a {@link LayerSpecification} with an embedded {@link SourceSpecification} can also be provided.\n */\nexport type AddLayerObject = LayerSpecification | (Omit & {source: SourceSpecification}) | CustomLayerInterface;\n\n/**\n * The Style base class\n */\nexport class Style extends Evented {\n map: Map;\n stylesheet: StyleSpecification;\n dispatcher: Dispatcher;\n imageManager: ImageManager;\n glyphManager: GlyphManager;\n lineAtlas: LineAtlas;\n light: Light;\n\n _request: Cancelable;\n _spriteRequest: Cancelable;\n _layers: {[_: string]: StyleLayer};\n _serializedLayers: {[_: string]: LayerSpecification};\n _order: Array;\n sourceCaches: {[_: string]: SourceCache};\n zoomHistory: ZoomHistory;\n _loaded: boolean;\n _rtlTextPluginCallback: (a: any) => any;\n _changed: boolean;\n _updatedSources: {[_: string]: 'clear' | 'reload'};\n _updatedLayers: {[_: string]: true};\n _removedLayers: {[_: string]: StyleLayer};\n _changedImages: {[_: string]: true};\n _glyphsDidChange: boolean;\n _updatedPaintProps: {[layer: string]: true};\n _layerOrderChanged: boolean;\n // image ids of images loaded from style's sprite\n _spritesImagesIds: {[spriteId: string]: string[]};\n // image ids of all images loaded (sprite + user)\n _availableImages: Array;\n\n crossTileSymbolIndex: CrossTileSymbolIndex;\n pauseablePlacement: PauseablePlacement;\n placement: Placement;\n z: number;\n\n static registerForPluginStateChange: typeof registerForPluginStateChange;\n\n constructor(map: Map, options: StyleOptions = {}) {\n super();\n\n this.map = map;\n this.dispatcher = new Dispatcher(getGlobalWorkerPool(), this, map._getMapId());\n this.imageManager = new ImageManager();\n this.imageManager.setEventedParent(this);\n this.glyphManager = new GlyphManager(map._requestManager, options.localIdeographFontFamily);\n this.lineAtlas = new LineAtlas(256, 512);\n this.crossTileSymbolIndex = new CrossTileSymbolIndex();\n\n this._spritesImagesIds = {};\n this._layers = {};\n\n this._order = [];\n this.sourceCaches = {};\n this.zoomHistory = new ZoomHistory();\n this._loaded = false;\n this._availableImages = [];\n\n this._resetUpdates();\n\n this.dispatcher.broadcast('setReferrer', getReferrer());\n\n const self = this;\n this._rtlTextPluginCallback = Style.registerForPluginStateChange((event) => {\n const state = {\n pluginStatus: event.pluginStatus,\n pluginURL: event.pluginURL\n };\n self.dispatcher.broadcast('syncRTLPluginState', state, (err, results) => {\n triggerPluginCompletionEvent(err);\n if (results) {\n const allComplete = results.every((elem) => elem);\n if (allComplete) {\n for (const id in self.sourceCaches) {\n const sourceType = self.sourceCaches[id].getSource().type;\n if (sourceType === 'vector' || sourceType === 'geojson') {\n // Non-vector sources don't have any symbols buckets to reload when the RTL text plugin loads\n // They also load more quickly, so they're more likely to have already displaying tiles\n // that would be unnecessarily booted by the plugin load event\n self.sourceCaches[id].reload(); // Should be a no-op if the plugin loads before any tiles load\n }\n }\n }\n }\n\n });\n });\n\n this.on('data', (event) => {\n if (event.dataType !== 'source' || event.sourceDataType !== 'metadata') {\n return;\n }\n\n const sourceCache = this.sourceCaches[event.sourceId];\n if (!sourceCache) {\n return;\n }\n\n const source = sourceCache.getSource();\n if (!source || !source.vectorLayerIds) {\n return;\n }\n\n for (const layerId in this._layers) {\n const layer = this._layers[layerId];\n if (layer.source === source.id) {\n this._validateLayer(layer);\n }\n }\n });\n }\n\n loadURL(url: string, options: StyleSwapOptions & StyleSetterOptions = {}, previousStyle?: StyleSpecification) {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n\n options.validate = typeof options.validate === 'boolean' ?\n options.validate : true;\n\n const request = this.map._requestManager.transformRequest(url, ResourceType.Style);\n this._request = getJSON(request, (error?: Error | null, json?: any | null) => {\n this._request = null;\n if (error) {\n this.fire(new ErrorEvent(error));\n } else if (json) {\n this._load(json, options, previousStyle);\n }\n });\n }\n\n loadJSON(json: StyleSpecification, options: StyleSetterOptions & StyleSwapOptions = {}, previousStyle?: StyleSpecification) {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n\n this._request = browser.frame(() => {\n this._request = null;\n options.validate = options.validate !== false;\n this._load(json, options, previousStyle);\n });\n }\n\n loadEmpty() {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n this._load(empty, {validate: false});\n }\n\n _load(json: StyleSpecification, options: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification) {\n const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json;\n if (options.validate && emitValidationErrors(this, validateStyle(nextState))) {\n return;\n }\n\n this._loaded = true;\n this.stylesheet = nextState;\n\n for (const id in nextState.sources) {\n this.addSource(id, nextState.sources[id], {validate: false});\n }\n\n if (nextState.sprite) {\n this._loadSprite(nextState.sprite);\n } else {\n this.imageManager.setLoaded(true);\n }\n\n this.glyphManager.setURL(nextState.glyphs);\n this._createLayers();\n\n this.light = new Light(this.stylesheet.light);\n\n this.map.setTerrain(this.stylesheet.terrain ?? null);\n\n this.fire(new Event('data', {dataType: 'style'}));\n this.fire(new Event('style.load'));\n }\n\n private _createLayers() {\n const dereferencedLayers = deref(this.stylesheet.layers);\n\n // Broadcast layers to workers first, so that expensive style processing (createStyleLayer)\n // can happen in parallel on both main and worker threads.\n this.dispatcher.broadcast('setLayers', dereferencedLayers);\n\n this._order = dereferencedLayers.map((layer) => layer.id);\n this._layers = {};\n\n // reset serialization field, to be populated only when needed\n this._serializedLayers = null;\n for (const layer of dereferencedLayers) {\n const styledLayer = createStyleLayer(layer);\n styledLayer.setEventedParent(this, {layer: {id: layer.id}});\n this._layers[layer.id] = styledLayer;\n }\n }\n\n _loadSprite(sprite: SpriteSpecification, isUpdate: boolean = false, completion: (err: Error) => void = undefined) {\n this.imageManager.setLoaded(false);\n\n this._spriteRequest = loadSprite(sprite, this.map._requestManager, this.map.getPixelRatio(), (err, images) => {\n this._spriteRequest = null;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (images) {\n for (const spriteId in images) {\n this._spritesImagesIds[spriteId] = [];\n\n // remove old sprite's loaded images (for the same sprite id) that are not in new sprite\n const imagesToRemove = this._spritesImagesIds[spriteId] ? this._spritesImagesIds[spriteId].filter(id => !(id in images)) : [];\n for (const id of imagesToRemove) {\n this.imageManager.removeImage(id);\n this._changedImages[id] = true;\n }\n\n for (const id in images[spriteId]) {\n // don't prefix images of the \"default\" sprite\n const imageId = spriteId === 'default' ? id : `${spriteId}:${id}`;\n // save all the sprite's images' ids to be able to delete them in `removeSprite`\n this._spritesImagesIds[spriteId].push(imageId);\n if (imageId in this.imageManager.images) {\n this.imageManager.updateImage(imageId, images[spriteId][id], false);\n } else {\n this.imageManager.addImage(imageId, images[spriteId][id]);\n }\n\n if (isUpdate) {\n this._changedImages[imageId] = true;\n }\n }\n }\n }\n\n this.imageManager.setLoaded(true);\n this._availableImages = this.imageManager.listImages();\n\n if (isUpdate) {\n this._changed = true;\n }\n\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n\n if (completion) {\n completion(err);\n }\n });\n }\n\n _unloadSprite() {\n for (const id of Object.values(this._spritesImagesIds).flat()) {\n this.imageManager.removeImage(id);\n this._changedImages[id] = true;\n }\n\n this._spritesImagesIds = {};\n this._availableImages = this.imageManager.listImages();\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n _validateLayer(layer: StyleLayer) {\n const sourceCache = this.sourceCaches[layer.source];\n if (!sourceCache) {\n return;\n }\n\n const sourceLayer = layer.sourceLayer;\n if (!sourceLayer) {\n return;\n }\n\n const source = sourceCache.getSource();\n if (source.type === 'geojson' || (source.vectorLayerIds && source.vectorLayerIds.indexOf(sourceLayer) === -1)) {\n this.fire(new ErrorEvent(new Error(\n `Source layer \"${sourceLayer}\" ` +\n `does not exist on source \"${source.id}\" ` +\n `as specified by style layer \"${layer.id}\".`\n )));\n }\n }\n\n loaded() {\n if (!this._loaded)\n return false;\n\n if (Object.keys(this._updatedSources).length)\n return false;\n\n for (const id in this.sourceCaches)\n if (!this.sourceCaches[id].loaded())\n return false;\n\n if (!this.imageManager.isLoaded())\n return false;\n\n return true;\n }\n\n /**\n * take an array of string IDs, and based on this._layers, generate an array of LayerSpecification\n * @param ids - an array of string IDs, for which serialized layers will be generated. If omitted, all serialized layers will be returned\n * @returns generated result\n */\n private _serializeByIds(ids?: Array): Array {\n\n const serializedLayersDictionary = this._serializedAllLayers();\n if (!ids || ids.length === 0) {\n return Object.values(serializedLayersDictionary);\n }\n\n const serializedLayers = [];\n for (const id of ids) {\n // this check will skip all custom layers\n if (serializedLayersDictionary[id]) {\n serializedLayers.push(serializedLayersDictionary[id]);\n }\n }\n\n return serializedLayers;\n }\n\n /**\n * Lazy initialization of this._serializedLayers dictionary and return it\n * @returns this._serializedLayers dictionary\n */\n private _serializedAllLayers(): {[_: string]: LayerSpecification} {\n let serializedLayers = this._serializedLayers;\n if (serializedLayers) {\n return serializedLayers;\n }\n\n serializedLayers = this._serializedLayers = {};\n const allLayerIds: string [] = Object.keys(this._layers);\n for (const layerId of allLayerIds) {\n const layer = this._layers[layerId];\n if (layer.type !== 'custom') {\n serializedLayers[layerId] = layer.serialize();\n }\n }\n\n return serializedLayers;\n }\n\n hasTransitions() {\n if (this.light && this.light.hasTransition()) {\n return true;\n }\n\n for (const id in this.sourceCaches) {\n if (this.sourceCaches[id].hasTransition()) {\n return true;\n }\n }\n\n for (const id in this._layers) {\n if (this._layers[id].hasTransition()) {\n return true;\n }\n }\n\n return false;\n }\n\n _checkLoaded() {\n if (!this._loaded) {\n throw new Error('Style is not done loading.');\n }\n }\n\n /**\n * @internal\n * Apply queued style updates in a batch and recalculate zoom-dependent paint properties.\n */\n update(parameters: EvaluationParameters) {\n if (!this._loaded) {\n return;\n }\n\n const changed = this._changed;\n if (this._changed) {\n const updatedIds = Object.keys(this._updatedLayers);\n const removedIds = Object.keys(this._removedLayers);\n\n if (updatedIds.length || removedIds.length) {\n this._updateWorkerLayers(updatedIds, removedIds);\n }\n for (const id in this._updatedSources) {\n const action = this._updatedSources[id];\n\n if (action === 'reload') {\n this._reloadSource(id);\n } else if (action === 'clear') {\n this._clearSource(id);\n } else {\n throw new Error(`Invalid action ${action}`);\n }\n }\n\n this._updateTilesForChangedImages();\n this._updateTilesForChangedGlyphs();\n\n for (const id in this._updatedPaintProps) {\n this._layers[id].updateTransitions(parameters);\n }\n\n this.light.updateTransitions(parameters);\n\n this._resetUpdates();\n }\n\n const sourcesUsedBefore = {};\n\n for (const sourceId in this.sourceCaches) {\n const sourceCache = this.sourceCaches[sourceId];\n sourcesUsedBefore[sourceId] = sourceCache.used;\n sourceCache.used = false;\n }\n\n for (const layerId of this._order) {\n const layer = this._layers[layerId];\n\n layer.recalculate(parameters, this._availableImages);\n if (!layer.isHidden(parameters.zoom) && layer.source) {\n this.sourceCaches[layer.source].used = true;\n }\n }\n\n for (const sourceId in sourcesUsedBefore) {\n const sourceCache = this.sourceCaches[sourceId];\n if (sourcesUsedBefore[sourceId] !== sourceCache.used) {\n sourceCache.fire(new Event('data', {sourceDataType: 'visibility', dataType: 'source', sourceId}));\n }\n }\n\n this.light.recalculate(parameters);\n this.z = parameters.zoom;\n\n if (changed) {\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n }\n\n /*\n * Apply any queued image changes.\n */\n _updateTilesForChangedImages() {\n const changedImages = Object.keys(this._changedImages);\n if (changedImages.length) {\n for (const name in this.sourceCaches) {\n this.sourceCaches[name].reloadTilesForDependencies(['icons', 'patterns'], changedImages);\n }\n this._changedImages = {};\n }\n }\n\n _updateTilesForChangedGlyphs() {\n if (this._glyphsDidChange) {\n for (const name in this.sourceCaches) {\n this.sourceCaches[name].reloadTilesForDependencies(['glyphs'], ['']);\n }\n this._glyphsDidChange = false;\n }\n }\n\n _updateWorkerLayers(updatedIds: Array, removedIds: Array) {\n this.dispatcher.broadcast('updateLayers', {\n layers: this._serializeByIds(updatedIds),\n removedIds\n });\n }\n\n _resetUpdates() {\n this._changed = false;\n\n this._updatedLayers = {};\n this._removedLayers = {};\n\n this._updatedSources = {};\n this._updatedPaintProps = {};\n\n this._changedImages = {};\n this._glyphsDidChange = false;\n }\n\n /**\n * Update this style's state to match the given style JSON, performing only\n * the necessary mutations.\n *\n * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec\n * diff algorithm produces an operation that is not supported.\n *\n * @returns true if any changes were made; false otherwise\n */\n setState(nextState: StyleSpecification, options: StyleSwapOptions = {}) {\n this._checkLoaded();\n\n const serializedStyle = this.serialize();\n nextState = options.transformStyle ? options.transformStyle(serializedStyle, nextState) : nextState;\n if (emitValidationErrors(this, validateStyle(nextState))) return false;\n\n nextState = clone(nextState);\n nextState.layers = deref(nextState.layers);\n\n const changes = diffStyles(serializedStyle, nextState)\n .filter(op => !(op.command in ignoredDiffOperations));\n\n if (changes.length === 0) {\n return false;\n }\n\n const unimplementedOps = changes.filter(op => !(op.command in supportedDiffOperations));\n if (unimplementedOps.length > 0) {\n throw new Error(`Unimplemented: ${unimplementedOps.map(op => op.command).join(', ')}.`);\n }\n\n for (const op of changes) {\n if (op.command === 'setTransition') {\n // `transition` is always read directly off of\n // `this.stylesheet`, which we update below\n continue;\n }\n (this as any)[op.command].apply(this, op.args);\n }\n\n this.stylesheet = nextState;\n\n // reset serialization field, to be populated only when needed\n this._serializedLayers = null;\n\n return true;\n }\n\n addImage(id: string, image: StyleImage) {\n if (this.getImage(id)) {\n return this.fire(new ErrorEvent(new Error(`An image named \"${id}\" already exists.`)));\n }\n this.imageManager.addImage(id, image);\n this._afterImageUpdated(id);\n }\n\n updateImage(id: string, image: StyleImage) {\n this.imageManager.updateImage(id, image);\n }\n\n getImage(id: string): StyleImage {\n return this.imageManager.getImage(id);\n }\n\n removeImage(id: string) {\n if (!this.getImage(id)) {\n return this.fire(new ErrorEvent(new Error(`An image named \"${id}\" does not exist.`)));\n }\n this.imageManager.removeImage(id);\n this._afterImageUpdated(id);\n }\n\n _afterImageUpdated(id: string) {\n this._availableImages = this.imageManager.listImages();\n this._changedImages[id] = true;\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n listImages() {\n this._checkLoaded();\n\n return this.imageManager.listImages();\n }\n\n addSource(id: string, source: SourceSpecification, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n if (this.sourceCaches[id] !== undefined) {\n throw new Error(`Source \"${id}\" already exists.`);\n }\n\n if (!source.type) {\n throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(source).join(', ')}.`);\n }\n\n const builtIns = ['vector', 'raster', 'geojson', 'video', 'image'];\n const shouldValidate = builtIns.indexOf(source.type) >= 0;\n if (shouldValidate && this._validate(validateStyle.source, `sources.${id}`, source, null, options)) return;\n\n if (this.map && this.map._collectResourceTiming) (source as any).collectResourceTiming = true;\n const sourceCache = this.sourceCaches[id] = new SourceCache(id, source, this.dispatcher);\n sourceCache.style = this;\n sourceCache.setEventedParent(this, () => ({\n isSourceLoaded: sourceCache.loaded(),\n source: sourceCache.serialize(),\n sourceId: id\n }));\n\n sourceCache.onAdd(this.map);\n this._changed = true;\n }\n\n /**\n * Remove a source from this stylesheet, given its id.\n * @param id - id of the source to remove\n * @throws if no source is found with the given ID\n * @returns `this`.\n */\n removeSource(id: string): this {\n this._checkLoaded();\n\n if (this.sourceCaches[id] === undefined) {\n throw new Error('There is no source with this ID');\n }\n for (const layerId in this._layers) {\n if (this._layers[layerId].source === id) {\n return this.fire(new ErrorEvent(new Error(`Source \"${id}\" cannot be removed while layer \"${layerId}\" is using it.`)));\n }\n }\n\n const sourceCache = this.sourceCaches[id];\n delete this.sourceCaches[id];\n delete this._updatedSources[id];\n sourceCache.fire(new Event('data', {sourceDataType: 'metadata', dataType: 'source', sourceId: id}));\n sourceCache.setEventedParent(null);\n sourceCache.onRemove(this.map);\n this._changed = true;\n }\n\n /**\n * Set the data of a GeoJSON source, given its id.\n * @param id - id of the source\n * @param data - GeoJSON source\n */\n setGeoJSONSourceData(id: string, data: GeoJSON.GeoJSON | string) {\n this._checkLoaded();\n\n if (this.sourceCaches[id] === undefined) throw new Error(`There is no source with this ID=${id}`);\n const geojsonSource: GeoJSONSource = (this.sourceCaches[id].getSource() as any);\n if (geojsonSource.type !== 'geojson') throw new Error(`geojsonSource.type is ${geojsonSource.type}, which is !== 'geojson`);\n\n geojsonSource.setData(data);\n this._changed = true;\n }\n\n /**\n * Get a source by ID.\n * @param id - ID of the desired source\n * @returns source\n */\n getSource(id: string): Source | undefined {\n return this.sourceCaches[id] && this.sourceCaches[id].getSource();\n }\n\n /**\n * Add a layer to the map style. The layer will be inserted before the layer with\n * ID `before`, or appended if `before` is omitted.\n * @param layerObject - The style layer to add.\n * @param before - ID of an existing layer to insert before\n * @param options - Style setter options.\n * @returns `this`.\n */\n addLayer(layerObject: AddLayerObject, before?: string, options: StyleSetterOptions = {}): this {\n this._checkLoaded();\n\n const id = layerObject.id;\n\n if (this.getLayer(id)) {\n this.fire(new ErrorEvent(new Error(`Layer \"${id}\" already exists on this map.`)));\n return;\n }\n\n let layer: ReturnType;\n if (layerObject.type === 'custom') {\n\n if (emitValidationErrors(this, validateCustomStyleLayer(layerObject))) return;\n\n layer = createStyleLayer(layerObject);\n\n } else {\n if ('source' in layerObject && typeof layerObject.source === 'object') {\n this.addSource(id, layerObject.source);\n layerObject = clone(layerObject);\n layerObject = extend(layerObject, {source: id});\n }\n\n // this layer is not in the style.layers array, so we pass an impossible array index\n if (this._validate(validateStyle.layer,\n `layers.${id}`, layerObject, {arrayIndex: -1}, options)) return;\n\n layer = createStyleLayer(layerObject as LayerSpecification | CustomLayerInterface);\n this._validateLayer(layer);\n\n layer.setEventedParent(this, {layer: {id}});\n }\n\n const index = before ? this._order.indexOf(before) : this._order.length;\n if (before && index === -1) {\n this.fire(new ErrorEvent(new Error(`Cannot add layer \"${id}\" before non-existing layer \"${before}\".`)));\n return;\n }\n\n this._order.splice(index, 0, id);\n this._layerOrderChanged = true;\n\n this._layers[id] = layer;\n\n if (this._removedLayers[id] && layer.source && layer.type !== 'custom') {\n // If, in the current batch, we have already removed this layer\n // and we are now re-adding it with a different `type`, then we\n // need to clear (rather than just reload) the underlying source's\n // tiles. Otherwise, tiles marked 'reloading' will have buckets /\n // buffers that are set up for the _previous_ version of this\n // layer, causing, e.g.:\n // https://github.com/mapbox/mapbox-gl-js/issues/3633\n const removed = this._removedLayers[id];\n delete this._removedLayers[id];\n if (removed.type !== layer.type) {\n this._updatedSources[layer.source] = 'clear';\n } else {\n this._updatedSources[layer.source] = 'reload';\n this.sourceCaches[layer.source].pause();\n }\n }\n this._updateLayer(layer);\n\n if (layer.onAdd) {\n layer.onAdd(this.map);\n }\n }\n\n /**\n * Moves a layer to a different z-position. The layer will be inserted before the layer with\n * ID `before`, or appended if `before` is omitted.\n * @param id - ID of the layer to move\n * @param before - ID of an existing layer to insert before\n */\n moveLayer(id: string, before?: string) {\n this._checkLoaded();\n this._changed = true;\n\n const layer = this._layers[id];\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be moved.`)));\n return;\n }\n\n if (id === before) {\n return;\n }\n\n const index = this._order.indexOf(id);\n this._order.splice(index, 1);\n\n const newIndex = before ? this._order.indexOf(before) : this._order.length;\n if (before && newIndex === -1) {\n this.fire(new ErrorEvent(new Error(`Cannot move layer \"${id}\" before non-existing layer \"${before}\".`)));\n return;\n }\n this._order.splice(newIndex, 0, id);\n\n this._layerOrderChanged = true;\n }\n\n /**\n * Remove the layer with the given id from the style.\n *\n * If no such layer exists, an `error` event is fired.\n *\n * @param id - id of the layer to remove\n * @event `error` - Fired if the layer does not exist\n */\n removeLayer(id: string) {\n this._checkLoaded();\n\n const layer = this._layers[id];\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot remove non-existing layer \"${id}\".`)));\n return;\n }\n\n layer.setEventedParent(null);\n\n const index = this._order.indexOf(id);\n this._order.splice(index, 1);\n\n this._layerOrderChanged = true;\n this._changed = true;\n this._removedLayers[id] = layer;\n delete this._layers[id];\n\n if (this._serializedLayers) {\n delete this._serializedLayers[id];\n }\n delete this._updatedLayers[id];\n delete this._updatedPaintProps[id];\n\n if (layer.onRemove) {\n layer.onRemove(this.map);\n }\n }\n\n /**\n * Return the style layer object with the given `id`.\n *\n * @param id - id of the desired layer\n * @returns a layer, if one with the given `id` exists\n */\n getLayer(id: string): StyleLayer | undefined {\n return this._layers[id];\n }\n\n /**\n * Return the ids of all layers currently in the style, including custom layers, in order.\n *\n * @returns ids of layers, in order\n */\n getLayersOrder(): string[] {\n return [...this._order];\n }\n\n /**\n * Checks if a specific layer is present within the style.\n *\n * @param id - the id of the desired layer\n * @returns a boolean specifying if the given layer is present\n */\n hasLayer(id: string): boolean {\n return id in this._layers;\n }\n\n setLayerZoomRange(layerId: string, minzoom?: number | null, maxzoom?: number | null) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (layer.minzoom === minzoom && layer.maxzoom === maxzoom) return;\n\n if (minzoom != null) {\n layer.minzoom = minzoom;\n }\n if (maxzoom != null) {\n layer.maxzoom = maxzoom;\n }\n this._updateLayer(layer);\n }\n\n setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot filter non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.filter, filter)) {\n return;\n }\n\n if (filter === null || filter === undefined) {\n layer.filter = undefined;\n this._updateLayer(layer);\n return;\n }\n\n if (this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter, null, options)) {\n return;\n }\n\n layer.filter = clone(filter);\n this._updateLayer(layer);\n }\n\n /**\n * Get a layer's filter object\n * @param layer - the layer to inspect\n * @returns the layer's filter, if any\n */\n getFilter(layer: string): FilterSpecification | void {\n return clone(this.getLayer(layer).filter);\n }\n\n setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.getLayoutProperty(name), value)) return;\n\n layer.setLayoutProperty(name, value, options);\n this._updateLayer(layer);\n }\n\n /**\n * Get a layout property's value from a given layer\n * @param layerId - the layer to inspect\n * @param name - the name of the layout property\n * @returns the property value\n */\n getLayoutProperty(layerId: string, name: string) {\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot get style of non-existing layer \"${layerId}\".`)));\n return;\n }\n\n return layer.getLayoutProperty(name);\n }\n\n setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.getPaintProperty(name), value)) return;\n\n const requiresRelayout = layer.setPaintProperty(name, value, options);\n if (requiresRelayout) {\n this._updateLayer(layer);\n }\n\n this._changed = true;\n this._updatedPaintProps[layerId] = true;\n }\n\n getPaintProperty(layer: string, name: string) {\n return this.getLayer(layer).getPaintProperty(name);\n }\n\n setFeatureState(target: FeatureIdentifier, state: any) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceLayer = target.sourceLayer;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n const sourceType = sourceCache.getSource().type;\n if (sourceType === 'geojson' && sourceLayer) {\n this.fire(new ErrorEvent(new Error('GeoJSON sources cannot have a sourceLayer parameter.')));\n return;\n }\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n if (target.id === undefined) {\n this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.')));\n }\n\n sourceCache.setFeatureState(sourceLayer, target.id, state);\n }\n\n removeFeatureState(target: FeatureIdentifier, key?: string) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n\n const sourceType = sourceCache.getSource().type;\n const sourceLayer = sourceType === 'vector' ? target.sourceLayer : undefined;\n\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n\n if (key && (typeof target.id !== 'string' && typeof target.id !== 'number')) {\n this.fire(new ErrorEvent(new Error('A feature id is required to remove its specific state property.')));\n return;\n }\n\n sourceCache.removeFeatureState(sourceLayer, target.id, key);\n }\n\n getFeatureState(target: FeatureIdentifier) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceLayer = target.sourceLayer;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n const sourceType = sourceCache.getSource().type;\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n if (target.id === undefined) {\n this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.')));\n }\n\n return sourceCache.getFeatureState(sourceLayer, target.id);\n }\n\n getTransition() {\n return extend({duration: 300, delay: 0}, this.stylesheet && this.stylesheet.transition);\n }\n\n serialize(): StyleSpecification {\n // We return undefined before we're loaded, following the pattern of Map.getStyle() before\n // the Style object is initialized.\n // Internally, Style._validate() calls Style.serialize() but callers are responsible for\n // calling Style._checkLoaded() first if their validation requires the style to be loaded.\n if (!this._loaded) return;\n\n const sources = mapObject(this.sourceCaches, (source) => source.serialize());\n const layers = this._serializeByIds(this._order);\n const terrain = this.map.getTerrain() || undefined;\n const myStyleSheet = this.stylesheet;\n\n return filterObject({\n version: myStyleSheet.version,\n name: myStyleSheet.name,\n metadata: myStyleSheet.metadata,\n light: myStyleSheet.light,\n center: myStyleSheet.center,\n zoom: myStyleSheet.zoom,\n bearing: myStyleSheet.bearing,\n pitch: myStyleSheet.pitch,\n sprite: myStyleSheet.sprite,\n glyphs: myStyleSheet.glyphs,\n transition: myStyleSheet.transition,\n sources,\n layers,\n terrain\n },\n (value) => { return value !== undefined; });\n }\n\n _updateLayer(layer: StyleLayer) {\n this._updatedLayers[layer.id] = true;\n if (layer.source && !this._updatedSources[layer.source] &&\n //Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865)\n this.sourceCaches[layer.source].getSource().type !== 'raster') {\n this._updatedSources[layer.source] = 'reload';\n this.sourceCaches[layer.source].pause();\n }\n\n // upon updating, serilized layer dictionary should be reset.\n // When needed, it will be populated with the correct copy again.\n this._serializedLayers = null;\n this._changed = true;\n }\n\n _flattenAndSortRenderedFeatures(sourceResults: Array<{ [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> }>) {\n // Feature order is complicated.\n // The order between features in two 2D layers is always determined by layer order.\n // The order between features in two 3D layers is always determined by depth.\n // The order between a feature in a 2D layer and a 3D layer is tricky:\n // Most often layer order determines the feature order in this case. If\n // a line layer is above a extrusion layer the line feature will be rendered\n // above the extrusion. If the line layer is below the extrusion layer,\n // it will be rendered below it.\n //\n // There is a weird case though.\n // You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b\n // Each layer has a feature that overlaps the other features.\n // The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above.\n // The feature in line_layer is rendered above extrusion_layer_a.\n // This means that that the line_layer feature is above the extrusion_layer_b feature despite\n // it being in an earlier layer.\n\n const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion';\n\n const layerIndex = {};\n const features3D = [];\n for (let l = this._order.length - 1; l >= 0; l--) {\n const layerId = this._order[l];\n if (isLayer3D(layerId)) {\n layerIndex[layerId] = l;\n for (const sourceResult of sourceResults) {\n const layerFeatures = sourceResult[layerId];\n if (layerFeatures) {\n for (const featureWrapper of layerFeatures) {\n features3D.push(featureWrapper);\n }\n }\n }\n }\n }\n\n features3D.sort((a, b) => {\n return b.intersectionZ - a.intersectionZ;\n });\n\n const features = [];\n for (let l = this._order.length - 1; l >= 0; l--) {\n const layerId = this._order[l];\n\n if (isLayer3D(layerId)) {\n // add all 3D features that are in or above the current layer\n for (let i = features3D.length - 1; i >= 0; i--) {\n const topmost3D = features3D[i].feature;\n if (layerIndex[topmost3D.layer.id] < l) break;\n features.push(topmost3D);\n features3D.pop();\n }\n } else {\n for (const sourceResult of sourceResults) {\n const layerFeatures = sourceResult[layerId];\n if (layerFeatures) {\n for (const featureWrapper of layerFeatures) {\n features.push(featureWrapper.feature);\n }\n }\n }\n }\n }\n\n return features;\n }\n\n queryRenderedFeatures(queryGeometry: any, params: QueryRenderedFeaturesOptions, transform: Transform) {\n if (params && params.filter) {\n this._validate(validateStyle.filter, 'queryRenderedFeatures.filter', params.filter, null, params);\n }\n\n const includedSources = {};\n if (params && params.layers) {\n if (!Array.isArray(params.layers)) {\n this.fire(new ErrorEvent(new Error('parameters.layers must be an Array.')));\n return [];\n }\n for (const layerId of params.layers) {\n const layer = this._layers[layerId];\n if (!layer) {\n // this layer is not in the style.layers array\n this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be queried for features.`)));\n return [];\n }\n includedSources[layer.source] = true;\n }\n }\n\n const sourceResults = [];\n\n params.availableImages = this._availableImages;\n\n // LayerSpecification is serialized StyleLayer, and this casting is safe.\n const serializedLayers = this._serializedAllLayers() as {[_: string]: StyleLayer};\n\n for (const id in this.sourceCaches) {\n if (params.layers && !includedSources[id]) continue;\n sourceResults.push(\n queryRenderedFeatures(\n this.sourceCaches[id],\n this._layers,\n serializedLayers,\n queryGeometry,\n params,\n transform)\n );\n }\n\n if (this.placement) {\n // If a placement has run, query against its CollisionIndex\n // for symbol results, and treat it as an extra source to merge\n sourceResults.push(\n queryRenderedSymbols(\n this._layers,\n serializedLayers,\n this.sourceCaches,\n queryGeometry,\n params,\n this.placement.collisionIndex,\n this.placement.retainedQueryData)\n );\n }\n\n return this._flattenAndSortRenderedFeatures(sourceResults);\n }\n\n querySourceFeatures(\n sourceID: string,\n params?: QuerySourceFeatureOptions\n ) {\n if (params && params.filter) {\n this._validate(validateStyle.filter, 'querySourceFeatures.filter', params.filter, null, params);\n }\n const sourceCache = this.sourceCaches[sourceID];\n return sourceCache ? querySourceFeatures(sourceCache, params) : [];\n }\n\n addSourceType(name: string, SourceType: SourceClass, callback: Callback) {\n if (getSourceType(name)) {\n return callback(new Error(`A source type called \"${name}\" already exists.`));\n }\n\n setSourceType(name, SourceType);\n\n if (!SourceType.workerSourceURL) {\n return callback(null, null);\n }\n\n this.dispatcher.broadcast('loadWorkerSource', {\n name,\n url: SourceType.workerSourceURL\n }, callback);\n }\n\n getLight() {\n return this.light.getLight();\n }\n\n setLight(lightOptions: LightSpecification, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const light = this.light.getLight();\n let _update = false;\n for (const key in lightOptions) {\n if (!deepEqual(lightOptions[key], light[key])) {\n _update = true;\n break;\n }\n }\n if (!_update) return;\n\n const parameters = {\n now: browser.now(),\n transition: extend({\n duration: 300,\n delay: 0\n }, this.stylesheet.transition)\n };\n\n this.light.setLight(lightOptions, options);\n this.light.updateTransitions(parameters);\n }\n\n _validate(validate: Validator, key: string, value: any, props: any, options: {\n validate?: boolean;\n } = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, extend({\n key,\n style: this.serialize(),\n value,\n styleSpec\n }, props)));\n }\n\n _remove(mapRemoved: boolean = true) {\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n if (this._spriteRequest) {\n this._spriteRequest.cancel();\n this._spriteRequest = null;\n }\n rtlTextPluginEvented.off('pluginStateChange', this._rtlTextPluginCallback);\n for (const layerId in this._layers) {\n const layer: StyleLayer = this._layers[layerId];\n layer.setEventedParent(null);\n }\n for (const id in this.sourceCaches) {\n const sourceCache = this.sourceCaches[id];\n sourceCache.setEventedParent(null);\n sourceCache.onRemove(this.map);\n }\n this.imageManager.setEventedParent(null);\n this.setEventedParent(null);\n this.dispatcher.remove(mapRemoved);\n }\n\n _clearSource(id: string) {\n this.sourceCaches[id].clearTiles();\n }\n\n _reloadSource(id: string) {\n this.sourceCaches[id].resume();\n this.sourceCaches[id].reload();\n }\n\n _updateSources(transform: Transform) {\n for (const id in this.sourceCaches) {\n this.sourceCaches[id].update(transform, this.map.terrain);\n }\n }\n\n _generateCollisionBoxes() {\n for (const id in this.sourceCaches) {\n this._reloadSource(id);\n }\n }\n\n _updatePlacement(transform: Transform, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, forceFullPlacement: boolean = false) {\n let symbolBucketsChanged = false;\n let placementCommitted = false;\n\n const layerTiles = {};\n\n for (const layerID of this._order) {\n const styleLayer = this._layers[layerID];\n if (styleLayer.type !== 'symbol') continue;\n\n if (!layerTiles[styleLayer.source]) {\n const sourceCache = this.sourceCaches[styleLayer.source];\n layerTiles[styleLayer.source] = sourceCache.getRenderableIds(true)\n .map((id) => sourceCache.getTileByID(id))\n .sort((a, b) => (b.tileID.overscaledZ - a.tileID.overscaledZ) || (a.tileID.isLessThan(b.tileID) ? -1 : 1));\n }\n\n const layerBucketsChanged = this.crossTileSymbolIndex.addLayer(styleLayer, layerTiles[styleLayer.source], transform.center.lng);\n symbolBucketsChanged = symbolBucketsChanged || layerBucketsChanged;\n }\n this.crossTileSymbolIndex.pruneUnusedLayers(this._order);\n\n // Anything that changes our \"in progress\" layer and tile indices requires us\n // to start over. When we start over, we do a full placement instead of incremental\n // to prevent starvation.\n // We need to restart placement to keep layer indices in sync.\n // Also force full placement when fadeDuration === 0 to ensure that newly loaded\n // tiles will fully display symbols in their first frame\n forceFullPlacement = forceFullPlacement || this._layerOrderChanged || fadeDuration === 0;\n\n if (forceFullPlacement || !this.pauseablePlacement || (this.pauseablePlacement.isDone() && !this.placement.stillRecent(browser.now(), transform.zoom))) {\n this.pauseablePlacement = new PauseablePlacement(transform, this.map.terrain, this._order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, this.placement);\n this._layerOrderChanged = false;\n }\n\n if (this.pauseablePlacement.isDone()) {\n // the last placement finished running, but the next one hasn’t\n // started yet because of the `stillRecent` check immediately\n // above, so mark it stale to ensure that we request another\n // render frame\n this.placement.setStale();\n } else {\n this.pauseablePlacement.continuePlacement(this._order, this._layers, layerTiles);\n\n if (this.pauseablePlacement.isDone()) {\n this.placement = this.pauseablePlacement.commit(browser.now());\n placementCommitted = true;\n }\n\n if (symbolBucketsChanged) {\n // since the placement gets split over multiple frames it is possible\n // these buckets were processed before they were changed and so the\n // placement is already stale while it is in progress\n this.pauseablePlacement.placement.setStale();\n }\n }\n\n if (placementCommitted || symbolBucketsChanged) {\n for (const layerID of this._order) {\n const styleLayer = this._layers[layerID];\n if (styleLayer.type !== 'symbol') continue;\n this.placement.updateLayerOpacities(styleLayer, layerTiles[styleLayer.source]);\n }\n }\n\n // needsRender is false when we have just finished a placement that didn't change the visibility of any symbols\n const needsRerender = !this.pauseablePlacement.isDone() || this.placement.hasTransitions(browser.now());\n return needsRerender;\n }\n\n _releaseSymbolFadeTiles() {\n for (const id in this.sourceCaches) {\n this.sourceCaches[id].releaseSymbolFadeTiles();\n }\n }\n\n // Callbacks from web workers\n\n getImages(\n mapId: string,\n params: {\n icons: Array;\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: StyleImage}>\n ) {\n this.imageManager.getImages(params.icons, callback);\n\n // Apply queued image changes before setting the tile's dependencies so that the tile\n // is not reloaded unnecessarily. Without this forced update the reload could happen in cases\n // like this one:\n // - icons contains \"my-image\"\n // - imageManager.getImages(...) triggers `onstyleimagemissing`\n // - the user adds \"my-image\" within the callback\n // - addImage adds \"my-image\" to this._changedImages\n // - the next frame triggers a reload of this tile even though it already has the latest version\n this._updateTilesForChangedImages();\n\n const sourceCache = this.sourceCaches[params.source];\n if (sourceCache) {\n sourceCache.setDependencies(params.tileID.key, params.type, params.icons);\n }\n }\n\n getGlyphs(\n mapId: string,\n params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n ) {\n this.glyphManager.getGlyphs(params.stacks, callback);\n const sourceCache = this.sourceCaches[params.source];\n if (sourceCache) {\n // we are not setting stacks as dependencies since for now\n // we just need to know which tiles have glyph dependencies\n sourceCache.setDependencies(params.tileID.key, params.type, ['']);\n }\n }\n\n getResource(mapId: string, params: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(params, callback);\n }\n\n getGlyphsUrl() {\n return this.stylesheet.glyphs || null;\n }\n\n setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n if (glyphsUrl && this._validate(validateStyle.glyphs, 'glyphs', glyphsUrl, null, options)) {\n return;\n }\n\n this._glyphsDidChange = true;\n this.stylesheet.glyphs = glyphsUrl;\n this.glyphManager.entries = {};\n this.glyphManager.setURL(glyphsUrl);\n }\n\n /**\n * Add a sprite.\n *\n * @param id - The id of the desired sprite\n * @param url - The url to load the desired sprite from\n * @param options - The style setter options\n * @param completion - The completion handler\n */\n addSprite(id: string, url: string, options: StyleSetterOptions = {}, completion?: (err: Error) => void) {\n this._checkLoaded();\n\n const spriteToAdd = [{id, url}];\n const updatedSprite = [\n ...coerceSpriteToArray(this.stylesheet.sprite),\n ...spriteToAdd\n ];\n\n if (this._validate(validateStyle.sprite, 'sprite', updatedSprite, null, options)) return;\n\n this.stylesheet.sprite = updatedSprite;\n this._loadSprite(spriteToAdd, true, completion);\n }\n\n /**\n * Remove a sprite by its id. When the last sprite is removed, the whole `this.stylesheet.sprite` object becomes\n * `undefined`. This falsy `undefined` value later prevents attempts to load the sprite when it's absent.\n *\n * @param id - the id of the sprite to remove\n */\n removeSprite(id: string) {\n this._checkLoaded();\n\n const internalSpriteRepresentation = coerceSpriteToArray(this.stylesheet.sprite);\n\n if (!internalSpriteRepresentation.find(sprite => sprite.id === id)) {\n this.fire(new ErrorEvent(new Error(`Sprite \"${id}\" doesn't exists on this map.`)));\n return;\n }\n\n if (this._spritesImagesIds[id]) {\n for (const imageId of this._spritesImagesIds[id]) {\n this.imageManager.removeImage(imageId);\n this._changedImages[imageId] = true;\n }\n }\n\n internalSpriteRepresentation.splice(internalSpriteRepresentation.findIndex(sprite => sprite.id === id), 1);\n this.stylesheet.sprite = internalSpriteRepresentation.length > 0 ? internalSpriteRepresentation : undefined;\n\n delete this._spritesImagesIds[id];\n this._availableImages = this.imageManager.listImages();\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n /**\n * Get the current sprite value.\n *\n * @returns empty array when no sprite is set; id-url pairs otherwise\n */\n getSprite() {\n return coerceSpriteToArray(this.stylesheet.sprite);\n }\n\n /**\n * Set a new value for the style's sprite.\n *\n * @param sprite - new sprite value\n * @param options - style setter options\n * @param completion - the completion handler\n */\n setSprite(sprite: SpriteSpecification, options: StyleSetterOptions = {}, completion?: (err: Error) => void) {\n this._checkLoaded();\n\n if (sprite && this._validate(validateStyle.sprite, 'sprite', sprite, null, options)) {\n return;\n }\n\n this.stylesheet.sprite = sprite;\n\n if (sprite) {\n this._loadSprite(sprite, true, completion);\n } else {\n this._unloadSprite();\n if (completion) {\n completion(null);\n }\n }\n }\n}\n\nStyle.registerForPluginStateChange = registerForPluginStateChange;\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos', type: 'Int16', components: 2}\n]);\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision mediump float;\\n#else\\n#if !defined(lowp)\\n#define lowp\\n#endif\\n#if !defined(mediump)\\n#define mediump\\n#endif\\n#if !defined(highp)\\n#define highp\\n#endif\\n#endif\\n';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#else\\n#if !defined(lowp)\\n#define lowp\\n#endif\\n#if !defined(mediump)\\n#define mediump\\n#endif\\n#if !defined(highp)\\n#define highp\\n#endif\\n#endif\\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\\n#ifdef TERRAIN3D\\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\\n#endif\\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\\n#ifdef TERRAIN3D\\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\\n#else\\nreturn 1.0;\\n#endif\\n}float calculate_visibility(vec4 pos) {\\n#ifdef TERRAIN3D\\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\\n#else\\nreturn 1.0;\\n#endif\\n}float ele(vec2 pos) {\\n#ifdef TERRAIN3D\\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\\n#else\\nreturn 0.0;\\n#endif\\n}float get_elevation(vec2 pos) {\\n#ifdef TERRAIN3D\\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\\n#else\\nreturn 0.0;\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec3 v_data;varying float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvoid main(void) {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'void main() {gl_FragColor=vec4(1.0);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform highp float u_intensity;varying vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main() {\\n#pragma mapbox: initialize highp float weight\\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#pragma mapbox: define mediump float radius\\nconst highp float ZERO=1.0/255.0/16.0;\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main(void) {\\n#pragma mapbox: initialize highp float weight\\n#pragma mapbox: initialize mediump float radius\\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(0.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_FragColor=color*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec4 v_color;void main() {gl_FragColor=v_color;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\\n#ifdef TERRAIN3D\\nattribute vec2 a_centroid;\\n#endif\\nvarying vec4 v_color;\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\n#pragma mapbox: define highp vec4 color\\nvoid main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\n#pragma mapbox: initialize highp vec4 color\\nvec3 normal=a_normal_ed.xyz;\\n#ifdef TERRAIN3D\\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\\n#else\\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\\n#endif\\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\\n#pragma mapbox: define lowp float base\\n#pragma mapbox: define lowp float height\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float base\\n#pragma mapbox: initialize lowp float height\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\\n#ifdef TERRAIN3D\\nattribute vec2 a_centroid;\\n#endif\\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\\n#pragma mapbox: define lowp float base\\n#pragma mapbox: define lowp float height\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float base\\n#pragma mapbox: initialize lowp float height\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\\n#ifdef TERRAIN3D\\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\\n#else\\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\\n#endif\\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\\n? a_pos\\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\\n#define PI 3.141592653589793\\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\n#define LINE_DISTANCE_SCALE 2.0\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\n#define LINE_DISTANCE_SCALE 2.0\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#define SDF_PX 8.0\\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#define SDF_PX 8.0\\n#define SDF 1.0\\n#define ICON 0.0\\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}';\n","\n// Disable Flow annotations here because Flow doesn't support importing GLSL files\n\nimport preludeFrag from './_prelude.fragment.glsl.g';\nimport preludeVert from './_prelude.vertex.glsl.g';\nimport backgroundFrag from './background.fragment.glsl.g';\nimport backgroundVert from './background.vertex.glsl.g';\nimport backgroundPatternFrag from './background_pattern.fragment.glsl.g';\nimport backgroundPatternVert from './background_pattern.vertex.glsl.g';\nimport circleFrag from './circle.fragment.glsl.g';\nimport circleVert from './circle.vertex.glsl.g';\nimport clippingMaskFrag from './clipping_mask.fragment.glsl.g';\nimport clippingMaskVert from './clipping_mask.vertex.glsl.g';\nimport heatmapFrag from './heatmap.fragment.glsl.g';\nimport heatmapVert from './heatmap.vertex.glsl.g';\nimport heatmapTextureFrag from './heatmap_texture.fragment.glsl.g';\nimport heatmapTextureVert from './heatmap_texture.vertex.glsl.g';\nimport collisionBoxFrag from './collision_box.fragment.glsl.g';\nimport collisionBoxVert from './collision_box.vertex.glsl.g';\nimport collisionCircleFrag from './collision_circle.fragment.glsl.g';\nimport collisionCircleVert from './collision_circle.vertex.glsl.g';\nimport debugFrag from './debug.fragment.glsl.g';\nimport debugVert from './debug.vertex.glsl.g';\nimport fillFrag from './fill.fragment.glsl.g';\nimport fillVert from './fill.vertex.glsl.g';\nimport fillOutlineFrag from './fill_outline.fragment.glsl.g';\nimport fillOutlineVert from './fill_outline.vertex.glsl.g';\nimport fillOutlinePatternFrag from './fill_outline_pattern.fragment.glsl.g';\nimport fillOutlinePatternVert from './fill_outline_pattern.vertex.glsl.g';\nimport fillPatternFrag from './fill_pattern.fragment.glsl.g';\nimport fillPatternVert from './fill_pattern.vertex.glsl.g';\nimport fillExtrusionFrag from './fill_extrusion.fragment.glsl.g';\nimport fillExtrusionVert from './fill_extrusion.vertex.glsl.g';\nimport fillExtrusionPatternFrag from './fill_extrusion_pattern.fragment.glsl.g';\nimport fillExtrusionPatternVert from './fill_extrusion_pattern.vertex.glsl.g';\nimport hillshadePrepareFrag from './hillshade_prepare.fragment.glsl.g';\nimport hillshadePrepareVert from './hillshade_prepare.vertex.glsl.g';\nimport hillshadeFrag from './hillshade.fragment.glsl.g';\nimport hillshadeVert from './hillshade.vertex.glsl.g';\nimport lineFrag from './line.fragment.glsl.g';\nimport lineVert from './line.vertex.glsl.g';\nimport lineGradientFrag from './line_gradient.fragment.glsl.g';\nimport lineGradientVert from './line_gradient.vertex.glsl.g';\nimport linePatternFrag from './line_pattern.fragment.glsl.g';\nimport linePatternVert from './line_pattern.vertex.glsl.g';\nimport lineSDFFrag from './line_sdf.fragment.glsl.g';\nimport lineSDFVert from './line_sdf.vertex.glsl.g';\nimport rasterFrag from './raster.fragment.glsl.g';\nimport rasterVert from './raster.vertex.glsl.g';\nimport symbolIconFrag from './symbol_icon.fragment.glsl.g';\nimport symbolIconVert from './symbol_icon.vertex.glsl.g';\nimport symbolSDFFrag from './symbol_sdf.fragment.glsl.g';\nimport symbolSDFVert from './symbol_sdf.vertex.glsl.g';\nimport symbolTextAndIconFrag from './symbol_text_and_icon.fragment.glsl.g';\nimport symbolTextAndIconVert from './symbol_text_and_icon.vertex.glsl.g';\nimport terrainDepthFrag from './terrain_depth.fragment.glsl.g';\nimport terrainCoordsFrag from './terrain_coords.fragment.glsl.g';\nimport terrainFrag from './terrain.fragment.glsl.g';\nimport terrainVert from './terrain.vertex.glsl.g';\n\nexport const shaders = {\n prelude: compile(preludeFrag, preludeVert),\n background: compile(backgroundFrag, backgroundVert),\n backgroundPattern: compile(backgroundPatternFrag, backgroundPatternVert),\n circle: compile(circleFrag, circleVert),\n clippingMask: compile(clippingMaskFrag, clippingMaskVert),\n heatmap: compile(heatmapFrag, heatmapVert),\n heatmapTexture: compile(heatmapTextureFrag, heatmapTextureVert),\n collisionBox: compile(collisionBoxFrag, collisionBoxVert),\n collisionCircle: compile(collisionCircleFrag, collisionCircleVert),\n debug: compile(debugFrag, debugVert),\n fill: compile(fillFrag, fillVert),\n fillOutline: compile(fillOutlineFrag, fillOutlineVert),\n fillOutlinePattern: compile(fillOutlinePatternFrag, fillOutlinePatternVert),\n fillPattern: compile(fillPatternFrag, fillPatternVert),\n fillExtrusion: compile(fillExtrusionFrag, fillExtrusionVert),\n fillExtrusionPattern: compile(fillExtrusionPatternFrag, fillExtrusionPatternVert),\n hillshadePrepare: compile(hillshadePrepareFrag, hillshadePrepareVert),\n hillshade: compile(hillshadeFrag, hillshadeVert),\n line: compile(lineFrag, lineVert),\n lineGradient: compile(lineGradientFrag, lineGradientVert),\n linePattern: compile(linePatternFrag, linePatternVert),\n lineSDF: compile(lineSDFFrag, lineSDFVert),\n raster: compile(rasterFrag, rasterVert),\n symbolIcon: compile(symbolIconFrag, symbolIconVert),\n symbolSDF: compile(symbolSDFFrag, symbolSDFVert),\n symbolTextAndIcon: compile(symbolTextAndIconFrag, symbolTextAndIconVert),\n terrain: compile(terrainFrag, terrainVert),\n terrainDepth: compile(terrainDepthFrag, terrainVert),\n terrainCoords: compile(terrainCoordsFrag, terrainVert)\n};\n\n// Expand #pragmas to #ifdefs.\n\nfunction compile(fragmentSource, vertexSource) {\n const re = /#pragma mapbox: ([\\w]+) ([\\w]+) ([\\w]+) ([\\w]+)/g;\n\n const staticAttributes = vertexSource.match(/attribute ([\\w]+) ([\\w]+)/g);\n const fragmentUniforms = fragmentSource.match(/uniform ([\\w]+) ([\\w]+)([\\s]*)([\\w]*)/g);\n const vertexUniforms = vertexSource.match(/uniform ([\\w]+) ([\\w]+)([\\s]*)([\\w]*)/g);\n const staticUniforms = vertexUniforms ? vertexUniforms.concat(fragmentUniforms) : fragmentUniforms;\n\n const fragmentPragmas = {};\n\n fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => {\n fragmentPragmas[name] = true;\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nvarying ${precision} ${type} ${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n return `\n#ifdef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n });\n\n vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => {\n const attrType = type === 'float' ? 'vec2' : 'vec4';\n const unpackType = name.match(/color/) ? 'color' : attrType;\n\n if (fragmentPragmas[name]) {\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nuniform lowp float u_${name}_t;\nattribute ${precision} ${attrType} a_${name};\nvarying ${precision} ${type} ${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n if (unpackType === 'vec4') {\n // vec4 attributes are only used for cross-faded properties, and are not packed\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${name} = a_${name};\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n } else {\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n }\n } else {\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nuniform lowp float u_${name}_t;\nattribute ${precision} ${attrType} a_${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n if (unpackType === 'vec4') {\n // vec4 attributes are only used for cross-faded properties, and are not packed\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = a_${name};\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n } else /* */ {\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n }\n }\n });\n\n return {fragmentSource, vertexSource, staticAttributes, staticUniforms};\n}\n","\nimport type {Program} from './program';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {Context} from '../gl/context';\n\n/**\n * @internal\n * A vertex array object used to pass data to the webgl code\n */\nexport class VertexArrayObject {\n context: Context;\n boundProgram: Program;\n boundLayoutVertexBuffer: VertexBuffer;\n boundPaintVertexBuffers: Array;\n boundIndexBuffer: IndexBuffer;\n boundVertexOffset: number;\n boundDynamicVertexBuffer: VertexBuffer;\n boundDynamicVertexBuffer2: VertexBuffer;\n boundDynamicVertexBuffer3: VertexBuffer;\n vao: any;\n\n constructor() {\n this.boundProgram = null;\n this.boundLayoutVertexBuffer = null;\n this.boundPaintVertexBuffers = [];\n this.boundIndexBuffer = null;\n this.boundVertexOffset = null;\n this.boundDynamicVertexBuffer = null;\n this.vao = null;\n }\n\n bind(context: Context,\n program: Program,\n layoutVertexBuffer: VertexBuffer,\n paintVertexBuffers: Array,\n indexBuffer?: IndexBuffer | null,\n vertexOffset?: number | null,\n dynamicVertexBuffer?: VertexBuffer | null,\n dynamicVertexBuffer2?: VertexBuffer | null,\n dynamicVertexBuffer3?: VertexBuffer | null) {\n\n this.context = context;\n\n let paintBuffersDiffer = this.boundPaintVertexBuffers.length !== paintVertexBuffers.length;\n for (let i = 0; !paintBuffersDiffer && i < paintVertexBuffers.length; i++) {\n if (this.boundPaintVertexBuffers[i] !== paintVertexBuffers[i]) {\n paintBuffersDiffer = true;\n }\n }\n\n const isFreshBindRequired = (\n !this.vao ||\n this.boundProgram !== program ||\n this.boundLayoutVertexBuffer !== layoutVertexBuffer ||\n paintBuffersDiffer ||\n this.boundIndexBuffer !== indexBuffer ||\n this.boundVertexOffset !== vertexOffset ||\n this.boundDynamicVertexBuffer !== dynamicVertexBuffer ||\n this.boundDynamicVertexBuffer2 !== dynamicVertexBuffer2 ||\n this.boundDynamicVertexBuffer3 !== dynamicVertexBuffer3\n );\n\n if (isFreshBindRequired) {\n this.freshBind(program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3);\n } else {\n context.bindVertexArray.set(this.vao);\n\n if (dynamicVertexBuffer) {\n // The buffer may have been updated. Rebind to upload data.\n dynamicVertexBuffer.bind();\n }\n\n if (indexBuffer && indexBuffer.dynamicDraw) {\n indexBuffer.bind();\n }\n\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.bind();\n }\n\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.bind();\n }\n }\n }\n\n freshBind(program: Program,\n layoutVertexBuffer: VertexBuffer,\n paintVertexBuffers: Array,\n indexBuffer?: IndexBuffer | null,\n vertexOffset?: number | null,\n dynamicVertexBuffer?: VertexBuffer | null,\n dynamicVertexBuffer2?: VertexBuffer | null,\n dynamicVertexBuffer3?: VertexBuffer | null) {\n\n const numNextAttributes = program.numAttributes;\n\n const context = this.context;\n const gl = context.gl;\n\n if (this.vao) this.destroy();\n this.vao = context.createVertexArray();\n context.bindVertexArray.set(this.vao);\n\n // store the arguments so that we can verify them when the vao is bound again\n this.boundProgram = program;\n this.boundLayoutVertexBuffer = layoutVertexBuffer;\n this.boundPaintVertexBuffers = paintVertexBuffers;\n this.boundIndexBuffer = indexBuffer;\n this.boundVertexOffset = vertexOffset;\n this.boundDynamicVertexBuffer = dynamicVertexBuffer;\n this.boundDynamicVertexBuffer2 = dynamicVertexBuffer2;\n this.boundDynamicVertexBuffer3 = dynamicVertexBuffer3;\n\n layoutVertexBuffer.enableAttributes(gl, program);\n for (const vertexBuffer of paintVertexBuffers) {\n vertexBuffer.enableAttributes(gl, program);\n }\n\n if (dynamicVertexBuffer) {\n dynamicVertexBuffer.enableAttributes(gl, program);\n }\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.enableAttributes(gl, program);\n }\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.enableAttributes(gl, program);\n }\n\n layoutVertexBuffer.bind();\n layoutVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n for (const vertexBuffer of paintVertexBuffers) {\n vertexBuffer.bind();\n vertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n }\n\n if (dynamicVertexBuffer) {\n dynamicVertexBuffer.bind();\n dynamicVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n }\n if (indexBuffer) {\n indexBuffer.bind();\n }\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.bind();\n dynamicVertexBuffer2.setVertexAttribPointers(gl, program, vertexOffset);\n }\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.bind();\n dynamicVertexBuffer3.setVertexAttribPointers(gl, program, vertexOffset);\n }\n\n context.currentNumAttributes = numNextAttributes;\n }\n\n destroy() {\n if (this.vao) {\n this.context.deleteVertexArray(this.vao);\n this.vao = null;\n }\n }\n}\n","import {\n Uniform1i,\n Uniform1f,\n Uniform4f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../../render/uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type TerrainPreludeUniformsType = {\n 'u_depth': Uniform1i;\n 'u_terrain': Uniform1i;\n 'u_terrain_dim': Uniform1f;\n 'u_terrain_matrix': UniformMatrix4f;\n 'u_terrain_unpack': Uniform4f;\n 'u_terrain_exaggeration': Uniform1f;\n};\n\nexport type TerrainUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texture': Uniform1i;\n 'u_ele_delta': Uniform1f;\n};\n\nexport type TerrainDepthUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ele_delta': Uniform1f;\n};\n\nexport type TerrainCoordsUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texture': Uniform1i;\n 'u_terrain_coords_id': Uniform1f;\n 'u_ele_delta': Uniform1f;\n};\n\nconst terrainPreludeUniforms = (context: Context, locations: UniformLocations): TerrainPreludeUniformsType => ({\n 'u_depth': new Uniform1i(context, locations.u_depth),\n 'u_terrain': new Uniform1i(context, locations.u_terrain),\n 'u_terrain_dim': new Uniform1f(context, locations.u_terrain_dim),\n 'u_terrain_matrix': new UniformMatrix4f(context, locations.u_terrain_matrix),\n 'u_terrain_unpack': new Uniform4f(context, locations.u_terrain_unpack),\n 'u_terrain_exaggeration': new Uniform1f(context, locations.u_terrain_exaggeration)\n});\n\nconst terrainUniforms = (context: Context, locations: UniformLocations): TerrainUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainDepthUniforms = (context: Context, locations: UniformLocations): TerrainDepthUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainCoordsUniforms = (context: Context, locations: UniformLocations): TerrainCoordsUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_terrain_coords_id': new Uniform1f(context, locations.u_terrain_coords_id),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainUniformValues = (\n matrix: mat4,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_texture': 0,\n 'u_ele_delta': eleDelta\n});\n\nconst terrainDepthUniformValues = (\n matrix: mat4,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_ele_delta': eleDelta\n});\n\nconst terrainCoordsUniformValues = (\n matrix: mat4,\n coordsId: number,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_terrain_coords_id': coordsId / 255,\n 'u_texture': 0,\n 'u_ele_delta': eleDelta\n});\n\nexport {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms, terrainPreludeUniforms, terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues};\n","import {shaders} from '../shaders/shaders';\nimport {ProgramConfiguration} from '../data/program_configuration';\nimport {VertexArrayObject} from './vertex_array_object';\nimport {Context} from '../gl/context';\n\nimport type {SegmentVector} from '../data/segment';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {DepthMode} from '../gl/depth_mode';\nimport type {StencilMode} from '../gl/stencil_mode';\nimport type {ColorMode} from '../gl/color_mode';\nimport type {CullFaceMode} from '../gl/cull_face_mode';\nimport type {UniformBindings, UniformValues, UniformLocations} from './uniform_binding';\nimport type {BinderUniform} from '../data/program_configuration';\nimport {terrainPreludeUniforms, TerrainPreludeUniformsType} from './program/terrain_program';\nimport type {TerrainData} from '../render/terrain';\nimport {Terrain} from '../render/terrain';\n\nexport type DrawMode = WebGLRenderingContextBase['LINES'] | WebGLRenderingContextBase['TRIANGLES'] | WebGL2RenderingContext['LINE_STRIP'];\n\nfunction getTokenizedAttributesAndUniforms(array: Array): Array {\n const result = [];\n\n for (let i = 0; i < array.length; i++) {\n if (array[i] === null) continue;\n const token = array[i].split(' ');\n result.push(token.pop());\n }\n return result;\n}\n\n/**\n * @internal\n * A webgl program to execute in the GPU space\n */\nexport class Program {\n program: WebGLProgram;\n attributes: {[_: string]: number};\n numAttributes: number;\n fixedUniforms: Us;\n terrainUniforms: TerrainPreludeUniformsType;\n binderUniforms: Array;\n failedToCreate: boolean;\n\n constructor(context: Context,\n source: {\n fragmentSource: string;\n vertexSource: string;\n staticAttributes: Array;\n staticUniforms: Array;\n },\n configuration: ProgramConfiguration,\n fixedUniforms: (b: Context, a: UniformLocations) => Us,\n showOverdrawInspector: boolean,\n terrain: Terrain) {\n\n const gl = context.gl;\n this.program = gl.createProgram();\n\n const staticAttrInfo = getTokenizedAttributesAndUniforms(source.staticAttributes);\n const dynamicAttrInfo = configuration ? configuration.getBinderAttributes() : [];\n const allAttrInfo = staticAttrInfo.concat(dynamicAttrInfo);\n\n const preludeUniformsInfo = shaders.prelude.staticUniforms ? getTokenizedAttributesAndUniforms(shaders.prelude.staticUniforms) : [];\n const staticUniformsInfo = source.staticUniforms ? getTokenizedAttributesAndUniforms(source.staticUniforms) : [];\n const dynamicUniformsInfo = configuration ? configuration.getBinderUniforms() : [];\n // remove duplicate uniforms\n const uniformList = preludeUniformsInfo.concat(staticUniformsInfo).concat(dynamicUniformsInfo);\n const allUniformsInfo = [];\n for (const uniform of uniformList) {\n if (allUniformsInfo.indexOf(uniform) < 0) allUniformsInfo.push(uniform);\n }\n\n const defines = configuration ? configuration.defines() : [];\n if (showOverdrawInspector) {\n defines.push('#define OVERDRAW_INSPECTOR;');\n }\n if (terrain) {\n defines.push('#define TERRAIN3D;');\n }\n\n const fragmentSource = defines.concat(shaders.prelude.fragmentSource, source.fragmentSource).join('\\n');\n const vertexSource = defines.concat(shaders.prelude.vertexSource, source.vertexSource).join('\\n');\n\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (gl.isContextLost()) {\n this.failedToCreate = true;\n return;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);\n }\n\n gl.attachShader(this.program, fragmentShader);\n\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n if (gl.isContextLost()) {\n this.failedToCreate = true;\n return;\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);\n }\n\n gl.attachShader(this.program, vertexShader);\n\n this.attributes = {};\n const uniformLocations = {};\n\n this.numAttributes = allAttrInfo.length;\n\n for (let i = 0; i < this.numAttributes; i++) {\n if (allAttrInfo[i]) {\n gl.bindAttribLocation(this.program, i, allAttrInfo[i]);\n this.attributes[allAttrInfo[i]] = i;\n }\n }\n\n gl.linkProgram(this.program);\n\n if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {\n throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);\n }\n\n gl.deleteShader(vertexShader);\n gl.deleteShader(fragmentShader);\n\n for (let it = 0; it < allUniformsInfo.length; it++) {\n const uniform = allUniformsInfo[it];\n if (uniform && !uniformLocations[uniform]) {\n const uniformLocation = gl.getUniformLocation(this.program, uniform);\n if (uniformLocation) {\n uniformLocations[uniform] = uniformLocation;\n }\n }\n }\n\n this.fixedUniforms = fixedUniforms(context, uniformLocations);\n this.terrainUniforms = terrainPreludeUniforms(context, uniformLocations);\n this.binderUniforms = configuration ? configuration.getUniforms(context, uniformLocations) : [];\n }\n\n draw(context: Context,\n drawMode: DrawMode,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly,\n cullFaceMode: Readonly,\n uniformValues: UniformValues,\n terrain: TerrainData,\n layerID: string,\n layoutVertexBuffer: VertexBuffer,\n indexBuffer: IndexBuffer,\n segments: SegmentVector,\n currentProperties?: any,\n zoom?: number | null,\n configuration?: ProgramConfiguration | null,\n dynamicLayoutBuffer?: VertexBuffer | null,\n dynamicLayoutBuffer2?: VertexBuffer | null,\n dynamicLayoutBuffer3?: VertexBuffer | null) {\n\n const gl = context.gl;\n\n if (this.failedToCreate) return;\n\n context.program.set(this.program);\n context.setDepthMode(depthMode);\n context.setStencilMode(stencilMode);\n context.setColorMode(colorMode);\n context.setCullFace(cullFaceMode);\n\n // set variables used by the 3d functions defined in _prelude.vertex.glsl\n if (terrain) {\n context.activeTexture.set(gl.TEXTURE2);\n gl.bindTexture(gl.TEXTURE_2D, terrain.depthTexture);\n context.activeTexture.set(gl.TEXTURE3);\n gl.bindTexture(gl.TEXTURE_2D, terrain.texture);\n for (const name in this.terrainUniforms) {\n this.terrainUniforms[name].set(terrain[name]);\n }\n }\n\n for (const name in this.fixedUniforms) {\n this.fixedUniforms[name].set(uniformValues[name]);\n }\n\n if (configuration) {\n configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom as any)});\n }\n\n let primitiveSize = 0;\n switch (drawMode) {\n case gl.LINES:\n primitiveSize = 2;\n break;\n case gl.TRIANGLES:\n primitiveSize = 3;\n break;\n case gl.LINE_STRIP:\n primitiveSize = 1;\n break;\n }\n\n for (const segment of segments.get()) {\n const vaos = segment.vaos || (segment.vaos = {});\n const vao: VertexArrayObject = vaos[layerID] || (vaos[layerID] = new VertexArrayObject());\n\n vao.bind(\n context,\n this,\n layoutVertexBuffer,\n configuration ? configuration.getPaintVertexBuffers() : [],\n indexBuffer,\n segment.vertexOffset,\n dynamicLayoutBuffer,\n dynamicLayoutBuffer2,\n dynamicLayoutBuffer3\n );\n\n gl.drawElements(\n drawMode,\n segment.primitiveLength * primitiveSize,\n gl.UNSIGNED_SHORT,\n segment.primitiveOffset * primitiveSize * 2);\n }\n }\n}\n","import {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f\n} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Painter} from '../painter';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {CrossFaded} from '../../style/properties';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {UniformValues} from '../uniform_binding';\nimport type {Tile} from '../../source/tile';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\n\ntype BackgroundPatternUniformsType = {\n 'u_image': Uniform1i;\n 'u_pattern_tl_a': Uniform2f;\n 'u_pattern_br_a': Uniform2f;\n 'u_pattern_tl_b': Uniform2f;\n 'u_pattern_br_b': Uniform2f;\n 'u_texsize': Uniform2f;\n 'u_mix': Uniform1f;\n 'u_pattern_size_a': Uniform2f;\n 'u_pattern_size_b': Uniform2f;\n 'u_scale_a': Uniform1f;\n 'u_scale_b': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_tile_units_to_pixels': Uniform1f;\n};\n\nexport type PatternUniformsType = {\n // pattern uniforms:\n 'u_image': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n};\n\nfunction patternUniformValues(crossfade: CrossfadeParameters, painter: Painter, tile: Tile): UniformValues {\n\n const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom);\n\n const numTiles = Math.pow(2, tile.tileID.overscaledZ);\n const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;\n\n const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);\n const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;\n\n return {\n 'u_image': 0,\n 'u_texsize': tile.imageAtlasTexture.size,\n 'u_scale': [tileRatio, crossfade.fromScale, crossfade.toScale],\n 'u_fade': crossfade.t,\n // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.\n 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],\n 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]\n };\n}\n\nfunction bgPatternUniformValues(\n image: CrossFaded,\n crossfade: CrossfadeParameters,\n painter: Painter,\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n }\n): UniformValues {\n const imagePosA = painter.imageManager.getPattern(image.from.toString());\n const imagePosB = painter.imageManager.getPattern(image.to.toString());\n const {width, height} = painter.imageManager.getPixelSize();\n\n const numTiles = Math.pow(2, tile.tileID.overscaledZ);\n const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;\n\n const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);\n const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;\n\n return {\n 'u_image': 0,\n 'u_pattern_tl_a': (imagePosA as any).tl,\n 'u_pattern_br_a': (imagePosA as any).br,\n 'u_pattern_tl_b': (imagePosB as any).tl,\n 'u_pattern_br_b': (imagePosB as any).br,\n 'u_texsize': [width, height],\n 'u_mix': crossfade.t,\n 'u_pattern_size_a': (imagePosA as any).displaySize,\n 'u_pattern_size_b': (imagePosB as any).displaySize,\n 'u_scale_a': crossfade.fromScale,\n 'u_scale_b': crossfade.toScale,\n 'u_tile_units_to_pixels': 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom),\n // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.\n 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],\n 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]\n };\n}\nexport {bgPatternUniformValues, patternUniformValues};\n","import {patternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n UniformMatrix4f\n} from '../uniform_binding';\n\nimport {mat3, mat4, vec3} from 'gl-matrix';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {Painter} from '../painter';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {Tile} from '../../source/tile';\n\nexport type FillExtrusionUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_lightpos': Uniform3f;\n 'u_lightintensity': Uniform1f;\n 'u_lightcolor': Uniform3f;\n 'u_vertical_gradient': Uniform1f;\n 'u_opacity': Uniform1f;\n};\n\nexport type FillExtrusionPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_lightpos': Uniform3f;\n 'u_lightintensity': Uniform1f;\n 'u_lightcolor': Uniform3f;\n 'u_height_factor': Uniform1f;\n 'u_vertical_gradient': Uniform1f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n 'u_opacity': Uniform1f;\n};\n\nconst fillExtrusionUniforms = (context: Context, locations: UniformLocations): FillExtrusionUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_lightpos': new Uniform3f(context, locations.u_lightpos),\n 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity),\n 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor),\n 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst fillExtrusionPatternUniforms = (context: Context, locations: UniformLocations): FillExtrusionPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_lightpos': new Uniform3f(context, locations.u_lightpos),\n 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity),\n 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor),\n 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient),\n 'u_height_factor': new Uniform1f(context, locations.u_height_factor),\n // pattern uniforms\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst fillExtrusionUniformValues = (\n matrix: mat4,\n painter: Painter,\n shouldUseVerticalGradient: boolean,\n opacity: number\n): UniformValues => {\n const light = painter.style.light;\n const _lp = light.properties.get('position');\n const lightPos = [_lp.x, _lp.y, _lp.z] as vec3;\n const lightMat = mat3.create();\n if (light.properties.get('anchor') === 'viewport') {\n mat3.fromRotation(lightMat, -painter.transform.angle);\n }\n vec3.transformMat3(lightPos, lightPos, lightMat);\n\n const lightColor = light.properties.get('color');\n\n return {\n 'u_matrix': matrix,\n 'u_lightpos': lightPos,\n 'u_lightintensity': light.properties.get('intensity'),\n 'u_lightcolor': [lightColor.r, lightColor.g, lightColor.b],\n 'u_vertical_gradient': +shouldUseVerticalGradient,\n 'u_opacity': opacity\n };\n};\n\nconst fillExtrusionPatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n shouldUseVerticalGradient: boolean,\n opacity: number,\n coord: OverscaledTileID,\n crossfade: CrossfadeParameters,\n tile: Tile\n): UniformValues => {\n return extend(fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity),\n patternUniformValues(crossfade, painter, tile),\n {\n 'u_height_factor': -Math.pow(2, coord.overscaledZ) / tile.tileSize / 8\n });\n};\n\nexport {\n fillExtrusionUniforms,\n fillExtrusionPatternUniforms,\n fillExtrusionUniformValues,\n fillExtrusionPatternUniformValues\n};\n","import {patternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {Tile} from '../../source/tile';\nimport {mat4} from 'gl-matrix';\n\nexport type FillUniformsType = {\n 'u_matrix': UniformMatrix4f;\n};\n\nexport type FillOutlineUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n};\n\nexport type FillPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nexport type FillOutlinePatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nconst fillUniforms = (context: Context, locations: UniformLocations): FillUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst fillPatternUniforms = (context: Context, locations: UniformLocations): FillPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst fillOutlineUniforms = (context: Context, locations: UniformLocations): FillOutlineUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world)\n});\n\nconst fillOutlinePatternUniforms = (context: Context, locations: UniformLocations): FillOutlinePatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst fillUniformValues = (matrix: mat4): UniformValues => ({\n 'u_matrix': matrix\n});\n\nconst fillPatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n crossfade: CrossfadeParameters,\n tile: Tile\n): UniformValues => extend(\n fillUniformValues(matrix),\n patternUniformValues(crossfade, painter, tile)\n);\n\nconst fillOutlineUniformValues = (matrix: mat4, drawingBufferSize: [number, number]): UniformValues => ({\n 'u_matrix': matrix,\n 'u_world': drawingBufferSize\n});\n\nconst fillOutlinePatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n crossfade: CrossfadeParameters,\n tile: Tile,\n drawingBufferSize: [number, number]\n): UniformValues => extend(\n fillPatternUniformValues(matrix, painter, crossfade, tile),\n {\n 'u_world': drawingBufferSize\n }\n);\n\nexport {\n fillUniforms,\n fillPatternUniforms,\n fillOutlineUniforms,\n fillOutlinePatternUniforms,\n fillUniformValues,\n fillPatternUniformValues,\n fillOutlineUniformValues,\n fillOutlinePatternUniformValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {Tile} from '../../source/tile';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {Painter} from '../painter';\n\nexport type CircleUniformsType = {\n 'u_camera_to_center_distance': Uniform1f;\n 'u_scale_with_map': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_extrude_scale': Uniform2f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n};\n\nconst circleUniforms = (context: Context, locations: UniformLocations): CircleUniformsType => ({\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_scale_with_map': new Uniform1i(context, locations.u_scale_with_map),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst circleUniformValues = (\n painter: Painter,\n coord: OverscaledTileID,\n tile: Tile,\n layer: CircleStyleLayer\n): UniformValues => {\n const transform = painter.transform;\n\n let pitchWithMap: boolean, extrudeScale: [number, number];\n if (layer.paint.get('circle-pitch-alignment') === 'map') {\n const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom);\n pitchWithMap = true;\n extrudeScale = [pixelRatio, pixelRatio];\n } else {\n pitchWithMap = false;\n extrudeScale = transform.pixelsToGLUnits;\n }\n\n return {\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_scale_with_map': +(layer.paint.get('circle-pitch-scale') === 'map'),\n 'u_matrix': painter.translatePosMatrix(\n coord.posMatrix,\n tile,\n layer.paint.get('circle-translate'),\n layer.paint.get('circle-translate-anchor')),\n 'u_pitch_with_map': +(pitchWithMap),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_extrude_scale': extrudeScale\n };\n};\n\nexport {circleUniforms, circleUniformValues};\n","import {Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Transform} from '../../geo/transform';\nimport type {Tile} from '../../source/tile';\nimport {mat4} from 'gl-matrix';\n\nexport type CollisionUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pixels_to_tile_units': Uniform1f;\n 'u_extrude_scale': Uniform2f;\n 'u_overscale_factor': Uniform1f;\n};\n\nexport type CollisionCircleUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_inv_matrix': UniformMatrix4f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_viewport_size': Uniform2f;\n};\n\nconst collisionUniforms = (context: Context, locations: UniformLocations): CollisionUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pixels_to_tile_units': new Uniform1f(context, locations.u_pixels_to_tile_units),\n 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale),\n 'u_overscale_factor': new Uniform1f(context, locations.u_overscale_factor)\n});\n\nconst collisionCircleUniforms = (context: Context, locations: UniformLocations): CollisionCircleUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_inv_matrix': new UniformMatrix4f(context, locations.u_inv_matrix),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_viewport_size': new Uniform2f(context, locations.u_viewport_size)\n});\n\nconst collisionUniformValues = (matrix: mat4, transform: Transform, tile: Tile): UniformValues => {\n const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom);\n const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);\n const overscaleFactor = tile.tileID.overscaleFactor();\n return {\n 'u_matrix': matrix,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_pixels_to_tile_units': pixelRatio,\n 'u_extrude_scale': [transform.pixelsToGLUnits[0] / (pixelRatio * scale),\n transform.pixelsToGLUnits[1] / (pixelRatio * scale)],\n 'u_overscale_factor': overscaleFactor\n };\n};\n\nconst collisionCircleUniformValues = (matrix: mat4, invMatrix: mat4, transform: Transform): UniformValues => {\n return {\n 'u_matrix': matrix,\n 'u_inv_matrix': invMatrix,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_viewport_size': [transform.width, transform.height]\n };\n};\n\nexport {collisionUniforms, collisionUniformValues, collisionCircleUniforms, collisionCircleUniformValues};\n","import {UniformColor, UniformMatrix4f, Uniform1i, Uniform1f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {mat4} from 'gl-matrix';\n\nexport type DebugUniformsType = {\n 'u_color': UniformColor;\n 'u_matrix': UniformMatrix4f;\n 'u_overlay': Uniform1i;\n 'u_overlay_scale': Uniform1f;\n};\n\nconst debugUniforms = (context: Context, locations: UniformLocations): DebugUniformsType => ({\n 'u_color': new UniformColor(context, locations.u_color),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_overlay': new Uniform1i(context, locations.u_overlay),\n 'u_overlay_scale': new Uniform1f(context, locations.u_overlay_scale)\n});\n\nconst debugUniformValues = (matrix: mat4, color: Color, scaleRatio: number = 1): UniformValues => ({\n 'u_matrix': matrix,\n 'u_color': color,\n 'u_overlay': 0,\n 'u_overlay_scale': scaleRatio\n});\n\nexport {debugUniforms, debugUniformValues};\n","import {UniformMatrix4f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type ClippingMaskUniformsType = {\n 'u_matrix': UniformMatrix4f;\n};\n\nconst clippingMaskUniforms = (context: Context, locations: UniformLocations): ClippingMaskUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst clippingMaskUniformValues = (matrix: mat4): UniformValues => ({\n 'u_matrix': matrix\n});\n\nexport {clippingMaskUniforms, clippingMaskUniformValues};\n","import {mat4} from 'gl-matrix';\n\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {Tile} from '../../source/tile';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Painter} from '../painter';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport type HeatmapUniformsType = {\n 'u_extrude_scale': Uniform1f;\n 'u_intensity': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n};\n\nexport type HeatmapTextureUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n 'u_image': Uniform1i;\n 'u_color_ramp': Uniform1i;\n 'u_opacity': Uniform1f;\n};\n\nconst heatmapUniforms = (context: Context, locations: UniformLocations): HeatmapUniformsType => ({\n 'u_extrude_scale': new Uniform1f(context, locations.u_extrude_scale),\n 'u_intensity': new Uniform1f(context, locations.u_intensity),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst heatmapTextureUniforms = (context: Context, locations: UniformLocations): HeatmapTextureUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_color_ramp': new Uniform1i(context, locations.u_color_ramp),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst heatmapUniformValues = (matrix: mat4, tile: Tile, zoom: number, intensity: number): UniformValues => ({\n 'u_matrix': matrix,\n 'u_extrude_scale': pixelsToTileUnits(tile, 1, zoom),\n 'u_intensity': intensity\n});\n\nconst heatmapTextureUniformValues = (\n painter: Painter,\n layer: HeatmapStyleLayer,\n textureUnit: number,\n colorRampUnit: number\n): UniformValues => {\n const matrix = mat4.create();\n mat4.ortho(matrix, 0, painter.width, painter.height, 0, 0, 1);\n\n const gl = painter.context.gl;\n\n return {\n 'u_matrix': matrix,\n 'u_world': [gl.drawingBufferWidth, gl.drawingBufferHeight],\n 'u_image': textureUnit,\n 'u_color_ramp': colorRampUnit,\n 'u_opacity': layer.paint.get('heatmap-opacity')\n };\n};\n\nexport {\n heatmapUniforms,\n heatmapTextureUniforms,\n heatmapUniformValues,\n heatmapTextureUniformValues\n};\n","import {mat4} from 'gl-matrix';\n\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformColor,\n UniformMatrix4f,\n Uniform4f\n} from '../uniform_binding';\nimport {EXTENT} from '../../data/extent';\nimport {MercatorCoordinate} from '../../geo/mercator_coordinate';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Tile} from '../../source/tile';\nimport type {Painter} from '../painter';\nimport type {HillshadeStyleLayer} from '../../style/style_layer/hillshade_style_layer';\nimport type {DEMData} from '../../data/dem_data';\nimport type {OverscaledTileID} from '../../source/tile_id';\n\nexport type HillshadeUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_image': Uniform1i;\n 'u_latrange': Uniform2f;\n 'u_light': Uniform2f;\n 'u_shadow': UniformColor;\n 'u_highlight': UniformColor;\n 'u_accent': UniformColor;\n};\n\nexport type HillshadePrepareUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_image': Uniform1i;\n 'u_dimension': Uniform2f;\n 'u_zoom': Uniform1f;\n 'u_unpack': Uniform4f;\n};\n\nconst hillshadeUniforms = (context: Context, locations: UniformLocations): HillshadeUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_latrange': new Uniform2f(context, locations.u_latrange),\n 'u_light': new Uniform2f(context, locations.u_light),\n 'u_shadow': new UniformColor(context, locations.u_shadow),\n 'u_highlight': new UniformColor(context, locations.u_highlight),\n 'u_accent': new UniformColor(context, locations.u_accent)\n});\n\nconst hillshadePrepareUniforms = (context: Context, locations: UniformLocations): HillshadePrepareUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_dimension': new Uniform2f(context, locations.u_dimension),\n 'u_zoom': new Uniform1f(context, locations.u_zoom),\n 'u_unpack': new Uniform4f(context, locations.u_unpack)\n});\n\nconst hillshadeUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: HillshadeStyleLayer,\n coord: OverscaledTileID\n): UniformValues => {\n const shadow = layer.paint.get('hillshade-shadow-color');\n const highlight = layer.paint.get('hillshade-highlight-color');\n const accent = layer.paint.get('hillshade-accent-color');\n\n let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180);\n // modify azimuthal angle by map rotation if light is anchored at the viewport\n if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') {\n azimuthal -= painter.transform.angle;\n }\n const align = !painter.options.moving;\n return {\n 'u_matrix': coord ? coord.posMatrix : painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align),\n 'u_image': 0,\n 'u_latrange': getTileLatRange(painter, tile.tileID),\n 'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal],\n 'u_shadow': shadow,\n 'u_highlight': highlight,\n 'u_accent': accent\n };\n};\n\nconst hillshadeUniformPrepareValues = (tileID: OverscaledTileID, dem: DEMData): UniformValues => {\n\n const stride = dem.stride;\n const matrix = mat4.create();\n // Flip rendering at y axis.\n mat4.ortho(matrix, 0, EXTENT, -EXTENT, 0, 0, 1);\n mat4.translate(matrix, matrix, [0, -EXTENT, 0]);\n\n return {\n 'u_matrix': matrix,\n 'u_image': 1,\n 'u_dimension': [stride, stride],\n 'u_zoom': tileID.overscaledZ,\n 'u_unpack': dem.getUnpackVector()\n };\n};\n\nfunction getTileLatRange(painter: Painter, tileID: OverscaledTileID) {\n // for scaling the magnitude of a points slope by its latitude\n const tilesAtZoom = Math.pow(2, tileID.canonical.z);\n const y = tileID.canonical.y;\n return [\n new MercatorCoordinate(0, y / tilesAtZoom).toLngLat().lat,\n new MercatorCoordinate(0, (y + 1) / tilesAtZoom).toLngLat().lat];\n}\n\nexport {\n hillshadeUniforms,\n hillshadePrepareUniforms,\n hillshadeUniformValues,\n hillshadeUniformPrepareValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Transform} from '../../geo/transform';\nimport type {Tile} from '../../source/tile';\nimport type {CrossFaded} from '../../style/properties';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type {Painter} from '../painter';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport {OverscaledTileID} from '../../source/tile_id';\n\nexport type LineUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n};\n\nexport type LineGradientUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_image': Uniform1i;\n 'u_image_height': Uniform1f;\n};\n\nexport type LinePatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texsize': Uniform2f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_image': Uniform1i;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nexport type LineSDFUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_patternscale_a': Uniform2f;\n 'u_patternscale_b': Uniform2f;\n 'u_sdfgamma': Uniform1f;\n 'u_image': Uniform1i;\n 'u_tex_y_a': Uniform1f;\n 'u_tex_y_b': Uniform1f;\n 'u_mix': Uniform1f;\n};\n\nconst lineUniforms = (context: Context, locations: UniformLocations): LineUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels)\n});\n\nconst lineGradientUniforms = (context: Context, locations: UniformLocations): LineGradientUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_image_height': new Uniform1f(context, locations.u_image_height)\n});\n\nconst linePatternUniforms = (context: Context, locations: UniformLocations): LinePatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst lineSDFUniforms = (context: Context, locations: UniformLocations): LineSDFUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_patternscale_a': new Uniform2f(context, locations.u_patternscale_a),\n 'u_patternscale_b': new Uniform2f(context, locations.u_patternscale_b),\n 'u_sdfgamma': new Uniform1f(context, locations.u_sdfgamma),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_tex_y_a': new Uniform1f(context, locations.u_tex_y_a),\n 'u_tex_y_b': new Uniform1f(context, locations.u_tex_y_b),\n 'u_mix': new Uniform1f(context, locations.u_mix)\n});\n\nconst lineUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n\n return {\n 'u_matrix': calculateMatrix(painter, tile, layer, coord),\n 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_units_to_pixels': [\n 1 / transform.pixelsToGLUnits[0],\n 1 / transform.pixelsToGLUnits[1]\n ]\n };\n};\n\nconst lineGradientUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n imageHeight: number,\n coord: OverscaledTileID\n): UniformValues => {\n return extend(lineUniformValues(painter, tile, layer, coord), {\n 'u_image': 0,\n 'u_image_height': imageHeight,\n });\n};\n\nconst linePatternUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n crossfade: CrossfadeParameters,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n const tileZoomRatio = calculateTileRatio(tile, transform);\n return {\n 'u_matrix': calculateMatrix(painter, tile, layer, coord),\n 'u_texsize': tile.imageAtlasTexture.size,\n // camera zoom ratio\n 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_image': 0,\n 'u_scale': [tileZoomRatio, crossfade.fromScale, crossfade.toScale],\n 'u_fade': crossfade.t,\n 'u_units_to_pixels': [\n 1 / transform.pixelsToGLUnits[0],\n 1 / transform.pixelsToGLUnits[1]\n ]\n };\n};\n\nconst lineSDFUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n dasharray: CrossFaded>,\n crossfade: CrossfadeParameters,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n const lineAtlas = painter.lineAtlas;\n const tileRatio = calculateTileRatio(tile, transform);\n\n const round = layer.layout.get('line-cap') === 'round';\n\n const posA = lineAtlas.getDash(dasharray.from, round);\n const posB = lineAtlas.getDash(dasharray.to, round);\n\n const widthA = posA.width * crossfade.fromScale;\n const widthB = posB.width * crossfade.toScale;\n\n return extend(lineUniformValues(painter, tile, layer, coord), {\n 'u_patternscale_a': [tileRatio / widthA, -posA.height / 2],\n 'u_patternscale_b': [tileRatio / widthB, -posB.height / 2],\n 'u_sdfgamma': lineAtlas.width / (Math.min(widthA, widthB) * 256 * painter.pixelRatio) / 2,\n 'u_image': 0,\n 'u_tex_y_a': posA.y,\n 'u_tex_y_b': posB.y,\n 'u_mix': crossfade.t\n });\n};\n\nfunction calculateTileRatio(tile: Tile, transform: Transform) {\n return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom);\n}\n\nfunction calculateMatrix(painter: Painter, tile: Tile, layer: LineStyleLayer, coord: OverscaledTileID) {\n return painter.translatePosMatrix(\n coord ? coord.posMatrix : tile.tileID.posMatrix,\n tile,\n layer.paint.get('line-translate'),\n layer.paint.get('line-translate-anchor')\n );\n}\n\nexport {\n lineUniforms,\n lineGradientUniforms,\n linePatternUniforms,\n lineSDFUniforms,\n lineUniformValues,\n lineGradientUniformValues,\n linePatternUniformValues,\n lineSDFUniformValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {RasterStyleLayer} from '../../style/style_layer/raster_style_layer';\nimport {mat4} from 'gl-matrix';\n\nexport type RasterUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_tl_parent': Uniform2f;\n 'u_scale_parent': Uniform1f;\n 'u_buffer_scale': Uniform1f;\n 'u_fade_t': Uniform1f;\n 'u_opacity': Uniform1f;\n 'u_image0': Uniform1i;\n 'u_image1': Uniform1i;\n 'u_brightness_low': Uniform1f;\n 'u_brightness_high': Uniform1f;\n 'u_saturation_factor': Uniform1f;\n 'u_contrast_factor': Uniform1f;\n 'u_spin_weights': Uniform3f;\n};\n\nconst rasterUniforms = (context: Context, locations: UniformLocations): RasterUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_tl_parent': new Uniform2f(context, locations.u_tl_parent),\n 'u_scale_parent': new Uniform1f(context, locations.u_scale_parent),\n 'u_buffer_scale': new Uniform1f(context, locations.u_buffer_scale),\n 'u_fade_t': new Uniform1f(context, locations.u_fade_t),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_image0': new Uniform1i(context, locations.u_image0),\n 'u_image1': new Uniform1i(context, locations.u_image1),\n 'u_brightness_low': new Uniform1f(context, locations.u_brightness_low),\n 'u_brightness_high': new Uniform1f(context, locations.u_brightness_high),\n 'u_saturation_factor': new Uniform1f(context, locations.u_saturation_factor),\n 'u_contrast_factor': new Uniform1f(context, locations.u_contrast_factor),\n 'u_spin_weights': new Uniform3f(context, locations.u_spin_weights)\n});\n\nconst rasterUniformValues = (\n matrix: mat4,\n parentTL: [number, number],\n parentScaleBy: number,\n fade: {\n mix: number;\n opacity: number;\n },\n layer: RasterStyleLayer\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_tl_parent': parentTL,\n 'u_scale_parent': parentScaleBy,\n 'u_buffer_scale': 1,\n 'u_fade_t': fade.mix,\n 'u_opacity': fade.opacity * layer.paint.get('raster-opacity'),\n 'u_image0': 0,\n 'u_image1': 1,\n 'u_brightness_low': layer.paint.get('raster-brightness-min'),\n 'u_brightness_high': layer.paint.get('raster-brightness-max'),\n 'u_saturation_factor': saturationFactor(layer.paint.get('raster-saturation')),\n 'u_contrast_factor': contrastFactor(layer.paint.get('raster-contrast')),\n 'u_spin_weights': spinWeights(layer.paint.get('raster-hue-rotate'))\n});\n\nfunction spinWeights(angle) {\n angle *= Math.PI / 180;\n const s = Math.sin(angle);\n const c = Math.cos(angle);\n return [\n (2 * c + 1) / 3,\n (-Math.sqrt(3) * s - c + 1) / 3,\n (Math.sqrt(3) * s - c + 1) / 3\n ];\n}\n\nfunction contrastFactor(contrast) {\n return contrast > 0 ?\n 1 / (1 - contrast) :\n 1 + contrast;\n}\n\nfunction saturationFactor(saturation) {\n return saturation > 0 ?\n 1 - 1 / (1.001 - saturation) :\n -saturation;\n}\n\nexport {rasterUniforms, rasterUniformValues};\n","import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type SymbolIconUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texture': Uniform1i;\n};\n\nexport type SymbolSDFUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texture': Uniform1i;\n 'u_gamma_scale': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_is_halo': Uniform1i;\n};\n\nexport type symbolTextAndIconUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texsize_icon': Uniform2f;\n 'u_texture': Uniform1i;\n 'u_texture_icon': Uniform1i;\n 'u_gamma_scale': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_is_halo': Uniform1i;\n};\n\nconst symbolIconUniforms = (context: Context, locations: UniformLocations): SymbolIconUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texture': new Uniform1i(context, locations.u_texture)\n});\n\nconst symbolSDFUniforms = (context: Context, locations: UniformLocations): SymbolSDFUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_is_halo': new Uniform1i(context, locations.u_is_halo)\n});\n\nconst symbolTextAndIconUniforms = (context: Context, locations: UniformLocations): symbolTextAndIconUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texsize_icon': new Uniform2f(context, locations.u_texsize_icon),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_texture_icon': new Uniform1i(context, locations.u_texture_icon),\n 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_is_halo': new Uniform1i(context, locations.u_is_halo)\n});\n\nconst symbolIconUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n isText: boolean,\n texSize: [number, number]\n): UniformValues => {\n const transform = painter.transform;\n\n return {\n 'u_is_size_zoom_constant': +(functionType === 'constant' || functionType === 'source'),\n 'u_is_size_feature_constant': +(functionType === 'constant' || functionType === 'camera'),\n 'u_size_t': size ? size.uSizeT : 0,\n 'u_size': size ? size.uSize : 0,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_pitch': transform.pitch / 360 * 2 * Math.PI,\n 'u_rotate_symbol': +rotateInShader,\n 'u_aspect_ratio': transform.width / transform.height,\n 'u_fade_change': painter.options.fadeDuration ? painter.symbolFadeChange : 1,\n 'u_matrix': matrix,\n 'u_label_plane_matrix': labelPlaneMatrix,\n 'u_coord_matrix': glCoordMatrix,\n 'u_is_text': +isText,\n 'u_pitch_with_map': +pitchWithMap,\n 'u_texsize': texSize,\n 'u_texture': 0\n };\n};\n\nconst symbolSDFUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n isText: boolean,\n texSize: [number, number],\n isHalo: boolean\n): UniformValues => {\n const transform = painter.transform;\n\n return extend(symbolIconUniformValues(functionType, size,\n rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,\n glCoordMatrix, isText, texSize), {\n 'u_gamma_scale': (pitchWithMap ? Math.cos(transform._pitch) * transform.cameraToCenterDistance : 1),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_is_halo': +isHalo\n });\n};\n\nconst symbolTextAndIconUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n texSizeSDF: [number, number],\n texSizeIcon: [number, number]\n): UniformValues => {\n return extend(symbolSDFUniformValues(functionType, size,\n rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,\n glCoordMatrix, true, texSizeSDF, true), {\n 'u_texsize_icon': texSizeIcon,\n 'u_texture_icon': 1\n });\n};\n\nexport {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues, symbolTextAndIconUniformValues, symbolTextAndIconUniforms};\n","import {bgPatternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformColor,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {Color, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport type {CrossFaded} from '../../style/properties';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport {mat4} from 'gl-matrix';\n\nexport type BackgroundUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_opacity': Uniform1f;\n 'u_color': UniformColor;\n};\n\nexport type BackgroundPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_opacity': Uniform1f;\n // pattern uniforms:\n 'u_image': Uniform1i;\n 'u_pattern_tl_a': Uniform2f;\n 'u_pattern_br_a': Uniform2f;\n 'u_pattern_tl_b': Uniform2f;\n 'u_pattern_br_b': Uniform2f;\n 'u_texsize': Uniform2f;\n 'u_mix': Uniform1f;\n 'u_pattern_size_a': Uniform2f;\n 'u_pattern_size_b': Uniform2f;\n 'u_scale_a': Uniform1f;\n 'u_scale_b': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_tile_units_to_pixels': Uniform1f;\n};\n\nconst backgroundUniforms = (context: Context, locations: UniformLocations): BackgroundUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_color': new UniformColor(context, locations.u_color)\n});\n\nconst backgroundPatternUniforms = (context: Context, locations: UniformLocations): BackgroundPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_pattern_tl_a': new Uniform2f(context, locations.u_pattern_tl_a),\n 'u_pattern_br_a': new Uniform2f(context, locations.u_pattern_br_a),\n 'u_pattern_tl_b': new Uniform2f(context, locations.u_pattern_tl_b),\n 'u_pattern_br_b': new Uniform2f(context, locations.u_pattern_br_b),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_mix': new Uniform1f(context, locations.u_mix),\n 'u_pattern_size_a': new Uniform2f(context, locations.u_pattern_size_a),\n 'u_pattern_size_b': new Uniform2f(context, locations.u_pattern_size_b),\n 'u_scale_a': new Uniform1f(context, locations.u_scale_a),\n 'u_scale_b': new Uniform1f(context, locations.u_scale_b),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_tile_units_to_pixels': new Uniform1f(context, locations.u_tile_units_to_pixels)\n});\n\nconst backgroundUniformValues = (matrix: mat4, opacity: number, color: Color): UniformValues => ({\n 'u_matrix': matrix,\n 'u_opacity': opacity,\n 'u_color': color\n});\n\nconst backgroundPatternUniformValues = (\n matrix: mat4,\n opacity: number,\n painter: Painter,\n image: CrossFaded,\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n },\n crossfade: CrossfadeParameters\n): UniformValues => extend(\n bgPatternUniformValues(image, crossfade, painter, tile),\n {\n 'u_matrix': matrix,\n 'u_opacity': opacity\n }\n);\n\nexport {\n backgroundUniforms,\n backgroundPatternUniforms,\n backgroundUniformValues,\n backgroundPatternUniformValues\n};\n","import {fillExtrusionUniforms, fillExtrusionPatternUniforms} from './fill_extrusion_program';\nimport {fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms} from './fill_program';\nimport {circleUniforms} from './circle_program';\nimport {collisionUniforms, collisionCircleUniforms} from './collision_program';\nimport {debugUniforms} from './debug_program';\nimport {clippingMaskUniforms} from './clipping_mask_program';\nimport {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program';\nimport {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program';\nimport {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program';\nimport {rasterUniforms} from './raster_program';\nimport {symbolIconUniforms, symbolSDFUniforms, symbolTextAndIconUniforms} from './symbol_program';\nimport {backgroundUniforms, backgroundPatternUniforms} from './background_program';\nimport {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms} from './terrain_program';\n\nexport const programUniforms = {\n fillExtrusion: fillExtrusionUniforms,\n fillExtrusionPattern: fillExtrusionPatternUniforms,\n fill: fillUniforms,\n fillPattern: fillPatternUniforms,\n fillOutline: fillOutlineUniforms,\n fillOutlinePattern: fillOutlinePatternUniforms,\n circle: circleUniforms,\n collisionBox: collisionUniforms,\n collisionCircle: collisionCircleUniforms,\n debug: debugUniforms,\n clippingMask: clippingMaskUniforms,\n heatmap: heatmapUniforms,\n heatmapTexture: heatmapTextureUniforms,\n hillshade: hillshadeUniforms,\n hillshadePrepare: hillshadePrepareUniforms,\n line: lineUniforms,\n lineGradient: lineGradientUniforms,\n linePattern: linePatternUniforms,\n lineSDF: lineSDFUniforms,\n raster: rasterUniforms,\n symbolIcon: symbolIconUniforms,\n symbolSDF: symbolSDFUniforms,\n symbolTextAndIcon: symbolTextAndIconUniforms,\n background: backgroundUniforms,\n backgroundPattern: backgroundPatternUniforms,\n terrain: terrainUniforms,\n terrainDepth: terrainDepthUniforms,\n terrainCoords: terrainCoordsUniforms\n};\n","\nimport type {StructArray} from '../util/struct_array';\nimport type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';\nimport type {Context} from '../gl/context';\n\n/**\n * @internal\n * an index buffer class\n */\nexport class IndexBuffer {\n context: Context;\n buffer: WebGLBuffer;\n dynamicDraw: boolean;\n\n constructor(context: Context, array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) {\n this.context = context;\n const gl = context.gl;\n this.buffer = gl.createBuffer();\n this.dynamicDraw = Boolean(dynamicDraw);\n\n // The bound index buffer is part of vertex array object state. We don't want to\n // modify whatever VAO happens to be currently bound, so make sure the default\n // vertex array provided by the context is bound instead.\n this.context.unbindVAO();\n\n context.bindElementBuffer.set(this.buffer);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);\n\n if (!this.dynamicDraw) {\n delete array.arrayBuffer;\n }\n }\n\n bind() {\n this.context.bindElementBuffer.set(this.buffer);\n }\n\n updateData(array: StructArray) {\n const gl = this.context.gl;\n if (!this.dynamicDraw) throw new Error('Attempted to update data while not in dynamic mode.');\n // The right VAO will get this buffer re-bound later in VertexArrayObject#bind\n // See https://github.com/mapbox/mapbox-gl-js/issues/5620\n this.context.unbindVAO();\n this.bind();\n gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, array.arrayBuffer);\n }\n\n destroy() {\n const gl = this.context.gl;\n if (this.buffer) {\n gl.deleteBuffer(this.buffer);\n delete this.buffer;\n }\n }\n}\n","\nimport type {\n StructArray,\n StructArrayMember\n} from '../util/struct_array';\n\nimport type {Program} from '../render/program';\nimport type {Context} from '../gl/context';\n\n/**\n * An Enum for AttributeType\n */\nconst AttributeType = {\n Int8: 'BYTE',\n Uint8: 'UNSIGNED_BYTE',\n Int16: 'SHORT',\n Uint16: 'UNSIGNED_SHORT',\n Int32: 'INT',\n Uint32: 'UNSIGNED_INT',\n Float32: 'FLOAT'\n};\n\n/**\n * @internal\n * The `VertexBuffer` class turns a `StructArray` into a WebGL buffer. Each member of the StructArray's\n * Struct type is converted to a WebGL attribute.\n */\nexport class VertexBuffer {\n length: number;\n attributes: ReadonlyArray;\n itemSize: number;\n dynamicDraw: boolean;\n context: Context;\n buffer: WebGLBuffer;\n\n /**\n * @param dynamicDraw - Whether this buffer will be repeatedly updated.\n */\n constructor(context: Context, array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) {\n this.length = array.length;\n this.attributes = attributes;\n this.itemSize = array.bytesPerElement;\n this.dynamicDraw = dynamicDraw;\n\n this.context = context;\n const gl = context.gl;\n this.buffer = gl.createBuffer();\n context.bindVertexBuffer.set(this.buffer);\n gl.bufferData(gl.ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);\n\n if (!this.dynamicDraw) {\n delete array.arrayBuffer;\n }\n }\n\n bind() {\n this.context.bindVertexBuffer.set(this.buffer);\n }\n\n updateData(array: StructArray) {\n if (array.length !== this.length) throw new Error(`Length of new data is ${array.length}, which doesn't match current length of ${this.length}`);\n const gl = this.context.gl;\n this.bind();\n gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer);\n }\n\n enableAttributes(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program) {\n for (let j = 0; j < this.attributes.length; j++) {\n const member = this.attributes[j];\n const attribIndex: number | void = program.attributes[member.name];\n if (attribIndex !== undefined) {\n gl.enableVertexAttribArray(attribIndex);\n }\n }\n }\n\n /**\n * Set the attribute pointers in a WebGL context\n * @param gl - The WebGL context\n * @param program - The active WebGL program\n * @param vertexOffset - Index of the starting vertex of the segment\n */\n setVertexAttribPointers(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program, vertexOffset?: number | null) {\n for (let j = 0; j < this.attributes.length; j++) {\n const member = this.attributes[j];\n const attribIndex: number | void = program.attributes[member.name];\n\n if (attribIndex !== undefined) {\n gl.vertexAttribPointer(\n attribIndex,\n member.components,\n (gl as any)[AttributeType[member.type]],\n false,\n this.itemSize,\n member.offset + (this.itemSize * (vertexOffset || 0))\n );\n }\n }\n }\n\n /**\n * Destroy the GL buffer bound to the given WebGL context\n */\n destroy() {\n const gl = this.context.gl;\n if (this.buffer) {\n gl.deleteBuffer(this.buffer);\n delete this.buffer;\n }\n }\n}\n","const cache = new WeakMap();\nexport function isWebGL2(\n gl: WebGLRenderingContext | WebGL2RenderingContext\n): gl is WebGL2RenderingContext {\n if (cache.has(gl)) {\n return cache.get(gl);\n } else {\n const value = gl.getParameter(gl.VERSION)?.startsWith('WebGL 2.0');\n cache.set(gl, value);\n return value;\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {isWebGL2} from './webgl2';\n\nimport type {Context} from './context';\nimport type {\n BlendFuncType,\n BlendEquationType,\n ColorMaskType,\n DepthRangeType,\n DepthMaskType,\n StencilFuncType,\n StencilOpType,\n DepthFuncType,\n TextureUnitType,\n ViewportType,\n CullFaceModeType,\n FrontFaceType,\n} from './types';\n\nexport interface IValue {\n current: T;\n default: T;\n dirty: boolean;\n get(): T;\n setDefault(): void;\n set(value: T): void;\n}\n\nclass BaseValue implements IValue {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n current: T;\n default: T;\n dirty: boolean;\n\n constructor(context: Context) {\n this.gl = context.gl;\n this.default = this.getDefault();\n this.current = this.default;\n this.dirty = false;\n }\n\n get(): T {\n return this.current;\n }\n set(value: T) { // eslint-disable-line\n // overridden in child classes;\n }\n\n getDefault(): T {\n return this.default; // overriden in child classes\n }\n setDefault() {\n this.set(this.default);\n }\n}\n\nexport class ClearColor extends BaseValue {\n getDefault(): Color {\n return Color.transparent;\n }\n set(v: Color) {\n const c = this.current;\n if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return;\n this.gl.clearColor(v.r, v.g, v.b, v.a);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ClearDepth extends BaseValue {\n getDefault(): number {\n return 1;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n this.gl.clearDepth(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ClearStencil extends BaseValue {\n getDefault(): number {\n return 0;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n this.gl.clearStencil(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ColorMask extends BaseValue {\n getDefault(): ColorMaskType {\n return [true, true, true, true];\n }\n set(v: ColorMaskType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return;\n this.gl.colorMask(v[0], v[1], v[2], v[3]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthMask extends BaseValue {\n getDefault(): DepthMaskType {\n return true;\n }\n set(v: DepthMaskType): void {\n if (v === this.current && !this.dirty) return;\n this.gl.depthMask(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilMask extends BaseValue {\n getDefault(): number {\n return 0xFF;\n }\n set(v: number): void {\n if (v === this.current && !this.dirty) return;\n this.gl.stencilMask(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilFunc extends BaseValue {\n getDefault(): StencilFuncType {\n return {\n func: this.gl.ALWAYS,\n ref: 0,\n mask: 0xFF\n };\n }\n set(v: StencilFuncType): void {\n const c = this.current;\n if (v.func === c.func && v.ref === c.ref && v.mask === c.mask && !this.dirty) return;\n this.gl.stencilFunc(v.func, v.ref, v.mask);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilOp extends BaseValue {\n getDefault(): StencilOpType {\n const gl = this.gl;\n return [gl.KEEP, gl.KEEP, gl.KEEP];\n }\n set(v: StencilOpType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && !this.dirty) return;\n this.gl.stencilOp(v[0], v[1], v[2]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilTest extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.STENCIL_TEST);\n } else {\n gl.disable(gl.STENCIL_TEST);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthRange extends BaseValue {\n getDefault(): DepthRangeType {\n return [0, 1];\n }\n set(v: DepthRangeType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return;\n this.gl.depthRange(v[0], v[1]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthTest extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.DEPTH_TEST);\n } else {\n gl.disable(gl.DEPTH_TEST);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthFunc extends BaseValue {\n getDefault(): DepthFuncType {\n return this.gl.LESS;\n }\n set(v: DepthFuncType) {\n if (v === this.current && !this.dirty) return;\n this.gl.depthFunc(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class Blend extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.BLEND);\n } else {\n gl.disable(gl.BLEND);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendFunc extends BaseValue {\n getDefault(): BlendFuncType {\n const gl = this.gl;\n return [gl.ONE, gl.ZERO];\n }\n set(v: BlendFuncType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return;\n this.gl.blendFunc(v[0], v[1]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendColor extends BaseValue {\n getDefault(): Color {\n return Color.transparent;\n }\n set(v: Color) {\n const c = this.current;\n if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return;\n this.gl.blendColor(v.r, v.g, v.b, v.a);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendEquation extends BaseValue {\n getDefault(): BlendEquationType {\n return this.gl.FUNC_ADD;\n }\n set(v: BlendEquationType) {\n if (v === this.current && !this.dirty) return;\n this.gl.blendEquation(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class CullFace extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.CULL_FACE);\n } else {\n gl.disable(gl.CULL_FACE);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class CullFaceSide extends BaseValue {\n getDefault(): CullFaceModeType {\n return this.gl.BACK;\n }\n set(v: CullFaceModeType) {\n if (v === this.current && !this.dirty) return;\n this.gl.cullFace(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class FrontFace extends BaseValue {\n getDefault(): FrontFaceType {\n return this.gl.CCW;\n }\n set(v: FrontFaceType) {\n if (v === this.current && !this.dirty) return;\n this.gl.frontFace(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ProgramValue extends BaseValue {\n getDefault(): WebGLProgram {\n return null;\n }\n set(v?: WebGLProgram | null) {\n if (v === this.current && !this.dirty) return;\n this.gl.useProgram(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ActiveTextureUnit extends BaseValue {\n getDefault(): TextureUnitType {\n return this.gl.TEXTURE0;\n }\n set(v: TextureUnitType) {\n if (v === this.current && !this.dirty) return;\n this.gl.activeTexture(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class Viewport extends BaseValue {\n getDefault(): ViewportType {\n const gl = this.gl;\n return [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight];\n }\n set(v: ViewportType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return;\n this.gl.viewport(v[0], v[1], v[2], v[3]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindFramebuffer extends BaseValue {\n getDefault(): WebGLFramebuffer {\n return null;\n }\n set(v?: WebGLFramebuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindFramebuffer(gl.FRAMEBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindRenderbuffer extends BaseValue {\n getDefault(): WebGLRenderbuffer {\n return null;\n }\n set(v?: WebGLRenderbuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindRenderbuffer(gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindTexture extends BaseValue {\n getDefault(): WebGLTexture {\n return null;\n }\n set(v?: WebGLTexture | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindVertexBuffer extends BaseValue {\n getDefault(): WebGLBuffer {\n return null;\n }\n set(v?: WebGLBuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindBuffer(gl.ARRAY_BUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindElementBuffer extends BaseValue {\n getDefault(): WebGLBuffer {\n return null;\n }\n set(v?: WebGLBuffer | null) {\n // Always rebind\n const gl = this.gl;\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindVertexArray extends BaseValue {\n getDefault(): WebGLVertexArrayObject | null {\n return null;\n }\n set(v: WebGLVertexArrayObject | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n\n if (isWebGL2(gl)) {\n gl.bindVertexArray(v);\n } else {\n gl.getExtension('OES_vertex_array_object')?.bindVertexArrayOES(v);\n }\n\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpack extends BaseValue {\n getDefault(): number {\n return 4;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpackPremultiplyAlpha extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean): void {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, ((v as any)));\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpackFlipY extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean): void {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, ((v as any)));\n this.current = v;\n this.dirty = false;\n }\n}\n\nclass FramebufferAttachment extends BaseValue {\n parent: WebGLFramebuffer;\n context: Context;\n\n constructor(context: Context, parent: WebGLFramebuffer) {\n super(context);\n this.context = context;\n this.parent = parent;\n }\n getDefault() {\n return null;\n }\n}\n\nexport class ColorAttachment extends FramebufferAttachment {\n setDirty() {\n this.dirty = true;\n }\n set(v?: WebGLTexture | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a renderbuffer to the color\n // attachment point, but thus far MBGL only uses textures for color\n const gl = this.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, v, 0);\n\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthAttachment extends FramebufferAttachment {\n set(v?: WebGLRenderbuffer | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a texture to the depth attachment\n // point, but thus far MBGL only uses renderbuffers for depth\n const gl = this.gl;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthStencilAttachment extends FramebufferAttachment {\n set(v?: WebGLRenderbuffer | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a texture to the depth attachment\n // point, but thus far MBGL only uses renderbuffers for depth\n const gl = this.gl;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n","import {ColorAttachment, DepthAttachment, DepthStencilAttachment} from './value';\n\nimport type {Context} from './context';\n\n/**\n * @internal\n * A framebuffer holder object\n */\nexport class Framebuffer {\n context: Context;\n width: number;\n height: number;\n framebuffer: WebGLFramebuffer;\n colorAttachment: ColorAttachment;\n depthAttachment: DepthAttachment;\n\n constructor(context: Context, width: number, height: number, hasDepth: boolean, hasStencil: boolean) {\n this.context = context;\n this.width = width;\n this.height = height;\n const gl = context.gl;\n const fbo = this.framebuffer = gl.createFramebuffer();\n\n this.colorAttachment = new ColorAttachment(context, fbo);\n if (hasDepth) {\n this.depthAttachment = hasStencil ? new DepthStencilAttachment(context, fbo) : new DepthAttachment(context, fbo);\n } else if (hasStencil) {\n throw new Error('Stencil cannot be setted without depth');\n }\n if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error('Framebuffer is not complete');\n }\n }\n\n destroy() {\n const gl = this.context.gl;\n\n const texture = this.colorAttachment.get();\n if (texture) gl.deleteTexture(texture);\n\n if (this.depthAttachment) {\n const renderbuffer = this.depthAttachment.get();\n if (renderbuffer) gl.deleteRenderbuffer(renderbuffer);\n }\n\n gl.deleteFramebuffer(this.framebuffer);\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BlendFuncType, ColorMaskType} from './types';\n\nconst ZERO = 0x0000;\nconst ONE = 0x0001;\nconst ONE_MINUS_SRC_ALPHA = 0x0303;\n\nexport class ColorMode {\n blendFunction: BlendFuncType;\n blendColor: Color;\n mask: ColorMaskType;\n\n constructor(blendFunction: BlendFuncType, blendColor: Color, mask: ColorMaskType) {\n this.blendFunction = blendFunction;\n this.blendColor = blendColor;\n this.mask = mask;\n }\n\n static Replace: BlendFuncType;\n\n static disabled: Readonly;\n static unblended: Readonly;\n static alphaBlended: Readonly;\n}\n\nColorMode.Replace = [ONE, ZERO];\n\nColorMode.disabled = new ColorMode(ColorMode.Replace, Color.transparent, [false, false, false, false]);\nColorMode.unblended = new ColorMode(ColorMode.Replace, Color.transparent, [true, true, true, true]);\nColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [true, true, true, true]);\n","import {IndexBuffer} from './index_buffer';\n\nimport {VertexBuffer} from './vertex_buffer';\nimport {Framebuffer} from './framebuffer';\nimport {DepthMode} from './depth_mode';\nimport {StencilMode} from './stencil_mode';\nimport {ColorMode} from './color_mode';\nimport {CullFaceMode} from './cull_face_mode';\nimport {deepEqual} from '../util/util';\nimport {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, BlendEquation, CullFace, CullFaceSide, FrontFace, ProgramValue, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArray, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha, PixelStoreUnpackFlipY} from './value';\n\nimport type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';\nimport type {\n StructArray,\n StructArrayMember\n} from '../util/struct_array';\nimport type {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {isWebGL2} from './webgl2';\n\ntype ClearArgs = {\n color?: Color;\n depth?: number;\n stencil?: number;\n};\n\n/**\n * @internal\n * A webgl wrapper class to allow injection, mocking and abstaction\n */\nexport class Context {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n\n currentNumAttributes: number;\n maxTextureSize: number;\n\n clearColor: ClearColor;\n clearDepth: ClearDepth;\n clearStencil: ClearStencil;\n colorMask: ColorMask;\n depthMask: DepthMask;\n stencilMask: StencilMask;\n stencilFunc: StencilFunc;\n stencilOp: StencilOp;\n stencilTest: StencilTest;\n depthRange: DepthRange;\n depthTest: DepthTest;\n depthFunc: DepthFunc;\n blend: Blend;\n blendFunc: BlendFunc;\n blendColor: BlendColor;\n blendEquation: BlendEquation;\n cullFace: CullFace;\n cullFaceSide: CullFaceSide;\n frontFace: FrontFace;\n program: ProgramValue;\n activeTexture: ActiveTextureUnit;\n viewport: Viewport;\n bindFramebuffer: BindFramebuffer;\n bindRenderbuffer: BindRenderbuffer;\n bindTexture: BindTexture;\n bindVertexBuffer: BindVertexBuffer;\n bindElementBuffer: BindElementBuffer;\n bindVertexArray: BindVertexArray;\n pixelStoreUnpack: PixelStoreUnpack;\n pixelStoreUnpackPremultiplyAlpha: PixelStoreUnpackPremultiplyAlpha;\n pixelStoreUnpackFlipY: PixelStoreUnpackFlipY;\n\n // eslint-disable-next-line camelcase\n extTextureFilterAnisotropic: EXT_texture_filter_anisotropic | null;\n extTextureFilterAnisotropicMax?: GLfloat;\n HALF_FLOAT?: GLenum;\n RGBA16F?: GLenum;\n RGB16F?: GLenum;\n\n constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) {\n this.gl = gl;\n this.clearColor = new ClearColor(this);\n this.clearDepth = new ClearDepth(this);\n this.clearStencil = new ClearStencil(this);\n this.colorMask = new ColorMask(this);\n this.depthMask = new DepthMask(this);\n this.stencilMask = new StencilMask(this);\n this.stencilFunc = new StencilFunc(this);\n this.stencilOp = new StencilOp(this);\n this.stencilTest = new StencilTest(this);\n this.depthRange = new DepthRange(this);\n this.depthTest = new DepthTest(this);\n this.depthFunc = new DepthFunc(this);\n this.blend = new Blend(this);\n this.blendFunc = new BlendFunc(this);\n this.blendColor = new BlendColor(this);\n this.blendEquation = new BlendEquation(this);\n this.cullFace = new CullFace(this);\n this.cullFaceSide = new CullFaceSide(this);\n this.frontFace = new FrontFace(this);\n this.program = new ProgramValue(this);\n this.activeTexture = new ActiveTextureUnit(this);\n this.viewport = new Viewport(this);\n this.bindFramebuffer = new BindFramebuffer(this);\n this.bindRenderbuffer = new BindRenderbuffer(this);\n this.bindTexture = new BindTexture(this);\n this.bindVertexBuffer = new BindVertexBuffer(this);\n this.bindElementBuffer = new BindElementBuffer(this);\n this.bindVertexArray = new BindVertexArray(this);\n this.pixelStoreUnpack = new PixelStoreUnpack(this);\n this.pixelStoreUnpackPremultiplyAlpha = new PixelStoreUnpackPremultiplyAlpha(this);\n this.pixelStoreUnpackFlipY = new PixelStoreUnpackFlipY(this);\n\n this.extTextureFilterAnisotropic = (\n gl.getExtension('EXT_texture_filter_anisotropic') ||\n gl.getExtension('MOZ_EXT_texture_filter_anisotropic') ||\n gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')\n );\n\n if (this.extTextureFilterAnisotropic) {\n this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\n }\n\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n\n if (isWebGL2(gl)) {\n this.HALF_FLOAT = gl.HALF_FLOAT;\n const extColorBufferHalfFloat = gl.getExtension('EXT_color_buffer_half_float');\n this.RGBA16F = gl.RGBA16F ?? extColorBufferHalfFloat?.RGBA16F_EXT;\n this.RGB16F = gl.RGB16F ?? extColorBufferHalfFloat?.RGB16F_EXT;\n gl.getExtension('EXT_color_buffer_float');\n } else {\n gl.getExtension('EXT_color_buffer_half_float');\n gl.getExtension('OES_texture_half_float_linear');\n const extTextureHalfFloat = gl.getExtension('OES_texture_half_float');\n this.HALF_FLOAT = extTextureHalfFloat?.HALF_FLOAT_OES;\n }\n }\n\n setDefault() {\n this.unbindVAO();\n\n this.clearColor.setDefault();\n this.clearDepth.setDefault();\n this.clearStencil.setDefault();\n this.colorMask.setDefault();\n this.depthMask.setDefault();\n this.stencilMask.setDefault();\n this.stencilFunc.setDefault();\n this.stencilOp.setDefault();\n this.stencilTest.setDefault();\n this.depthRange.setDefault();\n this.depthTest.setDefault();\n this.depthFunc.setDefault();\n this.blend.setDefault();\n this.blendFunc.setDefault();\n this.blendColor.setDefault();\n this.blendEquation.setDefault();\n this.cullFace.setDefault();\n this.cullFaceSide.setDefault();\n this.frontFace.setDefault();\n this.program.setDefault();\n this.activeTexture.setDefault();\n this.bindFramebuffer.setDefault();\n this.pixelStoreUnpack.setDefault();\n this.pixelStoreUnpackPremultiplyAlpha.setDefault();\n this.pixelStoreUnpackFlipY.setDefault();\n }\n\n setDirty() {\n this.clearColor.dirty = true;\n this.clearDepth.dirty = true;\n this.clearStencil.dirty = true;\n this.colorMask.dirty = true;\n this.depthMask.dirty = true;\n this.stencilMask.dirty = true;\n this.stencilFunc.dirty = true;\n this.stencilOp.dirty = true;\n this.stencilTest.dirty = true;\n this.depthRange.dirty = true;\n this.depthTest.dirty = true;\n this.depthFunc.dirty = true;\n this.blend.dirty = true;\n this.blendFunc.dirty = true;\n this.blendColor.dirty = true;\n this.blendEquation.dirty = true;\n this.cullFace.dirty = true;\n this.cullFaceSide.dirty = true;\n this.frontFace.dirty = true;\n this.program.dirty = true;\n this.activeTexture.dirty = true;\n this.viewport.dirty = true;\n this.bindFramebuffer.dirty = true;\n this.bindRenderbuffer.dirty = true;\n this.bindTexture.dirty = true;\n this.bindVertexBuffer.dirty = true;\n this.bindElementBuffer.dirty = true;\n this.bindVertexArray.dirty = true;\n this.pixelStoreUnpack.dirty = true;\n this.pixelStoreUnpackPremultiplyAlpha.dirty = true;\n this.pixelStoreUnpackFlipY.dirty = true;\n }\n\n createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) {\n return new IndexBuffer(this, array, dynamicDraw);\n }\n\n createVertexBuffer(array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) {\n return new VertexBuffer(this, array, attributes, dynamicDraw);\n }\n\n createRenderbuffer(storageFormat: number, width: number, height: number) {\n const gl = this.gl;\n\n const rbo = gl.createRenderbuffer();\n this.bindRenderbuffer.set(rbo);\n gl.renderbufferStorage(gl.RENDERBUFFER, storageFormat, width, height);\n this.bindRenderbuffer.set(null);\n\n return rbo;\n }\n\n createFramebuffer(width: number, height: number, hasDepth: boolean, hasStencil: boolean) {\n return new Framebuffer(this, width, height, hasDepth, hasStencil);\n }\n\n clear({\n color,\n depth,\n stencil\n }: ClearArgs) {\n const gl = this.gl;\n let mask = 0;\n\n if (color) {\n mask |= gl.COLOR_BUFFER_BIT;\n this.clearColor.set(color);\n this.colorMask.set([true, true, true, true]);\n }\n\n if (typeof depth !== 'undefined') {\n mask |= gl.DEPTH_BUFFER_BIT;\n\n // Workaround for platforms where clearDepth doesn't seem to work\n // without resetting the depthRange. See https://github.com/mapbox/mapbox-gl-js/issues/3437\n this.depthRange.set([0, 1]);\n\n this.clearDepth.set(depth);\n this.depthMask.set(true);\n }\n\n if (typeof stencil !== 'undefined') {\n mask |= gl.STENCIL_BUFFER_BIT;\n this.clearStencil.set(stencil);\n this.stencilMask.set(0xFF);\n }\n\n gl.clear(mask);\n }\n\n setCullFace(cullFaceMode: Readonly) {\n if (cullFaceMode.enable === false) {\n this.cullFace.set(false);\n } else {\n this.cullFace.set(true);\n this.cullFaceSide.set(cullFaceMode.mode);\n this.frontFace.set(cullFaceMode.frontFace);\n }\n }\n\n setDepthMode(depthMode: Readonly) {\n if (depthMode.func === this.gl.ALWAYS && !depthMode.mask) {\n this.depthTest.set(false);\n } else {\n this.depthTest.set(true);\n this.depthFunc.set(depthMode.func);\n this.depthMask.set(depthMode.mask);\n this.depthRange.set(depthMode.range);\n }\n }\n\n setStencilMode(stencilMode: Readonly) {\n if (stencilMode.test.func === this.gl.ALWAYS && !stencilMode.mask) {\n this.stencilTest.set(false);\n } else {\n this.stencilTest.set(true);\n this.stencilMask.set(stencilMode.mask);\n this.stencilOp.set([stencilMode.fail, stencilMode.depthFail, stencilMode.pass]);\n this.stencilFunc.set({\n func: stencilMode.test.func,\n ref: stencilMode.ref,\n mask: stencilMode.test.mask\n });\n }\n }\n\n setColorMode(colorMode: Readonly) {\n if (deepEqual(colorMode.blendFunction, ColorMode.Replace)) {\n this.blend.set(false);\n } else {\n this.blend.set(true);\n this.blendFunc.set(colorMode.blendFunction);\n this.blendColor.set(colorMode.blendColor);\n }\n\n this.colorMask.set(colorMode.mask);\n }\n\n createVertexArray(): WebGLVertexArrayObject | undefined {\n if (isWebGL2(this.gl))\n return this.gl.createVertexArray();\n return this.gl.getExtension('OES_vertex_array_object')?.createVertexArrayOES();\n }\n\n deleteVertexArray(x: WebGLVertexArrayObject | undefined) {\n if (isWebGL2(this.gl))\n return this.gl.deleteVertexArray(x);\n return this.gl.getExtension('OES_vertex_array_object')?.deleteVertexArrayOES(x);\n }\n\n unbindVAO() {\n // Unbinding the VAO prevents other things (custom layers, new buffer creation) from\n // unintentionally changing the state of the last VAO used.\n this.bindVertexArray.set(null);\n }\n}\n","import type {DepthFuncType, DepthMaskType, DepthRangeType} from './types';\n\nconst ALWAYS = 0x0207;\n\nexport class DepthMode {\n func: DepthFuncType;\n mask: DepthMaskType;\n range: DepthRangeType;\n\n // DepthMask enums\n static ReadOnly: boolean;\n static ReadWrite: boolean;\n\n constructor(depthFunc: DepthFuncType, depthMask: DepthMaskType, depthRange: DepthRangeType) {\n this.func = depthFunc;\n this.mask = depthMask;\n this.range = depthRange;\n }\n\n static disabled: Readonly;\n}\n\nDepthMode.ReadOnly = false;\nDepthMode.ReadWrite = true;\n\nDepthMode.disabled = new DepthMode(ALWAYS, DepthMode.ReadOnly, [0, 1]);\n","import type {StencilOpConstant, StencilTestGL} from './types';\n\nconst ALWAYS = 0x0207;\nconst KEEP = 0x1E00;\n\nexport class StencilMode {\n test: StencilTestGL;\n ref: number;\n mask: number;\n fail: StencilOpConstant;\n depthFail: StencilOpConstant;\n pass: StencilOpConstant;\n\n constructor(test: StencilTestGL, ref: number, mask: number, fail: StencilOpConstant,\n depthFail: StencilOpConstant, pass: StencilOpConstant) {\n this.test = test;\n this.ref = ref;\n this.mask = mask;\n this.fail = fail;\n this.depthFail = depthFail;\n this.pass = pass;\n }\n\n static disabled: Readonly;\n}\n\nStencilMode.disabled = new StencilMode({func: ALWAYS, mask: 0}, 0, 0, KEEP, KEEP, KEEP);\n","import type {CullFaceModeType, FrontFaceType} from './types';\n\nconst BACK = 0x0405;\nconst CCW = 0x0901;\n\nexport class CullFaceMode {\n enable: boolean;\n mode: CullFaceModeType;\n frontFace: FrontFaceType;\n\n constructor(enable: boolean, mode: CullFaceModeType, frontFace: FrontFaceType) {\n this.enable = enable;\n this.mode = mode;\n this.frontFace = frontFace;\n }\n\n static disabled: Readonly;\n static backCCW: Readonly;\n}\n\nCullFaceMode.disabled = new CullFaceMode(false, BACK, CCW);\nCullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW);\n","import type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {collisionUniformValues, collisionCircleUniformValues} from './program/collision_program';\n\nimport {QuadTriangleArray, CollisionCircleLayoutArray} from '../data/array_types.g';\nimport {collisionCircleLayout} from '../data/bucket/symbol_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {mat4} from 'gl-matrix';\nimport {VertexBuffer} from '../gl/vertex_buffer';\nimport {IndexBuffer} from '../gl/index_buffer';\n\ntype TileBatch = {\n circleArray: Array;\n circleOffset: number;\n transform: mat4;\n invTransform: mat4;\n coord: OverscaledTileID;\n};\n\nlet quadTriangles: QuadTriangleArray;\n\nexport function drawCollisionDebug(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array, translate: [number, number], translateAnchor: 'map' | 'viewport', isText: boolean) {\n const context = painter.context;\n const gl = context.gl;\n const program = painter.useProgram('collisionBox');\n const tileBatches: Array = [];\n let circleCount = 0;\n let circleOffset = 0;\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n const tile = sourceCache.getTile(coord);\n const bucket: SymbolBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n let posMatrix = coord.posMatrix;\n if (translate[0] !== 0 || translate[1] !== 0) {\n posMatrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor);\n }\n const buffers = isText ? bucket.textCollisionBox : bucket.iconCollisionBox;\n // Get collision circle data of this bucket\n const circleArray: Array = bucket.collisionCircleArray;\n if (circleArray.length > 0) {\n // We need to know the projection matrix that was used for projecting collision circles to the screen.\n // This might vary between buckets as the symbol placement is a continuous process. This matrix is\n // required for transforming points from previous screen space to the current one\n const invTransform = mat4.create();\n const transform = posMatrix;\n\n mat4.mul(invTransform, bucket.placementInvProjMatrix, painter.transform.glCoordMatrix);\n mat4.mul(invTransform, invTransform, bucket.placementViewportMatrix);\n\n tileBatches.push({\n circleArray,\n circleOffset,\n transform,\n invTransform,\n coord\n });\n\n circleCount += circleArray.length / 4; // 4 values per circle\n circleOffset = circleCount;\n }\n if (!buffers) continue;\n program.draw(context, gl.LINES,\n DepthMode.disabled, StencilMode.disabled,\n painter.colorModeForRenderPass(),\n CullFaceMode.disabled,\n collisionUniformValues(\n posMatrix,\n painter.transform,\n tile),\n painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord),\n layer.id, buffers.layoutVertexBuffer, buffers.indexBuffer,\n buffers.segments, null, painter.transform.zoom, null, null,\n buffers.collisionVertexBuffer);\n }\n\n if (!isText || !tileBatches.length) {\n return;\n }\n\n // Render collision circles\n const circleProgram = painter.useProgram('collisionCircle');\n\n // Construct vertex data\n const vertexData = new CollisionCircleLayoutArray();\n vertexData.resize(circleCount * 4);\n vertexData._trim();\n\n let vertexOffset = 0;\n\n for (const batch of tileBatches) {\n for (let i = 0; i < batch.circleArray.length / 4; i++) {\n const circleIdx = i * 4;\n const x = batch.circleArray[circleIdx + 0];\n const y = batch.circleArray[circleIdx + 1];\n const radius = batch.circleArray[circleIdx + 2];\n const collision = batch.circleArray[circleIdx + 3];\n\n // 4 floats per vertex, 4 vertices per quad\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 0);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 1);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 2);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 3);\n }\n }\n if (!quadTriangles || quadTriangles.length < circleCount * 2) {\n quadTriangles = createQuadTriangles(circleCount);\n }\n\n const indexBuffer: IndexBuffer = context.createIndexBuffer(quadTriangles, true);\n const vertexBuffer: VertexBuffer = context.createVertexBuffer(vertexData, collisionCircleLayout.members, true);\n\n // Render batches\n for (const batch of tileBatches) {\n const uniforms = collisionCircleUniformValues(\n batch.transform,\n batch.invTransform,\n painter.transform\n );\n\n circleProgram.draw(\n context,\n gl.TRIANGLES,\n DepthMode.disabled,\n StencilMode.disabled,\n painter.colorModeForRenderPass(),\n CullFaceMode.disabled,\n uniforms,\n painter.style.map.terrain && painter.style.map.terrain.getTerrainData(batch.coord),\n layer.id,\n vertexBuffer,\n indexBuffer,\n SegmentVector.simpleSegment(0, batch.circleOffset * 2, batch.circleArray.length, batch.circleArray.length / 2),\n null,\n painter.transform.zoom,\n null,\n null,\n null);\n }\n\n vertexBuffer.destroy();\n indexBuffer.destroy();\n}\n\nfunction createQuadTriangles(quadCount: number): QuadTriangleArray {\n const triCount = quadCount * 2;\n const array = new QuadTriangleArray();\n\n array.resize(triCount);\n array._trim();\n\n // Two triangles and 4 vertices per quad.\n for (let i = 0; i < triCount; i++) {\n const idx = i * 6;\n\n array.uint16[idx + 0] = i * 4 + 0;\n array.uint16[idx + 1] = i * 4 + 1;\n array.uint16[idx + 2] = i * 4 + 2;\n array.uint16[idx + 3] = i * 4 + 2;\n array.uint16[idx + 4] = i * 4 + 3;\n array.uint16[idx + 5] = i * 4 + 0;\n }\n\n return array;\n}\n","import Point from '@mapbox/point-geometry';\nimport {drawCollisionDebug} from './draw_collision_debug';\n\nimport {SegmentVector} from '../data/segment';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport * as symbolProjection from '../symbol/projection';\nimport {EvaluatedZoomSize, evaluateSizeForFeature, evaluateSizeForZoom} from '../symbol/symbol_size';\nimport {mat4} from 'gl-matrix';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {addDynamicAttributes} from '../data/bucket/symbol_bucket';\n\nimport {getAnchorAlignment, WritingMode} from '../symbol/shaping';\nimport ONE_EM from '../symbol/one_em';\n\nimport {\n SymbolIconUniformsType,\n symbolIconUniformValues,\n symbolSDFUniformValues,\n symbolTextAndIconUniformValues\n} from './program/symbol_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\n\nimport type {Texture} from '../render/texture';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {UniformValues} from './uniform_binding';\nimport type {SymbolSDFUniformsType} from '../render/program/symbol_program';\nimport type {CrossTileID, VariableOffset} from '../symbol/placement';\nimport type {SymbolBucket, SymbolBuffers} from '../data/bucket/symbol_bucket';\nimport type {TerrainData} from '../render/terrain';\nimport type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {ColorMode} from '../gl/color_mode';\nimport type {Program} from './program';\nimport type {TextAnchor} from '../style/style_layer/variable_text_anchor';\n\ntype SymbolTileRenderState = {\n segments: SegmentVector;\n sortKey: number;\n terrainData: TerrainData;\n state: {\n program: Program;\n buffers: SymbolBuffers;\n uniformValues: UniformValues;\n atlasTexture: Texture;\n atlasTextureIcon: Texture | null;\n atlasInterpolation: GLenum;\n atlasInterpolationIcon: GLenum;\n isSDF: boolean;\n hasHalo: boolean;\n };\n};\n\nconst identityMat4 = mat4.identity(new Float32Array(16));\n\nexport function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array, variableOffsets: {\n [_ in CrossTileID]: VariableOffset;\n}) {\n if (painter.renderPass !== 'translucent') return;\n\n // Disable the stencil test so that labels aren't clipped to tile boundaries.\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n\n //Compute variable-offsets before painting since icons and text data positioning\n //depend on each other in this case.\n if (hasVariablePlacement) {\n updateVariableAnchors(coords, painter, layer, sourceCache,\n layer.layout.get('text-rotation-alignment'),\n layer.layout.get('text-pitch-alignment'),\n variableOffsets\n );\n }\n\n if (layer.paint.get('icon-opacity').constantOr(1) !== 0) {\n drawLayerSymbols(painter, sourceCache, layer, coords, false,\n layer.paint.get('icon-translate'),\n layer.paint.get('icon-translate-anchor'),\n layer.layout.get('icon-rotation-alignment'),\n layer.layout.get('icon-pitch-alignment'),\n layer.layout.get('icon-keep-upright'),\n stencilMode, colorMode\n );\n }\n\n if (layer.paint.get('text-opacity').constantOr(1) !== 0) {\n drawLayerSymbols(painter, sourceCache, layer, coords, true,\n layer.paint.get('text-translate'),\n layer.paint.get('text-translate-anchor'),\n layer.layout.get('text-rotation-alignment'),\n layer.layout.get('text-pitch-alignment'),\n layer.layout.get('text-keep-upright'),\n stencilMode, colorMode\n );\n }\n\n if (sourceCache.map.showCollisionBoxes) {\n drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'),\n layer.paint.get('text-translate-anchor'), true);\n drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'),\n layer.paint.get('icon-translate-anchor'), false);\n }\n}\n\nfunction calculateVariableRenderShift(\n anchor: TextAnchor,\n width: number,\n height: number,\n textOffset: [number, number],\n textBoxScale: number,\n renderTextSize: number): Point {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);\n const shiftX = -(horizontalAlign - 0.5) * width;\n const shiftY = -(verticalAlign - 0.5) * height;\n return new Point(\n (shiftX / textBoxScale + textOffset[0]) * renderTextSize,\n (shiftY / textBoxScale + textOffset[1]) * renderTextSize\n );\n}\n\nfunction updateVariableAnchors(coords: Array,\n painter: Painter,\n layer:SymbolStyleLayer, sourceCache: SourceCache,\n rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'],\n pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'],\n variableOffsets: {[_ in CrossTileID]: VariableOffset}) {\n const tr = painter.transform;\n const rotateWithMap = rotationAlignment === 'map';\n const pitchWithMap = pitchAlignment === 'map';\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n const bucket = tile.getBucket(layer) as SymbolBucket;\n if (!bucket || !bucket.text || !bucket.text.segments.get().length) continue;\n\n const sizeData = bucket.textSizeData;\n const size = evaluateSizeForZoom(sizeData, tr.zoom);\n\n const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom);\n const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale);\n const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData();\n\n if (size) {\n const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ);\n const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null;\n updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets,\n tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon, getElevation);\n }\n }\n}\n\nfunction updateVariableAnchorsForBucket(\n bucket: SymbolBucket,\n rotateWithMap: boolean,\n pitchWithMap: boolean,\n variableOffsets: {[_ in CrossTileID]: VariableOffset},\n transform: Transform,\n labelPlaneMatrix: mat4,\n posMatrix: mat4,\n tileScale: number,\n size: EvaluatedZoomSize,\n updateTextFitIcon: boolean,\n getElevation: (x: number, y: number) => number) {\n const placedSymbols = bucket.text.placedSymbolArray;\n const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray;\n const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray;\n const placedTextShifts = {};\n\n dynamicTextLayoutVertexArray.clear();\n for (let s = 0; s < placedSymbols.length; s++) {\n const symbol = placedSymbols.get(s);\n const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation;\n const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null;\n\n if (!variableOffset) {\n // These symbols are from a justification that is not being used, or a label that wasn't placed\n // so we don't need to do the extra math to figure out what incremental shift to apply.\n symbolProjection.hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray);\n } else {\n const tileAnchor = new Point(symbol.anchorX, symbol.anchorY);\n const projectedAnchor = symbolProjection.project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix, getElevation);\n const perspectiveRatio = symbolProjection.getPerspectiveRatio(transform.cameraToCenterDistance, projectedAnchor.signedDistanceFromCamera);\n let renderTextSize = evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / ONE_EM;\n if (pitchWithMap) {\n // Go from size in pixels to equivalent size in tile units\n renderTextSize *= bucket.tilePixelRatio / tileScale;\n }\n\n const {width, height, anchor, textOffset, textBoxScale} = variableOffset;\n\n const shift = calculateVariableRenderShift(\n anchor, width, height, textOffset, textBoxScale, renderTextSize);\n\n // Usual case is that we take the projected anchor and add the pixel-based shift\n // calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent\n // tile-unit based shift to the anchor before projecting to the label plane.\n const shiftedAnchor = pitchWithMap ?\n symbolProjection.project(tileAnchor.add(shift), labelPlaneMatrix, getElevation).point :\n projectedAnchor.point.add(rotateWithMap ?\n shift.rotate(-transform.angle) :\n shift);\n\n const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === WritingMode.vertical) ? Math.PI / 2 : 0;\n for (let g = 0; g < symbol.numGlyphs; g++) {\n addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle);\n }\n //Only offset horizontal text icons\n if (updateTextFitIcon && symbol.associatedIconIndex >= 0) {\n placedTextShifts[symbol.associatedIconIndex] = {shiftedAnchor, angle};\n }\n }\n }\n\n if (updateTextFitIcon) {\n dynamicIconLayoutVertexArray.clear();\n const placedIcons = bucket.icon.placedSymbolArray;\n for (let i = 0; i < placedIcons.length; i++) {\n const placedIcon = placedIcons.get(i);\n if (placedIcon.hidden) {\n symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);\n } else {\n const shift = placedTextShifts[i];\n if (!shift) {\n symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);\n } else {\n for (let g = 0; g < placedIcon.numGlyphs; g++) {\n addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle);\n }\n }\n }\n }\n bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray);\n }\n bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray);\n}\n\nfunction getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) {\n if (bucket.iconsInText && isText) {\n return 'symbolTextAndIcon';\n } else if (isSDF) {\n return 'symbolSDF';\n } else {\n return 'symbolIcon';\n }\n}\n\nfunction drawLayerSymbols(\n painter: Painter,\n sourceCache: SourceCache,\n layer: SymbolStyleLayer,\n coords: Array,\n isText: boolean,\n translate: [number, number],\n translateAnchor: 'map' | 'viewport',\n rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'],\n pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'],\n keepUpright: boolean,\n stencilMode: StencilMode,\n colorMode: Readonly) {\n\n const context = painter.context;\n const gl = context.gl;\n const tr = painter.transform;\n\n const rotateWithMap = rotationAlignment === 'map';\n const pitchWithMap = pitchAlignment === 'map';\n const alongLine = rotationAlignment !== 'viewport' && layer.layout.get('symbol-placement') !== 'point';\n // Line label rotation happens in `updateLineLabels`\n // Pitched point labels are automatically rotated by the labelPlaneMatrix projection\n // Unpitched point labels need to have their rotation applied after projection\n const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;\n\n const hasSortKey = !layer.layout.get('symbol-sort-key').isConstant();\n let sortFeaturesByKey = false;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n\n const tileRenderState: Array = [];\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n const bucket = tile.getBucket(layer) as SymbolBucket;\n if (!bucket) continue;\n const buffers = isText ? bucket.text : bucket.icon;\n\n if (!buffers || !buffers.segments.get().length || !buffers.hasVisibleVertices) continue;\n const programConfiguration = buffers.programConfigurations.get(layer.id);\n\n const isSDF = isText || bucket.sdfIcons;\n\n const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;\n const transformed = pitchWithMap || tr.pitch !== 0;\n\n const program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration);\n const size = evaluateSizeForZoom(sizeData, tr.zoom);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n let texSize: [number, number];\n let texSizeIcon: [number, number] = [0, 0];\n let atlasTexture: Texture;\n let atlasInterpolation: GLenum;\n let atlasTextureIcon = null;\n let atlasInterpolationIcon: GLenum;\n if (isText) {\n atlasTexture = tile.glyphAtlasTexture;\n atlasInterpolation = gl.LINEAR;\n texSize = tile.glyphAtlasTexture.size;\n if (bucket.iconsInText) {\n texSizeIcon = tile.imageAtlasTexture.size;\n atlasTextureIcon = tile.imageAtlasTexture;\n const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera';\n atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST;\n }\n } else {\n const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;\n atlasTexture = tile.imageAtlasTexture;\n atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ?\n gl.LINEAR :\n gl.NEAREST;\n texSize = tile.imageAtlasTexture.size;\n }\n\n const s = pixelsToTileUnits(tile, 1, painter.transform.zoom);\n const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);\n const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);\n\n const hasVariableAnchors = hasVariablePlacement && bucket.hasTextData();\n const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&\n hasVariableAnchors &&\n bucket.hasIconData();\n\n if (alongLine) {\n const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null;\n const rotateToLine = layer.layout.get('text-rotation-alignment') === 'map';\n symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright, rotateToLine, getElevation);\n }\n\n const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),\n uLabelPlaneMatrix = (alongLine || (isText && hasVariablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,\n uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);\n\n const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;\n\n let uniformValues: UniformValues;\n if (isSDF) {\n if (!bucket.iconsInText) {\n uniformValues = symbolSDFUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);\n } else {\n uniformValues = symbolTextAndIconUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);\n }\n } else {\n uniformValues = symbolIconUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, isText, texSize);\n }\n\n const state = {\n program,\n buffers,\n uniformValues,\n atlasTexture,\n atlasTextureIcon,\n atlasInterpolation,\n atlasInterpolationIcon,\n isSDF,\n hasHalo\n };\n\n if (hasSortKey && bucket.canOverlap) {\n sortFeaturesByKey = true;\n const oldSegments = buffers.segments.get();\n for (const segment of oldSegments) {\n tileRenderState.push({\n segments: new SegmentVector([segment]),\n sortKey: segment.sortKey,\n state,\n terrainData\n });\n }\n } else {\n tileRenderState.push({\n segments: buffers.segments,\n sortKey: 0,\n state,\n terrainData\n });\n }\n }\n\n if (sortFeaturesByKey) {\n tileRenderState.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const segmentState of tileRenderState) {\n const state = segmentState.state;\n\n context.activeTexture.set(gl.TEXTURE0);\n // @ts-ignore\n state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE);\n if (state.atlasTextureIcon) {\n context.activeTexture.set(gl.TEXTURE1);\n if (state.atlasTextureIcon) {\n // @ts-ignore\n state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE);\n }\n }\n\n if (state.isSDF) {\n const uniformValues = state.uniformValues;\n if (state.hasHalo) {\n uniformValues['u_is_halo'] = 1;\n drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues, segmentState.terrainData);\n }\n uniformValues['u_is_halo'] = 0;\n }\n drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues, segmentState.terrainData);\n }\n}\n\nfunction drawSymbolElements(\n buffers: SymbolBuffers,\n segments: SegmentVector,\n layer: SymbolStyleLayer,\n painter: Painter,\n program: Program,\n depthMode: Readonly,\n stencilMode: StencilMode,\n colorMode: Readonly,\n uniformValues: UniformValues,\n terrainData: TerrainData) {\n const context = painter.context;\n const gl = context.gl;\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, buffers.layoutVertexBuffer,\n buffers.indexBuffer, segments, layer.paint,\n painter.transform.zoom, buffers.programConfigurations.get(layer.id),\n buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer);\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Program} from './program';\nimport {circleUniformValues} from './program/circle_program';\nimport {SegmentVector} from '../data/segment';\nimport {OverscaledTileID} from '../source/tile_id';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {CircleStyleLayer} from '../style/style_layer/circle_style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {ProgramConfiguration} from '../data/program_configuration';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {UniformValues} from './uniform_binding';\nimport type {CircleUniformsType} from './program/circle_program';\nimport type {TerrainData} from '../render/terrain';\n\ntype TileRenderState = {\n programConfiguration: ProgramConfiguration;\n program: Program;\n layoutVertexBuffer: VertexBuffer;\n indexBuffer: IndexBuffer;\n uniformValues: UniformValues;\n terrainData: TerrainData;\n};\n\ntype SegmentsTileRenderState = {\n segments: SegmentVector;\n sortKey: number;\n state: TileRenderState;\n};\n\nexport function drawCircles(painter: Painter, sourceCache: SourceCache, layer: CircleStyleLayer, coords: Array) {\n if (painter.renderPass !== 'translucent') return;\n\n const opacity = layer.paint.get('circle-opacity');\n const strokeWidth = layer.paint.get('circle-stroke-width');\n const strokeOpacity = layer.paint.get('circle-stroke-opacity');\n const sortFeaturesByKey = !layer.layout.get('circle-sort-key').isConstant();\n\n if (opacity.constantOr(1) === 0 && (strokeWidth.constantOr(1) === 0 || strokeOpacity.constantOr(1) === 0)) {\n return;\n }\n\n const context = painter.context;\n const gl = context.gl;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n // Turn off stencil testing to allow circles to be drawn across boundaries,\n // so that large circles are not clipped to tiles\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n\n const segmentsRenderStates: Array = [];\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n\n const tile = sourceCache.getTile(coord);\n const bucket: CircleBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram('circle', programConfiguration);\n const layoutVertexBuffer = bucket.layoutVertexBuffer;\n const indexBuffer = bucket.indexBuffer;\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const uniformValues = circleUniformValues(painter, coord, tile, layer);\n\n const state: TileRenderState = {\n programConfiguration,\n program,\n layoutVertexBuffer,\n indexBuffer,\n uniformValues,\n terrainData\n };\n\n if (sortFeaturesByKey) {\n const oldSegments = bucket.segments.get();\n for (const segment of oldSegments) {\n segmentsRenderStates.push({\n segments: new SegmentVector([segment]),\n sortKey: (segment.sortKey as any as number),\n state\n });\n }\n } else {\n segmentsRenderStates.push({\n segments: bucket.segments,\n sortKey: 0,\n state\n });\n }\n\n }\n\n if (sortFeaturesByKey) {\n segmentsRenderStates.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const segmentsState of segmentsRenderStates) {\n const {programConfiguration, program, layoutVertexBuffer, indexBuffer, uniformValues, terrainData} = segmentsState.state;\n const segments = segmentsState.segments;\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id,\n layoutVertexBuffer, indexBuffer, segments,\n layer.paint, painter.transform.zoom, programConfiguration);\n }\n}\n","import {Texture} from './texture';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Context} from '../gl/context';\nimport {Framebuffer} from '../gl/framebuffer';\nimport {\n heatmapUniformValues,\n heatmapTextureUniformValues\n} from './program/heatmap_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {HeatmapStyleLayer} from '../style/style_layer/heatmap_style_layer';\nimport type {HeatmapBucket} from '../data/bucket/heatmap_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapStyleLayer, coords: Array) {\n if (layer.paint.get('heatmap-opacity') === 0) {\n return;\n }\n\n if (painter.renderPass === 'offscreen') {\n const context = painter.context;\n const gl = context.gl;\n\n // Allow kernels to be drawn across boundaries, so that\n // large kernels are not clipped to tiles\n const stencilMode = StencilMode.disabled;\n // Turn on additive blending for kernels, which is a key aspect of kernel density estimation formula\n const colorMode = new ColorMode([gl.ONE, gl.ONE], Color.transparent, [true, true, true, true]);\n\n bindFramebuffer(context, painter, layer);\n\n context.clear({color: Color.transparent});\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n\n // Skip tiles that have uncovered parents to avoid flickering; we don't need\n // to use complex tile masking here because the change between zoom levels is subtle,\n // so it's fine to simply render the parent until all its 4 children are loaded\n if (sourceCache.hasRenderableParent(coord)) continue;\n\n const tile = sourceCache.getTile(coord);\n const bucket: HeatmapBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram('heatmap', programConfiguration);\n const {zoom} = painter.transform;\n\n program.draw(context, gl.TRIANGLES, DepthMode.disabled, stencilMode, colorMode, CullFaceMode.disabled,\n heatmapUniformValues(coord.posMatrix, tile, zoom, layer.paint.get('heatmap-intensity')), null,\n layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer,\n bucket.segments, layer.paint, painter.transform.zoom,\n programConfiguration);\n }\n\n context.viewport.set([0, 0, painter.width, painter.height]);\n\n } else if (painter.renderPass === 'translucent') {\n painter.context.setColorMode(painter.colorModeForRenderPass());\n renderTextureToMap(painter, layer);\n }\n}\n\nfunction bindFramebuffer(context: Context, painter: Painter, layer: HeatmapStyleLayer) {\n const gl = context.gl;\n context.activeTexture.set(gl.TEXTURE1);\n\n // Use a 4x downscaled screen texture for better performance\n context.viewport.set([0, 0, painter.width / 4, painter.height / 4]);\n\n let fbo = layer.heatmapFbo;\n\n if (!fbo) {\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\n fbo = layer.heatmapFbo = context.createFramebuffer(painter.width / 4, painter.height / 4, false, false);\n\n bindTextureToFramebuffer(context, painter, texture, fbo);\n\n } else {\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n context.bindFramebuffer.set(fbo.framebuffer);\n }\n}\n\nfunction bindTextureToFramebuffer(context: Context, painter: Painter, texture: WebGLTexture, fbo: Framebuffer) {\n const gl = context.gl;\n // Use the higher precision half-float texture where available (producing much smoother looking heatmaps);\n // Otherwise, fall back to a low precision texture\n\n const numType = context.HALF_FLOAT ?? gl.UNSIGNED_BYTE;\n const internalFormat = context.RGBA16F ?? gl.RGBA;\n\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, painter.width / 4, painter.height / 4, 0, gl.RGBA, numType, null);\n fbo.colorAttachment.set(texture);\n}\n\nfunction renderTextureToMap(painter: Painter, layer: HeatmapStyleLayer) {\n const context = painter.context;\n const gl = context.gl;\n\n // Here we bind two different textures from which we'll sample in drawing\n // heatmaps: the kernel texture, prepared in the offscreen pass, and a\n // color ramp texture.\n const fbo = layer.heatmapFbo;\n if (!fbo) return;\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n\n context.activeTexture.set(gl.TEXTURE1);\n let colorRampTexture = layer.colorRampTexture;\n if (!colorRampTexture) {\n colorRampTexture = layer.colorRampTexture = new Texture(context, layer.colorRamp, gl.RGBA);\n }\n colorRampTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n\n painter.useProgram('heatmapTexture').draw(context, gl.TRIANGLES,\n DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled,\n heatmapTextureUniformValues(painter, layer, 0, 1), null,\n layer.id, painter.viewportBuffer, painter.quadTriangleIndexBuffer,\n painter.viewportSegments, layer.paint, painter.transform.zoom);\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Texture} from './texture';\nimport {\n lineUniformValues,\n linePatternUniformValues,\n lineSDFUniformValues,\n lineGradientUniformValues\n} from './program/line_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {LineStyleLayer} from '../style/style_layer/line_style_layer';\nimport type {LineBucket} from '../data/bucket/line_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {clamp, nextPowerOfTwo} from '../util/util';\nimport {renderColorRamp} from '../util/color_ramp';\nimport {EXTENT} from '../data/extent';\n\nexport function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array) {\n if (painter.renderPass !== 'translucent') return;\n\n const opacity = layer.paint.get('line-opacity');\n const width = layer.paint.get('line-width');\n if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n\n const dasharray = layer.paint.get('line-dasharray');\n const patternProperty = layer.paint.get('line-pattern');\n const image = patternProperty.constantOr(1 as any);\n\n const gradient = layer.paint.get('line-gradient');\n const crossfade = layer.getCrossfadeParameters();\n\n const programId =\n image ? 'linePattern' :\n dasharray ? 'lineSDF' :\n gradient ? 'lineGradient' : 'line';\n\n const context = painter.context;\n const gl = context.gl;\n\n let firstTile = true;\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n\n if (image && !tile.patternsLoaded()) continue;\n\n const bucket: LineBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const prevProgram = painter.context.program.get();\n const program = painter.useProgram(programId, programConfiguration);\n const programChanged = firstTile || program.program !== prevProgram;\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern && tile.imageAtlas) {\n const atlas = tile.imageAtlas;\n const posTo = atlas.patternPositions[constantPattern.to.toString()];\n const posFrom = atlas.patternPositions[constantPattern.from.toString()];\n if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);\n }\n\n const terrainCoord = terrainData ? coord : null;\n const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade, terrainCoord) :\n dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade, terrainCoord) :\n gradient ? lineGradientUniformValues(painter, tile, layer, bucket.lineClipsArray.length, terrainCoord) :\n lineUniformValues(painter, tile, layer, terrainCoord);\n\n if (image) {\n context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n } else if (dasharray && (programChanged || painter.lineAtlas.dirty)) {\n context.activeTexture.set(gl.TEXTURE0);\n painter.lineAtlas.bind(context);\n } else if (gradient) {\n const layerGradient = bucket.gradients[layer.id];\n let gradientTexture = layerGradient.texture;\n if (layer.gradientVersion !== layerGradient.version) {\n let textureResolution = 256;\n if (layer.stepInterpolant) {\n const sourceMaxZoom = sourceCache.getSource().maxzoom;\n const potentialOverzoom = coord.canonical.z === sourceMaxZoom ?\n Math.ceil(1 << (painter.transform.maxZoom - coord.canonical.z)) : 1;\n const lineLength = bucket.maxLineLength / EXTENT;\n // Logical pixel tile size is 512px, and 1024px right before current zoom + 1\n const maxTilePixelSize = 1024;\n // Maximum possible texture coverage heuristic, bound by hardware max texture size\n const maxTextureCoverage = lineLength * maxTilePixelSize * potentialOverzoom;\n textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize);\n }\n layerGradient.gradient = renderColorRamp({\n expression: layer.gradientExpression(),\n evaluationKey: 'lineProgress',\n resolution: textureResolution,\n image: layerGradient.gradient || undefined,\n clips: bucket.lineClipsArray\n });\n if (layerGradient.texture) {\n layerGradient.texture.update(layerGradient.gradient);\n } else {\n layerGradient.texture = new Texture(context, layerGradient.gradient, gl.RGBA);\n }\n layerGradient.version = layer.gradientVersion;\n gradientTexture = layerGradient.texture;\n }\n context.activeTexture.set(gl.TEXTURE0);\n gradientTexture.bind(layer.stepInterpolant ? gl.NEAREST : gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n program.draw(context, gl.TRIANGLES, depthMode,\n painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData,\n layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments,\n layer.paint, painter.transform.zoom, programConfiguration, bucket.layoutVertexBuffer2);\n\n firstTile = false;\n // once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic\n }\n}\n","import type {CrossFaded} from '../style/properties';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport type {Tile} from '../source/tile';\nimport type {ProgramConfiguration} from '../data/program_configuration';\nimport type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';\nimport type {FillStyleLayer} from '../style/style_layer/fill_style_layer';\n\n/**\n * A simple helper shared by draw_fill and draw_fill_extrusions to find the correct pattern positions AND update program.\n * For transtionable properties, especially 'fill-pattern' and 'fill-extrusion-pattern', while rendering certain frames\n * tile.imageAtlas has been updated by worker to hold the new pattern only, but rendering code is still looking for the previous image.\n * The mismatch was causing setConstantPatternPositions method not being called and pixelRatio was always the\n * default of 1, instead of actual values set by original map.addImage.\n *\n * @param programConfiguration - to be used to set pattern position and device pixel ratio.\n * @param propertyName - 'fill-pattern' or 'fill-extrusion-pattern' property key\n * @param constantPattern - either 'fill-pattern' or 'fill-extrusion-pattern' property value\n * @param tile - current tile being drawn\n * @param layer - current layer being rendered\n */\nexport function updatePatternPositionsInProgram(\n programConfiguration: ProgramConfiguration,\n propertyName: 'fill-pattern' | 'fill-extrusion-pattern',\n constantPattern: CrossFaded,\n tile: Tile,\n layer: FillStyleLayer | FillExtrusionStyleLayer): void {\n\n if (!constantPattern || !tile || !tile.imageAtlas) {\n return;\n }\n\n const patternPositions = tile.imageAtlas.patternPositions;\n let posTo = patternPositions[constantPattern.to.toString()];\n let posFrom = patternPositions[constantPattern.from.toString()];\n\n // https://github.com/maplibre/maplibre-gl-js/issues/3377\n if (!posTo && posFrom) posTo = posFrom;\n if (!posFrom && posTo) posFrom = posTo;\n\n // try again in case patternPositions has been updated by worker\n if (!posTo || !posFrom) {\n const transitioned = layer.getPaintProperty(propertyName) as string;\n posTo = patternPositions[transitioned];\n posFrom = patternPositions[transitioned];\n }\n\n if (posTo && posFrom) {\n programConfiguration.setConstantPatternPositions(posTo, posFrom);\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {\n fillUniformValues,\n fillPatternUniformValues,\n fillOutlineUniformValues,\n fillOutlinePatternUniformValues\n} from './program/fill_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {FillStyleLayer} from '../style/style_layer/fill_style_layer';\nimport type {FillBucket} from '../data/bucket/fill_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';\n\nexport function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLayer, coords: Array) {\n const color = layer.paint.get('fill-color');\n const opacity = layer.paint.get('fill-opacity');\n\n if (opacity.constantOr(1) === 0) {\n return;\n }\n\n const colorMode = painter.colorModeForRenderPass();\n\n const pattern = layer.paint.get('fill-pattern');\n const pass = painter.opaquePassEnabledForLayer() &&\n (!pattern.constantOr(1 as any) &&\n color.constantOr(Color.transparent).a === 1 &&\n opacity.constantOr(0) === 1) ? 'opaque' : 'translucent';\n\n // Draw fill\n if (painter.renderPass === pass) {\n const depthMode = painter.depthModeForSublayer(\n 1, painter.renderPass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly);\n drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, false);\n }\n\n // Draw stroke\n if (painter.renderPass === 'translucent' && layer.paint.get('fill-antialias')) {\n\n // If we defined a different color for the fill outline, we are\n // going to ignore the bits in 0x07 and just care about the global\n // clipping mask.\n // Otherwise, we only want to drawFill the antialiased parts that are\n // *outside* the current shape. This is important in case the fill\n // or stroke color is translucent. If we wouldn't clip to outside\n // the current shape, some pixels from the outline stroke overlapped\n // the (non-antialiased) fill.\n const depthMode = painter.depthModeForSublayer(\n layer.getPaintProperty('fill-outline-color') ? 2 : 0, DepthMode.ReadOnly);\n drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, true);\n }\n}\n\nfunction drawFillTiles(\n painter: Painter,\n sourceCache: SourceCache,\n layer: FillStyleLayer,\n coords: Array,\n depthMode: Readonly,\n colorMode: Readonly,\n isOutline: boolean) {\n const gl = painter.context.gl;\n const fillPropertyName = 'fill-pattern';\n const patternProperty = layer.paint.get(fillPropertyName);\n const image = patternProperty && patternProperty.constantOr(1 as any);\n const crossfade = layer.getCrossfadeParameters();\n let drawMode, programName, uniformValues, indexBuffer, segments;\n\n if (!isOutline) {\n programName = image ? 'fillPattern' : 'fill';\n drawMode = gl.TRIANGLES;\n } else {\n programName = image && !layer.getPaintProperty('fill-outline-color') ? 'fillOutlinePattern' : 'fillOutline';\n drawMode = gl.LINES;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n if (image && !tile.patternsLoaded()) continue;\n\n const bucket: FillBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram(programName, programConfiguration);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n if (image) {\n painter.context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n }\n\n updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer);\n\n const terrainCoord = terrainData ? coord : null;\n const posMatrix = terrainCoord ? terrainCoord.posMatrix : coord.posMatrix;\n const tileMatrix = painter.translatePosMatrix(posMatrix, tile,\n layer.paint.get('fill-translate'), layer.paint.get('fill-translate-anchor'));\n\n if (!isOutline) {\n indexBuffer = bucket.indexBuffer;\n segments = bucket.segments;\n uniformValues = image ?\n fillPatternUniformValues(tileMatrix, painter, crossfade, tile) :\n fillUniformValues(tileMatrix);\n } else {\n indexBuffer = bucket.indexBuffer2;\n segments = bucket.segments2;\n const drawingBufferSize = [gl.drawingBufferWidth, gl.drawingBufferHeight] as [number, number];\n uniformValues = (programName === 'fillOutlinePattern' && image) ?\n fillOutlinePatternUniformValues(tileMatrix, painter, crossfade, tile, drawingBufferSize) :\n fillOutlineUniformValues(tileMatrix, drawingBufferSize);\n }\n\n program.draw(painter.context, drawMode, depthMode,\n painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData,\n layer.id, bucket.layoutVertexBuffer, indexBuffer, segments,\n layer.paint, painter.transform.zoom, programConfiguration);\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {\n fillExtrusionUniformValues,\n fillExtrusionPatternUniformValues,\n} from './program/fill_extrusion_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';\nimport type {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nimport {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';\n\nexport function drawFillExtrusion(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLayer, coords: Array) {\n const opacity = layer.paint.get('fill-extrusion-opacity');\n if (opacity === 0) {\n return;\n }\n\n if (painter.renderPass === 'translucent') {\n const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);\n\n if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1 as any)) {\n const colorMode = painter.colorModeForRenderPass();\n drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode);\n\n } else {\n // Draw transparent buildings in two passes so that only the closest surface is drawn.\n // First draw all the extrusions into only the depth buffer. No colors are drawn.\n drawExtrusionTiles(painter, source, layer, coords, depthMode,\n StencilMode.disabled,\n ColorMode.disabled);\n\n // Then draw all the extrusions a second type, only coloring fragments if they have the\n // same depth value as the closest fragment in the previous pass. Use the stencil buffer\n // to prevent the second draw in cases where we have coincident polygons.\n drawExtrusionTiles(painter, source, layer, coords, depthMode,\n painter.stencilModeFor3D(),\n painter.colorModeForRenderPass());\n }\n }\n}\n\nfunction drawExtrusionTiles(\n painter: Painter,\n source: SourceCache,\n layer: FillExtrusionStyleLayer,\n coords: OverscaledTileID[],\n depthMode: DepthMode,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const fillPropertyName = 'fill-extrusion-pattern';\n const patternProperty = layer.paint.get(fillPropertyName);\n const image = patternProperty.constantOr(1 as any);\n const crossfade = layer.getCrossfadeParameters();\n const opacity = layer.paint.get('fill-extrusion-opacity');\n const constantPattern = patternProperty.constantOr(null);\n for (const coord of coords) {\n const tile = source.getTile(coord);\n const bucket: FillExtrusionBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration);\n\n if (image) {\n painter.context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n }\n\n updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer);\n\n const matrix = painter.translatePosMatrix(\n coord.posMatrix,\n tile,\n layer.paint.get('fill-extrusion-translate'),\n layer.paint.get('fill-extrusion-translate-anchor'));\n\n const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient');\n const uniformValues = image ?\n fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile) :\n fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity);\n\n program.draw(context, context.gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.backCCW,\n uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer,\n bucket.segments, layer.paint, painter.transform.zoom,\n programConfiguration, painter.style.map.terrain && bucket.centroidVertexBuffer);\n }\n}\n","import {Texture} from './texture';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {Tile} from '../source/tile';\nimport {\n hillshadeUniformValues,\n hillshadeUniformPrepareValues\n} from './program/hillshade_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: HillshadeStyleLayer, tileIDs: Array) {\n if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') return;\n\n const context = painter.context;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n\n const [stencilModes, coords] = painter.renderPass === 'translucent' ?\n painter.stencilConfigForOverlap(tileIDs) : [{}, tileIDs];\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n if (typeof tile.needsHillshadePrepare !== 'undefined' && tile.needsHillshadePrepare && painter.renderPass === 'offscreen') {\n prepareHillshade(painter, tile, layer, depthMode, StencilMode.disabled, colorMode);\n } else if (painter.renderPass === 'translucent') {\n renderHillshade(painter, coord, tile, layer, depthMode, stencilModes[coord.overscaledZ], colorMode);\n }\n }\n\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\nfunction renderHillshade(\n painter: Painter,\n coord: OverscaledTileID,\n tile: Tile,\n layer: HillshadeStyleLayer,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const fbo = tile.fbo;\n if (!fbo) return;\n\n const program = painter.useProgram('hillshade');\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n\n const terrainCoord = terrainData ? coord : null;\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n hillshadeUniformValues(painter, tile, layer, terrainCoord), terrainData, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n\n}\n\n// hillshade rendering is done in two steps. the prepare step first calculates the slope of the terrain in the x and y\n// directions for each pixel, and saves those values to a framebuffer texture in the r and g channels.\nfunction prepareHillshade(\n painter: Painter,\n tile: Tile,\n layer: HillshadeStyleLayer,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const dem = tile.dem;\n if (dem && dem.data) {\n const tileSize = dem.dim;\n const textureStride = dem.stride;\n\n const pixelData = dem.getPixels();\n context.activeTexture.set(gl.TEXTURE1);\n\n context.pixelStoreUnpackPremultiplyAlpha.set(false);\n tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride);\n if (tile.demTexture) {\n const demTexture = tile.demTexture;\n demTexture.update(pixelData, {premultiply: false});\n demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);\n } else {\n tile.demTexture = new Texture(context, pixelData, gl.RGBA, {premultiply: false});\n tile.demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);\n }\n\n context.activeTexture.set(gl.TEXTURE0);\n\n let fbo = tile.fbo;\n\n if (!fbo) {\n const renderTexture = new Texture(context, {width: tileSize, height: tileSize, data: null}, gl.RGBA);\n renderTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n\n fbo = tile.fbo = context.createFramebuffer(tileSize, tileSize, true, false);\n fbo.colorAttachment.set(renderTexture.texture);\n }\n\n context.bindFramebuffer.set(fbo.framebuffer);\n context.viewport.set([0, 0, tileSize, tileSize]);\n\n painter.useProgram('hillshadePrepare').draw(context, gl.TRIANGLES,\n depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n hillshadeUniformPrepareValues(tile.tileID, dem),\n null, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n\n tile.needsHillshadePrepare = false;\n }\n}\n","import {clamp} from '../util/util';\n\nimport {ImageSource} from '../source/image_source';\nimport {browser} from '../util/browser';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {rasterUniformValues} from './program/raster_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {RasterStyleLayer} from '../style/style_layer/raster_style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array) {\n if (painter.renderPass !== 'translucent') return;\n if (layer.paint.get('raster-opacity') === 0) return;\n if (!tileIDs.length) return;\n\n const context = painter.context;\n const gl = context.gl;\n const source = sourceCache.getSource();\n const program = painter.useProgram('raster');\n\n const colorMode = painter.colorModeForRenderPass();\n\n const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] :\n painter.stencilConfigForOverlap(tileIDs);\n\n const minTileZ = coords[coords.length - 1].overscaledZ;\n\n const align = !painter.options.moving;\n for (const coord of coords) {\n // Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers\n // Use gl.LESS to prevent double drawing in areas where tiles overlap.\n const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ,\n layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS);\n\n const tile = sourceCache.getTile(coord);\n\n tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));\n\n const parentTile = sourceCache.findLoadedParent(coord, 0),\n fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform, painter.style.map.terrain);\n\n let parentScaleBy, parentTL;\n\n const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;\n\n context.activeTexture.set(gl.TEXTURE0);\n tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n\n context.activeTexture.set(gl.TEXTURE1);\n\n if (parentTile) {\n parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ);\n parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1];\n\n } else {\n tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n }\n\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const terrainCoord = terrainData ? coord : null;\n const posMatrix = terrainCoord ? terrainCoord.posMatrix : painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);\n const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer);\n\n if (source instanceof ImageSource) {\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, source.boundsBuffer,\n painter.quadTriangleIndexBuffer, source.boundsSegments);\n } else {\n program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n }\n }\n}\n\nfunction getFadeValues(tile, parentTile, sourceCache, layer, transform, terrain) {\n const fadeDuration = layer.paint.get('raster-fade-duration');\n\n if (!terrain && fadeDuration > 0) {\n const now = browser.now();\n const sinceTile = (now - tile.timeAdded) / fadeDuration;\n const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1;\n\n const source = sourceCache.getSource();\n const idealZ = transform.coveringZoomLevel({\n tileSize: source.tileSize,\n roundZoom: source.roundZoom\n });\n\n // if no parent or parent is older, fade in; if parent is younger, fade out\n const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ);\n\n const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1);\n\n // we don't crossfade tiles that were just refreshed upon expiring:\n // once they're old enough to pass the crossfading threshold\n // (fadeDuration), unset the `refreshedUponExpiration` flag so we don't\n // incorrectly fail to crossfade them when zooming\n if (tile.refreshedUponExpiration && sinceTile >= 1) tile.refreshedUponExpiration = false;\n\n if (parentTile) {\n return {\n opacity: 1,\n mix: 1 - childOpacity\n };\n } else {\n return {\n opacity: childOpacity,\n mix: 0\n };\n }\n } else {\n return {\n opacity: 1,\n mix: 0\n };\n }\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {\n backgroundUniformValues,\n backgroundPatternUniformValues\n} from './program/background_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {BackgroundStyleLayer} from '../style/style_layer/background_style_layer';\nimport {OverscaledTileID} from '../source/tile_id';\n\nexport function drawBackground(painter: Painter, sourceCache: SourceCache, layer: BackgroundStyleLayer, coords?: Array) {\n const color = layer.paint.get('background-color');\n const opacity = layer.paint.get('background-opacity');\n\n if (opacity === 0) return;\n\n const context = painter.context;\n const gl = context.gl;\n const transform = painter.transform;\n const tileSize = transform.tileSize;\n const image = layer.paint.get('background-pattern');\n if (painter.isPatternMissing(image)) return;\n\n const pass = (!image && color.a === 1 && opacity === 1 && painter.opaquePassEnabledForLayer()) ? 'opaque' : 'translucent';\n if (painter.renderPass !== pass) return;\n\n const stencilMode = StencilMode.disabled;\n const depthMode = painter.depthModeForSublayer(0, pass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n const program = painter.useProgram(image ? 'backgroundPattern' : 'background');\n const tileIDs = coords ? coords : transform.coveringTiles({tileSize, terrain: painter.style.map.terrain});\n\n if (image) {\n context.activeTexture.set(gl.TEXTURE0);\n painter.imageManager.bind(painter.context);\n }\n\n const crossfade = layer.getCrossfadeParameters();\n for (const tileID of tileIDs) {\n const matrix = coords ? tileID.posMatrix : painter.transform.calculatePosMatrix(tileID.toUnwrapped());\n const uniformValues = image ?\n backgroundPatternUniformValues(matrix, opacity, painter, image, {tileID, tileSize}, crossfade) :\n backgroundUniformValues(matrix, opacity, color);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(tileID);\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, painter.tileExtentBuffer,\n painter.quadTriangleIndexBuffer, painter.tileExtentSegments);\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {debugUniformValues} from './program/debug_program';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {ColorMode} from '../gl/color_mode';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {Style} from '../style/style';\n\nconst topColor = new Color(1, 0, 0, 1);\nconst btmColor = new Color(0, 1, 0, 1);\nconst leftColor = new Color(0, 0, 1, 1);\nconst rightColor = new Color(1, 0, 1, 1);\nconst centerColor = new Color(0, 1, 1, 1);\n\nexport function drawDebugPadding(painter: Painter) {\n const padding = painter.transform.padding;\n const lineWidth = 3;\n // Top\n drawHorizontalLine(painter, painter.transform.height - (padding.top || 0), lineWidth, topColor);\n // Bottom\n drawHorizontalLine(painter, padding.bottom || 0, lineWidth, btmColor);\n // Left\n drawVerticalLine(painter, padding.left || 0, lineWidth, leftColor);\n // Right\n drawVerticalLine(painter, painter.transform.width - (padding.right || 0), lineWidth, rightColor);\n // Center\n const center = painter.transform.centerPoint;\n drawCrosshair(painter, center.x, painter.transform.height - center.y, centerColor);\n}\n\nfunction drawCrosshair(painter: Painter, x: number, y: number, color: Color) {\n const size = 20;\n const lineWidth = 2;\n //Vertical line\n drawDebugSSRect(painter, x - lineWidth / 2, y - size / 2, lineWidth, size, color);\n //Horizontal line\n drawDebugSSRect(painter, x - size / 2, y - lineWidth / 2, size, lineWidth, color);\n}\n\nfunction drawHorizontalLine(painter: Painter, y: number, lineWidth: number, color: Color) {\n drawDebugSSRect(painter, 0, y + lineWidth / 2, painter.transform.width, lineWidth, color);\n}\n\nfunction drawVerticalLine(painter: Painter, x: number, lineWidth: number, color: Color) {\n drawDebugSSRect(painter, x - lineWidth / 2, 0, lineWidth, painter.transform.height, color);\n}\n\nfunction drawDebugSSRect(painter: Painter, x: number, y: number, width: number, height: number, color: Color) {\n const context = painter.context;\n const gl = context.gl;\n\n gl.enable(gl.SCISSOR_TEST);\n gl.scissor(x * painter.pixelRatio, y * painter.pixelRatio, width * painter.pixelRatio, height * painter.pixelRatio);\n context.clear({color});\n gl.disable(gl.SCISSOR_TEST);\n}\n\nexport function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array) {\n for (let i = 0; i < coords.length; i++) {\n drawDebugTile(painter, sourceCache, coords[i]);\n }\n}\n\nfunction drawDebugTile(painter: Painter, sourceCache: SourceCache, coord: OverscaledTileID) {\n const context = painter.context;\n const gl = context.gl;\n\n const posMatrix = coord.posMatrix;\n const program = painter.useProgram('debug');\n\n const depthMode = DepthMode.disabled;\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n const id = '$debug';\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n context.activeTexture.set(gl.TEXTURE0);\n\n const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData;\n const tileByteLength = (tileRawData && tileRawData.byteLength) || 0;\n const tileSizeKb = Math.floor(tileByteLength / 1024);\n const tileSize = sourceCache.getTile(coord).tileSize;\n const scaleRatio = (512 / Math.min(tileSize, 512) * (coord.overscaledZ / painter.transform.zoom)) * 0.5;\n let tileIdText = coord.canonical.toString();\n if (coord.overscaledZ !== coord.canonical.z) {\n tileIdText += ` => ${coord.overscaledZ}`;\n }\n const tileLabel = `${tileIdText} ${tileSizeKb}kB`;\n drawTextToOverlay(painter, tileLabel);\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, ColorMode.alphaBlended, CullFaceMode.disabled,\n debugUniformValues(posMatrix, Color.transparent, scaleRatio), null, id,\n painter.debugBuffer, painter.quadTriangleIndexBuffer, painter.debugSegments);\n program.draw(context, gl.LINE_STRIP, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n debugUniformValues(posMatrix, Color.red), terrainData, id,\n painter.debugBuffer, painter.tileBorderIndexBuffer, painter.debugSegments);\n}\n\nfunction drawTextToOverlay(painter: Painter, text: string) {\n painter.initDebugOverlayCanvas();\n const canvas = painter.debugOverlayCanvas;\n const gl = painter.context.gl;\n const ctx2d = painter.debugOverlayCanvas.getContext('2d');\n ctx2d.clearRect(0, 0, canvas.width, canvas.height);\n\n ctx2d.shadowColor = 'white';\n ctx2d.shadowBlur = 2;\n ctx2d.lineWidth = 1.5;\n ctx2d.strokeStyle = 'white';\n ctx2d.textBaseline = 'top';\n ctx2d.font = `bold ${36}px Open Sans, sans-serif`;\n ctx2d.fillText(text, 5, 5);\n ctx2d.strokeText(text, 5, 5);\n\n painter.debugOverlayTexture.update(canvas);\n painter.debugOverlayTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n}\n\nexport function selectDebugSource(style: Style, zoom: number): SourceCache | null {\n // Use vector source with highest maxzoom\n // Else use source with highest maxzoom of any type\n let selectedSource: SourceCache = null;\n const layers = Object.values(style._layers);\n const sources = layers.flatMap((layer) => {\n if (layer.source && !layer.isHidden(zoom)) {\n const sourceCache = style.sourceCaches[layer.source];\n return [sourceCache];\n } else {\n return [];\n }\n });\n const vectorSources = sources.filter((source) => source.getSource().type === 'vector');\n const otherSources = sources.filter((source) => source.getSource().type !== 'vector');\n const considerSource = (source: SourceCache) => {\n if (!selectedSource || (selectedSource.getSource().maxzoom < source.getSource().maxzoom)) {\n selectedSource = source;\n }\n };\n vectorSources.forEach((source) => considerSource(source));\n if (!selectedSource) {\n otherSources.forEach((source) => considerSource(source));\n }\n return selectedSource;\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {CustomStyleLayer} from '../style/style_layer/custom_style_layer';\n\nexport function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) {\n\n const context = painter.context;\n const implementation = layer.implementation;\n\n if (painter.renderPass === 'offscreen') {\n\n const prerender = implementation.prerender;\n if (prerender) {\n painter.setCustomLayerDefaults();\n context.setColorMode(painter.colorModeForRenderPass());\n\n prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());\n\n context.setDirty();\n painter.setBaseState();\n }\n\n } else if (painter.renderPass === 'translucent') {\n\n painter.setCustomLayerDefaults();\n\n context.setColorMode(painter.colorModeForRenderPass());\n context.setStencilMode(StencilMode.disabled);\n\n const depthMode = implementation.renderingMode === '3d' ?\n new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D) :\n painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n\n context.setDepthMode(depthMode);\n\n implementation.render(context.gl, painter.transform.customLayerMatrix());\n\n context.setDirty();\n painter.setBaseState();\n context.bindFramebuffer.set(null);\n }\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues} from './program/terrain_program';\nimport type {Painter} from './painter';\nimport type {Tile} from '../source/tile';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {ColorMode} from '../gl/color_mode';\nimport {Terrain} from './terrain';\n\n/**\n * Redraw the Depth Framebuffer\n * @param painter - the painter\n * @param terrain - the terrain\n */\nfunction drawDepth(painter: Painter, terrain: Terrain) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = ColorMode.unblended;\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]);\n const mesh = terrain.getTerrainMesh();\n const tiles = terrain.sourceCache.getRenderableTiles();\n const program = painter.useProgram('terrainDepth');\n context.bindFramebuffer.set(terrain.getFramebuffer('depth').framebuffer);\n context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]);\n context.clear({color: Color.transparent, depth: 1});\n for (const tile of tiles) {\n const terrainData = terrain.getTerrainData(tile.tileID);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainDepthUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n }\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\n/**\n * Redraw the Coords Framebuffers\n * @param painter - the painter\n * @param terrain - the terrain\n */\nfunction drawCoords(painter: Painter, terrain: Terrain) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = ColorMode.unblended;\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]);\n const mesh = terrain.getTerrainMesh();\n const coords = terrain.getCoordsTexture();\n const tiles = terrain.sourceCache.getRenderableTiles();\n\n // draw tile-coords into framebuffer\n const program = painter.useProgram('terrainCoords');\n context.bindFramebuffer.set(terrain.getFramebuffer('coords').framebuffer);\n context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]);\n context.clear({color: Color.transparent, depth: 1});\n terrain.coordsIndex = [];\n for (const tile of tiles) {\n const terrainData = terrain.getTerrainData(tile.tileID);\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, coords.texture);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainCoordsUniformValues(posMatrix, 255 - terrain.coordsIndex.length, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n terrain.coordsIndex.push(tile.tileID.key);\n }\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\nfunction drawTerrain(painter: Painter, terrain: Terrain, tiles: Array) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = painter.colorModeForRenderPass();\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);\n const program = painter.useProgram('terrain');\n const mesh = terrain.getTerrainMesh();\n\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n\n for (const tile of tiles) {\n const texture = painter.renderToTexture.getTexture(tile);\n const terrainData = terrain.getTerrainData(tile.tileID);\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture.texture);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n }\n\n}\n\nexport {\n drawTerrain,\n drawDepth,\n drawCoords\n};\n","import {browser} from '../util/browser';\nimport {mat4, vec3} from 'gl-matrix';\nimport {SourceCache} from '../source/source_cache';\nimport {EXTENT} from '../data/extent';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport {SegmentVector} from '../data/segment';\nimport {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types.g';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport posAttributes from '../data/pos_attributes';\nimport {ProgramConfiguration} from '../data/program_configuration';\nimport {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';\nimport {shaders} from '../shaders/shaders';\nimport {Program} from './program';\nimport {programUniforms} from './program/program_uniforms';\nimport {Context} from '../gl/context';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Texture} from './texture';\nimport {clippingMaskUniformValues} from './program/clipping_mask_program';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {drawSymbols} from './draw_symbol';\nimport {drawCircles} from './draw_circle';\nimport {drawHeatmap} from './draw_heatmap';\nimport {drawLine} from './draw_line';\nimport {drawFill} from './draw_fill';\nimport {drawFillExtrusion} from './draw_fill_extrusion';\nimport {drawHillshade} from './draw_hillshade';\nimport {drawRaster} from './draw_raster';\nimport {drawBackground} from './draw_background';\nimport {drawDebug, drawDebugPadding, selectDebugSource} from './draw_debug';\nimport {drawCustom} from './draw_custom';\nimport {drawDepth, drawCoords} from './draw_terrain';\nimport {OverscaledTileID} from '../source/tile_id';\n\nimport type {Transform} from '../geo/transform';\nimport type {Tile} from '../source/tile';\nimport type {Style} from '../style/style';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CrossFaded} from '../style/properties';\nimport type {LineAtlas} from './line_atlas';\nimport type {ImageManager} from './image_manager';\nimport type {GlyphManager} from './glyph_manager';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {DepthRangeType, DepthMaskType, DepthFuncType} from '../gl/types';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {RenderToTexture} from './render_to_texture';\n\nexport type RenderPass = 'offscreen' | 'opaque' | 'translucent';\n\ntype PainterOptions = {\n showOverdrawInspector: boolean;\n showTileBoundaries: boolean;\n showPadding: boolean;\n rotating: boolean;\n zooming: boolean;\n moving: boolean;\n fadeDuration: number;\n};\n\n/**\n * @internal\n * Initialize a new painter object.\n */\nexport class Painter {\n context: Context;\n transform: Transform;\n renderToTexture: RenderToTexture;\n _tileTextures: {\n [_: number]: Array;\n };\n numSublayers: number;\n depthEpsilon: number;\n emptyProgramConfiguration: ProgramConfiguration;\n width: number;\n height: number;\n pixelRatio: number;\n tileExtentBuffer: VertexBuffer;\n tileExtentSegments: SegmentVector;\n debugBuffer: VertexBuffer;\n debugSegments: SegmentVector;\n rasterBoundsBuffer: VertexBuffer;\n rasterBoundsSegments: SegmentVector;\n viewportBuffer: VertexBuffer;\n viewportSegments: SegmentVector;\n quadTriangleIndexBuffer: IndexBuffer;\n tileBorderIndexBuffer: IndexBuffer;\n _tileClippingMaskIDs: {[_: string]: number};\n stencilClearMode: StencilMode;\n style: Style;\n options: PainterOptions;\n lineAtlas: LineAtlas;\n imageManager: ImageManager;\n glyphManager: GlyphManager;\n depthRangeFor3D: DepthRangeType;\n opaquePassCutoff: number;\n renderPass: RenderPass;\n currentLayer: number;\n currentStencilSource: string;\n nextStencilID: number;\n id: string;\n _showOverdrawInspector: boolean;\n cache: {[_: string]: Program};\n crossTileSymbolIndex: CrossTileSymbolIndex;\n symbolFadeChange: number;\n debugOverlayTexture: Texture;\n debugOverlayCanvas: HTMLCanvasElement;\n // this object stores the current camera-matrix and the last render time\n // of the terrain-facilitators. e.g. depth & coords framebuffers\n // every time the camera-matrix changes the terrain-facilitators will be redrawn.\n terrainFacilitator: {dirty: boolean; matrix: mat4; renderTime: number};\n\n constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, transform: Transform) {\n this.context = new Context(gl);\n this.transform = transform;\n this._tileTextures = {};\n this.terrainFacilitator = {dirty: true, matrix: mat4.create(), renderTime: 0};\n\n this.setup();\n\n // Within each layer there are multiple distinct z-planes that can be drawn to.\n // This is implemented using the WebGL depth buffer.\n this.numSublayers = SourceCache.maxUnderzooming + SourceCache.maxOverzooming + 1;\n this.depthEpsilon = 1 / Math.pow(2, 16);\n\n this.crossTileSymbolIndex = new CrossTileSymbolIndex();\n }\n\n /*\n * Update the GL viewport, projection matrix, and transforms to compensate\n * for a new width and height value.\n */\n resize(width: number, height: number, pixelRatio: number) {\n this.width = Math.floor(width * pixelRatio);\n this.height = Math.floor(height * pixelRatio);\n this.pixelRatio = pixelRatio;\n this.context.viewport.set([0, 0, this.width, this.height]);\n\n if (this.style) {\n for (const layerId of this.style._order) {\n this.style._layers[layerId].resize();\n }\n }\n }\n\n setup() {\n const context = this.context;\n\n const tileExtentArray = new PosArray();\n tileExtentArray.emplaceBack(0, 0);\n tileExtentArray.emplaceBack(EXTENT, 0);\n tileExtentArray.emplaceBack(0, EXTENT);\n tileExtentArray.emplaceBack(EXTENT, EXTENT);\n this.tileExtentBuffer = context.createVertexBuffer(tileExtentArray, posAttributes.members);\n this.tileExtentSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const debugArray = new PosArray();\n debugArray.emplaceBack(0, 0);\n debugArray.emplaceBack(EXTENT, 0);\n debugArray.emplaceBack(0, EXTENT);\n debugArray.emplaceBack(EXTENT, EXTENT);\n this.debugBuffer = context.createVertexBuffer(debugArray, posAttributes.members);\n this.debugSegments = SegmentVector.simpleSegment(0, 0, 4, 5);\n\n const rasterBoundsArray = new RasterBoundsArray();\n rasterBoundsArray.emplaceBack(0, 0, 0, 0);\n rasterBoundsArray.emplaceBack(EXTENT, 0, EXTENT, 0);\n rasterBoundsArray.emplaceBack(0, EXTENT, 0, EXTENT);\n rasterBoundsArray.emplaceBack(EXTENT, EXTENT, EXTENT, EXTENT);\n this.rasterBoundsBuffer = context.createVertexBuffer(rasterBoundsArray, rasterBoundsAttributes.members);\n this.rasterBoundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const viewportArray = new PosArray();\n viewportArray.emplaceBack(0, 0);\n viewportArray.emplaceBack(1, 0);\n viewportArray.emplaceBack(0, 1);\n viewportArray.emplaceBack(1, 1);\n this.viewportBuffer = context.createVertexBuffer(viewportArray, posAttributes.members);\n this.viewportSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const tileLineStripIndices = new LineStripIndexArray();\n tileLineStripIndices.emplaceBack(0);\n tileLineStripIndices.emplaceBack(1);\n tileLineStripIndices.emplaceBack(3);\n tileLineStripIndices.emplaceBack(2);\n tileLineStripIndices.emplaceBack(0);\n this.tileBorderIndexBuffer = context.createIndexBuffer(tileLineStripIndices);\n\n const quadTriangleIndices = new TriangleIndexArray();\n quadTriangleIndices.emplaceBack(0, 1, 2);\n quadTriangleIndices.emplaceBack(2, 1, 3);\n this.quadTriangleIndexBuffer = context.createIndexBuffer(quadTriangleIndices);\n\n const gl = this.context.gl;\n this.stencilClearMode = new StencilMode({func: gl.ALWAYS, mask: 0}, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO);\n }\n\n /*\n * Reset the drawing canvas by clearing the stencil buffer so that we can draw\n * new tiles at the same location, while retaining previously drawn pixels.\n */\n clearStencil() {\n const context = this.context;\n const gl = context.gl;\n\n this.nextStencilID = 1;\n this.currentStencilSource = undefined;\n\n // As a temporary workaround for https://github.com/mapbox/mapbox-gl-js/issues/5490,\n // pending an upstream fix, we draw a fullscreen stencil=0 clipping mask here,\n // effectively clearing the stencil buffer: once an upstream patch lands, remove\n // this function in favor of context.clear({ stencil: 0x0 })\n\n const matrix = mat4.create();\n mat4.ortho(matrix, 0, this.width, this.height, 0, 0, 1);\n mat4.scale(matrix, matrix, [gl.drawingBufferWidth, gl.drawingBufferHeight, 0]);\n\n this.useProgram('clippingMask').draw(context, gl.TRIANGLES,\n DepthMode.disabled, this.stencilClearMode, ColorMode.disabled, CullFaceMode.disabled,\n clippingMaskUniformValues(matrix), null,\n '$clipping', this.viewportBuffer,\n this.quadTriangleIndexBuffer, this.viewportSegments);\n }\n\n _renderTileClippingMasks(layer: StyleLayer, tileIDs: Array) {\n if (this.currentStencilSource === layer.source || !layer.isTileClipped() || !tileIDs || !tileIDs.length) return;\n\n this.currentStencilSource = layer.source;\n\n const context = this.context;\n const gl = context.gl;\n\n if (this.nextStencilID + tileIDs.length > 256) {\n // we'll run out of fresh IDs so we need to clear and start from scratch\n this.clearStencil();\n }\n\n context.setColorMode(ColorMode.disabled);\n context.setDepthMode(DepthMode.disabled);\n\n const program = this.useProgram('clippingMask');\n\n this._tileClippingMaskIDs = {};\n\n for (const tileID of tileIDs) {\n const id = this._tileClippingMaskIDs[tileID.key] = this.nextStencilID++;\n const terrainData = this.style.map.terrain && this.style.map.terrain.getTerrainData(tileID);\n\n program.draw(context, gl.TRIANGLES, DepthMode.disabled,\n // Tests will always pass, and ref value will be written to stencil buffer.\n new StencilMode({func: gl.ALWAYS, mask: 0}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE),\n ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(tileID.posMatrix),\n terrainData, '$clipping', this.tileExtentBuffer,\n this.quadTriangleIndexBuffer, this.tileExtentSegments);\n }\n }\n\n stencilModeFor3D(): StencilMode {\n this.currentStencilSource = undefined;\n\n if (this.nextStencilID + 1 > 256) {\n this.clearStencil();\n }\n\n const id = this.nextStencilID++;\n const gl = this.context.gl;\n return new StencilMode({func: gl.NOTEQUAL, mask: 0xFF}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n\n stencilModeForClipping(tileID: OverscaledTileID): StencilMode {\n const gl = this.context.gl;\n return new StencilMode({func: gl.EQUAL, mask: 0xFF}, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n\n /*\n * Sort coordinates by Z as drawing tiles is done in Z-descending order.\n * All children with the same Z write the same stencil value. Children\n * stencil values are greater than parent's. This is used only for raster\n * and raster-dem tiles, which are already clipped to tile boundaries, to\n * mask area of tile overlapped by children tiles.\n * Stencil ref values continue range used in _tileClippingMaskIDs.\n *\n * Returns [StencilMode for tile overscaleZ map, sortedCoords].\n */\n stencilConfigForOverlap(tileIDs: Array): [{\n [_: number]: Readonly;\n }, Array] {\n const gl = this.context.gl;\n const coords = tileIDs.sort((a, b) => b.overscaledZ - a.overscaledZ);\n const minTileZ = coords[coords.length - 1].overscaledZ;\n const stencilValues = coords[0].overscaledZ - minTileZ + 1;\n if (stencilValues > 1) {\n this.currentStencilSource = undefined;\n if (this.nextStencilID + stencilValues > 256) {\n this.clearStencil();\n }\n const zToStencilMode = {};\n for (let i = 0; i < stencilValues; i++) {\n zToStencilMode[i + minTileZ] = new StencilMode({func: gl.GEQUAL, mask: 0xFF}, i + this.nextStencilID, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n this.nextStencilID += stencilValues;\n return [zToStencilMode, coords];\n }\n return [{[minTileZ]: StencilMode.disabled}, coords];\n }\n\n colorModeForRenderPass(): Readonly {\n const gl = this.context.gl;\n if (this._showOverdrawInspector) {\n const numOverdrawSteps = 8;\n const a = 1 / numOverdrawSteps;\n\n return new ColorMode([gl.CONSTANT_COLOR, gl.ONE], new Color(a, a, a, 0), [true, true, true, true]);\n } else if (this.renderPass === 'opaque') {\n return ColorMode.unblended;\n } else {\n return ColorMode.alphaBlended;\n }\n }\n\n depthModeForSublayer(n: number, mask: DepthMaskType, func?: DepthFuncType | null): Readonly {\n if (!this.opaquePassEnabledForLayer()) return DepthMode.disabled;\n const depth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon;\n return new DepthMode(func || this.context.gl.LEQUAL, mask, [depth, depth]);\n }\n\n /*\n * The opaque pass and 3D layers both use the depth buffer.\n * Layers drawn above 3D layers need to be drawn using the\n * painter's algorithm so that they appear above 3D features.\n * This returns true for layers that can be drawn using the\n * opaque pass.\n */\n opaquePassEnabledForLayer() {\n return this.currentLayer < this.opaquePassCutoff;\n }\n\n render(style: Style, options: PainterOptions) {\n this.style = style;\n this.options = options;\n\n this.lineAtlas = style.lineAtlas;\n this.imageManager = style.imageManager;\n this.glyphManager = style.glyphManager;\n\n this.symbolFadeChange = style.placement.symbolFadeChange(browser.now());\n\n this.imageManager.beginFrame();\n\n const layerIds = this.style._order;\n const sourceCaches = this.style.sourceCaches;\n\n const coordsAscending: {[_: string]: Array} = {};\n const coordsDescending: {[_: string]: Array} = {};\n const coordsDescendingSymbol: {[_: string]: Array} = {};\n\n for (const id in sourceCaches) {\n const sourceCache = sourceCaches[id];\n if (sourceCache.used) {\n sourceCache.prepare(this.context);\n }\n\n coordsAscending[id] = sourceCache.getVisibleCoordinates();\n coordsDescending[id] = coordsAscending[id].slice().reverse();\n coordsDescendingSymbol[id] = sourceCache.getVisibleCoordinates(true).reverse();\n }\n\n this.opaquePassCutoff = Infinity;\n for (let i = 0; i < layerIds.length; i++) {\n const layerId = layerIds[i];\n if (this.style._layers[layerId].is3D()) {\n this.opaquePassCutoff = i;\n break;\n }\n }\n\n if (this.renderToTexture) {\n this.renderToTexture.prepareForRender(this.style, this.transform.zoom);\n // this is disabled, because render-to-texture is rendering all layers from bottom to top.\n this.opaquePassCutoff = 0;\n\n // update coords/depth-framebuffer on camera movement, or tile reloading\n const newTiles = this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);\n if (this.terrainFacilitator.dirty || !mat4.equals(this.terrainFacilitator.matrix, this.transform.projMatrix) || newTiles.length) {\n mat4.copy(this.terrainFacilitator.matrix, this.transform.projMatrix);\n this.terrainFacilitator.renderTime = Date.now();\n this.terrainFacilitator.dirty = false;\n drawDepth(this, this.style.map.terrain);\n drawCoords(this, this.style.map.terrain);\n }\n }\n\n // Offscreen pass ===============================================\n // We first do all rendering that requires rendering to a separate\n // framebuffer, and then save those for rendering back to the map\n // later: in doing this we avoid doing expensive framebuffer restores.\n this.renderPass = 'offscreen';\n\n for (const layerId of layerIds) {\n const layer = this.style._layers[layerId];\n if (!layer.hasOffscreenPass() || layer.isHidden(this.transform.zoom)) continue;\n\n const coords = coordsDescending[layer.source];\n if (layer.type !== 'custom' && !coords.length) continue;\n\n this.renderLayer(this, sourceCaches[layer.source], layer, coords);\n }\n\n // Rebind the main framebuffer now that all offscreen layers have been rendered:\n this.context.bindFramebuffer.set(null);\n\n // Clear buffers in preparation for drawing to the main framebuffer\n this.context.clear({color: options.showOverdrawInspector ? Color.black : Color.transparent, depth: 1});\n this.clearStencil();\n\n this._showOverdrawInspector = options.showOverdrawInspector;\n this.depthRangeFor3D = [0, 1 - ((style._order.length + 2) * this.numSublayers * this.depthEpsilon)];\n\n // Opaque pass ===============================================\n // Draw opaque layers top-to-bottom first.\n if (!this.renderToTexture) {\n this.renderPass = 'opaque';\n\n for (this.currentLayer = layerIds.length - 1; this.currentLayer >= 0; this.currentLayer--) {\n const layer = this.style._layers[layerIds[this.currentLayer]];\n const sourceCache = sourceCaches[layer.source];\n const coords = coordsAscending[layer.source];\n\n this._renderTileClippingMasks(layer, coords);\n this.renderLayer(this, sourceCache, layer, coords);\n }\n }\n\n // Translucent pass ===============================================\n // Draw all other layers bottom-to-top.\n this.renderPass = 'translucent';\n\n for (this.currentLayer = 0; this.currentLayer < layerIds.length; this.currentLayer++) {\n const layer = this.style._layers[layerIds[this.currentLayer]];\n const sourceCache = sourceCaches[layer.source];\n\n if (this.renderToTexture && this.renderToTexture.renderLayer(layer)) continue;\n\n // For symbol layers in the translucent pass, we add extra tiles to the renderable set\n // for cross-tile symbol fading. Symbol layers don't use tile clipping, so no need to render\n // separate clipping masks\n const coords = (layer.type === 'symbol' ? coordsDescendingSymbol : coordsDescending)[layer.source];\n\n this._renderTileClippingMasks(layer, coordsAscending[layer.source]);\n this.renderLayer(this, sourceCache, layer, coords);\n }\n\n if (this.options.showTileBoundaries) {\n const selectedSource = selectDebugSource(this.style, this.transform.zoom);\n if (selectedSource) {\n drawDebug(this, selectedSource, selectedSource.getVisibleCoordinates());\n }\n }\n\n if (this.options.showPadding) {\n drawDebugPadding(this);\n }\n\n // Set defaults for most GL values so that anyone using the state after the render\n // encounters more expected values.\n this.context.setDefault();\n }\n\n renderLayer(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array) {\n if (layer.isHidden(this.transform.zoom)) return;\n if (layer.type !== 'background' && layer.type !== 'custom' && !(coords || []).length) return;\n this.id = layer.id;\n\n switch (layer.type) {\n case 'symbol':\n drawSymbols(painter, sourceCache, layer as any, coords, this.style.placement.variableOffsets);\n break;\n case 'circle':\n drawCircles(painter, sourceCache, layer as any, coords);\n break;\n case 'heatmap':\n drawHeatmap(painter, sourceCache, layer as any, coords);\n break;\n case 'line':\n drawLine(painter, sourceCache, layer as any, coords);\n break;\n case 'fill':\n drawFill(painter, sourceCache, layer as any, coords);\n break;\n case 'fill-extrusion':\n drawFillExtrusion(painter, sourceCache, layer as any, coords);\n break;\n case 'hillshade':\n drawHillshade(painter, sourceCache, layer as any, coords);\n break;\n case 'raster':\n drawRaster(painter, sourceCache, layer as any, coords);\n break;\n case 'background':\n drawBackground(painter, sourceCache, layer as any, coords);\n break;\n case 'custom':\n drawCustom(painter, sourceCache, layer as any);\n break;\n }\n }\n\n /**\n * Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it.\n * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units.\n * @returns matrix\n */\n translatePosMatrix(matrix: mat4, tile: Tile, translate: [number, number], translateAnchor: 'map' | 'viewport', inViewportPixelUnitsUnits?: boolean): mat4 {\n if (!translate[0] && !translate[1]) return matrix;\n\n const angle = inViewportPixelUnitsUnits ?\n (translateAnchor === 'map' ? this.transform.angle : 0) :\n (translateAnchor === 'viewport' ? -this.transform.angle : 0);\n\n if (angle) {\n const sinA = Math.sin(angle);\n const cosA = Math.cos(angle);\n translate = [\n translate[0] * cosA - translate[1] * sinA,\n translate[0] * sinA + translate[1] * cosA\n ];\n }\n\n const translation = [\n inViewportPixelUnitsUnits ? translate[0] : pixelsToTileUnits(tile, translate[0], this.transform.zoom),\n inViewportPixelUnitsUnits ? translate[1] : pixelsToTileUnits(tile, translate[1], this.transform.zoom),\n 0\n ] as vec3;\n\n const translatedMatrix = new Float32Array(16);\n mat4.translate(translatedMatrix, matrix, translation);\n return translatedMatrix;\n }\n\n saveTileTexture(texture: Texture) {\n const textures = this._tileTextures[texture.size[0]];\n if (!textures) {\n this._tileTextures[texture.size[0]] = [texture];\n } else {\n textures.push(texture);\n }\n }\n\n getTileTexture(size: number) {\n const textures = this._tileTextures[size];\n return textures && textures.length > 0 ? textures.pop() : null;\n }\n\n /**\n * Checks whether a pattern image is needed, and if it is, whether it is not loaded.\n *\n * @returns true if a needed image is missing and rendering needs to be skipped.\n */\n isPatternMissing(image?: CrossFaded | null): boolean {\n if (!image) return false;\n if (!image.from || !image.to) return true;\n const imagePosA = this.imageManager.getPattern(image.from.toString());\n const imagePosB = this.imageManager.getPattern(image.to.toString());\n return !imagePosA || !imagePosB;\n }\n\n useProgram(name: string, programConfiguration?: ProgramConfiguration | null): Program {\n this.cache = this.cache || {};\n const key = name +\n (programConfiguration ? programConfiguration.cacheKey : '') +\n (this._showOverdrawInspector ? '/overdraw' : '') +\n (this.style.map.terrain ? '/terrain' : '');\n if (!this.cache[key]) {\n this.cache[key] = new Program(\n this.context,\n shaders[name],\n programConfiguration,\n programUniforms[name],\n this._showOverdrawInspector,\n this.style.map.terrain\n );\n }\n return this.cache[key];\n }\n\n /*\n * Reset some GL state to default values to avoid hard-to-debug bugs\n * in custom layers.\n */\n setCustomLayerDefaults() {\n // Prevent custom layers from unintentionally modify the last VAO used.\n // All other state is state is restored on it's own, but for VAOs it's\n // simpler to unbind so that we don't have to track the state of VAOs.\n this.context.unbindVAO();\n\n // The default values for this state is meaningful and often expected.\n // Leaving this state dirty could cause a lot of confusion for users.\n this.context.cullFace.setDefault();\n this.context.activeTexture.setDefault();\n this.context.pixelStoreUnpack.setDefault();\n this.context.pixelStoreUnpackPremultiplyAlpha.setDefault();\n this.context.pixelStoreUnpackFlipY.setDefault();\n }\n\n /*\n * Set GL state that is shared by all layers.\n */\n setBaseState() {\n const gl = this.context.gl;\n this.context.cullFace.set(false);\n this.context.viewport.set([0, 0, this.width, this.height]);\n this.context.blendEquation.set(gl.FUNC_ADD);\n }\n\n initDebugOverlayCanvas() {\n if (this.debugOverlayCanvas == null) {\n this.debugOverlayCanvas = document.createElement('canvas');\n this.debugOverlayCanvas.width = 512;\n this.debugOverlayCanvas.height = 512;\n const gl = this.context.gl;\n this.debugOverlayTexture = new Texture(this.context, this.debugOverlayCanvas, gl.RGBA);\n }\n }\n\n destroy() {\n if (this.debugOverlayTexture) {\n this.debugOverlayTexture.destroy();\n }\n }\n\n /*\n * Return true if drawing buffer size is != from requested size.\n * That means that we've reached GL limits somehow.\n * Note: drawing buffer size changes only when canvas size changes\n */\n overLimit() {\n const {drawingBufferWidth, drawingBufferHeight} = this.context.gl;\n return this.width !== drawingBufferWidth || this.height !== drawingBufferHeight;\n }\n}\n","import {mat4, vec3, vec4} from 'gl-matrix';\n\nclass Frustum {\n\n constructor(public points: vec4[], public planes: vec4[]) { }\n\n public static fromInvProjectionMatrix(invProj: mat4, worldSize: number, zoom: number): Frustum {\n const clipSpaceCorners = [\n [-1, 1, -1, 1],\n [1, 1, -1, 1],\n [1, -1, -1, 1],\n [-1, -1, -1, 1],\n [-1, 1, 1, 1],\n [1, 1, 1, 1],\n [1, -1, 1, 1],\n [-1, -1, 1, 1]\n ];\n\n const scale = Math.pow(2, zoom);\n\n // Transform frustum corner points from clip space to tile space, Z to meters\n const frustumCoords = clipSpaceCorners.map(v => {\n v = vec4.transformMat4([] as any, v as any, invProj) as any;\n const s = 1.0 / v[3] / worldSize * scale;\n return vec4.mul(v as any, v as any, [s, s, 1.0 / v[3], s] as vec4);\n });\n\n const frustumPlanePointIndices = [\n [0, 1, 2], // near\n [6, 5, 4], // far\n [0, 3, 7], // left\n [2, 1, 5], // right\n [3, 2, 6], // bottom\n [0, 4, 5] // top\n ];\n\n const frustumPlanes = frustumPlanePointIndices.map((p: number[]) => {\n const a = vec3.sub([] as any, frustumCoords[p[0]] as vec3, frustumCoords[p[1]] as vec3);\n const b = vec3.sub([] as any, frustumCoords[p[2]] as vec3, frustumCoords[p[1]] as vec3);\n const n = vec3.normalize([] as any, vec3.cross([] as any, a, b)) as any;\n const d = -vec3.dot(n, frustumCoords[p[1]] as vec3);\n return n.concat(d);\n });\n\n return new Frustum(frustumCoords, frustumPlanes);\n }\n}\n\nclass Aabb {\n min: vec3;\n max: vec3;\n center: vec3;\n\n constructor(min_: vec3, max_: vec3) {\n this.min = min_;\n this.max = max_;\n this.center = vec3.scale([] as any, vec3.add([] as any, this.min, this.max), 0.5);\n }\n\n quadrant(index: number): Aabb {\n const split = [(index % 2) === 0, index < 2];\n const qMin = vec3.clone(this.min);\n const qMax = vec3.clone(this.max);\n for (let axis = 0; axis < split.length; axis++) {\n qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];\n qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];\n }\n // Elevation is always constant, hence quadrant.max.z = this.max.z\n qMax[2] = this.max[2];\n return new Aabb(qMin, qMax);\n }\n\n distanceX(point: Array): number {\n const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);\n return pointOnAabb - point[0];\n }\n\n distanceY(point: Array): number {\n const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);\n return pointOnAabb - point[1];\n }\n\n // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,\n // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.\n intersects(frustum: Frustum): number {\n // Execute separating axis test between two convex objects to find intersections\n // Each frustum plane together with 3 major axes define the separating axes\n\n const aabbPoints = [\n [this.min[0], this.min[1], this.min[2], 1],\n [this.max[0], this.min[1], this.min[2], 1],\n [this.max[0], this.max[1], this.min[2], 1],\n [this.min[0], this.max[1], this.min[2], 1],\n [this.min[0], this.min[1], this.max[2], 1],\n [this.max[0], this.min[1], this.max[2], 1],\n [this.max[0], this.max[1], this.max[2], 1],\n [this.min[0], this.max[1], this.max[2], 1]\n ];\n\n let fullyInside = true;\n\n for (let p = 0; p < frustum.planes.length; p++) {\n const plane = frustum.planes[p];\n let pointsInside = 0;\n\n for (let i = 0; i < aabbPoints.length; i++) {\n if (vec4.dot(plane, aabbPoints[i] as any) >= 0) {\n pointsInside++;\n }\n }\n\n if (pointsInside === 0)\n return 0;\n\n if (pointsInside !== aabbPoints.length)\n fullyInside = false;\n }\n\n if (fullyInside)\n return 2;\n\n for (let axis = 0; axis < 3; axis++) {\n let projMin = Number.MAX_VALUE;\n let projMax = -Number.MAX_VALUE;\n\n for (let p = 0; p < frustum.points.length; p++) {\n const projectedPoint = frustum.points[p][axis] - this.min[axis];\n\n projMin = Math.min(projMin, projectedPoint);\n projMax = Math.max(projMax, projectedPoint);\n }\n\n if (projMax < 0 || projMin > this.max[axis] - this.min[axis])\n return 0;\n }\n\n return 1;\n }\n}\nexport {\n Aabb,\n Frustum\n};\n","import {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport Point from '@mapbox/point-geometry';\nimport {clamp} from '../util/util';\n\n/**\n * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.\n * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements\n * on top of the map and having the vanishing point shift as UI elements resize.\n *\n * @group Geography and Geometry\n */\nexport class EdgeInsets {\n /**\n * @defaultValue 0\n */\n top: number;\n /**\n * @defaultValue 0\n */\n bottom: number;\n /**\n * @defaultValue 0\n */\n left: number;\n /**\n * @defaultValue 0\n */\n right: number;\n\n constructor(top: number = 0, bottom: number = 0, left: number = 0, right: number = 0) {\n if (isNaN(top) || top < 0 ||\n isNaN(bottom) || bottom < 0 ||\n isNaN(left) || left < 0 ||\n isNaN(right) || right < 0\n ) {\n throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');\n }\n\n this.top = top;\n this.bottom = bottom;\n this.left = left;\n this.right = right;\n }\n\n /**\n * Interpolates the inset in-place.\n * This maintains the current inset value for any inset not present in `target`.\n * @param start - interpolation start\n * @param target - interpolation target\n * @param t - interpolation step/weight\n * @returns the insets\n */\n interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets {\n if (target.top != null && start.top != null) this.top = interpolates.number(start.top, target.top, t);\n if (target.bottom != null && start.bottom != null) this.bottom = interpolates.number(start.bottom, target.bottom, t);\n if (target.left != null && start.left != null) this.left = interpolates.number(start.left, target.left, t);\n if (target.right != null && start.right != null) this.right = interpolates.number(start.right, target.right, t);\n\n return this;\n }\n\n /**\n * Utility method that computes the new apprent center or vanishing point after applying insets.\n * This is in pixels and with the top left being (0.0) and +y being downwards.\n *\n * @param width - the width\n * @param height - the height\n * @returns the point\n */\n getCenter(width: number, height: number): Point {\n // Clamp insets so they never overflow width/height and always calculate a valid center\n const x = clamp((this.left + width - this.right) / 2, 0, width);\n const y = clamp((this.top + height - this.bottom) / 2, 0, height);\n\n return new Point(x, y);\n }\n\n equals(other: PaddingOptions): boolean {\n return this.top === other.top &&\n this.bottom === other.bottom &&\n this.left === other.left &&\n this.right === other.right;\n }\n\n clone(): EdgeInsets {\n return new EdgeInsets(this.top, this.bottom, this.left, this.right);\n }\n\n /**\n * Returns the current state as json, useful when you want to have a\n * read-only representation of the inset.\n *\n * @returns state as json\n */\n toJSON(): PaddingOptions {\n return {\n top: this.top,\n bottom: this.bottom,\n left: this.left,\n right: this.right\n };\n }\n}\n\n/**\n * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be\n * non-negative integers.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n *\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: 20\n * });\n * ```\n * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)\n * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)\n */\nexport type PaddingOptions = {\n /**\n * Padding in pixels from the top of the map canvas.\n */\n top: number;\n /**\n * Padding in pixels from the bottom of the map canvas.\n */\n bottom: number;\n /**\n * Padding in pixels from the left of the map canvas.\n */\n right: number;\n /**\n * Padding in pixels from the right of the map canvas.\n */\n left: number;\n};\n","import {LngLat} from './lng_lat';\nimport {LngLatBounds} from './lng_lat_bounds';\nimport {MercatorCoordinate, mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude} from './mercator_coordinate';\nimport Point from '@mapbox/point-geometry';\nimport {wrap, clamp} from '../util/util';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {EXTENT} from '../data/extent';\nimport {vec3, vec4, mat4, mat2, vec2} from 'gl-matrix';\nimport {Aabb, Frustum} from '../util/primitives';\nimport {EdgeInsets} from './edge_insets';\n\nimport {UnwrappedTileID, OverscaledTileID, CanonicalTileID} from '../source/tile_id';\nimport type {PaddingOptions} from './edge_insets';\nimport {Terrain} from '../render/terrain';\n\n/**\n * @internal\n * A single transform, generally used for a single tile to be\n * scaled, rotated, and zoomed.\n */\nexport class Transform {\n tileSize: number;\n tileZoom: number;\n lngRange: [number, number];\n latRange: [number, number];\n maxValidLatitude: number;\n scale: number;\n width: number;\n height: number;\n angle: number;\n rotationMatrix: mat2;\n pixelsToGLUnits: [number, number];\n cameraToCenterDistance: number;\n mercatorMatrix: mat4;\n projMatrix: mat4;\n invProjMatrix: mat4;\n alignedProjMatrix: mat4;\n pixelMatrix: mat4;\n pixelMatrix3D: mat4;\n pixelMatrixInverse: mat4;\n glCoordMatrix: mat4;\n labelPlaneMatrix: mat4;\n _fov: number;\n _pitch: number;\n _zoom: number;\n _unmodified: boolean;\n _renderWorldCopies: boolean;\n _minZoom: number;\n _maxZoom: number;\n _minPitch: number;\n _maxPitch: number;\n _center: LngLat;\n _elevation: number;\n _pixelPerMeter: number;\n _edgeInsets: EdgeInsets;\n _constraining: boolean;\n _posMatrixCache: {[_: string]: mat4};\n _alignedPosMatrixCache: {[_: string]: mat4};\n _minEleveationForCurrentTile: number;\n\n constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean) {\n this.tileSize = 512; // constant\n this.maxValidLatitude = 85.051129; // constant\n\n this._renderWorldCopies = renderWorldCopies === undefined ? true : !!renderWorldCopies;\n this._minZoom = minZoom || 0;\n this._maxZoom = maxZoom || 22;\n\n this._minPitch = (minPitch === undefined || minPitch === null) ? 0 : minPitch;\n this._maxPitch = (maxPitch === undefined || maxPitch === null) ? 60 : maxPitch;\n\n this.setMaxBounds();\n\n this.width = 0;\n this.height = 0;\n this._center = new LngLat(0, 0);\n this._elevation = 0;\n this.zoom = 0;\n this.angle = 0;\n this._fov = 0.6435011087932844;\n this._pitch = 0;\n this._unmodified = true;\n this._edgeInsets = new EdgeInsets();\n this._posMatrixCache = {};\n this._alignedPosMatrixCache = {};\n this._minEleveationForCurrentTile = 0;\n }\n\n clone(): Transform {\n const clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies);\n clone.apply(this);\n return clone;\n }\n\n apply(that: Transform) {\n this.tileSize = that.tileSize;\n this.latRange = that.latRange;\n this.width = that.width;\n this.height = that.height;\n this._center = that._center;\n this._elevation = that._elevation;\n this._minEleveationForCurrentTile = that._minEleveationForCurrentTile;\n this.zoom = that.zoom;\n this.angle = that.angle;\n this._fov = that._fov;\n this._pitch = that._pitch;\n this._unmodified = that._unmodified;\n this._edgeInsets = that._edgeInsets.clone();\n this._calcMatrices();\n }\n\n get minZoom(): number { return this._minZoom; }\n set minZoom(zoom: number) {\n if (this._minZoom === zoom) return;\n this._minZoom = zoom;\n this.zoom = Math.max(this.zoom, zoom);\n }\n\n get maxZoom(): number { return this._maxZoom; }\n set maxZoom(zoom: number) {\n if (this._maxZoom === zoom) return;\n this._maxZoom = zoom;\n this.zoom = Math.min(this.zoom, zoom);\n }\n\n get minPitch(): number { return this._minPitch; }\n set minPitch(pitch: number) {\n if (this._minPitch === pitch) return;\n this._minPitch = pitch;\n this.pitch = Math.max(this.pitch, pitch);\n }\n\n get maxPitch(): number { return this._maxPitch; }\n set maxPitch(pitch: number) {\n if (this._maxPitch === pitch) return;\n this._maxPitch = pitch;\n this.pitch = Math.min(this.pitch, pitch);\n }\n\n get renderWorldCopies(): boolean { return this._renderWorldCopies; }\n set renderWorldCopies(renderWorldCopies: boolean) {\n if (renderWorldCopies === undefined) {\n renderWorldCopies = true;\n } else if (renderWorldCopies === null) {\n renderWorldCopies = false;\n }\n\n this._renderWorldCopies = renderWorldCopies;\n }\n\n get worldSize(): number {\n return this.tileSize * this.scale;\n }\n\n get centerOffset(): Point {\n return this.centerPoint._sub(this.size._div(2));\n }\n\n get size(): Point {\n return new Point(this.width, this.height);\n }\n\n get bearing(): number {\n return -this.angle / Math.PI * 180;\n }\n set bearing(bearing: number) {\n const b = -wrap(bearing, -180, 180) * Math.PI / 180;\n if (this.angle === b) return;\n this._unmodified = false;\n this.angle = b;\n this._calcMatrices();\n\n // 2x2 matrix for rotating points\n this.rotationMatrix = mat2.create();\n mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);\n }\n\n get pitch(): number {\n return this._pitch / Math.PI * 180;\n }\n set pitch(pitch: number) {\n const p = clamp(pitch, this.minPitch, this.maxPitch) / 180 * Math.PI;\n if (this._pitch === p) return;\n this._unmodified = false;\n this._pitch = p;\n this._calcMatrices();\n }\n\n get fov(): number {\n return this._fov / Math.PI * 180;\n }\n set fov(fov: number) {\n fov = Math.max(0.01, Math.min(60, fov));\n if (this._fov === fov) return;\n this._unmodified = false;\n this._fov = fov / 180 * Math.PI;\n this._calcMatrices();\n }\n\n get zoom(): number { return this._zoom; }\n set zoom(zoom: number) {\n const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);\n if (this._zoom === constrainedZoom) return;\n this._unmodified = false;\n this._zoom = constrainedZoom;\n this.tileZoom = Math.max(0, Math.floor(constrainedZoom));\n this.scale = this.zoomScale(constrainedZoom);\n this._constrain();\n this._calcMatrices();\n }\n\n get center(): LngLat { return this._center; }\n set center(center: LngLat) {\n if (center.lat === this._center.lat && center.lng === this._center.lng) return;\n this._unmodified = false;\n this._center = center;\n this._constrain();\n this._calcMatrices();\n }\n\n get elevation(): number { return this._elevation; }\n set elevation(elevation: number) {\n if (elevation === this._elevation) return;\n this._elevation = elevation;\n this._constrain();\n this._calcMatrices();\n }\n\n get padding(): PaddingOptions { return this._edgeInsets.toJSON(); }\n set padding(padding: PaddingOptions) {\n if (this._edgeInsets.equals(padding)) return;\n this._unmodified = false;\n //Update edge-insets inplace\n this._edgeInsets.interpolate(this._edgeInsets, padding, 1);\n this._calcMatrices();\n }\n\n /**\n * The center of the screen in pixels with the top-left corner being (0,0)\n * and +y axis pointing downwards. This accounts for padding.\n */\n get centerPoint(): Point {\n return this._edgeInsets.getCenter(this.width, this.height);\n }\n\n /**\n * Returns if the padding params match\n *\n * @param padding - the padding to check against\n * @returns true if they are equal, false otherwise\n */\n isPaddingEqual(padding: PaddingOptions): boolean {\n return this._edgeInsets.equals(padding);\n }\n\n /**\n * Helper method to update edge-insets in place\n *\n * @param start - the starting padding\n * @param target - the target padding\n * @param t - the step/weight\n */\n interpolatePadding(start: PaddingOptions, target: PaddingOptions, t: number) {\n this._unmodified = false;\n this._edgeInsets.interpolate(start, target, t);\n this._constrain();\n this._calcMatrices();\n }\n\n /**\n * Return a zoom level that will cover all tiles the transform\n * @param options - the options\n * @returns zoom level An integer zoom level at which all tiles will be visible.\n */\n coveringZoomLevel(options: {\n /**\n * Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.\n */\n roundZoom?: boolean;\n /**\n * Tile size, expressed in screen pixels.\n */\n tileSize: number;\n }): number {\n const z = (options.roundZoom ? Math.round : Math.floor)(\n this.zoom + this.scaleZoom(this.tileSize / options.tileSize)\n );\n // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.\n return Math.max(0, z);\n }\n\n /**\n * Return any \"wrapped\" copies of a given tile coordinate that are visible\n * in the current view.\n */\n getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) {\n const result = [new UnwrappedTileID(0, tileID)];\n if (this._renderWorldCopies) {\n const utl = this.pointCoordinate(new Point(0, 0));\n const utr = this.pointCoordinate(new Point(this.width, 0));\n const ubl = this.pointCoordinate(new Point(this.width, this.height));\n const ubr = this.pointCoordinate(new Point(0, this.height));\n const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));\n const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));\n\n // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.\n // Both sources draw outside the tile boundaries of the tile that \"contains them\" so we need\n // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.\n const extraWorldCopy = 1;\n\n for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {\n if (w === 0) continue;\n result.push(new UnwrappedTileID(w, tileID));\n }\n }\n return result;\n }\n\n /**\n * Return all coordinates that could cover this transform for a covering\n * zoom level.\n * @param options - the options\n * @returns OverscaledTileIDs\n */\n coveringTiles(\n options: {\n tileSize: number;\n minzoom?: number;\n maxzoom?: number;\n roundZoom?: boolean;\n reparseOverscaled?: boolean;\n renderWorldCopies?: boolean;\n terrain?: Terrain;\n }\n ): Array {\n let z = this.coveringZoomLevel(options);\n const actualZ = z;\n\n if (options.minzoom !== undefined && z < options.minzoom) return [];\n if (options.maxzoom !== undefined && z > options.maxzoom) z = options.maxzoom;\n\n const cameraCoord = this.pointCoordinate(this.getCameraPoint());\n const centerCoord = MercatorCoordinate.fromLngLat(this.center);\n const numTiles = Math.pow(2, z);\n const cameraPoint = [numTiles * cameraCoord.x, numTiles * cameraCoord.y, 0];\n const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];\n const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, z);\n\n // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level\n let minZoom = options.minzoom || 0;\n // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks\n if (!options.terrain && this.pitch <= 60.0 && this._edgeInsets.top < 0.1)\n minZoom = z;\n\n // There should always be a certain number of maximum zoom level tiles surrounding the center location in 2D or in front of the camera in 3D\n const radiusOfMaxLvlLodInTiles = options.terrain ? 2 / Math.min(this.tileSize, options.tileSize) * this.tileSize : 3;\n\n const newRootTile = (wrap: number): any => {\n return {\n aabb: new Aabb([wrap * numTiles, 0, 0], [(wrap + 1) * numTiles, numTiles, 0]),\n zoom: 0,\n x: 0,\n y: 0,\n wrap,\n fullyVisible: false\n };\n };\n\n // Do a depth-first traversal to find visible tiles and proper levels of detail\n const stack = [];\n const result = [];\n const maxZoom = z;\n const overscaledZ = options.reparseOverscaled ? actualZ : z;\n\n if (this._renderWorldCopies) {\n // Render copy of the globe thrice on both sides\n for (let i = 1; i <= 3; i++) {\n stack.push(newRootTile(-i));\n stack.push(newRootTile(i));\n }\n }\n\n stack.push(newRootTile(0));\n\n while (stack.length > 0) {\n const it = stack.pop();\n const x = it.x;\n const y = it.y;\n let fullyVisible = it.fullyVisible;\n\n // Visibility of a tile is not required if any of its ancestor if fully inside the frustum\n if (!fullyVisible) {\n const intersectResult = it.aabb.intersects(cameraFrustum);\n\n if (intersectResult === 0)\n continue;\n\n fullyVisible = intersectResult === 2;\n }\n\n const refPoint = options.terrain ? cameraPoint : centerPoint;\n const distanceX = it.aabb.distanceX(refPoint);\n const distanceY = it.aabb.distanceY(refPoint);\n const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));\n\n // We're using distance based heuristics to determine if a tile should be split into quadrants or not.\n // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.\n // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)\n // we can define distance thresholds for each relative level:\n // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as \"offset+2^(k+1)-2\"\n const distToSplit = radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;\n\n // Have we reached the target depth or is the tile too far away to be any split further?\n if (it.zoom === maxZoom || (longestDim > distToSplit && it.zoom >= minZoom)) {\n const dz = maxZoom - it.zoom, dx = cameraPoint[0] - 0.5 - (x << dz), dy = cameraPoint[1] - 0.5 - (y << dz);\n result.push({\n tileID: new OverscaledTileID(it.zoom === maxZoom ? overscaledZ : it.zoom, it.wrap, it.zoom, x, y),\n distanceSq: vec2.sqrLen([centerPoint[0] - 0.5 - x, centerPoint[1] - 0.5 - y]),\n // this variable is currently not used, but may be important to reduce the amount of loaded tiles\n tileDistanceToCamera: Math.sqrt(dx * dx + dy * dy)\n });\n continue;\n }\n\n for (let i = 0; i < 4; i++) {\n const childX = (x << 1) + (i % 2);\n const childY = (y << 1) + (i >> 1);\n const childZ = it.zoom + 1;\n let quadrant = it.aabb.quadrant(i);\n if (options.terrain) {\n const tileID = new OverscaledTileID(childZ, it.wrap, childZ, childX, childY);\n const minMax = options.terrain.getMinMaxElevation(tileID);\n const minElevation = minMax.minElevation ?? this.elevation;\n const maxElevation = minMax.maxElevation ?? this.elevation;\n quadrant = new Aabb(\n [quadrant.min[0], quadrant.min[1], minElevation] as vec3,\n [quadrant.max[0], quadrant.max[1], maxElevation] as vec3\n );\n }\n stack.push({aabb: quadrant, zoom: childZ, x: childX, y: childY, wrap: it.wrap, fullyVisible});\n }\n }\n\n return result.sort((a, b) => a.distanceSq - b.distanceSq).map(a => a.tileID);\n }\n\n resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n this.pixelsToGLUnits = [2 / width, -2 / height];\n this._constrain();\n this._calcMatrices();\n }\n\n get unmodified(): boolean { return this._unmodified; }\n\n zoomScale(zoom: number) { return Math.pow(2, zoom); }\n scaleZoom(scale: number) { return Math.log(scale) / Math.LN2; }\n\n project(lnglat: LngLat) {\n const lat = clamp(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude);\n return new Point(\n mercatorXfromLng(lnglat.lng) * this.worldSize,\n mercatorYfromLat(lat) * this.worldSize);\n }\n\n unproject(point: Point): LngLat {\n return new MercatorCoordinate(point.x / this.worldSize, point.y / this.worldSize).toLngLat();\n }\n\n get point(): Point { return this.project(this.center); }\n\n /**\n * get the camera position in LngLat and altitudes in meter\n * @returns An object with lngLat & altitude.\n */\n getCameraPosition(): {\n lngLat: LngLat;\n altitude: number;\n } {\n const lngLat = this.pointLocation(this.getCameraPoint());\n const altitude = Math.cos(this._pitch) * this.cameraToCenterDistance / this._pixelPerMeter;\n return {lngLat, altitude: altitude + this.elevation};\n }\n\n /**\n * This method works in combination with freezeElevation activated.\n * freezeElevtion is enabled during map-panning because during this the camera should sit in constant height.\n * After panning finished, call this method to recalculate the zoomlevel for the current camera-height in current terrain.\n * @param terrain - the terrain\n */\n recalculateZoom(terrain: Terrain) {\n // find position the camera is looking on\n const center = this.pointLocation(this.centerPoint, terrain);\n const elevation = terrain.getElevationForLngLatZoom(center, this.tileZoom);\n const deltaElevation = this.elevation - elevation;\n if (!deltaElevation) return;\n\n // calculate mercator distance between camera & target\n const cameraPosition = this.getCameraPosition();\n const camera = MercatorCoordinate.fromLngLat(cameraPosition.lngLat, cameraPosition.altitude);\n const target = MercatorCoordinate.fromLngLat(center, elevation);\n const dx = camera.x - target.x, dy = camera.y - target.y, dz = camera.z - target.z;\n const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);\n\n // from this distance we calculate the new zoomlevel\n const zoom = this.scaleZoom(this.cameraToCenterDistance / distance / this.tileSize);\n\n // update matrices\n this._elevation = elevation;\n this._center = center;\n this.zoom = zoom;\n }\n\n setLocationAtPoint(lnglat: LngLat, point: Point) {\n const a = this.pointCoordinate(point);\n const b = this.pointCoordinate(this.centerPoint);\n const loc = this.locationCoordinate(lnglat);\n const newCenter = new MercatorCoordinate(\n loc.x - (a.x - b.x),\n loc.y - (a.y - b.y));\n this.center = this.coordinateLocation(newCenter);\n if (this._renderWorldCopies) {\n this.center = this.center.wrap();\n }\n }\n\n /**\n * Given a location, return the screen point that corresponds to it\n * @param lnglat - location\n * @param terrain - optional terrain\n * @returns screen point\n */\n locationPoint(lnglat: LngLat, terrain?: Terrain): Point {\n return terrain ?\n this.coordinatePoint(this.locationCoordinate(lnglat), terrain.getElevationForLngLatZoom(lnglat, this.tileZoom), this.pixelMatrix3D) :\n this.coordinatePoint(this.locationCoordinate(lnglat));\n }\n\n /**\n * Given a point on screen, return its lnglat\n * @param p - screen point\n * @param terrain - optional terrain\n * @returns lnglat location\n */\n pointLocation(p: Point, terrain?: Terrain): LngLat {\n return this.coordinateLocation(this.pointCoordinate(p, terrain));\n }\n\n /**\n * Given a geographical lnglat, return an unrounded\n * coordinate that represents it at this transform's zoom level.\n * @param lnglat - the location\n * @returns The mercator coordinate\n */\n locationCoordinate(lnglat: LngLat): MercatorCoordinate {\n return MercatorCoordinate.fromLngLat(lnglat);\n }\n\n /**\n * Given a Coordinate, return its geographical position.\n * @param coord - mercator coordivates\n * @returns lng and lat\n */\n coordinateLocation(coord: MercatorCoordinate): LngLat {\n return coord && coord.toLngLat();\n }\n\n /**\n * Given a Point, return its mercator coordinate.\n * @param p - the point\n * @param terrain - optional terrain\n * @returns lnglat\n */\n pointCoordinate(p: Point, terrain?: Terrain): MercatorCoordinate {\n // get point-coordinate from terrain coordinates framebuffer\n if (terrain) {\n const coordinate = terrain.pointCoordinate(p);\n if (coordinate != null) {\n return coordinate;\n }\n }\n\n // calculate point-coordinate on flat earth\n const targetZ = 0;\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that\n // line with z=0\n\n const coord0 = [p.x, p.y, 0, 1] as any;\n const coord1 = [p.x, p.y, 1, 1] as any;\n\n vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);\n vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);\n\n const w0 = coord0[3];\n const w1 = coord1[3];\n const x0 = coord0[0] / w0;\n const x1 = coord1[0] / w1;\n const y0 = coord0[1] / w0;\n const y1 = coord1[1] / w1;\n const z0 = coord0[2] / w0;\n const z1 = coord1[2] / w1;\n\n const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);\n\n return new MercatorCoordinate(\n interpolates.number(x0, x1, t) / this.worldSize,\n interpolates.number(y0, y1, t) / this.worldSize);\n }\n\n /**\n * Given a coordinate, return the screen point that corresponds to it\n * @param coord - the coordinates\n * @param elevation - the elevation\n * @param pixelMatrix - the pixel matrix\n * @returns screen point\n */\n coordinatePoint(coord: MercatorCoordinate, elevation: number = 0, pixelMatrix = this.pixelMatrix): Point {\n const p = [coord.x * this.worldSize, coord.y * this.worldSize, elevation, 1] as any;\n vec4.transformMat4(p, p, pixelMatrix);\n return new Point(p[0] / p[3], p[1] / p[3]);\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds.\n */\n getBounds(): LngLatBounds {\n const top = Math.max(0, this.height / 2 - this.getHorizon());\n return new LngLatBounds()\n .extend(this.pointLocation(new Point(0, top)))\n .extend(this.pointLocation(new Point(this.width, top)))\n .extend(this.pointLocation(new Point(this.width, this.height)))\n .extend(this.pointLocation(new Point(0, this.height)));\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns max bounds\n */\n getMaxBounds(): LngLatBounds | null {\n if (!this.latRange || this.latRange.length !== 2 ||\n !this.lngRange || this.lngRange.length !== 2) return null;\n\n return new LngLatBounds([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]);\n }\n\n /**\n * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),\n * multiplied by a static factor to simulate the earth-radius.\n * The calculated value is the horizontal line from the camera-height to sea-level.\n * @returns Horizon above center in pixels.\n */\n getHorizon(): number {\n return Math.tan(Math.PI / 2 - this._pitch) * this.cameraToCenterDistance * 0.85;\n }\n\n /**\n * Sets or clears the map's geographical constraints.\n * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map.\n */\n setMaxBounds(bounds?: LngLatBounds | null) {\n if (bounds) {\n this.lngRange = [bounds.getWest(), bounds.getEast()];\n this.latRange = [bounds.getSouth(), bounds.getNorth()];\n this._constrain();\n } else {\n this.lngRange = null;\n this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];\n }\n }\n\n /**\n * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map.\n * @param unwrappedTileID - the tile ID\n */\n calculatePosMatrix(unwrappedTileID: UnwrappedTileID, aligned: boolean = false): mat4 {\n const posMatrixKey = unwrappedTileID.key;\n const cache = aligned ? this._alignedPosMatrixCache : this._posMatrixCache;\n if (cache[posMatrixKey]) {\n return cache[posMatrixKey];\n }\n\n const canonical = unwrappedTileID.canonical;\n const scale = this.worldSize / this.zoomScale(canonical.z);\n const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;\n\n const posMatrix = mat4.identity(new Float64Array(16) as any);\n mat4.translate(posMatrix, posMatrix, [unwrappedX * scale, canonical.y * scale, 0]);\n mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);\n mat4.multiply(posMatrix, aligned ? this.alignedProjMatrix : this.projMatrix, posMatrix);\n\n cache[posMatrixKey] = new Float32Array(posMatrix);\n return cache[posMatrixKey];\n }\n\n customLayerMatrix(): mat4 {\n return this.mercatorMatrix.slice() as any;\n }\n\n _constrain() {\n if (!this.center || !this.width || !this.height || this._constraining) return;\n\n this._constraining = true;\n\n let minY = -90;\n let maxY = 90;\n let minX = -180;\n let maxX = 180;\n let sy, sx, x2, y2;\n const size = this.size,\n unmodified = this._unmodified;\n\n if (this.latRange) {\n const latRange = this.latRange;\n minY = mercatorYfromLat(latRange[1]) * this.worldSize;\n maxY = mercatorYfromLat(latRange[0]) * this.worldSize;\n sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;\n }\n\n if (this.lngRange) {\n const lngRange = this.lngRange;\n\n minX = wrap(\n mercatorXfromLng(lngRange[0]) * this.worldSize,\n 0,\n this.worldSize\n );\n maxX = wrap(\n mercatorXfromLng(lngRange[1]) * this.worldSize,\n 0,\n this.worldSize\n );\n\n if (maxX < minX) maxX += this.worldSize;\n\n sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;\n }\n\n const point = this.point;\n\n // how much the map should scale to fit the screen into given latitude/longitude ranges\n const s = Math.max(sx || 0, sy || 0);\n\n if (s) {\n this.center = this.unproject(new Point(\n sx ? (maxX + minX) / 2 : point.x,\n sy ? (maxY + minY) / 2 : point.y));\n this.zoom += this.scaleZoom(s);\n this._unmodified = unmodified;\n this._constraining = false;\n return;\n }\n\n if (this.latRange) {\n const y = point.y,\n h2 = size.y / 2;\n\n if (y - h2 < minY) y2 = minY + h2;\n if (y + h2 > maxY) y2 = maxY - h2;\n }\n\n if (this.lngRange) {\n const centerX = (minX + maxX) / 2;\n const x = wrap(point.x, centerX - this.worldSize / 2, centerX + this.worldSize / 2);\n const w2 = size.x / 2;\n\n if (x - w2 < minX) x2 = minX + w2;\n if (x + w2 > maxX) x2 = maxX - w2;\n }\n\n // pan the map if the screen goes off the range\n if (x2 !== undefined || y2 !== undefined) {\n this.center = this.unproject(new Point(\n x2 !== undefined ? x2 : point.x,\n y2 !== undefined ? y2 : point.y)).wrap();\n }\n\n this._unmodified = unmodified;\n this._constraining = false;\n }\n\n _calcMatrices() {\n if (!this.height) return;\n\n const halfFov = this._fov / 2;\n const offset = this.centerOffset;\n const x = this.point.x, y = this.point.y;\n this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;\n this._pixelPerMeter = mercatorZfromAltitude(1, this.center.lat) * this.worldSize;\n\n let m = mat4.identity(new Float64Array(16) as any);\n mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);\n mat4.translate(m, m, [1, -1, 0]);\n this.labelPlaneMatrix = m;\n\n m = mat4.identity(new Float64Array(16) as any);\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [-1, -1, 0]);\n mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);\n this.glCoordMatrix = m;\n\n // Calculate the camera to sea-level distance in pixel in respect of terrain\n const cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch);\n // In case of negative minimum elevation (e.g. the dead see, under the sea maps) use a lower plane for calculation\n const minElevation = Math.min(this.elevation, this._minEleveationForCurrentTile);\n const cameraToLowestPointDistance = cameraToSeaLevelDistance - minElevation * this._pixelPerMeter / Math.cos(this._pitch);\n const lowestPlane = minElevation < 0 ? cameraToLowestPointDistance : cameraToSeaLevelDistance;\n\n // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the\n // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.\n // 1 Z unit is equivalent to 1 horizontal px at the center of the map\n // (the distance between[width/2, height/2] and [width/2 + 1, height/2])\n const groundAngle = Math.PI / 2 + this._pitch;\n const fovAboveCenter = this._fov * (0.5 + offset.y / this.height);\n const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));\n\n // Find the distance from the center point to the horizon\n const horizon = this.getHorizon();\n const horizonAngle = Math.atan(horizon / this.cameraToCenterDistance);\n const fovCenterToHorizon = 2 * horizonAngle * (0.5 + offset.y / (horizon * 2));\n const topHalfSurfaceDistanceHorizon = Math.sin(fovCenterToHorizon) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovCenterToHorizon, 0.01, Math.PI - 0.01));\n\n // Calculate z distance of the farthest fragment that should be rendered.\n // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n const topHalfMinDistance = Math.min(topHalfSurfaceDistance, topHalfSurfaceDistanceHorizon);\n const farZ = (Math.cos(Math.PI / 2 - this._pitch) * topHalfMinDistance + lowestPlane) * 1.01;\n\n // The larger the value of nearZ is\n // - the more depth precision is available for features (good)\n // - clipping starts appearing sooner when the camera is close to 3d features (bad)\n //\n // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues\n // when rendering it's layers using custom layers. This value was experimentally chosen and\n // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.\n const nearZ = this.height / 50;\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n m = new Float64Array(16) as any;\n mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);\n\n // Apply center of perspective offset\n m[8] = -offset.x * 2 / this.width;\n m[9] = offset.y * 2 / this.height;\n\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);\n mat4.rotateX(m, m, this._pitch);\n mat4.rotateZ(m, m, this.angle);\n mat4.translate(m, m, [-x, -y, 0]);\n\n // The mercatorMatrix can be used to transform points from mercator coordinates\n // ([0, 0] nw, [1, 1] se) to GL coordinates.\n this.mercatorMatrix = mat4.scale([] as any, m, [this.worldSize, this.worldSize, this.worldSize]);\n\n // scale vertically to meters per pixel (inverse of ground resolution):\n mat4.scale(m, m, [1, 1, this._pixelPerMeter]);\n\n // matrix for conversion from location to screen coordinates in 2D\n this.pixelMatrix = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n mat4.translate(m, m, [0, 0, -this.elevation]); // elevate camera over terrain\n this.projMatrix = m;\n this.invProjMatrix = mat4.invert([] as any, m);\n\n // matrix for conversion from location to screen coordinates in 2D\n this.pixelMatrix3D = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);\n\n // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.\n // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional\n // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension\n // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle\n // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that\n // it is always <= 0.5 pixels.\n const xShift = (this.width % 2) / 2, yShift = (this.height % 2) / 2,\n angleCos = Math.cos(this.angle), angleSin = Math.sin(this.angle),\n dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift,\n dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;\n const alignedM = new Float64Array(m) as any as mat4;\n mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);\n this.alignedProjMatrix = alignedM;\n\n // inverse matrix for conversion from screen coordinaes to location\n m = mat4.invert(new Float64Array(16) as any, this.pixelMatrix);\n if (!m) throw new Error('failed to invert matrix');\n this.pixelMatrixInverse = m;\n\n this._posMatrixCache = {};\n this._alignedPosMatrixCache = {};\n }\n\n maxPitchScaleFactor() {\n // calcMatrices hasn't run yet\n if (!this.pixelMatrixInverse) return 1;\n\n const coord = this.pointCoordinate(new Point(0, 0));\n const p = [coord.x * this.worldSize, coord.y * this.worldSize, 0, 1] as vec4;\n const topPoint = vec4.transformMat4(p, p, this.pixelMatrix);\n return topPoint[3] / this.cameraToCenterDistance;\n }\n\n /**\n * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`\n * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).\n * `cameraPoint` is the projected position of the `cameraLocation`.\n *\n * This point is useful to us because only fill-extrusions that are between `cameraPoint` and\n * the query point on the surface of the earth can extend and intersect the query.\n *\n * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because\n * the camera is right above the center of the map.\n */\n getCameraPoint() {\n const pitch = this._pitch;\n const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);\n return this.centerPoint.add(new Point(0, yOffset));\n }\n\n /**\n * When the map is pitched, some of the 3D features that intersect a query will not intersect\n * the query at the surface of the earth. Instead the feature may be closer and only intersect\n * the query because it extrudes into the air.\n * @param queryGeometry - For point queries, the line from the query point to the \"camera point\",\n * for other geometries, the envelope of the query geometry and the \"camera point\"\n * @returns a geometry that includes all of the original query as well as all possible ares of the\n * screen where the *base* of a visible extrusion could be.\n *\n */\n getCameraQueryGeometry(queryGeometry: Array): Array {\n const c = this.getCameraPoint();\n\n if (queryGeometry.length === 1) {\n return [queryGeometry[0], c];\n } else {\n let minX = c.x;\n let minY = c.y;\n let maxX = c.x;\n let maxY = c.y;\n for (const p of queryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return [\n new Point(minX, minY),\n new Point(maxX, minY),\n new Point(maxX, maxY),\n new Point(minX, maxY),\n new Point(minX, minY)\n ];\n }\n }\n}\n","/**\n * Throttle the given function to run at most every `period` milliseconds.\n */\nexport function throttle void>(fn: T, time: number): (...args: Parameters) => ReturnType {\n let pending = false;\n let timerId: ReturnType = null;\n let lastCallContext = null;\n let lastCallArgs: Parameters;\n\n const later = () => {\n timerId = null;\n if (pending) {\n fn.apply(lastCallContext, lastCallArgs);\n timerId = setTimeout(later, time);\n pending = false;\n }\n };\n\n return (...args: Parameters) => {\n pending = true;\n lastCallContext = this;\n lastCallArgs = args;\n if (!timerId) {\n later();\n }\n return timerId;\n };\n}\n","import {throttle} from '../util/throttle';\n\nimport type {Map} from './map';\n\n/**\n * Adds the map's position to its page's location hash.\n * Passed as an option to the map object.\n *\n * @group Markers and Controls\n */\nexport class Hash {\n _map: Map;\n _hashName: string;\n\n constructor(hashName?: string | null) {\n this._hashName = hashName && encodeURIComponent(hashName);\n }\n\n /**\n * Map element to listen for coordinate changes\n *\n * @param map - The map object\n * @returns `this`\n */\n addTo(map: Map) {\n this._map = map;\n addEventListener('hashchange', this._onHashChange, false);\n this._map.on('moveend', this._updateHash);\n return this;\n }\n\n /**\n * Removes hash\n *\n * @returns `this`\n */\n remove() {\n removeEventListener('hashchange', this._onHashChange, false);\n this._map.off('moveend', this._updateHash);\n clearTimeout(this._updateHash());\n\n delete this._map;\n return this;\n }\n\n getHashString(mapFeedback?: boolean) {\n const center = this._map.getCenter(),\n zoom = Math.round(this._map.getZoom() * 100) / 100,\n // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px\n precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10),\n m = Math.pow(10, precision),\n lng = Math.round(center.lng * m) / m,\n lat = Math.round(center.lat * m) / m,\n bearing = this._map.getBearing(),\n pitch = this._map.getPitch();\n let hash = '';\n if (mapFeedback) {\n // new map feedback site has some constraints that don't allow\n // us to use the same hash format as we do for the Map hash option.\n hash += `/${lng}/${lat}/${zoom}`;\n } else {\n hash += `${zoom}/${lat}/${lng}`;\n }\n\n if (bearing || pitch) hash += (`/${Math.round(bearing * 10) / 10}`);\n if (pitch) hash += (`/${Math.round(pitch)}`);\n\n if (this._hashName) {\n const hashName = this._hashName;\n let found = false;\n const parts = window.location.hash.slice(1).split('&').map(part => {\n const key = part.split('=')[0];\n if (key === hashName) {\n found = true;\n return `${key}=${hash}`;\n }\n return part;\n }).filter(a => a);\n if (!found) {\n parts.push(`${hashName}=${hash}`);\n }\n return `#${parts.join('&')}`;\n }\n\n return `#${hash}`;\n }\n\n _getCurrentHash = () => {\n // Get the current hash from location, stripped from its number sign\n const hash = window.location.hash.replace('#', '');\n if (this._hashName) {\n // Split the parameter-styled hash into parts and find the value we need\n let keyval;\n hash.split('&').map(\n part => part.split('=')\n ).forEach(part => {\n if (part[0] === this._hashName) {\n keyval = part;\n }\n });\n return (keyval ? keyval[1] || '' : '').split('/');\n }\n return hash.split('/');\n };\n\n _onHashChange = () => {\n const loc = this._getCurrentHash();\n if (loc.length >= 3 && !loc.some(v => isNaN(v))) {\n const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this._map.getBearing();\n this._map.jumpTo({\n center: [+loc[2], +loc[1]],\n zoom: +loc[0],\n bearing,\n pitch: +(loc[4] || 0)\n });\n return true;\n }\n return false;\n };\n\n _updateHashUnthrottled = () => {\n // Replace if already present, else append the updated hash string\n const location = window.location.href.replace(/(#.+)?$/, this.getHashString());\n try {\n window.history.replaceState(window.history.state, null, location);\n } catch (SecurityError) {\n // IE11 does not allow this if the page is within an iframe created\n // with iframe.contentWindow.document.write(...).\n // https://github.com/mapbox/mapbox-gl-js/issues/7410\n }\n };\n\n /**\n * Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.\n */\n _updateHash: () => ReturnType = throttle(this._updateHashUnthrottled, 30 * 1000 / 100);\n}\n","import {browser} from '../util/browser';\nimport type {Map} from './map';\nimport {bezier, clamp, extend} from '../util/util';\nimport Point from '@mapbox/point-geometry';\nimport type {DragPanOptions} from './handler/shim/drag_pan';\n\nconst defaultInertiaOptions = {\n linearity: 0.3,\n easing: bezier(0, 0, 0.3, 1),\n};\n\nconst defaultPanInertiaOptions = extend({\n deceleration: 2500,\n maxSpeed: 1400\n}, defaultInertiaOptions);\n\nconst defaultZoomInertiaOptions = extend({\n deceleration: 20,\n maxSpeed: 1400\n}, defaultInertiaOptions);\n\nconst defaultBearingInertiaOptions = extend({\n deceleration: 1000,\n maxSpeed: 360\n}, defaultInertiaOptions);\n\nconst defaultPitchInertiaOptions = extend({\n deceleration: 1000,\n maxSpeed: 90\n}, defaultInertiaOptions);\n\nexport type InertiaOptions = {\n linearity: number;\n easing: (t: number) => number;\n deceleration: number;\n maxSpeed: number;\n};\n\nexport type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;\n\nexport class HandlerInertia {\n _map: Map;\n _inertiaBuffer: Array<{\n time: number;\n settings: any;\n }>;\n\n constructor(map: Map) {\n this._map = map;\n this.clear();\n }\n\n clear() {\n this._inertiaBuffer = [];\n }\n\n record(settings: any) {\n this._drainInertiaBuffer();\n this._inertiaBuffer.push({time: browser.now(), settings});\n }\n\n _drainInertiaBuffer() {\n const inertia = this._inertiaBuffer,\n now = browser.now(),\n cutoff = 160; //msec\n\n while (inertia.length > 0 && now - inertia[0].time > cutoff)\n inertia.shift();\n }\n\n _onMoveEnd(panInertiaOptions?: DragPanOptions | boolean) {\n this._drainInertiaBuffer();\n if (this._inertiaBuffer.length < 2) {\n return;\n }\n\n const deltas = {\n zoom: 0,\n bearing: 0,\n pitch: 0,\n pan: new Point(0, 0),\n pinchAround: undefined,\n around: undefined\n };\n\n for (const {settings} of this._inertiaBuffer) {\n deltas.zoom += settings.zoomDelta || 0;\n deltas.bearing += settings.bearingDelta || 0;\n deltas.pitch += settings.pitchDelta || 0;\n if (settings.panDelta) deltas.pan._add(settings.panDelta);\n if (settings.around) deltas.around = settings.around;\n if (settings.pinchAround) deltas.pinchAround = settings.pinchAround;\n }\n\n const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1];\n const duration = (lastEntry.time - this._inertiaBuffer[0].time);\n\n const easeOptions = {} as any;\n\n if (deltas.pan.mag()) {\n const result = calculateEasing(deltas.pan.mag(), duration, extend({}, defaultPanInertiaOptions, panInertiaOptions || {}));\n easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());\n easeOptions.center = this._map.transform.center;\n extendDuration(easeOptions, result);\n }\n\n if (deltas.zoom) {\n const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);\n easeOptions.zoom = this._map.transform.zoom + result.amount;\n extendDuration(easeOptions, result);\n }\n\n if (deltas.bearing) {\n const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);\n easeOptions.bearing = this._map.transform.bearing + clamp(result.amount, -179, 179);\n extendDuration(easeOptions, result);\n }\n\n if (deltas.pitch) {\n const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);\n easeOptions.pitch = this._map.transform.pitch + result.amount;\n extendDuration(easeOptions, result);\n }\n\n if (easeOptions.zoom || easeOptions.bearing) {\n const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;\n easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter();\n }\n\n this.clear();\n return extend(easeOptions, {\n noMoveStart: true\n });\n\n }\n}\n\n// Unfortunately zoom, bearing, etc can't have different durations and easings so\n// we need to choose one. We use the longest duration and it's corresponding easing.\nfunction extendDuration(easeOptions, result) {\n if (!easeOptions.duration || easeOptions.duration < result.duration) {\n easeOptions.duration = result.duration;\n easeOptions.easing = result.easing;\n }\n}\n\nfunction calculateEasing(amount, inertiaDuration: number, inertiaOptions) {\n const {maxSpeed, linearity, deceleration} = inertiaOptions;\n const speed = clamp(\n amount * linearity / (inertiaDuration / 1000),\n -maxSpeed,\n maxSpeed);\n const duration = Math.abs(speed) / (deceleration * linearity);\n return {\n easing: inertiaOptions.easing,\n duration: duration * 1000,\n amount: speed * (duration / 2)\n };\n}\n","import {Event} from '../util/evented';\n\nimport {DOM} from '../util/dom';\nimport Point from '@mapbox/point-geometry';\nimport {extend} from '../util/util';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\n\nimport type {Map} from './map';\nimport type {LngLat} from '../geo/lng_lat';\nimport {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * An event from the mouse relevant to a specific layer.\n *\n * @group Event Related\n */\nexport type MapLayerMouseEvent = MapMouseEvent & { features?: MapGeoJSONFeature[] };\n\n/**\n * An event from a touch device relevat to a specific layer.\n *\n * @group Event Related\n */\nexport type MapLayerTouchEvent = MapTouchEvent & { features?: MapGeoJSONFeature[] };\n\n/**\n * The source event data type\n */\nexport type MapSourceDataType = 'content' | 'metadata' | 'visibility' | 'idle';\n\n/**\n * `MapLayerEventType` - a mapping between the event name and the event.\n * **Note:** These events are compatible with the optional `layerId` parameter.\n * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the\n * event action contains a visible portion of the specified layer.\n * The following example can be used for all the events.\n *\n * @group Event Related\n * @example\n * ```ts\n * // Initialize the map\n * let map = new maplibregl.Map({ // map options });\n * // Set an event listener for a specific layer\n * map.on('the-event-name', 'poi-label', function(e) {\n * console.log('An event has occurred on a visible portion of the poi-label layer');\n * });\n * ```\n */\nexport type MapLayerEventType = {\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released contains a visible portion of the specified layer.\n *\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n click: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released twice contains a visible portion of the specified layer.\n *\n * **Note:** Under normal conditions, this event will be preceded by two `click` events.\n */\n dblclick: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed while inside a visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mousedown: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is released while inside a visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mouseup: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved while the cursor is inside a visible portion of the specified layer.\n * As you move the cursor across the layer, the event will fire every time the cursor changes position within that layer.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mousemove: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from\n * outside that layer or outside the map canvas.\n *\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n */\n mouseenter: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves\n * the map canvas.\n *\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n */\n mouseleave: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved inside a visible portion of the specified layer.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mouseover: MapLayerMouseEvent;\n /**\n * Fired when a point device (usually a mouse) leaves the visible portion of the specified layer.\n */\n mouseout: MapLayerMouseEvent;\n /**\n * Fired when the right button of the mouse is clicked or the context menu key is pressed within visible portion of the specified layer.\n */\n contextmenu: MapLayerMouseEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchstart: MapLayerTouchEvent;\n /**\n * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchend: MapLayerTouchEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchcancel: MapLayerTouchEvent;\n};\n\n/**\n * `MapEventType` - a mapping between the event name and the event value.\n * These events are used with the {@link Map#on} method.\n * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}.\n * The following example can be used for all the events.\n *\n * @group Event Related\n * @example\n * ```ts\n * // Initialize the map\n * let map = new maplibregl.Map({ // map options });\n * // Set an event listener\n * map.on('the-event-name', () => {\n * console.log('An event has occurred!');\n * });\n * ```\n */\nexport type MapEventType = {\n /**\n * Fired when an error occurs. This is GL JS's primary error reporting\n * mechanism. We use an event instead of `throw` to better accommodate\n * asynchronous operations. If no listeners are bound to the `error` event, the\n * error will be printed to the console.\n */\n error: ErrorEvent;\n /**\n * @event `load` Fired immediately after all necessary resources have been downloaded\n * and the first visually complete rendering of the map has occurred.\n *\n * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)\n * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)\n */\n load: MapLibreEvent;\n /**\n * Fired after the last frame rendered before the map enters an\n * \"idle\" state:\n *\n * - No camera transitions are in progress\n * - All currently requested tiles have loaded\n * - All fade/transition animations have completed\n */\n idle: MapLibreEvent;\n /**\n * Fired immediately after the map has been removed with {@link Map#remove}.\n */\n remove: MapLibreEvent;\n /**\n * Fired whenever the map is drawn to the screen, as the result of\n *\n * - a change to the map's position, zoom, pitch, or bearing\n * - a change to the map's style\n * - a change to a GeoJSON source\n * - the loading of a vector tile, GeoJSON file, glyph, or sprite\n */\n render: MapLibreEvent;\n /**\n * Fired immediately after the map has been resized.\n */\n resize: MapLibreEvent;\n /**\n * Fired when the WebGL context is lost.\n */\n webglcontextlost: MapContextEvent;\n /**\n * Fired when the WebGL context is restored.\n */\n webglcontextrestored: MapContextEvent;\n /**\n * Fired when any map data (style, source, tile, etc) begins loading or\n * changing asynchronously. All `dataloading` events are followed by a `data`,\n * `dataabort` or `error` event.\n */\n dataloading: MapDataEvent;\n /**\n * Fired when any map data loads or changes. See {@link MapDataEvent} for more information.\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n data: MapDataEvent;\n tiledataloading: MapDataEvent;\n /**\n * Fired when one of the map's sources begins loading or changing asynchronously.\n * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event.\n */\n sourcedataloading: MapSourceDataEvent;\n /**\n * Fired when the map's style begins loading or changing asynchronously.\n * All `styledataloading` events are followed by a `styledata`\n * or `error` event.\n */\n styledataloading: MapStyleDataEvent;\n /**\n * Fired when one of the map's sources loads or changes, including if a tile belonging\n * to a source loads or changes.\n */\n sourcedata: MapSourceDataEvent;\n /**\n * Fired when the map's style loads or changes.\n */\n styledata: MapStyleDataEvent;\n /**\n * Fired when an icon or pattern needed by the style is missing. The missing image can\n * be added with {@link Map#addImage} within this event listener callback to prevent the image from\n * being skipped. This event can be used to dynamically generate icons and patterns.\n * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n */\n styleimagemissing: MapStyleImageMissingEvent;\n /**\n * Fired when a request for one of the map's sources' tiles or data is aborted.\n */\n dataabort: MapDataEvent;\n /**\n * Fired when a request for one of the map's sources' data is aborted.\n */\n sourcedataabort: MapSourceDataEvent;\n /**\n * Fired when the user cancels a \"box zoom\" interaction, or when the bounding box does not meet the minimum size threshold.\n * See {@link BoxZoomHandler}.\n */\n boxzoomcancel: MapLibreZoomEvent;\n /**\n * Fired when a \"box zoom\" interaction starts. See {@link BoxZoomHandler}.\n */\n boxzoomstart: MapLibreZoomEvent;\n /**\n * Fired when a \"box zoom\" interaction ends. See {@link BoxZoomHandler}.\n */\n boxzoomend: MapLibreZoomEvent;\n /**\n * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.\n */\n touchcancel: MapTouchEvent;\n /**\n * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchmove: MapTouchEvent;\n /**\n * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchend: MapTouchEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchstart: MapTouchEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.\n *\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n click: MapMouseEvent;\n /**\n * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.\n */\n contextmenu: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession.\n *\n * **Note:** Under normal conditions, this event will be preceded by two `click` events.\n */\n dblclick: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map.\n * As you move the cursor across the map, the event will fire every time the cursor changes position within the map.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mousemove: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is released within the map.\n *\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mouseup: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed within the map.\n *\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mousedown: MapMouseEvent;\n /**\n * Fired when a point device (usually a mouse) leaves the map's canvas.\n */\n mouseout: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved within the map.\n * As you move the cursor across a web page containing a map,\n * the event will fire each time it enters the map or any child elements.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mouseover: MapMouseEvent;\n /**\n * Fired just before the map begins a transition from one\n * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.\n *\n */\n movestart: MapLibreEvent;\n /**\n * Fired repeatedly during an animated transition from one view to\n * another, as the result of either user interaction or methods such as {@link Map#flyTo}.\n *\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n move: MapLibreEvent;\n /**\n * Fired just after the map completes a transition from one\n * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.\n *\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n moveend: MapLibreEvent;\n /**\n * Fired just before the map begins a transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoomstart: MapLibreEvent;\n /**\n * Fired repeatedly during an animated transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoom: MapLibreEvent;\n /**\n * Fired just after the map completes a transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoomend: MapLibreEvent;\n /**\n * Fired when a \"drag to rotate\" interaction starts. See {@link DragRotateHandler}.\n */\n rotatestart: MapLibreEvent;\n /**\n * Fired repeatedly during a \"drag to rotate\" interaction. See {@link DragRotateHandler}.\n */\n rotate: MapLibreEvent;\n /**\n * Fired when a \"drag to rotate\" interaction ends. See {@link DragRotateHandler}.\n */\n rotateend: MapLibreEvent;\n /**\n * Fired when a \"drag to pan\" interaction starts. See {@link DragPanHandler}.\n */\n dragstart: MapLibreEvent;\n /**\n * Fired repeatedly during a \"drag to pan\" interaction. See {@link DragPanHandler}.\n */\n drag: MapLibreEvent;\n /**\n * Fired when a \"drag to pan\" interaction ends. See {@link DragPanHandler}.\n * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n dragend: MapLibreEvent;\n /**\n * Fired whenever the map's pitch (tilt) begins a change as\n * the result of either user interaction or methods such as {@link Map#flyTo} .\n */\n pitchstart: MapLibreEvent;\n /**\n * Fired repeatedly during the map's pitch (tilt) animation between\n * one state and another as the result of either user interaction\n * or methods such as {@link Map#flyTo}.\n */\n pitch: MapLibreEvent;\n /**\n * Fired immediately after the map's pitch (tilt) finishes changing as\n * the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n pitchend: MapLibreEvent;\n /**\n * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.\n */\n wheel: MapWheelEvent;\n /**\n * Fired when terrain is changed\n */\n terrain: MapTerrainEvent;\n};\n\n/**\n * The base event for MapLibre\n *\n * @group Event Related\n */\nexport type MapLibreEvent = {\n type: keyof MapEventType | keyof MapLayerEventType;\n target: Map;\n originalEvent: TOrig;\n}\n\n/**\n * The style data event\n *\n * @group Event Related\n */\nexport type MapStyleDataEvent = MapLibreEvent & {\n dataType: 'style';\n}\n\n/**\n * The source data event interface\n *\n * @group Event Related\n */\nexport type MapSourceDataEvent = MapLibreEvent & {\n dataType: 'source';\n /**\n * True if the event has a `dataType` of `source` and the source has no outstanding network requests.\n */\n isSourceLoaded: boolean;\n /**\n * The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`.\n */\n source: SourceSpecification;\n sourceId: string;\n sourceDataType: MapSourceDataType;\n /**\n * The tile being loaded or changed, if the event has a `dataType` of `source` and\n * the event is related to loading of a tile.\n */\n tile: any;\n}\n/**\n * `MapMouseEvent` is the event type for mouse-related map events.\n * @example\n * ```ts\n * // The `click` event is an example of a `MapMouseEvent`.\n * // Set up an event listener on the map.\n * map.on('click', function(e) {\n * // The event object (e) contains information like the\n * // coordinates of the point on the map that was clicked.\n * console.log('A click event has occurred at ' + e.lngLat);\n * });\n * ```\n */\nexport class MapMouseEvent extends Event implements MapLibreEvent {\n /**\n * The event type\n */\n type: 'mousedown' | 'mouseup' | 'click' | 'dblclick' | 'mousemove' | 'mouseover' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'contextmenu';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: MouseEvent;\n\n /**\n * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.\n */\n point: Point;\n\n /**\n * The geographic location on the map of the mouse cursor.\n */\n lngLat: LngLat;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the following default map behaviors:\n *\n * * On `mousedown` events, the behavior of {@link DragPanHandler}\n * * On `mousedown` events, the behavior of {@link DragRotateHandler}\n * * On `mousedown` events, the behavior of {@link BoxZoomHandler}\n * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}\n *\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n constructor(type: string, map: Map, originalEvent: MouseEvent, data: any = {}) {\n const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);\n const lngLat = map.unproject(point);\n super(type, extend({point, lngLat, originalEvent}, data));\n this._defaultPrevented = false;\n this.target = map;\n }\n}\n\n/**\n * `MapTouchEvent` is the event type for touch-related map events.\n *\n * @group Event Related\n */\nexport class MapTouchEvent extends Event implements MapLibreEvent {\n /**\n * The event type.\n */\n type: 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: TouchEvent;\n\n /**\n * The geographic location on the map of the center of the touch event points.\n */\n lngLat: LngLat;\n\n /**\n * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left\n * corner.\n */\n point: Point;\n\n /**\n * The array of pixel coordinates corresponding to a\n * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.\n */\n points: Array;\n\n /**\n * The geographical locations on the map corresponding to a\n * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.\n */\n lngLats: Array;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the following default map behaviors:\n *\n * * On `touchstart` events, the behavior of {@link DragPanHandler}\n * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler}\n *\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n constructor(type: string, map: Map, originalEvent: TouchEvent) {\n const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;\n const points = DOM.touchPos(map.getCanvasContainer(), touches);\n const lngLats = points.map((t) => map.unproject(t));\n const point = points.reduce((prev, curr, i, arr) => {\n return prev.add(curr.div(arr.length));\n }, new Point(0, 0));\n const lngLat = map.unproject(point);\n super(type, {points, point, lngLats, lngLat, originalEvent});\n this._defaultPrevented = false;\n }\n}\n\n/**\n * `MapWheelEvent` is the event type for the `wheel` map event.\n *\n * @group Event Related\n */\nexport class MapWheelEvent extends Event {\n /**\n * The event type.\n */\n type: 'wheel';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: WheelEvent;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the behavior of {@link ScrollZoomHandler}.\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n /** */\n constructor(type: string, map: Map, originalEvent: WheelEvent) {\n super(type, {originalEvent});\n this._defaultPrevented = false;\n }\n}\n\n/**\n * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.\n *\n * @group Event Related\n */\nexport type MapLibreZoomEvent = {\n /**\n * The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel`\n */\n type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel';\n /**\n * The `Map` instance that triggered the event\n */\n target: Map;\n /**\n * The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent`\n */\n originalEvent: MouseEvent;\n};\n\n/**\n * A `MapDataEvent` object is emitted with the `data`\n * and `dataloading` events. Possible values for\n * `dataType`s are:\n *\n * - `'source'`: The non-tile data associated with any source\n * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map\n *\n * Possible values for `sourceDataType`s are:\n *\n * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles\n * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource)\n * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible')\n * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading)\n *\n * @group Event Related\n *\n * @example\n * ```ts\n * // The sourcedata event is an example of MapDataEvent.\n * // Set up an event listener on the map.\n * map.on('sourcedata', function(e) {\n * if (e.isSourceLoaded) {\n * // Do something when the source has finished loading\n * }\n * });\n * ```\n */\nexport type MapDataEvent = {\n /**\n * The event type.\n */\n type: string;\n /**\n * The type of data that has changed. One of `'source'`, `'style'`.\n */\n dataType: string;\n /**\n * Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`.\n */\n sourceDataType: MapSourceDataType;\n};\n\n/**\n * The terrain event\n *\n * @group Event Related\n */\nexport type MapTerrainEvent = {\n type: 'terrain';\n};\n\n/**\n * An event related to the web gl context\n *\n * @group Event Related\n */\nexport type MapContextEvent = {\n type: 'webglcontextlost' | 'webglcontextrestored';\n originalEvent: WebGLContextEvent;\n};\n\n/**\n * The style image missing event\n *\n * @group Event Related\n *\n * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n */\nexport type MapStyleImageMissingEvent = MapLibreEvent & {\n type: 'styleimagemissing';\n id: string;\n}\n","import {MapMouseEvent, MapTouchEvent, MapWheelEvent} from '../events';\nimport {Handler} from '../handler_manager';\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\n\nexport class MapEventHandler implements Handler {\n\n _mousedownPos: Point;\n _clickTolerance: number;\n _map: Map;\n\n constructor(map: Map, options: {\n clickTolerance: number;\n }) {\n this._map = map;\n this._clickTolerance = options.clickTolerance;\n }\n\n reset() {\n delete this._mousedownPos;\n }\n\n wheel(e: WheelEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - ScrollZoom\n return this._firePreventable(new MapWheelEvent(e.type, this._map, e));\n }\n\n mousedown(e: MouseEvent, point: Point) {\n this._mousedownPos = point;\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - MousePan\n // - MouseRotate\n // - MousePitch\n // - DblclickHandler\n return this._firePreventable(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseup(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n click(e: MouseEvent, point: Point) {\n if (this._mousedownPos && this._mousedownPos.dist(point) >= this._clickTolerance) return;\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n dblclick(e: MouseEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - DblClickZoom\n return this._firePreventable(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseover(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseout(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n touchstart(e: TouchEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - TouchPan\n // - TouchZoom\n // - TouchRotate\n // - TouchPitch\n // - TapZoom\n // - SwipeZoom\n return this._firePreventable(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchmove(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchend(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchcancel(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n _firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent) {\n this._map.fire(mapEvent);\n if (mapEvent.defaultPrevented) {\n // returning an object marks the handler as active and resets other handlers\n return {};\n }\n }\n\n isEnabled() {\n return true;\n }\n\n isActive() {\n return false;\n }\n enable() {}\n disable() {}\n}\n\nexport class BlockableMapEventHandler {\n _map: Map;\n _delayContextMenu: boolean;\n _ignoreContextMenu: boolean;\n _contextMenuEvent: MouseEvent;\n\n constructor(map: Map) {\n this._map = map;\n }\n\n reset() {\n this._delayContextMenu = false;\n this._ignoreContextMenu = true;\n delete this._contextMenuEvent;\n }\n\n mousemove(e: MouseEvent) {\n // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n mousedown() {\n this._delayContextMenu = true;\n this._ignoreContextMenu = false;\n }\n\n mouseup() {\n this._delayContextMenu = false;\n if (this._contextMenuEvent) {\n this._map.fire(new MapMouseEvent('contextmenu', this._map, this._contextMenuEvent));\n delete this._contextMenuEvent;\n }\n }\n contextmenu(e: MouseEvent) {\n if (this._delayContextMenu) {\n // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake\n this._contextMenuEvent = e;\n } else if (!this._ignoreContextMenu) {\n // Windows: contextmenu fired on mouseup, so fire event now\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n // prevent browser context menu when necessary\n if (this._map.listens('contextmenu')) {\n e.preventDefault();\n }\n }\n\n isEnabled() {\n return true;\n }\n\n isActive() {\n return false;\n }\n enable() {}\n disable() {}\n}\n","import type {Map} from '../map';\nimport type {PointLike} from '../camera';\nimport type {Transform} from '../../geo/transform';\nimport Point from '@mapbox/point-geometry';\nimport {LngLat} from '../../geo/lng_lat';\n\n/**\n * @internal\n * Shared utilities for the Handler classes to access the correct camera state.\n * If Camera.transformCameraUpdate is specified, the \"desired state\" of camera may differ from the state used for rendering.\n * The handlers need the \"desired state\" to track accumulated changes.\n */\nexport class TransformProvider {\n _map: Map;\n\n constructor(map: Map) {\n this._map = map;\n }\n\n get transform(): Transform {\n return this._map._requestedCameraState || this._map.transform;\n }\n\n get center() {\n return {lng: this.transform.center.lng, lat: this.transform.center.lat};\n }\n\n get zoom() {\n return this.transform.zoom;\n }\n\n get pitch() {\n return this.transform.pitch;\n }\n\n get bearing() {\n return this.transform.bearing;\n }\n\n unproject(point: PointLike): LngLat {\n return this.transform.pointLocation(Point.convert(point), this._map.terrain);\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport {Event} from '../../util/evented';\nimport {TransformProvider} from './transform-provider';\n\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\nimport {Handler} from '../handler_manager';\n\n/**\n * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.\n * The bounding box is defined by clicking and holding `shift` while dragging the cursor.\n *\n * @group Handlers\n */\nexport class BoxZoomHandler implements Handler {\n _map: Map;\n _tr: TransformProvider;\n _el: HTMLElement;\n _container: HTMLElement;\n _enabled: boolean;\n _active: boolean;\n _startPos: Point;\n _lastPos: Point;\n _box: HTMLElement;\n _clickTolerance: number;\n\n /** @internal */\n constructor(map: Map, options: {\n clickTolerance: number;\n }) {\n this._map = map;\n this._tr = new TransformProvider(map);\n this._el = map.getCanvasContainer();\n this._container = map.getContainer();\n this._clickTolerance = options.clickTolerance || 1;\n }\n\n /**\n * Returns a Boolean indicating whether the \"box zoom\" interaction is enabled.\n *\n * @returns `true` if the \"box zoom\" interaction is enabled.\n */\n isEnabled() {\n return !!this._enabled;\n }\n\n /**\n * Returns a Boolean indicating whether the \"box zoom\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"box zoom\" interaction is active.\n */\n isActive() {\n return !!this._active;\n }\n\n /**\n * Enables the \"box zoom\" interaction.\n *\n * @example\n * ```ts\n * map.boxZoom.enable();\n * ```\n */\n enable() {\n if (this.isEnabled()) return;\n this._enabled = true;\n }\n\n /**\n * Disables the \"box zoom\" interaction.\n *\n * @example\n * ```ts\n * map.boxZoom.disable();\n * ```\n */\n disable() {\n if (!this.isEnabled()) return;\n this._enabled = false;\n }\n\n mousedown(e: MouseEvent, point: Point) {\n if (!this.isEnabled()) return;\n if (!(e.shiftKey && e.button === 0)) return;\n\n DOM.disableDrag();\n this._startPos = this._lastPos = point;\n this._active = true;\n }\n\n mousemoveWindow(e: MouseEvent, point: Point) {\n if (!this._active) return;\n\n const pos = point;\n\n if (this._lastPos.equals(pos) || (!this._box && pos.dist(this._startPos) < this._clickTolerance)) {\n return;\n }\n\n const p0 = this._startPos;\n this._lastPos = pos;\n\n if (!this._box) {\n this._box = DOM.create('div', 'maplibregl-boxzoom', this._container);\n this._container.classList.add('maplibregl-crosshair');\n this._fireEvent('boxzoomstart', e);\n }\n\n const minX = Math.min(p0.x, pos.x),\n maxX = Math.max(p0.x, pos.x),\n minY = Math.min(p0.y, pos.y),\n maxY = Math.max(p0.y, pos.y);\n\n DOM.setTransform(this._box, `translate(${minX}px,${minY}px)`);\n\n this._box.style.width = `${maxX - minX}px`;\n this._box.style.height = `${maxY - minY}px`;\n }\n\n mouseupWindow(e: MouseEvent, point: Point) {\n if (!this._active) return;\n\n if (e.button !== 0) return;\n\n const p0 = this._startPos,\n p1 = point;\n\n this.reset();\n\n DOM.suppressClick();\n\n if (p0.x === p1.x && p0.y === p1.y) {\n this._fireEvent('boxzoomcancel', e);\n } else {\n this._map.fire(new Event('boxzoomend', {originalEvent: e}));\n return {\n cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this._tr.bearing, {linear: true})\n };\n }\n }\n\n keydown(e: KeyboardEvent) {\n if (!this._active) return;\n\n if (e.keyCode === 27) {\n this.reset();\n this._fireEvent('boxzoomcancel', e);\n }\n }\n\n reset() {\n this._active = false;\n\n this._container.classList.remove('maplibregl-crosshair');\n\n if (this._box) {\n DOM.remove(this._box);\n this._box = null;\n }\n\n DOM.enableDrag();\n\n delete this._startPos;\n delete this._lastPos;\n }\n\n _fireEvent(type: string, e: any) {\n return this._map.fire(new Event(type, {originalEvent: e}));\n }\n}\n","import Point from '@mapbox/point-geometry';\n\nexport function indexTouches(touches: Array, points: Array) {\n if (touches.length !== points.length) throw new Error(`The number of touches and points are not equal - touches ${touches.length}, points ${points.length}`);\n const obj = {};\n for (let i = 0; i < touches.length; i++) {\n obj[touches[i].identifier] = points[i];\n }\n return obj;\n}\n","import Point from '@mapbox/point-geometry';\nimport {indexTouches} from './handler_util';\n\nfunction getCentroid(points: Array) {\n const sum = new Point(0, 0);\n for (const point of points) {\n sum._add(point);\n }\n return sum.div(points.length);\n}\n\nexport const MAX_TAP_INTERVAL = 500;\nconst MAX_TOUCH_TIME = 500;\nexport const MAX_DIST = 30;\n\nexport class SingleTapRecognizer {\n\n numTouches: number;\n centroid: Point;\n startTime: number;\n aborted: boolean;\n touches: {\n [k in number | string]: Point;\n };\n\n constructor(options: {\n numTouches: number;\n }) {\n this.reset();\n this.numTouches = options.numTouches;\n }\n\n reset() {\n delete this.centroid;\n delete this.startTime;\n delete this.touches;\n this.aborted = false;\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n\n if (this.centroid || mapTouches.length > this.numTouches) {\n this.aborted = true;\n }\n if (this.aborted) {\n return;\n }\n\n if (this.startTime === undefined) {\n this.startTime = e.timeStamp;\n }\n\n if (mapTouches.length === this.numTouches) {\n this.centroid = getCentroid(points);\n this.touches = indexTouches(mapTouches, points);\n }\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this.aborted || !this.centroid) return;\n\n const newTouches = indexTouches(mapTouches, points);\n for (const id in this.touches) {\n const prevPos = this.touches[id];\n const pos = newTouches[id];\n if (!pos || pos.dist(prevPos) > MAX_DIST) {\n this.aborted = true;\n }\n }\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {\n this.aborted = true;\n }\n\n if (mapTouches.length === 0) {\n const centroid = !this.aborted && this.centroid;\n this.reset();\n if (centroid) return centroid;\n }\n }\n\n}\n\nexport class TapRecognizer {\n\n singleTap: SingleTapRecognizer;\n numTaps: number;\n lastTime: number;\n lastTap: Point;\n count: number;\n\n constructor(options: {\n numTaps: number;\n numTouches: number;\n }) {\n this.singleTap = new SingleTapRecognizer(options);\n this.numTaps = options.numTaps;\n this.reset();\n }\n\n reset() {\n this.lastTime = Infinity;\n delete this.lastTap;\n this.count = 0;\n this.singleTap.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n this.singleTap.touchstart(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n this.singleTap.touchmove(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n const tap = this.singleTap.touchend(e, points, mapTouches);\n if (tap) {\n const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;\n const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;\n\n if (!soonEnough || !closeEnough) {\n this.reset();\n }\n\n this.count++;\n this.lastTime = e.timeStamp;\n this.lastTap = tap;\n\n if (this.count === this.numTaps) {\n this.reset();\n return tap;\n }\n }\n }\n}\n","import {TapRecognizer} from './tap_recognizer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\nimport {Handler} from '../handler_manager';\n\nexport class TapZoomHandler implements Handler {\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n _zoomIn: TapRecognizer;\n _zoomOut: TapRecognizer;\n\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n this._zoomIn = new TapRecognizer({\n numTouches: 1,\n numTaps: 2\n });\n\n this._zoomOut = new TapRecognizer({\n numTouches: 2,\n numTaps: 1\n });\n\n this.reset();\n }\n\n reset() {\n this._active = false;\n this._zoomIn.reset();\n this._zoomOut.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n this._zoomIn.touchstart(e, points, mapTouches);\n this._zoomOut.touchstart(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n this._zoomIn.touchmove(e, points, mapTouches);\n this._zoomOut.touchmove(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches);\n const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches);\n const tr = this._tr;\n\n if (zoomInPoint) {\n this._active = true;\n e.preventDefault();\n setTimeout(() => this.reset(), 0);\n return {\n cameraAnimation: (map: Map) => map.easeTo({\n duration: 300,\n zoom: tr.zoom + 1,\n around: tr.unproject(zoomInPoint)\n }, {originalEvent: e})\n };\n } else if (zoomOutPoint) {\n this._active = true;\n e.preventDefault();\n setTimeout(() => this.reset(), 0);\n return {\n cameraAnimation: (map: Map) => map.easeTo({\n duration: 300,\n zoom: tr.zoom - 1,\n around: tr.unproject(zoomOutPoint)\n }, {originalEvent: e})\n };\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import {DOM} from '../../util/dom';\nimport type Point from '@mapbox/point-geometry';\nimport {DragMoveStateManager} from './drag_move_state_manager';\nimport {Handler} from '../handler_manager';\n\ninterface DragMovementResult {\n bearingDelta?: number;\n pitchDelta?: number;\n around?: Point;\n panDelta?: Point;\n}\n\nexport interface DragPanResult extends DragMovementResult {\n around: Point;\n panDelta: Point;\n}\n\nexport interface DragRotateResult extends DragMovementResult {\n bearingDelta: number;\n}\n\nexport interface DragPitchResult extends DragMovementResult {\n pitchDelta: number;\n}\n\ntype DragMoveFunction = (lastPoint: Point, point: Point) => T;\n\nexport interface DragMoveHandler extends Handler {\n dragStart: (e: E, point: Point) => void;\n dragMove: (e: E, point: Point) => T | void;\n dragEnd: (e: E) => void;\n getClickTolerance: () => number;\n}\n\nexport type DragMoveHandlerOptions = {\n /**\n * If the movement is shorter than this value, consider it a click.\n */\n clickTolerance: number;\n /**\n * The move function to run on a valid movement.\n */\n move: DragMoveFunction;\n /**\n * A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details.\n */\n moveStateManager: DragMoveStateManager;\n /**\n * A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler\n * @param handler - the handler\n */\n assignEvents: (handler: DragMoveHandler) => void;\n /**\n * Should the move start on the \"start\" event, or should it start on the first valid move.\n */\n activateOnStart?: boolean;\n /**\n * If true, handler will be enabled during construction\n */\n enable?: boolean;\n}\n\n/**\n * A generic class to create handlers for drag events, from both mouse and touch events.\n */\nexport class DragHandler implements DragMoveHandler {\n // Event handlers that may be assigned by the implementations of this class\n contextmenu?: Handler['contextmenu'];\n mousedown?: Handler['mousedown'];\n mousemoveWindow?: Handler['mousemoveWindow'];\n mouseup?: Handler['mouseup'];\n touchstart?: Handler['touchstart'];\n touchmoveWindow?: Handler['touchmoveWindow'];\n touchend?: Handler['touchend'];\n\n _clickTolerance: number;\n _moveFunction: DragMoveFunction;\n _activateOnStart: boolean;\n _active: boolean;\n _enabled: boolean;\n _moved: boolean;\n _lastPoint: Point | null;\n _moveStateManager: DragMoveStateManager;\n\n constructor(options: DragMoveHandlerOptions) {\n this._enabled = !!options.enable;\n this._moveStateManager = options.moveStateManager;\n this._clickTolerance = options.clickTolerance || 1;\n this._moveFunction = options.move;\n this._activateOnStart = !!options.activateOnStart;\n\n options.assignEvents(this);\n\n this.reset();\n }\n\n reset(e?: E) {\n this._active = false;\n this._moved = false;\n delete this._lastPoint;\n this._moveStateManager.endMove(e);\n }\n\n _move(...params: Parameters>) {\n const move = this._moveFunction(...params);\n if (move.bearingDelta || move.pitchDelta || move.around || move.panDelta) {\n this._active = true;\n return move;\n }\n }\n\n dragStart(e: E, point: Point);\n dragStart(e: E, point: Point[]);\n dragStart(e: E, point: Point | Point[]) {\n if (!this.isEnabled() || this._lastPoint) return;\n\n if (!this._moveStateManager.isValidStartEvent(e)) return;\n this._moveStateManager.startMove(e);\n\n this._lastPoint = point['length'] ? point[0] : point;\n\n if (this._activateOnStart && this._lastPoint) this._active = true;\n }\n\n dragMove(e: E, point: Point);\n dragMove(e: E, point: Point[]);\n dragMove(e: E, point: Point | Point[]) {\n if (!this.isEnabled()) return;\n const lastPoint = this._lastPoint;\n if (!lastPoint) return;\n e.preventDefault();\n\n if (!this._moveStateManager.isValidMoveEvent(e)) {\n this.reset(e);\n return;\n }\n\n const movePoint = point['length'] ? point[0] : point;\n\n if (!this._moved && movePoint.dist(lastPoint) < this._clickTolerance) return;\n this._moved = true;\n this._lastPoint = movePoint;\n\n return this._move(lastPoint, movePoint);\n }\n\n dragEnd(e: E) {\n if (!this.isEnabled() || !this._lastPoint) return;\n if (!this._moveStateManager.isValidEndEvent(e)) return;\n if (this._moved) DOM.suppressClick();\n this.reset(e);\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n\n getClickTolerance() {\n return this._clickTolerance;\n }\n}\n","import {DOM} from '../../util/dom';\n\nconst LEFT_BUTTON = 0;\nconst RIGHT_BUTTON = 2;\n\n// the values for each button in MouseEvent.buttons\nconst BUTTONS_FLAGS = {\n [LEFT_BUTTON]: 1,\n [RIGHT_BUTTON]: 2\n};\n\nfunction buttonNoLongerPressed(e: MouseEvent, button: number) {\n const flag = BUTTONS_FLAGS[button];\n return e.buttons === undefined || (e.buttons & flag) !== flag;\n}\n\n/*\n * Drag events are initiated by specific interaction which needs to be tracked until it ends.\n * This requires some state management:\n * 1. registering the initiating event,\n * 2. tracking that it was not canceled / not confusing it with another event firing.\n * 3. recognizing the ending event and cleaning up any internal state\n *\n * Concretely, we implement two state managers:\n * 1. MouseMoveStateManager\n * Receives a functions that is used to recognize mouse events that should be registered as the\n * relevant drag interactions - i.e. dragging with the right mouse button, or while CTRL is pressed.\n * 2. OneFingerTouchMoveStateManager\n * Checks if a drag event is using one finger, and continuously tracking that this is the same event\n * (i.e. to make sure not additional finger has started interacting with the screen before raising\n * the first finger).\n */\nexport interface DragMoveStateManager {\n startMove: (e: E) => void;\n endMove: (e?: E) => void;\n isValidStartEvent: (e: E) => boolean;\n isValidMoveEvent: (e: E) => boolean;\n isValidEndEvent: (e?: E) => boolean;\n}\n\nexport class MouseMoveStateManager implements DragMoveStateManager {\n _eventButton: number | undefined;\n _correctEvent: (e: MouseEvent) => boolean;\n\n constructor(options: {\n checkCorrectEvent: (e: MouseEvent) => boolean;\n }) {\n this._correctEvent = options.checkCorrectEvent;\n }\n\n startMove(e: MouseEvent) {\n const eventButton = DOM.mouseButton(e);\n this._eventButton = eventButton;\n }\n\n endMove(_e?: MouseEvent) {\n delete this._eventButton;\n }\n\n isValidStartEvent(e: MouseEvent) {\n return this._correctEvent(e);\n }\n\n isValidMoveEvent(e: MouseEvent) {\n // Some browsers don't fire a `mouseup` when the mouseup occurs outside\n // the window or iframe:\n // https://github.com/mapbox/mapbox-gl-js/issues/4622\n //\n // If the button is no longer pressed during this `mousemove` it may have\n // been released outside of the window or iframe.\n return !buttonNoLongerPressed(e, this._eventButton);\n }\n\n isValidEndEvent(e: MouseEvent) {\n const eventButton = DOM.mouseButton(e);\n return eventButton === this._eventButton;\n }\n}\n\nexport class OneFingerTouchMoveStateManager implements DragMoveStateManager {\n _firstTouch: number | undefined;\n\n constructor() {\n this._firstTouch = undefined;\n }\n\n _isOneFingerTouch(e: TouchEvent) {\n return e.targetTouches.length === 1;\n }\n\n _isSameTouchEvent(e: TouchEvent) {\n return e.targetTouches[0].identifier === this._firstTouch;\n }\n\n startMove(e: TouchEvent) {\n const firstTouch = e.targetTouches[0].identifier;\n this._firstTouch = firstTouch;\n }\n\n endMove(_e?: TouchEvent) {\n delete this._firstTouch;\n }\n\n isValidStartEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e);\n }\n\n isValidMoveEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);\n }\n\n isValidEndEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);\n }\n}\n","import type Point from '@mapbox/point-geometry';\n\nimport {DOM} from '../../util/dom';\nimport {DragMoveHandler, DragPanResult, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';\nimport {MouseMoveStateManager} from './drag_move_state_manager';\n\nexport interface MousePanHandler extends DragMoveHandler {}\nexport interface MouseRotateHandler extends DragMoveHandler {}\nexport interface MousePitchHandler extends DragMoveHandler {}\n\nconst LEFT_BUTTON = 0;\nconst RIGHT_BUTTON = 2;\n\nconst assignEvents = (handler: DragHandler) => {\n handler.mousedown = handler.dragStart;\n handler.mousemoveWindow = handler.dragMove;\n handler.mouseup = handler.dragEnd;\n handler.contextmenu = function(e: MouseEvent) {\n e.preventDefault();\n };\n};\n\nexport const generateMousePanHandler = ({enable, clickTolerance,}: {\n clickTolerance: number;\n enable?: boolean;\n}): MousePanHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent) => DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey,\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({around: point, panDelta: point.sub(lastPoint)}),\n activateOnStart: true,\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateMouseRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: {\n clickTolerance: number;\n bearingDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): MouseRotateHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent): boolean =>\n (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) ||\n (DOM.mouseButton(e) === RIGHT_BUTTON),\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}),\n // prevent browser context menu when necessary; we don't allow it with rotation\n // because we can't discern rotation gesture start from contextmenu on Mac\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateMousePitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: {\n clickTolerance: number;\n pitchDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): MousePitchHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent): boolean =>\n (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) ||\n (DOM.mouseButton(e) === RIGHT_BUTTON),\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}),\n // prevent browser context menu when necessary; we don't allow it with rotation\n // because we can't discern rotation gesture start from contextmenu on Mac\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n","import Point from '@mapbox/point-geometry';\nimport {indexTouches} from './handler_util';\nimport type {Map} from '../map';\nimport {GestureOptions} from '../map';\nimport {Handler} from '../handler_manager';\n\nexport class TouchPanHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _touches: {\n [k in string | number]: Point;\n };\n _minTouches: number;\n _clickTolerance: number;\n _sum: Point;\n _map: Map;\n _cancelCooperativeMessage: boolean;\n\n constructor(options: {\n clickTolerance: number;\n cooperativeGestures: boolean | GestureOptions;\n }, map: Map) {\n this._minTouches = options.cooperativeGestures ? 2 : 1;\n this._clickTolerance = options.clickTolerance || 1;\n this._map = map;\n this.reset();\n }\n\n reset() {\n this._active = false;\n this._touches = {};\n this._sum = new Point(0, 0);\n\n // Put a delay on the cooperative gesture message so it's less twitchy\n setTimeout(() => {\n this._cancelCooperativeMessage = false;\n }, 200);\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n return this._calculateTransform(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this._map._cooperativeGestures) {\n if (this._minTouches === 2 && mapTouches.length < 2 && !this._cancelCooperativeMessage) {\n // If coop gesture enabled, show panning info to user\n this._map._onCooperativeGesture(e, false, mapTouches.length);\n } else if (!this._cancelCooperativeMessage) {\n // If user is successfully navigating, we don't need this warning until the touch resets\n this._cancelCooperativeMessage = true;\n }\n }\n if (!this._active || mapTouches.length < this._minTouches) return;\n e.preventDefault();\n return this._calculateTransform(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n this._calculateTransform(e, points, mapTouches);\n\n if (this._active && mapTouches.length < this._minTouches) {\n this.reset();\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n _calculateTransform(e: TouchEvent, points: Array, mapTouches: Array) {\n if (mapTouches.length > 0) this._active = true;\n\n const touches = indexTouches(mapTouches, points);\n\n const touchPointSum = new Point(0, 0);\n const touchDeltaSum = new Point(0, 0);\n let touchDeltaCount = 0;\n\n for (const identifier in touches) {\n const point = touches[identifier];\n const prevPoint = this._touches[identifier];\n if (prevPoint) {\n touchPointSum._add(point);\n touchDeltaSum._add(point.sub(prevPoint));\n touchDeltaCount++;\n touches[identifier] = point;\n }\n }\n\n this._touches = touches;\n\n if (touchDeltaCount < this._minTouches || !touchDeltaSum.mag()) return;\n\n const panDelta = touchDeltaSum.div(touchDeltaCount);\n this._sum._add(panDelta);\n if (this._sum.mag() < this._clickTolerance) return;\n\n const around = touchPointSum.div(touchDeltaCount);\n\n return {\n around,\n panDelta\n };\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {DOM} from '../../util/dom';\nimport type {Map} from '../map';\nimport {Handler} from '../handler_manager';\n\n/**\n * An options object sent to the enable function of some of the handlers\n */\nexport type AroundCenterOptions = {\n /**\n * If \"center\" is passed, map will zoom around the center of map\n */\n around: 'center';\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers\n *\n * @group Handlers\n */\nabstract class TwoFingersTouchHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _firstTwoTouches: [number, number];\n _vector: Point;\n _startVector: Point;\n _aroundCenter: boolean;\n\n /** @internal */\n constructor() {\n this.reset();\n }\n\n reset() {\n this._active = false;\n delete this._firstTwoTouches;\n }\n\n abstract _start(points: [Point, Point]);\n abstract _move(points: [Point, Point], pinchAround: Point, e: TouchEvent);\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n //log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);\n if (this._firstTwoTouches || mapTouches.length < 2) return;\n\n this._firstTwoTouches = [\n mapTouches[0].identifier,\n mapTouches[1].identifier\n ];\n\n // implemented by child classes\n this._start([points[0], points[1]]);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._firstTwoTouches) return;\n\n e.preventDefault();\n\n const [idA, idB] = this._firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (!a || !b) return;\n const pinchAround = this._aroundCenter ? null : a.add(b).div(2);\n\n // implemented by child classes\n return this._move([a, b], pinchAround, e);\n\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._firstTwoTouches) return;\n\n const [idA, idB] = this._firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (a && b) return;\n\n if (this._active) DOM.suppressClick();\n\n this.reset();\n }\n\n touchcancel() {\n this.reset();\n }\n\n /**\n * Enables the \"drag to pitch\" interaction.\n *\n * @example\n * ```ts\n * map.touchPitch.enable();\n * ```\n */\n enable(options?: AroundCenterOptions | boolean | null) {\n this._enabled = true;\n this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';\n }\n\n /**\n * Disables the \"drag to pitch\" interaction.\n *\n * @example\n * ```ts\n * map.touchPitch.disable();\n * ```\n */\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pitch\" interaction is enabled.\n *\n * @returns `true` if the \"drag to pitch\" interaction is enabled.\n */\n isEnabled() {\n return this._enabled;\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pitch\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to pitch\" interaction is active.\n */\n isActive() {\n return this._active;\n }\n}\n\nfunction getTouchById(mapTouches: Array, points: Array, identifier: number) {\n for (let i = 0; i < mapTouches.length; i++) {\n if (mapTouches[i].identifier === identifier) return points[i];\n }\n}\n\n/* ZOOM */\n\nconst ZOOM_THRESHOLD = 0.1;\n\nfunction getZoomDelta(distance, lastDistance) {\n return Math.log(distance / lastDistance) / Math.LN2;\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers\n *\n * @group Handlers\n */\nexport class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {\n\n _distance: number;\n _startDistance: number;\n\n reset() {\n super.reset();\n delete this._distance;\n delete this._startDistance;\n }\n\n _start(points: [Point, Point]) {\n this._startDistance = this._distance = points[0].dist(points[1]);\n }\n\n _move(points: [Point, Point], pinchAround: Point) {\n const lastDistance = this._distance;\n this._distance = points[0].dist(points[1]);\n if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) return;\n this._active = true;\n return {\n zoomDelta: getZoomDelta(this._distance, lastDistance),\n pinchAround\n };\n }\n}\n\n/* ROTATE */\n\nconst ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle\n\nfunction getBearingDelta(a, b) {\n return a.angleWith(b) * 180 / Math.PI;\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers\n *\n * @group Handlers\n */\nexport class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {\n _minDiameter: number;\n\n reset() {\n super.reset();\n delete this._minDiameter;\n delete this._startVector;\n delete this._vector;\n }\n\n _start(points: [Point, Point]) {\n this._startVector = this._vector = points[0].sub(points[1]);\n this._minDiameter = points[0].dist(points[1]);\n }\n\n _move(points: [Point, Point], pinchAround: Point) {\n const lastVector = this._vector;\n this._vector = points[0].sub(points[1]);\n\n if (!this._active && this._isBelowThreshold(this._vector)) return;\n this._active = true;\n\n return {\n bearingDelta: getBearingDelta(this._vector, lastVector),\n pinchAround\n };\n }\n\n _isBelowThreshold(vector: Point) {\n /*\n * The threshold before a rotation actually happens is configured in\n * pixels along the circumference of the circle formed by the two fingers.\n * This makes the threshold in degrees larger when the fingers are close\n * together and smaller when the fingers are far apart.\n *\n * Use the smallest diameter from the whole gesture to reduce sensitivity\n * when pinching in and out.\n */\n\n this._minDiameter = Math.min(this._minDiameter, vector.mag());\n const circumference = Math.PI * this._minDiameter;\n const threshold = ROTATION_THRESHOLD / circumference * 360;\n\n const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector);\n return Math.abs(bearingDeltaSinceStart) < threshold;\n }\n}\n\n/* PITCH */\n\nfunction isVertical(vector) {\n return Math.abs(vector.y) > Math.abs(vector.x);\n}\n\nconst ALLOWED_SINGLE_TOUCH_TIME = 100;\n\n/**\n * The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.\n *\n * @group Handlers\n */\nexport class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {\n\n _valid: boolean | void;\n _firstMove: number;\n _lastPoints: [Point, Point];\n _map: Map;\n _currentTouchCount: number;\n\n constructor(map: Map) {\n super();\n this._map = map;\n }\n\n reset() {\n super.reset();\n this._valid = undefined;\n delete this._firstMove;\n delete this._lastPoints;\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n super.touchstart(e, points, mapTouches);\n this._currentTouchCount = mapTouches.length;\n }\n\n _start(points: [Point, Point]) {\n this._lastPoints = points;\n if (isVertical(points[0].sub(points[1]))) {\n // fingers are more horizontal than vertical\n this._valid = false;\n\n }\n }\n\n _move(points: [Point, Point], center: Point, e: TouchEvent) {\n // If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register\n if (this._map._cooperativeGestures && this._currentTouchCount < 3) {\n return;\n }\n\n const vectorA = points[0].sub(this._lastPoints[0]);\n const vectorB = points[1].sub(this._lastPoints[1]);\n\n this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);\n if (!this._valid) return;\n\n this._lastPoints = points;\n this._active = true;\n const yDeltaAverage = (vectorA.y + vectorB.y) / 2;\n const degreesPerPixelMoved = -0.5;\n return {\n pitchDelta: yDeltaAverage * degreesPerPixelMoved\n };\n }\n\n gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number) {\n if (this._valid !== undefined) return this._valid;\n\n const threshold = 2;\n const movedA = vectorA.mag() >= threshold;\n const movedB = vectorB.mag() >= threshold;\n\n // neither finger has moved a meaningful amount, wait\n if (!movedA && !movedB) return;\n\n // One finger has moved and the other has not.\n // If enough time has passed, decide it is not a pitch.\n if (!movedA || !movedB) {\n if (this._firstMove === undefined) {\n this._firstMove = timeStamp;\n }\n\n if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) {\n // still waiting for a movement from the second finger\n return undefined;\n } else {\n return false;\n }\n }\n\n const isSameDirection = vectorA.y > 0 === vectorB.y > 0;\n return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;\n }\n}\n","import {Handler} from '../handler_manager';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\n\nconst defaultOptions = {\n panStep: 100,\n bearingStep: 15,\n pitchStep: 10\n};\n\n/**\n * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using\n * the following keyboard shortcuts:\n *\n * - `=` / `+`: Increase the zoom level by 1.\n * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.\n * - `-`: Decrease the zoom level by 1.\n * - `Shift--`: Decrease the zoom level by 2.\n * - Arrow keys: Pan by 100 pixels.\n * - `Shift+⇢`: Increase the rotation by 15 degrees.\n * - `Shift+⇠`: Decrease the rotation by 15 degrees.\n * - `Shift+⇡`: Increase the pitch by 10 degrees.\n * - `Shift+⇣`: Decrease the pitch by 10 degrees.\n *\n * @group Handlers\n */\nexport class KeyboardHandler implements Handler {\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n _panStep: number;\n _bearingStep: number;\n _pitchStep: number;\n _rotationDisabled: boolean;\n\n /** @internal */\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n const stepOptions = defaultOptions;\n this._panStep = stepOptions.panStep;\n this._bearingStep = stepOptions.bearingStep;\n this._pitchStep = stepOptions.pitchStep;\n this._rotationDisabled = false;\n }\n\n reset() {\n this._active = false;\n }\n\n keydown(e: KeyboardEvent) {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n\n let zoomDir = 0;\n let bearingDir = 0;\n let pitchDir = 0;\n let xDir = 0;\n let yDir = 0;\n\n switch (e.keyCode) {\n case 61:\n case 107:\n case 171:\n case 187:\n zoomDir = 1;\n break;\n\n case 189:\n case 109:\n case 173:\n zoomDir = -1;\n break;\n\n case 37:\n if (e.shiftKey) {\n bearingDir = -1;\n } else {\n e.preventDefault();\n xDir = -1;\n }\n break;\n\n case 39:\n if (e.shiftKey) {\n bearingDir = 1;\n } else {\n e.preventDefault();\n xDir = 1;\n }\n break;\n\n case 38:\n if (e.shiftKey) {\n pitchDir = 1;\n } else {\n e.preventDefault();\n yDir = -1;\n }\n break;\n\n case 40:\n if (e.shiftKey) {\n pitchDir = -1;\n } else {\n e.preventDefault();\n yDir = 1;\n }\n break;\n\n default:\n return;\n }\n\n if (this._rotationDisabled) {\n bearingDir = 0;\n pitchDir = 0;\n }\n\n return {\n cameraAnimation: (map: Map) => {\n const tr = this._tr;\n map.easeTo({\n duration: 300,\n easeId: 'keyboardHandler',\n easing: easeOut,\n\n zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom,\n bearing: tr.bearing + bearingDir * this._bearingStep,\n pitch: tr.pitch + pitchDir * this._pitchStep,\n offset: [-xDir * this._panStep, -yDir * this._panStep],\n center: tr.center\n }, {originalEvent: e});\n }\n };\n }\n\n /**\n * Enables the \"keyboard rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.enable();\n * ```\n */\n enable() {\n this._enabled = true;\n }\n\n /**\n * Disables the \"keyboard rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.disable();\n * ```\n */\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n /**\n * Returns a Boolean indicating whether the \"keyboard rotate and zoom\"\n * interaction is enabled.\n *\n * @returns `true` if the \"keyboard rotate and zoom\"\n * interaction is enabled.\n */\n isEnabled() {\n return this._enabled;\n }\n\n /**\n * Returns true if the handler is enabled and has detected the start of a\n * zoom/rotate gesture.\n *\n * @returns `true` if the handler is enabled and has detected the\n * start of a zoom/rotate gesture.\n */\n isActive() {\n return this._active;\n }\n\n /**\n * Disables the \"keyboard pan/rotate\" interaction, leaving the\n * \"keyboard zoom\" interaction enabled.\n *\n * @example\n * ```ts\n * map.keyboard.disableRotation();\n * ```\n */\n disableRotation() {\n this._rotationDisabled = true;\n }\n\n /**\n * Enables the \"keyboard pan/rotate\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.enable();\n * map.keyboard.enableRotation();\n * ```\n */\n enableRotation() {\n this._rotationDisabled = false;\n }\n}\n\nfunction easeOut(t: number) {\n return t * (2 - t);\n}\n","import {DOM} from '../../util/dom';\n\nimport {defaultEasing, bezier} from '../../util/util';\nimport {browser} from '../../util/browser';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {LngLat} from '../../geo/lng_lat';\nimport {TransformProvider} from './transform-provider';\n\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\nimport type {AroundCenterOptions} from './two_fingers_touch';\nimport {Handler} from '../handler_manager';\n\n// deltaY value for mouse scroll wheel identification\nconst wheelZoomDelta = 4.000244140625;\n\n// These magic numbers control the rate of zoom. Trackpad events fire at a greater\n// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick\nconst defaultZoomRate = 1 / 100;\nconst wheelZoomRate = 1 / 450;\n\n// upper bound on how much we scale the map in any single render frame; this\n// is used to limit zoom rate in the case of very fast scrolling\nconst maxScalePerFrame = 2;\n\n/**\n * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.\n *\n * @group Handlers\n */\nexport class ScrollZoomHandler implements Handler {\n _map: Map;\n _tr: TransformProvider;\n _el: HTMLElement;\n _enabled: boolean;\n _active: boolean;\n _zooming: boolean;\n _aroundCenter: boolean;\n _around: LngLat;\n _aroundPoint: Point;\n _type: 'wheel' | 'trackpad' | null;\n _lastValue: number;\n _timeout: ReturnType; // used for delayed-handling of a single wheel movement\n _finishTimeout: ReturnType; // used to delay final '{move,zoom}end' events\n\n _lastWheelEvent: any;\n _lastWheelEventTime: number;\n\n _startZoom: number;\n _targetZoom: number;\n _delta: number;\n _easing: ((a: number) => number);\n _prevEase: {\n start: number;\n duration: number;\n easing: (_: number) => number;\n };\n\n _frameId: boolean;\n _triggerRenderFrame: () => void;\n\n _defaultZoomRate: number;\n _wheelZoomRate: number;\n\n /** @internal */\n constructor(map: Map, triggerRenderFrame: () => void) {\n this._map = map;\n this._tr = new TransformProvider(map);\n this._el = map.getCanvasContainer();\n this._triggerRenderFrame = triggerRenderFrame;\n\n this._delta = 0;\n\n this._defaultZoomRate = defaultZoomRate;\n this._wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Set the zoom rate of a trackpad\n * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value.\n * @example\n * Speed up trackpad zoom\n * ```ts\n * map.scrollZoom.setZoomRate(1/25);\n * ```\n */\n setZoomRate(zoomRate: number) {\n this._defaultZoomRate = zoomRate;\n }\n\n /**\n * Set the zoom rate of a mouse wheel\n * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value.\n * @example\n * Slow down zoom of mouse wheel\n * ```ts\n * map.scrollZoom.setWheelZoomRate(1/600);\n * ```\n */\n setWheelZoomRate(wheelZoomRate: number) {\n this._wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Returns a Boolean indicating whether the \"scroll to zoom\" interaction is enabled.\n * @returns `true` if the \"scroll to zoom\" interaction is enabled.\n */\n isEnabled() {\n return !!this._enabled;\n }\n\n /*\n * Active state is turned on and off with every scroll wheel event and is set back to false before the map\n * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in\n * progress.\n */\n isActive() {\n return !!this._active || this._finishTimeout !== undefined;\n }\n\n isZooming() {\n return !!this._zooming;\n }\n\n /**\n * Enables the \"scroll to zoom\" interaction.\n *\n * @param options - Options object.\n * @example\n * ```ts\n * map.scrollZoom.enable();\n * map.scrollZoom.enable({ around: 'center' })\n * ```\n */\n enable(options?: AroundCenterOptions | boolean) {\n if (this.isEnabled()) return;\n this._enabled = true;\n this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';\n }\n\n /**\n * Disables the \"scroll to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.scrollZoom.disable();\n * ```\n */\n disable() {\n if (!this.isEnabled()) return;\n this._enabled = false;\n }\n\n wheel(e: WheelEvent) {\n if (!this.isEnabled()) return;\n if (this._map._cooperativeGestures) {\n if (e[this._map._metaKey]) {\n e.preventDefault();\n } else {\n return;\n }\n }\n let value = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;\n const now = browser.now(),\n timeDelta = now - (this._lastWheelEventTime || 0);\n\n this._lastWheelEventTime = now;\n\n if (value !== 0 && (value % wheelZoomDelta) === 0) {\n // This one is definitely a mouse wheel event.\n this._type = 'wheel';\n\n } else if (value !== 0 && Math.abs(value) < 4) {\n // This one is definitely a trackpad event because it is so small.\n this._type = 'trackpad';\n\n } else if (timeDelta > 400) {\n // This is likely a new scroll action.\n this._type = null;\n this._lastValue = value;\n\n // Start a timeout in case this was a singular event, and dely it by up to 40ms.\n this._timeout = setTimeout(this._onTimeout, 40, e);\n\n } else if (!this._type) {\n // This is a repeating event, but we don't know the type of event just yet.\n // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.\n this._type = (Math.abs(timeDelta * value) < 200) ? 'trackpad' : 'wheel';\n\n // Make sure our delayed event isn't fired again, because we accumulate\n // the previous event (which was less than 40ms ago) into this event.\n if (this._timeout) {\n clearTimeout(this._timeout);\n this._timeout = null;\n value += this._lastValue;\n }\n }\n\n // Slow down zoom if shift key is held for more precise zooming\n if (e.shiftKey && value) value = value / 4;\n\n // Only fire the callback if we actually know what type of scrolling device the user uses.\n if (this._type) {\n this._lastWheelEvent = e;\n this._delta -= value;\n if (!this._active) {\n this._start(e);\n }\n }\n\n e.preventDefault();\n }\n\n _onTimeout = (initialEvent: MouseEvent) => {\n this._type = 'wheel';\n this._delta -= this._lastValue;\n if (!this._active) {\n this._start(initialEvent);\n }\n };\n\n _start(e: MouseEvent) {\n if (!this._delta) return;\n\n if (this._frameId) {\n this._frameId = null;\n }\n\n this._active = true;\n if (!this.isZooming()) {\n this._zooming = true;\n }\n\n if (this._finishTimeout) {\n clearTimeout(this._finishTimeout);\n delete this._finishTimeout;\n }\n\n const pos = DOM.mousePos(this._el, e);\n const tr = this._tr;\n\n this._around = LngLat.convert(this._aroundCenter ? tr.center : tr.unproject(pos));\n this._aroundPoint = tr.transform.locationPoint(this._around);\n if (!this._frameId) {\n this._frameId = true;\n this._triggerRenderFrame();\n }\n }\n\n renderFrame() {\n if (!this._frameId) return;\n this._frameId = null;\n\n if (!this.isActive()) return;\n const tr = this._tr.transform;\n\n // if we've had scroll events since the last render frame, consume the\n // accumulated delta, and update the target zoom level accordingly\n if (this._delta !== 0) {\n // For trackpad events and single mouse wheel ticks, use the default zoom rate\n const zoomRate = (this._type === 'wheel' && Math.abs(this._delta) > wheelZoomDelta) ? this._wheelZoomRate : this._defaultZoomRate;\n // Scale by sigmoid of scroll wheel delta.\n let scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate)));\n\n if (this._delta < 0 && scale !== 0) {\n scale = 1 / scale;\n }\n\n const fromScale = typeof this._targetZoom === 'number' ? tr.zoomScale(this._targetZoom) : tr.scale;\n this._targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)));\n\n // if this is a mouse wheel, refresh the starting zoom and easing\n // function we're using to smooth out the zooming between wheel\n // events\n if (this._type === 'wheel') {\n this._startZoom = tr.zoom;\n this._easing = this._smoothOutEasing(200);\n }\n\n this._delta = 0;\n }\n\n const targetZoom = typeof this._targetZoom === 'number' ?\n this._targetZoom : tr.zoom;\n const startZoom = this._startZoom;\n const easing = this._easing;\n\n let finished = false;\n let zoom;\n if (this._type === 'wheel' && startZoom && easing) {\n\n const t = Math.min((browser.now() - this._lastWheelEventTime) / 200, 1);\n const k = easing(t);\n zoom = interpolates.number(startZoom, targetZoom, k);\n if (t < 1) {\n if (!this._frameId) {\n this._frameId = true;\n }\n } else {\n finished = true;\n }\n } else {\n zoom = targetZoom;\n finished = true;\n }\n\n this._active = true;\n\n if (finished) {\n this._active = false;\n this._finishTimeout = setTimeout(() => {\n this._zooming = false;\n this._triggerRenderFrame();\n delete this._targetZoom;\n delete this._finishTimeout;\n }, 200);\n }\n\n return {\n noInertia: true,\n needsRenderFrame: !finished,\n zoomDelta: zoom - tr.zoom,\n around: this._aroundPoint,\n originalEvent: this._lastWheelEvent\n };\n }\n\n _smoothOutEasing(duration: number) {\n let easing = defaultEasing;\n\n if (this._prevEase) {\n const currentEase = this._prevEase;\n const t = (browser.now() - currentEase.start) / currentEase.duration;\n const speed = currentEase.easing(t + 0.01) - currentEase.easing(t);\n\n // Quick hack to make new bezier that is continuous with last\n const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;\n const y = Math.sqrt(0.27 * 0.27 - x * x);\n\n easing = bezier(x, y, 0.25, 1);\n }\n\n this._prevEase = {\n start: browser.now(),\n duration,\n easing\n };\n\n return easing;\n }\n\n reset() {\n this._active = false;\n this._zooming = false;\n delete this._targetZoom;\n if (this._finishTimeout) {\n clearTimeout(this._finishTimeout);\n delete this._finishTimeout;\n }\n }\n}\n","import type {ClickZoomHandler} from '../click_zoom';\nimport type {TapZoomHandler} from './../tap_zoom';\n\n/**\n * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by\n * double clicking or double tapping.\n *\n * @group Handlers\n */\nexport class DoubleClickZoomHandler {\n\n _clickZoom: ClickZoomHandler;\n _tapZoom: TapZoomHandler;\n\n /** @internal */\n constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler) {\n this._clickZoom = clickZoom;\n this._tapZoom = TapZoom;\n }\n\n /**\n * Enables the \"double click to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.doubleClickZoom.enable();\n * ```\n */\n enable() {\n this._clickZoom.enable();\n this._tapZoom.enable();\n }\n\n /**\n * Disables the \"double click to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.doubleClickZoom.disable();\n * ```\n */\n disable() {\n this._clickZoom.disable();\n this._tapZoom.disable();\n }\n\n /**\n * Returns a Boolean indicating whether the \"double click to zoom\" interaction is enabled.\n *\n * @returns `true` if the \"double click to zoom\" interaction is enabled.\n */\n isEnabled() {\n return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();\n }\n\n /**\n * Returns a Boolean indicating whether the \"double click to zoom\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"double click to zoom\" interaction is active.\n */\n isActive() {\n return this._clickZoom.isActive() || this._tapZoom.isActive();\n }\n}\n","import type Point from '@mapbox/point-geometry';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\nimport {Handler} from '../handler_manager';\n\n/**\n * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking\n * It is used by other handlers\n */\nexport class ClickZoomHandler implements Handler {\n\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n\n /** @internal */\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n this.reset();\n }\n\n reset() {\n this._active = false;\n }\n\n dblclick(e: MouseEvent, point: Point) {\n e.preventDefault();\n return {\n cameraAnimation: (map: Map) => {\n map.easeTo({\n duration: 300,\n zoom: this._tr.zoom + (e.shiftKey ? -1 : 1),\n around: this._tr.unproject(point)\n }, {originalEvent: e});\n }\n };\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import {Handler} from '../handler_manager';\nimport {TapRecognizer, MAX_TAP_INTERVAL, MAX_DIST} from './tap_recognizer';\nimport type Point from '@mapbox/point-geometry';\n\nexport class TapDragZoomHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _swipePoint: Point;\n _swipeTouch: number;\n _tapTime: number;\n _tapPoint: Point;\n _tap: TapRecognizer;\n\n constructor() {\n\n this._tap = new TapRecognizer({\n numTouches: 1,\n numTaps: 1\n });\n\n this.reset();\n }\n\n reset() {\n this._active = false;\n delete this._swipePoint;\n delete this._swipeTouch;\n delete this._tapTime;\n delete this._tapPoint;\n this._tap.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this._swipePoint) return;\n\n if (!this._tapTime) {\n this._tap.touchstart(e, points, mapTouches);\n } else {\n const swipePoint = points[0];\n\n const soonEnough = e.timeStamp - this._tapTime < MAX_TAP_INTERVAL;\n const closeEnough = this._tapPoint.dist(swipePoint) < MAX_DIST;\n\n if (!soonEnough || !closeEnough) {\n this.reset();\n } else if (mapTouches.length > 0) {\n this._swipePoint = swipePoint;\n this._swipeTouch = mapTouches[0].identifier;\n }\n }\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._tapTime) {\n this._tap.touchmove(e, points, mapTouches);\n } else if (this._swipePoint) {\n if (mapTouches[0].identifier !== this._swipeTouch) {\n return;\n }\n\n const newSwipePoint = points[0];\n const dist = newSwipePoint.y - this._swipePoint.y;\n this._swipePoint = newSwipePoint;\n\n e.preventDefault();\n this._active = true;\n\n return {\n zoomDelta: dist / 128\n };\n }\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._tapTime) {\n const point = this._tap.touchend(e, points, mapTouches);\n if (point) {\n this._tapTime = e.timeStamp;\n this._tapPoint = point;\n }\n } else if (this._swipePoint) {\n if (mapTouches.length === 0) {\n this.reset();\n }\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import type {MousePanHandler} from '../mouse';\nimport type {TouchPanHandler} from './../touch_pan';\n\n/**\n * A {@link DragPanHandler} options object\n */\nexport type DragPanOptions = {\n /**\n * factor used to scale the drag velocity\n * @defaultValue 0\n */\n linearity?: number;\n /**\n * easing function applled to `map.panTo` when applying the drag.\n * @param t - the easing function\n * @defaultValue bezier(0, 0, 0.3, 1)\n */\n easing?: (t: number) => number;\n /**\n * the maximum value of the drag velocity.\n * @defaultValue 1400\n */\n deceleration?: number;\n /**\n * the rate at which the speed reduces after the pan ends.\n * @defaultValue 2500\n */\n maxSpeed?: number;\n};\n\n/**\n * The `DragPanHandler` allows the user to pan the map by clicking and dragging\n * the cursor.\n *\n * @group Handlers\n */\nexport class DragPanHandler {\n\n _el: HTMLElement;\n _mousePan: MousePanHandler;\n _touchPan: TouchPanHandler;\n _inertiaOptions: DragPanOptions | boolean;\n\n /** @internal */\n constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler) {\n this._el = el;\n this._mousePan = mousePan;\n this._touchPan = touchPan;\n }\n\n /**\n * Enables the \"drag to pan\" interaction.\n *\n * @param options - Options object\n * @example\n * ```ts\n * map.dragPan.enable();\n * map.dragPan.enable({\n * linearity: 0.3,\n * easing: bezier(0, 0, 0.3, 1),\n * maxSpeed: 1400,\n * deceleration: 2500,\n * });\n * ```\n */\n enable(options?: DragPanOptions | boolean) {\n this._inertiaOptions = options || {};\n this._mousePan.enable();\n this._touchPan.enable();\n this._el.classList.add('maplibregl-touch-drag-pan');\n }\n\n /**\n * Disables the \"drag to pan\" interaction.\n *\n * @example\n * ```ts\n * map.dragPan.disable();\n * ```\n */\n disable() {\n this._mousePan.disable();\n this._touchPan.disable();\n this._el.classList.remove('maplibregl-touch-drag-pan');\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pan\" interaction is enabled.\n *\n * @returns `true` if the \"drag to pan\" interaction is enabled.\n */\n isEnabled() {\n return this._mousePan.isEnabled() && this._touchPan.isEnabled();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pan\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to pan\" interaction is active.\n */\n isActive() {\n return this._mousePan.isActive() || this._touchPan.isActive();\n }\n}\n","import type {MousePitchHandler, MouseRotateHandler} from '../mouse';\n\nexport type DragRotateHandlerOptions = {\n /**\n * Control the map pitch in addition to the bearing\n * @defaultValue true\n */\n pitchWithRotate: boolean;\n}\n\n/**\n * The `DragRotateHandler` allows the user to rotate the map by clicking and\n * dragging the cursor while holding the right mouse button or `ctrl` key.\n *\n * @group Handlers\n */\nexport class DragRotateHandler {\n\n _mouseRotate: MouseRotateHandler;\n _mousePitch: MousePitchHandler;\n _pitchWithRotate: boolean;\n\n /** @internal */\n constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler) {\n this._pitchWithRotate = options.pitchWithRotate;\n this._mouseRotate = mouseRotate;\n this._mousePitch = mousePitch;\n }\n\n /**\n * Enables the \"drag to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.dragRotate.enable();\n * ```\n */\n enable() {\n this._mouseRotate.enable();\n if (this._pitchWithRotate) this._mousePitch.enable();\n }\n\n /**\n * Disables the \"drag to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.dragRotate.disable();\n * ```\n */\n disable() {\n this._mouseRotate.disable();\n this._mousePitch.disable();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to rotate\" interaction is enabled.\n *\n * @returns `true` if the \"drag to rotate\" interaction is enabled.\n */\n isEnabled() {\n return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled());\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to rotate\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to rotate\" interaction is active.\n */\n isActive() {\n return this._mouseRotate.isActive() || this._mousePitch.isActive();\n }\n}\n","import type {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, AroundCenterOptions} from '../two_fingers_touch';\nimport type {TapDragZoomHandler} from '../tap_drag_zoom';\n\n/**\n * The `TwoFingersTouchZoomRotateHandler` allows the user to zoom and rotate the map by\n * pinching on a touchscreen.\n *\n * They can zoom with one finger by double tapping and dragging. On the second tap,\n * hold the finger down and drag up or down to zoom in or out.\n *\n * @group Handlers\n */\nexport class TwoFingersTouchZoomRotateHandler {\n\n _el: HTMLElement;\n _touchZoom: TwoFingersTouchZoomHandler;\n _touchRotate: TwoFingersTouchRotateHandler;\n _tapDragZoom: TapDragZoomHandler;\n _rotationDisabled: boolean;\n _enabled: boolean;\n\n /** @internal */\n constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler) {\n this._el = el;\n this._touchZoom = touchZoom;\n this._touchRotate = touchRotate;\n this._tapDragZoom = tapDragZoom;\n this._rotationDisabled = false;\n this._enabled = true;\n }\n\n /**\n * Enables the \"pinch to rotate and zoom\" interaction.\n *\n * @param options - Options object.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.enable();\n * map.touchZoomRotate.enable({ around: 'center' });\n * ```\n */\n enable(options?: AroundCenterOptions | boolean | null) {\n this._touchZoom.enable(options);\n if (!this._rotationDisabled) this._touchRotate.enable(options);\n this._tapDragZoom.enable();\n this._el.classList.add('maplibregl-touch-zoom-rotate');\n }\n\n /**\n * Disables the \"pinch to rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.disable();\n * ```\n */\n disable() {\n this._touchZoom.disable();\n this._touchRotate.disable();\n this._tapDragZoom.disable();\n this._el.classList.remove('maplibregl-touch-zoom-rotate');\n }\n\n /**\n * Returns a Boolean indicating whether the \"pinch to rotate and zoom\" interaction is enabled.\n *\n * @returns `true` if the \"pinch to rotate and zoom\" interaction is enabled.\n */\n isEnabled() {\n return this._touchZoom.isEnabled() &&\n (this._rotationDisabled || this._touchRotate.isEnabled()) &&\n this._tapDragZoom.isEnabled();\n }\n\n /**\n * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.\n *\n * @returns `true` if the handler is active, `false` otherwise\n */\n isActive() {\n return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive();\n }\n\n /**\n * Disables the \"pinch to rotate\" interaction, leaving the \"pinch to zoom\"\n * interaction enabled.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.disableRotation();\n * ```\n */\n disableRotation() {\n this._rotationDisabled = true;\n this._touchRotate.disable();\n }\n\n /**\n * Enables the \"pinch to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.enable();\n * map.touchZoomRotate.enableRotation();\n * ```\n */\n enableRotation() {\n this._rotationDisabled = false;\n if (this._touchZoom.isEnabled()) this._touchRotate.enable();\n }\n}\n","import {Event} from '../util/evented';\nimport {DOM} from '../util/dom';\nimport {Map, CompleteMapOptions} from './map';\nimport {HandlerInertia} from './handler_inertia';\nimport {MapEventHandler, BlockableMapEventHandler} from './handler/map_event';\nimport {BoxZoomHandler} from './handler/box_zoom';\nimport {TapZoomHandler} from './handler/tap_zoom';\nimport {generateMouseRotationHandler, generateMousePitchHandler, generateMousePanHandler} from './handler/mouse';\nimport {TouchPanHandler} from './handler/touch_pan';\nimport {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';\nimport {KeyboardHandler} from './handler/keyboard';\nimport {ScrollZoomHandler} from './handler/scroll_zoom';\nimport {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';\nimport {ClickZoomHandler} from './handler/click_zoom';\nimport {TapDragZoomHandler} from './handler/tap_drag_zoom';\nimport {DragPanHandler} from './handler/shim/drag_pan';\nimport {DragRotateHandler} from './handler/shim/drag_rotate';\nimport {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';\nimport {extend} from '../util/util';\nimport {browser} from '../util/browser';\nimport Point from '@mapbox/point-geometry';\n\nexport type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;\n\nconst isMoving = p => p.zoom || p.drag || p.pitch || p.rotate;\n\nclass RenderFrameEvent extends Event {\n type: 'renderFrame';\n timeStamp: number;\n}\n\n/**\n * Handlers interpret dom events and return camera changes that should be\n * applied to the map (`HandlerResult`s). The camera changes are all deltas.\n * The handler itself should have no knowledge of the map's current state.\n * This makes it easier to merge multiple results and keeps handlers simpler.\n * For example, if there is a mousedown and mousemove, the mousePan handler\n * would return a `panDelta` on the mousemove.\n */\nexport interface Handler {\n enable(): void;\n disable(): void;\n isEnabled(): boolean;\n isActive(): boolean;\n /**\n * `reset` can be called by the manager at any time and must reset everything to it's original state\n */\n reset(): void;\n // Handlers can optionally implement these methods.\n // They are called with dom events whenever those dom evens are received.\n readonly touchstart?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchmove?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchmoveWindow?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchend?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchcancel?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly contextmenu?: (e: MouseEvent) => HandlerResult | void;\n readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void;\n readonly keydown?: (e: KeyboardEvent) => HandlerResult | void;\n readonly keyup?: (e: KeyboardEvent) => HandlerResult | void;\n /**\n * `renderFrame` is the only non-dom event. It is called during render\n * frames and can be used to smooth camera changes (see scroll handler).\n */\n readonly renderFrame?: () => HandlerResult | void;\n}\n\n/**\n * All handler methods that are called with events can optionally return a `HandlerResult`.\n */\nexport type HandlerResult = {\n panDelta?: Point;\n zoomDelta?: number;\n bearingDelta?: number;\n pitchDelta?: number;\n /**\n * the point to not move when changing the camera\n */\n around?: Point | null;\n /**\n * same as above, except for pinch actions, which are given higher priority\n */\n pinchAround?: Point | null;\n /**\n * A method that can fire a one-off easing by directly changing the map's camera.\n */\n cameraAnimation?: (map: Map) => any;\n /**\n * The last three properties are needed by only one handler: scrollzoom.\n * The DOM event to be used as the `originalEvent` on any camera change events.\n */\n originalEvent?: Event;\n /**\n * Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom).\n */\n needsRenderFrame?: boolean;\n /**\n * The camera changes won't get recorded for inertial zooming.\n */\n noInertia?: boolean;\n};\n\nexport type EventInProgress = {\n handlerName: string;\n originalEvent: Event;\n}\n\nexport type EventsInProgress = {\n zoom?: EventInProgress;\n pitch?: EventInProgress;\n rotate?: EventInProgress;\n drag?: EventInProgress;\n}\n\nfunction hasChange(result: HandlerResult) {\n return (result.panDelta && result.panDelta.mag()) || result.zoomDelta || result.bearingDelta || result.pitchDelta;\n}\n\nexport class HandlerManager {\n _map: Map;\n _el: HTMLElement;\n _handlers: Array<{\n handlerName: string;\n handler: Handler;\n allowed: Array;\n }>;\n _eventsInProgress: EventsInProgress;\n _frameId: number;\n _inertia: HandlerInertia;\n _bearingSnap: number;\n _handlersById: {[x: string]: Handler};\n _updatingCamera: boolean;\n _changes: Array<[HandlerResult, EventsInProgress, {[handlerName: string]: Event}]>;\n _terrainMovement: boolean;\n _zoom: {handlerName: string};\n _previousActiveHandlers: {[x: string]: Handler};\n _listeners: Array<[Window | Document | HTMLElement, string, {\n passive?: boolean;\n capture?: boolean;\n } | undefined]>;\n\n constructor(map: Map, options: CompleteMapOptions) {\n this._map = map;\n this._el = this._map.getCanvasContainer();\n this._handlers = [];\n this._handlersById = {};\n this._changes = [];\n\n this._inertia = new HandlerInertia(map);\n this._bearingSnap = options.bearingSnap;\n this._previousActiveHandlers = {};\n\n // Track whether map is currently moving, to compute start/move/end events\n this._eventsInProgress = {};\n\n this._addDefaultHandlers(options);\n\n const el = this._el;\n\n this._listeners = [\n // This needs to be `passive: true` so that a double tap fires two\n // pairs of touchstart/end events in iOS Safari 13. If this is set to\n // `passive: false` then the second pair of events is only fired if\n // preventDefault() is called on the first touchstart. Calling preventDefault()\n // undesirably prevents click events.\n [el, 'touchstart', {passive: true}],\n // This needs to be `passive: false` so that scrolls and pinches can be\n // prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12.\n [el, 'touchmove', {passive: false}],\n [el, 'touchend', undefined],\n [el, 'touchcancel', undefined],\n\n [el, 'mousedown', undefined],\n [el, 'mousemove', undefined],\n [el, 'mouseup', undefined],\n\n // Bind window-level event listeners for move and up/end events. In the absence of\n // the pointer capture API, which is not supported by all necessary platforms,\n // window-level event listeners give us the best shot at capturing events that\n // fall outside the map canvas element. Use `{capture: true}` for the move event\n // to prevent map move events from being fired during a drag.\n [document, 'mousemove', {capture: true}],\n [document, 'mouseup', undefined],\n\n [el, 'mouseover', undefined],\n [el, 'mouseout', undefined],\n [el, 'dblclick', undefined],\n [el, 'click', undefined],\n\n [el, 'keydown', {capture: false}],\n [el, 'keyup', undefined],\n\n [el, 'wheel', {passive: false}],\n [el, 'contextmenu', undefined],\n\n [window, 'blur', undefined]\n ];\n\n for (const [target, type, listenerOptions] of this._listeners) {\n DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);\n }\n }\n\n destroy() {\n for (const [target, type, listenerOptions] of this._listeners) {\n DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);\n }\n }\n\n _addDefaultHandlers(options: CompleteMapOptions) {\n const map = this._map;\n const el = map.getCanvasContainer();\n this._add('mapEvent', new MapEventHandler(map, options));\n\n const boxZoom = map.boxZoom = new BoxZoomHandler(map, options);\n this._add('boxZoom', boxZoom);\n if (options.interactive && options.boxZoom) {\n boxZoom.enable();\n }\n\n const tapZoom = new TapZoomHandler(map);\n const clickZoom = new ClickZoomHandler(map);\n map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);\n this._add('tapZoom', tapZoom);\n this._add('clickZoom', clickZoom);\n if (options.interactive && options.doubleClickZoom) {\n map.doubleClickZoom.enable();\n }\n\n const tapDragZoom = new TapDragZoomHandler();\n this._add('tapDragZoom', tapDragZoom);\n\n const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map);\n this._add('touchPitch', touchPitch);\n if (options.interactive && options.touchPitch) {\n map.touchPitch.enable(options.touchPitch);\n }\n\n const mouseRotate = generateMouseRotationHandler(options);\n const mousePitch = generateMousePitchHandler(options);\n map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);\n this._add('mouseRotate', mouseRotate, ['mousePitch']);\n this._add('mousePitch', mousePitch, ['mouseRotate']);\n if (options.interactive && options.dragRotate) {\n map.dragRotate.enable();\n }\n\n const mousePan = generateMousePanHandler(options);\n const touchPan = new TouchPanHandler(options, map);\n map.dragPan = new DragPanHandler(el, mousePan, touchPan);\n this._add('mousePan', mousePan);\n this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']);\n if (options.interactive && options.dragPan) {\n map.dragPan.enable(options.dragPan);\n }\n\n const touchRotate = new TwoFingersTouchRotateHandler();\n const touchZoom = new TwoFingersTouchZoomHandler();\n map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);\n this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);\n this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);\n if (options.interactive && options.touchZoomRotate) {\n map.touchZoomRotate.enable(options.touchZoomRotate);\n }\n\n const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame());\n this._add('scrollZoom', scrollZoom, ['mousePan']);\n if (options.interactive && options.scrollZoom) {\n map.scrollZoom.enable(options.scrollZoom);\n }\n\n const keyboard = map.keyboard = new KeyboardHandler(map);\n this._add('keyboard', keyboard);\n if (options.interactive && options.keyboard) {\n map.keyboard.enable();\n }\n\n this._add('blockableMapEvent', new BlockableMapEventHandler(map));\n }\n\n _add(handlerName: string, handler: Handler, allowed?: Array) {\n this._handlers.push({handlerName, handler, allowed});\n this._handlersById[handlerName] = handler;\n }\n\n stop(allowEndAnimation: boolean) {\n // do nothing if this method was triggered by a gesture update\n if (this._updatingCamera) return;\n\n for (const {handler} of this._handlers) {\n handler.reset();\n }\n this._inertia.clear();\n this._fireEvents({}, {}, allowEndAnimation);\n this._changes = [];\n }\n\n isActive() {\n for (const {handler} of this._handlers) {\n if (handler.isActive()) return true;\n }\n return false;\n }\n\n isZooming() {\n return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();\n }\n isRotating() {\n return !!this._eventsInProgress.rotate;\n }\n\n isMoving() {\n return Boolean(isMoving(this._eventsInProgress)) || this.isZooming();\n }\n\n _blockedByActive(activeHandlers: {[x: string]: Handler}, allowed: Array, myName: string) {\n for (const name in activeHandlers) {\n if (name === myName) continue;\n if (!allowed || allowed.indexOf(name) < 0) {\n return true;\n }\n }\n return false;\n }\n\n handleWindowEvent = (e: { type: 'mousemove' | 'mouseup' | 'touchmove'}) => {\n this.handleEvent(e, `${e.type}Window`);\n };\n\n _getMapTouches(touches: TouchList) {\n const mapTouches = [];\n for (const t of touches) {\n const target = (t.target as any as Node);\n if (this._el.contains(target)) {\n mapTouches.push(t);\n }\n }\n return mapTouches as any as TouchList;\n }\n\n handleEvent = (e: Event, eventName?: keyof Handler) => {\n\n if (e.type === 'blur') {\n this.stop(true);\n return;\n }\n\n this._updatingCamera = true;\n\n const inputEvent = e.type === 'renderFrame' ? undefined : e as InputEvent;\n\n /*\n * We don't call e.preventDefault() for any events by default.\n * Handlers are responsible for calling it where necessary.\n */\n\n const mergedHandlerResult: HandlerResult = {needsRenderFrame: false};\n const eventsInProgress: EventsInProgress = {};\n const activeHandlers = {};\n const eventTouches = (e as TouchEvent).touches;\n\n const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined;\n const points = mapTouches ? DOM.touchPos(this._el, mapTouches) : DOM.mousePos(this._el, ((e as MouseEvent)));\n\n for (const {handlerName, handler, allowed} of this._handlers) {\n if (!handler.isEnabled()) continue;\n\n let data: HandlerResult;\n if (this._blockedByActive(activeHandlers, allowed, handlerName)) {\n handler.reset();\n\n } else {\n if (handler[eventName || e.type]) {\n data = handler[eventName || e.type](e, points, mapTouches);\n this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent);\n if (data && data.needsRenderFrame) {\n this._triggerRenderFrame();\n }\n }\n }\n\n if (data || handler.isActive()) {\n activeHandlers[handlerName] = handler;\n }\n }\n\n const deactivatedHandlers: {[handlerName: string]: Event} = {};\n for (const name in this._previousActiveHandlers) {\n if (!activeHandlers[name]) {\n deactivatedHandlers[name] = inputEvent;\n }\n }\n this._previousActiveHandlers = activeHandlers;\n\n if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) {\n this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]);\n this._triggerRenderFrame();\n }\n\n if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) {\n this._map._stop(true);\n }\n\n this._updatingCamera = false;\n\n const {cameraAnimation} = mergedHandlerResult;\n if (cameraAnimation) {\n this._inertia.clear();\n this._fireEvents({}, {}, true);\n this._changes = [];\n cameraAnimation(this._map);\n }\n };\n\n mergeHandlerResult(mergedHandlerResult: HandlerResult,\n eventsInProgress: EventsInProgress,\n handlerResult: HandlerResult,\n name: string,\n e?: InputEvent) {\n if (!handlerResult) return;\n\n extend(mergedHandlerResult, handlerResult);\n\n const eventData = {handlerName: name, originalEvent: handlerResult.originalEvent || e};\n\n // track which handler changed which camera property\n if (handlerResult.zoomDelta !== undefined) {\n eventsInProgress.zoom = eventData;\n }\n if (handlerResult.panDelta !== undefined) {\n eventsInProgress.drag = eventData;\n }\n if (handlerResult.pitchDelta !== undefined) {\n eventsInProgress.pitch = eventData;\n }\n if (handlerResult.bearingDelta !== undefined) {\n eventsInProgress.rotate = eventData;\n }\n\n }\n\n _applyChanges() {\n const combined: HandlerResult = {};\n const combinedEventsInProgress: EventsInProgress = {};\n const combinedDeactivatedHandlers = {};\n\n for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) {\n\n if (change.panDelta) combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta);\n if (change.zoomDelta) combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;\n if (change.bearingDelta) combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;\n if (change.pitchDelta) combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;\n if (change.around !== undefined) combined.around = change.around;\n if (change.pinchAround !== undefined) combined.pinchAround = change.pinchAround;\n if (change.noInertia) combined.noInertia = change.noInertia;\n\n extend(combinedEventsInProgress, eventsInProgress);\n extend(combinedDeactivatedHandlers, deactivatedHandlers);\n }\n\n this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);\n this._changes = [];\n }\n\n _updateMapTransform(combinedResult: HandlerResult,\n combinedEventsInProgress: EventsInProgress,\n deactivatedHandlers: {[handlerName: string]: Event}) {\n const map = this._map;\n const tr = map._getTransformForUpdate();\n const terrain = map.terrain;\n\n if (!hasChange(combinedResult) && !(terrain && this._terrainMovement)) {\n return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);\n }\n\n let {panDelta, zoomDelta, bearingDelta, pitchDelta, around, pinchAround} = combinedResult;\n\n if (pinchAround !== undefined) {\n around = pinchAround;\n }\n\n // stop any ongoing camera animations (easeTo, flyTo)\n map._stop(true);\n\n around = around || map.transform.centerPoint;\n const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);\n if (bearingDelta) tr.bearing += bearingDelta;\n if (pitchDelta) tr.pitch += pitchDelta;\n if (zoomDelta) tr.zoom += zoomDelta;\n\n if (!terrain) {\n tr.setLocationAtPoint(loc, around);\n } else {\n // when 3d-terrain is enabled act a little different:\n // - dragging do not drag the picked point itself, instead it drags the map by pixel-delta.\n // With this approach it is no longer possible to pick a point from somewhere near\n // the horizon to the center in one move.\n // So this logic avoids the problem, that in such cases you easily loose orientation.\n if (!this._terrainMovement &&\n (combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) {\n // When starting to drag or move, flag it and register moveend to clear flagging\n this._terrainMovement = true;\n this._map._elevationFreeze = true;\n tr.setLocationAtPoint(loc, around);\n this._map.once('moveend', () => {\n this._map._elevationFreeze = false;\n this._terrainMovement = false;\n tr.recalculateZoom(map.terrain);\n });\n } else if (combinedEventsInProgress.drag && this._terrainMovement) {\n // drag map\n tr.center = tr.pointLocation(tr.centerPoint.sub(panDelta));\n } else {\n tr.setLocationAtPoint(loc, around);\n }\n }\n\n map._applyUpdatedTransform(tr);\n\n this._map._update();\n if (!combinedResult.noInertia) this._inertia.record(combinedResult);\n this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);\n\n }\n\n _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {[handlerName: string]: Event}, allowEndAnimation: boolean) {\n\n const wasMoving = isMoving(this._eventsInProgress);\n const nowMoving = isMoving(newEventsInProgress);\n\n const startEvents = {};\n\n for (const eventName in newEventsInProgress) {\n const {originalEvent} = newEventsInProgress[eventName];\n if (!this._eventsInProgress[eventName]) {\n startEvents[`${eventName}start`] = originalEvent;\n }\n this._eventsInProgress[eventName] = newEventsInProgress[eventName];\n }\n\n // fire start events only after this._eventsInProgress has been updated\n if (!wasMoving && nowMoving) {\n this._fireEvent('movestart', nowMoving.originalEvent);\n }\n\n for (const name in startEvents) {\n this._fireEvent(name, startEvents[name]);\n }\n\n if (nowMoving) {\n this._fireEvent('move', nowMoving.originalEvent);\n }\n\n for (const eventName in newEventsInProgress) {\n const {originalEvent} = newEventsInProgress[eventName];\n this._fireEvent(eventName, originalEvent);\n }\n\n const endEvents = {};\n\n let originalEndEvent;\n for (const eventName in this._eventsInProgress) {\n const {handlerName, originalEvent} = this._eventsInProgress[eventName];\n if (!this._handlersById[handlerName].isActive()) {\n delete this._eventsInProgress[eventName];\n originalEndEvent = deactivatedHandlers[handlerName] || originalEvent;\n endEvents[`${eventName}end`] = originalEndEvent;\n }\n }\n\n for (const name in endEvents) {\n this._fireEvent(name, endEvents[name]);\n }\n\n const stillMoving = isMoving(this._eventsInProgress);\n if (allowEndAnimation && (wasMoving || nowMoving) && !stillMoving) {\n this._updatingCamera = true;\n const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);\n\n const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;\n\n if (inertialEase && (inertialEase.essential || !browser.prefersReducedMotion)) {\n if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {\n inertialEase.bearing = 0;\n }\n inertialEase.freezeElevation = true;\n this._map.easeTo(inertialEase, {originalEvent: originalEndEvent});\n } else {\n this._map.fire(new Event('moveend', {originalEvent: originalEndEvent}));\n if (shouldSnapToNorth(this._map.getBearing())) {\n this._map.resetNorth();\n }\n }\n this._updatingCamera = false;\n }\n\n }\n\n _fireEvent(type: string, e?: Event) {\n this._map.fire(new Event(type, e ? {originalEvent: e} : {}));\n }\n\n _requestFrame() {\n this._map.triggerRepaint();\n return this._map._renderTaskQueue.add(timeStamp => {\n delete this._frameId;\n this.handleEvent(new RenderFrameEvent('renderFrame', {timeStamp}));\n this._applyChanges();\n });\n }\n\n _triggerRenderFrame() {\n if (this._frameId === undefined) {\n this._frameId = this._requestFrame();\n }\n }\n}\n","import {extend, warnOnce, clamp, wrap, defaultEasing, pick} from '../util/util';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {browser} from '../util/browser';\nimport {LngLat} from '../geo/lng_lat';\nimport {LngLatBounds} from '../geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {Event, Evented} from '../util/evented';\nimport {Terrain} from '../render/terrain';\n\nimport type {Transform} from '../geo/transform';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport type {TaskID} from '../util/task_queue';\nimport type {PaddingOptions} from '../geo/edge_insets';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\n\n/**\n * A [Point](https://github.com/mapbox/point-geometry) or an array of two numbers representing `x` and `y` screen coordinates in pixels.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let p1 = new Point(-77, 38); // a PointLike which is a Point\n * let p2 = [-77, 38]; // a PointLike which is an array of two numbers\n * ```\n */\nexport type PointLike = Point | [number, number];\n\n/**\n * A helper to allow require of at least one propery\n */\nexport type RequireAtLeastOne = { [K in keyof T]-?: Required> & Partial>>; }[keyof T];\n\n/**\n * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location,\n * zoom, bearing, and pitch of the camera. All properties are optional, and when a property is omitted, the current\n * camera value for that property will remain unchanged.\n *\n * @example\n * Set the map's initial perspective with CameraOptions\n * ```ts\n * let map = new maplibregl.Map({\n * container: 'map',\n * style: 'https://demotiles.maplibre.org/style.json',\n * center: [-73.5804, 45.53483],\n * pitch: 60,\n * bearing: -60,\n * zoom: 10\n * });\n * ```\n * @see [Set pitch and bearing](https://maplibre.org/maplibre-gl-js/docs/examples/set-perspective/)\n * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/)\n * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/)\n * @see [Display buildings in 3D](https://maplibre.org/maplibre-gl-js/docs/examples/3d-buildings/)\n */\nexport type CameraOptions = CenterZoomBearing & {\n /**\n * The desired pitch in degrees. The pitch is the angle towards the horizon\n * measured in degrees with a range between 0 and 60 degrees. For example, pitch: 0 provides the appearance\n * of looking straight down at the map, while pitch: 60 tilts the user's perspective towards the horizon.\n * Increasing the pitch value is often used to display 3D objects.\n */\n pitch?: number;\n /**\n * If `zoom` is specified, `around` determines the point around which the zoom is centered.\n */\n around?: LngLatLike;\n};\n\n/**\n * Holds center, zoom and bearing properties\n */\nexport type CenterZoomBearing = {\n /**\n * The desired center.\n */\n center?: LngLatLike;\n /**\n * The desired zoom level.\n */\n zoom?: number;\n /**\n * The desired bearing in degrees. The bearing is the compass direction that\n * is \"up\". For example, `bearing: 90` orients the map so that east is up.\n */\n bearing?: number;\n}\n\n/**\n * The options object related to the {@link Map#jumpTo} method\n */\nexport type JumpToOptions = CameraOptions & {\n /**\n * Dimensions in pixels applied on each side of the viewport for shifting the vanishing point.\n */\n padding?: PaddingOptions;\n}\n\n/**\n * A options object for the {@link Map#cameraForBounds} method\n */\nexport type CameraForBoundsOptions = CameraOptions & {\n /**\n * The amount of padding in pixels to add to the given bounds.\n */\n padding?: number | RequireAtLeastOne;\n /**\n * The center of the given bounds relative to the map's center, measured in pixels.\n * @defaultValue [0, 0]\n */\n offset?: PointLike;\n /**\n * The maximum zoom level to allow when the camera would transition to the specified bounds.\n */\n maxZoom?: number;\n}\n\n/**\n * The {@link Map#flyTo} options object\n */\nexport type FlyToOptions = AnimationOptions & CameraOptions & {\n /**\n * The zooming \"curve\" that will occur along the\n * flight path. A high value maximizes zooming for an exaggerated animation, while a low\n * value minimizes zooming for an effect closer to {@link Map#easeTo}. 1.42 is the average\n * value selected by participants in the user study discussed in\n * [van Wijk (2003)](https://www.win.tue.nl/~vanwijk/zoompan.pdf). A value of\n * `Math.pow(6, 0.25)` would be equivalent to the root mean squared average velocity. A\n * value of 1 would produce a circular motion.\n * @defaultValue 1.42\n */\n curve?: number;\n /**\n * The zero-based zoom level at the peak of the flight path. If\n * `options.curve` is specified, this option is ignored.\n */\n minZoom?: number;\n /**\n * The average speed of the animation defined in relation to\n * `options.curve`. A speed of 1.2 means that the map appears to move along the flight path\n * by 1.2 times `options.curve` screenfuls every second. A _screenful_ is the map's visible span.\n * It does not correspond to a fixed physical distance, but varies by zoom level.\n * @defaultValue 1.2\n */\n speed?: number;\n /**\n * The average speed of the animation measured in screenfuls\n * per second, assuming a linear timing curve. If `options.speed` is specified, this option is ignored.\n */\n screenSpeed?: number;\n /**\n * The animation's maximum duration, measured in milliseconds.\n * If duration exceeds maximum duration, it resets to 0.\n */\n maxDuration?: number;\n /**\n * The amount of padding in pixels to add to the given bounds.\n */\n padding?: number | RequireAtLeastOne;\n}\n\nexport type EaseToOptions = AnimationOptions & CameraOptions & {\n delayEndEvents?: number;\n padding?: number | RequireAtLeastOne;\n}\n\n/**\n * Options for {@link Map#fitBounds} method\n */\nexport type FitBoundsOptions = FlyToOptions & {\n /**\n * If `true`, the map transitions using {@link Map#easeTo}. If `false`, the map transitions using {@link Map#flyTo}.\n * See those functions and {@link AnimationOptions} for information about options available.\n * @defaultValue false\n */\n linear?: boolean;\n /**\n * The center of the given bounds relative to the map's center, measured in pixels.\n * @defaultValue [0, 0]\n */\n offset?: PointLike;\n /**\n * The maximum zoom level to allow when the map view transitions to the specified bounds.\n */\n maxZoom?: number;\n}\n\n/**\n * Options common to map movement methods that involve animation, such as {@link Map#panBy} and\n * {@link Map#easeTo}, controlling the duration and easing function of the animation. All properties\n * are optional.\n *\n */\nexport type AnimationOptions = {\n /**\n * The animation's duration, measured in milliseconds.\n */\n duration?: number;\n /**\n * A function taking a time in the range 0..1 and returning a number where 0 is\n * the initial state and 1 is the final state.\n */\n easing?: (_: number) => number;\n /**\n * of the target center relative to real map container center at the end of animation.\n */\n offset?: PointLike;\n /**\n * If `false`, no animation will occur.\n */\n animate?: boolean;\n /**\n * If `true`, then the animation is considered essential and will not be affected by\n * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/\\@media/prefers-reduced-motion).\n */\n essential?: boolean;\n /**\n * Default false. Needed in 3D maps to let the camera stay in a constant\n * height based on sea-level. After the animation finished the zoom-level will be recalculated in respect of\n * the distance from the camera to the center-coordinate-altitude.\n */\n freezeElevation?: boolean;\n};\n\n/**\n * A callback hook that allows manipulating the camera and being notified about camera updates before they happen\n */\nexport type CameraUpdateTransformFunction = (next: {\n center: LngLat;\n zoom: number;\n pitch: number;\n bearing: number;\n elevation: number;\n}) => {\n center?: LngLat;\n zoom?: number;\n pitch?: number;\n bearing?: number;\n elevation?: number;\n};\n\nexport abstract class Camera extends Evented {\n transform: Transform;\n terrain: Terrain;\n\n _moving: boolean;\n _zooming: boolean;\n _rotating: boolean;\n _pitching: boolean;\n _padding: boolean;\n\n _bearingSnap: number;\n _easeStart: number;\n _easeOptions: {\n duration?: number;\n easing?: (_: number) => number;\n };\n _easeId: string | void;\n\n _onEaseFrame: (_: number) => void;\n _onEaseEnd: (easeId?: string) => void;\n _easeFrameId: TaskID;\n\n /**\n * @internal\n * holds the geographical coordinate of the target\n */\n _elevationCenter: LngLat;\n /**\n * @internal\n * holds the targ altitude value, = center elevation of the target.\n * This value may changes during flight, because new terrain-tiles loads during flight.\n */\n _elevationTarget: number;\n /**\n * @internal\n * holds the start altitude value, = center elevation before animation begins\n * this value will recalculated during flight in respect of changing _elevationTarget values,\n * so the linear interpolation between start and target keeps smooth and without jumps.\n */\n _elevationStart: number;\n /**\n * @internal\n * Saves the current state of the elevation freeze - this is used during map movement to prevent \"rocky\" camera movement.\n */\n _elevationFreeze: boolean;\n /**\n * @internal\n * Used to track accumulated changes during continuous interaction\n */\n _requestedCameraState?: Transform;\n /**\n * A callback used to defer camera updates or apply arbitrary constraints.\n * If specified, this Camera instance can be used as a stateless component in React etc.\n */\n transformCameraUpdate: CameraUpdateTransformFunction | null;\n\n abstract _requestRenderFrame(a: () => void): TaskID;\n abstract _cancelRenderFrame(_: TaskID): void;\n\n constructor(transform: Transform, options: {\n bearingSnap: number;\n }) {\n super();\n this._moving = false;\n this._zooming = false;\n this.transform = transform;\n this._bearingSnap = options.bearingSnap;\n\n this.on('moveend', () => {\n delete this._requestedCameraState;\n });\n }\n\n /**\n * Returns the map's geographical centerpoint.\n *\n * @returns The map's geographical centerpoint.\n * @example\n * Return a LngLat object such as `{lng: 0, lat: 0}`\n * ```ts\n * let center = map.getCenter();\n * // access longitude and latitude values directly\n * let {lng, lat} = map.getCenter();\n * ```\n */\n getCenter(): LngLat { return new LngLat(this.transform.center.lng, this.transform.center.lat); }\n\n /**\n * Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param center - The centerpoint to set.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * map.setCenter([-74, 38]);\n * ```\n */\n setCenter(center: LngLatLike, eventData?: any) {\n return this.jumpTo({center}, eventData);\n }\n\n /**\n * Pans the map by the specified offset.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param offset - `x` and `y` coordinates by which to pan the map.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n panBy(offset: PointLike, options?: AnimationOptions, eventData?: any): this {\n offset = Point.convert(offset).mult(-1);\n return this.panTo(this.transform.center, extend({offset}, options), eventData);\n }\n\n /**\n * Pans the map to the specified location with an animated transition.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param lnglat - The location to pan the map to.\n * @param options - Options describing the destination and animation of the transition.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * map.panTo([-74, 38]);\n * // Specify that the panTo animation should last 5000 milliseconds.\n * map.panTo([-74, 38], {duration: 5000});\n * ```\n * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/)\n */\n panTo(lnglat: LngLatLike, options?: AnimationOptions, eventData?: any): this {\n return this.easeTo(extend({\n center: lnglat\n }, options), eventData);\n }\n\n /**\n * Returns the map's current zoom level.\n *\n * @returns The map's current zoom level.\n * @example\n * ```ts\n * map.getZoom();\n * ```\n */\n getZoom(): number { return this.transform.zoom; }\n\n /**\n * Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param zoom - The zoom level to set (0-20).\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom to the zoom level 5 without an animated transition\n * ```ts\n * map.setZoom(5);\n * ```\n */\n setZoom(zoom: number, eventData?: any): this {\n this.jumpTo({zoom}, eventData);\n return this;\n }\n\n /**\n * Zooms the map to the specified zoom level, with an animated transition.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param zoom - The zoom level to transition to.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // Zoom to the zoom level 5 without an animated transition\n * map.zoomTo(5);\n * // Zoom to the zoom level 8 with an animated transition\n * map.zoomTo(8, {\n * duration: 2000,\n * offset: [100, 50]\n * });\n * ```\n */\n zoomTo(zoom: number, options?: AnimationOptions | null, eventData?: any): this {\n return this.easeTo(extend({\n zoom\n }, options), eventData);\n }\n\n /**\n * Increases the map's zoom level by 1.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom the map in one level with a custom animation duration\n * ```ts\n * map.zoomIn({duration: 1000});\n * ```\n */\n zoomIn(options?: AnimationOptions, eventData?: any): this {\n this.zoomTo(this.getZoom() + 1, options, eventData);\n return this;\n }\n\n /**\n * Decreases the map's zoom level by 1.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom the map out one level with a custom animation offset\n * ```ts\n * map.zoomOut({offset: [80, 60]});\n * ```\n */\n zoomOut(options?: AnimationOptions, eventData?: any): this {\n this.zoomTo(this.getZoom() - 1, options, eventData);\n return this;\n }\n\n /**\n * Returns the map's current bearing. The bearing is the compass direction that is \"up\"; for example, a bearing\n * of 90° orients the map so that east is up.\n *\n * @returns The map's current bearing.\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n getBearing(): number { return this.transform.bearing; }\n\n /**\n * Sets the map's bearing (rotation). The bearing is the compass direction that is \"up\"; for example, a bearing\n * of 90° orients the map so that east is up.\n *\n * Equivalent to `jumpTo({bearing: bearing})`.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param bearing - The desired bearing.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Rotate the map to 90 degrees\n * ```ts\n * map.setBearing(90);\n * ```\n */\n setBearing(bearing: number, eventData?: any): this {\n this.jumpTo({bearing}, eventData);\n return this;\n }\n\n /**\n * Returns the current padding applied around the map viewport.\n *\n * @returns The current padding around the map viewport.\n */\n getPadding(): PaddingOptions { return this.transform.padding; }\n\n /**\n * Sets the padding in pixels around the viewport.\n *\n * Equivalent to `jumpTo({padding: padding})`.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param padding - The desired padding.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Sets a left padding of 300px, and a top padding of 50px\n * ```ts\n * map.setPadding({ left: 300, top: 50 });\n * ```\n */\n setPadding(padding: PaddingOptions, eventData?: any): this {\n this.jumpTo({padding}, eventData);\n return this;\n }\n\n /**\n * Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction\n * that is \"up\"; for example, a bearing of 90° orients the map so that east is up.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param bearing - The desired bearing.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n rotateTo(bearing: number, options?: AnimationOptions, eventData?: any): this {\n return this.easeTo(extend({\n bearing\n }, options), eventData);\n }\n\n /**\n * Rotates the map so that north is up (0° bearing), with an animated transition.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n resetNorth(options?: AnimationOptions, eventData?: any): this {\n this.rotateTo(0, extend({duration: 1000}, options), eventData);\n return this;\n }\n\n /**\n * Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n resetNorthPitch(options?: AnimationOptions, eventData?: any): this {\n this.easeTo(extend({\n bearing: 0,\n pitch: 0,\n duration: 1000\n }, options), eventData);\n return this;\n }\n\n /**\n * Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the\n * `bearingSnap` threshold).\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n snapToNorth(options?: AnimationOptions, eventData?: any): this {\n if (Math.abs(this.getBearing()) < this._bearingSnap) {\n return this.resetNorth(options, eventData);\n }\n return this;\n }\n\n /**\n * Returns the map's current pitch (tilt).\n *\n * @returns The map's current pitch, measured in degrees away from the plane of the screen.\n */\n getPitch(): number { return this.transform.pitch; }\n\n /**\n * Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`.\n *\n * Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`.\n *\n * @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60).\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n setPitch(pitch: number, eventData?: any): this {\n this.jumpTo({pitch}, eventData);\n return this;\n }\n\n /**\n * @param bounds - Calculate the center for these bounds in the viewport and use\n * the highest zoom level up to and including `Map#getMaxZoom()` that fits\n * in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0.\n * @param options - Options object\n * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.\n * If map is unable to fit, method will warn and return undefined.\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * let newCameraTransform = map.cameraForBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n */\n cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CenterZoomBearing {\n bounds = LngLatBounds.convert(bounds);\n const bearing = options && options.bearing || 0;\n return this._cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), bearing, options);\n }\n\n /**\n * @internal\n * Calculate the center of these two points in the viewport and use\n * the highest zoom level up to and including `Map#getMaxZoom()` that fits\n * the points in the viewport at the specified bearing.\n * @param p0 - First point\n * @param p1 - Second point\n * @param bearing - Desired map bearing at end of animation, in degrees\n * @param options - the camera options\n * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.\n * If map is unable to fit, method will warn and return undefined.\n * @example\n * ```ts\n * let p0 = [-79, 43];\n * let p1 = [-73, 45];\n * let bearing = 90;\n * let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n */\n _cameraForBoxAndBearing(p0: LngLatLike, p1: LngLatLike, bearing: number, options?: CameraForBoundsOptions): CenterZoomBearing {\n const defaultPadding = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n options = extend({\n padding: defaultPadding,\n offset: [0, 0],\n maxZoom: this.transform.maxZoom\n }, options);\n\n if (typeof options.padding === 'number') {\n const p = options.padding;\n options.padding = {\n top: p,\n bottom: p,\n right: p,\n left: p\n };\n }\n\n options.padding = extend(defaultPadding, options.padding) as PaddingOptions;\n const tr = this.transform;\n const edgePadding = tr.padding;\n\n // We want to calculate the upper right and lower left of the box defined by p0 and p1\n // in a coordinate system rotate to match the destination bearing.\n const p0world = tr.project(LngLat.convert(p0));\n const p1world = tr.project(LngLat.convert(p1));\n const p0rotated = p0world.rotate(-bearing * Math.PI / 180);\n const p1rotated = p1world.rotate(-bearing * Math.PI / 180);\n\n const upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));\n const lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));\n\n // Calculate zoom: consider the original bbox and padding.\n const size = upperRight.sub(lowerLeft);\n const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x;\n const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y;\n\n if (scaleY < 0 || scaleX < 0) {\n warnOnce(\n 'Map cannot fit within canvas with the given bounds, padding, and/or offset.'\n );\n return undefined;\n }\n\n const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);\n\n // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.\n const offset = Point.convert(options.offset);\n const paddingOffsetX = (options.padding.left - options.padding.right) / 2;\n const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;\n const paddingOffset = new Point(paddingOffsetX, paddingOffsetY);\n const rotatedPaddingOffset = paddingOffset.rotate(bearing * Math.PI / 180);\n const offsetAtInitialZoom = offset.add(rotatedPaddingOffset);\n const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));\n\n const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));\n\n return {\n center,\n zoom,\n bearing\n };\n }\n\n /**\n * Pans and zooms the map to contain its visible area within the specified geographical bounds.\n * This function will also reset the map's bearing to 0 if bearing is nonzero.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param bounds - Center these bounds in the viewport and use the highest\n * zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport.\n * @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)\n */\n fitBounds(bounds: LngLatBoundsLike, options?: FitBoundsOptions, eventData?: any): this {\n return this._fitInternal(\n this.cameraForBounds(bounds, options),\n options,\n eventData);\n }\n\n /**\n * Pans, rotates and zooms the map to to fit the box made by points p0 and p1\n * once the map is rotated to the specified bearing. To zoom without rotating,\n * pass in the current map bearing.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`.\n *\n * @param p0 - First point on screen, in pixel coordinates\n * @param p1 - Second point on screen, in pixel coordinates\n * @param bearing - Desired map bearing at end of animation, in degrees\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * let p0 = [220, 400];\n * let p1 = [500, 900];\n * map.fitScreenCoordinates(p0, p1, map.getBearing(), {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n * @see Used by {@link BoxZoomHandler}\n */\n fitScreenCoordinates(p0: PointLike, p1: PointLike, bearing: number, options?: FitBoundsOptions, eventData?: any): this {\n return this._fitInternal(\n this._cameraForBoxAndBearing(\n this.transform.pointLocation(Point.convert(p0)),\n this.transform.pointLocation(Point.convert(p1)),\n bearing,\n options),\n options,\n eventData);\n }\n\n _fitInternal(calculatedOptions?: CenterZoomBearing, options?: FitBoundsOptions, eventData?: any): this {\n // cameraForBounds warns + returns undefined if unable to fit:\n if (!calculatedOptions) return this;\n\n options = extend(calculatedOptions, options);\n // Explicitly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.\n delete options.padding;\n\n return options.linear ?\n this.easeTo(options, eventData) :\n this.flyTo(options, eventData);\n }\n\n /**\n * Changes any combination of center, zoom, bearing, and pitch, without\n * an animated transition. The map will retain its current values for any\n * details not specified in `options`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // jump to coordinates at current zoom\n * map.jumpTo({center: [0, 0]});\n * // jump with zoom, pitch, and bearing options\n * map.jumpTo({\n * center: [0, 0],\n * zoom: 8,\n * pitch: 45,\n * bearing: 90\n * });\n * ```\n * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/)\n * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/)\n */\n jumpTo(options: JumpToOptions, eventData?: any): this {\n this.stop();\n\n const tr = this._getTransformForUpdate();\n let zoomChanged = false,\n bearingChanged = false,\n pitchChanged = false;\n\n if ('zoom' in options && tr.zoom !== +options.zoom) {\n zoomChanged = true;\n tr.zoom = +options.zoom;\n }\n\n if (options.center !== undefined) {\n tr.center = LngLat.convert(options.center);\n }\n\n if ('bearing' in options && tr.bearing !== +options.bearing) {\n bearingChanged = true;\n tr.bearing = +options.bearing;\n }\n\n if ('pitch' in options && tr.pitch !== +options.pitch) {\n pitchChanged = true;\n tr.pitch = +options.pitch;\n }\n\n if (options.padding != null && !tr.isPaddingEqual(options.padding)) {\n tr.padding = options.padding;\n }\n this._applyUpdatedTransform(tr);\n\n this.fire(new Event('movestart', eventData))\n .fire(new Event('move', eventData));\n\n if (zoomChanged) {\n this.fire(new Event('zoomstart', eventData))\n .fire(new Event('zoom', eventData))\n .fire(new Event('zoomend', eventData));\n }\n\n if (bearingChanged) {\n this.fire(new Event('rotatestart', eventData))\n .fire(new Event('rotate', eventData))\n .fire(new Event('rotateend', eventData));\n }\n\n if (pitchChanged) {\n this.fire(new Event('pitchstart', eventData))\n .fire(new Event('pitch', eventData))\n .fire(new Event('pitchend', eventData));\n }\n\n return this.fire(new Event('moveend', eventData));\n }\n\n /**\n * Calculates pitch, zoom and bearing for looking at `newCenter` with the camera position being `newCenter`\n * and returns them as {@link CameraOptions}.\n * @param from - The camera to look from\n * @param altitudeFrom - The altitude of the camera to look from\n * @param to - The center to look at\n * @param altitudeTo - Optional altitude of the center to look at. If none given the ground height will be used.\n * @returns the calculated camera options\n */\n calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo: number = 0): CameraOptions {\n const fromMerc = MercatorCoordinate.fromLngLat(from, altitudeFrom);\n const toMerc = MercatorCoordinate.fromLngLat(to, altitudeTo);\n const dx = toMerc.x - fromMerc.x;\n const dy = toMerc.y - fromMerc.y;\n const dz = toMerc.z - fromMerc.z;\n\n const distance3D = Math.hypot(dx, dy, dz);\n if (distance3D === 0) throw new Error('Can\\'t calculate camera options with same From and To');\n\n const groundDistance = Math.hypot(dx, dy);\n\n const zoom = this.transform.scaleZoom(this.transform.cameraToCenterDistance / distance3D / this.transform.tileSize);\n const bearing = (Math.atan2(dx, -dy) * 180) / Math.PI;\n let pitch = (Math.acos(groundDistance / distance3D) * 180) / Math.PI;\n pitch = dz < 0 ? 90 - pitch : 90 + pitch;\n\n return {\n center: toMerc.toLngLat(),\n zoom,\n pitch,\n bearing\n };\n }\n\n /**\n * Changes any combination of `center`, `zoom`, `bearing`, `pitch`, and `padding` with an animated transition\n * between old and new values. The map will retain its current values for any\n * details not specified in `options`.\n *\n * Note: The transition will happen instantly if the user has enabled\n * the `reduced motion` accessibility feature enabled in their operating system,\n * unless `options` includes `essential: true`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options describing the destination and animation of the transition.\n * Accepts {@link CameraOptions} and {@link AnimationOptions}.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n easeTo(options: EaseToOptions & {\n easeId?: string;\n noMoveStart?: boolean;\n }, eventData?: any): this {\n this._stop(false, options.easeId);\n\n options = extend({\n offset: [0, 0],\n duration: 500,\n easing: defaultEasing\n }, options);\n\n if (options.animate === false || (!options.essential && browser.prefersReducedMotion)) options.duration = 0;\n\n const tr = this._getTransformForUpdate(),\n startZoom = this.getZoom(),\n startBearing = this.getBearing(),\n startPitch = this.getPitch(),\n startPadding = this.getPadding(),\n\n zoom = 'zoom' in options ? +options.zoom : startZoom,\n bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing,\n pitch = 'pitch' in options ? +options.pitch : startPitch,\n padding = 'padding' in options ? options.padding : tr.padding;\n\n const offsetAsPoint = Point.convert(options.offset);\n let pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n const locationAtOffset = tr.pointLocation(pointAtOffset);\n const center = LngLat.convert(options.center || locationAtOffset);\n this._normalizeCenter(center);\n\n const from = tr.project(locationAtOffset);\n const delta = tr.project(center).sub(from);\n const finalScale = tr.zoomScale(zoom - startZoom);\n\n let around, aroundPoint;\n\n if (options.around) {\n around = LngLat.convert(options.around);\n aroundPoint = tr.locationPoint(around);\n }\n\n const currently = {\n moving: this._moving,\n zooming: this._zooming,\n rotating: this._rotating,\n pitching: this._pitching\n };\n\n this._zooming = this._zooming || (zoom !== startZoom);\n this._rotating = this._rotating || (startBearing !== bearing);\n this._pitching = this._pitching || (pitch !== startPitch);\n this._padding = !tr.isPaddingEqual(padding as PaddingOptions);\n\n this._easeId = options.easeId;\n this._prepareEase(eventData, options.noMoveStart, currently);\n if (this.terrain) this._prepareElevation(center);\n\n this._ease((k) => {\n if (this._zooming) {\n tr.zoom = interpolates.number(startZoom, zoom, k);\n }\n if (this._rotating) {\n tr.bearing = interpolates.number(startBearing, bearing, k);\n }\n if (this._pitching) {\n tr.pitch = interpolates.number(startPitch, pitch, k);\n }\n if (this._padding) {\n tr.interpolatePadding(startPadding, padding as PaddingOptions, k);\n // When padding is being applied, Transform#centerPoint is changing continuously,\n // thus we need to recalculate offsetPoint every frame\n pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n }\n\n if (this.terrain && !options.freezeElevation) this._updateElevation(k);\n\n if (around) {\n tr.setLocationAtPoint(around, aroundPoint);\n } else {\n const scale = tr.zoomScale(tr.zoom - startZoom);\n const base = zoom > startZoom ?\n Math.min(2, finalScale) :\n Math.max(0.5, finalScale);\n const speedup = Math.pow(base, 1 - k);\n const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));\n tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);\n }\n\n this._applyUpdatedTransform(tr);\n\n this._fireMoveEvents(eventData);\n\n }, (interruptingEaseId?: string) => {\n if (this.terrain) this._finalizeElevation();\n this._afterEase(eventData, interruptingEaseId);\n }, options as any);\n\n return this;\n }\n\n _prepareEase(eventData: any, noMoveStart: boolean, currently: any = {}) {\n this._moving = true;\n if (!noMoveStart && !currently.moving) {\n this.fire(new Event('movestart', eventData));\n }\n if (this._zooming && !currently.zooming) {\n this.fire(new Event('zoomstart', eventData));\n }\n if (this._rotating && !currently.rotating) {\n this.fire(new Event('rotatestart', eventData));\n }\n if (this._pitching && !currently.pitching) {\n this.fire(new Event('pitchstart', eventData));\n }\n }\n\n _prepareElevation(center: LngLat) {\n this._elevationCenter = center;\n this._elevationStart = this.transform.elevation;\n this._elevationTarget = this.terrain.getElevationForLngLatZoom(center, this.transform.tileZoom);\n this._elevationFreeze = true;\n }\n\n _updateElevation(k: number) {\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);\n const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);\n // target terrain updated during flight, slowly move camera to new height\n if (k < 1 && elevation !== this._elevationTarget) {\n const pitch1 = this._elevationTarget - this._elevationStart;\n const pitch2 = (elevation - (pitch1 * k + this._elevationStart)) / (1 - k);\n this._elevationStart += k * (pitch1 - pitch2);\n this._elevationTarget = elevation;\n }\n this.transform.elevation = interpolates.number(this._elevationStart, this._elevationTarget, k);\n }\n\n _finalizeElevation() {\n this._elevationFreeze = false;\n this.transform.recalculateZoom(this.terrain);\n }\n\n /**\n * @internal\n * Called when the camera is about to be manipulated.\n * If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes.\n * This underlying transform represents the \"desired state\" proposed by input handlers / animations / UI controls.\n * It may differ from the state used for rendering (`this.transform`).\n * @returns Transform to apply changes to\n */\n _getTransformForUpdate(): Transform {\n if (!this.transformCameraUpdate) return this.transform;\n\n if (!this._requestedCameraState) {\n this._requestedCameraState = this.transform.clone();\n }\n return this._requestedCameraState;\n }\n\n /**\n * @internal\n * Called after the camera is done being manipulated.\n * @param tr - the requested camera end state\n * Call `transformCameraUpdate` if present, and then apply the \"approved\" changes.\n */\n _applyUpdatedTransform(tr: Transform) {\n if (!this.transformCameraUpdate) return;\n\n const nextTransform = tr.clone();\n const {\n center,\n zoom,\n pitch,\n bearing,\n elevation\n } = this.transformCameraUpdate(nextTransform);\n if (center) nextTransform.center = center;\n if (zoom !== undefined) nextTransform.zoom = zoom;\n if (pitch !== undefined) nextTransform.pitch = pitch;\n if (bearing !== undefined) nextTransform.bearing = bearing;\n if (elevation !== undefined) nextTransform.elevation = elevation;\n this.transform.apply(nextTransform);\n }\n\n _fireMoveEvents(eventData?: any) {\n this.fire(new Event('move', eventData));\n if (this._zooming) {\n this.fire(new Event('zoom', eventData));\n }\n if (this._rotating) {\n this.fire(new Event('rotate', eventData));\n }\n if (this._pitching) {\n this.fire(new Event('pitch', eventData));\n }\n }\n\n _afterEase(eventData?: any, easeId?: string) {\n // if this easing is being stopped to start another easing with\n // the same id then don't fire any events to avoid extra start/stop events\n if (this._easeId && easeId && this._easeId === easeId) {\n return;\n }\n delete this._easeId;\n\n const wasZooming = this._zooming;\n const wasRotating = this._rotating;\n const wasPitching = this._pitching;\n this._moving = false;\n this._zooming = false;\n this._rotating = false;\n this._pitching = false;\n this._padding = false;\n\n if (wasZooming) {\n this.fire(new Event('zoomend', eventData));\n }\n if (wasRotating) {\n this.fire(new Event('rotateend', eventData));\n }\n if (wasPitching) {\n this.fire(new Event('pitchend', eventData));\n }\n this.fire(new Event('moveend', eventData));\n }\n\n /**\n * Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that\n * evokes flight. The animation seamlessly incorporates zooming and panning to help\n * the user maintain her bearings even after traversing a great distance.\n *\n * Note: The animation will be skipped, and this will behave equivalently to `jumpTo`\n * if the user has the `reduced motion` accessibility feature enabled in their operating system,\n * unless 'options' includes `essential: true`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options describing the destination and animation of the transition.\n * Accepts {@link CameraOptions}, {@link AnimationOptions},\n * and the following additional options.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // fly with default options to null island\n * map.flyTo({center: [0, 0], zoom: 9});\n * // using flyTo options\n * map.flyTo({\n * center: [0, 0],\n * zoom: 9,\n * speed: 0.2,\n * curve: 1,\n * easing(t) {\n * return t;\n * }\n * });\n * ```\n * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/)\n * @see [Slowly fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto-options/)\n * @see [Fly to a location based on scroll position](https://maplibre.org/maplibre-gl-js/docs/examples/scroll-fly-to/)\n */\n flyTo(options: FlyToOptions, eventData?: any): this {\n // Fall through to jumpTo if user has set prefers-reduced-motion\n if (!options.essential && browser.prefersReducedMotion) {\n const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']) as CameraOptions;\n return this.jumpTo(coercedOptions, eventData);\n }\n\n // This method implements an “optimal path” animation, as detailed in:\n //\n // Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and panning.” INFOVIS\n // ’03. pp. 15–22. .\n //\n // Where applicable, local variable documentation begins with the associated variable or\n // function in van Wijk (2003).\n\n this.stop();\n\n options = extend({\n offset: [0, 0],\n speed: 1.2,\n curve: 1.42,\n easing: defaultEasing\n }, options);\n\n const tr = this._getTransformForUpdate(),\n startZoom = this.getZoom(),\n startBearing = this.getBearing(),\n startPitch = this.getPitch(),\n startPadding = this.getPadding();\n\n const zoom = 'zoom' in options ? clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;\n const bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing;\n const pitch = 'pitch' in options ? +options.pitch : startPitch;\n const padding = 'padding' in options ? options.padding : tr.padding;\n\n const scale = tr.zoomScale(zoom - startZoom);\n const offsetAsPoint = Point.convert(options.offset);\n let pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n const locationAtOffset = tr.pointLocation(pointAtOffset);\n const center = LngLat.convert(options.center || locationAtOffset);\n this._normalizeCenter(center);\n\n const from = tr.project(locationAtOffset);\n const delta = tr.project(center).sub(from);\n\n let rho = options.curve;\n\n // w₀: Initial visible span, measured in pixels at the initial scale.\n const w0 = Math.max(tr.width, tr.height),\n // w₁: Final visible span, measured in pixels with respect to the initial scale.\n w1 = w0 / scale,\n // Length of the flight path as projected onto the ground plane, measured in pixels from\n // the world image origin at the initial scale.\n u1 = delta.mag();\n\n if ('minZoom' in options) {\n const minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);\n // wm: Maximum visible span, measured in pixels with respect to the initial\n // scale.\n const wMax = w0 / tr.zoomScale(minZoom - startZoom);\n rho = Math.sqrt(wMax / u1 * 2);\n }\n\n // ρ²\n const rho2 = rho * rho;\n\n /**\n * rᵢ: Returns the zoom-out factor at one end of the animation.\n *\n * @param descent - `true` for the descent, `false` for the ascent\n */\n function zoomOutFactor(descent: boolean) {\n const b = (w1 * w1 - w0 * w0 + (descent ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (descent ? w1 : w0) * rho2 * u1);\n return Math.log(Math.sqrt(b * b + 1) - b);\n }\n\n function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; }\n function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; }\n function tanh(n) { return sinh(n) / cosh(n); }\n\n // r₀: Zoom-out factor during ascent.\n const r0 = zoomOutFactor(false);\n\n // w(s): Returns the visible span on the ground, measured in pixels with respect to the\n // initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°.\n let w: (_: number) => number = function (s) {\n return (cosh(r0) / cosh(r0 + rho * s));\n };\n\n // u(s): Returns the distance along the flight path as projected onto the ground plane,\n // measured in pixels from the world image origin at the initial scale.\n let u: (_: number) => number = function (s) {\n return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;\n };\n\n // S: Total length of the flight path, measured in ρ-screenfuls.\n let S = (zoomOutFactor(true) - r0) / rho;\n\n // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.\n if (Math.abs(u1) < 0.000001 || !isFinite(S)) {\n // Perform a more or less instantaneous transition if the path is too short.\n if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData);\n\n const k = w1 < w0 ? -1 : 1;\n S = Math.abs(Math.log(w1 / w0)) / rho;\n\n u = function() { return 0; };\n w = function(s) { return Math.exp(k * rho * s); };\n }\n\n if ('duration' in options) {\n options.duration = +options.duration;\n } else {\n const V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;\n options.duration = 1000 * S / V;\n }\n\n if (options.maxDuration && options.duration > options.maxDuration) {\n options.duration = 0;\n }\n\n this._zooming = true;\n this._rotating = (startBearing !== bearing);\n this._pitching = (pitch !== startPitch);\n this._padding = !tr.isPaddingEqual(padding as PaddingOptions);\n\n this._prepareEase(eventData, false);\n if (this.terrain) this._prepareElevation(center);\n\n this._ease((k) => {\n // s: The distance traveled along the flight path, measured in ρ-screenfuls.\n const s = k * S;\n const scale = 1 / w(s);\n tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale);\n\n if (this._rotating) {\n tr.bearing = interpolates.number(startBearing, bearing, k);\n }\n if (this._pitching) {\n tr.pitch = interpolates.number(startPitch, pitch, k);\n }\n if (this._padding) {\n tr.interpolatePadding(startPadding, padding as PaddingOptions, k);\n // When padding is being applied, Transform#centerPoint is changing continuously,\n // thus we need to recalculate offsetPoint every frame\n pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n }\n\n if (this.terrain && !options.freezeElevation) this._updateElevation(k);\n\n const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(scale));\n tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);\n\n this._applyUpdatedTransform(tr);\n\n this._fireMoveEvents(eventData);\n\n }, () => {\n if (this.terrain) this._finalizeElevation();\n this._afterEase(eventData);\n }, options);\n\n return this;\n }\n\n isEasing() {\n return !!this._easeFrameId;\n }\n\n /**\n * Stops any animated transition underway.\n *\n * @returns `this`\n */\n stop(): this {\n return this._stop();\n }\n\n _stop(allowGestures?: boolean, easeId?: string): this {\n if (this._easeFrameId) {\n this._cancelRenderFrame(this._easeFrameId);\n delete this._easeFrameId;\n delete this._onEaseFrame;\n }\n\n if (this._onEaseEnd) {\n // The _onEaseEnd function might emit events which trigger new\n // animation, which sets a new _onEaseEnd. Ensure we don't delete\n // it unintentionally.\n const onEaseEnd = this._onEaseEnd;\n delete this._onEaseEnd;\n onEaseEnd.call(this, easeId);\n }\n if (!allowGestures) {\n const handlers = (this as any).handlers;\n if (handlers) handlers.stop(false);\n }\n return this;\n }\n\n _ease(frame: (_: number) => void,\n finish: () => void,\n options: {\n animate?: boolean;\n duration?: number;\n easing?: (_: number) => number;\n }) {\n if (options.animate === false || options.duration === 0) {\n frame(1);\n finish();\n } else {\n this._easeStart = browser.now();\n this._easeOptions = options;\n this._onEaseFrame = frame;\n this._onEaseEnd = finish;\n this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);\n }\n }\n\n // Callback for map._requestRenderFrame\n _renderFrameCallback = () => {\n const t = Math.min((browser.now() - this._easeStart) / this._easeOptions.duration, 1);\n this._onEaseFrame(this._easeOptions.easing(t));\n\n // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted\n if (t < 1 && this._easeFrameId) {\n this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);\n } else {\n this.stop();\n }\n };\n\n // convert bearing so that it's numerically close to the current one so that it interpolates properly\n _normalizeBearing(bearing: number, currentBearing: number) {\n bearing = wrap(bearing, -180, 180);\n const diff = Math.abs(bearing - currentBearing);\n if (Math.abs(bearing - 360 - currentBearing) < diff) bearing -= 360;\n if (Math.abs(bearing + 360 - currentBearing) < diff) bearing += 360;\n return bearing;\n }\n\n // If a path crossing the antimeridian would be shorter, extend the final coordinate so that\n // interpolating between the two endpoints will cross it.\n _normalizeCenter(center: LngLat) {\n const tr = this.transform;\n if (!tr.renderWorldCopies || tr.lngRange) return;\n\n const delta = center.lng - tr.center.lng;\n center.lng +=\n delta > 180 ? -360 :\n delta < -180 ? 360 : 0;\n }\n\n /**\n * Query the current elevation of location. It return null if terrain is not enabled. the elevation is in meters relative to mean sea-level\n * @param lngLatLike - [x,y] or LngLat coordinates of the location\n * @returns elevation in meters\n */\n queryTerrainElevation(lngLatLike: LngLatLike): number | null {\n if (!this.terrain) {\n return null;\n }\n const elevation = this.terrain.getElevationForLngLatZoom(LngLat.convert(lngLatLike), this.transform.tileZoom);\n /**\n * Different zoomlevels with different terrain-tiles the elevation-values are not the same.\n * map.transform.elevation variable with the center-altitude.\n * In maplibre the proj-matrix is translated by this value in negative z-direction.\n * So we need to add this value to the elevation to get the correct value.\n */\n return elevation - this.transform.elevation;\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\nimport type {MapDataEvent} from '../events';\nimport type {StyleSpecification} from '@maplibre/maplibre-gl-style-spec';\n/**\n * The {@link AttributionControl} options\n */\ntype AttributionOptions = {\n /**\n * If `true`, the attribution control will always collapse when moving the map. If `false`,\n * force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide.\n * **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.**\n */\n compact?: boolean;\n /**\n * Attributions to show in addition to any other attributions.\n */\n customAttribution?: string | Array;\n};\n\n/**\n * An `AttributionControl` control presents the map's attribution information. By default, the attribution control is expanded (regardless of map width).\n * @group Markers and Controls\n * @example\n * ```ts\n * let map = new maplibregl.Map({attributionControl: false})\n * .addControl(new maplibregl.AttributionControl({\n * compact: true\n * }));\n * ```\n */\nexport class AttributionControl implements IControl {\n options: AttributionOptions;\n _map: Map;\n _compact: boolean;\n _container: HTMLElement;\n _innerContainer: HTMLElement;\n _compactButton: HTMLElement;\n _editLink: HTMLAnchorElement;\n _attribHTML: string;\n styleId: string;\n styleOwner: string;\n\n /**\n * @param options - the attribution options\n */\n constructor(options: AttributionOptions = {}) {\n this.options = options;\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-right';\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._compact = this.options && this.options.compact;\n this._container = DOM.create('details', 'maplibregl-ctrl maplibregl-ctrl-attrib');\n this._compactButton = DOM.create('summary', 'maplibregl-ctrl-attrib-button', this._container);\n this._compactButton.addEventListener('click', this._toggleAttribution);\n this._setElementTitle(this._compactButton, 'ToggleAttribution');\n this._innerContainer = DOM.create('div', 'maplibregl-ctrl-attrib-inner', this._container);\n\n this._updateAttributions();\n this._updateCompact();\n\n this._map.on('styledata', this._updateData);\n this._map.on('sourcedata', this._updateData);\n this._map.on('terrain', this._updateData);\n this._map.on('resize', this._updateCompact);\n this._map.on('drag', this._updateCompactMinimize);\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n\n this._map.off('styledata', this._updateData);\n this._map.off('sourcedata', this._updateData);\n this._map.off('terrain', this._updateData);\n this._map.off('resize', this._updateCompact);\n this._map.off('drag', this._updateCompactMinimize);\n\n this._map = undefined;\n this._compact = undefined;\n this._attribHTML = undefined;\n }\n\n _setElementTitle(element: HTMLElement, title: string) {\n const str = this._map._getUIString(`AttributionControl.${title}`);\n element.title = str;\n element.setAttribute('aria-label', str);\n }\n\n _toggleAttribution = () => {\n if (this._container.classList.contains('maplibregl-compact')) {\n if (this._container.classList.contains('maplibregl-compact-show')) {\n this._container.setAttribute('open', '');\n this._container.classList.remove('maplibregl-compact-show');\n } else {\n this._container.classList.add('maplibregl-compact-show');\n this._container.removeAttribute('open');\n }\n }\n };\n\n _updateData = (e: MapDataEvent) => {\n if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style' || e.type === 'terrain')) {\n this._updateAttributions();\n }\n };\n\n _updateAttributions() {\n if (!this._map.style) return;\n let attributions: Array = [];\n if (this.options.customAttribution) {\n if (Array.isArray(this.options.customAttribution)) {\n attributions = attributions.concat(\n this.options.customAttribution.map(attribution => {\n if (typeof attribution !== 'string') return '';\n return attribution;\n })\n );\n } else if (typeof this.options.customAttribution === 'string') {\n attributions.push(this.options.customAttribution);\n }\n }\n\n if (this._map.style.stylesheet) {\n const stylesheet = this._map.style.stylesheet as StyleSpecification & { owner: string; id: string };\n this.styleOwner = stylesheet.owner;\n this.styleId = stylesheet.id;\n }\n\n const sourceCaches = this._map.style.sourceCaches;\n for (const id in sourceCaches) {\n const sourceCache = sourceCaches[id];\n if (sourceCache.used || sourceCache.usedForTerrain) {\n const source = sourceCache.getSource();\n if (source.attribution && attributions.indexOf(source.attribution) < 0) {\n attributions.push(source.attribution);\n }\n }\n }\n\n // remove any entries that are whitespace\n attributions = attributions.filter(e => String(e).trim());\n\n // remove any entries that are substrings of another entry.\n // first sort by length so that substrings come first\n attributions.sort((a, b) => a.length - b.length);\n attributions = attributions.filter((attrib, i) => {\n for (let j = i + 1; j < attributions.length; j++) {\n if (attributions[j].indexOf(attrib) >= 0) { return false; }\n }\n return true;\n });\n\n // check if attribution string is different to minimize DOM changes\n const attribHTML = attributions.join(' | ');\n if (attribHTML === this._attribHTML) return;\n\n this._attribHTML = attribHTML;\n\n if (attributions.length) {\n this._innerContainer.innerHTML = attribHTML;\n this._container.classList.remove('maplibregl-attrib-empty');\n } else {\n this._container.classList.add('maplibregl-attrib-empty');\n }\n this._updateCompact();\n // remove old DOM node from _editLink\n this._editLink = null;\n }\n\n _updateCompact = () => {\n if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {\n if (this._compact === false) {\n this._container.setAttribute('open', '');\n } else if (!this._container.classList.contains('maplibregl-compact') && !this._container.classList.contains('maplibregl-attrib-empty')) {\n this._container.setAttribute('open', '');\n this._container.classList.add('maplibregl-compact', 'maplibregl-compact-show');\n }\n } else {\n this._container.setAttribute('open', '');\n if (this._container.classList.contains('maplibregl-compact')) {\n this._container.classList.remove('maplibregl-compact', 'maplibregl-compact-show');\n }\n }\n };\n\n _updateCompactMinimize = () => {\n if (this._container.classList.contains('maplibregl-compact')) {\n if (this._container.classList.contains('maplibregl-compact-show')) {\n this._container.classList.remove('maplibregl-compact-show');\n }\n }\n };\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\n\n/**\n * The {@link LogoControl} options object\n */\ntype LogoOptions = {\n /**\n * If `true`, force a compact logo.\n * If `false`, force the full logo. The default is a responsive logo that collapses when the map is less than 640 pixels wide.\n */\n compact?: boolean;\n};\n\n/**\n * A `LogoControl` is a control that adds the watermark.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.LogoControl({compact: false}));\n * ```\n **/\nexport class LogoControl implements IControl {\n options: LogoOptions;\n _map: Map;\n _compact: boolean;\n _container: HTMLElement;\n\n constructor(options: LogoOptions = {}) {\n this.options = options;\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-left';\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._compact = this.options && this.options.compact;\n this._container = DOM.create('div', 'maplibregl-ctrl');\n const anchor = DOM.create('a', 'maplibregl-ctrl-logo');\n anchor.target = '_blank';\n anchor.rel = 'noopener nofollow';\n anchor.href = 'https://maplibre.org/';\n anchor.setAttribute('aria-label', this._map._getUIString('LogoControl.Title'));\n anchor.setAttribute('rel', 'noopener nofollow');\n this._container.appendChild(anchor);\n this._container.style.display = 'block';\n\n this._map.on('resize', this._updateCompact);\n this._updateCompact();\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('resize', this._updateCompact);\n this._map = undefined;\n this._compact = undefined;\n }\n\n _updateCompact = () => {\n const containerChildren = this._container.children;\n if (containerChildren.length) {\n const anchor = containerChildren[0];\n if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {\n if (this._compact !== false) {\n anchor.classList.add('maplibregl-compact');\n }\n } else {\n anchor.classList.remove('maplibregl-compact');\n }\n }\n };\n\n}\n","export type TaskID = number; // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61\n\ntype Task = {\n callback: (timeStamp: number) => void;\n id: TaskID;\n cancelled: boolean;\n};\n\nexport class TaskQueue {\n _queue: Array;\n _id: TaskID;\n _cleared: boolean;\n _currentlyRunning: Array | false;\n\n constructor() {\n this._queue = [];\n this._id = 0;\n this._cleared = false;\n this._currentlyRunning = false;\n }\n\n add(callback: (timeStamp: number) => void): TaskID {\n const id = ++this._id;\n const queue = this._queue;\n queue.push({callback, id, cancelled: false});\n return id;\n }\n\n remove(id: TaskID) {\n const running = this._currentlyRunning;\n const queue = running ? this._queue.concat(running) : this._queue;\n for (const task of queue) {\n if (task.id === id) {\n task.cancelled = true;\n return;\n }\n }\n }\n\n run(timeStamp: number = 0) {\n if (this._currentlyRunning) throw new Error('Attempting to run(), but is already running.');\n const queue = this._currentlyRunning = this._queue;\n\n // Tasks queued by callbacks in the current queue should be executed\n // on the next run, not the current run.\n this._queue = [];\n\n for (const task of queue) {\n if (task.cancelled) continue;\n task.callback(timeStamp);\n if (this._cleared) break;\n }\n\n this._cleared = false;\n this._currentlyRunning = false;\n }\n\n clear() {\n if (this._currentlyRunning) {\n this._cleared = true;\n }\n this._queue = [];\n }\n}\n","export const defaultLocale = {\n 'AttributionControl.ToggleAttribution': 'Toggle attribution',\n 'AttributionControl.MapFeedback': 'Map feedback',\n 'FullscreenControl.Enter': 'Enter fullscreen',\n 'FullscreenControl.Exit': 'Exit fullscreen',\n 'GeolocateControl.FindMyLocation': 'Find my location',\n 'GeolocateControl.LocationNotAvailable': 'Location not available',\n 'LogoControl.Title': 'Mapbox logo',\n 'NavigationControl.ResetBearing': 'Reset bearing to north',\n 'NavigationControl.ZoomIn': 'Zoom in',\n 'NavigationControl.ZoomOut': 'Zoom out',\n 'ScaleControl.Feet': 'ft',\n 'ScaleControl.Meters': 'm',\n 'ScaleControl.Kilometers': 'km',\n 'ScaleControl.Miles': 'mi',\n 'ScaleControl.NauticalMiles': 'nm',\n 'TerrainControl.enableTerrain': 'Enable terrain',\n 'TerrainControl.disableTerrain': 'Disable terrain'\n};\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos3d', type: 'Int16', components: 3}\n]);\n","import {OverscaledTileID} from './tile_id';\nimport {Tile} from './tile';\nimport {EXTENT} from '../data/extent';\nimport {mat4} from 'gl-matrix';\nimport {Evented} from '../util/evented';\nimport type {Transform} from '../geo/transform';\nimport type {SourceCache} from '../source/source_cache';\nimport {Terrain} from '../render/terrain';\n\n/**\n * @internal\n * This class is a helper for the Terrain-class, it:\n * - loads raster-dem tiles\n * - manages all renderToTexture tiles.\n * - caches previous rendered tiles.\n * - finds all necessary renderToTexture tiles for a OverscaledTileID area\n * - finds the corresponding raster-dem tile for OverscaledTileID\n */\nexport class TerrainSourceCache extends Evented {\n /**\n * source-cache for the raster-dem source.\n */\n sourceCache: SourceCache;\n /**\n * stores all render-to-texture tiles.\n */\n _tiles: {[_: string]: Tile};\n /**\n * contains a list of tileID-keys for the current scene. (only for performance)\n */\n _renderableTilesKeys: Array;\n /**\n * raster-dem-tile for a TileID cache.\n */\n _sourceTileCache: {[_: string]: string};\n /**\n * minimum zoomlevel to render the terrain.\n */\n minzoom: number;\n /**\n * maximum zoomlevel to render the terrain.\n */\n maxzoom: number;\n /**\n * render-to-texture tileSize in scene.\n */\n tileSize: number;\n /**\n * raster-dem tiles will load for performance the actualZoom - deltaZoom zoom-level.\n */\n deltaZoom: number;\n\n constructor(sourceCache: SourceCache) {\n super();\n this.sourceCache = sourceCache;\n this._tiles = {};\n this._renderableTilesKeys = [];\n this._sourceTileCache = {};\n this.minzoom = 0;\n this.maxzoom = 22;\n this.tileSize = 512;\n this.deltaZoom = 1;\n sourceCache.usedForTerrain = true;\n sourceCache.tileSize = this.tileSize * 2 ** this.deltaZoom;\n }\n\n destruct() {\n this.sourceCache.usedForTerrain = false;\n this.sourceCache.tileSize = null;\n }\n\n /**\n * Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory.\n * @param transform - the operation to do\n * @param terrain - the terrain\n */\n update(transform: Transform, terrain: Terrain): void {\n // load raster-dem tiles for the current scene.\n this.sourceCache.update(transform, terrain);\n // create internal render-to-texture tiles for the current scene.\n this._renderableTilesKeys = [];\n const keys = {};\n for (const tileID of transform.coveringTiles({\n tileSize: this.tileSize,\n minzoom: this.minzoom,\n maxzoom: this.maxzoom,\n reparseOverscaled: false,\n terrain\n })) {\n keys[tileID.key] = true;\n this._renderableTilesKeys.push(tileID.key);\n if (!this._tiles[tileID.key]) {\n tileID.posMatrix = new Float64Array(16) as any;\n mat4.ortho(tileID.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n this._tiles[tileID.key] = new Tile(tileID, this.tileSize);\n }\n }\n // free unused tiles\n for (const key in this._tiles) {\n if (!keys[key]) delete this._tiles[key];\n }\n }\n\n /**\n * Free render to texture cache\n * @param tileID - optional, free only corresponding to tileID.\n */\n freeRtt(tileID?: OverscaledTileID) {\n for (const key in this._tiles) {\n const tile = this._tiles[key];\n if (!tileID || tile.tileID.equals(tileID) || tile.tileID.isChildOf(tileID) || tileID.isChildOf(tile.tileID))\n tile.rtt = [];\n }\n }\n\n /**\n * get a list of tiles, which are loaded and should be rendered in the current scene\n * @returns the renderable tiles\n */\n getRenderableTiles(): Array {\n return this._renderableTilesKeys.map(key => this.getTileByID(key));\n }\n\n /**\n * get terrain tile by the TileID key\n * @param id - the tile id\n * @returns the tile\n */\n getTileByID(id: string): Tile {\n return this._tiles[id];\n }\n\n /**\n * Searches for the corresponding current renderable terrain-tiles\n * @param tileID - the tile to look for\n * @returns the tiles that were found\n */\n getTerrainCoords(tileID: OverscaledTileID): Record {\n const coords = {};\n for (const key of this._renderableTilesKeys) {\n const _tileID = this._tiles[key].tileID;\n if (_tileID.canonical.equals(tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n coords[key] = coord;\n } else if (_tileID.canonical.isChildOf(tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n const dz = _tileID.canonical.z - tileID.canonical.z;\n const dx = _tileID.canonical.x - (_tileID.canonical.x >> dz << dz);\n const dy = _tileID.canonical.y - (_tileID.canonical.y >> dz << dz);\n const size = EXTENT >> dz;\n mat4.ortho(coord.posMatrix, 0, size, 0, size, 0, 1);\n mat4.translate(coord.posMatrix, coord.posMatrix, [-dx * size, -dy * size, 0]);\n coords[key] = coord;\n } else if (tileID.canonical.isChildOf(_tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n const dz = tileID.canonical.z - _tileID.canonical.z;\n const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);\n const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);\n const size = EXTENT >> dz;\n mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n mat4.translate(coord.posMatrix, coord.posMatrix, [dx * size, dy * size, 0]);\n mat4.scale(coord.posMatrix, coord.posMatrix, [1 / (2 ** dz), 1 / (2 ** dz), 0]);\n coords[key] = coord;\n }\n }\n return coords;\n }\n\n /**\n * find the covering raster-dem tile\n * @param tileID - the tile to look for\n * @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem.\n * @returns the tile\n */\n getSourceTile(tileID: OverscaledTileID, searchForDEM?: boolean): Tile {\n const source = this.sourceCache._source;\n let z = tileID.overscaledZ - this.deltaZoom;\n if (z > source.maxzoom) z = source.maxzoom;\n if (z < source.minzoom) return null;\n // cache for tileID to terrain-tileID\n if (!this._sourceTileCache[tileID.key])\n this._sourceTileCache[tileID.key] = tileID.scaledTo(z).key;\n let tile = this.sourceCache.getTileByID(this._sourceTileCache[tileID.key]);\n // during tile-loading phase look if parent tiles (with loaded dem) are available.\n if (!(tile && tile.dem) && searchForDEM)\n while (z >= source.minzoom && !(tile && tile.dem))\n tile = this.sourceCache.getTileByID(tileID.scaledTo(z--).key);\n return tile;\n }\n\n /**\n * get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers.\n * @param time - the time\n * @returns the relevant tiles\n */\n tilesAfterTime(time = Date.now()): Array {\n return Object.values(this._tiles).filter(t => t.timeAdded >= time);\n }\n}\n","\nimport {Tile} from '../source/tile';\nimport {mat4, vec2} from 'gl-matrix';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {RGBAImage} from '../util/image';\nimport {warnOnce} from '../util/util';\nimport {Pos3dArray, TriangleIndexArray} from '../data/array_types.g';\nimport pos3dAttributes from '../data/pos3d_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {VertexBuffer} from '../gl/vertex_buffer';\nimport {IndexBuffer} from '../gl/index_buffer';\nimport {Painter} from './painter';\nimport {Texture} from '../render/texture';\nimport type {Framebuffer} from '../gl/framebuffer';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate, lngFromMercatorX, mercatorXfromLng} from '../geo/mercator_coordinate';\nimport {TerrainSourceCache} from '../source/terrain_source_cache';\nimport {SourceCache} from '../source/source_cache';\nimport {EXTENT} from '../data/extent';\nimport type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {LngLat, earthRadius} from '../geo/lng_lat';\n\n/**\n * @internal\n * A terrain GPU related object\n */\nexport type TerrainData = {\n 'u_depth': number;\n 'u_terrain': number;\n 'u_terrain_dim': number;\n 'u_terrain_matrix': mat4;\n 'u_terrain_unpack': number[];\n 'u_terrain_exaggeration': number;\n texture: WebGLTexture;\n depthTexture: WebGLTexture;\n tile: Tile;\n}\n\n/**\n * @internal\n * A terrain mesh object\n */\nexport type TerrainMesh = {\n indexBuffer: IndexBuffer;\n vertexBuffer: VertexBuffer;\n segments: SegmentVector;\n}\n\n/**\n * @internal\n * This is the main class which handles most of the 3D Terrain logic. It has the following topics:\n * 1) loads raster-dem tiles via the internal sourceCache this.sourceCache\n * 2) creates a depth-framebuffer, which is used to calculate the visibility of coordinates\n * 3) creates a coords-framebuffer, which is used the get to tile-coordinate for a screen-pixel\n * 4) stores all render-to-texture tiles in the this.sourceCache._tiles\n * 5) calculates the elevation for a specific tile-coordinate\n * 6) creates a terrain-mesh\n *\n * A note about the GPU resource-usage:\n * Framebuffers:\n * - one for the depth & coords framebuffer with the size of the map-div.\n * - one for rendering a tile to texture with the size of tileSize (= 512x512).\n * Textures:\n * - one texture for an empty raster-dem tile with size 1x1\n * - one texture for an empty depth-buffer, when terrain is disabled with size 1x1\n * - one texture for an each loaded raster-dem with size of the source.tileSize\n * - one texture for the coords-framebuffer with the size of the map-div.\n * - one texture for the depth-framebuffer with the size of the map-div.\n * - one texture for the encoded tile-coords with the size 2*tileSize (=1024x1024)\n * - finally for each render-to-texture tile (= this._tiles) a set of textures\n * for each render stack (The stack-concept is documented in painter.ts).\n * Normally there exists 1-3 Textures per tile, depending on the stylesheet.\n * Each Textures has the size 2*tileSize (= 1024x1024). Also there exists a\n * cache of the last 150 newest rendered tiles.\n *\n */\nexport class Terrain {\n /**\n * The style this terrain crresponds to\n */\n painter: Painter;\n /**\n * the sourcecache this terrain is based on\n */\n sourceCache: TerrainSourceCache;\n /**\n * the TerrainSpecification object passed to this instance\n */\n options: TerrainSpecification;\n /**\n * define the meshSize per tile.\n */\n meshSize: number;\n /**\n * multiplicator for the elevation. Used to make terrain more \"extreme\".\n */\n exaggeration: number;\n /**\n * to not see pixels in the render-to-texture tiles it is good to render them bigger\n * this number is the multiplicator (must be a power of 2) for the current tileSize.\n * So to get good results with not too much memory footprint a value of 2 should be fine.\n */\n qualityFactor: number;\n /**\n * holds the framebuffer object in size of the screen to render the coords & depth into a texture.\n */\n _fbo: Framebuffer;\n _fboCoordsTexture: Texture;\n _fboDepthTexture: Texture;\n _emptyDepthTexture: Texture;\n /**\n * GL Objects for the terrain-mesh\n * The mesh is a regular mesh, which has the advantage that it can be reused for all tiles.\n */\n _mesh: TerrainMesh;\n /**\n * coords index contains a list of tileID.keys. This index is used to identify\n * the tile via the alpha-cannel in the coords-texture.\n * As the alpha-channel has 1 Byte a max of 255 tiles can rendered without an error.\n */\n coordsIndex: Array;\n /**\n * tile-coords encoded in the rgb channel, _coordsIndex is in the alpha-channel.\n */\n _coordsTexture: Texture;\n /**\n * accuracy of the coords. 2 * tileSize should be enoughth.\n */\n _coordsTextureSize: number;\n /**\n * variables for an empty dem texture, which is used while the raster-dem tile is loading.\n */\n _emptyDemUnpack: number[];\n _emptyDemTexture: Texture;\n _emptyDemMatrix: mat4;\n /**\n * as of overzooming of raster-dem tiles in high zoomlevels, this cache contains\n * matrices to transform from vector-tile coords to raster-dem-tile coords.\n */\n _demMatrixCache: {[_: string]: { matrix: mat4; coord: OverscaledTileID }};\n\n constructor(painter: Painter, sourceCache: SourceCache, options: TerrainSpecification) {\n this.painter = painter;\n this.sourceCache = new TerrainSourceCache(sourceCache);\n this.options = options;\n this.exaggeration = typeof options.exaggeration === 'number' ? options.exaggeration : 1.0;\n this.qualityFactor = 2;\n this.meshSize = 128;\n this._demMatrixCache = {};\n this.coordsIndex = [];\n this._coordsTextureSize = 1024;\n }\n\n /**\n * get the elevation-value from original dem-data for a given tile-coordinate\n * @param tileID - the tile to get elevation for\n * @param x - between 0 .. EXTENT\n * @param y - between 0 .. EXTENT\n * @param extent - optional, default 8192\n * @returns the elevation\n */\n getDEMElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {\n if (!(x >= 0 && x < extent && y >= 0 && y < extent)) return 0;\n const terrain = this.getTerrainData(tileID);\n const dem = terrain.tile?.dem;\n if (!dem)\n return 0;\n\n const pos = vec2.transformMat4([] as any, [x / extent * EXTENT, y / extent * EXTENT], terrain.u_terrain_matrix);\n const coord = [pos[0] * dem.dim, pos[1] * dem.dim];\n\n // bilinear interpolation\n const cx = Math.floor(coord[0]),\n cy = Math.floor(coord[1]),\n tx = coord[0] - cx,\n ty = coord[1] - cy;\n return (\n dem.get(cx, cy) * (1 - tx) * (1 - ty) +\n dem.get(cx + 1, cy) * (tx) * (1 - ty) +\n dem.get(cx, cy + 1) * (1 - tx) * (ty) +\n dem.get(cx + 1, cy + 1) * (tx) * (ty)\n );\n }\n\n /**\n * Get the elevation for given {@link LngLat} in respect of exaggeration.\n * @param lnglat - the location\n * @param zoom - the zoom\n * @returns the elevation\n */\n getElevationForLngLatZoom(lnglat: LngLat, zoom: number) {\n const {tileID, mercatorX, mercatorY} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);\n return this.getElevation(tileID, mercatorX % EXTENT, mercatorY % EXTENT, EXTENT);\n }\n\n /**\n * Get the elevation for given coordinate in respect of exaggeration.\n * @param tileID - the tile id\n * @param x - between 0 .. EXTENT\n * @param y - between 0 .. EXTENT\n * @param extent - optional, default 8192\n * @returns the elevation\n */\n getElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {\n return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration;\n }\n\n /**\n * returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object\n * @param tileID - the tile to get the terrain for\n * @returns the terrain data to use in the program\n */\n getTerrainData(tileID: OverscaledTileID): TerrainData {\n // create empty DEM Objects, which will used while raster-dem tiles are loading.\n // creates an empty depth-buffer texture which is needed, during the initialization process of the 3d mesh..\n if (!this._emptyDemTexture) {\n const context = this.painter.context;\n const image = new RGBAImage({width: 1, height: 1}, new Uint8Array(1 * 4));\n this._emptyDepthTexture = new Texture(context, image, context.gl.RGBA, {premultiply: false});\n this._emptyDemUnpack = [0, 0, 0, 0];\n this._emptyDemTexture = new Texture(context, new RGBAImage({width: 1, height: 1}), context.gl.RGBA, {premultiply: false});\n this._emptyDemTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n this._emptyDemMatrix = mat4.identity([] as any);\n }\n // find covering dem tile and prepare demTexture\n const sourceTile = this.sourceCache.getSourceTile(tileID, true);\n if (sourceTile && sourceTile.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) {\n const context = this.painter.context;\n sourceTile.demTexture = this.painter.getTileTexture(sourceTile.dem.stride);\n if (sourceTile.demTexture) sourceTile.demTexture.update(sourceTile.dem.getPixels(), {premultiply: false});\n else sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, {premultiply: false});\n sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n sourceTile.needsTerrainPrepare = false;\n }\n // create matrix for lookup in dem data\n const matrixKey = sourceTile && (sourceTile + sourceTile.tileID.key) + tileID.key;\n if (matrixKey && !this._demMatrixCache[matrixKey]) {\n const maxzoom = this.sourceCache.sourceCache._source.maxzoom;\n let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;\n if (tileID.overscaledZ > tileID.canonical.z) {\n if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;\n else warnOnce('cannot calculate elevation if elevation maxzoom > source.maxzoom');\n }\n const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);\n const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);\n const demMatrix = mat4.fromScaling(new Float64Array(16) as any, [1 / (EXTENT << dz), 1 / (EXTENT << dz), 0]);\n mat4.translate(demMatrix, demMatrix, [dx * EXTENT, dy * EXTENT, 0]);\n this._demMatrixCache[tileID.key] = {matrix: demMatrix, coord: tileID};\n }\n // return uniform values & textures\n return {\n 'u_depth': 2,\n 'u_terrain': 3,\n 'u_terrain_dim': sourceTile && sourceTile.dem && sourceTile.dem.dim || 1,\n 'u_terrain_matrix': matrixKey ? this._demMatrixCache[tileID.key].matrix : this._emptyDemMatrix,\n 'u_terrain_unpack': sourceTile && sourceTile.dem && sourceTile.dem.getUnpackVector() || this._emptyDemUnpack,\n 'u_terrain_exaggeration': this.exaggeration,\n texture: (sourceTile && sourceTile.demTexture || this._emptyDemTexture).texture,\n depthTexture: (this._fboDepthTexture || this._emptyDepthTexture).texture,\n tile: sourceTile\n };\n }\n\n /**\n * get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture\n * @param texture - the texture\n * @returns the frame buffer\n */\n getFramebuffer(texture: string): Framebuffer {\n const painter = this.painter;\n const width = painter.width / devicePixelRatio;\n const height = painter.height / devicePixelRatio;\n if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) {\n this._fbo.destroy();\n this._fboCoordsTexture.destroy();\n this._fboDepthTexture.destroy();\n delete this._fbo;\n delete this._fboDepthTexture;\n delete this._fboCoordsTexture;\n }\n if (!this._fboCoordsTexture) {\n this._fboCoordsTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});\n this._fboCoordsTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);\n }\n if (!this._fboDepthTexture) {\n this._fboDepthTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});\n this._fboDepthTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);\n }\n if (!this._fbo) {\n this._fbo = painter.context.createFramebuffer(width, height, true, false);\n this._fbo.depthAttachment.set(painter.context.createRenderbuffer(painter.context.gl.DEPTH_COMPONENT16, width, height));\n }\n this._fbo.colorAttachment.set(texture === 'coords' ? this._fboCoordsTexture.texture : this._fboDepthTexture.texture);\n return this._fbo;\n }\n\n /**\n * create coords texture, needed to grab coordinates from canvas\n * encode coords coordinate into 4 bytes:\n * - 8 lower bits for x\n * - 8 lower bits for y\n * - 4 higher bits for x\n * - 4 higher bits for y\n * - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value\n * @returns the texture\n */\n getCoordsTexture(): Texture {\n const context = this.painter.context;\n if (this._coordsTexture) return this._coordsTexture;\n const data = new Uint8Array(this._coordsTextureSize * this._coordsTextureSize * 4);\n for (let y = 0, i = 0; y < this._coordsTextureSize; y++) for (let x = 0; x < this._coordsTextureSize; x++, i += 4) {\n data[i + 0] = x & 255;\n data[i + 1] = y & 255;\n data[i + 2] = ((x >> 8) << 4) | (y >> 8);\n data[i + 3] = 0;\n }\n const image = new RGBAImage({width: this._coordsTextureSize, height: this._coordsTextureSize}, new Uint8Array(data.buffer));\n const texture = new Texture(context, image, context.gl.RGBA, {premultiply: false});\n texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n this._coordsTexture = texture;\n return texture;\n }\n\n /**\n * Reads a pixel from the coords-framebuffer and translate this to mercator.\n * @param p - Screen-Coordinate\n * @returns mercator coordinate for a screen pixel\n */\n pointCoordinate(p: Point): MercatorCoordinate {\n const rgba = new Uint8Array(4);\n const context = this.painter.context, gl = context.gl;\n // grab coordinate pixel from coordinates framebuffer\n context.bindFramebuffer.set(this.getFramebuffer('coords').framebuffer);\n gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);\n context.bindFramebuffer.set(null);\n // decode coordinates (encoding see getCoordsTexture)\n const x = rgba[0] + ((rgba[2] >> 4) << 8);\n const y = rgba[1] + ((rgba[2] & 15) << 8);\n const tileID = this.coordsIndex[255 - rgba[3]];\n const tile = tileID && this.sourceCache.getTileByID(tileID);\n if (!tile) return null;\n const coordsSize = this._coordsTextureSize;\n const worldSize = (1 << tile.tileID.canonical.z) * coordsSize;\n const mercatorX = (tile.tileID.canonical.x * coordsSize + x) / worldSize;\n return new MercatorCoordinate(\n this._allowMercatorOverflow(p, mercatorX),\n (tile.tileID.canonical.y * coordsSize + y) / worldSize,\n this.getElevation(tile.tileID, x, y, coordsSize)\n );\n }\n\n /**\n * create a regular mesh which will be used by all terrain-tiles\n * @returns the created regular mesh\n */\n getTerrainMesh(): TerrainMesh {\n if (this._mesh) return this._mesh;\n const context = this.painter.context;\n const vertexArray = new Pos3dArray();\n const indexArray = new TriangleIndexArray();\n const meshSize = this.meshSize;\n const delta = EXTENT / meshSize;\n const meshSize2 = meshSize * meshSize;\n for (let y = 0; y <= meshSize; y++) for (let x = 0; x <= meshSize; x++)\n vertexArray.emplaceBack(x * delta, y * delta, 0);\n for (let y = 0; y < meshSize2; y += meshSize + 1) for (let x = 0; x < meshSize; x++) {\n indexArray.emplaceBack(x + y, meshSize + x + y + 1, meshSize + x + y + 2);\n indexArray.emplaceBack(x + y, meshSize + x + y + 2, x + y + 1);\n }\n // add an extra frame around the mesh to avoid stiching on tile boundaries with different zoomlevels\n // first code-block is for top-bottom frame and second for left-right frame\n const offsetTop = vertexArray.length, offsetBottom = offsetTop + (meshSize + 1) * 2;\n for (const y of [0, 1]) for (let x = 0; x <= meshSize; x++) for (const z of [0, 1])\n vertexArray.emplaceBack(x * delta, y * EXTENT, z);\n for (let x = 0; x < meshSize * 2; x += 2) {\n indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 1, offsetBottom + x + 3);\n indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 3, offsetBottom + x + 2);\n indexArray.emplaceBack(offsetTop + x, offsetTop + x + 3, offsetTop + x + 1);\n indexArray.emplaceBack(offsetTop + x, offsetTop + x + 2, offsetTop + x + 3);\n }\n const offsetLeft = vertexArray.length, offsetRight = offsetLeft + (meshSize + 1) * 2;\n for (const x of [0, 1]) for (let y = 0; y <= meshSize; y++) for (const z of [0, 1])\n vertexArray.emplaceBack(x * EXTENT, y * delta, z);\n for (let y = 0; y < meshSize * 2; y += 2) {\n indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 1, offsetLeft + y + 3);\n indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 3, offsetLeft + y + 2);\n indexArray.emplaceBack(offsetRight + y, offsetRight + y + 3, offsetRight + y + 1);\n indexArray.emplaceBack(offsetRight + y, offsetRight + y + 2, offsetRight + y + 3);\n }\n this._mesh = {\n indexBuffer: context.createIndexBuffer(indexArray),\n vertexBuffer: context.createVertexBuffer(vertexArray, pos3dAttributes.members),\n segments: SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length)\n };\n return this._mesh;\n }\n\n /**\n * Calculates a height of the frame around the terrain-mesh to avoid stiching between\n * tile boundaries in different zoomlevels.\n * @param zoom - current zoomlevel\n * @returns the elevation delta in meters\n */\n getMeshFrameDelta(zoom: number): number {\n // divide by 5 is evaluated by trial & error to get a frame in the right height\n return 2 * Math.PI * earthRadius / Math.pow(2, zoom) / 5;\n }\n\n getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number) {\n const {tileID} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);\n return this.getMinMaxElevation(tileID).minElevation ?? 0;\n }\n\n /**\n * Get the minimum and maximum elevation contained in a tile. This includes any\n * exaggeration included in the terrain.\n *\n * @param tileID - ID of the tile to be used as a source for the min/max elevation\n * @returns the minimum and maximum elevation found in the tile, including the terrain's\n * exaggeration\n */\n getMinMaxElevation(tileID: OverscaledTileID): {minElevation: number | null; maxElevation: number | null} {\n const tile = this.getTerrainData(tileID).tile;\n const minMax = {minElevation: null, maxElevation: null};\n if (tile && tile.dem) {\n minMax.minElevation = tile.dem.min * this.exaggeration;\n minMax.maxElevation = tile.dem.max * this.exaggeration;\n }\n return minMax;\n }\n\n _getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { tileID: OverscaledTileID; mercatorX: number; mercatorY: number} {\n const mercatorCoordinate = MercatorCoordinate.fromLngLat(lnglat.wrap());\n const worldSize = (1 << zoom) * EXTENT;\n const mercatorX = mercatorCoordinate.x * worldSize;\n const mercatorY = mercatorCoordinate.y * worldSize;\n const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);\n const tileID = new OverscaledTileID(zoom, 0, zoom, tileX, tileY);\n return {\n tileID,\n mercatorX,\n mercatorY\n };\n }\n\n _allowMercatorOverflow(p: Point, mercatorX: number): number {\n const inLeftHalf = p.x < (this.painter.width / 2);\n let lng = lngFromMercatorX(mercatorX);\n const centerLng = this.painter.transform.center.lng;\n if (\n (inLeftHalf && Math.sign(lng) > 0 && Math.sign(centerLng) < 0) ||\n (!inLeftHalf && Math.sign(lng) < 0 && Math.sign(centerLng) > 0)\n ) {\n lng = 360 * Math.sign(centerLng) + lng;\n return mercatorXfromLng(lng);\n }\n return mercatorX;\n }\n}\n","import {Texture} from '../render/texture';\nimport {Context} from './context';\nimport {Framebuffer} from './framebuffer';\n\nexport type PoolObject = {\n id: number;\n fbo: Framebuffer;\n texture: Texture;\n stamp: number;\n inUse: boolean;\n};\n/**\n * @internal\n * `RenderPool` is a resource pool for textures and framebuffers\n */\nexport class RenderPool {\n private _objects: Array;\n /**\n * An index array of recently used pool objects.\n * Items that are used recently are last in the array\n */\n private _recentlyUsed: Array;\n private _stamp: number;\n\n constructor(\n private readonly _context: Context,\n private readonly _size: number,\n private readonly _tileSize: number) {\n this._objects = [];\n this._recentlyUsed = [];\n this._stamp = 0;\n }\n\n public destruct() {\n for (const obj of this._objects) {\n obj.texture.destroy();\n obj.fbo.destroy();\n }\n }\n\n private _createObject(id: number): PoolObject {\n const fbo = this._context.createFramebuffer(this._tileSize, this._tileSize, true, true);\n const texture = new Texture(this._context, {width: this._tileSize, height: this._tileSize, data: null}, this._context.gl.RGBA);\n texture.bind(this._context.gl.LINEAR, this._context.gl.CLAMP_TO_EDGE);\n fbo.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL, this._tileSize, this._tileSize));\n fbo.colorAttachment.set(texture.texture);\n return {id, fbo, texture, stamp: -1, inUse: false};\n }\n\n public getObjectForId(id: number): PoolObject {\n return this._objects[id];\n }\n\n public useObject(obj: PoolObject) {\n obj.inUse = true;\n this._recentlyUsed = this._recentlyUsed.filter(id => obj.id !== id);\n this._recentlyUsed.push(obj.id);\n }\n\n public stampObject(obj: PoolObject) {\n obj.stamp = ++this._stamp;\n }\n\n public getOrCreateFreeObject(): PoolObject {\n // check for free existing object\n for (const id of this._recentlyUsed) {\n if (!this._objects[id].inUse)\n return this._objects[id];\n }\n if (this._objects.length >= this._size)\n throw new Error('No free RenderPool available, call freeAllObjects() required!');\n // create new object\n const obj = this._createObject(this._objects.length);\n this._objects.push(obj);\n return obj;\n }\n\n public freeObject(obj: PoolObject) {\n obj.inUse = false;\n }\n\n public freeAllObjects() {\n for (const obj of this._objects)\n this.freeObject(obj);\n }\n\n public isFull(): boolean {\n if (this._objects.length < this._size) {\n return false;\n }\n return this._objects.some(o => !o.inUse) === false;\n }\n}\n","import {Painter} from './painter';\nimport {Tile} from '../source/tile';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {drawTerrain} from './draw_terrain';\nimport {Style} from '../style/style';\nimport {Terrain} from './terrain';\nimport {RenderPool} from '../gl/render_pool';\nimport {Texture} from './texture';\nimport type {StyleLayer} from '../style/style_layer';\n\n/**\n * lookup table which layers should rendered to texture\n */\nconst LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {\n background: true,\n fill: true,\n line: true,\n raster: true,\n hillshade: true\n};\n\n/**\n * @internal\n * A helper class to help define what should be rendered to texture and how\n */\nexport class RenderToTexture {\n painter: Painter;\n terrain: Terrain;\n pool: RenderPool;\n /**\n * coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile\n * e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile\n */\n _coordsDescendingInv: {[_: string]: {[_:string]: Array}};\n /**\n * create a string representation of all to tiles rendered to render-to-texture tiles\n * this string representation is used to check if tile should be re-rendered.\n */\n _coordsDescendingInvStr: {[_: string]: {[_:string]: string}};\n /**\n * store for render-stacks\n * a render stack is a set of layers which should be rendered into one texture\n * every stylesheet can have multiple stacks. A new stack is created if layers which should\n * not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols\n */\n _stacks: Array>;\n /**\n * remember the previous processed layer to check if a new stack is needed\n */\n _prevType: string;\n /**\n * a list of tiles that can potentially rendered\n */\n _renderableTiles: Array;\n /**\n * a list of tiles that should be rendered to screen in the next render-call\n */\n _rttTiles: Array;\n /**\n * a list of all layer-ids which should be rendered\n */\n _renderableLayerIds: Array;\n\n constructor(painter: Painter, terrain: Terrain) {\n this.painter = painter;\n this.terrain = terrain;\n this.pool = new RenderPool(painter.context, 30, terrain.sourceCache.tileSize * terrain.qualityFactor);\n }\n\n destruct() {\n this.pool.destruct();\n }\n\n getTexture(tile: Tile): Texture {\n return this.pool.getObjectForId(tile.rtt[this._stacks.length - 1].id).texture;\n }\n\n prepareForRender(style: Style, zoom: number) {\n this._stacks = [];\n this._prevType = null;\n this._rttTiles = [];\n this._renderableTiles = this.terrain.sourceCache.getRenderableTiles();\n this._renderableLayerIds = style._order.filter(id => !style._layers[id].isHidden(zoom));\n\n this._coordsDescendingInv = {};\n for (const id in style.sourceCaches) {\n this._coordsDescendingInv[id] = {};\n const tileIDs = style.sourceCaches[id].getVisibleCoordinates();\n for (const tileID of tileIDs) {\n const keys = this.terrain.sourceCache.getTerrainCoords(tileID);\n for (const key in keys) {\n if (!this._coordsDescendingInv[id][key]) this._coordsDescendingInv[id][key] = [];\n this._coordsDescendingInv[id][key].push(keys[key]);\n }\n }\n }\n\n this._coordsDescendingInvStr = {};\n for (const id of style._order) {\n const layer = style._layers[id], source = layer.source;\n if (LAYERS[layer.type]) {\n if (!this._coordsDescendingInvStr[source]) {\n this._coordsDescendingInvStr[source] = {};\n for (const key in this._coordsDescendingInv[source])\n this._coordsDescendingInvStr[source][key] = this._coordsDescendingInv[source][key].map(c => c.key).sort().join();\n }\n }\n }\n\n // check tiles to render\n for (const tile of this._renderableTiles) {\n for (const source in this._coordsDescendingInvStr) {\n // rerender if there are more coords to render than in the last rendering\n const coords = this._coordsDescendingInvStr[source][tile.tileID.key];\n if (coords && coords !== tile.rttCoords[source]) tile.rtt = [];\n }\n }\n }\n\n /**\n * due that switching textures is relatively slow, the render\n * layer-by-layer context is not practicable. To bypass this problem\n * this lines of code stack all layers and later render all at once.\n * Because of the stylesheet possibility to mixing render-to-texture layers\n * and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example\n * a symbol-layer is in between of fill-layers.\n * @param layer - the layer to render\n * @returns if true layer is rendered to texture, otherwise false\n */\n renderLayer(layer: StyleLayer): boolean {\n if (layer.isHidden(this.painter.transform.zoom)) return false;\n\n const type = layer.type;\n const painter = this.painter;\n const isLastLayer = this._renderableLayerIds[this._renderableLayerIds.length - 1] === layer.id;\n\n // remember background, fill, line & raster layer to render into a stack\n if (LAYERS[type]) {\n // create a new stack if previous layer was not rendered to texture (f.e. symbols)\n if (!this._prevType || !LAYERS[this._prevType]) this._stacks.push([]);\n // push current render-to-texture layer to render-stack\n this._prevType = type;\n this._stacks[this._stacks.length - 1].push(layer.id);\n // rendering is done later, all in once\n if (!isLastLayer) return true;\n }\n\n // in case a stack is finished render all collected stack-layers into a texture\n if (LAYERS[this._prevType] || (LAYERS[type] && isLastLayer)) {\n this._prevType = type;\n const stack = this._stacks.length - 1, layers = this._stacks[stack] || [];\n for (const tile of this._renderableTiles) {\n // if render pool is full draw current tiles to screen and free pool\n if (this.pool.isFull()) {\n drawTerrain(this.painter, this.terrain, this._rttTiles);\n this._rttTiles = [];\n this.pool.freeAllObjects();\n }\n this._rttTiles.push(tile);\n // check for cached PoolObject\n if (tile.rtt[stack]) {\n const obj = this.pool.getObjectForId(tile.rtt[stack].id);\n if (obj.stamp === tile.rtt[stack].stamp) {\n this.pool.useObject(obj);\n continue;\n }\n }\n // get free PoolObject\n const obj = this.pool.getOrCreateFreeObject();\n this.pool.useObject(obj);\n this.pool.stampObject(obj);\n tile.rtt[stack] = {id: obj.id, stamp: obj.stamp};\n // prepare PoolObject for rendering\n painter.context.bindFramebuffer.set(obj.fbo.framebuffer);\n painter.context.clear({color: Color.transparent, stencil: 0});\n painter.currentStencilSource = undefined;\n for (let l = 0; l < layers.length; l++) {\n const layer = painter.style._layers[layers[l]];\n const coords = layer.source ? this._coordsDescendingInv[layer.source][tile.tileID.key] : [tile.tileID];\n painter.context.viewport.set([0, 0, obj.fbo.width, obj.fbo.height]);\n painter._renderTileClippingMasks(layer, coords);\n painter.renderLayer(painter, painter.style.sourceCaches[layer.source], layer, coords);\n if (layer.source) tile.rttCoords[layer.source] = this._coordsDescendingInvStr[layer.source][tile.tileID.key];\n }\n }\n drawTerrain(this.painter, this.terrain, this._rttTiles);\n this._rttTiles = [];\n this.pool.freeAllObjects();\n\n return LAYERS[type];\n }\n\n return false;\n }\n\n}\n","import {extend, warnOnce, uniqueId, isImageBitmap} from '../util/util';\nimport {browser} from '../util/browser';\nimport {DOM} from '../util/dom';\nimport packageJSON from '../../package.json' assert {type: 'json'};\n\nimport {getJSON} from '../util/ajax';\nimport {ImageRequest} from '../util/image_request';\nimport type {GetImageCallback} from '../util/image_request';\n\nimport {RequestManager, ResourceType} from '../util/request_manager';\nimport {Style, StyleSwapOptions} from '../style/style';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {Painter} from '../render/painter';\nimport {Transform} from '../geo/transform';\nimport {Hash} from './hash';\nimport {HandlerManager} from './handler_manager';\nimport {Camera, CameraOptions, CameraUpdateTransformFunction, FitBoundsOptions} from './camera';\nimport {LngLat} from '../geo/lng_lat';\nimport {LngLatBounds} from '../geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {AttributionControl} from './control/attribution_control';\nimport {LogoControl} from './control/logo_control';\n\nimport {RGBAImage} from '../util/image';\nimport {Event, ErrorEvent, Listener} from '../util/evented';\nimport {MapEventType, MapLayerEventType, MapMouseEvent, MapSourceDataEvent, MapStyleDataEvent} from './events';\nimport {TaskQueue} from '../util/task_queue';\nimport {throttle} from '../util/throttle';\nimport {webpSupported} from '../util/webp_supported';\nimport {PerformanceMarkers, PerformanceUtils} from '../util/performance';\nimport {Source, SourceClass} from '../source/source';\nimport {StyleLayer} from '../style/style_layer';\n\nimport type {RequestTransformFunction} from '../util/request_manager';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport type {AddLayerObject, FeatureIdentifier, StyleOptions, StyleSetterOptions} from '../style/style';\nimport type {MapDataEvent} from './events';\nimport type {StyleImage, StyleImageInterface, StyleImageMetadata} from '../style/style_image';\nimport type {PointLike} from './camera';\nimport type {ScrollZoomHandler} from './handler/scroll_zoom';\nimport type {BoxZoomHandler} from './handler/box_zoom';\nimport type {AroundCenterOptions, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';\nimport type {DragRotateHandler} from './handler/shim/drag_rotate';\nimport {DragPanHandler, DragPanOptions} from './handler/shim/drag_pan';\n\nimport type {KeyboardHandler} from './handler/keyboard';\nimport type {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';\nimport type {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';\nimport {defaultLocale} from './default_locale';\nimport type {TaskID} from '../util/task_queue';\nimport type {Cancelable} from '../types/cancelable';\nimport type {\n FilterSpecification,\n StyleSpecification,\n LightSpecification,\n SourceSpecification,\n TerrainSpecification\n} from '@maplibre/maplibre-gl-style-spec';\n\nimport {Callback} from '../types/callback';\nimport type {ControlPosition, IControl} from './control/control';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {Terrain} from '../render/terrain';\nimport {RenderToTexture} from '../render/render_to_texture';\nimport {config} from '../util/config';\nimport type {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions} from '../source/query_features';\n\nconst version = packageJSON.version;\n\n/**\n * The {@link Map} options object.\n */\nexport type MapOptions = {\n /**\n * If `true`, the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL.\n * For example, `http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60`.\n * An additional string may optionally be provided to indicate a parameter-styled hash,\n * e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar, where foo\n * is a custom parameter and bar is an arbitrary hash distinct from the map hash.\n * @defaultValue false\n */\n hash?: boolean | string;\n /**\n * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.\n * @defaultValue true\n */\n interactive?: boolean;\n /**\n * The HTML element in which MapLibre GL JS will render the map, or the element's string `id`. The specified element must have no children.\n */\n container: HTMLElement | string;\n /**\n * The threshold, measured in degrees, that determines when the map's\n * bearing will snap to north. For example, with a `bearingSnap` of 7, if the user rotates\n * the map within 7 degrees of north, the map will automatically snap to exact north.\n * @defaultValue 7\n */\n bearingSnap?: number;\n /**\n * If `true`, an {@link AttributionControl} will be added to the map.\n * @defaultValue true\n */\n attributionControl?: boolean;\n /**\n * Attribution text to show in an {@link AttributionControl}. Only applicable if `options.attributionControl` is `true`.\n */\n customAttribution?: string | Array;\n /**\n * If `true`, the MapLibre logo will be shown.\n * @defaultValue false\n */\n maplibreLogo?: boolean;\n /**\n * A string representing the position of the MapLibre wordmark on the map. Valid options are `top-left`,`top-right`, `bottom-left`, or `bottom-right`.\n * @defaultValue 'bottom-left'\n */\n logoPosition?: ControlPosition;\n /**\n * If `true`, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected\n * (i.e. a software renderer would be used).\n * @defaultValue false\n */\n failIfMajorPerformanceCaveat?: boolean;\n /**\n * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization.\n * @defaultValue false\n */\n preserveDrawingBuffer?: boolean;\n /**\n * If `true`, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. This is `false` by default as a performance optimization.\n */\n antialias?: boolean;\n /**\n * If `false`, the map won't attempt to re-request tiles once they expire per their HTTP `cacheControl`/`expires` headers.\n * @defaultValue true\n */\n refreshExpiredTiles?: boolean;\n /**\n * If set, the map will be constrained to the given bounds.\n */\n maxBounds?: LngLatBoundsLike;\n /**\n * If `true`, the \"scroll to zoom\" interaction is enabled. {@link AroundCenterOptions} are passed as options to {@link ScrollZoomHandler#enable}.\n * @defaultValue true\n */\n scrollZoom?: boolean | AroundCenterOptions;\n /**\n * The minimum zoom level of the map (0-24).\n * @defaultValue 0\n */\n minZoom?: number | null;\n /**\n * The maximum zoom level of the map (0-24).\n * @defaultValue 22\n */\n maxZoom?: number | null;\n /**\n * The minimum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 0\n */\n minPitch?: number | null;\n /**\n * The maximum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 60\n */\n maxPitch?: number | null;\n /**\n * If `true`, the \"box zoom\" interaction is enabled (see {@link BoxZoomHandler}).\n * @defaultValue true\n */\n boxZoom?: boolean;\n /**\n * If `true`, the \"drag to rotate\" interaction is enabled (see {@link DragRotateHandler}).\n * @defaultValue true\n */\n dragRotate?: boolean;\n /**\n * If `true`, the \"drag to pan\" interaction is enabled. An `Object` value is passed as options to {@link DragPanHandler#enable}.\n * @defaultValue true\n */\n dragPan?: boolean | DragPanOptions;\n /**\n * If `true`, keyboard shortcuts are enabled (see {@link KeyboardHandler}).\n * @defaultValue true\n */\n keyboard?: boolean;\n /**\n * If `true`, the \"double click to zoom\" interaction is enabled (see {@link DoubleClickZoomHandler}).\n * @defaultValue true\n */\n doubleClickZoom?: boolean;\n /**\n * If `true`, the \"pinch to rotate and zoom\" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchZoomRotateHandler#enable}.\n * @defaultValue true\n */\n touchZoomRotate?: boolean | AroundCenterOptions;\n /**\n * If `true`, the \"drag to pitch\" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchPitchHandler#enable}.\n * @defaultValue true\n */\n touchPitch?: boolean | AroundCenterOptions;\n /**\n * If `true` or set to an options object, the map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, \"drag to pitch\" requires a three-finger gesture. Cooperative gestures are disabled when a map enters fullscreen using {@link FullscreenControl}.\n * @defaultValue undefined\n */\n cooperativeGestures?: boolean | GestureOptions;\n /**\n * If `true`, the map will automatically resize when the browser window resizes.\n * @defaultValue true\n */\n trackResize?: boolean;\n /**\n * The initial geographical centerpoint of the map. If `center` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.\n * @defaultValue [0, 0]\n */\n center?: LngLatLike;\n /**\n * The initial zoom level of the map. If `zoom` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.\n * @defaultValue 0\n */\n zoom?: number;\n /**\n * The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If `bearing` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.\n * @defaultValue 0\n */\n bearing?: number;\n /**\n * The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If `pitch` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 0\n */\n pitch?: number;\n /**\n * If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n * @defaultValue true\n */\n renderWorldCopies?: boolean;\n /**\n * The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport which can be set using `maxTileCacheZoomLevels` constructor options.\n * @defaultValue null\n */\n maxTileCacheSize?: number;\n /**\n * The maximum number of zoom levels for which to store tiles for a given source. Tile cache dynamic size is calculated by multiplying `maxTileCacheZoomLevels` with the approximate number of tiles in the viewport for a given source.\n * @defaultValue 5\n */\n maxTileCacheZoomLevels?: number;\n /**\n * A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.\n * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties.\n */\n transformRequest?: RequestTransformFunction;\n /**\n * A callback run before the map's camera is moved due to user input or animation. The callback can be used to modify the new center, zoom, pitch and bearing.\n * Expected to return an object containing center, zoom, pitch or bearing values to overwrite.\n */\n transformCameraUpdate?: CameraUpdateTransformFunction;\n /**\n * A patch to apply to the default localization table for UI strings, e.g. control tooltips. The `locale` object maps namespaced UI string IDs to translated strings in the target language; see `src/ui/default_locale.js` for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table).\n * @defaultValue null\n */\n locale?: any;\n /**\n * Controls the duration of the fade-in/fade-out animation for label collisions after initial map load, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading.\n * @defaultValue 300\n */\n fadeDuration?: number;\n /**\n * If `true`, symbols from multiple sources can collide with each other during collision detection. If `false`, collision detection is run separately for the symbols in each source.\n * @defaultValue true\n */\n crossSourceCollisions?: boolean;\n /**\n * If `true`, Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers (this information is normally inaccessible from the main Javascript thread). Information will be returned in a `resourceTiming` property of relevant `data` events.\n * @defaultValue false\n */\n collectResourceTiming?: boolean;\n /**\n * The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag).\n * @defaultValue true\n */\n clickTolerance?: number;\n /**\n * The initial bounds of the map. If `bounds` is specified, it overrides `center` and `zoom` constructor options.\n */\n bounds?: LngLatBoundsLike;\n /**\n * A {@link FitBoundsOptions} options object to use _only_ when fitting the initial `bounds` provided above.\n */\n fitBoundsOptions?: FitBoundsOptions;\n /**\n * Defines a CSS\n * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.\n * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).\n * Set to `false`, to enable font settings from the map's style for these glyph ranges.\n * The purpose of this option is to avoid bandwidth-intensive glyph server requests. (See [Use locally generated ideographs](https://maplibre.org/maplibre-gl-js/docs/examples/local-ideographs).)\n * @defaultValue 'sans-serif'\n */\n localIdeographFontFamily?: string;\n /**\n * The map's MapLibre style. This must be a JSON object conforming to\n * the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/),\n * or a URL to such JSON.\n */\n style: StyleSpecification | string;\n /**\n * If `false`, the map's pitch (tilt) control with \"drag to rotate\" interaction will be disabled.\n * @defaultValue true\n */\n pitchWithRotate?: boolean;\n /**\n * The pixel ratio. The canvas' `width` attribute will be `container.clientWidth * pixelRatio` and its `height` attribute will be `container.clientHeight * pixelRatio`. Defaults to `devicePixelRatio` if not specified.\n */\n pixelRatio?: number;\n /**\n * If false, style validation will be skipped. Useful in production environment.\n * @defaultValue true\n */\n validateStyle?: boolean;\n /**\n * The canvas' `width` and `height` max size. The values are passed as an array where the first element is max width and the second element is max height.\n * You shouldn't set this above WebGl `MAX_TEXTURE_SIZE`. Defaults to [4096, 4096].\n */\n maxCanvasSize?: [number, number];\n};\n\n/**\n * An options object for the gesture settings\n * @example\n * ```ts\n * let options = {\n * windowsHelpText: \"Use Ctrl + scroll to zoom the map\",\n * macHelpText: \"Use ⌘ + scroll to zoom the map\",\n * mobileHelpText: \"Use two fingers to move the map\",\n * }\n * ```\n */\nexport type GestureOptions = {\n windowsHelpText?: string;\n macHelpText?: string;\n mobileHelpText?: string;\n};\n\nexport type AddImageOptions = {\n\n}\n\n// See article here: https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585\ntype Complete = {\n [P in keyof Required]: Pick extends Required> ? T[P] : (T[P] | undefined);\n}\n\n// This type is used inside map since all properties are assigned a default value.\nexport type CompleteMapOptions = Complete;\n\nconst defaultMinZoom = -2;\nconst defaultMaxZoom = 22;\n\n// the default values, but also the valid range\nconst defaultMinPitch = 0;\nconst defaultMaxPitch = 60;\n\n// use this variable to check maxPitch for validity\nconst maxPitchThreshold = 85;\n\nconst defaultOptions = {\n center: [0, 0],\n zoom: 0,\n bearing: 0,\n pitch: 0,\n\n minZoom: defaultMinZoom,\n maxZoom: defaultMaxZoom,\n\n minPitch: defaultMinPitch,\n maxPitch: defaultMaxPitch,\n\n interactive: true,\n scrollZoom: true,\n boxZoom: true,\n dragRotate: true,\n dragPan: true,\n keyboard: true,\n doubleClickZoom: true,\n touchZoomRotate: true,\n touchPitch: true,\n cooperativeGestures: undefined,\n\n bearingSnap: 7,\n clickTolerance: 3,\n pitchWithRotate: true,\n\n hash: false,\n attributionControl: true,\n maplibreLogo: false,\n\n failIfMajorPerformanceCaveat: false,\n preserveDrawingBuffer: false,\n trackResize: true,\n renderWorldCopies: true,\n refreshExpiredTiles: true,\n maxTileCacheSize: null,\n maxTileCacheZoomLevels: config.MAX_TILE_CACHE_ZOOM_LEVELS,\n localIdeographFontFamily: 'sans-serif',\n transformRequest: null,\n transformCameraUpdate: null,\n fadeDuration: 300,\n crossSourceCollisions: true,\n validateStyle: true,\n /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */\n maxCanvasSize: [4096, 4096]\n} as CompleteMapOptions;\n\n/**\n * The `Map` object represents the map on your page. It exposes methods\n * and properties that enable you to programmatically change the map,\n * and fires events as users interact with it.\n *\n * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list.\n * Then MapLibre GL JS initializes the map on the page and returns your `Map` object.\n *\n * @group Main\n *\n * @example\n * ```ts\n * let map = new maplibregl.Map({\n * container: 'map',\n * center: [-122.420679, 37.772537],\n * zoom: 13,\n * style: style_object,\n * hash: true,\n * transformRequest: (url, resourceType)=> {\n * if(resourceType === 'Source' && url.startsWith('http://myHost')) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true},\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * });\n * ```\n * @see [Display a map](https://maplibre.org/maplibre-gl-js/docs/examples/simple-map/)\n */\nexport class Map extends Camera {\n style: Style;\n painter: Painter;\n handlers: HandlerManager;\n\n _container: HTMLElement;\n _canvasContainer: HTMLElement;\n _controlContainer: HTMLElement;\n _controlPositions: {[_: string]: HTMLElement};\n _interactive: boolean;\n _cooperativeGestures: boolean | GestureOptions;\n _cooperativeGesturesScreen: HTMLElement;\n _metaKey: keyof MouseEvent;\n _showTileBoundaries: boolean;\n _showCollisionBoxes: boolean;\n _showPadding: boolean;\n _showOverdrawInspector: boolean;\n _repaint: boolean;\n _vertices: boolean;\n _canvas: HTMLCanvasElement;\n _maxTileCacheSize: number;\n _maxTileCacheZoomLevels: number;\n _frame: Cancelable;\n _styleDirty: boolean;\n _sourcesDirty: boolean;\n _placementDirty: boolean;\n\n _loaded: boolean;\n _idleTriggered: boolean;\n // accounts for placement finishing as well\n _fullyLoaded: boolean;\n _trackResize: boolean;\n _resizeObserver: ResizeObserver;\n _preserveDrawingBuffer: boolean;\n _failIfMajorPerformanceCaveat: boolean;\n _antialias: boolean;\n _refreshExpiredTiles: boolean;\n _hash: Hash;\n _delegatedListeners: any;\n _fadeDuration: number;\n _crossSourceCollisions: boolean;\n _crossFadingFactor: number;\n _collectResourceTiming: boolean;\n _renderTaskQueue: TaskQueue;\n _controls: Array;\n _mapId: number;\n _localIdeographFontFamily: string;\n _validateStyle: boolean;\n _requestManager: RequestManager;\n _locale: any;\n _removed: boolean;\n _clickTolerance: number;\n _overridePixelRatio: number | null;\n _maxCanvasSize: [number, number];\n _terrainDataCallback: (e: MapStyleDataEvent | MapSourceDataEvent) => void;\n\n /**\n * @internal\n * image queue throttling handle. To be used later when clean up\n */\n _imageQueueHandle: number;\n\n /**\n * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.\n * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.\n */\n scrollZoom: ScrollZoomHandler;\n\n /**\n * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed.\n * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section.\n */\n boxZoom: BoxZoomHandler;\n\n /**\n * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right\n * mouse button or with the Control key pressed. Find more details and examples using `dragRotate`\n * in the {@link DragRotateHandler} section.\n */\n dragRotate: DragRotateHandler;\n\n /**\n * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture.\n * Find more details and examples using `dragPan` in the {@link DragPanHandler} section.\n */\n dragPan: DragPanHandler;\n\n /**\n * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard\n * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section.\n */\n keyboard: KeyboardHandler;\n\n /**\n * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking.\n * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section.\n */\n doubleClickZoom: DoubleClickZoomHandler;\n\n /**\n * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures.\n * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section.\n */\n touchZoomRotate: TwoFingersTouchZoomRotateHandler;\n\n /**\n * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures.\n * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section.\n */\n touchPitch: TwoFingersTouchPitchHandler;\n\n constructor(options: MapOptions) {\n PerformanceUtils.mark(PerformanceMarkers.create);\n\n options = extend({}, defaultOptions, options);\n\n if (options.minZoom != null && options.maxZoom != null && options.minZoom > options.maxZoom) {\n throw new Error('maxZoom must be greater than or equal to minZoom');\n }\n\n if (options.minPitch != null && options.maxPitch != null && options.minPitch > options.maxPitch) {\n throw new Error('maxPitch must be greater than or equal to minPitch');\n }\n\n if (options.minPitch != null && options.minPitch < defaultMinPitch) {\n throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);\n }\n\n if (options.maxPitch != null && options.maxPitch > maxPitchThreshold) {\n throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);\n }\n\n const transform = new Transform(options.minZoom, options.maxZoom, options.minPitch, options.maxPitch, options.renderWorldCopies);\n super(transform, {bearingSnap: options.bearingSnap});\n\n this._interactive = options.interactive;\n this._cooperativeGestures = options.cooperativeGestures;\n this._metaKey = navigator.platform.indexOf('Mac') === 0 ? 'metaKey' : 'ctrlKey';\n this._maxTileCacheSize = options.maxTileCacheSize;\n this._maxTileCacheZoomLevels = options.maxTileCacheZoomLevels;\n this._failIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat;\n this._preserveDrawingBuffer = options.preserveDrawingBuffer;\n this._antialias = options.antialias;\n this._trackResize = options.trackResize;\n this._bearingSnap = options.bearingSnap;\n this._refreshExpiredTiles = options.refreshExpiredTiles;\n this._fadeDuration = options.fadeDuration;\n this._crossSourceCollisions = options.crossSourceCollisions;\n this._crossFadingFactor = 1;\n this._collectResourceTiming = options.collectResourceTiming;\n this._renderTaskQueue = new TaskQueue();\n this._controls = [];\n this._mapId = uniqueId();\n this._locale = extend({}, defaultLocale, options.locale);\n this._clickTolerance = options.clickTolerance;\n this._overridePixelRatio = options.pixelRatio;\n this._maxCanvasSize = options.maxCanvasSize;\n this.transformCameraUpdate = options.transformCameraUpdate;\n\n this._imageQueueHandle = ImageRequest.addThrottleControl(() => this.isMoving());\n\n this._requestManager = new RequestManager(options.transformRequest);\n\n if (typeof options.container === 'string') {\n this._container = document.getElementById(options.container);\n if (!this._container) {\n throw new Error(`Container '${options.container}' not found.`);\n }\n } else if (options.container instanceof HTMLElement) {\n this._container = options.container;\n } else {\n throw new Error('Invalid type: \\'container\\' must be a String or HTMLElement.');\n }\n\n if (options.maxBounds) {\n this.setMaxBounds(options.maxBounds);\n }\n\n this._setupContainer();\n this._setupPainter();\n\n this.on('move', () => this._update(false));\n this.on('moveend', () => this._update(false));\n this.on('zoom', () => this._update(true));\n this.on('terrain', () => {\n this.painter.terrainFacilitator.dirty = true;\n this._update(true);\n });\n this.once('idle', () => { this._idleTriggered = true; });\n\n if (typeof window !== 'undefined') {\n addEventListener('online', this._onWindowOnline, false);\n let initialResizeEventCaptured = false;\n const throttledResizeCallback = throttle((entries: ResizeObserverEntry[]) => {\n if (this._trackResize && !this._removed) {\n this.resize(entries)._update();\n }\n }, 50);\n this._resizeObserver = new ResizeObserver((entries) => {\n if (!initialResizeEventCaptured) {\n initialResizeEventCaptured = true;\n return;\n }\n throttledResizeCallback(entries);\n });\n this._resizeObserver.observe(this._container);\n }\n\n this.handlers = new HandlerManager(this, options as CompleteMapOptions);\n\n if (this._cooperativeGestures) {\n this._setupCooperativeGestures();\n }\n\n const hashName = (typeof options.hash === 'string' && options.hash) || undefined;\n this._hash = options.hash && (new Hash(hashName)).addTo(this);\n // don't set position from options if set through hash\n if (!this._hash || !this._hash._onHashChange()) {\n this.jumpTo({\n center: options.center,\n zoom: options.zoom,\n bearing: options.bearing,\n pitch: options.pitch\n });\n\n if (options.bounds) {\n this.resize();\n this.fitBounds(options.bounds, extend({}, options.fitBoundsOptions, {duration: 0}));\n }\n }\n\n this.resize();\n\n this._localIdeographFontFamily = options.localIdeographFontFamily;\n this._validateStyle = options.validateStyle;\n\n if (options.style) this.setStyle(options.style, {localIdeographFontFamily: options.localIdeographFontFamily});\n\n if (options.attributionControl)\n this.addControl(new AttributionControl({customAttribution: options.customAttribution}));\n\n if (options.maplibreLogo)\n this.addControl(new LogoControl(), options.logoPosition);\n\n this.on('style.load', () => {\n if (this.transform.unmodified) {\n this.jumpTo(this.style.stylesheet as any);\n }\n });\n this.on('data', (event: MapDataEvent) => {\n this._update(event.dataType === 'style');\n this.fire(new Event(`${event.dataType}data`, event));\n });\n this.on('dataloading', (event: MapDataEvent) => {\n this.fire(new Event(`${event.dataType}dataloading`, event));\n });\n this.on('dataabort', (event: MapDataEvent) => {\n this.fire(new Event('sourcedataabort', event));\n });\n }\n\n /**\n * @internal\n * Returns a unique number for this map instance which is used for the MapLoadEvent\n * to make sure we only fire one event per instantiated map object.\n * @returns the uniq map ID\n */\n _getMapId() {\n return this._mapId;\n }\n\n /**\n * Adds an {@link IControl} to the map, calling `control.onAdd(this)`.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param control - The {@link IControl} to add.\n * @param position - position on the map to which the control will be added.\n * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`.\n * @returns `this`\n * @example\n * Add zoom and rotation controls to the map.\n * ```ts\n * map.addControl(new maplibregl.NavigationControl());\n * ```\n * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)\n */\n addControl(control: IControl, position?: ControlPosition): Map {\n if (position === undefined) {\n if (control.getDefaultPosition) {\n position = control.getDefaultPosition();\n } else {\n position = 'top-right';\n }\n }\n if (!control || !control.onAdd) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.')));\n }\n const controlElement = control.onAdd(this);\n this._controls.push(control);\n\n const positionContainer = this._controlPositions[position];\n if (position.indexOf('bottom') !== -1) {\n positionContainer.insertBefore(controlElement, positionContainer.firstChild);\n } else {\n positionContainer.appendChild(controlElement);\n }\n return this;\n }\n\n /**\n * Removes the control from the map.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param control - The {@link IControl} to remove.\n * @returns `this`\n * @example\n * ```ts\n * // Define a new navigation control.\n * let navigation = new maplibregl.NavigationControl();\n * // Add zoom and rotation controls to the map.\n * map.addControl(navigation);\n * // Remove zoom and rotation controls from the map.\n * map.removeControl(navigation);\n * ```\n */\n removeControl(control: IControl): Map {\n if (!control || !control.onRemove) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.')));\n }\n const ci = this._controls.indexOf(control);\n if (ci > -1) this._controls.splice(ci, 1);\n control.onRemove(this);\n return this;\n }\n\n /**\n * Checks if a control exists on the map.\n *\n * @param control - The {@link IControl} to check.\n * @returns true if map contains control.\n * @example\n * ```ts\n * // Define a new navigation control.\n * let navigation = new maplibregl.NavigationControl();\n * // Add zoom and rotation controls to the map.\n * map.addControl(navigation);\n * // Check that the navigation control exists on the map.\n * map.hasControl(navigation);\n * ```\n */\n hasControl(control: IControl): boolean {\n return this._controls.indexOf(control) > -1;\n }\n\n calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions {\n if (altitudeTo == null && this.terrain) {\n altitudeTo = this.terrain.getElevationForLngLatZoom(to, this.transform.tileZoom);\n }\n return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo);\n }\n\n /**\n * Resizes the map according to the dimensions of its\n * `container` element.\n *\n * Checks if the map container size changed and updates the map if it has changed.\n * This method must be called after the map's `container` is resized programmatically\n * or when the map is shown after being initially hidden with CSS.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`.\n *\n * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend`\n * events that get triggered as a result of resize. This can be useful for differentiating the\n * source of an event (for example, user-initiated or programmatically-triggered events).\n * @returns `this`\n * @example\n * Resize the map when the map container is shown after being initially hidden with CSS.\n * ```ts\n * let mapDiv = document.getElementById('map');\n * if (mapDiv.style.visibility === true) map.resize();\n * ```\n */\n resize(eventData?: any): Map {\n const dimensions = this._containerDimensions();\n const width = dimensions[0];\n const height = dimensions[1];\n\n const clampedPixelRatio = this._getClampedPixelRatio(width, height);\n this._resizeCanvas(width, height, clampedPixelRatio);\n this.painter.resize(width, height, clampedPixelRatio);\n\n // check if we've reached GL limits, in that case further clamps pixelRatio\n if (this.painter.overLimit()) {\n const gl = this.painter.context.gl;\n // store updated _maxCanvasSize value\n this._maxCanvasSize = [gl.drawingBufferWidth, gl.drawingBufferHeight];\n const clampedPixelRatio = this._getClampedPixelRatio(width, height);\n this._resizeCanvas(width, height, clampedPixelRatio);\n this.painter.resize(width, height, clampedPixelRatio);\n }\n\n this.transform.resize(width, height);\n this._requestedCameraState?.resize(width, height);\n\n const fireMoving = !this._moving;\n if (fireMoving) {\n this.stop();\n this.fire(new Event('movestart', eventData))\n .fire(new Event('move', eventData));\n }\n\n this.fire(new Event('resize', eventData));\n\n if (fireMoving) this.fire(new Event('moveend', eventData));\n\n return this;\n }\n\n /**\n * @internal\n * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize.\n * Internally you should use this and not getPixelRatio().\n */\n _getClampedPixelRatio(width: number, height: number): number {\n const {0: maxCanvasWidth, 1: maxCanvasHeight} = this._maxCanvasSize;\n const pixelRatio = this.getPixelRatio();\n\n const canvasWidth = width * pixelRatio;\n const canvasHeight = height * pixelRatio;\n\n const widthScaleFactor = canvasWidth > maxCanvasWidth ? (maxCanvasWidth / canvasWidth) : 1;\n const heightScaleFactor = canvasHeight > maxCanvasHeight ? (maxCanvasHeight / canvasHeight) : 1;\n\n return Math.min(widthScaleFactor, heightScaleFactor) * pixelRatio;\n }\n\n /**\n * Returns the map's pixel ratio.\n * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.\n * @returns The pixel ratio.\n */\n getPixelRatio(): number {\n return this._overridePixelRatio ?? devicePixelRatio;\n }\n\n /**\n * Sets the map's pixel ratio. This allows to override `devicePixelRatio`.\n * After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio`\n * and its height attribute will be `container.clientHeight * pixelRatio`.\n * Set this to null to disable `devicePixelRatio` override.\n * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.\n * @param pixelRatio - The pixel ratio.\n */\n setPixelRatio(pixelRatio: number) {\n this._overridePixelRatio = pixelRatio;\n this.resize();\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns The geographical bounds of the map as {@link LngLatBounds}.\n * @example\n * ```ts\n * let bounds = map.getBounds();\n * ```\n */\n getBounds(): LngLatBounds {\n return this.transform.getBounds();\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns The map object.\n * @example\n * ```ts\n * let maxBounds = map.getMaxBounds();\n * ```\n */\n getMaxBounds(): LngLatBounds | null {\n return this.transform.getMaxBounds();\n }\n\n /**\n * Sets or clears the map's geographical bounds.\n *\n * Pan and zoom operations are constrained within these bounds.\n * If a pan or zoom is performed that would\n * display regions outside these bounds, the map will\n * instead display a position and zoom level\n * as close as possible to the operation's request while still\n * remaining within the bounds.\n *\n * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds.\n * @returns `this`\n * @example\n * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds.\n * ```ts\n * let bounds = [\n * [-74.04728, 40.68392], // [west, south]\n * [-73.91058, 40.87764] // [east, north]\n * ];\n * map.setMaxBounds(bounds);\n * ```\n */\n setMaxBounds(bounds?: LngLatBoundsLike | null): Map {\n this.transform.setMaxBounds(LngLatBounds.convert(bounds));\n return this._update();\n }\n\n /**\n * Sets or clears the map's minimum zoom level.\n * If the map's current zoom level is lower than the new minimum,\n * the map will zoom to the new minimum.\n *\n * It is not always possible to zoom out and reach the set `minZoom`.\n * Other factors such as map height may restrict zooming. For example,\n * if the map is 512px tall it will not be possible to zoom below zoom 0\n * no matter what the `minZoom` is set to.\n *\n * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.\n *\n * @param minZoom - The minimum zoom level to set (-2 - 24).\n * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2).\n * @returns `this`\n * @example\n * ```ts\n * map.setMinZoom(12.25);\n * ```\n */\n setMinZoom(minZoom?: number | null): Map {\n\n minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;\n\n if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {\n this.transform.minZoom = minZoom;\n this._update();\n\n if (this.getZoom() < minZoom) this.setZoom(minZoom);\n\n return this;\n\n } else throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);\n }\n\n /**\n * Returns the map's minimum allowable zoom level.\n *\n * @returns minZoom\n * @example\n * ```ts\n * let minZoom = map.getMinZoom();\n * ```\n */\n getMinZoom(): number { return this.transform.minZoom; }\n\n /**\n * Sets or clears the map's maximum zoom level.\n * If the map's current zoom level is higher than the new maximum,\n * the map will zoom to the new maximum.\n *\n * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.\n *\n * @param maxZoom - The maximum zoom level to set.\n * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).\n * @returns `this`\n * @example\n * ```ts\n * map.setMaxZoom(18.75);\n * ```\n */\n setMaxZoom(maxZoom?: number | null): Map {\n\n maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;\n\n if (maxZoom >= this.transform.minZoom) {\n this.transform.maxZoom = maxZoom;\n this._update();\n\n if (this.getZoom() > maxZoom) this.setZoom(maxZoom);\n\n return this;\n\n } else throw new Error('maxZoom must be greater than the current minZoom');\n }\n\n /**\n * Returns the map's maximum allowable zoom level.\n *\n * @returns The maxZoom\n * @example\n * ```ts\n * let maxZoom = map.getMaxZoom();\n * ```\n */\n getMaxZoom(): number { return this.transform.maxZoom; }\n\n /**\n * Sets or clears the map's minimum pitch.\n * If the map's current pitch is lower than the new minimum,\n * the map will pitch to the new minimum.\n *\n * A {@link ErrorEvent} event will be fired if minPitch is out of bounds.\n *\n * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0).\n * @returns `this`\n */\n setMinPitch(minPitch?: number | null): Map {\n\n minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;\n\n if (minPitch < defaultMinPitch) {\n throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);\n }\n\n if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {\n this.transform.minPitch = minPitch;\n this._update();\n\n if (this.getPitch() < minPitch) this.setPitch(minPitch);\n\n return this;\n\n } else throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);\n }\n\n /**\n * Returns the map's minimum allowable pitch.\n *\n * @returns The minPitch\n */\n getMinPitch(): number { return this.transform.minPitch; }\n\n /**\n * Sets or clears the map's maximum pitch.\n * If the map's current pitch is higher than the new maximum,\n * the map will pitch to the new maximum.\n *\n * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds.\n *\n * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60).\n * @returns `this`\n */\n setMaxPitch(maxPitch?: number | null): Map {\n\n maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;\n\n if (maxPitch > maxPitchThreshold) {\n throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);\n }\n\n if (maxPitch >= this.transform.minPitch) {\n this.transform.maxPitch = maxPitch;\n this._update();\n\n if (this.getPitch() > maxPitch) this.setPitch(maxPitch);\n\n return this;\n\n } else throw new Error('maxPitch must be greater than the current minPitch');\n }\n\n /**\n * Returns the map's maximum allowable pitch.\n *\n * @returns The maxPitch\n */\n getMaxPitch(): number { return this.transform.maxPitch; }\n\n /**\n * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n * @returns The renderWorldCopies\n * @example\n * ```ts\n * let worldCopiesRendered = map.getRenderWorldCopies();\n * ```\n * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)\n */\n getRenderWorldCopies(): boolean { return this.transform.renderWorldCopies; }\n\n /**\n * Sets the state of `renderWorldCopies`.\n *\n * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n *\n * `undefined` is treated as `true`, `null` is treated as `false`.\n * @returns `this`\n * @example\n * ```ts\n * map.setRenderWorldCopies(true);\n * ```\n * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)\n */\n setRenderWorldCopies(renderWorldCopies?: boolean | null): Map {\n this.transform.renderWorldCopies = renderWorldCopies;\n return this._update();\n }\n\n /**\n * Gets the map's cooperativeGestures option\n *\n * @returns The gestureOptions\n */\n getCooperativeGestures(): boolean | GestureOptions {\n return this._cooperativeGestures;\n }\n\n /**\n * Sets or clears the map's cooperativeGestures option\n *\n * @param gestureOptions - If `true` or set to an options object, map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, \"drag to pitch\" requires a three-finger gesture.\n * @returns `this`\n */\n setCooperativeGestures(gestureOptions?: GestureOptions | boolean | null): Map {\n this._cooperativeGestures = gestureOptions;\n if (this._cooperativeGestures) {\n this._setupCooperativeGestures();\n } else {\n this._destroyCooperativeGestures();\n }\n\n return this;\n }\n\n /**\n * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`,\n * that correspond to the specified geographical location.\n *\n * @param lnglat - The geographical location to project.\n * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`.\n * @example\n * ```ts\n * let coordinate = [-122.420679, 37.772537];\n * let point = map.project(coordinate);\n * ```\n */\n project(lnglat: LngLatLike): Point {\n return this.transform.locationPoint(LngLat.convert(lnglat), this.style && this.terrain);\n }\n\n /**\n * Returns a {@link LngLat} representing geographical coordinates that correspond\n * to the specified pixel coordinates.\n *\n * @param point - The pixel coordinates to unproject.\n * @returns The {@link LngLat} corresponding to `point`.\n * @example\n * ```ts\n * map.on('click', function(e) {\n * // When the map is clicked, get the geographic coordinate.\n * let coordinate = map.unproject(e.point);\n * });\n * ```\n */\n unproject(point: PointLike): LngLat {\n return this.transform.pointLocation(Point.convert(point), this.terrain);\n }\n\n /**\n * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.\n * @returns true if the map is moving.\n * @example\n * ```ts\n * let isMoving = map.isMoving();\n * ```\n */\n isMoving(): boolean {\n return this._moving || this.handlers?.isMoving();\n }\n\n /**\n * Returns true if the map is zooming due to a camera animation or user gesture.\n * @returns true if the map is zooming.\n * @example\n * ```ts\n * let isZooming = map.isZooming();\n * ```\n */\n isZooming(): boolean {\n return this._zooming || this.handlers?.isZooming();\n }\n\n /**\n * Returns true if the map is rotating due to a camera animation or user gesture.\n * @returns true if the map is rotating.\n * @example\n * ```ts\n * map.isRotating();\n * ```\n */\n isRotating(): boolean {\n return this._rotating || this.handlers?.isRotating();\n }\n\n _createDelegatedListener(type: keyof MapEventType | string, layerId: string, listener: Listener): {\n layer: string;\n listener: Listener;\n delegates: {[type in keyof MapEventType]?: (e: any) => void};\n } {\n if (type === 'mouseenter' || type === 'mouseover') {\n let mousein = false;\n const mousemove = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (!features.length) {\n mousein = false;\n } else if (!mousein) {\n mousein = true;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent, {features}));\n }\n };\n const mouseout = () => {\n mousein = false;\n };\n return {layer: layerId, listener, delegates: {mousemove, mouseout}};\n } else if (type === 'mouseleave' || type === 'mouseout') {\n let mousein = false;\n const mousemove = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (features.length) {\n mousein = true;\n } else if (mousein) {\n mousein = false;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent));\n }\n };\n const mouseout = (e) => {\n if (mousein) {\n mousein = false;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent));\n }\n };\n return {layer: layerId, listener, delegates: {mousemove, mouseout}};\n } else {\n const delegate = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (features.length) {\n // Here we need to mutate the original event, so that preventDefault works as expected.\n e.features = features;\n listener.call(this, e);\n delete e.features;\n }\n };\n return {layer: layerId, listener, delegates: {[type]: delegate}};\n }\n }\n\n /**\n * @event\n * Adds a listener for events of a specified type, optionally limited to features in a specified style layer.\n * See {@link MapEventType} and {@link MapLayerEventType} for a full list of events and their description.\n *\n * | Event | Compatible with `layerId` |\n * |------------------------|---------------------------|\n * | `mousedown` | yes |\n * | `mouseup` | yes |\n * | `mouseover` | yes |\n * | `mouseout` | yes |\n * | `mousemove` | yes |\n * | `mouseenter` | yes (required) |\n * | `mouseleave` | yes (required) |\n * | `click` | yes |\n * | `dblclick` | yes |\n * | `contextmenu` | yes |\n * | `touchstart` | yes |\n * | `touchend` | yes |\n * | `touchcancel` | yes |\n * | `wheel` | |\n * | `resize` | |\n * | `remove` | |\n * | `touchmove` | |\n * | `movestart` | |\n * | `move` | |\n * | `moveend` | |\n * | `dragstart` | |\n * | `drag` | |\n * | `dragend` | |\n * | `zoomstart` | |\n * | `zoom` | |\n * | `zoomend` | |\n * | `rotatestart` | |\n * | `rotate` | |\n * | `rotateend` | |\n * | `pitchstart` | |\n * | `pitch` | |\n * | `pitchend` | |\n * | `boxzoomstart` | |\n * | `boxzoomend` | |\n * | `boxzoomcancel` | |\n * | `webglcontextlost` | |\n * | `webglcontextrestored` | |\n * | `load` | |\n * | `render` | |\n * | `idle` | |\n * | `error` | |\n * | `data` | |\n * | `styledata` | |\n * | `sourcedata` | |\n * | `dataloading` | |\n * | `styledataloading` | |\n * | `sourcedataloading` | |\n * | `styleimagemissing` | |\n * | `dataabort` | |\n * | `sourcedataabort` | |\n *\n * @param type - The event type to listen for. Events compatible with the optional `layerId` parameter are triggered\n * when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas.\n * @param layer - The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location\n * is within a visible feature in this layer. The event will have a `features` property containing\n * an array of the matching features. If `layer` is not supplied, the event will not have a `features` property.\n * Please note that many event types are not compatible with the optional `layer` parameter.\n * @param listener - The function to be called when the event is fired.\n * @returns `this`\n * @example\n * ```ts\n * // Set an event listener that will fire\n * // when the map has finished loading\n * map.on('load', function() {\n * // Once the map has finished loading,\n * // add a new layer\n * map.addLayer({\n * id: 'points-of-interest',\n * source: {\n * type: 'vector',\n * url: 'https://maplibre.org/maplibre-style-spec/'\n * },\n * 'source-layer': 'poi_label',\n * type: 'circle',\n * paint: {\n * // MapLibre Style Specification paint properties\n * },\n * layout: {\n * // MapLibre Style Specification layout properties\n * }\n * });\n * });\n * ```\n * @example\n * ```ts\n * // Set an event listener that will fire\n * // when a feature on the countries layer of the map is clicked\n * map.on('click', 'countries', (e) => {\n * new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setHTML(`Country name: ${e.features[0].properties.name}`)\n * .addTo(map);\n * });\n * ```\n * @see [Display popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n on(\n type: T,\n layer: string,\n listener: (ev: MapLayerEventType[T] & Object) => void,\n ): Map;\n /**\n * Overload of the `on` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n on(type: T, listener: (ev: MapEventType[T] & Object) => void): this;\n /**\n * Overload of the `on` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n on(type: keyof MapEventType | string, listener: Listener): this;\n on(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {\n if (listener === undefined) {\n return super.on(type, layerIdOrListener as Listener);\n }\n\n const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener);\n\n this._delegatedListeners = this._delegatedListeners || {};\n this._delegatedListeners[type] = this._delegatedListeners[type] || [];\n this._delegatedListeners[type].push(delegatedListener);\n\n for (const event in delegatedListener.delegates) {\n this.on(event, delegatedListener.delegates[event]);\n }\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer.\n *\n * @event\n * @param type - The event type to listen for; one of `'mousedown'`, `'mouseup'`, `'click'`, `'dblclick'`,\n * `'mousemove'`, `'mouseenter'`, `'mouseleave'`, `'mouseover'`, `'mouseout'`, `'contextmenu'`, `'touchstart'`,\n * `'touchend'`, or `'touchcancel'`. `mouseenter` and `mouseover` events are triggered when the cursor enters\n * a visible portion of the specified layer from outside that layer or outside the map canvas. `mouseleave`\n * and `mouseout` events are triggered when the cursor leaves a visible portion of the specified layer, or leaves\n * the map canvas.\n * @param layer - The ID of a style layer or a listener if no ID is provided. Only events whose location is within a visible\n * feature in this layer will trigger the listener. The event will have a `features` property containing\n * an array of the matching features.\n * @param listener - The function to be called when the event is fired.\n * @returns `this` if listener is provided, promise otherwise to allow easier usage of async/await\n */\n once(\n type: T,\n layer: string,\n listener?: (ev: MapLayerEventType[T] & Object) => void,\n ): this | Promise;\n /**\n * Overload of the `once` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n once(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise;\n /**\n * Overload of the `once` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n once(type: keyof MapEventType | string, listener?: Listener): this | Promise;\n once(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this | Promise {\n\n if (listener === undefined) {\n return super.once(type, layerIdOrListener as Listener);\n }\n\n const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener);\n\n for (const event in delegatedListener.delegates) {\n this.once(event, delegatedListener.delegates[event]);\n }\n\n return this;\n }\n\n /**\n * Removes an event listener for events previously added with `Map#on`.\n *\n * @event\n * @param type - The event type previously used to install the listener.\n * @param layer - The layer ID or listener previously used to install the listener.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(\n type: T,\n layer: string,\n listener: (ev: MapLayerEventType[T] & Object) => void,\n ): this;\n /**\n * Overload of the `off` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(type: T, listener: (ev: MapEventType[T] & Object) => void): this;\n /**\n * Overload of the `off` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(type: keyof MapEventType | string, listener: Listener): this;\n off(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {\n if (listener === undefined) {\n return super.off(type, layerIdOrListener as Listener);\n }\n\n const removeDelegatedListener = (delegatedListeners) => {\n const listeners = delegatedListeners[type];\n for (let i = 0; i < listeners.length; i++) {\n const delegatedListener = listeners[i];\n if (delegatedListener.layer === layerIdOrListener && delegatedListener.listener === listener) {\n for (const event in delegatedListener.delegates) {\n this.off(((event as any)), delegatedListener.delegates[event]);\n }\n listeners.splice(i, 1);\n return this;\n }\n }\n };\n\n if (this._delegatedListeners && this._delegatedListeners[type]) {\n removeDelegatedListener(this._delegatedListeners);\n }\n\n return this;\n }\n\n /**\n * Returns an array of MapGeoJSONFeature objects\n * representing visible features that satisfy the query parameters.\n *\n * @param geometryOrOptions - (optional) The geometry of the query region:\n * either a single point or southwest and northeast points describing a bounding box.\n * Omitting this parameter (i.e. calling {@link Map#queryRenderedFeatures} with zero arguments,\n * or with only a `options` argument) is equivalent to passing a bounding box encompassing the entire\n * map viewport.\n * The geometryOrOptions can receive a {@link QueryRenderedFeaturesOptions} only to support a situation where the function receives only one parameter which is the options parameter.\n * @param options - (optional) Options object.\n *\n * @returns An array of MapGeoJSONFeature objects.\n *\n * The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only\n * string and numeric property values are supported (i.e. `null`, `Array`, and `Object` values are not supported).\n *\n * Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object\n * representing the style layer to which the feature belongs. Layout and paint properties in this object contain values\n * which are fully evaluated for the given zoom level and feature.\n *\n * Only features that are currently rendered are included. Some features will **not** be included, like:\n *\n * - Features from layers whose `visibility` property is `\"none\"`.\n * - Features from layers whose zoom range excludes the current zoom level.\n * - Symbol features that have been hidden due to text or icon collision.\n *\n * Features from all other layers are included, including features that may have no visible\n * contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to\n * 0.\n *\n * The topmost rendered feature appears first in the returned array, and subsequent features are sorted by\n * descending z-order. Features that are rendered multiple times (due to wrapping across the antemeridian at low\n * zoom levels) are returned only once (though subject to the following caveat).\n *\n * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature\n * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple\n * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query.\n * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding\n * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile\n * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple\n * tiles due to tile buffering.\n *\n * @example\n * Find all features at a point\n * ```ts\n * let features = map.queryRenderedFeatures(\n * [20, 35],\n * { layers: ['my-layer-name'] }\n * );\n * ```\n *\n * @example\n * Find all features within a static bounding box\n * ```ts\n * let features = map.queryRenderedFeatures(\n * [[10, 20], [30, 50]],\n * { layers: ['my-layer-name'] }\n * );\n * ```\n *\n * @example\n * Find all features within a bounding box around a point\n * ```ts\n * let width = 10;\n * let height = 20;\n * let features = map.queryRenderedFeatures([\n * [point.x - width / 2, point.y - height / 2],\n * [point.x + width / 2, point.y + height / 2]\n * ], { layers: ['my-layer-name'] });\n * ```\n *\n * @example\n * Query all rendered features from a single layer\n * ```ts\n * let features = map.queryRenderedFeatures({ layers: ['my-layer-name'] });\n * ```\n * @see [Get features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/queryrenderedfeatures/)\n */\n queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[] {\n if (!this.style) {\n return [];\n }\n let queryGeometry;\n const isGeometry = geometryOrOptions instanceof Point || Array.isArray(geometryOrOptions);\n const geometry = isGeometry ? geometryOrOptions : [[0, 0], [this.transform.width, this.transform.height]];\n options = options || (isGeometry ? {} : geometryOrOptions) || {};\n\n if (geometry instanceof Point || typeof geometry[0] === 'number') {\n queryGeometry = [Point.convert(geometry as PointLike)];\n } else {\n const tl = Point.convert(geometry[0] as PointLike);\n const br = Point.convert(geometry[1] as PointLike);\n queryGeometry = [tl, new Point(br.x, tl.y), br, new Point(tl.x, br.y), tl];\n }\n\n return this.style.queryRenderedFeatures(queryGeometry, options, this.transform);\n }\n\n /**\n * Returns an array of MapGeoJSONFeature objects\n * representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.\n *\n * @param sourceId - The ID of the vector tile or GeoJSON source to query.\n * @param parameters - The options object.\n * @returns An array of MapGeoJSONFeature objects.\n *\n * In contrast to {@link Map#queryRenderedFeatures}, this function returns all features matching the query parameters,\n * whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded\n * vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently\n * visible viewport.\n *\n * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature\n * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple\n * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query.\n * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding\n * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile\n * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple\n * tiles due to tile buffering.\n *\n * @example\n * Find all features in one source layer in a vector source\n * ```ts\n * let features = map.querySourceFeatures('your-source-id', {\n * sourceLayer: 'your-source-layer'\n * });\n * ```\n *\n */\n querySourceFeatures(sourceId: string, parameters?: QuerySourceFeatureOptions | null): MapGeoJSONFeature[] {\n return this.style.querySourceFeatures(sourceId, parameters);\n }\n\n /**\n * Updates the map's MapLibre style object with a new value.\n *\n * If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style\n * against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites\n * (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current\n * style and the given style are different in any way, the map renderer will force a full update, removing the current style and building\n * the given one from scratch.\n *\n *\n * @param style - A JSON object conforming to the schema described in the\n * [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), or a URL to such JSON.\n * @param options - The options object.\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setStyle(\"https://demotiles.maplibre.org/style.json\");\n *\n * map.setStyle('https://demotiles.maplibre.org/style.json', {\n * transformStyle: (previousStyle, nextStyle) => ({\n * ...nextStyle,\n * sources: {\n * ...nextStyle.sources,\n * // copy a source from previous style\n * 'osm': previousStyle.sources.osm\n * },\n * layers: [\n * // background layer\n * nextStyle.layers[0],\n * // copy a layer from previous style\n * previousStyle.layers[0],\n * // other layers from the next style\n * ...nextStyle.layers.slice(1).map(layer => {\n * // hide the layers we don't need from demotiles style\n * if (layer.id.startsWith('geolines')) {\n * layer.layout = {...layer.layout || {}, visibility: 'none'};\n * // filter out US polygons\n * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {\n * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];\n * }\n * return layer;\n * })\n * ]\n * })\n * });\n * ```\n */\n setStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions): this {\n options = extend({},\n {\n localIdeographFontFamily: this._localIdeographFontFamily,\n validate: this._validateStyle\n }, options);\n\n if ((options.diff !== false && options.localIdeographFontFamily === this._localIdeographFontFamily) && this.style && style) {\n this._diffStyle(style, options);\n return this;\n } else {\n this._localIdeographFontFamily = options.localIdeographFontFamily;\n return this._updateStyle(style, options);\n }\n }\n\n /**\n * Updates the requestManager's transform request with a new function\n *\n * @param transformRequest - A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.\n * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties\n *\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setTransformRequest((url: string, resourceType: string) => {});\n * ```\n */\n setTransformRequest(transformRequest: RequestTransformFunction): this {\n this._requestManager.setTransformRequest(transformRequest);\n return this;\n }\n\n _getUIString(key: string) {\n const str = this._locale[key];\n if (str == null) {\n throw new Error(`Missing UI string '${key}'`);\n }\n\n return str;\n }\n\n _updateStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions) {\n // transformStyle relies on having previous style serialized, if it is not loaded yet, delay _updateStyle until previous style is loaded\n if (options.transformStyle && this.style && !this.style._loaded) {\n this.style.once('style.load', () => this._updateStyle(style, options));\n return;\n }\n\n const previousStyle = this.style && options.transformStyle ? this.style.serialize() : undefined;\n if (this.style) {\n this.style.setEventedParent(null);\n\n // Only release workers when map is getting disposed\n this.style._remove(!style);\n }\n\n if (!style) {\n delete this.style;\n return this;\n } else {\n this.style = new Style(this, options || {});\n }\n\n this.style.setEventedParent(this, {style: this.style});\n\n if (typeof style === 'string') {\n this.style.loadURL(style, options, previousStyle);\n } else {\n this.style.loadJSON(style, options, previousStyle);\n }\n\n return this;\n }\n\n _lazyInitEmptyStyle() {\n if (!this.style) {\n this.style = new Style(this, {});\n this.style.setEventedParent(this, {style: this.style});\n this.style.loadEmpty();\n }\n }\n\n _diffStyle(style: StyleSpecification | string, options?: StyleSwapOptions & StyleOptions) {\n if (typeof style === 'string') {\n const url = style;\n const request = this._requestManager.transformRequest(url, ResourceType.Style);\n getJSON(request, (error?: Error | null, json?: any | null) => {\n if (error) {\n this.fire(new ErrorEvent(error));\n } else if (json) {\n this._updateDiff(json, options);\n }\n });\n } else if (typeof style === 'object') {\n this._updateDiff(style, options);\n }\n }\n\n _updateDiff(style: StyleSpecification, options?: StyleSwapOptions & StyleOptions) {\n try {\n if (this.style.setState(style, options)) {\n this._update(true);\n }\n } catch (e) {\n warnOnce(\n `Unable to perform style diff: ${e.message || e.error || e}. Rebuilding the style from scratch.`\n );\n this._updateStyle(style, options);\n }\n }\n\n /**\n * Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style.\n *\n * @returns The map's style JSON object.\n *\n * @example\n * ```ts\n * let styleJson = map.getStyle();\n * ```\n *\n */\n getStyle(): StyleSpecification {\n if (this.style) {\n return this.style.serialize();\n }\n }\n\n /**\n * Returns a Boolean indicating whether the map's style is fully loaded.\n *\n * @returns A Boolean indicating whether the style is fully loaded.\n *\n * @example\n * ```ts\n * let styleLoadStatus = map.isStyleLoaded();\n * ```\n */\n isStyleLoaded(): boolean | void {\n if (!this.style) return warnOnce('There is no style added to the map.');\n return this.style.loaded();\n }\n\n /**\n * Adds a source to the map's style.\n *\n * Events triggered:\n *\n * Triggers the `source.add` event.\n *\n * @param id - The ID of the source to add. Must not conflict with existing sources.\n * @param source - The source object, conforming to the\n * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or\n * {@link CanvasSourceSpecification}.\n * @returns `this`\n * @example\n * ```ts\n * map.addSource('my-data', {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * });\n * ```\n * @example\n * ```ts\n * map.addSource('my-data', {\n * \"type\": \"geojson\",\n * \"data\": {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [-77.0323, 38.9131]\n * },\n * \"properties\": {\n * \"title\": \"Mapbox DC\",\n * \"marker-symbol\": \"monument\"\n * }\n * }\n * });\n * ```\n * @see GeoJSON source: [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n */\n addSource(id: string, source: SourceSpecification): this {\n this._lazyInitEmptyStyle();\n this.style.addSource(id, source);\n return this._update(true);\n }\n\n /**\n * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with\n * the given ID in the map's style has no outstanding network requests, otherwise `false`.\n *\n * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID.\n *\n * @param id - The ID of the source to be checked.\n * @returns A Boolean indicating whether the source is loaded.\n * @example\n * ```ts\n * let sourceLoaded = map.isSourceLoaded('bathymetry-data');\n * ```\n */\n isSourceLoaded(id: string): boolean {\n const source = this.style && this.style.sourceCaches[id];\n if (source === undefined) {\n this.fire(new ErrorEvent(new Error(`There is no source with ID '${id}'`)));\n return;\n }\n return source.loaded();\n }\n\n /**\n * Loads a 3D terrain mesh, based on a \"raster-dem\" source.\n *\n * Triggers the `terrain` event.\n *\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setTerrain({ source: 'terrain' });\n * ```\n */\n setTerrain(options: TerrainSpecification | null): this {\n this.style._checkLoaded();\n\n // clear event handlers\n if (this._terrainDataCallback) this.style.off('data', this._terrainDataCallback);\n\n if (!options) {\n // remove terrain\n if (this.terrain) this.terrain.sourceCache.destruct();\n this.terrain = null;\n if (this.painter.renderToTexture) this.painter.renderToTexture.destruct();\n this.painter.renderToTexture = null;\n this.transform._minEleveationForCurrentTile = 0;\n this.transform.elevation = 0;\n } else {\n // add terrain\n const sourceCache = this.style.sourceCaches[options.source];\n if (!sourceCache) throw new Error(`cannot load terrain, because there exists no source with ID: ${options.source}`);\n // Warn once if user is using the same source for hillshade and terrain\n for (const index in this.style._layers) {\n const thisLayer = this.style._layers[index];\n if (thisLayer.type === 'hillshade' && thisLayer.source === options.source) {\n warnOnce('You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.');\n }\n }\n this.terrain = new Terrain(this.painter, sourceCache, options);\n this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain);\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this._terrainDataCallback = e => {\n if (e.dataType === 'style') {\n this.terrain.sourceCache.freeRtt();\n } else if (e.dataType === 'source' && e.tile) {\n if (e.sourceId === options.source && !this._elevationFreeze) {\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n }\n this.terrain.sourceCache.freeRtt(e.tile.tileID);\n }\n };\n this.style.on('data', this._terrainDataCallback);\n }\n\n this.fire(new Event('terrain', {terrain: options}));\n return this;\n }\n\n /**\n * Get the terrain-options if terrain is loaded\n * @returns the TerrainSpecification passed to setTerrain\n * @example\n * ```ts\n * map.getTerrain(); // { source: 'terrain' };\n * ```\n */\n getTerrain(): TerrainSpecification | null {\n return this.terrain?.options ?? null;\n }\n\n /**\n * Returns a Boolean indicating whether all tiles in the viewport from all sources on\n * the style are loaded.\n *\n * @returns A Boolean indicating whether all tiles are loaded.\n * @example\n * ```ts\n * let tilesLoaded = map.areTilesLoaded();\n * ```\n */\n areTilesLoaded(): boolean {\n const sources = this.style && this.style.sourceCaches;\n for (const id in sources) {\n const source = sources[id];\n const tiles = source._tiles;\n for (const t in tiles) {\n const tile = tiles[t];\n if (!(tile.state === 'loaded' || tile.state === 'errored')) return false;\n }\n }\n return true;\n }\n\n /**\n * Adds a [custom source type](#Custom Sources), making it available for use with\n * {@link Map#addSource}.\n * @param name - The name of the source type; source definition objects use this name in the `{type: ...}` field.\n * @param SourceType - A {@link Source} constructor.\n * @param callback - Called when the source type is ready or with an error argument if there is an error.\n */\n addSourceType(name: string, SourceType: SourceClass, callback: Callback) {\n this._lazyInitEmptyStyle();\n return this.style.addSourceType(name, SourceType, callback);\n }\n\n /**\n * Removes a source from the map's style.\n *\n * @param id - The ID of the source to remove.\n * @returns `this`\n * @example\n * ```ts\n * map.removeSource('bathymetry-data');\n * ```\n */\n removeSource(id: string): Map {\n this.style.removeSource(id);\n return this._update(true);\n }\n\n /**\n * Returns the source with the specified ID in the map's style.\n *\n * This method is often used to update a source using the instance members for the relevant\n * source type as defined in [Sources](#sources).\n * For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates`\n * of an image source.\n *\n * @param id - The ID of the source to get.\n * @returns The style source with the specified ID or `undefined` if the ID\n * corresponds to no existing sources.\n * The shape of the object varies by source type.\n * A list of options for each source type is available on the MapLibre Style Specification's\n * [Sources](https://maplibre.org/maplibre-style-spec/sources/) page.\n * @example\n * ```ts\n * let sourceObject = map.getSource('points');\n * ```\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)\n * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n */\n getSource(id: string): Source | undefined {\n return this.style.getSource(id);\n }\n\n /**\n * Add an image to the style. This image can be displayed on the map like any other icon in the style's\n * sprite using the image's ID with\n * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),\n * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),\n * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),\n * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).\n *\n * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image.\n *\n * @param id - The ID of the image.\n * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`\n * properties with the same format as `ImageData`.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * // If the style's sprite does not already contain an image with ID 'cat',\n * // add the image 'cat-icon.png' to the style's sprite with the ID 'cat'.\n * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) {\n * if (error) throw error;\n * if (!map.hasImage('cat')) map.addImage('cat', image);\n * });\n *\n * // Add a stretchable image that can be used with `icon-text-fit`\n * // In this example, the image is 600px wide by 400px high.\n * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png', function(error, image) {\n * if (error) throw error;\n * if (!map.hasImage('border-image')) {\n * map.addImage('border-image', image, {\n * content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border\n * stretchX: [[16, 584]], // stretch everything horizontally except the 16px border\n * stretchY: [[16, 384]], // stretch everything vertically except the 16px border\n * });\n * }\n * });\n * ```\n * @see Use `HTMLImageElement`: [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/)\n * @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-generated/)\n */\n addImage(id: string,\n image: HTMLImageElement | ImageBitmap | ImageData | {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n } | StyleImageInterface,\n options: Partial = {}): this {\n const {\n pixelRatio = 1,\n sdf = false,\n stretchX,\n stretchY,\n content\n } = options;\n this._lazyInitEmptyStyle();\n const version = 0;\n\n if (image instanceof HTMLImageElement || isImageBitmap(image)) {\n const {width, height, data} = browser.getImageData(image);\n this.style.addImage(id, {data: new RGBAImage({width, height}, data), pixelRatio, stretchX, stretchY, content, sdf, version});\n } else if (image.width === undefined || image.height === undefined) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' +\n 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`')));\n } else {\n const {width, height, data} = image as ImageData;\n const userImage = (image as any as StyleImageInterface);\n\n this.style.addImage(id, {\n data: new RGBAImage({width, height}, new Uint8Array(data)),\n pixelRatio,\n stretchX,\n stretchY,\n content,\n sdf,\n version,\n userImage\n });\n\n if (userImage.onAdd) {\n userImage.onAdd(this, id);\n }\n return this;\n }\n }\n\n /**\n * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's\n * sprite using the image's ID with\n * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),\n * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),\n * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),\n * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the image.\n * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`\n * properties with the same format as `ImageData`.\n * @returns `this`\n * @example\n * ```ts\n * // If an image with the ID 'cat' already exists in the style's sprite,\n * // replace that image with a new image, 'other-cat-icon.png'.\n * if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png');\n * ```\n */\n updateImage(id: string,\n image: HTMLImageElement | ImageBitmap | ImageData | {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n } | StyleImageInterface): this {\n\n const existingImage = this.style.getImage(id);\n if (!existingImage) {\n return this.fire(new ErrorEvent(new Error(\n 'The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.')));\n }\n const imageData = (image instanceof HTMLImageElement || isImageBitmap(image)) ?\n browser.getImageData(image) :\n image;\n const {width, height, data} = imageData;\n\n if (width === undefined || height === undefined) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' +\n 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`')));\n }\n\n if (width !== existingImage.data.width || height !== existingImage.data.height) {\n return this.fire(new ErrorEvent(new Error(\n 'The width and height of the updated image must be that same as the previous version of the image')));\n }\n\n const copy = !(image instanceof HTMLImageElement || isImageBitmap(image));\n existingImage.data.replace(data, copy);\n\n this.style.updateImage(id, existingImage);\n return this;\n }\n\n /**\n * Returns an image, specified by ID, currently available in the map.\n * This includes both images from the style's original sprite\n * and any images that have been added at runtime using {@link Map#addImage}.\n *\n * @param id - The ID of the image.\n * @returns An image in the map with the specified ID.\n *\n * @example\n * ```ts\n * let coffeeShopIcon = map.getImage(\"coffee_cup\");\n * ```\n */\n getImage(id: string): StyleImage {\n return this.style.getImage(id);\n }\n\n /**\n * Check whether or not an image with a specific ID exists in the style. This checks both images\n * in the style's original sprite and any images\n * that have been added at runtime using {@link Map#addImage}.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the image.\n *\n * @returns A Boolean indicating whether the image exists.\n * @example\n * Check if an image with the ID 'cat' exists in the style's sprite.\n * ```ts\n * let catIconExists = map.hasImage('cat');\n * ```\n */\n hasImage(id: string): boolean {\n if (!id) {\n this.fire(new ErrorEvent(new Error('Missing required image id')));\n return false;\n }\n\n return !!this.style.getImage(id);\n }\n\n /**\n * Remove an image from a style. This can be an image from the style's original\n * sprite or any images\n * that have been added at runtime using {@link Map#addImage}.\n *\n * @param id - The ID of the image.\n *\n * @example\n * ```ts\n * // If an image with the ID 'cat' exists in\n * // the style's sprite, remove it.\n * if (map.hasImage('cat')) map.removeImage('cat');\n * ```\n */\n removeImage(id: string) {\n this.style.removeImage(id);\n }\n\n /**\n * Load an image from an external URL to be used with {@link Map#addImage}. External\n * domains must support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS).\n *\n * @param url - The URL of the image file. Image file must be in png, webp, or jpg format.\n * @param callback - Expecting `callback(error, data)`. Called when the image has loaded or with an error argument if there is an error.\n *\n * @example\n * Load an image from an external URL.\n * ```ts\n * map.loadImage('http://placekitten.com/50/50', function(error, image) {\n * if (error) throw error;\n * // Add the loaded image to the style's sprite with the ID 'kitten'.\n * map.addImage('kitten', image);\n * });\n * ```\n * @see [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/)\n */\n loadImage(url: string, callback: GetImageCallback) {\n ImageRequest.getImage(this._requestManager.transformRequest(url, ResourceType.Image), callback);\n }\n\n /**\n * Returns an Array of strings containing the IDs of all images currently available in the map.\n * This includes both images from the style's original sprite\n * and any images that have been added at runtime using {@link Map#addImage}.\n *\n * @returns An Array of strings containing the names of all sprites/images currently available in the map.\n *\n * @example\n * ```ts\n * let allImages = map.listImages();\n * ```\n */\n listImages(): Array {\n return this.style.listImages();\n }\n\n /**\n * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers)\n * to the map's style.\n *\n * A layer defines how data from a specified source will be styled. Read more about layer types\n * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers).\n *\n * @param layer - The layer to add,\n * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,\n * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition.\n * The MapLibre Style Specification's layer definition is appropriate for most layers.\n *\n * @param beforeId - The ID of an existing layer to insert the new layer before,\n * resulting in the new layer appearing visually beneath the existing layer.\n * If this argument is not specified, the layer will be appended to the end of the layers array\n * and appear visually above all other layers.\n *\n * @returns `this`\n *\n * @example\n * Add a circle layer with a vector source\n * ```ts\n * map.addLayer({\n * id: 'points-of-interest',\n * source: {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * },\n * 'source-layer': 'poi_label',\n * type: 'circle',\n * paint: {\n * // MapLibre Style Specification paint properties\n * },\n * layout: {\n * // MapLibre Style Specification layout properties\n * }\n * });\n * ```\n *\n * @example\n * Define a source before using it to create a new layer\n * ```ts\n * map.addSource('state-data', {\n * type: 'geojson',\n * data: 'path/to/data.geojson'\n * });\n *\n * map.addLayer({\n * id: 'states',\n * // References the GeoJSON source defined above\n * // and does not require a `source-layer`\n * source: 'state-data',\n * type: 'symbol',\n * layout: {\n * // Set the label content to the\n * // feature's `name` property\n * text-field: ['get', 'name']\n * }\n * });\n * ```\n *\n * @example\n * Add a new symbol layer before an existing layer\n * ```ts\n * map.addLayer({\n * id: 'states',\n * // References a source that's already been defined\n * source: 'state-data',\n * type: 'symbol',\n * layout: {\n * // Set the label content to the\n * // feature's `name` property\n * text-field: ['get', 'name']\n * }\n * // Add the layer before the existing `cities` layer\n * }, 'cities');\n * ```\n * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)\n * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)\n * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/)\n */\n addLayer(layer: AddLayerObject, beforeId?: string) {\n this._lazyInitEmptyStyle();\n this.style.addLayer(layer, beforeId);\n return this._update(true);\n }\n\n /**\n * Moves a layer to a different z-position.\n *\n * @param id - The ID of the layer to move.\n * @param beforeId - The ID of an existing layer to insert the new layer before. When viewing the map, the `id` layer will appear beneath the `beforeId` layer. If `beforeId` is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map.\n * @returns `this`\n *\n * @example\n * Move a layer with ID 'polygon' before the layer with ID 'country-label'. The `polygon` layer will appear beneath the `country-label` layer on the map.\n * ```ts\n * map.moveLayer('polygon', 'country-label');\n * ```\n */\n moveLayer(id: string, beforeId?: string): this {\n this.style.moveLayer(id, beforeId);\n return this._update(true);\n }\n\n /**\n * Removes the layer with the given ID from the map's style.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the layer to remove\n * @returns `this`\n *\n * @example\n * If a layer with ID 'state-data' exists, remove it.\n * ```ts\n * if (map.getLayer('state-data')) map.removeLayer('state-data');\n * ```\n */\n removeLayer(id: string): this {\n this.style.removeLayer(id);\n return this._update(true);\n }\n\n /**\n * Returns the layer with the specified ID in the map's style.\n *\n * @param id - The ID of the layer to get.\n * @returns The layer with the specified ID, or `undefined`\n * if the ID corresponds to no existing layers.\n *\n * @example\n * ```ts\n * let stateDataLayer = map.getLayer('state-data');\n * ```\n * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/)\n * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/)\n */\n getLayer(id: string): StyleLayer | undefined {\n return this.style.getLayer(id);\n }\n\n /**\n * Return the ids of all layers currently in the style, including custom layers, in order.\n *\n * @returns ids of layers, in order\n *\n * @example\n * ```ts\n * const orderedLayerIds = map.getLayersOrder();\n * ```\n */\n getLayersOrder(): string[] {\n return this.style.getLayersOrder();\n }\n\n /**\n * Sets the zoom extent for the specified style layer. The zoom extent includes the\n * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)\n * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom))\n * at which the layer will be rendered.\n *\n * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the\n * minimum zoom level of the _source layer_ because the data does not exist at those zoom levels. If the minimum\n * zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style\n * layer will not be rendered at all zoom levels in the zoom range.\n *\n * @param layerId - The ID of the layer to which the zoom extent will be applied.\n * @param minzoom - The minimum zoom to set (0-24).\n * @param maxzoom - The maximum zoom to set (0-24).\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setLayerZoomRange('my-layer', 2, 5);\n * ```\n */\n setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this {\n this.style.setLayerZoomRange(layerId, minzoom, maxzoom);\n return this._update(true);\n }\n\n /**\n * Sets the filter for the specified style layer.\n *\n * Filters control which features a style layer renders from its source.\n * Any feature for which the filter expression evaluates to `true` will be\n * rendered on the map. Those that are false will be hidden.\n *\n * Use `setFilter` to show a subset of your source data.\n *\n * To clear the filter, pass `null` or `undefined` as the second parameter.\n *\n * @param layerId - The ID of the layer to which the filter will be applied.\n * @param filter - The filter, conforming to the MapLibre Style Specification's\n * [filter definition](https://maplibre.org/maplibre-style-spec/layers/#filter). If `null` or `undefined` is provided, the function removes any existing filter from the layer.\n * @param options - Options object.\n * @returns `this`\n *\n * @example\n * Display only features with the 'name' property 'USA'\n * ```ts\n * map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']);\n * ```\n * @example\n * Display only features with five or more 'available-spots'\n * ```ts\n * map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]);\n * ```\n * @example\n * Remove the filter for the 'bike-docks' style layer\n * ```ts\n * map.setFilter('bike-docks', null);\n * ```\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\n setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) {\n this.style.setFilter(layerId, filter, options);\n return this._update(true);\n }\n\n /**\n * Returns the filter applied to the specified style layer.\n *\n * @param layerId - The ID of the style layer whose filter to get.\n * @returns The layer's filter.\n */\n getFilter(layerId: string): FilterSpecification | void {\n return this.style.getFilter(layerId);\n }\n\n /**\n * Sets the value of a paint property in the specified style layer.\n *\n * @param layerId - The ID of the layer to set the paint property in.\n * @param name - The name of the paint property to set.\n * @param value - The value of the paint property to set.\n * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).\n * Pass `null` to unset the existing value.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setPaintProperty('my-layer', 'fill-color', '#faafee');\n * ```\n * @see [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/)\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this {\n this.style.setPaintProperty(layerId, name, value, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of a paint property in the specified style layer.\n *\n * @param layerId - The ID of the layer to get the paint property from.\n * @param name - The name of a paint property to get.\n * @returns The value of the specified paint property.\n */\n getPaintProperty(layerId: string, name: string) {\n return this.style.getPaintProperty(layerId, name);\n }\n\n /**\n * Sets the value of a layout property in the specified style layer.\n *\n * @param layerId - The ID of the layer to set the layout property in.\n * @param name - The name of the layout property to set.\n * @param value - The value of the layout property. Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).\n * @param options - The options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setLayoutProperty('my-layer', 'visibility', 'none');\n * ```\n */\n setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this {\n this.style.setLayoutProperty(layerId, name, value, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of a layout property in the specified style layer.\n *\n * @param layerId - The ID of the layer to get the layout property from.\n * @param name - The name of the layout property to get.\n * @returns The value of the specified layout property.\n */\n getLayoutProperty(layerId: string, name: string) {\n return this.style.getLayoutProperty(layerId, name);\n }\n\n /**\n * Sets the value of the style's glyphs property.\n *\n * @param glyphsUrl - Glyph URL to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/glyphs/).\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setGlyphs('https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf');\n * ```\n */\n setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}): this {\n this._lazyInitEmptyStyle();\n this.style.setGlyphs(glyphsUrl, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of the style's glyphs URL\n *\n * @returns glyphs Style's glyphs url\n */\n getGlyphs(): string | null {\n return this.style.getGlyphsUrl();\n }\n\n /**\n * Adds a sprite to the map's style. Fires the `style` event.\n *\n * @param id - The ID of the sprite to add. Must not conflict with existing sprites.\n * @param url - The URL to load the sprite from\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.addSprite('sprite-two', 'http://example.com/sprite-two');\n * ```\n */\n addSprite(id: string, url: string, options: StyleSetterOptions = {}): this {\n this._lazyInitEmptyStyle();\n this.style.addSprite(id, url, options, (err) => {\n if (!err) {\n this._update(true);\n }\n });\n return this;\n }\n\n /**\n * Removes the sprite from the map's style. Fires the `style` event.\n *\n * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be \"default\".\n * @returns `this`\n * @example\n * ```ts\n * map.removeSprite('sprite-two');\n * map.removeSprite('default');\n * ```\n */\n removeSprite(id: string) {\n this._lazyInitEmptyStyle();\n this.style.removeSprite(id);\n return this._update(true);\n }\n\n /**\n * Returns the as-is value of the style's sprite.\n *\n * @returns style's sprite list of id-url pairs\n */\n getSprite(): {id: string; url: string}[] {\n return this.style.getSprite();\n }\n\n /**\n * Sets the value of the style's sprite property.\n *\n * @param spriteUrl - Sprite URL to set.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setSprite('YOUR_SPRITE_URL');\n * ```\n */\n setSprite(spriteUrl: string | null, options: StyleSetterOptions = {}) {\n this._lazyInitEmptyStyle();\n this.style.setSprite(spriteUrl, options, (err) => {\n if (!err) {\n this._update(true);\n }\n });\n return this;\n }\n\n /**\n * Sets the any combination of light values.\n *\n * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light).\n * @param options - Options object.\n * @returns `this`\n *\n * @example\n * ```ts\n * let layerVisibility = map.getLayoutProperty('my-layer', 'visibility');\n * ```\n */\n setLight(light: LightSpecification, options: StyleSetterOptions = {}) {\n this._lazyInitEmptyStyle();\n this.style.setLight(light, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of the light object.\n *\n * @returns light Light properties of the style.\n */\n getLight(): LightSpecification {\n return this.style.getLight();\n }\n\n /**\n * Sets the `state` of a feature.\n * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime.\n * When using this method, the `state` object is merged with any existing key-value pairs in the feature's state.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * This method can only be used with sources that have a `feature.id` attribute. The `feature.id` attribute can be defined in three ways:\n * - For vector or GeoJSON sources, including an `id` attribute in the original data file.\n * - For vector or GeoJSON sources, using the [`promoteId`](https://maplibre.org/maplibre-style-spec/sources/#vector-promoteId) option at the time the source is defined.\n * - For GeoJSON sources, using the [`generateId`](https://maplibre.org/maplibre-style-spec/sources/#geojson-generateId) option to auto-assign an `id` based on the feature's index in the source data. If you change feature data using `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values.\n *\n * _Note: You can use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) to access the values in a feature's state object for the purposes of styling._\n *\n * @param feature - Feature identifier. Feature objects returned from\n * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @param state - A set of key-value pairs. The values should be valid JSON types.\n * @returns `this`\n *\n * @example\n * ```ts\n * // When the mouse moves over the `my-layer` layer, update\n * // the feature state for the feature under the mouse\n * map.on('mousemove', 'my-layer', function(e) {\n * if (e.features.length > 0) {\n * map.setFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id,\n * }, {\n * hover: true\n * });\n * }\n * });\n * ```\n * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n */\n setFeatureState(feature: FeatureIdentifier, state: any): this {\n this.style.setFeatureState(feature, state);\n return this._update();\n }\n\n /**\n * Removes the `state` of a feature, setting it back to the default behavior.\n * If only a `target.source` is specified, it will remove the state for all features from that source.\n * If `target.id` is also specified, it will remove all keys for that feature's state.\n * If `key` is also specified, it removes only that key from that feature's state.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * @param target - Identifier of where to remove state. It can be a source, a feature, or a specific key of feature.\n * Feature objects returned from {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @param key - (optional) The key in the feature state to reset.\n * @returns `this`\n * @example\n * Reset the entire state object for all features in the `my-source` source\n * ```ts\n * map.removeFeatureState({\n * source: 'my-source'\n * });\n * ```\n *\n * @example\n * When the mouse leaves the `my-layer` layer,\n * reset the entire state object for the\n * feature under the mouse\n * ```ts\n * map.on('mouseleave', 'my-layer', function(e) {\n * map.removeFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * });\n * });\n * ```\n *\n * @example\n * When the mouse leaves the `my-layer` layer,\n * reset only the `hover` key-value pair in the\n * state for the feature under the mouse\n * ```ts\n * map.on('mouseleave', 'my-layer', function(e) {\n * map.removeFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * }, 'hover');\n * });\n * ```\n */\n removeFeatureState(target: FeatureIdentifier, key?: string): this {\n this.style.removeFeatureState(target, key);\n return this._update();\n }\n\n /**\n * Gets the `state` of a feature.\n * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * _Note: To access the values in a feature's state object for the purposes of styling the feature, use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state)._\n *\n * @param feature - Feature identifier. Feature objects returned from\n * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @returns The state of the feature: a set of key-value pairs that was assigned to the feature at runtime.\n *\n * @example\n * When the mouse moves over the `my-layer` layer,\n * get the feature state for the feature under the mouse\n * ```ts\n * map.on('mousemove', 'my-layer', function(e) {\n * if (e.features.length > 0) {\n * map.getFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * });\n * }\n * });\n * ```\n */\n getFeatureState(feature: FeatureIdentifier): any {\n return this.style.getFeatureState(feature);\n }\n\n /**\n * Returns the map's containing HTML element.\n *\n * @returns The map's container.\n */\n getContainer(): HTMLElement {\n return this._container;\n }\n\n /**\n * Returns the HTML element containing the map's `` element.\n *\n * If you want to add non-GL overlays to the map, you should append them to this element.\n *\n * This is the element to which event bindings for map interactivity (such as panning and zooming) are\n * attached. It will receive bubbled events from child elements such as the ``, but not from\n * map controls.\n *\n * @returns The container of the map's ``.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n getCanvasContainer(): HTMLElement {\n return this._canvasContainer;\n }\n\n /**\n * Returns the map's `` element.\n *\n * @returns The map's `` element.\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n getCanvas(): HTMLCanvasElement {\n return this._canvas;\n }\n\n _containerDimensions() {\n let width = 0;\n let height = 0;\n\n if (this._container) {\n width = this._container.clientWidth || 400;\n height = this._container.clientHeight || 300;\n }\n\n return [width, height];\n }\n\n _setupContainer() {\n const container = this._container;\n container.classList.add('maplibregl-map');\n\n const canvasContainer = this._canvasContainer = DOM.create('div', 'maplibregl-canvas-container', container);\n if (this._interactive) {\n canvasContainer.classList.add('maplibregl-interactive');\n }\n\n this._canvas = DOM.create('canvas', 'maplibregl-canvas', canvasContainer);\n this._canvas.addEventListener('webglcontextlost', this._contextLost, false);\n this._canvas.addEventListener('webglcontextrestored', this._contextRestored, false);\n this._canvas.setAttribute('tabindex', '0');\n this._canvas.setAttribute('aria-label', 'Map');\n this._canvas.setAttribute('role', 'region');\n\n const dimensions = this._containerDimensions();\n const clampedPixelRatio = this._getClampedPixelRatio(dimensions[0], dimensions[1]);\n this._resizeCanvas(dimensions[0], dimensions[1], clampedPixelRatio);\n\n const controlContainer = this._controlContainer = DOM.create('div', 'maplibregl-control-container', container);\n const positions = this._controlPositions = {};\n ['top-left', 'top-right', 'bottom-left', 'bottom-right'].forEach((positionName) => {\n positions[positionName] = DOM.create('div', `maplibregl-ctrl-${positionName} `, controlContainer);\n });\n\n this._container.addEventListener('scroll', this._onMapScroll, false);\n }\n\n _cooperativeGesturesOnWheel = (event: WheelEvent) => {\n this._onCooperativeGesture(event, event[this._metaKey], 1);\n };\n\n _setupCooperativeGestures() {\n const container = this._container;\n this._cooperativeGesturesScreen = DOM.create('div', 'maplibregl-cooperative-gesture-screen', container);\n let desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.windowsHelpText ? this._cooperativeGestures.windowsHelpText : 'Use Ctrl + scroll to zoom the map';\n if (navigator.platform.indexOf('Mac') === 0) {\n desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.macHelpText ? this._cooperativeGestures.macHelpText : 'Use ⌘ + scroll to zoom the map';\n }\n const mobileMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.mobileHelpText ? this._cooperativeGestures.mobileHelpText : 'Use two fingers to move the map';\n this._cooperativeGesturesScreen.innerHTML = `\n
${desktopMessage}
\n
${mobileMessage}
\n `;\n\n // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures\n this._cooperativeGesturesScreen.setAttribute('aria-hidden', 'true');\n\n // Add event to canvas container since gesture container is pointer-events: none\n this._canvasContainer.addEventListener('wheel', this._cooperativeGesturesOnWheel, false);\n\n // Add a cooperative gestures class (enable touch-action: pan-x pan-y;)\n this._canvasContainer.classList.add('maplibregl-cooperative-gestures');\n }\n\n _destroyCooperativeGestures() {\n DOM.remove(this._cooperativeGesturesScreen);\n this._canvasContainer.removeEventListener('wheel', this._cooperativeGesturesOnWheel, false);\n this._canvasContainer.classList.remove('maplibregl-cooperative-gestures');\n }\n\n _resizeCanvas(width: number, height: number, pixelRatio: number) {\n // Request the required canvas size taking the pixelratio into account.\n this._canvas.width = Math.floor(pixelRatio * width);\n this._canvas.height = Math.floor(pixelRatio * height);\n\n // Maintain the same canvas size, potentially downscaling it for HiDPI displays\n this._canvas.style.width = `${width}px`;\n this._canvas.style.height = `${height}px`;\n }\n\n _setupPainter() {\n\n const attributes = {\n alpha: true,\n stencil: true,\n depth: true,\n failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat,\n preserveDrawingBuffer: this._preserveDrawingBuffer,\n antialias: this._antialias || false\n };\n\n let webglcontextcreationerrorDetailObject: any = null;\n this._canvas.addEventListener('webglcontextcreationerror', (args: WebGLContextEvent) => {\n webglcontextcreationerrorDetailObject = {requestedAttributes: attributes};\n if (args) {\n webglcontextcreationerrorDetailObject.statusMessage = args.statusMessage;\n webglcontextcreationerrorDetailObject.type = args.type;\n }\n }, {once: true});\n\n const gl =\n this._canvas.getContext('webgl2', attributes) as WebGL2RenderingContext ||\n this._canvas.getContext('webgl', attributes) as WebGLRenderingContext;\n\n if (!gl) {\n const msg = 'Failed to initialize WebGL';\n if (webglcontextcreationerrorDetailObject) {\n webglcontextcreationerrorDetailObject.message = msg;\n throw new Error(JSON.stringify(webglcontextcreationerrorDetailObject));\n } else {\n throw new Error(msg);\n }\n }\n\n this.painter = new Painter(gl, this.transform);\n\n webpSupported.testSupport(gl);\n }\n\n _contextLost = (event: any) => {\n event.preventDefault();\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this.fire(new Event('webglcontextlost', {originalEvent: event}));\n };\n\n _contextRestored = (event: any) => {\n this._setupPainter();\n this.resize();\n this._update();\n this.fire(new Event('webglcontextrestored', {originalEvent: event}));\n };\n\n _onMapScroll = (event: any) => {\n if (event.target !== this._container) return;\n\n // Revert any scroll which would move the canvas outside of the view\n this._container.scrollTop = 0;\n this._container.scrollLeft = 0;\n return false;\n };\n\n _onCooperativeGesture(event: any, metaPress, touches) {\n if (!metaPress && touches < 2) {\n // Alert user how to scroll/pan\n this._cooperativeGesturesScreen.classList.add('maplibregl-show');\n setTimeout(() => {\n this._cooperativeGesturesScreen.classList.remove('maplibregl-show');\n }, 100);\n }\n return false;\n }\n\n /**\n * Returns a Boolean indicating whether the map is fully loaded.\n *\n * Returns `false` if the style is not yet fully loaded,\n * or if there has been a change to the sources or style that\n * has not yet fully loaded.\n *\n * @returns A Boolean indicating whether the map is fully loaded.\n */\n loaded(): boolean {\n return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded();\n }\n\n /**\n * @internal\n * Update this map's style and sources, and re-render the map.\n *\n * @param updateStyle - mark the map's style for reprocessing as\n * well as its sources\n * @returns `this`\n */\n _update(updateStyle?: boolean) {\n if (!this.style || !this.style._loaded) return this;\n\n this._styleDirty = this._styleDirty || updateStyle;\n this._sourcesDirty = true;\n this.triggerRepaint();\n\n return this;\n }\n\n /**\n * @internal\n * Request that the given callback be executed during the next render\n * frame. Schedule a render frame if one is not already scheduled.\n *\n * @returns An id that can be used to cancel the callback\n */\n _requestRenderFrame(callback: () => void): TaskID {\n this._update();\n return this._renderTaskQueue.add(callback);\n }\n\n _cancelRenderFrame(id: TaskID) {\n this._renderTaskQueue.remove(id);\n }\n\n /**\n * @internal\n * Call when a (re-)render of the map is required:\n * - The style has changed (`setPaintProperty()`, etc.)\n * - Source data has changed (e.g. tiles have finished loading)\n * - The map has is moving (or just finished moving)\n * - A transition is in progress\n *\n * @param paintStartTimeStamp - The time when the animation frame began executing.\n *\n * @returns `this`\n */\n _render(paintStartTimeStamp: number) {\n const fadeDuration = this._idleTriggered ? this._fadeDuration : 0;\n\n // A custom layer may have used the context asynchronously. Mark the state as dirty.\n this.painter.context.setDirty();\n this.painter.setBaseState();\n\n this._renderTaskQueue.run(paintStartTimeStamp);\n // A task queue callback may have fired a user event which may have removed the map\n if (this._removed) return;\n\n let crossFading = false;\n\n // If the style has changed, the map is being zoomed, or a transition or fade is in progress:\n // - Apply style changes (in a batch)\n // - Recalculate paint properties.\n if (this.style && this._styleDirty) {\n this._styleDirty = false;\n\n const zoom = this.transform.zoom;\n const now = browser.now();\n this.style.zoomHistory.update(zoom, now);\n\n const parameters = new EvaluationParameters(zoom, {\n now,\n fadeDuration,\n zoomHistory: this.style.zoomHistory,\n transition: this.style.getTransition()\n });\n\n const factor = parameters.crossFadingFactor();\n if (factor !== 1 || factor !== this._crossFadingFactor) {\n crossFading = true;\n this._crossFadingFactor = factor;\n }\n\n this.style.update(parameters);\n }\n\n // If we are in _render for any reason other than an in-progress paint\n // transition, update source caches to check for and load any tiles we\n // need for the current transform\n if (this.style && this._sourcesDirty) {\n this._sourcesDirty = false;\n this.style._updateSources(this.transform);\n }\n\n // update terrain stuff\n if (this.terrain) {\n this.terrain.sourceCache.update(this.transform, this.terrain);\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n if (!this._elevationFreeze) {\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n }\n } else {\n this.transform._minEleveationForCurrentTile = 0;\n this.transform.elevation = 0;\n }\n\n this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions);\n\n // Actually draw\n this.painter.render(this.style, {\n showTileBoundaries: this.showTileBoundaries,\n showOverdrawInspector: this._showOverdrawInspector,\n rotating: this.isRotating(),\n zooming: this.isZooming(),\n moving: this.isMoving(),\n fadeDuration,\n showPadding: this.showPadding,\n });\n\n this.fire(new Event('render'));\n\n if (this.loaded() && !this._loaded) {\n this._loaded = true;\n PerformanceUtils.mark(PerformanceMarkers.load);\n this.fire(new Event('load'));\n }\n\n if (this.style && (this.style.hasTransitions() || crossFading)) {\n this._styleDirty = true;\n }\n\n if (this.style && !this._placementDirty) {\n // Since no fade operations are in progress, we can release\n // all tiles held for fading. If we didn't do this, the tiles\n // would just sit in the SourceCaches until the next render\n this.style._releaseSymbolFadeTiles();\n }\n\n // Schedule another render frame if it's needed.\n //\n // Even though `_styleDirty` and `_sourcesDirty` are reset in this\n // method, synchronous events fired during Style#update or\n // Style#_updateSources could have caused them to be set again.\n const somethingDirty = this._sourcesDirty || this._styleDirty || this._placementDirty;\n if (somethingDirty || this._repaint) {\n this.triggerRepaint();\n } else if (!this.isMoving() && this.loaded()) {\n this.fire(new Event('idle'));\n }\n\n if (this._loaded && !this._fullyLoaded && !somethingDirty) {\n this._fullyLoaded = true;\n PerformanceUtils.mark(PerformanceMarkers.fullLoad);\n }\n\n return this;\n }\n\n /**\n * Force a synchronous redraw of the map.\n * @returns `this`\n * @example\n * ```ts\n * map.redraw();\n * ```\n */\n redraw(): this {\n if (this.style) {\n // cancel the scheduled update\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this._render(0);\n }\n return this;\n }\n\n /**\n * Clean up and release all internal resources associated with this map.\n *\n * This includes DOM elements, event bindings, web workers, and WebGL resources.\n *\n * Use this method when you are done using the map and wish to ensure that it no\n * longer consumes browser resources. Afterwards, you must not call any other\n * methods on the map.\n */\n remove() {\n if (this._hash) this._hash.remove();\n\n for (const control of this._controls) control.onRemove(this);\n this._controls = [];\n\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this._renderTaskQueue.clear();\n this.painter.destroy();\n this.handlers.destroy();\n delete this.handlers;\n this.setStyle(null);\n if (typeof window !== 'undefined') {\n removeEventListener('online', this._onWindowOnline, false);\n }\n\n ImageRequest.removeThrottleControl(this._imageQueueHandle);\n\n this._resizeObserver?.disconnect();\n const extension = this.painter.context.gl.getExtension('WEBGL_lose_context');\n if (extension) extension.loseContext();\n this._canvas.removeEventListener('webglcontextrestored', this._contextRestored, false);\n this._canvas.removeEventListener('webglcontextlost', this._contextLost, false);\n DOM.remove(this._canvasContainer);\n DOM.remove(this._controlContainer);\n if (this._cooperativeGestures) {\n this._destroyCooperativeGestures();\n }\n this._container.classList.remove('maplibregl-map');\n\n PerformanceUtils.clearMetrics();\n\n this._removed = true;\n this.fire(new Event('remove'));\n }\n\n /**\n * Trigger the rendering of a single frame. Use this method with custom layers to\n * repaint the map when the layer changes. Calling this multiple times before the\n * next frame is rendered will still result in only a single frame being rendered.\n * @example\n * ```ts\n * map.triggerRepaint();\n * ```\n * @see [Add a 3D model](https://maplibre.org/maplibre-gl-js/docs/examples/add-3d-model/)\n * @see [Add an animated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/)\n */\n triggerRepaint() {\n if (this.style && !this._frame) {\n this._frame = browser.frame((paintStartTimeStamp: number) => {\n PerformanceUtils.frame(paintStartTimeStamp);\n this._frame = null;\n this._render(paintStartTimeStamp);\n });\n }\n }\n\n _onWindowOnline = () => {\n this._update();\n };\n\n /**\n * Gets and sets a Boolean indicating whether the map will render an outline\n * around each tile and the tile ID. These tile boundaries are useful for\n * debugging.\n *\n * The uncompressed file size of the first vector source is drawn in the top left\n * corner of each tile, next to the tile ID.\n *\n * @example\n * ```ts\n * map.showTileBoundaries = true;\n * ```\n */\n get showTileBoundaries(): boolean { return !!this._showTileBoundaries; }\n set showTileBoundaries(value: boolean) {\n if (this._showTileBoundaries === value) return;\n this._showTileBoundaries = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will visualize\n * the padding offsets.\n */\n get showPadding(): boolean { return !!this._showPadding; }\n set showPadding(value: boolean) {\n if (this._showPadding === value) return;\n this._showPadding = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will render boxes\n * around all symbols in the data source, revealing which symbols\n * were rendered or which were hidden due to collisions.\n * This information is useful for debugging.\n */\n get showCollisionBoxes(): boolean { return !!this._showCollisionBoxes; }\n set showCollisionBoxes(value: boolean) {\n if (this._showCollisionBoxes === value) return;\n this._showCollisionBoxes = value;\n if (value) {\n // When we turn collision boxes on we have to generate them for existing tiles\n // When we turn them off, there's no cost to leaving existing boxes in place\n this.style._generateCollisionBoxes();\n } else {\n // Otherwise, call an update to remove collision boxes\n this._update();\n }\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map should color-code\n * each fragment to show how many times it has been shaded.\n * White fragments have been shaded 8 or more times.\n * Black fragments have been shaded 0 times.\n * This information is useful for debugging.\n */\n get showOverdrawInspector(): boolean { return !!this._showOverdrawInspector; }\n set showOverdrawInspector(value: boolean) {\n if (this._showOverdrawInspector === value) return;\n this._showOverdrawInspector = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will\n * continuously repaint. This information is useful for analyzing performance.\n */\n get repaint(): boolean { return !!this._repaint; }\n set repaint(value: boolean) {\n if (this._repaint !== value) {\n this._repaint = value;\n this.triggerRepaint();\n }\n }\n // show vertices\n get vertices(): boolean { return !!this._vertices; }\n set vertices(value: boolean) { this._vertices = value; this._update(); }\n\n /**\n * Returns the package version of the library\n * @returns Package version of the library\n */\n get version(): string {\n return version;\n }\n\n /**\n * Returns the elevation for the point where the camera is looking.\n * This value corresponds to:\n * \"meters above sea level\" * \"exaggeration\"\n * @returns The elevation.\n */\n getCameraTargetElevation(): number {\n return this.transform.elevation;\n }\n}\n","import type Point from '@mapbox/point-geometry';\n\nimport {DragMoveHandler, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';\nimport {OneFingerTouchMoveStateManager} from './drag_move_state_manager';\n\nexport interface OneFingerTouchRotateHandler extends DragMoveHandler {}\nexport interface OneFingerTouchPitchHandler extends DragMoveHandler {}\n\nconst assignEvents = (handler: DragHandler) => {\n handler.touchstart = handler.dragStart;\n handler.touchmoveWindow = handler.dragMove;\n handler.touchend = handler.dragEnd;\n};\n\nexport const generateOneFingerTouchRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: {\n clickTolerance: number;\n bearingDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): OneFingerTouchRotateHandler => {\n const touchMoveStateManager = new OneFingerTouchMoveStateManager();\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}),\n moveStateManager: touchMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateOneFingerTouchPitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: {\n clickTolerance: number;\n pitchDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): OneFingerTouchPitchHandler => {\n const touchMoveStateManager = new OneFingerTouchMoveStateManager();\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}),\n moveStateManager: touchMoveStateManager,\n enable,\n assignEvents,\n });\n};\n","import Point from '@mapbox/point-geometry';\n\nimport {DOM} from '../../util/dom';\nimport {extend} from '../../util/util';\nimport {generateMousePitchHandler, generateMouseRotationHandler, MousePitchHandler, MouseRotateHandler} from '../handler/mouse';\nimport {generateOneFingerTouchPitchHandler, generateOneFingerTouchRotationHandler, OneFingerTouchPitchHandler, OneFingerTouchRotateHandler} from '../handler/one_finger_touch_drag';\n\nimport type {Map} from '../map';\nimport type {IControl} from './control';\n\n/**\n * The {@link NavigationControl} options object\n */\ntype NavigationOptions = {\n /**\n * If `true` the compass button is included.\n */\n showCompass?: boolean;\n /**\n * If `true` the zoom-in and zoom-out buttons are included.\n */\n showZoom?: boolean;\n /**\n * If `true` the pitch is visualized by rotating X-axis of compass.\n */\n visualizePitch?: boolean;\n};\n\nconst defaultOptions: NavigationOptions = {\n showCompass: true,\n showZoom: true,\n visualizePitch: false\n};\n\n/**\n * A `NavigationControl` control contains zoom buttons and a compass.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let nav = new maplibregl.NavigationControl();\n * map.addControl(nav, 'top-left');\n * ```\n * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)\n */\nexport class NavigationControl implements IControl {\n _map: Map;\n options: NavigationOptions;\n _container: HTMLElement;\n _zoomInButton: HTMLButtonElement;\n _zoomOutButton: HTMLButtonElement;\n _compass: HTMLButtonElement;\n _compassIcon: HTMLElement;\n _handler: MouseRotateWrapper;\n\n /**\n * @param options - the control's options\n */\n constructor(options?: NavigationOptions) {\n this.options = extend({}, defaultOptions, options);\n\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._container.addEventListener('contextmenu', (e) => e.preventDefault());\n\n if (this.options.showZoom) {\n this._zoomInButton = this._createButton('maplibregl-ctrl-zoom-in', (e) => this._map.zoomIn({}, {originalEvent: e}));\n DOM.create('span', 'maplibregl-ctrl-icon', this._zoomInButton).setAttribute('aria-hidden', 'true');\n this._zoomOutButton = this._createButton('maplibregl-ctrl-zoom-out', (e) => this._map.zoomOut({}, {originalEvent: e}));\n DOM.create('span', 'maplibregl-ctrl-icon', this._zoomOutButton).setAttribute('aria-hidden', 'true');\n }\n if (this.options.showCompass) {\n this._compass = this._createButton('maplibregl-ctrl-compass', (e) => {\n if (this.options.visualizePitch) {\n this._map.resetNorthPitch({}, {originalEvent: e});\n } else {\n this._map.resetNorth({}, {originalEvent: e});\n }\n });\n this._compassIcon = DOM.create('span', 'maplibregl-ctrl-icon', this._compass);\n this._compassIcon.setAttribute('aria-hidden', 'true');\n }\n }\n\n _updateZoomButtons = () => {\n const zoom = this._map.getZoom();\n const isMax = zoom === this._map.getMaxZoom();\n const isMin = zoom === this._map.getMinZoom();\n this._zoomInButton.disabled = isMax;\n this._zoomOutButton.disabled = isMin;\n this._zoomInButton.setAttribute('aria-disabled', isMax.toString());\n this._zoomOutButton.setAttribute('aria-disabled', isMin.toString());\n };\n\n _rotateCompassArrow = () => {\n const rotate = this.options.visualizePitch ?\n `scale(${1 / Math.pow(Math.cos(this._map.transform.pitch * (Math.PI / 180)), 0.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle * (180 / Math.PI)}deg)` :\n `rotate(${this._map.transform.angle * (180 / Math.PI)}deg)`;\n\n this._compassIcon.style.transform = rotate;\n };\n\n onAdd(map: Map) {\n this._map = map;\n if (this.options.showZoom) {\n this._setButtonTitle(this._zoomInButton, 'ZoomIn');\n this._setButtonTitle(this._zoomOutButton, 'ZoomOut');\n this._map.on('zoom', this._updateZoomButtons);\n this._updateZoomButtons();\n }\n if (this.options.showCompass) {\n this._setButtonTitle(this._compass, 'ResetBearing');\n if (this.options.visualizePitch) {\n this._map.on('pitch', this._rotateCompassArrow);\n }\n this._map.on('rotate', this._rotateCompassArrow);\n this._rotateCompassArrow();\n this._handler = new MouseRotateWrapper(this._map, this._compass, this.options.visualizePitch);\n }\n return this._container;\n }\n\n onRemove() {\n DOM.remove(this._container);\n if (this.options.showZoom) {\n this._map.off('zoom', this._updateZoomButtons);\n }\n if (this.options.showCompass) {\n if (this.options.visualizePitch) {\n this._map.off('pitch', this._rotateCompassArrow);\n }\n this._map.off('rotate', this._rotateCompassArrow);\n this._handler.off();\n delete this._handler;\n }\n\n delete this._map;\n }\n\n _createButton(className: string, fn: (e?: any) => unknown) {\n const a = DOM.create('button', className, this._container) as HTMLButtonElement;\n a.type = 'button';\n a.addEventListener('click', fn);\n return a;\n }\n\n _setButtonTitle = (button: HTMLButtonElement, title: string) => {\n const str = this._map._getUIString(`NavigationControl.${title}`);\n button.title = str;\n button.setAttribute('aria-label', str);\n };\n}\n\nclass MouseRotateWrapper {\n\n map: Map;\n _clickTolerance: number;\n element: HTMLElement;\n // Rotation and pitch handlers are separated due to different _clickTolerance values\n mouseRotate: MouseRotateHandler;\n touchRotate: OneFingerTouchRotateHandler;\n mousePitch: MousePitchHandler;\n touchPitch: OneFingerTouchPitchHandler;\n _startPos: Point;\n _lastPos: Point;\n\n constructor(map: Map, element: HTMLElement, pitch: boolean = false) {\n this._clickTolerance = 10;\n const mapRotateTolerance = map.dragRotate._mouseRotate.getClickTolerance();\n const mapPitchTolerance = map.dragRotate._mousePitch.getClickTolerance();\n this.element = element;\n this.mouseRotate = generateMouseRotationHandler({clickTolerance: mapRotateTolerance, enable: true});\n this.touchRotate = generateOneFingerTouchRotationHandler({clickTolerance: mapRotateTolerance, enable: true});\n this.map = map;\n if (pitch) {\n this.mousePitch = generateMousePitchHandler({clickTolerance: mapPitchTolerance, enable: true});\n this.touchPitch = generateOneFingerTouchPitchHandler({clickTolerance: mapPitchTolerance, enable: true});\n }\n\n DOM.addEventListener(element, 'mousedown', this.mousedown);\n DOM.addEventListener(element, 'touchstart', this.touchstart, {passive: false});\n DOM.addEventListener(element, 'touchcancel', this.reset);\n }\n\n startMouse(e: MouseEvent, point: Point) {\n this.mouseRotate.dragStart(e, point);\n if (this.mousePitch) this.mousePitch.dragStart(e, point);\n DOM.disableDrag();\n }\n\n startTouch(e: TouchEvent, point: Point) {\n this.touchRotate.dragStart(e, point);\n if (this.touchPitch) this.touchPitch.dragStart(e, point);\n DOM.disableDrag();\n }\n\n moveMouse(e: MouseEvent, point: Point) {\n const map = this.map;\n const {bearingDelta} = this.mouseRotate.dragMove(e, point) || {};\n if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta);\n if (this.mousePitch) {\n const {pitchDelta} = this.mousePitch.dragMove(e, point) || {};\n if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta);\n }\n }\n\n moveTouch(e: TouchEvent, point: Point) {\n const map = this.map;\n const {bearingDelta} = this.touchRotate.dragMove(e, point) || {};\n if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta);\n if (this.touchPitch) {\n const {pitchDelta} = this.touchPitch.dragMove(e, point) || {};\n if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta);\n }\n }\n\n off() {\n const element = this.element;\n DOM.removeEventListener(element, 'mousedown', this.mousedown);\n DOM.removeEventListener(element, 'touchstart', this.touchstart, {passive: false});\n DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.removeEventListener(window, 'touchend', this.touchend);\n DOM.removeEventListener(element, 'touchcancel', this.reset);\n this.offTemp();\n }\n\n offTemp() {\n DOM.enableDrag();\n DOM.removeEventListener(window, 'mousemove', this.mousemove);\n DOM.removeEventListener(window, 'mouseup', this.mouseup);\n DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.removeEventListener(window, 'touchend', this.touchend);\n }\n\n mousedown = (e: MouseEvent) => {\n this.startMouse(extend({}, e, {ctrlKey: true, preventDefault: () => e.preventDefault()}), DOM.mousePos(this.element, e));\n DOM.addEventListener(window, 'mousemove', this.mousemove);\n DOM.addEventListener(window, 'mouseup', this.mouseup);\n };\n\n mousemove = (e: MouseEvent) => {\n this.moveMouse(e, DOM.mousePos(this.element, e));\n };\n\n mouseup = (e: MouseEvent) => {\n this.mouseRotate.dragEnd(e);\n if (this.mousePitch) this.mousePitch.dragEnd(e);\n this.offTemp();\n };\n\n touchstart = (e: TouchEvent) => {\n if (e.targetTouches.length !== 1) {\n this.reset();\n } else {\n this._startPos = this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0];\n this.startTouch(e, this._startPos);\n DOM.addEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.addEventListener(window, 'touchend', this.touchend);\n }\n };\n\n touchmove = (e: TouchEvent) => {\n if (e.targetTouches.length !== 1) {\n this.reset();\n } else {\n this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0];\n this.moveTouch(e, this._lastPos);\n }\n };\n\n touchend = (e: TouchEvent) => {\n if (e.targetTouches.length === 0 &&\n this._startPos &&\n this._lastPos &&\n this._startPos.dist(this._lastPos) < this._clickTolerance) {\n this.element.click();\n }\n delete this._startPos;\n delete this._lastPos;\n this.offTemp();\n };\n\n reset = () => {\n this.mouseRotate.reset();\n if (this.mousePitch) this.mousePitch.reset();\n this.touchRotate.reset();\n if (this.touchPitch) this.touchPitch.reset();\n delete this._startPos;\n delete this._lastPos;\n this.offTemp();\n };\n}\n","let supportsGeolocation;\n\nexport function checkGeolocationSupport(callback: (supported: boolean) => void, forceRecalculation = false): void {\n if (supportsGeolocation !== undefined && !forceRecalculation) {\n callback(supportsGeolocation);\n } else if (window.navigator.permissions !== undefined) {\n // navigator.permissions has incomplete browser support\n // http://caniuse.com/#feat=permissions-api\n // Test for the case where a browser disables Geolocation because of an\n // insecure origin\n window.navigator.permissions.query({name: 'geolocation'}).then((p) => {\n supportsGeolocation = p.state !== 'denied';\n callback(supportsGeolocation);\n }).catch(() => {\n // Fix for iOS16 which rejects query but still supports geolocation\n supportsGeolocation = !!window.navigator.geolocation;\n callback(supportsGeolocation);\n });\n\n } else {\n supportsGeolocation = !!window.navigator.geolocation;\n callback(supportsGeolocation);\n }\n}\n","import {LngLat} from '../geo/lng_lat';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {Transform} from '../geo/transform';\n\n/**\n * Given a LngLat, prior projected position, and a transform, return a new LngLat shifted\n * n × 360° east or west for some n ≥ 0 such that:\n *\n * * the projected location of the result is on screen, if possible, and secondarily:\n * * the difference between the projected location of the result and the prior position\n * is minimized.\n *\n * The object is to preserve perceived object constancy for Popups and Markers as much as\n * possible; they should avoid shifting large distances across the screen, even when the\n * map center changes by ±360° due to automatic wrapping, and when about to go off screen,\n * should wrap just enough to avoid doing so.\n */\nexport function smartWrap(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {\n lngLat = new LngLat(lngLat.lng, lngLat.lat);\n\n // First, try shifting one world in either direction, and see if either is closer to the\n // prior position. This preserves object constancy when the map center is auto-wrapped\n // during animations.\n if (priorPos) {\n const left = new LngLat(lngLat.lng - 360, lngLat.lat);\n const right = new LngLat(lngLat.lng + 360, lngLat.lat);\n const delta = transform.locationPoint(lngLat).distSqr(priorPos);\n if (transform.locationPoint(left).distSqr(priorPos) < delta) {\n lngLat = left;\n } else if (transform.locationPoint(right).distSqr(priorPos) < delta) {\n lngLat = right;\n }\n }\n\n // Second, wrap toward the center until the new position is on screen, or we can't get\n // any closer.\n while (Math.abs(lngLat.lng - transform.center.lng) > 180) {\n const pos = transform.locationPoint(lngLat);\n if (pos.x >= 0 && pos.y >= 0 && pos.x <= transform.width && pos.y <= transform.height) {\n break;\n }\n if (lngLat.lng > transform.center.lng) {\n lngLat.lng -= 360;\n } else {\n lngLat.lng += 360;\n }\n }\n\n return lngLat;\n}\n","/**\n * Where to position the anchor.\n * Used by a popup and a marker.\n */\nexport type PositionAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport const anchorTranslate: {\n [_ in PositionAnchor]: string;\n} = {\n 'center': 'translate(-50%,-50%)',\n 'top': 'translate(-50%,0)',\n 'top-left': 'translate(0,0)',\n 'top-right': 'translate(-100%,0)',\n 'bottom': 'translate(-50%,-100%)',\n 'bottom-left': 'translate(0,-100%)',\n 'bottom-right': 'translate(-100%,-100%)',\n 'left': 'translate(0,-50%)',\n 'right': 'translate(-100%,-50%)'\n};\n\nexport function applyAnchorClass(element: HTMLElement, anchor: PositionAnchor, prefix: string) {\n const classList = element.classList;\n for (const key in anchorTranslate) {\n classList.remove(`maplibregl-${prefix}-anchor-${key}`);\n }\n classList.add(`maplibregl-${prefix}-anchor-${anchor}`);\n}\n","import {DOM} from '../util/dom';\nimport {LngLat} from '../geo/lng_lat';\nimport Point from '@mapbox/point-geometry';\nimport {smartWrap} from '../util/smart_wrap';\nimport {anchorTranslate, applyAnchorClass} from './anchor';\nimport type {PositionAnchor} from './anchor';\nimport {Event, Evented} from '../util/evented';\nimport type {Map} from './map';\nimport {Popup, Offset} from './popup';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {MapMouseEvent, MapTouchEvent} from './events';\nimport type {PointLike} from './camera';\n\n/**\n * Alignment options of rotation and pitch\n */\ntype Alignment = 'map' | 'viewport' | 'auto';\n\n/**\n * The {@link Marker} options object\n */\ntype MarkerOptions = {\n /**\n * DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker.\n */\n element?: HTMLElement;\n /**\n * Space-separated CSS class names to add to marker element.\n */\n className?: string;\n /**\n * The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.\n */\n offset?: PointLike;\n /**\n * A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}.\n * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.\n * @defaultValue 'center'\n * */\n anchor?: PositionAnchor;\n /**\n * The color to use for the default marker if options.element is not provided. The default is light blue.\n * @defaultValue '#3FB1CE'\n */\n color?: string;\n /**\n * The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`.\n * @defaultValue 1\n */\n scale?: number;\n /**\n * A boolean indicating whether or not a marker is able to be dragged to a new position on the map.\n * @defaultValue false\n */\n draggable?: boolean;\n /**\n * The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance.\n * @defaultValue 0\n */\n clickTolerance?: number;\n /**\n * The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.\n * @defaultValue 0\n */\n rotation?: number;\n /**\n * `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`.\n * @defaultValue 'auto'\n */\n rotationAlignment?: Alignment;\n /**\n * `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`.\n * @defaultValue 'auto'\n */\n pitchAlignment?: Alignment;\n};\n\n/**\n * Creates a marker component\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([30.5, 50.5])\n * .addTo(map);\n * ```\n *\n * @example\n * Set options\n * ```ts\n * let marker = new maplibregl.Marker({\n * color: \"#FFFFFF\",\n * draggable: true\n * }).setLngLat([30.5, 50.5])\n * .addTo(map);\n * ```\n * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n *\n * ### Events\n *\n * @event `dragstart` Fired when dragging starts, `marker` object that is being dragged\n *\n * @event `drag` Fired while dragging. `marker` object that is being dragged\n *\n * @event `dragend` Fired when the marker is finished being dragged, `marker` object that was dragged\n */\nexport class Marker extends Evented {\n _map: Map;\n _anchor: PositionAnchor;\n _offset: Point;\n _element: HTMLElement;\n _popup: Popup;\n _lngLat: LngLat;\n _pos: Point;\n _color: string;\n _scale: number;\n _defaultMarker: boolean;\n _draggable: boolean;\n _clickTolerance: number;\n _isDragging: boolean;\n _state: 'inactive' | 'pending' | 'active'; // used for handling drag events\n _positionDelta: Point;\n _pointerdownPos: Point;\n _rotation: number;\n _pitchAlignment: Alignment;\n _rotationAlignment: Alignment;\n _originalTabIndex: string; // original tabindex of _element\n _opacityTimeout: ReturnType;\n\n /**\n * @param options - the options\n */\n constructor(options?: MarkerOptions) {\n super();\n\n this._anchor = options && options.anchor || 'center';\n this._color = options && options.color || '#3FB1CE';\n this._scale = options && options.scale || 1;\n this._draggable = options && options.draggable || false;\n this._clickTolerance = options && options.clickTolerance || 0;\n this._isDragging = false;\n this._state = 'inactive';\n this._rotation = options && options.rotation || 0;\n this._rotationAlignment = options && options.rotationAlignment || 'auto';\n this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment;\n\n if (!options || !options.element) {\n this._defaultMarker = true;\n this._element = DOM.create('div');\n this._element.setAttribute('aria-label', 'Map marker');\n\n // create default map marker SVG\n const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg');\n const defaultHeight = 41;\n const defaultWidth = 27;\n svg.setAttributeNS(null, 'display', 'block');\n svg.setAttributeNS(null, 'height', `${defaultHeight}px`);\n svg.setAttributeNS(null, 'width', `${defaultWidth}px`);\n svg.setAttributeNS(null, 'viewBox', `0 0 ${defaultWidth} ${defaultHeight}`);\n\n const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n markerLarge.setAttributeNS(null, 'stroke', 'none');\n markerLarge.setAttributeNS(null, 'stroke-width', '1');\n markerLarge.setAttributeNS(null, 'fill', 'none');\n markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd');\n\n const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n page1.setAttributeNS(null, 'fill-rule', 'nonzero');\n\n const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)');\n shadow.setAttributeNS(null, 'fill', '#000000');\n\n const ellipses = [\n {'rx': '10.5', 'ry': '5.25002273'},\n {'rx': '10.5', 'ry': '5.25002273'},\n {'rx': '9.5', 'ry': '4.77275007'},\n {'rx': '8.5', 'ry': '4.29549936'},\n {'rx': '7.5', 'ry': '3.81822308'},\n {'rx': '6.5', 'ry': '3.34094679'},\n {'rx': '5.5', 'ry': '2.86367051'},\n {'rx': '4.5', 'ry': '2.38636864'}\n ];\n\n for (const data of ellipses) {\n const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse');\n ellipse.setAttributeNS(null, 'opacity', '0.04');\n ellipse.setAttributeNS(null, 'cx', '10.5');\n ellipse.setAttributeNS(null, 'cy', '5.80029008');\n ellipse.setAttributeNS(null, 'rx', data['rx']);\n ellipse.setAttributeNS(null, 'ry', data['ry']);\n shadow.appendChild(ellipse);\n }\n\n const background = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n background.setAttributeNS(null, 'fill', this._color);\n\n const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');\n bgPath.setAttributeNS(null, 'd', 'M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z');\n\n background.appendChild(bgPath);\n\n const border = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n border.setAttributeNS(null, 'opacity', '0.25');\n border.setAttributeNS(null, 'fill', '#000000');\n\n const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');\n borderPath.setAttributeNS(null, 'd', 'M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z');\n\n border.appendChild(borderPath);\n\n const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)');\n maki.setAttributeNS(null, 'fill', '#FFFFFF');\n\n const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)');\n\n const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');\n circle1.setAttributeNS(null, 'fill', '#000000');\n circle1.setAttributeNS(null, 'opacity', '0.25');\n circle1.setAttributeNS(null, 'cx', '5.5');\n circle1.setAttributeNS(null, 'cy', '5.5');\n circle1.setAttributeNS(null, 'r', '5.4999962');\n\n const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');\n circle2.setAttributeNS(null, 'fill', '#FFFFFF');\n circle2.setAttributeNS(null, 'cx', '5.5');\n circle2.setAttributeNS(null, 'cy', '5.5');\n circle2.setAttributeNS(null, 'r', '5.4999962');\n\n circleContainer.appendChild(circle1);\n circleContainer.appendChild(circle2);\n\n page1.appendChild(shadow);\n page1.appendChild(background);\n page1.appendChild(border);\n page1.appendChild(maki);\n page1.appendChild(circleContainer);\n\n svg.appendChild(page1);\n\n svg.setAttributeNS(null, 'height', `${defaultHeight * this._scale}px`);\n svg.setAttributeNS(null, 'width', `${defaultWidth * this._scale}px`);\n\n this._element.appendChild(svg);\n\n // if no element and no offset option given apply an offset for the default marker\n // the -14 as the y value of the default marker offset was determined as follows\n //\n // the marker tip is at the center of the shadow ellipse from the default svg\n // the y value of the center of the shadow ellipse relative to the svg top left is \"shadow transform translate-y (29.0) + ellipse cy (5.80029008)\"\n // offset to the svg center \"height (41 / 2)\" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14\n // negative is used to move the marker up from the center so the tip is at the Marker lngLat\n this._offset = Point.convert(options && options.offset || [0, -14]);\n } else {\n this._element = options.element;\n this._offset = Point.convert(options && options.offset || [0, 0]);\n }\n\n this._element.classList.add('maplibregl-marker');\n this._element.addEventListener('dragstart', (e: DragEvent) => {\n e.preventDefault();\n });\n this._element.addEventListener('mousedown', (e: MouseEvent) => {\n // prevent focusing on click\n e.preventDefault();\n });\n applyAnchorClass(this._element, this._anchor, 'marker');\n\n if (options && options.className) {\n for (const name of options.className.split(' ')) {\n this._element.classList.add(name);\n }\n }\n\n this._popup = null;\n }\n\n /**\n * Attaches the `Marker` to a `Map` object.\n * @param map - The MapLibre GL JS map to add the marker to.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([30.5, 50.5])\n * .addTo(map); // add the marker to the map\n * ```\n */\n addTo(map: Map): this {\n this.remove();\n this._map = map;\n map.getCanvasContainer().appendChild(this._element);\n map.on('move', this._update);\n map.on('moveend', this._update);\n map.on('terrain', this._update);\n\n this.setDraggable(this._draggable);\n this._update();\n\n // If we attached the `click` listener to the marker element, the popup\n // would close once the event propagated to `map` due to the\n // `Popup#_onClickClose` listener.\n this._map.on('click', this._onMapClick);\n\n return this;\n }\n\n /**\n * Removes the marker from a map\n * @example\n * ```ts\n * let marker = new maplibregl.Marker().addTo(map);\n * marker.remove();\n * ```\n * @returns `this`\n */\n remove(): this {\n if (this._opacityTimeout) {\n clearTimeout(this._opacityTimeout);\n delete this._opacityTimeout;\n }\n if (this._map) {\n this._map.off('click', this._onMapClick);\n this._map.off('move', this._update);\n this._map.off('moveend', this._update);\n this._map.off('mousedown', this._addDragHandler);\n this._map.off('touchstart', this._addDragHandler);\n this._map.off('mouseup', this._onUp);\n this._map.off('touchend', this._onUp);\n this._map.off('mousemove', this._onMove);\n this._map.off('touchmove', this._onMove);\n delete this._map;\n }\n DOM.remove(this._element);\n if (this._popup) this._popup.remove();\n return this;\n }\n\n /**\n * Get the marker's geographical location.\n *\n * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously\n * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep\n * the marker on screen.\n *\n * @returns A {@link LngLat} describing the marker's location.\n * @example\n * ```ts\n * // Store the marker's longitude and latitude coordinates in a variable\n * let lngLat = marker.getLngLat();\n * // Print the marker's longitude and latitude values in the console\n * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat )\n * ```\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n /**\n * Set the marker's geographical position and move it.\n * @param lnglat - A {@link LngLat} describing where the marker should be located.\n * @returns `this`\n * @example\n * Create a new marker, set the longitude and latitude, and add it to the map\n * ```ts\n * new maplibregl.Marker()\n * .setLngLat([-65.017, -16.457])\n * .addTo(map);\n * ```\n * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n setLngLat(lnglat: LngLatLike): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n if (this._popup) this._popup.setLngLat(this._lngLat);\n this._update();\n return this;\n }\n\n /**\n * Returns the `Marker`'s HTML element.\n * @returns element\n */\n getElement(): HTMLElement {\n return this._element;\n }\n\n /**\n * Binds a {@link Popup} to the {@link Marker}.\n * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup\n * set on this {@link Marker} instance is unset.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\")) // add popup\n * .addTo(map);\n * ```\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n */\n setPopup(popup?: Popup | null): this {\n if (this._popup) {\n this._popup.remove();\n this._popup = null;\n this._element.removeEventListener('keypress', this._onKeyPress);\n\n if (!this._originalTabIndex) {\n this._element.removeAttribute('tabindex');\n }\n }\n\n if (popup) {\n if (!('offset' in popup.options)) {\n const markerHeight = 41 - (5.8 / 2);\n const markerRadius = 13.5;\n const linearOffset = Math.abs(markerRadius) / Math.SQRT2;\n popup.options.offset = this._defaultMarker ? {\n 'top': [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n 'bottom': [0, -markerHeight],\n 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n 'left': [markerRadius, (markerHeight - markerRadius) * -1],\n 'right': [-markerRadius, (markerHeight - markerRadius) * -1]\n } as Offset : this._offset;\n }\n this._popup = popup;\n if (this._lngLat) this._popup.setLngLat(this._lngLat);\n\n this._originalTabIndex = this._element.getAttribute('tabindex');\n if (!this._originalTabIndex) {\n this._element.setAttribute('tabindex', '0');\n }\n this._element.addEventListener('keypress', this._onKeyPress);\n }\n\n return this;\n }\n\n _onKeyPress = (e: KeyboardEvent) => {\n const code = e.code;\n const legacyCode = e.charCode || e.keyCode;\n\n if (\n (code === 'Space') || (code === 'Enter') ||\n (legacyCode === 32) || (legacyCode === 13) // space or enter\n ) {\n this.togglePopup();\n }\n };\n\n _onMapClick = (e: MapMouseEvent) => {\n const targetElement = e.originalEvent.target;\n const element = this._element;\n\n if (this._popup && (targetElement === element || element.contains(targetElement as any))) {\n this.togglePopup();\n }\n };\n\n /**\n * Returns the {@link Popup} instance that is bound to the {@link Marker}.\n * @returns popup\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\"))\n * .addTo(map);\n *\n * console.log(marker.getPopup()); // return the popup instance\n * ```\n */\n getPopup(): Popup {\n return this._popup;\n }\n\n /**\n * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\"))\n * .addTo(map);\n *\n * marker.togglePopup(); // toggle popup open or closed\n * ```\n */\n togglePopup(): this {\n const popup = this._popup;\n\n if (!popup) return this;\n else if (popup.isOpen()) popup.remove();\n else popup.addTo(this._map);\n return this;\n }\n\n _update = (e?: { type: 'move' | 'moveend' | 'terrain' | 'render' }) => {\n if (!this._map) return;\n\n const isFullyLoaded = this._map.loaded() && !this._map.isMoving();\n if (e?.type === 'terrain' || (e?.type === 'render' && !isFullyLoaded)) {\n this._map.once('render', this._update);\n }\n\n if (this._map.transform.renderWorldCopies) {\n this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);\n }\n\n this._pos = this._map.project(this._lngLat)._add(this._offset);\n\n let rotation = '';\n if (this._rotationAlignment === 'viewport' || this._rotationAlignment === 'auto') {\n rotation = `rotateZ(${this._rotation}deg)`;\n } else if (this._rotationAlignment === 'map') {\n rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`;\n }\n\n let pitch = '';\n if (this._pitchAlignment === 'viewport' || this._pitchAlignment === 'auto') {\n pitch = 'rotateX(0deg)';\n } else if (this._pitchAlignment === 'map') {\n pitch = `rotateX(${this._map.getPitch()}deg)`;\n }\n\n // because rounding the coordinates at every `move` event causes stuttered zooming\n // we only round them when _update is called with `moveend` or when its called with\n // no arguments (when the Marker is initialized or Marker#setLngLat is invoked).\n if (!e || e.type === 'moveend') {\n this._pos = this._pos.round();\n }\n\n DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`);\n\n // in case of 3D, ask the terrain coords-framebuffer for this pos and check if the marker is visible\n // call this logic in setTimeout with a timeout of 100ms to save performance in map-movement\n if (this._map.terrain && !this._opacityTimeout) this._opacityTimeout = setTimeout(() => {\n const lnglat = this._map.unproject(this._pos);\n const metresPerPixel = 40075016.686 * Math.abs(Math.cos(this._lngLat.lat * Math.PI / 180)) / Math.pow(2, this._map.transform.tileZoom + 8);\n this._element.style.opacity = lnglat.distanceTo(this._lngLat) > metresPerPixel * 20 ? '0.2' : '1.0';\n this._opacityTimeout = null;\n }, 100);\n };\n\n /**\n * Get the marker's offset.\n * @returns The marker's screen coordinates in pixels.\n */\n getOffset(): Point {\n return this._offset;\n }\n\n /**\n * Sets the offset of the marker\n * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.\n * @returns `this`\n */\n setOffset(offset: PointLike): this {\n this._offset = Point.convert(offset);\n this._update();\n return this;\n }\n\n /**\n * Adds a CSS class to the marker element.\n *\n * @param className - on-empty string with CSS class name to add to marker element\n *\n * @example\n * ```\n * let marker = new maplibregl.Marker()\n * marker.addClassName('some-class')\n * ```\n */\n addClassName(className: string) {\n this._element.classList.add(className);\n }\n\n /**\n * Removes a CSS class from the marker element.\n *\n * @param className - Non-empty string with CSS class name to remove from marker element\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * marker.removeClassName('some-class')\n * ```\n */\n removeClassName(className: string) {\n this._element.classList.remove(className);\n }\n\n /**\n * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class.\n *\n * @param className - Non-empty string with CSS class name to add/remove\n *\n * @returns if the class was removed return false, if class was added, then return true\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * marker.toggleClassName('toggleClass')\n * ```\n */\n toggleClassName(className: string): boolean {\n return this._element.classList.toggle(className);\n }\n\n _onMove = (e: MapMouseEvent | MapTouchEvent) => {\n if (!this._isDragging) {\n const clickTolerance = this._clickTolerance || this._map._clickTolerance;\n this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance;\n }\n if (!this._isDragging) return;\n\n this._pos = e.point.sub(this._positionDelta);\n this._lngLat = this._map.unproject(this._pos);\n this.setLngLat(this._lngLat);\n // suppress click event so that popups don't toggle on drag\n this._element.style.pointerEvents = 'none';\n\n // make sure dragstart only fires on the first move event after mousedown.\n // this can't be on mousedown because that event doesn't necessarily\n // imply that a drag is about to happen.\n if (this._state === 'pending') {\n this._state = 'active';\n this.fire(new Event('dragstart'));\n }\n this.fire(new Event('drag'));\n };\n\n _onUp = () => {\n // revert to normal pointer event handling\n this._element.style.pointerEvents = 'auto';\n this._positionDelta = null;\n this._pointerdownPos = null;\n this._isDragging = false;\n this._map.off('mousemove', this._onMove);\n this._map.off('touchmove', this._onMove);\n\n // only fire dragend if it was preceded by at least one drag event\n if (this._state === 'active') {\n this.fire(new Event('dragend'));\n }\n\n this._state = 'inactive';\n };\n\n _addDragHandler = (e: MapMouseEvent | MapTouchEvent) => {\n if (this._element.contains(e.originalEvent.target as any)) {\n e.preventDefault();\n\n // We need to calculate the pixel distance between the click point\n // and the marker position, with the offset accounted for. Then we\n // can subtract this distance from the mousemove event's position\n // to calculate the new marker position.\n // If we don't do this, the marker 'jumps' to the click position\n // creating a jarring UX effect.\n this._positionDelta = e.point.sub(this._pos).add(this._offset);\n\n this._pointerdownPos = e.point;\n\n this._state = 'pending';\n this._map.on('mousemove', this._onMove);\n this._map.on('touchmove', this._onMove);\n this._map.once('mouseup', this._onUp);\n this._map.once('touchend', this._onUp);\n }\n };\n\n /**\n * Sets the `draggable` property and functionality of the marker\n * @param shouldBeDraggable - Turns drag functionality on/off\n * @returns `this`\n */\n setDraggable(shouldBeDraggable?: boolean): this {\n this._draggable = !!shouldBeDraggable; // convert possible undefined value to false\n\n // handle case where map may not exist yet\n // e.g. when setDraggable is called before addTo\n if (this._map) {\n if (shouldBeDraggable) {\n this._map.on('mousedown', this._addDragHandler);\n this._map.on('touchstart', this._addDragHandler);\n } else {\n this._map.off('mousedown', this._addDragHandler);\n this._map.off('touchstart', this._addDragHandler);\n }\n }\n\n return this;\n }\n\n /**\n * Returns true if the marker can be dragged\n * @returns True if the marker is draggable.\n */\n isDraggable(): boolean {\n return this._draggable;\n }\n\n /**\n * Sets the `rotation` property of the marker.\n * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting.\n * @returns `this`\n */\n setRotation(rotation?: number): this {\n this._rotation = rotation || 0;\n this._update();\n return this;\n }\n\n /**\n * Returns the current rotation angle of the marker (in degrees).\n * @returns The current rotation angle of the marker.\n */\n getRotation(): number {\n return this._rotation;\n }\n\n /**\n * Sets the `rotationAlignment` property of the marker.\n * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto'\n * @returns `this`\n */\n setRotationAlignment(alignment?: Alignment): this {\n this._rotationAlignment = alignment || 'auto';\n this._update();\n return this;\n }\n\n /**\n * Returns the current `rotationAlignment` property of the marker.\n * @returns The current rotational alignment of the marker.\n */\n getRotationAlignment(): Alignment {\n return this._rotationAlignment;\n }\n\n /**\n * Sets the `pitchAlignment` property of the marker.\n * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`.\n * @returns `this`\n */\n setPitchAlignment(alignment?: Alignment): this {\n this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment;\n this._update();\n return this;\n }\n\n /**\n * Returns the current `pitchAlignment` property of the marker.\n * @returns The current pitch alignment of the marker in degrees.\n */\n getPitchAlignment(): Alignment {\n return this._pitchAlignment;\n }\n}\n","import {Event, Evented} from '../../util/evented';\nimport {DOM} from '../../util/dom';\nimport {extend, warnOnce} from '../../util/util';\nimport {checkGeolocationSupport} from '../../util/geolocation_support';\nimport {LngLat} from '../../geo/lng_lat';\nimport {Marker} from '../marker';\n\nimport type {Map} from '../map';\nimport type {FitBoundsOptions} from '../camera';\nimport type {IControl} from './control';\nimport {LngLatBounds} from '../../geo/lng_lat_bounds';\n\n/**\n * The {@link GeolocateControl} options\n */\ntype GeolocateOptions = {\n /**\n * A Geolocation API [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) object.\n * @defaultValue `{enableHighAccuracy: false, timeout: 6000}`\n */\n positionOptions?: PositionOptions;\n /**\n * A options object to use when the map is panned and zoomed to the user's location. The default is to use a `maxZoom` of 15 to limit how far the map will zoom in for very accurate locations.\n */\n fitBoundsOptions?: FitBoundsOptions;\n /**\n * If `true` the Geolocate Control becomes a toggle button and when active the map will receive updates to the user's location as it changes.\n * @defaultValue false\n */\n trackUserLocation?: boolean;\n /**\n * By default, if showUserLocation is `true`, a transparent circle will be drawn around the user location indicating the accuracy (95% confidence level) of the user's location. Set to `false` to disable. Always disabled when showUserLocation is `false`.\n * @defaultValue true\n */\n showAccuracyCircle?: boolean;\n /**\n * By default a dot will be shown on the map at the user's location. Set to `false` to disable.\n * @defaultValue true\n */\n showUserLocation?: boolean;\n};\n\nconst defaultOptions: GeolocateOptions = {\n positionOptions: {\n enableHighAccuracy: false,\n maximumAge: 0,\n timeout: 6000 /* 6 sec */\n },\n fitBoundsOptions: {\n maxZoom: 15\n },\n trackUserLocation: false,\n showAccuracyCircle: true,\n showUserLocation: true\n};\n\nlet numberOfWatches = 0;\nlet noTimeout = false;\n\n/**\n * A `GeolocateControl` control provides a button that uses the browser's geolocation\n * API to locate the user on the map.\n *\n * Not all browsers support geolocation,\n * and some users may disable the feature. Geolocation support for modern\n * browsers including Chrome requires sites to be served over HTTPS. If\n * geolocation support is not available, the GeolocateControl will show\n * as disabled.\n *\n * The zoom level applied will depend on the accuracy of the geolocation provided by the device.\n *\n * The GeolocateControl has two modes. If `trackUserLocation` is `false` (default) the control acts as a button, which when pressed will set the map's camera to target the user location. If the user moves, the map won't update. This is most suited for the desktop. If `trackUserLocation` is `true` the control acts as a toggle button that when active the user's location is actively monitored for changes. In this mode the GeolocateControl has three interaction states:\n * * active - the map's camera automatically updates as the user's location changes, keeping the location dot in the center. Initial state and upon clicking the `GeolocateControl` button.\n * * passive - the user's location dot automatically updates, but the map's camera does not. Occurs upon the user initiating a map movement.\n * * disabled - occurs if Geolocation is not available, disabled or denied.\n *\n * These interaction states can't be controlled programmatically, rather they are set based on user interactions.\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * }));\n * ```\n * @see [Locate the user](https://maplibre.org/maplibre-gl-js/docs/examples/locate-user/)\n *\n * ### Events\n *\n * @event `trackuserlocationend` - Fired when the Geolocate Control changes to the background state, which happens when a user changes the camera during an active position lock. This only applies when trackUserLocation is true. In the background state, the dot on the map will update with location updates but the camera will not.\n *\n * @event `trackuserlocationstart` - Fired when the Geolocate Control changes to the active lock state, which happens either upon first obtaining a successful Geolocation API position for the user (a geolocate event will follow), or the user clicks the geolocate button when in the background state which uses the last known position to recenter the map and enter active lock state (no geolocate event will follow unless the users's location changes).\n *\n * @event `geolocate` - Fired on each Geolocation API position update which returned as success.\n * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @event `error` - Fired on each Geolocation API position update which returned as an error.\n * `data` - The returned [PositionError](https://developer.mozilla.org/en-US/docs/Web/API/PositionError) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @event `outofmaxbounds` Fired on each Geolocation API position update which returned as success but user position is out of map maxBounds.\n * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a trackuserlocationend event occurs.\n * geolocate.on('trackuserlocationend', function() {\n * console.log('A trackuserlocationend event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a trackuserlocationstart event occurs.\n * geolocate.on('trackuserlocationstart', function() {\n * console.log('A trackuserlocationstart event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a geolocate event occurs.\n * geolocate.on('geolocate', function() {\n * console.log('A geolocate event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when an error event occurs.\n * geolocate.on('error', function() {\n * console.log('An error event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when an outofmaxbounds event occurs.\n * geolocate.on('outofmaxbounds', function() {\n * console.log('An outofmaxbounds event has occurred.')\n * });\n * ```\n */\nexport class GeolocateControl extends Evented implements IControl {\n _map: Map;\n options: GeolocateOptions;\n _container: HTMLElement;\n _dotElement: HTMLElement;\n _circleElement: HTMLElement;\n _geolocateButton: HTMLButtonElement;\n _geolocationWatchID: number;\n _timeoutId: ReturnType;\n /* Geolocate Control Watch States\n * This is the private state of the control.\n *\n * OFF\n * off/inactive\n * WAITING_ACTIVE\n * Geolocate Control was clicked but still waiting for Geolocation API response with user location\n * ACTIVE_LOCK\n * Showing the user location as a dot AND tracking the camera to be fixed to their location. If their location changes the map moves to follow.\n * ACTIVE_ERROR\n * There was en error from the Geolocation API while trying to show and track the user location.\n * BACKGROUND\n * Showing the user location as a dot but the camera doesn't follow their location as it changes.\n * BACKGROUND_ERROR\n * There was an error from the Geolocation API while trying to show (but not track) the user location.\n */\n _watchState: 'OFF' | 'ACTIVE_LOCK' | 'WAITING_ACTIVE' | 'ACTIVE_ERROR' | 'BACKGROUND' | 'BACKGROUND_ERROR';\n _lastKnownPosition: any;\n _userLocationDotMarker: Marker;\n _accuracyCircleMarker: Marker;\n _accuracy: number;\n _setup: boolean; // set to true once the control has been setup\n\n constructor(options: GeolocateOptions) {\n super();\n this.options = extend({}, defaultOptions, options);\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n checkGeolocationSupport(this._setupUI);\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n // clear the geolocation watch if exists\n if (this._geolocationWatchID !== undefined) {\n window.navigator.geolocation.clearWatch(this._geolocationWatchID);\n this._geolocationWatchID = undefined;\n }\n\n // clear the markers from the map\n if (this.options.showUserLocation && this._userLocationDotMarker) {\n this._userLocationDotMarker.remove();\n }\n if (this.options.showAccuracyCircle && this._accuracyCircleMarker) {\n this._accuracyCircleMarker.remove();\n }\n\n DOM.remove(this._container);\n this._map.off('zoom', this._onZoom);\n this._map = undefined;\n numberOfWatches = 0;\n noTimeout = false;\n }\n\n /**\n * Check if the Geolocation API Position is outside the map's maxbounds.\n *\n * @param position - the Geolocation API Position\n * @returns `true` if position is outside the map's maxbounds, otherwise returns `false`.\n */\n _isOutOfMapMaxBounds(position: GeolocationPosition) {\n const bounds = this._map.getMaxBounds();\n const coordinates = position.coords;\n\n return bounds && (\n coordinates.longitude < bounds.getWest() ||\n coordinates.longitude > bounds.getEast() ||\n coordinates.latitude < bounds.getSouth() ||\n coordinates.latitude > bounds.getNorth()\n );\n }\n\n _setErrorState() {\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n this._watchState = 'ACTIVE_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error');\n break;\n case 'ACTIVE_LOCK':\n this._watchState = 'ACTIVE_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n // turn marker grey\n break;\n case 'BACKGROUND':\n this._watchState = 'BACKGROUND_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n // turn marker grey\n break;\n case 'ACTIVE_ERROR':\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n }\n\n /**\n * When the Geolocation API returns a new location, update the GeolocateControl.\n *\n * @param position - the Geolocation API Position\n */\n _onSuccess = (position: GeolocationPosition) => {\n if (!this._map) {\n // control has since been removed\n return;\n }\n\n if (this._isOutOfMapMaxBounds(position)) {\n this._setErrorState();\n\n this.fire(new Event('outofmaxbounds', position));\n this._updateMarker();\n this._finish();\n\n return;\n }\n\n if (this.options.trackUserLocation) {\n // keep a record of the position so that if the state is BACKGROUND and the user\n // clicks the button, we can move to ACTIVE_LOCK immediately without waiting for\n // watchPosition to trigger _onSuccess\n this._lastKnownPosition = position;\n\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n case 'ACTIVE_LOCK':\n case 'ACTIVE_ERROR':\n this._watchState = 'ACTIVE_LOCK';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'BACKGROUND':\n case 'BACKGROUND_ERROR':\n this._watchState = 'BACKGROUND';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background');\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n }\n\n // if showUserLocation and the watch state isn't off then update the marker location\n if (this.options.showUserLocation && this._watchState !== 'OFF') {\n this._updateMarker(position);\n }\n\n // if in normal mode (not watch mode), or if in watch mode and the state is active watch\n // then update the camera\n if (!this.options.trackUserLocation || this._watchState === 'ACTIVE_LOCK') {\n this._updateCamera(position);\n }\n\n if (this.options.showUserLocation) {\n this._dotElement.classList.remove('maplibregl-user-location-dot-stale');\n }\n\n this.fire(new Event('geolocate', position));\n this._finish();\n };\n\n /**\n * Update the camera location to center on the current position\n *\n * @param position - the Geolocation API Position\n */\n _updateCamera = (position: GeolocationPosition) => {\n const center = new LngLat(position.coords.longitude, position.coords.latitude);\n const radius = position.coords.accuracy;\n const bearing = this._map.getBearing();\n const options = extend({bearing}, this.options.fitBoundsOptions);\n const newBounds = LngLatBounds.fromLngLat(center, radius);\n\n this._map.fitBounds(newBounds, options, {\n geolocateSource: true // tag this camera change so it won't cause the control to change to background state\n });\n };\n\n /**\n * Update the user location dot Marker to the current position\n *\n * @param position - the Geolocation API Position\n */\n _updateMarker = (position?: GeolocationPosition | null) => {\n if (position) {\n const center = new LngLat(position.coords.longitude, position.coords.latitude);\n this._accuracyCircleMarker.setLngLat(center).addTo(this._map);\n this._userLocationDotMarker.setLngLat(center).addTo(this._map);\n this._accuracy = position.coords.accuracy;\n if (this.options.showUserLocation && this.options.showAccuracyCircle) {\n this._updateCircleRadius();\n }\n } else {\n this._userLocationDotMarker.remove();\n this._accuracyCircleMarker.remove();\n }\n };\n\n _updateCircleRadius() {\n const bounds = this._map.getBounds();\n const southEastPoint = bounds.getSouthEast();\n const northEastPoint = bounds.getNorthEast();\n const mapHeightInMeters = southEastPoint.distanceTo(northEastPoint);\n const mapHeightInPixels = this._map._container.clientHeight;\n const circleDiameter = Math.ceil(2 * (this._accuracy / (mapHeightInMeters / mapHeightInPixels)));\n this._circleElement.style.width = `${circleDiameter}px`;\n this._circleElement.style.height = `${circleDiameter}px`;\n }\n\n _onZoom = () => {\n if (this.options.showUserLocation && this.options.showAccuracyCircle) {\n this._updateCircleRadius();\n }\n };\n\n _onError = (error: GeolocationPositionError) => {\n if (!this._map) {\n // control has since been removed\n return;\n }\n\n if (this.options.trackUserLocation) {\n if (error.code === 1) {\n // PERMISSION_DENIED\n this._watchState = 'OFF';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.disabled = true;\n const title = this._map._getUIString('GeolocateControl.LocationNotAvailable');\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n\n if (this._geolocationWatchID !== undefined) {\n this._clearWatch();\n }\n } else if (error.code === 3 && noTimeout) {\n // this represents a forced error state\n // this was triggered to force immediate geolocation when a watch is already present\n // see https://github.com/mapbox/mapbox-gl-js/issues/8214\n // and https://w3c.github.io/geolocation-api/#example-5-forcing-the-user-agent-to-return-a-fresh-cached-position\n return;\n } else {\n this._setErrorState();\n }\n }\n\n if (this._watchState !== 'OFF' && this.options.showUserLocation) {\n this._dotElement.classList.add('maplibregl-user-location-dot-stale');\n }\n\n this.fire(new Event('error', error));\n\n this._finish();\n };\n\n _finish = () => {\n if (this._timeoutId) { clearTimeout(this._timeoutId); }\n this._timeoutId = undefined;\n };\n\n _setupUI = (supported: boolean) => {\n // this method is called asynchronously during onAdd\n // the control could have been removed before reaching here\n if (!this._map) {\n return;\n }\n\n this._container.addEventListener('contextmenu', (e: MouseEvent) => e.preventDefault());\n this._geolocateButton = DOM.create('button', 'maplibregl-ctrl-geolocate', this._container);\n DOM.create('span', 'maplibregl-ctrl-icon', this._geolocateButton).setAttribute('aria-hidden', 'true');\n this._geolocateButton.type = 'button';\n\n if (supported === false) {\n warnOnce('Geolocation support is not available so the GeolocateControl will be disabled.');\n const title = this._map._getUIString('GeolocateControl.LocationNotAvailable');\n this._geolocateButton.disabled = true;\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n } else {\n const title = this._map._getUIString('GeolocateControl.FindMyLocation');\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n }\n\n if (this.options.trackUserLocation) {\n this._geolocateButton.setAttribute('aria-pressed', 'false');\n this._watchState = 'OFF';\n }\n\n // when showUserLocation is enabled, keep the Geolocate button disabled until the device location marker is setup on the map\n if (this.options.showUserLocation) {\n this._dotElement = DOM.create('div', 'maplibregl-user-location-dot');\n\n this._userLocationDotMarker = new Marker({element: this._dotElement});\n\n this._circleElement = DOM.create('div', 'maplibregl-user-location-accuracy-circle');\n this._accuracyCircleMarker = new Marker({element: this._circleElement, pitchAlignment: 'map'});\n\n if (this.options.trackUserLocation) this._watchState = 'OFF';\n\n this._map.on('zoom', this._onZoom);\n }\n\n this._geolocateButton.addEventListener('click',\n this.trigger.bind(this));\n\n this._setup = true;\n\n // when the camera is changed (and it's not as a result of the Geolocation Control) change\n // the watch mode to background watch, so that the marker is updated but not the camera.\n if (this.options.trackUserLocation) {\n this._map.on('movestart', (event: any) => {\n const fromResize = event.originalEvent && event.originalEvent.type === 'resize';\n if (!event.geolocateSource && this._watchState === 'ACTIVE_LOCK' && !fromResize) {\n this._watchState = 'BACKGROUND';\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n\n this.fire(new Event('trackuserlocationend'));\n }\n });\n }\n };\n\n /**\n * Programmatically request and move the map to the user's location.\n *\n * @returns `false` if called before control was added to a map, otherwise returns `true`.\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * map.on('load', function() {\n * geolocate.trigger();\n * });\n * ```\n */\n trigger(): boolean {\n if (!this._setup) {\n warnOnce('Geolocate control triggered before added to a map');\n return false;\n }\n if (this.options.trackUserLocation) {\n // update watchState and do any outgoing state cleanup\n switch (this._watchState) {\n case 'OFF':\n // turn on the Geolocate Control\n this._watchState = 'WAITING_ACTIVE';\n\n this.fire(new Event('trackuserlocationstart'));\n break;\n case 'WAITING_ACTIVE':\n case 'ACTIVE_LOCK':\n case 'ACTIVE_ERROR':\n case 'BACKGROUND_ERROR':\n // turn off the Geolocate Control\n numberOfWatches--;\n noTimeout = false;\n this._watchState = 'OFF';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n\n this.fire(new Event('trackuserlocationend'));\n break;\n case 'BACKGROUND':\n this._watchState = 'ACTIVE_LOCK';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n // set camera to last known location\n if (this._lastKnownPosition) this._updateCamera(this._lastKnownPosition);\n\n this.fire(new Event('trackuserlocationstart'));\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n\n // incoming state setup\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'ACTIVE_LOCK':\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'OFF':\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n\n // manage geolocation.watchPosition / geolocation.clearWatch\n if (this._watchState === 'OFF' && this._geolocationWatchID !== undefined) {\n // clear watchPosition as we've changed to an OFF state\n this._clearWatch();\n } else if (this._geolocationWatchID === undefined) {\n // enable watchPosition since watchState is not OFF and there is no watchPosition already running\n\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.setAttribute('aria-pressed', 'true');\n\n numberOfWatches++;\n let positionOptions;\n if (numberOfWatches > 1) {\n positionOptions = {maximumAge: 600000, timeout: 0};\n noTimeout = true;\n } else {\n positionOptions = this.options.positionOptions;\n noTimeout = false;\n }\n\n this._geolocationWatchID = window.navigator.geolocation.watchPosition(\n this._onSuccess, this._onError, positionOptions);\n }\n } else {\n window.navigator.geolocation.getCurrentPosition(\n this._onSuccess, this._onError, this.options.positionOptions);\n\n // This timeout ensures that we still call finish() even if\n // the user declines to share their location in Firefox\n this._timeoutId = setTimeout(this._finish, 10000 /* 10sec */);\n }\n\n return true;\n }\n\n _clearWatch() {\n window.navigator.geolocation.clearWatch(this._geolocationWatchID);\n\n this._geolocationWatchID = undefined;\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.setAttribute('aria-pressed', 'false');\n\n if (this.options.showUserLocation) {\n this._updateMarker(null);\n }\n }\n}\n\n","import {DOM} from '../../util/dom';\nimport {extend} from '../../util/util';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\n\n/**\n * The unit type for length to use for the {@link ScaleControl}\n */\nexport type Unit = 'imperial' | 'metric' | 'nautical';\n\n/**\n * The {@link ScaleControl} options object\n */\ntype ScaleOptions = {\n /**\n * The maximum length of the scale control in pixels.\n * @defaultValue 100\n */\n maxWidth?: number;\n /**\n * Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).\n * @defaultValue 'metric'\n */\n unit?: Unit;\n};\n\nconst defaultOptions: ScaleOptions = {\n maxWidth: 100,\n unit: 'metric'\n};\n\n/**\n * A `ScaleControl` control displays the ratio of a distance on the map to the corresponding distance on the ground.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let scale = new maplibregl.ScaleControl({\n * maxWidth: 80,\n * unit: 'imperial'\n * });\n * map.addControl(scale);\n *\n * scale.setUnit('metric');\n * ```\n */\nexport class ScaleControl implements IControl {\n _map: Map;\n _container: HTMLElement;\n options: ScaleOptions;\n\n constructor(options: ScaleOptions) {\n this.options = extend({}, defaultOptions, options);\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-left';\n }\n\n _onMove = () => {\n updateScale(this._map, this._container, this.options);\n };\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-scale', map.getContainer());\n\n this._map.on('move', this._onMove);\n this._onMove();\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('move', this._onMove);\n this._map = undefined;\n }\n\n /**\n * Set the scale's unit of the distance\n *\n * @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).\n */\n setUnit = (unit: Unit) => {\n this.options.unit = unit;\n updateScale(this._map, this._container, this.options);\n };\n}\n\nfunction updateScale(map, container, options) {\n // A horizontal scale is imagined to be present at center of the map\n // container with maximum length (Default) as 100px.\n // Using spherical law of cosines approximation, the real distance is\n // found between the two coordinates.\n const maxWidth = options && options.maxWidth || 100;\n\n const y = map._container.clientHeight / 2;\n const left = map.unproject([0, y]);\n const right = map.unproject([maxWidth, y]);\n const maxMeters = left.distanceTo(right);\n // The real distance corresponding to 100px scale length is rounded off to\n // near pretty number and the scale length for the same is found out.\n // Default unit of the scale is based on User's locale.\n if (options && options.unit === 'imperial') {\n const maxFeet = 3.2808 * maxMeters;\n if (maxFeet > 5280) {\n const maxMiles = maxFeet / 5280;\n setScale(container, maxWidth, maxMiles, map._getUIString('ScaleControl.Miles'));\n } else {\n setScale(container, maxWidth, maxFeet, map._getUIString('ScaleControl.Feet'));\n }\n } else if (options && options.unit === 'nautical') {\n const maxNauticals = maxMeters / 1852;\n setScale(container, maxWidth, maxNauticals, map._getUIString('ScaleControl.NauticalMiles'));\n } else if (maxMeters >= 1000) {\n setScale(container, maxWidth, maxMeters / 1000, map._getUIString('ScaleControl.Kilometers'));\n } else {\n setScale(container, maxWidth, maxMeters, map._getUIString('ScaleControl.Meters'));\n }\n}\n\nfunction setScale(container, maxWidth, maxDistance, unit) {\n const distance = getRoundNum(maxDistance);\n const ratio = distance / maxDistance;\n container.style.width = `${maxWidth * ratio}px`;\n container.innerHTML = `${distance} ${unit}`;\n}\n\nfunction getDecimalRoundNum(d) {\n const multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10));\n return Math.round(d * multiplier) / multiplier;\n}\n\nfunction getRoundNum(num) {\n const pow10 = Math.pow(10, (`${Math.floor(num)}`).length - 1);\n let d = num / pow10;\n\n d = d >= 10 ? 10 :\n d >= 5 ? 5 :\n d >= 3 ? 3 :\n d >= 2 ? 2 :\n d >= 1 ? 1 : getDecimalRoundNum(d);\n\n return pow10 * d;\n}\n","import {DOM} from '../../util/dom';\n\nimport {warnOnce} from '../../util/util';\n\nimport {Event, Evented} from '../../util/evented';\nimport type {Map, GestureOptions} from '../map';\nimport type {IControl} from './control';\n\n/**\n * The {@link FullscreenControl} options\n */\ntype FullscreenOptions = {\n /**\n * `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen.\n */\n container?: HTMLElement;\n};\n\n/**\n * A `FullscreenControl` control contains a button for toggling the map in and out of fullscreen mode.\n * When [requestFullscreen](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen) is not supported, fullscreen is handled via CSS properties.\n * The map's `cooperativeGestures` option is temporarily disabled while the map\n * is in fullscreen mode, and is restored when the map exist fullscreen mode.\n *\n * @group Markers and Controls\n * @param options - the full screen control options\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')}));\n * ```\n * @see [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/)\n *\n * ### Events\n *\n * @event `fullscreenstart` - Fired when fullscreen mode has started\n *\n * @event `fullscreenend` - Fired when fullscreen mode has ended\n */\nexport class FullscreenControl extends Evented implements IControl {\n _map: Map;\n _controlContainer: HTMLElement;\n _fullscreen: boolean;\n _fullscreenchange: string;\n _fullscreenButton: HTMLButtonElement;\n _container: HTMLElement;\n _prevCooperativeGestures: boolean | GestureOptions;\n\n constructor(options: FullscreenOptions = {}) {\n super();\n this._fullscreen = false;\n\n if (options && options.container) {\n if (options.container instanceof HTMLElement) {\n this._container = options.container;\n } else {\n warnOnce('Full screen control \\'container\\' must be a DOM element.');\n }\n }\n\n if ('onfullscreenchange' in document) {\n this._fullscreenchange = 'fullscreenchange';\n } else if ('onmozfullscreenchange' in document) {\n this._fullscreenchange = 'mozfullscreenchange';\n } else if ('onwebkitfullscreenchange' in document) {\n this._fullscreenchange = 'webkitfullscreenchange';\n } else if ('onmsfullscreenchange' in document) {\n this._fullscreenchange = 'MSFullscreenChange';\n }\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map): HTMLElement {\n this._map = map;\n if (!this._container) this._container = this._map.getContainer();\n this._controlContainer = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._setupUI();\n return this._controlContainer;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._controlContainer);\n this._map = null;\n window.document.removeEventListener(this._fullscreenchange, this._onFullscreenChange);\n }\n\n _setupUI() {\n const button = this._fullscreenButton = DOM.create('button', (('maplibregl-ctrl-fullscreen')), this._controlContainer);\n DOM.create('span', 'maplibregl-ctrl-icon', button).setAttribute('aria-hidden', 'true');\n button.type = 'button';\n this._updateTitle();\n this._fullscreenButton.addEventListener('click', this._onClickFullscreen);\n window.document.addEventListener(this._fullscreenchange, this._onFullscreenChange);\n }\n\n _updateTitle() {\n const title = this._getTitle();\n this._fullscreenButton.setAttribute('aria-label', title);\n this._fullscreenButton.title = title;\n }\n\n _getTitle() {\n return this._map._getUIString(this._isFullscreen() ? 'FullscreenControl.Exit' : 'FullscreenControl.Enter');\n }\n\n _isFullscreen() {\n return this._fullscreen;\n }\n\n _onFullscreenChange = () => {\n const fullscreenElement =\n window.document.fullscreenElement ||\n (window.document as any).mozFullScreenElement ||\n (window.document as any).webkitFullscreenElement ||\n (window.document as any).msFullscreenElement;\n\n if ((fullscreenElement === this._container) !== this._fullscreen) {\n this._handleFullscreenChange();\n }\n };\n\n _handleFullscreenChange() {\n this._fullscreen = !this._fullscreen;\n this._fullscreenButton.classList.toggle('maplibregl-ctrl-shrink');\n this._fullscreenButton.classList.toggle('maplibregl-ctrl-fullscreen');\n this._updateTitle();\n\n if (this._fullscreen) {\n this.fire(new Event('fullscreenstart'));\n if (this._map._cooperativeGestures) {\n this._prevCooperativeGestures = this._map._cooperativeGestures;\n this._map.setCooperativeGestures();\n }\n } else {\n this.fire(new Event('fullscreenend'));\n if (this._prevCooperativeGestures) {\n this._map.setCooperativeGestures(this._prevCooperativeGestures);\n delete this._prevCooperativeGestures;\n }\n }\n }\n\n _onClickFullscreen = () => {\n if (this._isFullscreen()) {\n this._exitFullscreen();\n } else {\n this._requestFullscreen();\n }\n };\n\n _exitFullscreen() {\n if (window.document.exitFullscreen) {\n (window.document as any).exitFullscreen();\n } else if ((window.document as any).mozCancelFullScreen) {\n (window.document as any).mozCancelFullScreen();\n } else if ((window.document as any).msExitFullscreen) {\n (window.document as any).msExitFullscreen();\n } else if ((window.document as any).webkitCancelFullScreen) {\n (window.document as any).webkitCancelFullScreen();\n } else {\n this._togglePseudoFullScreen();\n }\n }\n\n _requestFullscreen() {\n if (this._container.requestFullscreen) {\n this._container.requestFullscreen();\n } else if ((this._container as any).mozRequestFullScreen) {\n (this._container as any).mozRequestFullScreen();\n } else if ((this._container as any).msRequestFullscreen) {\n (this._container as any).msRequestFullscreen();\n } else if ((this._container as any).webkitRequestFullscreen) {\n (this._container as any).webkitRequestFullscreen();\n } else {\n this._togglePseudoFullScreen();\n }\n }\n\n _togglePseudoFullScreen() {\n this._container.classList.toggle('maplibregl-pseudo-fullscreen');\n this._handleFullscreenChange();\n this._map.resize();\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {IControl} from './control';\nimport type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A `TerrainControl` control contains a button for turning the terrain on and off.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let map = new maplibregl.Map({TerrainControl: false})\n * .addControl(new maplibregl.TerrainControl({\n * source: \"terrain\"\n * }));\n * ```\n */\nexport class TerrainControl implements IControl {\n options: TerrainSpecification;\n _map: Map;\n _container: HTMLElement;\n _terrainButton: HTMLButtonElement;\n\n constructor(options: TerrainSpecification) {\n this.options = options;\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._terrainButton = DOM.create('button', 'maplibregl-ctrl-terrain', this._container);\n DOM.create('span', 'maplibregl-ctrl-icon', this._terrainButton).setAttribute('aria-hidden', 'true');\n this._terrainButton.type = 'button';\n this._terrainButton.addEventListener('click', this._toggleTerrain);\n\n this._updateTerrainIcon();\n this._map.on('terrain', this._updateTerrainIcon);\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('terrain', this._updateTerrainIcon);\n this._map = undefined;\n }\n\n _toggleTerrain = () => {\n if (this._map.getTerrain()) {\n this._map.setTerrain(null);\n } else {\n this._map.setTerrain(this.options);\n }\n this._updateTerrainIcon();\n };\n\n _updateTerrainIcon = () => {\n this._terrainButton.classList.remove('maplibregl-ctrl-terrain');\n this._terrainButton.classList.remove('maplibregl-ctrl-terrain-enabled');\n if (this._map.terrain) {\n this._terrainButton.classList.add('maplibregl-ctrl-terrain-enabled');\n this._terrainButton.title = this._map._getUIString('TerrainControl.disableTerrain');\n } else {\n this._terrainButton.classList.add('maplibregl-ctrl-terrain');\n this._terrainButton.title = this._map._getUIString('TerrainControl.enableTerrain');\n }\n };\n}\n","import {extend} from '../util/util';\nimport {Event, Evented} from '../util/evented';\nimport {MapMouseEvent} from '../ui/events';\nimport {DOM} from '../util/dom';\nimport {LngLat} from '../geo/lng_lat';\nimport Point from '@mapbox/point-geometry';\nimport {smartWrap} from '../util/smart_wrap';\nimport {anchorTranslate, applyAnchorClass} from './anchor';\n\nimport type {PositionAnchor} from './anchor';\nimport type {Map} from './map';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {PointLike} from './camera';\n\nconst defaultOptions = {\n closeButton: true,\n closeOnClick: true,\n focusAfterOpen: true,\n className: '',\n maxWidth: '240px'\n};\n\n/**\n * A pixel offset specified as:\n * - a single number specifying a distance from the location\n * - a {@link PointLike} specifying a constant offset\n * - an object of {@link Point}s specifying an offset for each anchor position\n * Negative offsets indicate left and up.\n */\nexport type Offset = number | PointLike | {\n [_ in PositionAnchor]: PointLike;\n};\n\nexport type PopupOptions = {\n /**\n * If `true`, a close button will appear in the top right corner of the popup.\n * @defaultValue true\n */\n closeButton?: boolean;\n /**\n * If `true`, the popup will closed when the map is clicked.\n * @defaultValue true\n */\n closeOnClick?: boolean;\n /**\n * If `true`, the popup will closed when the map moves.\n * @defaultValue false\n */\n closeOnMove?: boolean;\n /**\n * If `true`, the popup will try to focus the first focusable element inside the popup.\n * @defaultValue true\n */\n focusAfterOpen?: boolean;\n /**\n * A string indicating the part of the Popup that should\n * be positioned closest to the coordinate set via {@link Popup#setLngLat}.\n * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`,\n * `'top-right'`, `'bottom-left'`, and `'bottom-right'`. If unset the anchor will be\n * dynamically set to ensure the popup falls within the map container with a preference\n * for `'bottom'`.\n */\n anchor?: PositionAnchor;\n /**\n * A pixel offset applied to the popup's location\n */\n offset?: Offset;\n /**\n * Space-separated CSS class names to add to popup container\n */\n className?: string;\n /**\n * A string that sets the CSS property of the popup's maximum width, eg `'300px'`.\n * To ensure the popup resizes to fit its content, set this property to `'none'`.\n * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width\n * @defaultValue '240px'\n */\n maxWidth?: string;\n};\n\nconst focusQuerySelector = [\n 'a[href]',\n '[tabindex]:not([tabindex=\\'-1\\'])',\n '[contenteditable]:not([contenteditable=\\'false\\'])',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n].join(', ');\n\n/**\n * A popup component.\n *\n * @group Markers and Controls\n *\n *\n * @example\n * Create a popup\n * ```ts\n * let popup = new maplibregl.Popup();\n * // Set an event listener that will fire\n * // any time the popup is opened\n * popup.on('open', function(){\n * console.log('popup was opened');\n * });\n * ```\n *\n * @example\n * Create a popup\n * ```ts\n * let popup = new maplibregl.Popup();\n * // Set an event listener that will fire\n * // any time the popup is closed\n * popup.on('close', function(){\n * console.log('popup was closed');\n * });\n * ```\n *\n * @example\n * ```ts\n * let markerHeight = 50, markerRadius = 10, linearOffset = 25;\n * let popupOffsets = {\n * 'top': [0, 0],\n * 'top-left': [0,0],\n * 'top-right': [0,0],\n * 'bottom': [0, -markerHeight],\n * 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n * 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n * 'left': [markerRadius, (markerHeight - markerRadius) * -1],\n * 'right': [-markerRadius, (markerHeight - markerRadius) * -1]\n * };\n * let popup = new maplibregl.Popup({offset: popupOffsets, className: 'my-class'})\n * .setLngLat(e.lngLat)\n * .setHTML(\"

Hello World!

\")\n * .setMaxWidth(\"300px\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n *\n * ### Events\n *\n * @event `open` Fired when the popup is opened manually or programmatically. `popup` object that was opened\n *\n * @event `close` Fired when the popup is closed manually or programmatically. `popup` object that was closed\n */\nexport class Popup extends Evented {\n _map: Map;\n options: PopupOptions;\n _content: HTMLElement;\n _container: HTMLElement;\n _closeButton: HTMLButtonElement;\n _tip: HTMLElement;\n _lngLat: LngLat;\n _trackPointer: boolean;\n _pos: Point;\n\n constructor(options?: PopupOptions) {\n super();\n this.options = extend(Object.create(defaultOptions), options);\n }\n\n /**\n * Adds the popup to a map.\n *\n * @param map - The MapLibre GL JS map to add the popup to.\n * @returns `this`\n * @example\n * ```ts\n * new maplibregl.Popup()\n * .setLngLat([0, 0])\n * .setHTML(\"

Null Island

\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Show polygon information on click](https://maplibre.org/maplibre-gl-js/docs/examples/polygon-popup-on-click/)\n */\n addTo(map: Map): this {\n if (this._map) this.remove();\n\n this._map = map;\n if (this.options.closeOnClick) {\n this._map.on('click', this._onClose);\n }\n\n if (this.options.closeOnMove) {\n this._map.on('move', this._onClose);\n }\n\n this._map.on('remove', this.remove);\n this._update();\n this._focusFirstElement();\n\n if (this._trackPointer) {\n this._map.on('mousemove', this._onMouseMove);\n this._map.on('mouseup', this._onMouseUp);\n if (this._container) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.add('maplibregl-track-pointer');\n } else {\n this._map.on('move', this._update);\n }\n\n this.fire(new Event('open'));\n\n return this;\n }\n\n /**\n * @returns `true` if the popup is open, `false` if it is closed.\n */\n isOpen() {\n return !!this._map;\n }\n\n /**\n * Removes the popup from the map it has been added to.\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup().addTo(map);\n * popup.remove();\n * ```\n * @returns `this`\n */\n remove = (): this => {\n if (this._content) {\n DOM.remove(this._content);\n }\n\n if (this._container) {\n DOM.remove(this._container);\n delete this._container;\n }\n\n if (this._map) {\n this._map.off('move', this._update);\n this._map.off('move', this._onClose);\n this._map.off('click', this._onClose);\n this._map.off('remove', this.remove);\n this._map.off('mousemove', this._onMouseMove);\n this._map.off('mouseup', this._onMouseUp);\n this._map.off('drag', this._onDrag);\n delete this._map;\n }\n\n this.fire(new Event('close'));\n\n return this;\n };\n\n /**\n * Returns the geographical location of the popup's anchor.\n *\n * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously\n * set by `setLngLat` because `Popup` wraps the anchor longitude across copies of the world to keep\n * the popup on screen.\n *\n * @returns The geographical location of the popup's anchor.\n */\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n /**\n * Sets the geographical location of the popup's anchor, and moves the popup to it. Replaces trackPointer() behavior.\n *\n * @param lnglat - The geographical location to set as the popup's anchor.\n * @returns `this`\n */\n setLngLat(lnglat: LngLatLike): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n\n this._trackPointer = false;\n\n this._update();\n\n if (this._map) {\n this._map.on('move', this._update);\n this._map.off('mousemove', this._onMouseMove);\n if (this._container) {\n this._container.classList.remove('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.remove('maplibregl-track-pointer');\n }\n\n return this;\n }\n\n /**\n * Tracks the popup anchor to the cursor position on screens with a pointer device (it will be hidden on touchscreens). Replaces the `setLngLat` behavior.\n * For most use cases, set `closeOnClick` and `closeButton` to `false`.\n * @example\n * ```ts\n * let popup = new maplibregl.Popup({ closeOnClick: false, closeButton: false })\n * .setHTML(\"

Hello World!

\")\n * .trackPointer()\n * .addTo(map);\n * ```\n * @returns `this`\n */\n trackPointer(): this {\n this._trackPointer = true;\n this._pos = null;\n this._update();\n if (this._map) {\n this._map.off('move', this._update);\n this._map.on('mousemove', this._onMouseMove);\n this._map.on('drag', this._onDrag);\n if (this._container) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.add('maplibregl-track-pointer');\n }\n\n return this;\n\n }\n\n /**\n * Returns the `Popup`'s HTML element.\n * @example\n * Change the `Popup` element's font size\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat([-96, 37.8])\n * .setHTML(\"

Hello World!

\")\n * .addTo(map);\n * let popupElem = popup.getElement();\n * popupElem.style.fontSize = \"25px\";\n * ```\n * @returns element\n */\n getElement(): HTMLElement {\n return this._container;\n }\n\n /**\n * Sets the popup's content to a string of text.\n *\n * This function creates a [Text](https://developer.mozilla.org/en-US/docs/Web/API/Text) node in the DOM,\n * so it cannot insert raw HTML. Use this method for security against XSS\n * if the popup content is user-provided.\n *\n * @param text - Textual content for the popup.\n * @returns `this`\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setText('Hello, world!')\n * .addTo(map);\n * ```\n */\n setText(text: string): this {\n return this.setDOMContent(document.createTextNode(text));\n }\n\n /**\n * Sets the popup's content to the HTML provided as a string.\n *\n * This method does not perform HTML filtering or sanitization, and must be\n * used only with trusted content. Consider {@link Popup#setText} if\n * the content is an untrusted text string.\n *\n * @param html - A string representing HTML content for the popup.\n * @returns `this`\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setHTML(\"

Hello World!

\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n */\n setHTML(html: string): this {\n const frag = document.createDocumentFragment();\n const temp = document.createElement('body');\n let child;\n temp.innerHTML = html;\n while (true) {\n child = temp.firstChild;\n if (!child) break;\n frag.appendChild(child);\n }\n\n return this.setDOMContent(frag);\n }\n\n /**\n * Returns the popup's maximum width.\n *\n * @returns The maximum width of the popup.\n */\n getMaxWidth(): string {\n return this._container?.style.maxWidth;\n }\n\n /**\n * Sets the popup's maximum width. This is setting the CSS property `max-width`.\n * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width\n *\n * @param maxWidth - A string representing the value for the maximum width.\n * @returns `this`\n */\n setMaxWidth(maxWidth: string): this {\n this.options.maxWidth = maxWidth;\n this._update();\n return this;\n }\n\n /**\n * Sets the popup's content to the element provided as a DOM node.\n *\n * @param htmlNode - A DOM node to be used as content for the popup.\n * @returns `this`\n * @example\n * Create an element with the popup content\n * ```ts\n * let div = document.createElement('div');\n * div.innerHTML = 'Hello, world!';\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setDOMContent(div)\n * .addTo(map);\n * ```\n */\n setDOMContent(htmlNode: Node): this {\n if (this._content) {\n // Clear out children first.\n while (this._content.hasChildNodes()) {\n if (this._content.firstChild) {\n this._content.removeChild(this._content.firstChild);\n }\n }\n } else {\n this._content = DOM.create('div', 'maplibregl-popup-content', this._container);\n }\n\n // The close button should be the last tabbable element inside the popup for a good keyboard UX.\n this._content.appendChild(htmlNode);\n this._createCloseButton();\n this._update();\n this._focusFirstElement();\n return this;\n }\n\n /**\n * Adds a CSS class to the popup container element.\n *\n * @param className - Non-empty string with CSS class name to add to popup container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.addClassName('some-class')\n * ```\n */\n addClassName(className: string) {\n if (this._container) {\n this._container.classList.add(className);\n }\n }\n\n /**\n * Removes a CSS class from the popup container element.\n *\n * @param className - Non-empty string with CSS class name to remove from popup container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.removeClassName('some-class')\n * ```\n */\n removeClassName(className: string) {\n if (this._container) {\n this._container.classList.remove(className);\n }\n }\n\n /**\n * Sets the popup's offset.\n *\n * @param offset - Sets the popup's offset.\n * @returns `this`\n */\n setOffset (offset?: Offset): this {\n this.options.offset = offset;\n this._update();\n return this;\n }\n\n /**\n * Add or remove the given CSS class on the popup container, depending on whether the container currently has that class.\n *\n * @param className - Non-empty string with CSS class name to add/remove\n *\n * @returns if the class was removed return false, if class was added, then return true, undefined if there is no container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.toggleClassName('toggleClass')\n * ```\n */\n toggleClassName(className: string): boolean | undefined {\n if (this._container) {\n return this._container.classList.toggle(className);\n }\n }\n\n _createCloseButton() {\n if (this.options.closeButton) {\n this._closeButton = DOM.create('button', 'maplibregl-popup-close-button', this._content);\n this._closeButton.type = 'button';\n this._closeButton.setAttribute('aria-label', 'Close popup');\n this._closeButton.innerHTML = '×';\n this._closeButton.addEventListener('click', this._onClose);\n }\n }\n\n _onMouseUp = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _onMouseMove = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _onDrag = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _update = (cursor?: Point) => {\n const hasPosition = this._lngLat || this._trackPointer;\n\n if (!this._map || !hasPosition || !this._content) { return; }\n\n if (!this._container) {\n this._container = DOM.create('div', 'maplibregl-popup', this._map.getContainer());\n this._tip = DOM.create('div', 'maplibregl-popup-tip', this._container);\n this._container.appendChild(this._content);\n if (this.options.className) {\n for (const name of this.options.className.split(' ')) {\n this._container.classList.add(name);\n }\n }\n\n if (this._trackPointer) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n }\n\n if (this.options.maxWidth && this._container.style.maxWidth !== this.options.maxWidth) {\n this._container.style.maxWidth = this.options.maxWidth;\n }\n\n if (this._map.transform.renderWorldCopies && !this._trackPointer) {\n this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);\n }\n\n if (this._trackPointer && !cursor) return;\n\n const pos = this._pos = this._trackPointer && cursor ? cursor : this._map.project(this._lngLat);\n\n let anchor = this.options.anchor;\n const offset = normalizeOffset(this.options.offset);\n\n if (!anchor) {\n const width = this._container.offsetWidth;\n const height = this._container.offsetHeight;\n let anchorComponents;\n\n if (pos.y + offset.bottom.y < height) {\n anchorComponents = ['top'];\n } else if (pos.y > this._map.transform.height - height) {\n anchorComponents = ['bottom'];\n } else {\n anchorComponents = [];\n }\n\n if (pos.x < width / 2) {\n anchorComponents.push('left');\n } else if (pos.x > this._map.transform.width - width / 2) {\n anchorComponents.push('right');\n }\n\n if (anchorComponents.length === 0) {\n anchor = 'bottom';\n } else {\n anchor = (anchorComponents.join('-') as any);\n }\n }\n\n const offsetedPos = pos.add(offset[anchor]).round();\n DOM.setTransform(this._container, `${anchorTranslate[anchor]} translate(${offsetedPos.x}px,${offsetedPos.y}px)`);\n applyAnchorClass(this._container, anchor, 'popup');\n };\n\n _focusFirstElement() {\n if (!this.options.focusAfterOpen || !this._container) return;\n\n const firstFocusable = this._container.querySelector(focusQuerySelector) as HTMLElement;\n\n if (firstFocusable) firstFocusable.focus();\n }\n\n _onClose = () => {\n this.remove();\n };\n}\n\nfunction normalizeOffset(offset?: Offset | null) {\n if (!offset) {\n return normalizeOffset(new Point(0, 0));\n\n } else if (typeof offset === 'number') {\n // input specifies a radius from which to calculate offsets at all positions\n const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);\n return {\n 'center': new Point(0, 0),\n 'top': new Point(0, offset),\n 'top-left': new Point(cornerOffset, cornerOffset),\n 'top-right': new Point(-cornerOffset, cornerOffset),\n 'bottom': new Point(0, -offset),\n 'bottom-left': new Point(cornerOffset, -cornerOffset),\n 'bottom-right': new Point(-cornerOffset, -cornerOffset),\n 'left': new Point(offset, 0),\n 'right': new Point(-offset, 0)\n };\n\n } else if (offset instanceof Point || Array.isArray(offset)) {\n // input specifies a single offset to be applied to all positions\n const convertedOffset = Point.convert(offset);\n return {\n 'center': convertedOffset,\n 'top': convertedOffset,\n 'top-left': convertedOffset,\n 'top-right': convertedOffset,\n 'bottom': convertedOffset,\n 'bottom-left': convertedOffset,\n 'bottom-right': convertedOffset,\n 'left': convertedOffset,\n 'right': convertedOffset\n };\n\n } else {\n // input specifies an offset per position\n return {\n 'center': Point.convert(offset['center'] || [0, 0]),\n 'top': Point.convert(offset['top'] || [0, 0]),\n 'top-left': Point.convert(offset['top-left'] || [0, 0]),\n 'top-right': Point.convert(offset['top-right'] || [0, 0]),\n 'bottom': Point.convert(offset['bottom'] || [0, 0]),\n 'bottom-left': Point.convert(offset['bottom-left'] || [0, 0]),\n 'bottom-right': Point.convert(offset['bottom-right'] || [0, 0]),\n 'left': Point.convert(offset['left'] || [0, 0]),\n 'right': Point.convert(offset['right'] || [0, 0])\n };\n }\n}\n","import {extend} from './util';\n\n/**\n * This is a private namespace for utility functions that will get automatically stripped\n * out in production builds.\n */\nexport const Debug = {\n extend(dest: any, ...sources: Array): any {\n return extend(dest, ...sources);\n },\n\n run(fn: () => any) {\n fn();\n },\n\n logToElement(message: string, overwrite: boolean = false, id: string = 'log') {\n const el = window.document.getElementById(id);\n if (el) {\n if (overwrite) el.innerHTML = '';\n el.innerHTML += `
${message}`;\n }\n\n }\n};\n","import packageJSON from '../package.json' assert {type: 'json'};\nimport {Map} from './ui/map';\nimport {NavigationControl} from './ui/control/navigation_control';\nimport {GeolocateControl} from './ui/control/geolocate_control';\nimport {AttributionControl} from './ui/control/attribution_control';\nimport {LogoControl} from './ui/control/logo_control';\nimport {ScaleControl} from './ui/control/scale_control';\nimport {FullscreenControl} from './ui/control/fullscreen_control';\nimport {TerrainControl} from './ui/control/terrain_control';\nimport {Popup} from './ui/popup';\nimport {Marker} from './ui/marker';\nimport {Style} from './style/style';\nimport {LngLat} from './geo/lng_lat';\nimport {LngLatBounds} from './geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from './geo/mercator_coordinate';\nimport {Evented} from './util/evented';\nimport {config} from './util/config';\nimport {Debug} from './util/debug';\nimport {isSafari} from './util/util';\nimport {setRTLTextPlugin, getRTLTextPluginStatus} from './source/rtl_text_plugin';\nimport {WorkerPool} from './util/worker_pool';\nimport {prewarm, clearPrewarmedResources} from './util/global_worker_pool';\nimport {PerformanceUtils} from './util/performance';\nimport {AJAXError} from './util/ajax';\nimport type {RequestParameters, ResponseCallback} from './util/ajax';\nimport type {Cancelable} from './types/cancelable';\nimport {GeoJSONSource} from './source/geojson_source';\nimport {CanvasSource} from './source/canvas_source';\nimport {ImageSource} from './source/image_source';\nimport {RasterDEMTileSource} from './source/raster_dem_tile_source';\nimport {RasterTileSource} from './source/raster_tile_source';\nimport {VectorTileSource} from './source/vector_tile_source';\nimport {VideoSource} from './source/video_source';\n\nconst version = packageJSON.version;\n\nexport type * from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * `maplibregl` is the global object that allows configurations that are not specific to a map instance\n *\n * @group Main\n */\nclass MapLibreGL {\n static Map = Map;\n static NavigationControl = NavigationControl;\n static GeolocateControl = GeolocateControl;\n static AttributionControl = AttributionControl;\n static LogoControl = LogoControl;\n static ScaleControl = ScaleControl;\n static FullscreenControl = FullscreenControl;\n static TerrainControl = TerrainControl;\n static Popup = Popup;\n static Marker = Marker;\n static Style = Style;\n static LngLat = LngLat;\n static LngLatBounds = LngLatBounds;\n static Point = Point;\n static MercatorCoordinate = MercatorCoordinate;\n static Evented = Evented;\n static AJAXError = AJAXError;\n static config = config;\n static CanvasSource = CanvasSource;\n static GeoJSONSource = GeoJSONSource;\n static ImageSource = ImageSource;\n static RasterDEMTileSource = RasterDEMTileSource;\n static RasterTileSource = RasterTileSource;\n static VectorTileSource = VectorTileSource;\n static VideoSource = VideoSource;\n /**\n * Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text).\n * Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left.\n *\n * @param pluginURL - URL pointing to the Mapbox RTL text plugin source.\n * @param callback - Called with an error argument if there is an error.\n * @param lazy - If set to `true`, mapboxgl will defer loading the plugin until rtl text is encountered,\n * rtl text will then be rendered only after the plugin finishes loading.\n * @example\n * ```ts\n * maplibregl.setRTLTextPlugin('https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.js');\n * ```\n * @see [Add support for right-to-left scripts](https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/)\n */\n static setRTLTextPlugin = setRTLTextPlugin;\n /**\n * Gets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) status.\n * The status can be `unavailable` (i.e. not requested or removed), `loading`, `loaded` or `error`.\n * If the status is `loaded` and the plugin is requested again, an error will be thrown.\n *\n * @example\n * ```ts\n * const pluginStatus = maplibregl.getRTLTextPluginStatus();\n * ```\n */\n static getRTLTextPluginStatus = getRTLTextPluginStatus;\n /**\n * Initializes resources like WebWorkers that can be shared across maps to lower load\n * times in some situations. `maplibregl.workerUrl` and `maplibregl.workerCount`, if being\n * used, must be set before `prewarm()` is called to have an effect.\n *\n * By default, the lifecycle of these resources is managed automatically, and they are\n * lazily initialized when a Map is first created. By invoking `prewarm()`, these\n * resources will be created ahead of time, and will not be cleared when the last Map\n * is removed from the page. This allows them to be re-used by new Map instances that\n * are created later. They can be manually cleared by calling\n * `maplibregl.clearPrewarmedResources()`. This is only necessary if your web page remains\n * active but stops using maps altogether.\n *\n * This is primarily useful when using GL-JS maps in a single page app, wherein a user\n * would navigate between various views that can cause Map instances to constantly be\n * created and destroyed.\n *\n * @example\n * ```ts\n * maplibregl.prewarm()\n * ```\n */\n static prewarm = prewarm;\n /**\n * Clears up resources that have previously been created by `maplibregl.prewarm()`.\n * Note that this is typically not necessary. You should only call this function\n * if you expect the user of your app to not return to a Map view at any point\n * in your application.\n *\n * @example\n * ```ts\n * maplibregl.clearPrewarmedResources()\n * ```\n */\n static clearPrewarmedResources = clearPrewarmedResources;\n /**\n * Returns the package version of the library\n * @returns Package version of the library\n */\n static get version(): string {\n return version;\n }\n\n /**\n * Gets and sets the number of web workers instantiated on a page with GL JS maps.\n * By default, workerCount is 1 except for Safari browser where it is set to half the number of CPU cores (capped at 3).\n * Make sure to set this property before creating any map instances for it to have effect.\n *\n * @returns Number of workers currently configured.\n * @example\n * ```ts\n * maplibregl.workerCount = 2;\n * ```\n */\n static get workerCount(): number {\n return WorkerPool.workerCount;\n }\n\n static set workerCount(count: number) {\n WorkerPool.workerCount = count;\n }\n /**\n * Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel,\n * which affects performance in raster-heavy maps. 16 by default.\n *\n * @returns Number of parallel requests currently configured.\n * @example\n * ```ts\n * maplibregl.maxParallelImageRequests = 10;\n * ```\n */\n static get maxParallelImageRequests(): number {\n return config.MAX_PARALLEL_IMAGE_REQUESTS;\n }\n\n static set maxParallelImageRequests(numRequests: number) {\n config.MAX_PARALLEL_IMAGE_REQUESTS = numRequests;\n }\n\n static get workerUrl(): string {\n return config.WORKER_URL;\n }\n\n static set workerUrl(value: string) {\n config.WORKER_URL = value;\n }\n\n /**\n * Sets a custom load tile function that will be called when using a source that starts with a custom url schema.\n * The example below will be triggered for custom:// urls defined in the sources list in the style definitions.\n * The function passed will receive the request parameters and should call the callback with the resulting request,\n * for example a pbf vector tile, non-compressed, represented as ArrayBuffer.\n *\n * @param customProtocol - the protocol to hook, for example 'custom'\n * @param loadFn - the function to use when trying to fetch a tile specified by the customProtocol\n * @example\n * This will fetch a file using the fetch API (this is obviously a non interesting example...)\n * ```ts\n * maplibregl.addProtocol('custom', (params, callback) => {\n fetch(`https://${params.url.split(\"://\")[1]}`)\n .then(t => {\n if (t.status == 200) {\n t.arrayBuffer().then(arr => {\n callback(null, arr, null, null);\n });\n } else {\n callback(new Error(`Tile fetch error: ${t.statusText}`));\n }\n })\n .catch(e => {\n callback(new Error(e));\n });\n return { cancel: () => { } };\n });\n * // the following is an example of a way to return an error when trying to load a tile\n * maplibregl.addProtocol('custom2', (params, callback) => {\n * callback(new Error('someErrorMessage'));\n * return { cancel: () => { } };\n * });\n * ```\n */\n static addProtocol(customProtocol: string, loadFn: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable) {\n config.REGISTERED_PROTOCOLS[customProtocol] = loadFn;\n }\n\n /**\n * Removes a previously added protocol\n *\n * @param customProtocol - the custom protocol to remove registration for\n * @example\n * ```ts\n * maplibregl.removeProtocol('custom');\n * ```\n */\n static removeProtocol(customProtocol: string) {\n delete config.REGISTERED_PROTOCOLS[customProtocol];\n }\n}\n\n//This gets automatically stripped out in production builds.\nDebug.extend(MapLibreGL, {isSafari, getPerformanceMetrics: PerformanceUtils.getPerformanceMetrics});\n\nexport default MapLibreGL;\n","//\n// Our custom intro provides a specialized \"define()\" function, called by the\n// AMD modules below, that sets up the worker blob URL and then executes the\n// main module, storing its exported value as 'maplibregl'\n\n// The three \"chunks\" imported here are produced by a first Rollup pass,\n// which outputs them as AMD modules.\n\n// Shared dependencies, i.e.:\n/*\ndefine(['exports'], function (exports) {\n // Code for all common dependencies\n // Each module's exports are attached attached to 'exports' (with\n // names rewritten to avoid collisions, etc.)\n})\n*/\nimport '../../staging/maplibregl/shared';\n\n// Worker and its unique dependencies, i.e.:\n/*\ndefine(['./shared.js'], function (__shared__js) {\n // Code for worker script and its unique dependencies.\n // Expects the output of 'shared' module to be passed in as an argument,\n // since all references to common deps look like, e.g.,\n // __shared__js.shapeText().\n});\n*/\n// When this wrapper function is passed to our custom define() above,\n// it gets stringified, together with the shared wrapper (using\n// Function.toString()), and the resulting string of code is made into a\n// Blob URL that gets used by the main module to create the web workers.\nimport '../../staging/maplibregl/worker';\n\n// Main module and its unique dependencies\n/*\ndefine(['./shared.js'], function (__shared__js) {\n // Code for main GL JS module and its unique dependencies.\n // Expects the output of 'shared' module to be passed in as an argument,\n // since all references to common deps look like, e.g.,\n // __shared__js.shapeText().\n //\n // Returns the actual maplibregl (i.e. src/index.js)\n});\n*/\nimport '../../staging/maplibregl/index';\n\nexport default maplibregl;\n"],"names":["Point","bezier","UnitBezier","clamp","deepEqual","clone","layout","paint","EXTENT","mercatorXfromLng","mercatorYfromLat","validateFilter","validatePaintProperty","validateLayoutProperty","validateSource","validateLight","validateTerrain","isChar","rtlTextPlugin","interpolates","styleSpec","align","members","size","alignment","require$$0","require$$1","murmurhashJsModule","sort","murmur3","swap","layoutAttributes","translate","getLayout","getPaint","equals","create","glMatrix.ARRAY_TYPE","copy","identity","fromValues","set","transpose","invert","adjoint","determinant","multiply","rotate","scale","fromRotation","fromScaling","str","frob","add","subtract","exactEquals","glMatrix.EPSILON","multiplyScalar","multiplyScalarAndAdd","mul","sub","fromTranslation","fromMat4","fromQuat","rotateX","rotateY","rotateZ","fromRotationTranslation","getTranslation","length","divide","ceil","floor","min","max","round","scaleAndAdd","distance","squaredDistance","squaredLength","negate","inverse","normalize","dot","cross","lerp","random","glMatrix.RANDOM","transformMat4","transformMat3","transformQuat","angle","zero","div","dist","sqrDist","len","sqrLen","forEach","conjugate","vec4.clone","vec4.fromValues","vec4.copy","vec4.set","vec4.add","vec4.scale","vec4.dot","vec4.lerp","vec4.length","vec4.squaredLength","vec4.normalize","vec4.exactEquals","vec4.equals","vec3.create","vec3.fromValues","vec3.dot","vec3.cross","vec3.len","vec3.normalize","mat3.create","quat.create","mat4.getRotation","mat4.getTranslation","quat.copy","quat.rotateX","quat.rotateY","quat.rotateZ","quat.dot","quat.length","quat.squaredLength","properties","projectQueryGeometry","vec4.transformMat4","earcutModule","signedArea","defaultCompare","classifyRings","EARCUT_MAX_RINGS","earcut","VectorTileFeature","VectorTileLayer","VectorTile","require$$2","vectorTileFeatureTypes","mvt","addVertex","layoutAttributesExt","ieee754","border","WritingMode","mat4.identity","globalRTLTextPlugin","vt","featureFilter","Queue","TextAnchorEnum","PerformanceMarkers","createStyleLayer","groupByLayout","potpack","AlphaImage","register","OverscaledTileID","CollisionBoxArray","DictionaryCoder","FeatureIndex","warnOnce","mapObject","ImageAtlas","SymbolBucket","performSymbolLayout","LineBucket","FillBucket","FillExtrusionBucket","EvaluationParameters","getArrayBuffer","Protobuf","RequestPerformance","extend","isImageBitmap","RGBAImage","getImageData","DEMData","rewind","FeatureWrapper","GeoJSONWrapper","vtPbfModule","KDBush","transform","getJSON","createExpression","Actor","isWorker","arrayBufferToImageBitmap","arrayBufferToImage","getProtocolAction","makeRequest","config","sameOrigin","browser","Evented","ErrorEvent","Event","ImagePosition","parseGlyphPbf","asyncAll","unicodeBlockLookup","sphericalToCartesian","Properties","DataConstantProperty","Transitionable","emitValidationErrors","validateStyle","pick","LngLat","__awaiter","offscreenCanvasSupported","isOffscreenCanvasDistorted","readImageUsingVideoFrame","createLayout","SegmentVector","MercatorCoordinate","RasterBoundsArray","CanonicalTileID","getVideo","ValidationError","mat4.create","mat4.translate","mat4.scale","mat4.multiply","uniqueId","deserializeBucket","lazyLoadRTLTextPlugin","toEvaluationFeature","GeoJSONFeature","parseCacheControl","createSource","keysDifference","isSafari","mat4.rotateZ","mat4.clone","symbolSize.evaluateSizeForZoom","symbolSize.evaluateSizeForFeature","addDynamicAttributes","findLineIntersection","projection.project","projection.getPerspectiveRatio","ONE_EM","projection.placeFirstAndLastGlyph","clipLine","intersectionTests.polygonIntersectsPolygon","projection.xyTransformMat4","getAnchorAlignment","projection.getLabelPlaneMatrix","projection.getGlCoordMatrix","getOverlapMode","mat4.invert","getAnchorJustification","_emitValidationErrors","diffOperations","emptyStyle","ZoomHistory","getReferrer","triggerPluginCompletionEvent","deref","diffStyles","validateCustomStyleLayer","filterObject","rtlTextPluginEvented","registerForPluginStateChange","Uniform1i","Uniform1f","UniformMatrix4f","Uniform4f","Uniform3f","Uniform2f","mat3.fromRotation","vec3.transformMat3","UniformColor","mat4.ortho","Color","ALWAYS","mat4.mul","CollisionCircleLayoutArray","collisionCircleLayout","QuadTriangleArray","evaluateSizeForZoom","symbolProjection.getLabelPlaneMatrix","symbolProjection.hideGlyphs","symbolProjection.project","symbolProjection.getPerspectiveRatio","evaluateSizeForFeature","symbolProjection.getGlCoordMatrix","symbolProjection.updateLineLabels","nextPowerOfTwo","renderColorRamp","PosArray","LineStripIndexArray","TriangleIndexArray","mat4.equals","mat4.copy","vec4.mul","vec3.sub","vec3.scale","vec3.add","vec3.clone","wrap","mat2.create","mat2.rotate","UnwrappedTileID","vec2.sqrLen","mercatorZfromAltitude","mat4.perspective","mat4.rotateX","LEFT_BUTTON","RIGHT_BUTTON","assignEvents","defaultOptions","defaultEasing","vec2.transformMat4","mat4.fromScaling","Pos3dArray","earthRadius","lngFromMercatorX","version","PerformanceUtils","Map","AJAXError","setRTLTextPlugin","getRTLTextPluginStatus"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1G,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AACF;AACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;AAChC,IAAI,IAAI,OAAO,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,IAAI;AAC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A,GAAG,gBAAgB,CAAC;AACpC,UAAW,CAAA,WAAA,GAAG,WAAW,CAAC;AACjC;;;;;;;;;;;;;AAaG;AACI,UAAgB,CAAA,gBAAA,GAAGmI,WAAAA,CAAAA,gBAAgB,CAAC;AAC3C;;;;;;;;;AASG;AACI,UAAsB,CAAA,sBAAA,GAAGC,WAAAA,CAAAA,sBAAsB,CAAC;AACvD;;;;;;;;;;;;;;;;;;;;;AAqBG;AACI,UAAO,CAAA,OAAA,GAAG,OAAO,CAAC;AACzB;;;;;;;;;;AAUG;AACI,UAAuB,CAAA,uBAAA,GAAG,uBAAuB,CAAC;AAyG7D;AACA,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,EAAC3F,QAAAA,EAAAA,WAAAA,CAAAA,QAAQ,EAAE,qBAAqB,EAAEuF,WAAAA,CAAAA,gBAAgB,CAAC,qBAAqB,EAAC,CAAC,CAAA;;;;;;AC5OnG;AACA;AACA;AACA;AACA;AAyCA;AACA,mBAAe,UAAU;;;;;;;;","x_google_ignoreList":[0,1,2,10,27,28,29,40,41,42,43,44,45,46,47,48,49,59,60,67,68,69,70,84,85,87,107,119,123,130,132,133,134,135,136,137,138,139,140,141,142,156]} \ No newline at end of file diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl.css b/web/libraries/maplibre-gl/dist/maplibre-gl.css new file mode 100644 index 00000000..317ea49a --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{-webkit-tap-highlight-color:rgb(0 0 0/0);font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (-ms-high-contrast:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (-ms-high-contrast:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8h-8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8h-8z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8h-8z'/%3E%3Cpath fill='%23999' d='m10.5 16 4 8 4-8h-8z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8h-8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8h-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1 9-9z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (-ms-high-contrast:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1 9-9z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1 9-9z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.255 1.255 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.255 1.255 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5.11 5.11 0 0 1 .314-.787l.009-.016a4.623 4.623 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.548 4.548 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4.314.319.566.676.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.416 2.416 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.448 2.448 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675c.211.2.381.43.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.76 4.76 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.407 3.407 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.255 1.255 0 0 1 .689 1.004 4.73 4.73 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528 0 .343-.02.694-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.815 5.815 0 0 1-.548-2.512c0-.286.017-.567.053-.843a1.255 1.255 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.778 4.778 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.47 4.47 0 0 1-1.935-.424 1.252 1.252 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.402 2.402 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.703 4.703 0 0 1-1.782 1.884 4.767 4.767 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.47 4.47 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a4.983 4.983 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.255 1.255 0 0 1-1.115.676h-.098a1.255 1.255 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15c.329-.237.574-.499.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267c-.088-.22-.264-.438-.526-.658l-.032-.028a3.16 3.16 0 0 0-.668-.428l-.27-.12a3.293 3.293 0 0 0-1.235-.23c-.757 0-1.415.163-1.974.493a3.36 3.36 0 0 0-1.3 1.382c-.297.593-.444 1.284-.444 2.074 0 .8.17 1.503.51 2.107a3.795 3.795 0 0 0 1.382 1.381 3.883 3.883 0 0 0 1.893.477c.53 0 1.015-.11 1.455-.33zm-2.789-5.38c-.384.45-.575 1.038-.575 1.762 0 .735.186 1.332.559 1.794.384.45.933.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.17 2.17 0 0 0 .468-.29l.178-.161a2.163 2.163 0 0 0 .397-.561c.163-.333.244-.717.244-1.15v-.115c0-.472-.098-.894-.296-1.267l-.043-.077a2.211 2.211 0 0 0-.633-.709l-.13-.086-.047-.028a2.099 2.099 0 0 0-1.073-.285c-.702 0-1.244.231-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.958.958 0 0 0-.353-.389.851.851 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.626 2.626 0 0 0 .331.423c.213.22.464.402.755.548l.173.074c.433.17.93.255 1.49.255.68 0 1.295-.165 1.844-.493a3.447 3.447 0 0 0 1.316-1.4c.329-.603.493-1.299.493-2.089 0-1.273-.33-2.243-.988-2.913-.658-.68-1.52-1.02-2.584-1.02-.598 0-1.124.115-1.575.347a2.807 2.807 0 0 0-.415.262l-.199.166a3.35 3.35 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138c.137.193.297.36.48.5l.155.11.053.034c.34.197.713.297 1.119.297.714 0 1.262-.225 1.645-.675.385-.46.576-1.048.576-1.762 0-.746-.192-1.338-.576-1.777-.372-.45-.92-.675-1.645-.675-.29 0-.569.053-.835.16a2.366 2.366 0 0 0-.284.136 1.99 1.99 0 0 0-.363.254 2.237 2.237 0 0 0-.46.569l-.082.162a2.56 2.56 0 0 0-.213 1.072v.115c0 .471.098.894.296 1.267l.135.211zm.964-.818a1.11 1.11 0 0 0 .367.385.937.937 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a.995.995 0 0 0-.503.135l-.012.007a.859.859 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.43 1.43 0 0 0 .14.66zm15.7-6.222c.232-.23.346-.516.346-.856a1.053 1.053 0 0 0-.345-.79 1.175 1.175 0 0 0-.84-.329c-.34 0-.625.11-.855.33a1.053 1.053 0 0 0-.346.79c0 .34.115.625.346.855.23.23.516.346.856.346.34 0 .62-.115.839-.346zm4.337 9.314.033-1.332c.128.269.324.518.59.747l.098.081a3.727 3.727 0 0 0 .316.224l.223.122a3.21 3.21 0 0 0 1.44.322 3.785 3.785 0 0 0 1.875-.477 3.52 3.52 0 0 0 1.382-1.366c.352-.593.526-1.29.526-2.09 0-.79-.147-1.48-.444-2.073a3.235 3.235 0 0 0-1.283-1.399c-.549-.34-1.195-.51-1.942-.51a3.476 3.476 0 0 0-1.527.344l-.086.043-.165.09a3.412 3.412 0 0 0-.33.214c-.288.21-.507.446-.656.707a1.893 1.893 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.482 2.482 0 0 0 .566.7c.078.065.159.125.245.18l.144.08a2.105 2.105 0 0 0 .975.232c.713 0 1.262-.225 1.645-.675.384-.46.576-1.053.576-1.778 0-.734-.192-1.327-.576-1.777-.373-.46-.921-.692-1.645-.692a2.18 2.18 0 0 0-1.015.235c-.147.075-.285.17-.415.282l-.15.142a2.086 2.086 0 0 0-.42.594c-.149.32-.223.685-.223 1.1v.115c0 .47.097.89.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.868.868 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.13 1.13 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013c.23-.087.472-.134.724-.14l.069-.002c.329 0 .542.033.642.099l.247-1.794c-.13-.066-.37-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2.086 2.086 0 0 0-.411.148 2.18 2.18 0 0 0-.4.249 2.482 2.482 0 0 0-.485.499 2.659 2.659 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884c0-.364.053-.678.159-.943a1.49 1.49 0 0 1 .466-.636 2.52 2.52 0 0 1 .399-.253 2.19 2.19 0 0 1 .224-.099zm9.784 2.656.05-.922c0-1.162-.285-2.062-.856-2.698-.559-.647-1.42-.97-2.584-.97-.746 0-1.415.163-2.007.493a3.462 3.462 0 0 0-1.4 1.382c-.329.604-.493 1.306-.493 2.106 0 .714.143 1.371.428 1.975.285.593.73 1.07 1.332 1.432.604.351 1.355.526 2.255.526.649 0 1.204-.062 1.668-.185l.044-.012.135-.04c.409-.122.736-.263.984-.421l-.542-1.267c-.2.108-.415.199-.642.274l-.297.087c-.34.088-.773.131-1.3.131-.636 0-1.135-.147-1.497-.444a1.573 1.573 0 0 1-.192-.193c-.244-.294-.415-.705-.512-1.234l-.004-.021h5.43zm-5.427-1.256-.003.022h3.752v-.138c-.007-.485-.104-.857-.288-1.118a1.056 1.056 0 0 0-.156-.176c-.307-.285-.746-.428-1.316-.428-.657 0-1.155.202-1.494.604-.253.3-.417.712-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81c-.68 0-1.311-.16-1.893-.478a3.795 3.795 0 0 1-1.381-1.382c-.34-.604-.51-1.306-.51-2.106 0-.79.147-1.482.444-2.074a3.364 3.364 0 0 1 1.3-1.382c.559-.33 1.217-.494 1.974-.494a3.293 3.293 0 0 1 1.234.231 3.341 3.341 0 0 1 .97.575c.264.22.44.439.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332c-.186.395-.526.746-1.02 1.053a3.167 3.167 0 0 1-1.662.444zm.296-1.482c.626 0 1.152-.214 1.58-.642.428-.44.642-1.01.642-1.711v-.115c0-.472-.098-.894-.296-1.267a2.211 2.211 0 0 0-.807-.872 2.098 2.098 0 0 0-1.119-.313c-.702 0-1.245.231-1.629.692-.384.45-.575 1.037-.575 1.76 0 .736.186 1.333.559 1.795.384.45.933.675 1.645.675zm6.521-6.237h1.711v1.4c.604-1.065 1.547-1.597 2.83-1.597 1.064 0 1.926.34 2.584 1.02.659.67.988 1.641.988 2.914 0 .79-.164 1.487-.493 2.09a3.456 3.456 0 0 1-1.316 1.399 3.51 3.51 0 0 1-1.844.493c-.636 0-1.19-.11-1.662-.329a2.665 2.665 0 0 1-1.086-.97l.017 5.134h-1.728V9.242zm4.048 6.22c.714 0 1.262-.224 1.645-.674.385-.46.576-1.048.576-1.762 0-.746-.192-1.338-.576-1.777-.372-.45-.92-.675-1.645-.675-.395 0-.768.098-1.12.296-.34.187-.613.46-.822.823-.197.351-.296.763-.296 1.234v.115c0 .472.098.894.296 1.267.209.362.483.647.823.855.34.197.713.297 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.159 1.159 0 0 1-.856-.346 1.165 1.165 0 0 1-.346-.856 1.053 1.053 0 0 1 .346-.79c.23-.219.516-.329.856-.329.329 0 .609.11.839.33a1.053 1.053 0 0 1 .345.79 1.159 1.159 0 0 1-.345.855c-.22.23-.5.346-.84.346zm7.875 9.133a3.167 3.167 0 0 1-1.662-.444c-.482-.307-.817-.658-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283c.186-.438.548-.812 1.086-1.119a3.486 3.486 0 0 1 1.778-.477c.746 0 1.393.17 1.942.51a3.235 3.235 0 0 1 1.283 1.4c.297.592.444 1.282.444 2.072 0 .8-.175 1.498-.526 2.09a3.52 3.52 0 0 1-1.382 1.366 3.785 3.785 0 0 1-1.876.477zm-.296-1.481c.713 0 1.26-.225 1.645-.675.384-.46.577-1.053.577-1.778 0-.734-.193-1.327-.577-1.776-.373-.46-.921-.692-1.645-.692a2.115 2.115 0 0 0-1.58.659c-.428.428-.642.992-.642 1.694v.115c0 .473.098.895.296 1.267a2.385 2.385 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481c.176-.505.46-.91.856-1.217a2.14 2.14 0 0 1 1.349-.46c.351 0 .593.032.724.098l-.247 1.794c-.099-.066-.313-.099-.642-.099-.516 0-.988.164-1.416.494-.417.329-.626.855-.626 1.58v3.883h-1.777V9.242zm9.534 7.718c-.9 0-1.651-.175-2.255-.526-.603-.362-1.047-.84-1.332-1.432a4.567 4.567 0 0 1-.428-1.975c0-.8.164-1.502.493-2.106a3.462 3.462 0 0 1 1.4-1.382c.592-.33 1.262-.494 2.007-.494 1.163 0 2.024.324 2.584.97.57.637.856 1.537.856 2.7 0 .296-.017.603-.05.92h-5.43c.12.67.356 1.153.708 1.45.362.296.86.443 1.497.443.526 0 .96-.044 1.3-.131a4.123 4.123 0 0 0 .938-.362l.542 1.267c-.274.175-.647.329-1.119.46-.472.132-1.042.197-1.711.197zm1.596-4.558c.01-.68-.137-1.158-.444-1.432-.307-.285-.746-.428-1.316-.428-1.152 0-1.815.62-1.991 1.86h3.752z'/%3E%3Cg fill-rule='evenodd' stroke-width='1.036'%3E%3Cpath fill='%23000' fill-opacity='.4' d='m8.166 16.146-.002.002a1.54 1.54 0 0 1-2.009 0l-.002-.002-.043-.034-.002-.002-.199-.162H4.377a.657.657 0 0 0-.659.659v1.84a.657.657 0 0 0 .659.659h5.565a.657.657 0 0 0 .659-.659v-1.84a.657.657 0 0 0-.659-.659H8.411l-.202.164zm-1.121-.905a.29.29 0 0 0 .113.023.286.286 0 0 0 .189-.07l.077-.063c.634-.508 4.672-3.743 4.672-7.575 0-2.55-2.215-4.625-4.938-4.625S2.221 5.006 2.221 7.556c0 3.225 2.86 6.027 4.144 7.137h.004l.04.038.484.4.077.063a.628.628 0 0 0 .074.047zm-2.52-.548a16.898 16.898 0 0 1-1.183-1.315C2.187 11.942.967 9.897.967 7.555c0-3.319 2.855-5.88 6.192-5.88 3.338 0 6.193 2.561 6.193 5.881 0 2.34-1.22 4.387-2.376 5.822a16.898 16.898 0 0 1-1.182 1.315h.15a1.912 1.912 0 0 1 1.914 1.914v1.84a1.912 1.912 0 0 1-1.914 1.914H4.377a1.912 1.912 0 0 1-1.914-1.914v-1.84a1.912 1.912 0 0 1 1.914-1.914zm3.82-6.935c0 .692-.55 1.222-1.187 1.222s-1.185-.529-1.185-1.222.548-1.222 1.185-1.222c.638 0 1.186.529 1.186 1.222zm-1.186 2.477c1.348 0 2.442-1.11 2.442-2.478S8.507 5.28 7.159 5.28 4.72 6.39 4.72 7.758s1.092 2.477 2.44 2.477zm2.048 7.71H5.114v-.838h4.093z'/%3E%3Cpath fill='%23e1e3e9' d='M2.222 7.555c0-2.55 2.214-4.625 4.937-4.625 2.723 0 4.938 2.075 4.938 4.625 0 3.832-4.038 7.068-4.672 7.575l-.077.063a.286.286 0 0 1-.189.07.286.286 0 0 1-.188-.07l-.077-.063c-.634-.507-4.672-3.743-4.672-7.575zm4.937 2.68c1.348 0 2.442-1.11 2.442-2.478S8.507 5.28 7.159 5.28 4.72 6.39 4.72 7.758s1.092 2.477 2.44 2.477z'/%3E%3Cpath fill='%23fff' d='M4.377 15.948a.657.657 0 0 0-.659.659v1.84a.657.657 0 0 0 .659.659h5.565a.657.657 0 0 0 .659-.659v-1.84a.657.657 0 0 0-.659-.659zm4.83 1.16H5.114v.838h4.093z'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (-ms-high-contrast:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.255 1.255 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.255 1.255 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5.11 5.11 0 0 1 .314-.787l.009-.016a4.623 4.623 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.548 4.548 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4.314.319.566.676.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.416 2.416 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.448 2.448 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675c.211.2.381.43.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.76 4.76 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.407 3.407 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.255 1.255 0 0 1 .689 1.004 4.73 4.73 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528 0 .343-.02.694-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.815 5.815 0 0 1-.548-2.512c0-.286.017-.567.053-.843a1.255 1.255 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.778 4.778 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.47 4.47 0 0 1-1.935-.424 1.252 1.252 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.402 2.402 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.703 4.703 0 0 1-1.782 1.884 4.767 4.767 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.47 4.47 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a4.983 4.983 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.255 1.255 0 0 1-1.115.676h-.098a1.255 1.255 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15c.329-.237.574-.499.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267c-.088-.22-.264-.438-.526-.658l-.032-.028a3.16 3.16 0 0 0-.668-.428l-.27-.12a3.293 3.293 0 0 0-1.235-.23c-.757 0-1.415.163-1.974.493a3.36 3.36 0 0 0-1.3 1.382c-.297.593-.444 1.284-.444 2.074 0 .8.17 1.503.51 2.107a3.795 3.795 0 0 0 1.382 1.381 3.883 3.883 0 0 0 1.893.477c.53 0 1.015-.11 1.455-.33zm-2.789-5.38c-.384.45-.575 1.038-.575 1.762 0 .735.186 1.332.559 1.794.384.45.933.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.17 2.17 0 0 0 .468-.29l.178-.161a2.163 2.163 0 0 0 .397-.561c.163-.333.244-.717.244-1.15v-.115c0-.472-.098-.894-.296-1.267l-.043-.077a2.211 2.211 0 0 0-.633-.709l-.13-.086-.047-.028a2.099 2.099 0 0 0-1.073-.285c-.702 0-1.244.231-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.958.958 0 0 0-.353-.389.851.851 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.626 2.626 0 0 0 .331.423c.213.22.464.402.755.548l.173.074c.433.17.93.255 1.49.255.68 0 1.295-.165 1.844-.493a3.447 3.447 0 0 0 1.316-1.4c.329-.603.493-1.299.493-2.089 0-1.273-.33-2.243-.988-2.913-.658-.68-1.52-1.02-2.584-1.02-.598 0-1.124.115-1.575.347a2.807 2.807 0 0 0-.415.262l-.199.166a3.35 3.35 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138c.137.193.297.36.48.5l.155.11.053.034c.34.197.713.297 1.119.297.714 0 1.262-.225 1.645-.675.385-.46.576-1.048.576-1.762 0-.746-.192-1.338-.576-1.777-.372-.45-.92-.675-1.645-.675-.29 0-.569.053-.835.16a2.366 2.366 0 0 0-.284.136 1.99 1.99 0 0 0-.363.254 2.237 2.237 0 0 0-.46.569l-.082.162a2.56 2.56 0 0 0-.213 1.072v.115c0 .471.098.894.296 1.267l.135.211zm.964-.818a1.11 1.11 0 0 0 .367.385.937.937 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a.995.995 0 0 0-.503.135l-.012.007a.859.859 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.43 1.43 0 0 0 .14.66zm15.7-6.222c.232-.23.346-.516.346-.856a1.053 1.053 0 0 0-.345-.79 1.175 1.175 0 0 0-.84-.329c-.34 0-.625.11-.855.33a1.053 1.053 0 0 0-.346.79c0 .34.115.625.346.855.23.23.516.346.856.346.34 0 .62-.115.839-.346zm4.337 9.314.033-1.332c.128.269.324.518.59.747l.098.081a3.727 3.727 0 0 0 .316.224l.223.122a3.21 3.21 0 0 0 1.44.322 3.785 3.785 0 0 0 1.875-.477 3.52 3.52 0 0 0 1.382-1.366c.352-.593.526-1.29.526-2.09 0-.79-.147-1.48-.444-2.073a3.235 3.235 0 0 0-1.283-1.399c-.549-.34-1.195-.51-1.942-.51a3.476 3.476 0 0 0-1.527.344l-.086.043-.165.09a3.412 3.412 0 0 0-.33.214c-.288.21-.507.446-.656.707a1.893 1.893 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.482 2.482 0 0 0 .566.7c.078.065.159.125.245.18l.144.08a2.105 2.105 0 0 0 .975.232c.713 0 1.262-.225 1.645-.675.384-.46.576-1.053.576-1.778 0-.734-.192-1.327-.576-1.777-.373-.46-.921-.692-1.645-.692a2.18 2.18 0 0 0-1.015.235c-.147.075-.285.17-.415.282l-.15.142a2.086 2.086 0 0 0-.42.594c-.149.32-.223.685-.223 1.1v.115c0 .47.097.89.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.868.868 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.13 1.13 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013c.23-.087.472-.134.724-.14l.069-.002c.329 0 .542.033.642.099l.247-1.794c-.13-.066-.37-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2.086 2.086 0 0 0-.411.148 2.18 2.18 0 0 0-.4.249 2.482 2.482 0 0 0-.485.499 2.659 2.659 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884c0-.364.053-.678.159-.943a1.49 1.49 0 0 1 .466-.636 2.52 2.52 0 0 1 .399-.253 2.19 2.19 0 0 1 .224-.099zm9.784 2.656.05-.922c0-1.162-.285-2.062-.856-2.698-.559-.647-1.42-.97-2.584-.97-.746 0-1.415.163-2.007.493a3.462 3.462 0 0 0-1.4 1.382c-.329.604-.493 1.306-.493 2.106 0 .714.143 1.371.428 1.975.285.593.73 1.07 1.332 1.432.604.351 1.355.526 2.255.526.649 0 1.204-.062 1.668-.185l.044-.012.135-.04c.409-.122.736-.263.984-.421l-.542-1.267c-.2.108-.415.199-.642.274l-.297.087c-.34.088-.773.131-1.3.131-.636 0-1.135-.147-1.497-.444a1.573 1.573 0 0 1-.192-.193c-.244-.294-.415-.705-.512-1.234l-.004-.021h5.43zm-5.427-1.256-.003.022h3.752v-.138c-.007-.485-.104-.857-.288-1.118a1.056 1.056 0 0 0-.156-.176c-.307-.285-.746-.428-1.316-.428-.657 0-1.155.202-1.494.604-.253.3-.417.712-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81c-.68 0-1.311-.16-1.893-.478a3.795 3.795 0 0 1-1.381-1.382c-.34-.604-.51-1.306-.51-2.106 0-.79.147-1.482.444-2.074a3.364 3.364 0 0 1 1.3-1.382c.559-.33 1.217-.494 1.974-.494a3.293 3.293 0 0 1 1.234.231 3.341 3.341 0 0 1 .97.575c.264.22.44.439.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332c-.186.395-.526.746-1.02 1.053a3.167 3.167 0 0 1-1.662.444zm.296-1.482c.626 0 1.152-.214 1.58-.642.428-.44.642-1.01.642-1.711v-.115c0-.472-.098-.894-.296-1.267a2.211 2.211 0 0 0-.807-.872 2.098 2.098 0 0 0-1.119-.313c-.702 0-1.245.231-1.629.692-.384.45-.575 1.037-.575 1.76 0 .736.186 1.333.559 1.795.384.45.933.675 1.645.675zm6.521-6.237h1.711v1.4c.604-1.065 1.547-1.597 2.83-1.597 1.064 0 1.926.34 2.584 1.02.659.67.988 1.641.988 2.914 0 .79-.164 1.487-.493 2.09a3.456 3.456 0 0 1-1.316 1.399 3.51 3.51 0 0 1-1.844.493c-.636 0-1.19-.11-1.662-.329a2.665 2.665 0 0 1-1.086-.97l.017 5.134h-1.728V9.242zm4.048 6.22c.714 0 1.262-.224 1.645-.674.385-.46.576-1.048.576-1.762 0-.746-.192-1.338-.576-1.777-.372-.45-.92-.675-1.645-.675-.395 0-.768.098-1.12.296-.34.187-.613.46-.822.823-.197.351-.296.763-.296 1.234v.115c0 .472.098.894.296 1.267.209.362.483.647.823.855.34.197.713.297 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.159 1.159 0 0 1-.856-.346 1.165 1.165 0 0 1-.346-.856 1.053 1.053 0 0 1 .346-.79c.23-.219.516-.329.856-.329.329 0 .609.11.839.33a1.053 1.053 0 0 1 .345.79 1.159 1.159 0 0 1-.345.855c-.22.23-.5.346-.84.346zm7.875 9.133a3.167 3.167 0 0 1-1.662-.444c-.482-.307-.817-.658-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283c.186-.438.548-.812 1.086-1.119a3.486 3.486 0 0 1 1.778-.477c.746 0 1.393.17 1.942.51a3.235 3.235 0 0 1 1.283 1.4c.297.592.444 1.282.444 2.072 0 .8-.175 1.498-.526 2.09a3.52 3.52 0 0 1-1.382 1.366 3.785 3.785 0 0 1-1.876.477zm-.296-1.481c.713 0 1.26-.225 1.645-.675.384-.46.577-1.053.577-1.778 0-.734-.193-1.327-.577-1.776-.373-.46-.921-.692-1.645-.692a2.115 2.115 0 0 0-1.58.659c-.428.428-.642.992-.642 1.694v.115c0 .473.098.895.296 1.267a2.385 2.385 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481c.176-.505.46-.91.856-1.217a2.14 2.14 0 0 1 1.349-.46c.351 0 .593.032.724.098l-.247 1.794c-.099-.066-.313-.099-.642-.099-.516 0-.988.164-1.416.494-.417.329-.626.855-.626 1.58v3.883h-1.777V9.242zm9.534 7.718c-.9 0-1.651-.175-2.255-.526-.603-.362-1.047-.84-1.332-1.432a4.567 4.567 0 0 1-.428-1.975c0-.8.164-1.502.493-2.106a3.462 3.462 0 0 1 1.4-1.382c.592-.33 1.262-.494 2.007-.494 1.163 0 2.024.324 2.584.97.57.637.856 1.537.856 2.7 0 .296-.017.603-.05.92h-5.43c.12.67.356 1.153.708 1.45.362.296.86.443 1.497.443.526 0 .96-.044 1.3-.131a4.123 4.123 0 0 0 .938-.362l.542 1.267c-.274.175-.647.329-1.119.46-.472.132-1.042.197-1.711.197zm1.596-4.558c.01-.68-.137-1.158-.444-1.432-.307-.285-.746-.428-1.316-.428-1.152 0-1.815.62-1.991 1.86h3.752z'/%3E%3Cg fill-rule='evenodd' stroke-width='1.036'%3E%3Cpath fill='%23000' fill-opacity='.4' d='m8.166 16.146-.002.002a1.54 1.54 0 0 1-2.009 0l-.002-.002-.043-.034-.002-.002-.199-.162H4.377a.657.657 0 0 0-.659.659v1.84a.657.657 0 0 0 .659.659h5.565a.657.657 0 0 0 .659-.659v-1.84a.657.657 0 0 0-.659-.659H8.411l-.202.164zm-1.121-.905a.29.29 0 0 0 .113.023.286.286 0 0 0 .189-.07l.077-.063c.634-.508 4.672-3.743 4.672-7.575 0-2.55-2.215-4.625-4.938-4.625S2.221 5.006 2.221 7.556c0 3.225 2.86 6.027 4.144 7.137h.004l.04.038.484.4.077.063a.628.628 0 0 0 .074.047zm-2.52-.548a16.898 16.898 0 0 1-1.183-1.315C2.187 11.942.967 9.897.967 7.555c0-3.319 2.855-5.88 6.192-5.88 3.338 0 6.193 2.561 6.193 5.881 0 2.34-1.22 4.387-2.376 5.822a16.898 16.898 0 0 1-1.182 1.315h.15a1.912 1.912 0 0 1 1.914 1.914v1.84a1.912 1.912 0 0 1-1.914 1.914H4.377a1.912 1.912 0 0 1-1.914-1.914v-1.84a1.912 1.912 0 0 1 1.914-1.914zm3.82-6.935c0 .692-.55 1.222-1.187 1.222s-1.185-.529-1.185-1.222.548-1.222 1.185-1.222c.638 0 1.186.529 1.186 1.222zm-1.186 2.477c1.348 0 2.442-1.11 2.442-2.478S8.507 5.28 7.159 5.28 4.72 6.39 4.72 7.758s1.092 2.477 2.44 2.477zm2.048 7.71H5.114v-.838h4.093z'/%3E%3Cpath fill='%23e1e3e9' d='M2.222 7.555c0-2.55 2.214-4.625 4.937-4.625 2.723 0 4.938 2.075 4.938 4.625 0 3.832-4.038 7.068-4.672 7.575l-.077.063a.286.286 0 0 1-.189.07.286.286 0 0 1-.188-.07l-.077-.063c-.634-.507-4.672-3.743-4.672-7.575zm4.937 2.68c1.348 0 2.442-1.11 2.442-2.478S8.507 5.28 7.159 5.28 4.72 6.39 4.72 7.758s1.092 2.477 2.44 2.477z'/%3E%3Cpath fill='%23fff' d='M4.377 15.948a.657.657 0 0 0-.659.659v1.84a.657.657 0 0 0 .659.659h5.565a.657.657 0 0 0 .659-.659v-1.84a.657.657 0 0 0-.659-.659zm4.83 1.16H5.114v.838h4.093z'/%3E%3C/g%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.255 1.255 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.255 1.255 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5.11 5.11 0 0 1 .314-.787l.009-.016a4.623 4.623 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.548 4.548 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4.314.319.566.676.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.416 2.416 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.448 2.448 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675c.211.2.381.43.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.76 4.76 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.407 3.407 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.255 1.255 0 0 1 .689 1.004 4.73 4.73 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528 0 .343-.02.694-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.815 5.815 0 0 1-.548-2.512c0-.286.017-.567.053-.843a1.255 1.255 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.778 4.778 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.47 4.47 0 0 1-1.935-.424 1.252 1.252 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.402 2.402 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.703 4.703 0 0 1-1.782 1.884 4.767 4.767 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.47 4.47 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a4.983 4.983 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.255 1.255 0 0 1-1.115.676h-.098a1.255 1.255 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15c.329-.237.574-.499.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267c-.088-.22-.264-.438-.526-.658l-.032-.028a3.16 3.16 0 0 0-.668-.428l-.27-.12a3.293 3.293 0 0 0-1.235-.23c-.757 0-1.415.163-1.974.493a3.36 3.36 0 0 0-1.3 1.382c-.297.593-.444 1.284-.444 2.074 0 .8.17 1.503.51 2.107a3.795 3.795 0 0 0 1.382 1.381 3.883 3.883 0 0 0 1.893.477c.53 0 1.015-.11 1.455-.33zm-2.789-5.38c-.384.45-.575 1.038-.575 1.762 0 .735.186 1.332.559 1.794.384.45.933.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.17 2.17 0 0 0 .468-.29l.178-.161a2.163 2.163 0 0 0 .397-.561c.163-.333.244-.717.244-1.15v-.115c0-.472-.098-.894-.296-1.267l-.043-.077a2.211 2.211 0 0 0-.633-.709l-.13-.086-.047-.028a2.099 2.099 0 0 0-1.073-.285c-.702 0-1.244.231-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.958.958 0 0 0-.353-.389.851.851 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.626 2.626 0 0 0 .331.423c.213.22.464.402.755.548l.173.074c.433.17.93.255 1.49.255.68 0 1.295-.165 1.844-.493a3.447 3.447 0 0 0 1.316-1.4c.329-.603.493-1.299.493-2.089 0-1.273-.33-2.243-.988-2.913-.658-.68-1.52-1.02-2.584-1.02-.598 0-1.124.115-1.575.347a2.807 2.807 0 0 0-.415.262l-.199.166a3.35 3.35 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138c.137.193.297.36.48.5l.155.11.053.034c.34.197.713.297 1.119.297.714 0 1.262-.225 1.645-.675.385-.46.576-1.048.576-1.762 0-.746-.192-1.338-.576-1.777-.372-.45-.92-.675-1.645-.675-.29 0-.569.053-.835.16a2.366 2.366 0 0 0-.284.136 1.99 1.99 0 0 0-.363.254 2.237 2.237 0 0 0-.46.569l-.082.162a2.56 2.56 0 0 0-.213 1.072v.115c0 .471.098.894.296 1.267l.135.211zm.964-.818a1.11 1.11 0 0 0 .367.385.937.937 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a.995.995 0 0 0-.503.135l-.012.007a.859.859 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.43 1.43 0 0 0 .14.66zm15.7-6.222c.232-.23.346-.516.346-.856a1.053 1.053 0 0 0-.345-.79 1.175 1.175 0 0 0-.84-.329c-.34 0-.625.11-.855.33a1.053 1.053 0 0 0-.346.79c0 .34.115.625.346.855.23.23.516.346.856.346.34 0 .62-.115.839-.346zm4.337 9.314.033-1.332c.128.269.324.518.59.747l.098.081a3.727 3.727 0 0 0 .316.224l.223.122a3.21 3.21 0 0 0 1.44.322 3.785 3.785 0 0 0 1.875-.477 3.52 3.52 0 0 0 1.382-1.366c.352-.593.526-1.29.526-2.09 0-.79-.147-1.48-.444-2.073a3.235 3.235 0 0 0-1.283-1.399c-.549-.34-1.195-.51-1.942-.51a3.476 3.476 0 0 0-1.527.344l-.086.043-.165.09a3.412 3.412 0 0 0-.33.214c-.288.21-.507.446-.656.707a1.893 1.893 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.482 2.482 0 0 0 .566.7c.078.065.159.125.245.18l.144.08a2.105 2.105 0 0 0 .975.232c.713 0 1.262-.225 1.645-.675.384-.46.576-1.053.576-1.778 0-.734-.192-1.327-.576-1.777-.373-.46-.921-.692-1.645-.692a2.18 2.18 0 0 0-1.015.235c-.147.075-.285.17-.415.282l-.15.142a2.086 2.086 0 0 0-.42.594c-.149.32-.223.685-.223 1.1v.115c0 .47.097.89.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.868.868 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.13 1.13 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013c.23-.087.472-.134.724-.14l.069-.002c.329 0 .542.033.642.099l.247-1.794c-.13-.066-.37-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2.086 2.086 0 0 0-.411.148 2.18 2.18 0 0 0-.4.249 2.482 2.482 0 0 0-.485.499 2.659 2.659 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884c0-.364.053-.678.159-.943a1.49 1.49 0 0 1 .466-.636 2.52 2.52 0 0 1 .399-.253 2.19 2.19 0 0 1 .224-.099zm9.784 2.656.05-.922c0-1.162-.285-2.062-.856-2.698-.559-.647-1.42-.97-2.584-.97-.746 0-1.415.163-2.007.493a3.462 3.462 0 0 0-1.4 1.382c-.329.604-.493 1.306-.493 2.106 0 .714.143 1.371.428 1.975.285.593.73 1.07 1.332 1.432.604.351 1.355.526 2.255.526.649 0 1.204-.062 1.668-.185l.044-.012.135-.04c.409-.122.736-.263.984-.421l-.542-1.267c-.2.108-.415.199-.642.274l-.297.087c-.34.088-.773.131-1.3.131-.636 0-1.135-.147-1.497-.444a1.573 1.573 0 0 1-.192-.193c-.244-.294-.415-.705-.512-1.234l-.004-.021h5.43zm-5.427-1.256-.003.022h3.752v-.138c-.007-.485-.104-.857-.288-1.118a1.056 1.056 0 0 0-.156-.176c-.307-.285-.746-.428-1.316-.428-.657 0-1.155.202-1.494.604-.253.3-.417.712-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81c-.68 0-1.311-.16-1.893-.478a3.795 3.795 0 0 1-1.381-1.382c-.34-.604-.51-1.306-.51-2.106 0-.79.147-1.482.444-2.074a3.364 3.364 0 0 1 1.3-1.382c.559-.33 1.217-.494 1.974-.494a3.293 3.293 0 0 1 1.234.231 3.341 3.341 0 0 1 .97.575c.264.22.44.439.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332c-.186.395-.526.746-1.02 1.053a3.167 3.167 0 0 1-1.662.444zm.296-1.482c.626 0 1.152-.214 1.58-.642.428-.44.642-1.01.642-1.711v-.115c0-.472-.098-.894-.296-1.267a2.211 2.211 0 0 0-.807-.872 2.098 2.098 0 0 0-1.119-.313c-.702 0-1.245.231-1.629.692-.384.45-.575 1.037-.575 1.76 0 .736.186 1.333.559 1.795.384.45.933.675 1.645.675zm6.521-6.237h1.711v1.4c.604-1.065 1.547-1.597 2.83-1.597 1.064 0 1.926.34 2.584 1.02.659.67.988 1.641.988 2.914 0 .79-.164 1.487-.493 2.09a3.456 3.456 0 0 1-1.316 1.399 3.51 3.51 0 0 1-1.844.493c-.636 0-1.19-.11-1.662-.329a2.665 2.665 0 0 1-1.086-.97l.017 5.134h-1.728V9.242zm4.048 6.22c.714 0 1.262-.224 1.645-.674.385-.46.576-1.048.576-1.762 0-.746-.192-1.338-.576-1.777-.372-.45-.92-.675-1.645-.675-.395 0-.768.098-1.12.296-.34.187-.613.46-.822.823-.197.351-.296.763-.296 1.234v.115c0 .472.098.894.296 1.267.209.362.483.647.823.855.34.197.713.297 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.159 1.159 0 0 1-.856-.346 1.165 1.165 0 0 1-.346-.856 1.053 1.053 0 0 1 .346-.79c.23-.219.516-.329.856-.329.329 0 .609.11.839.33a1.053 1.053 0 0 1 .345.79 1.159 1.159 0 0 1-.345.855c-.22.23-.5.346-.84.346zm7.875 9.133a3.167 3.167 0 0 1-1.662-.444c-.482-.307-.817-.658-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283c.186-.438.548-.812 1.086-1.119a3.486 3.486 0 0 1 1.778-.477c.746 0 1.393.17 1.942.51a3.235 3.235 0 0 1 1.283 1.4c.297.592.444 1.282.444 2.072 0 .8-.175 1.498-.526 2.09a3.52 3.52 0 0 1-1.382 1.366 3.785 3.785 0 0 1-1.876.477zm-.296-1.481c.713 0 1.26-.225 1.645-.675.384-.46.577-1.053.577-1.778 0-.734-.193-1.327-.577-1.776-.373-.46-.921-.692-1.645-.692a2.115 2.115 0 0 0-1.58.659c-.428.428-.642.992-.642 1.694v.115c0 .473.098.895.296 1.267a2.385 2.385 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481c.176-.505.46-.91.856-1.217a2.14 2.14 0 0 1 1.349-.46c.351 0 .593.032.724.098l-.247 1.794c-.099-.066-.313-.099-.642-.099-.516 0-.988.164-1.416.494-.417.329-.626.855-.626 1.58v3.883h-1.777V9.242zm9.534 7.718c-.9 0-1.651-.175-2.255-.526-.603-.362-1.047-.84-1.332-1.432a4.567 4.567 0 0 1-.428-1.975c0-.8.164-1.502.493-2.106a3.462 3.462 0 0 1 1.4-1.382c.592-.33 1.262-.494 2.007-.494 1.163 0 2.024.324 2.584.97.57.637.856 1.537.856 2.7 0 .296-.017.603-.05.92h-5.43c.12.67.356 1.153.708 1.45.362.296.86.443 1.497.443.526 0 .96-.044 1.3-.131a4.123 4.123 0 0 0 .938-.362l.542 1.267c-.274.175-.647.329-1.119.46-.472.132-1.042.197-1.711.197zm1.596-4.558c.01-.68-.137-1.158-.444-1.432-.307-.285-.746-.428-1.316-.428-1.152 0-1.815.62-1.991 1.86h3.752z'/%3E%3Cg fill-rule='evenodd' stroke-width='1.036'%3E%3Cpath fill='%23000' fill-opacity='.4' d='m8.166 16.146-.002.002a1.54 1.54 0 0 1-2.009 0l-.002-.002-.043-.034-.002-.002-.199-.162H4.377a.657.657 0 0 0-.659.659v1.84a.657.657 0 0 0 .659.659h5.565a.657.657 0 0 0 .659-.659v-1.84a.657.657 0 0 0-.659-.659H8.411l-.202.164zm-1.121-.905a.29.29 0 0 0 .113.023.286.286 0 0 0 .189-.07l.077-.063c.634-.508 4.672-3.743 4.672-7.575 0-2.55-2.215-4.625-4.938-4.625S2.221 5.006 2.221 7.556c0 3.225 2.86 6.027 4.144 7.137h.004l.04.038.484.4.077.063a.628.628 0 0 0 .074.047zm-2.52-.548a16.898 16.898 0 0 1-1.183-1.315C2.187 11.942.967 9.897.967 7.555c0-3.319 2.855-5.88 6.192-5.88 3.338 0 6.193 2.561 6.193 5.881 0 2.34-1.22 4.387-2.376 5.822a16.898 16.898 0 0 1-1.182 1.315h.15a1.912 1.912 0 0 1 1.914 1.914v1.84a1.912 1.912 0 0 1-1.914 1.914H4.377a1.912 1.912 0 0 1-1.914-1.914v-1.84a1.912 1.912 0 0 1 1.914-1.914zm3.82-6.935c0 .692-.55 1.222-1.187 1.222s-1.185-.529-1.185-1.222.548-1.222 1.185-1.222c.638 0 1.186.529 1.186 1.222zm-1.186 2.477c1.348 0 2.442-1.11 2.442-2.478S8.507 5.28 7.159 5.28 4.72 6.39 4.72 7.758s1.092 2.477 2.44 2.477zm2.048 7.71H5.114v-.838h4.093z'/%3E%3Cpath fill='%23e1e3e9' d='M2.222 7.555c0-2.55 2.214-4.625 4.937-4.625 2.723 0 4.938 2.075 4.938 4.625 0 3.832-4.038 7.068-4.672 7.575l-.077.063a.286.286 0 0 1-.189.07.286.286 0 0 1-.188-.07l-.077-.063c-.634-.507-4.672-3.743-4.672-7.575zm4.937 2.68c1.348 0 2.442-1.11 2.442-2.478S8.507 5.28 7.159 5.28 4.72 6.39 4.72 7.758s1.092 2.477 2.44 2.477z'/%3E%3Cpath fill='%23fff' d='M4.377 15.948a.657.657 0 0 0-.659.659v1.84a.657.657 0 0 0 .659.659h5.565a.657.657 0 0 0 .659-.659v-1.84a.657.657 0 0 0-.659-.659zm4.83 1.16H5.114v.838h4.093z'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (-ms-high-contrast:black-on-white){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(width <= 480px){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl.d.ts b/web/libraries/maplibre-gl/dist/maplibre-gl.d.ts new file mode 100644 index 00000000..7bb2791b --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl.d.ts @@ -0,0 +1,11683 @@ +// Generated by dts-bundle-generator v8.1.2 + +import Point from '@mapbox/point-geometry'; +import TinySDF from '@mapbox/tiny-sdf'; +import { VectorTileFeature, VectorTileLayer } from '@mapbox/vector-tile'; +import { Color, CompositeExpression, Feature, FeatureFilter, FeatureState, FilterSpecification, Formatted, FormattedSection, GeoJSONSourceSpecification, GlobalProperties, ICanonicalTileID, IMercatorCoordinate, ImageSourceSpecification, InterpolationType, LayerSpecification, LightSpecification, Padding, PromoteIdSpecification, PropertyValueSpecification, RasterDEMSourceSpecification, RasterSourceSpecification, ResolvedImage, SourceExpression, SourceSpecification, SpriteSpecification, StylePropertyExpression, StylePropertySpecification, StyleSpecification, TerrainSpecification, TransitionSpecification, VariableAnchorOffsetCollection, VectorSourceSpecification, VideoSourceSpecification } from '@maplibre/maplibre-gl-style-spec'; +import { mat2, mat4, vec4 } from 'gl-matrix'; +import KDBush from 'kdbush'; +import { PotpackBox } from 'potpack'; +import { ClusterProperties, Options } from 'supercluster'; + +/** + * A request that can be cancelled + */ +export type Cancelable = { + cancel: () => void; +}; +/** + * A callback definition. + * + * @example + * ```ts + * asyncFunction((error, result) => { + * if (error) { + * // handle error + * } else if (result) { + * // handle success + * } + * }); + * ``` + */ +export type Callback = (error?: Error | null, result?: T | null) => void; +/** + * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks. + * @example + * ```ts + * // use transformRequest to modify requests that begin with `http://myHost` + * transformRequest: function(url, resourceType) { + * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) { + * return { + * url: url.replace('http', 'https'), + * headers: { 'my-custom-header': true }, + * credentials: 'include' // Include cookies for cross-origin requests + * } + * } + * } + * ``` + */ +export type RequestParameters = { + /** + * The URL to be requested. + */ + url: string; + /** + * The headers to be sent with the request. + */ + headers?: any; + /** + * Request method `'GET' | 'POST' | 'PUT'`. + */ + method?: "GET" | "POST" | "PUT"; + /** + * Request body. + */ + body?: string; + /** + * Response body type to be returned `'string' | 'json' | 'arrayBuffer'`. + */ + type?: "string" | "json" | "arrayBuffer" | "image"; + /** + * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests. + */ + credentials?: "same-origin" | "include"; + /** + * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events. + */ + collectResourceTiming?: boolean; + /** + * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache) + */ + cache?: RequestCache; +}; +/** + * The response callback used in various places + */ +export type ResponseCallback = (error?: Error | null, data?: T | null, cacheControl?: string | null, expires?: string | null) => void; +export declare class AJAXError extends Error { + /** + * The response's HTTP status code. + */ + status: number; + /** + * The response's HTTP status text. + */ + statusText: string; + /** + * The request's URL. + */ + url: string; + /** + * The response's body. + */ + body: Blob; + /** + * @param status - The response's HTTP status code. + * @param statusText - The response's HTTP status text. + * @param url - The request's URL. + * @param body - The response's body. + */ + constructor(status: number, statusText: string, url: string, body: Blob); +} +/** + * A type used to store the tile's expiration date and cache control definition + */ +export type ExpiryData = { + cacheControl?: string | null; + expires?: Date | string | null; +}; +/** + * The callback that is being called after an image was fetched + */ +export type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void; +/** + * A type of MapLibre resource. + */ +export declare const enum ResourceType { + Glyphs = "Glyphs", + Image = "Image", + Source = "Source", + SpriteImage = "SpriteImage", + SpriteJSON = "SpriteJSON", + Style = "Style", + Tile = "Tile", + Unknown = "Unknown" +} +/** + * This function is used to tranform a request. + * It is used just before executing the relevant request. + */ +export type RequestTransformFunction = (url: string, resourceType?: ResourceType) => RequestParameters | undefined; +export declare class RequestManager { + _transformRequestFn: RequestTransformFunction; + constructor(transformRequestFn?: RequestTransformFunction); + transformRequest(url: string, type: ResourceType): RequestParameters; + normalizeSpriteURL(url: string, format: string, extension: string): string; + setTransformRequest(transformRequest: RequestTransformFunction): void; +} +/** + * A listener method used as a callback to events + */ +export type Listener = (a: any) => any; +export type Listeners = { + [_: string]: Array; +}; +export declare class Event { + readonly type: string; + constructor(type: string, data?: any); +} +export declare class Evented { + _listeners: Listeners; + _oneTimeListeners: Listeners; + _eventedParent: Evented; + _eventedParentData: any | (() => any); + /** + * Adds a listener to a specified event type. + * + * @param type - The event type to add a listen for. + * @param listener - The function to be called when the event is fired. + * The listener function is called with the data object passed to `fire`, + * extended with `target` and `type` properties. + * @returns `this` + */ + on(type: string, listener: Listener): this; + /** + * Removes a previously registered event listener. + * + * @param type - The event type to remove listeners for. + * @param listener - The listener function to remove. + * @returns `this` + */ + off(type: string, listener: Listener): this; + /** + * Adds a listener that will be called only once to a specified event type. + * + * The listener will be called first time the event fires after the listener is registered. + * + * @param type - The event type to listen for. + * @param listener - The function to be called when the event is fired the first time. + * @returns `this` or a promise if a listener is not provided + */ + once(type: string, listener?: Listener): this | Promise; + fire(event: Event | string, properties?: any): this; + /** + * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type. + * + * @param type - The event type + * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise + */ + listens(type: string): boolean; + /** + * Bubble all events fired by this instance of Evented to this parent instance of Evented. + * @returns `this` + */ + setEventedParent(parent?: Evented | null, data?: any | (() => any)): this; +} +export declare class ZoomHistory { + lastZoom: number; + lastFloorZoom: number; + lastIntegerZoom: number; + lastIntegerZoomTime: number; + first: boolean; + constructor(); + update(z: number, now: number): boolean; +} +export type CrossfadeParameters = { + fromScale: number; + toScale: number; + t: number; +}; +export declare class EvaluationParameters { + zoom: number; + now: number; + fadeDuration: number; + zoomHistory: ZoomHistory; + transition: TransitionSpecification; + constructor(zoom: number, options?: any); + isSupportedScript(str: string): boolean; + crossFadingFactor(): number; + getCrossfadeParameters(): CrossfadeParameters; +} +/** + * A {@link LngLat} object, an array of two numbers representing longitude and latitude, + * or an object with `lng` and `lat` or `lon` and `lat` properties. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let v1 = new maplibregl.LngLat(-122.420679, 37.772537); + * let v2 = [-122.420679, 37.772537]; + * let v3 = {lon: -122.420679, lat: 37.772537}; + * ``` + */ +export type LngLatLike = LngLat | { + lng: number; + lat: number; +} | { + lon: number; + lat: number; +} | [ + number, + number +]; +export declare class LngLat { + lng: number; + lat: number; + /** + * @param lng - Longitude, measured in degrees. + * @param lat - Latitude, measured in degrees. + */ + constructor(lng: number, lat: number); + /** + * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180). + * + * @returns The wrapped `LngLat` object. + * @example + * ```ts + * let ll = new maplibregl.LngLat(286.0251, 40.7736); + * let wrapped = ll.wrap(); + * wrapped.lng; // = -73.9749 + * ``` + */ + wrap(): LngLat; + /** + * Returns the coordinates represented as an array of two numbers. + * + * @returns The coordinates represented as an array of longitude and latitude. + * @example + * ```ts + * let ll = new maplibregl.LngLat(-73.9749, 40.7736); + * ll.toArray(); // = [-73.9749, 40.7736] + * ``` + */ + toArray(): [ + number, + number + ]; + /** + * Returns the coordinates represent as a string. + * + * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`. + * @example + * ```ts + * let ll = new maplibregl.LngLat(-73.9749, 40.7736); + * ll.toString(); // = "LngLat(-73.9749, 40.7736)" + * ``` + */ + toString(): string; + /** + * Returns the approximate distance between a pair of coordinates in meters + * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) + * + * @param lngLat - coordinates to compute the distance to + * @returns Distance in meters between the two coordinates. + * @example + * ```ts + * let new_york = new maplibregl.LngLat(-74.0060, 40.7128); + * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522); + * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km + * ``` + */ + distanceTo(lngLat: LngLat): number; + /** + * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties + * to a `LngLat` object. + * + * If a `LngLat` object is passed in, the function returns it unchanged. + * + * @param input - An array of two numbers or object to convert, or a `LngLat` object to return. + * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object. + * @example + * ```ts + * let arr = [-73.9749, 40.7736]; + * let ll = maplibregl.LngLat.convert(arr); + * ll; // = LngLat {lng: -73.9749, lat: 40.7736} + * ``` + */ + static convert(input: LngLatLike): LngLat; +} +export declare class MercatorCoordinate implements IMercatorCoordinate { + x: number; + y: number; + z: number; + /** + * @param x - The x component of the position. + * @param y - The y component of the position. + * @param z - The z component of the position. + */ + constructor(x: number, y: number, z?: number); + /** + * Project a `LngLat` to a `MercatorCoordinate`. + * + * @param lngLatLike - The location to project. + * @param altitude - The altitude in meters of the position. + * @returns The projected mercator coordinate. + * @example + * ```ts + * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0); + * coord; // MercatorCoordinate(0.5, 0.5, 0) + * ``` + */ + static fromLngLat(lngLatLike: LngLatLike, altitude?: number): MercatorCoordinate; + /** + * Returns the `LngLat` for the coordinate. + * + * @returns The `LngLat` object. + * @example + * ```ts + * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0); + * let lngLat = coord.toLngLat(); // LngLat(0, 0) + * ``` + */ + toLngLat(): LngLat; + /** + * Returns the altitude in meters of the coordinate. + * + * @returns The altitude in meters. + * @example + * ```ts + * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02); + * coord.toAltitude(); // 6914.281956295339 + * ``` + */ + toAltitude(): number; + /** + * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude. + * + * For coordinates in real world units using meters, this naturally provides the scale + * to transform into `MercatorCoordinate`s. + * + * @returns Distance of 1 meter in `MercatorCoordinate` units. + */ + meterInMercatorCoordinateUnits(): number; +} +export declare class CanonicalTileID implements ICanonicalTileID { + z: number; + x: number; + y: number; + key: string; + constructor(z: number, x: number, y: number); + equals(id: ICanonicalTileID): boolean; + url(urls: Array, pixelRatio: number, scheme?: string | null): string; + isChildOf(parent: ICanonicalTileID): boolean; + getTilePoint(coord: IMercatorCoordinate): Point; + toString(): string; +} +export declare class UnwrappedTileID { + wrap: number; + canonical: CanonicalTileID; + key: string; + constructor(wrap: number, canonical: CanonicalTileID); +} +export declare class OverscaledTileID { + overscaledZ: number; + wrap: number; + canonical: CanonicalTileID; + key: string; + posMatrix: mat4; + constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number); + clone(): OverscaledTileID; + equals(id: OverscaledTileID): boolean; + scaledTo(targetZ: number): OverscaledTileID; + calculateScaledKey(targetZ: number, withWrap: boolean): string; + isChildOf(parent: OverscaledTileID): boolean; + children(sourceMaxZoom: number): OverscaledTileID[]; + isLessThan(rhs: OverscaledTileID): boolean; + wrapped(): OverscaledTileID; + unwrapTo(wrap: number): OverscaledTileID; + overscaleFactor(): number; + toUnwrapped(): UnwrappedTileID; + toString(): string; + getTilePoint(coord: MercatorCoordinate): Point; +} +export type TimePoint = number; +/** + * A from-to type + */ +export type CrossFaded = { + to: T; + from: T; +}; +/** + * @internal + * Implementations of the `Property` interface: + * + * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value, + * the default value, etc. This comes from the style specification JSON. + * * Define behavior that needs to be polymorphic across different properties: "possibly evaluating" + * an input value (see below), and interpolating between two possibly-evaluted values. + * + * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`). + * The type `R` is the intermediate "possibly evaluated" value type. See below. + * + * There are two main implementations of the interface -- one for properties that allow data-driven values, + * and one for properties that don't. There are a few "special case" implementations as well: one for properties + * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`, + * and one for `light-position`. + */ +export interface Property { + specification: StylePropertySpecification; + possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): R; + interpolate(a: R, b: R, t: number): R; +} +export declare class PropertyValue { + property: Property; + value: PropertyValueSpecification | void; + expression: StylePropertyExpression; + constructor(property: Property, value: PropertyValueSpecification | void); + isDataDriven(): boolean; + possiblyEvaluate(parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): R; +} +export type TransitionParameters = { + now: TimePoint; + transition: TransitionSpecification; +}; +export declare class TransitionablePropertyValue { + property: Property; + value: PropertyValue; + transition: TransitionSpecification | void; + constructor(property: Property); + transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue): TransitioningPropertyValue; + untransitioned(): TransitioningPropertyValue; +} +export declare class Transitionable { + _properties: Properties; + _values: { + [K in keyof Props]: TransitionablePropertyValue; + }; + constructor(properties: Properties); + getValue(name: S): PropertyValueSpecification | void; + setValue(name: S, value: PropertyValueSpecification | void): void; + getTransition(name: S): TransitionSpecification | void; + setTransition(name: S, value: TransitionSpecification | void): void; + serialize(): any; + transitioned(parameters: TransitionParameters, prior: Transitioning): Transitioning; + untransitioned(): Transitioning; +} +export declare class TransitioningPropertyValue { + property: Property; + value: PropertyValue; + prior: TransitioningPropertyValue; + begin: TimePoint; + end: TimePoint; + constructor(property: Property, value: PropertyValue, prior: TransitioningPropertyValue, transition: TransitionSpecification, now: TimePoint); + possiblyEvaluate(parameters: EvaluationParameters, canonical: CanonicalTileID, availableImages: Array): R; +} +export declare class Transitioning { + _properties: Properties; + _values: { + [K in keyof Props]: PossiblyEvaluatedPropertyValue; + }; + constructor(properties: Properties); + possiblyEvaluate(parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): PossiblyEvaluated; + hasTransition(): boolean; +} +export declare class Layout { + _properties: Properties; + _values: { + [K in keyof Props]: PropertyValue>; + }; + constructor(properties: Properties); + hasValue(name: S): boolean; + getValue(name: S): any; + setValue(name: S, value: any): void; + serialize(): any; + possiblyEvaluate(parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): PossiblyEvaluated; +} +/** + * "Possibly evaluated value" is an intermediate stage in the evaluation chain for both paint and layout property + * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code + * which uses data-driven property values must assume that the value is dependent on feature data, and request that it + * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation + * will not actually depend on the feature, and we can benefit from returning the prior result of having done the + * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and "global" parameters + * such as current zoom level. + * + * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or + * camera expression, then the "possibly evaluated" result is a constant value. Otherwise, the input value was either + * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate + * the source and composite cases because they are handled differently when generating GL attributes, buffers, and + * uniforms. + * + * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that + * do not allow data-driven values. For such properties, we know that the "possibly evaluated" result is always a constant + * scalar value. See below. + */ +export type PossiblyEvaluatedValue = { + kind: "constant"; + value: T; +} | SourceExpression | CompositeExpression; +export declare class PossiblyEvaluatedPropertyValue { + property: DataDrivenProperty; + value: PossiblyEvaluatedValue; + parameters: EvaluationParameters; + constructor(property: DataDrivenProperty, value: PossiblyEvaluatedValue, parameters: EvaluationParameters); + isConstant(): boolean; + constantOr(value: T): T; + evaluate(feature: Feature, featureState: FeatureState, canonical?: CanonicalTileID, availableImages?: Array): T; +} +export declare class PossiblyEvaluated { + _properties: Properties; + _values: PossibleEvaluatedProps; + constructor(properties: Properties); + get(name: S): PossibleEvaluatedProps[S]; +} +export declare class DataConstantProperty implements Property { + specification: StylePropertySpecification; + constructor(specification: StylePropertySpecification); + possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters): T; + interpolate(a: T, b: T, t: number): T; +} +export declare class DataDrivenProperty implements Property> { + specification: StylePropertySpecification; + overrides: any; + constructor(specification: StylePropertySpecification, overrides?: any); + possiblyEvaluate(value: PropertyValue>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): PossiblyEvaluatedPropertyValue; + interpolate(a: PossiblyEvaluatedPropertyValue, b: PossiblyEvaluatedPropertyValue, t: number): PossiblyEvaluatedPropertyValue; + evaluate(value: PossiblyEvaluatedValue, parameters: EvaluationParameters, feature: Feature, featureState: FeatureState, canonical?: CanonicalTileID, availableImages?: Array): T; +} +export declare class CrossFadedDataDrivenProperty extends DataDrivenProperty> { + possiblyEvaluate(value: PropertyValue, PossiblyEvaluatedPropertyValue>>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): PossiblyEvaluatedPropertyValue>; + evaluate(value: PossiblyEvaluatedValue>, globals: EvaluationParameters, feature: Feature, featureState: FeatureState, canonical?: CanonicalTileID, availableImages?: Array): CrossFaded; + _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded; + interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue>; +} +export declare class CrossFadedProperty implements Property> { + specification: StylePropertySpecification; + constructor(specification: StylePropertySpecification); + possiblyEvaluate(value: PropertyValue>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): CrossFaded; + _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded; + interpolate(a?: CrossFaded | null): CrossFaded; +} +export declare class ColorRampProperty implements Property { + specification: StylePropertySpecification; + constructor(specification: StylePropertySpecification); + possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array): boolean; + interpolate(): boolean; +} +export declare class Properties { + properties: Props; + defaultPropertyValues: { + [K in keyof Props]: PropertyValue; + }; + defaultTransitionablePropertyValues: { + [K in keyof Props]: TransitionablePropertyValue; + }; + defaultTransitioningPropertyValues: { + [K in keyof Props]: TransitioningPropertyValue; + }; + defaultPossiblyEvaluatedValues: { + [K in keyof Props]: PossiblyEvaluatedPropertyValue; + }; + overridableProperties: Array; + constructor(properties: Props); +} +/** + * An object with is transferable between main and worker thread + */ +export type Transferable = ArrayBuffer | MessagePort | ImageBitmap; +declare const viewTypes: { + Int8: Int8ArrayConstructor; + Uint8: Uint8ArrayConstructor; + Int16: Int16ArrayConstructor; + Uint16: Uint16ArrayConstructor; + Int32: Int32ArrayConstructor; + Uint32: Uint32ArrayConstructor; + Float32: Float32ArrayConstructor; +}; +/** + * @internal + * A view type size + */ +export type ViewType = keyof typeof viewTypes; +export declare class Struct { + _pos1: number; + _pos2: number; + _pos4: number; + _pos8: number; + readonly _structArray: StructArray; + size: number; + /** + * @param structArray - The StructArray the struct is stored in + * @param index - The index of the struct in the StructArray. + */ + constructor(structArray: StructArray, index: number); +} +/** + * @internal + * A struct array memeber + */ +export type StructArrayMember = { + name: string; + type: ViewType; + components: number; + offset: number; +}; +/** + * An array that can be desialized + */ +export type SerializedStructArray = { + length: number; + arrayBuffer: ArrayBuffer; +}; +declare abstract class StructArray { + capacity: number; + length: number; + isTransferred: boolean; + arrayBuffer: ArrayBuffer; + uint8: Uint8Array; + members: Array; + bytesPerElement: number; + abstract emplaceBack(...v: number[]): any; + abstract emplace(i: number, ...v: number[]): any; + constructor(); + /** + * Serialize a StructArray instance. Serializes both the raw data and the + * metadata needed to reconstruct the StructArray base class during + * deserialization. + */ + static serialize(array: StructArray, transferables?: Array): SerializedStructArray; + static deserialize(input: SerializedStructArray): any; + /** + * Resize the array to discard unused capacity. + */ + _trim(): void; + /** + * Resets the length of the array to 0 without de-allocating capcacity. + */ + clear(): void; + /** + * Resize the array. + * If `n` is greater than the current length then additional elements with undefined values are added. + * If `n` is less than the current length then the array will be reduced to the first `n` elements. + * @param n - The new size of the array. + */ + resize(n: number): void; + /** + * Indicate a planned increase in size, so that any necessary allocation may + * be done once, ahead of time. + * @param n - The expected size of the array. + */ + reserve(n: number): void; + /** + * Create TypedArray views for the current ArrayBuffer. + */ + _refreshViews(): void; +} +export declare class StructArrayLayout2i4 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number): number; + emplace(i: number, v0: number, v1: number): number; +} +export declare class StructArrayLayout3i6 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number): number; + emplace(i: number, v0: number, v1: number, v2: number): number; +} +export declare class StructArrayLayout4i8 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number): number; +} +export declare class StructArrayLayout2i4i12 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; +} +export declare class StructArrayLayout2i4ub8 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; +} +export declare class StructArrayLayout2f8 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number): number; + emplace(i: number, v0: number, v1: number): number; +} +export declare class StructArrayLayout4i4ui4i24 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint16: Uint16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number): number; +} +export declare class StructArrayLayout3f12 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number): number; + emplace(i: number, v0: number, v1: number, v2: number): number; +} +export declare class StructArrayLayout1ul4 extends StructArray { + uint8: Uint8Array; + uint32: Uint32Array; + _refreshViews(): void; + emplaceBack(v0: number): number; + emplace(i: number, v0: number): number; +} +export declare class StructArrayLayout6i1ul2ui20 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint32: Uint32Array; + uint16: Uint16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number): number; +} +export declare class StructArrayLayout2ub2f12 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number): number; +} +export declare class StructArrayLayout3ui6 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number): number; + emplace(i: number, v0: number, v1: number, v2: number): number; +} +export declare class StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint16: Uint16Array; + uint32: Uint32Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number): number; +} +export declare class StructArrayLayout8i15ui1ul2f2ui64 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint16: Uint16Array; + uint32: Uint32Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number): number; + emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number): number; +} +export declare class StructArrayLayout1f4 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number): number; + emplace(i: number, v0: number): number; +} +export declare class StructArrayLayout1ui2f12 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + float32: Float32Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number): number; + emplace(i: number, v0: number, v1: number, v2: number): number; +} +export declare class StructArrayLayout1ul2ui8 extends StructArray { + uint8: Uint8Array; + uint32: Uint32Array; + uint16: Uint16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number, v2: number): number; + emplace(i: number, v0: number, v1: number, v2: number): number; +} +export declare class StructArrayLayout2ui4 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + _refreshViews(): void; + emplaceBack(v0: number, v1: number): number; + emplace(i: number, v0: number, v1: number): number; +} +export declare class StructArrayLayout1ui2 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + _refreshViews(): void; + emplaceBack(v0: number): number; + emplace(i: number, v0: number): number; +} +export declare class CollisionBoxStruct extends Struct { + _structArray: CollisionBoxArray; + get anchorPointX(): number; + get anchorPointY(): number; + get x1(): number; + get y1(): number; + get x2(): number; + get y2(): number; + get featureIndex(): number; + get sourceLayerIndex(): number; + get bucketIndex(): number; + get anchorPoint(): Point; +} +export declare class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 { + /** + * Return the CollisionBoxStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): CollisionBoxStruct; +} +export declare class PlacedSymbolStruct extends Struct { + _structArray: PlacedSymbolArray; + get anchorX(): number; + get anchorY(): number; + get glyphStartIndex(): number; + get numGlyphs(): number; + get vertexStartIndex(): number; + get lineStartIndex(): number; + get lineLength(): number; + get segment(): number; + get lowerSize(): number; + get upperSize(): number; + get lineOffsetX(): number; + get lineOffsetY(): number; + get writingMode(): number; + get placedOrientation(): number; + set placedOrientation(x: number); + get hidden(): number; + set hidden(x: number); + get crossTileID(): number; + set crossTileID(x: number); + get associatedIconIndex(): number; +} +export declare class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 { + /** + * Return the PlacedSymbolStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): PlacedSymbolStruct; +} +export declare class SymbolInstanceStruct extends Struct { + _structArray: SymbolInstanceArray; + get anchorX(): number; + get anchorY(): number; + get rightJustifiedTextSymbolIndex(): number; + get centerJustifiedTextSymbolIndex(): number; + get leftJustifiedTextSymbolIndex(): number; + get verticalPlacedTextSymbolIndex(): number; + get placedIconSymbolIndex(): number; + get verticalPlacedIconSymbolIndex(): number; + get key(): number; + get textBoxStartIndex(): number; + get textBoxEndIndex(): number; + get verticalTextBoxStartIndex(): number; + get verticalTextBoxEndIndex(): number; + get iconBoxStartIndex(): number; + get iconBoxEndIndex(): number; + get verticalIconBoxStartIndex(): number; + get verticalIconBoxEndIndex(): number; + get featureIndex(): number; + get numHorizontalGlyphVertices(): number; + get numVerticalGlyphVertices(): number; + get numIconVertices(): number; + get numVerticalIconVertices(): number; + get useRuntimeCollisionCircles(): number; + get crossTileID(): number; + set crossTileID(x: number); + get textBoxScale(): number; + get collisionCircleDiameter(): number; + get textAnchorOffsetStartIndex(): number; + get textAnchorOffsetEndIndex(): number; +} +export type SymbolInstance = SymbolInstanceStruct; +export declare class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 { + /** + * Return the SymbolInstanceStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): SymbolInstanceStruct; +} +export declare class GlyphOffsetArray extends StructArrayLayout1f4 { + getoffsetX(index: number): number; +} +export declare class SymbolLineVertexArray extends StructArrayLayout3i6 { + getx(index: number): number; + gety(index: number): number; + gettileUnitDistanceFromAnchor(index: number): number; +} +export declare class TextAnchorOffsetStruct extends Struct { + _structArray: TextAnchorOffsetArray; + get textAnchor(): number; + get textOffset0(): number; + get textOffset1(): number; +} +export type TextAnchorOffset = TextAnchorOffsetStruct; +export declare class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 { + /** + * Return the TextAnchorOffsetStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): TextAnchorOffsetStruct; +} +export declare class FeatureIndexStruct extends Struct { + _structArray: FeatureIndexArray; + get featureIndex(): number; + get sourceLayerIndex(): number; + get bucketIndex(): number; +} +export declare class FeatureIndexArray extends StructArrayLayout1ul2ui8 { + /** + * Return the FeatureIndexStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): FeatureIndexStruct; +} +export declare class PosArray extends StructArrayLayout2i4 { +} +export declare class RasterBoundsArray extends StructArrayLayout4i8 { +} +export declare class CircleLayoutArray extends StructArrayLayout2i4 { +} +export declare class FillLayoutArray extends StructArrayLayout2i4 { +} +export declare class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 { +} +export declare class LineLayoutArray extends StructArrayLayout2i4ub8 { +} +export declare class LineExtLayoutArray extends StructArrayLayout2f8 { +} +export declare class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 { +} +export declare class SymbolDynamicLayoutArray extends StructArrayLayout3f12 { +} +export declare class SymbolOpacityArray extends StructArrayLayout1ul4 { +} +export declare class CollisionVertexArray extends StructArrayLayout2ub2f12 { +} +export declare class TriangleIndexArray extends StructArrayLayout3ui6 { +} +export declare class LineIndexArray extends StructArrayLayout2ui4 { +} +export declare class LineStripIndexArray extends StructArrayLayout1ui2 { +} +export type SerializedFeaturePositionMap = { + ids: Float64Array; + positions: Uint32Array; +}; +export type FeaturePosition = { + index: number; + start: number; + end: number; +}; +export declare class FeaturePositionMap { + ids: Array; + positions: Array; + indexed: boolean; + constructor(); + add(id: unknown, index: number, start: number, end: number): void; + getPositions(id: unknown): Array; + static serialize(map: FeaturePositionMap, transferables: Array): SerializedFeaturePositionMap; + static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap; +} +export declare class IndexBuffer { + context: Context; + buffer: WebGLBuffer; + dynamicDraw: boolean; + constructor(context: Context, array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean); + bind(): void; + updateData(array: StructArray): void; + destroy(): void; +} +export declare class VertexBuffer { + length: number; + attributes: ReadonlyArray; + itemSize: number; + dynamicDraw: boolean; + context: Context; + buffer: WebGLBuffer; + /** + * @param dynamicDraw - Whether this buffer will be repeatedly updated. + */ + constructor(context: Context, array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean); + bind(): void; + updateData(array: StructArray): void; + enableAttributes(gl: WebGLRenderingContext | WebGL2RenderingContext, program: Program): void; + /** + * Set the attribute pointers in a WebGL context + * @param gl - The WebGL context + * @param program - The active WebGL program + * @param vertexOffset - Index of the starting vertex of the segment + */ + setVertexAttribPointers(gl: WebGLRenderingContext | WebGL2RenderingContext, program: Program, vertexOffset?: number | null): void; + /** + * Destroy the GL buffer bound to the given WebGL context + */ + destroy(): void; +} +export type BlendFuncConstant = WebGLRenderingContextBase["ZERO"] | WebGLRenderingContextBase["ONE"] | WebGLRenderingContextBase["SRC_COLOR"] | WebGLRenderingContextBase["ONE_MINUS_SRC_COLOR"] | WebGLRenderingContextBase["DST_COLOR"] | WebGLRenderingContextBase["ONE_MINUS_DST_COLOR"] | WebGLRenderingContextBase["SRC_ALPHA"] | WebGLRenderingContextBase["ONE_MINUS_SRC_ALPHA"] | WebGLRenderingContextBase["DST_ALPHA"] | WebGLRenderingContextBase["ONE_MINUS_DST_ALPHA"] | WebGLRenderingContextBase["CONSTANT_COLOR"] | WebGLRenderingContextBase["ONE_MINUS_CONSTANT_COLOR"] | WebGLRenderingContextBase["CONSTANT_ALPHA"] | WebGLRenderingContextBase["ONE_MINUS_CONSTANT_ALPHA"] | WebGLRenderingContextBase["BLEND_COLOR"]; +export type BlendFuncType = [ + BlendFuncConstant, + BlendFuncConstant +]; +export type BlendEquationType = WebGLRenderingContextBase["FUNC_ADD"] | WebGLRenderingContextBase["FUNC_SUBTRACT"] | WebGLRenderingContextBase["FUNC_REVERSE_SUBTRACT"]; +export type ColorMaskType = [ + boolean, + boolean, + boolean, + boolean +]; +export type CompareFuncType = WebGLRenderingContextBase["NEVER"] | WebGLRenderingContextBase["LESS"] | WebGLRenderingContextBase["EQUAL"] | WebGLRenderingContextBase["LEQUAL"] | WebGLRenderingContextBase["GREATER"] | WebGLRenderingContextBase["NOTEQUAL"] | WebGLRenderingContextBase["GEQUAL"] | WebGLRenderingContextBase["ALWAYS"]; +export type DepthMaskType = boolean; +export type DepthRangeType = [ + number, + number +]; +export type DepthFuncType = CompareFuncType; +export type StencilFuncType = { + func: CompareFuncType; + ref: number; + mask: number; +}; +export type StencilOpConstant = WebGLRenderingContextBase["KEEP"] | WebGLRenderingContextBase["ZERO"] | WebGLRenderingContextBase["REPLACE"] | WebGLRenderingContextBase["INCR"] | WebGLRenderingContextBase["INCR_WRAP"] | WebGLRenderingContextBase["DECR"] | WebGLRenderingContextBase["DECR_WRAP"] | WebGLRenderingContextBase["INVERT"]; +export type StencilOpType = [ + StencilOpConstant, + StencilOpConstant, + StencilOpConstant +]; +export type TextureUnitType = number; +export type ViewportType = [ + number, + number, + number, + number +]; +export type StencilTestGL = { + func: WebGLRenderingContextBase["NEVER"]; + mask: 0; +} | { + func: WebGLRenderingContextBase["LESS"]; + mask: number; +} | { + func: WebGLRenderingContextBase["EQUAL"]; + mask: number; +} | { + func: WebGLRenderingContextBase["LEQUAL"]; + mask: number; +} | { + func: WebGLRenderingContextBase["GREATER"]; + mask: number; +} | { + func: WebGLRenderingContextBase["NOTEQUAL"]; + mask: number; +} | { + func: WebGLRenderingContextBase["GEQUAL"]; + mask: number; +} | { + func: WebGLRenderingContextBase["ALWAYS"]; + mask: 0; +}; +export type CullFaceModeType = WebGLRenderingContextBase["FRONT"] | WebGLRenderingContextBase["BACK"] | WebGLRenderingContextBase["FRONT_AND_BACK"]; +export type FrontFaceType = WebGLRenderingContextBase["CW"] | WebGLRenderingContextBase["CCW"]; +export interface IValue { + current: T; + default: T; + dirty: boolean; + get(): T; + setDefault(): void; + set(value: T): void; +} +export declare class BaseValue implements IValue { + gl: WebGLRenderingContext | WebGL2RenderingContext; + current: T; + default: T; + dirty: boolean; + constructor(context: Context); + get(): T; + set(value: T): void; + getDefault(): T; + setDefault(): void; +} +export declare class ClearColor extends BaseValue { + getDefault(): Color; + set(v: Color): void; +} +export declare class ClearDepth extends BaseValue { + getDefault(): number; + set(v: number): void; +} +export declare class ClearStencil extends BaseValue { + getDefault(): number; + set(v: number): void; +} +export declare class ColorMask extends BaseValue { + getDefault(): ColorMaskType; + set(v: ColorMaskType): void; +} +export declare class DepthMask extends BaseValue { + getDefault(): DepthMaskType; + set(v: DepthMaskType): void; +} +export declare class StencilMask extends BaseValue { + getDefault(): number; + set(v: number): void; +} +export declare class StencilFunc extends BaseValue { + getDefault(): StencilFuncType; + set(v: StencilFuncType): void; +} +export declare class StencilOp extends BaseValue { + getDefault(): StencilOpType; + set(v: StencilOpType): void; +} +export declare class StencilTest extends BaseValue { + getDefault(): boolean; + set(v: boolean): void; +} +export declare class DepthRange extends BaseValue { + getDefault(): DepthRangeType; + set(v: DepthRangeType): void; +} +export declare class DepthTest extends BaseValue { + getDefault(): boolean; + set(v: boolean): void; +} +export declare class DepthFunc extends BaseValue { + getDefault(): DepthFuncType; + set(v: DepthFuncType): void; +} +export declare class Blend extends BaseValue { + getDefault(): boolean; + set(v: boolean): void; +} +export declare class BlendFunc extends BaseValue { + getDefault(): BlendFuncType; + set(v: BlendFuncType): void; +} +export declare class BlendColor extends BaseValue { + getDefault(): Color; + set(v: Color): void; +} +export declare class BlendEquation extends BaseValue { + getDefault(): BlendEquationType; + set(v: BlendEquationType): void; +} +export declare class CullFace extends BaseValue { + getDefault(): boolean; + set(v: boolean): void; +} +export declare class CullFaceSide extends BaseValue { + getDefault(): CullFaceModeType; + set(v: CullFaceModeType): void; +} +export declare class FrontFace extends BaseValue { + getDefault(): FrontFaceType; + set(v: FrontFaceType): void; +} +export declare class ProgramValue extends BaseValue { + getDefault(): WebGLProgram; + set(v?: WebGLProgram | null): void; +} +export declare class ActiveTextureUnit extends BaseValue { + getDefault(): TextureUnitType; + set(v: TextureUnitType): void; +} +export declare class Viewport extends BaseValue { + getDefault(): ViewportType; + set(v: ViewportType): void; +} +export declare class BindFramebuffer extends BaseValue { + getDefault(): WebGLFramebuffer; + set(v?: WebGLFramebuffer | null): void; +} +export declare class BindRenderbuffer extends BaseValue { + getDefault(): WebGLRenderbuffer; + set(v?: WebGLRenderbuffer | null): void; +} +export declare class BindTexture extends BaseValue { + getDefault(): WebGLTexture; + set(v?: WebGLTexture | null): void; +} +export declare class BindVertexBuffer extends BaseValue { + getDefault(): WebGLBuffer; + set(v?: WebGLBuffer | null): void; +} +export declare class BindElementBuffer extends BaseValue { + getDefault(): WebGLBuffer; + set(v?: WebGLBuffer | null): void; +} +export declare class BindVertexArray extends BaseValue { + getDefault(): WebGLVertexArrayObject | null; + set(v: WebGLVertexArrayObject | null): void; +} +export declare class PixelStoreUnpack extends BaseValue { + getDefault(): number; + set(v: number): void; +} +export declare class PixelStoreUnpackPremultiplyAlpha extends BaseValue { + getDefault(): boolean; + set(v: boolean): void; +} +export declare class PixelStoreUnpackFlipY extends BaseValue { + getDefault(): boolean; + set(v: boolean): void; +} +export declare class FramebufferAttachment extends BaseValue { + parent: WebGLFramebuffer; + context: Context; + constructor(context: Context, parent: WebGLFramebuffer); + getDefault(): any; +} +export declare class ColorAttachment extends FramebufferAttachment { + setDirty(): void; + set(v?: WebGLTexture | null): void; +} +export declare class DepthAttachment extends FramebufferAttachment { + set(v?: WebGLRenderbuffer | null): void; +} +export declare class Framebuffer { + context: Context; + width: number; + height: number; + framebuffer: WebGLFramebuffer; + colorAttachment: ColorAttachment; + depthAttachment: DepthAttachment; + constructor(context: Context, width: number, height: number, hasDepth: boolean, hasStencil: boolean); + destroy(): void; +} +export declare class DepthMode { + func: DepthFuncType; + mask: DepthMaskType; + range: DepthRangeType; + static ReadOnly: boolean; + static ReadWrite: boolean; + constructor(depthFunc: DepthFuncType, depthMask: DepthMaskType, depthRange: DepthRangeType); + static disabled: Readonly; +} +export declare class StencilMode { + test: StencilTestGL; + ref: number; + mask: number; + fail: StencilOpConstant; + depthFail: StencilOpConstant; + pass: StencilOpConstant; + constructor(test: StencilTestGL, ref: number, mask: number, fail: StencilOpConstant, depthFail: StencilOpConstant, pass: StencilOpConstant); + static disabled: Readonly; +} +export declare class ColorMode { + blendFunction: BlendFuncType; + blendColor: Color; + mask: ColorMaskType; + constructor(blendFunction: BlendFuncType, blendColor: Color, mask: ColorMaskType); + static Replace: BlendFuncType; + static disabled: Readonly; + static unblended: Readonly; + static alphaBlended: Readonly; +} +export declare class CullFaceMode { + enable: boolean; + mode: CullFaceModeType; + frontFace: FrontFaceType; + constructor(enable: boolean, mode: CullFaceModeType, frontFace: FrontFaceType); + static disabled: Readonly; + static backCCW: Readonly; +} +export type ClearArgs = { + color?: Color; + depth?: number; + stencil?: number; +}; +export declare class Context { + gl: WebGLRenderingContext | WebGL2RenderingContext; + currentNumAttributes: number; + maxTextureSize: number; + clearColor: ClearColor; + clearDepth: ClearDepth; + clearStencil: ClearStencil; + colorMask: ColorMask; + depthMask: DepthMask; + stencilMask: StencilMask; + stencilFunc: StencilFunc; + stencilOp: StencilOp; + stencilTest: StencilTest; + depthRange: DepthRange; + depthTest: DepthTest; + depthFunc: DepthFunc; + blend: Blend; + blendFunc: BlendFunc; + blendColor: BlendColor; + blendEquation: BlendEquation; + cullFace: CullFace; + cullFaceSide: CullFaceSide; + frontFace: FrontFace; + program: ProgramValue; + activeTexture: ActiveTextureUnit; + viewport: Viewport; + bindFramebuffer: BindFramebuffer; + bindRenderbuffer: BindRenderbuffer; + bindTexture: BindTexture; + bindVertexBuffer: BindVertexBuffer; + bindElementBuffer: BindElementBuffer; + bindVertexArray: BindVertexArray; + pixelStoreUnpack: PixelStoreUnpack; + pixelStoreUnpackPremultiplyAlpha: PixelStoreUnpackPremultiplyAlpha; + pixelStoreUnpackFlipY: PixelStoreUnpackFlipY; + extTextureFilterAnisotropic: EXT_texture_filter_anisotropic | null; + extTextureFilterAnisotropicMax?: GLfloat; + HALF_FLOAT?: GLenum; + RGBA16F?: GLenum; + RGB16F?: GLenum; + constructor(gl: WebGLRenderingContext | WebGL2RenderingContext); + setDefault(): void; + setDirty(): void; + createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean): IndexBuffer; + createVertexBuffer(array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean): VertexBuffer; + createRenderbuffer(storageFormat: number, width: number, height: number): WebGLRenderbuffer; + createFramebuffer(width: number, height: number, hasDepth: boolean, hasStencil: boolean): Framebuffer; + clear({ color, depth, stencil }: ClearArgs): void; + setCullFace(cullFaceMode: Readonly): void; + setDepthMode(depthMode: Readonly): void; + setStencilMode(stencilMode: Readonly): void; + setColorMode(colorMode: Readonly): void; + createVertexArray(): WebGLVertexArrayObject | undefined; + deleteVertexArray(x: WebGLVertexArrayObject | undefined): void; + unbindVAO(): void; +} +export type $ObjMap any> = { + [K in keyof T]: F extends (v: T[K]) => infer R ? R : never; +}; +export type UniformValues = $ObjMap(u: Uniform) => V>; +export type UniformLocations = { + [_: string]: WebGLUniformLocation; +}; +declare abstract class Uniform { + gl: WebGLRenderingContext | WebGL2RenderingContext; + location: WebGLUniformLocation; + current: T; + constructor(context: Context, location: WebGLUniformLocation); + abstract set(v: T): void; +} +export declare class Uniform1i extends Uniform { + constructor(context: Context, location: WebGLUniformLocation); + set(v: number): void; +} +export declare class Uniform1f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation); + set(v: number): void; +} +export declare class Uniform4f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation); + set(v: vec4): void; +} +export declare class UniformMatrix4f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation); + set(v: mat4): void; +} +/** + * @internal + * A uniform bindings + */ +export type UniformBindings = { + [_: string]: Uniform; +}; +export type Size = { + width: number; + height: number; +}; +export type Point2D = { + x: number; + y: number; +}; +export declare class AlphaImage { + width: number; + height: number; + data: Uint8Array; + constructor(size: Size, data?: Uint8Array | Uint8ClampedArray); + resize(size: Size): void; + clone(): AlphaImage; + static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size): void; +} +export declare class RGBAImage { + width: number; + height: number; + /** + * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers. + */ + data: Uint8Array; + constructor(size: Size, data?: Uint8Array | Uint8ClampedArray); + resize(size: Size): void; + replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean): void; + clone(): RGBAImage; + static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size): void; +} +/** + * The sprite data + */ +export type SpriteOnDemandStyleImage = { + width: number; + height: number; + x: number; + y: number; + context: CanvasRenderingContext2D; +}; +/** + * The style's image metadata + */ +export type StyleImageData = { + data: RGBAImage; + version?: number; + hasRenderCallback?: boolean; + userImage?: StyleImageInterface; + spriteData?: SpriteOnDemandStyleImage; +}; +/** + * The style's image metadata + */ +export type StyleImageMetadata = { + /** + * The ratio of pixels in the image to physical pixels on the screen + */ + pixelRatio: number; + /** + * Whether the image should be interpreted as an SDF image + */ + sdf: boolean; + /** + * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally. + */ + stretchX?: Array<[ + number, + number + ]>; + /** + * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically. + */ + stretchY?: Array<[ + number, + number + ]>; + /** + * If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`. + */ + content?: [ + number, + number, + number, + number + ]; +}; +/** + * the style's image, including data and metedata + */ +export type StyleImage = StyleImageData & StyleImageMetadata; +/** + * Interface for dynamically generated style images. This is a specification for + * implementers to model: it is not an exported method or class. + * + * Images implementing this interface can be redrawn for every frame. They can be used to animate + * icons and patterns or make them respond to user input. Style images can implement a + * {@link StyleImageInterface#render} method. The method is called every frame and + * can be used to update the image. + * + * @see [Add an animated icon to the map.](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/) + * + * @example + * ```ts + * let flashingSquare = { + * width: 64, + * height: 64, + * data: new Uint8Array(64 * 64 * 4), + * + * onAdd: function(map) { + * this.map = map; + * }, + * + * render: function() { + * // keep repainting while the icon is on the map + * this.map.triggerRepaint(); + * + * // alternate between black and white based on the time + * let value = Math.round(Date.now() / 1000) % 2 === 0 ? 255 : 0; + * + * // check if image needs to be changed + * if (value !== this.previousValue) { + * this.previousValue = value; + * + * let bytesPerPixel = 4; + * for (let x = 0; x < this.width; x++) { + * for (let y = 0; y < this.height; y++) { + * let offset = (y * this.width + x) * bytesPerPixel; + * this.data[offset + 0] = value; + * this.data[offset + 1] = value; + * this.data[offset + 2] = value; + * this.data[offset + 3] = 255; + * } + * } + * + * // return true to indicate that the image changed + * return true; + * } + * } + * } + * + * map.addImage('flashing_square', flashingSquare); + * ``` + */ +export interface StyleImageInterface { + width: number; + height: number; + data: Uint8Array | Uint8ClampedArray; + /** + * This method is called once before every frame where the icon will be used. + * The method can optionally update the image's `data` member with a new image. + * + * If the method updates the image it must return `true` to commit the change. + * If the method returns `false` or nothing the image is assumed to not have changed. + * + * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update + * the image instead of implementing this method. + * + * @returns `true` if this method updated the image. `false` if the image was not changed. + */ + render?: () => boolean; + /** + * Optional method called when the layer has been added to the Map with {@link Map#addImage}. + * + * @param map - The Map this custom layer was just added to. + */ + onAdd?: (map: Map, id: string) => void; + /** + * Optional method called when the icon is removed from the map with {@link Map#removeImage}. + * This gives the image a chance to clean up resources and event listeners. + */ + onRemove?: () => void; +} +export type TextureFormat = WebGLRenderingContextBase["RGBA"] | WebGLRenderingContextBase["ALPHA"]; +export type TextureFilter = WebGLRenderingContextBase["LINEAR"] | WebGLRenderingContextBase["LINEAR_MIPMAP_NEAREST"] | WebGLRenderingContextBase["NEAREST"]; +export type TextureWrap = WebGLRenderingContextBase["REPEAT"] | WebGLRenderingContextBase["CLAMP_TO_EDGE"] | WebGLRenderingContextBase["MIRRORED_REPEAT"]; +export type EmptyImage = { + width: number; + height: number; + data: null; +}; +export type DataTextureImage = RGBAImage | AlphaImage | EmptyImage; +export type TextureImage = TexImageSource | DataTextureImage; +export declare class Texture { + context: Context; + size: [ + number, + number + ]; + texture: WebGLTexture; + format: TextureFormat; + filter: TextureFilter; + wrap: TextureWrap; + useMipmap: boolean; + constructor(context: Context, image: TextureImage, format: TextureFormat, options?: { + premultiply?: boolean; + useMipmap?: boolean; + } | null); + update(image: TextureImage, options?: { + premultiply?: boolean; + useMipmap?: boolean; + } | null, position?: { + x: number; + y: number; + }): void; + bind(filter: TextureFilter, wrap: TextureWrap, minFilter?: TextureFilter | null): void; + isSizePowerOfTwo(): boolean; + destroy(): void; +} +export type Pattern = { + bin: PotpackBox; + position: ImagePosition; +}; +export declare class ImageManager extends Evented { + images: { + [_: string]: StyleImage; + }; + updatedImages: { + [_: string]: boolean; + }; + callbackDispatchedThisFrame: { + [_: string]: boolean; + }; + loaded: boolean; + requestors: Array<{ + ids: Array; + callback: Callback<{ + [_: string]: StyleImage; + }>; + }>; + patterns: { + [_: string]: Pattern; + }; + atlasImage: RGBAImage; + atlasTexture: Texture; + dirty: boolean; + constructor(); + isLoaded(): boolean; + setLoaded(loaded: boolean): void; + getImage(id: string): StyleImage; + addImage(id: string, image: StyleImage): void; + _validate(id: string, image: StyleImage): boolean; + _validateStretch(stretch: Array<[ + number, + number + ]>, size: number): boolean; + _validateContent(content: [ + number, + number, + number, + number + ], image: StyleImage): boolean; + updateImage(id: string, image: StyleImage, validate?: boolean): void; + removeImage(id: string): void; + listImages(): Array; + getImages(ids: Array, callback: Callback<{ + [_: string]: StyleImage; + }>): void; + _notify(ids: Array, callback: Callback<{ + [_: string]: StyleImage; + }>): void; + getPixelSize(): { + width: number; + height: number; + }; + getPattern(id: string): ImagePosition; + bind(context: Context): void; + _updatePatternAtlas(): void; + beginFrame(): void; + dispatchRenderCallbacks(ids: Array): void; +} +export type GlyphMetrics = { + width: number; + height: number; + left: number; + top: number; + advance: number; + /** + * isDoubleResolution = true for 48px textures + */ + isDoubleResolution?: boolean; +}; +/** + * @internal + * A style glyph type + */ +export type StyleGlyph = { + id: number; + bitmap: AlphaImage; + metrics: GlyphMetrics; +}; +/** + * A rectangle type with postion, width and height. + */ +export type Rect = { + x: number; + y: number; + w: number; + h: number; +}; +/** + * The glyph's position + */ +export type GlyphPosition = { + rect: Rect; + metrics: GlyphMetrics; +}; +/** + * The glyphs' positions + */ +export type GlyphPositions = { + [_: string]: { + [_: number]: GlyphPosition; + }; +}; +export declare class ImagePosition { + paddedRect: Rect; + pixelRatio: number; + version: number; + stretchY: Array<[ + number, + number + ]>; + stretchX: Array<[ + number, + number + ]>; + content: [ + number, + number, + number, + number + ]; + constructor(paddedRect: Rect, { pixelRatio, version, stretchX, stretchY, content }: StyleImage); + get tl(): [ + number, + number + ]; + get br(): [ + number, + number + ]; + get tlbr(): Array; + get displaySize(): [ + number, + number + ]; +} +export declare class ImageAtlas { + image: RGBAImage; + iconPositions: { + [_: string]: ImagePosition; + }; + patternPositions: { + [_: string]: ImagePosition; + }; + haveRenderCallbacks: Array; + uploaded: boolean; + constructor(icons: { + [_: string]: StyleImage; + }, patterns: { + [_: string]: StyleImage; + }); + addImages(images: { + [_: string]: StyleImage; + }, positions: { + [_: string]: ImagePosition; + }, bins: Array): void; + patchUpdatedImages(imageManager: ImageManager, texture: Texture): void; + patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture): void; +} +export type SerializedGrid = { + buffer: ArrayBuffer; +}; +export declare class TransferableGridIndex { + cells: number[][]; + arrayBuffer: ArrayBuffer; + d: number; + keys: number[]; + bboxes: number[]; + n: number; + extent: number; + padding: number; + scale: any; + uid: number; + min: number; + max: number; + constructor(extent: number | ArrayBuffer, n?: number, padding?: number); + insert(key: number, x1: number, y1: number, x2: number, y2: number): void; + _insertReadonly(): void; + _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number): void; + query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[]; + _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: any, seenUids: any, intersectionTest: Function): void; + _forEachCell(x1: number, y1: number, x2: number, y2: number, fn: Function, arg1: any, arg2: any, intersectionTest: any): void; + _convertFromCellCoord(x: any): number; + _convertToCellCoord(x: any): number; + toArrayBuffer(): ArrayBuffer; + static serialize(grid: TransferableGridIndex, transferables?: Array): SerializedGrid; + static deserialize(serialized: SerializedGrid): TransferableGridIndex; +} +export declare class DictionaryCoder { + _stringToNumber: { + [_: string]: number; + }; + _numberToString: Array; + constructor(strings: Array); + encode(string: string): number; + decode(n: number): string; +} +/** + * A helper for type to omit a property from a type + */ +export type DistributiveKeys = T extends T ? keyof T : never; +/** + * A helper for type to omit a property from a type + */ +export type DistributiveOmit> = T extends unknown ? Omit : never; +/** + * An extended geojson feature used by the events to return data to the listener + */ +export type MapGeoJSONFeature = GeoJSONFeature & { + layer: DistributiveOmit & { + source: string; + }; + source: string; + sourceLayer?: string; + state: { + [key: string]: any; + }; +}; +export declare class GeoJSONFeature { + type: "Feature"; + _geometry: GeoJSON.Geometry; + properties: { + [name: string]: any; + }; + id: number | string | undefined; + _vectorTileFeature: VectorTileFeature; + constructor(vectorTileFeature: VectorTileFeature, z: number, x: number, y: number, id: string | number | undefined); + get geometry(): GeoJSON.Geometry; + set geometry(g: GeoJSON.Geometry); + toJSON(): any; +} +/** + * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order, + * or an array of numbers in [west, south, east, north] order. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let v1 = new maplibregl.LngLatBounds( + * new maplibregl.LngLat(-73.9876, 40.7661), + * new maplibregl.LngLat(-73.9397, 40.8002) + * ); + * let v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]) + * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; + * ``` + */ +export type LngLatBoundsLike = LngLatBounds | [ + LngLatLike, + LngLatLike +] | [ + number, + number, + number, + number +]; +export declare class LngLatBounds { + _ne: LngLat; + _sw: LngLat; + /** + * @param sw - The southwest corner of the bounding box. + * OR array of 4 numbers in the order of west, south, east, north + * OR array of 2 LngLatLike: [sw,ne] + * @param ne - The northeast corner of the bounding box. + * @example + * ```ts + * let sw = new maplibregl.LngLat(-73.9876, 40.7661); + * let ne = new maplibregl.LngLat(-73.9397, 40.8002); + * let llb = new maplibregl.LngLatBounds(sw, ne); + * ``` + * OR + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]); + * ``` + * OR + * ```ts + * let llb = new maplibregl.LngLatBounds([sw, ne]); + * ``` + */ + constructor(sw?: LngLatLike | [ + number, + number, + number, + number + ] | [ + LngLatLike, + LngLatLike + ], ne?: LngLatLike); + /** + * Set the northeast corner of the bounding box + * + * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box. + * @returns `this` + */ + setNorthEast(ne: LngLatLike): this; + /** + * Set the southwest corner of the bounding box + * + * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box. + * @returns `this` + */ + setSouthWest(sw: LngLatLike): this; + /** + * Extend the bounds to include a given LngLatLike or LngLatBoundsLike. + * + * @param obj - object to extend to + * @returns `this` + */ + extend(obj: LngLatLike | LngLatBoundsLike): this; + /** + * Returns the geographical coordinate equidistant from the bounding box's corners. + * + * @returns The bounding box's center. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315} + * ``` + */ + getCenter(): LngLat; + /** + * Returns the southwest corner of the bounding box. + * + * @returns The southwest corner of the bounding box. + */ + getSouthWest(): LngLat; + /** + * Returns the northeast corner of the bounding box. + * + * @returns The northeast corner of the bounding box. + */ + getNorthEast(): LngLat; + /** + * Returns the northwest corner of the bounding box. + * + * @returns The northwest corner of the bounding box. + */ + getNorthWest(): LngLat; + /** + * Returns the southeast corner of the bounding box. + * + * @returns The southeast corner of the bounding box. + */ + getSouthEast(): LngLat; + /** + * Returns the west edge of the bounding box. + * + * @returns The west edge of the bounding box. + */ + getWest(): number; + /** + * Returns the south edge of the bounding box. + * + * @returns The south edge of the bounding box. + */ + getSouth(): number; + /** + * Returns the east edge of the bounding box. + * + * @returns The east edge of the bounding box. + */ + getEast(): number; + /** + * Returns the north edge of the bounding box. + * + * @returns The north edge of the bounding box. + */ + getNorth(): number; + /** + * Returns the bounding box represented as an array. + * + * @returns The bounding box represented as an array, consisting of the + * southwest and northeast coordinates of the bounding represented as arrays of numbers. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]] + * ``` + */ + toArray(): [ + number, + number + ][]; + /** + * Return the bounding box represented as a string. + * + * @returns The bounding box represents as a string of the format + * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))" + * ``` + */ + toString(): string; + /** + * Check if the bounding box is an empty/`null`-type box. + * + * @returns True if bounds have been defined, otherwise false. + */ + isEmpty(): boolean; + /** + * Check if the point is within the bounding box. + * + * @param lnglat - geographic point to check against. + * @returns `true` if the point is within the bounding box. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds( + * new maplibregl.LngLat(-73.9876, 40.7661), + * new maplibregl.LngLat(-73.9397, 40.8002) + * ); + * + * let ll = new maplibregl.LngLat(-73.9567, 40.7789); + * + * console.log(llb.contains(ll)); // = true + * ``` + */ + contains(lnglat: LngLatLike): boolean; + /** + * Converts an array to a `LngLatBounds` object. + * + * If a `LngLatBounds` object is passed in, the function returns it unchanged. + * + * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values. + * + * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return. + * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object. + * @example + * ```ts + * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; + * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}} + * ``` + */ + static convert(input: LngLatBoundsLike | null): LngLatBounds; + /** + * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`. + * + * @param center - center coordinates of the new bounds. + * @param radius - Distance in meters from the coordinates to extend the bounds. + * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`. + * @example + * ```ts + * let center = new maplibregl.LngLat(-73.9749, 40.7736); + * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]] + * ``` + */ + static fromLngLat(center: LngLat, radius?: number): LngLatBounds; +} +export declare class EdgeInsets { + /** + * @defaultValue 0 + */ + top: number; + /** + * @defaultValue 0 + */ + bottom: number; + /** + * @defaultValue 0 + */ + left: number; + /** + * @defaultValue 0 + */ + right: number; + constructor(top?: number, bottom?: number, left?: number, right?: number); + /** + * Interpolates the inset in-place. + * This maintains the current inset value for any inset not present in `target`. + * @param start - interpolation start + * @param target - interpolation target + * @param t - interpolation step/weight + * @returns the insets + */ + interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets; + /** + * Utility method that computes the new apprent center or vanishing point after applying insets. + * This is in pixels and with the top left being (0.0) and +y being downwards. + * + * @param width - the width + * @param height - the height + * @returns the point + */ + getCenter(width: number, height: number): Point; + equals(other: PaddingOptions): boolean; + clone(): EdgeInsets; + /** + * Returns the current state as json, useful when you want to have a + * read-only representation of the inset. + * + * @returns state as json + */ + toJSON(): PaddingOptions; +} +/** + * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be + * non-negative integers. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: 20 + * }); + * ``` + * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/) + * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/) + */ +export type PaddingOptions = { + /** + * Padding in pixels from the top of the map canvas. + */ + top: number; + /** + * Padding in pixels from the bottom of the map canvas. + */ + bottom: number; + /** + * Padding in pixels from the left of the map canvas. + */ + right: number; + /** + * Padding in pixels from the right of the map canvas. + */ + left: number; +}; +export declare class TileCache { + max: number; + data: { + [key: string]: Array<{ + value: Tile; + timeout: ReturnType; + }>; + }; + order: Array; + onRemove: (element: Tile) => void; + /** + * @param max - number of permitted values + * @param onRemove - callback called with items when they expire + */ + constructor(max: number, onRemove: (element: Tile) => void); + /** + * Clear the cache + * + * @returns this cache + */ + reset(): this; + /** + * Add a key, value combination to the cache, trimming its size if this pushes + * it over max length. + * + * @param tileID - lookup key for the item + * @param data - tile data + * + * @returns this cache + */ + add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void): this; + /** + * Determine whether the value attached to `key` is present + * + * @param tileID - the key to be looked-up + * @returns whether the cache has this value + */ + has(tileID: OverscaledTileID): boolean; + /** + * Get the value attached to a specific key and remove data from cache. + * If the key is not found, returns `null` + * + * @param tileID - the key to look up + * @returns the tile data, or null if it isn't found + */ + getAndRemove(tileID: OverscaledTileID): Tile; + _getAndRemoveByKey(key: string): Tile; + getByKey(key: string): Tile; + /** + * Get the value attached to a specific key without removing data + * from the cache. If the key is not found, returns `null` + * + * @param tileID - the key to look up + * @returns the tile data, or null if it isn't found + */ + get(tileID: OverscaledTileID): Tile; + /** + * Remove a key/value combination from the cache. + * + * @param tileID - the key for the pair to delete + * @param value - If a value is provided, remove that exact version of the value. + * @returns this cache + */ + remove(tileID: OverscaledTileID, value?: { + value: Tile; + timeout: ReturnType; + }): this; + /** + * Change the max size of the cache. + * + * @param max - the max size of the cache + * @returns this cache + */ + setMaxSize(max: number): TileCache; + /** + * Remove entries that do not pass a filter function. Used for removing + * stale tiles from the cache. + * + * @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out. + */ + filter(filterFn: (tile: Tile) => boolean): void; +} +export type SerializedObject = { + [_: string]: S; +}; +export type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array | SerializedObject; +export declare class ThrottledInvoker { + _channel: MessageChannel; + _triggered: boolean; + _callback: Function; + constructor(callback: Function); + trigger(): void; + remove(): void; +} +export type DEMEncoding = "mapbox" | "terrarium" | "custom"; +export declare class DEMData { + uid: string; + data: Uint32Array; + stride: number; + dim: number; + min: number; + max: number; + redFactor: number; + greenFactor: number; + blueFactor: number; + baseShift: number; + constructor(uid: string, data: RGBAImage, encoding: DEMEncoding, redFactor?: number, greenFactor?: number, blueFactor?: number, baseShift?: number); + get(x: number, y: number): number; + getUnpackVector(): number[]; + _idx(x: number, y: number): number; + unpack(r: number, g: number, b: number): number; + getPixels(): RGBAImage; + backfillBorder(borderTile: DEMData, dx: number, dy: number): void; +} +export type TileParameters = { + source: string; + uid: string; +}; +export type WorkerTileParameters = TileParameters & { + tileID: OverscaledTileID; + request: RequestParameters; + zoom: number; + maxZoom: number; + tileSize: number; + promoteId: PromoteIdSpecification; + pixelRatio: number; + showCollisionBoxes: boolean; + collectResourceTiming?: boolean; + returnDependencies?: boolean; +}; +/** + * @internal + * The worker tile's result type + */ +export type WorkerTileResult = { + buckets: Array; + imageAtlas: ImageAtlas; + glyphAtlasImage: AlphaImage; + featureIndex: FeatureIndex; + collisionBoxArray: CollisionBoxArray; + rawTileData?: ArrayBuffer; + resourceTiming?: Array; + glyphMap?: { + [_: string]: { + [_: number]: StyleGlyph; + }; + } | null; + iconMap?: { + [_: string]: StyleImage; + } | null; + glyphPositions?: GlyphPositions | null; +}; +export type WorkerTileCallback = (error?: Error | null, result?: WorkerTileResult | null) => void; +/** + * May be implemented by custom source types to provide code that can be run on + * the WebWorkers. In addition to providing a custom + * {@link WorkerSource#loadTile}, any other methods attached to a `WorkerSource` + * implementation may also be targeted by the {@link Source} via + * `dispatcher.getActor().send('source-type.methodname', params, callback)`. + * + * @see {@link Map#addSourceType} + */ +export interface WorkerSource { + availableImages: Array; + /** + * Loads a tile from the given params and parse it into buckets ready to send + * back to the main thread for rendering. Should call the callback with: + * `{ buckets, featureIndex, collisionIndex, rawTileData}`. + */ + loadTile(params: WorkerTileParameters, callback: WorkerTileCallback): void; + /** + * Re-parses a tile that has already been loaded. Yields the same data as + * {@link WorkerSource#loadTile}. + */ + reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback): void; + /** + * Aborts loading a tile that is in progress. + */ + abortTile(params: TileParameters, callback: WorkerTileCallback): void; + /** + * Removes this tile from any local caches. + */ + removeTile(params: TileParameters, callback: WorkerTileCallback): void; + /** + * Tells the WorkerSource to abort in-progress tasks and release resources. + * The foreground Source is responsible for ensuring that 'removeSource' is + * the last message sent to the WorkerSource. + */ + removeSource?: (params: { + source: string; + }, callback: WorkerTileCallback) => void; +} +export interface ActorTarget { + addEventListener: typeof window.addEventListener; + removeEventListener: typeof window.removeEventListener; + postMessage: typeof window.postMessage; + terminate?: () => void; +} +export interface WorkerSourceProvider { + getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource; +} +export interface GlyphsProvider { + getGlyphs(mapId: string, params: { + stacks: { + [_: string]: Array; + }; + source: string; + tileID: OverscaledTileID; + type: string; + }, callback: Callback<{ + [_: string]: { + [_: number]: StyleGlyph; + }; + }>): any; +} +export type MessageType = "" | "" | "geojson.getClusterExpansionZoom" | "geojson.getClusterChildren" | "geojson.getClusterLeaves" | "geojson.loadData" | "removeSource" | "loadWorkerSource" | "loadDEMTile" | "removeDEMTile" | "removeTile" | "reloadTile" | "abortTile" | "loadTile" | "getTile" | "getGlyphs" | "getImages" | "setImages" | "syncRTLPluginState" | "setReferrer" | "setLayers" | "updateLayers"; +export type MessageData = { + id: string; + type: MessageType; + data?: Serialized; + targetMapId?: string | number | null; + mustQueue?: boolean; + error?: Serialized | null; + hasCallback?: boolean; + sourceMapId: string | number | null; +}; +export type Message = { + data: MessageData; +}; +export declare class Actor { + target: ActorTarget; + parent: WorkerSourceProvider | GlyphsProvider; + mapId: string | number | null; + callbacks: { + [x: number]: Function; + }; + name: string; + tasks: { + [x: number]: MessageData; + }; + taskQueue: Array; + cancelCallbacks: { + [x: number]: () => void; + }; + invoker: ThrottledInvoker; + globalScope: ActorTarget; + /** + * @param target - The target + * @param parent - The parent + * @param mapId - A unique identifier for the Map instance using this Actor. + */ + constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number); + /** + * Sends a message from a main-thread map to a Worker or from a Worker back to + * a main-thread map instance. + * + * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource. + * @param targetMapId - A particular mapId to which to send this message. + */ + send(type: MessageType, data: unknown, callback?: Function | null, targetMapId?: string | null, mustQueue?: boolean): Cancelable; + receive: (message: Message) => void; + process: () => void; + processTask(id: string, task: MessageData): void; + remove(): void; +} +export declare class WorkerPool { + static workerCount: number; + active: { + [_ in number | string]: boolean; + }; + workers: Array; + constructor(); + acquire(mapId: number | string): Array; + release(mapId: number | string): void; + isPreloaded(): boolean; + numActive(): number; +} +export declare class Dispatcher { + workerPool: WorkerPool; + actors: Array; + currentActor: number; + id: string | number; + constructor(workerPool: WorkerPool, parent: GlyphsProvider, mapId: string | number); + /** + * Broadcast a message to all Workers. + */ + broadcast(type: MessageType, data: unknown, cb?: (...args: any[]) => any): void; + /** + * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion. + * @returns An actor object backed by a web worker for processing messages. + */ + getActor(): Actor; + remove(mapRemoved?: boolean): void; +} +/** + * Four geographical coordinates, + * represented as arrays of longitude and latitude numbers, which define the corners of the image. + * The coordinates start at the top left corner of the image and proceed in clockwise order. + * They do not have to represent a rectangle. + */ +export type Coordinates = [ + [ + number, + number + ], + [ + number, + number + ], + [ + number, + number + ], + [ + number, + number + ] +]; +/** + * The options object for the {@link ImageSource#updateImage} method + */ +export type UpdateImageOptions = { + /** + * Required image URL. + */ + url: string; + /** + * The image coordinates + */ + coordinates?: Coordinates; +}; +export declare class ImageSource extends Evented implements Source { + type: string; + id: string; + minzoom: number; + maxzoom: number; + tileSize: number; + url: string; + coordinates: Coordinates; + tiles: { + [_: string]: Tile; + }; + options: any; + dispatcher: Dispatcher; + map: Map; + texture: Texture | null; + image: HTMLImageElement | ImageBitmap; + tileID: CanonicalTileID; + _boundsArray: RasterBoundsArray; + boundsBuffer: VertexBuffer; + boundsSegments: SegmentVector; + _loaded: boolean; + _request: Cancelable; + /** @internal */ + constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented); + load: (newCoordinates?: Coordinates, successCallback?: () => void) => void; + loaded(): boolean; + /** + * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing, + * set the `raster-fade-duration` paint property on the raster layer to 0. + * + * @param options - The options object. + * @returns `this` + */ + updateImage(options: UpdateImageOptions): this; + _finishLoading(): void; + onAdd(map: Map): void; + onRemove(): void; + /** + * Sets the image's coordinates and re-renders the map. + * + * @param coordinates - Four geographical coordinates, + * represented as arrays of longitude and latitude numbers, which define the corners of the image. + * The coordinates start at the top left corner of the image and proceed in clockwise order. + * They do not have to represent a rectangle. + * @returns `this` + */ + setCoordinates(coordinates: Coordinates): this; + prepare: () => void; + loadTile(tile: Tile, callback: Callback): void; + serialize: () => ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification; + hasTransition(): boolean; +} +/** + * Options to add a canvas source type to the map. + */ +export type CanvasSourceSpecification = { + /** + * Source type. Must be `"canvas"`. + */ + type: "canvas"; + /** + * Four geographical coordinates denoting where to place the corners of the canvas, specified in `[longitude, latitude]` pairs. + */ + coordinates: [ + [ + number, + number + ], + [ + number, + number + ], + [ + number, + number + ], + [ + number, + number + ] + ]; + /** + * Whether the canvas source is animated. If the canvas is static (i.e. pixels do not need to be re-read on every frame), `animate` should be set to `false` to improve performance. + * @defaultValue true + */ + animate?: boolean; + /** + * Canvas source from which to read pixels. Can be a string representing the ID of the canvas element, or the `HTMLCanvasElement` itself. + */ + canvas?: string | HTMLCanvasElement; +}; +export declare class CanvasSource extends ImageSource { + options: CanvasSourceSpecification; + animate: boolean; + canvas: HTMLCanvasElement; + width: number; + height: number; + /** + * Enables animation. The image will be copied from the canvas to the map on each frame. + */ + play: () => void; + /** + * Disables animation. The map will display a static copy of the canvas image. + */ + pause: () => void; + _playing: boolean; + /** @internal */ + constructor(id: string, options: CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented); + load: () => void; + /** + * Returns the HTML `canvas` element. + * + * @returns The HTML `canvas` element. + */ + getCanvas(): HTMLCanvasElement; + onAdd(map: Map): void; + onRemove(): void; + prepare: () => void; + serialize: () => CanvasSourceSpecification; + hasTransition(): boolean; + _hasInvalidDimensions(): boolean; +} +/** + * The `Source` interface must be implemented by each source type, including "core" types (`vector`, `raster`, + * `video`, etc.) and all custom, third-party types. + * + * @event `data` - Fired with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata + * has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}` + * to indicate that the source data has changed, so that any current caches should be flushed. + * + * @group Sources + */ +export interface Source { + readonly type: string; + /** + * The id for the source. Must not be used by any existing source. + */ + id: string; + minzoom: number; + maxzoom: number; + tileSize: number; + attribution?: string; + /** + * `true` if zoom levels are rounded to the nearest integer in the source data, `false` if they are floor-ed to the nearest integer. + */ + roundZoom?: boolean; + /** + * `false` if tiles can be drawn outside their boundaries, `true` if they cannot. + */ + isTileClipped?: boolean; + tileID?: CanonicalTileID; + /** + * `true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not. + */ + reparseOverscaled?: boolean; + vectorLayerIds?: Array; + hasTransition(): boolean; + loaded(): boolean; + fire(event: Event): unknown; + readonly onAdd?: (map: Map) => void; + readonly onRemove?: (map: Map) => void; + loadTile(tile: Tile, callback: Callback): void; + readonly hasTile?: (tileID: OverscaledTileID) => boolean; + readonly abortTile?: (tile: Tile, callback: Callback) => void; + readonly unloadTile?: (tile: Tile, callback: Callback) => void; + /** + * @returns A plain (stringifiable) JS object representing the current state of the source. + * Creating a source using the returned object as the `options` should result in a Source that is + * equivalent to this one. + */ + serialize(): any; + readonly prepare?: () => void; +} +/** + * A supporting type to the source definition + */ +export type SourceStatics = { + workerSourceURL?: URL; +}; +/** + * A general definition of a {@link Source} class for factory usage + */ +export type SourceClass = { + new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source; +} & SourceStatics; +export declare class SourceCache extends Evented { + id: string; + dispatcher: Dispatcher; + map: Map; + style: Style; + _source: Source; + _sourceLoaded: boolean; + _sourceErrored: boolean; + _tiles: { + [_: string]: Tile; + }; + _prevLng: number; + _cache: TileCache; + _timers: { + [_ in any]: ReturnType; + }; + _cacheTimers: { + [_ in any]: ReturnType; + }; + _maxTileCacheSize: number; + _maxTileCacheZoomLevels: number; + _paused: boolean; + _shouldReloadOnResume: boolean; + _coveredTiles: { + [_: string]: boolean; + }; + transform: Transform; + terrain: Terrain; + used: boolean; + usedForTerrain: boolean; + tileSize: number; + _state: SourceFeatureState; + _loadedParentTiles: { + [_: string]: Tile; + }; + _didEmitContent: boolean; + _updated: boolean; + static maxUnderzooming: number; + static maxOverzooming: number; + constructor(id: string, options: SourceSpecification, dispatcher: Dispatcher); + onAdd(map: Map): void; + onRemove(map: Map): void; + /** + * Return true if no tile data is pending, tiles will not change unless + * an additional API call is received. + */ + loaded(): boolean; + getSource(): Source; + pause(): void; + resume(): void; + _loadTile(tile: Tile, callback: Callback): void; + _unloadTile(tile: Tile): void; + _abortTile(tile: Tile): void; + serialize(): any; + prepare(context: Context): void; + /** + * Return all tile ids ordered with z-order, and cast to numbers + */ + getIds(): Array; + getRenderableIds(symbolLayer?: boolean): Array; + hasRenderableParent(tileID: OverscaledTileID): boolean; + _isIdRenderable(id: string, symbolLayer?: boolean): boolean; + reload(): void; + _reloadTile(id: string, state: TileState): void; + _tileLoaded(tile: Tile, id: string, previousState: TileState, err?: Error | null): void; + /** + * For raster terrain source, backfill DEM to eliminate visible tile boundaries + */ + _backfillDEM(tile: Tile): void; + /** + * Get a specific tile by TileID + */ + getTile(tileID: OverscaledTileID): Tile; + /** + * Get a specific tile by id + */ + getTileByID(id: string): Tile; + /** + * For a given set of tiles, retain children that are loaded and have a zoom + * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive) + */ + _retainLoadedChildren(idealTiles: { + [_ in any]: OverscaledTileID; + }, zoom: number, maxCoveringZoom: number, retain: { + [_ in any]: OverscaledTileID; + }): void; + /** + * Find a loaded parent of the given tile (up to minCoveringZoom) + */ + findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): Tile; + _getLoadedTile(tileID: OverscaledTileID): Tile; + /** + * Resizes the tile cache based on the current viewport's size + * or the maxTileCacheSize option passed during map creation + * + * Larger viewports use more tiles and need larger caches. Larger viewports + * are more likely to be found on devices with more memory and on pages where + * the map is more important. + */ + updateCacheSize(transform: Transform): void; + handleWrapJump(lng: number): void; + /** + * Removes tiles that are outside the viewport and adds new tiles that + * are inside the viewport. + */ + update(transform: Transform, terrain?: Terrain): void; + releaseSymbolFadeTiles(): void; + _updateRetainedTiles(idealTileIDs: Array, zoom: number): { + [_: string]: OverscaledTileID; + }; + _updateLoadedParentTileCache(): void; + /** + * Add a tile, given its coordinate, to the pyramid. + */ + _addTile(tileID: OverscaledTileID): Tile; + _setTileReloadTimer(id: string, tile: Tile): void; + /** + * Remove a tile, given its id, from the pyramid + */ + _removeTile(id: string): void; + /** + * Remove all tiles from this pyramid + */ + clearTiles(): void; + /** + * Search through our current tiles and attempt to find the tiles that + * cover the given bounds. + * @param pointQueryGeometry - coordinates of the corners of bounding rectangle + * @returns result items have `{tile, minX, maxX, minY, maxY}`, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile. + */ + tilesIn(pointQueryGeometry: Array, maxPitchScaleFactor: number, has3DLayer: boolean): any[]; + getVisibleCoordinates(symbolLayer?: boolean): Array; + hasTransition(): boolean; + /** + * Set the value of a particular state for a feature + */ + setFeatureState(sourceLayer: string, featureId: number | string, state: any): void; + /** + * Resets the value of a particular state key for a feature + */ + removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string): void; + /** + * Get the entire state object for a feature + */ + getFeatureState(sourceLayer: string, featureId: number | string): any; + /** + * Sets the set of keys that the tile depends on. This allows tiles to + * be reloaded when their dependencies change. + */ + setDependencies(tileKey: string, namespace: string, dependencies: Array): void; + /** + * Reloads all tiles that depend on the given keys. + */ + reloadTilesForDependencies(namespaces: Array, keys: Array): void; +} +declare enum WritingMode { + none = 0, + horizontal = 1, + vertical = 2, + horizontalOnly = 3 +} +export declare class Anchor extends Point { + angle: any; + segment?: number; + constructor(x: number, y: number, angle: number, segment?: number); + clone(): Anchor; +} +export type SymbolLayoutProps = { + "symbol-placement": DataConstantProperty<"point" | "line" | "line-center">; + "symbol-spacing": DataConstantProperty; + "symbol-avoid-edges": DataConstantProperty; + "symbol-sort-key": DataDrivenProperty; + "symbol-z-order": DataConstantProperty<"auto" | "viewport-y" | "source">; + "icon-allow-overlap": DataConstantProperty; + "icon-overlap": DataConstantProperty<"never" | "always" | "cooperative">; + "icon-ignore-placement": DataConstantProperty; + "icon-optional": DataConstantProperty; + "icon-rotation-alignment": DataConstantProperty<"map" | "viewport" | "auto">; + "icon-size": DataDrivenProperty; + "icon-text-fit": DataConstantProperty<"none" | "width" | "height" | "both">; + "icon-text-fit-padding": DataConstantProperty<[ + number, + number, + number, + number + ]>; + "icon-image": DataDrivenProperty; + "icon-rotate": DataDrivenProperty; + "icon-padding": DataDrivenProperty; + "icon-keep-upright": DataConstantProperty; + "icon-offset": DataDrivenProperty<[ + number, + number + ]>; + "icon-anchor": DataDrivenProperty<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">; + "icon-pitch-alignment": DataConstantProperty<"map" | "viewport" | "auto">; + "text-pitch-alignment": DataConstantProperty<"map" | "viewport" | "auto">; + "text-rotation-alignment": DataConstantProperty<"map" | "viewport" | "viewport-glyph" | "auto">; + "text-field": DataDrivenProperty; + "text-font": DataDrivenProperty>; + "text-size": DataDrivenProperty; + "text-max-width": DataDrivenProperty; + "text-line-height": DataConstantProperty; + "text-letter-spacing": DataDrivenProperty; + "text-justify": DataDrivenProperty<"auto" | "left" | "center" | "right">; + "text-radial-offset": DataDrivenProperty; + "text-variable-anchor": DataConstantProperty>; + "text-variable-anchor-offset": DataDrivenProperty; + "text-anchor": DataDrivenProperty<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">; + "text-max-angle": DataConstantProperty; + "text-writing-mode": DataConstantProperty>; + "text-rotate": DataDrivenProperty; + "text-padding": DataConstantProperty; + "text-keep-upright": DataConstantProperty; + "text-transform": DataDrivenProperty<"none" | "uppercase" | "lowercase">; + "text-offset": DataDrivenProperty<[ + number, + number + ]>; + "text-allow-overlap": DataConstantProperty; + "text-overlap": DataConstantProperty<"never" | "always" | "cooperative">; + "text-ignore-placement": DataConstantProperty; + "text-optional": DataConstantProperty; +}; +export type SymbolLayoutPropsPossiblyEvaluated = { + "symbol-placement": "point" | "line" | "line-center"; + "symbol-spacing": number; + "symbol-avoid-edges": boolean; + "symbol-sort-key": PossiblyEvaluatedPropertyValue; + "symbol-z-order": "auto" | "viewport-y" | "source"; + "icon-allow-overlap": boolean; + "icon-overlap": "never" | "always" | "cooperative"; + "icon-ignore-placement": boolean; + "icon-optional": boolean; + "icon-rotation-alignment": "map" | "viewport" | "auto"; + "icon-size": PossiblyEvaluatedPropertyValue; + "icon-text-fit": "none" | "width" | "height" | "both"; + "icon-text-fit-padding": [ + number, + number, + number, + number + ]; + "icon-image": PossiblyEvaluatedPropertyValue; + "icon-rotate": PossiblyEvaluatedPropertyValue; + "icon-padding": PossiblyEvaluatedPropertyValue; + "icon-keep-upright": boolean; + "icon-offset": PossiblyEvaluatedPropertyValue<[ + number, + number + ]>; + "icon-anchor": PossiblyEvaluatedPropertyValue<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">; + "icon-pitch-alignment": "map" | "viewport" | "auto"; + "text-pitch-alignment": "map" | "viewport" | "auto"; + "text-rotation-alignment": "map" | "viewport" | "viewport-glyph" | "auto"; + "text-field": PossiblyEvaluatedPropertyValue; + "text-font": PossiblyEvaluatedPropertyValue>; + "text-size": PossiblyEvaluatedPropertyValue; + "text-max-width": PossiblyEvaluatedPropertyValue; + "text-line-height": number; + "text-letter-spacing": PossiblyEvaluatedPropertyValue; + "text-justify": PossiblyEvaluatedPropertyValue<"auto" | "left" | "center" | "right">; + "text-radial-offset": PossiblyEvaluatedPropertyValue; + "text-variable-anchor": Array<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">; + "text-variable-anchor-offset": PossiblyEvaluatedPropertyValue; + "text-anchor": PossiblyEvaluatedPropertyValue<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">; + "text-max-angle": number; + "text-writing-mode": Array<"horizontal" | "vertical">; + "text-rotate": PossiblyEvaluatedPropertyValue; + "text-padding": number; + "text-keep-upright": boolean; + "text-transform": PossiblyEvaluatedPropertyValue<"none" | "uppercase" | "lowercase">; + "text-offset": PossiblyEvaluatedPropertyValue<[ + number, + number + ]>; + "text-allow-overlap": boolean; + "text-overlap": "never" | "always" | "cooperative"; + "text-ignore-placement": boolean; + "text-optional": boolean; +}; +export type SymbolPaintProps = { + "icon-opacity": DataDrivenProperty; + "icon-color": DataDrivenProperty; + "icon-halo-color": DataDrivenProperty; + "icon-halo-width": DataDrivenProperty; + "icon-halo-blur": DataDrivenProperty; + "icon-translate": DataConstantProperty<[ + number, + number + ]>; + "icon-translate-anchor": DataConstantProperty<"map" | "viewport">; + "text-opacity": DataDrivenProperty; + "text-color": DataDrivenProperty; + "text-halo-color": DataDrivenProperty; + "text-halo-width": DataDrivenProperty; + "text-halo-blur": DataDrivenProperty; + "text-translate": DataConstantProperty<[ + number, + number + ]>; + "text-translate-anchor": DataConstantProperty<"map" | "viewport">; +}; +export type SymbolPaintPropsPossiblyEvaluated = { + "icon-opacity": PossiblyEvaluatedPropertyValue; + "icon-color": PossiblyEvaluatedPropertyValue; + "icon-halo-color": PossiblyEvaluatedPropertyValue; + "icon-halo-width": PossiblyEvaluatedPropertyValue; + "icon-halo-blur": PossiblyEvaluatedPropertyValue; + "icon-translate": [ + number, + number + ]; + "icon-translate-anchor": "map" | "viewport"; + "text-opacity": PossiblyEvaluatedPropertyValue; + "text-color": PossiblyEvaluatedPropertyValue; + "text-halo-color": PossiblyEvaluatedPropertyValue; + "text-halo-width": PossiblyEvaluatedPropertyValue; + "text-halo-blur": PossiblyEvaluatedPropertyValue; + "text-translate": [ + number, + number + ]; + "text-translate-anchor": "map" | "viewport"; +}; +export declare class SymbolStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + constructor(layer: LayerSpecification); + recalculate(parameters: EvaluationParameters, availableImages: Array): void; + getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array): any; + createBucket(parameters: BucketParameters): SymbolBucket; + queryRadius(): number; + queryIntersectsFeature(): boolean; + _setPaintOverrides(): void; + _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean; + static hasPaintOverride(layout: PossiblyEvaluated, propertyName: string): boolean; +} +/** + * A textured quad for rendering a single icon or glyph. + * + * The zoom range the glyph can be shown is defined by minScale and maxScale. + * + * @param tl - The offset of the top left corner from the anchor. + * @param tr - The offset of the top right corner from the anchor. + * @param bl - The offset of the bottom left corner from the anchor. + * @param br - The offset of the bottom right corner from the anchor. + * @param tex - The texture coordinates. + */ +export type SymbolQuad = { + tl: Point; + tr: Point; + bl: Point; + br: Point; + tex: { + x: number; + y: number; + w: number; + h: number; + }; + pixelOffsetTL: Point; + pixelOffsetBR: Point; + writingMode: any | void; + glyphOffset: [ + number, + number + ]; + sectionIndex: number; + isSDF: boolean; + minFontScaleX: number; + minFontScaleY: number; +}; +export type SizeData = { + kind: "constant"; + layoutSize: number; +} | { + kind: "source"; +} | { + kind: "camera"; + minZoom: number; + maxZoom: number; + minSize: number; + maxSize: number; + interpolationType: InterpolationType; +} | { + kind: "composite"; + minZoom: number; + maxZoom: number; + interpolationType: InterpolationType; +}; +export type SingleCollisionBox = { + x1: number; + y1: number; + x2: number; + y2: number; + anchorPointX: number; + anchorPointY: number; +}; +export type CollisionArrays = { + textBox?: SingleCollisionBox; + verticalTextBox?: SingleCollisionBox; + iconBox?: SingleCollisionBox; + verticalIconBox?: SingleCollisionBox; + textFeatureIndex?: number; + verticalTextFeatureIndex?: number; + iconFeatureIndex?: number; + verticalIconFeatureIndex?: number; +}; +export type SymbolFeature = { + sortKey: number | void; + text: Formatted | void; + icon: ResolvedImage; + index: number; + sourceLayerIndex: number; + geometry: Array>; + properties: any; + type: "Unknown" | "Point" | "LineString" | "Polygon"; + id?: any; +}; +export type SortKeyRange = { + sortKey: number; + symbolInstanceStart: number; + symbolInstanceEnd: number; +}; +declare function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number): void; +export declare class SymbolBuffers { + layoutVertexArray: SymbolLayoutArray; + layoutVertexBuffer: VertexBuffer; + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + dynamicLayoutVertexArray: SymbolDynamicLayoutArray; + dynamicLayoutVertexBuffer: VertexBuffer; + opacityVertexArray: SymbolOpacityArray; + opacityVertexBuffer: VertexBuffer; + hasVisibleVertices: boolean; + collisionVertexArray: CollisionVertexArray; + collisionVertexBuffer: VertexBuffer; + placedSymbolArray: PlacedSymbolArray; + constructor(programConfigurations: ProgramConfigurationSet); + isEmpty(): boolean; + upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean): void; + destroy(): void; +} +export declare class CollisionBuffers { + layoutVertexArray: StructArray; + layoutAttributes: Array; + layoutVertexBuffer: VertexBuffer; + indexArray: TriangleIndexArray | LineIndexArray; + indexBuffer: IndexBuffer; + segments: SegmentVector; + collisionVertexArray: CollisionVertexArray; + collisionVertexBuffer: VertexBuffer; + constructor(LayoutArray: { + new (...args: any): StructArray; + }, layoutAttributes: Array, IndexArray: { + new (...args: any): TriangleIndexArray | LineIndexArray; + }); + upload(context: Context): void; + destroy(): void; +} +export declare class SymbolBucket implements Bucket { + static MAX_GLYPHS: number; + static addDynamicAttributes: typeof addDynamicAttributes; + collisionBoxArray: CollisionBoxArray; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + index: number; + sdfIcons: boolean; + iconsInText: boolean; + iconsNeedLinear: boolean; + bucketInstanceId: number; + justReloaded: boolean; + hasPattern: boolean; + textSizeData: SizeData; + iconSizeData: SizeData; + glyphOffsetArray: GlyphOffsetArray; + lineVertexArray: SymbolLineVertexArray; + features: Array; + symbolInstances: SymbolInstanceArray; + textAnchorOffsets: TextAnchorOffsetArray; + collisionArrays: Array; + sortKeyRanges: Array; + pixelRatio: number; + tilePixelRatio: number; + compareText: { + [_: string]: Array; + }; + fadeStartTime: number; + sortFeaturesByKey: boolean; + sortFeaturesByY: boolean; + canOverlap: boolean; + sortedAngle: number; + featureSortOrder: Array; + collisionCircleArray: Array; + placementInvProjMatrix: mat4; + placementViewportMatrix: mat4; + text: SymbolBuffers; + icon: SymbolBuffers; + textCollisionBox: CollisionBuffers; + iconCollisionBox: CollisionBuffers; + uploaded: boolean; + sourceLayerIndex: number; + sourceID: string; + symbolInstanceIndexes: Array; + writingModes: WritingMode[]; + allowVerticalPlacement: boolean; + hasRTLText: boolean; + constructor(options: BucketParameters); + createArrays(): void; + calculateGlyphDependencies(text: string, stack: { + [_: number]: boolean; + }, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean): void; + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }): void; + isEmpty(): boolean; + uploadPending(): boolean; + upload(context: Context): void; + destroyDebugData(): void; + destroy(): void; + addToLineVertexArray(anchor: Anchor, line: any): { + lineStartIndex: number; + lineLength: number; + }; + addSymbols(arrays: SymbolBuffers, quads: Array, sizeVertex: any, lineOffset: [ + number, + number + ], alongLine: boolean, feature: SymbolFeature, writingMode: WritingMode, labelAnchor: Anchor, lineStartIndex: number, lineLength: number, associatedIconIndex: number, canonical: CanonicalTileID): void; + _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point): any; + addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance): void; + addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean): void; + generateCollisionDebugBuffers(): void; + _deserializeCollisionBoxesForSymbol(collisionBoxArray: CollisionBoxArray, textStartIndex: number, textEndIndex: number, verticalTextStartIndex: number, verticalTextEndIndex: number, iconStartIndex: number, iconEndIndex: number, verticalIconStartIndex: number, verticalIconEndIndex: number): CollisionArrays; + deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray): void; + hasTextData(): boolean; + hasIconData(): boolean; + hasDebugData(): CollisionBuffers; + hasTextCollisionBoxData(): boolean; + hasIconCollisionBoxData(): boolean; + addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number): void; + getSortedSymbolIndexes(angle: number): any[]; + addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number): void; + sortFeatures(angle: number): void; +} +export interface SymbolsByKeyEntry { + index?: KDBush; + positions?: { + x: number; + y: number; + }[]; + crossTileIDs: number[]; +} +export declare class TileLayerIndex { + tileID: OverscaledTileID; + bucketInstanceId: number; + _symbolsByKey: Record; + constructor(tileID: OverscaledTileID, symbolInstances: SymbolInstanceArray, bucketInstanceId: number); + getScaledCoordinates(symbolInstance: SymbolInstance, childTileID: OverscaledTileID): { + x: number; + y: number; + }; + findMatches(symbolInstances: SymbolInstanceArray, newTileID: OverscaledTileID, zoomCrossTileIDs: { + [crossTileID: number]: boolean; + }): void; + getCrossTileIDsLists(): number[][]; +} +export declare class CrossTileIDs { + maxCrossTileID: number; + constructor(); + generate(): number; +} +export declare class CrossTileSymbolLayerIndex { + indexes: { + [zoom in string | number]: { + [tileId in string | number]: TileLayerIndex; + }; + }; + usedCrossTileIDs: { + [zoom in string | number]: { + [crossTileID: number]: boolean; + }; + }; + lng: number; + constructor(); + handleWrapJump(lng: number): void; + addBucket(tileID: OverscaledTileID, bucket: SymbolBucket, crossTileIDs: CrossTileIDs): boolean; + removeBucketCrossTileIDs(zoom: string | number, removedBucket: TileLayerIndex): void; + removeStaleBuckets(currentIDs: { + [k in string | number]: boolean; + }): boolean; +} +export declare class CrossTileSymbolIndex { + layerIndexes: { + [layerId: string]: CrossTileSymbolLayerIndex; + }; + crossTileIDs: CrossTileIDs; + maxBucketInstanceId: number; + bucketsInCurrentPlacement: { + [_: number]: boolean; + }; + constructor(); + addLayer(styleLayer: StyleLayer, tiles: Array, lng: number): boolean; + pruneUnusedLayers(usedLayers: Array): void; +} +/** + * A dash entry + */ +export type DashEntry = { + y: number; + height: number; + width: number; +}; +export declare class LineAtlas { + width: number; + height: number; + nextRow: number; + bytes: number; + data: Uint8Array; + dashEntry: { + [_: string]: DashEntry; + }; + dirty: boolean; + texture: WebGLTexture; + constructor(width: number, height: number); + /** + * Get or create a dash line pattern. + * + * @param dasharray - the key (represented by numbers) to get the dash texture + * @param round - whether to add circle caps in between dash segments + * @returns position of dash texture in {@link DashEntry} + */ + getDash(dasharray: Array, round: boolean): DashEntry; + getDashRanges(dasharray: Array, lineAtlasWidth: number, stretch: number): any[]; + addRoundDash(ranges: any, stretch: number, n: number): void; + addRegularDash(ranges: any): void; + addDash(dasharray: Array, round: boolean): DashEntry; + bind(context: Context): void; +} +declare function loadGlyphRange(fontstack: string, range: number, urlTemplate: string, requestManager: RequestManager, callback: Callback<{ + [_: number]: StyleGlyph | null; +}>): void; +export type Entry = { + glyphs: { + [id: number]: StyleGlyph | null; + }; + requests: { + [range: number]: Array>; + }; + ranges: { + [range: number]: boolean | null; + }; + tinySDF?: TinySDF; +}; +export declare class GlyphManager { + requestManager: RequestManager; + localIdeographFontFamily: string; + entries: { + [_: string]: Entry; + }; + url: string; + static loadGlyphRange: typeof loadGlyphRange; + static TinySDF: typeof TinySDF; + constructor(requestManager: RequestManager, localIdeographFontFamily?: string | null); + setURL(url?: string | null): void; + getGlyphs(glyphs: { + [stack: string]: Array; + }, callback: Callback<{ + [stack: string]: { + [id: number]: StyleGlyph; + }; + }>): void; + _doesCharSupportLocalGlyph(id: number): boolean; + _tinySDF(entry: Entry, stack: string, id: number): StyleGlyph; +} +export type PoolObject = { + id: number; + fbo: Framebuffer; + texture: Texture; + stamp: number; + inUse: boolean; +}; +export declare class RenderPool { + private readonly _context; + private readonly _size; + private readonly _tileSize; + private _objects; + /** + * An index array of recently used pool objects. + * Items that are used recently are last in the array + */ + private _recentlyUsed; + private _stamp; + constructor(_context: Context, _size: number, _tileSize: number); + destruct(): void; + private _createObject; + getObjectForId(id: number): PoolObject; + useObject(obj: PoolObject): void; + stampObject(obj: PoolObject): void; + getOrCreateFreeObject(): PoolObject; + freeObject(obj: PoolObject): void; + freeAllObjects(): void; + isFull(): boolean; +} +export declare class RenderToTexture { + painter: Painter; + terrain: Terrain; + pool: RenderPool; + /** + * coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile + * e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile + */ + _coordsDescendingInv: { + [_: string]: { + [_: string]: Array; + }; + }; + /** + * create a string representation of all to tiles rendered to render-to-texture tiles + * this string representation is used to check if tile should be re-rendered. + */ + _coordsDescendingInvStr: { + [_: string]: { + [_: string]: string; + }; + }; + /** + * store for render-stacks + * a render stack is a set of layers which should be rendered into one texture + * every stylesheet can have multiple stacks. A new stack is created if layers which should + * not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols + */ + _stacks: Array>; + /** + * remember the previous processed layer to check if a new stack is needed + */ + _prevType: string; + /** + * a list of tiles that can potentially rendered + */ + _renderableTiles: Array; + /** + * a list of tiles that should be rendered to screen in the next render-call + */ + _rttTiles: Array; + /** + * a list of all layer-ids which should be rendered + */ + _renderableLayerIds: Array; + constructor(painter: Painter, terrain: Terrain); + destruct(): void; + getTexture(tile: Tile): Texture; + prepareForRender(style: Style, zoom: number): void; + /** + * due that switching textures is relatively slow, the render + * layer-by-layer context is not practicable. To bypass this problem + * this lines of code stack all layers and later render all at once. + * Because of the stylesheet possibility to mixing render-to-texture layers + * and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example + * a symbol-layer is in between of fill-layers. + * @param layer - the layer to render + * @returns if true layer is rendered to texture, otherwise false + */ + renderLayer(layer: StyleLayer): boolean; +} +export type RenderPass = "offscreen" | "opaque" | "translucent"; +export type PainterOptions = { + showOverdrawInspector: boolean; + showTileBoundaries: boolean; + showPadding: boolean; + rotating: boolean; + zooming: boolean; + moving: boolean; + fadeDuration: number; +}; +export declare class Painter { + context: Context; + transform: Transform; + renderToTexture: RenderToTexture; + _tileTextures: { + [_: number]: Array; + }; + numSublayers: number; + depthEpsilon: number; + emptyProgramConfiguration: ProgramConfiguration; + width: number; + height: number; + pixelRatio: number; + tileExtentBuffer: VertexBuffer; + tileExtentSegments: SegmentVector; + debugBuffer: VertexBuffer; + debugSegments: SegmentVector; + rasterBoundsBuffer: VertexBuffer; + rasterBoundsSegments: SegmentVector; + viewportBuffer: VertexBuffer; + viewportSegments: SegmentVector; + quadTriangleIndexBuffer: IndexBuffer; + tileBorderIndexBuffer: IndexBuffer; + _tileClippingMaskIDs: { + [_: string]: number; + }; + stencilClearMode: StencilMode; + style: Style; + options: PainterOptions; + lineAtlas: LineAtlas; + imageManager: ImageManager; + glyphManager: GlyphManager; + depthRangeFor3D: DepthRangeType; + opaquePassCutoff: number; + renderPass: RenderPass; + currentLayer: number; + currentStencilSource: string; + nextStencilID: number; + id: string; + _showOverdrawInspector: boolean; + cache: { + [_: string]: Program; + }; + crossTileSymbolIndex: CrossTileSymbolIndex; + symbolFadeChange: number; + debugOverlayTexture: Texture; + debugOverlayCanvas: HTMLCanvasElement; + terrainFacilitator: { + dirty: boolean; + matrix: mat4; + renderTime: number; + }; + constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, transform: Transform); + resize(width: number, height: number, pixelRatio: number): void; + setup(): void; + clearStencil(): void; + _renderTileClippingMasks(layer: StyleLayer, tileIDs: Array): void; + stencilModeFor3D(): StencilMode; + stencilModeForClipping(tileID: OverscaledTileID): StencilMode; + stencilConfigForOverlap(tileIDs: Array): [ + { + [_: number]: Readonly; + }, + Array + ]; + colorModeForRenderPass(): Readonly; + depthModeForSublayer(n: number, mask: DepthMaskType, func?: DepthFuncType | null): Readonly; + opaquePassEnabledForLayer(): boolean; + render(style: Style, options: PainterOptions): void; + renderLayer(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array): void; + /** + * Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it. + * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units. + * @returns matrix + */ + translatePosMatrix(matrix: mat4, tile: Tile, translate: [ + number, + number + ], translateAnchor: "map" | "viewport", inViewportPixelUnitsUnits?: boolean): mat4; + saveTileTexture(texture: Texture): void; + getTileTexture(size: number): Texture; + /** + * Checks whether a pattern image is needed, and if it is, whether it is not loaded. + * + * @returns true if a needed image is missing and rendering needs to be skipped. + */ + isPatternMissing(image?: CrossFaded | null): boolean; + useProgram(name: string, programConfiguration?: ProgramConfiguration | null): Program; + setCustomLayerDefaults(): void; + setBaseState(): void; + initDebugOverlayCanvas(): void; + destroy(): void; + overLimit(): boolean; +} +export declare class TerrainSourceCache extends Evented { + /** + * source-cache for the raster-dem source. + */ + sourceCache: SourceCache; + /** + * stores all render-to-texture tiles. + */ + _tiles: { + [_: string]: Tile; + }; + /** + * contains a list of tileID-keys for the current scene. (only for performance) + */ + _renderableTilesKeys: Array; + /** + * raster-dem-tile for a TileID cache. + */ + _sourceTileCache: { + [_: string]: string; + }; + /** + * minimum zoomlevel to render the terrain. + */ + minzoom: number; + /** + * maximum zoomlevel to render the terrain. + */ + maxzoom: number; + /** + * render-to-texture tileSize in scene. + */ + tileSize: number; + /** + * raster-dem tiles will load for performance the actualZoom - deltaZoom zoom-level. + */ + deltaZoom: number; + constructor(sourceCache: SourceCache); + destruct(): void; + /** + * Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory. + * @param transform - the operation to do + * @param terrain - the terrain + */ + update(transform: Transform, terrain: Terrain): void; + /** + * Free render to texture cache + * @param tileID - optional, free only corresponding to tileID. + */ + freeRtt(tileID?: OverscaledTileID): void; + /** + * get a list of tiles, which are loaded and should be rendered in the current scene + * @returns the renderable tiles + */ + getRenderableTiles(): Array; + /** + * get terrain tile by the TileID key + * @param id - the tile id + * @returns the tile + */ + getTileByID(id: string): Tile; + /** + * Searches for the corresponding current renderable terrain-tiles + * @param tileID - the tile to look for + * @returns the tiles that were found + */ + getTerrainCoords(tileID: OverscaledTileID): Record; + /** + * find the covering raster-dem tile + * @param tileID - the tile to look for + * @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem. + * @returns the tile + */ + getSourceTile(tileID: OverscaledTileID, searchForDEM?: boolean): Tile; + /** + * get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers. + * @param time - the time + * @returns the relevant tiles + */ + tilesAfterTime(time?: number): Array; +} +/** + * @internal + * A terrain GPU related object + */ +export type TerrainData = { + "u_depth": number; + "u_terrain": number; + "u_terrain_dim": number; + "u_terrain_matrix": mat4; + "u_terrain_unpack": number[]; + "u_terrain_exaggeration": number; + texture: WebGLTexture; + depthTexture: WebGLTexture; + tile: Tile; +}; +/** + * @internal + * A terrain mesh object + */ +export type TerrainMesh = { + indexBuffer: IndexBuffer; + vertexBuffer: VertexBuffer; + segments: SegmentVector; +}; +export declare class Terrain { + /** + * The style this terrain crresponds to + */ + painter: Painter; + /** + * the sourcecache this terrain is based on + */ + sourceCache: TerrainSourceCache; + /** + * the TerrainSpecification object passed to this instance + */ + options: TerrainSpecification; + /** + * define the meshSize per tile. + */ + meshSize: number; + /** + * multiplicator for the elevation. Used to make terrain more "extreme". + */ + exaggeration: number; + /** + * to not see pixels in the render-to-texture tiles it is good to render them bigger + * this number is the multiplicator (must be a power of 2) for the current tileSize. + * So to get good results with not too much memory footprint a value of 2 should be fine. + */ + qualityFactor: number; + /** + * holds the framebuffer object in size of the screen to render the coords & depth into a texture. + */ + _fbo: Framebuffer; + _fboCoordsTexture: Texture; + _fboDepthTexture: Texture; + _emptyDepthTexture: Texture; + /** + * GL Objects for the terrain-mesh + * The mesh is a regular mesh, which has the advantage that it can be reused for all tiles. + */ + _mesh: TerrainMesh; + /** + * coords index contains a list of tileID.keys. This index is used to identify + * the tile via the alpha-cannel in the coords-texture. + * As the alpha-channel has 1 Byte a max of 255 tiles can rendered without an error. + */ + coordsIndex: Array; + /** + * tile-coords encoded in the rgb channel, _coordsIndex is in the alpha-channel. + */ + _coordsTexture: Texture; + /** + * accuracy of the coords. 2 * tileSize should be enoughth. + */ + _coordsTextureSize: number; + /** + * variables for an empty dem texture, which is used while the raster-dem tile is loading. + */ + _emptyDemUnpack: number[]; + _emptyDemTexture: Texture; + _emptyDemMatrix: mat4; + /** + * as of overzooming of raster-dem tiles in high zoomlevels, this cache contains + * matrices to transform from vector-tile coords to raster-dem-tile coords. + */ + _demMatrixCache: { + [_: string]: { + matrix: mat4; + coord: OverscaledTileID; + }; + }; + constructor(painter: Painter, sourceCache: SourceCache, options: TerrainSpecification); + /** + * get the elevation-value from original dem-data for a given tile-coordinate + * @param tileID - the tile to get elevation for + * @param x - between 0 .. EXTENT + * @param y - between 0 .. EXTENT + * @param extent - optional, default 8192 + * @returns the elevation + */ + getDEMElevation(tileID: OverscaledTileID, x: number, y: number, extent?: number): number; + /** + * Get the elevation for given {@link LngLat} in respect of exaggeration. + * @param lnglat - the location + * @param zoom - the zoom + * @returns the elevation + */ + getElevationForLngLatZoom(lnglat: LngLat, zoom: number): number; + /** + * Get the elevation for given coordinate in respect of exaggeration. + * @param tileID - the tile id + * @param x - between 0 .. EXTENT + * @param y - between 0 .. EXTENT + * @param extent - optional, default 8192 + * @returns the elevation + */ + getElevation(tileID: OverscaledTileID, x: number, y: number, extent?: number): number; + /** + * returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object + * @param tileID - the tile to get the terrain for + * @returns the terrain data to use in the program + */ + getTerrainData(tileID: OverscaledTileID): TerrainData; + /** + * get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture + * @param texture - the texture + * @returns the frame buffer + */ + getFramebuffer(texture: string): Framebuffer; + /** + * create coords texture, needed to grab coordinates from canvas + * encode coords coordinate into 4 bytes: + * - 8 lower bits for x + * - 8 lower bits for y + * - 4 higher bits for x + * - 4 higher bits for y + * - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value + * @returns the texture + */ + getCoordsTexture(): Texture; + /** + * Reads a pixel from the coords-framebuffer and translate this to mercator. + * @param p - Screen-Coordinate + * @returns mercator coordinate for a screen pixel + */ + pointCoordinate(p: Point): MercatorCoordinate; + /** + * create a regular mesh which will be used by all terrain-tiles + * @returns the created regular mesh + */ + getTerrainMesh(): TerrainMesh; + /** + * Calculates a height of the frame around the terrain-mesh to avoid stiching between + * tile boundaries in different zoomlevels. + * @param zoom - current zoomlevel + * @returns the elevation delta in meters + */ + getMeshFrameDelta(zoom: number): number; + getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number): number; + /** + * Get the minimum and maximum elevation contained in a tile. This includes any + * exaggeration included in the terrain. + * + * @param tileID - ID of the tile to be used as a source for the min/max elevation + * @returns the minimum and maximum elevation found in the tile, including the terrain's + * exaggeration + */ + getMinMaxElevation(tileID: OverscaledTileID): { + minElevation: number | null; + maxElevation: number | null; + }; + _getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { + tileID: OverscaledTileID; + mercatorX: number; + mercatorY: number; + }; + _allowMercatorOverflow(p: Point, mercatorX: number): number; +} +export declare class Transform { + tileSize: number; + tileZoom: number; + lngRange: [ + number, + number + ]; + latRange: [ + number, + number + ]; + maxValidLatitude: number; + scale: number; + width: number; + height: number; + angle: number; + rotationMatrix: mat2; + pixelsToGLUnits: [ + number, + number + ]; + cameraToCenterDistance: number; + mercatorMatrix: mat4; + projMatrix: mat4; + invProjMatrix: mat4; + alignedProjMatrix: mat4; + pixelMatrix: mat4; + pixelMatrix3D: mat4; + pixelMatrixInverse: mat4; + glCoordMatrix: mat4; + labelPlaneMatrix: mat4; + _fov: number; + _pitch: number; + _zoom: number; + _unmodified: boolean; + _renderWorldCopies: boolean; + _minZoom: number; + _maxZoom: number; + _minPitch: number; + _maxPitch: number; + _center: LngLat; + _elevation: number; + _pixelPerMeter: number; + _edgeInsets: EdgeInsets; + _constraining: boolean; + _posMatrixCache: { + [_: string]: mat4; + }; + _alignedPosMatrixCache: { + [_: string]: mat4; + }; + _minEleveationForCurrentTile: number; + constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean); + clone(): Transform; + apply(that: Transform): void; + get minZoom(): number; + set minZoom(zoom: number); + get maxZoom(): number; + set maxZoom(zoom: number); + get minPitch(): number; + set minPitch(pitch: number); + get maxPitch(): number; + set maxPitch(pitch: number); + get renderWorldCopies(): boolean; + set renderWorldCopies(renderWorldCopies: boolean); + get worldSize(): number; + get centerOffset(): Point; + get size(): Point; + get bearing(): number; + set bearing(bearing: number); + get pitch(): number; + set pitch(pitch: number); + get fov(): number; + set fov(fov: number); + get zoom(): number; + set zoom(zoom: number); + get center(): LngLat; + set center(center: LngLat); + get elevation(): number; + set elevation(elevation: number); + get padding(): PaddingOptions; + set padding(padding: PaddingOptions); + /** + * The center of the screen in pixels with the top-left corner being (0,0) + * and +y axis pointing downwards. This accounts for padding. + */ + get centerPoint(): Point; + /** + * Returns if the padding params match + * + * @param padding - the padding to check against + * @returns true if they are equal, false otherwise + */ + isPaddingEqual(padding: PaddingOptions): boolean; + /** + * Helper method to update edge-insets in place + * + * @param start - the starting padding + * @param target - the target padding + * @param t - the step/weight + */ + interpolatePadding(start: PaddingOptions, target: PaddingOptions, t: number): void; + /** + * Return a zoom level that will cover all tiles the transform + * @param options - the options + * @returns zoom level An integer zoom level at which all tiles will be visible. + */ + coveringZoomLevel(options: { + /** + * Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored. + */ + roundZoom?: boolean; + /** + * Tile size, expressed in screen pixels. + */ + tileSize: number; + }): number; + /** + * Return any "wrapped" copies of a given tile coordinate that are visible + * in the current view. + */ + getVisibleUnwrappedCoordinates(tileID: CanonicalTileID): UnwrappedTileID[]; + /** + * Return all coordinates that could cover this transform for a covering + * zoom level. + * @param options - the options + * @returns OverscaledTileIDs + */ + coveringTiles(options: { + tileSize: number; + minzoom?: number; + maxzoom?: number; + roundZoom?: boolean; + reparseOverscaled?: boolean; + renderWorldCopies?: boolean; + terrain?: Terrain; + }): Array; + resize(width: number, height: number): void; + get unmodified(): boolean; + zoomScale(zoom: number): number; + scaleZoom(scale: number): number; + project(lnglat: LngLat): Point; + unproject(point: Point): LngLat; + get point(): Point; + /** + * get the camera position in LngLat and altitudes in meter + * @returns An object with lngLat & altitude. + */ + getCameraPosition(): { + lngLat: LngLat; + altitude: number; + }; + /** + * This method works in combination with freezeElevation activated. + * freezeElevtion is enabled during map-panning because during this the camera should sit in constant height. + * After panning finished, call this method to recalculate the zoomlevel for the current camera-height in current terrain. + * @param terrain - the terrain + */ + recalculateZoom(terrain: Terrain): void; + setLocationAtPoint(lnglat: LngLat, point: Point): void; + /** + * Given a location, return the screen point that corresponds to it + * @param lnglat - location + * @param terrain - optional terrain + * @returns screen point + */ + locationPoint(lnglat: LngLat, terrain?: Terrain): Point; + /** + * Given a point on screen, return its lnglat + * @param p - screen point + * @param terrain - optional terrain + * @returns lnglat location + */ + pointLocation(p: Point, terrain?: Terrain): LngLat; + /** + * Given a geographical lnglat, return an unrounded + * coordinate that represents it at this transform's zoom level. + * @param lnglat - the location + * @returns The mercator coordinate + */ + locationCoordinate(lnglat: LngLat): MercatorCoordinate; + /** + * Given a Coordinate, return its geographical position. + * @param coord - mercator coordivates + * @returns lng and lat + */ + coordinateLocation(coord: MercatorCoordinate): LngLat; + /** + * Given a Point, return its mercator coordinate. + * @param p - the point + * @param terrain - optional terrain + * @returns lnglat + */ + pointCoordinate(p: Point, terrain?: Terrain): MercatorCoordinate; + /** + * Given a coordinate, return the screen point that corresponds to it + * @param coord - the coordinates + * @param elevation - the elevation + * @param pixelMatrix - the pixel matrix + * @returns screen point + */ + coordinatePoint(coord: MercatorCoordinate, elevation?: number, pixelMatrix?: mat4): Point; + /** + * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not + * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. + * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds. + */ + getBounds(): LngLatBounds; + /** + * Returns the maximum geographical bounds the map is constrained to, or `null` if none set. + * @returns max bounds + */ + getMaxBounds(): LngLatBounds | null; + /** + * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2), + * multiplied by a static factor to simulate the earth-radius. + * The calculated value is the horizontal line from the camera-height to sea-level. + * @returns Horizon above center in pixels. + */ + getHorizon(): number; + /** + * Sets or clears the map's geographical constraints. + * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map. + */ + setMaxBounds(bounds?: LngLatBounds | null): void; + /** + * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map. + * @param unwrappedTileID - the tile ID + */ + calculatePosMatrix(unwrappedTileID: UnwrappedTileID, aligned?: boolean): mat4; + customLayerMatrix(): mat4; + _constrain(): void; + _calcMatrices(): void; + maxPitchScaleFactor(): number; + /** + * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation` + * as the name for the location under the camera and on the surface of the earth (lng, lat, 0). + * `cameraPoint` is the projected position of the `cameraLocation`. + * + * This point is useful to us because only fill-extrusions that are between `cameraPoint` and + * the query point on the surface of the earth can extend and intersect the query. + * + * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because + * the camera is right above the center of the map. + */ + getCameraPoint(): Point; + /** + * When the map is pitched, some of the 3D features that intersect a query will not intersect + * the query at the surface of the earth. Instead the feature may be closer and only intersect + * the query because it extrudes into the air. + * @param queryGeometry - For point queries, the line from the query point to the "camera point", + * for other geometries, the envelope of the query geometry and the "camera point" + * @returns a geometry that includes all of the original query as well as all possible ares of the + * screen where the *base* of a visible extrusion could be. + * + */ + getCameraQueryGeometry(queryGeometry: Array): Array; +} +export type QueryParameters = { + scale: number; + pixelPosMatrix: mat4; + transform: Transform; + tileSize: number; + queryGeometry: Array; + cameraQueryGeometry: Array; + queryPadding: number; + params: { + filter: FilterSpecification; + layers: Array; + availableImages: Array; + }; +}; +export declare class FeatureIndex { + tileID: OverscaledTileID; + x: number; + y: number; + z: number; + grid: TransferableGridIndex; + grid3D: TransferableGridIndex; + featureIndexArray: FeatureIndexArray; + promoteId?: PromoteIdSpecification; + rawTileData: ArrayBuffer; + bucketLayerIDs: Array>; + vtLayers: { + [_: string]: VectorTileLayer; + }; + sourceLayerCoder: DictionaryCoder; + constructor(tileID: OverscaledTileID, promoteId?: PromoteIdSpecification | null); + insert(feature: VectorTileFeature, geometry: Array>, featureIndex: number, sourceLayerIndex: number, bucketIndex: number, is3D?: boolean): void; + loadVTLayers(): { + [_: string]: VectorTileLayer; + }; + query(args: QueryParameters, styleLayers: { + [_: string]: StyleLayer; + }, serializedLayers: { + [_: string]: any; + }, sourceFeatureState: SourceFeatureState): { + [_: string]: Array<{ + featureIndex: number; + feature: GeoJSONFeature; + }>; + }; + loadMatchingFeature(result: { + [_: string]: Array<{ + featureIndex: number; + feature: GeoJSONFeature; + intersectionZ?: boolean | number; + }>; + }, bucketIndex: number, sourceLayerIndex: number, featureIndex: number, filter: FeatureFilter, filterLayerIDs: Array, availableImages: Array, styleLayers: { + [_: string]: StyleLayer; + }, serializedLayers: { + [_: string]: any; + }, sourceFeatureState?: SourceFeatureState, intersectionTest?: (feature: VectorTileFeature, styleLayer: StyleLayer, featureState: any, id: string | number | void) => boolean | number): void; + lookupSymbolFeatures(symbolFeatureIndexes: Array, serializedLayers: { + [_: string]: StyleLayer; + }, bucketIndex: number, sourceLayerIndex: number, filterSpec: FilterSpecification, filterLayerIDs: Array, availableImages: Array, styleLayers: { + [_: string]: StyleLayer; + }): {}; + hasLayer(id: string): boolean; + getId(feature: VectorTileFeature, sourceLayerId: string): string | number; +} +/** + * The tile's state, can be: + * - `loading` Tile data is in the process of loading. + * - `loaded` Tile data has been loaded. Tile can be rendered. + * - `reloading` Tile data has been loaded and is being updated. Tile can be rendered. + * - `unloaded` Tile data has been deleted. + * - `errored` Tile data was not loaded because of an error. + * - `expired` Tile data was previously loaded, but has expired per its HTTP headers and is in the process of refreshing. + */ +export type TileState = "loading" | "loaded" | "reloading" | "unloaded" | "errored" | "expired"; +export declare class Tile { + tileID: OverscaledTileID; + uid: number; + uses: number; + tileSize: number; + buckets: { + [_: string]: Bucket; + }; + latestFeatureIndex: FeatureIndex; + latestRawTileData: ArrayBuffer; + imageAtlas: ImageAtlas; + imageAtlasTexture: Texture; + glyphAtlasImage: AlphaImage; + glyphAtlasTexture: Texture; + expirationTime: any; + expiredRequestCount: number; + state: TileState; + timeAdded: number; + fadeEndTime: number; + collisionBoxArray: CollisionBoxArray; + redoWhenDone: boolean; + showCollisionBoxes: boolean; + placementSource: any; + actor: Actor; + vtLayers: { + [_: string]: VectorTileLayer; + }; + neighboringTiles: any; + dem: DEMData; + demMatrix: mat4; + aborted: boolean; + needsHillshadePrepare: boolean; + needsTerrainPrepare: boolean; + request: Cancelable; + texture: any; + fbo: Framebuffer; + demTexture: Texture; + refreshedUponExpiration: boolean; + reloadCallback: any; + resourceTiming: Array; + queryPadding: number; + symbolFadeHoldUntil: number; + hasSymbolBuckets: boolean; + hasRTLText: boolean; + dependencies: any; + rtt: Array<{ + id: number; + stamp: number; + }>; + rttCoords: { + [_: string]: string; + }; + /** + * @param tileID - the tile ID + * @param size - The tile size + */ + constructor(tileID: OverscaledTileID, size: number); + registerFadeDuration(duration: number): void; + wasRequested(): boolean; + clearTextures(painter: any): void; + /** + * Given a data object with a 'buffers' property, load it into + * this tile's elementGroups and buffers properties and set loaded + * to true. If the data is null, like in the case of an empty + * GeoJSON tile, no-op but still set loaded to true. + * @param data - The data from the worker + * @param painter - the painter + * @param justReloaded - `true` to just reload + */ + loadVectorData(data: WorkerTileResult, painter: any, justReloaded?: boolean | null): void; + /** + * Release any data or WebGL resources referenced by this tile. + */ + unloadVectorData(): void; + getBucket(layer: StyleLayer): Bucket; + upload(context: Context): void; + prepare(imageManager: ImageManager): void; + queryRenderedFeatures(layers: { + [_: string]: StyleLayer; + }, serializedLayers: { + [_: string]: any; + }, sourceFeatureState: SourceFeatureState, queryGeometry: Array, cameraQueryGeometry: Array, scale: number, params: { + filter: FilterSpecification; + layers: Array; + availableImages: Array; + }, transform: Transform, maxPitchScaleFactor: number, pixelPosMatrix: mat4): { + [_: string]: Array<{ + featureIndex: number; + feature: GeoJSONFeature; + }>; + }; + querySourceFeatures(result: Array, params?: { + sourceLayer?: string; + filter?: FilterSpecification; + validate?: boolean; + }): void; + hasData(): boolean; + patternsLoaded(): boolean; + setExpiryData(data: ExpiryData): void; + getExpiryTimeout(): number; + setFeatureState(states: LayerFeatureStates, painter: any): void; + holdingForFade(): boolean; + symbolFadeFinished(): boolean; + clearFadeHold(): void; + setHoldDuration(duration: number): void; + setDependencies(namespace: string, dependencies: Array): void; + hasDependency(namespaces: Array, keys: Array): boolean; +} +export type FeatureStates = { + [featureId: string]: FeatureState; +}; +export type LayerFeatureStates = { + [layer: string]: FeatureStates; +}; +export declare class SourceFeatureState { + state: LayerFeatureStates; + stateChanges: LayerFeatureStates; + deletedStates: {}; + constructor(); + updateState(sourceLayer: string, featureId: number | string, newState: any): void; + removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string): void; + getState(sourceLayer: string, featureId: number | string): any; + initializeTileState(tile: Tile, painter: any): void; + coalesceChanges(tiles: { + [_ in any]: Tile; + }, painter: any): void; +} +export type BinderUniform = { + name: string; + property: string; + binding: Uniform; +}; +/** + * `Binder` is the interface definition for the strategies for constructing, + * uploading, and binding paint property data as GLSL attributes. Most style- + * spec properties have a 1:1 relationship to shader attribute/uniforms, but + * some require multiple values per feature to be passed to the GPU, and in + * those cases we bind multiple attributes/uniforms. + * + * It has three implementations, one for each of the three strategies we use: + * + * * For _constant_ properties -- those whose value is a constant, or the constant + * result of evaluating a camera expression at a particular camera position -- we + * don't need a vertex attribute buffer, and instead use a uniform. + * * For data expressions, we use a vertex buffer with a single attribute value, + * the evaluated result of the source function for the given feature. + * * For composite expressions, we use a vertex buffer with two attributes: min and + * max values covering the range of zooms at which we expect the tile to be + * displayed. These values are calculated by evaluating the composite expression for + * the given feature at strategically chosen zoom levels. In addition to this + * attribute data, we also use a uniform value which the shader uses to interpolate + * between the min and max value at the final displayed zoom level. The use of a + * uniform allows us to cheaply update the value on every frame. + * + * Note that the shader source varies depending on whether we're using a uniform or + * attribute. We dynamically compile shaders at runtime to accommodate this. + */ +export interface AttributeBinder { + populatePaintArray(length: number, feature: Feature, imagePositions: { + [_: string]: ImagePosition; + }, canonical?: CanonicalTileID, formattedSection?: FormattedSection): void; + updatePaintArray(start: number, length: number, feature: Feature, featureState: FeatureState, imagePositions: { + [_: string]: ImagePosition; + }): void; + upload(a: Context): void; + destroy(): void; +} +export interface UniformBinder { + uniformNames: Array; + setUniform(uniform: Uniform, globals: GlobalProperties, currentValue: PossiblyEvaluatedPropertyValue, uniformName: string): void; + getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial>; +} +export declare class ProgramConfiguration { + binders: { + [_: string]: AttributeBinder | UniformBinder; + }; + cacheKey: string; + _buffers: Array; + constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean); + getMaxValue(property: string): number; + populatePaintArrays(newLength: number, feature: Feature, imagePositions: { + [_: string]: ImagePosition; + }, canonical?: CanonicalTileID, formattedSection?: FormattedSection): void; + setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition): void; + updatePaintArrays(featureStates: FeatureStates, featureMap: FeaturePositionMap, vtLayer: VectorTileLayer, layer: TypedStyleLayer, imagePositions: { + [_: string]: ImagePosition; + }): boolean; + defines(): Array; + getBinderAttributes(): Array; + getBinderUniforms(): Array; + getPaintVertexBuffers(): Array; + getUniforms(context: Context, locations: UniformLocations): Array; + setUniforms(context: Context, binderUniforms: Array, properties: any, globals: GlobalProperties): void; + updatePaintBuffers(crossfade?: CrossfadeParameters): void; + upload(context: Context): void; + destroy(): void; +} +export declare class ProgramConfigurationSet { + programConfigurations: { + [_: string]: ProgramConfiguration; + }; + needsUpload: boolean; + _featureMap: FeaturePositionMap; + _bufferOffset: number; + constructor(layers: ReadonlyArray, zoom: number, filterProperties?: (_: string) => boolean); + populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: { + [_: string]: ImagePosition; + }, canonical: CanonicalTileID, formattedSection?: FormattedSection): void; + updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: ReadonlyArray, imagePositions: { + [_: string]: ImagePosition; + }): void; + get(layerId: string): ProgramConfiguration; + upload(context: Context): void; + destroy(): void; +} +export type TerrainPreludeUniformsType = { + "u_depth": Uniform1i; + "u_terrain": Uniform1i; + "u_terrain_dim": Uniform1f; + "u_terrain_matrix": UniformMatrix4f; + "u_terrain_unpack": Uniform4f; + "u_terrain_exaggeration": Uniform1f; +}; +export type DrawMode = WebGLRenderingContextBase["LINES"] | WebGLRenderingContextBase["TRIANGLES"] | WebGL2RenderingContext["LINE_STRIP"]; +export declare class Program { + program: WebGLProgram; + attributes: { + [_: string]: number; + }; + numAttributes: number; + fixedUniforms: Us; + terrainUniforms: TerrainPreludeUniformsType; + binderUniforms: Array; + failedToCreate: boolean; + constructor(context: Context, source: { + fragmentSource: string; + vertexSource: string; + staticAttributes: Array; + staticUniforms: Array; + }, configuration: ProgramConfiguration, fixedUniforms: (b: Context, a: UniformLocations) => Us, showOverdrawInspector: boolean, terrain: Terrain); + draw(context: Context, drawMode: DrawMode, depthMode: Readonly, stencilMode: Readonly, colorMode: Readonly, cullFaceMode: Readonly, uniformValues: UniformValues, terrain: TerrainData, layerID: string, layoutVertexBuffer: VertexBuffer, indexBuffer: IndexBuffer, segments: SegmentVector, currentProperties?: any, zoom?: number | null, configuration?: ProgramConfiguration | null, dynamicLayoutBuffer?: VertexBuffer | null, dynamicLayoutBuffer2?: VertexBuffer | null, dynamicLayoutBuffer3?: VertexBuffer | null): void; +} +export declare class VertexArrayObject { + context: Context; + boundProgram: Program; + boundLayoutVertexBuffer: VertexBuffer; + boundPaintVertexBuffers: Array; + boundIndexBuffer: IndexBuffer; + boundVertexOffset: number; + boundDynamicVertexBuffer: VertexBuffer; + boundDynamicVertexBuffer2: VertexBuffer; + boundDynamicVertexBuffer3: VertexBuffer; + vao: any; + constructor(); + bind(context: Context, program: Program, layoutVertexBuffer: VertexBuffer, paintVertexBuffers: Array, indexBuffer?: IndexBuffer | null, vertexOffset?: number | null, dynamicVertexBuffer?: VertexBuffer | null, dynamicVertexBuffer2?: VertexBuffer | null, dynamicVertexBuffer3?: VertexBuffer | null): void; + freshBind(program: Program, layoutVertexBuffer: VertexBuffer, paintVertexBuffers: Array, indexBuffer?: IndexBuffer | null, vertexOffset?: number | null, dynamicVertexBuffer?: VertexBuffer | null, dynamicVertexBuffer2?: VertexBuffer | null, dynamicVertexBuffer3?: VertexBuffer | null): void; + destroy(): void; +} +/** + * @internal + * A single segment of a vector + */ +export type Segment = { + sortKey?: number; + vertexOffset: number; + primitiveOffset: number; + vertexLength: number; + primitiveLength: number; + vaos: { + [_: string]: VertexArrayObject; + }; +}; +export declare class SegmentVector { + static MAX_VERTEX_ARRAY_LENGTH: number; + segments: Array; + constructor(segments?: Array); + prepareSegment(numVertices: number, layoutVertexArray: StructArray, indexArray: StructArray, sortKey?: number): Segment; + get(): Segment[]; + destroy(): void; + static simpleSegment(vertexOffset: number, primitiveOffset: number, vertexLength: number, primitiveLength: number): SegmentVector; +} +export declare class HeatmapBucket extends CircleBucket { + layers: Array; +} +export type HeatmapPaintProps = { + "heatmap-radius": DataDrivenProperty; + "heatmap-weight": DataDrivenProperty; + "heatmap-intensity": DataConstantProperty; + "heatmap-color": ColorRampProperty; + "heatmap-opacity": DataConstantProperty; +}; +export type HeatmapPaintPropsPossiblyEvaluated = { + "heatmap-radius": PossiblyEvaluatedPropertyValue; + "heatmap-weight": PossiblyEvaluatedPropertyValue; + "heatmap-intensity": number; + "heatmap-color": ColorRampProperty; + "heatmap-opacity": number; +}; +export declare class HeatmapStyleLayer extends StyleLayer { + heatmapFbo: Framebuffer; + colorRamp: RGBAImage; + colorRampTexture: Texture; + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + createBucket(options: any): HeatmapBucket; + constructor(layer: LayerSpecification); + _handleSpecialPaintPropertyUpdate(name: string): void; + _updateColorRamp(): void; + resize(): void; + queryRadius(): number; + queryIntersectsFeature(): boolean; + hasOffscreenPass(): boolean; +} +export declare class CircleBucket implements Bucket { + index: number; + zoom: number; + overscaling: number; + layerIds: Array; + layers: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + layoutVertexArray: CircleLayoutArray; + layoutVertexBuffer: VertexBuffer; + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + uploaded: boolean; + constructor(options: BucketParameters); + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }): void; + isEmpty(): boolean; + uploadPending(): boolean; + upload(context: Context): void; + destroy(): void; + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID): void; +} +export type CircleLayoutProps = { + "circle-sort-key": DataDrivenProperty; +}; +export type CircleLayoutPropsPossiblyEvaluated = { + "circle-sort-key": PossiblyEvaluatedPropertyValue; +}; +export type CirclePaintProps = { + "circle-radius": DataDrivenProperty; + "circle-color": DataDrivenProperty; + "circle-blur": DataDrivenProperty; + "circle-opacity": DataDrivenProperty; + "circle-translate": DataConstantProperty<[ + number, + number + ]>; + "circle-translate-anchor": DataConstantProperty<"map" | "viewport">; + "circle-pitch-scale": DataConstantProperty<"map" | "viewport">; + "circle-pitch-alignment": DataConstantProperty<"map" | "viewport">; + "circle-stroke-width": DataDrivenProperty; + "circle-stroke-color": DataDrivenProperty; + "circle-stroke-opacity": DataDrivenProperty; +}; +export type CirclePaintPropsPossiblyEvaluated = { + "circle-radius": PossiblyEvaluatedPropertyValue; + "circle-color": PossiblyEvaluatedPropertyValue; + "circle-blur": PossiblyEvaluatedPropertyValue; + "circle-opacity": PossiblyEvaluatedPropertyValue; + "circle-translate": [ + number, + number + ]; + "circle-translate-anchor": "map" | "viewport"; + "circle-pitch-scale": "map" | "viewport"; + "circle-pitch-alignment": "map" | "viewport"; + "circle-stroke-width": PossiblyEvaluatedPropertyValue; + "circle-stroke-color": PossiblyEvaluatedPropertyValue; + "circle-stroke-opacity": PossiblyEvaluatedPropertyValue; +}; +export declare class CircleStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + constructor(layer: LayerSpecification); + createBucket(parameters: BucketParameters): CircleBucket; + queryRadius(bucket: Bucket): number; + queryIntersectsFeature(queryGeometry: Array, feature: VectorTileFeature, featureState: FeatureState, geometry: Array>, zoom: number, transform: Transform, pixelsToTileUnits: number, pixelPosMatrix: mat4): boolean; +} +export declare class FillBucket implements Bucket { + index: number; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + patternFeatures: Array; + layoutVertexArray: FillLayoutArray; + layoutVertexBuffer: VertexBuffer; + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + indexArray2: LineIndexArray; + indexBuffer2: IndexBuffer; + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + segments2: SegmentVector; + uploaded: boolean; + constructor(options: BucketParameters); + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }): void; + addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }): void; + isEmpty(): boolean; + uploadPending(): boolean; + upload(context: Context): void; + destroy(): void; + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }): void; +} +export type FillLayoutProps = { + "fill-sort-key": DataDrivenProperty; +}; +export type FillLayoutPropsPossiblyEvaluated = { + "fill-sort-key": PossiblyEvaluatedPropertyValue; +}; +export type FillPaintProps = { + "fill-antialias": DataConstantProperty; + "fill-opacity": DataDrivenProperty; + "fill-color": DataDrivenProperty; + "fill-outline-color": DataDrivenProperty; + "fill-translate": DataConstantProperty<[ + number, + number + ]>; + "fill-translate-anchor": DataConstantProperty<"map" | "viewport">; + "fill-pattern": CrossFadedDataDrivenProperty; +}; +export type FillPaintPropsPossiblyEvaluated = { + "fill-antialias": boolean; + "fill-opacity": PossiblyEvaluatedPropertyValue; + "fill-color": PossiblyEvaluatedPropertyValue; + "fill-outline-color": PossiblyEvaluatedPropertyValue; + "fill-translate": [ + number, + number + ]; + "fill-translate-anchor": "map" | "viewport"; + "fill-pattern": PossiblyEvaluatedPropertyValue>; +}; +export declare class FillStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + constructor(layer: LayerSpecification); + recalculate(parameters: EvaluationParameters, availableImages: Array): void; + createBucket(parameters: BucketParameters): FillBucket; + queryRadius(): number; + queryIntersectsFeature(queryGeometry: Array, feature: VectorTileFeature, featureState: FeatureState, geometry: Array>, zoom: number, transform: Transform, pixelsToTileUnits: number): boolean; + isTileClipped(): boolean; +} +export declare class FillExtrusionBucket implements Bucket { + index: number; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + layoutVertexArray: FillExtrusionLayoutArray; + layoutVertexBuffer: VertexBuffer; + centroidVertexArray: PosArray; + centroidVertexBuffer: VertexBuffer; + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + uploaded: boolean; + features: Array; + constructor(options: BucketParameters); + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }): void; + isEmpty(): boolean; + uploadPending(): boolean; + upload(context: Context): void; + destroy(): void; + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }): void; +} +export type FillExtrusionPaintProps = { + "fill-extrusion-opacity": DataConstantProperty; + "fill-extrusion-color": DataDrivenProperty; + "fill-extrusion-translate": DataConstantProperty<[ + number, + number + ]>; + "fill-extrusion-translate-anchor": DataConstantProperty<"map" | "viewport">; + "fill-extrusion-pattern": CrossFadedDataDrivenProperty; + "fill-extrusion-height": DataDrivenProperty; + "fill-extrusion-base": DataDrivenProperty; + "fill-extrusion-vertical-gradient": DataConstantProperty; +}; +export type FillExtrusionPaintPropsPossiblyEvaluated = { + "fill-extrusion-opacity": number; + "fill-extrusion-color": PossiblyEvaluatedPropertyValue; + "fill-extrusion-translate": [ + number, + number + ]; + "fill-extrusion-translate-anchor": "map" | "viewport"; + "fill-extrusion-pattern": PossiblyEvaluatedPropertyValue>; + "fill-extrusion-height": PossiblyEvaluatedPropertyValue; + "fill-extrusion-base": PossiblyEvaluatedPropertyValue; + "fill-extrusion-vertical-gradient": boolean; +}; +export declare class FillExtrusionStyleLayer extends StyleLayer { + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + constructor(layer: LayerSpecification); + createBucket(parameters: BucketParameters): FillExtrusionBucket; + queryRadius(): number; + is3D(): boolean; + queryIntersectsFeature(queryGeometry: Array, feature: VectorTileFeature, featureState: FeatureState, geometry: Array>, zoom: number, transform: Transform, pixelsToTileUnits: number, pixelPosMatrix: mat4): boolean | number; +} +export type HillshadePaintProps = { + "hillshade-illumination-direction": DataConstantProperty; + "hillshade-illumination-anchor": DataConstantProperty<"map" | "viewport">; + "hillshade-exaggeration": DataConstantProperty; + "hillshade-shadow-color": DataConstantProperty; + "hillshade-highlight-color": DataConstantProperty; + "hillshade-accent-color": DataConstantProperty; +}; +export type HillshadePaintPropsPossiblyEvaluated = { + "hillshade-illumination-direction": number; + "hillshade-illumination-anchor": "map" | "viewport"; + "hillshade-exaggeration": number; + "hillshade-shadow-color": Color; + "hillshade-highlight-color": Color; + "hillshade-accent-color": Color; +}; +export declare class HillshadeStyleLayer extends StyleLayer { + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + constructor(layer: LayerSpecification); + hasOffscreenPass(): boolean; +} +export type LineClips = { + start: number; + end: number; +}; +export type GradientTexture = { + texture?: Texture; + gradient?: RGBAImage; + version?: number; +}; +export declare class LineBucket implements Bucket { + distance: number; + totalDistance: number; + maxLineLength: number; + scaledDistance: number; + lineClips?: LineClips; + e1: number; + e2: number; + index: number; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + gradients: { + [x: string]: GradientTexture; + }; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + patternFeatures: Array; + lineClipsArray: Array; + layoutVertexArray: LineLayoutArray; + layoutVertexBuffer: VertexBuffer; + layoutVertexArray2: LineExtLayoutArray; + layoutVertexBuffer2: VertexBuffer; + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + uploaded: boolean; + constructor(options: BucketParameters); + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }): void; + addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }): void; + isEmpty(): boolean; + uploadPending(): boolean; + upload(context: Context): void; + destroy(): void; + lineFeatureClips(feature: BucketFeature): LineClips | undefined; + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }): void; + addLine(vertices: Array, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number): void; + /** + * Add two vertices to the buffers. + * + * @param p - the line vertex to add buffer vertices for + * @param normal - vertex normal + * @param endLeft - extrude to shift the left vertex along the line + * @param endRight - extrude to shift the left vertex along the line + * @param segment - the segment object to add the vertex to + * @param round - whether this is a round cap + */ + addCurrentVertex(p: Point, normal: Point, endLeft: number, endRight: number, segment: Segment, round?: boolean): void; + addHalfVertex({ x, y }: Point, extrudeX: number, extrudeY: number, round: boolean, up: boolean, dir: number, segment: Segment): void; + updateScaledDistance(): void; + updateDistance(prev: Point, next: Point): void; +} +export type LineLayoutProps = { + "line-cap": DataConstantProperty<"butt" | "round" | "square">; + "line-join": DataDrivenProperty<"bevel" | "round" | "miter">; + "line-miter-limit": DataConstantProperty; + "line-round-limit": DataConstantProperty; + "line-sort-key": DataDrivenProperty; +}; +export type LineLayoutPropsPossiblyEvaluated = { + "line-cap": "butt" | "round" | "square"; + "line-join": PossiblyEvaluatedPropertyValue<"bevel" | "round" | "miter">; + "line-miter-limit": number; + "line-round-limit": number; + "line-sort-key": PossiblyEvaluatedPropertyValue; +}; +export type LinePaintProps = { + "line-opacity": DataDrivenProperty; + "line-color": DataDrivenProperty; + "line-translate": DataConstantProperty<[ + number, + number + ]>; + "line-translate-anchor": DataConstantProperty<"map" | "viewport">; + "line-width": DataDrivenProperty; + "line-gap-width": DataDrivenProperty; + "line-offset": DataDrivenProperty; + "line-blur": DataDrivenProperty; + "line-dasharray": CrossFadedProperty>; + "line-pattern": CrossFadedDataDrivenProperty; + "line-gradient": ColorRampProperty; +}; +export type LinePaintPropsPossiblyEvaluated = { + "line-opacity": PossiblyEvaluatedPropertyValue; + "line-color": PossiblyEvaluatedPropertyValue; + "line-translate": [ + number, + number + ]; + "line-translate-anchor": "map" | "viewport"; + "line-width": PossiblyEvaluatedPropertyValue; + "line-gap-width": PossiblyEvaluatedPropertyValue; + "line-offset": PossiblyEvaluatedPropertyValue; + "line-blur": PossiblyEvaluatedPropertyValue; + "line-dasharray": CrossFaded>; + "line-pattern": PossiblyEvaluatedPropertyValue>; + "line-gradient": ColorRampProperty; +}; +export declare class LineStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + gradientVersion: number; + stepInterpolant: boolean; + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + constructor(layer: LayerSpecification); + _handleSpecialPaintPropertyUpdate(name: string): void; + gradientExpression(): import("@maplibre/maplibre-gl-style-spec").StylePropertyExpression; + recalculate(parameters: EvaluationParameters, availableImages: Array): void; + createBucket(parameters: BucketParameters): LineBucket; + queryRadius(bucket: Bucket): number; + queryIntersectsFeature(queryGeometry: Array, feature: VectorTileFeature, featureState: FeatureState, geometry: Array>, zoom: number, transform: Transform, pixelsToTileUnits: number): boolean; + isTileClipped(): boolean; +} +export type TypedStyleLayer = CircleStyleLayer | FillStyleLayer | FillExtrusionStyleLayer | HeatmapStyleLayer | HillshadeStyleLayer | LineStyleLayer | SymbolStyleLayer; +export type BucketParameters = { + index: number; + layers: Array; + zoom: number; + pixelRatio: number; + overscaling: number; + collisionBoxArray: CollisionBoxArray; + sourceLayerIndex: number; + sourceID: string; +}; +export type PopulateParameters = { + featureIndex: FeatureIndex; + iconDependencies: {}; + patternDependencies: {}; + glyphDependencies: {}; + availableImages: Array; +}; +export type IndexedFeature = { + feature: VectorTileFeature; + id: number | string; + index: number; + sourceLayerIndex: number; +}; +export type BucketFeature = { + index: number; + sourceLayerIndex: number; + geometry: Array>; + properties: any; + type: 0 | 1 | 2 | 3; + id?: any; + readonly patterns: { + [_: string]: { + "min": string; + "mid": string; + "max": string; + }; + }; + sortKey?: number; +}; +/** + * The `Bucket` interface is the single point of knowledge about turning vector + * tiles into WebGL buffers. + * + * `Bucket` is an abstract interface. An implementation exists for each style layer type. + * Create a bucket via the `StyleLayer#createBucket` method. + * + * The concrete bucket types, using layout options from the style layer, + * transform feature geometries into vertex and index data for use by the + * vertex shader. They also (via `ProgramConfiguration`) use feature + * properties and the zoom level to populate the attributes needed for + * data-driven styling. + * + * Buckets are designed to be built on a worker thread and then serialized and + * transferred back to the main thread for rendering. On the worker side, a + * bucket's vertex, index, and attribute data is stored in `bucket.arrays: ArrayGroup`. + * When a bucket's data is serialized and sent back to the main thread, + * is gets deserialized (using `new Bucket(serializedBucketData)`, with + * the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups + * hold the same data as ArrayGroups, but are tuned for consumption by WebGL. + */ +export interface Bucket { + layerIds: Array; + hasPattern: boolean; + readonly layers: Array; + readonly stateDependentLayers: Array; + readonly stateDependentLayerIds: Array; + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }): void; + isEmpty(): boolean; + upload(context: Context): void; + uploadPending(): boolean; + /** + * Release the WebGL resources associated with the buffers. Note that because + * buckets are shared between layers having the same layout properties, they + * must be destroyed in groups (all buckets for a tile, or all symbol buckets). + */ + destroy(): void; +} +/** + * @param gl - The map's gl context. + * @param matrix - The map's camera matrix. It projects spherical mercator + * coordinates to gl coordinates. The spherical mercator coordinate `[0, 0]` represents the + * top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When + * the `renderingMode` is `"3d"`, the z coordinate is conformal. A box with identical x, y, and z + * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate.fromLngLat} + * can be used to project a `LngLat` to a mercator coordinate. + */ +export type CustomRenderMethod = (gl: WebGLRenderingContext | WebGL2RenderingContext, matrix: mat4) => void; +/** + * Interface for custom style layers. This is a specification for + * implementers to model: it is not an exported method or class. + * + * Custom layers allow a user to render directly into the map's GL context using the map's camera. + * These layers can be added between any regular layers using {@link Map#addLayer}. + * + * Custom layers must have a unique `id` and must have the `type` of `"custom"`. + * They must implement `render` and may implement `prerender`, `onAdd` and `onRemove`. + * They can trigger rendering using {@link Map#triggerRepaint} + * and they should appropriately handle {@link MapContextEvent} with `webglcontextlost` and `webglcontextrestored`. + * + * The `renderingMode` property controls whether the layer is treated as a `"2d"` or `"3d"` map layer. Use: + * - `"renderingMode": "3d"` to use the depth buffer and share it with other layers + * - `"renderingMode": "2d"` to add a layer with no depth. If you need to use the depth buffer for a `"2d"` layer you must use an offscreen + * framebuffer and {@link CustomLayerInterface#prerender} + * + * @example + * Custom layer implemented as ES6 class + * ```ts + * class NullIslandLayer { + * constructor() { + * this.id = 'null-island'; + * this.type = 'custom'; + * this.renderingMode = '2d'; + * } + * + * onAdd(map, gl) { + * const vertexSource = ` + * uniform mat4 u_matrix; + * void main() { + * gl_Position = u_matrix * vec4(0.5, 0.5, 0.0, 1.0); + * gl_PointSize = 20.0; + * }`; + * + * const fragmentSource = ` + * void main() { + * fragColor = vec4(1.0, 0.0, 0.0, 1.0); + * }`; + * + * const vertexShader = gl.createShader(gl.VERTEX_SHADER); + * gl.shaderSource(vertexShader, vertexSource); + * gl.compileShader(vertexShader); + * const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + * gl.shaderSource(fragmentShader, fragmentSource); + * gl.compileShader(fragmentShader); + * + * this.program = gl.createProgram(); + * gl.attachShader(this.program, vertexShader); + * gl.attachShader(this.program, fragmentShader); + * gl.linkProgram(this.program); + * } + * + * render(gl, matrix) { + * gl.useProgram(this.program); + * gl.uniformMatrix4fv(gl.getUniformLocation(this.program, "u_matrix"), false, matrix); + * gl.drawArrays(gl.POINTS, 0, 1); + * } + * } + * + * map.on('load', function() { + * map.addLayer(new NullIslandLayer()); + * }); + * ``` + */ +export interface CustomLayerInterface { + /** + * A unique layer id. + */ + id: string; + /** + * The layer's type. Must be `"custom"`. + */ + type: "custom"; + /** + * Either `"2d"` or `"3d"`. Defaults to `"2d"`. + */ + renderingMode?: "2d" | "3d"; + /** + * Called during a render frame allowing the layer to draw into the GL context. + * + * The layer can assume blending and depth state is set to allow the layer to properly + * blend and clip other layers. The layer cannot make any other assumptions about the + * current GL state. + * + * If the layer needs to render to a texture, it should implement the `prerender` method + * to do this and only use the `render` method for drawing directly into the main framebuffer. + * + * The blend function is set to `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. This expects + * colors to be provided in premultiplied alpha form where the `r`, `g` and `b` values are already + * multiplied by the `a` value. If you are unable to provide colors in premultiplied form you + * may want to change the blend function to + * `gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. + */ + render: CustomRenderMethod; + /** + * Optional method called during a render frame to allow a layer to prepare resources or render into a texture. + * + * The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering. + */ + prerender?: CustomRenderMethod; + /** + * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This + * gives the layer a chance to initialize gl resources and register event listeners. + * + * @param map - The Map this custom layer was just added to. + * @param gl - The gl context for the map. + */ + onAdd?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void; + /** + * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This + * gives the layer a chance to clean up gl resources and event listeners. + * + * @param map - The Map this custom layer was just added to. + * @param gl - The gl context for the map. + */ + onRemove?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void; +} +declare abstract class StyleLayer extends Evented { + id: string; + metadata: unknown; + type: LayerSpecification["type"] | CustomLayerInterface["type"]; + source: string; + sourceLayer: string; + minzoom: number; + maxzoom: number; + filter: FilterSpecification | void; + visibility: "visible" | "none" | void; + _crossfadeParameters: CrossfadeParameters; + _unevaluatedLayout: Layout; + readonly layout: unknown; + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + readonly paint: unknown; + _featureFilter: FeatureFilter; + readonly onAdd: ((map: Map) => void); + readonly onRemove: ((map: Map) => void); + queryRadius?(bucket: Bucket): number; + queryIntersectsFeature?(queryGeometry: Array, feature: VectorTileFeature, featureState: FeatureState, geometry: Array>, zoom: number, transform: Transform, pixelsToTileUnits: number, pixelPosMatrix: mat4): boolean | number; + constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{ + layout?: Properties; + paint?: Properties; + }>); + getCrossfadeParameters(): CrossfadeParameters; + getLayoutProperty(name: string): any; + setLayoutProperty(name: string, value: any, options?: StyleSetterOptions): void; + getPaintProperty(name: string): unknown; + setPaintProperty(name: string, value: unknown, options?: StyleSetterOptions): boolean; + _handleSpecialPaintPropertyUpdate(_: string): void; + _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean; + isHidden(zoom: number): boolean; + updateTransitions(parameters: TransitionParameters): void; + hasTransition(): boolean; + recalculate(parameters: EvaluationParameters, availableImages: Array): void; + serialize(): LayerSpecification; + _validate(validate: Function, key: string, name: string, value: unknown, options?: StyleSetterOptions): boolean; + is3D(): boolean; + isTileClipped(): boolean; + hasOffscreenPass(): boolean; + resize(): void; + isStateDependent(): boolean; +} +export type LightPosition = { + x: number; + y: number; + z: number; +}; +export declare class LightPositionProperty implements Property<[ + number, + number, + number +], LightPosition> { + specification: StylePropertySpecification; + constructor(); + possiblyEvaluate(value: PropertyValue<[ + number, + number, + number + ], LightPosition>, parameters: EvaluationParameters): LightPosition; + interpolate(a: LightPosition, b: LightPosition, t: number): LightPosition; +} +export type Props = { + "anchor": DataConstantProperty<"map" | "viewport">; + "position": LightPositionProperty; + "color": DataConstantProperty; + "intensity": DataConstantProperty; +}; +export type PropsPossiblyEvaluated = { + "anchor": "map" | "viewport"; + "position": LightPosition; + "color": Color; + "intensity": number; +}; +export declare class Light extends Evented { + _transitionable: Transitionable; + _transitioning: Transitioning; + properties: PossiblyEvaluated; + constructor(lightOptions?: LightSpecification); + getLight(): LightSpecification; + setLight(light?: LightSpecification, options?: StyleSetterOptions): void; + updateTransitions(parameters: TransitionParameters): void; + hasTransition(): boolean; + recalculate(parameters: EvaluationParameters): void; + _validate(validate: Function, value: unknown, options?: { + validate?: boolean; + }): boolean; +} +/** + * The overlap mode for properties like `icon-overlap`and `text-overlap` + */ +export type OverlapMode = "never" | "always" | "cooperative"; +export type QueryResult = { + key: T; + x1: number; + y1: number; + x2: number; + y2: number; +}; +/** + * A key for the grid + */ +export type GridKey = { + overlapMode?: OverlapMode; +}; +export declare class GridIndex { + circleKeys: Array; + boxKeys: Array; + boxCells: Array>; + circleCells: Array>; + bboxes: Array; + circles: Array; + xCellCount: number; + yCellCount: number; + width: number; + height: number; + xScale: number; + yScale: number; + boxUid: number; + circleUid: number; + constructor(width: number, height: number, cellSize: number); + keysLength(): number; + insert(key: T, x1: number, y1: number, x2: number, y2: number): void; + insertCircle(key: T, x: number, y: number, radius: number): void; + private _insertBoxCell; + private _insertCircleCell; + private _query; + query(x1: number, y1: number, x2: number, y2: number): Array>; + hitTest(x1: number, y1: number, x2: number, y2: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean; + hitTestCircle(x: number, y: number, radius: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean; + private _queryCell; + private _queryCellCircle; + private _forEachCell; + private _convertToXCellCoord; + private _convertToYCellCoord; + private _circlesCollide; + private _circleAndRectCollide; +} +export type FeatureKey = { + bucketInstanceId: number; + featureIndex: number; + collisionGroupID: number; + overlapMode: OverlapMode; +}; +export declare class CollisionIndex { + grid: GridIndex; + ignoredGrid: GridIndex; + transform: Transform; + pitchfactor: number; + screenRightBoundary: number; + screenBottomBoundary: number; + gridRightBoundary: number; + gridBottomBoundary: number; + perspectiveRatioCutoff: number; + constructor(transform: Transform, grid?: GridIndex, ignoredGrid?: GridIndex); + placeCollisionBox(collisionBox: SingleCollisionBox, overlapMode: OverlapMode, textPixelRatio: number, posMatrix: mat4, collisionGroupPredicate?: (key: FeatureKey) => boolean, getElevation?: (x: number, y: number) => number): { + box: Array; + offscreen: boolean; + }; + placeCollisionCircles(overlapMode: OverlapMode, symbol: any, lineVertexArray: SymbolLineVertexArray, glyphOffsetArray: GlyphOffsetArray, fontSize: number, posMatrix: mat4, labelPlaneMatrix: mat4, labelToScreenMatrix: mat4, showCollisionCircles: boolean, pitchWithMap: boolean, collisionGroupPredicate: (key: FeatureKey) => boolean, circlePixelDiameter: number, textPixelPadding: number, getElevation: (x: number, y: number) => number): { + circles: Array; + offscreen: boolean; + collisionDetected: boolean; + }; + /** + * Because the geometries in the CollisionIndex are an approximation of the shape of + * symbols on the map, we use the CollisionIndex to look up the symbol part of + * `queryRenderedFeatures`. + */ + queryRenderedSymbols(viewportQueryGeometry: Array): {}; + insertCollisionBox(collisionBox: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number): void; + insertCollisionCircles(collisionCircles: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number): void; + projectAndGetPerspectiveRatio(posMatrix: mat4, x: number, y: number, getElevation?: (x: number, y: number) => number): { + point: Point; + perspectiveRatio: number; + }; + isOffscreen(x1: number, y1: number, x2: number, y2: number): boolean; + isInsideGrid(x1: number, y1: number, x2: number, y2: number): boolean; + getViewportMatrix(): mat4; +} +declare enum TextAnchorEnum { + "center" = 1, + "left" = 2, + "right" = 3, + "top" = 4, + "bottom" = 5, + "top-left" = 6, + "top-right" = 7, + "bottom-left" = 8, + "bottom-right" = 9 +} +export type TextAnchor = keyof typeof TextAnchorEnum; +export declare class OpacityState { + opacity: number; + placed: boolean; + constructor(prevState: OpacityState, increment: number, placed: boolean, skipFade?: boolean | null); + isHidden(): boolean; +} +export declare class JointOpacityState { + text: OpacityState; + icon: OpacityState; + constructor(prevState: JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null); + isHidden(): boolean; +} +export declare class JointPlacement { + text: boolean; + icon: boolean; + skipFade: boolean; + constructor(text: boolean, icon: boolean, skipFade: boolean); +} +export declare class CollisionCircleArray { + invProjMatrix: mat4; + viewportMatrix: mat4; + circles: Array; + constructor(); +} +export declare class RetainedQueryData { + bucketInstanceId: number; + featureIndex: FeatureIndex; + sourceLayerIndex: number; + bucketIndex: number; + tileID: OverscaledTileID; + featureSortOrder: Array; + constructor(bucketInstanceId: number, featureIndex: FeatureIndex, sourceLayerIndex: number, bucketIndex: number, tileID: OverscaledTileID); +} +export type CollisionGroup = { + ID: number; + predicate?: (key: FeatureKey) => boolean; +}; +export declare class CollisionGroups { + collisionGroups: { + [groupName: string]: CollisionGroup; + }; + maxGroupID: number; + crossSourceCollisions: boolean; + constructor(crossSourceCollisions: boolean); + get(sourceID: string): CollisionGroup; +} +export type VariableOffset = { + textOffset: [ + number, + number + ]; + width: number; + height: number; + anchor: TextAnchor; + textBoxScale: number; + prevAnchor?: TextAnchor; +}; +export type TileLayerParameters = { + bucket: SymbolBucket; + layout: PossiblyEvaluated; + posMatrix: mat4; + textLabelPlaneMatrix: mat4; + labelToScreenMatrix: mat4; + scale: number; + textPixelRatio: number; + holdingForFade: boolean; + collisionBoxArray: CollisionBoxArray; + partiallyEvaluatedTextSize: { + uSize: number; + uSizeT: number; + }; + collisionGroup: CollisionGroup; +}; +export type BucketPart = { + sortKey?: number | void; + symbolInstanceStart: number; + symbolInstanceEnd: number; + parameters: TileLayerParameters; +}; +export type CrossTileID = string | number; +export declare class Placement { + transform: Transform; + terrain: Terrain; + collisionIndex: CollisionIndex; + placements: { + [_ in CrossTileID]: JointPlacement; + }; + opacities: { + [_ in CrossTileID]: JointOpacityState; + }; + variableOffsets: { + [_ in CrossTileID]: VariableOffset; + }; + placedOrientations: { + [_ in CrossTileID]: number; + }; + commitTime: number; + prevZoomAdjustment: number; + lastPlacementChangeTime: number; + stale: boolean; + fadeDuration: number; + retainedQueryData: { + [_: number]: RetainedQueryData; + }; + collisionGroups: CollisionGroups; + prevPlacement: Placement; + zoomAtLastRecencyCheck: number; + collisionCircleArrays: { + [k in any]: CollisionCircleArray; + }; + constructor(transform: Transform, terrain: Terrain, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement); + getBucketParts(results: Array, styleLayer: StyleLayer, tile: Tile, sortAcrossTiles: boolean): void; + attemptAnchorPlacement(textAnchorOffset: TextAnchorOffset, textBox: SingleCollisionBox, width: number, height: number, textBoxScale: number, rotateWithMap: boolean, pitchWithMap: boolean, textPixelRatio: number, posMatrix: mat4, collisionGroup: CollisionGroup, textOverlapMode: OverlapMode, symbolInstance: SymbolInstance, bucket: SymbolBucket, orientation: number, iconBox?: SingleCollisionBox | null, getElevation?: (x: number, y: number) => number): { + shift: Point; + placedGlyphBoxes: { + box: Array; + offscreen: boolean; + }; + }; + placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: { + [k in string | number]: boolean; + }, showCollisionBoxes: boolean): void; + markUsedJustification(bucket: SymbolBucket, placedAnchor: TextAnchor, symbolInstance: SymbolInstance, orientation: number): void; + markUsedOrientation(bucket: SymbolBucket, orientation: number, symbolInstance: SymbolInstance): void; + commit(now: number): void; + updateLayerOpacities(styleLayer: StyleLayer, tiles: Array): void; + updateBucketOpacities(bucket: SymbolBucket, seenCrossTileIDs: { + [k in string | number]: boolean; + }, collisionBoxArray?: CollisionBoxArray | null): void; + symbolFadeChange(now: number): number; + zoomAdjustment(zoom: number): number; + hasTransitions(now: number): boolean; + stillRecent(now: number, zoom: number): boolean; + setStale(): void; +} +/** + * Options to pass to query the map for the rendered features + */ +export type QueryRenderedFeaturesOptions = { + /** + * An array of [style layer IDs](https://maplibre.org/maplibre-style-spec/#layer-id) for the query to inspect. + * Only features within these layers will be returned. If this parameter is undefined, all layers will be checked. + */ + layers?: Array; + /** + * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) to limit query results. + */ + filter?: FilterSpecification; + /** + * An array of string representing the available images + */ + availableImages?: Array; + /** + * Whether to check if the [options.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. + */ + validate?: boolean; +}; +/** + * The options object related to the {@link Map#queryRenderedFeatures} method + */ +export type QuerySourceFeatureOptions = { + /** + * The name of the source layer to query. *For vector tile sources, this parameter is required.* For GeoJSON sources, it is ignored. + */ + sourceLayer?: string; + /** + * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) + * to limit query results. + */ + filter?: FilterSpecification; + /** + * Whether to check if the [parameters.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. + * @defaultValue true + */ + validate?: boolean; +}; +declare const status: { + unavailable: string; + deferred: string; + loading: string; + loaded: string; + error: string; +}; +export type PluginState = { + pluginStatus: typeof status[keyof typeof status]; + pluginURL: string; +}; +export type PluginStateSyncCallback = (state: PluginState) => void; +declare const registerForPluginStateChange: (callback: PluginStateSyncCallback) => PluginStateSyncCallback; +export declare class LayerPlacement { + _sortAcrossTiles: boolean; + _currentTileIndex: number; + _currentPartIndex: number; + _seenCrossTileIDs: { + [k in string | number]: boolean; + }; + _bucketParts: Array; + constructor(styleLayer: SymbolStyleLayer); + continuePlacement(tiles: Array, placement: Placement, showCollisionBoxes: boolean, styleLayer: StyleLayer, shouldPausePlacement: () => boolean): boolean; +} +export declare class PauseablePlacement { + placement: Placement; + _done: boolean; + _currentPlacementIndex: number; + _forceFullPlacement: boolean; + _showCollisionBoxes: boolean; + _inProgressLayer: LayerPlacement; + constructor(transform: Transform, terrain: Terrain, order: Array, forceFullPlacement: boolean, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement); + isDone(): boolean; + continuePlacement(order: Array, layers: { + [_: string]: StyleLayer; + }, layerTiles: { + [_: string]: Array; + }): void; + commit(now: number): Placement; +} +export type ValidationError = { + message: string; + line: number; + identifier?: string; +}; +export type Validator = (a: any) => ReadonlyArray; +/** + * A feature identifier that is bound to a source + */ +export type FeatureIdentifier = { + /** + * Unique id of the feature. + */ + id?: string | number | undefined; + /** + * The id of the vector or GeoJSON source for the feature. + */ + source: string; + /** + * *For vector tile sources, `sourceLayer` is required.* + */ + sourceLayer?: string | undefined; +}; +/** + * The options object related to the {@link Map}'s style related methods + */ +export type StyleOptions = { + /** + * If false, style validation will be skipped. Useful in production environment. + */ + validate?: boolean; + /** + * Defines a CSS + * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges. + * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold). + * Set to `false`, to enable font settings from the map's style for these glyph ranges. + * Forces a full update. + */ + localIdeographFontFamily?: string; +}; +/** + * Supporting type to add validation to another style related type + */ +export type StyleSetterOptions = { + /** + * Whether to check if the filter conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. + */ + validate?: boolean; +}; +/** + * Part of {@link Map#setStyle} options, transformStyle is a convenience function that allows to modify a style after it is fetched but before it is committed to the map state + * this function exposes previous and next styles, it can be commonly used to support a range of functionalities like: + * when previous style carries certain 'state' that needs to be carried over to a new style gracefully + * when a desired style is a certain combination of previous and incoming style + * when an incoming style requires modification based on external state + * + * @param previousStyle - The current style. + * @param nextStyle - The next style. + * @returns resulting style that will to be applied to the map + * + * @example + * ```ts + * map.setStyle('https://demotiles.maplibre.org/style.json', { + * transformStyle: (previousStyle, nextStyle) => ({ + * ...nextStyle, + * sources: { + * ...nextStyle.sources, + * // copy a source from previous style + * 'osm': previousStyle.sources.osm + * }, + * layers: [ + * // background layer + * nextStyle.layers[0], + * // copy a layer from previous style + * previousStyle.layers[0], + * // other layers from the next style + * ...nextStyle.layers.slice(1).map(layer => { + * // hide the layers we don't need from demotiles style + * if (layer.id.startsWith('geolines')) { + * layer.layout = {...layer.layout || {}, visibility: 'none'}; + * // filter out US polygons + * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) { + * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA']; + * } + * return layer; + * }) + * ] + * }) + * }); + * ``` + */ +export type TransformStyleFunction = (previous: StyleSpecification | undefined, next: StyleSpecification) => StyleSpecification; +/** + * The options object related to the {@link Map}'s style related methods + */ +export type StyleSwapOptions = { + /** + * If false, force a 'full' update, removing the current style + * and building the given one instead of attempting a diff-based update. + */ + diff?: boolean; + /** + * TransformStyleFunction is a convenience function + * that allows to modify a style after it is fetched but before it is committed to the map state. Refer to {@link TransformStyleFunction}. + */ + transformStyle?: TransformStyleFunction; +}; +/** + * Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification} + * or a {@link CustomLayerInterface}, a {@link LayerSpecification} with an embedded {@link SourceSpecification} can also be provided. + */ +export type AddLayerObject = LayerSpecification | (Omit & { + source: SourceSpecification; +}) | CustomLayerInterface; +export declare class Style extends Evented { + map: Map; + stylesheet: StyleSpecification; + dispatcher: Dispatcher; + imageManager: ImageManager; + glyphManager: GlyphManager; + lineAtlas: LineAtlas; + light: Light; + _request: Cancelable; + _spriteRequest: Cancelable; + _layers: { + [_: string]: StyleLayer; + }; + _serializedLayers: { + [_: string]: LayerSpecification; + }; + _order: Array; + sourceCaches: { + [_: string]: SourceCache; + }; + zoomHistory: ZoomHistory; + _loaded: boolean; + _rtlTextPluginCallback: (a: any) => any; + _changed: boolean; + _updatedSources: { + [_: string]: "clear" | "reload"; + }; + _updatedLayers: { + [_: string]: true; + }; + _removedLayers: { + [_: string]: StyleLayer; + }; + _changedImages: { + [_: string]: true; + }; + _glyphsDidChange: boolean; + _updatedPaintProps: { + [layer: string]: true; + }; + _layerOrderChanged: boolean; + _spritesImagesIds: { + [spriteId: string]: string[]; + }; + _availableImages: Array; + crossTileSymbolIndex: CrossTileSymbolIndex; + pauseablePlacement: PauseablePlacement; + placement: Placement; + z: number; + static registerForPluginStateChange: typeof registerForPluginStateChange; + constructor(map: Map, options?: StyleOptions); + loadURL(url: string, options?: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification): void; + loadJSON(json: StyleSpecification, options?: StyleSetterOptions & StyleSwapOptions, previousStyle?: StyleSpecification): void; + loadEmpty(): void; + _load(json: StyleSpecification, options: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification): void; + private _createLayers; + _loadSprite(sprite: SpriteSpecification, isUpdate?: boolean, completion?: (err: Error) => void): void; + _unloadSprite(): void; + _validateLayer(layer: StyleLayer): void; + loaded(): boolean; + /** + * take an array of string IDs, and based on this._layers, generate an array of LayerSpecification + * @param ids - an array of string IDs, for which serialized layers will be generated. If omitted, all serialized layers will be returned + * @returns generated result + */ + private _serializeByIds; + /** + * Lazy initialization of this._serializedLayers dictionary and return it + * @returns this._serializedLayers dictionary + */ + private _serializedAllLayers; + hasTransitions(): boolean; + _checkLoaded(): void; + /** + * @internal + * Apply queued style updates in a batch and recalculate zoom-dependent paint properties. + */ + update(parameters: EvaluationParameters): void; + _updateTilesForChangedImages(): void; + _updateTilesForChangedGlyphs(): void; + _updateWorkerLayers(updatedIds: Array, removedIds: Array): void; + _resetUpdates(): void; + /** + * Update this style's state to match the given style JSON, performing only + * the necessary mutations. + * + * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec + * diff algorithm produces an operation that is not supported. + * + * @returns true if any changes were made; false otherwise + */ + setState(nextState: StyleSpecification, options?: StyleSwapOptions): boolean; + addImage(id: string, image: StyleImage): this; + updateImage(id: string, image: StyleImage): void; + getImage(id: string): StyleImage; + removeImage(id: string): this; + _afterImageUpdated(id: string): void; + listImages(): string[]; + addSource(id: string, source: SourceSpecification, options?: StyleSetterOptions): void; + /** + * Remove a source from this stylesheet, given its id. + * @param id - id of the source to remove + * @throws if no source is found with the given ID + * @returns `this`. + */ + removeSource(id: string): this; + /** + * Set the data of a GeoJSON source, given its id. + * @param id - id of the source + * @param data - GeoJSON source + */ + setGeoJSONSourceData(id: string, data: GeoJSON.GeoJSON | string): void; + /** + * Get a source by ID. + * @param id - ID of the desired source + * @returns source + */ + getSource(id: string): Source | undefined; + /** + * Add a layer to the map style. The layer will be inserted before the layer with + * ID `before`, or appended if `before` is omitted. + * @param layerObject - The style layer to add. + * @param before - ID of an existing layer to insert before + * @param options - Style setter options. + * @returns `this`. + */ + addLayer(layerObject: AddLayerObject, before?: string, options?: StyleSetterOptions): this; + /** + * Moves a layer to a different z-position. The layer will be inserted before the layer with + * ID `before`, or appended if `before` is omitted. + * @param id - ID of the layer to move + * @param before - ID of an existing layer to insert before + */ + moveLayer(id: string, before?: string): void; + /** + * Remove the layer with the given id from the style. + * + * If no such layer exists, an `error` event is fired. + * + * @param id - id of the layer to remove + * @event `error` - Fired if the layer does not exist + */ + removeLayer(id: string): void; + /** + * Return the style layer object with the given `id`. + * + * @param id - id of the desired layer + * @returns a layer, if one with the given `id` exists + */ + getLayer(id: string): StyleLayer | undefined; + /** + * Return the ids of all layers currently in the style, including custom layers, in order. + * + * @returns ids of layers, in order + */ + getLayersOrder(): string[]; + /** + * Checks if a specific layer is present within the style. + * + * @param id - the id of the desired layer + * @returns a boolean specifying if the given layer is present + */ + hasLayer(id: string): boolean; + setLayerZoomRange(layerId: string, minzoom?: number | null, maxzoom?: number | null): void; + setFilter(layerId: string, filter?: FilterSpecification | null, options?: StyleSetterOptions): void; + /** + * Get a layer's filter object + * @param layer - the layer to inspect + * @returns the layer's filter, if any + */ + getFilter(layer: string): FilterSpecification | void; + setLayoutProperty(layerId: string, name: string, value: any, options?: StyleSetterOptions): void; + /** + * Get a layout property's value from a given layer + * @param layerId - the layer to inspect + * @param name - the name of the layout property + * @returns the property value + */ + getLayoutProperty(layerId: string, name: string): any; + setPaintProperty(layerId: string, name: string, value: any, options?: StyleSetterOptions): void; + getPaintProperty(layer: string, name: string): unknown; + setFeatureState(target: FeatureIdentifier, state: any): void; + removeFeatureState(target: FeatureIdentifier, key?: string): void; + getFeatureState(target: FeatureIdentifier): any; + getTransition(): any; + serialize(): StyleSpecification; + _updateLayer(layer: StyleLayer): void; + _flattenAndSortRenderedFeatures(sourceResults: Array<{ + [key: string]: Array<{ + featureIndex: number; + feature: MapGeoJSONFeature; + }>; + }>): any[]; + queryRenderedFeatures(queryGeometry: any, params: QueryRenderedFeaturesOptions, transform: Transform): any[]; + querySourceFeatures(sourceID: string, params?: QuerySourceFeatureOptions): any[]; + addSourceType(name: string, SourceType: SourceClass, callback: Callback): void; + getLight(): LightSpecification; + setLight(lightOptions: LightSpecification, options?: StyleSetterOptions): void; + _validate(validate: Validator, key: string, value: any, props: any, options?: { + validate?: boolean; + }): boolean; + _remove(mapRemoved?: boolean): void; + _clearSource(id: string): void; + _reloadSource(id: string): void; + _updateSources(transform: Transform): void; + _generateCollisionBoxes(): void; + _updatePlacement(transform: Transform, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, forceFullPlacement?: boolean): boolean; + _releaseSymbolFadeTiles(): void; + getImages(mapId: string, params: { + icons: Array; + source: string; + tileID: OverscaledTileID; + type: string; + }, callback: Callback<{ + [_: string]: StyleImage; + }>): void; + getGlyphs(mapId: string, params: { + stacks: { + [_: string]: Array; + }; + source: string; + tileID: OverscaledTileID; + type: string; + }, callback: Callback<{ + [_: string]: { + [_: number]: StyleGlyph; + }; + }>): void; + getResource(mapId: string, params: RequestParameters, callback: ResponseCallback): Cancelable; + getGlyphsUrl(): string; + setGlyphs(glyphsUrl: string | null, options?: StyleSetterOptions): void; + /** + * Add a sprite. + * + * @param id - The id of the desired sprite + * @param url - The url to load the desired sprite from + * @param options - The style setter options + * @param completion - The completion handler + */ + addSprite(id: string, url: string, options?: StyleSetterOptions, completion?: (err: Error) => void): void; + /** + * Remove a sprite by its id. When the last sprite is removed, the whole `this.stylesheet.sprite` object becomes + * `undefined`. This falsy `undefined` value later prevents attempts to load the sprite when it's absent. + * + * @param id - the id of the sprite to remove + */ + removeSprite(id: string): void; + /** + * Get the current sprite value. + * + * @returns empty array when no sprite is set; id-url pairs otherwise + */ + getSprite(): { + id: string; + url: string; + }[]; + /** + * Set a new value for the style's sprite. + * + * @param sprite - new sprite value + * @param options - style setter options + * @param completion - the completion handler + */ + setSprite(sprite: SpriteSpecification, options?: StyleSetterOptions, completion?: (err: Error) => void): void; +} +export declare class Hash { + _map: Map; + _hashName: string; + constructor(hashName?: string | null); + /** + * Map element to listen for coordinate changes + * + * @param map - The map object + * @returns `this` + */ + addTo(map: Map): this; + /** + * Removes hash + * + * @returns `this` + */ + remove(): this; + getHashString(mapFeedback?: boolean): string; + _getCurrentHash: () => any; + _onHashChange: () => boolean; + _updateHashUnthrottled: () => void; + /** + * Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds. + */ + _updateHash: () => ReturnType; +} +export interface DragMovementResult { + bearingDelta?: number; + pitchDelta?: number; + around?: Point; + panDelta?: Point; +} +export interface DragPanResult extends DragMovementResult { + around: Point; + panDelta: Point; +} +export interface DragRotateResult extends DragMovementResult { + bearingDelta: number; +} +export interface DragPitchResult extends DragMovementResult { + pitchDelta: number; +} +export interface DragMoveHandler extends Handler { + dragStart: (e: E, point: Point) => void; + dragMove: (e: E, point: Point) => T | void; + dragEnd: (e: E) => void; + getClickTolerance: () => number; +} +export interface MousePanHandler extends DragMoveHandler { +} +export interface MouseRotateHandler extends DragMoveHandler { +} +export interface MousePitchHandler extends DragMoveHandler { +} +export declare class TouchPanHandler implements Handler { + _enabled: boolean; + _active: boolean; + _touches: { + [k in string | number]: Point; + }; + _minTouches: number; + _clickTolerance: number; + _sum: Point; + _map: Map; + _cancelCooperativeMessage: boolean; + constructor(options: { + clickTolerance: number; + cooperativeGestures: boolean | GestureOptions; + }, map: Map); + reset(): void; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): { + around: Point; + panDelta: Point; + }; + touchmove(e: TouchEvent, points: Array, mapTouches: Array): { + around: Point; + panDelta: Point; + }; + touchend(e: TouchEvent, points: Array, mapTouches: Array): void; + touchcancel(): void; + _calculateTransform(e: TouchEvent, points: Array, mapTouches: Array): { + around: Point; + panDelta: Point; + }; + enable(): void; + disable(): void; + isEnabled(): boolean; + isActive(): boolean; +} +/** + * A {@link DragPanHandler} options object + */ +export type DragPanOptions = { + /** + * factor used to scale the drag velocity + * @defaultValue 0 + */ + linearity?: number; + /** + * easing function applled to `map.panTo` when applying the drag. + * @param t - the easing function + * @defaultValue bezier(0, 0, 0.3, 1) + */ + easing?: (t: number) => number; + /** + * the maximum value of the drag velocity. + * @defaultValue 1400 + */ + deceleration?: number; + /** + * the rate at which the speed reduces after the pan ends. + * @defaultValue 2500 + */ + maxSpeed?: number; +}; +export declare class DragPanHandler { + _el: HTMLElement; + _mousePan: MousePanHandler; + _touchPan: TouchPanHandler; + _inertiaOptions: DragPanOptions | boolean; + /** @internal */ + constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler); + /** + * Enables the "drag to pan" interaction. + * + * @param options - Options object + * @example + * ```ts + * map.dragPan.enable(); + * map.dragPan.enable({ + * linearity: 0.3, + * easing: bezier(0, 0, 0.3, 1), + * maxSpeed: 1400, + * deceleration: 2500, + * }); + * ``` + */ + enable(options?: DragPanOptions | boolean): void; + /** + * Disables the "drag to pan" interaction. + * + * @example + * ```ts + * map.dragPan.disable(); + * ``` + */ + disable(): void; + /** + * Returns a Boolean indicating whether the "drag to pan" interaction is enabled. + * + * @returns `true` if the "drag to pan" interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to pan" interaction is active. + */ + isActive(): boolean; +} +export declare class HandlerInertia { + _map: Map; + _inertiaBuffer: Array<{ + time: number; + settings: any; + }>; + constructor(map: Map); + clear(): void; + record(settings: any): void; + _drainInertiaBuffer(): void; + _onMoveEnd(panInertiaOptions?: DragPanOptions | boolean): any; +} +export type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent; +/** + * Handlers interpret dom events and return camera changes that should be + * applied to the map (`HandlerResult`s). The camera changes are all deltas. + * The handler itself should have no knowledge of the map's current state. + * This makes it easier to merge multiple results and keeps handlers simpler. + * For example, if there is a mousedown and mousemove, the mousePan handler + * would return a `panDelta` on the mousemove. + */ +export interface Handler { + enable(): void; + disable(): void; + isEnabled(): boolean; + isActive(): boolean; + /** + * `reset` can be called by the manager at any time and must reset everything to it's original state + */ + reset(): void; + readonly touchstart?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchmove?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchmoveWindow?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchend?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchcancel?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly contextmenu?: (e: MouseEvent) => HandlerResult | void; + readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void; + readonly keydown?: (e: KeyboardEvent) => HandlerResult | void; + readonly keyup?: (e: KeyboardEvent) => HandlerResult | void; + /** + * `renderFrame` is the only non-dom event. It is called during render + * frames and can be used to smooth camera changes (see scroll handler). + */ + readonly renderFrame?: () => HandlerResult | void; +} +/** + * All handler methods that are called with events can optionally return a `HandlerResult`. + */ +export type HandlerResult = { + panDelta?: Point; + zoomDelta?: number; + bearingDelta?: number; + pitchDelta?: number; + /** + * the point to not move when changing the camera + */ + around?: Point | null; + /** + * same as above, except for pinch actions, which are given higher priority + */ + pinchAround?: Point | null; + /** + * A method that can fire a one-off easing by directly changing the map's camera. + */ + cameraAnimation?: (map: Map) => any; + /** + * The last three properties are needed by only one handler: scrollzoom. + * The DOM event to be used as the `originalEvent` on any camera change events. + */ + originalEvent?: Event; + /** + * Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom). + */ + needsRenderFrame?: boolean; + /** + * The camera changes won't get recorded for inertial zooming. + */ + noInertia?: boolean; +}; +export type EventInProgress = { + handlerName: string; + originalEvent: Event; +}; +export type EventsInProgress = { + zoom?: EventInProgress; + pitch?: EventInProgress; + rotate?: EventInProgress; + drag?: EventInProgress; +}; +export declare class HandlerManager { + _map: Map; + _el: HTMLElement; + _handlers: Array<{ + handlerName: string; + handler: Handler; + allowed: Array; + }>; + _eventsInProgress: EventsInProgress; + _frameId: number; + _inertia: HandlerInertia; + _bearingSnap: number; + _handlersById: { + [x: string]: Handler; + }; + _updatingCamera: boolean; + _changes: Array<[ + HandlerResult, + EventsInProgress, + { + [handlerName: string]: Event; + } + ]>; + _terrainMovement: boolean; + _zoom: { + handlerName: string; + }; + _previousActiveHandlers: { + [x: string]: Handler; + }; + _listeners: Array<[ + Window | Document | HTMLElement, + string, + { + passive?: boolean; + capture?: boolean; + } | undefined + ]>; + constructor(map: Map, options: CompleteMapOptions); + destroy(): void; + _addDefaultHandlers(options: CompleteMapOptions): void; + _add(handlerName: string, handler: Handler, allowed?: Array): void; + stop(allowEndAnimation: boolean): void; + isActive(): boolean; + isZooming(): boolean; + isRotating(): boolean; + isMoving(): boolean; + _blockedByActive(activeHandlers: { + [x: string]: Handler; + }, allowed: Array, myName: string): boolean; + handleWindowEvent: (e: { + type: "mousemove" | "mouseup" | "touchmove"; + }) => void; + _getMapTouches(touches: TouchList): TouchList; + handleEvent: (e: Event, eventName?: keyof Handler) => void; + mergeHandlerResult(mergedHandlerResult: HandlerResult, eventsInProgress: EventsInProgress, handlerResult: HandlerResult, name: string, e?: InputEvent): void; + _applyChanges(): void; + _updateMapTransform(combinedResult: HandlerResult, combinedEventsInProgress: EventsInProgress, deactivatedHandlers: { + [handlerName: string]: Event; + }): void; + _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: { + [handlerName: string]: Event; + }, allowEndAnimation: boolean): void; + _fireEvent(type: string, e?: Event): void; + _requestFrame(): number; + _triggerRenderFrame(): void; +} +export type TaskID = number; +export type Task = { + callback: (timeStamp: number) => void; + id: TaskID; + cancelled: boolean; +}; +export declare class TaskQueue { + _queue: Array; + _id: TaskID; + _cleared: boolean; + _currentlyRunning: Array | false; + constructor(); + add(callback: (timeStamp: number) => void): TaskID; + remove(id: TaskID): void; + run(timeStamp?: number): void; + clear(): void; +} +/** + * A [Point](https://github.com/mapbox/point-geometry) or an array of two numbers representing `x` and `y` screen coordinates in pixels. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let p1 = new Point(-77, 38); // a PointLike which is a Point + * let p2 = [-77, 38]; // a PointLike which is an array of two numbers + * ``` + */ +export type PointLike = Point | [ + number, + number +]; +/** + * A helper to allow require of at least one propery + */ +export type RequireAtLeastOne = { + [K in keyof T]-?: Required> & Partial>>; +}[keyof T]; +/** + * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location, + * zoom, bearing, and pitch of the camera. All properties are optional, and when a property is omitted, the current + * camera value for that property will remain unchanged. + * + * @example + * Set the map's initial perspective with CameraOptions + * ```ts + * let map = new maplibregl.Map({ + * container: 'map', + * style: 'https://demotiles.maplibre.org/style.json', + * center: [-73.5804, 45.53483], + * pitch: 60, + * bearing: -60, + * zoom: 10 + * }); + * ``` + * @see [Set pitch and bearing](https://maplibre.org/maplibre-gl-js/docs/examples/set-perspective/) + * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/) + * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/) + * @see [Display buildings in 3D](https://maplibre.org/maplibre-gl-js/docs/examples/3d-buildings/) + */ +export type CameraOptions = CenterZoomBearing & { + /** + * The desired pitch in degrees. The pitch is the angle towards the horizon + * measured in degrees with a range between 0 and 60 degrees. For example, pitch: 0 provides the appearance + * of looking straight down at the map, while pitch: 60 tilts the user's perspective towards the horizon. + * Increasing the pitch value is often used to display 3D objects. + */ + pitch?: number; + /** + * If `zoom` is specified, `around` determines the point around which the zoom is centered. + */ + around?: LngLatLike; +}; +/** + * Holds center, zoom and bearing properties + */ +export type CenterZoomBearing = { + /** + * The desired center. + */ + center?: LngLatLike; + /** + * The desired zoom level. + */ + zoom?: number; + /** + * The desired bearing in degrees. The bearing is the compass direction that + * is "up". For example, `bearing: 90` orients the map so that east is up. + */ + bearing?: number; +}; +/** + * The options object related to the {@link Map#jumpTo} method + */ +export type JumpToOptions = CameraOptions & { + /** + * Dimensions in pixels applied on each side of the viewport for shifting the vanishing point. + */ + padding?: PaddingOptions; +}; +/** + * A options object for the {@link Map#cameraForBounds} method + */ +export type CameraForBoundsOptions = CameraOptions & { + /** + * The amount of padding in pixels to add to the given bounds. + */ + padding?: number | RequireAtLeastOne; + /** + * The center of the given bounds relative to the map's center, measured in pixels. + * @defaultValue [0, 0] + */ + offset?: PointLike; + /** + * The maximum zoom level to allow when the camera would transition to the specified bounds. + */ + maxZoom?: number; +}; +/** + * The {@link Map#flyTo} options object + */ +export type FlyToOptions = AnimationOptions & CameraOptions & { + /** + * The zooming "curve" that will occur along the + * flight path. A high value maximizes zooming for an exaggerated animation, while a low + * value minimizes zooming for an effect closer to {@link Map#easeTo}. 1.42 is the average + * value selected by participants in the user study discussed in + * [van Wijk (2003)](https://www.win.tue.nl/~vanwijk/zoompan.pdf). A value of + * `Math.pow(6, 0.25)` would be equivalent to the root mean squared average velocity. A + * value of 1 would produce a circular motion. + * @defaultValue 1.42 + */ + curve?: number; + /** + * The zero-based zoom level at the peak of the flight path. If + * `options.curve` is specified, this option is ignored. + */ + minZoom?: number; + /** + * The average speed of the animation defined in relation to + * `options.curve`. A speed of 1.2 means that the map appears to move along the flight path + * by 1.2 times `options.curve` screenfuls every second. A _screenful_ is the map's visible span. + * It does not correspond to a fixed physical distance, but varies by zoom level. + * @defaultValue 1.2 + */ + speed?: number; + /** + * The average speed of the animation measured in screenfuls + * per second, assuming a linear timing curve. If `options.speed` is specified, this option is ignored. + */ + screenSpeed?: number; + /** + * The animation's maximum duration, measured in milliseconds. + * If duration exceeds maximum duration, it resets to 0. + */ + maxDuration?: number; + /** + * The amount of padding in pixels to add to the given bounds. + */ + padding?: number | RequireAtLeastOne; +}; +export type EaseToOptions = AnimationOptions & CameraOptions & { + delayEndEvents?: number; + padding?: number | RequireAtLeastOne; +}; +/** + * Options for {@link Map#fitBounds} method + */ +export type FitBoundsOptions = FlyToOptions & { + /** + * If `true`, the map transitions using {@link Map#easeTo}. If `false`, the map transitions using {@link Map#flyTo}. + * See those functions and {@link AnimationOptions} for information about options available. + * @defaultValue false + */ + linear?: boolean; + /** + * The center of the given bounds relative to the map's center, measured in pixels. + * @defaultValue [0, 0] + */ + offset?: PointLike; + /** + * The maximum zoom level to allow when the map view transitions to the specified bounds. + */ + maxZoom?: number; +}; +/** + * Options common to map movement methods that involve animation, such as {@link Map#panBy} and + * {@link Map#easeTo}, controlling the duration and easing function of the animation. All properties + * are optional. + * + */ +export type AnimationOptions = { + /** + * The animation's duration, measured in milliseconds. + */ + duration?: number; + /** + * A function taking a time in the range 0..1 and returning a number where 0 is + * the initial state and 1 is the final state. + */ + easing?: (_: number) => number; + /** + * of the target center relative to real map container center at the end of animation. + */ + offset?: PointLike; + /** + * If `false`, no animation will occur. + */ + animate?: boolean; + /** + * If `true`, then the animation is considered essential and will not be affected by + * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/\@media/prefers-reduced-motion). + */ + essential?: boolean; + /** + * Default false. Needed in 3D maps to let the camera stay in a constant + * height based on sea-level. After the animation finished the zoom-level will be recalculated in respect of + * the distance from the camera to the center-coordinate-altitude. + */ + freezeElevation?: boolean; +}; +/** + * A callback hook that allows manipulating the camera and being notified about camera updates before they happen + */ +export type CameraUpdateTransformFunction = (next: { + center: LngLat; + zoom: number; + pitch: number; + bearing: number; + elevation: number; +}) => { + center?: LngLat; + zoom?: number; + pitch?: number; + bearing?: number; + elevation?: number; +}; +declare abstract class Camera extends Evented { + transform: Transform; + terrain: Terrain; + _moving: boolean; + _zooming: boolean; + _rotating: boolean; + _pitching: boolean; + _padding: boolean; + _bearingSnap: number; + _easeStart: number; + _easeOptions: { + duration?: number; + easing?: (_: number) => number; + }; + _easeId: string | void; + _onEaseFrame: (_: number) => void; + _onEaseEnd: (easeId?: string) => void; + _easeFrameId: TaskID; + /** + * @internal + * holds the geographical coordinate of the target + */ + _elevationCenter: LngLat; + /** + * @internal + * holds the targ altitude value, = center elevation of the target. + * This value may changes during flight, because new terrain-tiles loads during flight. + */ + _elevationTarget: number; + /** + * @internal + * holds the start altitude value, = center elevation before animation begins + * this value will recalculated during flight in respect of changing _elevationTarget values, + * so the linear interpolation between start and target keeps smooth and without jumps. + */ + _elevationStart: number; + /** + * @internal + * Saves the current state of the elevation freeze - this is used during map movement to prevent "rocky" camera movement. + */ + _elevationFreeze: boolean; + /** + * @internal + * Used to track accumulated changes during continuous interaction + */ + _requestedCameraState?: Transform; + /** + * A callback used to defer camera updates or apply arbitrary constraints. + * If specified, this Camera instance can be used as a stateless component in React etc. + */ + transformCameraUpdate: CameraUpdateTransformFunction | null; + abstract _requestRenderFrame(a: () => void): TaskID; + abstract _cancelRenderFrame(_: TaskID): void; + constructor(transform: Transform, options: { + bearingSnap: number; + }); + /** + * Returns the map's geographical centerpoint. + * + * @returns The map's geographical centerpoint. + * @example + * Return a LngLat object such as `{lng: 0, lat: 0}` + * ```ts + * let center = map.getCenter(); + * // access longitude and latitude values directly + * let {lng, lat} = map.getCenter(); + * ``` + */ + getCenter(): LngLat; + /** + * Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param center - The centerpoint to set. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * map.setCenter([-74, 38]); + * ``` + */ + setCenter(center: LngLatLike, eventData?: any): this; + /** + * Pans the map by the specified offset. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param offset - `x` and `y` coordinates by which to pan the map. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + panBy(offset: PointLike, options?: AnimationOptions, eventData?: any): this; + /** + * Pans the map to the specified location with an animated transition. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param lnglat - The location to pan the map to. + * @param options - Options describing the destination and animation of the transition. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * map.panTo([-74, 38]); + * // Specify that the panTo animation should last 5000 milliseconds. + * map.panTo([-74, 38], {duration: 5000}); + * ``` + * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/) + */ + panTo(lnglat: LngLatLike, options?: AnimationOptions, eventData?: any): this; + /** + * Returns the map's current zoom level. + * + * @returns The map's current zoom level. + * @example + * ```ts + * map.getZoom(); + * ``` + */ + getZoom(): number; + /** + * Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param zoom - The zoom level to set (0-20). + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom to the zoom level 5 without an animated transition + * ```ts + * map.setZoom(5); + * ``` + */ + setZoom(zoom: number, eventData?: any): this; + /** + * Zooms the map to the specified zoom level, with an animated transition. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param zoom - The zoom level to transition to. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // Zoom to the zoom level 5 without an animated transition + * map.zoomTo(5); + * // Zoom to the zoom level 8 with an animated transition + * map.zoomTo(8, { + * duration: 2000, + * offset: [100, 50] + * }); + * ``` + */ + zoomTo(zoom: number, options?: AnimationOptions | null, eventData?: any): this; + /** + * Increases the map's zoom level by 1. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom the map in one level with a custom animation duration + * ```ts + * map.zoomIn({duration: 1000}); + * ``` + */ + zoomIn(options?: AnimationOptions, eventData?: any): this; + /** + * Decreases the map's zoom level by 1. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom the map out one level with a custom animation offset + * ```ts + * map.zoomOut({offset: [80, 60]}); + * ``` + */ + zoomOut(options?: AnimationOptions, eventData?: any): this; + /** + * Returns the map's current bearing. The bearing is the compass direction that is "up"; for example, a bearing + * of 90° orients the map so that east is up. + * + * @returns The map's current bearing. + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + getBearing(): number; + /** + * Sets the map's bearing (rotation). The bearing is the compass direction that is "up"; for example, a bearing + * of 90° orients the map so that east is up. + * + * Equivalent to `jumpTo({bearing: bearing})`. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param bearing - The desired bearing. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Rotate the map to 90 degrees + * ```ts + * map.setBearing(90); + * ``` + */ + setBearing(bearing: number, eventData?: any): this; + /** + * Returns the current padding applied around the map viewport. + * + * @returns The current padding around the map viewport. + */ + getPadding(): PaddingOptions; + /** + * Sets the padding in pixels around the viewport. + * + * Equivalent to `jumpTo({padding: padding})`. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param padding - The desired padding. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Sets a left padding of 300px, and a top padding of 50px + * ```ts + * map.setPadding({ left: 300, top: 50 }); + * ``` + */ + setPadding(padding: PaddingOptions, eventData?: any): this; + /** + * Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction + * that is "up"; for example, a bearing of 90° orients the map so that east is up. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param bearing - The desired bearing. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + rotateTo(bearing: number, options?: AnimationOptions, eventData?: any): this; + /** + * Rotates the map so that north is up (0° bearing), with an animated transition. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + resetNorth(options?: AnimationOptions, eventData?: any): this; + /** + * Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + resetNorthPitch(options?: AnimationOptions, eventData?: any): this; + /** + * Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the + * `bearingSnap` threshold). + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + snapToNorth(options?: AnimationOptions, eventData?: any): this; + /** + * Returns the map's current pitch (tilt). + * + * @returns The map's current pitch, measured in degrees away from the plane of the screen. + */ + getPitch(): number; + /** + * Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`. + * + * Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`. + * + * @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60). + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + setPitch(pitch: number, eventData?: any): this; + /** + * @param bounds - Calculate the center for these bounds in the viewport and use + * the highest zoom level up to and including `Map#getMaxZoom()` that fits + * in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0. + * @param options - Options object + * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`. + * If map is unable to fit, method will warn and return undefined. + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * let newCameraTransform = map.cameraForBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + */ + cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CenterZoomBearing; + /** + * @internal + * Calculate the center of these two points in the viewport and use + * the highest zoom level up to and including `Map#getMaxZoom()` that fits + * the points in the viewport at the specified bearing. + * @param p0 - First point + * @param p1 - Second point + * @param bearing - Desired map bearing at end of animation, in degrees + * @param options - the camera options + * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`. + * If map is unable to fit, method will warn and return undefined. + * @example + * ```ts + * let p0 = [-79, 43]; + * let p1 = [-73, 45]; + * let bearing = 90; + * let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + */ + _cameraForBoxAndBearing(p0: LngLatLike, p1: LngLatLike, bearing: number, options?: CameraForBoundsOptions): CenterZoomBearing; + /** + * Pans and zooms the map to contain its visible area within the specified geographical bounds. + * This function will also reset the map's bearing to 0 if bearing is nonzero. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param bounds - Center these bounds in the viewport and use the highest + * zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport. + * @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/) + */ + fitBounds(bounds: LngLatBoundsLike, options?: FitBoundsOptions, eventData?: any): this; + /** + * Pans, rotates and zooms the map to to fit the box made by points p0 and p1 + * once the map is rotated to the specified bearing. To zoom without rotating, + * pass in the current map bearing. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`. + * + * @param p0 - First point on screen, in pixel coordinates + * @param p1 - Second point on screen, in pixel coordinates + * @param bearing - Desired map bearing at end of animation, in degrees + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * let p0 = [220, 400]; + * let p1 = [500, 900]; + * map.fitScreenCoordinates(p0, p1, map.getBearing(), { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * @see Used by {@link BoxZoomHandler} + */ + fitScreenCoordinates(p0: PointLike, p1: PointLike, bearing: number, options?: FitBoundsOptions, eventData?: any): this; + _fitInternal(calculatedOptions?: CenterZoomBearing, options?: FitBoundsOptions, eventData?: any): this; + /** + * Changes any combination of center, zoom, bearing, and pitch, without + * an animated transition. The map will retain its current values for any + * details not specified in `options`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // jump to coordinates at current zoom + * map.jumpTo({center: [0, 0]}); + * // jump with zoom, pitch, and bearing options + * map.jumpTo({ + * center: [0, 0], + * zoom: 8, + * pitch: 45, + * bearing: 90 + * }); + * ``` + * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/) + * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/) + */ + jumpTo(options: JumpToOptions, eventData?: any): this; + /** + * Calculates pitch, zoom and bearing for looking at `newCenter` with the camera position being `newCenter` + * and returns them as {@link CameraOptions}. + * @param from - The camera to look from + * @param altitudeFrom - The altitude of the camera to look from + * @param to - The center to look at + * @param altitudeTo - Optional altitude of the center to look at. If none given the ground height will be used. + * @returns the calculated camera options + */ + calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions; + /** + * Changes any combination of `center`, `zoom`, `bearing`, `pitch`, and `padding` with an animated transition + * between old and new values. The map will retain its current values for any + * details not specified in `options`. + * + * Note: The transition will happen instantly if the user has enabled + * the `reduced motion` accessibility feature enabled in their operating system, + * unless `options` includes `essential: true`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options describing the destination and animation of the transition. + * Accepts {@link CameraOptions} and {@link AnimationOptions}. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + easeTo(options: EaseToOptions & { + easeId?: string; + noMoveStart?: boolean; + }, eventData?: any): this; + _prepareEase(eventData: any, noMoveStart: boolean, currently?: any): void; + _prepareElevation(center: LngLat): void; + _updateElevation(k: number): void; + _finalizeElevation(): void; + /** + * @internal + * Called when the camera is about to be manipulated. + * If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes. + * This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls. + * It may differ from the state used for rendering (`this.transform`). + * @returns Transform to apply changes to + */ + _getTransformForUpdate(): Transform; + /** + * @internal + * Called after the camera is done being manipulated. + * @param tr - the requested camera end state + * Call `transformCameraUpdate` if present, and then apply the "approved" changes. + */ + _applyUpdatedTransform(tr: Transform): void; + _fireMoveEvents(eventData?: any): void; + _afterEase(eventData?: any, easeId?: string): void; + /** + * Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that + * evokes flight. The animation seamlessly incorporates zooming and panning to help + * the user maintain her bearings even after traversing a great distance. + * + * Note: The animation will be skipped, and this will behave equivalently to `jumpTo` + * if the user has the `reduced motion` accessibility feature enabled in their operating system, + * unless 'options' includes `essential: true`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options describing the destination and animation of the transition. + * Accepts {@link CameraOptions}, {@link AnimationOptions}, + * and the following additional options. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // fly with default options to null island + * map.flyTo({center: [0, 0], zoom: 9}); + * // using flyTo options + * map.flyTo({ + * center: [0, 0], + * zoom: 9, + * speed: 0.2, + * curve: 1, + * easing(t) { + * return t; + * } + * }); + * ``` + * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/) + * @see [Slowly fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto-options/) + * @see [Fly to a location based on scroll position](https://maplibre.org/maplibre-gl-js/docs/examples/scroll-fly-to/) + */ + flyTo(options: FlyToOptions, eventData?: any): this; + isEasing(): boolean; + /** + * Stops any animated transition underway. + * + * @returns `this` + */ + stop(): this; + _stop(allowGestures?: boolean, easeId?: string): this; + _ease(frame: (_: number) => void, finish: () => void, options: { + animate?: boolean; + duration?: number; + easing?: (_: number) => number; + }): void; + _renderFrameCallback: () => void; + _normalizeBearing(bearing: number, currentBearing: number): number; + _normalizeCenter(center: LngLat): void; + /** + * Query the current elevation of location. It return null if terrain is not enabled. the elevation is in meters relative to mean sea-level + * @param lngLatLike - [x,y] or LngLat coordinates of the location + * @returns elevation in meters + */ + queryTerrainElevation(lngLatLike: LngLatLike): number | null; +} +/** + * An event from the mouse relevant to a specific layer. + * + * @group Event Related + */ +export type MapLayerMouseEvent = MapMouseEvent & { + features?: MapGeoJSONFeature[]; +}; +/** + * An event from a touch device relevat to a specific layer. + * + * @group Event Related + */ +export type MapLayerTouchEvent = MapTouchEvent & { + features?: MapGeoJSONFeature[]; +}; +/** + * The source event data type + */ +export type MapSourceDataType = "content" | "metadata" | "visibility" | "idle"; +/** + * `MapLayerEventType` - a mapping between the event name and the event. + * **Note:** These events are compatible with the optional `layerId` parameter. + * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the + * event action contains a visible portion of the specified layer. + * The following example can be used for all the events. + * + * @group Event Related + * @example + * ```ts + * // Initialize the map + * let map = new maplibregl.Map({ // map options }); + * // Set an event listener for a specific layer + * map.on('the-event-name', 'poi-label', function(e) { + * console.log('An event has occurred on a visible portion of the poi-label layer'); + * }); + * ``` + */ +export type MapLayerEventType = { + /** + * Fired when a pointing device (usually a mouse) is pressed and released contains a visible portion of the specified layer. + * + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + click: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed and released twice contains a visible portion of the specified layer. + * + * **Note:** Under normal conditions, this event will be preceded by two `click` events. + */ + dblclick: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed while inside a visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mousedown: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is released while inside a visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mouseup: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved while the cursor is inside a visible portion of the specified layer. + * As you move the cursor across the layer, the event will fire every time the cursor changes position within that layer. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mousemove: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from + * outside that layer or outside the map canvas. + * + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + */ + mouseenter: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves + * the map canvas. + * + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + */ + mouseleave: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved inside a visible portion of the specified layer. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mouseover: MapLayerMouseEvent; + /** + * Fired when a point device (usually a mouse) leaves the visible portion of the specified layer. + */ + mouseout: MapLayerMouseEvent; + /** + * Fired when the right button of the mouse is clicked or the context menu key is pressed within visible portion of the specified layer. + */ + contextmenu: MapLayerMouseEvent; + /** + * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchstart: MapLayerTouchEvent; + /** + * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchend: MapLayerTouchEvent; + /** + * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchcancel: MapLayerTouchEvent; +}; +/** + * `MapEventType` - a mapping between the event name and the event value. + * These events are used with the {@link Map#on} method. + * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}. + * The following example can be used for all the events. + * + * @group Event Related + * @example + * ```ts + * // Initialize the map + * let map = new maplibregl.Map({ // map options }); + * // Set an event listener + * map.on('the-event-name', () => { + * console.log('An event has occurred!'); + * }); + * ``` + */ +export type MapEventType = { + /** + * Fired when an error occurs. This is GL JS's primary error reporting + * mechanism. We use an event instead of `throw` to better accommodate + * asynchronous operations. If no listeners are bound to the `error` event, the + * error will be printed to the console. + */ + error: ErrorEvent; + /** + * @event `load` Fired immediately after all necessary resources have been downloaded + * and the first visually complete rendering of the map has occurred. + * + * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/) + * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/) + */ + load: MapLibreEvent; + /** + * Fired after the last frame rendered before the map enters an + * "idle" state: + * + * - No camera transitions are in progress + * - All currently requested tiles have loaded + * - All fade/transition animations have completed + */ + idle: MapLibreEvent; + /** + * Fired immediately after the map has been removed with {@link Map#remove}. + */ + remove: MapLibreEvent; + /** + * Fired whenever the map is drawn to the screen, as the result of + * + * - a change to the map's position, zoom, pitch, or bearing + * - a change to the map's style + * - a change to a GeoJSON source + * - the loading of a vector tile, GeoJSON file, glyph, or sprite + */ + render: MapLibreEvent; + /** + * Fired immediately after the map has been resized. + */ + resize: MapLibreEvent; + /** + * Fired when the WebGL context is lost. + */ + webglcontextlost: MapContextEvent; + /** + * Fired when the WebGL context is restored. + */ + webglcontextrestored: MapContextEvent; + /** + * Fired when any map data (style, source, tile, etc) begins loading or + * changing asynchronously. All `dataloading` events are followed by a `data`, + * `dataabort` or `error` event. + */ + dataloading: MapDataEvent; + /** + * Fired when any map data loads or changes. See {@link MapDataEvent} for more information. + * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/) + */ + data: MapDataEvent; + tiledataloading: MapDataEvent; + /** + * Fired when one of the map's sources begins loading or changing asynchronously. + * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event. + */ + sourcedataloading: MapSourceDataEvent; + /** + * Fired when the map's style begins loading or changing asynchronously. + * All `styledataloading` events are followed by a `styledata` + * or `error` event. + */ + styledataloading: MapStyleDataEvent; + /** + * Fired when one of the map's sources loads or changes, including if a tile belonging + * to a source loads or changes. + */ + sourcedata: MapSourceDataEvent; + /** + * Fired when the map's style loads or changes. + */ + styledata: MapStyleDataEvent; + /** + * Fired when an icon or pattern needed by the style is missing. The missing image can + * be added with {@link Map#addImage} within this event listener callback to prevent the image from + * being skipped. This event can be used to dynamically generate icons and patterns. + * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/) + */ + styleimagemissing: MapStyleImageMissingEvent; + /** + * Fired when a request for one of the map's sources' tiles or data is aborted. + */ + dataabort: MapDataEvent; + /** + * Fired when a request for one of the map's sources' data is aborted. + */ + sourcedataabort: MapSourceDataEvent; + /** + * Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold. + * See {@link BoxZoomHandler}. + */ + boxzoomcancel: MapLibreZoomEvent; + /** + * Fired when a "box zoom" interaction starts. See {@link BoxZoomHandler}. + */ + boxzoomstart: MapLibreZoomEvent; + /** + * Fired when a "box zoom" interaction ends. See {@link BoxZoomHandler}. + */ + boxzoomend: MapLibreZoomEvent; + /** + * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map. + */ + touchcancel: MapTouchEvent; + /** + * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchmove: MapTouchEvent; + /** + * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchend: MapTouchEvent; + /** + * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchstart: MapTouchEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map. + * + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + click: MapMouseEvent; + /** + * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map. + */ + contextmenu: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession. + * + * **Note:** Under normal conditions, this event will be preceded by two `click` events. + */ + dblclick: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map. + * As you move the cursor across the map, the event will fire every time the cursor changes position within the map. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mousemove: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is released within the map. + * + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mouseup: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed within the map. + * + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mousedown: MapMouseEvent; + /** + * Fired when a point device (usually a mouse) leaves the map's canvas. + */ + mouseout: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved within the map. + * As you move the cursor across a web page containing a map, + * the event will fire each time it enters the map or any child elements. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mouseover: MapMouseEvent; + /** + * Fired just before the map begins a transition from one + * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}. + * + */ + movestart: MapLibreEvent; + /** + * Fired repeatedly during an animated transition from one view to + * another, as the result of either user interaction or methods such as {@link Map#flyTo}. + * + * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/) + */ + move: MapLibreEvent; + /** + * Fired just after the map completes a transition from one + * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}. + * + * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/) + */ + moveend: MapLibreEvent; + /** + * Fired just before the map begins a transition from one zoom level to another, + * as the result of either user interaction or methods such as {@link Map#flyTo}. + */ + zoomstart: MapLibreEvent; + /** + * Fired repeatedly during an animated transition from one zoom level to another, + * as the result of either user interaction or methods such as {@link Map#flyTo}. + */ + zoom: MapLibreEvent; + /** + * Fired just after the map completes a transition from one zoom level to another, + * as the result of either user interaction or methods such as {@link Map#flyTo}. + */ + zoomend: MapLibreEvent; + /** + * Fired when a "drag to rotate" interaction starts. See {@link DragRotateHandler}. + */ + rotatestart: MapLibreEvent; + /** + * Fired repeatedly during a "drag to rotate" interaction. See {@link DragRotateHandler}. + */ + rotate: MapLibreEvent; + /** + * Fired when a "drag to rotate" interaction ends. See {@link DragRotateHandler}. + */ + rotateend: MapLibreEvent; + /** + * Fired when a "drag to pan" interaction starts. See {@link DragPanHandler}. + */ + dragstart: MapLibreEvent; + /** + * Fired repeatedly during a "drag to pan" interaction. See {@link DragPanHandler}. + */ + drag: MapLibreEvent; + /** + * Fired when a "drag to pan" interaction ends. See {@link DragPanHandler}. + * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + dragend: MapLibreEvent; + /** + * Fired whenever the map's pitch (tilt) begins a change as + * the result of either user interaction or methods such as {@link Map#flyTo} . + */ + pitchstart: MapLibreEvent; + /** + * Fired repeatedly during the map's pitch (tilt) animation between + * one state and another as the result of either user interaction + * or methods such as {@link Map#flyTo}. + */ + pitch: MapLibreEvent; + /** + * Fired immediately after the map's pitch (tilt) finishes changing as + * the result of either user interaction or methods such as {@link Map#flyTo}. + */ + pitchend: MapLibreEvent; + /** + * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map. + */ + wheel: MapWheelEvent; + /** + * Fired when terrain is changed + */ + terrain: MapTerrainEvent; +}; +/** + * The base event for MapLibre + * + * @group Event Related + */ +export type MapLibreEvent = { + type: keyof MapEventType | keyof MapLayerEventType; + target: Map; + originalEvent: TOrig; +}; +/** + * The style data event + * + * @group Event Related + */ +export type MapStyleDataEvent = MapLibreEvent & { + dataType: "style"; +}; +/** + * The source data event interface + * + * @group Event Related + */ +export type MapSourceDataEvent = MapLibreEvent & { + dataType: "source"; + /** + * True if the event has a `dataType` of `source` and the source has no outstanding network requests. + */ + isSourceLoaded: boolean; + /** + * The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`. + */ + source: SourceSpecification; + sourceId: string; + sourceDataType: MapSourceDataType; + /** + * The tile being loaded or changed, if the event has a `dataType` of `source` and + * the event is related to loading of a tile. + */ + tile: any; +}; +export declare class MapMouseEvent extends Event implements MapLibreEvent { + /** + * The event type + */ + type: "mousedown" | "mouseup" | "click" | "dblclick" | "mousemove" | "mouseover" | "mouseenter" | "mouseleave" | "mouseout" | "contextmenu"; + /** + * The `Map` object that fired the event. + */ + target: Map; + /** + * The DOM event which caused the map event. + */ + originalEvent: MouseEvent; + /** + * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner. + */ + point: Point; + /** + * The geographic location on the map of the mouse cursor. + */ + lngLat: LngLat; + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the following default map behaviors: + * + * * On `mousedown` events, the behavior of {@link DragPanHandler} + * * On `mousedown` events, the behavior of {@link DragRotateHandler} + * * On `mousedown` events, the behavior of {@link BoxZoomHandler} + * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler} + * + */ + preventDefault(): void; + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented(): boolean; + _defaultPrevented: boolean; + constructor(type: string, map: Map, originalEvent: MouseEvent, data?: any); +} +export declare class MapTouchEvent extends Event implements MapLibreEvent { + /** + * The event type. + */ + type: "touchstart" | "touchmove" | "touchend" | "touchcancel"; + /** + * The `Map` object that fired the event. + */ + target: Map; + /** + * The DOM event which caused the map event. + */ + originalEvent: TouchEvent; + /** + * The geographic location on the map of the center of the touch event points. + */ + lngLat: LngLat; + /** + * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left + * corner. + */ + point: Point; + /** + * The array of pixel coordinates corresponding to a + * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property. + */ + points: Array; + /** + * The geographical locations on the map corresponding to a + * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property. + */ + lngLats: Array; + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the following default map behaviors: + * + * * On `touchstart` events, the behavior of {@link DragPanHandler} + * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler} + * + */ + preventDefault(): void; + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented(): boolean; + _defaultPrevented: boolean; + constructor(type: string, map: Map, originalEvent: TouchEvent); +} +export declare class MapWheelEvent extends Event { + /** + * The event type. + */ + type: "wheel"; + /** + * The `Map` object that fired the event. + */ + target: Map; + /** + * The DOM event which caused the map event. + */ + originalEvent: WheelEvent; + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the behavior of {@link ScrollZoomHandler}. + */ + preventDefault(): void; + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented(): boolean; + _defaultPrevented: boolean; + /** */ + constructor(type: string, map: Map, originalEvent: WheelEvent); +} +/** + * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}. + * + * @group Event Related + */ +export type MapLibreZoomEvent = { + /** + * The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel` + */ + type: "boxzoomstart" | "boxzoomend" | "boxzoomcancel"; + /** + * The `Map` instance that triggered the event + */ + target: Map; + /** + * The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent` + */ + originalEvent: MouseEvent; +}; +/** + * A `MapDataEvent` object is emitted with the `data` + * and `dataloading` events. Possible values for + * `dataType`s are: + * + * - `'source'`: The non-tile data associated with any source + * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map + * + * Possible values for `sourceDataType`s are: + * + * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles + * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource) + * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible') + * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading) + * + * @group Event Related + * + * @example + * ```ts + * // The sourcedata event is an example of MapDataEvent. + * // Set up an event listener on the map. + * map.on('sourcedata', function(e) { + * if (e.isSourceLoaded) { + * // Do something when the source has finished loading + * } + * }); + * ``` + */ +export type MapDataEvent = { + /** + * The event type. + */ + type: string; + /** + * The type of data that has changed. One of `'source'`, `'style'`. + */ + dataType: string; + /** + * Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`. + */ + sourceDataType: MapSourceDataType; +}; +/** + * The terrain event + * + * @group Event Related + */ +export type MapTerrainEvent = { + type: "terrain"; +}; +/** + * An event related to the web gl context + * + * @group Event Related + */ +export type MapContextEvent = { + type: "webglcontextlost" | "webglcontextrestored"; + originalEvent: WebGLContextEvent; +}; +/** + * The style image missing event + * + * @group Event Related + * + * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/) + */ +export type MapStyleImageMissingEvent = MapLibreEvent & { + type: "styleimagemissing"; + id: string; +}; +export declare class TransformProvider { + _map: Map; + constructor(map: Map); + get transform(): Transform; + get center(): { + lng: number; + lat: number; + }; + get zoom(): number; + get pitch(): number; + get bearing(): number; + unproject(point: PointLike): LngLat; +} +/** + * An options object sent to the enable function of some of the handlers + */ +export type AroundCenterOptions = { + /** + * If "center" is passed, map will zoom around the center of map + */ + around: "center"; +}; +declare abstract class TwoFingersTouchHandler implements Handler { + _enabled: boolean; + _active: boolean; + _firstTwoTouches: [ + number, + number + ]; + _vector: Point; + _startVector: Point; + _aroundCenter: boolean; + /** @internal */ + constructor(); + reset(): void; + abstract _start(points: [ + Point, + Point + ]): any; + abstract _move(points: [ + Point, + Point + ], pinchAround: Point, e: TouchEvent): any; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): void; + touchmove(e: TouchEvent, points: Array, mapTouches: Array): any; + touchend(e: TouchEvent, points: Array, mapTouches: Array): void; + touchcancel(): void; + /** + * Enables the "drag to pitch" interaction. + * + * @example + * ```ts + * map.touchPitch.enable(); + * ``` + */ + enable(options?: AroundCenterOptions | boolean | null): void; + /** + * Disables the "drag to pitch" interaction. + * + * @example + * ```ts + * map.touchPitch.disable(); + * ``` + */ + disable(): void; + /** + * Returns a Boolean indicating whether the "drag to pitch" interaction is enabled. + * + * @returns `true` if the "drag to pitch" interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to pitch" interaction is active. + */ + isActive(): boolean; +} +export declare class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler { + _distance: number; + _startDistance: number; + reset(): void; + _start(points: [ + Point, + Point + ]): void; + _move(points: [ + Point, + Point + ], pinchAround: Point): { + zoomDelta: number; + pinchAround: Point; + }; +} +export declare class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler { + _minDiameter: number; + reset(): void; + _start(points: [ + Point, + Point + ]): void; + _move(points: [ + Point, + Point + ], pinchAround: Point): { + bearingDelta: number; + pinchAround: Point; + }; + _isBelowThreshold(vector: Point): boolean; +} +export declare class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler { + _valid: boolean | void; + _firstMove: number; + _lastPoints: [ + Point, + Point + ]; + _map: Map; + _currentTouchCount: number; + constructor(map: Map); + reset(): void; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): void; + _start(points: [ + Point, + Point + ]): void; + _move(points: [ + Point, + Point + ], center: Point, e: TouchEvent): { + pitchDelta: number; + }; + gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number): boolean | void; +} +export declare class ScrollZoomHandler implements Handler { + _map: Map; + _tr: TransformProvider; + _el: HTMLElement; + _enabled: boolean; + _active: boolean; + _zooming: boolean; + _aroundCenter: boolean; + _around: LngLat; + _aroundPoint: Point; + _type: "wheel" | "trackpad" | null; + _lastValue: number; + _timeout: ReturnType; + _finishTimeout: ReturnType; + _lastWheelEvent: any; + _lastWheelEventTime: number; + _startZoom: number; + _targetZoom: number; + _delta: number; + _easing: ((a: number) => number); + _prevEase: { + start: number; + duration: number; + easing: (_: number) => number; + }; + _frameId: boolean; + _triggerRenderFrame: () => void; + _defaultZoomRate: number; + _wheelZoomRate: number; + /** @internal */ + constructor(map: Map, triggerRenderFrame: () => void); + /** + * Set the zoom rate of a trackpad + * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value. + * @example + * Speed up trackpad zoom + * ```ts + * map.scrollZoom.setZoomRate(1/25); + * ``` + */ + setZoomRate(zoomRate: number): void; + /** + * Set the zoom rate of a mouse wheel + * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value. + * @example + * Slow down zoom of mouse wheel + * ```ts + * map.scrollZoom.setWheelZoomRate(1/600); + * ``` + */ + setWheelZoomRate(wheelZoomRate: number): void; + /** + * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled. + * @returns `true` if the "scroll to zoom" interaction is enabled. + */ + isEnabled(): boolean; + isActive(): boolean; + isZooming(): boolean; + /** + * Enables the "scroll to zoom" interaction. + * + * @param options - Options object. + * @example + * ```ts + * map.scrollZoom.enable(); + * map.scrollZoom.enable({ around: 'center' }) + * ``` + */ + enable(options?: AroundCenterOptions | boolean): void; + /** + * Disables the "scroll to zoom" interaction. + * + * @example + * ```ts + * map.scrollZoom.disable(); + * ``` + */ + disable(): void; + wheel(e: WheelEvent): void; + _onTimeout: (initialEvent: MouseEvent) => void; + _start(e: MouseEvent): void; + renderFrame(): { + noInertia: boolean; + needsRenderFrame: boolean; + zoomDelta: number; + around: Point; + originalEvent: any; + }; + _smoothOutEasing(duration: number): (t: number) => number; + reset(): void; +} +export declare class BoxZoomHandler implements Handler { + _map: Map; + _tr: TransformProvider; + _el: HTMLElement; + _container: HTMLElement; + _enabled: boolean; + _active: boolean; + _startPos: Point; + _lastPos: Point; + _box: HTMLElement; + _clickTolerance: number; + /** @internal */ + constructor(map: Map, options: { + clickTolerance: number; + }); + /** + * Returns a Boolean indicating whether the "box zoom" interaction is enabled. + * + * @returns `true` if the "box zoom" interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used. + * + * @returns `true` if the "box zoom" interaction is active. + */ + isActive(): boolean; + /** + * Enables the "box zoom" interaction. + * + * @example + * ```ts + * map.boxZoom.enable(); + * ``` + */ + enable(): void; + /** + * Disables the "box zoom" interaction. + * + * @example + * ```ts + * map.boxZoom.disable(); + * ``` + */ + disable(): void; + mousedown(e: MouseEvent, point: Point): void; + mousemoveWindow(e: MouseEvent, point: Point): void; + mouseupWindow(e: MouseEvent, point: Point): { + cameraAnimation: (map: any) => any; + }; + keydown(e: KeyboardEvent): void; + reset(): void; + _fireEvent(type: string, e: any): Map; +} +export type DragRotateHandlerOptions = { + /** + * Control the map pitch in addition to the bearing + * @defaultValue true + */ + pitchWithRotate: boolean; +}; +export declare class DragRotateHandler { + _mouseRotate: MouseRotateHandler; + _mousePitch: MousePitchHandler; + _pitchWithRotate: boolean; + /** @internal */ + constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler); + /** + * Enables the "drag to rotate" interaction. + * + * @example + * ```ts + * map.dragRotate.enable(); + * ``` + */ + enable(): void; + /** + * Disables the "drag to rotate" interaction. + * + * @example + * ```ts + * map.dragRotate.disable(); + * ``` + */ + disable(): void; + /** + * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled. + * + * @returns `true` if the "drag to rotate" interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to rotate" interaction is active. + */ + isActive(): boolean; +} +export declare class KeyboardHandler implements Handler { + _tr: TransformProvider; + _enabled: boolean; + _active: boolean; + _panStep: number; + _bearingStep: number; + _pitchStep: number; + _rotationDisabled: boolean; + /** @internal */ + constructor(map: Map); + reset(): void; + keydown(e: KeyboardEvent): { + cameraAnimation: (map: Map) => void; + }; + /** + * Enables the "keyboard rotate and zoom" interaction. + * + * @example + * ```ts + * map.keyboard.enable(); + * ``` + */ + enable(): void; + /** + * Disables the "keyboard rotate and zoom" interaction. + * + * @example + * ```ts + * map.keyboard.disable(); + * ``` + */ + disable(): void; + /** + * Returns a Boolean indicating whether the "keyboard rotate and zoom" + * interaction is enabled. + * + * @returns `true` if the "keyboard rotate and zoom" + * interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns true if the handler is enabled and has detected the start of a + * zoom/rotate gesture. + * + * @returns `true` if the handler is enabled and has detected the + * start of a zoom/rotate gesture. + */ + isActive(): boolean; + /** + * Disables the "keyboard pan/rotate" interaction, leaving the + * "keyboard zoom" interaction enabled. + * + * @example + * ```ts + * map.keyboard.disableRotation(); + * ``` + */ + disableRotation(): void; + /** + * Enables the "keyboard pan/rotate" interaction. + * + * @example + * ```ts + * map.keyboard.enable(); + * map.keyboard.enableRotation(); + * ``` + */ + enableRotation(): void; +} +export declare class ClickZoomHandler implements Handler { + _tr: TransformProvider; + _enabled: boolean; + _active: boolean; + /** @internal */ + constructor(map: Map); + reset(): void; + dblclick(e: MouseEvent, point: Point): { + cameraAnimation: (map: Map) => void; + }; + enable(): void; + disable(): void; + isEnabled(): boolean; + isActive(): boolean; +} +export declare class SingleTapRecognizer { + numTouches: number; + centroid: Point; + startTime: number; + aborted: boolean; + touches: { + [k in number | string]: Point; + }; + constructor(options: { + numTouches: number; + }); + reset(): void; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): void; + touchmove(e: TouchEvent, points: Array, mapTouches: Array): void; + touchend(e: TouchEvent, points: Array, mapTouches: Array): Point; +} +export declare class TapRecognizer { + singleTap: SingleTapRecognizer; + numTaps: number; + lastTime: number; + lastTap: Point; + count: number; + constructor(options: { + numTaps: number; + numTouches: number; + }); + reset(): void; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): void; + touchmove(e: TouchEvent, points: Array, mapTouches: Array): void; + touchend(e: TouchEvent, points: Array, mapTouches: Array): Point; +} +export declare class TapZoomHandler implements Handler { + _tr: TransformProvider; + _enabled: boolean; + _active: boolean; + _zoomIn: TapRecognizer; + _zoomOut: TapRecognizer; + constructor(map: Map); + reset(): void; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): void; + touchmove(e: TouchEvent, points: Array, mapTouches: Array): void; + touchend(e: TouchEvent, points: Array, mapTouches: Array): { + cameraAnimation: (map: Map) => Map; + }; + touchcancel(): void; + enable(): void; + disable(): void; + isEnabled(): boolean; + isActive(): boolean; +} +export declare class DoubleClickZoomHandler { + _clickZoom: ClickZoomHandler; + _tapZoom: TapZoomHandler; + /** @internal */ + constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler); + /** + * Enables the "double click to zoom" interaction. + * + * @example + * ```ts + * map.doubleClickZoom.enable(); + * ``` + */ + enable(): void; + /** + * Disables the "double click to zoom" interaction. + * + * @example + * ```ts + * map.doubleClickZoom.disable(); + * ``` + */ + disable(): void; + /** + * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled. + * + * @returns `true` if the "double click to zoom" interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used. + * + * @returns `true` if the "double click to zoom" interaction is active. + */ + isActive(): boolean; +} +export declare class TapDragZoomHandler implements Handler { + _enabled: boolean; + _active: boolean; + _swipePoint: Point; + _swipeTouch: number; + _tapTime: number; + _tapPoint: Point; + _tap: TapRecognizer; + constructor(); + reset(): void; + touchstart(e: TouchEvent, points: Array, mapTouches: Array): void; + touchmove(e: TouchEvent, points: Array, mapTouches: Array): { + zoomDelta: number; + }; + touchend(e: TouchEvent, points: Array, mapTouches: Array): void; + touchcancel(): void; + enable(): void; + disable(): void; + isEnabled(): boolean; + isActive(): boolean; +} +export declare class TwoFingersTouchZoomRotateHandler { + _el: HTMLElement; + _touchZoom: TwoFingersTouchZoomHandler; + _touchRotate: TwoFingersTouchRotateHandler; + _tapDragZoom: TapDragZoomHandler; + _rotationDisabled: boolean; + _enabled: boolean; + /** @internal */ + constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler); + /** + * Enables the "pinch to rotate and zoom" interaction. + * + * @param options - Options object. + * + * @example + * ```ts + * map.touchZoomRotate.enable(); + * map.touchZoomRotate.enable({ around: 'center' }); + * ``` + */ + enable(options?: AroundCenterOptions | boolean | null): void; + /** + * Disables the "pinch to rotate and zoom" interaction. + * + * @example + * ```ts + * map.touchZoomRotate.disable(); + * ``` + */ + disable(): void; + /** + * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled. + * + * @returns `true` if the "pinch to rotate and zoom" interaction is enabled. + */ + isEnabled(): boolean; + /** + * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture. + * + * @returns `true` if the handler is active, `false` otherwise + */ + isActive(): boolean; + /** + * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom" + * interaction enabled. + * + * @example + * ```ts + * map.touchZoomRotate.disableRotation(); + * ``` + */ + disableRotation(): void; + /** + * Enables the "pinch to rotate" interaction. + * + * @example + * ```ts + * map.touchZoomRotate.enable(); + * map.touchZoomRotate.enableRotation(); + * ``` + */ + enableRotation(): void; +} +/** + * A position defintion for the control to be placed, can be in one of the corners of the map. + * When two or more controls are places in the same location they are stacked toward the center of the map. + */ +export type ControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right"; +/** + * Interface for interactive controls added to the map. This is a + * specification for implementers to model: it is not + * an exported method or class. + * + * Controls must implement `onAdd` and `onRemove`, and must own an + * element, which is often a `div` element. To use MapLibre GL JS's + * default control styling, add the `maplibregl-ctrl` class to your control's + * node. + * + * @example + * Control implemented as ES6 class + * ```ts + * class HelloWorldControl { + * onAdd(map) { + * this._map = map; + * this._container = document.createElement('div'); + * this._container.className = 'maplibregl-ctrl'; + * this._container.textContent = 'Hello, world'; + * return this._container; + * } + * + * onRemove() { + * this._container.parentNode.removeChild(this._container); + * this._map = undefined; + * } + * } + * + * // Control implemented as ES5 prototypical class + * function HelloWorldControl() { } + * + * HelloWorldControl.prototype.onAdd = function(map) { + * this._map = map; + * this._container = document.createElement('div'); + * this._container.className = 'maplibregl-ctrl'; + * this._container.textContent = 'Hello, world'; + * return this._container; + * }; + * + * HelloWorldControl.prototype.onRemove = function () { + * this._container.parentNode.removeChild(this._container); + * this._map = undefined; + * }; + * ``` + */ +export interface IControl { + /** + * Register a control on the map and give it a chance to register event listeners + * and resources. This method is called by {@link Map#addControl} + * internally. + * + * @param map - the Map this control will be added to + * @returns The control's container element. This should + * be created by the control and returned by onAdd without being attached + * to the DOM: the map will insert the control's element into the DOM + * as necessary. + */ + onAdd(map: Map): HTMLElement; + /** + * Unregister a control on the map and give it a chance to detach event listeners + * and resources. This method is called by {@link Map#removeControl} + * internally. + * + * @param map - the Map this control will be removed from + */ + onRemove(map: Map): void; + /** + * Optionally provide a default position for this control. If this method + * is implemented and {@link Map#addControl} is called without the `position` + * parameter, the value returned by getDefaultPosition will be used as the + * control's position. + * + * @returns a control position, one of the values valid in addControl. + */ + readonly getDefaultPosition?: () => ControlPosition; +} +/** + * The {@link Map} options object. + */ +export type MapOptions = { + /** + * If `true`, the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL. + * For example, `http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60`. + * An additional string may optionally be provided to indicate a parameter-styled hash, + * e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar, where foo + * is a custom parameter and bar is an arbitrary hash distinct from the map hash. + * @defaultValue false + */ + hash?: boolean | string; + /** + * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction. + * @defaultValue true + */ + interactive?: boolean; + /** + * The HTML element in which MapLibre GL JS will render the map, or the element's string `id`. The specified element must have no children. + */ + container: HTMLElement | string; + /** + * The threshold, measured in degrees, that determines when the map's + * bearing will snap to north. For example, with a `bearingSnap` of 7, if the user rotates + * the map within 7 degrees of north, the map will automatically snap to exact north. + * @defaultValue 7 + */ + bearingSnap?: number; + /** + * If `true`, an {@link AttributionControl} will be added to the map. + * @defaultValue true + */ + attributionControl?: boolean; + /** + * Attribution text to show in an {@link AttributionControl}. Only applicable if `options.attributionControl` is `true`. + */ + customAttribution?: string | Array; + /** + * If `true`, the MapLibre logo will be shown. + * @defaultValue false + */ + maplibreLogo?: boolean; + /** + * A string representing the position of the MapLibre wordmark on the map. Valid options are `top-left`,`top-right`, `bottom-left`, or `bottom-right`. + * @defaultValue 'bottom-left' + */ + logoPosition?: ControlPosition; + /** + * If `true`, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected + * (i.e. a software renderer would be used). + * @defaultValue false + */ + failIfMajorPerformanceCaveat?: boolean; + /** + * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization. + * @defaultValue false + */ + preserveDrawingBuffer?: boolean; + /** + * If `true`, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. This is `false` by default as a performance optimization. + */ + antialias?: boolean; + /** + * If `false`, the map won't attempt to re-request tiles once they expire per their HTTP `cacheControl`/`expires` headers. + * @defaultValue true + */ + refreshExpiredTiles?: boolean; + /** + * If set, the map will be constrained to the given bounds. + */ + maxBounds?: LngLatBoundsLike; + /** + * If `true`, the "scroll to zoom" interaction is enabled. {@link AroundCenterOptions} are passed as options to {@link ScrollZoomHandler#enable}. + * @defaultValue true + */ + scrollZoom?: boolean | AroundCenterOptions; + /** + * The minimum zoom level of the map (0-24). + * @defaultValue 0 + */ + minZoom?: number | null; + /** + * The maximum zoom level of the map (0-24). + * @defaultValue 22 + */ + maxZoom?: number | null; + /** + * The minimum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * @defaultValue 0 + */ + minPitch?: number | null; + /** + * The maximum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * @defaultValue 60 + */ + maxPitch?: number | null; + /** + * If `true`, the "box zoom" interaction is enabled (see {@link BoxZoomHandler}). + * @defaultValue true + */ + boxZoom?: boolean; + /** + * If `true`, the "drag to rotate" interaction is enabled (see {@link DragRotateHandler}). + * @defaultValue true + */ + dragRotate?: boolean; + /** + * If `true`, the "drag to pan" interaction is enabled. An `Object` value is passed as options to {@link DragPanHandler#enable}. + * @defaultValue true + */ + dragPan?: boolean | DragPanOptions; + /** + * If `true`, keyboard shortcuts are enabled (see {@link KeyboardHandler}). + * @defaultValue true + */ + keyboard?: boolean; + /** + * If `true`, the "double click to zoom" interaction is enabled (see {@link DoubleClickZoomHandler}). + * @defaultValue true + */ + doubleClickZoom?: boolean; + /** + * If `true`, the "pinch to rotate and zoom" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchZoomRotateHandler#enable}. + * @defaultValue true + */ + touchZoomRotate?: boolean | AroundCenterOptions; + /** + * If `true`, the "drag to pitch" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchPitchHandler#enable}. + * @defaultValue true + */ + touchPitch?: boolean | AroundCenterOptions; + /** + * If `true` or set to an options object, the map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, "drag to pitch" requires a three-finger gesture. Cooperative gestures are disabled when a map enters fullscreen using {@link FullscreenControl}. + * @defaultValue undefined + */ + cooperativeGestures?: boolean | GestureOptions; + /** + * If `true`, the map will automatically resize when the browser window resizes. + * @defaultValue true + */ + trackResize?: boolean; + /** + * The initial geographical centerpoint of the map. If `center` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON. + * @defaultValue [0, 0] + */ + center?: LngLatLike; + /** + * The initial zoom level of the map. If `zoom` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. + * @defaultValue 0 + */ + zoom?: number; + /** + * The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If `bearing` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. + * @defaultValue 0 + */ + bearing?: number; + /** + * The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If `pitch` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * @defaultValue 0 + */ + pitch?: number; + /** + * If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * @defaultValue true + */ + renderWorldCopies?: boolean; + /** + * The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport which can be set using `maxTileCacheZoomLevels` constructor options. + * @defaultValue null + */ + maxTileCacheSize?: number; + /** + * The maximum number of zoom levels for which to store tiles for a given source. Tile cache dynamic size is calculated by multiplying `maxTileCacheZoomLevels` with the approximate number of tiles in the viewport for a given source. + * @defaultValue 5 + */ + maxTileCacheZoomLevels?: number; + /** + * A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. + * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties. + */ + transformRequest?: RequestTransformFunction; + /** + * A callback run before the map's camera is moved due to user input or animation. The callback can be used to modify the new center, zoom, pitch and bearing. + * Expected to return an object containing center, zoom, pitch or bearing values to overwrite. + */ + transformCameraUpdate?: CameraUpdateTransformFunction; + /** + * A patch to apply to the default localization table for UI strings, e.g. control tooltips. The `locale` object maps namespaced UI string IDs to translated strings in the target language; see `src/ui/default_locale.js` for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table). + * @defaultValue null + */ + locale?: any; + /** + * Controls the duration of the fade-in/fade-out animation for label collisions after initial map load, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading. + * @defaultValue 300 + */ + fadeDuration?: number; + /** + * If `true`, symbols from multiple sources can collide with each other during collision detection. If `false`, collision detection is run separately for the symbols in each source. + * @defaultValue true + */ + crossSourceCollisions?: boolean; + /** + * If `true`, Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers (this information is normally inaccessible from the main Javascript thread). Information will be returned in a `resourceTiming` property of relevant `data` events. + * @defaultValue false + */ + collectResourceTiming?: boolean; + /** + * The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag). + * @defaultValue true + */ + clickTolerance?: number; + /** + * The initial bounds of the map. If `bounds` is specified, it overrides `center` and `zoom` constructor options. + */ + bounds?: LngLatBoundsLike; + /** + * A {@link FitBoundsOptions} options object to use _only_ when fitting the initial `bounds` provided above. + */ + fitBoundsOptions?: FitBoundsOptions; + /** + * Defines a CSS + * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges. + * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold). + * Set to `false`, to enable font settings from the map's style for these glyph ranges. + * The purpose of this option is to avoid bandwidth-intensive glyph server requests. (See [Use locally generated ideographs](https://maplibre.org/maplibre-gl-js/docs/examples/local-ideographs).) + * @defaultValue 'sans-serif' + */ + localIdeographFontFamily?: string; + /** + * The map's MapLibre style. This must be a JSON object conforming to + * the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), + * or a URL to such JSON. + */ + style: StyleSpecification | string; + /** + * If `false`, the map's pitch (tilt) control with "drag to rotate" interaction will be disabled. + * @defaultValue true + */ + pitchWithRotate?: boolean; + /** + * The pixel ratio. The canvas' `width` attribute will be `container.clientWidth * pixelRatio` and its `height` attribute will be `container.clientHeight * pixelRatio`. Defaults to `devicePixelRatio` if not specified. + */ + pixelRatio?: number; + /** + * If false, style validation will be skipped. Useful in production environment. + * @defaultValue true + */ + validateStyle?: boolean; + /** + * The canvas' `width` and `height` max size. The values are passed as an array where the first element is max width and the second element is max height. + * You shouldn't set this above WebGl `MAX_TEXTURE_SIZE`. Defaults to [4096, 4096]. + */ + maxCanvasSize?: [ + number, + number + ]; +}; +/** + * An options object for the gesture settings + * @example + * ```ts + * let options = { + * windowsHelpText: "Use Ctrl + scroll to zoom the map", + * macHelpText: "Use ⌘ + scroll to zoom the map", + * mobileHelpText: "Use two fingers to move the map", + * } + * ``` + */ +export type GestureOptions = { + windowsHelpText?: string; + macHelpText?: string; + mobileHelpText?: string; +}; +export type Complete = { + [P in keyof Required]: Pick extends Required> ? T[P] : (T[P] | undefined); +}; +export type CompleteMapOptions = Complete; +export declare class Map extends Camera { + style: Style; + painter: Painter; + handlers: HandlerManager; + _container: HTMLElement; + _canvasContainer: HTMLElement; + _controlContainer: HTMLElement; + _controlPositions: { + [_: string]: HTMLElement; + }; + _interactive: boolean; + _cooperativeGestures: boolean | GestureOptions; + _cooperativeGesturesScreen: HTMLElement; + _metaKey: keyof MouseEvent; + _showTileBoundaries: boolean; + _showCollisionBoxes: boolean; + _showPadding: boolean; + _showOverdrawInspector: boolean; + _repaint: boolean; + _vertices: boolean; + _canvas: HTMLCanvasElement; + _maxTileCacheSize: number; + _maxTileCacheZoomLevels: number; + _frame: Cancelable; + _styleDirty: boolean; + _sourcesDirty: boolean; + _placementDirty: boolean; + _loaded: boolean; + _idleTriggered: boolean; + _fullyLoaded: boolean; + _trackResize: boolean; + _resizeObserver: ResizeObserver; + _preserveDrawingBuffer: boolean; + _failIfMajorPerformanceCaveat: boolean; + _antialias: boolean; + _refreshExpiredTiles: boolean; + _hash: Hash; + _delegatedListeners: any; + _fadeDuration: number; + _crossSourceCollisions: boolean; + _crossFadingFactor: number; + _collectResourceTiming: boolean; + _renderTaskQueue: TaskQueue; + _controls: Array; + _mapId: number; + _localIdeographFontFamily: string; + _validateStyle: boolean; + _requestManager: RequestManager; + _locale: any; + _removed: boolean; + _clickTolerance: number; + _overridePixelRatio: number | null; + _maxCanvasSize: [ + number, + number + ]; + _terrainDataCallback: (e: MapStyleDataEvent | MapSourceDataEvent) => void; + /** + * @internal + * image queue throttling handle. To be used later when clean up + */ + _imageQueueHandle: number; + /** + * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad. + * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section. + */ + scrollZoom: ScrollZoomHandler; + /** + * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed. + * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section. + */ + boxZoom: BoxZoomHandler; + /** + * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right + * mouse button or with the Control key pressed. Find more details and examples using `dragRotate` + * in the {@link DragRotateHandler} section. + */ + dragRotate: DragRotateHandler; + /** + * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture. + * Find more details and examples using `dragPan` in the {@link DragPanHandler} section. + */ + dragPan: DragPanHandler; + /** + * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard + * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section. + */ + keyboard: KeyboardHandler; + /** + * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking. + * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section. + */ + doubleClickZoom: DoubleClickZoomHandler; + /** + * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures. + * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section. + */ + touchZoomRotate: TwoFingersTouchZoomRotateHandler; + /** + * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures. + * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section. + */ + touchPitch: TwoFingersTouchPitchHandler; + constructor(options: MapOptions); + /** + * @internal + * Returns a unique number for this map instance which is used for the MapLoadEvent + * to make sure we only fire one event per instantiated map object. + * @returns the uniq map ID + */ + _getMapId(): number; + /** + * Adds an {@link IControl} to the map, calling `control.onAdd(this)`. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param control - The {@link IControl} to add. + * @param position - position on the map to which the control will be added. + * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`. + * @returns `this` + * @example + * Add zoom and rotation controls to the map. + * ```ts + * map.addControl(new maplibregl.NavigationControl()); + * ``` + * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/) + */ + addControl(control: IControl, position?: ControlPosition): Map; + /** + * Removes the control from the map. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param control - The {@link IControl} to remove. + * @returns `this` + * @example + * ```ts + * // Define a new navigation control. + * let navigation = new maplibregl.NavigationControl(); + * // Add zoom and rotation controls to the map. + * map.addControl(navigation); + * // Remove zoom and rotation controls from the map. + * map.removeControl(navigation); + * ``` + */ + removeControl(control: IControl): Map; + /** + * Checks if a control exists on the map. + * + * @param control - The {@link IControl} to check. + * @returns true if map contains control. + * @example + * ```ts + * // Define a new navigation control. + * let navigation = new maplibregl.NavigationControl(); + * // Add zoom and rotation controls to the map. + * map.addControl(navigation); + * // Check that the navigation control exists on the map. + * map.hasControl(navigation); + * ``` + */ + hasControl(control: IControl): boolean; + calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions; + /** + * Resizes the map according to the dimensions of its + * `container` element. + * + * Checks if the map container size changed and updates the map if it has changed. + * This method must be called after the map's `container` is resized programmatically + * or when the map is shown after being initially hidden with CSS. + * + * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`. + * + * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend` + * events that get triggered as a result of resize. This can be useful for differentiating the + * source of an event (for example, user-initiated or programmatically-triggered events). + * @returns `this` + * @example + * Resize the map when the map container is shown after being initially hidden with CSS. + * ```ts + * let mapDiv = document.getElementById('map'); + * if (mapDiv.style.visibility === true) map.resize(); + * ``` + */ + resize(eventData?: any): Map; + /** + * @internal + * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize. + * Internally you should use this and not getPixelRatio(). + */ + _getClampedPixelRatio(width: number, height: number): number; + /** + * Returns the map's pixel ratio. + * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize. + * @returns The pixel ratio. + */ + getPixelRatio(): number; + /** + * Sets the map's pixel ratio. This allows to override `devicePixelRatio`. + * After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio` + * and its height attribute will be `container.clientHeight * pixelRatio`. + * Set this to null to disable `devicePixelRatio` override. + * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize. + * @param pixelRatio - The pixel ratio. + */ + setPixelRatio(pixelRatio: number): void; + /** + * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not + * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. + * @returns The geographical bounds of the map as {@link LngLatBounds}. + * @example + * ```ts + * let bounds = map.getBounds(); + * ``` + */ + getBounds(): LngLatBounds; + /** + * Returns the maximum geographical bounds the map is constrained to, or `null` if none set. + * @returns The map object. + * @example + * ```ts + * let maxBounds = map.getMaxBounds(); + * ``` + */ + getMaxBounds(): LngLatBounds | null; + /** + * Sets or clears the map's geographical bounds. + * + * Pan and zoom operations are constrained within these bounds. + * If a pan or zoom is performed that would + * display regions outside these bounds, the map will + * instead display a position and zoom level + * as close as possible to the operation's request while still + * remaining within the bounds. + * + * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds. + * @returns `this` + * @example + * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds. + * ```ts + * let bounds = [ + * [-74.04728, 40.68392], // [west, south] + * [-73.91058, 40.87764] // [east, north] + * ]; + * map.setMaxBounds(bounds); + * ``` + */ + setMaxBounds(bounds?: LngLatBoundsLike | null): Map; + /** + * Sets or clears the map's minimum zoom level. + * If the map's current zoom level is lower than the new minimum, + * the map will zoom to the new minimum. + * + * It is not always possible to zoom out and reach the set `minZoom`. + * Other factors such as map height may restrict zooming. For example, + * if the map is 512px tall it will not be possible to zoom below zoom 0 + * no matter what the `minZoom` is set to. + * + * A {@link ErrorEvent} event will be fired if minZoom is out of bounds. + * + * @param minZoom - The minimum zoom level to set (-2 - 24). + * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2). + * @returns `this` + * @example + * ```ts + * map.setMinZoom(12.25); + * ``` + */ + setMinZoom(minZoom?: number | null): Map; + /** + * Returns the map's minimum allowable zoom level. + * + * @returns minZoom + * @example + * ```ts + * let minZoom = map.getMinZoom(); + * ``` + */ + getMinZoom(): number; + /** + * Sets or clears the map's maximum zoom level. + * If the map's current zoom level is higher than the new maximum, + * the map will zoom to the new maximum. + * + * A {@link ErrorEvent} event will be fired if minZoom is out of bounds. + * + * @param maxZoom - The maximum zoom level to set. + * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22). + * @returns `this` + * @example + * ```ts + * map.setMaxZoom(18.75); + * ``` + */ + setMaxZoom(maxZoom?: number | null): Map; + /** + * Returns the map's maximum allowable zoom level. + * + * @returns The maxZoom + * @example + * ```ts + * let maxZoom = map.getMaxZoom(); + * ``` + */ + getMaxZoom(): number; + /** + * Sets or clears the map's minimum pitch. + * If the map's current pitch is lower than the new minimum, + * the map will pitch to the new minimum. + * + * A {@link ErrorEvent} event will be fired if minPitch is out of bounds. + * + * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0). + * @returns `this` + */ + setMinPitch(minPitch?: number | null): Map; + /** + * Returns the map's minimum allowable pitch. + * + * @returns The minPitch + */ + getMinPitch(): number; + /** + * Sets or clears the map's maximum pitch. + * If the map's current pitch is higher than the new maximum, + * the map will pitch to the new maximum. + * + * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds. + * + * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60). + * @returns `this` + */ + setMaxPitch(maxPitch?: number | null): Map; + /** + * Returns the map's maximum allowable pitch. + * + * @returns The maxPitch + */ + getMaxPitch(): number; + /** + * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * @returns The renderWorldCopies + * @example + * ```ts + * let worldCopiesRendered = map.getRenderWorldCopies(); + * ``` + * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/) + */ + getRenderWorldCopies(): boolean; + /** + * Sets the state of `renderWorldCopies`. + * + * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * + * `undefined` is treated as `true`, `null` is treated as `false`. + * @returns `this` + * @example + * ```ts + * map.setRenderWorldCopies(true); + * ``` + * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/) + */ + setRenderWorldCopies(renderWorldCopies?: boolean | null): Map; + /** + * Gets the map's cooperativeGestures option + * + * @returns The gestureOptions + */ + getCooperativeGestures(): boolean | GestureOptions; + /** + * Sets or clears the map's cooperativeGestures option + * + * @param gestureOptions - If `true` or set to an options object, map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, "drag to pitch" requires a three-finger gesture. + * @returns `this` + */ + setCooperativeGestures(gestureOptions?: GestureOptions | boolean | null): Map; + /** + * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`, + * that correspond to the specified geographical location. + * + * @param lnglat - The geographical location to project. + * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`. + * @example + * ```ts + * let coordinate = [-122.420679, 37.772537]; + * let point = map.project(coordinate); + * ``` + */ + project(lnglat: LngLatLike): Point; + /** + * Returns a {@link LngLat} representing geographical coordinates that correspond + * to the specified pixel coordinates. + * + * @param point - The pixel coordinates to unproject. + * @returns The {@link LngLat} corresponding to `point`. + * @example + * ```ts + * map.on('click', function(e) { + * // When the map is clicked, get the geographic coordinate. + * let coordinate = map.unproject(e.point); + * }); + * ``` + */ + unproject(point: PointLike): LngLat; + /** + * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture. + * @returns true if the map is moving. + * @example + * ```ts + * let isMoving = map.isMoving(); + * ``` + */ + isMoving(): boolean; + /** + * Returns true if the map is zooming due to a camera animation or user gesture. + * @returns true if the map is zooming. + * @example + * ```ts + * let isZooming = map.isZooming(); + * ``` + */ + isZooming(): boolean; + /** + * Returns true if the map is rotating due to a camera animation or user gesture. + * @returns true if the map is rotating. + * @example + * ```ts + * map.isRotating(); + * ``` + */ + isRotating(): boolean; + _createDelegatedListener(type: keyof MapEventType | string, layerId: string, listener: Listener): { + layer: string; + listener: Listener; + delegates: { + [type in keyof MapEventType]?: (e: any) => void; + }; + }; + /** + * @event + * Adds a listener for events of a specified type, optionally limited to features in a specified style layer. + * See {@link MapEventType} and {@link MapLayerEventType} for a full list of events and their description. + * + * | Event | Compatible with `layerId` | + * |------------------------|---------------------------| + * | `mousedown` | yes | + * | `mouseup` | yes | + * | `mouseover` | yes | + * | `mouseout` | yes | + * | `mousemove` | yes | + * | `mouseenter` | yes (required) | + * | `mouseleave` | yes (required) | + * | `click` | yes | + * | `dblclick` | yes | + * | `contextmenu` | yes | + * | `touchstart` | yes | + * | `touchend` | yes | + * | `touchcancel` | yes | + * | `wheel` | | + * | `resize` | | + * | `remove` | | + * | `touchmove` | | + * | `movestart` | | + * | `move` | | + * | `moveend` | | + * | `dragstart` | | + * | `drag` | | + * | `dragend` | | + * | `zoomstart` | | + * | `zoom` | | + * | `zoomend` | | + * | `rotatestart` | | + * | `rotate` | | + * | `rotateend` | | + * | `pitchstart` | | + * | `pitch` | | + * | `pitchend` | | + * | `boxzoomstart` | | + * | `boxzoomend` | | + * | `boxzoomcancel` | | + * | `webglcontextlost` | | + * | `webglcontextrestored` | | + * | `load` | | + * | `render` | | + * | `idle` | | + * | `error` | | + * | `data` | | + * | `styledata` | | + * | `sourcedata` | | + * | `dataloading` | | + * | `styledataloading` | | + * | `sourcedataloading` | | + * | `styleimagemissing` | | + * | `dataabort` | | + * | `sourcedataabort` | | + * + * @param type - The event type to listen for. Events compatible with the optional `layerId` parameter are triggered + * when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas. + * @param layer - The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location + * is within a visible feature in this layer. The event will have a `features` property containing + * an array of the matching features. If `layer` is not supplied, the event will not have a `features` property. + * Please note that many event types are not compatible with the optional `layer` parameter. + * @param listener - The function to be called when the event is fired. + * @returns `this` + * @example + * ```ts + * // Set an event listener that will fire + * // when the map has finished loading + * map.on('load', function() { + * // Once the map has finished loading, + * // add a new layer + * map.addLayer({ + * id: 'points-of-interest', + * source: { + * type: 'vector', + * url: 'https://maplibre.org/maplibre-style-spec/' + * }, + * 'source-layer': 'poi_label', + * type: 'circle', + * paint: { + * // MapLibre Style Specification paint properties + * }, + * layout: { + * // MapLibre Style Specification layout properties + * } + * }); + * }); + * ``` + * @example + * ```ts + * // Set an event listener that will fire + * // when a feature on the countries layer of the map is clicked + * map.on('click', 'countries', (e) => { + * new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setHTML(`Country name: ${e.features[0].properties.name}`) + * .addTo(map); + * }); + * ``` + * @see [Display popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + on(type: T, layer: string, listener: (ev: MapLayerEventType[T] & Object) => void): Map; + /** + * Overload of the `on` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + on(type: T, listener: (ev: MapEventType[T] & Object) => void): this; + /** + * Overload of the `on` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + on(type: keyof MapEventType | string, listener: Listener): this; + /** + * Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer. + * + * @event + * @param type - The event type to listen for; one of `'mousedown'`, `'mouseup'`, `'click'`, `'dblclick'`, + * `'mousemove'`, `'mouseenter'`, `'mouseleave'`, `'mouseover'`, `'mouseout'`, `'contextmenu'`, `'touchstart'`, + * `'touchend'`, or `'touchcancel'`. `mouseenter` and `mouseover` events are triggered when the cursor enters + * a visible portion of the specified layer from outside that layer or outside the map canvas. `mouseleave` + * and `mouseout` events are triggered when the cursor leaves a visible portion of the specified layer, or leaves + * the map canvas. + * @param layer - The ID of a style layer or a listener if no ID is provided. Only events whose location is within a visible + * feature in this layer will trigger the listener. The event will have a `features` property containing + * an array of the matching features. + * @param listener - The function to be called when the event is fired. + * @returns `this` if listener is provided, promise otherwise to allow easier usage of async/await + */ + once(type: T, layer: string, listener?: (ev: MapLayerEventType[T] & Object) => void): this | Promise; + /** + * Overload of the `once` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + once(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise; + /** + * Overload of the `once` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + once(type: keyof MapEventType | string, listener?: Listener): this | Promise; + /** + * Removes an event listener for events previously added with `Map#on`. + * + * @event + * @param type - The event type previously used to install the listener. + * @param layer - The layer ID or listener previously used to install the listener. + * @param listener - The function previously installed as a listener. + * @returns `this` + */ + off(type: T, layer: string, listener: (ev: MapLayerEventType[T] & Object) => void): this; + /** + * Overload of the `off` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The function previously installed as a listener. + * @returns `this` + */ + off(type: T, listener: (ev: MapEventType[T] & Object) => void): this; + /** + * Overload of the `off` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The function previously installed as a listener. + * @returns `this` + */ + off(type: keyof MapEventType | string, listener: Listener): this; + /** + * Returns an array of MapGeoJSONFeature objects + * representing visible features that satisfy the query parameters. + * + * @param geometryOrOptions - (optional) The geometry of the query region: + * either a single point or southwest and northeast points describing a bounding box. + * Omitting this parameter (i.e. calling {@link Map#queryRenderedFeatures} with zero arguments, + * or with only a `options` argument) is equivalent to passing a bounding box encompassing the entire + * map viewport. + * The geometryOrOptions can receive a {@link QueryRenderedFeaturesOptions} only to support a situation where the function receives only one parameter which is the options parameter. + * @param options - (optional) Options object. + * + * @returns An array of MapGeoJSONFeature objects. + * + * The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only + * string and numeric property values are supported (i.e. `null`, `Array`, and `Object` values are not supported). + * + * Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object + * representing the style layer to which the feature belongs. Layout and paint properties in this object contain values + * which are fully evaluated for the given zoom level and feature. + * + * Only features that are currently rendered are included. Some features will **not** be included, like: + * + * - Features from layers whose `visibility` property is `"none"`. + * - Features from layers whose zoom range excludes the current zoom level. + * - Symbol features that have been hidden due to text or icon collision. + * + * Features from all other layers are included, including features that may have no visible + * contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to + * 0. + * + * The topmost rendered feature appears first in the returned array, and subsequent features are sorted by + * descending z-order. Features that are rendered multiple times (due to wrapping across the antemeridian at low + * zoom levels) are returned only once (though subject to the following caveat). + * + * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature + * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple + * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. + * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding + * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile + * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple + * tiles due to tile buffering. + * + * @example + * Find all features at a point + * ```ts + * let features = map.queryRenderedFeatures( + * [20, 35], + * { layers: ['my-layer-name'] } + * ); + * ``` + * + * @example + * Find all features within a static bounding box + * ```ts + * let features = map.queryRenderedFeatures( + * [[10, 20], [30, 50]], + * { layers: ['my-layer-name'] } + * ); + * ``` + * + * @example + * Find all features within a bounding box around a point + * ```ts + * let width = 10; + * let height = 20; + * let features = map.queryRenderedFeatures([ + * [point.x - width / 2, point.y - height / 2], + * [point.x + width / 2, point.y + height / 2] + * ], { layers: ['my-layer-name'] }); + * ``` + * + * @example + * Query all rendered features from a single layer + * ```ts + * let features = map.queryRenderedFeatures({ layers: ['my-layer-name'] }); + * ``` + * @see [Get features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/queryrenderedfeatures/) + */ + queryRenderedFeatures(geometryOrOptions?: PointLike | [ + PointLike, + PointLike + ] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[]; + /** + * Returns an array of MapGeoJSONFeature objects + * representing features within the specified vector tile or GeoJSON source that satisfy the query parameters. + * + * @param sourceId - The ID of the vector tile or GeoJSON source to query. + * @param parameters - The options object. + * @returns An array of MapGeoJSONFeature objects. + * + * In contrast to {@link Map#queryRenderedFeatures}, this function returns all features matching the query parameters, + * whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded + * vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently + * visible viewport. + * + * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature + * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple + * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. + * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding + * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile + * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple + * tiles due to tile buffering. + * + * @example + * Find all features in one source layer in a vector source + * ```ts + * let features = map.querySourceFeatures('your-source-id', { + * sourceLayer: 'your-source-layer' + * }); + * ``` + * + */ + querySourceFeatures(sourceId: string, parameters?: QuerySourceFeatureOptions | null): MapGeoJSONFeature[]; + /** + * Updates the map's MapLibre style object with a new value. + * + * If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style + * against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites + * (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current + * style and the given style are different in any way, the map renderer will force a full update, removing the current style and building + * the given one from scratch. + * + * + * @param style - A JSON object conforming to the schema described in the + * [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), or a URL to such JSON. + * @param options - The options object. + * @returns `this` + * + * @example + * ```ts + * map.setStyle("https://demotiles.maplibre.org/style.json"); + * + * map.setStyle('https://demotiles.maplibre.org/style.json', { + * transformStyle: (previousStyle, nextStyle) => ({ + * ...nextStyle, + * sources: { + * ...nextStyle.sources, + * // copy a source from previous style + * 'osm': previousStyle.sources.osm + * }, + * layers: [ + * // background layer + * nextStyle.layers[0], + * // copy a layer from previous style + * previousStyle.layers[0], + * // other layers from the next style + * ...nextStyle.layers.slice(1).map(layer => { + * // hide the layers we don't need from demotiles style + * if (layer.id.startsWith('geolines')) { + * layer.layout = {...layer.layout || {}, visibility: 'none'}; + * // filter out US polygons + * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) { + * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA']; + * } + * return layer; + * }) + * ] + * }) + * }); + * ``` + */ + setStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions): this; + /** + * Updates the requestManager's transform request with a new function + * + * @param transformRequest - A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. + * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties + * + * @returns `this` + * + * @example + * ```ts + * map.setTransformRequest((url: string, resourceType: string) => {}); + * ``` + */ + setTransformRequest(transformRequest: RequestTransformFunction): this; + _getUIString(key: string): any; + _updateStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions): this; + _lazyInitEmptyStyle(): void; + _diffStyle(style: StyleSpecification | string, options?: StyleSwapOptions & StyleOptions): void; + _updateDiff(style: StyleSpecification, options?: StyleSwapOptions & StyleOptions): void; + /** + * Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style. + * + * @returns The map's style JSON object. + * + * @example + * ```ts + * let styleJson = map.getStyle(); + * ``` + * + */ + getStyle(): StyleSpecification; + /** + * Returns a Boolean indicating whether the map's style is fully loaded. + * + * @returns A Boolean indicating whether the style is fully loaded. + * + * @example + * ```ts + * let styleLoadStatus = map.isStyleLoaded(); + * ``` + */ + isStyleLoaded(): boolean | void; + /** + * Adds a source to the map's style. + * + * Events triggered: + * + * Triggers the `source.add` event. + * + * @param id - The ID of the source to add. Must not conflict with existing sources. + * @param source - The source object, conforming to the + * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or + * {@link CanvasSourceSpecification}. + * @returns `this` + * @example + * ```ts + * map.addSource('my-data', { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }); + * ``` + * @example + * ```ts + * map.addSource('my-data', { + * "type": "geojson", + * "data": { + * "type": "Feature", + * "geometry": { + * "type": "Point", + * "coordinates": [-77.0323, 38.9131] + * }, + * "properties": { + * "title": "Mapbox DC", + * "marker-symbol": "monument" + * } + * } + * }); + * ``` + * @see GeoJSON source: [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + */ + addSource(id: string, source: SourceSpecification): this; + /** + * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with + * the given ID in the map's style has no outstanding network requests, otherwise `false`. + * + * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID. + * + * @param id - The ID of the source to be checked. + * @returns A Boolean indicating whether the source is loaded. + * @example + * ```ts + * let sourceLoaded = map.isSourceLoaded('bathymetry-data'); + * ``` + */ + isSourceLoaded(id: string): boolean; + /** + * Loads a 3D terrain mesh, based on a "raster-dem" source. + * + * Triggers the `terrain` event. + * + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setTerrain({ source: 'terrain' }); + * ``` + */ + setTerrain(options: TerrainSpecification | null): this; + /** + * Get the terrain-options if terrain is loaded + * @returns the TerrainSpecification passed to setTerrain + * @example + * ```ts + * map.getTerrain(); // { source: 'terrain' }; + * ``` + */ + getTerrain(): TerrainSpecification | null; + /** + * Returns a Boolean indicating whether all tiles in the viewport from all sources on + * the style are loaded. + * + * @returns A Boolean indicating whether all tiles are loaded. + * @example + * ```ts + * let tilesLoaded = map.areTilesLoaded(); + * ``` + */ + areTilesLoaded(): boolean; + /** + * Adds a [custom source type](#Custom Sources), making it available for use with + * {@link Map#addSource}. + * @param name - The name of the source type; source definition objects use this name in the `{type: ...}` field. + * @param SourceType - A {@link Source} constructor. + * @param callback - Called when the source type is ready or with an error argument if there is an error. + */ + addSourceType(name: string, SourceType: SourceClass, callback: Callback): void; + /** + * Removes a source from the map's style. + * + * @param id - The ID of the source to remove. + * @returns `this` + * @example + * ```ts + * map.removeSource('bathymetry-data'); + * ``` + */ + removeSource(id: string): Map; + /** + * Returns the source with the specified ID in the map's style. + * + * This method is often used to update a source using the instance members for the relevant + * source type as defined in [Sources](#sources). + * For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates` + * of an image source. + * + * @param id - The ID of the source to get. + * @returns The style source with the specified ID or `undefined` if the ID + * corresponds to no existing sources. + * The shape of the object varies by source type. + * A list of options for each source type is available on the MapLibre Style Specification's + * [Sources](https://maplibre.org/maplibre-style-spec/sources/) page. + * @example + * ```ts + * let sourceObject = map.getSource('points'); + * ``` + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/) + * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + */ + getSource(id: string): Source | undefined; + /** + * Add an image to the style. This image can be displayed on the map like any other icon in the style's + * sprite using the image's ID with + * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image), + * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern), + * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern), + * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern). + * + * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image. + * + * @param id - The ID of the image. + * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data` + * properties with the same format as `ImageData`. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * // If the style's sprite does not already contain an image with ID 'cat', + * // add the image 'cat-icon.png' to the style's sprite with the ID 'cat'. + * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) { + * if (error) throw error; + * if (!map.hasImage('cat')) map.addImage('cat', image); + * }); + * + * // Add a stretchable image that can be used with `icon-text-fit` + * // In this example, the image is 600px wide by 400px high. + * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png', function(error, image) { + * if (error) throw error; + * if (!map.hasImage('border-image')) { + * map.addImage('border-image', image, { + * content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border + * stretchX: [[16, 584]], // stretch everything horizontally except the 16px border + * stretchY: [[16, 384]], // stretch everything vertically except the 16px border + * }); + * } + * }); + * ``` + * @see Use `HTMLImageElement`: [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/) + * @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-generated/) + */ + addImage(id: string, image: HTMLImageElement | ImageBitmap | ImageData | { + width: number; + height: number; + data: Uint8Array | Uint8ClampedArray; + } | StyleImageInterface, options?: Partial): this; + /** + * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's + * sprite using the image's ID with + * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image), + * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern), + * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern), + * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern). + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the image. + * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data` + * properties with the same format as `ImageData`. + * @returns `this` + * @example + * ```ts + * // If an image with the ID 'cat' already exists in the style's sprite, + * // replace that image with a new image, 'other-cat-icon.png'. + * if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png'); + * ``` + */ + updateImage(id: string, image: HTMLImageElement | ImageBitmap | ImageData | { + width: number; + height: number; + data: Uint8Array | Uint8ClampedArray; + } | StyleImageInterface): this; + /** + * Returns an image, specified by ID, currently available in the map. + * This includes both images from the style's original sprite + * and any images that have been added at runtime using {@link Map#addImage}. + * + * @param id - The ID of the image. + * @returns An image in the map with the specified ID. + * + * @example + * ```ts + * let coffeeShopIcon = map.getImage("coffee_cup"); + * ``` + */ + getImage(id: string): StyleImage; + /** + * Check whether or not an image with a specific ID exists in the style. This checks both images + * in the style's original sprite and any images + * that have been added at runtime using {@link Map#addImage}. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the image. + * + * @returns A Boolean indicating whether the image exists. + * @example + * Check if an image with the ID 'cat' exists in the style's sprite. + * ```ts + * let catIconExists = map.hasImage('cat'); + * ``` + */ + hasImage(id: string): boolean; + /** + * Remove an image from a style. This can be an image from the style's original + * sprite or any images + * that have been added at runtime using {@link Map#addImage}. + * + * @param id - The ID of the image. + * + * @example + * ```ts + * // If an image with the ID 'cat' exists in + * // the style's sprite, remove it. + * if (map.hasImage('cat')) map.removeImage('cat'); + * ``` + */ + removeImage(id: string): void; + /** + * Load an image from an external URL to be used with {@link Map#addImage}. External + * domains must support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS). + * + * @param url - The URL of the image file. Image file must be in png, webp, or jpg format. + * @param callback - Expecting `callback(error, data)`. Called when the image has loaded or with an error argument if there is an error. + * + * @example + * Load an image from an external URL. + * ```ts + * map.loadImage('http://placekitten.com/50/50', function(error, image) { + * if (error) throw error; + * // Add the loaded image to the style's sprite with the ID 'kitten'. + * map.addImage('kitten', image); + * }); + * ``` + * @see [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/) + */ + loadImage(url: string, callback: GetImageCallback): void; + /** + * Returns an Array of strings containing the IDs of all images currently available in the map. + * This includes both images from the style's original sprite + * and any images that have been added at runtime using {@link Map#addImage}. + * + * @returns An Array of strings containing the names of all sprites/images currently available in the map. + * + * @example + * ```ts + * let allImages = map.listImages(); + * ``` + */ + listImages(): Array; + /** + * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers) + * to the map's style. + * + * A layer defines how data from a specified source will be styled. Read more about layer types + * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers). + * + * @param layer - The layer to add, + * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or, + * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition. + * The MapLibre Style Specification's layer definition is appropriate for most layers. + * + * @param beforeId - The ID of an existing layer to insert the new layer before, + * resulting in the new layer appearing visually beneath the existing layer. + * If this argument is not specified, the layer will be appended to the end of the layers array + * and appear visually above all other layers. + * + * @returns `this` + * + * @example + * Add a circle layer with a vector source + * ```ts + * map.addLayer({ + * id: 'points-of-interest', + * source: { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }, + * 'source-layer': 'poi_label', + * type: 'circle', + * paint: { + * // MapLibre Style Specification paint properties + * }, + * layout: { + * // MapLibre Style Specification layout properties + * } + * }); + * ``` + * + * @example + * Define a source before using it to create a new layer + * ```ts + * map.addSource('state-data', { + * type: 'geojson', + * data: 'path/to/data.geojson' + * }); + * + * map.addLayer({ + * id: 'states', + * // References the GeoJSON source defined above + * // and does not require a `source-layer` + * source: 'state-data', + * type: 'symbol', + * layout: { + * // Set the label content to the + * // feature's `name` property + * text-field: ['get', 'name'] + * } + * }); + * ``` + * + * @example + * Add a new symbol layer before an existing layer + * ```ts + * map.addLayer({ + * id: 'states', + * // References a source that's already been defined + * source: 'state-data', + * type: 'symbol', + * layout: { + * // Set the label content to the + * // feature's `name` property + * text-field: ['get', 'name'] + * } + * // Add the layer before the existing `cities` layer + * }, 'cities'); + * ``` + * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/) + * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/) + * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/) + */ + addLayer(layer: AddLayerObject, beforeId?: string): this; + /** + * Moves a layer to a different z-position. + * + * @param id - The ID of the layer to move. + * @param beforeId - The ID of an existing layer to insert the new layer before. When viewing the map, the `id` layer will appear beneath the `beforeId` layer. If `beforeId` is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map. + * @returns `this` + * + * @example + * Move a layer with ID 'polygon' before the layer with ID 'country-label'. The `polygon` layer will appear beneath the `country-label` layer on the map. + * ```ts + * map.moveLayer('polygon', 'country-label'); + * ``` + */ + moveLayer(id: string, beforeId?: string): this; + /** + * Removes the layer with the given ID from the map's style. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the layer to remove + * @returns `this` + * + * @example + * If a layer with ID 'state-data' exists, remove it. + * ```ts + * if (map.getLayer('state-data')) map.removeLayer('state-data'); + * ``` + */ + removeLayer(id: string): this; + /** + * Returns the layer with the specified ID in the map's style. + * + * @param id - The ID of the layer to get. + * @returns The layer with the specified ID, or `undefined` + * if the ID corresponds to no existing layers. + * + * @example + * ```ts + * let stateDataLayer = map.getLayer('state-data'); + * ``` + * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/) + * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/) + */ + getLayer(id: string): StyleLayer | undefined; + /** + * Return the ids of all layers currently in the style, including custom layers, in order. + * + * @returns ids of layers, in order + * + * @example + * ```ts + * const orderedLayerIds = map.getLayersOrder(); + * ``` + */ + getLayersOrder(): string[]; + /** + * Sets the zoom extent for the specified style layer. The zoom extent includes the + * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom) + * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom)) + * at which the layer will be rendered. + * + * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the + * minimum zoom level of the _source layer_ because the data does not exist at those zoom levels. If the minimum + * zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style + * layer will not be rendered at all zoom levels in the zoom range. + * + * @param layerId - The ID of the layer to which the zoom extent will be applied. + * @param minzoom - The minimum zoom to set (0-24). + * @param maxzoom - The maximum zoom to set (0-24). + * @returns `this` + * + * @example + * ```ts + * map.setLayerZoomRange('my-layer', 2, 5); + * ``` + */ + setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this; + /** + * Sets the filter for the specified style layer. + * + * Filters control which features a style layer renders from its source. + * Any feature for which the filter expression evaluates to `true` will be + * rendered on the map. Those that are false will be hidden. + * + * Use `setFilter` to show a subset of your source data. + * + * To clear the filter, pass `null` or `undefined` as the second parameter. + * + * @param layerId - The ID of the layer to which the filter will be applied. + * @param filter - The filter, conforming to the MapLibre Style Specification's + * [filter definition](https://maplibre.org/maplibre-style-spec/layers/#filter). If `null` or `undefined` is provided, the function removes any existing filter from the layer. + * @param options - Options object. + * @returns `this` + * + * @example + * Display only features with the 'name' property 'USA' + * ```ts + * map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']); + * ``` + * @example + * Display only features with five or more 'available-spots' + * ```ts + * map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]); + * ``` + * @example + * Remove the filter for the 'bike-docks' style layer + * ```ts + * map.setFilter('bike-docks', null); + * ``` + * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/) + */ + setFilter(layerId: string, filter?: FilterSpecification | null, options?: StyleSetterOptions): this; + /** + * Returns the filter applied to the specified style layer. + * + * @param layerId - The ID of the style layer whose filter to get. + * @returns The layer's filter. + */ + getFilter(layerId: string): FilterSpecification | void; + /** + * Sets the value of a paint property in the specified style layer. + * + * @param layerId - The ID of the layer to set the paint property in. + * @param name - The name of the paint property to set. + * @param value - The value of the paint property to set. + * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/). + * Pass `null` to unset the existing value. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setPaintProperty('my-layer', 'fill-color', '#faafee'); + * ``` + * @see [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/) + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + setPaintProperty(layerId: string, name: string, value: any, options?: StyleSetterOptions): this; + /** + * Returns the value of a paint property in the specified style layer. + * + * @param layerId - The ID of the layer to get the paint property from. + * @param name - The name of a paint property to get. + * @returns The value of the specified paint property. + */ + getPaintProperty(layerId: string, name: string): unknown; + /** + * Sets the value of a layout property in the specified style layer. + * + * @param layerId - The ID of the layer to set the layout property in. + * @param name - The name of the layout property to set. + * @param value - The value of the layout property. Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/). + * @param options - The options object. + * @returns `this` + * @example + * ```ts + * map.setLayoutProperty('my-layer', 'visibility', 'none'); + * ``` + */ + setLayoutProperty(layerId: string, name: string, value: any, options?: StyleSetterOptions): this; + /** + * Returns the value of a layout property in the specified style layer. + * + * @param layerId - The ID of the layer to get the layout property from. + * @param name - The name of the layout property to get. + * @returns The value of the specified layout property. + */ + getLayoutProperty(layerId: string, name: string): any; + /** + * Sets the value of the style's glyphs property. + * + * @param glyphsUrl - Glyph URL to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/glyphs/). + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setGlyphs('https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'); + * ``` + */ + setGlyphs(glyphsUrl: string | null, options?: StyleSetterOptions): this; + /** + * Returns the value of the style's glyphs URL + * + * @returns glyphs Style's glyphs url + */ + getGlyphs(): string | null; + /** + * Adds a sprite to the map's style. Fires the `style` event. + * + * @param id - The ID of the sprite to add. Must not conflict with existing sprites. + * @param url - The URL to load the sprite from + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.addSprite('sprite-two', 'http://example.com/sprite-two'); + * ``` + */ + addSprite(id: string, url: string, options?: StyleSetterOptions): this; + /** + * Removes the sprite from the map's style. Fires the `style` event. + * + * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be "default". + * @returns `this` + * @example + * ```ts + * map.removeSprite('sprite-two'); + * map.removeSprite('default'); + * ``` + */ + removeSprite(id: string): this; + /** + * Returns the as-is value of the style's sprite. + * + * @returns style's sprite list of id-url pairs + */ + getSprite(): { + id: string; + url: string; + }[]; + /** + * Sets the value of the style's sprite property. + * + * @param spriteUrl - Sprite URL to set. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setSprite('YOUR_SPRITE_URL'); + * ``` + */ + setSprite(spriteUrl: string | null, options?: StyleSetterOptions): this; + /** + * Sets the any combination of light values. + * + * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light). + * @param options - Options object. + * @returns `this` + * + * @example + * ```ts + * let layerVisibility = map.getLayoutProperty('my-layer', 'visibility'); + * ``` + */ + setLight(light: LightSpecification, options?: StyleSetterOptions): this; + /** + * Returns the value of the light object. + * + * @returns light Light properties of the style. + */ + getLight(): LightSpecification; + /** + * Sets the `state` of a feature. + * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime. + * When using this method, the `state` object is merged with any existing key-value pairs in the feature's state. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * This method can only be used with sources that have a `feature.id` attribute. The `feature.id` attribute can be defined in three ways: + * - For vector or GeoJSON sources, including an `id` attribute in the original data file. + * - For vector or GeoJSON sources, using the [`promoteId`](https://maplibre.org/maplibre-style-spec/sources/#vector-promoteId) option at the time the source is defined. + * - For GeoJSON sources, using the [`generateId`](https://maplibre.org/maplibre-style-spec/sources/#geojson-generateId) option to auto-assign an `id` based on the feature's index in the source data. If you change feature data using `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values. + * + * _Note: You can use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) to access the values in a feature's state object for the purposes of styling._ + * + * @param feature - Feature identifier. Feature objects returned from + * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @param state - A set of key-value pairs. The values should be valid JSON types. + * @returns `this` + * + * @example + * ```ts + * // When the mouse moves over the `my-layer` layer, update + * // the feature state for the feature under the mouse + * map.on('mousemove', 'my-layer', function(e) { + * if (e.features.length > 0) { + * map.setFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id, + * }, { + * hover: true + * }); + * } + * }); + * ``` + * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + */ + setFeatureState(feature: FeatureIdentifier, state: any): this; + /** + * Removes the `state` of a feature, setting it back to the default behavior. + * If only a `target.source` is specified, it will remove the state for all features from that source. + * If `target.id` is also specified, it will remove all keys for that feature's state. + * If `key` is also specified, it removes only that key from that feature's state. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * @param target - Identifier of where to remove state. It can be a source, a feature, or a specific key of feature. + * Feature objects returned from {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @param key - (optional) The key in the feature state to reset. + * @returns `this` + * @example + * Reset the entire state object for all features in the `my-source` source + * ```ts + * map.removeFeatureState({ + * source: 'my-source' + * }); + * ``` + * + * @example + * When the mouse leaves the `my-layer` layer, + * reset the entire state object for the + * feature under the mouse + * ```ts + * map.on('mouseleave', 'my-layer', function(e) { + * map.removeFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }); + * }); + * ``` + * + * @example + * When the mouse leaves the `my-layer` layer, + * reset only the `hover` key-value pair in the + * state for the feature under the mouse + * ```ts + * map.on('mouseleave', 'my-layer', function(e) { + * map.removeFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }, 'hover'); + * }); + * ``` + */ + removeFeatureState(target: FeatureIdentifier, key?: string): this; + /** + * Gets the `state` of a feature. + * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * _Note: To access the values in a feature's state object for the purposes of styling the feature, use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state)._ + * + * @param feature - Feature identifier. Feature objects returned from + * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @returns The state of the feature: a set of key-value pairs that was assigned to the feature at runtime. + * + * @example + * When the mouse moves over the `my-layer` layer, + * get the feature state for the feature under the mouse + * ```ts + * map.on('mousemove', 'my-layer', function(e) { + * if (e.features.length > 0) { + * map.getFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }); + * } + * }); + * ``` + */ + getFeatureState(feature: FeatureIdentifier): any; + /** + * Returns the map's containing HTML element. + * + * @returns The map's container. + */ + getContainer(): HTMLElement; + /** + * Returns the HTML element containing the map's `` element. + * + * If you want to add non-GL overlays to the map, you should append them to this element. + * + * This is the element to which event bindings for map interactivity (such as panning and zooming) are + * attached. It will receive bubbled events from child elements such as the ``, but not from + * map controls. + * + * @returns The container of the map's ``. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + getCanvasContainer(): HTMLElement; + /** + * Returns the map's `` element. + * + * @returns The map's `` element. + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + getCanvas(): HTMLCanvasElement; + _containerDimensions(): number[]; + _setupContainer(): void; + _cooperativeGesturesOnWheel: (event: WheelEvent) => void; + _setupCooperativeGestures(): void; + _destroyCooperativeGestures(): void; + _resizeCanvas(width: number, height: number, pixelRatio: number): void; + _setupPainter(): void; + _contextLost: (event: any) => void; + _contextRestored: (event: any) => void; + _onMapScroll: (event: any) => boolean; + _onCooperativeGesture(event: any, metaPress: any, touches: any): boolean; + /** + * Returns a Boolean indicating whether the map is fully loaded. + * + * Returns `false` if the style is not yet fully loaded, + * or if there has been a change to the sources or style that + * has not yet fully loaded. + * + * @returns A Boolean indicating whether the map is fully loaded. + */ + loaded(): boolean; + /** + * @internal + * Update this map's style and sources, and re-render the map. + * + * @param updateStyle - mark the map's style for reprocessing as + * well as its sources + * @returns `this` + */ + _update(updateStyle?: boolean): this; + /** + * @internal + * Request that the given callback be executed during the next render + * frame. Schedule a render frame if one is not already scheduled. + * + * @returns An id that can be used to cancel the callback + */ + _requestRenderFrame(callback: () => void): TaskID; + _cancelRenderFrame(id: TaskID): void; + /** + * @internal + * Call when a (re-)render of the map is required: + * - The style has changed (`setPaintProperty()`, etc.) + * - Source data has changed (e.g. tiles have finished loading) + * - The map has is moving (or just finished moving) + * - A transition is in progress + * + * @param paintStartTimeStamp - The time when the animation frame began executing. + * + * @returns `this` + */ + _render(paintStartTimeStamp: number): this; + /** + * Force a synchronous redraw of the map. + * @returns `this` + * @example + * ```ts + * map.redraw(); + * ``` + */ + redraw(): this; + /** + * Clean up and release all internal resources associated with this map. + * + * This includes DOM elements, event bindings, web workers, and WebGL resources. + * + * Use this method when you are done using the map and wish to ensure that it no + * longer consumes browser resources. Afterwards, you must not call any other + * methods on the map. + */ + remove(): void; + /** + * Trigger the rendering of a single frame. Use this method with custom layers to + * repaint the map when the layer changes. Calling this multiple times before the + * next frame is rendered will still result in only a single frame being rendered. + * @example + * ```ts + * map.triggerRepaint(); + * ``` + * @see [Add a 3D model](https://maplibre.org/maplibre-gl-js/docs/examples/add-3d-model/) + * @see [Add an animated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/) + */ + triggerRepaint(): void; + _onWindowOnline: () => void; + /** + * Gets and sets a Boolean indicating whether the map will render an outline + * around each tile and the tile ID. These tile boundaries are useful for + * debugging. + * + * The uncompressed file size of the first vector source is drawn in the top left + * corner of each tile, next to the tile ID. + * + * @example + * ```ts + * map.showTileBoundaries = true; + * ``` + */ + get showTileBoundaries(): boolean; + set showTileBoundaries(value: boolean); + /** + * Gets and sets a Boolean indicating whether the map will visualize + * the padding offsets. + */ + get showPadding(): boolean; + set showPadding(value: boolean); + /** + * Gets and sets a Boolean indicating whether the map will render boxes + * around all symbols in the data source, revealing which symbols + * were rendered or which were hidden due to collisions. + * This information is useful for debugging. + */ + get showCollisionBoxes(): boolean; + set showCollisionBoxes(value: boolean); + /** + * Gets and sets a Boolean indicating whether the map should color-code + * each fragment to show how many times it has been shaded. + * White fragments have been shaded 8 or more times. + * Black fragments have been shaded 0 times. + * This information is useful for debugging. + */ + get showOverdrawInspector(): boolean; + set showOverdrawInspector(value: boolean); + /** + * Gets and sets a Boolean indicating whether the map will + * continuously repaint. This information is useful for analyzing performance. + */ + get repaint(): boolean; + set repaint(value: boolean); + get vertices(): boolean; + set vertices(value: boolean); + /** + * Returns the package version of the library + * @returns Package version of the library + */ + get version(): string; + /** + * Returns the elevation for the point where the camera is looking. + * This value corresponds to: + * "meters above sea level" * "exaggeration" + * @returns The elevation. + */ + getCameraTargetElevation(): number; +} +export interface OneFingerTouchRotateHandler extends DragMoveHandler { +} +export interface OneFingerTouchPitchHandler extends DragMoveHandler { +} +/** + * The {@link NavigationControl} options object + */ +export type NavigationOptions = { + /** + * If `true` the compass button is included. + */ + showCompass?: boolean; + /** + * If `true` the zoom-in and zoom-out buttons are included. + */ + showZoom?: boolean; + /** + * If `true` the pitch is visualized by rotating X-axis of compass. + */ + visualizePitch?: boolean; +}; +export declare class NavigationControl implements IControl { + _map: Map; + options: NavigationOptions; + _container: HTMLElement; + _zoomInButton: HTMLButtonElement; + _zoomOutButton: HTMLButtonElement; + _compass: HTMLButtonElement; + _compassIcon: HTMLElement; + _handler: MouseRotateWrapper; + /** + * @param options - the control's options + */ + constructor(options?: NavigationOptions); + _updateZoomButtons: () => void; + _rotateCompassArrow: () => void; + onAdd(map: Map): HTMLElement; + onRemove(): void; + _createButton(className: string, fn: (e?: any) => unknown): HTMLButtonElement; + _setButtonTitle: (button: HTMLButtonElement, title: string) => void; +} +export declare class MouseRotateWrapper { + map: Map; + _clickTolerance: number; + element: HTMLElement; + mouseRotate: MouseRotateHandler; + touchRotate: OneFingerTouchRotateHandler; + mousePitch: MousePitchHandler; + touchPitch: OneFingerTouchPitchHandler; + _startPos: Point; + _lastPos: Point; + constructor(map: Map, element: HTMLElement, pitch?: boolean); + startMouse(e: MouseEvent, point: Point): void; + startTouch(e: TouchEvent, point: Point): void; + moveMouse(e: MouseEvent, point: Point): void; + moveTouch(e: TouchEvent, point: Point): void; + off(): void; + offTemp(): void; + mousedown: (e: MouseEvent) => void; + mousemove: (e: MouseEvent) => void; + mouseup: (e: MouseEvent) => void; + touchstart: (e: TouchEvent) => void; + touchmove: (e: TouchEvent) => void; + touchend: (e: TouchEvent) => void; + reset: () => void; +} +/** + * Where to position the anchor. + * Used by a popup and a marker. + */ +export type PositionAnchor = "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right"; +/** + * A pixel offset specified as: + * - a single number specifying a distance from the location + * - a {@link PointLike} specifying a constant offset + * - an object of {@link Point}s specifying an offset for each anchor position + * Negative offsets indicate left and up. + */ +export type Offset = number | PointLike | { + [_ in PositionAnchor]: PointLike; +}; +export type PopupOptions = { + /** + * If `true`, a close button will appear in the top right corner of the popup. + * @defaultValue true + */ + closeButton?: boolean; + /** + * If `true`, the popup will closed when the map is clicked. + * @defaultValue true + */ + closeOnClick?: boolean; + /** + * If `true`, the popup will closed when the map moves. + * @defaultValue false + */ + closeOnMove?: boolean; + /** + * If `true`, the popup will try to focus the first focusable element inside the popup. + * @defaultValue true + */ + focusAfterOpen?: boolean; + /** + * A string indicating the part of the Popup that should + * be positioned closest to the coordinate set via {@link Popup#setLngLat}. + * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, + * `'top-right'`, `'bottom-left'`, and `'bottom-right'`. If unset the anchor will be + * dynamically set to ensure the popup falls within the map container with a preference + * for `'bottom'`. + */ + anchor?: PositionAnchor; + /** + * A pixel offset applied to the popup's location + */ + offset?: Offset; + /** + * Space-separated CSS class names to add to popup container + */ + className?: string; + /** + * A string that sets the CSS property of the popup's maximum width, eg `'300px'`. + * To ensure the popup resizes to fit its content, set this property to `'none'`. + * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width + * @defaultValue '240px' + */ + maxWidth?: string; +}; +export declare class Popup extends Evented { + _map: Map; + options: PopupOptions; + _content: HTMLElement; + _container: HTMLElement; + _closeButton: HTMLButtonElement; + _tip: HTMLElement; + _lngLat: LngLat; + _trackPointer: boolean; + _pos: Point; + constructor(options?: PopupOptions); + /** + * Adds the popup to a map. + * + * @param map - The MapLibre GL JS map to add the popup to. + * @returns `this` + * @example + * ```ts + * new maplibregl.Popup() + * .setLngLat([0, 0]) + * .setHTML("

Null Island

") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Show polygon information on click](https://maplibre.org/maplibre-gl-js/docs/examples/polygon-popup-on-click/) + */ + addTo(map: Map): this; + /** + * @returns `true` if the popup is open, `false` if it is closed. + */ + isOpen(): boolean; + /** + * Removes the popup from the map it has been added to. + * + * @example + * ```ts + * let popup = new maplibregl.Popup().addTo(map); + * popup.remove(); + * ``` + * @returns `this` + */ + remove: () => this; + /** + * Returns the geographical location of the popup's anchor. + * + * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously + * set by `setLngLat` because `Popup` wraps the anchor longitude across copies of the world to keep + * the popup on screen. + * + * @returns The geographical location of the popup's anchor. + */ + getLngLat(): LngLat; + /** + * Sets the geographical location of the popup's anchor, and moves the popup to it. Replaces trackPointer() behavior. + * + * @param lnglat - The geographical location to set as the popup's anchor. + * @returns `this` + */ + setLngLat(lnglat: LngLatLike): this; + /** + * Tracks the popup anchor to the cursor position on screens with a pointer device (it will be hidden on touchscreens). Replaces the `setLngLat` behavior. + * For most use cases, set `closeOnClick` and `closeButton` to `false`. + * @example + * ```ts + * let popup = new maplibregl.Popup({ closeOnClick: false, closeButton: false }) + * .setHTML("

Hello World!

") + * .trackPointer() + * .addTo(map); + * ``` + * @returns `this` + */ + trackPointer(): this; + /** + * Returns the `Popup`'s HTML element. + * @example + * Change the `Popup` element's font size + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat([-96, 37.8]) + * .setHTML("

Hello World!

") + * .addTo(map); + * let popupElem = popup.getElement(); + * popupElem.style.fontSize = "25px"; + * ``` + * @returns element + */ + getElement(): HTMLElement; + /** + * Sets the popup's content to a string of text. + * + * This function creates a [Text](https://developer.mozilla.org/en-US/docs/Web/API/Text) node in the DOM, + * so it cannot insert raw HTML. Use this method for security against XSS + * if the popup content is user-provided. + * + * @param text - Textual content for the popup. + * @returns `this` + * @example + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setText('Hello, world!') + * .addTo(map); + * ``` + */ + setText(text: string): this; + /** + * Sets the popup's content to the HTML provided as a string. + * + * This method does not perform HTML filtering or sanitization, and must be + * used only with trusted content. Consider {@link Popup#setText} if + * the content is an untrusted text string. + * + * @param html - A string representing HTML content for the popup. + * @returns `this` + * @example + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setHTML("

Hello World!

") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + */ + setHTML(html: string): this; + /** + * Returns the popup's maximum width. + * + * @returns The maximum width of the popup. + */ + getMaxWidth(): string; + /** + * Sets the popup's maximum width. This is setting the CSS property `max-width`. + * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width + * + * @param maxWidth - A string representing the value for the maximum width. + * @returns `this` + */ + setMaxWidth(maxWidth: string): this; + /** + * Sets the popup's content to the element provided as a DOM node. + * + * @param htmlNode - A DOM node to be used as content for the popup. + * @returns `this` + * @example + * Create an element with the popup content + * ```ts + * let div = document.createElement('div'); + * div.innerHTML = 'Hello, world!'; + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setDOMContent(div) + * .addTo(map); + * ``` + */ + setDOMContent(htmlNode: Node): this; + /** + * Adds a CSS class to the popup container element. + * + * @param className - Non-empty string with CSS class name to add to popup container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.addClassName('some-class') + * ``` + */ + addClassName(className: string): void; + /** + * Removes a CSS class from the popup container element. + * + * @param className - Non-empty string with CSS class name to remove from popup container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.removeClassName('some-class') + * ``` + */ + removeClassName(className: string): void; + /** + * Sets the popup's offset. + * + * @param offset - Sets the popup's offset. + * @returns `this` + */ + setOffset(offset?: Offset): this; + /** + * Add or remove the given CSS class on the popup container, depending on whether the container currently has that class. + * + * @param className - Non-empty string with CSS class name to add/remove + * + * @returns if the class was removed return false, if class was added, then return true, undefined if there is no container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.toggleClassName('toggleClass') + * ``` + */ + toggleClassName(className: string): boolean | undefined; + _createCloseButton(): void; + _onMouseUp: (event: MapMouseEvent) => void; + _onMouseMove: (event: MapMouseEvent) => void; + _onDrag: (event: MapMouseEvent) => void; + _update: (cursor?: Point) => void; + _focusFirstElement(): void; + _onClose: () => void; +} +/** + * Alignment options of rotation and pitch + */ +export type Alignment = "map" | "viewport" | "auto"; +/** + * The {@link Marker} options object + */ +export type MarkerOptions = { + /** + * DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker. + */ + element?: HTMLElement; + /** + * Space-separated CSS class names to add to marker element. + */ + className?: string; + /** + * The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up. + */ + offset?: PointLike; + /** + * A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}. + * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. + * @defaultValue 'center' + * */ + anchor?: PositionAnchor; + /** + * The color to use for the default marker if options.element is not provided. The default is light blue. + * @defaultValue '#3FB1CE' + */ + color?: string; + /** + * The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`. + * @defaultValue 1 + */ + scale?: number; + /** + * A boolean indicating whether or not a marker is able to be dragged to a new position on the map. + * @defaultValue false + */ + draggable?: boolean; + /** + * The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance. + * @defaultValue 0 + */ + clickTolerance?: number; + /** + * The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise. + * @defaultValue 0 + */ + rotation?: number; + /** + * `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`. + * @defaultValue 'auto' + */ + rotationAlignment?: Alignment; + /** + * `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`. + * @defaultValue 'auto' + */ + pitchAlignment?: Alignment; +}; +export declare class Marker extends Evented { + _map: Map; + _anchor: PositionAnchor; + _offset: Point; + _element: HTMLElement; + _popup: Popup; + _lngLat: LngLat; + _pos: Point; + _color: string; + _scale: number; + _defaultMarker: boolean; + _draggable: boolean; + _clickTolerance: number; + _isDragging: boolean; + _state: "inactive" | "pending" | "active"; + _positionDelta: Point; + _pointerdownPos: Point; + _rotation: number; + _pitchAlignment: Alignment; + _rotationAlignment: Alignment; + _originalTabIndex: string; + _opacityTimeout: ReturnType; + /** + * @param options - the options + */ + constructor(options?: MarkerOptions); + /** + * Attaches the `Marker` to a `Map` object. + * @param map - The MapLibre GL JS map to add the marker to. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([30.5, 50.5]) + * .addTo(map); // add the marker to the map + * ``` + */ + addTo(map: Map): this; + /** + * Removes the marker from a map + * @example + * ```ts + * let marker = new maplibregl.Marker().addTo(map); + * marker.remove(); + * ``` + * @returns `this` + */ + remove(): this; + /** + * Get the marker's geographical location. + * + * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously + * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep + * the marker on screen. + * + * @returns A {@link LngLat} describing the marker's location. + * @example + * ```ts + * // Store the marker's longitude and latitude coordinates in a variable + * let lngLat = marker.getLngLat(); + * // Print the marker's longitude and latitude values in the console + * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat ) + * ``` + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + getLngLat(): LngLat; + /** + * Set the marker's geographical position and move it. + * @param lnglat - A {@link LngLat} describing where the marker should be located. + * @returns `this` + * @example + * Create a new marker, set the longitude and latitude, and add it to the map + * ```ts + * new maplibregl.Marker() + * .setLngLat([-65.017, -16.457]) + * .addTo(map); + * ``` + * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/) + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + setLngLat(lnglat: LngLatLike): this; + /** + * Returns the `Marker`'s HTML element. + * @returns element + */ + getElement(): HTMLElement; + /** + * Binds a {@link Popup} to the {@link Marker}. + * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup + * set on this {@link Marker} instance is unset. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) // add popup + * .addTo(map); + * ``` + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + */ + setPopup(popup?: Popup | null): this; + _onKeyPress: (e: KeyboardEvent) => void; + _onMapClick: (e: MapMouseEvent) => void; + /** + * Returns the {@link Popup} instance that is bound to the {@link Marker}. + * @returns popup + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * console.log(marker.getPopup()); // return the popup instance + * ``` + */ + getPopup(): Popup; + /** + * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * marker.togglePopup(); // toggle popup open or closed + * ``` + */ + togglePopup(): this; + _update: (e?: { + type: "move" | "moveend" | "terrain" | "render"; + }) => void; + /** + * Get the marker's offset. + * @returns The marker's screen coordinates in pixels. + */ + getOffset(): Point; + /** + * Sets the offset of the marker + * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up. + * @returns `this` + */ + setOffset(offset: PointLike): this; + /** + * Adds a CSS class to the marker element. + * + * @param className - on-empty string with CSS class name to add to marker element + * + * @example + * ``` + * let marker = new maplibregl.Marker() + * marker.addClassName('some-class') + * ``` + */ + addClassName(className: string): void; + /** + * Removes a CSS class from the marker element. + * + * @param className - Non-empty string with CSS class name to remove from marker element + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * marker.removeClassName('some-class') + * ``` + */ + removeClassName(className: string): void; + /** + * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class. + * + * @param className - Non-empty string with CSS class name to add/remove + * + * @returns if the class was removed return false, if class was added, then return true + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * marker.toggleClassName('toggleClass') + * ``` + */ + toggleClassName(className: string): boolean; + _onMove: (e: MapMouseEvent | MapTouchEvent) => void; + _onUp: () => void; + _addDragHandler: (e: MapMouseEvent | MapTouchEvent) => void; + /** + * Sets the `draggable` property and functionality of the marker + * @param shouldBeDraggable - Turns drag functionality on/off + * @returns `this` + */ + setDraggable(shouldBeDraggable?: boolean): this; + /** + * Returns true if the marker can be dragged + * @returns True if the marker is draggable. + */ + isDraggable(): boolean; + /** + * Sets the `rotation` property of the marker. + * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting. + * @returns `this` + */ + setRotation(rotation?: number): this; + /** + * Returns the current rotation angle of the marker (in degrees). + * @returns The current rotation angle of the marker. + */ + getRotation(): number; + /** + * Sets the `rotationAlignment` property of the marker. + * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto' + * @returns `this` + */ + setRotationAlignment(alignment?: Alignment): this; + /** + * Returns the current `rotationAlignment` property of the marker. + * @returns The current rotational alignment of the marker. + */ + getRotationAlignment(): Alignment; + /** + * Sets the `pitchAlignment` property of the marker. + * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`. + * @returns `this` + */ + setPitchAlignment(alignment?: Alignment): this; + /** + * Returns the current `pitchAlignment` property of the marker. + * @returns The current pitch alignment of the marker in degrees. + */ + getPitchAlignment(): Alignment; +} +/** + * The {@link GeolocateControl} options + */ +export type GeolocateOptions = { + /** + * A Geolocation API [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) object. + * @defaultValue `{enableHighAccuracy: false, timeout: 6000}` + */ + positionOptions?: PositionOptions; + /** + * A options object to use when the map is panned and zoomed to the user's location. The default is to use a `maxZoom` of 15 to limit how far the map will zoom in for very accurate locations. + */ + fitBoundsOptions?: FitBoundsOptions; + /** + * If `true` the Geolocate Control becomes a toggle button and when active the map will receive updates to the user's location as it changes. + * @defaultValue false + */ + trackUserLocation?: boolean; + /** + * By default, if showUserLocation is `true`, a transparent circle will be drawn around the user location indicating the accuracy (95% confidence level) of the user's location. Set to `false` to disable. Always disabled when showUserLocation is `false`. + * @defaultValue true + */ + showAccuracyCircle?: boolean; + /** + * By default a dot will be shown on the map at the user's location. Set to `false` to disable. + * @defaultValue true + */ + showUserLocation?: boolean; +}; +export declare class GeolocateControl extends Evented implements IControl { + _map: Map; + options: GeolocateOptions; + _container: HTMLElement; + _dotElement: HTMLElement; + _circleElement: HTMLElement; + _geolocateButton: HTMLButtonElement; + _geolocationWatchID: number; + _timeoutId: ReturnType; + _watchState: "OFF" | "ACTIVE_LOCK" | "WAITING_ACTIVE" | "ACTIVE_ERROR" | "BACKGROUND" | "BACKGROUND_ERROR"; + _lastKnownPosition: any; + _userLocationDotMarker: Marker; + _accuracyCircleMarker: Marker; + _accuracy: number; + _setup: boolean; + constructor(options: GeolocateOptions); + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement; + /** {@inheritDoc IControl.onRemove} */ + onRemove(): void; + /** + * Check if the Geolocation API Position is outside the map's maxbounds. + * + * @param position - the Geolocation API Position + * @returns `true` if position is outside the map's maxbounds, otherwise returns `false`. + */ + _isOutOfMapMaxBounds(position: GeolocationPosition): boolean; + _setErrorState(): void; + /** + * When the Geolocation API returns a new location, update the GeolocateControl. + * + * @param position - the Geolocation API Position + */ + _onSuccess: (position: GeolocationPosition) => void; + /** + * Update the camera location to center on the current position + * + * @param position - the Geolocation API Position + */ + _updateCamera: (position: GeolocationPosition) => void; + /** + * Update the user location dot Marker to the current position + * + * @param position - the Geolocation API Position + */ + _updateMarker: (position?: GeolocationPosition | null) => void; + _updateCircleRadius(): void; + _onZoom: () => void; + _onError: (error: GeolocationPositionError) => void; + _finish: () => void; + _setupUI: (supported: boolean) => void; + /** + * Programmatically request and move the map to the user's location. + * + * @returns `false` if called before control was added to a map, otherwise returns `true`. + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * map.on('load', function() { + * geolocate.trigger(); + * }); + * ``` + */ + trigger(): boolean; + _clearWatch(): void; +} +/** + * The {@link AttributionControl} options + */ +export type AttributionOptions = { + /** + * If `true`, the attribution control will always collapse when moving the map. If `false`, + * force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide. + * **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.** + */ + compact?: boolean; + /** + * Attributions to show in addition to any other attributions. + */ + customAttribution?: string | Array; +}; +export declare class AttributionControl implements IControl { + options: AttributionOptions; + _map: Map; + _compact: boolean; + _container: HTMLElement; + _innerContainer: HTMLElement; + _compactButton: HTMLElement; + _editLink: HTMLAnchorElement; + _attribHTML: string; + styleId: string; + styleOwner: string; + /** + * @param options - the attribution options + */ + constructor(options?: AttributionOptions); + getDefaultPosition(): ControlPosition; + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement; + /** {@inheritDoc IControl.onRemove} */ + onRemove(): void; + _setElementTitle(element: HTMLElement, title: string): void; + _toggleAttribution: () => void; + _updateData: (e: MapDataEvent) => void; + _updateAttributions(): void; + _updateCompact: () => void; + _updateCompactMinimize: () => void; +} +/** + * The {@link LogoControl} options object + */ +export type LogoOptions = { + /** + * If `true`, force a compact logo. + * If `false`, force the full logo. The default is a responsive logo that collapses when the map is less than 640 pixels wide. + */ + compact?: boolean; +}; +export declare class LogoControl implements IControl { + options: LogoOptions; + _map: Map; + _compact: boolean; + _container: HTMLElement; + constructor(options?: LogoOptions); + getDefaultPosition(): ControlPosition; + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement; + /** {@inheritDoc IControl.onRemove} */ + onRemove(): void; + _updateCompact: () => void; +} +/** + * The unit type for length to use for the {@link ScaleControl} + */ +export type Unit = "imperial" | "metric" | "nautical"; +/** + * The {@link ScaleControl} options object + */ +export type ScaleOptions = { + /** + * The maximum length of the scale control in pixels. + * @defaultValue 100 + */ + maxWidth?: number; + /** + * Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`). + * @defaultValue 'metric' + */ + unit?: Unit; +}; +export declare class ScaleControl implements IControl { + _map: Map; + _container: HTMLElement; + options: ScaleOptions; + constructor(options: ScaleOptions); + getDefaultPosition(): ControlPosition; + _onMove: () => void; + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement; + /** {@inheritDoc IControl.onRemove} */ + onRemove(): void; + /** + * Set the scale's unit of the distance + * + * @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`). + */ + setUnit: (unit: Unit) => void; +} +/** + * The {@link FullscreenControl} options + */ +export type FullscreenOptions = { + /** + * `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen. + */ + container?: HTMLElement; +}; +export declare class FullscreenControl extends Evented implements IControl { + _map: Map; + _controlContainer: HTMLElement; + _fullscreen: boolean; + _fullscreenchange: string; + _fullscreenButton: HTMLButtonElement; + _container: HTMLElement; + _prevCooperativeGestures: boolean | GestureOptions; + constructor(options?: FullscreenOptions); + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement; + /** {@inheritDoc IControl.onRemove} */ + onRemove(): void; + _setupUI(): void; + _updateTitle(): void; + _getTitle(): any; + _isFullscreen(): boolean; + _onFullscreenChange: () => void; + _handleFullscreenChange(): void; + _onClickFullscreen: () => void; + _exitFullscreen(): void; + _requestFullscreen(): void; + _togglePseudoFullScreen(): void; +} +export declare class TerrainControl implements IControl { + options: TerrainSpecification; + _map: Map; + _container: HTMLElement; + _terrainButton: HTMLButtonElement; + constructor(options: TerrainSpecification); + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement; + /** {@inheritDoc IControl.onRemove} */ + onRemove(): void; + _toggleTerrain: () => void; + _updateTerrainIcon: () => void; +} +declare function prewarm(): void; +declare function clearPrewarmedResources(): void; +/** + * A way to indentify a feature, either by string or by number + */ +export type GeoJSONFeatureId = number | string; +/** + * The geojson source diff object + */ +export type GeoJSONSourceDiff = { + /** + * When set to `true` it will remove all features + */ + removeAll?: boolean; + /** + * An array of features IDs to remove + */ + remove?: Array; + /** + * An array of features to add + */ + add?: Array; + /** + * An array of update objects + */ + update?: Array; +}; +/** + * A geojson feature diff object + */ +export type GeoJSONFeatureDiff = { + /** + * The feature ID + */ + id: GeoJSONFeatureId; + /** + * If it's a new geometry, place it here + */ + newGeometry?: GeoJSON.Geometry; + /** + * Setting to `true` will remove all preperties + */ + removeAllProperties?: boolean; + /** + * The properties keys to remove + */ + removeProperties?: Array; + /** + * The properties to add or update along side their values + */ + addOrUpdateProperties?: Array<{ + key: string; + value: any; + }>; +}; +export type GeoJSONSourceOptions = GeoJSONSourceSpecification & { + workerOptions?: WorkerOptions; + collectResourceTiming?: boolean; +}; +export type GeoJsonSourceOptions = { + data?: GeoJSON.GeoJSON | string | undefined; + cluster?: boolean; + clusterMaxZoom?: number; + clusterRadius?: number; + clusterMinPoints?: number; + generateId?: boolean; +}; +export type WorkerOptions = { + source?: string; + cluster?: boolean; + geojsonVtOptions?: { + buffer?: number; + tolerance?: number; + extent?: number; + maxZoom?: number; + linemetrics?: boolean; + generateId?: boolean; + }; + superclusterOptions?: Options; + clusterProperties?: ClusterProperties; + fliter?: any; + promoteId?: any; + collectResourceTiming?: boolean; +}; +/** + * The cluster options to set + */ +export type SetClusterOptions = { + /** + * Whether or not to cluster + */ + cluster?: boolean; + /** + * The cluster's max zoom + */ + clusterMaxZoom?: number; + /** + * The cluster's radius + */ + clusterRadius?: number; +}; +export declare class GeoJSONSource extends Evented implements Source { + type: "geojson"; + id: string; + minzoom: number; + maxzoom: number; + tileSize: number; + attribution: string; + promoteId: PromoteIdSpecification; + isTileClipped: boolean; + reparseOverscaled: boolean; + _data: GeoJSON.GeoJSON | string | undefined; + _options: GeoJsonSourceOptions; + workerOptions: WorkerOptions; + map: Map; + actor: Actor; + _pendingLoads: number; + _collectResourceTiming: boolean; + _removed: boolean; + /** @internal */ + constructor(id: string, options: GeoJSONSourceOptions, dispatcher: Dispatcher, eventedParent: Evented); + load: () => void; + onAdd(map: Map): void; + /** + * Sets the GeoJSON data and re-renders the map. + * + * @param data - A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files. + * @returns `this` + */ + setData(data: GeoJSON.GeoJSON | string): this; + /** + * Updates the source's GeoJSON, and re-renders the map. + * + * For sources with lots of features, this method can be used to make updates more quickly. + * + * This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature, + * or by using the promoteId option to specify which property should be used as the ID. + * + * It is an error to call updateData on a source that did not have unique IDs for each of its features already. + * + * Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error. + * + * @param diff - The changes that need to be applied. + * @returns `this` + */ + updateData(diff: GeoJSONSourceDiff): this; + /** + * To disable/enable clustering on the source options + * @param options - The options to set + * @returns `this` + * @example + * ```ts + * map.getSource('some id').setClusterOptions({cluster: false}); + * map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14}); + * ``` + */ + setClusterOptions(options: SetClusterOptions): this; + /** + * For clustered sources, fetches the zoom at which the given cluster expands. + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param callback - A callback to be called when the zoom value is retrieved (`(error, zoom) => { ... }`). + * @returns `this` + */ + getClusterExpansionZoom(clusterId: number, callback: Callback): this; + /** + * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features). + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`). + * @returns `this` + */ + getClusterChildren(clusterId: number, callback: Callback>): this; + /** + * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features). + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param limit - The maximum number of features to return. + * @param offset - The number of features to skip (e.g. for pagination). + * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`). + * @returns `this` + * @example + * Retrieve cluster leaves on click + * ```ts + * map.on('click', 'clusters', function(e) { + * let features = map.queryRenderedFeatures(e.point, { + * layers: ['clusters'] + * }); + * + * let clusterId = features[0].properties.cluster_id; + * let pointCount = features[0].properties.point_count; + * let clusterSource = map.getSource('clusters'); + * + * clusterSource.getClusterLeaves(clusterId, pointCount, 0, function(error, features) { + * // Print cluster leaves in the console + * console.log('Cluster leaves:', error, features); + * }) + * }); + * ``` + */ + getClusterLeaves(clusterId: number, limit: number, offset: number, callback: Callback>): this; + /** + * Responsible for invoking WorkerSource's geojson.loadData target, which + * handles loading the geojson data and preparing to serve it up as tiles, + * using geojson-vt or supercluster as appropriate. + * @param diff - the diff object + */ + _updateWorkerData(diff?: GeoJSONSourceDiff): void; + loaded(): boolean; + loadTile(tile: Tile, callback: Callback): void; + abortTile(tile: Tile): void; + unloadTile(tile: Tile): void; + onRemove(): void; + serialize: () => GeoJSONSourceSpecification; + hasTransition(): boolean; +} +export declare class TileBounds { + bounds: LngLatBounds; + minzoom: number; + maxzoom: number; + constructor(bounds: [ + number, + number, + number, + number + ], minzoom?: number | null, maxzoom?: number | null); + validateBounds(bounds: [ + number, + number, + number, + number + ]): LngLatBoundsLike; + contains(tileID: CanonicalTileID): boolean; +} +export declare class RasterTileSource extends Evented implements Source { + type: "raster" | "raster-dem"; + id: string; + minzoom: number; + maxzoom: number; + url: string; + scheme: string; + tileSize: number; + bounds: [ + number, + number, + number, + number + ]; + tileBounds: TileBounds; + roundZoom: boolean; + dispatcher: Dispatcher; + map: Map; + tiles: Array; + _loaded: boolean; + _options: RasterSourceSpecification | RasterDEMSourceSpecification; + _tileJSONRequest: Cancelable; + constructor(id: string, options: RasterSourceSpecification | RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented); + load(): void; + loaded(): boolean; + onAdd(map: Map): void; + onRemove(): void; + setSourceProperty(callback: Function): void; + /** + * Sets the source `tiles` property and re-renders the map. + * + * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) + * @returns `this` + */ + setTiles(tiles: Array): this; + serialize(): any; + hasTile(tileID: OverscaledTileID): boolean; + loadTile(tile: Tile, callback: Callback): void; + abortTile(tile: Tile, callback: Callback): void; + unloadTile(tile: Tile, callback: Callback): void; + hasTransition(): boolean; +} +export declare class RasterDEMTileSource extends RasterTileSource implements Source { + encoding: DEMEncoding; + redFactor?: number; + greenFactor?: number; + blueFactor?: number; + baseShift?: number; + constructor(id: string, options: RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented); + loadTile(tile: Tile, callback: Callback): void; + _getNeighboringTiles(tileID: OverscaledTileID): {}; + unloadTile(tile: Tile): void; +} +export type VectorTileSourceOptions = VectorSourceSpecification & { + collectResourceTiming?: boolean; +}; +export declare class VectorTileSource extends Evented implements Source { + type: "vector"; + id: string; + minzoom: number; + maxzoom: number; + url: string; + scheme: string; + tileSize: number; + promoteId: PromoteIdSpecification; + _options: VectorSourceSpecification; + _collectResourceTiming: boolean; + dispatcher: Dispatcher; + map: Map; + bounds: [ + number, + number, + number, + number + ]; + tiles: Array; + tileBounds: TileBounds; + reparseOverscaled: boolean; + isTileClipped: boolean; + _tileJSONRequest: Cancelable; + _loaded: boolean; + constructor(id: string, options: VectorTileSourceOptions, dispatcher: Dispatcher, eventedParent: Evented); + load: () => void; + loaded(): boolean; + hasTile(tileID: OverscaledTileID): boolean; + onAdd(map: Map): void; + setSourceProperty(callback: Function): void; + /** + * Sets the source `tiles` property and re-renders the map. + * + * @param tiles - An array of one or more tile source URLs, as in the TileJSON spec. + * @returns `this` + */ + setTiles(tiles: Array): this; + /** + * Sets the source `url` property and re-renders the map. + * + * @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`. + * @returns `this` + */ + setUrl(url: string): this; + onRemove(): void; + serialize: () => VectorSourceSpecification; + loadTile(tile: Tile, callback: Callback): void; + abortTile(tile: Tile): void; + unloadTile(tile: Tile): void; + hasTransition(): boolean; +} +export declare class VideoSource extends ImageSource { + options: VideoSourceSpecification; + urls: Array; + video: HTMLVideoElement; + roundZoom: boolean; + constructor(id: string, options: VideoSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented); + load: () => void; + /** + * Pauses the video. + */ + pause(): void; + /** + * Plays the video. + */ + play(): void; + /** + * Sets playback to a timestamp, in seconds. + */ + seek(seconds: number): void; + /** + * Returns the HTML `video` element. + * + * @returns The HTML `video` element. + */ + getVideo(): HTMLVideoElement; + onAdd(map: Map): void; + /** + * Sets the video's coordinates and re-renders the map. + * + * @returns `this` + */ + prepare: () => this; + serialize: () => VideoSourceSpecification; + hasTransition(): boolean; +} +export declare class MapLibreGL { + static Map: typeof Map; + static NavigationControl: typeof NavigationControl; + static GeolocateControl: typeof GeolocateControl; + static AttributionControl: typeof AttributionControl; + static LogoControl: typeof LogoControl; + static ScaleControl: typeof ScaleControl; + static FullscreenControl: typeof FullscreenControl; + static TerrainControl: typeof TerrainControl; + static Popup: typeof Popup; + static Marker: typeof Marker; + static Style: typeof Style; + static LngLat: typeof LngLat; + static LngLatBounds: typeof LngLatBounds; + static Point: typeof Point; + static MercatorCoordinate: typeof MercatorCoordinate; + static Evented: typeof Evented; + static AJAXError: typeof AJAXError; + static config: { + MAX_PARALLEL_IMAGE_REQUESTS: number; + MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number; + MAX_TILE_CACHE_ZOOM_LEVELS: number; + REGISTERED_PROTOCOLS: { + [x: string]: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable; + }; + WORKER_URL: string; + }; + static CanvasSource: typeof CanvasSource; + static GeoJSONSource: typeof GeoJSONSource; + static ImageSource: typeof ImageSource; + static RasterDEMTileSource: typeof RasterDEMTileSource; + static RasterTileSource: typeof RasterTileSource; + static VectorTileSource: typeof VectorTileSource; + static VideoSource: typeof VideoSource; + /** + * Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text). + * Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. + * + * @param pluginURL - URL pointing to the Mapbox RTL text plugin source. + * @param callback - Called with an error argument if there is an error. + * @param lazy - If set to `true`, mapboxgl will defer loading the plugin until rtl text is encountered, + * rtl text will then be rendered only after the plugin finishes loading. + * @example + * ```ts + * maplibregl.setRTLTextPlugin('https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.js'); + * ``` + * @see [Add support for right-to-left scripts](https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/) + */ + static setRTLTextPlugin: (url: string, callback: (error?: Error) => void, deferred?: boolean) => void; + /** + * Gets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) status. + * The status can be `unavailable` (i.e. not requested or removed), `loading`, `loaded` or `error`. + * If the status is `loaded` and the plugin is requested again, an error will be thrown. + * + * @example + * ```ts + * const pluginStatus = maplibregl.getRTLTextPluginStatus(); + * ``` + */ + static getRTLTextPluginStatus: () => string; + /** + * Initializes resources like WebWorkers that can be shared across maps to lower load + * times in some situations. `maplibregl.workerUrl` and `maplibregl.workerCount`, if being + * used, must be set before `prewarm()` is called to have an effect. + * + * By default, the lifecycle of these resources is managed automatically, and they are + * lazily initialized when a Map is first created. By invoking `prewarm()`, these + * resources will be created ahead of time, and will not be cleared when the last Map + * is removed from the page. This allows them to be re-used by new Map instances that + * are created later. They can be manually cleared by calling + * `maplibregl.clearPrewarmedResources()`. This is only necessary if your web page remains + * active but stops using maps altogether. + * + * This is primarily useful when using GL-JS maps in a single page app, wherein a user + * would navigate between various views that can cause Map instances to constantly be + * created and destroyed. + * + * @example + * ```ts + * maplibregl.prewarm() + * ``` + */ + static prewarm: typeof prewarm; + /** + * Clears up resources that have previously been created by `maplibregl.prewarm()`. + * Note that this is typically not necessary. You should only call this function + * if you expect the user of your app to not return to a Map view at any point + * in your application. + * + * @example + * ```ts + * maplibregl.clearPrewarmedResources() + * ``` + */ + static clearPrewarmedResources: typeof clearPrewarmedResources; + /** + * Returns the package version of the library + * @returns Package version of the library + */ + static get version(): string; + /** + * Gets and sets the number of web workers instantiated on a page with GL JS maps. + * By default, workerCount is 1 except for Safari browser where it is set to half the number of CPU cores (capped at 3). + * Make sure to set this property before creating any map instances for it to have effect. + * + * @returns Number of workers currently configured. + * @example + * ```ts + * maplibregl.workerCount = 2; + * ``` + */ + static get workerCount(): number; + static set workerCount(count: number); + /** + * Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel, + * which affects performance in raster-heavy maps. 16 by default. + * + * @returns Number of parallel requests currently configured. + * @example + * ```ts + * maplibregl.maxParallelImageRequests = 10; + * ``` + */ + static get maxParallelImageRequests(): number; + static set maxParallelImageRequests(numRequests: number); + static get workerUrl(): string; + static set workerUrl(value: string); + /** + * Sets a custom load tile function that will be called when using a source that starts with a custom url schema. + * The example below will be triggered for custom:// urls defined in the sources list in the style definitions. + * The function passed will receive the request parameters and should call the callback with the resulting request, + * for example a pbf vector tile, non-compressed, represented as ArrayBuffer. + * + * @param customProtocol - the protocol to hook, for example 'custom' + * @param loadFn - the function to use when trying to fetch a tile specified by the customProtocol + * @example + * This will fetch a file using the fetch API (this is obviously a non interesting example...) + * ```ts + * maplibregl.addProtocol('custom', (params, callback) => { + fetch(`https://${params.url.split("://")[1]}`) + .then(t => { + if (t.status == 200) { + t.arrayBuffer().then(arr => { + callback(null, arr, null, null); + }); + } else { + callback(new Error(`Tile fetch error: ${t.statusText}`)); + } + }) + .catch(e => { + callback(new Error(e)); + }); + return { cancel: () => { } }; + }); + * // the following is an example of a way to return an error when trying to load a tile + * maplibregl.addProtocol('custom2', (params, callback) => { + * callback(new Error('someErrorMessage')); + * return { cancel: () => { } }; + * }); + * ``` + */ + static addProtocol(customProtocol: string, loadFn: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable): void; + /** + * Removes a previously added protocol + * + * @param customProtocol - the custom protocol to remove registration for + * @example + * ```ts + * maplibregl.removeProtocol('custom'); + * ``` + */ + static removeProtocol(customProtocol: string): void; +} +export type * from "@maplibre/maplibre-gl-style-spec"; + +export { + MapLibreGL as default, +}; + +export as namespace maplibregl; + +export {}; diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl.js b/web/libraries/maplibre-gl/dist/maplibre-gl.js new file mode 100644 index 00000000..1ff44afe --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl.js @@ -0,0 +1,48 @@ +/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.6.2/LICENSE.txt */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var shared, worker, maplibregl; +// define gets called three times: one for each chunk. we rely on the order +// they're imported to know which is which +function define(_, chunk) { + if (!shared) { + shared = chunk; + } else if (!worker) { + worker = chunk; + } else { + var workerBundleString = 'var sharedChunk = {}; (' + shared + ')(sharedChunk); (' + worker + ')(sharedChunk);' + + var sharedChunk = {}; + shared(sharedChunk); + maplibregl = chunk(sharedChunk); + if (typeof window !== 'undefined') { + maplibregl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); + } + } +} + + +define(["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,a){function s(t){try{l(n.next(t));}catch(t){a(t);}}function o(t){try{l(n.throw(t));}catch(t){a(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(s,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var n=i;function i(t,e){this.x=t,this.y=e;}i.prototype={clone:function(){return new i(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},i.convert=function(t){return t instanceof i?t:Array.isArray(t)?new i(t[0],t[1]):t};var a=r(n),s=o;function o(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}o.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?s=r:o=r,r=.5*(o-s)+s;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var l=r(s);let u,c;function h(){return null==u&&(u="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),u}function p(){if(null==c&&(c=!1,h())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r(e.y-t.y)*(r.x-t.x)}function k(t){let e=0;for(let r,n,i=0,a=t.length,s=a-1;icancelAnimationFrame(e)}},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0,t.width,t.height),r},resolveURL:t=>(E||(E=document.createElement("a")),E.href=t,E.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==F&&(F=matchMedia("(prefers-reduced-motion: reduce)")),F.matches)}},$={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};class L extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n;}}const D=I()?()=>self.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href,O=t=>$.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))];function U(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:D(),signal:r.signal});let i=!1,a=!1;"json"===t.type&&n.headers.set("Accept","application/json");return a||fetch(n).then((r=>r.ok?(r=>{("arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{a||(i=!0,e(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")));})).catch((t=>{a||e(new Error(t.message));}));})(r):r.blob().then((n=>e(new L(r.status,r.statusText,t.url,n)))))).catch((t=>{20!==t.code&&e(new Error(t.message));})),{cancel:()=>{a=!0,i||r.abort();}}}const R=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(I()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!I())return (O(t.url)||U)(t,e)}if(!(/^file:/.test(r=t.url)||/^file:/.test(D())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return U(t,e);if(I()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return "json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===t.type)try{n=JSON.parse(r.response);}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"));}else {const n=new Blob([r.response],{type:r.getResponseHeader("Content-Type")});e(new L(r.status,r.statusText,t.url,n));}},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},q=function(t,e){return R(g(t,{type:"arrayBuffer"}),e)};function j(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function N(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function Z(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class K{constructor(t,e={}){g(this,e),this.type=t;}}class G extends K{constructor(t,e={}){super("error",g({error:t},e));}}class J{on(t,e){return this._listeners=this._listeners||{},N(t,e,this._listeners),this}off(t,e){return Z(t,e,this._listeners),Z(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},N(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new K(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)Z(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(g(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof G&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var X={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const Y=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function H(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return Y.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function W(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const kt=[ht,pt,ft,dt,yt,vt,mt,At(gt),bt,wt,_t];function It(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!It(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of kt)if(!It(t,e))return null}return `Expected ${St(t)} but found ${St(e)} instead.`}function zt(t,e){return e.some((e=>e.kind===t.kind))}function Mt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Ct(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Bt=.96422,Pt=.82521,Vt=4/29,Et=6/29,Ft=3*Et*Et,Tt=Et*Et*Et,$t=Math.PI/180,Lt=180/Math.PI;function Dt(t){return (t%=360)<0&&(t+=360),t}function Ot([t,e,r,n]){let i,a;const s=Rt((.2225045*(t=Ut(t))+.7168786*(e=Ut(e))+.0606169*(r=Ut(r)))/1);t===e&&e===r?i=a=s:(i=Rt((.4360747*t+.3850649*e+.1430804*r)/Bt),a=Rt((.0139322*t+.0971045*e+.7141733*r)/Pt));const o=116*s-16;return [o<0?0:o,500*(i-s),200*(s-a),n]}function Ut(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Rt(t){return t>Tt?Math.pow(t,1/3):t/Ft+Vt}function qt([t,e,r,n]){let i=(t+16)/116,a=isNaN(e)?i:i+e/500,s=isNaN(r)?i:i-r/200;return i=1*Nt(i),a=Bt*Nt(a),s=Pt*Nt(s),[jt(3.1338561*a-1.6168667*i-.4906146*s),jt(-.9787684*a+1.9161415*i+.033454*s),jt(.0719453*a-.2289914*i+1.4052427*s),n]}function jt(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function Nt(t){return t>Et?t*t*t:Ft*(t-Vt)}function Zt(t){return parseInt(t.padEnd(2,t),16)/255}function Kt(t,e){return Gt(e?t/100:t,0,1)}function Gt(t,e,r){return Math.min(Math.max(e,t),r)}function Jt(t){return !t.some(Number.isNaN)}const Xt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class Yt{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof Yt)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=Xt[t];if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [Zt(t.slice(r,r+=e)),Zt(t.slice(r,r+=e)),Zt(t.slice(r,r+=e)),Zt(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,a,s,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,s,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[Gt(+r/e,0,1),Gt(+a/e,0,1),Gt(+l/e,0,1),h?Kt(+h,p):1];if(Jt(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,a,s,o,l,u]=r,c=[n||" ",a||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,Gt(+i,0,100),Gt(+s,0,100),l?Kt(+l,u):1];if(Jt(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,a=e*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return t=Dt(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new Yt(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=Ot(t),a=Math.sqrt(r*r+n*n);return [Math.round(1e4*a)?Dt(Math.atan2(n,r)*Lt):NaN,a,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Ot(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}}Yt.black=new Yt(0,0,0,1),Yt.white=new Yt(1,1,1,1),Yt.transparent=new Yt(0,0,0,0),Yt.red=new Yt(1,0,0,1);class Ht{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Wt{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class Qt{constructor(t){this.sections=t;}static fromString(t){return new Qt([new Wt(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Qt?t:Qt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class te{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof te)return t;if("number"==typeof t)return new te([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new te(t)}}toString(){return JSON.stringify(this.values)}}const ee=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class re{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof re)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ae(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Yt||t instanceof Ht||t instanceof Qt||t instanceof te||t instanceof re||t instanceof ne)return !0;if(Array.isArray(t)){for(const e of t)if(!ae(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!ae(t[e]))return !1;return !0}return !1}function se(t){if(null===t)return ht;if("string"==typeof t)return ft;if("boolean"==typeof t)return dt;if("number"==typeof t)return pt;if(t instanceof Yt)return yt;if(t instanceof Ht)return xt;if(t instanceof Qt)return vt;if(t instanceof te)return bt;if(t instanceof re)return _t;if(t instanceof ne)return wt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=se(e);if(r){if(r===t)continue;r=gt;break}r=t;}return At(r||gt,e)}return mt}function oe(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Yt||t instanceof Qt||t instanceof te||t instanceof re||t instanceof ne?t.toString():JSON.stringify(t)}class le{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!ae(t[1]))return e.error("invalid value");const r=t[1];let n=se(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new le(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}class ue{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const ce={string:ft,number:pt,boolean:dt,object:mt};class he{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,a;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in ce)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=ce[r],n++;}else i=gt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],n++;}r=At(i,a);}else {if(!ce[i])throw new Error(`Types doesn't contain name = ${i}`);r=ce[i];}const a=[];for(;nt.outputDefined()))}}const pe={"to-boolean":dt,"to-color":yt,"to-number":pt,"to-string":ft};class fe{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!pe[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=pe[r],i=[];for(let r=1;r4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ie(e[0],e[1],e[2],e[3]),!r))return new Yt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ue(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=te.parse(e);if(n)return n}throw new ue(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=re.parse(e);if(n)return n}throw new ue(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ue(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Qt.fromString(oe(this.args[0].evaluate(t)));case"resolvedImage":return ne.fromString(oe(this.args[0].evaluate(t)));default:return oe(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const de=["Unknown","Point","LineString","Polygon"];class ye{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?de[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Yt.parse(t)),e}}class me{constructor(t,e,r=[],n,i=new ct,a=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=a,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new he(e,[t]):"coerce"===r?new fe(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof le)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new ye;try{n=new le(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new me(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new ut(r,t));}checkSubtype(t,e){const r=It(t,e);return r&&this.error(r),r}}class ge{constructor(t,e,r){this.type=xt,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,dt);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,dt);if(!i)return null;let a=null;return r.locale&&(a=e.parse(r.locale,1,ft),!a)?null:new ge(n,i,a)}evaluate(t){return new Ht(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}const xe=8192;function ve(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function be(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function we(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*xe),Math.round(n*i*xe)]}function _e(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],a=t[0]-r[0],s=t[1]-r[1];return n*s-a*i==0&&n*a<=0&&i*s<=0}function Ae(t,e){let r=!1;for(let s=0,o=e.length;s(n=t)[1]!=(a=o[e+1])[1]>n[1]&&n[0]<(a[0]-i[0])*(n[1]-i[1])/(a[1]-i[1])+i[0]&&(r=!r);}}var n,i,a;return r}function Se(t,e){for(let r=0;r0&&o<0||s<0&&o>0}function Ie(t,e,r){for(const u of r)for(let r=0;rr[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}ve(e,t);}function Ve(t,e,r,n){const i=Math.pow(2,n.z)*xe,a=[n.x*xe,n.y*xe],s=[];for(const n of t)for(const t of n){const n=[t.x+a[0],t.y+a[1]];Pe(n,e,r,i),s.push(n);}return s}function Ee(t,e,r,n){const i=Math.pow(2,n.z)*xe,a=[n.x*xe,n.y*xe],s=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+a[0],n.y+a[1]];ve(e,r),t.push(r);}s.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of s)for(const n of t)Pe(n,e,r,i);}var o;return s}class Fe{constructor(t,e){this.type=dt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ae(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,a]of s){o=new me(e.registry,Le,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(St).join(", ")})`:`(${St(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&Le(t):r&&t instanceof le;})),!!r&&De(t)&&Ue(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function De(t){if(t instanceof $e){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Fe)return !1;let e=!0;return t.eachChild((t=>{e&&!De(t)&&(e=!1);})),e}function Oe(t){if(t instanceof $e&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Oe(t)&&(e=!1);})),e}function Ue(t,e){if(t instanceof $e&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!Ue(t,e)&&(r=!1);})),r}function Re(t,e){const r=t.length-1;let n,i,a=0,s=r,o=0;for(;a<=s;)if(o=Math.floor((a+s)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new ue("Input is not a number.");s=o-1;}return 0}class qe{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,pt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(s,l,i);if(!u)return null;i=i||u.type,n.push([a,u]);}return new qe(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[Re(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function je(t,e,r){return t+r*(e-t)}function Ne(t,e,r){return t.map(((t,n)=>je(t,e[n],r)))}const Ze={number:je,color:function(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,a,s]=Ne(t.rgb,e.rgb,r);return new Yt(n,i,a,s,!1)}case"hcl":{const[n,i,a,s]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==a&&0!==a||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*$t,qt([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:je(i,l,r),je(a,u,r),je(s,c,r)]);return new Yt(f,d,y,m,!1)}case"lab":{const[n,i,a,s]=qt(Ne(t.lab,e.lab,r));return new Yt(n,i,a,s,!1)}}},array:Ne,padding:function(t,e,r){return new te(Ne(t.values,e.values,r))},variableAnchorOffsetCollection:function(t,e,r){const n=t.values,i=e.values;if(n.length!==i.length)throw new ue(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const a=[];for(let t=0;t"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,pt),!i)return null;const s=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=yt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,s.push([r,u]);}return Ct(o,pt)||Ct(o,yt)||Ct(o,bt)||Ct(o,_t)||Ct(o,At(pt))?new Ke(o,r,n,i,s):e.error(`Type ${St(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const a=Re(e,n),s=Ke.interpolationFactor(this.interpolation,n,e[a],e[a+1]),o=r[a].evaluate(t),l=r[a+1].evaluate(t);switch(this.operator){case"interpolate":return Ze[this.type.kind](o,l,s);case"interpolate-hcl":return Ze.color(o,l,s,"hcl");case"interpolate-lab":return Ze.color(o,l,s,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Ge(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}class Je{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const a=n&&i.some((t=>It(n,t.type)));return new Je(a?gt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof ne&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}class Xe{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new ue(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new ue(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class He{constructor(t,e){this.type=dt,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,gt),n=e.parse(t[2],2,gt);return r&&n?zt(r.type,[dt,ft,pt,ht,gt])?new He(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${St(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Mt(e,["boolean","string","number","null"]))throw new ue(`Expected first argument to be of type boolean, string, number or null, but found ${St(se(e))} instead.`);if(!Mt(r,["string","array"]))throw new ue(`Expected second argument to be of type array or string, but found ${St(se(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class We{constructor(t,e,r){this.type=pt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,gt),n=e.parse(t[2],2,gt);if(!r||!n)return null;if(!zt(r.type,[dt,ft,pt,ht,gt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${St(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,pt);return i?new We(r,n,i):null}return new We(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Mt(e,["boolean","string","number","null"]))throw new ue(`Expected first argument to be of type boolean, string, number or null, but found ${St(se(e))} instead.`);if(!Mt(r,["string","array"]))throw new ue(`Expected second argument to be of type array or string, but found ${St(se(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class Qe{constructor(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},a=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,se(t)))return null}else r=se(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=a.length;}const c=e.parse(l,s,n);if(!c)return null;n=n||c.type,a.push(c);}const s=e.parse(t[1],1,gt);if(!s)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==s.type.kind&&e.concat(1).checkSubtype(r,s.type)?null:new Qe(r,n,s,i,a,o):null}evaluate(t){const e=this.input.evaluate(t);return (se(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class tr{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class er{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,gt),n=e.parse(t[2],2,pt);if(!r||!n)return null;if(!zt(r.type,[At(gt),ft,gt]))return e.error(`Expected first argument to be of type array or string, but found ${St(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,pt);return i?new er(r.type,r,n,i):null}return new er(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!Mt(e,["string","array"]))throw new ue(`Expected first argument to be of type array or string, but found ${St(se(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function rr(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function nr(t,e,r,n){return 0===n.compare(e,r)}function ir(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=dt,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let a=e.parse(t[1],1,gt);if(!a)return null;if(!rr(r,a.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${St(a.type)}'.`);let s=e.parse(t[2],2,gt);if(!s)return null;if(!rr(r,s.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${St(s.type)}'.`);if(a.type.kind!==s.type.kind&&"value"!==a.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${St(a.type)}' and '${St(s.type)}'.`);n&&("value"===a.type.kind&&"value"!==s.type.kind?a=new he(s.type,[a]):"value"!==a.type.kind&&"value"===s.type.kind&&(s=new he(a.type,[s])));let o=null;if(4===t.length){if("string"!==a.type.kind&&"string"!==s.type.kind&&"value"!==a.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,xt),!o)return null}return new i(a,s,o)}evaluate(i){const a=this.lhs.evaluate(i),s=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=se(a),r=se(s);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new ue(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=se(a),r=se(s);if("string"!==t.kind||"string"!==r.kind)return e(i,a,s)}return this.collator?r(i,a,s,this.collator.evaluate(i)):e(i,a,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const ar=ir("==",(function(t,e,r){return e===r}),nr),sr=ir("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !nr(0,e,r,n)})),or=ir("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),ur=ir("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),cr=ir(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class hr{constructor(t,e,r,n,i){this.type=ft,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,pt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,ft),!i))return null;let a=null;if(n.currency&&(a=e.parse(n.currency,1,ft),!a))return null;let s=null;if(n["min-fraction-digits"]&&(s=e.parse(n["min-fraction-digits"],1,pt),!s))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,pt),!o)?null:new hr(r,i,a,s,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class pr{constructor(t){this.type=vt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const a=t[r];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;let t=null;if(a["font-scale"]&&(t=e.parse(a["font-scale"],1,pt),!t))return null;let r=null;if(a["text-font"]&&(r=e.parse(a["text-font"],1,At(ft)),!r))return null;let s=null;if(a["text-color"]&&(s=e.parse(a["text-color"],1,yt),!s))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=s;}else {const a=e.parse(t[r],1,gt);if(!a)return null;const s=a.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:a,scale:null,font:null,textColor:null});}}return new pr(n)}evaluate(t){return new Qt(this.sections.map((e=>{const r=e.content.evaluate(t);return se(r)===wt?new Wt("",r,null,null,null):new Wt(oe(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}}class fr{constructor(t){this.type=wt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,ft);return r?new fr(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=ne.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class dr{constructor(t){this.type=pt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${St(r.type)} instead.`):new dr(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ue(`Expected value to be of type string or array, but found ${St(se(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const yr={"==":ar,"!=":sr,">":lr,"<":or,">=":cr,"<=":ur,array:he,at:Ye,boolean:he,case:tr,coalesce:Je,collator:ge,format:pr,image:fr,in:He,"index-of":We,interpolate:Ke,"interpolate-hcl":Ke,"interpolate-lab":Ke,length:dr,let:Xe,literal:le,match:Qe,number:he,"number-format":hr,object:he,slice:er,step:qe,string:he,"to-boolean":fe,"to-color":fe,"to-number":fe,"to-string":fe,var:Te,within:Fe};function mr(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const a=i?i.evaluate(t):1,s=ie(e,r,n,a);if(s)throw new ue(s);return new Yt(e/255,r/255,n/255,a,!1)}function gr(t,e){return t in e}function xr(t,e){const r=e[t];return void 0===r?null:r}function vr(t){return {type:t}}function br(t){return {result:"success",value:t}}function wr(t){return {result:"error",value:t}}function _r(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Ar(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Sr(t){return !!t.expression&&t.expression.interpolated}function kr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Ir(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function zr(t){return t}function Mr(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),a=t.type||(Sr(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?Yt.parse:te.parse;(t=lt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default);}if(t.colorSpace&&"rgb"!==(s=t.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${t.colorSpace}"`);var s;let o,l,u;if("exponential"===a)o=Vr;else if("interval"===a)o=Pr;else if("categorical"===a){o=Br,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}else {if("identity"!==a)throw new Error(`Unknown function type "${a}"`);o=Er;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Vr({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:Ke.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Cr(t.default,e.default):o(t,e,i,l,u)}}}function Cr(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Br(t,e,r,n,i){return Cr(typeof r===i?n[r]:void 0,t.default,e.default)}function Pr(t,e,r){if("number"!==kr(r))return Cr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=Re(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Vr(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==kr(r))return Cr(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const a=Re(t.stops.map((t=>t[0])),r),s=function(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),o=t.stops[a][1],l=t.stops[a+1][1],u=Ze[e.type]||zr;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,s,t.colorSpace)}}:u(o,l,s,t.colorSpace)}function Er(t,e,r){switch(e.type){case"color":r=Yt.parse(r);break;case"formatted":r=Qt.fromString(r.toString());break;case"resolvedImage":r=ne.fromString(r.toString());break;case"padding":r=te.parse(r);break;default:kr(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return Cr(r,t.default,e.default)}$e.register(yr,{error:[{kind:"error"},[ft],(t,[e])=>{throw new ue(e.evaluate(t))}],typeof:[ft,[gt],(t,[e])=>St(se(e.evaluate(t)))],"to-rgba":[At(pt,4),[yt],(t,[e])=>{const[r,n,i,a]=e.evaluate(t).rgb;return [255*r,255*n,255*i,a]}],rgb:[yt,[pt,pt,pt],mr],rgba:[yt,[pt,pt,pt,pt],mr],has:{type:dt,overloads:[[[ft],(t,[e])=>gr(e.evaluate(t),t.properties())],[[ft,mt],(t,[e,r])=>gr(e.evaluate(t),r.evaluate(t))]]},get:{type:gt,overloads:[[[ft],(t,[e])=>xr(e.evaluate(t),t.properties())],[[ft,mt],(t,[e,r])=>xr(e.evaluate(t),r.evaluate(t))]]},"feature-state":[gt,[ft],(t,[e])=>xr(e.evaluate(t),t.featureState||{})],properties:[mt,[],t=>t.properties()],"geometry-type":[ft,[],t=>t.geometryType()],id:[gt,[],t=>t.id()],zoom:[pt,[],t=>t.globals.zoom],"heatmap-density":[pt,[],t=>t.globals.heatmapDensity||0],"line-progress":[pt,[],t=>t.globals.lineProgress||0],accumulated:[gt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[pt,vr(pt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[pt,vr(pt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:pt,overloads:[[[pt,pt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[pt],(t,[e])=>-e.evaluate(t)]]},"/":[pt,[pt,pt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[pt,[pt,pt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[pt,[],()=>Math.LN2],pi:[pt,[],()=>Math.PI],e:[pt,[],()=>Math.E],"^":[pt,[pt,pt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[pt,[pt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[pt,[pt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[pt,[pt],(t,[e])=>Math.log(e.evaluate(t))],log2:[pt,[pt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[pt,[pt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[pt,[pt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[pt,[pt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[pt,[pt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[pt,[pt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[pt,[pt],(t,[e])=>Math.atan(e.evaluate(t))],min:[pt,vr(pt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[pt,vr(pt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[pt,[pt],(t,[e])=>Math.abs(e.evaluate(t))],round:[pt,[pt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[pt,[pt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[pt,[pt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[dt,[ft,gt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[dt,[gt],(t,[e])=>t.id()===e.value],"filter-type-==":[dt,[ft],(t,[e])=>t.geometryType()===e.value],"filter-<":[dt,[ft,gt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[dt,[ft,gt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[dt,[gt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[dt,[ft,gt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[dt,[gt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[dt,[ft,gt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[dt,[gt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[dt,[gt],(t,[e])=>e.value in t.properties()],"filter-has-id":[dt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[dt,[At(ft)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[dt,[At(gt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[dt,[ft,At(gt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[dt,[ft,At(gt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:dt,overloads:[[[dt,dt],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[vr(dt),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:dt,overloads:[[[dt,dt],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[vr(dt),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[dt,[dt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[dt,[ft],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[ft,[ft],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ft,[ft],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ft,vr(gt),(t,e)=>e.map((e=>oe(e.evaluate(t)))).join("")],"resolved-locale":[ft,[xt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Fr{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new ye,this._defaultValue=e?"color"===(r=e).type&&Ir(r.default)?new Yt(0,0,0,0):"color"===r.type?Yt.parse(r.default)||null:"padding"===r.type?te.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?re.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new ue(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Tr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in yr}function $r(t,e){const r=new me(yr,Le,[],e?function(t){const e={color:yt,string:ft,number:pt,enum:ft,boolean:dt,formatted:vt,padding:bt,resolvedImage:wt,variableAnchorOffsetCollection:_t};return "array"===t.type?At(e[t.value]||gt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?br(new Fr(n,e)):wr(r.errors)}class Lr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Oe(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}}class Dr{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Oe(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}interpolationFactor(t,e,r){return this.interpolationType?Ke.interpolationFactor(this.interpolationType,t,e,r):0}}function Or(t,e){const r=$r(t,e);if("error"===r.result)return r;const n=r.value.expression,i=De(n);if(!i&&!_r(e))return wr([new ut("","data expressions not supported")]);const a=Ue(n,["zoom"]);if(!a&&!Ar(e))return wr([new ut("","zoom expressions not supported")]);const s=Rr(n);return s||a?s instanceof ut?wr([s]):s instanceof Ke&&!Sr(e)?wr([new ut("",'"interpolate" expressions cannot be used with this property')]):br(s?new Dr(i?"camera":"composite",r.value,s.labels,s instanceof Ke?s.interpolation:void 0):new Lr(i?"constant":"source",r.value)):wr([new ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Ur{constructor(t,e){this._parameters=t,this._specification=e,lt(this,Mr(this._parameters,this._specification));}static deserialize(t){return new Ur(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function Rr(t){let e=null;if(t instanceof Xe)e=Rr(t.result);else if(t instanceof Je){for(const r of t.args)if(e=Rr(r),e)break}else (t instanceof qe||t instanceof Ke)&&t.input instanceof $e&&"zoom"===t.input.name&&(e=t);return e instanceof ut||t.eachChild((t=>{const r=Rr(t);r instanceof ut?e=r:!e&&r?e=new ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new ut("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function qr(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!qr(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const jr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Nr(t){if(null==t)return {filter:()=>!0,needGeometry:!1};qr(t)||(t=Gr(t));const e=$r(t,jr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:Kr(t)}}function Zr(t,e){return te?1:0}function Kr(t){if(!Array.isArray(t))return !1;if("within"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?Jr(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Gr))):"all"===e?["all"].concat(t.slice(1).map(Gr)):"none"===e?["all"].concat(t.slice(1).map(Gr).map(Hr)):"in"===e?Xr(t[1],t.slice(2)):"!in"===e?Hr(Xr(t[1],t.slice(2))):"has"===e?Yr(t[1]):"!has"===e?Hr(Yr(t[1])):"within"!==e||t;var r;}function Jr(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function Xr(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Zr)]]:["filter-in-small",t,["literal",e]]}}function Yr(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function Hr(t){return ["!",t]}function Wr(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${Wr(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new ot(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function on(t){const e=t.valueSpec,r=en(t.value.type);let n,i,a,s={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===kr(t.value.stops)&&"array"===kr(t.value.stops[0])&&"object"===kr(t.value.stops[0][0]),c=nn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new ot(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(an({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===kr(n)&&0===n.length&&e.push(new ot(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new ot(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new ot(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Sr(t.valueSpec)&&c.push(new ot(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!_r(t.valueSpec)?c.push(new ot(t.key,t.value,"property functions not supported")):o&&!Ar(t.valueSpec)&&c.push(new ot(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new ot(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==kr(n))return [new ot(o,n,`array expected, ${kr(n)} found`)];if(2!==n.length)return [new ot(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==kr(n[0]))return [new ot(o,n,`object expected, ${kr(n[0])} found`)];if(void 0===n[0].zoom)return [new ot(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new ot(o,n,"object stop key must have value")];if(a&&a>en(n[0].zoom))return [new ot(o,n[0].zoom,"stop zoom values must appear in ascending order")];en(n[0].zoom)!==a&&(a=en(n[0].zoom),i=void 0,s={}),r=r.concat(nn({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:sn,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return Tr(rn(n[1]))?r.concat([new ot(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,a){const o=kr(t.value),l=en(t.value),u=null!==t.value?t.value:a;if(n){if(o!==n)return [new ot(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new ot(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return _r(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ot(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew ot(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new ot(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Oe(r))return [new ot(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Oe(r))return [new ot(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ue(r,["zoom","feature-state"]))return [new ot(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!De(r))return [new ot(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function un(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(en(r))&&i.push(new ot(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(en(r))&&i.push(new ot(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function cn(t){return qr(rn(t.value))?ln(lt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):hn(t)}function hn(t){const e=t.value,r=t.key;if("array"!==kr(e))return [new ot(r,e,`array expected, ${kr(e)} found`)];const n=t.styleSpec;let i,a=[];if(e.length<1)return [new ot(r,e,"filter array must have at least 1 element")];switch(a=a.concat(un({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),en(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===en(e[1])&&a.push(new ot(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&a.push(new ot(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=kr(e[1]),"string"!==i&&a.push(new ot(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let s=2;s{t in r&&e.push(new ot(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{en(e.id)===o&&(t=e);})),t?t.ref?e.push(new ot(n,r.ref,"ref cannot reference another ref layer")):s=en(t.type):e.push(new ot(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==s)if(r.source){const t=i.sources&&i.sources[r.source],a=t&&en(t.type);t?"vector"===a&&"raster"===s?e.push(new ot(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==a&&"hillshade"===s?e.push(new ot(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===a&&"raster"!==s?e.push(new ot(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==a||r["source-layer"]?"raster-dem"===a&&"hillshade"!==s?e.push(new ot(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!r.paint||!r.paint["line-gradient"]||"geojson"===a&&t.lineMetrics||e.push(new ot(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new ot(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new ot(n,r.source,`source "${r.source}" not found`));}else e.push(new ot(n,r,'missing required property "source"'));return e=e.concat(nn({key:n,value:r,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:cn,layout:t=>nn({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>dn(lt({layerType:s},t))}}),paint:t=>nn({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>fn(lt({layerType:s},t))}})}})),e}function mn(t){const e=t.value,r=t.key,n=kr(e);return "string"!==n?[new ot(r,e,`string expected, ${n} found`)]:[]}const gn={promoteId:function({key:t,value:e}){if("string"===kr(e))return mn({key:t,value:e});{const r=[];for(const n in e)r.push(...mn({key:`${t}.${n}`,value:e[n]}));return r}}};function xn(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,a=t.validateSpec;if(!e.type)return [new ot(r,e,'"type" is required')];const s=en(e.type);let o;switch(s){case"vector":case"raster":return o=nn({key:r,value:e,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:gn,validateSpec:a}),o;case"raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,a=i.source_raster_dem,s=t.style;let o=[];const l=kr(n);if(void 0===n)return o;if("object"!==l)return o.push(new ot("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===en(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new ot(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:a[e],validateSpec:t.validateSpec,style:s,styleSpec:i})):o.push(new ot(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:a}),o;case"geojson":if(o=nn({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:a,objectElementValidators:gn}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],s="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...ln({key:`${r}.${t}.map`,value:i,validateSpec:a,expressionContext:"cluster-map"})),o.push(...ln({key:`${r}.${t}.reduce`,value:s,validateSpec:a,expressionContext:"cluster-reduce"}));}return o;case"video":return nn({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:a,styleSpec:n});case"image":return nn({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:a,styleSpec:n});case"canvas":return [new ot(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return un({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:a,styleSpec:n})}}function vn(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let a=[];const s=kr(e);if(void 0===e)return a;if("object"!==s)return a=a.concat([new ot("light",e,`object expected, ${s} found`)]),a;for(const s in e){const o=s.match(/^(.*)-transition$/);a=a.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:s,value:e[s],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new ot(s,e[s],`unknown property "${s}"`)]);}return a}function bn(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let a=[];const s=kr(e);if(void 0===e)return a;if("object"!==s)return a=a.concat([new ot("terrain",e,`object expected, ${s} found`)]),a;for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new ot(s,e[s],`unknown property "${s}"`)]);return a}function wn(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],a=[];for(const s in r)r[s].id&&i.includes(r[s].id)&&e.push(new ot(n,r,`all the sprites' ids must be unique, but ${r[s].id} is duplicated`)),i.push(r[s].id),r[s].url&&a.includes(r[s].url)&&e.push(new ot(n,r,`all the sprites' URLs must be unique, but ${r[s].url} is duplicated`)),a.push(r[s].url),e=e.concat(nn({key:`${n}[${s}]`,value:r[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return mn({key:n,value:r})}const _n={"*":()=>[],array:an,boolean:function(t){const e=t.value,r=t.key,n=kr(e);return "boolean"!==n?[new ot(r,e,`boolean expected, ${n} found`)]:[]},number:sn,color:function(t){const e=t.key,r=t.value,n=kr(r);return "string"!==n?[new ot(e,r,`color expected, ${n} found`)]:Yt.parse(String(r))?[]:[new ot(e,r,`color expected, "${r}" found`)]},constants:tn,enum:un,filter:cn,function:on,layer:yn,object:nn,source:xn,light:vn,terrain:bn,string:mn,formatted:function(t){return 0===mn(t).length?[]:ln(t)},resolvedImage:function(t){return 0===mn(t).length?[]:ln(t)},padding:function(t){const e=t.key,r=t.value;if("array"===kr(r)){if(r.length<1||r.length>4)return [new ot(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let a=0;a[]}})),t.constants&&(r=r.concat(tn({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:An}))),zn(r)}function In(t){return function(e){return t({...e,validateSpec:An})}}function zn(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Mn(t){return function(...e){return zn(t.apply(this,e))}}kn.source=Mn(In(xn)),kn.sprite=Mn(In(wn)),kn.glyphs=Mn(In(Sn)),kn.light=Mn(In(vn)),kn.terrain=Mn(In(bn)),kn.layer=Mn(In(yn)),kn.filter=Mn(In(cn)),kn.paintProperty=Mn(In(fn)),kn.layoutProperty=Mn(In(dn));const Cn=kn,Bn=Cn.light,Pn=Cn.paintProperty,Vn=Cn.layoutProperty;function En(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new G(new Error(n.message))),r=!0;return r}class Fn{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(s[h]=!0,a.push(i[h])):s[h]=!1;}}}}_forEachCell(t,e,r,n,i,a,s,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,a,s,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const a=t[r];i[r]=Tn[n].shallow.indexOf(r)>=0?a:Dn(a,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof t)}function On(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||Ln(t)||M(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(On);if("object"==typeof t){const e=t.$name||"Object";if(!Tn[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Tn[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=Tn[e].shallow.indexOf(r)>=0?i:On(i);}return n}throw new Error("can't deserialize object of type "+typeof t)}class Un{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function qn(t){for(const e of t)if(Zn(e.charCodeAt(0)))return !0;return !1}function jn(t){for(const e of t)if(!Nn(e.charCodeAt(0)))return !1;return !0}function Nn(t){return !(Rn.Arabic(t)||Rn["Arabic Supplement"](t)||Rn["Arabic Extended-A"](t)||Rn["Arabic Presentation Forms-A"](t)||Rn["Arabic Presentation Forms-B"](t))}function Zn(t){return !(746!==t&&747!==t&&(t<4352||!(Rn["Bopomofo Extended"](t)||Rn.Bopomofo(t)||Rn["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Rn["CJK Compatibility Ideographs"](t)||Rn["CJK Compatibility"](t)||Rn["CJK Radicals Supplement"](t)||Rn["CJK Strokes"](t)||!(!Rn["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Rn["CJK Unified Ideographs Extension A"](t)||Rn["CJK Unified Ideographs"](t)||Rn["Enclosed CJK Letters and Months"](t)||Rn["Hangul Compatibility Jamo"](t)||Rn["Hangul Jamo Extended-A"](t)||Rn["Hangul Jamo Extended-B"](t)||Rn["Hangul Jamo"](t)||Rn["Hangul Syllables"](t)||Rn.Hiragana(t)||Rn["Ideographic Description Characters"](t)||Rn.Kanbun(t)||Rn["Kangxi Radicals"](t)||Rn["Katakana Phonetic Extensions"](t)||Rn.Katakana(t)&&12540!==t||!(!Rn["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Rn["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Rn["Unified Canadian Aboriginal Syllabics"](t)||Rn["Unified Canadian Aboriginal Syllabics Extended"](t)||Rn["Vertical Forms"](t)||Rn["Yijing Hexagram Symbols"](t)||Rn["Yi Syllables"](t)||Rn["Yi Radicals"](t))))}function Kn(t){return !(Zn(t)||function(t){return !!(Rn["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Rn["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Rn["Letterlike Symbols"](t)||Rn["Number Forms"](t)||Rn["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Rn["Control Pictures"](t)&&9251!==t||Rn["Optical Character Recognition"](t)||Rn["Enclosed Alphanumerics"](t)||Rn["Geometric Shapes"](t)||Rn["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Rn["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Rn["CJK Symbols and Punctuation"](t)||Rn.Katakana(t)||Rn["Private Use Area"](t)||Rn["CJK Compatibility Forms"](t)||Rn["Small Form Variants"](t)||Rn["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Gn(t){return t>=1424&&t<=2303||Rn["Arabic Presentation Forms-A"](t)||Rn["Arabic Presentation Forms-B"](t)}function Jn(t,e){return !(!e&&Gn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Rn.Khmer(t))}function Xn(t){for(const e of t)if(Gn(e.charCodeAt(0)))return !0;return !1}const Yn="deferred",Hn="loading",Wn="loaded";let Qn=null,ti="unavailable",ei=null;const ri=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(ti="error"),Qn&&Qn(t);};function ni(){ii.fire(new K("pluginStateChange",{pluginStatus:ti,pluginURL:ei}));}const ii=new J,ai=function(){return ti},si=function(){if(ti!==Yn||!ei)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");ti=Hn,ni(),ei&&q({url:ei},(t=>{t?ri(t):(ti=Wn,ni());}));},oi={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>ti===Wn||null!=oi.applyArabicShaping,isLoading:()=>ti===Hn,setState(t){if(!I())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");ti=t.pluginStatus,ei=t.pluginURL;},isParsed(){if(!I())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return null!=oi.applyArabicShaping&&null!=oi.processBidirectionalText&&null!=oi.processStyledBidirectionalText},getPluginURL(){if(!I())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return ei}};class li{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Un,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!Jn(r.charCodeAt(0),e))return !1;return !0}(t,oi.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class ui{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Ir(t))return new Ur(t,e);if(Tr(t)){const r=Or(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=Yt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(r=re.parse(t)):r=te.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class ci{constructor(t){this.property=t,this.value=new ui(t,void 0);}transitioned(t,e){return new pi(this.property,this.value,e,g({},t.transition,this.transition),t.now)}untransitioned(){return new pi(this.property,this.value,null,{},0)}}class hi{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return w(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ci(this._values[t].property)),this._values[t].value=new ui(this._values[t].property,null===e?void 0:w(e));}getTransition(t){return w(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ci(this._values[t].property)),this._values[t].transition=w(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new fi(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new fi(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class pi{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),a=this.prior;if(a){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(s))}}return i}}class fi{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues);}possiblyEvaluate(t,e,r){const n=new mi(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return !0;return !1}}class di{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues);}hasValue(t){return void 0!==this._values[t].value}getValue(t){return w(this._values[t].value)}setValue(t,e){this._values[t]=new ui(this._values[t].property,null===e?void 0:w(e));}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);}return t}possiblyEvaluate(t,e,r){const n=new mi(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}}class yi{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r;}isConstant(){return "constant"===this.value.kind}constantOr(t){return "constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n)}}class mi{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues);}get(t){return this._values[t]}}class gi{constructor(t){this.specification=t;}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,r){const n=Ze[this.specification.type];return n?n(t,e,r):t}}class xi{constructor(t,e){this.specification=t,this.overrides=e;}possiblyEvaluate(t,e,r,n){return new yi(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},r,n)}:t.expression,e)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new yi(this,{kind:"constant",value:void 0},t.parameters);const n=Ze[this.specification.type];if(n){const i=n(t.value.value,e.value.value,r);return new yi(this,{kind:"constant",value:i},t.parameters)}return t}evaluate(t,e,r,n,i,a){return "constant"===t.kind?t.value:t.evaluate(e,r,n,i,a)}}class vi extends xi{possiblyEvaluate(t,e,r,n){if(void 0===t.value)return new yi(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n),a="resolvedImage"===t.property.specification.type&&"string"!=typeof i?i.name:i,s=this._calculate(a,a,a,e);return new yi(this,{kind:"constant",value:s},e)}if("camera"===t.expression.kind){const r=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new yi(this,{kind:"constant",value:r},e)}return new yi(this,t.expression,e)}evaluate(t,e,r,n,i,a){if("source"===t.kind){const s=t.evaluate(e,r,n,i,a);return this._calculate(s,s,s,e)}return "composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},r,n),t.evaluate({zoom:Math.floor(e.zoom)},r,n),t.evaluate({zoom:Math.floor(e.zoom)+1},r,n),e):t.value}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class bi{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new li(Math.floor(e.zoom-1),e)),t.expression.evaluate(new li(Math.floor(e.zoom),e)),t.expression.evaluate(new li(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class wi{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class _i{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new ui(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new ci(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}$n("DataDrivenProperty",xi),$n("DataConstantProperty",gi),$n("CrossFadedDataDrivenProperty",vi),$n("CrossFadedProperty",bi),$n("ColorRampProperty",wi);const Ai="-transition";class Si extends J{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new di(e.layout)),e.paint)){this._transitionablePaint=new hi(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new mi(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(Vn,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(Ai)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(Pn,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(Ai))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),a=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const s=this._transitionablePaint._values[t].value;return s.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,a,s)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),b(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&En(this,t.call(Cn,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:X,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof yi&&_r(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const ki={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ii{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class zi{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Mi(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=ki[t.type].BYTES_PER_ELEMENT,a=r=Ci(r,Math.max(e,i)),s=t.components||1;return n=Math.max(n,i),r+=i*s,{name:t.name,type:t.type,components:s,offset:a}})),size:Ci(r,Math.max(n,e)),alignment:e}}function Ci(t,e){return Math.ceil(t/e)*e}class Bi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Bi.prototype.bytesPerElement=4,$n("StructArrayLayout2i4",Bi);class Pi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Pi.prototype.bytesPerElement=6,$n("StructArrayLayout3i6",Pi);class Vi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,t}}Vi.prototype.bytesPerElement=8,$n("StructArrayLayout4i8",Vi);class Ei extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=a,this.int16[o+5]=s,t}}Ei.prototype.bytesPerElement=12,$n("StructArrayLayout2i4i12",Ei);class Fi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=a,this.uint8[l+7]=s,t}}Fi.prototype.bytesPerElement=8,$n("StructArrayLayout2i4ub8",Fi);class Ti extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Ti.prototype.bytesPerElement=8,$n("StructArrayLayout2f8",Ti);class $i extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,a,s,o,l,u)}emplace(t,e,r,n,i,a,s,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=a,this.uint16[h+5]=s,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}$i.prototype.bytesPerElement=20,$n("StructArrayLayout10ui20",$i);class Li extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,a,s,o,l,u,c,h)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=a,this.uint16[f+5]=s,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}Li.prototype.bytesPerElement=24,$n("StructArrayLayout4i4ui4i24",Li);class Di extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Di.prototype.bytesPerElement=12,$n("StructArrayLayout3f12",Di);class Oi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Oi.prototype.bytesPerElement=4,$n("StructArrayLayout1ul4",Oi);class Ui extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,a,s,o,l)}emplace(t,e,r,n,i,a,s,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=a,this.int16[c+5]=s,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}Ui.prototype.bytesPerElement=20,$n("StructArrayLayout6i1ul2ui20",Ui);class Ri extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=a,this.int16[o+5]=s,t}}Ri.prototype.bytesPerElement=12,$n("StructArrayLayout2i2i2i12",Ri);class qi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=4*t,o=8*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.int16[o+6]=i,this.int16[o+7]=a,t}}qi.prototype.bytesPerElement=16,$n("StructArrayLayout2f1f2i16",qi);class ji extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=12*t,s=3*t;return this.uint8[a+0]=e,this.uint8[a+1]=r,this.float32[s+1]=n,this.float32[s+2]=i,t}}ji.prototype.bytesPerElement=12,$n("StructArrayLayout2ub2f12",ji);class Ni extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Ni.prototype.bytesPerElement=6,$n("StructArrayLayout3ui6",Ni);class Zi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=a,this.uint32[v+3]=s,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}Zi.prototype.bytesPerElement=48,$n("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Zi);class Ki extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,I,z){const M=this.length;return this.resize(M+1),this.emplace(M,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,I,z)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,I,z,M){const C=32*t,B=16*t;return this.int16[C+0]=e,this.int16[C+1]=r,this.int16[C+2]=n,this.int16[C+3]=i,this.int16[C+4]=a,this.int16[C+5]=s,this.int16[C+6]=o,this.int16[C+7]=l,this.uint16[C+8]=u,this.uint16[C+9]=c,this.uint16[C+10]=h,this.uint16[C+11]=p,this.uint16[C+12]=f,this.uint16[C+13]=d,this.uint16[C+14]=y,this.uint16[C+15]=m,this.uint16[C+16]=g,this.uint16[C+17]=x,this.uint16[C+18]=v,this.uint16[C+19]=b,this.uint16[C+20]=w,this.uint16[C+21]=_,this.uint16[C+22]=A,this.uint32[B+12]=S,this.float32[B+13]=k,this.float32[B+14]=I,this.uint16[C+30]=z,this.uint16[C+31]=M,t}}Ki.prototype.bytesPerElement=64,$n("StructArrayLayout8i15ui1ul2f2ui64",Ki);class Gi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Gi.prototype.bytesPerElement=4,$n("StructArrayLayout1f4",Gi);class Ji extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Ji.prototype.bytesPerElement=12,$n("StructArrayLayout1ui2f12",Ji);class Xi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}Xi.prototype.bytesPerElement=8,$n("StructArrayLayout1ul2ui8",Xi);class Yi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Yi.prototype.bytesPerElement=4,$n("StructArrayLayout2ui4",Yi);class Hi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Hi.prototype.bytesPerElement=2,$n("StructArrayLayout1ui2",Hi);class Wi extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,t}}Wi.prototype.bytesPerElement=16,$n("StructArrayLayout4f16",Wi);class Qi extends Ii{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new a(this.anchorPointX,this.anchorPointY)}}Qi.prototype.size=20;class ta extends Ui{get(t){return new Qi(this,t)}}$n("CollisionBoxArray",ta);class ea extends Ii{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}ea.prototype.size=48;class ra extends Zi{get(t){return new ea(this,t)}}$n("PlacedSymbolArray",ra);class na extends Ii{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}na.prototype.size=64;class ia extends Ki{get(t){return new na(this,t)}}$n("SymbolInstanceArray",ia);class aa extends Gi{getoffsetX(t){return this.float32[1*t+0]}}$n("GlyphOffsetArray",aa);class sa extends Pi{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}$n("SymbolLineVertexArray",sa);class oa extends Ii{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}oa.prototype.size=12;class la extends Ji{get(t){return new oa(this,t)}}$n("TextAnchorOffsetArray",la);class ua extends Ii{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}ua.prototype.size=8;class ca extends Xi{get(t){return new ua(this,t)}}$n("FeatureIndexArray",ca);class ha extends Bi{}class pa extends Bi{}class fa extends Bi{}class da extends Ei{}class ya extends Fi{}class ma extends Ti{}class ga extends $i{}class xa extends Li{}class va extends Di{}class ba extends Oi{}class wa extends Ri{}class _a extends ji{}class Aa extends Ni{}class Sa extends Yi{}const ka=Mi([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ia}=ka;class za{constructor(t=[]){this.segments=t;}prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>za.MAX_VERTEX_ARRAY_LENGTH&&A(`Max vertices per segment is ${za.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>za.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new za([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ma(t,e){return 256*(t=y(Math.floor(t),0,255))+y(Math.floor(e),0,255)}za.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,$n("SegmentVector",za);const Ca=Mi([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ba={exports:{}},Pa={exports:{}};Pa.exports=function(t,e){var r,n,i,a,s,o,l,u;for(n=t.length-(r=3&t.length),i=e,s=3432918353,o=461845907,u=0;u>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var Va=Pa.exports,Ea={exports:{}};Ea.exports=function(t,e){for(var r,n=t.length,i=e^n,a=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++a;switch(n){case 3:i^=(255&t.charCodeAt(a+2))<<16;case 2:i^=(255&t.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var Fa=Va,Ta=Ea.exports;Ba.exports=Fa,Ba.exports.murmur3=Fa,Ba.exports.murmur2=Ta;var $a=r(Ba.exports);class La{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(Da(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=Da(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Oa(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new La;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Da(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:$a(String(t))}function Oa(t,e,r,n){for(;r>1];let a=r-1,s=n+1;for(;;){do{a++;}while(t[a]i);if(a>=s)break;Ua(t,a,s),Ua(e,3*a,3*s),Ua(e,3*a+1,3*s+1),Ua(e,3*a+2,3*s+2);}s-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new Na(t,e):new qa(t,e)}}class Ja{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new ja(t,e):new qa(t,e)}}class Xa{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const a=this.paintVertexArray.length,s=this.expression.evaluate(new li(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(a,t,s);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=Ka(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new a;}populatePaintArray(t,e,r,n,i){const a=this.expression.evaluate(new li(this.zoom),e,{},n,[],i),s=this.expression.evaluate(new li(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,a,s);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),a=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,a);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Ka(r),a=Ka(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Xa||r instanceof Ya)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Wa(n,e,r);this.needsUpload=!1,this._featureMap=new La,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,a){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,a);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function ts(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function es(t,e,r){const n={color:{source:Ti,composite:Wi},number:{source:Gi,composite:Ti}},i=function(t){return {"line-pattern":{source:ga,composite:ga},"fill-pattern":{source:ga,composite:ga},"fill-extrusion-pattern":{source:ga,composite:ga}}[t]}(t);return i&&i[r]||n[e][r]}$n("ConstantBinder",Ga),$n("CrossFadedConstantBinder",Ja),$n("SourceExpressionBinder",Xa),$n("CrossFadedCompositeBinder",Ha),$n("CompositeExpressionBinder",Ya),$n("ProgramConfiguration",Wa,{omit:["_buffers"]}),$n("ProgramConfigurationSet",Qa);const rs=8192,ns=Math.pow(2,14)-1,is=-ns-1;function as(t){const e=rs/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||ar.y+1)&&A("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function ss(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?as(t):[]}}function os(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2);}class ls{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new pa,this.indexArray=new Aa,this.segments=new za,this.programConfigurations=new Qa(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let a=null,s=!1;"circle"===n.type&&(a=n.layout.get("circle-sort-key"),s=!a.isConstant());for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ss(e,t);if(!this.layers[0]._featureFilter.filter(new li(this.zoom),u,r))continue;const c=s?a.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:as(e),patterns:{},sortKey:c};i.push(h);}s&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:a,sourceLayerIndex:s}=n,o=t[a].feature;this.addFeature(n,i,a,r),e.featureIndex.insert(o,i,a,s,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ia),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=rs||n<0||n>=rs)continue;const i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=i.vertexLength;os(this.layoutVertexArray,r,n,-1,-1),os(this.layoutVertexArray,r,n,1,-1),os(this.layoutVertexArray,r,n,1,1),os(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+3,a+2),i.vertexLength+=4,i.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n);}}function us(t,e){for(let r=0;r1){if(fs(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function gs(t,e){let r,n,i,a=!1;for(let s=0;se.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);}return a}function xs(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(r=!r);}return r}function vs(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const a=S(t,e,r[0]);return a!==S(t,e,r[1])||a!==S(t,e,r[2])||a!==S(t,e,r[3])}function bs(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function ws(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function _s(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=a.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const o=[];for(let e=0;eFs(t,e)))}(l,o),p=c?u*s:u;for(const t of n)for(const e of t){const t=c?e:Fs(e,o);let r=p;const n=Vs([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/a.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=a.cameraToCenterDistance/n[3]),cs(h,t,r))return !0}return !1}}function Fs(t,e){const r=Vs([],[t.x,t.y,0,1],e);return new a(r[0]/r[3],r[1]/r[3])}class Ts extends ls{}let $s;$n("HeatmapBucket",Ts,{omit:["layers"]});var Ls={get paint(){return $s=$s||new _i({"heatmap-radius":new xi(X.paint_heatmap["heatmap-radius"]),"heatmap-weight":new xi(X.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new gi(X.paint_heatmap["heatmap-intensity"]),"heatmap-color":new wi(X.paint_heatmap["heatmap-color"]),"heatmap-opacity":new gi(X.paint_heatmap["heatmap-opacity"])})}};function Ds(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Os(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Ds({},{width:e,height:r},n);Us(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Us(t,e,r,n,i,a){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,o=e.data;if(s===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=a;const s=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*s.r/s.a),i.data[r+n+1]=Math.floor(255*s.g/s.a),i.data[r+n+2]=Math.floor(255*s.b/s.a),i.data[r+n+3]=Math.floor(255*s.a);};if(t.clips)for(let e=0,i=0;e80*r){n=a=t[0],i=s=t[1];for(var d=r;da&&(a=o),l>s&&(s=l);u=0!==(u=Math.max(a-n,s-i))?32767/u:0;}return to(p,f,r,n,i,u,0),f}function Ws(t,e,r,n,i){var a,s;if(i===Ao(t,e,r,n)>0)for(a=e;a=e;a-=n)s=bo(a,t[a],t[a+1],s);return s&&fo(s,s.next)&&(wo(s),s=s.next),s}function Qs(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!fo(n,n.next)&&0!==po(n.prev,n,n.next))n=n.next;else {if(wo(n),(n=e=n.prev)===n.next)break;r=!0;}}while(r||n!==e);return e}function to(t,e,r,n,i,a,s){if(t){!s&&a&&function(t,e,r,n){var i=t;do{0===i.z&&(i.z=lo(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,s,o,l,u=1;do{for(r=t,t=null,a=null,s=0;r;){for(s++,n=r,o=0,e=0;e0||l>0&&n;)0!==o&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,o--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n;}a.nextZ=null,u*=2;}while(s>1)}(i);}(t,n,i,a);for(var o,l,u=t;t.prev!==t.next;)if(o=t.prev,l=t.next,a?ro(t,n,i,a):eo(t))e.push(o.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),wo(t),t=l.next,u=l.next;else if((t=l)===u){s?1===s?to(t=no(Qs(t),e,r),e,r,n,i,a,2):2===s&&io(t,e,r,n,i,a):to(Qs(t),e,r,n,i,a,1);break}}}function eo(t){var e=t.prev,r=t,n=t.next;if(po(e,r,n)>=0)return !1;for(var i=e.x,a=r.x,s=n.x,o=e.y,l=r.y,u=n.y,c=ia?i>s?i:s:a>s?a:s,f=o>l?o>u?o:u:l>u?l:u,d=n.next;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&co(i,o,a,l,s,u,d.x,d.y)&&po(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function ro(t,e,r,n){var i=t.prev,a=t,s=t.next;if(po(i,a,s)>=0)return !1;for(var o=i.x,l=a.x,u=s.x,c=i.y,h=a.y,p=s.y,f=ol?o>u?o:u:l>u?l:u,m=c>h?c>p?c:p:h>p?h:p,g=lo(f,d,e,r,n),x=lo(y,m,e,r,n),v=t.prevZ,b=t.nextZ;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==s&&co(o,c,l,h,u,p,v.x,v.y)&&po(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==s&&co(o,c,l,h,u,p,b.x,b.y)&&po(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==s&&co(o,c,l,h,u,p,v.x,v.y)&&po(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==s&&co(o,c,l,h,u,p,b.x,b.y)&&po(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function no(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!fo(i,a)&&yo(i,n,n.next,a)&&xo(i,a)&&xo(a,i)&&(e.push(i.i/r|0),e.push(n.i/r|0),e.push(a.i/r|0),wo(n),wo(n.next),n=t=a),n=n.next;}while(n!==t);return Qs(n)}function io(t,e,r,n,i,a){var s=t;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&ho(s,o)){var l=vo(s,o);return s=Qs(s,s.next),l=Qs(l,l.next),to(s,e,r,n,i,a,0),void to(l,e,r,n,i,a,0)}o=o.next;}s=s.next;}while(s!==t)}function ao(t,e){return t.x-e.x}function so(t,e){var r=function(t,e){var r,n=e,i=t.x,a=t.y,s=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var o=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=i&&o>s&&(s=o,r=n.x=n.x&&n.x>=c&&i!==n.x&&co(ar.x||n.x===r.x&&oo(r,n)))&&(r=n,p=l)),n=n.next;}while(n!==u);return r}(t,e);if(!r)return e;var n=vo(r,t);return Qs(n,n.next),Qs(r,r.next)}function oo(t,e){return po(t.prev,t,e.prev)<0&&po(e.next,t,t.next)<0}function lo(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function uo(t){var e=t,r=t;do{(e.x=(t-s)*(a-o)&&(t-s)*(n-o)>=(r-s)*(e-o)&&(r-s)*(a-o)>=(i-s)*(n-o)}function ho(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&yo(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(xo(t,e)&&xo(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(po(t.prev,t,e.prev)||po(t,e.prev,e))||fo(t,e)&&po(t.prev,t,t.next)>0&&po(e.prev,e,e.next)>0)}function po(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function fo(t,e){return t.x===e.x&&t.y===e.y}function yo(t,e,r,n){var i=go(po(t,e,r)),a=go(po(t,e,n)),s=go(po(r,n,t)),o=go(po(r,n,e));return i!==a&&s!==o||!(0!==i||!mo(t,r,e))||!(0!==a||!mo(t,n,e))||!(0!==s||!mo(r,t,n))||!(0!==o||!mo(r,e,n))}function mo(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function go(t){return t>0?1:t<0?-1:0}function xo(t,e){return po(t.prev,t,t.next)<0?po(t,e,t.next)>=0&&po(t,t.prev,e)>=0:po(t,e,t.prev)<0||po(t,t.next,e)<0}function vo(t,e){var r=new _o(t.i,t.x,t.y),n=new _o(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function bo(t,e,r,n){var i=new _o(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function wo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function _o(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function Ao(t,e,r,n){for(var i=0,a=e,s=r-n;a0&&r.holes.push(n+=t[i-1].length);}return r};var So=r(Ys.exports);function ko(t,e,r,n,i){Io(t,e,r||0,n||t.length-1,i||Mo);}function Io(t,e,r,n,i){for(;n>r;){if(n-r>600){var a=n-r+1,s=e-r+1,o=Math.log(a),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(a-l)/a)*(s-a/2<0?-1:1);Io(t,e,Math.max(r,Math.floor(e-s*l/a+u)),Math.min(n,Math.floor(e+(a-s)*l/a+u)),i);}var c=t[e],h=r,p=n;for(zo(t,r,e),i(t[n],c)>0&&zo(t,r,n);h0;)p--;}0===i(t[r],c)?zo(t,r,p):zo(t,++p,n),p<=e&&(r=p+1),e<=p&&(n=p-1);}}function zo(t,e,r){var n=t[e];t[e]=t[r],t[r]=n;}function Mo(t,e){return te?1:0}function Co(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,a;for(let e=0;e1)for(let t=0;tt.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new fa,this.indexArray=new Aa,this.indexArray2=new Sa,this.programConfigurations=new Qa(t.layers,t.zoom),this.segments=new za,this.segments2=new za,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Po("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),a=[];for(const{feature:s,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ss(s,t);if(!this.layers[0]._featureFilter.filter(new li(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:as(s),patterns:{},sortKey:h};a.push(p);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:i,index:a,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Vo("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,a,r,{});e.featureIndex.insert(t[a].feature,i,a,s,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Xs),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i){for(const t of Co(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],a=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&a.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t>3;}if(i--,1===n||2===n)a+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&o.push(e),e=[]),e.push(new qo(a,s));else {if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone());}}return e&&o.push(e),o},No.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,s=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(a+=t.readSVarint())u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return [s,l,o,u]},No.prototype.toGeoJSON=function(t,e,r){var n,i,a=this.extent*Math.pow(2,r),s=this.extent*t,o=this.extent*e,l=this.loadGeometry(),u=No.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}Xo.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Go(this._pbf,e,this.extent,this._keys,this._values)};var Ho=Jo;function Wo(t,e,r){if(3===t){var n=new Ho(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n);}}Ro.VectorTile=function(t,e){this.layers=t.readFields(Wo,{},e);},Ro.VectorTileFeature=jo,Ro.VectorTileLayer=Jo;const Qo=Ro.VectorTileFeature.types,tl=Math.pow(2,13);function el(t,e,r,n,i,a,s,o){t.emplaceBack(e,r,2*Math.floor(n*tl)+s,i*tl*2,a*tl*2,Math.round(o));}class rl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new da,this.centroidVertexArray=new ha,this.indexArray=new Aa,this.programConfigurations=new Qa(t.layers,t.zoom),this.segments=new za,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=Po("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:a,sourceLayerIndex:s}of t){const t=this.layers[0]._featureFilter.needGeometry,o=ss(n,t);if(!this.layers[0]._featureFilter.filter(new li(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:s,index:a,geometry:t?o.geometry:as(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Vo("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,a,r,{}),e.featureIndex.insert(n,l.geometry,a,s,this.index,!0);}}addFeatures(t,e,r){for(const t of this.features){const{geometry:n}=t;this.addFeature(t,n,t.index,e,r);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Uo),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Oo.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i){const a={x:0,y:0,vertexCount:0};for(const r of Co(e,500)){let e=0;for(const t of r)e+=t.length;let n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of r){if(0===t.length)continue;if(il(t))continue;let e=0;for(let r=0;r=1){const s=t[r-1];if(!nl(i,s)){n.vertexLength+4>za.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(s)._perp()._unit(),r=s.dist(i);e+r>32768&&(e=0),el(this.layoutVertexArray,i.x,i.y,t.x,t.y,0,0,e),el(this.layoutVertexArray,i.x,i.y,t.x,t.y,0,1,e),a.x+=2*i.x,a.y+=2*i.y,a.vertexCount+=2,e+=r,el(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,e),el(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,e),a.x+=2*s.x,a.y+=2*s.y,a.vertexCount+=2;const o=n.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),n.vertexLength+=4,n.primitiveLength+=2;}}}}if(n.vertexLength+e>za.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==Qo[t.type])continue;const i=[],s=[],o=n.vertexLength;for(const t of r)if(0!==t.length){t!==r[0]&&s.push(i.length/2);for(let e=0;ers)||t.y===e.y&&(t.y<0||t.y>rs)}function il(t){return t.every((t=>t.x<0))||t.every((t=>t.x>rs))||t.every((t=>t.y<0))||t.every((t=>t.y>rs))}let al;$n("FillExtrusionBucket",rl,{omit:["layers","features"]});var sl={get paint(){return al=al||new _i({"fill-extrusion-opacity":new gi(X["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new xi(X["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new gi(X["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new gi(X["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new vi(X["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new xi(X["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new xi(X["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new gi(X["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class ol extends Si{constructor(t){super(t,sl);}createBucket(t){return new rl(t)}queryRadius(){return ws(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature(t,e,r,n,i,s,o,l){const u=_s(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,o),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),p=function(t,e,r,n){const i=[];for(const r of t){const t=[r.x,r.y,0,1];Vs(t,t,e),i.push(new a(t[0]/t[3],t[1]/t[3]));}return i}(u,l),f=function(t,e,r,n){const i=[],s=[],o=n[8]*e,l=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,A=g+f,S=x+d,k=new a((y+o)/b,(m+l)/b);k.z=v/b,t.push(k);const I=new a(w/S,_/S);I.z=A/S,r.push(I);}i.push(t),s.push(r);}return [i,s]}(n,h,c,l);return function(t,e,r){let n=1/0;hs(r,e)&&(n=ul(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ya,this.layoutVertexArray2=new ma,this.indexArray=new Aa,this.programConfigurations=new Qa(t.layers,t.zoom),this.segments=new za,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Po("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),a=[];for(const{feature:e,id:s,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ss(e,t);if(!this.layers[0]._featureFilter.filter(new li(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:as(e),patterns:{},sortKey:c};a.push(h);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:i,index:a,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Vo("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,a,r,{});e.featureIndex.insert(t[a].feature,i,a,s,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,fl)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,hl),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i){const a=this.layers[0].layout,s=a.get("line-join").evaluate(t,{}),o=a.get("line-cap"),l=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,s,o,l,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(w&&e>l){const t=h.dist(p);if(t>2*u){const e=h.sub(h.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,d,0,0,c),p=e;}}const A=p&&f;let S=A?r:s?"butt":n;if(A&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v100)m=y.mult(-1);else {const t=v*d.add(y).mag()/d.sub(y).mag();m._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(h,m,0,0,c),this.addCurrentVertex(h,m.mult(-1),0,0,c);}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(p&&this.addCurrentVertex(h,d,e,r,c),"fakeround"===S){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*u){const e=h.add(f.sub(h)._mult(u/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,y,0,0,c),h=e;}}}}addCurrentVertex(t,e,r,n,i,a=!1){const s=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,a,!1,r,i),this.addHalfVertex(t,s,o,a,!0,-n,i),this.distance>ml/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,a));}addHalfVertex({x:t,y:e},r,n,i,a,s,o){const l=.5*(this.lineClips?this.scaledDistance*(ml-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(a?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),a?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let xl,vl;$n("LineBucket",gl,{omit:["layers","patternFeatures"]});var bl={get paint(){return vl=vl||new _i({"line-opacity":new xi(X.paint_line["line-opacity"]),"line-color":new xi(X.paint_line["line-color"]),"line-translate":new gi(X.paint_line["line-translate"]),"line-translate-anchor":new gi(X.paint_line["line-translate-anchor"]),"line-width":new xi(X.paint_line["line-width"]),"line-gap-width":new xi(X.paint_line["line-gap-width"]),"line-offset":new xi(X.paint_line["line-offset"]),"line-blur":new xi(X.paint_line["line-blur"]),"line-dasharray":new bi(X.paint_line["line-dasharray"]),"line-pattern":new vi(X.paint_line["line-pattern"]),"line-gradient":new wi(X.paint_line["line-gradient"])})},get layout(){return xl=xl||new _i({"line-cap":new gi(X.layout_line["line-cap"]),"line-join":new xi(X.layout_line["line-join"]),"line-miter-limit":new gi(X.layout_line["line-miter-limit"]),"line-round-limit":new gi(X.layout_line["line-round-limit"]),"line-sort-key":new xi(X.layout_line["line-sort-key"])})}};class wl extends xi{possiblyEvaluate(t,e){return e=new li(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=g({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let _l;class Al extends Si{constructor(t){super(t,bl),this.gradientVersion=0,_l||(_l=new wl(bl.paint.properties["line-width"].specification),_l.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof qe,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=_l.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new gl(t)}queryRadius(t){const e=t,r=Sl(bs("line-width",this,e),bs("line-gap-width",this,e)),n=bs("line-offset",this,e);return r/2+Math.abs(n)+ws(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,i,s,o){const l=_s(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,o),u=o/2*Sl(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),c=this.paint.get("line-offset").evaluate(e,r);return c&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const kl=Mi([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Il=Mi([{name:"a_projected_pos",components:3,type:"Float32"}],4);Mi([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const zl=Mi([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Mi([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Ml=Mi([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Cl=Mi([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Bl(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),oi.applyArabicShaping&&(t=oi.applyArabicShaping(t)),t}(t.text,e,r);})),t}Mi([{name:"triangle",components:3,type:"Uint16"}]),Mi([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Mi([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Mi([{type:"Float32",name:"offsetX"}]),Mi([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Mi([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Pl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Vl=24,El=$l,Fl=function(t,e,r,n,i){var a,s,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,a=f&(1<<-c)-1,f>>=-c,c+=o;c>0;a=256*a+t[e+h],h+=p,c-=8);for(s=a&(1<<-c)-1,a>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=p,c-=8);if(0===a)a=1-u;else {if(a===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),a-=u;}return (f?-1:1)*s*Math.pow(2,a-n)},Tl=function(t,e,r,n,i,a){var s,o,l,u=8*a-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(o=0,s=c):s+h>=1?(o=(e*l-1)*Math.pow(2,i),s+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(s=s<0;t[r+f]=255&s,f+=d,s/=256,u-=8);t[r+f-d]|=128*y;};function $l(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}$l.Varint=0,$l.Fixed64=1,$l.Bytes=2,$l.Fixed32=5;var Ll=4294967296,Dl=1/Ll,Ol="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Ul(t){return t.type===$l.Bytes?t.readVarint()+t.pos:t.pos+1}function Rl(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function ql(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function jl(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function tu(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}$l.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Wl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=tu(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Wl(this.buf,this.pos)+Wl(this.buf,this.pos+4)*Ll;return this.pos+=8,t},readSFixed64:function(){var t=Wl(this.buf,this.pos)+tu(this.buf,this.pos+4)*Ll;return this.pos+=8,t},readFloat:function(){var t=Fl(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Fl(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return Rl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return Rl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return Rl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return Rl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return Rl(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return Rl(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Ol?function(t,e,r){return Ol.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(s=t[i+2],128==(192&(a=t[i+1]))&&128==(192&s)&&((u=(15&l)<<12|(63&a)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(s=t[i+2],o=t[i+3],128==(192&(a=t[i+1]))&&128==(192&s)&&128==(192&o)&&((u=(15&l)<<18|(63&a)<<12|(63&s)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==$l.Bytes)return t.push(this.readVarint(e));var r=Ul(this);for(t=t||[];this.pos127;);else if(e===$l.Bytes)this.pos=this.readVarint()+this.pos;else if(e===$l.Fixed32)this.pos+=4;else {if(e!==$l.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&ql(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(t){this.realloc(4),Tl(this.buf,t,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(t){this.realloc(8),Tl(this.buf,t,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&ql(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,e,r){this.writeTag(t,$l.Bytes),this.writeRawMessage(e,r);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,jl,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Nl,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Gl,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Zl,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Kl,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Jl,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Xl,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Yl,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Hl,e);},writeBytesField:function(t,e){this.writeTag(t,$l.Bytes),this.writeBytes(e);},writeFixed32Field:function(t,e){this.writeTag(t,$l.Fixed32),this.writeFixed32(e);},writeSFixed32Field:function(t,e){this.writeTag(t,$l.Fixed32),this.writeSFixed32(e);},writeFixed64Field:function(t,e){this.writeTag(t,$l.Fixed64),this.writeFixed64(e);},writeSFixed64Field:function(t,e){this.writeTag(t,$l.Fixed64),this.writeSFixed64(e);},writeVarintField:function(t,e){this.writeTag(t,$l.Varint),this.writeVarint(e);},writeSVarintField:function(t,e){this.writeTag(t,$l.Varint),this.writeSVarint(e);},writeStringField:function(t,e){this.writeTag(t,$l.Bytes),this.writeString(e);},writeFloatField:function(t,e){this.writeTag(t,$l.Fixed32),this.writeFloat(e);},writeDoubleField:function(t,e){this.writeTag(t,$l.Fixed64),this.writeDouble(e);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}};var eu=r(El);const ru=3;function nu(t,e,r){1===t&&r.readMessage(iu,e);}function iu(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:a,left:s,top:o,advance:l}=r.readMessage(au,{});e.push({id:t,bitmap:new Rs({width:i+2*ru,height:a+2*ru},n),metrics:{width:i,height:a,left:s,top:o,advance:l}});}}function au(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const su=ru;function ou(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,a=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,a=Math.max(a,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&mu[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new du;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(fu.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function yu(e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m){const g=du.fromFeature(e,a);let x;p===t.ai.vertical&&g.verticalizePunctuation();const{processBidirectionalText:v,processStyledBidirectionalText:b}=oi;if(v&&1===g.sections.length){x=[];const t=v(g.toString(),Au(g,c,s,r,i,d,y));for(const e of t){const t=new du;t.text=e,t.sections=g.sections;for(let r=0;r0&&n>_&&(_=n);}else {const t=n[y.fontStack],e=t&&t[g];if(e&&e.rect)A=e.rect,b=e.metrics;else {const t=r[y.fontStack],e=t&&t[g];if(!e)continue;b=e.metrics;}x=(a-y.scale)*Vl;}I?(e.verticalizable=!0,w.push({glyph:g,imageName:S,x:f,y:d+x,vertical:I,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:A}),f+=k*y.scale+c):(w.push({glyph:g,imageName:S,x:f,y:d+x,vertical:I,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:A}),f+=b.advance*y.scale+c);}0!==w.length&&(y=Math.max(f-c,y),ku(w,0,w.length-1,g,_)),f=0;const A=s*a+_;b.lineOffset=Math.max(_,l),d+=A,m=Math.max(A,m),++x;}var v;const b=d-pu,{horizontalAlign:w,verticalAlign:_}=Su(o);((function(t,e,r,n,i,a,s,o,l){const u=(e-r)*i;let c=0;c=a!==s?-o*n-pu:(-n*l+.5)*s;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c;}))(e.positionedLines,g,w,_,y,m,s,b,a.length),e.top+=-_*b,e.bottom=e.top+b,e.left+=-w*y,e.right=e.left+y;}(_,r,n,i,x,o,l,u,p,c,f,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return !1;return !0}(w)&&_}const mu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},gu={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function xu(t,e,r,n,i,a){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Vl/a+i:0}{const n=r[e.fontStack],a=n&&n[t];return a?a.metrics.advance*e.scale+i:0}}function vu(t,e,r,n){const i=Math.pow(t-e,2);return n?t=0;let c=0;for(let r=0;rt.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ms([]),this.placementViewportMatrix=Ms([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pu(this.zoom,r["text-size"]),this.iconSizeData=Pu(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),a=n.get("symbol-z-order");this.canOverlap="never"!==Vu(n,"text-overlap","text-allow-overlap")||"never"!==Vu(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ai[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Du(new Qa(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Du(new Qa(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new aa,this.lineVertexArray=new sa,this.symbolInstances=new ia,this.textAnchorOffsets=new la;}calculateGlyphDependencies(t,e,r,n,i){for(let a=0;a0)&&("constant"!==s.value.kind||s.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new li(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=ss(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=as(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=Qt.factory(t);Lu(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ai()||this.hasRTLText&&oi.isParsed())&&(x=Bl(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof ne?t:ne.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:Eu[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=s.evaluate(g,{},n).join(","),r="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ai.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=qn(x.toString()),i=t.fontStack||e,a=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,a,r,this.allowVerticalPlacement,n);}}}"line"===a.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function a(e){n.push(t[e]),i++;}function s(t,e,i){const a=r[t];return delete r[t],r[e]=a,n[a].geometry[0].pop(),n[a].geometry[0]=n[a].geometry[0].concat(i[0]),a}function o(t,r,i){const a=e[r];return delete e[r],e[t]=a,n[a].geometry[0].shift(),n[a].geometry[0]=i[0].concat(n[a].geometry[0]),a}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),a}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Ru,qu;$n("SymbolBucket",Uu,{omit:["layers","collisionBoxArray","features","compareText"]}),Uu.MAX_GLYPHS=65535,Uu.addDynamicAttributes=$u;var ju={get paint(){return qu=qu||new _i({"icon-opacity":new xi(X.paint_symbol["icon-opacity"]),"icon-color":new xi(X.paint_symbol["icon-color"]),"icon-halo-color":new xi(X.paint_symbol["icon-halo-color"]),"icon-halo-width":new xi(X.paint_symbol["icon-halo-width"]),"icon-halo-blur":new xi(X.paint_symbol["icon-halo-blur"]),"icon-translate":new gi(X.paint_symbol["icon-translate"]),"icon-translate-anchor":new gi(X.paint_symbol["icon-translate-anchor"]),"text-opacity":new xi(X.paint_symbol["text-opacity"]),"text-color":new xi(X.paint_symbol["text-color"],{runtimeType:yt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new xi(X.paint_symbol["text-halo-color"]),"text-halo-width":new xi(X.paint_symbol["text-halo-width"]),"text-halo-blur":new xi(X.paint_symbol["text-halo-blur"]),"text-translate":new gi(X.paint_symbol["text-translate"]),"text-translate-anchor":new gi(X.paint_symbol["text-translate-anchor"])})},get layout(){return Ru=Ru||new _i({"symbol-placement":new gi(X.layout_symbol["symbol-placement"]),"symbol-spacing":new gi(X.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new gi(X.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new xi(X.layout_symbol["symbol-sort-key"]),"symbol-z-order":new gi(X.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new gi(X.layout_symbol["icon-allow-overlap"]),"icon-overlap":new gi(X.layout_symbol["icon-overlap"]),"icon-ignore-placement":new gi(X.layout_symbol["icon-ignore-placement"]),"icon-optional":new gi(X.layout_symbol["icon-optional"]),"icon-rotation-alignment":new gi(X.layout_symbol["icon-rotation-alignment"]),"icon-size":new xi(X.layout_symbol["icon-size"]),"icon-text-fit":new gi(X.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new gi(X.layout_symbol["icon-text-fit-padding"]),"icon-image":new xi(X.layout_symbol["icon-image"]),"icon-rotate":new xi(X.layout_symbol["icon-rotate"]),"icon-padding":new xi(X.layout_symbol["icon-padding"]),"icon-keep-upright":new gi(X.layout_symbol["icon-keep-upright"]),"icon-offset":new xi(X.layout_symbol["icon-offset"]),"icon-anchor":new xi(X.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new gi(X.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new gi(X.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new gi(X.layout_symbol["text-rotation-alignment"]),"text-field":new xi(X.layout_symbol["text-field"]),"text-font":new xi(X.layout_symbol["text-font"]),"text-size":new xi(X.layout_symbol["text-size"]),"text-max-width":new xi(X.layout_symbol["text-max-width"]),"text-line-height":new gi(X.layout_symbol["text-line-height"]),"text-letter-spacing":new xi(X.layout_symbol["text-letter-spacing"]),"text-justify":new xi(X.layout_symbol["text-justify"]),"text-radial-offset":new xi(X.layout_symbol["text-radial-offset"]),"text-variable-anchor":new gi(X.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new xi(X.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new xi(X.layout_symbol["text-anchor"]),"text-max-angle":new gi(X.layout_symbol["text-max-angle"]),"text-writing-mode":new gi(X.layout_symbol["text-writing-mode"]),"text-rotate":new xi(X.layout_symbol["text-rotate"]),"text-padding":new gi(X.layout_symbol["text-padding"]),"text-keep-upright":new gi(X.layout_symbol["text-keep-upright"]),"text-transform":new xi(X.layout_symbol["text-transform"]),"text-offset":new xi(X.layout_symbol["text-offset"]),"text-allow-overlap":new gi(X.layout_symbol["text-allow-overlap"]),"text-overlap":new gi(X.layout_symbol["text-overlap"]),"text-ignore-placement":new gi(X.layout_symbol["text-ignore-placement"]),"text-optional":new gi(X.layout_symbol["text-optional"])})}};class Nu{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:ht,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}$n("FormatSectionOverride",Nu,{omit:["defaultValue"]});class Zu extends Si{constructor(t){super(t,ju);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||Tr(a.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Uu(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of ju.paint.overridableProperties){if(!Zu.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Nu(e),n=new Fr(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Lr("source",n):new Dr("composite",n,e.value.zoomStops),this.paint._values[t]=new yi(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Zu.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=ju.paint.properties[e];let i=!1;const a=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Qt)a(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof le&&se(e.value)===vt?a(e.value.sections):e instanceof pr?a(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Ku;var Gu={get paint(){return Ku=Ku||new _i({"background-color":new gi(X.paint_background["background-color"]),"background-pattern":new bi(X.paint_background["background-pattern"]),"background-opacity":new gi(X.paint_background["background-opacity"])})}};class Ju extends Si{constructor(t){super(t,Gu);}}let Xu;var Yu={get paint(){return Xu=Xu||new _i({"raster-opacity":new gi(X.paint_raster["raster-opacity"]),"raster-hue-rotate":new gi(X.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new gi(X.paint_raster["raster-brightness-min"]),"raster-brightness-max":new gi(X.paint_raster["raster-brightness-max"]),"raster-saturation":new gi(X.paint_raster["raster-saturation"]),"raster-contrast":new gi(X.paint_raster["raster-contrast"]),"raster-resampling":new gi(X.paint_raster["raster-resampling"]),"raster-fade-duration":new gi(X.paint_raster["raster-fade-duration"])})}};class Hu extends Si{constructor(t){super(t,Yu);}}class Wu extends Si{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Qu{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){delete this._channel,this._callback=()=>{};}}const tc=6371008.8;class ec{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ec(m(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return tc*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof ec)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new ec(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new ec(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const rc=2*Math.PI*tc;function nc(t){return rc*Math.cos(t*Math.PI/180)}function ic(t){return (180+t)/360}function ac(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function sc(t,e){return t/nc(e)}function oc(t){return 360*t-180}function lc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class uc{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=ec.convert(t);return new uc(ic(r.lng),ac(r.lat),sc(e,r.lat))}toLngLat(){return new ec(oc(this.x),lc(this.y))}toAltitude(){return this.z*nc(lc(this.y))}meterInMercatorCoordinateUnits(){return 1/rc*(t=lc(this.y),1/Math.cos(t*Math.PI/180));var t;}}function cc(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class hc{constructor(t,e,r){if(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=dc(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(a=this.y,s=this.z,o=cc(256*(i=this.x),256*(a=Math.pow(2,s)-a-1),s),l=cc(256*(i+1),256*(a+1),s),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,a,s,o,l;const u=function(t,e,r){let n,i="";for(let a=t;a>0;a--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new a((t.x*e-this.x)*rs,(t.y*e-this.y)*rs)}toString(){return `${this.z}/${this.x}/${this.y}`}}class pc{constructor(t,e){this.wrap=t,this.canonical=e,this.key=dc(t,e.z,e.z,e.x,e.y);}}class fc{constructor(t,e,r,n,i){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new hc(r,+n,+i),this.key=dc(e,t,r,n,i);}clone(){return new fc(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new fc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?dc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):dc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new fc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new fc(e,this.wrap,e,r,n),new fc(e,this.wrap,e,r+1,n),new fc(e,this.wrap,e,r,n+1),new fc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new qs({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,a=r*this.dim,s=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:a=s-1;break;case 1:s=a+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=a;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class gc{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class xc{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Fn(rs,16,0),this.grid3D=new Fn(rs,16,0),this.featureIndexArray=new ca,this.promoteId=e;}insert(t,e,r,n,i,a){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=a?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(s,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ro.VectorTile(new eu(this.rawTileData)).layers,this.sourceLayerCoder=new mc(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},s=rs/t.tileSize/t.scale,o=Nr(i.filter),l=t.queryGeometry,u=t.queryPadding*s,c=bc(l),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=bc(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const a of t)if(e<=a.x&&r<=a.y&&n>=a.x&&i>=a.y)return !0;const s=[new a(e,r),new a(e,i),new a(n,i),new a(n,r)];if(t.length>2)for(const e of s)if(xs(t,e))return !0;for(let e=0;e(p||(p=as(e)),r.queryIntersectsFeature(l,e,n,p,this.z,t.transform,s,t.pixelPosMatrix))));}return d}loadMatchingFeature(t,e,r,n,i,a,s,o,l,u,c){const h=this.bucketLayerIDs[e];if(a&&!function(t,e){for(let r=0;r=0)return !0;return !1}(a,h))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=ss(f,!0);if(!i.filter(new li(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new li(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const s=e instanceof mi?e.get(a):null;return s&&s.evaluate?s.evaluate(r,n,i):s}))}function bc(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),i=Math.max(i,a.y);return {minX:e,minY:r,maxX:n,maxY:i}}function wc(t,e){return e-t}function _c(t,e,r,n,i){const s=[];for(let o=0;o=n&&c.x>=n||(o.x>=n?o=new a(n,o.y+(n-o.x)/(c.x-o.x)*(c.y-o.y))._round():c.x>=n&&(c=new a(n,o.y+(n-o.x)/(c.x-o.x)*(c.y-o.y))._round()),o.y>=i&&c.y>=i||(o.y>=i?o=new a(o.x+(i-o.y)/(c.y-o.y)*(c.x-o.x),i)._round():c.y>=i&&(c=new a(o.x+(i-o.y)/(c.y-o.y)*(c.x-o.x),i)._round()),u&&o.equals(u[u.length-1])||(u=[o],s.push(u)),u.push(c)))));}}return s}$n("FeatureIndex",xc,{omit:["rawTileData","sourceLayerCoder"]});class Ac extends a{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new Ac(this.x,this.y,this.angle,this.segment)}}function Sc(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let a=e,s=e.segment+1,o=0;for(;o>-r/2;){if(s--,s<0)return !1;o-=t[s].dist(a),a=t[s];}o+=t[s].dist(t[s+1]),s++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;s++,o+=e.dist(r);}return !0}function kc(t){let e=0;for(let r=0;ru){const c=(u-l)/a,h=Ze.number(n.x,i.x,c),p=Ze.number(n.y,i.y,c),f=new Ac(h,p,i.angleTo(n),r);return f._round(),!s||Sc(t,f,o,s,e)?f:void 0}l+=a;}}function Cc(t,e,r,n,i,a,s,o,l){const u=Ic(n,a,s),c=zc(n,i),h=c*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new Ac(g,x,y,e);r._round(),n&&!Sc(t,r,a,n,i)||f.push(r);}}h+=d;}return o||f.length||s||(f=Bc(t,h/2,r,n,i,a,s,!0,l)),f}$n("Anchor",Ac);const Pc=lu;function Vc(t,e,r,n){const i=[],s=t.image,o=s.pixelRatio,l=s.paddedRect.w-2*Pc,u=s.paddedRect.h-2*Pc,c=t.right-t.left,h=t.bottom-t.top,p=s.stretchX||[[0,l]],f=s.stretchY||[[0,u]],d=(t,e)=>t+e[1]-e[0],y=p.reduce(d,0),m=f.reduce(d,0),g=l-y,x=u-m;let v=0,b=y,w=0,_=m,A=0,S=g,k=0,I=x;if(s.content&&n){const t=s.content;v=Ec(p,0,t[0]),w=Ec(f,0,t[1]),b=Ec(p,t[0],t[2]),_=Ec(f,t[1],t[3]),A=t[0]-v,k=t[1]-w,S=t[2]-t[0]-b,I=t[3]-t[1]-_;}const z=(n,i,l,u)=>{const p=Tc(n.stretch-v,b,c,t.left),f=$c(n.fixed-A,S,n.stretch,y),d=Tc(i.stretch-w,_,h,t.top),g=$c(i.fixed-k,I,i.stretch,m),x=Tc(l.stretch-v,b,c,t.left),z=$c(l.fixed-A,S,l.stretch,y),M=Tc(u.stretch-w,_,h,t.top),C=$c(u.fixed-k,I,u.stretch,m),B=new a(p,d),P=new a(x,d),V=new a(x,M),E=new a(p,M),F=new a(f/o,g/o),T=new a(z/o,C/o),$=e*Math.PI/180;if($){const t=Math.sin($),e=Math.cos($),r=[e,-t,t,e];B._matMult(r),P._matMult(r),E._matMult(r),V._matMult(r);}const L=n.stretch+n.fixed,D=i.stretch+i.fixed;return {tl:B,tr:P,bl:E,br:V,tex:{x:s.paddedRect.x+Pc+L,y:s.paddedRect.y+Pc+D,w:l.stretch+l.fixed-L,h:u.stretch+u.fixed-D},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:T,minFontScaleX:S/o/c,minFontScaleY:I/o/h,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=Fc(p,g,y),e=Fc(f,x,m);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {let u=s.top*o-l[0],h=s.bottom*o+l[2],p=s.left*o-l[3],f=s.right*o+l[1];const d=s.collisionPadding;if(d&&(p-=d[0]*o,u-=d[1]*o,f+=d[2]*o,h+=d[3]*o),c){const t=new a(p,u),e=new a(f,u),r=new a(p,h),n=new a(f,h),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),u=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,p,u,f,h,r,n,i);}this.boxEndIndex=t.length;}}class Dc{constructor(t=[],e=Oc){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this.length++,this._up(this.length-1);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=a,t=n;}e[t]=i;}}function Oc(t,e){return te?1:0}function Uc(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,o=-1/0;const l=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>o)&&(o=e.y);}const u=Math.min(s-n,o-i);let c=u/2;const h=new Dc([],Rc);if(0===u)return new a(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new qc(n.p.x-c,n.p.y-c,c,t)),h.push(new qc(n.p.x+c,n.p.y-c,c,t)),h.push(new qc(n.p.x-c,n.p.y+c,c,t)),h.push(new qc(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Rc(t,e){return e.max-t.max}function qc(t,e,r,n){this.p=new a(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,ms(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var jc;t.aq=void 0,(jc=t.aq||(t.aq={}))[jc.center=1]="center",jc[jc.left=2]="left",jc[jc.right=3]="right",jc[jc.top=4]="top",jc[jc.bottom=5]="bottom",jc[jc["top-left"]=6]="top-left",jc[jc["top-right"]=7]="top-right",jc[jc["bottom-left"]=8]="bottom-left",jc[jc["bottom-right"]=9]="bottom-right";const Nc=7,Zc=Number.POSITIVE_INFINITY;function Kc(t,e){return e[1]!==Zc?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-Nc;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+Nc;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=i-Nc;break;case"bottom-right":case"bottom-left":n=-i+Nc;break;case"bottom":n=-e+Nc;break;case"top":n=e-Nc;}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e;}return [r,n]}(t,e[0])}function Gc(t,e,r){var n;const i=t.layout,a=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(a){const t=a.values,e=[];for(let r=0;rt*Vl));n.startsWith("top")?i[1]-=Nc:n.startsWith("bottom")&&(i[1]+=Nc),e[r+1]=i;}return new re(e)}const s=i.get("text-variable-anchor");if(s){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Vl,Zc]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Vl));const a=[];for(const t of s)a.push(t,Kc(t,n));return new re(a)}return null}function Jc(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function Xc(e,r,n,i,a,s,o,l,u,c,h){let p=s.textMaxSize.evaluate(r,{});void 0===p&&(p=o);const f=e.layers[0].layout,d=f.get("icon-offset").evaluate(r,{},h),y=Hc(n.horizontal),m=o/24,g=e.tilePixelRatio*m,x=e.tilePixelRatio*p/24,v=e.tilePixelRatio*l,b=e.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*e.tilePixelRatio,_=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),a=i&&i.values;return [a[0]*n,a[1]*n,a[2]*n,a[3]*n]}(f,r,h,e.tilePixelRatio),S=f.get("text-max-angle")/180*Math.PI,k="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),I="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),z=f.get("symbol-placement"),M=b/2,C=f.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=zu(i,n.vertical,C,f.get("icon-text-fit-padding"),d,m)),y&&(i=zu(i,y,C,f.get("icon-text-fit-padding"),d,m)));const P=(l,p)=>{p.x<0||p.x>=rs||p.y<0||p.y>=rs||function(e,r,n,i,a,s,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,I){const z=e.addToLineVertexArray(r,n);let M,C,B,P,V=0,E=0,F=0,T=0,$=-1,L=-1;const D={};let O=$a("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},k)+90;B=new Lc(u,r,c,h,p,i.vertical,f,d,y,t),o&&(P=new Lc(u,r,c,h,p,o,g,x,y,t));}if(a){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),s=Vc(a,n,S,i),f=o?Vc(o,n,S,i):void 0;C=new Lc(u,r,c,h,p,a,g,x,!1,n),V=4*s.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[Cu*l.layout.get("icon-size").evaluate(w,{})],y[0]>Bu&&A(`${e.layerIds[0]}: Value for "icon-size" is >= ${Mu}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[Cu*_.compositeIconSizes[0].evaluate(w,{},k),Cu*_.compositeIconSizes[1].evaluate(w,{},k)],(y[0]>Bu||y[1]>Bu)&&A(`${e.layerIds[0]}: Value for "icon-size" is >= ${Mu}. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,y,b,v,w,t.ai.none,r,z.lineStartIndex,z.lineLength,-1,k),$=e.icon.placedSymbolArray.length-1,f&&(E=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ai.vertical,r,z.lineStartIndex,z.lineLength,-1,k),L=e.icon.placedSymbolArray.length-1);}const U=Object.keys(i.horizontal);for(const n of U){const a=i.horizontal[n];if(!M){O=$a(a.text);const t=l.layout.get("text-rotate").evaluate(w,{},k);M=new Lc(u,r,c,h,p,a,f,d,y,t);}const o=1===a.positionedLines.length;if(F+=Yc(e,r,a,s,l,y,w,m,z,i.vertical?t.ai.horizontal:t.ai.horizontalOnly,o?U:[n],D,$,_,k),o)break}i.vertical&&(T+=Yc(e,r,i.vertical,s,l,y,w,m,z,t.ai.vertical,["vertical"],D,L,_,k));const R=M?M.boxStartIndex:e.collisionBoxArray.length,q=M?M.boxEndIndex:e.collisionBoxArray.length,j=B?B.boxStartIndex:e.collisionBoxArray.length,N=B?B.boxEndIndex:e.collisionBoxArray.length,Z=C?C.boxStartIndex:e.collisionBoxArray.length,K=C?C.boxEndIndex:e.collisionBoxArray.length,G=P?P.boxStartIndex:e.collisionBoxArray.length,J=P?P.boxEndIndex:e.collisionBoxArray.length;let X=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=Y(M,X),X=Y(B,X),X=Y(C,X),X=Y(P,X);const H=X>-1?1:0;H&&(X*=I/Vl),e.glyphOffsetArray.length>=Uu.MAX_GLYPHS&&A("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Gc(l,w,k),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?D.right:-1,D.center>=0?D.center:-1,D.left>=0?D.left:-1,D.vertical||-1,$,L,O,R,q,j,N,Z,K,G,J,c,F,T,V,E,H,0,f,X,Q,tt);}(e,p,l,n,i,a,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,g,[w,w,w,w],k,u,v,_,I,d,r,s,c,h,o);};if("line"===z)for(const t of _c(r.geometry,0,0,rs,rs)){const r=Cc(t,b,S,n.vertical||y,i,24,x,e.overscaling,rs);for(const n of r)y&&Wc(e,y.text,M,n)||P(t,n);}else if("line-center"===z){for(const t of r.geometry)if(t.length>1){const e=Mc(t,S,n.vertical||y,i,24,x);e&&P(t,e);}}else if("Polygon"===r.type)for(const t of Co(r.geometry,0)){const e=Uc(t,16);P(t[0],new Ac(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry)P(t,new Ac(t[0].x,t[0].y,0));else if("Point"===r.type)for(const t of r.geometry)for(const e of t)P([e],new Ac(e.x,e.y,0));}function Yc(t,e,r,n,i,s,o,l,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,o,l){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=su+1,p=!0,f=1,d=0;const y=(i||l)&&n.vertical,m=n.metrics.advance*n.scale/2;if(l&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Vl-n.metrics.width*n.scale)/2:(n.scale-1)*Vl)),n.imageName){const t=o[n.imageName];p=t.sdf,f=t.pixelRatio,h=lu/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],A=w+s.w/b*n.scale/f,S=_+s.h/b*n.scale/f,k=new a(w,_),I=new a(A,_),z=new a(w,S),M=new a(A,S);if(y){const t=new a(-m,m-pu),e=-Math.PI/2,r=Vl/2-m,i=new a(5-pu-r,-(n.imageName?r:0)),s=new a(...v);k._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),I._matMult(r),z._matMult(r),M._matMult(r);}const C=new a(0,0),B=new a(0,0);c.push({tl:k,tr:I,bl:z,br:M,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:C,pixelOffsetBR:B,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,l,i,s,o,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[Cu*i.layout.get("text-size").evaluate(o,{})],x[0]>Bu&&A(`${t.layerIds[0]}: Value for "text-size" is >= ${Mu}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[Cu*d.compositeTextSizes[0].evaluate(o,{},y),Cu*d.compositeTextSizes[1].evaluate(o,{},y)],(x[0]>Bu||x[1]>Bu)&&A(`${t.layerIds[0]}: Value for "text-size" is >= ${Mu}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,l,s,o,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function Hc(t){for(const e in t)return t[e];return null}function Wc(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Qc[15&r];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new th(s,a,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Qc.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-s%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+a+s+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return eh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:a,nodeSize:s}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=s){for(let s=h;s<=c;s++){const o=a[2*s],u=a[2*s+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[s]);}continue}const p=h+c>>1,f=a[2*p],d=a[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:a}=this,s=[0,n.length-1,0],o=[],l=r*r;for(;s.length;){const u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=a){for(let r=h;r<=c;r++)ah(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];ah(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(s.push(h),s.push(p-1),s.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(s.push(p+1),s.push(c),s.push(1-u));}return o}}function eh(t,e,r,n,i,a){if(i-n<=r)return;const s=n+i>>1;rh(t,e,s,n,i,a),eh(t,e,r,n,s-1,1-a),eh(t,e,r,s+1,i,1-a);}function rh(t,e,r,n,i,a){for(;i>n;){if(i-n>600){const s=i-n+1,o=r-n+1,l=Math.log(s),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(s-u)/s)*(o-s/2<0?-1:1);rh(t,e,r,Math.max(n,Math.floor(r-o*u/s+c)),Math.min(i,Math.floor(r+(s-o)*u/s+c)),a);}const s=e[2*r+a];let o=n,l=i;for(nh(t,e,n,r),e[2*i+a]>s&&nh(t,e,n,i);os;)l--;}e[2*n+a]===s?nh(t,e,n,l):(l++,nh(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function nh(t,e,r,n){ih(t,r,n),ih(e,2*r,2*n),ih(e,2*r+1,2*n+1);}function ih(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function ah(t,e,r,n){const i=t-r,a=e-n;return i*i+a*a}var sh;t.bh=void 0,(sh=t.bh||(t.bh={})).create="create",sh.load="load",sh.fullLoad="fullLoad";let oh=null,lh=[];const uh=1e3/60,ch="loadTime",hh="fullLoadTime",ph={mark(t){performance.mark(t);},frame(t){const e=t;null!=oh&&lh.push(e-oh),oh=e;},clearMetrics(){oh=null,lh=[],performance.clearMeasures(ch),performance.clearMeasures(hh);for(const e in t.bh)performance.clearMarks(t.bh[e]);},getPerformanceMetrics(){performance.measure(ch,t.bh.create,t.bh.load),performance.measure(hh,t.bh.create,t.bh.fullLoad);const e=performance.getEntriesByName(ch)[0].duration,r=performance.getEntriesByName(hh)[0].duration,n=lh.length,i=1/(lh.reduce(((t,e)=>t+e),0)/n/1e3),a=lh.filter((t=>t>uh)).reduce(((t,e)=>t+(e-uh)/uh),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:a/(n+a)*100,totalFrames:n}}};t.$=function(t,e,r){var n,i,a,s,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=a,t[3]=s,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=a*y+u*m+f*g+e[14],t[15]=s*y+c*m+d*g+e[15]),t},t.A=zs,t.B=Ze,t.C=class{constructor(t,e,r){this.receive=t=>{const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[r];const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t();}else I()||e.mustQueue?(this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger()):this.processTask(r,e);},this.process=()=>{if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e);},this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new Qu(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=I()?t:window;}send(t,e,r,n,i=!1){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[a]=r);const s=[],o={id:a,type:t,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:Dn(e,s)};return this.target.postMessage(o,{transfer:s}),{cancel:()=>{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:n,sourceMapId:this.mapId});}}}processTask(t,e){if(""===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(On(e.error)):r(null,On(e.data)));}else {let r=!1;const n=[],i=e.hasCallback?(e,i)=>{r=!0,delete this.cancelCallbacks[t];const a={id:t,type:"",sourceMapId:this.mapId,error:e?Dn(e):null,data:Dn(i,n)};this.target.postMessage(a,{transfer:n});}:t=>{r=!0;};let a=null;const s=On(e.data);if(this.parent[e.type])a=this.parent[e.type](e.sourceMapId,s,i);else if("getWorkerSource"in this.parent){const t=e.type.split(".");a=this.parent.getWorkerSource(e.sourceMapId,t[0],s.source)[t[1]](s,i);}else i(new Error(`Could not find function ${e.type}`));!r&&a&&a.cancel&&(this.cancelCallbacks[t]=a.cancel);}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1);}},t.D=gi,t.E=J,t.F=function(t,e){const r={};for(let n=0;n{}}},t.Y=ot,t.Z=function(){var t=new zs(16);return zs!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t._=e,t.a=M,t.a$=class extends Hi{},t.a0=function(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.a1=Cs,t.a2=function(){return x++},t.a3=ta,t.a4=Uu,t.a5=function(){oi.isLoading()||oi.isLoaded()||"deferred"!==ai()||si();},t.a6=Nr,t.a7=ss,t.a8=li,t.a9=gc,t.aA=ri,t.aB=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r{n[t.source]?r.push({command:Q.removeLayer,args:[t.id]}):a.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(at),i=e.map(at),a=t.reduce(st,{}),s=e.reduce(st,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f,d,y;for(u=0,c=0;u@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const a=n||i;return e[r]=!a||a.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ac=function(t){if(null==z){const e=t.navigator?t.navigator.userAgent:null;z=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return z},t.ad=y,t.ae=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],s=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+u*n,t[1]=s*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-a*n,t[5]=c*i-s*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.af=function(t){var e=new zs(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.ag=Vs,t.ah=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:a,maxZoom:s}=t,o=i?y(Ke.interpolationFactor(i,e,a,s),0,1):0;"camera"===t.kind?n=Ze.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.aj=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/Cu:"composite"===t.kind?Ze.number(n/Cu,i/Cu,r):e},t.ak=$u,t.al=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,o=n.y-r.y,l=n.x-r.x,u=o*s-l*i;if(0===u)return null;const c=(l*(t.y-r.y)-o*(t.x-r.x))/u;return new a(t.x+c*s,t.y+c*i)},t.am=_c,t.an=us,t.ao=Ms,t.ap=Vl,t.ar=Vu,t.as=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*s,v=r*l-i*s,b=r*u-a*s,w=n*l-i*o,_=n*u-a*o,A=i*u-a*l,S=c*y-h*d,k=c*m-p*d,I=c*g-f*d,z=h*m-p*y,M=h*g-f*y,C=p*g-f*m,B=x*C-v*M+b*z+w*I-_*k+A*S;return B?(t[0]=(o*C-l*M+u*z)*(B=1/B),t[1]=(i*M-n*C-a*z)*B,t[2]=(y*A-m*_+g*w)*B,t[3]=(p*_-h*A-f*w)*B,t[4]=(l*I-s*C-u*k)*B,t[5]=(r*C-i*I+a*k)*B,t[6]=(m*b-d*A-g*v)*B,t[7]=(c*A-p*b+f*v)*B,t[8]=(s*M-o*I+u*S)*B,t[9]=(n*I-r*M-a*S)*B,t[10]=(d*_-y*b+g*x)*B,t[11]=(h*b-c*_-f*x)*B,t[12]=(o*k-s*z-l*S)*B,t[13]=(r*z-n*k+i*S)*B,t[14]=(y*v-d*w-m*x)*B,t[15]=(c*w-h*v+p*x)*B,t):null},t.at=Jc,t.au=Su,t.av=th,t.aw=function(){const t={},e=X.$version;for(const r in X.$root){const n=X.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.ax=Q,t.ay=Un,t.az=D,t.b=function(t,e){const r=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(r).then((t=>{e(null,t);})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));},t.b0=Aa,t.b1=function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],f=t[11],d=t[12],y=t[13],m=t[14],g=t[15],x=e[0],v=e[1],b=e[2],w=e[3],_=e[4],A=e[5],S=e[6],k=e[7],I=e[8],z=e[9],M=e[10],C=e[11],B=e[12],P=e[13],V=e[14],E=e[15];return Math.abs(r-x)<=Is*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=Is*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(i-b)<=Is*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-w)<=Is*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-_)<=Is*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(o-A)<=Is*Math.max(1,Math.abs(o),Math.abs(A))&&Math.abs(l-S)<=Is*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(u-k)<=Is*Math.max(1,Math.abs(u),Math.abs(k))&&Math.abs(c-I)<=Is*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-z)<=Is*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(p-M)<=Is*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(f-C)<=Is*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(d-B)<=Is*Math.max(1,Math.abs(d),Math.abs(B))&&Math.abs(y-P)<=Is*Math.max(1,Math.abs(y),Math.abs(P))&&Math.abs(m-V)<=Is*Math.max(1,Math.abs(m),Math.abs(V))&&Math.abs(g-E)<=Is*Math.max(1,Math.abs(g),Math.abs(E))},t.b2=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.b3=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.b4=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},t.b5=m,t.b6=pc,t.b7=sc,t.b8=function(t,e,r,n,i){var a,s=1/Math.tan(e/2);return t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(a=1/(n-i)),t[14]=2*i*n*a):(t[10]=-1,t[14]=-2*n),t},t.b9=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+u*n,t[5]=s*i+c*n,t[6]=o*i+h*n,t[7]=l*i+p*n,t[8]=u*i-a*n,t[9]=c*i-s*n,t[10]=h*i-o*n,t[11]=p*i-l*n,t},t.bA=n,t.bB=El,t.bC=$r,t.bD=oi,t.ba=f,t.bb=d,t.bc=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.bd=class extends Pi{},t.be=tc,t.bf=oc,t.bg=ph,t.bi=L,t.bj=function(t,e,r=!1){if(ti===Yn||ti===Hn||ti===Wn)throw new Error("setRTLTextPlugin cannot be called multiple times.");ei=T.resolveURL(t),ti=Yn,Qn=e,ni(),r||si();},t.bk=ai,t.bl=function(t,e){const r={};for(let n=0;nt*Vl));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b=n.get("symbol-placement"),w="point"===b?n.get("text-max-width").evaluate(i,{},e.canonical)*Vl:0,_=()=>{e.bucket.allowVerticalPlacement&&qn(a)&&(d.vertical=yu(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,w,s,m,"left",f,g,t.ai.vertical,!0,b,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;t{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=C;}));},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):C;},t.e=g,t.f=function(t,e){return R(g(t,{type:"json"}),e)},t.g=O,t.h=T,t.i=I,t.j=G,t.k=K,t.l=q,t.m=R,t.n=function(t){return new eu(t).readFields(nu,[])},t.o=function(t,e,r){if(!t.length)return r(null,[]);let n=t.length;const i=new Array(t.length);let a=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(a=t),i[s]=e,0==--n&&r(a,i);}));}));},t.p=ou,t.q=Rs,t.r=_i,t.s=j,t.t=Bn,t.u=Rn,t.v=X,t.w=A,t.x=En,t.y=Cn,t.z=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}};})); + +define(["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,i){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.aC(i);t._featureFilter=e.a6(t.filter),this.keyCache[i.id]&&delete this.keyCache[i.id];}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const o=e.bl(Object.values(this._layerConfigs),this.keyCache);for(const e of o){const t=e.map((e=>this._layers[e.id])),i=t[0];if("none"===i.visibility)continue;const o=i.source||"";let r=this.familiesBySource[o];r||(r=this.familiesBySource[o]={});const s=i.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class i{constructor(t){const i={},o=[];for(const e in t){const r=t[e],s=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};o.push(i),s[e]={rect:i,metrics:t.metrics};}}const{w:r,h:s}=e.p(o),n=new e.q({width:r||1,height:s||1});for(const o in t){const r=t[o];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=i[o][t].rect;e.q.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=i;}}e.bm("GlyphAtlas",i);class o{constructor(t){this.tileID=new e.O(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[],this.dependencySentinel=-1;}parse(t,o,s,n,a){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a3;const l=new e.bn(Object.keys(t.layers).sort()),c=new e.bo(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s},d=o.familiesBySource[this.source];for(const i in d){const o=t.layers[i];if(!o)continue;1===o.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(i),a=[];for(let e=0;e=i.maxzoom||"none"!==i.visibility&&(r(t,this.zoom,s),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,u,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}let p,f,g,m;const y=e.aH(u.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.cancel())),this.inFlightDependencies=[];const v=++this.dependencySentinel;Object.keys(y).length?this.inFlightDependencies.push(n.send("getGlyphs",{uid:this.uid,stacks:y,source:this.source,tileID:this.tileID,type:"glyphs"},((e,t)=>{v===this.dependencySentinel&&(p||(p=e,f=t,b.call(this)));}))):f={};const w=Object.keys(u.iconDependencies);w.length?this.inFlightDependencies.push(n.send("getImages",{icons:w,source:this.source,tileID:this.tileID,type:"icons"},((e,t)=>{v===this.dependencySentinel&&(p||(p=e,g=t,b.call(this)));}))):g={};const x=Object.keys(u.patternDependencies);function b(){if(p)return a(p);if(f&&g&&m){const t=new i(f),o=new e.bp(g,m);for(const i in h){const n=h[i];n instanceof e.a4?(r(n.layers,this.zoom,s),e.bq({bucket:n,glyphMap:f,glyphPositions:t.positions,imageMap:g,imagePositions:o.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):n.hasPattern&&(n instanceof e.br||n instanceof e.bs||n instanceof e.bt)&&(r(n.layers,this.zoom,s),n.addFeatures(u,this.tileID.canonical,o.patternPositions));}this.status="done",a(null,{buckets:Object.values(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,imageAtlas:o,glyphMap:this.returnDependencies?f:null,iconMap:this.returnDependencies?g:null,glyphPositions:this.returnDependencies?t.positions:null});}}x.length?this.inFlightDependencies.push(n.send("getImages",{icons:x,source:this.source,tileID:this.tileID,type:"patterns"},((e,t)=>{v===this.dependencySentinel&&(p||(p=e,m=t,b.call(this)));}))):m={},b.call(this);}}function r(t,i,o){const r=new e.a8(i);for(const e of t)e.recalculate(r,o);}function s(t,i){const o=e.l(t.request,((o,r,s,n)=>{if(o)i(o);else if(r)try{const t=new e.bw.VectorTile(new e.bv(r));i(null,{vectorTile:t,rawData:r,cacheControl:s,expires:n});}catch(e){const o=new Uint8Array(r);let s=`Unable to parse the tile at ${t.request.url}, `;s+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.messge}`,i(new Error(s));}}));return ()=>{o.cancel(),i();}}class n{constructor(e,t,i,o){this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=o||s,this.fetching={},this.loading={},this.loaded={};}loadTile(t,i){const r=t.uid;this.loading||(this.loading={});const s=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.bu(t.request),n=this.loading[r]=new o(t);n.abort=this.loadVectorData(t,((t,o)=>{if(delete this.loading[r],t||!o)return n.status="done",this.loaded[r]=n,i(t);const a=o.rawData,l={};o.expires&&(l.expires=o.expires),o.cacheControl&&(l.cacheControl=o.cacheControl);const c={};if(s){const e=s.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}n.vectorTile=o.vectorTile,n.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,o)=>{if(delete this.fetching[r],t||!o)return i(t);i(null,e.e({rawTileData:a.slice(0)},o,l,c));})),this.loaded=this.loaded||{},this.loaded[r]=n,this.fetching[r]={rawTileData:a,cacheControl:l,resourceTiming:c};}));}reloadTile(t,i){const o=this.loaded,r=t.uid;if(o&&o[r]){const s=o[r];s.showCollisionBoxes=t.showCollisionBoxes,"parsing"===s.status?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,o)=>{if(t||!o)return i(t,o);let s;if(this.fetching[r]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[r];delete this.fetching[r],s=e.e({rawTileData:t.slice(0)},o,i,n);}else s=o;i(null,s);})):"done"===s.status&&(s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,i):i());}}abortTile(e,t){const i=this.loading,o=e.uid;i&&i[o]&&i[o].abort&&(i[o].abort(),delete i[o]),t();}removeTile(e,t){const i=this.loaded,o=e.uid;i&&i[o]&&delete i[o],t();}}class a{constructor(){this.loaded={};}loadTile(t,i){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:r,rawImageData:s,redFactor:n,greenFactor:a,blueFactor:l,baseShift:c}=t,h=s.width+2,u=s.height+2,d=e.a(s)?new e.R({width:h,height:u},yield e.bx(s,-1,-1,h,u)):s,p=new e.by(o,d,r,n,a,l,c);this.loaded=this.loaded||{},this.loaded[o]=p,i(null,p);}))}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i];}}function l(e,t){if(0!==e.length){c(e[0],t);for(var i=1;i=Math.abs(a)?i-l+a:a-l+i,i=l;}i+o>=0!=!!t&&e.reverse();}var h=e.bz((function e(t,i){var o,r=t&&t.type;if("FeatureCollection"===r)for(o=0;o>31}function T(e,t){for(var i=e.loadGeometry(),o=e.type,r=0,s=0,n=i.length,a=0;ae},O=Math.fround||(C=new Float32Array(1),e=>(C[0]=+e,C[0]));var C;const L=3,F=5,z=6;class N{constructor(e){this.options=Object.assign(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:i,maxZoom:o}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=i;e--){const i=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-i);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,o,180,s],t),n=this.getClusters([-180,o,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(Z(i),G(s),Z(r),G(o)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+F]>1?E(l,t,this.clusterProps):this.points[l[t+L]]);}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),o="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(o);const s=r.data;if(t*this.stride>=s.length)throw new Error(o);const n=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const i=t*this.stride;s[i+4]===e&&l.push(s[i+F]>1?E(s,i,this.clusterProps):this.points[s[i+L]]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,i){const o=[];return this._appendLeaves(o,e,t=t||10,i=i||0,0),o}getTile(e,t,i){const o=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(o.range((t-a)/r,l,(t+1+a)/r,c),o.data,t,i,r,h),0===t&&this._addTileFeatures(o.range(1-a/r,l,1,c),o.data,r,i,r,h),t===r-1&&this._addTileFeatures(o.range(0,l,a/r,c),o.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id;}return t}_appendLeaves(e,t,i,o,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=o?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,i,o,r):r1;let l,c,h;if(a)l=j(t,e,this.clusterProps),c=t[e],h=t[e+1];else {const i=this.points[t[e+L]];l=i.properties;const[o,r]=i.geometry.coordinates;c=Z(o),h=G(r);}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-o))]],tags:l};let d;d=a||this.options.generateId?t[e+L]:this.points[t[e+L]].id,void 0!==d&&(u.id=d),s.features.push(u);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:o,reduce:r,minPoints:s}=this.options,n=i/(o*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+F]);}if(p>d&&p>=s){let e,s=o*d,n=h*d,f=-1;const g=((i/c|0)<<5)+(t+1)+this.points.length;for(const o of u){const l=o*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+F];s+=a[l]*h,n+=a[l+1]*h,a[l+4]=g,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[i+4]=g,l.push(s/p,n/p,1/0,g,-1,p),r&&l.push(f);}else {for(let e=0;e1)for(const e of u){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,i){if(e[t+F]>1){const o=this.clusterProps[e[t+z]];return i?Object.assign({},o):o}const o=this.points[e[t+L]].properties,r=this.options.map(o);return i&&r===o?Object.assign({},r):r}}function E(e,t,i){return {type:"Feature",id:e[t+L],properties:j(e,t,i),geometry:{type:"Point",coordinates:[(o=e[t],360*(o-.5)),J(e[t+1])]}};var o;}function j(e,t,i){const o=e[t+F],r=o>=1e4?`${Math.round(o/1e3)}k`:o>=1e3?Math.round(o/100)/10+"k":o,s=e[t+z],n=-1===s?{}:Object.assign({},i[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+L],point_count:o,point_count_abbreviated:r})}function Z(e){return e/360+.5}function G(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function J(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Y(e,t,i,o){for(var r,s=o,n=i-t>>1,a=i-t,l=e[t],c=e[t+1],h=e[i],u=e[i+1],d=t+3;ds)r=d,s=p;else if(p===s){var f=Math.abs(d-n);fo&&(r-t>3&&Y(e,t,r,o),e[r+2]=s,i-r>3&&Y(e,r,i,o));}function A(e,t,i,o,r,s){var n=r-i,a=s-o;if(0!==n||0!==a){var l=((e-i)*n+(t-o)*a)/(n*n+a*a);l>1?(i=r,o=s):l>0&&(i+=n*l,o+=a*l);}return (n=e-i)*n+(a=t-o)*a}function V(e,t,i,o){var r={id:void 0===e?null:e,type:t,geometry:i,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,i=e.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)B(e,t);else if("Polygon"===i||"MultiLineString"===i)for(var o=0;o0&&(n+=o?(r*c-l*s)/2:Math.sqrt(Math.pow(l-r,2)+Math.pow(c-s,2))),r=l,s=c;}var h=t.length-3;t[2]=1,Y(t,0,h,i),t[h+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function W(e,t,i,o){for(var r=0;r1?1:i}function H(e,t,i,o,r,s,n,a){if(o/=t,s>=(i/=t)&&n=o)return null;for(var l=[],c=0;c=i&&f=o)){var g=[];if("Point"===d||"MultiPoint"===d)K(u,g,i,o,r);else if("LineString"===d)Q(u,g,i,o,r,!1,a.lineMetrics);else if("MultiLineString"===d)te(u,g,i,o,r,!1);else if("Polygon"===d)te(u,g,i,o,r,!0);else if("MultiPolygon"===d)for(var m=0;m=i&&n<=o&&(t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]));}}function Q(e,t,i,o,r,s,n){for(var a,l,c=ee(e),h=0===r?oe:re,u=e.start,d=0;di&&(l=h(c,p,f,m,y,i),n&&(c.start=u+a*l)):v>o?w=i&&(l=h(c,p,f,m,y,i),x=!0),w>o&&v<=o&&(l=h(c,p,f,m,y,o),x=!0),!s&&x&&(n&&(c.end=u+a*l),t.push(c),c=ee(e)),n&&(u+=a);}var b=e.length-3;p=e[b],f=e[b+1],g=e[b+2],(v=0===r?p:f)>=i&&v<=o&&ie(c,p,f,g),b=c.length-3,s&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&ie(c,c[0],c[1],c[2]),c.length&&t.push(c);}function ee(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function te(e,t,i,o,r,s){for(var n=0;nn.maxX&&(n.maxX=h),u>n.maxY&&(n.maxY=u);}return n}function he(e,t,i,o){var r=t.geometry,s=t.type,n=[];if("Point"===s||"MultiPoint"===s)for(var a=0;a0&&t.size<(r?n:o))i.numPoints+=t.length/3;else {for(var a=[],l=0;ln)&&(i.numSimplified++,a.push(t[l]),a.push(t[l+1])),i.numPoints++;r&&function(e,t){for(var i=0,o=0,r=e.length,s=r-2;o0===t)for(o=0,r=e.length;o24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var o=function(e,t){var i=[];if("FeatureCollection"===e.type)for(var o=0;o1&&console.time("creation"),d=this.tiles[u]=ce(e,t,i,o,l),this.tileCoords.push({z:t,x:i,y:o}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,o,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++;}if(d.source=e,r){if(t===l.maxZoom||t===r)continue;var f=1<1&&console.time("clipping");var g,m,y,v,w,x,b=.5*l.buffer/l.extent,S=.5-b,M=.5+b,I=1+b;g=m=y=v=null,w=H(e,h,i-b,i+M,0,d.minX,d.maxX,l),x=H(e,h,i+S,i+I,0,d.minX,d.maxX,l),e=null,w&&(g=H(w,h,o-b,o+M,1,d.minY,d.maxY,l),m=H(w,h,o+S,o+I,1,d.minY,d.maxY,l),w=null),x&&(y=H(x,h,o-b,o+M,1,d.minY,d.maxY,l),v=H(x,h,o+S,o+I,1,d.minY,d.maxY,l),x=null),c>1&&console.timeEnd("clipping"),a.push(g||[],t+1,2*i,2*o),a.push(m||[],t+1,2*i,2*o+1),a.push(y||[],t+1,2*i+1,2*o),a.push(v||[],t+1,2*i+1,2*o+1);}}},de.prototype.getTile=function(e,t,i){var o=this.options,r=o.extent,s=o.debug;if(e<0||e>24)return null;var n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);for(var l,c=e,h=t,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[pe(c,h,u)];return l&&l.source?(s>1&&console.log("found parent tile z%d-%d-%d",c,h,u),s>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,e,t,i),s>1&&console.timeEnd("drilling down"),this.tiles[a]?ae(this.tiles[a],r):null):null};class ye extends n{constructor(t,i,o,r){super(t,i,o),this._dataUpdateable=new Map,this.loadGeoJSON=(t,i)=>{const{promoteId:o}=t;if(t.request)return e.f(t.request,((e,t,r,s)=>{this._dataUpdateable=ge(t,o)?me(t,o):void 0,i(e,t,r,s);}));if("string"==typeof t.data)try{const e=JSON.parse(t.data);this._dataUpdateable=ge(e,o)?me(e,o):void 0,i(null,e);}catch(e){i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));}else t.dataDiff?this._dataUpdateable?(function(e,t,i){var o,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const i of t.remove)e.delete(i);if(t.add)for(const o of t.add){const t=fe(o,i);null!=t&&e.set(t,o);}if(t.update)for(const i of t.update){let t=e.get(i.id);if(null==t)continue;const a=!i.removeAllProperties&&((null===(o=i.removeProperties)||void 0===o?void 0:o.length)>0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((i.newGeometry||i.removeAllProperties||a)&&(t=Object.assign({},t),e.set(i.id,t),a&&(t.properties=Object.assign({},t.properties))),i.newGeometry&&(t.geometry=i.newGeometry),i.removeAllProperties)t.properties={};else if((null===(s=i.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of i.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=i.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:o}of i.addOrUpdateProperties)t.properties[e]=o;}}(this._dataUpdateable,t.dataDiff,o),i(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):i(new Error(`Cannot update existing geojson data in ${t.source}`)):i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));return {cancel:()=>{}}},this.loadVectorData=this.loadGeoJSONTile,r&&(this.loadGeoJSON=r);}loadGeoJSONTile(t,i){const o=t.tileID.canonical;if(!this._geoJSONIndex)return i(null,null);const r=this._geoJSONIndex.getTile(o.z,o.x,o.y);if(!r)return i(null,null);const s=new class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.N,this.length=t.length,this._features=t;}feature(t){return new class{constructor(t){this._feature=t,this.extent=e.N,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10));}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const o=[];for(const t of i)o.push(new e.P(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,i){return u.call(this,e,t,i)}}(this._features[t])}}(r.features);let n=k(s);0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),i(null,{vectorTile:s,rawData:n.buffer});}loadData(t,i){var o;null===(o=this._pendingRequest)||void 0===o||o.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.bu(t.request);this._pendingCallback=i,this._pendingRequest=this.loadGeoJSON(t,((o,s)=>{if(delete this._pendingCallback,delete this._pendingRequest,o||!s)return i(o);if("object"!=typeof s)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{h(s,!0);try{if(t.filter){const i=e.bC(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const o=s.features.filter((e=>i.value.evaluate({zoom:0},e)));s={type:"FeatureCollection",features:o};}this._geoJSONIndex=t.cluster?new N(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const o={},r={},s={accumulated:null,zoom:0},n={properties:null},a=Object.keys(i);for(const t of a){const[s,n]=i[t],a=e.bC(n),l=e.bC("string"==typeof s?[s,["accumulated"],["get",t]]:s);o[t]=a.value,r[t]=l.value;}return t.map=e=>{n.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load(s.features):function(e,t){return new de(e,t)}(s,t.geojsonVtOptions);}catch(o){return i(o)}this.loaded={};const n={};if(r){const e=r.finish();e&&(n.resourceTiming={},n.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}i(null,n);}}));}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}removeSource(e,t){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),t();}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class ve{constructor(t){this.self=t,this.actor=new e.C(t,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:n,geojson:ye},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.bD.isParsed())throw new Error("RTL text plugin already registered.");e.bD.applyArabicShaping=t.applyArabicShaping,e.bD.processBidirectionalText=t.processBidirectionalText,e.bD.processStyledBidirectionalText=t.processStyledBidirectionalText;};}setReferrer(e,t){this.referrer=t;}setImages(e,t,i){this.availableImages[e]=t;for(const i in this.workerSources[e]){const o=this.workerSources[e][i];for(const e in o)o[e].availableImages=t;}i();}setLayers(e,t,i){this.getLayerIndex(e).replace(t),i();}updateLayers(e,t,i){this.getLayerIndex(e).update(t.layers,t.removedIds),i();}loadTile(e,t,i){this.getWorkerSource(e,t.type,t.source).loadTile(t,i);}loadDEMTile(e,t,i){this.getDEMWorkerSource(e,t.source).loadTile(t,i);}reloadTile(e,t,i){this.getWorkerSource(e,t.type,t.source).reloadTile(t,i);}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source).abortTile(t,i);}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source).removeTile(t,i);}removeDEMTile(e,t){this.getDEMWorkerSource(e,t.source).removeTile(t);}removeSource(e,t,i){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const o=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,i):i();}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i();}catch(e){i(e.toString());}}syncRTLPluginState(t,i,o){try{e.bD.setState(i);const t=e.bD.getPluginURL();if(e.bD.isLoaded()&&!e.bD.isParsed()&&null!=t){this.self.importScripts(t);const i=e.bD.isParsed();o(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i);}}catch(e){o(e.toString());}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}getWorkerSource(e,t,i){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),this.workerSources[e][t][i]||(this.workerSources[e][t][i]=new this.workerSourceTypes[t]({send:(t,i,o)=>{this.actor.send(t,i,o,e);}},this.getLayerIndex(e),this.getAvailableImages(e))),this.workerSources[e][t][i]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new a),this.demWorkerSources[e][t]}}return e.i()&&(self.worker=new ve(self)),ve})); + +define(["./shared"],(function(t){"use strict";var e="3.6.2";class i{static testProp(t){if(!i.docStyle)return t[0];for(let e=0;e{window.removeEventListener("click",i.suppressClickInternal,!0);}),0);}static mousePos(e,i){const s=e.getBoundingClientRect();return new t.P(i.clientX-s.left-e.clientLeft,i.clientY-s.top-e.clientTop)}static touchPos(e,i){const s=e.getBoundingClientRect(),a=[];for(let o=0;o{i=[],a=0,o=0,r={};},e.addThrottleControl=t=>{const e=o++;return r[e]=t,e},e.removeThrottleControl=t=>{delete r[t],h();},e.getImage=(t,e,o=!0)=>{s.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*");const r={requestParameters:t,supportImageRefresh:o,callback:e,cancelled:!1,completed:!1,cancel:()=>{r.completed||r.cancelled||(r.cancelled=!0,r.innerRequest&&(r.innerRequest.cancel(),a--),h());}};return i.push(r),h(),r};const n=e=>{const{requestParameters:i,supportImageRefresh:s,callback:a}=e;return t.e(i,{type:"image"}),(!1!==s||t.i()||t.g(i.url)||i.headers&&!Object.keys(i.headers).reduce(((t,e)=>t&&"accept"===e),!0)?t.m:c)(i,((t,i,s,o)=>{l(e,a,t,i,s,o);}))},l=(e,i,s,o,r,n)=>{s?i(s):o instanceof HTMLImageElement||t.a(o)?i(null,o):o&&((e,i)=>{"function"==typeof createImageBitmap?t.b(e,i):t.d(e,i);})(o,((t,e)=>{null!=t?i(t):null!=e&&i(null,e,{cacheControl:r,expires:n});})),e.cancelled||(e.completed=!0,a--,h());},h=()=>{const e=(()=>{const t=Object.keys(r);let e=!1;if(t.length>0)for(const i of t)if(e=r[i](),e)break;return e})()?t.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=a;t0;t++){const e=i.shift();if(e.cancelled){t--;continue}const s=n(e);a++,e.innerRequest=s;}},c=(e,i)=>{const s=new Image,a=e.url;let o=!1;const r=e.credentials;return r&&"include"===r?s.crossOrigin="use-credentials":(r&&"same-origin"===r||!t.s(a))&&(s.crossOrigin="anonymous"),s.fetchPriority="high",s.onload=()=>{i(null,s),s.onerror=s.onload=null;},s.onerror=()=>{o||i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.")),s.onerror=s.onload=null;},s.src=a,{cancel:()=>{o=!0,s.src="";}}};}(h||(h={})),h.resetRequestQueue(),function(t){t.Glyphs="Glyphs",t.Image="Image",t.Source="Source",t.SpriteImage="SpriteImage",t.SpriteJSON="SpriteJSON",t.Style="Style",t.Tile="Tile",t.Unknown="Unknown";}(c||(c={}));class u{constructor(t){this._transformRequestFn=t;}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeSpriteURL(t,e,i){const s=function(t){const e=t.match(d);if(!e)throw new Error(`Unable to parse URL "${t}"`);return {protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}(t);return s.path+=`${e}${i}`,function(t){const e=t.params.length?`?${t.params.join("&")}`:"";return `${t.protocol}://${t.authority}${t.path}${e}`}(s)}setTransformRequest(t){this._transformRequestFn=t;}}const d=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function _(e){var i=new t.A(3);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i}var p,m=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t};p=new t.A(3),t.A!=Float32Array&&(p[0]=0,p[1]=0,p[2]=0);var f=function(t){var e=t[0],i=t[1];return e*e+i*i};function g(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:s,url:a}of t){const t=`${s}${a}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:s,url:a}));}}return e}function v(e,i,s,a,o){if(a)return void e(a);if(o!==Object.values(i).length||o!==Object.values(s).length)return;const r={};for(const e in i){r[e]={};const a=t.h.getImageCanvasContext(s[e]),o=i[e];for(const t in o){const{width:i,height:s,x:n,y:l,sdf:h,pixelRatio:c,stretchX:u,stretchY:d,content:_}=o[t];r[e][t]={data:null,pixelRatio:c,sdf:h,stretchX:u,stretchY:d,content:_,spriteData:{width:i,height:s,x:n,y:l,context:a}};}}e(null,r);}!function(){var e=new t.A(2);t.A!=Float32Array&&(e[0]=0,e[1]=0);}();class x{constructor(t,e,i,s){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,s);}update(e,i,s){const{width:a,height:o}=e,r=!(this.size&&this.size[0]===a&&this.size[1]===o||s),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),r)this.size=[a,o],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.a(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,a,o,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:r}=s||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.a(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,r,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,r,a,o,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D);}bind(t,e,i){const{context:s}=this,{gl:a}=s;a.bindTexture(a.TEXTURE_2D,this.texture),i!==a.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=a.LINEAR),t!==this.filter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,e),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,e),this.wrap=e);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}function y(t){const{userImage:e}=t;return !!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e);}_validate(e,i){let s=!0;const a=i.data||i.spriteData;return this._validateStretch(i.stretchX,a&&a.width)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "stretchX" value`))),s=!1),this._validateStretch(i.stretchY,a&&a.height)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "stretchY" value`))),s=!1),this._validateContent(i.content,i)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "content" value`))),s=!1),s}_validateStretch(t,e){if(!t)return !0;let i=0;for(const s of t){if(s[0]-1);l++,o[l]=n,r[l]=h,r[l+1]=w;}for(let n=0,l=0;n{let s=this.entries[t];s||(s=this.entries[t]={glyphs:{},requests:{},ranges:{}});let a=s.glyphs[e];if(void 0!==a)return void i(null,{stack:t,id:e,glyph:a});if(a=this._tinySDF(s,t,e),a)return s.glyphs[e]=a,void i(null,{stack:t,id:e,glyph:a});const o=Math.floor(e/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(s.ranges[o])return void i(null,{stack:t,id:e,glyph:a});if(!this.url)return void i(new Error("glyphsUrl is not set"));let r=s.requests[o];r||(r=s.requests[o]=[],E.loadGlyphRange(t,o,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(s.glyphs[+t]=e[+t]);s.ranges[o]=!0;}for(const i of r)i(t,e);delete s.requests[o];}))),r.push(((s,a)=>{s?i(s):a&&i(null,{stack:t,id:e,glyph:a[e]||null});}));}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:s,glyph:a}of e)(t[i]||(t[i]={}))[s]=a&&{id:a.id,bitmap:a.bitmap.clone(),metrics:a.metrics};i(null,t);}}));}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&(t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e))}_tinySDF(e,i,s){const a=this.localIdeographFontFamily;if(!a)return;if(!this._doesCharSupportLocalGlyph(s))return;let o=e.tinySDF;if(!o){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),o=e.tinySDF=new E.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:a,fontWeight:t});}const r=o.draw(String.fromCharCode(s));return {id:s,bitmap:new t.q({width:r.width||60,height:r.height||60},r.data),metrics:{width:r.glyphWidth/2||24,height:r.glyphHeight/2||24,left:r.glyphLeft/2+.5||0,top:r.glyphTop/2-27.5||-8,advance:r.glyphAdvance/2||24,isDoubleResolution:!0}}}}E.loadGlyphRange=function(e,i,s,a,o){const r=256*i,n=r+255,l=a.transformRequest(s.replace("{fontstack}",e).replace("{range}",`${r}-${n}`),c.Glyphs);t.l(l,((e,i)=>{if(e)o(e);else if(i){const e={};for(const s of t.n(i))e[s.id]=s;o(null,e);}}));},E.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:s=.25,fontFamily:a="sans-serif",fontWeight:o="normal",fontStyle:r="normal"}={}){this.buffer=e,this.cutoff=s,this.radius=i;const n=this.size=t+4*e,l=this._createCanvas(n),h=this.ctx=l.getContext("2d",{willReadFrequently:!0});h.font=`${r} ${o} ${t}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:s,actualBoundingBoxLeft:a,actualBoundingBoxRight:o}=this.ctx.measureText(t),r=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-a))),l=Math.min(this.size-this.buffer,r+Math.ceil(s)),h=n+2*this.buffer,c=l+2*this.buffer,u=Math.max(h*c,0),d=new Uint8ClampedArray(u),_={data:d,width:h,height:c,glyphWidth:n,glyphHeight:l,glyphTop:r,glyphLeft:0,glyphAdvance:e};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(t,m,m+r);const v=p.getImageData(m,m,n,l);g.fill(w,0,u),f.fill(0,0,u);for(let t=0;t0?t*t:0,f[s]=t<0?t*t:0;}}T(g,0,0,h,c,h,this.f,this.v,this.z),T(f,m,m,n,l,h,this.f,this.v,this.z);for(let t=0;t1&&(r=t[++o]);const l=Math.abs(n-r.left),h=Math.abs(n-r.right),c=Math.min(l,h);let u;const d=e/i*(s+1);if(r.isDash){const t=s-Math.abs(d);u=Math.sqrt(c*c+t*t);}else u=s-Math.sqrt(c*c+d*d);this.data[a+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],s=t[e+1];i.zeroLength?t.splice(e,1):s&&s.isDash===i.isDash&&(s.left=i.left,t.splice(e,1));}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const s=this.width*this.nextRow;let a=0,o=t[a];for(let e=0;e1&&(o=t[++a]);const i=Math.abs(e-o.left),r=Math.abs(e-o.right),n=Math.min(i,r);this.data[s+e]=Math.max(0,Math.min(255,(o.isDash?n:-n)+128));}}addDash(e,i){const s=i?7:0,a=2*s+1;if(this.nextRow+a>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{t.send(e,i,s);}),s=s||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((t=>{t.remove();})),this.actors=[],t&&this.workerPool.release(this.id);}}function z(e,i,s){const a=function(i,a){if(i)return s(i);if(a){const i=t.F(t.e(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(i.vectorLayers=a.vector_layers,i.vectorLayerIds=i.vectorLayers.map((t=>t.id))),s(null,i);}};return e.url?t.f(i.transformRequest(e.url,c.Source),a):t.h.frame((()=>a(null,e)))}class L{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])));}setNorthEast(e){return this._ne=e instanceof t.L?new t.L(e.lng,e.lat):t.L.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.L?new t.L(e.lng,e.lat):t.L.convert(e),this}extend(e){const i=this._sw,s=this._ne;let a,o;if(e instanceof t.L)a=e,o=e;else {if(!(e instanceof L))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(L.convert(e)):this.extend(t.L.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.L.convert(e)):this;if(a=e._sw,o=e._ne,!a||!o)return this}return i||s?(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),s.lng=Math.max(o.lng,s.lng),s.lat=Math.max(o.lat,s.lat)):(this._sw=new t.L(a.lng,a.lat),this._ne=new t.L(o.lng,o.lat)),this}getCenter(){return new t.L((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.L(this.getWest(),this.getNorth())}getSouthEast(){return new t.L(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:s}=t.L.convert(e);let a=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=s&&s<=this._ne.lat&&a}static convert(t){return t instanceof L?t:t?new L(t):t}static fromLngLat(e,i=0){const s=360*i/40075017,a=s/Math.cos(Math.PI/180*e.lat);return new L(new t.L(e.lng-a,e.lat-s),new t.L(e.lng+a,e.lat+s))}}class A{constructor(t,e,i){this.bounds=L.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24;}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),s=Math.floor(t.G(this.bounds.getWest())*i),a=Math.floor(t.H(this.bounds.getNorth())*i),o=Math.ceil(t.G(this.bounds.getEast())*i),r=Math.ceil(t.H(this.bounds.getSouth())*i);return e.x>=s&&e.x=a&&e.y{this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this._tileJSONRequest=z(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e?this.fire(new t.j(e)):i&&(t.e(this,i),i.bounds&&(this.tileBounds=new A(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.k("data",{dataType:"source",sourceDataType:"content"})));}));},this.serialize=()=>t.e({},this._options),this.id=e,this.dispatcher=s,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.e(this,t.F(i,["url","scheme","tileSize","promoteId"])),this._options=t.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(a);}loaded(){return this._loaded}hasTile(t){return !this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load();}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load();}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t;})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),s={request:this.map._requestManager.transformRequest(i,c.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function a(i,s){return delete t.request,t.aborted?e(null):i&&404!==i.status?e(i):(s&&s.resourceTiming&&(t.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&t.setExpiryData(s),t.loadVectorData(s,this.map.painter),e(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}s.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state?"loading"===t.state?t.reloadCallback=e:t.request=t.actor.send("reloadTile",s,a.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",s,a.bind(this)));}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0);}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0);}hasTransition(){return !1}}class k extends t.E{constructor(e,i,s,a){super(),this.id=e,this.dispatcher=s,this.setEventedParent(a),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.F(i,["url","scheme","tileSize"]));}load(){this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this._tileJSONRequest=z(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.j(e)):i&&(t.e(this,i),i.bounds&&(this.tileBounds=new A(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.k("data",{dataType:"source",sourceDataType:"content"})));}));}loaded(){return this._loaded}onAdd(t){this.map=t,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load();}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t;})),this}serialize(){return t.e({},this._options)}hasTile(t){return !this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=h.getImage(this.map._requestManager.transformRequest(i,c.Tile),((i,s,a)=>{if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(s){this.map._refreshExpiredTiles&&a&&t.setExpiryData(a);const i=this.map.painter.context,o=i.gl;t.texture=this.map.painter.getTileTexture(s.width),t.texture?t.texture.update(s,{useMipmap:!0}):(t.texture=new x(i,s,o.RGBA,{useMipmap:!0}),t.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),i.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),t.state="loaded",e(null);}}),this.map._refreshExpiredTiles);}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e();}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e();}hasTransition(){return !1}}class F extends k{constructor(e,i,s,a){super(e,i,s,a),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e,i){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(s,c.Tile);function o(t,s){t&&(e.state="errored",i(t)),s&&(e.dem=s,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded",i(null));}e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.request=h.getImage(a,((s,a,r)=>t._(this,void 0,void 0,(function*(){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(s)e.state="errored",i(s);else if(a){this.map._refreshExpiredTiles&&e.setExpiryData(r);const i=t.a(a)&&t.J()?a:yield function(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.K()){const i=e.width+2,s=e.height+2;try{return new t.R({width:i,height:s},yield t.M(e,-1,-1,i,s))}catch(t){}}return t.h.getImageData(e,1)}))}(a),s={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",s,o));}}))),this.map._refreshExpiredTiles);}_getNeighboringTiles(e){const i=e.canonical,s=Math.pow(2,i.z),a=(i.x-1+s)%s,o=0===i.x?e.wrap-1:e.wrap,r=(i.x+1+s)%s,n=i.x+1===s?e.wrap+1:e.wrap,l={};return l[new t.O(e.overscaledZ,o,i.z,a,i.y).key]={backfilled:!1},l[new t.O(e.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},i.y>0&&(l[new t.O(e.overscaledZ,o,i.z,a,i.y-1).key]={backfilled:!1},l[new t.O(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.O(e.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1}),i.y+1{this._updateWorkerData();},this.serialize=()=>t.e({},this._options,{type:this.type,data:this._data}),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=s.getActor(),this.setEventedParent(a),this._data=i.data,this._options=t.e({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=t.N/this.tileSize;this.workerOptions=t.e({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:t.N,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:t.N,radius:(i.clusterRadius||50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions),"string"==typeof this.promoteId&&(this.workerOptions.promoteId=this.promoteId);}onAdd(t){this.map=t,this.load();}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(void 0!==t.clusterRadius&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),void 0!==t.clusterMaxZoom&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,s){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},s),this}_updateWorkerData(e){const i=t.e({},this.workerOptions);e?i.dataDiff=e:"string"==typeof this._data?(i.request=this.map._requestManager.transformRequest(t.h.resolveURL(this._data),c.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new t.k("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,i,((e,i)=>{if(this._pendingLoads--,this._removed||i&&i.abandoned)return void this.fire(new t.k("dataabort",{dataType:"source"}));let s=null;if(i&&i.resourceTiming&&i.resourceTiming[this.id]&&(s=i.resourceTiming[this.id].slice(0)),e)return void this.fire(new t.j(e));const a={dataType:"source"};this._collectResourceTiming&&s&&s.length>0&&t.e(a,{resourceTiming:s}),this.fire(new t.k("data",Object.assign(Object.assign({},a),{sourceDataType:"metadata"}))),this.fire(new t.k("data",Object.assign(Object.assign({},a),{sourceDataType:"content"})));}));}loaded(){return 0===this._pendingLoads}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const s={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(i,s,((s,a)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):s?e(s):(t.loadVectorData(a,this.map.painter,"reloadTile"===i),e(null)))));}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0;}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id});}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id});}hasTransition(){return !1}}var O=t.Q([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class N extends t.E{constructor(e,i,s,a){super(),this.load=(e,i)=>{this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=h.getImage(this.map._requestManager.transformRequest(this.url,c.Image),((s,a)=>{this._request=null,this._loaded=!0,s?this.fire(new t.j(s)):a&&(this.image=a,e&&(this.coordinates=e),i&&i(),this._finishLoading());}));},this.prepare=()=>{if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,O.members)),this.boundsSegments||(this.boundsSegments=t.S.simpleSegment(0,0,4,2)),this.texture||(this.texture=new x(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let s=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,s=!0);}s&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));},this.serialize=()=>({type:"image",url:this.options.url,coordinates:this.coordinates}),this.id=e,this.dispatcher=s,this.coordinates=i.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(a),this.options=i;}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(t){this.map=t,this.load();}onRemove(){this._request&&(this._request.cancel(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.U.fromLngLat);this.tileID=function(e){let i=1/0,s=1/0,a=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t.x),s=Math.min(s,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y);const r=Math.max(a-i,o-s),n=Math.max(0,Math.floor(-Math.log(r)/Math.LN2)),l=Math.pow(2,n);return new t.W(n,Math.floor((i+a)/2*l),Math.floor((s+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;const s=i.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new t.V,this._boundsArray.emplaceBack(s[0].x,s[0].y,0,0),this._boundsArray.emplaceBack(s[1].x,s[1].y,t.N,0),this._boundsArray.emplaceBack(s[3].x,s[3].y,0,t.N),this._boundsArray.emplaceBack(s[2].x,s[2].y,t.N,t.N),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new t.k("data",{dataType:"source",sourceDataType:"content"})),this}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null));}hasTransition(){return !1}}class U extends N{constructor(e,i,s,a){super(e,i,s,a),this.load=()=>{this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,c.Source).url);t.X(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.j(e)):i&&(this.video=i,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading());}));},this.prepare=()=>{if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,O.members)),this.boundsSegments||(this.boundsSegments=t.S.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new x(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let s=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,s=!0);}s&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));},this.serialize=()=>({type:"video",urls:this.urls,coordinates:this.coordinates}),this.roundZoom=!0,this.type="video",this.options=i;}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.j(new t.Y(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}hasTransition(){return this.video&&!this.video.paused}}class Z extends N{constructor(e,i,s,a){super(e,i,s,a),this.load=()=>{this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());},this.prepare=()=>{let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,s=i.gl;this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,O.members)),this.boundsSegments||(this.boundsSegments=t.S.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new x(i,this.canvas,s.RGBA,{premultiply:!0});let a=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,a=!0);}a&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));},this.serialize=()=>({type:"canvas",coordinates:this.coordinates}),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.j(new t.Y(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.j(new t.Y(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.j(new t.Y(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.j(new t.Y(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.j(new t.Y(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of [this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return !0;return !1}}const G={},j=t=>{switch(t){case"geojson":return B;case"image":return N;case"raster":return k;case"raster-dem":return F;case"vector":return R;case"video":return U;case"canvas":return Z}return G[t]};function V(e,i){const s=t.Z();return t.$(s,s,[1,1,0]),t.a0(s,s,[.5*e.width,.5*e.height,1]),t.a1(s,s,e.calculatePosMatrix(i.toUnwrapped()))}function q(t,e,i,s,a,o){const r=function(t,e,i){if(t)for(const s of t){const t=e[s];if(t&&t.source===i&&"fill-extrusion"===t.type)return !0}else for(const t in e){const s=e[t];if(s.source===i&&"fill-extrusion"===s.type)return !0}return !1}(a&&a.layers,e,t.id),n=o.maxPitchScaleFactor(),l=t.tilesIn(s,n,r);l.sort($);const h=[];for(const s of l)h.push({wrappedTileID:s.tileID.wrapped().key,queryResults:s.tile.queryRenderedFeatures(e,i,t._state,s.queryGeometry,s.cameraQueryGeometry,s.scale,a,o,n,V(t.transform,s.tileID))});const c=function(t){const e={},i={};for(const s of t){const t=s.queryResults,a=s.wrappedTileID,o=i[a]=i[a]||{};for(const i in t){const s=t[i],a=o[i]=o[i]||{},r=e[i]=e[i]||[];for(const t of s)a[t.featureIndex]||(a[t.featureIndex]=!0,r.push(t));}}return e}(h);for(const e in c)c[e].forEach((e=>{const i=e.feature,s=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=s;}));return c}function $(t,e){const i=t.tileID,s=e.tileID;return i.overscaledZ-s.overscaledZ||i.canonical.y-s.canonical.y||i.wrap-s.wrap||i.canonical.x-s.canonical.x}class W{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a2(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){s.layers=t,s.stateDependentLayerIds&&(s.stateDependentLayers=s.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=s;}}return i}(e.buckets,i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a4){if(this.hasSymbolBuckets=!0,!s)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a4&&i.hasRTLText){this.hasRTLText=!0,t.a5();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a3;}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t);}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new x(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new x(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null);}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture);}queryRenderedFeatures(t,e,i,s,a,o,r,n,l,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:s,cameraQueryGeometry:a,scale:o,tileSize:this.tileSize,pixelPosMatrix:h,transform:n,params:r,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(e,i){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const a=s.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",r=a._geojsonTileLayer||a[o];if(!r)return;const n=t.a6(i&&i.filter),{z:l,x:h,y:c}=this.tileID.canonical,u={z:l,x:h,y:c};for(let i=0;it)e=!1;else if(i)if(this.expirationTime{this.remove(t,a);}),i)),this.data[s].push(a),this.order.push(s),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,s=void 0===e?0:this.data[i].indexOf(e),a=this.data[i][s];return this.data[i].splice(s,1),a.timeout&&clearTimeout(a.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}filter(t){const e=[];for(const i in this.data)for(const s of this.data[i])t(s.value)||e.push(s);for(const t of e)this.remove(t.value.tileID,t);}}class X{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,s){const a=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][a]=this.stateChanges[e][a]||{},t.e(this.stateChanges[e][a],s),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==a&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][a]){this.deletedStates[e][a]={};for(const t in this.state[e][a])s[t]||(this.deletedStates[e][a][t]=null);}else for(const t in s)this.deletedStates[e]&&this.deletedStates[e][a]&&null===this.deletedStates[e][a][t]&&delete this.deletedStates[e][a][t];}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const s=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][s]&&(this.deletedStates[t][s]=this.deletedStates[t][s]||{},this.deletedStates[t][s][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][s])for(i in this.deletedStates[t][s]={},this.stateChanges[t][s])this.deletedStates[t][s][i]=null;else this.deletedStates[t][s]=null;else this.deletedStates[t]=null;}getState(e,i){const s=String(i),a=t.e({},(this.state[e]||{})[s],(this.stateChanges[e]||{})[s]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete a[e];}return a}initializeTileState(t,e){t.setFeatureState(this.state,e);}coalesceChanges(e,i){const s={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const s in this.stateChanges[e])this.state[e][s]||(this.state[e][s]={}),t.e(this.state[e][s],this.stateChanges[e][s]),i[s]=this.state[e][s];s[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}s[e]=s[e]||{},t.e(s[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(s).length)for(const t in e)e[t].setFeatureState(s,i);}}class K extends t.E{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);})),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((t,e,i,s)=>{const a=new(j(e.type))(t,e,i,s);if(a.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${a.id}`);return a})(t,e,i,this),this._tiles={},this._cache=new H(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new X,this._didEmitContent=!1,this._updated=!1;}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t);}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(t,e){return this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(e){this._source.abortTile&&this._source.abortTile(e,(()=>{})),this._source.fire(new t.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(Q).map((t=>t.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const s=e.tileID,a=i.tileID,o=new t.P(s.canonical.x,s.canonical.y)._rotate(this.transform.angle),r=new t.P(a.canonical.x,a.canonical.y)._rotate(this.transform.angle);return s.overscaledZ-a.overscaledZ||r.y-o.y||r.x-o.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Q).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return !!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading");}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)));}_tileLoaded(e,i,s,a){if(a)return e.state="errored",void(404!==a.status?this._source.fire(new t.j(a,{tile:e})):this.update(this.transform,this.terrain));e.timeAdded=t.h.now(),"expired"===s&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.k("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(t){const e=this.getRenderableIds();for(let s=0;s1||(Math.abs(i)>1&&(1===Math.abs(i+a)?i+=a:1===Math.abs(i-a)&&(i-=a)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,s),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)));}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,s){for(const a in this._tiles){let o=this._tiles[a];if(s[a]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let r=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(r=t);}let n=r;for(;n.overscaledZ>e;)if(n=n.scaledTo(n.overscaledZ-1),t[n.key]){s[r.key]=r;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),s=this._getLoadedTile(e);if(s)return s}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,s=Math.ceil(e.height/this._source.tileSize)+1,a=Math.floor(i*s*(null===this._maxTileCacheZoomLevels?t.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(o);}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const s=this._tiles[i];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),t[s.tileID.key]=s;}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t]);}}update(e,i){if(this.transform=e,this.terrain=i,!this._sourceLoaded||this._paused)return;let s;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.O(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(s=e.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i}),this._source.hasTile&&(s=s.filter((t=>this._source.hasTile(t))))):s=[];const a=e.coveringZoomLevel(this._source),o=Math.max(a-K.maxOverzooming,this._source.minzoom),r=Math.max(a+K.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of s)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const s=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[s.key]=s;}s=s.concat(Object.values(t));}const n=0===s.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(s,a);if(Y(this._source.type)){const e={},n={},h=Object.keys(l),c=t.h.now();for(const t of h){const i=l[t],s=this._tiles[t];if(!s||0!==s.fadeEndTime&&s.fadeEndTime<=c)continue;const a=this.findLoadedParent(i,o);a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),n[t]=i;}this._retainLoadedChildren(n,a,r,l);for(const t in e)l[t]||(this._coveredTiles[t]=!0,l[t]=e[t]);if(i){const t={},e={};for(const i of s)this._tiles[i.key].hasData()?t[i.key]=i:e[i.key]=i;for(const i in e){const s=e[i].children(this._source.maxzoom);this._tiles[s[0].key]&&this._tiles[s[1].key]&&this._tiles[s[2].key]&&this._tiles[s[3].key]&&(t[s[0].key]=l[s[0].key]=s[0],t[s[1].key]=l[s[1].key]=s[1],t[s[2].key]=l[s[2].key]=s[2],t[s[3].key]=l[s[3].key]=s[3],delete e[i]);}for(const i in e){const s=this.findLoadedParent(e[i],this._source.minzoom);if(s){t[s.tileID.key]=l[s.tileID.key]=s.tileID;for(const e in t)t[e].isChildOf(s.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}for(const t in l)this._tiles[t].clearFadeHold();const h=t.ab(this._tiles,l);for(const t of h){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t);}this._updateLoadedParentTileCache();}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t);}_updateRetainedTiles(t,e){const i={},s={},a=Math.max(e-K.maxOverzooming,this._source.minzoom),o=Math.max(e+K.maxUnderzooming,this._source.minzoom),r={};for(const s of t){const t=this._addTile(s);i[s.key]=s,t.hasData()||ethis._source.maxzoom){const t=o.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){i[t.key]=t;continue}}else {const t=o.children(this._source.maxzoom);if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let r=t.wasRequested();for(let e=o.overscaledZ-1;e>=a;--e){const a=o.scaledTo(e);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&r&&(t=this._addTile(a)),t){const e=t.hasData();if((r||e)&&(i[a.key]=a),r=t.wasRequested(),e)break}}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,s=this._tiles[t].tileID;for(;s.overscaledZ>0;){if(s.key in this._loadedParentTiles){i=this._loadedParentTiles[s.key];break}e.push(s.key);const t=s.scaledTo(s.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;s=t;}for(const t of e)this._loadedParentTiles[t]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const s=i;return i||(i=new W(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,this._tileLoaded.bind(this,i,e.key,i.state))),i.uses++,this._tiles[e.key]=i,s||this._source.fire(new t.k("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t];}),i));}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset();}tilesIn(e,i,s){const a=[],o=this.transform;if(!o)return a;const r=s?o.getCameraQueryGeometry(e):e,n=e.map((t=>o.pointCoordinate(t,this.terrain))),l=r.map((t=>o.pointCoordinate(t,this.terrain))),h=this.getIds();let c=1/0,u=1/0,d=-1/0,_=-1/0;for(const t of l)c=Math.min(c,t.x),u=Math.min(u,t.y),d=Math.max(d,t.x),_=Math.max(_,t.y);for(let e=0;e=0&&f[1].y+m>=0){const t=n.map((t=>r.getTilePoint(t))),e=l.map((t=>r.getTilePoint(t)));a.push({tile:s,tileID:r,queryGeometry:t,cameraQueryGeometry:e,scale:p});}}return a}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return !0;if(Y(this._source.type)){const e=t.h.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i);}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i);}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const s=this._tiles[t];s&&s.setDependencies(e,i);}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)));}}function Q(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),s=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||s-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Y(t){return "raster"===t||"image"===t||"video"===t}K.maxOverzooming=10,K.maxUnderzooming=3;const J="mapboxgl_preloaded_worker_pool";class tt{constructor(){this.active={};}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[J]}numActive(){return Object.keys(this.active).length}}const et=Math.floor(t.h.hardwareConcurrency/2);let it;function st(){return it||(it=new tt),it}tt.workerCount=t.ac(globalThis)?Math.max(Math.min(et,3),1):1;class at{constructor(t,e){this.reset(t,e);}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t0?(a-r)/n:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function ot(t,e){let i=!0;return "always"===t||"never"!==t&&"never"!==e||(i=!1),i}class rt{constructor(t,e,i){const s=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||s<0||e>this.height)return [];const n=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=s){if(a)return [{key:null,x1:t,y1:e,x2:i,y2:s}];for(let t=0;t0}hitTestCircle(t,e,i,s,a){const o=t-i,r=t+i,n=e-i,l=e+i;if(r<0||o>this.width||l<0||n>this.height)return !1;const h=[];return this._forEachCell(o,n,r,l,this._queryCellCircle,h,{hitTest:!0,overlapMode:s,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},a),h.length>0}_queryCell(t,e,i,s,a,o,r,n){const{seenUids:l,hitTest:h,overlapMode:c}=r,u=this.boxCells[a];if(null!==u){const a=this.bboxes;for(const r of u)if(!l.box[r]){l.box[r]=!0;const u=4*r,d=this.boxKeys[r];if(t<=a[u+2]&&e<=a[u+3]&&i>=a[u+0]&&s>=a[u+1]&&(!n||n(d))&&(!h||!ot(c,d.overlapMode))&&(o.push({key:d,x1:a[u],y1:a[u+1],x2:a[u+2],y2:a[u+3]}),h))return !0}}const d=this.circleCells[a];if(null!==d){const a=this.circles;for(const r of d)if(!l.circle[r]){l.circle[r]=!0;const u=3*r,d=this.circleKeys[r];if(this._circleAndRectCollide(a[u],a[u+1],a[u+2],t,e,i,s)&&(!n||n(d))&&(!h||!ot(c,d.overlapMode))){const t=a[u],e=a[u+1],i=a[u+2];if(o.push({key:d,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),h)return !0}}}return !1}_queryCellCircle(t,e,i,s,a,o,r,n){const{circle:l,seenUids:h,overlapMode:c}=r,u=this.boxCells[a];if(null!==u){const t=this.bboxes;for(const e of u)if(!h.box[e]){h.box[e]=!0;const i=4*e,s=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!n||n(s))&&!ot(c,s.overlapMode))return o.push(!0),!0}}const d=this.circleCells[a];if(null!==d){const t=this.circles;for(const e of d)if(!h.circle[e]){h.circle[e]=!0;const i=3*e,s=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!n||n(s))&&!ot(c,s.overlapMode))return o.push(!0),!0}}}_forEachCell(t,e,i,s,a,o,r,n){const l=this._convertToXCellCoord(t),h=this._convertToYCellCoord(e),c=this._convertToXCellCoord(i),u=this._convertToYCellCoord(s);for(let d=l;d<=c;d++)for(let l=h;l<=u;l++)if(a.call(this,t,e,i,s,this.xCellCount*l+d,o,r,n))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,s,a,o){const r=s-t,n=a-e,l=i+o;return l*l>r*r+n*n}_circleAndRectCollide(t,e,i,s,a,o,r){const n=(o-s)/2,l=Math.abs(t-(s+n));if(l>n+i)return !1;const h=(r-a)/2,c=Math.abs(e-(a+h));if(c>h+i)return !1;if(l<=n||c<=h)return !0;const u=l-n,d=c-h;return u*u+d*d<=i*i}}function nt(e,i,s,a,o){const r=t.Z();return i?(t.a0(r,r,[1/o,1/o,1]),s||t.ae(r,r,a.angle)):t.a1(r,a.labelPlaneMatrix,e),r}function lt(e,i,s,a,o){if(i){const i=t.af(e);return t.a0(i,i,[o,o,1]),s||t.ae(i,i,-a.angle),i}return a.glCoordMatrix}function ht(e,i,s){let a;s?(a=[e.x,e.y,s(e.x,e.y),1],t.ag(a,a,i)):(a=[e.x,e.y,0,1],Tt(a,a,i));const o=a[3];return {point:new t.P(a[0]/o,a[1]/o),signedDistanceFromCamera:o}}function ct(t,e){return .5+t/e*.5}function ut(t,e){const i=t[0]/t[3],s=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&s>=-e[1]&&s<=e[1]}function dt(e,i,s,a,o,r,n,l,h,c){const u=a?e.textSizeData:e.iconSizeData,d=t.ah(u,s.transform.zoom),_=[256/s.width*2+1,256/s.height*2+1],p=a?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;p.clear();const m=e.lineVertexArray,f=a?e.text.placedSymbolArray:e.icon.placedSymbolArray,g=s.transform.width/s.transform.height;let v=!1;for(let a=0;aMath.abs(s.x-i.x)*a?{useVertical:!0}:(e===t.ai.vertical?i.ys.x)?{needsFlipping:!0}:null}function mt(e,i,s,a,o,r,n,l,h,c,u,d,_,p,m,f){const g=i/24,v=e.lineOffsetX*g,x=e.lineOffsetY*g;let y;if(e.numGlyphs>1){const t=e.glyphStartIndex+e.numGlyphs,i=e.lineStartIndex,o=e.lineStartIndex+e.lineLength,c=_t(g,l,v,x,s,u,d,e,h,r,_,m,f);if(!c)return {notEnoughRoom:!0};const b=ht(c.first.point,n,f).point,w=ht(c.last.point,n,f).point;if(a&&!s){const t=pt(e.writingMode,b,w,p);if(t)return t}y=[c.first];for(let a=e.glyphStartIndex+1;a0?r.point:ft(d,a,i,1,o,f),l=pt(e.writingMode,i,n,p);if(l)return l}const i=yt(g*l.getoffsetX(e.glyphStartIndex),v,x,s,u,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,h,r,_,m,f);if(!i)return {notEnoughRoom:!0};y=[i];}for(const e of y)t.ak(c,e.point,e.angle);return {}}function ft(t,e,i,s,a,o){const r=ht(t.add(t.sub(e)._unit()),a,o).point,n=i.sub(r);return i.add(n._mult(s/n.mag()))}function gt(e,i){const{projectionCache:s,lineVertexArray:a,labelPlaneMatrix:o,tileAnchorPoint:r,distanceFromAnchor:n,getElevation:l,previousVertex:h,direction:c,absOffsetX:u}=i;if(s.projections[e])return s.projections[e];const d=new t.P(a.getx(e),a.gety(e)),_=ht(d,o,l);if(_.signedDistanceFromCamera>0)return s.projections[e]=_.point,_.point;const p=e-c;return ft(0===n?r:new t.P(a.getx(p),a.gety(p)),d,h,u-n+1,o,l)}function vt(t,e,i){return t._unit()._perp()._mult(e*i)}function xt(e,i,s,a,o,r,n,l){const{projectionCache:h,direction:c}=l;if(h.offsets[e])return h.offsets[e];const u=s.add(i);if(e+c=o)return h.offsets[e]=u,u;const d=gt(e+c,l),_=vt(d.sub(s),n,c),p=s.add(_),m=d.add(_);return h.offsets[e]=t.al(r,u,p,m)||u,h.offsets[e]}function yt(t,e,i,s,a,o,r,n,l,h,c,u,d,_){const p=s?t-e:t+e;let m=p>0?1:-1,f=0;s&&(m*=-1,f=Math.PI),m<0&&(f+=Math.PI);let g,v,x=m>0?n+r:n+r+1,y=a,b=a,w=0,T=0;const I=Math.abs(p),E=[];let S;for(;w+T<=I;){if(x+=m,x=l)return null;w+=T,b=y,v=g;const t={projectionCache:u,lineVertexArray:h,labelPlaneMatrix:c,tileAnchorPoint:o,distanceFromAnchor:w,getElevation:_,previousVertex:b,direction:m,absOffsetX:I};if(y=gt(x,t),0===i)E.push(b),S=y.sub(b);else {let e;const s=y.sub(b);e=0===s.mag()?vt(gt(x+m,t).sub(y),i,m):vt(s,i,m),v||(v=b.add(e)),g=xt(x,e,y,n,l,v,i,t),E.push(v),S=g.sub(v);}T=S.mag();}const C=S._mult((I-w)/T)._add(v||b),P=f+Math.atan2(y.y-b.y,y.x-b.x);return E.push(C),{point:C,angle:d?P:0,path:E}}const bt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function wt(t,e){for(let i=0;i=1;t--)c.push(r.path[t]);for(let t=1;tht(t,l,p)));c=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point));}let g=[];if(c.length>0){const e=c[0].clone(),i=c[0].clone();for(let t=1;t=s.x&&i.x<=a.x&&e.y>=s.y&&i.y<=a.y?[c]:i.xa.x||i.ya.y?[]:t.am([c],s.x,s.y,a.x,a.y);}for(const t of g){o.reset(t,.25*i);let s=0;s=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t=this.screenRightBoundary||sthis.screenBottomBoundary}isInsideGrid(t,e,i,s){return i>=0&&t=0&&et.collisionGroupID===e};}return this.collisionGroups[t]}}function At(e,i,s,a,o){const{horizontalAlign:r,verticalAlign:n}=t.au(e);return new t.P(-(r-.5)*i+a[0]*o,-(n-.5)*s+a[1]*o)}function Rt(e,i,s,a,o,r){const{x1:n,x2:l,y1:h,y2:c,anchorPointX:u,anchorPointY:d}=e,_=new t.P(i,s);return a&&_._rotate(o?r:-r),{x1:n+_.x,y1:h+_.y,x2:l+_.x,y2:c+_.y,anchorPointX:u,anchorPointY:d}}class kt{constructor(t,e,i,s,a){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new Et(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Lt(s),this.collisionCircleArrays={},this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(e,i,s,a){const o=s.getBucket(i),r=s.latestFeatureIndex;if(!o||!r||i.id!==o.layerIds[0])return;const n=s.collisionBoxArray,l=o.layers[0].layout,h=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),c=s.tileSize/t.N,u=this.transform.calculatePosMatrix(s.tileID.toUnwrapped()),d="map"===l.get("text-pitch-alignment"),_="map"===l.get("text-rotation-alignment"),p=St(s,1,this.transform.zoom),m=nt(u,d,_,this.transform,p);let f=null;if(d){const e=lt(u,d,_,this.transform,p);f=t.a1([],this.transform.labelPlaneMatrix,e);}this.retainedQueryData[o.bucketInstanceId]=new zt(o.bucketInstanceId,r,o.sourceLayerIndex,o.index,s.tileID);const g={bucket:o,layout:l,posMatrix:u,textLabelPlaneMatrix:m,labelToScreenMatrix:f,scale:h,textPixelRatio:c,holdingForFade:s.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ah(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(a)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:s,symbolInstanceEnd:a}=t;e.push({sortKey:i,symbolInstanceStart:s,symbolInstanceEnd:a,parameters:g});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:g});}attemptAnchorPlacement(e,i,s,a,o,r,n,l,h,c,u,d,_,p,m,f){const g=t.aq[e.textAnchor],v=[e.textOffset0,e.textOffset1],x=At(g,s,a,v,o),y=this.collisionIndex.placeCollisionBox(Rt(i,x.x,x.y,r,n,this.transform.angle),u,l,h,c.predicate,f);if((!m||0!==this.collisionIndex.placeCollisionBox(Rt(m,x.x,x.y,r,n,this.transform.angle),u,l,h,c.predicate,f).box.length)&&y.box.length>0){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[d.crossTileID]&&this.prevPlacement.placements[d.crossTileID]&&this.prevPlacement.placements[d.crossTileID].text&&(t=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:v,width:s,height:a,anchor:g,textBoxScale:o,prevAnchor:t},this.markUsedJustification(_,g,d,p),_.allowVerticalPlacement&&(this.markUsedOrientation(_,p,d),this.placedOrientations[d.crossTileID]=p),{shift:x,placedGlyphBoxes:y}}}placeLayerBucketPart(e,i,s){const{bucket:a,layout:o,posMatrix:r,textLabelPlaneMatrix:n,labelToScreenMatrix:l,textPixelRatio:h,holdingForFade:c,collisionBoxArray:u,partiallyEvaluatedTextSize:d,collisionGroup:_}=e.parameters,p=o.get("text-optional"),m=o.get("icon-optional"),f=t.ar(o,"text-overlap","text-allow-overlap"),g="always"===f,v=t.ar(o,"icon-overlap","icon-allow-overlap"),x="always"===v,y="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),I=g&&(x||!a.hasIconData()||m),E=x&&(g||!a.hasTextData()||p);!a.collisionArrays&&u&&a.deserializeCollisionBoxes(u);const S=this.retainedQueryData[a.bucketInstanceId].tileID,C=this.terrain?(t,e)=>this.terrain.getElevation(S,t,e):null,P=(e,u)=>{var x,T;if(i[e.crossTileID])return;if(c)return void(this.placements[e.crossTileID]=new Dt(!1,!1,!1));let S=!1,P=!1,D=!0,M=null,z={box:null,offscreen:null},L={box:null,offscreen:null},A=null,R=null,k=null,F=0,B=0,O=0;u.textFeatureIndex?F=u.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),u.verticalTextFeatureIndex&&(B=u.verticalTextFeatureIndex);const N=u.textBox;if(N){const i=i=>{let s=t.ai.horizontal;if(a.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,s=t,this.markUsedOrientation(a,s,e));}return s},s=(i,s)=>{if(a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&u.verticalTextBox){for(const e of a.writingModes)if(e===t.ai.vertical?(z=s(),L=z):z=i(),z&&z.box&&z.box.length)break}else z=i();},o=e.textAnchorOffsetStartIndex,n=e.textAnchorOffsetEndIndex;if(n===o){const o=(t,i)=>{const s=this.collisionIndex.placeCollisionBox(t,f,h,r,_.predicate,C);return s&&s.box&&s.box.length&&(this.markUsedOrientation(a,i,e),this.placedOrientations[e.crossTileID]=i),s};s((()=>o(N,t.ai.horizontal)),(()=>{const i=u.verticalTextBox;return a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?o(i,t.ai.vertical):{box:null,offscreen:null}})),i(z&&z.box&&z.box.length);}else {let l=t.aq[null===(T=null===(x=this.prevPlacement)||void 0===x?void 0:x.variableOffsets[e.crossTileID])||void 0===T?void 0:T.anchor];const c=(t,i,s)=>{const c=t.x2-t.x1,u=t.y2-t.y1,d=e.textBoxScale,p=w&&"never"===v?i:null;let m={box:[],offscreen:!1},g="never"===f?1:2,x="never";l&&g++;for(let i=0;ic(N,u.iconBox,t.ai.horizontal)),(()=>{const i=u.verticalTextBox;return a.allowVerticalPlacement&&!(z&&z.box&&z.box.length)&&e.numVerticalGlyphVertices>0&&i?c(i,u.verticalIconBox,t.ai.vertical):{box:null,offscreen:null}})),z&&(S=z.box,D=z.offscreen);const d=i(z&&z.box);if(!S&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(a,t.anchor,e,d));}}}if(A=z,S=A&&A.box&&A.box.length>0,D=A&&A.offscreen,e.useRuntimeCollisionCircles){const i=a.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),h=t.aj(a.textSizeData,d,i),c=o.get("text-padding");R=this.collisionIndex.placeCollisionCircles(f,i,a.lineVertexArray,a.glyphOffsetArray,h,r,n,l,s,b,_.predicate,e.collisionCircleDiameter,c,C),R.circles.length&&R.collisionDetected&&!s&&t.w("Collisions detected, but collision boxes are not shown"),S=g||R.circles.length>0&&!R.collisionDetected,D=D&&R.offscreen;}if(u.iconFeatureIndex&&(O=u.iconFeatureIndex),u.iconBox){const t=t=>{const e=w&&M?Rt(t,M.x,M.y,y,b,this.transform.angle):t;return this.collisionIndex.placeCollisionBox(e,v,h,r,_.predicate,C)};L&&L.box&&L.box.length&&u.verticalIconBox?(k=t(u.verticalIconBox),P=k.box.length>0):(k=t(u.iconBox),P=k.box.length>0),D=D&&k.offscreen;}const U=p||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Z=m||0===e.numIconVertices;if(U||Z?Z?U||(P=P&&S):S=P&&S:P=S=P&&S,S&&A&&A.box&&this.collisionIndex.insertCollisionBox(A.box,f,o.get("text-ignore-placement"),a.bucketInstanceId,L&&L.box&&B?B:F,_.ID),P&&k&&this.collisionIndex.insertCollisionBox(k.box,v,o.get("icon-ignore-placement"),a.bucketInstanceId,O,_.ID),R&&(S&&this.collisionIndex.insertCollisionCircles(R.circles,f,o.get("text-ignore-placement"),a.bucketInstanceId,F,_.ID),s)){const t=a.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Mt);for(let t=0;t=0;--e){const i=t[e];P(a.symbolInstances.get(i),a.collisionArrays[i]);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:s.crossTileID);}markUsedOrientation(e,i,s){const a=i===t.ai.horizontal||i===t.ai.horizontalOnly?i:0,o=i===t.ai.vertical?i:0,r=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex];for(const t of r)e.text.placedSymbolArray.get(t).placedOrientation=a;s.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).placedOrientation=o);}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const s=e?e.symbolFadeChange(t):1,a=e?e.opacities:{},o=e?e.variableOffsets:{},r=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=a[t];o?(this.opacities[t]=new Pt(o,s,e.text,e.icon),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new Pt(null,s,e.text,e.icon,e.skipFade),i=i||e.text||e.icon);}for(const t in a){const e=a[t];if(!this.opacities[t]){const a=new Pt(e,s,!1,!1);a.isHidden()||(this.opacities[t]=a,i=i||e.text.placed||e.icon.placed);}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in r)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=r[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t);}updateLayerOpacities(t,e){const i={};for(const s of e){const e=s.getBucket(t);e&&s.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,s.collisionBoxArray);}}updateBucketOpacities(e,i,s){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const a=e.layers[0],o=a.layout,r=new Pt(null,0,!1,!1,!0),n=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),c="map"===o.get("text-rotation-alignment"),u="map"===o.get("text-pitch-alignment"),d="none"!==o.get("icon-text-fit"),_=new Pt(null,0,n&&(l||!e.hasIconData()||o.get("icon-optional")),l&&(n||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&s&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(s);const p=(t,e,i)=>{for(let s=0;s0,g=this.placedOrientations[a.crossTileID],v=g===t.ai.vertical,x=g===t.ai.horizontal||g===t.ai.horizontalOnly;if(o>0||n>0){const t=Vt(m.text);p(e.text,o,v?qt:t),p(e.text,n,x?qt:t);const i=m.text.isHidden();[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||v?1:0);})),a.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const s=this.variableOffsets[a.crossTileID];s&&this.markUsedJustification(e,s.anchor,a,g);const r=this.placedOrientations[a.crossTileID];r&&(this.markUsedJustification(e,"left",a,r),this.markUsedOrientation(e,r,a));}if(f){const t=Vt(m.icon),i=!(d&&a.verticalPlacedIconSymbolIndex&&v);a.placedIconSymbolIndex>=0&&(p(e.icon,a.numIconVertices,i?t:qt),e.icon.placedSymbolArray.get(a.placedIconSymbolIndex).hidden=m.icon.isHidden()),a.verticalPlacedIconSymbolIndex>=0&&(p(e.icon,a.numVerticalIconVertices,i?qt:t),e.icon.placedSymbolArray.get(a.verticalPlacedIconSymbolIndex).hidden=m.icon.isHidden());}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[s];if(i){let s=new t.P(0,0);if(i.textBox||i.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(s=At(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),c&&s._rotate(u?this.transform.angle:-this.transform.angle)):t=!1;}i.textBox&&Ft(e.textCollisionBox.collisionVertexArray,m.text.placed,!t||v,s.x,s.y),i.verticalTextBox&&Ft(e.textCollisionBox.collisionVertexArray,m.text.placed,!t||x,s.x,s.y);}const a=Boolean(!x&&i.verticalIconBox);i.iconBox&&Ft(e.iconCollisionBox.collisionVertexArray,m.icon.placed,a,d?s.x:0,d?s.y:0),i.verticalIconBox&&Ft(e.iconCollisionBox.collisionVertexArray,m.icon.placed,!a,d?s.x:0,d?s.y:0);}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);if(e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId];}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0;}}function Ft(t,e,i,s,a){t.emplaceBack(e?1:0,i?1:0,s||0,a||0),t.emplaceBack(e?1:0,i?1:0,s||0,a||0),t.emplaceBack(e?1:0,i?1:0,s||0,a||0),t.emplaceBack(e?1:0,i?1:0,s||0,a||0);}const Bt=Math.pow(2,25),Ot=Math.pow(2,24),Nt=Math.pow(2,17),Ut=Math.pow(2,16),Zt=Math.pow(2,9),Gt=Math.pow(2,8),jt=Math.pow(2,1);function Vt(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Bt+e*Ot+i*Nt+e*Ut+i*Zt+e*Gt+i*jt+e}const qt=0;class $t{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(t,e,i,s,a){const o=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex!this._forceFullPlacement&&t.h.now()-a>2;for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=a)&&(!t.maxzoom||t.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new $t(t)),this._inProgressLayer.continuePlacement(s[t.source],this.placement,this._showCollisionBoxes,t,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(t){return this.placement.commit(t),this.placement}}const Ht=512/t.N/2;class Xt{constructor(e,i,s){this.tileID=e,this.bucketInstanceId=s,this._symbolsByKey={};const a=new Map;for(let t=0;t({x:Math.floor(t.anchorX*Ht),y:Math.floor(t.anchorY*Ht)}))),crossTileIDs:i.map((t=>t.crossTileID))};if(s.positions.length>128){const e=new t.av(s.positions.length,16,Uint16Array);for(const{x:t,y:i}of s.positions)e.add(t,i);e.finish(),delete s.positions,s.index=e;}this._symbolsByKey[e]=s;}}getScaledCoordinates(e,i){const{x:s,y:a,z:o}=this.tileID.canonical,{x:r,y:n,z:l}=i.canonical,h=Ht/Math.pow(2,l-o),c=(n*t.N+e.anchorY)*h,u=a*t.N*Ht;return {x:Math.floor((r*t.N+e.anchorX)*h-s*t.N*Ht),y:Math.floor(c-u)}}findMatches(t,e,i){const s=this.tileID.canonical.zt))}}class Kt{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class Qt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],s={};for(const t in i){const a=i[t];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+e),s[a.tileID.key]=a;}this.indexes[t]=s;}this.lng=t;}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key]);}for(let t=0;tt.overscaledZ)for(const i in a){const o=a[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,s);}else {const o=a[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,s);}}for(let t=0;t{e[t]=!0;}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t];}}const Jt=(e,i)=>t.x(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),te=t.F(t.ax,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),ee=t.F(t.ax,["setCenter","setZoom","setBearing","setPitch"]),ie=t.aw();class se extends t.E{constructor(e,i={}){super(),this.map=e,this.dispatcher=new M(st(),this,e._getMapId()),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new E(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new D(256,512),this.crossTileSymbolIndex=new Yt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.az());const s=this;this._rtlTextPluginCallback=se.registerForPluginStateChange((e=>{s.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.aA(e),i&&i.every((t=>t)))for(const t in s.sourceCaches){const e=s.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||s.sourceCaches[t].reload();}}));})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e);}}));}loadURL(e,i={},s){this.fire(new t.k("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const a=this.map._requestManager.transformRequest(e,c.Style);this._request=t.f(a,((e,a)=>{this._request=null,e?this.fire(new t.j(e)):a&&this._load(a,i,s);}));}loadJSON(e,i={},s){this.fire(new t.k("dataloading",{dataType:"style"})),this._request=t.h.frame((()=>{this._request=null,i.validate=!1!==i.validate,this._load(e,i,s);}));}loadEmpty(){this.fire(new t.k("dataloading",{dataType:"style"})),this._load(ie,{validate:!1});}_load(e,i,s){var a;const o=i.transformStyle?i.transformStyle(s,e):e;if(!i.validate||!Jt(this,t.y(o))){this._loaded=!0,this.stylesheet=o;for(const t in o.sources)this.addSource(t,o.sources[t],{validate:!1});o.sprite?this._loadSprite(o.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(o.glyphs),this._createLayers(),this.light=new P(this.stylesheet.light),this.map.setTerrain(null!==(a=this.stylesheet.terrain)&&void 0!==a?a:null),this.fire(new t.k("data",{dataType:"style"})),this.fire(new t.k("style.load"));}}_createLayers(){const e=t.aB(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",e),this._order=e.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.aC(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,s=void 0){this.imageManager.setLoaded(!1),this._spriteRequest=function(e,i,s,a){const o=g(e),r=o.length,n=s>1?"@2x":"",l={},u={},d={};for(const{id:e,url:s}of o){const o=i.transformRequest(i.normalizeSpriteURL(s,n,".json"),c.SpriteJSON),_=`${e}_${o.url}`;l[_]=t.f(o,((t,i)=>{delete l[_],u[e]=i,v(a,u,d,t,r);}));const p=i.transformRequest(i.normalizeSpriteURL(s,n,".png"),c.SpriteImage),m=`${e}_${p.url}`;l[m]=h.getImage(p,((t,i)=>{delete l[m],d[e]=i,v(a,u,d,t,r);}));}return {cancel(){for(const t of Object.values(l))t.cancel();}}}(e,this.map._requestManager,this.map.getPixelRatio(),((e,a)=>{if(this._spriteRequest=null,e)this.fire(new t.j(e));else if(a)for(const t in a){this._spritesImagesIds[t]=[];const e=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in a))):[];for(const t of e)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const e in a[t]){const s="default"===t?e:`${t}:${e}`;this._spritesImagesIds[t].push(s),s in this.imageManager.images?this.imageManager.updateImage(s,a[t][e],!1):this.imageManager.addImage(s,a[t][e]),i&&(this._changedImages[s]=!0);}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.k("data",{dataType:"style"})),s&&s(e);}));}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const s=e.sourceLayer;if(!s)return;const a=i.getSource();("geojson"===a.type||a.vectorLayerIds&&-1===a.vectorLayerIds.indexOf(s))&&this.fire(new t.j(new Error(`Source layer "${s}" does not exist on source "${a.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(t){const e=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e);const i=[];for(const s of t)e[s]&&i.push(e[s]);return i}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize());}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return !0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return !0;for(const t in this._layers)if(this._layers[t].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else {if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this._resetUpdates();}const s={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];s[t]=e.used,e.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in s){const i=this.sourceCaches[e];s[e]!==i.used&&i.fire(new t.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.z=e.zoom,i&&this.fire(new t.k("data",{dataType:"style"}));}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(t),removedIds:e});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){this._checkLoaded();const s=this.serialize();if(e=i.transformStyle?i.transformStyle(s,e):e,Jt(this,t.y(e)))return !1;(e=t.aD(e)).layers=t.aB(e.layers);const a=t.aE(s,e).filter((t=>!(t.command in ee)));if(0===a.length)return !1;const o=a.filter((t=>!(t.command in te)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((t=>t.command)).join(", ")}.`);for(const t of a)"setTransition"!==t.command&&this[t.command].apply(this,t.args);return this.stylesheet=e,this._serializedLayers=null,!0}addImage(e,i){if(this.getImage(e))return this.fire(new t.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(t,e){this.imageManager.updateImage(t,e);}getImage(t){return this.imageManager.getImage(t)}removeImage(e){if(!this.getImage(e))return this.fire(new t.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,s={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.y.source,`sources.${e}`,i,null,s))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const a=this.sourceCaches[e]=new K(e,i,this.dispatcher);a.style=this,a.setEventedParent(this,(()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:e}))),a.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.j(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0;}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(e,i,s={}){this._checkLoaded();const a=e.id;if(this.getLayer(a))return void this.fire(new t.j(new Error(`Layer "${a}" already exists on this map.`)));let o;if("custom"===e.type){if(Jt(this,t.aF(e)))return;o=t.aC(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(a,e.source),e=t.aD(e),e=t.e(e,{source:a})),this._validate(t.y.layer,`layers.${a}`,e,{arrayIndex:-1},s))return;o=t.aC(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:a}});}const r=i?this._order.indexOf(i):this._order.length;if(i&&-1===r)this.fire(new t.j(new Error(`Cannot add layer "${a}" before non-existing layer "${i}".`)));else {if(this._order.splice(r,0,a),this._layerOrderChanged=!0,this._layers[a]=o,this._removedLayers[a]&&o.source&&"custom"!==o.type){const t=this._removedLayers[a];delete this._removedLayers[a],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause());}this._updateLayer(o),o.onAdd&&o.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const s=this._order.indexOf(e);this._order.splice(s,1);const a=i?this._order.indexOf(i):this._order.length;i&&-1===a?this.fire(new t.j(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(a,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.j(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const s=this._order.indexOf(e);this._order.splice(s,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(t){return this._layers[t]}getLayersOrder(){return [...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(e,i,s){this._checkLoaded();const a=this.getLayer(e);a?a.minzoom===i&&a.maxzoom===s||(null!=i&&(a.minzoom=i),null!=s&&(a.maxzoom=s),this._updateLayer(a)):this.fire(new t.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,s={}){this._checkLoaded();const a=this.getLayer(e);if(a){if(!t.aG(a.filter,i))return null==i?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(t.y.filter,`layers.${a.id}.filter`,i,null,s)||(a.filter=t.aD(i),this._updateLayer(a)))}else this.fire(new t.j(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.aD(this.getLayer(e).filter)}setLayoutProperty(e,i,s,a={}){this._checkLoaded();const o=this.getLayer(e);o?t.aG(o.getLayoutProperty(i),s)||(o.setLayoutProperty(i,s,a),this._updateLayer(o)):this.fire(new t.j(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const s=this.getLayer(e);if(s)return s.getLayoutProperty(i);this.fire(new t.j(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,s,a={}){this._checkLoaded();const o=this.getLayer(e);o?t.aG(o.getPaintProperty(i),s)||(o.setPaintProperty(i,s,a)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.j(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const s=e.source,a=e.sourceLayer,o=this.sourceCaches[s];if(void 0===o)return void this.fire(new t.j(new Error(`The source '${s}' does not exist in the map's style.`)));const r=o.getSource().type;"geojson"===r&&a?this.fire(new t.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==r||a?(void 0===e.id&&this.fire(new t.j(new Error("The feature id parameter must be provided."))),o.setFeatureState(a,e.id,i)):this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const s=e.source,a=this.sourceCaches[s];if(void 0===a)return void this.fire(new t.j(new Error(`The source '${s}' does not exist in the map's style.`)));const o=a.getSource().type,r="vector"===o?e.sourceLayer:void 0;"vector"!==o||r?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.j(new Error("A feature id is required to remove its specific state property."))):a.removeFeatureState(r,e.id,i):this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,s=e.sourceLayer,a=this.sourceCaches[i];if(void 0!==a)return "vector"!==a.getSource().type||s?(void 0===e.id&&this.fire(new t.j(new Error("The feature id parameter must be provided."))),a.getFeatureState(s,e.id)):void this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.j(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.aH(this.sourceCaches,(t=>t.serialize())),i=this._serializeByIds(this._order),s=this.map.getTerrain()||void 0,a=this.stylesheet;return t.aI({version:a.version,name:a.name,metadata:a.metadata,light:a.light,center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,sprite:a.sprite,glyphs:a.glyphs,transition:a.transition,sources:e,layers:i,terrain:s},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},s=[];for(let a=this._order.length-1;a>=0;a--){const o=this._order[a];if(e(o)){i[o]=a;for(const e of t){const t=e[o];if(t)for(const e of t)s.push(e);}}}s.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const a=[];for(let o=this._order.length-1;o>=0;o--){const r=this._order[o];if(e(r))for(let t=s.length-1;t>=0;t--){const e=s[t].feature;if(i[e.layer.id]{const s=i.featureSortOrder;if(s){const i=s.indexOf(t.featureIndex);return s.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of a)e.push(t);}}for(const e in n)n[e].forEach((s=>{const a=s.feature,o=i[t[e].source].getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=o;}));return n}(this._layers,r,this.sourceCaches,e,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.y.filter,"querySourceFeatures.filter",i.filter,null,i);const s=this.sourceCaches[e];return s?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),s=[],a={};for(let t=0;t{G[t]=e;})(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const s=this.light.getLight();let a=!1;for(const i in e)if(!t.aG(e[i],s[i])){a=!0;break}if(!a)return;const o={now:t.h.now(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(o);}_validate(e,i,s,a,o={}){return (!o||!1!==o.validate)&&Jt(this,e.call(t.y,t.e({key:i,style:this.serialize(),value:s,styleSpec:t.v},a)))}_remove(e=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.aJ.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map);}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(e);}_clearSource(t){this.sourceCaches[t].clearTiles();}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload();}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.map.terrain);}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t);}_updatePlacement(e,i,s,a,o=!1){let r=!1,n=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this.sourceCaches[i.source];l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)));}const s=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);r=r||s;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===s)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.h.now(),e.zoom))&&(this.pauseablePlacement=new Wt(e,this.map.terrain,this._order,o,i,s,a,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.h.now()),n=!0),r&&this.pauseablePlacement.placement.setStale()),n||r)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.h.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles();}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const s=this.sourceCaches[e.source];s&&s.setDependencies(e.tileID.key,e.type,e.icons);}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i);const s=this.sourceCaches[e.source];s&&s.setDependencies(e.tileID.key,e.type,[""]);}getResource(e,i,s){return t.m(i,s)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.y.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,s={},a){this._checkLoaded();const o=[{id:e,url:i}],r=[...g(this.stylesheet.sprite),...o];this._validate(t.y.sprite,"sprite",r,null,s)||(this.stylesheet.sprite=r,this._loadSprite(o,!0,a));}removeSprite(e){this._checkLoaded();const i=g(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}else this.fire(new t.j(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return g(this.stylesheet.sprite)}setSprite(e,i={},s){this._checkLoaded(),e&&this._validate(t.y.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,s):(this._unloadSprite(),s&&s(null)));}}se.registerForPluginStateChange=t.aK;var ae=t.Q([{name:"a_pos",type:"Int16",components:2}]),oe="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const re={prelude:ne("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:ne("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:ne("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:ne("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:ne("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ne("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}"),heatmapTexture:ne("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ne("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ne("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ne("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:ne("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),fillOutline:ne("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillOutlinePattern:ne("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillPattern:ne("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:ne("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:ne("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:ne("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ne("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:ne("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:ne("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:ne("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:ne("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:ne("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:ne("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:ne("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:ne("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:ne("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",oe),terrainDepth:ne("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",oe),terrainCoords:ne("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",oe)};function ne(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=e.match(/attribute ([\w]+) ([\w]+)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),r=o?o.concat(a):a,n={};return {fragmentSource:t=t.replace(i,((t,e,i,s,a)=>(n[a]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${a}\nvarying ${i} ${s} ${a};\n#else\nuniform ${i} ${s} u_${a};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${a}\n ${i} ${s} ${a} = u_${a};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,s,a)=>{const o="float"===s?"vec2":"vec4",r=a.match(/color/)?"color":o;return n[a]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nattribute ${i} ${o} a_${a};\nvarying ${i} ${s} ${a};\n#else\nuniform ${i} ${s} u_${a};\n#endif\n`:"vec4"===r?`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = a_${a};\n#else\n ${i} ${s} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = unpack_mix_${r}(a_${a}, u_${a}_t);\n#else\n ${i} ${s} ${a} = u_${a};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nattribute ${i} ${o} a_${a};\n#else\nuniform ${i} ${s} u_${a};\n#endif\n`:"vec4"===r?`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${s} ${a} = a_${a};\n#else\n ${i} ${s} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${s} ${a} = unpack_mix_${r}(a_${a}, u_${a}_t);\n#else\n ${i} ${s} ${a} = u_${a};\n#endif\n`})),staticAttributes:s,staticUniforms:r}}class le{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(t,e,i,s,a,o,r,n,l){this.context=t;let h=this.boundPaintVertexBuffers.length!==s.length;for(let t=0;!h&&t({u_depth:new t.aL(e,i.u_depth),u_terrain:new t.aL(e,i.u_terrain),u_terrain_dim:new t.aM(e,i.u_terrain_dim),u_terrain_matrix:new t.aN(e,i.u_terrain_matrix),u_terrain_unpack:new t.aO(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.aM(e,i.u_terrain_exaggeration)}))(e,b),this.binderUniforms=s?s.getUniforms(e,b):[];}draw(t,e,i,s,a,o,r,n,l,h,c,u,d,_,p,m,f,g){const v=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(s),t.setColorMode(a),t.setCullFace(o),n){t.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,n.depthTexture),t.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,n.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(n[t]);}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(r[t]);p&&p.setUniforms(t,this.binderUniforms,d,{zoom:_});let x=0;switch(e){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1;}for(const i of u.get()){const s=i.vaos||(i.vaos={});(s[l]||(s[l]=new le)).bind(t,this,h,p?p.getPaintVertexBuffers():[],c,i.vertexOffset,m,f,g),v.drawElements(e,i.primitiveLength*x,v.UNSIGNED_SHORT,i.primitiveOffset*x*2);}}}function ue(t,e,i){const s=1/St(i,1,e.transform.tileZoom),a=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,e.transform.tileZoom)/a,r=o*(i.tileID.canonical.x+i.tileID.wrap*a),n=o*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[s,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[r>>16,n>>16],u_pixel_coord_lower:[65535&r,65535&n]}}const de=(e,i,s,a)=>{const o=i.style.light,r=o.properties.get("position"),n=[r.x,r.y,r.z],l=function(){var e=new t.A(9);return t.A!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}();"viewport"===o.properties.get("anchor")&&function(t,e){var i=Math.sin(e),s=Math.cos(e);t[0]=s,t[1]=i,t[2]=0,t[3]=-i,t[4]=s,t[5]=0,t[6]=0,t[7]=0,t[8]=1;}(l,-i.transform.angle),function(t,e,i){var s=e[0],a=e[1],o=e[2];t[0]=s*i[0]+a*i[3]+o*i[6],t[1]=s*i[1]+a*i[4]+o*i[7],t[2]=s*i[2]+a*i[5]+o*i[8];}(n,n,l);const h=o.properties.get("color");return {u_matrix:e,u_lightpos:n,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+s,u_opacity:a}},_e=(e,i,s,a,o,r,n)=>t.e(de(e,i,s,a),ue(r,i,n),{u_height_factor:-Math.pow(2,o.overscaledZ)/n.tileSize/8}),pe=t=>({u_matrix:t}),me=(e,i,s,a)=>t.e(pe(e),ue(s,i,a)),fe=(t,e)=>({u_matrix:t,u_world:e}),ge=(e,i,s,a,o)=>t.e(me(e,i,s,a),{u_world:o}),ve=(t,e,i,s)=>{const a=t.transform;let o,r;if("map"===s.paint.get("circle-pitch-alignment")){const t=St(i,1,a.zoom);o=!0,r=[t,t];}else o=!1,r=a.pixelsToGLUnits;return {u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+("map"===s.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_pitch_with_map:+o,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:r}},xe=(t,e,i)=>{const s=St(i,1,e.zoom),a=Math.pow(2,e.zoom-i.tileID.overscaledZ),o=i.tileID.overscaleFactor();return {u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:s,u_extrude_scale:[e.pixelsToGLUnits[0]/(s*a),e.pixelsToGLUnits[1]/(s*a)],u_overscale_factor:o}},ye=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),be=t=>({u_matrix:t}),we=(t,e,i,s)=>({u_matrix:t,u_extrude_scale:St(e,1,i),u_intensity:s});function Te(e,i){const s=Math.pow(2,i.canonical.z),a=i.canonical.y;return [new t.U(0,a/s).toLngLat().lat,new t.U(0,(a+1)/s).toLngLat().lat]}const Ie=(t,e,i,s)=>{const a=t.transform;return {u_matrix:De(t,e,i,s),u_ratio:1/St(e,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Ee=(e,i,s,a,o)=>t.e(Ie(e,i,s,o),{u_image:0,u_image_height:a}),Se=(t,e,i,s,a)=>{const o=t.transform,r=Pe(e,o);return {u_matrix:De(t,e,i,a),u_texsize:e.imageAtlasTexture.size,u_ratio:1/St(e,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[r,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Ce=(e,i,s,a,o,r)=>{const n=e.lineAtlas,l=Pe(i,e.transform),h="round"===s.layout.get("line-cap"),c=n.getDash(a.from,h),u=n.getDash(a.to,h),d=c.width*o.fromScale,_=u.width*o.toScale;return t.e(Ie(e,i,s,r),{u_patternscale_a:[l/d,-c.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:c.y,u_tex_y_b:u.y,u_mix:o.t})};function Pe(t,e){return 1/St(t,1,e.tileZoom)}function De(t,e,i,s){return t.translatePosMatrix(s?s.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Me=(t,e,i,s,a)=>{return {u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:s.mix,u_opacity:s.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(r=a.paint.get("raster-saturation"),r>0?1-1/(1.001-r):-r),u_contrast_factor:(o=a.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:ze(a.paint.get("raster-hue-rotate"))};var o,r;};function ze(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return [(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Le=(t,e,i,s,a,o,r,n,l,h)=>{const c=a.transform;return {u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:c.width/c.height,u_fade_change:a.options.fadeDuration?a.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:r,u_coord_matrix:n,u_is_text:+l,u_pitch_with_map:+s,u_texsize:h,u_texture:0}},Ae=(e,i,s,a,o,r,n,l,h,c,u)=>{const d=o.transform;return t.e(Le(e,i,s,a,o,r,n,l,h,c),{u_gamma_scale:a?Math.cos(d._pitch)*d.cameraToCenterDistance:1,u_device_pixel_ratio:o.pixelRatio,u_is_halo:+u})},Re=(e,i,s,a,o,r,n,l,h,c)=>t.e(Ae(e,i,s,a,o,r,n,l,!0,h,!0),{u_texsize_icon:c,u_texture_icon:1}),ke=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),Fe=(e,i,s,a,o,r)=>t.e(function(t,e,i,s){const a=i.imageManager.getPattern(t.from.toString()),o=i.imageManager.getPattern(t.to.toString()),{width:r,height:n}=i.imageManager.getPixelSize(),l=Math.pow(2,s.tileID.overscaledZ),h=s.tileSize*Math.pow(2,i.transform.tileZoom)/l,c=h*(s.tileID.canonical.x+s.tileID.wrap*l),u=h*s.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[r,n],u_mix:e.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/St(s,1,i.transform.tileZoom),u_pixel_coord_upper:[c>>16,u>>16],u_pixel_coord_lower:[65535&c,65535&u]}}(a,r,s,o),{u_matrix:e,u_opacity:i}),Be={fillExtrusion:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_lightpos:new t.aP(e,i.u_lightpos),u_lightintensity:new t.aM(e,i.u_lightintensity),u_lightcolor:new t.aP(e,i.u_lightcolor),u_vertical_gradient:new t.aM(e,i.u_vertical_gradient),u_opacity:new t.aM(e,i.u_opacity)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_lightpos:new t.aP(e,i.u_lightpos),u_lightintensity:new t.aM(e,i.u_lightintensity),u_lightcolor:new t.aP(e,i.u_lightcolor),u_vertical_gradient:new t.aM(e,i.u_vertical_gradient),u_height_factor:new t.aM(e,i.u_height_factor),u_image:new t.aL(e,i.u_image),u_texsize:new t.aQ(e,i.u_texsize),u_pixel_coord_upper:new t.aQ(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.aQ(e,i.u_pixel_coord_lower),u_scale:new t.aP(e,i.u_scale),u_fade:new t.aM(e,i.u_fade),u_opacity:new t.aM(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_image:new t.aL(e,i.u_image),u_texsize:new t.aQ(e,i.u_texsize),u_pixel_coord_upper:new t.aQ(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.aQ(e,i.u_pixel_coord_lower),u_scale:new t.aP(e,i.u_scale),u_fade:new t.aM(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_world:new t.aQ(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_world:new t.aQ(e,i.u_world),u_image:new t.aL(e,i.u_image),u_texsize:new t.aQ(e,i.u_texsize),u_pixel_coord_upper:new t.aQ(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.aQ(e,i.u_pixel_coord_lower),u_scale:new t.aP(e,i.u_scale),u_fade:new t.aM(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.aM(e,i.u_camera_to_center_distance),u_scale_with_map:new t.aL(e,i.u_scale_with_map),u_pitch_with_map:new t.aL(e,i.u_pitch_with_map),u_extrude_scale:new t.aQ(e,i.u_extrude_scale),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_matrix:new t.aN(e,i.u_matrix)}),collisionBox:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_camera_to_center_distance:new t.aM(e,i.u_camera_to_center_distance),u_pixels_to_tile_units:new t.aM(e,i.u_pixels_to_tile_units),u_extrude_scale:new t.aQ(e,i.u_extrude_scale),u_overscale_factor:new t.aM(e,i.u_overscale_factor)}),collisionCircle:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_inv_matrix:new t.aN(e,i.u_inv_matrix),u_camera_to_center_distance:new t.aM(e,i.u_camera_to_center_distance),u_viewport_size:new t.aQ(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.aR(e,i.u_color),u_matrix:new t.aN(e,i.u_matrix),u_overlay:new t.aL(e,i.u_overlay),u_overlay_scale:new t.aM(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.aM(e,i.u_extrude_scale),u_intensity:new t.aM(e,i.u_intensity),u_matrix:new t.aN(e,i.u_matrix)}),heatmapTexture:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_world:new t.aQ(e,i.u_world),u_image:new t.aL(e,i.u_image),u_color_ramp:new t.aL(e,i.u_color_ramp),u_opacity:new t.aM(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_image:new t.aL(e,i.u_image),u_latrange:new t.aQ(e,i.u_latrange),u_light:new t.aQ(e,i.u_light),u_shadow:new t.aR(e,i.u_shadow),u_highlight:new t.aR(e,i.u_highlight),u_accent:new t.aR(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_image:new t.aL(e,i.u_image),u_dimension:new t.aQ(e,i.u_dimension),u_zoom:new t.aM(e,i.u_zoom),u_unpack:new t.aO(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_ratio:new t.aM(e,i.u_ratio),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.aQ(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_ratio:new t.aM(e,i.u_ratio),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.aQ(e,i.u_units_to_pixels),u_image:new t.aL(e,i.u_image),u_image_height:new t.aM(e,i.u_image_height)}),linePattern:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_texsize:new t.aQ(e,i.u_texsize),u_ratio:new t.aM(e,i.u_ratio),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_image:new t.aL(e,i.u_image),u_units_to_pixels:new t.aQ(e,i.u_units_to_pixels),u_scale:new t.aP(e,i.u_scale),u_fade:new t.aM(e,i.u_fade)}),lineSDF:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_ratio:new t.aM(e,i.u_ratio),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.aQ(e,i.u_units_to_pixels),u_patternscale_a:new t.aQ(e,i.u_patternscale_a),u_patternscale_b:new t.aQ(e,i.u_patternscale_b),u_sdfgamma:new t.aM(e,i.u_sdfgamma),u_image:new t.aL(e,i.u_image),u_tex_y_a:new t.aM(e,i.u_tex_y_a),u_tex_y_b:new t.aM(e,i.u_tex_y_b),u_mix:new t.aM(e,i.u_mix)}),raster:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_tl_parent:new t.aQ(e,i.u_tl_parent),u_scale_parent:new t.aM(e,i.u_scale_parent),u_buffer_scale:new t.aM(e,i.u_buffer_scale),u_fade_t:new t.aM(e,i.u_fade_t),u_opacity:new t.aM(e,i.u_opacity),u_image0:new t.aL(e,i.u_image0),u_image1:new t.aL(e,i.u_image1),u_brightness_low:new t.aM(e,i.u_brightness_low),u_brightness_high:new t.aM(e,i.u_brightness_high),u_saturation_factor:new t.aM(e,i.u_saturation_factor),u_contrast_factor:new t.aM(e,i.u_contrast_factor),u_spin_weights:new t.aP(e,i.u_spin_weights)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.aL(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.aL(e,i.u_is_size_feature_constant),u_size_t:new t.aM(e,i.u_size_t),u_size:new t.aM(e,i.u_size),u_camera_to_center_distance:new t.aM(e,i.u_camera_to_center_distance),u_pitch:new t.aM(e,i.u_pitch),u_rotate_symbol:new t.aL(e,i.u_rotate_symbol),u_aspect_ratio:new t.aM(e,i.u_aspect_ratio),u_fade_change:new t.aM(e,i.u_fade_change),u_matrix:new t.aN(e,i.u_matrix),u_label_plane_matrix:new t.aN(e,i.u_label_plane_matrix),u_coord_matrix:new t.aN(e,i.u_coord_matrix),u_is_text:new t.aL(e,i.u_is_text),u_pitch_with_map:new t.aL(e,i.u_pitch_with_map),u_texsize:new t.aQ(e,i.u_texsize),u_texture:new t.aL(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.aL(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.aL(e,i.u_is_size_feature_constant),u_size_t:new t.aM(e,i.u_size_t),u_size:new t.aM(e,i.u_size),u_camera_to_center_distance:new t.aM(e,i.u_camera_to_center_distance),u_pitch:new t.aM(e,i.u_pitch),u_rotate_symbol:new t.aL(e,i.u_rotate_symbol),u_aspect_ratio:new t.aM(e,i.u_aspect_ratio),u_fade_change:new t.aM(e,i.u_fade_change),u_matrix:new t.aN(e,i.u_matrix),u_label_plane_matrix:new t.aN(e,i.u_label_plane_matrix),u_coord_matrix:new t.aN(e,i.u_coord_matrix),u_is_text:new t.aL(e,i.u_is_text),u_pitch_with_map:new t.aL(e,i.u_pitch_with_map),u_texsize:new t.aQ(e,i.u_texsize),u_texture:new t.aL(e,i.u_texture),u_gamma_scale:new t.aM(e,i.u_gamma_scale),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_is_halo:new t.aL(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.aL(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.aL(e,i.u_is_size_feature_constant),u_size_t:new t.aM(e,i.u_size_t),u_size:new t.aM(e,i.u_size),u_camera_to_center_distance:new t.aM(e,i.u_camera_to_center_distance),u_pitch:new t.aM(e,i.u_pitch),u_rotate_symbol:new t.aL(e,i.u_rotate_symbol),u_aspect_ratio:new t.aM(e,i.u_aspect_ratio),u_fade_change:new t.aM(e,i.u_fade_change),u_matrix:new t.aN(e,i.u_matrix),u_label_plane_matrix:new t.aN(e,i.u_label_plane_matrix),u_coord_matrix:new t.aN(e,i.u_coord_matrix),u_is_text:new t.aL(e,i.u_is_text),u_pitch_with_map:new t.aL(e,i.u_pitch_with_map),u_texsize:new t.aQ(e,i.u_texsize),u_texsize_icon:new t.aQ(e,i.u_texsize_icon),u_texture:new t.aL(e,i.u_texture),u_texture_icon:new t.aL(e,i.u_texture_icon),u_gamma_scale:new t.aM(e,i.u_gamma_scale),u_device_pixel_ratio:new t.aM(e,i.u_device_pixel_ratio),u_is_halo:new t.aL(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_opacity:new t.aM(e,i.u_opacity),u_color:new t.aR(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_opacity:new t.aM(e,i.u_opacity),u_image:new t.aL(e,i.u_image),u_pattern_tl_a:new t.aQ(e,i.u_pattern_tl_a),u_pattern_br_a:new t.aQ(e,i.u_pattern_br_a),u_pattern_tl_b:new t.aQ(e,i.u_pattern_tl_b),u_pattern_br_b:new t.aQ(e,i.u_pattern_br_b),u_texsize:new t.aQ(e,i.u_texsize),u_mix:new t.aM(e,i.u_mix),u_pattern_size_a:new t.aQ(e,i.u_pattern_size_a),u_pattern_size_b:new t.aQ(e,i.u_pattern_size_b),u_scale_a:new t.aM(e,i.u_scale_a),u_scale_b:new t.aM(e,i.u_scale_b),u_pixel_coord_upper:new t.aQ(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.aQ(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.aM(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_texture:new t.aL(e,i.u_texture),u_ele_delta:new t.aM(e,i.u_ele_delta)}),terrainDepth:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_ele_delta:new t.aM(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_matrix:new t.aN(e,i.u_matrix),u_texture:new t.aL(e,i.u_texture),u_terrain_coords_id:new t.aM(e,i.u_terrain_coords_id),u_ele_delta:new t.aM(e,i.u_ele_delta)})};class Oe{constructor(t,e,i){this.context=t;const s=t.gl;this.buffer=s.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),s.bufferData(s.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const Ne={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ue{constructor(t,e,i,s){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=s,this.context=t;const a=t.gl;this.buffer=a.createBuffer(),t.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer);}enableAttributes(t,e){for(let i=0;i0){const i=t.Z(),s=v;t.aU(i,g.placementInvProjMatrix,e.transform.glCoordMatrix),t.aU(i,i,g.placementViewportMatrix),u.push({circleArray:y,circleOffset:_,transform:s,invTransform:i,coord:m}),d+=y.length/4,_=d;}x&&c.draw(l,h.LINES,Pi.disabled,Mi.disabled,e.colorModeForRenderPass(),zi.disabled,xe(v,e.transform,f),e.style.map.terrain&&e.style.map.terrain.getTerrainData(m),s.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,e.transform.zoom,null,null,x.collisionVertexBuffer);}if(!n||!u.length)return;const p=e.useProgram("collisionCircle"),m=new t.aV;m.resize(4*d),m._trim();let f=0;for(const t of u)for(let e=0;e=0&&(m[f.associatedIconIndex]={shiftedAnchor:E,angle:S});}else wt(f.numGlyphs,_);}if(c){p.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===s.layout.get("text-rotation-alignment");dt(h,l.posMatrix,e,o,F,B,g,c,i,t);}const U=e.translatePosMatrix(l.posMatrix,a,r,n),Z=v||o&&T||N?Ri:F,G=e.translatePosMatrix(B,a,r,n,!0),j=_&&0!==s.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let V;V=_?h.iconsInText?Re(w.kind,C,x,g,e,U,Z,G,D,A):Ae(w.kind,C,x,g,e,U,Z,G,o,D,!0):Le(w.kind,C,x,g,e,U,Z,G,o,D);const q={program:S,buffers:u,uniformValues:V,atlasTexture:M,atlasTextureIcon:R,atlasInterpolation:z,atlasInterpolationIcon:L,isSDF:_,hasHalo:j};if(y&&h.canOverlap){b=!0;const e=u.segments.get();for(const i of e)I.push({segments:new t.S([i]),sortKey:i.sortKey,state:q,terrainData:P});}else I.push({segments:u.segments,sortKey:0,state:q,terrainData:P});}b&&I.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of I){const i=t.state;if(_.activeTexture.set(p.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,p.CLAMP_TO_EDGE),i.atlasTextureIcon&&(_.activeTexture.set(p.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),i.isSDF){const a=i.uniformValues;i.hasHalo&&(a.u_is_halo=1,Ni(i.buffers,t.segments,s,e,i.program,w,u,d,a,t.terrainData)),a.u_is_halo=0;}Ni(i.buffers,t.segments,s,e,i.program,w,u,d,i.uniformValues,t.terrainData);}}function Ni(t,e,i,s,a,o,r,n,l,h){const c=s.context;a.draw(c,c.gl.TRIANGLES,o,r,n,zi.disabled,l,h,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,s.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer);}function Ui(t,e,i,s,a){if(!i||!s||!s.imageAtlas)return;const o=s.imageAtlas.patternPositions;let r=o[i.to.toString()],n=o[i.from.toString()];if(!r&&n&&(r=n),!n&&r&&(n=r),!r||!n){const t=a.getPaintProperty(e);r=o[t],n=o[t];}r&&n&&t.setConstantPatternPositions(r,n);}function Zi(t,e,i,s,a,o,r){const n=t.context.gl,l="fill-pattern",h=i.paint.get(l),c=h&&h.constantOr(1),u=i.getCrossfadeParameters();let d,_,p,m,f;r?(_=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=n.LINES):(_=c?"fillPattern":"fill",d=n.TRIANGLES);const g=h.constantOr(null);for(const h of s){const s=e.getTile(h);if(c&&!s.patternsLoaded())continue;const v=s.getBucket(i);if(!v)continue;const x=v.programConfigurations.get(i.id),y=t.useProgram(_,x),b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(h);c&&(t.context.activeTexture.set(n.TEXTURE0),s.imageAtlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),x.updatePaintBuffers(u)),Ui(x,l,g,s,i);const w=b?h:null,T=t.translatePosMatrix(w?w.posMatrix:h.posMatrix,s,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(r){m=v.indexBuffer2,f=v.segments2;const e=[n.drawingBufferWidth,n.drawingBufferHeight];p="fillOutlinePattern"===_&&c?ge(T,t,u,s,e):fe(T,e);}else m=v.indexBuffer,f=v.segments,p=c?me(T,t,u,s):pe(T);y.draw(t.context,d,a,t.stencilModeForClipping(h),o,zi.disabled,p,b,i.id,v.layoutVertexBuffer,m,f,i.paint,t.transform.zoom,x);}}function Gi(t,e,i,s,a,o,r){const n=t.context,l=n.gl,h="fill-extrusion-pattern",c=i.paint.get(h),u=c.constantOr(1),d=i.getCrossfadeParameters(),_=i.paint.get("fill-extrusion-opacity"),p=c.constantOr(null);for(const c of s){const s=e.getTile(c),m=s.getBucket(i);if(!m)continue;const f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(c),g=m.programConfigurations.get(i.id),v=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",g);u&&(t.context.activeTexture.set(l.TEXTURE0),s.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),g.updatePaintBuffers(d)),Ui(g,h,p,s,i);const x=t.translatePosMatrix(c.posMatrix,s,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),y=i.paint.get("fill-extrusion-vertical-gradient"),b=u?_e(x,t,y,_,c,d,s):de(x,t,y,_);v.draw(n,n.gl.TRIANGLES,a,o,r,zi.backCCW,b,f,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,g,t.style.map.terrain&&m.centroidVertexBuffer);}}function ji(t,e,i,s,a,o,r){const n=t.context,l=n.gl,h=i.fbo;if(!h)return;const c=t.useProgram("hillshade"),u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);n.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,h.colorAttachment.get()),c.draw(n,l.TRIANGLES,a,o,r,zi.disabled,((t,e,i,s)=>{const a=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),r=i.paint.get("hillshade-accent-color");let n=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(n-=t.transform.angle);const l=!t.options.moving;return {u_matrix:s?s.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:Te(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),n],u_shadow:a,u_highlight:o,u_accent:r}})(t,i,s,u?e:null),u,s.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments);}function Vi(e,i,s,a,o,r){const n=e.context,l=n.gl,h=i.dem;if(h&&h.data){const c=h.dim,u=h.stride,d=h.getPixels();if(n.activeTexture.set(l.TEXTURE1),n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(u),i.demTexture){const t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE);}else i.demTexture=new x(n,d,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);n.activeTexture.set(l.TEXTURE0);let _=i.fbo;if(!_){const t=new x(n,{width:c,height:c,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),_=i.fbo=n.createFramebuffer(c,c,!0,!1),_.colorAttachment.set(t.texture);}n.bindFramebuffer.set(_.framebuffer),n.viewport.set([0,0,c,c]),e.useProgram("hillshadePrepare").draw(n,l.TRIANGLES,a,o,r,zi.disabled,((e,i)=>{const s=i.stride,a=t.Z();return t.aS(a,0,t.N,-t.N,0,0,1),t.$(a,a,[0,-t.N,0]),{u_matrix:a,u_image:1,u_dimension:[s,s],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,h),null,s.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1;}}function qi(e,i,s,a,o,r){const n=a.paint.get("raster-fade-duration");if(!r&&n>0){const a=t.h.now(),r=(a-e.timeAdded)/n,l=i?(a-i.timeAdded)/n:-1,h=s.getSource(),c=o.coveringZoomLevel({tileSize:h.tileSize,roundZoom:h.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),d=u&&e.refreshedUponExpiration?1:t.ad(u?r:1-l,0,1);return e.refreshedUponExpiration&&r>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return {opacity:1,mix:0}}const $i=new t.aT(1,0,0,1),Wi=new t.aT(0,1,0,1),Hi=new t.aT(0,0,1,1),Xi=new t.aT(1,0,1,1),Ki=new t.aT(0,1,1,1);function Qi(t,e,i,s){Ji(t,0,e+i/2,t.transform.width,i,s);}function Yi(t,e,i,s){Ji(t,e-i/2,0,i,t.transform.height,s);}function Ji(t,e,i,s,a,o){const r=t.context,n=r.gl;n.enable(n.SCISSOR_TEST),n.scissor(e*t.pixelRatio,i*t.pixelRatio,s*t.pixelRatio,a*t.pixelRatio),r.clear({color:o}),n.disable(n.SCISSOR_TEST);}function ts(e,i,s){const a=e.context,o=a.gl,r=s.posMatrix,n=e.useProgram("debug"),l=Pi.disabled,h=Mi.disabled,c=e.colorModeForRenderPass(),u="$debug",d=e.style.map.terrain&&e.style.map.terrain.getTerrainData(s);a.activeTexture.set(o.TEXTURE0);const _=i.getTileByID(s.key).latestRawTileData,p=Math.floor((_&&_.byteLength||0)/1024),m=i.getTile(s).tileSize,f=512/Math.min(m,512)*(s.overscaledZ/e.transform.zoom)*.5;let g=s.canonical.toString();s.overscaledZ!==s.canonical.z&&(g+=` => ${s.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,s=t.context.gl,a=t.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(e,5,5),a.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);}(e,`${g} ${p}kB`),n.draw(a,o.TRIANGLES,l,h,Si.alphaBlended,zi.disabled,ye(r,t.aT.transparent,f),null,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),n.draw(a,o.LINE_STRIP,l,h,c,zi.disabled,ye(r,t.aT.red),d,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function es(t,e,i){const s=t.context,a=s.gl,o=t.colorModeForRenderPass(),r=new Pi(a.LEQUAL,Pi.ReadWrite,t.depthRangeFor3D),n=t.useProgram("terrain"),l=e.getTerrainMesh();s.bindFramebuffer.set(null),s.viewport.set([0,0,t.width,t.height]);for(const h of i){const i=t.renderToTexture.getTexture(h),c=e.getTerrainData(h.tileID);s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,i.texture);const u={u_matrix:t.transform.calculatePosMatrix(h.tileID.toUnwrapped()),u_texture:0,u_ele_delta:e.getMeshFrameDelta(t.transform.zoom)};n.draw(s,a.TRIANGLES,r,Mi.disabled,o,zi.backCCW,u,c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments);}}class is{constructor(e,i){this.context=new Ci(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.Z(),renderTime:0},this.setup(),this.numSublayers=K.maxUnderzooming+K.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Yt;}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize();}setup(){const e=this.context,i=new t.a_;i.emplaceBack(0,0),i.emplaceBack(t.N,0),i.emplaceBack(0,t.N),i.emplaceBack(t.N,t.N),this.tileExtentBuffer=e.createVertexBuffer(i,ae.members),this.tileExtentSegments=t.S.simpleSegment(0,0,4,2);const s=new t.a_;s.emplaceBack(0,0),s.emplaceBack(t.N,0),s.emplaceBack(0,t.N),s.emplaceBack(t.N,t.N),this.debugBuffer=e.createVertexBuffer(s,ae.members),this.debugSegments=t.S.simpleSegment(0,0,4,5);const a=new t.V;a.emplaceBack(0,0,0,0),a.emplaceBack(t.N,0,t.N,0),a.emplaceBack(0,t.N,0,t.N),a.emplaceBack(t.N,t.N,t.N,t.N),this.rasterBoundsBuffer=e.createVertexBuffer(a,O.members),this.rasterBoundsSegments=t.S.simpleSegment(0,0,4,2);const o=new t.a_;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,ae.members),this.viewportSegments=t.S.simpleSegment(0,0,4,2);const r=new t.a$;r.emplaceBack(0),r.emplaceBack(1),r.emplaceBack(3),r.emplaceBack(2),r.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(r);const n=new t.b0;n.emplaceBack(0,1,2),n.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(n);const l=this.context.gl;this.stencilClearMode=new Mi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const s=t.Z();t.aS(s,0,this.width,this.height,0,0,1),t.a0(s,s,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,i.TRIANGLES,Pi.disabled,this.stencilClearMode,Si.disabled,zi.disabled,be(s),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const i=this.context,s=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(Si.disabled),i.setDepthMode(Pi.disabled);const a=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,o=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);a.draw(i,s.TRIANGLES,Pi.disabled,new Mi({func:s.ALWAYS,mask:0},e,255,s.KEEP,s.KEEP,s.REPLACE),Si.disabled,zi.disabled,be(t.posMatrix),o,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Mi({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Mi({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),s=i[i.length-1].overscaledZ,a=i[0].overscaledZ-s+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();const t={};for(let i=0;i=0;this.currentLayer--){const t=this.style._layers[s[this.currentLayer]],e=a[t.source],i=o[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i);}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayeri.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[])),a=s.filter((t=>"vector"===t.getSource().type)),o=s.filter((t=>"vector"!==t.getSource().type)),r=t=>{(!i||i.getSource().maxzoomr(t))),i||o.forEach((t=>r(t))),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let s=0;si.style.map.terrain.getElevation(o,t,e):null);}}}(a,e,s,i,s.layout.get("text-rotation-alignment"),s.layout.get("text-pitch-alignment"),o),0!==s.paint.get("icon-opacity").constantOr(1)&&Oi(e,i,s,a,!1,s.paint.get("icon-translate"),s.paint.get("icon-translate-anchor"),s.layout.get("icon-rotation-alignment"),s.layout.get("icon-pitch-alignment"),s.layout.get("icon-keep-upright"),r,n),0!==s.paint.get("text-opacity").constantOr(1)&&Oi(e,i,s,a,!0,s.paint.get("text-translate"),s.paint.get("text-translate-anchor"),s.layout.get("text-rotation-alignment"),s.layout.get("text-pitch-alignment"),s.layout.get("text-keep-upright"),r,n),i.map.showCollisionBoxes&&(Ai(e,i,s,a,s.paint.get("text-translate"),s.paint.get("text-translate-anchor"),!0),Ai(e,i,s,a,s.paint.get("icon-translate"),s.paint.get("icon-translate-anchor"),!1));}(e,i,s,a,this.style.placement.variableOffsets);break;case"circle":!function(e,i,s,a){if("translucent"!==e.renderPass)return;const o=s.paint.get("circle-opacity"),r=s.paint.get("circle-stroke-width"),n=s.paint.get("circle-stroke-opacity"),l=!s.layout.get("circle-sort-key").isConstant();if(0===o.constantOr(1)&&(0===r.constantOr(1)||0===n.constantOr(1)))return;const h=e.context,c=h.gl,u=e.depthModeForSublayer(0,Pi.ReadOnly),d=Mi.disabled,_=e.colorModeForRenderPass(),p=[];for(let o=0;ot.sortKey-e.sortKey));for(const t of p){const{programConfiguration:i,program:a,layoutVertexBuffer:o,indexBuffer:r,uniformValues:n,terrainData:l}=t.state;a.draw(h,c.TRIANGLES,u,d,_,zi.disabled,n,l,s.id,o,r,t.segments,s.paint,e.transform.zoom,i);}}(e,i,s,a);break;case"heatmap":!function(e,i,s,a){if(0!==s.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const o=e.context,r=o.gl,n=Mi.disabled,l=new Si([r.ONE,r.ONE],t.aT.transparent,[!0,!0,!0,!0]);!function(t,e,i){const s=t.gl;t.activeTexture.set(s.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let a=i.heatmapFbo;if(a)s.bindTexture(s.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer);else {const o=s.createTexture();s.bindTexture(s.TEXTURE_2D,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),a=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1,!1),function(t,e,i,s){var a,o;const r=t.gl,n=null!==(a=t.HALF_FLOAT)&&void 0!==a?a:r.UNSIGNED_BYTE,l=null!==(o=t.RGBA16F)&&void 0!==o?o:r.RGBA;r.texImage2D(r.TEXTURE_2D,0,l,e.width/4,e.height/4,0,r.RGBA,n,null),s.colorAttachment.set(i);}(t,e,o,a);}}(o,e,s),o.clear({color:t.aT.transparent});for(let t=0;t{const o=t.Z();t.aS(o,0,e.width,e.height,0,0,1);const r=e.context.gl;return {u_matrix:o,u_world:[r.drawingBufferWidth,r.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(e,i),null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom);}(e,s));}(e,i,s,a);break;case"line":!function(e,i,s,a){if("translucent"!==e.renderPass)return;const o=s.paint.get("line-opacity"),r=s.paint.get("line-width");if(0===o.constantOr(1)||0===r.constantOr(1))return;const n=e.depthModeForSublayer(0,Pi.ReadOnly),l=e.colorModeForRenderPass(),h=s.paint.get("line-dasharray"),c=s.paint.get("line-pattern"),u=c.constantOr(1),d=s.paint.get("line-gradient"),_=s.getCrossfadeParameters(),p=u?"linePattern":h?"lineSDF":d?"lineGradient":"line",m=e.context,f=m.gl;let g=!0;for(const o of a){const a=i.getTile(o);if(u&&!a.patternsLoaded())continue;const r=a.getBucket(s);if(!r)continue;const v=r.programConfigurations.get(s.id),y=e.context.program.get(),b=e.useProgram(p,v),w=g||b.program!==y,T=e.style.map.terrain&&e.style.map.terrain.getTerrainData(o),I=c.constantOr(null);if(I&&a.imageAtlas){const t=a.imageAtlas,e=t.patternPositions[I.to.toString()],i=t.patternPositions[I.from.toString()];e&&i&&v.setConstantPatternPositions(e,i);}const E=T?o:null,S=u?Se(e,a,s,_,E):h?Ce(e,a,s,h,_,E):d?Ee(e,a,s,r.lineClipsArray.length,E):Ie(e,a,s,E);if(u)m.activeTexture.set(f.TEXTURE0),a.imageAtlasTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),v.updatePaintBuffers(_);else if(h&&(w||e.lineAtlas.dirty))m.activeTexture.set(f.TEXTURE0),e.lineAtlas.bind(m);else if(d){const a=r.gradients[s.id];let n=a.texture;if(s.gradientVersion!==a.version){let l=256;if(s.stepInterpolant){const s=i.getSource().maxzoom,a=o.canonical.z===s?Math.ceil(1<0?e.pop():null}isPatternMissing(t){if(!t)return !1;if(!t.from||!t.to)return !0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return !e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new ce(this.context,re[t],e,Be[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new x(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class ss{constructor(t,e){this.points=t,this.planes=e;}static fromInvProjectionMatrix(e,i,s){const a=Math.pow(2,s),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((s=>{const o=1/(s=t.ag([],s,e))[3]/i*a;return t.b3(s,s,[o,o,1/s[3],o])})),r=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=function(t,e){var i=e[0],s=e[1],a=e[2],o=i*i+s*s+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}([],function(t,e,i){var s=e[0],a=e[1],o=e[2],r=i[0],n=i[1],l=i[2];return t[0]=a*l-o*n,t[1]=o*r-s*l,t[2]=s*n-a*r,t}([],m([],o[t[0]],o[t[1]]),m([],o[t[2]],o[t[1]]))),i=-((s=e)[0]*(a=o[t[1]])[0]+s[1]*a[1]+s[2]*a[2]);var s,a;return e.concat(i)}));return new ss(o,r)}}class as{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max));}quadrant(t){const e=[t%2==0,t<2],i=_(this.min),s=_(this.max);for(let t=0;t=0&&r++;if(0===r)return 0;r!==i.length&&(s=!1);}if(s)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,s=-Number.MAX_VALUE;for(let a=0;athis.max[t]-this.min[t])return 0}return 1}}class os{constructor(t=0,e=0,i=0,s=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(s)||s<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=s;}interpolate(e,i,s){return null!=i.top&&null!=e.top&&(this.top=t.B.number(e.top,i.top,s)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.B.number(e.bottom,i.bottom,s)),null!=i.left&&null!=e.left&&(this.left=t.B.number(e.left,i.left,s)),null!=i.right&&null!=e.right&&(this.right=t.B.number(e.right,i.right,s)),this}getCenter(e,i){const s=t.ad((this.left+e-this.right)/2,0,e),a=t.ad((this.top+i-this.bottom)/2,0,i);return new t.P(s,a)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new os(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class rs{constructor(e,i,s,a,o){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===o||!!o,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==s?0:s,this._maxPitch=null==a?60:a,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.L(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new os,this._posMatrixCache={},this._alignedPosMatrixCache={},this._minEleveationForCurrentTile=0;}clone(){const t=new rs(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this._minEleveationForCurrentTile=t._minEleveationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices();}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t));}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t));}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t));}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t));}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t;}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this.width,this.height)}get bearing(){return -this.angle/Math.PI*180}set bearing(e){const i=-t.b5(e,-180,180)*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=function(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}(),function(t,e,i){var s=e[0],a=e[1],o=e[2],r=e[3],n=Math.sin(i),l=Math.cos(i);t[0]=s*l+o*n,t[1]=a*l+r*n,t[2]=s*-n+o*l,t[3]=a*-n+r*l;}(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.ad(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices());}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices());}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices();}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(e){const i=[new t.b6(0,e)];if(this._renderWorldCopies){const s=this.pointCoordinate(new t.P(0,0)),a=this.pointCoordinate(new t.P(this.width,0)),o=this.pointCoordinate(new t.P(this.width,this.height)),r=this.pointCoordinate(new t.P(0,this.height)),n=Math.floor(Math.min(s.x,a.x,o.x,r.x)),l=Math.floor(Math.max(s.x,a.x,o.x,r.x)),h=1;for(let s=n-h;s<=l+h;s++)0!==s&&i.push(new t.b6(s,e));}return i}coveringTiles(e){var i,s;let a=this.coveringZoomLevel(e);const o=a;if(void 0!==e.minzoom&&ae.maxzoom&&(a=e.maxzoom);const r=this.pointCoordinate(this.getCameraPoint()),n=t.U.fromLngLat(this.center),l=Math.pow(2,a),h=[l*r.x,l*r.y,0],c=[l*n.x,l*n.y,0],u=ss.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,a);let d=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(d=a);const _=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,p=t=>({aabb:new as([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],g=[],v=a,x=e.reparseOverscaled?o:a;if(this._renderWorldCopies)for(let t=1;t<=3;t++)m.push(p(-t)),m.push(p(t));for(m.push(p(0));m.length>0;){const a=m.pop(),o=a.x,r=a.y;let n=a.fullyVisible;if(!n){const t=a.aabb.intersects(u);if(0===t)continue;n=2===t;}const l=e.terrain?h:c,p=a.aabb.distanceX(l),y=a.aabb.distanceY(l),b=Math.max(Math.abs(p),Math.abs(y));if(a.zoom===v||b>_+(1<=d){const e=v-a.zoom,i=h[0]-.5-(o<>1),u=a.zoom+1;let d=a.aabb.quadrant(l);if(e.terrain){const o=new t.O(u,a.wrap,u,h,c),r=e.terrain.getMinMaxElevation(o),n=null!==(i=r.minElevation)&&void 0!==i?i:this.elevation,l=null!==(s=r.maxElevation)&&void 0!==s?s:this.elevation;d=new as([d.min[0],d.min[1],n],[d.max[0],d.max[1],l]);}m.push({aabb:d,zoom:u,x:h,y:c,wrap:a.wrap,fullyVisible:n});}}return g.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.ad(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.P(t.G(e.lng)*this.worldSize,t.H(i)*this.worldSize)}unproject(e){return new t.U(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return {lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){const i=this.pointLocation(this.centerPoint,e),s=e.getElevationForLngLatZoom(i,this.tileZoom);if(!(this.elevation-s))return;const a=this.getCameraPosition(),o=t.U.fromLngLat(a.lngLat,a.altitude),r=t.U.fromLngLat(i,s),n=o.x-r.x,l=o.y-r.y,h=o.z-r.z,c=Math.sqrt(n*n+l*l+h*h),u=this.scaleZoom(this.cameraToCenterDistance/c/this.tileSize);this._elevation=s,this._center=i,this.zoom=u;}setLocationAtPoint(e,i){const s=this.pointCoordinate(i),a=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(e),r=new t.U(o.x-(s.x-a.x),o.y-(s.y-a.y));this.center=this.coordinateLocation(r),this._renderWorldCopies&&(this.center=this.center.wrap());}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(e){return t.U.fromLngLat(e)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(e,i){if(i){const t=i.pointCoordinate(e);if(null!=t)return t}const s=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.ag(s,s,this.pixelMatrixInverse),t.ag(a,a,this.pixelMatrixInverse);const o=s[3],r=a[3],n=s[1]/o,l=a[1]/r,h=s[2]/o,c=a[2]/r,u=h===c?0:(0-h)/(c-h);return new t.U(t.B.number(s[0]/o,a[0]/r,u)/this.worldSize,t.B.number(n,l,u)/this.worldSize)}coordinatePoint(e,i=0,s=this.pixelMatrix){const a=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.ag(a,a,s),new t.P(a[0]/a[3],a[1]/a[3])}getBounds(){const e=Math.max(0,this.height/2-this.getHorizon());return (new L).extend(this.pointLocation(new t.P(0,e))).extend(this.pointLocation(new t.P(this.width,e))).extend(this.pointLocation(new t.P(this.width,this.height))).extend(this.pointLocation(new t.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new L([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude]);}calculatePosMatrix(e,i=!1){const s=e.key,a=i?this._alignedPosMatrixCache:this._posMatrixCache;if(a[s])return a[s];const o=e.canonical,r=this.worldSize/this.zoomScale(o.z),n=o.x+Math.pow(2,o.z)*e.wrap,l=t.ao(new Float64Array(16));return t.$(l,l,[n*r,o.y*r,0]),t.a0(l,l,[r/t.N,r/t.N,1]),t.a1(l,i?this.alignedProjMatrix:this.projMatrix,l),a[s]=new Float32Array(l),a[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let e,i,s,a,o=-90,r=90,n=-180,l=180;const h=this.size,c=this._unmodified;if(this.latRange){const i=this.latRange;o=t.H(i[1])*this.worldSize,r=t.H(i[0])*this.worldSize,e=r-or&&(a=r-e);}if(this.lngRange){const e=(n+l)/2,i=t.b5(u.x,e-this.worldSize/2,e+this.worldSize/2),a=h.x/2;i-al&&(s=l-a);}void 0===s&&void 0===a||(this.center=this.unproject(new t.P(void 0!==s?s:u.x,void 0!==a?a:u.y)).wrap()),this._unmodified=c,this._constraining=!1;}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,i=this.point.x,s=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=t.b7(1,this.center.lat)*this.worldSize;let a=t.ao(new Float64Array(16));t.a0(a,a,[this.width/2,-this.height/2,1]),t.$(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=t.ao(new Float64Array(16)),t.a0(a,a,[1,-1,1]),t.$(a,a,[-1,-1,0]),t.a0(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a;const o=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),r=Math.min(this.elevation,this._minEleveationForCurrentTile),n=o-r*this._pixelPerMeter/Math.cos(this._pitch),l=r<0?n:o,h=Math.PI/2+this._pitch,c=this._fov*(.5+e.y/this.height),u=Math.sin(c)*l/Math.sin(t.ad(Math.PI-h-c,.01,Math.PI-.01)),d=this.getHorizon(),_=2*Math.atan(d/this.cameraToCenterDistance)*(.5+e.y/(2*d)),p=Math.sin(_)*l/Math.sin(t.ad(Math.PI-h-_,.01,Math.PI-.01)),m=Math.min(u,p),f=1.01*(Math.cos(Math.PI/2-this._pitch)*m+l),g=this.height/50;a=new Float64Array(16),t.b8(a,this._fov,this.width/this.height,g,f),a[8]=2*-e.x/this.width,a[9]=2*e.y/this.height,t.a0(a,a,[1,-1,1]),t.$(a,a,[0,0,-this.cameraToCenterDistance]),t.b9(a,a,this._pitch),t.ae(a,a,this.angle),t.$(a,a,[-i,-s,0]),this.mercatorMatrix=t.a0([],a,[this.worldSize,this.worldSize,this.worldSize]),t.a0(a,a,[1,1,this._pixelPerMeter]),this.pixelMatrix=t.a1(new Float64Array(16),this.labelPlaneMatrix,a),t.$(a,a,[0,0,-this.elevation]),this.projMatrix=a,this.invProjMatrix=t.as([],a),this.pixelMatrix3D=t.a1(new Float64Array(16),this.labelPlaneMatrix,a);const v=this.width%2/2,x=this.height%2/2,y=Math.cos(this.angle),b=Math.sin(this.angle),w=i-Math.round(i)+y*v+b*x,T=s-Math.round(s)+y*x+b*v,I=new Float64Array(a);if(t.$(I,I,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=I,a=t.as(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");this.pixelMatrixInverse=a,this._posMatrixCache={},this._alignedPosMatrixCache={};}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.ag(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(0,e))}getCameraQueryGeometry(e){const i=this.getCameraPoint();if(1===e.length)return [e[0],i];{let s=i.x,a=i.y,o=i.x,r=i.y;for(const t of e)s=Math.min(s,t.x),a=Math.min(a,t.y),o=Math.max(o,t.x),r=Math.max(r,t.y);return [new t.P(s,a),new t.P(o,a),new t.P(o,r),new t.P(s,r),new t.P(s,a)]}}}function ns(t,e){let i,s=!1,a=null,o=null;const r=()=>{a=null,s&&(t.apply(o,i),a=setTimeout(r,e),s=!1);};return (...t)=>(s=!0,o=this,i=t,a||r(),a)}class ls{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t);})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return !1},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t);}catch(t){}},this._updateHash=ns(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t);}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,s=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.pow(10,s),o=Math.round(e.lng*a)/a,r=Math.round(e.lat*a)/a,n=this._map.getBearing(),l=this._map.getPitch();let h="";if(h+=t?`/${o}/${r}/${i}`:`${i}/${r}/${o}`,(n||l)&&(h+="/"+Math.round(10*n)/10),l&&(h+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const s=i.split("=")[0];return s===t?(e=!0,`${s}=${h}`):i})).filter((t=>t));return e||i.push(`${t}=${h}`),`#${i.join("&")}`}return `#${h}`}}const hs={linearity:.3,easing:t.ba(0,0,.3,1)},cs=t.e({deceleration:2500,maxSpeed:1400},hs),us=t.e({deceleration:20,maxSpeed:1400},hs),ds=t.e({deceleration:1e3,maxSpeed:360},hs),_s=t.e({deceleration:1e3,maxSpeed:90},hs);class ps{constructor(t){this._map=t,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.h.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.h.now();for(;e.length>0&&i-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(i.pan.mag()){const o=fs(i.pan.mag(),s,t.e({},cs,e||{}));a.offset=i.pan.mult(o.amount/i.pan.mag()),a.center=this._map.transform.center,ms(a,o);}if(i.zoom){const t=fs(i.zoom,s,us);a.zoom=this._map.transform.zoom+t.amount,ms(a,t);}if(i.bearing){const e=fs(i.bearing,s,ds);a.bearing=this._map.transform.bearing+t.ad(e.amount,-179,179),ms(a,e);}if(i.pitch){const t=fs(i.pitch,s,_s);a.pitch=this._map.transform.pitch+t.amount,ms(a,t);}if(a.zoom||a.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;a.around=t?this._map.unproject(t):this._map.getCenter();}return this.clear(),t.e(a,{noMoveStart:!0})}}function ms(t,e){(!t.duration||t.durations.unproject(t))),l=r.reduce(((t,e,i,s)=>t.add(e.div(s.length))),new t.P(0,0));super(e,{points:r,point:l,lngLats:n,lngLat:s.unproject(l),originalEvent:a}),this._defaultPrevented=!1;}}class xs extends t.k{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1;}}class ys{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance;}reset(){delete this._mousedownPos;}wheel(t){return this._firePreventable(new xs(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new gs(t.type,this._map,t))}mouseup(t){this._map.fire(new gs(t.type,this._map,t));}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new gs(t.type,this._map,t));}dblclick(t){return this._firePreventable(new gs(t.type,this._map,t))}mouseover(t){this._map.fire(new gs(t.type,this._map,t));}mouseout(t){this._map.fire(new gs(t.type,this._map,t));}touchstart(t){return this._firePreventable(new vs(t.type,this._map,t))}touchmove(t){this._map.fire(new vs(t.type,this._map,t));}touchend(t){this._map.fire(new vs(t.type,this._map,t));}touchcancel(t){this._map.fire(new vs(t.type,this._map,t));}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class bs{constructor(t){this._map=t;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(t){this._map.fire(new gs(t.type,this._map,t));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new gs("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new gs(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class ws{constructor(t){this._map=t;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.pointLocation(t.P.convert(e),this._map.terrain)}}class Ts{constructor(t,e){this._map=t,this._tr=new ws(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(i.disableDrag(),this._startPos=this._lastPos=e,this._active=!0);}mousemoveWindow(t,e){if(!this._active)return;const s=e;if(this._lastPos.equals(s)||!this._box&&s.dist(this._startPos)t.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(i.remove(this._box),this._box=null),i.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.k(e,{originalEvent:i}))}}function Is(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let s=0;sthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),s.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Is(s,i)));}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const s=Is(i,e);for(const t in this.touches){const e=s[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0);}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Ss{constructor(t){this.singleTap=new Es(t),this.numTaps=t.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(t,e,i){this.singleTap.touchstart(t,e,i);}touchmove(t,e,i){this.singleTap.touchmove(t,e,i);}touchend(t,e,i){const s=this.singleTap.touchend(t,e,i);if(s){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(s)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=s,this.count===this.numTaps)return this.reset(),s}}}class Cs{constructor(t){this._tr=new ws(t),this._zoomIn=new Ss({numTouches:1,numTaps:2}),this._zoomOut=new Ss({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i);}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i);}touchend(t,e,i){const s=this._zoomIn.touchend(t,e,i),a=this._zoomOut.touchend(t,e,i),o=this._tr;return s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(s)},{originalEvent:t})}):a?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(a)},{originalEvent:t})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ps{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset();}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t);}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const s=e.length?e[0]:e;return !this._moved&&s.dist(i){t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=function(t){t.preventDefault();};},As=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:s=.8})=>{const a=new Ms({checkCorrectEvent:t=>0===i.mouseButton(t)&&t.ctrlKey||2===i.mouseButton(t)});return new Ps({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*s}),moveStateManager:a,enable:t,assignEvents:Ls})},Rs=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:s=-.5})=>{const a=new Ms({checkCorrectEvent:t=>0===i.mouseButton(t)&&t.ctrlKey||2===i.mouseButton(t)});return new Ps({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*s}),moveStateManager:a,enable:t,assignEvents:Ls})};class ks{constructor(t,e){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0),setTimeout((()=>{this._cancelCooperativeMessage=!1;}),200);}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._map._cooperativeGestures&&(2===this._minTouches&&i.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,i.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(i.length0&&(this._active=!0);const a=Is(s,i),o=new t.P(0,0),r=new t.P(0,0);let n=0;for(const t in a){const e=a[t],i=this._touches[t];i&&(o._add(e),r._add(e.sub(i)),n++,a[t]=e);}if(this._touches=a,nMath.abs(t.x)}class js extends Fs{constructor(t){super(),this._map=t;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length;}_start(t){this._lastPoints=t,Gs(t[0].sub(t[1]))&&(this._valid=!1);}_move(t,e,i){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const s=t[0].sub(this._lastPoints[0]),a=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(s,a,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(s.y+a.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const s=t.mag()>=2,a=e.mag()>=2;if(!s&&!a)return;if(!s||!a)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return Gs(t)&&Gs(e)&&o}}const Vs={panStep:100,bearingStep:15,pitchStep:10};class qs{constructor(t){this._tr=new ws(t);const e=Vs;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,s=0,a=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),a=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),a=1);break;case 38:t.shiftKey?s=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?s=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,s=0),{cameraAnimation:r=>{const n=this._tr;r.easeTo({duration:300,easeId:"keyboardHandler",easing:$s,zoom:e?Math.round(n.zoom)+e*(t.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+s*this._pitchStep,offset:[-a*this._panStep,-o*this._panStep],center:n.center},{originalEvent:t});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function $s(t){return t*(2-t)}const Ws=4.000244140625;class Hs{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t);},this._map=t,this._tr=new ws(t),this._el=t.getCanvasContainer(),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(t){this._defaultZoomRate=t;}setWheelZoomRate(t){this._wheelZoomRate=t;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around);}disable(){this.isEnabled()&&(this._enabled=!1);}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!e[this._map._metaKey])return;e.preventDefault();}let i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const s=t.h.now(),a=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,0!==i&&i%Ws==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":a>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(a*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const s=i.mousePos(this._el,e),a=this._tr;this._around=t.L.convert(this._aroundCenter?a.center:a.unproject(s)),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>Ws?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);const s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*i))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"==typeof this._targetZoom?this._targetZoom:e.zoom,s=this._startZoom,a=this._easing;let o,r=!1;if("wheel"===this._type&&s&&a){const e=Math.min((t.h.now()-this._lastWheelEventTime)/200,1),n=a(e);o=t.B.number(s,i,n),e<1?this._frameId||(this._frameId=!0):r=!0;}else o=i,r=!0;return this._active=!0,r&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200)),{noInertia:!0,needsRenderFrame:!r,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.bb;if(this._prevEase){const e=this._prevEase,s=(t.h.now()-e.start)/e.duration,a=e.easing(s+.01)-e.easing(s),o=.27/Math.sqrt(a*a+1e-4)*.01,r=Math.sqrt(.0729-o*o);i=t.ba(o,r,.25,1);}return this._prevEase={start:t.h.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class Xs{constructor(t,e){this._clickZoom=t,this._tapZoom=e;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ks{constructor(t){this._tr=new ws(t),this.reset();}reset(){this._active=!1;}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Qs{constructor(){this._tap=new Ss({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const s=e[0],a=t.timeStamp-this._tapTime<500,o=this._tapPoint.dist(s)<30;a&&o?i.length>0&&(this._swipePoint=s,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(t,e,i);}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const s=e[0],a=s.y-this._swipePoint.y;return this._swipePoint=s,t.preventDefault(),this._active=!0,{zoomDelta:a/128}}}else this._tap.touchmove(t,e,i);}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const s=this._tap.touchend(t,e,i);s&&(this._tapTime=t.timeStamp,this._tapPoint=s);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ys{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i;}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Js{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class ta{constructor(t,e,i,s){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=s,this._rotationDisabled=!1,this._enabled=!0;}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}const ea=t=>t.zoom||t.drag||t.pitch||t.rotate;class ia extends t.k{}function sa(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class aa{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`);},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const s="renderFrame"===t.type?void 0:t,a={needsRenderFrame:!1},o={},r={},n=t.touches,l=n?this._getMapTouches(n):void 0,h=l?i.touchPos(this._el,l):i.mousePos(this._el,t);for(const{handlerName:i,handler:n,allowed:c}of this._handlers){if(!n.isEnabled())continue;let u;this._blockedByActive(r,c,i)?n.reset():n[e||t.type]&&(u=n[e||t.type](t,h,l),this.mergeHandlerResult(a,o,u,i,s),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||n.isActive())&&(r[i]=n);}const c={};for(const t in this._previousActiveHandlers)r[t]||(c[t]=s);this._previousActiveHandlers=r,(Object.keys(c).length||sa(a))&&(this._changes.push([a,o,c]),this._triggerRenderFrame()),(Object.keys(r).length||sa(a))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=a;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map));},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ps(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,s]of this._listeners)i.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,s);}destroy(){for(const[t,e,s]of this._listeners)i.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,s);}_addDefaultHandlers(t){const e=this._map,s=e.getCanvasContainer();this._add("mapEvent",new ys(e,t));const a=e.boxZoom=new Ts(e,t);this._add("boxZoom",a),t.interactive&&t.boxZoom&&a.enable();const o=new Cs(e),r=new Ks(e);e.doubleClickZoom=new Xs(r,o),this._add("tapZoom",o),this._add("clickZoom",r),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();const n=new Qs;this._add("tapDragZoom",n);const l=e.touchPitch=new js(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);const h=As(t),c=Rs(t);e.dragRotate=new Js(t,h,c),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();const u=(({enable:t,clickTolerance:e})=>{const s=new Ms({checkCorrectEvent:t=>0===i.mouseButton(t)&&!t.ctrlKey});return new Ps({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:s,enable:t,assignEvents:Ls})})(t),d=new ks(t,e);e.dragPan=new Ys(s,u,d),this._add("mousePan",u),this._add("touchPan",d,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);const _=new Zs,p=new Ns;e.touchZoomRotate=new ta(s,p,_,n),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);const m=e.scrollZoom=new Hs(e,(()=>this._triggerRenderFrame()));this._add("scrollZoom",m,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);const f=e.keyboard=new qs(e);this._add("keyboard",f),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new bs(e));}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e;}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[];}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(ea(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const s in t)if(s!==i&&(!e||e.indexOf(s)<0))return !0;return !1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(e,i,s,a,o){if(!s)return;t.e(e,s);const r={handlerName:a,originalEvent:s.originalEvent||o};void 0!==s.zoomDelta&&(i.zoom=r),void 0!==s.panDelta&&(i.drag=r),void 0!==s.pitchDelta&&(i.pitch=r),void 0!==s.bearingDelta&&(i.rotate=r);}_applyChanges(){const e={},i={},s={};for(const[a,o,r]of this._changes)a.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(a.panDelta)),a.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+a.pitchDelta),void 0!==a.around&&(e.around=a.around),void 0!==a.pinchAround&&(e.pinchAround=a.pinchAround),a.noInertia&&(e.noInertia=a.noInertia),t.e(i,o),t.e(s,r);this._updateMapTransform(e,i,s),this._changes=[];}_updateMapTransform(t,e,i){const s=this._map,a=s._getTransformForUpdate(),o=s.terrain;if(!(sa(t)||o&&this._terrainMovement))return this._fireEvents(e,i,!0);let{panDelta:r,zoomDelta:n,bearingDelta:l,pitchDelta:h,around:c,pinchAround:u}=t;void 0!==u&&(c=u),s._stop(!0),c=c||s.transform.centerPoint;const d=a.pointLocation(r?c.sub(r):c);l&&(a.bearing+=l),h&&(a.pitch+=h),n&&(a.zoom+=n),o?this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?a.center=a.pointLocation(a.centerPoint.sub(r)):a.setLocationAtPoint(d,c):(this._terrainMovement=!0,this._map._elevationFreeze=!0,a.setLocationAtPoint(d,c),this._map.once("moveend",(()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,a.recalculateZoom(s.terrain);}))):a.setLocationAtPoint(d,c),s._applyUpdatedTransform(a),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0);}_fireEvents(e,i,s){const a=ea(this._eventsInProgress),o=ea(e),r={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(r[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!a&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in r)this._fireEvent(t,r[t]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const n={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:s}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||s,n[`${t}end`]=l);}for(const t in n)this._fireEvent(t,n[t]);const h=ea(this._eventsInProgress);if(s&&(a||o)&&!h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ia("renderFrame",{timeStamp:t})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class oa extends t.E{constructor(e,i){super(),this._renderFrameCallback=()=>{const e=Math.min((t.h.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState;}));}getCenter(){return new t.L(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,s){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),s)}panTo(e,i,s){return this.easeTo(t.e({center:e},i),s)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,s){return this.easeTo(t.e({zoom:e},i),s)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,s){return this.easeTo(t.e({bearing:e},i),s)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(s.zoom=t.B.number(a,l,p)),this._rotating&&(s.bearing=t.B.number(o,h,p)),this._pitching&&(s.pitch=t.B.number(r,c,p)),this._padding&&(s.interpolatePadding(n,u,p),_=s.centerPoint.add(d)),this.terrain&&!e.freezeElevation&&this._updateElevation(p),x)s.setLocationAtPoint(x,y);else {const t=s.zoomScale(s.zoom-a),e=l>a?Math.min(2,v):Math.max(.5,v),i=Math.pow(e,1-p),o=s.unproject(f.add(g.mult(p*i)).mult(t));s.setLocationAtPoint(s.renderWorldCopies?o.wrap():o,_);}this._applyUpdatedTransform(s),this._fireMoveEvents(i);}),(t=>{this.terrain&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,s={}){this._moving=!0,i||s.moving||this.fire(new t.k("movestart",e)),this._zooming&&!s.zooming&&this.fire(new t.k("zoomstart",e)),this._rotating&&!s.rotating&&this.fire(new t.k("rotatestart",e)),this._pitching&&!s.pitching&&this.fire(new t.k("pitchstart",e));}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.elevation=t.B.number(this._elevationStart,this._elevationTarget,e);}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const e=t.clone(),{center:i,zoom:s,pitch:a,bearing:o,elevation:r}=this.transformCameraUpdate(e);i&&(e.center=i),void 0!==s&&(e.zoom=s),void 0!==a&&(e.pitch=a),void 0!==o&&(e.bearing=o),void 0!==r&&(e.elevation=r),this.transform.apply(e);}_fireMoveEvents(e){this.fire(new t.k("move",e)),this._zooming&&this.fire(new t.k("zoom",e)),this._rotating&&this.fire(new t.k("rotate",e)),this._pitching&&this.fire(new t.k("pitch",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const s=this._zooming,a=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new t.k("zoomend",e)),a&&this.fire(new t.k("rotateend",e)),o&&this.fire(new t.k("pitchend",e)),this.fire(new t.k("moveend",e));}flyTo(e,i){if(!e.essential&&t.h.prefersReducedMotion){const s=t.F(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(s,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.bb},e);const s=this._getTransformForUpdate(),a=this.getZoom(),o=this.getBearing(),r=this.getPitch(),n=this.getPadding(),l="zoom"in e?t.ad(+e.zoom,s.minZoom,s.maxZoom):a,h="bearing"in e?this._normalizeBearing(e.bearing,o):o,c="pitch"in e?+e.pitch:r,u="padding"in e?e.padding:s.padding,d=s.zoomScale(l-a),_=t.P.convert(e.offset);let p=s.centerPoint.add(_);const m=s.pointLocation(p),f=t.L.convert(e.center||m);this._normalizeCenter(f);const g=s.project(m),v=s.project(f).sub(g);let x=e.curve;const y=Math.max(s.width,s.height),b=y/d,w=v.mag();if("minZoom"in e){const i=t.ad(Math.min(e.minZoom,a,l),s.minZoom,s.maxZoom),o=y/s.zoomScale(i-a);x=Math.sqrt(o/w*2);}const T=x*x;function I(t){const e=(b*b-y*y+(t?-1:1)*T*T*w*w)/(2*(t?b:y)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function E(t){return (Math.exp(t)-Math.exp(-t))/2}function S(t){return (Math.exp(t)+Math.exp(-t))/2}const C=I(!1);let P=function(t){return S(C)/S(C+x*t)},D=function(t){return y*((S(C)*(E(e=C+x*t)/S(e))-E(C))/T)/w;var e;},M=(I(!0)-C)/x;if(Math.abs(w)<1e-6||!isFinite(M)){if(Math.abs(y-b)<1e-6)return this.easeTo(e,i);const t=be.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==h,this._pitching=c!==r,this._padding=!s.isPaddingEqual(u),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f),this._ease((d=>{const m=d*M,x=1/P(m);s.zoom=1===d?l:a+s.scaleZoom(x),this._rotating&&(s.bearing=t.B.number(o,h,d)),this._pitching&&(s.pitch=t.B.number(r,c,d)),this._padding&&(s.interpolatePadding(n,u,d),p=s.centerPoint.add(_)),this.terrain&&!e.freezeElevation&&this._updateElevation(d);const y=1===d?f:s.unproject(g.add(v.mult(D(m))).mult(x));s.setLocationAtPoint(s.renderWorldCopies?y.wrap():y,p),this._applyUpdatedTransform(s),this._fireMoveEvents(i);}),(()=>{this.terrain&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e);}if(!t){const t=this.handlers;t&&t.stop(!1);}return this}_ease(e,i,s){!1===s.animate||0===s.duration?(e(1),i()):(this._easeStart=t.h.now(),this._easeOptions=s,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.b5(e,-180,180);const s=Math.abs(e-i);return Math.abs(e-360-i)180?-360:i<-180?360:0;}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(t.L.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}class ra{constructor(t={}){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=t;}getDefaultPosition(){return "bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=i.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=i.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=i.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){i.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id;}const e=this._map.style.sourceCaches;for(const i in e){const s=e[i];if(s.used||s.usedForTerrain){const e=s.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution);}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let s=i+1;s=0)return !1;return !0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class na{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact");}},this.options=t;}getDefaultPosition(){return "bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=i.create("div","maplibregl-ctrl");const e=i.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){i.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class la{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}const ha={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var ca=t.Q([{name:"a_pos3d",type:"Int16",components:3}]);class ua extends t.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const s={};for(const a of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))s[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.posMatrix=new Float64Array(16),t.aS(a.posMatrix,0,t.N,0,t.N,0,1),this._tiles[a.key]=new W(a,this.tileSize));for(const t in this._tiles)s[t]||delete this._tiles[t];}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(e){const i={};for(const s of this._renderableTilesKeys){const a=this._tiles[s].tileID;if(a.canonical.equals(e.canonical)){const a=e.clone();a.posMatrix=new Float64Array(16),t.aS(a.posMatrix,0,t.N,0,t.N,0,1),i[s]=a;}else if(a.canonical.isChildOf(e.canonical)){const o=e.clone();o.posMatrix=new Float64Array(16);const r=a.canonical.z-e.canonical.z,n=a.canonical.x-(a.canonical.x>>r<>r<>r;t.aS(o.posMatrix,0,h,0,h,0,1),t.$(o.posMatrix,o.posMatrix,[-n*h,-l*h,0]),i[s]=o;}else if(e.canonical.isChildOf(a.canonical)){const o=e.clone();o.posMatrix=new Float64Array(16);const r=e.canonical.z-a.canonical.z,n=e.canonical.x-(e.canonical.x>>r<>r<>r;t.aS(o.posMatrix,0,t.N,0,t.N,0,1),t.$(o.posMatrix,o.posMatrix,[n*h,l*h,0]),t.a0(o.posMatrix,o.posMatrix,[1/2**r,1/2**r,0]),i[s]=o;}}return i}getSourceTile(t,e){const i=this.sourceCache._source;let s=t.overscaledZ-this.deltaZoom;if(s>i.maxzoom&&(s=i.maxzoom),s=i.minzoom&&(!a||!a.dem);)a=this.sourceCache.getTileByID(t.scaledTo(s--).key);return a}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeAdded>=t))}}class da{constructor(t,e,i){this.painter=t,this.sourceCache=new ua(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,s,a=t.N){var o;if(!(i>=0&&i=0&&se.canonical.z&&(e.canonical.z>=s?a=e.canonical.z-s:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>a<>a<>8<<4|t>>8,i[e+3]=0;const s=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),a=new x(e,s,e.gl.RGBA,{premultiply:!1});return a.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=a,a}pointCoordinate(e){const i=new Uint8Array(4),s=this.painter.context,a=s.gl;s.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),a.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,a.RGBA,a.UNSIGNED_BYTE,i),s.bindFramebuffer.set(null);const o=i[0]+(i[2]>>4<<8),r=i[1]+((15&i[2])<<8),n=this.coordsIndex[255-i[3]],l=n&&this.sourceCache.getTileByID(n);if(!l)return null;const h=this._coordsTextureSize,c=(1<0&&Math.sign(o)<0||!s&&Math.sign(a)<0&&Math.sign(o)>0?(a=360*Math.sign(o)+a,t.G(a)):i}}class _a{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0;}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy();}_createObject(t){const e=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new x(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),e.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),e.colorAttachment.set(i.texture),{id:t,fbo:e,texture:i,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((e=>t.id!==e)),this._recentlyUsed.push(t.id);}stampObject(t){t.stamp=++this._stamp;}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1;}freeAllObjects(){for(const t of this._objects)this.freeObject(t);}isFull(){return !(this._objects.length!t.inUse))}}const pa={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ma{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new _a(t.context,30,e.sourceCache.tileSize*e.qualityFactor);}destruct(){this.pool.destruct();}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsDescendingInv={};for(const e in t.sourceCaches){this._coordsDescendingInv[e]={};const i=t.sourceCaches[e].getVisibleCoordinates();for(const t of i){const i=this.terrain.sourceCache.getTerrainCoords(t);for(const t in i)this._coordsDescendingInv[e][t]||(this._coordsDescendingInv[e][t]=[]),this._coordsDescendingInv[e][t].push(i[t]);}}this._coordsDescendingInvStr={};for(const e of t._order){const i=t._layers[e],s=i.source;if(pa[i.type]&&!this._coordsDescendingInvStr[s]){this._coordsDescendingInvStr[s]={};for(const t in this._coordsDescendingInv[s])this._coordsDescendingInvStr[s][t]=this._coordsDescendingInv[s][t].map((t=>t.key)).sort().join();}}for(const t of this._renderableTiles)for(const e in this._coordsDescendingInvStr){const i=this._coordsDescendingInvStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[]);}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return !1;const i=e.type,s=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(pa[i]&&(this._prevType&&pa[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(e.id),!a))return !0;if(pa[this._prevType]||pa[i]&&a){this._prevType=i;const e=this._stacks.length-1,a=this._stacks[e]||[];for(const i of this._renderableTiles){if(this.pool.isFull()&&(es(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[e]){const t=this.pool.getObjectForId(i.rtt[e].id);if(t.stamp===i.rtt[e].stamp){this.pool.useObject(t);continue}}const o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),i.rtt[e]={id:o.id,stamp:o.stamp},s.context.bindFramebuffer.set(o.fbo.framebuffer),s.context.clear({color:t.aT.transparent,stencil:0}),s.currentStencilSource=void 0;for(let t=0;t{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd;},xa={showCompass:!0,showZoom:!0,visualizePitch:!1};class ya{constructor(e,s,a=!1){this.mousedown=e=>{this.startMouse(t.e({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),i.mousePos(this.element,e)),i.addEventListener(window,"mousemove",this.mousemove),i.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=t=>{this.moveMouse(t,i.mousePos(this.element,t));},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp();},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=i.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),i.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),i.addEventListener(window,"touchend",this.touchend));},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=i.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos));},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10;const o=e.dragRotate._mouseRotate.getClickTolerance(),r=e.dragRotate._mousePitch.getClickTolerance();this.element=s,this.mouseRotate=As({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const s=new zs;return new Ps({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:s,enable:t,assignEvents:va})})({clickTolerance:o,enable:!0}),this.map=e,a&&(this.mousePitch=Rs({clickTolerance:r,enable:!0}),this.touchPitch=(({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const s=new zs;return new Ps({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:s,enable:t,assignEvents:va})})({clickTolerance:r,enable:!0})),i.addEventListener(s,"mousedown",this.mousedown),i.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),i.addEventListener(s,"touchcancel",this.reset);}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),i.disableDrag();}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),i.disableDrag();}moveMouse(t,e){const i=this.map,{bearingDelta:s}=this.mouseRotate.dragMove(t,e)||{};if(s&&i.setBearing(i.getBearing()+s),this.mousePitch){const{pitchDelta:s}=this.mousePitch.dragMove(t,e)||{};s&&i.setPitch(i.getPitch()+s);}}moveTouch(t,e){const i=this.map,{bearingDelta:s}=this.touchRotate.dragMove(t,e)||{};if(s&&i.setBearing(i.getBearing()+s),this.touchPitch){const{pitchDelta:s}=this.touchPitch.dragMove(t,e)||{};s&&i.setPitch(i.getPitch()+s);}}off(){const t=this.element;i.removeEventListener(t,"mousedown",this.mousedown),i.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),i.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),i.removeEventListener(window,"touchend",this.touchend),i.removeEventListener(t,"touchcancel",this.reset),this.offTemp();}offTemp(){i.enableDrag(),i.removeEventListener(window,"mousemove",this.mousemove),i.removeEventListener(window,"mouseup",this.mouseup),i.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),i.removeEventListener(window,"touchend",this.touchend);}}let ba;function wa(e,i,s){if(e=new t.L(e.lng,e.lat),i){const a=new t.L(e.lng-360,e.lat),o=new t.L(e.lng+360,e.lat),r=s.locationPoint(e).distSqr(i);s.locationPoint(a).distSqr(i)180;){const t=s.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=s.width&&t.y<=s.height)break;e.lng>s.center.lng?e.lng-=360:e.lng+=360;}return e}const Ta={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ia(t,e,i){const s=t.classList;for(const t in Ta)s.remove(`maplibregl-${i}-anchor-${t}`);s.add(`maplibregl-${i}-anchor-${e}`);}class Ea extends t.E{constructor(e){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup();},this._update=t=>{if(!this._map)return;const e=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!e)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=wa(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let s="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?s=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(s=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let a="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?a="rotateX(0deg)":"map"===this._pitchAlignment&&(a=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),i.setTransform(this._element,`${Ta[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${a} ${s}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout((()=>{const t=this._map.unproject(this._pos),e=40075016.686*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=t.distanceTo(this._lngLat)>20*e?"0.2":"1.0",this._opacityTimeout=null;}),100));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.k("dragstart"))),this.fire(new t.k("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.k("dragend")),this._state="inactive";},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=i.create("div"),this._element.setAttribute("aria-label","Map marker");const s=i.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${a}px`),s.setAttributeNS(null,"width",`${o}px`),s.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);const r=i.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"stroke","none"),r.setAttributeNS(null,"stroke-width","1"),r.setAttributeNS(null,"fill","none"),r.setAttributeNS(null,"fill-rule","evenodd");const n=i.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"fill-rule","nonzero");const l=i.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const h=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of h){const e=i.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e);}const c=i.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const u=i.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(u);const d=i.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=i.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=i.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=i.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=i.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=i.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),n.appendChild(l),n.appendChild(c),n.appendChild(d),n.appendChild(p),n.appendChild(m),s.appendChild(n),s.setAttributeNS(null,"height",a*this._scale+"px"),s.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(s),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault();})),this._element.addEventListener("mousedown",(t=>{t.preventDefault();})),Ia(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),i.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.L.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,s=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[s,-1*(e-i+s)],"bottom-right":[-s,-1*(e-i+s)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset;}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(t){this._element.classList.add(t);}removeClassName(t){this._element.classList.remove(t);}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const Sa={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ca=0,Pa=!1;const Da={maxWidth:100,unit:"metric"};function Ma(t,e,i){const s=i&&i.maxWidth||100,a=t._container.clientHeight/2,o=t.unproject([0,a]),r=t.unproject([s,a]),n=o.distanceTo(r);if(i&&"imperial"===i.unit){const i=3.2808*n;i>5280?za(e,s,i/5280,t._getUIString("ScaleControl.Miles")):za(e,s,i,t._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?za(e,s,n/1852,t._getUIString("ScaleControl.NauticalMiles")):n>=1e3?za(e,s,n/1e3,t._getUIString("ScaleControl.Kilometers")):za(e,s,n,t._getUIString("ScaleControl.Meters"));}function za(t,e,i,s){const a=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(a/i)+"px",t.innerHTML=`${a} ${s}`;}const La={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Aa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ra(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ra(new t.P(0,0))}const ka={extend:(e,...i)=>t.e(e,...i),run(t){t();},logToElement(t,e=!1,i="log"){const s=window.document.getElementById(i);s&&(e&&(s.innerHTML=""),s.innerHTML+=`
${t}`);}},Fa=e;class Ba{static get version(){return Fa}static get workerCount(){return tt.workerCount}static set workerCount(t){tt.workerCount=t;}static get maxParallelImageRequests(){return t.c.MAX_PARALLEL_IMAGE_REQUESTS}static set maxParallelImageRequests(e){t.c.MAX_PARALLEL_IMAGE_REQUESTS=e;}static get workerUrl(){return t.c.WORKER_URL}static set workerUrl(e){t.c.WORKER_URL=e;}static addProtocol(e,i){t.c.REGISTERED_PROTOCOLS[e]=i;}static removeProtocol(e){delete t.c.REGISTERED_PROTOCOLS[e];}}return Ba.Map=class extends oa{constructor(e){if(t.bg.mark(t.bh.create),null!=(e=t.e({},ga,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new rs(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._cooperativeGesturesOnWheel=t=>{this._onCooperativeGesture(t,t[this._metaKey],1);},this._contextLost=e=>{e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.k("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.k("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=e.interactive,this._cooperativeGestures=e.cooperativeGestures,this._metaKey=0===navigator.platform.indexOf("Mac")?"metaKey":"ctrlKey",this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new la,this._controls=[],this._mapId=t.a2(),this._locale=t.e({},ha,e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this._imageQueueHandle=h.addThrottleControl((()=>this.isMoving())),this._requestManager=new u(e.transformRequest),"string"==typeof e.container){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else {if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container;}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=ns((t=>{this._trackResize&&!this._removed&&this.resize(t)._update();}),50);this._resizeObserver=new ResizeObserver((i=>{t?e(i):t=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new aa(this,e),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=e.hash&&new ls("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new ra({customAttribution:e.customAttribution})),e.maplibreLogo&&this.addControl(new na,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet);})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.k(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.k(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.k("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const s=e.onAdd(this);this._controls.push(e);const a=this._controlPositions[i];return -1!==i.indexOf("bottom")?a.insertBefore(s,a.firstChild):a.appendChild(s),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,s){return null==s&&this.terrain&&(s=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,s)}resize(e){var i;const s=this._containerDimensions(),a=s[0],o=s[1],r=this._getClampedPixelRatio(a,o);if(this._resizeCanvas(a,o,r),this.painter.resize(a,o,r),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(a,o);this._resizeCanvas(a,o,e),this.painter.resize(a,o,e);}this.transform.resize(a,o),null===(i=this._requestedCameraState)||void 0===i||i.resize(a,o);const n=!this._moving;return n&&(this.stop(),this.fire(new t.k("movestart",e)).fire(new t.k("move",e))),this.fire(new t.k("resize",e)),n&&this.fire(new t.k("moveend",e)),this}_getClampedPixelRatio(t,e){const{0:i,1:s}=this._maxCanvasSize,a=this.getPixelRatio(),o=t*a,r=e*a;return Math.min(o>i?i/o:1,r>s?s/r:1)*a}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(L.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(t){return this._cooperativeGestures=t,this._cooperativeGestures?this._setupCooperativeGestures():this._destroyCooperativeGestures(),this}project(e){return this.transform.locationPoint(t.L.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.pointLocation(t.P.convert(e),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let s=!1;const a=a=>{const o=this.getLayer(e)?this.queryRenderedFeatures(a.point,{layers:[e]}):[];o.length?s||(s=!0,i.call(this,new gs(t,this,a.originalEvent,{features:o}))):s=!1;};return {layer:e,listener:i,delegates:{mousemove:a,mouseout:()=>{s=!1;}}}}if("mouseleave"===t||"mouseout"===t){let s=!1;const a=a=>{(this.getLayer(e)?this.queryRenderedFeatures(a.point,{layers:[e]}):[]).length?s=!0:s&&(s=!1,i.call(this,new gs(t,this,a.originalEvent)));},o=e=>{s&&(s=!1,i.call(this,new gs(t,this,e.originalEvent)));};return {layer:e,listener:i,delegates:{mousemove:a,mouseout:o}}}{const s=t=>{const s=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];s.length&&(t.features=s,i.call(this,t),delete t.features);};return {layer:e,listener:i,delegates:{[t]:s}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const s=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(s);for(const t in s.delegates)this.on(t,s.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const s=this._createDelegatedListener(t,e,i);for(const t in s.delegates)this.once(t,s.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(s=>{const a=this._delegatedListeners[t];for(let t=0;tthis._updateStyle(t,e)));const i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new se(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new se(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const s=this._requestManager.transformRequest(e,c.Style);t.f(s,((e,s)=>{e?this.fire(new t.j(e)):s&&this._updateDiff(s,i);}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(s){t.w(`Unable to perform style diff: ${s.message||s.error||s}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.j(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);for(const i in this.style._layers){const s=this.style._layers[i];"hillshade"===s.type&&s.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new da(this.painter,i,e),this.painter.renderToTexture=new ma(this.painter,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=t=>{"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0;return this.fire(new t.k("terrain",{terrain:e})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return !1}}return !0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,s={}){const{pixelRatio:a=1,sdf:o=!1,stretchX:r,stretchY:n,content:l}=s;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.a(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:s,height:h,data:c}=i,u=i;return this.style.addImage(e,{data:new t.R({width:s,height:h},new Uint8Array(c)),pixelRatio:a,stretchX:r,stretchY:n,content:l,sdf:o,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e),this}}{const{width:s,height:h,data:c}=t.h.getImageData(i);this.style.addImage(e,{data:new t.R({width:s,height:h},c),pixelRatio:a,stretchX:r,stretchY:n,content:l,sdf:o,version:0});}}updateImage(e,i){const s=this.style.getImage(e);if(!s)return this.fire(new t.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=i instanceof HTMLImageElement||t.a(i)?t.h.getImageData(i):i,{width:o,height:r,data:n}=a;if(void 0===o||void 0===r)return this.fire(new t.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==s.data.width||r!==s.data.height)return this.fire(new t.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const l=!(i instanceof HTMLImageElement||t.a(i));return s.data.replace(n,l),this.style.updateImage(e,s),this}getImage(t){return this.style.getImage(t)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.j(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t);}loadImage(t,e){h.getImage(this._requestManager.transformRequest(t,c.Image),e);}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,s={}){return this.style.setPaintProperty(t,e,i,s),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,s={}){return this.style.setLayoutProperty(t,e,i,s),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0);})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0);})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=i.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=i.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const s=this._containerDimensions(),a=this._getClampedPixelRatio(s[0],s[1]);this._resizeCanvas(s[0],s[1],a);const o=this._controlContainer=i.create("div","maplibregl-control-container",t),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{r[t]=i.create("div",`maplibregl-ctrl-${t} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_setupCooperativeGestures(){this._cooperativeGesturesScreen=i.create("div","maplibregl-cooperative-gesture-screen",this._container);let t="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";0===navigator.platform.indexOf("Mac")&&(t="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map"),this._cooperativeGesturesScreen.innerHTML=`\n
${t}
\n
${"boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}
\n `,this._cooperativeGesturesScreen.setAttribute("aria-hidden","true"),this._canvasContainer.addEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.add("maplibregl-cooperative-gestures");}_destroyCooperativeGestures(){i.remove(this._cooperativeGesturesScreen),this._canvasContainer.removeEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.remove("maplibregl-cooperative-gestures");}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`;}_setupPainter(){const t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type);}),{once:!0});const i=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new is(i,this.transform),s.testSupport(i);}_onCooperativeGesture(t,e,i){return !e&&i<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout((()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show");}),100)),!1}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t);}_render(e){const i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let s=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,a=t.h.now();this.style.zoomHistory.update(e,a);const o=new t.a8(e,{now:a,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=o.crossFadingFactor();1===r&&r===this._crossFadingFactor||(s=!0,this._crossFadingFactor=r),this.style.update(o);}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,i,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:i,showPadding:this.showPadding}),this.fire(new t.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.bg.mark(t.bh.load),this.fire(new t.k("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,t.bg.mark(t.bh.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),h.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");s&&s.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),i.remove(this._canvasContainer),i.remove(this._controlContainer),this._cooperativeGestures&&this._destroyCooperativeGestures(),this._container.classList.remove("maplibregl-map"),t.bg.clearMetrics(),this._removed=!0,this.fire(new t.k("remove"));}triggerRepaint(){this.style&&!this._frame&&(this._frame=t.h.frame((e=>{t.bg.frame(e),this._frame=null,this._render(e);})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update());}get showPadding(){return !!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update());}get repaint(){return !!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(t){this._vertices=t,this._update();}get version(){return fa}getCameraTargetElevation(){return this.transform.elevation}},Ba.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t;},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i);},this.options=t.e({},xa,e),this._container=i.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),i.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),i.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t});})),this._compassIcon=i.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ya(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){i.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(t,e){const s=i.create("button",t,this._container);return s.type="button",s.addEventListener("click",e),s}},Ba.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.k("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.L(e.coords.longitude,e.coords.latitude),s=e.coords.accuracy,a=this._map.getBearing(),o=t.e({bearing:a},this.options.fitBoundsOptions),r=L.fromLngLat(i,s);this._map.fitBounds(r,o,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.L(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Pa)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.k("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=e=>{if(this._map){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=i.create("button","maplibregl-ctrl-geolocate",this._container),i.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=i.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ea({element:this._dotElement}),this._circleElement=i.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ea({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.k("trackuserlocationend")));}));}},this.options=t.e({},Sa,e);}onAdd(t){return this._map=t,this._container=i.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(t,e=!1){void 0===ba||e?void 0!==window.navigator.permissions?window.navigator.permissions.query({name:"geolocation"}).then((e=>{ba="denied"!==e.state,t(ba);})).catch((()=>{ba=!!window.navigator.geolocation,t(ba);})):(ba=!!window.navigator.geolocation,t(ba)):t(ba);}(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),i.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ca=0,Pa=!1;}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),s=e.distanceTo(i),a=Math.ceil(this._accuracy/(s/this._map._container.clientHeight)*2);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ca--,Pa=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ca++,Ca>1?(t={maximumAge:6e5,timeout:0},Pa=!0):(t=this.options.positionOptions,Pa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},Ba.AttributionControl=ra,Ba.LogoControl=na,Ba.ScaleControl=class{constructor(e){this._onMove=()=>{Ma(this._map,this._container,this.options);},this.setUnit=t=>{this.options.unit=t,Ma(this._map,this._container,this.options);},this.options=t.e({},Da,e);}getDefaultPosition(){return "bottom-left"}onAdd(t){return this._map=t,this._container=i.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){i.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},Ba.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=i.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){i.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const t=this._fullscreenButton=i.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);i.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.k("fullscreenstart")),this._map._cooperativeGestures&&(this._prevCooperativeGestures=this._map._cooperativeGestures,this._map.setCooperativeGestures())):(this.fire(new t.k("fullscreenend")),this._prevCooperativeGestures&&(this._map.setCooperativeGestures(this._prevCooperativeGestures),delete this._prevCooperativeGestures));}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},Ba.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"));},this.options=t;}onAdd(t){return this._map=t,this._container=i.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=i.create("button","maplibregl-ctrl-terrain",this._container),i.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){i.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},Ba.Popup=class extends t.E{constructor(e){super(),this.remove=()=>(this._content&&i.remove(this._content),this._container&&(i.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new t.k("close")),this),this._onMouseUp=t=>{this._update(t.point);},this._onMouseMove=t=>{this._update(t.point);},this._onDrag=t=>{this._update(t.point);},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=i.create("div","maplibregl-popup",this._map.getContainer()),this._tip=i.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=wa(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const e=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let s=this.options.anchor;const a=Ra(this.options.offset);if(!s){const t=this._container.offsetWidth,i=this._container.offsetHeight;let o;o=e.y+a.bottom.ythis._map.transform.height-i?["bottom"]:[],e.xthis._map.transform.width-t/2&&o.push("right"),s=0===o.length?"bottom":o.join("-");}const o=e.add(a[s]).round();i.setTransform(this._container,`${Ta[s]} translate(${o.x}px,${o.y}px)`),Ia(this._container,s,"popup");},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(La),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.k("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.L.convert(e),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let s;for(i.innerHTML=t;s=i.firstChild,s;)e.appendChild(s);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=i.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t);}removeClassName(t){this._container&&this._container.classList.remove(t);}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}_createCloseButton(){this.options.closeButton&&(this._closeButton=i.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(Aa);t&&t.focus();}},Ba.Marker=Ea,Ba.Style=se,Ba.LngLat=t.L,Ba.LngLatBounds=L,Ba.Point=t.P,Ba.MercatorCoordinate=t.U,Ba.Evented=t.E,Ba.AJAXError=t.bi,Ba.config=t.c,Ba.CanvasSource=Z,Ba.GeoJSONSource=B,Ba.ImageSource=N,Ba.RasterDEMTileSource=F,Ba.RasterTileSource=k,Ba.VectorTileSource=R,Ba.VideoSource=U,Ba.setRTLTextPlugin=t.bj,Ba.getRTLTextPluginStatus=t.bk,Ba.prewarm=function(){st().acquire(J);},Ba.clearPrewarmedResources=function(){const t=it;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(J),it=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},ka.extend(Ba,{isSafari:t.ac,getPerformanceMetrics:t.bg.getPerformanceMetrics}),Ba})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/web/libraries/maplibre-gl/dist/maplibre-gl.js.map b/web/libraries/maplibre-gl/dist/maplibre-gl.js.map new file mode 100644 index 00000000..24ea7c9e --- /dev/null +++ b/web/libraries/maplibre-gl/dist/maplibre-gl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"maplibre-gl.js","sources":["../node_modules/tslib/tslib.es6.js","../node_modules/@mapbox/point-geometry/index.js","../node_modules/@mapbox/unitbezier/index.js","../src/util/offscreen_canvas_supported.ts","../src/util/offscreen_canvas_distorted.ts","../src/util/util.ts","../src/util/browser.ts","../src/util/config.ts","../src/util/ajax.ts","../src/util/evented.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.mjs","../src/style/validate_style.ts","../src/util/transferable_grid_index.ts","../src/util/web_worker_transfer.ts","../src/style/zoom_history.ts","../src/util/is_char_in_unicode_block.ts","../src/util/script_detection.ts","../src/source/rtl_text_plugin.ts","../src/style/evaluation_parameters.ts","../src/style/properties.ts","../src/style/style_layer.ts","../src/util/struct_array.ts","../src/data/array_types.g.ts","../src/data/bucket/circle_attributes.ts","../src/data/segment.ts","../src/shaders/encode_attribute.ts","../src/data/bucket/pattern_attributes.ts","../node_modules/murmurhash-js/murmurhash3_gc.js","../node_modules/murmurhash-js/murmurhash2_gc.js","../node_modules/murmurhash-js/index.js","../src/data/feature_position_map.ts","../src/render/uniform_binding.ts","../src/data/program_configuration.ts","../src/data/extent.ts","../src/data/load_geometry.ts","../src/data/evaluation_feature.ts","../src/data/bucket/circle_bucket.ts","../src/util/intersection_tests.ts","../src/style/query_utils.ts","../src/style/style_layer/circle_style_layer_properties.g.ts","../node_modules/gl-matrix/esm/common.js","../node_modules/gl-matrix/esm/mat4.js","../node_modules/gl-matrix/esm/vec4.js","../src/style/style_layer/circle_style_layer.ts","../src/data/bucket/heatmap_bucket.ts","../src/style/style_layer/heatmap_style_layer_properties.g.ts","../src/util/image.ts","../src/util/color_ramp.ts","../src/style/style_layer/heatmap_style_layer.ts","../src/style/style_layer/hillshade_style_layer_properties.g.ts","../src/style/style_layer/hillshade_style_layer.ts","../src/data/bucket/fill_attributes.ts","../node_modules/earcut/src/earcut.js","../node_modules/quickselect/index.js","../src/util/classify_rings.ts","../src/data/bucket/pattern_bucket_features.ts","../src/data/bucket/fill_bucket.ts","../src/style/style_layer/fill_style_layer_properties.g.ts","../src/style/style_layer/fill_style_layer.ts","../src/data/bucket/fill_extrusion_attributes.ts","../node_modules/@mapbox/vector-tile/lib/vectortilefeature.js","../node_modules/@mapbox/vector-tile/lib/vectortilelayer.js","../node_modules/@mapbox/vector-tile/lib/vectortile.js","../node_modules/@mapbox/vector-tile/index.js","../src/data/bucket/fill_extrusion_bucket.ts","../src/style/style_layer/fill_extrusion_style_layer_properties.g.ts","../src/style/style_layer/fill_extrusion_style_layer.ts","../src/data/bucket/line_attributes.ts","../src/data/bucket/line_attributes_ext.ts","../src/data/bucket/line_bucket.ts","../src/style/style_layer/line_style_layer_properties.g.ts","../src/style/style_layer/line_style_layer.ts","../src/data/bucket/symbol_attributes.ts","../src/symbol/transform_text.ts","../src/util/verticalize_punctuation.ts","../src/symbol/one_em.ts","../node_modules/pbf/index.js","../node_modules/ieee754/index.js","../src/style/parse_glyph_pbf.ts","../node_modules/potpack/index.js","../src/render/image_atlas.ts","../src/symbol/shaping.ts","../src/symbol/symbol_size.ts","../src/style/style_layer/overlap_mode.ts","../src/data/bucket/symbol_bucket.ts","../src/symbol/merge_lines.ts","../src/style/style_layer/symbol_style_layer_properties.g.ts","../src/style/format_section_override.ts","../src/style/style_layer/symbol_style_layer.ts","../src/util/resolve_tokens.ts","../src/style/style_layer/background_style_layer_properties.g.ts","../src/style/style_layer/background_style_layer.ts","../src/style/style_layer/raster_style_layer_properties.g.ts","../src/style/style_layer/raster_style_layer.ts","../src/style/style_layer/custom_style_layer.ts","../src/util/throttled_invoker.ts","../src/geo/lng_lat.ts","../src/geo/mercator_coordinate.ts","../node_modules/@mapbox/whoots-js/index.mjs","../src/source/tile_id.ts","../src/data/dem_data.ts","../src/util/dictionary_coder.ts","../src/util/vectortile_to_geojson.ts","../src/data/feature_index.ts","../src/symbol/clip_line.ts","../src/symbol/anchor.ts","../src/symbol/check_max_angle.ts","../src/symbol/get_anchors.ts","../src/symbol/quads.ts","../src/symbol/collision_feature.ts","../node_modules/tinyqueue/index.js","../src/util/find_pole_of_inaccessibility.ts","../src/style/style_layer/variable_text_anchor.ts","../src/symbol/symbol_layout.ts","../node_modules/kdbush/index.js","../src/util/performance.ts","../src/util/actor.ts","../src/style/create_style_layer.ts","../src/style/style_layer_index.ts","../src/render/glyph_atlas.ts","../src/source/worker_tile.ts","../src/source/vector_tile_worker_source.ts","../src/source/raster_dem_tile_worker_source.ts","../node_modules/@mapbox/geojson-rewind/index.js","../src/source/geojson_wrapper.ts","../node_modules/vt-pbf/lib/geojson_wrapper.js","../node_modules/vt-pbf/index.js","../node_modules/supercluster/index.js","../node_modules/geojson-vt/src/simplify.js","../node_modules/geojson-vt/src/feature.js","../node_modules/geojson-vt/src/convert.js","../node_modules/geojson-vt/src/clip.js","../node_modules/geojson-vt/src/wrap.js","../node_modules/geojson-vt/src/transform.js","../node_modules/geojson-vt/src/tile.js","../node_modules/geojson-vt/src/index.js","../src/source/geojson_source_diff.ts","../src/source/geojson_worker_source.ts","../src/source/worker.ts","../src/util/dom.ts","../src/util/webp_supported.ts","../src/util/image_request.ts","../src/util/request_manager.ts","../node_modules/gl-matrix/esm/vec3.js","../node_modules/gl-matrix/esm/vec2.js","../src/util/style.ts","../src/style/load_sprite.ts","../src/render/texture.ts","../src/style/style_image.ts","../src/render/image_manager.ts","../node_modules/@mapbox/tiny-sdf/index.js","../src/render/glyph_manager.ts","../src/style/load_glyph_range.ts","../src/style/light.ts","../src/render/line_atlas.ts","../src/util/dispatcher.ts","../src/source/load_tilejson.ts","../src/geo/lng_lat_bounds.ts","../src/source/tile_bounds.ts","../src/source/vector_tile_source.ts","../src/source/raster_tile_source.ts","../src/source/raster_dem_tile_source.ts","../src/source/geojson_source.ts","../src/data/raster_bounds_attributes.ts","../src/source/image_source.ts","../src/source/video_source.ts","../src/source/canvas_source.ts","../src/source/source.ts","../src/source/query_features.ts","../src/source/tile.ts","../src/data/bucket.ts","../src/source/tile_cache.ts","../src/source/source_state.ts","../src/source/source_cache.ts","../src/util/worker_pool.ts","../src/util/web_worker.ts","../src/util/global_worker_pool.ts","../src/symbol/path_interpolator.ts","../src/symbol/grid_index.ts","../src/symbol/projection.ts","../src/symbol/collision_index.ts","../src/source/pixels_to_tile_units.ts","../src/symbol/placement.ts","../src/style/pauseable_placement.ts","../src/symbol/cross_tile_symbol_index.ts","../src/style/style.ts","../src/data/pos_attributes.ts","../src/shaders/terrain.vertex.glsl.g.ts","../src/shaders/shaders.ts","../src/shaders/_prelude.fragment.glsl.g.ts","../src/shaders/_prelude.vertex.glsl.g.ts","../src/shaders/background.fragment.glsl.g.ts","../src/shaders/background.vertex.glsl.g.ts","../src/shaders/background_pattern.fragment.glsl.g.ts","../src/shaders/background_pattern.vertex.glsl.g.ts","../src/shaders/circle.fragment.glsl.g.ts","../src/shaders/circle.vertex.glsl.g.ts","../src/shaders/clipping_mask.fragment.glsl.g.ts","../src/shaders/clipping_mask.vertex.glsl.g.ts","../src/shaders/heatmap.fragment.glsl.g.ts","../src/shaders/heatmap.vertex.glsl.g.ts","../src/shaders/heatmap_texture.fragment.glsl.g.ts","../src/shaders/heatmap_texture.vertex.glsl.g.ts","../src/shaders/collision_box.fragment.glsl.g.ts","../src/shaders/collision_box.vertex.glsl.g.ts","../src/shaders/collision_circle.fragment.glsl.g.ts","../src/shaders/collision_circle.vertex.glsl.g.ts","../src/shaders/debug.fragment.glsl.g.ts","../src/shaders/debug.vertex.glsl.g.ts","../src/shaders/fill.fragment.glsl.g.ts","../src/shaders/fill.vertex.glsl.g.ts","../src/shaders/fill_outline.fragment.glsl.g.ts","../src/shaders/fill_outline.vertex.glsl.g.ts","../src/shaders/fill_outline_pattern.fragment.glsl.g.ts","../src/shaders/fill_outline_pattern.vertex.glsl.g.ts","../src/shaders/fill_pattern.fragment.glsl.g.ts","../src/shaders/fill_pattern.vertex.glsl.g.ts","../src/shaders/fill_extrusion.fragment.glsl.g.ts","../src/shaders/fill_extrusion.vertex.glsl.g.ts","../src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts","../src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts","../src/shaders/hillshade_prepare.fragment.glsl.g.ts","../src/shaders/hillshade_prepare.vertex.glsl.g.ts","../src/shaders/hillshade.fragment.glsl.g.ts","../src/shaders/hillshade.vertex.glsl.g.ts","../src/shaders/line.fragment.glsl.g.ts","../src/shaders/line.vertex.glsl.g.ts","../src/shaders/line_gradient.fragment.glsl.g.ts","../src/shaders/line_gradient.vertex.glsl.g.ts","../src/shaders/line_pattern.fragment.glsl.g.ts","../src/shaders/line_pattern.vertex.glsl.g.ts","../src/shaders/line_sdf.fragment.glsl.g.ts","../src/shaders/line_sdf.vertex.glsl.g.ts","../src/shaders/raster.fragment.glsl.g.ts","../src/shaders/raster.vertex.glsl.g.ts","../src/shaders/symbol_icon.fragment.glsl.g.ts","../src/shaders/symbol_icon.vertex.glsl.g.ts","../src/shaders/symbol_sdf.fragment.glsl.g.ts","../src/shaders/symbol_sdf.vertex.glsl.g.ts","../src/shaders/symbol_text_and_icon.fragment.glsl.g.ts","../src/shaders/symbol_text_and_icon.vertex.glsl.g.ts","../src/shaders/terrain.fragment.glsl.g.ts","../src/shaders/terrain_depth.fragment.glsl.g.ts","../src/shaders/terrain_coords.fragment.glsl.g.ts","../src/render/vertex_array_object.ts","../src/render/program.ts","../src/render/program/terrain_program.ts","../src/render/program/pattern.ts","../src/render/program/fill_extrusion_program.ts","../node_modules/gl-matrix/esm/mat3.js","../src/render/program/fill_program.ts","../src/render/program/circle_program.ts","../src/render/program/collision_program.ts","../src/render/program/debug_program.ts","../src/render/program/clipping_mask_program.ts","../src/render/program/heatmap_program.ts","../src/render/program/hillshade_program.ts","../src/render/program/line_program.ts","../src/render/program/raster_program.ts","../src/render/program/symbol_program.ts","../src/render/program/background_program.ts","../src/render/program/program_uniforms.ts","../src/gl/index_buffer.ts","../src/gl/vertex_buffer.ts","../src/gl/webgl2.ts","../src/gl/value.ts","../src/gl/framebuffer.ts","../src/gl/color_mode.ts","../src/gl/context.ts","../src/gl/depth_mode.ts","../src/gl/stencil_mode.ts","../src/gl/cull_face_mode.ts","../src/render/draw_collision_debug.ts","../src/render/draw_symbol.ts","../src/render/update_pattern_positions_in_program.ts","../src/render/draw_fill.ts","../src/render/draw_fill_extrusion.ts","../src/render/draw_hillshade.ts","../src/render/draw_raster.ts","../src/render/draw_debug.ts","../src/render/draw_terrain.ts","../src/render/painter.ts","../src/render/draw_circle.ts","../src/render/draw_heatmap.ts","../src/render/draw_line.ts","../src/render/draw_background.ts","../src/render/draw_custom.ts","../src/util/primitives.ts","../src/geo/edge_insets.ts","../src/geo/transform.ts","../node_modules/gl-matrix/esm/mat2.js","../src/util/throttle.ts","../src/ui/hash.ts","../src/ui/handler_inertia.ts","../src/ui/events.ts","../src/ui/handler/map_event.ts","../src/ui/handler/transform-provider.ts","../src/ui/handler/box_zoom.ts","../src/ui/handler/handler_util.ts","../src/ui/handler/tap_recognizer.ts","../src/ui/handler/tap_zoom.ts","../src/ui/handler/drag_handler.ts","../src/ui/handler/drag_move_state_manager.ts","../src/ui/handler/mouse.ts","../src/ui/handler/touch_pan.ts","../src/ui/handler/two_fingers_touch.ts","../src/ui/handler/keyboard.ts","../src/ui/handler/scroll_zoom.ts","../src/ui/handler/shim/dblclick_zoom.ts","../src/ui/handler/click_zoom.ts","../src/ui/handler/tap_drag_zoom.ts","../src/ui/handler/shim/drag_pan.ts","../src/ui/handler/shim/drag_rotate.ts","../src/ui/handler/shim/two_fingers_touch.ts","../src/ui/handler_manager.ts","../src/ui/camera.ts","../src/ui/control/attribution_control.ts","../src/ui/control/logo_control.ts","../src/util/task_queue.ts","../src/ui/default_locale.ts","../src/data/pos3d_attributes.ts","../src/source/terrain_source_cache.ts","../src/render/terrain.ts","../src/gl/render_pool.ts","../src/render/render_to_texture.ts","../src/ui/map.ts","../src/ui/handler/one_finger_touch_drag.ts","../src/ui/control/navigation_control.ts","../src/util/geolocation_support.ts","../src/util/smart_wrap.ts","../src/ui/anchor.ts","../src/ui/marker.ts","../src/ui/control/geolocate_control.ts","../src/ui/control/scale_control.ts","../src/ui/popup.ts","../src/util/debug.ts","../src/index.ts","../src/ui/control/fullscreen_control.ts","../src/ui/control/terrain_control.ts","../build/rollup/maplibregl.js"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","'use strict';\n\nmodule.exports = Point;\n\n/**\n * A standalone point geometry with useful accessor, comparison, and\n * modification methods.\n *\n * @class Point\n * @param {Number} x the x-coordinate. this could be longitude or screen\n * pixels, or any other sort of unit.\n * @param {Number} y the y-coordinate. this could be latitude or screen\n * pixels, or any other sort of unit.\n * @example\n * var point = new Point(-77, 38);\n */\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n}\n\nPoint.prototype = {\n\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone: function() { return new Point(this.x, this.y); },\n\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add: function(p) { return this.clone()._add(p); },\n\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub: function(p) { return this.clone()._sub(p); },\n\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint: function(p) { return this.clone()._multByPoint(p); },\n\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint: function(p) { return this.clone()._divByPoint(p); },\n\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n mult: function(k) { return this.clone()._mult(k); },\n\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {Point} k factor\n * @return {Point} output point\n */\n div: function(k) { return this.clone()._div(k); },\n\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate: function(a) { return this.clone()._rotate(a); },\n\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {Number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); },\n\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {Array} m transformation matrix\n * @return {Point} output point\n */\n matMult: function(m) { return this.clone()._matMult(m); },\n\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit: function() { return this.clone()._unit(); },\n\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp: function() { return this.clone()._perp(); },\n\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round: function() { return this.clone()._round(); },\n\n /**\n * Return the magitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {Number} magnitude\n */\n mag: function() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals: function(other) {\n return this.x === other.x &&\n this.y === other.y;\n },\n\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {Number} distance\n */\n dist: function(p) {\n return Math.sqrt(this.distSqr(p));\n },\n\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {Number} distance\n */\n distSqr: function(p) {\n var dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {Number} angle\n */\n angle: function() {\n return Math.atan2(this.y, this.x);\n },\n\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleTo: function(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {Number} angle\n */\n angleWith: function(b) {\n return this.angleWithSep(b.x, b.y);\n },\n\n /*\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(θ) for θ.\n * @param {Number} x the x-coordinate\n * @param {Number} y the y-coordinate\n * @return {Number} the angle in radians\n */\n angleWithSep: function(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y);\n },\n\n _matMult: function(m) {\n var x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _add: function(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n\n _sub: function(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n\n _mult: function(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n\n _div: function(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n\n _multByPoint: function(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n\n _divByPoint: function(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n\n _unit: function() {\n this._div(this.mag());\n return this;\n },\n\n _perp: function() {\n var y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n\n _rotate: function(angle) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n _rotateAround: function(angle, p) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n\n _round: function() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n }\n};\n\n/**\n * Construct a point from an array if necessary, otherwise if the input\n * is already a Point, or an unknown type, return it unchanged\n * @param {Array|Point|*} a any kind of input value\n * @return {Point} constructed point, or passed-through value.\n * @example\n * // this\n * var point = Point.convert([0, 1]);\n * // is equivalent to\n * var point = new Point(0, 1);\n */\nPoint.convert = function (a) {\n if (a instanceof Point) {\n return a;\n }\n if (Array.isArray(a)) {\n return new Point(a[0], a[1]);\n }\n return a;\n};\n","'use strict';\n\nmodule.exports = UnitBezier;\n\nfunction UnitBezier(p1x, p1y, p2x, p2y) {\n // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n this.cx = 3.0 * p1x;\n this.bx = 3.0 * (p2x - p1x) - this.cx;\n this.ax = 1.0 - this.cx - this.bx;\n\n this.cy = 3.0 * p1y;\n this.by = 3.0 * (p2y - p1y) - this.cy;\n this.ay = 1.0 - this.cy - this.by;\n\n this.p1x = p1x;\n this.p1y = p1y;\n this.p2x = p2x;\n this.p2y = p2y;\n}\n\nUnitBezier.prototype = {\n sampleCurveX: function (t) {\n // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n return ((this.ax * t + this.bx) * t + this.cx) * t;\n },\n\n sampleCurveY: function (t) {\n return ((this.ay * t + this.by) * t + this.cy) * t;\n },\n\n sampleCurveDerivativeX: function (t) {\n return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n },\n\n solveCurveX: function (x, epsilon) {\n if (epsilon === undefined) epsilon = 1e-6;\n\n if (x < 0.0) return 0.0;\n if (x > 1.0) return 1.0;\n\n var t = x;\n\n // First try a few iterations of Newton's method - normally very fast.\n for (var i = 0; i < 8; i++) {\n var x2 = this.sampleCurveX(t) - x;\n if (Math.abs(x2) < epsilon) return t;\n\n var d2 = this.sampleCurveDerivativeX(t);\n if (Math.abs(d2) < 1e-6) break;\n\n t = t - x2 / d2;\n }\n\n // Fall back to the bisection method for reliability.\n var t0 = 0.0;\n var t1 = 1.0;\n t = x;\n\n for (i = 0; i < 20; i++) {\n x2 = this.sampleCurveX(t);\n if (Math.abs(x2 - x) < epsilon) break;\n\n if (x > x2) {\n t0 = t;\n } else {\n t1 = t;\n }\n\n t = (t1 - t0) * 0.5 + t0;\n }\n\n return t;\n },\n\n solve: function (x, epsilon) {\n return this.sampleCurveY(this.solveCurveX(x, epsilon));\n }\n};\n","let supportsOffscreenCanvas: boolean;\n\nexport function offscreenCanvasSupported(): boolean {\n if (supportsOffscreenCanvas == null) {\n supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&\n new OffscreenCanvas(1, 1).getContext('2d') &&\n typeof createImageBitmap === 'function';\n }\n\n return supportsOffscreenCanvas;\n}\n","import {offscreenCanvasSupported} from './offscreen_canvas_supported';\n\nlet offscreenCanvasDistorted: boolean;\n\n/**\n * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185).\n * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false\n * if they don't match.\n *\n * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise.\n */\nexport function isOffscreenCanvasDistorted(): boolean {\n if (offscreenCanvasDistorted == null) {\n offscreenCanvasDistorted = false;\n if (offscreenCanvasSupported()) {\n const size = 5;\n const canvas = new OffscreenCanvas(size, size);\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (context) {\n // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel):\n // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...]\n for (let i = 0; i < size * size; i++) {\n const base = i * 4;\n context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;\n context.fillRect(i % size, Math.floor(i / size), 1, 1);\n }\n const data = context.getImageData(0, 0, size, size).data;\n for (let i = 0; i < size * size * 4; i++) {\n if (i % 4 !== 3 && data[i] !== i) {\n offscreenCanvasDistorted = true;\n break;\n }\n }\n }\n }\n }\n\n return offscreenCanvasDistorted || false;\n}\n","import Point from '@mapbox/point-geometry';\nimport UnitBezier from '@mapbox/unitbezier';\nimport type {Callback} from '../types/callback';\nimport {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted';\nimport type {Size} from './image';\n\n/**\n * Given a value `t` that varies between 0 and 1, return\n * an interpolation function that eases between 0 and 1 in a pleasing\n * cubic in-out fashion.\n */\nexport function easeCubicInOut(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n const t2 = t * t,\n t3 = t2 * t;\n return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75);\n}\n\n/**\n * Given given (x, y), (x1, y1) control points for a bezier curve,\n * return a function that interpolates along that curve.\n *\n * @param p1x - control point 1 x coordinate\n * @param p1y - control point 1 y coordinate\n * @param p2x - control point 2 x coordinate\n * @param p2y - control point 2 y coordinate\n */\nexport function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {\n const bezier = new UnitBezier(p1x, p1y, p2x, p2y);\n return function(t: number) {\n return bezier.solve(t);\n };\n}\n\n/**\n * A default bezier-curve powered easing function with\n * control points (0.25, 0.1) and (0.25, 1)\n */\nexport const defaultEasing = bezier(0.25, 0.1, 0.25, 1);\n\n/**\n * constrain n to the given range via min + max\n *\n * @param n - value\n * @param min - the minimum value to be returned\n * @param max - the maximum value to be returned\n * @returns the clamped value\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/**\n * constrain n to the given range, excluding the minimum, via modular arithmetic\n *\n * @param n - value\n * @param min - the minimum value to be returned, exclusive\n * @param max - the maximum value to be returned, inclusive\n * @returns constrained number\n */\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((n - min) % d + d) % d + min;\n return (w === min) ? max : w;\n}\n\n/**\n * Call an asynchronous function on an array of arguments,\n * calling `callback` with the completed results of all calls.\n *\n * @param array - input to each call of the async function.\n * @param fn - an async function with signature (data, callback)\n * @param callback - a callback run after all async work is done.\n * called with an array, containing the results of each async call.\n */\nexport function asyncAll(\n array: Array,\n fn: (item: Item, fnCallback: Callback) => void,\n callback: Callback>\n) {\n if (!array.length) { return callback(null, []); }\n let remaining = array.length;\n const results = new Array(array.length);\n let error = null;\n array.forEach((item, i) => {\n fn(item, (err, result) => {\n if (err) error = err;\n results[i] = (result as any as Result); // https://github.com/facebook/flow/issues/2123\n if (--remaining === 0) callback(error, results);\n });\n });\n}\n\n/**\n * Compute the difference between the keys in one object and the keys\n * in another object.\n *\n * @returns keys difference\n */\nexport function keysDifference(\n obj: {[key: string]: S},\n other: {[key: string]: T}\n): Array {\n const difference = [];\n for (const i in obj) {\n if (!(i in other)) {\n difference.push(i);\n }\n }\n return difference;\n}\n\n/**\n * Given a destination object and optionally many source objects,\n * copy all properties from the source objects into the destination.\n * The last source object given overrides properties from previous\n * source objects.\n *\n * @param dest - destination object\n * @param sources - sources from which properties are pulled\n */\nexport function extend(dest: any, ...sources: Array): any {\n for (const src of sources) {\n for (const k in src) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n/**\n * Given an object and a number of properties as strings, return version\n * of that object with only those properties.\n *\n * @param src - the object\n * @param properties - an array of property names chosen\n * to appear on the resulting object.\n * @returns object with limited properties.\n * @example\n * ```ts\n * let foo = { name: 'Charlie', age: 10 };\n * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' }\n * ```\n */\nexport function pick(src: any, properties: Array): any {\n const result = {};\n for (let i = 0; i < properties.length; i++) {\n const k = properties[i];\n if (k in src) {\n result[k] = src[k];\n }\n }\n return result;\n}\n\nlet id = 1;\n\n/**\n * Return a unique numeric id, starting at 1 and incrementing with\n * each call.\n *\n * @returns unique numeric id.\n */\nexport function uniqueId(): number {\n return id++;\n}\n\n/**\n * Return whether a given value is a power of two\n */\nexport function isPowerOfTwo(value: number): boolean {\n return (Math.log(value) / Math.LN2) % 1 === 0;\n}\n\n/**\n * Return the next power of two, or the input value if already a power of two\n */\nexport function nextPowerOfTwo(value: number): number {\n if (value <= 1) return 1;\n return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/**\n * Create an object by mapping all the values of an existing object while\n * preserving their keys.\n */\nexport function mapObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n output[key] = iterator.call(context || this, input[key], key, input);\n }\n return output;\n}\n\n/**\n * Create an object by filtering out values of an existing object.\n */\nexport function filterObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n if (iterator.call(context || this, input[key], key, input)) {\n output[key] = input[key];\n }\n }\n return output;\n}\n\n/**\n * Deeply compares two object literals.\n * @param a - first object literal to be compared\n * @param b - second object literal to be compared\n * @returns true if the two object literals are deeply equal, false otherwise\n */\nexport function deepEqual(a?: unknown | null, b?: unknown | null): boolean {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object')) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key])) return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * Deeply clones two objects.\n */\nexport function clone(input: T): T {\n if (Array.isArray(input)) {\n return input.map(clone) as any as T;\n } else if (typeof input === 'object' && input) {\n return mapObject(input, clone) as any as T;\n } else {\n return input;\n }\n}\n\n/**\n * Check if two arrays have at least one common element.\n */\nexport function arraysIntersect(a: Array, b: Array): boolean {\n for (let l = 0; l < a.length; l++) {\n if (b.indexOf(a[l]) >= 0) return true;\n }\n return false;\n}\n\n/**\n * Print a warning message to the console and ensure duplicate warning messages\n * are not printed.\n */\nconst warnOnceHistory: {[key: string]: boolean} = {};\n\nexport function warnOnce(message: string): void {\n if (!warnOnceHistory[message]) {\n // console isn't defined in some WebWorkers, see #2558\n if (typeof console !== 'undefined') console.warn(message);\n warnOnceHistory[message] = true;\n }\n}\n\n/**\n * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order\n *\n * @returns true for a counter clockwise set of points\n */\n// http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/\nexport function isCounterClockwise(a: Point, b: Point, c: Point): boolean {\n return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x);\n}\n\n/**\n * For two lines a and b in 2d space, defined by any two points along the lines,\n * find the intersection point, or return null if the lines are parallel\n *\n * @param a1 - First point on line a\n * @param a2 - Second point on line a\n * @param b1 - First point on line b\n * @param b2 - Second point on line b\n *\n * @returns the intersection point of the two lines or null if they are parallel\n */\nexport function findLineIntersection(a1: Point, a2: Point, b1: Point, b2: Point): Point | null {\n const aDeltaY = a2.y - a1.y;\n const aDeltaX = a2.x - a1.x;\n const bDeltaY = b2.y - b1.y;\n const bDeltaX = b2.x - b1.x;\n\n const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY);\n\n if (denominator === 0) {\n // Lines are parallel\n return null;\n }\n\n const originDeltaY = a1.y - b1.y;\n const originDeltaX = a1.x - b1.x;\n const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator;\n\n // Find intersection by projecting out from origin of first segment\n return new Point(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY));\n}\n\n/**\n * Returns the signed area for the polygon ring. Positive areas are exterior rings and\n * have a clockwise winding. Negative areas are interior rings and have a counter clockwise\n * ordering.\n *\n * @param ring - Exterior or interior ring\n */\nexport function calculateSignedArea(ring: Array): number {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\n/**\n * Detects closed polygons, first + last point are equal\n *\n * @param points - array of points\n * @returns `true` if the points are a closed polygon\n */\nexport function isClosedPolygon(points: Array): boolean {\n // If it is 2 points that are the same then it is a point\n // If it is 3 points with start and end the same then it is a line\n if (points.length < 4)\n return false;\n\n const p1 = points[0];\n const p2 = points[points.length - 1];\n\n if (Math.abs(p1.x - p2.x) > 0 ||\n Math.abs(p1.y - p2.y) > 0) {\n return false;\n }\n\n // polygon simplification can produce polygons with zero area and more than 3 points\n return Math.abs(calculateSignedArea(points)) > 0.01;\n}\n\n/**\n * Converts spherical coordinates to cartesian coordinates.\n *\n * @param spherical - Spherical coordinates, in [radial, azimuthal, polar]\n * @returns cartesian coordinates in [x, y, z]\n */\n\nexport function sphericalToCartesian([r, azimuthal, polar]: [number, number, number]): {\n x: number;\n y: number;\n z: number;\n} {\n // We abstract \"north\"/\"up\" (compass-wise) to be 0° when really this is 90° (π/2):\n // correct for that here\n azimuthal += 90;\n\n // Convert azimuthal and polar angles to radians\n azimuthal *= Math.PI / 180;\n polar *= Math.PI / 180;\n\n return {\n x: r * Math.cos(azimuthal) * Math.sin(polar),\n y: r * Math.sin(azimuthal) * Math.sin(polar),\n z: r * Math.cos(polar)\n };\n}\n\n/**\n * Returns true if the when run in the web-worker context.\n *\n * @returns `true` if the when run in the web-worker context.\n */\nexport function isWorker(): boolean {\n // @ts-ignore\n return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;\n}\n\n/**\n * Parses data from 'Cache-Control' headers.\n *\n * @param cacheControl - Value of 'Cache-Control' header\n * @returns object containing parsed header info.\n */\n\nexport function parseCacheControl(cacheControl: string): any {\n // Taken from [Wreck](https://github.com/hapijs/wreck)\n const re = /(?:^|(?:\\s*\\,\\s*))([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)(?:\\=(?:([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)|(?:\\\"((?:[^\"\\\\]|\\\\.)*)\\\")))?/g;\n\n const header = {};\n cacheControl.replace(re, ($0, $1, $2, $3) => {\n const value = $2 || $3;\n header[$1] = value ? value.toLowerCase() : true;\n return '';\n });\n\n if (header['max-age']) {\n const maxAge = parseInt(header['max-age'], 10);\n if (isNaN(maxAge)) delete header['max-age'];\n else header['max-age'] = maxAge;\n }\n\n return header;\n}\n\nlet _isSafari = null;\n\n/**\n * Returns true when run in WebKit derived browsers.\n * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to\n * transfer data between WebWorkers and the main thread.\n * https://github.com/mapbox/mapbox-gl-js/issues/8771\n *\n * This should be removed once the underlying Safari issue is fixed.\n *\n * @param scope - Since this function is used both on the main thread and WebWorker context,\n * let the calling scope pass in the global scope object.\n * @returns `true` when run in WebKit derived browsers.\n */\nexport function isSafari(scope: any): boolean {\n if (_isSafari == null) {\n const userAgent = scope.navigator ? scope.navigator.userAgent : null;\n _isSafari = !!scope.safari ||\n !!(userAgent && (/\\b(iPad|iPhone|iPod)\\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome'))));\n }\n return _isSafari;\n}\n\nexport function storageAvailable(type: string): boolean {\n try {\n const storage = window[type];\n storage.setItem('_mapbox_test_', 1);\n storage.removeItem('_mapbox_test_');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n//Unicode compliant base64 encoder for strings\nexport function b64EncodeUnicode(str: string) {\n return btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,\n (match, p1) => {\n return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line\n }\n )\n );\n}\n\n// Unicode compliant decoder for base64-encoded strings\nexport function b64DecodeUnicode(str: string) {\n return decodeURIComponent(atob(str).split('').map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line\n }).join(''));\n}\n\nexport function isImageBitmap(image: any): image is ImageBitmap {\n return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;\n}\n\n/**\n * Converts an ArrayBuffer to an ImageBitmap.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image bitmap (when no error) as the second\n */\nexport function arrayBufferToImageBitmap(data: ArrayBuffer, callback: (err?: Error | null, image?: ImageBitmap | null) => void) {\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n createImageBitmap(blob).then((imgBitmap) => {\n callback(null, imgBitmap);\n }).catch((e) => {\n callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));\n });\n}\n\nconst transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';\n\n/**\n * Converts an ArrayBuffer to an HTMLImageElement.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image element (when no error) as the second\n */\nexport function arrayBufferToImage(data: ArrayBuffer, callback: (err?: Error | null, image?: HTMLImageElement | null) => void) {\n const img: HTMLImageElement = new Image();\n img.onload = () => {\n callback(null, img);\n URL.revokeObjectURL(img.src);\n // prevent image dataURI memory leak in Safari;\n // but don't free the image immediately because it might be uploaded in the next frame\n // https://github.com/mapbox/mapbox-gl-js/issues/10226\n img.onload = null;\n window.requestAnimationFrame(() => { img.src = transparentPngUrl; });\n };\n img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;\n}\n\n/**\n * Computes the webcodecs VideoFrame API options to select a rectangle out of\n * an image and write it into the destination rectangle.\n *\n * Rect (x/y/width/height) select the overlapping rectangle from the source image\n * and layout (offset/stride) write that overlapping rectangle to the correct place\n * in the destination image.\n *\n * Offset is the byte offset in the dest image that the first pixel appears at\n * and stride is the number of bytes to the start of the next row:\n * ┌───────────┐\n * │ dest │\n * │ ┌───┼───────┐\n * │offset→│▓▓▓│ source│\n * │ │▓▓▓│ │\n * │ └───┼───────┘\n * │stride ⇠╌╌╌│\n * │╌╌╌╌╌╌→ │\n * └───────────┘\n *\n * @param image - source image containing a width and height attribute\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns the layout and rect options to pass into VideoFrame API\n */\nfunction computeVideoFrameParameters(image: Size, x: number, y: number, width: number, height: number): VideoFrameCopyToOptions {\n const destRowOffset = Math.max(-x, 0) * 4;\n const firstSourceRow = Math.max(0, y);\n const firstDestRow = firstSourceRow - y;\n const offset = firstDestRow * width * 4 + destRowOffset;\n const stride = width * 4;\n\n const sourceLeft = Math.max(0, x);\n const sourceTop = Math.max(0, y);\n const sourceRight = Math.min(image.width, x + width);\n const sourceBottom = Math.min(image.height, y + height);\n return {\n rect: {\n x: sourceLeft,\n y: sourceTop,\n width: sourceRight - sourceLeft,\n height: sourceBottom - sourceTop\n },\n layout: [{offset, stride}]\n };\n}\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport async function readImageUsingVideoFrame(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (typeof VideoFrame === 'undefined') {\n throw new Error('VideoFrame not supported');\n }\n const frame = new VideoFrame(image, {timestamp: 0});\n try {\n const format = frame?.format;\n if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {\n throw new Error(`Unrecognized format ${format}`);\n }\n const swapBR = format.startsWith('BGR');\n const result = new Uint8ClampedArray(width * height * 4);\n await frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));\n if (swapBR) {\n for (let i = 0; i < result.length; i += 4) {\n const tmp = result[i];\n result[i] = result[i + 2];\n result[i + 2] = tmp;\n }\n }\n return result;\n } finally {\n frame.close();\n }\n}\n\nlet offscreenCanvas: OffscreenCanvas;\nlet offscreenCanvasContext: OffscreenCanvasRenderingContext2D;\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport function readImageDataUsingOffscreenCanvas(\n imgBitmap: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Uint8ClampedArray {\n const origWidth = imgBitmap.width;\n const origHeight = imgBitmap.height;\n // Lazily initialize OffscreenCanvas\n if (!offscreenCanvas || !offscreenCanvasContext) {\n // Dem tiles are typically 256x256\n offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);\n offscreenCanvasContext = offscreenCanvas.getContext('2d', {willReadFrequently: true});\n }\n\n offscreenCanvas.width = origWidth;\n offscreenCanvas.height = origHeight;\n\n offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);\n const imgData = offscreenCanvasContext.getImageData(x, y, width, height);\n offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);\n return imgData.data;\n}\n\n/**\n * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and\n * the browser is mangling OffscreenCanvas getImageData results.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image\n */\nexport async function getImageData(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise {\n if (isOffscreenCanvasDistorted()) {\n try {\n return await readImageUsingVideoFrame(image, x, y, width, height);\n } catch (e) {\n // fall back to OffscreenCanvas\n }\n }\n return readImageDataUsingOffscreenCanvas(image, x, y, width, height);\n}\n","import type {Cancelable} from '../types/cancelable';\n\nconst now = typeof performance !== 'undefined' && performance && performance.now ?\n performance.now.bind(performance) :\n Date.now.bind(Date);\n\nlet linkEl;\n\nlet reducedMotionQuery: MediaQueryList;\n\n/** */\nexport const browser = {\n /**\n * Provides a function that outputs milliseconds: either performance.now()\n * or a fallback to Date.now()\n */\n now,\n\n frame(fn: (paintStartTimestamp: number) => void): Cancelable {\n const frame = requestAnimationFrame(fn);\n return {cancel: () => cancelAnimationFrame(frame)};\n },\n\n getImageData(img: HTMLImageElement | ImageBitmap, padding: number = 0): ImageData {\n const context = this.getImageCanvasContext(img);\n return context.getImageData(-padding, -padding, img.width as number + 2 * padding, img.height as number + 2 * padding);\n },\n\n getImageCanvasContext(img: HTMLImageElement | ImageBitmap): CanvasRenderingContext2D {\n const canvas = window.document.createElement('canvas') as HTMLCanvasElement;\n const context = canvas.getContext('2d', {willReadFrequently: true});\n if (!context) {\n throw new Error('failed to create canvas 2d context');\n }\n canvas.width = img.width as number;\n canvas.height = img.height as number;\n context.drawImage(img, 0, 0, img.width as number, img.height as number);\n return context;\n },\n\n resolveURL(path: string) {\n if (!linkEl) linkEl = document.createElement('a');\n linkEl.href = path;\n return linkEl.href;\n },\n\n hardwareConcurrency: typeof navigator !== 'undefined' && navigator.hardwareConcurrency || 4,\n\n get prefersReducedMotion(): boolean {\n // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util'\n if (!matchMedia) return false;\n //Lazily initialize media query\n if (reducedMotionQuery == null) {\n reducedMotionQuery = matchMedia('(prefers-reduced-motion: reduce)');\n }\n return reducedMotionQuery.matches;\n },\n};\n","import type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from './ajax';\n\n/**\n * This is a global config object used to store the configuration\n * It is available in the workers as well.\n * Only serializable data should be stored in it.\n */\ntype Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: number;\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number;\n MAX_TILE_CACHE_ZOOM_LEVELS: number;\n REGISTERED_PROTOCOLS: {[x: string]: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable};\n WORKER_URL: string;\n};\n\nexport const config: Config = {\n MAX_PARALLEL_IMAGE_REQUESTS: 16,\n MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8,\n MAX_TILE_CACHE_ZOOM_LEVELS: 5,\n REGISTERED_PROTOCOLS: {},\n WORKER_URL: ''\n};\n","import {extend, warnOnce, isWorker} from './util';\nimport {config} from './config';\n\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\n/**\n * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks.\n * @example\n * ```ts\n * // use transformRequest to modify requests that begin with `http://myHost`\n * transformRequest: function(url, resourceType) {\n * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true },\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * ```\n */\nexport type RequestParameters = {\n /**\n * The URL to be requested.\n */\n url: string;\n /**\n * The headers to be sent with the request.\n */\n headers?: any;\n /**\n * Request method `'GET' | 'POST' | 'PUT'`.\n */\n method?: 'GET' | 'POST' | 'PUT';\n /**\n * Request body.\n */\n body?: string;\n /**\n * Response body type to be returned `'string' | 'json' | 'arrayBuffer'`.\n */\n type?: 'string' | 'json' | 'arrayBuffer' | 'image';\n /**\n * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests.\n */\n credentials?: 'same-origin' | 'include';\n /**\n * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events.\n */\n collectResourceTiming?: boolean;\n /**\n * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)\n */\n cache?: RequestCache;\n};\n\n/**\n * The response callback used in various places\n */\nexport type ResponseCallback = (\n error?: Error | null,\n data?: T | null,\n cacheControl?: string | null,\n expires?: string | null\n) => void;\n\n/**\n * An error thrown when a HTTP request results in an error response.\n */\nexport class AJAXError extends Error {\n /**\n * The response's HTTP status code.\n */\n status: number;\n\n /**\n * The response's HTTP status text.\n */\n statusText: string;\n\n /**\n * The request's URL.\n */\n url: string;\n\n /**\n * The response's body.\n */\n body: Blob;\n\n /**\n * @param status - The response's HTTP status code.\n * @param statusText - The response's HTTP status text.\n * @param url - The request's URL.\n * @param body - The response's body.\n */\n constructor(status: number, statusText: string, url: string, body: Blob) {\n super(`AJAXError: ${statusText} (${status}): ${url}`);\n this.status = status;\n this.statusText = statusText;\n this.url = url;\n this.body = body;\n }\n}\n\n// Ensure that we're sending the correct referrer from blob URL worker bundles.\n// For files loaded from the local file system, `location.origin` will be set\n// to the string(!) \"null\" (Firefox), or \"file://\" (Chrome, Safari, Edge, IE),\n// and we will set an empty referrer. Otherwise, we're using the document's URL.\n/* global self */\nexport const getReferrer = isWorker() ?\n () => (self as any).worker && (self as any).worker.referrer :\n () => (window.location.protocol === 'blob:' ? window.parent : window).location.href;\n\nexport const getProtocolAction = url => config.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))];\n\n// Determines whether a URL is a file:// URL. This is obviously the case if it begins\n// with file://. Relative URLs are also file:// URLs iff the original document was loaded\n// via a file:// URL.\nconst isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\\w+:/.test(url));\n\nfunction makeFetchRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const controller = new AbortController();\n const request = new Request(requestParameters.url, {\n method: requestParameters.method || 'GET',\n body: requestParameters.body,\n credentials: requestParameters.credentials,\n headers: requestParameters.headers,\n cache: requestParameters.cache,\n referrer: getReferrer(),\n signal: controller.signal\n });\n let complete = false;\n let aborted = false;\n\n if (requestParameters.type === 'json') {\n request.headers.set('Accept', 'application/json');\n }\n\n const validateOrFetch = (err, cachedResponse?, responseIsFresh?) => {\n if (aborted) return;\n\n if (err) {\n // Do fetch in case of cache error.\n // HTTP pages in Edge trigger a security error that can be ignored.\n if (err.message !== 'SecurityError') {\n warnOnce(err);\n }\n }\n\n if (cachedResponse && responseIsFresh) {\n return finishRequest(cachedResponse);\n }\n\n if (cachedResponse) {\n // We can't do revalidation with 'If-None-Match' because then the\n // request doesn't have simple cors headers.\n }\n\n fetch(request).then(response => {\n if (response.ok) {\n return finishRequest(response);\n\n } else {\n return response.blob().then(body => callback(new AJAXError(response.status, response.statusText, requestParameters.url, body)));\n }\n }).catch(error => {\n if (error.code === 20) {\n // silence expected AbortError\n return;\n }\n callback(new Error(error.message));\n });\n };\n\n const finishRequest = (response) => {\n (\n (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') ? response.arrayBuffer() :\n requestParameters.type === 'json' ? response.json() :\n response.text()\n ).then(result => {\n if (aborted) return;\n complete = true;\n callback(null, result, response.headers.get('Cache-Control'), response.headers.get('Expires'));\n }).catch(err => {\n if (!aborted) callback(new Error(err.message));\n });\n };\n\n validateOrFetch(null, null);\n\n return {cancel: () => {\n aborted = true;\n if (!complete) controller.abort();\n }};\n}\n\nfunction makeXMLHttpRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n const xhr: XMLHttpRequest = new XMLHttpRequest();\n\n xhr.open(requestParameters.method || 'GET', requestParameters.url, true);\n if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') {\n xhr.responseType = 'arraybuffer';\n }\n for (const k in requestParameters.headers) {\n xhr.setRequestHeader(k, requestParameters.headers[k]);\n }\n if (requestParameters.type === 'json') {\n xhr.responseType = 'text';\n xhr.setRequestHeader('Accept', 'application/json');\n }\n xhr.withCredentials = requestParameters.credentials === 'include';\n xhr.onerror = () => {\n callback(new Error(xhr.statusText));\n };\n xhr.onload = () => {\n if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) {\n let data: unknown = xhr.response;\n if (requestParameters.type === 'json') {\n // We're manually parsing JSON here to get better error messages.\n try {\n data = JSON.parse(xhr.response);\n } catch (err) {\n return callback(err);\n }\n }\n callback(null, data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires'));\n } else {\n const body = new Blob([xhr.response], {type: xhr.getResponseHeader('Content-Type')});\n callback(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body));\n }\n };\n xhr.send(requestParameters.body);\n return {cancel: () => xhr.abort()};\n}\n\nexport const makeRequest = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n // We're trying to use the Fetch API if possible. However, in some situations we can't use it:\n // - IE11 doesn't support it at all. In this case, we dispatch the request to the main thread so\n // that we can get an accruate referrer header.\n // - Safari exposes window.AbortController, but it doesn't work actually abort any requests in\n // some versions (see https://bugs.webkit.org/show_bug.cgi?id=174980#c2)\n // - Requests for resources with the file:// URI scheme don't work with the Fetch API either. In\n // this case we unconditionally use XHR on the current thread since referrers don't matter.\n if (/:\\/\\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) {\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n return (self as any).worker.actor.send('getResource', requestParameters, callback);\n }\n if (!isWorker()) {\n const action = getProtocolAction(requestParameters.url) || makeFetchRequest;\n return action(requestParameters, callback);\n }\n }\n if (!isFileURL(requestParameters.url)) {\n if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) {\n return makeFetchRequest(requestParameters, callback);\n }\n if (isWorker() && (self as any).worker && (self as any).worker.actor) {\n const queueOnMainThread = true;\n return (self as any).worker.actor.send('getResource', requestParameters, callback, undefined, queueOnMainThread);\n }\n }\n return makeXMLHttpRequest(requestParameters, callback);\n};\n\nexport const getJSON = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'json'}), callback);\n};\n\nexport const getArrayBuffer = function(\n requestParameters: RequestParameters,\n callback: ResponseCallback\n): Cancelable {\n return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), callback);\n};\n\nexport const postData = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(extend(requestParameters, {method: 'POST'}), callback);\n};\n\nexport function sameOrigin(inComingUrl: string) {\n // URL class should be available everywhere\n // https://developer.mozilla.org/en-US/docs/Web/API/URL\n // In addtion, a relative URL \"/foo\" or \"./foo\" will throw exception in its ctor,\n // try-catch is expansive so just use a heuristic check to avoid it\n // also check data URL\n if (!inComingUrl ||\n inComingUrl.indexOf('://') <= 0 || // relative URL\n inComingUrl.indexOf('data:image/') === 0 || // data image URL\n inComingUrl.indexOf('blob:') === 0) { // blob\n return true;\n }\n const urlObj = new URL(inComingUrl);\n const locationObj = window.location;\n return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host;\n}\n/**\n * A type used to store the tile's expiration date and cache control definition\n */\nexport type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null};\nexport const getVideo = function(urls: Array, callback: Callback): Cancelable {\n const video: HTMLVideoElement = window.document.createElement('video');\n video.muted = true;\n video.onloadstart = function() {\n callback(null, video);\n };\n for (let i = 0; i < urls.length; i++) {\n const s: HTMLSourceElement = window.document.createElement('source');\n if (!sameOrigin(urls[i])) {\n video.crossOrigin = 'Anonymous';\n }\n s.src = urls[i];\n video.appendChild(s);\n }\n return {cancel: () => {}};\n};\n","import {extend} from './util';\n\n/**\n * A listener method used as a callback to events\n */\nexport type Listener = (a: any) => any;\n\ntype Listeners = {[_: string]: Array};\n\nfunction _addEventListener(type: string, listener: Listener, listenerList: Listeners) {\n const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;\n if (!listenerExists) {\n listenerList[type] = listenerList[type] || [];\n listenerList[type].push(listener);\n }\n}\n\nfunction _removeEventListener(type: string, listener: Listener, listenerList: Listeners) {\n if (listenerList && listenerList[type]) {\n const index = listenerList[type].indexOf(listener);\n if (index !== -1) {\n listenerList[type].splice(index, 1);\n }\n }\n}\n\n/**\n * The event class\n */\nexport class Event {\n readonly type: string;\n\n constructor(type: string, data: any = {}) {\n extend(this, data);\n this.type = type;\n }\n}\n\ninterface ErrorLike {\n message: string;\n}\n\n/**\n * An error event\n */\nexport class ErrorEvent extends Event {\n error: ErrorLike;\n\n constructor(error: ErrorLike, data: any = {}) {\n super('error', extend({error}, data));\n }\n}\n\n/**\n * Methods mixed in to other classes for event capabilities.\n *\n * @group Event Related\n */\nexport class Evented {\n _listeners: Listeners;\n _oneTimeListeners: Listeners;\n _eventedParent: Evented;\n _eventedParentData: any | (() => any);\n\n /**\n * Adds a listener to a specified event type.\n *\n * @param type - The event type to add a listen for.\n * @param listener - The function to be called when the event is fired.\n * The listener function is called with the data object passed to `fire`,\n * extended with `target` and `type` properties.\n * @returns `this`\n */\n on(type: string, listener: Listener): this {\n this._listeners = this._listeners || {};\n _addEventListener(type, listener, this._listeners);\n\n return this;\n }\n\n /**\n * Removes a previously registered event listener.\n *\n * @param type - The event type to remove listeners for.\n * @param listener - The listener function to remove.\n * @returns `this`\n */\n off(type: string, listener: Listener) {\n _removeEventListener(type, listener, this._listeners);\n _removeEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type.\n *\n * The listener will be called first time the event fires after the listener is registered.\n *\n * @param type - The event type to listen for.\n * @param listener - The function to be called when the event is fired the first time.\n * @returns `this` or a promise if a listener is not provided\n */\n once(type: string, listener?: Listener): this | Promise {\n if (!listener) {\n return new Promise((resolve) => this.once(type, resolve));\n }\n this._oneTimeListeners = this._oneTimeListeners || {};\n _addEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n fire(event: Event | string, properties?: any) {\n // Compatibility with (type: string, properties: Object) signature from previous versions.\n // See https://github.com/mapbox/mapbox-gl-js/issues/6522,\n // https://github.com/mapbox/mapbox-gl-draw/issues/766\n if (typeof event === 'string') {\n event = new Event(event, properties || {});\n }\n\n const type = event.type;\n\n if (this.listens(type)) {\n (event as any).target = this;\n\n // make sure adding or removing listeners inside other listeners won't cause an infinite loop\n const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];\n for (const listener of listeners) {\n listener.call(this, event);\n }\n\n const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];\n for (const listener of oneTimeListeners) {\n _removeEventListener(type, listener, this._oneTimeListeners);\n listener.call(this, event);\n }\n\n const parent = this._eventedParent;\n if (parent) {\n extend(\n event,\n typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData\n );\n parent.fire(event);\n }\n\n // To ensure that no error events are dropped, print them to the\n // console if they have no listeners.\n } else if (event instanceof ErrorEvent) {\n console.error(event.error);\n }\n\n return this;\n }\n\n /**\n * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.\n *\n * @param type - The event type\n * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise\n */\n listens(type: string): boolean {\n return (\n (this._listeners && this._listeners[type] && this._listeners[type].length > 0) ||\n (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) ||\n (this._eventedParent && this._eventedParent.listens(type))\n );\n }\n\n /**\n * Bubble all events fired by this instance of Evented to this parent instance of Evented.\n * @returns `this`\n */\n setEventedParent(parent?: Evented | null, data?: any | (() => any)) {\n this._eventedParent = parent;\n this._eventedParentData = data;\n\n return this;\n }\n}\n","import UnitBezier from '@mapbox/unitbezier';\n\nvar $version = 8;\nvar $root = {\n\tversion: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: [\n\t\t\t8\n\t\t]\n\t},\n\tname: {\n\t\ttype: \"string\"\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tcenter: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\"\n\t},\n\tzoom: {\n\t\ttype: \"number\"\n\t},\n\tbearing: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\"\n\t},\n\tpitch: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"degrees\"\n\t},\n\tlight: {\n\t\ttype: \"light\"\n\t},\n\tterrain: {\n\t\ttype: \"terrain\"\n\t},\n\tsources: {\n\t\trequired: true,\n\t\ttype: \"sources\"\n\t},\n\tsprite: {\n\t\ttype: \"sprite\"\n\t},\n\tglyphs: {\n\t\ttype: \"string\"\n\t},\n\ttransition: {\n\t\ttype: \"transition\"\n\t},\n\tlayers: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"layer\"\n\t}\n};\nvar sources = {\n\t\"*\": {\n\t\ttype: \"source\"\n\t}\n};\nvar source = [\n\t\"source_vector\",\n\t\"source_raster\",\n\t\"source_raster_dem\",\n\t\"source_geojson\",\n\t\"source_video\",\n\t\"source_image\"\n];\nvar source_vector = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvector: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\traster: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster_dem = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\t\"raster-dem\": {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tencoding: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tterrarium: {\n\t\t\t},\n\t\t\tmapbox: {\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"mapbox\"\n\t},\n\tredFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tblueFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tgreenFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tbaseShift: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_geojson = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tgeojson: {\n\t\t\t}\n\t\t}\n\t},\n\tdata: {\n\t\trequired: true,\n\t\ttype: \"*\"\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 18\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tbuffer: {\n\t\ttype: \"number\",\n\t\t\"default\": 128,\n\t\tmaximum: 512,\n\t\tminimum: 0\n\t},\n\tfilter: {\n\t\ttype: \"*\"\n\t},\n\ttolerance: {\n\t\ttype: \"number\",\n\t\t\"default\": 0.375\n\t},\n\tcluster: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tclusterRadius: {\n\t\ttype: \"number\",\n\t\t\"default\": 50,\n\t\tminimum: 0\n\t},\n\tclusterMaxZoom: {\n\t\ttype: \"number\"\n\t},\n\tclusterMinPoints: {\n\t\ttype: \"number\"\n\t},\n\tclusterProperties: {\n\t\ttype: \"*\"\n\t},\n\tlineMetrics: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tgenerateId: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t}\n};\nvar source_video = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvideo: {\n\t\t\t}\n\t\t}\n\t},\n\turls: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar source_image = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\timage: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\trequired: true,\n\t\ttype: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar layer = {\n\tid: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tfill: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\tsymbol: {\n\t\t\t},\n\t\t\tcircle: {\n\t\t\t},\n\t\t\theatmap: {\n\t\t\t},\n\t\t\t\"fill-extrusion\": {\n\t\t\t},\n\t\t\traster: {\n\t\t\t},\n\t\t\thillshade: {\n\t\t\t},\n\t\t\tbackground: {\n\t\t\t}\n\t\t},\n\t\trequired: true\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tsource: {\n\t\ttype: \"string\"\n\t},\n\t\"source-layer\": {\n\t\ttype: \"string\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tfilter: {\n\t\ttype: \"filter\"\n\t},\n\tlayout: {\n\t\ttype: \"layout\"\n\t},\n\tpaint: {\n\t\ttype: \"paint\"\n\t}\n};\nvar layout = [\n\t\"layout_fill\",\n\t\"layout_line\",\n\t\"layout_circle\",\n\t\"layout_heatmap\",\n\t\"layout_fill-extrusion\",\n\t\"layout_symbol\",\n\t\"layout_raster\",\n\t\"layout_hillshade\",\n\t\"layout_background\"\n];\nvar layout_background = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_fill = {\n\t\"fill-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_circle = {\n\t\"circle-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_heatmap = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_line = {\n\t\"line-cap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbutt: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tsquare: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"butt\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-join\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbevel: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tmiter: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"miter\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-miter-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"miter\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-round-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.05,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"round\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_symbol = {\n\t\"symbol-placement\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tpoint: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\t\"line-center\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"point\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 250,\n\t\tminimum: 1,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"symbol-placement\": \"line\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-avoid-edges\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"symbol-z-order\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\t\"viewport-y\": {\n\t\t\t},\n\t\t\tsource: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"!\": \"icon-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tunits: \"factor of the original icon size\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-text-fit\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\twidth: {\n\t\t\t},\n\t\t\theight: {\n\t\t\t},\n\t\t\tboth: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-text-fit-padding\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"icon-text-fit\": [\n\t\t\t\t\t\"both\",\n\t\t\t\t\t\"width\",\n\t\t\t\t\t\"height\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-image\": {\n\t\ttype: \"resolvedImage\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-padding\": {\n\t\ttype: \"padding\",\n\t\t\"default\": [\n\t\t\t2\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"icon-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\t\"viewport-glyph\": {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-field\": {\n\t\ttype: \"formatted\",\n\t\t\"default\": \"\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-font\": {\n\t\ttype: \"array\",\n\t\tvalue: \"string\",\n\t\t\"default\": [\n\t\t\t\"Open Sans Regular\",\n\t\t\t\"Arial Unicode MS Regular\"\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 16,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 10,\n\t\tminimum: 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-line-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.2,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-letter-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-justify\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-radial-offset\": {\n\t\ttype: \"number\",\n\t\tunits: \"ems\",\n\t\t\"default\": 0,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\t\"property-type\": \"data-driven\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t}\n\t},\n\t\"text-variable-anchor\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-variable-anchor-offset\": {\n\t\ttype: \"variableAnchorOffsetCollection\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-variable-anchor\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-angle\": {\n\t\ttype: \"number\",\n\t\t\"default\": 45,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-writing-mode\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\thorizontal: {\n\t\t\t},\n\t\t\tvertical: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-padding\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"text-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-transform\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\tuppercase: {\n\t\t\t},\n\t\t\tlowercase: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tunits: \"ems\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-radial-offset\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_raster = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar layout_hillshade = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n};\nvar filter = {\n\ttype: \"array\",\n\tvalue: \"*\"\n};\nvar filter_operator = {\n\ttype: \"enum\",\n\tvalues: {\n\t\t\"==\": {\n\t\t},\n\t\t\"!=\": {\n\t\t},\n\t\t\">\": {\n\t\t},\n\t\t\">=\": {\n\t\t},\n\t\t\"<\": {\n\t\t},\n\t\t\"<=\": {\n\t\t},\n\t\t\"in\": {\n\t\t},\n\t\t\"!in\": {\n\t\t},\n\t\tall: {\n\t\t},\n\t\tany: {\n\t\t},\n\t\tnone: {\n\t\t},\n\t\thas: {\n\t\t},\n\t\t\"!has\": {\n\t\t},\n\t\twithin: {\n\t\t}\n\t}\n};\nvar geometry_type = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tPoint: {\n\t\t},\n\t\tLineString: {\n\t\t},\n\t\tPolygon: {\n\t\t}\n\t}\n};\nvar function_stop = {\n\ttype: \"array\",\n\tminimum: 0,\n\tmaximum: 24,\n\tvalue: [\n\t\t\"number\",\n\t\t\"color\"\n\t],\n\tlength: 2\n};\nvar expression$1 = {\n\ttype: \"array\",\n\tvalue: \"*\",\n\tminimum: 1\n};\nvar light = {\n\tanchor: {\n\t\ttype: \"enum\",\n\t\t\"default\": \"viewport\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tposition: {\n\t\ttype: \"array\",\n\t\t\"default\": [\n\t\t\t1.15,\n\t\t\t210,\n\t\t\t30\n\t\t],\n\t\tlength: 3,\n\t\tvalue: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tcolor: {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\tintensity: {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar terrain = {\n\tsource: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\texaggeration: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\t\"default\": 1\n\t}\n};\nvar paint = [\n\t\"paint_fill\",\n\t\"paint_line\",\n\t\"paint_circle\",\n\t\"paint_heatmap\",\n\t\"paint_fill-extrusion\",\n\t\"paint_symbol\",\n\t\"paint_raster\",\n\t\"paint_hillshade\",\n\t\"paint_background\"\n];\nvar paint_fill = {\n\t\"fill-antialias\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-outline-color\": {\n\t\ttype: \"color\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fill-antialias\": true\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t}\n};\nvar paint_line = {\n\t\"line-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"line-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-gap-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-offset\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-dasharray\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"line widths\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"line-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-gradient\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-dasharray\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"geojson\",\n\t\t\t\thas: {\n\t\t\t\t\tlineMetrics: true\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"line-progress\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n};\nvar paint_circle = {\n\t\"circle-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 5,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"circle-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-scale\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-stroke-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t}\n};\nvar paint_heatmap = {\n\t\"heatmap-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 30,\n\t\tminimum: 1,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-weight\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-intensity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"heatmap-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": [\n\t\t\t\"interpolate\",\n\t\t\t[\n\t\t\t\t\"linear\"\n\t\t\t],\n\t\t\t[\n\t\t\t\t\"heatmap-density\"\n\t\t\t],\n\t\t\t0,\n\t\t\t\"rgba(0, 0, 255, 0)\",\n\t\t\t0.1,\n\t\t\t\"royalblue\",\n\t\t\t0.3,\n\t\t\t\"cyan\",\n\t\t\t0.5,\n\t\t\t\"lime\",\n\t\t\t0.7,\n\t\t\t\"yellow\",\n\t\t\t1,\n\t\t\t\"red\"\n\t\t],\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"heatmap-density\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t},\n\t\"heatmap-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_symbol = {\n\t\"icon-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"icon-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\toverridable: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"text-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_raster = {\n\t\"raster-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-hue-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\ttransition: true,\n\t\tunits: \"degrees\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-min\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-max\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-saturation\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-contrast\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-resampling\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tlinear: {\n\t\t\t},\n\t\t\tnearest: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"linear\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-fade-duration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\tunits: \"milliseconds\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_hillshade = {\n\t\"hillshade-illumination-direction\": {\n\t\ttype: \"number\",\n\t\t\"default\": 335,\n\t\tminimum: 0,\n\t\tmaximum: 359,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-exaggeration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-shadow-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-highlight-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#FFFFFF\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-accent-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_background = {\n\t\"background-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"background-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"background-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"background-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar transition = {\n\tduration: {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t},\n\tdelay: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t}\n};\nvar promoteId = {\n\t\"*\": {\n\t\ttype: \"string\"\n\t}\n};\nvar v8Spec = {\n\t$version: $version,\n\t$root: $root,\n\tsources: sources,\n\tsource: source,\n\tsource_vector: source_vector,\n\tsource_raster: source_raster,\n\tsource_raster_dem: source_raster_dem,\n\tsource_geojson: source_geojson,\n\tsource_video: source_video,\n\tsource_image: source_image,\n\tlayer: layer,\n\tlayout: layout,\n\tlayout_background: layout_background,\n\tlayout_fill: layout_fill,\n\tlayout_circle: layout_circle,\n\tlayout_heatmap: layout_heatmap,\n\t\"layout_fill-extrusion\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n},\n\tlayout_line: layout_line,\n\tlayout_symbol: layout_symbol,\n\tlayout_raster: layout_raster,\n\tlayout_hillshade: layout_hillshade,\n\tfilter: filter,\n\tfilter_operator: filter_operator,\n\tgeometry_type: geometry_type,\n\t\"function\": {\n\texpression: {\n\t\ttype: \"expression\"\n\t},\n\tstops: {\n\t\ttype: \"array\",\n\t\tvalue: \"function_stop\"\n\t},\n\tbase: {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0\n\t},\n\tproperty: {\n\t\ttype: \"string\",\n\t\t\"default\": \"$zoom\"\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tidentity: {\n\t\t\t},\n\t\t\texponential: {\n\t\t\t},\n\t\t\tinterval: {\n\t\t\t},\n\t\t\tcategorical: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"exponential\"\n\t},\n\tcolorSpace: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\trgb: {\n\t\t\t},\n\t\t\tlab: {\n\t\t\t},\n\t\t\thcl: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"rgb\"\n\t},\n\t\"default\": {\n\t\ttype: \"*\",\n\t\trequired: false\n\t}\n},\n\tfunction_stop: function_stop,\n\texpression: expression$1,\n\tlight: light,\n\tterrain: terrain,\n\tpaint: paint,\n\tpaint_fill: paint_fill,\n\t\"paint_fill-extrusion\": {\n\t\"fill-extrusion-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-extrusion-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-extrusion-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"fill-extrusion-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-base\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"fill-extrusion-height\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-vertical-gradient\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tpaint_line: paint_line,\n\tpaint_circle: paint_circle,\n\tpaint_heatmap: paint_heatmap,\n\tpaint_symbol: paint_symbol,\n\tpaint_raster: paint_raster,\n\tpaint_hillshade: paint_hillshade,\n\tpaint_background: paint_background,\n\ttransition: transition,\n\t\"property-type\": {\n\t\"data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded-data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"color-ramp\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"data-constant\": {\n\t\ttype: \"property-type\"\n\t},\n\tconstant: {\n\t\ttype: \"property-type\"\n\t}\n},\n\tpromoteId: promoteId\n};\n\nconst refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\n\nfunction deref(layer, parent) {\n const result = {};\n for (const k in layer) {\n if (k !== 'ref') {\n result[k] = layer[k];\n }\n }\n refProperties.forEach((k) => {\n if (k in parent) {\n result[k] = parent[k];\n }\n });\n return result;\n}\n/**\n * Given an array of layers, some of which may contain `ref` properties\n * whose value is the `id` of another property, return a new array where\n * such layers have been augmented with the 'type', 'source', etc. properties\n * from the parent layer, and the `ref` property has been removed.\n *\n * The input is not modified. The output may contain references to portions\n * of the input.\n *\n * @private\n * @param {Array} layers\n * @returns {Array}\n */\nfunction derefLayers(layers) {\n layers = layers.slice();\n const map = Object.create(null);\n for (let i = 0; i < layers.length; i++) {\n map[layers[i].id] = layers[i];\n }\n for (let i = 0; i < layers.length; i++) {\n if ('ref' in layers[i]) {\n layers[i] = deref(layers[i], map[layers[i].ref]);\n }\n }\n return layers;\n}\n\n/**\n * Deeply compares two object literals.\n *\n * @private\n */\nfunction deepEqual(a, b) {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object'))\n return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length)\n return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a === b;\n}\n\nconst operations = {\n /*\n * { command: 'setStyle', args: [stylesheet] }\n */\n setStyle: 'setStyle',\n /*\n * { command: 'addLayer', args: [layer, 'beforeLayerId'] }\n */\n addLayer: 'addLayer',\n /*\n * { command: 'removeLayer', args: ['layerId'] }\n */\n removeLayer: 'removeLayer',\n /*\n * { command: 'setPaintProperty', args: ['layerId', 'prop', value] }\n */\n setPaintProperty: 'setPaintProperty',\n /*\n * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }\n */\n setLayoutProperty: 'setLayoutProperty',\n /*\n * { command: 'setFilter', args: ['layerId', filter] }\n */\n setFilter: 'setFilter',\n /*\n * { command: 'addSource', args: ['sourceId', source] }\n */\n addSource: 'addSource',\n /*\n * { command: 'removeSource', args: ['sourceId'] }\n */\n removeSource: 'removeSource',\n /*\n * { command: 'setGeoJSONSourceData', args: ['sourceId', data] }\n */\n setGeoJSONSourceData: 'setGeoJSONSourceData',\n /*\n * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }\n */\n setLayerZoomRange: 'setLayerZoomRange',\n /*\n * { command: 'setLayerProperty', args: ['layerId', 'prop', value] }\n */\n setLayerProperty: 'setLayerProperty',\n /*\n * { command: 'setCenter', args: [[lon, lat]] }\n */\n setCenter: 'setCenter',\n /*\n * { command: 'setZoom', args: [zoom] }\n */\n setZoom: 'setZoom',\n /*\n * { command: 'setBearing', args: [bearing] }\n */\n setBearing: 'setBearing',\n /*\n * { command: 'setPitch', args: [pitch] }\n */\n setPitch: 'setPitch',\n /*\n * { command: 'setSprite', args: ['spriteUrl'] }\n */\n setSprite: 'setSprite',\n /*\n * { command: 'setGlyphs', args: ['glyphsUrl'] }\n */\n setGlyphs: 'setGlyphs',\n /*\n * { command: 'setTransition', args: [transition] }\n */\n setTransition: 'setTransition',\n /*\n * { command: 'setLighting', args: [lightProperties] }\n */\n setLight: 'setLight'\n};\nfunction addSource(sourceId, after, commands) {\n commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] });\n}\nfunction removeSource(sourceId, commands, sourcesRemoved) {\n commands.push({ command: operations.removeSource, args: [sourceId] });\n sourcesRemoved[sourceId] = true;\n}\nfunction updateSource(sourceId, after, commands, sourcesRemoved) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\nfunction canUpdateGeoJSON(before, after, sourceId) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\nfunction diffSources(before, after, commands, sourcesRemoved) {\n before = before || {};\n after = after || {};\n let sourceId;\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n }\n else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {\n commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] });\n }\n else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\nfunction diffLayerPropertyChanges(before, after, commands, layerId, klass, command) {\n before = before || {};\n after = after || {};\n let prop;\n for (prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n for (prop in after) {\n if (!Object.prototype.hasOwnProperty.call(after, prop) || Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n}\nfunction pluckId(layer) {\n return layer.id;\n}\nfunction indexById(group, layer) {\n group[layer.id] = layer;\n return group;\n}\nfunction diffLayers(before, after, commands) {\n before = before || [];\n after = after || [];\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;\n // remove layers\n for (i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.indexOf(layerId, d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n // add/reorder layers\n for (i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n if (tracker[tracker.length - 1 - i] === layerId)\n continue;\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n commands.push({ command: operations.removeLayer, args: [layerId] });\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n commands.push({ command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId] });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n // update layers\n for (i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer))\n continue;\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {\n commands.push({ command: operations.removeLayer, args: [layerId] });\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n commands.push({ command: operations.addLayer, args: [afterLayer, insertBeforeLayerId] });\n continue;\n }\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);\n diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n commands.push({ command: operations.setFilter, args: [layerId, afterLayer.filter] });\n }\n if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) || !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) {\n commands.push({ command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] });\n }\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n for (prop in afterLayer) {\n if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) || Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] });\n }\n }\n }\n}\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nfunction diffStyles(before, after) {\n if (!before)\n return [{ command: operations.setStyle, args: [after] }];\n let commands = [];\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{ command: operations.setStyle, args: [after] }];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({ command: operations.setCenter, args: [after.center] });\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({ command: operations.setZoom, args: [after.zoom] });\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({ command: operations.setBearing, args: [after.bearing] });\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({ command: operations.setPitch, args: [after.pitch] });\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({ command: operations.setSprite, args: [after.sprite] });\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({ command: operations.setGlyphs, args: [after.glyphs] });\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({ command: operations.setTransition, args: [after.transition] });\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({ command: operations.setLight, args: [after.light] });\n }\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if (sourcesRemoved[layer.source]) {\n commands.push({ command: operations.removeLayer, args: [layer.id] });\n }\n else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n }\n catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{ command: operations.setStyle, args: [after] }];\n }\n return commands;\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ValidationError {\n constructor(key, value, message, identifier) {\n this.message = (key ? `${key}: ` : '') + message;\n if (identifier)\n this.identifier = identifier;\n if (value !== null && value !== undefined && value.__line__) {\n this.line = value.__line__;\n }\n }\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ParsingError {\n constructor(error) {\n this.error = error;\n this.message = error.message;\n const match = error.message.match(/line (\\d+)/);\n this.line = match ? parseInt(match[1], 10) : 0;\n }\n}\n\nfunction extendBy(output, ...inputs) {\n for (const input of inputs) {\n for (const k in input) {\n output[k] = input[k];\n }\n }\n return output;\n}\n\nclass ExpressionParsingError extends Error {\n constructor(key, message) {\n super(message);\n this.message = message;\n this.key = key;\n }\n}\n\n/**\n * Tracks `let` bindings during expression parsing.\n * @private\n */\nclass Scope {\n constructor(parent, bindings = []) {\n this.parent = parent;\n this.bindings = {};\n for (const [name, expression] of bindings) {\n this.bindings[name] = expression;\n }\n }\n concat(bindings) {\n return new Scope(this, bindings);\n }\n get(name) {\n if (this.bindings[name]) {\n return this.bindings[name];\n }\n if (this.parent) {\n return this.parent.get(name);\n }\n throw new Error(`${name} not found in scope.`);\n }\n has(name) {\n if (this.bindings[name])\n return true;\n return this.parent ? this.parent.has(name) : false;\n }\n}\n\nconst NullType = { kind: 'null' };\nconst NumberType = { kind: 'number' };\nconst StringType = { kind: 'string' };\nconst BooleanType = { kind: 'boolean' };\nconst ColorType = { kind: 'color' };\nconst ObjectType = { kind: 'object' };\nconst ValueType = { kind: 'value' };\nconst ErrorType = { kind: 'error' };\nconst CollatorType = { kind: 'collator' };\nconst FormattedType = { kind: 'formatted' };\nconst PaddingType = { kind: 'padding' };\nconst ResolvedImageType = { kind: 'resolvedImage' };\nconst VariableAnchorOffsetCollectionType = { kind: 'variableAnchorOffsetCollection' };\nfunction array$1(itemType, N) {\n return {\n kind: 'array',\n itemType,\n N\n };\n}\nfunction toString$1(type) {\n if (type.kind === 'array') {\n const itemType = toString$1(type.itemType);\n return typeof type.N === 'number' ?\n `array<${itemType}, ${type.N}>` :\n type.itemType.kind === 'value' ? 'array' : `array<${itemType}>`;\n }\n else {\n return type.kind;\n }\n}\nconst valueMemberTypes = [\n NullType,\n NumberType,\n StringType,\n BooleanType,\n ColorType,\n FormattedType,\n ObjectType,\n array$1(ValueType),\n PaddingType,\n ResolvedImageType,\n VariableAnchorOffsetCollectionType\n];\n/**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message.\n * @private\n */\nfunction checkSubtype(expected, t) {\n if (t.kind === 'error') {\n // Error is a subtype of every type\n return null;\n }\n else if (expected.kind === 'array') {\n if (t.kind === 'array' &&\n ((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) &&\n (typeof expected.N !== 'number' || expected.N === t.N)) {\n return null;\n }\n }\n else if (expected.kind === t.kind) {\n return null;\n }\n else if (expected.kind === 'value') {\n for (const memberType of valueMemberTypes) {\n if (!checkSubtype(memberType, t)) {\n return null;\n }\n }\n }\n return `Expected ${toString$1(expected)} but found ${toString$1(t)} instead.`;\n}\nfunction isValidType(provided, allowedTypes) {\n return allowedTypes.some(t => t.kind === provided.kind);\n}\nfunction isValidNativeType(provided, allowedTypes) {\n return allowedTypes.some(t => {\n if (t === 'null') {\n return provided === null;\n }\n else if (t === 'array') {\n return Array.isArray(provided);\n }\n else if (t === 'object') {\n return provided && !Array.isArray(provided) && typeof provided === 'object';\n }\n else {\n return t === typeof provided;\n }\n });\n}\n/**\n * Verify whether the specified type is of the same type as the specified sample.\n *\n * @param provided Type to verify\n * @param sample Sample type to reference\n * @returns `true` if both objects are of the same type, `false` otherwise\n * @example basic types\n * if (verifyType(outputType, ValueType)) {\n * // type narrowed to:\n * outputType.kind; // 'value'\n * }\n * @example array types\n * if (verifyType(outputType, array(NumberType))) {\n * // type narrowed to:\n * outputType.kind; // 'array'\n * outputType.itemType; // NumberTypeT\n * outputType.itemType.kind; // 'number'\n * }\n */\nfunction verifyType(provided, sample) {\n if (provided.kind === 'array' && sample.kind === 'array') {\n return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number';\n }\n return provided.kind === sample.kind;\n}\n\n// See https://observablehq.com/@mbostock/lab-and-rgb\nconst Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;\nfunction constrainAngle(angle) {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\nfunction rgbToLab([r, g, b, alpha]) {\n r = rgb2xyz(r);\n g = rgb2xyz(g);\n b = rgb2xyz(b);\n let x, z;\n const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn);\n if (r === g && g === b) {\n x = z = y;\n }\n else {\n x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);\n z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);\n }\n const l = 116 * y - 16;\n return [(l < 0) ? 0 : l, 500 * (x - y), 200 * (y - z), alpha];\n}\nfunction rgb2xyz(x) {\n return (x <= 0.04045) ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);\n}\nfunction xyz2lab(t) {\n return (t > t3) ? Math.pow(t, 1 / 3) : t / t2 + t0;\n}\nfunction labToRgb([l, a, b, alpha]) {\n let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200;\n y = Yn * lab2xyz(y);\n x = Xn * lab2xyz(x);\n z = Zn * lab2xyz(z);\n return [\n xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z),\n xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),\n xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),\n alpha,\n ];\n}\nfunction xyz2rgb(x) {\n x = (x <= 0.00304) ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;\n return (x < 0) ? 0 : (x > 1) ? 1 : x; // clip to 0..1 range\n}\nfunction lab2xyz(t) {\n return (t > t1) ? t * t * t : t2 * (t - t0);\n}\nfunction rgbToHcl(rgbColor) {\n const [l, a, b, alpha] = rgbToLab(rgbColor);\n const c = Math.sqrt(a * a + b * b);\n const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN;\n return [h, c, l, alpha];\n}\nfunction hclToRgb([h, c, l, alpha]) {\n h = isNaN(h) ? 0 : h * deg2rad;\n return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]);\n}\n// https://drafts.csswg.org/css-color-4/#hsl-to-rgb\nfunction hslToRgb([h, s, l, alpha]) {\n h = constrainAngle(h);\n s /= 100;\n l /= 100;\n function f(n) {\n const k = (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n return [f(0), f(8), f(4), alpha];\n}\n\n/**\n * CSS color parser compliant with CSS Color 4 Specification.\n * Supports: named colors, `transparent` keyword, all rgb hex notations,\n * rgb(), rgba(), hsl() and hsla() functions.\n * Does not round the parsed values to integers from the range 0..255.\n *\n * Syntax:\n *\n * = | \n * = | \n *\n * rgb() = rgb( {3} [ / ]? ) | rgb( {3} [ / ]? )\n * rgb() = rgb( #{3} , ? ) | rgb( #{3} , ? )\n *\n * hsl() = hsl( [ / ]? )\n * hsl() = hsl( , , , ? )\n *\n * Caveats:\n * - - with optional `deg` suffix; `grad`, `rad`, `turn` are not supported\n * - `none` keyword is not supported\n * - comments inside rgb()/hsl() are not supported\n * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb()\n * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl()\n *\n * @param input CSS color string to parse.\n * @returns Color in sRGB color space, with `red`, `green`, `blue`\n * and `alpha` channels normalized to the range 0..1,\n * or `undefined` if the input is not a valid color string.\n */\nfunction parseCssColor(input) {\n input = input.toLowerCase().trim();\n if (input === 'transparent') {\n return [0, 0, 0, 0];\n }\n // 'white', 'black', 'blue'\n const namedColorsMatch = namedColors[input];\n if (namedColorsMatch) {\n const [r, g, b] = namedColorsMatch;\n return [r / 255, g / 255, b / 255, 1];\n }\n // #f0c, #f0cf, #ff00cc, #ff00ccff\n if (input.startsWith('#')) {\n const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n if (hexRegexp.test(input)) {\n const step = input.length < 6 ? 1 : 2;\n let i = 1;\n return [\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i + step) || 'ff'),\n ];\n }\n }\n // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6)\n if (input.startsWith('rgb')) {\n const rgbRegExp = /^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const rgbMatch = input.match(rgbRegExp);\n if (rgbMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n r, // \n rp, // % (optional)\n f1, // , (optional)\n g, // \n gp, // % (optional)\n f2, // , (optional)\n b, // \n bp, // % (optional)\n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = rgbMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const valFormat = [rp, gp, bp].join('');\n const maxValue = (valFormat === '%%%') ? 100 :\n (valFormat === '') ? 255 : 0;\n if (maxValue) {\n const rgba = [\n clamp(+r / maxValue, 0, 1),\n clamp(+g / maxValue, 0, 1),\n clamp(+b / maxValue, 0, 1),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(rgba)) {\n return rgba;\n }\n // invalid numbers\n }\n // values must be all numbers or all percentages\n }\n return; // comma optional syntax requires no commas at all\n }\n }\n // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%)\n const hslRegExp = /^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const hslMatch = input.match(hslRegExp);\n if (hslMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n h, // \n f1, // , (optional)\n s, // \n f2, // , (optional)\n l, // \n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = hslMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const hsla = [\n +h,\n clamp(+s, 0, 100),\n clamp(+l, 0, 100),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(hsla)) {\n return hslToRgb(hsla);\n }\n // invalid numbers\n }\n // comma optional syntax requires no commas at all\n }\n}\nfunction parseHex(hex) {\n return parseInt(hex.padEnd(2, hex), 16) / 255;\n}\nfunction parseAlpha(a, asPercentage) {\n return clamp(asPercentage ? (a / 100) : a, 0, 1);\n}\nfunction clamp(n, min, max) {\n return Math.min(Math.max(min, n), max);\n}\n/**\n * The regular expression for numeric values is not super specific, and it may\n * happen that it will accept a value that is not a valid number. In order to\n * detect and eliminate such values this function exists.\n *\n * @param array Array of uncertain numbers.\n * @returns `true` if the specified array contains only valid numbers, `false` otherwise.\n */\nfunction validateNumbers(array) {\n return !array.some(Number.isNaN);\n}\n/**\n * To generate:\n * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors}\n * - run in the console:\n * @example\n * copy(`{\\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\\s+/).join(', ')}],`).join('\\n')}\\n}`);\n */\nconst namedColors = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n\n/**\n * Color representation used by WebGL.\n * Defined in sRGB color space and pre-blended with alpha.\n * @private\n */\nclass Color {\n /**\n * @param r Red component premultiplied by `alpha` 0..1\n * @param g Green component premultiplied by `alpha` 0..1\n * @param b Blue component premultiplied by `alpha` 0..1\n * @param [alpha=1] Alpha component 0..1\n * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already\n * been multiplied by alpha. If `true` nothing happens if `false` then they will\n * be multiplied automatically.\n */\n constructor(r, g, b, alpha = 1, premultiplied = true) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = alpha;\n if (!premultiplied) {\n this.r *= alpha;\n this.g *= alpha;\n this.b *= alpha;\n if (!alpha) {\n // alpha = 0 erases completely rgb channels. This behavior is not desirable\n // if this particular color is later used in color interpolation.\n // Because of that, a reference to original color is saved.\n this.overwriteGetter('rgb', [r, g, b, alpha]);\n }\n }\n }\n /**\n * Parses CSS color strings and converts colors to sRGB color space if needed.\n * Officially supported color formats:\n * - keyword, e.g. 'aquamarine' or 'steelblue'\n * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'\n * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'\n * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'\n *\n * @param input CSS color string to parse.\n * @returns A `Color` instance, or `undefined` if the input is not a valid color string.\n */\n static parse(input) {\n // in zoom-and-property function input could be an instance of Color class\n if (input instanceof Color) {\n return input;\n }\n if (typeof input !== 'string') {\n return;\n }\n const rgba = parseCssColor(input);\n if (rgba) {\n return new Color(...rgba, false);\n }\n }\n /**\n * Used in color interpolation and by 'to-rgba' expression.\n *\n * @returns Gien color, with reversed alpha blending, in sRGB color space.\n */\n get rgb() {\n const { r, g, b, a } = this;\n const f = a || Infinity; // reverse alpha blending factor\n return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]);\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in HCL color space.\n */\n get hcl() {\n return this.overwriteGetter('hcl', rgbToHcl(this.rgb));\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in LAB color space.\n */\n get lab() {\n return this.overwriteGetter('lab', rgbToLab(this.rgb));\n }\n /**\n * Lazy getter pattern. When getter is called for the first time lazy value\n * is calculated and then overwrites getter function in given object instance.\n *\n * @example:\n * const redColor = Color.parse('red');\n * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate\n * // the value of red in HCL space and invoke this `overwriteGetter` function\n * // which in turn will set a field with a key 'hcl' in the `redColor` object.\n * // In other words it will override `get hcl()` from its `Color` prototype\n * // with its own property: hcl = [calculated red value in hcl].\n * let y = redColor.hcl; // next call will no longer invoke getter but simply\n * // return the previously calculated value\n * x === y; // true - `x` is exactly the same object as `y`\n *\n * @param getterKey Getter key\n * @param lazyValue Lazily calculated value to be memoized by current instance\n * @private\n */\n overwriteGetter(getterKey, lazyValue) {\n Object.defineProperty(this, getterKey, { value: lazyValue });\n return lazyValue;\n }\n /**\n * Used by 'to-string' expression.\n *\n * @returns Serialized color in format `rgba(r,g,b,a)`\n * where r,g,b are numbers within 0..255 and alpha is number within 1..0\n *\n * @example\n * var purple = new Color.parse('purple');\n * purple.toString; // = \"rgba(128,0,128,1)\"\n * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');\n * translucentGreen.toString(); // = \"rgba(26,207,26,0.73)\"\n */\n toString() {\n const [r, g, b, a] = this.rgb;\n return `rgba(${[r, g, b].map(n => Math.round(n * 255)).join(',')},${a})`;\n }\n}\nColor.black = new Color(0, 0, 0, 1);\nColor.white = new Color(1, 1, 1, 1);\nColor.transparent = new Color(0, 0, 0, 0);\nColor.red = new Color(1, 0, 0, 1);\n\n// Flow type declarations for Intl cribbed from\n// https://github.com/facebook/flow/issues/1270\nclass Collator {\n constructor(caseSensitive, diacriticSensitive, locale) {\n if (caseSensitive)\n this.sensitivity = diacriticSensitive ? 'variant' : 'case';\n else\n this.sensitivity = diacriticSensitive ? 'accent' : 'base';\n this.locale = locale;\n this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: 'search' });\n }\n compare(lhs, rhs) {\n return this.collator.compare(lhs, rhs);\n }\n resolvedLocale() {\n // We create a Collator without \"usage: search\" because we don't want\n // the search options encoded in our result (e.g. \"en-u-co-search\")\n return new Intl.Collator(this.locale ? this.locale : [])\n .resolvedOptions().locale;\n }\n}\n\nclass FormattedSection {\n constructor(text, image, scale, fontStack, textColor) {\n this.text = text;\n this.image = image;\n this.scale = scale;\n this.fontStack = fontStack;\n this.textColor = textColor;\n }\n}\nclass Formatted {\n constructor(sections) {\n this.sections = sections;\n }\n static fromString(unformatted) {\n return new Formatted([new FormattedSection(unformatted, null, null, null, null)]);\n }\n isEmpty() {\n if (this.sections.length === 0)\n return true;\n return !this.sections.some(section => section.text.length !== 0 ||\n (section.image && section.image.name.length !== 0));\n }\n static factory(text) {\n if (text instanceof Formatted) {\n return text;\n }\n else {\n return Formatted.fromString(text);\n }\n }\n toString() {\n if (this.sections.length === 0)\n return '';\n return this.sections.map(section => section.text).join('');\n }\n}\n\n/**\n * A set of four numbers representing padding around a box. Create instances from\n * bare arrays or numeric values using the static method `Padding.parse`.\n * @private\n */\nclass Padding {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric padding values\n * @param input A padding value\n * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value.\n */\n static parse(input) {\n if (input instanceof Padding) {\n return input;\n }\n // Backwards compatibility: bare number is treated the same as array with single value.\n // Padding applies to all four sides.\n if (typeof input === 'number') {\n return new Padding([input, input, input, input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n if (input.length < 1 || input.length > 4) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n // Expand shortcut properties into explicit 4-sided values\n switch (input.length) {\n case 1:\n input = [input[0], input[0], input[0], input[0]];\n break;\n case 2:\n input = [input[0], input[1], input[0], input[1]];\n break;\n case 3:\n input = [input[0], input[1], input[2], input[1]];\n break;\n }\n return new Padding(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\n/** Set of valid anchor positions, as a set for validation */\nconst anchors = new Set(['center', 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right']);\n/**\n * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from\n * bare arrays using the static method `VariableAnchorOffsetCollection.parse`.\n * @private\n */\nclass VariableAnchorOffsetCollection {\n constructor(values) {\n this.values = values.slice();\n }\n static parse(input) {\n if (input instanceof VariableAnchorOffsetCollection) {\n return input;\n }\n if (!Array.isArray(input) ||\n input.length < 1 ||\n input.length % 2 !== 0) {\n return undefined;\n }\n for (let i = 0; i < input.length; i += 2) {\n // Elements in even positions should be anchor positions; Elements in odd positions should be offset values\n const anchorValue = input[i];\n const offsetValue = input[i + 1];\n if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) {\n return undefined;\n }\n if (!Array.isArray(offsetValue) || offsetValue.length !== 2 || typeof offsetValue[0] !== 'number' || typeof offsetValue[1] !== 'number') {\n return undefined;\n }\n }\n return new VariableAnchorOffsetCollection(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\nclass ResolvedImage {\n constructor(options) {\n this.name = options.name;\n this.available = options.available;\n }\n toString() {\n return this.name;\n }\n static fromString(name) {\n if (!name)\n return null; // treat empty values as no image\n return new ResolvedImage({ name, available: false });\n }\n}\n\nfunction validateRGBA(r, g, b, a) {\n if (!(typeof r === 'number' && r >= 0 && r <= 255 &&\n typeof g === 'number' && g >= 0 && g <= 255 &&\n typeof b === 'number' && b >= 0 && b <= 255)) {\n const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];\n return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;\n }\n if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) {\n return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;\n }\n return null;\n}\nfunction isValue(mixed) {\n if (mixed === null ||\n typeof mixed === 'string' ||\n typeof mixed === 'boolean' ||\n typeof mixed === 'number' ||\n mixed instanceof Color ||\n mixed instanceof Collator ||\n mixed instanceof Formatted ||\n mixed instanceof Padding ||\n mixed instanceof VariableAnchorOffsetCollection ||\n mixed instanceof ResolvedImage) {\n return true;\n }\n else if (Array.isArray(mixed)) {\n for (const item of mixed) {\n if (!isValue(item)) {\n return false;\n }\n }\n return true;\n }\n else if (typeof mixed === 'object') {\n for (const key in mixed) {\n if (!isValue(mixed[key])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\nfunction typeOf(value) {\n if (value === null) {\n return NullType;\n }\n else if (typeof value === 'string') {\n return StringType;\n }\n else if (typeof value === 'boolean') {\n return BooleanType;\n }\n else if (typeof value === 'number') {\n return NumberType;\n }\n else if (value instanceof Color) {\n return ColorType;\n }\n else if (value instanceof Collator) {\n return CollatorType;\n }\n else if (value instanceof Formatted) {\n return FormattedType;\n }\n else if (value instanceof Padding) {\n return PaddingType;\n }\n else if (value instanceof VariableAnchorOffsetCollection) {\n return VariableAnchorOffsetCollectionType;\n }\n else if (value instanceof ResolvedImage) {\n return ResolvedImageType;\n }\n else if (Array.isArray(value)) {\n const length = value.length;\n let itemType;\n for (const item of value) {\n const t = typeOf(item);\n if (!itemType) {\n itemType = t;\n }\n else if (itemType === t) {\n continue;\n }\n else {\n itemType = ValueType;\n break;\n }\n }\n return array$1(itemType || ValueType, length);\n }\n else {\n return ObjectType;\n }\n}\nfunction toString(value) {\n const type = typeof value;\n if (value === null) {\n return '';\n }\n else if (type === 'string' || type === 'number' || type === 'boolean') {\n return String(value);\n }\n else if (value instanceof Color || value instanceof Formatted || value instanceof Padding || value instanceof VariableAnchorOffsetCollection || value instanceof ResolvedImage) {\n return value.toString();\n }\n else {\n return JSON.stringify(value);\n }\n}\n\nclass Literal {\n constructor(type, value) {\n this.type = type;\n this.value = value;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (!isValue(args[1]))\n return context.error('invalid value');\n const value = args[1];\n let type = typeOf(value);\n // special case: infer the item type if possible for zero-length arrays\n const expected = context.expectedType;\n if (type.kind === 'array' &&\n type.N === 0 &&\n expected &&\n expected.kind === 'array' &&\n (typeof expected.N !== 'number' || expected.N === 0)) {\n type = expected;\n }\n return new Literal(type, value);\n }\n evaluate() {\n return this.value;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass RuntimeError {\n constructor(message) {\n this.name = 'ExpressionEvaluationError';\n this.message = message;\n }\n toJSON() {\n return this.message;\n }\n}\n\nconst types$1 = {\n string: StringType,\n number: NumberType,\n boolean: BooleanType,\n object: ObjectType\n};\nclass Assertion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n let i = 1;\n let type;\n const name = args[0];\n if (name === 'array') {\n let itemType;\n if (args.length > 2) {\n const type = args[1];\n if (typeof type !== 'string' || !(type in types$1) || type === 'object')\n return context.error('The item type argument of \"array\" must be one of string, number, boolean', 1);\n itemType = types$1[type];\n i++;\n }\n else {\n itemType = ValueType;\n }\n let N;\n if (args.length > 3) {\n if (args[2] !== null &&\n (typeof args[2] !== 'number' ||\n args[2] < 0 ||\n args[2] !== Math.floor(args[2]))) {\n return context.error('The length argument to \"array\" must be a positive integer literal', 2);\n }\n N = args[2];\n i++;\n }\n type = array$1(itemType, N);\n }\n else {\n if (!types$1[name])\n throw new Error(`Types doesn't contain name = ${name}`);\n type = types$1[name];\n }\n const parsed = [];\n for (; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Assertion(type, parsed);\n }\n evaluate(ctx) {\n for (let i = 0; i < this.args.length; i++) {\n const value = this.args[i].evaluate(ctx);\n const error = checkSubtype(this.type, typeOf(value));\n if (!error) {\n return value;\n }\n else if (i === this.args.length - 1) {\n throw new RuntimeError(`Expected value to be of type ${toString$1(this.type)}, but found ${toString$1(typeOf(value))} instead.`);\n }\n }\n throw new Error();\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst types = {\n 'to-boolean': BooleanType,\n 'to-color': ColorType,\n 'to-number': NumberType,\n 'to-string': StringType\n};\n/**\n * Special form for error-coalescing coercion expressions \"to-number\",\n * \"to-color\". Since these coercions can fail at runtime, they accept multiple\n * arguments, only evaluating one at a time until one succeeds.\n *\n * @private\n */\nclass Coercion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n const name = args[0];\n if (!types[name])\n throw new Error(`Can't parse ${name} as it is not part of the known types`);\n if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2)\n return context.error('Expected one argument.');\n const type = types[name];\n const parsed = [];\n for (let i = 1; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Coercion(type, parsed);\n }\n evaluate(ctx) {\n switch (this.type.kind) {\n case 'boolean':\n return Boolean(this.args[0].evaluate(ctx));\n case 'color': {\n let input;\n let error;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n error = null;\n if (input instanceof Color) {\n return input;\n }\n else if (typeof input === 'string') {\n const c = ctx.parseColor(input);\n if (c)\n return c;\n }\n else if (Array.isArray(input)) {\n if (input.length < 3 || input.length > 4) {\n error = `Invalid rbga value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`;\n }\n else {\n error = validateRGBA(input[0], input[1], input[2], input[3]);\n }\n if (!error) {\n return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);\n }\n }\n }\n throw new RuntimeError(error || `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'padding': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const pad = Padding.parse(input);\n if (pad) {\n return pad;\n }\n }\n throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'variableAnchorOffsetCollection': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const coll = VariableAnchorOffsetCollection.parse(input);\n if (coll) {\n return coll;\n }\n }\n throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'number': {\n let value = null;\n for (const arg of this.args) {\n value = arg.evaluate(ctx);\n if (value === null)\n return 0;\n const num = Number(value);\n if (isNaN(num))\n continue;\n return num;\n }\n throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`);\n }\n case 'formatted':\n // There is no explicit 'to-formatted' but this coercion can be implicitly\n // created by properties that expect the 'formatted' type.\n return Formatted.fromString(toString(this.args[0].evaluate(ctx)));\n case 'resolvedImage':\n return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx)));\n default:\n return toString(this.args[0].evaluate(ctx));\n }\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\nclass EvaluationContext {\n constructor() {\n this.globals = null;\n this.feature = null;\n this.featureState = null;\n this.formattedSection = null;\n this._parseColorCache = {};\n this.availableImages = null;\n this.canonical = null;\n }\n id() {\n return this.feature && 'id' in this.feature ? this.feature.id : null;\n }\n geometryType() {\n return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;\n }\n geometry() {\n return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n }\n canonicalID() {\n return this.canonical;\n }\n properties() {\n return this.feature && this.feature.properties || {};\n }\n parseColor(input) {\n let cached = this._parseColorCache[input];\n if (!cached) {\n cached = this._parseColorCache[input] = Color.parse(input);\n }\n return cached;\n }\n}\n\n/**\n * State associated parsing at a given point in an expression tree.\n * @private\n */\nclass ParsingContext {\n constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) {\n this.registry = registry;\n this.path = path;\n this.key = path.map(part => `[${part}]`).join('');\n this.scope = scope;\n this.errors = errors;\n this.expectedType = expectedType;\n this._isConstant = isConstantFunc;\n }\n /**\n * @param expr the JSON expression to parse\n * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed\n * @param options\n * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.\n * @private\n */\n parse(expr, index, expectedType, bindings, options = {}) {\n if (index) {\n return this.concat(index, expectedType, bindings)._parse(expr, options);\n }\n return this._parse(expr, options);\n }\n _parse(expr, options) {\n if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {\n expr = ['literal', expr];\n }\n function annotate(parsed, type, typeAnnotation) {\n if (typeAnnotation === 'assert') {\n return new Assertion(type, [parsed]);\n }\n else if (typeAnnotation === 'coerce') {\n return new Coercion(type, [parsed]);\n }\n else {\n return parsed;\n }\n }\n if (Array.isArray(expr)) {\n if (expr.length === 0) {\n return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');\n }\n const op = expr[0];\n if (typeof op !== 'string') {\n this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use [\"literal\", [...]].`, 0);\n return null;\n }\n const Expr = this.registry[op];\n if (Expr) {\n let parsed = Expr.parse(expr, this);\n if (!parsed)\n return null;\n if (this.expectedType) {\n const expected = this.expectedType;\n const actual = parsed.type;\n // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.\n // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.\n // Otherwise, we do static type-checking.\n //\n // These behaviors are overridable for:\n // * The \"coalesce\" operator, which needs to omit type annotations.\n // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.\n //\n if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');\n }\n else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'padding' && (actual.kind === 'value' || actual.kind === 'number' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'variableAnchorOffsetCollection' && (actual.kind === 'value' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (this.checkSubtype(expected, actual)) {\n return null;\n }\n }\n // If an expression's arguments are all literals, we can evaluate\n // it immediately and replace it with a literal value in the\n // parsed/compiled result. Expressions that expect an image should\n // not be resolved here so we can later get the available images.\n if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && this._isConstant(parsed)) {\n const ec = new EvaluationContext();\n try {\n parsed = new Literal(parsed.type, parsed.evaluate(ec));\n }\n catch (e) {\n this.error(e.message);\n return null;\n }\n }\n return parsed;\n }\n return this.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n else if (typeof expr === 'undefined') {\n return this.error('\\'undefined\\' value invalid. Use null instead.');\n }\n else if (typeof expr === 'object') {\n return this.error('Bare objects invalid. Use [\"literal\", {...}] instead.');\n }\n else {\n return this.error(`Expected an array, but found ${typeof expr} instead.`);\n }\n }\n /**\n * Returns a copy of this context suitable for parsing the subexpression at\n * index `index`, optionally appending to 'let' binding map.\n *\n * Note that `errors` property, intended for collecting errors while\n * parsing, is copied by reference rather than cloned.\n * @private\n */\n concat(index, expectedType, bindings) {\n const path = typeof index === 'number' ? this.path.concat(index) : this.path;\n const scope = bindings ? this.scope.concat(bindings) : this.scope;\n return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors);\n }\n /**\n * Push a parsing (or type checking) error into the `this.errors`\n * @param error The message\n * @param keys Optionally specify the source of the error at a child\n * of the current expression at `this.key`.\n * @private\n */\n error(error, ...keys) {\n const key = `${this.key}${keys.map(k => `[${k}]`).join('')}`;\n this.errors.push(new ExpressionParsingError(key, error));\n }\n /**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message and also pushes it to `this.errors`.\n * @param expected The expected type\n * @param t The actual type\n * @returns null if `t` is a subtype of `expected`; otherwise returns an error message\n */\n checkSubtype(expected, t) {\n const error = checkSubtype(expected, t);\n if (error)\n this.error(error);\n return error;\n }\n}\n\nclass CollatorExpression {\n constructor(caseSensitive, diacriticSensitive, locale) {\n this.type = CollatorType;\n this.locale = locale;\n this.caseSensitive = caseSensitive;\n this.diacriticSensitive = diacriticSensitive;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error('Expected one argument.');\n const options = args[1];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('Collator options argument must be an object.');\n const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);\n if (!caseSensitive)\n return null;\n const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);\n if (!diacriticSensitive)\n return null;\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n return new CollatorExpression(caseSensitive, diacriticSensitive, locale);\n }\n evaluate(ctx) {\n return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);\n }\n eachChild(fn) {\n fn(this.caseSensitive);\n fn(this.diacriticSensitive);\n if (this.locale) {\n fn(this.locale);\n }\n }\n outputDefined() {\n // Technically the set of possible outputs is the combinatoric set of Collators produced\n // by all possible outputs of locale/caseSensitive/diacriticSensitive\n // But for the primary use of Collators in comparison operators, we ignore the Collator's\n // possible outputs anyway, so we can get away with leaving this false for now.\n return false;\n }\n}\n\nconst EXTENT = 8192;\nfunction updateBBox(bbox, coord) {\n bbox[0] = Math.min(bbox[0], coord[0]);\n bbox[1] = Math.min(bbox[1], coord[1]);\n bbox[2] = Math.max(bbox[2], coord[0]);\n bbox[3] = Math.max(bbox[3], coord[1]);\n}\nfunction mercatorXfromLng(lng) {\n return (180 + lng) / 360;\n}\nfunction mercatorYfromLat(lat) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\nfunction boxWithinBox(bbox1, bbox2) {\n if (bbox1[0] <= bbox2[0])\n return false;\n if (bbox1[2] >= bbox2[2])\n return false;\n if (bbox1[1] <= bbox2[1])\n return false;\n if (bbox1[3] >= bbox2[3])\n return false;\n return true;\n}\nfunction getTileCoordinates(p, canonical) {\n const x = mercatorXfromLng(p[0]);\n const y = mercatorYfromLat(p[1]);\n const tilesAtZoom = Math.pow(2, canonical.z);\n return [Math.round(x * tilesAtZoom * EXTENT), Math.round(y * tilesAtZoom * EXTENT)];\n}\nfunction onBoundary(p, p1, p2) {\n const x1 = p[0] - p1[0];\n const y1 = p[1] - p1[1];\n const x2 = p[0] - p2[0];\n const y2 = p[1] - p2[1];\n return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);\n}\nfunction rayIntersect(p, p1, p2) {\n return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]);\n}\n// ray casting algorithm for detecting if point is in polygon\nfunction pointWithinPolygon(point, rings) {\n let inside = false;\n for (let i = 0, len = rings.length; i < len; i++) {\n const ring = rings[i];\n for (let j = 0, len2 = ring.length; j < len2 - 1; j++) {\n if (onBoundary(point, ring[j], ring[j + 1]))\n return false;\n if (rayIntersect(point, ring[j], ring[j + 1]))\n inside = !inside;\n }\n }\n return inside;\n}\nfunction pointWithinPolygons(point, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (pointWithinPolygon(point, polygons[i]))\n return true;\n }\n return false;\n}\nfunction perp(v1, v2) {\n return (v1[0] * v2[1] - v1[1] * v2[0]);\n}\n// check if p1 and p2 are in different sides of line segment q1->q2\nfunction twoSided(p1, p2, q1, q2) {\n // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)\n const x1 = p1[0] - q1[0];\n const y1 = p1[1] - q1[1];\n const x2 = p2[0] - q1[0];\n const y2 = p2[1] - q1[1];\n const x3 = q2[0] - q1[0];\n const y3 = q2[1] - q1[1];\n const det1 = (x1 * y3 - x3 * y1);\n const det2 = (x2 * y3 - x3 * y2);\n if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0))\n return true;\n return false;\n}\n// a, b are end points for line segment1, c and d are end points for line segment2\nfunction lineIntersectLine(a, b, c, d) {\n // check if two segments are parallel or not\n // precondition is end point a, b is inside polygon, if line a->b is\n // parallel to polygon edge c->d, then a->b won't intersect with c->d\n const vectorP = [b[0] - a[0], b[1] - a[1]];\n const vectorQ = [d[0] - c[0], d[1] - c[1]];\n if (perp(vectorQ, vectorP) === 0)\n return false;\n // If lines are intersecting with each other, the relative location should be:\n // a and b lie in different sides of segment c->d\n // c and d lie in different sides of segment a->b\n if (twoSided(a, b, c, d) && twoSided(c, d, a, b))\n return true;\n return false;\n}\nfunction lineIntersectPolygon(p1, p2, polygon) {\n for (const ring of polygon) {\n // loop through every edge of the ring\n for (let j = 0; j < ring.length - 1; ++j) {\n if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) {\n return true;\n }\n }\n }\n return false;\n}\nfunction lineStringWithinPolygon(line, polygon) {\n // First, check if geometry points of line segments are all inside polygon\n for (let i = 0; i < line.length; ++i) {\n if (!pointWithinPolygon(line[i], polygon)) {\n return false;\n }\n }\n // Second, check if there is line segment intersecting polygon edge\n for (let i = 0; i < line.length - 1; ++i) {\n if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {\n return false;\n }\n }\n return true;\n}\nfunction lineStringWithinPolygons(line, polygons) {\n for (let i = 0; i < polygons.length; i++) {\n if (lineStringWithinPolygon(line, polygons[i]))\n return true;\n }\n return false;\n}\nfunction getTilePolygon(coordinates, bbox, canonical) {\n const polygon = [];\n for (let i = 0; i < coordinates.length; i++) {\n const ring = [];\n for (let j = 0; j < coordinates[i].length; j++) {\n const coord = getTileCoordinates(coordinates[i][j], canonical);\n updateBBox(bbox, coord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n return polygon;\n}\nfunction getTilePolygons(coordinates, bbox, canonical) {\n const polygons = [];\n for (let i = 0; i < coordinates.length; i++) {\n const polygon = getTilePolygon(coordinates[i], bbox, canonical);\n polygons.push(polygon);\n }\n return polygons;\n}\nfunction updatePoint(p, bbox, polyBBox, worldSize) {\n if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {\n const halfWorldSize = worldSize * 0.5;\n let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0;\n if (shift === 0) {\n shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0;\n }\n p[0] += shift;\n }\n updateBBox(bbox, p);\n}\nfunction resetBBox(bbox) {\n bbox[0] = bbox[1] = Infinity;\n bbox[2] = bbox[3] = -Infinity;\n}\nfunction getTilePoints(geometry, pointBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tilePoints = [];\n for (const points of geometry) {\n for (const point of points) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updatePoint(p, pointBBox, polyBBox, worldSize);\n tilePoints.push(p);\n }\n }\n return tilePoints;\n}\nfunction getTileLines(geometry, lineBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tileLines = [];\n for (const line of geometry) {\n const tileLine = [];\n for (const point of line) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updateBBox(lineBBox, p);\n tileLine.push(p);\n }\n tileLines.push(tileLine);\n }\n if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {\n resetBBox(lineBBox);\n for (const line of tileLines) {\n for (const p of line) {\n updatePoint(p, lineBBox, polyBBox, worldSize);\n }\n }\n }\n return tileLines;\n}\nfunction pointsWithinPolygons(ctx, polygonGeometry) {\n const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygon(point, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygons(point, tilePolygons))\n return false;\n }\n }\n return true;\n}\nfunction linesWithinPolygons(ctx, polygonGeometry) {\n const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygon(line, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygons(line, tilePolygons))\n return false;\n }\n }\n return true;\n}\nclass Within {\n constructor(geojson, geometries) {\n this.type = BooleanType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n for (let i = 0; i < geojson.features.length; ++i) {\n const type = geojson.features[i].geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.features[i].geometry);\n }\n }\n }\n else if (geojson.type === 'Feature') {\n const type = geojson.geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.geometry);\n }\n }\n else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {\n return new Within(geojson, geojson);\n }\n }\n return context.error('\\'within\\' expression requires valid geojson object that contains polygon geometry type.');\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointsWithinPolygons(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return linesWithinPolygons(ctx, this.geometries);\n }\n }\n return false;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass Var {\n constructor(name, boundExpression) {\n this.type = boundExpression.type;\n this.name = name;\n this.boundExpression = boundExpression;\n }\n static parse(args, context) {\n if (args.length !== 2 || typeof args[1] !== 'string')\n return context.error('\\'var\\' expression requires exactly one string literal argument.');\n const name = args[1];\n if (!context.scope.has(name)) {\n return context.error(`Unknown variable \"${name}\". Make sure \"${name}\" has been bound in an enclosing \"let\" expression before using it.`, 1);\n }\n return new Var(name, context.scope.get(name));\n }\n evaluate(ctx) {\n return this.boundExpression.evaluate(ctx);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nclass CompoundExpression {\n constructor(name, type, evaluate, args) {\n this.name = name;\n this.type = type;\n this._evaluate = evaluate;\n this.args = args;\n }\n evaluate(ctx) {\n return this._evaluate(ctx, this.args);\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return false;\n }\n static parse(args, context) {\n const op = args[0];\n const definition = CompoundExpression.definitions[op];\n if (!definition) {\n return context.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n // Now check argument types against each signature\n const type = Array.isArray(definition) ?\n definition[0] : definition.type;\n const availableOverloads = Array.isArray(definition) ?\n [[definition[1], definition[2]]] :\n definition.overloads;\n const overloads = availableOverloads.filter(([signature]) => (!Array.isArray(signature) || // varags\n signature.length === args.length - 1 // correct param count\n ));\n let signatureContext = null;\n for (const [params, evaluate] of overloads) {\n // Use a fresh context for each attempted signature so that, if\n // we eventually succeed, we haven't polluted `context.errors`.\n signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope);\n // First parse all the args, potentially coercing to the\n // types expected by this overload.\n const parsedArgs = [];\n let argParseFailed = false;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n const expectedType = Array.isArray(params) ?\n params[i - 1] :\n params.type;\n const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);\n if (!parsed) {\n argParseFailed = true;\n break;\n }\n parsedArgs.push(parsed);\n }\n if (argParseFailed) {\n // Couldn't coerce args of this overload to expected type, move\n // on to next one.\n continue;\n }\n if (Array.isArray(params)) {\n if (params.length !== parsedArgs.length) {\n signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);\n continue;\n }\n }\n for (let i = 0; i < parsedArgs.length; i++) {\n const expected = Array.isArray(params) ? params[i] : params.type;\n const arg = parsedArgs[i];\n signatureContext.concat(i + 1).checkSubtype(expected, arg.type);\n }\n if (signatureContext.errors.length === 0) {\n return new CompoundExpression(op, type, evaluate, parsedArgs);\n }\n }\n if (overloads.length === 1) {\n context.errors.push(...signatureContext.errors);\n }\n else {\n const expected = overloads.length ? overloads : availableOverloads;\n const signatures = expected\n .map(([params]) => stringifySignature(params))\n .join(' | ');\n const actualTypes = [];\n // For error message, re-parse arguments without trying to\n // apply any coercions\n for (let i = 1; i < args.length; i++) {\n const parsed = context.parse(args[i], 1 + actualTypes.length);\n if (!parsed)\n return null;\n actualTypes.push(toString$1(parsed.type));\n }\n context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);\n }\n return null;\n }\n static register(registry, definitions) {\n CompoundExpression.definitions = definitions;\n for (const name in definitions) {\n registry[name] = CompoundExpression;\n }\n }\n}\nfunction stringifySignature(signature) {\n if (Array.isArray(signature)) {\n return `(${signature.map(toString$1).join(', ')})`;\n }\n else {\n return `(${toString$1(signature.type)}...)`;\n }\n}\nfunction isExpressionConstant(expression) {\n if (expression instanceof Var) {\n return isExpressionConstant(expression.boundExpression);\n }\n else if (expression instanceof CompoundExpression && expression.name === 'error') {\n return false;\n }\n else if (expression instanceof CollatorExpression) {\n // Although the results of a Collator expression with fixed arguments\n // generally shouldn't change between executions, we can't serialize them\n // as constant expressions because results change based on environment.\n return false;\n }\n else if (expression instanceof Within) {\n return false;\n }\n const isTypeAnnotation = expression instanceof Coercion ||\n expression instanceof Assertion;\n let childrenConstant = true;\n expression.eachChild(child => {\n // We can _almost_ assume that if `expressions` children are constant,\n // they would already have been evaluated to Literal values when they\n // were parsed. Type annotations are the exception, because they might\n // have been inferred and added after a child was parsed.\n // So we recurse into isConstant() for the children of type annotations,\n // but otherwise simply check whether they are Literals.\n if (isTypeAnnotation) {\n childrenConstant = childrenConstant && isExpressionConstant(child);\n }\n else {\n childrenConstant = childrenConstant && child instanceof Literal;\n }\n });\n if (!childrenConstant) {\n return false;\n }\n return isFeatureConstant(expression) &&\n isGlobalPropertyConstant(expression, ['zoom', 'heatmap-density', 'line-progress', 'accumulated', 'is-supported-script']);\n}\nfunction isFeatureConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'get' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'feature-state') {\n return false;\n }\n else if (e.name === 'has' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'properties' ||\n e.name === 'geometry-type' ||\n e.name === 'id') {\n return false;\n }\n else if (/^filter-/.test(e.name)) {\n return false;\n }\n }\n if (e instanceof Within) {\n return false;\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isFeatureConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isStateConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'feature-state') {\n return false;\n }\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isStateConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isGlobalPropertyConstant(e, properties) {\n if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isGlobalPropertyConstant(arg, properties)) {\n result = false;\n }\n });\n return result;\n}\n\n/**\n * Returns the index of the last stop <= input, or 0 if it doesn't exist.\n * @private\n */\nfunction findStopLessThanOrEqualTo(stops, input) {\n const lastIndex = stops.length - 1;\n let lowerIndex = 0;\n let upperIndex = lastIndex;\n let currentIndex = 0;\n let currentValue, nextValue;\n while (lowerIndex <= upperIndex) {\n currentIndex = Math.floor((lowerIndex + upperIndex) / 2);\n currentValue = stops[currentIndex];\n nextValue = stops[currentIndex + 1];\n if (currentValue <= input) {\n if (currentIndex === lastIndex || input < nextValue) { // Search complete\n return currentIndex;\n }\n lowerIndex = currentIndex + 1;\n }\n else if (currentValue > input) {\n upperIndex = currentIndex - 1;\n }\n else {\n throw new RuntimeError('Input is not a number.');\n }\n }\n return 0;\n}\n\nclass Step {\n constructor(type, input, stops) {\n this.type = type;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static parse(args, context) {\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n const input = context.parse(args[1], 1, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 1; i < args.length; i += 2) {\n const label = i === 1 ? -Infinity : args[i];\n const value = args[i + 1];\n const labelKey = i;\n const valueKey = i + 1;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"step\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n return new Step(outputType, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n return outputs[index].evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n\n/**\n * Checks whether the specified color space is one of the supported interpolation color spaces.\n *\n * @param colorSpace Color space key to verify.\n * @returns `true` if the specified color space is one of the supported\n * interpolation color spaces, `false` otherwise\n */\nfunction isSupportedInterpolationColorSpace(colorSpace) {\n return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab';\n}\n/**\n * @param interpolationType Interpolation type\n * @returns interpolation fn\n * @deprecated use `interpolate[type]` instead\n */\nconst interpolateFactory = (interpolationType) => {\n switch (interpolationType) {\n case 'number': return number;\n case 'color': return color;\n case 'array': return array;\n case 'padding': return padding;\n case 'variableAnchorOffsetCollection': return variableAnchorOffsetCollection;\n }\n};\nfunction number(from, to, t) {\n return from + t * (to - from);\n}\nfunction color(from, to, t, spaceKey = 'rgb') {\n switch (spaceKey) {\n case 'rgb': {\n const [r, g, b, alpha] = array(from.rgb, to.rgb, t);\n return new Color(r, g, b, alpha, false);\n }\n case 'hcl': {\n const [hue0, chroma0, light0, alphaF] = from.hcl;\n const [hue1, chroma1, light1, alphaT] = to.hcl;\n // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js\n let hue, chroma;\n if (!isNaN(hue0) && !isNaN(hue1)) {\n let dh = hue1 - hue0;\n if (hue1 > hue0 && dh > 180) {\n dh -= 360;\n }\n else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh += 360;\n }\n hue = hue0 + t * dh;\n }\n else if (!isNaN(hue0)) {\n hue = hue0;\n if (light1 === 1 || light1 === 0)\n chroma = chroma0;\n }\n else if (!isNaN(hue1)) {\n hue = hue1;\n if (light0 === 1 || light0 === 0)\n chroma = chroma1;\n }\n else {\n hue = NaN;\n }\n const [r, g, b, alpha] = hclToRgb([\n hue,\n chroma !== null && chroma !== void 0 ? chroma : number(chroma0, chroma1, t),\n number(light0, light1, t),\n number(alphaF, alphaT, t),\n ]);\n return new Color(r, g, b, alpha, false);\n }\n case 'lab': {\n const [r, g, b, alpha] = labToRgb(array(from.lab, to.lab, t));\n return new Color(r, g, b, alpha, false);\n }\n }\n}\nfunction array(from, to, t) {\n return from.map((d, i) => {\n return number(d, to[i], t);\n });\n}\nfunction padding(from, to, t) {\n return new Padding(array(from.values, to.values, t));\n}\nfunction variableAnchorOffsetCollection(from, to, t) {\n const fromValues = from.values;\n const toValues = to.values;\n if (fromValues.length !== toValues.length) {\n throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`);\n }\n const output = [];\n for (let i = 0; i < fromValues.length; i += 2) {\n // Anchor entries must match\n if (fromValues[i] !== toValues[i]) {\n throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`);\n }\n output.push(fromValues[i]);\n // Interpolate the offset values for each anchor\n const [fx, fy] = fromValues[i + 1];\n const [tx, ty] = toValues[i + 1];\n output.push([number(fx, tx, t), number(fy, ty, t)]);\n }\n return new VariableAnchorOffsetCollection(output);\n}\nconst interpolate = {\n number,\n color,\n array,\n padding,\n variableAnchorOffsetCollection\n};\n\nclass Interpolate {\n constructor(type, operator, interpolation, input, stops) {\n this.type = type;\n this.operator = operator;\n this.interpolation = interpolation;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static interpolationFactor(interpolation, input, lower, upper) {\n let t = 0;\n if (interpolation.name === 'exponential') {\n t = exponentialInterpolation(input, interpolation.base, lower, upper);\n }\n else if (interpolation.name === 'linear') {\n t = exponentialInterpolation(input, 1, lower, upper);\n }\n else if (interpolation.name === 'cubic-bezier') {\n const c = interpolation.controlPoints;\n const ub = new UnitBezier(c[0], c[1], c[2], c[3]);\n t = ub.solve(exponentialInterpolation(input, 1, lower, upper));\n }\n return t;\n }\n static parse(args, context) {\n let [operator, interpolation, input, ...rest] = args;\n if (!Array.isArray(interpolation) || interpolation.length === 0) {\n return context.error('Expected an interpolation type expression.', 1);\n }\n if (interpolation[0] === 'linear') {\n interpolation = { name: 'linear' };\n }\n else if (interpolation[0] === 'exponential') {\n const base = interpolation[1];\n if (typeof base !== 'number')\n return context.error('Exponential interpolation requires a numeric base.', 1, 1);\n interpolation = {\n name: 'exponential',\n base\n };\n }\n else if (interpolation[0] === 'cubic-bezier') {\n const controlPoints = interpolation.slice(1);\n if (controlPoints.length !== 4 ||\n controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)) {\n return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);\n }\n interpolation = {\n name: 'cubic-bezier',\n controlPoints: controlPoints\n };\n }\n else {\n return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);\n }\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n input = context.parse(input, 2, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {\n outputType = ColorType;\n }\n else if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 0; i < rest.length; i += 2) {\n const label = rest[i];\n const value = rest[i + 1];\n const labelKey = i + 3;\n const valueKey = i + 4;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"interpolate\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n if (!verifyType(outputType, NumberType) &&\n !verifyType(outputType, ColorType) &&\n !verifyType(outputType, PaddingType) &&\n !verifyType(outputType, VariableAnchorOffsetCollectionType) &&\n !verifyType(outputType, array$1(NumberType))) {\n return context.error(`Type ${toString$1(outputType)} is not interpolatable.`);\n }\n return new Interpolate(outputType, operator, interpolation, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n const lower = labels[index];\n const upper = labels[index + 1];\n const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);\n const outputLower = outputs[index].evaluate(ctx);\n const outputUpper = outputs[index + 1].evaluate(ctx);\n switch (this.operator) {\n case 'interpolate':\n return interpolate[this.type.kind](outputLower, outputUpper, t);\n case 'interpolate-hcl':\n return interpolate.color(outputLower, outputUpper, t, 'hcl');\n case 'interpolate-lab':\n return interpolate.color(outputLower, outputUpper, t, 'lab');\n }\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n*/\nfunction exponentialInterpolation(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass Coalesce {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expectected at least one argument.');\n }\n let outputType = null;\n const expectedType = context.expectedType;\n if (expectedType && expectedType.kind !== 'value') {\n outputType = expectedType;\n }\n const parsedArgs = [];\n for (const arg of args.slice(1)) {\n const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' });\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n parsedArgs.push(parsed);\n }\n if (!outputType)\n throw new Error('No output type');\n // Above, we parse arguments without inferred type annotation so that\n // they don't produce a runtime error for `null` input, which would\n // preempt the desired null-coalescing behavior.\n // Thus, if any of our arguments would have needed an annotation, we\n // need to wrap the enclosing coalesce expression with it instead.\n const needsAnnotation = expectedType &&\n parsedArgs.some(arg => checkSubtype(expectedType, arg.type));\n return needsAnnotation ?\n new Coalesce(ValueType, parsedArgs) :\n new Coalesce(outputType, parsedArgs);\n }\n evaluate(ctx) {\n let result = null;\n let argCount = 0;\n let requestedImageName;\n for (const arg of this.args) {\n argCount++;\n result = arg.evaluate(ctx);\n // we need to keep track of the first requested image in a coalesce statement\n // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire\n if (result && result instanceof ResolvedImage && !result.available) {\n if (!requestedImageName) {\n requestedImageName = result.name;\n }\n result = null;\n if (argCount === this.args.length) {\n result = requestedImageName;\n }\n }\n if (result !== null)\n break;\n }\n return result;\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nclass Let {\n constructor(bindings, result) {\n this.type = result.type;\n this.bindings = [].concat(bindings);\n this.result = result;\n }\n evaluate(ctx) {\n return this.result.evaluate(ctx);\n }\n eachChild(fn) {\n for (const binding of this.bindings) {\n fn(binding[1]);\n }\n fn(this.result);\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);\n const bindings = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const name = args[i];\n if (typeof name !== 'string') {\n return context.error(`Expected string, but found ${typeof name} instead.`, i);\n }\n if (/[^a-zA-Z0-9_]/.test(name)) {\n return context.error('Variable names must contain only alphanumeric characters or \\'_\\'.', i);\n }\n const value = context.parse(args[i + 1], i + 1);\n if (!value)\n return null;\n bindings.push([name, value]);\n }\n const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);\n if (!result)\n return null;\n return new Let(bindings, result);\n }\n outputDefined() {\n return this.result.outputDefined();\n }\n}\n\nclass At {\n constructor(type, index, input) {\n this.type = type;\n this.index = index;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n const index = context.parse(args[1], 1, NumberType);\n const input = context.parse(args[2], 2, array$1(context.expectedType || ValueType));\n if (!index || !input)\n return null;\n const t = input.type;\n return new At(t.itemType, index, input);\n }\n evaluate(ctx) {\n const index = this.index.evaluate(ctx);\n const array = this.input.evaluate(ctx);\n if (index < 0) {\n throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);\n }\n if (index >= array.length) {\n throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);\n }\n if (index !== Math.floor(index)) {\n throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);\n }\n return array[index];\n }\n eachChild(fn) {\n fn(this.index);\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nclass In {\n constructor(needle, haystack) {\n this.type = BooleanType;\n this.needle = needle;\n this.haystack = haystack;\n }\n static parse(args, context) {\n if (args.length !== 3) {\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n return new In(needle, haystack);\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!haystack)\n return false;\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n return haystack.indexOf(needle) >= 0;\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n }\n outputDefined() {\n return true;\n }\n}\n\nclass IndexOf {\n constructor(needle, haystack, fromIndex) {\n this.type = NumberType;\n this.needle = needle;\n this.haystack = haystack;\n this.fromIndex = fromIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(needle.type)} instead`);\n }\n if (args.length === 4) {\n const fromIndex = context.parse(args[3], 3, NumberType);\n if (!fromIndex)\n return null;\n return new IndexOf(needle, haystack, fromIndex);\n }\n else {\n return new IndexOf(needle, haystack);\n }\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${toString$1(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${toString$1(typeOf(haystack))} instead.`);\n }\n if (this.fromIndex) {\n const fromIndex = this.fromIndex.evaluate(ctx);\n return haystack.indexOf(needle, fromIndex);\n }\n return haystack.indexOf(needle);\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n if (this.fromIndex) {\n fn(this.fromIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass Match {\n constructor(inputType, outputType, input, cases, outputs, otherwise) {\n this.inputType = inputType;\n this.type = outputType;\n this.input = input;\n this.cases = cases;\n this.outputs = outputs;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 5)\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 1)\n return context.error('Expected an even number of arguments.');\n let inputType;\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const cases = {};\n const outputs = [];\n for (let i = 2; i < args.length - 1; i += 2) {\n let labels = args[i];\n const value = args[i + 1];\n if (!Array.isArray(labels)) {\n labels = [labels];\n }\n const labelContext = context.concat(i);\n if (labels.length === 0) {\n return labelContext.error('Expected at least one branch label.');\n }\n for (const label of labels) {\n if (typeof label !== 'number' && typeof label !== 'string') {\n return labelContext.error('Branch labels must be numbers or strings.');\n }\n else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {\n return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);\n }\n else if (typeof label === 'number' && Math.floor(label) !== label) {\n return labelContext.error('Numeric branch labels must be integer values.');\n }\n else if (!inputType) {\n inputType = typeOf(label);\n }\n else if (labelContext.checkSubtype(inputType, typeOf(label))) {\n return null;\n }\n if (typeof cases[String(label)] !== 'undefined') {\n return labelContext.error('Branch labels must be unique.');\n }\n cases[String(label)] = outputs.length;\n }\n const result = context.parse(value, i, outputType);\n if (!result)\n return null;\n outputType = outputType || result.type;\n outputs.push(result);\n }\n const input = context.parse(args[1], 1, ValueType);\n if (!input)\n return null;\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {\n return null;\n }\n return new Match(inputType, outputType, input, cases, outputs, otherwise);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;\n return output.evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n this.outputs.forEach(fn);\n fn(this.otherwise);\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Case {\n constructor(type, branches, otherwise) {\n this.type = type;\n this.branches = branches;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 0)\n return context.error('Expected an odd number of arguments.');\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const branches = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const test = context.parse(args[i], i, BooleanType);\n if (!test)\n return null;\n const result = context.parse(args[i + 1], i + 1, outputType);\n if (!result)\n return null;\n branches.push([test, result]);\n outputType = outputType || result.type;\n }\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (!outputType)\n throw new Error('Can\\'t infer output type');\n return new Case(outputType, branches, otherwise);\n }\n evaluate(ctx) {\n for (const [test, expression] of this.branches) {\n if (test.evaluate(ctx)) {\n return expression.evaluate(ctx);\n }\n }\n return this.otherwise.evaluate(ctx);\n }\n eachChild(fn) {\n for (const [test, expression] of this.branches) {\n fn(test);\n fn(expression);\n }\n fn(this.otherwise);\n }\n outputDefined() {\n return this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Slice {\n constructor(type, input, beginIndex, endIndex) {\n this.type = type;\n this.input = input;\n this.beginIndex = beginIndex;\n this.endIndex = endIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const input = context.parse(args[1], 1, ValueType);\n const beginIndex = context.parse(args[2], 2, NumberType);\n if (!input || !beginIndex)\n return null;\n if (!isValidType(input.type, [array$1(ValueType), StringType, ValueType])) {\n return context.error(`Expected first argument to be of type array or string, but found ${toString$1(input.type)} instead`);\n }\n if (args.length === 4) {\n const endIndex = context.parse(args[3], 3, NumberType);\n if (!endIndex)\n return null;\n return new Slice(input.type, input, beginIndex, endIndex);\n }\n else {\n return new Slice(input.type, input, beginIndex);\n }\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const beginIndex = this.beginIndex.evaluate(ctx);\n if (!isValidNativeType(input, ['string', 'array'])) {\n throw new RuntimeError(`Expected first argument to be of type array or string, but found ${toString$1(typeOf(input))} instead.`);\n }\n if (this.endIndex) {\n const endIndex = this.endIndex.evaluate(ctx);\n return input.slice(beginIndex, endIndex);\n }\n return input.slice(beginIndex);\n }\n eachChild(fn) {\n fn(this.input);\n fn(this.beginIndex);\n if (this.endIndex) {\n fn(this.endIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nfunction isComparableType(op, type) {\n if (op === '==' || op === '!=') {\n // equality operator\n return type.kind === 'boolean' ||\n type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'null' ||\n type.kind === 'value';\n }\n else {\n // ordering operator\n return type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'value';\n }\n}\nfunction eq(ctx, a, b) { return a === b; }\nfunction neq(ctx, a, b) { return a !== b; }\nfunction lt(ctx, a, b) { return a < b; }\nfunction gt(ctx, a, b) { return a > b; }\nfunction lteq(ctx, a, b) { return a <= b; }\nfunction gteq(ctx, a, b) { return a >= b; }\nfunction eqCollate(ctx, a, b, c) { return c.compare(a, b) === 0; }\nfunction neqCollate(ctx, a, b, c) { return !eqCollate(ctx, a, b, c); }\nfunction ltCollate(ctx, a, b, c) { return c.compare(a, b) < 0; }\nfunction gtCollate(ctx, a, b, c) { return c.compare(a, b) > 0; }\nfunction lteqCollate(ctx, a, b, c) { return c.compare(a, b) <= 0; }\nfunction gteqCollate(ctx, a, b, c) { return c.compare(a, b) >= 0; }\n/**\n * Special form for comparison operators, implementing the signatures:\n * - (T, T, ?Collator) => boolean\n * - (T, value, ?Collator) => boolean\n * - (value, T, ?Collator) => boolean\n *\n * For inequalities, T must be either value, string, or number. For ==/!=, it\n * can also be boolean or null.\n *\n * Equality semantics are equivalent to Javascript's strict equality (===/!==)\n * -- i.e., when the arguments' types don't match, == evaluates to false, != to\n * true.\n *\n * When types don't match in an ordering comparison, a runtime error is thrown.\n *\n * @private\n */\nfunction makeComparison(op, compareBasic, compareWithCollator) {\n const isOrderComparison = op !== '==' && op !== '!=';\n return class Comparison {\n constructor(lhs, rhs, collator) {\n this.type = BooleanType;\n this.lhs = lhs;\n this.rhs = rhs;\n this.collator = collator;\n this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';\n }\n static parse(args, context) {\n if (args.length !== 3 && args.length !== 4)\n return context.error('Expected two or three arguments.');\n const op = args[0];\n let lhs = context.parse(args[1], 1, ValueType);\n if (!lhs)\n return null;\n if (!isComparableType(op, lhs.type)) {\n return context.concat(1).error(`\"${op}\" comparisons are not supported for type '${toString$1(lhs.type)}'.`);\n }\n let rhs = context.parse(args[2], 2, ValueType);\n if (!rhs)\n return null;\n if (!isComparableType(op, rhs.type)) {\n return context.concat(2).error(`\"${op}\" comparisons are not supported for type '${toString$1(rhs.type)}'.`);\n }\n if (lhs.type.kind !== rhs.type.kind &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`);\n }\n if (isOrderComparison) {\n // typing rules specific to less/greater than operators\n if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {\n // (value, T)\n lhs = new Assertion(rhs.type, [lhs]);\n }\n else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {\n // (T, value)\n rhs = new Assertion(lhs.type, [rhs]);\n }\n }\n let collator = null;\n if (args.length === 4) {\n if (lhs.type.kind !== 'string' &&\n rhs.type.kind !== 'string' &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error('Cannot use collator to compare non-string types.');\n }\n collator = context.parse(args[3], 3, CollatorType);\n if (!collator)\n return null;\n }\n return new Comparison(lhs, rhs, collator);\n }\n evaluate(ctx) {\n const lhs = this.lhs.evaluate(ctx);\n const rhs = this.rhs.evaluate(ctx);\n if (isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n // check that type is string or number, and equal\n if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {\n throw new RuntimeError(`Expected arguments for \"${op}\" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`);\n }\n }\n if (this.collator && !isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n if (lt.kind !== 'string' || rt.kind !== 'string') {\n return compareBasic(ctx, lhs, rhs);\n }\n }\n return this.collator ?\n compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) :\n compareBasic(ctx, lhs, rhs);\n }\n eachChild(fn) {\n fn(this.lhs);\n fn(this.rhs);\n if (this.collator) {\n fn(this.collator);\n }\n }\n outputDefined() {\n return true;\n }\n };\n}\nconst Equals = makeComparison('==', eq, eqCollate);\nconst NotEquals = makeComparison('!=', neq, neqCollate);\nconst LessThan = makeComparison('<', lt, ltCollate);\nconst GreaterThan = makeComparison('>', gt, gtCollate);\nconst LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);\nconst GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);\n\nclass NumberFormat {\n constructor(number, locale, currency, minFractionDigits, maxFractionDigits) {\n this.type = StringType;\n this.number = number;\n this.locale = locale;\n this.currency = currency;\n this.minFractionDigits = minFractionDigits;\n this.maxFractionDigits = maxFractionDigits;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error('Expected two arguments.');\n const number = context.parse(args[1], 1, NumberType);\n if (!number)\n return null;\n const options = args[2];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('NumberFormat options argument must be an object.');\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n let currency = null;\n if (options['currency']) {\n currency = context.parse(options['currency'], 1, StringType);\n if (!currency)\n return null;\n }\n let minFractionDigits = null;\n if (options['min-fraction-digits']) {\n minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);\n if (!minFractionDigits)\n return null;\n }\n let maxFractionDigits = null;\n if (options['max-fraction-digits']) {\n maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);\n if (!maxFractionDigits)\n return null;\n }\n return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);\n }\n evaluate(ctx) {\n return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {\n style: this.currency ? 'currency' : 'decimal',\n currency: this.currency ? this.currency.evaluate(ctx) : undefined,\n minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,\n maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,\n }).format(this.number.evaluate(ctx));\n }\n eachChild(fn) {\n fn(this.number);\n if (this.locale) {\n fn(this.locale);\n }\n if (this.currency) {\n fn(this.currency);\n }\n if (this.minFractionDigits) {\n fn(this.minFractionDigits);\n }\n if (this.maxFractionDigits) {\n fn(this.maxFractionDigits);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass FormatExpression {\n constructor(sections) {\n this.type = FormattedType;\n this.sections = sections;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n const firstArg = args[1];\n if (!Array.isArray(firstArg) && typeof firstArg === 'object') {\n return context.error('First argument must be an image or text section.');\n }\n const sections = [];\n let nextTokenMayBeObject = false;\n for (let i = 1; i <= args.length - 1; ++i) {\n const arg = args[i];\n if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) {\n nextTokenMayBeObject = false;\n let scale = null;\n if (arg['font-scale']) {\n scale = context.parse(arg['font-scale'], 1, NumberType);\n if (!scale)\n return null;\n }\n let font = null;\n if (arg['text-font']) {\n font = context.parse(arg['text-font'], 1, array$1(StringType));\n if (!font)\n return null;\n }\n let textColor = null;\n if (arg['text-color']) {\n textColor = context.parse(arg['text-color'], 1, ColorType);\n if (!textColor)\n return null;\n }\n const lastExpression = sections[sections.length - 1];\n lastExpression.scale = scale;\n lastExpression.font = font;\n lastExpression.textColor = textColor;\n }\n else {\n const content = context.parse(args[i], 1, ValueType);\n if (!content)\n return null;\n const kind = content.type.kind;\n if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage')\n return context.error('Formatted text type must be \\'string\\', \\'value\\', \\'image\\' or \\'null\\'.');\n nextTokenMayBeObject = true;\n sections.push({ content, scale: null, font: null, textColor: null });\n }\n }\n return new FormatExpression(sections);\n }\n evaluate(ctx) {\n const evaluateSection = section => {\n const evaluatedContent = section.content.evaluate(ctx);\n if (typeOf(evaluatedContent) === ResolvedImageType) {\n return new FormattedSection('', evaluatedContent, null, null, null);\n }\n return new FormattedSection(toString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null);\n };\n return new Formatted(this.sections.map(evaluateSection));\n }\n eachChild(fn) {\n for (const section of this.sections) {\n fn(section.content);\n if (section.scale) {\n fn(section.scale);\n }\n if (section.font) {\n fn(section.font);\n }\n if (section.textColor) {\n fn(section.textColor);\n }\n }\n }\n outputDefined() {\n // Technically the combinatoric set of all children\n // Usually, this.text will be undefined anyway\n return false;\n }\n}\n\nclass ImageExpression {\n constructor(input) {\n this.type = ResolvedImageType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error('Expected two arguments.');\n }\n const name = context.parse(args[1], 1, StringType);\n if (!name)\n return context.error('No image name provided.');\n return new ImageExpression(name);\n }\n evaluate(ctx) {\n const evaluatedImageName = this.input.evaluate(ctx);\n const value = ResolvedImage.fromString(evaluatedImageName);\n if (value && ctx.availableImages)\n value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;\n return value;\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n // The output of image is determined by the list of available images in the evaluation context\n return false;\n }\n}\n\nclass Length {\n constructor(input) {\n this.type = NumberType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n const input = context.parse(args[1], 1);\n if (!input)\n return null;\n if (input.type.kind !== 'array' && input.type.kind !== 'string' && input.type.kind !== 'value')\n return context.error(`Expected argument of type string or array, but found ${toString$1(input.type)} instead.`);\n return new Length(input);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n if (typeof input === 'string') {\n return input.length;\n }\n else if (Array.isArray(input)) {\n return input.length;\n }\n else {\n throw new RuntimeError(`Expected value to be of type string or array, but found ${toString$1(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nconst expressions = {\n // special forms\n '==': Equals,\n '!=': NotEquals,\n '>': GreaterThan,\n '<': LessThan,\n '>=': GreaterThanOrEqual,\n '<=': LessThanOrEqual,\n 'array': Assertion,\n 'at': At,\n 'boolean': Assertion,\n 'case': Case,\n 'coalesce': Coalesce,\n 'collator': CollatorExpression,\n 'format': FormatExpression,\n 'image': ImageExpression,\n 'in': In,\n 'index-of': IndexOf,\n 'interpolate': Interpolate,\n 'interpolate-hcl': Interpolate,\n 'interpolate-lab': Interpolate,\n 'length': Length,\n 'let': Let,\n 'literal': Literal,\n 'match': Match,\n 'number': Assertion,\n 'number-format': NumberFormat,\n 'object': Assertion,\n 'slice': Slice,\n 'step': Step,\n 'string': Assertion,\n 'to-boolean': Coercion,\n 'to-color': Coercion,\n 'to-number': Coercion,\n 'to-string': Coercion,\n 'var': Var,\n 'within': Within\n};\nfunction rgba(ctx, [r, g, b, a]) {\n r = r.evaluate(ctx);\n g = g.evaluate(ctx);\n b = b.evaluate(ctx);\n const alpha = a ? a.evaluate(ctx) : 1;\n const error = validateRGBA(r, g, b, alpha);\n if (error)\n throw new RuntimeError(error);\n return new Color(r / 255, g / 255, b / 255, alpha, false);\n}\nfunction has(key, obj) {\n return key in obj;\n}\nfunction get(key, obj) {\n const v = obj[key];\n return typeof v === 'undefined' ? null : v;\n}\nfunction binarySearch(v, a, i, j) {\n while (i <= j) {\n const m = (i + j) >> 1;\n if (a[m] === v)\n return true;\n if (a[m] > v)\n j = m - 1;\n else\n i = m + 1;\n }\n return false;\n}\nfunction varargs(type) {\n return { type };\n}\nCompoundExpression.register(expressions, {\n 'error': [\n ErrorType,\n [StringType],\n (ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); }\n ],\n 'typeof': [\n StringType,\n [ValueType],\n (ctx, [v]) => toString$1(typeOf(v.evaluate(ctx)))\n ],\n 'to-rgba': [\n array$1(NumberType, 4),\n [ColorType],\n (ctx, [v]) => {\n const [r, g, b, a] = v.evaluate(ctx).rgb;\n return [r * 255, g * 255, b * 255, a];\n },\n ],\n 'rgb': [\n ColorType,\n [NumberType, NumberType, NumberType],\n rgba\n ],\n 'rgba': [\n ColorType,\n [NumberType, NumberType, NumberType, NumberType],\n rgba\n ],\n 'has': {\n type: BooleanType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'get': {\n type: ValueType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'feature-state': [\n ValueType,\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})\n ],\n 'properties': [\n ObjectType,\n [],\n (ctx) => ctx.properties()\n ],\n 'geometry-type': [\n StringType,\n [],\n (ctx) => ctx.geometryType()\n ],\n 'id': [\n ValueType,\n [],\n (ctx) => ctx.id()\n ],\n 'zoom': [\n NumberType,\n [],\n (ctx) => ctx.globals.zoom\n ],\n 'heatmap-density': [\n NumberType,\n [],\n (ctx) => ctx.globals.heatmapDensity || 0\n ],\n 'line-progress': [\n NumberType,\n [],\n (ctx) => ctx.globals.lineProgress || 0\n ],\n 'accumulated': [\n ValueType,\n [],\n (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated\n ],\n '+': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 0;\n for (const arg of args) {\n result += arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '*': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 1;\n for (const arg of args) {\n result *= arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '-': {\n type: NumberType,\n overloads: [\n [\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)\n ], [\n [NumberType],\n (ctx, [a]) => -a.evaluate(ctx)\n ]\n ]\n },\n '/': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)\n ],\n '%': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)\n ],\n 'ln2': [\n NumberType,\n [],\n () => Math.LN2\n ],\n 'pi': [\n NumberType,\n [],\n () => Math.PI\n ],\n 'e': [\n NumberType,\n [],\n () => Math.E\n ],\n '^': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))\n ],\n 'sqrt': [\n NumberType,\n [NumberType],\n (ctx, [x]) => Math.sqrt(x.evaluate(ctx))\n ],\n 'log10': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10\n ],\n 'ln': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx))\n ],\n 'log2': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2\n ],\n 'sin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.sin(n.evaluate(ctx))\n ],\n 'cos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.cos(n.evaluate(ctx))\n ],\n 'tan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.tan(n.evaluate(ctx))\n ],\n 'asin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.asin(n.evaluate(ctx))\n ],\n 'acos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.acos(n.evaluate(ctx))\n ],\n 'atan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.atan(n.evaluate(ctx))\n ],\n 'min': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'max': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'abs': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.abs(n.evaluate(ctx))\n ],\n 'round': [\n NumberType,\n [NumberType],\n (ctx, [n]) => {\n const v = n.evaluate(ctx);\n // Javascript's Math.round() rounds towards +Infinity for halfway\n // values, even when they're negative. It's more common to round\n // away from 0 (e.g., this is what python and C++ do)\n return v < 0 ? -Math.round(-v) : Math.round(v);\n }\n ],\n 'floor': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.floor(n.evaluate(ctx))\n ],\n 'ceil': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.ceil(n.evaluate(ctx))\n ],\n 'filter-==': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => ctx.properties()[k.value] === v.value\n ],\n 'filter-id-==': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => ctx.id() === v.value\n ],\n 'filter-type-==': [\n BooleanType,\n [StringType],\n (ctx, [v]) => ctx.geometryType() === v.value\n ],\n 'filter-<': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter-id-<': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter->': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-id->': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-<=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter-id-<=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter->=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-id->=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-has': [\n BooleanType,\n [ValueType],\n (ctx, [k]) => k.value in ctx.properties()\n ],\n 'filter-has-id': [\n BooleanType,\n [],\n (ctx) => (ctx.id() !== null && ctx.id() !== undefined)\n ],\n 'filter-type-in': [\n BooleanType,\n [array$1(StringType)],\n (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0\n ],\n 'filter-id-in': [\n BooleanType,\n [array$1(ValueType)],\n (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0\n ],\n 'filter-in-small': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is an array literal\n (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0\n ],\n 'filter-in-large': [\n BooleanType,\n [StringType, array$1(ValueType)],\n // assumes v is a array literal with values sorted in ascending order and of a single type\n (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)\n ],\n 'all': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (!arg.evaluate(ctx))\n return false;\n }\n return true;\n }\n ]\n ]\n },\n 'any': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (arg.evaluate(ctx))\n return true;\n }\n return false;\n }\n ]\n ]\n },\n '!': [\n BooleanType,\n [BooleanType],\n (ctx, [b]) => !b.evaluate(ctx)\n ],\n 'is-supported-script': [\n BooleanType,\n [StringType],\n // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant\n (ctx, [s]) => {\n const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;\n if (isSupportedScript) {\n return isSupportedScript(s.evaluate(ctx));\n }\n return true;\n }\n ],\n 'upcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toUpperCase()\n ],\n 'downcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toLowerCase()\n ],\n 'concat': [\n StringType,\n varargs(ValueType),\n (ctx, args) => args.map(arg => toString(arg.evaluate(ctx))).join('')\n ],\n 'resolved-locale': [\n StringType,\n [CollatorType],\n (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()\n ]\n});\n\nfunction success(value) {\n return { result: 'success', value };\n}\nfunction error(value) {\n return { result: 'error', value };\n}\n\nfunction supportsPropertyExpression(spec) {\n return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven';\n}\nfunction supportsZoomExpression(spec) {\n return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;\n}\nfunction supportsInterpolation(spec) {\n return !!spec.expression && spec.expression.interpolated;\n}\n\nfunction getType(val) {\n if (val instanceof Number) {\n return 'number';\n }\n else if (val instanceof String) {\n return 'string';\n }\n else if (val instanceof Boolean) {\n return 'boolean';\n }\n else if (Array.isArray(val)) {\n return 'array';\n }\n else if (val === null) {\n return 'null';\n }\n else {\n return typeof val;\n }\n}\n\nfunction isFunction(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\nfunction identityFunction(x) {\n return x;\n}\nfunction createFunction(parameters, propertySpec) {\n const isColor = propertySpec.type === 'color';\n const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');\n if (isColor || propertySpec.type === 'padding') {\n const parseFn = isColor ? Color.parse : Padding.parse;\n parameters = extendBy({}, parameters);\n if (parameters.stops) {\n parameters.stops = parameters.stops.map((stop) => {\n return [stop[0], parseFn(stop[1])];\n });\n }\n if (parameters.default) {\n parameters.default = parseFn(parameters.default);\n }\n else {\n parameters.default = parseFn(propertySpec.default);\n }\n }\n if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) {\n throw new Error(`Unknown color space: \"${parameters.colorSpace}\"`);\n }\n let innerFun;\n let hashedStops;\n let categoricalKeyType;\n if (type === 'exponential') {\n innerFun = evaluateExponentialFunction;\n }\n else if (type === 'interval') {\n innerFun = evaluateIntervalFunction;\n }\n else if (type === 'categorical') {\n innerFun = evaluateCategoricalFunction;\n // For categorical functions, generate an Object as a hashmap of the stops for fast searching\n hashedStops = Object.create(null);\n for (const stop of parameters.stops) {\n hashedStops[stop[0]] = stop[1];\n }\n // Infer key type based on first stop key-- used to encforce strict type checking later\n categoricalKeyType = typeof parameters.stops[0][0];\n }\n else if (type === 'identity') {\n innerFun = evaluateIdentityFunction;\n }\n else {\n throw new Error(`Unknown function type \"${type}\"`);\n }\n if (zoomAndFeatureDependent) {\n const featureFunctions = {};\n const zoomStops = [];\n for (let s = 0; s < parameters.stops.length; s++) {\n const stop = parameters.stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctions[zoom] === undefined) {\n featureFunctions[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n stops: []\n };\n zoomStops.push(zoom);\n }\n featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);\n }\n const featureFunctionStops = [];\n for (const z of zoomStops) {\n featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);\n }\n const interpolationType = { name: 'linear' };\n return {\n kind: 'composite',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: featureFunctionStops.map(s => s[0]),\n evaluate({ zoom }, properties) {\n return evaluateExponentialFunction({\n stops: featureFunctionStops,\n base: parameters.base\n }, propertySpec, zoom).evaluate(zoom, properties);\n }\n };\n }\n else if (zoomDependent) {\n const interpolationType = type === 'exponential' ?\n { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 } : null;\n return {\n kind: 'camera',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: parameters.stops.map(s => s[0]),\n evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)\n };\n }\n else {\n return {\n kind: 'source',\n evaluate(_, feature) {\n const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;\n if (value === undefined) {\n return coalesce$1(parameters.default, propertySpec.default);\n }\n return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);\n }\n };\n }\n}\nfunction coalesce$1(a, b, c) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n if (c !== undefined)\n return c;\n}\nfunction evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {\n const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input\n return coalesce$1(evaluated, parameters.default, propertySpec.default);\n}\nfunction evaluateIntervalFunction(parameters, propertySpec, input) {\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n return parameters.stops[index][1];\n}\nfunction evaluateExponentialFunction(parameters, propertySpec, input) {\n const base = parameters.base !== undefined ? parameters.base : 1;\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);\n const outputLower = parameters.stops[index][1];\n const outputUpper = parameters.stops[index + 1][1];\n const interp = interpolate[propertySpec.type] || identityFunction;\n if (typeof outputLower.evaluate === 'function') {\n return {\n evaluate(...args) {\n const evaluatedLower = outputLower.evaluate.apply(undefined, args);\n const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);\n // Special case for fill-outline-color, which has no spec default.\n if (evaluatedLower === undefined || evaluatedUpper === undefined) {\n return undefined;\n }\n return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace);\n }\n };\n }\n return interp(outputLower, outputUpper, t, parameters.colorSpace);\n}\nfunction evaluateIdentityFunction(parameters, propertySpec, input) {\n switch (propertySpec.type) {\n case 'color':\n input = Color.parse(input);\n break;\n case 'formatted':\n input = Formatted.fromString(input.toString());\n break;\n case 'resolvedImage':\n input = ResolvedImage.fromString(input.toString());\n break;\n case 'padding':\n input = Padding.parse(input);\n break;\n default:\n if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {\n input = undefined;\n }\n }\n return coalesce$1(input, parameters.default, propertySpec.default);\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n *\n * How it works:\n * Two consecutive stop values define a (scaled and shifted) exponential\n * function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction interpolationFactor(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass StyleExpression {\n constructor(expression, propertySpec) {\n this.expression = expression;\n this._warningHistory = {};\n this._evaluator = new EvaluationContext();\n this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;\n this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature;\n this._evaluator.featureState = featureState;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection;\n return this.expression.evaluate(this._evaluator);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature || null;\n this._evaluator.featureState = featureState || null;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection || null;\n try {\n const val = this.expression.evaluate(this._evaluator);\n // eslint-disable-next-line no-self-compare\n if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {\n return this._defaultValue;\n }\n if (this._enumValues && !(val in this._enumValues)) {\n throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);\n }\n return val;\n }\n catch (e) {\n if (!this._warningHistory[e.message]) {\n this._warningHistory[e.message] = true;\n if (typeof console !== 'undefined') {\n console.warn(e.message);\n }\n }\n return this._defaultValue;\n }\n }\n}\nfunction isExpression(expression) {\n return Array.isArray(expression) && expression.length > 0 &&\n typeof expression[0] === 'string' && expression[0] in expressions;\n}\n/**\n * Parse and typecheck the given style spec JSON expression. If\n * options.defaultValue is provided, then the resulting StyleExpression's\n * `evaluate()` method will handle errors by logging a warning (once per\n * message) and returning the default value. Otherwise, it will throw\n * evaluation errors.\n *\n * @private\n */\nfunction createExpression(expression, propertySpec) {\n const parser = new ParsingContext(expressions, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined);\n // For string-valued properties, coerce to string at the top level rather than asserting.\n const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);\n if (!parsed) {\n return error(parser.errors);\n }\n return success(new StyleExpression(parsed, propertySpec));\n}\nclass ZoomConstantExpression {\n constructor(kind, expression) {\n this.kind = kind;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'constant' && !isStateConstant(expression.expression);\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n}\nclass ZoomDependentExpression {\n constructor(kind, expression, zoomStops, interpolationType) {\n this.kind = kind;\n this.zoomStops = zoomStops;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'camera' && !isStateConstant(expression.expression);\n this.interpolationType = interpolationType;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n interpolationFactor(input, lower, upper) {\n if (this.interpolationType) {\n return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);\n }\n else {\n return 0;\n }\n }\n}\nfunction isZoomExpression(expression) {\n return expression._styleExpression !== undefined;\n}\nfunction createPropertyExpression(expressionInput, propertySpec) {\n const expression = createExpression(expressionInput, propertySpec);\n if (expression.result === 'error') {\n return expression;\n }\n const parsed = expression.value.expression;\n const isFeatureConstantResult = isFeatureConstant(parsed);\n if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'data expressions not supported')]);\n }\n const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']);\n if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'zoom expressions not supported')]);\n }\n const zoomCurve = findZoomCurve(parsed);\n if (!zoomCurve && !isZoomConstant) {\n return error([new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.')]);\n }\n else if (zoomCurve instanceof ExpressionParsingError) {\n return error([zoomCurve]);\n }\n else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {\n return error([new ExpressionParsingError('', '\"interpolate\" expressions cannot be used with this property')]);\n }\n if (!zoomCurve) {\n return success(isFeatureConstantResult ?\n new ZoomConstantExpression('constant', expression.value) :\n new ZoomConstantExpression('source', expression.value));\n }\n const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;\n return success(isFeatureConstantResult ?\n new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType) :\n new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType));\n}\n// serialization wrapper for old-style stop functions normalized to the\n// expression interface\nclass StylePropertyFunction {\n constructor(parameters, specification) {\n this._parameters = parameters;\n this._specification = specification;\n extendBy(this, createFunction(this._parameters, this._specification));\n }\n static deserialize(serialized) {\n return new StylePropertyFunction(serialized._parameters, serialized._specification);\n }\n static serialize(input) {\n return {\n _parameters: input._parameters,\n _specification: input._specification\n };\n }\n}\nfunction normalizePropertyExpression(value, specification) {\n if (isFunction(value)) {\n return new StylePropertyFunction(value, specification);\n }\n else if (isExpression(value)) {\n const expression = createPropertyExpression(value, specification);\n if (expression.result === 'error') {\n // this should have been caught in validation\n throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n return expression.value;\n }\n else {\n let constant = value;\n if (specification.type === 'color' && typeof value === 'string') {\n constant = Color.parse(value);\n }\n else if (specification.type === 'padding' && (typeof value === 'number' || Array.isArray(value))) {\n constant = Padding.parse(value);\n }\n else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) {\n constant = VariableAnchorOffsetCollection.parse(value);\n }\n return {\n kind: 'constant',\n evaluate: () => constant\n };\n }\n}\n// Zoom-dependent expressions may only use [\"zoom\"] as the input to a top-level \"step\" or \"interpolate\"\n// expression (collectively referred to as a \"curve\"). The curve may be wrapped in one or more \"let\" or\n// \"coalesce\" expressions.\nfunction findZoomCurve(expression) {\n let result = null;\n if (expression instanceof Let) {\n result = findZoomCurve(expression.result);\n }\n else if (expression instanceof Coalesce) {\n for (const arg of expression.args) {\n result = findZoomCurve(arg);\n if (result) {\n break;\n }\n }\n }\n else if ((expression instanceof Step || expression instanceof Interpolate) &&\n expression.input instanceof CompoundExpression &&\n expression.input.name === 'zoom') {\n result = expression;\n }\n if (result instanceof ExpressionParsingError) {\n return result;\n }\n expression.eachChild((child) => {\n const childResult = findZoomCurve(child);\n if (childResult instanceof ExpressionParsingError) {\n result = childResult;\n }\n else if (!result && childResult) {\n result = new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.');\n }\n else if (result && childResult && result !== childResult) {\n result = new ExpressionParsingError('', 'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.');\n }\n });\n return result;\n}\nfunction getExpectedType(spec) {\n const types = {\n color: ColorType,\n string: StringType,\n number: NumberType,\n enum: StringType,\n boolean: BooleanType,\n formatted: FormattedType,\n padding: PaddingType,\n resolvedImage: ResolvedImageType,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType\n };\n if (spec.type === 'array') {\n return array$1(types[spec.value] || ValueType, spec.length);\n }\n return types[spec.type];\n}\nfunction getDefaultValue(spec) {\n if (spec.type === 'color' && isFunction(spec.default)) {\n // Special case for heatmap-color: it uses the 'default:' to define a\n // default color ramp, but createExpression expects a simple value to fall\n // back to in case of runtime errors\n return new Color(0, 0, 0, 0);\n }\n else if (spec.type === 'color') {\n return Color.parse(spec.default) || null;\n }\n else if (spec.type === 'padding') {\n return Padding.parse(spec.default) || null;\n }\n else if (spec.type === 'variableAnchorOffsetCollection') {\n return VariableAnchorOffsetCollection.parse(spec.default) || null;\n }\n else if (spec.default === undefined) {\n return null;\n }\n else {\n return spec.default;\n }\n}\n\nfunction isExpressionFilter(filter) {\n if (filter === true || filter === false) {\n return true;\n }\n if (!Array.isArray(filter) || filter.length === 0) {\n return false;\n }\n switch (filter[0]) {\n case 'has':\n return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';\n case 'in':\n return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2]));\n case '!in':\n case '!has':\n case 'none':\n return false;\n case '==':\n case '!=':\n case '>':\n case '>=':\n case '<':\n case '<=':\n return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2]));\n case 'any':\n case 'all':\n for (const f of filter.slice(1)) {\n if (!isExpressionFilter(f) && typeof f !== 'boolean') {\n return false;\n }\n }\n return true;\n default:\n return true;\n }\n}\nconst filterSpec = {\n 'type': 'boolean',\n 'default': false,\n 'transition': false,\n 'property-type': 'data-driven',\n 'expression': {\n 'interpolated': false,\n 'parameters': ['zoom', 'feature']\n }\n};\n/**\n * Given a filter expressed as nested arrays, return a new function\n * that evaluates whether a given feature (with a .properties or .tags property)\n * passes its test.\n *\n * @private\n * @param {Array} filter MapLibre filter\n * @returns {Function} filter-evaluating function\n */\nfunction createFilter(filter) {\n if (filter === null || filter === undefined) {\n return { filter: () => true, needGeometry: false };\n }\n if (!isExpressionFilter(filter)) {\n filter = convertFilter$1(filter);\n }\n const compiled = createExpression(filter, filterSpec);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n else {\n const needGeometry = geometryNeeded(filter);\n return { filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical),\n needGeometry };\n }\n}\n// Comparison function to sort numbers and strings\nfunction compare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\nfunction geometryNeeded(filter) {\n if (!Array.isArray(filter))\n return false;\n if (filter[0] === 'within')\n return true;\n for (let index = 1; index < filter.length; index++) {\n if (geometryNeeded(filter[index]))\n return true;\n }\n return false;\n}\nfunction convertFilter$1(filter) {\n if (!filter)\n return true;\n const op = filter[0];\n if (filter.length <= 1)\n return (op !== 'any');\n const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') :\n op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) :\n op === '<' ||\n op === '>' ||\n op === '<=' ||\n op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) :\n op === 'any' ? convertDisjunctionOp(filter.slice(1)) :\n op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) :\n op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) :\n op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) :\n op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) :\n op === 'has' ? convertHasOp$1(filter[1]) :\n op === '!has' ? convertNegation(convertHasOp$1(filter[1])) :\n op === 'within' ? filter :\n true;\n return converted;\n}\nfunction convertComparisonOp$1(property, value, op) {\n switch (property) {\n case '$type':\n return [`filter-type-${op}`, value];\n case '$id':\n return [`filter-id-${op}`, value];\n default:\n return [`filter-${op}`, property, value];\n }\n}\nfunction convertDisjunctionOp(filters) {\n return ['any'].concat(filters.map(convertFilter$1));\n}\nfunction convertInOp$1(property, values) {\n if (values.length === 0) {\n return false;\n }\n switch (property) {\n case '$type':\n return ['filter-type-in', ['literal', values]];\n case '$id':\n return ['filter-id-in', ['literal', values]];\n default:\n if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) {\n return ['filter-in-large', property, ['literal', values.sort(compare)]];\n }\n else {\n return ['filter-in-small', property, ['literal', values]];\n }\n }\n}\nfunction convertHasOp$1(property) {\n switch (property) {\n case '$type':\n return true;\n case '$id':\n return ['filter-has-id'];\n default:\n return ['filter-has', property];\n }\n}\nfunction convertNegation(filter) {\n return ['!', filter];\n}\n\n/*\n * Convert the given filter to an expression, storing the expected types for\n * any feature properties referenced in expectedTypes.\n *\n * These expected types are needed in order to construct preflight type checks\n * needed for handling 'any' filters. A preflight type check is necessary in\n * order to mimic legacy filters' semantics around expected type mismatches.\n * For example, consider the legacy filter:\n *\n * [\"any\", [\"all\", [\">\", \"y\", 0], [\">\", \"y\", 0]], [\">\", \"x\", 0]]\n *\n * Naively, we might convert this to the expression:\n *\n * [\"any\", [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]], [\">\", [\"get\", \"x\"], 0]]\n *\n * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the\n * [\">\", [\"get\", \"y\"], 0] would cause an evaluation error, leading to the\n * entire filter returning false. Legacy filter semantics, though, ask for\n * [\">\", \"y\", 0] to simply return `false` when `y` is of the wrong type,\n * allowing the subsequent terms of the outer \"any\" expression to be evaluated\n * (resulting, in this case, in a `true` value, because x > 0).\n *\n * We account for this by inserting a preflight type-checking expression before\n * each \"any\" term, allowing us to avoid evaluating the actual converted filter\n * if any type mismatches would cause it to produce an evalaution error:\n *\n * [\"any\",\n * [\"case\",\n * [\"all\", [\"==\", [\"typeof\", [\"get\", \"y\"]], \"number\"], [\"==\", [\"typeof\", [\"get\", \"z\"], \"number]],\n * [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]],\n * false\n * ],\n * [\"case\",\n * [\"==\", [\"typeof\", [\"get\", \"x\"], \"number\"]],\n * [\">\", [\"get\", \"x\"], 0],\n * false\n * ]\n * ]\n *\n * An alternative, possibly more direct approach would be to use type checks\n * in the conversion of each comparison operator, so that the converted version\n * of each individual ==, >=, etc. would mimic the legacy filter semantics. The\n * downside of this approach is that it can lead to many more type checks than\n * would otherwise be necessary: outside the context of an \"any\" expression,\n * bailing out due to a runtime type error (expression semantics) and returning\n * false (legacy filter semantics) are equivalent: they cause the filter to\n * produce a `false` result.\n */\nfunction convertFilter(filter, expectedTypes = {}) {\n if (isExpressionFilter(filter))\n return filter;\n if (!filter)\n return true;\n const legacyFilter = filter;\n const legacyOp = legacyFilter[0];\n if (filter.length <= 1)\n return (legacyOp !== 'any');\n switch (legacyOp) {\n case '==':\n case '!=':\n case '<':\n case '>':\n case '<=':\n case '>=': {\n const [, property, value] = filter;\n return convertComparisonOp(property, value, legacyOp, expectedTypes);\n }\n case 'any': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => {\n const types = {};\n const child = convertFilter(f, types);\n const typechecks = runtimeTypeChecks(types);\n return typechecks === true ? child : ['case', typechecks, child, false];\n });\n return ['any', ...children];\n }\n case 'all': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map(f => convertFilter(f, expectedTypes));\n return children.length > 1 ? ['all', ...children] : children[0];\n }\n case 'none': {\n const [, ...conditions] = legacyFilter;\n return ['!', convertFilter(['any', ...conditions], {})];\n }\n case 'in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values);\n }\n case '!in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values, true);\n }\n case 'has':\n return convertHasOp(legacyFilter[1]);\n case '!has':\n return ['!', convertHasOp(legacyFilter[1])];\n default:\n return true;\n }\n}\n// Given a set of feature properties and an expected type for each one,\n// construct an boolean expression that tests whether each property has the\n// right type.\n// E.g.: for {name: 'string', population: 'number'}, return\n// [ 'all',\n// ['==', ['typeof', ['get', 'name'], 'string']],\n// ['==', ['typeof', ['get', 'population'], 'number]]\n// ]\nfunction runtimeTypeChecks(expectedTypes) {\n const conditions = [];\n for (const property in expectedTypes) {\n const get = property === '$id' ? ['id'] : ['get', property];\n conditions.push(['==', ['typeof', get], expectedTypes[property]]);\n }\n if (conditions.length === 0)\n return true;\n if (conditions.length === 1)\n return conditions[0];\n return ['all', ...conditions];\n}\nfunction convertComparisonOp(property, value, op, expectedTypes) {\n let get;\n if (property === '$type') {\n return [op, ['geometry-type'], value];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n if (expectedTypes && value !== null) {\n const type = typeof value;\n expectedTypes[property] = type;\n }\n if (op === '==' && property !== '$id' && value === null) {\n return [\n 'all',\n ['has', property],\n ['==', get, null]\n ];\n }\n else if (op === '!=' && property !== '$id' && value === null) {\n return [\n 'any',\n ['!', ['has', property]],\n ['!=', get, null]\n ];\n }\n return [op, get, value];\n}\nfunction convertInOp(property, values, negate = false) {\n if (values.length === 0)\n return negate;\n let get;\n if (property === '$type') {\n get = ['geometry-type'];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n // Determine if the list of values to be searched is homogenously typed.\n // If so (and if the type is string or number), then we can use a\n // [match, input, [...values], true, false] construction rather than a\n // bunch of `==` tests.\n let uniformTypes = true;\n const type = typeof values[0];\n for (const value of values) {\n if (typeof value !== type) {\n uniformTypes = false;\n break;\n }\n }\n if (uniformTypes && (type === 'string' || type === 'number')) {\n // Match expressions must have unique values.\n const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);\n return ['match', get, uniqueValues, !negate, negate];\n }\n if (negate) {\n return ['all', ...values.map(v => ['!=', get, v])];\n }\n else {\n return ['any', ...values.map(v => ['==', get, v])];\n }\n}\nfunction convertHasOp(property) {\n if (property === '$type') {\n return true;\n }\n else if (property === '$id') {\n return ['!=', ['id'], null];\n }\n else {\n return ['has', property];\n }\n}\n\nfunction convertLiteral(value) {\n return typeof value === 'object' ? ['literal', value] : value;\n}\nfunction convertFunction(parameters, propertySpec) {\n let stops = parameters.stops;\n if (!stops) {\n // identity function\n return convertIdentityFunction(parameters, propertySpec);\n }\n const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n stops = stops.map((stop) => {\n if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {\n return [stop[0], convertTokenString(stop[1])];\n }\n return [stop[0], convertLiteral(stop[1])];\n });\n if (zoomAndFeatureDependent) {\n return convertZoomAndPropertyFunction(parameters, propertySpec, stops);\n }\n else if (zoomDependent) {\n return convertZoomFunction(parameters, propertySpec, stops);\n }\n else {\n return convertPropertyFunction(parameters, propertySpec, stops);\n }\n}\nfunction convertIdentityFunction(parameters, propertySpec) {\n const get = ['get', parameters.property];\n if (parameters.default === undefined) {\n // By default, expressions for string-valued properties get coerced. To preserve\n // legacy function semantics, insert an explicit assertion instead.\n return propertySpec.type === 'string' ? ['string', get] : get;\n }\n else if (propertySpec.type === 'enum') {\n return [\n 'match',\n get,\n Object.keys(propertySpec.values),\n get,\n parameters.default\n ];\n }\n else {\n const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];\n if (propertySpec.type === 'array') {\n expression.splice(1, 0, propertySpec.value, propertySpec.length || null);\n }\n return expression;\n }\n}\nfunction getInterpolateOperator(parameters) {\n switch (parameters.colorSpace) {\n case 'hcl': return 'interpolate-hcl';\n case 'lab': return 'interpolate-lab';\n default: return 'interpolate';\n }\n}\nfunction convertZoomAndPropertyFunction(parameters, propertySpec, stops) {\n const featureFunctionParameters = {};\n const featureFunctionStops = {};\n const zoomStops = [];\n for (let s = 0; s < stops.length; s++) {\n const stop = stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctionParameters[zoom] === undefined) {\n featureFunctionParameters[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n };\n featureFunctionStops[zoom] = [];\n zoomStops.push(zoom);\n }\n featureFunctionStops[zoom].push([stop[0].value, stop[1]]);\n }\n // the interpolation type for the zoom dimension of a zoom-and-property\n // function is determined directly from the style property specification\n // for which it's being used: linear for interpolatable properties, step\n // otherwise.\n const functionType = getFunctionType({}, propertySpec);\n if (functionType === 'exponential') {\n const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, false);\n }\n return expression;\n }\n else {\n const expression = ['step', ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, true);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n }\n}\nfunction coalesce(a, b) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n}\nfunction getFallback(parameters, propertySpec) {\n const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));\n /*\n * Some fields with type: resolvedImage have an undefined default.\n * Because undefined is an invalid value for resolvedImage, set fallback to\n * an empty string instead of undefined to ensure output\n * passes validation.\n */\n if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {\n return '';\n }\n return defaultValue;\n}\nfunction convertPropertyFunction(parameters, propertySpec, stops) {\n const type = getFunctionType(parameters, propertySpec);\n const get = ['get', parameters.property];\n if (type === 'categorical' && typeof stops[0][0] === 'boolean') {\n const expression = ['case'];\n for (const stop of stops) {\n expression.push(['==', get, stop[0]], stop[1]);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'categorical') {\n const expression = ['match', get];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'interval') {\n const expression = ['step', ['number', get]];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], true);\n }\n fixupDegenerateStepCurve(expression);\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n const expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n ['number', get]\n ];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else {\n throw new Error(`Unknown property function type ${type}`);\n }\n}\nfunction convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) {\n const type = getFunctionType(parameters, propertySpec);\n let expression;\n let isStep = false;\n if (type === 'interval') {\n expression = ['step', input];\n isStep = true;\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n expression = [getInterpolateOperator(parameters), base === 1 ? ['linear'] : ['exponential', base], input];\n }\n else {\n throw new Error(`Unknown zoom function type \"${type}\"`);\n }\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], isStep);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n}\nfunction fixupDegenerateStepCurve(expression) {\n // degenerate step curve (i.e. a constant function): add a noop stop\n if (expression[0] === 'step' && expression.length === 3) {\n expression.push(0);\n expression.push(expression[3]);\n }\n}\nfunction appendStopPair(curve, input, output, isStep) {\n // Skip duplicate stop values. They were not validated for functions, but they are for expressions.\n // https://github.com/mapbox/mapbox-gl-js/issues/4107\n if (curve.length > 3 && input === curve[curve.length - 2]) {\n return;\n }\n // step curves don't get the first input value, as it is redundant.\n if (!(isStep && curve.length === 2)) {\n curve.push(input);\n }\n curve.push(output);\n}\nfunction getFunctionType(parameters, propertySpec) {\n if (parameters.type) {\n return parameters.type;\n }\n else {\n return propertySpec.expression.interpolated ? 'exponential' : 'interval';\n }\n}\n// \"String with {name} token\" => [\"concat\", \"String with \", [\"get\", \"name\"], \" token\"]\nfunction convertTokenString(s) {\n const result = ['concat'];\n const re = /{([^{}]+)}/g;\n let pos = 0;\n for (let match = re.exec(s); match !== null; match = re.exec(s)) {\n const literal = s.slice(pos, re.lastIndex - match[0].length);\n pos = re.lastIndex;\n if (literal.length > 0)\n result.push(literal);\n result.push(['get', match[1]]);\n }\n if (result.length === 1) {\n return s;\n }\n if (pos < s.length) {\n result.push(s.slice(pos));\n }\n else if (result.length === 2) {\n return ['to-string', result[1]];\n }\n return result;\n}\n\nfunction getPropertyReference(propertyName) {\n for (let i = 0; i < v8Spec.layout.length; i++) {\n for (const key in v8Spec[v8Spec.layout[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.layout[i]][key];\n }\n }\n for (let i = 0; i < v8Spec.paint.length; i++) {\n for (const key in v8Spec[v8Spec.paint[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.paint[i]][key];\n }\n }\n return null;\n}\nfunction eachSource(style, callback) {\n for (const k in style.sources) {\n callback(style.sources[k]);\n }\n}\nfunction eachLayer(style, callback) {\n for (const layer of style.layers) {\n callback(layer);\n }\n}\nfunction eachProperty(style, options, callback) {\n function inner(layer, propertyType) {\n const properties = layer[propertyType];\n if (!properties)\n return;\n Object.keys(properties).forEach((key) => {\n callback({\n path: [layer.id, propertyType, key],\n key,\n value: properties[key],\n reference: getPropertyReference(key),\n set(x) {\n properties[key] = x;\n }\n });\n });\n }\n eachLayer(style, (layer) => {\n if (options.paint) {\n inner(layer, 'paint');\n }\n if (options.layout) {\n inner(layer, 'layout');\n }\n });\n}\n\nfunction stringify(obj) {\n const type = typeof obj;\n if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null)\n return JSON.stringify(obj);\n if (Array.isArray(obj)) {\n let str = '[';\n for (const val of obj) {\n str += `${stringify(val)},`;\n }\n return `${str}]`;\n }\n const keys = Object.keys(obj).sort();\n let str = '{';\n for (let i = 0; i < keys.length; i++) {\n str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`;\n }\n return `${str}}`;\n}\nfunction getKey(layer) {\n let key = '';\n for (const k of refProperties) {\n key += `/${stringify(layer[k])}`;\n }\n return key;\n}\n/**\n * Given an array of layers, return an array of arrays of layers where all\n * layers in each group have identical layout-affecting properties. These\n * are the properties that were formerly used by explicit `ref` mechanism\n * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n * 'filter', and 'layout'.\n *\n * The input is not modified. The output layers are references to the\n * input layers.\n *\n * @private\n * @param {Array} layers\n * @param {Object} [cachedKeys] - an object to keep already calculated keys.\n * @returns {Array>}\n */\nfunction groupByLayout(layers, cachedKeys) {\n const groups = {};\n for (let i = 0; i < layers.length; i++) {\n const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);\n // update the cache if there is one\n if (cachedKeys)\n cachedKeys[layers[i].id] = k;\n let group = groups[k];\n if (!group) {\n group = groups[k] = [];\n }\n group.push(layers[i]);\n }\n const result = [];\n for (const k in groups) {\n result.push(groups[k]);\n }\n return result;\n}\n\nfunction emptyStyle() {\n const style = {};\n const version = v8Spec['$version'];\n for (const styleKey in v8Spec['$root']) {\n const spec = v8Spec['$root'][styleKey];\n if (spec.required) {\n let value = null;\n if (styleKey === 'version') {\n value = version;\n }\n else {\n if (spec.type === 'array') {\n value = [];\n }\n else {\n value = {};\n }\n }\n if (value != null) {\n style[styleKey] = value;\n }\n }\n }\n return style;\n}\n\nfunction validateConstants(options) {\n const key = options.key;\n const constants = options.value;\n if (constants) {\n return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];\n }\n else {\n return [];\n }\n}\n\n// Turn jsonlint-lines-primitives objects into primitive objects\nfunction unbundle(value) {\n if (value instanceof Number || value instanceof String || value instanceof Boolean) {\n return value.valueOf();\n }\n else {\n return value;\n }\n}\nfunction deepUnbundle(value) {\n if (Array.isArray(value)) {\n return value.map(deepUnbundle);\n }\n else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {\n const unbundledValue = {};\n for (const key in value) {\n unbundledValue[key] = deepUnbundle(value[key]);\n }\n return unbundledValue;\n }\n return unbundle(value);\n}\n\nfunction validateObject(options) {\n const key = options.key;\n const object = options.value;\n const elementSpecs = options.valueSpec || {};\n const elementValidators = options.objectElementValidators || {};\n const style = options.style;\n const styleSpec = options.styleSpec;\n const validateSpec = options.validateSpec;\n let errors = [];\n const type = getType(object);\n if (type !== 'object') {\n return [new ValidationError(key, object, `object expected, ${type} found`)];\n }\n for (const objectKey in object) {\n const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'\n const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];\n let validateElement;\n if (elementValidators[elementSpecKey]) {\n validateElement = elementValidators[elementSpecKey];\n }\n else if (elementSpecs[elementSpecKey]) {\n validateElement = validateSpec;\n }\n else if (elementValidators['*']) {\n validateElement = elementValidators['*'];\n }\n else if (elementSpecs['*']) {\n validateElement = validateSpec;\n }\n else {\n errors.push(new ValidationError(key, object[objectKey], `unknown property \"${objectKey}\"`));\n continue;\n }\n errors = errors.concat(validateElement({\n key: (key ? `${key}.` : key) + objectKey,\n value: object[objectKey],\n valueSpec: elementSpec,\n style,\n styleSpec,\n object,\n objectKey,\n validateSpec,\n }, object));\n }\n for (const elementSpecKey in elementSpecs) {\n // Don't check `required` when there's a custom validator for that property.\n if (elementValidators[elementSpecKey]) {\n continue;\n }\n if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {\n errors.push(new ValidationError(key, object, `missing required property \"${elementSpecKey}\"`));\n }\n }\n return errors;\n}\n\nfunction validateArray(options) {\n const array = options.value;\n const arraySpec = options.valueSpec;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const key = options.key;\n const validateArrayElement = options.arrayElementValidator || validateSpec;\n if (getType(array) !== 'array') {\n return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];\n }\n if (arraySpec.length && array.length !== arraySpec.length) {\n return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)];\n }\n if (arraySpec['min-length'] && array.length < arraySpec['min-length']) {\n return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)];\n }\n let arrayElementSpec = {\n 'type': arraySpec.value,\n 'values': arraySpec.values\n };\n if (styleSpec.$version < 7) {\n arrayElementSpec['function'] = arraySpec.function;\n }\n if (getType(arraySpec.value) === 'object') {\n arrayElementSpec = arraySpec.value;\n }\n let errors = [];\n for (let i = 0; i < array.length; i++) {\n errors = errors.concat(validateArrayElement({\n array,\n arrayIndex: i,\n value: array[i],\n valueSpec: arrayElementSpec,\n validateSpec: options.validateSpec,\n style,\n styleSpec,\n key: `${key}[${i}]`\n }));\n }\n return errors;\n}\n\nfunction validateNumber(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n let type = getType(value);\n // eslint-disable-next-line no-self-compare\n if (type === 'number' && value !== value) {\n type = 'NaN';\n }\n if (type !== 'number') {\n return [new ValidationError(key, value, `number expected, ${type} found`)];\n }\n if ('minimum' in valueSpec && value < valueSpec.minimum) {\n return [new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)];\n }\n if ('maximum' in valueSpec && value > valueSpec.maximum) {\n return [new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)];\n }\n return [];\n}\n\nfunction validateFunction(options) {\n const functionValueSpec = options.valueSpec;\n const functionType = unbundle(options.value.type);\n let stopKeyType;\n let stopDomainValues = {};\n let previousStopDomainValue;\n let previousStopDomainZoom;\n const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;\n const isPropertyFunction = !isZoomFunction;\n const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' &&\n getType(options.value.stops[0]) === 'array' &&\n getType(options.value.stops[0][0]) === 'object';\n const errors = validateObject({\n key: options.key,\n value: options.value,\n valueSpec: options.styleSpec.function,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n stops: validateFunctionStops,\n default: validateFunctionDefault\n }\n });\n if (functionType === 'identity' && isZoomFunction) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"property\"'));\n }\n if (functionType !== 'identity' && !options.value.stops) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"stops\"'));\n }\n if (functionType === 'exponential' && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported'));\n }\n if (options.styleSpec.$version >= 8) {\n if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'property functions not supported'));\n }\n else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));\n }\n }\n if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) {\n errors.push(new ValidationError(options.key, options.value, '\"property\" property is required'));\n }\n return errors;\n function validateFunctionStops(options) {\n if (functionType === 'identity') {\n return [new ValidationError(options.key, options.value, 'identity function may not have a \"stops\" property')];\n }\n let errors = [];\n const value = options.value;\n errors = errors.concat(validateArray({\n key: options.key,\n value,\n valueSpec: options.valueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n arrayElementValidator: validateFunctionStop\n }));\n if (getType(value) === 'array' && value.length === 0) {\n errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));\n }\n return errors;\n }\n function validateFunctionStop(options) {\n let errors = [];\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n if (value.length !== 2) {\n return [new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)];\n }\n if (isZoomAndPropertyFunction) {\n if (getType(value[0]) !== 'object') {\n return [new ValidationError(key, value, `object expected, ${getType(value[0])} found`)];\n }\n if (value[0].zoom === undefined) {\n return [new ValidationError(key, value, 'object stop key must have zoom')];\n }\n if (value[0].value === undefined) {\n return [new ValidationError(key, value, 'object stop key must have value')];\n }\n if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {\n return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')];\n }\n if (unbundle(value[0].zoom) !== previousStopDomainZoom) {\n previousStopDomainZoom = unbundle(value[0].zoom);\n previousStopDomainValue = undefined;\n stopDomainValues = {};\n }\n errors = errors.concat(validateObject({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: { zoom: {} },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue }\n }));\n }\n else {\n errors = errors.concat(validateStopDomainValue({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: {},\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }, value));\n }\n if (isExpression(deepUnbundle(value[1]))) {\n return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]);\n }\n return errors.concat(options.validateSpec({\n key: `${key}[1]`,\n value: value[1],\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n function validateStopDomainValue(options, stop) {\n const type = getType(options.value);\n const value = unbundle(options.value);\n const reportValue = options.value !== null ? options.value : stop;\n if (!stopKeyType) {\n stopKeyType = type;\n }\n else if (type !== stopKeyType) {\n return [new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)];\n }\n if (type !== 'number' && type !== 'string' && type !== 'boolean') {\n return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];\n }\n if (type !== 'number' && functionType !== 'categorical') {\n let message = `number expected, ${type} found`;\n if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {\n message += '\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.';\n }\n return [new ValidationError(options.key, reportValue, message)];\n }\n if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) {\n return [new ValidationError(options.key, reportValue, `integer expected, found ${value}`)];\n }\n if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];\n }\n else {\n previousStopDomainValue = value;\n }\n if (functionType === 'categorical' && value in stopDomainValues) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];\n }\n else {\n stopDomainValues[value] = true;\n }\n return [];\n }\n function validateFunctionDefault(options) {\n return options.validateSpec({\n key: options.key,\n value: options.value,\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n });\n }\n}\n\nfunction validateExpression(options) {\n const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);\n if (expression.result === 'error') {\n return expression.value.map((error) => {\n return new ValidationError(`${options.key}${error.key}`, options.value, error.message);\n });\n }\n const expressionObj = expression.value.expression || expression.value._styleExpression.expression;\n if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&\n !expressionObj.outputDefined()) {\n return [new ValidationError(options.key, options.value, `Invalid data expression for \"${options.propertyKey}\". Output values must be contained as literals within the expression.`)];\n }\n if (options.expressionContext === 'property' && options.propertyType === 'layout' &&\n (!isStateConstant(expressionObj))) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with layout properties.')];\n }\n if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with filters.')];\n }\n if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {\n if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {\n return [new ValidationError(options.key, options.value, '\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.')];\n }\n if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')];\n }\n }\n return [];\n}\n\nfunction validateBoolean(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'boolean') {\n return [new ValidationError(key, value, `boolean expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateColor(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `color expected, ${type} found`)];\n }\n if (!Color.parse(String(value))) { // cast String object to string primitive\n return [new ValidationError(key, value, `color expected, \"${value}\" found`)];\n }\n return [];\n}\n\nfunction validateEnum(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n const errors = [];\n if (Array.isArray(valueSpec.values)) { // <=v7\n if (valueSpec.values.indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n else { // >=v8\n if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n return errors;\n}\n\nfunction validateFilter(options) {\n if (isExpressionFilter(deepUnbundle(options.value))) {\n return validateExpression(extendBy({}, options, {\n expressionContext: 'filter',\n valueSpec: { value: 'boolean' }\n }));\n }\n else {\n return validateNonExpressionFilter(options);\n }\n}\nfunction validateNonExpressionFilter(options) {\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n const styleSpec = options.styleSpec;\n let type;\n let errors = [];\n if (value.length < 1) {\n return [new ValidationError(key, value, 'filter array must have at least 1 element')];\n }\n errors = errors.concat(validateEnum({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: styleSpec.filter_operator,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n switch (unbundle(value[0])) {\n case '<':\n case '<=':\n case '>':\n case '>=':\n if (value.length >= 2 && unbundle(value[1]) === '$type') {\n errors.push(new ValidationError(key, value, `\"$type\" cannot be use with operator \"${value[0]}\"`));\n }\n /* falls through */\n case '==':\n case '!=':\n if (value.length !== 3) {\n errors.push(new ValidationError(key, value, `filter array for operator \"${value[0]}\" must have 3 elements`));\n }\n /* falls through */\n case 'in':\n case '!in':\n if (value.length >= 2) {\n type = getType(value[1]);\n if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n }\n for (let i = 2; i < value.length; i++) {\n type = getType(value[i]);\n if (unbundle(value[1]) === '$type') {\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec.geometry_type,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));\n }\n }\n break;\n case 'any':\n case 'all':\n case 'none':\n for (let i = 1; i < value.length; i++) {\n errors = errors.concat(validateNonExpressionFilter({\n key: `${key}[${i}]`,\n value: value[i],\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n break;\n case 'has':\n case '!has':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n break;\n case 'within':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'object') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`));\n }\n break;\n }\n return errors;\n}\n\nfunction validateProperty(options, propertyType) {\n const key = options.key;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const value = options.value;\n const propertyKey = options.objectKey;\n const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];\n if (!layerSpec)\n return [];\n const transitionMatch = propertyKey.match(/^(.*)-transition$/);\n if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {\n return validateSpec({\n key,\n value,\n valueSpec: styleSpec.transition,\n style,\n styleSpec\n });\n }\n const valueSpec = options.valueSpec || layerSpec[propertyKey];\n if (!valueSpec) {\n return [new ValidationError(key, value, `unknown property \"${propertyKey}\"`)];\n }\n let tokenMatch;\n if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {\n return [new ValidationError(key, value, `\"${propertyKey}\" does not support interpolation syntax\\n` +\n `Use an identity property function instead: \\`{ \"type\": \"identity\", \"property\": ${JSON.stringify(tokenMatch[1])} }\\`.`)];\n }\n const errors = [];\n if (options.layerType === 'symbol') {\n if (propertyKey === 'text-field' && style && !style.glyphs) {\n errors.push(new ValidationError(key, value, 'use of \"text-field\" requires a style \"glyphs\" property'));\n }\n if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') {\n errors.push(new ValidationError(key, value, '\"text-font\" does not support identity functions'));\n }\n }\n return errors.concat(validateSpec({\n key: options.key,\n value,\n valueSpec,\n style,\n styleSpec,\n expressionContext: 'property',\n propertyType,\n propertyKey\n }));\n}\n\nfunction validatePaintProperty(options) {\n return validateProperty(options, 'paint');\n}\n\nfunction validateLayoutProperty(options) {\n return validateProperty(options, 'layout');\n}\n\nfunction validateLayer(options) {\n let errors = [];\n const layer = options.value;\n const key = options.key;\n const style = options.style;\n const styleSpec = options.styleSpec;\n if (!layer.type && !layer.ref) {\n errors.push(new ValidationError(key, layer, 'either \"type\" or \"ref\" is required'));\n }\n let type = unbundle(layer.type);\n const ref = unbundle(layer.ref);\n if (layer.id) {\n const layerId = unbundle(layer.id);\n for (let i = 0; i < options.arrayIndex; i++) {\n const otherLayer = style.layers[i];\n if (unbundle(otherLayer.id) === layerId) {\n errors.push(new ValidationError(key, layer.id, `duplicate layer id \"${layer.id}\", previously used at line ${otherLayer.id.__line__}`));\n }\n }\n }\n if ('ref' in layer) {\n ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => {\n if (p in layer) {\n errors.push(new ValidationError(key, layer[p], `\"${p}\" is prohibited for ref layers`));\n }\n });\n let parent;\n style.layers.forEach((layer) => {\n if (unbundle(layer.id) === ref)\n parent = layer;\n });\n if (!parent) {\n errors.push(new ValidationError(key, layer.ref, `ref layer \"${ref}\" not found`));\n }\n else if (parent.ref) {\n errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));\n }\n else {\n type = unbundle(parent.type);\n }\n }\n else if (type !== 'background') {\n if (!layer.source) {\n errors.push(new ValidationError(key, layer, 'missing required property \"source\"'));\n }\n else {\n const source = style.sources && style.sources[layer.source];\n const sourceType = source && unbundle(source.type);\n if (!source) {\n errors.push(new ValidationError(key, layer.source, `source \"${layer.source}\" not found`));\n }\n else if (sourceType === 'vector' && type === 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'hillshade') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType === 'raster' && type !== 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a vector source`));\n }\n else if (sourceType === 'vector' && !layer['source-layer']) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" must specify a \"source-layer\"`));\n }\n else if (sourceType === 'raster-dem' && type !== 'hillshade') {\n errors.push(new ValidationError(key, layer.source, 'raster-dem source can only be used with layer type \\'hillshade\\'.'));\n }\n else if (type === 'line' && layer.paint && layer.paint['line-gradient'] &&\n (sourceType !== 'geojson' || !source.lineMetrics)) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`));\n }\n }\n }\n errors = errors.concat(validateObject({\n key,\n value: layer,\n valueSpec: styleSpec.layer,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'() {\n return [];\n },\n // We don't want to enforce the spec's `\"requires\": true` for backward compatibility with refs;\n // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772.\n type() {\n return options.validateSpec({\n key: `${key}.type`,\n value: layer.type,\n valueSpec: styleSpec.layer.type,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n object: layer,\n objectKey: 'type'\n });\n },\n filter: validateFilter,\n layout(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validateLayoutProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n },\n paint(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validatePaintProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n }\n }\n }));\n return errors;\n}\n\nfunction validateString(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `string expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateRasterDEMSource(options) {\n var _a;\n const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';\n const rasterDEM = options.value;\n const styleSpec = options.styleSpec;\n const rasterDEMSpec = styleSpec.source_raster_dem;\n const style = options.style;\n let errors = [];\n const rootType = getType(rasterDEM);\n if (rasterDEM === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));\n return errors;\n }\n const encoding = unbundle(rasterDEM.encoding);\n const isCustomEncoding = encoding === 'custom';\n const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];\n const encodingName = options.value.encoding ? `\"${options.value.encoding}\"` : 'Default';\n for (const key in rasterDEM) {\n if (!isCustomEncoding && customEncodingKeys.includes(key)) {\n errors.push(new ValidationError(key, rasterDEM[key], `In \"${sourceName}\": \"${key}\" is only valid when \"encoding\" is set to \"custom\". ${encodingName} encoding found`));\n }\n else if (rasterDEMSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: rasterDEM[key],\n valueSpec: rasterDEMSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors.push(new ValidationError(key, rasterDEM[key], `unknown property \"${key}\"`));\n }\n }\n return errors;\n}\n\nconst objectElementValidators = {\n promoteId: validatePromoteId\n};\nfunction validateSource(options) {\n const value = options.value;\n const key = options.key;\n const styleSpec = options.styleSpec;\n const style = options.style;\n const validateSpec = options.validateSpec;\n if (!value.type) {\n return [new ValidationError(key, value, '\"type\" is required')];\n }\n const type = unbundle(value.type);\n let errors;\n switch (type) {\n case 'vector':\n case 'raster':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec[`source_${type.replace('-', '_')}`],\n style: options.style,\n styleSpec,\n objectElementValidators,\n validateSpec,\n });\n return errors;\n case 'raster-dem':\n errors = validateRasterDEMSource({\n sourceName: key,\n value,\n style: options.style,\n styleSpec,\n validateSpec,\n });\n return errors;\n case 'geojson':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec.source_geojson,\n style,\n styleSpec,\n validateSpec,\n objectElementValidators\n });\n if (value.cluster) {\n for (const prop in value.clusterProperties) {\n const [operator, mapExpr] = value.clusterProperties[prop];\n const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator;\n errors.push(...validateExpression({\n key: `${key}.${prop}.map`,\n value: mapExpr,\n validateSpec,\n expressionContext: 'cluster-map'\n }));\n errors.push(...validateExpression({\n key: `${key}.${prop}.reduce`,\n value: reduceExpr,\n validateSpec,\n expressionContext: 'cluster-reduce'\n }));\n }\n }\n return errors;\n case 'video':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_video,\n style,\n validateSpec,\n styleSpec\n });\n case 'image':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_image,\n style,\n validateSpec,\n styleSpec\n });\n case 'canvas':\n return [new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')];\n default:\n return validateEnum({\n key: `${key}.type`,\n value: value.type,\n valueSpec: { values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image'] },\n style,\n validateSpec,\n styleSpec\n });\n }\n}\nfunction validatePromoteId({ key, value }) {\n if (getType(value) === 'string') {\n return validateString({ key, value });\n }\n else {\n const errors = [];\n for (const prop in value) {\n errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] }));\n }\n return errors;\n }\n}\n\nfunction validateLight(options) {\n const light = options.value;\n const styleSpec = options.styleSpec;\n const lightSpec = styleSpec.light;\n const style = options.style;\n let errors = [];\n const rootType = getType(light);\n if (light === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in light) {\n const transitionMatch = key.match(/^(.*)-transition$/);\n if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: styleSpec.transition,\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else if (lightSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: lightSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, light[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateTerrain(options) {\n const terrain = options.value;\n const styleSpec = options.styleSpec;\n const terrainSpec = styleSpec.terrain;\n const style = options.style;\n let errors = [];\n const rootType = getType(terrain);\n if (terrain === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in terrain) {\n if (terrainSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: terrain[key],\n valueSpec: terrainSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, terrain[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateFormatted(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validateImage(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validatePadding(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1 || value.length > 4) {\n return [new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)];\n }\n const arrayElementSpec = {\n type: 'number'\n };\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateVariableAnchorOffsetCollection(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n const styleSpec = options.styleSpec;\n if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) {\n return [new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')];\n }\n let errors = [];\n for (let i = 0; i < value.length; i += 2) {\n // Elements in even positions should be values from text-anchor enum\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec['layout_symbol']['text-anchor']\n }));\n // Elements in odd positions should be points (2-element numeric arrays)\n errors = errors.concat(validateArray({\n key: `${key}[${i + 1}]`,\n value: value[i + 1],\n valueSpec: {\n length: 2,\n value: 'number'\n },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec\n }));\n }\n return errors;\n}\n\nfunction validateSprite(options) {\n let errors = [];\n const sprite = options.value;\n const key = options.key;\n if (!Array.isArray(sprite)) {\n return validateString({\n key,\n value: sprite\n });\n }\n else {\n const allSpriteIds = [];\n const allSpriteURLs = [];\n for (const i in sprite) {\n if (sprite[i].id && allSpriteIds.includes(sprite[i].id))\n errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`));\n allSpriteIds.push(sprite[i].id);\n if (sprite[i].url && allSpriteURLs.includes(sprite[i].url))\n errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`));\n allSpriteURLs.push(sprite[i].url);\n const pairSpec = {\n id: {\n type: 'string',\n required: true,\n },\n url: {\n type: 'string',\n required: true,\n }\n };\n errors = errors.concat(validateObject({\n key: `${key}[${i}]`,\n value: sprite[i],\n valueSpec: pairSpec,\n validateSpec: options.validateSpec,\n }));\n }\n return errors;\n }\n}\n\nconst VALIDATORS = {\n '*'() {\n return [];\n },\n 'array': validateArray,\n 'boolean': validateBoolean,\n 'number': validateNumber,\n 'color': validateColor,\n 'constants': validateConstants,\n 'enum': validateEnum,\n 'filter': validateFilter,\n 'function': validateFunction,\n 'layer': validateLayer,\n 'object': validateObject,\n 'source': validateSource,\n 'light': validateLight,\n 'terrain': validateTerrain,\n 'string': validateString,\n 'formatted': validateFormatted,\n 'resolvedImage': validateImage,\n 'padding': validatePadding,\n 'variableAnchorOffsetCollection': validateVariableAnchorOffsetCollection,\n 'sprite': validateSprite,\n};\n// Main recursive validation function. Tracks:\n//\n// - key: string representing location of validation in style tree. Used only\n// for more informative error reporting.\n// - value: current value from style being evaluated. May be anything from a\n// high level object that needs to be descended into deeper or a simple\n// scalar value.\n// - valueSpec: current spec being evaluated. Tracks value.\n// - styleSpec: current full spec being evaluated.\nfunction validate(options) {\n const value = options.value;\n const valueSpec = options.valueSpec;\n const styleSpec = options.styleSpec;\n options.validateSpec = validate;\n if (valueSpec.expression && isFunction(unbundle(value))) {\n return validateFunction(options);\n }\n else if (valueSpec.expression && isExpression(deepUnbundle(value))) {\n return validateExpression(options);\n }\n else if (valueSpec.type && VALIDATORS[valueSpec.type]) {\n return VALIDATORS[valueSpec.type](options);\n }\n else {\n const valid = validateObject(extendBy({}, options, {\n valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec\n }));\n return valid;\n }\n}\n\nfunction validateGlyphsUrl(options) {\n const value = options.value;\n const key = options.key;\n const errors = validateString(options);\n if (errors.length)\n return errors;\n if (value.indexOf('{fontstack}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{fontstack}\" token'));\n }\n if (value.indexOf('{range}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{range}\" token'));\n }\n return errors;\n}\n\n/**\n * Validate a MapLibre style against the style specification. This entrypoint,\n * `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as\n * small a browserify bundle as possible by omitting unnecessary functionality\n * and legacy style specifications.\n *\n * @private\n * @param {Object} style The style to be validated.\n * @param {Object} [styleSpec] The style specification to validate against.\n * If omitted, the latest style spec is used.\n * @returns {Array}\n * @example\n * var validate = require('maplibre-gl-style-spec/lib/validate_style.min');\n * var errors = validate(style);\n */\nfunction validateStyleMin(style, styleSpec = v8Spec) {\n let errors = [];\n errors = errors.concat(validate({\n key: '',\n value: style,\n valueSpec: styleSpec.$root,\n styleSpec,\n style,\n validateSpec: validate,\n objectElementValidators: {\n glyphs: validateGlyphsUrl,\n '*'() {\n return [];\n }\n }\n }));\n if (style['constants']) {\n errors = errors.concat(validateConstants({\n key: 'constants',\n value: style['constants'],\n style,\n styleSpec,\n validateSpec: validate,\n }));\n }\n return sortErrors(errors);\n}\nvalidateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource));\nvalidateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite));\nvalidateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl));\nvalidateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight));\nvalidateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain));\nvalidateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer));\nvalidateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter));\nvalidateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty));\nvalidateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty));\nfunction injectValidateSpec(validator) {\n return function (options) {\n return validator({\n ...options,\n validateSpec: validate,\n });\n };\n}\nfunction sortErrors(errors) {\n return [].concat(errors).sort((a, b) => {\n return a.line - b.line;\n });\n}\nfunction wrapCleanErrors(inner) {\n return function (...args) {\n return sortErrors(inner.apply(this, args));\n };\n}\n\nconst v8 = v8Spec;\nconst expression = {\n StyleExpression,\n StylePropertyFunction,\n ZoomConstantExpression,\n ZoomDependentExpression,\n createExpression,\n createPropertyExpression,\n isExpression,\n isExpressionFilter,\n isZoomExpression,\n normalizePropertyExpression,\n};\nconst styleFunction = {\n convertFunction,\n createFunction,\n isFunction\n};\nconst visit = { eachLayer, eachProperty, eachSource };\n\nexport { Color, ColorType, CompoundExpression, EvaluationContext, FormatExpression, Formatted, FormattedSection, FormattedType, Interpolate, Literal, NullType, Padding, ParsingError, ResolvedImage, Step, StyleExpression, StylePropertyFunction, ValidationError, VariableAnchorOffsetCollection, ZoomConstantExpression, ZoomDependentExpression, convertFilter, convertFunction, createExpression, createFunction, createPropertyExpression, derefLayers, diffStyles as diff, emptyStyle, expression, expressions, createFilter as featureFilter, styleFunction as function, groupByLayout, interpolateFactory, interpolate as interpolates, isExpression, isFunction, isZoomExpression, v8Spec as latest, normalizePropertyExpression, operations, supportsPropertyExpression, toString$1 as toString, typeOf, v8, validateStyleMin, visit };\n//# sourceMappingURL=index.mjs.map\n","import {validateStyleMin} from '@maplibre/maplibre-gl-style-spec';\nimport {ErrorEvent} from '../util/evented';\n\nimport type {Evented} from '../util/evented';\n\ntype ValidationError = {\n message: string;\n line: number;\n identifier?: string;\n};\n\nexport type Validator = (a: any) => ReadonlyArray;\n\ntype ValidateStyle = {\n source: Validator;\n sprite: Validator;\n glyphs: Validator;\n layer: Validator;\n light: Validator;\n terrain: Validator;\n filter: Validator;\n paintProperty: Validator;\n layoutProperty: Validator;\n (b: any, a?: any | null): ReadonlyArray;\n};\n\nexport const validateStyle = (validateStyleMin as unknown as ValidateStyle);\n\nexport const validateSource = validateStyle.source;\nexport const validateLight = validateStyle.light;\nexport const validateTerrain = validateStyle.terrain;\nexport const validateFilter = validateStyle.filter;\nexport const validatePaintProperty = validateStyle.paintProperty;\nexport const validateLayoutProperty = validateStyle.layoutProperty;\n\nexport function emitValidationErrors(\n emitter: Evented,\n errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n }> | null\n): boolean {\n let hasErrors = false;\n if (errors && errors.length) {\n for (const error of errors) {\n emitter.fire(new ErrorEvent(new Error(error.message)));\n hasErrors = true;\n }\n }\n return hasErrors;\n}\n","/*\nThis file was copied from https://github.com/mapbox/grid-index and was\nmigrated from JavaScript to TypeScript.\n\nCopyright (c) 2016, Mapbox\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n*/\n\nconst NUM_PARAMS = 3;\n\nexport type SerializedGrid = {\n buffer: ArrayBuffer;\n};\n\nexport class TransferableGridIndex {\n cells: number[][];\n arrayBuffer: ArrayBuffer;\n d: number;\n keys: number[];\n bboxes: number[];\n n: number;\n extent: number;\n padding: number;\n scale: any;\n uid: number;\n min: number;\n max: number;\n\n constructor(extent: number | ArrayBuffer, n?: number, padding?: number) {\n const cells = this.cells = [];\n\n if (extent instanceof ArrayBuffer) {\n this.arrayBuffer = extent;\n const array = new Int32Array(this.arrayBuffer);\n extent = array[0];\n n = array[1];\n padding = array[2];\n\n this.d = n + 2 * padding;\n for (let k = 0; k < this.d * this.d; k++) {\n const start = array[NUM_PARAMS + k];\n const end = array[NUM_PARAMS + k + 1];\n cells.push(start === end ? null : array.subarray(start, end));\n }\n const keysOffset = array[NUM_PARAMS + cells.length];\n const bboxesOffset = array[NUM_PARAMS + cells.length + 1];\n this.keys = array.subarray(keysOffset, bboxesOffset) as any as number[];\n this.bboxes = array.subarray(bboxesOffset) as any as number[];\n\n this.insert = this._insertReadonly;\n\n } else {\n this.d = n + 2 * padding;\n for (let i = 0; i < this.d * this.d; i++) {\n cells.push([]);\n }\n this.keys = [];\n this.bboxes = [];\n }\n\n this.n = n;\n this.extent = extent;\n this.padding = padding;\n this.scale = n / extent;\n this.uid = 0;\n\n const p = (padding / n) * extent;\n this.min = -p;\n this.max = extent + p;\n }\n\n insert(key: number, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined);\n this.keys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n _insertReadonly() {\n throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.');\n }\n\n _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.cells[cellIndex].push(uid);\n }\n\n query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[] {\n const min = this.min;\n const max = this.max;\n if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) {\n // We use `Array#slice` because `this.keys` may be a `Int32Array` and\n // some browsers (Safari and IE) do not support `TypedArray#slice`\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility\n return Array.prototype.slice.call(this.keys);\n\n } else {\n const result = [];\n const seenUids = {};\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest);\n return result;\n }\n }\n\n _queryCell(x1: number, y1: number, x2: number, y2:number, cellIndex:number, result, seenUids, intersectionTest: Function) {\n const cell = this.cells[cellIndex];\n if (cell !== null) {\n const keys = this.keys;\n const bboxes = this.bboxes;\n for (let u = 0; u < cell.length; u++) {\n const uid = cell[u];\n if (seenUids[uid] === undefined) {\n const offset = uid * 4;\n if (intersectionTest ?\n intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) :\n ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]))) {\n seenUids[uid] = true;\n result.push(keys[uid]);\n } else {\n seenUids[uid] = false;\n }\n }\n }\n }\n }\n\n _forEachCell(x1: number, y1: number, x2:number, y2:number, fn: Function, arg1, arg2, intersectionTest) {\n const cx1 = this._convertToCellCoord(x1);\n const cy1 = this._convertToCellCoord(y1);\n const cx2 = this._convertToCellCoord(x2);\n const cy2 = this._convertToCellCoord(y2);\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.d * y + x;\n if (intersectionTest && !intersectionTest(\n this._convertFromCellCoord(x),\n this._convertFromCellCoord(y),\n this._convertFromCellCoord(x + 1),\n this._convertFromCellCoord(y + 1))) continue;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) return;\n }\n }\n }\n\n _convertFromCellCoord (x) {\n return (x - this.padding) / this.scale;\n }\n\n _convertToCellCoord(x) {\n return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding));\n }\n\n toArrayBuffer(): ArrayBuffer {\n if (this.arrayBuffer) return this.arrayBuffer;\n\n const cells = this.cells;\n\n const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1;\n let totalCellLength = 0;\n for (let i = 0; i < this.cells.length; i++) {\n totalCellLength += this.cells[i].length;\n }\n\n const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length);\n array[0] = this.extent;\n array[1] = this.n;\n array[2] = this.padding;\n\n let offset = metadataLength;\n for (let k = 0; k < cells.length; k++) {\n const cell = cells[k];\n array[NUM_PARAMS + k] = offset;\n array.set(cell, offset);\n offset += cell.length;\n }\n\n array[NUM_PARAMS + cells.length] = offset;\n array.set(this.keys, offset);\n offset += this.keys.length;\n\n array[NUM_PARAMS + cells.length + 1] = offset;\n array.set(this.bboxes, offset);\n offset += this.bboxes.length;\n\n return array.buffer;\n }\n\n public static serialize(grid: TransferableGridIndex, transferables?: Array): SerializedGrid {\n const buffer = grid.toArrayBuffer();\n if (transferables) {\n transferables.push(buffer);\n }\n return {buffer};\n }\n\n public static deserialize(serialized: SerializedGrid): TransferableGridIndex {\n return new TransferableGridIndex(serialized.buffer);\n }\n}\n","import {TransferableGridIndex} from './transferable_grid_index';\nimport {Color, CompoundExpression, expressions, ResolvedImage, StylePropertyFunction,\n StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport {AJAXError} from './ajax';\n\nimport type {Transferable} from '../types/transferable';\nimport {isImageBitmap} from './util';\n\ntype SerializedObject = {\n [_: string]: S;\n};\n\nexport type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array | SerializedObject;\n\ntype Registry = {\n [_: string]: {\n klass: {\n new (...args: any): any;\n deserialize?: (input: Serialized) => unknown;\n };\n omit: ReadonlyArray;\n shallow: ReadonlyArray;\n };\n};\n\n/**\n * Register options\n */\ntype RegisterOptions = {\n /**\n * List of properties to omit from serialization (e.g., cached/computed properties)\n */\n omit?: ReadonlyArray;\n /**\n * List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize().\n */\n shallow?: ReadonlyArray;\n};\n\nconst registry: Registry = {};\n\n/**\n * Register the given class as serializable.\n *\n * @param options - the registration options\n */\nexport function register(\n name: string,\n klass: {\n new (...args: any): T;\n },\n options: RegisterOptions = {}\n) {\n if (registry[name]) throw new Error(`${name} is already registered.`);\n ((Object.defineProperty as any))(klass, '_classRegistryKey', {\n value: name,\n writeable: false\n });\n registry[name] = {\n klass,\n omit: options.omit as ReadonlyArray || [],\n shallow: options.shallow as ReadonlyArray || []\n };\n}\n\nregister('Object', Object);\nregister('TransferableGridIndex', TransferableGridIndex);\n\nregister('Color', Color);\nregister('Error', Error);\nregister('AJAXError', AJAXError);\nregister('ResolvedImage', ResolvedImage);\n\nregister('StylePropertyFunction', StylePropertyFunction);\nregister('StyleExpression', StyleExpression, {omit: ['_evaluator']});\n\nregister('ZoomDependentExpression', ZoomDependentExpression);\nregister('ZoomConstantExpression', ZoomConstantExpression);\nregister('CompoundExpression', CompoundExpression, {omit: ['_evaluate']});\nfor (const name in expressions) {\n if ((expressions[name] as any)._classRegistryKey) continue;\n register(`Expression_${name}`, expressions[name]);\n}\n\nfunction isArrayBuffer(value: any): value is ArrayBuffer {\n return value && typeof ArrayBuffer !== 'undefined' &&\n (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer'));\n}\n\n/**\n * Serialize the given object for transfer to or from a web worker.\n *\n * For non-builtin types, recursively serialize each property (possibly\n * omitting certain properties - see register()), and package the result along\n * with the constructor's `name` so that the appropriate constructor can be\n * looked up in `deserialize()`.\n *\n * If a `transferables` array is provided, add any transferable objects (i.e.,\n * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed,\n * this should happen in the client code, before using serialize().)\n */\nexport function serialize(input: unknown, transferables?: Array | null): Serialized {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob) {\n return input;\n }\n\n if (isArrayBuffer(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (isImageBitmap(input)) {\n if (transferables) {\n transferables.push(input);\n }\n return input;\n }\n\n if (ArrayBuffer.isView(input)) {\n const view = input;\n if (transferables) {\n transferables.push(view.buffer);\n }\n return view;\n }\n\n if (input instanceof ImageData) {\n if (transferables) {\n transferables.push(input.data.buffer);\n }\n return input;\n }\n\n if (Array.isArray(input)) {\n const serialized: Array = [];\n for (const item of input) {\n serialized.push(serialize(item, transferables));\n }\n return serialized;\n }\n\n if (typeof input === 'object') {\n const klass = (input.constructor as any);\n const name = klass._classRegistryKey;\n if (!name) {\n throw new Error('can\\'t serialize object of unregistered class');\n }\n if (!registry[name]) throw new Error(`${name} is not registered.`);\n\n const properties: SerializedObject = klass.serialize ?\n // (Temporary workaround) allow a class to provide static\n // `serialize()` and `deserialize()` methods to bypass the generic\n // approach.\n // This temporary workaround lets us use the generic serialization\n // approach for objects whose members include instances of dynamic\n // StructArray types. Once we refactor StructArray to be static,\n // we can remove this complexity.\n (klass.serialize(input, transferables) as SerializedObject) : {};\n\n if (!klass.serialize) {\n for (const key in input) {\n if (!input.hasOwnProperty(key)) continue; // eslint-disable-line no-prototype-builtins\n if (registry[name].omit.indexOf(key) >= 0) continue;\n const property = input[key];\n properties[key] = registry[name].shallow.indexOf(key) >= 0 ?\n property :\n serialize(property, transferables);\n }\n if (input instanceof Error) {\n properties.message = input.message;\n }\n } else {\n if (transferables && properties === transferables[transferables.length - 1]) {\n throw new Error('statically serialized object won\\'t survive transfer of $name property');\n }\n }\n\n if (properties.$name) {\n throw new Error('$name property is reserved for worker serialization logic.');\n }\n if (name !== 'Object') {\n properties.$name = name;\n }\n\n return properties;\n }\n\n throw new Error(`can't serialize object of type ${typeof input}`);\n}\n\nexport function deserialize(input: Serialized): unknown {\n if (input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob ||\n isArrayBuffer(input) ||\n isImageBitmap(input) ||\n ArrayBuffer.isView(input) ||\n input instanceof ImageData) {\n return input;\n }\n\n if (Array.isArray(input)) {\n return input.map(deserialize);\n }\n\n if (typeof input === 'object') {\n const name = input.$name || 'Object';\n if (!registry[name]) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n const {klass} = registry[name];\n if (!klass) {\n throw new Error(`can't deserialize unregistered class ${name}`);\n }\n\n if (klass.deserialize) {\n return klass.deserialize(input);\n }\n\n const result = Object.create(klass.prototype);\n\n for (const key of Object.keys(input)) {\n if (key === '$name') continue;\n const value = (input as SerializedObject)[key];\n result[key] = registry[name].shallow.indexOf(key) >= 0 ? value : deserialize(value);\n }\n\n return result;\n }\n\n throw new Error(`can't deserialize object of type ${typeof input}`);\n}\n","export class ZoomHistory {\n lastZoom: number;\n lastFloorZoom: number;\n lastIntegerZoom: number;\n lastIntegerZoomTime: number;\n first: boolean;\n\n constructor() {\n this.first = true;\n }\n\n update(z: number, now: number) {\n const floorZ = Math.floor(z);\n\n if (this.first) {\n this.first = false;\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = 0;\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n if (this.lastFloorZoom > floorZ) {\n this.lastIntegerZoom = floorZ + 1;\n this.lastIntegerZoomTime = now;\n } else if (this.lastFloorZoom < floorZ) {\n this.lastIntegerZoom = floorZ;\n this.lastIntegerZoomTime = now;\n }\n\n if (z !== this.lastZoom) {\n this.lastZoom = z;\n this.lastFloorZoom = floorZ;\n return true;\n }\n\n return false;\n }\n}\n","// The following table comes from .\n// Keep it synchronized with .\n\ntype UnicodeBlockLookup = {[key: string]: (char: number) => boolean};\n\nexport const unicodeBlockLookup: UnicodeBlockLookup = {\n // 'Basic Latin': (char) => char >= 0x0000 && char <= 0x007F,\n 'Latin-1 Supplement': (char) => char >= 0x0080 && char <= 0x00FF,\n // 'Latin Extended-A': (char) => char >= 0x0100 && char <= 0x017F,\n // 'Latin Extended-B': (char) => char >= 0x0180 && char <= 0x024F,\n // 'IPA Extensions': (char) => char >= 0x0250 && char <= 0x02AF,\n // 'Spacing Modifier Letters': (char) => char >= 0x02B0 && char <= 0x02FF,\n // 'Combining Diacritical Marks': (char) => char >= 0x0300 && char <= 0x036F,\n // 'Greek and Coptic': (char) => char >= 0x0370 && char <= 0x03FF,\n // 'Cyrillic': (char) => char >= 0x0400 && char <= 0x04FF,\n // 'Cyrillic Supplement': (char) => char >= 0x0500 && char <= 0x052F,\n // 'Armenian': (char) => char >= 0x0530 && char <= 0x058F,\n //'Hebrew': (char) => char >= 0x0590 && char <= 0x05FF,\n 'Arabic': (char) => char >= 0x0600 && char <= 0x06FF,\n //'Syriac': (char) => char >= 0x0700 && char <= 0x074F,\n 'Arabic Supplement': (char) => char >= 0x0750 && char <= 0x077F,\n // 'Thaana': (char) => char >= 0x0780 && char <= 0x07BF,\n // 'NKo': (char) => char >= 0x07C0 && char <= 0x07FF,\n // 'Samaritan': (char) => char >= 0x0800 && char <= 0x083F,\n // 'Mandaic': (char) => char >= 0x0840 && char <= 0x085F,\n // 'Syriac Supplement': (char) => char >= 0x0860 && char <= 0x086F,\n 'Arabic Extended-A': (char) => char >= 0x08A0 && char <= 0x08FF,\n // 'Devanagari': (char) => char >= 0x0900 && char <= 0x097F,\n // 'Bengali': (char) => char >= 0x0980 && char <= 0x09FF,\n // 'Gurmukhi': (char) => char >= 0x0A00 && char <= 0x0A7F,\n // 'Gujarati': (char) => char >= 0x0A80 && char <= 0x0AFF,\n // 'Oriya': (char) => char >= 0x0B00 && char <= 0x0B7F,\n // 'Tamil': (char) => char >= 0x0B80 && char <= 0x0BFF,\n // 'Telugu': (char) => char >= 0x0C00 && char <= 0x0C7F,\n // 'Kannada': (char) => char >= 0x0C80 && char <= 0x0CFF,\n // 'Malayalam': (char) => char >= 0x0D00 && char <= 0x0D7F,\n // 'Sinhala': (char) => char >= 0x0D80 && char <= 0x0DFF,\n // 'Thai': (char) => char >= 0x0E00 && char <= 0x0E7F,\n // 'Lao': (char) => char >= 0x0E80 && char <= 0x0EFF,\n // 'Tibetan': (char) => char >= 0x0F00 && char <= 0x0FFF,\n // 'Myanmar': (char) => char >= 0x1000 && char <= 0x109F,\n // 'Georgian': (char) => char >= 0x10A0 && char <= 0x10FF,\n 'Hangul Jamo': (char) => char >= 0x1100 && char <= 0x11FF,\n // 'Ethiopic': (char) => char >= 0x1200 && char <= 0x137F,\n // 'Ethiopic Supplement': (char) => char >= 0x1380 && char <= 0x139F,\n // 'Cherokee': (char) => char >= 0x13A0 && char <= 0x13FF,\n 'Unified Canadian Aboriginal Syllabics': (char) => char >= 0x1400 && char <= 0x167F,\n // 'Ogham': (char) => char >= 0x1680 && char <= 0x169F,\n // 'Runic': (char) => char >= 0x16A0 && char <= 0x16FF,\n // 'Tagalog': (char) => char >= 0x1700 && char <= 0x171F,\n // 'Hanunoo': (char) => char >= 0x1720 && char <= 0x173F,\n // 'Buhid': (char) => char >= 0x1740 && char <= 0x175F,\n // 'Tagbanwa': (char) => char >= 0x1760 && char <= 0x177F,\n 'Khmer': (char) => char >= 0x1780 && char <= 0x17FF,\n // 'Mongolian': (char) => char >= 0x1800 && char <= 0x18AF,\n 'Unified Canadian Aboriginal Syllabics Extended': (char) => char >= 0x18B0 && char <= 0x18FF,\n // 'Limbu': (char) => char >= 0x1900 && char <= 0x194F,\n // 'Tai Le': (char) => char >= 0x1950 && char <= 0x197F,\n // 'New Tai Lue': (char) => char >= 0x1980 && char <= 0x19DF,\n // 'Khmer Symbols': (char) => char >= 0x19E0 && char <= 0x19FF,\n // 'Buginese': (char) => char >= 0x1A00 && char <= 0x1A1F,\n // 'Tai Tham': (char) => char >= 0x1A20 && char <= 0x1AAF,\n // 'Combining Diacritical Marks Extended': (char) => char >= 0x1AB0 && char <= 0x1AFF,\n // 'Balinese': (char) => char >= 0x1B00 && char <= 0x1B7F,\n // 'Sundanese': (char) => char >= 0x1B80 && char <= 0x1BBF,\n // 'Batak': (char) => char >= 0x1BC0 && char <= 0x1BFF,\n // 'Lepcha': (char) => char >= 0x1C00 && char <= 0x1C4F,\n // 'Ol Chiki': (char) => char >= 0x1C50 && char <= 0x1C7F,\n // 'Cyrillic Extended-C': (char) => char >= 0x1C80 && char <= 0x1C8F,\n // 'Georgian Extended': (char) => char >= 0x1C90 && char <= 0x1CBF,\n // 'Sundanese Supplement': (char) => char >= 0x1CC0 && char <= 0x1CCF,\n // 'Vedic Extensions': (char) => char >= 0x1CD0 && char <= 0x1CFF,\n // 'Phonetic Extensions': (char) => char >= 0x1D00 && char <= 0x1D7F,\n // 'Phonetic Extensions Supplement': (char) => char >= 0x1D80 && char <= 0x1DBF,\n // 'Combining Diacritical Marks Supplement': (char) => char >= 0x1DC0 && char <= 0x1DFF,\n // 'Latin Extended Additional': (char) => char >= 0x1E00 && char <= 0x1EFF,\n // 'Greek Extended': (char) => char >= 0x1F00 && char <= 0x1FFF,\n 'General Punctuation': (char) => char >= 0x2000 && char <= 0x206F,\n // 'Superscripts and Subscripts': (char) => char >= 0x2070 && char <= 0x209F,\n // 'Currency Symbols': (char) => char >= 0x20A0 && char <= 0x20CF,\n // 'Combining Diacritical Marks for Symbols': (char) => char >= 0x20D0 && char <= 0x20FF,\n 'Letterlike Symbols': (char) => char >= 0x2100 && char <= 0x214F,\n 'Number Forms': (char) => char >= 0x2150 && char <= 0x218F,\n // 'Arrows': (char) => char >= 0x2190 && char <= 0x21FF,\n // 'Mathematical Operators': (char) => char >= 0x2200 && char <= 0x22FF,\n 'Miscellaneous Technical': (char) => char >= 0x2300 && char <= 0x23FF,\n 'Control Pictures': (char) => char >= 0x2400 && char <= 0x243F,\n 'Optical Character Recognition': (char) => char >= 0x2440 && char <= 0x245F,\n 'Enclosed Alphanumerics': (char) => char >= 0x2460 && char <= 0x24FF,\n // 'Box Drawing': (char) => char >= 0x2500 && char <= 0x257F,\n // 'Block Elements': (char) => char >= 0x2580 && char <= 0x259F,\n 'Geometric Shapes': (char) => char >= 0x25A0 && char <= 0x25FF,\n 'Miscellaneous Symbols': (char) => char >= 0x2600 && char <= 0x26FF,\n // 'Dingbats': (char) => char >= 0x2700 && char <= 0x27BF,\n // 'Miscellaneous Mathematical Symbols-A': (char) => char >= 0x27C0 && char <= 0x27EF,\n // 'Supplemental Arrows-A': (char) => char >= 0x27F0 && char <= 0x27FF,\n // 'Braille Patterns': (char) => char >= 0x2800 && char <= 0x28FF,\n // 'Supplemental Arrows-B': (char) => char >= 0x2900 && char <= 0x297F,\n // 'Miscellaneous Mathematical Symbols-B': (char) => char >= 0x2980 && char <= 0x29FF,\n // 'Supplemental Mathematical Operators': (char) => char >= 0x2A00 && char <= 0x2AFF,\n 'Miscellaneous Symbols and Arrows': (char) => char >= 0x2B00 && char <= 0x2BFF,\n // 'Glagolitic': (char) => char >= 0x2C00 && char <= 0x2C5F,\n // 'Latin Extended-C': (char) => char >= 0x2C60 && char <= 0x2C7F,\n // 'Coptic': (char) => char >= 0x2C80 && char <= 0x2CFF,\n // 'Georgian Supplement': (char) => char >= 0x2D00 && char <= 0x2D2F,\n // 'Tifinagh': (char) => char >= 0x2D30 && char <= 0x2D7F,\n // 'Ethiopic Extended': (char) => char >= 0x2D80 && char <= 0x2DDF,\n // 'Cyrillic Extended-A': (char) => char >= 0x2DE0 && char <= 0x2DFF,\n // 'Supplemental Punctuation': (char) => char >= 0x2E00 && char <= 0x2E7F,\n 'CJK Radicals Supplement': (char) => char >= 0x2E80 && char <= 0x2EFF,\n 'Kangxi Radicals': (char) => char >= 0x2F00 && char <= 0x2FDF,\n 'Ideographic Description Characters': (char) => char >= 0x2FF0 && char <= 0x2FFF,\n 'CJK Symbols and Punctuation': (char) => char >= 0x3000 && char <= 0x303F,\n 'Hiragana': (char) => char >= 0x3040 && char <= 0x309F,\n 'Katakana': (char) => char >= 0x30A0 && char <= 0x30FF,\n 'Bopomofo': (char) => char >= 0x3100 && char <= 0x312F,\n 'Hangul Compatibility Jamo': (char) => char >= 0x3130 && char <= 0x318F,\n 'Kanbun': (char) => char >= 0x3190 && char <= 0x319F,\n 'Bopomofo Extended': (char) => char >= 0x31A0 && char <= 0x31BF,\n 'CJK Strokes': (char) => char >= 0x31C0 && char <= 0x31EF,\n 'Katakana Phonetic Extensions': (char) => char >= 0x31F0 && char <= 0x31FF,\n 'Enclosed CJK Letters and Months': (char) => char >= 0x3200 && char <= 0x32FF,\n 'CJK Compatibility': (char) => char >= 0x3300 && char <= 0x33FF,\n 'CJK Unified Ideographs Extension A': (char) => char >= 0x3400 && char <= 0x4DBF,\n 'Yijing Hexagram Symbols': (char) => char >= 0x4DC0 && char <= 0x4DFF,\n 'CJK Unified Ideographs': (char) => char >= 0x4E00 && char <= 0x9FFF,\n 'Yi Syllables': (char) => char >= 0xA000 && char <= 0xA48F,\n 'Yi Radicals': (char) => char >= 0xA490 && char <= 0xA4CF,\n // 'Lisu': (char) => char >= 0xA4D0 && char <= 0xA4FF,\n // 'Vai': (char) => char >= 0xA500 && char <= 0xA63F,\n // 'Cyrillic Extended-B': (char) => char >= 0xA640 && char <= 0xA69F,\n // 'Bamum': (char) => char >= 0xA6A0 && char <= 0xA6FF,\n // 'Modifier Tone Letters': (char) => char >= 0xA700 && char <= 0xA71F,\n // 'Latin Extended-D': (char) => char >= 0xA720 && char <= 0xA7FF,\n // 'Syloti Nagri': (char) => char >= 0xA800 && char <= 0xA82F,\n // 'Common Indic Number Forms': (char) => char >= 0xA830 && char <= 0xA83F,\n // 'Phags-pa': (char) => char >= 0xA840 && char <= 0xA87F,\n // 'Saurashtra': (char) => char >= 0xA880 && char <= 0xA8DF,\n // 'Devanagari Extended': (char) => char >= 0xA8E0 && char <= 0xA8FF,\n // 'Kayah Li': (char) => char >= 0xA900 && char <= 0xA92F,\n // 'Rejang': (char) => char >= 0xA930 && char <= 0xA95F,\n 'Hangul Jamo Extended-A': (char) => char >= 0xA960 && char <= 0xA97F,\n // 'Javanese': (char) => char >= 0xA980 && char <= 0xA9DF,\n // 'Myanmar Extended-B': (char) => char >= 0xA9E0 && char <= 0xA9FF,\n // 'Cham': (char) => char >= 0xAA00 && char <= 0xAA5F,\n // 'Myanmar Extended-A': (char) => char >= 0xAA60 && char <= 0xAA7F,\n // 'Tai Viet': (char) => char >= 0xAA80 && char <= 0xAADF,\n // 'Meetei Mayek Extensions': (char) => char >= 0xAAE0 && char <= 0xAAFF,\n // 'Ethiopic Extended-A': (char) => char >= 0xAB00 && char <= 0xAB2F,\n // 'Latin Extended-E': (char) => char >= 0xAB30 && char <= 0xAB6F,\n // 'Cherokee Supplement': (char) => char >= 0xAB70 && char <= 0xABBF,\n // 'Meetei Mayek': (char) => char >= 0xABC0 && char <= 0xABFF,\n 'Hangul Syllables': (char) => char >= 0xAC00 && char <= 0xD7AF,\n 'Hangul Jamo Extended-B': (char) => char >= 0xD7B0 && char <= 0xD7FF,\n // 'High Surrogates': (char) => char >= 0xD800 && char <= 0xDB7F,\n // 'High Private Use Surrogates': (char) => char >= 0xDB80 && char <= 0xDBFF,\n // 'Low Surrogates': (char) => char >= 0xDC00 && char <= 0xDFFF,\n 'Private Use Area': (char) => char >= 0xE000 && char <= 0xF8FF,\n 'CJK Compatibility Ideographs': (char) => char >= 0xF900 && char <= 0xFAFF,\n // 'Alphabetic Presentation Forms': (char) => char >= 0xFB00 && char <= 0xFB4F,\n 'Arabic Presentation Forms-A': (char) => char >= 0xFB50 && char <= 0xFDFF,\n // 'Variation Selectors': (char) => char >= 0xFE00 && char <= 0xFE0F,\n 'Vertical Forms': (char) => char >= 0xFE10 && char <= 0xFE1F,\n // 'Combining Half Marks': (char) => char >= 0xFE20 && char <= 0xFE2F,\n 'CJK Compatibility Forms': (char) => char >= 0xFE30 && char <= 0xFE4F,\n 'Small Form Variants': (char) => char >= 0xFE50 && char <= 0xFE6F,\n 'Arabic Presentation Forms-B': (char) => char >= 0xFE70 && char <= 0xFEFF,\n 'Halfwidth and Fullwidth Forms': (char) => char >= 0xFF00 && char <= 0xFFEF\n // 'Specials': (char) => char >= 0xFFF0 && char <= 0xFFFF,\n // 'Linear B Syllabary': (char) => char >= 0x10000 && char <= 0x1007F,\n // 'Linear B Ideograms': (char) => char >= 0x10080 && char <= 0x100FF,\n // 'Aegean Numbers': (char) => char >= 0x10100 && char <= 0x1013F,\n // 'Ancient Greek Numbers': (char) => char >= 0x10140 && char <= 0x1018F,\n // 'Ancient Symbols': (char) => char >= 0x10190 && char <= 0x101CF,\n // 'Phaistos Disc': (char) => char >= 0x101D0 && char <= 0x101FF,\n // 'Lycian': (char) => char >= 0x10280 && char <= 0x1029F,\n // 'Carian': (char) => char >= 0x102A0 && char <= 0x102DF,\n // 'Coptic Epact Numbers': (char) => char >= 0x102E0 && char <= 0x102FF,\n // 'Old Italic': (char) => char >= 0x10300 && char <= 0x1032F,\n // 'Gothic': (char) => char >= 0x10330 && char <= 0x1034F,\n // 'Old Permic': (char) => char >= 0x10350 && char <= 0x1037F,\n // 'Ugaritic': (char) => char >= 0x10380 && char <= 0x1039F,\n // 'Old Persian': (char) => char >= 0x103A0 && char <= 0x103DF,\n // 'Deseret': (char) => char >= 0x10400 && char <= 0x1044F,\n // 'Shavian': (char) => char >= 0x10450 && char <= 0x1047F,\n // 'Osmanya': (char) => char >= 0x10480 && char <= 0x104AF,\n // 'Osage': (char) => char >= 0x104B0 && char <= 0x104FF,\n // 'Elbasan': (char) => char >= 0x10500 && char <= 0x1052F,\n // 'Caucasian Albanian': (char) => char >= 0x10530 && char <= 0x1056F,\n // 'Linear A': (char) => char >= 0x10600 && char <= 0x1077F,\n // 'Cypriot Syllabary': (char) => char >= 0x10800 && char <= 0x1083F,\n // 'Imperial Aramaic': (char) => char >= 0x10840 && char <= 0x1085F,\n // 'Palmyrene': (char) => char >= 0x10860 && char <= 0x1087F,\n // 'Nabataean': (char) => char >= 0x10880 && char <= 0x108AF,\n // 'Hatran': (char) => char >= 0x108E0 && char <= 0x108FF,\n // 'Phoenician': (char) => char >= 0x10900 && char <= 0x1091F,\n // 'Lydian': (char) => char >= 0x10920 && char <= 0x1093F,\n // 'Meroitic Hieroglyphs': (char) => char >= 0x10980 && char <= 0x1099F,\n // 'Meroitic Cursive': (char) => char >= 0x109A0 && char <= 0x109FF,\n // 'Kharoshthi': (char) => char >= 0x10A00 && char <= 0x10A5F,\n // 'Old South Arabian': (char) => char >= 0x10A60 && char <= 0x10A7F,\n // 'Old North Arabian': (char) => char >= 0x10A80 && char <= 0x10A9F,\n // 'Manichaean': (char) => char >= 0x10AC0 && char <= 0x10AFF,\n // 'Avestan': (char) => char >= 0x10B00 && char <= 0x10B3F,\n // 'Inscriptional Parthian': (char) => char >= 0x10B40 && char <= 0x10B5F,\n // 'Inscriptional Pahlavi': (char) => char >= 0x10B60 && char <= 0x10B7F,\n // 'Psalter Pahlavi': (char) => char >= 0x10B80 && char <= 0x10BAF,\n // 'Old Turkic': (char) => char >= 0x10C00 && char <= 0x10C4F,\n // 'Old Hungarian': (char) => char >= 0x10C80 && char <= 0x10CFF,\n // 'Hanifi Rohingya': (char) => char >= 0x10D00 && char <= 0x10D3F,\n // 'Rumi Numeral Symbols': (char) => char >= 0x10E60 && char <= 0x10E7F,\n // 'Old Sogdian': (char) => char >= 0x10F00 && char <= 0x10F2F,\n // 'Sogdian': (char) => char >= 0x10F30 && char <= 0x10F6F,\n // 'Elymaic': (char) => char >= 0x10FE0 && char <= 0x10FFF,\n // 'Brahmi': (char) => char >= 0x11000 && char <= 0x1107F,\n // 'Kaithi': (char) => char >= 0x11080 && char <= 0x110CF,\n // 'Sora Sompeng': (char) => char >= 0x110D0 && char <= 0x110FF,\n // 'Chakma': (char) => char >= 0x11100 && char <= 0x1114F,\n // 'Mahajani': (char) => char >= 0x11150 && char <= 0x1117F,\n // 'Sharada': (char) => char >= 0x11180 && char <= 0x111DF,\n // 'Sinhala Archaic Numbers': (char) => char >= 0x111E0 && char <= 0x111FF,\n // 'Khojki': (char) => char >= 0x11200 && char <= 0x1124F,\n // 'Multani': (char) => char >= 0x11280 && char <= 0x112AF,\n // 'Khudawadi': (char) => char >= 0x112B0 && char <= 0x112FF,\n // 'Grantha': (char) => char >= 0x11300 && char <= 0x1137F,\n // 'Newa': (char) => char >= 0x11400 && char <= 0x1147F,\n // 'Tirhuta': (char) => char >= 0x11480 && char <= 0x114DF,\n // 'Siddham': (char) => char >= 0x11580 && char <= 0x115FF,\n // 'Modi': (char) => char >= 0x11600 && char <= 0x1165F,\n // 'Mongolian Supplement': (char) => char >= 0x11660 && char <= 0x1167F,\n // 'Takri': (char) => char >= 0x11680 && char <= 0x116CF,\n // 'Ahom': (char) => char >= 0x11700 && char <= 0x1173F,\n // 'Dogra': (char) => char >= 0x11800 && char <= 0x1184F,\n // 'Warang Citi': (char) => char >= 0x118A0 && char <= 0x118FF,\n // 'Nandinagari': (char) => char >= 0x119A0 && char <= 0x119FF,\n // 'Zanabazar Square': (char) => char >= 0x11A00 && char <= 0x11A4F,\n // 'Soyombo': (char) => char >= 0x11A50 && char <= 0x11AAF,\n // 'Pau Cin Hau': (char) => char >= 0x11AC0 && char <= 0x11AFF,\n // 'Bhaiksuki': (char) => char >= 0x11C00 && char <= 0x11C6F,\n // 'Marchen': (char) => char >= 0x11C70 && char <= 0x11CBF,\n // 'Masaram Gondi': (char) => char >= 0x11D00 && char <= 0x11D5F,\n // 'Gunjala Gondi': (char) => char >= 0x11D60 && char <= 0x11DAF,\n // 'Makasar': (char) => char >= 0x11EE0 && char <= 0x11EFF,\n // 'Tamil Supplement': (char) => char >= 0x11FC0 && char <= 0x11FFF,\n // 'Cuneiform': (char) => char >= 0x12000 && char <= 0x123FF,\n // 'Cuneiform Numbers and Punctuation': (char) => char >= 0x12400 && char <= 0x1247F,\n // 'Early Dynastic Cuneiform': (char) => char >= 0x12480 && char <= 0x1254F,\n // 'Egyptian Hieroglyphs': (char) => char >= 0x13000 && char <= 0x1342F,\n // 'Egyptian Hieroglyph Format Controls': (char) => char >= 0x13430 && char <= 0x1343F,\n // 'Anatolian Hieroglyphs': (char) => char >= 0x14400 && char <= 0x1467F,\n // 'Bamum Supplement': (char) => char >= 0x16800 && char <= 0x16A3F,\n // 'Mro': (char) => char >= 0x16A40 && char <= 0x16A6F,\n // 'Bassa Vah': (char) => char >= 0x16AD0 && char <= 0x16AFF,\n // 'Pahawh Hmong': (char) => char >= 0x16B00 && char <= 0x16B8F,\n // 'Medefaidrin': (char) => char >= 0x16E40 && char <= 0x16E9F,\n // 'Miao': (char) => char >= 0x16F00 && char <= 0x16F9F,\n // 'Ideographic Symbols and Punctuation': (char) => char >= 0x16FE0 && char <= 0x16FFF,\n // 'Tangut': (char) => char >= 0x17000 && char <= 0x187FF,\n // 'Tangut Components': (char) => char >= 0x18800 && char <= 0x18AFF,\n // 'Kana Supplement': (char) => char >= 0x1B000 && char <= 0x1B0FF,\n // 'Kana Extended-A': (char) => char >= 0x1B100 && char <= 0x1B12F,\n // 'Small Kana Extension': (char) => char >= 0x1B130 && char <= 0x1B16F,\n // 'Nushu': (char) => char >= 0x1B170 && char <= 0x1B2FF,\n // 'Duployan': (char) => char >= 0x1BC00 && char <= 0x1BC9F,\n // 'Shorthand Format Controls': (char) => char >= 0x1BCA0 && char <= 0x1BCAF,\n // 'Byzantine Musical Symbols': (char) => char >= 0x1D000 && char <= 0x1D0FF,\n // 'Musical Symbols': (char) => char >= 0x1D100 && char <= 0x1D1FF,\n // 'Ancient Greek Musical Notation': (char) => char >= 0x1D200 && char <= 0x1D24F,\n // 'Mayan Numerals': (char) => char >= 0x1D2E0 && char <= 0x1D2FF,\n // 'Tai Xuan Jing Symbols': (char) => char >= 0x1D300 && char <= 0x1D35F,\n // 'Counting Rod Numerals': (char) => char >= 0x1D360 && char <= 0x1D37F,\n // 'Mathematical Alphanumeric Symbols': (char) => char >= 0x1D400 && char <= 0x1D7FF,\n // 'Sutton SignWriting': (char) => char >= 0x1D800 && char <= 0x1DAAF,\n // 'Glagolitic Supplement': (char) => char >= 0x1E000 && char <= 0x1E02F,\n // 'Nyiakeng Puachue Hmong': (char) => char >= 0x1E100 && char <= 0x1E14F,\n // 'Wancho': (char) => char >= 0x1E2C0 && char <= 0x1E2FF,\n // 'Mende Kikakui': (char) => char >= 0x1E800 && char <= 0x1E8DF,\n // 'Adlam': (char) => char >= 0x1E900 && char <= 0x1E95F,\n // 'Indic Siyaq Numbers': (char) => char >= 0x1EC70 && char <= 0x1ECBF,\n // 'Ottoman Siyaq Numbers': (char) => char >= 0x1ED00 && char <= 0x1ED4F,\n // 'Arabic Mathematical Alphabetic Symbols': (char) => char >= 0x1EE00 && char <= 0x1EEFF,\n // 'Mahjong Tiles': (char) => char >= 0x1F000 && char <= 0x1F02F,\n // 'Domino Tiles': (char) => char >= 0x1F030 && char <= 0x1F09F,\n // 'Playing Cards': (char) => char >= 0x1F0A0 && char <= 0x1F0FF,\n // 'Enclosed Alphanumeric Supplement': (char) => char >= 0x1F100 && char <= 0x1F1FF,\n // 'Enclosed Ideographic Supplement': (char) => char >= 0x1F200 && char <= 0x1F2FF,\n // 'Miscellaneous Symbols and Pictographs': (char) => char >= 0x1F300 && char <= 0x1F5FF,\n // 'Emoticons': (char) => char >= 0x1F600 && char <= 0x1F64F,\n // 'Ornamental Dingbats': (char) => char >= 0x1F650 && char <= 0x1F67F,\n // 'Transport and Map Symbols': (char) => char >= 0x1F680 && char <= 0x1F6FF,\n // 'Alchemical Symbols': (char) => char >= 0x1F700 && char <= 0x1F77F,\n // 'Geometric Shapes Extended': (char) => char >= 0x1F780 && char <= 0x1F7FF,\n // 'Supplemental Arrows-C': (char) => char >= 0x1F800 && char <= 0x1F8FF,\n // 'Supplemental Symbols and Pictographs': (char) => char >= 0x1F900 && char <= 0x1F9FF,\n // 'Chess Symbols': (char) => char >= 0x1FA00 && char <= 0x1FA6F,\n // 'Symbols and Pictographs Extended-A': (char) => char >= 0x1FA70 && char <= 0x1FAFF,\n // 'CJK Unified Ideographs Extension B': (char) => char >= 0x20000 && char <= 0x2A6DF,\n // 'CJK Unified Ideographs Extension C': (char) => char >= 0x2A700 && char <= 0x2B73F,\n // 'CJK Unified Ideographs Extension D': (char) => char >= 0x2B740 && char <= 0x2B81F,\n // 'CJK Unified Ideographs Extension E': (char) => char >= 0x2B820 && char <= 0x2CEAF,\n // 'CJK Unified Ideographs Extension F': (char) => char >= 0x2CEB0 && char <= 0x2EBEF,\n // 'CJK Compatibility Ideographs Supplement': (char) => char >= 0x2F800 && char <= 0x2FA1F,\n // 'Tags': (char) => char >= 0xE0000 && char <= 0xE007F,\n // 'Variation Selectors Supplement': (char) => char >= 0xE0100 && char <= 0xE01EF,\n // 'Supplementary Private Use Area-A': (char) => char >= 0xF0000 && char <= 0xFFFFF,\n // 'Supplementary Private Use Area-B': (char) => char >= 0x100000 && char <= 0x10FFFF,\n};\n","/* eslint-disable new-cap */\n\nimport {unicodeBlockLookup as isChar} from './is_char_in_unicode_block';\n\nexport function allowsIdeographicBreaking(chars: string) {\n for (const char of chars) {\n if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function allowsVerticalWritingMode(chars: string) {\n for (const char of chars) {\n if (charHasUprightVerticalOrientation(char.charCodeAt(0))) return true;\n }\n return false;\n}\n\nexport function allowsLetterSpacing(chars: string) {\n for (const char of chars) {\n if (!charAllowsLetterSpacing(char.charCodeAt(0))) return false;\n }\n return true;\n}\n\nexport function charAllowsLetterSpacing(char: number) {\n if (isChar['Arabic'](char)) return false;\n if (isChar['Arabic Supplement'](char)) return false;\n if (isChar['Arabic Extended-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-A'](char)) return false;\n if (isChar['Arabic Presentation Forms-B'](char)) return false;\n\n return true;\n}\n\nexport function charAllowsIdeographicBreaking(char: number) {\n // Return early for characters outside all ideographic ranges.\n if (char < 0x2E80) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n\n return false;\n}\n\n// The following logic comes from\n// .\n// Keep it synchronized with\n// .\n// The data file denotes with “U” or “Tu” any codepoint that may be drawn\n// upright in vertical text but does not distinguish between upright and\n// “neutral” characters.\n\n// Blocks in the Unicode supplementary planes are excluded from this module due\n// to .\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * upright orientation.\n *\n * A character has upright orientation if it is drawn upright (unrotated)\n * whether the line is oriented horizontally or vertically, even if both\n * adjacent characters can be rotated. For example, a Chinese character is\n * always drawn upright. An uprightly oriented character causes an adjacent\n * “neutral” character to be drawn upright as well.\n */\nexport function charHasUprightVerticalOrientation(char: number) {\n if (char === 0x02EA /* modifier letter yin departing tone mark */ ||\n char === 0x02EB /* modifier letter yang departing tone mark */) {\n return true;\n }\n\n // Return early for characters outside all ranges whose characters remain\n // upright in vertical writing mode.\n if (char < 0x1100) return false;\n\n if (isChar['Bopomofo Extended'](char)) return true;\n if (isChar['Bopomofo'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) {\n if (!((char >= 0xFE49 /* dashed overline */ && char <= 0xFE4F) /* wavy low line */)) {\n return true;\n }\n }\n if (isChar['CJK Compatibility Ideographs'](char)) return true;\n if (isChar['CJK Compatibility'](char)) return true;\n if (isChar['CJK Radicals Supplement'](char)) return true;\n if (isChar['CJK Strokes'](char)) return true;\n if (isChar['CJK Symbols and Punctuation'](char)) {\n if (!((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) &&\n !((char >= 0x3014 /* left tortoise shell bracket */ && char <= 0x301F) /* low double prime quotation mark */) &&\n char !== 0x3030 /* wavy dash */) {\n return true;\n }\n }\n if (isChar['CJK Unified Ideographs Extension A'](char)) return true;\n if (isChar['CJK Unified Ideographs'](char)) return true;\n if (isChar['Enclosed CJK Letters and Months'](char)) return true;\n if (isChar['Hangul Compatibility Jamo'](char)) return true;\n if (isChar['Hangul Jamo Extended-A'](char)) return true;\n if (isChar['Hangul Jamo Extended-B'](char)) return true;\n if (isChar['Hangul Jamo'](char)) return true;\n if (isChar['Hangul Syllables'](char)) return true;\n if (isChar['Hiragana'](char)) return true;\n if (isChar['Ideographic Description Characters'](char)) return true;\n if (isChar['Kanbun'](char)) return true;\n if (isChar['Kangxi Radicals'](char)) return true;\n if (isChar['Katakana Phonetic Extensions'](char)) return true;\n if (isChar['Katakana'](char)) {\n if (char !== 0x30FC /* katakana-hiragana prolonged sound mark */) {\n return true;\n }\n }\n if (isChar['Halfwidth and Fullwidth Forms'](char)) {\n if (char !== 0xFF08 /* fullwidth left parenthesis */ &&\n char !== 0xFF09 /* fullwidth right parenthesis */ &&\n char !== 0xFF0D /* fullwidth hyphen-minus */ &&\n !((char >= 0xFF1A /* fullwidth colon */ && char <= 0xFF1E) /* fullwidth greater-than sign */) &&\n char !== 0xFF3B /* fullwidth left square bracket */ &&\n char !== 0xFF3D /* fullwidth right square bracket */ &&\n char !== 0xFF3F /* fullwidth low line */ &&\n !(char >= 0xFF5B /* fullwidth left curly bracket */ && char <= 0xFFDF) &&\n char !== 0xFFE3 /* fullwidth macron */ &&\n !(char >= 0xFFE8 /* halfwidth forms light vertical */ && char <= 0xFFEF)) {\n return true;\n }\n }\n if (isChar['Small Form Variants'](char)) {\n if (!((char >= 0xFE58 /* small em dash */ && char <= 0xFE5E) /* small right tortoise shell bracket */) &&\n !((char >= 0xFE63 /* small hyphen-minus */ && char <= 0xFE66) /* small equals sign */)) {\n return true;\n }\n }\n if (isChar['Unified Canadian Aboriginal Syllabics'](char)) return true;\n if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) return true;\n if (isChar['Vertical Forms'](char)) return true;\n if (isChar['Yijing Hexagram Symbols'](char)) return true;\n if (isChar['Yi Syllables'](char)) return true;\n if (isChar['Yi Radicals'](char)) return true;\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * neutral orientation.\n *\n * A character has neutral orientation if it may be drawn rotated or unrotated\n * when the line is oriented vertically, depending on the orientation of the\n * adjacent characters. For example, along a verticlly oriented line, the vulgar\n * fraction ½ is drawn upright among Chinese characters but rotated among Latin\n * letters. A neutrally oriented character does not influence whether an\n * adjacent character is drawn upright or rotated.\n */\nexport function charHasNeutralVerticalOrientation(char: number) {\n if (isChar['Latin-1 Supplement'](char)) {\n if (char === 0x00A7 /* section sign */ ||\n char === 0x00A9 /* copyright sign */ ||\n char === 0x00AE /* registered sign */ ||\n char === 0x00B1 /* plus-minus sign */ ||\n char === 0x00BC /* vulgar fraction one quarter */ ||\n char === 0x00BD /* vulgar fraction one half */ ||\n char === 0x00BE /* vulgar fraction three quarters */ ||\n char === 0x00D7 /* multiplication sign */ ||\n char === 0x00F7 /* division sign */) {\n return true;\n }\n }\n if (isChar['General Punctuation'](char)) {\n if (char === 0x2016 /* double vertical line */ ||\n char === 0x2020 /* dagger */ ||\n char === 0x2021 /* double dagger */ ||\n char === 0x2030 /* per mille sign */ ||\n char === 0x2031 /* per ten thousand sign */ ||\n char === 0x203B /* reference mark */ ||\n char === 0x203C /* double exclamation mark */ ||\n char === 0x2042 /* asterism */ ||\n char === 0x2047 /* double question mark */ ||\n char === 0x2048 /* question exclamation mark */ ||\n char === 0x2049 /* exclamation question mark */ ||\n char === 0x2051 /* two asterisks aligned vertically */) {\n return true;\n }\n }\n if (isChar['Letterlike Symbols'](char)) return true;\n if (isChar['Number Forms'](char)) return true;\n if (isChar['Miscellaneous Technical'](char)) {\n if ((char >= 0x2300 /* diameter sign */ && char <= 0x2307 /* wavy line */) ||\n (char >= 0x230C /* bottom right crop */ && char <= 0x231F /* bottom right corner */) ||\n (char >= 0x2324 /* up arrowhead between two horizontal bars */ && char <= 0x2328 /* keyboard */) ||\n char === 0x232B /* erase to the left */ ||\n (char >= 0x237D /* shouldered open box */ && char <= 0x239A /* clear screen symbol */) ||\n (char >= 0x23BE /* dentistry symbol light vertical and top right */ && char <= 0x23CD /* square foot */) ||\n char === 0x23CF /* eject symbol */ ||\n (char >= 0x23D1 /* metrical breve */ && char <= 0x23DB /* fuse */) ||\n (char >= 0x23E2 /* white trapezium */ && char <= 0x23FF)) {\n return true;\n }\n }\n if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) return true;\n if (isChar['Optical Character Recognition'](char)) return true;\n if (isChar['Enclosed Alphanumerics'](char)) return true;\n if (isChar['Geometric Shapes'](char)) return true;\n if (isChar['Miscellaneous Symbols'](char)) {\n if (!((char >= 0x261A /* black left pointing index */ && char <= 0x261F) /* white down pointing index */)) {\n return true;\n }\n }\n if (isChar['Miscellaneous Symbols and Arrows'](char)) {\n if ((char >= 0x2B12 /* square with top half black */ && char <= 0x2B2F /* white vertical ellipse */) ||\n (char >= 0x2B50 /* white medium star */ && char <= 0x2B59 /* heavy circled saltire */) ||\n (char >= 0x2BB8 /* upwards white arrow from bar with horizontal bar */ && char <= 0x2BEB)) {\n return true;\n }\n }\n if (isChar['CJK Symbols and Punctuation'](char)) return true;\n if (isChar['Katakana'](char)) return true;\n if (isChar['Private Use Area'](char)) return true;\n if (isChar['CJK Compatibility Forms'](char)) return true;\n if (isChar['Small Form Variants'](char)) return true;\n if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;\n\n if (char === 0x221E /* infinity */ ||\n char === 0x2234 /* therefore */ ||\n char === 0x2235 /* because */ ||\n (char >= 0x2700 /* black safety scissors */ && char <= 0x2767 /* rotated floral heart bullet */) ||\n (char >= 0x2776 /* dingbat negative circled digit one */ && char <= 0x2793 /* dingbat negative circled sans-serif number ten */) ||\n char === 0xFFFC /* object replacement character */ ||\n char === 0xFFFD /* replacement character */) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Returns true if the given Unicode codepoint identifies a character with\n * rotated orientation.\n *\n * A character has rotated orientation if it is drawn rotated when the line is\n * oriented vertically, even if both adjacent characters are upright. For\n * example, a Latin letter is drawn rotated along a vertical line. A rotated\n * character causes an adjacent “neutral” character to be drawn rotated as well.\n */\nexport function charHasRotatedVerticalOrientation(char: number) {\n return !(charHasUprightVerticalOrientation(char) ||\n charHasNeutralVerticalOrientation(char));\n}\n\nexport function charInComplexShapingScript(char: number) {\n return isChar['Arabic'](char) ||\n isChar['Arabic Supplement'](char) ||\n isChar['Arabic Extended-A'](char) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInRTLScript(char: number) {\n // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts\n return (char >= 0x0590 && char <= 0x08FF) ||\n isChar['Arabic Presentation Forms-A'](char) ||\n isChar['Arabic Presentation Forms-B'](char);\n}\n\nexport function charInSupportedScript(char: number, canRenderRTL: boolean) {\n // This is a rough heuristic: whether we \"can render\" a script\n // actually depends on the properties of the font being used\n // and whether differences from the ideal rendering are considered\n // semantically significant.\n\n // Even in Latin script, we \"can't render\" combinations such as the fi\n // ligature, but we don't consider that semantically significant.\n if (!canRenderRTL && charInRTLScript(char)) {\n return false;\n }\n if ((char >= 0x0900 && char <= 0x0DFF) ||\n // Main blocks for Indic scripts and Sinhala\n (char >= 0x0F00 && char <= 0x109F) ||\n // Main blocks for Tibetan and Myanmar\n isChar['Khmer'](char)) {\n // These blocks cover common scripts that require\n // complex text shaping, based on unicode script metadata:\n // http://www.unicode.org/repos/cldr/trunk/common/properties/scriptMetadata.txt\n // where \"Web Rank <= 32\" \"Shaping Required = YES\"\n return false;\n }\n return true;\n}\n\nexport function stringContainsRTLText(chars: string): boolean {\n for (const char of chars) {\n if (charInRTLScript(char.charCodeAt(0))) {\n return true;\n }\n }\n return false;\n}\n\nexport function isStringInSupportedScript(chars: string, canRenderRTL: boolean) {\n for (const char of chars) {\n if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {\n return false;\n }\n }\n return true;\n}\n","import {getArrayBuffer} from '../util/ajax';\nimport {browser} from '../util/browser';\nimport {Event, Evented} from '../util/evented';\nimport {isWorker} from '../util/util';\n\nconst status = {\n unavailable: 'unavailable', // Not loaded\n deferred: 'deferred', // The plugin URL has been specified, but loading has been deferred\n loading: 'loading', // request in-flight\n loaded: 'loaded',\n error: 'error'\n};\n\nexport type PluginState = {\n pluginStatus: typeof status[keyof typeof status];\n pluginURL: string;\n};\n\n/**\n * An error callback\n */\ntype ErrorCallback = (error?: Error | null) => void;\ntype PluginStateSyncCallback = (state: PluginState) => void;\nlet _completionCallback = null;\n\n//Variables defining the current state of the plugin\nlet pluginStatus = status.unavailable;\nlet pluginURL = null;\n\nexport const triggerPluginCompletionEvent = function(error: Error | string) {\n // NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin\n if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) {\n pluginStatus = status.error;\n }\n\n if (_completionCallback) {\n _completionCallback(error);\n }\n};\n\nfunction sendPluginStateToWorker() {\n evented.fire(new Event('pluginStateChange', {pluginStatus, pluginURL}));\n}\n\nexport const evented = new Evented();\n\nexport const getRTLTextPluginStatus = function () {\n return pluginStatus;\n};\n\nexport const registerForPluginStateChange = function(callback: PluginStateSyncCallback) {\n // Do an initial sync of the state\n callback({pluginStatus, pluginURL});\n // Listen for all future state changes\n evented.on('pluginStateChange', callback);\n return callback;\n};\n\nexport const clearRTLTextPlugin = function() {\n pluginStatus = status.unavailable;\n pluginURL = null;\n _completionCallback = null;\n};\n\nexport const setRTLTextPlugin = function(url: string, callback: ErrorCallback, deferred: boolean = false) {\n if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) {\n throw new Error('setRTLTextPlugin cannot be called multiple times.');\n }\n pluginURL = browser.resolveURL(url);\n pluginStatus = status.deferred;\n _completionCallback = callback;\n sendPluginStateToWorker();\n\n //Start downloading the plugin immediately if not intending to lazy-load\n if (!deferred) {\n downloadRTLTextPlugin();\n }\n};\n\nexport const downloadRTLTextPlugin = function() {\n if (pluginStatus !== status.deferred || !pluginURL) {\n throw new Error('rtl-text-plugin cannot be downloaded unless a pluginURL is specified');\n }\n pluginStatus = status.loading;\n sendPluginStateToWorker();\n if (pluginURL) {\n getArrayBuffer({url: pluginURL}, (error) => {\n if (error) {\n triggerPluginCompletionEvent(error);\n } else {\n pluginStatus = status.loaded;\n sendPluginStateToWorker();\n }\n });\n }\n};\n\nexport const plugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n isLoaded: () => boolean;\n isLoading: () => boolean;\n setState: (state: PluginState) => void;\n isParsed: () => boolean;\n getPluginURL: () => string;\n} = {\n applyArabicShaping: null,\n processBidirectionalText: null,\n processStyledBidirectionalText: null,\n isLoaded() {\n return pluginStatus === status.loaded || // Main Thread: loaded if the completion callback returned successfully\n plugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled\n },\n isLoading() { // Main Thread Only: query the loading status, this function does not return the correct value in the worker context.\n return pluginStatus === status.loading;\n },\n setState(state: PluginState) { // Worker thread only: this tells the worker threads that the plugin is available on the Main thread\n if (!isWorker()) throw new Error('Cannot set the state of the rtl-text-plugin when not in the web-worker context');\n\n pluginStatus = state.pluginStatus;\n pluginURL = state.pluginURL;\n },\n isParsed(): boolean {\n if (!isWorker()) throw new Error('rtl-text-plugin is only parsed on the worker-threads');\n\n return plugin.applyArabicShaping != null &&\n plugin.processBidirectionalText != null &&\n plugin.processStyledBidirectionalText != null;\n },\n getPluginURL(): string {\n if (!isWorker()) throw new Error('rtl-text-plugin url can only be queried from the worker threads');\n return pluginURL;\n }\n};\n\nexport const lazyLoadRTLTextPlugin = function() {\n if (!plugin.isLoading() &&\n !plugin.isLoaded() &&\n getRTLTextPluginStatus() === 'deferred'\n ) {\n downloadRTLTextPlugin();\n }\n};\n","import {ZoomHistory} from './zoom_history';\nimport {isStringInSupportedScript} from '../util/script_detection';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {TransitionSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CrossfadeParameters = {\n fromScale: number;\n toScale: number;\n t: number;\n};\n\n/**\n * @internal\n * A parameter that can be evaluated to a value\n */\nexport class EvaluationParameters {\n zoom: number;\n now: number;\n fadeDuration: number;\n zoomHistory: ZoomHistory;\n transition: TransitionSpecification;\n\n // \"options\" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate\n constructor(zoom: number, options?: any) {\n this.zoom = zoom;\n\n if (options) {\n this.now = options.now;\n this.fadeDuration = options.fadeDuration;\n this.zoomHistory = options.zoomHistory;\n this.transition = options.transition;\n } else {\n this.now = 0;\n this.fadeDuration = 0;\n this.zoomHistory = new ZoomHistory();\n this.transition = {};\n }\n }\n\n isSupportedScript(str: string): boolean {\n return isStringInSupportedScript(str, rtlTextPlugin.isLoaded());\n }\n\n crossFadingFactor() {\n if (this.fadeDuration === 0) {\n return 1;\n } else {\n return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);\n }\n }\n\n getCrossfadeParameters(): CrossfadeParameters {\n const z = this.zoom;\n const fraction = z - Math.floor(z);\n const t = this.crossFadingFactor();\n\n return z > this.zoomHistory.lastIntegerZoom ?\n {fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t} :\n {fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction};\n }\n}\n","import {clone, extend, easeCubicInOut} from '../util/util';\nimport {interpolates, Color, StylePropertySpecification, normalizePropertyExpression,\n Feature,\n FeatureState,\n StylePropertyExpression,\n SourceExpression,\n CompositeExpression, TransitionSpecification,\n PropertyValueSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from './evaluation_parameters';\n\nimport {CanonicalTileID} from '../source/tile_id';\n\ntype TimePoint = number;\n\n/**\n * A from-to type\n */\nexport type CrossFaded = {\n to: T;\n from: T;\n};\n\n/**\n * @internal\n * Implementations of the `Property` interface:\n *\n * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value,\n * the default value, etc. This comes from the style specification JSON.\n * * Define behavior that needs to be polymorphic across different properties: \"possibly evaluating\"\n * an input value (see below), and interpolating between two possibly-evaluted values.\n *\n * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`).\n * The type `R` is the intermediate \"possibly evaluated\" value type. See below.\n *\n * There are two main implementations of the interface -- one for properties that allow data-driven values,\n * and one for properties that don't. There are a few \"special case\" implementations as well: one for properties\n * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`,\n * and one for `light-position`.\n */\nexport interface Property {\n specification: StylePropertySpecification;\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R;\n interpolate(a: R, b: R, t: number): R;\n}\n\n/**\n * @internal\n * `PropertyValue` represents the value part of a property key-value unit. It's used to represent both\n * paint and layout property values, and regardless of whether or not their property supports data-driven\n * expressions.\n *\n * `PropertyValue` stores the raw input value as seen in a style or a runtime styling API call, i.e. one of the\n * following:\n *\n * * A constant value of the type appropriate for the property\n * * A function which produces a value of that type (but functions are quasi-deprecated in favor of expressions)\n * * An expression which produces a value of that type\n * * \"undefined\"/\"not present\", in which case the property is assumed to take on its default value.\n *\n * In addition to storing the original input value, `PropertyValue` also stores a normalized representation,\n * effectively treating functions as if they are expressions, and constant or default values as if they are\n * (constant) expressions.\n */\nexport class PropertyValue {\n property: Property;\n value: PropertyValueSpecification | void;\n expression: StylePropertyExpression;\n\n constructor(property: Property, value: PropertyValueSpecification | void) {\n this.property = property;\n this.value = value;\n this.expression = normalizePropertyExpression(value === undefined ? property.specification.default : value, property.specification);\n }\n\n isDataDriven(): boolean {\n return this.expression.kind === 'source' || this.expression.kind === 'composite';\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): R {\n return this.property.possiblyEvaluate(this, parameters, canonical, availableImages);\n }\n}\n\nexport type TransitionParameters = {\n now: TimePoint;\n transition: TransitionSpecification;\n};\n\n/**\n * @internal\n * Paint properties are _transitionable_: they can change in a fluid manner, interpolating or cross-fading between\n * old and new value. The duration of the transition, and the delay before it begins, is configurable.\n *\n * `TransitionablePropertyValue` is a compositional class that stores both the property value and that transition\n * configuration.\n *\n * A `TransitionablePropertyValue` can calculate the next step in the evaluation chain for paint property values:\n * `TransitioningPropertyValue`.\n */\nclass TransitionablePropertyValue {\n property: Property;\n value: PropertyValue;\n transition: TransitionSpecification | void;\n\n constructor(property: Property) {\n this.property = property;\n this.value = new PropertyValue(property, undefined);\n }\n\n transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, prior,\n extend({}, parameters.transition, this.transition), parameters.now);\n }\n\n untransitioned(): TransitioningPropertyValue {\n return new TransitioningPropertyValue(this.property, this.value, null, {}, 0);\n }\n}\n\n/**\n * @internal\n * `Transitionable` stores a map of all (property name, `TransitionablePropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the `TransitioningPropertyValue`s for all of them at once, producing a\n * `Transitioning` instance for the same set of properties.\n */\nexport class Transitionable {\n _properties: Properties;\n _values: {[K in keyof Props]: TransitionablePropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitionablePropertyValues) as any);\n }\n\n getValue(name: S): PropertyValueSpecification | void {\n return clone(this._values[name].value.value);\n }\n\n setValue(name: S, value: PropertyValueSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n // Note that we do not _remove_ an own property in the case where a value is being reset\n // to the default: the transition might still be non-default.\n this._values[name].value = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value));\n }\n\n getTransition(name: S): TransitionSpecification | void {\n return clone(this._values[name].transition);\n }\n\n setTransition(name: S, value: TransitionSpecification | void) {\n if (!Object.prototype.hasOwnProperty.call(this._values, name)) {\n this._values[name] = new TransitionablePropertyValue(this._values[name].property);\n }\n this._values[name].transition = clone(value) || undefined;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n\n const transition = this.getTransition(property as keyof Props);\n if (transition !== undefined) {\n result[`${property}-transition`] = transition;\n }\n }\n return result;\n }\n\n transitioned(parameters: TransitionParameters, prior: Transitioning): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].transitioned(parameters, prior._values[property]);\n }\n return result;\n }\n\n untransitioned(): Transitioning {\n const result = new Transitioning(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].untransitioned();\n }\n return result;\n }\n}\n\n/**\n * @internal\n * `TransitioningPropertyValue` implements the first of two intermediate steps in the evaluation chain of a paint\n * property value. In this step, transitions between old and new values are handled: as long as the transition is in\n * progress, `TransitioningPropertyValue` maintains a reference to the prior value, and interpolates between it and\n * the new value based on the current time and the configured transition duration and delay. The product is the next\n * step in the evaluation chain: the \"possibly evaluated\" result type `R`. See below for more on this concept.\n */\nclass TransitioningPropertyValue {\n property: Property;\n value: PropertyValue;\n prior: TransitioningPropertyValue;\n begin: TimePoint;\n end: TimePoint;\n\n constructor(property: Property,\n value: PropertyValue,\n prior: TransitioningPropertyValue,\n transition: TransitionSpecification,\n now: TimePoint) {\n this.property = property;\n this.value = value;\n this.begin = now + transition.delay || 0;\n this.end = this.begin + transition.duration || 0;\n if (property.specification.transition && (transition.delay || transition.duration)) {\n this.prior = prior;\n }\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical: CanonicalTileID,\n availableImages: Array\n ): R {\n const now = parameters.now || 0;\n const finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages);\n const prior = this.prior;\n if (!prior) {\n // No prior value.\n return finalValue;\n } else if (now > this.end) {\n // Transition from prior value is now complete.\n this.prior = null;\n return finalValue;\n } else if (this.value.isDataDriven()) {\n // Transitions to data-driven properties are not supported.\n // We snap immediately to the data-driven value so that, when we perform layout,\n // we see the data-driven function and can use it to populate vertex buffers.\n this.prior = null;\n return finalValue;\n } else if (now < this.begin) {\n // Transition hasn't started yet.\n return prior.possiblyEvaluate(parameters, canonical, availableImages);\n } else {\n // Interpolate between recursively-calculated prior value and final.\n const t = (now - this.begin) / (this.end - this.begin);\n return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t));\n }\n }\n}\n\n/**\n * @internal\n * `Transitioning` stores a map of all (property name, `TransitioningPropertyValue`) pairs for paint properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Transitioning {\n _properties: Properties;\n _values: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultTransitioningPropertyValues) as any);\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n\n hasTransition() {\n for (const property of Object.keys(this._values)) {\n if (this._values[property].prior) {\n return true;\n }\n }\n return false;\n }\n}\n\n// ------- Layout -------\n\n/**\n * Because layout properties are not transitionable, they have a simpler representation and evaluation chain than\n * paint properties: `PropertyValue`s are possibly evaluated, producing possibly evaluated values, which are then\n * fully evaluated.\n *\n * `Layout` stores a map of all (property name, `PropertyValue`) pairs for layout properties of a\n * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a\n * `PossiblyEvaluated` instance for the same set of properties.\n */\nexport class Layout {\n _properties: Properties;\n _values: {[K in keyof Props]: PropertyValue>};\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = (Object.create(properties.defaultPropertyValues) as any);\n }\n\n hasValue(name: S) {\n return this._values[name].value !== undefined;\n }\n\n getValue(name: S) {\n return clone(this._values[name].value);\n }\n\n setValue(name: S, value: any) {\n this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value)) as any;\n }\n\n serialize() {\n const result: any = {};\n for (const property of Object.keys(this._values)) {\n const value = this.getValue(property as keyof Props);\n if (value !== undefined) {\n result[property] = value;\n }\n }\n return result;\n }\n\n possiblyEvaluate(\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluated {\n const result = new PossiblyEvaluated(this._properties);\n for (const property of Object.keys(this._values)) {\n result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);\n }\n return result;\n }\n}\n\n// ------- PossiblyEvaluated -------\n\n/**\n * \"Possibly evaluated value\" is an intermediate stage in the evaluation chain for both paint and layout property\n * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code\n * which uses data-driven property values must assume that the value is dependent on feature data, and request that it\n * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation\n * will not actually depend on the feature, and we can benefit from returning the prior result of having done the\n * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and \"global\" parameters\n * such as current zoom level.\n *\n * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or\n * camera expression, then the \"possibly evaluated\" result is a constant value. Otherwise, the input value was either\n * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate\n * the source and composite cases because they are handled differently when generating GL attributes, buffers, and\n * uniforms.\n *\n * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that\n * do not allow data-driven values. For such properties, we know that the \"possibly evaluated\" result is always a constant\n * scalar value. See below.\n */\ntype PossiblyEvaluatedValue = {\n kind: 'constant';\n value: T;\n} | SourceExpression | CompositeExpression;\n\n/**\n * @internal\n * `PossiblyEvaluatedPropertyValue` is used for data-driven paint and layout property values. It holds a\n * `PossiblyEvaluatedValue` and the `GlobalProperties` that were used to generate it. You're not allowed to supply\n * a different set of `GlobalProperties` when performing the final evaluation because they would be ignored in the\n * case where the input value was a constant or camera function.\n */\nexport class PossiblyEvaluatedPropertyValue {\n property: DataDrivenProperty;\n value: PossiblyEvaluatedValue;\n parameters: EvaluationParameters;\n\n constructor(property: DataDrivenProperty, value: PossiblyEvaluatedValue, parameters: EvaluationParameters) {\n this.property = property;\n this.value = value;\n this.parameters = parameters;\n }\n\n isConstant(): boolean {\n return this.value.kind === 'constant';\n }\n\n constantOr(value: T): T {\n if (this.value.kind === 'constant') {\n return this.value.value;\n } else {\n return value;\n }\n }\n\n evaluate(\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages);\n }\n}\n\n/**\n * @internal\n * `PossiblyEvaluated` stores a map of all (property name, `R`) pairs for paint or layout properties of a\n * given layer type.\n */\nexport class PossiblyEvaluated {\n _properties: Properties;\n _values: PossibleEvaluatedProps;\n\n constructor(properties: Properties) {\n this._properties = properties;\n this._values = Object.create(properties.defaultPossiblyEvaluatedValues);\n }\n\n get(name: S): PossibleEvaluatedProps[S] {\n return this._values[name];\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that do not permit data-driven (source or composite) expressions.\n * This restriction allows us to declare statically that the result of possibly evaluating this kind of property\n * is in fact always the scalar type `T`, and can be used without further evaluating the value on a per-feature basis.\n */\nexport class DataConstantProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters): T {\n if (value.isDataDriven()) throw new Error('Value should not be data driven');\n return value.expression.evaluate(parameters);\n }\n\n interpolate(a: T, b: T, t: number): T {\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n return interpolationFn(a, b, t);\n } else {\n return a;\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for properties that permit data-driven (source or composite) expressions.\n * The result of possibly evaluating this kind of property is `PossiblyEvaluatedPropertyValue`; obtaining\n * a scalar value `T` requires further evaluation on a per-feature basis.\n */\nexport class DataDrivenProperty implements Property> {\n specification: StylePropertySpecification;\n overrides: any;\n\n constructor(specification: StylePropertySpecification, overrides?: any) {\n this.specification = specification;\n this.overrides = overrides;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue {\n if (value.expression.kind === 'constant' || value.expression.kind === 'camera') {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: value.expression.evaluate(parameters, null, {}, canonical, availableImages)}, parameters);\n } else {\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n interpolate(\n a: PossiblyEvaluatedPropertyValue,\n b: PossiblyEvaluatedPropertyValue,\n t: number\n ): PossiblyEvaluatedPropertyValue {\n // If either possibly-evaluated value is non-constant, give up: we aren't able to interpolate data-driven values.\n if (a.value.kind !== 'constant' || b.value.kind !== 'constant') {\n return a;\n }\n\n // Special case hack solely for fill-outline-color. The undefined value is subsequently handled in\n // FillStyleLayer#recalculate, which sets fill-outline-color to the fill-color value if the former\n // is a PossiblyEvaluatedPropertyValue containing a constant undefined value. In addition to the\n // return value here, the other source of a PossiblyEvaluatedPropertyValue containing a constant\n // undefined value is the \"default value\" for fill-outline-color held in\n // `Properties#defaultPossiblyEvaluatedValues`, which serves as the prototype of\n // `PossiblyEvaluated#_values`.\n if (a.value.value === undefined || b.value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, a.parameters);\n }\n\n const interpolationType = this.specification.type as keyof typeof interpolates;\n const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined;\n if (interpolationFn) {\n const interpolatedValue = interpolationFn(a.value.value, b.value.value, t);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: interpolatedValue}, a.parameters);\n } else {\n return a;\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue,\n parameters: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): T {\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return value.evaluate(parameters, feature, featureState, canonical, availableImages);\n }\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for data driven `line-pattern` which are transitioned by cross-fading\n * rather than interpolation.\n */\n\nexport class CrossFadedDataDrivenProperty extends DataDrivenProperty> {\n\n possiblyEvaluate(\n value: PropertyValue, PossiblyEvaluatedPropertyValue>>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): PossiblyEvaluatedPropertyValue> {\n if (value.value === undefined) {\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, parameters);\n } else if (value.expression.kind === 'constant') {\n const evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n const isImageExpression = value.property.specification.type as any === 'resolvedImage';\n const constantValue = isImageExpression && typeof evaluatedValue !== 'string' ? evaluatedValue.name : evaluatedValue;\n const constant = this._calculate(constantValue, constantValue, constantValue, parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: constant}, parameters);\n } else if (value.expression.kind === 'camera') {\n const cameraVal = this._calculate(\n value.expression.evaluate({zoom: parameters.zoom - 1.0}),\n value.expression.evaluate({zoom: parameters.zoom}),\n value.expression.evaluate({zoom: parameters.zoom + 1.0}),\n parameters);\n return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: cameraVal}, parameters);\n } else {\n // source or composite expression\n return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);\n }\n }\n\n evaluate(\n value: PossiblyEvaluatedValue>,\n globals: EvaluationParameters,\n feature: Feature,\n featureState: FeatureState,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.kind === 'source') {\n const constant = value.evaluate(globals, feature, featureState, canonical, availableImages);\n return this._calculate(constant, constant, constant, globals);\n } else if (value.kind === 'composite') {\n return this._calculate(\n value.evaluate({zoom: Math.floor(globals.zoom) - 1.0}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom)}, feature, featureState),\n value.evaluate({zoom: Math.floor(globals.zoom) + 1.0}, feature, featureState),\n globals);\n } else {\n return value.value;\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue> {\n return a;\n }\n}\n/**\n * @internal\n * An implementation of `Property` for `*-pattern` and `line-dasharray`, which are transitioned by cross-fading\n * rather than interpolation.\n */\nexport class CrossFadedProperty implements Property> {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue>,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): CrossFaded {\n if (value.value === undefined) {\n return undefined;\n } else if (value.expression.kind === 'constant') {\n const constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n return this._calculate(constant, constant, constant, parameters);\n } else {\n return this._calculate(\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1.0), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)),\n value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1.0), parameters)),\n parameters);\n }\n }\n\n _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded {\n const z = parameters.zoom;\n return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};\n }\n\n interpolate(a?: CrossFaded | null): CrossFaded {\n return a;\n }\n}\n\n/**\n * @internal\n * An implementation of `Property` for `heatmap-color` and `line-gradient`. Interpolation is a no-op, and\n * evaluation returns a boolean value in order to indicate its presence, but the real\n * evaluation happens in StyleLayer classes.\n */\n\nexport class ColorRampProperty implements Property {\n specification: StylePropertySpecification;\n\n constructor(specification: StylePropertySpecification) {\n this.specification = specification;\n }\n\n possiblyEvaluate(\n value: PropertyValue,\n parameters: EvaluationParameters,\n canonical?: CanonicalTileID,\n availableImages?: Array\n ): boolean {\n return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages);\n }\n\n interpolate(): boolean { return false; }\n}\n\n/**\n * @internal\n * `Properties` holds objects containing default values for the layout or paint property set of a given\n * layer type. These objects are immutable, and they are used as the prototypes for the `_values` members of\n * `Transitionable`, `Transitioning`, `Layout`, and `PossiblyEvaluated`. This allows these classes to avoid\n * doing work in the common case where a property has no explicit value set and should be considered to take\n * on the default value: using `for (const property of Object.keys(this._values))`, they can iterate over\n * only the _own_ properties of `_values`, skipping repeated calculation of transitions and possible/final\n * evaluations for defaults, the result of which will always be the same.\n */\nexport class Properties {\n properties: Props;\n defaultPropertyValues: {[K in keyof Props]: PropertyValue};\n defaultTransitionablePropertyValues: {[K in keyof Props]: TransitionablePropertyValue};\n defaultTransitioningPropertyValues: {[K in keyof Props]: TransitioningPropertyValue};\n defaultPossiblyEvaluatedValues: {[K in keyof Props]: PossiblyEvaluatedPropertyValue};\n overridableProperties: Array;\n\n constructor(properties: Props) {\n this.properties = properties;\n this.defaultPropertyValues = ({} as any);\n this.defaultTransitionablePropertyValues = ({} as any);\n this.defaultTransitioningPropertyValues = ({} as any);\n this.defaultPossiblyEvaluatedValues = ({} as any);\n this.overridableProperties = ([] as any);\n\n for (const property in properties) {\n const prop = properties[property] as any;\n if (prop.specification.overridable) {\n this.overridableProperties.push(property);\n }\n const defaultPropertyValue = this.defaultPropertyValues[property] =\n new PropertyValue(prop, undefined);\n const defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] =\n new TransitionablePropertyValue(prop);\n this.defaultTransitioningPropertyValues[property] =\n defaultTransitionablePropertyValue.untransitioned();\n this.defaultPossiblyEvaluatedValues[property] =\n defaultPropertyValue.possiblyEvaluate({} as any);\n }\n }\n}\n\nregister('DataDrivenProperty', DataDrivenProperty);\nregister('DataConstantProperty', DataConstantProperty);\nregister('CrossFadedDataDrivenProperty', CrossFadedDataDrivenProperty);\nregister('CrossFadedProperty', CrossFadedProperty);\nregister('ColorRampProperty', ColorRampProperty);\n","import {filterObject} from '../util/util';\n\nimport {latest as styleSpec, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {\n validateStyle,\n validateLayoutProperty,\n validatePaintProperty,\n emitValidationErrors\n} from './validate_style';\nimport {Evented} from '../util/evented';\nimport {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties';\n\nimport type {Bucket} from '../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureFilter, FeatureState,\n LayerSpecification,\n FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {TransitionParameters, PropertyValue} from './properties';\nimport {EvaluationParameters} from './evaluation_parameters';\nimport type {CrossfadeParameters} from './evaluation_parameters';\n\nimport type {Transform} from '../geo/transform';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Map} from '../ui/map';\nimport type {StyleSetterOptions} from './style';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nconst TRANSITION_SUFFIX = '-transition';\n\n/**\n * A base class for style layers\n */\nexport abstract class StyleLayer extends Evented {\n id: string;\n metadata: unknown;\n type: LayerSpecification['type'] | CustomLayerInterface['type'];\n source: string;\n sourceLayer: string;\n minzoom: number;\n maxzoom: number;\n filter: FilterSpecification | void;\n visibility: 'visible' | 'none' | void;\n _crossfadeParameters: CrossfadeParameters;\n\n _unevaluatedLayout: Layout;\n readonly layout: unknown;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n readonly paint: unknown;\n\n _featureFilter: FeatureFilter;\n\n readonly onAdd: ((map: Map) => void);\n readonly onRemove: ((map: Map) => void);\n\n queryRadius?(bucket: Bucket): number;\n queryIntersectsFeature?(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number;\n\n constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{\n layout?: Properties;\n paint?: Properties;\n }>) {\n super();\n\n this.id = layer.id;\n this.type = layer.type;\n this._featureFilter = {filter: () => true, needGeometry: false};\n\n if (layer.type === 'custom') return;\n\n layer = (layer as any as LayerSpecification);\n\n this.metadata = layer.metadata;\n this.minzoom = layer.minzoom;\n this.maxzoom = layer.maxzoom;\n\n if (layer.type !== 'background') {\n this.source = layer.source;\n this.sourceLayer = layer['source-layer'];\n this.filter = layer.filter;\n }\n\n if (properties.layout) {\n this._unevaluatedLayout = new Layout(properties.layout);\n }\n\n if (properties.paint) {\n this._transitionablePaint = new Transitionable(properties.paint);\n\n for (const property in layer.paint) {\n this.setPaintProperty(property, layer.paint[property], {validate: false});\n }\n for (const property in layer.layout) {\n this.setLayoutProperty(property, layer.layout[property], {validate: false});\n }\n\n this._transitioningPaint = this._transitionablePaint.untransitioned();\n //$FlowFixMe\n this.paint = new PossiblyEvaluated(properties.paint);\n }\n }\n\n getCrossfadeParameters() {\n return this._crossfadeParameters;\n }\n\n getLayoutProperty(name: string) {\n if (name === 'visibility') {\n return this.visibility;\n }\n\n return this._unevaluatedLayout.getValue(name);\n }\n\n setLayoutProperty(name: string, value: any, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.layout.${name}`;\n if (this._validate(validateLayoutProperty, key, name, value, options)) {\n return;\n }\n }\n\n if (name === 'visibility') {\n this.visibility = value;\n return;\n }\n\n this._unevaluatedLayout.setValue(name, value);\n }\n\n getPaintProperty(name: string) {\n if (name.endsWith(TRANSITION_SUFFIX)) {\n return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length));\n } else {\n return this._transitionablePaint.getValue(name);\n }\n }\n\n setPaintProperty(name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (value !== null && value !== undefined) {\n const key = `layers.${this.id}.paint.${name}`;\n if (this._validate(validatePaintProperty, key, name, value, options)) {\n return false;\n }\n }\n\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), (value as any) || undefined);\n return false;\n } else {\n const transitionable = this._transitionablePaint._values[name];\n const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven';\n const wasDataDriven = transitionable.value.isDataDriven();\n const oldValue = transitionable.value;\n\n this._transitionablePaint.setValue(name, value);\n this._handleSpecialPaintPropertyUpdate(name);\n\n const newValue = this._transitionablePaint._values[name].value;\n const isDataDriven = newValue.isDataDriven();\n\n // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas\n // so a call to _updateLayer is necessary, and we return true from this function so it gets called in\n // Style#setPaintProperty\n return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name, oldValue, newValue);\n }\n }\n\n _handleSpecialPaintPropertyUpdate(_: string) {\n // No-op; can be overridden by derived classes.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n // No-op; can be overridden by derived classes.\n return false;\n }\n\n isHidden(zoom: number) {\n if (this.minzoom && zoom < this.minzoom) return true;\n if (this.maxzoom && zoom >= this.maxzoom) return true;\n return this.visibility === 'none';\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint);\n }\n\n hasTransition() {\n return this._transitioningPaint.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n if (parameters.getCrossfadeParameters) {\n this._crossfadeParameters = parameters.getCrossfadeParameters();\n }\n\n if (this._unevaluatedLayout) {\n (this as any).layout = this._unevaluatedLayout.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n (this as any).paint = this._transitioningPaint.possiblyEvaluate(parameters, undefined, availableImages);\n }\n\n serialize(): LayerSpecification {\n const output: LayerSpecification = {\n 'id': this.id,\n 'type': this.type as LayerSpecification['type'],\n 'source': this.source,\n 'source-layer': this.sourceLayer,\n 'metadata': this.metadata,\n 'minzoom': this.minzoom,\n 'maxzoom': this.maxzoom,\n 'filter': this.filter as FilterSpecification,\n 'layout': this._unevaluatedLayout && this._unevaluatedLayout.serialize(),\n 'paint': this._transitionablePaint && this._transitionablePaint.serialize()\n };\n\n if (this.visibility) {\n output.layout = output.layout || {};\n output.layout.visibility = this.visibility;\n }\n\n return filterObject(output, (value, key) => {\n return value !== undefined &&\n !(key === 'layout' && !Object.keys(value).length) &&\n !(key === 'paint' && !Object.keys(value).length);\n });\n }\n\n _validate(validate: Function, key: string, name: string, value: unknown, options: StyleSetterOptions = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, {\n key,\n layerType: this.type,\n objectKey: name,\n value,\n styleSpec,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true}\n }));\n }\n\n is3D() {\n return false;\n }\n\n isTileClipped() {\n return false;\n }\n\n hasOffscreenPass() {\n return false;\n }\n\n resize() {\n // noop\n }\n\n isStateDependent() {\n for (const property in (this as any).paint._values) {\n const value = (this as any).paint.get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n\n if ((value.value.kind === 'source' || value.value.kind === 'composite') &&\n value.value.isStateDependent) {\n return true;\n }\n }\n return false;\n }\n}\n","// Note: all \"sizes\" are measured in bytes\n\nimport type {Transferable} from '../types/transferable';\n\n/**\n * @internal\n * A view type size\n */\nconst viewTypes = {\n 'Int8': Int8Array,\n 'Uint8': Uint8Array,\n 'Int16': Int16Array,\n 'Uint16': Uint16Array,\n 'Int32': Int32Array,\n 'Uint32': Uint32Array,\n 'Float32': Float32Array\n};\n\n/**\n * @internal\n * A view type size\n */\nexport type ViewType = keyof typeof viewTypes;\n\n/** @internal */\nclass Struct {\n _pos1: number;\n _pos2: number;\n _pos4: number;\n _pos8: number;\n readonly _structArray: StructArray;\n\n // The following properties are defined on the prototype of sub classes.\n size: number;\n\n /**\n * @param structArray - The StructArray the struct is stored in\n * @param index - The index of the struct in the StructArray.\n */\n constructor(structArray: StructArray, index: number) {\n (this as any)._structArray = structArray;\n this._pos1 = index * this.size;\n this._pos2 = this._pos1 / 2;\n this._pos4 = this._pos1 / 4;\n this._pos8 = this._pos1 / 8;\n }\n}\n\nconst DEFAULT_CAPACITY = 128;\nconst RESIZE_MULTIPLIER = 5;\n\n/**\n * @internal\n * A struct array memeber\n */\nexport type StructArrayMember = {\n name: string;\n type: ViewType;\n components: number;\n offset: number;\n};\n\nexport type StructArrayLayout = {\n members: Array;\n size: number;\n alignment: number;\n};\n\n/**\n * An array that can be desialized\n */\nexport type SerializedStructArray = {\n length: number;\n arrayBuffer: ArrayBuffer;\n};\n\n/**\n * @internal\n * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray`\n * making it behave like an array of typed structs.\n *\n * Conceptually, a StructArray is comprised of elements, i.e., instances of its\n * associated struct type. Each particular struct type, together with an\n * alignment size, determines the memory layout of a StructArray whose elements\n * are of that type. Thus, for each such layout that we need, we have\n * a corresponding StructArrayLayout class, inheriting from StructArray and\n * implementing `emplaceBack()` and `_refreshViews()`.\n *\n * In some cases, where we need to access particular elements of a StructArray,\n * we implement a more specific subclass that inherits from one of the\n * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured\n * object whose properties are proxies into the underlying memory space for the\n * i-th element. This affords the convience of working with (seemingly) plain\n * Javascript objects without the overhead of serializing/deserializing them\n * into ArrayBuffers for efficient web worker transfer.\n */\nabstract class StructArray {\n capacity: number;\n length: number;\n isTransferred: boolean;\n arrayBuffer: ArrayBuffer;\n uint8: Uint8Array;\n\n // The following properties are defined on the prototype.\n members: Array;\n bytesPerElement: number;\n abstract emplaceBack(...v: number[]);\n abstract emplace(i: number, ...v: number[]);\n\n constructor() {\n this.isTransferred = false;\n this.capacity = -1;\n this.resize(0);\n }\n\n /**\n * Serialize a StructArray instance. Serializes both the raw data and the\n * metadata needed to reconstruct the StructArray base class during\n * deserialization.\n */\n static serialize(array: StructArray, transferables?: Array): SerializedStructArray {\n\n array._trim();\n\n if (transferables) {\n array.isTransferred = true;\n transferables.push(array.arrayBuffer);\n }\n\n return {\n length: array.length,\n arrayBuffer: array.arrayBuffer,\n };\n }\n\n static deserialize(input: SerializedStructArray) {\n const structArray = Object.create(this.prototype);\n structArray.arrayBuffer = input.arrayBuffer;\n structArray.length = input.length;\n structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;\n structArray._refreshViews();\n return structArray;\n }\n\n /**\n * Resize the array to discard unused capacity.\n */\n _trim() {\n if (this.length !== this.capacity) {\n this.capacity = this.length;\n this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement);\n this._refreshViews();\n }\n }\n\n /**\n * Resets the length of the array to 0 without de-allocating capcacity.\n */\n clear() {\n this.length = 0;\n }\n\n /**\n * Resize the array.\n * If `n` is greater than the current length then additional elements with undefined values are added.\n * If `n` is less than the current length then the array will be reduced to the first `n` elements.\n * @param n - The new size of the array.\n */\n resize(n: number) {\n this.reserve(n);\n this.length = n;\n }\n\n /**\n * Indicate a planned increase in size, so that any necessary allocation may\n * be done once, ahead of time.\n * @param n - The expected size of the array.\n */\n reserve(n: number) {\n if (n > this.capacity) {\n this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY);\n this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);\n\n const oldUint8Array = this.uint8;\n this._refreshViews();\n if (oldUint8Array) this.uint8.set(oldUint8Array);\n }\n }\n\n /**\n * Create TypedArray views for the current ArrayBuffer.\n */\n _refreshViews() {\n throw new Error('_refreshViews() must be implemented by each concrete StructArray layout');\n }\n}\n\n/**\n * Given a list of member fields, create a full StructArrayLayout, in\n * particular calculating the correct byte offset for each field. This data\n * is used at build time to generate StructArrayLayout_*#emplaceBack() and\n * other accessors, and at runtime for binding vertex buffer attributes.\n */\nfunction createLayout(\n members: Array<{\n name: string;\n type: ViewType;\n readonly components?: number;\n }>,\n alignment: number = 1\n): StructArrayLayout {\n\n let offset = 0;\n let maxSize = 0;\n const layoutMembers = members.map((member) => {\n const typeSize = sizeOf(member.type);\n const memberOffset = offset = align(offset, Math.max(alignment, typeSize));\n const components = member.components || 1;\n\n maxSize = Math.max(maxSize, typeSize);\n offset += typeSize * components;\n\n return {\n name: member.name,\n type: member.type,\n components,\n offset: memberOffset,\n };\n });\n\n const size = align(offset, Math.max(maxSize, alignment));\n\n return {\n members: layoutMembers,\n size,\n alignment\n };\n}\n\nfunction sizeOf(type: ViewType): number {\n return viewTypes[type].BYTES_PER_ELEMENT;\n}\n\nfunction align(offset: number, size: number): number {\n return Math.ceil(offset / size) * size;\n}\n\nexport {StructArray, Struct, viewTypes, createLayout};\n","// This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`.\n\nimport {Struct, StructArray} from '../util/struct_array';\nimport {register} from '../util/web_worker_transfer';\nimport Point from '@mapbox/point-geometry';\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n *\n */\nclass StructArrayLayout2i4 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2i4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2i4', StructArrayLayout2i4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[3]\n *\n */\nclass StructArrayLayout3i6 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3i6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3i6', StructArrayLayout3i6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n *\n */\nclass StructArrayLayout4i8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o2 = i * 4;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4i8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout4i8', StructArrayLayout4i8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[4]\n *\n */\nclass StructArrayLayout2i4i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i4i12', StructArrayLayout2i4i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint8[4]\n *\n */\nclass StructArrayLayout2i4ub8 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 4;\n const o1 = i * 8;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint8[o1 + 4] = v2;\n this.uint8[o1 + 5] = v3;\n this.uint8[o1 + 6] = v4;\n this.uint8[o1 + 7] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i4ub8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n *\n */\nclass StructArrayLayout2f8 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o4 = i * 2;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2f8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout2f8', StructArrayLayout2f8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[10]\n *\n */\nclass StructArrayLayout10ui20 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {\n const o2 = i * 10;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n return i;\n }\n}\n\nStructArrayLayout10ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout10ui20', StructArrayLayout10ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[4]\n * [8]: Uint16[4]\n * [16]: Int16[4]\n *\n */\nclass StructArrayLayout4i4ui4i24 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) {\n const o2 = i * 12;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.uint16[o2 + 4] = v4;\n this.uint16[o2 + 5] = v5;\n this.uint16[o2 + 6] = v6;\n this.uint16[o2 + 7] = v7;\n this.int16[o2 + 8] = v8;\n this.int16[o2 + 9] = v9;\n this.int16[o2 + 10] = v10;\n this.int16[o2 + 11] = v11;\n return i;\n }\n}\n\nStructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24;\nregister('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[3]\n *\n */\nclass StructArrayLayout3f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 3;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout3f12', StructArrayLayout3f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n *\n */\nclass StructArrayLayout1ul4 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.uint32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ul4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1ul4', StructArrayLayout1ul4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[6]\n * [12]: Uint32[1]\n * [16]: Uint16[2]\n *\n */\nclass StructArrayLayout6i1ul2ui20 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) {\n const o2 = i * 10;\n const o4 = i * 5;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.uint32[o4 + 3] = v6;\n this.uint16[o2 + 8] = v7;\n this.uint16[o2 + 9] = v8;\n return i;\n }\n}\n\nStructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20;\nregister('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Int16[2]\n * [8]: Int16[2]\n *\n */\nclass StructArrayLayout2i2i2i12 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) {\n const o2 = i * 6;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n return i;\n }\n}\n\nStructArrayLayout2i2i2i12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[2]\n * [8]: Float32[1]\n * [12]: Int16[2]\n *\n */\nclass StructArrayLayout2f1f2i16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n int16: Int16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number) {\n const o4 = i * 4;\n const o2 = i * 8;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.int16[o2 + 6] = v3;\n this.int16[o2 + 7] = v4;\n return i;\n }\n}\n\nStructArrayLayout2f1f2i16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint8[2]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout2ub2f12 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o1 = i * 12;\n const o4 = i * 3;\n this.uint8[o1 + 0] = v0;\n this.uint8[o1 + 1] = v1;\n this.float32[o4 + 1] = v2;\n this.float32[o4 + 2] = v3;\n return i;\n }\n}\n\nStructArrayLayout2ub2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[3]\n *\n */\nclass StructArrayLayout3ui6 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout3ui6.prototype.bytesPerElement = 6;\nregister('StructArrayLayout3ui6', StructArrayLayout3ui6);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[2]\n * [4]: Uint16[2]\n * [8]: Uint32[3]\n * [20]: Uint16[3]\n * [28]: Float32[2]\n * [36]: Uint8[3]\n * [40]: Uint32[1]\n * [44]: Int16[1]\n *\n */\nclass StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) {\n const o2 = i * 24;\n const o4 = i * 12;\n const o1 = i * 48;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.uint16[o2 + 2] = v2;\n this.uint16[o2 + 3] = v3;\n this.uint32[o4 + 2] = v4;\n this.uint32[o4 + 3] = v5;\n this.uint32[o4 + 4] = v6;\n this.uint16[o2 + 10] = v7;\n this.uint16[o2 + 11] = v8;\n this.uint16[o2 + 12] = v9;\n this.float32[o4 + 7] = v10;\n this.float32[o4 + 8] = v11;\n this.uint8[o1 + 36] = v12;\n this.uint8[o1 + 37] = v13;\n this.uint8[o1 + 38] = v14;\n this.uint32[o4 + 10] = v15;\n this.int16[o2 + 22] = v16;\n return i;\n }\n}\n\nStructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48;\nregister('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Int16[8]\n * [16]: Uint16[15]\n * [48]: Uint32[1]\n * [52]: Float32[2]\n * [60]: Uint16[2]\n *\n */\nclass StructArrayLayout8i15ui1ul2f2ui64 extends StructArray {\n uint8: Uint8Array;\n int16: Int16Array;\n uint16: Uint16Array;\n uint32: Uint32Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.int16 = new Int16Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {\n const o2 = i * 32;\n const o4 = i * 16;\n this.int16[o2 + 0] = v0;\n this.int16[o2 + 1] = v1;\n this.int16[o2 + 2] = v2;\n this.int16[o2 + 3] = v3;\n this.int16[o2 + 4] = v4;\n this.int16[o2 + 5] = v5;\n this.int16[o2 + 6] = v6;\n this.int16[o2 + 7] = v7;\n this.uint16[o2 + 8] = v8;\n this.uint16[o2 + 9] = v9;\n this.uint16[o2 + 10] = v10;\n this.uint16[o2 + 11] = v11;\n this.uint16[o2 + 12] = v12;\n this.uint16[o2 + 13] = v13;\n this.uint16[o2 + 14] = v14;\n this.uint16[o2 + 15] = v15;\n this.uint16[o2 + 16] = v16;\n this.uint16[o2 + 17] = v17;\n this.uint16[o2 + 18] = v18;\n this.uint16[o2 + 19] = v19;\n this.uint16[o2 + 20] = v20;\n this.uint16[o2 + 21] = v21;\n this.uint16[o2 + 22] = v22;\n this.uint32[o4 + 12] = v23;\n this.float32[o4 + 13] = v24;\n this.float32[o4 + 14] = v25;\n this.uint16[o2 + 30] = v26;\n this.uint16[o2 + 31] = v27;\n return i;\n }\n}\n\nStructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64;\nregister('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[1]\n *\n */\nclass StructArrayLayout1f4 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o4 = i * 1;\n this.float32[o4 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1f4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout1f4', StructArrayLayout1f4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n * [4]: Float32[2]\n *\n */\nclass StructArrayLayout1ui2f12 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o2 = i * 6;\n const o4 = i * 3;\n this.uint16[o2 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ui2f12.prototype.bytesPerElement = 12;\nregister('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint32[1]\n * [4]: Uint16[2]\n *\n */\nclass StructArrayLayout1ul2ui8 extends StructArray {\n uint8: Uint8Array;\n uint32: Uint32Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint32 = new Uint32Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number) {\n const o4 = i * 2;\n const o2 = i * 4;\n this.uint32[o4 + 0] = v0;\n this.uint16[o2 + 2] = v1;\n this.uint16[o2 + 3] = v2;\n return i;\n }\n}\n\nStructArrayLayout1ul2ui8.prototype.bytesPerElement = 8;\nregister('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[2]\n *\n */\nclass StructArrayLayout2ui4 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1);\n }\n\n public emplace(i: number, v0: number, v1: number) {\n const o2 = i * 2;\n this.uint16[o2 + 0] = v0;\n this.uint16[o2 + 1] = v1;\n return i;\n }\n}\n\nStructArrayLayout2ui4.prototype.bytesPerElement = 4;\nregister('StructArrayLayout2ui4', StructArrayLayout2ui4);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Uint16[1]\n *\n */\nclass StructArrayLayout1ui2 extends StructArray {\n uint8: Uint8Array;\n uint16: Uint16Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.uint16 = new Uint16Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0);\n }\n\n public emplace(i: number, v0: number) {\n const o2 = i * 1;\n this.uint16[o2 + 0] = v0;\n return i;\n }\n}\n\nStructArrayLayout1ui2.prototype.bytesPerElement = 2;\nregister('StructArrayLayout1ui2', StructArrayLayout1ui2);\n\n/**\n * @internal\n * Implementation of the StructArray layout:\n * [0]: Float32[4]\n *\n */\nclass StructArrayLayout4f16 extends StructArray {\n uint8: Uint8Array;\n float32: Float32Array;\n\n _refreshViews() {\n this.uint8 = new Uint8Array(this.arrayBuffer);\n this.float32 = new Float32Array(this.arrayBuffer);\n }\n\n public emplaceBack(v0: number, v1: number, v2: number, v3: number) {\n const i = this.length;\n this.resize(i + 1);\n return this.emplace(i, v0, v1, v2, v3);\n }\n\n public emplace(i: number, v0: number, v1: number, v2: number, v3: number) {\n const o4 = i * 4;\n this.float32[o4 + 0] = v0;\n this.float32[o4 + 1] = v1;\n this.float32[o4 + 2] = v2;\n this.float32[o4 + 3] = v3;\n return i;\n }\n}\n\nStructArrayLayout4f16.prototype.bytesPerElement = 16;\nregister('StructArrayLayout4f16', StructArrayLayout4f16);\n\n/** @internal */\nclass CollisionBoxStruct extends Struct {\n _structArray: CollisionBoxArray;\n get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorPointY() { return this._structArray.int16[this._pos2 + 1]; }\n get x1() { return this._structArray.int16[this._pos2 + 2]; }\n get y1() { return this._structArray.int16[this._pos2 + 3]; }\n get x2() { return this._structArray.int16[this._pos2 + 4]; }\n get y2() { return this._structArray.int16[this._pos2 + 5]; }\n get featureIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 8]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); }\n}\n\nCollisionBoxStruct.prototype.size = 20;\n\nexport type CollisionBox = CollisionBoxStruct;\n\n/** @internal */\nexport class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {\n /**\n * Return the CollisionBoxStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): CollisionBoxStruct {\n return new CollisionBoxStruct(this, index);\n }\n}\n\nregister('CollisionBoxArray', CollisionBoxArray);\n\n/** @internal */\nclass PlacedSymbolStruct extends Struct {\n _structArray: PlacedSymbolArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get glyphStartIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get numGlyphs() { return this._structArray.uint16[this._pos2 + 3]; }\n get vertexStartIndex() { return this._structArray.uint32[this._pos4 + 2]; }\n get lineStartIndex() { return this._structArray.uint32[this._pos4 + 3]; }\n get lineLength() { return this._structArray.uint32[this._pos4 + 4]; }\n get segment() { return this._structArray.uint16[this._pos2 + 10]; }\n get lowerSize() { return this._structArray.uint16[this._pos2 + 11]; }\n get upperSize() { return this._structArray.uint16[this._pos2 + 12]; }\n get lineOffsetX() { return this._structArray.float32[this._pos4 + 7]; }\n get lineOffsetY() { return this._structArray.float32[this._pos4 + 8]; }\n get writingMode() { return this._structArray.uint8[this._pos1 + 36]; }\n get placedOrientation() { return this._structArray.uint8[this._pos1 + 37]; }\n set placedOrientation(x: number) { this._structArray.uint8[this._pos1 + 37] = x; }\n get hidden() { return this._structArray.uint8[this._pos1 + 38]; }\n set hidden(x: number) { this._structArray.uint8[this._pos1 + 38] = x; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 10]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 10] = x; }\n get associatedIconIndex() { return this._structArray.int16[this._pos2 + 22]; }\n}\n\nPlacedSymbolStruct.prototype.size = 48;\n\nexport type PlacedSymbol = PlacedSymbolStruct;\n\n/** @internal */\nexport class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 {\n /**\n * Return the PlacedSymbolStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): PlacedSymbolStruct {\n return new PlacedSymbolStruct(this, index);\n }\n}\n\nregister('PlacedSymbolArray', PlacedSymbolArray);\n\n/** @internal */\nclass SymbolInstanceStruct extends Struct {\n _structArray: SymbolInstanceArray;\n get anchorX() { return this._structArray.int16[this._pos2 + 0]; }\n get anchorY() { return this._structArray.int16[this._pos2 + 1]; }\n get rightJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 2]; }\n get centerJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 3]; }\n get leftJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 4]; }\n get verticalPlacedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 5]; }\n get placedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 6]; }\n get verticalPlacedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 7]; }\n get key() { return this._structArray.uint16[this._pos2 + 8]; }\n get textBoxStartIndex() { return this._structArray.uint16[this._pos2 + 9]; }\n get textBoxEndIndex() { return this._structArray.uint16[this._pos2 + 10]; }\n get verticalTextBoxStartIndex() { return this._structArray.uint16[this._pos2 + 11]; }\n get verticalTextBoxEndIndex() { return this._structArray.uint16[this._pos2 + 12]; }\n get iconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 13]; }\n get iconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 14]; }\n get verticalIconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 15]; }\n get verticalIconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 16]; }\n get featureIndex() { return this._structArray.uint16[this._pos2 + 17]; }\n get numHorizontalGlyphVertices() { return this._structArray.uint16[this._pos2 + 18]; }\n get numVerticalGlyphVertices() { return this._structArray.uint16[this._pos2 + 19]; }\n get numIconVertices() { return this._structArray.uint16[this._pos2 + 20]; }\n get numVerticalIconVertices() { return this._structArray.uint16[this._pos2 + 21]; }\n get useRuntimeCollisionCircles() { return this._structArray.uint16[this._pos2 + 22]; }\n get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; }\n set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 12] = x; }\n get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; }\n get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; }\n get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; }\n get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; }\n}\n\nSymbolInstanceStruct.prototype.size = 64;\n\nexport type SymbolInstance = SymbolInstanceStruct;\n\n/** @internal */\nexport class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 {\n /**\n * Return the SymbolInstanceStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): SymbolInstanceStruct {\n return new SymbolInstanceStruct(this, index);\n }\n}\n\nregister('SymbolInstanceArray', SymbolInstanceArray);\n\n/** @internal */\nexport class GlyphOffsetArray extends StructArrayLayout1f4 {\n getoffsetX(index: number) { return this.float32[index * 1 + 0]; }\n}\n\nregister('GlyphOffsetArray', GlyphOffsetArray);\n\n/** @internal */\nexport class SymbolLineVertexArray extends StructArrayLayout3i6 {\n getx(index: number) { return this.int16[index * 3 + 0]; }\n gety(index: number) { return this.int16[index * 3 + 1]; }\n gettileUnitDistanceFromAnchor(index: number) { return this.int16[index * 3 + 2]; }\n}\n\nregister('SymbolLineVertexArray', SymbolLineVertexArray);\n\n/** @internal */\nclass TextAnchorOffsetStruct extends Struct {\n _structArray: TextAnchorOffsetArray;\n get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; }\n get textOffset0() { return this._structArray.float32[this._pos4 + 1]; }\n get textOffset1() { return this._structArray.float32[this._pos4 + 2]; }\n}\n\nTextAnchorOffsetStruct.prototype.size = 12;\n\nexport type TextAnchorOffset = TextAnchorOffsetStruct;\n\n/** @internal */\nexport class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 {\n /**\n * Return the TextAnchorOffsetStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): TextAnchorOffsetStruct {\n return new TextAnchorOffsetStruct(this, index);\n }\n}\n\nregister('TextAnchorOffsetArray', TextAnchorOffsetArray);\n\n/** @internal */\nclass FeatureIndexStruct extends Struct {\n _structArray: FeatureIndexArray;\n get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; }\n get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 2]; }\n get bucketIndex() { return this._structArray.uint16[this._pos2 + 3]; }\n}\n\nFeatureIndexStruct.prototype.size = 8;\n\nexport type FeatureIndex = FeatureIndexStruct;\n\n/** @internal */\nexport class FeatureIndexArray extends StructArrayLayout1ul2ui8 {\n /**\n * Return the FeatureIndexStruct at the given location in the array.\n * @param index The index of the element.\n */\n get(index: number): FeatureIndexStruct {\n return new FeatureIndexStruct(this, index);\n }\n}\n\nregister('FeatureIndexArray', FeatureIndexArray);\n\nexport class PosArray extends StructArrayLayout2i4 {}\nexport class Pos3dArray extends StructArrayLayout3i6 {}\nexport class RasterBoundsArray extends StructArrayLayout4i8 {}\nexport class CircleLayoutArray extends StructArrayLayout2i4 {}\nexport class FillLayoutArray extends StructArrayLayout2i4 {}\nexport class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 {}\nexport class HeatmapLayoutArray extends StructArrayLayout2i4 {}\nexport class LineLayoutArray extends StructArrayLayout2i4ub8 {}\nexport class LineExtLayoutArray extends StructArrayLayout2f8 {}\nexport class PatternLayoutArray extends StructArrayLayout10ui20 {}\nexport class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 {}\nexport class SymbolDynamicLayoutArray extends StructArrayLayout3f12 {}\nexport class SymbolOpacityArray extends StructArrayLayout1ul4 {}\nexport class CollisionBoxLayoutArray extends StructArrayLayout2i2i2i12 {}\nexport class CollisionCircleLayoutArray extends StructArrayLayout2f1f2i16 {}\nexport class CollisionVertexArray extends StructArrayLayout2ub2f12 {}\nexport class QuadTriangleArray extends StructArrayLayout3ui6 {}\nexport class TriangleIndexArray extends StructArrayLayout3ui6 {}\nexport class LineIndexArray extends StructArrayLayout2ui4 {}\nexport class LineStripIndexArray extends StructArrayLayout1ui2 {}\nexport {\n StructArrayLayout2i4,\n StructArrayLayout3i6,\n StructArrayLayout4i8,\n StructArrayLayout2i4i12,\n StructArrayLayout2i4ub8,\n StructArrayLayout2f8,\n StructArrayLayout10ui20,\n StructArrayLayout4i4ui4i24,\n StructArrayLayout3f12,\n StructArrayLayout1ul4,\n StructArrayLayout6i1ul2ui20,\n StructArrayLayout2i2i2i12,\n StructArrayLayout2f1f2i16,\n StructArrayLayout2ub2f12,\n StructArrayLayout3ui6,\n StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48,\n StructArrayLayout8i15ui1ul2f2ui64,\n StructArrayLayout1f4,\n StructArrayLayout1ui2f12,\n StructArrayLayout1ul2ui8,\n StructArrayLayout2ui4,\n StructArrayLayout1ui2,\n StructArrayLayout4f16\n};\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","import {warnOnce} from '../util/util';\n\nimport {register} from '../util/web_worker_transfer';\n\nimport type {VertexArrayObject} from '../render/vertex_array_object';\nimport type {StructArray} from '../util/struct_array';\n\n/**\n * @internal\n * A single segment of a vector\n */\nexport type Segment = {\n sortKey?: number;\n vertexOffset: number;\n primitiveOffset: number;\n vertexLength: number;\n primitiveLength: number;\n vaos: {[_: string]: VertexArrayObject};\n};\n\n/**\n * @internal\n * Used for calculations on vector segments\n */\nexport class SegmentVector {\n static MAX_VERTEX_ARRAY_LENGTH: number;\n segments: Array;\n\n constructor(segments: Array = []) {\n this.segments = segments;\n }\n\n prepareSegment(\n numVertices: number,\n layoutVertexArray: StructArray,\n indexArray: StructArray,\n sortKey?: number\n ): Segment {\n let segment: Segment = this.segments[this.segments.length - 1];\n if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`);\n if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) {\n segment = ({\n vertexOffset: layoutVertexArray.length,\n primitiveOffset: indexArray.length,\n vertexLength: 0,\n primitiveLength: 0\n } as any);\n if (sortKey !== undefined) segment.sortKey = sortKey;\n this.segments.push(segment);\n }\n return segment;\n }\n\n get() {\n return this.segments;\n }\n\n destroy() {\n for (const segment of this.segments) {\n for (const k in segment.vaos) {\n segment.vaos[k].destroy();\n }\n }\n }\n\n static simpleSegment(\n vertexOffset: number,\n primitiveOffset: number,\n vertexLength: number,\n primitiveLength: number\n ): SegmentVector {\n return new SegmentVector([{\n vertexOffset,\n primitiveOffset,\n vertexLength,\n primitiveLength,\n vaos: {},\n sortKey: 0\n }]);\n }\n}\n\n/**\n * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit\n * addressing of vertex buffers.\n */\nSegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1;\n\nregister('SegmentVector', SegmentVector);\n","import {clamp} from '../util/util';\n\n/**\n * Packs two numbers, interpreted as 8-bit unsigned integers, into a single\n * float. Unpack them in the shader using the `unpack_float()` function,\n * defined in _prelude.vertex.glsl\n */\nexport function packUint8ToFloat(a: number, b: number) {\n // coerce a and b to 8-bit ints\n a = clamp(Math.floor(a), 0, 255);\n b = clamp(Math.floor(b), 0, 255);\n return 256 * a + b;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const patternAttributes = createLayout([\n // [tl.x, tl.y, br.x, br.y]\n {name: 'a_pattern_from', components: 4, type: 'Uint16'},\n {name: 'a_pattern_to', components: 4, type: 'Uint16'},\n {name: 'a_pixel_ratio_from', components: 1, type: 'Uint16'},\n {name: 'a_pixel_ratio_to', components: 1, type: 'Uint16'},\n]);\n","/**\n * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} key ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash \n */\n\nfunction murmurhash3_32_gc(key, seed) {\n\tvar remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;\n\t\n\tremainder = key.length & 3; // key.length % 4\n\tbytes = key.length - remainder;\n\th1 = seed;\n\tc1 = 0xcc9e2d51;\n\tc2 = 0x1b873593;\n\ti = 0;\n\t\n\twhile (i < bytes) {\n\t \tk1 = \n\t \t ((key.charCodeAt(i) & 0xff)) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 8) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 16) |\n\t \t ((key.charCodeAt(++i) & 0xff) << 24);\n\t\t++i;\n\t\t\n\t\tk1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;\n\n\t\th1 ^= k1;\n h1 = (h1 << 13) | (h1 >>> 19);\n\t\th1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;\n\t\th1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));\n\t}\n\t\n\tk1 = 0;\n\t\n\tswitch (remainder) {\n\t\tcase 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;\n\t\tcase 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;\n\t\tcase 1: k1 ^= (key.charCodeAt(i) & 0xff);\n\t\t\n\t\tk1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;\n\t\tk1 = (k1 << 15) | (k1 >>> 17);\n\t\tk1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;\n\t\th1 ^= k1;\n\t}\n\t\n\th1 ^= key.length;\n\n\th1 ^= h1 >>> 16;\n\th1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;\n\th1 ^= h1 >>> 13;\n\th1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;\n\th1 ^= h1 >>> 16;\n\n\treturn h1 >>> 0;\n}\n\nif(typeof module !== \"undefined\") {\n module.exports = murmurhash3_32_gc\n}","/**\n * JS Implementation of MurmurHash2\n * \n * @author Gary Court\n * @see http://github.com/garycourt/murmurhash-js\n * @author Austin Appleby\n * @see http://sites.google.com/site/murmurhash/\n * \n * @param {string} str ASCII only\n * @param {number} seed Positive integer only\n * @return {number} 32-bit positive integer hash\n */\n\nfunction murmurhash2_32_gc(str, seed) {\n var\n l = str.length,\n h = seed ^ l,\n i = 0,\n k;\n \n while (l >= 4) {\n \tk = \n \t ((str.charCodeAt(i) & 0xff)) |\n \t ((str.charCodeAt(++i) & 0xff) << 8) |\n \t ((str.charCodeAt(++i) & 0xff) << 16) |\n \t ((str.charCodeAt(++i) & 0xff) << 24);\n \n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n k ^= k >>> 24;\n k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\n\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;\n\n l -= 4;\n ++i;\n }\n \n switch (l) {\n case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n case 1: h ^= (str.charCodeAt(i) & 0xff);\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n }\n\n h ^= h >>> 13;\n h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n h ^= h >>> 15;\n\n return h >>> 0;\n}\n\nif(typeof module !== undefined) {\n module.exports = murmurhash2_32_gc\n}\n","var murmur3 = require(\"./murmurhash3_gc.js\")\nvar murmur2 = require(\"./murmurhash2_gc.js\")\n\nmodule.exports = murmur3\nmodule.exports.murmur3 = murmur3\nmodule.exports.murmur2 = murmur2\n","import murmur3 from 'murmurhash-js';\nimport {register} from '../util/web_worker_transfer';\n\ntype SerializedFeaturePositionMap = {\n ids: Float64Array;\n positions: Uint32Array;\n};\n\ntype FeaturePosition = {\n index: number;\n start: number;\n end: number;\n};\n\n// A transferable data structure that maps feature ids to their indices and buffer offsets\nexport class FeaturePositionMap {\n ids: Array;\n positions: Array;\n indexed: boolean;\n\n constructor() {\n this.ids = [];\n this.positions = [];\n this.indexed = false;\n }\n\n add(id: unknown, index: number, start: number, end: number) {\n this.ids.push(getNumericId(id));\n this.positions.push(index, start, end);\n }\n\n getPositions(id: unknown): Array {\n if (!this.indexed) throw new Error('Trying to get index, but feature positions are not indexed');\n\n const intId = getNumericId(id);\n\n // binary search for the first occurrence of id in this.ids;\n // relies on ids/positions being sorted by id, which happens in serialization\n let i = 0;\n let j = this.ids.length - 1;\n while (i < j) {\n const m = (i + j) >> 1;\n if (this.ids[m] >= intId) {\n j = m;\n } else {\n i = m + 1;\n }\n }\n const positions = [];\n while (this.ids[i] === intId) {\n const index = this.positions[3 * i];\n const start = this.positions[3 * i + 1];\n const end = this.positions[3 * i + 2];\n positions.push({index, start, end});\n i++;\n }\n return positions;\n }\n\n static serialize(map: FeaturePositionMap, transferables: Array): SerializedFeaturePositionMap {\n const ids = new Float64Array(map.ids);\n const positions = new Uint32Array(map.positions);\n\n sort(ids, positions, 0, ids.length - 1);\n\n if (transferables) {\n transferables.push(ids.buffer, positions.buffer);\n }\n\n return {ids, positions};\n }\n\n static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap {\n const map = new FeaturePositionMap();\n // after transferring, we only use these arrays statically (no pushes),\n // so TypedArray vs Array distinction that flow points out doesn't matter\n map.ids = (obj.ids as any);\n map.positions = (obj.positions as any);\n map.indexed = true;\n return map;\n }\n}\n\nfunction getNumericId(value: unknown) {\n const numValue = +value;\n if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) {\n return numValue;\n }\n return murmur3(String(value));\n}\n\n// custom quicksort that sorts ids, indices and offsets together (by ids)\n// uses Hoare partitioning & manual tail call optimization to avoid worst case scenarios\nfunction sort(ids, positions, left, right) {\n while (left < right) {\n const pivot = ids[(left + right) >> 1];\n let i = left - 1;\n let j = right + 1;\n\n while (true) {\n do i++; while (ids[i] < pivot);\n do j--; while (ids[j] > pivot);\n if (i >= j) break;\n swap(ids, i, j);\n swap(positions, 3 * i, 3 * j);\n swap(positions, 3 * i + 1, 3 * j + 1);\n swap(positions, 3 * i + 2, 3 * j + 2);\n }\n\n if (j - left < right - j) {\n sort(ids, positions, left, j);\n left = j + 1;\n } else {\n sort(ids, positions, j + 1, right);\n right = j;\n }\n }\n}\n\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nregister('FeaturePositionMap', FeaturePositionMap);\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Context} from '../gl/context';\nimport {mat4, vec2, vec3, vec4} from 'gl-matrix';\n\ntype $ObjMap any> = {\n [K in keyof T]: F extends (v: T[K]) => infer R ? R : never;\n};\n\nexport type UniformValues = $ObjMap(u: Uniform) => V>;\nexport type UniformLocations = {[_: string]: WebGLUniformLocation};\n\n/**\n * @internal\n * A base uniform abstract class\n */\nabstract class Uniform {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n location: WebGLUniformLocation;\n current: T;\n\n constructor(context: Context, location: WebGLUniformLocation) {\n this.gl = context.gl;\n this.location = location;\n }\n\n abstract set(v: T): void;\n}\n\nclass Uniform1i extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1i(this.location, v);\n }\n }\n}\n\nclass Uniform1f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = 0;\n }\n\n set(v: number): void {\n if (this.current !== v) {\n this.current = v;\n this.gl.uniform1f(this.location, v);\n }\n }\n}\n\nclass Uniform2f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0];\n }\n\n set(v: vec2): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1]) {\n this.current = v;\n this.gl.uniform2f(this.location, v[0], v[1]);\n }\n }\n}\n\nclass Uniform3f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0];\n }\n\n set(v: vec3): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) {\n this.current = v;\n this.gl.uniform3f(this.location, v[0], v[1], v[2]);\n }\n }\n}\n\nclass Uniform4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = [0, 0, 0, 0];\n }\n\n set(v: vec4): void {\n if (v[0] !== this.current[0] || v[1] !== this.current[1] ||\n v[2] !== this.current[2] || v[3] !== this.current[3]) {\n this.current = v;\n this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]);\n }\n }\n}\n\nclass UniformColor extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = Color.transparent;\n }\n\n set(v: Color): void {\n if (v.r !== this.current.r || v.g !== this.current.g ||\n v.b !== this.current.b || v.a !== this.current.a) {\n this.current = v;\n this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a);\n }\n }\n}\n\nconst emptyMat4 = new Float32Array(16) as mat4;\nclass UniformMatrix4f extends Uniform {\n constructor(context: Context, location: WebGLUniformLocation) {\n super(context, location);\n this.current = emptyMat4;\n }\n\n set(v: mat4): void {\n // The vast majority of matrix comparisons that will trip this set\n // happen at i=12 or i=0, so we check those first to avoid lots of\n // unnecessary iteration:\n if (v[12] !== this.current[12] || v[0] !== this.current[0]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n return;\n }\n for (let i = 1; i < 16; i++) {\n if (v[i] !== this.current[i]) {\n this.current = v;\n this.gl.uniformMatrix4fv(this.location, false, v);\n break;\n }\n }\n }\n}\n\nexport {\n Uniform,\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n Uniform4f,\n UniformColor,\n UniformMatrix4f\n};\n\n/**\n * @internal\n * A uniform bindings\n */\nexport type UniformBindings = {[_: string]: Uniform};\n","import {packUint8ToFloat} from '../shaders/encode_attribute';\nimport {Color, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {register} from '../util/web_worker_transfer';\nimport {PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types.g';\nimport {clamp} from '../util/util';\nimport {patternAttributes} from './bucket/pattern_attributes';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {FeaturePositionMap} from './feature_position_map';\nimport {Uniform, Uniform1f, UniformColor, Uniform4f} from '../render/uniform_binding';\n\nimport type {UniformLocations} from '../render/uniform_binding';\n\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Context} from '../gl/context';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {CrossfadeParameters} from '../style/evaluation_parameters';\nimport type {StructArray, StructArrayMember} from '../util/struct_array';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {\n Feature,\n FeatureState,\n GlobalProperties,\n SourceExpression,\n CompositeExpression,\n FormattedSection\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureStates} from '../source/source_state';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type BinderUniform = {\n name: string;\n property: string;\n binding: Uniform;\n};\n\nfunction packColor(color: Color): [number, number] {\n return [\n packUint8ToFloat(255 * color.r, 255 * color.g),\n packUint8ToFloat(255 * color.b, 255 * color.a)\n ];\n}\n\n/**\n * `Binder` is the interface definition for the strategies for constructing,\n * uploading, and binding paint property data as GLSL attributes. Most style-\n * spec properties have a 1:1 relationship to shader attribute/uniforms, but\n * some require multiple values per feature to be passed to the GPU, and in\n * those cases we bind multiple attributes/uniforms.\n *\n * It has three implementations, one for each of the three strategies we use:\n *\n * * For _constant_ properties -- those whose value is a constant, or the constant\n * result of evaluating a camera expression at a particular camera position -- we\n * don't need a vertex attribute buffer, and instead use a uniform.\n * * For data expressions, we use a vertex buffer with a single attribute value,\n * the evaluated result of the source function for the given feature.\n * * For composite expressions, we use a vertex buffer with two attributes: min and\n * max values covering the range of zooms at which we expect the tile to be\n * displayed. These values are calculated by evaluating the composite expression for\n * the given feature at strategically chosen zoom levels. In addition to this\n * attribute data, we also use a uniform value which the shader uses to interpolate\n * between the min and max value at the final displayed zoom level. The use of a\n * uniform allows us to cheaply update the value on every frame.\n *\n * Note that the shader source varies depending on whether we're using a uniform or\n * attribute. We dynamically compile shaders at runtime to accommodate this.\n */\ninterface AttributeBinder {\n populatePaintArray(\n length: number,\n feature: Feature,\n imagePositions: {[_: string]: ImagePosition},\n canonical?: CanonicalTileID,\n formattedSection?: FormattedSection\n ): void;\n updatePaintArray(\n start: number,\n length: number,\n feature: Feature,\n featureState: FeatureState,\n imagePositions: {[_: string]: ImagePosition}\n ): void;\n upload(a: Context): void;\n destroy(): void;\n}\n\ninterface UniformBinder {\n uniformNames: Array;\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue,\n uniformName: string\n ): void;\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial>;\n}\n\nclass ConstantBinder implements UniformBinder {\n value: unknown;\n type: string;\n uniformNames: Array;\n\n constructor(value: unknown, names: Array, type: string) {\n this.value = value;\n this.uniformNames = names.map(name => `u_${name}`);\n this.type = type;\n }\n\n setUniform(\n uniform: Uniform,\n globals: GlobalProperties,\n currentValue: PossiblyEvaluatedPropertyValue\n ): void {\n uniform.set(currentValue.constantOr(this.value));\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Partial> {\n return (this.type === 'color') ?\n new UniformColor(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedConstantBinder implements UniformBinder {\n uniformNames: Array;\n patternFrom: Array;\n patternTo: Array;\n pixelRatioFrom: number;\n pixelRatioTo: number;\n\n constructor(value: unknown, names: Array) {\n this.uniformNames = names.map(name => `u_${name}`);\n this.patternFrom = null;\n this.patternTo = null;\n this.pixelRatioFrom = 1.0;\n this.pixelRatioTo = 1.0;\n }\n\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n this.pixelRatioFrom = posFrom.pixelRatio;\n this.pixelRatioTo = posTo.pixelRatio;\n this.patternFrom = posFrom.tlbr;\n this.patternTo = posTo.tlbr;\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties, currentValue: PossiblyEvaluatedPropertyValue, uniformName: string) {\n const pos =\n uniformName === 'u_pattern_to' ? this.patternTo :\n uniformName === 'u_pattern_from' ? this.patternFrom :\n uniformName === 'u_pixel_ratio_to' ? this.pixelRatioTo :\n uniformName === 'u_pixel_ratio_from' ? this.pixelRatioFrom : null;\n if (pos) uniform.set(pos);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial> {\n return name.substr(0, 9) === 'u_pattern' ?\n new Uniform4f(context, location) :\n new Uniform1f(context, location);\n }\n}\n\nclass SourceExpressionBinder implements AttributeBinder {\n expression: SourceExpression;\n type: string;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: SourceExpression, names: Array, type: string, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.type = type;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 2 : 1,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const start = this.paintVertexArray.length;\n const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection);\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, value);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const value = this.expression.evaluate({zoom: 0}, feature, featureState);\n this._setPaintValue(start, end, value);\n }\n\n _setPaintValue(start, end, value) {\n if (this.type === 'color') {\n const color = packColor(value);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, color[0], color[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, value);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(value));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n}\n\nclass CompositeExpressionBinder implements AttributeBinder, UniformBinder {\n expression: CompositeExpression;\n uniformNames: Array;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n maxValue: number;\n\n paintVertexArray: StructArray;\n paintVertexAttributes: Array;\n paintVertexBuffer: VertexBuffer;\n\n constructor(expression: CompositeExpression, names: Array, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }) {\n this.expression = expression;\n this.uniformNames = names.map(name => `u_${name}_t`);\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.maxValue = 0;\n this.paintVertexAttributes = names.map((name) => ({\n name: `a_${name}`,\n type: 'Float32',\n components: type === 'color' ? 4 : 2,\n offset: 0\n }));\n this.paintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection);\n const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection);\n const start = this.paintVertexArray.length;\n this.paintVertexArray.resize(newLength);\n this._setPaintValue(start, newLength, min, max);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) {\n const min = this.expression.evaluate({zoom: this.zoom}, feature, featureState);\n const max = this.expression.evaluate({zoom: this.zoom + 1}, feature, featureState);\n this._setPaintValue(start, end, min, max);\n }\n\n _setPaintValue(start, end, min, max) {\n if (this.type === 'color') {\n const minColor = packColor(min);\n const maxColor = packColor(max);\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]);\n }\n } else {\n for (let i = start; i < end; i++) {\n this.paintVertexArray.emplace(i, min, max);\n }\n this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max));\n }\n }\n\n upload(context: Context) {\n if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {\n if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {\n this.paintVertexBuffer.updateData(this.paintVertexArray);\n } else {\n this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);\n }\n }\n }\n\n destroy() {\n if (this.paintVertexBuffer) {\n this.paintVertexBuffer.destroy();\n }\n }\n\n setUniform(uniform: Uniform, globals: GlobalProperties): void {\n const currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom;\n const factor = clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1);\n uniform.set(factor);\n }\n\n getBinding(context: Context, location: WebGLUniformLocation, _: string): Uniform1f {\n return new Uniform1f(context, location);\n }\n}\n\nclass CrossFadedCompositeBinder implements AttributeBinder {\n expression: CompositeExpression;\n type: string;\n useIntegerZoom: boolean;\n zoom: number;\n layerId: string;\n\n zoomInPaintVertexArray: StructArray;\n zoomOutPaintVertexArray: StructArray;\n zoomInPaintVertexBuffer: VertexBuffer;\n zoomOutPaintVertexBuffer: VertexBuffer;\n paintVertexAttributes: Array;\n\n constructor(expression: CompositeExpression, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: {\n new (...args: any): StructArray;\n }, layerId: string) {\n this.expression = expression;\n this.type = type;\n this.useIntegerZoom = useIntegerZoom;\n this.zoom = zoom;\n this.layerId = layerId;\n\n this.zoomInPaintVertexArray = new PaintVertexArray();\n this.zoomOutPaintVertexArray = new PaintVertexArray();\n }\n\n populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}) {\n const start = this.zoomInPaintVertexArray.length;\n this.zoomInPaintVertexArray.resize(length);\n this.zoomOutPaintVertexArray.resize(length);\n this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}) {\n this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions);\n }\n\n _setPaintValues(start, end, patterns, positions) {\n if (!positions || !patterns) return;\n\n const {min, mid, max} = patterns;\n const imageMin = positions[min];\n const imageMid = positions[mid];\n const imageMax = positions[max];\n if (!imageMin || !imageMid || !imageMax) return;\n\n // We populate two paint arrays because, for cross-faded properties, we don't know which direction\n // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass\n // unnecessary vertex data to the shaders, we determine which to upload at draw time.\n for (let i = start; i < end; i++) {\n this.zoomInPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1],\n imageMid.pixelRatio,\n imageMin.pixelRatio,\n );\n this.zoomOutPaintVertexArray.emplace(i,\n imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1],\n imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1],\n imageMid.pixelRatio,\n imageMax.pixelRatio,\n );\n }\n }\n\n upload(context: Context) {\n if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) {\n this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);\n }\n }\n\n destroy() {\n if (this.zoomOutPaintVertexBuffer) this.zoomOutPaintVertexBuffer.destroy();\n if (this.zoomInPaintVertexBuffer) this.zoomInPaintVertexBuffer.destroy();\n }\n}\n\n/**\n * @internal\n * ProgramConfiguration contains the logic for binding style layer properties and tile\n * layer feature data into GL program uniforms and vertex attributes.\n *\n * Non-data-driven property values are bound to shader uniforms. Data-driven property\n * values are bound to vertex attributes. In order to support a uniform GLSL syntax over\n * both, [Mapbox GL Shaders](https://github.com/mapbox/mapbox-gl-shaders) defines a `#pragma`\n * abstraction, which ProgramConfiguration is responsible for implementing. At runtime,\n * it examines the attributes of a particular layer, combines this with fixed knowledge\n * about how layers of the particular type are implemented, and determines which uniforms\n * and vertex attributes will be required. It can then substitute the appropriate text\n * into the shader source code, create and link a program, and bind the uniforms and\n * vertex attributes in preparation for drawing.\n *\n * When a vector tile is parsed, this same configuration information is used to\n * populate the attribute buffers needed for data-driven styling using the zoom\n * level and feature property data.\n */\nexport class ProgramConfiguration {\n binders: {[_: string]: AttributeBinder | UniformBinder};\n cacheKey: string;\n\n _buffers: Array;\n\n constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean) {\n this.binders = {};\n this._buffers = [];\n\n const keys = [];\n\n for (const property in layer.paint._values) {\n if (!filterProperties(property)) continue;\n const value = (layer.paint as any).get(property);\n if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {\n continue;\n }\n const names = paintAttributeNames(property, layer.type);\n const expression = value.value;\n const type = value.property.specification.type;\n const useIntegerZoom = (value.property as any).useIntegerZoom;\n const propType = value.property.specification['property-type'];\n const isCrossFaded = propType === 'cross-faded' || propType === 'cross-faded-data-driven';\n\n if (expression.kind === 'constant') {\n this.binders[property] = isCrossFaded ?\n new CrossFadedConstantBinder(expression.value, names) :\n new ConstantBinder(expression.value, names, type);\n keys.push(`/u_${property}`);\n\n } else if (expression.kind === 'source' || isCrossFaded) {\n const StructArrayLayout = layoutType(property, type, 'source');\n this.binders[property] = isCrossFaded ?\n new CrossFadedCompositeBinder(expression as CompositeExpression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) :\n new SourceExpressionBinder(expression as SourceExpression, names, type, StructArrayLayout);\n keys.push(`/a_${property}`);\n\n } else {\n const StructArrayLayout = layoutType(property, type, 'composite');\n this.binders[property] = new CompositeExpressionBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout);\n keys.push(`/z_${property}`);\n }\n }\n\n this.cacheKey = keys.sort().join('');\n }\n\n getMaxValue(property: string): number {\n const binder = this.binders[property];\n return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0;\n }\n\n populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n (binder as AttributeBinder).populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection);\n }\n }\n setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof CrossFadedConstantBinder)\n binder.setConstantPatternPositions(posTo, posFrom);\n }\n }\n\n updatePaintArrays(\n featureStates: FeatureStates,\n featureMap: FeaturePositionMap,\n vtLayer: VectorTileLayer,\n layer: TypedStyleLayer,\n imagePositions: {[_: string]: ImagePosition}\n ): boolean {\n let dirty: boolean = false;\n for (const id in featureStates) {\n const positions = featureMap.getPositions(id);\n\n for (const pos of positions) {\n const feature = vtLayer.feature(pos.index);\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ||\n binder instanceof CrossFadedCompositeBinder) && (binder as any).expression.isStateDependent === true) {\n //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255\n const value = (layer.paint as any).get(property);\n (binder as any).expression = value.value;\n (binder as AttributeBinder).updatePaintArray(pos.start, pos.end, feature, featureStates[id], imagePositions);\n dirty = true;\n }\n }\n }\n }\n return dirty;\n }\n\n defines(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {\n result.push(...binder.uniformNames.map(name => `#define HAS_UNIFORM_${name}`));\n }\n }\n return result;\n }\n\n getBinderAttributes(): Array {\n const result = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) {\n for (let i = 0; i < binder.paintVertexAttributes.length; i++) {\n result.push(binder.paintVertexAttributes[i].name);\n }\n } else if (binder instanceof CrossFadedCompositeBinder) {\n for (let i = 0; i < patternAttributes.members.length; i++) {\n result.push(patternAttributes.members[i].name);\n }\n }\n }\n return result;\n }\n\n getBinderUniforms(): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const uniformName of binder.uniformNames) {\n uniforms.push(uniformName);\n }\n }\n }\n return uniforms;\n }\n\n getPaintVertexBuffers(): Array {\n return this._buffers;\n }\n\n getUniforms(context: Context, locations: UniformLocations): Array {\n const uniforms = [];\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {\n for (const name of binder.uniformNames) {\n if (locations[name]) {\n const binding = binder.getBinding(context, locations[name], name);\n uniforms.push({name, property, binding});\n }\n }\n }\n }\n return uniforms;\n }\n\n setUniforms(\n context: Context,\n binderUniforms: Array,\n properties: any,\n globals: GlobalProperties\n ) {\n // Uniform state bindings are owned by the Program, but we set them\n // from within the ProgramConfiguraton's binder members.\n for (const {name, property, binding} of binderUniforms) {\n (this.binders[property] as any).setUniform(binding, globals, properties.get(property), name);\n }\n }\n\n updatePaintBuffers(crossfade?: CrossfadeParameters) {\n this._buffers = [];\n\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (crossfade && binder instanceof CrossFadedCompositeBinder) {\n const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;\n if (patternVertexBuffer) this._buffers.push(patternVertexBuffer);\n\n } else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) {\n this._buffers.push(binder.paintVertexBuffer);\n }\n }\n }\n\n upload(context: Context) {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.upload(context);\n }\n this.updatePaintBuffers();\n }\n\n destroy() {\n for (const property in this.binders) {\n const binder = this.binders[property];\n if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)\n binder.destroy();\n }\n }\n}\n\nexport class ProgramConfigurationSet {\n programConfigurations: {[_: string]: ProgramConfiguration};\n needsUpload: boolean;\n _featureMap: FeaturePositionMap;\n _bufferOffset: number;\n\n constructor(layers: ReadonlyArray, zoom: number, filterProperties: (_: string) => boolean = () => true) {\n this.programConfigurations = {};\n for (const layer of layers) {\n this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties);\n }\n this.needsUpload = false;\n this._featureMap = new FeaturePositionMap();\n this._bufferOffset = 0;\n }\n\n populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[_: string]: ImagePosition}, canonical: CanonicalTileID, formattedSection?: FormattedSection) {\n for (const key in this.programConfigurations) {\n this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection);\n }\n\n if (feature.id !== undefined) {\n this._featureMap.add(feature.id, index, this._bufferOffset, length);\n }\n this._bufferOffset = length;\n\n this.needsUpload = true;\n }\n\n updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: ReadonlyArray, imagePositions: {[_: string]: ImagePosition}) {\n for (const layer of layers) {\n this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload;\n }\n }\n\n get(layerId: string) {\n return this.programConfigurations[layerId];\n }\n\n upload(context: Context) {\n if (!this.needsUpload) return;\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].upload(context);\n }\n this.needsUpload = false;\n }\n\n destroy() {\n for (const layerId in this.programConfigurations) {\n this.programConfigurations[layerId].destroy();\n }\n }\n}\n\nfunction paintAttributeNames(property, type) {\n const attributeNameExceptions = {\n 'text-opacity': ['opacity'],\n 'icon-opacity': ['opacity'],\n 'text-color': ['fill_color'],\n 'icon-color': ['fill_color'],\n 'text-halo-color': ['halo_color'],\n 'icon-halo-color': ['halo_color'],\n 'text-halo-blur': ['halo_blur'],\n 'icon-halo-blur': ['halo_blur'],\n 'text-halo-width': ['halo_width'],\n 'icon-halo-width': ['halo_width'],\n 'line-gap-width': ['gapwidth'],\n 'line-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n 'fill-extrusion-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'],\n };\n\n return attributeNameExceptions[property] || [property.replace(`${type}-`, '').replace(/-/g, '_')];\n}\n\nfunction getLayoutException(property) {\n const propertyExceptions = {\n 'line-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n },\n 'fill-extrusion-pattern': {\n 'source': PatternLayoutArray,\n 'composite': PatternLayoutArray\n }\n };\n\n return propertyExceptions[property];\n}\n\nfunction layoutType(property, type, binderType) {\n const defaultLayouts = {\n 'color': {\n 'source': StructArrayLayout2f8,\n 'composite': StructArrayLayout4f16\n },\n 'number': {\n 'source': StructArrayLayout1f4,\n 'composite': StructArrayLayout2f8\n }\n };\n\n const layoutException = getLayoutException(property);\n return layoutException && layoutException[binderType] || defaultLayouts[type][binderType];\n}\n\nregister('ConstantBinder', ConstantBinder);\nregister('CrossFadedConstantBinder', CrossFadedConstantBinder);\nregister('SourceExpressionBinder', SourceExpressionBinder);\nregister('CrossFadedCompositeBinder', CrossFadedCompositeBinder);\nregister('CompositeExpressionBinder', CompositeExpressionBinder);\nregister('ProgramConfiguration', ProgramConfiguration, {omit: ['_buffers']});\nregister('ProgramConfigurationSet', ProgramConfigurationSet);\n","/**\n * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of\n * all source features normalized to this extent upon load.\n *\n * The value is a consequence of the following:\n *\n * * Vertex buffer store positions as signed 16 bit integers.\n * * One bit is lost for signedness to support tile buffers.\n * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.\n * * One bit is lost to support features extending past the extent on the right edge of the tile.\n * * This leaves us with 2^13 = 8192\n */\nexport const EXTENT = 8192;\n","import {warnOnce, clamp} from '../util/util';\n\nimport {EXTENT} from './extent';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n// These bounds define the minimum and maximum supported coordinate values.\n// While visible coordinates are within [0, EXTENT], tiles may theoretically\n// contain coordinates within [-Infinity, Infinity]. Our range is limited by the\n// number of bits used to represent the coordinate.\nconst BITS = 15;\nconst MAX = Math.pow(2, BITS - 1) - 1;\nconst MIN = -MAX - 1;\n\n/**\n * Loads a geometry from a VectorTileFeature and scales it to the common extent\n * used internally.\n * @param feature - the vector tile feature to load\n */\nexport function loadGeometry(feature: VectorTileFeature): Array> {\n const scale = EXTENT / feature.extent;\n const geometry = feature.loadGeometry();\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n for (let p = 0; p < ring.length; p++) {\n const point = ring[p];\n // round here because mapbox-gl-native uses integers to represent\n // points and we need to do the same to avoid renering differences.\n const x = Math.round(point.x * scale);\n const y = Math.round(point.y * scale);\n\n point.x = clamp(x, MIN, MAX);\n point.y = clamp(y, MIN, MAX);\n\n if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) {\n // warn when exceeding allowed extent except for the 1-px-off case\n // https://github.com/mapbox/mapbox-gl-js/issues/8992\n warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size');\n }\n }\n }\n return geometry;\n}\n","import {loadGeometry} from './load_geometry';\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\n\ntype EvaluationFeature = Feature & { geometry: Array> };\n/**\n * Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which\n * will be loaded based on necessity.\n * @param feature - the feature to evaluate\n * @param needGeometry - if set to true this will load the geometry\n */\nexport function toEvaluationFeature(feature: VectorTileFeature, needGeometry: boolean): EvaluationFeature {\n return {type: feature.type,\n id: feature.id,\n properties: feature.properties,\n geometry: needGeometry ? loadGeometry(feature) : []};\n}\n","import {CircleLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './circle_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EXTENT} from '../extent';\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nfunction addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {\n layoutVertexArray.emplaceBack(\n (x * 2) + ((extrudeX + 1) / 2),\n (y * 2) + ((extrudeY + 1) / 2));\n}\n\n/**\n * @internal\n * Circles are represented by two triangles.\n *\n * Each corner has a pos that is the center of the circle and an extrusion\n * vector that is where it points.\n */\nexport class CircleBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layerIds: Array;\n layers: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: CircleLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new CircleLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.segments = new SegmentVector();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const styleLayer = this.layers[0];\n const bucketFeatures: BucketFeature[] = [];\n let circleSortKey = null;\n let sortFeaturesByKey = false;\n\n // Heatmap layers are handled in this bucket and have no evaluated properties, so we check our access\n if (styleLayer.type === 'circle') {\n circleSortKey = (styleLayer as CircleStyleLayer).layout.get('circle-sort-key');\n sortFeaturesByKey = !circleSortKey.isConstant();\n }\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n circleSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n const feature = features[index].feature;\n\n this.addFeature(bucketFeature, geometry, index, canonical);\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID) {\n for (const ring of geometry) {\n for (const point of ring) {\n const x = point.x;\n const y = point.y;\n\n // Do not include points that are outside the tile boundaries.\n if (x < 0 || x >= EXTENT || y < 0 || y >= EXTENT) continue;\n\n // this geometry will be of the Point type, and we'll derive\n // two triangles from it.\n //\n // ┌─────────┐\n // │ 3 2 │\n // │ │\n // │ 0 1 │\n // └─────────┘\n\n const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey);\n const index = segment.vertexLength;\n\n addCircleVertex(this.layoutVertexArray, x, y, -1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, -1);\n addCircleVertex(this.layoutVertexArray, x, y, 1, 1);\n addCircleVertex(this.layoutVertexArray, x, y, -1, 1);\n\n this.indexArray.emplaceBack(index, index + 1, index + 2);\n this.indexArray.emplaceBack(index, index + 3, index + 2);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical);\n }\n}\n\nregister('CircleBucket', CircleBucket, {omit: ['layers']});\n","import {isCounterClockwise} from './util';\n\nimport Point from '@mapbox/point-geometry';\n\nexport {polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox};\n\ntype Line = Array;\ntype MultiLine = Array;\ntype Ring = Array;\ntype Polygon = Array;\ntype MultiPolygon = Array;\n\nfunction polygonIntersectsPolygon(polygonA: Polygon, polygonB: Polygon) {\n for (let i = 0; i < polygonA.length; i++) {\n if (polygonContainsPoint(polygonB, polygonA[i])) return true;\n }\n\n for (let i = 0; i < polygonB.length; i++) {\n if (polygonContainsPoint(polygonA, polygonB[i])) return true;\n }\n\n if (lineIntersectsLine(polygonA, polygonB)) return true;\n\n return false;\n}\n\nfunction polygonIntersectsBufferedPoint(polygon: Polygon, point: Point, radius: number) {\n if (polygonContainsPoint(polygon, point)) return true;\n if (pointIntersectsBufferedLine(point, polygon, radius)) return true;\n return false;\n}\n\nfunction polygonIntersectsMultiPolygon(polygon: Polygon, multiPolygon: MultiPolygon) {\n\n if (polygon.length === 1) {\n return multiPolygonContainsPoint(multiPolygon, polygon[0]);\n }\n\n for (let m = 0; m < multiPolygon.length; m++) {\n const ring = multiPolygon[m];\n for (let n = 0; n < ring.length; n++) {\n if (polygonContainsPoint(polygon, ring[n])) return true;\n }\n }\n\n for (let i = 0; i < polygon.length; i++) {\n if (multiPolygonContainsPoint(multiPolygon, polygon[i])) return true;\n }\n\n for (let k = 0; k < multiPolygon.length; k++) {\n if (lineIntersectsLine(polygon, multiPolygon[k])) return true;\n }\n\n return false;\n}\n\nfunction polygonIntersectsBufferedMultiLine(polygon: Polygon, multiLine: MultiLine, radius: number) {\n for (let i = 0; i < multiLine.length; i++) {\n const line = multiLine[i];\n\n if (polygon.length >= 3) {\n for (let k = 0; k < line.length; k++) {\n if (polygonContainsPoint(polygon, line[k])) return true;\n }\n }\n\n if (lineIntersectsBufferedLine(polygon, line, radius)) return true;\n }\n return false;\n}\n\nfunction lineIntersectsBufferedLine(lineA: Line, lineB: Line, radius: number) {\n\n if (lineA.length > 1) {\n if (lineIntersectsLine(lineA, lineB)) return true;\n\n // Check whether any point in either line is within radius of the other line\n for (let j = 0; j < lineB.length; j++) {\n if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) return true;\n }\n }\n\n for (let k = 0; k < lineA.length; k++) {\n if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) return true;\n }\n\n return false;\n}\n\nfunction lineIntersectsLine(lineA: Line, lineB: Line) {\n if (lineA.length === 0 || lineB.length === 0) return false;\n for (let i = 0; i < lineA.length - 1; i++) {\n const a0 = lineA[i];\n const a1 = lineA[i + 1];\n for (let j = 0; j < lineB.length - 1; j++) {\n const b0 = lineB[j];\n const b1 = lineB[j + 1];\n if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) return true;\n }\n }\n return false;\n}\n\nfunction lineSegmentIntersectsLineSegment(a0: Point, a1: Point, b0: Point, b1: Point) {\n return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) &&\n isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1);\n}\n\nfunction pointIntersectsBufferedLine(p: Point, line: Line, radius: number) {\n const radiusSquared = radius * radius;\n\n if (line.length === 1) return p.distSqr(line[0]) < radiusSquared;\n\n for (let i = 1; i < line.length; i++) {\n // Find line segments that have a distance <= radius^2 to p\n // In that case, we treat the line as \"containing point p\".\n const v = line[i - 1], w = line[i];\n if (distToSegmentSquared(p, v, w) < radiusSquared) return true;\n }\n return false;\n}\n\n// Code from http://stackoverflow.com/a/1501725/331379.\nfunction distToSegmentSquared(p: Point, v: Point, w: Point) {\n const l2 = v.distSqr(w);\n if (l2 === 0) return p.distSqr(v);\n const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;\n if (t < 0) return p.distSqr(v);\n if (t > 1) return p.distSqr(w);\n return p.distSqr(w.sub(v)._mult(t)._add(v));\n}\n\n// point in polygon ray casting algorithm\nfunction multiPolygonContainsPoint(rings: Array, p: Point) {\n let c = false,\n ring, p1, p2;\n\n for (let k = 0; k < rings.length; k++) {\n ring = rings[k];\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n }\n return c;\n}\n\nfunction polygonContainsPoint(ring: Ring, p: Point) {\n let c = false;\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const p1 = ring[i];\n const p2 = ring[j];\n if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n c = !c;\n }\n }\n return c;\n}\n\nfunction polygonIntersectsBox(ring: Ring, boxX1: number, boxY1: number, boxX2: number, boxY2: number) {\n for (const p of ring) {\n if (boxX1 <= p.x &&\n boxY1 <= p.y &&\n boxX2 >= p.x &&\n boxY2 >= p.y) return true;\n }\n\n const corners = [\n new Point(boxX1, boxY1),\n new Point(boxX1, boxY2),\n new Point(boxX2, boxY2),\n new Point(boxX2, boxY1)];\n\n if (ring.length > 2) {\n for (const corner of corners) {\n if (polygonContainsPoint(ring, corner)) return true;\n }\n }\n\n for (let i = 0; i < ring.length - 1; i++) {\n const p1 = ring[i];\n const p2 = ring[i + 1];\n if (edgeIntersectsBox(p1, p2, corners)) return true;\n }\n\n return false;\n}\n\nfunction edgeIntersectsBox(e1: Point, e2: Point, corners: Array) {\n const tl = corners[0];\n const br = corners[2];\n // the edge and box do not intersect in either the x or y dimensions\n if (((e1.x < tl.x) && (e2.x < tl.x)) ||\n ((e1.x > br.x) && (e2.x > br.x)) ||\n ((e1.y < tl.y) && (e2.y < tl.y)) ||\n ((e1.y > br.y) && (e2.y > br.y))) return false;\n\n // check if all corners of the box are on the same side of the edge\n const dir = isCounterClockwise(e1, e2, corners[0]);\n return dir !== isCounterClockwise(e1, e2, corners[1]) ||\n dir !== isCounterClockwise(e1, e2, corners[2]) ||\n dir !== isCounterClockwise(e1, e2, corners[3]);\n}\n","import Point from '@mapbox/point-geometry';\n\nimport type {PossiblyEvaluatedPropertyValue} from './properties';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {LineBucket} from '../data/bucket/line_bucket';\n\nexport function getMaximumPaintValue(\n property: string,\n layer: StyleLayer,\n bucket: CircleBucket | LineBucket\n): number {\n const value = ((layer.paint as any).get(property) as PossiblyEvaluatedPropertyValue).value;\n if (value.kind === 'constant') {\n return value.value;\n } else {\n return bucket.programConfigurations.get(layer.id).getMaxValue(property);\n }\n}\n\nexport function translateDistance(translate: [number, number]) {\n return Math.sqrt(translate[0] * translate[0] + translate[1] * translate[1]);\n}\n\nexport function translate(queryGeometry: Array,\n translate: [number, number],\n translateAnchor: 'viewport' | 'map',\n bearing: number,\n pixelsToTileUnits: number) {\n if (!translate[0] && !translate[1]) {\n return queryGeometry;\n }\n const pt = Point.convert(translate)._mult(pixelsToTileUnits);\n\n if (translateAnchor === 'viewport') {\n pt._rotate(-bearing);\n }\n\n const translated = [];\n for (let i = 0; i < queryGeometry.length; i++) {\n const point = queryGeometry[i];\n translated.push(point.sub(pt));\n }\n return translated;\n}\n\nexport function offsetLine(rings: Array>, offset: number) {\n const newRings: Array> = [];\n for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {\n const ring = rings[ringIndex];\n const newRing: Array = [];\n for (let index = 0; index < ring.length; index++) {\n const a = ring[index - 1];\n const b = ring[index];\n const c = ring[index + 1];\n const aToB = index === 0 ? new Point(0, 0) : b.sub(a)._unit()._perp();\n const bToC = index === ring.length - 1 ? new Point(0, 0) : c.sub(b)._unit()._perp();\n const extrude = aToB._add(bToC)._unit();\n\n const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;\n if (cosHalfAngle !== 0) {\n extrude._mult(1 / cosHalfAngle);\n }\n\n newRing.push(extrude._mult(offset)._add(b));\n }\n newRings.push(newRing);\n }\n return newRings;\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type CircleLayoutProps = {\n \"circle-sort-key\": DataDrivenProperty,\n};\n\nexport type CircleLayoutPropsPossiblyEvaluated = {\n \"circle-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"circle-sort-key\": new DataDrivenProperty(styleSpec[\"layout_circle\"][\"circle-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type CirclePaintProps = {\n \"circle-radius\": DataDrivenProperty,\n \"circle-color\": DataDrivenProperty,\n \"circle-blur\": DataDrivenProperty,\n \"circle-opacity\": DataDrivenProperty,\n \"circle-translate\": DataConstantProperty<[number, number]>,\n \"circle-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-scale\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\">,\n \"circle-stroke-width\": DataDrivenProperty,\n \"circle-stroke-color\": DataDrivenProperty,\n \"circle-stroke-opacity\": DataDrivenProperty,\n};\n\nexport type CirclePaintPropsPossiblyEvaluated = {\n \"circle-radius\": PossiblyEvaluatedPropertyValue,\n \"circle-color\": PossiblyEvaluatedPropertyValue,\n \"circle-blur\": PossiblyEvaluatedPropertyValue,\n \"circle-opacity\": PossiblyEvaluatedPropertyValue,\n \"circle-translate\": [number, number],\n \"circle-translate-anchor\": \"map\" | \"viewport\",\n \"circle-pitch-scale\": \"map\" | \"viewport\",\n \"circle-pitch-alignment\": \"map\" | \"viewport\",\n \"circle-stroke-width\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-color\": PossiblyEvaluatedPropertyValue,\n \"circle-stroke-opacity\": PossiblyEvaluatedPropertyValue,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"circle-radius\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-radius\"] as any as StylePropertySpecification),\n \"circle-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-color\"] as any as StylePropertySpecification),\n \"circle-blur\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-blur\"] as any as StylePropertySpecification),\n \"circle-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-opacity\"] as any as StylePropertySpecification),\n \"circle-translate\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate\"] as any as StylePropertySpecification),\n \"circle-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-translate-anchor\"] as any as StylePropertySpecification),\n \"circle-pitch-scale\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-scale\"] as any as StylePropertySpecification),\n \"circle-pitch-alignment\": new DataConstantProperty(styleSpec[\"paint_circle\"][\"circle-pitch-alignment\"] as any as StylePropertySpecification),\n \"circle-stroke-width\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-width\"] as any as StylePropertySpecification),\n \"circle-stroke-color\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-color\"] as any as StylePropertySpecification),\n \"circle-stroke-opacity\": new DataDrivenProperty(styleSpec[\"paint_circle\"][\"circle-stroke-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","/**\n * Common utilities\n * @module glMatrix\n */\n// Configuration Constants\nexport var EPSILON = 0.000001;\nexport var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;\nexport var RANDOM = Math.random;\n/**\n * Sets the type of array used when creating new vectors and matrices\n *\n * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array\n */\n\nexport function setMatrixArrayType(type) {\n ARRAY_TYPE = type;\n}\nvar degree = Math.PI / 180;\n/**\n * Convert Degree To Radian\n *\n * @param {Number} a Angle in Degrees\n */\n\nexport function toRadian(a) {\n return a * degree;\n}\n/**\n * Tests whether or not the arguments have approximately the same value, within an absolute\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\n * than or equal to 1.0, and a relative tolerance is used for larger values)\n *\n * @param {Number} a The first number to test.\n * @param {Number} b The second number to test.\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\n */\n\nexport function equals(a, b) {\n return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));\n}\nif (!Math.hypot) Math.hypot = function () {\n var y = 0,\n i = arguments.length;\n\n while (i--) {\n y += arguments[i] * arguments[i];\n }\n\n return Math.sqrt(y);\n};","import * as glMatrix from \"./common.js\";\n/**\n * 4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.\n * @module mat4\n */\n\n/**\n * Creates a new identity mat4\n *\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(16);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n }\n\n out[0] = 1;\n out[5] = 1;\n out[10] = 1;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat4} a matrix to clone\n * @returns {mat4} a new 4x4 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Copy the values from one mat4 to another\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Create a new mat4 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} A new mat4\n */\n\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n var out = new glMatrix.ARRAY_TYPE(16);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set the components of a mat4 to the given values\n *\n * @param {mat4} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} out\n */\n\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m03;\n out[4] = m10;\n out[5] = m11;\n out[6] = m12;\n out[7] = m13;\n out[8] = m20;\n out[9] = m21;\n out[10] = m22;\n out[11] = m23;\n out[12] = m30;\n out[13] = m31;\n out[14] = m32;\n out[15] = m33;\n return out;\n}\n/**\n * Set a mat4 to the identity matrix\n *\n * @param {mat4} out the receiving matrix\n * @returns {mat4} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a12 = a[6],\n a13 = a[7];\n var a23 = a[11];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a01;\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a02;\n out[9] = a12;\n out[11] = a[14];\n out[12] = a03;\n out[13] = a13;\n out[14] = a23;\n } else {\n out[0] = a[0];\n out[1] = a[4];\n out[2] = a[8];\n out[3] = a[12];\n out[4] = a[1];\n out[5] = a[5];\n out[6] = a[9];\n out[7] = a[13];\n out[8] = a[2];\n out[9] = a[6];\n out[10] = a[10];\n out[11] = a[14];\n out[12] = a[3];\n out[13] = a[7];\n out[14] = a[11];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Inverts a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22);\n out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\n out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12);\n out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\n out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\n out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22);\n out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\n out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12);\n out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21);\n out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\n out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11);\n out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\n out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\n out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21);\n out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\n out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11);\n return out;\n}\n/**\n * Calculates the determinant of a mat4\n *\n * @param {ReadonlyMat4} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n}\n/**\n * Multiplies two mat4s\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15]; // Cache only the current line of the second matrix\n\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[4];\n b1 = b[5];\n b2 = b[6];\n b3 = b[7];\n out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[8];\n b1 = b[9];\n b2 = b[10];\n b3 = b[11];\n out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n b0 = b[12];\n b1 = b[13];\n b2 = b[14];\n b3 = b[15];\n out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n return out;\n}\n/**\n * Translate a mat4 by the given vector\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to translate\n * @param {ReadonlyVec3} v vector to translate by\n * @returns {mat4} out\n */\n\nexport function translate(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n\n if (a === out) {\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n } else {\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a03;\n out[4] = a10;\n out[5] = a11;\n out[6] = a12;\n out[7] = a13;\n out[8] = a20;\n out[9] = a21;\n out[10] = a22;\n out[11] = a23;\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\n }\n\n return out;\n}\n/**\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {ReadonlyVec3} v the vec3 to scale the matrix by\n * @returns {mat4} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1],\n z = v[2];\n out[0] = a[0] * x;\n out[1] = a[1] * x;\n out[2] = a[2] * x;\n out[3] = a[3] * x;\n out[4] = a[4] * y;\n out[5] = a[5] * y;\n out[6] = a[6] * y;\n out[7] = a[7] * y;\n out[8] = a[8] * z;\n out[9] = a[9] * z;\n out[10] = a[10] * z;\n out[11] = a[11] * z;\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n return out;\n}\n/**\n * Rotates a mat4 by the given angle around the given axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function rotate(out, a, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n var a00, a01, a02, a03;\n var a10, a11, a12, a13;\n var a20, a21, a22, a23;\n var b00, b01, b02;\n var b10, b11, b12;\n var b20, b21, b22;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c;\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11]; // Construct the elements of the rotation matrix\n\n b00 = x * x * t + c;\n b01 = y * x * t + z * s;\n b02 = z * x * t - y * s;\n b10 = x * y * t - z * s;\n b11 = y * y * t + c;\n b12 = z * y * t + x * s;\n b20 = x * z * t + y * s;\n b21 = y * z * t - x * s;\n b22 = z * z * t + c; // Perform rotation-specific matrix multiplication\n\n out[0] = a00 * b00 + a10 * b01 + a20 * b02;\n out[1] = a01 * b00 + a11 * b01 + a21 * b02;\n out[2] = a02 * b00 + a12 * b01 + a22 * b02;\n out[3] = a03 * b00 + a13 * b01 + a23 * b02;\n out[4] = a00 * b10 + a10 * b11 + a20 * b12;\n out[5] = a01 * b10 + a11 * b11 + a21 * b12;\n out[6] = a02 * b10 + a12 * b11 + a22 * b12;\n out[7] = a03 * b10 + a13 * b11 + a23 * b12;\n out[8] = a00 * b20 + a10 * b21 + a20 * b22;\n out[9] = a01 * b20 + a11 * b21 + a21 * b22;\n out[10] = a02 * b20 + a12 * b21 + a22 * b22;\n out[11] = a03 * b20 + a13 * b21 + a23 * b22;\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n }\n\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the X axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateX(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[4] = a10 * c + a20 * s;\n out[5] = a11 * c + a21 * s;\n out[6] = a12 * c + a22 * s;\n out[7] = a13 * c + a23 * s;\n out[8] = a20 * c - a10 * s;\n out[9] = a21 * c - a11 * s;\n out[10] = a22 * c - a12 * s;\n out[11] = a23 * c - a13 * s;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Y axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateY(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged rows\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c - a20 * s;\n out[1] = a01 * c - a21 * s;\n out[2] = a02 * c - a22 * s;\n out[3] = a03 * c - a23 * s;\n out[8] = a00 * s + a20 * c;\n out[9] = a01 * s + a21 * c;\n out[10] = a02 * s + a22 * c;\n out[11] = a03 * s + a23 * c;\n return out;\n}\n/**\n * Rotates a matrix by the given angle around the Z axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function rotateZ(out, a, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n if (a !== out) {\n // If the source and destination differ, copy the unchanged last row\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n } // Perform axis-specific matrix multiplication\n\n\n out[0] = a00 * c + a10 * s;\n out[1] = a01 * c + a11 * s;\n out[2] = a02 * c + a12 * s;\n out[3] = a03 * c + a13 * s;\n out[4] = a10 * c - a00 * s;\n out[5] = a11 * c - a01 * s;\n out[6] = a12 * c - a02 * s;\n out[7] = a13 * c - a03 * s;\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.scale(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = v[1];\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = v[2];\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle around a given axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotate(dest, dest, rad, axis);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\n\nexport function fromRotation(out, rad, axis) {\n var x = axis[0],\n y = axis[1],\n z = axis[2];\n var len = Math.hypot(x, y, z);\n var s, c, t;\n\n if (len < glMatrix.EPSILON) {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n s = Math.sin(rad);\n c = Math.cos(rad);\n t = 1 - c; // Perform rotation-specific matrix multiplication\n\n out[0] = x * x * t + c;\n out[1] = y * x * t + z * s;\n out[2] = z * x * t - y * s;\n out[3] = 0;\n out[4] = x * y * t - z * s;\n out[5] = y * y * t + c;\n out[6] = z * y * t + x * s;\n out[7] = 0;\n out[8] = x * z * t + y * s;\n out[9] = y * z * t - x * s;\n out[10] = z * z * t + c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the X axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateX(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromXRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = c;\n out[6] = s;\n out[7] = 0;\n out[8] = 0;\n out[9] = -s;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Y axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateY(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromYRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = 0;\n out[2] = -s;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = s;\n out[9] = 0;\n out[10] = c;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from the given angle around the Z axis\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.rotateZ(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\n\nexport function fromZRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad); // Perform axis-specific matrix multiplication\n\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = 0;\n out[4] = -s;\n out[5] = c;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation and vector translation\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslation(out, q, v) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a new mat4 from a dual quat.\n *\n * @param {mat4} out Matrix\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @returns {mat4} mat4 receiving operation result\n */\n\nexport function fromQuat2(out, a) {\n var translation = new glMatrix.ARRAY_TYPE(3);\n var bx = -a[0],\n by = -a[1],\n bz = -a[2],\n bw = a[3],\n ax = a[4],\n ay = a[5],\n az = a[6],\n aw = a[7];\n var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense\n\n if (magnitude > 0) {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\n } else {\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n }\n\n fromRotationTranslation(out, a, translation);\n return out;\n}\n/**\n * Returns the translation vector component of a transformation\n * matrix. If a matrix is built with fromRotationTranslation,\n * the returned vector will be the same as the translation vector\n * originally supplied.\n * @param {vec3} out Vector to receive translation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getTranslation(out, mat) {\n out[0] = mat[12];\n out[1] = mat[13];\n out[2] = mat[14];\n return out;\n}\n/**\n * Returns the scaling factor component of a transformation\n * matrix. If a matrix is built with fromRotationTranslationScale\n * with a normalized Quaternion paramter, the returned vector will be\n * the same as the scaling vector\n * originally supplied.\n * @param {vec3} out Vector to receive scaling factor component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\n\nexport function getScaling(out, mat) {\n var m11 = mat[0];\n var m12 = mat[1];\n var m13 = mat[2];\n var m21 = mat[4];\n var m22 = mat[5];\n var m23 = mat[6];\n var m31 = mat[8];\n var m32 = mat[9];\n var m33 = mat[10];\n out[0] = Math.hypot(m11, m12, m13);\n out[1] = Math.hypot(m21, m22, m23);\n out[2] = Math.hypot(m31, m32, m33);\n return out;\n}\n/**\n * Returns a quaternion representing the rotational component\n * of a transformation matrix. If a matrix is built with\n * fromRotationTranslation, the returned quaternion will be the\n * same as the quaternion originally supplied.\n * @param {quat} out Quaternion to receive the rotation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {quat} out\n */\n\nexport function getRotation(out, mat) {\n var scaling = new glMatrix.ARRAY_TYPE(3);\n getScaling(scaling, mat);\n var is1 = 1 / scaling[0];\n var is2 = 1 / scaling[1];\n var is3 = 1 / scaling[2];\n var sm11 = mat[0] * is1;\n var sm12 = mat[1] * is2;\n var sm13 = mat[2] * is3;\n var sm21 = mat[4] * is1;\n var sm22 = mat[5] * is2;\n var sm23 = mat[6] * is3;\n var sm31 = mat[8] * is1;\n var sm32 = mat[9] * is2;\n var sm33 = mat[10] * is3;\n var trace = sm11 + sm22 + sm33;\n var S = 0;\n\n if (trace > 0) {\n S = Math.sqrt(trace + 1.0) * 2;\n out[3] = 0.25 * S;\n out[0] = (sm23 - sm32) / S;\n out[1] = (sm31 - sm13) / S;\n out[2] = (sm12 - sm21) / S;\n } else if (sm11 > sm22 && sm11 > sm33) {\n S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n out[3] = (sm23 - sm32) / S;\n out[0] = 0.25 * S;\n out[1] = (sm12 + sm21) / S;\n out[2] = (sm31 + sm13) / S;\n } else if (sm22 > sm33) {\n S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n out[3] = (sm31 - sm13) / S;\n out[0] = (sm12 + sm21) / S;\n out[1] = 0.25 * S;\n out[2] = (sm23 + sm32) / S;\n } else {\n S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n out[3] = (sm12 - sm21) / S;\n out[0] = (sm31 + sm13) / S;\n out[1] = (sm23 + sm32) / S;\n out[2] = 0.25 * S;\n }\n\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScale(out, q, v, s) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n out[0] = (1 - (yy + zz)) * sx;\n out[1] = (xy + wz) * sx;\n out[2] = (xz - wy) * sx;\n out[3] = 0;\n out[4] = (xy - wz) * sy;\n out[5] = (1 - (xx + zz)) * sy;\n out[6] = (yz + wx) * sy;\n out[7] = 0;\n out[8] = (xz + wy) * sz;\n out[9] = (yz - wx) * sz;\n out[10] = (1 - (xx + yy)) * sz;\n out[11] = 0;\n out[12] = v[0];\n out[13] = v[1];\n out[14] = v[2];\n out[15] = 1;\n return out;\n}\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\n * This is equivalent to (but much faster than):\n *\n * mat4.identity(dest);\n * mat4.translate(dest, vec);\n * mat4.translate(dest, origin);\n * let quatMat = mat4.create();\n * quat4.toMat4(quat, quatMat);\n * mat4.multiply(dest, quatMat);\n * mat4.scale(dest, scale)\n * mat4.translate(dest, negativeOrigin);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat4} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @param {ReadonlyVec3} o The origin vector around which to scale and rotate\n * @returns {mat4} out\n */\n\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\n // Quaternion math\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n var sx = s[0];\n var sy = s[1];\n var sz = s[2];\n var ox = o[0];\n var oy = o[1];\n var oz = o[2];\n var out0 = (1 - (yy + zz)) * sx;\n var out1 = (xy + wz) * sx;\n var out2 = (xz - wy) * sx;\n var out4 = (xy - wz) * sy;\n var out5 = (1 - (xx + zz)) * sy;\n var out6 = (yz + wx) * sy;\n var out8 = (xz + wy) * sz;\n var out9 = (yz - wx) * sz;\n var out10 = (1 - (xx + yy)) * sz;\n out[0] = out0;\n out[1] = out1;\n out[2] = out2;\n out[3] = 0;\n out[4] = out4;\n out[5] = out5;\n out[6] = out6;\n out[7] = 0;\n out[8] = out8;\n out[9] = out9;\n out[10] = out10;\n out[11] = 0;\n out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\n out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\n out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\n out[15] = 1;\n return out;\n}\n/**\n * Calculates a 4x4 matrix from the given quaternion\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat4} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[1] = yx + wz;\n out[2] = zx - wy;\n out[3] = 0;\n out[4] = yx - wz;\n out[5] = 1 - xx - zz;\n out[6] = zy + wx;\n out[7] = 0;\n out[8] = zx + wy;\n out[9] = zy - wx;\n out[10] = 1 - xx - yy;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a frustum matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Number} left Left bound of the frustum\n * @param {Number} right Right bound of the frustum\n * @param {Number} bottom Bottom bound of the frustum\n * @param {Number} top Top bound of the frustum\n * @param {Number} near Near bound of the frustum\n * @param {Number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function frustum(out, left, right, bottom, top, near, far) {\n var rl = 1 / (right - left);\n var tb = 1 / (top - bottom);\n var nf = 1 / (near - far);\n out[0] = near * 2 * rl;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = near * 2 * tb;\n out[6] = 0;\n out[7] = 0;\n out[8] = (right + left) * rl;\n out[9] = (top + bottom) * tb;\n out[10] = (far + near) * nf;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[14] = far * near * 2 * nf;\n out[15] = 0;\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveNO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = (far + near) * nf;\n out[14] = 2 * far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -2 * near;\n }\n\n return out;\n}\n/**\n * Alias for {@link mat4.perspectiveNO}\n * @function\n */\n\nexport var perspective = perspectiveNO;\n/**\n * Generates a perspective projection matrix suitable for WebGPU with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\n\nexport function perspectiveZO(out, fovy, aspect, near, far) {\n var f = 1.0 / Math.tan(fovy / 2),\n nf;\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[11] = -1;\n out[12] = 0;\n out[13] = 0;\n out[15] = 0;\n\n if (far != null && far !== Infinity) {\n nf = 1 / (near - far);\n out[10] = far * nf;\n out[14] = far * near * nf;\n } else {\n out[10] = -1;\n out[14] = -near;\n }\n\n return out;\n}\n/**\n * Generates a perspective projection matrix with the given field of view.\n * This is primarily useful for generating projection matrices to be used\n * with the still experiemental WebVR API.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\n var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);\n var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);\n var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);\n var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);\n var xScale = 2.0 / (leftTan + rightTan);\n var yScale = 2.0 / (upTan + downTan);\n out[0] = xScale;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n out[4] = 0.0;\n out[5] = yScale;\n out[6] = 0.0;\n out[7] = 0.0;\n out[8] = -((leftTan - rightTan) * xScale * 0.5);\n out[9] = (upTan - downTan) * yScale * 0.5;\n out[10] = far / (near - far);\n out[11] = -1.0;\n out[12] = 0.0;\n out[13] = 0.0;\n out[14] = far * near / (near - far);\n out[15] = 0.0;\n return out;\n}\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoNO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 2 * nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = (far + near) * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Alias for {@link mat4.orthoNO}\n * @function\n */\n\nexport var ortho = orthoNO;\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\n\nexport function orthoZO(out, left, right, bottom, top, near, far) {\n var lr = 1 / (left - right);\n var bt = 1 / (bottom - top);\n var nf = 1 / (near - far);\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = nf;\n out[11] = 0;\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = near * nf;\n out[15] = 1;\n return out;\n}\n/**\n * Generates a look-at matrix with the given eye position, focal point, and up axis.\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function lookAt(out, eye, center, up) {\n var x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\n var eyex = eye[0];\n var eyey = eye[1];\n var eyez = eye[2];\n var upx = up[0];\n var upy = up[1];\n var upz = up[2];\n var centerx = center[0];\n var centery = center[1];\n var centerz = center[2];\n\n if (Math.abs(eyex - centerx) < glMatrix.EPSILON && Math.abs(eyey - centery) < glMatrix.EPSILON && Math.abs(eyez - centerz) < glMatrix.EPSILON) {\n return identity(out);\n }\n\n z0 = eyex - centerx;\n z1 = eyey - centery;\n z2 = eyez - centerz;\n len = 1 / Math.hypot(z0, z1, z2);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n x0 = upy * z2 - upz * z1;\n x1 = upz * z0 - upx * z2;\n x2 = upx * z1 - upy * z0;\n len = Math.hypot(x0, x1, x2);\n\n if (!len) {\n x0 = 0;\n x1 = 0;\n x2 = 0;\n } else {\n len = 1 / len;\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n y0 = z1 * x2 - z2 * x1;\n y1 = z2 * x0 - z0 * x2;\n y2 = z0 * x1 - z1 * x0;\n len = Math.hypot(y0, y1, y2);\n\n if (!len) {\n y0 = 0;\n y1 = 0;\n y2 = 0;\n } else {\n len = 1 / len;\n y0 *= len;\n y1 *= len;\n y2 *= len;\n }\n\n out[0] = x0;\n out[1] = y0;\n out[2] = z0;\n out[3] = 0;\n out[4] = x1;\n out[5] = y1;\n out[6] = z1;\n out[7] = 0;\n out[8] = x2;\n out[9] = y2;\n out[10] = z2;\n out[11] = 0;\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n out[15] = 1;\n return out;\n}\n/**\n * Generates a matrix that makes something look at something else.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\n\nexport function targetTo(out, eye, target, up) {\n var eyex = eye[0],\n eyey = eye[1],\n eyez = eye[2],\n upx = up[0],\n upy = up[1],\n upz = up[2];\n var z0 = eyex - target[0],\n z1 = eyey - target[1],\n z2 = eyez - target[2];\n var len = z0 * z0 + z1 * z1 + z2 * z2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n z0 *= len;\n z1 *= len;\n z2 *= len;\n }\n\n var x0 = upy * z2 - upz * z1,\n x1 = upz * z0 - upx * z2,\n x2 = upx * z1 - upy * z0;\n len = x0 * x0 + x1 * x1 + x2 * x2;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n out[0] = x0;\n out[1] = x1;\n out[2] = x2;\n out[3] = 0;\n out[4] = z1 * x2 - z2 * x1;\n out[5] = z2 * x0 - z0 * x2;\n out[6] = z0 * x1 - z1 * x0;\n out[7] = 0;\n out[8] = z0;\n out[9] = z1;\n out[10] = z2;\n out[11] = 0;\n out[12] = eyex;\n out[13] = eyey;\n out[14] = eyez;\n out[15] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat4\n *\n * @param {ReadonlyMat4} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \", \" + a[9] + \", \" + a[10] + \", \" + a[11] + \", \" + a[12] + \", \" + a[13] + \", \" + a[14] + \", \" + a[15] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat4\n *\n * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);\n}\n/**\n * Adds two mat4's\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n out[9] = a[9] + b[9];\n out[10] = a[10] + b[10];\n out[11] = a[11] + b[11];\n out[12] = a[12] + b[12];\n out[13] = a[13] + b[13];\n out[14] = a[14] + b[14];\n out[15] = a[15] + b[15];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n out[9] = a[9] - b[9];\n out[10] = a[10] - b[10];\n out[11] = a[11] - b[11];\n out[12] = a[12] - b[12];\n out[13] = a[13] - b[13];\n out[14] = a[14] - b[14];\n out[15] = a[15] - b[15];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat4} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n out[9] = a[9] * b;\n out[10] = a[10] * b;\n out[11] = a[11] * b;\n out[12] = a[12] * b;\n out[13] = a[13] * b;\n out[14] = a[14] * b;\n out[15] = a[15] * b;\n return out;\n}\n/**\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat4} out the receiving vector\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat4} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n out[9] = a[9] + b[9] * scale;\n out[10] = a[10] + b[10] * scale;\n out[11] = a[11] + b[11] * scale;\n out[12] = a[12] + b[12] * scale;\n out[13] = a[13] + b[13] * scale;\n out[14] = a[14] + b[14] * scale;\n out[15] = a[15] + b[15] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7];\n var a8 = a[8],\n a9 = a[9],\n a10 = a[10],\n a11 = a[11];\n var a12 = a[12],\n a13 = a[13],\n a14 = a[14],\n a15 = a[15];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n var b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7];\n var b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11];\n var b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15));\n}\n/**\n * Alias for {@link mat4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat4.subtract}\n * @function\n */\n\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n/**\n * 4 Dimensional Vector\n * @module vec4\n */\n\n/**\n * Creates a new, empty vec4\n *\n * @returns {vec4} a new 4D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec4 initialized with values from an existing vector\n *\n * @param {ReadonlyVec4} a vector to clone\n * @returns {vec4} a new 4D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Creates a new vec4 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} a new 4D vector\n */\n\nexport function fromValues(x, y, z, w) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Copy the values from one vec4 to another\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the source vector\n * @returns {vec4} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to the given values\n *\n * @param {vec4} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} out\n */\n\nexport function set(out, x, y, z, w) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n out[3] = w;\n return out;\n}\n/**\n * Adds two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Multiplies two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n out[3] = a[3] * b[3];\n return out;\n}\n/**\n * Divides two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n out[3] = a[3] / b[3];\n return out;\n}\n/**\n * Math.ceil the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to ceil\n * @returns {vec4} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n out[3] = Math.ceil(a[3]);\n return out;\n}\n/**\n * Math.floor the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to floor\n * @returns {vec4} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n out[3] = Math.floor(a[3]);\n return out;\n}\n/**\n * Returns the minimum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n out[3] = Math.min(a[3], b[3]);\n return out;\n}\n/**\n * Returns the maximum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n out[3] = Math.max(a[3], b[3]);\n return out;\n}\n/**\n * Math.round the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to round\n * @returns {vec4} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n out[3] = Math.round(a[3]);\n return out;\n}\n/**\n * Scales a vec4 by a scalar number\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec4} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two vec4's after scaling the second operand by a scalar value\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec4} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n var w = b[3] - a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Calculates the length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return Math.hypot(x, y, z, w);\n}\n/**\n * Calculates the squared length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n return x * x + y * y + z * z + w * w;\n}\n/**\n * Negates the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to negate\n * @returns {vec4} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = -a[3];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to invert\n * @returns {vec4} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n out[3] = 1.0 / a[3];\n return out;\n}\n/**\n * Normalize a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to normalize\n * @returns {vec4} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var w = a[3];\n var len = x * x + y * y + z * z + w * w;\n\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = x * len;\n out[1] = y * len;\n out[2] = z * len;\n out[3] = w * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n/**\n * Returns the cross-product of three vectors in a 4-dimensional space\n *\n * @param {ReadonlyVec4} result the receiving vector\n * @param {ReadonlyVec4} U the first vector\n * @param {ReadonlyVec4} V the second vector\n * @param {ReadonlyVec4} W the third vector\n * @returns {vec4} result\n */\n\nexport function cross(out, u, v, w) {\n var A = v[0] * w[1] - v[1] * w[0],\n B = v[0] * w[2] - v[2] * w[0],\n C = v[0] * w[3] - v[3] * w[0],\n D = v[1] * w[2] - v[2] * w[1],\n E = v[1] * w[3] - v[3] * w[1],\n F = v[2] * w[3] - v[3] * w[2];\n var G = u[0];\n var H = u[1];\n var I = u[2];\n var J = u[3];\n out[0] = H * F - I * E + J * D;\n out[1] = -(G * F) + I * C - J * B;\n out[2] = G * E - H * C + J * A;\n out[3] = -(G * D) + H * B - I * A;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec4} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n var aw = a[3];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n out[3] = aw + t * (b[3] - aw);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec4} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec4} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a\n // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.\n // http://projecteuclid.org/euclid.aoms/1177692644;\n\n var v1, v2, v3, v4;\n var s1, s2;\n\n do {\n v1 = glMatrix.RANDOM() * 2 - 1;\n v2 = glMatrix.RANDOM() * 2 - 1;\n s1 = v1 * v1 + v2 * v2;\n } while (s1 >= 1);\n\n do {\n v3 = glMatrix.RANDOM() * 2 - 1;\n v4 = glMatrix.RANDOM() * 2 - 1;\n s2 = v3 * v3 + v4 * v4;\n } while (s2 >= 1);\n\n var d = Math.sqrt((1 - s1) / s2);\n out[0] = scale * v1;\n out[1] = scale * v2;\n out[2] = scale * v3 * d;\n out[3] = scale * v4 * d;\n return out;\n}\n/**\n * Transforms the vec4 with a mat4.\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec4} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2],\n w = a[3];\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n return out;\n}\n/**\n * Transforms the vec4 with a quat\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec4} out\n */\n\nexport function transformQuat(out, a, q) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3]; // calculate quat * vec\n\n var ix = qw * x + qy * z - qz * y;\n var iy = qw * y + qz * x - qx * z;\n var iz = qw * z + qx * y - qy * x;\n var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat\n\n out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n out[3] = a[3];\n return out;\n}\n/**\n * Set the components of a vec4 to zero\n *\n * @param {vec4} out the receiving vector\n * @returns {vec4} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n out[3] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec4} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Alias for {@link vec4.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec4.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec4.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec4.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec4.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec4.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec4.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec4s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 4;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n vec[3] = a[i + 3];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n a[i + 3] = vec[3];\n }\n\n return a;\n };\n}();","import {StyleLayer} from '../style_layer';\n\nimport {CircleBucket} from '../../data/bucket/circle_bucket';\nimport {polygonIntersectsBufferedPoint} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate} from '../query_utils';\nimport properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../../geo/transform';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties.g';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\n/**\n * A style layer that defines a circle\n */\nexport class CircleStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new CircleBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const circleBucket: CircleBucket = (bucket as any);\n return getMaximumPaintValue('circle-radius', this, circleBucket) +\n getMaximumPaintValue('circle-stroke-width', this, circleBucket) +\n translateDistance(this.paint.get('circle-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('circle-translate'),\n this.paint.get('circle-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const radius = this.paint.get('circle-radius').evaluate(feature, featureState);\n const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState);\n const size = radius + stroke;\n\n // For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile\n // // Otherwise, compare geometry in the plane of the viewport\n // // A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance\n // // A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance\n const alignWithMap = this.paint.get('circle-pitch-alignment') === 'map';\n const transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry(translatedPolygon, pixelPosMatrix);\n const transformedSize = alignWithMap ? size * pixelsToTileUnits : size;\n\n for (const ring of geometry) {\n for (const point of ring) {\n\n const transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix);\n\n let adjustedSize = transformedSize;\n const projectedCenter = vec4.transformMat4([] as any, [point.x, point.y, 0, 1], pixelPosMatrix);\n if (this.paint.get('circle-pitch-scale') === 'viewport' && this.paint.get('circle-pitch-alignment') === 'map') {\n adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance;\n } else if (this.paint.get('circle-pitch-scale') === 'map' && this.paint.get('circle-pitch-alignment') === 'viewport') {\n adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3];\n }\n\n if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) return true;\n }\n }\n\n return false;\n }\n}\n\nfunction projectPoint(p: Point, pixelPosMatrix: mat4) {\n const point = vec4.transformMat4([] as any, [p.x, p.y, 0, 1], pixelPosMatrix);\n return new Point(point[0] / point[3], point[1] / point[3]);\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4) {\n return queryGeometry.map((p) => {\n return projectPoint(p, pixelPosMatrix);\n });\n}\n","import {CircleBucket} from './circle_bucket';\nimport {register} from '../../util/web_worker_transfer';\n\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport class HeatmapBucket extends CircleBucket {\n // Needed for flow to accept omit: ['layers'] below, due to\n // https://github.com/facebook/flow/issues/4262\n layers: Array;\n}\n\nregister('HeatmapBucket', HeatmapBucket, {omit: ['layers']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HeatmapPaintProps = {\n \"heatmap-radius\": DataDrivenProperty,\n \"heatmap-weight\": DataDrivenProperty,\n \"heatmap-intensity\": DataConstantProperty,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": DataConstantProperty,\n};\n\nexport type HeatmapPaintPropsPossiblyEvaluated = {\n \"heatmap-radius\": PossiblyEvaluatedPropertyValue,\n \"heatmap-weight\": PossiblyEvaluatedPropertyValue,\n \"heatmap-intensity\": number,\n \"heatmap-color\": ColorRampProperty,\n \"heatmap-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"heatmap-radius\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-radius\"] as any as StylePropertySpecification),\n \"heatmap-weight\": new DataDrivenProperty(styleSpec[\"paint_heatmap\"][\"heatmap-weight\"] as any as StylePropertySpecification),\n \"heatmap-intensity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-intensity\"] as any as StylePropertySpecification),\n \"heatmap-color\": new ColorRampProperty(styleSpec[\"paint_heatmap\"][\"heatmap-color\"] as any as StylePropertySpecification),\n \"heatmap-opacity\": new DataConstantProperty(styleSpec[\"paint_heatmap\"][\"heatmap-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {register} from './web_worker_transfer';\n\nexport type Size = {\n width: number;\n height: number;\n};\n\ntype Point2D = {\n x: number;\n y: number;\n};\n\nfunction createImage(image: any, {\n width,\n height\n}: Size, channels: number, data?: Uint8Array | Uint8ClampedArray) {\n if (!data) {\n data = new Uint8Array(width * height * channels);\n } else if (data instanceof Uint8ClampedArray) {\n data = new Uint8Array(data.buffer);\n } else if (data.length !== width * height * channels) {\n throw new RangeError(`mismatched image size. expected: ${data.length} but got: ${width * height * channels}`);\n }\n image.width = width;\n image.height = height;\n image.data = data;\n return image;\n}\n\nfunction resizeImage(image: any, {\n width,\n height\n}: Size, channels: number) {\n if (width === image.width && height === image.height) {\n return;\n }\n\n const newImage = createImage({}, {width, height}, channels);\n\n copyImage(image, newImage, {x: 0, y: 0}, {x: 0, y: 0}, {\n width: Math.min(image.width, width),\n height: Math.min(image.height, height)\n }, channels);\n\n image.width = width;\n image.height = height;\n image.data = newImage.data;\n}\n\nfunction copyImage(srcImg: any, dstImg: any, srcPt: Point2D, dstPt: Point2D, size: Size, channels: number) {\n if (size.width === 0 || size.height === 0) {\n return dstImg;\n }\n\n if (size.width > srcImg.width ||\n size.height > srcImg.height ||\n srcPt.x > srcImg.width - size.width ||\n srcPt.y > srcImg.height - size.height) {\n throw new RangeError('out of range source coordinates for image copy');\n }\n\n if (size.width > dstImg.width ||\n size.height > dstImg.height ||\n dstPt.x > dstImg.width - size.width ||\n dstPt.y > dstImg.height - size.height) {\n throw new RangeError('out of range destination coordinates for image copy');\n }\n\n const srcData = srcImg.data;\n const dstData = dstImg.data;\n\n if (srcData === dstData) throw new Error('srcData equals dstData, so image is already copied');\n\n for (let y = 0; y < size.height; y++) {\n const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels;\n const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels;\n for (let i = 0; i < size.width * channels; i++) {\n dstData[dstOffset + i] = srcData[srcOffset + i];\n }\n }\n return dstImg;\n}\n\n/**\n * @internal\n * An image with alpha color value\n */\nexport class AlphaImage {\n width: number;\n height: number;\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 1, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 1);\n }\n\n clone() {\n return new AlphaImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 1);\n }\n}\n\n/**\n * An object to store image data not premultiplied, because ImageData is not premultiplied.\n * UNPACK_PREMULTIPLY_ALPHA_WEBGL must be used when uploading to a texture.\n */\nexport class RGBAImage {\n width: number;\n height: number;\n\n /**\n * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers.\n */\n data: Uint8Array;\n\n constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n createImage(this, size, 4, data);\n }\n\n resize(size: Size) {\n resizeImage(this, size, 4);\n }\n\n replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean) {\n if (copy) {\n this.data.set(data);\n } else if (data instanceof Uint8ClampedArray) {\n this.data = new Uint8Array(data.buffer);\n } else {\n this.data = data;\n }\n }\n\n clone() {\n return new RGBAImage({width: this.width, height: this.height}, new Uint8Array(this.data));\n }\n\n static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size) {\n copyImage(srcImg, dstImg, srcPt, dstPt, size, 4);\n }\n}\n\nregister('AlphaImage', AlphaImage);\nregister('RGBAImage', RGBAImage);\n","import {RGBAImage} from './image';\nimport {isPowerOfTwo} from './util';\n\nimport type {StylePropertyExpression} from '@maplibre/maplibre-gl-style-spec';\n\nexport type ColorRampParams = {\n expression: StylePropertyExpression;\n evaluationKey: string;\n resolution?: number;\n image?: RGBAImage;\n clips?: Array;\n};\n\n/**\n * Given an expression that should evaluate to a color ramp,\n * return a RGBA image representing that ramp expression.\n */\nexport function renderColorRamp(params: ColorRampParams): RGBAImage {\n const evaluationGlobals = {};\n const width = params.resolution || 256;\n const height = params.clips ? params.clips.length : 1;\n const image = params.image || new RGBAImage({width, height});\n\n if (!isPowerOfTwo(width)) throw new Error(`width is not a power of 2 - ${width}`);\n\n const renderPixel = (stride, index, progress) => {\n evaluationGlobals[params.evaluationKey] = progress;\n const pxColor = params.expression.evaluate(evaluationGlobals as any);\n // the colors are being unpremultiplied because Color uses\n // premultiplied values, and the Texture class expects unpremultiplied ones\n image.data[stride + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a);\n image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a);\n image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a);\n image.data[stride + index + 3] = Math.floor(pxColor.a * 255);\n };\n\n if (!params.clips) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n const progress = i / (width - 1);\n\n renderPixel(0, j, progress);\n }\n } else {\n for (let clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) {\n for (let i = 0, j = 0; i < width; i++, j += 4) {\n // Remap progress between clips\n const progress = i / (width - 1);\n const {start, end} = params.clips[clip];\n const evaluationProgress = start * (1 - progress) + end * progress;\n renderPixel(stride, j, evaluationProgress);\n }\n }\n }\n\n return image;\n}\n","import {StyleLayer} from '../style_layer';\n\nimport {HeatmapBucket} from '../../data/bucket/heatmap_bucket';\nimport {RGBAImage} from '../../util/image';\nimport properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties.g';\nimport {renderColorRamp} from '../../util/color_ramp';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {Texture} from '../../render/texture';\nimport type {Framebuffer} from '../../gl/framebuffer';\nimport type {HeatmapPaintProps} from './heatmap_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A style layer that defines a heatmap\n */\nexport class HeatmapStyleLayer extends StyleLayer {\n\n heatmapFbo: Framebuffer;\n colorRamp: RGBAImage;\n colorRampTexture: Texture;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n createBucket(options: any) {\n return new HeatmapBucket(options);\n }\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n\n // make sure color ramp texture is generated for default heatmap color too\n this._updateColorRamp();\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'heatmap-color') {\n this._updateColorRamp();\n }\n }\n\n _updateColorRamp() {\n const expression = this._transitionablePaint._values['heatmap-color'].value.expression;\n this.colorRamp = renderColorRamp({\n expression,\n evaluationKey: 'heatmapDensity',\n image: this.colorRamp\n });\n this.colorRampTexture = null;\n }\n\n resize() {\n if (this.heatmapFbo) {\n this.heatmapFbo.destroy();\n this.heatmapFbo = null;\n }\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n return false;\n }\n\n hasOffscreenPass() {\n return this.paint.get('heatmap-opacity') !== 0 && this.visibility !== 'none';\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type HillshadePaintProps = {\n \"hillshade-illumination-direction\": DataConstantProperty,\n \"hillshade-illumination-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"hillshade-exaggeration\": DataConstantProperty,\n \"hillshade-shadow-color\": DataConstantProperty,\n \"hillshade-highlight-color\": DataConstantProperty,\n \"hillshade-accent-color\": DataConstantProperty,\n};\n\nexport type HillshadePaintPropsPossiblyEvaluated = {\n \"hillshade-illumination-direction\": number,\n \"hillshade-illumination-anchor\": \"map\" | \"viewport\",\n \"hillshade-exaggeration\": number,\n \"hillshade-shadow-color\": Color,\n \"hillshade-highlight-color\": Color,\n \"hillshade-accent-color\": Color,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"hillshade-illumination-direction\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-direction\"] as any as StylePropertySpecification),\n \"hillshade-illumination-anchor\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-illumination-anchor\"] as any as StylePropertySpecification),\n \"hillshade-exaggeration\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-exaggeration\"] as any as StylePropertySpecification),\n \"hillshade-shadow-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-shadow-color\"] as any as StylePropertySpecification),\n \"hillshade-highlight-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-highlight-color\"] as any as StylePropertySpecification),\n \"hillshade-accent-color\": new DataConstantProperty(styleSpec[\"paint_hillshade\"][\"hillshade-accent-color\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {HillshadePaintPropsPossiblyEvaluated} from './hillshade_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {HillshadePaintProps} from './hillshade_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class HillshadeStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n hasOffscreenPass() {\n return this.paint.get('hillshade-exaggeration') !== 0 && this.visibility !== 'none';\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nmodule.exports = earcut;\nmodule.exports.default = earcut;\n\nfunction earcut(data, holeIndices, dim) {\n\n dim = dim || 2;\n\n var hasHoles = holeIndices && holeIndices.length,\n outerLen = hasHoles ? holeIndices[0] * dim : data.length,\n outerNode = linkedList(data, 0, outerLen, dim, true),\n triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n var minX, minY, maxX, maxY, x, y, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = maxX = data[0];\n minY = maxY = data[1];\n\n for (var i = dim; i < outerLen; i += dim) {\n x = data[i];\n y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n var i, last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n } else {\n for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n var p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n var stop = ear,\n prev, next;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n prev = ear.prev;\n next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n // cut off the triangle\n triangles.push(prev.i / dim | 0);\n triangles.push(ear.i / dim | 0);\n triangles.push(next.i / dim | 0);\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n var p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n // z-order range for the current triangle bbox;\n var minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n var p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles, dim) {\n var p = start;\n do {\n var a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i / dim | 0);\n triangles.push(p.i / dim | 0);\n triangles.push(b.i / dim | 0);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n var a = start;\n do {\n var b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n var c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n var queue = [],\n i, len, start, end, list;\n\n for (i = 0, len = holeIndices.length; i < len; i++) {\n start = holeIndices[i] * dim;\n end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareX);\n\n // process holes from left to right\n for (i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareX(a, b) {\n return a.x - b.x;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and and link it\nfunction eliminateHole(hole, outerNode) {\n var bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n var bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n var p = outerNode,\n hx = hole.x,\n hy = hole.y,\n qx = -Infinity,\n m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n do {\n if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n var stop = m,\n mx = m.x,\n my = m.y,\n tanMin = Infinity,\n tan;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n var p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n var i, p, q, e, tail, numMerges, pSize, qSize,\n inSize = 1;\n\n do {\n p = list;\n list = null;\n tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n q = p;\n pSize = 0;\n for (i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n var p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n var o1 = sign(area(p1, q1, p2));\n var o2 = sign(area(p1, q1, q2));\n var o3 = sign(area(p2, q2, p1));\n var o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n var p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n var p = a,\n inside = false,\n px = (a.x + b.x) / 2,\n py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n var a2 = new Node(a.i, a.x, a.y),\n b2 = new Node(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n var p = new Node(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n // vertex index in coordinates array\n this.i = i;\n\n // vertex coordinates\n this.x = x;\n this.y = y;\n\n // previous and next vertex nodes in a polygon ring\n this.prev = null;\n this.next = null;\n\n // z-order curve value\n this.z = 0;\n\n // previous and next nodes in z-order\n this.prevZ = null;\n this.nextZ = null;\n\n // indicates whether this is a steiner point\n this.steiner = false;\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nearcut.deviation = function (data, holeIndices, dim, triangles) {\n var hasHoles = holeIndices && holeIndices.length;\n var outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (var i = 0, len = holeIndices.length; i < len; i++) {\n var start = holeIndices[i] * dim;\n var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n var trianglesArea = 0;\n for (i = 0; i < triangles.length; i += 3) {\n var a = triangles[i] * dim;\n var b = triangles[i + 1] * dim;\n var c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n};\n\nfunction signedArea(data, start, end, dim) {\n var sum = 0;\n for (var i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nearcut.flatten = function (data) {\n var dim = data[0][0].length,\n result = {vertices: [], holes: [], dimensions: dim},\n holeIndex = 0;\n\n for (var i = 0; i < data.length; i++) {\n for (var j = 0; j < data[i].length; j++) {\n for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);\n }\n if (i > 0) {\n holeIndex += data[i - 1].length;\n result.holes.push(holeIndex);\n }\n }\n return result;\n};\n","\nexport default function quickselect(arr, k, left, right, compare) {\n quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);\n}\n\nfunction quickselectStep(arr, k, left, right, compare) {\n\n while (right > left) {\n if (right - left > 600) {\n var n = right - left + 1;\n var m = k - left + 1;\n var z = Math.log(n);\n var s = 0.5 * Math.exp(2 * z / 3);\n var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselectStep(arr, k, newLeft, newRight, compare);\n }\n\n var t = arr[k];\n var i = left;\n var j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\nfunction swap(arr, i, j) {\n var tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import quickselect from 'quickselect';\n\nimport {calculateSignedArea} from './util';\n\nimport type Point from '@mapbox/point-geometry';\n\n// classifies an array of rings into polygons with outer rings and holes\nexport function classifyRings(rings: Array>, maxRings: number) {\n const len = rings.length;\n\n if (len <= 1) return [rings];\n\n const polygons = [];\n let polygon,\n ccw;\n\n for (let i = 0; i < len; i++) {\n const area = calculateSignedArea(rings[i]);\n if (area === 0) continue;\n\n (rings[i] as any).area = Math.abs(area);\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n (polygon as any).push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n // Earcut performance degrades with the # of rings in a polygon. For this\n // reason, we limit strip out all but the `maxRings` largest rings.\n if (maxRings > 1) {\n for (let j = 0; j < polygons.length; j++) {\n if (polygons[j].length <= maxRings) continue;\n quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);\n polygons[j] = polygons[j].slice(0, maxRings);\n }\n }\n\n return polygons;\n}\n\nfunction compareAreas(a, b) {\n return b.area - a.area;\n}\n","import type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\n\nimport type {\n BucketFeature,\n PopulateParameters\n} from '../bucket';\nimport {PossiblyEvaluated} from '../../style/properties';\n\ntype PatternStyleLayers = Array | Array | Array;\n\nexport function hasPattern(type: string, layers: PatternStyleLayers, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n let hasPattern = false;\n\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n if (!patternProperty.isConstant()) {\n hasPattern = true;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern) {\n hasPattern = true;\n patterns[constantPattern.to] = true;\n patterns[constantPattern.from] = true;\n }\n }\n\n return hasPattern;\n}\n\nexport function addPatternDependencies(type: string, layers: PatternStyleLayers, patternFeature: BucketFeature, zoom: number, options: PopulateParameters) {\n const patterns = options.patternDependencies;\n for (const layer of layers) {\n const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`);\n\n const patternPropertyValue = patternProperty.value;\n if (patternPropertyValue.kind !== 'constant') {\n let min = patternPropertyValue.evaluate({zoom: zoom - 1}, patternFeature, {}, options.availableImages);\n let mid = patternPropertyValue.evaluate({zoom}, patternFeature, {}, options.availableImages);\n let max = patternPropertyValue.evaluate({zoom: zoom + 1}, patternFeature, {}, options.availableImages);\n min = min && min.name ? min.name : min;\n mid = mid && mid.name ? mid.name : mid;\n max = max && max.name ? max.name : max;\n // add to patternDependencies\n patterns[min] = true;\n patterns[mid] = true;\n patterns[max] = true;\n\n // save for layout\n patternFeature.patterns[layer.id] = {min, mid, max};\n }\n }\n return patternFeature;\n}\n","import {FillLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './fill_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {LineIndexArray, TriangleIndexArray} from '../index_array_type';\nimport earcut from 'earcut';\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {FillStyleLayer} from '../../style/style_layer/fill_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport class FillBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n\n layoutVertexArray: FillLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n indexArray2: LineIndexArray;\n indexBuffer2: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n segments2: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n\n this.layoutVertexArray = new FillLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.indexArray2 = new LineIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.segments2 = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('fill', this.layers, options);\n const fillSortKey = this.layers[0].layout.get('fill-sort-key');\n const sortFeaturesByKey = !fillSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternFeature = addPatternDependencies('fill', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending(): boolean {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.indexBuffer2 = context.createIndexBuffer(this.indexArray2);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.indexBuffer2.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.segments2.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {\n [_: string]: ImagePosition;\n }) {\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n\n const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n const triangleIndex = triangleSegment.vertexLength;\n\n const flattened = [];\n const holeIndices = [];\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2);\n const lineIndex = lineSegment.vertexLength;\n\n this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y);\n this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex);\n flattened.push(ring[0].x);\n flattened.push(ring[0].y);\n\n for (let i = 1; i < ring.length; i++) {\n this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y);\n this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);\n flattened.push(ring[i].x);\n flattened.push(ring[i].y);\n }\n\n lineSegment.vertexLength += ring.length;\n lineSegment.primitiveLength += ring.length;\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let i = 0; i < indices.length; i += 3) {\n this.indexArray.emplaceBack(\n triangleIndex + indices[i],\n triangleIndex + indices[i + 1],\n triangleIndex + indices[i + 2]);\n }\n\n triangleSegment.vertexLength += numVertices;\n triangleSegment.primitiveLength += indices.length / 3;\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillBucket', FillBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FillLayoutProps = {\n \"fill-sort-key\": DataDrivenProperty,\n};\n\nexport type FillLayoutPropsPossiblyEvaluated = {\n \"fill-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"fill-sort-key\": new DataDrivenProperty(styleSpec[\"layout_fill\"][\"fill-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type FillPaintProps = {\n \"fill-antialias\": DataConstantProperty,\n \"fill-opacity\": DataDrivenProperty,\n \"fill-color\": DataDrivenProperty,\n \"fill-outline-color\": DataDrivenProperty,\n \"fill-translate\": DataConstantProperty<[number, number]>,\n \"fill-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-pattern\": CrossFadedDataDrivenProperty,\n};\n\nexport type FillPaintPropsPossiblyEvaluated = {\n \"fill-antialias\": boolean,\n \"fill-opacity\": PossiblyEvaluatedPropertyValue,\n \"fill-color\": PossiblyEvaluatedPropertyValue,\n \"fill-outline-color\": PossiblyEvaluatedPropertyValue,\n \"fill-translate\": [number, number],\n \"fill-translate-anchor\": \"map\" | \"viewport\",\n \"fill-pattern\": PossiblyEvaluatedPropertyValue>,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-antialias\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-antialias\"] as any as StylePropertySpecification),\n \"fill-opacity\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-opacity\"] as any as StylePropertySpecification),\n \"fill-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-color\"] as any as StylePropertySpecification),\n \"fill-outline-color\": new DataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-outline-color\"] as any as StylePropertySpecification),\n \"fill-translate\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate\"] as any as StylePropertySpecification),\n \"fill-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill\"][\"fill-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill\"][\"fill-pattern\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillBucket} from '../../data/bucket/fill_bucket';\nimport {polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties.g';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';\n\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type Point from '@mapbox/point-geometry';\nimport type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class FillStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n const outlineColor = this.paint._values['fill-outline-color'];\n if (outlineColor.value.kind === 'constant' && outlineColor.value.value === undefined) {\n this.paint._values['fill-outline-color'] = this.paint._values['fill-color'];\n }\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-translate'),\n this.paint.get('fill-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n return polygonIntersectsMultiPolygon(translatedPolygon, geometry);\n }\n\n isTileClipped() {\n return true;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nconst layout = createLayout([\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_normal_ed', components: 4, type: 'Int16'},\n], 4);\n\nexport const centroidAttributes = createLayout([\n {name: 'a_centroid', components: 2, type: 'Int16'}\n], 4);\n\nexport default layout;\nexport const {members, size, alignment} = layout;\n","'use strict';\n\nvar Point = require('@mapbox/point-geometry');\n\nmodule.exports = VectorTileFeature;\n\nfunction VectorTileFeature(pbf, end, extent, keys, values) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n\n pbf.readFields(readFeature, this, end);\n}\n\nfunction readFeature(tag, feature, pbf) {\n if (tag == 1) feature.id = pbf.readVarint();\n else if (tag == 2) readTag(pbf, feature);\n else if (tag == 3) feature.type = pbf.readVarint();\n else if (tag == 4) feature._geometry = pbf.pos;\n}\n\nfunction readTag(pbf, feature) {\n var end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var key = feature._keys[pbf.readVarint()],\n value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n\nVectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\nVectorTileFeature.prototype.loadGeometry = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n lines = [],\n line;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) { // moveTo\n if (line) lines.push(line);\n line = [];\n }\n\n line.push(new Point(x, y));\n\n } else if (cmd === 7) {\n\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].clone()); // closePolygon\n }\n\n } else {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n if (line) lines.push(line);\n\n return lines;\n};\n\nVectorTileFeature.prototype.bbox = function() {\n var pbf = this._pbf;\n pbf.pos = this._geometry;\n\n var end = pbf.readVarint() + pbf.pos,\n cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n x1 = Infinity,\n x2 = -Infinity,\n y1 = Infinity,\n y2 = -Infinity;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n var cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n\n } else if (cmd !== 7) {\n throw new Error('unknown command ' + cmd);\n }\n }\n\n return [x1, y1, x2, y2];\n};\n\nVectorTileFeature.prototype.toGeoJSON = function(x, y, z) {\n var size = this.extent * Math.pow(2, z),\n x0 = this.extent * x,\n y0 = this.extent * y,\n coords = this.loadGeometry(),\n type = VectorTileFeature.types[this.type],\n i, j;\n\n function project(line) {\n for (var j = 0; j < line.length; j++) {\n var p = line[j], y2 = 180 - (p.y + y0) * 360 / size;\n line[j] = [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90\n ];\n }\n }\n\n switch (this.type) {\n case 1:\n var points = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n project(coords);\n break;\n\n case 2:\n for (i = 0; i < coords.length; i++) {\n project(coords[i]);\n }\n break;\n\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n project(coords[i][j]);\n }\n }\n break;\n }\n\n if (coords.length === 1) {\n coords = coords[0];\n } else {\n type = 'Multi' + type;\n }\n\n var result = {\n type: \"Feature\",\n geometry: {\n type: type,\n coordinates: coords\n },\n properties: this.properties\n };\n\n if ('id' in this) {\n result.id = this.id;\n }\n\n return result;\n};\n\n// classifies an array of rings into polygons with outer rings and holes\n\nfunction classifyRings(rings) {\n var len = rings.length;\n\n if (len <= 1) return [rings];\n\n var polygons = [],\n polygon,\n ccw;\n\n for (var i = 0; i < len; i++) {\n var area = signedArea(rings[i]);\n if (area === 0) continue;\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n return polygons;\n}\n\nfunction signedArea(ring) {\n var sum = 0;\n for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n","'use strict';\n\nvar VectorTileFeature = require('./vectortilefeature.js');\n\nmodule.exports = VectorTileLayer;\n\nfunction VectorTileLayer(pbf, end) {\n // Public\n this.version = 1;\n this.name = null;\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n}\n\nfunction readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n}\n\nfunction readValueMessage(pbf) {\n var value = null,\n end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n var tag = pbf.readVarint() >> 3;\n\n value = tag === 1 ? pbf.readString() :\n tag === 2 ? pbf.readFloat() :\n tag === 3 ? pbf.readDouble() :\n tag === 4 ? pbf.readVarint64() :\n tag === 5 ? pbf.readVarint() :\n tag === 6 ? pbf.readSVarint() :\n tag === 7 ? pbf.readBoolean() : null;\n }\n\n return value;\n}\n\n// return feature `i` from this layer as a `VectorTileFeature`\nVectorTileLayer.prototype.feature = function(i) {\n if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');\n\n this._pbf.pos = this._features[i];\n\n var end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n};\n","'use strict';\n\nvar VectorTileLayer = require('./vectortilelayer');\n\nmodule.exports = VectorTile;\n\nfunction VectorTile(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n}\n\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n}\n\n","module.exports.VectorTile = require('./lib/vectortile.js');\nmodule.exports.VectorTileFeature = require('./lib/vectortilefeature.js');\nmodule.exports.VectorTileLayer = require('./lib/vectortilelayer.js');\n","import {FillExtrusionLayoutArray, PosArray} from '../array_types.g';\n\nimport {members as layoutAttributes, centroidAttributes} from './fill_extrusion_attributes';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport earcut from 'earcut';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {classifyRings} from '../../util/classify_rings';\nconst EARCUT_MAX_RINGS = 500;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\n\nimport type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type Point from '@mapbox/point-geometry';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nconst FACTOR = Math.pow(2, 13);\n\nfunction addVertex(vertexArray, x, y, nx, ny, nz, t, e) {\n vertexArray.emplaceBack(\n // a_pos\n x,\n y,\n // a_normal_ed: 3-component normal and 1-component edgedistance\n Math.floor(nx * FACTOR) * 2 + t,\n ny * FACTOR * 2,\n nz * FACTOR * 2,\n // edgedistance (used for wrapping patterns around extrusion sides)\n Math.round(e)\n );\n}\n\nexport class FillExtrusionBucket implements Bucket {\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n layoutVertexArray: FillExtrusionLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n centroidVertexArray: PosArray;\n centroidVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n features: Array;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n\n this.layoutVertexArray = new FillExtrusionLayoutArray();\n this.centroidVertexArray = new PosArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.features = [];\n this.hasPattern = hasPattern('fill-extrusion', this.layers, options);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const bucketFeature: BucketFeature = {\n id,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n properties: feature.properties,\n type: feature.type,\n patterns: {}\n };\n\n if (this.hasPattern) {\n this.features.push(addPatternDependencies('fill-extrusion', this.layers, bucketFeature, this.zoom, options));\n } else {\n this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {});\n }\n\n options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);\n }\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.features) {\n const {geometry} = feature;\n this.addFeature(feature, geometry, feature.index, canonical, imagePositions);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.centroidVertexBuffer.destroy();\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const centroid = {x: 0, y: 0, vertexCount: 0};\n for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {\n let numVertices = 0;\n for (const ring of polygon) {\n numVertices += ring.length;\n }\n let segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (isEntirelyOutside(ring)) {\n continue;\n }\n\n let edgeDistance = 0;\n\n for (let p = 0; p < ring.length; p++) {\n const p1 = ring[p];\n\n if (p >= 1) {\n const p2 = ring[p - 1];\n\n if (!isBoundaryEdge(p1, p2)) {\n if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);\n }\n\n const perp = p1.sub(p2)._perp()._unit();\n const dist = p2.dist(p1);\n if (edgeDistance + dist > 32768) edgeDistance = 0;\n\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p1.x;\n centroid.y += 2 * p1.y;\n centroid.vertexCount += 2;\n\n edgeDistance += dist;\n\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance);\n addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance);\n centroid.x += 2 * p2.x;\n centroid.y += 2 * p2.y;\n centroid.vertexCount += 2;\n\n const bottomRight = segment.vertexLength;\n\n // ┌──────┐\n // │ 0 1 │ Counter-clockwise winding order.\n // │ │ Triangle 1: 0 => 2 => 1\n // │ 2 3 │ Triangle 2: 1 => 2 => 3\n // └──────┘\n this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);\n this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n }\n }\n }\n\n }\n\n if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {\n segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);\n }\n\n //Only triangulate and draw the area of the feature if it is a polygon\n //Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined\n if (vectorTileFeatureTypes[feature.type] !== 'Polygon')\n continue;\n\n const flattened = [];\n const holeIndices = [];\n const triangleIndex = segment.vertexLength;\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n\n addVertex(this.layoutVertexArray, p.x, p.y, 0, 0, 1, 1, 0);\n centroid.x += p.x;\n centroid.y += p.y;\n centroid.vertexCount += 1;\n\n flattened.push(p.x);\n flattened.push(p.y);\n }\n\n }\n\n const indices = earcut(flattened, holeIndices);\n\n for (let j = 0; j < indices.length; j += 3) {\n // Counter-clockwise winding order.\n this.indexArray.emplaceBack(\n triangleIndex + indices[j],\n triangleIndex + indices[j + 2],\n triangleIndex + indices[j + 1]);\n }\n\n segment.primitiveLength += indices.length / 3;\n segment.vertexLength += numVertices;\n }\n\n // remember polygon centroid to calculate elevation in GPU\n for (let i = 0; i < centroid.vertexCount; i++) {\n this.centroidVertexArray.emplaceBack(\n Math.floor(centroid.x / centroid.vertexCount),\n Math.floor(centroid.y / centroid.vertexCount)\n );\n }\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n}\n\nregister('FillExtrusionBucket', FillExtrusionBucket, {omit: ['layers', 'features']});\n\nfunction isBoundaryEdge(p1, p2) {\n return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) ||\n (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT));\n}\n\nfunction isEntirelyOutside(ring) {\n return ring.every(p => p.x < 0) ||\n ring.every(p => p.x > EXTENT) ||\n ring.every(p => p.y < 0) ||\n ring.every(p => p.y > EXTENT);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type FillExtrusionPaintProps = {\n \"fill-extrusion-opacity\": DataConstantProperty,\n \"fill-extrusion-color\": DataDrivenProperty,\n \"fill-extrusion-translate\": DataConstantProperty<[number, number]>,\n \"fill-extrusion-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"fill-extrusion-pattern\": CrossFadedDataDrivenProperty,\n \"fill-extrusion-height\": DataDrivenProperty,\n \"fill-extrusion-base\": DataDrivenProperty,\n \"fill-extrusion-vertical-gradient\": DataConstantProperty,\n};\n\nexport type FillExtrusionPaintPropsPossiblyEvaluated = {\n \"fill-extrusion-opacity\": number,\n \"fill-extrusion-color\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-translate\": [number, number],\n \"fill-extrusion-translate-anchor\": \"map\" | \"viewport\",\n \"fill-extrusion-pattern\": PossiblyEvaluatedPropertyValue>,\n \"fill-extrusion-height\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-base\": PossiblyEvaluatedPropertyValue,\n \"fill-extrusion-vertical-gradient\": boolean,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"fill-extrusion-opacity\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-opacity\"] as any as StylePropertySpecification),\n \"fill-extrusion-color\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-color\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate\"] as any as StylePropertySpecification),\n \"fill-extrusion-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-translate-anchor\"] as any as StylePropertySpecification),\n \"fill-extrusion-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-pattern\"] as any as StylePropertySpecification),\n \"fill-extrusion-height\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-height\"] as any as StylePropertySpecification),\n \"fill-extrusion-base\": new DataDrivenProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-base\"] as any as StylePropertySpecification),\n \"fill-extrusion-vertical-gradient\": new DataConstantProperty(styleSpec[\"paint_fill-extrusion\"][\"fill-extrusion-vertical-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport {FillExtrusionBucket} from '../../data/bucket/fill_extrusion_bucket';\nimport {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests';\nimport {translateDistance, translate} from '../query_utils';\nimport properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\nimport {mat4, vec4} from 'gl-matrix';\nimport Point from '@mapbox/point-geometry';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {BucketParameters} from '../../data/bucket';\nimport type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class Point3D extends Point {\n z: number;\n}\n\nexport class FillExtrusionStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n createBucket(parameters: BucketParameters) {\n return new FillExtrusionBucket(parameters);\n }\n\n queryRadius(): number {\n return translateDistance(this.paint.get('fill-extrusion-translate'));\n }\n\n is3D(): boolean {\n return true;\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number,\n pixelPosMatrix: mat4\n ): boolean | number {\n\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('fill-extrusion-translate'),\n this.paint.get('fill-extrusion-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n\n const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState);\n const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState);\n\n const projectedQueryGeometry = projectQueryGeometry(translatedPolygon, pixelPosMatrix, transform, 0);\n\n const projected = projectExtrusion(geometry, base, height, pixelPosMatrix);\n const projectedBase = projected[0];\n const projectedTop = projected[1];\n return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry);\n }\n}\n\nfunction dot(a, b) {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function getIntersectionDistance(projectedQueryGeometry: Array, projectedFace: Array) {\n\n if (projectedQueryGeometry.length === 1) {\n // For point queries calculate the z at which the point intersects the face\n // using barycentric coordinates.\n\n // Find the barycentric coordinates of the projected point within the first\n // triangle of the face, using only the xy plane. It doesn't matter if the\n // point is outside the first triangle because all the triangles in the face\n // are in the same plane.\n //\n // Check whether points are coincident and use other points if they are.\n let i = 0;\n const a = projectedFace[i++];\n let b;\n while (!b || a.equals(b)) {\n b = projectedFace[i++];\n if (!b) return Infinity;\n }\n\n // Loop until point `c` is not colinear with points `a` and `b`.\n for (; i < projectedFace.length; i++) {\n const c = projectedFace[i];\n\n const p = projectedQueryGeometry[0];\n\n const ab = b.sub(a);\n const ac = c.sub(a);\n const ap = p.sub(a);\n\n const dotABAB = dot(ab, ab);\n const dotABAC = dot(ab, ac);\n const dotACAC = dot(ac, ac);\n const dotAPAB = dot(ap, ab);\n const dotAPAC = dot(ap, ac);\n const denom = dotABAB * dotACAC - dotABAC * dotABAC;\n\n const v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom;\n const w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom;\n const u = 1 - v - w;\n\n // Use the barycentric weighting along with the original triangle z coordinates to get the point of intersection.\n const distance = a.z * u + b.z * v + c.z * w;\n\n if (isFinite(distance)) return distance;\n }\n\n return Infinity;\n\n } else {\n // The counts as closest is less clear when the query is a box. This\n // returns the distance to the nearest point on the face, whether it is\n // within the query or not. It could be more correct to return the\n // distance to the closest point within the query box but this would be\n // more complicated and expensive to calculate with little benefit.\n let closestDistance = Infinity;\n for (const p of projectedFace) {\n closestDistance = Math.min(closestDistance, p.z);\n }\n return closestDistance;\n }\n}\n\nfunction checkIntersection(projectedBase: Array>, projectedTop: Array>, projectedQueryGeometry: Array) {\n let closestDistance = Infinity;\n\n if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) {\n closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]);\n }\n\n for (let r = 0; r < projectedTop.length; r++) {\n const ringTop = projectedTop[r];\n const ringBase = projectedBase[r];\n for (let p = 0; p < ringTop.length - 1; p++) {\n const topA = ringTop[p];\n const topB = ringTop[p + 1];\n const baseA = ringBase[p];\n const baseB = ringBase[p + 1];\n const face = [topA, topB, baseB, baseA, topA];\n if (polygonIntersectsPolygon(projectedQueryGeometry, face)) {\n closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face));\n }\n }\n }\n\n return closestDistance === Infinity ? false : closestDistance;\n}\n\n/*\n * Project the geometry using matrix `m`. This is essentially doing\n * `vec4.transformMat4([], [p.x, p.y, z, 1], m)` but the multiplication\n * is inlined so that parts of the projection that are the same across\n * different points can only be done once. This produced a measurable\n * performance improvement.\n */\nfunction projectExtrusion(geometry: Array>, zBase: number, zTop: number, m: mat4): [Array>, Array>] {\n const projectedBase = [] as Array>;\n const projectedTop = [] as Array>;\n const baseXZ = m[8] * zBase;\n const baseYZ = m[9] * zBase;\n const baseZZ = m[10] * zBase;\n const baseWZ = m[11] * zBase;\n const topXZ = m[8] * zTop;\n const topYZ = m[9] * zTop;\n const topZZ = m[10] * zTop;\n const topWZ = m[11] * zTop;\n\n for (const r of geometry) {\n const ringBase = [] as Array;\n const ringTop = [] as Array;\n for (const p of r) {\n const x = p.x;\n const y = p.y;\n\n const sX = m[0] * x + m[4] * y + m[12];\n const sY = m[1] * x + m[5] * y + m[13];\n const sZ = m[2] * x + m[6] * y + m[14];\n const sW = m[3] * x + m[7] * y + m[15];\n\n const baseX = sX + baseXZ;\n const baseY = sY + baseYZ;\n const baseZ = sZ + baseZZ;\n const baseW = sW + baseWZ;\n\n const topX = sX + topXZ;\n const topY = sY + topYZ;\n const topZ = sZ + topZZ;\n const topW = sW + topWZ;\n\n const b = new Point(baseX / baseW, baseY / baseW) as Point3D;\n b.z = baseZ / baseW;\n ringBase.push(b);\n\n const t = new Point(topX / topW, topY / topW) as Point3D;\n t.z = topZ / topW;\n ringTop.push(t);\n }\n projectedBase.push(ringBase);\n projectedTop.push(ringTop);\n }\n return [projectedBase, projectedTop];\n}\n\nfunction projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4, transform: Transform, z: number) {\n const projectedQueryGeometry = [];\n for (const p of queryGeometry) {\n const v = [p.x, p.y, z, 1] as vec4;\n vec4.transformMat4(v, v, pixelPosMatrix);\n projectedQueryGeometry.push(new Point(v[0] / v[3], v[1] / v[3]));\n }\n return projectedQueryGeometry;\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributes = createLayout([\n {name: 'a_pos_normal', components: 2, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint8'}\n], 4);\n\nexport const {members, size, alignment} = lineLayoutAttributes;\n","import {createLayout} from '../../util/struct_array';\n\nexport const lineLayoutAttributesExt = createLayout([\n {name: 'a_uv_x', components: 1, type: 'Float32'},\n {name: 'a_split_index', components: 1, type: 'Float32'},\n]);\n\nexport const {members, size, alignment} = lineLayoutAttributesExt;\n","import {LineLayoutArray, LineExtLayoutArray} from '../array_types.g';\n\nimport {members as layoutAttributes} from './line_attributes';\nimport {members as layoutAttributesExt} from './line_attributes_ext';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray} from '../index_array_type';\nimport {EXTENT} from '../extent';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {register} from '../../util/web_worker_transfer';\nimport {hasPattern, addPatternDependencies} from './pattern_bucket_features';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\n\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n BucketFeature,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Segment} from '../segment';\nimport {RGBAImage} from '../../util/image';\nimport type {Context} from '../../gl/context';\nimport type {Texture} from '../../render/texture';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\n// NOTE ON EXTRUDE SCALE:\n// scale the extrusion vector so that the normal length is this value.\n// contains the \"texture\" normals (-1..1). this is distinct from the extrude\n// normals for line joins, because the x-value remains 0 for the texture\n// normal array, while the extrude normal actually moves the vertex to create\n// the acute/bevelled line join.\nconst EXTRUDE_SCALE = 63;\n\n/*\n * Sharp corners cause dashed lines to tilt because the distance along the line\n * is the same at both the inner and outer corners. To improve the appearance of\n * dashed lines we add extra points near sharp corners so that a smaller part\n * of the line is tilted.\n *\n * COS_HALF_SHARP_CORNER controls how sharp a corner has to be for us to add an\n * extra vertex. The default is 75 degrees.\n *\n * The newly created vertices are placed SHARP_CORNER_OFFSET pixels from the corner.\n */\nconst COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180));\nconst SHARP_CORNER_OFFSET = 15;\n\n// Angle per triangle for approximating round line joins.\nconst DEG_PER_TRIANGLE = 20;\n\n// The number of bits that is used to store the line distance in the buffer.\nconst LINE_DISTANCE_BUFFER_BITS = 15;\n\n// We don't have enough bits for the line distance as we'd like to have, so\n// use this value to scale the line distance (in tile units) down to a smaller\n// value. This lets us store longer distances while sacrificing precision.\nconst LINE_DISTANCE_SCALE = 1 / 2;\n\n// The maximum line distance, in tile units, that fits in the buffer.\nconst MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE;\n\ntype LineClips = {\n start: number;\n end: number;\n};\n\ntype GradientTexture = {\n texture?: Texture;\n gradient?: RGBAImage;\n version?: number;\n};\n\n/**\n * @internal\n * Line bucket class\n */\nexport class LineBucket implements Bucket {\n distance: number;\n totalDistance: number;\n maxLineLength: number;\n scaledDistance: number;\n lineClips?: LineClips;\n\n e1: number;\n e2: number;\n\n index: number;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n gradients: {[x: string]: GradientTexture};\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n patternFeatures: Array;\n lineClipsArray: Array;\n\n layoutVertexArray: LineLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n layoutVertexArray2: LineExtLayoutArray;\n layoutVertexBuffer2: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n hasPattern: boolean;\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n uploaded: boolean;\n\n constructor(options: BucketParameters) {\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.hasPattern = false;\n this.patternFeatures = [];\n this.lineClipsArray = [];\n this.gradients = {};\n this.layers.forEach(layer => {\n this.gradients[layer.id] = {};\n });\n\n this.layoutVertexArray = new LineLayoutArray();\n this.layoutVertexArray2 = new LineExtLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);\n this.segments = new SegmentVector();\n this.maxLineLength = 0;\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n this.hasPattern = hasPattern('line', this.layers, options);\n const lineSortKey = this.layers[0].layout.get('line-sort-key');\n const sortFeaturesByKey = !lineSortKey.isConstant();\n const bucketFeatures: BucketFeature[] = [];\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n const needGeometry = this.layers[0]._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n\n if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;\n\n const sortKey = sortFeaturesByKey ?\n lineSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const bucketFeature: BucketFeature = {\n id,\n properties: feature.properties,\n type: feature.type,\n sourceLayerIndex,\n index,\n geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),\n patterns: {},\n sortKey\n };\n\n bucketFeatures.push(bucketFeature);\n }\n\n if (sortFeaturesByKey) {\n bucketFeatures.sort((a, b) => {\n return (a.sortKey) - (b.sortKey);\n });\n }\n\n for (const bucketFeature of bucketFeatures) {\n const {geometry, index, sourceLayerIndex} = bucketFeature;\n\n if (this.hasPattern) {\n const patternBucketFeature = addPatternDependencies('line', this.layers, bucketFeature, this.zoom, options);\n // pattern features are added only once the pattern is loaded into the image atlas\n // so are stored during populate until later updated with positions by tile worker in addFeatures\n this.patternFeatures.push(patternBucketFeature);\n } else {\n this.addFeature(bucketFeature, geometry, index, canonical, {});\n }\n\n const feature = features[index].feature;\n options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index);\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);\n }\n\n addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n for (const feature of this.patternFeatures) {\n this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);\n }\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0;\n }\n\n uploadPending() {\n return !this.uploaded || this.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded) {\n if (this.layoutVertexArray2.length !== 0) {\n this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, layoutAttributesExt);\n }\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n }\n this.programConfigurations.upload(context);\n this.uploaded = true;\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n }\n\n lineFeatureClips(feature: BucketFeature): LineClips | undefined {\n if (!!feature.properties && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_start') && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_end')) {\n const start = +feature.properties['mapbox_clip_start'];\n const end = +feature.properties['mapbox_clip_end'];\n return {start, end};\n }\n }\n\n addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {\n const layout = this.layers[0].layout;\n const join = layout.get('line-join').evaluate(feature, {});\n const cap = layout.get('line-cap');\n const miterLimit = layout.get('line-miter-limit');\n const roundLimit = layout.get('line-round-limit');\n this.lineClips = this.lineFeatureClips(feature);\n\n for (const line of geometry) {\n this.addLine(line, feature, join, cap, miterLimit, roundLimit);\n }\n\n this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);\n }\n\n addLine(vertices: Array, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number) {\n this.distance = 0;\n this.scaledDistance = 0;\n this.totalDistance = 0;\n\n if (this.lineClips) {\n this.lineClipsArray.push(this.lineClips);\n // Calculate the total distance, in tile units, of this tiled line feature\n for (let i = 0; i < vertices.length - 1; i++) {\n this.totalDistance += vertices[i].dist(vertices[i + 1]);\n }\n this.updateScaledDistance();\n this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);\n }\n\n const isPolygon = vectorTileFeatureTypes[feature.type] === 'Polygon';\n\n // If the line has duplicate vertices at the ends, adjust start/length to remove them.\n let len = vertices.length;\n while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) {\n len--;\n }\n let first = 0;\n while (first < len - 1 && vertices[first].equals(vertices[first + 1])) {\n first++;\n }\n\n // Ignore invalid geometry.\n if (len < (isPolygon ? 3 : 2)) return;\n\n if (join === 'bevel') miterLimit = 1.05;\n\n const sharpCornerOffset = this.overscaling <= 16 ?\n SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) :\n 0;\n\n // we could be more precise, but it would only save a negligible amount of space\n const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray);\n\n let currentVertex: Point;\n let prevVertex: Point;\n let nextVertex: Point;\n let prevNormal: Point;\n let nextNormal: Point;\n\n // the last two vertices added\n this.e1 = this.e2 = -1;\n\n if (isPolygon) {\n currentVertex = vertices[len - 2];\n nextNormal = vertices[first].sub(currentVertex)._unit()._perp();\n }\n\n for (let i = first; i < len; i++) {\n\n nextVertex = i === len - 1 ?\n (isPolygon ? vertices[first + 1] : undefined) : // if it's a polygon, treat the last vertex like the first\n vertices[i + 1]; // just the next vertex\n\n // if two consecutive vertices exist, skip the current one\n if (nextVertex && vertices[i].equals(nextVertex)) continue;\n\n if (nextNormal) prevNormal = nextNormal;\n if (currentVertex) prevVertex = currentVertex;\n\n currentVertex = vertices[i];\n\n // Calculate the normal towards the next vertex in this line. In case\n // there is no next vertex, pretend that the line is continuing straight,\n // meaning that we are just using the previous normal.\n nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal;\n\n // If we still don't have a previous normal, this is the beginning of a\n // non-closed line, so we're doing a straight \"join\".\n prevNormal = prevNormal || nextNormal;\n\n // Determine the normal of the join extrusion. It is the angle bisector\n // of the segments between the previous line and the next line.\n // In the case of 180° angles, the prev and next normals cancel each other out:\n // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be\n // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle\n // below will also become 0 and miterLength will become Infinity.\n let joinNormal = prevNormal.add(nextNormal);\n if (joinNormal.x !== 0 || joinNormal.y !== 0) {\n joinNormal._unit();\n }\n /* joinNormal prevNormal\n * ↖ ↑\n * .________. prevVertex\n * |\n * nextNormal ← | currentVertex\n * |\n * nextVertex !\n *\n */\n\n // calculate cosines of the angle (and its half) using dot product\n const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y;\n const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y;\n\n // Calculate the length of the miter (the ratio of the miter to the width)\n // as the inverse of cosine of the angle between next and join normals\n const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity;\n\n // approximate angle from cosine\n const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle);\n\n const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex;\n const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0;\n\n if (isSharpCorner && i > first) {\n const prevSegmentLength = currentVertex.dist(prevVertex);\n if (prevSegmentLength > 2 * sharpCornerOffset) {\n const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round());\n this.updateDistance(prevVertex, newPrevVertex);\n this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment);\n prevVertex = newPrevVertex;\n }\n }\n\n // The join if a middle vertex, otherwise the cap.\n const middleVertex = prevVertex && nextVertex;\n let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap;\n\n if (middleVertex && currentJoin === 'round') {\n if (miterLength < roundLimit) {\n currentJoin = 'miter';\n } else if (miterLength <= 2) {\n currentJoin = 'fakeround';\n }\n }\n\n if (currentJoin === 'miter' && miterLength > miterLimit) {\n currentJoin = 'bevel';\n }\n\n if (currentJoin === 'bevel') {\n // The maximum extrude length is 128 / 63 = 2 times the width of the line\n // so if miterLength >= 2 we need to draw a different type of bevel here.\n if (miterLength > 2) currentJoin = 'flipbevel';\n\n // If the miterLength is really small and the line bevel wouldn't be visible,\n // just draw a miter join to save a triangle.\n if (miterLength < miterLimit) currentJoin = 'miter';\n }\n\n // Calculate how far along the line the currentVertex is\n if (prevVertex) this.updateDistance(prevVertex, currentVertex);\n\n if (currentJoin === 'miter') {\n\n joinNormal._mult(miterLength);\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n\n } else if (currentJoin === 'flipbevel') {\n // miter is too big, flip the direction to make a beveled join\n\n if (miterLength > 100) {\n // Almost parallel lines\n joinNormal = nextNormal.mult(-1);\n\n } else {\n const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag();\n joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1));\n }\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);\n this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment);\n\n } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') {\n const offset = -Math.sqrt(miterLength * miterLength - 1);\n const offsetA = lineTurnsLeft ? offset : 0;\n const offsetB = lineTurnsLeft ? 0 : offset;\n\n // Close previous segment with a bevel\n if (prevVertex) {\n this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment);\n }\n\n if (currentJoin === 'fakeround') {\n // The join angle is sharp enough that a round join would be visible.\n // Bevel joins fill the gap between segments with a single pie slice triangle.\n // Create a round join by adding multiple pie slices. The join isn't actually round, but\n // it looks like it is at the sizes we render lines at.\n\n // pick the number of triangles for approximating round join by based on the angle between normals\n const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE);\n\n for (let m = 1; m < n; m++) {\n let t = m / n;\n if (t !== 0.5) {\n // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp\n const t2 = t - 0.5;\n const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519));\n const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638);\n t = t + t * t2 * (t - 1) * (A * t2 * t2 + B);\n }\n const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1);\n this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment);\n }\n }\n\n if (nextVertex) {\n // Start next segment\n this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment);\n }\n\n } else if (currentJoin === 'butt') {\n this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap\n\n } else if (currentJoin === 'square') {\n const offset = prevVertex ? 1 : -1; // closing or starting square cap\n this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment);\n\n } else if (currentJoin === 'round') {\n\n if (prevVertex) {\n // Close previous segment with butt\n this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment);\n\n // Add round cap or linejoin at end of segment\n this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true);\n }\n if (nextVertex) {\n // Add round cap before first segment\n this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true);\n\n // Start next segment with a butt\n this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment);\n }\n }\n\n if (isSharpCorner && i < len - 1) {\n const nextSegmentLength = currentVertex.dist(nextVertex);\n if (nextSegmentLength > 2 * sharpCornerOffset) {\n const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round());\n this.updateDistance(currentVertex, newCurrentVertex);\n this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment);\n currentVertex = newCurrentVertex;\n }\n }\n }\n }\n\n /**\n * Add two vertices to the buffers.\n *\n * @param p - the line vertex to add buffer vertices for\n * @param normal - vertex normal\n * @param endLeft - extrude to shift the left vertex along the line\n * @param endRight - extrude to shift the left vertex along the line\n * @param segment - the segment object to add the vertex to\n * @param round - whether this is a round cap\n */\n addCurrentVertex(p: Point, normal: Point, endLeft: number, endRight: number, segment: Segment, round: boolean = false) {\n // left and right extrude vectors, perpendicularly shifted by endLeft/endRight\n const leftX = normal.x + normal.y * endLeft;\n const leftY = normal.y - normal.x * endLeft;\n const rightX = -normal.x + normal.y * endRight;\n const rightY = -normal.y - normal.x * endRight;\n\n this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment);\n this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment);\n\n // There is a maximum \"distance along the line\" that we can store in the buffers.\n // When we get close to the distance, reset it to zero and add the vertex again with\n // a distance of zero. The max distance is determined by the number of bits we allocate\n // to `linesofar`.\n if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) {\n this.distance = 0;\n this.updateScaledDistance();\n this.addCurrentVertex(p, normal, endLeft, endRight, segment, round);\n }\n }\n\n addHalfVertex({x, y}: Point, extrudeX: number, extrudeY: number, round: boolean, up: boolean, dir: number, segment: Segment) {\n const totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance;\n // scale down so that we can store longer distances while sacrificing precision.\n const linesofarScaled = totalDistance * LINE_DISTANCE_SCALE;\n\n this.layoutVertexArray.emplaceBack(\n // a_pos_normal\n // Encode round/up the least significant bits\n (x << 1) + (round ? 1 : 0),\n (y << 1) + (up ? 1 : 0),\n // a_data\n // add 128 to store a byte in an unsigned byte\n Math.round(EXTRUDE_SCALE * extrudeX) + 128,\n Math.round(EXTRUDE_SCALE * extrudeY) + 128,\n // Encode the -1/0/1 direction value into the first two bits of .z of a_data.\n // Combine it with the lower 6 bits of `linesofarScaled` (shifted by 2 bits to make\n // room for the direction value). The upper 8 bits of `linesofarScaled` are placed in\n // the `w` component.\n ((dir === 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofarScaled & 0x3F) << 2),\n linesofarScaled >> 6);\n\n // Constructs a second vertex buffer with higher precision line progress\n if (this.lineClips) {\n const progressRealigned = this.scaledDistance - this.lineClips.start;\n const endClipRealigned = this.lineClips.end - this.lineClips.start;\n const uvX = progressRealigned / endClipRealigned;\n this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length);\n }\n\n const e = segment.vertexLength++;\n if (this.e1 >= 0 && this.e2 >= 0) {\n this.indexArray.emplaceBack(this.e1, this.e2, e);\n segment.primitiveLength++;\n }\n if (up) {\n this.e2 = e;\n } else {\n this.e1 = e;\n }\n }\n\n updateScaledDistance() {\n // Knowing the ratio of the full linestring covered by this tiled feature, as well\n // as the total distance (in tile units) of this tiled feature, and the distance\n // (in tile units) of the current vertex, we can determine the relative distance\n // of this vertex along the full linestring feature and scale it to [0, 2^15)\n this.scaledDistance = this.lineClips ?\n this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance :\n this.distance;\n }\n\n updateDistance(prev: Point, next: Point) {\n this.distance += prev.dist(next);\n this.updateScaledDistance();\n }\n}\n\nregister('LineBucket', LineBucket, {omit: ['layers', 'patternFeatures']});\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LineLayoutProps = {\n \"line-cap\": DataConstantProperty<\"butt\" | \"round\" | \"square\">,\n \"line-join\": DataDrivenProperty<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": DataConstantProperty,\n \"line-round-limit\": DataConstantProperty,\n \"line-sort-key\": DataDrivenProperty,\n};\n\nexport type LineLayoutPropsPossiblyEvaluated = {\n \"line-cap\": \"butt\" | \"round\" | \"square\",\n \"line-join\": PossiblyEvaluatedPropertyValue<\"bevel\" | \"round\" | \"miter\">,\n \"line-miter-limit\": number,\n \"line-round-limit\": number,\n \"line-sort-key\": PossiblyEvaluatedPropertyValue,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"line-cap\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-cap\"] as any as StylePropertySpecification),\n \"line-join\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-join\"] as any as StylePropertySpecification),\n \"line-miter-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-miter-limit\"] as any as StylePropertySpecification),\n \"line-round-limit\": new DataConstantProperty(styleSpec[\"layout_line\"][\"line-round-limit\"] as any as StylePropertySpecification),\n \"line-sort-key\": new DataDrivenProperty(styleSpec[\"layout_line\"][\"line-sort-key\"] as any as StylePropertySpecification),\n});\n\nexport type LinePaintProps = {\n \"line-opacity\": DataDrivenProperty,\n \"line-color\": DataDrivenProperty,\n \"line-translate\": DataConstantProperty<[number, number]>,\n \"line-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"line-width\": DataDrivenProperty,\n \"line-gap-width\": DataDrivenProperty,\n \"line-offset\": DataDrivenProperty,\n \"line-blur\": DataDrivenProperty,\n \"line-dasharray\": CrossFadedProperty>,\n \"line-pattern\": CrossFadedDataDrivenProperty,\n \"line-gradient\": ColorRampProperty,\n};\n\nexport type LinePaintPropsPossiblyEvaluated = {\n \"line-opacity\": PossiblyEvaluatedPropertyValue,\n \"line-color\": PossiblyEvaluatedPropertyValue,\n \"line-translate\": [number, number],\n \"line-translate-anchor\": \"map\" | \"viewport\",\n \"line-width\": PossiblyEvaluatedPropertyValue,\n \"line-gap-width\": PossiblyEvaluatedPropertyValue,\n \"line-offset\": PossiblyEvaluatedPropertyValue,\n \"line-blur\": PossiblyEvaluatedPropertyValue,\n \"line-dasharray\": CrossFaded>,\n \"line-pattern\": PossiblyEvaluatedPropertyValue>,\n \"line-gradient\": ColorRampProperty,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"line-opacity\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-opacity\"] as any as StylePropertySpecification),\n \"line-color\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-color\"] as any as StylePropertySpecification),\n \"line-translate\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate\"] as any as StylePropertySpecification),\n \"line-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_line\"][\"line-translate-anchor\"] as any as StylePropertySpecification),\n \"line-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-width\"] as any as StylePropertySpecification),\n \"line-gap-width\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-gap-width\"] as any as StylePropertySpecification),\n \"line-offset\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-offset\"] as any as StylePropertySpecification),\n \"line-blur\": new DataDrivenProperty(styleSpec[\"paint_line\"][\"line-blur\"] as any as StylePropertySpecification),\n \"line-dasharray\": new CrossFadedProperty(styleSpec[\"paint_line\"][\"line-dasharray\"] as any as StylePropertySpecification),\n \"line-pattern\": new CrossFadedDataDrivenProperty(styleSpec[\"paint_line\"][\"line-pattern\"] as any as StylePropertySpecification),\n \"line-gradient\": new ColorRampProperty(styleSpec[\"paint_line\"][\"line-gradient\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import Point from '@mapbox/point-geometry';\n\nimport {StyleLayer} from '../style_layer';\nimport {LineBucket} from '../../data/bucket/line_bucket';\nimport {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests';\nimport {getMaximumPaintValue, translateDistance, translate, offsetLine} from '../query_utils';\nimport properties, {LineLayoutPropsPossiblyEvaluated, LinePaintPropsPossiblyEvaluated} from './line_style_layer_properties.g';\nimport {extend} from '../../util/util';\nimport {EvaluationParameters} from '../evaluation_parameters';\nimport {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties';\n\nimport {isZoomExpression, Step} from '@maplibre/maplibre-gl-style-spec';\nimport type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Bucket, BucketParameters} from '../../data/bucket';\nimport type {LineLayoutProps, LinePaintProps} from './line_style_layer_properties.g';\nimport type {Transform} from '../../geo/transform';\nimport type {VectorTileFeature} from '@mapbox/vector-tile';\n\nexport class LineFloorwidthProperty extends DataDrivenProperty {\n useIntegerZoom: true;\n\n possiblyEvaluate(value, parameters) {\n parameters = new EvaluationParameters(Math.floor(parameters.zoom), {\n now: parameters.now,\n fadeDuration: parameters.fadeDuration,\n zoomHistory: parameters.zoomHistory,\n transition: parameters.transition\n });\n return super.possiblyEvaluate(value, parameters);\n }\n\n evaluate(value, globals, feature, featureState) {\n globals = extend({}, globals, {zoom: Math.floor(globals.zoom)});\n return super.evaluate(value, globals, feature, featureState);\n }\n}\n\nlet lineFloorwidthProperty: LineFloorwidthProperty;\n\nexport class LineStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n gradientVersion: number;\n stepInterpolant: boolean;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n this.gradientVersion = 0;\n if (!lineFloorwidthProperty) {\n lineFloorwidthProperty =\n new LineFloorwidthProperty(properties.paint.properties['line-width'].specification);\n lineFloorwidthProperty.useIntegerZoom = true;\n }\n }\n\n _handleSpecialPaintPropertyUpdate(name: string) {\n if (name === 'line-gradient') {\n const expression = this.gradientExpression();\n if (isZoomExpression(expression)) {\n this.stepInterpolant = expression._styleExpression.expression instanceof Step;\n } else {\n this.stepInterpolant = false;\n }\n this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;\n }\n }\n\n gradientExpression() {\n return this._transitionablePaint._values['line-gradient'].value.expression;\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n (this.paint._values as any)['line-floorwidth'] =\n lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values['line-width'].value, parameters);\n }\n\n createBucket(parameters: BucketParameters) {\n return new LineBucket(parameters);\n }\n\n queryRadius(bucket: Bucket): number {\n const lineBucket: LineBucket = (bucket as any);\n const width = getLineWidth(\n getMaximumPaintValue('line-width', this, lineBucket),\n getMaximumPaintValue('line-gap-width', this, lineBucket));\n const offset = getMaximumPaintValue('line-offset', this, lineBucket);\n return width / 2 + Math.abs(offset) + translateDistance(this.paint.get('line-translate'));\n }\n\n queryIntersectsFeature(\n queryGeometry: Array,\n feature: VectorTileFeature,\n featureState: FeatureState,\n geometry: Array>,\n zoom: number,\n transform: Transform,\n pixelsToTileUnits: number\n ): boolean {\n const translatedPolygon = translate(queryGeometry,\n this.paint.get('line-translate'),\n this.paint.get('line-translate-anchor'),\n transform.angle, pixelsToTileUnits);\n const halfWidth = pixelsToTileUnits / 2 * getLineWidth(\n this.paint.get('line-width').evaluate(feature, featureState),\n this.paint.get('line-gap-width').evaluate(feature, featureState));\n const lineOffset = this.paint.get('line-offset').evaluate(feature, featureState);\n if (lineOffset) {\n geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits);\n }\n\n return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth);\n }\n\n isTileClipped() {\n return true;\n }\n}\n\nfunction getLineWidth(lineWidth, lineGapWidth) {\n if (lineGapWidth > 0) {\n return lineGapWidth + 2 * lineWidth;\n } else {\n return lineWidth;\n }\n}\n","import {createLayout} from '../../util/struct_array';\n\nexport const symbolLayoutAttributes = createLayout([\n {name: 'a_pos_offset', components: 4, type: 'Int16'},\n {name: 'a_data', components: 4, type: 'Uint16'},\n {name: 'a_pixeloffset', components: 4, type: 'Int16'}\n], 4);\n\nexport const dynamicLayoutAttributes = createLayout([\n {name: 'a_projected_pos', components: 3, type: 'Float32'}\n], 4);\n\nexport const placementOpacityAttributes = createLayout([\n {name: 'a_fade_opacity', components: 1, type: 'Uint32'}\n], 4);\n\nexport const collisionVertexAttributes = createLayout([\n {name: 'a_placed', components: 2, type: 'Uint8'},\n {name: 'a_shift', components: 2, type: 'Float32'}\n]);\n\nexport const collisionBox = createLayout([\n // the box is centered around the anchor point\n {type: 'Int16', name: 'anchorPointX'},\n {type: 'Int16', name: 'anchorPointY'},\n\n // distances to the edges from the anchor\n {type: 'Int16', name: 'x1'},\n {type: 'Int16', name: 'y1'},\n {type: 'Int16', name: 'x2'},\n {type: 'Int16', name: 'y2'},\n\n // the index of the feature in the original vectortile\n {type: 'Uint32', name: 'featureIndex'},\n // the source layer the feature appears in\n {type: 'Uint16', name: 'sourceLayerIndex'},\n // the bucket the feature appears in\n {type: 'Uint16', name: 'bucketIndex'},\n]);\n\nexport const collisionBoxLayout = createLayout([ // used to render collision boxes for debugging purposes\n {name: 'a_pos', components: 2, type: 'Int16'},\n {name: 'a_anchor_pos', components: 2, type: 'Int16'},\n {name: 'a_extrude', components: 2, type: 'Int16'}\n], 4);\n\nexport const collisionCircleLayout = createLayout([ // used to render collision circles for debugging purposes\n {name: 'a_pos', components: 2, type: 'Float32'},\n {name: 'a_radius', components: 1, type: 'Float32'},\n {name: 'a_flags', components: 2, type: 'Int16'}\n], 4);\n\nexport const quadTriangle = createLayout([\n {name: 'triangle', components: 3, type: 'Uint16'},\n]);\n\nexport const placement = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Uint16', name: 'glyphStartIndex'},\n {type: 'Uint16', name: 'numGlyphs'},\n {type: 'Uint32', name: 'vertexStartIndex'},\n {type: 'Uint32', name: 'lineStartIndex'},\n {type: 'Uint32', name: 'lineLength'},\n {type: 'Uint16', name: 'segment'},\n {type: 'Uint16', name: 'lowerSize'},\n {type: 'Uint16', name: 'upperSize'},\n {type: 'Float32', name: 'lineOffsetX'},\n {type: 'Float32', name: 'lineOffsetY'},\n {type: 'Uint8', name: 'writingMode'},\n {type: 'Uint8', name: 'placedOrientation'},\n {type: 'Uint8', name: 'hidden'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Int16', name: 'associatedIconIndex'}\n]);\n\nexport const symbolInstance = createLayout([\n {type: 'Int16', name: 'anchorX'},\n {type: 'Int16', name: 'anchorY'},\n {type: 'Int16', name: 'rightJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'centerJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'leftJustifiedTextSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedTextSymbolIndex'},\n {type: 'Int16', name: 'placedIconSymbolIndex'},\n {type: 'Int16', name: 'verticalPlacedIconSymbolIndex'},\n {type: 'Uint16', name: 'key'},\n {type: 'Uint16', name: 'textBoxStartIndex'},\n {type: 'Uint16', name: 'textBoxEndIndex'},\n {type: 'Uint16', name: 'verticalTextBoxStartIndex'},\n {type: 'Uint16', name: 'verticalTextBoxEndIndex'},\n {type: 'Uint16', name: 'iconBoxStartIndex'},\n {type: 'Uint16', name: 'iconBoxEndIndex'},\n {type: 'Uint16', name: 'verticalIconBoxStartIndex'},\n {type: 'Uint16', name: 'verticalIconBoxEndIndex'},\n {type: 'Uint16', name: 'featureIndex'},\n {type: 'Uint16', name: 'numHorizontalGlyphVertices'},\n {type: 'Uint16', name: 'numVerticalGlyphVertices'},\n {type: 'Uint16', name: 'numIconVertices'},\n {type: 'Uint16', name: 'numVerticalIconVertices'},\n {type: 'Uint16', name: 'useRuntimeCollisionCircles'},\n {type: 'Uint32', name: 'crossTileID'},\n {type: 'Float32', name: 'textBoxScale'},\n {type: 'Float32', name: 'collisionCircleDiameter'},\n {type: 'Uint16', name: 'textAnchorOffsetStartIndex'},\n {type: 'Uint16', name: 'textAnchorOffsetEndIndex'}\n]);\n\nexport const glyphOffset = createLayout([\n {type: 'Float32', name: 'offsetX'}\n]);\n\nexport const lineVertex = createLayout([\n {type: 'Int16', name: 'x'},\n {type: 'Int16', name: 'y'},\n {type: 'Int16', name: 'tileUnitDistanceFromAnchor'}\n]);\n\nexport const textAnchorOffset = createLayout([\n {type: 'Uint16', name: 'textAnchor'},\n {type: 'Float32', components: 2, name: 'textOffset'}\n]);\n","import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\n\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport {Formatted} from '@maplibre/maplibre-gl-style-spec';\n\nfunction transformTextInternal(text: string, layer: SymbolStyleLayer, feature: Feature) {\n const transform = layer.layout.get('text-transform').evaluate(feature, {});\n if (transform === 'uppercase') {\n text = text.toLocaleUpperCase();\n } else if (transform === 'lowercase') {\n text = text.toLocaleLowerCase();\n }\n\n if (rtlTextPlugin.applyArabicShaping) {\n text = rtlTextPlugin.applyArabicShaping(text);\n }\n\n return text;\n}\n\nexport function transformText(text: Formatted, layer: SymbolStyleLayer, feature: Feature): Formatted {\n text.sections.forEach(section => {\n section.text = transformTextInternal(section.text, layer, feature);\n });\n return text;\n}\n","import {charHasRotatedVerticalOrientation} from './script_detection';\n\nexport const verticalizedCharacterMap = {\n '!': '︕',\n '#': '#',\n '$': '$',\n '%': '%',\n '&': '&',\n '(': '︵',\n ')': '︶',\n '*': '*',\n '+': '+',\n ',': '︐',\n '-': '︲',\n '.': '・',\n '/': '/',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '=': '=',\n '>': '﹀',\n '?': '︖',\n '@': '@',\n '[': '﹇',\n '\\\\': '\',\n ']': '﹈',\n '^': '^',\n '_': '︳',\n '`': '`',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '~': '~',\n '¢': '¢',\n '£': '£',\n '¥': '¥',\n '¦': '¦',\n '¬': '¬',\n '¯': ' ̄',\n '–': '︲',\n '—': '︱',\n '‘': '﹃',\n '’': '﹄',\n '“': '﹁',\n '”': '﹂',\n '…': '︙',\n '‧': '・',\n '₩': '₩',\n '、': '︑',\n '。': '︒',\n '〈': '︿',\n '〉': '﹀',\n '《': '︽',\n '》': '︾',\n '「': '﹁',\n '」': '﹂',\n '『': '﹃',\n '』': '﹄',\n '【': '︻',\n '】': '︼',\n '〔': '︹',\n '〕': '︺',\n '〖': '︗',\n '〗': '︘',\n '!': '︕',\n '(': '︵',\n ')': '︶',\n ',': '︐',\n '-': '︲',\n '.': '・',\n ':': '︓',\n ';': '︔',\n '<': '︿',\n '>': '﹀',\n '?': '︖',\n '[': '﹇',\n ']': '﹈',\n '_': '︳',\n '{': '︷',\n '|': '―',\n '}': '︸',\n '⦅': '︵',\n '⦆': '︶',\n '。': '︒',\n '「': '﹁',\n '」': '﹂'\n};\n\nexport function verticalizePunctuation(input: string) {\n let output = '';\n\n for (let i = 0; i < input.length; i++) {\n const nextCharCode = input.charCodeAt(i + 1) || null;\n const prevCharCode = input.charCodeAt(i - 1) || null;\n\n const canReplacePunctuation = (\n (!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) &&\n (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]])\n );\n\n if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) {\n output += verticalizedCharacterMap[input[i]];\n } else {\n output += input[i];\n }\n }\n\n return output;\n}\n\n","// ONE_EM constant used to go between \"em\" units used in style spec and \"points\" used internally for layout\n\nexport default 24;\n","'use strict';\n\nmodule.exports = Pbf;\n\nvar ieee754 = require('ieee754');\n\nfunction Pbf(buf) {\n this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n}\n\nPbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum\nPbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64\nPbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields\nPbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32\n\nvar SHIFT_LEFT_32 = (1 << 16) * (1 << 16),\n SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n\n// Threshold chosen based on both benchmarking and knowledge about browser string\n// data structures (which currently switch structure types at 12 bytes or more)\nvar TEXT_DECODER_MIN_LENGTH = 12;\nvar utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');\n\nPbf.prototype = {\n\n destroy: function() {\n this.buf = null;\n },\n\n // === READING =================================================================\n\n readFields: function(readField, result, end) {\n end = end || this.length;\n\n while (this.pos < end) {\n var val = this.readVarint(),\n tag = val >> 3,\n startPos = this.pos;\n\n this.type = val & 0x7;\n readField(tag, result, this);\n\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n },\n\n readMessage: function(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n },\n\n readFixed32: function() {\n var val = readUInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n readSFixed32: function() {\n var val = readInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n\n readFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readSFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readFloat: function() {\n var val = ieee754.read(this.buf, this.pos, true, 23, 4);\n this.pos += 4;\n return val;\n },\n\n readDouble: function() {\n var val = ieee754.read(this.buf, this.pos, true, 52, 8);\n this.pos += 8;\n return val;\n },\n\n readVarint: function(isSigned) {\n var buf = this.buf,\n val, b;\n\n b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;\n b = buf[this.pos]; val |= (b & 0x0f) << 28;\n\n return readVarintRemainder(val, isSigned, this);\n },\n\n readVarint64: function() { // for compatibility with v2.0.1\n return this.readVarint(true);\n },\n\n readSVarint: function() {\n var num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding\n },\n\n readBoolean: function() {\n return Boolean(this.readVarint());\n },\n\n readString: function() {\n var end = this.readVarint() + this.pos;\n var pos = this.pos;\n this.pos = end;\n\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n // longer strings are fast with the built-in browser TextDecoder API\n return readUtf8TextDecoder(this.buf, pos, end);\n }\n // short strings are fast with our custom implementation\n return readUtf8(this.buf, pos, end);\n },\n\n readBytes: function() {\n var end = this.readVarint() + this.pos,\n buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n },\n\n // verbose for performance reasons; doesn't affect gzipped size\n\n readPackedVarint: function(arr, isSigned) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n },\n readPackedSVarint: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n },\n readPackedBoolean: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n },\n readPackedFloat: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n },\n readPackedDouble: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n },\n readPackedFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n },\n readPackedSFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n },\n readPackedFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n },\n readPackedSFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n },\n\n skip: function(val) {\n var type = val & 0x7;\n if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}\n else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;\n else if (type === Pbf.Fixed32) this.pos += 4;\n else if (type === Pbf.Fixed64) this.pos += 8;\n else throw new Error('Unimplemented type: ' + type);\n },\n\n // === WRITING =================================================================\n\n writeTag: function(tag, type) {\n this.writeVarint((tag << 3) | type);\n },\n\n realloc: function(min) {\n var length = this.length || 16;\n\n while (length < this.pos + min) length *= 2;\n\n if (length !== this.length) {\n var buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.length = length;\n }\n },\n\n finish: function() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n },\n\n writeFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeSFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeSFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeVarint: function(val) {\n val = +val || 0;\n\n if (val > 0xfffffff || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n\n this.realloc(4);\n\n this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = (val >>> 7) & 0x7f;\n },\n\n writeSVarint: function(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n },\n\n writeBoolean: function(val) {\n this.writeVarint(Boolean(val));\n },\n\n writeString: function(str) {\n str = String(str);\n this.realloc(str.length * 4);\n\n this.pos++; // reserve 1 byte for short string length\n\n var startPos = this.pos;\n // write the string directly to the buffer and see how much was written\n this.pos = writeUtf8(this.buf, str, this.pos);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeFloat: function(val) {\n this.realloc(4);\n ieee754.write(this.buf, val, this.pos, true, 23, 4);\n this.pos += 4;\n },\n\n writeDouble: function(val) {\n this.realloc(8);\n ieee754.write(this.buf, val, this.pos, true, 52, 8);\n this.pos += 8;\n },\n\n writeBytes: function(buffer) {\n var len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n },\n\n writeRawMessage: function(fn, obj) {\n this.pos++; // reserve 1 byte for short message length\n\n // write the message directly to the buffer and see how much was written\n var startPos = this.pos;\n fn(obj, this);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeMessage: function(tag, fn, obj) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeRawMessage(fn, obj);\n },\n\n writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },\n writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },\n writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },\n writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },\n writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },\n writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },\n writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },\n writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },\n writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },\n\n writeBytesField: function(tag, buffer) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeBytes(buffer);\n },\n writeFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFixed32(val);\n },\n writeSFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeSFixed32(val);\n },\n writeFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeFixed64(val);\n },\n writeSFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeSFixed64(val);\n },\n writeVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeVarint(val);\n },\n writeSVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeSVarint(val);\n },\n writeStringField: function(tag, str) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeString(str);\n },\n writeFloatField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFloat(val);\n },\n writeDoubleField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeDouble(val);\n },\n writeBooleanField: function(tag, val) {\n this.writeVarintField(tag, Boolean(val));\n }\n};\n\nfunction readVarintRemainder(l, s, p) {\n var buf = p.buf,\n h, b;\n\n b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);\n\n throw new Error('Expected varint not more than 10 bytes');\n}\n\nfunction readPackedEnd(pbf) {\n return pbf.type === Pbf.Bytes ?\n pbf.readVarint() + pbf.pos : pbf.pos + 1;\n}\n\nfunction toNum(low, high, isSigned) {\n if (isSigned) {\n return high * 0x100000000 + (low >>> 0);\n }\n\n return ((high >>> 0) * 0x100000000) + (low >>> 0);\n}\n\nfunction writeBigVarint(val, pbf) {\n var low, high;\n\n if (val >= 0) {\n low = (val % 0x100000000) | 0;\n high = (val / 0x100000000) | 0;\n } else {\n low = ~(-val % 0x100000000);\n high = ~(-val / 0x100000000);\n\n if (low ^ 0xffffffff) {\n low = (low + 1) | 0;\n } else {\n low = 0;\n high = (high + 1) | 0;\n }\n }\n\n if (val >= 0x10000000000000000 || val < -0x10000000000000000) {\n throw new Error('Given varint doesn\\'t fit into 10 bytes');\n }\n\n pbf.realloc(10);\n\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n}\n\nfunction writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos] = low & 0x7f;\n}\n\nfunction writeBigVarintHigh(high, pbf) {\n var lsb = (high & 0x07) << 4;\n\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f;\n}\n\nfunction makeRoomForExtraLength(startPos, len, pbf) {\n var extraLen =\n len <= 0x3fff ? 1 :\n len <= 0x1fffff ? 2 :\n len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n\n // if 1 byte isn't enough for encoding message length, shift the data to the right\n pbf.realloc(extraLen);\n for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n}\n\nfunction writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }\nfunction writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }\nfunction writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }\nfunction writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }\nfunction writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }\nfunction writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }\nfunction writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }\nfunction writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }\nfunction writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }\n\n// Buffer code below from https://github.com/feross/buffer, MIT-licensed\n\nfunction readUInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] * 0x1000000);\n}\n\nfunction writeInt32(buf, val, pos) {\n buf[pos] = val;\n buf[pos + 1] = (val >>> 8);\n buf[pos + 2] = (val >>> 16);\n buf[pos + 3] = (val >>> 24);\n}\n\nfunction readInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] << 24);\n}\n\nfunction readUtf8(buf, pos, end) {\n var str = '';\n var i = pos;\n\n while (i < end) {\n var b0 = buf[i];\n var c = null; // codepoint\n var bytesPerSequence =\n b0 > 0xEF ? 4 :\n b0 > 0xDF ? 3 :\n b0 > 0xBF ? 2 : 1;\n\n if (i + bytesPerSequence > end) break;\n\n var b1, b2, b3;\n\n if (bytesPerSequence === 1) {\n if (b0 < 0x80) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 0xC0) === 0x80) {\n c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);\n if (c <= 0x7F) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);\n if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);\n if (c <= 0xFFFF || c >= 0x110000) {\n c = null;\n }\n }\n }\n\n if (c === null) {\n c = 0xFFFD;\n bytesPerSequence = 1;\n\n } else if (c > 0xFFFF) {\n c -= 0x10000;\n str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);\n c = 0xDC00 | c & 0x3FF;\n }\n\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n\n return str;\n}\n\nfunction readUtf8TextDecoder(buf, pos, end) {\n return utf8TextDecoder.decode(buf.subarray(pos, end));\n}\n\nfunction writeUtf8(buf, str, pos) {\n for (var i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i); // code point\n\n if (c > 0xD7FF && c < 0xE000) {\n if (lead) {\n if (c < 0xDC00) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = c;\n continue;\n } else {\n c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;\n lead = null;\n }\n } else {\n if (c > 0xDBFF || (i + 1 === str.length)) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = null;\n }\n\n if (c < 0x80) {\n buf[pos++] = c;\n } else {\n if (c < 0x800) {\n buf[pos++] = c >> 0x6 | 0xC0;\n } else {\n if (c < 0x10000) {\n buf[pos++] = c >> 0xC | 0xE0;\n } else {\n buf[pos++] = c >> 0x12 | 0xF0;\n buf[pos++] = c >> 0xC & 0x3F | 0x80;\n }\n buf[pos++] = c >> 0x6 & 0x3F | 0x80;\n }\n buf[pos++] = c & 0x3F | 0x80;\n }\n }\n return pos;\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","import {AlphaImage} from '../util/image';\n\nimport Protobuf from 'pbf';\nconst border = 3;\n\nimport type {StyleGlyph} from './style_glyph';\n\nfunction readFontstacks(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 1) {\n pbf.readMessage(readFontstack, glyphs);\n }\n}\n\nfunction readFontstack(tag: number, glyphs: Array, pbf: Protobuf) {\n if (tag === 3) {\n const {id, bitmap, width, height, left, top, advance} = pbf.readMessage(readGlyph, {});\n glyphs.push({\n id,\n bitmap: new AlphaImage({\n width: width + 2 * border,\n height: height + 2 * border\n }, bitmap),\n metrics: {width, height, left, top, advance}\n });\n }\n}\n\nfunction readGlyph(tag: number, glyph: any, pbf: Protobuf) {\n if (tag === 1) glyph.id = pbf.readVarint();\n else if (tag === 2) glyph.bitmap = pbf.readBytes();\n else if (tag === 3) glyph.width = pbf.readVarint();\n else if (tag === 4) glyph.height = pbf.readVarint();\n else if (tag === 5) glyph.left = pbf.readSVarint();\n else if (tag === 6) glyph.top = pbf.readSVarint();\n else if (tag === 7) glyph.advance = pbf.readVarint();\n}\n\nexport function parseGlyphPbf(data: ArrayBuffer | Uint8Array): Array {\n return new Protobuf(data).readFields(readFontstacks, []);\n}\n\nexport const GLYPH_PBF_BORDER = border;\n","\nexport default function potpack(boxes) {\n\n // calculate total box area and maximum box width\n let area = 0;\n let maxWidth = 0;\n\n for (const box of boxes) {\n area += box.w * box.h;\n maxWidth = Math.max(maxWidth, box.w);\n }\n\n // sort the boxes for insertion by height, descending\n boxes.sort((a, b) => b.h - a.h);\n\n // aim for a squarish resulting container,\n // slightly adjusted for sub-100% space utilization\n const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth);\n\n // start with a single empty space, unbounded at the bottom\n const spaces = [{x: 0, y: 0, w: startWidth, h: Infinity}];\n\n let width = 0;\n let height = 0;\n\n for (const box of boxes) {\n // look through spaces backwards so that we check smaller spaces first\n for (let i = spaces.length - 1; i >= 0; i--) {\n const space = spaces[i];\n\n // look for empty spaces that can accommodate the current box\n if (box.w > space.w || box.h > space.h) continue;\n\n // found the space; add the box to its top-left corner\n // |-------|-------|\n // | box | |\n // |_______| |\n // | space |\n // |_______________|\n box.x = space.x;\n box.y = space.y;\n\n height = Math.max(height, box.y + box.h);\n width = Math.max(width, box.x + box.w);\n\n if (box.w === space.w && box.h === space.h) {\n // space matches the box exactly; remove it\n const last = spaces.pop();\n if (i < spaces.length) spaces[i] = last;\n\n } else if (box.h === space.h) {\n // space matches the box height; update it accordingly\n // |-------|---------------|\n // | box | updated space |\n // |_______|_______________|\n space.x += box.w;\n space.w -= box.w;\n\n } else if (box.w === space.w) {\n // space matches the box width; update it accordingly\n // |---------------|\n // | box |\n // |_______________|\n // | updated space |\n // |_______________|\n space.y += box.h;\n space.h -= box.h;\n\n } else {\n // otherwise the box splits the space into two spaces\n // |-------|-----------|\n // | box | new space |\n // |_______|___________|\n // | updated space |\n // |___________________|\n spaces.push({\n x: space.x + box.w,\n y: space.y,\n w: space.w - box.w,\n h: box.h\n });\n space.y += box.h;\n space.h -= box.h;\n }\n break;\n }\n }\n\n return {\n w: width, // container width\n h: height, // container height\n fill: (area / (width * height)) || 0 // space utilization\n };\n}\n","/* eslint-disable key-spacing */\nimport {RGBAImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {ImageManager} from './image_manager';\nimport type {Texture} from './texture';\nimport type {Rect} from './glyph_atlas';\n\nconst IMAGE_PADDING: number = 1;\nexport {IMAGE_PADDING};\n\nexport class ImagePosition {\n paddedRect: Rect;\n pixelRatio: number;\n version: number;\n stretchY: Array<[number, number]>;\n stretchX: Array<[number, number]>;\n content: [number, number, number, number];\n\n constructor(paddedRect: Rect, {\n pixelRatio,\n version,\n stretchX,\n stretchY,\n content\n }: StyleImage) {\n this.paddedRect = paddedRect;\n this.pixelRatio = pixelRatio;\n this.stretchX = stretchX;\n this.stretchY = stretchY;\n this.content = content;\n this.version = version;\n }\n\n get tl(): [number, number] {\n return [\n this.paddedRect.x + IMAGE_PADDING,\n this.paddedRect.y + IMAGE_PADDING\n ];\n }\n\n get br(): [number, number] {\n return [\n this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING,\n this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING\n ];\n }\n\n get tlbr(): Array {\n return this.tl.concat(this.br);\n }\n\n get displaySize(): [number, number] {\n return [\n (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio,\n (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio\n ];\n }\n}\n\n/**\n * @internal\n * A class holding all the images\n */\nexport class ImageAtlas {\n image: RGBAImage;\n iconPositions: {[_: string]: ImagePosition};\n patternPositions: {[_: string]: ImagePosition};\n haveRenderCallbacks: Array;\n uploaded: boolean;\n\n constructor(icons: {[_: string]: StyleImage}, patterns: {[_: string]: StyleImage}) {\n const iconPositions = {}, patternPositions = {};\n this.haveRenderCallbacks = [];\n\n const bins = [];\n\n this.addImages(icons, iconPositions, bins);\n this.addImages(patterns, patternPositions, bins);\n\n const {w, h} = potpack(bins);\n const image = new RGBAImage({width: w || 1, height: h || 1});\n\n for (const id in icons) {\n const src = icons[id];\n const bin = iconPositions[id].paddedRect;\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: bin.x + IMAGE_PADDING, y: bin.y + IMAGE_PADDING}, src.data);\n }\n\n for (const id in patterns) {\n const src = patterns[id];\n const bin = patternPositions[id].paddedRect;\n const x = bin.x + IMAGE_PADDING,\n y = bin.y + IMAGE_PADDING,\n w = src.data.width,\n h = src.data.height;\n\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y}, src.data);\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src.data, image, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src.data, image, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.image = image;\n this.iconPositions = iconPositions;\n this.patternPositions = patternPositions;\n }\n\n addImages(images: {[_: string]: StyleImage}, positions: {[_: string]: ImagePosition}, bins: Array) {\n for (const id in images) {\n const src = images[id];\n const bin = {\n x: 0,\n y: 0,\n w: src.data.width + 2 * IMAGE_PADDING,\n h: src.data.height + 2 * IMAGE_PADDING,\n };\n bins.push(bin);\n positions[id] = new ImagePosition(bin, src);\n\n if (src.hasRenderCallback) {\n this.haveRenderCallbacks.push(id);\n }\n }\n }\n\n patchUpdatedImages(imageManager: ImageManager, texture: Texture) {\n imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks);\n for (const name in imageManager.updatedImages) {\n this.patchUpdatedImage(this.iconPositions[name], imageManager.getImage(name), texture);\n this.patchUpdatedImage(this.patternPositions[name], imageManager.getImage(name), texture);\n }\n }\n\n patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture) {\n if (!position || !image) return;\n\n if (position.version === image.version) return;\n\n position.version = image.version;\n const [x, y] = position.tl;\n texture.update(image.data, undefined, {x, y});\n }\n\n}\n\nregister('ImagePosition', ImagePosition);\nregister('ImageAtlas', ImageAtlas);\n","import {\n charHasUprightVerticalOrientation,\n charAllowsIdeographicBreaking,\n charInComplexShapingScript\n} from '../util/script_detection';\nimport {verticalizePunctuation} from '../util/verticalize_punctuation';\nimport {plugin as rtlTextPlugin} from '../source/rtl_text_plugin';\nimport ONE_EM from './one_em';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleGlyph, GlyphMetrics} from '../style/style_glyph';\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\nimport type {ImagePosition} from '../render/image_atlas';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {Rect, GlyphPosition} from '../render/glyph_atlas';\nimport {Formatted, FormattedSection} from '@maplibre/maplibre-gl-style-spec';\n\nenum WritingMode {\n none = 0,\n horizontal = 1,\n vertical = 2,\n horizontalOnly = 3\n}\n\nconst SHAPING_DEFAULT_OFFSET = -17;\nexport {shapeText, shapeIcon, fitIconToText, getAnchorAlignment, WritingMode, SHAPING_DEFAULT_OFFSET};\n\n// The position of a glyph relative to the text's anchor point.\nexport type PositionedGlyph = {\n glyph: number;\n imageName: string | null;\n x: number;\n y: number;\n vertical: boolean;\n scale: number;\n fontStack: string;\n sectionIndex: number;\n metrics: GlyphMetrics;\n rect: Rect | null;\n};\n\nexport type PositionedLine = {\n positionedGlyphs: Array;\n lineOffset: number;\n};\n\n// A collection of positioned glyphs and some metadata\nexport type Shaping = {\n positionedLines: Array;\n top: number;\n bottom: number;\n left: number;\n right: number;\n writingMode: WritingMode.horizontal | WritingMode.vertical;\n text: string;\n iconsInText: boolean;\n verticalizable: boolean;\n};\n\nfunction isEmpty(positionedLines: Array) {\n for (const line of positionedLines) {\n if (line.positionedGlyphs.length !== 0) {\n return false;\n }\n }\n return true;\n}\n\nexport type SymbolAnchor = 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\nexport type TextJustify = 'left' | 'center' | 'right';\n\n// Max number of images in label is 6401 U+E000–U+F8FF that covers\n// Basic Multilingual Plane Unicode Private Use Area (PUA).\nconst PUAbegin = 0xE000;\nconst PUAend = 0xF8FF;\n\nclass SectionOptions {\n // Text options\n scale: number;\n fontStack: string;\n // Image options\n imageName: string | null;\n\n constructor() {\n this.scale = 1.0;\n this.fontStack = '';\n this.imageName = null;\n }\n\n static forText(scale: number | null, fontStack: string) {\n const textOptions = new SectionOptions();\n textOptions.scale = scale || 1;\n textOptions.fontStack = fontStack;\n return textOptions;\n }\n\n static forImage(imageName: string) {\n const imageOptions = new SectionOptions();\n imageOptions.imageName = imageName;\n return imageOptions;\n }\n\n}\n\nclass TaggedString {\n text: string;\n sectionIndex: Array; // maps each character in 'text' to its corresponding entry in 'sections'\n sections: Array;\n imageSectionID: number | null;\n\n constructor() {\n this.text = '';\n this.sectionIndex = [];\n this.sections = [];\n this.imageSectionID = null;\n }\n\n static fromFeature(text: Formatted, defaultFontStack: string) {\n const result = new TaggedString();\n for (let i = 0; i < text.sections.length; i++) {\n const section = text.sections[i];\n if (!section.image) {\n result.addTextSection(section, defaultFontStack);\n } else {\n result.addImageSection(section);\n }\n }\n return result;\n }\n\n length(): number {\n return this.text.length;\n }\n\n getSection(index: number): SectionOptions {\n return this.sections[this.sectionIndex[index]];\n }\n\n getSectionIndex(index: number): number {\n return this.sectionIndex[index];\n }\n\n getCharCode(index: number): number {\n return this.text.charCodeAt(index);\n }\n\n verticalizePunctuation() {\n this.text = verticalizePunctuation(this.text);\n }\n\n trim() {\n let beginningWhitespace = 0;\n for (let i = 0;\n i < this.text.length && whitespace[this.text.charCodeAt(i)];\n i++) {\n beginningWhitespace++;\n }\n let trailingWhitespace = this.text.length;\n for (let i = this.text.length - 1;\n i >= 0 && i >= beginningWhitespace && whitespace[this.text.charCodeAt(i)];\n i--) {\n trailingWhitespace--;\n }\n this.text = this.text.substring(beginningWhitespace, trailingWhitespace);\n this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace);\n }\n\n substring(start: number, end: number): TaggedString {\n const substring = new TaggedString();\n substring.text = this.text.substring(start, end);\n substring.sectionIndex = this.sectionIndex.slice(start, end);\n substring.sections = this.sections;\n return substring;\n }\n\n toString(): string {\n return this.text;\n }\n\n getMaxScale() {\n return this.sectionIndex.reduce((max, index) => Math.max(max, this.sections[index].scale), 0);\n }\n\n addTextSection(section: FormattedSection, defaultFontStack: string) {\n this.text += section.text;\n this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack));\n const index = this.sections.length - 1;\n for (let i = 0; i < section.text.length; ++i) {\n this.sectionIndex.push(index);\n }\n }\n\n addImageSection(section: FormattedSection) {\n const imageName = section.image ? section.image.name : '';\n if (imageName.length === 0) {\n warnOnce('Can\\'t add FormattedSection with an empty image.');\n return;\n }\n\n const nextImageSectionCharCode = this.getNextImageSectionCharCode();\n if (!nextImageSectionCharCode) {\n warnOnce(`Reached maximum number of images ${PUAend - PUAbegin + 2}`);\n return;\n }\n\n this.text += String.fromCharCode(nextImageSectionCharCode);\n this.sections.push(SectionOptions.forImage(imageName));\n this.sectionIndex.push(this.sections.length - 1);\n }\n\n getNextImageSectionCharCode(): number | null {\n if (!this.imageSectionID) {\n this.imageSectionID = PUAbegin;\n return this.imageSectionID;\n }\n\n if (this.imageSectionID >= PUAend) return null;\n return ++this.imageSectionID;\n }\n}\n\nfunction breakLines(input: TaggedString, lineBreakPoints: Array): Array {\n const lines = [];\n const text = input.text;\n let start = 0;\n for (const lineBreak of lineBreakPoints) {\n lines.push(input.substring(start, lineBreak));\n start = lineBreak;\n }\n\n if (start < text.length) {\n lines.push(input.substring(start, text.length));\n }\n return lines;\n}\n\nfunction shapeText(\n text: Formatted,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n defaultFontStack: string,\n maxWidth: number,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n spacing: number,\n translate: [number, number],\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n allowVerticalPlacement: boolean,\n symbolPlacement: string,\n layoutTextSize: number,\n layoutTextSizeThisZoom: number\n): Shaping | false {\n const logicalInput = TaggedString.fromFeature(text, defaultFontStack);\n\n if (writingMode === WritingMode.vertical) {\n logicalInput.verticalizePunctuation();\n }\n\n let lines: Array;\n\n const {processBidirectionalText, processStyledBidirectionalText} = rtlTextPlugin;\n if (processBidirectionalText && logicalInput.sections.length === 1) {\n // Bidi doesn't have to be style-aware\n lines = [];\n const untaggedLines =\n processBidirectionalText(logicalInput.toString(),\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of untaggedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line;\n taggedLine.sections = logicalInput.sections;\n for (let i = 0; i < line.length; i++) {\n taggedLine.sectionIndex.push(0);\n }\n lines.push(taggedLine);\n }\n } else if (processStyledBidirectionalText) {\n // Need version of mapbox-gl-rtl-text with style support for combining RTL text\n // with formatting\n lines = [];\n const processedLines =\n processStyledBidirectionalText(logicalInput.text,\n logicalInput.sectionIndex,\n determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n for (const line of processedLines) {\n const taggedLine = new TaggedString();\n taggedLine.text = line[0];\n taggedLine.sectionIndex = line[1];\n taggedLine.sections = logicalInput.sections;\n lines.push(taggedLine);\n }\n } else {\n lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));\n }\n\n const positionedLines = [];\n const shaping = {\n positionedLines,\n text: logicalInput.toString(),\n top: translate[1],\n bottom: translate[1],\n left: translate[0],\n right: translate[0],\n writingMode,\n iconsInText: false,\n verticalizable: false\n };\n\n shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom);\n if (isEmpty(positionedLines)) return false;\n\n return shaping;\n}\n\n// using computed properties due to https://github.com/facebook/flow/issues/380\n/* eslint no-useless-computed-key: 0 */\n\nconst whitespace: {\n [_: number]: boolean;\n} = {\n [0x09]: true, // tab\n [0x0a]: true, // newline\n [0x0b]: true, // vertical tab\n [0x0c]: true, // form feed\n [0x0d]: true, // carriage return\n [0x20]: true, // space\n};\n\nconst breakable: {\n [_: number]: boolean;\n} = {\n [0x0a]: true, // newline\n [0x20]: true, // space\n [0x26]: true, // ampersand\n [0x28]: true, // left parenthesis\n [0x29]: true, // right parenthesis\n [0x2b]: true, // plus sign\n [0x2d]: true, // hyphen-minus\n [0x2f]: true, // solidus\n [0xad]: true, // soft hyphen\n [0xb7]: true, // middle dot\n [0x200b]: true, // zero-width space\n [0x2010]: true, // hyphen\n [0x2013]: true, // en dash\n [0x2027]: true // interpunct\n // Many other characters may be reasonable breakpoints\n // Consider \"neutral orientation\" characters at scriptDetection.charHasNeutralVerticalOrientation\n // See https://github.com/mapbox/mapbox-gl-js/issues/3658\n};\n\nfunction getGlyphAdvance(\n codePoint: number,\n section: SectionOptions,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n spacing: number,\n layoutTextSize: number\n): number {\n if (!section.imageName) {\n const positions = glyphMap[section.fontStack];\n const glyph = positions && positions[codePoint];\n if (!glyph) return 0;\n return glyph.metrics.advance * section.scale + spacing;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) return 0;\n return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing;\n }\n}\n\nfunction determineAverageLineWidth(logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n layoutTextSize: number) {\n let totalWidth = 0;\n\n for (let index = 0; index < logicalInput.length(); index++) {\n const section = logicalInput.getSection(index);\n totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize);\n }\n\n const lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth));\n return totalWidth / lineCount;\n}\n\nfunction calculateBadness(lineWidth: number,\n targetWidth: number,\n penalty: number,\n isLastBreak: boolean) {\n const raggedness = Math.pow(lineWidth - targetWidth, 2);\n if (isLastBreak) {\n // Favor finals lines shorter than average over longer than average\n if (lineWidth < targetWidth) {\n return raggedness / 2;\n } else {\n return raggedness * 2;\n }\n }\n\n return raggedness + Math.abs(penalty) * penalty;\n}\n\nfunction calculatePenalty(codePoint: number, nextCodePoint: number, penalizableIdeographicBreak: boolean) {\n let penalty = 0;\n // Force break on newline\n if (codePoint === 0x0a) {\n penalty -= 10000;\n }\n // Penalize breaks between characters that allow ideographic breaking because\n // they are less preferable than breaks at spaces (or zero width spaces).\n if (penalizableIdeographicBreak) {\n penalty += 150;\n }\n\n // Penalize open parenthesis at end of line\n if (codePoint === 0x28 || codePoint === 0xff08) {\n penalty += 50;\n }\n\n // Penalize close parenthesis at beginning of line\n if (nextCodePoint === 0x29 || nextCodePoint === 0xff09) {\n penalty += 50;\n }\n return penalty;\n}\n\ntype Break = {\n index: number;\n x: number;\n priorBreak: Break;\n badness: number;\n};\n\nfunction evaluateBreak(\n breakIndex: number,\n breakX: number,\n targetWidth: number,\n potentialBreaks: Array,\n penalty: number,\n isLastBreak: boolean\n): Break {\n // We could skip evaluating breaks where the line length (breakX - priorBreak.x) > maxWidth\n // ...but in fact we allow lines longer than maxWidth (if there's no break points)\n // ...and when targetWidth and maxWidth are close, strictly enforcing maxWidth can give\n // more lopsided results.\n\n let bestPriorBreak: Break = null;\n let bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak);\n\n for (const potentialBreak of potentialBreaks) {\n const lineWidth = breakX - potentialBreak.x;\n const breakBadness =\n calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness;\n if (breakBadness <= bestBreakBadness) {\n bestPriorBreak = potentialBreak;\n bestBreakBadness = breakBadness;\n }\n }\n\n return {\n index: breakIndex,\n x: breakX,\n priorBreak: bestPriorBreak,\n badness: bestBreakBadness\n };\n}\n\nfunction leastBadBreaks(lastLineBreak?: Break | null): Array {\n if (!lastLineBreak) {\n return [];\n }\n return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index);\n}\n\nfunction determineLineBreaks(\n logicalInput: TaggedString,\n spacing: number,\n maxWidth: number,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n symbolPlacement: string,\n layoutTextSize: number\n): Array {\n if (symbolPlacement !== 'point')\n return [];\n\n if (!logicalInput)\n return [];\n\n const potentialLineBreaks = [];\n const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize);\n\n const hasServerSuggestedBreakpoints = logicalInput.text.indexOf('\\u200b') >= 0;\n\n let currentX = 0;\n\n for (let i = 0; i < logicalInput.length(); i++) {\n const section = logicalInput.getSection(i);\n const codePoint = logicalInput.getCharCode(i);\n if (!whitespace[codePoint]) currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize);\n\n // Ideographic characters, spaces, and word-breaking punctuation that often appear without\n // surrounding spaces.\n if ((i < logicalInput.length() - 1)) {\n const ideographicBreak = charAllowsIdeographicBreaking(codePoint);\n if (breakable[codePoint] || ideographicBreak || section.imageName) {\n\n potentialLineBreaks.push(\n evaluateBreak(\n i + 1,\n currentX,\n targetWidth,\n potentialLineBreaks,\n calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints),\n false));\n }\n }\n }\n\n return leastBadBreaks(\n evaluateBreak(\n logicalInput.length(),\n currentX,\n targetWidth,\n potentialLineBreaks,\n 0,\n true));\n}\n\nfunction getAnchorAlignment(anchor: SymbolAnchor) {\n let horizontalAlign = 0.5, verticalAlign = 0.5;\n\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n horizontalAlign = 1;\n break;\n case 'left':\n case 'top-left':\n case 'bottom-left':\n horizontalAlign = 0;\n break;\n }\n\n switch (anchor) {\n case 'bottom':\n case 'bottom-right':\n case 'bottom-left':\n verticalAlign = 1;\n break;\n case 'top':\n case 'top-right':\n case 'top-left':\n verticalAlign = 0;\n break;\n }\n\n return {horizontalAlign, verticalAlign};\n}\n\nfunction shapeLines(shaping: Shaping,\n glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n },\n glyphPositions: {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n },\n imagePositions: {[_: string]: ImagePosition},\n lines: Array,\n lineHeight: number,\n textAnchor: SymbolAnchor,\n textJustify: TextJustify,\n writingMode: WritingMode.horizontal | WritingMode.vertical,\n spacing: number,\n allowVerticalPlacement: boolean,\n layoutTextSizeThisZoom: number) {\n\n let x = 0;\n let y = SHAPING_DEFAULT_OFFSET;\n\n let maxLineLength = 0;\n let maxLineHeight = 0;\n\n const justify =\n textJustify === 'right' ? 1 :\n textJustify === 'left' ? 0 : 0.5;\n\n let lineIndex = 0;\n for (const line of lines) {\n line.trim();\n\n const lineMaxScale = line.getMaxScale();\n const maxLineOffset = (lineMaxScale - 1) * ONE_EM;\n const positionedLine = {positionedGlyphs: [], lineOffset: 0};\n shaping.positionedLines[lineIndex] = positionedLine;\n const positionedGlyphs = positionedLine.positionedGlyphs;\n let lineOffset = 0.0;\n\n if (!line.length()) {\n y += lineHeight; // Still need a line feed after empty line\n ++lineIndex;\n continue;\n }\n\n for (let i = 0; i < line.length(); i++) {\n const section = line.getSection(i);\n const sectionIndex = line.getSectionIndex(i);\n const codePoint = line.getCharCode(i);\n let baselineOffset = 0.0;\n let metrics = null;\n let rect = null;\n let imageName = null;\n let verticalAdvance = ONE_EM;\n const vertical = !(writingMode === WritingMode.horizontal ||\n // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled.\n (!allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint)) ||\n // If vertical placement is enabled, don't verticalize glyphs that\n // are from complex text layout script, or whitespaces.\n (allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint))));\n\n if (!section.imageName) {\n const positions = glyphPositions[section.fontStack];\n const glyphPosition = positions && positions[codePoint];\n if (glyphPosition && glyphPosition.rect) {\n rect = glyphPosition.rect;\n metrics = glyphPosition.metrics;\n } else {\n const glyphs = glyphMap[section.fontStack];\n const glyph = glyphs && glyphs[codePoint];\n if (!glyph) continue;\n metrics = glyph.metrics;\n }\n\n // We don't know the baseline, but since we're laying out\n // at 24 points, we can calculate how much it will move when\n // we scale up or down.\n baselineOffset = (lineMaxScale - section.scale) * ONE_EM;\n } else {\n const imagePosition = imagePositions[section.imageName];\n if (!imagePosition) continue;\n imageName = section.imageName;\n shaping.iconsInText = shaping.iconsInText || true;\n rect = imagePosition.paddedRect;\n const size = imagePosition.displaySize;\n // If needed, allow to set scale factor for an image using\n // alias \"image-scale\" that could be alias for \"font-scale\"\n // when FormattedSection is an image section.\n section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom;\n\n metrics = {width: size[0],\n height: size[1],\n left: IMAGE_PADDING,\n top: -GLYPH_PBF_BORDER,\n advance: vertical ? size[1] : size[0]};\n\n // Difference between one EM and an image size.\n // Aligns bottom of an image to a baseline level.\n const imageOffset = ONE_EM - size[1] * section.scale;\n baselineOffset = maxLineOffset + imageOffset;\n verticalAdvance = metrics.advance;\n\n // Difference between height of an image and one EM at max line scale.\n // Pushes current line down if an image size is over 1 EM at max line scale.\n const offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale :\n size[1] * section.scale - ONE_EM * lineMaxScale;\n if (offset > 0 && offset > lineOffset) {\n lineOffset = offset;\n }\n }\n\n if (!vertical) {\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += metrics.advance * section.scale + spacing;\n } else {\n shaping.verticalizable = true;\n positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect});\n x += verticalAdvance * section.scale + spacing;\n }\n }\n\n // Only justify if we placed at least one glyph\n if (positionedGlyphs.length !== 0) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset);\n }\n\n x = 0;\n const currentLineHeight = lineHeight * lineMaxScale + lineOffset;\n positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset);\n y += currentLineHeight;\n maxLineHeight = Math.max(currentLineHeight, maxLineHeight);\n ++lineIndex;\n }\n\n // Calculate the bounding box and justify / align text block.\n const height = y - SHAPING_DEFAULT_OFFSET;\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(textAnchor);\n align(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length);\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top + height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\n// justify right = 1, left = 0, center = 0.5\nfunction justifyLine(positionedGlyphs: Array,\n start: number,\n end: number,\n justify: 1 | 0 | 0.5,\n lineOffset: number) {\n if (!justify && !lineOffset)\n return;\n\n const lastPositionedGlyph = positionedGlyphs[end];\n const lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale;\n const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;\n\n for (let j = start; j <= end; j++) {\n positionedGlyphs[j].x -= lineIndent;\n positionedGlyphs[j].y += lineOffset;\n }\n}\n\nfunction align(positionedLines: Array,\n justify: number,\n horizontalAlign: number,\n verticalAlign: number,\n maxLineLength: number,\n maxLineHeight: number,\n lineHeight: number,\n blockHeight: number,\n lineCount: number) {\n const shiftX = (justify - horizontalAlign) * maxLineLength;\n let shiftY = 0;\n\n if (maxLineHeight !== lineHeight) {\n shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET;\n } else {\n shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;\n }\n\n for (const line of positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n positionedGlyph.x += shiftX;\n positionedGlyph.y += shiftY;\n }\n }\n}\n\nexport type PositionedIcon = {\n image: ImagePosition;\n top: number;\n bottom: number;\n left: number;\n right: number;\n collisionPadding?: [number, number, number, number];\n};\n\nfunction shapeIcon(\n image: ImagePosition,\n iconOffset: [number, number],\n iconAnchor: SymbolAnchor\n): PositionedIcon {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(iconAnchor);\n const dx = iconOffset[0];\n const dy = iconOffset[1];\n const x1 = dx - image.displaySize[0] * horizontalAlign;\n const x2 = x1 + image.displaySize[0];\n const y1 = dy - image.displaySize[1] * verticalAlign;\n const y2 = y1 + image.displaySize[1];\n return {image, top: y1, bottom: y2, left: x1, right: x2};\n}\n\nfunction fitIconToText(\n shapedIcon: PositionedIcon,\n shapedText: Shaping,\n textFit: string,\n padding: [number, number, number, number],\n iconOffset: [number, number],\n fontScale: number\n): PositionedIcon {\n\n const image = shapedIcon.image;\n\n let collisionPadding;\n if (image.content) {\n const content = image.content;\n const pixelRatio = image.pixelRatio || 1;\n collisionPadding = [\n content[0] / pixelRatio,\n content[1] / pixelRatio,\n image.displaySize[0] - content[2] / pixelRatio,\n image.displaySize[1] - content[3] / pixelRatio\n ];\n }\n\n // We don't respect the icon-anchor, because icon-text-fit is set. Instead,\n // the icon will be centered on the text, then stretched in the given\n // dimensions.\n\n const textLeft = shapedText.left * fontScale;\n const textRight = shapedText.right * fontScale;\n\n let top, right, bottom, left;\n if (textFit === 'width' || textFit === 'both') {\n // Stretched horizontally to the text width\n left = iconOffset[0] + textLeft - padding[3];\n right = iconOffset[0] + textRight + padding[1];\n } else {\n // Centered on the text\n left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2;\n right = left + image.displaySize[0];\n }\n\n const textTop = shapedText.top * fontScale;\n const textBottom = shapedText.bottom * fontScale;\n if (textFit === 'height' || textFit === 'both') {\n // Stretched vertically to the text height\n top = iconOffset[1] + textTop - padding[0];\n bottom = iconOffset[1] + textBottom + padding[2];\n } else {\n // Centered on the text\n top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2;\n bottom = top + image.displaySize[1];\n }\n\n return {image, top, right, bottom, left, collisionPadding};\n}\n","import {Interpolate, interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {clamp} from '../util/util';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\n\nimport type {PropertyValue, PossiblyEvaluatedPropertyValue} from '../style/properties';\nimport type {InterpolationType} from '@maplibre/maplibre-gl-style-spec';\n\nconst MAX_GLYPH_ICON_SIZE = 255;\nconst SIZE_PACK_FACTOR = 128;\nconst MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;\n\nexport {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR, MAX_GLYPH_ICON_SIZE, MAX_PACKED_SIZE};\n\nexport type SizeData = {\n kind: 'constant';\n layoutSize: number;\n} | {\n kind: 'source';\n} | {\n kind: 'camera';\n minZoom: number;\n maxZoom: number;\n minSize: number;\n maxSize: number;\n interpolationType: InterpolationType;\n} | {\n kind: 'composite';\n minZoom: number;\n maxZoom: number;\n interpolationType: InterpolationType;\n};\n\nexport type EvaluatedZoomSize = {uSizeT: number; uSize: number};\n\n// For {text,icon}-size, get the bucket-level data that will be needed by\n// the painter to set symbol-size-related uniforms\nfunction getSizeData(\n tileZoom: number,\n value: PropertyValue>\n): SizeData {\n const {expression} = value;\n\n if (expression.kind === 'constant') {\n const layoutSize = expression.evaluate(new EvaluationParameters(tileZoom + 1));\n return {kind: 'constant', layoutSize};\n\n } else if (expression.kind === 'source') {\n return {kind: 'source'};\n\n } else {\n const {zoomStops, interpolationType} = expression;\n\n // calculate covering zoom stops for zoom-dependent values\n let lower = 0;\n while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) lower++;\n lower = Math.max(0, lower - 1);\n let upper = lower;\n while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) upper++;\n upper = Math.min(zoomStops.length - 1, upper);\n\n const minZoom = zoomStops[lower];\n const maxZoom = zoomStops[upper];\n\n // We'd like to be able to use CameraExpression or CompositeExpression in these\n // return types rather than ExpressionSpecification, but the former are not\n // transferrable across Web Worker boundaries.\n if (expression.kind === 'composite') {\n return {kind: 'composite', minZoom, maxZoom, interpolationType};\n }\n\n // for camera functions, also save off the function values\n // evaluated at the covering zoom levels\n const minSize = expression.evaluate(new EvaluationParameters(minZoom));\n const maxSize = expression.evaluate(new EvaluationParameters(maxZoom));\n\n return {kind: 'camera', minZoom, maxZoom, minSize, maxSize, interpolationType};\n }\n}\n\nfunction evaluateSizeForFeature(sizeData: SizeData,\n {\n uSize,\n uSizeT\n }: {\n uSize: number;\n uSizeT: number;\n },\n {\n lowerSize,\n upperSize\n }: {\n lowerSize: number;\n upperSize: number;\n }): number {\n if (sizeData.kind === 'source') {\n return lowerSize / SIZE_PACK_FACTOR;\n } else if (sizeData.kind === 'composite') {\n return interpolates.number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT);\n }\n return uSize;\n}\n\nfunction evaluateSizeForZoom(sizeData: SizeData, zoom: number): EvaluatedZoomSize {\n let uSizeT = 0;\n let uSize = 0;\n\n if (sizeData.kind === 'constant') {\n uSize = sizeData.layoutSize;\n\n } else if (sizeData.kind !== 'source') {\n const {interpolationType, minZoom, maxZoom} = sizeData;\n\n // Even though we could get the exact value of the camera function\n // at z = tr.zoom, we intentionally do not: instead, we interpolate\n // between the camera function values at a pair of zoom stops covering\n // [tileZoom, tileZoom + 1] in order to be consistent with this\n // restriction on composite functions\n const t = !interpolationType ? 0 : clamp(\n Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1);\n\n if (sizeData.kind === 'camera') {\n uSize = interpolates.number(sizeData.minSize, sizeData.maxSize, t);\n } else {\n uSizeT = t;\n }\n }\n\n return {uSizeT, uSize};\n}\n","import {SymbolLayoutPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\nimport type {SymbolLayoutProps} from './symbol_style_layer_properties.g';\nimport {PossiblyEvaluated} from '../properties';\n\n/**\n * The overlap mode for properties like `icon-overlap`and `text-overlap`\n */\nexport type OverlapMode = 'never' | 'always' | 'cooperative';\n\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap', allowOverlapProp: 'icon-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'text-overlap', allowOverlapProp: 'text-allow-overlap'): OverlapMode;\nexport function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap' | 'text-overlap', allowOverlapProp: 'icon-allow-overlap' | 'text-allow-overlap'): OverlapMode {\n let result: OverlapMode = 'never';\n const overlap = layout.get(overlapProp);\n\n if (overlap) {\n // if -overlap is set, use it\n result = overlap;\n } else if (layout.get(allowOverlapProp)) {\n // fall back to -allow-overlap, with false='never', true='always'\n result = 'always';\n }\n\n return result;\n}\n","import {\n symbolLayoutAttributes,\n collisionVertexAttributes,\n collisionBoxLayout,\n dynamicLayoutAttributes,\n} from './symbol_attributes';\n\nimport {SymbolLayoutArray,\n SymbolDynamicLayoutArray,\n SymbolOpacityArray,\n CollisionBoxLayoutArray,\n CollisionVertexArray,\n PlacedSymbolArray,\n SymbolInstanceArray,\n GlyphOffsetArray,\n SymbolLineVertexArray,\n TextAnchorOffsetArray\n} from '../array_types.g';\n\nimport Point from '@mapbox/point-geometry';\nimport {SegmentVector} from '../segment';\nimport {ProgramConfigurationSet} from '../program_configuration';\nimport {TriangleIndexArray, LineIndexArray} from '../index_array_type';\nimport {transformText} from '../../symbol/transform_text';\nimport {mergeLines} from '../../symbol/merge_lines';\nimport {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';\nimport {WritingMode} from '../../symbol/shaping';\nimport {loadGeometry} from '../load_geometry';\nimport {toEvaluationFeature} from '../evaluation_feature';\nimport mvt from '@mapbox/vector-tile';\nconst vectorTileFeatureTypes = mvt.VectorTileFeature.types;\nimport {verticalizedCharacterMap} from '../../util/verticalize_punctuation';\nimport {Anchor} from '../../symbol/anchor';\nimport {getSizeData, MAX_PACKED_SIZE} from '../../symbol/symbol_size';\n\nimport {register} from '../../util/web_worker_transfer';\nimport {EvaluationParameters} from '../../style/evaluation_parameters';\nimport {Formatted, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';\nimport {mat4} from 'gl-matrix';\nimport {getOverlapMode} from '../../style/style_layer/overlap_mode';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport type {\n Bucket,\n BucketParameters,\n IndexedFeature,\n PopulateParameters\n} from '../bucket';\nimport type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types.g';\nimport type {StructArray, StructArrayMember, ViewType} from '../../util/struct_array';\nimport type {SymbolStyleLayer} from '../../style/style_layer/symbol_style_layer';\nimport type {Context} from '../../gl/context';\nimport type {IndexBuffer} from '../../gl/index_buffer';\nimport type {VertexBuffer} from '../../gl/vertex_buffer';\nimport type {SymbolQuad} from '../../symbol/quads';\nimport type {SizeData} from '../../symbol/symbol_size';\nimport type {FeatureStates} from '../../source/source_state';\nimport type {ImagePosition} from '../../render/image_atlas';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\n\nexport type SingleCollisionBox = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n anchorPointX: number;\n anchorPointY: number;\n};\n\nexport type CollisionArrays = {\n textBox?: SingleCollisionBox;\n verticalTextBox?: SingleCollisionBox;\n iconBox?: SingleCollisionBox;\n verticalIconBox?: SingleCollisionBox;\n textFeatureIndex?: number;\n verticalTextFeatureIndex?: number;\n iconFeatureIndex?: number;\n verticalIconFeatureIndex?: number;\n};\n\nexport type SymbolFeature = {\n sortKey: number | void;\n text: Formatted | void;\n icon: ResolvedImage;\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 'Unknown' | 'Point' | 'LineString' | 'Polygon';\n id?: any;\n};\n\nexport type SortKeyRange = {\n sortKey: number;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n};\n\n// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them\n// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph\n// 7 bits are for the current opacity, and the lowest bit is the target opacity\n\n// actually defined in symbol_attributes.js\n// const placementOpacityAttributes = [\n// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }\n// ];\nconst shaderOpacityAttributes = [\n {name: 'a_fade_opacity', components: 1, type: 'Uint8' as ViewType, offset: 0}\n];\n\nfunction addVertex(\n array: StructArray,\n anchorX: number,\n anchorY: number,\n ox: number,\n oy: number,\n tx: number,\n ty: number,\n sizeVertex: number,\n isSDF: boolean,\n pixelOffsetX: number,\n pixelOffsetY: number,\n minFontScaleX: number,\n minFontScaleY: number\n) {\n const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;\n const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;\n array.emplaceBack(\n // a_pos_offset\n anchorX,\n anchorY,\n Math.round(ox * 32),\n Math.round(oy * 32),\n\n // a_data\n tx, // x coordinate of symbol on glyph atlas texture\n ty, // y coordinate of symbol on glyph atlas texture\n (aSizeX << 1) + (isSDF ? 1 : 0),\n aSizeY,\n pixelOffsetX * 16,\n pixelOffsetY * 16,\n minFontScaleX * 256,\n minFontScaleY * 256\n );\n}\n\nfunction addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) {\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);\n}\n\nfunction containsRTLText(formattedText: Formatted): boolean {\n for (const section of formattedText.sections) {\n if (stringContainsRTLText(section.text)) {\n return true;\n }\n }\n return false;\n}\n\nexport class SymbolBuffers {\n layoutVertexArray: SymbolLayoutArray;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray;\n indexBuffer: IndexBuffer;\n\n programConfigurations: ProgramConfigurationSet;\n segments: SegmentVector;\n\n dynamicLayoutVertexArray: SymbolDynamicLayoutArray;\n dynamicLayoutVertexBuffer: VertexBuffer;\n\n opacityVertexArray: SymbolOpacityArray;\n opacityVertexBuffer: VertexBuffer;\n hasVisibleVertices: boolean;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n placedSymbolArray: PlacedSymbolArray;\n\n constructor(programConfigurations: ProgramConfigurationSet) {\n this.layoutVertexArray = new SymbolLayoutArray();\n this.indexArray = new TriangleIndexArray();\n this.programConfigurations = programConfigurations;\n this.segments = new SegmentVector();\n this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();\n this.opacityVertexArray = new SymbolOpacityArray();\n this.hasVisibleVertices = false;\n this.placedSymbolArray = new PlacedSymbolArray();\n }\n\n isEmpty() {\n return this.layoutVertexArray.length === 0 &&\n this.indexArray.length === 0 &&\n this.dynamicLayoutVertexArray.length === 0 &&\n this.opacityVertexArray.length === 0;\n }\n\n upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) {\n if (this.isEmpty()) {\n return;\n }\n\n if (upload) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);\n this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);\n this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);\n this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);\n // This is a performance hack so that we can write to opacityVertexArray with uint32s\n // even though the shaders read uint8s\n this.opacityVertexBuffer.itemSize = 1;\n }\n if (upload || update) {\n this.programConfigurations.upload(context);\n }\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.programConfigurations.destroy();\n this.segments.destroy();\n this.dynamicLayoutVertexBuffer.destroy();\n this.opacityVertexBuffer.destroy();\n }\n}\n\nregister('SymbolBuffers', SymbolBuffers);\n\nclass CollisionBuffers {\n layoutVertexArray: StructArray;\n layoutAttributes: Array;\n layoutVertexBuffer: VertexBuffer;\n\n indexArray: TriangleIndexArray | LineIndexArray;\n indexBuffer: IndexBuffer;\n\n segments: SegmentVector;\n\n collisionVertexArray: CollisionVertexArray;\n collisionVertexBuffer: VertexBuffer;\n\n constructor(LayoutArray: {\n new (...args: any): StructArray;\n },\n layoutAttributes: Array,\n IndexArray: {\n new (...args: any): TriangleIndexArray | LineIndexArray;\n }) {\n this.layoutVertexArray = new LayoutArray();\n this.layoutAttributes = layoutAttributes;\n this.indexArray = new IndexArray();\n this.segments = new SegmentVector();\n this.collisionVertexArray = new CollisionVertexArray();\n }\n\n upload(context: Context) {\n this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);\n this.indexBuffer = context.createIndexBuffer(this.indexArray);\n this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);\n }\n\n destroy() {\n if (!this.layoutVertexBuffer) return;\n this.layoutVertexBuffer.destroy();\n this.indexBuffer.destroy();\n this.segments.destroy();\n this.collisionVertexBuffer.destroy();\n }\n}\n\nregister('CollisionBuffers', CollisionBuffers);\n\n/**\n * @internal\n * Unlike other buckets, which simply implement #addFeature with type-specific\n * logic for (essentially) triangulating feature geometries, SymbolBucket\n * requires specialized behavior:\n *\n * 1. WorkerTile#parse(), the logical owner of the bucket creation process,\n * calls SymbolBucket#populate(), which resolves text and icon tokens on\n * each feature, adds each glyphs and symbols needed to the passed-in\n * collections options.glyphDependencies and options.iconDependencies, and\n * stores the feature data for use in subsequent step (this.features).\n *\n * 2. WorkerTile asynchronously requests from the main thread all of the glyphs\n * and icons needed (by this bucket and any others). When glyphs and icons\n * have been received, the WorkerTile creates a CollisionIndex and invokes:\n *\n * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and\n * layout on a Symbol Bucket. This step populates:\n * `this.symbolInstances`: metadata on generated symbols\n * `this.collisionBoxArray`: collision data for use by foreground\n * `this.text`: SymbolBuffers for text symbols\n * `this.icons`: SymbolBuffers for icons\n * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes\n * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes\n * The results are sent to the foreground for rendering\n *\n * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,\n * and uses the CollisionIndex along with current camera settings to determine\n * which symbols can actually show on the map. Collided symbols are hidden\n * using a dynamic \"OpacityVertexArray\".\n */\nexport class SymbolBucket implements Bucket {\n static MAX_GLYPHS: number;\n static addDynamicAttributes: typeof addDynamicAttributes;\n\n collisionBoxArray: CollisionBoxArray;\n zoom: number;\n overscaling: number;\n layers: Array;\n layerIds: Array;\n stateDependentLayers: Array;\n stateDependentLayerIds: Array;\n\n index: number;\n sdfIcons: boolean;\n iconsInText: boolean;\n iconsNeedLinear: boolean;\n bucketInstanceId: number;\n justReloaded: boolean;\n hasPattern: boolean;\n\n textSizeData: SizeData;\n iconSizeData: SizeData;\n\n glyphOffsetArray: GlyphOffsetArray;\n lineVertexArray: SymbolLineVertexArray;\n features: Array;\n symbolInstances: SymbolInstanceArray;\n textAnchorOffsets: TextAnchorOffsetArray;\n collisionArrays: Array;\n sortKeyRanges: Array;\n pixelRatio: number;\n tilePixelRatio: number;\n compareText: {[_: string]: Array};\n fadeStartTime: number;\n sortFeaturesByKey: boolean;\n sortFeaturesByY: boolean;\n canOverlap: boolean;\n sortedAngle: number;\n featureSortOrder: Array;\n\n collisionCircleArray: Array;\n placementInvProjMatrix: mat4;\n placementViewportMatrix: mat4;\n\n text: SymbolBuffers;\n icon: SymbolBuffers;\n textCollisionBox: CollisionBuffers;\n iconCollisionBox: CollisionBuffers;\n uploaded: boolean;\n sourceLayerIndex: number;\n sourceID: string;\n symbolInstanceIndexes: Array;\n writingModes: WritingMode[];\n allowVerticalPlacement: boolean;\n hasRTLText: boolean;\n\n constructor(options: BucketParameters) {\n this.collisionBoxArray = options.collisionBoxArray;\n this.zoom = options.zoom;\n this.overscaling = options.overscaling;\n this.layers = options.layers;\n this.layerIds = this.layers.map(layer => layer.id);\n this.index = options.index;\n this.pixelRatio = options.pixelRatio;\n this.sourceLayerIndex = options.sourceLayerIndex;\n this.hasPattern = false;\n this.hasRTLText = false;\n this.sortKeyRanges = [];\n\n this.collisionCircleArray = [];\n this.placementInvProjMatrix = mat4.identity([] as any);\n this.placementViewportMatrix = mat4.identity([] as any);\n\n const layer = this.layers[0];\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);\n this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);\n\n const layout = this.layers[0].layout;\n const sortKey = layout.get('symbol-sort-key');\n const zOrder = layout.get('symbol-z-order');\n this.canOverlap =\n getOverlapMode(layout, 'text-overlap', 'text-allow-overlap') !== 'never' ||\n getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap') !== 'never' ||\n layout.get('text-ignore-placement') ||\n layout.get('icon-ignore-placement');\n this.sortFeaturesByKey = zOrder !== 'viewport-y' && !sortKey.isConstant();\n const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey);\n this.sortFeaturesByY = zOrderByViewportY && this.canOverlap;\n\n if (layout.get('symbol-placement') === 'point') {\n this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]);\n }\n\n this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);\n\n this.sourceID = options.sourceID;\n }\n\n createArrays() {\n this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property)));\n this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property)));\n\n this.glyphOffsetArray = new GlyphOffsetArray();\n this.lineVertexArray = new SymbolLineVertexArray();\n this.symbolInstances = new SymbolInstanceArray();\n this.textAnchorOffsets = new TextAnchorOffsetArray();\n }\n\n calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {\n for (let i = 0; i < text.length; i++) {\n stack[text.charCodeAt(i)] = true;\n if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {\n const verticalChar = verticalizedCharacterMap[text.charAt(i)];\n if (verticalChar) {\n stack[verticalChar.charCodeAt(0)] = true;\n }\n }\n }\n }\n\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) {\n const layer = this.layers[0];\n const layout = layer.layout;\n\n const textFont = layout.get('text-font');\n const textField = layout.get('text-field');\n const iconImage = layout.get('icon-image');\n const hasText =\n (textField.value.kind !== 'constant' ||\n (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) ||\n textField.value.value.toString().length > 0) &&\n (textFont.value.kind !== 'constant' || textFont.value.value.length > 0);\n // we should always resolve the icon-image value if the property was defined in the style\n // this allows us to fire the styleimagemissing event if image evaluation returns null\n // the only way to distinguish between null returned from a coalesce statement with no valid images\n // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object\n const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;\n const symbolSortKey = layout.get('symbol-sort-key');\n\n this.features = [];\n\n if (!hasText && !hasIcon) {\n return;\n }\n\n const icons = options.iconDependencies;\n const stacks = options.glyphDependencies;\n const availableImages = options.availableImages;\n const globalProperties = new EvaluationParameters(this.zoom);\n\n for (const {feature, id, index, sourceLayerIndex} of features) {\n\n const needGeometry = layer._featureFilter.needGeometry;\n const evaluationFeature = toEvaluationFeature(feature, needGeometry);\n if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {\n continue;\n }\n\n if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature);\n\n let text: Formatted | void;\n if (hasText) {\n // Expression evaluation will automatically coerce to Formatted\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages);\n const formattedText = Formatted.factory(resolvedTokens);\n if (containsRTLText(formattedText)) {\n this.hasRTLText = true;\n }\n if (\n !this.hasRTLText || // non-rtl text so can proceed safely\n getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping\n this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text\n ) {\n text = transformText(formattedText, layer, evaluationFeature);\n }\n }\n\n let icon: ResolvedImage;\n if (hasIcon) {\n // Expression evaluation will automatically coerce to Image\n // but plain string token evaluation skips that pathway so do the\n // conversion here.\n const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages);\n if (resolvedTokens instanceof ResolvedImage) {\n icon = resolvedTokens;\n } else {\n icon = ResolvedImage.fromString(resolvedTokens);\n }\n }\n\n if (!text && !icon) {\n continue;\n }\n const sortKey = this.sortFeaturesByKey ?\n symbolSortKey.evaluate(evaluationFeature, {}, canonical) :\n undefined;\n\n const symbolFeature: SymbolFeature = {\n id,\n text,\n icon,\n index,\n sourceLayerIndex,\n geometry: evaluationFeature.geometry,\n properties: feature.properties,\n type: vectorTileFeatureTypes[feature.type],\n sortKey\n };\n this.features.push(symbolFeature);\n\n if (icon) {\n icons[icon.name] = true;\n }\n\n if (text) {\n const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;\n for (const section of text.sections) {\n if (!section.image) {\n const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());\n const sectionFont = section.fontStack || fontStack;\n const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};\n this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);\n } else {\n // Add section image to the list of dependencies.\n icons[section.image.name] = true;\n }\n }\n }\n }\n\n if (layout.get('symbol-placement') === 'line') {\n // Merge adjacent lines with the same text to improve labelling.\n // It's better to place labels on one long line than on many short segments.\n this.features = mergeLines(this.features);\n }\n\n if (this.sortFeaturesByKey) {\n this.features.sort((a, b) => {\n // a.sortKey is always a number when sortFeaturesByKey is true\n return (a.sortKey as number) - (b.sortKey as number);\n });\n }\n }\n\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {\n if (!this.stateDependentLayers.length) return;\n this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);\n }\n\n isEmpty() {\n // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created.\n // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary.\n return this.symbolInstances.length === 0 && !this.hasRTLText;\n }\n\n uploadPending() {\n return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;\n }\n\n upload(context: Context) {\n if (!this.uploaded && this.hasDebugData()) {\n this.textCollisionBox.upload(context);\n this.iconCollisionBox.upload(context);\n }\n this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);\n this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);\n this.uploaded = true;\n }\n\n destroyDebugData() {\n this.textCollisionBox.destroy();\n this.iconCollisionBox.destroy();\n }\n\n destroy() {\n this.text.destroy();\n this.icon.destroy();\n\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n }\n\n addToLineVertexArray(anchor: Anchor, line: any) {\n const lineStartIndex = this.lineVertexArray.length;\n if (anchor.segment !== undefined) {\n let sumForwardLength = anchor.dist(line[anchor.segment + 1]);\n let sumBackwardLength = anchor.dist(line[anchor.segment]);\n const vertices = {};\n for (let i = anchor.segment + 1; i < line.length; i++) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};\n if (i < line.length - 1) {\n sumForwardLength += line[i + 1].dist(line[i]);\n }\n }\n for (let i = anchor.segment || 0; i >= 0; i--) {\n vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};\n if (i > 0) {\n sumBackwardLength += line[i - 1].dist(line[i]);\n }\n }\n for (let i = 0; i < line.length; i++) {\n const vertex = vertices[i];\n this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);\n }\n }\n return {\n lineStartIndex,\n lineLength: this.lineVertexArray.length - lineStartIndex\n };\n }\n\n addSymbols(arrays: SymbolBuffers,\n quads: Array,\n sizeVertex: any,\n lineOffset: [number, number],\n alongLine: boolean,\n feature: SymbolFeature,\n writingMode: WritingMode,\n labelAnchor: Anchor,\n lineStartIndex: number,\n lineLength: number,\n associatedIconIndex: number,\n canonical: CanonicalTileID) {\n const indexArray = arrays.indexArray;\n const layoutVertexArray = arrays.layoutVertexArray;\n\n const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey as number : undefined);\n const glyphOffsetArrayStart = this.glyphOffsetArray.length;\n const vertexStartIndex = segment.vertexLength;\n\n const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0;\n\n const sections = feature.text && feature.text.sections;\n\n for (let i = 0; i < quads.length; i++) {\n const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i];\n const index = segment.vertexLength;\n\n const y = glyphOffset[1];\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);\n\n addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);\n\n indexArray.emplaceBack(index, index + 1, index + 2);\n indexArray.emplaceBack(index + 1, index + 2, index + 3);\n\n segment.vertexLength += 4;\n segment.primitiveLength += 2;\n\n this.glyphOffsetArray.emplaceBack(glyphOffset[0]);\n\n if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {\n arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);\n }\n }\n\n arrays.placedSymbolArray.emplaceBack(\n labelAnchor.x, labelAnchor.y,\n glyphOffsetArrayStart,\n this.glyphOffsetArray.length - glyphOffsetArrayStart,\n vertexStartIndex,\n lineStartIndex,\n lineLength,\n labelAnchor.segment,\n sizeVertex ? sizeVertex[0] : 0,\n sizeVertex ? sizeVertex[1] : 0,\n lineOffset[0], lineOffset[1],\n writingMode,\n // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed\n 0,\n false as unknown as number,\n // The crossTileID is only filled/used on the foreground for dynamic text anchors\n 0,\n associatedIconIndex\n );\n }\n\n _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) {\n collisionVertexArray.emplaceBack(0, 0);\n return layoutVertexArray.emplaceBack(\n // pos\n point.x,\n point.y,\n // a_anchor_pos\n anchorX,\n anchorY,\n // extrude\n Math.round(extrude.x),\n Math.round(extrude.y));\n }\n\n addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance) {\n const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);\n const index = segment.vertexLength;\n\n const layoutVertexArray = arrays.layoutVertexArray;\n const collisionVertexArray = arrays.collisionVertexArray;\n\n const anchorX = symbolInstance.anchorX;\n const anchorY = symbolInstance.anchorY;\n\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2));\n this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2));\n\n segment.vertexLength += 4;\n\n const indexArray = arrays.indexArray as LineIndexArray;\n indexArray.emplaceBack(index, index + 1);\n indexArray.emplaceBack(index + 1, index + 2);\n indexArray.emplaceBack(index + 2, index + 3);\n indexArray.emplaceBack(index + 3, index);\n\n segment.primitiveLength += 4;\n }\n\n addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {\n for (let b = startIndex; b < endIndex; b++) {\n const box: CollisionBox = this.collisionBoxArray.get(b);\n const x1 = box.x1;\n const y1 = box.y1;\n const x2 = box.x2;\n const y2 = box.y2;\n\n this.addCollisionDebugVertices(x1, y1, x2, y2,\n isText ? this.textCollisionBox : this.iconCollisionBox,\n box.anchorPoint, symbolInstance);\n }\n }\n\n generateCollisionDebugBuffers() {\n if (this.hasDebugData()) {\n this.destroyDebugData();\n }\n\n this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);\n\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true);\n this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false);\n this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false);\n }\n }\n\n // These flat arrays are meant to be quicker to iterate over than the source\n // CollisionBoxArray\n _deserializeCollisionBoxesForSymbol(\n collisionBoxArray: CollisionBoxArray,\n textStartIndex: number,\n textEndIndex: number,\n verticalTextStartIndex: number,\n verticalTextEndIndex: number,\n iconStartIndex: number,\n iconEndIndex: number,\n verticalIconStartIndex: number,\n verticalIconEndIndex: number\n ): CollisionArrays {\n\n const collisionArrays = {} as CollisionArrays;\n for (let k = textStartIndex; k < textEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.textFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalTextFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = iconStartIndex; k < iconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.iconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {\n // An icon can only have one box now, so this indexing is a bit vestigial...\n const box: CollisionBox = collisionBoxArray.get(k);\n collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};\n collisionArrays.verticalIconFeatureIndex = box.featureIndex;\n break; // Only one box allowed per instance\n }\n return collisionArrays;\n }\n\n deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) {\n this.collisionArrays = [];\n for (let i = 0; i < this.symbolInstances.length; i++) {\n const symbolInstance = this.symbolInstances.get(i);\n this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(\n collisionBoxArray,\n symbolInstance.textBoxStartIndex,\n symbolInstance.textBoxEndIndex,\n symbolInstance.verticalTextBoxStartIndex,\n symbolInstance.verticalTextBoxEndIndex,\n symbolInstance.iconBoxStartIndex,\n symbolInstance.iconBoxEndIndex,\n symbolInstance.verticalIconBoxStartIndex,\n symbolInstance.verticalIconBoxEndIndex\n ));\n }\n }\n\n hasTextData() {\n return this.text.segments.get().length > 0;\n }\n\n hasIconData() {\n return this.icon.segments.get().length > 0;\n }\n\n hasDebugData() {\n return this.textCollisionBox && this.iconCollisionBox;\n }\n\n hasTextCollisionBoxData() {\n return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;\n }\n\n hasIconCollisionBoxData() {\n return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;\n }\n\n addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) {\n const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);\n\n const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;\n for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {\n iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);\n iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);\n }\n }\n\n getSortedSymbolIndexes(angle: number) {\n if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) {\n return this.symbolInstanceIndexes;\n }\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n const rotatedYs = [];\n const featureIndexes = [];\n const result = [];\n\n for (let i = 0; i < this.symbolInstances.length; ++i) {\n result.push(i);\n const symbolInstance = this.symbolInstances.get(i);\n rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);\n featureIndexes.push(symbolInstance.featureIndex);\n }\n\n result.sort((aIndex, bIndex) => {\n return (rotatedYs[aIndex] - rotatedYs[bIndex]) ||\n (featureIndexes[bIndex] - featureIndexes[aIndex]);\n });\n\n return result;\n }\n\n addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) {\n const last = this.sortKeyRanges[this.sortKeyRanges.length - 1];\n if (last && last.sortKey === sortKey) {\n last.symbolInstanceEnd = symbolInstanceIndex + 1;\n } else {\n this.sortKeyRanges.push({\n sortKey,\n symbolInstanceStart: symbolInstanceIndex,\n symbolInstanceEnd: symbolInstanceIndex + 1\n });\n }\n }\n\n sortFeatures(angle: number) {\n if (!this.sortFeaturesByY) return;\n if (this.sortedAngle === angle) return;\n\n // The current approach to sorting doesn't sort across segments so don't try.\n // Sorting within segments separately seemed not to be worth the complexity.\n if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return;\n\n // If the symbols are allowed to overlap sort them by their vertical screen position.\n // The index array buffer is rewritten to reference the (unchanged) vertices in the\n // sorted order.\n\n // To avoid sorting the actual symbolInstance array we sort an array of indexes.\n this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);\n this.sortedAngle = angle;\n\n this.text.indexArray.clear();\n this.icon.indexArray.clear();\n\n this.featureSortOrder = [];\n\n for (const i of this.symbolInstanceIndexes) {\n const symbolInstance = this.symbolInstances.get(i);\n this.featureSortOrder.push(symbolInstance.featureIndex);\n\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach((index, i, array) => {\n // Only add a given index the first time it shows up,\n // to avoid duplicate opacity entries when multiple justifications\n // share the same glyphs.\n if (index >= 0 && array.indexOf(index) === i) {\n this.addIndicesForPlacedSymbol(this.text, index);\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex);\n }\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex);\n }\n }\n\n if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray);\n if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray);\n }\n}\n\nregister('SymbolBucket', SymbolBucket, {\n omit: ['layers', 'collisionBoxArray', 'features', 'compareText']\n});\n\n// this constant is based on the size of StructArray indexes used in a symbol\n// bucket--namely, glyphOffsetArrayStart\n// eg the max valid UInt16 is 65,535\n// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation\n// lineStartIndex and textBoxStartIndex could potentially be concerns\n// but we expect there to be many fewer boxes/lines than glyphs\nSymbolBucket.MAX_GLYPHS = 65535;\n\nSymbolBucket.addDynamicAttributes = addDynamicAttributes;\n\nexport {addDynamicAttributes};\n","import type {SymbolFeature} from '../data/bucket/symbol_bucket';\n\nexport function mergeLines(features: Array): Array {\n const leftIndex: {[_: string]: number} = {};\n const rightIndex: {[_: string]: number} = {};\n const mergedFeatures = [];\n let mergedIndex = 0;\n\n function add(k) {\n mergedFeatures.push(features[k]);\n mergedIndex++;\n }\n\n function mergeFromRight(leftKey: string, rightKey: string, geom) {\n const i = rightIndex[leftKey];\n delete rightIndex[leftKey];\n rightIndex[rightKey] = i;\n\n mergedFeatures[i].geometry[0].pop();\n mergedFeatures[i].geometry[0] = mergedFeatures[i].geometry[0].concat(geom[0]);\n return i;\n }\n\n function mergeFromLeft(leftKey: string, rightKey: string, geom) {\n const i = leftIndex[rightKey];\n delete leftIndex[rightKey];\n leftIndex[leftKey] = i;\n\n mergedFeatures[i].geometry[0].shift();\n mergedFeatures[i].geometry[0] = geom[0].concat(mergedFeatures[i].geometry[0]);\n return i;\n }\n\n function getKey(text, geom, onRight?) {\n const point = onRight ? geom[0][geom[0].length - 1] : geom[0][0];\n return `${text}:${point.x}:${point.y}`;\n }\n\n for (let k = 0; k < features.length; k++) {\n const feature = features[k];\n const geom = feature.geometry;\n const text = feature.text ? feature.text.toString() : null;\n\n if (!text) {\n add(k);\n continue;\n }\n\n const leftKey = getKey(text, geom),\n rightKey = getKey(text, geom, true);\n\n if ((leftKey in rightIndex) && (rightKey in leftIndex) && (rightIndex[leftKey] !== leftIndex[rightKey])) {\n // found lines with the same text adjacent to both ends of the current line, merge all three\n const j = mergeFromLeft(leftKey, rightKey, geom);\n const i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry);\n\n delete leftIndex[leftKey];\n delete rightIndex[rightKey];\n\n rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i;\n mergedFeatures[j].geometry = null;\n\n } else if (leftKey in rightIndex) {\n // found mergeable line adjacent to the start of the current line, merge\n mergeFromRight(leftKey, rightKey, geom);\n\n } else if (rightKey in leftIndex) {\n // found mergeable line adjacent to the end of the current line, merge\n mergeFromLeft(leftKey, rightKey, geom);\n\n } else {\n // no adjacent lines, add as a new item\n add(k);\n leftIndex[leftKey] = mergedIndex - 1;\n rightIndex[rightKey] = mergedIndex - 1;\n }\n }\n\n return mergedFeatures.filter((f) => f.geometry);\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n ColorType\n } from '@maplibre/maplibre-gl-style-spec';\n \nexport type SymbolLayoutProps = {\n \"symbol-placement\": DataConstantProperty<\"point\" | \"line\" | \"line-center\">,\n \"symbol-spacing\": DataConstantProperty,\n \"symbol-avoid-edges\": DataConstantProperty,\n \"symbol-sort-key\": DataDrivenProperty,\n \"symbol-z-order\": DataConstantProperty<\"auto\" | \"viewport-y\" | \"source\">,\n \"icon-allow-overlap\": DataConstantProperty,\n \"icon-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"icon-ignore-placement\": DataConstantProperty,\n \"icon-optional\": DataConstantProperty,\n \"icon-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"icon-size\": DataDrivenProperty,\n \"icon-text-fit\": DataConstantProperty<\"none\" | \"width\" | \"height\" | \"both\">,\n \"icon-text-fit-padding\": DataConstantProperty<[number, number, number, number]>,\n \"icon-image\": DataDrivenProperty,\n \"icon-rotate\": DataDrivenProperty,\n \"icon-padding\": DataDrivenProperty,\n \"icon-keep-upright\": DataConstantProperty,\n \"icon-offset\": DataDrivenProperty<[number, number]>,\n \"icon-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-pitch-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"auto\">,\n \"text-rotation-alignment\": DataConstantProperty<\"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\">,\n \"text-field\": DataDrivenProperty,\n \"text-font\": DataDrivenProperty>,\n \"text-size\": DataDrivenProperty,\n \"text-max-width\": DataDrivenProperty,\n \"text-line-height\": DataConstantProperty,\n \"text-letter-spacing\": DataDrivenProperty,\n \"text-justify\": DataDrivenProperty<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": DataDrivenProperty,\n \"text-variable-anchor\": DataConstantProperty>,\n \"text-variable-anchor-offset\": DataDrivenProperty,\n \"text-anchor\": DataDrivenProperty<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": DataConstantProperty,\n \"text-writing-mode\": DataConstantProperty>,\n \"text-rotate\": DataDrivenProperty,\n \"text-padding\": DataConstantProperty,\n \"text-keep-upright\": DataConstantProperty,\n \"text-transform\": DataDrivenProperty<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": DataDrivenProperty<[number, number]>,\n \"text-allow-overlap\": DataConstantProperty,\n \"text-overlap\": DataConstantProperty<\"never\" | \"always\" | \"cooperative\">,\n \"text-ignore-placement\": DataConstantProperty,\n \"text-optional\": DataConstantProperty,\n};\n\nexport type SymbolLayoutPropsPossiblyEvaluated = {\n \"symbol-placement\": \"point\" | \"line\" | \"line-center\",\n \"symbol-spacing\": number,\n \"symbol-avoid-edges\": boolean,\n \"symbol-sort-key\": PossiblyEvaluatedPropertyValue,\n \"symbol-z-order\": \"auto\" | \"viewport-y\" | \"source\",\n \"icon-allow-overlap\": boolean,\n \"icon-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"icon-ignore-placement\": boolean,\n \"icon-optional\": boolean,\n \"icon-rotation-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"icon-size\": PossiblyEvaluatedPropertyValue,\n \"icon-text-fit\": \"none\" | \"width\" | \"height\" | \"both\",\n \"icon-text-fit-padding\": [number, number, number, number],\n \"icon-image\": PossiblyEvaluatedPropertyValue,\n \"icon-rotate\": PossiblyEvaluatedPropertyValue,\n \"icon-padding\": PossiblyEvaluatedPropertyValue,\n \"icon-keep-upright\": boolean,\n \"icon-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"icon-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"icon-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-pitch-alignment\": \"map\" | \"viewport\" | \"auto\",\n \"text-rotation-alignment\": \"map\" | \"viewport\" | \"viewport-glyph\" | \"auto\",\n \"text-field\": PossiblyEvaluatedPropertyValue,\n \"text-font\": PossiblyEvaluatedPropertyValue>,\n \"text-size\": PossiblyEvaluatedPropertyValue,\n \"text-max-width\": PossiblyEvaluatedPropertyValue,\n \"text-line-height\": number,\n \"text-letter-spacing\": PossiblyEvaluatedPropertyValue,\n \"text-justify\": PossiblyEvaluatedPropertyValue<\"auto\" | \"left\" | \"center\" | \"right\">,\n \"text-radial-offset\": PossiblyEvaluatedPropertyValue,\n \"text-variable-anchor\": Array<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-variable-anchor-offset\": PossiblyEvaluatedPropertyValue,\n \"text-anchor\": PossiblyEvaluatedPropertyValue<\"center\" | \"left\" | \"right\" | \"top\" | \"bottom\" | \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\">,\n \"text-max-angle\": number,\n \"text-writing-mode\": Array<\"horizontal\" | \"vertical\">,\n \"text-rotate\": PossiblyEvaluatedPropertyValue,\n \"text-padding\": number,\n \"text-keep-upright\": boolean,\n \"text-transform\": PossiblyEvaluatedPropertyValue<\"none\" | \"uppercase\" | \"lowercase\">,\n \"text-offset\": PossiblyEvaluatedPropertyValue<[number, number]>,\n \"text-allow-overlap\": boolean,\n \"text-overlap\": \"never\" | \"always\" | \"cooperative\",\n \"text-ignore-placement\": boolean,\n \"text-optional\": boolean,\n};\n\nlet layout: Properties;\nconst getLayout = () => layout = layout || new Properties({\n \"symbol-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-placement\"] as any as StylePropertySpecification),\n \"symbol-spacing\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-spacing\"] as any as StylePropertySpecification),\n \"symbol-avoid-edges\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-avoid-edges\"] as any as StylePropertySpecification),\n \"symbol-sort-key\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"symbol-sort-key\"] as any as StylePropertySpecification),\n \"symbol-z-order\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"symbol-z-order\"] as any as StylePropertySpecification),\n \"icon-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-allow-overlap\"] as any as StylePropertySpecification),\n \"icon-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-overlap\"] as any as StylePropertySpecification),\n \"icon-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-ignore-placement\"] as any as StylePropertySpecification),\n \"icon-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-optional\"] as any as StylePropertySpecification),\n \"icon-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-rotation-alignment\"] as any as StylePropertySpecification),\n \"icon-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-size\"] as any as StylePropertySpecification),\n \"icon-text-fit\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit\"] as any as StylePropertySpecification),\n \"icon-text-fit-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-text-fit-padding\"] as any as StylePropertySpecification),\n \"icon-image\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-image\"] as any as StylePropertySpecification),\n \"icon-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-rotate\"] as any as StylePropertySpecification),\n \"icon-padding\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-padding\"] as any as StylePropertySpecification),\n \"icon-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-keep-upright\"] as any as StylePropertySpecification),\n \"icon-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-offset\"] as any as StylePropertySpecification),\n \"icon-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"icon-anchor\"] as any as StylePropertySpecification),\n \"icon-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"icon-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-pitch-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-pitch-alignment\"] as any as StylePropertySpecification),\n \"text-rotation-alignment\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-rotation-alignment\"] as any as StylePropertySpecification),\n \"text-field\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-field\"] as any as StylePropertySpecification),\n \"text-font\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-font\"] as any as StylePropertySpecification),\n \"text-size\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-size\"] as any as StylePropertySpecification),\n \"text-max-width\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-max-width\"] as any as StylePropertySpecification),\n \"text-line-height\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-line-height\"] as any as StylePropertySpecification),\n \"text-letter-spacing\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-letter-spacing\"] as any as StylePropertySpecification),\n \"text-justify\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-justify\"] as any as StylePropertySpecification),\n \"text-radial-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-radial-offset\"] as any as StylePropertySpecification),\n \"text-variable-anchor\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor\"] as any as StylePropertySpecification),\n \"text-variable-anchor-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-variable-anchor-offset\"] as any as StylePropertySpecification),\n \"text-anchor\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-anchor\"] as any as StylePropertySpecification),\n \"text-max-angle\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-max-angle\"] as any as StylePropertySpecification),\n \"text-writing-mode\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-writing-mode\"] as any as StylePropertySpecification),\n \"text-rotate\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-rotate\"] as any as StylePropertySpecification),\n \"text-padding\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-padding\"] as any as StylePropertySpecification),\n \"text-keep-upright\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-keep-upright\"] as any as StylePropertySpecification),\n \"text-transform\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-transform\"] as any as StylePropertySpecification),\n \"text-offset\": new DataDrivenProperty(styleSpec[\"layout_symbol\"][\"text-offset\"] as any as StylePropertySpecification),\n \"text-allow-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-allow-overlap\"] as any as StylePropertySpecification),\n \"text-overlap\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-overlap\"] as any as StylePropertySpecification),\n \"text-ignore-placement\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-ignore-placement\"] as any as StylePropertySpecification),\n \"text-optional\": new DataConstantProperty(styleSpec[\"layout_symbol\"][\"text-optional\"] as any as StylePropertySpecification),\n});\n\nexport type SymbolPaintProps = {\n \"icon-opacity\": DataDrivenProperty,\n \"icon-color\": DataDrivenProperty,\n \"icon-halo-color\": DataDrivenProperty,\n \"icon-halo-width\": DataDrivenProperty,\n \"icon-halo-blur\": DataDrivenProperty,\n \"icon-translate\": DataConstantProperty<[number, number]>,\n \"icon-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n \"text-opacity\": DataDrivenProperty,\n \"text-color\": DataDrivenProperty,\n \"text-halo-color\": DataDrivenProperty,\n \"text-halo-width\": DataDrivenProperty,\n \"text-halo-blur\": DataDrivenProperty,\n \"text-translate\": DataConstantProperty<[number, number]>,\n \"text-translate-anchor\": DataConstantProperty<\"map\" | \"viewport\">,\n};\n\nexport type SymbolPaintPropsPossiblyEvaluated = {\n \"icon-opacity\": PossiblyEvaluatedPropertyValue,\n \"icon-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-color\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-width\": PossiblyEvaluatedPropertyValue,\n \"icon-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"icon-translate\": [number, number],\n \"icon-translate-anchor\": \"map\" | \"viewport\",\n \"text-opacity\": PossiblyEvaluatedPropertyValue,\n \"text-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-color\": PossiblyEvaluatedPropertyValue,\n \"text-halo-width\": PossiblyEvaluatedPropertyValue,\n \"text-halo-blur\": PossiblyEvaluatedPropertyValue,\n \"text-translate\": [number, number],\n \"text-translate-anchor\": \"map\" | \"viewport\",\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"icon-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-opacity\"] as any as StylePropertySpecification),\n \"icon-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-color\"] as any as StylePropertySpecification),\n \"icon-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-color\"] as any as StylePropertySpecification),\n \"icon-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-width\"] as any as StylePropertySpecification),\n \"icon-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"icon-halo-blur\"] as any as StylePropertySpecification),\n \"icon-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate\"] as any as StylePropertySpecification),\n \"icon-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"icon-translate-anchor\"] as any as StylePropertySpecification),\n \"text-opacity\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-opacity\"] as any as StylePropertySpecification),\n \"text-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-color\"] as any as StylePropertySpecification, { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }),\n \"text-halo-color\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-color\"] as any as StylePropertySpecification),\n \"text-halo-width\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-width\"] as any as StylePropertySpecification),\n \"text-halo-blur\": new DataDrivenProperty(styleSpec[\"paint_symbol\"][\"text-halo-blur\"] as any as StylePropertySpecification),\n \"text-translate\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate\"] as any as StylePropertySpecification),\n \"text-translate-anchor\": new DataConstantProperty(styleSpec[\"paint_symbol\"][\"text-translate-anchor\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() }, get layout() { return getLayout() } });","import type {Expression, EvaluationContext, Type, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {NullType} from '@maplibre/maplibre-gl-style-spec';\nimport {PossiblyEvaluatedPropertyValue} from './properties';\nimport {register} from '../util/web_worker_transfer';\n\n// This is an internal expression class. It is only used in GL JS and\n// has GL JS dependencies which can break the standalone style-spec module\nexport class FormatSectionOverride implements Expression {\n type: Type;\n defaultValue: PossiblyEvaluatedPropertyValue;\n\n constructor(defaultValue: PossiblyEvaluatedPropertyValue) {\n if (defaultValue.property.overrides === undefined) throw new Error('overrides must be provided to instantiate FormatSectionOverride class');\n this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType;\n this.defaultValue = defaultValue;\n }\n\n evaluate(ctx: EvaluationContext) {\n if (ctx.formattedSection) {\n const overrides = this.defaultValue.property.overrides;\n if (overrides && overrides.hasOverride(ctx.formattedSection)) {\n return overrides.getOverride(ctx.formattedSection);\n }\n }\n\n if (ctx.feature && ctx.featureState) {\n return this.defaultValue.evaluate(ctx.feature, ctx.featureState);\n }\n\n return this.defaultValue.property.specification.default;\n }\n\n eachChild(fn: (_: Expression) => void) {\n if (!this.defaultValue.isConstant()) {\n const expr: ZoomConstantExpression<'source'> = (this.defaultValue.value as any);\n fn(expr._styleExpression.expression);\n }\n }\n\n // Cannot be statically evaluated, as the output depends on the evaluation context.\n outputDefined() {\n return false;\n }\n\n serialize() {\n return null;\n }\n}\n\nregister('FormatSectionOverride', FormatSectionOverride, {omit: ['defaultValue']});\n","import {StyleLayer} from '../style_layer';\n\nimport {SymbolBucket, SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {resolveTokens} from '../../util/resolve_tokens';\nimport properties, {SymbolLayoutPropsPossiblyEvaluated, SymbolPaintPropsPossiblyEvaluated} from './symbol_style_layer_properties.g';\n\nimport {\n Transitionable,\n Transitioning,\n Layout,\n PossiblyEvaluated,\n PossiblyEvaluatedPropertyValue,\n PropertyValue\n} from '../properties';\n\nimport {\n isExpression,\n StyleExpression,\n ZoomConstantExpression,\n ZoomDependentExpression,\n FormattedType,\n typeOf,\n Formatted,\n FormatExpression,\n Literal} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BucketParameters} from '../../data/bucket';\nimport type {SymbolLayoutProps, SymbolPaintProps} from './symbol_style_layer_properties.g';\nimport type {EvaluationParameters} from '../evaluation_parameters';\nimport type {Expression, Feature, SourceExpression, LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {CanonicalTileID} from '../../source/tile_id';\nimport {FormatSectionOverride} from '../format_section_override';\n\nexport class SymbolStyleLayer extends StyleLayer {\n _unevaluatedLayout: Layout;\n layout: PossiblyEvaluated;\n\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n\n recalculate(parameters: EvaluationParameters, availableImages: Array) {\n super.recalculate(parameters, availableImages);\n\n if (this.layout.get('icon-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['icon-rotation-alignment'] = 'map';\n } else {\n this.layout._values['icon-rotation-alignment'] = 'viewport';\n }\n }\n\n if (this.layout.get('text-rotation-alignment') === 'auto') {\n if (this.layout.get('symbol-placement') !== 'point') {\n this.layout._values['text-rotation-alignment'] = 'map';\n } else {\n this.layout._values['text-rotation-alignment'] = 'viewport';\n }\n }\n\n // If unspecified, `*-pitch-alignment` inherits `*-rotation-alignment`\n if (this.layout.get('text-pitch-alignment') === 'auto') {\n this.layout._values['text-pitch-alignment'] = this.layout.get('text-rotation-alignment') === 'map' ? 'map' : 'viewport';\n }\n if (this.layout.get('icon-pitch-alignment') === 'auto') {\n this.layout._values['icon-pitch-alignment'] = this.layout.get('icon-rotation-alignment');\n }\n\n if (this.layout.get('symbol-placement') === 'point') {\n const writingModes = this.layout.get('text-writing-mode');\n if (writingModes) {\n // remove duplicates, preserving order\n const deduped = [];\n for (const m of writingModes) {\n if (deduped.indexOf(m) < 0) deduped.push(m);\n }\n this.layout._values['text-writing-mode'] = deduped;\n } else {\n this.layout._values['text-writing-mode'] = ['horizontal'];\n }\n }\n\n this._setPaintOverrides();\n }\n\n getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array) {\n const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages);\n const unevaluated = this._unevaluatedLayout._values[name];\n if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) {\n return resolveTokens(feature.properties, value);\n }\n\n return value;\n }\n\n createBucket(parameters: BucketParameters) {\n return new SymbolBucket(parameters);\n }\n\n queryRadius(): number {\n return 0;\n }\n\n queryIntersectsFeature(): boolean {\n throw new Error('Should take a different path in FeatureIndex');\n }\n\n _setPaintOverrides() {\n for (const overridable of properties.paint.overridableProperties) {\n if (!SymbolStyleLayer.hasPaintOverride(this.layout, overridable)) {\n continue;\n }\n const overriden = this.paint.get(overridable as keyof SymbolPaintPropsPossiblyEvaluated) as PossiblyEvaluatedPropertyValue;\n const override = new FormatSectionOverride(overriden);\n const styleExpression = new StyleExpression(override, overriden.property.specification);\n let expression = null;\n if (overriden.value.kind === 'constant' || overriden.value.kind === 'source') {\n expression = new ZoomConstantExpression('source', styleExpression) as SourceExpression;\n } else {\n expression = new ZoomDependentExpression('composite',\n styleExpression,\n overriden.value.zoomStops);\n }\n this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property,\n expression,\n overriden.parameters);\n }\n }\n\n _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean {\n if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) {\n return false;\n }\n return SymbolStyleLayer.hasPaintOverride(this.layout, name);\n }\n\n static hasPaintOverride(layout: PossiblyEvaluated, propertyName: string): boolean {\n const textField = layout.get('text-field');\n const property = properties.paint.properties[propertyName];\n let hasOverrides = false;\n\n const checkSections = (sections) => {\n for (const section of sections) {\n if (property.overrides && property.overrides.hasOverride(section)) {\n hasOverrides = true;\n return;\n }\n }\n };\n\n if (textField.value.kind === 'constant' && textField.value.value instanceof Formatted) {\n checkSections(textField.value.value.sections);\n } else if (textField.value.kind === 'source') {\n\n const checkExpression = (expression: Expression) => {\n if (hasOverrides) return;\n\n if (expression instanceof Literal && typeOf(expression.value) === FormattedType) {\n const formatted: Formatted = (expression.value as any);\n checkSections(formatted.sections);\n } else if (expression instanceof FormatExpression) {\n checkSections(expression.sections);\n } else {\n expression.eachChild(checkExpression);\n }\n };\n\n const expr: ZoomConstantExpression<'source'> = (textField.value as any);\n if (expr._styleExpression) {\n checkExpression(expr._styleExpression.expression);\n }\n }\n\n return hasOverrides;\n }\n}\n\nexport type SymbolPadding = [number, number, number, number];\n\nexport function getIconPadding(layout: PossiblyEvaluated, feature: SymbolFeature, canonical: CanonicalTileID, pixelRatio = 1): SymbolPadding {\n // Support text-padding in addition to icon-padding? Unclear how to apply asymmetric text-padding to the radius for collision circles.\n const result = layout.get('icon-padding').evaluate(feature, {}, canonical);\n const values = result && result.values;\n\n return [\n values[0] * pixelRatio,\n values[1] * pixelRatio,\n values[2] * pixelRatio,\n values[3] * pixelRatio,\n ];\n}\n","/**\n * Replace tokens in a string template with values in an object\n *\n * @param properties - a key/value relationship between tokens and replacements\n * @param text - the template string\n * @returns the template with tokens replaced\n */\nexport function resolveTokens(\n properties: {\n readonly [x: string]: unknown;\n } | null,\n text: string\n): string {\n return text.replace(/{([^{}]+)}/g, (match, key: string) => {\n return properties && key in properties ? String(properties[key]) : '';\n });\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type BackgroundPaintProps = {\n \"background-color\": DataConstantProperty,\n \"background-pattern\": CrossFadedProperty,\n \"background-opacity\": DataConstantProperty,\n};\n\nexport type BackgroundPaintPropsPossiblyEvaluated = {\n \"background-color\": Color,\n \"background-pattern\": CrossFaded,\n \"background-opacity\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"background-color\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-color\"] as any as StylePropertySpecification),\n \"background-pattern\": new CrossFadedProperty(styleSpec[\"paint_background\"][\"background-pattern\"] as any as StylePropertySpecification),\n \"background-opacity\": new DataConstantProperty(styleSpec[\"paint_background\"][\"background-opacity\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {BackgroundPaintProps} from './background_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class BackgroundStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'.\n/* eslint-disable */\n\nimport {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {\n Properties,\n DataConstantProperty,\n DataDrivenProperty,\n CrossFadedDataDrivenProperty,\n CrossFadedProperty,\n ColorRampProperty,\n PossiblyEvaluatedPropertyValue,\n CrossFaded\n} from '../properties';\n\nimport type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';\n\n\nexport type RasterPaintProps = {\n \"raster-opacity\": DataConstantProperty,\n \"raster-hue-rotate\": DataConstantProperty,\n \"raster-brightness-min\": DataConstantProperty,\n \"raster-brightness-max\": DataConstantProperty,\n \"raster-saturation\": DataConstantProperty,\n \"raster-contrast\": DataConstantProperty,\n \"raster-resampling\": DataConstantProperty<\"linear\" | \"nearest\">,\n \"raster-fade-duration\": DataConstantProperty,\n};\n\nexport type RasterPaintPropsPossiblyEvaluated = {\n \"raster-opacity\": number,\n \"raster-hue-rotate\": number,\n \"raster-brightness-min\": number,\n \"raster-brightness-max\": number,\n \"raster-saturation\": number,\n \"raster-contrast\": number,\n \"raster-resampling\": \"linear\" | \"nearest\",\n \"raster-fade-duration\": number,\n};\n\nlet paint: Properties;\nconst getPaint = () => paint = paint || new Properties({\n \"raster-opacity\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-opacity\"] as any as StylePropertySpecification),\n \"raster-hue-rotate\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-hue-rotate\"] as any as StylePropertySpecification),\n \"raster-brightness-min\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-min\"] as any as StylePropertySpecification),\n \"raster-brightness-max\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-brightness-max\"] as any as StylePropertySpecification),\n \"raster-saturation\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-saturation\"] as any as StylePropertySpecification),\n \"raster-contrast\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-contrast\"] as any as StylePropertySpecification),\n \"raster-resampling\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-resampling\"] as any as StylePropertySpecification),\n \"raster-fade-duration\": new DataConstantProperty(styleSpec[\"paint_raster\"][\"raster-fade-duration\"] as any as StylePropertySpecification),\n});\n\nexport default ({ get paint() { return getPaint() } });","import {StyleLayer} from '../style_layer';\n\nimport properties, {RasterPaintPropsPossiblyEvaluated} from './raster_style_layer_properties.g';\nimport {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';\n\nimport type {RasterPaintProps} from './raster_style_layer_properties.g';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport class RasterStyleLayer extends StyleLayer {\n _transitionablePaint: Transitionable;\n _transitioningPaint: Transitioning;\n paint: PossiblyEvaluated;\n\n constructor(layer: LayerSpecification) {\n super(layer, properties);\n }\n}\n","import {StyleLayer} from '../style_layer';\nimport type {Map} from '../../ui/map';\nimport {mat4} from 'gl-matrix';\nimport {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * @param gl - The map's gl context.\n * @param matrix - The map's camera matrix. It projects spherical mercator\n * coordinates to gl coordinates. The spherical mercator coordinate `[0, 0]` represents the\n * top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When\n * the `renderingMode` is `\"3d\"`, the z coordinate is conformal. A box with identical x, y, and z\n * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate.fromLngLat}\n * can be used to project a `LngLat` to a mercator coordinate.\n */\ntype CustomRenderMethod = (gl: WebGLRenderingContext|WebGL2RenderingContext, matrix: mat4) => void;\n\n/**\n * Interface for custom style layers. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Custom layers allow a user to render directly into the map's GL context using the map's camera.\n * These layers can be added between any regular layers using {@link Map#addLayer}.\n *\n * Custom layers must have a unique `id` and must have the `type` of `\"custom\"`.\n * They must implement `render` and may implement `prerender`, `onAdd` and `onRemove`.\n * They can trigger rendering using {@link Map#triggerRepaint}\n * and they should appropriately handle {@link MapContextEvent} with `webglcontextlost` and `webglcontextrestored`.\n *\n * The `renderingMode` property controls whether the layer is treated as a `\"2d\"` or `\"3d\"` map layer. Use:\n * - `\"renderingMode\": \"3d\"` to use the depth buffer and share it with other layers\n * - `\"renderingMode\": \"2d\"` to add a layer with no depth. If you need to use the depth buffer for a `\"2d\"` layer you must use an offscreen\n * framebuffer and {@link CustomLayerInterface#prerender}\n *\n * @example\n * Custom layer implemented as ES6 class\n * ```ts\n * class NullIslandLayer {\n * constructor() {\n * this.id = 'null-island';\n * this.type = 'custom';\n * this.renderingMode = '2d';\n * }\n *\n * onAdd(map, gl) {\n * const vertexSource = `\n * uniform mat4 u_matrix;\n * void main() {\n * gl_Position = u_matrix * vec4(0.5, 0.5, 0.0, 1.0);\n * gl_PointSize = 20.0;\n * }`;\n *\n * const fragmentSource = `\n * void main() {\n * fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n * }`;\n *\n * const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n * gl.shaderSource(vertexShader, vertexSource);\n * gl.compileShader(vertexShader);\n * const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n * gl.shaderSource(fragmentShader, fragmentSource);\n * gl.compileShader(fragmentShader);\n *\n * this.program = gl.createProgram();\n * gl.attachShader(this.program, vertexShader);\n * gl.attachShader(this.program, fragmentShader);\n * gl.linkProgram(this.program);\n * }\n *\n * render(gl, matrix) {\n * gl.useProgram(this.program);\n * gl.uniformMatrix4fv(gl.getUniformLocation(this.program, \"u_matrix\"), false, matrix);\n * gl.drawArrays(gl.POINTS, 0, 1);\n * }\n * }\n *\n * map.on('load', function() {\n * map.addLayer(new NullIslandLayer());\n * });\n * ```\n */\nexport interface CustomLayerInterface {\n /**\n * A unique layer id.\n */\n id: string;\n /**\n * The layer's type. Must be `\"custom\"`.\n */\n type: 'custom';\n /**\n * Either `\"2d\"` or `\"3d\"`. Defaults to `\"2d\"`.\n */\n renderingMode?: '2d' | '3d';\n /**\n * Called during a render frame allowing the layer to draw into the GL context.\n *\n * The layer can assume blending and depth state is set to allow the layer to properly\n * blend and clip other layers. The layer cannot make any other assumptions about the\n * current GL state.\n *\n * If the layer needs to render to a texture, it should implement the `prerender` method\n * to do this and only use the `render` method for drawing directly into the main framebuffer.\n *\n * The blend function is set to `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. This expects\n * colors to be provided in premultiplied alpha form where the `r`, `g` and `b` values are already\n * multiplied by the `a` value. If you are unable to provide colors in premultiplied form you\n * may want to change the blend function to\n * `gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`.\n */\n render: CustomRenderMethod;\n /**\n * Optional method called during a render frame to allow a layer to prepare resources or render into a texture.\n *\n * The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering.\n */\n prerender?: CustomRenderMethod;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This\n * gives the layer a chance to initialize gl resources and register event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onAdd?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n /**\n * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This\n * gives the layer a chance to clean up gl resources and event listeners.\n *\n * @param map - The Map this custom layer was just added to.\n * @param gl - The gl context for the map.\n */\n onRemove?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void;\n}\n\nexport function validateCustomStyleLayer(layerObject: CustomLayerInterface) {\n const errors = [];\n const id = layerObject.id;\n\n if (id === undefined) {\n errors.push({\n message: `layers.${id}: missing required property \"id\"`\n });\n }\n\n if (layerObject.render === undefined) {\n errors.push({\n message: `layers.${id}: missing required method \"render\"`\n });\n }\n\n if (layerObject.renderingMode &&\n layerObject.renderingMode !== '2d' &&\n layerObject.renderingMode !== '3d') {\n errors.push({\n message: `layers.${id}: property \"renderingMode\" must be either \"2d\" or \"3d\"`\n });\n }\n\n return errors;\n}\n\nexport class CustomStyleLayer extends StyleLayer {\n\n implementation: CustomLayerInterface;\n\n constructor(implementation: CustomLayerInterface) {\n super(implementation, {});\n this.implementation = implementation;\n }\n\n is3D() {\n return this.implementation.renderingMode === '3d';\n }\n\n hasOffscreenPass() {\n return this.implementation.prerender !== undefined;\n }\n\n recalculate() {}\n updateTransitions() {}\n hasTransition() { return false; }\n\n serialize(): LayerSpecification {\n throw new Error('Custom layers cannot be serialized');\n }\n\n onAdd = (map: Map) => {\n if (this.implementation.onAdd) {\n this.implementation.onAdd(map, map.painter.context.gl);\n }\n };\n\n onRemove = (map: Map) => {\n if (this.implementation.onRemove) {\n this.implementation.onRemove(map, map.painter.context.gl);\n }\n };\n}\n","/**\n * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests\n * are ignored until the function was actually invoked.\n */\nexport class ThrottledInvoker {\n _channel: MessageChannel;\n _triggered: boolean;\n _callback: Function;\n\n constructor(callback: Function) {\n this._callback = callback;\n this._triggered = false;\n if (typeof MessageChannel !== 'undefined') {\n this._channel = new MessageChannel();\n this._channel.port2.onmessage = () => {\n this._triggered = false;\n this._callback();\n };\n }\n }\n\n trigger() {\n if (!this._triggered) {\n this._triggered = true;\n if (this._channel) {\n this._channel.port1.postMessage(true);\n } else {\n setTimeout(() => {\n this._triggered = false;\n this._callback();\n }, 0);\n }\n }\n }\n\n remove() {\n delete this._channel;\n this._callback = () => {};\n }\n}\n","import {wrap} from '../util/util';\n\n/*\n* Approximate radius of the earth in meters.\n* Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84\n* 6371008.8 is one published \"average radius\" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4\n*/\nexport const earthRadius = 6371008.8;\n\n/**\n * A {@link LngLat} object, an array of two numbers representing longitude and latitude,\n * or an object with `lng` and `lat` or `lon` and `lat` properties.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLat(-122.420679, 37.772537);\n * let v2 = [-122.420679, 37.772537];\n * let v3 = {lon: -122.420679, lat: 37.772537};\n * ```\n */\nexport type LngLatLike = LngLat | {\n lng: number;\n lat: number;\n} | {\n lon: number;\n lat: number;\n} | [number, number];\n\n/**\n * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.\n * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).\n *\n * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the\n * [GeoJSON specification](https://tools.ietf.org/html/rfc7946).\n *\n * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option\n * can also accept an `Array` of two numbers and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-123.9749, 40.7736);\n * ll.lng; // = -123.9749\n * ```\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\nexport class LngLat {\n lng: number;\n lat: number;\n\n /**\n * @param lng - Longitude, measured in degrees.\n * @param lat - Latitude, measured in degrees.\n */\n constructor(lng: number, lat: number) {\n if (isNaN(lng) || isNaN(lat)) {\n throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);\n }\n this.lng = +lng;\n this.lat = +lat;\n if (this.lat > 90 || this.lat < -90) {\n throw new Error('Invalid LngLat latitude value: must be between -90 and 90');\n }\n }\n\n /**\n * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).\n *\n * @returns The wrapped `LngLat` object.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(286.0251, 40.7736);\n * let wrapped = ll.wrap();\n * wrapped.lng; // = -73.9749\n * ```\n */\n wrap() {\n return new LngLat(wrap(this.lng, -180, 180), this.lat);\n }\n\n /**\n * Returns the coordinates represented as an array of two numbers.\n *\n * @returns The coordinates represented as an array of longitude and latitude.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toArray(); // = [-73.9749, 40.7736]\n * ```\n */\n toArray(): [number, number] {\n return [this.lng, this.lat];\n }\n\n /**\n * Returns the coordinates represent as a string.\n *\n * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.\n * @example\n * ```ts\n * let ll = new maplibregl.LngLat(-73.9749, 40.7736);\n * ll.toString(); // = \"LngLat(-73.9749, 40.7736)\"\n * ```\n */\n toString(): string {\n return `LngLat(${this.lng}, ${this.lat})`;\n }\n\n /**\n * Returns the approximate distance between a pair of coordinates in meters\n * Uses the Haversine Formula (from R.W. Sinnott, \"Virtues of the Haversine\", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)\n *\n * @param lngLat - coordinates to compute the distance to\n * @returns Distance in meters between the two coordinates.\n * @example\n * ```ts\n * let new_york = new maplibregl.LngLat(-74.0060, 40.7128);\n * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522);\n * new_york.distanceTo(los_angeles); // = 3935751.690893987, \"true distance\" using a non-spherical approximation is ~3966km\n * ```\n */\n distanceTo(lngLat: LngLat): number {\n const rad = Math.PI / 180;\n const lat1 = this.lat * rad;\n const lat2 = lngLat.lat * rad;\n const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);\n\n const maxMeters = earthRadius * Math.acos(Math.min(a, 1));\n return maxMeters;\n }\n\n /**\n * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties\n * to a `LngLat` object.\n *\n * If a `LngLat` object is passed in, the function returns it unchanged.\n *\n * @param input - An array of two numbers or object to convert, or a `LngLat` object to return.\n * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.\n * @example\n * ```ts\n * let arr = [-73.9749, 40.7736];\n * let ll = maplibregl.LngLat.convert(arr);\n * ll; // = LngLat {lng: -73.9749, lat: 40.7736}\n * ```\n */\n static convert(input: LngLatLike): LngLat {\n if (input instanceof LngLat) {\n return input;\n }\n if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {\n return new LngLat(Number(input[0]), Number(input[1]));\n }\n if (!Array.isArray(input) && typeof input === 'object' && input !== null) {\n return new LngLat(\n // flow can't refine this to have one of lng or lat, so we have to cast to any\n Number('lng' in input ? (input as any).lng : (input as any).lon),\n Number(input.lat)\n );\n }\n throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]');\n }\n}\n","import {LngLat, earthRadius} from '../geo/lng_lat';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport {IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/*\n * The average circumference of the world in meters.\n */\nconst earthCircumfrence = 2 * Math.PI * earthRadius; // meters\n\n/*\n * The circumference at a line of latitude in meters.\n */\nfunction circumferenceAtLatitude(latitude: number) {\n return earthCircumfrence * Math.cos(latitude * Math.PI / 180);\n}\n\nexport function mercatorXfromLng(lng: number) {\n return (180 + lng) / 360;\n}\n\nexport function mercatorYfromLat(lat: number) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\n\nexport function mercatorZfromAltitude(altitude: number, lat: number) {\n return altitude / circumferenceAtLatitude(lat);\n}\n\nexport function lngFromMercatorX(x: number) {\n return x * 360 - 180;\n}\n\nexport function latFromMercatorY(y: number) {\n const y2 = 180 - y * 360;\n return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;\n}\n\nexport function altitudeFromMercatorZ(z: number, y: number) {\n return z * circumferenceAtLatitude(latFromMercatorY(y));\n}\n\n/**\n * Determine the Mercator scale factor for a given latitude, see\n * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor\n *\n * At the equator the scale factor will be 1, which increases at higher latitudes.\n *\n * @param lat - Latitude\n * @returns scale factor\n */\nexport function mercatorScale(lat: number) {\n return 1 / Math.cos(lat * Math.PI / 180);\n}\n\n/**\n * A `MercatorCoordinate` object represents a projected three dimensional position.\n *\n * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:\n * - the size of 1 unit is the width of the projected world instead of the \"mercator meter\"\n * - the origin of the coordinate space is at the north-west corner instead of the middle\n *\n * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and\n * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with\n * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think\n * of the coordinate space as the `0/0/0` tile with an extent of `1`.\n *\n * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let nullIsland = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * ```\n * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/)\n */\nexport class MercatorCoordinate implements IMercatorCoordinate {\n x: number;\n y: number;\n z: number;\n\n /**\n * @param x - The x component of the position.\n * @param y - The y component of the position.\n * @param z - The z component of the position.\n */\n constructor(x: number, y: number, z: number = 0) {\n this.x = +x;\n this.y = +y;\n this.z = +z;\n }\n\n /**\n * Project a `LngLat` to a `MercatorCoordinate`.\n *\n * @param lngLatLike - The location to project.\n * @param altitude - The altitude in meters of the position.\n * @returns The projected mercator coordinate.\n * @example\n * ```ts\n * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);\n * coord; // MercatorCoordinate(0.5, 0.5, 0)\n * ```\n */\n static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0): MercatorCoordinate {\n const lngLat = LngLat.convert(lngLatLike);\n\n return new MercatorCoordinate(\n mercatorXfromLng(lngLat.lng),\n mercatorYfromLat(lngLat.lat),\n mercatorZfromAltitude(altitude, lngLat.lat));\n }\n\n /**\n * Returns the `LngLat` for the coordinate.\n *\n * @returns The `LngLat` object.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0);\n * let lngLat = coord.toLngLat(); // LngLat(0, 0)\n * ```\n */\n toLngLat() {\n return new LngLat(\n lngFromMercatorX(this.x),\n latFromMercatorY(this.y));\n }\n\n /**\n * Returns the altitude in meters of the coordinate.\n *\n * @returns The altitude in meters.\n * @example\n * ```ts\n * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02);\n * coord.toAltitude(); // 6914.281956295339\n * ```\n */\n toAltitude(): number {\n return altitudeFromMercatorZ(this.z, this.y);\n }\n\n /**\n * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.\n *\n * For coordinates in real world units using meters, this naturally provides the scale\n * to transform into `MercatorCoordinate`s.\n *\n * @returns Distance of 1 meter in `MercatorCoordinate` units.\n */\n meterInMercatorCoordinateUnits(): number {\n // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude\n return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));\n }\n}\n","export { getURL, getTileBBox, getMercCoords };\n\n\n/**\n * getURL\n *\n * @param {String} baseUrl Base url of the WMS server\n * @param {String} layer Layer name\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @param {Object} [options]\n * @param {String} [options.format='image/png']\n * @param {String} [options.service='WMS']\n * @param {String} [options.version='1.1.1']\n * @param {String} [options.request='GetMap']\n * @param {String} [options.srs='EPSG:3857']\n * @param {Number} [options.width='256']\n * @param {Number} [options.height='256']\n * @returns {String} url\n * @example\n * var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';\n * var layer = 'Natural2015';\n * var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19);\n */\nfunction getURL(baseUrl, layer, x, y, z, options) {\n options = options || {};\n\n var url = baseUrl + '?' + [\n 'bbox=' + getTileBBox(x, y, z),\n 'format=' + (options.format || 'image/png'),\n 'service=' + (options.service || 'WMS'),\n 'version=' + (options.version || '1.1.1'),\n 'request=' + (options.request || 'GetMap'),\n 'srs=' + (options.srs || 'EPSG:3857'),\n 'width=' + (options.width || 256),\n 'height=' + (options.height || 256),\n 'layers=' + layer\n ].join('&');\n\n return url;\n}\n\n\n/**\n * getTileBBox\n *\n * @param {Number} x Tile coordinate x\n * @param {Number} y Tile coordinate y\n * @param {Number} z Tile zoom\n * @returns {String} String of the bounding box\n */\nfunction getTileBBox(x, y, z) {\n // for Google/OSM tile scheme we need to alter the y\n y = (Math.pow(2, z) - y - 1);\n\n var min = getMercCoords(x * 256, y * 256, z),\n max = getMercCoords((x + 1) * 256, (y + 1) * 256, z);\n\n return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1];\n}\n\n\n/**\n * getMercCoords\n *\n * @param {Number} x Pixel coordinate x\n * @param {Number} y Pixel coordinate y\n * @param {Number} z Tile zoom\n * @returns {Array} [x, y]\n */\nfunction getMercCoords(x, y, z) {\n var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z),\n merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0),\n merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0);\n\n return [merc_x, merc_y];\n}\n","import {getTileBBox} from '@mapbox/whoots-js';\nimport {EXTENT} from '../data/extent';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {register} from '../util/web_worker_transfer';\nimport {mat4} from 'gl-matrix';\nimport {ICanonicalTileID, IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A canonical way to define a tile ID\n */\nexport class CanonicalTileID implements ICanonicalTileID {\n z: number;\n x: number;\n y: number;\n key: string;\n\n constructor(z: number, x: number, y: number) {\n\n if (z < 0 || z > 25 || y < 0 || y >= Math.pow(2, z) || x < 0 || x >= Math.pow(2, z)) {\n throw new Error(`x=${x}, y=${y}, z=${z} outside of bounds. 0<=x<${Math.pow(2, z)}, 0<=y<${Math.pow(2, z)} 0<=z<=25 `);\n }\n\n this.z = z;\n this.x = x;\n this.y = y;\n this.key = calculateKey(0, z, z, x, y);\n }\n\n equals(id: ICanonicalTileID) {\n return this.z === id.z && this.x === id.x && this.y === id.y;\n }\n\n // given a list of urls, choose a url template and return a tile URL\n url(urls: Array, pixelRatio: number, scheme?: string | null) {\n const bbox = getTileBBox(this.x, this.y, this.z);\n const quadkey = getQuadkey(this.z, this.x, this.y);\n\n return urls[(this.x + this.y) % urls.length]\n .replace(/{prefix}/g, (this.x % 16).toString(16) + (this.y % 16).toString(16))\n .replace(/{z}/g, String(this.z))\n .replace(/{x}/g, String(this.x))\n .replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))\n .replace(/{ratio}/g, pixelRatio > 1 ? '@2x' : '')\n .replace(/{quadkey}/g, quadkey)\n .replace(/{bbox-epsg-3857}/g, bbox);\n }\n\n isChildOf(parent: ICanonicalTileID) {\n const dz = this.z - parent.z;\n return dz > 0 && parent.x === (this.x >> dz) && parent.y === (this.y >> dz);\n }\n\n getTilePoint(coord: IMercatorCoordinate) {\n const tilesAtZoom = Math.pow(2, this.z);\n return new Point(\n (coord.x * tilesAtZoom - this.x) * EXTENT,\n (coord.y * tilesAtZoom - this.y) * EXTENT);\n }\n\n toString() {\n return `${this.z}/${this.x}/${this.y}`;\n }\n}\n\n/**\n * @internal\n * An unwrapped tile identifier\n */\nexport class UnwrappedTileID {\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n\n constructor(wrap: number, canonical: CanonicalTileID) {\n this.wrap = wrap;\n this.canonical = canonical;\n this.key = calculateKey(wrap, canonical.z, canonical.z, canonical.x, canonical.y);\n }\n}\n\n/**\n * An overscaled tile identifier\n */\nexport class OverscaledTileID {\n overscaledZ: number;\n wrap: number;\n canonical: CanonicalTileID;\n key: string;\n posMatrix: mat4;\n\n constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number) {\n if (overscaledZ < z) throw new Error(`overscaledZ should be >= z; overscaledZ = ${overscaledZ}; z = ${z}`);\n this.overscaledZ = overscaledZ;\n this.wrap = wrap;\n this.canonical = new CanonicalTileID(z, +x, +y);\n this.key = calculateKey(wrap, overscaledZ, z, x, y);\n }\n\n clone() {\n return new OverscaledTileID(this.overscaledZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n equals(id: OverscaledTileID) {\n return this.overscaledZ === id.overscaledZ && this.wrap === id.wrap && this.canonical.equals(id.canonical);\n }\n\n scaledTo(targetZ: number) {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return new OverscaledTileID(targetZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return new OverscaledTileID(targetZ, this.wrap, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n /*\n * calculateScaledKey is an optimization:\n * when withWrap == true, implements the same as this.scaledTo(z).key,\n * when withWrap == false, implements the same as this.scaledTo(z).wrapped().key.\n */\n calculateScaledKey(targetZ: number, withWrap: boolean): string {\n if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`);\n const zDifference = this.canonical.z - targetZ;\n if (targetZ > this.canonical.z) {\n return calculateKey(this.wrap * +withWrap, targetZ, this.canonical.z, this.canonical.x, this.canonical.y);\n } else {\n return calculateKey(this.wrap * +withWrap, targetZ, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference);\n }\n }\n\n isChildOf(parent: OverscaledTileID) {\n if (parent.wrap !== this.wrap) {\n // We can't be a child if we're in a different world copy\n return false;\n }\n const zDifference = this.canonical.z - parent.canonical.z;\n // We're first testing for z == 0, to avoid a 32 bit shift, which is undefined.\n return parent.overscaledZ === 0 || (\n parent.overscaledZ < this.overscaledZ &&\n parent.canonical.x === (this.canonical.x >> zDifference) &&\n parent.canonical.y === (this.canonical.y >> zDifference));\n }\n\n children(sourceMaxZoom: number) {\n if (this.overscaledZ >= sourceMaxZoom) {\n // return a single tile coord representing a an overscaled tile\n return [new OverscaledTileID(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)];\n }\n\n const z = this.canonical.z + 1;\n const x = this.canonical.x * 2;\n const y = this.canonical.y * 2;\n return [\n new OverscaledTileID(z, this.wrap, z, x, y),\n new OverscaledTileID(z, this.wrap, z, x + 1, y),\n new OverscaledTileID(z, this.wrap, z, x, y + 1),\n new OverscaledTileID(z, this.wrap, z, x + 1, y + 1)\n ];\n }\n\n isLessThan(rhs: OverscaledTileID) {\n if (this.wrap < rhs.wrap) return true;\n if (this.wrap > rhs.wrap) return false;\n\n if (this.overscaledZ < rhs.overscaledZ) return true;\n if (this.overscaledZ > rhs.overscaledZ) return false;\n\n if (this.canonical.x < rhs.canonical.x) return true;\n if (this.canonical.x > rhs.canonical.x) return false;\n\n if (this.canonical.y < rhs.canonical.y) return true;\n return false;\n }\n\n wrapped() {\n return new OverscaledTileID(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n unwrapTo(wrap: number) {\n return new OverscaledTileID(this.overscaledZ, wrap, this.canonical.z, this.canonical.x, this.canonical.y);\n }\n\n overscaleFactor() {\n return Math.pow(2, this.overscaledZ - this.canonical.z);\n }\n\n toUnwrapped() {\n return new UnwrappedTileID(this.wrap, this.canonical);\n }\n\n toString() {\n return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`;\n }\n\n getTilePoint(coord: MercatorCoordinate) {\n return this.canonical.getTilePoint(new MercatorCoordinate(coord.x - this.wrap, coord.y));\n }\n}\n\nfunction calculateKey(wrap: number, overscaledZ: number, z: number, x: number, y: number): string {\n wrap *= 2;\n if (wrap < 0) wrap = wrap * -1 - 1;\n const dim = 1 << z;\n return (dim * dim * wrap + dim * y + x).toString(36) + z.toString(36) + overscaledZ.toString(36);\n}\n\nfunction getQuadkey(z, x, y) {\n let quadkey = '', mask;\n for (let i = z; i > 0; i--) {\n mask = 1 << (i - 1);\n quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0));\n }\n return quadkey;\n}\n\nregister('CanonicalTileID', CanonicalTileID);\nregister('OverscaledTileID', OverscaledTileID, {omit: ['posMatrix']});\n","import {RGBAImage} from '../util/image';\n\nimport {warnOnce} from '../util/util';\nimport {register} from '../util/web_worker_transfer';\n\n// DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders\n// data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially\n// loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the\n// elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of\n// integer overflow when creating the texture used in the hillshadePrepare step.\n\n// DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8\n// surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a\n// tile's edge without backfilling from neighboring tiles.\n\nexport type DEMEncoding = 'mapbox' | 'terrarium' | 'custom'\n\nexport class DEMData {\n uid: string;\n data: Uint32Array;\n stride: number;\n dim: number;\n min: number;\n max: number;\n redFactor: number;\n greenFactor: number;\n blueFactor: number;\n baseShift: number;\n\n // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride\n // and dim is calculated as stride - 2.\n constructor(uid: string, data: RGBAImage, encoding: DEMEncoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {\n this.uid = uid;\n if (data.height !== data.width) throw new RangeError('DEM tiles must be square');\n if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {\n warnOnce(`\"${encoding}\" is not a valid encoding type. Valid types include \"mapbox\", \"terrarium\" and \"custom\".`);\n return;\n }\n this.stride = data.height;\n const dim = this.dim = data.height - 2;\n this.data = new Uint32Array(data.data.buffer);\n switch (encoding) {\n case 'terrarium':\n // unpacking formula for mapzen terrarium:\n // https://aws.amazon.com/public-datasets/terrain/\n this.redFactor = 256.0;\n this.greenFactor = 1.0;\n this.blueFactor = 1.0 / 256.0;\n this.baseShift = 32768.0;\n break;\n case 'custom':\n this.redFactor = redFactor;\n this.greenFactor = greenFactor;\n this.blueFactor = blueFactor;\n this.baseShift = baseShift;\n break;\n case 'mapbox':\n default:\n // unpacking formula for mapbox.terrain-rgb:\n // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb\n this.redFactor = 6553.6;\n this.greenFactor = 25.6;\n this.blueFactor = 0.1;\n this.baseShift = 10000.0;\n break;\n }\n\n // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image\n // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring\n // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder\n for (let x = 0; x < dim; x++) {\n // left vertical border\n this.data[this._idx(-1, x)] = this.data[this._idx(0, x)];\n // right vertical border\n this.data[this._idx(dim, x)] = this.data[this._idx(dim - 1, x)];\n // left horizontal border\n this.data[this._idx(x, -1)] = this.data[this._idx(x, 0)];\n // right horizontal border\n this.data[this._idx(x, dim)] = this.data[this._idx(x, dim - 1)];\n }\n // corners\n this.data[this._idx(-1, -1)] = this.data[this._idx(0, 0)];\n this.data[this._idx(dim, -1)] = this.data[this._idx(dim - 1, 0)];\n this.data[this._idx(-1, dim)] = this.data[this._idx(0, dim - 1)];\n this.data[this._idx(dim, dim)] = this.data[this._idx(dim - 1, dim - 1)];\n\n // calculate min/max values\n this.min = Number.MAX_SAFE_INTEGER;\n this.max = Number.MIN_SAFE_INTEGER;\n for (let x = 0; x < dim; x++) {\n for (let y = 0; y < dim; y++) {\n const ele = this.get(x, y);\n if (ele > this.max) this.max = ele;\n if (ele < this.min) this.min = ele;\n }\n }\n }\n\n get(x: number, y: number) {\n const pixels = new Uint8Array(this.data.buffer);\n const index = this._idx(x, y) * 4;\n return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);\n }\n\n getUnpackVector() {\n return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];\n }\n\n _idx(x: number, y: number) {\n if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) throw new RangeError('out of range source coordinates for DEM data');\n return (y + 1) * this.stride + (x + 1);\n }\n\n unpack(r: number, g: number, b: number) {\n return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);\n }\n\n getPixels() {\n return new RGBAImage({width: this.stride, height: this.stride}, new Uint8Array(this.data.buffer));\n }\n\n backfillBorder(borderTile: DEMData, dx: number, dy: number) {\n if (this.dim !== borderTile.dim) throw new Error('dem dimension mismatch');\n\n let xMin = dx * this.dim,\n xMax = dx * this.dim + this.dim,\n yMin = dy * this.dim,\n yMax = dy * this.dim + this.dim;\n\n switch (dx) {\n case -1:\n xMin = xMax - 1;\n break;\n case 1:\n xMax = xMin + 1;\n break;\n }\n\n switch (dy) {\n case -1:\n yMin = yMax - 1;\n break;\n case 1:\n yMax = yMin + 1;\n break;\n }\n\n const ox = -dx * this.dim;\n const oy = -dy * this.dim;\n for (let y = yMin; y < yMax; y++) {\n for (let x = xMin; x < xMax; x++) {\n this.data[this._idx(x, y)] = borderTile.data[this._idx(x + ox, y + oy)];\n }\n }\n }\n}\n\nregister('DEMData', DEMData);\n","export class DictionaryCoder {\n _stringToNumber: {[_: string]: number};\n _numberToString: Array;\n\n constructor(strings: Array) {\n this._stringToNumber = {};\n this._numberToString = [];\n for (let i = 0; i < strings.length; i++) {\n const string = strings[i];\n this._stringToNumber[string] = i;\n this._numberToString[i] = string;\n }\n }\n\n encode(string: string) {\n return this._stringToNumber[string];\n }\n\n decode(n: number) {\n if (n >= this._numberToString.length) throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`);\n return this._numberToString[n];\n }\n}\n","import type {VectorTileFeature} from '@mapbox/vector-tile';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveKeys = T extends T ? keyof T : never;\n/**\n * A helper for type to omit a property from a type\n */\ntype DistributiveOmit> = T extends unknown\n ? Omit\n : never;\n\n/**\n * An extended geojson feature used by the events to return data to the listener\n */\nexport type MapGeoJSONFeature = GeoJSONFeature & {\n layer: DistributiveOmit & {source: string};\n source: string;\n sourceLayer?: string;\n state: { [key: string]: any };\n}\n\n/**\n * A geojson feature\n */\nexport class GeoJSONFeature {\n type: 'Feature';\n _geometry: GeoJSON.Geometry;\n properties: { [name: string]: any };\n id: number | string | undefined;\n\n _vectorTileFeature: VectorTileFeature;\n\n constructor(vectorTileFeature: VectorTileFeature, z: number, x: number, y: number, id: string | number | undefined) {\n this.type = 'Feature';\n\n this._vectorTileFeature = vectorTileFeature;\n (vectorTileFeature as any)._z = z;\n (vectorTileFeature as any)._x = x;\n (vectorTileFeature as any)._y = y;\n\n this.properties = vectorTileFeature.properties;\n this.id = id;\n }\n\n get geometry(): GeoJSON.Geometry {\n if (this._geometry === undefined) {\n this._geometry = this._vectorTileFeature.toGeoJSON(\n (this._vectorTileFeature as any)._x,\n (this._vectorTileFeature as any)._y,\n (this._vectorTileFeature as any)._z).geometry;\n }\n return this._geometry;\n }\n\n set geometry(g: GeoJSON.Geometry) {\n this._geometry = g;\n }\n\n toJSON() {\n const json: any = {\n geometry: this.geometry\n };\n for (const i in this) {\n if (i === '_geometry' || i === '_vectorTileFeature') continue;\n json[i] = (this)[i];\n }\n return json;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {loadGeometry} from './load_geometry';\nimport {toEvaluationFeature} from './evaluation_feature';\nimport {EXTENT} from './extent';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {TransferableGridIndex} from '../util/transferable_grid_index';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {arraysIntersect, mapObject, extend} from '../util/util';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {register} from '../util/web_worker_transfer';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {polygonIntersectsBox} from '../util/intersection_tests';\nimport {PossiblyEvaluated} from '../style/properties';\nimport {FeatureIndexArray} from './array_types.g';\nimport {mat4} from 'gl-matrix';\n\nimport type {StyleLayer} from '../style/style_layer';\nimport type {FeatureFilter, FeatureState, FilterSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\n\ntype QueryParameters = {\n scale: number;\n pixelPosMatrix: mat4;\n transform: Transform;\n tileSize: number;\n queryGeometry: Array;\n cameraQueryGeometry: Array;\n queryPadding: number;\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n };\n};\n\n/**\n * @internal\n * An in memory index class to allow fast interaction with features\n */\nexport class FeatureIndex {\n tileID: OverscaledTileID;\n x: number;\n y: number;\n z: number;\n grid: TransferableGridIndex;\n grid3D: TransferableGridIndex;\n featureIndexArray: FeatureIndexArray;\n promoteId?: PromoteIdSpecification;\n\n rawTileData: ArrayBuffer;\n bucketLayerIDs: Array>;\n\n vtLayers: {[_: string]: VectorTileLayer};\n sourceLayerCoder: DictionaryCoder;\n\n constructor(tileID: OverscaledTileID, promoteId?: PromoteIdSpecification | null) {\n this.tileID = tileID;\n this.x = tileID.canonical.x;\n this.y = tileID.canonical.y;\n this.z = tileID.canonical.z;\n this.grid = new TransferableGridIndex(EXTENT, 16, 0);\n this.grid3D = new TransferableGridIndex(EXTENT, 16, 0);\n this.featureIndexArray = new FeatureIndexArray();\n this.promoteId = promoteId;\n }\n\n insert(feature: VectorTileFeature, geometry: Array>, featureIndex: number, sourceLayerIndex: number, bucketIndex: number, is3D?: boolean) {\n const key = this.featureIndexArray.length;\n this.featureIndexArray.emplaceBack(featureIndex, sourceLayerIndex, bucketIndex);\n\n const grid = is3D ? this.grid3D : this.grid;\n\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (let i = 0; i < ring.length; i++) {\n const p = ring[i];\n bbox[0] = Math.min(bbox[0], p.x);\n bbox[1] = Math.min(bbox[1], p.y);\n bbox[2] = Math.max(bbox[2], p.x);\n bbox[3] = Math.max(bbox[3], p.y);\n }\n\n if (bbox[0] < EXTENT &&\n bbox[1] < EXTENT &&\n bbox[2] >= 0 &&\n bbox[3] >= 0) {\n grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]);\n }\n }\n }\n\n loadVTLayers(): {[_: string]: VectorTileLayer} {\n if (!this.vtLayers) {\n this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers;\n this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']);\n }\n return this.vtLayers;\n }\n\n // Finds non-symbol features in this tile at a particular position.\n query(\n args: QueryParameters,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n this.loadVTLayers();\n\n const params = args.params || {} as { filter: any; layers: string[]; availableImages: string[] },\n pixelsToTileUnits = EXTENT / args.tileSize / args.scale,\n filter = featureFilter(params.filter);\n\n const queryGeometry = args.queryGeometry;\n const queryPadding = args.queryPadding * pixelsToTileUnits;\n\n const bounds = getBounds(queryGeometry);\n const matching = this.grid.query(bounds.minX - queryPadding, bounds.minY - queryPadding, bounds.maxX + queryPadding, bounds.maxY + queryPadding);\n\n const cameraBounds = getBounds(args.cameraQueryGeometry);\n const matching3D = this.grid3D.query(\n cameraBounds.minX - queryPadding, cameraBounds.minY - queryPadding, cameraBounds.maxX + queryPadding, cameraBounds.maxY + queryPadding,\n (bx1, by1, bx2, by2) => {\n return polygonIntersectsBox(args.cameraQueryGeometry, bx1 - queryPadding, by1 - queryPadding, bx2 + queryPadding, by2 + queryPadding);\n });\n\n for (const key of matching3D) {\n matching.push(key);\n }\n\n matching.sort(topDownFeatureComparator);\n\n const result = {};\n let previousIndex;\n for (let k = 0; k < matching.length; k++) {\n const index = matching[k];\n\n // don't check the same feature more than once\n if (index === previousIndex) continue;\n previousIndex = index;\n\n const match = this.featureIndexArray.get(index);\n let featureGeometry = null;\n this.loadMatchingFeature(\n result,\n match.bucketIndex,\n match.sourceLayerIndex,\n match.featureIndex,\n filter,\n params.layers,\n params.availableImages,\n styleLayers,\n serializedLayers,\n sourceFeatureState,\n (feature: VectorTileFeature, styleLayer: StyleLayer, featureState: FeatureState) => {\n if (!featureGeometry) {\n featureGeometry = loadGeometry(feature);\n }\n\n return styleLayer.queryIntersectsFeature(queryGeometry, feature, featureState, featureGeometry, this.z, args.transform, pixelsToTileUnits, args.pixelPosMatrix);\n }\n );\n }\n\n return result;\n }\n\n loadMatchingFeature(\n result: {\n [_: string]: Array<{\n featureIndex: number;\n feature: GeoJSONFeature;\n intersectionZ?: boolean | number;\n }>;\n },\n bucketIndex: number,\n sourceLayerIndex: number,\n featureIndex: number,\n filter: FeatureFilter,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState?: SourceFeatureState,\n intersectionTest?: (\n feature: VectorTileFeature,\n styleLayer: StyleLayer,\n featureState: any,\n id: string | number | void\n ) => boolean | number) {\n\n const layerIDs = this.bucketLayerIDs[bucketIndex];\n if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs))\n return;\n\n const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);\n const sourceLayer = this.vtLayers[sourceLayerName];\n const feature = sourceLayer.feature(featureIndex);\n\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) {\n return;\n }\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n return;\n }\n\n const id = this.getId(feature, sourceLayerName);\n\n for (let l = 0; l < layerIDs.length; l++) {\n const layerID = layerIDs[l];\n\n if (filterLayerIDs && filterLayerIDs.indexOf(layerID) < 0) {\n continue;\n }\n\n const styleLayer = styleLayers[layerID];\n\n if (!styleLayer) continue;\n\n let featureState = {};\n if (id && sourceFeatureState) {\n // `feature-state` expression evaluation requires feature state to be available\n featureState = sourceFeatureState.getState(styleLayer.sourceLayer || '_geojsonTileLayer', id);\n }\n\n const serializedLayer = extend({}, serializedLayers[layerID]);\n\n serializedLayer.paint = evaluateProperties(serializedLayer.paint, styleLayer.paint, feature, featureState, availableImages);\n serializedLayer.layout = evaluateProperties(serializedLayer.layout, styleLayer.layout, feature, featureState, availableImages);\n\n const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer, featureState);\n if (!intersectionZ) {\n // Only applied for non-symbol features\n continue;\n }\n\n const geojsonFeature = new GeoJSONFeature(feature, this.z, this.x, this.y, id) as MapGeoJSONFeature;\n geojsonFeature.layer = serializedLayer;\n let layerResult = result[layerID];\n if (layerResult === undefined) {\n layerResult = result[layerID] = [];\n }\n layerResult.push({featureIndex, feature: geojsonFeature, intersectionZ});\n }\n }\n\n // Given a set of symbol indexes that have already been looked up,\n // return a matching set of GeoJSONFeatures\n lookupSymbolFeatures(symbolFeatureIndexes: Array,\n serializedLayers: {[_: string]: StyleLayer},\n bucketIndex: number,\n sourceLayerIndex: number,\n filterSpec: FilterSpecification,\n filterLayerIDs: Array,\n availableImages: Array,\n styleLayers: {[_: string]: StyleLayer}) {\n const result = {};\n this.loadVTLayers();\n\n const filter = featureFilter(filterSpec);\n\n for (const symbolFeatureIndex of symbolFeatureIndexes) {\n this.loadMatchingFeature(\n result,\n bucketIndex,\n sourceLayerIndex,\n symbolFeatureIndex,\n filter,\n filterLayerIDs,\n availableImages,\n styleLayers,\n serializedLayers\n );\n\n }\n return result;\n }\n\n hasLayer(id: string) {\n for (const layerIDs of this.bucketLayerIDs) {\n for (const layerID of layerIDs) {\n if (id === layerID) return true;\n }\n }\n\n return false;\n }\n\n getId(feature: VectorTileFeature, sourceLayerId: string): string | number {\n let id: string | number = feature.id;\n if (this.promoteId) {\n const propName = typeof this.promoteId === 'string' ? this.promoteId : this.promoteId[sourceLayerId];\n id = feature.properties[propName] as string | number;\n if (typeof id === 'boolean') id = Number(id);\n }\n return id;\n }\n}\n\nregister(\n 'FeatureIndex',\n FeatureIndex,\n {omit: ['rawTileData', 'sourceLayerCoder']}\n);\n\nfunction evaluateProperties(serializedProperties, styleLayerProperties, feature, featureState, availableImages) {\n return mapObject(serializedProperties, (property, key) => {\n const prop = styleLayerProperties instanceof PossiblyEvaluated ? styleLayerProperties.get(key) : null;\n return prop && prop.evaluate ? prop.evaluate(feature, featureState, availableImages) : prop;\n });\n}\n\nfunction getBounds(geometry: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const p of geometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return {minX, minY, maxX, maxY};\n}\n\nfunction topDownFeatureComparator(a, b) {\n return b - a;\n}\n","import Point from '@mapbox/point-geometry';\n\n/**\n * Returns the part of a multiline that intersects with the provided rectangular box.\n *\n * @param lines - the lines to check\n * @param x1 - the left edge of the box\n * @param y1 - the top edge of the box\n * @param x2 - the right edge of the box\n * @param y2 - the bottom edge of the box\n * @returns lines\n */\nexport function clipLine(lines: Array>, x1: number, y1: number, x2: number, y2: number): Array> {\n const clippedLines = [];\n\n for (let l = 0; l < lines.length; l++) {\n const line = lines[l];\n let clippedLine;\n\n for (let i = 0; i < line.length - 1; i++) {\n let p0 = line[i];\n let p1 = line[i + 1];\n\n if (p0.x < x1 && p1.x < x1) {\n continue;\n } else if (p0.x < x1) {\n p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x < x1) {\n p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y < y1 && p1.y < y1) {\n continue;\n } else if (p0.y < y1) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n } else if (p1.y < y1) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();\n }\n\n if (p0.x >= x2 && p1.x >= x2) {\n continue;\n } else if (p0.x >= x2) {\n p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n } else if (p1.x >= x2) {\n p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();\n }\n\n if (p0.y >= y2 && p1.y >= y2) {\n continue;\n } else if (p0.y >= y2) {\n p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n } else if (p1.y >= y2) {\n p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();\n }\n\n if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) {\n clippedLine = [p0];\n clippedLines.push(clippedLine);\n }\n\n clippedLine.push(p1);\n }\n }\n\n return clippedLines;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {register} from '../util/web_worker_transfer';\n\nexport class Anchor extends Point {\n angle: any;\n segment?: number;\n\n constructor(x: number, y: number, angle: number, segment?: number) {\n super(x, y);\n this.angle = angle;\n if (segment !== undefined) {\n this.segment = segment;\n }\n }\n\n clone() {\n return new Anchor(this.x, this.y, this.angle, this.segment);\n }\n}\n\nregister('Anchor', Anchor);\n","import type Point from '@mapbox/point-geometry';\nimport type {Anchor} from './anchor';\n\n/**\n * Labels placed around really sharp angles aren't readable. Check if any\n * part of the potential label has a combined angle that is too big.\n *\n * @param line - The line to check\n * @param anchor - The point on the line around which the label is anchored.\n * @param labelLength - The length of the label in geometry units.\n * @param windowSize - The check fails if the combined angles within a part of the line that is `windowSize` long is too big.\n * @param maxAngle - The maximum combined angle that any window along the label is allowed to have.\n *\n * @returns whether the label should be placed\n */\nexport function checkMaxAngle(line: Array, anchor: Anchor, labelLength: number, windowSize: number, maxAngle: number) {\n\n // horizontal labels and labels with length 0 always pass\n if (anchor.segment === undefined || labelLength === 0) return true;\n\n let p = anchor;\n let index = anchor.segment + 1;\n let anchorDistance = 0;\n\n // move backwards along the line to the first segment the label appears on\n while (anchorDistance > -labelLength / 2) {\n index--;\n\n // there isn't enough room for the label after the beginning of the line\n if (index < 0) return false;\n\n anchorDistance -= line[index].dist(p);\n p = line[index];\n }\n\n anchorDistance += line[index].dist(line[index + 1]);\n index++;\n\n // store recent corners and their total angle difference\n const recentCorners = [];\n let recentAngleDelta = 0;\n\n // move forwards by the length of the label and check angles along the way\n while (anchorDistance < labelLength / 2) {\n const prev = line[index - 1];\n const current = line[index];\n const next = line[index + 1];\n\n // there isn't enough room for the label before the end of the line\n if (!next) return false;\n\n let angleDelta = prev.angleTo(current) - current.angleTo(next);\n // restrict angle to -pi..pi range\n angleDelta = Math.abs(((angleDelta + 3 * Math.PI) % (Math.PI * 2)) - Math.PI);\n\n recentCorners.push({\n distance: anchorDistance,\n angleDelta\n });\n recentAngleDelta += angleDelta;\n\n // remove corners that are far enough away from the list of recent anchors\n while (anchorDistance - recentCorners[0].distance > windowSize) {\n recentAngleDelta -= recentCorners.shift().angleDelta;\n }\n\n // the sum of angles within the window area exceeds the maximum allowed value. check fails.\n if (recentAngleDelta > maxAngle) return false;\n\n index++;\n anchorDistance += current.dist(next);\n }\n\n // no part of the line had an angle greater than the maximum allowed. check passes.\n return true;\n}\n","import {interpolates} from '@maplibre/maplibre-gl-style-spec';\n\nimport {Anchor} from '../symbol/anchor';\nimport {checkMaxAngle} from './check_max_angle';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {Shaping, PositionedIcon} from './shaping';\n\nexport {getAnchors, getCenterAnchor};\n\nfunction getLineLength(line: Array): number {\n let lineLength = 0;\n for (let k = 0; k < line.length - 1; k++) {\n lineLength += line[k].dist(line[k + 1]);\n }\n return lineLength;\n}\n\nfunction getAngleWindowSize(\n shapedText: Shaping,\n glyphSize: number,\n boxScale: number\n): number {\n return shapedText ?\n 3 / 5 * glyphSize * boxScale :\n 0;\n}\n\nfunction getShapedLabelLength(shapedText?: Shaping | null, shapedIcon?: PositionedIcon | null): number {\n return Math.max(\n shapedText ? shapedText.right - shapedText.left : 0,\n shapedIcon ? shapedIcon.right - shapedIcon.left : 0);\n}\n\nfunction getCenterAnchor(line: Array,\n maxAngle: number,\n shapedText: Shaping,\n shapedIcon: PositionedIcon,\n glyphSize: number,\n boxScale: number) {\n const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);\n const labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale;\n\n let prevDistance = 0;\n const centerDistance = getLineLength(line) / 2;\n\n for (let i = 0; i < line.length - 1; i++) {\n\n const a = line[i],\n b = line[i + 1];\n\n const segmentDistance = a.dist(b);\n\n if (prevDistance + segmentDistance > centerDistance) {\n // The center is on this segment\n const t = (centerDistance - prevDistance) / segmentDistance,\n x = interpolates.number(a.x, b.x, t),\n y = interpolates.number(a.y, b.y, t);\n\n const anchor = new Anchor(x, y, b.angleTo(a), i);\n anchor._round();\n if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {\n return anchor;\n } else {\n return;\n }\n }\n\n prevDistance += segmentDistance;\n }\n}\n\nfunction getAnchors(line: Array,\n spacing: number,\n maxAngle: number,\n shapedText: Shaping,\n shapedIcon: PositionedIcon,\n glyphSize: number,\n boxScale: number,\n overscaling: number,\n tileExtent: number) {\n\n // Resample a line to get anchor points for labels and check that each\n // potential label passes text-max-angle check and has enough froom to fit\n // on the line.\n\n const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);\n const shapedLabelLength = getShapedLabelLength(shapedText, shapedIcon);\n const labelLength = shapedLabelLength * boxScale;\n\n // Is the line continued from outside the tile boundary?\n const isLineContinued = line[0].x === 0 || line[0].x === tileExtent || line[0].y === 0 || line[0].y === tileExtent;\n\n // Is the label long, relative to the spacing?\n // If so, adjust the spacing so there is always a minimum space of `spacing / 4` between label edges.\n if (spacing - labelLength < spacing / 4) {\n spacing = labelLength + spacing / 4;\n }\n\n // Offset the first anchor by:\n // Either half the label length plus a fixed extra offset if the line is not continued\n // Or half the spacing if the line is continued.\n\n // For non-continued lines, add a bit of fixed extra offset to avoid collisions at T intersections.\n const fixedExtraOffset = glyphSize * 2;\n\n const offset = !isLineContinued ?\n ((shapedLabelLength / 2 + fixedExtraOffset) * boxScale * overscaling) % spacing :\n (spacing / 2 * overscaling) % spacing;\n\n return resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, false, tileExtent);\n}\n\nfunction resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, placeAtMiddle, tileExtent) {\n\n const halfLabelLength = labelLength / 2;\n const lineLength = getLineLength(line);\n\n let distance = 0,\n markedDistance = offset - spacing;\n\n let anchors = [];\n\n for (let i = 0; i < line.length - 1; i++) {\n\n const a = line[i],\n b = line[i + 1];\n\n const segmentDist = a.dist(b),\n angle = b.angleTo(a);\n\n while (markedDistance + spacing < distance + segmentDist) {\n markedDistance += spacing;\n\n const t = (markedDistance - distance) / segmentDist,\n x = interpolates.number(a.x, b.x, t),\n y = interpolates.number(a.y, b.y, t);\n\n // Check that the point is within the tile boundaries and that\n // the label would fit before the beginning and end of the line\n // if placed at this point.\n if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent &&\n markedDistance - halfLabelLength >= 0 &&\n markedDistance + halfLabelLength <= lineLength) {\n const anchor = new Anchor(x, y, angle, i);\n anchor._round();\n\n if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {\n anchors.push(anchor);\n }\n }\n }\n\n distance += segmentDist;\n }\n\n if (!placeAtMiddle && !anchors.length && !isLineContinued) {\n // The first attempt at finding anchors at which labels can be placed failed.\n // Try again, but this time just try placing one anchor at the middle of the line.\n // This has the most effect for short lines in overscaled tiles, since the\n // initial offset used in overscaled tiles is calculated to align labels with positions in\n // parent tiles instead of placing the label as close to the beginning as possible.\n anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, true, tileExtent);\n }\n\n return anchors;\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf';\n\nimport type {Anchor} from './anchor';\nimport type {PositionedIcon, Shaping} from './shaping';\nimport {SHAPING_DEFAULT_OFFSET} from './shaping';\nimport {IMAGE_PADDING} from '../render/image_atlas';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {Feature} from '@maplibre/maplibre-gl-style-spec';\nimport type {StyleImage} from '../style/style_image';\nimport ONE_EM from './one_em';\nimport {Rect} from '../render/glyph_atlas';\n\n/**\n * A textured quad for rendering a single icon or glyph.\n *\n * The zoom range the glyph can be shown is defined by minScale and maxScale.\n *\n * @param tl - The offset of the top left corner from the anchor.\n * @param tr - The offset of the top right corner from the anchor.\n * @param bl - The offset of the bottom left corner from the anchor.\n * @param br - The offset of the bottom right corner from the anchor.\n * @param tex - The texture coordinates.\n */\nexport type SymbolQuad = {\n tl: Point;\n tr: Point;\n bl: Point;\n br: Point;\n tex: {\n x: number;\n y: number;\n w: number;\n h: number;\n };\n pixelOffsetTL: Point;\n pixelOffsetBR: Point;\n writingMode: any | void;\n glyphOffset: [number, number];\n sectionIndex: number;\n isSDF: boolean;\n minFontScaleX: number;\n minFontScaleY: number;\n};\n\n// If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual\n// pixels. The quad needs to be padded to account for this, otherwise they'll look slightly clipped\n// on one edge in some cases.\nconst border = IMAGE_PADDING;\n\n/**\n * Create the quads used for rendering an icon.\n */\nexport function getIconQuads(\n shapedIcon: PositionedIcon,\n iconRotate: number,\n isSDFIcon: boolean,\n hasIconTextFit: boolean\n): Array {\n const quads = [];\n\n const image = shapedIcon.image;\n const pixelRatio = image.pixelRatio;\n const imageWidth = image.paddedRect.w - 2 * border;\n const imageHeight = image.paddedRect.h - 2 * border;\n\n const iconWidth = shapedIcon.right - shapedIcon.left;\n const iconHeight = shapedIcon.bottom - shapedIcon.top;\n\n const stretchX = image.stretchX || [[0, imageWidth]];\n const stretchY = image.stretchY || [[0, imageHeight]];\n\n const reduceRanges = (sum, range) => sum + range[1] - range[0];\n const stretchWidth = stretchX.reduce(reduceRanges, 0);\n const stretchHeight = stretchY.reduce(reduceRanges, 0);\n const fixedWidth = imageWidth - stretchWidth;\n const fixedHeight = imageHeight - stretchHeight;\n\n let stretchOffsetX = 0;\n let stretchContentWidth = stretchWidth;\n let stretchOffsetY = 0;\n let stretchContentHeight = stretchHeight;\n let fixedOffsetX = 0;\n let fixedContentWidth = fixedWidth;\n let fixedOffsetY = 0;\n let fixedContentHeight = fixedHeight;\n\n if (image.content && hasIconTextFit) {\n const content = image.content;\n stretchOffsetX = sumWithinRange(stretchX, 0, content[0]);\n stretchOffsetY = sumWithinRange(stretchY, 0, content[1]);\n stretchContentWidth = sumWithinRange(stretchX, content[0], content[2]);\n stretchContentHeight = sumWithinRange(stretchY, content[1], content[3]);\n fixedOffsetX = content[0] - stretchOffsetX;\n fixedOffsetY = content[1] - stretchOffsetY;\n fixedContentWidth = content[2] - content[0] - stretchContentWidth;\n fixedContentHeight = content[3] - content[1] - stretchContentHeight;\n }\n\n const makeBox = (left, top, right, bottom) => {\n\n const leftEm = getEmOffset(left.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);\n const leftPx = getPxOffset(left.fixed - fixedOffsetX, fixedContentWidth, left.stretch, stretchWidth);\n\n const topEm = getEmOffset(top.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);\n const topPx = getPxOffset(top.fixed - fixedOffsetY, fixedContentHeight, top.stretch, stretchHeight);\n\n const rightEm = getEmOffset(right.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);\n const rightPx = getPxOffset(right.fixed - fixedOffsetX, fixedContentWidth, right.stretch, stretchWidth);\n\n const bottomEm = getEmOffset(bottom.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);\n const bottomPx = getPxOffset(bottom.fixed - fixedOffsetY, fixedContentHeight, bottom.stretch, stretchHeight);\n\n const tl = new Point(leftEm, topEm);\n const tr = new Point(rightEm, topEm);\n const br = new Point(rightEm, bottomEm);\n const bl = new Point(leftEm, bottomEm);\n const pixelOffsetTL = new Point(leftPx / pixelRatio, topPx / pixelRatio);\n const pixelOffsetBR = new Point(rightPx / pixelRatio, bottomPx / pixelRatio);\n\n const angle = iconRotate * Math.PI / 180;\n\n if (angle) {\n const sin = Math.sin(angle),\n cos = Math.cos(angle),\n matrix = [cos, -sin, sin, cos];\n\n tl._matMult(matrix);\n tr._matMult(matrix);\n bl._matMult(matrix);\n br._matMult(matrix);\n }\n\n const x1 = left.stretch + left.fixed;\n const x2 = right.stretch + right.fixed;\n const y1 = top.stretch + top.fixed;\n const y2 = bottom.stretch + bottom.fixed;\n\n const subRect = {\n x: image.paddedRect.x + border + x1,\n y: image.paddedRect.y + border + y1,\n w: x2 - x1,\n h: y2 - y1\n };\n\n const minFontScaleX = fixedContentWidth / pixelRatio / iconWidth;\n const minFontScaleY = fixedContentHeight / pixelRatio / iconHeight;\n\n // Icon quad is padded, so texture coordinates also need to be padded.\n return {tl, tr, bl, br, tex: subRect, writingMode: undefined, glyphOffset: [0, 0], sectionIndex: 0, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, isSDF: isSDFIcon};\n };\n\n if (!hasIconTextFit || (!image.stretchX && !image.stretchY)) {\n quads.push(makeBox(\n {fixed: 0, stretch: -1},\n {fixed: 0, stretch: -1},\n {fixed: 0, stretch: imageWidth + 1},\n {fixed: 0, stretch: imageHeight + 1}));\n } else {\n const xCuts = stretchZonesToCuts(stretchX, fixedWidth, stretchWidth);\n const yCuts = stretchZonesToCuts(stretchY, fixedHeight, stretchHeight);\n\n for (let xi = 0; xi < xCuts.length - 1; xi++) {\n const x1 = xCuts[xi];\n const x2 = xCuts[xi + 1];\n for (let yi = 0; yi < yCuts.length - 1; yi++) {\n const y1 = yCuts[yi];\n const y2 = yCuts[yi + 1];\n quads.push(makeBox(x1, y1, x2, y2));\n }\n }\n }\n\n return quads;\n}\n\nfunction sumWithinRange(ranges, min, max) {\n let sum = 0;\n for (const range of ranges) {\n sum += Math.max(min, Math.min(max, range[1])) - Math.max(min, Math.min(max, range[0]));\n }\n return sum;\n}\n\nfunction stretchZonesToCuts(stretchZones, fixedSize, stretchSize) {\n const cuts = [{fixed: -border, stretch: 0}];\n\n for (const [c1, c2] of stretchZones) {\n const last = cuts[cuts.length - 1];\n cuts.push({\n fixed: c1 - last.stretch,\n stretch: last.stretch\n });\n cuts.push({\n fixed: c1 - last.stretch,\n stretch: last.stretch + (c2 - c1)\n });\n }\n cuts.push({\n fixed: fixedSize + border,\n stretch: stretchSize\n });\n return cuts;\n}\n\nfunction getEmOffset(stretchOffset, stretchSize, iconSize, iconOffset) {\n return stretchOffset / stretchSize * iconSize + iconOffset;\n}\n\nfunction getPxOffset(fixedOffset, fixedSize, stretchOffset, stretchSize) {\n return fixedOffset - fixedSize * stretchOffset / stretchSize;\n}\n\n/**\n * Create the quads used for rendering a text label.\n */\nexport function getGlyphQuads(\n anchor: Anchor,\n shaping: Shaping,\n textOffset: [number, number],\n layer: SymbolStyleLayer,\n alongLine: boolean,\n feature: Feature,\n imageMap: {[_: string]: StyleImage},\n allowVerticalPlacement: boolean\n): Array {\n\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}) * Math.PI / 180;\n const quads = [];\n\n for (const line of shaping.positionedLines) {\n for (const positionedGlyph of line.positionedGlyphs) {\n if (!positionedGlyph.rect) continue;\n const textureRect: Rect = positionedGlyph.rect || {} as Rect;\n\n // The rects have an additional buffer that is not included in their size.\n const glyphPadding = 1.0;\n let rectBuffer = GLYPH_PBF_BORDER + glyphPadding;\n let isSDF = true;\n let pixelRatio = 1.0;\n let lineOffset = 0.0;\n\n const rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical;\n const halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2;\n\n // Align images and scaled glyphs in the middle of a vertical line.\n if (allowVerticalPlacement && shaping.verticalizable) {\n const scaledGlyphOffset = (positionedGlyph.scale - 1) * ONE_EM;\n const imageOffset = (ONE_EM - positionedGlyph.metrics.width * positionedGlyph.scale) / 2;\n lineOffset = line.lineOffset / 2 - (positionedGlyph.imageName ? -imageOffset : scaledGlyphOffset);\n }\n\n if (positionedGlyph.imageName) {\n const image = imageMap[positionedGlyph.imageName];\n isSDF = image.sdf;\n pixelRatio = image.pixelRatio;\n rectBuffer = IMAGE_PADDING / pixelRatio;\n }\n\n const glyphOffset = alongLine ?\n [positionedGlyph.x + halfAdvance, positionedGlyph.y] :\n [0, 0];\n\n let builtInOffset: [number, number] = alongLine ?\n [0, 0] :\n [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1] - lineOffset];\n\n let verticalizedLabelOffset = [0, 0] as [number, number];\n if (rotateVerticalGlyph) {\n // Vertical POI labels that are rotated 90deg CW and whose glyphs must preserve upright orientation\n // need to be rotated 90deg CCW. After a quad is rotated, it is translated to the original built-in offset.\n verticalizedLabelOffset = builtInOffset;\n builtInOffset = [0, 0];\n }\n\n const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1;\n\n const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];\n const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1];\n const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio;\n const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio;\n\n const tl = new Point(x1, y1);\n const tr = new Point(x2, y1);\n const bl = new Point(x1, y2);\n const br = new Point(x2, y2);\n\n if (rotateVerticalGlyph) {\n // Vertical-supporting glyphs are laid out in 24x24 point boxes (1 square em)\n // In horizontal orientation, the y values for glyphs are below the midline\n // and we use a \"yOffset\" of -17 to pull them up to the middle.\n // By rotating counter-clockwise around the point at the center of the left\n // edge of a 24x24 layout box centered below the midline, we align the center\n // of the glyphs with the horizontal midline, so the yOffset is no longer\n // necessary, but we also pull the glyph to the left along the x axis.\n // The y coordinate includes baseline yOffset, thus needs to be accounted\n // for when glyph is rotated and translated.\n const center = new Point(-halfAdvance, halfAdvance - SHAPING_DEFAULT_OFFSET);\n const verticalRotation = -Math.PI / 2;\n\n // xHalfWidthOffsetCorrection is a difference between full-width and half-width\n // advance, should be 0 for full-width glyphs and will pull up half-width glyphs.\n const xHalfWidthOffsetCorrection = ONE_EM / 2 - halfAdvance;\n const yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0.0;\n const halfWidthOffsetCorrection = new Point(5 - SHAPING_DEFAULT_OFFSET - xHalfWidthOffsetCorrection, -yImageOffsetCorrection);\n const verticalOffsetCorrection = new Point(...verticalizedLabelOffset);\n tl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n tr._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n bl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n br._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);\n }\n\n if (textRotate) {\n const sin = Math.sin(textRotate),\n cos = Math.cos(textRotate),\n matrix = [cos, -sin, sin, cos];\n\n tl._matMult(matrix);\n tr._matMult(matrix);\n bl._matMult(matrix);\n br._matMult(matrix);\n }\n\n const pixelOffsetTL = new Point(0, 0);\n const pixelOffsetBR = new Point(0, 0);\n const minFontScaleX = 0;\n const minFontScaleY = 0;\n quads.push({tl, tr, bl, br, tex: textureRect, writingMode: shaping.writingMode, glyphOffset, sectionIndex: positionedGlyph.sectionIndex, isSDF, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY});\n }\n }\n\n return quads;\n}\n","import type {CollisionBoxArray} from '../data/array_types.g';\nimport Point from '@mapbox/point-geometry';\nimport type {Anchor} from './anchor';\nimport {SymbolPadding} from '../style/style_layer/symbol_style_layer';\n\n/**\n * A CollisionFeature represents the area of the tile covered by a single label.\n * It is used with CollisionIndex to check if the label overlaps with any\n * previous labels. A CollisionFeature is mostly just a set of CollisionBox\n * objects.\n */\nexport class CollisionFeature {\n boxStartIndex: number;\n boxEndIndex: number;\n circleDiameter: number;\n\n /**\n * Create a CollisionFeature, adding its collision box data to the given collisionBoxArray in the process.\n * For line aligned labels a collision circle diameter is computed instead.\n *\n * @param anchor - The point along the line around which the label is anchored.\n * @param shaped - The text or icon shaping results.\n * @param boxScale - A magic number used to convert from glyph metrics units to geometry units.\n * @param padding - The amount of padding to add around the label edges.\n * @param alignLine - Whether the label is aligned with the line or the viewport.\n */\n constructor(collisionBoxArray: CollisionBoxArray,\n anchor: Anchor,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n shaped: any,\n boxScale: number,\n padding: SymbolPadding,\n alignLine: boolean,\n rotate: number) {\n\n this.boxStartIndex = collisionBoxArray.length;\n\n if (alignLine) {\n // Compute height of the shape in glyph metrics and apply collision padding.\n // Note that the pixel based 'text-padding' is applied at runtime\n let top = shaped.top;\n let bottom = shaped.bottom;\n const collisionPadding = shaped.collisionPadding;\n\n if (collisionPadding) {\n top -= collisionPadding[1];\n bottom += collisionPadding[3];\n }\n\n let height = bottom - top;\n\n if (height > 0) {\n // set minimum box height to avoid very many small labels\n height = Math.max(10, height);\n this.circleDiameter = height;\n }\n } else {\n // margin is in CSS order: [top, right, bottom, left]\n let y1 = shaped.top * boxScale - padding[0];\n let y2 = shaped.bottom * boxScale + padding[2];\n let x1 = shaped.left * boxScale - padding[3];\n let x2 = shaped.right * boxScale + padding[1];\n\n const collisionPadding = shaped.collisionPadding;\n if (collisionPadding) {\n x1 -= collisionPadding[0] * boxScale;\n y1 -= collisionPadding[1] * boxScale;\n x2 += collisionPadding[2] * boxScale;\n y2 += collisionPadding[3] * boxScale;\n }\n\n if (rotate) {\n // Account for *-rotate in point collision boxes\n // See https://github.com/mapbox/mapbox-gl-js/issues/6075\n // Doesn't account for icon-text-fit\n\n const tl = new Point(x1, y1);\n const tr = new Point(x2, y1);\n const bl = new Point(x1, y2);\n const br = new Point(x2, y2);\n\n const rotateRadians = rotate * Math.PI / 180;\n\n tl._rotate(rotateRadians);\n tr._rotate(rotateRadians);\n bl._rotate(rotateRadians);\n br._rotate(rotateRadians);\n\n // Collision features require an \"on-axis\" geometry,\n // so take the envelope of the rotated geometry\n // (may be quite large for wide labels rotated 45 degrees)\n x1 = Math.min(tl.x, tr.x, bl.x, br.x);\n x2 = Math.max(tl.x, tr.x, bl.x, br.x);\n y1 = Math.min(tl.y, tr.y, bl.y, br.y);\n y2 = Math.max(tl.y, tr.y, bl.y, br.y);\n }\n collisionBoxArray.emplaceBack(anchor.x, anchor.y, x1, y1, x2, y2, featureIndex, sourceLayerIndex, bucketIndex);\n }\n\n this.boxEndIndex = collisionBoxArray.length;\n }\n}\n","\nexport default class TinyQueue {\n constructor(data = [], compare = defaultCompare) {\n this.data = data;\n this.length = this.data.length;\n this.compare = compare;\n\n if (this.length > 0) {\n for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);\n }\n }\n\n push(item) {\n this.data.push(item);\n this.length++;\n this._up(this.length - 1);\n }\n\n pop() {\n if (this.length === 0) return undefined;\n\n const top = this.data[0];\n const bottom = this.data.pop();\n this.length--;\n\n if (this.length > 0) {\n this.data[0] = bottom;\n this._down(0);\n }\n\n return top;\n }\n\n peek() {\n return this.data[0];\n }\n\n _up(pos) {\n const {data, compare} = this;\n const item = data[pos];\n\n while (pos > 0) {\n const parent = (pos - 1) >> 1;\n const current = data[parent];\n if (compare(item, current) >= 0) break;\n data[pos] = current;\n pos = parent;\n }\n\n data[pos] = item;\n }\n\n _down(pos) {\n const {data, compare} = this;\n const halfLength = this.length >> 1;\n const item = data[pos];\n\n while (pos < halfLength) {\n let left = (pos << 1) + 1;\n let best = data[left];\n const right = left + 1;\n\n if (right < this.length && compare(data[right], best) < 0) {\n left = right;\n best = data[right];\n }\n if (compare(best, item) >= 0) break;\n\n data[pos] = best;\n pos = left;\n }\n\n data[pos] = item;\n }\n}\n\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import Queue from 'tinyqueue';\n\nimport Point from '@mapbox/point-geometry';\nimport {distToSegmentSquared} from './intersection_tests';\n\n/**\n * Finds an approximation of a polygon's Pole Of Inaccessibiliy https://en.wikipedia.org/wiki/Pole_of_inaccessibility\n * This is a copy of http://github.com/mapbox/polylabel adapted to use Points\n *\n * @param polygonRings - first item in array is the outer ring followed optionally by the list of holes, should be an element of the result of util/classify_rings\n * @param precision - Specified in input coordinate units. If 0 returns after first run, if `> 0` repeatedly narrows the search space until the radius of the area searched for the best pole is less than precision\n * @param debug - Print some statistics to the console during execution\n * @returns Pole of Inaccessibiliy.\n */\nexport function findPoleOfInaccessibility(\n polygonRings: Array>,\n precision: number = 1,\n debug: boolean = false\n): Point {\n // find the bounding box of the outer ring\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n const outerRing = polygonRings[0];\n for (let i = 0; i < outerRing.length; i++) {\n const p = outerRing[i];\n if (!i || p.x < minX) minX = p.x;\n if (!i || p.y < minY) minY = p.y;\n if (!i || p.x > maxX) maxX = p.x;\n if (!i || p.y > maxY) maxY = p.y;\n }\n\n const width = maxX - minX;\n const height = maxY - minY;\n const cellSize = Math.min(width, height);\n let h = cellSize / 2;\n\n // a priority queue of cells in order of their \"potential\" (max distance to polygon)\n const cellQueue = new Queue([], compareMax);\n\n if (cellSize === 0) return new Point(minX, minY);\n\n // cover polygon with initial cells\n for (let x = minX; x < maxX; x += cellSize) {\n for (let y = minY; y < maxY; y += cellSize) {\n cellQueue.push(new Cell(x + h, y + h, h, polygonRings));\n }\n }\n\n // take centroid as the first best guess\n let bestCell = getCentroidCell(polygonRings);\n let numProbes = cellQueue.length;\n\n while (cellQueue.length) {\n // pick the most promising cell from the queue\n const cell = cellQueue.pop();\n\n // update the best cell if we found a better one\n if (cell.d > bestCell.d || !bestCell.d) {\n bestCell = cell;\n if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes);\n }\n\n // do not drill down further if there's no chance of a better solution\n if (cell.max - bestCell.d <= precision) continue;\n\n // split the cell into four cells\n h = cell.h / 2;\n cellQueue.push(new Cell(cell.p.x - h, cell.p.y - h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x + h, cell.p.y - h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x - h, cell.p.y + h, h, polygonRings));\n cellQueue.push(new Cell(cell.p.x + h, cell.p.y + h, h, polygonRings));\n numProbes += 4;\n }\n\n if (debug) {\n console.log(`num probes: ${numProbes}`);\n console.log(`best distance: ${bestCell.d}`);\n }\n\n return bestCell.p;\n}\n\nfunction compareMax(a, b) {\n return b.max - a.max;\n}\n\nfunction Cell(x, y, h, polygon) {\n this.p = new Point(x, y);\n this.h = h; // half the cell size\n this.d = pointToPolygonDist(this.p, polygon); // distance from cell center to polygon\n this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell\n}\n\n// signed distance from point to polygon outline (negative if point is outside)\nfunction pointToPolygonDist(p, polygon) {\n let inside = false;\n let minDistSq = Infinity;\n\n for (let k = 0; k < polygon.length; k++) {\n const ring = polygon[k];\n\n for (let i = 0, len = ring.length, j = len - 1; i < len; j = i++) {\n const a = ring[i];\n const b = ring[j];\n\n if ((a.y > p.y !== b.y > p.y) &&\n (p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x)) inside = !inside;\n\n minDistSq = Math.min(minDistSq, distToSegmentSquared(p, a, b));\n }\n }\n\n return (inside ? 1 : -1) * Math.sqrt(minDistSq);\n}\n\n// get polygon centroid\nfunction getCentroidCell(polygon) {\n let area = 0;\n let x = 0;\n let y = 0;\n const points = polygon[0];\n for (let i = 0, len = points.length, j = len - 1; i < len; j = i++) {\n const a = points[i];\n const b = points[j];\n const f = a.x * b.y - b.x * a.y;\n x += (a.x + b.x) * f;\n y += (a.y + b.y) * f;\n area += f * 3;\n }\n return new Cell(x / area, y / area, 0, polygon);\n}\n","import {VariableAnchorOffsetCollection, VariableAnchorOffsetCollectionSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolFeature} from '../../data/bucket/symbol_bucket';\nimport {CanonicalTileID} from '../../source/tile_id';\nimport ONE_EM from '../../symbol/one_em';\nimport {SymbolStyleLayer} from './symbol_style_layer';\n\nexport enum TextAnchorEnum {\n 'center' = 1,\n 'left' = 2,\n 'right' = 3,\n 'top' = 4,\n 'bottom' = 5,\n 'top-left' = 6,\n 'top-right' = 7,\n 'bottom-left' = 8,\n 'bottom-right' = 9\n}\n\nexport type TextAnchor = keyof typeof TextAnchorEnum;\n\n// The radial offset is to the edge of the text box\n// In the horizontal direction, the edge of the text box is where glyphs start\n// But in the vertical direction, the glyphs appear to \"start\" at the baseline\n// We don't actually load baseline data, but we assume an offset of ONE_EM - 17\n// (see \"yOffset\" in shaping.js)\nconst baselineOffset = 7;\nexport const INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY;\n\nexport function evaluateVariableOffset(anchor: TextAnchor, offset: [number, number]): [number, number] {\n\n function fromRadialOffset(anchor: TextAnchor, radialOffset: number): [number, number] {\n let x = 0, y = 0;\n if (radialOffset < 0) radialOffset = 0; // Ignore negative offset.\n // solve for r where r^2 + r^2 = radialOffset^2\n const hypotenuse = radialOffset / Math.SQRT2;\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n y = hypotenuse - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n y = -hypotenuse + baselineOffset;\n break;\n case 'bottom':\n y = -radialOffset + baselineOffset;\n break;\n case 'top':\n y = radialOffset - baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n x = -hypotenuse;\n break;\n case 'top-left':\n case 'bottom-left':\n x = hypotenuse;\n break;\n case 'left':\n x = radialOffset;\n break;\n case 'right':\n x = -radialOffset;\n break;\n }\n\n return [x, y];\n }\n\n function fromTextOffset(anchor: TextAnchor, offsetX: number, offsetY: number): [number, number] {\n let x = 0, y = 0;\n // Use absolute offset values.\n offsetX = Math.abs(offsetX);\n offsetY = Math.abs(offsetY);\n\n switch (anchor) {\n case 'top-right':\n case 'top-left':\n case 'top':\n y = offsetY - baselineOffset;\n break;\n case 'bottom-right':\n case 'bottom-left':\n case 'bottom':\n y = -offsetY + baselineOffset;\n break;\n }\n\n switch (anchor) {\n case 'top-right':\n case 'bottom-right':\n case 'right':\n x = -offsetX;\n break;\n case 'top-left':\n case 'bottom-left':\n case 'left':\n x = offsetX;\n break;\n }\n\n return [x, y];\n }\n\n return (offset[1] !== INVALID_TEXT_OFFSET) ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]);\n}\n\n// Helper to support both text-variable-anchor and text-variable-anchor-offset. Offset values converted from EMs to PXs\nexport function getTextVariableAnchorOffset(layer: SymbolStyleLayer, feature: SymbolFeature, canonical: CanonicalTileID): VariableAnchorOffsetCollection | null {\n const layout = layer.layout;\n // If style specifies text-variable-anchor-offset, just return it\n const variableAnchorOffset = layout.get('text-variable-anchor-offset')?.evaluate(feature, {}, canonical);\n\n if (variableAnchorOffset) {\n const sourceValues = variableAnchorOffset.values;\n const destValues: VariableAnchorOffsetCollectionSpecification = [];\n\n // Convert offsets from EM to PX, and apply baseline shift\n for (let i = 0; i < sourceValues.length; i += 2) {\n const anchor = destValues[i] = sourceValues[i] as TextAnchor;\n const offset = (sourceValues[i + 1] as [number, number]).map(t => t * ONE_EM) as [number, number];\n\n if (anchor.startsWith('top')) {\n offset[1] -= baselineOffset;\n } else if (anchor.startsWith('bottom')) {\n offset[1] += baselineOffset;\n }\n\n destValues[i + 1] = offset;\n }\n\n return new VariableAnchorOffsetCollection(destValues);\n }\n\n // If style specifies text-variable-anchor, convert to the new format\n const variableAnchor = layout.get('text-variable-anchor');\n\n if (variableAnchor) {\n let textOffset: [number, number];\n const unevaluatedLayout = layer._unevaluatedLayout;\n\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n if (unevaluatedLayout.getValue('text-radial-offset') !== undefined) {\n textOffset = [layout.get('text-radial-offset').evaluate(feature, {}, canonical) * ONE_EM, INVALID_TEXT_OFFSET];\n } else {\n textOffset = layout.get('text-offset').evaluate(feature, {}, canonical).map(t => t * ONE_EM) as [number, number];\n }\n\n const anchorOffsets: VariableAnchorOffsetCollectionSpecification = [];\n\n for (const anchor of variableAnchor) {\n anchorOffsets.push(anchor, evaluateVariableOffset(anchor, textOffset));\n }\n\n return new VariableAnchorOffsetCollection(anchorOffsets);\n }\n\n return null;\n}\n","import {Anchor} from './anchor';\n\nimport {getAnchors, getCenterAnchor} from './get_anchors';\nimport {clipLine} from './clip_line';\nimport {shapeText, shapeIcon, WritingMode, fitIconToText} from './shaping';\nimport {getGlyphQuads, getIconQuads} from './quads';\nimport {CollisionFeature} from './collision_feature';\nimport {warnOnce} from '../util/util';\nimport {\n allowsVerticalWritingMode,\n allowsLetterSpacing\n} from '../util/script_detection';\nimport {findPoleOfInaccessibility} from '../util/find_pole_of_inaccessibility';\nimport {classifyRings} from '../util/classify_rings';\nimport {EXTENT} from '../data/extent';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SIZE_PACK_FACTOR, MAX_PACKED_SIZE, MAX_GLYPH_ICON_SIZE} from './symbol_size';\nimport ONE_EM from './one_em';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {Shaping, PositionedIcon, TextJustify} from './shaping';\nimport type {CollisionBoxArray, TextAnchorOffsetArray} from '../data/array_types.g';\nimport type {SymbolFeature} from '../data/bucket/symbol_bucket';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {GlyphPosition} from '../render/glyph_atlas';\nimport type {PossiblyEvaluatedPropertyValue} from '../style/properties';\n\nimport Point from '@mapbox/point-geometry';\nimport murmur3 from 'murmurhash-js';\nimport {getIconPadding, SymbolPadding} from '../style/style_layer/symbol_style_layer';\nimport {VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';\nimport {getTextVariableAnchorOffset, evaluateVariableOffset, INVALID_TEXT_OFFSET, TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\n// The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and\n// `icon-size` at up to three:\n//\n// 1. `text-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `text-size`\n// expressions, and to calculate the box dimensions for icon-text-fit.\n// 2. `icon-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `icon-size`\n// expressions.\n// 3. `text-size` and `icon-size` at the zoom level of the bucket, plus one. Used to calculate collision boxes.\n// 4. `text-size` at zoom level 18. Used for something line-symbol-placement-related.\n// 5. For composite `*-size` expressions: two zoom levels of curve stops that \"cover\" the zoom level of the\n// bucket. These go into a vertex buffer and are used by the shader to interpolate the size at render time.\n//\n// (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below.\n//\ntype Sizes = {\n layoutTextSize: PossiblyEvaluatedPropertyValue; // (3),\n layoutIconSize: PossiblyEvaluatedPropertyValue; // (3),\n textMaxSize: PossiblyEvaluatedPropertyValue; // (4),\n compositeTextSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5),\n compositeIconSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5)\n};\n\ntype ShapedTextOrientations = {\n vertical: Shaping | false;\n horizontal: Record;\n};\n\nexport function performSymbolLayout(args: {\n bucket: SymbolBucket;\n glyphMap: {\n [_: string]: {\n [x: number]: StyleGlyph;\n };\n };\n glyphPositions: {\n [_: string]: {\n [x: number]: GlyphPosition;\n };\n };\n imageMap: {[_: string]: StyleImage};\n imagePositions: {[_: string]: ImagePosition};\n showCollisionBoxes: boolean;\n canonical: CanonicalTileID;\n}) {\n args.bucket.createArrays();\n\n const tileSize = 512 * args.bucket.overscaling;\n args.bucket.tilePixelRatio = EXTENT / tileSize;\n args.bucket.compareText = {};\n args.bucket.iconsNeedLinear = false;\n\n const layer = args.bucket.layers[0];\n const layout = layer.layout;\n const unevaluatedLayoutValues = layer._unevaluatedLayout._values;\n\n const sizes: Sizes = {\n // Filled in below, if *SizeData.kind is 'composite'\n // compositeIconSizes: undefined,\n // compositeTextSizes: undefined,\n layoutIconSize: unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n layoutTextSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical),\n textMaxSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18))\n } as Sizes;\n\n if (args.bucket.textSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.textSizeData;\n sizes.compositeTextSizes = [\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n if (args.bucket.iconSizeData.kind === 'composite') {\n const {minZoom, maxZoom} = args.bucket.iconSizeData;\n sizes.compositeIconSizes = [\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical),\n unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical)\n ];\n }\n\n const lineHeight = layout.get('text-line-height') * ONE_EM;\n const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point';\n const keepUpright = layout.get('text-keep-upright');\n const textSize = layout.get('text-size');\n\n for (const feature of args.bucket.features) {\n const fontstack = layout.get('text-font').evaluate(feature, {}, args.canonical).join(',');\n const layoutTextSizeThisZoom = textSize.evaluate(feature, {}, args.canonical);\n const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, args.canonical);\n const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, args.canonical);\n\n const shapedTextOrientations: ShapedTextOrientations = {\n horizontal: {} as Record,\n vertical: undefined\n };\n const text = feature.text;\n let textOffset: [number, number] = [0, 0];\n if (text) {\n const unformattedText = text.toString();\n const spacing = layout.get('text-letter-spacing').evaluate(feature, {}, args.canonical) * ONE_EM;\n const spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0;\n\n const textAnchor = layout.get('text-anchor').evaluate(feature, {}, args.canonical);\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, args.canonical);\n\n if (!variableAnchorOffset) {\n const radialOffset = layout.get('text-radial-offset').evaluate(feature, {}, args.canonical);\n // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector\n // is calculated at placement time instead of layout time\n if (radialOffset) {\n // The style spec says don't use `text-offset` and `text-radial-offset` together\n // but doesn't actually specify what happens if you use both. We go with the radial offset.\n textOffset = evaluateVariableOffset(textAnchor, [radialOffset * ONE_EM, INVALID_TEXT_OFFSET]);\n } else {\n textOffset = (layout.get('text-offset').evaluate(feature, {}, args.canonical).map(t => t * ONE_EM) as [number, number]);\n }\n }\n\n let textJustify = textAlongLine ?\n 'center' :\n layout.get('text-justify').evaluate(feature, {}, args.canonical);\n\n const symbolPlacement = layout.get('symbol-placement');\n const maxWidth = symbolPlacement === 'point' ?\n layout.get('text-max-width').evaluate(feature, {}, args.canonical) * ONE_EM :\n 0;\n\n const addVerticalShapingForPointLabelIfNeeded = () => {\n if (args.bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) {\n // Vertical POI label placement is meant to be used for scripts that support vertical\n // writing mode, thus, default left justification is used. If Latin\n // scripts would need to be supported, this should take into account other justifications.\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor,\n 'left', spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n };\n\n // If this layer uses text-variable-anchor, generate shapings for all justification possibilities.\n if (!textAlongLine && variableAnchorOffset) {\n const justifications = new Set();\n\n if (textJustify === 'auto') {\n for (let i = 0; i < variableAnchorOffset.values.length; i += 2) {\n justifications.add(getAnchorJustification(variableAnchorOffset.values[i] as TextAnchor));\n }\n } else {\n justifications.add(textJustify);\n }\n\n let singleLine = false;\n for (const justification of justifications) {\n if (shapedTextOrientations.horizontal[justification]) continue;\n if (singleLine) {\n // If the shaping for the first justification was only a single line, we\n // can re-use it for the other justifications\n shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0];\n } else {\n // If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply\n // the offsets for the anchor in the placement step.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, 'center',\n justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) {\n shapedTextOrientations.horizontal[justification] = shaping;\n singleLine = shaping.positionedLines.length === 1;\n }\n }\n }\n\n addVerticalShapingForPointLabelIfNeeded();\n } else {\n if (textJustify === 'auto') {\n textJustify = getAnchorJustification(textAnchor);\n }\n\n // Horizontal point or line label.\n const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed,\n textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n if (shaping) shapedTextOrientations.horizontal[textJustify] = shaping;\n\n // Vertical point label (if allowVerticalPlacement is enabled).\n addVerticalShapingForPointLabelIfNeeded();\n\n // Verticalized line label.\n if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) {\n shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify,\n spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);\n }\n }\n }\n\n let shapedIcon;\n let isSDFIcon = false;\n if (feature.icon && feature.icon.name) {\n const image = args.imageMap[feature.icon.name];\n if (image) {\n shapedIcon = shapeIcon(\n args.imagePositions[feature.icon.name],\n layout.get('icon-offset').evaluate(feature, {}, args.canonical),\n layout.get('icon-anchor').evaluate(feature, {}, args.canonical));\n // null/undefined SDF property treated same as default (false)\n isSDFIcon = !!image.sdf;\n if (args.bucket.sdfIcons === undefined) {\n args.bucket.sdfIcons = isSDFIcon;\n } else if (args.bucket.sdfIcons !== isSDFIcon) {\n warnOnce('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer');\n }\n if (image.pixelRatio !== args.bucket.pixelRatio) {\n args.bucket.iconsNeedLinear = true;\n } else if (layout.get('icon-rotate').constantOr(1) !== 0) {\n args.bucket.iconsNeedLinear = true;\n }\n }\n }\n\n const shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical;\n args.bucket.iconsInText = shapedText ? shapedText.iconsInText : false;\n if (shapedText || shapedIcon) {\n addFeature(args.bucket, feature, shapedTextOrientations, shapedIcon, args.imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, args.canonical);\n }\n }\n\n if (args.showCollisionBoxes) {\n args.bucket.generateCollisionDebugBuffers();\n }\n}\n\n// Choose the justification that matches the direction of the TextAnchor\nexport function getAnchorJustification(anchor: TextAnchor): TextJustify {\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n return 'right';\n case 'left':\n case 'top-left':\n case 'bottom-left':\n return 'left';\n }\n return 'center';\n}\n\n/**\n * Given a feature and its shaped text and icon data, add a 'symbol\n * instance' for each _possible_ placement of the symbol feature.\n * (At render timePlaceSymbols#place() selects which of these instances to\n * show or hide based on collisions with symbols in other layers.)\n */\nfunction addFeature(bucket: SymbolBucket,\n feature: SymbolFeature,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon,\n imageMap: {[_: string]: StyleImage},\n sizes: Sizes,\n layoutTextSize: number,\n layoutIconSize: number,\n textOffset: [number, number],\n isSDFIcon: boolean, canonical: CanonicalTileID) {\n // To reduce the number of labels that jump around when zooming we need\n // to use a text-size value that is the same for all zoom levels.\n // bucket calculates text-size at a high zoom level so that all tiles can\n // use the same value when calculating anchor positions.\n let textMaxSize = sizes.textMaxSize.evaluate(feature, {});\n if (textMaxSize === undefined) {\n textMaxSize = layoutTextSize;\n }\n const layout = bucket.layers[0].layout;\n const iconOffset = layout.get('icon-offset').evaluate(feature, {}, canonical);\n const defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal);\n const glyphSize = 24,\n fontScale = layoutTextSize / glyphSize,\n textBoxScale = bucket.tilePixelRatio * fontScale,\n textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize,\n iconBoxScale = bucket.tilePixelRatio * layoutIconSize,\n symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing'),\n textPadding = layout.get('text-padding') * bucket.tilePixelRatio,\n iconPadding = getIconPadding(layout, feature, canonical, bucket.tilePixelRatio),\n textMaxAngle = layout.get('text-max-angle') / 180 * Math.PI,\n textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point',\n iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point',\n symbolPlacement = layout.get('symbol-placement'),\n textRepeatDistance = symbolMinDistance / 2;\n\n const iconTextFit = layout.get('icon-text-fit');\n let verticallyShapedIcon;\n // Adjust shaped icon size when icon-text-fit is used.\n if (shapedIcon && iconTextFit !== 'none') {\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n if (defaultHorizontalShaping) {\n shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit,\n layout.get('icon-text-fit-padding'), iconOffset, fontScale);\n }\n }\n\n const addSymbolAtAnchor = (line, anchor) => {\n if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) {\n // Symbol layers are drawn across tile boundaries, We filter out symbols\n // outside our tile boundaries (which may be included in vector tile buffers)\n // to prevent double-drawing symbols.\n return;\n }\n\n addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0],\n bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index,\n textBoxScale, [textPadding, textPadding, textPadding, textPadding], textAlongLine, textOffset,\n iconBoxScale, iconPadding, iconAlongLine, iconOffset,\n feature, sizes, isSDFIcon, canonical, layoutTextSize);\n };\n\n if (symbolPlacement === 'line') {\n for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) {\n const anchors = getAnchors(\n line,\n symbolMinDistance,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale,\n bucket.overscaling,\n EXTENT\n );\n for (const anchor of anchors) {\n const shapedText = defaultHorizontalShaping;\n if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (symbolPlacement === 'line-center') {\n // No clipping, multiple lines per feature are allowed\n // \"lines\" with only one point are ignored as in clipLines\n for (const line of feature.geometry) {\n if (line.length > 1) {\n const anchor = getCenterAnchor(\n line,\n textMaxAngle,\n shapedTextOrientations.vertical || defaultHorizontalShaping,\n shapedIcon,\n glyphSize,\n textMaxBoxScale);\n if (anchor) {\n addSymbolAtAnchor(line, anchor);\n }\n }\n }\n } else if (feature.type === 'Polygon') {\n for (const polygon of classifyRings(feature.geometry, 0)) {\n // 16 here represents 2 pixels\n const poi = findPoleOfInaccessibility(polygon, 16);\n addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0));\n }\n } else if (feature.type === 'LineString') {\n // https://github.com/mapbox/mapbox-gl-js/issues/3808\n for (const line of feature.geometry) {\n addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0));\n }\n } else if (feature.type === 'Point') {\n for (const points of feature.geometry) {\n for (const point of points) {\n addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0));\n }\n }\n }\n}\n\nfunction addTextVariableAnchorOffsets(textAnchorOffsets: TextAnchorOffsetArray, variableAnchorOffset: VariableAnchorOffsetCollection): [number, number] {\n const startIndex = textAnchorOffsets.length;\n const values = variableAnchorOffset?.values;\n\n if (values?.length > 0) {\n for (let i = 0; i < values.length; i += 2) {\n const anchor = TextAnchorEnum[values[i] as TextAnchor];\n const offset = values[i + 1] as [number, number];\n\n textAnchorOffsets.emplaceBack(anchor, offset[0], offset[1]);\n }\n }\n\n return [startIndex, textAnchorOffsets.length];\n}\n\nfunction addTextVertices(bucket: SymbolBucket,\n anchor: Point,\n shapedText: Shaping,\n imageMap: {[_: string]: StyleImage},\n layer: SymbolStyleLayer,\n textAlongLine: boolean,\n feature: SymbolFeature,\n textOffset: [number, number],\n lineArray: {\n lineStartIndex: number;\n lineLength: number;\n },\n writingMode: WritingMode,\n placementTypes: Array<'vertical' | 'center' | 'left' | 'right'>,\n placedTextSymbolIndices: {[_: string]: number},\n placedIconIndex: number,\n sizes: Sizes,\n canonical: CanonicalTileID) {\n const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset,\n layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement);\n\n const sizeData = bucket.textSizeData;\n let textSizeData = null;\n\n if (sizeData.kind === 'source') {\n textSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {})\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n textSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical)\n ];\n if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"text-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"text-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.text,\n glyphQuads,\n textSizeData,\n textOffset,\n textAlongLine,\n feature,\n writingMode,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n placedIconIndex,\n canonical);\n\n // The placedSymbolArray is used at render time in drawTileSymbols\n // These indices allow access to the array at collision detection time\n for (const placementType of placementTypes) {\n placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1;\n }\n\n return glyphQuads.length * 4;\n}\n\nfunction getDefaultHorizontalShaping(\n horizontalShaping: Record\n): Shaping | null {\n // We don't care which shaping we get because this is used for collision purposes\n // and all the justifications have the same collision box\n for (const justification in horizontalShaping) {\n return horizontalShaping[justification];\n }\n return null;\n}\n\n/**\n * Add a single label & icon placement.\n */\nfunction addSymbol(bucket: SymbolBucket,\n anchor: Anchor,\n line: Array,\n shapedTextOrientations: ShapedTextOrientations,\n shapedIcon: PositionedIcon | void,\n imageMap: {[_: string]: StyleImage},\n verticallyShapedIcon: PositionedIcon | void,\n layer: SymbolStyleLayer,\n collisionBoxArray: CollisionBoxArray,\n featureIndex: number,\n sourceLayerIndex: number,\n bucketIndex: number,\n textBoxScale: number,\n textPadding: SymbolPadding,\n textAlongLine: boolean,\n textOffset: [number, number],\n iconBoxScale: number,\n iconPadding: SymbolPadding,\n iconAlongLine: boolean,\n iconOffset: [number, number],\n feature: SymbolFeature,\n sizes: Sizes,\n isSDFIcon: boolean,\n canonical: CanonicalTileID,\n layoutTextSize: number) {\n const lineArray = bucket.addToLineVertexArray(anchor, line);\n\n let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature;\n\n let numIconVertices = 0;\n let numVerticalIconVertices = 0;\n let numHorizontalGlyphVertices = 0;\n let numVerticalGlyphVertices = 0;\n let placedIconSymbolIndex = -1;\n let verticalPlacedIconSymbolIndex = -1;\n const placedTextSymbolIndices: {[k: string]: number} = {};\n let key = murmur3('');\n\n if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {\n const textRotation = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n const verticalTextRotation = textRotation + 90.0;\n const verticalShaping = shapedTextOrientations.vertical;\n verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation);\n\n if (verticallyShapedIcon) {\n verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation);\n }\n }\n\n //Place icon first, so text can have a reference to its index in the placed symbol array.\n //Text symbols can lazily shift at render-time because of variable anchor placement.\n //If the style specifies an `icon-text-fit` then the icon would have to shift along with it.\n // For more info check `updateVariableAnchors` in `draw_symbol.js` .\n if (shapedIcon) {\n const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {});\n const hasIconTextFit = layer.layout.get('icon-text-fit') !== 'none';\n const iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit);\n const verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : undefined;\n iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/false, iconRotate);\n\n numIconVertices = iconQuads.length * 4;\n\n const sizeData = bucket.iconSizeData;\n let iconSizeData = null;\n\n if (sizeData.kind === 'source') {\n iconSizeData = [\n SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {})\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n } else if (sizeData.kind === 'composite') {\n iconSizeData = [\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical),\n SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical)\n ];\n if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) {\n warnOnce(`${bucket.layerIds[0]}: Value for \"icon-size\" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your \"icon-size\".`);\n }\n }\n\n bucket.addSymbols(\n bucket.icon,\n iconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.none,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n\n if (verticalIconQuads) {\n numVerticalIconVertices = verticalIconQuads.length * 4;\n\n bucket.addSymbols(\n bucket.icon,\n verticalIconQuads,\n iconSizeData,\n iconOffset,\n iconAlongLine,\n feature,\n WritingMode.vertical,\n anchor,\n lineArray.lineStartIndex,\n lineArray.lineLength,\n // The icon itself does not have an associated symbol since the text isnt placed yet\n -1, canonical);\n\n verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;\n }\n }\n\n const justifications = Object.keys(shapedTextOrientations.horizontal) as TextJustify[];\n for (const justification of justifications) {\n const shaping = shapedTextOrientations.horizontal[justification];\n\n if (!textCollisionFeature) {\n key = murmur3(shaping.text);\n const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}, canonical);\n // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature\n // We're counting on all versions having similar dimensions\n textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate);\n }\n\n const singleLine = shaping.positionedLines.length === 1;\n numHorizontalGlyphVertices += addTextVertices(\n bucket, anchor, shaping, imageMap, layer, textAlongLine, feature, textOffset, lineArray,\n shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly,\n singleLine ? justifications : [justification],\n placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical);\n\n if (singleLine) {\n break;\n }\n }\n\n if (shapedTextOrientations.vertical) {\n numVerticalGlyphVertices += addTextVertices(\n bucket, anchor, shapedTextOrientations.vertical, imageMap, layer, textAlongLine, feature,\n textOffset, lineArray, WritingMode.vertical, ['vertical'], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical);\n }\n\n const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n const verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;\n const verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;\n\n // Check if runtime collision circles should be used for any of the collision features.\n // It is enough to choose the tallest feature shape as circles are always placed on a line.\n // All measurements are in glyph metrics and later converted into pixels using proper font size \"layoutTextSize\"\n let collisionCircleDiameter = -1;\n\n const getCollisionCircleHeight = (feature: CollisionFeature, prevHeight: number): number => {\n if (feature && feature.circleDiameter)\n return Math.max(feature.circleDiameter, prevHeight);\n return prevHeight;\n };\n\n collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter);\n collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter);\n const useRuntimeCollisionCircles = (collisionCircleDiameter > -1) ? 1 : 0;\n\n // Convert circle collision height into pixels\n if (useRuntimeCollisionCircles)\n collisionCircleDiameter *= layoutTextSize / ONE_EM;\n\n if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) warnOnce(\n 'Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907'\n );\n\n if (feature.sortKey !== undefined) {\n bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey as number);\n }\n\n const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, canonical);\n const [textAnchorOffsetStartIndex, textAnchorOffsetEndIndex] = addTextVariableAnchorOffsets(bucket.textAnchorOffsets, variableAnchorOffset);\n\n bucket.symbolInstances.emplaceBack(\n anchor.x,\n anchor.y,\n placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1,\n placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1,\n placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1,\n placedTextSymbolIndices.vertical || -1,\n placedIconSymbolIndex,\n verticalPlacedIconSymbolIndex,\n key,\n textBoxStartIndex,\n textBoxEndIndex,\n verticalTextBoxStartIndex,\n verticalTextBoxEndIndex,\n iconBoxStartIndex,\n iconBoxEndIndex,\n verticalIconBoxStartIndex,\n verticalIconBoxEndIndex,\n featureIndex,\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n numIconVertices,\n numVerticalIconVertices,\n useRuntimeCollisionCircles,\n 0,\n textBoxScale,\n collisionCircleDiameter,\n textAnchorOffsetStartIndex,\n textAnchorOffsetEndIndex);\n}\n\nfunction anchorIsTooClose(bucket: SymbolBucket, text: string, repeatDistance: number, anchor: Point) {\n const compareText = bucket.compareText;\n if (!(text in compareText)) {\n compareText[text] = [];\n } else {\n const otherAnchors = compareText[text];\n for (let k = otherAnchors.length - 1; k >= 0; k--) {\n if (anchor.dist(otherAnchors[k]) < repeatDistance) {\n // If it's within repeatDistance of one anchor, stop looking\n return true;\n }\n }\n }\n // If anchor is not within repeatDistance of any other anchor, add to array\n compareText[text].push(anchor);\n return false;\n}\n","\nconst ARRAY_TYPES = [\n Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n];\n\n/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */\n\nconst VERSION = 1; // serialized format version\nconst HEADER_SIZE = 8;\n\nexport default class KDBush {\n\n /**\n * Creates an index from raw `ArrayBuffer` data.\n * @param {ArrayBuffer} data\n */\n static from(data) {\n if (!(data instanceof ArrayBuffer)) {\n throw new Error('Data must be an instance of ArrayBuffer.');\n }\n const [magic, versionAndType] = new Uint8Array(data, 0, 2);\n if (magic !== 0xdb) {\n throw new Error('Data does not appear to be in a KDBush format.');\n }\n const version = versionAndType >> 4;\n if (version !== VERSION) {\n throw new Error(`Got v${version} data when expected v${VERSION}.`);\n }\n const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];\n if (!ArrayType) {\n throw new Error('Unrecognized array type.');\n }\n const [nodeSize] = new Uint16Array(data, 2, 1);\n const [numItems] = new Uint32Array(data, 4, 1);\n\n return new KDBush(numItems, nodeSize, ArrayType, data);\n }\n\n /**\n * Creates an index that will hold a given number of items.\n * @param {number} numItems\n * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).\n * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).\n * @param {ArrayBuffer} [data] (For internal use only)\n */\n constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) {\n if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`);\n\n this.numItems = +numItems;\n this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);\n this.ArrayType = ArrayType;\n this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;\n\n const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);\n const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;\n const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;\n const padCoords = (8 - idsByteSize % 8) % 8;\n\n if (arrayTypeIndex < 0) {\n throw new Error(`Unexpected typed array class: ${ArrayType}.`);\n }\n\n if (data && (data instanceof ArrayBuffer)) { // reconstruct an index from a buffer\n this.data = data;\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = numItems * 2;\n this._finished = true;\n } else { // initialize a new index\n this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = 0;\n this._finished = false;\n\n // set header\n new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);\n new Uint16Array(this.data, 2, 1)[0] = nodeSize;\n new Uint32Array(this.data, 4, 1)[0] = numItems;\n }\n }\n\n /**\n * Add a point to the index.\n * @param {number} x\n * @param {number} y\n * @returns {number} An incremental index associated with the added item (starting from `0`).\n */\n add(x, y) {\n const index = this._pos >> 1;\n this.ids[index] = index;\n this.coords[this._pos++] = x;\n this.coords[this._pos++] = y;\n return index;\n }\n\n /**\n * Perform indexing of the added points.\n */\n finish() {\n const numAdded = this._pos >> 1;\n if (numAdded !== this.numItems) {\n throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);\n }\n // kd-sort both arrays for efficient search\n sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);\n\n this._finished = true;\n return this;\n }\n\n /**\n * Search the index for items within a given bounding box.\n * @param {number} minX\n * @param {number} minY\n * @param {number} maxX\n * @param {number} maxY\n * @returns {number[]} An array of indices correponding to the found items.\n */\n range(minX, minY, maxX, maxY) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n\n // recursively search for items in range in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n const x = coords[2 * i];\n const y = coords[2 * i + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? minX <= x : minY <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? maxX >= x : maxY >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n\n /**\n * Search the index for items within a given radius.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @returns {number[]} An array of indices correponding to the found items.\n */\n within(qx, qy, r) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n const r2 = r * r;\n\n // recursively search for items within radius in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? qx - r <= x : qy - r <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? qx + r >= x : qy + r >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} nodeSize\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction sort(ids, coords, nodeSize, left, right, axis) {\n if (right - left <= nodeSize) return;\n\n const m = (left + right) >> 1; // middle index\n\n // sort ids and coords around the middle index so that the halves lie\n // either left/right or top/bottom correspondingly (taking turns)\n select(ids, coords, m, left, right, axis);\n\n // recursively kd-sort first half and second half on the opposite axis\n sort(ids, coords, nodeSize, left, m - 1, 1 - axis);\n sort(ids, coords, nodeSize, m + 1, right, 1 - axis);\n}\n\n/**\n * Custom Floyd-Rivest selection algorithm: sort ids and coords so that\n * [left..k-1] items are smaller than k-th item (on either x or y axis)\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} k\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction select(ids, coords, k, left, right, axis) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n select(ids, coords, k, newLeft, newRight, axis);\n }\n\n const t = coords[2 * k + axis];\n let i = left;\n let j = right;\n\n swapItem(ids, coords, left, k);\n if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);\n\n while (i < j) {\n swapItem(ids, coords, i, j);\n i++;\n j--;\n while (coords[2 * i + axis] < t) i++;\n while (coords[2 * j + axis] > t) j--;\n }\n\n if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);\n else {\n j++;\n swapItem(ids, coords, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} i\n * @param {number} j\n */\nfunction swapItem(ids, coords, i, j) {\n swap(ids, i, j);\n swap(coords, 2 * i, 2 * j);\n swap(coords, 2 * i + 1, 2 * j + 1);\n}\n\n/**\n * @param {InstanceType} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @param {number} ax\n * @param {number} ay\n * @param {number} bx\n * @param {number} by\n */\nfunction sqDist(ax, ay, bx, by) {\n const dx = ax - bx;\n const dy = ay - by;\n return dx * dx + dy * dy;\n}\n","import type {RequestParameters} from '../util/ajax';\n\nexport type PerformanceMetrics = {\n loadTime: number;\n fullLoadTime: number;\n fps: number;\n percentDroppedFrames: number;\n totalFrames: number;\n};\n\nexport enum PerformanceMarkers {\n create = 'create',\n load = 'load',\n fullLoad = 'fullLoad'\n}\n\nlet lastFrameTime = null;\nlet frameTimes = [];\n\nconst minFramerateTarget = 60;\nconst frameTimeTarget = 1000 / minFramerateTarget;\n\nconst loadTimeKey = 'loadTime';\nconst fullLoadTimeKey = 'fullLoadTime';\n\nexport const PerformanceUtils = {\n mark(marker: PerformanceMarkers) {\n performance.mark(marker);\n },\n frame(timestamp: number) {\n const currTimestamp = timestamp;\n if (lastFrameTime != null) {\n const frameTime = currTimestamp - lastFrameTime;\n frameTimes.push(frameTime);\n }\n lastFrameTime = currTimestamp;\n },\n clearMetrics() {\n lastFrameTime = null;\n frameTimes = [];\n performance.clearMeasures(loadTimeKey);\n performance.clearMeasures(fullLoadTimeKey);\n\n for (const marker in PerformanceMarkers) {\n performance.clearMarks(PerformanceMarkers[marker]);\n }\n },\n\n getPerformanceMetrics(): PerformanceMetrics {\n performance.measure(loadTimeKey, PerformanceMarkers.create, PerformanceMarkers.load);\n performance.measure(fullLoadTimeKey, PerformanceMarkers.create, PerformanceMarkers.fullLoad);\n const loadTime = performance.getEntriesByName(loadTimeKey)[0].duration;\n const fullLoadTime = performance.getEntriesByName(fullLoadTimeKey)[0].duration;\n const totalFrames = frameTimes.length;\n\n const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;\n const fps = 1 / avgFrameTime;\n\n // count frames that missed our framerate target\n const droppedFrames = frameTimes\n .filter((frameTime) => frameTime > frameTimeTarget)\n .reduce((acc, curr) => {\n return acc + (curr - frameTimeTarget) / frameTimeTarget;\n }, 0);\n const percentDroppedFrames = (droppedFrames / (totalFrames + droppedFrames)) * 100;\n\n return {\n loadTime,\n fullLoadTime,\n fps,\n percentDroppedFrames,\n totalFrames\n };\n }\n};\n\n/**\n * @internal\n * Safe wrapper for the performance resource timing API in web workers with graceful degradation\n */\nexport class RequestPerformance {\n _marks: {\n start: string;\n end: string;\n measure: string;\n };\n\n constructor (request: RequestParameters) {\n this._marks = {\n start: [request.url, 'start'].join('#'),\n end: [request.url, 'end'].join('#'),\n measure: request.url.toString()\n };\n\n performance.mark(this._marks.start);\n }\n\n finish() {\n performance.mark(this._marks.end);\n let resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // fallback if web worker implementation of perf.getEntriesByName returns empty\n if (resourceTimingData.length === 0) {\n performance.measure(this._marks.measure, this._marks.start, this._marks.end);\n resourceTimingData = performance.getEntriesByName(this._marks.measure);\n\n // cleanup\n performance.clearMarks(this._marks.start);\n performance.clearMarks(this._marks.end);\n performance.clearMeasures(this._marks.measure);\n }\n\n return resourceTimingData;\n }\n}\n\nexport default performance;\n","import {isWorker} from './util';\nimport {serialize, deserialize, Serialized} from './web_worker_transfer';\nimport {ThrottledInvoker} from './throttled_invoker';\n\nimport type {Transferable} from '../types/transferable';\nimport type {Cancelable} from '../types/cancelable';\nimport type {WorkerSource} from '../source/worker_source';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {Callback} from '../types/callback';\nimport type {StyleGlyph} from '../style/style_glyph';\n\nexport interface ActorTarget {\n addEventListener: typeof window.addEventListener;\n removeEventListener: typeof window.removeEventListener;\n postMessage: typeof window.postMessage;\n terminate?: () => void;\n}\n\nexport interface WorkerSourceProvider {\n getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource;\n}\n\nexport interface GlyphsProvider {\n getGlyphs(mapId: string, params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n );\n}\n\nexport type MessageType = '' | '' |\n'geojson.getClusterExpansionZoom' | 'geojson.getClusterChildren' | 'geojson.getClusterLeaves' | 'geojson.loadData' |\n'removeSource' | 'loadWorkerSource' | 'loadDEMTile' | 'removeDEMTile' |\n'removeTile' | 'reloadTile' | 'abortTile' | 'loadTile' | 'getTile' |\n'getGlyphs' | 'getImages' | 'setImages' |\n'syncRTLPluginState' | 'setReferrer' | 'setLayers' | 'updateLayers';\n\nexport type MessageData = {\n id: string;\n type: MessageType;\n data?: Serialized;\n targetMapId?: string | number | null;\n mustQueue?: boolean;\n error?: Serialized | null;\n hasCallback?: boolean;\n sourceMapId: string | number | null;\n}\n\nexport type Message = {\n data: MessageData;\n}\n\n/**\n * An implementation of the [Actor design pattern](http://en.wikipedia.org/wiki/Actor_model)\n * that maintains the relationship between asynchronous tasks and the objects\n * that spin them off - in this case, tasks like parsing parts of styles,\n * owned by the styles\n */\nexport class Actor {\n target: ActorTarget;\n parent: WorkerSourceProvider | GlyphsProvider;\n mapId: string | number | null;\n callbacks: { [x: number]: Function};\n name: string;\n tasks: { [x: number]: MessageData };\n taskQueue: Array;\n cancelCallbacks: { [x: number]: () => void };\n invoker: ThrottledInvoker;\n globalScope: ActorTarget;\n\n /**\n * @param target - The target\n * @param parent - The parent\n * @param mapId - A unique identifier for the Map instance using this Actor.\n */\n constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number) {\n this.target = target;\n this.parent = parent;\n this.mapId = mapId;\n this.callbacks = {};\n this.tasks = {};\n this.taskQueue = [];\n this.cancelCallbacks = {};\n this.invoker = new ThrottledInvoker(this.process);\n this.target.addEventListener('message', this.receive, false);\n this.globalScope = isWorker() ? target : window;\n }\n\n /**\n * Sends a message from a main-thread map to a Worker or from a Worker back to\n * a main-thread map instance.\n *\n * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource.\n * @param targetMapId - A particular mapId to which to send this message.\n */\n send(\n type: MessageType,\n data: unknown,\n callback?: Function | null,\n targetMapId?: string | null,\n mustQueue: boolean = false\n ): Cancelable {\n // We're using a string ID instead of numbers because they are being used as object keys\n // anyway, and thus stringified implicitly. We use random IDs because an actor may receive\n // message from multiple other actors which could run in different execution context. A\n // linearly increasing ID could produce collisions.\n const id = Math.round((Math.random() * 1e18)).toString(36).substring(0, 10);\n if (callback) {\n this.callbacks[id] = callback;\n }\n const buffers: Array = [];\n const message: MessageData = {\n id,\n type,\n hasCallback: !!callback,\n targetMapId,\n mustQueue,\n sourceMapId: this.mapId,\n data: serialize(data, buffers)\n };\n\n this.target.postMessage(message, {transfer: buffers});\n return {\n cancel: () => {\n if (callback) {\n // Set the callback to null so that it never fires after the request is aborted.\n delete this.callbacks[id];\n }\n const cancelMessage: MessageData = {\n id,\n type: '',\n targetMapId,\n sourceMapId: this.mapId\n };\n this.target.postMessage(cancelMessage);\n }\n };\n }\n\n receive = (message: Message) => {\n const data = message.data;\n const id = data.id;\n\n if (!id) {\n return;\n }\n\n if (data.targetMapId && this.mapId !== data.targetMapId) {\n return;\n }\n\n if (data.type === '') {\n // Remove the original request from the queue. This is only possible if it\n // hasn't been kicked off yet. The id will remain in the queue, but because\n // there is no associated task, it will be dropped once it's time to execute it.\n delete this.tasks[id];\n const cancel = this.cancelCallbacks[id];\n delete this.cancelCallbacks[id];\n if (cancel) {\n cancel();\n }\n } else {\n if (isWorker() || data.mustQueue) {\n // In workers, store the tasks that we need to process before actually processing them. This\n // is necessary because we want to keep receiving messages, and in particular,\n // messages. Some tasks may take a while in the worker thread, so before\n // executing the next task in our queue, postMessage preempts this and \n // messages can be processed. We're using a MessageChannel object to get throttle the\n // process() flow to one at a time.\n this.tasks[id] = data;\n this.taskQueue.push(id);\n this.invoker.trigger();\n } else {\n // In the main thread, process messages immediately so that other work does not slip in\n // between getting partial data back from workers.\n this.processTask(id, data);\n }\n }\n };\n\n process = () => {\n if (!this.taskQueue.length) {\n return;\n }\n const id = this.taskQueue.shift();\n const task = this.tasks[id];\n delete this.tasks[id];\n // Schedule another process call if we know there's more to process _before_ invoking the\n // current task. This is necessary so that processing continues even if the current task\n // doesn't execute successfully.\n if (this.taskQueue.length) {\n this.invoker.trigger();\n }\n if (!task) {\n // If the task ID doesn't have associated task data anymore, it was canceled.\n return;\n }\n\n this.processTask(id, task);\n };\n\n processTask(id: string, task: MessageData) {\n if (task.type === '') {\n // The done() function in the counterpart has been called, and we are now\n // firing the callback in the originating actor, if there is one.\n const callback = this.callbacks[id];\n delete this.callbacks[id];\n if (callback) {\n // If we get a response, but don't have a callback, the request was canceled.\n if (task.error) {\n callback(deserialize(task.error));\n } else {\n callback(null, deserialize(task.data));\n }\n }\n } else {\n let completed = false;\n const buffers: Array = [];\n const done = task.hasCallback ? (err: Error, data?: any) => {\n completed = true;\n delete this.cancelCallbacks[id];\n const responseMessage: MessageData = {\n id,\n type: '',\n sourceMapId: this.mapId,\n error: err ? serialize(err) : null,\n data: serialize(data, buffers)\n };\n this.target.postMessage(responseMessage, {transfer: buffers});\n } : (_) => {\n completed = true;\n };\n\n let callback: Cancelable = null;\n const params = deserialize(task.data);\n if (this.parent[task.type]) {\n // task.type == 'loadTile', 'removeTile', etc.\n callback = this.parent[task.type](task.sourceMapId, params, done);\n } else if ('getWorkerSource' in this.parent) {\n // task.type == sourcetype.method\n const keys = task.type.split('.');\n const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], (params as any).source);\n callback = scope[keys[1]](params, done);\n } else {\n // No function was found.\n done(new Error(`Could not find function ${task.type}`));\n }\n\n if (!completed && callback && callback.cancel) {\n // Allows canceling the task as long as it hasn't been completed yet.\n this.cancelCallbacks[id] = callback.cancel;\n }\n }\n }\n\n remove() {\n this.invoker.remove();\n this.target.removeEventListener('message', this.receive, false);\n }\n}\n","import {CircleStyleLayer} from './style_layer/circle_style_layer';\nimport {HeatmapStyleLayer} from './style_layer/heatmap_style_layer';\nimport {HillshadeStyleLayer} from './style_layer/hillshade_style_layer';\nimport {FillStyleLayer} from './style_layer/fill_style_layer';\nimport {FillExtrusionStyleLayer} from './style_layer/fill_extrusion_style_layer';\nimport {LineStyleLayer} from './style_layer/line_style_layer';\nimport {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport {BackgroundStyleLayer} from './style_layer/background_style_layer';\nimport {RasterStyleLayer} from './style_layer/raster_style_layer';\nimport {CustomStyleLayer, type CustomLayerInterface} from './style_layer/custom_style_layer';\n\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) {\n if (layer.type === 'custom') {\n return new CustomStyleLayer(layer);\n }\n switch (layer.type) {\n case 'background':\n return new BackgroundStyleLayer(layer);\n case 'circle':\n return new CircleStyleLayer(layer);\n case 'fill':\n return new FillStyleLayer(layer);\n case 'fill-extrusion':\n return new FillExtrusionStyleLayer(layer);\n case 'heatmap':\n return new HeatmapStyleLayer(layer);\n case 'hillshade':\n return new HillshadeStyleLayer(layer);\n case 'line':\n return new LineStyleLayer(layer);\n case 'raster':\n return new RasterStyleLayer(layer);\n case 'symbol':\n return new SymbolStyleLayer(layer);\n }\n}\n\n","import {StyleLayer} from './style_layer';\nimport {createStyleLayer} from './create_style_layer';\n\nimport {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {TypedStyleLayer} from './style_layer/typed_style_layer';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LayerConfigs = {[_: string]: LayerSpecification};\nexport type Family = Array;\n\nexport class StyleLayerIndex {\n familiesBySource: {\n [source: string]: {\n [sourceLayer: string]: Array>;\n };\n };\n keyCache: {[source: string]: string};\n\n _layerConfigs: LayerConfigs;\n _layers: {[_: string]: StyleLayer};\n\n constructor(layerConfigs?: Array | null) {\n this.keyCache = {};\n if (layerConfigs) {\n this.replace(layerConfigs);\n }\n }\n\n replace(layerConfigs: Array) {\n this._layerConfigs = {};\n this._layers = {};\n this.update(layerConfigs, []);\n }\n\n update(layerConfigs: Array, removedIds: Array) {\n for (const layerConfig of layerConfigs) {\n this._layerConfigs[layerConfig.id] = layerConfig;\n\n const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig);\n layer._featureFilter = featureFilter(layer.filter);\n if (this.keyCache[layerConfig.id])\n delete this.keyCache[layerConfig.id];\n }\n for (const id of removedIds) {\n delete this.keyCache[id];\n delete this._layerConfigs[id];\n delete this._layers[id];\n }\n\n this.familiesBySource = {};\n\n const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache);\n\n for (const layerConfigs of groups) {\n const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]);\n\n const layer = layers[0];\n if (layer.visibility === 'none') {\n continue;\n }\n\n const sourceId = layer.source || '';\n let sourceGroup = this.familiesBySource[sourceId];\n if (!sourceGroup) {\n sourceGroup = this.familiesBySource[sourceId] = {};\n }\n\n const sourceLayerId = layer.sourceLayer || '_geojsonTileLayer';\n let sourceLayerFamilies = sourceGroup[sourceLayerId];\n if (!sourceLayerFamilies) {\n sourceLayerFamilies = sourceGroup[sourceLayerId] = [];\n }\n\n sourceLayerFamilies.push(layers);\n }\n }\n}\n","import {AlphaImage} from '../util/image';\nimport {register} from '../util/web_worker_transfer';\nimport potpack from 'potpack';\n\nimport type {GlyphMetrics, StyleGlyph} from '../style/style_glyph';\n\nconst padding = 1;\n\n/**\n * A rectangle type with postion, width and height.\n */\nexport type Rect = {\n x: number;\n y: number;\n w: number;\n h: number;\n};\n\n/**\n * The glyph's position\n */\nexport type GlyphPosition = {\n rect: Rect;\n metrics: GlyphMetrics;\n};\n\n/**\n * The glyphs' positions\n */\nexport type GlyphPositions = {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n};\n\nexport class GlyphAtlas {\n image: AlphaImage;\n positions: GlyphPositions;\n\n constructor(stacks: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n }) {\n const positions = {};\n const bins = [];\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n const stackPositions = positions[stack] = {};\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n\n const bin = {\n x: 0,\n y: 0,\n w: src.bitmap.width + 2 * padding,\n h: src.bitmap.height + 2 * padding\n };\n bins.push(bin);\n stackPositions[id] = {rect: bin, metrics: src.metrics};\n }\n }\n\n const {w, h} = potpack(bins);\n const image = new AlphaImage({width: w || 1, height: h || 1});\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n const bin = positions[stack][id].rect;\n AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);\n }\n }\n\n this.image = image;\n this.positions = positions;\n }\n}\n\nregister('GlyphAtlas', GlyphAtlas);\n","import {FeatureIndex} from '../data/feature_index';\nimport {performSymbolLayout} from '../symbol/symbol_layout';\nimport {CollisionBoxArray} from '../data/array_types.g';\nimport {DictionaryCoder} from '../util/dictionary_coder';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {LineBucket} from '../data/bucket/line_bucket';\nimport {FillBucket} from '../data/bucket/fill_bucket';\nimport {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';\nimport {warnOnce, mapObject} from '../util/util';\nimport {ImageAtlas} from '../render/image_atlas';\nimport {GlyphAtlas} from '../render/glyph_atlas';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {OverscaledTileID} from './tile_id';\n\nimport type {Bucket} from '../data/bucket';\nimport type {Actor} from '../util/actor';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\nimport type {StyleImage} from '../style/style_image';\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {\n WorkerTileParameters,\n WorkerTileCallback,\n} from '../source/worker_source';\nimport type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {VectorTile} from '@mapbox/vector-tile';\nimport {Cancelable} from '../types/cancelable';\n\nexport class WorkerTile {\n tileID: OverscaledTileID;\n uid: string;\n zoom: number;\n pixelRatio: number;\n tileSize: number;\n source: string;\n promoteId: PromoteIdSpecification;\n overscaling: number;\n showCollisionBoxes: boolean;\n collectResourceTiming: boolean;\n returnDependencies: boolean;\n\n status: 'parsing' | 'done';\n data: VectorTile;\n collisionBoxArray: CollisionBoxArray;\n\n abort: (() => void);\n vectorTile: VectorTile;\n inFlightDependencies: Cancelable[];\n dependencySentinel: number;\n\n constructor(params: WorkerTileParameters) {\n this.tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y);\n this.uid = params.uid;\n this.zoom = params.zoom;\n this.pixelRatio = params.pixelRatio;\n this.tileSize = params.tileSize;\n this.source = params.source;\n this.overscaling = this.tileID.overscaleFactor();\n this.showCollisionBoxes = params.showCollisionBoxes;\n this.collectResourceTiming = !!params.collectResourceTiming;\n this.returnDependencies = !!params.returnDependencies;\n this.promoteId = params.promoteId;\n this.inFlightDependencies = [];\n this.dependencySentinel = -1;\n }\n\n parse(data: VectorTile, layerIndex: StyleLayerIndex, availableImages: Array, actor: Actor, callback: WorkerTileCallback) {\n this.status = 'parsing';\n this.data = data;\n\n this.collisionBoxArray = new CollisionBoxArray();\n const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort());\n\n const featureIndex = new FeatureIndex(this.tileID, this.promoteId);\n featureIndex.bucketLayerIDs = [];\n\n const buckets: {[_: string]: Bucket} = {};\n\n const options = {\n featureIndex,\n iconDependencies: {},\n patternDependencies: {},\n glyphDependencies: {},\n availableImages\n };\n\n const layerFamilies = layerIndex.familiesBySource[this.source];\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer = data.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n if (sourceLayer.version === 1) {\n warnOnce(`Vector tile source \"${this.source}\" layer \"${sourceLayerId}\" ` +\n 'does not use vector tile spec v2 and therefore may have some rendering errors.');\n }\n\n const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId);\n const features = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature = sourceLayer.feature(index);\n const id = featureIndex.getId(feature, sourceLayerId);\n features.push({feature, id, index, sourceLayerIndex});\n }\n\n for (const family of layerFamilies[sourceLayerId]) {\n const layer = family[0];\n\n if (layer.source !== this.source) {\n warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`);\n }\n if (layer.minzoom && this.zoom < Math.floor(layer.minzoom)) continue;\n if (layer.maxzoom && this.zoom >= layer.maxzoom) continue;\n if (layer.visibility === 'none') continue;\n\n recalculateLayers(family, this.zoom, availableImages);\n\n const bucket = buckets[layer.id] = layer.createBucket({\n index: featureIndex.bucketLayerIDs.length,\n layers: family,\n zoom: this.zoom,\n pixelRatio: this.pixelRatio,\n overscaling: this.overscaling,\n collisionBoxArray: this.collisionBoxArray,\n sourceLayerIndex,\n sourceID: this.source\n });\n\n bucket.populate(features, options, this.tileID.canonical);\n featureIndex.bucketLayerIDs.push(family.map((l) => l.id));\n }\n }\n\n let error: Error;\n let glyphMap: {\n [_: string]: {\n [_: number]: StyleGlyph;\n };\n };\n let iconMap: {[_: string]: StyleImage};\n let patternMap: {[_: string]: StyleImage};\n\n const stacks = mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number));\n\n this.inFlightDependencies.forEach((request) => request?.cancel());\n this.inFlightDependencies = [];\n\n // cancelling seems to be not sufficient, we seems to still manage to get a callback hit, so use a sentinel to drop stale results\n const dependencySentinel = ++this.dependencySentinel;\n if (Object.keys(stacks).length) {\n this.inFlightDependencies.push(actor.send('getGlyphs', {uid: this.uid, stacks, source: this.source, tileID: this.tileID, type: 'glyphs'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n glyphMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n glyphMap = {};\n }\n\n const icons = Object.keys(options.iconDependencies);\n if (icons.length) {\n this.inFlightDependencies.push(actor.send('getImages', {icons, source: this.source, tileID: this.tileID, type: 'icons'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n iconMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n iconMap = {};\n }\n\n const patterns = Object.keys(options.patternDependencies);\n if (patterns.length) {\n this.inFlightDependencies.push(actor.send('getImages', {icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns'}, (err, result) => {\n if (dependencySentinel !== this.dependencySentinel) {\n return;\n }\n if (!error) {\n error = err;\n patternMap = result;\n maybePrepare.call(this);\n }\n }));\n } else {\n patternMap = {};\n }\n\n maybePrepare.call(this);\n\n function maybePrepare() {\n if (error) {\n return callback(error);\n } else if (glyphMap && iconMap && patternMap) {\n const glyphAtlas = new GlyphAtlas(glyphMap);\n const imageAtlas = new ImageAtlas(iconMap, patternMap);\n\n for (const key in buckets) {\n const bucket = buckets[key];\n if (bucket instanceof SymbolBucket) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n performSymbolLayout({\n bucket,\n glyphMap,\n glyphPositions: glyphAtlas.positions,\n imageMap: iconMap,\n imagePositions: imageAtlas.iconPositions,\n showCollisionBoxes: this.showCollisionBoxes,\n canonical: this.tileID.canonical\n });\n } else if (bucket.hasPattern &&\n (bucket instanceof LineBucket ||\n bucket instanceof FillBucket ||\n bucket instanceof FillExtrusionBucket)) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions);\n }\n }\n\n this.status = 'done';\n callback(null, {\n buckets: Object.values(buckets).filter(b => !b.isEmpty()),\n featureIndex,\n collisionBoxArray: this.collisionBoxArray,\n glyphAtlasImage: glyphAtlas.image,\n imageAtlas,\n // Only used for benchmarking:\n glyphMap: this.returnDependencies ? glyphMap : null,\n iconMap: this.returnDependencies ? iconMap : null,\n glyphPositions: this.returnDependencies ? glyphAtlas.positions : null\n });\n }\n }\n }\n}\n\nfunction recalculateLayers(layers: ReadonlyArray, zoom: number, availableImages: Array) {\n // Layers are shared and may have been used by a WorkerTile with a different zoom.\n const parameters = new EvaluationParameters(zoom);\n for (const layer of layers) {\n layer.recalculate(parameters, availableImages);\n }\n}\n","import {ExpiryData, getArrayBuffer} from '../util/ajax';\n\nimport vt from '@mapbox/vector-tile';\nimport Protobuf from 'pbf';\nimport {WorkerTile} from './worker_tile';\nimport {extend} from '../util/util';\nimport {RequestPerformance} from '../util/performance';\n\nimport type {\n WorkerSource,\n WorkerTileParameters,\n WorkerTileCallback,\n TileParameters\n} from '../source/worker_source';\n\nimport type {Actor} from '../util/actor';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\nimport type {Callback} from '../types/callback';\nimport type {VectorTile} from '@mapbox/vector-tile';\n\nexport type LoadVectorTileResult = {\n vectorTile: VectorTile;\n rawData: ArrayBuffer;\n resourceTiming?: Array;\n} & ExpiryData;\n\ntype FetchingState = {\n rawTileData: ArrayBuffer;\n cacheControl: ExpiryData;\n resourceTiming: any;\n}\n\n/**\n * The callback when finished loading vector data\n */\nexport type LoadVectorDataCallback = Callback;\n\nexport type AbortVectorData = () => void;\nexport type LoadVectorData = (params: WorkerTileParameters, callback: LoadVectorDataCallback) => AbortVectorData | void;\n\n/**\n * Loads a vector tile\n */\nfunction loadVectorTile(params: WorkerTileParameters, callback: LoadVectorDataCallback) {\n const request = getArrayBuffer(params.request, (err?: Error | null, data?: ArrayBuffer | null, cacheControl?: string | null, expires?: string | null) => {\n if (err) {\n callback(err);\n } else if (data) {\n try {\n const vectorTile = new vt.VectorTile(new Protobuf(data));\n callback(null, {\n vectorTile,\n rawData: data,\n cacheControl,\n expires\n });\n } catch (ex) {\n const bytes = new Uint8Array(data);\n const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;\n let errorMessage = `Unable to parse the tile at ${params.request.url}, `;\n if (isGzipped) {\n errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';\n } else {\n errorMessage += `got error: ${ex.messge}`;\n }\n callback(new Error(errorMessage));\n }\n }\n });\n return () => {\n request.cancel();\n callback();\n };\n}\n\n/**\n * The {@link WorkerSource} implementation that supports {@link VectorTileSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory VectorTile\n * representation. To do so, create it with\n * `new VectorTileWorkerSource(actor, styleLayers, customLoadVectorDataFunction)`.\n */\nexport class VectorTileWorkerSource implements WorkerSource {\n actor: Actor;\n layerIndex: StyleLayerIndex;\n availableImages: Array;\n loadVectorData: LoadVectorData;\n fetching: {[_: string]: FetchingState };\n loading: {[_: string]: WorkerTile};\n loaded: {[_: string]: WorkerTile};\n\n /**\n * @param loadVectorData - Optional method for custom loading of a VectorTile\n * object based on parameters passed from the main-thread Source. See\n * {@link VectorTileWorkerSource#loadTile}. The default implementation simply\n * loads the pbf at `params.url`.\n */\n constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadVectorData?: LoadVectorData | null) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.loadVectorData = loadVectorData || loadVectorTile;\n this.fetching = {};\n this.loading = {};\n this.loaded = {};\n }\n\n /**\n * Implements {@link WorkerSource#loadTile}. Delegates to\n * {@link VectorTileWorkerSource#loadVectorData} (which by default expects\n * a `params.url` property) for fetching and producing a VectorTile object.\n */\n loadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const uid = params.uid;\n\n if (!this.loading)\n this.loading = {};\n\n const perf = (params && params.request && params.request.collectResourceTiming) ?\n new RequestPerformance(params.request) : false;\n\n const workerTile = this.loading[uid] = new WorkerTile(params);\n workerTile.abort = this.loadVectorData(params, (err, response) => {\n delete this.loading[uid];\n\n if (err || !response) {\n workerTile.status = 'done';\n this.loaded[uid] = workerTile;\n return callback(err);\n }\n\n const rawTileData = response.rawData;\n const cacheControl = {} as ExpiryData;\n if (response.expires) cacheControl.expires = response.expires;\n if (response.cacheControl) cacheControl.cacheControl = response.cacheControl;\n\n const resourceTiming = {} as {resourceTiming: any};\n if (perf) {\n const resourceTimingData = perf.finish();\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n if (resourceTimingData)\n resourceTiming.resourceTiming = JSON.parse(JSON.stringify(resourceTimingData));\n }\n\n workerTile.vectorTile = response.vectorTile;\n workerTile.parse(response.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => {\n delete this.fetching[uid];\n if (err || !result) return callback(err);\n\n // Transferring a copy of rawTileData because the worker needs to retain its copy.\n callback(null, extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming));\n });\n\n this.loaded = this.loaded || {};\n this.loaded[uid] = workerTile;\n // keep the original fetching state so that reload tile can pick it up if the original parse is cancelled by reloads' parse\n this.fetching[uid] = {rawTileData, cacheControl, resourceTiming};\n }) as AbortVectorData;\n }\n\n /**\n * Implements {@link WorkerSource#reloadTile}.\n */\n reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded;\n const uid = params.uid;\n if (loaded && loaded[uid]) {\n const workerTile = loaded[uid];\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n if (workerTile.status === 'parsing') {\n workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => {\n if (err || !result) return callback(err, result);\n\n // if we have cancelled the original parse, make sure to pass the rawTileData from the original fetch\n let parseResult;\n if (this.fetching[uid]) {\n const {rawTileData, cacheControl, resourceTiming} = this.fetching[uid];\n delete this.fetching[uid];\n parseResult = extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming);\n } else {\n parseResult = result;\n }\n\n callback(null, parseResult);\n });\n } else if (workerTile.status === 'done') {\n // if there was no vector tile data on the initial load, don't try and re-parse tile\n if (workerTile.vectorTile) {\n workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, callback);\n } else {\n callback();\n }\n }\n }\n }\n\n /**\n * Implements {@link WorkerSource#abortTile}.\n *\n * @param params - The tile parameters\n * @param callback - The callback\n */\n abortTile(params: TileParameters, callback: WorkerTileCallback) {\n const loading = this.loading,\n uid = params.uid;\n if (loading && loading[uid] && loading[uid].abort) {\n loading[uid].abort();\n delete loading[uid];\n }\n callback();\n }\n\n /**\n * Implements {@link WorkerSource#removeTile}.\n *\n * @param params - The tile parameters\n * @param callback - The callback\n */\n removeTile(params: TileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded && loaded[uid]) {\n delete loaded[uid];\n }\n callback();\n }\n}\n","import {DEMData} from '../data/dem_data';\nimport {RGBAImage} from '../util/image';\nimport type {Actor} from '../util/actor';\nimport type {\n WorkerDEMTileParameters,\n WorkerDEMTileCallback,\n TileParameters\n} from './worker_source';\nimport {getImageData, isImageBitmap} from '../util/util';\n\nexport class RasterDEMTileWorkerSource {\n actor: Actor;\n loaded: {[_: string]: DEMData};\n\n constructor() {\n this.loaded = {};\n }\n\n async loadTile(params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) {\n const {uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift} = params;\n const width = rawImageData.width + 2;\n const height = rawImageData.height + 2;\n const imagePixels: RGBAImage = isImageBitmap(rawImageData) ?\n new RGBAImage({width, height}, await getImageData(rawImageData, -1, -1, width, height)) :\n rawImageData;\n const dem = new DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);\n this.loaded = this.loaded || {};\n this.loaded[uid] = dem;\n callback(null, dem);\n }\n\n removeTile(params: TileParameters) {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded && loaded[uid]) {\n delete loaded[uid];\n }\n }\n}\n","\nmodule.exports = rewind;\n\nfunction rewind(gj, outer) {\n var type = gj && gj.type, i;\n\n if (type === 'FeatureCollection') {\n for (i = 0; i < gj.features.length; i++) rewind(gj.features[i], outer);\n\n } else if (type === 'GeometryCollection') {\n for (i = 0; i < gj.geometries.length; i++) rewind(gj.geometries[i], outer);\n\n } else if (type === 'Feature') {\n rewind(gj.geometry, outer);\n\n } else if (type === 'Polygon') {\n rewindRings(gj.coordinates, outer);\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < gj.coordinates.length; i++) rewindRings(gj.coordinates[i], outer);\n }\n\n return gj;\n}\n\nfunction rewindRings(rings, outer) {\n if (rings.length === 0) return;\n\n rewindRing(rings[0], outer);\n for (var i = 1; i < rings.length; i++) {\n rewindRing(rings[i], !outer);\n }\n}\n\nfunction rewindRing(ring, dir) {\n var area = 0, err = 0;\n for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {\n var k = (ring[i][0] - ring[j][0]) * (ring[j][1] + ring[i][1]);\n var m = area + k;\n err += Math.abs(area) >= Math.abs(k) ? area - m + k : k - m + area;\n area = m;\n }\n if (area + err >= 0 !== !!dir) ring.reverse();\n}\n","import Point from '@mapbox/point-geometry';\n\nimport mvt from '@mapbox/vector-tile';\nimport type {VectorTileFeature, VectorTileLayer, VectorTile} from '@mapbox/vector-tile';\nconst toGeoJSON = mvt.VectorTileFeature.prototype.toGeoJSON;\nimport {EXTENT} from '../data/extent';\nimport type {TileFeature, AnyProps} from 'supercluster';\nimport type {Feature as GeoJSONVTFeature} from 'geojson-vt';\n\nexport type Feature = TileFeature | GeoJSONVTFeature;\n\nclass FeatureWrapper implements VectorTileFeature {\n _feature: Feature;\n\n extent: number;\n type: Feature['type'];\n id: number;\n properties: {[_: string]: string | number | boolean};\n\n constructor(feature: Feature) {\n this._feature = feature;\n\n this.extent = EXTENT;\n this.type = feature.type;\n this.properties = feature.tags;\n\n // If the feature has a top-level `id` property, copy it over, but only\n // if it can be coerced to an integer, because this wrapper is used for\n // serializing geojson feature data into vector tile PBF data, and the\n // vector tile spec only supports integer values for feature ids --\n // allowing non-integer values here results in a non-compliant PBF\n // that causes an exception when it is parsed with vector-tile-js\n if ('id' in feature && !isNaN(feature.id as any)) {\n this.id = parseInt(feature.id, 10);\n }\n }\n\n loadGeometry() {\n if (this._feature.type === 1) {\n const geometry = [];\n for (const point of this._feature.geometry) {\n geometry.push([new Point(point[0], point[1])]);\n }\n return geometry;\n } else {\n const geometry = [];\n for (const ring of this._feature.geometry) {\n const newRing = [];\n for (const point of ring) {\n newRing.push(new Point(point[0], point[1]));\n }\n geometry.push(newRing);\n }\n return geometry;\n }\n }\n\n toGeoJSON(x: number, y: number, z: number) {\n return toGeoJSON.call(this, x, y, z);\n }\n}\n\nexport class GeoJSONWrapper implements VectorTile, VectorTileLayer {\n layers: {[_: string]: VectorTileLayer};\n name: string;\n extent: number;\n length: number;\n _features: Array;\n\n constructor(features: Array) {\n this.layers = {'_geojsonTileLayer': this};\n this.name = '_geojsonTileLayer';\n this.extent = EXTENT;\n this.length = features.length;\n this._features = features;\n }\n\n feature(i: number): VectorTileFeature {\n return new FeatureWrapper(this._features[i]);\n }\n}\n","'use strict'\n\nvar Point = require('@mapbox/point-geometry')\nvar VectorTileFeature = require('@mapbox/vector-tile').VectorTileFeature\n\nmodule.exports = GeoJSONWrapper\n\n// conform to vectortile api\nfunction GeoJSONWrapper (features, options) {\n this.options = options || {}\n this.features = features\n this.length = features.length\n}\n\nGeoJSONWrapper.prototype.feature = function (i) {\n return new FeatureWrapper(this.features[i], this.options.extent)\n}\n\nfunction FeatureWrapper (feature, extent) {\n this.id = typeof feature.id === 'number' ? feature.id : undefined\n this.type = feature.type\n this.rawGeometry = feature.type === 1 ? [feature.geometry] : feature.geometry\n this.properties = feature.tags\n this.extent = extent || 4096\n}\n\nFeatureWrapper.prototype.loadGeometry = function () {\n var rings = this.rawGeometry\n this.geometry = []\n\n for (var i = 0; i < rings.length; i++) {\n var ring = rings[i]\n var newRing = []\n for (var j = 0; j < ring.length; j++) {\n newRing.push(new Point(ring[j][0], ring[j][1]))\n }\n this.geometry.push(newRing)\n }\n return this.geometry\n}\n\nFeatureWrapper.prototype.bbox = function () {\n if (!this.geometry) this.loadGeometry()\n\n var rings = this.geometry\n var x1 = Infinity\n var x2 = -Infinity\n var y1 = Infinity\n var y2 = -Infinity\n\n for (var i = 0; i < rings.length; i++) {\n var ring = rings[i]\n\n for (var j = 0; j < ring.length; j++) {\n var coord = ring[j]\n\n x1 = Math.min(x1, coord.x)\n x2 = Math.max(x2, coord.x)\n y1 = Math.min(y1, coord.y)\n y2 = Math.max(y2, coord.y)\n }\n }\n\n return [x1, y1, x2, y2]\n}\n\nFeatureWrapper.prototype.toGeoJSON = VectorTileFeature.prototype.toGeoJSON\n","var Pbf = require('pbf')\nvar GeoJSONWrapper = require('./lib/geojson_wrapper')\n\nmodule.exports = fromVectorTileJs\nmodule.exports.fromVectorTileJs = fromVectorTileJs\nmodule.exports.fromGeojsonVt = fromGeojsonVt\nmodule.exports.GeoJSONWrapper = GeoJSONWrapper\n\n/**\n * Serialize a vector-tile-js-created tile to pbf\n *\n * @param {Object} tile\n * @return {Buffer} uncompressed, pbf-serialized tile data\n */\nfunction fromVectorTileJs (tile) {\n var out = new Pbf()\n writeTile(tile, out)\n return out.finish()\n}\n\n/**\n * Serialized a geojson-vt-created tile to pbf.\n *\n * @param {Object} layers - An object mapping layer names to geojson-vt-created vector tile objects\n * @param {Object} [options] - An object specifying the vector-tile specification version and extent that were used to create `layers`.\n * @param {Number} [options.version=1] - Version of vector-tile spec used\n * @param {Number} [options.extent=4096] - Extent of the vector tile\n * @return {Buffer} uncompressed, pbf-serialized tile data\n */\nfunction fromGeojsonVt (layers, options) {\n options = options || {}\n var l = {}\n for (var k in layers) {\n l[k] = new GeoJSONWrapper(layers[k].features, options)\n l[k].name = k\n l[k].version = options.version\n l[k].extent = options.extent\n }\n return fromVectorTileJs({ layers: l })\n}\n\nfunction writeTile (tile, pbf) {\n for (var key in tile.layers) {\n pbf.writeMessage(3, writeLayer, tile.layers[key])\n }\n}\n\nfunction writeLayer (layer, pbf) {\n pbf.writeVarintField(15, layer.version || 1)\n pbf.writeStringField(1, layer.name || '')\n pbf.writeVarintField(5, layer.extent || 4096)\n\n var i\n var context = {\n keys: [],\n values: [],\n keycache: {},\n valuecache: {}\n }\n\n for (i = 0; i < layer.length; i++) {\n context.feature = layer.feature(i)\n pbf.writeMessage(2, writeFeature, context)\n }\n\n var keys = context.keys\n for (i = 0; i < keys.length; i++) {\n pbf.writeStringField(3, keys[i])\n }\n\n var values = context.values\n for (i = 0; i < values.length; i++) {\n pbf.writeMessage(4, writeValue, values[i])\n }\n}\n\nfunction writeFeature (context, pbf) {\n var feature = context.feature\n\n if (feature.id !== undefined) {\n pbf.writeVarintField(1, feature.id)\n }\n\n pbf.writeMessage(2, writeProperties, context)\n pbf.writeVarintField(3, feature.type)\n pbf.writeMessage(4, writeGeometry, feature)\n}\n\nfunction writeProperties (context, pbf) {\n var feature = context.feature\n var keys = context.keys\n var values = context.values\n var keycache = context.keycache\n var valuecache = context.valuecache\n\n for (var key in feature.properties) {\n var value = feature.properties[key]\n\n var keyIndex = keycache[key]\n if (value === null) continue // don't encode null value properties\n\n if (typeof keyIndex === 'undefined') {\n keys.push(key)\n keyIndex = keys.length - 1\n keycache[key] = keyIndex\n }\n pbf.writeVarint(keyIndex)\n\n var type = typeof value\n if (type !== 'string' && type !== 'boolean' && type !== 'number') {\n value = JSON.stringify(value)\n }\n var valueKey = type + ':' + value\n var valueIndex = valuecache[valueKey]\n if (typeof valueIndex === 'undefined') {\n values.push(value)\n valueIndex = values.length - 1\n valuecache[valueKey] = valueIndex\n }\n pbf.writeVarint(valueIndex)\n }\n}\n\nfunction command (cmd, length) {\n return (length << 3) + (cmd & 0x7)\n}\n\nfunction zigzag (num) {\n return (num << 1) ^ (num >> 31)\n}\n\nfunction writeGeometry (feature, pbf) {\n var geometry = feature.loadGeometry()\n var type = feature.type\n var x = 0\n var y = 0\n var rings = geometry.length\n for (var r = 0; r < rings; r++) {\n var ring = geometry[r]\n var count = 1\n if (type === 1) {\n count = ring.length\n }\n pbf.writeVarint(command(1, count)) // moveto\n // do not write polygon closing path as lineto\n var lineCount = type === 3 ? ring.length - 1 : ring.length\n for (var i = 0; i < lineCount; i++) {\n if (i === 1 && type !== 1) {\n pbf.writeVarint(command(2, lineCount - 1)) // lineto\n }\n var dx = ring[i].x - x\n var dy = ring[i].y - y\n pbf.writeVarint(zigzag(dx))\n pbf.writeVarint(zigzag(dy))\n x += dx\n y += dy\n }\n if (type === 3) {\n pbf.writeVarint(command(7, 1)) // closepath\n }\n }\n}\n\nfunction writeValue (value, pbf) {\n var type = typeof value\n if (type === 'string') {\n pbf.writeStringField(1, value)\n } else if (type === 'boolean') {\n pbf.writeBooleanField(7, value)\n } else if (type === 'number') {\n if (value % 1 !== 0) {\n pbf.writeDoubleField(3, value)\n } else if (value < 0) {\n pbf.writeSVarintField(6, value)\n } else {\n pbf.writeVarintField(5, value)\n }\n }\n}\n","\nimport KDBush from 'kdbush';\n\nconst defaultOptions = {\n minZoom: 0, // min zoom to generate clusters on\n maxZoom: 16, // max zoom level to cluster the points on\n minPoints: 2, // minimum points to form a cluster\n radius: 40, // cluster radius in pixels\n extent: 512, // tile extent (radius is calculated relative to it)\n nodeSize: 64, // size of the KD-tree leaf node, affects performance\n log: false, // whether to log timing info\n\n // whether to generate numeric ids for input features (in vector tiles)\n generateId: false,\n\n // a reduce function for calculating custom cluster properties\n reduce: null, // (accumulated, props) => { accumulated.sum += props.sum; }\n\n // properties to use for individual points when running the reducer\n map: props => props // props => ({sum: props.my_value})\n};\n\nconst fround = Math.fround || (tmp => ((x) => { tmp[0] = +x; return tmp[0]; }))(new Float32Array(1));\n\nconst OFFSET_ZOOM = 2;\nconst OFFSET_ID = 3;\nconst OFFSET_PARENT = 4;\nconst OFFSET_NUM = 5;\nconst OFFSET_PROP = 6;\n\nexport default class Supercluster {\n constructor(options) {\n this.options = Object.assign(Object.create(defaultOptions), options);\n this.trees = new Array(this.options.maxZoom + 1);\n this.stride = this.options.reduce ? 7 : 6;\n this.clusterProps = [];\n }\n\n load(points) {\n const {log, minZoom, maxZoom} = this.options;\n\n if (log) console.time('total time');\n\n const timerId = `prepare ${ points.length } points`;\n if (log) console.time(timerId);\n\n this.points = points;\n\n // generate a cluster object for each point and index input points into a KD-tree\n const data = [];\n\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n if (!p.geometry) continue;\n\n const [lng, lat] = p.geometry.coordinates;\n const x = fround(lngX(lng));\n const y = fround(latY(lat));\n // store internal point/cluster data in flat numeric arrays for performance\n data.push(\n x, y, // projected point coordinates\n Infinity, // the last zoom the point was processed at\n i, // index of the source feature in the original input array\n -1, // parent cluster id\n 1 // number of points in a cluster\n );\n if (this.options.reduce) data.push(0); // noop\n }\n let tree = this.trees[maxZoom + 1] = this._createTree(data);\n\n if (log) console.timeEnd(timerId);\n\n // cluster points on max zoom, then cluster the results on previous zoom, etc.;\n // results in a cluster hierarchy across zoom levels\n for (let z = maxZoom; z >= minZoom; z--) {\n const now = +Date.now();\n\n // create a new set of clusters for the zoom and index them with a KD-tree\n tree = this.trees[z] = this._createTree(this._cluster(tree, z));\n\n if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, +Date.now() - now);\n }\n\n if (log) console.timeEnd('total time');\n\n return this;\n }\n\n getClusters(bbox, zoom) {\n let minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180;\n const minLat = Math.max(-90, Math.min(90, bbox[1]));\n let maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180;\n const maxLat = Math.max(-90, Math.min(90, bbox[3]));\n\n if (bbox[2] - bbox[0] >= 360) {\n minLng = -180;\n maxLng = 180;\n } else if (minLng > maxLng) {\n const easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom);\n const westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom);\n return easternHem.concat(westernHem);\n }\n\n const tree = this.trees[this._limitZoom(zoom)];\n const ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat));\n const data = tree.data;\n const clusters = [];\n for (const id of ids) {\n const k = this.stride * id;\n clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n return clusters;\n }\n\n getChildren(clusterId) {\n const originId = this._getOriginId(clusterId);\n const originZoom = this._getOriginZoom(clusterId);\n const errorMsg = 'No cluster with the specified id.';\n\n const tree = this.trees[originZoom];\n if (!tree) throw new Error(errorMsg);\n\n const data = tree.data;\n if (originId * this.stride >= data.length) throw new Error(errorMsg);\n\n const r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1));\n const x = data[originId * this.stride];\n const y = data[originId * this.stride + 1];\n const ids = tree.within(x, y, r);\n const children = [];\n for (const id of ids) {\n const k = id * this.stride;\n if (data[k + OFFSET_PARENT] === clusterId) {\n children.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n }\n\n if (children.length === 0) throw new Error(errorMsg);\n\n return children;\n }\n\n getLeaves(clusterId, limit, offset) {\n limit = limit || 10;\n offset = offset || 0;\n\n const leaves = [];\n this._appendLeaves(leaves, clusterId, limit, offset, 0);\n\n return leaves;\n }\n\n getTile(z, x, y) {\n const tree = this.trees[this._limitZoom(z)];\n const z2 = Math.pow(2, z);\n const {extent, radius} = this.options;\n const p = radius / extent;\n const top = (y - p) / z2;\n const bottom = (y + 1 + p) / z2;\n\n const tile = {\n features: []\n };\n\n this._addTileFeatures(\n tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom),\n tree.data, x, y, z2, tile);\n\n if (x === 0) {\n this._addTileFeatures(\n tree.range(1 - p / z2, top, 1, bottom),\n tree.data, z2, y, z2, tile);\n }\n if (x === z2 - 1) {\n this._addTileFeatures(\n tree.range(0, top, p / z2, bottom),\n tree.data, -1, y, z2, tile);\n }\n\n return tile.features.length ? tile : null;\n }\n\n getClusterExpansionZoom(clusterId) {\n let expansionZoom = this._getOriginZoom(clusterId) - 1;\n while (expansionZoom <= this.options.maxZoom) {\n const children = this.getChildren(clusterId);\n expansionZoom++;\n if (children.length !== 1) break;\n clusterId = children[0].properties.cluster_id;\n }\n return expansionZoom;\n }\n\n _appendLeaves(result, clusterId, limit, offset, skipped) {\n const children = this.getChildren(clusterId);\n\n for (const child of children) {\n const props = child.properties;\n\n if (props && props.cluster) {\n if (skipped + props.point_count <= offset) {\n // skip the whole cluster\n skipped += props.point_count;\n } else {\n // enter the cluster\n skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped);\n // exit the cluster\n }\n } else if (skipped < offset) {\n // skip a single point\n skipped++;\n } else {\n // add a single point\n result.push(child);\n }\n if (result.length === limit) break;\n }\n\n return skipped;\n }\n\n _createTree(data) {\n const tree = new KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array);\n for (let i = 0; i < data.length; i += this.stride) tree.add(data[i], data[i + 1]);\n tree.finish();\n tree.data = data;\n return tree;\n }\n\n _addTileFeatures(ids, data, x, y, z2, tile) {\n for (const i of ids) {\n const k = i * this.stride;\n const isCluster = data[k + OFFSET_NUM] > 1;\n\n let tags, px, py;\n if (isCluster) {\n tags = getClusterProperties(data, k, this.clusterProps);\n px = data[k];\n py = data[k + 1];\n } else {\n const p = this.points[data[k + OFFSET_ID]];\n tags = p.properties;\n const [lng, lat] = p.geometry.coordinates;\n px = lngX(lng);\n py = latY(lat);\n }\n\n const f = {\n type: 1,\n geometry: [[\n Math.round(this.options.extent * (px * z2 - x)),\n Math.round(this.options.extent * (py * z2 - y))\n ]],\n tags\n };\n\n // assign id\n let id;\n if (isCluster || this.options.generateId) {\n // optionally generate id for points\n id = data[k + OFFSET_ID];\n } else {\n // keep id if already assigned\n id = this.points[data[k + OFFSET_ID]].id;\n }\n\n if (id !== undefined) f.id = id;\n\n tile.features.push(f);\n }\n }\n\n _limitZoom(z) {\n return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1));\n }\n\n _cluster(tree, zoom) {\n const {radius, extent, reduce, minPoints} = this.options;\n const r = radius / (extent * Math.pow(2, zoom));\n const data = tree.data;\n const nextData = [];\n const stride = this.stride;\n\n // loop through each point\n for (let i = 0; i < data.length; i += stride) {\n // if we've already visited the point at this zoom level, skip it\n if (data[i + OFFSET_ZOOM] <= zoom) continue;\n data[i + OFFSET_ZOOM] = zoom;\n\n // find all nearby points\n const x = data[i];\n const y = data[i + 1];\n const neighborIds = tree.within(data[i], data[i + 1], r);\n\n const numPointsOrigin = data[i + OFFSET_NUM];\n let numPoints = numPointsOrigin;\n\n // count the number of points in a potential cluster\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n // filter out neighbors that are already processed\n if (data[k + OFFSET_ZOOM] > zoom) numPoints += data[k + OFFSET_NUM];\n }\n\n // if there were neighbors to merge, and there are enough points to form a cluster\n if (numPoints > numPointsOrigin && numPoints >= minPoints) {\n let wx = x * numPointsOrigin;\n let wy = y * numPointsOrigin;\n\n let clusterProperties;\n let clusterPropIndex = -1;\n\n // encode both zoom and point index on which the cluster originated -- offset by total length of features\n const id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length;\n\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice)\n\n const numPoints2 = data[k + OFFSET_NUM];\n wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center\n wy += data[k + 1] * numPoints2;\n\n data[k + OFFSET_PARENT] = id;\n\n if (reduce) {\n if (!clusterProperties) {\n clusterProperties = this._map(data, i, true);\n clusterPropIndex = this.clusterProps.length;\n this.clusterProps.push(clusterProperties);\n }\n reduce(clusterProperties, this._map(data, k));\n }\n }\n\n data[i + OFFSET_PARENT] = id;\n nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints);\n if (reduce) nextData.push(clusterPropIndex);\n\n } else { // left points as unclustered\n for (let j = 0; j < stride; j++) nextData.push(data[i + j]);\n\n if (numPoints > 1) {\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom;\n for (let j = 0; j < stride; j++) nextData.push(data[k + j]);\n }\n }\n }\n }\n\n return nextData;\n }\n\n // get index of the point from which the cluster originated\n _getOriginId(clusterId) {\n return (clusterId - this.points.length) >> 5;\n }\n\n // get zoom of the point from which the cluster originated\n _getOriginZoom(clusterId) {\n return (clusterId - this.points.length) % 32;\n }\n\n _map(data, i, clone) {\n if (data[i + OFFSET_NUM] > 1) {\n const props = this.clusterProps[data[i + OFFSET_PROP]];\n return clone ? Object.assign({}, props) : props;\n }\n const original = this.points[data[i + OFFSET_ID]].properties;\n const result = this.options.map(original);\n return clone && result === original ? Object.assign({}, result) : result;\n }\n}\n\nfunction getClusterJSON(data, i, clusterProps) {\n return {\n type: 'Feature',\n id: data[i + OFFSET_ID],\n properties: getClusterProperties(data, i, clusterProps),\n geometry: {\n type: 'Point',\n coordinates: [xLng(data[i]), yLat(data[i + 1])]\n }\n };\n}\n\nfunction getClusterProperties(data, i, clusterProps) {\n const count = data[i + OFFSET_NUM];\n const abbrev =\n count >= 10000 ? `${Math.round(count / 1000) }k` :\n count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count;\n const propIndex = data[i + OFFSET_PROP];\n const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]);\n return Object.assign(properties, {\n cluster: true,\n cluster_id: data[i + OFFSET_ID],\n point_count: count,\n point_count_abbreviated: abbrev\n });\n}\n\n// longitude/latitude to spherical mercator in [0..1] range\nfunction lngX(lng) {\n return lng / 360 + 0.5;\n}\nfunction latY(lat) {\n const sin = Math.sin(lat * Math.PI / 180);\n const y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);\n return y < 0 ? 0 : y > 1 ? 1 : y;\n}\n\n// spherical mercator to longitude/latitude\nfunction xLng(x) {\n return (x - 0.5) * 360;\n}\nfunction yLat(y) {\n const y2 = (180 - y * 360) * Math.PI / 180;\n return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90;\n}\n","\n// calculate simplification data using optimized Douglas-Peucker algorithm\n\nexport default function simplify(coords, first, last, sqTolerance) {\n var maxSqDist = sqTolerance;\n var mid = (last - first) >> 1;\n var minPosToMid = last - first;\n var index;\n\n var ax = coords[first];\n var ay = coords[first + 1];\n var bx = coords[last];\n var by = coords[last + 1];\n\n for (var i = first + 3; i < last; i += 3) {\n var d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n\n } else if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n var posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n\n if (maxSqDist > sqTolerance) {\n if (index - first > 3) simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3) simplify(coords, index, last, sqTolerance);\n }\n}\n\n// square distance from a point to a segment\nfunction getSqSegDist(px, py, x, y, bx, by) {\n\n var dx = bx - x;\n var dy = by - y;\n\n if (dx !== 0 || dy !== 0) {\n\n var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n\n if (t > 1) {\n x = bx;\n y = by;\n\n } else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n\n dx = px - x;\n dy = py - y;\n\n return dx * dx + dy * dy;\n}\n","\nexport default function createFeature(id, type, geom, tags) {\n var feature = {\n id: typeof id === 'undefined' ? null : id,\n type: type,\n geometry: geom,\n tags: tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n calcBBox(feature);\n return feature;\n}\n\nfunction calcBBox(feature) {\n var geom = feature.geometry;\n var type = feature.type;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n\n } else if (type === 'Polygon' || type === 'MultiLineString') {\n for (var i = 0; i < geom.length; i++) {\n calcLineBBox(feature, geom[i]);\n }\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < geom.length; i++) {\n for (var j = 0; j < geom[i].length; j++) {\n calcLineBBox(feature, geom[i][j]);\n }\n }\n }\n}\n\nfunction calcLineBBox(feature, geom) {\n for (var i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n","\nimport simplify from './simplify';\nimport createFeature from './feature';\n\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\n\nexport default function convert(data, options) {\n var features = [];\n if (data.type === 'FeatureCollection') {\n for (var i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n\n } else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n\n } else {\n // single geometry or a geometry collection\n convertFeature(features, {geometry: data}, options);\n }\n\n return features;\n}\n\nfunction convertFeature(features, geojson, options, index) {\n if (!geojson.geometry) return;\n\n var coords = geojson.geometry.coordinates;\n var type = geojson.geometry.type;\n var tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n var geometry = [];\n var id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n } else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n\n } else if (type === 'MultiPoint') {\n for (var i = 0; i < coords.length; i++) {\n convertPoint(coords[i], geometry);\n }\n\n } else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n\n } else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (i = 0; i < coords.length; i++) {\n geometry = [];\n convertLine(coords[i], geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n } else {\n convertLines(coords, geometry, tolerance, false);\n }\n\n } else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n\n } else if (type === 'MultiPolygon') {\n for (i = 0; i < coords.length; i++) {\n var polygon = [];\n convertLines(coords[i], polygon, tolerance, true);\n geometry.push(polygon);\n }\n } else if (type === 'GeometryCollection') {\n for (i = 0; i < geojson.geometry.geometries.length; i++) {\n convertFeature(features, {\n id: id,\n geometry: geojson.geometry.geometries[i],\n properties: geojson.properties\n }, options, index);\n }\n return;\n } else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\n\nfunction convertPoint(coords, out) {\n out.push(projectX(coords[0]));\n out.push(projectY(coords[1]));\n out.push(0);\n}\n\nfunction convertLine(ring, out, tolerance, isPolygon) {\n var x0, y0;\n var size = 0;\n\n for (var j = 0; j < ring.length; j++) {\n var x = projectX(ring[j][0]);\n var y = projectY(ring[j][1]);\n\n out.push(x);\n out.push(y);\n out.push(0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n var last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings, out, tolerance, isPolygon) {\n for (var i = 0; i < rings.length; i++) {\n var geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\nfunction projectX(x) {\n return x / 360 + 0.5;\n}\n\nfunction projectY(y) {\n var sin = Math.sin(y * Math.PI / 180);\n var y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n","\nimport createFeature from './feature';\n\n/* clip features between two axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n */\n\nexport default function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {\n\n k1 /= scale;\n k2 /= scale;\n\n if (minAll >= k1 && maxAll < k2) return features; // trivial accept\n else if (maxAll < k1 || minAll >= k2) return null; // trivial reject\n\n var clipped = [];\n\n for (var i = 0; i < features.length; i++) {\n\n var feature = features[i];\n var geometry = feature.geometry;\n var type = feature.type;\n\n var min = axis === 0 ? feature.minX : feature.minY;\n var max = axis === 0 ? feature.maxX : feature.maxY;\n\n if (min >= k1 && max < k2) { // trivial accept\n clipped.push(feature);\n continue;\n } else if (max < k1 || min >= k2) { // trivial reject\n continue;\n }\n\n var newGeometry = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n clipPoints(geometry, newGeometry, k1, k2, axis);\n\n } else if (type === 'LineString') {\n clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);\n\n } else if (type === 'MultiLineString') {\n clipLines(geometry, newGeometry, k1, k2, axis, false);\n\n } else if (type === 'Polygon') {\n clipLines(geometry, newGeometry, k1, k2, axis, true);\n\n } else if (type === 'MultiPolygon') {\n for (var j = 0; j < geometry.length; j++) {\n var polygon = [];\n clipLines(geometry[j], polygon, k1, k2, axis, true);\n if (polygon.length) {\n newGeometry.push(polygon);\n }\n }\n }\n\n if (newGeometry.length) {\n if (options.lineMetrics && type === 'LineString') {\n for (j = 0; j < newGeometry.length; j++) {\n clipped.push(createFeature(feature.id, type, newGeometry[j], feature.tags));\n }\n continue;\n }\n\n if (type === 'LineString' || type === 'MultiLineString') {\n if (newGeometry.length === 1) {\n type = 'LineString';\n newGeometry = newGeometry[0];\n } else {\n type = 'MultiLineString';\n }\n }\n if (type === 'Point' || type === 'MultiPoint') {\n type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';\n }\n\n clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n }\n\n return clipped.length ? clipped : null;\n}\n\nfunction clipPoints(geom, newGeom, k1, k2, axis) {\n for (var i = 0; i < geom.length; i += 3) {\n var a = geom[i + axis];\n\n if (a >= k1 && a <= k2) {\n newGeom.push(geom[i]);\n newGeom.push(geom[i + 1]);\n newGeom.push(geom[i + 2]);\n }\n }\n}\n\nfunction clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {\n\n var slice = newSlice(geom);\n var intersect = axis === 0 ? intersectX : intersectY;\n var len = geom.start;\n var segLen, t;\n\n for (var i = 0; i < geom.length - 3; i += 3) {\n var ax = geom[i];\n var ay = geom[i + 1];\n var az = geom[i + 2];\n var bx = geom[i + 3];\n var by = geom[i + 4];\n var a = axis === 0 ? ax : ay;\n var b = axis === 0 ? bx : by;\n var exited = false;\n\n if (trackMetrics) segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n\n if (a < k1) {\n // ---|--> | (line enters the clip region from the left)\n if (b > k1) {\n t = intersect(slice, ax, ay, bx, by, k1);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else if (a > k2) {\n // | <--|--- (line enters the clip region from the right)\n if (b < k2) {\n t = intersect(slice, ax, ay, bx, by, k2);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else {\n addPoint(slice, ax, ay, az);\n }\n if (b < k1 && a >= k1) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, k1);\n exited = true;\n }\n if (b > k2 && a <= k2) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, k2);\n exited = true;\n }\n\n if (!isPolygon && exited) {\n if (trackMetrics) slice.end = len + segLen * t;\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n\n if (trackMetrics) len += segLen;\n }\n\n // add the last point\n var last = geom.length - 3;\n ax = geom[last];\n ay = geom[last + 1];\n az = geom[last + 2];\n a = axis === 0 ? ax : ay;\n if (a >= k1 && a <= k2) addPoint(slice, ax, ay, az);\n\n // close the polygon if its endpoints are not the same after clipping\n last = slice.length - 3;\n if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {\n addPoint(slice, slice[0], slice[1], slice[2]);\n }\n\n // add the final slice\n if (slice.length) {\n newGeom.push(slice);\n }\n}\n\nfunction newSlice(line) {\n var slice = [];\n slice.size = line.size;\n slice.start = line.start;\n slice.end = line.end;\n return slice;\n}\n\nfunction clipLines(geom, newGeom, k1, k2, axis, isPolygon) {\n for (var i = 0; i < geom.length; i++) {\n clipLine(geom[i], newGeom, k1, k2, axis, isPolygon, false);\n }\n}\n\nfunction addPoint(out, x, y, z) {\n out.push(x);\n out.push(y);\n out.push(z);\n}\n\nfunction intersectX(out, ax, ay, bx, by, x) {\n var t = (x - ax) / (bx - ax);\n out.push(x);\n out.push(ay + (by - ay) * t);\n out.push(1);\n return t;\n}\n\nfunction intersectY(out, ax, ay, bx, by, y) {\n var t = (y - ay) / (by - ay);\n out.push(ax + (bx - ax) * t);\n out.push(y);\n out.push(1);\n return t;\n}\n","\nimport clip from './clip';\nimport createFeature from './feature';\n\nexport default function wrap(features, options) {\n var buffer = options.buffer / options.extent;\n var merged = features;\n var left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy\n var right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy\n\n if (left || right) {\n merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy\n\n if (left) merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n if (right) merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n }\n\n return merged;\n}\n\nfunction shiftFeatureCoords(features, offset) {\n var newFeatures = [];\n\n for (var i = 0; i < features.length; i++) {\n var feature = features[i],\n type = feature.type;\n\n var newGeometry;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n newGeometry = shiftCoords(feature.geometry, offset);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n newGeometry = [];\n for (var j = 0; j < feature.geometry.length; j++) {\n newGeometry.push(shiftCoords(feature.geometry[j], offset));\n }\n } else if (type === 'MultiPolygon') {\n newGeometry = [];\n for (j = 0; j < feature.geometry.length; j++) {\n var newPolygon = [];\n for (var k = 0; k < feature.geometry[j].length; k++) {\n newPolygon.push(shiftCoords(feature.geometry[j][k], offset));\n }\n newGeometry.push(newPolygon);\n }\n }\n\n newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n\n return newFeatures;\n}\n\nfunction shiftCoords(points, offset) {\n var newPoints = [];\n newPoints.size = points.size;\n\n if (points.start !== undefined) {\n newPoints.start = points.start;\n newPoints.end = points.end;\n }\n\n for (var i = 0; i < points.length; i += 3) {\n newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);\n }\n return newPoints;\n}\n","\n// Transforms the coordinates of each feature in the given tile from\n// mercator-projected space into (extent x extent) tile space.\nexport default function transformTile(tile, extent) {\n if (tile.transformed) return tile;\n\n var z2 = 1 << tile.z,\n tx = tile.x,\n ty = tile.y,\n i, j, k;\n\n for (i = 0; i < tile.features.length; i++) {\n var feature = tile.features[i],\n geom = feature.geometry,\n type = feature.type;\n\n feature.geometry = [];\n\n if (type === 1) {\n for (j = 0; j < geom.length; j += 2) {\n feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));\n }\n } else {\n for (j = 0; j < geom.length; j++) {\n var ring = [];\n for (k = 0; k < geom[j].length; k += 2) {\n ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));\n }\n feature.geometry.push(ring);\n }\n }\n }\n\n tile.transformed = true;\n\n return tile;\n}\n\nfunction transformPoint(x, y, extent, z2, tx, ty) {\n return [\n Math.round(extent * (x * z2 - tx)),\n Math.round(extent * (y * z2 - ty))];\n}\n","\nexport default function createTile(features, z, tx, ty, options) {\n var tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n var tile = {\n features: [],\n numPoints: 0,\n numSimplified: 0,\n numFeatures: 0,\n source: null,\n x: tx,\n y: ty,\n z: z,\n transformed: false,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0\n };\n for (var i = 0; i < features.length; i++) {\n tile.numFeatures++;\n addFeature(tile, features[i], tolerance, options);\n\n var minX = features[i].minX;\n var minY = features[i].minY;\n var maxX = features[i].maxX;\n var maxY = features[i].maxY;\n\n if (minX < tile.minX) tile.minX = minX;\n if (minY < tile.minY) tile.minY = minY;\n if (maxX > tile.maxX) tile.maxX = maxX;\n if (maxY > tile.maxY) tile.maxY = maxY;\n }\n return tile;\n}\n\nfunction addFeature(tile, feature, tolerance, options) {\n\n var geom = feature.geometry,\n type = feature.type,\n simplified = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n for (var i = 0; i < geom.length; i += 3) {\n simplified.push(geom[i]);\n simplified.push(geom[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n\n } else if (type === 'LineString') {\n addLine(simplified, geom, tile, tolerance, false, false);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n for (i = 0; i < geom.length; i++) {\n addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);\n }\n\n } else if (type === 'MultiPolygon') {\n\n for (var k = 0; k < geom.length; k++) {\n var polygon = geom[k];\n for (i = 0; i < polygon.length; i++) {\n addLine(simplified, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n }\n\n if (simplified.length) {\n var tags = feature.tags || null;\n if (type === 'LineString' && options.lineMetrics) {\n tags = {};\n for (var key in feature.tags) tags[key] = feature.tags[key];\n tags['mapbox_clip_start'] = geom.start / geom.size;\n tags['mapbox_clip_end'] = geom.end / geom.size;\n }\n var tileFeature = {\n geometry: simplified,\n type: type === 'Polygon' || type === 'MultiPolygon' ? 3 :\n type === 'LineString' || type === 'MultiLineString' ? 2 : 1,\n tags: tags\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n }\n}\n\nfunction addLine(result, geom, tile, tolerance, isPolygon, isOuter) {\n var sqTolerance = tolerance * tolerance;\n\n if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) {\n tile.numPoints += geom.length / 3;\n return;\n }\n\n var ring = [];\n\n for (var i = 0; i < geom.length; i += 3) {\n if (tolerance === 0 || geom[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom[i]);\n ring.push(geom[i + 1]);\n }\n tile.numPoints++;\n }\n\n if (isPolygon) rewind(ring, isOuter);\n\n result.push(ring);\n}\n\nfunction rewind(ring, clockwise) {\n var area = 0;\n for (var i = 0, len = ring.length, j = len - 2; i < len; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n if (area > 0 === clockwise) {\n for (i = 0, len = ring.length; i < len / 2; i += 2) {\n var x = ring[i];\n var y = ring[i + 1];\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n }\n}\n","\nimport convert from './convert'; // GeoJSON conversion and preprocessing\nimport clip from './clip'; // stripe clipping algorithm\nimport wrap from './wrap'; // date line processing\nimport transform from './transform'; // coordinate transformation\nimport createTile from './tile'; // final simplified tile generation\n\nexport default function geojsonvt(data, options) {\n return new GeoJSONVT(data, options);\n}\n\nfunction GeoJSONVT(data, options) {\n options = this.options = extend(Object.create(this.options), options);\n\n var debug = options.debug;\n\n if (debug) console.time('preprocess data');\n\n if (options.maxZoom < 0 || options.maxZoom > 24) throw new Error('maxZoom should be in the 0-24 range');\n if (options.promoteId && options.generateId) throw new Error('promoteId and generateId cannot be used together.');\n\n var features = convert(data, options);\n\n this.tiles = {};\n this.tileCoords = [];\n\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n this.stats = {};\n this.total = 0;\n }\n\n features = wrap(features, options);\n\n // start slicing from the top tile down\n if (features.length) this.splitTile(features, 0, 0, 0);\n\n if (debug) {\n if (features.length) console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n}\n\nGeoJSONVT.prototype.options = {\n maxZoom: 14, // max zoom to preserve detail on\n indexMaxZoom: 5, // max zoom in the tile index\n indexMaxPoints: 100000, // max number of points per tile in the tile index\n tolerance: 3, // simplification tolerance (higher means simpler)\n extent: 4096, // tile extent\n buffer: 64, // tile buffer on each side\n lineMetrics: false, // whether to calculate line metrics\n promoteId: null, // name of a feature property to be promoted to feature.id\n generateId: false, // whether to generate feature ids. Cannot be used with promoteId\n debug: 0 // logging level (0, 1 or 2)\n};\n\nGeoJSONVT.prototype.splitTile = function (features, z, x, y, cz, cx, cy) {\n\n var stack = [features, z, x, y],\n options = this.options,\n debug = options.debug;\n\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop();\n x = stack.pop();\n z = stack.pop();\n features = stack.pop();\n\n var z2 = 1 << z,\n id = toID(z, x, y),\n tile = this.tiles[id];\n\n if (!tile) {\n if (debug > 1) console.time('creation');\n\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({z: z, x: x, y: y});\n\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)',\n z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n var key = 'z' + z;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n\n // if it's the first-pass tiling\n if (!cz) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;\n\n // if a drilldown to a specific tile\n } else {\n // stop tiling if we reached base zoom or our target tile zoom\n if (z === options.maxZoom || z === cz) continue;\n\n // stop tiling if it's not an ancestor of the target tile\n var m = 1 << (cz - z);\n if (x !== Math.floor(cx / m) || y !== Math.floor(cy / m)) continue;\n }\n\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n\n if (features.length === 0) continue;\n\n if (debug > 1) console.time('clipping');\n\n // values we'll use for clipping\n var k1 = 0.5 * options.buffer / options.extent,\n k2 = 0.5 - k1,\n k3 = 0.5 + k1,\n k4 = 1 + k1,\n tl, bl, tr, br, left, right;\n\n tl = bl = tr = br = null;\n\n left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);\n right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);\n features = null;\n\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n left = null;\n }\n\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n right = null;\n }\n\n if (debug > 1) console.timeEnd('clipping');\n\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n};\n\nGeoJSONVT.prototype.getTile = function (z, x, y) {\n var options = this.options,\n extent = options.extent,\n debug = options.debug;\n\n if (z < 0 || z > 24) return null;\n\n var z2 = 1 << z;\n x = ((x % z2) + z2) % z2; // wrap tile x coordinate\n\n var id = toID(z, x, y);\n if (this.tiles[id]) return transform(this.tiles[id], extent);\n\n if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y);\n\n var z0 = z,\n x0 = x,\n y0 = y,\n parent;\n\n while (!parent && z0 > 0) {\n z0--;\n x0 = Math.floor(x0 / 2);\n y0 = Math.floor(y0 / 2);\n parent = this.tiles[toID(z0, x0, y0)];\n }\n\n if (!parent || !parent.source) return null;\n\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n\n if (debug > 1) console.time('drilling down');\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) console.timeEnd('drilling down');\n\n return this.tiles[id] ? transform(this.tiles[id], extent) : null;\n};\n\nfunction toID(z, x, y) {\n return (((1 << z) * y + x) * 32) + z;\n}\n\nfunction extend(dest, src) {\n for (var i in src) dest[i] = src[i];\n return dest;\n}\n","/**\n * A way to indentify a feature, either by string or by number\n */\nexport type GeoJSONFeatureId = number | string;\n\n/**\n * The geojson source diff object\n */\nexport type GeoJSONSourceDiff = {\n /**\n * When set to `true` it will remove all features\n */\n removeAll?: boolean;\n /**\n * An array of features IDs to remove\n */\n remove?: Array;\n /**\n * An array of features to add\n */\n add?: Array;\n /**\n * An array of update objects\n */\n update?: Array;\n}\n\n/**\n * A geojson feature diff object\n */\nexport type GeoJSONFeatureDiff = {\n /**\n * The feature ID\n */\n id: GeoJSONFeatureId;\n /**\n * If it's a new geometry, place it here\n */\n newGeometry?: GeoJSON.Geometry;\n /**\n * Setting to `true` will remove all preperties\n */\n removeAllProperties?: boolean;\n /**\n * The properties keys to remove\n */\n removeProperties?: Array;\n /**\n * The properties to add or update along side their values\n */\n addOrUpdateProperties?: Array<{key: string; value: any}>;\n}\n\nexport type UpdateableGeoJSON = GeoJSON.Feature | GeoJSON.FeatureCollection | undefined;\n\nfunction getFeatureId(feature: GeoJSON.Feature, promoteId?: string): GeoJSONFeatureId | undefined {\n return promoteId ? feature.properties[promoteId] : feature.id;\n}\n\nexport function isUpdateableGeoJSON(data: GeoJSON.GeoJSON | undefined, promoteId?: string): data is UpdateableGeoJSON {\n // null can be updated\n if (data == null) {\n return true;\n }\n\n // a single feature with an id can be updated, need to explicitly check against null because 0 is a valid feature id that is falsy\n if (data.type === 'Feature') {\n return getFeatureId(data, promoteId) != null;\n }\n\n // a feature collection can be updated if every feature has an id, and the ids are all unique\n // this prevents us from silently dropping features if ids get reused\n if (data.type === 'FeatureCollection') {\n const seenIds = new Set();\n for (const feature of data.features) {\n const id = getFeatureId(feature, promoteId);\n if (id == null) {\n return false;\n }\n\n if (seenIds.has(id)) {\n return false;\n }\n\n seenIds.add(id);\n }\n\n return true;\n }\n\n return false;\n}\n\nexport function toUpdateable(data: UpdateableGeoJSON, promoteId?: string) {\n const result = new Map();\n if (data == null) {\n // empty result\n } else if (data.type === 'Feature') {\n result.set(getFeatureId(data, promoteId)!, data);\n } else {\n for (const feature of data.features) {\n result.set(getFeatureId(feature, promoteId)!, feature);\n }\n }\n\n return result;\n}\n\n// mutates updateable\nexport function applySourceDiff(updateable: Map, diff: GeoJSONSourceDiff, promoteId?: string): void {\n if (diff.removeAll) {\n updateable.clear();\n }\n\n if (diff.remove) {\n for (const id of diff.remove) {\n updateable.delete(id);\n }\n }\n\n if (diff.add) {\n for (const feature of diff.add) {\n const id = getFeatureId(feature, promoteId);\n\n if (id != null) {\n updateable.set(id, feature);\n }\n }\n }\n\n if (diff.update) {\n for (const update of diff.update) {\n let feature = updateable.get(update.id);\n\n if (feature == null) {\n continue;\n }\n\n // be careful to clone the feature and/or properties objects to avoid mutating our input\n const cloneFeature = update.newGeometry || update.removeAllProperties;\n // note: removeAllProperties gives us a new properties object, so we can skip the clone step\n const cloneProperties = !update.removeAllProperties && (update.removeProperties?.length > 0 || update.addOrUpdateProperties?.length > 0);\n if (cloneFeature || cloneProperties) {\n feature = {...feature};\n updateable.set(update.id, feature);\n if (cloneProperties) {\n feature.properties = {...feature.properties};\n }\n }\n\n if (update.newGeometry) {\n feature.geometry = update.newGeometry;\n }\n\n if (update.removeAllProperties) {\n feature.properties = {};\n } else if (update.removeProperties?.length > 0) {\n for (const prop of update.removeProperties) {\n if (Object.prototype.hasOwnProperty.call(feature.properties, prop)) {\n delete feature.properties[prop];\n }\n }\n }\n\n if (update.addOrUpdateProperties?.length > 0) {\n for (const {key, value} of update.addOrUpdateProperties) {\n feature.properties[key] = value;\n }\n }\n }\n }\n}\n","import {getJSON} from '../util/ajax';\n\nimport {RequestPerformance} from '../util/performance';\nimport rewind from '@mapbox/geojson-rewind';\nimport {GeoJSONWrapper} from './geojson_wrapper';\nimport vtpbf from 'vt-pbf';\nimport Supercluster, {type Options as SuperclusterOptions, type ClusterProperties} from 'supercluster';\nimport geojsonvt, {type Options as GeoJSONVTOptions} from 'geojson-vt';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source';\nimport {createExpression} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {\n WorkerTileParameters,\n WorkerTileCallback,\n} from '../source/worker_source';\n\nimport type {Actor} from '../util/actor';\nimport type {StyleLayerIndex} from '../style/style_layer_index';\n\nimport type {LoadVectorDataCallback} from './vector_tile_worker_source';\nimport type {RequestParameters, ResponseCallback} from '../util/ajax';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport {isUpdateableGeoJSON, type GeoJSONSourceDiff, applySourceDiff, toUpdateable, GeoJSONFeatureId} from './geojson_source_diff';\n\nexport type LoadGeoJSONParameters = {\n request?: RequestParameters;\n /**\n * Literal GeoJSON data. Must be provided if `request.url` is not.\n */\n data?: string;\n dataDiff?: GeoJSONSourceDiff;\n source: string;\n cluster: boolean;\n superclusterOptions?: SuperclusterOptions;\n geojsonVtOptions?: GeoJSONVTOptions;\n clusterProperties?: ClusterProperties;\n filter?: Array;\n promoteId?: string;\n};\n\nexport type LoadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback) => Cancelable;\n\ntype GeoJSONIndex = ReturnType | Supercluster;\n\n/**\n * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory GeoJSON\n * representation. To do so, create it with\n * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.\n * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).\n */\nexport class GeoJSONWorkerSource extends VectorTileWorkerSource {\n _pendingCallback: Callback<{\n resourceTiming?: {[_: string]: Array};\n abandoned?: boolean;\n }>;\n _pendingRequest: Cancelable;\n _geoJSONIndex: GeoJSONIndex;\n _dataUpdateable = new Map();\n\n /**\n * @param loadGeoJSON - Optional method for custom loading/parsing of\n * GeoJSON based on parameters passed from the main-thread Source.\n * See {@link GeoJSONWorkerSource#loadGeoJSON}.\n */\n constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadGeoJSON?: LoadGeoJSON | null) {\n super(actor, layerIndex, availableImages);\n this.loadVectorData = this.loadGeoJSONTile;\n if (loadGeoJSON) {\n this.loadGeoJSON = loadGeoJSON;\n }\n }\n\n loadGeoJSONTile(params: WorkerTileParameters, callback: LoadVectorDataCallback): (() => void) | void {\n const canonical = params.tileID.canonical;\n\n if (!this._geoJSONIndex) {\n return callback(null, null); // we couldn't load the file\n }\n\n const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);\n if (!geoJSONTile) {\n return callback(null, null); // nothing in the given tile\n }\n\n const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features);\n // Encode the geojson-vt tile into binary vector tile form. This\n // is a convenience that allows `FeatureIndex` to operate the same way\n // across `VectorTileSource` and `GeoJSONSource` data.\n let pbf = vtpbf(geojsonWrapper);\n if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {\n // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)\n pbf = new Uint8Array(pbf);\n }\n\n callback(null, {\n vectorTile: geojsonWrapper,\n rawData: pbf.buffer\n });\n }\n\n /**\n * Fetches (if appropriate), parses, and index geojson data into tiles. This\n * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}\n * can correctly serve up tiles.\n *\n * Defers to {@link GeoJSONWorkerSource#loadGeoJSON} for the fetching/parsing,\n * expecting `callback(error, data)` to be called with either an error or a\n * parsed GeoJSON object.\n *\n * When a `loadData` request comes in while a previous one is being processed,\n * the previous one is aborted.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n */\n loadData(params: LoadGeoJSONParameters, callback: Callback<{\n resourceTiming?: {[_: string]: Array};\n abandoned?: boolean;\n }>) {\n this._pendingRequest?.cancel();\n if (this._pendingCallback) {\n // Tell the foreground the previous call has been abandoned\n this._pendingCallback(null, {abandoned: true});\n }\n\n const perf = (params && params.request && params.request.collectResourceTiming) ?\n new RequestPerformance(params.request) : false;\n\n this._pendingCallback = callback;\n this._pendingRequest = this.loadGeoJSON(params, (err?: Error | null, data?: any | null) => {\n delete this._pendingCallback;\n delete this._pendingRequest;\n\n if (err || !data) {\n return callback(err);\n } else if (typeof data !== 'object') {\n return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n } else {\n rewind(data, true);\n\n try {\n if (params.filter) {\n const compiled = createExpression(params.filter, {type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false} as any);\n if (compiled.result === 'error')\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n\n const features = data.features.filter(feature => compiled.value.evaluate({zoom: 0}, feature));\n data = {type: 'FeatureCollection', features};\n }\n\n this._geoJSONIndex = params.cluster ?\n new Supercluster(getSuperclusterOptions(params)).load(data.features) :\n geojsonvt(data, params.geojsonVtOptions);\n } catch (err) {\n return callback(err);\n }\n\n this.loaded = {};\n\n const result = {} as { resourceTiming: any };\n if (perf) {\n const resourceTimingData = perf.finish();\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n if (resourceTimingData) {\n result.resourceTiming = {};\n result.resourceTiming[params.source] = JSON.parse(JSON.stringify(resourceTimingData));\n }\n }\n callback(null, result);\n }\n });\n }\n\n /**\n * Implements {@link WorkerSource#reloadTile}.\n *\n * If the tile is loaded, uses the implementation in VectorTileWorkerSource.\n * Otherwise, such as after a setData() call, we load the tile fresh.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n */\n reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {\n const loaded = this.loaded,\n uid = params.uid;\n\n if (loaded && loaded[uid]) {\n return super.reloadTile(params, callback);\n } else {\n return this.loadTile(params, callback);\n }\n }\n\n /**\n * Fetch and parse GeoJSON according to the given params. Calls `callback`\n * with `(err, data)`, where `data` is a parsed GeoJSON object.\n *\n * GeoJSON is loaded and parsed from `params.url` if it exists, or else\n * expected as a literal (string or object) `params.data`.\n *\n * @param params - the parameters\n * @param callback - the callback for completion or error\n * @returns A Cancelable object.\n */\n loadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback): Cancelable => {\n const {promoteId} = params;\n // Because of same origin issues, urls must either include an explicit\n // origin or absolute path.\n // ie: /foo/bar.json or http://example.com/bar.json\n // but not ../foo/bar.json\n if (params.request) {\n return getJSON(params.request, (\n error?: Error,\n data?: any,\n cacheControl?: string,\n expires?: string\n ) => {\n this._dataUpdateable = isUpdateableGeoJSON(data, promoteId) ? toUpdateable(data, promoteId) : undefined;\n callback(error, data, cacheControl, expires);\n });\n } else if (typeof params.data === 'string') {\n try {\n const parsed = JSON.parse(params.data);\n this._dataUpdateable = isUpdateableGeoJSON(parsed, promoteId) ? toUpdateable(parsed, promoteId) : undefined;\n callback(null, parsed);\n } catch (e) {\n callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n }\n } else if (params.dataDiff) {\n if (this._dataUpdateable) {\n applySourceDiff(this._dataUpdateable, params.dataDiff, promoteId);\n callback(null, {type: 'FeatureCollection', features: Array.from(this._dataUpdateable.values())});\n } else {\n callback(new Error(`Cannot update existing geojson data in ${params.source}`));\n }\n } else {\n callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`));\n }\n\n return {cancel: () => {}};\n };\n\n removeSource(params: {\n source: string;\n }, callback: WorkerTileCallback) {\n if (this._pendingCallback) {\n // Don't leak callbacks\n this._pendingCallback(null, {abandoned: true});\n }\n callback();\n }\n\n getClusterExpansionZoom(params: {\n clusterId: number;\n }, callback: Callback) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getClusterExpansionZoom(params.clusterId));\n } catch (e) {\n callback(e);\n }\n }\n\n getClusterChildren(params: {\n clusterId: number;\n }, callback: Callback>) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getChildren(params.clusterId));\n } catch (e) {\n callback(e);\n }\n }\n\n getClusterLeaves(params: {\n clusterId: number;\n limit: number;\n offset: number;\n }, callback: Callback>) {\n try {\n callback(null, (this._geoJSONIndex as Supercluster).getLeaves(params.clusterId, params.limit, params.offset));\n } catch (e) {\n callback(e);\n }\n }\n}\n\nfunction getSuperclusterOptions({superclusterOptions, clusterProperties}: LoadGeoJSONParameters) {\n if (!clusterProperties || !superclusterOptions) return superclusterOptions;\n\n const mapExpressions = {};\n const reduceExpressions = {};\n const globals = {accumulated: null, zoom: 0};\n const feature = {properties: null};\n const propertyNames = Object.keys(clusterProperties);\n\n for (const key of propertyNames) {\n const [operator, mapExpression] = clusterProperties[key];\n\n const mapExpressionParsed = createExpression(mapExpression);\n const reduceExpressionParsed = createExpression(\n typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator);\n\n mapExpressions[key] = mapExpressionParsed.value;\n reduceExpressions[key] = reduceExpressionParsed.value;\n }\n\n superclusterOptions.map = (pointProperties) => {\n feature.properties = pointProperties;\n const properties = {};\n for (const key of propertyNames) {\n properties[key] = mapExpressions[key].evaluate(globals, feature);\n }\n return properties;\n };\n superclusterOptions.reduce = (accumulated, clusterProperties) => {\n feature.properties = clusterProperties;\n for (const key of propertyNames) {\n globals.accumulated = accumulated[key];\n accumulated[key] = reduceExpressions[key].evaluate(globals, feature);\n }\n };\n\n return superclusterOptions;\n}\n","import {Actor, ActorTarget} from '../util/actor';\nimport {StyleLayerIndex} from '../style/style_layer_index';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source';\nimport {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source';\nimport {GeoJSONWorkerSource} from './geojson_worker_source';\nimport {plugin as globalRTLTextPlugin} from './rtl_text_plugin';\nimport {isWorker} from '../util/util';\n\nimport type {\n WorkerSource,\n WorkerTileParameters,\n WorkerDEMTileParameters,\n WorkerTileCallback,\n WorkerDEMTileCallback,\n TileParameters\n} from '../source/worker_source';\n\nimport type {WorkerGlobalScopeInterface} from '../util/web_worker';\nimport type {Callback} from '../types/callback';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {PluginState} from './rtl_text_plugin';\n\n/**\n * The Worker class responsidble for background thread related execution\n */\nexport default class Worker {\n self: WorkerGlobalScopeInterface & ActorTarget;\n actor: Actor;\n layerIndexes: {[_: string]: StyleLayerIndex};\n availableImages: {[_: string]: Array};\n workerSourceTypes: {\n [_: string]: {\n new (...args: any): WorkerSource;\n };\n };\n workerSources: {\n [_: string]: {\n [_: string]: {\n [_: string]: WorkerSource;\n };\n };\n };\n demWorkerSources: {\n [_: string]: {\n [_: string]: RasterDEMTileWorkerSource;\n };\n };\n referrer: string;\n\n constructor(self: WorkerGlobalScopeInterface & ActorTarget) {\n this.self = self;\n this.actor = new Actor(self, this);\n\n this.layerIndexes = {};\n this.availableImages = {};\n\n this.workerSourceTypes = {\n vector: VectorTileWorkerSource,\n geojson: GeoJSONWorkerSource\n };\n\n // [mapId][sourceType][sourceName] => worker source instance\n this.workerSources = {};\n this.demWorkerSources = {};\n\n this.self.registerWorkerSource = (name: string, WorkerSource: {\n new (...args: any): WorkerSource;\n }) => {\n if (this.workerSourceTypes[name]) {\n throw new Error(`Worker source with name \"${name}\" already registered.`);\n }\n this.workerSourceTypes[name] = WorkerSource;\n };\n\n // This is invoked by the RTL text plugin when the download via the `importScripts` call has finished, and the code has been parsed.\n this.self.registerRTLTextPlugin = (rtlTextPlugin: {\n applyArabicShaping: Function;\n processBidirectionalText: ((b: string, a: Array) => Array);\n processStyledBidirectionalText?: ((c: string, b: Array, a: Array) => Array<[string, Array]>);\n }) => {\n if (globalRTLTextPlugin.isParsed()) {\n throw new Error('RTL text plugin already registered.');\n }\n globalRTLTextPlugin['applyArabicShaping'] = rtlTextPlugin.applyArabicShaping;\n globalRTLTextPlugin['processBidirectionalText'] = rtlTextPlugin.processBidirectionalText;\n globalRTLTextPlugin['processStyledBidirectionalText'] = rtlTextPlugin.processStyledBidirectionalText;\n };\n }\n\n setReferrer(mapID: string, referrer: string) {\n this.referrer = referrer;\n }\n\n setImages(mapId: string, images: Array, callback: WorkerTileCallback) {\n this.availableImages[mapId] = images;\n for (const workerSource in this.workerSources[mapId]) {\n const ws = this.workerSources[mapId][workerSource];\n for (const source in ws) {\n ws[source].availableImages = images;\n }\n }\n callback();\n }\n\n setLayers(mapId: string, layers: Array, callback: WorkerTileCallback) {\n this.getLayerIndex(mapId).replace(layers);\n callback();\n }\n\n updateLayers(mapId: string, params: {\n layers: Array;\n removedIds: Array;\n }, callback: WorkerTileCallback) {\n this.getLayerIndex(mapId).update(params.layers, params.removedIds);\n callback();\n }\n\n loadTile(mapId: string, params: WorkerTileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).loadTile(params, callback);\n }\n\n loadDEMTile(mapId: string, params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) {\n this.getDEMWorkerSource(mapId, params.source).loadTile(params, callback);\n }\n\n reloadTile(mapId: string, params: WorkerTileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).reloadTile(params, callback);\n }\n\n abortTile(mapId: string, params: TileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).abortTile(params, callback);\n }\n\n removeTile(mapId: string, params: TileParameters & {\n type: string;\n }, callback: WorkerTileCallback) {\n this.getWorkerSource(mapId, params.type, params.source).removeTile(params, callback);\n }\n\n removeDEMTile(mapId: string, params: TileParameters) {\n this.getDEMWorkerSource(mapId, params.source).removeTile(params);\n }\n\n removeSource(mapId: string, params: {\n source: string;\n } & {\n type: string;\n }, callback: WorkerTileCallback) {\n\n if (!this.workerSources[mapId] ||\n !this.workerSources[mapId][params.type] ||\n !this.workerSources[mapId][params.type][params.source]) {\n return;\n }\n\n const worker = this.workerSources[mapId][params.type][params.source];\n delete this.workerSources[mapId][params.type][params.source];\n\n if (worker.removeSource !== undefined) {\n worker.removeSource(params, callback);\n } else {\n callback();\n }\n }\n\n /**\n * Load a {@link WorkerSource} script at params.url. The script is run\n * (using importScripts) with `registerWorkerSource` in scope, which is a\n * function taking `(name, workerSourceObject)`.\n */\n loadWorkerSource(map: string, params: {\n url: string;\n }, callback: Callback) {\n try {\n this.self.importScripts(params.url);\n callback();\n } catch (e) {\n callback(e.toString());\n }\n }\n\n syncRTLPluginState(map: string, state: PluginState, callback: Callback) {\n try {\n globalRTLTextPlugin.setState(state);\n const pluginURL = globalRTLTextPlugin.getPluginURL();\n if (\n globalRTLTextPlugin.isLoaded() &&\n !globalRTLTextPlugin.isParsed() &&\n pluginURL != null // Not possible when `isLoaded` is true, but keeps flow happy\n ) {\n this.self.importScripts(pluginURL);\n const complete = globalRTLTextPlugin.isParsed();\n const error = complete ? undefined : new Error(`RTL Text Plugin failed to import scripts from ${pluginURL}`);\n callback(error, complete);\n }\n } catch (e) {\n callback(e.toString());\n }\n }\n\n getAvailableImages(mapId: string) {\n let availableImages = this.availableImages[mapId];\n\n if (!availableImages) {\n availableImages = [];\n }\n\n return availableImages;\n }\n\n getLayerIndex(mapId: string) {\n let layerIndexes = this.layerIndexes[mapId];\n if (!layerIndexes) {\n layerIndexes = this.layerIndexes[mapId] = new StyleLayerIndex();\n }\n return layerIndexes;\n }\n\n getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource {\n if (!this.workerSources[mapId])\n this.workerSources[mapId] = {};\n if (!this.workerSources[mapId][sourceType])\n this.workerSources[mapId][sourceType] = {};\n\n if (!this.workerSources[mapId][sourceType][sourceName]) {\n // use a wrapped actor so that we can attach a target mapId param\n // to any messages invoked by the WorkerSource\n const actor = {\n send: (type, data, callback) => {\n this.actor.send(type, data, callback, mapId);\n }\n };\n this.workerSources[mapId][sourceType][sourceName] = new (this.workerSourceTypes[sourceType] as any)((actor as any), this.getLayerIndex(mapId), this.getAvailableImages(mapId));\n }\n\n return this.workerSources[mapId][sourceType][sourceName];\n }\n\n getDEMWorkerSource(mapId: string, source: string) {\n if (!this.demWorkerSources[mapId])\n this.demWorkerSources[mapId] = {};\n\n if (!this.demWorkerSources[mapId][source]) {\n this.demWorkerSources[mapId][source] = new RasterDEMTileWorkerSource();\n }\n\n return this.demWorkerSources[mapId][source];\n }\n}\n\nif (isWorker()) {\n (self as any).worker = new Worker(self as any);\n}\n","import Point from '@mapbox/point-geometry';\n\nexport class DOM {\n private static readonly docStyle = typeof window !== 'undefined' && window.document && window.document.documentElement.style;\n\n private static userSelect: string;\n\n private static selectProp = DOM.testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);\n\n private static transformProp = DOM.testProp(['transform', 'WebkitTransform']);\n\n private static testProp(props: string[]): string {\n if (!DOM.docStyle) return props[0];\n for (let i = 0; i < props.length; i++) {\n if (props[i] in DOM.docStyle) {\n return props[i];\n }\n }\n return props[0];\n }\n\n public static create(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K] {\n const el = window.document.createElement(tagName);\n if (className !== undefined) el.className = className;\n if (container) container.appendChild(el);\n return el;\n }\n\n public static createNS(namespaceURI: string, tagName: string) {\n const el = window.document.createElementNS(namespaceURI, tagName);\n return el;\n }\n\n public static disableDrag() {\n if (DOM.docStyle && DOM.selectProp) {\n DOM.userSelect = DOM.docStyle[DOM.selectProp];\n DOM.docStyle[DOM.selectProp] = 'none';\n }\n }\n\n public static enableDrag() {\n if (DOM.docStyle && DOM.selectProp) {\n DOM.docStyle[DOM.selectProp] = DOM.userSelect;\n }\n }\n\n public static setTransform(el: HTMLElement, value: string) {\n el.style[DOM.transformProp] = value;\n }\n\n public static addEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: {\n passive?: boolean;\n capture?: boolean;\n } = {}) {\n if ('passive' in options) {\n target.addEventListener(type, callback, options);\n } else {\n target.addEventListener(type, callback, options.capture);\n }\n }\n\n public static removeEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: {\n passive?: boolean;\n capture?: boolean;\n } = {}) {\n if ('passive' in options) {\n target.removeEventListener(type, callback, options);\n } else {\n target.removeEventListener(type, callback, options.capture);\n }\n }\n\n // Suppress the next click, but only if it's immediate.\n private static suppressClickInternal(e) {\n e.preventDefault();\n e.stopPropagation();\n window.removeEventListener('click', DOM.suppressClickInternal, true);\n }\n\n public static suppressClick() {\n window.addEventListener('click', DOM.suppressClickInternal, true);\n window.setTimeout(() => {\n window.removeEventListener('click', DOM.suppressClickInternal, true);\n }, 0);\n }\n\n public static mousePos(el: HTMLElement, e: MouseEvent | Touch) {\n const rect = el.getBoundingClientRect();\n return new Point(\n e.clientX - rect.left - el.clientLeft,\n e.clientY - rect.top - el.clientTop\n );\n }\n\n public static touchPos(el: HTMLElement, touches: TouchList) {\n const rect = el.getBoundingClientRect();\n const points: Point[] = [];\n for (let i = 0; i < touches.length; i++) {\n points.push(new Point(\n touches[i].clientX - rect.left - el.clientLeft,\n touches[i].clientY - rect.top - el.clientTop\n ));\n }\n return points;\n }\n\n public static mouseButton(e: MouseEvent) {\n return e.button;\n }\n\n public static remove(node: HTMLElement) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n}\n","export const webpSupported = {\n supported: false,\n testSupport\n};\n\nlet glForTesting: WebGLRenderingContext|WebGL2RenderingContext;\nlet webpCheckComplete = false;\nlet webpImgTest;\nlet webpImgTestOnloadComplete = false;\n\nif (typeof document !== 'undefined') {\n webpImgTest = document.createElement('img');\n webpImgTest.onload = function() {\n if (glForTesting) testWebpTextureUpload(glForTesting);\n glForTesting = null;\n webpImgTestOnloadComplete = true;\n };\n webpImgTest.onerror = function() {\n webpCheckComplete = true;\n glForTesting = null;\n };\n webpImgTest.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=';\n}\n\nfunction testSupport(gl: WebGLRenderingContext | WebGL2RenderingContext) {\n if (webpCheckComplete || !webpImgTest) return;\n\n // HTMLImageElement.complete is set when an image is done loading it's source\n // regardless of whether the load was successful or not.\n // It's possible for an error to set HTMLImageElement.complete to true which would trigger\n // testWebpTextureUpload and mistakenly set exported.supported to true in browsers which don't support webp\n // To avoid this, we set a flag in the image's onload handler and only call testWebpTextureUpload\n // after a successful image load event.\n if (webpImgTestOnloadComplete) {\n testWebpTextureUpload(gl);\n } else {\n glForTesting = gl;\n\n }\n}\n\nfunction testWebpTextureUpload(gl: WebGLRenderingContext|WebGL2RenderingContext) {\n // Edge 18 supports WebP but not uploading a WebP image to a gl texture\n // Test support for this before allowing WebP images.\n // https://github.com/mapbox/mapbox-gl-js/issues/7671\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n\n try {\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, webpImgTest);\n\n // The error does not get triggered in Edge if the context is lost\n if (gl.isContextLost()) return;\n\n webpSupported.supported = true;\n } catch (e) {\n // Catch \"Unspecified Error.\" in Edge 18.\n }\n\n gl.deleteTexture(texture);\n\n webpCheckComplete = true;\n}\n","import type {Cancelable} from '../types/cancelable';\nimport {RequestParameters, ExpiryData, makeRequest, sameOrigin, getProtocolAction} from './ajax';\nimport type {Callback} from '../types/callback';\n\nimport {arrayBufferToImageBitmap, arrayBufferToImage, extend, isWorker, isImageBitmap} from './util';\nimport {webpSupported} from './webp_supported';\nimport {config} from './config';\n\n/**\n * The callback that is being called after an image was fetched\n */\nexport type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void;\n\ntype ImageQueueThrottleControlCallback = () => boolean;\n\nexport type ImageRequestQueueItem = Cancelable & {\n requestParameters: RequestParameters;\n supportImageRefresh: boolean;\n callback: GetImageCallback;\n cancelled: boolean;\n completed: boolean;\n innerRequest?: Cancelable;\n}\n\ntype ImageQueueThrottleCallbackDictionary = {\n [Key: number]: ImageQueueThrottleControlCallback;\n}\n\ntype HTMLImageElementWithPriority = HTMLImageElement &\n{\n // fetchPriority is experimental property supported on Chromium browsers from Version 102\n // By default images are downloaded with priority low, whereas fetch request downloads with priority high\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority\n fetchPriority?: 'auto' | 'high' | 'low';\n};\n\n/**\n * By default, the image queue is self driven, meaning as soon as one requested item is processed,\n * it will move on to next one as quickly as it can while limiting\n * the number of concurrent requests to MAX_PARALLEL_IMAGE_REQUESTS. The default behavior\n * ensures that static views of the map can be rendered with minimal delay.\n *\n * However, the default behavior can prevent dynamic views of the map from rendering\n * smoothly in that many requests can finish in one render frame, putting too much pressure on GPU.\n *\n * When the view of the map is moving dynamically, smoother frame rates can be achieved\n * by throttling the number of items processed by the queue per frame. This can be\n * accomplished by using {@link addThrottleControl} to allow the caller to\n * use a lambda function to determine when the queue should be throttled (e.g. when isMoving())\n * and manually calling {@link processQueue} in the render loop.\n */\nexport namespace ImageRequest {\n let imageRequestQueue : ImageRequestQueueItem[];\n let currentParallelImageRequests:number;\n\n let throttleControlCallbackHandleCounter: number;\n let throttleControlCallbacks: ImageQueueThrottleCallbackDictionary;\n\n /**\n * Reset the image request queue, removing all pending requests.\n */\n export const resetRequestQueue = (): void => {\n imageRequestQueue = [];\n currentParallelImageRequests = 0;\n throttleControlCallbackHandleCounter = 0;\n throttleControlCallbacks = {};\n };\n\n /**\n * Install a callback to control when image queue throttling is desired.\n * (e.g. when the map view is moving)\n * @param callback - The callback function to install\n * @returns handle that identifies the installed callback.\n */\n export const addThrottleControl = (callback: ImageQueueThrottleControlCallback): number => {\n const handle = throttleControlCallbackHandleCounter++;\n throttleControlCallbacks[handle] = callback;\n return handle;\n };\n\n /**\n * Remove a previously installed callback by passing in the handle returned\n * by {@link addThrottleControl}.\n * @param callbackHandle - The handle for the callback to remove.\n */\n export const removeThrottleControl = (callbackHandle: number): void => {\n delete throttleControlCallbacks[callbackHandle];\n // Try updating the queue\n processQueue();\n };\n\n /**\n * Check to see if any of the installed callbacks are requesting the queue\n * to be throttled.\n * @returns `true` if any callback is causing the queue to be throttled.\n */\n const isThrottled = (): boolean => {\n const allControlKeys = Object.keys(throttleControlCallbacks);\n let throttleingRequested = false;\n if (allControlKeys.length > 0) {\n for (const key of allControlKeys) {\n throttleingRequested = throttleControlCallbacks[key]();\n if (throttleingRequested) {\n break;\n }\n }\n }\n return throttleingRequested;\n };\n\n /**\n * Request to load an image.\n * @param requestParameters - Request parameters.\n * @param callback - Callback to issue when the request completes.\n * @param supportImageRefresh - `true`, if the image request need to support refresh based on cache headers.\n * @returns Cancelable request.\n */\n export const getImage = (\n requestParameters: RequestParameters,\n callback: GetImageCallback,\n supportImageRefresh: boolean = true\n ): ImageRequestQueueItem => {\n if (webpSupported.supported) {\n if (!requestParameters.headers) {\n requestParameters.headers = {};\n }\n requestParameters.headers.accept = 'image/webp,*/*';\n }\n\n const request:ImageRequestQueueItem = {\n requestParameters,\n supportImageRefresh,\n callback,\n cancelled: false,\n completed: false,\n cancel: () => {\n if (!request.completed && !request.cancelled) {\n request.cancelled = true;\n\n // Only reduce currentParallelImageRequests, if the image request was issued.\n if (request.innerRequest) {\n request.innerRequest.cancel();\n currentParallelImageRequests--;\n }\n\n // in the case of cancelling, it WILL move on\n processQueue();\n }\n }\n };\n\n imageRequestQueue.push(request);\n processQueue();\n return request;\n };\n\n const arrayBufferToCanvasImageSource = (data: ArrayBuffer, callback: Callback) => {\n const imageBitmapSupported = typeof createImageBitmap === 'function';\n if (imageBitmapSupported) {\n arrayBufferToImageBitmap(data, callback);\n } else {\n arrayBufferToImage(data, callback);\n }\n };\n\n const doImageRequest = (itemInQueue: ImageRequestQueueItem): Cancelable => {\n const {requestParameters, supportImageRefresh, callback} = itemInQueue;\n extend(requestParameters, {type: 'image'});\n\n // - If refreshExpiredTiles is false, then we can use HTMLImageElement to download raster images.\n // - Fetch/XHR (via MakeRequest API) will be used to download images for following scenarios:\n // 1. Style image sprite will had a issue with HTMLImageElement as described\n // here: https://github.com/mapbox/mapbox-gl-js/issues/1470\n // 2. If refreshExpiredTiles is true (default), then in order to read the image cache header,\n // fetch/XHR request will be required\n // - For any special case handling like use of AddProtocol, worker initiated request or additional headers\n // let makeRequest handle it.\n // - HtmlImageElement request automatically adds accept header for all the browser supported images\n const canUseHTMLImageElement = supportImageRefresh === false &&\n !isWorker() &&\n !getProtocolAction(requestParameters.url) &&\n (!requestParameters.headers ||\n Object.keys(requestParameters.headers).reduce((acc, item) => acc && item === 'accept', true));\n\n const action = canUseHTMLImageElement ? getImageUsingHtmlImage : makeRequest;\n return action(\n requestParameters,\n (err?: Error | null,\n data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null,\n cacheControl?: string | null,\n expires?: string | null) => {\n onImageResponse(itemInQueue, callback, err, data, cacheControl, expires);\n });\n };\n\n const onImageResponse = (\n itemInQueue: ImageRequestQueueItem,\n callback:GetImageCallback,\n err?: Error | null,\n data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null,\n cacheControl?: string | null,\n expires?: string | null): void => {\n if (err) {\n callback(err);\n } else if (data instanceof HTMLImageElement || isImageBitmap(data)) {\n // User using addProtocol can directly return HTMLImageElement/ImageBitmap type\n // If HtmlImageElement is used to get image then response type will be HTMLImageElement\n callback(null, data);\n } else if (data) {\n const decoratedCallback = (imgErr?: Error | null, imgResult?: CanvasImageSource | null) => {\n if (imgErr != null) {\n callback(imgErr);\n } else if (imgResult != null) {\n callback(null, imgResult as (HTMLImageElement | ImageBitmap), {cacheControl, expires});\n }\n };\n arrayBufferToCanvasImageSource(data, decoratedCallback);\n }\n if (!itemInQueue.cancelled) {\n itemInQueue.completed = true;\n currentParallelImageRequests--;\n\n processQueue();\n }\n };\n\n /**\n * Process some number of items in the image request queue.\n */\n const processQueue = (): void => {\n\n const maxImageRequests = isThrottled() ?\n config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME :\n config.MAX_PARALLEL_IMAGE_REQUESTS;\n\n // limit concurrent image loads to help with raster sources performance on big screens\n for (let numImageRequests = currentParallelImageRequests;\n numImageRequests < maxImageRequests && imageRequestQueue.length > 0;\n numImageRequests++) {\n\n const topItemInQueue: ImageRequestQueueItem = imageRequestQueue.shift();\n if (topItemInQueue.cancelled) {\n numImageRequests--;\n continue;\n }\n\n const innerRequest = doImageRequest(topItemInQueue);\n\n currentParallelImageRequests++;\n\n topItemInQueue.innerRequest = innerRequest;\n }\n };\n\n const getImageUsingHtmlImage = (requestParameters: RequestParameters, callback: GetImageCallback): Cancelable => {\n const image = new Image() as HTMLImageElementWithPriority;\n const url = requestParameters.url;\n let requestCancelled = false;\n const credentials = requestParameters.credentials;\n if (credentials && credentials === 'include') {\n image.crossOrigin = 'use-credentials';\n } else if ((credentials && credentials === 'same-origin') || !sameOrigin(url)) {\n image.crossOrigin = 'anonymous';\n }\n\n image.fetchPriority = 'high';\n image.onload = () => {\n callback(null, image);\n image.onerror = image.onload = null;\n };\n image.onerror = () => {\n if (!requestCancelled) {\n callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n }\n image.onerror = image.onload = null;\n };\n image.src = url;\n return {\n cancel: () => {\n requestCancelled = true;\n // Set src to '' to actually cancel the request\n image.src = '';\n }\n };\n };\n}\n\nImageRequest.resetRequestQueue();\n","import type {RequestParameters} from './ajax';\n\n/**\n * A type of MapLibre resource.\n */\nexport const enum ResourceType {\n Glyphs = 'Glyphs',\n Image = 'Image',\n Source = 'Source',\n SpriteImage = 'SpriteImage',\n SpriteJSON = 'SpriteJSON',\n Style = 'Style',\n Tile = 'Tile',\n Unknown = 'Unknown',\n}\n\n/**\n * This function is used to tranform a request.\n * It is used just before executing the relevant request.\n */\nexport type RequestTransformFunction = (url: string, resourceType?: ResourceType) => RequestParameters | undefined;\n\ntype UrlObject = {\n protocol: string;\n authority: string;\n path: string;\n params: Array;\n};\n\nexport class RequestManager {\n _transformRequestFn: RequestTransformFunction;\n\n constructor(transformRequestFn?: RequestTransformFunction) {\n this._transformRequestFn = transformRequestFn;\n }\n\n transformRequest(url: string, type: ResourceType) {\n if (this._transformRequestFn) {\n return this._transformRequestFn(url, type) || {url};\n }\n\n return {url};\n }\n\n normalizeSpriteURL(url: string, format: string, extension: string): string {\n const urlObject = parseUrl(url);\n urlObject.path += `${format}${extension}`;\n return formatUrl(urlObject);\n }\n\n setTransformRequest(transformRequest: RequestTransformFunction) {\n this._transformRequestFn = transformRequest;\n }\n}\n\nconst urlRe = /^(\\w+):\\/\\/([^/?]*)(\\/[^?]+)?\\??(.+)?/;\n\nfunction parseUrl(url: string): UrlObject {\n const parts = url.match(urlRe);\n if (!parts) {\n throw new Error(`Unable to parse URL \"${url}\"`);\n }\n return {\n protocol: parts[1],\n authority: parts[2],\n path: parts[3] || '/',\n params: parts[4] ? parts[4].split('&') : []\n };\n}\n\nfunction formatUrl(obj: UrlObject): string {\n const params = obj.params.length ? `?${obj.params.join('&')}` : '';\n return `${obj.protocol}://${obj.authority}${obj.path}${params}`;\n}\n","import * as glMatrix from \"./common.js\";\n/**\n * 3 Dimensional Vector\n * @module vec3\n */\n\n/**\n * Creates a new, empty vec3\n *\n * @returns {vec3} a new 3D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(3);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec3 initialized with values from an existing vector\n *\n * @param {ReadonlyVec3} a vector to clone\n * @returns {vec3} a new 3D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Calculates the length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Creates a new vec3 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} a new 3D vector\n */\n\nexport function fromValues(x, y, z) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Copy the values from one vec3 to another\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the source vector\n * @returns {vec3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Set the components of a vec3 to the given values\n *\n * @param {vec3} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} out\n */\n\nexport function set(out, x, y, z) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Adds two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n return out;\n}\n/**\n * Multiplies two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n return out;\n}\n/**\n * Divides two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n return out;\n}\n/**\n * Math.ceil the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to ceil\n * @returns {vec3} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n return out;\n}\n/**\n * Math.floor the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to floor\n * @returns {vec3} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n return out;\n}\n/**\n * Returns the minimum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n return out;\n}\n/**\n * Returns the maximum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n return out;\n}\n/**\n * Math.round the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to round\n * @returns {vec3} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n return out;\n}\n/**\n * Scales a vec3 by a scalar number\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec3} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n return out;\n}\n/**\n * Adds two vec3's after scaling the second operand by a scalar value\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec3} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Calculates the squared euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Calculates the squared length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Negates the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to negate\n * @returns {vec3} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to invert\n * @returns {vec3} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n return out;\n}\n/**\n * Normalize a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to normalize\n * @returns {vec3} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var len = x * x + y * y + z * z;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n out[2] = a[2] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n/**\n * Computes the cross product of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2];\n var bx = b[0],\n by = b[1],\n bz = b[2];\n out[0] = ay * bz - az * by;\n out[1] = az * bx - ax * bz;\n out[2] = ax * by - ay * bx;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n return out;\n}\n/**\n * Performs a hermite interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function hermite(out, a, b, c, d, t) {\n var factorTimes2 = t * t;\n var factor1 = factorTimes2 * (2 * t - 3) + 1;\n var factor2 = factorTimes2 * (t - 2) + t;\n var factor3 = factorTimes2 * (t - 1);\n var factor4 = factorTimes2 * (3 - 2 * t);\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Performs a bezier interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function bezier(out, a, b, c, d, t) {\n var inverseFactor = 1 - t;\n var inverseFactorTimesTwo = inverseFactor * inverseFactor;\n var factorTimes2 = t * t;\n var factor1 = inverseFactorTimesTwo * inverseFactor;\n var factor2 = 3 * t * inverseFactorTimesTwo;\n var factor3 = 3 * factorTimes2 * inverseFactor;\n var factor4 = factorTimes2 * t;\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec3} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec3} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n var z = glMatrix.RANDOM() * 2.0 - 1.0;\n var zScale = Math.sqrt(1.0 - z * z) * scale;\n out[0] = Math.cos(r) * zScale;\n out[1] = Math.sin(r) * zScale;\n out[2] = z * scale;\n return out;\n}\n/**\n * Transforms the vec3 with a mat4.\n * 4th vector component is implicitly '1'\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var w = m[3] * x + m[7] * y + m[11] * z + m[15];\n w = w || 1.0;\n out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n return out;\n}\n/**\n * Transforms the vec3 with a mat3.\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat3} m the 3x3 matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n out[0] = x * m[0] + y * m[3] + z * m[6];\n out[1] = x * m[1] + y * m[4] + z * m[7];\n out[2] = x * m[2] + y * m[5] + z * m[8];\n return out;\n}\n/**\n * Transforms the vec3 with a quat\n * Can also be used for dual quaternions. (Multiply it with the real part)\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec3} out\n */\n\nexport function transformQuat(out, a, q) {\n // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3];\n var x = a[0],\n y = a[1],\n z = a[2]; // var qvec = [qx, qy, qz];\n // var uv = vec3.cross([], qvec, a);\n\n var uvx = qy * z - qz * y,\n uvy = qz * x - qx * z,\n uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv);\n\n var uuvx = qy * uvz - qz * uvy,\n uuvy = qz * uvx - qx * uvz,\n uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w);\n\n var w2 = qw * 2;\n uvx *= w2;\n uvy *= w2;\n uvz *= w2; // vec3.scale(uuv, uuv, 2);\n\n uuvx *= 2;\n uuvy *= 2;\n uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv));\n\n out[0] = x + uvx + uuvx;\n out[1] = y + uvy + uuvy;\n out[2] = z + uvz + uuvz;\n return out;\n}\n/**\n * Rotate a 3D vector around the x-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateX(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the y-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateY(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the z-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateZ(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2]; //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Get the angle between two 3D vectors\n * @param {ReadonlyVec3} a The first operand\n * @param {ReadonlyVec3} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2],\n bx = b[0],\n by = b[1],\n bz = b[2],\n mag1 = Math.sqrt(ax * ax + ay * ay + az * az),\n mag2 = Math.sqrt(bx * bx + by * by + bz * bz),\n mag = mag1 * mag2,\n cosine = mag && dot(a, b) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec3 to zero\n *\n * @param {vec3} out the receiving vector\n * @returns {vec3} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec3} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));\n}\n/**\n * Alias for {@link vec3.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec3.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec3.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec3.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec3.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec3.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec3s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 3;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n }\n\n return a;\n };\n}();","import * as glMatrix from \"./common.js\";\n/**\n * 2 Dimensional Vector\n * @module vec2\n */\n\n/**\n * Creates a new, empty vec2\n *\n * @returns {vec2} a new 2D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(2);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec2 initialized with values from an existing vector\n *\n * @param {ReadonlyVec2} a vector to clone\n * @returns {vec2} a new 2D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(2);\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n/**\n * Creates a new vec2 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} a new 2D vector\n */\n\nexport function fromValues(x, y) {\n var out = new glMatrix.ARRAY_TYPE(2);\n out[0] = x;\n out[1] = y;\n return out;\n}\n/**\n * Copy the values from one vec2 to another\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the source vector\n * @returns {vec2} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n return out;\n}\n/**\n * Set the components of a vec2 to the given values\n *\n * @param {vec2} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @returns {vec2} out\n */\n\nexport function set(out, x, y) {\n out[0] = x;\n out[1] = y;\n return out;\n}\n/**\n * Adds two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n return out;\n}\n/**\n * Multiplies two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n return out;\n}\n/**\n * Divides two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n return out;\n}\n/**\n * Math.ceil the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to ceil\n * @returns {vec2} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n return out;\n}\n/**\n * Math.floor the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to floor\n * @returns {vec2} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n return out;\n}\n/**\n * Returns the minimum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n return out;\n}\n/**\n * Returns the maximum of two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec2} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n return out;\n}\n/**\n * Math.round the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to round\n * @returns {vec2} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n return out;\n}\n/**\n * Scales a vec2 by a scalar number\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec2} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n return out;\n}\n/**\n * Adds two vec2's after scaling the second operand by a scalar value\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec2} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return Math.hypot(x, y);\n}\n/**\n * Calculates the squared euclidian distance between two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0],\n y = b[1] - a[1];\n return x * x + y * y;\n}\n/**\n * Calculates the length of a vec2\n *\n * @param {ReadonlyVec2} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0],\n y = a[1];\n return Math.hypot(x, y);\n}\n/**\n * Calculates the squared length of a vec2\n *\n * @param {ReadonlyVec2} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0],\n y = a[1];\n return x * x + y * y;\n}\n/**\n * Negates the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to negate\n * @returns {vec2} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to invert\n * @returns {vec2} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n return out;\n}\n/**\n * Normalize a vec2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a vector to normalize\n * @returns {vec2} out\n */\n\nexport function normalize(out, a) {\n var x = a[0],\n y = a[1];\n var len = x * x + y * y;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec2's\n *\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1];\n}\n/**\n * Computes the cross product of two vec2's\n * Note that the cross product must by definition produce a 3D vector\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var z = a[0] * b[1] - a[1] * b[0];\n out[0] = out[1] = 0;\n out[2] = z;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec2's\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the first operand\n * @param {ReadonlyVec2} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec2} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0],\n ay = a[1];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec2} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec2} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n out[0] = Math.cos(r) * scale;\n out[1] = Math.sin(r) * scale;\n return out;\n}\n/**\n * Transforms the vec2 with a mat2\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat2} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat2(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y;\n out[1] = m[1] * x + m[3] * y;\n return out;\n}\n/**\n * Transforms the vec2 with a mat2d\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat2d} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat2d(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[2] * y + m[4];\n out[1] = m[1] * x + m[3] * y + m[5];\n return out;\n}\n/**\n * Transforms the vec2 with a mat3\n * 3rd vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat3} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1];\n out[0] = m[0] * x + m[3] * y + m[6];\n out[1] = m[1] * x + m[4] * y + m[7];\n return out;\n}\n/**\n * Transforms the vec2 with a mat4\n * 3rd vector component is implicitly '0'\n * 4th vector component is implicitly '1'\n *\n * @param {vec2} out the receiving vector\n * @param {ReadonlyVec2} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec2} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0];\n var y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n return out;\n}\n/**\n * Rotate a 2D vector\n * @param {vec2} out The receiving vec2\n * @param {ReadonlyVec2} a The vec2 point to rotate\n * @param {ReadonlyVec2} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec2} out\n */\n\nexport function rotate(out, a, b, rad) {\n //Translate point to the origin\n var p0 = a[0] - b[0],\n p1 = a[1] - b[1],\n sinC = Math.sin(rad),\n cosC = Math.cos(rad); //perform rotation and translate to correct position\n\n out[0] = p0 * cosC - p1 * sinC + b[0];\n out[1] = p0 * sinC + p1 * cosC + b[1];\n return out;\n}\n/**\n * Get the angle between two 2D vectors\n * @param {ReadonlyVec2} a The first operand\n * @param {ReadonlyVec2} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var x1 = a[0],\n y1 = a[1],\n x2 = b[0],\n y2 = b[1],\n // mag is the product of the magnitudes of a and b\n mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2),\n // mag &&.. short circuits if mag == 0\n cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1\n\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec2 to zero\n *\n * @param {vec2} out the receiving vector\n * @returns {vec2} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec2} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec2(\" + a[0] + \", \" + a[1] + \")\";\n}\n/**\n * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec2} a The first vector.\n * @param {ReadonlyVec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec2} a The first vector.\n * @param {ReadonlyVec2} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1];\n var b0 = b[0],\n b1 = b[1];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));\n}\n/**\n * Alias for {@link vec2.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec2.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec2.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec2.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec2.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec2.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec2s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 2;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n }\n\n return a;\n };\n}();","import {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * Takes a SpriteSpecification value and returns it in its array form. If `undefined` is passed as an input value, an\n * empty array is returned.\n * duplicated entries with identical id/url will be removed in returned array\n * @param sprite - optional sprite to coerce\n * @returns an empty array in case `undefined` is passed; id-url pairs otherwise\n */\nexport function coerceSpriteToArray(sprite?: SpriteSpecification): {id: string; url: string}[] {\n const resultArray: {id: string; url: string}[] = [];\n\n if (typeof sprite === 'string') {\n resultArray.push({id: 'default', url: sprite});\n } else if (sprite && sprite.length > 0) {\n const dedupArray: string[] = [];\n for (const {id, url} of sprite) {\n const key = `${id}${url}`;\n if (dedupArray.indexOf(key) === -1) {\n dedupArray.push(key);\n resultArray.push({id, url});\n }\n }\n }\n\n return resultArray;\n\n}\n","import {getJSON} from '../util/ajax';\nimport {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\n\nimport {browser} from '../util/browser';\nimport {coerceSpriteToArray} from '../util/style';\n\nimport type {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {StyleImage} from './style_image';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\n\nexport function loadSprite(\n originalSprite: SpriteSpecification,\n requestManager: RequestManager,\n pixelRatio: number,\n callback: Callback<{[spriteName: string]: {[id: string]: StyleImage}}>\n): Cancelable {\n const spriteArray = coerceSpriteToArray(originalSprite);\n const spriteArrayLength = spriteArray.length;\n const format = pixelRatio > 1 ? '@2x' : '';\n\n const combinedRequestsMap: {[requestKey: string]: Cancelable} = {};\n const jsonsMap: {[id: string]: any} = {};\n const imagesMap: {[id: string]: (HTMLImageElement | ImageBitmap)} = {};\n\n for (const {id, url} of spriteArray) {\n const jsonRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.json'), ResourceType.SpriteJSON);\n const jsonRequestKey = `${id}_${jsonRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique\n combinedRequestsMap[jsonRequestKey] = getJSON(jsonRequestParameters, (err?: Error | null, data?: any | null) => {\n delete combinedRequestsMap[jsonRequestKey];\n jsonsMap[id] = data;\n doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength);\n });\n\n const imageRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.png'), ResourceType.SpriteImage);\n const imageRequestKey = `${id}_${imageRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique\n combinedRequestsMap[imageRequestKey] = ImageRequest.getImage(imageRequestParameters, (err, img) => {\n delete combinedRequestsMap[imageRequestKey];\n imagesMap[id] = img;\n doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength);\n });\n }\n\n return {\n cancel() {\n for (const requst of Object.values(combinedRequestsMap)) {\n requst.cancel();\n }\n }\n };\n}\n\n/**\n * @param callbackFunc - the callback function (both erro and success)\n * @param jsonsMap - JSON data map\n * @param imagesMap - image data map\n * @param err - error object\n * @param expectedResultCounter - number of expected JSON or Image results when everything is finished, respectively.\n */\nfunction doOnceCompleted(\n callbackFunc:Callback<{[spriteName: string]: {[id: string]: StyleImage}}>,\n jsonsMap:{[id: string]: any},\n imagesMap:{[id: string]: (HTMLImageElement | ImageBitmap)},\n err: Error,\n expectedResultCounter: number): void {\n\n if (err) {\n callbackFunc(err);\n return;\n }\n\n if (expectedResultCounter !== Object.values(jsonsMap).length || expectedResultCounter !== Object.values(imagesMap).length) {\n // not done yet, nothing to do\n return;\n }\n\n const result = {} as {[spriteName: string]: {[id: string]: StyleImage}};\n for (const spriteName in jsonsMap) {\n result[spriteName] = {};\n\n const context = browser.getImageCanvasContext(imagesMap[spriteName]);\n const json = jsonsMap[spriteName];\n\n for (const id in json) {\n const {width, height, x, y, sdf, pixelRatio, stretchX, stretchY, content} = json[id];\n const spriteData = {width, height, x, y, context};\n result[spriteName][id] = {data: null, pixelRatio, sdf, stretchX, stretchY, content, spriteData};\n }\n }\n\n callbackFunc(null, result);\n}\n","import type {Context} from '../gl/context';\nimport type {RGBAImage, AlphaImage} from '../util/image';\nimport {isImageBitmap} from '../util/util';\n\nexport type TextureFormat = WebGLRenderingContextBase['RGBA'] | WebGLRenderingContextBase['ALPHA'];\nexport type TextureFilter = WebGLRenderingContextBase['LINEAR'] | WebGLRenderingContextBase['LINEAR_MIPMAP_NEAREST'] | WebGLRenderingContextBase['NEAREST'];\nexport type TextureWrap = WebGLRenderingContextBase['REPEAT'] | WebGLRenderingContextBase['CLAMP_TO_EDGE'] | WebGLRenderingContextBase['MIRRORED_REPEAT'];\n\ntype EmptyImage = {\n width: number;\n height: number;\n data: null;\n};\n\ntype DataTextureImage = RGBAImage | AlphaImage | EmptyImage;\nexport type TextureImage = TexImageSource | DataTextureImage;\n\n/**\n * @internal\n * A `Texture` GL related object\n */\nexport class Texture {\n context: Context;\n size: [number, number];\n texture: WebGLTexture;\n format: TextureFormat;\n filter: TextureFilter;\n wrap: TextureWrap;\n useMipmap: boolean;\n\n constructor(context: Context, image: TextureImage, format: TextureFormat, options?: {\n premultiply?: boolean;\n useMipmap?: boolean;\n } | null) {\n this.context = context;\n this.format = format;\n this.texture = context.gl.createTexture();\n this.update(image, options);\n }\n\n update(image: TextureImage, options?: {\n premultiply?: boolean;\n useMipmap?: boolean;\n } | null, position?: {\n x: number;\n y: number;\n }) {\n const {width, height} = image as {width: number; height: number};\n const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position;\n const {context} = this;\n const {gl} = context;\n\n this.useMipmap = Boolean(options && options.useMipmap);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n context.pixelStoreUnpackFlipY.set(false);\n context.pixelStoreUnpack.set(1);\n context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl.RGBA && (!options || options.premultiply !== false));\n\n if (resize) {\n this.size = [width, height];\n\n if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image);\n } else {\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);\n }\n\n } else {\n const {x, y} = position || {x: 0, y: 0};\n if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image);\n } else {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);\n }\n }\n\n if (this.useMipmap && this.isSizePowerOfTwo()) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n }\n\n bind(filter: TextureFilter, wrap: TextureWrap, minFilter?: TextureFilter | null) {\n const {context} = this;\n const {gl} = context;\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n if (minFilter === gl.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) {\n minFilter = gl.LINEAR;\n }\n\n if (filter !== this.filter) {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || filter);\n this.filter = filter;\n }\n\n if (wrap !== this.wrap) {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);\n this.wrap = wrap;\n }\n }\n\n isSizePowerOfTwo() {\n return this.size[0] === this.size[1] && (Math.log(this.size[0]) / Math.LN2) % 1 === 0;\n }\n\n destroy() {\n const {gl} = this.context;\n gl.deleteTexture(this.texture);\n this.texture = null;\n }\n}\n","import {RGBAImage} from '../util/image';\n\nimport type {Map} from '../ui/map';\n\n/**\n * The sprite data\n */\nexport type SpriteOnDemandStyleImage = {\n width: number;\n height: number;\n x: number;\n y: number;\n context: CanvasRenderingContext2D;\n};\n\n/**\n * The style's image metadata\n */\nexport type StyleImageData = {\n data: RGBAImage;\n version?: number;\n hasRenderCallback?: boolean;\n userImage?: StyleImageInterface;\n spriteData?: SpriteOnDemandStyleImage;\n};\n\n/**\n * The style's image metadata\n */\nexport type StyleImageMetadata = {\n /**\n * The ratio of pixels in the image to physical pixels on the screen\n */\n pixelRatio: number;\n /**\n * Whether the image should be interpreted as an SDF image\n */\n sdf: boolean;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally.\n */\n stretchX?: Array<[number, number]>;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically.\n */\n stretchY?: Array<[number, number]>;\n /**\n * If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`.\n */\n content?: [number, number, number, number];\n};\n\n/**\n * the style's image, including data and metedata\n */\nexport type StyleImage = StyleImageData & StyleImageMetadata;\n\n/**\n * Interface for dynamically generated style images. This is a specification for\n * implementers to model: it is not an exported method or class.\n *\n * Images implementing this interface can be redrawn for every frame. They can be used to animate\n * icons and patterns or make them respond to user input. Style images can implement a\n * {@link StyleImageInterface#render} method. The method is called every frame and\n * can be used to update the image.\n *\n * @see [Add an animated icon to the map.](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/)\n *\n * @example\n * ```ts\n * let flashingSquare = {\n * width: 64,\n * height: 64,\n * data: new Uint8Array(64 * 64 * 4),\n *\n * onAdd: function(map) {\n * this.map = map;\n * },\n *\n * render: function() {\n * // keep repainting while the icon is on the map\n * this.map.triggerRepaint();\n *\n * // alternate between black and white based on the time\n * let value = Math.round(Date.now() / 1000) % 2 === 0 ? 255 : 0;\n *\n * // check if image needs to be changed\n * if (value !== this.previousValue) {\n * this.previousValue = value;\n *\n * let bytesPerPixel = 4;\n * for (let x = 0; x < this.width; x++) {\n * for (let y = 0; y < this.height; y++) {\n * let offset = (y * this.width + x) * bytesPerPixel;\n * this.data[offset + 0] = value;\n * this.data[offset + 1] = value;\n * this.data[offset + 2] = value;\n * this.data[offset + 3] = 255;\n * }\n * }\n *\n * // return true to indicate that the image changed\n * return true;\n * }\n * }\n * }\n *\n * map.addImage('flashing_square', flashingSquare);\n * ```\n */\n\nexport interface StyleImageInterface {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n /**\n * This method is called once before every frame where the icon will be used.\n * The method can optionally update the image's `data` member with a new image.\n *\n * If the method updates the image it must return `true` to commit the change.\n * If the method returns `false` or nothing the image is assumed to not have changed.\n *\n * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update\n * the image instead of implementing this method.\n *\n * @returns `true` if this method updated the image. `false` if the image was not changed.\n */\n render?: () => boolean;\n /**\n * Optional method called when the layer has been added to the Map with {@link Map#addImage}.\n *\n * @param map - The Map this custom layer was just added to.\n */\n onAdd?: (map: Map, id: string) => void;\n /**\n * Optional method called when the icon is removed from the map with {@link Map#removeImage}.\n * This gives the image a chance to clean up resources and event listeners.\n */\n onRemove?: () => void;\n}\n\nexport function renderStyleImage(image: StyleImage) {\n const {userImage} = image;\n if (userImage && userImage.render) {\n const updated = userImage.render();\n if (updated) {\n image.data.replace(new Uint8Array(userImage.data.buffer));\n return true;\n }\n }\n return false;\n}\n","/* eslint-disable key-spacing */\nimport potpack from 'potpack';\n\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {RGBAImage} from '../util/image';\nimport {ImagePosition} from './image_atlas';\nimport {Texture} from './texture';\nimport {renderStyleImage} from '../style/style_image';\nimport {warnOnce} from '../util/util';\n\nimport type {StyleImage} from '../style/style_image';\nimport type {Context} from '../gl/context';\nimport type {PotpackBox} from 'potpack';\nimport type {Callback} from '../types/callback';\n\ntype Pattern = {\n bin: PotpackBox;\n position: ImagePosition;\n};\n\n// When copied into the atlas texture, image data is padded by one pixel on each side. Icon\n// images are padded with fully transparent pixels, while pattern images are padded with a\n// copy of the image data wrapped from the opposite side. In both cases, this ensures the\n// correct behavior of GL_LINEAR texture sampling mode.\nconst padding = 1;\n\n/*\n ImageManager does three things:\n\n 1. Tracks requests for icon images from tile workers and sends responses when the requests are fulfilled.\n 2. Builds a texture atlas for pattern images.\n 3. Rerenders renderable images once per frame\n\n These are disparate responsibilities and should eventually be handled by different classes. When we implement\n data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time\n to refactor this.\n*/\nexport class ImageManager extends Evented {\n images: {[_: string]: StyleImage};\n updatedImages: {[_: string]: boolean};\n callbackDispatchedThisFrame: {[_: string]: boolean};\n loaded: boolean;\n requestors: Array<{\n ids: Array;\n callback: Callback<{[_: string]: StyleImage}>;\n }>;\n\n patterns: {[_: string]: Pattern};\n atlasImage: RGBAImage;\n atlasTexture: Texture;\n dirty: boolean;\n\n constructor() {\n super();\n this.images = {};\n this.updatedImages = {};\n this.callbackDispatchedThisFrame = {};\n this.loaded = false;\n this.requestors = [];\n\n this.patterns = {};\n this.atlasImage = new RGBAImage({width: 1, height: 1});\n this.dirty = true;\n }\n\n isLoaded() {\n return this.loaded;\n }\n\n setLoaded(loaded: boolean) {\n if (this.loaded === loaded) {\n return;\n }\n\n this.loaded = loaded;\n\n if (loaded) {\n for (const {ids, callback} of this.requestors) {\n this._notify(ids, callback);\n }\n this.requestors = [];\n }\n }\n\n getImage(id: string): StyleImage {\n const image = this.images[id];\n\n // Extract sprite image data on demand\n if (image && !image.data && image.spriteData) {\n const spriteData = image.spriteData;\n image.data = new RGBAImage({\n width: spriteData.width,\n height: spriteData.height\n }, spriteData.context.getImageData(\n spriteData.x,\n spriteData.y,\n spriteData.width,\n spriteData.height).data);\n image.spriteData = null;\n }\n\n return image;\n }\n\n addImage(id: string, image: StyleImage) {\n if (this.images[id]) throw new Error(`Image id ${id} already exist, use updateImage instead`);\n if (this._validate(id, image)) {\n this.images[id] = image;\n }\n }\n\n _validate(id: string, image: StyleImage) {\n let valid = true;\n const data = image.data || image.spriteData;\n if (!this._validateStretch(image.stretchX, data && data.width)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"stretchX\" value`)));\n valid = false;\n }\n if (!this._validateStretch(image.stretchY, data && data.height)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"stretchY\" value`)));\n valid = false;\n }\n if (!this._validateContent(image.content, image)) {\n this.fire(new ErrorEvent(new Error(`Image \"${id}\" has invalid \"content\" value`)));\n valid = false;\n }\n return valid;\n }\n\n _validateStretch(stretch: Array<[number, number]>, size: number) {\n if (!stretch) return true;\n let last = 0;\n for (const part of stretch) {\n if (part[0] < last || part[1] < part[0] || size < part[1]) return false;\n last = part[1];\n }\n return true;\n }\n\n _validateContent(content: [number, number, number, number], image: StyleImage) {\n if (!content) return true;\n if (content.length !== 4) return false;\n const spriteData = image.spriteData;\n const width = (spriteData && spriteData.width) || image.data.width;\n const height = (spriteData && spriteData.height) || image.data.height;\n if (content[0] < 0 || width < content[0]) return false;\n if (content[1] < 0 || height < content[1]) return false;\n if (content[2] < 0 || width < content[2]) return false;\n if (content[3] < 0 || height < content[3]) return false;\n if (content[2] < content[0]) return false;\n if (content[3] < content[1]) return false;\n return true;\n }\n\n updateImage(id: string, image: StyleImage, validate = true) {\n const oldImage = this.getImage(id);\n if (validate && (oldImage.data.width !== image.data.width || oldImage.data.height !== image.data.height)) {\n throw new Error(`size mismatch between old image (${oldImage.data.width}x${oldImage.data.height}) and new image (${image.data.width}x${image.data.height}).`);\n }\n image.version = oldImage.version + 1;\n this.images[id] = image;\n this.updatedImages[id] = true;\n }\n\n removeImage(id: string) {\n const image = this.images[id];\n delete this.images[id];\n delete this.patterns[id];\n\n if (image.userImage && image.userImage.onRemove) {\n image.userImage.onRemove();\n }\n }\n\n listImages(): Array {\n return Object.keys(this.images);\n }\n\n getImages(ids: Array, callback: Callback<{[_: string]: StyleImage}>) {\n // If the sprite has been loaded, or if all the icon dependencies are already present\n // (i.e. if they've been added via runtime styling), then notify the requestor immediately.\n // Otherwise, delay notification until the sprite is loaded. At that point, if any of the\n // dependencies are still unavailable, we'll just assume they are permanently missing.\n let hasAllDependencies = true;\n if (!this.isLoaded()) {\n for (const id of ids) {\n if (!this.images[id]) {\n hasAllDependencies = false;\n }\n }\n }\n if (this.isLoaded() || hasAllDependencies) {\n this._notify(ids, callback);\n } else {\n this.requestors.push({ids, callback});\n }\n }\n\n _notify(ids: Array, callback: Callback<{[_: string]: StyleImage}>) {\n const response = {};\n\n for (const id of ids) {\n let image = this.getImage(id);\n\n if (!image) {\n this.fire(new Event('styleimagemissing', {id}));\n //Try to acquire image again in case styleimagemissing has populated it\n image = this.getImage(id);\n }\n\n if (image) {\n // Clone the image so that our own copy of its ArrayBuffer doesn't get transferred.\n response[id] = {\n data: image.data.clone(),\n pixelRatio: image.pixelRatio,\n sdf: image.sdf,\n version: image.version,\n stretchX: image.stretchX,\n stretchY: image.stretchY,\n content: image.content,\n hasRenderCallback: Boolean(image.userImage && image.userImage.render)\n };\n } else {\n warnOnce(`Image \"${id}\" could not be loaded. Please make sure you have added the image with map.addImage() or a \"sprite\" property in your style. You can provide missing images by listening for the \"styleimagemissing\" map event.`);\n }\n }\n\n callback(null, response);\n }\n\n // Pattern stuff\n\n getPixelSize() {\n const {width, height} = this.atlasImage;\n return {width, height};\n }\n\n getPattern(id: string): ImagePosition {\n const pattern = this.patterns[id];\n\n const image = this.getImage(id);\n if (!image) {\n return null;\n }\n\n if (pattern && pattern.position.version === image.version) {\n return pattern.position;\n }\n\n if (!pattern) {\n const w = image.data.width + padding * 2;\n const h = image.data.height + padding * 2;\n const bin = {w, h, x: 0, y: 0};\n const position = new ImagePosition(bin, image);\n this.patterns[id] = {bin, position};\n } else {\n pattern.position.version = image.version;\n }\n\n this._updatePatternAtlas();\n\n return this.patterns[id].position;\n }\n\n bind(context: Context) {\n const gl = context.gl;\n if (!this.atlasTexture) {\n this.atlasTexture = new Texture(context, this.atlasImage, gl.RGBA);\n } else if (this.dirty) {\n this.atlasTexture.update(this.atlasImage);\n this.dirty = false;\n }\n\n this.atlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n _updatePatternAtlas() {\n const bins = [];\n for (const id in this.patterns) {\n bins.push(this.patterns[id].bin);\n }\n\n const {w, h} = potpack(bins);\n\n const dst = this.atlasImage;\n dst.resize({width: w || 1, height: h || 1});\n\n for (const id in this.patterns) {\n const {bin} = this.patterns[id];\n const x = bin.x + padding;\n const y = bin.y + padding;\n const src = this.getImage(id).data;\n const w = src.width;\n const h = src.height;\n\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y}, {width: w, height: h});\n\n // Add 1 pixel wrapped padding on each side of the image.\n RGBAImage.copy(src, dst, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B\n RGBAImage.copy(src, dst, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L\n RGBAImage.copy(src, dst, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R\n }\n\n this.dirty = true;\n }\n\n beginFrame() {\n this.callbackDispatchedThisFrame = {};\n }\n\n dispatchRenderCallbacks(ids: Array) {\n for (const id of ids) {\n\n // the callback for the image was already dispatched for a different frame\n if (this.callbackDispatchedThisFrame[id]) continue;\n this.callbackDispatchedThisFrame[id] = true;\n\n const image = this.getImage(id);\n if (!image) warnOnce(`Image with ID: \"${id}\" was not found`);\n\n const updated = renderStyleImage(image);\n if (updated) {\n this.updateImage(id, image);\n }\n }\n }\n}\n","const INF = 1e20;\n\nexport default class TinySDF {\n constructor({\n fontSize = 24,\n buffer = 3,\n radius = 8,\n cutoff = 0.25,\n fontFamily = 'sans-serif',\n fontWeight = 'normal',\n fontStyle = 'normal'\n } = {}) {\n this.buffer = buffer;\n this.cutoff = cutoff;\n this.radius = radius;\n\n // make the canvas size big enough to both have the specified buffer around the glyph\n // for \"halo\", and account for some glyphs possibly being larger than their font size\n const size = this.size = fontSize + buffer * 4;\n\n const canvas = this._createCanvas(size);\n const ctx = this.ctx = canvas.getContext('2d', {willReadFrequently: true});\n ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;\n\n ctx.textBaseline = 'alphabetic';\n ctx.textAlign = 'left'; // Necessary so that RTL text doesn't have different alignment\n ctx.fillStyle = 'black';\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(size * size);\n this.gridInner = new Float64Array(size * size);\n this.f = new Float64Array(size);\n this.z = new Float64Array(size + 1);\n this.v = new Uint16Array(size);\n }\n\n _createCanvas(size) {\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = size;\n return canvas;\n }\n\n draw(char) {\n const {\n width: glyphAdvance,\n actualBoundingBoxAscent,\n actualBoundingBoxDescent,\n actualBoundingBoxLeft,\n actualBoundingBoxRight\n } = this.ctx.measureText(char);\n\n // The integer/pixel part of the top alignment is encoded in metrics.glyphTop\n // The remainder is implicitly encoded in the rasterization\n const glyphTop = Math.ceil(actualBoundingBoxAscent);\n const glyphLeft = 0;\n\n // If the glyph overflows the canvas size, it will be clipped at the bottom/right\n const glyphWidth = Math.max(0, Math.min(this.size - this.buffer, Math.ceil(actualBoundingBoxRight - actualBoundingBoxLeft)));\n const glyphHeight = Math.min(this.size - this.buffer, glyphTop + Math.ceil(actualBoundingBoxDescent));\n\n const width = glyphWidth + 2 * this.buffer;\n const height = glyphHeight + 2 * this.buffer;\n\n const len = Math.max(width * height, 0);\n const data = new Uint8ClampedArray(len);\n const glyph = {data, width, height, glyphWidth, glyphHeight, glyphTop, glyphLeft, glyphAdvance};\n if (glyphWidth === 0 || glyphHeight === 0) return glyph;\n\n const {ctx, buffer, gridInner, gridOuter} = this;\n ctx.clearRect(buffer, buffer, glyphWidth, glyphHeight);\n ctx.fillText(char, buffer, buffer + glyphTop);\n const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight);\n\n // Initialize grids outside the glyph range to alpha 0\n gridOuter.fill(INF, 0, len);\n gridInner.fill(0, 0, len);\n\n for (let y = 0; y < glyphHeight; y++) {\n for (let x = 0; x < glyphWidth; x++) {\n const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 255; // alpha value\n if (a === 0) continue; // empty pixels\n\n const j = (y + buffer) * width + x + buffer;\n\n if (a === 1) { // fully drawn pixels\n gridOuter[j] = 0;\n gridInner[j] = INF;\n\n } else { // aliased pixels\n const d = 0.5 - a;\n gridOuter[j] = d > 0 ? d * d : 0;\n gridInner[j] = d < 0 ? d * d : 0;\n }\n }\n }\n\n edt(gridOuter, 0, 0, width, height, width, this.f, this.v, this.z);\n edt(gridInner, buffer, buffer, glyphWidth, glyphHeight, width, this.f, this.v, this.z);\n\n for (let i = 0; i < len; i++) {\n const d = Math.sqrt(gridOuter[i]) - Math.sqrt(gridInner[i]);\n data[i] = Math.round(255 - 255 * (d / this.radius + this.cutoff));\n }\n\n return glyph;\n }\n}\n\n// 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nfunction edt(data, x0, y0, width, height, gridSize, f, v, z) {\n for (let x = x0; x < x0 + width; x++) edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z);\n for (let y = y0; y < y0 + height; y++) edt1d(data, y * gridSize + x0, 1, width, f, v, z);\n}\n\n// 1D squared distance transform\nfunction edt1d(grid, offset, stride, length, f, v, z) {\n v[0] = 0;\n z[0] = -INF;\n z[1] = INF;\n f[0] = grid[offset];\n\n for (let q = 1, k = 0, s = 0; q < length; q++) {\n f[q] = grid[offset + q * stride];\n const q2 = q * q;\n do {\n const r = v[k];\n s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2;\n } while (s <= z[k] && --k > -1);\n\n k++;\n v[k] = q;\n z[k] = s;\n z[k + 1] = INF;\n }\n\n for (let q = 0, k = 0; q < length; q++) {\n while (z[k + 1] < q) k++;\n const r = v[k];\n const qr = q - r;\n grid[offset + q * stride] = f[r] + qr * qr;\n }\n}\n","import {loadGlyphRange} from '../style/load_glyph_range';\n\nimport TinySDF from '@mapbox/tiny-sdf';\nimport {unicodeBlockLookup} from '../util/is_char_in_unicode_block';\nimport {asyncAll} from '../util/util';\nimport {AlphaImage} from '../util/image';\n\nimport type {StyleGlyph} from '../style/style_glyph';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\n\ntype Entry = {\n // null means we've requested the range, but the glyph wasn't included in the result.\n glyphs: {\n [id: number]: StyleGlyph | null;\n };\n requests: {\n [range: number]: Array>;\n };\n ranges: {\n [range: number]: boolean | null;\n };\n tinySDF?: TinySDF;\n};\n\nexport class GlyphManager {\n requestManager: RequestManager;\n localIdeographFontFamily: string;\n entries: {\n [_: string]: Entry;\n };\n url: string;\n\n // exposed as statics to enable stubbing in unit tests\n static loadGlyphRange = loadGlyphRange;\n static TinySDF = TinySDF;\n\n constructor(requestManager: RequestManager, localIdeographFontFamily?: string | null) {\n this.requestManager = requestManager;\n this.localIdeographFontFamily = localIdeographFontFamily;\n this.entries = {};\n }\n\n setURL(url?: string | null) {\n this.url = url;\n }\n\n getGlyphs(glyphs: {\n [stack: string]: Array;\n }, callback: Callback<{\n [stack: string]: {\n [id: number]: StyleGlyph;\n };\n }>) {\n const all = [];\n\n for (const stack in glyphs) {\n for (const id of glyphs[stack]) {\n all.push({stack, id});\n }\n }\n\n asyncAll(all, ({stack, id}, callback: Callback<{\n stack: string;\n id: number;\n glyph: StyleGlyph;\n }>) => {\n let entry = this.entries[stack];\n if (!entry) {\n entry = this.entries[stack] = {\n glyphs: {},\n requests: {},\n ranges: {}\n };\n }\n\n let glyph = entry.glyphs[id];\n if (glyph !== undefined) {\n callback(null, {stack, id, glyph});\n return;\n }\n\n glyph = this._tinySDF(entry, stack, id);\n if (glyph) {\n entry.glyphs[id] = glyph;\n callback(null, {stack, id, glyph});\n return;\n }\n\n const range = Math.floor(id / 256);\n if (range * 256 > 65535) {\n callback(new Error('glyphs > 65535 not supported'));\n return;\n }\n\n if (entry.ranges[range]) {\n callback(null, {stack, id, glyph});\n return;\n }\n\n if (!this.url) {\n callback(new Error('glyphsUrl is not set'));\n return;\n }\n\n let requests = entry.requests[range];\n if (!requests) {\n requests = entry.requests[range] = [];\n GlyphManager.loadGlyphRange(stack, range, this.url, this.requestManager,\n (err, response?: {\n [_: number]: StyleGlyph | null;\n } | null) => {\n if (response) {\n for (const id in response) {\n if (!this._doesCharSupportLocalGlyph(+id)) {\n entry.glyphs[+id] = response[+id];\n }\n }\n entry.ranges[range] = true;\n }\n for (const cb of requests) {\n cb(err, response);\n }\n delete entry.requests[range];\n });\n }\n\n requests.push((err, result?: {\n [_: number]: StyleGlyph | null;\n } | null) => {\n if (err) {\n callback(err);\n } else if (result) {\n callback(null, {stack, id, glyph: result[id] || null});\n }\n });\n }, (err, glyphs?: Array<{\n stack: string;\n id: number;\n glyph: StyleGlyph;\n }> | null) => {\n if (err) {\n callback(err);\n } else if (glyphs) {\n const result = {};\n\n for (const {stack, id, glyph} of glyphs) {\n // Clone the glyph so that our own copy of its ArrayBuffer doesn't get transferred.\n (result[stack] || (result[stack] = {}))[id] = glyph && {\n id: glyph.id,\n bitmap: glyph.bitmap.clone(),\n metrics: glyph.metrics\n };\n }\n\n callback(null, result);\n }\n });\n }\n\n _doesCharSupportLocalGlyph(id: number): boolean {\n /* eslint-disable new-cap */\n return !!this.localIdeographFontFamily &&\n (unicodeBlockLookup['CJK Unified Ideographs'](id) ||\n unicodeBlockLookup['Hangul Syllables'](id) ||\n unicodeBlockLookup['Hiragana'](id) ||\n unicodeBlockLookup['Katakana'](id));\n /* eslint-enable new-cap */\n }\n\n _tinySDF(entry: Entry, stack: string, id: number): StyleGlyph {\n const fontFamily = this.localIdeographFontFamily;\n if (!fontFamily) {\n return;\n }\n\n if (!this._doesCharSupportLocalGlyph(id)) {\n return;\n }\n\n // Client-generated glyphs are rendered at 2x texture scale,\n // because CJK glyphs are more detailed than others.\n const textureScale = 2;\n\n let tinySDF = entry.tinySDF;\n if (!tinySDF) {\n let fontWeight = '400';\n if (/bold/i.test(stack)) {\n fontWeight = '900';\n } else if (/medium/i.test(stack)) {\n fontWeight = '500';\n } else if (/light/i.test(stack)) {\n fontWeight = '200';\n }\n tinySDF = entry.tinySDF = new GlyphManager.TinySDF({\n fontSize: 24 * textureScale,\n buffer: 3 * textureScale,\n radius: 8 * textureScale,\n cutoff: 0.25,\n fontFamily,\n fontWeight\n });\n }\n\n const char = tinySDF.draw(String.fromCharCode(id));\n\n /**\n * TinySDF's \"top\" is the distance from the alphabetic baseline to the top of the glyph.\n * Server-generated fonts specify \"top\" relative to an origin above the em box (the origin\n * comes from FreeType, but I'm unclear on exactly how it's derived)\n * ref: https://github.com/mapbox/sdf-glyph-foundry\n *\n * Server fonts don't yet include baseline information, so we can't line up exactly with them\n * (and they don't line up with each other)\n * ref: https://github.com/mapbox/node-fontnik/pull/160\n *\n * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment\n * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode)\n */\n const topAdjustment = 27.5;\n\n const leftAdjustment = 0.5;\n\n return {\n id,\n bitmap: new AlphaImage({width: char.width || 30 * textureScale, height: char.height || 30 * textureScale}, char.data),\n metrics: {\n width: char.glyphWidth / textureScale || 24,\n height: char.glyphHeight / textureScale || 24,\n left: (char.glyphLeft / textureScale + leftAdjustment) || 0,\n top: char.glyphTop / textureScale - topAdjustment || -8,\n advance: char.glyphAdvance / textureScale || 24,\n isDoubleResolution: true\n }\n };\n }\n}\n","import {getArrayBuffer} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\n\nimport {parseGlyphPbf} from './parse_glyph_pbf';\n\nimport type {StyleGlyph} from './style_glyph';\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\n\nexport function loadGlyphRange(fontstack: string,\n range: number,\n urlTemplate: string,\n requestManager: RequestManager,\n callback: Callback<{\n [_: number]: StyleGlyph | null;\n }>) {\n const begin = range * 256;\n const end = begin + 255;\n\n const request = requestManager.transformRequest(\n urlTemplate.replace('{fontstack}', fontstack).replace('{range}', `${begin}-${end}`),\n ResourceType.Glyphs\n );\n\n getArrayBuffer(request, (err?: Error | null, data?: ArrayBuffer | null) => {\n if (err) {\n callback(err);\n } else if (data) {\n const glyphs = {};\n\n for (const glyph of parseGlyphPbf(data)) {\n glyphs[glyph.id] = glyph;\n }\n\n callback(null, glyphs);\n }\n });\n}\n","import {interpolates, Color, latest as styleSpec} from '@maplibre/maplibre-gl-style-spec';\n\nimport {extend, sphericalToCartesian} from '../util/util';\nimport {Evented} from '../util/evented';\nimport {\n validateStyle,\n validateLight,\n emitValidationErrors\n} from './validate_style';\n\nimport type {StylePropertySpecification, LightSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {EvaluationParameters} from './evaluation_parameters';\nimport type {StyleSetterOptions} from '../style/style';\nimport {Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty} from './properties';\n\nimport type {\n Property,\n PropertyValue,\n TransitionParameters\n} from './properties';\n\ntype LightPosition = {\n x: number;\n y: number;\n z: number;\n};\n\nclass LightPositionProperty implements Property<[number, number, number], LightPosition> {\n specification: StylePropertySpecification;\n\n constructor() {\n this.specification = styleSpec.light.position as StylePropertySpecification;\n }\n\n possiblyEvaluate(\n value: PropertyValue<[number, number, number], LightPosition>,\n parameters: EvaluationParameters\n ): LightPosition {\n return sphericalToCartesian(value.expression.evaluate(parameters));\n }\n\n interpolate(a: LightPosition, b: LightPosition, t: number): LightPosition {\n return {\n x: interpolates.number(a.x, b.x, t),\n y: interpolates.number(a.y, b.y, t),\n z: interpolates.number(a.z, b.z, t),\n };\n }\n}\n\ntype Props = {\n 'anchor': DataConstantProperty<'map' | 'viewport'>;\n 'position': LightPositionProperty;\n 'color': DataConstantProperty;\n 'intensity': DataConstantProperty;\n};\n\ntype PropsPossiblyEvaluated = {\n 'anchor': 'map' | 'viewport';\n 'position': LightPosition;\n 'color': Color;\n 'intensity': number;\n};\n\nconst TRANSITION_SUFFIX = '-transition';\n\nlet lightProperties: Properties;\n\n/*\n * Represents the light used to light extruded features.\n */\nexport class Light extends Evented {\n _transitionable: Transitionable;\n _transitioning: Transitioning;\n properties: PossiblyEvaluated;\n\n constructor(lightOptions?: LightSpecification) {\n super();\n lightProperties = lightProperties || new Properties({\n 'anchor': new DataConstantProperty(styleSpec.light.anchor as StylePropertySpecification),\n 'position': new LightPositionProperty(),\n 'color': new DataConstantProperty(styleSpec.light.color as StylePropertySpecification),\n 'intensity': new DataConstantProperty(styleSpec.light.intensity as StylePropertySpecification),\n });\n this._transitionable = new Transitionable(lightProperties);\n this.setLight(lightOptions);\n this._transitioning = this._transitionable.untransitioned();\n }\n\n getLight(): LightSpecification {\n return this._transitionable.serialize();\n }\n\n setLight(light?: LightSpecification, options: StyleSetterOptions = {}) {\n if (this._validate(validateLight, light, options)) {\n return;\n }\n\n for (const name in light) {\n const value = light[name];\n if (name.endsWith(TRANSITION_SUFFIX)) {\n this._transitionable.setTransition(name.slice(0, -TRANSITION_SUFFIX.length) as keyof Props, value);\n } else {\n this._transitionable.setValue(name as keyof Props, value);\n }\n }\n }\n\n updateTransitions(parameters: TransitionParameters) {\n this._transitioning = this._transitionable.transitioned(parameters, this._transitioning);\n }\n\n hasTransition() {\n return this._transitioning.hasTransition();\n }\n\n recalculate(parameters: EvaluationParameters) {\n this.properties = this._transitioning.possiblyEvaluate(parameters);\n }\n\n _validate(validate: Function, value: unknown, options?: {\n validate?: boolean;\n }) {\n if (options && options.validate === false) {\n return false;\n }\n\n return emitValidationErrors(this, validate.call(validateStyle, extend({\n value,\n // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407\n style: {glyphs: true, sprite: true},\n styleSpec\n })));\n }\n}\n","import {warnOnce} from '../util/util';\n\nimport type {Context} from '../gl/context';\n\n/**\n * A dash entry\n */\ntype DashEntry = {\n y: number;\n height: number;\n width: number;\n}\n\n/**\n * @internal\n * A LineAtlas lets us reuse rendered dashed lines\n * by writing many of them to a texture and then fetching their positions\n * using {@link LineAtlas#getDash}.\n *\n * @param width - the width\n * @param height - the height\n */\nexport class LineAtlas {\n width: number;\n height: number;\n nextRow: number;\n bytes: number;\n data: Uint8Array;\n dashEntry: {[_: string]: DashEntry};\n dirty: boolean;\n texture: WebGLTexture;\n\n constructor(width: number, height: number) {\n this.width = width;\n this.height = height;\n this.nextRow = 0;\n\n this.data = new Uint8Array(this.width * this.height);\n\n this.dashEntry = {};\n }\n\n /**\n * Get or create a dash line pattern.\n *\n * @param dasharray - the key (represented by numbers) to get the dash texture\n * @param round - whether to add circle caps in between dash segments\n * @returns position of dash texture in {@link DashEntry}\n */\n getDash(dasharray: Array, round: boolean) {\n const key = dasharray.join(',') + String(round);\n\n if (!this.dashEntry[key]) {\n this.dashEntry[key] = this.addDash(dasharray, round);\n }\n return this.dashEntry[key];\n }\n\n getDashRanges(dasharray: Array, lineAtlasWidth: number, stretch: number) {\n // If dasharray has an odd length, both the first and last parts\n // are dashes and should be joined seamlessly.\n const oddDashArray = dasharray.length % 2 === 1;\n\n const ranges = [];\n\n let left = oddDashArray ? -dasharray[dasharray.length - 1] * stretch : 0;\n let right = dasharray[0] * stretch;\n let isDash = true;\n\n ranges.push({left, right, isDash, zeroLength: dasharray[0] === 0});\n\n let currentDashLength = dasharray[0];\n for (let i = 1; i < dasharray.length; i++) {\n isDash = !isDash;\n\n const dashLength = dasharray[i];\n left = currentDashLength * stretch;\n currentDashLength += dashLength;\n right = currentDashLength * stretch;\n\n ranges.push({left, right, isDash, zeroLength: dashLength === 0});\n }\n\n return ranges;\n }\n\n addRoundDash(ranges: any, stretch: number, n: number) {\n const halfStretch = stretch / 2;\n\n for (let y = -n; y <= n; y++) {\n const row = this.nextRow + n + y;\n const index = this.width * row;\n let currIndex = 0;\n let range = ranges[currIndex];\n\n for (let x = 0; x < this.width; x++) {\n if (x / range.right > 1) { range = ranges[++currIndex]; }\n\n const distLeft = Math.abs(x - range.left);\n const distRight = Math.abs(x - range.right);\n const minDist = Math.min(distLeft, distRight);\n let signedDistance;\n\n const distMiddle = y / n * (halfStretch + 1);\n if (range.isDash) {\n const distEdge = halfStretch - Math.abs(distMiddle);\n signedDistance = Math.sqrt(minDist * minDist + distEdge * distEdge);\n } else {\n signedDistance = halfStretch - Math.sqrt(minDist * minDist + distMiddle * distMiddle);\n }\n\n this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128));\n }\n }\n }\n\n addRegularDash(ranges: any) {\n\n // Collapse any zero-length range\n // Collapse neighbouring same-type parts into a single part\n for (let i = ranges.length - 1; i >= 0; --i) {\n const part = ranges[i];\n const next = ranges[i + 1];\n if (part.zeroLength) {\n ranges.splice(i, 1);\n } else if (next && next.isDash === part.isDash) {\n next.left = part.left;\n ranges.splice(i, 1);\n }\n }\n\n // Combine the first and last parts if possible\n const first = ranges[0];\n const last = ranges[ranges.length - 1];\n if (first.isDash === last.isDash) {\n first.left = last.left - this.width;\n last.right = first.right + this.width;\n }\n\n const index = this.width * this.nextRow;\n let currIndex = 0;\n let range = ranges[currIndex];\n\n for (let x = 0; x < this.width; x++) {\n if (x / range.right > 1) {\n range = ranges[++currIndex];\n }\n\n const distLeft = Math.abs(x - range.left);\n const distRight = Math.abs(x - range.right);\n\n const minDist = Math.min(distLeft, distRight);\n const signedDistance = range.isDash ? minDist : -minDist;\n\n this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128));\n }\n }\n\n addDash(dasharray: Array, round: boolean): DashEntry {\n const n = round ? 7 : 0;\n const height = 2 * n + 1;\n\n if (this.nextRow + height > this.height) {\n warnOnce('LineAtlas out of space');\n return null;\n }\n\n let length = 0;\n for (let i = 0; i < dasharray.length; i++) { length += dasharray[i]; }\n\n if (length !== 0) {\n const stretch = this.width / length;\n const ranges = this.getDashRanges(dasharray, this.width, stretch);\n\n if (round) {\n this.addRoundDash(ranges, stretch, n);\n } else {\n this.addRegularDash(ranges);\n }\n }\n\n const dashEntry = {\n y: (this.nextRow + n + 0.5) / this.height,\n height: 2 * n / this.height,\n width: length\n };\n\n this.nextRow += height;\n this.dirty = true;\n\n return dashEntry;\n }\n\n bind(context: Context) {\n const gl = context.gl;\n if (!this.texture) {\n this.texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, this.width, this.height, 0, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);\n\n } else {\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n\n if (this.dirty) {\n this.dirty = false;\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);\n }\n }\n }\n}\n","import {asyncAll} from './util';\nimport {Actor, GlyphsProvider, MessageType} from './actor';\n\nimport type {WorkerPool} from './worker_pool';\nimport type {WorkerSource} from '../source/worker_source'; /* eslint-disable-line */ // this is used for the docs' import\n/**\n * Responsible for sending messages from a {@link Source} to an associated\n * {@link WorkerSource}.\n */\nexport class Dispatcher {\n workerPool: WorkerPool;\n actors: Array;\n currentActor: number;\n id: string | number;\n\n constructor(workerPool: WorkerPool, parent: GlyphsProvider, mapId: string | number) {\n this.workerPool = workerPool;\n this.actors = [];\n this.currentActor = 0;\n this.id = mapId;\n const workers = this.workerPool.acquire(mapId);\n for (let i = 0; i < workers.length; i++) {\n const worker = workers[i];\n const actor = new Actor(worker, parent, mapId);\n actor.name = `Worker ${i}`;\n this.actors.push(actor);\n }\n if (!this.actors.length) throw new Error('No actors found');\n }\n\n /**\n * Broadcast a message to all Workers.\n */\n broadcast(type: MessageType, data: unknown, cb?: (...args: any[]) => any) {\n cb = cb || function () {};\n asyncAll(this.actors, (actor, done) => {\n actor.send(type, data, done);\n }, cb);\n }\n\n /**\n * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion.\n * @returns An actor object backed by a web worker for processing messages.\n */\n getActor(): Actor {\n this.currentActor = (this.currentActor + 1) % this.actors.length;\n return this.actors[this.currentActor];\n }\n\n remove(mapRemoved: boolean = true) {\n this.actors.forEach((actor) => { actor.remove(); });\n this.actors = [];\n if (mapRemoved) this.workerPool.release(this.id);\n }\n}\n","import {pick, extend} from '../util/util';\n\nimport {getJSON} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\n\nimport type {RequestManager} from '../util/request_manager';\nimport type {Callback} from '../types/callback';\nimport type {TileJSON} from '../types/tilejson';\nimport type {Cancelable} from '../types/cancelable';\nimport type {RasterDEMSourceSpecification, RasterSourceSpecification, VectorSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport function loadTileJson(\n options: RasterSourceSpecification | RasterDEMSourceSpecification | VectorSourceSpecification,\n requestManager: RequestManager,\n callback: Callback\n): Cancelable {\n const loaded = function(err: Error, tileJSON: any) {\n if (err) {\n return callback(err);\n } else if (tileJSON) {\n const result: any = pick(\n // explicit source options take precedence over TileJSON\n extend(tileJSON, options),\n ['tiles', 'minzoom', 'maxzoom', 'attribution', 'bounds', 'scheme', 'tileSize', 'encoding']\n );\n\n if (tileJSON.vector_layers) {\n result.vectorLayers = tileJSON.vector_layers;\n result.vectorLayerIds = result.vectorLayers.map((layer) => { return layer.id; });\n }\n\n callback(null, result);\n }\n };\n\n if (options.url) {\n return getJSON(requestManager.transformRequest(options.url, ResourceType.Source), loaded);\n } else {\n return browser.frame(() => loaded(null, options));\n }\n}\n","import {LngLat} from './lng_lat';\nimport type {LngLatLike} from './lng_lat';\n\n/**\n * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,\n * or an array of numbers in [west, south, east, north] order.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let v1 = new maplibregl.LngLatBounds(\n * new maplibregl.LngLat(-73.9876, 40.7661),\n * new maplibregl.LngLat(-73.9397, 40.8002)\n * );\n * let v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])\n * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];\n * ```\n */\nexport type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number];\n\n/**\n * A `LngLatBounds` object represents a geographical bounding box,\n * defined by its southwest and northeast points in longitude and latitude.\n *\n * If no arguments are provided to the constructor, a `null` bounding box is created.\n *\n * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option\n * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.\n * This flexible type is documented as {@link LngLatBoundsLike}.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let sw = new maplibregl.LngLat(-73.9876, 40.7661);\n * let ne = new maplibregl.LngLat(-73.9397, 40.8002);\n * let llb = new maplibregl.LngLatBounds(sw, ne);\n * ```\n */\nexport class LngLatBounds {\n _ne: LngLat;\n _sw: LngLat;\n\n /**\n * @param sw - The southwest corner of the bounding box.\n * OR array of 4 numbers in the order of west, south, east, north\n * OR array of 2 LngLatLike: [sw,ne]\n * @param ne - The northeast corner of the bounding box.\n * @example\n * ```ts\n * let sw = new maplibregl.LngLat(-73.9876, 40.7661);\n * let ne = new maplibregl.LngLat(-73.9397, 40.8002);\n * let llb = new maplibregl.LngLatBounds(sw, ne);\n * ```\n * OR\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]);\n * ```\n * OR\n * ```ts\n * let llb = new maplibregl.LngLatBounds([sw, ne]);\n * ```\n */\n constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike) {\n if (!sw) {\n // noop\n } else if (ne) {\n this.setSouthWest(sw).setNorthEast(ne);\n } else if (Array.isArray(sw)) {\n if (sw.length === 4) {\n // 4 element array: west, south, east, north\n this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);\n } else {\n this.setSouthWest(sw[0] as LngLatLike).setNorthEast(sw[1] as LngLatLike);\n }\n }\n }\n\n /**\n * Set the northeast corner of the bounding box\n *\n * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box.\n * @returns `this`\n */\n setNorthEast(ne: LngLatLike): this {\n this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);\n return this;\n }\n\n /**\n * Set the southwest corner of the bounding box\n *\n * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box.\n * @returns `this`\n */\n setSouthWest(sw: LngLatLike): this {\n this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);\n return this;\n }\n\n /**\n * Extend the bounds to include a given LngLatLike or LngLatBoundsLike.\n *\n * @param obj - object to extend to\n * @returns `this`\n */\n extend(obj: LngLatLike | LngLatBoundsLike): this {\n const sw = this._sw,\n ne = this._ne;\n let sw2, ne2;\n\n if (obj instanceof LngLat) {\n sw2 = obj;\n ne2 = obj;\n\n } else if (obj instanceof LngLatBounds) {\n sw2 = obj._sw;\n ne2 = obj._ne;\n\n if (!sw2 || !ne2) return this;\n\n } else {\n if (Array.isArray(obj)) {\n if (obj.length === 4 || (obj as any[]).every(Array.isArray)) {\n const lngLatBoundsObj = (obj as any as LngLatBoundsLike);\n return this.extend(LngLatBounds.convert(lngLatBoundsObj));\n } else {\n const lngLatObj = (obj as any as LngLatLike);\n return this.extend(LngLat.convert(lngLatObj));\n }\n\n } else if (obj && ('lng' in obj || 'lon' in obj) && 'lat' in obj) {\n return this.extend(LngLat.convert(obj));\n }\n\n return this;\n }\n\n if (!sw && !ne) {\n this._sw = new LngLat(sw2.lng, sw2.lat);\n this._ne = new LngLat(ne2.lng, ne2.lat);\n\n } else {\n sw.lng = Math.min(sw2.lng, sw.lng);\n sw.lat = Math.min(sw2.lat, sw.lat);\n ne.lng = Math.max(ne2.lng, ne.lng);\n ne.lat = Math.max(ne2.lat, ne.lat);\n }\n\n return this;\n }\n\n /**\n * Returns the geographical coordinate equidistant from the bounding box's corners.\n *\n * @returns The bounding box's center.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}\n * ```\n */\n getCenter(): LngLat {\n return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);\n }\n\n /**\n * Returns the southwest corner of the bounding box.\n *\n * @returns The southwest corner of the bounding box.\n */\n getSouthWest(): LngLat { return this._sw; }\n\n /**\n * Returns the northeast corner of the bounding box.\n *\n * @returns The northeast corner of the bounding box.\n */\n getNorthEast(): LngLat { return this._ne; }\n\n /**\n * Returns the northwest corner of the bounding box.\n *\n * @returns The northwest corner of the bounding box.\n */\n getNorthWest(): LngLat { return new LngLat(this.getWest(), this.getNorth()); }\n\n /**\n * Returns the southeast corner of the bounding box.\n *\n * @returns The southeast corner of the bounding box.\n */\n getSouthEast(): LngLat { return new LngLat(this.getEast(), this.getSouth()); }\n\n /**\n * Returns the west edge of the bounding box.\n *\n * @returns The west edge of the bounding box.\n */\n getWest(): number { return this._sw.lng; }\n\n /**\n * Returns the south edge of the bounding box.\n *\n * @returns The south edge of the bounding box.\n */\n getSouth(): number { return this._sw.lat; }\n\n /**\n * Returns the east edge of the bounding box.\n *\n * @returns The east edge of the bounding box.\n */\n getEast(): number { return this._ne.lng; }\n\n /**\n * Returns the north edge of the bounding box.\n *\n * @returns The north edge of the bounding box.\n */\n getNorth(): number { return this._ne.lat; }\n\n /**\n * Returns the bounding box represented as an array.\n *\n * @returns The bounding box represented as an array, consisting of the\n * southwest and northeast coordinates of the bounding represented as arrays of numbers.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]\n * ```\n */\n toArray() {\n return [this._sw.toArray(), this._ne.toArray()];\n }\n\n /**\n * Return the bounding box represented as a string.\n *\n * @returns The bounding box represents as a string of the format\n * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);\n * llb.toString(); // = \"LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))\"\n * ```\n */\n toString() {\n return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;\n }\n\n /**\n * Check if the bounding box is an empty/`null`-type box.\n *\n * @returns True if bounds have been defined, otherwise false.\n */\n isEmpty() {\n return !(this._sw && this._ne);\n }\n\n /**\n * Check if the point is within the bounding box.\n *\n * @param lnglat - geographic point to check against.\n * @returns `true` if the point is within the bounding box.\n * @example\n * ```ts\n * let llb = new maplibregl.LngLatBounds(\n * new maplibregl.LngLat(-73.9876, 40.7661),\n * new maplibregl.LngLat(-73.9397, 40.8002)\n * );\n *\n * let ll = new maplibregl.LngLat(-73.9567, 40.7789);\n *\n * console.log(llb.contains(ll)); // = true\n * ```\n */\n contains(lnglat: LngLatLike) {\n const {lng, lat} = LngLat.convert(lnglat);\n\n const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat;\n let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng;\n if (this._sw.lng > this._ne.lng) { // wrapped coordinates\n containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng;\n }\n\n return containsLatitude && containsLongitude;\n }\n\n /**\n * Converts an array to a `LngLatBounds` object.\n *\n * If a `LngLatBounds` object is passed in, the function returns it unchanged.\n *\n * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.\n *\n * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return.\n * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.\n * @example\n * ```ts\n * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];\n * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}\n * ```\n */\n static convert(input: LngLatBoundsLike | null): LngLatBounds {\n if (input instanceof LngLatBounds) return input;\n if (!input) return input as null;\n return new LngLatBounds(input);\n }\n\n /**\n * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.\n *\n * @param center - center coordinates of the new bounds.\n * @param radius - Distance in meters from the coordinates to extend the bounds.\n * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`.\n * @example\n * ```ts\n * let center = new maplibregl.LngLat(-73.9749, 40.7736);\n * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]\n * ```\n */\n static fromLngLat(center: LngLat, radius:number = 0): LngLatBounds {\n const earthCircumferenceInMetersAtEquator = 40075017;\n const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator,\n lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * center.lat);\n\n return new LngLatBounds(new LngLat(center.lng - lngAccuracy, center.lat - latAccuracy),\n new LngLat(center.lng + lngAccuracy, center.lat + latAccuracy));\n }\n}\n","import {LngLatBounds, LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport {mercatorXfromLng, mercatorYfromLat} from '../geo/mercator_coordinate';\n\nimport type {CanonicalTileID} from './tile_id';\n\nexport class TileBounds {\n bounds: LngLatBounds;\n minzoom: number;\n maxzoom: number;\n\n constructor(bounds: [number, number, number, number], minzoom?: number | null, maxzoom?: number | null) {\n this.bounds = LngLatBounds.convert(this.validateBounds(bounds));\n this.minzoom = minzoom || 0;\n this.maxzoom = maxzoom || 24;\n }\n\n validateBounds(bounds: [number, number, number, number]): LngLatBoundsLike {\n // make sure the bounds property contains valid longitude and latitudes\n if (!Array.isArray(bounds) || bounds.length !== 4) return [-180, -90, 180, 90];\n return [Math.max(-180, bounds[0]), Math.max(-90, bounds[1]), Math.min(180, bounds[2]), Math.min(90, bounds[3])];\n }\n\n contains(tileID: CanonicalTileID) {\n const worldSize = Math.pow(2, tileID.z);\n const level = {\n minX: Math.floor(mercatorXfromLng(this.bounds.getWest()) * worldSize),\n minY: Math.floor(mercatorYfromLat(this.bounds.getNorth()) * worldSize),\n maxX: Math.ceil(mercatorXfromLng(this.bounds.getEast()) * worldSize),\n maxY: Math.ceil(mercatorYfromLat(this.bounds.getSouth()) * worldSize)\n };\n const hit = tileID.x >= level.minX && tileID.x < level.maxX && tileID.y >= level.minY && tileID.y < level.maxY;\n return hit;\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\n\nimport {extend, pick} from '../util/util';\nimport {loadTileJson} from './load_tilejson';\nimport {TileBounds} from './tile_bounds';\nimport {ResourceType} from '../util/request_manager';\n\nimport type {Source} from './source';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport type {VectorSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type VectorTileSourceOptions = VectorSourceSpecification & {\n collectResourceTiming?: boolean;\n}\n\n/**\n * A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/).\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'vector',\n * tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],\n * minzoom: 6,\n * maxzoom: 14\n * });\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setUrl(\"https://demotiles.maplibre.org/tiles/tiles.json\");\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);\n * ```\n * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)\n */\nexport class VectorTileSource extends Evented implements Source {\n type: 'vector';\n id: string;\n minzoom: number;\n maxzoom: number;\n url: string;\n scheme: string;\n tileSize: number;\n promoteId: PromoteIdSpecification;\n\n _options: VectorSourceSpecification;\n _collectResourceTiming: boolean;\n dispatcher: Dispatcher;\n map: Map;\n bounds: [number, number, number, number];\n tiles: Array;\n tileBounds: TileBounds;\n reparseOverscaled: boolean;\n isTileClipped: boolean;\n _tileJSONRequest: Cancelable;\n _loaded: boolean;\n\n constructor(id: string, options: VectorTileSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n\n this.type = 'vector';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.scheme = 'xyz';\n this.tileSize = 512;\n this.reparseOverscaled = true;\n this.isTileClipped = true;\n this._loaded = false;\n\n extend(this, pick(options, ['url', 'scheme', 'tileSize', 'promoteId']));\n this._options = extend({type: 'vector'}, options);\n\n this._collectResourceTiming = options.collectResourceTiming;\n\n if (this.tileSize !== 512) {\n throw new Error('vector tile sources must have a tileSize of 512');\n }\n\n this.setEventedParent(eventedParent);\n }\n\n load = () => {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {\n this._tileJSONRequest = null;\n this._loaded = true;\n this.map.style.sourceCaches[this.id].clearTiles();\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (tileJSON) {\n extend(this, tileJSON);\n if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);\n\n // `content` is included here to prevent a race condition where `Style#_updateSources` is called\n // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives\n // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n }\n });\n };\n\n loaded(): boolean {\n return this._loaded;\n }\n\n hasTile(tileID: OverscaledTileID) {\n return !this.tileBounds || this.tileBounds.contains(tileID.canonical);\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n setSourceProperty(callback: Function) {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n }\n\n callback();\n\n this.load();\n }\n\n /**\n * Sets the source `tiles` property and re-renders the map.\n *\n * @param tiles - An array of one or more tile source URLs, as in the TileJSON spec.\n * @returns `this`\n */\n setTiles(tiles: Array): this {\n this.setSourceProperty(() => {\n this._options.tiles = tiles;\n });\n\n return this;\n }\n\n /**\n * Sets the source `url` property and re-renders the map.\n *\n * @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`.\n * @returns `this`\n */\n setUrl(url: string): this {\n this.setSourceProperty(() => {\n this.url = url;\n this._options.url = url;\n });\n\n return this;\n }\n\n onRemove() {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n this._tileJSONRequest = null;\n }\n }\n\n serialize = (): VectorSourceSpecification => {\n return extend({}, this._options);\n };\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n const params = {\n request: this.map._requestManager.transformRequest(url, ResourceType.Tile),\n uid: tile.uid,\n tileID: tile.tileID,\n zoom: tile.tileID.overscaledZ,\n tileSize: this.tileSize * tile.tileID.overscaleFactor(),\n type: this.type,\n source: this.id,\n pixelRatio: this.map.getPixelRatio(),\n showCollisionBoxes: this.map.showCollisionBoxes,\n promoteId: this.promoteId\n };\n params.request.collectResourceTiming = this._collectResourceTiming;\n\n if (!tile.actor || tile.state === 'expired') {\n tile.actor = this.dispatcher.getActor();\n tile.request = tile.actor.send('loadTile', params, done.bind(this));\n } else if (tile.state === 'loading') {\n // schedule tile reloading after it has been loaded\n tile.reloadCallback = callback;\n } else {\n tile.request = tile.actor.send('reloadTile', params, done.bind(this));\n }\n\n function done(err, data) {\n delete tile.request;\n\n if (tile.aborted)\n return callback(null);\n\n if (err && err.status !== 404) {\n return callback(err);\n }\n\n if (data && data.resourceTiming)\n tile.resourceTiming = data.resourceTiming;\n\n if (this.map._refreshExpiredTiles && data) tile.setExpiryData(data);\n tile.loadVectorData(data, this.map.painter);\n\n callback(null);\n\n if (tile.reloadCallback) {\n this.loadTile(tile, tile.reloadCallback);\n tile.reloadCallback = null;\n }\n }\n }\n\n abortTile(tile: Tile) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n if (tile.actor) {\n tile.actor.send('abortTile', {uid: tile.uid, type: this.type, source: this.id}, undefined);\n }\n }\n\n unloadTile(tile: Tile) {\n tile.unloadVectorData();\n if (tile.actor) {\n tile.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}, undefined);\n }\n }\n\n hasTransition() {\n return false;\n }\n}\n","import {extend, pick} from '../util/util';\n\nimport {ImageRequest} from '../util/image_request';\n\nimport {ResourceType} from '../util/request_manager';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {loadTileJson} from './load_tilejson';\nimport {TileBounds} from './tile_bounds';\nimport {Texture} from '../render/texture';\n\nimport type {Source} from './source';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {Cancelable} from '../types/cancelable';\nimport type {\n RasterSourceSpecification,\n RasterDEMSourceSpecification\n} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A source containing raster tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('raster-source', {\n * 'type': 'raster',\n * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'],\n * 'tileSize': 256,\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('wms-test-source', {\n * 'type': 'raster',\n * // use the tiles option to specify a WMS tile source URL\n * 'tiles': [\n * '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'\n * ],\n * 'tileSize': 256\n * });\n * ```\n * @see [Add a raster tile source](https://maplibre.org/maplibre-gl-js/docs/examples/map-tiles/)\n * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/)\n * @see [Display a satellite map](https://maplibre.org/maplibre-gl-js/docs/examples/satellite-map/)\n */\nexport class RasterTileSource extends Evented implements Source {\n type: 'raster' | 'raster-dem';\n id: string;\n minzoom: number;\n maxzoom: number;\n url: string;\n scheme: string;\n tileSize: number;\n\n bounds: [number, number, number, number];\n tileBounds: TileBounds;\n roundZoom: boolean;\n dispatcher: Dispatcher;\n map: Map;\n tiles: Array;\n\n _loaded: boolean;\n _options: RasterSourceSpecification | RasterDEMSourceSpecification;\n _tileJSONRequest: Cancelable;\n\n constructor(id: string, options: RasterSourceSpecification | RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n this.setEventedParent(eventedParent);\n\n this.type = 'raster';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.roundZoom = true;\n this.scheme = 'xyz';\n this.tileSize = 512;\n this._loaded = false;\n\n this._options = extend({type: 'raster'}, options);\n extend(this, pick(options, ['url', 'scheme', 'tileSize']));\n }\n\n load() {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {\n this._tileJSONRequest = null;\n this._loaded = true;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (tileJSON) {\n extend(this, tileJSON);\n if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);\n\n // `content` is included here to prevent a race condition where `Style#_updateSources` is called\n // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives\n // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n }\n });\n }\n\n loaded(): boolean {\n return this._loaded;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n onRemove() {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n this._tileJSONRequest = null;\n }\n }\n\n setSourceProperty(callback: Function) {\n if (this._tileJSONRequest) {\n this._tileJSONRequest.cancel();\n }\n\n callback();\n\n this.load();\n }\n\n /**\n * Sets the source `tiles` property and re-renders the map.\n *\n * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/)\n * @returns `this`\n */\n setTiles(tiles: Array): this {\n this.setSourceProperty(() => {\n this._options.tiles = tiles;\n });\n\n return this;\n }\n\n serialize() {\n return extend({}, this._options);\n }\n\n hasTile(tileID: OverscaledTileID) {\n return !this.tileBounds || this.tileBounds.contains(tileID.canonical);\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), (err, img, expiry) => {\n delete tile.request;\n\n if (tile.aborted) {\n tile.state = 'unloaded';\n callback(null);\n } else if (err) {\n tile.state = 'errored';\n callback(err);\n } else if (img) {\n if (this.map._refreshExpiredTiles && expiry) tile.setExpiryData(expiry);\n\n const context = this.map.painter.context;\n const gl = context.gl;\n tile.texture = this.map.painter.getTileTexture(img.width);\n if (tile.texture) {\n tile.texture.update(img, {useMipmap: true});\n } else {\n tile.texture = new Texture(context, img, gl.RGBA, {useMipmap: true});\n tile.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n\n if (context.extTextureFilterAnisotropic) {\n gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax);\n }\n }\n\n tile.state = 'loaded';\n\n callback(null);\n }\n }, this.map._refreshExpiredTiles);\n }\n\n abortTile(tile: Tile, callback: Callback) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n callback();\n }\n\n unloadTile(tile: Tile, callback: Callback) {\n if (tile.texture) this.map.painter.saveTileTexture(tile.texture);\n callback();\n }\n\n hasTransition() {\n return false;\n }\n}\n","import {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\nimport {extend, isImageBitmap, readImageUsingVideoFrame} from '../util/util';\nimport {Evented} from '../util/evented';\nimport {browser} from '../util/browser';\nimport {offscreenCanvasSupported} from '../util/offscreen_canvas_supported';\nimport {OverscaledTileID} from './tile_id';\nimport {RasterTileSource} from './raster_tile_source';\n// ensure DEMData is registered for worker transfer on main thread:\nimport '../data/dem_data';\nimport type {DEMEncoding} from '../data/dem_data';\n\nimport type {Source} from './source';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {RasterDEMSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {ExpiryData} from '../util/ajax';\nimport {isOffscreenCanvasDistorted} from '../util/offscreen_canvas_distorted';\nimport {RGBAImage} from '../util/image';\n\n/**\n * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)\n * This source can be used to show hillshading and 3D terrain\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('raster-dem-source', {\n * type: 'raster-dem',\n * url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',\n * tileSize: 256\n * });\n * ```\n * @see [3D Terrain](https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/)\n */\nexport class RasterDEMTileSource extends RasterTileSource implements Source {\n encoding: DEMEncoding;\n redFactor?: number;\n greenFactor?: number;\n blueFactor?: number;\n baseShift?: number;\n\n constructor(id: string, options: RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n this.type = 'raster-dem';\n this.maxzoom = 22;\n this._options = extend({type: 'raster-dem'}, options);\n this.encoding = options.encoding || 'mapbox';\n this.redFactor = options.redFactor;\n this.greenFactor = options.greenFactor;\n this.blueFactor = options.blueFactor;\n this.baseShift = options.baseShift;\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);\n const request = this.map._requestManager.transformRequest(url, ResourceType.Tile);\n tile.neighboringTiles = this._getNeighboringTiles(tile.tileID);\n tile.request = ImageRequest.getImage(request, async (err: Error, img: (HTMLImageElement | ImageBitmap), expiry: ExpiryData) => {\n delete tile.request;\n if (tile.aborted) {\n tile.state = 'unloaded';\n callback(null);\n } else if (err) {\n tile.state = 'errored';\n callback(err);\n } else if (img) {\n if (this.map._refreshExpiredTiles) tile.setExpiryData(expiry);\n const transfer = isImageBitmap(img) && offscreenCanvasSupported();\n const rawImageData = transfer ? img : await readImageNow(img);\n const params = {\n uid: tile.uid,\n coord: tile.tileID,\n source: this.id,\n rawImageData,\n encoding: this.encoding,\n redFactor: this.redFactor,\n greenFactor: this.greenFactor,\n blueFactor: this.blueFactor,\n baseShift: this.baseShift\n };\n\n if (!tile.actor || tile.state === 'expired') {\n tile.actor = this.dispatcher.getActor();\n tile.actor.send('loadDEMTile', params, done);\n }\n }\n }, this.map._refreshExpiredTiles);\n\n async function readImageNow(img: ImageBitmap | HTMLImageElement): Promise {\n if (typeof VideoFrame !== 'undefined' && isOffscreenCanvasDistorted()) {\n const width = img.width + 2;\n const height = img.height + 2;\n try {\n return new RGBAImage({width, height}, await readImageUsingVideoFrame(img, -1, -1, width, height));\n } catch (e) {\n // fall-back to browser canvas decoding\n }\n }\n return browser.getImageData(img, 1);\n }\n\n function done(err, data) {\n if (err) {\n tile.state = 'errored';\n callback(err);\n }\n\n if (data) {\n tile.dem = data;\n tile.needsHillshadePrepare = true;\n tile.needsTerrainPrepare = true;\n tile.state = 'loaded';\n callback(null);\n }\n }\n }\n\n _getNeighboringTiles(tileID: OverscaledTileID) {\n const canonical = tileID.canonical;\n const dim = Math.pow(2, canonical.z);\n\n const px = (canonical.x - 1 + dim) % dim;\n const pxw = canonical.x === 0 ? tileID.wrap - 1 : tileID.wrap;\n const nx = (canonical.x + 1 + dim) % dim;\n const nxw = canonical.x + 1 === dim ? tileID.wrap + 1 : tileID.wrap;\n\n const neighboringTiles = {};\n // add adjacent tiles\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y).key] = {backfilled: false};\n\n // Add upper neighboringTiles\n if (canonical.y > 0) {\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y - 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y - 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y - 1).key] = {backfilled: false};\n }\n // Add lower neighboringTiles\n if (canonical.y + 1 < dim) {\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y + 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y + 1).key] = {backfilled: false};\n neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y + 1).key] = {backfilled: false};\n }\n\n return neighboringTiles;\n }\n\n unloadTile(tile: Tile) {\n if (tile.demTexture) this.map.painter.saveTileTexture(tile.demTexture);\n if (tile.fbo) {\n tile.fbo.destroy();\n delete tile.fbo;\n }\n if (tile.dem) delete tile.dem;\n delete tile.neighboringTiles;\n\n tile.state = 'unloaded';\n if (tile.actor) {\n tile.actor.send('removeDEMTile', {uid: tile.uid, source: this.id});\n }\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\n\nimport {extend} from '../util/util';\nimport {EXTENT} from '../data/extent';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\n\nimport type {Source} from './source';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Actor} from '../util/actor';\nimport type {Callback} from '../types/callback';\nimport type {GeoJSONSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {GeoJSONSourceDiff} from './geojson_source_diff';\nimport type {Options, ClusterProperties} from 'supercluster';\n\nexport type GeoJSONSourceOptions = GeoJSONSourceSpecification & {\n workerOptions?: WorkerOptions;\n collectResourceTiming?: boolean;\n}\n\nexport type GeoJsonSourceOptions = {\n data?: GeoJSON.GeoJSON | string | undefined;\n cluster?: boolean;\n clusterMaxZoom?: number;\n clusterRadius?: number;\n clusterMinPoints?: number;\n generateId?: boolean;\n}\nexport type WorkerOptions = {\n source?: string;\n cluster?: boolean;\n geojsonVtOptions?: {\n buffer?: number;\n tolerance?: number;\n extent?: number;\n maxZoom?: number;\n linemetrics?: boolean;\n generateId?: boolean;\n };\n superclusterOptions?: Options;\n clusterProperties?: ClusterProperties;\n fliter?: any;\n promoteId?: any;\n collectResourceTiming?: boolean;\n}\n\n/**\n * The cluster options to set\n */\nexport type SetClusterOptions = {\n /**\n * Whether or not to cluster\n */\n cluster?: boolean;\n /**\n * The cluster's max zoom\n */\n clusterMaxZoom?: number;\n /**\n * The cluster's radius\n */\n clusterRadius?: number;\n}\n\n/**\n * A source containing GeoJSON.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-geojson) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'geojson',\n * data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'\n * });\n * ```\n *\n * @example\n * ```ts\n * map.addSource('some id', {\n * type: 'geojson',\n * data: {\n * \"type\": \"FeatureCollection\",\n * \"features\": [{\n * \"type\": \"Feature\",\n * \"properties\": {},\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [\n * -76.53063297271729,\n * 39.18174077994108\n * ]\n * }\n * }]\n * }\n * });\n * ```\n *\n * @example\n * ```ts\n * map.getSource('some id').setData({\n * \"type\": \"FeatureCollection\",\n * \"features\": [{\n * \"type\": \"Feature\",\n * \"properties\": { \"name\": \"Null Island\" },\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [ 0, 0 ]\n * }\n * }]\n * });\n * ```\n * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)\n * @see [Add a GeoJSON line](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-line/)\n * @see [Create a heatmap from points](https://maplibre.org/maplibre-gl-js/docs/examples/heatmap/)\n * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)\n */\nexport class GeoJSONSource extends Evented implements Source {\n type: 'geojson';\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution: string;\n promoteId: PromoteIdSpecification;\n\n isTileClipped: boolean;\n reparseOverscaled: boolean;\n _data: GeoJSON.GeoJSON | string | undefined;\n _options: GeoJsonSourceOptions;\n workerOptions: WorkerOptions;\n map: Map;\n actor: Actor;\n _pendingLoads: number;\n _collectResourceTiming: boolean;\n _removed: boolean;\n\n /** @internal */\n constructor(id: string, options: GeoJSONSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n\n this.id = id;\n\n // `type` is a property rather than a constant to make it easy for 3rd\n // parties to use GeoJSONSource to build their own source types.\n this.type = 'geojson';\n\n this.minzoom = 0;\n this.maxzoom = 18;\n this.tileSize = 512;\n this.isTileClipped = true;\n this.reparseOverscaled = true;\n this._removed = false;\n this._pendingLoads = 0;\n\n this.actor = dispatcher.getActor();\n this.setEventedParent(eventedParent);\n\n this._data = (options.data as any);\n this._options = extend({}, options);\n\n this._collectResourceTiming = options.collectResourceTiming;\n\n if (options.maxzoom !== undefined) this.maxzoom = options.maxzoom;\n if (options.type) this.type = options.type;\n if (options.attribution) this.attribution = options.attribution;\n this.promoteId = options.promoteId;\n\n const scale = EXTENT / this.tileSize;\n\n // sent to the worker, along with `url: ...` or `data: literal geojson`,\n // so that it can load/parse/index the geojson data\n // extending with `options.workerOptions` helps to make it easy for\n // third-party sources to hack/reuse GeoJSONSource.\n this.workerOptions = extend({\n source: this.id,\n cluster: options.cluster || false,\n geojsonVtOptions: {\n buffer: (options.buffer !== undefined ? options.buffer : 128) * scale,\n tolerance: (options.tolerance !== undefined ? options.tolerance : 0.375) * scale,\n extent: EXTENT,\n maxZoom: this.maxzoom,\n lineMetrics: options.lineMetrics || false,\n generateId: options.generateId || false\n },\n superclusterOptions: {\n maxZoom: options.clusterMaxZoom !== undefined ? options.clusterMaxZoom : this.maxzoom - 1,\n minPoints: Math.max(2, options.clusterMinPoints || 2),\n extent: EXTENT,\n radius: (options.clusterRadius || 50) * scale,\n log: false,\n generateId: options.generateId || false\n },\n clusterProperties: options.clusterProperties,\n filter: options.filter\n }, options.workerOptions);\n\n // send the promoteId to the worker to have more flexible updates, but only if it is a string\n if (typeof this.promoteId === 'string') {\n this.workerOptions.promoteId = this.promoteId;\n }\n }\n\n load = () => {\n this._updateWorkerData();\n };\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n /**\n * Sets the GeoJSON data and re-renders the map.\n *\n * @param data - A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files.\n * @returns `this`\n */\n setData(data: GeoJSON.GeoJSON | string): this {\n this._data = data;\n this._updateWorkerData();\n\n return this;\n }\n\n /**\n * Updates the source's GeoJSON, and re-renders the map.\n *\n * For sources with lots of features, this method can be used to make updates more quickly.\n *\n * This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature,\n * or by using the promoteId option to specify which property should be used as the ID.\n *\n * It is an error to call updateData on a source that did not have unique IDs for each of its features already.\n *\n * Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error.\n *\n * @param diff - The changes that need to be applied.\n * @returns `this`\n */\n updateData(diff: GeoJSONSourceDiff): this {\n this._updateWorkerData(diff);\n\n return this;\n }\n\n /**\n * To disable/enable clustering on the source options\n * @param options - The options to set\n * @returns `this`\n * @example\n * ```ts\n * map.getSource('some id').setClusterOptions({cluster: false});\n * map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14});\n * ```\n */\n setClusterOptions(options: SetClusterOptions): this {\n this.workerOptions.cluster = options.cluster;\n if (options) {\n if (options.clusterRadius !== undefined) this.workerOptions.superclusterOptions.radius = options.clusterRadius;\n if (options.clusterMaxZoom !== undefined) this.workerOptions.superclusterOptions.maxZoom = options.clusterMaxZoom;\n }\n this._updateWorkerData();\n return this;\n }\n\n /**\n * For clustered sources, fetches the zoom at which the given cluster expands.\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param callback - A callback to be called when the zoom value is retrieved (`(error, zoom) => { ... }`).\n * @returns `this`\n */\n getClusterExpansionZoom(clusterId: number, callback: Callback): this {\n this.actor.send('geojson.getClusterExpansionZoom', {clusterId, source: this.id}, callback);\n return this;\n }\n\n /**\n * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`).\n * @returns `this`\n */\n getClusterChildren(clusterId: number, callback: Callback>): this {\n this.actor.send('geojson.getClusterChildren', {clusterId, source: this.id}, callback);\n return this;\n }\n\n /**\n * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).\n *\n * @param clusterId - The value of the cluster's `cluster_id` property.\n * @param limit - The maximum number of features to return.\n * @param offset - The number of features to skip (e.g. for pagination).\n * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`).\n * @returns `this`\n * @example\n * Retrieve cluster leaves on click\n * ```ts\n * map.on('click', 'clusters', function(e) {\n * let features = map.queryRenderedFeatures(e.point, {\n * layers: ['clusters']\n * });\n *\n * let clusterId = features[0].properties.cluster_id;\n * let pointCount = features[0].properties.point_count;\n * let clusterSource = map.getSource('clusters');\n *\n * clusterSource.getClusterLeaves(clusterId, pointCount, 0, function(error, features) {\n * // Print cluster leaves in the console\n * console.log('Cluster leaves:', error, features);\n * })\n * });\n * ```\n */\n getClusterLeaves(clusterId: number, limit: number, offset: number, callback: Callback>): this {\n this.actor.send('geojson.getClusterLeaves', {\n source: this.id,\n clusterId,\n limit,\n offset\n }, callback);\n return this;\n }\n\n /**\n * Responsible for invoking WorkerSource's geojson.loadData target, which\n * handles loading the geojson data and preparing to serve it up as tiles,\n * using geojson-vt or supercluster as appropriate.\n * @param diff - the diff object\n */\n _updateWorkerData(diff?: GeoJSONSourceDiff) {\n const options = extend({}, this.workerOptions);\n if (diff) {\n options.dataDiff = diff;\n } else if (typeof this._data === 'string') {\n options.request = this.map._requestManager.transformRequest(browser.resolveURL(this._data as string), ResourceType.Source);\n options.request.collectResourceTiming = this._collectResourceTiming;\n } else {\n options.data = JSON.stringify(this._data);\n }\n\n this._pendingLoads++;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n\n // target {this.type}.loadData rather than literally geojson.loadData,\n // so that other geojson-like source types can easily reuse this\n // implementation\n this.actor.send(`${this.type}.loadData`, options, (err, result) => {\n this._pendingLoads--;\n\n if (this._removed || (result && result.abandoned)) {\n this.fire(new Event('dataabort', {dataType: 'source'}));\n return;\n }\n\n let resourceTiming = null;\n if (result && result.resourceTiming && result.resourceTiming[this.id])\n resourceTiming = result.resourceTiming[this.id].slice(0);\n\n if (err) {\n this.fire(new ErrorEvent(err));\n return;\n }\n\n const data: any = {dataType: 'source'};\n if (this._collectResourceTiming && resourceTiming && resourceTiming.length > 0)\n extend(data, {resourceTiming});\n\n // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache\n // know its ok to start requesting tiles.\n this.fire(new Event('data', {...data, sourceDataType: 'metadata'}));\n this.fire(new Event('data', {...data, sourceDataType: 'content'}));\n });\n }\n\n loaded(): boolean {\n return this._pendingLoads === 0;\n }\n\n loadTile(tile: Tile, callback: Callback) {\n const message = !tile.actor ? 'loadTile' : 'reloadTile';\n tile.actor = this.actor;\n const params = {\n type: this.type,\n uid: tile.uid,\n tileID: tile.tileID,\n zoom: tile.tileID.overscaledZ,\n maxZoom: this.maxzoom,\n tileSize: this.tileSize,\n source: this.id,\n pixelRatio: this.map.getPixelRatio(),\n showCollisionBoxes: this.map.showCollisionBoxes,\n promoteId: this.promoteId\n };\n\n tile.request = this.actor.send(message, params, (err, data) => {\n delete tile.request;\n tile.unloadVectorData();\n\n if (tile.aborted) {\n return callback(null);\n }\n\n if (err) {\n return callback(err);\n }\n\n tile.loadVectorData(data, this.map.painter, message === 'reloadTile');\n\n return callback(null);\n });\n }\n\n abortTile(tile: Tile) {\n if (tile.request) {\n tile.request.cancel();\n delete tile.request;\n }\n tile.aborted = true;\n }\n\n unloadTile(tile: Tile) {\n tile.unloadVectorData();\n this.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id});\n }\n\n onRemove() {\n this._removed = true;\n this.actor.send('removeSource', {type: this.type, source: this.id});\n }\n\n serialize = (): GeoJSONSourceSpecification => {\n return extend({}, this._options, {\n type: this.type,\n data: this._data\n });\n };\n\n hasTransition() {\n return false;\n }\n}\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos', type: 'Int16', components: 2},\n {name: 'a_texture_pos', type: 'Int16', components: 2}\n]);\n","import {CanonicalTileID} from './tile_id';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {ImageRequest} from '../util/image_request';\nimport {ResourceType} from '../util/request_manager';\nimport {EXTENT} from '../data/extent';\nimport {RasterBoundsArray} from '../data/array_types.g';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\n\nimport type {Source} from './source';\nimport type {CanvasSourceSpecification} from './canvas_source';\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Tile} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {\n ImageSourceSpecification,\n VideoSourceSpecification\n} from '@maplibre/maplibre-gl-style-spec';\nimport {Cancelable} from '../types/cancelable';\n\n/**\n * Four geographical coordinates,\n * represented as arrays of longitude and latitude numbers, which define the corners of the image.\n * The coordinates start at the top left corner of the image and proceed in clockwise order.\n * They do not have to represent a rectangle.\n */\nexport type Coordinates = [[number, number], [number, number], [number, number], [number, number]];\n\n/**\n * The options object for the {@link ImageSource#updateImage} method\n */\nexport type UpdateImageOptions = {\n /**\n * Required image URL.\n */\n url: string;\n /**\n * The image coordinates\n */\n coordinates?: Coordinates;\n}\n\n/**\n * A data source containing an image.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-image) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'image',\n * url: 'https://www.maplibre.org/images/foo.png',\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update coordinates\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * // update url and coordinates simultaneously\n * mySource.updateImage({\n * url: 'https://www.maplibre.org/images/bar.png',\n * coordinates: [\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]\n * })\n *\n * map.removeSource('some id'); // remove\n * ```\n */\nexport class ImageSource extends Evented implements Source {\n type: string;\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n url: string;\n\n coordinates: Coordinates;\n tiles: {[_: string]: Tile};\n options: any;\n dispatcher: Dispatcher;\n map: Map;\n texture: Texture | null;\n image: HTMLImageElement | ImageBitmap;\n tileID: CanonicalTileID;\n _boundsArray: RasterBoundsArray;\n boundsBuffer: VertexBuffer;\n boundsSegments: SegmentVector;\n _loaded: boolean;\n _request: Cancelable;\n\n /** @internal */\n constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n this.coordinates = options.coordinates;\n\n this.type = 'image';\n this.minzoom = 0;\n this.maxzoom = 22;\n this.tileSize = 512;\n this.tiles = {};\n this._loaded = false;\n\n this.setEventedParent(eventedParent);\n\n this.options = options;\n }\n\n load = (newCoordinates?: Coordinates, successCallback?: () => void) => {\n this._loaded = false;\n this.fire(new Event('dataloading', {dataType: 'source'}));\n\n this.url = this.options.url;\n\n this._request = ImageRequest.getImage(this.map._requestManager.transformRequest(this.url, ResourceType.Image), (err, image) => {\n this._request = null;\n this._loaded = true;\n\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (image) {\n this.image = image;\n if (newCoordinates) {\n this.coordinates = newCoordinates;\n }\n if (successCallback) {\n successCallback();\n }\n this._finishLoading();\n }\n });\n };\n\n loaded(): boolean {\n return this._loaded;\n }\n\n /**\n * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing,\n * set the `raster-fade-duration` paint property on the raster layer to 0.\n *\n * @param options - The options object.\n * @returns `this`\n */\n updateImage(options: UpdateImageOptions): this {\n if (!options.url) {\n return this;\n }\n\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n\n this.options.url = options.url;\n this.load(options.coordinates, () => { this.texture = null; });\n return this;\n }\n\n _finishLoading() {\n if (this.map) {\n this.setCoordinates(this.coordinates);\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));\n }\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n }\n\n onRemove() {\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n }\n\n /**\n * Sets the image's coordinates and re-renders the map.\n *\n * @param coordinates - Four geographical coordinates,\n * represented as arrays of longitude and latitude numbers, which define the corners of the image.\n * The coordinates start at the top left corner of the image and proceed in clockwise order.\n * They do not have to represent a rectangle.\n * @returns `this`\n */\n setCoordinates(coordinates: Coordinates): this {\n this.coordinates = coordinates;\n\n // Calculate which mercator tile is suitable for rendering the video in\n // and create a buffer with the corner coordinates. These coordinates\n // may be outside the tile, because raster tiles aren't clipped when rendering.\n\n // transform the geo coordinates into (zoom 0) tile space coordinates\n const cornerCoords = coordinates.map(MercatorCoordinate.fromLngLat);\n\n // Compute the coordinates of the tile we'll use to hold this image's\n // render data\n this.tileID = getCoordinatesCenterTileID(cornerCoords);\n\n // Constrain min/max zoom to our tile's zoom level in order to force\n // SourceCache to request this tile (no matter what the map's zoom\n // level)\n this.minzoom = this.maxzoom = this.tileID.z;\n\n // Transform the corner coordinates into the coordinate space of our\n // tile.\n const tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round());\n\n this._boundsArray = new RasterBoundsArray();\n this._boundsArray.emplaceBack(tileCoords[0].x, tileCoords[0].y, 0, 0);\n this._boundsArray.emplaceBack(tileCoords[1].x, tileCoords[1].y, EXTENT, 0);\n this._boundsArray.emplaceBack(tileCoords[3].x, tileCoords[3].y, 0, EXTENT);\n this._boundsArray.emplaceBack(tileCoords[2].x, tileCoords[2].y, EXTENT, EXTENT);\n\n if (this.boundsBuffer) {\n this.boundsBuffer.destroy();\n delete this.boundsBuffer;\n }\n\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));\n return this;\n }\n\n prepare = () => {\n if (Object.keys(this.tiles).length === 0 || !this.image) {\n return;\n }\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.image, gl.RGBA);\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n loadTile(tile: Tile, callback: Callback) {\n // We have a single tile -- whose coordinates are this.tileID -- that\n // covers the image we want to render. If that's the one being\n // requested, set it up with the image; otherwise, mark the tile as\n // `errored` to indicate that we have no data for it.\n // If the world wraps, we may have multiple \"wrapped\" copies of the\n // single tile.\n if (this.tileID && this.tileID.equals(tile.tileID.canonical)) {\n this.tiles[String(tile.tileID.wrap)] = tile;\n tile.buckets = {};\n callback(null);\n } else {\n tile.state = 'errored';\n callback(null);\n }\n }\n\n serialize = (): ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification => {\n return {\n type: 'image',\n url: this.options.url,\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return false;\n }\n}\n\n/**\n * Given a list of coordinates, get their center as a coordinate.\n *\n * @returns centerpoint\n * @internal\n */\nexport function getCoordinatesCenterTileID(coords: Array) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const coord of coords) {\n minX = Math.min(minX, coord.x);\n minY = Math.min(minY, coord.y);\n maxX = Math.max(maxX, coord.x);\n maxY = Math.max(maxY, coord.y);\n }\n\n const dx = maxX - minX;\n const dy = maxY - minY;\n const dMax = Math.max(dx, dy);\n const zoom = Math.max(0, Math.floor(-Math.log(dMax) / Math.LN2));\n const tilesAtZoom = Math.pow(2, zoom);\n\n return new CanonicalTileID(\n zoom,\n Math.floor((minX + maxX) / 2 * tilesAtZoom),\n Math.floor((minY + maxY) / 2 * tilesAtZoom));\n}\n","import {getVideo} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\n\nimport {ImageSource} from './image_source';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {Event, ErrorEvent} from '../util/evented';\nimport {ValidationError} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Evented} from '../util/evented';\nimport type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A data source containing video.\n * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-video) for detailed documentation of options.)\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'video',\n * url: [\n * 'https://www.mapbox.com/blog/assets/baltimore-smoke.mp4',\n * 'https://www.mapbox.com/blog/assets/baltimore-smoke.webm'\n * ],\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * map.removeSource('some id'); // remove\n * ```\n * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)\n *\n * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.\n * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,\n * set the layer's `raster-fade-duration` property to `0`.\n */\nexport class VideoSource extends ImageSource {\n options: VideoSourceSpecification;\n urls: Array;\n video: HTMLVideoElement;\n roundZoom: boolean;\n\n constructor(id: string, options: VideoSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n this.roundZoom = true;\n this.type = 'video';\n this.options = options;\n }\n\n load = () => {\n this._loaded = false;\n const options = this.options;\n\n this.urls = [];\n for (const url of options.urls) {\n this.urls.push(this.map._requestManager.transformRequest(url, ResourceType.Source).url);\n }\n\n getVideo(this.urls, (err, video) => {\n this._loaded = true;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (video) {\n this.video = video;\n this.video.loop = true;\n\n // Start repainting when video starts playing. hasTransition() will then return\n // true to trigger additional frames as long as the videos continues playing.\n this.video.addEventListener('playing', () => {\n this.map.triggerRepaint();\n });\n\n if (this.map) {\n this.video.play();\n }\n\n this._finishLoading();\n }\n });\n };\n\n /**\n * Pauses the video.\n */\n pause() {\n if (this.video) {\n this.video.pause();\n }\n }\n\n /**\n * Plays the video.\n */\n play() {\n if (this.video) {\n this.video.play();\n }\n }\n\n /**\n * Sets playback to a timestamp, in seconds.\n */\n seek(seconds: number) {\n if (this.video) {\n const seekableRange = this.video.seekable;\n if (seconds < seekableRange.start(0) || seconds > seekableRange.end(0)) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`, null, `Playback for this video can be set only between the ${seekableRange.start(0)} and ${seekableRange.end(0)}-second mark.`)));\n } else this.video.currentTime = seconds;\n }\n }\n\n /**\n * Returns the HTML `video` element.\n *\n * @returns The HTML `video` element.\n */\n getVideo(): HTMLVideoElement {\n return this.video;\n }\n\n onAdd(map: Map) {\n if (this.map) return;\n this.map = map;\n this.load();\n if (this.video) {\n this.video.play();\n this.setCoordinates(this.coordinates);\n }\n }\n\n /**\n * Sets the video's coordinates and re-renders the map.\n *\n * @returns `this`\n */\n prepare = (): this => {\n if (Object.keys(this.tiles).length === 0 || this.video.readyState < 2) {\n return; // not enough data for current position\n }\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.video, gl.RGBA);\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n } else if (!this.video.paused) {\n this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, this.video);\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n serialize = (): VideoSourceSpecification => {\n return {\n type: 'video',\n urls: this.urls,\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return this.video && !this.video.paused;\n }\n}\n","import {ImageSource} from './image_source';\n\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {Texture} from '../render/texture';\nimport {Event, ErrorEvent} from '../util/evented';\nimport {ValidationError} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {Map} from '../ui/map';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Evented} from '../util/evented';\n\n/**\n * Options to add a canvas source type to the map.\n */\nexport type CanvasSourceSpecification = {\n /**\n * Source type. Must be `\"canvas\"`.\n */\n type: 'canvas';\n /**\n * Four geographical coordinates denoting where to place the corners of the canvas, specified in `[longitude, latitude]` pairs.\n */\n coordinates: [[number, number], [number, number], [number, number], [number, number]];\n /**\n * Whether the canvas source is animated. If the canvas is static (i.e. pixels do not need to be re-read on every frame), `animate` should be set to `false` to improve performance.\n * @defaultValue true\n */\n animate?: boolean;\n /**\n * Canvas source from which to read pixels. Can be a string representing the ID of the canvas element, or the `HTMLCanvasElement` itself.\n */\n canvas?: string | HTMLCanvasElement;\n};\n\n/**\n * A data source containing the contents of an HTML canvas. See {@link CanvasSourceSpecification} for detailed documentation of options.\n *\n * @group Sources\n *\n * @example\n * ```ts\n * // add to map\n * map.addSource('some id', {\n * type: 'canvas',\n * canvas: 'idOfMyHTMLCanvas',\n * animate: true,\n * coordinates: [\n * [-76.54, 39.18],\n * [-76.52, 39.18],\n * [-76.52, 39.17],\n * [-76.54, 39.17]\n * ]\n * });\n *\n * // update\n * let mySource = map.getSource('some id');\n * mySource.setCoordinates([\n * [-76.54335737228394, 39.18579907229748],\n * [-76.52803659439087, 39.1838364847587],\n * [-76.5295386314392, 39.17683392507606],\n * [-76.54520273208618, 39.17876344106642]\n * ]);\n *\n * map.removeSource('some id'); // remove\n * ```\n */\nexport class CanvasSource extends ImageSource {\n options: CanvasSourceSpecification;\n animate: boolean;\n canvas: HTMLCanvasElement;\n width: number;\n height: number;\n /**\n * Enables animation. The image will be copied from the canvas to the map on each frame.\n */\n play: () => void;\n /**\n * Disables animation. The map will display a static copy of the canvas image.\n */\n pause: () => void;\n _playing: boolean;\n\n /** @internal */\n constructor(id: string, options: CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {\n super(id, options, dispatcher, eventedParent);\n\n // We build in some validation here, since canvas sources aren't included in the style spec:\n if (!options.coordinates) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property \"coordinates\"')));\n } else if (!Array.isArray(options.coordinates) || options.coordinates.length !== 4 ||\n options.coordinates.some(c => !Array.isArray(c) || c.length !== 2 || c.some(l => typeof l !== 'number'))) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '\"coordinates\" property must be an array of 4 longitude/latitude array pairs')));\n }\n\n if (options.animate && typeof options.animate !== 'boolean') {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'optional \"animate\" property must be a boolean value')));\n }\n\n if (!options.canvas) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property \"canvas\"')));\n } else if (typeof options.canvas !== 'string' && !(options.canvas instanceof HTMLCanvasElement)) {\n this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '\"canvas\" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance')));\n }\n\n this.options = options;\n this.animate = options.animate !== undefined ? options.animate : true;\n }\n\n load = () => {\n this._loaded = true;\n if (!this.canvas) {\n this.canvas = (this.options.canvas instanceof HTMLCanvasElement) ?\n this.options.canvas :\n document.getElementById(this.options.canvas) as HTMLCanvasElement;\n // cast to HTMLCanvasElement in else of ternary\n // should we do a safety check and throw if it's not actually HTMLCanvasElement?\n }\n this.width = this.canvas.width;\n this.height = this.canvas.height;\n\n if (this._hasInvalidDimensions()) {\n this.fire(new ErrorEvent(new Error('Canvas dimensions cannot be less than or equal to zero.')));\n return;\n }\n\n this.play = function() {\n this._playing = true;\n this.map.triggerRepaint();\n };\n\n this.pause = function() {\n if (this._playing) {\n this.prepare();\n this._playing = false;\n }\n };\n\n this._finishLoading();\n };\n\n /**\n * Returns the HTML `canvas` element.\n *\n * @returns The HTML `canvas` element.\n */\n getCanvas(): HTMLCanvasElement {\n return this.canvas;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this.load();\n if (this.canvas) {\n if (this.animate) this.play();\n }\n }\n\n onRemove() {\n this.pause();\n }\n\n prepare = () => {\n let resize = false;\n if (this.canvas.width !== this.width) {\n this.width = this.canvas.width;\n resize = true;\n }\n if (this.canvas.height !== this.height) {\n this.height = this.canvas.height;\n resize = true;\n }\n\n if (this._hasInvalidDimensions()) return;\n\n if (Object.keys(this.tiles).length === 0) return; // not enough data for current position\n\n const context = this.map.painter.context;\n const gl = context.gl;\n\n if (!this.boundsBuffer) {\n this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);\n }\n\n if (!this.boundsSegments) {\n this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n }\n\n if (!this.texture) {\n this.texture = new Texture(context, this.canvas, gl.RGBA, {premultiply: true});\n } else if (resize || this._playing) {\n this.texture.update(this.canvas, {premultiply: true});\n }\n\n let newTilesLoaded = false;\n for (const w in this.tiles) {\n const tile = this.tiles[w];\n if (tile.state !== 'loaded') {\n tile.state = 'loaded';\n tile.texture = this.texture;\n newTilesLoaded = true;\n }\n }\n\n if (newTilesLoaded) {\n this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id}));\n }\n };\n\n serialize = (): CanvasSourceSpecification => {\n return {\n type: 'canvas',\n coordinates: this.coordinates\n };\n };\n\n hasTransition() {\n return this._playing;\n }\n\n _hasInvalidDimensions() {\n for (const x of [this.canvas.width, this.canvas.height]) {\n if (isNaN(x) || x <= 0) return true;\n }\n return false;\n }\n}\n","import {VectorTileSource} from '../source/vector_tile_source';\nimport {RasterTileSource} from '../source/raster_tile_source';\nimport {RasterDEMTileSource} from '../source/raster_dem_tile_source';\nimport {GeoJSONSource} from '../source/geojson_source';\nimport {VideoSource} from '../source/video_source';\nimport {ImageSource} from '../source/image_source';\nimport {CanvasSource} from '../source/canvas_source';\n\nimport type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Event, Evented} from '../util/evented';\nimport type {Map} from '../ui/map';\nimport type {Tile} from './tile';\nimport type {OverscaledTileID, CanonicalTileID} from './tile_id';\nimport type {Callback} from '../types/callback';\nimport type {CanvasSourceSpecification} from '../source/canvas_source';\n\nconst registeredSources = {} as {[key:string]: SourceClass};\n\n/**\n * The `Source` interface must be implemented by each source type, including \"core\" types (`vector`, `raster`,\n * `video`, etc.) and all custom, third-party types.\n *\n * @event `data` - Fired with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata\n * has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}`\n * to indicate that the source data has changed, so that any current caches should be flushed.\n *\n * @group Sources\n */\nexport interface Source {\n readonly type: string;\n /**\n * The id for the source. Must not be used by any existing source.\n */\n id: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution?: string;\n /**\n * `true` if zoom levels are rounded to the nearest integer in the source data, `false` if they are floor-ed to the nearest integer.\n */\n roundZoom?: boolean;\n /**\n * `false` if tiles can be drawn outside their boundaries, `true` if they cannot.\n */\n isTileClipped?: boolean;\n tileID?: CanonicalTileID;\n /**\n * `true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not.\n */\n reparseOverscaled?: boolean;\n vectorLayerIds?: Array;\n hasTransition(): boolean;\n loaded(): boolean;\n fire(event: Event): unknown;\n readonly onAdd?: (map: Map) => void;\n readonly onRemove?: (map: Map) => void;\n loadTile(tile: Tile, callback: Callback): void;\n readonly hasTile?: (tileID: OverscaledTileID) => boolean;\n readonly abortTile?: (tile: Tile, callback: Callback) => void;\n readonly unloadTile?: (tile: Tile, callback: Callback) => void;\n /**\n * @returns A plain (stringifiable) JS object representing the current state of the source.\n * Creating a source using the returned object as the `options` should result in a Source that is\n * equivalent to this one.\n */\n serialize(): any;\n readonly prepare?: () => void;\n}\n\n/**\n * A supporting type to the source definition\n */\ntype SourceStatics = {\n /*\n * An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource}\n * implementation for this Source type by calling `self.registerWorkerSource(workerSource: WorkerSource)`.\n */\n workerSourceURL?: URL;\n};\n\n/**\n * A general definition of a {@link Source} class for factory usage\n */\nexport type SourceClass = {\n new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source;\n} & SourceStatics;\n\n/**\n * Creates a tiled data source instance given an options object.\n *\n * @param id - The id for the source. Must not be used by any existing source.\n * @param specification - Source options, specific to the source type (except for `options.type`, which is always required).\n * @param source - A source definition object compliant with\n * [`maplibre-gl-style-spec`](https://maplibre.org/maplibre-style-spec/#sources) or, for a third-party source type,\n * with that type's requirements.\n * @param dispatcher - A {@link Dispatcher} instance, which can be used to send messages to the workers.\n * @returns a newly created source\n */\nexport const create = (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source => {\n\n const Class = getSourceType(specification.type);\n const source = new Class(id, specification, dispatcher, eventedParent);\n\n if (source.id !== id) {\n throw new Error(`Expected Source id to be ${id} instead of ${source.id}`);\n }\n\n return source;\n};\n\nexport const getSourceType = (name: string): SourceClass => {\n switch (name) {\n case 'geojson':\n return GeoJSONSource;\n case 'image':\n return ImageSource;\n case 'raster':\n return RasterTileSource;\n case 'raster-dem':\n return RasterDEMTileSource;\n case 'vector':\n return VectorTileSource;\n case 'video':\n return VideoSource;\n case 'canvas':\n return CanvasSource;\n }\n return registeredSources[name];\n};\n\nexport const setSourceType = (name: string, type: SourceClass) => {\n registeredSources[name] = type;\n};\n\nexport interface Actor {\n send(type: string, data: any, callback: Callback): void;\n}\n","import type {SourceCache} from './source_cache';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CollisionIndex} from '../symbol/collision_index';\nimport type {Transform} from '../geo/transform';\nimport type {RetainedQueryData} from '../symbol/placement';\nimport type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport type Point from '@mapbox/point-geometry';\nimport {mat4} from 'gl-matrix';\n\n/**\n * Options to pass to query the map for the rendered features\n */\nexport type QueryRenderedFeaturesOptions = {\n /**\n * An array of [style layer IDs](https://maplibre.org/maplibre-style-spec/#layer-id) for the query to inspect.\n * Only features within these layers will be returned. If this parameter is undefined, all layers will be checked.\n */\n layers?: Array;\n /**\n * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) to limit query results.\n */\n filter?: FilterSpecification;\n /**\n * An array of string representing the available images\n */\n availableImages?: Array;\n /**\n * Whether to check if the [options.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n */\n validate?: boolean;\n};\n\n/**\n * The options object related to the {@link Map#queryRenderedFeatures} method\n */\nexport type QuerySourceFeatureOptions = {\n /**\n * The name of the source layer to query. *For vector tile sources, this parameter is required.* For GeoJSON sources, it is ignored.\n */\n sourceLayer?: string;\n /**\n * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter)\n * to limit query results.\n */\n filter?: FilterSpecification;\n /**\n * Whether to check if the [parameters.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n * @defaultValue true\n */\n validate?: boolean;\n}\n\n/*\n * Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates.\n */\nfunction getPixelPosMatrix(transform, tileID) {\n const t = mat4.create();\n mat4.translate(t, t, [1, 1, 0]);\n mat4.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]);\n return mat4.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped()));\n}\n\nfunction queryIncludes3DLayer(layers: Array, styleLayers: {[_: string]: StyleLayer}, sourceID: string) {\n if (layers) {\n for (const layerID of layers) {\n const layer = styleLayers[layerID];\n if (layer && layer.source === sourceID && layer.type === 'fill-extrusion') {\n return true;\n }\n }\n } else {\n for (const key in styleLayers) {\n const layer = styleLayers[key];\n if (layer.source === sourceID && layer.type === 'fill-extrusion') {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function queryRenderedFeatures(\n sourceCache: SourceCache,\n styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n queryGeometry: Array,\n params: QueryRenderedFeaturesOptions,\n transform: Transform\n): { [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> } {\n\n const has3DLayer = queryIncludes3DLayer(params && params.layers, styleLayers, sourceCache.id);\n const maxPitchScaleFactor = transform.maxPitchScaleFactor();\n const tilesIn = sourceCache.tilesIn(queryGeometry, maxPitchScaleFactor, has3DLayer);\n\n tilesIn.sort(sortTilesIn);\n const renderedFeatureLayers = [];\n for (const tileIn of tilesIn) {\n renderedFeatureLayers.push({\n wrappedTileID: tileIn.tileID.wrapped().key,\n queryResults: tileIn.tile.queryRenderedFeatures(\n styleLayers,\n serializedLayers,\n sourceCache._state,\n tileIn.queryGeometry,\n tileIn.cameraQueryGeometry,\n tileIn.scale,\n params,\n transform,\n maxPitchScaleFactor,\n getPixelPosMatrix(sourceCache.transform, tileIn.tileID))\n });\n }\n\n const result = mergeRenderedFeatureLayers(renderedFeatureLayers);\n\n // Merge state from SourceCache into the results\n for (const layerID in result) {\n result[layerID].forEach((featureWrapper) => {\n const feature = featureWrapper.feature as MapGeoJSONFeature;\n const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id);\n feature.source = feature.layer.source;\n if (feature.layer['source-layer']) {\n feature.sourceLayer = feature.layer['source-layer'];\n }\n feature.state = state;\n });\n }\n return result;\n}\n\nexport function queryRenderedSymbols(styleLayers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: StyleLayer},\n sourceCaches: {[_: string]: SourceCache},\n queryGeometry: Array,\n params: QueryRenderedFeaturesOptions,\n collisionIndex: CollisionIndex,\n retainedQueryData: {\n [_: number]: RetainedQueryData;\n }) {\n const result = {};\n const renderedSymbols = collisionIndex.queryRenderedSymbols(queryGeometry);\n const bucketQueryData = [];\n for (const bucketInstanceId of Object.keys(renderedSymbols).map(Number)) {\n bucketQueryData.push(retainedQueryData[bucketInstanceId]);\n }\n bucketQueryData.sort(sortTilesIn);\n\n for (const queryData of bucketQueryData) {\n const bucketSymbols = queryData.featureIndex.lookupSymbolFeatures(\n renderedSymbols[queryData.bucketInstanceId],\n serializedLayers,\n queryData.bucketIndex,\n queryData.sourceLayerIndex,\n params.filter,\n params.layers,\n params.availableImages,\n styleLayers);\n\n for (const layerID in bucketSymbols) {\n const resultFeatures = result[layerID] = result[layerID] || [];\n const layerSymbols = bucketSymbols[layerID];\n layerSymbols.sort((a, b) => {\n // Match topDownFeatureComparator from FeatureIndex, but using\n // most recent sorting of features from bucket.sortFeatures\n const featureSortOrder = queryData.featureSortOrder;\n if (featureSortOrder) {\n // queryRenderedSymbols documentation says we'll return features in\n // \"top-to-bottom\" rendering order (aka last-to-first).\n // Actually there can be multiple symbol instances per feature, so\n // we sort each feature based on the first matching symbol instance.\n const sortedA = featureSortOrder.indexOf(a.featureIndex);\n const sortedB = featureSortOrder.indexOf(b.featureIndex);\n return sortedB - sortedA;\n } else {\n // Bucket hasn't been re-sorted based on angle, so use the\n // reverse of the order the features appeared in the data.\n return b.featureIndex - a.featureIndex;\n }\n });\n for (const symbolFeature of layerSymbols) {\n resultFeatures.push(symbolFeature);\n }\n }\n }\n\n // Merge state from SourceCache into the results\n for (const layerName in result) {\n result[layerName].forEach((featureWrapper) => {\n const feature = featureWrapper.feature;\n const layer = styleLayers[layerName];\n const sourceCache = sourceCaches[layer.source];\n const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id);\n feature.source = feature.layer.source;\n if (feature.layer['source-layer']) {\n feature.sourceLayer = feature.layer['source-layer'];\n }\n feature.state = state;\n });\n }\n return result;\n}\n\nexport function querySourceFeatures(sourceCache: SourceCache, params: QuerySourceFeatureOptions) {\n const tiles = sourceCache.getRenderableIds().map((id) => {\n return sourceCache.getTileByID(id);\n });\n\n const result = [];\n\n const dataTiles = {};\n for (let i = 0; i < tiles.length; i++) {\n const tile = tiles[i];\n const dataID = tile.tileID.canonical.key;\n if (!dataTiles[dataID]) {\n dataTiles[dataID] = true;\n tile.querySourceFeatures(result, params);\n }\n }\n\n return result;\n}\n\nfunction sortTilesIn(a, b) {\n const idA = a.tileID;\n const idB = b.tileID;\n return (idA.overscaledZ - idB.overscaledZ) || (idA.canonical.y - idB.canonical.y) || (idA.wrap - idB.wrap) || (idA.canonical.x - idB.canonical.x);\n}\n\nfunction mergeRenderedFeatureLayers(tiles) {\n // Merge results from all tiles, but if two tiles share the same\n // wrapped ID, don't duplicate features between the two tiles\n const result = {};\n const wrappedIDLayerMap = {};\n for (const tile of tiles) {\n const queryResults = tile.queryResults;\n const wrappedID = tile.wrappedTileID;\n const wrappedIDLayers = wrappedIDLayerMap[wrappedID] = wrappedIDLayerMap[wrappedID] || {};\n for (const layerID in queryResults) {\n const tileFeatures = queryResults[layerID];\n const wrappedIDFeatures = wrappedIDLayers[layerID] = wrappedIDLayers[layerID] || {};\n const resultFeatures = result[layerID] = result[layerID] || [];\n for (const tileFeature of tileFeatures) {\n if (!wrappedIDFeatures[tileFeature.featureIndex]) {\n wrappedIDFeatures[tileFeature.featureIndex] = true;\n resultFeatures.push(tileFeature);\n }\n }\n }\n }\n return result;\n}\n","import {uniqueId, parseCacheControl} from '../util/util';\nimport {deserialize as deserializeBucket} from '../data/bucket';\nimport '../data/feature_index';\nimport type {FeatureIndex} from '../data/feature_index';\nimport {GeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {featureFilter} from '@maplibre/maplibre-gl-style-spec';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {CollisionBoxArray} from '../data/array_types.g';\nimport {Texture} from '../render/texture';\nimport {browser} from '../util/browser';\nimport {toEvaluationFeature} from '../data/evaluation_feature';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {SourceFeatureState} from '../source/source_state';\nimport {lazyLoadRTLTextPlugin} from './rtl_text_plugin';\n\nconst CLOCK_SKEW_RETRY_TIMEOUT = 30000;\n\nimport type {Bucket} from '../data/bucket';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {WorkerTileResult} from './worker_source';\nimport type {Actor} from '../util/actor';\nimport type {DEMData} from '../data/dem_data';\nimport type {AlphaImage} from '../util/image';\nimport type {ImageAtlas} from '../render/image_atlas';\nimport type {ImageManager} from '../render/image_manager';\nimport type {Context} from '../gl/context';\nimport type {OverscaledTileID} from './tile_id';\nimport type {Framebuffer} from '../gl/framebuffer';\nimport type {Transform} from '../geo/transform';\nimport type {LayerFeatureStates} from './source_state';\nimport type {Cancelable} from '../types/cancelable';\nimport type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type Point from '@mapbox/point-geometry';\nimport {mat4} from 'gl-matrix';\nimport type {VectorTileLayer} from '@mapbox/vector-tile';\nimport {ExpiryData} from '../util/ajax';\n\n/**\n * The tile's state, can be:\n * - `loading` Tile data is in the process of loading.\n * - `loaded` Tile data has been loaded. Tile can be rendered.\n * - `reloading` Tile data has been loaded and is being updated. Tile can be rendered.\n * - `unloaded` Tile data has been deleted.\n * - `errored` Tile data was not loaded because of an error.\n * - `expired` Tile data was previously loaded, but has expired per its HTTP headers and is in the process of refreshing.\n */\nexport type TileState = 'loading' | 'loaded' | 'reloading' | 'unloaded' | 'errored' | 'expired';\n\n/**\n * @internal\n * A tile object is the combination of a Coordinate, which defines\n * its place, as well as a unique ID and data tracking for its content\n */\nexport class Tile {\n tileID: OverscaledTileID;\n uid: number;\n uses: number;\n tileSize: number;\n buckets: {[_: string]: Bucket};\n latestFeatureIndex: FeatureIndex;\n latestRawTileData: ArrayBuffer;\n imageAtlas: ImageAtlas;\n imageAtlasTexture: Texture;\n glyphAtlasImage: AlphaImage;\n glyphAtlasTexture: Texture;\n expirationTime: any;\n expiredRequestCount: number;\n state: TileState;\n timeAdded: number = 0;\n fadeEndTime: number = 0;\n collisionBoxArray: CollisionBoxArray;\n redoWhenDone: boolean;\n showCollisionBoxes: boolean;\n placementSource: any;\n actor: Actor;\n vtLayers: {[_: string]: VectorTileLayer};\n\n neighboringTiles: any;\n dem: DEMData;\n demMatrix: mat4;\n aborted: boolean;\n needsHillshadePrepare: boolean;\n needsTerrainPrepare: boolean;\n request: Cancelable;\n texture: any;\n fbo: Framebuffer;\n demTexture: Texture;\n refreshedUponExpiration: boolean;\n reloadCallback: any;\n resourceTiming: Array;\n queryPadding: number;\n\n symbolFadeHoldUntil: number;\n hasSymbolBuckets: boolean;\n hasRTLText: boolean;\n dependencies: any;\n rtt: Array<{id: number; stamp: number}>;\n rttCoords: {[_:string]: string};\n\n /**\n * @param tileID - the tile ID\n * @param size - The tile size\n */\n constructor(tileID: OverscaledTileID, size: number) {\n this.tileID = tileID;\n this.uid = uniqueId();\n this.uses = 0;\n this.tileSize = size;\n this.buckets = {};\n this.expirationTime = null;\n this.queryPadding = 0;\n this.hasSymbolBuckets = false;\n this.hasRTLText = false;\n this.dependencies = {};\n this.rtt = [];\n this.rttCoords = {};\n\n // Counts the number of times a response was already expired when\n // received. We're using this to add a delay when making a new request\n // so we don't have to keep retrying immediately in case of a server\n // serving expired tiles.\n this.expiredRequestCount = 0;\n\n this.state = 'loading';\n }\n\n registerFadeDuration(duration: number) {\n const fadeEndTime = duration + this.timeAdded;\n\n if (fadeEndTime < this.fadeEndTime) {\n return;\n }\n\n this.fadeEndTime = fadeEndTime;\n }\n\n wasRequested() {\n return this.state === 'errored' || this.state === 'loaded' || this.state === 'reloading';\n }\n\n clearTextures(painter: any) {\n if (this.demTexture) painter.saveTileTexture(this.demTexture);\n this.demTexture = null;\n }\n\n /**\n * Given a data object with a 'buffers' property, load it into\n * this tile's elementGroups and buffers properties and set loaded\n * to true. If the data is null, like in the case of an empty\n * GeoJSON tile, no-op but still set loaded to true.\n * @param data - The data from the worker\n * @param painter - the painter\n * @param justReloaded - `true` to just reload\n */\n loadVectorData(data: WorkerTileResult, painter: any, justReloaded?: boolean | null) {\n if (this.hasData()) {\n this.unloadVectorData();\n }\n\n this.state = 'loaded';\n\n // empty GeoJSON tile\n if (!data) {\n this.collisionBoxArray = new CollisionBoxArray();\n return;\n }\n\n if (data.featureIndex) {\n this.latestFeatureIndex = data.featureIndex;\n if (data.rawTileData) {\n // Only vector tiles have rawTileData, and they won't update it for\n // 'reloadTile'\n this.latestRawTileData = data.rawTileData;\n this.latestFeatureIndex.rawTileData = data.rawTileData;\n } else if (this.latestRawTileData) {\n // If rawTileData hasn't updated, hold onto a pointer to the last\n // one we received\n this.latestFeatureIndex.rawTileData = this.latestRawTileData;\n }\n }\n this.collisionBoxArray = data.collisionBoxArray;\n this.buckets = deserializeBucket(data.buckets, painter.style);\n\n this.hasSymbolBuckets = false;\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket instanceof SymbolBucket) {\n this.hasSymbolBuckets = true;\n if (justReloaded) {\n bucket.justReloaded = true;\n } else {\n break;\n }\n }\n }\n\n this.hasRTLText = false;\n if (this.hasSymbolBuckets) {\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket instanceof SymbolBucket) {\n if (bucket.hasRTLText) {\n this.hasRTLText = true;\n lazyLoadRTLTextPlugin();\n break;\n }\n }\n }\n }\n\n this.queryPadding = 0;\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(id).queryRadius(bucket));\n }\n\n if (data.imageAtlas) {\n this.imageAtlas = data.imageAtlas;\n }\n if (data.glyphAtlasImage) {\n this.glyphAtlasImage = data.glyphAtlasImage;\n }\n }\n\n /**\n * Release any data or WebGL resources referenced by this tile.\n */\n unloadVectorData() {\n for (const id in this.buckets) {\n this.buckets[id].destroy();\n }\n this.buckets = {};\n\n if (this.imageAtlasTexture) {\n this.imageAtlasTexture.destroy();\n }\n\n if (this.imageAtlas) {\n this.imageAtlas = null;\n }\n\n if (this.glyphAtlasTexture) {\n this.glyphAtlasTexture.destroy();\n }\n\n this.latestFeatureIndex = null;\n this.state = 'unloaded';\n }\n\n getBucket(layer: StyleLayer) {\n return this.buckets[layer.id];\n }\n\n upload(context: Context) {\n for (const id in this.buckets) {\n const bucket = this.buckets[id];\n if (bucket.uploadPending()) {\n bucket.upload(context);\n }\n }\n\n const gl = context.gl;\n if (this.imageAtlas && !this.imageAtlas.uploaded) {\n this.imageAtlasTexture = new Texture(context, this.imageAtlas.image, gl.RGBA);\n this.imageAtlas.uploaded = true;\n }\n\n if (this.glyphAtlasImage) {\n this.glyphAtlasTexture = new Texture(context, this.glyphAtlasImage, gl.ALPHA);\n this.glyphAtlasImage = null;\n }\n }\n\n prepare(imageManager: ImageManager) {\n if (this.imageAtlas) {\n this.imageAtlas.patchUpdatedImages(imageManager, this.imageAtlasTexture);\n }\n }\n\n // Queries non-symbol features rendered for this tile.\n // Symbol features are queried globally\n queryRenderedFeatures(\n layers: {[_: string]: StyleLayer},\n serializedLayers: {[_: string]: any},\n sourceFeatureState: SourceFeatureState,\n queryGeometry: Array,\n cameraQueryGeometry: Array,\n scale: number,\n params: {\n filter: FilterSpecification;\n layers: Array;\n availableImages: Array;\n },\n transform: Transform,\n maxPitchScaleFactor: number,\n pixelPosMatrix: mat4\n ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} {\n if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData)\n return {};\n\n return this.latestFeatureIndex.query({\n queryGeometry,\n cameraQueryGeometry,\n scale,\n tileSize: this.tileSize,\n pixelPosMatrix,\n transform,\n params,\n queryPadding: this.queryPadding * maxPitchScaleFactor\n }, layers, serializedLayers, sourceFeatureState);\n }\n\n querySourceFeatures(result: Array, params?: {\n sourceLayer?: string;\n filter?: FilterSpecification;\n validate?: boolean;\n }) {\n const featureIndex = this.latestFeatureIndex;\n if (!featureIndex || !featureIndex.rawTileData) return;\n\n const vtLayers = featureIndex.loadVTLayers();\n\n const sourceLayer = params && params.sourceLayer ? params.sourceLayer : '';\n const layer = vtLayers._geojsonTileLayer || vtLayers[sourceLayer];\n\n if (!layer) return;\n\n const filter = featureFilter(params && params.filter);\n const {z, x, y} = this.tileID.canonical;\n const coord = {z, x, y};\n\n for (let i = 0; i < layer.length; i++) {\n const feature = layer.feature(i);\n if (filter.needGeometry) {\n const evaluationFeature = toEvaluationFeature(feature, true);\n if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) continue;\n } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {\n continue;\n }\n const id = featureIndex.getId(feature, sourceLayer);\n const geojsonFeature = new GeoJSONFeature(feature, z, x, y, id);\n (geojsonFeature as any).tile = coord;\n result.push(geojsonFeature);\n }\n }\n\n hasData() {\n return this.state === 'loaded' || this.state === 'reloading' || this.state === 'expired';\n }\n\n patternsLoaded() {\n return this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;\n }\n\n setExpiryData(data: ExpiryData) {\n const prior = this.expirationTime;\n\n if (data.cacheControl) {\n const parsedCC = parseCacheControl(data.cacheControl);\n if (parsedCC['max-age']) this.expirationTime = Date.now() + parsedCC['max-age'] * 1000;\n } else if (data.expires) {\n this.expirationTime = new Date(data.expires).getTime();\n }\n\n if (this.expirationTime) {\n const now = Date.now();\n let isExpired = false;\n\n if (this.expirationTime > now) {\n isExpired = false;\n } else if (!prior) {\n isExpired = true;\n } else if (this.expirationTime < prior) {\n // Expiring date is going backwards:\n // fall back to exponential backoff\n isExpired = true;\n\n } else {\n const delta = this.expirationTime - prior;\n\n if (!delta) {\n // Server is serving the same expired resource over and over: fall\n // back to exponential backoff.\n isExpired = true;\n\n } else {\n // Assume that either the client or the server clock is wrong and\n // try to interpolate a valid expiration date (from the client POV)\n // observing a minimum timeout.\n this.expirationTime = now + Math.max(delta, CLOCK_SKEW_RETRY_TIMEOUT);\n\n }\n }\n\n if (isExpired) {\n this.expiredRequestCount++;\n this.state = 'expired';\n } else {\n this.expiredRequestCount = 0;\n }\n }\n }\n\n getExpiryTimeout() {\n if (this.expirationTime) {\n if (this.expiredRequestCount) {\n return 1000 * (1 << Math.min(this.expiredRequestCount - 1, 31));\n } else {\n // Max value for `setTimeout` implementations is a 32 bit integer; cap this accordingly\n return Math.min(this.expirationTime - new Date().getTime(), Math.pow(2, 31) - 1);\n }\n }\n }\n\n setFeatureState(states: LayerFeatureStates, painter: any) {\n if (!this.latestFeatureIndex ||\n !this.latestFeatureIndex.rawTileData ||\n Object.keys(states).length === 0) {\n return;\n }\n\n const vtLayers = this.latestFeatureIndex.loadVTLayers();\n\n for (const id in this.buckets) {\n if (!painter.style.hasLayer(id)) continue;\n\n const bucket = this.buckets[id];\n // Buckets are grouped by common source-layer\n const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer';\n const sourceLayer = vtLayers[sourceLayerId];\n const sourceLayerStates = states[sourceLayerId];\n if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) continue;\n\n bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {});\n const layer = painter && painter.style && painter.style.getLayer(id);\n if (layer) {\n this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket));\n }\n }\n }\n\n holdingForFade(): boolean {\n return this.symbolFadeHoldUntil !== undefined;\n }\n\n symbolFadeFinished(): boolean {\n return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < browser.now();\n }\n\n clearFadeHold() {\n this.symbolFadeHoldUntil = undefined;\n }\n\n setHoldDuration(duration: number) {\n this.symbolFadeHoldUntil = browser.now() + duration;\n }\n\n setDependencies(namespace: string, dependencies: Array) {\n const index = {};\n for (const dep of dependencies) {\n index[dep] = true;\n }\n this.dependencies[namespace] = index;\n }\n\n hasDependency(namespaces: Array, keys: Array) {\n for (const namespace of namespaces) {\n const dependencies = this.dependencies[namespace];\n if (dependencies) {\n for (const key of keys) {\n if (dependencies[key]) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}\n","import type {CollisionBoxArray} from './array_types.g';\nimport type {Style} from '../style/style';\nimport type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';\nimport type {FeatureIndex} from './feature_index';\nimport type {Context} from '../gl/context';\nimport type {FeatureStates} from '../source/source_state';\nimport type {ImagePosition} from '../render/image_atlas';\nimport type {CanonicalTileID} from '../source/tile_id';\nimport type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile';\nimport Point from '@mapbox/point-geometry';\n\nexport type BucketParameters = {\n index: number;\n layers: Array;\n zoom: number;\n pixelRatio: number;\n overscaling: number;\n collisionBoxArray: CollisionBoxArray;\n sourceLayerIndex: number;\n sourceID: string;\n};\n\nexport type PopulateParameters = {\n featureIndex: FeatureIndex;\n iconDependencies: {};\n patternDependencies: {};\n glyphDependencies: {};\n availableImages: Array;\n};\n\nexport type IndexedFeature = {\n feature: VectorTileFeature;\n id: number | string;\n index: number;\n sourceLayerIndex: number;\n};\n\nexport type BucketFeature = {\n index: number;\n sourceLayerIndex: number;\n geometry: Array>;\n properties: any;\n type: 0 | 1 | 2 | 3;\n id?: any;\n readonly patterns: {\n [_: string]: {\n 'min': string;\n 'mid': string;\n 'max': string;\n };\n };\n sortKey?: number;\n};\n\n/**\n * The `Bucket` interface is the single point of knowledge about turning vector\n * tiles into WebGL buffers.\n *\n * `Bucket` is an abstract interface. An implementation exists for each style layer type.\n * Create a bucket via the `StyleLayer#createBucket` method.\n *\n * The concrete bucket types, using layout options from the style layer,\n * transform feature geometries into vertex and index data for use by the\n * vertex shader. They also (via `ProgramConfiguration`) use feature\n * properties and the zoom level to populate the attributes needed for\n * data-driven styling.\n *\n * Buckets are designed to be built on a worker thread and then serialized and\n * transferred back to the main thread for rendering. On the worker side, a\n * bucket's vertex, index, and attribute data is stored in `bucket.arrays: ArrayGroup`.\n * When a bucket's data is serialized and sent back to the main thread,\n * is gets deserialized (using `new Bucket(serializedBucketData)`, with\n * the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups\n * hold the same data as ArrayGroups, but are tuned for consumption by WebGL.\n */\nexport interface Bucket {\n layerIds: Array;\n hasPattern: boolean;\n readonly layers: Array;\n readonly stateDependentLayers: Array;\n readonly stateDependentLayerIds: Array;\n populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void;\n update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}): void;\n isEmpty(): boolean;\n upload(context: Context): void;\n uploadPending(): boolean;\n /**\n * Release the WebGL resources associated with the buffers. Note that because\n * buckets are shared between layers having the same layout properties, they\n * must be destroyed in groups (all buckets for a tile, or all symbol buckets).\n */\n destroy(): void;\n}\n\nexport function deserialize(input: Array, style: Style): {[_: string]: Bucket} {\n const output = {};\n\n // Guard against the case where the map's style has been set to null while\n // this bucket has been parsing.\n if (!style) return output;\n\n for (const bucket of input) {\n const layers = bucket.layerIds\n .map((id) => style.getLayer(id))\n .filter(Boolean);\n\n if (layers.length === 0) {\n continue;\n }\n\n // look up StyleLayer objects from layer ids (since we don't\n // want to waste time serializing/copying them from the worker)\n (bucket as any).layers = layers;\n if (bucket.stateDependentLayerIds) {\n (bucket as any).stateDependentLayers = bucket.stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]);\n }\n for (const layer of layers) {\n output[layer.id] = bucket;\n }\n }\n\n return output;\n}\n","import {OverscaledTileID} from './tile_id';\nimport type {Tile} from './tile';\n\n/**\n * @internal\n * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms)\n * with hash lookup made possible by keeping a list of keys in parallel to\n * an array of dictionary of values\n */\nexport class TileCache {\n max: number;\n data: {\n [key: string]: Array<{\n value: Tile;\n timeout: ReturnType;\n }>;\n };\n order: Array;\n onRemove: (element: Tile) => void;\n /**\n * @param max - number of permitted values\n * @param onRemove - callback called with items when they expire\n */\n constructor(max: number, onRemove: (element: Tile) => void) {\n this.max = max;\n this.onRemove = onRemove;\n this.reset();\n }\n\n /**\n * Clear the cache\n *\n * @returns this cache\n */\n reset() {\n for (const key in this.data) {\n for (const removedData of this.data[key]) {\n if (removedData.timeout) clearTimeout(removedData.timeout);\n this.onRemove(removedData.value);\n }\n }\n\n this.data = {};\n this.order = [];\n\n return this;\n }\n\n /**\n * Add a key, value combination to the cache, trimming its size if this pushes\n * it over max length.\n *\n * @param tileID - lookup key for the item\n * @param data - tile data\n *\n * @returns this cache\n */\n add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void) {\n const key = tileID.wrapped().key;\n if (this.data[key] === undefined) {\n this.data[key] = [];\n }\n\n const dataWrapper = {\n value: data,\n timeout: undefined\n };\n\n if (expiryTimeout !== undefined) {\n dataWrapper.timeout = setTimeout(() => {\n this.remove(tileID, dataWrapper);\n }, expiryTimeout as number);\n }\n\n this.data[key].push(dataWrapper);\n this.order.push(key);\n\n if (this.order.length > this.max) {\n const removedData = this._getAndRemoveByKey(this.order[0]);\n if (removedData) this.onRemove(removedData);\n }\n\n return this;\n }\n\n /**\n * Determine whether the value attached to `key` is present\n *\n * @param tileID - the key to be looked-up\n * @returns whether the cache has this value\n */\n has(tileID: OverscaledTileID): boolean {\n return tileID.wrapped().key in this.data;\n }\n\n /**\n * Get the value attached to a specific key and remove data from cache.\n * If the key is not found, returns `null`\n *\n * @param tileID - the key to look up\n * @returns the tile data, or null if it isn't found\n */\n getAndRemove(tileID: OverscaledTileID): Tile {\n if (!this.has(tileID)) { return null; }\n return this._getAndRemoveByKey(tileID.wrapped().key);\n }\n\n /*\n * Get and remove the value with the specified key.\n */\n _getAndRemoveByKey(key: string): Tile {\n const data = this.data[key].shift();\n if (data.timeout) clearTimeout(data.timeout);\n\n if (this.data[key].length === 0) {\n delete this.data[key];\n }\n this.order.splice(this.order.indexOf(key), 1);\n\n return data.value;\n }\n\n /*\n * Get the value with the specified (wrapped tile) key.\n */\n getByKey(key: string): Tile {\n const data = this.data[key];\n return data ? data[0].value : null;\n }\n\n /**\n * Get the value attached to a specific key without removing data\n * from the cache. If the key is not found, returns `null`\n *\n * @param tileID - the key to look up\n * @returns the tile data, or null if it isn't found\n */\n get(tileID: OverscaledTileID): Tile {\n if (!this.has(tileID)) { return null; }\n\n const data = this.data[tileID.wrapped().key][0];\n return data.value;\n }\n\n /**\n * Remove a key/value combination from the cache.\n *\n * @param tileID - the key for the pair to delete\n * @param value - If a value is provided, remove that exact version of the value.\n * @returns this cache\n */\n remove(tileID: OverscaledTileID, value?: {\n value: Tile;\n timeout: ReturnType;\n }) {\n if (!this.has(tileID)) { return this; }\n const key = tileID.wrapped().key;\n\n const dataIndex = value === undefined ? 0 : this.data[key].indexOf(value);\n const data = this.data[key][dataIndex];\n this.data[key].splice(dataIndex, 1);\n if (data.timeout) clearTimeout(data.timeout);\n if (this.data[key].length === 0) {\n delete this.data[key];\n }\n this.onRemove(data.value);\n this.order.splice(this.order.indexOf(key), 1);\n\n return this;\n }\n\n /**\n * Change the max size of the cache.\n *\n * @param max - the max size of the cache\n * @returns this cache\n */\n setMaxSize(max: number): TileCache {\n this.max = max;\n\n while (this.order.length > this.max) {\n const removedData = this._getAndRemoveByKey(this.order[0]);\n if (removedData) this.onRemove(removedData);\n }\n\n return this;\n }\n\n /**\n * Remove entries that do not pass a filter function. Used for removing\n * stale tiles from the cache.\n *\n * @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out.\n */\n filter(filterFn: (tile: Tile) => boolean) {\n const removed = [];\n for (const key in this.data) {\n for (const entry of this.data[key]) {\n if (!filterFn(entry.value)) {\n removed.push(entry);\n }\n }\n }\n for (const r of removed) {\n this.remove(r.value.tileID, r);\n }\n }\n}\n","import {extend} from '../util/util';\nimport {Tile} from './tile';\nimport type {FeatureState} from '@maplibre/maplibre-gl-style-spec';\n\nexport type FeatureStates = {[featureId: string]: FeatureState};\nexport type LayerFeatureStates = {[layer: string]: FeatureStates};\n\n/**\n * @internal\n * SourceFeatureState manages the state and pending changes\n * to features in a source, separated by source layer.\n * stateChanges and deletedStates batch all changes to the tile (updates and removes, respectively)\n * between coalesce() events. addFeatureState() and removeFeatureState() also update their counterpart's\n * list of changes, such that coalesce() can apply the proper state changes while agnostic to the order of operations.\n * In deletedStates, all null's denote complete removal of state at that scope\n*/\nexport class SourceFeatureState {\n state: LayerFeatureStates;\n stateChanges: LayerFeatureStates;\n deletedStates: {};\n\n constructor() {\n this.state = {};\n this.stateChanges = {};\n this.deletedStates = {};\n }\n\n updateState(sourceLayer: string, featureId: number | string, newState: any) {\n const feature = String(featureId);\n this.stateChanges[sourceLayer] = this.stateChanges[sourceLayer] || {};\n this.stateChanges[sourceLayer][feature] = this.stateChanges[sourceLayer][feature] || {};\n extend(this.stateChanges[sourceLayer][feature], newState);\n\n if (this.deletedStates[sourceLayer] === null) {\n this.deletedStates[sourceLayer] = {};\n for (const ft in this.state[sourceLayer]) {\n if (ft !== feature) this.deletedStates[sourceLayer][ft] = null;\n }\n } else {\n const featureDeletionQueued = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] === null;\n if (featureDeletionQueued) {\n this.deletedStates[sourceLayer][feature] = {};\n for (const prop in this.state[sourceLayer][feature]) {\n if (!newState[prop]) this.deletedStates[sourceLayer][feature][prop] = null;\n }\n } else {\n for (const key in newState) {\n const deletionInQueue = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] && this.deletedStates[sourceLayer][feature][key] === null;\n if (deletionInQueue) delete this.deletedStates[sourceLayer][feature][key];\n }\n }\n }\n }\n\n removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string) {\n const sourceLayerDeleted = this.deletedStates[sourceLayer] === null;\n if (sourceLayerDeleted) return;\n\n const feature = String(featureId);\n\n this.deletedStates[sourceLayer] = this.deletedStates[sourceLayer] || {};\n\n if (key && featureId !== undefined) {\n if (this.deletedStates[sourceLayer][feature] !== null) {\n this.deletedStates[sourceLayer][feature] = this.deletedStates[sourceLayer][feature] || {};\n this.deletedStates[sourceLayer][feature][key] = null;\n }\n } else if (featureId !== undefined) {\n const updateInQueue = this.stateChanges[sourceLayer] && this.stateChanges[sourceLayer][feature];\n if (updateInQueue) {\n this.deletedStates[sourceLayer][feature] = {};\n for (key in this.stateChanges[sourceLayer][feature]) this.deletedStates[sourceLayer][feature][key] = null;\n\n } else {\n this.deletedStates[sourceLayer][feature] = null;\n }\n } else {\n this.deletedStates[sourceLayer] = null;\n }\n\n }\n\n getState(sourceLayer: string, featureId: number | string) {\n const feature = String(featureId);\n const base = this.state[sourceLayer] || {};\n const changes = this.stateChanges[sourceLayer] || {};\n\n const reconciledState = extend({}, base[feature], changes[feature]);\n\n //return empty object if the whole source layer is awaiting deletion\n if (this.deletedStates[sourceLayer] === null) return {};\n else if (this.deletedStates[sourceLayer]) {\n const featureDeletions = this.deletedStates[sourceLayer][featureId];\n if (featureDeletions === null) return {};\n for (const prop in featureDeletions) delete reconciledState[prop];\n }\n return reconciledState;\n }\n\n initializeTileState(tile: Tile, painter: any) {\n tile.setFeatureState(this.state, painter);\n }\n\n coalesceChanges(tiles: {\n [_ in any]: Tile;\n }, painter: any) {\n //track changes with full state objects, but only for features that got modified\n const featuresChanged: LayerFeatureStates = {};\n\n for (const sourceLayer in this.stateChanges) {\n this.state[sourceLayer] = this.state[sourceLayer] || {};\n const layerStates = {};\n for (const feature in this.stateChanges[sourceLayer]) {\n if (!this.state[sourceLayer][feature]) this.state[sourceLayer][feature] = {};\n extend(this.state[sourceLayer][feature], this.stateChanges[sourceLayer][feature]);\n layerStates[feature] = this.state[sourceLayer][feature];\n }\n featuresChanged[sourceLayer] = layerStates;\n }\n\n for (const sourceLayer in this.deletedStates) {\n this.state[sourceLayer] = this.state[sourceLayer] || {};\n const layerStates = {};\n\n if (this.deletedStates[sourceLayer] === null) {\n for (const ft in this.state[sourceLayer]) {\n layerStates[ft] = {};\n this.state[sourceLayer][ft] = {};\n }\n } else {\n for (const feature in this.deletedStates[sourceLayer]) {\n const deleteWholeFeatureState = this.deletedStates[sourceLayer][feature] === null;\n if (deleteWholeFeatureState) this.state[sourceLayer][feature] = {};\n else {\n for (const key of Object.keys(this.deletedStates[sourceLayer][feature])) {\n delete this.state[sourceLayer][feature][key];\n }\n }\n layerStates[feature] = this.state[sourceLayer][feature];\n }\n }\n\n featuresChanged[sourceLayer] = featuresChanged[sourceLayer] || {};\n extend(featuresChanged[sourceLayer], layerStates);\n }\n\n this.stateChanges = {};\n this.deletedStates = {};\n\n if (Object.keys(featuresChanged).length === 0) return;\n\n for (const id in tiles) {\n const tile = tiles[id];\n tile.setFeatureState(featuresChanged, painter);\n }\n }\n}\n","import {create as createSource} from './source';\n\nimport {Tile} from './tile';\nimport {Event, ErrorEvent, Evented} from '../util/evented';\nimport {TileCache} from './tile_cache';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\nimport {keysDifference} from '../util/util';\nimport {EXTENT} from '../data/extent';\nimport {Context} from '../gl/context';\nimport Point from '@mapbox/point-geometry';\nimport {browser} from '../util/browser';\nimport {OverscaledTileID} from './tile_id';\nimport {SourceFeatureState} from './source_state';\n\nimport type {Source} from './source';\nimport type {Map} from '../ui/map';\nimport type {Style} from '../style/style';\nimport type {Dispatcher} from '../util/dispatcher';\nimport type {Transform} from '../geo/transform';\nimport type {TileState} from './tile';\nimport type {Callback} from '../types/callback';\nimport type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {MapSourceDataEvent} from '../ui/events';\nimport {Terrain} from '../render/terrain';\nimport {config} from '../util/config';\n\n/**\n * @internal\n * `SourceCache` is responsible for\n *\n * - creating an instance of `Source`\n * - forwarding events from `Source`\n * - caching tiles loaded from an instance of `Source`\n * - loading the tiles needed to render a given viewport\n * - unloading the cached tiles not needed to render a given viewport\n */\nexport class SourceCache extends Evented {\n id: string;\n dispatcher: Dispatcher;\n map: Map;\n style: Style;\n\n _source: Source;\n _sourceLoaded: boolean;\n _sourceErrored: boolean;\n _tiles: {[_: string]: Tile};\n _prevLng: number;\n _cache: TileCache;\n _timers: {\n [_ in any]: ReturnType;\n };\n _cacheTimers: {\n [_ in any]: ReturnType;\n };\n _maxTileCacheSize: number;\n _maxTileCacheZoomLevels: number;\n _paused: boolean;\n _shouldReloadOnResume: boolean;\n _coveredTiles: {[_: string]: boolean};\n transform: Transform;\n terrain: Terrain;\n used: boolean;\n usedForTerrain: boolean;\n tileSize: number;\n _state: SourceFeatureState;\n _loadedParentTiles: {[_: string]: Tile};\n _didEmitContent: boolean;\n _updated: boolean;\n\n static maxUnderzooming: number;\n static maxOverzooming: number;\n\n constructor(id: string, options: SourceSpecification, dispatcher: Dispatcher) {\n super();\n this.id = id;\n this.dispatcher = dispatcher;\n\n this.on('data', (e: MapSourceDataEvent) => {\n // this._sourceLoaded signifies that the TileJSON is loaded if applicable.\n // if the source type does not come with a TileJSON, the flag signifies the\n // source data has loaded (i.e geojson has been tiled on the worker and is ready)\n if (e.dataType === 'source' && e.sourceDataType === 'metadata') this._sourceLoaded = true;\n\n // for sources with mutable data, this event fires when the underlying data\n // to a source is changed. (i.e. GeoJSONSource#setData and ImageSource#serCoordinates)\n if (this._sourceLoaded && !this._paused && e.dataType === 'source' && e.sourceDataType === 'content') {\n this.reload();\n if (this.transform) {\n this.update(this.transform, this.terrain);\n }\n\n this._didEmitContent = true;\n }\n });\n\n this.on('dataloading', () => {\n this._sourceErrored = false;\n });\n\n this.on('error', () => {\n // Only set _sourceErrored if the source does not have pending loads.\n this._sourceErrored = this._source.loaded();\n });\n\n this._source = createSource(id, options, dispatcher, this);\n\n this._tiles = {};\n this._cache = new TileCache(0, this._unloadTile.bind(this));\n this._timers = {};\n this._cacheTimers = {};\n this._maxTileCacheSize = null;\n this._maxTileCacheZoomLevels = null;\n this._loadedParentTiles = {};\n\n this._coveredTiles = {};\n this._state = new SourceFeatureState();\n this._didEmitContent = false;\n this._updated = false;\n }\n\n onAdd(map: Map) {\n this.map = map;\n this._maxTileCacheSize = map ? map._maxTileCacheSize : null;\n this._maxTileCacheZoomLevels = map ? map._maxTileCacheZoomLevels : null;\n if (this._source && this._source.onAdd) {\n this._source.onAdd(map);\n }\n }\n\n onRemove(map: Map) {\n this.clearTiles();\n if (this._source && this._source.onRemove) {\n this._source.onRemove(map);\n }\n }\n\n /**\n * Return true if no tile data is pending, tiles will not change unless\n * an additional API call is received.\n */\n loaded(): boolean {\n if (this._sourceErrored) { return true; }\n if (!this._sourceLoaded) { return false; }\n if (!this._source.loaded()) { return false; }\n if ((this.used !== undefined || this.usedForTerrain !== undefined) && !this.used && !this.usedForTerrain) { return true; }\n // do not consider as loaded if the update hasn't been called yet (we do not know if we will have any tiles to fetch)\n if (!this._updated) { return false; }\n\n for (const t in this._tiles) {\n const tile = this._tiles[t];\n if (tile.state !== 'loaded' && tile.state !== 'errored')\n return false;\n }\n return true;\n }\n\n getSource(): Source {\n return this._source;\n }\n\n pause() {\n this._paused = true;\n }\n\n resume() {\n if (!this._paused) return;\n const shouldReload = this._shouldReloadOnResume;\n this._paused = false;\n this._shouldReloadOnResume = false;\n if (shouldReload) this.reload();\n if (this.transform) this.update(this.transform, this.terrain);\n }\n\n _loadTile(tile: Tile, callback: Callback) {\n return this._source.loadTile(tile, callback);\n }\n\n _unloadTile(tile: Tile) {\n if (this._source.unloadTile)\n return this._source.unloadTile(tile, () => {});\n }\n\n _abortTile(tile: Tile) {\n if (this._source.abortTile)\n this._source.abortTile(tile, () => {});\n\n this._source.fire(new Event('dataabort', {tile, coord: tile.tileID, dataType: 'source'}));\n }\n\n serialize() {\n return this._source.serialize();\n }\n\n prepare(context: Context) {\n if (this._source.prepare) {\n this._source.prepare();\n }\n\n this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null);\n for (const i in this._tiles) {\n const tile = this._tiles[i];\n tile.upload(context);\n tile.prepare(this.map.style.imageManager);\n }\n }\n\n /**\n * Return all tile ids ordered with z-order, and cast to numbers\n */\n getIds(): Array {\n return (Object.values(this._tiles) as any).map((tile: Tile) => tile.tileID).sort(compareTileId).map(id => id.key);\n }\n\n getRenderableIds(symbolLayer?: boolean): Array {\n const renderables: Array = [];\n for (const id in this._tiles) {\n if (this._isIdRenderable(id, symbolLayer)) renderables.push(this._tiles[id]);\n }\n if (symbolLayer) {\n return renderables.sort((a_: Tile, b_: Tile) => {\n const a = a_.tileID;\n const b = b_.tileID;\n const rotatedA = (new Point(a.canonical.x, a.canonical.y))._rotate(this.transform.angle);\n const rotatedB = (new Point(b.canonical.x, b.canonical.y))._rotate(this.transform.angle);\n return a.overscaledZ - b.overscaledZ || rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x;\n }).map(tile => tile.tileID.key);\n }\n return renderables.map(tile => tile.tileID).sort(compareTileId).map(id => id.key);\n }\n\n hasRenderableParent(tileID: OverscaledTileID) {\n const parentTile = this.findLoadedParent(tileID, 0);\n if (parentTile) {\n return this._isIdRenderable(parentTile.tileID.key);\n }\n return false;\n }\n\n _isIdRenderable(id: string, symbolLayer?: boolean) {\n return this._tiles[id] && this._tiles[id].hasData() &&\n !this._coveredTiles[id] && (symbolLayer || !this._tiles[id].holdingForFade());\n }\n\n reload() {\n if (this._paused) {\n this._shouldReloadOnResume = true;\n return;\n }\n\n this._cache.reset();\n\n for (const i in this._tiles) {\n if (this._tiles[i].state !== 'errored') this._reloadTile(i, 'reloading');\n }\n }\n\n _reloadTile(id: string, state: TileState) {\n const tile = this._tiles[id];\n\n // this potentially does not address all underlying\n // issues https://github.com/mapbox/mapbox-gl-js/issues/4252\n // - hard to tell without repro steps\n if (!tile) return;\n\n // The difference between \"loading\" tiles and \"reloading\" or \"expired\"\n // tiles is that \"reloading\"/\"expired\" tiles are \"renderable\".\n // Therefore, a \"loading\" tile cannot become a \"reloading\" tile without\n // first becoming a \"loaded\" tile.\n if (tile.state !== 'loading') {\n tile.state = state;\n }\n\n this._loadTile(tile, this._tileLoaded.bind(this, tile, id, state));\n }\n\n _tileLoaded(tile: Tile, id: string, previousState: TileState, err?: Error | null) {\n if (err) {\n tile.state = 'errored';\n if ((err as any).status !== 404) this._source.fire(new ErrorEvent(err, {tile}));\n // continue to try loading parent/children tiles if a tile doesn't exist (404)\n else this.update(this.transform, this.terrain);\n return;\n }\n\n tile.timeAdded = browser.now();\n if (previousState === 'expired') tile.refreshedUponExpiration = true;\n this._setTileReloadTimer(id, tile);\n if (this.getSource().type === 'raster-dem' && tile.dem) this._backfillDEM(tile);\n this._state.initializeTileState(tile, this.map ? this.map.painter : null);\n\n if (!tile.aborted) {\n this._source.fire(new Event('data', {dataType: 'source', tile, coord: tile.tileID}));\n }\n }\n\n /**\n * For raster terrain source, backfill DEM to eliminate visible tile boundaries\n */\n _backfillDEM(tile: Tile) {\n const renderables = this.getRenderableIds();\n for (let i = 0; i < renderables.length; i++) {\n const borderId = renderables[i];\n if (tile.neighboringTiles && tile.neighboringTiles[borderId]) {\n const borderTile = this.getTileByID(borderId);\n fillBorder(tile, borderTile);\n fillBorder(borderTile, tile);\n }\n }\n\n function fillBorder(tile, borderTile) {\n tile.needsHillshadePrepare = true;\n tile.needsTerrainPrepare = true;\n let dx = borderTile.tileID.canonical.x - tile.tileID.canonical.x;\n const dy = borderTile.tileID.canonical.y - tile.tileID.canonical.y;\n const dim = Math.pow(2, tile.tileID.canonical.z);\n const borderId = borderTile.tileID.key;\n if (dx === 0 && dy === 0) return;\n\n if (Math.abs(dy) > 1) {\n return;\n }\n if (Math.abs(dx) > 1) {\n // Adjust the delta coordinate for world wraparound.\n if (Math.abs(dx + dim) === 1) {\n dx += dim;\n } else if (Math.abs(dx - dim) === 1) {\n dx -= dim;\n }\n }\n if (!borderTile.dem || !tile.dem) return;\n tile.dem.backfillBorder(borderTile.dem, dx, dy);\n if (tile.neighboringTiles && tile.neighboringTiles[borderId])\n tile.neighboringTiles[borderId].backfilled = true;\n }\n }\n /**\n * Get a specific tile by TileID\n */\n getTile(tileID: OverscaledTileID): Tile {\n return this.getTileByID(tileID.key);\n }\n\n /**\n * Get a specific tile by id\n */\n getTileByID(id: string): Tile {\n return this._tiles[id];\n }\n\n /**\n * For a given set of tiles, retain children that are loaded and have a zoom\n * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive)\n */\n _retainLoadedChildren(\n idealTiles: {\n [_ in any]: OverscaledTileID;\n },\n zoom: number,\n maxCoveringZoom: number,\n retain: {\n [_ in any]: OverscaledTileID;\n }\n ) {\n for (const id in this._tiles) {\n let tile = this._tiles[id];\n\n // only consider renderable tiles up to maxCoveringZoom\n if (retain[id] ||\n !tile.hasData() ||\n tile.tileID.overscaledZ <= zoom ||\n tile.tileID.overscaledZ > maxCoveringZoom\n ) continue;\n\n // loop through parents and retain the topmost loaded one if found\n let topmostLoadedID = tile.tileID;\n while (tile && tile.tileID.overscaledZ > zoom + 1) {\n const parentID = tile.tileID.scaledTo(tile.tileID.overscaledZ - 1);\n\n tile = this._tiles[parentID.key];\n\n if (tile && tile.hasData()) {\n topmostLoadedID = parentID;\n }\n }\n\n // loop through ancestors of the topmost loaded child to see if there's one that needed it\n let tileID = topmostLoadedID;\n while (tileID.overscaledZ > zoom) {\n tileID = tileID.scaledTo(tileID.overscaledZ - 1);\n\n if (idealTiles[tileID.key]) {\n // found a parent that needed a loaded child; retain that child\n retain[topmostLoadedID.key] = topmostLoadedID;\n break;\n }\n }\n }\n }\n\n /**\n * Find a loaded parent of the given tile (up to minCoveringZoom)\n */\n findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): Tile {\n if (tileID.key in this._loadedParentTiles) {\n const parent = this._loadedParentTiles[tileID.key];\n if (parent && parent.tileID.overscaledZ >= minCoveringZoom) {\n return parent;\n } else {\n return null;\n }\n }\n for (let z = tileID.overscaledZ - 1; z >= minCoveringZoom; z--) {\n const parentTileID = tileID.scaledTo(z);\n const tile = this._getLoadedTile(parentTileID);\n if (tile) {\n return tile;\n }\n }\n }\n\n _getLoadedTile(tileID: OverscaledTileID): Tile {\n const tile = this._tiles[tileID.key];\n if (tile && tile.hasData()) {\n return tile;\n }\n // TileCache ignores wrap in lookup.\n const cachedTile = this._cache.getByKey(tileID.wrapped().key);\n return cachedTile;\n }\n\n /**\n * Resizes the tile cache based on the current viewport's size\n * or the maxTileCacheSize option passed during map creation\n *\n * Larger viewports use more tiles and need larger caches. Larger viewports\n * are more likely to be found on devices with more memory and on pages where\n * the map is more important.\n */\n updateCacheSize(transform: Transform) {\n const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1;\n const heightInTiles = Math.ceil(transform.height / this._source.tileSize) + 1;\n const approxTilesInView = widthInTiles * heightInTiles;\n const commonZoomRange = this._maxTileCacheZoomLevels === null ?\n config.MAX_TILE_CACHE_ZOOM_LEVELS : this._maxTileCacheZoomLevels;\n const viewDependentMaxSize = Math.floor(approxTilesInView * commonZoomRange);\n const maxSize = typeof this._maxTileCacheSize === 'number' ?\n Math.min(this._maxTileCacheSize, viewDependentMaxSize) : viewDependentMaxSize;\n\n this._cache.setMaxSize(maxSize);\n }\n\n handleWrapJump(lng: number) {\n // On top of the regular z/x/y values, TileIDs have a `wrap` value that specify\n // which cppy of the world the tile belongs to. For example, at `lng: 10` you\n // might render z/x/y/0 while at `lng: 370` you would render z/x/y/1.\n //\n // When lng values get wrapped (going from `lng: 370` to `long: 10`) you expect\n // to see the same thing on the screen (370 degrees and 10 degrees is the same\n // place in the world) but all the TileIDs will have different wrap values.\n //\n // In order to make this transition seamless, we calculate the rounded difference of\n // \"worlds\" between the last frame and the current frame. If the map panned by\n // a world, then we can assign all the tiles new TileIDs with updated wrap values.\n // For example, assign z/x/y/1 a new id: z/x/y/0. It is the same tile, just rendered\n // in a different position.\n //\n // This enables us to reuse the tiles at more ideal locations and prevent flickering.\n const prevLng = this._prevLng === undefined ? lng : this._prevLng;\n const lngDifference = lng - prevLng;\n const worldDifference = lngDifference / 360;\n const wrapDelta = Math.round(worldDifference);\n this._prevLng = lng;\n\n if (wrapDelta) {\n const tiles: {[_: string]: Tile} = {};\n for (const key in this._tiles) {\n const tile = this._tiles[key];\n tile.tileID = tile.tileID.unwrapTo(tile.tileID.wrap + wrapDelta);\n tiles[tile.tileID.key] = tile;\n }\n this._tiles = tiles;\n\n // Reset tile reload timers\n for (const id in this._timers) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n this._setTileReloadTimer(id, tile);\n }\n }\n }\n\n /**\n * Removes tiles that are outside the viewport and adds new tiles that\n * are inside the viewport.\n */\n update(transform: Transform, terrain?: Terrain) {\n this.transform = transform;\n this.terrain = terrain;\n if (!this._sourceLoaded || this._paused) { return; }\n\n this.updateCacheSize(transform);\n this.handleWrapJump(this.transform.center.lng);\n\n // Covered is a list of retained tiles who's areas are fully covered by other,\n // better, retained tiles. They are not drawn separately.\n this._coveredTiles = {};\n\n let idealTileIDs;\n if (!this.used && !this.usedForTerrain) {\n idealTileIDs = [];\n } else if (this._source.tileID) {\n idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID)\n .map((unwrapped) => new OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y));\n } else {\n idealTileIDs = transform.coveringTiles({\n tileSize: this.usedForTerrain ? this.tileSize : this._source.tileSize,\n minzoom: this._source.minzoom,\n maxzoom: this._source.maxzoom,\n roundZoom: this.usedForTerrain ? false : this._source.roundZoom,\n reparseOverscaled: this._source.reparseOverscaled,\n terrain\n });\n\n if (this._source.hasTile) {\n idealTileIDs = idealTileIDs.filter((coord) => (this._source.hasTile as any)(coord));\n }\n }\n\n // Determine the overzooming/underzooming amounts.\n const zoom = transform.coveringZoomLevel(this._source);\n const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);\n const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);\n\n // When sourcecache is used for terrain also load parent tiles to avoid flickering when zooming out\n if (this.usedForTerrain) {\n const parents = {};\n for (const tileID of idealTileIDs) {\n if (tileID.canonical.z > this._source.minzoom) {\n const parent = tileID.scaledTo(tileID.canonical.z - 1);\n parents[parent.key] = parent;\n // load very low zoom to calculate tile visibility in transform.coveringTiles and high zoomlevels correct\n const parent2 = tileID.scaledTo(Math.max(this._source.minzoom, Math.min(tileID.canonical.z, 5)));\n parents[parent2.key] = parent2;\n }\n }\n idealTileIDs = idealTileIDs.concat(Object.values(parents));\n }\n\n const noPendingDataEmissions = idealTileIDs.length === 0 && !this._updated && this._didEmitContent;\n this._updated = true;\n // if we won't have any tiles to fetch and content is already emitted\n // there will be no more data emissions, so we need to emit the event with isSourceLoaded = true\n if (noPendingDataEmissions) {\n this.fire(new Event('data', {sourceDataType: 'idle', dataType: 'source', sourceId: this.id}));\n }\n\n // Retain is a list of tiles that we shouldn't delete, even if they are not\n // the most ideal tile for the current viewport. This may include tiles like\n // parent or child tiles that are *already* loaded.\n const retain = this._updateRetainedTiles(idealTileIDs, zoom);\n\n if (isRasterType(this._source.type)) {\n const parentsForFading: {[_: string]: OverscaledTileID} = {};\n const fadingTiles = {};\n const ids = Object.keys(retain);\n const now = browser.now();\n for (const id of ids) {\n const tileID = retain[id];\n\n const tile = this._tiles[id];\n\n // when fadeEndTime is 0, the tile is created but registerFadeDuration\n // has not been called, therefore must be kept in fadingTiles dictionary\n // for next round of rendering\n if (!tile || (tile.fadeEndTime !== 0 && tile.fadeEndTime <= now)) {\n continue;\n }\n\n // if the tile is loaded but still fading in, find parents to cross-fade with it\n const parentTile = this.findLoadedParent(tileID, minCoveringZoom);\n if (parentTile) {\n this._addTile(parentTile.tileID);\n parentsForFading[parentTile.tileID.key] = parentTile.tileID;\n }\n\n fadingTiles[id] = tileID;\n }\n\n // for tiles that are still fading in, also find children to cross-fade with\n this._retainLoadedChildren(fadingTiles, zoom, maxCoveringZoom, retain);\n\n for (const id in parentsForFading) {\n if (!retain[id]) {\n // If a tile is only needed for fading, mark it as covered so that it isn't rendered on it's own.\n this._coveredTiles[id] = true;\n retain[id] = parentsForFading[id];\n }\n }\n\n // disable fading logic in terrain3D mode to avoid rendering two tiles on the same place\n if (terrain) {\n const idealRasterTileIDs: {[_: string]: OverscaledTileID} = {};\n const missingTileIDs: {[_: string]: OverscaledTileID} = {};\n for (const tileID of idealTileIDs) {\n if (this._tiles[tileID.key].hasData())\n idealRasterTileIDs[tileID.key] = tileID;\n else\n missingTileIDs[tileID.key] = tileID;\n }\n // search for a complete set of children for each missing tile\n for (const key in missingTileIDs) {\n const children = missingTileIDs[key].children(this._source.maxzoom);\n if (this._tiles[children[0].key] && this._tiles[children[1].key] && this._tiles[children[2].key] && this._tiles[children[3].key]) {\n idealRasterTileIDs[children[0].key] = retain[children[0].key] = children[0];\n idealRasterTileIDs[children[1].key] = retain[children[1].key] = children[1];\n idealRasterTileIDs[children[2].key] = retain[children[2].key] = children[2];\n idealRasterTileIDs[children[3].key] = retain[children[3].key] = children[3];\n delete missingTileIDs[key];\n }\n }\n // search for parent for each missing tile\n for (const key in missingTileIDs) {\n const parent = this.findLoadedParent(missingTileIDs[key], this._source.minzoom);\n if (parent) {\n idealRasterTileIDs[parent.tileID.key] = retain[parent.tileID.key] = parent.tileID;\n // remove idealTiles which would be rendered twice\n for (const key in idealRasterTileIDs) {\n if (idealRasterTileIDs[key].isChildOf(parent.tileID)) delete idealRasterTileIDs[key];\n }\n }\n }\n // cover all tiles which are not needed\n for (const key in this._tiles) {\n if (!idealRasterTileIDs[key]) this._coveredTiles[key] = true;\n }\n }\n }\n\n for (const retainedId in retain) {\n // Make sure retained tiles always clear any existing fade holds\n // so that if they're removed again their fade timer starts fresh.\n this._tiles[retainedId].clearFadeHold();\n }\n\n // Remove the tiles we don't need anymore.\n const remove = keysDifference(this._tiles, retain);\n for (const tileID of remove) {\n const tile = this._tiles[tileID];\n if (tile.hasSymbolBuckets && !tile.holdingForFade()) {\n tile.setHoldDuration(this.map._fadeDuration);\n } else if (!tile.hasSymbolBuckets || tile.symbolFadeFinished()) {\n this._removeTile(tileID);\n }\n }\n\n // Construct a cache of loaded parents\n this._updateLoadedParentTileCache();\n }\n\n releaseSymbolFadeTiles() {\n for (const id in this._tiles) {\n if (this._tiles[id].holdingForFade()) {\n this._removeTile(id);\n }\n }\n }\n\n _updateRetainedTiles(idealTileIDs: Array, zoom: number): {[_: string]: OverscaledTileID} {\n const retain: {[_: string]: OverscaledTileID} = {};\n const checked: {[_: string]: boolean} = {};\n const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);\n const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);\n\n const missingTiles = {};\n for (const tileID of idealTileIDs) {\n const tile = this._addTile(tileID);\n\n // retain the tile even if it's not loaded because it's an ideal tile.\n retain[tileID.key] = tileID;\n\n if (tile.hasData()) continue;\n\n if (zoom < this._source.maxzoom) {\n // save missing tiles that potentially have loaded children\n missingTiles[tileID.key] = tileID;\n }\n }\n\n // retain any loaded children of ideal tiles up to maxCoveringZoom\n this._retainLoadedChildren(missingTiles, zoom, maxCoveringZoom, retain);\n\n for (const tileID of idealTileIDs) {\n let tile = this._tiles[tileID.key];\n\n if (tile.hasData()) continue;\n\n // The tile we require is not yet loaded or does not exist;\n // Attempt to find children that fully cover it.\n\n if (zoom + 1 > this._source.maxzoom) {\n // We're looking for an overzoomed child tile.\n const childCoord = tileID.children(this._source.maxzoom)[0];\n const childTile = this.getTile(childCoord);\n if (!!childTile && childTile.hasData()) {\n retain[childCoord.key] = childCoord;\n continue; // tile is covered by overzoomed child\n }\n } else {\n // check if all 4 immediate children are loaded (i.e. the missing ideal tile is covered)\n const children = tileID.children(this._source.maxzoom);\n\n if (retain[children[0].key] &&\n retain[children[1].key] &&\n retain[children[2].key] &&\n retain[children[3].key]) continue; // tile is covered by children\n }\n\n // We couldn't find child tiles that entirely cover the ideal tile; look for parents now.\n\n // As we ascend up the tile pyramid of the ideal tile, we check whether the parent\n // tile has been previously requested (and errored because we only loop over tiles with no data)\n // in order to determine if we need to request its parent.\n let parentWasRequested = tile.wasRequested();\n\n for (let overscaledZ = tileID.overscaledZ - 1; overscaledZ >= minCoveringZoom; --overscaledZ) {\n const parentId = tileID.scaledTo(overscaledZ);\n\n // Break parent tile ascent if this route has been previously checked by another child.\n if (checked[parentId.key]) break;\n checked[parentId.key] = true;\n\n tile = this.getTile(parentId);\n if (!tile && parentWasRequested) {\n tile = this._addTile(parentId);\n }\n if (tile) {\n const hasData = tile.hasData();\n if (parentWasRequested || hasData) {\n retain[parentId.key] = parentId;\n }\n // Save the current values, since they're the parent of the next iteration\n // of the parent tile ascent loop.\n parentWasRequested = tile.wasRequested();\n if (hasData) break;\n }\n }\n }\n\n return retain;\n }\n\n _updateLoadedParentTileCache() {\n this._loadedParentTiles = {};\n\n for (const tileKey in this._tiles) {\n const path = [];\n let parentTile: Tile;\n let currentId = this._tiles[tileKey].tileID;\n\n // Find the closest loaded ancestor by traversing the tile tree towards the root and\n // caching results along the way\n while (currentId.overscaledZ > 0) {\n\n // Do we have a cached result from previous traversals?\n if (currentId.key in this._loadedParentTiles) {\n parentTile = this._loadedParentTiles[currentId.key];\n break;\n }\n\n path.push(currentId.key);\n\n // Is the parent loaded?\n const parentId = currentId.scaledTo(currentId.overscaledZ - 1);\n parentTile = this._getLoadedTile(parentId);\n if (parentTile) {\n break;\n }\n\n currentId = parentId;\n }\n\n // Cache the result of this traversal to all newly visited tiles\n for (const key of path) {\n this._loadedParentTiles[key] = parentTile;\n }\n }\n }\n\n /**\n * Add a tile, given its coordinate, to the pyramid.\n */\n _addTile(tileID: OverscaledTileID): Tile {\n let tile = this._tiles[tileID.key];\n if (tile)\n return tile;\n\n tile = this._cache.getAndRemove(tileID);\n if (tile) {\n this._setTileReloadTimer(tileID.key, tile);\n // set the tileID because the cached tile could have had a different wrap value\n tile.tileID = tileID;\n this._state.initializeTileState(tile, this.map ? this.map.painter : null);\n if (this._cacheTimers[tileID.key]) {\n clearTimeout(this._cacheTimers[tileID.key]);\n delete this._cacheTimers[tileID.key];\n this._setTileReloadTimer(tileID.key, tile);\n }\n }\n\n const cached = tile;\n\n if (!tile) {\n tile = new Tile(tileID, this._source.tileSize * tileID.overscaleFactor());\n this._loadTile(tile, this._tileLoaded.bind(this, tile, tileID.key, tile.state));\n }\n\n tile.uses++;\n this._tiles[tileID.key] = tile;\n if (!cached) {\n this._source.fire(new Event('dataloading', {tile, coord: tile.tileID, dataType: 'source'}));\n }\n\n return tile;\n }\n\n _setTileReloadTimer(id: string, tile: Tile) {\n if (id in this._timers) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n\n const expiryTimeout = tile.getExpiryTimeout();\n if (expiryTimeout) {\n this._timers[id] = setTimeout(() => {\n this._reloadTile(id, 'expired');\n delete this._timers[id];\n }, expiryTimeout);\n }\n }\n\n /**\n * Remove a tile, given its id, from the pyramid\n */\n _removeTile(id: string) {\n const tile = this._tiles[id];\n if (!tile)\n return;\n\n tile.uses--;\n delete this._tiles[id];\n if (this._timers[id]) {\n clearTimeout(this._timers[id]);\n delete this._timers[id];\n }\n\n if (tile.uses > 0)\n return;\n\n if (tile.hasData() && tile.state !== 'reloading') {\n this._cache.add(tile.tileID, tile, tile.getExpiryTimeout());\n } else {\n tile.aborted = true;\n this._abortTile(tile);\n this._unloadTile(tile);\n }\n }\n\n /**\n * Remove all tiles from this pyramid\n */\n clearTiles() {\n this._shouldReloadOnResume = false;\n this._paused = false;\n\n for (const id in this._tiles)\n this._removeTile(id);\n\n this._cache.reset();\n }\n\n /**\n * Search through our current tiles and attempt to find the tiles that\n * cover the given bounds.\n * @param pointQueryGeometry - coordinates of the corners of bounding rectangle\n * @returns result items have `{tile, minX, maxX, minY, maxY}`, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile.\n */\n tilesIn(pointQueryGeometry: Array, maxPitchScaleFactor: number, has3DLayer: boolean): any[] {\n\n const tileResults = [];\n\n const transform = this.transform;\n if (!transform) return tileResults;\n\n const cameraPointQueryGeometry = has3DLayer ?\n transform.getCameraQueryGeometry(pointQueryGeometry) :\n pointQueryGeometry;\n\n const queryGeometry = pointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain));\n const cameraQueryGeometry = cameraPointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain));\n\n const ids = this.getIds();\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const p of cameraQueryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n\n for (let i = 0; i < ids.length; i++) {\n const tile = this._tiles[ids[i]];\n if (tile.holdingForFade()) {\n // Tiles held for fading are covered by tiles that are closer to ideal\n continue;\n }\n const tileID = tile.tileID;\n const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);\n const queryPadding = maxPitchScaleFactor * tile.queryPadding * EXTENT / tile.tileSize / scale;\n\n const tileSpaceBounds = [\n tileID.getTilePoint(new MercatorCoordinate(minX, minY)),\n tileID.getTilePoint(new MercatorCoordinate(maxX, maxY))\n ];\n\n if (tileSpaceBounds[0].x - queryPadding < EXTENT && tileSpaceBounds[0].y - queryPadding < EXTENT &&\n tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) {\n\n const tileSpaceQueryGeometry: Array = queryGeometry.map((c) => tileID.getTilePoint(c));\n const tileSpaceCameraQueryGeometry = cameraQueryGeometry.map((c) => tileID.getTilePoint(c));\n\n tileResults.push({\n tile,\n tileID,\n queryGeometry: tileSpaceQueryGeometry,\n cameraQueryGeometry: tileSpaceCameraQueryGeometry,\n scale\n });\n }\n }\n\n return tileResults;\n }\n\n getVisibleCoordinates(symbolLayer?: boolean): Array {\n const coords = this.getRenderableIds(symbolLayer).map((id) => this._tiles[id].tileID);\n for (const coord of coords) {\n coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped());\n }\n return coords;\n }\n\n hasTransition() {\n if (this._source.hasTransition()) {\n return true;\n }\n\n if (isRasterType(this._source.type)) {\n const now = browser.now();\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n if (tile.fadeEndTime >= now) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Set the value of a particular state for a feature\n */\n setFeatureState(sourceLayer: string, featureId: number | string, state: any) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n this._state.updateState(sourceLayer, featureId, state);\n }\n\n /**\n * Resets the value of a particular state key for a feature\n */\n removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n this._state.removeFeatureState(sourceLayer, featureId, key);\n }\n\n /**\n * Get the entire state object for a feature\n */\n getFeatureState(sourceLayer: string, featureId: number | string) {\n sourceLayer = sourceLayer || '_geojsonTileLayer';\n return this._state.getState(sourceLayer, featureId);\n }\n\n /**\n * Sets the set of keys that the tile depends on. This allows tiles to\n * be reloaded when their dependencies change.\n */\n setDependencies(tileKey: string, namespace: string, dependencies: Array) {\n const tile = this._tiles[tileKey];\n if (tile) {\n tile.setDependencies(namespace, dependencies);\n }\n }\n\n /**\n * Reloads all tiles that depend on the given keys.\n */\n reloadTilesForDependencies(namespaces: Array, keys: Array) {\n for (const id in this._tiles) {\n const tile = this._tiles[id];\n if (tile.hasDependency(namespaces, keys)) {\n this._reloadTile(id, 'reloading');\n }\n }\n this._cache.filter(tile => !tile.hasDependency(namespaces, keys));\n }\n}\n\nSourceCache.maxOverzooming = 10;\nSourceCache.maxUnderzooming = 3;\n\nfunction compareTileId(a: OverscaledTileID, b: OverscaledTileID): number {\n // Different copies of the world are sorted based on their distance to the center.\n // Wrap values are converted to unsigned distances by reserving odd number for copies\n // with negative wrap and even numbers for copies with positive wrap.\n const aWrap = Math.abs(a.wrap * 2) - +(a.wrap < 0);\n const bWrap = Math.abs(b.wrap * 2) - +(b.wrap < 0);\n return a.overscaledZ - b.overscaledZ || bWrap - aWrap || b.canonical.y - a.canonical.y || b.canonical.x - a.canonical.x;\n}\n\nfunction isRasterType(type) {\n return type === 'raster' || type === 'image' || type === 'video';\n}\n","import {workerFactory} from './web_worker';\nimport {browser} from './browser';\nimport {isSafari} from './util';\nimport {ActorTarget} from './actor';\n\nexport const PRELOAD_POOL_ID = 'mapboxgl_preloaded_worker_pool';\n\n/**\n * Constructs a worker pool.\n */\nexport class WorkerPool {\n static workerCount: number;\n\n active: {\n [_ in number | string]: boolean;\n };\n workers: Array;\n\n constructor() {\n this.active = {};\n }\n\n acquire(mapId: number | string): Array {\n if (!this.workers) {\n // Lazily look up the value of mapboxgl.workerCount so that\n // client code has had a chance to set it.\n this.workers = [];\n while (this.workers.length < WorkerPool.workerCount) {\n this.workers.push(workerFactory());\n }\n }\n\n this.active[mapId] = true;\n return this.workers.slice();\n }\n\n release(mapId: number | string) {\n delete this.active[mapId];\n if (this.numActive() === 0) {\n this.workers.forEach((w) => {\n w.terminate();\n });\n this.workers = null;\n }\n }\n\n isPreloaded(): boolean {\n return !!this.active[PRELOAD_POOL_ID];\n }\n\n numActive(): number {\n return Object.keys(this.active).length;\n }\n}\n\n// Based on results from A/B testing: https://github.com/maplibre/maplibre-gl-js/pull/2354\nconst availableLogicalProcessors = Math.floor(browser.hardwareConcurrency / 2);\nWorkerPool.workerCount = isSafari(globalThis) ? Math.max(Math.min(availableLogicalProcessors, 3), 1) : 1;\n","import {config} from './config';\n\nimport type {WorkerSource} from '../source/worker_source';\n\nexport interface WorkerGlobalScopeInterface {\n importScripts(...urls: Array): void;\n registerWorkerSource: (\n b: string,\n a: {\n new(...args: any): WorkerSource;\n }\n ) => void;\n registerRTLTextPlugin: (_: any) => void;\n}\n\nexport function workerFactory() {\n return new Worker(config.WORKER_URL);\n}\n","import {WorkerPool, PRELOAD_POOL_ID} from './worker_pool';\n\nlet globalWorkerPool;\n\n/**\n * Creates (if necessary) and returns the single, global WorkerPool instance\n * to be shared across each Map\n */\nexport function getGlobalWorkerPool() {\n if (!globalWorkerPool) {\n globalWorkerPool = new WorkerPool();\n }\n return globalWorkerPool;\n}\n\nexport function prewarm() {\n const workerPool = getGlobalWorkerPool();\n workerPool.acquire(PRELOAD_POOL_ID);\n}\n\nexport function clearPrewarmedResources() {\n const pool = globalWorkerPool;\n if (pool) {\n // Remove the pool only if all maps that referenced the preloaded global worker pool have been removed.\n if (pool.isPreloaded() && pool.numActive() === 1) {\n pool.release(PRELOAD_POOL_ID);\n globalWorkerPool = null;\n } else {\n console.warn('Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()');\n }\n }\n}\n","import {clamp} from '../util/util';\nimport Point from '@mapbox/point-geometry';\n\nexport class PathInterpolator {\n points: Array;\n length: number;\n paddedLength: number;\n padding: number;\n _distances: Array;\n\n constructor(points_?: Array | null, padding_?: number | null) {\n this.reset(points_, padding_);\n }\n\n reset(points_?: Array | null, padding_?: number | null) {\n this.points = points_ || [];\n\n // Compute cumulative distance from first point to every other point in the segment.\n // Last entry in the array is total length of the path\n this._distances = [0.0];\n\n for (let i = 1; i < this.points.length; i++) {\n this._distances[i] = this._distances[i - 1] + this.points[i].dist(this.points[i - 1]);\n }\n\n this.length = this._distances[this._distances.length - 1];\n this.padding = Math.min(padding_ || 0, this.length * 0.5);\n this.paddedLength = this.length - this.padding * 2.0;\n }\n\n lerp(t: number): Point {\n if (this.points.length === 1) {\n return this.points[0];\n }\n\n t = clamp(t, 0, 1);\n\n // Find the correct segment [p0, p1] where p0 <= x < p1\n let currentIndex = 1;\n let distOfCurrentIdx = this._distances[currentIndex];\n const distToTarget = t * this.paddedLength + this.padding;\n\n while (distOfCurrentIdx < distToTarget && currentIndex < this._distances.length) {\n distOfCurrentIdx = this._distances[++currentIndex];\n }\n\n // Interpolate between the two points of the segment\n const idxOfPrevPoint = currentIndex - 1;\n const distOfPrevIdx = this._distances[idxOfPrevPoint];\n const segmentLength = distOfCurrentIdx - distOfPrevIdx;\n const segmentT = segmentLength > 0 ? (distToTarget - distOfPrevIdx) / segmentLength : 0;\n\n return this.points[idxOfPrevPoint].mult(1.0 - segmentT).add(this.points[currentIndex].mult(segmentT));\n }\n}\n","import type {OverlapMode} from '../style/style_layer/overlap_mode';\n\ntype QueryArgs = {\n hitTest: boolean;\n overlapMode?: OverlapMode;\n circle?: {\n x: number;\n y: number;\n radius: number;\n };\n seenUids: {\n box: {\n [_: number]: boolean;\n };\n circle: {\n [_: number]: boolean;\n };\n };\n};\n\ntype QueryResult = {\n key: T;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n};\n\n/**\n * A key for the grid\n */\nexport type GridKey = {\n overlapMode?: OverlapMode;\n}\n\nfunction overlapAllowed(overlapA: OverlapMode, overlapB: OverlapMode): boolean {\n let allowed = true;\n\n if (overlapA === 'always') {\n // symbol A using 'always' overlap - allowed to overlap anything.\n } else if (overlapA === 'never' || overlapB === 'never') {\n // symbol A using 'never' overlap - can't overlap anything\n // symbol A using 'cooperative' overlap - can overlap 'always' or 'cooperative' symbol; can't overlap 'never'\n allowed = false;\n }\n\n return allowed;\n}\n\n/**\n * @internal\n * GridIndex is a data structure for testing the intersection of\n * circles and rectangles in a 2d plane.\n * It is optimized for rapid insertion and querying.\n * GridIndex splits the plane into a set of \"cells\" and keeps track\n * of which geometries intersect with each cell. At query time,\n * full geometry comparisons are only done for items that share\n * at least one cell. As long as the geometries are relatively\n * uniformly distributed across the plane, this greatly reduces\n * the number of comparisons necessary.\n */\nexport class GridIndex {\n circleKeys: Array;\n boxKeys: Array;\n boxCells: Array>;\n circleCells: Array>;\n bboxes: Array;\n circles: Array;\n xCellCount: number;\n yCellCount: number;\n width: number;\n height: number;\n xScale: number;\n yScale: number;\n boxUid: number;\n circleUid: number;\n\n constructor (width: number, height: number, cellSize: number) {\n const boxCells = this.boxCells = [];\n const circleCells = this.circleCells = [];\n\n // More cells -> fewer geometries to check per cell, but items tend\n // to be split across more cells.\n // Sweet spot allows most small items to fit in one cell\n this.xCellCount = Math.ceil(width / cellSize);\n this.yCellCount = Math.ceil(height / cellSize);\n\n for (let i = 0; i < this.xCellCount * this.yCellCount; i++) {\n boxCells.push([]);\n circleCells.push([]);\n }\n this.circleKeys = [];\n this.boxKeys = [];\n this.bboxes = [];\n this.circles = [];\n\n this.width = width;\n this.height = height;\n this.xScale = this.xCellCount / width;\n this.yScale = this.yCellCount / height;\n this.boxUid = 0;\n this.circleUid = 0;\n }\n\n keysLength() {\n return this.boxKeys.length + this.circleKeys.length;\n }\n\n insert(key: T, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertBoxCell, this.boxUid++);\n this.boxKeys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n insertCircle(key: T, x: number, y: number, radius: number) {\n // Insert circle into grid for all cells in the circumscribing square\n // It's more than necessary (by a factor of 4/PI), but fast to insert\n this._forEachCell(x - radius, y - radius, x + radius, y + radius, this._insertCircleCell, this.circleUid++);\n this.circleKeys.push(key);\n this.circles.push(x);\n this.circles.push(y);\n this.circles.push(radius);\n }\n\n private _insertBoxCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.boxCells[cellIndex].push(uid);\n }\n\n private _insertCircleCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.circleCells[cellIndex].push(uid);\n }\n\n private _query(x1: number, y1: number, x2: number, y2: number, hitTest: boolean, overlapMode: OverlapMode, predicate?: (key: T) => boolean): Array> {\n if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {\n return [];\n }\n const result: Array> = [];\n if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {\n if (hitTest) {\n // Covers the entire grid, so collides with everything\n return [{\n key: null,\n x1,\n y1,\n x2,\n y2\n }];\n }\n for (let boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {\n result.push({\n key: this.boxKeys[boxUid],\n x1: this.bboxes[boxUid * 4],\n y1: this.bboxes[boxUid * 4 + 1],\n x2: this.bboxes[boxUid * 4 + 2],\n y2: this.bboxes[boxUid * 4 + 3]\n });\n }\n for (let circleUid = 0; circleUid < this.circleKeys.length; circleUid++) {\n const x = this.circles[circleUid * 3];\n const y = this.circles[circleUid * 3 + 1];\n const radius = this.circles[circleUid * 3 + 2];\n result.push({\n key: this.circleKeys[circleUid],\n x1: x - radius,\n y1: y - radius,\n x2: x + radius,\n y2: y + radius\n });\n }\n } else {\n const queryArgs: QueryArgs = {\n hitTest,\n overlapMode,\n seenUids: {box: {}, circle: {}}\n };\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, queryArgs, predicate);\n }\n\n return result;\n }\n\n query(x1: number, y1: number, x2: number, y2: number): Array> {\n return this._query(x1, y1, x2, y2, false, null);\n }\n\n hitTest(x1: number, y1: number, x2: number, y2: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean {\n return this._query(x1, y1, x2, y2, true, overlapMode, predicate).length > 0;\n }\n\n hitTestCircle(x: number, y: number, radius: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean {\n // Insert circle into grid for all cells in the circumscribing square\n // It's more than necessary (by a factor of 4/PI), but fast to insert\n const x1 = x - radius;\n const x2 = x + radius;\n const y1 = y - radius;\n const y2 = y + radius;\n if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {\n return false;\n }\n\n // Box query early exits if the bounding box is larger than the grid, but we don't do\n // the equivalent calculation for circle queries because early exit is less likely\n // and the calculation is more expensive\n const result: boolean[] = [];\n const queryArgs: QueryArgs = {\n hitTest: true,\n overlapMode,\n circle: {x, y, radius},\n seenUids: {box: {}, circle: {}}\n };\n this._forEachCell(x1, y1, x2, y2, this._queryCellCircle, result, queryArgs, predicate);\n return result.length > 0;\n }\n\n private _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array>, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean {\n const {seenUids, hitTest, overlapMode} = queryArgs;\n const boxCell = this.boxCells[cellIndex];\n\n if (boxCell !== null) {\n const bboxes = this.bboxes;\n for (const boxUid of boxCell) {\n if (!seenUids.box[boxUid]) {\n seenUids.box[boxUid] = true;\n const offset = boxUid * 4;\n const key = this.boxKeys[boxUid];\n\n if ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]) &&\n (!predicate || predicate(key))) {\n if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push({\n key,\n x1: bboxes[offset],\n y1: bboxes[offset + 1],\n x2: bboxes[offset + 2],\n y2: bboxes[offset + 3]\n });\n if (hitTest) {\n // true return value stops the query after first match\n return true;\n }\n }\n }\n }\n }\n }\n const circleCell = this.circleCells[cellIndex];\n if (circleCell !== null) {\n const circles = this.circles;\n for (const circleUid of circleCell) {\n if (!seenUids.circle[circleUid]) {\n seenUids.circle[circleUid] = true;\n const offset = circleUid * 3;\n const key = this.circleKeys[circleUid];\n\n if (this._circleAndRectCollide(\n circles[offset],\n circles[offset + 1],\n circles[offset + 2],\n x1,\n y1,\n x2,\n y2) &&\n (!predicate || predicate(key))) {\n if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) {\n const x = circles[offset];\n const y = circles[offset + 1];\n const radius = circles[offset + 2];\n result.push({\n key,\n x1: x - radius,\n y1: y - radius,\n x2: x + radius,\n y2: y + radius\n });\n if (hitTest) {\n // true return value stops the query after first match\n return true;\n }\n }\n }\n }\n }\n }\n\n // false return to continue query\n return false;\n }\n\n private _queryCellCircle(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean {\n const {circle, seenUids, overlapMode} = queryArgs;\n const boxCell = this.boxCells[cellIndex];\n\n if (boxCell !== null) {\n const bboxes = this.bboxes;\n for (const boxUid of boxCell) {\n if (!seenUids.box[boxUid]) {\n seenUids.box[boxUid] = true;\n const offset = boxUid * 4;\n const key = this.boxKeys[boxUid];\n if (this._circleAndRectCollide(\n circle.x,\n circle.y,\n circle.radius,\n bboxes[offset + 0],\n bboxes[offset + 1],\n bboxes[offset + 2],\n bboxes[offset + 3]) &&\n (!predicate || predicate(key)) &&\n !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push(true);\n return true;\n }\n }\n }\n }\n\n const circleCell = this.circleCells[cellIndex];\n if (circleCell !== null) {\n const circles = this.circles;\n for (const circleUid of circleCell) {\n if (!seenUids.circle[circleUid]) {\n seenUids.circle[circleUid] = true;\n const offset = circleUid * 3;\n const key = this.circleKeys[circleUid];\n if (this._circlesCollide(\n circles[offset],\n circles[offset + 1],\n circles[offset + 2],\n circle.x,\n circle.y,\n circle.radius) &&\n (!predicate || predicate(key)) &&\n !overlapAllowed(overlapMode, key.overlapMode)) {\n result.push(true);\n return true;\n }\n }\n }\n }\n }\n\n private _forEachCell(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n fn: (x1: number, y1: number, x2: number, y2: number, cellIndex: number, arg1: TArg, arg2?: QueryArgs, predicate?: (key: T) => boolean) => boolean | void,\n arg1: TArg,\n arg2?: QueryArgs,\n predicate?: (key: T) => boolean) {\n const cx1 = this._convertToXCellCoord(x1);\n const cy1 = this._convertToYCellCoord(y1);\n const cx2 = this._convertToXCellCoord(x2);\n const cy2 = this._convertToYCellCoord(y2);\n\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.xCellCount * y + x;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) return;\n }\n }\n }\n\n private _convertToXCellCoord(x: number) {\n return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale)));\n }\n\n private _convertToYCellCoord(y: number) {\n return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));\n }\n\n private _circlesCollide(x1: number, y1: number, r1: number, x2: number, y2: number, r2: number): boolean {\n const dx = x2 - x1;\n const dy = y2 - y1;\n const bothRadii = r1 + r2;\n return (bothRadii * bothRadii) > (dx * dx + dy * dy);\n }\n\n private _circleAndRectCollide(\n circleX: number,\n circleY: number,\n radius: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number\n ): boolean {\n const halfRectWidth = (x2 - x1) / 2;\n const distX = Math.abs(circleX - (x1 + halfRectWidth));\n if (distX > (halfRectWidth + radius)) {\n return false;\n }\n\n const halfRectHeight = (y2 - y1) / 2;\n const distY = Math.abs(circleY - (y1 + halfRectHeight));\n if (distY > (halfRectHeight + radius)) {\n return false;\n }\n\n if (distX <= halfRectWidth || distY <= halfRectHeight) {\n return true;\n }\n\n const dx = distX - halfRectWidth;\n const dy = distY - halfRectHeight;\n return (dx * dx + dy * dy <= (radius * radius));\n }\n}\n","import Point from '@mapbox/point-geometry';\n\nimport {mat4, vec4} from 'gl-matrix';\nimport * as symbolSize from './symbol_size';\nimport {addDynamicAttributes} from '../data/bucket/symbol_bucket';\n\nimport type {Painter} from '../render/painter';\nimport type {Transform} from '../geo/transform';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport type {\n GlyphOffsetArray,\n SymbolLineVertexArray,\n SymbolDynamicLayoutArray\n} from '../data/array_types.g';\nimport {WritingMode} from '../symbol/shaping';\nimport {findLineIntersection} from '../util/util';\n\nexport {updateLineLabels, hideGlyphs, getLabelPlaneMatrix, getGlCoordMatrix, project, getPerspectiveRatio, placeFirstAndLastGlyph, placeGlyphAlongLine, xyTransformMat4, projectVertexToViewport, findOffsetIntersectionPoint, transformToOffsetNormal};\n\n/*\n * # Overview of coordinate spaces\n *\n * ## Tile coordinate spaces\n * Each label has an anchor. Some labels have corresponding line geometries.\n * The points for both anchors and lines are stored in tile units. Each tile has it's own\n * coordinate space going from (0, 0) at the top left to (EXTENT, EXTENT) at the bottom right.\n *\n * ## GL coordinate space\n * At the end of everything, the vertex shader needs to produce a position in GL coordinate space,\n * which is (-1, 1) at the top left and (1, -1) in the bottom right.\n *\n * ## Map pixel coordinate spaces\n * Each tile has a pixel coordinate space. It's just the tile units scaled so that one unit is\n * whatever counts as 1 pixel at the current zoom.\n * This space is used for pitch-alignment=map, rotation-alignment=map\n *\n * ## Rotated map pixel coordinate spaces\n * Like the above, but rotated so axis of the space are aligned with the viewport instead of the tile.\n * This space is used for pitch-alignment=map, rotation-alignment=viewport\n *\n * ## Viewport pixel coordinate space\n * (0, 0) is at the top left of the canvas and (pixelWidth, pixelHeight) is at the bottom right corner\n * of the canvas. This space is used for pitch-alignment=viewport\n *\n *\n * # Vertex projection\n * It goes roughly like this:\n * 1. project the anchor and line from tile units into the correct label coordinate space\n * - map pixel space pitch-alignment=map rotation-alignment=map\n * - rotated map pixel space pitch-alignment=map rotation-alignment=viewport\n * - viewport pixel space pitch-alignment=viewport rotation-alignment=*\n * 2. if the label follows a line, find the point along the line that is the correct distance from the anchor.\n * 3. add the glyph's corner offset to the point from step 3\n * 4. convert from the label coordinate space to gl coordinates\n *\n * For horizontal labels we want to do step 1 in the shader for performance reasons (no cpu work).\n * This is what `u_label_plane_matrix` is used for.\n * For labels aligned with lines we have to steps 1 and 2 on the cpu since we need access to the line geometry.\n * This is what `updateLineLabels(...)` does.\n * Since the conversion is handled on the cpu we just set `u_label_plane_matrix` to an identity matrix.\n *\n * Steps 3 and 4 are done in the shaders for all labels.\n */\n\n/*\n * Returns a matrix for converting from tile units to the correct label coordinate space.\n */\nfunction getLabelPlaneMatrix(posMatrix: mat4,\n pitchWithMap: boolean,\n rotateWithMap: boolean,\n transform: Transform,\n pixelsToTileUnits: number) {\n const m = mat4.create();\n if (pitchWithMap) {\n mat4.scale(m, m, [1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1]);\n if (!rotateWithMap) {\n mat4.rotateZ(m, m, transform.angle);\n }\n } else {\n mat4.multiply(m, transform.labelPlaneMatrix, posMatrix);\n }\n return m;\n}\n\n/*\n * Returns a matrix for converting from the correct label coordinate space to gl coords.\n */\nfunction getGlCoordMatrix(posMatrix: mat4,\n pitchWithMap: boolean,\n rotateWithMap: boolean,\n transform: Transform,\n pixelsToTileUnits: number) {\n if (pitchWithMap) {\n const m = mat4.clone(posMatrix);\n mat4.scale(m, m, [pixelsToTileUnits, pixelsToTileUnits, 1]);\n if (!rotateWithMap) {\n mat4.rotateZ(m, m, -transform.angle);\n }\n return m;\n } else {\n return transform.glCoordMatrix;\n }\n}\n\nfunction project(point: Point, matrix: mat4, getElevation?: (x: number, y: number) => number) {\n let pos;\n if (getElevation) { // slow because of handle z-index\n pos = [point.x, point.y, getElevation(point.x, point.y), 1] as vec4;\n vec4.transformMat4(pos, pos, matrix);\n } else { // fast because of ignore z-index\n pos = [point.x, point.y, 0, 1] as vec4;\n xyTransformMat4(pos, pos, matrix);\n }\n const w = pos[3];\n return {\n point: new Point(pos[0] / w, pos[1] / w),\n signedDistanceFromCamera: w\n };\n}\n\nfunction getPerspectiveRatio(cameraToCenterDistance: number, signedDistanceFromCamera: number): number {\n return 0.5 + 0.5 * (cameraToCenterDistance / signedDistanceFromCamera);\n}\n\nfunction isVisible(anchorPos: vec4,\n clippingBuffer: [number, number]) {\n const x = anchorPos[0] / anchorPos[3];\n const y = anchorPos[1] / anchorPos[3];\n const inPaddedViewport = (\n x >= -clippingBuffer[0] &&\n x <= clippingBuffer[0] &&\n y >= -clippingBuffer[1] &&\n y <= clippingBuffer[1]);\n return inPaddedViewport;\n}\n\n/*\n * Update the `dynamicLayoutVertexBuffer` for the buffer with the correct glyph positions for the current map view.\n * This is only run on labels that are aligned with lines. Horizontal labels are handled entirely in the shader.\n */\nfunction updateLineLabels(bucket: SymbolBucket,\n posMatrix: mat4,\n painter: Painter,\n isText: boolean,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n pitchWithMap: boolean,\n keepUpright: boolean,\n rotateToLine: boolean,\n getElevation: (x: number, y: number) => number) {\n\n const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;\n const partiallyEvaluatedSize = symbolSize.evaluateSizeForZoom(sizeData, painter.transform.zoom);\n\n const clippingBuffer: [number, number] = [256 / painter.width * 2 + 1, 256 / painter.height * 2 + 1];\n\n const dynamicLayoutVertexArray = isText ?\n bucket.text.dynamicLayoutVertexArray :\n bucket.icon.dynamicLayoutVertexArray;\n dynamicLayoutVertexArray.clear();\n\n const lineVertexArray = bucket.lineVertexArray;\n const placedSymbols = isText ? bucket.text.placedSymbolArray : bucket.icon.placedSymbolArray;\n\n const aspectRatio = painter.transform.width / painter.transform.height;\n\n let useVertical = false;\n\n for (let s = 0; s < placedSymbols.length; s++) {\n const symbol = placedSymbols.get(s);\n\n // Don't do calculations for vertical glyphs unless the previous symbol was horizontal\n // and we determined that vertical glyphs were necessary.\n // Also don't do calculations for symbols that are collided and fully faded out\n if (symbol.hidden || symbol.writingMode === WritingMode.vertical && !useVertical) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n continue;\n }\n // Awkward... but we're counting on the paired \"vertical\" symbol coming immediately after its horizontal counterpart\n useVertical = false;\n\n let anchorPos;\n if (getElevation) { // slow because of handle z-index\n anchorPos = [symbol.anchorX, symbol.anchorY, getElevation(symbol.anchorX, symbol.anchorY), 1] as vec4;\n vec4.transformMat4(anchorPos, anchorPos, posMatrix);\n } else { // fast because of ignore z-index\n anchorPos = [symbol.anchorX, symbol.anchorY, 0, 1] as vec4;\n xyTransformMat4(anchorPos, anchorPos, posMatrix);\n }\n\n // Don't bother calculating the correct point for invisible labels.\n if (!isVisible(anchorPos, clippingBuffer)) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n continue;\n }\n\n const cameraToAnchorDistance = anchorPos[3];\n const perspectiveRatio = getPerspectiveRatio(painter.transform.cameraToCenterDistance, cameraToAnchorDistance);\n\n const fontSize = symbolSize.evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol);\n const pitchScaledFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;\n\n const tileAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);\n const anchorPoint = project(tileAnchorPoint, labelPlaneMatrix, getElevation).point;\n const projectionCache = {projections: {}, offsets: {}};\n\n const placeUnflipped: any = placeGlyphsAlongLine(symbol, pitchScaledFontSize, false /*unflipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix,\n bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation);\n\n useVertical = placeUnflipped.useVertical;\n\n if (placeUnflipped.notEnoughRoom || useVertical ||\n (placeUnflipped.needsFlipping &&\n (placeGlyphsAlongLine(symbol, pitchScaledFontSize, true /*flipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix,\n bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) as any).notEnoughRoom)) {\n hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray);\n }\n }\n\n if (isText) {\n bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray);\n } else {\n bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray);\n }\n}\n\ntype FirstAndLastGlyphPlacement = {\n first: PlacedGlyph;\n last: PlacedGlyph;\n} | null;\n\n/*\n * Place the first and last glyph of a line label, projected to the label plane.\n * This function is called both during collision detection (to determine the label's size)\n * and during line label rendering (to make sure the label fits on the line geometry with\n * the current camera position, which may differ from the position used during collision detection).\n *\n * Calling this function has the effect of populating the \"projectionCache\" with all projected\n * vertex locations the label will need, making future calls to placeGlyphAlongLine (for all the\n * intermediate glyphs) much cheaper.\n *\n * Returns null if the label can't fit on the geometry\n */\nfunction placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffsetArray, lineOffsetX: number, lineOffsetY: number, flip: boolean, anchorPoint: Point, tileAnchorPoint: Point, symbol: any, lineVertexArray: SymbolLineVertexArray, labelPlaneMatrix: mat4, projectionCache: ProjectionCache, rotateToLine: boolean, getElevation: (x: number, y: number) => number): FirstAndLastGlyphPlacement {\n const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;\n const lineStartIndex = symbol.lineStartIndex;\n const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;\n\n const firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex);\n const lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1);\n\n const firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!firstPlacedGlyph)\n return null;\n\n const lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!lastPlacedGlyph)\n return null;\n\n return {first: firstPlacedGlyph, last: lastPlacedGlyph};\n}\n\nfunction requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRatio) {\n if (writingMode === WritingMode.horizontal) {\n // On top of choosing whether to flip, choose whether to render this version of the glyphs or the alternate\n // vertical glyphs. We can't just filter out vertical glyphs in the horizontal range because the horizontal\n // and vertical versions can have slightly different projections which could lead to angles where both or\n // neither showed.\n const rise = Math.abs(lastPoint.y - firstPoint.y);\n const run = Math.abs(lastPoint.x - firstPoint.x) * aspectRatio;\n if (rise > run) {\n return {useVertical: true};\n }\n }\n\n if (writingMode === WritingMode.vertical ? firstPoint.y < lastPoint.y : firstPoint.x > lastPoint.x) {\n // Includes \"horizontalOnly\" case for labels without vertical glyphs\n return {needsFlipping: true};\n }\n\n return null;\n}\n\n/*\n* Place first and last glyph along the line projected to label plane, and if they fit\n* iterate through all the intermediate glyphs, calculating their label plane positions\n* from the projected line.\n*\n* Finally, add resulting glyph position calculations to dynamicLayoutVertexArray for\n* upload to the GPU\n*/\nfunction placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) {\n const fontScale = fontSize / 24;\n const lineOffsetX = symbol.lineOffsetX * fontScale;\n const lineOffsetY = symbol.lineOffsetY * fontScale;\n\n let placedGlyphs;\n if (symbol.numGlyphs > 1) {\n const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;\n const lineStartIndex = symbol.lineStartIndex;\n const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;\n\n // Place the first and the last glyph in the label first, so we can figure out\n // the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode\n const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!firstAndLastGlyph) {\n return {notEnoughRoom: true};\n }\n const firstPoint = project(firstAndLastGlyph.first.point, glCoordMatrix, getElevation).point;\n const lastPoint = project(firstAndLastGlyph.last.point, glCoordMatrix, getElevation).point;\n\n if (keepUpright && !flip) {\n const orientationChange = requiresOrientationChange(symbol.writingMode, firstPoint, lastPoint, aspectRatio);\n if (orientationChange) {\n return orientationChange;\n }\n }\n\n placedGlyphs = [firstAndLastGlyph.first];\n for (let glyphIndex = symbol.glyphStartIndex + 1; glyphIndex < glyphEndIndex - 1; glyphIndex++) {\n // Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed\n placedGlyphs.push(placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation));\n }\n placedGlyphs.push(firstAndLastGlyph.last);\n } else {\n // Only a single glyph to place\n // So, determine whether to flip based on projected angle of the line segment it's on\n if (keepUpright && !flip) {\n const a = project(tileAnchorPoint, posMatrix, getElevation).point;\n const tileVertexIndex = (symbol.lineStartIndex + symbol.segment + 1);\n const tileSegmentEnd = new Point(lineVertexArray.getx(tileVertexIndex), lineVertexArray.gety(tileVertexIndex));\n const projectedVertex = project(tileSegmentEnd, posMatrix, getElevation);\n // We know the anchor will be in the viewport, but the end of the line segment may be\n // behind the plane of the camera, in which case we can use a point at any arbitrary (closer)\n // point on the segment.\n const b = (projectedVertex.signedDistanceFromCamera > 0) ?\n projectedVertex.point :\n projectTruncatedLineSegment(tileAnchorPoint, tileSegmentEnd, a, 1, posMatrix, getElevation);\n\n const orientationChange = requiresOrientationChange(symbol.writingMode, a, b, aspectRatio);\n if (orientationChange) {\n return orientationChange;\n }\n }\n const singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(symbol.glyphStartIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,\n symbol.lineStartIndex, symbol.lineStartIndex + symbol.lineLength, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation);\n if (!singleGlyph)\n return {notEnoughRoom: true};\n\n placedGlyphs = [singleGlyph];\n }\n\n for (const glyph of placedGlyphs) {\n addDynamicAttributes(dynamicLayoutVertexArray, glyph.point, glyph.angle);\n }\n return {};\n}\n\nfunction projectTruncatedLineSegment(previousTilePoint: Point, currentTilePoint: Point, previousProjectedPoint: Point, minimumLength: number, projectionMatrix: mat4, getElevation: (x: number, y: number) => number) {\n // We are assuming \"previousTilePoint\" won't project to a point within one unit of the camera plane\n // If it did, that would mean our label extended all the way out from within the viewport to a (very distant)\n // point near the plane of the camera. We wouldn't be able to render the label anyway once it crossed the\n // plane of the camera.\n const projectedUnitVertex = project(previousTilePoint.add(previousTilePoint.sub(currentTilePoint)._unit()), projectionMatrix, getElevation).point;\n const projectedUnitSegment = previousProjectedPoint.sub(projectedUnitVertex);\n\n return previousProjectedPoint.add(projectedUnitSegment._mult(minimumLength / projectedUnitSegment.mag()));\n}\n\ntype IndexToPointCache = { [lineIndex: number]: Point };\n\n/**\n * We calculate label-plane projected points for line vertices as we place glyphs along the line\n * Since we will use the same vertices for potentially many glyphs, cache the results for this bucket\n * over the course of the render. Each vertex location also potentially has one offset equivalent\n * for us to hold onto. The vertex indices are per-symbol-bucket.\n */\ntype ProjectionCache = {\n /**\n * tile-unit vertices projected into label-plane units\n */\n projections: IndexToPointCache;\n /**\n * label-plane vertices which have been shifted to follow an offset line\n */\n offsets: IndexToPointCache;\n};\n\n/**\n * Arguments necessary to project a vertex to the label plane\n */\ntype ProjectionArgs = {\n /**\n * Used to cache results, save cost if projecting the same vertex multiple times\n */\n projectionCache: ProjectionCache;\n /**\n * The array of tile-unit vertices transferred from worker\n */\n lineVertexArray: SymbolLineVertexArray;\n /**\n * Label plane projection matrix\n */\n labelPlaneMatrix: mat4;\n /**\n * Function to get elevation at a point\n * @param x - the x coordinate\n * @param y - the y coordinate\n */\n getElevation: (x: number, y: number) => number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n tileAnchorPoint: Point;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n distanceFromAnchor: number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n previousVertex: Point;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n direction: number;\n /**\n * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera\n */\n absOffsetX: number;\n};\n\n/**\n * Transform a vertex from tile coordinates to label plane coordinates\n * @param index - index of vertex to project\n * @param projectionArgs - necessary data to project a vertex\n * @returns the vertex projected to the label plane\n */\nfunction projectVertexToViewport(index: number, projectionArgs: ProjectionArgs): Point {\n const {projectionCache, lineVertexArray, labelPlaneMatrix, tileAnchorPoint, distanceFromAnchor, getElevation, previousVertex, direction, absOffsetX} = projectionArgs;\n if (projectionCache.projections[index]) {\n return projectionCache.projections[index];\n }\n const currentVertex = new Point(lineVertexArray.getx(index), lineVertexArray.gety(index));\n const projection = project(currentVertex, labelPlaneMatrix, getElevation);\n if (projection.signedDistanceFromCamera > 0) {\n projectionCache.projections[index] = projection.point;\n return projection.point;\n }\n\n // The vertex is behind the plane of the camera, so we can't project it\n // Instead, we'll create a vertex along the line that's far enough to include the glyph\n const previousLineVertexIndex = index - direction;\n const previousTilePoint = distanceFromAnchor === 0 ?\n tileAnchorPoint :\n new Point(lineVertexArray.getx(previousLineVertexIndex), lineVertexArray.gety(previousLineVertexIndex));\n // Don't cache because the new vertex might not be far enough out for future glyphs on the same segment\n return projectTruncatedLineSegment(previousTilePoint, currentVertex, previousVertex, absOffsetX - distanceFromAnchor + 1, labelPlaneMatrix, getElevation);\n}\n\n/**\n * Calculate the normal vector for a line segment\n * @param segmentVector - will be mutated as a tiny optimization\n * @param offset - magnitude of resulting vector\n * @param direction - direction of line traversal\n * @returns a normal vector from the segment, with magnitude equal to offset amount\n */\nfunction transformToOffsetNormal(segmentVector: Point, offset: number, direction: number): Point {\n return segmentVector._unit()._perp()._mult(offset * direction);\n}\n\n/**\n * Construct offset line segments for the current segment and the next segment, then extend/shrink\n * the segments until they intersect. If the segments are parallel, then they will touch with no modification.\n *\n * @param index - Index of the current vertex\n * @param prevToCurrentOffsetNormal - Normal vector of the line segment from the previous vertex to the current vertex\n * @param currentVertex - Current (non-offset) vertex projected to the label plane\n * @param lineStartIndex - Beginning index for the line this label is on\n * @param lineEndIndex - End index for the line this label is on\n * @param offsetPreviousVertex - The previous vertex projected to the label plane, and then offset along the previous segments normal\n * @param lineOffsetY - Magnitude of the offset\n * @param projectionArgs - Necessary data for tile-to-label-plane projection\n * @returns The point at which the current and next line segments intersect, once offset and extended/shrunk to their meeting point\n */\nfunction findOffsetIntersectionPoint(index: number, prevToCurrentOffsetNormal: Point, currentVertex: Point, lineStartIndex: number, lineEndIndex: number, offsetPreviousVertex: Point, lineOffsetY: number, projectionArgs: ProjectionArgs) {\n const {projectionCache, direction} = projectionArgs;\n if (projectionCache.offsets[index]) {\n return projectionCache.offsets[index];\n }\n\n const offsetCurrentVertex = currentVertex.add(prevToCurrentOffsetNormal);\n\n if (index + direction < lineStartIndex || index + direction >= lineEndIndex) {\n // This is the end of the line, no intersection to calculate\n projectionCache.offsets[index] = offsetCurrentVertex;\n return offsetCurrentVertex;\n }\n // Offset the vertices for the next segment\n const nextVertex = projectVertexToViewport(index + direction, projectionArgs);\n const currentToNextOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction);\n const offsetNextSegmentBegin = currentVertex.add(currentToNextOffsetNormal);\n const offsetNextSegmentEnd = nextVertex.add(currentToNextOffsetNormal);\n\n // find the intersection of these two lines\n // if the lines are parallel, offsetCurrent/offsetNextBegin will touch\n projectionCache.offsets[index] = findLineIntersection(offsetPreviousVertex, offsetCurrentVertex, offsetNextSegmentBegin, offsetNextSegmentEnd) || offsetCurrentVertex;\n\n return projectionCache.offsets[index];\n}\n\n/**\n * Placed Glyph type\n */\ntype PlacedGlyph = {\n /**\n * The point at which the glyph should be placed, in label plane coordinates\n */\n point: Point;\n /**\n * The angle at which the glyph should be placed\n */\n angle: number;\n /**\n * The label-plane path used to reach this glyph: used only for collision detection\n */\n path: Array;\n};\n\n/*\n * Place a single glyph along its line, projected into the label plane, by iterating outward\n * from the anchor point until the distance traversed in the label plane equals the glyph's\n * offsetX. Returns null if the glyph can't fit on the line geometry.\n */\nfunction placeGlyphAlongLine(\n offsetX: number,\n lineOffsetX: number,\n lineOffsetY: number,\n flip: boolean,\n anchorPoint: Point,\n tileAnchorPoint: Point,\n anchorSegment: number,\n lineStartIndex: number,\n lineEndIndex: number,\n lineVertexArray: SymbolLineVertexArray,\n labelPlaneMatrix: mat4,\n projectionCache: ProjectionCache,\n rotateToLine: boolean,\n getElevation: (x: number, y: number) => number): PlacedGlyph | null {\n\n const combinedOffsetX = flip ?\n offsetX - lineOffsetX :\n offsetX + lineOffsetX;\n\n let direction = combinedOffsetX > 0 ? 1 : -1;\n\n let angle = 0;\n if (flip) {\n // The label needs to be flipped to keep text upright.\n // Iterate in the reverse direction.\n direction *= -1;\n angle = Math.PI;\n }\n\n if (direction < 0) angle += Math.PI;\n\n let currentIndex = direction > 0 ?\n lineStartIndex + anchorSegment :\n lineStartIndex + anchorSegment + 1;\n\n let currentVertex = anchorPoint;\n let previousVertex = anchorPoint;\n\n // offsetPrev and intersectionPoint are analogous to previousVertex and currentVertex\n // but if there's a line offset they are calculated in parallel as projection happens\n let offsetIntersectionPoint: Point;\n let offsetPreviousVertex: Point;\n\n let distanceFromAnchor = 0;\n let currentSegmentDistance = 0;\n const absOffsetX = Math.abs(combinedOffsetX);\n const pathVertices: Array = [];\n\n let currentLineSegment: Point;\n while (distanceFromAnchor + currentSegmentDistance <= absOffsetX) {\n currentIndex += direction;\n\n // offset does not fit on the projected line\n if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex)\n return null;\n\n // accumulate values from last iteration\n distanceFromAnchor += currentSegmentDistance;\n previousVertex = currentVertex;\n offsetPreviousVertex = offsetIntersectionPoint;\n\n const projectionArgs: ProjectionArgs = {\n projectionCache,\n lineVertexArray,\n labelPlaneMatrix,\n tileAnchorPoint,\n distanceFromAnchor,\n getElevation,\n previousVertex,\n direction,\n absOffsetX\n };\n\n // find next vertex in viewport space\n currentVertex = projectVertexToViewport(currentIndex, projectionArgs);\n if (lineOffsetY === 0) {\n // Store vertices for collision detection and update current segment geometry\n pathVertices.push(previousVertex);\n currentLineSegment = currentVertex.sub(previousVertex);\n } else {\n // Calculate the offset for this section\n let prevToCurrentOffsetNormal;\n const prevToCurrent = currentVertex.sub(previousVertex);\n if (prevToCurrent.mag() === 0) {\n // We are starting with our anchor point directly on the vertex, so look one vertex ahead\n // to calculate a normal\n const nextVertex = projectVertexToViewport(currentIndex + direction, projectionArgs);\n prevToCurrentOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction);\n } else {\n prevToCurrentOffsetNormal = transformToOffsetNormal(prevToCurrent, lineOffsetY, direction);\n }\n // Initialize offsetPrev on our first iteration, after that it will be pre-calculated\n if (!offsetPreviousVertex)\n offsetPreviousVertex = previousVertex.add(prevToCurrentOffsetNormal);\n\n offsetIntersectionPoint = findOffsetIntersectionPoint(currentIndex, prevToCurrentOffsetNormal, currentVertex, lineStartIndex, lineEndIndex, offsetPreviousVertex, lineOffsetY, projectionArgs);\n\n pathVertices.push(offsetPreviousVertex);\n currentLineSegment = offsetIntersectionPoint.sub(offsetPreviousVertex);\n }\n currentSegmentDistance = currentLineSegment.mag();\n }\n\n // The point is on the current segment. Interpolate to find it.\n const segmentInterpolationT = (absOffsetX - distanceFromAnchor) / currentSegmentDistance;\n const p = currentLineSegment._mult(segmentInterpolationT)._add(offsetPreviousVertex || previousVertex);\n\n const segmentAngle = angle + Math.atan2(currentVertex.y - previousVertex.y, currentVertex.x - previousVertex.x);\n\n pathVertices.push(p);\n\n return {\n point: p,\n angle: rotateToLine ? segmentAngle : 0.0,\n path: pathVertices\n };\n}\n\nconst hiddenGlyphAttributes = new Float32Array([-Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0]);\n\n// Hide them by moving them offscreen. We still need to add them to the buffer\n// because the dynamic buffer is paired with a static buffer that doesn't get updated.\nfunction hideGlyphs(num: number, dynamicLayoutVertexArray: SymbolDynamicLayoutArray) {\n for (let i = 0; i < num; i++) {\n const offset = dynamicLayoutVertexArray.length;\n dynamicLayoutVertexArray.resize(offset + 4);\n // Since all hidden glyphs have the same attributes, we can build up the array faster with a single call to Float32Array.set\n // for each set of four vertices, instead of calling addDynamicAttributes for each vertex.\n dynamicLayoutVertexArray.float32.set(hiddenGlyphAttributes, offset * 3);\n }\n}\n\n// For line label layout, we're not using z output and our w input is always 1\n// This custom matrix transformation ignores those components to make projection faster\nfunction xyTransformMat4(out: vec4, a: vec4, m: mat4) {\n const x = a[0], y = a[1];\n out[0] = m[0] * x + m[4] * y + m[12];\n out[1] = m[1] * x + m[5] * y + m[13];\n out[3] = m[3] * x + m[7] * y + m[15];\n return out;\n}\n","import Point from '@mapbox/point-geometry';\nimport {clipLine} from './clip_line';\nimport {PathInterpolator} from './path_interpolator';\n\nimport * as intersectionTests from '../util/intersection_tests';\nimport {GridIndex} from './grid_index';\nimport {mat4, vec4} from 'gl-matrix';\nimport ONE_EM from '../symbol/one_em';\n\nimport * as projection from '../symbol/projection';\n\nimport type {Transform} from '../geo/transform';\nimport type {SingleCollisionBox} from '../data/bucket/symbol_bucket';\nimport type {\n GlyphOffsetArray,\n SymbolLineVertexArray\n} from '../data/array_types.g';\nimport type {OverlapMode} from '../style/style_layer/overlap_mode';\n\n// When a symbol crosses the edge that causes it to be included in\n// collision detection, it will cause changes in the symbols around\n// it. This constant specifies how many pixels to pad the edge of\n// the viewport for collision detection so that the bulk of the changes\n// occur offscreen. Making this constant greater increases label\n// stability, but it's expensive.\nconst viewportPadding = 100;\n\nexport type FeatureKey = {\n bucketInstanceId: number;\n featureIndex: number;\n collisionGroupID: number;\n overlapMode: OverlapMode;\n};\n\n/**\n * @internal\n * A collision index used to prevent symbols from overlapping. It keep tracks of\n * where previous symbols have been placed and is used to check if a new\n * symbol overlaps with any previously added symbols.\n *\n * There are two steps to insertion: first placeCollisionBox/Circles checks if\n * there's room for a symbol, then insertCollisionBox/Circles actually puts the\n * symbol in the index. The two step process allows paired symbols to be inserted\n * together even if they overlap.\n */\nexport class CollisionIndex {\n grid: GridIndex;\n ignoredGrid: GridIndex;\n transform: Transform;\n pitchfactor: number;\n screenRightBoundary: number;\n screenBottomBoundary: number;\n gridRightBoundary: number;\n gridBottomBoundary: number;\n\n // With perspectiveRatio the fontsize is calculated for tilted maps (near = bigger, far = smaller).\n // The cutoff defines a threshold to no longer render labels near the horizon.\n perspectiveRatioCutoff: number;\n\n constructor(\n transform: Transform,\n grid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25),\n ignoredGrid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25)\n ) {\n this.transform = transform;\n\n this.grid = grid;\n this.ignoredGrid = ignoredGrid;\n this.pitchfactor = Math.cos(transform._pitch) * transform.cameraToCenterDistance;\n\n this.screenRightBoundary = transform.width + viewportPadding;\n this.screenBottomBoundary = transform.height + viewportPadding;\n this.gridRightBoundary = transform.width + 2 * viewportPadding;\n this.gridBottomBoundary = transform.height + 2 * viewportPadding;\n\n this.perspectiveRatioCutoff = 0.6;\n }\n\n placeCollisionBox(\n collisionBox: SingleCollisionBox,\n overlapMode: OverlapMode,\n textPixelRatio: number,\n posMatrix: mat4,\n collisionGroupPredicate?: (key: FeatureKey) => boolean,\n getElevation?: (x: number, y: number) => number\n ): {\n box: Array;\n offscreen: boolean;\n } {\n const projectedPoint = this.projectAndGetPerspectiveRatio(posMatrix, collisionBox.anchorPointX, collisionBox.anchorPointY, getElevation);\n const tileToViewport = textPixelRatio * projectedPoint.perspectiveRatio;\n const tlX = collisionBox.x1 * tileToViewport + projectedPoint.point.x;\n const tlY = collisionBox.y1 * tileToViewport + projectedPoint.point.y;\n const brX = collisionBox.x2 * tileToViewport + projectedPoint.point.x;\n const brY = collisionBox.y2 * tileToViewport + projectedPoint.point.y;\n\n if (!this.isInsideGrid(tlX, tlY, brX, brY) ||\n (overlapMode !== 'always' && this.grid.hitTest(tlX, tlY, brX, brY, overlapMode, collisionGroupPredicate)) ||\n projectedPoint.perspectiveRatio < this.perspectiveRatioCutoff) {\n return {\n box: [],\n offscreen: false\n };\n }\n\n return {\n box: [tlX, tlY, brX, brY],\n offscreen: this.isOffscreen(tlX, tlY, brX, brY)\n };\n }\n\n placeCollisionCircles(\n overlapMode: OverlapMode,\n symbol: any,\n lineVertexArray: SymbolLineVertexArray,\n glyphOffsetArray: GlyphOffsetArray,\n fontSize: number,\n posMatrix: mat4,\n labelPlaneMatrix: mat4,\n labelToScreenMatrix: mat4,\n showCollisionCircles: boolean,\n pitchWithMap: boolean,\n collisionGroupPredicate: (key: FeatureKey) => boolean,\n circlePixelDiameter: number,\n textPixelPadding: number,\n getElevation: (x: number, y: number) => number\n ): {\n circles: Array;\n offscreen: boolean;\n collisionDetected: boolean;\n } {\n const placedCollisionCircles = [];\n\n const tileUnitAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);\n const screenAnchorPoint = projection.project(tileUnitAnchorPoint, posMatrix, getElevation);\n const perspectiveRatio = projection.getPerspectiveRatio(this.transform.cameraToCenterDistance, screenAnchorPoint.signedDistanceFromCamera);\n const labelPlaneFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;\n const labelPlaneFontScale = labelPlaneFontSize / ONE_EM;\n\n const labelPlaneAnchorPoint = projection.project(tileUnitAnchorPoint, labelPlaneMatrix, getElevation).point;\n\n const projectionCache = {projections: {}, offsets: {}};\n const lineOffsetX = symbol.lineOffsetX * labelPlaneFontScale;\n const lineOffsetY = symbol.lineOffsetY * labelPlaneFontScale;\n\n const firstAndLastGlyph = projection.placeFirstAndLastGlyph(\n labelPlaneFontScale,\n glyphOffsetArray,\n lineOffsetX,\n lineOffsetY,\n /*flip*/ false,\n labelPlaneAnchorPoint,\n tileUnitAnchorPoint,\n symbol,\n lineVertexArray,\n labelPlaneMatrix,\n projectionCache,\n false,\n getElevation);\n\n let collisionDetected = false;\n let inGrid = false;\n let entirelyOffscreen = true;\n\n if (firstAndLastGlyph) {\n const radius = circlePixelDiameter * 0.5 * perspectiveRatio + textPixelPadding;\n const screenPlaneMin = new Point(-viewportPadding, -viewportPadding);\n const screenPlaneMax = new Point(this.screenRightBoundary, this.screenBottomBoundary);\n const interpolator = new PathInterpolator();\n\n // Construct a projected path from projected line vertices. Anchor points are ignored and removed\n const first = firstAndLastGlyph.first;\n const last = firstAndLastGlyph.last;\n\n let projectedPath = [];\n for (let i = first.path.length - 1; i >= 1; i--) {\n projectedPath.push(first.path[i]);\n }\n for (let i = 1; i < last.path.length; i++) {\n projectedPath.push(last.path[i]);\n }\n\n // Tolerate a slightly longer distance than one diameter between two adjacent circles\n const circleDist = radius * 2.5;\n\n // The path might need to be converted into screen space if a pitched map is used as the label space\n if (labelToScreenMatrix) {\n const screenSpacePath = projectedPath.map(p => projection.project(p, labelToScreenMatrix, getElevation));\n\n // Do not try to place collision circles if even of the points is behind the camera.\n // This is a plausible scenario with big camera pitch angles\n if (screenSpacePath.some(point => point.signedDistanceFromCamera <= 0)) {\n projectedPath = [];\n } else {\n projectedPath = screenSpacePath.map(p => p.point);\n }\n }\n\n let segments = [];\n\n if (projectedPath.length > 0) {\n // Quickly check if the path is fully inside or outside of the padded collision region.\n // For overlapping paths we'll only create collision circles for the visible segments\n const minPoint = projectedPath[0].clone();\n const maxPoint = projectedPath[0].clone();\n\n for (let i = 1; i < projectedPath.length; i++) {\n minPoint.x = Math.min(minPoint.x, projectedPath[i].x);\n minPoint.y = Math.min(minPoint.y, projectedPath[i].y);\n maxPoint.x = Math.max(maxPoint.x, projectedPath[i].x);\n maxPoint.y = Math.max(maxPoint.y, projectedPath[i].y);\n }\n\n if (minPoint.x >= screenPlaneMin.x && maxPoint.x <= screenPlaneMax.x &&\n minPoint.y >= screenPlaneMin.y && maxPoint.y <= screenPlaneMax.y) {\n // Quad fully visible\n segments = [projectedPath];\n } else if (maxPoint.x < screenPlaneMin.x || minPoint.x > screenPlaneMax.x ||\n maxPoint.y < screenPlaneMin.y || minPoint.y > screenPlaneMax.y) {\n // Not visible\n segments = [];\n } else {\n segments = clipLine([projectedPath], screenPlaneMin.x, screenPlaneMin.y, screenPlaneMax.x, screenPlaneMax.y);\n }\n }\n\n for (const seg of segments) {\n // interpolate positions for collision circles. Add a small padding to both ends of the segment\n interpolator.reset(seg, radius * 0.25);\n\n let numCircles = 0;\n\n if (interpolator.length <= 0.5 * radius) {\n numCircles = 1;\n } else {\n numCircles = Math.ceil(interpolator.paddedLength / circleDist) + 1;\n }\n\n for (let i = 0; i < numCircles; i++) {\n const t = i / Math.max(numCircles - 1, 1);\n const circlePosition = interpolator.lerp(t);\n\n // add viewport padding to the position and perform initial collision check\n const centerX = circlePosition.x + viewportPadding;\n const centerY = circlePosition.y + viewportPadding;\n\n placedCollisionCircles.push(centerX, centerY, radius, 0);\n\n const x1 = centerX - radius;\n const y1 = centerY - radius;\n const x2 = centerX + radius;\n const y2 = centerY + radius;\n\n entirelyOffscreen = entirelyOffscreen && this.isOffscreen(x1, y1, x2, y2);\n inGrid = inGrid || this.isInsideGrid(x1, y1, x2, y2);\n\n if (overlapMode !== 'always' && this.grid.hitTestCircle(centerX, centerY, radius, overlapMode, collisionGroupPredicate)) {\n // Don't early exit if we're showing the debug circles because we still want to calculate\n // which circles are in use\n collisionDetected = true;\n if (!showCollisionCircles) {\n return {\n circles: [],\n offscreen: false,\n collisionDetected\n };\n }\n }\n }\n }\n }\n\n return {\n circles: ((!showCollisionCircles && collisionDetected) || !inGrid || perspectiveRatio < this.perspectiveRatioCutoff) ? [] : placedCollisionCircles,\n offscreen: entirelyOffscreen,\n collisionDetected\n };\n }\n\n /**\n * Because the geometries in the CollisionIndex are an approximation of the shape of\n * symbols on the map, we use the CollisionIndex to look up the symbol part of\n * `queryRenderedFeatures`.\n */\n queryRenderedSymbols(viewportQueryGeometry: Array) {\n if (viewportQueryGeometry.length === 0 || (this.grid.keysLength() === 0 && this.ignoredGrid.keysLength() === 0)) {\n return {};\n }\n\n const query = [];\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const point of viewportQueryGeometry) {\n const gridPoint = new Point(point.x + viewportPadding, point.y + viewportPadding);\n minX = Math.min(minX, gridPoint.x);\n minY = Math.min(minY, gridPoint.y);\n maxX = Math.max(maxX, gridPoint.x);\n maxY = Math.max(maxY, gridPoint.y);\n query.push(gridPoint);\n }\n\n const features = this.grid.query(minX, minY, maxX, maxY)\n .concat(this.ignoredGrid.query(minX, minY, maxX, maxY));\n\n const seenFeatures = {};\n const result = {};\n\n for (const feature of features) {\n const featureKey = feature.key;\n // Skip already seen features.\n if (seenFeatures[featureKey.bucketInstanceId] === undefined) {\n seenFeatures[featureKey.bucketInstanceId] = {};\n }\n if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) {\n continue;\n }\n\n // Check if query intersects with the feature box\n // \"Collision Circles\" for line labels are treated as boxes here\n // Since there's no actual collision taking place, the circle vs. square\n // distinction doesn't matter as much, and box geometry is easier\n // to work with.\n const bbox = [\n new Point(feature.x1, feature.y1),\n new Point(feature.x2, feature.y1),\n new Point(feature.x2, feature.y2),\n new Point(feature.x1, feature.y2)\n ];\n if (!intersectionTests.polygonIntersectsPolygon(query, bbox)) {\n continue;\n }\n\n seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true;\n if (result[featureKey.bucketInstanceId] === undefined) {\n result[featureKey.bucketInstanceId] = [];\n }\n result[featureKey.bucketInstanceId].push(featureKey.featureIndex);\n }\n\n return result;\n }\n\n insertCollisionBox(collisionBox: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) {\n const grid = ignorePlacement ? this.ignoredGrid : this.grid;\n\n const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode};\n grid.insert(key, collisionBox[0], collisionBox[1], collisionBox[2], collisionBox[3]);\n }\n\n insertCollisionCircles(collisionCircles: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) {\n const grid = ignorePlacement ? this.ignoredGrid : this.grid;\n\n const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode};\n for (let k = 0; k < collisionCircles.length; k += 4) {\n grid.insertCircle(key, collisionCircles[k], collisionCircles[k + 1], collisionCircles[k + 2]);\n }\n }\n\n projectAndGetPerspectiveRatio(posMatrix: mat4, x: number, y: number, getElevation?: (x: number, y: number) => number) {\n let p;\n if (getElevation) { // slow because of handle z-index\n p = [x, y, getElevation(x, y), 1] as vec4;\n vec4.transformMat4(p, p, posMatrix);\n } else { // fast because of ignore z-index\n p = [x, y, 0, 1] as vec4;\n projection.xyTransformMat4(p, p, posMatrix);\n }\n const a = new Point(\n (((p[0] / p[3] + 1) / 2) * this.transform.width) + viewportPadding,\n (((-p[1] / p[3] + 1) / 2) * this.transform.height) + viewportPadding\n );\n return {\n point: a,\n // See perspective ratio comment in symbol_sdf.vertex\n // We're doing collision detection in viewport space so we need\n // to scale down boxes in the distance\n perspectiveRatio: 0.5 + 0.5 * (this.transform.cameraToCenterDistance / p[3])\n };\n }\n\n isOffscreen(x1: number, y1: number, x2: number, y2: number) {\n return x2 < viewportPadding || x1 >= this.screenRightBoundary || y2 < viewportPadding || y1 > this.screenBottomBoundary;\n }\n\n isInsideGrid(x1: number, y1: number, x2: number, y2: number) {\n return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary;\n }\n\n /*\n * Returns a matrix for transforming collision shapes to viewport coordinate space.\n * Use this function to render e.g. collision circles on the screen.\n * example transformation: clipPos = glCoordMatrix * viewportMatrix * circle_pos\n */\n getViewportMatrix() {\n const m = mat4.identity([] as any);\n mat4.translate(m, m, [-viewportPadding, -viewportPadding, 0.0]);\n return m;\n }\n}\n","import {EXTENT} from '../data/extent';\n\nimport type {OverscaledTileID} from './tile_id';\n\n/**\n * Converts a pixel value at a the given zoom level to tile units.\n *\n * The shaders mostly calculate everything in tile units so style\n * properties need to be converted from pixels to tile units using this.\n *\n * For example, a translation by 30 pixels at zoom 6.5 will be a\n * translation by pixelsToTileUnits(30, 6.5) tile units.\n *\n * @returns value in tile units\n */\nexport function pixelsToTileUnits(\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n },\n pixelValue: number,\n z: number\n): number {\n return pixelValue * (EXTENT / (tile.tileSize * Math.pow(2, z - tile.tileID.overscaledZ)));\n}\n","import {CollisionIndex} from './collision_index';\nimport type {FeatureKey} from './collision_index';\nimport {EXTENT} from '../data/extent';\nimport * as symbolSize from './symbol_size';\nimport * as projection from './projection';\nimport {getAnchorJustification} from './symbol_layout';\nimport {getAnchorAlignment, WritingMode} from './shaping';\nimport {mat4} from 'gl-matrix';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport Point from '@mapbox/point-geometry';\nimport type {Transform} from '../geo/transform';\nimport type {StyleLayer} from '../style/style_layer';\nimport {PossiblyEvaluated} from '../style/properties';\nimport type {SymbolLayoutProps, SymbolLayoutPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties.g';\nimport {getOverlapMode, OverlapMode} from '../style/style_layer/overlap_mode';\n\nimport type {Tile} from '../source/tile';\nimport {SymbolBucket, CollisionArrays, SingleCollisionBox} from '../data/bucket/symbol_bucket';\n\nimport type {CollisionBoxArray, CollisionVertexArray, SymbolInstance, TextAnchorOffset} from '../data/array_types.g';\nimport type {FeatureIndex} from '../data/feature_index';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {Terrain} from '../render/terrain';\nimport {warnOnce} from '../util/util';\nimport {TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor';\n\nclass OpacityState {\n opacity: number;\n placed: boolean;\n constructor(prevState: OpacityState, increment: number, placed: boolean, skipFade?: boolean | null) {\n if (prevState) {\n this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment)));\n } else {\n this.opacity = (skipFade && placed) ? 1 : 0;\n }\n this.placed = placed;\n }\n isHidden() {\n return this.opacity === 0 && !this.placed;\n }\n}\n\nclass JointOpacityState {\n text: OpacityState;\n icon: OpacityState;\n constructor(prevState: JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null) {\n this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade);\n this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade);\n }\n isHidden() {\n return this.text.isHidden() && this.icon.isHidden();\n }\n}\n\nclass JointPlacement {\n text: boolean;\n icon: boolean;\n // skipFade = outside viewport, but within CollisionIndex::viewportPadding px of the edge\n // Because these symbols aren't onscreen yet, we can skip the \"fade in\" animation,\n // and if a subsequent viewport change brings them into view, they'll be fully\n // visible right away.\n skipFade: boolean;\n constructor(text: boolean, icon: boolean, skipFade: boolean) {\n this.text = text;\n this.icon = icon;\n this.skipFade = skipFade;\n }\n}\n\nclass CollisionCircleArray {\n // Stores collision circles and placement matrices of a bucket for debug rendering.\n invProjMatrix: mat4;\n viewportMatrix: mat4;\n circles: Array;\n\n constructor() {\n this.invProjMatrix = mat4.create();\n this.viewportMatrix = mat4.create();\n this.circles = [];\n }\n}\n\nexport class RetainedQueryData {\n bucketInstanceId: number;\n featureIndex: FeatureIndex;\n sourceLayerIndex: number;\n bucketIndex: number;\n tileID: OverscaledTileID;\n featureSortOrder: Array;\n constructor(bucketInstanceId: number,\n featureIndex: FeatureIndex,\n sourceLayerIndex: number,\n bucketIndex: number,\n tileID: OverscaledTileID) {\n this.bucketInstanceId = bucketInstanceId;\n this.featureIndex = featureIndex;\n this.sourceLayerIndex = sourceLayerIndex;\n this.bucketIndex = bucketIndex;\n this.tileID = tileID;\n }\n}\n\ntype CollisionGroup = {\n ID: number;\n predicate?: (key: FeatureKey) => boolean;\n};\n\nclass CollisionGroups {\n collisionGroups: {[groupName: string]: CollisionGroup};\n maxGroupID: number;\n crossSourceCollisions: boolean;\n\n constructor(crossSourceCollisions: boolean) {\n this.crossSourceCollisions = crossSourceCollisions;\n this.maxGroupID = 0;\n this.collisionGroups = {};\n }\n\n get(sourceID: string) {\n // The predicate/groupID mechanism allows for arbitrary grouping,\n // but the current interface defines one source == one group when\n // crossSourceCollisions == true.\n if (!this.crossSourceCollisions) {\n if (!this.collisionGroups[sourceID]) {\n const nextGroupID = ++this.maxGroupID;\n this.collisionGroups[sourceID] = {\n ID: nextGroupID,\n predicate: (key) => {\n return key.collisionGroupID === nextGroupID;\n }\n };\n }\n return this.collisionGroups[sourceID];\n } else {\n return {ID: 0, predicate: null};\n }\n }\n}\n\nfunction calculateVariableLayoutShift(\n anchor: TextAnchor,\n width: number,\n height: number,\n textOffset: [number, number],\n textBoxScale: number\n): Point {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);\n const shiftX = -(horizontalAlign - 0.5) * width;\n const shiftY = -(verticalAlign - 0.5) * height;\n return new Point(\n shiftX + textOffset[0] * textBoxScale,\n shiftY + textOffset[1] * textBoxScale\n );\n}\n\nfunction shiftVariableCollisionBox(collisionBox: SingleCollisionBox,\n shiftX: number, shiftY: number,\n rotateWithMap: boolean, pitchWithMap: boolean,\n angle: number) {\n const {x1, x2, y1, y2, anchorPointX, anchorPointY} = collisionBox;\n const rotatedOffset = new Point(shiftX, shiftY);\n if (rotateWithMap) {\n rotatedOffset._rotate(pitchWithMap ? angle : -angle);\n }\n return {\n x1: x1 + rotatedOffset.x,\n y1: y1 + rotatedOffset.y,\n x2: x2 + rotatedOffset.x,\n y2: y2 + rotatedOffset.y,\n // symbol anchor point stays the same regardless of text-anchor\n anchorPointX,\n anchorPointY\n };\n}\n\nexport type VariableOffset = {\n textOffset: [number, number];\n width: number;\n height: number;\n anchor: TextAnchor;\n textBoxScale: number;\n prevAnchor?: TextAnchor;\n};\n\ntype TileLayerParameters = {\n bucket: SymbolBucket;\n layout: PossiblyEvaluated;\n posMatrix: mat4;\n textLabelPlaneMatrix: mat4;\n labelToScreenMatrix: mat4;\n scale: number;\n textPixelRatio: number;\n holdingForFade: boolean;\n collisionBoxArray: CollisionBoxArray;\n partiallyEvaluatedTextSize: {\n uSize: number;\n uSizeT: number;\n };\n collisionGroup: CollisionGroup;\n};\n\nexport type BucketPart = {\n sortKey?: number | void;\n symbolInstanceStart: number;\n symbolInstanceEnd: number;\n parameters: TileLayerParameters;\n};\n\nexport type CrossTileID = string | number;\n\nexport class Placement {\n transform: Transform;\n terrain: Terrain;\n collisionIndex: CollisionIndex;\n placements: {\n [_ in CrossTileID]: JointPlacement;\n };\n opacities: {\n [_ in CrossTileID]: JointOpacityState;\n };\n variableOffsets: {\n [_ in CrossTileID]: VariableOffset;\n };\n placedOrientations: {\n [_ in CrossTileID]: number;\n };\n commitTime: number;\n prevZoomAdjustment: number;\n lastPlacementChangeTime: number;\n stale: boolean;\n fadeDuration: number;\n retainedQueryData: {\n [_: number]: RetainedQueryData;\n };\n collisionGroups: CollisionGroups;\n prevPlacement: Placement;\n zoomAtLastRecencyCheck: number;\n collisionCircleArrays: {\n [k in any]: CollisionCircleArray;\n };\n\n constructor(transform: Transform, terrain: Terrain, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement) {\n this.transform = transform.clone();\n this.terrain = terrain;\n this.collisionIndex = new CollisionIndex(this.transform);\n this.placements = {};\n this.opacities = {};\n this.variableOffsets = {};\n this.stale = false;\n this.commitTime = 0;\n this.fadeDuration = fadeDuration;\n this.retainedQueryData = {};\n this.collisionGroups = new CollisionGroups(crossSourceCollisions);\n this.collisionCircleArrays = {};\n\n this.prevPlacement = prevPlacement;\n if (prevPlacement) {\n prevPlacement.prevPlacement = undefined; // Only hold on to one placement back\n }\n\n this.placedOrientations = {};\n }\n\n getBucketParts(results: Array, styleLayer: StyleLayer, tile: Tile, sortAcrossTiles: boolean) {\n const symbolBucket = (tile.getBucket(styleLayer) as SymbolBucket);\n const bucketFeatureIndex = tile.latestFeatureIndex;\n if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0])\n return;\n\n const collisionBoxArray = tile.collisionBoxArray;\n\n const layout = symbolBucket.layers[0].layout;\n\n const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ);\n const textPixelRatio = tile.tileSize / EXTENT;\n\n const posMatrix = this.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pixelsToTiles = pixelsToTileUnits(tile, 1, this.transform.zoom);\n\n const textLabelPlaneMatrix = projection.getLabelPlaneMatrix(posMatrix,\n pitchWithMap,\n rotateWithMap,\n this.transform,\n pixelsToTiles);\n\n let labelToScreenMatrix = null;\n\n if (pitchWithMap) {\n const glMatrix = projection.getGlCoordMatrix(\n posMatrix,\n pitchWithMap,\n rotateWithMap,\n this.transform,\n pixelsToTiles);\n\n labelToScreenMatrix = mat4.multiply([] as any, this.transform.labelPlaneMatrix, glMatrix);\n }\n\n // As long as this placement lives, we have to hold onto this bucket's\n // matching FeatureIndex/data for querying purposes\n this.retainedQueryData[symbolBucket.bucketInstanceId] = new RetainedQueryData(\n symbolBucket.bucketInstanceId,\n bucketFeatureIndex,\n symbolBucket.sourceLayerIndex,\n symbolBucket.index,\n tile.tileID\n );\n\n const parameters = {\n bucket: symbolBucket,\n layout,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n scale,\n textPixelRatio,\n holdingForFade: tile.holdingForFade(),\n collisionBoxArray,\n partiallyEvaluatedTextSize: symbolSize.evaluateSizeForZoom(symbolBucket.textSizeData, this.transform.zoom),\n collisionGroup: this.collisionGroups.get(symbolBucket.sourceID)\n };\n\n if (sortAcrossTiles) {\n for (const range of symbolBucket.sortKeyRanges) {\n const {sortKey, symbolInstanceStart, symbolInstanceEnd} = range;\n results.push({sortKey, symbolInstanceStart, symbolInstanceEnd, parameters});\n }\n } else {\n results.push({\n symbolInstanceStart: 0,\n symbolInstanceEnd: symbolBucket.symbolInstances.length,\n parameters\n });\n }\n }\n\n attemptAnchorPlacement(\n textAnchorOffset: TextAnchorOffset,\n textBox: SingleCollisionBox,\n width: number,\n height: number,\n textBoxScale: number,\n rotateWithMap: boolean,\n pitchWithMap: boolean,\n textPixelRatio: number,\n posMatrix: mat4,\n collisionGroup: CollisionGroup,\n textOverlapMode: OverlapMode,\n symbolInstance: SymbolInstance,\n bucket: SymbolBucket,\n orientation: number,\n iconBox?: SingleCollisionBox | null,\n getElevation?: (x: number, y: number) => number\n ): {\n shift: Point;\n placedGlyphBoxes: {\n box: Array;\n offscreen: boolean;\n };\n } {\n\n const anchor = TextAnchorEnum[textAnchorOffset.textAnchor] as TextAnchor;\n const textOffset = [textAnchorOffset.textOffset0, textAnchorOffset.textOffset1] as [number, number];\n const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale);\n\n const placedGlyphBoxes = this.collisionIndex.placeCollisionBox(\n shiftVariableCollisionBox(\n textBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle),\n textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n\n if (iconBox) {\n const placedIconBoxes = this.collisionIndex.placeCollisionBox(\n shiftVariableCollisionBox(\n iconBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle),\n textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n if (placedIconBoxes.box.length === 0) return;\n }\n\n if (placedGlyphBoxes.box.length > 0) {\n let prevAnchor;\n // If this label was placed in the previous placement, record the anchor position\n // to allow us to animate the transition\n if (this.prevPlacement &&\n this.prevPlacement.variableOffsets[symbolInstance.crossTileID] &&\n this.prevPlacement.placements[symbolInstance.crossTileID] &&\n this.prevPlacement.placements[symbolInstance.crossTileID].text) {\n prevAnchor = this.prevPlacement.variableOffsets[symbolInstance.crossTileID].anchor;\n }\n if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\\'t be 0');\n this.variableOffsets[symbolInstance.crossTileID] = {\n textOffset,\n width,\n height,\n anchor,\n textBoxScale,\n prevAnchor\n };\n this.markUsedJustification(bucket, anchor, symbolInstance, orientation);\n\n if (bucket.allowVerticalPlacement) {\n this.markUsedOrientation(bucket, orientation, symbolInstance);\n this.placedOrientations[symbolInstance.crossTileID] = orientation;\n }\n\n return {shift, placedGlyphBoxes};\n }\n }\n\n placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: {\n [k in string | number]: boolean;\n }, showCollisionBoxes: boolean) {\n\n const {\n bucket,\n layout,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n textPixelRatio,\n holdingForFade,\n collisionBoxArray,\n partiallyEvaluatedTextSize,\n collisionGroup\n } = bucketPart.parameters;\n\n const textOptional = layout.get('text-optional');\n const iconOptional = layout.get('icon-optional');\n const textOverlapMode = getOverlapMode(layout, 'text-overlap', 'text-allow-overlap');\n const textAlwaysOverlap = textOverlapMode === 'always';\n const iconOverlapMode = getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap');\n const iconAlwaysOverlap = iconOverlapMode === 'always';\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const hasIconTextFit = layout.get('icon-text-fit') !== 'none';\n const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y';\n\n // This logic is similar to the \"defaultOpacityState\" logic below in updateBucketOpacities\n // If we know a symbol is always supposed to show, force it to be marked visible even if\n // it wasn't placed into the collision index (because some or all of it was outside the range\n // of the collision grid).\n // There is a subtle edge case here we're accepting:\n // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false\n // A's icon is outside the grid, so doesn't get placed\n // A's text would be inside grid, but doesn't get placed because of icon-optional: false\n // We still show A because of the allow-overlap settings.\n // Symbol B has allow-overlap: false, and gets placed where A's text would be\n // On panning in, there is a short period when Symbol B and Symbol A will overlap\n // This is the reverse of our normal policy of \"fade in on pan\", but should look like any other\n // collision and hopefully not be too noticeable.\n // See https://github.com/mapbox/mapbox-gl-js/issues/7172\n const alwaysShowText = textAlwaysOverlap && (iconAlwaysOverlap || !bucket.hasIconData() || iconOptional);\n const alwaysShowIcon = iconAlwaysOverlap && (textAlwaysOverlap || !bucket.hasTextData() || textOptional);\n\n if (!bucket.collisionArrays && collisionBoxArray) {\n bucket.deserializeCollisionBoxes(collisionBoxArray);\n }\n\n const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID;\n const getElevation = this.terrain ? (x: number, y: number) => this.terrain.getElevation(tileID, x, y) : null;\n\n const placeSymbol = (symbolInstance: SymbolInstance, collisionArrays: CollisionArrays) => {\n if (seenCrossTileIDs[symbolInstance.crossTileID]) return;\n if (holdingForFade) {\n // Mark all symbols from this tile as \"not placed\", but don't add to seenCrossTileIDs, because we don't\n // know yet if we have a duplicate in a parent tile that _should_ be placed.\n this.placements[symbolInstance.crossTileID] = new JointPlacement(false, false, false);\n return;\n }\n\n let placeText = false;\n let placeIcon = false;\n let offscreen = true;\n let shift = null;\n\n let placed = {box: null, offscreen: null};\n let placedVerticalText = {box: null, offscreen: null};\n\n let placedGlyphBoxes = null;\n let placedGlyphCircles = null;\n let placedIconBoxes = null;\n let textFeatureIndex = 0;\n let verticalTextFeatureIndex = 0;\n let iconFeatureIndex = 0;\n\n if (collisionArrays.textFeatureIndex) {\n textFeatureIndex = collisionArrays.textFeatureIndex;\n } else if (symbolInstance.useRuntimeCollisionCircles) {\n textFeatureIndex = symbolInstance.featureIndex;\n }\n if (collisionArrays.verticalTextFeatureIndex) {\n verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex;\n }\n\n const textBox = collisionArrays.textBox;\n if (textBox) {\n\n const updatePreviousOrientationIfNotPlaced = (isPlaced) => {\n let previousOrientation = WritingMode.horizontal;\n if (bucket.allowVerticalPlacement && !isPlaced && this.prevPlacement) {\n const prevPlacedOrientation = this.prevPlacement.placedOrientations[symbolInstance.crossTileID];\n if (prevPlacedOrientation) {\n this.placedOrientations[symbolInstance.crossTileID] = prevPlacedOrientation;\n previousOrientation = prevPlacedOrientation;\n this.markUsedOrientation(bucket, previousOrientation, symbolInstance);\n }\n }\n return previousOrientation;\n };\n\n const placeTextForPlacementModes = (placeHorizontalFn, placeVerticalFn) => {\n if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && collisionArrays.verticalTextBox) {\n for (const placementMode of bucket.writingModes) {\n if (placementMode === WritingMode.vertical) {\n placed = placeVerticalFn();\n placedVerticalText = placed;\n } else {\n placed = placeHorizontalFn();\n }\n if (placed && placed.box && placed.box.length) break;\n }\n } else {\n placed = placeHorizontalFn();\n }\n };\n\n const textAnchorOffsetStart = symbolInstance.textAnchorOffsetStartIndex;\n const textAnchorOffsetEnd = symbolInstance.textAnchorOffsetEndIndex;\n\n // If start+end indices match, text-variable-anchor is not in play.\n if (textAnchorOffsetEnd === textAnchorOffsetStart) {\n const placeBox = (collisionTextBox, orientation) => {\n const placedFeature = this.collisionIndex.placeCollisionBox(\n collisionTextBox,\n textOverlapMode,\n textPixelRatio,\n posMatrix,\n collisionGroup.predicate,\n getElevation\n );\n if (placedFeature && placedFeature.box && placedFeature.box.length) {\n this.markUsedOrientation(bucket, orientation, symbolInstance);\n this.placedOrientations[symbolInstance.crossTileID] = orientation;\n }\n return placedFeature;\n };\n\n const placeHorizontal = () => {\n return placeBox(textBox, WritingMode.horizontal);\n };\n\n const placeVertical = () => {\n const verticalTextBox = collisionArrays.verticalTextBox;\n if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {\n return placeBox(verticalTextBox, WritingMode.vertical);\n }\n return {box: null, offscreen: null};\n };\n\n placeTextForPlacementModes(placeHorizontal, placeVertical);\n updatePreviousOrientationIfNotPlaced(placed && placed.box && placed.box.length);\n\n } else {\n // If this symbol was in the last placement, prefer placement using same anchor, if it's still available\n let prevAnchor = TextAnchorEnum[this.prevPlacement?.variableOffsets[symbolInstance.crossTileID]?.anchor];\n\n const placeBoxForVariableAnchors = (collisionTextBox, collisionIconBox, orientation) => {\n const width = collisionTextBox.x2 - collisionTextBox.x1;\n const height = collisionTextBox.y2 - collisionTextBox.y1;\n const textBoxScale = symbolInstance.textBoxScale;\n const variableIconBox = hasIconTextFit && (iconOverlapMode === 'never') ? collisionIconBox : null;\n\n let placedBox: {\n box: Array;\n offscreen: boolean;\n } = {box: [], offscreen: false};\n let placementPasses = (textOverlapMode === 'never') ? 1 : 2;\n let overlapMode: OverlapMode = 'never';\n\n if (prevAnchor) {\n placementPasses++;\n }\n\n for (let pass = 0; pass < placementPasses; pass++) {\n for (let i = textAnchorOffsetStart; i < textAnchorOffsetEnd; i++) {\n const textAnchorOffset = bucket.textAnchorOffsets.get(i);\n\n if (prevAnchor && textAnchorOffset.textAnchor !== prevAnchor) {\n continue;\n }\n\n const result = this.attemptAnchorPlacement(\n textAnchorOffset, collisionTextBox, width, height,\n textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix,\n collisionGroup, overlapMode, symbolInstance, bucket, orientation, variableIconBox, getElevation);\n\n if (result) {\n placedBox = result.placedGlyphBoxes;\n if (placedBox && placedBox.box && placedBox.box.length) {\n placeText = true;\n shift = result.shift;\n return placedBox;\n }\n }\n }\n\n if (prevAnchor) {\n prevAnchor = null;\n } else {\n overlapMode = textOverlapMode;\n }\n }\n\n return placedBox;\n };\n\n const placeHorizontal = () => {\n return placeBoxForVariableAnchors(textBox, collisionArrays.iconBox, WritingMode.horizontal);\n };\n\n const placeVertical = () => {\n const verticalTextBox = collisionArrays.verticalTextBox;\n const wasPlaced = placed && placed.box && placed.box.length;\n if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {\n return placeBoxForVariableAnchors(verticalTextBox, collisionArrays.verticalIconBox, WritingMode.vertical);\n }\n return {box: null, offscreen: null};\n };\n\n placeTextForPlacementModes(placeHorizontal, placeVertical);\n\n if (placed) {\n placeText = placed.box;\n offscreen = placed.offscreen;\n }\n\n const prevOrientation = updatePreviousOrientationIfNotPlaced(placed && placed.box);\n\n // If we didn't get placed, we still need to copy our position from the last placement for\n // fade animations\n if (!placeText && this.prevPlacement) {\n const prevOffset = this.prevPlacement.variableOffsets[symbolInstance.crossTileID];\n if (prevOffset) {\n this.variableOffsets[symbolInstance.crossTileID] = prevOffset;\n this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, prevOrientation);\n }\n }\n\n }\n }\n\n placedGlyphBoxes = placed;\n placeText = placedGlyphBoxes && placedGlyphBoxes.box && placedGlyphBoxes.box.length > 0;\n\n offscreen = placedGlyphBoxes && placedGlyphBoxes.offscreen;\n\n if (symbolInstance.useRuntimeCollisionCircles) {\n const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.centerJustifiedTextSymbolIndex);\n const fontSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol);\n\n const textPixelPadding = layout.get('text-padding');\n const circlePixelDiameter = symbolInstance.collisionCircleDiameter;\n\n placedGlyphCircles = this.collisionIndex.placeCollisionCircles(\n textOverlapMode,\n placedSymbol,\n bucket.lineVertexArray,\n bucket.glyphOffsetArray,\n fontSize,\n posMatrix,\n textLabelPlaneMatrix,\n labelToScreenMatrix,\n showCollisionBoxes,\n pitchWithMap,\n collisionGroup.predicate,\n circlePixelDiameter,\n textPixelPadding,\n getElevation\n );\n\n if (placedGlyphCircles.circles.length && placedGlyphCircles.collisionDetected && !showCollisionBoxes) {\n warnOnce('Collisions detected, but collision boxes are not shown');\n }\n\n // If text-overlap is set to 'always', force \"placedCircles\" to true\n // In theory there should always be at least one circle placed\n // in this case, but for now quirks in text-anchor\n // and text-offset may prevent that from being true.\n placeText = textAlwaysOverlap || (placedGlyphCircles.circles.length > 0 && !placedGlyphCircles.collisionDetected);\n offscreen = offscreen && placedGlyphCircles.offscreen;\n }\n\n if (collisionArrays.iconFeatureIndex) {\n iconFeatureIndex = collisionArrays.iconFeatureIndex;\n }\n\n if (collisionArrays.iconBox) {\n const placeIconFeature = iconBox => {\n const shiftedIconBox = hasIconTextFit && shift ?\n shiftVariableCollisionBox(\n iconBox, shift.x, shift.y,\n rotateWithMap, pitchWithMap, this.transform.angle) :\n iconBox;\n return this.collisionIndex.placeCollisionBox(shiftedIconBox,\n iconOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation);\n };\n\n if (placedVerticalText && placedVerticalText.box && placedVerticalText.box.length && collisionArrays.verticalIconBox) {\n placedIconBoxes = placeIconFeature(collisionArrays.verticalIconBox);\n placeIcon = placedIconBoxes.box.length > 0;\n } else {\n placedIconBoxes = placeIconFeature(collisionArrays.iconBox);\n placeIcon = placedIconBoxes.box.length > 0;\n }\n offscreen = offscreen && placedIconBoxes.offscreen;\n }\n\n const iconWithoutText = textOptional ||\n (symbolInstance.numHorizontalGlyphVertices === 0 && symbolInstance.numVerticalGlyphVertices === 0);\n const textWithoutIcon = iconOptional || symbolInstance.numIconVertices === 0;\n\n // Combine the scales for icons and text.\n if (!iconWithoutText && !textWithoutIcon) {\n placeIcon = placeText = placeIcon && placeText;\n } else if (!textWithoutIcon) {\n placeText = placeIcon && placeText;\n } else if (!iconWithoutText) {\n placeIcon = placeIcon && placeText;\n }\n\n if (placeText && placedGlyphBoxes && placedGlyphBoxes.box) {\n if (placedVerticalText && placedVerticalText.box && verticalTextFeatureIndex) {\n this.collisionIndex.insertCollisionBox(\n placedGlyphBoxes.box,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n verticalTextFeatureIndex,\n collisionGroup.ID);\n } else {\n this.collisionIndex.insertCollisionBox(\n placedGlyphBoxes.box,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n textFeatureIndex,\n collisionGroup.ID);\n }\n\n }\n if (placeIcon && placedIconBoxes) {\n this.collisionIndex.insertCollisionBox(\n placedIconBoxes.box,\n iconOverlapMode,\n layout.get('icon-ignore-placement'),\n bucket.bucketInstanceId,\n iconFeatureIndex,\n collisionGroup.ID);\n }\n if (placedGlyphCircles) {\n if (placeText) {\n this.collisionIndex.insertCollisionCircles(\n placedGlyphCircles.circles,\n textOverlapMode,\n layout.get('text-ignore-placement'),\n bucket.bucketInstanceId,\n textFeatureIndex,\n collisionGroup.ID);\n }\n\n if (showCollisionBoxes) {\n const id = bucket.bucketInstanceId;\n let circleArray = this.collisionCircleArrays[id];\n\n // Group collision circles together by bucket. Circles can't be pushed forward for rendering yet as the symbol placement\n // for a bucket is not guaranteed to be complete before the commit-function has been called\n if (circleArray === undefined)\n circleArray = this.collisionCircleArrays[id] = new CollisionCircleArray();\n\n for (let i = 0; i < placedGlyphCircles.circles.length; i += 4) {\n circleArray.circles.push(placedGlyphCircles.circles[i + 0]); // x\n circleArray.circles.push(placedGlyphCircles.circles[i + 1]); // y\n circleArray.circles.push(placedGlyphCircles.circles[i + 2]); // radius\n circleArray.circles.push(placedGlyphCircles.collisionDetected ? 1 : 0); // collisionDetected-flag\n }\n }\n }\n\n if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\\'t be 0');\n if (bucket.bucketInstanceId === 0) throw new Error('bucket.bucketInstanceId can\\'t be 0');\n\n this.placements[symbolInstance.crossTileID] = new JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded);\n seenCrossTileIDs[symbolInstance.crossTileID] = true;\n };\n\n if (zOrderByViewportY) {\n if (bucketPart.symbolInstanceStart !== 0) throw new Error('bucket.bucketInstanceId should be 0');\n const symbolIndexes = bucket.getSortedSymbolIndexes(this.transform.angle);\n for (let i = symbolIndexes.length - 1; i >= 0; --i) {\n const symbolIndex = symbolIndexes[i];\n placeSymbol(bucket.symbolInstances.get(symbolIndex), bucket.collisionArrays[symbolIndex]);\n }\n } else {\n for (let i = bucketPart.symbolInstanceStart; i < bucketPart.symbolInstanceEnd; i++) {\n placeSymbol(bucket.symbolInstances.get(i), bucket.collisionArrays[i]);\n }\n }\n\n if (showCollisionBoxes && bucket.bucketInstanceId in this.collisionCircleArrays) {\n const circleArray = this.collisionCircleArrays[bucket.bucketInstanceId];\n\n // Store viewport and inverse projection matrices per bucket\n mat4.invert(circleArray.invProjMatrix, posMatrix);\n circleArray.viewportMatrix = this.collisionIndex.getViewportMatrix();\n }\n\n bucket.justReloaded = false;\n }\n\n markUsedJustification(bucket: SymbolBucket, placedAnchor: TextAnchor, symbolInstance: SymbolInstance, orientation: number) {\n const justifications = {\n 'left': symbolInstance.leftJustifiedTextSymbolIndex,\n 'center': symbolInstance.centerJustifiedTextSymbolIndex,\n 'right': symbolInstance.rightJustifiedTextSymbolIndex\n };\n\n let autoIndex;\n if (orientation === WritingMode.vertical) {\n autoIndex = symbolInstance.verticalPlacedTextSymbolIndex;\n } else {\n autoIndex = justifications[getAnchorJustification(placedAnchor)];\n }\n\n const indexes = [\n symbolInstance.leftJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.verticalPlacedTextSymbolIndex\n ];\n\n for (const index of indexes) {\n if (index >= 0) {\n if (autoIndex >= 0 && index !== autoIndex) {\n // There are multiple justifications and this one isn't it: shift offscreen\n bucket.text.placedSymbolArray.get(index).crossTileID = 0;\n } else {\n // Either this is the chosen justification or the justification is hardwired: use this one\n bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID;\n }\n }\n }\n }\n\n markUsedOrientation(bucket: SymbolBucket, orientation: number, symbolInstance: SymbolInstance) {\n const horizontal = (orientation === WritingMode.horizontal || orientation === WritingMode.horizontalOnly) ? orientation : 0;\n const vertical = orientation === WritingMode.vertical ? orientation : 0;\n\n const horizontalIndexes = [\n symbolInstance.leftJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.rightJustifiedTextSymbolIndex\n ];\n\n for (const index of horizontalIndexes) {\n bucket.text.placedSymbolArray.get(index).placedOrientation = horizontal;\n }\n\n if (symbolInstance.verticalPlacedTextSymbolIndex) {\n bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).placedOrientation = vertical;\n }\n }\n\n commit(now: number): void {\n this.commitTime = now;\n this.zoomAtLastRecencyCheck = this.transform.zoom;\n\n const prevPlacement = this.prevPlacement;\n let placementChanged = false;\n\n this.prevZoomAdjustment = prevPlacement ? prevPlacement.zoomAdjustment(this.transform.zoom) : 0;\n const increment = prevPlacement ? prevPlacement.symbolFadeChange(now) : 1;\n\n const prevOpacities = prevPlacement ? prevPlacement.opacities : {};\n const prevOffsets = prevPlacement ? prevPlacement.variableOffsets : {};\n const prevOrientations = prevPlacement ? prevPlacement.placedOrientations : {};\n\n // add the opacities from the current placement, and copy their current values from the previous placement\n for (const crossTileID in this.placements) {\n const jointPlacement = this.placements[crossTileID];\n const prevOpacity = prevOpacities[crossTileID];\n if (prevOpacity) {\n this.opacities[crossTileID] = new JointOpacityState(prevOpacity, increment, jointPlacement.text, jointPlacement.icon);\n placementChanged = placementChanged ||\n jointPlacement.text !== prevOpacity.text.placed ||\n jointPlacement.icon !== prevOpacity.icon.placed;\n } else {\n this.opacities[crossTileID] = new JointOpacityState(null, increment, jointPlacement.text, jointPlacement.icon, jointPlacement.skipFade);\n placementChanged = placementChanged || jointPlacement.text || jointPlacement.icon;\n }\n }\n\n // copy and update values from the previous placement that aren't in the current placement but haven't finished fading\n for (const crossTileID in prevOpacities) {\n const prevOpacity = prevOpacities[crossTileID];\n if (!this.opacities[crossTileID]) {\n const jointOpacity = new JointOpacityState(prevOpacity, increment, false, false);\n if (!jointOpacity.isHidden()) {\n this.opacities[crossTileID] = jointOpacity;\n placementChanged = placementChanged || prevOpacity.text.placed || prevOpacity.icon.placed;\n }\n }\n }\n for (const crossTileID in prevOffsets) {\n if (!this.variableOffsets[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {\n this.variableOffsets[crossTileID] = prevOffsets[crossTileID];\n }\n }\n\n for (const crossTileID in prevOrientations) {\n if (!this.placedOrientations[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {\n this.placedOrientations[crossTileID] = prevOrientations[crossTileID];\n }\n }\n\n // this.lastPlacementChangeTime is the time of the last commit() that\n // resulted in a placement change -- in other words, the start time of\n // the last symbol fade animation\n if (prevPlacement && prevPlacement.lastPlacementChangeTime === undefined) {\n throw new Error('Last placement time for previous placement is not defined');\n }\n if (placementChanged) {\n this.lastPlacementChangeTime = now;\n } else if (typeof this.lastPlacementChangeTime !== 'number') {\n this.lastPlacementChangeTime = prevPlacement ? prevPlacement.lastPlacementChangeTime : now;\n }\n }\n\n updateLayerOpacities(styleLayer: StyleLayer, tiles: Array) {\n const seenCrossTileIDs = {};\n for (const tile of tiles) {\n const symbolBucket = tile.getBucket(styleLayer) as SymbolBucket;\n if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) {\n this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray);\n }\n }\n }\n\n updateBucketOpacities(bucket: SymbolBucket, seenCrossTileIDs: {\n [k in string | number]: boolean;\n }, collisionBoxArray?: CollisionBoxArray | null) {\n if (bucket.hasTextData()) {\n bucket.text.opacityVertexArray.clear();\n bucket.text.hasVisibleVertices = false;\n }\n if (bucket.hasIconData()) {\n bucket.icon.opacityVertexArray.clear();\n bucket.icon.hasVisibleVertices = false;\n }\n if (bucket.hasIconCollisionBoxData()) bucket.iconCollisionBox.collisionVertexArray.clear();\n if (bucket.hasTextCollisionBoxData()) bucket.textCollisionBox.collisionVertexArray.clear();\n\n const layer = bucket.layers[0];\n const layout = layer.layout;\n const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true);\n const textAllowOverlap = layout.get('text-allow-overlap');\n const iconAllowOverlap = layout.get('icon-allow-overlap');\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n const rotateWithMap = layout.get('text-rotation-alignment') === 'map';\n const pitchWithMap = layout.get('text-pitch-alignment') === 'map';\n const hasIconTextFit = layout.get('icon-text-fit') !== 'none';\n // If allow-overlap is true, we can show symbols before placement runs on them\n // But we have to wait for placement if we potentially depend on a paired icon/text\n // with allow-overlap: false.\n // See https://github.com/mapbox/mapbox-gl-js/issues/7032\n const defaultOpacityState = new JointOpacityState(null, 0,\n textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || layout.get('icon-optional')),\n iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || layout.get('text-optional')),\n true);\n\n if (!bucket.collisionArrays && collisionBoxArray && ((bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()))) {\n bucket.deserializeCollisionBoxes(collisionBoxArray);\n }\n\n const addOpacities = (iconOrText, numVertices: number, opacity: number) => {\n for (let i = 0; i < numVertices / 4; i++) {\n iconOrText.opacityVertexArray.emplaceBack(opacity);\n }\n iconOrText.hasVisibleVertices = iconOrText.hasVisibleVertices || (opacity !== PACKED_HIDDEN_OPACITY);\n };\n\n for (let s = 0; s < bucket.symbolInstances.length; s++) {\n const symbolInstance = bucket.symbolInstances.get(s);\n const {\n numHorizontalGlyphVertices,\n numVerticalGlyphVertices,\n crossTileID\n } = symbolInstance;\n\n const isDuplicate = seenCrossTileIDs[crossTileID];\n\n let opacityState = this.opacities[crossTileID];\n if (isDuplicate) {\n opacityState = duplicateOpacityState;\n } else if (!opacityState) {\n opacityState = defaultOpacityState;\n // store the state so that future placements use it as a starting point\n this.opacities[crossTileID] = opacityState;\n }\n\n seenCrossTileIDs[crossTileID] = true;\n\n const hasText = numHorizontalGlyphVertices > 0 || numVerticalGlyphVertices > 0;\n const hasIcon = symbolInstance.numIconVertices > 0;\n\n const placedOrientation = this.placedOrientations[symbolInstance.crossTileID];\n const horizontalHidden = placedOrientation === WritingMode.vertical;\n const verticalHidden = placedOrientation === WritingMode.horizontal || placedOrientation === WritingMode.horizontalOnly;\n\n if (hasText) {\n const packedOpacity = packOpacity(opacityState.text);\n // Vertical text fades in/out on collision the same way as corresponding\n // horizontal text. Switch between vertical/horizontal should be instantaneous\n const horizontalOpacity = horizontalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;\n addOpacities(bucket.text, numHorizontalGlyphVertices, horizontalOpacity);\n const verticalOpacity = verticalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;\n addOpacities(bucket.text, numVerticalGlyphVertices, verticalOpacity);\n\n // If this label is completely faded, mark it so that we don't have to calculate\n // its position at render time. If this layer has variable placement, shift the various\n // symbol instances appropriately so that symbols from buckets that have yet to be placed\n // offset appropriately.\n const symbolHidden = opacityState.text.isHidden();\n [\n symbolInstance.rightJustifiedTextSymbolIndex,\n symbolInstance.centerJustifiedTextSymbolIndex,\n symbolInstance.leftJustifiedTextSymbolIndex\n ].forEach(index => {\n if (index >= 0) {\n bucket.text.placedSymbolArray.get(index).hidden = symbolHidden || horizontalHidden ? 1 : 0;\n }\n });\n\n if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {\n bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).hidden = symbolHidden || verticalHidden ? 1 : 0;\n }\n\n const prevOffset = this.variableOffsets[symbolInstance.crossTileID];\n if (prevOffset) {\n this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, placedOrientation);\n }\n\n const prevOrientation = this.placedOrientations[symbolInstance.crossTileID];\n if (prevOrientation) {\n this.markUsedJustification(bucket, 'left', symbolInstance, prevOrientation);\n this.markUsedOrientation(bucket, prevOrientation, symbolInstance);\n }\n }\n\n if (hasIcon) {\n const packedOpacity = packOpacity(opacityState.icon);\n\n const useHorizontal = !(hasIconTextFit && symbolInstance.verticalPlacedIconSymbolIndex && horizontalHidden);\n\n if (symbolInstance.placedIconSymbolIndex >= 0) {\n const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;\n addOpacities(bucket.icon, symbolInstance.numIconVertices, horizontalOpacity);\n bucket.icon.placedSymbolArray.get(symbolInstance.placedIconSymbolIndex).hidden =\n (opacityState.icon.isHidden() as any);\n }\n\n if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {\n const verticalOpacity = !useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;\n addOpacities(bucket.icon, symbolInstance.numVerticalIconVertices, verticalOpacity);\n bucket.icon.placedSymbolArray.get(symbolInstance.verticalPlacedIconSymbolIndex).hidden =\n (opacityState.icon.isHidden() as any);\n }\n }\n\n if (bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()) {\n const collisionArrays = bucket.collisionArrays[s];\n if (collisionArrays) {\n let shift = new Point(0, 0);\n if (collisionArrays.textBox || collisionArrays.verticalTextBox) {\n let used = true;\n if (hasVariablePlacement) {\n const variableOffset = this.variableOffsets[crossTileID];\n if (variableOffset) {\n // This will show either the currently placed position or the last\n // successfully placed position (so you can visualize what collision\n // just made the symbol disappear, and the most likely place for the\n // symbol to come back)\n shift = calculateVariableLayoutShift(variableOffset.anchor,\n variableOffset.width,\n variableOffset.height,\n variableOffset.textOffset,\n variableOffset.textBoxScale);\n if (rotateWithMap) {\n shift._rotate(pitchWithMap ? this.transform.angle : -this.transform.angle);\n }\n } else {\n // No offset -> this symbol hasn't been placed since coming on-screen\n // No single box is particularly meaningful and all of them would be too noisy\n // Use the center box just to show something's there, but mark it \"not used\"\n used = false;\n }\n }\n\n if (collisionArrays.textBox) {\n updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || horizontalHidden, shift.x, shift.y);\n }\n if (collisionArrays.verticalTextBox) {\n updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || verticalHidden, shift.x, shift.y);\n }\n }\n\n const verticalIconUsed = Boolean(!verticalHidden && collisionArrays.verticalIconBox);\n\n if (collisionArrays.iconBox) {\n updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, verticalIconUsed,\n hasIconTextFit ? shift.x : 0,\n hasIconTextFit ? shift.y : 0);\n }\n\n if (collisionArrays.verticalIconBox) {\n updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, !verticalIconUsed,\n hasIconTextFit ? shift.x : 0,\n hasIconTextFit ? shift.y : 0);\n }\n }\n }\n }\n\n bucket.sortFeatures(this.transform.angle);\n if (this.retainedQueryData[bucket.bucketInstanceId]) {\n this.retainedQueryData[bucket.bucketInstanceId].featureSortOrder = bucket.featureSortOrder;\n }\n\n if (bucket.hasTextData() && bucket.text.opacityVertexBuffer) {\n bucket.text.opacityVertexBuffer.updateData(bucket.text.opacityVertexArray);\n }\n if (bucket.hasIconData() && bucket.icon.opacityVertexBuffer) {\n bucket.icon.opacityVertexBuffer.updateData(bucket.icon.opacityVertexArray);\n }\n if (bucket.hasIconCollisionBoxData() && bucket.iconCollisionBox.collisionVertexBuffer) {\n bucket.iconCollisionBox.collisionVertexBuffer.updateData(bucket.iconCollisionBox.collisionVertexArray);\n }\n if (bucket.hasTextCollisionBoxData() && bucket.textCollisionBox.collisionVertexBuffer) {\n bucket.textCollisionBox.collisionVertexBuffer.updateData(bucket.textCollisionBox.collisionVertexArray);\n }\n\n if (bucket.text.opacityVertexArray.length !== bucket.text.layoutVertexArray.length / 4) throw new Error(`bucket.text.opacityVertexArray.length (= ${bucket.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${bucket.text.layoutVertexArray.length}) / 4`);\n if (bucket.icon.opacityVertexArray.length !== bucket.icon.layoutVertexArray.length / 4) throw new Error(`bucket.icon.opacityVertexArray.length (= ${bucket.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${bucket.icon.layoutVertexArray.length}) / 4`);\n\n // Push generated collision circles to the bucket for debug rendering\n if (bucket.bucketInstanceId in this.collisionCircleArrays) {\n const instance = this.collisionCircleArrays[bucket.bucketInstanceId];\n\n bucket.placementInvProjMatrix = instance.invProjMatrix;\n bucket.placementViewportMatrix = instance.viewportMatrix;\n bucket.collisionCircleArray = instance.circles;\n\n delete this.collisionCircleArrays[bucket.bucketInstanceId];\n }\n }\n\n symbolFadeChange(now: number) {\n return this.fadeDuration === 0 ?\n 1 :\n ((now - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment);\n }\n\n zoomAdjustment(zoom: number) {\n // When zooming out quickly, labels can overlap each other. This\n // adjustment is used to reduce the interval between placement calculations\n // and to reduce the fade duration when zooming out quickly. Discovering the\n // collisions more quickly and fading them more quickly reduces the unwanted effect.\n return Math.max(0, (this.transform.zoom - zoom) / 1.5);\n }\n\n hasTransitions(now: number) {\n return this.stale ||\n now - this.lastPlacementChangeTime < this.fadeDuration;\n }\n\n stillRecent(now: number, zoom: number) {\n // The adjustment makes placement more frequent when zooming.\n // This condition applies the adjustment only after the map has\n // stopped zooming. This avoids adding extra jank while zooming.\n const durationAdjustment = this.zoomAtLastRecencyCheck === zoom ?\n (1 - this.zoomAdjustment(zoom)) :\n 1;\n this.zoomAtLastRecencyCheck = zoom;\n\n return this.commitTime + this.fadeDuration * durationAdjustment > now;\n }\n\n setStale() {\n this.stale = true;\n }\n}\n\nfunction updateCollisionVertices(collisionVertexArray: CollisionVertexArray, placed: boolean, notUsed: boolean | number, shiftX?: number, shiftY?: number) {\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);\n}\n\n// All four vertices for a glyph will have the same opacity state\n// So we pack the opacity into a uint8, and then repeat it four times\n// to make a single uint32 that we can upload for each glyph in the\n// label.\nconst shift25 = Math.pow(2, 25);\nconst shift24 = Math.pow(2, 24);\nconst shift17 = Math.pow(2, 17);\nconst shift16 = Math.pow(2, 16);\nconst shift9 = Math.pow(2, 9);\nconst shift8 = Math.pow(2, 8);\nconst shift1 = Math.pow(2, 1);\nfunction packOpacity(opacityState: OpacityState): number {\n if (opacityState.opacity === 0 && !opacityState.placed) {\n return 0;\n } else if (opacityState.opacity === 1 && opacityState.placed) {\n return 4294967295;\n }\n const targetBit = opacityState.placed ? 1 : 0;\n const opacityBits = Math.floor(opacityState.opacity * 127);\n return opacityBits * shift25 + targetBit * shift24 +\n opacityBits * shift17 + targetBit * shift16 +\n opacityBits * shift9 + targetBit * shift8 +\n opacityBits * shift1 + targetBit;\n}\n\nconst PACKED_HIDDEN_OPACITY = 0;\n","import {browser} from '../util/browser';\n\nimport {Placement} from '../symbol/placement';\n\nimport type {Transform} from '../geo/transform';\nimport type {StyleLayer} from './style_layer';\nimport type {SymbolStyleLayer} from './style_layer/symbol_style_layer';\nimport type {Tile} from '../source/tile';\nimport type {BucketPart} from '../symbol/placement';\nimport {Terrain} from '../render/terrain';\n\nclass LayerPlacement {\n _sortAcrossTiles: boolean;\n _currentTileIndex: number;\n _currentPartIndex: number;\n _seenCrossTileIDs: {\n [k in string | number]: boolean;\n };\n _bucketParts: Array;\n\n constructor(styleLayer: SymbolStyleLayer) {\n this._sortAcrossTiles = styleLayer.layout.get('symbol-z-order') !== 'viewport-y' &&\n !styleLayer.layout.get('symbol-sort-key').isConstant();\n\n this._currentTileIndex = 0;\n this._currentPartIndex = 0;\n this._seenCrossTileIDs = {};\n this._bucketParts = [];\n }\n\n continuePlacement(tiles: Array, placement: Placement, showCollisionBoxes: boolean, styleLayer: StyleLayer, shouldPausePlacement: () => boolean) {\n\n const bucketParts = this._bucketParts;\n\n while (this._currentTileIndex < tiles.length) {\n const tile = tiles[this._currentTileIndex];\n placement.getBucketParts(bucketParts, styleLayer, tile, this._sortAcrossTiles);\n\n this._currentTileIndex++;\n if (shouldPausePlacement()) {\n return true;\n }\n }\n\n if (this._sortAcrossTiles) {\n this._sortAcrossTiles = false;\n bucketParts.sort((a, b) => (a.sortKey as any as number) - (b.sortKey as any as number));\n }\n\n while (this._currentPartIndex < bucketParts.length) {\n const bucketPart = bucketParts[this._currentPartIndex];\n placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes);\n\n this._currentPartIndex++;\n if (shouldPausePlacement()) {\n return true;\n }\n }\n return false;\n }\n}\n\nexport class PauseablePlacement {\n placement: Placement;\n _done: boolean;\n _currentPlacementIndex: number;\n _forceFullPlacement: boolean;\n _showCollisionBoxes: boolean;\n _inProgressLayer: LayerPlacement;\n\n constructor(\n transform: Transform,\n terrain: Terrain,\n order: Array,\n forceFullPlacement: boolean,\n showCollisionBoxes: boolean,\n fadeDuration: number,\n crossSourceCollisions: boolean,\n prevPlacement?: Placement\n ) {\n this.placement = new Placement(transform, terrain, fadeDuration, crossSourceCollisions, prevPlacement);\n this._currentPlacementIndex = order.length - 1;\n this._forceFullPlacement = forceFullPlacement;\n this._showCollisionBoxes = showCollisionBoxes;\n this._done = false;\n }\n\n isDone() {\n return this._done;\n }\n\n continuePlacement(\n order: Array,\n layers: {[_: string]: StyleLayer},\n layerTiles: {[_: string]: Array}\n ) {\n const startTime = browser.now();\n\n const shouldPausePlacement = () => {\n return this._forceFullPlacement ? false : (browser.now() - startTime) > 2;\n };\n\n while (this._currentPlacementIndex >= 0) {\n const layerId = order[this._currentPlacementIndex];\n const layer = layers[layerId];\n const placementZoom = this.placement.collisionIndex.transform.zoom;\n if (layer.type === 'symbol' &&\n (!layer.minzoom || layer.minzoom <= placementZoom) &&\n (!layer.maxzoom || layer.maxzoom > placementZoom)) {\n\n if (!this._inProgressLayer) {\n this._inProgressLayer = new LayerPlacement(layer as any as SymbolStyleLayer);\n }\n\n const pausePlacement = this._inProgressLayer.continuePlacement(layerTiles[layer.source], this.placement, this._showCollisionBoxes, layer, shouldPausePlacement);\n\n if (pausePlacement) {\n // We didn't finish placing all layers within 2ms,\n // but we can keep rendering with a partial placement\n // We'll resume here on the next frame\n return;\n }\n\n delete this._inProgressLayer;\n }\n\n this._currentPlacementIndex--;\n }\n\n this._done = true;\n }\n\n commit(now: number) {\n this.placement.commit(now);\n return this.placement;\n }\n}\n","import KDBush from 'kdbush';\nimport {EXTENT} from '../data/extent';\n\nimport {SymbolInstanceArray} from '../data/array_types.g';\n\nimport type {SymbolInstance} from '../data/array_types.g';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {Tile} from '../source/tile';\n\n/*\n The CrossTileSymbolIndex generally works on the assumption that\n a conceptual \"unique symbol\" can be identified by the text of\n the label combined with the anchor point. The goal is to assign\n these conceptual \"unique symbols\" a shared crossTileID that can be\n used by Placement to keep fading opacity states consistent and to\n deduplicate labels.\n\n The CrossTileSymbolIndex indexes all the current symbol instances and\n their crossTileIDs. When a symbol bucket gets added or updated, the\n index assigns a crossTileID to each of it's symbol instances by either\n matching it with an existing id or assigning a new one.\n*/\n\n// Round anchor positions to roughly 4 pixel grid\nconst roundingFactor = 512 / EXTENT / 2;\n\nexport const KDBUSH_THRESHHOLD = 128;\n\ninterface SymbolsByKeyEntry {\n index?: KDBush;\n positions?: {x: number; y: number}[];\n crossTileIDs: number[];\n}\n\nclass TileLayerIndex {\n _symbolsByKey: Record = {};\n\n constructor(public tileID: OverscaledTileID, symbolInstances: SymbolInstanceArray, public bucketInstanceId: number) {\n // group the symbolInstances by key\n const symbolInstancesByKey = new Map();\n for (let i = 0; i < symbolInstances.length; i++) {\n const symbolInstance = symbolInstances.get(i);\n const key = symbolInstance.key;\n const instances = symbolInstancesByKey.get(key);\n if (instances) {\n // This tile may have multiple symbol instances with the same key\n // Store each one along with its coordinates\n instances.push(symbolInstance);\n } else {\n symbolInstancesByKey.set(key, [symbolInstance]);\n }\n }\n\n // index the SymbolInstances in this each bucket\n for (const [key, symbols] of symbolInstancesByKey) {\n const positions = symbols.map(symbolInstance => ({x: Math.floor(symbolInstance.anchorX * roundingFactor), y: Math.floor(symbolInstance.anchorY * roundingFactor)}));\n const crossTileIDs = symbols.map(v => v.crossTileID);\n const entry: SymbolsByKeyEntry = {positions, crossTileIDs};\n\n // once we get too many symbols for a given key, it becomes much faster to index it before queries\n if (entry.positions.length > KDBUSH_THRESHHOLD) {\n\n const index = new KDBush(entry.positions.length, 16, Uint16Array);\n for (const {x, y} of entry.positions) index.add(x, y);\n index.finish();\n\n // clear all references to the original positions data\n delete entry.positions;\n entry.index = index;\n }\n\n this._symbolsByKey[key] = entry;\n }\n }\n\n // Converts the coordinates of the input symbol instance into coordinates that be can compared\n // against other symbols in this index. Coordinates are:\n // (1) local-tile-based (so after correction we get x,y values relative to our local anchorX/Y)\n // (2) converted to the z-scale of this TileLayerIndex\n // (3) down-sampled by \"roundingFactor\" from tile coordinate precision in order to be\n // more tolerant of small differences between tiles.\n getScaledCoordinates(symbolInstance: SymbolInstance, childTileID: OverscaledTileID): {x: number; y: number} {\n const {x: localX, y: localY, z: localZ} = this.tileID.canonical;\n const {x, y, z} = childTileID.canonical;\n\n const zDifference = z - localZ;\n const scale = roundingFactor / Math.pow(2, zDifference);\n const xWorld = (x * EXTENT + symbolInstance.anchorX) * scale;\n const yWorld = (y * EXTENT + symbolInstance.anchorY) * scale;\n const xOffset = localX * EXTENT * roundingFactor;\n const yOffset = localY * EXTENT * roundingFactor;\n const result = {\n x: Math.floor(xWorld - xOffset),\n y: Math.floor(yWorld - yOffset)\n };\n\n return result;\n }\n\n findMatches(symbolInstances: SymbolInstanceArray, newTileID: OverscaledTileID, zoomCrossTileIDs: {\n [crossTileID: number]: boolean;\n }) {\n const tolerance = this.tileID.canonical.z < newTileID.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - newTileID.canonical.z);\n\n for (let i = 0; i < symbolInstances.length; i++) {\n const symbolInstance = symbolInstances.get(i);\n if (symbolInstance.crossTileID) {\n // already has a match, skip\n continue;\n }\n\n const entry = this._symbolsByKey[symbolInstance.key];\n if (!entry) {\n // No symbol with this key in this bucket\n continue;\n }\n\n const scaledSymbolCoord = this.getScaledCoordinates(symbolInstance, newTileID);\n\n if (entry.index) {\n // Return any symbol with the same keys whose coordinates are within 1\n // grid unit. (with a 4px grid, this covers a 12px by 12px area)\n const indexes = entry.index.range(\n scaledSymbolCoord.x - tolerance,\n scaledSymbolCoord.y - tolerance,\n scaledSymbolCoord.x + tolerance,\n scaledSymbolCoord.y + tolerance).sort();\n\n for (const i of indexes) {\n const crossTileID = entry.crossTileIDs[i];\n\n if (!zoomCrossTileIDs[crossTileID]) {\n // Once we've marked ourselves duplicate against this parent symbol,\n // don't let any other symbols at the same zoom level duplicate against\n // the same parent (see issue #5993)\n zoomCrossTileIDs[crossTileID] = true;\n symbolInstance.crossTileID = crossTileID;\n break;\n }\n }\n } else if (entry.positions) {\n for (let i = 0; i < entry.positions.length; i++) {\n const thisTileSymbol = entry.positions[i];\n const crossTileID = entry.crossTileIDs[i];\n\n // Return any symbol with the same keys whose coordinates are within 1\n // grid unit. (with a 4px grid, this covers a 12px by 12px area)\n if (Math.abs(thisTileSymbol.x - scaledSymbolCoord.x) <= tolerance &&\n Math.abs(thisTileSymbol.y - scaledSymbolCoord.y) <= tolerance &&\n !zoomCrossTileIDs[crossTileID]) {\n // Once we've marked ourselves duplicate against this parent symbol,\n // don't let any other symbols at the same zoom level duplicate against\n // the same parent (see issue #5993)\n zoomCrossTileIDs[crossTileID] = true;\n symbolInstance.crossTileID = crossTileID;\n break;\n }\n }\n }\n }\n }\n\n getCrossTileIDsLists() {\n return Object.values(this._symbolsByKey).map(({crossTileIDs}) => crossTileIDs);\n }\n}\n\nclass CrossTileIDs {\n maxCrossTileID: number;\n constructor() {\n this.maxCrossTileID = 0;\n }\n generate() {\n return ++this.maxCrossTileID;\n }\n}\n\nclass CrossTileSymbolLayerIndex {\n indexes: {\n [zoom in string | number]: {\n [tileId in string | number]: TileLayerIndex;\n };\n };\n usedCrossTileIDs: {\n [zoom in string | number]: {\n [crossTileID: number]: boolean;\n };\n };\n lng: number;\n\n constructor() {\n this.indexes = {};\n this.usedCrossTileIDs = {};\n this.lng = 0;\n }\n\n /*\n * Sometimes when a user pans across the antimeridian the longitude value gets wrapped.\n * To prevent labels from flashing out and in we adjust the tileID values in the indexes\n * so that they match the new wrapped version of the map.\n */\n handleWrapJump(lng: number) {\n const wrapDelta = Math.round((lng - this.lng) / 360);\n if (wrapDelta !== 0) {\n for (const zoom in this.indexes) {\n const zoomIndexes = this.indexes[zoom];\n const newZoomIndex = {};\n for (const key in zoomIndexes) {\n // change the tileID's wrap and add it to a new index\n const index = zoomIndexes[key];\n index.tileID = index.tileID.unwrapTo(index.tileID.wrap + wrapDelta);\n newZoomIndex[index.tileID.key] = index;\n }\n this.indexes[zoom] = newZoomIndex;\n }\n }\n this.lng = lng;\n }\n\n addBucket(tileID: OverscaledTileID, bucket: SymbolBucket, crossTileIDs: CrossTileIDs) {\n if (this.indexes[tileID.overscaledZ] &&\n this.indexes[tileID.overscaledZ][tileID.key]) {\n if (this.indexes[tileID.overscaledZ][tileID.key].bucketInstanceId ===\n bucket.bucketInstanceId) {\n return false;\n } else {\n // We're replacing this bucket with an updated version\n // Remove the old bucket's \"used crossTileIDs\" now so that\n // the new bucket can claim them.\n // The old index entries themselves stick around until\n // 'removeStaleBuckets' is called.\n this.removeBucketCrossTileIDs(tileID.overscaledZ,\n this.indexes[tileID.overscaledZ][tileID.key]);\n }\n }\n\n for (let i = 0; i < bucket.symbolInstances.length; i++) {\n const symbolInstance = bucket.symbolInstances.get(i);\n symbolInstance.crossTileID = 0;\n }\n\n if (!this.usedCrossTileIDs[tileID.overscaledZ]) {\n this.usedCrossTileIDs[tileID.overscaledZ] = {};\n }\n const zoomCrossTileIDs = this.usedCrossTileIDs[tileID.overscaledZ];\n\n for (const zoom in this.indexes) {\n const zoomIndexes = this.indexes[zoom];\n if (Number(zoom) > tileID.overscaledZ) {\n for (const id in zoomIndexes) {\n const childIndex = zoomIndexes[id];\n if (childIndex.tileID.isChildOf(tileID)) {\n childIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs);\n }\n }\n } else {\n const parentCoord = tileID.scaledTo(Number(zoom));\n const parentIndex = zoomIndexes[parentCoord.key];\n if (parentIndex) {\n parentIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs);\n }\n }\n }\n\n for (let i = 0; i < bucket.symbolInstances.length; i++) {\n const symbolInstance = bucket.symbolInstances.get(i);\n if (!symbolInstance.crossTileID) {\n // symbol did not match any known symbol, assign a new id\n symbolInstance.crossTileID = crossTileIDs.generate();\n zoomCrossTileIDs[symbolInstance.crossTileID] = true;\n }\n }\n\n if (this.indexes[tileID.overscaledZ] === undefined) {\n this.indexes[tileID.overscaledZ] = {};\n }\n this.indexes[tileID.overscaledZ][tileID.key] = new TileLayerIndex(tileID, bucket.symbolInstances, bucket.bucketInstanceId);\n\n return true;\n }\n\n removeBucketCrossTileIDs(zoom: string | number, removedBucket: TileLayerIndex) {\n for (const crossTileIDs of removedBucket.getCrossTileIDsLists()) {\n for (const crossTileID of crossTileIDs) {\n delete this.usedCrossTileIDs[zoom][crossTileID];\n }\n }\n }\n\n removeStaleBuckets(currentIDs: {\n [k in string | number]: boolean;\n }) {\n let tilesChanged = false;\n for (const z in this.indexes) {\n const zoomIndexes = this.indexes[z];\n for (const tileKey in zoomIndexes) {\n if (!currentIDs[zoomIndexes[tileKey].bucketInstanceId]) {\n this.removeBucketCrossTileIDs(z, zoomIndexes[tileKey]);\n delete zoomIndexes[tileKey];\n tilesChanged = true;\n }\n }\n }\n return tilesChanged;\n }\n}\n\nexport class CrossTileSymbolIndex {\n layerIndexes: {[layerId: string]: CrossTileSymbolLayerIndex};\n crossTileIDs: CrossTileIDs;\n maxBucketInstanceId: number;\n bucketsInCurrentPlacement: {[_: number]: boolean};\n\n constructor() {\n this.layerIndexes = {};\n this.crossTileIDs = new CrossTileIDs();\n this.maxBucketInstanceId = 0;\n this.bucketsInCurrentPlacement = {};\n }\n\n addLayer(styleLayer: StyleLayer, tiles: Array, lng: number) {\n let layerIndex = this.layerIndexes[styleLayer.id];\n if (layerIndex === undefined) {\n layerIndex = this.layerIndexes[styleLayer.id] = new CrossTileSymbolLayerIndex();\n }\n\n let symbolBucketsChanged = false;\n const currentBucketIDs = {};\n\n layerIndex.handleWrapJump(lng);\n\n for (const tile of tiles) {\n const symbolBucket = (tile.getBucket(styleLayer) as any as SymbolBucket);\n if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0])\n continue;\n\n if (!symbolBucket.bucketInstanceId) {\n symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId;\n }\n\n if (layerIndex.addBucket(tile.tileID, symbolBucket, this.crossTileIDs)) {\n symbolBucketsChanged = true;\n }\n currentBucketIDs[symbolBucket.bucketInstanceId] = true;\n }\n\n if (layerIndex.removeStaleBuckets(currentBucketIDs)) {\n symbolBucketsChanged = true;\n }\n\n return symbolBucketsChanged;\n }\n\n pruneUnusedLayers(usedLayers: Array) {\n const usedLayerMap = {};\n usedLayers.forEach((usedLayer) => {\n usedLayerMap[usedLayer] = true;\n });\n for (const layerId in this.layerIndexes) {\n if (!usedLayerMap[layerId]) {\n delete this.layerIndexes[layerId];\n }\n }\n }\n}\n","import {Event, ErrorEvent, Evented} from '../util/evented';\nimport {StyleLayer} from './style_layer';\nimport {createStyleLayer} from './create_style_layer';\nimport {loadSprite} from './load_sprite';\nimport {ImageManager} from '../render/image_manager';\nimport {GlyphManager} from '../render/glyph_manager';\nimport {Light} from './light';\nimport {LineAtlas} from '../render/line_atlas';\nimport {pick, clone, extend, deepEqual, filterObject, mapObject} from '../util/util';\nimport {coerceSpriteToArray} from '../util/style';\nimport {getJSON, getReferrer, makeRequest} from '../util/ajax';\nimport {ResourceType} from '../util/request_manager';\nimport {browser} from '../util/browser';\nimport {Dispatcher} from '../util/dispatcher';\nimport {validateStyle, emitValidationErrors as _emitValidationErrors} from './validate_style';\nimport {getSourceType, setSourceType, Source} from '../source/source';\nimport type {SourceClass} from '../source/source';\nimport {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions, queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures} from '../source/query_features';\nimport {SourceCache} from '../source/source_cache';\nimport {GeoJSONSource} from '../source/geojson_source';\nimport {latest as styleSpec, derefLayers as deref, emptyStyle, diff as diffStyles, operations as diffOperations} from '@maplibre/maplibre-gl-style-spec';\nimport {getGlobalWorkerPool} from '../util/global_worker_pool';\nimport {\n registerForPluginStateChange,\n evented as rtlTextPluginEvented,\n triggerPluginCompletionEvent\n} from '../source/rtl_text_plugin';\nimport {PauseablePlacement} from './pauseable_placement';\nimport {ZoomHistory} from './zoom_history';\nimport {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';\nimport {validateCustomStyleLayer} from './style_layer/custom_style_layer';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\n\n// We're skipping validation errors with the `source.canvas` identifier in order\n// to continue to allow canvas sources to be added at runtime/updated in\n// smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424):\nconst emitValidationErrors = (evented: Evented, errors?: ReadonlyArray<{\n message: string;\n identifier?: string;\n}> | null) =>\n _emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas'));\n\nimport type {Map} from '../ui/map';\nimport type {Transform} from '../geo/transform';\nimport type {StyleImage} from './style_image';\nimport type {StyleGlyph} from './style_glyph';\nimport type {Callback} from '../types/callback';\nimport type {EvaluationParameters} from './evaluation_parameters';\nimport type {Placement} from '../symbol/placement';\nimport type {Cancelable} from '../types/cancelable';\nimport type {RequestParameters, ResponseCallback} from '../util/ajax';\nimport type {\n LayerSpecification,\n FilterSpecification,\n StyleSpecification,\n LightSpecification,\n SourceSpecification,\n SpriteSpecification,\n} from '@maplibre/maplibre-gl-style-spec';\nimport type {CustomLayerInterface} from './style_layer/custom_style_layer';\nimport type {Validator} from './validate_style';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nconst supportedDiffOperations = pick(diffOperations, [\n 'addLayer',\n 'removeLayer',\n 'setPaintProperty',\n 'setLayoutProperty',\n 'setFilter',\n 'addSource',\n 'removeSource',\n 'setLayerZoomRange',\n 'setLight',\n 'setTransition',\n 'setGeoJSONSourceData',\n 'setGlyphs',\n 'setSprite',\n]);\n\nconst ignoredDiffOperations = pick(diffOperations, [\n 'setCenter',\n 'setZoom',\n 'setBearing',\n 'setPitch'\n]);\n\nconst empty = emptyStyle() as StyleSpecification;\n/**\n * A feature identifier that is bound to a source\n */\nexport type FeatureIdentifier = {\n /**\n * Unique id of the feature.\n */\n id?: string | number | undefined;\n /**\n * The id of the vector or GeoJSON source for the feature.\n */\n source: string;\n /**\n * *For vector tile sources, `sourceLayer` is required.*\n */\n sourceLayer?: string | undefined;\n};\n\n/**\n * The options object related to the {@link Map}'s style related methods\n */\nexport type StyleOptions = {\n /**\n * If false, style validation will be skipped. Useful in production environment.\n */\n validate?: boolean;\n /**\n * Defines a CSS\n * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.\n * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).\n * Set to `false`, to enable font settings from the map's style for these glyph ranges.\n * Forces a full update.\n */\n localIdeographFontFamily?: string;\n};\n\n/**\n * Supporting type to add validation to another style related type\n */\nexport type StyleSetterOptions = {\n /**\n * Whether to check if the filter conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function.\n */\n validate?: boolean;\n};\n\n/**\n * Part of {@link Map#setStyle} options, transformStyle is a convenience function that allows to modify a style after it is fetched but before it is committed to the map state\n * this function exposes previous and next styles, it can be commonly used to support a range of functionalities like:\n * when previous style carries certain 'state' that needs to be carried over to a new style gracefully\n * when a desired style is a certain combination of previous and incoming style\n * when an incoming style requires modification based on external state\n *\n * @param previousStyle - The current style.\n * @param nextStyle - The next style.\n * @returns resulting style that will to be applied to the map\n *\n * @example\n * ```ts\n * map.setStyle('https://demotiles.maplibre.org/style.json', {\n * transformStyle: (previousStyle, nextStyle) => ({\n * ...nextStyle,\n * sources: {\n * ...nextStyle.sources,\n * // copy a source from previous style\n * 'osm': previousStyle.sources.osm\n * },\n * layers: [\n * // background layer\n * nextStyle.layers[0],\n * // copy a layer from previous style\n * previousStyle.layers[0],\n * // other layers from the next style\n * ...nextStyle.layers.slice(1).map(layer => {\n * // hide the layers we don't need from demotiles style\n * if (layer.id.startsWith('geolines')) {\n * layer.layout = {...layer.layout || {}, visibility: 'none'};\n * // filter out US polygons\n * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {\n * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];\n * }\n * return layer;\n * })\n * ]\n * })\n * });\n * ```\n */\nexport type TransformStyleFunction = (previous: StyleSpecification | undefined, next: StyleSpecification) => StyleSpecification;\n\n/**\n * The options object related to the {@link Map}'s style related methods\n */\nexport type StyleSwapOptions = {\n /**\n * If false, force a 'full' update, removing the current style\n * and building the given one instead of attempting a diff-based update.\n */\n diff?: boolean;\n /**\n * TransformStyleFunction is a convenience function\n * that allows to modify a style after it is fetched but before it is committed to the map state. Refer to {@link TransformStyleFunction}.\n */\n transformStyle?: TransformStyleFunction;\n}\n\n/**\n * Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification}\n * or a {@link CustomLayerInterface}, a {@link LayerSpecification} with an embedded {@link SourceSpecification} can also be provided.\n */\nexport type AddLayerObject = LayerSpecification | (Omit & {source: SourceSpecification}) | CustomLayerInterface;\n\n/**\n * The Style base class\n */\nexport class Style extends Evented {\n map: Map;\n stylesheet: StyleSpecification;\n dispatcher: Dispatcher;\n imageManager: ImageManager;\n glyphManager: GlyphManager;\n lineAtlas: LineAtlas;\n light: Light;\n\n _request: Cancelable;\n _spriteRequest: Cancelable;\n _layers: {[_: string]: StyleLayer};\n _serializedLayers: {[_: string]: LayerSpecification};\n _order: Array;\n sourceCaches: {[_: string]: SourceCache};\n zoomHistory: ZoomHistory;\n _loaded: boolean;\n _rtlTextPluginCallback: (a: any) => any;\n _changed: boolean;\n _updatedSources: {[_: string]: 'clear' | 'reload'};\n _updatedLayers: {[_: string]: true};\n _removedLayers: {[_: string]: StyleLayer};\n _changedImages: {[_: string]: true};\n _glyphsDidChange: boolean;\n _updatedPaintProps: {[layer: string]: true};\n _layerOrderChanged: boolean;\n // image ids of images loaded from style's sprite\n _spritesImagesIds: {[spriteId: string]: string[]};\n // image ids of all images loaded (sprite + user)\n _availableImages: Array;\n\n crossTileSymbolIndex: CrossTileSymbolIndex;\n pauseablePlacement: PauseablePlacement;\n placement: Placement;\n z: number;\n\n static registerForPluginStateChange: typeof registerForPluginStateChange;\n\n constructor(map: Map, options: StyleOptions = {}) {\n super();\n\n this.map = map;\n this.dispatcher = new Dispatcher(getGlobalWorkerPool(), this, map._getMapId());\n this.imageManager = new ImageManager();\n this.imageManager.setEventedParent(this);\n this.glyphManager = new GlyphManager(map._requestManager, options.localIdeographFontFamily);\n this.lineAtlas = new LineAtlas(256, 512);\n this.crossTileSymbolIndex = new CrossTileSymbolIndex();\n\n this._spritesImagesIds = {};\n this._layers = {};\n\n this._order = [];\n this.sourceCaches = {};\n this.zoomHistory = new ZoomHistory();\n this._loaded = false;\n this._availableImages = [];\n\n this._resetUpdates();\n\n this.dispatcher.broadcast('setReferrer', getReferrer());\n\n const self = this;\n this._rtlTextPluginCallback = Style.registerForPluginStateChange((event) => {\n const state = {\n pluginStatus: event.pluginStatus,\n pluginURL: event.pluginURL\n };\n self.dispatcher.broadcast('syncRTLPluginState', state, (err, results) => {\n triggerPluginCompletionEvent(err);\n if (results) {\n const allComplete = results.every((elem) => elem);\n if (allComplete) {\n for (const id in self.sourceCaches) {\n const sourceType = self.sourceCaches[id].getSource().type;\n if (sourceType === 'vector' || sourceType === 'geojson') {\n // Non-vector sources don't have any symbols buckets to reload when the RTL text plugin loads\n // They also load more quickly, so they're more likely to have already displaying tiles\n // that would be unnecessarily booted by the plugin load event\n self.sourceCaches[id].reload(); // Should be a no-op if the plugin loads before any tiles load\n }\n }\n }\n }\n\n });\n });\n\n this.on('data', (event) => {\n if (event.dataType !== 'source' || event.sourceDataType !== 'metadata') {\n return;\n }\n\n const sourceCache = this.sourceCaches[event.sourceId];\n if (!sourceCache) {\n return;\n }\n\n const source = sourceCache.getSource();\n if (!source || !source.vectorLayerIds) {\n return;\n }\n\n for (const layerId in this._layers) {\n const layer = this._layers[layerId];\n if (layer.source === source.id) {\n this._validateLayer(layer);\n }\n }\n });\n }\n\n loadURL(url: string, options: StyleSwapOptions & StyleSetterOptions = {}, previousStyle?: StyleSpecification) {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n\n options.validate = typeof options.validate === 'boolean' ?\n options.validate : true;\n\n const request = this.map._requestManager.transformRequest(url, ResourceType.Style);\n this._request = getJSON(request, (error?: Error | null, json?: any | null) => {\n this._request = null;\n if (error) {\n this.fire(new ErrorEvent(error));\n } else if (json) {\n this._load(json, options, previousStyle);\n }\n });\n }\n\n loadJSON(json: StyleSpecification, options: StyleSetterOptions & StyleSwapOptions = {}, previousStyle?: StyleSpecification) {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n\n this._request = browser.frame(() => {\n this._request = null;\n options.validate = options.validate !== false;\n this._load(json, options, previousStyle);\n });\n }\n\n loadEmpty() {\n this.fire(new Event('dataloading', {dataType: 'style'}));\n this._load(empty, {validate: false});\n }\n\n _load(json: StyleSpecification, options: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification) {\n const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json;\n if (options.validate && emitValidationErrors(this, validateStyle(nextState))) {\n return;\n }\n\n this._loaded = true;\n this.stylesheet = nextState;\n\n for (const id in nextState.sources) {\n this.addSource(id, nextState.sources[id], {validate: false});\n }\n\n if (nextState.sprite) {\n this._loadSprite(nextState.sprite);\n } else {\n this.imageManager.setLoaded(true);\n }\n\n this.glyphManager.setURL(nextState.glyphs);\n this._createLayers();\n\n this.light = new Light(this.stylesheet.light);\n\n this.map.setTerrain(this.stylesheet.terrain ?? null);\n\n this.fire(new Event('data', {dataType: 'style'}));\n this.fire(new Event('style.load'));\n }\n\n private _createLayers() {\n const dereferencedLayers = deref(this.stylesheet.layers);\n\n // Broadcast layers to workers first, so that expensive style processing (createStyleLayer)\n // can happen in parallel on both main and worker threads.\n this.dispatcher.broadcast('setLayers', dereferencedLayers);\n\n this._order = dereferencedLayers.map((layer) => layer.id);\n this._layers = {};\n\n // reset serialization field, to be populated only when needed\n this._serializedLayers = null;\n for (const layer of dereferencedLayers) {\n const styledLayer = createStyleLayer(layer);\n styledLayer.setEventedParent(this, {layer: {id: layer.id}});\n this._layers[layer.id] = styledLayer;\n }\n }\n\n _loadSprite(sprite: SpriteSpecification, isUpdate: boolean = false, completion: (err: Error) => void = undefined) {\n this.imageManager.setLoaded(false);\n\n this._spriteRequest = loadSprite(sprite, this.map._requestManager, this.map.getPixelRatio(), (err, images) => {\n this._spriteRequest = null;\n if (err) {\n this.fire(new ErrorEvent(err));\n } else if (images) {\n for (const spriteId in images) {\n this._spritesImagesIds[spriteId] = [];\n\n // remove old sprite's loaded images (for the same sprite id) that are not in new sprite\n const imagesToRemove = this._spritesImagesIds[spriteId] ? this._spritesImagesIds[spriteId].filter(id => !(id in images)) : [];\n for (const id of imagesToRemove) {\n this.imageManager.removeImage(id);\n this._changedImages[id] = true;\n }\n\n for (const id in images[spriteId]) {\n // don't prefix images of the \"default\" sprite\n const imageId = spriteId === 'default' ? id : `${spriteId}:${id}`;\n // save all the sprite's images' ids to be able to delete them in `removeSprite`\n this._spritesImagesIds[spriteId].push(imageId);\n if (imageId in this.imageManager.images) {\n this.imageManager.updateImage(imageId, images[spriteId][id], false);\n } else {\n this.imageManager.addImage(imageId, images[spriteId][id]);\n }\n\n if (isUpdate) {\n this._changedImages[imageId] = true;\n }\n }\n }\n }\n\n this.imageManager.setLoaded(true);\n this._availableImages = this.imageManager.listImages();\n\n if (isUpdate) {\n this._changed = true;\n }\n\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n\n if (completion) {\n completion(err);\n }\n });\n }\n\n _unloadSprite() {\n for (const id of Object.values(this._spritesImagesIds).flat()) {\n this.imageManager.removeImage(id);\n this._changedImages[id] = true;\n }\n\n this._spritesImagesIds = {};\n this._availableImages = this.imageManager.listImages();\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n _validateLayer(layer: StyleLayer) {\n const sourceCache = this.sourceCaches[layer.source];\n if (!sourceCache) {\n return;\n }\n\n const sourceLayer = layer.sourceLayer;\n if (!sourceLayer) {\n return;\n }\n\n const source = sourceCache.getSource();\n if (source.type === 'geojson' || (source.vectorLayerIds && source.vectorLayerIds.indexOf(sourceLayer) === -1)) {\n this.fire(new ErrorEvent(new Error(\n `Source layer \"${sourceLayer}\" ` +\n `does not exist on source \"${source.id}\" ` +\n `as specified by style layer \"${layer.id}\".`\n )));\n }\n }\n\n loaded() {\n if (!this._loaded)\n return false;\n\n if (Object.keys(this._updatedSources).length)\n return false;\n\n for (const id in this.sourceCaches)\n if (!this.sourceCaches[id].loaded())\n return false;\n\n if (!this.imageManager.isLoaded())\n return false;\n\n return true;\n }\n\n /**\n * take an array of string IDs, and based on this._layers, generate an array of LayerSpecification\n * @param ids - an array of string IDs, for which serialized layers will be generated. If omitted, all serialized layers will be returned\n * @returns generated result\n */\n private _serializeByIds(ids?: Array): Array {\n\n const serializedLayersDictionary = this._serializedAllLayers();\n if (!ids || ids.length === 0) {\n return Object.values(serializedLayersDictionary);\n }\n\n const serializedLayers = [];\n for (const id of ids) {\n // this check will skip all custom layers\n if (serializedLayersDictionary[id]) {\n serializedLayers.push(serializedLayersDictionary[id]);\n }\n }\n\n return serializedLayers;\n }\n\n /**\n * Lazy initialization of this._serializedLayers dictionary and return it\n * @returns this._serializedLayers dictionary\n */\n private _serializedAllLayers(): {[_: string]: LayerSpecification} {\n let serializedLayers = this._serializedLayers;\n if (serializedLayers) {\n return serializedLayers;\n }\n\n serializedLayers = this._serializedLayers = {};\n const allLayerIds: string [] = Object.keys(this._layers);\n for (const layerId of allLayerIds) {\n const layer = this._layers[layerId];\n if (layer.type !== 'custom') {\n serializedLayers[layerId] = layer.serialize();\n }\n }\n\n return serializedLayers;\n }\n\n hasTransitions() {\n if (this.light && this.light.hasTransition()) {\n return true;\n }\n\n for (const id in this.sourceCaches) {\n if (this.sourceCaches[id].hasTransition()) {\n return true;\n }\n }\n\n for (const id in this._layers) {\n if (this._layers[id].hasTransition()) {\n return true;\n }\n }\n\n return false;\n }\n\n _checkLoaded() {\n if (!this._loaded) {\n throw new Error('Style is not done loading.');\n }\n }\n\n /**\n * @internal\n * Apply queued style updates in a batch and recalculate zoom-dependent paint properties.\n */\n update(parameters: EvaluationParameters) {\n if (!this._loaded) {\n return;\n }\n\n const changed = this._changed;\n if (this._changed) {\n const updatedIds = Object.keys(this._updatedLayers);\n const removedIds = Object.keys(this._removedLayers);\n\n if (updatedIds.length || removedIds.length) {\n this._updateWorkerLayers(updatedIds, removedIds);\n }\n for (const id in this._updatedSources) {\n const action = this._updatedSources[id];\n\n if (action === 'reload') {\n this._reloadSource(id);\n } else if (action === 'clear') {\n this._clearSource(id);\n } else {\n throw new Error(`Invalid action ${action}`);\n }\n }\n\n this._updateTilesForChangedImages();\n this._updateTilesForChangedGlyphs();\n\n for (const id in this._updatedPaintProps) {\n this._layers[id].updateTransitions(parameters);\n }\n\n this.light.updateTransitions(parameters);\n\n this._resetUpdates();\n }\n\n const sourcesUsedBefore = {};\n\n for (const sourceId in this.sourceCaches) {\n const sourceCache = this.sourceCaches[sourceId];\n sourcesUsedBefore[sourceId] = sourceCache.used;\n sourceCache.used = false;\n }\n\n for (const layerId of this._order) {\n const layer = this._layers[layerId];\n\n layer.recalculate(parameters, this._availableImages);\n if (!layer.isHidden(parameters.zoom) && layer.source) {\n this.sourceCaches[layer.source].used = true;\n }\n }\n\n for (const sourceId in sourcesUsedBefore) {\n const sourceCache = this.sourceCaches[sourceId];\n if (sourcesUsedBefore[sourceId] !== sourceCache.used) {\n sourceCache.fire(new Event('data', {sourceDataType: 'visibility', dataType: 'source', sourceId}));\n }\n }\n\n this.light.recalculate(parameters);\n this.z = parameters.zoom;\n\n if (changed) {\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n }\n\n /*\n * Apply any queued image changes.\n */\n _updateTilesForChangedImages() {\n const changedImages = Object.keys(this._changedImages);\n if (changedImages.length) {\n for (const name in this.sourceCaches) {\n this.sourceCaches[name].reloadTilesForDependencies(['icons', 'patterns'], changedImages);\n }\n this._changedImages = {};\n }\n }\n\n _updateTilesForChangedGlyphs() {\n if (this._glyphsDidChange) {\n for (const name in this.sourceCaches) {\n this.sourceCaches[name].reloadTilesForDependencies(['glyphs'], ['']);\n }\n this._glyphsDidChange = false;\n }\n }\n\n _updateWorkerLayers(updatedIds: Array, removedIds: Array) {\n this.dispatcher.broadcast('updateLayers', {\n layers: this._serializeByIds(updatedIds),\n removedIds\n });\n }\n\n _resetUpdates() {\n this._changed = false;\n\n this._updatedLayers = {};\n this._removedLayers = {};\n\n this._updatedSources = {};\n this._updatedPaintProps = {};\n\n this._changedImages = {};\n this._glyphsDidChange = false;\n }\n\n /**\n * Update this style's state to match the given style JSON, performing only\n * the necessary mutations.\n *\n * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec\n * diff algorithm produces an operation that is not supported.\n *\n * @returns true if any changes were made; false otherwise\n */\n setState(nextState: StyleSpecification, options: StyleSwapOptions = {}) {\n this._checkLoaded();\n\n const serializedStyle = this.serialize();\n nextState = options.transformStyle ? options.transformStyle(serializedStyle, nextState) : nextState;\n if (emitValidationErrors(this, validateStyle(nextState))) return false;\n\n nextState = clone(nextState);\n nextState.layers = deref(nextState.layers);\n\n const changes = diffStyles(serializedStyle, nextState)\n .filter(op => !(op.command in ignoredDiffOperations));\n\n if (changes.length === 0) {\n return false;\n }\n\n const unimplementedOps = changes.filter(op => !(op.command in supportedDiffOperations));\n if (unimplementedOps.length > 0) {\n throw new Error(`Unimplemented: ${unimplementedOps.map(op => op.command).join(', ')}.`);\n }\n\n for (const op of changes) {\n if (op.command === 'setTransition') {\n // `transition` is always read directly off of\n // `this.stylesheet`, which we update below\n continue;\n }\n (this as any)[op.command].apply(this, op.args);\n }\n\n this.stylesheet = nextState;\n\n // reset serialization field, to be populated only when needed\n this._serializedLayers = null;\n\n return true;\n }\n\n addImage(id: string, image: StyleImage) {\n if (this.getImage(id)) {\n return this.fire(new ErrorEvent(new Error(`An image named \"${id}\" already exists.`)));\n }\n this.imageManager.addImage(id, image);\n this._afterImageUpdated(id);\n }\n\n updateImage(id: string, image: StyleImage) {\n this.imageManager.updateImage(id, image);\n }\n\n getImage(id: string): StyleImage {\n return this.imageManager.getImage(id);\n }\n\n removeImage(id: string) {\n if (!this.getImage(id)) {\n return this.fire(new ErrorEvent(new Error(`An image named \"${id}\" does not exist.`)));\n }\n this.imageManager.removeImage(id);\n this._afterImageUpdated(id);\n }\n\n _afterImageUpdated(id: string) {\n this._availableImages = this.imageManager.listImages();\n this._changedImages[id] = true;\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n listImages() {\n this._checkLoaded();\n\n return this.imageManager.listImages();\n }\n\n addSource(id: string, source: SourceSpecification, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n if (this.sourceCaches[id] !== undefined) {\n throw new Error(`Source \"${id}\" already exists.`);\n }\n\n if (!source.type) {\n throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(source).join(', ')}.`);\n }\n\n const builtIns = ['vector', 'raster', 'geojson', 'video', 'image'];\n const shouldValidate = builtIns.indexOf(source.type) >= 0;\n if (shouldValidate && this._validate(validateStyle.source, `sources.${id}`, source, null, options)) return;\n\n if (this.map && this.map._collectResourceTiming) (source as any).collectResourceTiming = true;\n const sourceCache = this.sourceCaches[id] = new SourceCache(id, source, this.dispatcher);\n sourceCache.style = this;\n sourceCache.setEventedParent(this, () => ({\n isSourceLoaded: sourceCache.loaded(),\n source: sourceCache.serialize(),\n sourceId: id\n }));\n\n sourceCache.onAdd(this.map);\n this._changed = true;\n }\n\n /**\n * Remove a source from this stylesheet, given its id.\n * @param id - id of the source to remove\n * @throws if no source is found with the given ID\n * @returns `this`.\n */\n removeSource(id: string): this {\n this._checkLoaded();\n\n if (this.sourceCaches[id] === undefined) {\n throw new Error('There is no source with this ID');\n }\n for (const layerId in this._layers) {\n if (this._layers[layerId].source === id) {\n return this.fire(new ErrorEvent(new Error(`Source \"${id}\" cannot be removed while layer \"${layerId}\" is using it.`)));\n }\n }\n\n const sourceCache = this.sourceCaches[id];\n delete this.sourceCaches[id];\n delete this._updatedSources[id];\n sourceCache.fire(new Event('data', {sourceDataType: 'metadata', dataType: 'source', sourceId: id}));\n sourceCache.setEventedParent(null);\n sourceCache.onRemove(this.map);\n this._changed = true;\n }\n\n /**\n * Set the data of a GeoJSON source, given its id.\n * @param id - id of the source\n * @param data - GeoJSON source\n */\n setGeoJSONSourceData(id: string, data: GeoJSON.GeoJSON | string) {\n this._checkLoaded();\n\n if (this.sourceCaches[id] === undefined) throw new Error(`There is no source with this ID=${id}`);\n const geojsonSource: GeoJSONSource = (this.sourceCaches[id].getSource() as any);\n if (geojsonSource.type !== 'geojson') throw new Error(`geojsonSource.type is ${geojsonSource.type}, which is !== 'geojson`);\n\n geojsonSource.setData(data);\n this._changed = true;\n }\n\n /**\n * Get a source by ID.\n * @param id - ID of the desired source\n * @returns source\n */\n getSource(id: string): Source | undefined {\n return this.sourceCaches[id] && this.sourceCaches[id].getSource();\n }\n\n /**\n * Add a layer to the map style. The layer will be inserted before the layer with\n * ID `before`, or appended if `before` is omitted.\n * @param layerObject - The style layer to add.\n * @param before - ID of an existing layer to insert before\n * @param options - Style setter options.\n * @returns `this`.\n */\n addLayer(layerObject: AddLayerObject, before?: string, options: StyleSetterOptions = {}): this {\n this._checkLoaded();\n\n const id = layerObject.id;\n\n if (this.getLayer(id)) {\n this.fire(new ErrorEvent(new Error(`Layer \"${id}\" already exists on this map.`)));\n return;\n }\n\n let layer: ReturnType;\n if (layerObject.type === 'custom') {\n\n if (emitValidationErrors(this, validateCustomStyleLayer(layerObject))) return;\n\n layer = createStyleLayer(layerObject);\n\n } else {\n if ('source' in layerObject && typeof layerObject.source === 'object') {\n this.addSource(id, layerObject.source);\n layerObject = clone(layerObject);\n layerObject = extend(layerObject, {source: id});\n }\n\n // this layer is not in the style.layers array, so we pass an impossible array index\n if (this._validate(validateStyle.layer,\n `layers.${id}`, layerObject, {arrayIndex: -1}, options)) return;\n\n layer = createStyleLayer(layerObject as LayerSpecification | CustomLayerInterface);\n this._validateLayer(layer);\n\n layer.setEventedParent(this, {layer: {id}});\n }\n\n const index = before ? this._order.indexOf(before) : this._order.length;\n if (before && index === -1) {\n this.fire(new ErrorEvent(new Error(`Cannot add layer \"${id}\" before non-existing layer \"${before}\".`)));\n return;\n }\n\n this._order.splice(index, 0, id);\n this._layerOrderChanged = true;\n\n this._layers[id] = layer;\n\n if (this._removedLayers[id] && layer.source && layer.type !== 'custom') {\n // If, in the current batch, we have already removed this layer\n // and we are now re-adding it with a different `type`, then we\n // need to clear (rather than just reload) the underlying source's\n // tiles. Otherwise, tiles marked 'reloading' will have buckets /\n // buffers that are set up for the _previous_ version of this\n // layer, causing, e.g.:\n // https://github.com/mapbox/mapbox-gl-js/issues/3633\n const removed = this._removedLayers[id];\n delete this._removedLayers[id];\n if (removed.type !== layer.type) {\n this._updatedSources[layer.source] = 'clear';\n } else {\n this._updatedSources[layer.source] = 'reload';\n this.sourceCaches[layer.source].pause();\n }\n }\n this._updateLayer(layer);\n\n if (layer.onAdd) {\n layer.onAdd(this.map);\n }\n }\n\n /**\n * Moves a layer to a different z-position. The layer will be inserted before the layer with\n * ID `before`, or appended if `before` is omitted.\n * @param id - ID of the layer to move\n * @param before - ID of an existing layer to insert before\n */\n moveLayer(id: string, before?: string) {\n this._checkLoaded();\n this._changed = true;\n\n const layer = this._layers[id];\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be moved.`)));\n return;\n }\n\n if (id === before) {\n return;\n }\n\n const index = this._order.indexOf(id);\n this._order.splice(index, 1);\n\n const newIndex = before ? this._order.indexOf(before) : this._order.length;\n if (before && newIndex === -1) {\n this.fire(new ErrorEvent(new Error(`Cannot move layer \"${id}\" before non-existing layer \"${before}\".`)));\n return;\n }\n this._order.splice(newIndex, 0, id);\n\n this._layerOrderChanged = true;\n }\n\n /**\n * Remove the layer with the given id from the style.\n *\n * If no such layer exists, an `error` event is fired.\n *\n * @param id - id of the layer to remove\n * @event `error` - Fired if the layer does not exist\n */\n removeLayer(id: string) {\n this._checkLoaded();\n\n const layer = this._layers[id];\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot remove non-existing layer \"${id}\".`)));\n return;\n }\n\n layer.setEventedParent(null);\n\n const index = this._order.indexOf(id);\n this._order.splice(index, 1);\n\n this._layerOrderChanged = true;\n this._changed = true;\n this._removedLayers[id] = layer;\n delete this._layers[id];\n\n if (this._serializedLayers) {\n delete this._serializedLayers[id];\n }\n delete this._updatedLayers[id];\n delete this._updatedPaintProps[id];\n\n if (layer.onRemove) {\n layer.onRemove(this.map);\n }\n }\n\n /**\n * Return the style layer object with the given `id`.\n *\n * @param id - id of the desired layer\n * @returns a layer, if one with the given `id` exists\n */\n getLayer(id: string): StyleLayer | undefined {\n return this._layers[id];\n }\n\n /**\n * Return the ids of all layers currently in the style, including custom layers, in order.\n *\n * @returns ids of layers, in order\n */\n getLayersOrder(): string[] {\n return [...this._order];\n }\n\n /**\n * Checks if a specific layer is present within the style.\n *\n * @param id - the id of the desired layer\n * @returns a boolean specifying if the given layer is present\n */\n hasLayer(id: string): boolean {\n return id in this._layers;\n }\n\n setLayerZoomRange(layerId: string, minzoom?: number | null, maxzoom?: number | null) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (layer.minzoom === minzoom && layer.maxzoom === maxzoom) return;\n\n if (minzoom != null) {\n layer.minzoom = minzoom;\n }\n if (maxzoom != null) {\n layer.maxzoom = maxzoom;\n }\n this._updateLayer(layer);\n }\n\n setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot filter non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.filter, filter)) {\n return;\n }\n\n if (filter === null || filter === undefined) {\n layer.filter = undefined;\n this._updateLayer(layer);\n return;\n }\n\n if (this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter, null, options)) {\n return;\n }\n\n layer.filter = clone(filter);\n this._updateLayer(layer);\n }\n\n /**\n * Get a layer's filter object\n * @param layer - the layer to inspect\n * @returns the layer's filter, if any\n */\n getFilter(layer: string): FilterSpecification | void {\n return clone(this.getLayer(layer).filter);\n }\n\n setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.getLayoutProperty(name), value)) return;\n\n layer.setLayoutProperty(name, value, options);\n this._updateLayer(layer);\n }\n\n /**\n * Get a layout property's value from a given layer\n * @param layerId - the layer to inspect\n * @param name - the name of the layout property\n * @returns the property value\n */\n getLayoutProperty(layerId: string, name: string) {\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot get style of non-existing layer \"${layerId}\".`)));\n return;\n }\n\n return layer.getLayoutProperty(name);\n }\n\n setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const layer = this.getLayer(layerId);\n if (!layer) {\n this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer \"${layerId}\".`)));\n return;\n }\n\n if (deepEqual(layer.getPaintProperty(name), value)) return;\n\n const requiresRelayout = layer.setPaintProperty(name, value, options);\n if (requiresRelayout) {\n this._updateLayer(layer);\n }\n\n this._changed = true;\n this._updatedPaintProps[layerId] = true;\n }\n\n getPaintProperty(layer: string, name: string) {\n return this.getLayer(layer).getPaintProperty(name);\n }\n\n setFeatureState(target: FeatureIdentifier, state: any) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceLayer = target.sourceLayer;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n const sourceType = sourceCache.getSource().type;\n if (sourceType === 'geojson' && sourceLayer) {\n this.fire(new ErrorEvent(new Error('GeoJSON sources cannot have a sourceLayer parameter.')));\n return;\n }\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n if (target.id === undefined) {\n this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.')));\n }\n\n sourceCache.setFeatureState(sourceLayer, target.id, state);\n }\n\n removeFeatureState(target: FeatureIdentifier, key?: string) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n\n const sourceType = sourceCache.getSource().type;\n const sourceLayer = sourceType === 'vector' ? target.sourceLayer : undefined;\n\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n\n if (key && (typeof target.id !== 'string' && typeof target.id !== 'number')) {\n this.fire(new ErrorEvent(new Error('A feature id is required to remove its specific state property.')));\n return;\n }\n\n sourceCache.removeFeatureState(sourceLayer, target.id, key);\n }\n\n getFeatureState(target: FeatureIdentifier) {\n this._checkLoaded();\n const sourceId = target.source;\n const sourceLayer = target.sourceLayer;\n const sourceCache = this.sourceCaches[sourceId];\n\n if (sourceCache === undefined) {\n this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`)));\n return;\n }\n const sourceType = sourceCache.getSource().type;\n if (sourceType === 'vector' && !sourceLayer) {\n this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.')));\n return;\n }\n if (target.id === undefined) {\n this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.')));\n }\n\n return sourceCache.getFeatureState(sourceLayer, target.id);\n }\n\n getTransition() {\n return extend({duration: 300, delay: 0}, this.stylesheet && this.stylesheet.transition);\n }\n\n serialize(): StyleSpecification {\n // We return undefined before we're loaded, following the pattern of Map.getStyle() before\n // the Style object is initialized.\n // Internally, Style._validate() calls Style.serialize() but callers are responsible for\n // calling Style._checkLoaded() first if their validation requires the style to be loaded.\n if (!this._loaded) return;\n\n const sources = mapObject(this.sourceCaches, (source) => source.serialize());\n const layers = this._serializeByIds(this._order);\n const terrain = this.map.getTerrain() || undefined;\n const myStyleSheet = this.stylesheet;\n\n return filterObject({\n version: myStyleSheet.version,\n name: myStyleSheet.name,\n metadata: myStyleSheet.metadata,\n light: myStyleSheet.light,\n center: myStyleSheet.center,\n zoom: myStyleSheet.zoom,\n bearing: myStyleSheet.bearing,\n pitch: myStyleSheet.pitch,\n sprite: myStyleSheet.sprite,\n glyphs: myStyleSheet.glyphs,\n transition: myStyleSheet.transition,\n sources,\n layers,\n terrain\n },\n (value) => { return value !== undefined; });\n }\n\n _updateLayer(layer: StyleLayer) {\n this._updatedLayers[layer.id] = true;\n if (layer.source && !this._updatedSources[layer.source] &&\n //Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865)\n this.sourceCaches[layer.source].getSource().type !== 'raster') {\n this._updatedSources[layer.source] = 'reload';\n this.sourceCaches[layer.source].pause();\n }\n\n // upon updating, serilized layer dictionary should be reset.\n // When needed, it will be populated with the correct copy again.\n this._serializedLayers = null;\n this._changed = true;\n }\n\n _flattenAndSortRenderedFeatures(sourceResults: Array<{ [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> }>) {\n // Feature order is complicated.\n // The order between features in two 2D layers is always determined by layer order.\n // The order between features in two 3D layers is always determined by depth.\n // The order between a feature in a 2D layer and a 3D layer is tricky:\n // Most often layer order determines the feature order in this case. If\n // a line layer is above a extrusion layer the line feature will be rendered\n // above the extrusion. If the line layer is below the extrusion layer,\n // it will be rendered below it.\n //\n // There is a weird case though.\n // You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b\n // Each layer has a feature that overlaps the other features.\n // The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above.\n // The feature in line_layer is rendered above extrusion_layer_a.\n // This means that that the line_layer feature is above the extrusion_layer_b feature despite\n // it being in an earlier layer.\n\n const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion';\n\n const layerIndex = {};\n const features3D = [];\n for (let l = this._order.length - 1; l >= 0; l--) {\n const layerId = this._order[l];\n if (isLayer3D(layerId)) {\n layerIndex[layerId] = l;\n for (const sourceResult of sourceResults) {\n const layerFeatures = sourceResult[layerId];\n if (layerFeatures) {\n for (const featureWrapper of layerFeatures) {\n features3D.push(featureWrapper);\n }\n }\n }\n }\n }\n\n features3D.sort((a, b) => {\n return b.intersectionZ - a.intersectionZ;\n });\n\n const features = [];\n for (let l = this._order.length - 1; l >= 0; l--) {\n const layerId = this._order[l];\n\n if (isLayer3D(layerId)) {\n // add all 3D features that are in or above the current layer\n for (let i = features3D.length - 1; i >= 0; i--) {\n const topmost3D = features3D[i].feature;\n if (layerIndex[topmost3D.layer.id] < l) break;\n features.push(topmost3D);\n features3D.pop();\n }\n } else {\n for (const sourceResult of sourceResults) {\n const layerFeatures = sourceResult[layerId];\n if (layerFeatures) {\n for (const featureWrapper of layerFeatures) {\n features.push(featureWrapper.feature);\n }\n }\n }\n }\n }\n\n return features;\n }\n\n queryRenderedFeatures(queryGeometry: any, params: QueryRenderedFeaturesOptions, transform: Transform) {\n if (params && params.filter) {\n this._validate(validateStyle.filter, 'queryRenderedFeatures.filter', params.filter, null, params);\n }\n\n const includedSources = {};\n if (params && params.layers) {\n if (!Array.isArray(params.layers)) {\n this.fire(new ErrorEvent(new Error('parameters.layers must be an Array.')));\n return [];\n }\n for (const layerId of params.layers) {\n const layer = this._layers[layerId];\n if (!layer) {\n // this layer is not in the style.layers array\n this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be queried for features.`)));\n return [];\n }\n includedSources[layer.source] = true;\n }\n }\n\n const sourceResults = [];\n\n params.availableImages = this._availableImages;\n\n // LayerSpecification is serialized StyleLayer, and this casting is safe.\n const serializedLayers = this._serializedAllLayers() as {[_: string]: StyleLayer};\n\n for (const id in this.sourceCaches) {\n if (params.layers && !includedSources[id]) continue;\n sourceResults.push(\n queryRenderedFeatures(\n this.sourceCaches[id],\n this._layers,\n serializedLayers,\n queryGeometry,\n params,\n transform)\n );\n }\n\n if (this.placement) {\n // If a placement has run, query against its CollisionIndex\n // for symbol results, and treat it as an extra source to merge\n sourceResults.push(\n queryRenderedSymbols(\n this._layers,\n serializedLayers,\n this.sourceCaches,\n queryGeometry,\n params,\n this.placement.collisionIndex,\n this.placement.retainedQueryData)\n );\n }\n\n return this._flattenAndSortRenderedFeatures(sourceResults);\n }\n\n querySourceFeatures(\n sourceID: string,\n params?: QuerySourceFeatureOptions\n ) {\n if (params && params.filter) {\n this._validate(validateStyle.filter, 'querySourceFeatures.filter', params.filter, null, params);\n }\n const sourceCache = this.sourceCaches[sourceID];\n return sourceCache ? querySourceFeatures(sourceCache, params) : [];\n }\n\n addSourceType(name: string, SourceType: SourceClass, callback: Callback) {\n if (getSourceType(name)) {\n return callback(new Error(`A source type called \"${name}\" already exists.`));\n }\n\n setSourceType(name, SourceType);\n\n if (!SourceType.workerSourceURL) {\n return callback(null, null);\n }\n\n this.dispatcher.broadcast('loadWorkerSource', {\n name,\n url: SourceType.workerSourceURL\n }, callback);\n }\n\n getLight() {\n return this.light.getLight();\n }\n\n setLight(lightOptions: LightSpecification, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n\n const light = this.light.getLight();\n let _update = false;\n for (const key in lightOptions) {\n if (!deepEqual(lightOptions[key], light[key])) {\n _update = true;\n break;\n }\n }\n if (!_update) return;\n\n const parameters = {\n now: browser.now(),\n transition: extend({\n duration: 300,\n delay: 0\n }, this.stylesheet.transition)\n };\n\n this.light.setLight(lightOptions, options);\n this.light.updateTransitions(parameters);\n }\n\n _validate(validate: Validator, key: string, value: any, props: any, options: {\n validate?: boolean;\n } = {}) {\n if (options && options.validate === false) {\n return false;\n }\n return emitValidationErrors(this, validate.call(validateStyle, extend({\n key,\n style: this.serialize(),\n value,\n styleSpec\n }, props)));\n }\n\n _remove(mapRemoved: boolean = true) {\n if (this._request) {\n this._request.cancel();\n this._request = null;\n }\n if (this._spriteRequest) {\n this._spriteRequest.cancel();\n this._spriteRequest = null;\n }\n rtlTextPluginEvented.off('pluginStateChange', this._rtlTextPluginCallback);\n for (const layerId in this._layers) {\n const layer: StyleLayer = this._layers[layerId];\n layer.setEventedParent(null);\n }\n for (const id in this.sourceCaches) {\n const sourceCache = this.sourceCaches[id];\n sourceCache.setEventedParent(null);\n sourceCache.onRemove(this.map);\n }\n this.imageManager.setEventedParent(null);\n this.setEventedParent(null);\n this.dispatcher.remove(mapRemoved);\n }\n\n _clearSource(id: string) {\n this.sourceCaches[id].clearTiles();\n }\n\n _reloadSource(id: string) {\n this.sourceCaches[id].resume();\n this.sourceCaches[id].reload();\n }\n\n _updateSources(transform: Transform) {\n for (const id in this.sourceCaches) {\n this.sourceCaches[id].update(transform, this.map.terrain);\n }\n }\n\n _generateCollisionBoxes() {\n for (const id in this.sourceCaches) {\n this._reloadSource(id);\n }\n }\n\n _updatePlacement(transform: Transform, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, forceFullPlacement: boolean = false) {\n let symbolBucketsChanged = false;\n let placementCommitted = false;\n\n const layerTiles = {};\n\n for (const layerID of this._order) {\n const styleLayer = this._layers[layerID];\n if (styleLayer.type !== 'symbol') continue;\n\n if (!layerTiles[styleLayer.source]) {\n const sourceCache = this.sourceCaches[styleLayer.source];\n layerTiles[styleLayer.source] = sourceCache.getRenderableIds(true)\n .map((id) => sourceCache.getTileByID(id))\n .sort((a, b) => (b.tileID.overscaledZ - a.tileID.overscaledZ) || (a.tileID.isLessThan(b.tileID) ? -1 : 1));\n }\n\n const layerBucketsChanged = this.crossTileSymbolIndex.addLayer(styleLayer, layerTiles[styleLayer.source], transform.center.lng);\n symbolBucketsChanged = symbolBucketsChanged || layerBucketsChanged;\n }\n this.crossTileSymbolIndex.pruneUnusedLayers(this._order);\n\n // Anything that changes our \"in progress\" layer and tile indices requires us\n // to start over. When we start over, we do a full placement instead of incremental\n // to prevent starvation.\n // We need to restart placement to keep layer indices in sync.\n // Also force full placement when fadeDuration === 0 to ensure that newly loaded\n // tiles will fully display symbols in their first frame\n forceFullPlacement = forceFullPlacement || this._layerOrderChanged || fadeDuration === 0;\n\n if (forceFullPlacement || !this.pauseablePlacement || (this.pauseablePlacement.isDone() && !this.placement.stillRecent(browser.now(), transform.zoom))) {\n this.pauseablePlacement = new PauseablePlacement(transform, this.map.terrain, this._order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, this.placement);\n this._layerOrderChanged = false;\n }\n\n if (this.pauseablePlacement.isDone()) {\n // the last placement finished running, but the next one hasn’t\n // started yet because of the `stillRecent` check immediately\n // above, so mark it stale to ensure that we request another\n // render frame\n this.placement.setStale();\n } else {\n this.pauseablePlacement.continuePlacement(this._order, this._layers, layerTiles);\n\n if (this.pauseablePlacement.isDone()) {\n this.placement = this.pauseablePlacement.commit(browser.now());\n placementCommitted = true;\n }\n\n if (symbolBucketsChanged) {\n // since the placement gets split over multiple frames it is possible\n // these buckets were processed before they were changed and so the\n // placement is already stale while it is in progress\n this.pauseablePlacement.placement.setStale();\n }\n }\n\n if (placementCommitted || symbolBucketsChanged) {\n for (const layerID of this._order) {\n const styleLayer = this._layers[layerID];\n if (styleLayer.type !== 'symbol') continue;\n this.placement.updateLayerOpacities(styleLayer, layerTiles[styleLayer.source]);\n }\n }\n\n // needsRender is false when we have just finished a placement that didn't change the visibility of any symbols\n const needsRerender = !this.pauseablePlacement.isDone() || this.placement.hasTransitions(browser.now());\n return needsRerender;\n }\n\n _releaseSymbolFadeTiles() {\n for (const id in this.sourceCaches) {\n this.sourceCaches[id].releaseSymbolFadeTiles();\n }\n }\n\n // Callbacks from web workers\n\n getImages(\n mapId: string,\n params: {\n icons: Array;\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: StyleImage}>\n ) {\n this.imageManager.getImages(params.icons, callback);\n\n // Apply queued image changes before setting the tile's dependencies so that the tile\n // is not reloaded unnecessarily. Without this forced update the reload could happen in cases\n // like this one:\n // - icons contains \"my-image\"\n // - imageManager.getImages(...) triggers `onstyleimagemissing`\n // - the user adds \"my-image\" within the callback\n // - addImage adds \"my-image\" to this._changedImages\n // - the next frame triggers a reload of this tile even though it already has the latest version\n this._updateTilesForChangedImages();\n\n const sourceCache = this.sourceCaches[params.source];\n if (sourceCache) {\n sourceCache.setDependencies(params.tileID.key, params.type, params.icons);\n }\n }\n\n getGlyphs(\n mapId: string,\n params: {\n stacks: {[_: string]: Array};\n source: string;\n tileID: OverscaledTileID;\n type: string;\n },\n callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>\n ) {\n this.glyphManager.getGlyphs(params.stacks, callback);\n const sourceCache = this.sourceCaches[params.source];\n if (sourceCache) {\n // we are not setting stacks as dependencies since for now\n // we just need to know which tiles have glyph dependencies\n sourceCache.setDependencies(params.tileID.key, params.type, ['']);\n }\n }\n\n getResource(mapId: string, params: RequestParameters, callback: ResponseCallback): Cancelable {\n return makeRequest(params, callback);\n }\n\n getGlyphsUrl() {\n return this.stylesheet.glyphs || null;\n }\n\n setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}) {\n this._checkLoaded();\n if (glyphsUrl && this._validate(validateStyle.glyphs, 'glyphs', glyphsUrl, null, options)) {\n return;\n }\n\n this._glyphsDidChange = true;\n this.stylesheet.glyphs = glyphsUrl;\n this.glyphManager.entries = {};\n this.glyphManager.setURL(glyphsUrl);\n }\n\n /**\n * Add a sprite.\n *\n * @param id - The id of the desired sprite\n * @param url - The url to load the desired sprite from\n * @param options - The style setter options\n * @param completion - The completion handler\n */\n addSprite(id: string, url: string, options: StyleSetterOptions = {}, completion?: (err: Error) => void) {\n this._checkLoaded();\n\n const spriteToAdd = [{id, url}];\n const updatedSprite = [\n ...coerceSpriteToArray(this.stylesheet.sprite),\n ...spriteToAdd\n ];\n\n if (this._validate(validateStyle.sprite, 'sprite', updatedSprite, null, options)) return;\n\n this.stylesheet.sprite = updatedSprite;\n this._loadSprite(spriteToAdd, true, completion);\n }\n\n /**\n * Remove a sprite by its id. When the last sprite is removed, the whole `this.stylesheet.sprite` object becomes\n * `undefined`. This falsy `undefined` value later prevents attempts to load the sprite when it's absent.\n *\n * @param id - the id of the sprite to remove\n */\n removeSprite(id: string) {\n this._checkLoaded();\n\n const internalSpriteRepresentation = coerceSpriteToArray(this.stylesheet.sprite);\n\n if (!internalSpriteRepresentation.find(sprite => sprite.id === id)) {\n this.fire(new ErrorEvent(new Error(`Sprite \"${id}\" doesn't exists on this map.`)));\n return;\n }\n\n if (this._spritesImagesIds[id]) {\n for (const imageId of this._spritesImagesIds[id]) {\n this.imageManager.removeImage(imageId);\n this._changedImages[imageId] = true;\n }\n }\n\n internalSpriteRepresentation.splice(internalSpriteRepresentation.findIndex(sprite => sprite.id === id), 1);\n this.stylesheet.sprite = internalSpriteRepresentation.length > 0 ? internalSpriteRepresentation : undefined;\n\n delete this._spritesImagesIds[id];\n this._availableImages = this.imageManager.listImages();\n this._changed = true;\n this.dispatcher.broadcast('setImages', this._availableImages);\n this.fire(new Event('data', {dataType: 'style'}));\n }\n\n /**\n * Get the current sprite value.\n *\n * @returns empty array when no sprite is set; id-url pairs otherwise\n */\n getSprite() {\n return coerceSpriteToArray(this.stylesheet.sprite);\n }\n\n /**\n * Set a new value for the style's sprite.\n *\n * @param sprite - new sprite value\n * @param options - style setter options\n * @param completion - the completion handler\n */\n setSprite(sprite: SpriteSpecification, options: StyleSetterOptions = {}, completion?: (err: Error) => void) {\n this._checkLoaded();\n\n if (sprite && this._validate(validateStyle.sprite, 'sprite', sprite, null, options)) {\n return;\n }\n\n this.stylesheet.sprite = sprite;\n\n if (sprite) {\n this._loadSprite(sprite, true, completion);\n } else {\n this._unloadSprite();\n if (completion) {\n completion(null);\n }\n }\n }\n}\n\nStyle.registerForPluginStateChange = registerForPluginStateChange;\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos', type: 'Int16', components: 2}\n]);\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}';\n","\n// Disable Flow annotations here because Flow doesn't support importing GLSL files\n\nimport preludeFrag from './_prelude.fragment.glsl.g';\nimport preludeVert from './_prelude.vertex.glsl.g';\nimport backgroundFrag from './background.fragment.glsl.g';\nimport backgroundVert from './background.vertex.glsl.g';\nimport backgroundPatternFrag from './background_pattern.fragment.glsl.g';\nimport backgroundPatternVert from './background_pattern.vertex.glsl.g';\nimport circleFrag from './circle.fragment.glsl.g';\nimport circleVert from './circle.vertex.glsl.g';\nimport clippingMaskFrag from './clipping_mask.fragment.glsl.g';\nimport clippingMaskVert from './clipping_mask.vertex.glsl.g';\nimport heatmapFrag from './heatmap.fragment.glsl.g';\nimport heatmapVert from './heatmap.vertex.glsl.g';\nimport heatmapTextureFrag from './heatmap_texture.fragment.glsl.g';\nimport heatmapTextureVert from './heatmap_texture.vertex.glsl.g';\nimport collisionBoxFrag from './collision_box.fragment.glsl.g';\nimport collisionBoxVert from './collision_box.vertex.glsl.g';\nimport collisionCircleFrag from './collision_circle.fragment.glsl.g';\nimport collisionCircleVert from './collision_circle.vertex.glsl.g';\nimport debugFrag from './debug.fragment.glsl.g';\nimport debugVert from './debug.vertex.glsl.g';\nimport fillFrag from './fill.fragment.glsl.g';\nimport fillVert from './fill.vertex.glsl.g';\nimport fillOutlineFrag from './fill_outline.fragment.glsl.g';\nimport fillOutlineVert from './fill_outline.vertex.glsl.g';\nimport fillOutlinePatternFrag from './fill_outline_pattern.fragment.glsl.g';\nimport fillOutlinePatternVert from './fill_outline_pattern.vertex.glsl.g';\nimport fillPatternFrag from './fill_pattern.fragment.glsl.g';\nimport fillPatternVert from './fill_pattern.vertex.glsl.g';\nimport fillExtrusionFrag from './fill_extrusion.fragment.glsl.g';\nimport fillExtrusionVert from './fill_extrusion.vertex.glsl.g';\nimport fillExtrusionPatternFrag from './fill_extrusion_pattern.fragment.glsl.g';\nimport fillExtrusionPatternVert from './fill_extrusion_pattern.vertex.glsl.g';\nimport hillshadePrepareFrag from './hillshade_prepare.fragment.glsl.g';\nimport hillshadePrepareVert from './hillshade_prepare.vertex.glsl.g';\nimport hillshadeFrag from './hillshade.fragment.glsl.g';\nimport hillshadeVert from './hillshade.vertex.glsl.g';\nimport lineFrag from './line.fragment.glsl.g';\nimport lineVert from './line.vertex.glsl.g';\nimport lineGradientFrag from './line_gradient.fragment.glsl.g';\nimport lineGradientVert from './line_gradient.vertex.glsl.g';\nimport linePatternFrag from './line_pattern.fragment.glsl.g';\nimport linePatternVert from './line_pattern.vertex.glsl.g';\nimport lineSDFFrag from './line_sdf.fragment.glsl.g';\nimport lineSDFVert from './line_sdf.vertex.glsl.g';\nimport rasterFrag from './raster.fragment.glsl.g';\nimport rasterVert from './raster.vertex.glsl.g';\nimport symbolIconFrag from './symbol_icon.fragment.glsl.g';\nimport symbolIconVert from './symbol_icon.vertex.glsl.g';\nimport symbolSDFFrag from './symbol_sdf.fragment.glsl.g';\nimport symbolSDFVert from './symbol_sdf.vertex.glsl.g';\nimport symbolTextAndIconFrag from './symbol_text_and_icon.fragment.glsl.g';\nimport symbolTextAndIconVert from './symbol_text_and_icon.vertex.glsl.g';\nimport terrainDepthFrag from './terrain_depth.fragment.glsl.g';\nimport terrainCoordsFrag from './terrain_coords.fragment.glsl.g';\nimport terrainFrag from './terrain.fragment.glsl.g';\nimport terrainVert from './terrain.vertex.glsl.g';\n\nexport const shaders = {\n prelude: compile(preludeFrag, preludeVert),\n background: compile(backgroundFrag, backgroundVert),\n backgroundPattern: compile(backgroundPatternFrag, backgroundPatternVert),\n circle: compile(circleFrag, circleVert),\n clippingMask: compile(clippingMaskFrag, clippingMaskVert),\n heatmap: compile(heatmapFrag, heatmapVert),\n heatmapTexture: compile(heatmapTextureFrag, heatmapTextureVert),\n collisionBox: compile(collisionBoxFrag, collisionBoxVert),\n collisionCircle: compile(collisionCircleFrag, collisionCircleVert),\n debug: compile(debugFrag, debugVert),\n fill: compile(fillFrag, fillVert),\n fillOutline: compile(fillOutlineFrag, fillOutlineVert),\n fillOutlinePattern: compile(fillOutlinePatternFrag, fillOutlinePatternVert),\n fillPattern: compile(fillPatternFrag, fillPatternVert),\n fillExtrusion: compile(fillExtrusionFrag, fillExtrusionVert),\n fillExtrusionPattern: compile(fillExtrusionPatternFrag, fillExtrusionPatternVert),\n hillshadePrepare: compile(hillshadePrepareFrag, hillshadePrepareVert),\n hillshade: compile(hillshadeFrag, hillshadeVert),\n line: compile(lineFrag, lineVert),\n lineGradient: compile(lineGradientFrag, lineGradientVert),\n linePattern: compile(linePatternFrag, linePatternVert),\n lineSDF: compile(lineSDFFrag, lineSDFVert),\n raster: compile(rasterFrag, rasterVert),\n symbolIcon: compile(symbolIconFrag, symbolIconVert),\n symbolSDF: compile(symbolSDFFrag, symbolSDFVert),\n symbolTextAndIcon: compile(symbolTextAndIconFrag, symbolTextAndIconVert),\n terrain: compile(terrainFrag, terrainVert),\n terrainDepth: compile(terrainDepthFrag, terrainVert),\n terrainCoords: compile(terrainCoordsFrag, terrainVert)\n};\n\n// Expand #pragmas to #ifdefs.\n\nfunction compile(fragmentSource, vertexSource) {\n const re = /#pragma mapbox: ([\\w]+) ([\\w]+) ([\\w]+) ([\\w]+)/g;\n\n const staticAttributes = vertexSource.match(/attribute ([\\w]+) ([\\w]+)/g);\n const fragmentUniforms = fragmentSource.match(/uniform ([\\w]+) ([\\w]+)([\\s]*)([\\w]*)/g);\n const vertexUniforms = vertexSource.match(/uniform ([\\w]+) ([\\w]+)([\\s]*)([\\w]*)/g);\n const staticUniforms = vertexUniforms ? vertexUniforms.concat(fragmentUniforms) : fragmentUniforms;\n\n const fragmentPragmas = {};\n\n fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => {\n fragmentPragmas[name] = true;\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nvarying ${precision} ${type} ${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n return `\n#ifdef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n });\n\n vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => {\n const attrType = type === 'float' ? 'vec2' : 'vec4';\n const unpackType = name.match(/color/) ? 'color' : attrType;\n\n if (fragmentPragmas[name]) {\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nuniform lowp float u_${name}_t;\nattribute ${precision} ${attrType} a_${name};\nvarying ${precision} ${type} ${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n if (unpackType === 'vec4') {\n // vec4 attributes are only used for cross-faded properties, and are not packed\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${name} = a_${name};\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n } else {\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n }\n } else {\n if (operation === 'define') {\n return `\n#ifndef HAS_UNIFORM_u_${name}\nuniform lowp float u_${name}_t;\nattribute ${precision} ${attrType} a_${name};\n#else\nuniform ${precision} ${type} u_${name};\n#endif\n`;\n } else /* if (operation === 'initialize') */ {\n if (unpackType === 'vec4') {\n // vec4 attributes are only used for cross-faded properties, and are not packed\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = a_${name};\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n } else /* */ {\n return `\n#ifndef HAS_UNIFORM_u_${name}\n ${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);\n#else\n ${precision} ${type} ${name} = u_${name};\n#endif\n`;\n }\n }\n }\n });\n\n return {fragmentSource, vertexSource, staticAttributes, staticUniforms};\n}\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision mediump float;\\n#else\\n#if !defined(lowp)\\n#define lowp\\n#endif\\n#if !defined(mediump)\\n#define mediump\\n#endif\\n#if !defined(highp)\\n#define highp\\n#endif\\n#endif\\n';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#else\\n#if !defined(lowp)\\n#define lowp\\n#endif\\n#if !defined(mediump)\\n#define mediump\\n#endif\\n#if !defined(highp)\\n#define highp\\n#endif\\n#endif\\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\\n#ifdef TERRAIN3D\\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\\n#endif\\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\\n#ifdef TERRAIN3D\\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\\n#else\\nreturn 1.0;\\n#endif\\n}float calculate_visibility(vec4 pos) {\\n#ifdef TERRAIN3D\\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\\n#else\\nreturn 1.0;\\n#endif\\n}float ele(vec2 pos) {\\n#ifdef TERRAIN3D\\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\\n#else\\nreturn 0.0;\\n#endif\\n}float get_elevation(vec2 pos) {\\n#ifdef TERRAIN3D\\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\\n#else\\nreturn 0.0;\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec3 v_data;varying float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvoid main(void) {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'void main() {gl_FragColor=vec4(1.0);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform highp float u_intensity;varying vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main() {\\n#pragma mapbox: initialize highp float weight\\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#pragma mapbox: define mediump float radius\\nconst highp float ZERO=1.0/255.0/16.0;\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main(void) {\\n#pragma mapbox: initialize highp float weight\\n#pragma mapbox: initialize mediump float radius\\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(0.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_FragColor=color*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying vec4 v_color;void main() {gl_FragColor=v_color;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\\n#ifdef TERRAIN3D\\nattribute vec2 a_centroid;\\n#endif\\nvarying vec4 v_color;\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\n#pragma mapbox: define highp vec4 color\\nvoid main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\n#pragma mapbox: initialize highp vec4 color\\nvec3 normal=a_normal_ed.xyz;\\n#ifdef TERRAIN3D\\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\\n#else\\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\\n#endif\\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\\n#pragma mapbox: define lowp float base\\n#pragma mapbox: define lowp float height\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float base\\n#pragma mapbox: initialize lowp float height\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\\n#ifdef TERRAIN3D\\nattribute vec2 a_centroid;\\n#endif\\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\\n#pragma mapbox: define lowp float base\\n#pragma mapbox: define lowp float height\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float base\\n#pragma mapbox: initialize lowp float height\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\\n#ifdef TERRAIN3D\\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\\n#else\\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\\n#endif\\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\\n? a_pos\\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\\n#define PI 3.141592653589793\\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#ifdef GL_ES\\nprecision highp float;\\n#endif\\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\n#define LINE_DISTANCE_SCALE 2.0\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\n#pragma mapbox: define lowp vec4 pattern_from\\n#pragma mapbox: define lowp vec4 pattern_to\\n#pragma mapbox: define lowp float pixel_ratio_from\\n#pragma mapbox: define lowp float pixel_ratio_to\\nvoid main() {\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\n#pragma mapbox: initialize mediump vec4 pattern_from\\n#pragma mapbox: initialize mediump vec4 pattern_to\\n#pragma mapbox: initialize lowp float pixel_ratio_from\\n#pragma mapbox: initialize lowp float pixel_ratio_to\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '\\n#define scale 0.015873016\\n#define LINE_DISTANCE_SCALE 2.0\\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float floorwidth\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float floorwidth\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\\n#ifdef TERRAIN3D\\nv_gamma_scale=1.0;\\n#else\\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\\n#endif\\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#define SDF_PX 8.0\\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default '#define SDF_PX 8.0\\n#define SDF 1.0\\n#define ICON 0.0\\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\ngl_FragColor=vec4(1.0);\\n#endif\\n}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}';\n","// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.\nexport default 'precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}';\n","\nimport type {Program} from './program';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {Context} from '../gl/context';\n\n/**\n * @internal\n * A vertex array object used to pass data to the webgl code\n */\nexport class VertexArrayObject {\n context: Context;\n boundProgram: Program;\n boundLayoutVertexBuffer: VertexBuffer;\n boundPaintVertexBuffers: Array;\n boundIndexBuffer: IndexBuffer;\n boundVertexOffset: number;\n boundDynamicVertexBuffer: VertexBuffer;\n boundDynamicVertexBuffer2: VertexBuffer;\n boundDynamicVertexBuffer3: VertexBuffer;\n vao: any;\n\n constructor() {\n this.boundProgram = null;\n this.boundLayoutVertexBuffer = null;\n this.boundPaintVertexBuffers = [];\n this.boundIndexBuffer = null;\n this.boundVertexOffset = null;\n this.boundDynamicVertexBuffer = null;\n this.vao = null;\n }\n\n bind(context: Context,\n program: Program,\n layoutVertexBuffer: VertexBuffer,\n paintVertexBuffers: Array,\n indexBuffer?: IndexBuffer | null,\n vertexOffset?: number | null,\n dynamicVertexBuffer?: VertexBuffer | null,\n dynamicVertexBuffer2?: VertexBuffer | null,\n dynamicVertexBuffer3?: VertexBuffer | null) {\n\n this.context = context;\n\n let paintBuffersDiffer = this.boundPaintVertexBuffers.length !== paintVertexBuffers.length;\n for (let i = 0; !paintBuffersDiffer && i < paintVertexBuffers.length; i++) {\n if (this.boundPaintVertexBuffers[i] !== paintVertexBuffers[i]) {\n paintBuffersDiffer = true;\n }\n }\n\n const isFreshBindRequired = (\n !this.vao ||\n this.boundProgram !== program ||\n this.boundLayoutVertexBuffer !== layoutVertexBuffer ||\n paintBuffersDiffer ||\n this.boundIndexBuffer !== indexBuffer ||\n this.boundVertexOffset !== vertexOffset ||\n this.boundDynamicVertexBuffer !== dynamicVertexBuffer ||\n this.boundDynamicVertexBuffer2 !== dynamicVertexBuffer2 ||\n this.boundDynamicVertexBuffer3 !== dynamicVertexBuffer3\n );\n\n if (isFreshBindRequired) {\n this.freshBind(program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3);\n } else {\n context.bindVertexArray.set(this.vao);\n\n if (dynamicVertexBuffer) {\n // The buffer may have been updated. Rebind to upload data.\n dynamicVertexBuffer.bind();\n }\n\n if (indexBuffer && indexBuffer.dynamicDraw) {\n indexBuffer.bind();\n }\n\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.bind();\n }\n\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.bind();\n }\n }\n }\n\n freshBind(program: Program,\n layoutVertexBuffer: VertexBuffer,\n paintVertexBuffers: Array,\n indexBuffer?: IndexBuffer | null,\n vertexOffset?: number | null,\n dynamicVertexBuffer?: VertexBuffer | null,\n dynamicVertexBuffer2?: VertexBuffer | null,\n dynamicVertexBuffer3?: VertexBuffer | null) {\n\n const numNextAttributes = program.numAttributes;\n\n const context = this.context;\n const gl = context.gl;\n\n if (this.vao) this.destroy();\n this.vao = context.createVertexArray();\n context.bindVertexArray.set(this.vao);\n\n // store the arguments so that we can verify them when the vao is bound again\n this.boundProgram = program;\n this.boundLayoutVertexBuffer = layoutVertexBuffer;\n this.boundPaintVertexBuffers = paintVertexBuffers;\n this.boundIndexBuffer = indexBuffer;\n this.boundVertexOffset = vertexOffset;\n this.boundDynamicVertexBuffer = dynamicVertexBuffer;\n this.boundDynamicVertexBuffer2 = dynamicVertexBuffer2;\n this.boundDynamicVertexBuffer3 = dynamicVertexBuffer3;\n\n layoutVertexBuffer.enableAttributes(gl, program);\n for (const vertexBuffer of paintVertexBuffers) {\n vertexBuffer.enableAttributes(gl, program);\n }\n\n if (dynamicVertexBuffer) {\n dynamicVertexBuffer.enableAttributes(gl, program);\n }\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.enableAttributes(gl, program);\n }\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.enableAttributes(gl, program);\n }\n\n layoutVertexBuffer.bind();\n layoutVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n for (const vertexBuffer of paintVertexBuffers) {\n vertexBuffer.bind();\n vertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n }\n\n if (dynamicVertexBuffer) {\n dynamicVertexBuffer.bind();\n dynamicVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset);\n }\n if (indexBuffer) {\n indexBuffer.bind();\n }\n if (dynamicVertexBuffer2) {\n dynamicVertexBuffer2.bind();\n dynamicVertexBuffer2.setVertexAttribPointers(gl, program, vertexOffset);\n }\n if (dynamicVertexBuffer3) {\n dynamicVertexBuffer3.bind();\n dynamicVertexBuffer3.setVertexAttribPointers(gl, program, vertexOffset);\n }\n\n context.currentNumAttributes = numNextAttributes;\n }\n\n destroy() {\n if (this.vao) {\n this.context.deleteVertexArray(this.vao);\n this.vao = null;\n }\n }\n}\n","import {shaders} from '../shaders/shaders';\nimport {ProgramConfiguration} from '../data/program_configuration';\nimport {VertexArrayObject} from './vertex_array_object';\nimport {Context} from '../gl/context';\n\nimport type {SegmentVector} from '../data/segment';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {DepthMode} from '../gl/depth_mode';\nimport type {StencilMode} from '../gl/stencil_mode';\nimport type {ColorMode} from '../gl/color_mode';\nimport type {CullFaceMode} from '../gl/cull_face_mode';\nimport type {UniformBindings, UniformValues, UniformLocations} from './uniform_binding';\nimport type {BinderUniform} from '../data/program_configuration';\nimport {terrainPreludeUniforms, TerrainPreludeUniformsType} from './program/terrain_program';\nimport type {TerrainData} from '../render/terrain';\nimport {Terrain} from '../render/terrain';\n\nexport type DrawMode = WebGLRenderingContextBase['LINES'] | WebGLRenderingContextBase['TRIANGLES'] | WebGL2RenderingContext['LINE_STRIP'];\n\nfunction getTokenizedAttributesAndUniforms(array: Array): Array {\n const result = [];\n\n for (let i = 0; i < array.length; i++) {\n if (array[i] === null) continue;\n const token = array[i].split(' ');\n result.push(token.pop());\n }\n return result;\n}\n\n/**\n * @internal\n * A webgl program to execute in the GPU space\n */\nexport class Program {\n program: WebGLProgram;\n attributes: {[_: string]: number};\n numAttributes: number;\n fixedUniforms: Us;\n terrainUniforms: TerrainPreludeUniformsType;\n binderUniforms: Array;\n failedToCreate: boolean;\n\n constructor(context: Context,\n source: {\n fragmentSource: string;\n vertexSource: string;\n staticAttributes: Array;\n staticUniforms: Array;\n },\n configuration: ProgramConfiguration,\n fixedUniforms: (b: Context, a: UniformLocations) => Us,\n showOverdrawInspector: boolean,\n terrain: Terrain) {\n\n const gl = context.gl;\n this.program = gl.createProgram();\n\n const staticAttrInfo = getTokenizedAttributesAndUniforms(source.staticAttributes);\n const dynamicAttrInfo = configuration ? configuration.getBinderAttributes() : [];\n const allAttrInfo = staticAttrInfo.concat(dynamicAttrInfo);\n\n const preludeUniformsInfo = shaders.prelude.staticUniforms ? getTokenizedAttributesAndUniforms(shaders.prelude.staticUniforms) : [];\n const staticUniformsInfo = source.staticUniforms ? getTokenizedAttributesAndUniforms(source.staticUniforms) : [];\n const dynamicUniformsInfo = configuration ? configuration.getBinderUniforms() : [];\n // remove duplicate uniforms\n const uniformList = preludeUniformsInfo.concat(staticUniformsInfo).concat(dynamicUniformsInfo);\n const allUniformsInfo = [];\n for (const uniform of uniformList) {\n if (allUniformsInfo.indexOf(uniform) < 0) allUniformsInfo.push(uniform);\n }\n\n const defines = configuration ? configuration.defines() : [];\n if (showOverdrawInspector) {\n defines.push('#define OVERDRAW_INSPECTOR;');\n }\n if (terrain) {\n defines.push('#define TERRAIN3D;');\n }\n\n const fragmentSource = defines.concat(shaders.prelude.fragmentSource, source.fragmentSource).join('\\n');\n const vertexSource = defines.concat(shaders.prelude.vertexSource, source.vertexSource).join('\\n');\n\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (gl.isContextLost()) {\n this.failedToCreate = true;\n return;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);\n }\n\n gl.attachShader(this.program, fragmentShader);\n\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n if (gl.isContextLost()) {\n this.failedToCreate = true;\n return;\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);\n }\n\n gl.attachShader(this.program, vertexShader);\n\n this.attributes = {};\n const uniformLocations = {};\n\n this.numAttributes = allAttrInfo.length;\n\n for (let i = 0; i < this.numAttributes; i++) {\n if (allAttrInfo[i]) {\n gl.bindAttribLocation(this.program, i, allAttrInfo[i]);\n this.attributes[allAttrInfo[i]] = i;\n }\n }\n\n gl.linkProgram(this.program);\n\n if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {\n throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);\n }\n\n gl.deleteShader(vertexShader);\n gl.deleteShader(fragmentShader);\n\n for (let it = 0; it < allUniformsInfo.length; it++) {\n const uniform = allUniformsInfo[it];\n if (uniform && !uniformLocations[uniform]) {\n const uniformLocation = gl.getUniformLocation(this.program, uniform);\n if (uniformLocation) {\n uniformLocations[uniform] = uniformLocation;\n }\n }\n }\n\n this.fixedUniforms = fixedUniforms(context, uniformLocations);\n this.terrainUniforms = terrainPreludeUniforms(context, uniformLocations);\n this.binderUniforms = configuration ? configuration.getUniforms(context, uniformLocations) : [];\n }\n\n draw(context: Context,\n drawMode: DrawMode,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly,\n cullFaceMode: Readonly,\n uniformValues: UniformValues,\n terrain: TerrainData,\n layerID: string,\n layoutVertexBuffer: VertexBuffer,\n indexBuffer: IndexBuffer,\n segments: SegmentVector,\n currentProperties?: any,\n zoom?: number | null,\n configuration?: ProgramConfiguration | null,\n dynamicLayoutBuffer?: VertexBuffer | null,\n dynamicLayoutBuffer2?: VertexBuffer | null,\n dynamicLayoutBuffer3?: VertexBuffer | null) {\n\n const gl = context.gl;\n\n if (this.failedToCreate) return;\n\n context.program.set(this.program);\n context.setDepthMode(depthMode);\n context.setStencilMode(stencilMode);\n context.setColorMode(colorMode);\n context.setCullFace(cullFaceMode);\n\n // set variables used by the 3d functions defined in _prelude.vertex.glsl\n if (terrain) {\n context.activeTexture.set(gl.TEXTURE2);\n gl.bindTexture(gl.TEXTURE_2D, terrain.depthTexture);\n context.activeTexture.set(gl.TEXTURE3);\n gl.bindTexture(gl.TEXTURE_2D, terrain.texture);\n for (const name in this.terrainUniforms) {\n this.terrainUniforms[name].set(terrain[name]);\n }\n }\n\n for (const name in this.fixedUniforms) {\n this.fixedUniforms[name].set(uniformValues[name]);\n }\n\n if (configuration) {\n configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom as any)});\n }\n\n let primitiveSize = 0;\n switch (drawMode) {\n case gl.LINES:\n primitiveSize = 2;\n break;\n case gl.TRIANGLES:\n primitiveSize = 3;\n break;\n case gl.LINE_STRIP:\n primitiveSize = 1;\n break;\n }\n\n for (const segment of segments.get()) {\n const vaos = segment.vaos || (segment.vaos = {});\n const vao: VertexArrayObject = vaos[layerID] || (vaos[layerID] = new VertexArrayObject());\n\n vao.bind(\n context,\n this,\n layoutVertexBuffer,\n configuration ? configuration.getPaintVertexBuffers() : [],\n indexBuffer,\n segment.vertexOffset,\n dynamicLayoutBuffer,\n dynamicLayoutBuffer2,\n dynamicLayoutBuffer3\n );\n\n gl.drawElements(\n drawMode,\n segment.primitiveLength * primitiveSize,\n gl.UNSIGNED_SHORT,\n segment.primitiveOffset * primitiveSize * 2);\n }\n }\n}\n","import {\n Uniform1i,\n Uniform1f,\n Uniform4f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../../render/uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type TerrainPreludeUniformsType = {\n 'u_depth': Uniform1i;\n 'u_terrain': Uniform1i;\n 'u_terrain_dim': Uniform1f;\n 'u_terrain_matrix': UniformMatrix4f;\n 'u_terrain_unpack': Uniform4f;\n 'u_terrain_exaggeration': Uniform1f;\n};\n\nexport type TerrainUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texture': Uniform1i;\n 'u_ele_delta': Uniform1f;\n};\n\nexport type TerrainDepthUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ele_delta': Uniform1f;\n};\n\nexport type TerrainCoordsUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texture': Uniform1i;\n 'u_terrain_coords_id': Uniform1f;\n 'u_ele_delta': Uniform1f;\n};\n\nconst terrainPreludeUniforms = (context: Context, locations: UniformLocations): TerrainPreludeUniformsType => ({\n 'u_depth': new Uniform1i(context, locations.u_depth),\n 'u_terrain': new Uniform1i(context, locations.u_terrain),\n 'u_terrain_dim': new Uniform1f(context, locations.u_terrain_dim),\n 'u_terrain_matrix': new UniformMatrix4f(context, locations.u_terrain_matrix),\n 'u_terrain_unpack': new Uniform4f(context, locations.u_terrain_unpack),\n 'u_terrain_exaggeration': new Uniform1f(context, locations.u_terrain_exaggeration)\n});\n\nconst terrainUniforms = (context: Context, locations: UniformLocations): TerrainUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainDepthUniforms = (context: Context, locations: UniformLocations): TerrainDepthUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainCoordsUniforms = (context: Context, locations: UniformLocations): TerrainCoordsUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_terrain_coords_id': new Uniform1f(context, locations.u_terrain_coords_id),\n 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta)\n});\n\nconst terrainUniformValues = (\n matrix: mat4,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_texture': 0,\n 'u_ele_delta': eleDelta\n});\n\nconst terrainDepthUniformValues = (\n matrix: mat4,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_ele_delta': eleDelta\n});\n\nconst terrainCoordsUniformValues = (\n matrix: mat4,\n coordsId: number,\n eleDelta: number\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_terrain_coords_id': coordsId / 255,\n 'u_texture': 0,\n 'u_ele_delta': eleDelta\n});\n\nexport {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms, terrainPreludeUniforms, terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues};\n","import {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f\n} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Painter} from '../painter';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {CrossFaded} from '../../style/properties';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {UniformValues} from '../uniform_binding';\nimport type {Tile} from '../../source/tile';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\n\ntype BackgroundPatternUniformsType = {\n 'u_image': Uniform1i;\n 'u_pattern_tl_a': Uniform2f;\n 'u_pattern_br_a': Uniform2f;\n 'u_pattern_tl_b': Uniform2f;\n 'u_pattern_br_b': Uniform2f;\n 'u_texsize': Uniform2f;\n 'u_mix': Uniform1f;\n 'u_pattern_size_a': Uniform2f;\n 'u_pattern_size_b': Uniform2f;\n 'u_scale_a': Uniform1f;\n 'u_scale_b': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_tile_units_to_pixels': Uniform1f;\n};\n\nexport type PatternUniformsType = {\n // pattern uniforms:\n 'u_image': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n};\n\nfunction patternUniformValues(crossfade: CrossfadeParameters, painter: Painter, tile: Tile): UniformValues {\n\n const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom);\n\n const numTiles = Math.pow(2, tile.tileID.overscaledZ);\n const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;\n\n const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);\n const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;\n\n return {\n 'u_image': 0,\n 'u_texsize': tile.imageAtlasTexture.size,\n 'u_scale': [tileRatio, crossfade.fromScale, crossfade.toScale],\n 'u_fade': crossfade.t,\n // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.\n 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],\n 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]\n };\n}\n\nfunction bgPatternUniformValues(\n image: CrossFaded,\n crossfade: CrossfadeParameters,\n painter: Painter,\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n }\n): UniformValues {\n const imagePosA = painter.imageManager.getPattern(image.from.toString());\n const imagePosB = painter.imageManager.getPattern(image.to.toString());\n const {width, height} = painter.imageManager.getPixelSize();\n\n const numTiles = Math.pow(2, tile.tileID.overscaledZ);\n const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;\n\n const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);\n const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;\n\n return {\n 'u_image': 0,\n 'u_pattern_tl_a': (imagePosA as any).tl,\n 'u_pattern_br_a': (imagePosA as any).br,\n 'u_pattern_tl_b': (imagePosB as any).tl,\n 'u_pattern_br_b': (imagePosB as any).br,\n 'u_texsize': [width, height],\n 'u_mix': crossfade.t,\n 'u_pattern_size_a': (imagePosA as any).displaySize,\n 'u_pattern_size_b': (imagePosB as any).displaySize,\n 'u_scale_a': crossfade.fromScale,\n 'u_scale_b': crossfade.toScale,\n 'u_tile_units_to_pixels': 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom),\n // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.\n 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],\n 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]\n };\n}\nexport {bgPatternUniformValues, patternUniformValues};\n","import {patternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n UniformMatrix4f\n} from '../uniform_binding';\n\nimport {mat3, mat4, vec3} from 'gl-matrix';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {Painter} from '../painter';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {Tile} from '../../source/tile';\n\nexport type FillExtrusionUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_lightpos': Uniform3f;\n 'u_lightintensity': Uniform1f;\n 'u_lightcolor': Uniform3f;\n 'u_vertical_gradient': Uniform1f;\n 'u_opacity': Uniform1f;\n};\n\nexport type FillExtrusionPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_lightpos': Uniform3f;\n 'u_lightintensity': Uniform1f;\n 'u_lightcolor': Uniform3f;\n 'u_height_factor': Uniform1f;\n 'u_vertical_gradient': Uniform1f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n 'u_opacity': Uniform1f;\n};\n\nconst fillExtrusionUniforms = (context: Context, locations: UniformLocations): FillExtrusionUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_lightpos': new Uniform3f(context, locations.u_lightpos),\n 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity),\n 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor),\n 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst fillExtrusionPatternUniforms = (context: Context, locations: UniformLocations): FillExtrusionPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_lightpos': new Uniform3f(context, locations.u_lightpos),\n 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity),\n 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor),\n 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient),\n 'u_height_factor': new Uniform1f(context, locations.u_height_factor),\n // pattern uniforms\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst fillExtrusionUniformValues = (\n matrix: mat4,\n painter: Painter,\n shouldUseVerticalGradient: boolean,\n opacity: number\n): UniformValues => {\n const light = painter.style.light;\n const _lp = light.properties.get('position');\n const lightPos = [_lp.x, _lp.y, _lp.z] as vec3;\n const lightMat = mat3.create();\n if (light.properties.get('anchor') === 'viewport') {\n mat3.fromRotation(lightMat, -painter.transform.angle);\n }\n vec3.transformMat3(lightPos, lightPos, lightMat);\n\n const lightColor = light.properties.get('color');\n\n return {\n 'u_matrix': matrix,\n 'u_lightpos': lightPos,\n 'u_lightintensity': light.properties.get('intensity'),\n 'u_lightcolor': [lightColor.r, lightColor.g, lightColor.b],\n 'u_vertical_gradient': +shouldUseVerticalGradient,\n 'u_opacity': opacity\n };\n};\n\nconst fillExtrusionPatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n shouldUseVerticalGradient: boolean,\n opacity: number,\n coord: OverscaledTileID,\n crossfade: CrossfadeParameters,\n tile: Tile\n): UniformValues => {\n return extend(fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity),\n patternUniformValues(crossfade, painter, tile),\n {\n 'u_height_factor': -Math.pow(2, coord.overscaledZ) / tile.tileSize / 8\n });\n};\n\nexport {\n fillExtrusionUniforms,\n fillExtrusionPatternUniforms,\n fillExtrusionUniformValues,\n fillExtrusionPatternUniformValues\n};\n","import * as glMatrix from \"./common.js\";\n/**\n * 3x3 Matrix\n * @module mat3\n */\n\n/**\n * Creates a new identity mat3\n *\n * @returns {mat3} a new 3x3 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(9);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n }\n\n out[0] = 1;\n out[4] = 1;\n out[8] = 1;\n return out;\n}\n/**\n * Copies the upper-left 3x3 values into the given mat3.\n *\n * @param {mat3} out the receiving 3x3 matrix\n * @param {ReadonlyMat4} a the source 4x4 matrix\n * @returns {mat3} out\n */\n\nexport function fromMat4(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[4];\n out[4] = a[5];\n out[5] = a[6];\n out[6] = a[8];\n out[7] = a[9];\n out[8] = a[10];\n return out;\n}\n/**\n * Creates a new mat3 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat3} a matrix to clone\n * @returns {mat3} a new 3x3 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(9);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Copy the values from one mat3 to another\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Create a new mat3 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} A new mat3\n */\n\nexport function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n var out = new glMatrix.ARRAY_TYPE(9);\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n/**\n * Set the components of a mat3 to the given values\n *\n * @param {mat3} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} out\n */\n\nexport function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n/**\n * Set a mat3 to the identity matrix\n *\n * @param {mat3} out the receiving matrix\n * @returns {mat3} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Transpose the values of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache some values\n if (out === a) {\n var a01 = a[1],\n a02 = a[2],\n a12 = a[5];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a01;\n out[5] = a[7];\n out[6] = a02;\n out[7] = a12;\n } else {\n out[0] = a[0];\n out[1] = a[3];\n out[2] = a[6];\n out[3] = a[1];\n out[4] = a[4];\n out[5] = a[7];\n out[6] = a[2];\n out[7] = a[5];\n out[8] = a[8];\n }\n\n return out;\n}\n/**\n * Inverts a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function invert(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n var b01 = a22 * a11 - a12 * a21;\n var b11 = -a22 * a10 + a12 * a20;\n var b21 = a21 * a10 - a11 * a20; // Calculate the determinant\n\n var det = a00 * b01 + a01 * b11 + a02 * b21;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = b01 * det;\n out[1] = (-a22 * a01 + a02 * a21) * det;\n out[2] = (a12 * a01 - a02 * a11) * det;\n out[3] = b11 * det;\n out[4] = (a22 * a00 - a02 * a20) * det;\n out[5] = (-a12 * a00 + a02 * a10) * det;\n out[6] = b21 * det;\n out[7] = (-a21 * a00 + a01 * a20) * det;\n out[8] = (a11 * a00 - a01 * a10) * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\n\nexport function adjoint(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n out[0] = a11 * a22 - a12 * a21;\n out[1] = a02 * a21 - a01 * a22;\n out[2] = a01 * a12 - a02 * a11;\n out[3] = a12 * a20 - a10 * a22;\n out[4] = a00 * a22 - a02 * a20;\n out[5] = a02 * a10 - a00 * a12;\n out[6] = a10 * a21 - a11 * a20;\n out[7] = a01 * a20 - a00 * a21;\n out[8] = a00 * a11 - a01 * a10;\n return out;\n}\n/**\n * Calculates the determinant of a mat3\n *\n * @param {ReadonlyMat3} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);\n}\n/**\n * Multiplies two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function multiply(out, a, b) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2];\n var a10 = a[3],\n a11 = a[4],\n a12 = a[5];\n var a20 = a[6],\n a21 = a[7],\n a22 = a[8];\n var b00 = b[0],\n b01 = b[1],\n b02 = b[2];\n var b10 = b[3],\n b11 = b[4],\n b12 = b[5];\n var b20 = b[6],\n b21 = b[7],\n b22 = b[8];\n out[0] = b00 * a00 + b01 * a10 + b02 * a20;\n out[1] = b00 * a01 + b01 * a11 + b02 * a21;\n out[2] = b00 * a02 + b01 * a12 + b02 * a22;\n out[3] = b10 * a00 + b11 * a10 + b12 * a20;\n out[4] = b10 * a01 + b11 * a11 + b12 * a21;\n out[5] = b10 * a02 + b11 * a12 + b12 * a22;\n out[6] = b20 * a00 + b21 * a10 + b22 * a20;\n out[7] = b20 * a01 + b21 * a11 + b22 * a21;\n out[8] = b20 * a02 + b21 * a12 + b22 * a22;\n return out;\n}\n/**\n * Translate a mat3 by the given vector\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to translate\n * @param {ReadonlyVec2} v vector to translate by\n * @returns {mat3} out\n */\n\nexport function translate(out, a, v) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a10 = a[3],\n a11 = a[4],\n a12 = a[5],\n a20 = a[6],\n a21 = a[7],\n a22 = a[8],\n x = v[0],\n y = v[1];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a10;\n out[4] = a11;\n out[5] = a12;\n out[6] = x * a00 + y * a10 + a20;\n out[7] = x * a01 + y * a11 + a21;\n out[8] = x * a02 + y * a12 + a22;\n return out;\n}\n/**\n * Rotates a mat3 by the given angle\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\n\nexport function rotate(out, a, rad) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a10 = a[3],\n a11 = a[4],\n a12 = a[5],\n a20 = a[6],\n a21 = a[7],\n a22 = a[8],\n s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c * a00 + s * a10;\n out[1] = c * a01 + s * a11;\n out[2] = c * a02 + s * a12;\n out[3] = c * a10 - s * a00;\n out[4] = c * a11 - s * a01;\n out[5] = c * a12 - s * a02;\n out[6] = a20;\n out[7] = a21;\n out[8] = a22;\n return out;\n}\n/**\n * Scales the mat3 by the dimensions in the given vec2\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat3} out\n **/\n\nexport function scale(out, a, v) {\n var x = v[0],\n y = v[1];\n out[0] = x * a[0];\n out[1] = x * a[1];\n out[2] = x * a[2];\n out[3] = y * a[3];\n out[4] = y * a[4];\n out[5] = y * a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n return out;\n}\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.translate(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Translation vector\n * @returns {mat3} out\n */\n\nexport function fromTranslation(out, v) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 1;\n out[5] = 0;\n out[6] = v[0];\n out[7] = v[1];\n out[8] = 1;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.rotate(dest, dest, rad);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad),\n c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = 0;\n out[3] = -s;\n out[4] = c;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat3.identity(dest);\n * mat3.scale(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat3} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = v[1];\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 1;\n return out;\n}\n/**\n * Copies the values from a mat2d into a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to copy\n * @returns {mat3} out\n **/\n\nexport function fromMat2d(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = 0;\n out[3] = a[2];\n out[4] = a[3];\n out[5] = 0;\n out[6] = a[4];\n out[7] = a[5];\n out[8] = 1;\n return out;\n}\n/**\n * Calculates a 3x3 matrix from the given quaternion\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat3} out\n */\n\nexport function fromQuat(out, q) {\n var x = q[0],\n y = q[1],\n z = q[2],\n w = q[3];\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n var xx = x * x2;\n var yx = y * x2;\n var yy = y * y2;\n var zx = z * x2;\n var zy = z * y2;\n var zz = z * z2;\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n out[0] = 1 - yy - zz;\n out[3] = yx - wz;\n out[6] = zx + wy;\n out[1] = yx + wz;\n out[4] = 1 - xx - zz;\n out[7] = zy - wx;\n out[2] = zx - wy;\n out[5] = zy + wx;\n out[8] = 1 - xx - yy;\n return out;\n}\n/**\n * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from\n *\n * @returns {mat3} out\n */\n\nexport function normalFromMat4(out, a) {\n var a00 = a[0],\n a01 = a[1],\n a02 = a[2],\n a03 = a[3];\n var a10 = a[4],\n a11 = a[5],\n a12 = a[6],\n a13 = a[7];\n var a20 = a[8],\n a21 = a[9],\n a22 = a[10],\n a23 = a[11];\n var a30 = a[12],\n a31 = a[13],\n a32 = a[14],\n a33 = a[15];\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32; // Calculate the determinant\n\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n return out;\n}\n/**\n * Generates a 2D projection matrix with the given bounds\n *\n * @param {mat3} out mat3 frustum matrix will be written into\n * @param {number} width Width of your gl context\n * @param {number} height Height of gl context\n * @returns {mat3} out\n */\n\nexport function projection(out, width, height) {\n out[0] = 2 / width;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = -2 / height;\n out[5] = 0;\n out[6] = -1;\n out[7] = 1;\n out[8] = 1;\n return out;\n}\n/**\n * Returns a string representation of a mat3\n *\n * @param {ReadonlyMat3} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat3\n *\n * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);\n}\n/**\n * Adds two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n out[4] = a[4] + b[4];\n out[5] = a[5] + b[5];\n out[6] = a[6] + b[6];\n out[7] = a[7] + b[7];\n out[8] = a[8] + b[8];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n out[4] = a[4] - b[4];\n out[5] = a[5] - b[5];\n out[6] = a[6] - b[6];\n out[7] = a[7] - b[7];\n out[8] = a[8] - b[8];\n return out;\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat3} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n out[4] = a[4] * b;\n out[5] = a[5] * b;\n out[6] = a[6] * b;\n out[7] = a[7] * b;\n out[8] = a[8] * b;\n return out;\n}\n/**\n * Adds two mat3's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat3} out the receiving vector\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat3} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n out[4] = a[4] + b[4] * scale;\n out[5] = a[5] + b[5] * scale;\n out[6] = a[6] + b[6] * scale;\n out[7] = a[7] + b[7] * scale;\n out[8] = a[8] + b[8] * scale;\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3],\n a4 = a[4],\n a5 = a[5],\n a6 = a[6],\n a7 = a[7],\n a8 = a[8];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));\n}\n/**\n * Alias for {@link mat3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat3.subtract}\n * @function\n */\n\nexport var sub = subtract;","import {patternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n Uniform3f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {Tile} from '../../source/tile';\nimport {mat4} from 'gl-matrix';\n\nexport type FillUniformsType = {\n 'u_matrix': UniformMatrix4f;\n};\n\nexport type FillOutlineUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n};\n\nexport type FillPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nexport type FillOutlinePatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n // pattern uniforms:\n 'u_texsize': Uniform2f;\n 'u_image': Uniform1i;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nconst fillUniforms = (context: Context, locations: UniformLocations): FillUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst fillPatternUniforms = (context: Context, locations: UniformLocations): FillPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst fillOutlineUniforms = (context: Context, locations: UniformLocations): FillOutlineUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world)\n});\n\nconst fillOutlinePatternUniforms = (context: Context, locations: UniformLocations): FillOutlinePatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst fillUniformValues = (matrix: mat4): UniformValues => ({\n 'u_matrix': matrix\n});\n\nconst fillPatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n crossfade: CrossfadeParameters,\n tile: Tile\n): UniformValues => extend(\n fillUniformValues(matrix),\n patternUniformValues(crossfade, painter, tile)\n);\n\nconst fillOutlineUniformValues = (matrix: mat4, drawingBufferSize: [number, number]): UniformValues => ({\n 'u_matrix': matrix,\n 'u_world': drawingBufferSize\n});\n\nconst fillOutlinePatternUniformValues = (\n matrix: mat4,\n painter: Painter,\n crossfade: CrossfadeParameters,\n tile: Tile,\n drawingBufferSize: [number, number]\n): UniformValues => extend(\n fillPatternUniformValues(matrix, painter, crossfade, tile),\n {\n 'u_world': drawingBufferSize\n }\n);\n\nexport {\n fillUniforms,\n fillPatternUniforms,\n fillOutlineUniforms,\n fillOutlinePatternUniforms,\n fillUniformValues,\n fillPatternUniformValues,\n fillOutlineUniformValues,\n fillOutlinePatternUniformValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport type {Tile} from '../../source/tile';\nimport type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';\nimport type {Painter} from '../painter';\n\nexport type CircleUniformsType = {\n 'u_camera_to_center_distance': Uniform1f;\n 'u_scale_with_map': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_extrude_scale': Uniform2f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n};\n\nconst circleUniforms = (context: Context, locations: UniformLocations): CircleUniformsType => ({\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_scale_with_map': new Uniform1i(context, locations.u_scale_with_map),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst circleUniformValues = (\n painter: Painter,\n coord: OverscaledTileID,\n tile: Tile,\n layer: CircleStyleLayer\n): UniformValues => {\n const transform = painter.transform;\n\n let pitchWithMap: boolean, extrudeScale: [number, number];\n if (layer.paint.get('circle-pitch-alignment') === 'map') {\n const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom);\n pitchWithMap = true;\n extrudeScale = [pixelRatio, pixelRatio];\n } else {\n pitchWithMap = false;\n extrudeScale = transform.pixelsToGLUnits;\n }\n\n return {\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_scale_with_map': +(layer.paint.get('circle-pitch-scale') === 'map'),\n 'u_matrix': painter.translatePosMatrix(\n coord.posMatrix,\n tile,\n layer.paint.get('circle-translate'),\n layer.paint.get('circle-translate-anchor')),\n 'u_pitch_with_map': +(pitchWithMap),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_extrude_scale': extrudeScale\n };\n};\n\nexport {circleUniforms, circleUniformValues};\n","import {Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Transform} from '../../geo/transform';\nimport type {Tile} from '../../source/tile';\nimport {mat4} from 'gl-matrix';\n\nexport type CollisionUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pixels_to_tile_units': Uniform1f;\n 'u_extrude_scale': Uniform2f;\n 'u_overscale_factor': Uniform1f;\n};\n\nexport type CollisionCircleUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_inv_matrix': UniformMatrix4f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_viewport_size': Uniform2f;\n};\n\nconst collisionUniforms = (context: Context, locations: UniformLocations): CollisionUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pixels_to_tile_units': new Uniform1f(context, locations.u_pixels_to_tile_units),\n 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale),\n 'u_overscale_factor': new Uniform1f(context, locations.u_overscale_factor)\n});\n\nconst collisionCircleUniforms = (context: Context, locations: UniformLocations): CollisionCircleUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_inv_matrix': new UniformMatrix4f(context, locations.u_inv_matrix),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_viewport_size': new Uniform2f(context, locations.u_viewport_size)\n});\n\nconst collisionUniformValues = (matrix: mat4, transform: Transform, tile: Tile): UniformValues => {\n const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom);\n const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);\n const overscaleFactor = tile.tileID.overscaleFactor();\n return {\n 'u_matrix': matrix,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_pixels_to_tile_units': pixelRatio,\n 'u_extrude_scale': [transform.pixelsToGLUnits[0] / (pixelRatio * scale),\n transform.pixelsToGLUnits[1] / (pixelRatio * scale)],\n 'u_overscale_factor': overscaleFactor\n };\n};\n\nconst collisionCircleUniformValues = (matrix: mat4, invMatrix: mat4, transform: Transform): UniformValues => {\n return {\n 'u_matrix': matrix,\n 'u_inv_matrix': invMatrix,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_viewport_size': [transform.width, transform.height]\n };\n};\n\nexport {collisionUniforms, collisionUniformValues, collisionCircleUniforms, collisionCircleUniformValues};\n","import {UniformColor, UniformMatrix4f, Uniform1i, Uniform1f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {mat4} from 'gl-matrix';\n\nexport type DebugUniformsType = {\n 'u_color': UniformColor;\n 'u_matrix': UniformMatrix4f;\n 'u_overlay': Uniform1i;\n 'u_overlay_scale': Uniform1f;\n};\n\nconst debugUniforms = (context: Context, locations: UniformLocations): DebugUniformsType => ({\n 'u_color': new UniformColor(context, locations.u_color),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_overlay': new Uniform1i(context, locations.u_overlay),\n 'u_overlay_scale': new Uniform1f(context, locations.u_overlay_scale)\n});\n\nconst debugUniformValues = (matrix: mat4, color: Color, scaleRatio: number = 1): UniformValues => ({\n 'u_matrix': matrix,\n 'u_color': color,\n 'u_overlay': 0,\n 'u_overlay_scale': scaleRatio\n});\n\nexport {debugUniforms, debugUniformValues};\n","import {UniformMatrix4f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type ClippingMaskUniformsType = {\n 'u_matrix': UniformMatrix4f;\n};\n\nconst clippingMaskUniforms = (context: Context, locations: UniformLocations): ClippingMaskUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst clippingMaskUniformValues = (matrix: mat4): UniformValues => ({\n 'u_matrix': matrix\n});\n\nexport {clippingMaskUniforms, clippingMaskUniformValues};\n","import {mat4} from 'gl-matrix';\n\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\n\nimport type {Context} from '../../gl/context';\nimport type {Tile} from '../../source/tile';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Painter} from '../painter';\nimport type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';\n\nexport type HeatmapUniformsType = {\n 'u_extrude_scale': Uniform1f;\n 'u_intensity': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n};\n\nexport type HeatmapTextureUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_world': Uniform2f;\n 'u_image': Uniform1i;\n 'u_color_ramp': Uniform1i;\n 'u_opacity': Uniform1f;\n};\n\nconst heatmapUniforms = (context: Context, locations: UniformLocations): HeatmapUniformsType => ({\n 'u_extrude_scale': new Uniform1f(context, locations.u_extrude_scale),\n 'u_intensity': new Uniform1f(context, locations.u_intensity),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix)\n});\n\nconst heatmapTextureUniforms = (context: Context, locations: UniformLocations): HeatmapTextureUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_world': new Uniform2f(context, locations.u_world),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_color_ramp': new Uniform1i(context, locations.u_color_ramp),\n 'u_opacity': new Uniform1f(context, locations.u_opacity)\n});\n\nconst heatmapUniformValues = (matrix: mat4, tile: Tile, zoom: number, intensity: number): UniformValues => ({\n 'u_matrix': matrix,\n 'u_extrude_scale': pixelsToTileUnits(tile, 1, zoom),\n 'u_intensity': intensity\n});\n\nconst heatmapTextureUniformValues = (\n painter: Painter,\n layer: HeatmapStyleLayer,\n textureUnit: number,\n colorRampUnit: number\n): UniformValues => {\n const matrix = mat4.create();\n mat4.ortho(matrix, 0, painter.width, painter.height, 0, 0, 1);\n\n const gl = painter.context.gl;\n\n return {\n 'u_matrix': matrix,\n 'u_world': [gl.drawingBufferWidth, gl.drawingBufferHeight],\n 'u_image': textureUnit,\n 'u_color_ramp': colorRampUnit,\n 'u_opacity': layer.paint.get('heatmap-opacity')\n };\n};\n\nexport {\n heatmapUniforms,\n heatmapTextureUniforms,\n heatmapUniformValues,\n heatmapTextureUniformValues\n};\n","import {mat4} from 'gl-matrix';\n\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformColor,\n UniformMatrix4f,\n Uniform4f\n} from '../uniform_binding';\nimport {EXTENT} from '../../data/extent';\nimport {MercatorCoordinate} from '../../geo/mercator_coordinate';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Tile} from '../../source/tile';\nimport type {Painter} from '../painter';\nimport type {HillshadeStyleLayer} from '../../style/style_layer/hillshade_style_layer';\nimport type {DEMData} from '../../data/dem_data';\nimport type {OverscaledTileID} from '../../source/tile_id';\n\nexport type HillshadeUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_image': Uniform1i;\n 'u_latrange': Uniform2f;\n 'u_light': Uniform2f;\n 'u_shadow': UniformColor;\n 'u_highlight': UniformColor;\n 'u_accent': UniformColor;\n};\n\nexport type HillshadePrepareUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_image': Uniform1i;\n 'u_dimension': Uniform2f;\n 'u_zoom': Uniform1f;\n 'u_unpack': Uniform4f;\n};\n\nconst hillshadeUniforms = (context: Context, locations: UniformLocations): HillshadeUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_latrange': new Uniform2f(context, locations.u_latrange),\n 'u_light': new Uniform2f(context, locations.u_light),\n 'u_shadow': new UniformColor(context, locations.u_shadow),\n 'u_highlight': new UniformColor(context, locations.u_highlight),\n 'u_accent': new UniformColor(context, locations.u_accent)\n});\n\nconst hillshadePrepareUniforms = (context: Context, locations: UniformLocations): HillshadePrepareUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_dimension': new Uniform2f(context, locations.u_dimension),\n 'u_zoom': new Uniform1f(context, locations.u_zoom),\n 'u_unpack': new Uniform4f(context, locations.u_unpack)\n});\n\nconst hillshadeUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: HillshadeStyleLayer,\n coord: OverscaledTileID\n): UniformValues => {\n const shadow = layer.paint.get('hillshade-shadow-color');\n const highlight = layer.paint.get('hillshade-highlight-color');\n const accent = layer.paint.get('hillshade-accent-color');\n\n let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180);\n // modify azimuthal angle by map rotation if light is anchored at the viewport\n if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') {\n azimuthal -= painter.transform.angle;\n }\n const align = !painter.options.moving;\n return {\n 'u_matrix': coord ? coord.posMatrix : painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align),\n 'u_image': 0,\n 'u_latrange': getTileLatRange(painter, tile.tileID),\n 'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal],\n 'u_shadow': shadow,\n 'u_highlight': highlight,\n 'u_accent': accent\n };\n};\n\nconst hillshadeUniformPrepareValues = (tileID: OverscaledTileID, dem: DEMData): UniformValues => {\n\n const stride = dem.stride;\n const matrix = mat4.create();\n // Flip rendering at y axis.\n mat4.ortho(matrix, 0, EXTENT, -EXTENT, 0, 0, 1);\n mat4.translate(matrix, matrix, [0, -EXTENT, 0]);\n\n return {\n 'u_matrix': matrix,\n 'u_image': 1,\n 'u_dimension': [stride, stride],\n 'u_zoom': tileID.overscaledZ,\n 'u_unpack': dem.getUnpackVector()\n };\n};\n\nfunction getTileLatRange(painter: Painter, tileID: OverscaledTileID) {\n // for scaling the magnitude of a points slope by its latitude\n const tilesAtZoom = Math.pow(2, tileID.canonical.z);\n const y = tileID.canonical.y;\n return [\n new MercatorCoordinate(0, y / tilesAtZoom).toLngLat().lat,\n new MercatorCoordinate(0, (y + 1) / tilesAtZoom).toLngLat().lat];\n}\n\nexport {\n hillshadeUniforms,\n hillshadePrepareUniforms,\n hillshadeUniformValues,\n hillshadeUniformPrepareValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';\nimport {pixelsToTileUnits} from '../../source/pixels_to_tile_units';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Transform} from '../../geo/transform';\nimport type {Tile} from '../../source/tile';\nimport type {CrossFaded} from '../../style/properties';\nimport type {LineStyleLayer} from '../../style/style_layer/line_style_layer';\nimport type {Painter} from '../painter';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport {OverscaledTileID} from '../../source/tile_id';\n\nexport type LineUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n};\n\nexport type LineGradientUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_image': Uniform1i;\n 'u_image_height': Uniform1f;\n};\n\nexport type LinePatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_texsize': Uniform2f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_image': Uniform1i;\n 'u_scale': Uniform3f;\n 'u_fade': Uniform1f;\n};\n\nexport type LineSDFUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_ratio': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_units_to_pixels': Uniform2f;\n 'u_patternscale_a': Uniform2f;\n 'u_patternscale_b': Uniform2f;\n 'u_sdfgamma': Uniform1f;\n 'u_image': Uniform1i;\n 'u_tex_y_a': Uniform1f;\n 'u_tex_y_b': Uniform1f;\n 'u_mix': Uniform1f;\n};\n\nconst lineUniforms = (context: Context, locations: UniformLocations): LineUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels)\n});\n\nconst lineGradientUniforms = (context: Context, locations: UniformLocations): LineGradientUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_image_height': new Uniform1f(context, locations.u_image_height)\n});\n\nconst linePatternUniforms = (context: Context, locations: UniformLocations): LinePatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_scale': new Uniform3f(context, locations.u_scale),\n 'u_fade': new Uniform1f(context, locations.u_fade)\n});\n\nconst lineSDFUniforms = (context: Context, locations: UniformLocations): LineSDFUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_ratio': new Uniform1f(context, locations.u_ratio),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),\n 'u_patternscale_a': new Uniform2f(context, locations.u_patternscale_a),\n 'u_patternscale_b': new Uniform2f(context, locations.u_patternscale_b),\n 'u_sdfgamma': new Uniform1f(context, locations.u_sdfgamma),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_tex_y_a': new Uniform1f(context, locations.u_tex_y_a),\n 'u_tex_y_b': new Uniform1f(context, locations.u_tex_y_b),\n 'u_mix': new Uniform1f(context, locations.u_mix)\n});\n\nconst lineUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n\n return {\n 'u_matrix': calculateMatrix(painter, tile, layer, coord),\n 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_units_to_pixels': [\n 1 / transform.pixelsToGLUnits[0],\n 1 / transform.pixelsToGLUnits[1]\n ]\n };\n};\n\nconst lineGradientUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n imageHeight: number,\n coord: OverscaledTileID\n): UniformValues => {\n return extend(lineUniformValues(painter, tile, layer, coord), {\n 'u_image': 0,\n 'u_image_height': imageHeight,\n });\n};\n\nconst linePatternUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n crossfade: CrossfadeParameters,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n const tileZoomRatio = calculateTileRatio(tile, transform);\n return {\n 'u_matrix': calculateMatrix(painter, tile, layer, coord),\n 'u_texsize': tile.imageAtlasTexture.size,\n // camera zoom ratio\n 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_image': 0,\n 'u_scale': [tileZoomRatio, crossfade.fromScale, crossfade.toScale],\n 'u_fade': crossfade.t,\n 'u_units_to_pixels': [\n 1 / transform.pixelsToGLUnits[0],\n 1 / transform.pixelsToGLUnits[1]\n ]\n };\n};\n\nconst lineSDFUniformValues = (\n painter: Painter,\n tile: Tile,\n layer: LineStyleLayer,\n dasharray: CrossFaded>,\n crossfade: CrossfadeParameters,\n coord: OverscaledTileID\n): UniformValues => {\n const transform = painter.transform;\n const lineAtlas = painter.lineAtlas;\n const tileRatio = calculateTileRatio(tile, transform);\n\n const round = layer.layout.get('line-cap') === 'round';\n\n const posA = lineAtlas.getDash(dasharray.from, round);\n const posB = lineAtlas.getDash(dasharray.to, round);\n\n const widthA = posA.width * crossfade.fromScale;\n const widthB = posB.width * crossfade.toScale;\n\n return extend(lineUniformValues(painter, tile, layer, coord), {\n 'u_patternscale_a': [tileRatio / widthA, -posA.height / 2],\n 'u_patternscale_b': [tileRatio / widthB, -posB.height / 2],\n 'u_sdfgamma': lineAtlas.width / (Math.min(widthA, widthB) * 256 * painter.pixelRatio) / 2,\n 'u_image': 0,\n 'u_tex_y_a': posA.y,\n 'u_tex_y_b': posB.y,\n 'u_mix': crossfade.t\n });\n};\n\nfunction calculateTileRatio(tile: Tile, transform: Transform) {\n return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom);\n}\n\nfunction calculateMatrix(painter: Painter, tile: Tile, layer: LineStyleLayer, coord: OverscaledTileID) {\n return painter.translatePosMatrix(\n coord ? coord.posMatrix : tile.tileID.posMatrix,\n tile,\n layer.paint.get('line-translate'),\n layer.paint.get('line-translate-anchor')\n );\n}\n\nexport {\n lineUniforms,\n lineGradientUniforms,\n linePatternUniforms,\n lineSDFUniforms,\n lineUniformValues,\n lineGradientUniformValues,\n linePatternUniformValues,\n lineSDFUniformValues\n};\n","import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';\n\nimport type {Context} from '../../gl/context';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {RasterStyleLayer} from '../../style/style_layer/raster_style_layer';\nimport {mat4} from 'gl-matrix';\n\nexport type RasterUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_tl_parent': Uniform2f;\n 'u_scale_parent': Uniform1f;\n 'u_buffer_scale': Uniform1f;\n 'u_fade_t': Uniform1f;\n 'u_opacity': Uniform1f;\n 'u_image0': Uniform1i;\n 'u_image1': Uniform1i;\n 'u_brightness_low': Uniform1f;\n 'u_brightness_high': Uniform1f;\n 'u_saturation_factor': Uniform1f;\n 'u_contrast_factor': Uniform1f;\n 'u_spin_weights': Uniform3f;\n};\n\nconst rasterUniforms = (context: Context, locations: UniformLocations): RasterUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_tl_parent': new Uniform2f(context, locations.u_tl_parent),\n 'u_scale_parent': new Uniform1f(context, locations.u_scale_parent),\n 'u_buffer_scale': new Uniform1f(context, locations.u_buffer_scale),\n 'u_fade_t': new Uniform1f(context, locations.u_fade_t),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_image0': new Uniform1i(context, locations.u_image0),\n 'u_image1': new Uniform1i(context, locations.u_image1),\n 'u_brightness_low': new Uniform1f(context, locations.u_brightness_low),\n 'u_brightness_high': new Uniform1f(context, locations.u_brightness_high),\n 'u_saturation_factor': new Uniform1f(context, locations.u_saturation_factor),\n 'u_contrast_factor': new Uniform1f(context, locations.u_contrast_factor),\n 'u_spin_weights': new Uniform3f(context, locations.u_spin_weights)\n});\n\nconst rasterUniformValues = (\n matrix: mat4,\n parentTL: [number, number],\n parentScaleBy: number,\n fade: {\n mix: number;\n opacity: number;\n },\n layer: RasterStyleLayer\n): UniformValues => ({\n 'u_matrix': matrix,\n 'u_tl_parent': parentTL,\n 'u_scale_parent': parentScaleBy,\n 'u_buffer_scale': 1,\n 'u_fade_t': fade.mix,\n 'u_opacity': fade.opacity * layer.paint.get('raster-opacity'),\n 'u_image0': 0,\n 'u_image1': 1,\n 'u_brightness_low': layer.paint.get('raster-brightness-min'),\n 'u_brightness_high': layer.paint.get('raster-brightness-max'),\n 'u_saturation_factor': saturationFactor(layer.paint.get('raster-saturation')),\n 'u_contrast_factor': contrastFactor(layer.paint.get('raster-contrast')),\n 'u_spin_weights': spinWeights(layer.paint.get('raster-hue-rotate'))\n});\n\nfunction spinWeights(angle) {\n angle *= Math.PI / 180;\n const s = Math.sin(angle);\n const c = Math.cos(angle);\n return [\n (2 * c + 1) / 3,\n (-Math.sqrt(3) * s - c + 1) / 3,\n (Math.sqrt(3) * s - c + 1) / 3\n ];\n}\n\nfunction contrastFactor(contrast) {\n return contrast > 0 ?\n 1 / (1 - contrast) :\n 1 + contrast;\n}\n\nfunction saturationFactor(saturation) {\n return saturation > 0 ?\n 1 - 1 / (1.001 - saturation) :\n -saturation;\n}\n\nexport {rasterUniforms, rasterUniformValues};\n","import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Context} from '../../gl/context';\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport {mat4} from 'gl-matrix';\n\nexport type SymbolIconUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texture': Uniform1i;\n};\n\nexport type SymbolSDFUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texture': Uniform1i;\n 'u_gamma_scale': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_is_halo': Uniform1i;\n};\n\nexport type symbolTextAndIconUniformsType = {\n 'u_is_size_zoom_constant': Uniform1i;\n 'u_is_size_feature_constant': Uniform1i;\n 'u_size_t': Uniform1f;\n 'u_size': Uniform1f;\n 'u_camera_to_center_distance': Uniform1f;\n 'u_pitch': Uniform1f;\n 'u_rotate_symbol': Uniform1i;\n 'u_aspect_ratio': Uniform1f;\n 'u_fade_change': Uniform1f;\n 'u_matrix': UniformMatrix4f;\n 'u_label_plane_matrix': UniformMatrix4f;\n 'u_coord_matrix': UniformMatrix4f;\n 'u_is_text': Uniform1i;\n 'u_pitch_with_map': Uniform1i;\n 'u_texsize': Uniform2f;\n 'u_texsize_icon': Uniform2f;\n 'u_texture': Uniform1i;\n 'u_texture_icon': Uniform1i;\n 'u_gamma_scale': Uniform1f;\n 'u_device_pixel_ratio': Uniform1f;\n 'u_is_halo': Uniform1i;\n};\n\nconst symbolIconUniforms = (context: Context, locations: UniformLocations): SymbolIconUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texture': new Uniform1i(context, locations.u_texture)\n});\n\nconst symbolSDFUniforms = (context: Context, locations: UniformLocations): SymbolSDFUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_is_halo': new Uniform1i(context, locations.u_is_halo)\n});\n\nconst symbolTextAndIconUniforms = (context: Context, locations: UniformLocations): symbolTextAndIconUniformsType => ({\n 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),\n 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),\n 'u_size_t': new Uniform1f(context, locations.u_size_t),\n 'u_size': new Uniform1f(context, locations.u_size),\n 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),\n 'u_pitch': new Uniform1f(context, locations.u_pitch),\n 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol),\n 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio),\n 'u_fade_change': new Uniform1f(context, locations.u_fade_change),\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),\n 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),\n 'u_is_text': new Uniform1i(context, locations.u_is_text),\n 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_texsize_icon': new Uniform2f(context, locations.u_texsize_icon),\n 'u_texture': new Uniform1i(context, locations.u_texture),\n 'u_texture_icon': new Uniform1i(context, locations.u_texture_icon),\n 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale),\n 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),\n 'u_is_halo': new Uniform1i(context, locations.u_is_halo)\n});\n\nconst symbolIconUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n isText: boolean,\n texSize: [number, number]\n): UniformValues => {\n const transform = painter.transform;\n\n return {\n 'u_is_size_zoom_constant': +(functionType === 'constant' || functionType === 'source'),\n 'u_is_size_feature_constant': +(functionType === 'constant' || functionType === 'camera'),\n 'u_size_t': size ? size.uSizeT : 0,\n 'u_size': size ? size.uSize : 0,\n 'u_camera_to_center_distance': transform.cameraToCenterDistance,\n 'u_pitch': transform.pitch / 360 * 2 * Math.PI,\n 'u_rotate_symbol': +rotateInShader,\n 'u_aspect_ratio': transform.width / transform.height,\n 'u_fade_change': painter.options.fadeDuration ? painter.symbolFadeChange : 1,\n 'u_matrix': matrix,\n 'u_label_plane_matrix': labelPlaneMatrix,\n 'u_coord_matrix': glCoordMatrix,\n 'u_is_text': +isText,\n 'u_pitch_with_map': +pitchWithMap,\n 'u_texsize': texSize,\n 'u_texture': 0\n };\n};\n\nconst symbolSDFUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n isText: boolean,\n texSize: [number, number],\n isHalo: boolean\n): UniformValues => {\n const transform = painter.transform;\n\n return extend(symbolIconUniformValues(functionType, size,\n rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,\n glCoordMatrix, isText, texSize), {\n 'u_gamma_scale': (pitchWithMap ? Math.cos(transform._pitch) * transform.cameraToCenterDistance : 1),\n 'u_device_pixel_ratio': painter.pixelRatio,\n 'u_is_halo': +isHalo\n });\n};\n\nconst symbolTextAndIconUniformValues = (\n functionType: string,\n size: {\n uSizeT: number;\n uSize: number;\n },\n rotateInShader: boolean,\n pitchWithMap: boolean,\n painter: Painter,\n matrix: mat4,\n labelPlaneMatrix: mat4,\n glCoordMatrix: mat4,\n texSizeSDF: [number, number],\n texSizeIcon: [number, number]\n): UniformValues => {\n return extend(symbolSDFUniformValues(functionType, size,\n rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,\n glCoordMatrix, true, texSizeSDF, true), {\n 'u_texsize_icon': texSizeIcon,\n 'u_texture_icon': 1\n });\n};\n\nexport {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues, symbolTextAndIconUniformValues, symbolTextAndIconUniforms};\n","import {bgPatternUniformValues} from './pattern';\nimport {\n Uniform1i,\n Uniform1f,\n Uniform2f,\n UniformColor,\n UniformMatrix4f\n} from '../uniform_binding';\nimport {extend} from '../../util/util';\n\nimport type {Painter} from '../painter';\nimport type {UniformValues, UniformLocations} from '../uniform_binding';\nimport type {Context} from '../../gl/context';\nimport type {Color, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport type {CrossFaded} from '../../style/properties';\nimport type {CrossfadeParameters} from '../../style/evaluation_parameters';\nimport type {OverscaledTileID} from '../../source/tile_id';\nimport {mat4} from 'gl-matrix';\n\nexport type BackgroundUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_opacity': Uniform1f;\n 'u_color': UniformColor;\n};\n\nexport type BackgroundPatternUniformsType = {\n 'u_matrix': UniformMatrix4f;\n 'u_opacity': Uniform1f;\n // pattern uniforms:\n 'u_image': Uniform1i;\n 'u_pattern_tl_a': Uniform2f;\n 'u_pattern_br_a': Uniform2f;\n 'u_pattern_tl_b': Uniform2f;\n 'u_pattern_br_b': Uniform2f;\n 'u_texsize': Uniform2f;\n 'u_mix': Uniform1f;\n 'u_pattern_size_a': Uniform2f;\n 'u_pattern_size_b': Uniform2f;\n 'u_scale_a': Uniform1f;\n 'u_scale_b': Uniform1f;\n 'u_pixel_coord_upper': Uniform2f;\n 'u_pixel_coord_lower': Uniform2f;\n 'u_tile_units_to_pixels': Uniform1f;\n};\n\nconst backgroundUniforms = (context: Context, locations: UniformLocations): BackgroundUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_color': new UniformColor(context, locations.u_color)\n});\n\nconst backgroundPatternUniforms = (context: Context, locations: UniformLocations): BackgroundPatternUniformsType => ({\n 'u_matrix': new UniformMatrix4f(context, locations.u_matrix),\n 'u_opacity': new Uniform1f(context, locations.u_opacity),\n 'u_image': new Uniform1i(context, locations.u_image),\n 'u_pattern_tl_a': new Uniform2f(context, locations.u_pattern_tl_a),\n 'u_pattern_br_a': new Uniform2f(context, locations.u_pattern_br_a),\n 'u_pattern_tl_b': new Uniform2f(context, locations.u_pattern_tl_b),\n 'u_pattern_br_b': new Uniform2f(context, locations.u_pattern_br_b),\n 'u_texsize': new Uniform2f(context, locations.u_texsize),\n 'u_mix': new Uniform1f(context, locations.u_mix),\n 'u_pattern_size_a': new Uniform2f(context, locations.u_pattern_size_a),\n 'u_pattern_size_b': new Uniform2f(context, locations.u_pattern_size_b),\n 'u_scale_a': new Uniform1f(context, locations.u_scale_a),\n 'u_scale_b': new Uniform1f(context, locations.u_scale_b),\n 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper),\n 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower),\n 'u_tile_units_to_pixels': new Uniform1f(context, locations.u_tile_units_to_pixels)\n});\n\nconst backgroundUniformValues = (matrix: mat4, opacity: number, color: Color): UniformValues => ({\n 'u_matrix': matrix,\n 'u_opacity': opacity,\n 'u_color': color\n});\n\nconst backgroundPatternUniformValues = (\n matrix: mat4,\n opacity: number,\n painter: Painter,\n image: CrossFaded,\n tile: {\n tileID: OverscaledTileID;\n tileSize: number;\n },\n crossfade: CrossfadeParameters\n): UniformValues => extend(\n bgPatternUniformValues(image, crossfade, painter, tile),\n {\n 'u_matrix': matrix,\n 'u_opacity': opacity\n }\n);\n\nexport {\n backgroundUniforms,\n backgroundPatternUniforms,\n backgroundUniformValues,\n backgroundPatternUniformValues\n};\n","import {fillExtrusionUniforms, fillExtrusionPatternUniforms} from './fill_extrusion_program';\nimport {fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms} from './fill_program';\nimport {circleUniforms} from './circle_program';\nimport {collisionUniforms, collisionCircleUniforms} from './collision_program';\nimport {debugUniforms} from './debug_program';\nimport {clippingMaskUniforms} from './clipping_mask_program';\nimport {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program';\nimport {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program';\nimport {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program';\nimport {rasterUniforms} from './raster_program';\nimport {symbolIconUniforms, symbolSDFUniforms, symbolTextAndIconUniforms} from './symbol_program';\nimport {backgroundUniforms, backgroundPatternUniforms} from './background_program';\nimport {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms} from './terrain_program';\n\nexport const programUniforms = {\n fillExtrusion: fillExtrusionUniforms,\n fillExtrusionPattern: fillExtrusionPatternUniforms,\n fill: fillUniforms,\n fillPattern: fillPatternUniforms,\n fillOutline: fillOutlineUniforms,\n fillOutlinePattern: fillOutlinePatternUniforms,\n circle: circleUniforms,\n collisionBox: collisionUniforms,\n collisionCircle: collisionCircleUniforms,\n debug: debugUniforms,\n clippingMask: clippingMaskUniforms,\n heatmap: heatmapUniforms,\n heatmapTexture: heatmapTextureUniforms,\n hillshade: hillshadeUniforms,\n hillshadePrepare: hillshadePrepareUniforms,\n line: lineUniforms,\n lineGradient: lineGradientUniforms,\n linePattern: linePatternUniforms,\n lineSDF: lineSDFUniforms,\n raster: rasterUniforms,\n symbolIcon: symbolIconUniforms,\n symbolSDF: symbolSDFUniforms,\n symbolTextAndIcon: symbolTextAndIconUniforms,\n background: backgroundUniforms,\n backgroundPattern: backgroundPatternUniforms,\n terrain: terrainUniforms,\n terrainDepth: terrainDepthUniforms,\n terrainCoords: terrainCoordsUniforms\n};\n","\nimport type {StructArray} from '../util/struct_array';\nimport type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';\nimport type {Context} from '../gl/context';\n\n/**\n * @internal\n * an index buffer class\n */\nexport class IndexBuffer {\n context: Context;\n buffer: WebGLBuffer;\n dynamicDraw: boolean;\n\n constructor(context: Context, array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) {\n this.context = context;\n const gl = context.gl;\n this.buffer = gl.createBuffer();\n this.dynamicDraw = Boolean(dynamicDraw);\n\n // The bound index buffer is part of vertex array object state. We don't want to\n // modify whatever VAO happens to be currently bound, so make sure the default\n // vertex array provided by the context is bound instead.\n this.context.unbindVAO();\n\n context.bindElementBuffer.set(this.buffer);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);\n\n if (!this.dynamicDraw) {\n delete array.arrayBuffer;\n }\n }\n\n bind() {\n this.context.bindElementBuffer.set(this.buffer);\n }\n\n updateData(array: StructArray) {\n const gl = this.context.gl;\n if (!this.dynamicDraw) throw new Error('Attempted to update data while not in dynamic mode.');\n // The right VAO will get this buffer re-bound later in VertexArrayObject#bind\n // See https://github.com/mapbox/mapbox-gl-js/issues/5620\n this.context.unbindVAO();\n this.bind();\n gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, array.arrayBuffer);\n }\n\n destroy() {\n const gl = this.context.gl;\n if (this.buffer) {\n gl.deleteBuffer(this.buffer);\n delete this.buffer;\n }\n }\n}\n","\nimport type {\n StructArray,\n StructArrayMember\n} from '../util/struct_array';\n\nimport type {Program} from '../render/program';\nimport type {Context} from '../gl/context';\n\n/**\n * An Enum for AttributeType\n */\nconst AttributeType = {\n Int8: 'BYTE',\n Uint8: 'UNSIGNED_BYTE',\n Int16: 'SHORT',\n Uint16: 'UNSIGNED_SHORT',\n Int32: 'INT',\n Uint32: 'UNSIGNED_INT',\n Float32: 'FLOAT'\n};\n\n/**\n * @internal\n * The `VertexBuffer` class turns a `StructArray` into a WebGL buffer. Each member of the StructArray's\n * Struct type is converted to a WebGL attribute.\n */\nexport class VertexBuffer {\n length: number;\n attributes: ReadonlyArray;\n itemSize: number;\n dynamicDraw: boolean;\n context: Context;\n buffer: WebGLBuffer;\n\n /**\n * @param dynamicDraw - Whether this buffer will be repeatedly updated.\n */\n constructor(context: Context, array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) {\n this.length = array.length;\n this.attributes = attributes;\n this.itemSize = array.bytesPerElement;\n this.dynamicDraw = dynamicDraw;\n\n this.context = context;\n const gl = context.gl;\n this.buffer = gl.createBuffer();\n context.bindVertexBuffer.set(this.buffer);\n gl.bufferData(gl.ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);\n\n if (!this.dynamicDraw) {\n delete array.arrayBuffer;\n }\n }\n\n bind() {\n this.context.bindVertexBuffer.set(this.buffer);\n }\n\n updateData(array: StructArray) {\n if (array.length !== this.length) throw new Error(`Length of new data is ${array.length}, which doesn't match current length of ${this.length}`);\n const gl = this.context.gl;\n this.bind();\n gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer);\n }\n\n enableAttributes(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program) {\n for (let j = 0; j < this.attributes.length; j++) {\n const member = this.attributes[j];\n const attribIndex: number | void = program.attributes[member.name];\n if (attribIndex !== undefined) {\n gl.enableVertexAttribArray(attribIndex);\n }\n }\n }\n\n /**\n * Set the attribute pointers in a WebGL context\n * @param gl - The WebGL context\n * @param program - The active WebGL program\n * @param vertexOffset - Index of the starting vertex of the segment\n */\n setVertexAttribPointers(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program, vertexOffset?: number | null) {\n for (let j = 0; j < this.attributes.length; j++) {\n const member = this.attributes[j];\n const attribIndex: number | void = program.attributes[member.name];\n\n if (attribIndex !== undefined) {\n gl.vertexAttribPointer(\n attribIndex,\n member.components,\n (gl as any)[AttributeType[member.type]],\n false,\n this.itemSize,\n member.offset + (this.itemSize * (vertexOffset || 0))\n );\n }\n }\n }\n\n /**\n * Destroy the GL buffer bound to the given WebGL context\n */\n destroy() {\n const gl = this.context.gl;\n if (this.buffer) {\n gl.deleteBuffer(this.buffer);\n delete this.buffer;\n }\n }\n}\n","const cache = new WeakMap();\nexport function isWebGL2(\n gl: WebGLRenderingContext | WebGL2RenderingContext\n): gl is WebGL2RenderingContext {\n if (cache.has(gl)) {\n return cache.get(gl);\n } else {\n const value = gl.getParameter(gl.VERSION)?.startsWith('WebGL 2.0');\n cache.set(gl, value);\n return value;\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {isWebGL2} from './webgl2';\n\nimport type {Context} from './context';\nimport type {\n BlendFuncType,\n BlendEquationType,\n ColorMaskType,\n DepthRangeType,\n DepthMaskType,\n StencilFuncType,\n StencilOpType,\n DepthFuncType,\n TextureUnitType,\n ViewportType,\n CullFaceModeType,\n FrontFaceType,\n} from './types';\n\nexport interface IValue {\n current: T;\n default: T;\n dirty: boolean;\n get(): T;\n setDefault(): void;\n set(value: T): void;\n}\n\nclass BaseValue implements IValue {\n gl: WebGLRenderingContext|WebGL2RenderingContext;\n current: T;\n default: T;\n dirty: boolean;\n\n constructor(context: Context) {\n this.gl = context.gl;\n this.default = this.getDefault();\n this.current = this.default;\n this.dirty = false;\n }\n\n get(): T {\n return this.current;\n }\n set(value: T) { // eslint-disable-line\n // overridden in child classes;\n }\n\n getDefault(): T {\n return this.default; // overriden in child classes\n }\n setDefault() {\n this.set(this.default);\n }\n}\n\nexport class ClearColor extends BaseValue {\n getDefault(): Color {\n return Color.transparent;\n }\n set(v: Color) {\n const c = this.current;\n if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return;\n this.gl.clearColor(v.r, v.g, v.b, v.a);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ClearDepth extends BaseValue {\n getDefault(): number {\n return 1;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n this.gl.clearDepth(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ClearStencil extends BaseValue {\n getDefault(): number {\n return 0;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n this.gl.clearStencil(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ColorMask extends BaseValue {\n getDefault(): ColorMaskType {\n return [true, true, true, true];\n }\n set(v: ColorMaskType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return;\n this.gl.colorMask(v[0], v[1], v[2], v[3]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthMask extends BaseValue {\n getDefault(): DepthMaskType {\n return true;\n }\n set(v: DepthMaskType): void {\n if (v === this.current && !this.dirty) return;\n this.gl.depthMask(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilMask extends BaseValue {\n getDefault(): number {\n return 0xFF;\n }\n set(v: number): void {\n if (v === this.current && !this.dirty) return;\n this.gl.stencilMask(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilFunc extends BaseValue {\n getDefault(): StencilFuncType {\n return {\n func: this.gl.ALWAYS,\n ref: 0,\n mask: 0xFF\n };\n }\n set(v: StencilFuncType): void {\n const c = this.current;\n if (v.func === c.func && v.ref === c.ref && v.mask === c.mask && !this.dirty) return;\n this.gl.stencilFunc(v.func, v.ref, v.mask);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilOp extends BaseValue {\n getDefault(): StencilOpType {\n const gl = this.gl;\n return [gl.KEEP, gl.KEEP, gl.KEEP];\n }\n set(v: StencilOpType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && !this.dirty) return;\n this.gl.stencilOp(v[0], v[1], v[2]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class StencilTest extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.STENCIL_TEST);\n } else {\n gl.disable(gl.STENCIL_TEST);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthRange extends BaseValue {\n getDefault(): DepthRangeType {\n return [0, 1];\n }\n set(v: DepthRangeType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return;\n this.gl.depthRange(v[0], v[1]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthTest extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.DEPTH_TEST);\n } else {\n gl.disable(gl.DEPTH_TEST);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthFunc extends BaseValue {\n getDefault(): DepthFuncType {\n return this.gl.LESS;\n }\n set(v: DepthFuncType) {\n if (v === this.current && !this.dirty) return;\n this.gl.depthFunc(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class Blend extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.BLEND);\n } else {\n gl.disable(gl.BLEND);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendFunc extends BaseValue {\n getDefault(): BlendFuncType {\n const gl = this.gl;\n return [gl.ONE, gl.ZERO];\n }\n set(v: BlendFuncType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return;\n this.gl.blendFunc(v[0], v[1]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendColor extends BaseValue {\n getDefault(): Color {\n return Color.transparent;\n }\n set(v: Color) {\n const c = this.current;\n if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return;\n this.gl.blendColor(v.r, v.g, v.b, v.a);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BlendEquation extends BaseValue {\n getDefault(): BlendEquationType {\n return this.gl.FUNC_ADD;\n }\n set(v: BlendEquationType) {\n if (v === this.current && !this.dirty) return;\n this.gl.blendEquation(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class CullFace extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n if (v) {\n gl.enable(gl.CULL_FACE);\n } else {\n gl.disable(gl.CULL_FACE);\n }\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class CullFaceSide extends BaseValue {\n getDefault(): CullFaceModeType {\n return this.gl.BACK;\n }\n set(v: CullFaceModeType) {\n if (v === this.current && !this.dirty) return;\n this.gl.cullFace(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class FrontFace extends BaseValue {\n getDefault(): FrontFaceType {\n return this.gl.CCW;\n }\n set(v: FrontFaceType) {\n if (v === this.current && !this.dirty) return;\n this.gl.frontFace(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ProgramValue extends BaseValue {\n getDefault(): WebGLProgram {\n return null;\n }\n set(v?: WebGLProgram | null) {\n if (v === this.current && !this.dirty) return;\n this.gl.useProgram(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class ActiveTextureUnit extends BaseValue {\n getDefault(): TextureUnitType {\n return this.gl.TEXTURE0;\n }\n set(v: TextureUnitType) {\n if (v === this.current && !this.dirty) return;\n this.gl.activeTexture(v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class Viewport extends BaseValue {\n getDefault(): ViewportType {\n const gl = this.gl;\n return [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight];\n }\n set(v: ViewportType) {\n const c = this.current;\n if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return;\n this.gl.viewport(v[0], v[1], v[2], v[3]);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindFramebuffer extends BaseValue {\n getDefault(): WebGLFramebuffer {\n return null;\n }\n set(v?: WebGLFramebuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindFramebuffer(gl.FRAMEBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindRenderbuffer extends BaseValue {\n getDefault(): WebGLRenderbuffer {\n return null;\n }\n set(v?: WebGLRenderbuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindRenderbuffer(gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindTexture extends BaseValue {\n getDefault(): WebGLTexture {\n return null;\n }\n set(v?: WebGLTexture | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindVertexBuffer extends BaseValue {\n getDefault(): WebGLBuffer {\n return null;\n }\n set(v?: WebGLBuffer | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.bindBuffer(gl.ARRAY_BUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindElementBuffer extends BaseValue {\n getDefault(): WebGLBuffer {\n return null;\n }\n set(v?: WebGLBuffer | null) {\n // Always rebind\n const gl = this.gl;\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class BindVertexArray extends BaseValue {\n getDefault(): WebGLVertexArrayObject | null {\n return null;\n }\n set(v: WebGLVertexArrayObject | null) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n\n if (isWebGL2(gl)) {\n gl.bindVertexArray(v);\n } else {\n gl.getExtension('OES_vertex_array_object')?.bindVertexArrayOES(v);\n }\n\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpack extends BaseValue {\n getDefault(): number {\n return 4;\n }\n set(v: number) {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpackPremultiplyAlpha extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean): void {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, ((v as any)));\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class PixelStoreUnpackFlipY extends BaseValue {\n getDefault(): boolean {\n return false;\n }\n set(v: boolean): void {\n if (v === this.current && !this.dirty) return;\n const gl = this.gl;\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, ((v as any)));\n this.current = v;\n this.dirty = false;\n }\n}\n\nclass FramebufferAttachment extends BaseValue {\n parent: WebGLFramebuffer;\n context: Context;\n\n constructor(context: Context, parent: WebGLFramebuffer) {\n super(context);\n this.context = context;\n this.parent = parent;\n }\n getDefault() {\n return null;\n }\n}\n\nexport class ColorAttachment extends FramebufferAttachment {\n setDirty() {\n this.dirty = true;\n }\n set(v?: WebGLTexture | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a renderbuffer to the color\n // attachment point, but thus far MBGL only uses textures for color\n const gl = this.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, v, 0);\n\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthAttachment extends FramebufferAttachment {\n set(v?: WebGLRenderbuffer | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a texture to the depth attachment\n // point, but thus far MBGL only uses renderbuffers for depth\n const gl = this.gl;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n\nexport class DepthStencilAttachment extends FramebufferAttachment {\n set(v?: WebGLRenderbuffer | null): void {\n if (v === this.current && !this.dirty) return;\n this.context.bindFramebuffer.set(this.parent);\n // note: it's possible to attach a texture to the depth attachment\n // point, but thus far MBGL only uses renderbuffers for depth\n const gl = this.gl;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, v);\n this.current = v;\n this.dirty = false;\n }\n}\n","import {ColorAttachment, DepthAttachment, DepthStencilAttachment} from './value';\n\nimport type {Context} from './context';\n\n/**\n * @internal\n * A framebuffer holder object\n */\nexport class Framebuffer {\n context: Context;\n width: number;\n height: number;\n framebuffer: WebGLFramebuffer;\n colorAttachment: ColorAttachment;\n depthAttachment: DepthAttachment;\n\n constructor(context: Context, width: number, height: number, hasDepth: boolean, hasStencil: boolean) {\n this.context = context;\n this.width = width;\n this.height = height;\n const gl = context.gl;\n const fbo = this.framebuffer = gl.createFramebuffer();\n\n this.colorAttachment = new ColorAttachment(context, fbo);\n if (hasDepth) {\n this.depthAttachment = hasStencil ? new DepthStencilAttachment(context, fbo) : new DepthAttachment(context, fbo);\n } else if (hasStencil) {\n throw new Error('Stencil cannot be setted without depth');\n }\n if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error('Framebuffer is not complete');\n }\n }\n\n destroy() {\n const gl = this.context.gl;\n\n const texture = this.colorAttachment.get();\n if (texture) gl.deleteTexture(texture);\n\n if (this.depthAttachment) {\n const renderbuffer = this.depthAttachment.get();\n if (renderbuffer) gl.deleteRenderbuffer(renderbuffer);\n }\n\n gl.deleteFramebuffer(this.framebuffer);\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\n\nimport type {BlendFuncType, ColorMaskType} from './types';\n\nconst ZERO = 0x0000;\nconst ONE = 0x0001;\nconst ONE_MINUS_SRC_ALPHA = 0x0303;\n\nexport class ColorMode {\n blendFunction: BlendFuncType;\n blendColor: Color;\n mask: ColorMaskType;\n\n constructor(blendFunction: BlendFuncType, blendColor: Color, mask: ColorMaskType) {\n this.blendFunction = blendFunction;\n this.blendColor = blendColor;\n this.mask = mask;\n }\n\n static Replace: BlendFuncType;\n\n static disabled: Readonly;\n static unblended: Readonly;\n static alphaBlended: Readonly;\n}\n\nColorMode.Replace = [ONE, ZERO];\n\nColorMode.disabled = new ColorMode(ColorMode.Replace, Color.transparent, [false, false, false, false]);\nColorMode.unblended = new ColorMode(ColorMode.Replace, Color.transparent, [true, true, true, true]);\nColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [true, true, true, true]);\n","import {IndexBuffer} from './index_buffer';\n\nimport {VertexBuffer} from './vertex_buffer';\nimport {Framebuffer} from './framebuffer';\nimport {DepthMode} from './depth_mode';\nimport {StencilMode} from './stencil_mode';\nimport {ColorMode} from './color_mode';\nimport {CullFaceMode} from './cull_face_mode';\nimport {deepEqual} from '../util/util';\nimport {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, BlendEquation, CullFace, CullFaceSide, FrontFace, ProgramValue, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArray, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha, PixelStoreUnpackFlipY} from './value';\n\nimport type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';\nimport type {\n StructArray,\n StructArrayMember\n} from '../util/struct_array';\nimport type {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {isWebGL2} from './webgl2';\n\ntype ClearArgs = {\n color?: Color;\n depth?: number;\n stencil?: number;\n};\n\n/**\n * @internal\n * A webgl wrapper class to allow injection, mocking and abstaction\n */\nexport class Context {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n\n currentNumAttributes: number;\n maxTextureSize: number;\n\n clearColor: ClearColor;\n clearDepth: ClearDepth;\n clearStencil: ClearStencil;\n colorMask: ColorMask;\n depthMask: DepthMask;\n stencilMask: StencilMask;\n stencilFunc: StencilFunc;\n stencilOp: StencilOp;\n stencilTest: StencilTest;\n depthRange: DepthRange;\n depthTest: DepthTest;\n depthFunc: DepthFunc;\n blend: Blend;\n blendFunc: BlendFunc;\n blendColor: BlendColor;\n blendEquation: BlendEquation;\n cullFace: CullFace;\n cullFaceSide: CullFaceSide;\n frontFace: FrontFace;\n program: ProgramValue;\n activeTexture: ActiveTextureUnit;\n viewport: Viewport;\n bindFramebuffer: BindFramebuffer;\n bindRenderbuffer: BindRenderbuffer;\n bindTexture: BindTexture;\n bindVertexBuffer: BindVertexBuffer;\n bindElementBuffer: BindElementBuffer;\n bindVertexArray: BindVertexArray;\n pixelStoreUnpack: PixelStoreUnpack;\n pixelStoreUnpackPremultiplyAlpha: PixelStoreUnpackPremultiplyAlpha;\n pixelStoreUnpackFlipY: PixelStoreUnpackFlipY;\n\n // eslint-disable-next-line camelcase\n extTextureFilterAnisotropic: EXT_texture_filter_anisotropic | null;\n extTextureFilterAnisotropicMax?: GLfloat;\n HALF_FLOAT?: GLenum;\n RGBA16F?: GLenum;\n RGB16F?: GLenum;\n\n constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) {\n this.gl = gl;\n this.clearColor = new ClearColor(this);\n this.clearDepth = new ClearDepth(this);\n this.clearStencil = new ClearStencil(this);\n this.colorMask = new ColorMask(this);\n this.depthMask = new DepthMask(this);\n this.stencilMask = new StencilMask(this);\n this.stencilFunc = new StencilFunc(this);\n this.stencilOp = new StencilOp(this);\n this.stencilTest = new StencilTest(this);\n this.depthRange = new DepthRange(this);\n this.depthTest = new DepthTest(this);\n this.depthFunc = new DepthFunc(this);\n this.blend = new Blend(this);\n this.blendFunc = new BlendFunc(this);\n this.blendColor = new BlendColor(this);\n this.blendEquation = new BlendEquation(this);\n this.cullFace = new CullFace(this);\n this.cullFaceSide = new CullFaceSide(this);\n this.frontFace = new FrontFace(this);\n this.program = new ProgramValue(this);\n this.activeTexture = new ActiveTextureUnit(this);\n this.viewport = new Viewport(this);\n this.bindFramebuffer = new BindFramebuffer(this);\n this.bindRenderbuffer = new BindRenderbuffer(this);\n this.bindTexture = new BindTexture(this);\n this.bindVertexBuffer = new BindVertexBuffer(this);\n this.bindElementBuffer = new BindElementBuffer(this);\n this.bindVertexArray = new BindVertexArray(this);\n this.pixelStoreUnpack = new PixelStoreUnpack(this);\n this.pixelStoreUnpackPremultiplyAlpha = new PixelStoreUnpackPremultiplyAlpha(this);\n this.pixelStoreUnpackFlipY = new PixelStoreUnpackFlipY(this);\n\n this.extTextureFilterAnisotropic = (\n gl.getExtension('EXT_texture_filter_anisotropic') ||\n gl.getExtension('MOZ_EXT_texture_filter_anisotropic') ||\n gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')\n );\n\n if (this.extTextureFilterAnisotropic) {\n this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\n }\n\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n\n if (isWebGL2(gl)) {\n this.HALF_FLOAT = gl.HALF_FLOAT;\n const extColorBufferHalfFloat = gl.getExtension('EXT_color_buffer_half_float');\n this.RGBA16F = gl.RGBA16F ?? extColorBufferHalfFloat?.RGBA16F_EXT;\n this.RGB16F = gl.RGB16F ?? extColorBufferHalfFloat?.RGB16F_EXT;\n gl.getExtension('EXT_color_buffer_float');\n } else {\n gl.getExtension('EXT_color_buffer_half_float');\n gl.getExtension('OES_texture_half_float_linear');\n const extTextureHalfFloat = gl.getExtension('OES_texture_half_float');\n this.HALF_FLOAT = extTextureHalfFloat?.HALF_FLOAT_OES;\n }\n }\n\n setDefault() {\n this.unbindVAO();\n\n this.clearColor.setDefault();\n this.clearDepth.setDefault();\n this.clearStencil.setDefault();\n this.colorMask.setDefault();\n this.depthMask.setDefault();\n this.stencilMask.setDefault();\n this.stencilFunc.setDefault();\n this.stencilOp.setDefault();\n this.stencilTest.setDefault();\n this.depthRange.setDefault();\n this.depthTest.setDefault();\n this.depthFunc.setDefault();\n this.blend.setDefault();\n this.blendFunc.setDefault();\n this.blendColor.setDefault();\n this.blendEquation.setDefault();\n this.cullFace.setDefault();\n this.cullFaceSide.setDefault();\n this.frontFace.setDefault();\n this.program.setDefault();\n this.activeTexture.setDefault();\n this.bindFramebuffer.setDefault();\n this.pixelStoreUnpack.setDefault();\n this.pixelStoreUnpackPremultiplyAlpha.setDefault();\n this.pixelStoreUnpackFlipY.setDefault();\n }\n\n setDirty() {\n this.clearColor.dirty = true;\n this.clearDepth.dirty = true;\n this.clearStencil.dirty = true;\n this.colorMask.dirty = true;\n this.depthMask.dirty = true;\n this.stencilMask.dirty = true;\n this.stencilFunc.dirty = true;\n this.stencilOp.dirty = true;\n this.stencilTest.dirty = true;\n this.depthRange.dirty = true;\n this.depthTest.dirty = true;\n this.depthFunc.dirty = true;\n this.blend.dirty = true;\n this.blendFunc.dirty = true;\n this.blendColor.dirty = true;\n this.blendEquation.dirty = true;\n this.cullFace.dirty = true;\n this.cullFaceSide.dirty = true;\n this.frontFace.dirty = true;\n this.program.dirty = true;\n this.activeTexture.dirty = true;\n this.viewport.dirty = true;\n this.bindFramebuffer.dirty = true;\n this.bindRenderbuffer.dirty = true;\n this.bindTexture.dirty = true;\n this.bindVertexBuffer.dirty = true;\n this.bindElementBuffer.dirty = true;\n this.bindVertexArray.dirty = true;\n this.pixelStoreUnpack.dirty = true;\n this.pixelStoreUnpackPremultiplyAlpha.dirty = true;\n this.pixelStoreUnpackFlipY.dirty = true;\n }\n\n createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) {\n return new IndexBuffer(this, array, dynamicDraw);\n }\n\n createVertexBuffer(array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) {\n return new VertexBuffer(this, array, attributes, dynamicDraw);\n }\n\n createRenderbuffer(storageFormat: number, width: number, height: number) {\n const gl = this.gl;\n\n const rbo = gl.createRenderbuffer();\n this.bindRenderbuffer.set(rbo);\n gl.renderbufferStorage(gl.RENDERBUFFER, storageFormat, width, height);\n this.bindRenderbuffer.set(null);\n\n return rbo;\n }\n\n createFramebuffer(width: number, height: number, hasDepth: boolean, hasStencil: boolean) {\n return new Framebuffer(this, width, height, hasDepth, hasStencil);\n }\n\n clear({\n color,\n depth,\n stencil\n }: ClearArgs) {\n const gl = this.gl;\n let mask = 0;\n\n if (color) {\n mask |= gl.COLOR_BUFFER_BIT;\n this.clearColor.set(color);\n this.colorMask.set([true, true, true, true]);\n }\n\n if (typeof depth !== 'undefined') {\n mask |= gl.DEPTH_BUFFER_BIT;\n\n // Workaround for platforms where clearDepth doesn't seem to work\n // without resetting the depthRange. See https://github.com/mapbox/mapbox-gl-js/issues/3437\n this.depthRange.set([0, 1]);\n\n this.clearDepth.set(depth);\n this.depthMask.set(true);\n }\n\n if (typeof stencil !== 'undefined') {\n mask |= gl.STENCIL_BUFFER_BIT;\n this.clearStencil.set(stencil);\n this.stencilMask.set(0xFF);\n }\n\n gl.clear(mask);\n }\n\n setCullFace(cullFaceMode: Readonly) {\n if (cullFaceMode.enable === false) {\n this.cullFace.set(false);\n } else {\n this.cullFace.set(true);\n this.cullFaceSide.set(cullFaceMode.mode);\n this.frontFace.set(cullFaceMode.frontFace);\n }\n }\n\n setDepthMode(depthMode: Readonly) {\n if (depthMode.func === this.gl.ALWAYS && !depthMode.mask) {\n this.depthTest.set(false);\n } else {\n this.depthTest.set(true);\n this.depthFunc.set(depthMode.func);\n this.depthMask.set(depthMode.mask);\n this.depthRange.set(depthMode.range);\n }\n }\n\n setStencilMode(stencilMode: Readonly) {\n if (stencilMode.test.func === this.gl.ALWAYS && !stencilMode.mask) {\n this.stencilTest.set(false);\n } else {\n this.stencilTest.set(true);\n this.stencilMask.set(stencilMode.mask);\n this.stencilOp.set([stencilMode.fail, stencilMode.depthFail, stencilMode.pass]);\n this.stencilFunc.set({\n func: stencilMode.test.func,\n ref: stencilMode.ref,\n mask: stencilMode.test.mask\n });\n }\n }\n\n setColorMode(colorMode: Readonly) {\n if (deepEqual(colorMode.blendFunction, ColorMode.Replace)) {\n this.blend.set(false);\n } else {\n this.blend.set(true);\n this.blendFunc.set(colorMode.blendFunction);\n this.blendColor.set(colorMode.blendColor);\n }\n\n this.colorMask.set(colorMode.mask);\n }\n\n createVertexArray(): WebGLVertexArrayObject | undefined {\n if (isWebGL2(this.gl))\n return this.gl.createVertexArray();\n return this.gl.getExtension('OES_vertex_array_object')?.createVertexArrayOES();\n }\n\n deleteVertexArray(x: WebGLVertexArrayObject | undefined) {\n if (isWebGL2(this.gl))\n return this.gl.deleteVertexArray(x);\n return this.gl.getExtension('OES_vertex_array_object')?.deleteVertexArrayOES(x);\n }\n\n unbindVAO() {\n // Unbinding the VAO prevents other things (custom layers, new buffer creation) from\n // unintentionally changing the state of the last VAO used.\n this.bindVertexArray.set(null);\n }\n}\n","import type {DepthFuncType, DepthMaskType, DepthRangeType} from './types';\n\nconst ALWAYS = 0x0207;\n\nexport class DepthMode {\n func: DepthFuncType;\n mask: DepthMaskType;\n range: DepthRangeType;\n\n // DepthMask enums\n static ReadOnly: boolean;\n static ReadWrite: boolean;\n\n constructor(depthFunc: DepthFuncType, depthMask: DepthMaskType, depthRange: DepthRangeType) {\n this.func = depthFunc;\n this.mask = depthMask;\n this.range = depthRange;\n }\n\n static disabled: Readonly;\n}\n\nDepthMode.ReadOnly = false;\nDepthMode.ReadWrite = true;\n\nDepthMode.disabled = new DepthMode(ALWAYS, DepthMode.ReadOnly, [0, 1]);\n","import type {StencilOpConstant, StencilTestGL} from './types';\n\nconst ALWAYS = 0x0207;\nconst KEEP = 0x1E00;\n\nexport class StencilMode {\n test: StencilTestGL;\n ref: number;\n mask: number;\n fail: StencilOpConstant;\n depthFail: StencilOpConstant;\n pass: StencilOpConstant;\n\n constructor(test: StencilTestGL, ref: number, mask: number, fail: StencilOpConstant,\n depthFail: StencilOpConstant, pass: StencilOpConstant) {\n this.test = test;\n this.ref = ref;\n this.mask = mask;\n this.fail = fail;\n this.depthFail = depthFail;\n this.pass = pass;\n }\n\n static disabled: Readonly;\n}\n\nStencilMode.disabled = new StencilMode({func: ALWAYS, mask: 0}, 0, 0, KEEP, KEEP, KEEP);\n","import type {CullFaceModeType, FrontFaceType} from './types';\n\nconst BACK = 0x0405;\nconst CCW = 0x0901;\n\nexport class CullFaceMode {\n enable: boolean;\n mode: CullFaceModeType;\n frontFace: FrontFaceType;\n\n constructor(enable: boolean, mode: CullFaceModeType, frontFace: FrontFaceType) {\n this.enable = enable;\n this.mode = mode;\n this.frontFace = frontFace;\n }\n\n static disabled: Readonly;\n static backCCW: Readonly;\n}\n\nCullFaceMode.disabled = new CullFaceMode(false, BACK, CCW);\nCullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW);\n","import type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {SymbolBucket} from '../data/bucket/symbol_bucket';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {collisionUniformValues, collisionCircleUniformValues} from './program/collision_program';\n\nimport {QuadTriangleArray, CollisionCircleLayoutArray} from '../data/array_types.g';\nimport {collisionCircleLayout} from '../data/bucket/symbol_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {mat4} from 'gl-matrix';\nimport {VertexBuffer} from '../gl/vertex_buffer';\nimport {IndexBuffer} from '../gl/index_buffer';\n\ntype TileBatch = {\n circleArray: Array;\n circleOffset: number;\n transform: mat4;\n invTransform: mat4;\n coord: OverscaledTileID;\n};\n\nlet quadTriangles: QuadTriangleArray;\n\nexport function drawCollisionDebug(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array, translate: [number, number], translateAnchor: 'map' | 'viewport', isText: boolean) {\n const context = painter.context;\n const gl = context.gl;\n const program = painter.useProgram('collisionBox');\n const tileBatches: Array = [];\n let circleCount = 0;\n let circleOffset = 0;\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n const tile = sourceCache.getTile(coord);\n const bucket: SymbolBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n let posMatrix = coord.posMatrix;\n if (translate[0] !== 0 || translate[1] !== 0) {\n posMatrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor);\n }\n const buffers = isText ? bucket.textCollisionBox : bucket.iconCollisionBox;\n // Get collision circle data of this bucket\n const circleArray: Array = bucket.collisionCircleArray;\n if (circleArray.length > 0) {\n // We need to know the projection matrix that was used for projecting collision circles to the screen.\n // This might vary between buckets as the symbol placement is a continuous process. This matrix is\n // required for transforming points from previous screen space to the current one\n const invTransform = mat4.create();\n const transform = posMatrix;\n\n mat4.mul(invTransform, bucket.placementInvProjMatrix, painter.transform.glCoordMatrix);\n mat4.mul(invTransform, invTransform, bucket.placementViewportMatrix);\n\n tileBatches.push({\n circleArray,\n circleOffset,\n transform,\n invTransform,\n coord\n });\n\n circleCount += circleArray.length / 4; // 4 values per circle\n circleOffset = circleCount;\n }\n if (!buffers) continue;\n program.draw(context, gl.LINES,\n DepthMode.disabled, StencilMode.disabled,\n painter.colorModeForRenderPass(),\n CullFaceMode.disabled,\n collisionUniformValues(\n posMatrix,\n painter.transform,\n tile),\n painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord),\n layer.id, buffers.layoutVertexBuffer, buffers.indexBuffer,\n buffers.segments, null, painter.transform.zoom, null, null,\n buffers.collisionVertexBuffer);\n }\n\n if (!isText || !tileBatches.length) {\n return;\n }\n\n // Render collision circles\n const circleProgram = painter.useProgram('collisionCircle');\n\n // Construct vertex data\n const vertexData = new CollisionCircleLayoutArray();\n vertexData.resize(circleCount * 4);\n vertexData._trim();\n\n let vertexOffset = 0;\n\n for (const batch of tileBatches) {\n for (let i = 0; i < batch.circleArray.length / 4; i++) {\n const circleIdx = i * 4;\n const x = batch.circleArray[circleIdx + 0];\n const y = batch.circleArray[circleIdx + 1];\n const radius = batch.circleArray[circleIdx + 2];\n const collision = batch.circleArray[circleIdx + 3];\n\n // 4 floats per vertex, 4 vertices per quad\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 0);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 1);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 2);\n vertexData.emplace(vertexOffset++, x, y, radius, collision, 3);\n }\n }\n if (!quadTriangles || quadTriangles.length < circleCount * 2) {\n quadTriangles = createQuadTriangles(circleCount);\n }\n\n const indexBuffer: IndexBuffer = context.createIndexBuffer(quadTriangles, true);\n const vertexBuffer: VertexBuffer = context.createVertexBuffer(vertexData, collisionCircleLayout.members, true);\n\n // Render batches\n for (const batch of tileBatches) {\n const uniforms = collisionCircleUniformValues(\n batch.transform,\n batch.invTransform,\n painter.transform\n );\n\n circleProgram.draw(\n context,\n gl.TRIANGLES,\n DepthMode.disabled,\n StencilMode.disabled,\n painter.colorModeForRenderPass(),\n CullFaceMode.disabled,\n uniforms,\n painter.style.map.terrain && painter.style.map.terrain.getTerrainData(batch.coord),\n layer.id,\n vertexBuffer,\n indexBuffer,\n SegmentVector.simpleSegment(0, batch.circleOffset * 2, batch.circleArray.length, batch.circleArray.length / 2),\n null,\n painter.transform.zoom,\n null,\n null,\n null);\n }\n\n vertexBuffer.destroy();\n indexBuffer.destroy();\n}\n\nfunction createQuadTriangles(quadCount: number): QuadTriangleArray {\n const triCount = quadCount * 2;\n const array = new QuadTriangleArray();\n\n array.resize(triCount);\n array._trim();\n\n // Two triangles and 4 vertices per quad.\n for (let i = 0; i < triCount; i++) {\n const idx = i * 6;\n\n array.uint16[idx + 0] = i * 4 + 0;\n array.uint16[idx + 1] = i * 4 + 1;\n array.uint16[idx + 2] = i * 4 + 2;\n array.uint16[idx + 3] = i * 4 + 2;\n array.uint16[idx + 4] = i * 4 + 3;\n array.uint16[idx + 5] = i * 4 + 0;\n }\n\n return array;\n}\n","import Point from '@mapbox/point-geometry';\nimport {drawCollisionDebug} from './draw_collision_debug';\n\nimport {SegmentVector} from '../data/segment';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport * as symbolProjection from '../symbol/projection';\nimport {EvaluatedZoomSize, evaluateSizeForFeature, evaluateSizeForZoom} from '../symbol/symbol_size';\nimport {mat4} from 'gl-matrix';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {addDynamicAttributes} from '../data/bucket/symbol_bucket';\n\nimport {getAnchorAlignment, WritingMode} from '../symbol/shaping';\nimport ONE_EM from '../symbol/one_em';\n\nimport {\n SymbolIconUniformsType,\n symbolIconUniformValues,\n symbolSDFUniformValues,\n symbolTextAndIconUniformValues\n} from './program/symbol_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';\n\nimport type {Texture} from '../render/texture';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport type {UniformValues} from './uniform_binding';\nimport type {SymbolSDFUniformsType} from '../render/program/symbol_program';\nimport type {CrossTileID, VariableOffset} from '../symbol/placement';\nimport type {SymbolBucket, SymbolBuffers} from '../data/bucket/symbol_bucket';\nimport type {TerrainData} from '../render/terrain';\nimport type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {Transform} from '../geo/transform';\nimport type {ColorMode} from '../gl/color_mode';\nimport type {Program} from './program';\nimport type {TextAnchor} from '../style/style_layer/variable_text_anchor';\n\ntype SymbolTileRenderState = {\n segments: SegmentVector;\n sortKey: number;\n terrainData: TerrainData;\n state: {\n program: Program;\n buffers: SymbolBuffers;\n uniformValues: UniformValues;\n atlasTexture: Texture;\n atlasTextureIcon: Texture | null;\n atlasInterpolation: GLenum;\n atlasInterpolationIcon: GLenum;\n isSDF: boolean;\n hasHalo: boolean;\n };\n};\n\nconst identityMat4 = mat4.identity(new Float32Array(16));\n\nexport function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array, variableOffsets: {\n [_ in CrossTileID]: VariableOffset;\n}) {\n if (painter.renderPass !== 'translucent') return;\n\n // Disable the stencil test so that labels aren't clipped to tile boundaries.\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n\n //Compute variable-offsets before painting since icons and text data positioning\n //depend on each other in this case.\n if (hasVariablePlacement) {\n updateVariableAnchors(coords, painter, layer, sourceCache,\n layer.layout.get('text-rotation-alignment'),\n layer.layout.get('text-pitch-alignment'),\n variableOffsets\n );\n }\n\n if (layer.paint.get('icon-opacity').constantOr(1) !== 0) {\n drawLayerSymbols(painter, sourceCache, layer, coords, false,\n layer.paint.get('icon-translate'),\n layer.paint.get('icon-translate-anchor'),\n layer.layout.get('icon-rotation-alignment'),\n layer.layout.get('icon-pitch-alignment'),\n layer.layout.get('icon-keep-upright'),\n stencilMode, colorMode\n );\n }\n\n if (layer.paint.get('text-opacity').constantOr(1) !== 0) {\n drawLayerSymbols(painter, sourceCache, layer, coords, true,\n layer.paint.get('text-translate'),\n layer.paint.get('text-translate-anchor'),\n layer.layout.get('text-rotation-alignment'),\n layer.layout.get('text-pitch-alignment'),\n layer.layout.get('text-keep-upright'),\n stencilMode, colorMode\n );\n }\n\n if (sourceCache.map.showCollisionBoxes) {\n drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'),\n layer.paint.get('text-translate-anchor'), true);\n drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'),\n layer.paint.get('icon-translate-anchor'), false);\n }\n}\n\nfunction calculateVariableRenderShift(\n anchor: TextAnchor,\n width: number,\n height: number,\n textOffset: [number, number],\n textBoxScale: number,\n renderTextSize: number): Point {\n const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);\n const shiftX = -(horizontalAlign - 0.5) * width;\n const shiftY = -(verticalAlign - 0.5) * height;\n return new Point(\n (shiftX / textBoxScale + textOffset[0]) * renderTextSize,\n (shiftY / textBoxScale + textOffset[1]) * renderTextSize\n );\n}\n\nfunction updateVariableAnchors(coords: Array,\n painter: Painter,\n layer:SymbolStyleLayer, sourceCache: SourceCache,\n rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'],\n pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'],\n variableOffsets: {[_ in CrossTileID]: VariableOffset}) {\n const tr = painter.transform;\n const rotateWithMap = rotationAlignment === 'map';\n const pitchWithMap = pitchAlignment === 'map';\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n const bucket = tile.getBucket(layer) as SymbolBucket;\n if (!bucket || !bucket.text || !bucket.text.segments.get().length) continue;\n\n const sizeData = bucket.textSizeData;\n const size = evaluateSizeForZoom(sizeData, tr.zoom);\n\n const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom);\n const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale);\n const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData();\n\n if (size) {\n const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ);\n const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null;\n updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets,\n tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon, getElevation);\n }\n }\n}\n\nfunction updateVariableAnchorsForBucket(\n bucket: SymbolBucket,\n rotateWithMap: boolean,\n pitchWithMap: boolean,\n variableOffsets: {[_ in CrossTileID]: VariableOffset},\n transform: Transform,\n labelPlaneMatrix: mat4,\n posMatrix: mat4,\n tileScale: number,\n size: EvaluatedZoomSize,\n updateTextFitIcon: boolean,\n getElevation: (x: number, y: number) => number) {\n const placedSymbols = bucket.text.placedSymbolArray;\n const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray;\n const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray;\n const placedTextShifts = {};\n\n dynamicTextLayoutVertexArray.clear();\n for (let s = 0; s < placedSymbols.length; s++) {\n const symbol = placedSymbols.get(s);\n const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation;\n const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null;\n\n if (!variableOffset) {\n // These symbols are from a justification that is not being used, or a label that wasn't placed\n // so we don't need to do the extra math to figure out what incremental shift to apply.\n symbolProjection.hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray);\n } else {\n const tileAnchor = new Point(symbol.anchorX, symbol.anchorY);\n const projectedAnchor = symbolProjection.project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix, getElevation);\n const perspectiveRatio = symbolProjection.getPerspectiveRatio(transform.cameraToCenterDistance, projectedAnchor.signedDistanceFromCamera);\n let renderTextSize = evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / ONE_EM;\n if (pitchWithMap) {\n // Go from size in pixels to equivalent size in tile units\n renderTextSize *= bucket.tilePixelRatio / tileScale;\n }\n\n const {width, height, anchor, textOffset, textBoxScale} = variableOffset;\n\n const shift = calculateVariableRenderShift(\n anchor, width, height, textOffset, textBoxScale, renderTextSize);\n\n // Usual case is that we take the projected anchor and add the pixel-based shift\n // calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent\n // tile-unit based shift to the anchor before projecting to the label plane.\n const shiftedAnchor = pitchWithMap ?\n symbolProjection.project(tileAnchor.add(shift), labelPlaneMatrix, getElevation).point :\n projectedAnchor.point.add(rotateWithMap ?\n shift.rotate(-transform.angle) :\n shift);\n\n const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === WritingMode.vertical) ? Math.PI / 2 : 0;\n for (let g = 0; g < symbol.numGlyphs; g++) {\n addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle);\n }\n //Only offset horizontal text icons\n if (updateTextFitIcon && symbol.associatedIconIndex >= 0) {\n placedTextShifts[symbol.associatedIconIndex] = {shiftedAnchor, angle};\n }\n }\n }\n\n if (updateTextFitIcon) {\n dynamicIconLayoutVertexArray.clear();\n const placedIcons = bucket.icon.placedSymbolArray;\n for (let i = 0; i < placedIcons.length; i++) {\n const placedIcon = placedIcons.get(i);\n if (placedIcon.hidden) {\n symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);\n } else {\n const shift = placedTextShifts[i];\n if (!shift) {\n symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);\n } else {\n for (let g = 0; g < placedIcon.numGlyphs; g++) {\n addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle);\n }\n }\n }\n }\n bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray);\n }\n bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray);\n}\n\nfunction getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) {\n if (bucket.iconsInText && isText) {\n return 'symbolTextAndIcon';\n } else if (isSDF) {\n return 'symbolSDF';\n } else {\n return 'symbolIcon';\n }\n}\n\nfunction drawLayerSymbols(\n painter: Painter,\n sourceCache: SourceCache,\n layer: SymbolStyleLayer,\n coords: Array,\n isText: boolean,\n translate: [number, number],\n translateAnchor: 'map' | 'viewport',\n rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'],\n pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'],\n keepUpright: boolean,\n stencilMode: StencilMode,\n colorMode: Readonly) {\n\n const context = painter.context;\n const gl = context.gl;\n const tr = painter.transform;\n\n const rotateWithMap = rotationAlignment === 'map';\n const pitchWithMap = pitchAlignment === 'map';\n const alongLine = rotationAlignment !== 'viewport' && layer.layout.get('symbol-placement') !== 'point';\n // Line label rotation happens in `updateLineLabels`\n // Pitched point labels are automatically rotated by the labelPlaneMatrix projection\n // Unpitched point labels need to have their rotation applied after projection\n const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;\n\n const hasSortKey = !layer.layout.get('symbol-sort-key').isConstant();\n let sortFeaturesByKey = false;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n\n const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');\n\n const tileRenderState: Array = [];\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n const bucket = tile.getBucket(layer) as SymbolBucket;\n if (!bucket) continue;\n const buffers = isText ? bucket.text : bucket.icon;\n\n if (!buffers || !buffers.segments.get().length || !buffers.hasVisibleVertices) continue;\n const programConfiguration = buffers.programConfigurations.get(layer.id);\n\n const isSDF = isText || bucket.sdfIcons;\n\n const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;\n const transformed = pitchWithMap || tr.pitch !== 0;\n\n const program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration);\n const size = evaluateSizeForZoom(sizeData, tr.zoom);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n let texSize: [number, number];\n let texSizeIcon: [number, number] = [0, 0];\n let atlasTexture: Texture;\n let atlasInterpolation: GLenum;\n let atlasTextureIcon = null;\n let atlasInterpolationIcon: GLenum;\n if (isText) {\n atlasTexture = tile.glyphAtlasTexture;\n atlasInterpolation = gl.LINEAR;\n texSize = tile.glyphAtlasTexture.size;\n if (bucket.iconsInText) {\n texSizeIcon = tile.imageAtlasTexture.size;\n atlasTextureIcon = tile.imageAtlasTexture;\n const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera';\n atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST;\n }\n } else {\n const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;\n atlasTexture = tile.imageAtlasTexture;\n atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ?\n gl.LINEAR :\n gl.NEAREST;\n texSize = tile.imageAtlasTexture.size;\n }\n\n const s = pixelsToTileUnits(tile, 1, painter.transform.zoom);\n const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);\n const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);\n\n const hasVariableAnchors = hasVariablePlacement && bucket.hasTextData();\n const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&\n hasVariableAnchors &&\n bucket.hasIconData();\n\n if (alongLine) {\n const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null;\n const rotateToLine = layer.layout.get('text-rotation-alignment') === 'map';\n symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright, rotateToLine, getElevation);\n }\n\n const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),\n uLabelPlaneMatrix = (alongLine || (isText && hasVariablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,\n uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);\n\n const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;\n\n let uniformValues: UniformValues;\n if (isSDF) {\n if (!bucket.iconsInText) {\n uniformValues = symbolSDFUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);\n } else {\n uniformValues = symbolTextAndIconUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);\n }\n } else {\n uniformValues = symbolIconUniformValues(sizeData.kind,\n size, rotateInShader, pitchWithMap, painter, matrix,\n uLabelPlaneMatrix, uglCoordMatrix, isText, texSize);\n }\n\n const state = {\n program,\n buffers,\n uniformValues,\n atlasTexture,\n atlasTextureIcon,\n atlasInterpolation,\n atlasInterpolationIcon,\n isSDF,\n hasHalo\n };\n\n if (hasSortKey && bucket.canOverlap) {\n sortFeaturesByKey = true;\n const oldSegments = buffers.segments.get();\n for (const segment of oldSegments) {\n tileRenderState.push({\n segments: new SegmentVector([segment]),\n sortKey: segment.sortKey,\n state,\n terrainData\n });\n }\n } else {\n tileRenderState.push({\n segments: buffers.segments,\n sortKey: 0,\n state,\n terrainData\n });\n }\n }\n\n if (sortFeaturesByKey) {\n tileRenderState.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const segmentState of tileRenderState) {\n const state = segmentState.state;\n\n context.activeTexture.set(gl.TEXTURE0);\n // @ts-ignore\n state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE);\n if (state.atlasTextureIcon) {\n context.activeTexture.set(gl.TEXTURE1);\n if (state.atlasTextureIcon) {\n // @ts-ignore\n state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE);\n }\n }\n\n if (state.isSDF) {\n const uniformValues = state.uniformValues;\n if (state.hasHalo) {\n uniformValues['u_is_halo'] = 1;\n drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues, segmentState.terrainData);\n }\n uniformValues['u_is_halo'] = 0;\n }\n drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues, segmentState.terrainData);\n }\n}\n\nfunction drawSymbolElements(\n buffers: SymbolBuffers,\n segments: SegmentVector,\n layer: SymbolStyleLayer,\n painter: Painter,\n program: Program,\n depthMode: Readonly,\n stencilMode: StencilMode,\n colorMode: Readonly,\n uniformValues: UniformValues,\n terrainData: TerrainData) {\n const context = painter.context;\n const gl = context.gl;\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, buffers.layoutVertexBuffer,\n buffers.indexBuffer, segments, layer.paint,\n painter.transform.zoom, buffers.programConfigurations.get(layer.id),\n buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer);\n}\n","import type {CrossFaded} from '../style/properties';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport type {Tile} from '../source/tile';\nimport type {ProgramConfiguration} from '../data/program_configuration';\nimport type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';\nimport type {FillStyleLayer} from '../style/style_layer/fill_style_layer';\n\n/**\n * A simple helper shared by draw_fill and draw_fill_extrusions to find the correct pattern positions AND update program.\n * For transtionable properties, especially 'fill-pattern' and 'fill-extrusion-pattern', while rendering certain frames\n * tile.imageAtlas has been updated by worker to hold the new pattern only, but rendering code is still looking for the previous image.\n * The mismatch was causing setConstantPatternPositions method not being called and pixelRatio was always the\n * default of 1, instead of actual values set by original map.addImage.\n *\n * @param programConfiguration - to be used to set pattern position and device pixel ratio.\n * @param propertyName - 'fill-pattern' or 'fill-extrusion-pattern' property key\n * @param constantPattern - either 'fill-pattern' or 'fill-extrusion-pattern' property value\n * @param tile - current tile being drawn\n * @param layer - current layer being rendered\n */\nexport function updatePatternPositionsInProgram(\n programConfiguration: ProgramConfiguration,\n propertyName: 'fill-pattern' | 'fill-extrusion-pattern',\n constantPattern: CrossFaded,\n tile: Tile,\n layer: FillStyleLayer | FillExtrusionStyleLayer): void {\n\n if (!constantPattern || !tile || !tile.imageAtlas) {\n return;\n }\n\n const patternPositions = tile.imageAtlas.patternPositions;\n let posTo = patternPositions[constantPattern.to.toString()];\n let posFrom = patternPositions[constantPattern.from.toString()];\n\n // https://github.com/maplibre/maplibre-gl-js/issues/3377\n if (!posTo && posFrom) posTo = posFrom;\n if (!posFrom && posTo) posFrom = posTo;\n\n // try again in case patternPositions has been updated by worker\n if (!posTo || !posFrom) {\n const transitioned = layer.getPaintProperty(propertyName) as string;\n posTo = patternPositions[transitioned];\n posFrom = patternPositions[transitioned];\n }\n\n if (posTo && posFrom) {\n programConfiguration.setConstantPatternPositions(posTo, posFrom);\n }\n}\n","import {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {\n fillUniformValues,\n fillPatternUniformValues,\n fillOutlineUniformValues,\n fillOutlinePatternUniformValues\n} from './program/fill_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {FillStyleLayer} from '../style/style_layer/fill_style_layer';\nimport type {FillBucket} from '../data/bucket/fill_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';\n\nexport function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLayer, coords: Array) {\n const color = layer.paint.get('fill-color');\n const opacity = layer.paint.get('fill-opacity');\n\n if (opacity.constantOr(1) === 0) {\n return;\n }\n\n const colorMode = painter.colorModeForRenderPass();\n\n const pattern = layer.paint.get('fill-pattern');\n const pass = painter.opaquePassEnabledForLayer() &&\n (!pattern.constantOr(1 as any) &&\n color.constantOr(Color.transparent).a === 1 &&\n opacity.constantOr(0) === 1) ? 'opaque' : 'translucent';\n\n // Draw fill\n if (painter.renderPass === pass) {\n const depthMode = painter.depthModeForSublayer(\n 1, painter.renderPass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly);\n drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, false);\n }\n\n // Draw stroke\n if (painter.renderPass === 'translucent' && layer.paint.get('fill-antialias')) {\n\n // If we defined a different color for the fill outline, we are\n // going to ignore the bits in 0x07 and just care about the global\n // clipping mask.\n // Otherwise, we only want to drawFill the antialiased parts that are\n // *outside* the current shape. This is important in case the fill\n // or stroke color is translucent. If we wouldn't clip to outside\n // the current shape, some pixels from the outline stroke overlapped\n // the (non-antialiased) fill.\n const depthMode = painter.depthModeForSublayer(\n layer.getPaintProperty('fill-outline-color') ? 2 : 0, DepthMode.ReadOnly);\n drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, true);\n }\n}\n\nfunction drawFillTiles(\n painter: Painter,\n sourceCache: SourceCache,\n layer: FillStyleLayer,\n coords: Array,\n depthMode: Readonly,\n colorMode: Readonly,\n isOutline: boolean) {\n const gl = painter.context.gl;\n const fillPropertyName = 'fill-pattern';\n const patternProperty = layer.paint.get(fillPropertyName);\n const image = patternProperty && patternProperty.constantOr(1 as any);\n const crossfade = layer.getCrossfadeParameters();\n let drawMode, programName, uniformValues, indexBuffer, segments;\n\n if (!isOutline) {\n programName = image ? 'fillPattern' : 'fill';\n drawMode = gl.TRIANGLES;\n } else {\n programName = image && !layer.getPaintProperty('fill-outline-color') ? 'fillOutlinePattern' : 'fillOutline';\n drawMode = gl.LINES;\n }\n\n const constantPattern = patternProperty.constantOr(null);\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n if (image && !tile.patternsLoaded()) continue;\n\n const bucket: FillBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram(programName, programConfiguration);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n if (image) {\n painter.context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n }\n\n updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer);\n\n const terrainCoord = terrainData ? coord : null;\n const posMatrix = terrainCoord ? terrainCoord.posMatrix : coord.posMatrix;\n const tileMatrix = painter.translatePosMatrix(posMatrix, tile,\n layer.paint.get('fill-translate'), layer.paint.get('fill-translate-anchor'));\n\n if (!isOutline) {\n indexBuffer = bucket.indexBuffer;\n segments = bucket.segments;\n uniformValues = image ?\n fillPatternUniformValues(tileMatrix, painter, crossfade, tile) :\n fillUniformValues(tileMatrix);\n } else {\n indexBuffer = bucket.indexBuffer2;\n segments = bucket.segments2;\n const drawingBufferSize = [gl.drawingBufferWidth, gl.drawingBufferHeight] as [number, number];\n uniformValues = (programName === 'fillOutlinePattern' && image) ?\n fillOutlinePatternUniformValues(tileMatrix, painter, crossfade, tile, drawingBufferSize) :\n fillOutlineUniformValues(tileMatrix, drawingBufferSize);\n }\n\n program.draw(painter.context, drawMode, depthMode,\n painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData,\n layer.id, bucket.layoutVertexBuffer, indexBuffer, segments,\n layer.paint, painter.transform.zoom, programConfiguration);\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {\n fillExtrusionUniformValues,\n fillExtrusionPatternUniformValues,\n} from './program/fill_extrusion_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';\nimport type {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nimport {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';\n\nexport function drawFillExtrusion(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLayer, coords: Array) {\n const opacity = layer.paint.get('fill-extrusion-opacity');\n if (opacity === 0) {\n return;\n }\n\n if (painter.renderPass === 'translucent') {\n const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);\n\n if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1 as any)) {\n const colorMode = painter.colorModeForRenderPass();\n drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode);\n\n } else {\n // Draw transparent buildings in two passes so that only the closest surface is drawn.\n // First draw all the extrusions into only the depth buffer. No colors are drawn.\n drawExtrusionTiles(painter, source, layer, coords, depthMode,\n StencilMode.disabled,\n ColorMode.disabled);\n\n // Then draw all the extrusions a second type, only coloring fragments if they have the\n // same depth value as the closest fragment in the previous pass. Use the stencil buffer\n // to prevent the second draw in cases where we have coincident polygons.\n drawExtrusionTiles(painter, source, layer, coords, depthMode,\n painter.stencilModeFor3D(),\n painter.colorModeForRenderPass());\n }\n }\n}\n\nfunction drawExtrusionTiles(\n painter: Painter,\n source: SourceCache,\n layer: FillExtrusionStyleLayer,\n coords: OverscaledTileID[],\n depthMode: DepthMode,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const fillPropertyName = 'fill-extrusion-pattern';\n const patternProperty = layer.paint.get(fillPropertyName);\n const image = patternProperty.constantOr(1 as any);\n const crossfade = layer.getCrossfadeParameters();\n const opacity = layer.paint.get('fill-extrusion-opacity');\n const constantPattern = patternProperty.constantOr(null);\n for (const coord of coords) {\n const tile = source.getTile(coord);\n const bucket: FillExtrusionBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration);\n\n if (image) {\n painter.context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n }\n\n updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer);\n\n const matrix = painter.translatePosMatrix(\n coord.posMatrix,\n tile,\n layer.paint.get('fill-extrusion-translate'),\n layer.paint.get('fill-extrusion-translate-anchor'));\n\n const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient');\n const uniformValues = image ?\n fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile) :\n fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity);\n\n program.draw(context, context.gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.backCCW,\n uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer,\n bucket.segments, layer.paint, painter.transform.zoom,\n programConfiguration, painter.style.map.terrain && bucket.centroidVertexBuffer);\n }\n}\n","import {Texture} from './texture';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {Tile} from '../source/tile';\nimport {\n hillshadeUniformValues,\n hillshadeUniformPrepareValues\n} from './program/hillshade_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: HillshadeStyleLayer, tileIDs: Array) {\n if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') return;\n\n const context = painter.context;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n\n const [stencilModes, coords] = painter.renderPass === 'translucent' ?\n painter.stencilConfigForOverlap(tileIDs) : [{}, tileIDs];\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n if (typeof tile.needsHillshadePrepare !== 'undefined' && tile.needsHillshadePrepare && painter.renderPass === 'offscreen') {\n prepareHillshade(painter, tile, layer, depthMode, StencilMode.disabled, colorMode);\n } else if (painter.renderPass === 'translucent') {\n renderHillshade(painter, coord, tile, layer, depthMode, stencilModes[coord.overscaledZ], colorMode);\n }\n }\n\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\nfunction renderHillshade(\n painter: Painter,\n coord: OverscaledTileID,\n tile: Tile,\n layer: HillshadeStyleLayer,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const fbo = tile.fbo;\n if (!fbo) return;\n\n const program = painter.useProgram('hillshade');\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n\n const terrainCoord = terrainData ? coord : null;\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n hillshadeUniformValues(painter, tile, layer, terrainCoord), terrainData, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n\n}\n\n// hillshade rendering is done in two steps. the prepare step first calculates the slope of the terrain in the x and y\n// directions for each pixel, and saves those values to a framebuffer texture in the r and g channels.\nfunction prepareHillshade(\n painter: Painter,\n tile: Tile,\n layer: HillshadeStyleLayer,\n depthMode: Readonly,\n stencilMode: Readonly,\n colorMode: Readonly) {\n const context = painter.context;\n const gl = context.gl;\n const dem = tile.dem;\n if (dem && dem.data) {\n const tileSize = dem.dim;\n const textureStride = dem.stride;\n\n const pixelData = dem.getPixels();\n context.activeTexture.set(gl.TEXTURE1);\n\n context.pixelStoreUnpackPremultiplyAlpha.set(false);\n tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride);\n if (tile.demTexture) {\n const demTexture = tile.demTexture;\n demTexture.update(pixelData, {premultiply: false});\n demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);\n } else {\n tile.demTexture = new Texture(context, pixelData, gl.RGBA, {premultiply: false});\n tile.demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);\n }\n\n context.activeTexture.set(gl.TEXTURE0);\n\n let fbo = tile.fbo;\n\n if (!fbo) {\n const renderTexture = new Texture(context, {width: tileSize, height: tileSize, data: null}, gl.RGBA);\n renderTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n\n fbo = tile.fbo = context.createFramebuffer(tileSize, tileSize, true, false);\n fbo.colorAttachment.set(renderTexture.texture);\n }\n\n context.bindFramebuffer.set(fbo.framebuffer);\n context.viewport.set([0, 0, tileSize, tileSize]);\n\n painter.useProgram('hillshadePrepare').draw(context, gl.TRIANGLES,\n depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n hillshadeUniformPrepareValues(tile.tileID, dem),\n null, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n\n tile.needsHillshadePrepare = false;\n }\n}\n","import {clamp} from '../util/util';\n\nimport {ImageSource} from '../source/image_source';\nimport {browser} from '../util/browser';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {rasterUniformValues} from './program/raster_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {RasterStyleLayer} from '../style/style_layer/raster_style_layer';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array) {\n if (painter.renderPass !== 'translucent') return;\n if (layer.paint.get('raster-opacity') === 0) return;\n if (!tileIDs.length) return;\n\n const context = painter.context;\n const gl = context.gl;\n const source = sourceCache.getSource();\n const program = painter.useProgram('raster');\n\n const colorMode = painter.colorModeForRenderPass();\n\n const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] :\n painter.stencilConfigForOverlap(tileIDs);\n\n const minTileZ = coords[coords.length - 1].overscaledZ;\n\n const align = !painter.options.moving;\n for (const coord of coords) {\n // Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers\n // Use gl.LESS to prevent double drawing in areas where tiles overlap.\n const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ,\n layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS);\n\n const tile = sourceCache.getTile(coord);\n\n tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));\n\n const parentTile = sourceCache.findLoadedParent(coord, 0),\n fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform, painter.style.map.terrain);\n\n let parentScaleBy, parentTL;\n\n const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;\n\n context.activeTexture.set(gl.TEXTURE0);\n tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n\n context.activeTexture.set(gl.TEXTURE1);\n\n if (parentTile) {\n parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ);\n parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1];\n\n } else {\n tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);\n }\n\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const terrainCoord = terrainData ? coord : null;\n const posMatrix = terrainCoord ? terrainCoord.posMatrix : painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);\n const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer);\n\n if (source instanceof ImageSource) {\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, source.boundsBuffer,\n painter.quadTriangleIndexBuffer, source.boundsSegments);\n } else {\n program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, painter.rasterBoundsBuffer,\n painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);\n }\n }\n}\n\nfunction getFadeValues(tile, parentTile, sourceCache, layer, transform, terrain) {\n const fadeDuration = layer.paint.get('raster-fade-duration');\n\n if (!terrain && fadeDuration > 0) {\n const now = browser.now();\n const sinceTile = (now - tile.timeAdded) / fadeDuration;\n const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1;\n\n const source = sourceCache.getSource();\n const idealZ = transform.coveringZoomLevel({\n tileSize: source.tileSize,\n roundZoom: source.roundZoom\n });\n\n // if no parent or parent is older, fade in; if parent is younger, fade out\n const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ);\n\n const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1);\n\n // we don't crossfade tiles that were just refreshed upon expiring:\n // once they're old enough to pass the crossfading threshold\n // (fadeDuration), unset the `refreshedUponExpiration` flag so we don't\n // incorrectly fail to crossfade them when zooming\n if (tile.refreshedUponExpiration && sinceTile >= 1) tile.refreshedUponExpiration = false;\n\n if (parentTile) {\n return {\n opacity: 1,\n mix: 1 - childOpacity\n };\n } else {\n return {\n opacity: childOpacity,\n mix: 0\n };\n }\n } else {\n return {\n opacity: 1,\n mix: 0\n };\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {debugUniformValues} from './program/debug_program';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {ColorMode} from '../gl/color_mode';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {Style} from '../style/style';\n\nconst topColor = new Color(1, 0, 0, 1);\nconst btmColor = new Color(0, 1, 0, 1);\nconst leftColor = new Color(0, 0, 1, 1);\nconst rightColor = new Color(1, 0, 1, 1);\nconst centerColor = new Color(0, 1, 1, 1);\n\nexport function drawDebugPadding(painter: Painter) {\n const padding = painter.transform.padding;\n const lineWidth = 3;\n // Top\n drawHorizontalLine(painter, painter.transform.height - (padding.top || 0), lineWidth, topColor);\n // Bottom\n drawHorizontalLine(painter, padding.bottom || 0, lineWidth, btmColor);\n // Left\n drawVerticalLine(painter, padding.left || 0, lineWidth, leftColor);\n // Right\n drawVerticalLine(painter, painter.transform.width - (padding.right || 0), lineWidth, rightColor);\n // Center\n const center = painter.transform.centerPoint;\n drawCrosshair(painter, center.x, painter.transform.height - center.y, centerColor);\n}\n\nfunction drawCrosshair(painter: Painter, x: number, y: number, color: Color) {\n const size = 20;\n const lineWidth = 2;\n //Vertical line\n drawDebugSSRect(painter, x - lineWidth / 2, y - size / 2, lineWidth, size, color);\n //Horizontal line\n drawDebugSSRect(painter, x - size / 2, y - lineWidth / 2, size, lineWidth, color);\n}\n\nfunction drawHorizontalLine(painter: Painter, y: number, lineWidth: number, color: Color) {\n drawDebugSSRect(painter, 0, y + lineWidth / 2, painter.transform.width, lineWidth, color);\n}\n\nfunction drawVerticalLine(painter: Painter, x: number, lineWidth: number, color: Color) {\n drawDebugSSRect(painter, x - lineWidth / 2, 0, lineWidth, painter.transform.height, color);\n}\n\nfunction drawDebugSSRect(painter: Painter, x: number, y: number, width: number, height: number, color: Color) {\n const context = painter.context;\n const gl = context.gl;\n\n gl.enable(gl.SCISSOR_TEST);\n gl.scissor(x * painter.pixelRatio, y * painter.pixelRatio, width * painter.pixelRatio, height * painter.pixelRatio);\n context.clear({color});\n gl.disable(gl.SCISSOR_TEST);\n}\n\nexport function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array) {\n for (let i = 0; i < coords.length; i++) {\n drawDebugTile(painter, sourceCache, coords[i]);\n }\n}\n\nfunction drawDebugTile(painter: Painter, sourceCache: SourceCache, coord: OverscaledTileID) {\n const context = painter.context;\n const gl = context.gl;\n\n const posMatrix = coord.posMatrix;\n const program = painter.useProgram('debug');\n\n const depthMode = DepthMode.disabled;\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n const id = '$debug';\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n context.activeTexture.set(gl.TEXTURE0);\n\n const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData;\n const tileByteLength = (tileRawData && tileRawData.byteLength) || 0;\n const tileSizeKb = Math.floor(tileByteLength / 1024);\n const tileSize = sourceCache.getTile(coord).tileSize;\n const scaleRatio = (512 / Math.min(tileSize, 512) * (coord.overscaledZ / painter.transform.zoom)) * 0.5;\n let tileIdText = coord.canonical.toString();\n if (coord.overscaledZ !== coord.canonical.z) {\n tileIdText += ` => ${coord.overscaledZ}`;\n }\n const tileLabel = `${tileIdText} ${tileSizeKb}kB`;\n drawTextToOverlay(painter, tileLabel);\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, ColorMode.alphaBlended, CullFaceMode.disabled,\n debugUniformValues(posMatrix, Color.transparent, scaleRatio), null, id,\n painter.debugBuffer, painter.quadTriangleIndexBuffer, painter.debugSegments);\n program.draw(context, gl.LINE_STRIP, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n debugUniformValues(posMatrix, Color.red), terrainData, id,\n painter.debugBuffer, painter.tileBorderIndexBuffer, painter.debugSegments);\n}\n\nfunction drawTextToOverlay(painter: Painter, text: string) {\n painter.initDebugOverlayCanvas();\n const canvas = painter.debugOverlayCanvas;\n const gl = painter.context.gl;\n const ctx2d = painter.debugOverlayCanvas.getContext('2d');\n ctx2d.clearRect(0, 0, canvas.width, canvas.height);\n\n ctx2d.shadowColor = 'white';\n ctx2d.shadowBlur = 2;\n ctx2d.lineWidth = 1.5;\n ctx2d.strokeStyle = 'white';\n ctx2d.textBaseline = 'top';\n ctx2d.font = `bold ${36}px Open Sans, sans-serif`;\n ctx2d.fillText(text, 5, 5);\n ctx2d.strokeText(text, 5, 5);\n\n painter.debugOverlayTexture.update(canvas);\n painter.debugOverlayTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n}\n\nexport function selectDebugSource(style: Style, zoom: number): SourceCache | null {\n // Use vector source with highest maxzoom\n // Else use source with highest maxzoom of any type\n let selectedSource: SourceCache = null;\n const layers = Object.values(style._layers);\n const sources = layers.flatMap((layer) => {\n if (layer.source && !layer.isHidden(zoom)) {\n const sourceCache = style.sourceCaches[layer.source];\n return [sourceCache];\n } else {\n return [];\n }\n });\n const vectorSources = sources.filter((source) => source.getSource().type === 'vector');\n const otherSources = sources.filter((source) => source.getSource().type !== 'vector');\n const considerSource = (source: SourceCache) => {\n if (!selectedSource || (selectedSource.getSource().maxzoom < source.getSource().maxzoom)) {\n selectedSource = source;\n }\n };\n vectorSources.forEach((source) => considerSource(source));\n if (!selectedSource) {\n otherSources.forEach((source) => considerSource(source));\n }\n return selectedSource;\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues} from './program/terrain_program';\nimport type {Painter} from './painter';\nimport type {Tile} from '../source/tile';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {ColorMode} from '../gl/color_mode';\nimport {Terrain} from './terrain';\n\n/**\n * Redraw the Depth Framebuffer\n * @param painter - the painter\n * @param terrain - the terrain\n */\nfunction drawDepth(painter: Painter, terrain: Terrain) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = ColorMode.unblended;\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]);\n const mesh = terrain.getTerrainMesh();\n const tiles = terrain.sourceCache.getRenderableTiles();\n const program = painter.useProgram('terrainDepth');\n context.bindFramebuffer.set(terrain.getFramebuffer('depth').framebuffer);\n context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]);\n context.clear({color: Color.transparent, depth: 1});\n for (const tile of tiles) {\n const terrainData = terrain.getTerrainData(tile.tileID);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainDepthUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n }\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\n/**\n * Redraw the Coords Framebuffers\n * @param painter - the painter\n * @param terrain - the terrain\n */\nfunction drawCoords(painter: Painter, terrain: Terrain) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = ColorMode.unblended;\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]);\n const mesh = terrain.getTerrainMesh();\n const coords = terrain.getCoordsTexture();\n const tiles = terrain.sourceCache.getRenderableTiles();\n\n // draw tile-coords into framebuffer\n const program = painter.useProgram('terrainCoords');\n context.bindFramebuffer.set(terrain.getFramebuffer('coords').framebuffer);\n context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]);\n context.clear({color: Color.transparent, depth: 1});\n terrain.coordsIndex = [];\n for (const tile of tiles) {\n const terrainData = terrain.getTerrainData(tile.tileID);\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, coords.texture);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainCoordsUniformValues(posMatrix, 255 - terrain.coordsIndex.length, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n terrain.coordsIndex.push(tile.tileID.key);\n }\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n}\n\nfunction drawTerrain(painter: Painter, terrain: Terrain, tiles: Array) {\n const context = painter.context;\n const gl = context.gl;\n const colorMode = painter.colorModeForRenderPass();\n const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);\n const program = painter.useProgram('terrain');\n const mesh = terrain.getTerrainMesh();\n\n context.bindFramebuffer.set(null);\n context.viewport.set([0, 0, painter.width, painter.height]);\n\n for (const tile of tiles) {\n const texture = painter.renderToTexture.getTexture(tile);\n const terrainData = terrain.getTerrainData(tile.tileID);\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture.texture);\n const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped());\n const uniformValues = terrainUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom));\n program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);\n }\n\n}\n\nexport {\n drawTerrain,\n drawDepth,\n drawCoords\n};\n","import {browser} from '../util/browser';\nimport {mat4, vec3} from 'gl-matrix';\nimport {SourceCache} from '../source/source_cache';\nimport {EXTENT} from '../data/extent';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport {SegmentVector} from '../data/segment';\nimport {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types.g';\nimport rasterBoundsAttributes from '../data/raster_bounds_attributes';\nimport posAttributes from '../data/pos_attributes';\nimport {ProgramConfiguration} from '../data/program_configuration';\nimport {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';\nimport {shaders} from '../shaders/shaders';\nimport {Program} from './program';\nimport {programUniforms} from './program/program_uniforms';\nimport {Context} from '../gl/context';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Texture} from './texture';\nimport {clippingMaskUniformValues} from './program/clipping_mask_program';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {drawSymbols} from './draw_symbol';\nimport {drawCircles} from './draw_circle';\nimport {drawHeatmap} from './draw_heatmap';\nimport {drawLine} from './draw_line';\nimport {drawFill} from './draw_fill';\nimport {drawFillExtrusion} from './draw_fill_extrusion';\nimport {drawHillshade} from './draw_hillshade';\nimport {drawRaster} from './draw_raster';\nimport {drawBackground} from './draw_background';\nimport {drawDebug, drawDebugPadding, selectDebugSource} from './draw_debug';\nimport {drawCustom} from './draw_custom';\nimport {drawDepth, drawCoords} from './draw_terrain';\nimport {OverscaledTileID} from '../source/tile_id';\n\nimport type {Transform} from '../geo/transform';\nimport type {Tile} from '../source/tile';\nimport type {Style} from '../style/style';\nimport type {StyleLayer} from '../style/style_layer';\nimport type {CrossFaded} from '../style/properties';\nimport type {LineAtlas} from './line_atlas';\nimport type {ImageManager} from './image_manager';\nimport type {GlyphManager} from './glyph_manager';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {DepthRangeType, DepthMaskType, DepthFuncType} from '../gl/types';\nimport type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';\nimport {RenderToTexture} from './render_to_texture';\n\nexport type RenderPass = 'offscreen' | 'opaque' | 'translucent';\n\ntype PainterOptions = {\n showOverdrawInspector: boolean;\n showTileBoundaries: boolean;\n showPadding: boolean;\n rotating: boolean;\n zooming: boolean;\n moving: boolean;\n fadeDuration: number;\n};\n\n/**\n * @internal\n * Initialize a new painter object.\n */\nexport class Painter {\n context: Context;\n transform: Transform;\n renderToTexture: RenderToTexture;\n _tileTextures: {\n [_: number]: Array;\n };\n numSublayers: number;\n depthEpsilon: number;\n emptyProgramConfiguration: ProgramConfiguration;\n width: number;\n height: number;\n pixelRatio: number;\n tileExtentBuffer: VertexBuffer;\n tileExtentSegments: SegmentVector;\n debugBuffer: VertexBuffer;\n debugSegments: SegmentVector;\n rasterBoundsBuffer: VertexBuffer;\n rasterBoundsSegments: SegmentVector;\n viewportBuffer: VertexBuffer;\n viewportSegments: SegmentVector;\n quadTriangleIndexBuffer: IndexBuffer;\n tileBorderIndexBuffer: IndexBuffer;\n _tileClippingMaskIDs: {[_: string]: number};\n stencilClearMode: StencilMode;\n style: Style;\n options: PainterOptions;\n lineAtlas: LineAtlas;\n imageManager: ImageManager;\n glyphManager: GlyphManager;\n depthRangeFor3D: DepthRangeType;\n opaquePassCutoff: number;\n renderPass: RenderPass;\n currentLayer: number;\n currentStencilSource: string;\n nextStencilID: number;\n id: string;\n _showOverdrawInspector: boolean;\n cache: {[_: string]: Program};\n crossTileSymbolIndex: CrossTileSymbolIndex;\n symbolFadeChange: number;\n debugOverlayTexture: Texture;\n debugOverlayCanvas: HTMLCanvasElement;\n // this object stores the current camera-matrix and the last render time\n // of the terrain-facilitators. e.g. depth & coords framebuffers\n // every time the camera-matrix changes the terrain-facilitators will be redrawn.\n terrainFacilitator: {dirty: boolean; matrix: mat4; renderTime: number};\n\n constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, transform: Transform) {\n this.context = new Context(gl);\n this.transform = transform;\n this._tileTextures = {};\n this.terrainFacilitator = {dirty: true, matrix: mat4.create(), renderTime: 0};\n\n this.setup();\n\n // Within each layer there are multiple distinct z-planes that can be drawn to.\n // This is implemented using the WebGL depth buffer.\n this.numSublayers = SourceCache.maxUnderzooming + SourceCache.maxOverzooming + 1;\n this.depthEpsilon = 1 / Math.pow(2, 16);\n\n this.crossTileSymbolIndex = new CrossTileSymbolIndex();\n }\n\n /*\n * Update the GL viewport, projection matrix, and transforms to compensate\n * for a new width and height value.\n */\n resize(width: number, height: number, pixelRatio: number) {\n this.width = Math.floor(width * pixelRatio);\n this.height = Math.floor(height * pixelRatio);\n this.pixelRatio = pixelRatio;\n this.context.viewport.set([0, 0, this.width, this.height]);\n\n if (this.style) {\n for (const layerId of this.style._order) {\n this.style._layers[layerId].resize();\n }\n }\n }\n\n setup() {\n const context = this.context;\n\n const tileExtentArray = new PosArray();\n tileExtentArray.emplaceBack(0, 0);\n tileExtentArray.emplaceBack(EXTENT, 0);\n tileExtentArray.emplaceBack(0, EXTENT);\n tileExtentArray.emplaceBack(EXTENT, EXTENT);\n this.tileExtentBuffer = context.createVertexBuffer(tileExtentArray, posAttributes.members);\n this.tileExtentSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const debugArray = new PosArray();\n debugArray.emplaceBack(0, 0);\n debugArray.emplaceBack(EXTENT, 0);\n debugArray.emplaceBack(0, EXTENT);\n debugArray.emplaceBack(EXTENT, EXTENT);\n this.debugBuffer = context.createVertexBuffer(debugArray, posAttributes.members);\n this.debugSegments = SegmentVector.simpleSegment(0, 0, 4, 5);\n\n const rasterBoundsArray = new RasterBoundsArray();\n rasterBoundsArray.emplaceBack(0, 0, 0, 0);\n rasterBoundsArray.emplaceBack(EXTENT, 0, EXTENT, 0);\n rasterBoundsArray.emplaceBack(0, EXTENT, 0, EXTENT);\n rasterBoundsArray.emplaceBack(EXTENT, EXTENT, EXTENT, EXTENT);\n this.rasterBoundsBuffer = context.createVertexBuffer(rasterBoundsArray, rasterBoundsAttributes.members);\n this.rasterBoundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const viewportArray = new PosArray();\n viewportArray.emplaceBack(0, 0);\n viewportArray.emplaceBack(1, 0);\n viewportArray.emplaceBack(0, 1);\n viewportArray.emplaceBack(1, 1);\n this.viewportBuffer = context.createVertexBuffer(viewportArray, posAttributes.members);\n this.viewportSegments = SegmentVector.simpleSegment(0, 0, 4, 2);\n\n const tileLineStripIndices = new LineStripIndexArray();\n tileLineStripIndices.emplaceBack(0);\n tileLineStripIndices.emplaceBack(1);\n tileLineStripIndices.emplaceBack(3);\n tileLineStripIndices.emplaceBack(2);\n tileLineStripIndices.emplaceBack(0);\n this.tileBorderIndexBuffer = context.createIndexBuffer(tileLineStripIndices);\n\n const quadTriangleIndices = new TriangleIndexArray();\n quadTriangleIndices.emplaceBack(0, 1, 2);\n quadTriangleIndices.emplaceBack(2, 1, 3);\n this.quadTriangleIndexBuffer = context.createIndexBuffer(quadTriangleIndices);\n\n const gl = this.context.gl;\n this.stencilClearMode = new StencilMode({func: gl.ALWAYS, mask: 0}, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO);\n }\n\n /*\n * Reset the drawing canvas by clearing the stencil buffer so that we can draw\n * new tiles at the same location, while retaining previously drawn pixels.\n */\n clearStencil() {\n const context = this.context;\n const gl = context.gl;\n\n this.nextStencilID = 1;\n this.currentStencilSource = undefined;\n\n // As a temporary workaround for https://github.com/mapbox/mapbox-gl-js/issues/5490,\n // pending an upstream fix, we draw a fullscreen stencil=0 clipping mask here,\n // effectively clearing the stencil buffer: once an upstream patch lands, remove\n // this function in favor of context.clear({ stencil: 0x0 })\n\n const matrix = mat4.create();\n mat4.ortho(matrix, 0, this.width, this.height, 0, 0, 1);\n mat4.scale(matrix, matrix, [gl.drawingBufferWidth, gl.drawingBufferHeight, 0]);\n\n this.useProgram('clippingMask').draw(context, gl.TRIANGLES,\n DepthMode.disabled, this.stencilClearMode, ColorMode.disabled, CullFaceMode.disabled,\n clippingMaskUniformValues(matrix), null,\n '$clipping', this.viewportBuffer,\n this.quadTriangleIndexBuffer, this.viewportSegments);\n }\n\n _renderTileClippingMasks(layer: StyleLayer, tileIDs: Array) {\n if (this.currentStencilSource === layer.source || !layer.isTileClipped() || !tileIDs || !tileIDs.length) return;\n\n this.currentStencilSource = layer.source;\n\n const context = this.context;\n const gl = context.gl;\n\n if (this.nextStencilID + tileIDs.length > 256) {\n // we'll run out of fresh IDs so we need to clear and start from scratch\n this.clearStencil();\n }\n\n context.setColorMode(ColorMode.disabled);\n context.setDepthMode(DepthMode.disabled);\n\n const program = this.useProgram('clippingMask');\n\n this._tileClippingMaskIDs = {};\n\n for (const tileID of tileIDs) {\n const id = this._tileClippingMaskIDs[tileID.key] = this.nextStencilID++;\n const terrainData = this.style.map.terrain && this.style.map.terrain.getTerrainData(tileID);\n\n program.draw(context, gl.TRIANGLES, DepthMode.disabled,\n // Tests will always pass, and ref value will be written to stencil buffer.\n new StencilMode({func: gl.ALWAYS, mask: 0}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE),\n ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(tileID.posMatrix),\n terrainData, '$clipping', this.tileExtentBuffer,\n this.quadTriangleIndexBuffer, this.tileExtentSegments);\n }\n }\n\n stencilModeFor3D(): StencilMode {\n this.currentStencilSource = undefined;\n\n if (this.nextStencilID + 1 > 256) {\n this.clearStencil();\n }\n\n const id = this.nextStencilID++;\n const gl = this.context.gl;\n return new StencilMode({func: gl.NOTEQUAL, mask: 0xFF}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n\n stencilModeForClipping(tileID: OverscaledTileID): StencilMode {\n const gl = this.context.gl;\n return new StencilMode({func: gl.EQUAL, mask: 0xFF}, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n\n /*\n * Sort coordinates by Z as drawing tiles is done in Z-descending order.\n * All children with the same Z write the same stencil value. Children\n * stencil values are greater than parent's. This is used only for raster\n * and raster-dem tiles, which are already clipped to tile boundaries, to\n * mask area of tile overlapped by children tiles.\n * Stencil ref values continue range used in _tileClippingMaskIDs.\n *\n * Returns [StencilMode for tile overscaleZ map, sortedCoords].\n */\n stencilConfigForOverlap(tileIDs: Array): [{\n [_: number]: Readonly;\n }, Array] {\n const gl = this.context.gl;\n const coords = tileIDs.sort((a, b) => b.overscaledZ - a.overscaledZ);\n const minTileZ = coords[coords.length - 1].overscaledZ;\n const stencilValues = coords[0].overscaledZ - minTileZ + 1;\n if (stencilValues > 1) {\n this.currentStencilSource = undefined;\n if (this.nextStencilID + stencilValues > 256) {\n this.clearStencil();\n }\n const zToStencilMode = {};\n for (let i = 0; i < stencilValues; i++) {\n zToStencilMode[i + minTileZ] = new StencilMode({func: gl.GEQUAL, mask: 0xFF}, i + this.nextStencilID, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE);\n }\n this.nextStencilID += stencilValues;\n return [zToStencilMode, coords];\n }\n return [{[minTileZ]: StencilMode.disabled}, coords];\n }\n\n colorModeForRenderPass(): Readonly {\n const gl = this.context.gl;\n if (this._showOverdrawInspector) {\n const numOverdrawSteps = 8;\n const a = 1 / numOverdrawSteps;\n\n return new ColorMode([gl.CONSTANT_COLOR, gl.ONE], new Color(a, a, a, 0), [true, true, true, true]);\n } else if (this.renderPass === 'opaque') {\n return ColorMode.unblended;\n } else {\n return ColorMode.alphaBlended;\n }\n }\n\n depthModeForSublayer(n: number, mask: DepthMaskType, func?: DepthFuncType | null): Readonly {\n if (!this.opaquePassEnabledForLayer()) return DepthMode.disabled;\n const depth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon;\n return new DepthMode(func || this.context.gl.LEQUAL, mask, [depth, depth]);\n }\n\n /*\n * The opaque pass and 3D layers both use the depth buffer.\n * Layers drawn above 3D layers need to be drawn using the\n * painter's algorithm so that they appear above 3D features.\n * This returns true for layers that can be drawn using the\n * opaque pass.\n */\n opaquePassEnabledForLayer() {\n return this.currentLayer < this.opaquePassCutoff;\n }\n\n render(style: Style, options: PainterOptions) {\n this.style = style;\n this.options = options;\n\n this.lineAtlas = style.lineAtlas;\n this.imageManager = style.imageManager;\n this.glyphManager = style.glyphManager;\n\n this.symbolFadeChange = style.placement.symbolFadeChange(browser.now());\n\n this.imageManager.beginFrame();\n\n const layerIds = this.style._order;\n const sourceCaches = this.style.sourceCaches;\n\n const coordsAscending: {[_: string]: Array} = {};\n const coordsDescending: {[_: string]: Array} = {};\n const coordsDescendingSymbol: {[_: string]: Array} = {};\n\n for (const id in sourceCaches) {\n const sourceCache = sourceCaches[id];\n if (sourceCache.used) {\n sourceCache.prepare(this.context);\n }\n\n coordsAscending[id] = sourceCache.getVisibleCoordinates();\n coordsDescending[id] = coordsAscending[id].slice().reverse();\n coordsDescendingSymbol[id] = sourceCache.getVisibleCoordinates(true).reverse();\n }\n\n this.opaquePassCutoff = Infinity;\n for (let i = 0; i < layerIds.length; i++) {\n const layerId = layerIds[i];\n if (this.style._layers[layerId].is3D()) {\n this.opaquePassCutoff = i;\n break;\n }\n }\n\n if (this.renderToTexture) {\n this.renderToTexture.prepareForRender(this.style, this.transform.zoom);\n // this is disabled, because render-to-texture is rendering all layers from bottom to top.\n this.opaquePassCutoff = 0;\n\n // update coords/depth-framebuffer on camera movement, or tile reloading\n const newTiles = this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);\n if (this.terrainFacilitator.dirty || !mat4.equals(this.terrainFacilitator.matrix, this.transform.projMatrix) || newTiles.length) {\n mat4.copy(this.terrainFacilitator.matrix, this.transform.projMatrix);\n this.terrainFacilitator.renderTime = Date.now();\n this.terrainFacilitator.dirty = false;\n drawDepth(this, this.style.map.terrain);\n drawCoords(this, this.style.map.terrain);\n }\n }\n\n // Offscreen pass ===============================================\n // We first do all rendering that requires rendering to a separate\n // framebuffer, and then save those for rendering back to the map\n // later: in doing this we avoid doing expensive framebuffer restores.\n this.renderPass = 'offscreen';\n\n for (const layerId of layerIds) {\n const layer = this.style._layers[layerId];\n if (!layer.hasOffscreenPass() || layer.isHidden(this.transform.zoom)) continue;\n\n const coords = coordsDescending[layer.source];\n if (layer.type !== 'custom' && !coords.length) continue;\n\n this.renderLayer(this, sourceCaches[layer.source], layer, coords);\n }\n\n // Rebind the main framebuffer now that all offscreen layers have been rendered:\n this.context.bindFramebuffer.set(null);\n\n // Clear buffers in preparation for drawing to the main framebuffer\n this.context.clear({color: options.showOverdrawInspector ? Color.black : Color.transparent, depth: 1});\n this.clearStencil();\n\n this._showOverdrawInspector = options.showOverdrawInspector;\n this.depthRangeFor3D = [0, 1 - ((style._order.length + 2) * this.numSublayers * this.depthEpsilon)];\n\n // Opaque pass ===============================================\n // Draw opaque layers top-to-bottom first.\n if (!this.renderToTexture) {\n this.renderPass = 'opaque';\n\n for (this.currentLayer = layerIds.length - 1; this.currentLayer >= 0; this.currentLayer--) {\n const layer = this.style._layers[layerIds[this.currentLayer]];\n const sourceCache = sourceCaches[layer.source];\n const coords = coordsAscending[layer.source];\n\n this._renderTileClippingMasks(layer, coords);\n this.renderLayer(this, sourceCache, layer, coords);\n }\n }\n\n // Translucent pass ===============================================\n // Draw all other layers bottom-to-top.\n this.renderPass = 'translucent';\n\n for (this.currentLayer = 0; this.currentLayer < layerIds.length; this.currentLayer++) {\n const layer = this.style._layers[layerIds[this.currentLayer]];\n const sourceCache = sourceCaches[layer.source];\n\n if (this.renderToTexture && this.renderToTexture.renderLayer(layer)) continue;\n\n // For symbol layers in the translucent pass, we add extra tiles to the renderable set\n // for cross-tile symbol fading. Symbol layers don't use tile clipping, so no need to render\n // separate clipping masks\n const coords = (layer.type === 'symbol' ? coordsDescendingSymbol : coordsDescending)[layer.source];\n\n this._renderTileClippingMasks(layer, coordsAscending[layer.source]);\n this.renderLayer(this, sourceCache, layer, coords);\n }\n\n if (this.options.showTileBoundaries) {\n const selectedSource = selectDebugSource(this.style, this.transform.zoom);\n if (selectedSource) {\n drawDebug(this, selectedSource, selectedSource.getVisibleCoordinates());\n }\n }\n\n if (this.options.showPadding) {\n drawDebugPadding(this);\n }\n\n // Set defaults for most GL values so that anyone using the state after the render\n // encounters more expected values.\n this.context.setDefault();\n }\n\n renderLayer(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array) {\n if (layer.isHidden(this.transform.zoom)) return;\n if (layer.type !== 'background' && layer.type !== 'custom' && !(coords || []).length) return;\n this.id = layer.id;\n\n switch (layer.type) {\n case 'symbol':\n drawSymbols(painter, sourceCache, layer as any, coords, this.style.placement.variableOffsets);\n break;\n case 'circle':\n drawCircles(painter, sourceCache, layer as any, coords);\n break;\n case 'heatmap':\n drawHeatmap(painter, sourceCache, layer as any, coords);\n break;\n case 'line':\n drawLine(painter, sourceCache, layer as any, coords);\n break;\n case 'fill':\n drawFill(painter, sourceCache, layer as any, coords);\n break;\n case 'fill-extrusion':\n drawFillExtrusion(painter, sourceCache, layer as any, coords);\n break;\n case 'hillshade':\n drawHillshade(painter, sourceCache, layer as any, coords);\n break;\n case 'raster':\n drawRaster(painter, sourceCache, layer as any, coords);\n break;\n case 'background':\n drawBackground(painter, sourceCache, layer as any, coords);\n break;\n case 'custom':\n drawCustom(painter, sourceCache, layer as any);\n break;\n }\n }\n\n /**\n * Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it.\n * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units.\n * @returns matrix\n */\n translatePosMatrix(matrix: mat4, tile: Tile, translate: [number, number], translateAnchor: 'map' | 'viewport', inViewportPixelUnitsUnits?: boolean): mat4 {\n if (!translate[0] && !translate[1]) return matrix;\n\n const angle = inViewportPixelUnitsUnits ?\n (translateAnchor === 'map' ? this.transform.angle : 0) :\n (translateAnchor === 'viewport' ? -this.transform.angle : 0);\n\n if (angle) {\n const sinA = Math.sin(angle);\n const cosA = Math.cos(angle);\n translate = [\n translate[0] * cosA - translate[1] * sinA,\n translate[0] * sinA + translate[1] * cosA\n ];\n }\n\n const translation = [\n inViewportPixelUnitsUnits ? translate[0] : pixelsToTileUnits(tile, translate[0], this.transform.zoom),\n inViewportPixelUnitsUnits ? translate[1] : pixelsToTileUnits(tile, translate[1], this.transform.zoom),\n 0\n ] as vec3;\n\n const translatedMatrix = new Float32Array(16);\n mat4.translate(translatedMatrix, matrix, translation);\n return translatedMatrix;\n }\n\n saveTileTexture(texture: Texture) {\n const textures = this._tileTextures[texture.size[0]];\n if (!textures) {\n this._tileTextures[texture.size[0]] = [texture];\n } else {\n textures.push(texture);\n }\n }\n\n getTileTexture(size: number) {\n const textures = this._tileTextures[size];\n return textures && textures.length > 0 ? textures.pop() : null;\n }\n\n /**\n * Checks whether a pattern image is needed, and if it is, whether it is not loaded.\n *\n * @returns true if a needed image is missing and rendering needs to be skipped.\n */\n isPatternMissing(image?: CrossFaded | null): boolean {\n if (!image) return false;\n if (!image.from || !image.to) return true;\n const imagePosA = this.imageManager.getPattern(image.from.toString());\n const imagePosB = this.imageManager.getPattern(image.to.toString());\n return !imagePosA || !imagePosB;\n }\n\n useProgram(name: string, programConfiguration?: ProgramConfiguration | null): Program {\n this.cache = this.cache || {};\n const key = name +\n (programConfiguration ? programConfiguration.cacheKey : '') +\n (this._showOverdrawInspector ? '/overdraw' : '') +\n (this.style.map.terrain ? '/terrain' : '');\n if (!this.cache[key]) {\n this.cache[key] = new Program(\n this.context,\n shaders[name],\n programConfiguration,\n programUniforms[name],\n this._showOverdrawInspector,\n this.style.map.terrain\n );\n }\n return this.cache[key];\n }\n\n /*\n * Reset some GL state to default values to avoid hard-to-debug bugs\n * in custom layers.\n */\n setCustomLayerDefaults() {\n // Prevent custom layers from unintentionally modify the last VAO used.\n // All other state is state is restored on it's own, but for VAOs it's\n // simpler to unbind so that we don't have to track the state of VAOs.\n this.context.unbindVAO();\n\n // The default values for this state is meaningful and often expected.\n // Leaving this state dirty could cause a lot of confusion for users.\n this.context.cullFace.setDefault();\n this.context.activeTexture.setDefault();\n this.context.pixelStoreUnpack.setDefault();\n this.context.pixelStoreUnpackPremultiplyAlpha.setDefault();\n this.context.pixelStoreUnpackFlipY.setDefault();\n }\n\n /*\n * Set GL state that is shared by all layers.\n */\n setBaseState() {\n const gl = this.context.gl;\n this.context.cullFace.set(false);\n this.context.viewport.set([0, 0, this.width, this.height]);\n this.context.blendEquation.set(gl.FUNC_ADD);\n }\n\n initDebugOverlayCanvas() {\n if (this.debugOverlayCanvas == null) {\n this.debugOverlayCanvas = document.createElement('canvas');\n this.debugOverlayCanvas.width = 512;\n this.debugOverlayCanvas.height = 512;\n const gl = this.context.gl;\n this.debugOverlayTexture = new Texture(this.context, this.debugOverlayCanvas, gl.RGBA);\n }\n }\n\n destroy() {\n if (this.debugOverlayTexture) {\n this.debugOverlayTexture.destroy();\n }\n }\n\n /*\n * Return true if drawing buffer size is != from requested size.\n * That means that we've reached GL limits somehow.\n * Note: drawing buffer size changes only when canvas size changes\n */\n overLimit() {\n const {drawingBufferWidth, drawingBufferHeight} = this.context.gl;\n return this.width !== drawingBufferWidth || this.height !== drawingBufferHeight;\n }\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Program} from './program';\nimport {circleUniformValues} from './program/circle_program';\nimport {SegmentVector} from '../data/segment';\nimport {OverscaledTileID} from '../source/tile_id';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {CircleStyleLayer} from '../style/style_layer/circle_style_layer';\nimport type {CircleBucket} from '../data/bucket/circle_bucket';\nimport type {ProgramConfiguration} from '../data/program_configuration';\nimport type {VertexBuffer} from '../gl/vertex_buffer';\nimport type {IndexBuffer} from '../gl/index_buffer';\nimport type {UniformValues} from './uniform_binding';\nimport type {CircleUniformsType} from './program/circle_program';\nimport type {TerrainData} from '../render/terrain';\n\ntype TileRenderState = {\n programConfiguration: ProgramConfiguration;\n program: Program;\n layoutVertexBuffer: VertexBuffer;\n indexBuffer: IndexBuffer;\n uniformValues: UniformValues;\n terrainData: TerrainData;\n};\n\ntype SegmentsTileRenderState = {\n segments: SegmentVector;\n sortKey: number;\n state: TileRenderState;\n};\n\nexport function drawCircles(painter: Painter, sourceCache: SourceCache, layer: CircleStyleLayer, coords: Array) {\n if (painter.renderPass !== 'translucent') return;\n\n const opacity = layer.paint.get('circle-opacity');\n const strokeWidth = layer.paint.get('circle-stroke-width');\n const strokeOpacity = layer.paint.get('circle-stroke-opacity');\n const sortFeaturesByKey = !layer.layout.get('circle-sort-key').isConstant();\n\n if (opacity.constantOr(1) === 0 && (strokeWidth.constantOr(1) === 0 || strokeOpacity.constantOr(1) === 0)) {\n return;\n }\n\n const context = painter.context;\n const gl = context.gl;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n // Turn off stencil testing to allow circles to be drawn across boundaries,\n // so that large circles are not clipped to tiles\n const stencilMode = StencilMode.disabled;\n const colorMode = painter.colorModeForRenderPass();\n\n const segmentsRenderStates: Array = [];\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n\n const tile = sourceCache.getTile(coord);\n const bucket: CircleBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram('circle', programConfiguration);\n const layoutVertexBuffer = bucket.layoutVertexBuffer;\n const indexBuffer = bucket.indexBuffer;\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n const uniformValues = circleUniformValues(painter, coord, tile, layer);\n\n const state: TileRenderState = {\n programConfiguration,\n program,\n layoutVertexBuffer,\n indexBuffer,\n uniformValues,\n terrainData\n };\n\n if (sortFeaturesByKey) {\n const oldSegments = bucket.segments.get();\n for (const segment of oldSegments) {\n segmentsRenderStates.push({\n segments: new SegmentVector([segment]),\n sortKey: (segment.sortKey as any as number),\n state\n });\n }\n } else {\n segmentsRenderStates.push({\n segments: bucket.segments,\n sortKey: 0,\n state\n });\n }\n\n }\n\n if (sortFeaturesByKey) {\n segmentsRenderStates.sort((a, b) => a.sortKey - b.sortKey);\n }\n\n for (const segmentsState of segmentsRenderStates) {\n const {programConfiguration, program, layoutVertexBuffer, indexBuffer, uniformValues, terrainData} = segmentsState.state;\n const segments = segmentsState.segments;\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id,\n layoutVertexBuffer, indexBuffer, segments,\n layer.paint, painter.transform.zoom, programConfiguration);\n }\n}\n","import {Texture} from './texture';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\nimport {ColorMode} from '../gl/color_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Context} from '../gl/context';\nimport {Framebuffer} from '../gl/framebuffer';\nimport {\n heatmapUniformValues,\n heatmapTextureUniformValues\n} from './program/heatmap_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {HeatmapStyleLayer} from '../style/style_layer/heatmap_style_layer';\nimport type {HeatmapBucket} from '../data/bucket/heatmap_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\n\nexport function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapStyleLayer, coords: Array) {\n if (layer.paint.get('heatmap-opacity') === 0) {\n return;\n }\n\n if (painter.renderPass === 'offscreen') {\n const context = painter.context;\n const gl = context.gl;\n\n // Allow kernels to be drawn across boundaries, so that\n // large kernels are not clipped to tiles\n const stencilMode = StencilMode.disabled;\n // Turn on additive blending for kernels, which is a key aspect of kernel density estimation formula\n const colorMode = new ColorMode([gl.ONE, gl.ONE], Color.transparent, [true, true, true, true]);\n\n bindFramebuffer(context, painter, layer);\n\n context.clear({color: Color.transparent});\n\n for (let i = 0; i < coords.length; i++) {\n const coord = coords[i];\n\n // Skip tiles that have uncovered parents to avoid flickering; we don't need\n // to use complex tile masking here because the change between zoom levels is subtle,\n // so it's fine to simply render the parent until all its 4 children are loaded\n if (sourceCache.hasRenderableParent(coord)) continue;\n\n const tile = sourceCache.getTile(coord);\n const bucket: HeatmapBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const program = painter.useProgram('heatmap', programConfiguration);\n const {zoom} = painter.transform;\n\n program.draw(context, gl.TRIANGLES, DepthMode.disabled, stencilMode, colorMode, CullFaceMode.disabled,\n heatmapUniformValues(coord.posMatrix, tile, zoom, layer.paint.get('heatmap-intensity')), null,\n layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer,\n bucket.segments, layer.paint, painter.transform.zoom,\n programConfiguration);\n }\n\n context.viewport.set([0, 0, painter.width, painter.height]);\n\n } else if (painter.renderPass === 'translucent') {\n painter.context.setColorMode(painter.colorModeForRenderPass());\n renderTextureToMap(painter, layer);\n }\n}\n\nfunction bindFramebuffer(context: Context, painter: Painter, layer: HeatmapStyleLayer) {\n const gl = context.gl;\n context.activeTexture.set(gl.TEXTURE1);\n\n // Use a 4x downscaled screen texture for better performance\n context.viewport.set([0, 0, painter.width / 4, painter.height / 4]);\n\n let fbo = layer.heatmapFbo;\n\n if (!fbo) {\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\n fbo = layer.heatmapFbo = context.createFramebuffer(painter.width / 4, painter.height / 4, false, false);\n\n bindTextureToFramebuffer(context, painter, texture, fbo);\n\n } else {\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n context.bindFramebuffer.set(fbo.framebuffer);\n }\n}\n\nfunction bindTextureToFramebuffer(context: Context, painter: Painter, texture: WebGLTexture, fbo: Framebuffer) {\n const gl = context.gl;\n // Use the higher precision half-float texture where available (producing much smoother looking heatmaps);\n // Otherwise, fall back to a low precision texture\n\n const numType = context.HALF_FLOAT ?? gl.UNSIGNED_BYTE;\n const internalFormat = context.RGBA16F ?? gl.RGBA;\n\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, painter.width / 4, painter.height / 4, 0, gl.RGBA, numType, null);\n fbo.colorAttachment.set(texture);\n}\n\nfunction renderTextureToMap(painter: Painter, layer: HeatmapStyleLayer) {\n const context = painter.context;\n const gl = context.gl;\n\n // Here we bind two different textures from which we'll sample in drawing\n // heatmaps: the kernel texture, prepared in the offscreen pass, and a\n // color ramp texture.\n const fbo = layer.heatmapFbo;\n if (!fbo) return;\n context.activeTexture.set(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());\n\n context.activeTexture.set(gl.TEXTURE1);\n let colorRampTexture = layer.colorRampTexture;\n if (!colorRampTexture) {\n colorRampTexture = layer.colorRampTexture = new Texture(context, layer.colorRamp, gl.RGBA);\n }\n colorRampTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n\n painter.useProgram('heatmapTexture').draw(context, gl.TRIANGLES,\n DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled,\n heatmapTextureUniformValues(painter, layer, 0, 1), null,\n layer.id, painter.viewportBuffer, painter.quadTriangleIndexBuffer,\n painter.viewportSegments, layer.paint, painter.transform.zoom);\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {Texture} from './texture';\nimport {\n lineUniformValues,\n linePatternUniformValues,\n lineSDFUniformValues,\n lineGradientUniformValues\n} from './program/line_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {LineStyleLayer} from '../style/style_layer/line_style_layer';\nimport type {LineBucket} from '../data/bucket/line_bucket';\nimport type {OverscaledTileID} from '../source/tile_id';\nimport {clamp, nextPowerOfTwo} from '../util/util';\nimport {renderColorRamp} from '../util/color_ramp';\nimport {EXTENT} from '../data/extent';\n\nexport function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array) {\n if (painter.renderPass !== 'translucent') return;\n\n const opacity = layer.paint.get('line-opacity');\n const width = layer.paint.get('line-width');\n if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return;\n\n const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n\n const dasharray = layer.paint.get('line-dasharray');\n const patternProperty = layer.paint.get('line-pattern');\n const image = patternProperty.constantOr(1 as any);\n\n const gradient = layer.paint.get('line-gradient');\n const crossfade = layer.getCrossfadeParameters();\n\n const programId =\n image ? 'linePattern' :\n dasharray ? 'lineSDF' :\n gradient ? 'lineGradient' : 'line';\n\n const context = painter.context;\n const gl = context.gl;\n\n let firstTile = true;\n\n for (const coord of coords) {\n const tile = sourceCache.getTile(coord);\n\n if (image && !tile.patternsLoaded()) continue;\n\n const bucket: LineBucket = (tile.getBucket(layer) as any);\n if (!bucket) continue;\n\n const programConfiguration = bucket.programConfigurations.get(layer.id);\n const prevProgram = painter.context.program.get();\n const program = painter.useProgram(programId, programConfiguration);\n const programChanged = firstTile || program.program !== prevProgram;\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord);\n\n const constantPattern = patternProperty.constantOr(null);\n if (constantPattern && tile.imageAtlas) {\n const atlas = tile.imageAtlas;\n const posTo = atlas.patternPositions[constantPattern.to.toString()];\n const posFrom = atlas.patternPositions[constantPattern.from.toString()];\n if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);\n }\n\n const terrainCoord = terrainData ? coord : null;\n const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade, terrainCoord) :\n dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade, terrainCoord) :\n gradient ? lineGradientUniformValues(painter, tile, layer, bucket.lineClipsArray.length, terrainCoord) :\n lineUniformValues(painter, tile, layer, terrainCoord);\n\n if (image) {\n context.activeTexture.set(gl.TEXTURE0);\n tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);\n programConfiguration.updatePaintBuffers(crossfade);\n } else if (dasharray && (programChanged || painter.lineAtlas.dirty)) {\n context.activeTexture.set(gl.TEXTURE0);\n painter.lineAtlas.bind(context);\n } else if (gradient) {\n const layerGradient = bucket.gradients[layer.id];\n let gradientTexture = layerGradient.texture;\n if (layer.gradientVersion !== layerGradient.version) {\n let textureResolution = 256;\n if (layer.stepInterpolant) {\n const sourceMaxZoom = sourceCache.getSource().maxzoom;\n const potentialOverzoom = coord.canonical.z === sourceMaxZoom ?\n Math.ceil(1 << (painter.transform.maxZoom - coord.canonical.z)) : 1;\n const lineLength = bucket.maxLineLength / EXTENT;\n // Logical pixel tile size is 512px, and 1024px right before current zoom + 1\n const maxTilePixelSize = 1024;\n // Maximum possible texture coverage heuristic, bound by hardware max texture size\n const maxTextureCoverage = lineLength * maxTilePixelSize * potentialOverzoom;\n textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize);\n }\n layerGradient.gradient = renderColorRamp({\n expression: layer.gradientExpression(),\n evaluationKey: 'lineProgress',\n resolution: textureResolution,\n image: layerGradient.gradient || undefined,\n clips: bucket.lineClipsArray\n });\n if (layerGradient.texture) {\n layerGradient.texture.update(layerGradient.gradient);\n } else {\n layerGradient.texture = new Texture(context, layerGradient.gradient, gl.RGBA);\n }\n layerGradient.version = layer.gradientVersion;\n gradientTexture = layerGradient.texture;\n }\n context.activeTexture.set(gl.TEXTURE0);\n gradientTexture.bind(layer.stepInterpolant ? gl.NEAREST : gl.LINEAR, gl.CLAMP_TO_EDGE);\n }\n\n program.draw(context, gl.TRIANGLES, depthMode,\n painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData,\n layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments,\n layer.paint, painter.transform.zoom, programConfiguration, bucket.layoutVertexBuffer2);\n\n firstTile = false;\n // once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic\n }\n}\n","import {StencilMode} from '../gl/stencil_mode';\nimport {DepthMode} from '../gl/depth_mode';\nimport {CullFaceMode} from '../gl/cull_face_mode';\nimport {\n backgroundUniformValues,\n backgroundPatternUniformValues\n} from './program/background_program';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {BackgroundStyleLayer} from '../style/style_layer/background_style_layer';\nimport {OverscaledTileID} from '../source/tile_id';\n\nexport function drawBackground(painter: Painter, sourceCache: SourceCache, layer: BackgroundStyleLayer, coords?: Array) {\n const color = layer.paint.get('background-color');\n const opacity = layer.paint.get('background-opacity');\n\n if (opacity === 0) return;\n\n const context = painter.context;\n const gl = context.gl;\n const transform = painter.transform;\n const tileSize = transform.tileSize;\n const image = layer.paint.get('background-pattern');\n if (painter.isPatternMissing(image)) return;\n\n const pass = (!image && color.a === 1 && opacity === 1 && painter.opaquePassEnabledForLayer()) ? 'opaque' : 'translucent';\n if (painter.renderPass !== pass) return;\n\n const stencilMode = StencilMode.disabled;\n const depthMode = painter.depthModeForSublayer(0, pass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly);\n const colorMode = painter.colorModeForRenderPass();\n const program = painter.useProgram(image ? 'backgroundPattern' : 'background');\n const tileIDs = coords ? coords : transform.coveringTiles({tileSize, terrain: painter.style.map.terrain});\n\n if (image) {\n context.activeTexture.set(gl.TEXTURE0);\n painter.imageManager.bind(painter.context);\n }\n\n const crossfade = layer.getCrossfadeParameters();\n for (const tileID of tileIDs) {\n const matrix = coords ? tileID.posMatrix : painter.transform.calculatePosMatrix(tileID.toUnwrapped());\n const uniformValues = image ?\n backgroundPatternUniformValues(matrix, opacity, painter, image, {tileID, tileSize}, crossfade) :\n backgroundUniformValues(matrix, opacity, color);\n const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(tileID);\n\n program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,\n uniformValues, terrainData, layer.id, painter.tileExtentBuffer,\n painter.quadTriangleIndexBuffer, painter.tileExtentSegments);\n }\n}\n","import {DepthMode} from '../gl/depth_mode';\nimport {StencilMode} from '../gl/stencil_mode';\n\nimport type {Painter} from './painter';\nimport type {SourceCache} from '../source/source_cache';\nimport type {CustomStyleLayer} from '../style/style_layer/custom_style_layer';\n\nexport function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) {\n\n const context = painter.context;\n const implementation = layer.implementation;\n\n if (painter.renderPass === 'offscreen') {\n\n const prerender = implementation.prerender;\n if (prerender) {\n painter.setCustomLayerDefaults();\n context.setColorMode(painter.colorModeForRenderPass());\n\n prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());\n\n context.setDirty();\n painter.setBaseState();\n }\n\n } else if (painter.renderPass === 'translucent') {\n\n painter.setCustomLayerDefaults();\n\n context.setColorMode(painter.colorModeForRenderPass());\n context.setStencilMode(StencilMode.disabled);\n\n const depthMode = implementation.renderingMode === '3d' ?\n new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D) :\n painter.depthModeForSublayer(0, DepthMode.ReadOnly);\n\n context.setDepthMode(depthMode);\n\n implementation.render(context.gl, painter.transform.customLayerMatrix());\n\n context.setDirty();\n painter.setBaseState();\n context.bindFramebuffer.set(null);\n }\n}\n","import {mat4, vec3, vec4} from 'gl-matrix';\n\nclass Frustum {\n\n constructor(public points: vec4[], public planes: vec4[]) { }\n\n public static fromInvProjectionMatrix(invProj: mat4, worldSize: number, zoom: number): Frustum {\n const clipSpaceCorners = [\n [-1, 1, -1, 1],\n [1, 1, -1, 1],\n [1, -1, -1, 1],\n [-1, -1, -1, 1],\n [-1, 1, 1, 1],\n [1, 1, 1, 1],\n [1, -1, 1, 1],\n [-1, -1, 1, 1]\n ];\n\n const scale = Math.pow(2, zoom);\n\n // Transform frustum corner points from clip space to tile space, Z to meters\n const frustumCoords = clipSpaceCorners.map(v => {\n v = vec4.transformMat4([] as any, v as any, invProj) as any;\n const s = 1.0 / v[3] / worldSize * scale;\n return vec4.mul(v as any, v as any, [s, s, 1.0 / v[3], s] as vec4);\n });\n\n const frustumPlanePointIndices = [\n [0, 1, 2], // near\n [6, 5, 4], // far\n [0, 3, 7], // left\n [2, 1, 5], // right\n [3, 2, 6], // bottom\n [0, 4, 5] // top\n ];\n\n const frustumPlanes = frustumPlanePointIndices.map((p: number[]) => {\n const a = vec3.sub([] as any, frustumCoords[p[0]] as vec3, frustumCoords[p[1]] as vec3);\n const b = vec3.sub([] as any, frustumCoords[p[2]] as vec3, frustumCoords[p[1]] as vec3);\n const n = vec3.normalize([] as any, vec3.cross([] as any, a, b)) as any;\n const d = -vec3.dot(n, frustumCoords[p[1]] as vec3);\n return n.concat(d);\n });\n\n return new Frustum(frustumCoords, frustumPlanes);\n }\n}\n\nclass Aabb {\n min: vec3;\n max: vec3;\n center: vec3;\n\n constructor(min_: vec3, max_: vec3) {\n this.min = min_;\n this.max = max_;\n this.center = vec3.scale([] as any, vec3.add([] as any, this.min, this.max), 0.5);\n }\n\n quadrant(index: number): Aabb {\n const split = [(index % 2) === 0, index < 2];\n const qMin = vec3.clone(this.min);\n const qMax = vec3.clone(this.max);\n for (let axis = 0; axis < split.length; axis++) {\n qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];\n qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];\n }\n // Elevation is always constant, hence quadrant.max.z = this.max.z\n qMax[2] = this.max[2];\n return new Aabb(qMin, qMax);\n }\n\n distanceX(point: Array): number {\n const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);\n return pointOnAabb - point[0];\n }\n\n distanceY(point: Array): number {\n const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);\n return pointOnAabb - point[1];\n }\n\n // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,\n // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.\n intersects(frustum: Frustum): number {\n // Execute separating axis test between two convex objects to find intersections\n // Each frustum plane together with 3 major axes define the separating axes\n\n const aabbPoints = [\n [this.min[0], this.min[1], this.min[2], 1],\n [this.max[0], this.min[1], this.min[2], 1],\n [this.max[0], this.max[1], this.min[2], 1],\n [this.min[0], this.max[1], this.min[2], 1],\n [this.min[0], this.min[1], this.max[2], 1],\n [this.max[0], this.min[1], this.max[2], 1],\n [this.max[0], this.max[1], this.max[2], 1],\n [this.min[0], this.max[1], this.max[2], 1]\n ];\n\n let fullyInside = true;\n\n for (let p = 0; p < frustum.planes.length; p++) {\n const plane = frustum.planes[p];\n let pointsInside = 0;\n\n for (let i = 0; i < aabbPoints.length; i++) {\n if (vec4.dot(plane, aabbPoints[i] as any) >= 0) {\n pointsInside++;\n }\n }\n\n if (pointsInside === 0)\n return 0;\n\n if (pointsInside !== aabbPoints.length)\n fullyInside = false;\n }\n\n if (fullyInside)\n return 2;\n\n for (let axis = 0; axis < 3; axis++) {\n let projMin = Number.MAX_VALUE;\n let projMax = -Number.MAX_VALUE;\n\n for (let p = 0; p < frustum.points.length; p++) {\n const projectedPoint = frustum.points[p][axis] - this.min[axis];\n\n projMin = Math.min(projMin, projectedPoint);\n projMax = Math.max(projMax, projectedPoint);\n }\n\n if (projMax < 0 || projMin > this.max[axis] - this.min[axis])\n return 0;\n }\n\n return 1;\n }\n}\nexport {\n Aabb,\n Frustum\n};\n","import {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport Point from '@mapbox/point-geometry';\nimport {clamp} from '../util/util';\n\n/**\n * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.\n * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements\n * on top of the map and having the vanishing point shift as UI elements resize.\n *\n * @group Geography and Geometry\n */\nexport class EdgeInsets {\n /**\n * @defaultValue 0\n */\n top: number;\n /**\n * @defaultValue 0\n */\n bottom: number;\n /**\n * @defaultValue 0\n */\n left: number;\n /**\n * @defaultValue 0\n */\n right: number;\n\n constructor(top: number = 0, bottom: number = 0, left: number = 0, right: number = 0) {\n if (isNaN(top) || top < 0 ||\n isNaN(bottom) || bottom < 0 ||\n isNaN(left) || left < 0 ||\n isNaN(right) || right < 0\n ) {\n throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');\n }\n\n this.top = top;\n this.bottom = bottom;\n this.left = left;\n this.right = right;\n }\n\n /**\n * Interpolates the inset in-place.\n * This maintains the current inset value for any inset not present in `target`.\n * @param start - interpolation start\n * @param target - interpolation target\n * @param t - interpolation step/weight\n * @returns the insets\n */\n interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets {\n if (target.top != null && start.top != null) this.top = interpolates.number(start.top, target.top, t);\n if (target.bottom != null && start.bottom != null) this.bottom = interpolates.number(start.bottom, target.bottom, t);\n if (target.left != null && start.left != null) this.left = interpolates.number(start.left, target.left, t);\n if (target.right != null && start.right != null) this.right = interpolates.number(start.right, target.right, t);\n\n return this;\n }\n\n /**\n * Utility method that computes the new apprent center or vanishing point after applying insets.\n * This is in pixels and with the top left being (0.0) and +y being downwards.\n *\n * @param width - the width\n * @param height - the height\n * @returns the point\n */\n getCenter(width: number, height: number): Point {\n // Clamp insets so they never overflow width/height and always calculate a valid center\n const x = clamp((this.left + width - this.right) / 2, 0, width);\n const y = clamp((this.top + height - this.bottom) / 2, 0, height);\n\n return new Point(x, y);\n }\n\n equals(other: PaddingOptions): boolean {\n return this.top === other.top &&\n this.bottom === other.bottom &&\n this.left === other.left &&\n this.right === other.right;\n }\n\n clone(): EdgeInsets {\n return new EdgeInsets(this.top, this.bottom, this.left, this.right);\n }\n\n /**\n * Returns the current state as json, useful when you want to have a\n * read-only representation of the inset.\n *\n * @returns state as json\n */\n toJSON(): PaddingOptions {\n return {\n top: this.top,\n bottom: this.bottom,\n left: this.left,\n right: this.right\n };\n }\n}\n\n/**\n * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be\n * non-negative integers.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n *\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: 20\n * });\n * ```\n * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/)\n * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)\n */\nexport type PaddingOptions = {\n /**\n * Padding in pixels from the top of the map canvas.\n */\n top: number;\n /**\n * Padding in pixels from the bottom of the map canvas.\n */\n bottom: number;\n /**\n * Padding in pixels from the left of the map canvas.\n */\n right: number;\n /**\n * Padding in pixels from the right of the map canvas.\n */\n left: number;\n};\n","import {LngLat} from './lng_lat';\nimport {LngLatBounds} from './lng_lat_bounds';\nimport {MercatorCoordinate, mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude} from './mercator_coordinate';\nimport Point from '@mapbox/point-geometry';\nimport {wrap, clamp} from '../util/util';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {EXTENT} from '../data/extent';\nimport {vec3, vec4, mat4, mat2, vec2} from 'gl-matrix';\nimport {Aabb, Frustum} from '../util/primitives';\nimport {EdgeInsets} from './edge_insets';\n\nimport {UnwrappedTileID, OverscaledTileID, CanonicalTileID} from '../source/tile_id';\nimport type {PaddingOptions} from './edge_insets';\nimport {Terrain} from '../render/terrain';\n\n/**\n * @internal\n * A single transform, generally used for a single tile to be\n * scaled, rotated, and zoomed.\n */\nexport class Transform {\n tileSize: number;\n tileZoom: number;\n lngRange: [number, number];\n latRange: [number, number];\n maxValidLatitude: number;\n scale: number;\n width: number;\n height: number;\n angle: number;\n rotationMatrix: mat2;\n pixelsToGLUnits: [number, number];\n cameraToCenterDistance: number;\n mercatorMatrix: mat4;\n projMatrix: mat4;\n invProjMatrix: mat4;\n alignedProjMatrix: mat4;\n pixelMatrix: mat4;\n pixelMatrix3D: mat4;\n pixelMatrixInverse: mat4;\n glCoordMatrix: mat4;\n labelPlaneMatrix: mat4;\n _fov: number;\n _pitch: number;\n _zoom: number;\n _unmodified: boolean;\n _renderWorldCopies: boolean;\n _minZoom: number;\n _maxZoom: number;\n _minPitch: number;\n _maxPitch: number;\n _center: LngLat;\n _elevation: number;\n _pixelPerMeter: number;\n _edgeInsets: EdgeInsets;\n _constraining: boolean;\n _posMatrixCache: {[_: string]: mat4};\n _alignedPosMatrixCache: {[_: string]: mat4};\n _minEleveationForCurrentTile: number;\n\n constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean) {\n this.tileSize = 512; // constant\n this.maxValidLatitude = 85.051129; // constant\n\n this._renderWorldCopies = renderWorldCopies === undefined ? true : !!renderWorldCopies;\n this._minZoom = minZoom || 0;\n this._maxZoom = maxZoom || 22;\n\n this._minPitch = (minPitch === undefined || minPitch === null) ? 0 : minPitch;\n this._maxPitch = (maxPitch === undefined || maxPitch === null) ? 60 : maxPitch;\n\n this.setMaxBounds();\n\n this.width = 0;\n this.height = 0;\n this._center = new LngLat(0, 0);\n this._elevation = 0;\n this.zoom = 0;\n this.angle = 0;\n this._fov = 0.6435011087932844;\n this._pitch = 0;\n this._unmodified = true;\n this._edgeInsets = new EdgeInsets();\n this._posMatrixCache = {};\n this._alignedPosMatrixCache = {};\n this._minEleveationForCurrentTile = 0;\n }\n\n clone(): Transform {\n const clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies);\n clone.apply(this);\n return clone;\n }\n\n apply(that: Transform) {\n this.tileSize = that.tileSize;\n this.latRange = that.latRange;\n this.width = that.width;\n this.height = that.height;\n this._center = that._center;\n this._elevation = that._elevation;\n this._minEleveationForCurrentTile = that._minEleveationForCurrentTile;\n this.zoom = that.zoom;\n this.angle = that.angle;\n this._fov = that._fov;\n this._pitch = that._pitch;\n this._unmodified = that._unmodified;\n this._edgeInsets = that._edgeInsets.clone();\n this._calcMatrices();\n }\n\n get minZoom(): number { return this._minZoom; }\n set minZoom(zoom: number) {\n if (this._minZoom === zoom) return;\n this._minZoom = zoom;\n this.zoom = Math.max(this.zoom, zoom);\n }\n\n get maxZoom(): number { return this._maxZoom; }\n set maxZoom(zoom: number) {\n if (this._maxZoom === zoom) return;\n this._maxZoom = zoom;\n this.zoom = Math.min(this.zoom, zoom);\n }\n\n get minPitch(): number { return this._minPitch; }\n set minPitch(pitch: number) {\n if (this._minPitch === pitch) return;\n this._minPitch = pitch;\n this.pitch = Math.max(this.pitch, pitch);\n }\n\n get maxPitch(): number { return this._maxPitch; }\n set maxPitch(pitch: number) {\n if (this._maxPitch === pitch) return;\n this._maxPitch = pitch;\n this.pitch = Math.min(this.pitch, pitch);\n }\n\n get renderWorldCopies(): boolean { return this._renderWorldCopies; }\n set renderWorldCopies(renderWorldCopies: boolean) {\n if (renderWorldCopies === undefined) {\n renderWorldCopies = true;\n } else if (renderWorldCopies === null) {\n renderWorldCopies = false;\n }\n\n this._renderWorldCopies = renderWorldCopies;\n }\n\n get worldSize(): number {\n return this.tileSize * this.scale;\n }\n\n get centerOffset(): Point {\n return this.centerPoint._sub(this.size._div(2));\n }\n\n get size(): Point {\n return new Point(this.width, this.height);\n }\n\n get bearing(): number {\n return -this.angle / Math.PI * 180;\n }\n set bearing(bearing: number) {\n const b = -wrap(bearing, -180, 180) * Math.PI / 180;\n if (this.angle === b) return;\n this._unmodified = false;\n this.angle = b;\n this._calcMatrices();\n\n // 2x2 matrix for rotating points\n this.rotationMatrix = mat2.create();\n mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);\n }\n\n get pitch(): number {\n return this._pitch / Math.PI * 180;\n }\n set pitch(pitch: number) {\n const p = clamp(pitch, this.minPitch, this.maxPitch) / 180 * Math.PI;\n if (this._pitch === p) return;\n this._unmodified = false;\n this._pitch = p;\n this._calcMatrices();\n }\n\n get fov(): number {\n return this._fov / Math.PI * 180;\n }\n set fov(fov: number) {\n fov = Math.max(0.01, Math.min(60, fov));\n if (this._fov === fov) return;\n this._unmodified = false;\n this._fov = fov / 180 * Math.PI;\n this._calcMatrices();\n }\n\n get zoom(): number { return this._zoom; }\n set zoom(zoom: number) {\n const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);\n if (this._zoom === constrainedZoom) return;\n this._unmodified = false;\n this._zoom = constrainedZoom;\n this.tileZoom = Math.max(0, Math.floor(constrainedZoom));\n this.scale = this.zoomScale(constrainedZoom);\n this._constrain();\n this._calcMatrices();\n }\n\n get center(): LngLat { return this._center; }\n set center(center: LngLat) {\n if (center.lat === this._center.lat && center.lng === this._center.lng) return;\n this._unmodified = false;\n this._center = center;\n this._constrain();\n this._calcMatrices();\n }\n\n get elevation(): number { return this._elevation; }\n set elevation(elevation: number) {\n if (elevation === this._elevation) return;\n this._elevation = elevation;\n this._constrain();\n this._calcMatrices();\n }\n\n get padding(): PaddingOptions { return this._edgeInsets.toJSON(); }\n set padding(padding: PaddingOptions) {\n if (this._edgeInsets.equals(padding)) return;\n this._unmodified = false;\n //Update edge-insets inplace\n this._edgeInsets.interpolate(this._edgeInsets, padding, 1);\n this._calcMatrices();\n }\n\n /**\n * The center of the screen in pixels with the top-left corner being (0,0)\n * and +y axis pointing downwards. This accounts for padding.\n */\n get centerPoint(): Point {\n return this._edgeInsets.getCenter(this.width, this.height);\n }\n\n /**\n * Returns if the padding params match\n *\n * @param padding - the padding to check against\n * @returns true if they are equal, false otherwise\n */\n isPaddingEqual(padding: PaddingOptions): boolean {\n return this._edgeInsets.equals(padding);\n }\n\n /**\n * Helper method to update edge-insets in place\n *\n * @param start - the starting padding\n * @param target - the target padding\n * @param t - the step/weight\n */\n interpolatePadding(start: PaddingOptions, target: PaddingOptions, t: number) {\n this._unmodified = false;\n this._edgeInsets.interpolate(start, target, t);\n this._constrain();\n this._calcMatrices();\n }\n\n /**\n * Return a zoom level that will cover all tiles the transform\n * @param options - the options\n * @returns zoom level An integer zoom level at which all tiles will be visible.\n */\n coveringZoomLevel(options: {\n /**\n * Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.\n */\n roundZoom?: boolean;\n /**\n * Tile size, expressed in screen pixels.\n */\n tileSize: number;\n }): number {\n const z = (options.roundZoom ? Math.round : Math.floor)(\n this.zoom + this.scaleZoom(this.tileSize / options.tileSize)\n );\n // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.\n return Math.max(0, z);\n }\n\n /**\n * Return any \"wrapped\" copies of a given tile coordinate that are visible\n * in the current view.\n */\n getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) {\n const result = [new UnwrappedTileID(0, tileID)];\n if (this._renderWorldCopies) {\n const utl = this.pointCoordinate(new Point(0, 0));\n const utr = this.pointCoordinate(new Point(this.width, 0));\n const ubl = this.pointCoordinate(new Point(this.width, this.height));\n const ubr = this.pointCoordinate(new Point(0, this.height));\n const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));\n const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));\n\n // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.\n // Both sources draw outside the tile boundaries of the tile that \"contains them\" so we need\n // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.\n const extraWorldCopy = 1;\n\n for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {\n if (w === 0) continue;\n result.push(new UnwrappedTileID(w, tileID));\n }\n }\n return result;\n }\n\n /**\n * Return all coordinates that could cover this transform for a covering\n * zoom level.\n * @param options - the options\n * @returns OverscaledTileIDs\n */\n coveringTiles(\n options: {\n tileSize: number;\n minzoom?: number;\n maxzoom?: number;\n roundZoom?: boolean;\n reparseOverscaled?: boolean;\n renderWorldCopies?: boolean;\n terrain?: Terrain;\n }\n ): Array {\n let z = this.coveringZoomLevel(options);\n const actualZ = z;\n\n if (options.minzoom !== undefined && z < options.minzoom) return [];\n if (options.maxzoom !== undefined && z > options.maxzoom) z = options.maxzoom;\n\n const cameraCoord = this.pointCoordinate(this.getCameraPoint());\n const centerCoord = MercatorCoordinate.fromLngLat(this.center);\n const numTiles = Math.pow(2, z);\n const cameraPoint = [numTiles * cameraCoord.x, numTiles * cameraCoord.y, 0];\n const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];\n const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, z);\n\n // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level\n let minZoom = options.minzoom || 0;\n // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks\n if (!options.terrain && this.pitch <= 60.0 && this._edgeInsets.top < 0.1)\n minZoom = z;\n\n // There should always be a certain number of maximum zoom level tiles surrounding the center location in 2D or in front of the camera in 3D\n const radiusOfMaxLvlLodInTiles = options.terrain ? 2 / Math.min(this.tileSize, options.tileSize) * this.tileSize : 3;\n\n const newRootTile = (wrap: number): any => {\n return {\n aabb: new Aabb([wrap * numTiles, 0, 0], [(wrap + 1) * numTiles, numTiles, 0]),\n zoom: 0,\n x: 0,\n y: 0,\n wrap,\n fullyVisible: false\n };\n };\n\n // Do a depth-first traversal to find visible tiles and proper levels of detail\n const stack = [];\n const result = [];\n const maxZoom = z;\n const overscaledZ = options.reparseOverscaled ? actualZ : z;\n\n if (this._renderWorldCopies) {\n // Render copy of the globe thrice on both sides\n for (let i = 1; i <= 3; i++) {\n stack.push(newRootTile(-i));\n stack.push(newRootTile(i));\n }\n }\n\n stack.push(newRootTile(0));\n\n while (stack.length > 0) {\n const it = stack.pop();\n const x = it.x;\n const y = it.y;\n let fullyVisible = it.fullyVisible;\n\n // Visibility of a tile is not required if any of its ancestor if fully inside the frustum\n if (!fullyVisible) {\n const intersectResult = it.aabb.intersects(cameraFrustum);\n\n if (intersectResult === 0)\n continue;\n\n fullyVisible = intersectResult === 2;\n }\n\n const refPoint = options.terrain ? cameraPoint : centerPoint;\n const distanceX = it.aabb.distanceX(refPoint);\n const distanceY = it.aabb.distanceY(refPoint);\n const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));\n\n // We're using distance based heuristics to determine if a tile should be split into quadrants or not.\n // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.\n // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)\n // we can define distance thresholds for each relative level:\n // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as \"offset+2^(k+1)-2\"\n const distToSplit = radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;\n\n // Have we reached the target depth or is the tile too far away to be any split further?\n if (it.zoom === maxZoom || (longestDim > distToSplit && it.zoom >= minZoom)) {\n const dz = maxZoom - it.zoom, dx = cameraPoint[0] - 0.5 - (x << dz), dy = cameraPoint[1] - 0.5 - (y << dz);\n result.push({\n tileID: new OverscaledTileID(it.zoom === maxZoom ? overscaledZ : it.zoom, it.wrap, it.zoom, x, y),\n distanceSq: vec2.sqrLen([centerPoint[0] - 0.5 - x, centerPoint[1] - 0.5 - y]),\n // this variable is currently not used, but may be important to reduce the amount of loaded tiles\n tileDistanceToCamera: Math.sqrt(dx * dx + dy * dy)\n });\n continue;\n }\n\n for (let i = 0; i < 4; i++) {\n const childX = (x << 1) + (i % 2);\n const childY = (y << 1) + (i >> 1);\n const childZ = it.zoom + 1;\n let quadrant = it.aabb.quadrant(i);\n if (options.terrain) {\n const tileID = new OverscaledTileID(childZ, it.wrap, childZ, childX, childY);\n const minMax = options.terrain.getMinMaxElevation(tileID);\n const minElevation = minMax.minElevation ?? this.elevation;\n const maxElevation = minMax.maxElevation ?? this.elevation;\n quadrant = new Aabb(\n [quadrant.min[0], quadrant.min[1], minElevation] as vec3,\n [quadrant.max[0], quadrant.max[1], maxElevation] as vec3\n );\n }\n stack.push({aabb: quadrant, zoom: childZ, x: childX, y: childY, wrap: it.wrap, fullyVisible});\n }\n }\n\n return result.sort((a, b) => a.distanceSq - b.distanceSq).map(a => a.tileID);\n }\n\n resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n this.pixelsToGLUnits = [2 / width, -2 / height];\n this._constrain();\n this._calcMatrices();\n }\n\n get unmodified(): boolean { return this._unmodified; }\n\n zoomScale(zoom: number) { return Math.pow(2, zoom); }\n scaleZoom(scale: number) { return Math.log(scale) / Math.LN2; }\n\n project(lnglat: LngLat) {\n const lat = clamp(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude);\n return new Point(\n mercatorXfromLng(lnglat.lng) * this.worldSize,\n mercatorYfromLat(lat) * this.worldSize);\n }\n\n unproject(point: Point): LngLat {\n return new MercatorCoordinate(point.x / this.worldSize, point.y / this.worldSize).toLngLat();\n }\n\n get point(): Point { return this.project(this.center); }\n\n /**\n * get the camera position in LngLat and altitudes in meter\n * @returns An object with lngLat & altitude.\n */\n getCameraPosition(): {\n lngLat: LngLat;\n altitude: number;\n } {\n const lngLat = this.pointLocation(this.getCameraPoint());\n const altitude = Math.cos(this._pitch) * this.cameraToCenterDistance / this._pixelPerMeter;\n return {lngLat, altitude: altitude + this.elevation};\n }\n\n /**\n * This method works in combination with freezeElevation activated.\n * freezeElevtion is enabled during map-panning because during this the camera should sit in constant height.\n * After panning finished, call this method to recalculate the zoomlevel for the current camera-height in current terrain.\n * @param terrain - the terrain\n */\n recalculateZoom(terrain: Terrain) {\n // find position the camera is looking on\n const center = this.pointLocation(this.centerPoint, terrain);\n const elevation = terrain.getElevationForLngLatZoom(center, this.tileZoom);\n const deltaElevation = this.elevation - elevation;\n if (!deltaElevation) return;\n\n // calculate mercator distance between camera & target\n const cameraPosition = this.getCameraPosition();\n const camera = MercatorCoordinate.fromLngLat(cameraPosition.lngLat, cameraPosition.altitude);\n const target = MercatorCoordinate.fromLngLat(center, elevation);\n const dx = camera.x - target.x, dy = camera.y - target.y, dz = camera.z - target.z;\n const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);\n\n // from this distance we calculate the new zoomlevel\n const zoom = this.scaleZoom(this.cameraToCenterDistance / distance / this.tileSize);\n\n // update matrices\n this._elevation = elevation;\n this._center = center;\n this.zoom = zoom;\n }\n\n setLocationAtPoint(lnglat: LngLat, point: Point) {\n const a = this.pointCoordinate(point);\n const b = this.pointCoordinate(this.centerPoint);\n const loc = this.locationCoordinate(lnglat);\n const newCenter = new MercatorCoordinate(\n loc.x - (a.x - b.x),\n loc.y - (a.y - b.y));\n this.center = this.coordinateLocation(newCenter);\n if (this._renderWorldCopies) {\n this.center = this.center.wrap();\n }\n }\n\n /**\n * Given a location, return the screen point that corresponds to it\n * @param lnglat - location\n * @param terrain - optional terrain\n * @returns screen point\n */\n locationPoint(lnglat: LngLat, terrain?: Terrain): Point {\n return terrain ?\n this.coordinatePoint(this.locationCoordinate(lnglat), terrain.getElevationForLngLatZoom(lnglat, this.tileZoom), this.pixelMatrix3D) :\n this.coordinatePoint(this.locationCoordinate(lnglat));\n }\n\n /**\n * Given a point on screen, return its lnglat\n * @param p - screen point\n * @param terrain - optional terrain\n * @returns lnglat location\n */\n pointLocation(p: Point, terrain?: Terrain): LngLat {\n return this.coordinateLocation(this.pointCoordinate(p, terrain));\n }\n\n /**\n * Given a geographical lnglat, return an unrounded\n * coordinate that represents it at this transform's zoom level.\n * @param lnglat - the location\n * @returns The mercator coordinate\n */\n locationCoordinate(lnglat: LngLat): MercatorCoordinate {\n return MercatorCoordinate.fromLngLat(lnglat);\n }\n\n /**\n * Given a Coordinate, return its geographical position.\n * @param coord - mercator coordivates\n * @returns lng and lat\n */\n coordinateLocation(coord: MercatorCoordinate): LngLat {\n return coord && coord.toLngLat();\n }\n\n /**\n * Given a Point, return its mercator coordinate.\n * @param p - the point\n * @param terrain - optional terrain\n * @returns lnglat\n */\n pointCoordinate(p: Point, terrain?: Terrain): MercatorCoordinate {\n // get point-coordinate from terrain coordinates framebuffer\n if (terrain) {\n const coordinate = terrain.pointCoordinate(p);\n if (coordinate != null) {\n return coordinate;\n }\n }\n\n // calculate point-coordinate on flat earth\n const targetZ = 0;\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that\n // line with z=0\n\n const coord0 = [p.x, p.y, 0, 1] as any;\n const coord1 = [p.x, p.y, 1, 1] as any;\n\n vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);\n vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);\n\n const w0 = coord0[3];\n const w1 = coord1[3];\n const x0 = coord0[0] / w0;\n const x1 = coord1[0] / w1;\n const y0 = coord0[1] / w0;\n const y1 = coord1[1] / w1;\n const z0 = coord0[2] / w0;\n const z1 = coord1[2] / w1;\n\n const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);\n\n return new MercatorCoordinate(\n interpolates.number(x0, x1, t) / this.worldSize,\n interpolates.number(y0, y1, t) / this.worldSize);\n }\n\n /**\n * Given a coordinate, return the screen point that corresponds to it\n * @param coord - the coordinates\n * @param elevation - the elevation\n * @param pixelMatrix - the pixel matrix\n * @returns screen point\n */\n coordinatePoint(coord: MercatorCoordinate, elevation: number = 0, pixelMatrix = this.pixelMatrix): Point {\n const p = [coord.x * this.worldSize, coord.y * this.worldSize, elevation, 1] as any;\n vec4.transformMat4(p, p, pixelMatrix);\n return new Point(p[0] / p[3], p[1] / p[3]);\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds.\n */\n getBounds(): LngLatBounds {\n const top = Math.max(0, this.height / 2 - this.getHorizon());\n return new LngLatBounds()\n .extend(this.pointLocation(new Point(0, top)))\n .extend(this.pointLocation(new Point(this.width, top)))\n .extend(this.pointLocation(new Point(this.width, this.height)))\n .extend(this.pointLocation(new Point(0, this.height)));\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns max bounds\n */\n getMaxBounds(): LngLatBounds | null {\n if (!this.latRange || this.latRange.length !== 2 ||\n !this.lngRange || this.lngRange.length !== 2) return null;\n\n return new LngLatBounds([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]);\n }\n\n /**\n * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),\n * multiplied by a static factor to simulate the earth-radius.\n * The calculated value is the horizontal line from the camera-height to sea-level.\n * @returns Horizon above center in pixels.\n */\n getHorizon(): number {\n return Math.tan(Math.PI / 2 - this._pitch) * this.cameraToCenterDistance * 0.85;\n }\n\n /**\n * Sets or clears the map's geographical constraints.\n * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map.\n */\n setMaxBounds(bounds?: LngLatBounds | null) {\n if (bounds) {\n this.lngRange = [bounds.getWest(), bounds.getEast()];\n this.latRange = [bounds.getSouth(), bounds.getNorth()];\n this._constrain();\n } else {\n this.lngRange = null;\n this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];\n }\n }\n\n /**\n * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map.\n * @param unwrappedTileID - the tile ID\n */\n calculatePosMatrix(unwrappedTileID: UnwrappedTileID, aligned: boolean = false): mat4 {\n const posMatrixKey = unwrappedTileID.key;\n const cache = aligned ? this._alignedPosMatrixCache : this._posMatrixCache;\n if (cache[posMatrixKey]) {\n return cache[posMatrixKey];\n }\n\n const canonical = unwrappedTileID.canonical;\n const scale = this.worldSize / this.zoomScale(canonical.z);\n const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;\n\n const posMatrix = mat4.identity(new Float64Array(16) as any);\n mat4.translate(posMatrix, posMatrix, [unwrappedX * scale, canonical.y * scale, 0]);\n mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);\n mat4.multiply(posMatrix, aligned ? this.alignedProjMatrix : this.projMatrix, posMatrix);\n\n cache[posMatrixKey] = new Float32Array(posMatrix);\n return cache[posMatrixKey];\n }\n\n customLayerMatrix(): mat4 {\n return this.mercatorMatrix.slice() as any;\n }\n\n _constrain() {\n if (!this.center || !this.width || !this.height || this._constraining) return;\n\n this._constraining = true;\n\n let minY = -90;\n let maxY = 90;\n let minX = -180;\n let maxX = 180;\n let sy, sx, x2, y2;\n const size = this.size,\n unmodified = this._unmodified;\n\n if (this.latRange) {\n const latRange = this.latRange;\n minY = mercatorYfromLat(latRange[1]) * this.worldSize;\n maxY = mercatorYfromLat(latRange[0]) * this.worldSize;\n sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;\n }\n\n if (this.lngRange) {\n const lngRange = this.lngRange;\n\n minX = wrap(\n mercatorXfromLng(lngRange[0]) * this.worldSize,\n 0,\n this.worldSize\n );\n maxX = wrap(\n mercatorXfromLng(lngRange[1]) * this.worldSize,\n 0,\n this.worldSize\n );\n\n if (maxX < minX) maxX += this.worldSize;\n\n sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;\n }\n\n const point = this.point;\n\n // how much the map should scale to fit the screen into given latitude/longitude ranges\n const s = Math.max(sx || 0, sy || 0);\n\n if (s) {\n this.center = this.unproject(new Point(\n sx ? (maxX + minX) / 2 : point.x,\n sy ? (maxY + minY) / 2 : point.y));\n this.zoom += this.scaleZoom(s);\n this._unmodified = unmodified;\n this._constraining = false;\n return;\n }\n\n if (this.latRange) {\n const y = point.y,\n h2 = size.y / 2;\n\n if (y - h2 < minY) y2 = minY + h2;\n if (y + h2 > maxY) y2 = maxY - h2;\n }\n\n if (this.lngRange) {\n const centerX = (minX + maxX) / 2;\n const x = wrap(point.x, centerX - this.worldSize / 2, centerX + this.worldSize / 2);\n const w2 = size.x / 2;\n\n if (x - w2 < minX) x2 = minX + w2;\n if (x + w2 > maxX) x2 = maxX - w2;\n }\n\n // pan the map if the screen goes off the range\n if (x2 !== undefined || y2 !== undefined) {\n this.center = this.unproject(new Point(\n x2 !== undefined ? x2 : point.x,\n y2 !== undefined ? y2 : point.y)).wrap();\n }\n\n this._unmodified = unmodified;\n this._constraining = false;\n }\n\n _calcMatrices() {\n if (!this.height) return;\n\n const halfFov = this._fov / 2;\n const offset = this.centerOffset;\n const x = this.point.x, y = this.point.y;\n this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;\n this._pixelPerMeter = mercatorZfromAltitude(1, this.center.lat) * this.worldSize;\n\n let m = mat4.identity(new Float64Array(16) as any);\n mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);\n mat4.translate(m, m, [1, -1, 0]);\n this.labelPlaneMatrix = m;\n\n m = mat4.identity(new Float64Array(16) as any);\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [-1, -1, 0]);\n mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);\n this.glCoordMatrix = m;\n\n // Calculate the camera to sea-level distance in pixel in respect of terrain\n const cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch);\n // In case of negative minimum elevation (e.g. the dead see, under the sea maps) use a lower plane for calculation\n const minElevation = Math.min(this.elevation, this._minEleveationForCurrentTile);\n const cameraToLowestPointDistance = cameraToSeaLevelDistance - minElevation * this._pixelPerMeter / Math.cos(this._pitch);\n const lowestPlane = minElevation < 0 ? cameraToLowestPointDistance : cameraToSeaLevelDistance;\n\n // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the\n // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.\n // 1 Z unit is equivalent to 1 horizontal px at the center of the map\n // (the distance between[width/2, height/2] and [width/2 + 1, height/2])\n const groundAngle = Math.PI / 2 + this._pitch;\n const fovAboveCenter = this._fov * (0.5 + offset.y / this.height);\n const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));\n\n // Find the distance from the center point to the horizon\n const horizon = this.getHorizon();\n const horizonAngle = Math.atan(horizon / this.cameraToCenterDistance);\n const fovCenterToHorizon = 2 * horizonAngle * (0.5 + offset.y / (horizon * 2));\n const topHalfSurfaceDistanceHorizon = Math.sin(fovCenterToHorizon) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovCenterToHorizon, 0.01, Math.PI - 0.01));\n\n // Calculate z distance of the farthest fragment that should be rendered.\n // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n const topHalfMinDistance = Math.min(topHalfSurfaceDistance, topHalfSurfaceDistanceHorizon);\n const farZ = (Math.cos(Math.PI / 2 - this._pitch) * topHalfMinDistance + lowestPlane) * 1.01;\n\n // The larger the value of nearZ is\n // - the more depth precision is available for features (good)\n // - clipping starts appearing sooner when the camera is close to 3d features (bad)\n //\n // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues\n // when rendering it's layers using custom layers. This value was experimentally chosen and\n // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.\n const nearZ = this.height / 50;\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n m = new Float64Array(16) as any;\n mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);\n\n // Apply center of perspective offset\n m[8] = -offset.x * 2 / this.width;\n m[9] = offset.y * 2 / this.height;\n\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);\n mat4.rotateX(m, m, this._pitch);\n mat4.rotateZ(m, m, this.angle);\n mat4.translate(m, m, [-x, -y, 0]);\n\n // The mercatorMatrix can be used to transform points from mercator coordinates\n // ([0, 0] nw, [1, 1] se) to GL coordinates.\n this.mercatorMatrix = mat4.scale([] as any, m, [this.worldSize, this.worldSize, this.worldSize]);\n\n // scale vertically to meters per pixel (inverse of ground resolution):\n mat4.scale(m, m, [1, 1, this._pixelPerMeter]);\n\n // matrix for conversion from location to screen coordinates in 2D\n this.pixelMatrix = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n mat4.translate(m, m, [0, 0, -this.elevation]); // elevate camera over terrain\n this.projMatrix = m;\n this.invProjMatrix = mat4.invert([] as any, m);\n\n // matrix for conversion from location to screen coordinates in 2D\n this.pixelMatrix3D = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);\n\n // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.\n // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional\n // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension\n // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle\n // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that\n // it is always <= 0.5 pixels.\n const xShift = (this.width % 2) / 2, yShift = (this.height % 2) / 2,\n angleCos = Math.cos(this.angle), angleSin = Math.sin(this.angle),\n dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift,\n dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;\n const alignedM = new Float64Array(m) as any as mat4;\n mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);\n this.alignedProjMatrix = alignedM;\n\n // inverse matrix for conversion from screen coordinaes to location\n m = mat4.invert(new Float64Array(16) as any, this.pixelMatrix);\n if (!m) throw new Error('failed to invert matrix');\n this.pixelMatrixInverse = m;\n\n this._posMatrixCache = {};\n this._alignedPosMatrixCache = {};\n }\n\n maxPitchScaleFactor() {\n // calcMatrices hasn't run yet\n if (!this.pixelMatrixInverse) return 1;\n\n const coord = this.pointCoordinate(new Point(0, 0));\n const p = [coord.x * this.worldSize, coord.y * this.worldSize, 0, 1] as vec4;\n const topPoint = vec4.transformMat4(p, p, this.pixelMatrix);\n return topPoint[3] / this.cameraToCenterDistance;\n }\n\n /**\n * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`\n * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).\n * `cameraPoint` is the projected position of the `cameraLocation`.\n *\n * This point is useful to us because only fill-extrusions that are between `cameraPoint` and\n * the query point on the surface of the earth can extend and intersect the query.\n *\n * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because\n * the camera is right above the center of the map.\n */\n getCameraPoint() {\n const pitch = this._pitch;\n const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);\n return this.centerPoint.add(new Point(0, yOffset));\n }\n\n /**\n * When the map is pitched, some of the 3D features that intersect a query will not intersect\n * the query at the surface of the earth. Instead the feature may be closer and only intersect\n * the query because it extrudes into the air.\n * @param queryGeometry - For point queries, the line from the query point to the \"camera point\",\n * for other geometries, the envelope of the query geometry and the \"camera point\"\n * @returns a geometry that includes all of the original query as well as all possible ares of the\n * screen where the *base* of a visible extrusion could be.\n *\n */\n getCameraQueryGeometry(queryGeometry: Array): Array {\n const c = this.getCameraPoint();\n\n if (queryGeometry.length === 1) {\n return [queryGeometry[0], c];\n } else {\n let minX = c.x;\n let minY = c.y;\n let maxX = c.x;\n let maxY = c.y;\n for (const p of queryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return [\n new Point(minX, minY),\n new Point(maxX, minY),\n new Point(maxX, maxY),\n new Point(minX, maxY),\n new Point(minX, minY)\n ];\n }\n }\n}\n","import * as glMatrix from \"./common.js\";\n/**\n * 2x2 Matrix\n * @module mat2\n */\n\n/**\n * Creates a new identity mat2\n *\n * @returns {mat2} a new 2x2 matrix\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(4);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[1] = 0;\n out[2] = 0;\n }\n\n out[0] = 1;\n out[3] = 1;\n return out;\n}\n/**\n * Creates a new mat2 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat2} a matrix to clone\n * @returns {mat2} a new 2x2 matrix\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Copy the values from one mat2 to another\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n return out;\n}\n/**\n * Set a mat2 to the identity matrix\n *\n * @param {mat2} out the receiving matrix\n * @returns {mat2} out\n */\n\nexport function identity(out) {\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 1;\n return out;\n}\n/**\n * Create a new mat2 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out A new 2x2 matrix\n */\n\nexport function fromValues(m00, m01, m10, m11) {\n var out = new glMatrix.ARRAY_TYPE(4);\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n/**\n * Set the components of a mat2 to the given values\n *\n * @param {mat2} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\n * @returns {mat2} out\n */\n\nexport function set(out, m00, m01, m10, m11) {\n out[0] = m00;\n out[1] = m01;\n out[2] = m10;\n out[3] = m11;\n return out;\n}\n/**\n * Transpose the values of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function transpose(out, a) {\n // If we are transposing ourselves we can skip a few steps but have to cache\n // some values\n if (out === a) {\n var a1 = a[1];\n out[1] = a[2];\n out[2] = a1;\n } else {\n out[0] = a[0];\n out[1] = a[2];\n out[2] = a[1];\n out[3] = a[3];\n }\n\n return out;\n}\n/**\n * Inverts a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function invert(out, a) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3]; // Calculate the determinant\n\n var det = a0 * a3 - a2 * a1;\n\n if (!det) {\n return null;\n }\n\n det = 1.0 / det;\n out[0] = a3 * det;\n out[1] = -a1 * det;\n out[2] = -a2 * det;\n out[3] = a0 * det;\n return out;\n}\n/**\n * Calculates the adjugate of a mat2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the source matrix\n * @returns {mat2} out\n */\n\nexport function adjoint(out, a) {\n // Caching this value is nessecary if out == a\n var a0 = a[0];\n out[0] = a[3];\n out[1] = -a[1];\n out[2] = -a[2];\n out[3] = a0;\n return out;\n}\n/**\n * Calculates the determinant of a mat2\n *\n * @param {ReadonlyMat2} a the source matrix\n * @returns {Number} determinant of a\n */\n\nexport function determinant(a) {\n return a[0] * a[3] - a[2] * a[1];\n}\n/**\n * Multiplies two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function multiply(out, a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n out[0] = a0 * b0 + a2 * b1;\n out[1] = a1 * b0 + a3 * b1;\n out[2] = a0 * b2 + a2 * b3;\n out[3] = a1 * b2 + a3 * b3;\n return out;\n}\n/**\n * Rotates a mat2 by the given angle\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\n\nexport function rotate(out, a, rad) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = a0 * c + a2 * s;\n out[1] = a1 * c + a3 * s;\n out[2] = a0 * -s + a2 * c;\n out[3] = a1 * -s + a3 * c;\n return out;\n}\n/**\n * Scales the mat2 by the dimensions in the given vec2\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to rotate\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat2} out\n **/\n\nexport function scale(out, a, v) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var v0 = v[0],\n v1 = v[1];\n out[0] = a0 * v0;\n out[1] = a1 * v0;\n out[2] = a2 * v1;\n out[3] = a3 * v1;\n return out;\n}\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.rotate(dest, dest, rad);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat2} out\n */\n\nexport function fromRotation(out, rad) {\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n out[0] = c;\n out[1] = s;\n out[2] = -s;\n out[3] = c;\n return out;\n}\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n * mat2.identity(dest);\n * mat2.scale(dest, dest, vec);\n *\n * @param {mat2} out mat2 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat2} out\n */\n\nexport function fromScaling(out, v) {\n out[0] = v[0];\n out[1] = 0;\n out[2] = 0;\n out[3] = v[1];\n return out;\n}\n/**\n * Returns a string representation of a mat2\n *\n * @param {ReadonlyMat2} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\n\nexport function str(a) {\n return \"mat2(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n/**\n * Returns Frobenius norm of a mat2\n *\n * @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\n\nexport function frob(a) {\n return Math.hypot(a[0], a[1], a[2], a[3]);\n}\n/**\n * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix\n * @param {ReadonlyMat2} L the lower triangular matrix\n * @param {ReadonlyMat2} D the diagonal matrix\n * @param {ReadonlyMat2} U the upper triangular matrix\n * @param {ReadonlyMat2} a the input matrix to factorize\n */\n\nexport function LDU(L, D, U, a) {\n L[2] = a[2] / a[0];\n U[0] = a[0];\n U[1] = a[1];\n U[3] = a[3] - L[2] * U[1];\n return [L, D, U];\n}\n/**\n * Adds two mat2's\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n out[3] = a[3] + b[3];\n return out;\n}\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @returns {mat2} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n out[3] = a[3] - b[3];\n return out;\n}\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat2} a The first matrix.\n * @param {ReadonlyMat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat2} a The first matrix.\n * @param {ReadonlyMat2} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2],\n a3 = a[3];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat2} out the receiving matrix\n * @param {ReadonlyMat2} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat2} out\n */\n\nexport function multiplyScalar(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n out[3] = a[3] * b;\n return out;\n}\n/**\n * Adds two mat2's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat2} out the receiving vector\n * @param {ReadonlyMat2} a the first operand\n * @param {ReadonlyMat2} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat2} out\n */\n\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n out[3] = a[3] + b[3] * scale;\n return out;\n}\n/**\n * Alias for {@link mat2.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link mat2.subtract}\n * @function\n */\n\nexport var sub = subtract;","/**\n * Throttle the given function to run at most every `period` milliseconds.\n */\nexport function throttle void>(fn: T, time: number): (...args: Parameters) => ReturnType {\n let pending = false;\n let timerId: ReturnType = null;\n let lastCallContext = null;\n let lastCallArgs: Parameters;\n\n const later = () => {\n timerId = null;\n if (pending) {\n fn.apply(lastCallContext, lastCallArgs);\n timerId = setTimeout(later, time);\n pending = false;\n }\n };\n\n return (...args: Parameters) => {\n pending = true;\n lastCallContext = this;\n lastCallArgs = args;\n if (!timerId) {\n later();\n }\n return timerId;\n };\n}\n","import {throttle} from '../util/throttle';\n\nimport type {Map} from './map';\n\n/**\n * Adds the map's position to its page's location hash.\n * Passed as an option to the map object.\n *\n * @group Markers and Controls\n */\nexport class Hash {\n _map: Map;\n _hashName: string;\n\n constructor(hashName?: string | null) {\n this._hashName = hashName && encodeURIComponent(hashName);\n }\n\n /**\n * Map element to listen for coordinate changes\n *\n * @param map - The map object\n * @returns `this`\n */\n addTo(map: Map) {\n this._map = map;\n addEventListener('hashchange', this._onHashChange, false);\n this._map.on('moveend', this._updateHash);\n return this;\n }\n\n /**\n * Removes hash\n *\n * @returns `this`\n */\n remove() {\n removeEventListener('hashchange', this._onHashChange, false);\n this._map.off('moveend', this._updateHash);\n clearTimeout(this._updateHash());\n\n delete this._map;\n return this;\n }\n\n getHashString(mapFeedback?: boolean) {\n const center = this._map.getCenter(),\n zoom = Math.round(this._map.getZoom() * 100) / 100,\n // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px\n precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10),\n m = Math.pow(10, precision),\n lng = Math.round(center.lng * m) / m,\n lat = Math.round(center.lat * m) / m,\n bearing = this._map.getBearing(),\n pitch = this._map.getPitch();\n let hash = '';\n if (mapFeedback) {\n // new map feedback site has some constraints that don't allow\n // us to use the same hash format as we do for the Map hash option.\n hash += `/${lng}/${lat}/${zoom}`;\n } else {\n hash += `${zoom}/${lat}/${lng}`;\n }\n\n if (bearing || pitch) hash += (`/${Math.round(bearing * 10) / 10}`);\n if (pitch) hash += (`/${Math.round(pitch)}`);\n\n if (this._hashName) {\n const hashName = this._hashName;\n let found = false;\n const parts = window.location.hash.slice(1).split('&').map(part => {\n const key = part.split('=')[0];\n if (key === hashName) {\n found = true;\n return `${key}=${hash}`;\n }\n return part;\n }).filter(a => a);\n if (!found) {\n parts.push(`${hashName}=${hash}`);\n }\n return `#${parts.join('&')}`;\n }\n\n return `#${hash}`;\n }\n\n _getCurrentHash = () => {\n // Get the current hash from location, stripped from its number sign\n const hash = window.location.hash.replace('#', '');\n if (this._hashName) {\n // Split the parameter-styled hash into parts and find the value we need\n let keyval;\n hash.split('&').map(\n part => part.split('=')\n ).forEach(part => {\n if (part[0] === this._hashName) {\n keyval = part;\n }\n });\n return (keyval ? keyval[1] || '' : '').split('/');\n }\n return hash.split('/');\n };\n\n _onHashChange = () => {\n const loc = this._getCurrentHash();\n if (loc.length >= 3 && !loc.some(v => isNaN(v))) {\n const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this._map.getBearing();\n this._map.jumpTo({\n center: [+loc[2], +loc[1]],\n zoom: +loc[0],\n bearing,\n pitch: +(loc[4] || 0)\n });\n return true;\n }\n return false;\n };\n\n _updateHashUnthrottled = () => {\n // Replace if already present, else append the updated hash string\n const location = window.location.href.replace(/(#.+)?$/, this.getHashString());\n try {\n window.history.replaceState(window.history.state, null, location);\n } catch (SecurityError) {\n // IE11 does not allow this if the page is within an iframe created\n // with iframe.contentWindow.document.write(...).\n // https://github.com/mapbox/mapbox-gl-js/issues/7410\n }\n };\n\n /**\n * Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.\n */\n _updateHash: () => ReturnType = throttle(this._updateHashUnthrottled, 30 * 1000 / 100);\n}\n","import {browser} from '../util/browser';\nimport type {Map} from './map';\nimport {bezier, clamp, extend} from '../util/util';\nimport Point from '@mapbox/point-geometry';\nimport type {DragPanOptions} from './handler/shim/drag_pan';\n\nconst defaultInertiaOptions = {\n linearity: 0.3,\n easing: bezier(0, 0, 0.3, 1),\n};\n\nconst defaultPanInertiaOptions = extend({\n deceleration: 2500,\n maxSpeed: 1400\n}, defaultInertiaOptions);\n\nconst defaultZoomInertiaOptions = extend({\n deceleration: 20,\n maxSpeed: 1400\n}, defaultInertiaOptions);\n\nconst defaultBearingInertiaOptions = extend({\n deceleration: 1000,\n maxSpeed: 360\n}, defaultInertiaOptions);\n\nconst defaultPitchInertiaOptions = extend({\n deceleration: 1000,\n maxSpeed: 90\n}, defaultInertiaOptions);\n\nexport type InertiaOptions = {\n linearity: number;\n easing: (t: number) => number;\n deceleration: number;\n maxSpeed: number;\n};\n\nexport type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;\n\nexport class HandlerInertia {\n _map: Map;\n _inertiaBuffer: Array<{\n time: number;\n settings: any;\n }>;\n\n constructor(map: Map) {\n this._map = map;\n this.clear();\n }\n\n clear() {\n this._inertiaBuffer = [];\n }\n\n record(settings: any) {\n this._drainInertiaBuffer();\n this._inertiaBuffer.push({time: browser.now(), settings});\n }\n\n _drainInertiaBuffer() {\n const inertia = this._inertiaBuffer,\n now = browser.now(),\n cutoff = 160; //msec\n\n while (inertia.length > 0 && now - inertia[0].time > cutoff)\n inertia.shift();\n }\n\n _onMoveEnd(panInertiaOptions?: DragPanOptions | boolean) {\n this._drainInertiaBuffer();\n if (this._inertiaBuffer.length < 2) {\n return;\n }\n\n const deltas = {\n zoom: 0,\n bearing: 0,\n pitch: 0,\n pan: new Point(0, 0),\n pinchAround: undefined,\n around: undefined\n };\n\n for (const {settings} of this._inertiaBuffer) {\n deltas.zoom += settings.zoomDelta || 0;\n deltas.bearing += settings.bearingDelta || 0;\n deltas.pitch += settings.pitchDelta || 0;\n if (settings.panDelta) deltas.pan._add(settings.panDelta);\n if (settings.around) deltas.around = settings.around;\n if (settings.pinchAround) deltas.pinchAround = settings.pinchAround;\n }\n\n const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1];\n const duration = (lastEntry.time - this._inertiaBuffer[0].time);\n\n const easeOptions = {} as any;\n\n if (deltas.pan.mag()) {\n const result = calculateEasing(deltas.pan.mag(), duration, extend({}, defaultPanInertiaOptions, panInertiaOptions || {}));\n easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());\n easeOptions.center = this._map.transform.center;\n extendDuration(easeOptions, result);\n }\n\n if (deltas.zoom) {\n const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);\n easeOptions.zoom = this._map.transform.zoom + result.amount;\n extendDuration(easeOptions, result);\n }\n\n if (deltas.bearing) {\n const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);\n easeOptions.bearing = this._map.transform.bearing + clamp(result.amount, -179, 179);\n extendDuration(easeOptions, result);\n }\n\n if (deltas.pitch) {\n const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);\n easeOptions.pitch = this._map.transform.pitch + result.amount;\n extendDuration(easeOptions, result);\n }\n\n if (easeOptions.zoom || easeOptions.bearing) {\n const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;\n easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter();\n }\n\n this.clear();\n return extend(easeOptions, {\n noMoveStart: true\n });\n\n }\n}\n\n// Unfortunately zoom, bearing, etc can't have different durations and easings so\n// we need to choose one. We use the longest duration and it's corresponding easing.\nfunction extendDuration(easeOptions, result) {\n if (!easeOptions.duration || easeOptions.duration < result.duration) {\n easeOptions.duration = result.duration;\n easeOptions.easing = result.easing;\n }\n}\n\nfunction calculateEasing(amount, inertiaDuration: number, inertiaOptions) {\n const {maxSpeed, linearity, deceleration} = inertiaOptions;\n const speed = clamp(\n amount * linearity / (inertiaDuration / 1000),\n -maxSpeed,\n maxSpeed);\n const duration = Math.abs(speed) / (deceleration * linearity);\n return {\n easing: inertiaOptions.easing,\n duration: duration * 1000,\n amount: speed * (duration / 2)\n };\n}\n","import {Event} from '../util/evented';\n\nimport {DOM} from '../util/dom';\nimport Point from '@mapbox/point-geometry';\nimport {extend} from '../util/util';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\n\nimport type {Map} from './map';\nimport type {LngLat} from '../geo/lng_lat';\nimport {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * An event from the mouse relevant to a specific layer.\n *\n * @group Event Related\n */\nexport type MapLayerMouseEvent = MapMouseEvent & { features?: MapGeoJSONFeature[] };\n\n/**\n * An event from a touch device relevat to a specific layer.\n *\n * @group Event Related\n */\nexport type MapLayerTouchEvent = MapTouchEvent & { features?: MapGeoJSONFeature[] };\n\n/**\n * The source event data type\n */\nexport type MapSourceDataType = 'content' | 'metadata' | 'visibility' | 'idle';\n\n/**\n * `MapLayerEventType` - a mapping between the event name and the event.\n * **Note:** These events are compatible with the optional `layerId` parameter.\n * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the\n * event action contains a visible portion of the specified layer.\n * The following example can be used for all the events.\n *\n * @group Event Related\n * @example\n * ```ts\n * // Initialize the map\n * let map = new maplibregl.Map({ // map options });\n * // Set an event listener for a specific layer\n * map.on('the-event-name', 'poi-label', function(e) {\n * console.log('An event has occurred on a visible portion of the poi-label layer');\n * });\n * ```\n */\nexport type MapLayerEventType = {\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released contains a visible portion of the specified layer.\n *\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n click: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released twice contains a visible portion of the specified layer.\n *\n * **Note:** Under normal conditions, this event will be preceded by two `click` events.\n */\n dblclick: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed while inside a visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mousedown: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is released while inside a visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mouseup: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved while the cursor is inside a visible portion of the specified layer.\n * As you move the cursor across the layer, the event will fire every time the cursor changes position within that layer.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mousemove: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from\n * outside that layer or outside the map canvas.\n *\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n */\n mouseenter: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves\n * the map canvas.\n *\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n */\n mouseleave: MapLayerMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved inside a visible portion of the specified layer.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mouseover: MapLayerMouseEvent;\n /**\n * Fired when a point device (usually a mouse) leaves the visible portion of the specified layer.\n */\n mouseout: MapLayerMouseEvent;\n /**\n * Fired when the right button of the mouse is clicked or the context menu key is pressed within visible portion of the specified layer.\n */\n contextmenu: MapLayerMouseEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchstart: MapLayerTouchEvent;\n /**\n * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchend: MapLayerTouchEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchcancel: MapLayerTouchEvent;\n};\n\n/**\n * `MapEventType` - a mapping between the event name and the event value.\n * These events are used with the {@link Map#on} method.\n * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}.\n * The following example can be used for all the events.\n *\n * @group Event Related\n * @example\n * ```ts\n * // Initialize the map\n * let map = new maplibregl.Map({ // map options });\n * // Set an event listener\n * map.on('the-event-name', () => {\n * console.log('An event has occurred!');\n * });\n * ```\n */\nexport type MapEventType = {\n /**\n * Fired when an error occurs. This is GL JS's primary error reporting\n * mechanism. We use an event instead of `throw` to better accommodate\n * asynchronous operations. If no listeners are bound to the `error` event, the\n * error will be printed to the console.\n */\n error: ErrorEvent;\n /**\n * @event `load` Fired immediately after all necessary resources have been downloaded\n * and the first visually complete rendering of the map has occurred.\n *\n * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)\n * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)\n */\n load: MapLibreEvent;\n /**\n * Fired after the last frame rendered before the map enters an\n * \"idle\" state:\n *\n * - No camera transitions are in progress\n * - All currently requested tiles have loaded\n * - All fade/transition animations have completed\n */\n idle: MapLibreEvent;\n /**\n * Fired immediately after the map has been removed with {@link Map#remove}.\n */\n remove: MapLibreEvent;\n /**\n * Fired whenever the map is drawn to the screen, as the result of\n *\n * - a change to the map's position, zoom, pitch, or bearing\n * - a change to the map's style\n * - a change to a GeoJSON source\n * - the loading of a vector tile, GeoJSON file, glyph, or sprite\n */\n render: MapLibreEvent;\n /**\n * Fired immediately after the map has been resized.\n */\n resize: MapLibreEvent;\n /**\n * Fired when the WebGL context is lost.\n */\n webglcontextlost: MapContextEvent;\n /**\n * Fired when the WebGL context is restored.\n */\n webglcontextrestored: MapContextEvent;\n /**\n * Fired when any map data (style, source, tile, etc) begins loading or\n * changing asynchronously. All `dataloading` events are followed by a `data`,\n * `dataabort` or `error` event.\n */\n dataloading: MapDataEvent;\n /**\n * Fired when any map data loads or changes. See {@link MapDataEvent} for more information.\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n data: MapDataEvent;\n tiledataloading: MapDataEvent;\n /**\n * Fired when one of the map's sources begins loading or changing asynchronously.\n * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event.\n */\n sourcedataloading: MapSourceDataEvent;\n /**\n * Fired when the map's style begins loading or changing asynchronously.\n * All `styledataloading` events are followed by a `styledata`\n * or `error` event.\n */\n styledataloading: MapStyleDataEvent;\n /**\n * Fired when one of the map's sources loads or changes, including if a tile belonging\n * to a source loads or changes.\n */\n sourcedata: MapSourceDataEvent;\n /**\n * Fired when the map's style loads or changes.\n */\n styledata: MapStyleDataEvent;\n /**\n * Fired when an icon or pattern needed by the style is missing. The missing image can\n * be added with {@link Map#addImage} within this event listener callback to prevent the image from\n * being skipped. This event can be used to dynamically generate icons and patterns.\n * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n */\n styleimagemissing: MapStyleImageMissingEvent;\n /**\n * Fired when a request for one of the map's sources' tiles or data is aborted.\n */\n dataabort: MapDataEvent;\n /**\n * Fired when a request for one of the map's sources' data is aborted.\n */\n sourcedataabort: MapSourceDataEvent;\n /**\n * Fired when the user cancels a \"box zoom\" interaction, or when the bounding box does not meet the minimum size threshold.\n * See {@link BoxZoomHandler}.\n */\n boxzoomcancel: MapLibreZoomEvent;\n /**\n * Fired when a \"box zoom\" interaction starts. See {@link BoxZoomHandler}.\n */\n boxzoomstart: MapLibreZoomEvent;\n /**\n * Fired when a \"box zoom\" interaction ends. See {@link BoxZoomHandler}.\n */\n boxzoomend: MapLibreZoomEvent;\n /**\n * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.\n */\n touchcancel: MapTouchEvent;\n /**\n * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchmove: MapTouchEvent;\n /**\n * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchend: MapTouchEvent;\n /**\n * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n touchstart: MapTouchEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.\n *\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n click: MapMouseEvent;\n /**\n * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.\n */\n contextmenu: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession.\n *\n * **Note:** Under normal conditions, this event will be preceded by two `click` events.\n */\n dblclick: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map.\n * As you move the cursor across the map, the event will fire every time the cursor changes position within the map.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mousemove: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is released within the map.\n *\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mouseup: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is pressed within the map.\n *\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n mousedown: MapMouseEvent;\n /**\n * Fired when a point device (usually a mouse) leaves the map's canvas.\n */\n mouseout: MapMouseEvent;\n /**\n * Fired when a pointing device (usually a mouse) is moved within the map.\n * As you move the cursor across a web page containing a map,\n * the event will fire each time it enters the map or any child elements.\n *\n * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)\n * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n */\n mouseover: MapMouseEvent;\n /**\n * Fired just before the map begins a transition from one\n * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.\n *\n */\n movestart: MapLibreEvent;\n /**\n * Fired repeatedly during an animated transition from one view to\n * another, as the result of either user interaction or methods such as {@link Map#flyTo}.\n *\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n move: MapLibreEvent;\n /**\n * Fired just after the map completes a transition from one\n * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.\n *\n * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n */\n moveend: MapLibreEvent;\n /**\n * Fired just before the map begins a transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoomstart: MapLibreEvent;\n /**\n * Fired repeatedly during an animated transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoom: MapLibreEvent;\n /**\n * Fired just after the map completes a transition from one zoom level to another,\n * as the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n zoomend: MapLibreEvent;\n /**\n * Fired when a \"drag to rotate\" interaction starts. See {@link DragRotateHandler}.\n */\n rotatestart: MapLibreEvent;\n /**\n * Fired repeatedly during a \"drag to rotate\" interaction. See {@link DragRotateHandler}.\n */\n rotate: MapLibreEvent;\n /**\n * Fired when a \"drag to rotate\" interaction ends. See {@link DragRotateHandler}.\n */\n rotateend: MapLibreEvent;\n /**\n * Fired when a \"drag to pan\" interaction starts. See {@link DragPanHandler}.\n */\n dragstart: MapLibreEvent;\n /**\n * Fired repeatedly during a \"drag to pan\" interaction. See {@link DragPanHandler}.\n */\n drag: MapLibreEvent;\n /**\n * Fired when a \"drag to pan\" interaction ends. See {@link DragPanHandler}.\n * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n dragend: MapLibreEvent;\n /**\n * Fired whenever the map's pitch (tilt) begins a change as\n * the result of either user interaction or methods such as {@link Map#flyTo} .\n */\n pitchstart: MapLibreEvent;\n /**\n * Fired repeatedly during the map's pitch (tilt) animation between\n * one state and another as the result of either user interaction\n * or methods such as {@link Map#flyTo}.\n */\n pitch: MapLibreEvent;\n /**\n * Fired immediately after the map's pitch (tilt) finishes changing as\n * the result of either user interaction or methods such as {@link Map#flyTo}.\n */\n pitchend: MapLibreEvent;\n /**\n * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.\n */\n wheel: MapWheelEvent;\n /**\n * Fired when terrain is changed\n */\n terrain: MapTerrainEvent;\n};\n\n/**\n * The base event for MapLibre\n *\n * @group Event Related\n */\nexport type MapLibreEvent = {\n type: keyof MapEventType | keyof MapLayerEventType;\n target: Map;\n originalEvent: TOrig;\n}\n\n/**\n * The style data event\n *\n * @group Event Related\n */\nexport type MapStyleDataEvent = MapLibreEvent & {\n dataType: 'style';\n}\n\n/**\n * The source data event interface\n *\n * @group Event Related\n */\nexport type MapSourceDataEvent = MapLibreEvent & {\n dataType: 'source';\n /**\n * True if the event has a `dataType` of `source` and the source has no outstanding network requests.\n */\n isSourceLoaded: boolean;\n /**\n * The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`.\n */\n source: SourceSpecification;\n sourceId: string;\n sourceDataType: MapSourceDataType;\n /**\n * The tile being loaded or changed, if the event has a `dataType` of `source` and\n * the event is related to loading of a tile.\n */\n tile: any;\n}\n/**\n * `MapMouseEvent` is the event type for mouse-related map events.\n * @example\n * ```ts\n * // The `click` event is an example of a `MapMouseEvent`.\n * // Set up an event listener on the map.\n * map.on('click', function(e) {\n * // The event object (e) contains information like the\n * // coordinates of the point on the map that was clicked.\n * console.log('A click event has occurred at ' + e.lngLat);\n * });\n * ```\n */\nexport class MapMouseEvent extends Event implements MapLibreEvent {\n /**\n * The event type\n */\n type: 'mousedown' | 'mouseup' | 'click' | 'dblclick' | 'mousemove' | 'mouseover' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'contextmenu';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: MouseEvent;\n\n /**\n * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.\n */\n point: Point;\n\n /**\n * The geographic location on the map of the mouse cursor.\n */\n lngLat: LngLat;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the following default map behaviors:\n *\n * * On `mousedown` events, the behavior of {@link DragPanHandler}\n * * On `mousedown` events, the behavior of {@link DragRotateHandler}\n * * On `mousedown` events, the behavior of {@link BoxZoomHandler}\n * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}\n *\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n constructor(type: string, map: Map, originalEvent: MouseEvent, data: any = {}) {\n const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);\n const lngLat = map.unproject(point);\n super(type, extend({point, lngLat, originalEvent}, data));\n this._defaultPrevented = false;\n this.target = map;\n }\n}\n\n/**\n * `MapTouchEvent` is the event type for touch-related map events.\n *\n * @group Event Related\n */\nexport class MapTouchEvent extends Event implements MapLibreEvent {\n /**\n * The event type.\n */\n type: 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: TouchEvent;\n\n /**\n * The geographic location on the map of the center of the touch event points.\n */\n lngLat: LngLat;\n\n /**\n * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left\n * corner.\n */\n point: Point;\n\n /**\n * The array of pixel coordinates corresponding to a\n * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.\n */\n points: Array;\n\n /**\n * The geographical locations on the map corresponding to a\n * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.\n */\n lngLats: Array;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the following default map behaviors:\n *\n * * On `touchstart` events, the behavior of {@link DragPanHandler}\n * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler}\n *\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n constructor(type: string, map: Map, originalEvent: TouchEvent) {\n const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;\n const points = DOM.touchPos(map.getCanvasContainer(), touches);\n const lngLats = points.map((t) => map.unproject(t));\n const point = points.reduce((prev, curr, i, arr) => {\n return prev.add(curr.div(arr.length));\n }, new Point(0, 0));\n const lngLat = map.unproject(point);\n super(type, {points, point, lngLats, lngLat, originalEvent});\n this._defaultPrevented = false;\n }\n}\n\n/**\n * `MapWheelEvent` is the event type for the `wheel` map event.\n *\n * @group Event Related\n */\nexport class MapWheelEvent extends Event {\n /**\n * The event type.\n */\n type: 'wheel';\n\n /**\n * The `Map` object that fired the event.\n */\n target: Map;\n\n /**\n * The DOM event which caused the map event.\n */\n originalEvent: WheelEvent;\n\n /**\n * Prevents subsequent default processing of the event by the map.\n *\n * Calling this method will prevent the behavior of {@link ScrollZoomHandler}.\n */\n preventDefault() {\n this._defaultPrevented = true;\n }\n\n /**\n * `true` if `preventDefault` has been called.\n */\n get defaultPrevented(): boolean {\n return this._defaultPrevented;\n }\n\n _defaultPrevented: boolean;\n\n /** */\n constructor(type: string, map: Map, originalEvent: WheelEvent) {\n super(type, {originalEvent});\n this._defaultPrevented = false;\n }\n}\n\n/**\n * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.\n *\n * @group Event Related\n */\nexport type MapLibreZoomEvent = {\n /**\n * The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel`\n */\n type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel';\n /**\n * The `Map` instance that triggered the event\n */\n target: Map;\n /**\n * The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent`\n */\n originalEvent: MouseEvent;\n};\n\n/**\n * A `MapDataEvent` object is emitted with the `data`\n * and `dataloading` events. Possible values for\n * `dataType`s are:\n *\n * - `'source'`: The non-tile data associated with any source\n * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map\n *\n * Possible values for `sourceDataType`s are:\n *\n * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles\n * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource)\n * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible')\n * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading)\n *\n * @group Event Related\n *\n * @example\n * ```ts\n * // The sourcedata event is an example of MapDataEvent.\n * // Set up an event listener on the map.\n * map.on('sourcedata', function(e) {\n * if (e.isSourceLoaded) {\n * // Do something when the source has finished loading\n * }\n * });\n * ```\n */\nexport type MapDataEvent = {\n /**\n * The event type.\n */\n type: string;\n /**\n * The type of data that has changed. One of `'source'`, `'style'`.\n */\n dataType: string;\n /**\n * Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`.\n */\n sourceDataType: MapSourceDataType;\n};\n\n/**\n * The terrain event\n *\n * @group Event Related\n */\nexport type MapTerrainEvent = {\n type: 'terrain';\n};\n\n/**\n * An event related to the web gl context\n *\n * @group Event Related\n */\nexport type MapContextEvent = {\n type: 'webglcontextlost' | 'webglcontextrestored';\n originalEvent: WebGLContextEvent;\n};\n\n/**\n * The style image missing event\n *\n * @group Event Related\n *\n * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n */\nexport type MapStyleImageMissingEvent = MapLibreEvent & {\n type: 'styleimagemissing';\n id: string;\n}\n","import {MapMouseEvent, MapTouchEvent, MapWheelEvent} from '../events';\nimport {Handler} from '../handler_manager';\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\n\nexport class MapEventHandler implements Handler {\n\n _mousedownPos: Point;\n _clickTolerance: number;\n _map: Map;\n\n constructor(map: Map, options: {\n clickTolerance: number;\n }) {\n this._map = map;\n this._clickTolerance = options.clickTolerance;\n }\n\n reset() {\n delete this._mousedownPos;\n }\n\n wheel(e: WheelEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - ScrollZoom\n return this._firePreventable(new MapWheelEvent(e.type, this._map, e));\n }\n\n mousedown(e: MouseEvent, point: Point) {\n this._mousedownPos = point;\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - MousePan\n // - MouseRotate\n // - MousePitch\n // - DblclickHandler\n return this._firePreventable(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseup(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n click(e: MouseEvent, point: Point) {\n if (this._mousedownPos && this._mousedownPos.dist(point) >= this._clickTolerance) return;\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n dblclick(e: MouseEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - DblClickZoom\n return this._firePreventable(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseover(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n mouseout(e: MouseEvent) {\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n touchstart(e: TouchEvent) {\n // If mapEvent.preventDefault() is called by the user, prevent handlers such as:\n // - TouchPan\n // - TouchZoom\n // - TouchRotate\n // - TouchPitch\n // - TapZoom\n // - SwipeZoom\n return this._firePreventable(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchmove(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchend(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n touchcancel(e: TouchEvent) {\n this._map.fire(new MapTouchEvent(e.type, this._map, e));\n }\n\n _firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent) {\n this._map.fire(mapEvent);\n if (mapEvent.defaultPrevented) {\n // returning an object marks the handler as active and resets other handlers\n return {};\n }\n }\n\n isEnabled() {\n return true;\n }\n\n isActive() {\n return false;\n }\n enable() {}\n disable() {}\n}\n\nexport class BlockableMapEventHandler {\n _map: Map;\n _delayContextMenu: boolean;\n _ignoreContextMenu: boolean;\n _contextMenuEvent: MouseEvent;\n\n constructor(map: Map) {\n this._map = map;\n }\n\n reset() {\n this._delayContextMenu = false;\n this._ignoreContextMenu = true;\n delete this._contextMenuEvent;\n }\n\n mousemove(e: MouseEvent) {\n // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n mousedown() {\n this._delayContextMenu = true;\n this._ignoreContextMenu = false;\n }\n\n mouseup() {\n this._delayContextMenu = false;\n if (this._contextMenuEvent) {\n this._map.fire(new MapMouseEvent('contextmenu', this._map, this._contextMenuEvent));\n delete this._contextMenuEvent;\n }\n }\n contextmenu(e: MouseEvent) {\n if (this._delayContextMenu) {\n // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake\n this._contextMenuEvent = e;\n } else if (!this._ignoreContextMenu) {\n // Windows: contextmenu fired on mouseup, so fire event now\n this._map.fire(new MapMouseEvent(e.type, this._map, e));\n }\n\n // prevent browser context menu when necessary\n if (this._map.listens('contextmenu')) {\n e.preventDefault();\n }\n }\n\n isEnabled() {\n return true;\n }\n\n isActive() {\n return false;\n }\n enable() {}\n disable() {}\n}\n","import type {Map} from '../map';\nimport type {PointLike} from '../camera';\nimport type {Transform} from '../../geo/transform';\nimport Point from '@mapbox/point-geometry';\nimport {LngLat} from '../../geo/lng_lat';\n\n/**\n * @internal\n * Shared utilities for the Handler classes to access the correct camera state.\n * If Camera.transformCameraUpdate is specified, the \"desired state\" of camera may differ from the state used for rendering.\n * The handlers need the \"desired state\" to track accumulated changes.\n */\nexport class TransformProvider {\n _map: Map;\n\n constructor(map: Map) {\n this._map = map;\n }\n\n get transform(): Transform {\n return this._map._requestedCameraState || this._map.transform;\n }\n\n get center() {\n return {lng: this.transform.center.lng, lat: this.transform.center.lat};\n }\n\n get zoom() {\n return this.transform.zoom;\n }\n\n get pitch() {\n return this.transform.pitch;\n }\n\n get bearing() {\n return this.transform.bearing;\n }\n\n unproject(point: PointLike): LngLat {\n return this.transform.pointLocation(Point.convert(point), this._map.terrain);\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport {Event} from '../../util/evented';\nimport {TransformProvider} from './transform-provider';\n\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\nimport {Handler} from '../handler_manager';\n\n/**\n * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.\n * The bounding box is defined by clicking and holding `shift` while dragging the cursor.\n *\n * @group Handlers\n */\nexport class BoxZoomHandler implements Handler {\n _map: Map;\n _tr: TransformProvider;\n _el: HTMLElement;\n _container: HTMLElement;\n _enabled: boolean;\n _active: boolean;\n _startPos: Point;\n _lastPos: Point;\n _box: HTMLElement;\n _clickTolerance: number;\n\n /** @internal */\n constructor(map: Map, options: {\n clickTolerance: number;\n }) {\n this._map = map;\n this._tr = new TransformProvider(map);\n this._el = map.getCanvasContainer();\n this._container = map.getContainer();\n this._clickTolerance = options.clickTolerance || 1;\n }\n\n /**\n * Returns a Boolean indicating whether the \"box zoom\" interaction is enabled.\n *\n * @returns `true` if the \"box zoom\" interaction is enabled.\n */\n isEnabled() {\n return !!this._enabled;\n }\n\n /**\n * Returns a Boolean indicating whether the \"box zoom\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"box zoom\" interaction is active.\n */\n isActive() {\n return !!this._active;\n }\n\n /**\n * Enables the \"box zoom\" interaction.\n *\n * @example\n * ```ts\n * map.boxZoom.enable();\n * ```\n */\n enable() {\n if (this.isEnabled()) return;\n this._enabled = true;\n }\n\n /**\n * Disables the \"box zoom\" interaction.\n *\n * @example\n * ```ts\n * map.boxZoom.disable();\n * ```\n */\n disable() {\n if (!this.isEnabled()) return;\n this._enabled = false;\n }\n\n mousedown(e: MouseEvent, point: Point) {\n if (!this.isEnabled()) return;\n if (!(e.shiftKey && e.button === 0)) return;\n\n DOM.disableDrag();\n this._startPos = this._lastPos = point;\n this._active = true;\n }\n\n mousemoveWindow(e: MouseEvent, point: Point) {\n if (!this._active) return;\n\n const pos = point;\n\n if (this._lastPos.equals(pos) || (!this._box && pos.dist(this._startPos) < this._clickTolerance)) {\n return;\n }\n\n const p0 = this._startPos;\n this._lastPos = pos;\n\n if (!this._box) {\n this._box = DOM.create('div', 'maplibregl-boxzoom', this._container);\n this._container.classList.add('maplibregl-crosshair');\n this._fireEvent('boxzoomstart', e);\n }\n\n const minX = Math.min(p0.x, pos.x),\n maxX = Math.max(p0.x, pos.x),\n minY = Math.min(p0.y, pos.y),\n maxY = Math.max(p0.y, pos.y);\n\n DOM.setTransform(this._box, `translate(${minX}px,${minY}px)`);\n\n this._box.style.width = `${maxX - minX}px`;\n this._box.style.height = `${maxY - minY}px`;\n }\n\n mouseupWindow(e: MouseEvent, point: Point) {\n if (!this._active) return;\n\n if (e.button !== 0) return;\n\n const p0 = this._startPos,\n p1 = point;\n\n this.reset();\n\n DOM.suppressClick();\n\n if (p0.x === p1.x && p0.y === p1.y) {\n this._fireEvent('boxzoomcancel', e);\n } else {\n this._map.fire(new Event('boxzoomend', {originalEvent: e}));\n return {\n cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this._tr.bearing, {linear: true})\n };\n }\n }\n\n keydown(e: KeyboardEvent) {\n if (!this._active) return;\n\n if (e.keyCode === 27) {\n this.reset();\n this._fireEvent('boxzoomcancel', e);\n }\n }\n\n reset() {\n this._active = false;\n\n this._container.classList.remove('maplibregl-crosshair');\n\n if (this._box) {\n DOM.remove(this._box);\n this._box = null;\n }\n\n DOM.enableDrag();\n\n delete this._startPos;\n delete this._lastPos;\n }\n\n _fireEvent(type: string, e: any) {\n return this._map.fire(new Event(type, {originalEvent: e}));\n }\n}\n","import Point from '@mapbox/point-geometry';\n\nexport function indexTouches(touches: Array, points: Array) {\n if (touches.length !== points.length) throw new Error(`The number of touches and points are not equal - touches ${touches.length}, points ${points.length}`);\n const obj = {};\n for (let i = 0; i < touches.length; i++) {\n obj[touches[i].identifier] = points[i];\n }\n return obj;\n}\n","import Point from '@mapbox/point-geometry';\nimport {indexTouches} from './handler_util';\n\nfunction getCentroid(points: Array) {\n const sum = new Point(0, 0);\n for (const point of points) {\n sum._add(point);\n }\n return sum.div(points.length);\n}\n\nexport const MAX_TAP_INTERVAL = 500;\nconst MAX_TOUCH_TIME = 500;\nexport const MAX_DIST = 30;\n\nexport class SingleTapRecognizer {\n\n numTouches: number;\n centroid: Point;\n startTime: number;\n aborted: boolean;\n touches: {\n [k in number | string]: Point;\n };\n\n constructor(options: {\n numTouches: number;\n }) {\n this.reset();\n this.numTouches = options.numTouches;\n }\n\n reset() {\n delete this.centroid;\n delete this.startTime;\n delete this.touches;\n this.aborted = false;\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n\n if (this.centroid || mapTouches.length > this.numTouches) {\n this.aborted = true;\n }\n if (this.aborted) {\n return;\n }\n\n if (this.startTime === undefined) {\n this.startTime = e.timeStamp;\n }\n\n if (mapTouches.length === this.numTouches) {\n this.centroid = getCentroid(points);\n this.touches = indexTouches(mapTouches, points);\n }\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this.aborted || !this.centroid) return;\n\n const newTouches = indexTouches(mapTouches, points);\n for (const id in this.touches) {\n const prevPos = this.touches[id];\n const pos = newTouches[id];\n if (!pos || pos.dist(prevPos) > MAX_DIST) {\n this.aborted = true;\n }\n }\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {\n this.aborted = true;\n }\n\n if (mapTouches.length === 0) {\n const centroid = !this.aborted && this.centroid;\n this.reset();\n if (centroid) return centroid;\n }\n }\n\n}\n\nexport class TapRecognizer {\n\n singleTap: SingleTapRecognizer;\n numTaps: number;\n lastTime: number;\n lastTap: Point;\n count: number;\n\n constructor(options: {\n numTaps: number;\n numTouches: number;\n }) {\n this.singleTap = new SingleTapRecognizer(options);\n this.numTaps = options.numTaps;\n this.reset();\n }\n\n reset() {\n this.lastTime = Infinity;\n delete this.lastTap;\n this.count = 0;\n this.singleTap.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n this.singleTap.touchstart(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n this.singleTap.touchmove(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n const tap = this.singleTap.touchend(e, points, mapTouches);\n if (tap) {\n const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;\n const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;\n\n if (!soonEnough || !closeEnough) {\n this.reset();\n }\n\n this.count++;\n this.lastTime = e.timeStamp;\n this.lastTap = tap;\n\n if (this.count === this.numTaps) {\n this.reset();\n return tap;\n }\n }\n }\n}\n","import {TapRecognizer} from './tap_recognizer';\nimport type Point from '@mapbox/point-geometry';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\nimport {Handler} from '../handler_manager';\n\nexport class TapZoomHandler implements Handler {\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n _zoomIn: TapRecognizer;\n _zoomOut: TapRecognizer;\n\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n this._zoomIn = new TapRecognizer({\n numTouches: 1,\n numTaps: 2\n });\n\n this._zoomOut = new TapRecognizer({\n numTouches: 2,\n numTaps: 1\n });\n\n this.reset();\n }\n\n reset() {\n this._active = false;\n this._zoomIn.reset();\n this._zoomOut.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n this._zoomIn.touchstart(e, points, mapTouches);\n this._zoomOut.touchstart(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n this._zoomIn.touchmove(e, points, mapTouches);\n this._zoomOut.touchmove(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches);\n const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches);\n const tr = this._tr;\n\n if (zoomInPoint) {\n this._active = true;\n e.preventDefault();\n setTimeout(() => this.reset(), 0);\n return {\n cameraAnimation: (map: Map) => map.easeTo({\n duration: 300,\n zoom: tr.zoom + 1,\n around: tr.unproject(zoomInPoint)\n }, {originalEvent: e})\n };\n } else if (zoomOutPoint) {\n this._active = true;\n e.preventDefault();\n setTimeout(() => this.reset(), 0);\n return {\n cameraAnimation: (map: Map) => map.easeTo({\n duration: 300,\n zoom: tr.zoom - 1,\n around: tr.unproject(zoomOutPoint)\n }, {originalEvent: e})\n };\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import {DOM} from '../../util/dom';\nimport type Point from '@mapbox/point-geometry';\nimport {DragMoveStateManager} from './drag_move_state_manager';\nimport {Handler} from '../handler_manager';\n\ninterface DragMovementResult {\n bearingDelta?: number;\n pitchDelta?: number;\n around?: Point;\n panDelta?: Point;\n}\n\nexport interface DragPanResult extends DragMovementResult {\n around: Point;\n panDelta: Point;\n}\n\nexport interface DragRotateResult extends DragMovementResult {\n bearingDelta: number;\n}\n\nexport interface DragPitchResult extends DragMovementResult {\n pitchDelta: number;\n}\n\ntype DragMoveFunction = (lastPoint: Point, point: Point) => T;\n\nexport interface DragMoveHandler extends Handler {\n dragStart: (e: E, point: Point) => void;\n dragMove: (e: E, point: Point) => T | void;\n dragEnd: (e: E) => void;\n getClickTolerance: () => number;\n}\n\nexport type DragMoveHandlerOptions = {\n /**\n * If the movement is shorter than this value, consider it a click.\n */\n clickTolerance: number;\n /**\n * The move function to run on a valid movement.\n */\n move: DragMoveFunction;\n /**\n * A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details.\n */\n moveStateManager: DragMoveStateManager;\n /**\n * A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler\n * @param handler - the handler\n */\n assignEvents: (handler: DragMoveHandler) => void;\n /**\n * Should the move start on the \"start\" event, or should it start on the first valid move.\n */\n activateOnStart?: boolean;\n /**\n * If true, handler will be enabled during construction\n */\n enable?: boolean;\n}\n\n/**\n * A generic class to create handlers for drag events, from both mouse and touch events.\n */\nexport class DragHandler implements DragMoveHandler {\n // Event handlers that may be assigned by the implementations of this class\n contextmenu?: Handler['contextmenu'];\n mousedown?: Handler['mousedown'];\n mousemoveWindow?: Handler['mousemoveWindow'];\n mouseup?: Handler['mouseup'];\n touchstart?: Handler['touchstart'];\n touchmoveWindow?: Handler['touchmoveWindow'];\n touchend?: Handler['touchend'];\n\n _clickTolerance: number;\n _moveFunction: DragMoveFunction;\n _activateOnStart: boolean;\n _active: boolean;\n _enabled: boolean;\n _moved: boolean;\n _lastPoint: Point | null;\n _moveStateManager: DragMoveStateManager;\n\n constructor(options: DragMoveHandlerOptions) {\n this._enabled = !!options.enable;\n this._moveStateManager = options.moveStateManager;\n this._clickTolerance = options.clickTolerance || 1;\n this._moveFunction = options.move;\n this._activateOnStart = !!options.activateOnStart;\n\n options.assignEvents(this);\n\n this.reset();\n }\n\n reset(e?: E) {\n this._active = false;\n this._moved = false;\n delete this._lastPoint;\n this._moveStateManager.endMove(e);\n }\n\n _move(...params: Parameters>) {\n const move = this._moveFunction(...params);\n if (move.bearingDelta || move.pitchDelta || move.around || move.panDelta) {\n this._active = true;\n return move;\n }\n }\n\n dragStart(e: E, point: Point);\n dragStart(e: E, point: Point[]);\n dragStart(e: E, point: Point | Point[]) {\n if (!this.isEnabled() || this._lastPoint) return;\n\n if (!this._moveStateManager.isValidStartEvent(e)) return;\n this._moveStateManager.startMove(e);\n\n this._lastPoint = point['length'] ? point[0] : point;\n\n if (this._activateOnStart && this._lastPoint) this._active = true;\n }\n\n dragMove(e: E, point: Point);\n dragMove(e: E, point: Point[]);\n dragMove(e: E, point: Point | Point[]) {\n if (!this.isEnabled()) return;\n const lastPoint = this._lastPoint;\n if (!lastPoint) return;\n e.preventDefault();\n\n if (!this._moveStateManager.isValidMoveEvent(e)) {\n this.reset(e);\n return;\n }\n\n const movePoint = point['length'] ? point[0] : point;\n\n if (!this._moved && movePoint.dist(lastPoint) < this._clickTolerance) return;\n this._moved = true;\n this._lastPoint = movePoint;\n\n return this._move(lastPoint, movePoint);\n }\n\n dragEnd(e: E) {\n if (!this.isEnabled() || !this._lastPoint) return;\n if (!this._moveStateManager.isValidEndEvent(e)) return;\n if (this._moved) DOM.suppressClick();\n this.reset(e);\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n\n getClickTolerance() {\n return this._clickTolerance;\n }\n}\n","import {DOM} from '../../util/dom';\n\nconst LEFT_BUTTON = 0;\nconst RIGHT_BUTTON = 2;\n\n// the values for each button in MouseEvent.buttons\nconst BUTTONS_FLAGS = {\n [LEFT_BUTTON]: 1,\n [RIGHT_BUTTON]: 2\n};\n\nfunction buttonNoLongerPressed(e: MouseEvent, button: number) {\n const flag = BUTTONS_FLAGS[button];\n return e.buttons === undefined || (e.buttons & flag) !== flag;\n}\n\n/*\n * Drag events are initiated by specific interaction which needs to be tracked until it ends.\n * This requires some state management:\n * 1. registering the initiating event,\n * 2. tracking that it was not canceled / not confusing it with another event firing.\n * 3. recognizing the ending event and cleaning up any internal state\n *\n * Concretely, we implement two state managers:\n * 1. MouseMoveStateManager\n * Receives a functions that is used to recognize mouse events that should be registered as the\n * relevant drag interactions - i.e. dragging with the right mouse button, or while CTRL is pressed.\n * 2. OneFingerTouchMoveStateManager\n * Checks if a drag event is using one finger, and continuously tracking that this is the same event\n * (i.e. to make sure not additional finger has started interacting with the screen before raising\n * the first finger).\n */\nexport interface DragMoveStateManager {\n startMove: (e: E) => void;\n endMove: (e?: E) => void;\n isValidStartEvent: (e: E) => boolean;\n isValidMoveEvent: (e: E) => boolean;\n isValidEndEvent: (e?: E) => boolean;\n}\n\nexport class MouseMoveStateManager implements DragMoveStateManager {\n _eventButton: number | undefined;\n _correctEvent: (e: MouseEvent) => boolean;\n\n constructor(options: {\n checkCorrectEvent: (e: MouseEvent) => boolean;\n }) {\n this._correctEvent = options.checkCorrectEvent;\n }\n\n startMove(e: MouseEvent) {\n const eventButton = DOM.mouseButton(e);\n this._eventButton = eventButton;\n }\n\n endMove(_e?: MouseEvent) {\n delete this._eventButton;\n }\n\n isValidStartEvent(e: MouseEvent) {\n return this._correctEvent(e);\n }\n\n isValidMoveEvent(e: MouseEvent) {\n // Some browsers don't fire a `mouseup` when the mouseup occurs outside\n // the window or iframe:\n // https://github.com/mapbox/mapbox-gl-js/issues/4622\n //\n // If the button is no longer pressed during this `mousemove` it may have\n // been released outside of the window or iframe.\n return !buttonNoLongerPressed(e, this._eventButton);\n }\n\n isValidEndEvent(e: MouseEvent) {\n const eventButton = DOM.mouseButton(e);\n return eventButton === this._eventButton;\n }\n}\n\nexport class OneFingerTouchMoveStateManager implements DragMoveStateManager {\n _firstTouch: number | undefined;\n\n constructor() {\n this._firstTouch = undefined;\n }\n\n _isOneFingerTouch(e: TouchEvent) {\n return e.targetTouches.length === 1;\n }\n\n _isSameTouchEvent(e: TouchEvent) {\n return e.targetTouches[0].identifier === this._firstTouch;\n }\n\n startMove(e: TouchEvent) {\n const firstTouch = e.targetTouches[0].identifier;\n this._firstTouch = firstTouch;\n }\n\n endMove(_e?: TouchEvent) {\n delete this._firstTouch;\n }\n\n isValidStartEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e);\n }\n\n isValidMoveEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);\n }\n\n isValidEndEvent(e: TouchEvent) {\n return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);\n }\n}\n","import type Point from '@mapbox/point-geometry';\n\nimport {DOM} from '../../util/dom';\nimport {DragMoveHandler, DragPanResult, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';\nimport {MouseMoveStateManager} from './drag_move_state_manager';\n\nexport interface MousePanHandler extends DragMoveHandler {}\nexport interface MouseRotateHandler extends DragMoveHandler {}\nexport interface MousePitchHandler extends DragMoveHandler {}\n\nconst LEFT_BUTTON = 0;\nconst RIGHT_BUTTON = 2;\n\nconst assignEvents = (handler: DragHandler) => {\n handler.mousedown = handler.dragStart;\n handler.mousemoveWindow = handler.dragMove;\n handler.mouseup = handler.dragEnd;\n handler.contextmenu = function(e: MouseEvent) {\n e.preventDefault();\n };\n};\n\nexport const generateMousePanHandler = ({enable, clickTolerance,}: {\n clickTolerance: number;\n enable?: boolean;\n}): MousePanHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent) => DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey,\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({around: point, panDelta: point.sub(lastPoint)}),\n activateOnStart: true,\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateMouseRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: {\n clickTolerance: number;\n bearingDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): MouseRotateHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent): boolean =>\n (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) ||\n (DOM.mouseButton(e) === RIGHT_BUTTON),\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}),\n // prevent browser context menu when necessary; we don't allow it with rotation\n // because we can't discern rotation gesture start from contextmenu on Mac\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateMousePitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: {\n clickTolerance: number;\n pitchDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): MousePitchHandler => {\n const mouseMoveStateManager = new MouseMoveStateManager({\n checkCorrectEvent: (e: MouseEvent): boolean =>\n (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) ||\n (DOM.mouseButton(e) === RIGHT_BUTTON),\n });\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}),\n // prevent browser context menu when necessary; we don't allow it with rotation\n // because we can't discern rotation gesture start from contextmenu on Mac\n moveStateManager: mouseMoveStateManager,\n enable,\n assignEvents,\n });\n};\n","import Point from '@mapbox/point-geometry';\nimport {indexTouches} from './handler_util';\nimport type {Map} from '../map';\nimport {GestureOptions} from '../map';\nimport {Handler} from '../handler_manager';\n\nexport class TouchPanHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _touches: {\n [k in string | number]: Point;\n };\n _minTouches: number;\n _clickTolerance: number;\n _sum: Point;\n _map: Map;\n _cancelCooperativeMessage: boolean;\n\n constructor(options: {\n clickTolerance: number;\n cooperativeGestures: boolean | GestureOptions;\n }, map: Map) {\n this._minTouches = options.cooperativeGestures ? 2 : 1;\n this._clickTolerance = options.clickTolerance || 1;\n this._map = map;\n this.reset();\n }\n\n reset() {\n this._active = false;\n this._touches = {};\n this._sum = new Point(0, 0);\n\n // Put a delay on the cooperative gesture message so it's less twitchy\n setTimeout(() => {\n this._cancelCooperativeMessage = false;\n }, 200);\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n return this._calculateTransform(e, points, mapTouches);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this._map._cooperativeGestures) {\n if (this._minTouches === 2 && mapTouches.length < 2 && !this._cancelCooperativeMessage) {\n // If coop gesture enabled, show panning info to user\n this._map._onCooperativeGesture(e, false, mapTouches.length);\n } else if (!this._cancelCooperativeMessage) {\n // If user is successfully navigating, we don't need this warning until the touch resets\n this._cancelCooperativeMessage = true;\n }\n }\n if (!this._active || mapTouches.length < this._minTouches) return;\n e.preventDefault();\n return this._calculateTransform(e, points, mapTouches);\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n this._calculateTransform(e, points, mapTouches);\n\n if (this._active && mapTouches.length < this._minTouches) {\n this.reset();\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n _calculateTransform(e: TouchEvent, points: Array, mapTouches: Array) {\n if (mapTouches.length > 0) this._active = true;\n\n const touches = indexTouches(mapTouches, points);\n\n const touchPointSum = new Point(0, 0);\n const touchDeltaSum = new Point(0, 0);\n let touchDeltaCount = 0;\n\n for (const identifier in touches) {\n const point = touches[identifier];\n const prevPoint = this._touches[identifier];\n if (prevPoint) {\n touchPointSum._add(point);\n touchDeltaSum._add(point.sub(prevPoint));\n touchDeltaCount++;\n touches[identifier] = point;\n }\n }\n\n this._touches = touches;\n\n if (touchDeltaCount < this._minTouches || !touchDeltaSum.mag()) return;\n\n const panDelta = touchDeltaSum.div(touchDeltaCount);\n this._sum._add(panDelta);\n if (this._sum.mag() < this._clickTolerance) return;\n\n const around = touchPointSum.div(touchDeltaCount);\n\n return {\n around,\n panDelta\n };\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {DOM} from '../../util/dom';\nimport type {Map} from '../map';\nimport {Handler} from '../handler_manager';\n\n/**\n * An options object sent to the enable function of some of the handlers\n */\nexport type AroundCenterOptions = {\n /**\n * If \"center\" is passed, map will zoom around the center of map\n */\n around: 'center';\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers\n *\n * @group Handlers\n */\nabstract class TwoFingersTouchHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _firstTwoTouches: [number, number];\n _vector: Point;\n _startVector: Point;\n _aroundCenter: boolean;\n\n /** @internal */\n constructor() {\n this.reset();\n }\n\n reset() {\n this._active = false;\n delete this._firstTwoTouches;\n }\n\n abstract _start(points: [Point, Point]);\n abstract _move(points: [Point, Point], pinchAround: Point, e: TouchEvent);\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n //log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);\n if (this._firstTwoTouches || mapTouches.length < 2) return;\n\n this._firstTwoTouches = [\n mapTouches[0].identifier,\n mapTouches[1].identifier\n ];\n\n // implemented by child classes\n this._start([points[0], points[1]]);\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._firstTwoTouches) return;\n\n e.preventDefault();\n\n const [idA, idB] = this._firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (!a || !b) return;\n const pinchAround = this._aroundCenter ? null : a.add(b).div(2);\n\n // implemented by child classes\n return this._move([a, b], pinchAround, e);\n\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._firstTwoTouches) return;\n\n const [idA, idB] = this._firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (a && b) return;\n\n if (this._active) DOM.suppressClick();\n\n this.reset();\n }\n\n touchcancel() {\n this.reset();\n }\n\n /**\n * Enables the \"drag to pitch\" interaction.\n *\n * @example\n * ```ts\n * map.touchPitch.enable();\n * ```\n */\n enable(options?: AroundCenterOptions | boolean | null) {\n this._enabled = true;\n this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';\n }\n\n /**\n * Disables the \"drag to pitch\" interaction.\n *\n * @example\n * ```ts\n * map.touchPitch.disable();\n * ```\n */\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pitch\" interaction is enabled.\n *\n * @returns `true` if the \"drag to pitch\" interaction is enabled.\n */\n isEnabled() {\n return this._enabled;\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pitch\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to pitch\" interaction is active.\n */\n isActive() {\n return this._active;\n }\n}\n\nfunction getTouchById(mapTouches: Array, points: Array, identifier: number) {\n for (let i = 0; i < mapTouches.length; i++) {\n if (mapTouches[i].identifier === identifier) return points[i];\n }\n}\n\n/* ZOOM */\n\nconst ZOOM_THRESHOLD = 0.1;\n\nfunction getZoomDelta(distance, lastDistance) {\n return Math.log(distance / lastDistance) / Math.LN2;\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers\n *\n * @group Handlers\n */\nexport class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {\n\n _distance: number;\n _startDistance: number;\n\n reset() {\n super.reset();\n delete this._distance;\n delete this._startDistance;\n }\n\n _start(points: [Point, Point]) {\n this._startDistance = this._distance = points[0].dist(points[1]);\n }\n\n _move(points: [Point, Point], pinchAround: Point) {\n const lastDistance = this._distance;\n this._distance = points[0].dist(points[1]);\n if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) return;\n this._active = true;\n return {\n zoomDelta: getZoomDelta(this._distance, lastDistance),\n pinchAround\n };\n }\n}\n\n/* ROTATE */\n\nconst ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle\n\nfunction getBearingDelta(a, b) {\n return a.angleWith(b) * 180 / Math.PI;\n}\n\n/**\n * The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers\n *\n * @group Handlers\n */\nexport class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {\n _minDiameter: number;\n\n reset() {\n super.reset();\n delete this._minDiameter;\n delete this._startVector;\n delete this._vector;\n }\n\n _start(points: [Point, Point]) {\n this._startVector = this._vector = points[0].sub(points[1]);\n this._minDiameter = points[0].dist(points[1]);\n }\n\n _move(points: [Point, Point], pinchAround: Point) {\n const lastVector = this._vector;\n this._vector = points[0].sub(points[1]);\n\n if (!this._active && this._isBelowThreshold(this._vector)) return;\n this._active = true;\n\n return {\n bearingDelta: getBearingDelta(this._vector, lastVector),\n pinchAround\n };\n }\n\n _isBelowThreshold(vector: Point) {\n /*\n * The threshold before a rotation actually happens is configured in\n * pixels along the circumference of the circle formed by the two fingers.\n * This makes the threshold in degrees larger when the fingers are close\n * together and smaller when the fingers are far apart.\n *\n * Use the smallest diameter from the whole gesture to reduce sensitivity\n * when pinching in and out.\n */\n\n this._minDiameter = Math.min(this._minDiameter, vector.mag());\n const circumference = Math.PI * this._minDiameter;\n const threshold = ROTATION_THRESHOLD / circumference * 360;\n\n const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector);\n return Math.abs(bearingDeltaSinceStart) < threshold;\n }\n}\n\n/* PITCH */\n\nfunction isVertical(vector) {\n return Math.abs(vector.y) > Math.abs(vector.x);\n}\n\nconst ALLOWED_SINGLE_TOUCH_TIME = 100;\n\n/**\n * The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.\n *\n * @group Handlers\n */\nexport class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {\n\n _valid: boolean | void;\n _firstMove: number;\n _lastPoints: [Point, Point];\n _map: Map;\n _currentTouchCount: number;\n\n constructor(map: Map) {\n super();\n this._map = map;\n }\n\n reset() {\n super.reset();\n this._valid = undefined;\n delete this._firstMove;\n delete this._lastPoints;\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n super.touchstart(e, points, mapTouches);\n this._currentTouchCount = mapTouches.length;\n }\n\n _start(points: [Point, Point]) {\n this._lastPoints = points;\n if (isVertical(points[0].sub(points[1]))) {\n // fingers are more horizontal than vertical\n this._valid = false;\n\n }\n }\n\n _move(points: [Point, Point], center: Point, e: TouchEvent) {\n // If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register\n if (this._map._cooperativeGestures && this._currentTouchCount < 3) {\n return;\n }\n\n const vectorA = points[0].sub(this._lastPoints[0]);\n const vectorB = points[1].sub(this._lastPoints[1]);\n\n this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);\n if (!this._valid) return;\n\n this._lastPoints = points;\n this._active = true;\n const yDeltaAverage = (vectorA.y + vectorB.y) / 2;\n const degreesPerPixelMoved = -0.5;\n return {\n pitchDelta: yDeltaAverage * degreesPerPixelMoved\n };\n }\n\n gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number) {\n if (this._valid !== undefined) return this._valid;\n\n const threshold = 2;\n const movedA = vectorA.mag() >= threshold;\n const movedB = vectorB.mag() >= threshold;\n\n // neither finger has moved a meaningful amount, wait\n if (!movedA && !movedB) return;\n\n // One finger has moved and the other has not.\n // If enough time has passed, decide it is not a pitch.\n if (!movedA || !movedB) {\n if (this._firstMove === undefined) {\n this._firstMove = timeStamp;\n }\n\n if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) {\n // still waiting for a movement from the second finger\n return undefined;\n } else {\n return false;\n }\n }\n\n const isSameDirection = vectorA.y > 0 === vectorB.y > 0;\n return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;\n }\n}\n","import {Handler} from '../handler_manager';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\n\nconst defaultOptions = {\n panStep: 100,\n bearingStep: 15,\n pitchStep: 10\n};\n\n/**\n * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using\n * the following keyboard shortcuts:\n *\n * - `=` / `+`: Increase the zoom level by 1.\n * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.\n * - `-`: Decrease the zoom level by 1.\n * - `Shift--`: Decrease the zoom level by 2.\n * - Arrow keys: Pan by 100 pixels.\n * - `Shift+⇢`: Increase the rotation by 15 degrees.\n * - `Shift+⇠`: Decrease the rotation by 15 degrees.\n * - `Shift+⇡`: Increase the pitch by 10 degrees.\n * - `Shift+⇣`: Decrease the pitch by 10 degrees.\n *\n * @group Handlers\n */\nexport class KeyboardHandler implements Handler {\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n _panStep: number;\n _bearingStep: number;\n _pitchStep: number;\n _rotationDisabled: boolean;\n\n /** @internal */\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n const stepOptions = defaultOptions;\n this._panStep = stepOptions.panStep;\n this._bearingStep = stepOptions.bearingStep;\n this._pitchStep = stepOptions.pitchStep;\n this._rotationDisabled = false;\n }\n\n reset() {\n this._active = false;\n }\n\n keydown(e: KeyboardEvent) {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n\n let zoomDir = 0;\n let bearingDir = 0;\n let pitchDir = 0;\n let xDir = 0;\n let yDir = 0;\n\n switch (e.keyCode) {\n case 61:\n case 107:\n case 171:\n case 187:\n zoomDir = 1;\n break;\n\n case 189:\n case 109:\n case 173:\n zoomDir = -1;\n break;\n\n case 37:\n if (e.shiftKey) {\n bearingDir = -1;\n } else {\n e.preventDefault();\n xDir = -1;\n }\n break;\n\n case 39:\n if (e.shiftKey) {\n bearingDir = 1;\n } else {\n e.preventDefault();\n xDir = 1;\n }\n break;\n\n case 38:\n if (e.shiftKey) {\n pitchDir = 1;\n } else {\n e.preventDefault();\n yDir = -1;\n }\n break;\n\n case 40:\n if (e.shiftKey) {\n pitchDir = -1;\n } else {\n e.preventDefault();\n yDir = 1;\n }\n break;\n\n default:\n return;\n }\n\n if (this._rotationDisabled) {\n bearingDir = 0;\n pitchDir = 0;\n }\n\n return {\n cameraAnimation: (map: Map) => {\n const tr = this._tr;\n map.easeTo({\n duration: 300,\n easeId: 'keyboardHandler',\n easing: easeOut,\n\n zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom,\n bearing: tr.bearing + bearingDir * this._bearingStep,\n pitch: tr.pitch + pitchDir * this._pitchStep,\n offset: [-xDir * this._panStep, -yDir * this._panStep],\n center: tr.center\n }, {originalEvent: e});\n }\n };\n }\n\n /**\n * Enables the \"keyboard rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.enable();\n * ```\n */\n enable() {\n this._enabled = true;\n }\n\n /**\n * Disables the \"keyboard rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.disable();\n * ```\n */\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n /**\n * Returns a Boolean indicating whether the \"keyboard rotate and zoom\"\n * interaction is enabled.\n *\n * @returns `true` if the \"keyboard rotate and zoom\"\n * interaction is enabled.\n */\n isEnabled() {\n return this._enabled;\n }\n\n /**\n * Returns true if the handler is enabled and has detected the start of a\n * zoom/rotate gesture.\n *\n * @returns `true` if the handler is enabled and has detected the\n * start of a zoom/rotate gesture.\n */\n isActive() {\n return this._active;\n }\n\n /**\n * Disables the \"keyboard pan/rotate\" interaction, leaving the\n * \"keyboard zoom\" interaction enabled.\n *\n * @example\n * ```ts\n * map.keyboard.disableRotation();\n * ```\n */\n disableRotation() {\n this._rotationDisabled = true;\n }\n\n /**\n * Enables the \"keyboard pan/rotate\" interaction.\n *\n * @example\n * ```ts\n * map.keyboard.enable();\n * map.keyboard.enableRotation();\n * ```\n */\n enableRotation() {\n this._rotationDisabled = false;\n }\n}\n\nfunction easeOut(t: number) {\n return t * (2 - t);\n}\n","import {DOM} from '../../util/dom';\n\nimport {defaultEasing, bezier} from '../../util/util';\nimport {browser} from '../../util/browser';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {LngLat} from '../../geo/lng_lat';\nimport {TransformProvider} from './transform-provider';\n\nimport type {Map} from '../map';\nimport type Point from '@mapbox/point-geometry';\nimport type {AroundCenterOptions} from './two_fingers_touch';\nimport {Handler} from '../handler_manager';\n\n// deltaY value for mouse scroll wheel identification\nconst wheelZoomDelta = 4.000244140625;\n\n// These magic numbers control the rate of zoom. Trackpad events fire at a greater\n// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick\nconst defaultZoomRate = 1 / 100;\nconst wheelZoomRate = 1 / 450;\n\n// upper bound on how much we scale the map in any single render frame; this\n// is used to limit zoom rate in the case of very fast scrolling\nconst maxScalePerFrame = 2;\n\n/**\n * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.\n *\n * @group Handlers\n */\nexport class ScrollZoomHandler implements Handler {\n _map: Map;\n _tr: TransformProvider;\n _el: HTMLElement;\n _enabled: boolean;\n _active: boolean;\n _zooming: boolean;\n _aroundCenter: boolean;\n _around: LngLat;\n _aroundPoint: Point;\n _type: 'wheel' | 'trackpad' | null;\n _lastValue: number;\n _timeout: ReturnType; // used for delayed-handling of a single wheel movement\n _finishTimeout: ReturnType; // used to delay final '{move,zoom}end' events\n\n _lastWheelEvent: any;\n _lastWheelEventTime: number;\n\n _startZoom: number;\n _targetZoom: number;\n _delta: number;\n _easing: ((a: number) => number);\n _prevEase: {\n start: number;\n duration: number;\n easing: (_: number) => number;\n };\n\n _frameId: boolean;\n _triggerRenderFrame: () => void;\n\n _defaultZoomRate: number;\n _wheelZoomRate: number;\n\n /** @internal */\n constructor(map: Map, triggerRenderFrame: () => void) {\n this._map = map;\n this._tr = new TransformProvider(map);\n this._el = map.getCanvasContainer();\n this._triggerRenderFrame = triggerRenderFrame;\n\n this._delta = 0;\n\n this._defaultZoomRate = defaultZoomRate;\n this._wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Set the zoom rate of a trackpad\n * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value.\n * @example\n * Speed up trackpad zoom\n * ```ts\n * map.scrollZoom.setZoomRate(1/25);\n * ```\n */\n setZoomRate(zoomRate: number) {\n this._defaultZoomRate = zoomRate;\n }\n\n /**\n * Set the zoom rate of a mouse wheel\n * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value.\n * @example\n * Slow down zoom of mouse wheel\n * ```ts\n * map.scrollZoom.setWheelZoomRate(1/600);\n * ```\n */\n setWheelZoomRate(wheelZoomRate: number) {\n this._wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Returns a Boolean indicating whether the \"scroll to zoom\" interaction is enabled.\n * @returns `true` if the \"scroll to zoom\" interaction is enabled.\n */\n isEnabled() {\n return !!this._enabled;\n }\n\n /*\n * Active state is turned on and off with every scroll wheel event and is set back to false before the map\n * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in\n * progress.\n */\n isActive() {\n return !!this._active || this._finishTimeout !== undefined;\n }\n\n isZooming() {\n return !!this._zooming;\n }\n\n /**\n * Enables the \"scroll to zoom\" interaction.\n *\n * @param options - Options object.\n * @example\n * ```ts\n * map.scrollZoom.enable();\n * map.scrollZoom.enable({ around: 'center' })\n * ```\n */\n enable(options?: AroundCenterOptions | boolean) {\n if (this.isEnabled()) return;\n this._enabled = true;\n this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';\n }\n\n /**\n * Disables the \"scroll to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.scrollZoom.disable();\n * ```\n */\n disable() {\n if (!this.isEnabled()) return;\n this._enabled = false;\n }\n\n wheel(e: WheelEvent) {\n if (!this.isEnabled()) return;\n if (this._map._cooperativeGestures) {\n if (e[this._map._metaKey]) {\n e.preventDefault();\n } else {\n return;\n }\n }\n let value = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;\n const now = browser.now(),\n timeDelta = now - (this._lastWheelEventTime || 0);\n\n this._lastWheelEventTime = now;\n\n if (value !== 0 && (value % wheelZoomDelta) === 0) {\n // This one is definitely a mouse wheel event.\n this._type = 'wheel';\n\n } else if (value !== 0 && Math.abs(value) < 4) {\n // This one is definitely a trackpad event because it is so small.\n this._type = 'trackpad';\n\n } else if (timeDelta > 400) {\n // This is likely a new scroll action.\n this._type = null;\n this._lastValue = value;\n\n // Start a timeout in case this was a singular event, and dely it by up to 40ms.\n this._timeout = setTimeout(this._onTimeout, 40, e);\n\n } else if (!this._type) {\n // This is a repeating event, but we don't know the type of event just yet.\n // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.\n this._type = (Math.abs(timeDelta * value) < 200) ? 'trackpad' : 'wheel';\n\n // Make sure our delayed event isn't fired again, because we accumulate\n // the previous event (which was less than 40ms ago) into this event.\n if (this._timeout) {\n clearTimeout(this._timeout);\n this._timeout = null;\n value += this._lastValue;\n }\n }\n\n // Slow down zoom if shift key is held for more precise zooming\n if (e.shiftKey && value) value = value / 4;\n\n // Only fire the callback if we actually know what type of scrolling device the user uses.\n if (this._type) {\n this._lastWheelEvent = e;\n this._delta -= value;\n if (!this._active) {\n this._start(e);\n }\n }\n\n e.preventDefault();\n }\n\n _onTimeout = (initialEvent: MouseEvent) => {\n this._type = 'wheel';\n this._delta -= this._lastValue;\n if (!this._active) {\n this._start(initialEvent);\n }\n };\n\n _start(e: MouseEvent) {\n if (!this._delta) return;\n\n if (this._frameId) {\n this._frameId = null;\n }\n\n this._active = true;\n if (!this.isZooming()) {\n this._zooming = true;\n }\n\n if (this._finishTimeout) {\n clearTimeout(this._finishTimeout);\n delete this._finishTimeout;\n }\n\n const pos = DOM.mousePos(this._el, e);\n const tr = this._tr;\n\n this._around = LngLat.convert(this._aroundCenter ? tr.center : tr.unproject(pos));\n this._aroundPoint = tr.transform.locationPoint(this._around);\n if (!this._frameId) {\n this._frameId = true;\n this._triggerRenderFrame();\n }\n }\n\n renderFrame() {\n if (!this._frameId) return;\n this._frameId = null;\n\n if (!this.isActive()) return;\n const tr = this._tr.transform;\n\n // if we've had scroll events since the last render frame, consume the\n // accumulated delta, and update the target zoom level accordingly\n if (this._delta !== 0) {\n // For trackpad events and single mouse wheel ticks, use the default zoom rate\n const zoomRate = (this._type === 'wheel' && Math.abs(this._delta) > wheelZoomDelta) ? this._wheelZoomRate : this._defaultZoomRate;\n // Scale by sigmoid of scroll wheel delta.\n let scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate)));\n\n if (this._delta < 0 && scale !== 0) {\n scale = 1 / scale;\n }\n\n const fromScale = typeof this._targetZoom === 'number' ? tr.zoomScale(this._targetZoom) : tr.scale;\n this._targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)));\n\n // if this is a mouse wheel, refresh the starting zoom and easing\n // function we're using to smooth out the zooming between wheel\n // events\n if (this._type === 'wheel') {\n this._startZoom = tr.zoom;\n this._easing = this._smoothOutEasing(200);\n }\n\n this._delta = 0;\n }\n\n const targetZoom = typeof this._targetZoom === 'number' ?\n this._targetZoom : tr.zoom;\n const startZoom = this._startZoom;\n const easing = this._easing;\n\n let finished = false;\n let zoom;\n if (this._type === 'wheel' && startZoom && easing) {\n\n const t = Math.min((browser.now() - this._lastWheelEventTime) / 200, 1);\n const k = easing(t);\n zoom = interpolates.number(startZoom, targetZoom, k);\n if (t < 1) {\n if (!this._frameId) {\n this._frameId = true;\n }\n } else {\n finished = true;\n }\n } else {\n zoom = targetZoom;\n finished = true;\n }\n\n this._active = true;\n\n if (finished) {\n this._active = false;\n this._finishTimeout = setTimeout(() => {\n this._zooming = false;\n this._triggerRenderFrame();\n delete this._targetZoom;\n delete this._finishTimeout;\n }, 200);\n }\n\n return {\n noInertia: true,\n needsRenderFrame: !finished,\n zoomDelta: zoom - tr.zoom,\n around: this._aroundPoint,\n originalEvent: this._lastWheelEvent\n };\n }\n\n _smoothOutEasing(duration: number) {\n let easing = defaultEasing;\n\n if (this._prevEase) {\n const currentEase = this._prevEase;\n const t = (browser.now() - currentEase.start) / currentEase.duration;\n const speed = currentEase.easing(t + 0.01) - currentEase.easing(t);\n\n // Quick hack to make new bezier that is continuous with last\n const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;\n const y = Math.sqrt(0.27 * 0.27 - x * x);\n\n easing = bezier(x, y, 0.25, 1);\n }\n\n this._prevEase = {\n start: browser.now(),\n duration,\n easing\n };\n\n return easing;\n }\n\n reset() {\n this._active = false;\n this._zooming = false;\n delete this._targetZoom;\n if (this._finishTimeout) {\n clearTimeout(this._finishTimeout);\n delete this._finishTimeout;\n }\n }\n}\n","import type {ClickZoomHandler} from '../click_zoom';\nimport type {TapZoomHandler} from './../tap_zoom';\n\n/**\n * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by\n * double clicking or double tapping.\n *\n * @group Handlers\n */\nexport class DoubleClickZoomHandler {\n\n _clickZoom: ClickZoomHandler;\n _tapZoom: TapZoomHandler;\n\n /** @internal */\n constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler) {\n this._clickZoom = clickZoom;\n this._tapZoom = TapZoom;\n }\n\n /**\n * Enables the \"double click to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.doubleClickZoom.enable();\n * ```\n */\n enable() {\n this._clickZoom.enable();\n this._tapZoom.enable();\n }\n\n /**\n * Disables the \"double click to zoom\" interaction.\n *\n * @example\n * ```ts\n * map.doubleClickZoom.disable();\n * ```\n */\n disable() {\n this._clickZoom.disable();\n this._tapZoom.disable();\n }\n\n /**\n * Returns a Boolean indicating whether the \"double click to zoom\" interaction is enabled.\n *\n * @returns `true` if the \"double click to zoom\" interaction is enabled.\n */\n isEnabled() {\n return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();\n }\n\n /**\n * Returns a Boolean indicating whether the \"double click to zoom\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"double click to zoom\" interaction is active.\n */\n isActive() {\n return this._clickZoom.isActive() || this._tapZoom.isActive();\n }\n}\n","import type Point from '@mapbox/point-geometry';\nimport type {Map} from '../map';\nimport {TransformProvider} from './transform-provider';\nimport {Handler} from '../handler_manager';\n\n/**\n * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking\n * It is used by other handlers\n */\nexport class ClickZoomHandler implements Handler {\n\n _tr: TransformProvider;\n _enabled: boolean;\n _active: boolean;\n\n /** @internal */\n constructor(map: Map) {\n this._tr = new TransformProvider(map);\n this.reset();\n }\n\n reset() {\n this._active = false;\n }\n\n dblclick(e: MouseEvent, point: Point) {\n e.preventDefault();\n return {\n cameraAnimation: (map: Map) => {\n map.easeTo({\n duration: 300,\n zoom: this._tr.zoom + (e.shiftKey ? -1 : 1),\n around: this._tr.unproject(point)\n }, {originalEvent: e});\n }\n };\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import {Handler} from '../handler_manager';\nimport {TapRecognizer, MAX_TAP_INTERVAL, MAX_DIST} from './tap_recognizer';\nimport type Point from '@mapbox/point-geometry';\n\nexport class TapDragZoomHandler implements Handler {\n\n _enabled: boolean;\n _active: boolean;\n _swipePoint: Point;\n _swipeTouch: number;\n _tapTime: number;\n _tapPoint: Point;\n _tap: TapRecognizer;\n\n constructor() {\n\n this._tap = new TapRecognizer({\n numTouches: 1,\n numTaps: 1\n });\n\n this.reset();\n }\n\n reset() {\n this._active = false;\n delete this._swipePoint;\n delete this._swipeTouch;\n delete this._tapTime;\n delete this._tapPoint;\n this._tap.reset();\n }\n\n touchstart(e: TouchEvent, points: Array, mapTouches: Array) {\n if (this._swipePoint) return;\n\n if (!this._tapTime) {\n this._tap.touchstart(e, points, mapTouches);\n } else {\n const swipePoint = points[0];\n\n const soonEnough = e.timeStamp - this._tapTime < MAX_TAP_INTERVAL;\n const closeEnough = this._tapPoint.dist(swipePoint) < MAX_DIST;\n\n if (!soonEnough || !closeEnough) {\n this.reset();\n } else if (mapTouches.length > 0) {\n this._swipePoint = swipePoint;\n this._swipeTouch = mapTouches[0].identifier;\n }\n }\n }\n\n touchmove(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._tapTime) {\n this._tap.touchmove(e, points, mapTouches);\n } else if (this._swipePoint) {\n if (mapTouches[0].identifier !== this._swipeTouch) {\n return;\n }\n\n const newSwipePoint = points[0];\n const dist = newSwipePoint.y - this._swipePoint.y;\n this._swipePoint = newSwipePoint;\n\n e.preventDefault();\n this._active = true;\n\n return {\n zoomDelta: dist / 128\n };\n }\n }\n\n touchend(e: TouchEvent, points: Array, mapTouches: Array) {\n if (!this._tapTime) {\n const point = this._tap.touchend(e, points, mapTouches);\n if (point) {\n this._tapTime = e.timeStamp;\n this._tapPoint = point;\n }\n } else if (this._swipePoint) {\n if (mapTouches.length === 0) {\n this.reset();\n }\n }\n }\n\n touchcancel() {\n this.reset();\n }\n\n enable() {\n this._enabled = true;\n }\n\n disable() {\n this._enabled = false;\n this.reset();\n }\n\n isEnabled() {\n return this._enabled;\n }\n\n isActive() {\n return this._active;\n }\n}\n","import type {MousePanHandler} from '../mouse';\nimport type {TouchPanHandler} from './../touch_pan';\n\n/**\n * A {@link DragPanHandler} options object\n */\nexport type DragPanOptions = {\n /**\n * factor used to scale the drag velocity\n * @defaultValue 0\n */\n linearity?: number;\n /**\n * easing function applled to `map.panTo` when applying the drag.\n * @param t - the easing function\n * @defaultValue bezier(0, 0, 0.3, 1)\n */\n easing?: (t: number) => number;\n /**\n * the maximum value of the drag velocity.\n * @defaultValue 1400\n */\n deceleration?: number;\n /**\n * the rate at which the speed reduces after the pan ends.\n * @defaultValue 2500\n */\n maxSpeed?: number;\n};\n\n/**\n * The `DragPanHandler` allows the user to pan the map by clicking and dragging\n * the cursor.\n *\n * @group Handlers\n */\nexport class DragPanHandler {\n\n _el: HTMLElement;\n _mousePan: MousePanHandler;\n _touchPan: TouchPanHandler;\n _inertiaOptions: DragPanOptions | boolean;\n\n /** @internal */\n constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler) {\n this._el = el;\n this._mousePan = mousePan;\n this._touchPan = touchPan;\n }\n\n /**\n * Enables the \"drag to pan\" interaction.\n *\n * @param options - Options object\n * @example\n * ```ts\n * map.dragPan.enable();\n * map.dragPan.enable({\n * linearity: 0.3,\n * easing: bezier(0, 0, 0.3, 1),\n * maxSpeed: 1400,\n * deceleration: 2500,\n * });\n * ```\n */\n enable(options?: DragPanOptions | boolean) {\n this._inertiaOptions = options || {};\n this._mousePan.enable();\n this._touchPan.enable();\n this._el.classList.add('maplibregl-touch-drag-pan');\n }\n\n /**\n * Disables the \"drag to pan\" interaction.\n *\n * @example\n * ```ts\n * map.dragPan.disable();\n * ```\n */\n disable() {\n this._mousePan.disable();\n this._touchPan.disable();\n this._el.classList.remove('maplibregl-touch-drag-pan');\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pan\" interaction is enabled.\n *\n * @returns `true` if the \"drag to pan\" interaction is enabled.\n */\n isEnabled() {\n return this._mousePan.isEnabled() && this._touchPan.isEnabled();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to pan\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to pan\" interaction is active.\n */\n isActive() {\n return this._mousePan.isActive() || this._touchPan.isActive();\n }\n}\n","import type {MousePitchHandler, MouseRotateHandler} from '../mouse';\n\nexport type DragRotateHandlerOptions = {\n /**\n * Control the map pitch in addition to the bearing\n * @defaultValue true\n */\n pitchWithRotate: boolean;\n}\n\n/**\n * The `DragRotateHandler` allows the user to rotate the map by clicking and\n * dragging the cursor while holding the right mouse button or `ctrl` key.\n *\n * @group Handlers\n */\nexport class DragRotateHandler {\n\n _mouseRotate: MouseRotateHandler;\n _mousePitch: MousePitchHandler;\n _pitchWithRotate: boolean;\n\n /** @internal */\n constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler) {\n this._pitchWithRotate = options.pitchWithRotate;\n this._mouseRotate = mouseRotate;\n this._mousePitch = mousePitch;\n }\n\n /**\n * Enables the \"drag to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.dragRotate.enable();\n * ```\n */\n enable() {\n this._mouseRotate.enable();\n if (this._pitchWithRotate) this._mousePitch.enable();\n }\n\n /**\n * Disables the \"drag to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.dragRotate.disable();\n * ```\n */\n disable() {\n this._mouseRotate.disable();\n this._mousePitch.disable();\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to rotate\" interaction is enabled.\n *\n * @returns `true` if the \"drag to rotate\" interaction is enabled.\n */\n isEnabled() {\n return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled());\n }\n\n /**\n * Returns a Boolean indicating whether the \"drag to rotate\" interaction is active, i.e. currently being used.\n *\n * @returns `true` if the \"drag to rotate\" interaction is active.\n */\n isActive() {\n return this._mouseRotate.isActive() || this._mousePitch.isActive();\n }\n}\n","import type {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, AroundCenterOptions} from '../two_fingers_touch';\nimport type {TapDragZoomHandler} from '../tap_drag_zoom';\n\n/**\n * The `TwoFingersTouchZoomRotateHandler` allows the user to zoom and rotate the map by\n * pinching on a touchscreen.\n *\n * They can zoom with one finger by double tapping and dragging. On the second tap,\n * hold the finger down and drag up or down to zoom in or out.\n *\n * @group Handlers\n */\nexport class TwoFingersTouchZoomRotateHandler {\n\n _el: HTMLElement;\n _touchZoom: TwoFingersTouchZoomHandler;\n _touchRotate: TwoFingersTouchRotateHandler;\n _tapDragZoom: TapDragZoomHandler;\n _rotationDisabled: boolean;\n _enabled: boolean;\n\n /** @internal */\n constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler) {\n this._el = el;\n this._touchZoom = touchZoom;\n this._touchRotate = touchRotate;\n this._tapDragZoom = tapDragZoom;\n this._rotationDisabled = false;\n this._enabled = true;\n }\n\n /**\n * Enables the \"pinch to rotate and zoom\" interaction.\n *\n * @param options - Options object.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.enable();\n * map.touchZoomRotate.enable({ around: 'center' });\n * ```\n */\n enable(options?: AroundCenterOptions | boolean | null) {\n this._touchZoom.enable(options);\n if (!this._rotationDisabled) this._touchRotate.enable(options);\n this._tapDragZoom.enable();\n this._el.classList.add('maplibregl-touch-zoom-rotate');\n }\n\n /**\n * Disables the \"pinch to rotate and zoom\" interaction.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.disable();\n * ```\n */\n disable() {\n this._touchZoom.disable();\n this._touchRotate.disable();\n this._tapDragZoom.disable();\n this._el.classList.remove('maplibregl-touch-zoom-rotate');\n }\n\n /**\n * Returns a Boolean indicating whether the \"pinch to rotate and zoom\" interaction is enabled.\n *\n * @returns `true` if the \"pinch to rotate and zoom\" interaction is enabled.\n */\n isEnabled() {\n return this._touchZoom.isEnabled() &&\n (this._rotationDisabled || this._touchRotate.isEnabled()) &&\n this._tapDragZoom.isEnabled();\n }\n\n /**\n * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.\n *\n * @returns `true` if the handler is active, `false` otherwise\n */\n isActive() {\n return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive();\n }\n\n /**\n * Disables the \"pinch to rotate\" interaction, leaving the \"pinch to zoom\"\n * interaction enabled.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.disableRotation();\n * ```\n */\n disableRotation() {\n this._rotationDisabled = true;\n this._touchRotate.disable();\n }\n\n /**\n * Enables the \"pinch to rotate\" interaction.\n *\n * @example\n * ```ts\n * map.touchZoomRotate.enable();\n * map.touchZoomRotate.enableRotation();\n * ```\n */\n enableRotation() {\n this._rotationDisabled = false;\n if (this._touchZoom.isEnabled()) this._touchRotate.enable();\n }\n}\n","import {Event} from '../util/evented';\nimport {DOM} from '../util/dom';\nimport {Map, CompleteMapOptions} from './map';\nimport {HandlerInertia} from './handler_inertia';\nimport {MapEventHandler, BlockableMapEventHandler} from './handler/map_event';\nimport {BoxZoomHandler} from './handler/box_zoom';\nimport {TapZoomHandler} from './handler/tap_zoom';\nimport {generateMouseRotationHandler, generateMousePitchHandler, generateMousePanHandler} from './handler/mouse';\nimport {TouchPanHandler} from './handler/touch_pan';\nimport {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';\nimport {KeyboardHandler} from './handler/keyboard';\nimport {ScrollZoomHandler} from './handler/scroll_zoom';\nimport {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';\nimport {ClickZoomHandler} from './handler/click_zoom';\nimport {TapDragZoomHandler} from './handler/tap_drag_zoom';\nimport {DragPanHandler} from './handler/shim/drag_pan';\nimport {DragRotateHandler} from './handler/shim/drag_rotate';\nimport {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';\nimport {extend} from '../util/util';\nimport {browser} from '../util/browser';\nimport Point from '@mapbox/point-geometry';\n\nexport type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;\n\nconst isMoving = p => p.zoom || p.drag || p.pitch || p.rotate;\n\nclass RenderFrameEvent extends Event {\n type: 'renderFrame';\n timeStamp: number;\n}\n\n/**\n * Handlers interpret dom events and return camera changes that should be\n * applied to the map (`HandlerResult`s). The camera changes are all deltas.\n * The handler itself should have no knowledge of the map's current state.\n * This makes it easier to merge multiple results and keeps handlers simpler.\n * For example, if there is a mousedown and mousemove, the mousePan handler\n * would return a `panDelta` on the mousemove.\n */\nexport interface Handler {\n enable(): void;\n disable(): void;\n isEnabled(): boolean;\n isActive(): boolean;\n /**\n * `reset` can be called by the manager at any time and must reset everything to it's original state\n */\n reset(): void;\n // Handlers can optionally implement these methods.\n // They are called with dom events whenever those dom evens are received.\n readonly touchstart?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchmove?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchmoveWindow?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchend?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly touchcancel?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void;\n readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void;\n readonly contextmenu?: (e: MouseEvent) => HandlerResult | void;\n readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void;\n readonly keydown?: (e: KeyboardEvent) => HandlerResult | void;\n readonly keyup?: (e: KeyboardEvent) => HandlerResult | void;\n /**\n * `renderFrame` is the only non-dom event. It is called during render\n * frames and can be used to smooth camera changes (see scroll handler).\n */\n readonly renderFrame?: () => HandlerResult | void;\n}\n\n/**\n * All handler methods that are called with events can optionally return a `HandlerResult`.\n */\nexport type HandlerResult = {\n panDelta?: Point;\n zoomDelta?: number;\n bearingDelta?: number;\n pitchDelta?: number;\n /**\n * the point to not move when changing the camera\n */\n around?: Point | null;\n /**\n * same as above, except for pinch actions, which are given higher priority\n */\n pinchAround?: Point | null;\n /**\n * A method that can fire a one-off easing by directly changing the map's camera.\n */\n cameraAnimation?: (map: Map) => any;\n /**\n * The last three properties are needed by only one handler: scrollzoom.\n * The DOM event to be used as the `originalEvent` on any camera change events.\n */\n originalEvent?: Event;\n /**\n * Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom).\n */\n needsRenderFrame?: boolean;\n /**\n * The camera changes won't get recorded for inertial zooming.\n */\n noInertia?: boolean;\n};\n\nexport type EventInProgress = {\n handlerName: string;\n originalEvent: Event;\n}\n\nexport type EventsInProgress = {\n zoom?: EventInProgress;\n pitch?: EventInProgress;\n rotate?: EventInProgress;\n drag?: EventInProgress;\n}\n\nfunction hasChange(result: HandlerResult) {\n return (result.panDelta && result.panDelta.mag()) || result.zoomDelta || result.bearingDelta || result.pitchDelta;\n}\n\nexport class HandlerManager {\n _map: Map;\n _el: HTMLElement;\n _handlers: Array<{\n handlerName: string;\n handler: Handler;\n allowed: Array;\n }>;\n _eventsInProgress: EventsInProgress;\n _frameId: number;\n _inertia: HandlerInertia;\n _bearingSnap: number;\n _handlersById: {[x: string]: Handler};\n _updatingCamera: boolean;\n _changes: Array<[HandlerResult, EventsInProgress, {[handlerName: string]: Event}]>;\n _terrainMovement: boolean;\n _zoom: {handlerName: string};\n _previousActiveHandlers: {[x: string]: Handler};\n _listeners: Array<[Window | Document | HTMLElement, string, {\n passive?: boolean;\n capture?: boolean;\n } | undefined]>;\n\n constructor(map: Map, options: CompleteMapOptions) {\n this._map = map;\n this._el = this._map.getCanvasContainer();\n this._handlers = [];\n this._handlersById = {};\n this._changes = [];\n\n this._inertia = new HandlerInertia(map);\n this._bearingSnap = options.bearingSnap;\n this._previousActiveHandlers = {};\n\n // Track whether map is currently moving, to compute start/move/end events\n this._eventsInProgress = {};\n\n this._addDefaultHandlers(options);\n\n const el = this._el;\n\n this._listeners = [\n // This needs to be `passive: true` so that a double tap fires two\n // pairs of touchstart/end events in iOS Safari 13. If this is set to\n // `passive: false` then the second pair of events is only fired if\n // preventDefault() is called on the first touchstart. Calling preventDefault()\n // undesirably prevents click events.\n [el, 'touchstart', {passive: true}],\n // This needs to be `passive: false` so that scrolls and pinches can be\n // prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12.\n [el, 'touchmove', {passive: false}],\n [el, 'touchend', undefined],\n [el, 'touchcancel', undefined],\n\n [el, 'mousedown', undefined],\n [el, 'mousemove', undefined],\n [el, 'mouseup', undefined],\n\n // Bind window-level event listeners for move and up/end events. In the absence of\n // the pointer capture API, which is not supported by all necessary platforms,\n // window-level event listeners give us the best shot at capturing events that\n // fall outside the map canvas element. Use `{capture: true}` for the move event\n // to prevent map move events from being fired during a drag.\n [document, 'mousemove', {capture: true}],\n [document, 'mouseup', undefined],\n\n [el, 'mouseover', undefined],\n [el, 'mouseout', undefined],\n [el, 'dblclick', undefined],\n [el, 'click', undefined],\n\n [el, 'keydown', {capture: false}],\n [el, 'keyup', undefined],\n\n [el, 'wheel', {passive: false}],\n [el, 'contextmenu', undefined],\n\n [window, 'blur', undefined]\n ];\n\n for (const [target, type, listenerOptions] of this._listeners) {\n DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);\n }\n }\n\n destroy() {\n for (const [target, type, listenerOptions] of this._listeners) {\n DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);\n }\n }\n\n _addDefaultHandlers(options: CompleteMapOptions) {\n const map = this._map;\n const el = map.getCanvasContainer();\n this._add('mapEvent', new MapEventHandler(map, options));\n\n const boxZoom = map.boxZoom = new BoxZoomHandler(map, options);\n this._add('boxZoom', boxZoom);\n if (options.interactive && options.boxZoom) {\n boxZoom.enable();\n }\n\n const tapZoom = new TapZoomHandler(map);\n const clickZoom = new ClickZoomHandler(map);\n map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);\n this._add('tapZoom', tapZoom);\n this._add('clickZoom', clickZoom);\n if (options.interactive && options.doubleClickZoom) {\n map.doubleClickZoom.enable();\n }\n\n const tapDragZoom = new TapDragZoomHandler();\n this._add('tapDragZoom', tapDragZoom);\n\n const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map);\n this._add('touchPitch', touchPitch);\n if (options.interactive && options.touchPitch) {\n map.touchPitch.enable(options.touchPitch);\n }\n\n const mouseRotate = generateMouseRotationHandler(options);\n const mousePitch = generateMousePitchHandler(options);\n map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);\n this._add('mouseRotate', mouseRotate, ['mousePitch']);\n this._add('mousePitch', mousePitch, ['mouseRotate']);\n if (options.interactive && options.dragRotate) {\n map.dragRotate.enable();\n }\n\n const mousePan = generateMousePanHandler(options);\n const touchPan = new TouchPanHandler(options, map);\n map.dragPan = new DragPanHandler(el, mousePan, touchPan);\n this._add('mousePan', mousePan);\n this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']);\n if (options.interactive && options.dragPan) {\n map.dragPan.enable(options.dragPan);\n }\n\n const touchRotate = new TwoFingersTouchRotateHandler();\n const touchZoom = new TwoFingersTouchZoomHandler();\n map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);\n this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);\n this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);\n if (options.interactive && options.touchZoomRotate) {\n map.touchZoomRotate.enable(options.touchZoomRotate);\n }\n\n const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame());\n this._add('scrollZoom', scrollZoom, ['mousePan']);\n if (options.interactive && options.scrollZoom) {\n map.scrollZoom.enable(options.scrollZoom);\n }\n\n const keyboard = map.keyboard = new KeyboardHandler(map);\n this._add('keyboard', keyboard);\n if (options.interactive && options.keyboard) {\n map.keyboard.enable();\n }\n\n this._add('blockableMapEvent', new BlockableMapEventHandler(map));\n }\n\n _add(handlerName: string, handler: Handler, allowed?: Array) {\n this._handlers.push({handlerName, handler, allowed});\n this._handlersById[handlerName] = handler;\n }\n\n stop(allowEndAnimation: boolean) {\n // do nothing if this method was triggered by a gesture update\n if (this._updatingCamera) return;\n\n for (const {handler} of this._handlers) {\n handler.reset();\n }\n this._inertia.clear();\n this._fireEvents({}, {}, allowEndAnimation);\n this._changes = [];\n }\n\n isActive() {\n for (const {handler} of this._handlers) {\n if (handler.isActive()) return true;\n }\n return false;\n }\n\n isZooming() {\n return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();\n }\n isRotating() {\n return !!this._eventsInProgress.rotate;\n }\n\n isMoving() {\n return Boolean(isMoving(this._eventsInProgress)) || this.isZooming();\n }\n\n _blockedByActive(activeHandlers: {[x: string]: Handler}, allowed: Array, myName: string) {\n for (const name in activeHandlers) {\n if (name === myName) continue;\n if (!allowed || allowed.indexOf(name) < 0) {\n return true;\n }\n }\n return false;\n }\n\n handleWindowEvent = (e: { type: 'mousemove' | 'mouseup' | 'touchmove'}) => {\n this.handleEvent(e, `${e.type}Window`);\n };\n\n _getMapTouches(touches: TouchList) {\n const mapTouches = [];\n for (const t of touches) {\n const target = (t.target as any as Node);\n if (this._el.contains(target)) {\n mapTouches.push(t);\n }\n }\n return mapTouches as any as TouchList;\n }\n\n handleEvent = (e: Event, eventName?: keyof Handler) => {\n\n if (e.type === 'blur') {\n this.stop(true);\n return;\n }\n\n this._updatingCamera = true;\n\n const inputEvent = e.type === 'renderFrame' ? undefined : e as InputEvent;\n\n /*\n * We don't call e.preventDefault() for any events by default.\n * Handlers are responsible for calling it where necessary.\n */\n\n const mergedHandlerResult: HandlerResult = {needsRenderFrame: false};\n const eventsInProgress: EventsInProgress = {};\n const activeHandlers = {};\n const eventTouches = (e as TouchEvent).touches;\n\n const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined;\n const points = mapTouches ? DOM.touchPos(this._el, mapTouches) : DOM.mousePos(this._el, ((e as MouseEvent)));\n\n for (const {handlerName, handler, allowed} of this._handlers) {\n if (!handler.isEnabled()) continue;\n\n let data: HandlerResult;\n if (this._blockedByActive(activeHandlers, allowed, handlerName)) {\n handler.reset();\n\n } else {\n if (handler[eventName || e.type]) {\n data = handler[eventName || e.type](e, points, mapTouches);\n this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent);\n if (data && data.needsRenderFrame) {\n this._triggerRenderFrame();\n }\n }\n }\n\n if (data || handler.isActive()) {\n activeHandlers[handlerName] = handler;\n }\n }\n\n const deactivatedHandlers: {[handlerName: string]: Event} = {};\n for (const name in this._previousActiveHandlers) {\n if (!activeHandlers[name]) {\n deactivatedHandlers[name] = inputEvent;\n }\n }\n this._previousActiveHandlers = activeHandlers;\n\n if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) {\n this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]);\n this._triggerRenderFrame();\n }\n\n if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) {\n this._map._stop(true);\n }\n\n this._updatingCamera = false;\n\n const {cameraAnimation} = mergedHandlerResult;\n if (cameraAnimation) {\n this._inertia.clear();\n this._fireEvents({}, {}, true);\n this._changes = [];\n cameraAnimation(this._map);\n }\n };\n\n mergeHandlerResult(mergedHandlerResult: HandlerResult,\n eventsInProgress: EventsInProgress,\n handlerResult: HandlerResult,\n name: string,\n e?: InputEvent) {\n if (!handlerResult) return;\n\n extend(mergedHandlerResult, handlerResult);\n\n const eventData = {handlerName: name, originalEvent: handlerResult.originalEvent || e};\n\n // track which handler changed which camera property\n if (handlerResult.zoomDelta !== undefined) {\n eventsInProgress.zoom = eventData;\n }\n if (handlerResult.panDelta !== undefined) {\n eventsInProgress.drag = eventData;\n }\n if (handlerResult.pitchDelta !== undefined) {\n eventsInProgress.pitch = eventData;\n }\n if (handlerResult.bearingDelta !== undefined) {\n eventsInProgress.rotate = eventData;\n }\n\n }\n\n _applyChanges() {\n const combined: HandlerResult = {};\n const combinedEventsInProgress: EventsInProgress = {};\n const combinedDeactivatedHandlers = {};\n\n for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) {\n\n if (change.panDelta) combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta);\n if (change.zoomDelta) combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;\n if (change.bearingDelta) combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;\n if (change.pitchDelta) combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;\n if (change.around !== undefined) combined.around = change.around;\n if (change.pinchAround !== undefined) combined.pinchAround = change.pinchAround;\n if (change.noInertia) combined.noInertia = change.noInertia;\n\n extend(combinedEventsInProgress, eventsInProgress);\n extend(combinedDeactivatedHandlers, deactivatedHandlers);\n }\n\n this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);\n this._changes = [];\n }\n\n _updateMapTransform(combinedResult: HandlerResult,\n combinedEventsInProgress: EventsInProgress,\n deactivatedHandlers: {[handlerName: string]: Event}) {\n const map = this._map;\n const tr = map._getTransformForUpdate();\n const terrain = map.terrain;\n\n if (!hasChange(combinedResult) && !(terrain && this._terrainMovement)) {\n return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);\n }\n\n let {panDelta, zoomDelta, bearingDelta, pitchDelta, around, pinchAround} = combinedResult;\n\n if (pinchAround !== undefined) {\n around = pinchAround;\n }\n\n // stop any ongoing camera animations (easeTo, flyTo)\n map._stop(true);\n\n around = around || map.transform.centerPoint;\n const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);\n if (bearingDelta) tr.bearing += bearingDelta;\n if (pitchDelta) tr.pitch += pitchDelta;\n if (zoomDelta) tr.zoom += zoomDelta;\n\n if (!terrain) {\n tr.setLocationAtPoint(loc, around);\n } else {\n // when 3d-terrain is enabled act a little different:\n // - dragging do not drag the picked point itself, instead it drags the map by pixel-delta.\n // With this approach it is no longer possible to pick a point from somewhere near\n // the horizon to the center in one move.\n // So this logic avoids the problem, that in such cases you easily loose orientation.\n if (!this._terrainMovement &&\n (combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) {\n // When starting to drag or move, flag it and register moveend to clear flagging\n this._terrainMovement = true;\n this._map._elevationFreeze = true;\n tr.setLocationAtPoint(loc, around);\n this._map.once('moveend', () => {\n this._map._elevationFreeze = false;\n this._terrainMovement = false;\n tr.recalculateZoom(map.terrain);\n });\n } else if (combinedEventsInProgress.drag && this._terrainMovement) {\n // drag map\n tr.center = tr.pointLocation(tr.centerPoint.sub(panDelta));\n } else {\n tr.setLocationAtPoint(loc, around);\n }\n }\n\n map._applyUpdatedTransform(tr);\n\n this._map._update();\n if (!combinedResult.noInertia) this._inertia.record(combinedResult);\n this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);\n\n }\n\n _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {[handlerName: string]: Event}, allowEndAnimation: boolean) {\n\n const wasMoving = isMoving(this._eventsInProgress);\n const nowMoving = isMoving(newEventsInProgress);\n\n const startEvents = {};\n\n for (const eventName in newEventsInProgress) {\n const {originalEvent} = newEventsInProgress[eventName];\n if (!this._eventsInProgress[eventName]) {\n startEvents[`${eventName}start`] = originalEvent;\n }\n this._eventsInProgress[eventName] = newEventsInProgress[eventName];\n }\n\n // fire start events only after this._eventsInProgress has been updated\n if (!wasMoving && nowMoving) {\n this._fireEvent('movestart', nowMoving.originalEvent);\n }\n\n for (const name in startEvents) {\n this._fireEvent(name, startEvents[name]);\n }\n\n if (nowMoving) {\n this._fireEvent('move', nowMoving.originalEvent);\n }\n\n for (const eventName in newEventsInProgress) {\n const {originalEvent} = newEventsInProgress[eventName];\n this._fireEvent(eventName, originalEvent);\n }\n\n const endEvents = {};\n\n let originalEndEvent;\n for (const eventName in this._eventsInProgress) {\n const {handlerName, originalEvent} = this._eventsInProgress[eventName];\n if (!this._handlersById[handlerName].isActive()) {\n delete this._eventsInProgress[eventName];\n originalEndEvent = deactivatedHandlers[handlerName] || originalEvent;\n endEvents[`${eventName}end`] = originalEndEvent;\n }\n }\n\n for (const name in endEvents) {\n this._fireEvent(name, endEvents[name]);\n }\n\n const stillMoving = isMoving(this._eventsInProgress);\n if (allowEndAnimation && (wasMoving || nowMoving) && !stillMoving) {\n this._updatingCamera = true;\n const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);\n\n const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;\n\n if (inertialEase && (inertialEase.essential || !browser.prefersReducedMotion)) {\n if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {\n inertialEase.bearing = 0;\n }\n inertialEase.freezeElevation = true;\n this._map.easeTo(inertialEase, {originalEvent: originalEndEvent});\n } else {\n this._map.fire(new Event('moveend', {originalEvent: originalEndEvent}));\n if (shouldSnapToNorth(this._map.getBearing())) {\n this._map.resetNorth();\n }\n }\n this._updatingCamera = false;\n }\n\n }\n\n _fireEvent(type: string, e?: Event) {\n this._map.fire(new Event(type, e ? {originalEvent: e} : {}));\n }\n\n _requestFrame() {\n this._map.triggerRepaint();\n return this._map._renderTaskQueue.add(timeStamp => {\n delete this._frameId;\n this.handleEvent(new RenderFrameEvent('renderFrame', {timeStamp}));\n this._applyChanges();\n });\n }\n\n _triggerRenderFrame() {\n if (this._frameId === undefined) {\n this._frameId = this._requestFrame();\n }\n }\n}\n","import {extend, warnOnce, clamp, wrap, defaultEasing, pick} from '../util/util';\nimport {interpolates} from '@maplibre/maplibre-gl-style-spec';\nimport {browser} from '../util/browser';\nimport {LngLat} from '../geo/lng_lat';\nimport {LngLatBounds} from '../geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {Event, Evented} from '../util/evented';\nimport {Terrain} from '../render/terrain';\n\nimport type {Transform} from '../geo/transform';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport type {TaskID} from '../util/task_queue';\nimport type {PaddingOptions} from '../geo/edge_insets';\nimport {MercatorCoordinate} from '../geo/mercator_coordinate';\n\n/**\n * A [Point](https://github.com/mapbox/point-geometry) or an array of two numbers representing `x` and `y` screen coordinates in pixels.\n *\n * @group Geography and Geometry\n *\n * @example\n * ```ts\n * let p1 = new Point(-77, 38); // a PointLike which is a Point\n * let p2 = [-77, 38]; // a PointLike which is an array of two numbers\n * ```\n */\nexport type PointLike = Point | [number, number];\n\n/**\n * A helper to allow require of at least one propery\n */\nexport type RequireAtLeastOne = { [K in keyof T]-?: Required> & Partial>>; }[keyof T];\n\n/**\n * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location,\n * zoom, bearing, and pitch of the camera. All properties are optional, and when a property is omitted, the current\n * camera value for that property will remain unchanged.\n *\n * @example\n * Set the map's initial perspective with CameraOptions\n * ```ts\n * let map = new maplibregl.Map({\n * container: 'map',\n * style: 'https://demotiles.maplibre.org/style.json',\n * center: [-73.5804, 45.53483],\n * pitch: 60,\n * bearing: -60,\n * zoom: 10\n * });\n * ```\n * @see [Set pitch and bearing](https://maplibre.org/maplibre-gl-js/docs/examples/set-perspective/)\n * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/)\n * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/)\n * @see [Display buildings in 3D](https://maplibre.org/maplibre-gl-js/docs/examples/3d-buildings/)\n */\nexport type CameraOptions = CenterZoomBearing & {\n /**\n * The desired pitch in degrees. The pitch is the angle towards the horizon\n * measured in degrees with a range between 0 and 60 degrees. For example, pitch: 0 provides the appearance\n * of looking straight down at the map, while pitch: 60 tilts the user's perspective towards the horizon.\n * Increasing the pitch value is often used to display 3D objects.\n */\n pitch?: number;\n /**\n * If `zoom` is specified, `around` determines the point around which the zoom is centered.\n */\n around?: LngLatLike;\n};\n\n/**\n * Holds center, zoom and bearing properties\n */\nexport type CenterZoomBearing = {\n /**\n * The desired center.\n */\n center?: LngLatLike;\n /**\n * The desired zoom level.\n */\n zoom?: number;\n /**\n * The desired bearing in degrees. The bearing is the compass direction that\n * is \"up\". For example, `bearing: 90` orients the map so that east is up.\n */\n bearing?: number;\n}\n\n/**\n * The options object related to the {@link Map#jumpTo} method\n */\nexport type JumpToOptions = CameraOptions & {\n /**\n * Dimensions in pixels applied on each side of the viewport for shifting the vanishing point.\n */\n padding?: PaddingOptions;\n}\n\n/**\n * A options object for the {@link Map#cameraForBounds} method\n */\nexport type CameraForBoundsOptions = CameraOptions & {\n /**\n * The amount of padding in pixels to add to the given bounds.\n */\n padding?: number | RequireAtLeastOne;\n /**\n * The center of the given bounds relative to the map's center, measured in pixels.\n * @defaultValue [0, 0]\n */\n offset?: PointLike;\n /**\n * The maximum zoom level to allow when the camera would transition to the specified bounds.\n */\n maxZoom?: number;\n}\n\n/**\n * The {@link Map#flyTo} options object\n */\nexport type FlyToOptions = AnimationOptions & CameraOptions & {\n /**\n * The zooming \"curve\" that will occur along the\n * flight path. A high value maximizes zooming for an exaggerated animation, while a low\n * value minimizes zooming for an effect closer to {@link Map#easeTo}. 1.42 is the average\n * value selected by participants in the user study discussed in\n * [van Wijk (2003)](https://www.win.tue.nl/~vanwijk/zoompan.pdf). A value of\n * `Math.pow(6, 0.25)` would be equivalent to the root mean squared average velocity. A\n * value of 1 would produce a circular motion.\n * @defaultValue 1.42\n */\n curve?: number;\n /**\n * The zero-based zoom level at the peak of the flight path. If\n * `options.curve` is specified, this option is ignored.\n */\n minZoom?: number;\n /**\n * The average speed of the animation defined in relation to\n * `options.curve`. A speed of 1.2 means that the map appears to move along the flight path\n * by 1.2 times `options.curve` screenfuls every second. A _screenful_ is the map's visible span.\n * It does not correspond to a fixed physical distance, but varies by zoom level.\n * @defaultValue 1.2\n */\n speed?: number;\n /**\n * The average speed of the animation measured in screenfuls\n * per second, assuming a linear timing curve. If `options.speed` is specified, this option is ignored.\n */\n screenSpeed?: number;\n /**\n * The animation's maximum duration, measured in milliseconds.\n * If duration exceeds maximum duration, it resets to 0.\n */\n maxDuration?: number;\n /**\n * The amount of padding in pixels to add to the given bounds.\n */\n padding?: number | RequireAtLeastOne;\n}\n\nexport type EaseToOptions = AnimationOptions & CameraOptions & {\n delayEndEvents?: number;\n padding?: number | RequireAtLeastOne;\n}\n\n/**\n * Options for {@link Map#fitBounds} method\n */\nexport type FitBoundsOptions = FlyToOptions & {\n /**\n * If `true`, the map transitions using {@link Map#easeTo}. If `false`, the map transitions using {@link Map#flyTo}.\n * See those functions and {@link AnimationOptions} for information about options available.\n * @defaultValue false\n */\n linear?: boolean;\n /**\n * The center of the given bounds relative to the map's center, measured in pixels.\n * @defaultValue [0, 0]\n */\n offset?: PointLike;\n /**\n * The maximum zoom level to allow when the map view transitions to the specified bounds.\n */\n maxZoom?: number;\n}\n\n/**\n * Options common to map movement methods that involve animation, such as {@link Map#panBy} and\n * {@link Map#easeTo}, controlling the duration and easing function of the animation. All properties\n * are optional.\n *\n */\nexport type AnimationOptions = {\n /**\n * The animation's duration, measured in milliseconds.\n */\n duration?: number;\n /**\n * A function taking a time in the range 0..1 and returning a number where 0 is\n * the initial state and 1 is the final state.\n */\n easing?: (_: number) => number;\n /**\n * of the target center relative to real map container center at the end of animation.\n */\n offset?: PointLike;\n /**\n * If `false`, no animation will occur.\n */\n animate?: boolean;\n /**\n * If `true`, then the animation is considered essential and will not be affected by\n * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/\\@media/prefers-reduced-motion).\n */\n essential?: boolean;\n /**\n * Default false. Needed in 3D maps to let the camera stay in a constant\n * height based on sea-level. After the animation finished the zoom-level will be recalculated in respect of\n * the distance from the camera to the center-coordinate-altitude.\n */\n freezeElevation?: boolean;\n};\n\n/**\n * A callback hook that allows manipulating the camera and being notified about camera updates before they happen\n */\nexport type CameraUpdateTransformFunction = (next: {\n center: LngLat;\n zoom: number;\n pitch: number;\n bearing: number;\n elevation: number;\n}) => {\n center?: LngLat;\n zoom?: number;\n pitch?: number;\n bearing?: number;\n elevation?: number;\n};\n\nexport abstract class Camera extends Evented {\n transform: Transform;\n terrain: Terrain;\n\n _moving: boolean;\n _zooming: boolean;\n _rotating: boolean;\n _pitching: boolean;\n _padding: boolean;\n\n _bearingSnap: number;\n _easeStart: number;\n _easeOptions: {\n duration?: number;\n easing?: (_: number) => number;\n };\n _easeId: string | void;\n\n _onEaseFrame: (_: number) => void;\n _onEaseEnd: (easeId?: string) => void;\n _easeFrameId: TaskID;\n\n /**\n * @internal\n * holds the geographical coordinate of the target\n */\n _elevationCenter: LngLat;\n /**\n * @internal\n * holds the targ altitude value, = center elevation of the target.\n * This value may changes during flight, because new terrain-tiles loads during flight.\n */\n _elevationTarget: number;\n /**\n * @internal\n * holds the start altitude value, = center elevation before animation begins\n * this value will recalculated during flight in respect of changing _elevationTarget values,\n * so the linear interpolation between start and target keeps smooth and without jumps.\n */\n _elevationStart: number;\n /**\n * @internal\n * Saves the current state of the elevation freeze - this is used during map movement to prevent \"rocky\" camera movement.\n */\n _elevationFreeze: boolean;\n /**\n * @internal\n * Used to track accumulated changes during continuous interaction\n */\n _requestedCameraState?: Transform;\n /**\n * A callback used to defer camera updates or apply arbitrary constraints.\n * If specified, this Camera instance can be used as a stateless component in React etc.\n */\n transformCameraUpdate: CameraUpdateTransformFunction | null;\n\n abstract _requestRenderFrame(a: () => void): TaskID;\n abstract _cancelRenderFrame(_: TaskID): void;\n\n constructor(transform: Transform, options: {\n bearingSnap: number;\n }) {\n super();\n this._moving = false;\n this._zooming = false;\n this.transform = transform;\n this._bearingSnap = options.bearingSnap;\n\n this.on('moveend', () => {\n delete this._requestedCameraState;\n });\n }\n\n /**\n * Returns the map's geographical centerpoint.\n *\n * @returns The map's geographical centerpoint.\n * @example\n * Return a LngLat object such as `{lng: 0, lat: 0}`\n * ```ts\n * let center = map.getCenter();\n * // access longitude and latitude values directly\n * let {lng, lat} = map.getCenter();\n * ```\n */\n getCenter(): LngLat { return new LngLat(this.transform.center.lng, this.transform.center.lat); }\n\n /**\n * Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param center - The centerpoint to set.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * map.setCenter([-74, 38]);\n * ```\n */\n setCenter(center: LngLatLike, eventData?: any) {\n return this.jumpTo({center}, eventData);\n }\n\n /**\n * Pans the map by the specified offset.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param offset - `x` and `y` coordinates by which to pan the map.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n panBy(offset: PointLike, options?: AnimationOptions, eventData?: any): this {\n offset = Point.convert(offset).mult(-1);\n return this.panTo(this.transform.center, extend({offset}, options), eventData);\n }\n\n /**\n * Pans the map to the specified location with an animated transition.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param lnglat - The location to pan the map to.\n * @param options - Options describing the destination and animation of the transition.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * map.panTo([-74, 38]);\n * // Specify that the panTo animation should last 5000 milliseconds.\n * map.panTo([-74, 38], {duration: 5000});\n * ```\n * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/)\n */\n panTo(lnglat: LngLatLike, options?: AnimationOptions, eventData?: any): this {\n return this.easeTo(extend({\n center: lnglat\n }, options), eventData);\n }\n\n /**\n * Returns the map's current zoom level.\n *\n * @returns The map's current zoom level.\n * @example\n * ```ts\n * map.getZoom();\n * ```\n */\n getZoom(): number { return this.transform.zoom; }\n\n /**\n * Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param zoom - The zoom level to set (0-20).\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom to the zoom level 5 without an animated transition\n * ```ts\n * map.setZoom(5);\n * ```\n */\n setZoom(zoom: number, eventData?: any): this {\n this.jumpTo({zoom}, eventData);\n return this;\n }\n\n /**\n * Zooms the map to the specified zoom level, with an animated transition.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param zoom - The zoom level to transition to.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // Zoom to the zoom level 5 without an animated transition\n * map.zoomTo(5);\n * // Zoom to the zoom level 8 with an animated transition\n * map.zoomTo(8, {\n * duration: 2000,\n * offset: [100, 50]\n * });\n * ```\n */\n zoomTo(zoom: number, options?: AnimationOptions | null, eventData?: any): this {\n return this.easeTo(extend({\n zoom\n }, options), eventData);\n }\n\n /**\n * Increases the map's zoom level by 1.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom the map in one level with a custom animation duration\n * ```ts\n * map.zoomIn({duration: 1000});\n * ```\n */\n zoomIn(options?: AnimationOptions, eventData?: any): this {\n this.zoomTo(this.getZoom() + 1, options, eventData);\n return this;\n }\n\n /**\n * Decreases the map's zoom level by 1.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Zoom the map out one level with a custom animation offset\n * ```ts\n * map.zoomOut({offset: [80, 60]});\n * ```\n */\n zoomOut(options?: AnimationOptions, eventData?: any): this {\n this.zoomTo(this.getZoom() - 1, options, eventData);\n return this;\n }\n\n /**\n * Returns the map's current bearing. The bearing is the compass direction that is \"up\"; for example, a bearing\n * of 90° orients the map so that east is up.\n *\n * @returns The map's current bearing.\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n getBearing(): number { return this.transform.bearing; }\n\n /**\n * Sets the map's bearing (rotation). The bearing is the compass direction that is \"up\"; for example, a bearing\n * of 90° orients the map so that east is up.\n *\n * Equivalent to `jumpTo({bearing: bearing})`.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param bearing - The desired bearing.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Rotate the map to 90 degrees\n * ```ts\n * map.setBearing(90);\n * ```\n */\n setBearing(bearing: number, eventData?: any): this {\n this.jumpTo({bearing}, eventData);\n return this;\n }\n\n /**\n * Returns the current padding applied around the map viewport.\n *\n * @returns The current padding around the map viewport.\n */\n getPadding(): PaddingOptions { return this.transform.padding; }\n\n /**\n * Sets the padding in pixels around the viewport.\n *\n * Equivalent to `jumpTo({padding: padding})`.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param padding - The desired padding.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * Sets a left padding of 300px, and a top padding of 50px\n * ```ts\n * map.setPadding({ left: 300, top: 50 });\n * ```\n */\n setPadding(padding: PaddingOptions, eventData?: any): this {\n this.jumpTo({padding}, eventData);\n return this;\n }\n\n /**\n * Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction\n * that is \"up\"; for example, a bearing of 90° orients the map so that east is up.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param bearing - The desired bearing.\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n rotateTo(bearing: number, options?: AnimationOptions, eventData?: any): this {\n return this.easeTo(extend({\n bearing\n }, options), eventData);\n }\n\n /**\n * Rotates the map so that north is up (0° bearing), with an animated transition.\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n resetNorth(options?: AnimationOptions, eventData?: any): this {\n this.rotateTo(0, extend({duration: 1000}, options), eventData);\n return this;\n }\n\n /**\n * Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n resetNorthPitch(options?: AnimationOptions, eventData?: any): this {\n this.easeTo(extend({\n bearing: 0,\n pitch: 0,\n duration: 1000\n }, options), eventData);\n return this;\n }\n\n /**\n * Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the\n * `bearingSnap` threshold).\n *\n * Triggers the following events: `movestart`, `moveend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n snapToNorth(options?: AnimationOptions, eventData?: any): this {\n if (Math.abs(this.getBearing()) < this._bearingSnap) {\n return this.resetNorth(options, eventData);\n }\n return this;\n }\n\n /**\n * Returns the map's current pitch (tilt).\n *\n * @returns The map's current pitch, measured in degrees away from the plane of the screen.\n */\n getPitch(): number { return this.transform.pitch; }\n\n /**\n * Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`.\n *\n * Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`.\n *\n * @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60).\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n */\n setPitch(pitch: number, eventData?: any): this {\n this.jumpTo({pitch}, eventData);\n return this;\n }\n\n /**\n * @param bounds - Calculate the center for these bounds in the viewport and use\n * the highest zoom level up to and including `Map#getMaxZoom()` that fits\n * in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0.\n * @param options - Options object\n * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.\n * If map is unable to fit, method will warn and return undefined.\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * let newCameraTransform = map.cameraForBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n */\n cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CenterZoomBearing {\n bounds = LngLatBounds.convert(bounds);\n const bearing = options && options.bearing || 0;\n return this._cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), bearing, options);\n }\n\n /**\n * @internal\n * Calculate the center of these two points in the viewport and use\n * the highest zoom level up to and including `Map#getMaxZoom()` that fits\n * the points in the viewport at the specified bearing.\n * @param p0 - First point\n * @param p1 - Second point\n * @param bearing - Desired map bearing at end of animation, in degrees\n * @param options - the camera options\n * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`.\n * If map is unable to fit, method will warn and return undefined.\n * @example\n * ```ts\n * let p0 = [-79, 43];\n * let p1 = [-73, 45];\n * let bearing = 90;\n * let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n */\n _cameraForBoxAndBearing(p0: LngLatLike, p1: LngLatLike, bearing: number, options?: CameraForBoundsOptions): CenterZoomBearing {\n const defaultPadding = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n options = extend({\n padding: defaultPadding,\n offset: [0, 0],\n maxZoom: this.transform.maxZoom\n }, options);\n\n if (typeof options.padding === 'number') {\n const p = options.padding;\n options.padding = {\n top: p,\n bottom: p,\n right: p,\n left: p\n };\n }\n\n options.padding = extend(defaultPadding, options.padding) as PaddingOptions;\n const tr = this.transform;\n const edgePadding = tr.padding;\n\n // We want to calculate the upper right and lower left of the box defined by p0 and p1\n // in a coordinate system rotate to match the destination bearing.\n const p0world = tr.project(LngLat.convert(p0));\n const p1world = tr.project(LngLat.convert(p1));\n const p0rotated = p0world.rotate(-bearing * Math.PI / 180);\n const p1rotated = p1world.rotate(-bearing * Math.PI / 180);\n\n const upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));\n const lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));\n\n // Calculate zoom: consider the original bbox and padding.\n const size = upperRight.sub(lowerLeft);\n const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x;\n const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y;\n\n if (scaleY < 0 || scaleX < 0) {\n warnOnce(\n 'Map cannot fit within canvas with the given bounds, padding, and/or offset.'\n );\n return undefined;\n }\n\n const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);\n\n // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.\n const offset = Point.convert(options.offset);\n const paddingOffsetX = (options.padding.left - options.padding.right) / 2;\n const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;\n const paddingOffset = new Point(paddingOffsetX, paddingOffsetY);\n const rotatedPaddingOffset = paddingOffset.rotate(bearing * Math.PI / 180);\n const offsetAtInitialZoom = offset.add(rotatedPaddingOffset);\n const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));\n\n const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));\n\n return {\n center,\n zoom,\n bearing\n };\n }\n\n /**\n * Pans and zooms the map to contain its visible area within the specified geographical bounds.\n * This function will also reset the map's bearing to 0 if bearing is nonzero.\n *\n * Triggers the following events: `movestart` and `moveend`.\n *\n * @param bounds - Center these bounds in the viewport and use the highest\n * zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport.\n * @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * let bbox = [[-79, 43], [-73, 45]];\n * map.fitBounds(bbox, {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/)\n */\n fitBounds(bounds: LngLatBoundsLike, options?: FitBoundsOptions, eventData?: any): this {\n return this._fitInternal(\n this.cameraForBounds(bounds, options),\n options,\n eventData);\n }\n\n /**\n * Pans, rotates and zooms the map to to fit the box made by points p0 and p1\n * once the map is rotated to the specified bearing. To zoom without rotating,\n * pass in the current map bearing.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`.\n *\n * @param p0 - First point on screen, in pixel coordinates\n * @param p1 - Second point on screen, in pixel coordinates\n * @param bearing - Desired map bearing at end of animation, in degrees\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * let p0 = [220, 400];\n * let p1 = [500, 900];\n * map.fitScreenCoordinates(p0, p1, map.getBearing(), {\n * padding: {top: 10, bottom:25, left: 15, right: 5}\n * });\n * ```\n * @see Used by {@link BoxZoomHandler}\n */\n fitScreenCoordinates(p0: PointLike, p1: PointLike, bearing: number, options?: FitBoundsOptions, eventData?: any): this {\n return this._fitInternal(\n this._cameraForBoxAndBearing(\n this.transform.pointLocation(Point.convert(p0)),\n this.transform.pointLocation(Point.convert(p1)),\n bearing,\n options),\n options,\n eventData);\n }\n\n _fitInternal(calculatedOptions?: CenterZoomBearing, options?: FitBoundsOptions, eventData?: any): this {\n // cameraForBounds warns + returns undefined if unable to fit:\n if (!calculatedOptions) return this;\n\n options = extend(calculatedOptions, options);\n // Explicitly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.\n delete options.padding;\n\n return options.linear ?\n this.easeTo(options, eventData) :\n this.flyTo(options, eventData);\n }\n\n /**\n * Changes any combination of center, zoom, bearing, and pitch, without\n * an animated transition. The map will retain its current values for any\n * details not specified in `options`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options object\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // jump to coordinates at current zoom\n * map.jumpTo({center: [0, 0]});\n * // jump with zoom, pitch, and bearing options\n * map.jumpTo({\n * center: [0, 0],\n * zoom: 8,\n * pitch: 45,\n * bearing: 90\n * });\n * ```\n * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/)\n * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/)\n */\n jumpTo(options: JumpToOptions, eventData?: any): this {\n this.stop();\n\n const tr = this._getTransformForUpdate();\n let zoomChanged = false,\n bearingChanged = false,\n pitchChanged = false;\n\n if ('zoom' in options && tr.zoom !== +options.zoom) {\n zoomChanged = true;\n tr.zoom = +options.zoom;\n }\n\n if (options.center !== undefined) {\n tr.center = LngLat.convert(options.center);\n }\n\n if ('bearing' in options && tr.bearing !== +options.bearing) {\n bearingChanged = true;\n tr.bearing = +options.bearing;\n }\n\n if ('pitch' in options && tr.pitch !== +options.pitch) {\n pitchChanged = true;\n tr.pitch = +options.pitch;\n }\n\n if (options.padding != null && !tr.isPaddingEqual(options.padding)) {\n tr.padding = options.padding;\n }\n this._applyUpdatedTransform(tr);\n\n this.fire(new Event('movestart', eventData))\n .fire(new Event('move', eventData));\n\n if (zoomChanged) {\n this.fire(new Event('zoomstart', eventData))\n .fire(new Event('zoom', eventData))\n .fire(new Event('zoomend', eventData));\n }\n\n if (bearingChanged) {\n this.fire(new Event('rotatestart', eventData))\n .fire(new Event('rotate', eventData))\n .fire(new Event('rotateend', eventData));\n }\n\n if (pitchChanged) {\n this.fire(new Event('pitchstart', eventData))\n .fire(new Event('pitch', eventData))\n .fire(new Event('pitchend', eventData));\n }\n\n return this.fire(new Event('moveend', eventData));\n }\n\n /**\n * Calculates pitch, zoom and bearing for looking at `newCenter` with the camera position being `newCenter`\n * and returns them as {@link CameraOptions}.\n * @param from - The camera to look from\n * @param altitudeFrom - The altitude of the camera to look from\n * @param to - The center to look at\n * @param altitudeTo - Optional altitude of the center to look at. If none given the ground height will be used.\n * @returns the calculated camera options\n */\n calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo: number = 0): CameraOptions {\n const fromMerc = MercatorCoordinate.fromLngLat(from, altitudeFrom);\n const toMerc = MercatorCoordinate.fromLngLat(to, altitudeTo);\n const dx = toMerc.x - fromMerc.x;\n const dy = toMerc.y - fromMerc.y;\n const dz = toMerc.z - fromMerc.z;\n\n const distance3D = Math.hypot(dx, dy, dz);\n if (distance3D === 0) throw new Error('Can\\'t calculate camera options with same From and To');\n\n const groundDistance = Math.hypot(dx, dy);\n\n const zoom = this.transform.scaleZoom(this.transform.cameraToCenterDistance / distance3D / this.transform.tileSize);\n const bearing = (Math.atan2(dx, -dy) * 180) / Math.PI;\n let pitch = (Math.acos(groundDistance / distance3D) * 180) / Math.PI;\n pitch = dz < 0 ? 90 - pitch : 90 + pitch;\n\n return {\n center: toMerc.toLngLat(),\n zoom,\n pitch,\n bearing\n };\n }\n\n /**\n * Changes any combination of `center`, `zoom`, `bearing`, `pitch`, and `padding` with an animated transition\n * between old and new values. The map will retain its current values for any\n * details not specified in `options`.\n *\n * Note: The transition will happen instantly if the user has enabled\n * the `reduced motion` accessibility feature enabled in their operating system,\n * unless `options` includes `essential: true`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options describing the destination and animation of the transition.\n * Accepts {@link CameraOptions} and {@link AnimationOptions}.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/)\n */\n easeTo(options: EaseToOptions & {\n easeId?: string;\n noMoveStart?: boolean;\n }, eventData?: any): this {\n this._stop(false, options.easeId);\n\n options = extend({\n offset: [0, 0],\n duration: 500,\n easing: defaultEasing\n }, options);\n\n if (options.animate === false || (!options.essential && browser.prefersReducedMotion)) options.duration = 0;\n\n const tr = this._getTransformForUpdate(),\n startZoom = this.getZoom(),\n startBearing = this.getBearing(),\n startPitch = this.getPitch(),\n startPadding = this.getPadding(),\n\n zoom = 'zoom' in options ? +options.zoom : startZoom,\n bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing,\n pitch = 'pitch' in options ? +options.pitch : startPitch,\n padding = 'padding' in options ? options.padding : tr.padding;\n\n const offsetAsPoint = Point.convert(options.offset);\n let pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n const locationAtOffset = tr.pointLocation(pointAtOffset);\n const center = LngLat.convert(options.center || locationAtOffset);\n this._normalizeCenter(center);\n\n const from = tr.project(locationAtOffset);\n const delta = tr.project(center).sub(from);\n const finalScale = tr.zoomScale(zoom - startZoom);\n\n let around, aroundPoint;\n\n if (options.around) {\n around = LngLat.convert(options.around);\n aroundPoint = tr.locationPoint(around);\n }\n\n const currently = {\n moving: this._moving,\n zooming: this._zooming,\n rotating: this._rotating,\n pitching: this._pitching\n };\n\n this._zooming = this._zooming || (zoom !== startZoom);\n this._rotating = this._rotating || (startBearing !== bearing);\n this._pitching = this._pitching || (pitch !== startPitch);\n this._padding = !tr.isPaddingEqual(padding as PaddingOptions);\n\n this._easeId = options.easeId;\n this._prepareEase(eventData, options.noMoveStart, currently);\n if (this.terrain) this._prepareElevation(center);\n\n this._ease((k) => {\n if (this._zooming) {\n tr.zoom = interpolates.number(startZoom, zoom, k);\n }\n if (this._rotating) {\n tr.bearing = interpolates.number(startBearing, bearing, k);\n }\n if (this._pitching) {\n tr.pitch = interpolates.number(startPitch, pitch, k);\n }\n if (this._padding) {\n tr.interpolatePadding(startPadding, padding as PaddingOptions, k);\n // When padding is being applied, Transform#centerPoint is changing continuously,\n // thus we need to recalculate offsetPoint every frame\n pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n }\n\n if (this.terrain && !options.freezeElevation) this._updateElevation(k);\n\n if (around) {\n tr.setLocationAtPoint(around, aroundPoint);\n } else {\n const scale = tr.zoomScale(tr.zoom - startZoom);\n const base = zoom > startZoom ?\n Math.min(2, finalScale) :\n Math.max(0.5, finalScale);\n const speedup = Math.pow(base, 1 - k);\n const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));\n tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);\n }\n\n this._applyUpdatedTransform(tr);\n\n this._fireMoveEvents(eventData);\n\n }, (interruptingEaseId?: string) => {\n if (this.terrain) this._finalizeElevation();\n this._afterEase(eventData, interruptingEaseId);\n }, options as any);\n\n return this;\n }\n\n _prepareEase(eventData: any, noMoveStart: boolean, currently: any = {}) {\n this._moving = true;\n if (!noMoveStart && !currently.moving) {\n this.fire(new Event('movestart', eventData));\n }\n if (this._zooming && !currently.zooming) {\n this.fire(new Event('zoomstart', eventData));\n }\n if (this._rotating && !currently.rotating) {\n this.fire(new Event('rotatestart', eventData));\n }\n if (this._pitching && !currently.pitching) {\n this.fire(new Event('pitchstart', eventData));\n }\n }\n\n _prepareElevation(center: LngLat) {\n this._elevationCenter = center;\n this._elevationStart = this.transform.elevation;\n this._elevationTarget = this.terrain.getElevationForLngLatZoom(center, this.transform.tileZoom);\n this._elevationFreeze = true;\n }\n\n _updateElevation(k: number) {\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);\n const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);\n // target terrain updated during flight, slowly move camera to new height\n if (k < 1 && elevation !== this._elevationTarget) {\n const pitch1 = this._elevationTarget - this._elevationStart;\n const pitch2 = (elevation - (pitch1 * k + this._elevationStart)) / (1 - k);\n this._elevationStart += k * (pitch1 - pitch2);\n this._elevationTarget = elevation;\n }\n this.transform.elevation = interpolates.number(this._elevationStart, this._elevationTarget, k);\n }\n\n _finalizeElevation() {\n this._elevationFreeze = false;\n this.transform.recalculateZoom(this.terrain);\n }\n\n /**\n * @internal\n * Called when the camera is about to be manipulated.\n * If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes.\n * This underlying transform represents the \"desired state\" proposed by input handlers / animations / UI controls.\n * It may differ from the state used for rendering (`this.transform`).\n * @returns Transform to apply changes to\n */\n _getTransformForUpdate(): Transform {\n if (!this.transformCameraUpdate) return this.transform;\n\n if (!this._requestedCameraState) {\n this._requestedCameraState = this.transform.clone();\n }\n return this._requestedCameraState;\n }\n\n /**\n * @internal\n * Called after the camera is done being manipulated.\n * @param tr - the requested camera end state\n * Call `transformCameraUpdate` if present, and then apply the \"approved\" changes.\n */\n _applyUpdatedTransform(tr: Transform) {\n if (!this.transformCameraUpdate) return;\n\n const nextTransform = tr.clone();\n const {\n center,\n zoom,\n pitch,\n bearing,\n elevation\n } = this.transformCameraUpdate(nextTransform);\n if (center) nextTransform.center = center;\n if (zoom !== undefined) nextTransform.zoom = zoom;\n if (pitch !== undefined) nextTransform.pitch = pitch;\n if (bearing !== undefined) nextTransform.bearing = bearing;\n if (elevation !== undefined) nextTransform.elevation = elevation;\n this.transform.apply(nextTransform);\n }\n\n _fireMoveEvents(eventData?: any) {\n this.fire(new Event('move', eventData));\n if (this._zooming) {\n this.fire(new Event('zoom', eventData));\n }\n if (this._rotating) {\n this.fire(new Event('rotate', eventData));\n }\n if (this._pitching) {\n this.fire(new Event('pitch', eventData));\n }\n }\n\n _afterEase(eventData?: any, easeId?: string) {\n // if this easing is being stopped to start another easing with\n // the same id then don't fire any events to avoid extra start/stop events\n if (this._easeId && easeId && this._easeId === easeId) {\n return;\n }\n delete this._easeId;\n\n const wasZooming = this._zooming;\n const wasRotating = this._rotating;\n const wasPitching = this._pitching;\n this._moving = false;\n this._zooming = false;\n this._rotating = false;\n this._pitching = false;\n this._padding = false;\n\n if (wasZooming) {\n this.fire(new Event('zoomend', eventData));\n }\n if (wasRotating) {\n this.fire(new Event('rotateend', eventData));\n }\n if (wasPitching) {\n this.fire(new Event('pitchend', eventData));\n }\n this.fire(new Event('moveend', eventData));\n }\n\n /**\n * Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that\n * evokes flight. The animation seamlessly incorporates zooming and panning to help\n * the user maintain her bearings even after traversing a great distance.\n *\n * Note: The animation will be skipped, and this will behave equivalently to `jumpTo`\n * if the user has the `reduced motion` accessibility feature enabled in their operating system,\n * unless 'options' includes `essential: true`.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`,\n * `pitch`, `pitchend`, and `rotate`.\n *\n * @param options - Options describing the destination and animation of the transition.\n * Accepts {@link CameraOptions}, {@link AnimationOptions},\n * and the following additional options.\n * @param eventData - Additional properties to be added to event objects of events triggered by this method.\n * @returns `this`\n * @example\n * ```ts\n * // fly with default options to null island\n * map.flyTo({center: [0, 0], zoom: 9});\n * // using flyTo options\n * map.flyTo({\n * center: [0, 0],\n * zoom: 9,\n * speed: 0.2,\n * curve: 1,\n * easing(t) {\n * return t;\n * }\n * });\n * ```\n * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/)\n * @see [Slowly fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto-options/)\n * @see [Fly to a location based on scroll position](https://maplibre.org/maplibre-gl-js/docs/examples/scroll-fly-to/)\n */\n flyTo(options: FlyToOptions, eventData?: any): this {\n // Fall through to jumpTo if user has set prefers-reduced-motion\n if (!options.essential && browser.prefersReducedMotion) {\n const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']) as CameraOptions;\n return this.jumpTo(coercedOptions, eventData);\n }\n\n // This method implements an “optimal path” animation, as detailed in:\n //\n // Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and panning.” INFOVIS\n // ’03. pp. 15–22. .\n //\n // Where applicable, local variable documentation begins with the associated variable or\n // function in van Wijk (2003).\n\n this.stop();\n\n options = extend({\n offset: [0, 0],\n speed: 1.2,\n curve: 1.42,\n easing: defaultEasing\n }, options);\n\n const tr = this._getTransformForUpdate(),\n startZoom = this.getZoom(),\n startBearing = this.getBearing(),\n startPitch = this.getPitch(),\n startPadding = this.getPadding();\n\n const zoom = 'zoom' in options ? clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;\n const bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing;\n const pitch = 'pitch' in options ? +options.pitch : startPitch;\n const padding = 'padding' in options ? options.padding : tr.padding;\n\n const scale = tr.zoomScale(zoom - startZoom);\n const offsetAsPoint = Point.convert(options.offset);\n let pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n const locationAtOffset = tr.pointLocation(pointAtOffset);\n const center = LngLat.convert(options.center || locationAtOffset);\n this._normalizeCenter(center);\n\n const from = tr.project(locationAtOffset);\n const delta = tr.project(center).sub(from);\n\n let rho = options.curve;\n\n // w₀: Initial visible span, measured in pixels at the initial scale.\n const w0 = Math.max(tr.width, tr.height),\n // w₁: Final visible span, measured in pixels with respect to the initial scale.\n w1 = w0 / scale,\n // Length of the flight path as projected onto the ground plane, measured in pixels from\n // the world image origin at the initial scale.\n u1 = delta.mag();\n\n if ('minZoom' in options) {\n const minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);\n // wm: Maximum visible span, measured in pixels with respect to the initial\n // scale.\n const wMax = w0 / tr.zoomScale(minZoom - startZoom);\n rho = Math.sqrt(wMax / u1 * 2);\n }\n\n // ρ²\n const rho2 = rho * rho;\n\n /**\n * rᵢ: Returns the zoom-out factor at one end of the animation.\n *\n * @param descent - `true` for the descent, `false` for the ascent\n */\n function zoomOutFactor(descent: boolean) {\n const b = (w1 * w1 - w0 * w0 + (descent ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (descent ? w1 : w0) * rho2 * u1);\n return Math.log(Math.sqrt(b * b + 1) - b);\n }\n\n function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; }\n function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; }\n function tanh(n) { return sinh(n) / cosh(n); }\n\n // r₀: Zoom-out factor during ascent.\n const r0 = zoomOutFactor(false);\n\n // w(s): Returns the visible span on the ground, measured in pixels with respect to the\n // initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°.\n let w: (_: number) => number = function (s) {\n return (cosh(r0) / cosh(r0 + rho * s));\n };\n\n // u(s): Returns the distance along the flight path as projected onto the ground plane,\n // measured in pixels from the world image origin at the initial scale.\n let u: (_: number) => number = function (s) {\n return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;\n };\n\n // S: Total length of the flight path, measured in ρ-screenfuls.\n let S = (zoomOutFactor(true) - r0) / rho;\n\n // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.\n if (Math.abs(u1) < 0.000001 || !isFinite(S)) {\n // Perform a more or less instantaneous transition if the path is too short.\n if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData);\n\n const k = w1 < w0 ? -1 : 1;\n S = Math.abs(Math.log(w1 / w0)) / rho;\n\n u = function() { return 0; };\n w = function(s) { return Math.exp(k * rho * s); };\n }\n\n if ('duration' in options) {\n options.duration = +options.duration;\n } else {\n const V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;\n options.duration = 1000 * S / V;\n }\n\n if (options.maxDuration && options.duration > options.maxDuration) {\n options.duration = 0;\n }\n\n this._zooming = true;\n this._rotating = (startBearing !== bearing);\n this._pitching = (pitch !== startPitch);\n this._padding = !tr.isPaddingEqual(padding as PaddingOptions);\n\n this._prepareEase(eventData, false);\n if (this.terrain) this._prepareElevation(center);\n\n this._ease((k) => {\n // s: The distance traveled along the flight path, measured in ρ-screenfuls.\n const s = k * S;\n const scale = 1 / w(s);\n tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale);\n\n if (this._rotating) {\n tr.bearing = interpolates.number(startBearing, bearing, k);\n }\n if (this._pitching) {\n tr.pitch = interpolates.number(startPitch, pitch, k);\n }\n if (this._padding) {\n tr.interpolatePadding(startPadding, padding as PaddingOptions, k);\n // When padding is being applied, Transform#centerPoint is changing continuously,\n // thus we need to recalculate offsetPoint every frame\n pointAtOffset = tr.centerPoint.add(offsetAsPoint);\n }\n\n if (this.terrain && !options.freezeElevation) this._updateElevation(k);\n\n const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(scale));\n tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);\n\n this._applyUpdatedTransform(tr);\n\n this._fireMoveEvents(eventData);\n\n }, () => {\n if (this.terrain) this._finalizeElevation();\n this._afterEase(eventData);\n }, options);\n\n return this;\n }\n\n isEasing() {\n return !!this._easeFrameId;\n }\n\n /**\n * Stops any animated transition underway.\n *\n * @returns `this`\n */\n stop(): this {\n return this._stop();\n }\n\n _stop(allowGestures?: boolean, easeId?: string): this {\n if (this._easeFrameId) {\n this._cancelRenderFrame(this._easeFrameId);\n delete this._easeFrameId;\n delete this._onEaseFrame;\n }\n\n if (this._onEaseEnd) {\n // The _onEaseEnd function might emit events which trigger new\n // animation, which sets a new _onEaseEnd. Ensure we don't delete\n // it unintentionally.\n const onEaseEnd = this._onEaseEnd;\n delete this._onEaseEnd;\n onEaseEnd.call(this, easeId);\n }\n if (!allowGestures) {\n const handlers = (this as any).handlers;\n if (handlers) handlers.stop(false);\n }\n return this;\n }\n\n _ease(frame: (_: number) => void,\n finish: () => void,\n options: {\n animate?: boolean;\n duration?: number;\n easing?: (_: number) => number;\n }) {\n if (options.animate === false || options.duration === 0) {\n frame(1);\n finish();\n } else {\n this._easeStart = browser.now();\n this._easeOptions = options;\n this._onEaseFrame = frame;\n this._onEaseEnd = finish;\n this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);\n }\n }\n\n // Callback for map._requestRenderFrame\n _renderFrameCallback = () => {\n const t = Math.min((browser.now() - this._easeStart) / this._easeOptions.duration, 1);\n this._onEaseFrame(this._easeOptions.easing(t));\n\n // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted\n if (t < 1 && this._easeFrameId) {\n this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);\n } else {\n this.stop();\n }\n };\n\n // convert bearing so that it's numerically close to the current one so that it interpolates properly\n _normalizeBearing(bearing: number, currentBearing: number) {\n bearing = wrap(bearing, -180, 180);\n const diff = Math.abs(bearing - currentBearing);\n if (Math.abs(bearing - 360 - currentBearing) < diff) bearing -= 360;\n if (Math.abs(bearing + 360 - currentBearing) < diff) bearing += 360;\n return bearing;\n }\n\n // If a path crossing the antimeridian would be shorter, extend the final coordinate so that\n // interpolating between the two endpoints will cross it.\n _normalizeCenter(center: LngLat) {\n const tr = this.transform;\n if (!tr.renderWorldCopies || tr.lngRange) return;\n\n const delta = center.lng - tr.center.lng;\n center.lng +=\n delta > 180 ? -360 :\n delta < -180 ? 360 : 0;\n }\n\n /**\n * Query the current elevation of location. It return null if terrain is not enabled. the elevation is in meters relative to mean sea-level\n * @param lngLatLike - [x,y] or LngLat coordinates of the location\n * @returns elevation in meters\n */\n queryTerrainElevation(lngLatLike: LngLatLike): number | null {\n if (!this.terrain) {\n return null;\n }\n const elevation = this.terrain.getElevationForLngLatZoom(LngLat.convert(lngLatLike), this.transform.tileZoom);\n /**\n * Different zoomlevels with different terrain-tiles the elevation-values are not the same.\n * map.transform.elevation variable with the center-altitude.\n * In maplibre the proj-matrix is translated by this value in negative z-direction.\n * So we need to add this value to the elevation to get the correct value.\n */\n return elevation - this.transform.elevation;\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\nimport type {MapDataEvent} from '../events';\nimport type {StyleSpecification} from '@maplibre/maplibre-gl-style-spec';\n/**\n * The {@link AttributionControl} options\n */\ntype AttributionOptions = {\n /**\n * If `true`, the attribution control will always collapse when moving the map. If `false`,\n * force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide.\n * **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.**\n */\n compact?: boolean;\n /**\n * Attributions to show in addition to any other attributions.\n */\n customAttribution?: string | Array;\n};\n\n/**\n * An `AttributionControl` control presents the map's attribution information. By default, the attribution control is expanded (regardless of map width).\n * @group Markers and Controls\n * @example\n * ```ts\n * let map = new maplibregl.Map({attributionControl: false})\n * .addControl(new maplibregl.AttributionControl({\n * compact: true\n * }));\n * ```\n */\nexport class AttributionControl implements IControl {\n options: AttributionOptions;\n _map: Map;\n _compact: boolean;\n _container: HTMLElement;\n _innerContainer: HTMLElement;\n _compactButton: HTMLElement;\n _editLink: HTMLAnchorElement;\n _attribHTML: string;\n styleId: string;\n styleOwner: string;\n\n /**\n * @param options - the attribution options\n */\n constructor(options: AttributionOptions = {}) {\n this.options = options;\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-right';\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._compact = this.options && this.options.compact;\n this._container = DOM.create('details', 'maplibregl-ctrl maplibregl-ctrl-attrib');\n this._compactButton = DOM.create('summary', 'maplibregl-ctrl-attrib-button', this._container);\n this._compactButton.addEventListener('click', this._toggleAttribution);\n this._setElementTitle(this._compactButton, 'ToggleAttribution');\n this._innerContainer = DOM.create('div', 'maplibregl-ctrl-attrib-inner', this._container);\n\n this._updateAttributions();\n this._updateCompact();\n\n this._map.on('styledata', this._updateData);\n this._map.on('sourcedata', this._updateData);\n this._map.on('terrain', this._updateData);\n this._map.on('resize', this._updateCompact);\n this._map.on('drag', this._updateCompactMinimize);\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n\n this._map.off('styledata', this._updateData);\n this._map.off('sourcedata', this._updateData);\n this._map.off('terrain', this._updateData);\n this._map.off('resize', this._updateCompact);\n this._map.off('drag', this._updateCompactMinimize);\n\n this._map = undefined;\n this._compact = undefined;\n this._attribHTML = undefined;\n }\n\n _setElementTitle(element: HTMLElement, title: string) {\n const str = this._map._getUIString(`AttributionControl.${title}`);\n element.title = str;\n element.setAttribute('aria-label', str);\n }\n\n _toggleAttribution = () => {\n if (this._container.classList.contains('maplibregl-compact')) {\n if (this._container.classList.contains('maplibregl-compact-show')) {\n this._container.setAttribute('open', '');\n this._container.classList.remove('maplibregl-compact-show');\n } else {\n this._container.classList.add('maplibregl-compact-show');\n this._container.removeAttribute('open');\n }\n }\n };\n\n _updateData = (e: MapDataEvent) => {\n if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style' || e.type === 'terrain')) {\n this._updateAttributions();\n }\n };\n\n _updateAttributions() {\n if (!this._map.style) return;\n let attributions: Array = [];\n if (this.options.customAttribution) {\n if (Array.isArray(this.options.customAttribution)) {\n attributions = attributions.concat(\n this.options.customAttribution.map(attribution => {\n if (typeof attribution !== 'string') return '';\n return attribution;\n })\n );\n } else if (typeof this.options.customAttribution === 'string') {\n attributions.push(this.options.customAttribution);\n }\n }\n\n if (this._map.style.stylesheet) {\n const stylesheet = this._map.style.stylesheet as StyleSpecification & { owner: string; id: string };\n this.styleOwner = stylesheet.owner;\n this.styleId = stylesheet.id;\n }\n\n const sourceCaches = this._map.style.sourceCaches;\n for (const id in sourceCaches) {\n const sourceCache = sourceCaches[id];\n if (sourceCache.used || sourceCache.usedForTerrain) {\n const source = sourceCache.getSource();\n if (source.attribution && attributions.indexOf(source.attribution) < 0) {\n attributions.push(source.attribution);\n }\n }\n }\n\n // remove any entries that are whitespace\n attributions = attributions.filter(e => String(e).trim());\n\n // remove any entries that are substrings of another entry.\n // first sort by length so that substrings come first\n attributions.sort((a, b) => a.length - b.length);\n attributions = attributions.filter((attrib, i) => {\n for (let j = i + 1; j < attributions.length; j++) {\n if (attributions[j].indexOf(attrib) >= 0) { return false; }\n }\n return true;\n });\n\n // check if attribution string is different to minimize DOM changes\n const attribHTML = attributions.join(' | ');\n if (attribHTML === this._attribHTML) return;\n\n this._attribHTML = attribHTML;\n\n if (attributions.length) {\n this._innerContainer.innerHTML = attribHTML;\n this._container.classList.remove('maplibregl-attrib-empty');\n } else {\n this._container.classList.add('maplibregl-attrib-empty');\n }\n this._updateCompact();\n // remove old DOM node from _editLink\n this._editLink = null;\n }\n\n _updateCompact = () => {\n if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {\n if (this._compact === false) {\n this._container.setAttribute('open', '');\n } else if (!this._container.classList.contains('maplibregl-compact') && !this._container.classList.contains('maplibregl-attrib-empty')) {\n this._container.setAttribute('open', '');\n this._container.classList.add('maplibregl-compact', 'maplibregl-compact-show');\n }\n } else {\n this._container.setAttribute('open', '');\n if (this._container.classList.contains('maplibregl-compact')) {\n this._container.classList.remove('maplibregl-compact', 'maplibregl-compact-show');\n }\n }\n };\n\n _updateCompactMinimize = () => {\n if (this._container.classList.contains('maplibregl-compact')) {\n if (this._container.classList.contains('maplibregl-compact-show')) {\n this._container.classList.remove('maplibregl-compact-show');\n }\n }\n };\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\n\n/**\n * The {@link LogoControl} options object\n */\ntype LogoOptions = {\n /**\n * If `true`, force a compact logo.\n * If `false`, force the full logo. The default is a responsive logo that collapses when the map is less than 640 pixels wide.\n */\n compact?: boolean;\n};\n\n/**\n * A `LogoControl` is a control that adds the watermark.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.LogoControl({compact: false}));\n * ```\n **/\nexport class LogoControl implements IControl {\n options: LogoOptions;\n _map: Map;\n _compact: boolean;\n _container: HTMLElement;\n\n constructor(options: LogoOptions = {}) {\n this.options = options;\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-left';\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._compact = this.options && this.options.compact;\n this._container = DOM.create('div', 'maplibregl-ctrl');\n const anchor = DOM.create('a', 'maplibregl-ctrl-logo');\n anchor.target = '_blank';\n anchor.rel = 'noopener nofollow';\n anchor.href = 'https://maplibre.org/';\n anchor.setAttribute('aria-label', this._map._getUIString('LogoControl.Title'));\n anchor.setAttribute('rel', 'noopener nofollow');\n this._container.appendChild(anchor);\n this._container.style.display = 'block';\n\n this._map.on('resize', this._updateCompact);\n this._updateCompact();\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('resize', this._updateCompact);\n this._map = undefined;\n this._compact = undefined;\n }\n\n _updateCompact = () => {\n const containerChildren = this._container.children;\n if (containerChildren.length) {\n const anchor = containerChildren[0];\n if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) {\n if (this._compact !== false) {\n anchor.classList.add('maplibregl-compact');\n }\n } else {\n anchor.classList.remove('maplibregl-compact');\n }\n }\n };\n\n}\n","export type TaskID = number; // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61\n\ntype Task = {\n callback: (timeStamp: number) => void;\n id: TaskID;\n cancelled: boolean;\n};\n\nexport class TaskQueue {\n _queue: Array;\n _id: TaskID;\n _cleared: boolean;\n _currentlyRunning: Array | false;\n\n constructor() {\n this._queue = [];\n this._id = 0;\n this._cleared = false;\n this._currentlyRunning = false;\n }\n\n add(callback: (timeStamp: number) => void): TaskID {\n const id = ++this._id;\n const queue = this._queue;\n queue.push({callback, id, cancelled: false});\n return id;\n }\n\n remove(id: TaskID) {\n const running = this._currentlyRunning;\n const queue = running ? this._queue.concat(running) : this._queue;\n for (const task of queue) {\n if (task.id === id) {\n task.cancelled = true;\n return;\n }\n }\n }\n\n run(timeStamp: number = 0) {\n if (this._currentlyRunning) throw new Error('Attempting to run(), but is already running.');\n const queue = this._currentlyRunning = this._queue;\n\n // Tasks queued by callbacks in the current queue should be executed\n // on the next run, not the current run.\n this._queue = [];\n\n for (const task of queue) {\n if (task.cancelled) continue;\n task.callback(timeStamp);\n if (this._cleared) break;\n }\n\n this._cleared = false;\n this._currentlyRunning = false;\n }\n\n clear() {\n if (this._currentlyRunning) {\n this._cleared = true;\n }\n this._queue = [];\n }\n}\n","export const defaultLocale = {\n 'AttributionControl.ToggleAttribution': 'Toggle attribution',\n 'AttributionControl.MapFeedback': 'Map feedback',\n 'FullscreenControl.Enter': 'Enter fullscreen',\n 'FullscreenControl.Exit': 'Exit fullscreen',\n 'GeolocateControl.FindMyLocation': 'Find my location',\n 'GeolocateControl.LocationNotAvailable': 'Location not available',\n 'LogoControl.Title': 'Mapbox logo',\n 'NavigationControl.ResetBearing': 'Reset bearing to north',\n 'NavigationControl.ZoomIn': 'Zoom in',\n 'NavigationControl.ZoomOut': 'Zoom out',\n 'ScaleControl.Feet': 'ft',\n 'ScaleControl.Meters': 'm',\n 'ScaleControl.Kilometers': 'km',\n 'ScaleControl.Miles': 'mi',\n 'ScaleControl.NauticalMiles': 'nm',\n 'TerrainControl.enableTerrain': 'Enable terrain',\n 'TerrainControl.disableTerrain': 'Disable terrain'\n};\n","import {createLayout} from '../util/struct_array';\n\nexport default createLayout([\n {name: 'a_pos3d', type: 'Int16', components: 3}\n]);\n","import {OverscaledTileID} from './tile_id';\nimport {Tile} from './tile';\nimport {EXTENT} from '../data/extent';\nimport {mat4} from 'gl-matrix';\nimport {Evented} from '../util/evented';\nimport type {Transform} from '../geo/transform';\nimport type {SourceCache} from '../source/source_cache';\nimport {Terrain} from '../render/terrain';\n\n/**\n * @internal\n * This class is a helper for the Terrain-class, it:\n * - loads raster-dem tiles\n * - manages all renderToTexture tiles.\n * - caches previous rendered tiles.\n * - finds all necessary renderToTexture tiles for a OverscaledTileID area\n * - finds the corresponding raster-dem tile for OverscaledTileID\n */\nexport class TerrainSourceCache extends Evented {\n /**\n * source-cache for the raster-dem source.\n */\n sourceCache: SourceCache;\n /**\n * stores all render-to-texture tiles.\n */\n _tiles: {[_: string]: Tile};\n /**\n * contains a list of tileID-keys for the current scene. (only for performance)\n */\n _renderableTilesKeys: Array;\n /**\n * raster-dem-tile for a TileID cache.\n */\n _sourceTileCache: {[_: string]: string};\n /**\n * minimum zoomlevel to render the terrain.\n */\n minzoom: number;\n /**\n * maximum zoomlevel to render the terrain.\n */\n maxzoom: number;\n /**\n * render-to-texture tileSize in scene.\n */\n tileSize: number;\n /**\n * raster-dem tiles will load for performance the actualZoom - deltaZoom zoom-level.\n */\n deltaZoom: number;\n\n constructor(sourceCache: SourceCache) {\n super();\n this.sourceCache = sourceCache;\n this._tiles = {};\n this._renderableTilesKeys = [];\n this._sourceTileCache = {};\n this.minzoom = 0;\n this.maxzoom = 22;\n this.tileSize = 512;\n this.deltaZoom = 1;\n sourceCache.usedForTerrain = true;\n sourceCache.tileSize = this.tileSize * 2 ** this.deltaZoom;\n }\n\n destruct() {\n this.sourceCache.usedForTerrain = false;\n this.sourceCache.tileSize = null;\n }\n\n /**\n * Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory.\n * @param transform - the operation to do\n * @param terrain - the terrain\n */\n update(transform: Transform, terrain: Terrain): void {\n // load raster-dem tiles for the current scene.\n this.sourceCache.update(transform, terrain);\n // create internal render-to-texture tiles for the current scene.\n this._renderableTilesKeys = [];\n const keys = {};\n for (const tileID of transform.coveringTiles({\n tileSize: this.tileSize,\n minzoom: this.minzoom,\n maxzoom: this.maxzoom,\n reparseOverscaled: false,\n terrain\n })) {\n keys[tileID.key] = true;\n this._renderableTilesKeys.push(tileID.key);\n if (!this._tiles[tileID.key]) {\n tileID.posMatrix = new Float64Array(16) as any;\n mat4.ortho(tileID.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n this._tiles[tileID.key] = new Tile(tileID, this.tileSize);\n }\n }\n // free unused tiles\n for (const key in this._tiles) {\n if (!keys[key]) delete this._tiles[key];\n }\n }\n\n /**\n * Free render to texture cache\n * @param tileID - optional, free only corresponding to tileID.\n */\n freeRtt(tileID?: OverscaledTileID) {\n for (const key in this._tiles) {\n const tile = this._tiles[key];\n if (!tileID || tile.tileID.equals(tileID) || tile.tileID.isChildOf(tileID) || tileID.isChildOf(tile.tileID))\n tile.rtt = [];\n }\n }\n\n /**\n * get a list of tiles, which are loaded and should be rendered in the current scene\n * @returns the renderable tiles\n */\n getRenderableTiles(): Array {\n return this._renderableTilesKeys.map(key => this.getTileByID(key));\n }\n\n /**\n * get terrain tile by the TileID key\n * @param id - the tile id\n * @returns the tile\n */\n getTileByID(id: string): Tile {\n return this._tiles[id];\n }\n\n /**\n * Searches for the corresponding current renderable terrain-tiles\n * @param tileID - the tile to look for\n * @returns the tiles that were found\n */\n getTerrainCoords(tileID: OverscaledTileID): Record {\n const coords = {};\n for (const key of this._renderableTilesKeys) {\n const _tileID = this._tiles[key].tileID;\n if (_tileID.canonical.equals(tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n coords[key] = coord;\n } else if (_tileID.canonical.isChildOf(tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n const dz = _tileID.canonical.z - tileID.canonical.z;\n const dx = _tileID.canonical.x - (_tileID.canonical.x >> dz << dz);\n const dy = _tileID.canonical.y - (_tileID.canonical.y >> dz << dz);\n const size = EXTENT >> dz;\n mat4.ortho(coord.posMatrix, 0, size, 0, size, 0, 1);\n mat4.translate(coord.posMatrix, coord.posMatrix, [-dx * size, -dy * size, 0]);\n coords[key] = coord;\n } else if (tileID.canonical.isChildOf(_tileID.canonical)) {\n const coord = tileID.clone();\n coord.posMatrix = new Float64Array(16) as any;\n const dz = tileID.canonical.z - _tileID.canonical.z;\n const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);\n const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);\n const size = EXTENT >> dz;\n mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1);\n mat4.translate(coord.posMatrix, coord.posMatrix, [dx * size, dy * size, 0]);\n mat4.scale(coord.posMatrix, coord.posMatrix, [1 / (2 ** dz), 1 / (2 ** dz), 0]);\n coords[key] = coord;\n }\n }\n return coords;\n }\n\n /**\n * find the covering raster-dem tile\n * @param tileID - the tile to look for\n * @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem.\n * @returns the tile\n */\n getSourceTile(tileID: OverscaledTileID, searchForDEM?: boolean): Tile {\n const source = this.sourceCache._source;\n let z = tileID.overscaledZ - this.deltaZoom;\n if (z > source.maxzoom) z = source.maxzoom;\n if (z < source.minzoom) return null;\n // cache for tileID to terrain-tileID\n if (!this._sourceTileCache[tileID.key])\n this._sourceTileCache[tileID.key] = tileID.scaledTo(z).key;\n let tile = this.sourceCache.getTileByID(this._sourceTileCache[tileID.key]);\n // during tile-loading phase look if parent tiles (with loaded dem) are available.\n if (!(tile && tile.dem) && searchForDEM)\n while (z >= source.minzoom && !(tile && tile.dem))\n tile = this.sourceCache.getTileByID(tileID.scaledTo(z--).key);\n return tile;\n }\n\n /**\n * get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers.\n * @param time - the time\n * @returns the relevant tiles\n */\n tilesAfterTime(time = Date.now()): Array {\n return Object.values(this._tiles).filter(t => t.timeAdded >= time);\n }\n}\n","\nimport {Tile} from '../source/tile';\nimport {mat4, vec2} from 'gl-matrix';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {RGBAImage} from '../util/image';\nimport {warnOnce} from '../util/util';\nimport {Pos3dArray, TriangleIndexArray} from '../data/array_types.g';\nimport pos3dAttributes from '../data/pos3d_attributes';\nimport {SegmentVector} from '../data/segment';\nimport {VertexBuffer} from '../gl/vertex_buffer';\nimport {IndexBuffer} from '../gl/index_buffer';\nimport {Painter} from './painter';\nimport {Texture} from '../render/texture';\nimport type {Framebuffer} from '../gl/framebuffer';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate, lngFromMercatorX, mercatorXfromLng} from '../geo/mercator_coordinate';\nimport {TerrainSourceCache} from '../source/terrain_source_cache';\nimport {SourceCache} from '../source/source_cache';\nimport {EXTENT} from '../data/extent';\nimport type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {LngLat, earthRadius} from '../geo/lng_lat';\n\n/**\n * @internal\n * A terrain GPU related object\n */\nexport type TerrainData = {\n 'u_depth': number;\n 'u_terrain': number;\n 'u_terrain_dim': number;\n 'u_terrain_matrix': mat4;\n 'u_terrain_unpack': number[];\n 'u_terrain_exaggeration': number;\n texture: WebGLTexture;\n depthTexture: WebGLTexture;\n tile: Tile;\n}\n\n/**\n * @internal\n * A terrain mesh object\n */\nexport type TerrainMesh = {\n indexBuffer: IndexBuffer;\n vertexBuffer: VertexBuffer;\n segments: SegmentVector;\n}\n\n/**\n * @internal\n * This is the main class which handles most of the 3D Terrain logic. It has the following topics:\n * 1) loads raster-dem tiles via the internal sourceCache this.sourceCache\n * 2) creates a depth-framebuffer, which is used to calculate the visibility of coordinates\n * 3) creates a coords-framebuffer, which is used the get to tile-coordinate for a screen-pixel\n * 4) stores all render-to-texture tiles in the this.sourceCache._tiles\n * 5) calculates the elevation for a specific tile-coordinate\n * 6) creates a terrain-mesh\n *\n * A note about the GPU resource-usage:\n * Framebuffers:\n * - one for the depth & coords framebuffer with the size of the map-div.\n * - one for rendering a tile to texture with the size of tileSize (= 512x512).\n * Textures:\n * - one texture for an empty raster-dem tile with size 1x1\n * - one texture for an empty depth-buffer, when terrain is disabled with size 1x1\n * - one texture for an each loaded raster-dem with size of the source.tileSize\n * - one texture for the coords-framebuffer with the size of the map-div.\n * - one texture for the depth-framebuffer with the size of the map-div.\n * - one texture for the encoded tile-coords with the size 2*tileSize (=1024x1024)\n * - finally for each render-to-texture tile (= this._tiles) a set of textures\n * for each render stack (The stack-concept is documented in painter.ts).\n * Normally there exists 1-3 Textures per tile, depending on the stylesheet.\n * Each Textures has the size 2*tileSize (= 1024x1024). Also there exists a\n * cache of the last 150 newest rendered tiles.\n *\n */\nexport class Terrain {\n /**\n * The style this terrain crresponds to\n */\n painter: Painter;\n /**\n * the sourcecache this terrain is based on\n */\n sourceCache: TerrainSourceCache;\n /**\n * the TerrainSpecification object passed to this instance\n */\n options: TerrainSpecification;\n /**\n * define the meshSize per tile.\n */\n meshSize: number;\n /**\n * multiplicator for the elevation. Used to make terrain more \"extreme\".\n */\n exaggeration: number;\n /**\n * to not see pixels in the render-to-texture tiles it is good to render them bigger\n * this number is the multiplicator (must be a power of 2) for the current tileSize.\n * So to get good results with not too much memory footprint a value of 2 should be fine.\n */\n qualityFactor: number;\n /**\n * holds the framebuffer object in size of the screen to render the coords & depth into a texture.\n */\n _fbo: Framebuffer;\n _fboCoordsTexture: Texture;\n _fboDepthTexture: Texture;\n _emptyDepthTexture: Texture;\n /**\n * GL Objects for the terrain-mesh\n * The mesh is a regular mesh, which has the advantage that it can be reused for all tiles.\n */\n _mesh: TerrainMesh;\n /**\n * coords index contains a list of tileID.keys. This index is used to identify\n * the tile via the alpha-cannel in the coords-texture.\n * As the alpha-channel has 1 Byte a max of 255 tiles can rendered without an error.\n */\n coordsIndex: Array;\n /**\n * tile-coords encoded in the rgb channel, _coordsIndex is in the alpha-channel.\n */\n _coordsTexture: Texture;\n /**\n * accuracy of the coords. 2 * tileSize should be enoughth.\n */\n _coordsTextureSize: number;\n /**\n * variables for an empty dem texture, which is used while the raster-dem tile is loading.\n */\n _emptyDemUnpack: number[];\n _emptyDemTexture: Texture;\n _emptyDemMatrix: mat4;\n /**\n * as of overzooming of raster-dem tiles in high zoomlevels, this cache contains\n * matrices to transform from vector-tile coords to raster-dem-tile coords.\n */\n _demMatrixCache: {[_: string]: { matrix: mat4; coord: OverscaledTileID }};\n\n constructor(painter: Painter, sourceCache: SourceCache, options: TerrainSpecification) {\n this.painter = painter;\n this.sourceCache = new TerrainSourceCache(sourceCache);\n this.options = options;\n this.exaggeration = typeof options.exaggeration === 'number' ? options.exaggeration : 1.0;\n this.qualityFactor = 2;\n this.meshSize = 128;\n this._demMatrixCache = {};\n this.coordsIndex = [];\n this._coordsTextureSize = 1024;\n }\n\n /**\n * get the elevation-value from original dem-data for a given tile-coordinate\n * @param tileID - the tile to get elevation for\n * @param x - between 0 .. EXTENT\n * @param y - between 0 .. EXTENT\n * @param extent - optional, default 8192\n * @returns the elevation\n */\n getDEMElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {\n if (!(x >= 0 && x < extent && y >= 0 && y < extent)) return 0;\n const terrain = this.getTerrainData(tileID);\n const dem = terrain.tile?.dem;\n if (!dem)\n return 0;\n\n const pos = vec2.transformMat4([] as any, [x / extent * EXTENT, y / extent * EXTENT], terrain.u_terrain_matrix);\n const coord = [pos[0] * dem.dim, pos[1] * dem.dim];\n\n // bilinear interpolation\n const cx = Math.floor(coord[0]),\n cy = Math.floor(coord[1]),\n tx = coord[0] - cx,\n ty = coord[1] - cy;\n return (\n dem.get(cx, cy) * (1 - tx) * (1 - ty) +\n dem.get(cx + 1, cy) * (tx) * (1 - ty) +\n dem.get(cx, cy + 1) * (1 - tx) * (ty) +\n dem.get(cx + 1, cy + 1) * (tx) * (ty)\n );\n }\n\n /**\n * Get the elevation for given {@link LngLat} in respect of exaggeration.\n * @param lnglat - the location\n * @param zoom - the zoom\n * @returns the elevation\n */\n getElevationForLngLatZoom(lnglat: LngLat, zoom: number) {\n const {tileID, mercatorX, mercatorY} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);\n return this.getElevation(tileID, mercatorX % EXTENT, mercatorY % EXTENT, EXTENT);\n }\n\n /**\n * Get the elevation for given coordinate in respect of exaggeration.\n * @param tileID - the tile id\n * @param x - between 0 .. EXTENT\n * @param y - between 0 .. EXTENT\n * @param extent - optional, default 8192\n * @returns the elevation\n */\n getElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {\n return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration;\n }\n\n /**\n * returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object\n * @param tileID - the tile to get the terrain for\n * @returns the terrain data to use in the program\n */\n getTerrainData(tileID: OverscaledTileID): TerrainData {\n // create empty DEM Objects, which will used while raster-dem tiles are loading.\n // creates an empty depth-buffer texture which is needed, during the initialization process of the 3d mesh..\n if (!this._emptyDemTexture) {\n const context = this.painter.context;\n const image = new RGBAImage({width: 1, height: 1}, new Uint8Array(1 * 4));\n this._emptyDepthTexture = new Texture(context, image, context.gl.RGBA, {premultiply: false});\n this._emptyDemUnpack = [0, 0, 0, 0];\n this._emptyDemTexture = new Texture(context, new RGBAImage({width: 1, height: 1}), context.gl.RGBA, {premultiply: false});\n this._emptyDemTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n this._emptyDemMatrix = mat4.identity([] as any);\n }\n // find covering dem tile and prepare demTexture\n const sourceTile = this.sourceCache.getSourceTile(tileID, true);\n if (sourceTile && sourceTile.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) {\n const context = this.painter.context;\n sourceTile.demTexture = this.painter.getTileTexture(sourceTile.dem.stride);\n if (sourceTile.demTexture) sourceTile.demTexture.update(sourceTile.dem.getPixels(), {premultiply: false});\n else sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, {premultiply: false});\n sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n sourceTile.needsTerrainPrepare = false;\n }\n // create matrix for lookup in dem data\n const matrixKey = sourceTile && (sourceTile + sourceTile.tileID.key) + tileID.key;\n if (matrixKey && !this._demMatrixCache[matrixKey]) {\n const maxzoom = this.sourceCache.sourceCache._source.maxzoom;\n let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;\n if (tileID.overscaledZ > tileID.canonical.z) {\n if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;\n else warnOnce('cannot calculate elevation if elevation maxzoom > source.maxzoom');\n }\n const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);\n const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);\n const demMatrix = mat4.fromScaling(new Float64Array(16) as any, [1 / (EXTENT << dz), 1 / (EXTENT << dz), 0]);\n mat4.translate(demMatrix, demMatrix, [dx * EXTENT, dy * EXTENT, 0]);\n this._demMatrixCache[tileID.key] = {matrix: demMatrix, coord: tileID};\n }\n // return uniform values & textures\n return {\n 'u_depth': 2,\n 'u_terrain': 3,\n 'u_terrain_dim': sourceTile && sourceTile.dem && sourceTile.dem.dim || 1,\n 'u_terrain_matrix': matrixKey ? this._demMatrixCache[tileID.key].matrix : this._emptyDemMatrix,\n 'u_terrain_unpack': sourceTile && sourceTile.dem && sourceTile.dem.getUnpackVector() || this._emptyDemUnpack,\n 'u_terrain_exaggeration': this.exaggeration,\n texture: (sourceTile && sourceTile.demTexture || this._emptyDemTexture).texture,\n depthTexture: (this._fboDepthTexture || this._emptyDepthTexture).texture,\n tile: sourceTile\n };\n }\n\n /**\n * get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture\n * @param texture - the texture\n * @returns the frame buffer\n */\n getFramebuffer(texture: string): Framebuffer {\n const painter = this.painter;\n const width = painter.width / devicePixelRatio;\n const height = painter.height / devicePixelRatio;\n if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) {\n this._fbo.destroy();\n this._fboCoordsTexture.destroy();\n this._fboDepthTexture.destroy();\n delete this._fbo;\n delete this._fboDepthTexture;\n delete this._fboCoordsTexture;\n }\n if (!this._fboCoordsTexture) {\n this._fboCoordsTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});\n this._fboCoordsTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);\n }\n if (!this._fboDepthTexture) {\n this._fboDepthTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});\n this._fboDepthTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);\n }\n if (!this._fbo) {\n this._fbo = painter.context.createFramebuffer(width, height, true, false);\n this._fbo.depthAttachment.set(painter.context.createRenderbuffer(painter.context.gl.DEPTH_COMPONENT16, width, height));\n }\n this._fbo.colorAttachment.set(texture === 'coords' ? this._fboCoordsTexture.texture : this._fboDepthTexture.texture);\n return this._fbo;\n }\n\n /**\n * create coords texture, needed to grab coordinates from canvas\n * encode coords coordinate into 4 bytes:\n * - 8 lower bits for x\n * - 8 lower bits for y\n * - 4 higher bits for x\n * - 4 higher bits for y\n * - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value\n * @returns the texture\n */\n getCoordsTexture(): Texture {\n const context = this.painter.context;\n if (this._coordsTexture) return this._coordsTexture;\n const data = new Uint8Array(this._coordsTextureSize * this._coordsTextureSize * 4);\n for (let y = 0, i = 0; y < this._coordsTextureSize; y++) for (let x = 0; x < this._coordsTextureSize; x++, i += 4) {\n data[i + 0] = x & 255;\n data[i + 1] = y & 255;\n data[i + 2] = ((x >> 8) << 4) | (y >> 8);\n data[i + 3] = 0;\n }\n const image = new RGBAImage({width: this._coordsTextureSize, height: this._coordsTextureSize}, new Uint8Array(data.buffer));\n const texture = new Texture(context, image, context.gl.RGBA, {premultiply: false});\n texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);\n this._coordsTexture = texture;\n return texture;\n }\n\n /**\n * Reads a pixel from the coords-framebuffer and translate this to mercator.\n * @param p - Screen-Coordinate\n * @returns mercator coordinate for a screen pixel\n */\n pointCoordinate(p: Point): MercatorCoordinate {\n const rgba = new Uint8Array(4);\n const context = this.painter.context, gl = context.gl;\n // grab coordinate pixel from coordinates framebuffer\n context.bindFramebuffer.set(this.getFramebuffer('coords').framebuffer);\n gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);\n context.bindFramebuffer.set(null);\n // decode coordinates (encoding see getCoordsTexture)\n const x = rgba[0] + ((rgba[2] >> 4) << 8);\n const y = rgba[1] + ((rgba[2] & 15) << 8);\n const tileID = this.coordsIndex[255 - rgba[3]];\n const tile = tileID && this.sourceCache.getTileByID(tileID);\n if (!tile) return null;\n const coordsSize = this._coordsTextureSize;\n const worldSize = (1 << tile.tileID.canonical.z) * coordsSize;\n const mercatorX = (tile.tileID.canonical.x * coordsSize + x) / worldSize;\n return new MercatorCoordinate(\n this._allowMercatorOverflow(p, mercatorX),\n (tile.tileID.canonical.y * coordsSize + y) / worldSize,\n this.getElevation(tile.tileID, x, y, coordsSize)\n );\n }\n\n /**\n * create a regular mesh which will be used by all terrain-tiles\n * @returns the created regular mesh\n */\n getTerrainMesh(): TerrainMesh {\n if (this._mesh) return this._mesh;\n const context = this.painter.context;\n const vertexArray = new Pos3dArray();\n const indexArray = new TriangleIndexArray();\n const meshSize = this.meshSize;\n const delta = EXTENT / meshSize;\n const meshSize2 = meshSize * meshSize;\n for (let y = 0; y <= meshSize; y++) for (let x = 0; x <= meshSize; x++)\n vertexArray.emplaceBack(x * delta, y * delta, 0);\n for (let y = 0; y < meshSize2; y += meshSize + 1) for (let x = 0; x < meshSize; x++) {\n indexArray.emplaceBack(x + y, meshSize + x + y + 1, meshSize + x + y + 2);\n indexArray.emplaceBack(x + y, meshSize + x + y + 2, x + y + 1);\n }\n // add an extra frame around the mesh to avoid stiching on tile boundaries with different zoomlevels\n // first code-block is for top-bottom frame and second for left-right frame\n const offsetTop = vertexArray.length, offsetBottom = offsetTop + (meshSize + 1) * 2;\n for (const y of [0, 1]) for (let x = 0; x <= meshSize; x++) for (const z of [0, 1])\n vertexArray.emplaceBack(x * delta, y * EXTENT, z);\n for (let x = 0; x < meshSize * 2; x += 2) {\n indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 1, offsetBottom + x + 3);\n indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 3, offsetBottom + x + 2);\n indexArray.emplaceBack(offsetTop + x, offsetTop + x + 3, offsetTop + x + 1);\n indexArray.emplaceBack(offsetTop + x, offsetTop + x + 2, offsetTop + x + 3);\n }\n const offsetLeft = vertexArray.length, offsetRight = offsetLeft + (meshSize + 1) * 2;\n for (const x of [0, 1]) for (let y = 0; y <= meshSize; y++) for (const z of [0, 1])\n vertexArray.emplaceBack(x * EXTENT, y * delta, z);\n for (let y = 0; y < meshSize * 2; y += 2) {\n indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 1, offsetLeft + y + 3);\n indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 3, offsetLeft + y + 2);\n indexArray.emplaceBack(offsetRight + y, offsetRight + y + 3, offsetRight + y + 1);\n indexArray.emplaceBack(offsetRight + y, offsetRight + y + 2, offsetRight + y + 3);\n }\n this._mesh = {\n indexBuffer: context.createIndexBuffer(indexArray),\n vertexBuffer: context.createVertexBuffer(vertexArray, pos3dAttributes.members),\n segments: SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length)\n };\n return this._mesh;\n }\n\n /**\n * Calculates a height of the frame around the terrain-mesh to avoid stiching between\n * tile boundaries in different zoomlevels.\n * @param zoom - current zoomlevel\n * @returns the elevation delta in meters\n */\n getMeshFrameDelta(zoom: number): number {\n // divide by 5 is evaluated by trial & error to get a frame in the right height\n return 2 * Math.PI * earthRadius / Math.pow(2, zoom) / 5;\n }\n\n getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number) {\n const {tileID} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);\n return this.getMinMaxElevation(tileID).minElevation ?? 0;\n }\n\n /**\n * Get the minimum and maximum elevation contained in a tile. This includes any\n * exaggeration included in the terrain.\n *\n * @param tileID - ID of the tile to be used as a source for the min/max elevation\n * @returns the minimum and maximum elevation found in the tile, including the terrain's\n * exaggeration\n */\n getMinMaxElevation(tileID: OverscaledTileID): {minElevation: number | null; maxElevation: number | null} {\n const tile = this.getTerrainData(tileID).tile;\n const minMax = {minElevation: null, maxElevation: null};\n if (tile && tile.dem) {\n minMax.minElevation = tile.dem.min * this.exaggeration;\n minMax.maxElevation = tile.dem.max * this.exaggeration;\n }\n return minMax;\n }\n\n _getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { tileID: OverscaledTileID; mercatorX: number; mercatorY: number} {\n const mercatorCoordinate = MercatorCoordinate.fromLngLat(lnglat.wrap());\n const worldSize = (1 << zoom) * EXTENT;\n const mercatorX = mercatorCoordinate.x * worldSize;\n const mercatorY = mercatorCoordinate.y * worldSize;\n const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);\n const tileID = new OverscaledTileID(zoom, 0, zoom, tileX, tileY);\n return {\n tileID,\n mercatorX,\n mercatorY\n };\n }\n\n _allowMercatorOverflow(p: Point, mercatorX: number): number {\n const inLeftHalf = p.x < (this.painter.width / 2);\n let lng = lngFromMercatorX(mercatorX);\n const centerLng = this.painter.transform.center.lng;\n if (\n (inLeftHalf && Math.sign(lng) > 0 && Math.sign(centerLng) < 0) ||\n (!inLeftHalf && Math.sign(lng) < 0 && Math.sign(centerLng) > 0)\n ) {\n lng = 360 * Math.sign(centerLng) + lng;\n return mercatorXfromLng(lng);\n }\n return mercatorX;\n }\n}\n","import {Texture} from '../render/texture';\nimport {Context} from './context';\nimport {Framebuffer} from './framebuffer';\n\nexport type PoolObject = {\n id: number;\n fbo: Framebuffer;\n texture: Texture;\n stamp: number;\n inUse: boolean;\n};\n/**\n * @internal\n * `RenderPool` is a resource pool for textures and framebuffers\n */\nexport class RenderPool {\n private _objects: Array;\n /**\n * An index array of recently used pool objects.\n * Items that are used recently are last in the array\n */\n private _recentlyUsed: Array;\n private _stamp: number;\n\n constructor(\n private readonly _context: Context,\n private readonly _size: number,\n private readonly _tileSize: number) {\n this._objects = [];\n this._recentlyUsed = [];\n this._stamp = 0;\n }\n\n public destruct() {\n for (const obj of this._objects) {\n obj.texture.destroy();\n obj.fbo.destroy();\n }\n }\n\n private _createObject(id: number): PoolObject {\n const fbo = this._context.createFramebuffer(this._tileSize, this._tileSize, true, true);\n const texture = new Texture(this._context, {width: this._tileSize, height: this._tileSize, data: null}, this._context.gl.RGBA);\n texture.bind(this._context.gl.LINEAR, this._context.gl.CLAMP_TO_EDGE);\n fbo.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL, this._tileSize, this._tileSize));\n fbo.colorAttachment.set(texture.texture);\n return {id, fbo, texture, stamp: -1, inUse: false};\n }\n\n public getObjectForId(id: number): PoolObject {\n return this._objects[id];\n }\n\n public useObject(obj: PoolObject) {\n obj.inUse = true;\n this._recentlyUsed = this._recentlyUsed.filter(id => obj.id !== id);\n this._recentlyUsed.push(obj.id);\n }\n\n public stampObject(obj: PoolObject) {\n obj.stamp = ++this._stamp;\n }\n\n public getOrCreateFreeObject(): PoolObject {\n // check for free existing object\n for (const id of this._recentlyUsed) {\n if (!this._objects[id].inUse)\n return this._objects[id];\n }\n if (this._objects.length >= this._size)\n throw new Error('No free RenderPool available, call freeAllObjects() required!');\n // create new object\n const obj = this._createObject(this._objects.length);\n this._objects.push(obj);\n return obj;\n }\n\n public freeObject(obj: PoolObject) {\n obj.inUse = false;\n }\n\n public freeAllObjects() {\n for (const obj of this._objects)\n this.freeObject(obj);\n }\n\n public isFull(): boolean {\n if (this._objects.length < this._size) {\n return false;\n }\n return this._objects.some(o => !o.inUse) === false;\n }\n}\n","import {Painter} from './painter';\nimport {Tile} from '../source/tile';\nimport {Color} from '@maplibre/maplibre-gl-style-spec';\nimport {OverscaledTileID} from '../source/tile_id';\nimport {drawTerrain} from './draw_terrain';\nimport {Style} from '../style/style';\nimport {Terrain} from './terrain';\nimport {RenderPool} from '../gl/render_pool';\nimport {Texture} from './texture';\nimport type {StyleLayer} from '../style/style_layer';\n\n/**\n * lookup table which layers should rendered to texture\n */\nconst LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {\n background: true,\n fill: true,\n line: true,\n raster: true,\n hillshade: true\n};\n\n/**\n * @internal\n * A helper class to help define what should be rendered to texture and how\n */\nexport class RenderToTexture {\n painter: Painter;\n terrain: Terrain;\n pool: RenderPool;\n /**\n * coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile\n * e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile\n */\n _coordsDescendingInv: {[_: string]: {[_:string]: Array}};\n /**\n * create a string representation of all to tiles rendered to render-to-texture tiles\n * this string representation is used to check if tile should be re-rendered.\n */\n _coordsDescendingInvStr: {[_: string]: {[_:string]: string}};\n /**\n * store for render-stacks\n * a render stack is a set of layers which should be rendered into one texture\n * every stylesheet can have multiple stacks. A new stack is created if layers which should\n * not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols\n */\n _stacks: Array>;\n /**\n * remember the previous processed layer to check if a new stack is needed\n */\n _prevType: string;\n /**\n * a list of tiles that can potentially rendered\n */\n _renderableTiles: Array;\n /**\n * a list of tiles that should be rendered to screen in the next render-call\n */\n _rttTiles: Array;\n /**\n * a list of all layer-ids which should be rendered\n */\n _renderableLayerIds: Array;\n\n constructor(painter: Painter, terrain: Terrain) {\n this.painter = painter;\n this.terrain = terrain;\n this.pool = new RenderPool(painter.context, 30, terrain.sourceCache.tileSize * terrain.qualityFactor);\n }\n\n destruct() {\n this.pool.destruct();\n }\n\n getTexture(tile: Tile): Texture {\n return this.pool.getObjectForId(tile.rtt[this._stacks.length - 1].id).texture;\n }\n\n prepareForRender(style: Style, zoom: number) {\n this._stacks = [];\n this._prevType = null;\n this._rttTiles = [];\n this._renderableTiles = this.terrain.sourceCache.getRenderableTiles();\n this._renderableLayerIds = style._order.filter(id => !style._layers[id].isHidden(zoom));\n\n this._coordsDescendingInv = {};\n for (const id in style.sourceCaches) {\n this._coordsDescendingInv[id] = {};\n const tileIDs = style.sourceCaches[id].getVisibleCoordinates();\n for (const tileID of tileIDs) {\n const keys = this.terrain.sourceCache.getTerrainCoords(tileID);\n for (const key in keys) {\n if (!this._coordsDescendingInv[id][key]) this._coordsDescendingInv[id][key] = [];\n this._coordsDescendingInv[id][key].push(keys[key]);\n }\n }\n }\n\n this._coordsDescendingInvStr = {};\n for (const id of style._order) {\n const layer = style._layers[id], source = layer.source;\n if (LAYERS[layer.type]) {\n if (!this._coordsDescendingInvStr[source]) {\n this._coordsDescendingInvStr[source] = {};\n for (const key in this._coordsDescendingInv[source])\n this._coordsDescendingInvStr[source][key] = this._coordsDescendingInv[source][key].map(c => c.key).sort().join();\n }\n }\n }\n\n // check tiles to render\n for (const tile of this._renderableTiles) {\n for (const source in this._coordsDescendingInvStr) {\n // rerender if there are more coords to render than in the last rendering\n const coords = this._coordsDescendingInvStr[source][tile.tileID.key];\n if (coords && coords !== tile.rttCoords[source]) tile.rtt = [];\n }\n }\n }\n\n /**\n * due that switching textures is relatively slow, the render\n * layer-by-layer context is not practicable. To bypass this problem\n * this lines of code stack all layers and later render all at once.\n * Because of the stylesheet possibility to mixing render-to-texture layers\n * and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example\n * a symbol-layer is in between of fill-layers.\n * @param layer - the layer to render\n * @returns if true layer is rendered to texture, otherwise false\n */\n renderLayer(layer: StyleLayer): boolean {\n if (layer.isHidden(this.painter.transform.zoom)) return false;\n\n const type = layer.type;\n const painter = this.painter;\n const isLastLayer = this._renderableLayerIds[this._renderableLayerIds.length - 1] === layer.id;\n\n // remember background, fill, line & raster layer to render into a stack\n if (LAYERS[type]) {\n // create a new stack if previous layer was not rendered to texture (f.e. symbols)\n if (!this._prevType || !LAYERS[this._prevType]) this._stacks.push([]);\n // push current render-to-texture layer to render-stack\n this._prevType = type;\n this._stacks[this._stacks.length - 1].push(layer.id);\n // rendering is done later, all in once\n if (!isLastLayer) return true;\n }\n\n // in case a stack is finished render all collected stack-layers into a texture\n if (LAYERS[this._prevType] || (LAYERS[type] && isLastLayer)) {\n this._prevType = type;\n const stack = this._stacks.length - 1, layers = this._stacks[stack] || [];\n for (const tile of this._renderableTiles) {\n // if render pool is full draw current tiles to screen and free pool\n if (this.pool.isFull()) {\n drawTerrain(this.painter, this.terrain, this._rttTiles);\n this._rttTiles = [];\n this.pool.freeAllObjects();\n }\n this._rttTiles.push(tile);\n // check for cached PoolObject\n if (tile.rtt[stack]) {\n const obj = this.pool.getObjectForId(tile.rtt[stack].id);\n if (obj.stamp === tile.rtt[stack].stamp) {\n this.pool.useObject(obj);\n continue;\n }\n }\n // get free PoolObject\n const obj = this.pool.getOrCreateFreeObject();\n this.pool.useObject(obj);\n this.pool.stampObject(obj);\n tile.rtt[stack] = {id: obj.id, stamp: obj.stamp};\n // prepare PoolObject for rendering\n painter.context.bindFramebuffer.set(obj.fbo.framebuffer);\n painter.context.clear({color: Color.transparent, stencil: 0});\n painter.currentStencilSource = undefined;\n for (let l = 0; l < layers.length; l++) {\n const layer = painter.style._layers[layers[l]];\n const coords = layer.source ? this._coordsDescendingInv[layer.source][tile.tileID.key] : [tile.tileID];\n painter.context.viewport.set([0, 0, obj.fbo.width, obj.fbo.height]);\n painter._renderTileClippingMasks(layer, coords);\n painter.renderLayer(painter, painter.style.sourceCaches[layer.source], layer, coords);\n if (layer.source) tile.rttCoords[layer.source] = this._coordsDescendingInvStr[layer.source][tile.tileID.key];\n }\n }\n drawTerrain(this.painter, this.terrain, this._rttTiles);\n this._rttTiles = [];\n this.pool.freeAllObjects();\n\n return LAYERS[type];\n }\n\n return false;\n }\n\n}\n","import {extend, warnOnce, uniqueId, isImageBitmap} from '../util/util';\nimport {browser} from '../util/browser';\nimport {DOM} from '../util/dom';\nimport packageJSON from '../../package.json' assert {type: 'json'};\n\nimport {getJSON} from '../util/ajax';\nimport {ImageRequest} from '../util/image_request';\nimport type {GetImageCallback} from '../util/image_request';\n\nimport {RequestManager, ResourceType} from '../util/request_manager';\nimport {Style, StyleSwapOptions} from '../style/style';\nimport {EvaluationParameters} from '../style/evaluation_parameters';\nimport {Painter} from '../render/painter';\nimport {Transform} from '../geo/transform';\nimport {Hash} from './hash';\nimport {HandlerManager} from './handler_manager';\nimport {Camera, CameraOptions, CameraUpdateTransformFunction, FitBoundsOptions} from './camera';\nimport {LngLat} from '../geo/lng_lat';\nimport {LngLatBounds} from '../geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {AttributionControl} from './control/attribution_control';\nimport {LogoControl} from './control/logo_control';\n\nimport {RGBAImage} from '../util/image';\nimport {Event, ErrorEvent, Listener} from '../util/evented';\nimport {MapEventType, MapLayerEventType, MapMouseEvent, MapSourceDataEvent, MapStyleDataEvent} from './events';\nimport {TaskQueue} from '../util/task_queue';\nimport {throttle} from '../util/throttle';\nimport {webpSupported} from '../util/webp_supported';\nimport {PerformanceMarkers, PerformanceUtils} from '../util/performance';\nimport {Source, SourceClass} from '../source/source';\nimport {StyleLayer} from '../style/style_layer';\n\nimport type {RequestTransformFunction} from '../util/request_manager';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {LngLatBoundsLike} from '../geo/lng_lat_bounds';\nimport type {AddLayerObject, FeatureIdentifier, StyleOptions, StyleSetterOptions} from '../style/style';\nimport type {MapDataEvent} from './events';\nimport type {StyleImage, StyleImageInterface, StyleImageMetadata} from '../style/style_image';\nimport type {PointLike} from './camera';\nimport type {ScrollZoomHandler} from './handler/scroll_zoom';\nimport type {BoxZoomHandler} from './handler/box_zoom';\nimport type {AroundCenterOptions, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch';\nimport type {DragRotateHandler} from './handler/shim/drag_rotate';\nimport {DragPanHandler, DragPanOptions} from './handler/shim/drag_pan';\n\nimport type {KeyboardHandler} from './handler/keyboard';\nimport type {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom';\nimport type {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch';\nimport {defaultLocale} from './default_locale';\nimport type {TaskID} from '../util/task_queue';\nimport type {Cancelable} from '../types/cancelable';\nimport type {\n FilterSpecification,\n StyleSpecification,\n LightSpecification,\n SourceSpecification,\n TerrainSpecification\n} from '@maplibre/maplibre-gl-style-spec';\n\nimport {Callback} from '../types/callback';\nimport type {ControlPosition, IControl} from './control/control';\nimport type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';\nimport {Terrain} from '../render/terrain';\nimport {RenderToTexture} from '../render/render_to_texture';\nimport {config} from '../util/config';\nimport type {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions} from '../source/query_features';\n\nconst version = packageJSON.version;\n\n/**\n * The {@link Map} options object.\n */\nexport type MapOptions = {\n /**\n * If `true`, the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL.\n * For example, `http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60`.\n * An additional string may optionally be provided to indicate a parameter-styled hash,\n * e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar, where foo\n * is a custom parameter and bar is an arbitrary hash distinct from the map hash.\n * @defaultValue false\n */\n hash?: boolean | string;\n /**\n * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.\n * @defaultValue true\n */\n interactive?: boolean;\n /**\n * The HTML element in which MapLibre GL JS will render the map, or the element's string `id`. The specified element must have no children.\n */\n container: HTMLElement | string;\n /**\n * The threshold, measured in degrees, that determines when the map's\n * bearing will snap to north. For example, with a `bearingSnap` of 7, if the user rotates\n * the map within 7 degrees of north, the map will automatically snap to exact north.\n * @defaultValue 7\n */\n bearingSnap?: number;\n /**\n * If `true`, an {@link AttributionControl} will be added to the map.\n * @defaultValue true\n */\n attributionControl?: boolean;\n /**\n * Attribution text to show in an {@link AttributionControl}. Only applicable if `options.attributionControl` is `true`.\n */\n customAttribution?: string | Array;\n /**\n * If `true`, the MapLibre logo will be shown.\n * @defaultValue false\n */\n maplibreLogo?: boolean;\n /**\n * A string representing the position of the MapLibre wordmark on the map. Valid options are `top-left`,`top-right`, `bottom-left`, or `bottom-right`.\n * @defaultValue 'bottom-left'\n */\n logoPosition?: ControlPosition;\n /**\n * If `true`, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected\n * (i.e. a software renderer would be used).\n * @defaultValue false\n */\n failIfMajorPerformanceCaveat?: boolean;\n /**\n * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization.\n * @defaultValue false\n */\n preserveDrawingBuffer?: boolean;\n /**\n * If `true`, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. This is `false` by default as a performance optimization.\n */\n antialias?: boolean;\n /**\n * If `false`, the map won't attempt to re-request tiles once they expire per their HTTP `cacheControl`/`expires` headers.\n * @defaultValue true\n */\n refreshExpiredTiles?: boolean;\n /**\n * If set, the map will be constrained to the given bounds.\n */\n maxBounds?: LngLatBoundsLike;\n /**\n * If `true`, the \"scroll to zoom\" interaction is enabled. {@link AroundCenterOptions} are passed as options to {@link ScrollZoomHandler#enable}.\n * @defaultValue true\n */\n scrollZoom?: boolean | AroundCenterOptions;\n /**\n * The minimum zoom level of the map (0-24).\n * @defaultValue 0\n */\n minZoom?: number | null;\n /**\n * The maximum zoom level of the map (0-24).\n * @defaultValue 22\n */\n maxZoom?: number | null;\n /**\n * The minimum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 0\n */\n minPitch?: number | null;\n /**\n * The maximum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 60\n */\n maxPitch?: number | null;\n /**\n * If `true`, the \"box zoom\" interaction is enabled (see {@link BoxZoomHandler}).\n * @defaultValue true\n */\n boxZoom?: boolean;\n /**\n * If `true`, the \"drag to rotate\" interaction is enabled (see {@link DragRotateHandler}).\n * @defaultValue true\n */\n dragRotate?: boolean;\n /**\n * If `true`, the \"drag to pan\" interaction is enabled. An `Object` value is passed as options to {@link DragPanHandler#enable}.\n * @defaultValue true\n */\n dragPan?: boolean | DragPanOptions;\n /**\n * If `true`, keyboard shortcuts are enabled (see {@link KeyboardHandler}).\n * @defaultValue true\n */\n keyboard?: boolean;\n /**\n * If `true`, the \"double click to zoom\" interaction is enabled (see {@link DoubleClickZoomHandler}).\n * @defaultValue true\n */\n doubleClickZoom?: boolean;\n /**\n * If `true`, the \"pinch to rotate and zoom\" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchZoomRotateHandler#enable}.\n * @defaultValue true\n */\n touchZoomRotate?: boolean | AroundCenterOptions;\n /**\n * If `true`, the \"drag to pitch\" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchPitchHandler#enable}.\n * @defaultValue true\n */\n touchPitch?: boolean | AroundCenterOptions;\n /**\n * If `true` or set to an options object, the map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, \"drag to pitch\" requires a three-finger gesture. Cooperative gestures are disabled when a map enters fullscreen using {@link FullscreenControl}.\n * @defaultValue undefined\n */\n cooperativeGestures?: boolean | GestureOptions;\n /**\n * If `true`, the map will automatically resize when the browser window resizes.\n * @defaultValue true\n */\n trackResize?: boolean;\n /**\n * The initial geographical centerpoint of the map. If `center` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.\n * @defaultValue [0, 0]\n */\n center?: LngLatLike;\n /**\n * The initial zoom level of the map. If `zoom` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.\n * @defaultValue 0\n */\n zoom?: number;\n /**\n * The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If `bearing` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.\n * @defaultValue 0\n */\n bearing?: number;\n /**\n * The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If `pitch` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * @defaultValue 0\n */\n pitch?: number;\n /**\n * If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n * @defaultValue true\n */\n renderWorldCopies?: boolean;\n /**\n * The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport which can be set using `maxTileCacheZoomLevels` constructor options.\n * @defaultValue null\n */\n maxTileCacheSize?: number;\n /**\n * The maximum number of zoom levels for which to store tiles for a given source. Tile cache dynamic size is calculated by multiplying `maxTileCacheZoomLevels` with the approximate number of tiles in the viewport for a given source.\n * @defaultValue 5\n */\n maxTileCacheZoomLevels?: number;\n /**\n * A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.\n * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties.\n */\n transformRequest?: RequestTransformFunction;\n /**\n * A callback run before the map's camera is moved due to user input or animation. The callback can be used to modify the new center, zoom, pitch and bearing.\n * Expected to return an object containing center, zoom, pitch or bearing values to overwrite.\n */\n transformCameraUpdate?: CameraUpdateTransformFunction;\n /**\n * A patch to apply to the default localization table for UI strings, e.g. control tooltips. The `locale` object maps namespaced UI string IDs to translated strings in the target language; see `src/ui/default_locale.js` for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table).\n * @defaultValue null\n */\n locale?: any;\n /**\n * Controls the duration of the fade-in/fade-out animation for label collisions after initial map load, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading.\n * @defaultValue 300\n */\n fadeDuration?: number;\n /**\n * If `true`, symbols from multiple sources can collide with each other during collision detection. If `false`, collision detection is run separately for the symbols in each source.\n * @defaultValue true\n */\n crossSourceCollisions?: boolean;\n /**\n * If `true`, Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers (this information is normally inaccessible from the main Javascript thread). Information will be returned in a `resourceTiming` property of relevant `data` events.\n * @defaultValue false\n */\n collectResourceTiming?: boolean;\n /**\n * The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag).\n * @defaultValue true\n */\n clickTolerance?: number;\n /**\n * The initial bounds of the map. If `bounds` is specified, it overrides `center` and `zoom` constructor options.\n */\n bounds?: LngLatBoundsLike;\n /**\n * A {@link FitBoundsOptions} options object to use _only_ when fitting the initial `bounds` provided above.\n */\n fitBoundsOptions?: FitBoundsOptions;\n /**\n * Defines a CSS\n * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges.\n * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).\n * Set to `false`, to enable font settings from the map's style for these glyph ranges.\n * The purpose of this option is to avoid bandwidth-intensive glyph server requests. (See [Use locally generated ideographs](https://maplibre.org/maplibre-gl-js/docs/examples/local-ideographs).)\n * @defaultValue 'sans-serif'\n */\n localIdeographFontFamily?: string;\n /**\n * The map's MapLibre style. This must be a JSON object conforming to\n * the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/),\n * or a URL to such JSON.\n */\n style: StyleSpecification | string;\n /**\n * If `false`, the map's pitch (tilt) control with \"drag to rotate\" interaction will be disabled.\n * @defaultValue true\n */\n pitchWithRotate?: boolean;\n /**\n * The pixel ratio. The canvas' `width` attribute will be `container.clientWidth * pixelRatio` and its `height` attribute will be `container.clientHeight * pixelRatio`. Defaults to `devicePixelRatio` if not specified.\n */\n pixelRatio?: number;\n /**\n * If false, style validation will be skipped. Useful in production environment.\n * @defaultValue true\n */\n validateStyle?: boolean;\n /**\n * The canvas' `width` and `height` max size. The values are passed as an array where the first element is max width and the second element is max height.\n * You shouldn't set this above WebGl `MAX_TEXTURE_SIZE`. Defaults to [4096, 4096].\n */\n maxCanvasSize?: [number, number];\n};\n\n/**\n * An options object for the gesture settings\n * @example\n * ```ts\n * let options = {\n * windowsHelpText: \"Use Ctrl + scroll to zoom the map\",\n * macHelpText: \"Use ⌘ + scroll to zoom the map\",\n * mobileHelpText: \"Use two fingers to move the map\",\n * }\n * ```\n */\nexport type GestureOptions = {\n windowsHelpText?: string;\n macHelpText?: string;\n mobileHelpText?: string;\n};\n\nexport type AddImageOptions = {\n\n}\n\n// See article here: https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585\ntype Complete = {\n [P in keyof Required]: Pick extends Required> ? T[P] : (T[P] | undefined);\n}\n\n// This type is used inside map since all properties are assigned a default value.\nexport type CompleteMapOptions = Complete;\n\nconst defaultMinZoom = -2;\nconst defaultMaxZoom = 22;\n\n// the default values, but also the valid range\nconst defaultMinPitch = 0;\nconst defaultMaxPitch = 60;\n\n// use this variable to check maxPitch for validity\nconst maxPitchThreshold = 85;\n\nconst defaultOptions = {\n center: [0, 0],\n zoom: 0,\n bearing: 0,\n pitch: 0,\n\n minZoom: defaultMinZoom,\n maxZoom: defaultMaxZoom,\n\n minPitch: defaultMinPitch,\n maxPitch: defaultMaxPitch,\n\n interactive: true,\n scrollZoom: true,\n boxZoom: true,\n dragRotate: true,\n dragPan: true,\n keyboard: true,\n doubleClickZoom: true,\n touchZoomRotate: true,\n touchPitch: true,\n cooperativeGestures: undefined,\n\n bearingSnap: 7,\n clickTolerance: 3,\n pitchWithRotate: true,\n\n hash: false,\n attributionControl: true,\n maplibreLogo: false,\n\n failIfMajorPerformanceCaveat: false,\n preserveDrawingBuffer: false,\n trackResize: true,\n renderWorldCopies: true,\n refreshExpiredTiles: true,\n maxTileCacheSize: null,\n maxTileCacheZoomLevels: config.MAX_TILE_CACHE_ZOOM_LEVELS,\n localIdeographFontFamily: 'sans-serif',\n transformRequest: null,\n transformCameraUpdate: null,\n fadeDuration: 300,\n crossSourceCollisions: true,\n validateStyle: true,\n /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */\n maxCanvasSize: [4096, 4096]\n} as CompleteMapOptions;\n\n/**\n * The `Map` object represents the map on your page. It exposes methods\n * and properties that enable you to programmatically change the map,\n * and fires events as users interact with it.\n *\n * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list.\n * Then MapLibre GL JS initializes the map on the page and returns your `Map` object.\n *\n * @group Main\n *\n * @example\n * ```ts\n * let map = new maplibregl.Map({\n * container: 'map',\n * center: [-122.420679, 37.772537],\n * zoom: 13,\n * style: style_object,\n * hash: true,\n * transformRequest: (url, resourceType)=> {\n * if(resourceType === 'Source' && url.startsWith('http://myHost')) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true},\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * });\n * ```\n * @see [Display a map](https://maplibre.org/maplibre-gl-js/docs/examples/simple-map/)\n */\nexport class Map extends Camera {\n style: Style;\n painter: Painter;\n handlers: HandlerManager;\n\n _container: HTMLElement;\n _canvasContainer: HTMLElement;\n _controlContainer: HTMLElement;\n _controlPositions: {[_: string]: HTMLElement};\n _interactive: boolean;\n _cooperativeGestures: boolean | GestureOptions;\n _cooperativeGesturesScreen: HTMLElement;\n _metaKey: keyof MouseEvent;\n _showTileBoundaries: boolean;\n _showCollisionBoxes: boolean;\n _showPadding: boolean;\n _showOverdrawInspector: boolean;\n _repaint: boolean;\n _vertices: boolean;\n _canvas: HTMLCanvasElement;\n _maxTileCacheSize: number;\n _maxTileCacheZoomLevels: number;\n _frame: Cancelable;\n _styleDirty: boolean;\n _sourcesDirty: boolean;\n _placementDirty: boolean;\n\n _loaded: boolean;\n _idleTriggered: boolean;\n // accounts for placement finishing as well\n _fullyLoaded: boolean;\n _trackResize: boolean;\n _resizeObserver: ResizeObserver;\n _preserveDrawingBuffer: boolean;\n _failIfMajorPerformanceCaveat: boolean;\n _antialias: boolean;\n _refreshExpiredTiles: boolean;\n _hash: Hash;\n _delegatedListeners: any;\n _fadeDuration: number;\n _crossSourceCollisions: boolean;\n _crossFadingFactor: number;\n _collectResourceTiming: boolean;\n _renderTaskQueue: TaskQueue;\n _controls: Array;\n _mapId: number;\n _localIdeographFontFamily: string;\n _validateStyle: boolean;\n _requestManager: RequestManager;\n _locale: any;\n _removed: boolean;\n _clickTolerance: number;\n _overridePixelRatio: number | null;\n _maxCanvasSize: [number, number];\n _terrainDataCallback: (e: MapStyleDataEvent | MapSourceDataEvent) => void;\n\n /**\n * @internal\n * image queue throttling handle. To be used later when clean up\n */\n _imageQueueHandle: number;\n\n /**\n * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.\n * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.\n */\n scrollZoom: ScrollZoomHandler;\n\n /**\n * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed.\n * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section.\n */\n boxZoom: BoxZoomHandler;\n\n /**\n * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right\n * mouse button or with the Control key pressed. Find more details and examples using `dragRotate`\n * in the {@link DragRotateHandler} section.\n */\n dragRotate: DragRotateHandler;\n\n /**\n * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture.\n * Find more details and examples using `dragPan` in the {@link DragPanHandler} section.\n */\n dragPan: DragPanHandler;\n\n /**\n * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard\n * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section.\n */\n keyboard: KeyboardHandler;\n\n /**\n * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking.\n * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section.\n */\n doubleClickZoom: DoubleClickZoomHandler;\n\n /**\n * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures.\n * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section.\n */\n touchZoomRotate: TwoFingersTouchZoomRotateHandler;\n\n /**\n * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures.\n * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section.\n */\n touchPitch: TwoFingersTouchPitchHandler;\n\n constructor(options: MapOptions) {\n PerformanceUtils.mark(PerformanceMarkers.create);\n\n options = extend({}, defaultOptions, options);\n\n if (options.minZoom != null && options.maxZoom != null && options.minZoom > options.maxZoom) {\n throw new Error('maxZoom must be greater than or equal to minZoom');\n }\n\n if (options.minPitch != null && options.maxPitch != null && options.minPitch > options.maxPitch) {\n throw new Error('maxPitch must be greater than or equal to minPitch');\n }\n\n if (options.minPitch != null && options.minPitch < defaultMinPitch) {\n throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);\n }\n\n if (options.maxPitch != null && options.maxPitch > maxPitchThreshold) {\n throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);\n }\n\n const transform = new Transform(options.minZoom, options.maxZoom, options.minPitch, options.maxPitch, options.renderWorldCopies);\n super(transform, {bearingSnap: options.bearingSnap});\n\n this._interactive = options.interactive;\n this._cooperativeGestures = options.cooperativeGestures;\n this._metaKey = navigator.platform.indexOf('Mac') === 0 ? 'metaKey' : 'ctrlKey';\n this._maxTileCacheSize = options.maxTileCacheSize;\n this._maxTileCacheZoomLevels = options.maxTileCacheZoomLevels;\n this._failIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat;\n this._preserveDrawingBuffer = options.preserveDrawingBuffer;\n this._antialias = options.antialias;\n this._trackResize = options.trackResize;\n this._bearingSnap = options.bearingSnap;\n this._refreshExpiredTiles = options.refreshExpiredTiles;\n this._fadeDuration = options.fadeDuration;\n this._crossSourceCollisions = options.crossSourceCollisions;\n this._crossFadingFactor = 1;\n this._collectResourceTiming = options.collectResourceTiming;\n this._renderTaskQueue = new TaskQueue();\n this._controls = [];\n this._mapId = uniqueId();\n this._locale = extend({}, defaultLocale, options.locale);\n this._clickTolerance = options.clickTolerance;\n this._overridePixelRatio = options.pixelRatio;\n this._maxCanvasSize = options.maxCanvasSize;\n this.transformCameraUpdate = options.transformCameraUpdate;\n\n this._imageQueueHandle = ImageRequest.addThrottleControl(() => this.isMoving());\n\n this._requestManager = new RequestManager(options.transformRequest);\n\n if (typeof options.container === 'string') {\n this._container = document.getElementById(options.container);\n if (!this._container) {\n throw new Error(`Container '${options.container}' not found.`);\n }\n } else if (options.container instanceof HTMLElement) {\n this._container = options.container;\n } else {\n throw new Error('Invalid type: \\'container\\' must be a String or HTMLElement.');\n }\n\n if (options.maxBounds) {\n this.setMaxBounds(options.maxBounds);\n }\n\n this._setupContainer();\n this._setupPainter();\n\n this.on('move', () => this._update(false));\n this.on('moveend', () => this._update(false));\n this.on('zoom', () => this._update(true));\n this.on('terrain', () => {\n this.painter.terrainFacilitator.dirty = true;\n this._update(true);\n });\n this.once('idle', () => { this._idleTriggered = true; });\n\n if (typeof window !== 'undefined') {\n addEventListener('online', this._onWindowOnline, false);\n let initialResizeEventCaptured = false;\n const throttledResizeCallback = throttle((entries: ResizeObserverEntry[]) => {\n if (this._trackResize && !this._removed) {\n this.resize(entries)._update();\n }\n }, 50);\n this._resizeObserver = new ResizeObserver((entries) => {\n if (!initialResizeEventCaptured) {\n initialResizeEventCaptured = true;\n return;\n }\n throttledResizeCallback(entries);\n });\n this._resizeObserver.observe(this._container);\n }\n\n this.handlers = new HandlerManager(this, options as CompleteMapOptions);\n\n if (this._cooperativeGestures) {\n this._setupCooperativeGestures();\n }\n\n const hashName = (typeof options.hash === 'string' && options.hash) || undefined;\n this._hash = options.hash && (new Hash(hashName)).addTo(this);\n // don't set position from options if set through hash\n if (!this._hash || !this._hash._onHashChange()) {\n this.jumpTo({\n center: options.center,\n zoom: options.zoom,\n bearing: options.bearing,\n pitch: options.pitch\n });\n\n if (options.bounds) {\n this.resize();\n this.fitBounds(options.bounds, extend({}, options.fitBoundsOptions, {duration: 0}));\n }\n }\n\n this.resize();\n\n this._localIdeographFontFamily = options.localIdeographFontFamily;\n this._validateStyle = options.validateStyle;\n\n if (options.style) this.setStyle(options.style, {localIdeographFontFamily: options.localIdeographFontFamily});\n\n if (options.attributionControl)\n this.addControl(new AttributionControl({customAttribution: options.customAttribution}));\n\n if (options.maplibreLogo)\n this.addControl(new LogoControl(), options.logoPosition);\n\n this.on('style.load', () => {\n if (this.transform.unmodified) {\n this.jumpTo(this.style.stylesheet as any);\n }\n });\n this.on('data', (event: MapDataEvent) => {\n this._update(event.dataType === 'style');\n this.fire(new Event(`${event.dataType}data`, event));\n });\n this.on('dataloading', (event: MapDataEvent) => {\n this.fire(new Event(`${event.dataType}dataloading`, event));\n });\n this.on('dataabort', (event: MapDataEvent) => {\n this.fire(new Event('sourcedataabort', event));\n });\n }\n\n /**\n * @internal\n * Returns a unique number for this map instance which is used for the MapLoadEvent\n * to make sure we only fire one event per instantiated map object.\n * @returns the uniq map ID\n */\n _getMapId() {\n return this._mapId;\n }\n\n /**\n * Adds an {@link IControl} to the map, calling `control.onAdd(this)`.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param control - The {@link IControl} to add.\n * @param position - position on the map to which the control will be added.\n * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`.\n * @returns `this`\n * @example\n * Add zoom and rotation controls to the map.\n * ```ts\n * map.addControl(new maplibregl.NavigationControl());\n * ```\n * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)\n */\n addControl(control: IControl, position?: ControlPosition): Map {\n if (position === undefined) {\n if (control.getDefaultPosition) {\n position = control.getDefaultPosition();\n } else {\n position = 'top-right';\n }\n }\n if (!control || !control.onAdd) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.')));\n }\n const controlElement = control.onAdd(this);\n this._controls.push(control);\n\n const positionContainer = this._controlPositions[position];\n if (position.indexOf('bottom') !== -1) {\n positionContainer.insertBefore(controlElement, positionContainer.firstChild);\n } else {\n positionContainer.appendChild(controlElement);\n }\n return this;\n }\n\n /**\n * Removes the control from the map.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param control - The {@link IControl} to remove.\n * @returns `this`\n * @example\n * ```ts\n * // Define a new navigation control.\n * let navigation = new maplibregl.NavigationControl();\n * // Add zoom and rotation controls to the map.\n * map.addControl(navigation);\n * // Remove zoom and rotation controls from the map.\n * map.removeControl(navigation);\n * ```\n */\n removeControl(control: IControl): Map {\n if (!control || !control.onRemove) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.')));\n }\n const ci = this._controls.indexOf(control);\n if (ci > -1) this._controls.splice(ci, 1);\n control.onRemove(this);\n return this;\n }\n\n /**\n * Checks if a control exists on the map.\n *\n * @param control - The {@link IControl} to check.\n * @returns true if map contains control.\n * @example\n * ```ts\n * // Define a new navigation control.\n * let navigation = new maplibregl.NavigationControl();\n * // Add zoom and rotation controls to the map.\n * map.addControl(navigation);\n * // Check that the navigation control exists on the map.\n * map.hasControl(navigation);\n * ```\n */\n hasControl(control: IControl): boolean {\n return this._controls.indexOf(control) > -1;\n }\n\n calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions {\n if (altitudeTo == null && this.terrain) {\n altitudeTo = this.terrain.getElevationForLngLatZoom(to, this.transform.tileZoom);\n }\n return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo);\n }\n\n /**\n * Resizes the map according to the dimensions of its\n * `container` element.\n *\n * Checks if the map container size changed and updates the map if it has changed.\n * This method must be called after the map's `container` is resized programmatically\n * or when the map is shown after being initially hidden with CSS.\n *\n * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`.\n *\n * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend`\n * events that get triggered as a result of resize. This can be useful for differentiating the\n * source of an event (for example, user-initiated or programmatically-triggered events).\n * @returns `this`\n * @example\n * Resize the map when the map container is shown after being initially hidden with CSS.\n * ```ts\n * let mapDiv = document.getElementById('map');\n * if (mapDiv.style.visibility === true) map.resize();\n * ```\n */\n resize(eventData?: any): Map {\n const dimensions = this._containerDimensions();\n const width = dimensions[0];\n const height = dimensions[1];\n\n const clampedPixelRatio = this._getClampedPixelRatio(width, height);\n this._resizeCanvas(width, height, clampedPixelRatio);\n this.painter.resize(width, height, clampedPixelRatio);\n\n // check if we've reached GL limits, in that case further clamps pixelRatio\n if (this.painter.overLimit()) {\n const gl = this.painter.context.gl;\n // store updated _maxCanvasSize value\n this._maxCanvasSize = [gl.drawingBufferWidth, gl.drawingBufferHeight];\n const clampedPixelRatio = this._getClampedPixelRatio(width, height);\n this._resizeCanvas(width, height, clampedPixelRatio);\n this.painter.resize(width, height, clampedPixelRatio);\n }\n\n this.transform.resize(width, height);\n this._requestedCameraState?.resize(width, height);\n\n const fireMoving = !this._moving;\n if (fireMoving) {\n this.stop();\n this.fire(new Event('movestart', eventData))\n .fire(new Event('move', eventData));\n }\n\n this.fire(new Event('resize', eventData));\n\n if (fireMoving) this.fire(new Event('moveend', eventData));\n\n return this;\n }\n\n /**\n * @internal\n * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize.\n * Internally you should use this and not getPixelRatio().\n */\n _getClampedPixelRatio(width: number, height: number): number {\n const {0: maxCanvasWidth, 1: maxCanvasHeight} = this._maxCanvasSize;\n const pixelRatio = this.getPixelRatio();\n\n const canvasWidth = width * pixelRatio;\n const canvasHeight = height * pixelRatio;\n\n const widthScaleFactor = canvasWidth > maxCanvasWidth ? (maxCanvasWidth / canvasWidth) : 1;\n const heightScaleFactor = canvasHeight > maxCanvasHeight ? (maxCanvasHeight / canvasHeight) : 1;\n\n return Math.min(widthScaleFactor, heightScaleFactor) * pixelRatio;\n }\n\n /**\n * Returns the map's pixel ratio.\n * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.\n * @returns The pixel ratio.\n */\n getPixelRatio(): number {\n return this._overridePixelRatio ?? devicePixelRatio;\n }\n\n /**\n * Sets the map's pixel ratio. This allows to override `devicePixelRatio`.\n * After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio`\n * and its height attribute will be `container.clientHeight * pixelRatio`.\n * Set this to null to disable `devicePixelRatio` override.\n * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.\n * @param pixelRatio - The pixel ratio.\n */\n setPixelRatio(pixelRatio: number) {\n this._overridePixelRatio = pixelRatio;\n this.resize();\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns The geographical bounds of the map as {@link LngLatBounds}.\n * @example\n * ```ts\n * let bounds = map.getBounds();\n * ```\n */\n getBounds(): LngLatBounds {\n return this.transform.getBounds();\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns The map object.\n * @example\n * ```ts\n * let maxBounds = map.getMaxBounds();\n * ```\n */\n getMaxBounds(): LngLatBounds | null {\n return this.transform.getMaxBounds();\n }\n\n /**\n * Sets or clears the map's geographical bounds.\n *\n * Pan and zoom operations are constrained within these bounds.\n * If a pan or zoom is performed that would\n * display regions outside these bounds, the map will\n * instead display a position and zoom level\n * as close as possible to the operation's request while still\n * remaining within the bounds.\n *\n * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds.\n * @returns `this`\n * @example\n * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds.\n * ```ts\n * let bounds = [\n * [-74.04728, 40.68392], // [west, south]\n * [-73.91058, 40.87764] // [east, north]\n * ];\n * map.setMaxBounds(bounds);\n * ```\n */\n setMaxBounds(bounds?: LngLatBoundsLike | null): Map {\n this.transform.setMaxBounds(LngLatBounds.convert(bounds));\n return this._update();\n }\n\n /**\n * Sets or clears the map's minimum zoom level.\n * If the map's current zoom level is lower than the new minimum,\n * the map will zoom to the new minimum.\n *\n * It is not always possible to zoom out and reach the set `minZoom`.\n * Other factors such as map height may restrict zooming. For example,\n * if the map is 512px tall it will not be possible to zoom below zoom 0\n * no matter what the `minZoom` is set to.\n *\n * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.\n *\n * @param minZoom - The minimum zoom level to set (-2 - 24).\n * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2).\n * @returns `this`\n * @example\n * ```ts\n * map.setMinZoom(12.25);\n * ```\n */\n setMinZoom(minZoom?: number | null): Map {\n\n minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;\n\n if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {\n this.transform.minZoom = minZoom;\n this._update();\n\n if (this.getZoom() < minZoom) this.setZoom(minZoom);\n\n return this;\n\n } else throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);\n }\n\n /**\n * Returns the map's minimum allowable zoom level.\n *\n * @returns minZoom\n * @example\n * ```ts\n * let minZoom = map.getMinZoom();\n * ```\n */\n getMinZoom(): number { return this.transform.minZoom; }\n\n /**\n * Sets or clears the map's maximum zoom level.\n * If the map's current zoom level is higher than the new maximum,\n * the map will zoom to the new maximum.\n *\n * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.\n *\n * @param maxZoom - The maximum zoom level to set.\n * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).\n * @returns `this`\n * @example\n * ```ts\n * map.setMaxZoom(18.75);\n * ```\n */\n setMaxZoom(maxZoom?: number | null): Map {\n\n maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;\n\n if (maxZoom >= this.transform.minZoom) {\n this.transform.maxZoom = maxZoom;\n this._update();\n\n if (this.getZoom() > maxZoom) this.setZoom(maxZoom);\n\n return this;\n\n } else throw new Error('maxZoom must be greater than the current minZoom');\n }\n\n /**\n * Returns the map's maximum allowable zoom level.\n *\n * @returns The maxZoom\n * @example\n * ```ts\n * let maxZoom = map.getMaxZoom();\n * ```\n */\n getMaxZoom(): number { return this.transform.maxZoom; }\n\n /**\n * Sets or clears the map's minimum pitch.\n * If the map's current pitch is lower than the new minimum,\n * the map will pitch to the new minimum.\n *\n * A {@link ErrorEvent} event will be fired if minPitch is out of bounds.\n *\n * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0).\n * @returns `this`\n */\n setMinPitch(minPitch?: number | null): Map {\n\n minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;\n\n if (minPitch < defaultMinPitch) {\n throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);\n }\n\n if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {\n this.transform.minPitch = minPitch;\n this._update();\n\n if (this.getPitch() < minPitch) this.setPitch(minPitch);\n\n return this;\n\n } else throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);\n }\n\n /**\n * Returns the map's minimum allowable pitch.\n *\n * @returns The minPitch\n */\n getMinPitch(): number { return this.transform.minPitch; }\n\n /**\n * Sets or clears the map's maximum pitch.\n * If the map's current pitch is higher than the new maximum,\n * the map will pitch to the new maximum.\n *\n * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds.\n *\n * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.\n * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60).\n * @returns `this`\n */\n setMaxPitch(maxPitch?: number | null): Map {\n\n maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;\n\n if (maxPitch > maxPitchThreshold) {\n throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);\n }\n\n if (maxPitch >= this.transform.minPitch) {\n this.transform.maxPitch = maxPitch;\n this._update();\n\n if (this.getPitch() > maxPitch) this.setPitch(maxPitch);\n\n return this;\n\n } else throw new Error('maxPitch must be greater than the current minPitch');\n }\n\n /**\n * Returns the map's maximum allowable pitch.\n *\n * @returns The maxPitch\n */\n getMaxPitch(): number { return this.transform.maxPitch; }\n\n /**\n * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n * @returns The renderWorldCopies\n * @example\n * ```ts\n * let worldCopiesRendered = map.getRenderWorldCopies();\n * ```\n * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)\n */\n getRenderWorldCopies(): boolean { return this.transform.renderWorldCopies; }\n\n /**\n * Sets the state of `renderWorldCopies`.\n *\n * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:\n * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire\n * container, there will be blank space beyond 180 and -180 degrees longitude.\n * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the\n * map and the other on the left edge of the map) at every zoom level.\n *\n * `undefined` is treated as `true`, `null` is treated as `false`.\n * @returns `this`\n * @example\n * ```ts\n * map.setRenderWorldCopies(true);\n * ```\n * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)\n */\n setRenderWorldCopies(renderWorldCopies?: boolean | null): Map {\n this.transform.renderWorldCopies = renderWorldCopies;\n return this._update();\n }\n\n /**\n * Gets the map's cooperativeGestures option\n *\n * @returns The gestureOptions\n */\n getCooperativeGestures(): boolean | GestureOptions {\n return this._cooperativeGestures;\n }\n\n /**\n * Sets or clears the map's cooperativeGestures option\n *\n * @param gestureOptions - If `true` or set to an options object, map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, \"drag to pitch\" requires a three-finger gesture.\n * @returns `this`\n */\n setCooperativeGestures(gestureOptions?: GestureOptions | boolean | null): Map {\n this._cooperativeGestures = gestureOptions;\n if (this._cooperativeGestures) {\n this._setupCooperativeGestures();\n } else {\n this._destroyCooperativeGestures();\n }\n\n return this;\n }\n\n /**\n * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`,\n * that correspond to the specified geographical location.\n *\n * @param lnglat - The geographical location to project.\n * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`.\n * @example\n * ```ts\n * let coordinate = [-122.420679, 37.772537];\n * let point = map.project(coordinate);\n * ```\n */\n project(lnglat: LngLatLike): Point {\n return this.transform.locationPoint(LngLat.convert(lnglat), this.style && this.terrain);\n }\n\n /**\n * Returns a {@link LngLat} representing geographical coordinates that correspond\n * to the specified pixel coordinates.\n *\n * @param point - The pixel coordinates to unproject.\n * @returns The {@link LngLat} corresponding to `point`.\n * @example\n * ```ts\n * map.on('click', function(e) {\n * // When the map is clicked, get the geographic coordinate.\n * let coordinate = map.unproject(e.point);\n * });\n * ```\n */\n unproject(point: PointLike): LngLat {\n return this.transform.pointLocation(Point.convert(point), this.terrain);\n }\n\n /**\n * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.\n * @returns true if the map is moving.\n * @example\n * ```ts\n * let isMoving = map.isMoving();\n * ```\n */\n isMoving(): boolean {\n return this._moving || this.handlers?.isMoving();\n }\n\n /**\n * Returns true if the map is zooming due to a camera animation or user gesture.\n * @returns true if the map is zooming.\n * @example\n * ```ts\n * let isZooming = map.isZooming();\n * ```\n */\n isZooming(): boolean {\n return this._zooming || this.handlers?.isZooming();\n }\n\n /**\n * Returns true if the map is rotating due to a camera animation or user gesture.\n * @returns true if the map is rotating.\n * @example\n * ```ts\n * map.isRotating();\n * ```\n */\n isRotating(): boolean {\n return this._rotating || this.handlers?.isRotating();\n }\n\n _createDelegatedListener(type: keyof MapEventType | string, layerId: string, listener: Listener): {\n layer: string;\n listener: Listener;\n delegates: {[type in keyof MapEventType]?: (e: any) => void};\n } {\n if (type === 'mouseenter' || type === 'mouseover') {\n let mousein = false;\n const mousemove = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (!features.length) {\n mousein = false;\n } else if (!mousein) {\n mousein = true;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent, {features}));\n }\n };\n const mouseout = () => {\n mousein = false;\n };\n return {layer: layerId, listener, delegates: {mousemove, mouseout}};\n } else if (type === 'mouseleave' || type === 'mouseout') {\n let mousein = false;\n const mousemove = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (features.length) {\n mousein = true;\n } else if (mousein) {\n mousein = false;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent));\n }\n };\n const mouseout = (e) => {\n if (mousein) {\n mousein = false;\n listener.call(this, new MapMouseEvent(type, this, e.originalEvent));\n }\n };\n return {layer: layerId, listener, delegates: {mousemove, mouseout}};\n } else {\n const delegate = (e) => {\n const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : [];\n if (features.length) {\n // Here we need to mutate the original event, so that preventDefault works as expected.\n e.features = features;\n listener.call(this, e);\n delete e.features;\n }\n };\n return {layer: layerId, listener, delegates: {[type]: delegate}};\n }\n }\n\n /**\n * @event\n * Adds a listener for events of a specified type, optionally limited to features in a specified style layer.\n * See {@link MapEventType} and {@link MapLayerEventType} for a full list of events and their description.\n *\n * | Event | Compatible with `layerId` |\n * |------------------------|---------------------------|\n * | `mousedown` | yes |\n * | `mouseup` | yes |\n * | `mouseover` | yes |\n * | `mouseout` | yes |\n * | `mousemove` | yes |\n * | `mouseenter` | yes (required) |\n * | `mouseleave` | yes (required) |\n * | `click` | yes |\n * | `dblclick` | yes |\n * | `contextmenu` | yes |\n * | `touchstart` | yes |\n * | `touchend` | yes |\n * | `touchcancel` | yes |\n * | `wheel` | |\n * | `resize` | |\n * | `remove` | |\n * | `touchmove` | |\n * | `movestart` | |\n * | `move` | |\n * | `moveend` | |\n * | `dragstart` | |\n * | `drag` | |\n * | `dragend` | |\n * | `zoomstart` | |\n * | `zoom` | |\n * | `zoomend` | |\n * | `rotatestart` | |\n * | `rotate` | |\n * | `rotateend` | |\n * | `pitchstart` | |\n * | `pitch` | |\n * | `pitchend` | |\n * | `boxzoomstart` | |\n * | `boxzoomend` | |\n * | `boxzoomcancel` | |\n * | `webglcontextlost` | |\n * | `webglcontextrestored` | |\n * | `load` | |\n * | `render` | |\n * | `idle` | |\n * | `error` | |\n * | `data` | |\n * | `styledata` | |\n * | `sourcedata` | |\n * | `dataloading` | |\n * | `styledataloading` | |\n * | `sourcedataloading` | |\n * | `styleimagemissing` | |\n * | `dataabort` | |\n * | `sourcedataabort` | |\n *\n * @param type - The event type to listen for. Events compatible with the optional `layerId` parameter are triggered\n * when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas.\n * @param layer - The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location\n * is within a visible feature in this layer. The event will have a `features` property containing\n * an array of the matching features. If `layer` is not supplied, the event will not have a `features` property.\n * Please note that many event types are not compatible with the optional `layer` parameter.\n * @param listener - The function to be called when the event is fired.\n * @returns `this`\n * @example\n * ```ts\n * // Set an event listener that will fire\n * // when the map has finished loading\n * map.on('load', function() {\n * // Once the map has finished loading,\n * // add a new layer\n * map.addLayer({\n * id: 'points-of-interest',\n * source: {\n * type: 'vector',\n * url: 'https://maplibre.org/maplibre-style-spec/'\n * },\n * 'source-layer': 'poi_label',\n * type: 'circle',\n * paint: {\n * // MapLibre Style Specification paint properties\n * },\n * layout: {\n * // MapLibre Style Specification layout properties\n * }\n * });\n * });\n * ```\n * @example\n * ```ts\n * // Set an event listener that will fire\n * // when a feature on the countries layer of the map is clicked\n * map.on('click', 'countries', (e) => {\n * new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setHTML(`Country name: ${e.features[0].properties.name}`)\n * .addTo(map);\n * });\n * ```\n * @see [Display popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n on(\n type: T,\n layer: string,\n listener: (ev: MapLayerEventType[T] & Object) => void,\n ): Map;\n /**\n * Overload of the `on` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n on(type: T, listener: (ev: MapEventType[T] & Object) => void): this;\n /**\n * Overload of the `on` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n on(type: keyof MapEventType | string, listener: Listener): this;\n on(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {\n if (listener === undefined) {\n return super.on(type, layerIdOrListener as Listener);\n }\n\n const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener);\n\n this._delegatedListeners = this._delegatedListeners || {};\n this._delegatedListeners[type] = this._delegatedListeners[type] || [];\n this._delegatedListeners[type].push(delegatedListener);\n\n for (const event in delegatedListener.delegates) {\n this.on(event, delegatedListener.delegates[event]);\n }\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer.\n *\n * @event\n * @param type - The event type to listen for; one of `'mousedown'`, `'mouseup'`, `'click'`, `'dblclick'`,\n * `'mousemove'`, `'mouseenter'`, `'mouseleave'`, `'mouseover'`, `'mouseout'`, `'contextmenu'`, `'touchstart'`,\n * `'touchend'`, or `'touchcancel'`. `mouseenter` and `mouseover` events are triggered when the cursor enters\n * a visible portion of the specified layer from outside that layer or outside the map canvas. `mouseleave`\n * and `mouseout` events are triggered when the cursor leaves a visible portion of the specified layer, or leaves\n * the map canvas.\n * @param layer - The ID of a style layer or a listener if no ID is provided. Only events whose location is within a visible\n * feature in this layer will trigger the listener. The event will have a `features` property containing\n * an array of the matching features.\n * @param listener - The function to be called when the event is fired.\n * @returns `this` if listener is provided, promise otherwise to allow easier usage of async/await\n */\n once(\n type: T,\n layer: string,\n listener?: (ev: MapLayerEventType[T] & Object) => void,\n ): this | Promise;\n /**\n * Overload of the `once` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n once(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise;\n /**\n * Overload of the `once` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The listener callback.\n * @returns `this`\n */\n once(type: keyof MapEventType | string, listener?: Listener): this | Promise;\n once(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this | Promise {\n\n if (listener === undefined) {\n return super.once(type, layerIdOrListener as Listener);\n }\n\n const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener);\n\n for (const event in delegatedListener.delegates) {\n this.once(event, delegatedListener.delegates[event]);\n }\n\n return this;\n }\n\n /**\n * Removes an event listener for events previously added with `Map#on`.\n *\n * @event\n * @param type - The event type previously used to install the listener.\n * @param layer - The layer ID or listener previously used to install the listener.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(\n type: T,\n layer: string,\n listener: (ev: MapLayerEventType[T] & Object) => void,\n ): this;\n /**\n * Overload of the `off` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(type: T, listener: (ev: MapEventType[T] & Object) => void): this;\n /**\n * Overload of the `off` method that allows to listen to events without specifying a layer.\n * @event\n * @param type - The type of the event.\n * @param listener - The function previously installed as a listener.\n * @returns `this`\n */\n off(type: keyof MapEventType | string, listener: Listener): this;\n off(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this {\n if (listener === undefined) {\n return super.off(type, layerIdOrListener as Listener);\n }\n\n const removeDelegatedListener = (delegatedListeners) => {\n const listeners = delegatedListeners[type];\n for (let i = 0; i < listeners.length; i++) {\n const delegatedListener = listeners[i];\n if (delegatedListener.layer === layerIdOrListener && delegatedListener.listener === listener) {\n for (const event in delegatedListener.delegates) {\n this.off(((event as any)), delegatedListener.delegates[event]);\n }\n listeners.splice(i, 1);\n return this;\n }\n }\n };\n\n if (this._delegatedListeners && this._delegatedListeners[type]) {\n removeDelegatedListener(this._delegatedListeners);\n }\n\n return this;\n }\n\n /**\n * Returns an array of MapGeoJSONFeature objects\n * representing visible features that satisfy the query parameters.\n *\n * @param geometryOrOptions - (optional) The geometry of the query region:\n * either a single point or southwest and northeast points describing a bounding box.\n * Omitting this parameter (i.e. calling {@link Map#queryRenderedFeatures} with zero arguments,\n * or with only a `options` argument) is equivalent to passing a bounding box encompassing the entire\n * map viewport.\n * The geometryOrOptions can receive a {@link QueryRenderedFeaturesOptions} only to support a situation where the function receives only one parameter which is the options parameter.\n * @param options - (optional) Options object.\n *\n * @returns An array of MapGeoJSONFeature objects.\n *\n * The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only\n * string and numeric property values are supported (i.e. `null`, `Array`, and `Object` values are not supported).\n *\n * Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object\n * representing the style layer to which the feature belongs. Layout and paint properties in this object contain values\n * which are fully evaluated for the given zoom level and feature.\n *\n * Only features that are currently rendered are included. Some features will **not** be included, like:\n *\n * - Features from layers whose `visibility` property is `\"none\"`.\n * - Features from layers whose zoom range excludes the current zoom level.\n * - Symbol features that have been hidden due to text or icon collision.\n *\n * Features from all other layers are included, including features that may have no visible\n * contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to\n * 0.\n *\n * The topmost rendered feature appears first in the returned array, and subsequent features are sorted by\n * descending z-order. Features that are rendered multiple times (due to wrapping across the antemeridian at low\n * zoom levels) are returned only once (though subject to the following caveat).\n *\n * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature\n * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple\n * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query.\n * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding\n * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile\n * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple\n * tiles due to tile buffering.\n *\n * @example\n * Find all features at a point\n * ```ts\n * let features = map.queryRenderedFeatures(\n * [20, 35],\n * { layers: ['my-layer-name'] }\n * );\n * ```\n *\n * @example\n * Find all features within a static bounding box\n * ```ts\n * let features = map.queryRenderedFeatures(\n * [[10, 20], [30, 50]],\n * { layers: ['my-layer-name'] }\n * );\n * ```\n *\n * @example\n * Find all features within a bounding box around a point\n * ```ts\n * let width = 10;\n * let height = 20;\n * let features = map.queryRenderedFeatures([\n * [point.x - width / 2, point.y - height / 2],\n * [point.x + width / 2, point.y + height / 2]\n * ], { layers: ['my-layer-name'] });\n * ```\n *\n * @example\n * Query all rendered features from a single layer\n * ```ts\n * let features = map.queryRenderedFeatures({ layers: ['my-layer-name'] });\n * ```\n * @see [Get features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/queryrenderedfeatures/)\n */\n queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[] {\n if (!this.style) {\n return [];\n }\n let queryGeometry;\n const isGeometry = geometryOrOptions instanceof Point || Array.isArray(geometryOrOptions);\n const geometry = isGeometry ? geometryOrOptions : [[0, 0], [this.transform.width, this.transform.height]];\n options = options || (isGeometry ? {} : geometryOrOptions) || {};\n\n if (geometry instanceof Point || typeof geometry[0] === 'number') {\n queryGeometry = [Point.convert(geometry as PointLike)];\n } else {\n const tl = Point.convert(geometry[0] as PointLike);\n const br = Point.convert(geometry[1] as PointLike);\n queryGeometry = [tl, new Point(br.x, tl.y), br, new Point(tl.x, br.y), tl];\n }\n\n return this.style.queryRenderedFeatures(queryGeometry, options, this.transform);\n }\n\n /**\n * Returns an array of MapGeoJSONFeature objects\n * representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.\n *\n * @param sourceId - The ID of the vector tile or GeoJSON source to query.\n * @param parameters - The options object.\n * @returns An array of MapGeoJSONFeature objects.\n *\n * In contrast to {@link Map#queryRenderedFeatures}, this function returns all features matching the query parameters,\n * whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded\n * vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently\n * visible viewport.\n *\n * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature\n * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple\n * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query.\n * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding\n * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile\n * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple\n * tiles due to tile buffering.\n *\n * @example\n * Find all features in one source layer in a vector source\n * ```ts\n * let features = map.querySourceFeatures('your-source-id', {\n * sourceLayer: 'your-source-layer'\n * });\n * ```\n *\n */\n querySourceFeatures(sourceId: string, parameters?: QuerySourceFeatureOptions | null): MapGeoJSONFeature[] {\n return this.style.querySourceFeatures(sourceId, parameters);\n }\n\n /**\n * Updates the map's MapLibre style object with a new value.\n *\n * If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style\n * against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites\n * (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current\n * style and the given style are different in any way, the map renderer will force a full update, removing the current style and building\n * the given one from scratch.\n *\n *\n * @param style - A JSON object conforming to the schema described in the\n * [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), or a URL to such JSON.\n * @param options - The options object.\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setStyle(\"https://demotiles.maplibre.org/style.json\");\n *\n * map.setStyle('https://demotiles.maplibre.org/style.json', {\n * transformStyle: (previousStyle, nextStyle) => ({\n * ...nextStyle,\n * sources: {\n * ...nextStyle.sources,\n * // copy a source from previous style\n * 'osm': previousStyle.sources.osm\n * },\n * layers: [\n * // background layer\n * nextStyle.layers[0],\n * // copy a layer from previous style\n * previousStyle.layers[0],\n * // other layers from the next style\n * ...nextStyle.layers.slice(1).map(layer => {\n * // hide the layers we don't need from demotiles style\n * if (layer.id.startsWith('geolines')) {\n * layer.layout = {...layer.layout || {}, visibility: 'none'};\n * // filter out US polygons\n * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {\n * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];\n * }\n * return layer;\n * })\n * ]\n * })\n * });\n * ```\n */\n setStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions): this {\n options = extend({},\n {\n localIdeographFontFamily: this._localIdeographFontFamily,\n validate: this._validateStyle\n }, options);\n\n if ((options.diff !== false && options.localIdeographFontFamily === this._localIdeographFontFamily) && this.style && style) {\n this._diffStyle(style, options);\n return this;\n } else {\n this._localIdeographFontFamily = options.localIdeographFontFamily;\n return this._updateStyle(style, options);\n }\n }\n\n /**\n * Updates the requestManager's transform request with a new function\n *\n * @param transformRequest - A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.\n * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties\n *\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setTransformRequest((url: string, resourceType: string) => {});\n * ```\n */\n setTransformRequest(transformRequest: RequestTransformFunction): this {\n this._requestManager.setTransformRequest(transformRequest);\n return this;\n }\n\n _getUIString(key: string) {\n const str = this._locale[key];\n if (str == null) {\n throw new Error(`Missing UI string '${key}'`);\n }\n\n return str;\n }\n\n _updateStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions) {\n // transformStyle relies on having previous style serialized, if it is not loaded yet, delay _updateStyle until previous style is loaded\n if (options.transformStyle && this.style && !this.style._loaded) {\n this.style.once('style.load', () => this._updateStyle(style, options));\n return;\n }\n\n const previousStyle = this.style && options.transformStyle ? this.style.serialize() : undefined;\n if (this.style) {\n this.style.setEventedParent(null);\n\n // Only release workers when map is getting disposed\n this.style._remove(!style);\n }\n\n if (!style) {\n delete this.style;\n return this;\n } else {\n this.style = new Style(this, options || {});\n }\n\n this.style.setEventedParent(this, {style: this.style});\n\n if (typeof style === 'string') {\n this.style.loadURL(style, options, previousStyle);\n } else {\n this.style.loadJSON(style, options, previousStyle);\n }\n\n return this;\n }\n\n _lazyInitEmptyStyle() {\n if (!this.style) {\n this.style = new Style(this, {});\n this.style.setEventedParent(this, {style: this.style});\n this.style.loadEmpty();\n }\n }\n\n _diffStyle(style: StyleSpecification | string, options?: StyleSwapOptions & StyleOptions) {\n if (typeof style === 'string') {\n const url = style;\n const request = this._requestManager.transformRequest(url, ResourceType.Style);\n getJSON(request, (error?: Error | null, json?: any | null) => {\n if (error) {\n this.fire(new ErrorEvent(error));\n } else if (json) {\n this._updateDiff(json, options);\n }\n });\n } else if (typeof style === 'object') {\n this._updateDiff(style, options);\n }\n }\n\n _updateDiff(style: StyleSpecification, options?: StyleSwapOptions & StyleOptions) {\n try {\n if (this.style.setState(style, options)) {\n this._update(true);\n }\n } catch (e) {\n warnOnce(\n `Unable to perform style diff: ${e.message || e.error || e}. Rebuilding the style from scratch.`\n );\n this._updateStyle(style, options);\n }\n }\n\n /**\n * Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style.\n *\n * @returns The map's style JSON object.\n *\n * @example\n * ```ts\n * let styleJson = map.getStyle();\n * ```\n *\n */\n getStyle(): StyleSpecification {\n if (this.style) {\n return this.style.serialize();\n }\n }\n\n /**\n * Returns a Boolean indicating whether the map's style is fully loaded.\n *\n * @returns A Boolean indicating whether the style is fully loaded.\n *\n * @example\n * ```ts\n * let styleLoadStatus = map.isStyleLoaded();\n * ```\n */\n isStyleLoaded(): boolean | void {\n if (!this.style) return warnOnce('There is no style added to the map.');\n return this.style.loaded();\n }\n\n /**\n * Adds a source to the map's style.\n *\n * Events triggered:\n *\n * Triggers the `source.add` event.\n *\n * @param id - The ID of the source to add. Must not conflict with existing sources.\n * @param source - The source object, conforming to the\n * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or\n * {@link CanvasSourceSpecification}.\n * @returns `this`\n * @example\n * ```ts\n * map.addSource('my-data', {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * });\n * ```\n * @example\n * ```ts\n * map.addSource('my-data', {\n * \"type\": \"geojson\",\n * \"data\": {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [-77.0323, 38.9131]\n * },\n * \"properties\": {\n * \"title\": \"Mapbox DC\",\n * \"marker-symbol\": \"monument\"\n * }\n * }\n * });\n * ```\n * @see GeoJSON source: [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n */\n addSource(id: string, source: SourceSpecification): this {\n this._lazyInitEmptyStyle();\n this.style.addSource(id, source);\n return this._update(true);\n }\n\n /**\n * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with\n * the given ID in the map's style has no outstanding network requests, otherwise `false`.\n *\n * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID.\n *\n * @param id - The ID of the source to be checked.\n * @returns A Boolean indicating whether the source is loaded.\n * @example\n * ```ts\n * let sourceLoaded = map.isSourceLoaded('bathymetry-data');\n * ```\n */\n isSourceLoaded(id: string): boolean {\n const source = this.style && this.style.sourceCaches[id];\n if (source === undefined) {\n this.fire(new ErrorEvent(new Error(`There is no source with ID '${id}'`)));\n return;\n }\n return source.loaded();\n }\n\n /**\n * Loads a 3D terrain mesh, based on a \"raster-dem\" source.\n *\n * Triggers the `terrain` event.\n *\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setTerrain({ source: 'terrain' });\n * ```\n */\n setTerrain(options: TerrainSpecification | null): this {\n this.style._checkLoaded();\n\n // clear event handlers\n if (this._terrainDataCallback) this.style.off('data', this._terrainDataCallback);\n\n if (!options) {\n // remove terrain\n if (this.terrain) this.terrain.sourceCache.destruct();\n this.terrain = null;\n if (this.painter.renderToTexture) this.painter.renderToTexture.destruct();\n this.painter.renderToTexture = null;\n this.transform._minEleveationForCurrentTile = 0;\n this.transform.elevation = 0;\n } else {\n // add terrain\n const sourceCache = this.style.sourceCaches[options.source];\n if (!sourceCache) throw new Error(`cannot load terrain, because there exists no source with ID: ${options.source}`);\n // Warn once if user is using the same source for hillshade and terrain\n for (const index in this.style._layers) {\n const thisLayer = this.style._layers[index];\n if (thisLayer.type === 'hillshade' && thisLayer.source === options.source) {\n warnOnce('You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.');\n }\n }\n this.terrain = new Terrain(this.painter, sourceCache, options);\n this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain);\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this._terrainDataCallback = e => {\n if (e.dataType === 'style') {\n this.terrain.sourceCache.freeRtt();\n } else if (e.dataType === 'source' && e.tile) {\n if (e.sourceId === options.source && !this._elevationFreeze) {\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n }\n this.terrain.sourceCache.freeRtt(e.tile.tileID);\n }\n };\n this.style.on('data', this._terrainDataCallback);\n }\n\n this.fire(new Event('terrain', {terrain: options}));\n return this;\n }\n\n /**\n * Get the terrain-options if terrain is loaded\n * @returns the TerrainSpecification passed to setTerrain\n * @example\n * ```ts\n * map.getTerrain(); // { source: 'terrain' };\n * ```\n */\n getTerrain(): TerrainSpecification | null {\n return this.terrain?.options ?? null;\n }\n\n /**\n * Returns a Boolean indicating whether all tiles in the viewport from all sources on\n * the style are loaded.\n *\n * @returns A Boolean indicating whether all tiles are loaded.\n * @example\n * ```ts\n * let tilesLoaded = map.areTilesLoaded();\n * ```\n */\n areTilesLoaded(): boolean {\n const sources = this.style && this.style.sourceCaches;\n for (const id in sources) {\n const source = sources[id];\n const tiles = source._tiles;\n for (const t in tiles) {\n const tile = tiles[t];\n if (!(tile.state === 'loaded' || tile.state === 'errored')) return false;\n }\n }\n return true;\n }\n\n /**\n * Adds a [custom source type](#Custom Sources), making it available for use with\n * {@link Map#addSource}.\n * @param name - The name of the source type; source definition objects use this name in the `{type: ...}` field.\n * @param SourceType - A {@link Source} constructor.\n * @param callback - Called when the source type is ready or with an error argument if there is an error.\n */\n addSourceType(name: string, SourceType: SourceClass, callback: Callback) {\n this._lazyInitEmptyStyle();\n return this.style.addSourceType(name, SourceType, callback);\n }\n\n /**\n * Removes a source from the map's style.\n *\n * @param id - The ID of the source to remove.\n * @returns `this`\n * @example\n * ```ts\n * map.removeSource('bathymetry-data');\n * ```\n */\n removeSource(id: string): Map {\n this.style.removeSource(id);\n return this._update(true);\n }\n\n /**\n * Returns the source with the specified ID in the map's style.\n *\n * This method is often used to update a source using the instance members for the relevant\n * source type as defined in [Sources](#sources).\n * For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates`\n * of an image source.\n *\n * @param id - The ID of the source to get.\n * @returns The style source with the specified ID or `undefined` if the ID\n * corresponds to no existing sources.\n * The shape of the object varies by source type.\n * A list of options for each source type is available on the MapLibre Style Specification's\n * [Sources](https://maplibre.org/maplibre-style-spec/sources/) page.\n * @example\n * ```ts\n * let sourceObject = map.getSource('points');\n * ```\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)\n * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)\n */\n getSource(id: string): Source | undefined {\n return this.style.getSource(id);\n }\n\n /**\n * Add an image to the style. This image can be displayed on the map like any other icon in the style's\n * sprite using the image's ID with\n * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),\n * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),\n * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),\n * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).\n *\n * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image.\n *\n * @param id - The ID of the image.\n * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`\n * properties with the same format as `ImageData`.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * // If the style's sprite does not already contain an image with ID 'cat',\n * // add the image 'cat-icon.png' to the style's sprite with the ID 'cat'.\n * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) {\n * if (error) throw error;\n * if (!map.hasImage('cat')) map.addImage('cat', image);\n * });\n *\n * // Add a stretchable image that can be used with `icon-text-fit`\n * // In this example, the image is 600px wide by 400px high.\n * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png', function(error, image) {\n * if (error) throw error;\n * if (!map.hasImage('border-image')) {\n * map.addImage('border-image', image, {\n * content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border\n * stretchX: [[16, 584]], // stretch everything horizontally except the 16px border\n * stretchY: [[16, 384]], // stretch everything vertically except the 16px border\n * });\n * }\n * });\n * ```\n * @see Use `HTMLImageElement`: [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/)\n * @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-generated/)\n */\n addImage(id: string,\n image: HTMLImageElement | ImageBitmap | ImageData | {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n } | StyleImageInterface,\n options: Partial = {}): this {\n const {\n pixelRatio = 1,\n sdf = false,\n stretchX,\n stretchY,\n content\n } = options;\n this._lazyInitEmptyStyle();\n const version = 0;\n\n if (image instanceof HTMLImageElement || isImageBitmap(image)) {\n const {width, height, data} = browser.getImageData(image);\n this.style.addImage(id, {data: new RGBAImage({width, height}, data), pixelRatio, stretchX, stretchY, content, sdf, version});\n } else if (image.width === undefined || image.height === undefined) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' +\n 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`')));\n } else {\n const {width, height, data} = image as ImageData;\n const userImage = (image as any as StyleImageInterface);\n\n this.style.addImage(id, {\n data: new RGBAImage({width, height}, new Uint8Array(data)),\n pixelRatio,\n stretchX,\n stretchY,\n content,\n sdf,\n version,\n userImage\n });\n\n if (userImage.onAdd) {\n userImage.onAdd(this, id);\n }\n return this;\n }\n }\n\n /**\n * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's\n * sprite using the image's ID with\n * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image),\n * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern),\n * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern),\n * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern).\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the image.\n * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data`\n * properties with the same format as `ImageData`.\n * @returns `this`\n * @example\n * ```ts\n * // If an image with the ID 'cat' already exists in the style's sprite,\n * // replace that image with a new image, 'other-cat-icon.png'.\n * if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png');\n * ```\n */\n updateImage(id: string,\n image: HTMLImageElement | ImageBitmap | ImageData | {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n } | StyleImageInterface): this {\n\n const existingImage = this.style.getImage(id);\n if (!existingImage) {\n return this.fire(new ErrorEvent(new Error(\n 'The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.')));\n }\n const imageData = (image instanceof HTMLImageElement || isImageBitmap(image)) ?\n browser.getImageData(image) :\n image;\n const {width, height, data} = imageData;\n\n if (width === undefined || height === undefined) {\n return this.fire(new ErrorEvent(new Error(\n 'Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' +\n 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`')));\n }\n\n if (width !== existingImage.data.width || height !== existingImage.data.height) {\n return this.fire(new ErrorEvent(new Error(\n 'The width and height of the updated image must be that same as the previous version of the image')));\n }\n\n const copy = !(image instanceof HTMLImageElement || isImageBitmap(image));\n existingImage.data.replace(data, copy);\n\n this.style.updateImage(id, existingImage);\n return this;\n }\n\n /**\n * Returns an image, specified by ID, currently available in the map.\n * This includes both images from the style's original sprite\n * and any images that have been added at runtime using {@link Map#addImage}.\n *\n * @param id - The ID of the image.\n * @returns An image in the map with the specified ID.\n *\n * @example\n * ```ts\n * let coffeeShopIcon = map.getImage(\"coffee_cup\");\n * ```\n */\n getImage(id: string): StyleImage {\n return this.style.getImage(id);\n }\n\n /**\n * Check whether or not an image with a specific ID exists in the style. This checks both images\n * in the style's original sprite and any images\n * that have been added at runtime using {@link Map#addImage}.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the image.\n *\n * @returns A Boolean indicating whether the image exists.\n * @example\n * Check if an image with the ID 'cat' exists in the style's sprite.\n * ```ts\n * let catIconExists = map.hasImage('cat');\n * ```\n */\n hasImage(id: string): boolean {\n if (!id) {\n this.fire(new ErrorEvent(new Error('Missing required image id')));\n return false;\n }\n\n return !!this.style.getImage(id);\n }\n\n /**\n * Remove an image from a style. This can be an image from the style's original\n * sprite or any images\n * that have been added at runtime using {@link Map#addImage}.\n *\n * @param id - The ID of the image.\n *\n * @example\n * ```ts\n * // If an image with the ID 'cat' exists in\n * // the style's sprite, remove it.\n * if (map.hasImage('cat')) map.removeImage('cat');\n * ```\n */\n removeImage(id: string) {\n this.style.removeImage(id);\n }\n\n /**\n * Load an image from an external URL to be used with {@link Map#addImage}. External\n * domains must support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS).\n *\n * @param url - The URL of the image file. Image file must be in png, webp, or jpg format.\n * @param callback - Expecting `callback(error, data)`. Called when the image has loaded or with an error argument if there is an error.\n *\n * @example\n * Load an image from an external URL.\n * ```ts\n * map.loadImage('http://placekitten.com/50/50', function(error, image) {\n * if (error) throw error;\n * // Add the loaded image to the style's sprite with the ID 'kitten'.\n * map.addImage('kitten', image);\n * });\n * ```\n * @see [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/)\n */\n loadImage(url: string, callback: GetImageCallback) {\n ImageRequest.getImage(this._requestManager.transformRequest(url, ResourceType.Image), callback);\n }\n\n /**\n * Returns an Array of strings containing the IDs of all images currently available in the map.\n * This includes both images from the style's original sprite\n * and any images that have been added at runtime using {@link Map#addImage}.\n *\n * @returns An Array of strings containing the names of all sprites/images currently available in the map.\n *\n * @example\n * ```ts\n * let allImages = map.listImages();\n * ```\n */\n listImages(): Array {\n return this.style.listImages();\n }\n\n /**\n * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers)\n * to the map's style.\n *\n * A layer defines how data from a specified source will be styled. Read more about layer types\n * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers).\n *\n * @param layer - The layer to add,\n * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,\n * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition.\n * The MapLibre Style Specification's layer definition is appropriate for most layers.\n *\n * @param beforeId - The ID of an existing layer to insert the new layer before,\n * resulting in the new layer appearing visually beneath the existing layer.\n * If this argument is not specified, the layer will be appended to the end of the layers array\n * and appear visually above all other layers.\n *\n * @returns `this`\n *\n * @example\n * Add a circle layer with a vector source\n * ```ts\n * map.addLayer({\n * id: 'points-of-interest',\n * source: {\n * type: 'vector',\n * url: 'https://demotiles.maplibre.org/tiles/tiles.json'\n * },\n * 'source-layer': 'poi_label',\n * type: 'circle',\n * paint: {\n * // MapLibre Style Specification paint properties\n * },\n * layout: {\n * // MapLibre Style Specification layout properties\n * }\n * });\n * ```\n *\n * @example\n * Define a source before using it to create a new layer\n * ```ts\n * map.addSource('state-data', {\n * type: 'geojson',\n * data: 'path/to/data.geojson'\n * });\n *\n * map.addLayer({\n * id: 'states',\n * // References the GeoJSON source defined above\n * // and does not require a `source-layer`\n * source: 'state-data',\n * type: 'symbol',\n * layout: {\n * // Set the label content to the\n * // feature's `name` property\n * text-field: ['get', 'name']\n * }\n * });\n * ```\n *\n * @example\n * Add a new symbol layer before an existing layer\n * ```ts\n * map.addLayer({\n * id: 'states',\n * // References a source that's already been defined\n * source: 'state-data',\n * type: 'symbol',\n * layout: {\n * // Set the label content to the\n * // feature's `name` property\n * text-field: ['get', 'name']\n * }\n * // Add the layer before the existing `cities` layer\n * }, 'cities');\n * ```\n * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)\n * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)\n * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/)\n */\n addLayer(layer: AddLayerObject, beforeId?: string) {\n this._lazyInitEmptyStyle();\n this.style.addLayer(layer, beforeId);\n return this._update(true);\n }\n\n /**\n * Moves a layer to a different z-position.\n *\n * @param id - The ID of the layer to move.\n * @param beforeId - The ID of an existing layer to insert the new layer before. When viewing the map, the `id` layer will appear beneath the `beforeId` layer. If `beforeId` is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map.\n * @returns `this`\n *\n * @example\n * Move a layer with ID 'polygon' before the layer with ID 'country-label'. The `polygon` layer will appear beneath the `country-label` layer on the map.\n * ```ts\n * map.moveLayer('polygon', 'country-label');\n * ```\n */\n moveLayer(id: string, beforeId?: string): this {\n this.style.moveLayer(id, beforeId);\n return this._update(true);\n }\n\n /**\n * Removes the layer with the given ID from the map's style.\n *\n * An {@link ErrorEvent} will be fired if the image parameter is invald.\n *\n * @param id - The ID of the layer to remove\n * @returns `this`\n *\n * @example\n * If a layer with ID 'state-data' exists, remove it.\n * ```ts\n * if (map.getLayer('state-data')) map.removeLayer('state-data');\n * ```\n */\n removeLayer(id: string): this {\n this.style.removeLayer(id);\n return this._update(true);\n }\n\n /**\n * Returns the layer with the specified ID in the map's style.\n *\n * @param id - The ID of the layer to get.\n * @returns The layer with the specified ID, or `undefined`\n * if the ID corresponds to no existing layers.\n *\n * @example\n * ```ts\n * let stateDataLayer = map.getLayer('state-data');\n * ```\n * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/)\n * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/)\n */\n getLayer(id: string): StyleLayer | undefined {\n return this.style.getLayer(id);\n }\n\n /**\n * Return the ids of all layers currently in the style, including custom layers, in order.\n *\n * @returns ids of layers, in order\n *\n * @example\n * ```ts\n * const orderedLayerIds = map.getLayersOrder();\n * ```\n */\n getLayersOrder(): string[] {\n return this.style.getLayersOrder();\n }\n\n /**\n * Sets the zoom extent for the specified style layer. The zoom extent includes the\n * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)\n * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom))\n * at which the layer will be rendered.\n *\n * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the\n * minimum zoom level of the _source layer_ because the data does not exist at those zoom levels. If the minimum\n * zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style\n * layer will not be rendered at all zoom levels in the zoom range.\n *\n * @param layerId - The ID of the layer to which the zoom extent will be applied.\n * @param minzoom - The minimum zoom to set (0-24).\n * @param maxzoom - The maximum zoom to set (0-24).\n * @returns `this`\n *\n * @example\n * ```ts\n * map.setLayerZoomRange('my-layer', 2, 5);\n * ```\n */\n setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this {\n this.style.setLayerZoomRange(layerId, minzoom, maxzoom);\n return this._update(true);\n }\n\n /**\n * Sets the filter for the specified style layer.\n *\n * Filters control which features a style layer renders from its source.\n * Any feature for which the filter expression evaluates to `true` will be\n * rendered on the map. Those that are false will be hidden.\n *\n * Use `setFilter` to show a subset of your source data.\n *\n * To clear the filter, pass `null` or `undefined` as the second parameter.\n *\n * @param layerId - The ID of the layer to which the filter will be applied.\n * @param filter - The filter, conforming to the MapLibre Style Specification's\n * [filter definition](https://maplibre.org/maplibre-style-spec/layers/#filter). If `null` or `undefined` is provided, the function removes any existing filter from the layer.\n * @param options - Options object.\n * @returns `this`\n *\n * @example\n * Display only features with the 'name' property 'USA'\n * ```ts\n * map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']);\n * ```\n * @example\n * Display only features with five or more 'available-spots'\n * ```ts\n * map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]);\n * ```\n * @example\n * Remove the filter for the 'bike-docks' style layer\n * ```ts\n * map.setFilter('bike-docks', null);\n * ```\n * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n */\n setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) {\n this.style.setFilter(layerId, filter, options);\n return this._update(true);\n }\n\n /**\n * Returns the filter applied to the specified style layer.\n *\n * @param layerId - The ID of the style layer whose filter to get.\n * @returns The layer's filter.\n */\n getFilter(layerId: string): FilterSpecification | void {\n return this.style.getFilter(layerId);\n }\n\n /**\n * Sets the value of a paint property in the specified style layer.\n *\n * @param layerId - The ID of the layer to set the paint property in.\n * @param name - The name of the paint property to set.\n * @param value - The value of the paint property to set.\n * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).\n * Pass `null` to unset the existing value.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setPaintProperty('my-layer', 'fill-color', '#faafee');\n * ```\n * @see [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/)\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this {\n this.style.setPaintProperty(layerId, name, value, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of a paint property in the specified style layer.\n *\n * @param layerId - The ID of the layer to get the paint property from.\n * @param name - The name of a paint property to get.\n * @returns The value of the specified paint property.\n */\n getPaintProperty(layerId: string, name: string) {\n return this.style.getPaintProperty(layerId, name);\n }\n\n /**\n * Sets the value of a layout property in the specified style layer.\n *\n * @param layerId - The ID of the layer to set the layout property in.\n * @param name - The name of the layout property to set.\n * @param value - The value of the layout property. Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).\n * @param options - The options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setLayoutProperty('my-layer', 'visibility', 'none');\n * ```\n */\n setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this {\n this.style.setLayoutProperty(layerId, name, value, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of a layout property in the specified style layer.\n *\n * @param layerId - The ID of the layer to get the layout property from.\n * @param name - The name of the layout property to get.\n * @returns The value of the specified layout property.\n */\n getLayoutProperty(layerId: string, name: string) {\n return this.style.getLayoutProperty(layerId, name);\n }\n\n /**\n * Sets the value of the style's glyphs property.\n *\n * @param glyphsUrl - Glyph URL to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/glyphs/).\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setGlyphs('https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf');\n * ```\n */\n setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}): this {\n this._lazyInitEmptyStyle();\n this.style.setGlyphs(glyphsUrl, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of the style's glyphs URL\n *\n * @returns glyphs Style's glyphs url\n */\n getGlyphs(): string | null {\n return this.style.getGlyphsUrl();\n }\n\n /**\n * Adds a sprite to the map's style. Fires the `style` event.\n *\n * @param id - The ID of the sprite to add. Must not conflict with existing sprites.\n * @param url - The URL to load the sprite from\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.addSprite('sprite-two', 'http://example.com/sprite-two');\n * ```\n */\n addSprite(id: string, url: string, options: StyleSetterOptions = {}): this {\n this._lazyInitEmptyStyle();\n this.style.addSprite(id, url, options, (err) => {\n if (!err) {\n this._update(true);\n }\n });\n return this;\n }\n\n /**\n * Removes the sprite from the map's style. Fires the `style` event.\n *\n * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be \"default\".\n * @returns `this`\n * @example\n * ```ts\n * map.removeSprite('sprite-two');\n * map.removeSprite('default');\n * ```\n */\n removeSprite(id: string) {\n this._lazyInitEmptyStyle();\n this.style.removeSprite(id);\n return this._update(true);\n }\n\n /**\n * Returns the as-is value of the style's sprite.\n *\n * @returns style's sprite list of id-url pairs\n */\n getSprite(): {id: string; url: string}[] {\n return this.style.getSprite();\n }\n\n /**\n * Sets the value of the style's sprite property.\n *\n * @param spriteUrl - Sprite URL to set.\n * @param options - Options object.\n * @returns `this`\n * @example\n * ```ts\n * map.setSprite('YOUR_SPRITE_URL');\n * ```\n */\n setSprite(spriteUrl: string | null, options: StyleSetterOptions = {}) {\n this._lazyInitEmptyStyle();\n this.style.setSprite(spriteUrl, options, (err) => {\n if (!err) {\n this._update(true);\n }\n });\n return this;\n }\n\n /**\n * Sets the any combination of light values.\n *\n * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light).\n * @param options - Options object.\n * @returns `this`\n *\n * @example\n * ```ts\n * let layerVisibility = map.getLayoutProperty('my-layer', 'visibility');\n * ```\n */\n setLight(light: LightSpecification, options: StyleSetterOptions = {}) {\n this._lazyInitEmptyStyle();\n this.style.setLight(light, options);\n return this._update(true);\n }\n\n /**\n * Returns the value of the light object.\n *\n * @returns light Light properties of the style.\n */\n getLight(): LightSpecification {\n return this.style.getLight();\n }\n\n /**\n * Sets the `state` of a feature.\n * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime.\n * When using this method, the `state` object is merged with any existing key-value pairs in the feature's state.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * This method can only be used with sources that have a `feature.id` attribute. The `feature.id` attribute can be defined in three ways:\n * - For vector or GeoJSON sources, including an `id` attribute in the original data file.\n * - For vector or GeoJSON sources, using the [`promoteId`](https://maplibre.org/maplibre-style-spec/sources/#vector-promoteId) option at the time the source is defined.\n * - For GeoJSON sources, using the [`generateId`](https://maplibre.org/maplibre-style-spec/sources/#geojson-generateId) option to auto-assign an `id` based on the feature's index in the source data. If you change feature data using `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values.\n *\n * _Note: You can use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) to access the values in a feature's state object for the purposes of styling._\n *\n * @param feature - Feature identifier. Feature objects returned from\n * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @param state - A set of key-value pairs. The values should be valid JSON types.\n * @returns `this`\n *\n * @example\n * ```ts\n * // When the mouse moves over the `my-layer` layer, update\n * // the feature state for the feature under the mouse\n * map.on('mousemove', 'my-layer', function(e) {\n * if (e.features.length > 0) {\n * map.setFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id,\n * }, {\n * hover: true\n * });\n * }\n * });\n * ```\n * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n */\n setFeatureState(feature: FeatureIdentifier, state: any): this {\n this.style.setFeatureState(feature, state);\n return this._update();\n }\n\n /**\n * Removes the `state` of a feature, setting it back to the default behavior.\n * If only a `target.source` is specified, it will remove the state for all features from that source.\n * If `target.id` is also specified, it will remove all keys for that feature's state.\n * If `key` is also specified, it removes only that key from that feature's state.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * @param target - Identifier of where to remove state. It can be a source, a feature, or a specific key of feature.\n * Feature objects returned from {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @param key - (optional) The key in the feature state to reset.\n * @returns `this`\n * @example\n * Reset the entire state object for all features in the `my-source` source\n * ```ts\n * map.removeFeatureState({\n * source: 'my-source'\n * });\n * ```\n *\n * @example\n * When the mouse leaves the `my-layer` layer,\n * reset the entire state object for the\n * feature under the mouse\n * ```ts\n * map.on('mouseleave', 'my-layer', function(e) {\n * map.removeFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * });\n * });\n * ```\n *\n * @example\n * When the mouse leaves the `my-layer` layer,\n * reset only the `hover` key-value pair in the\n * state for the feature under the mouse\n * ```ts\n * map.on('mouseleave', 'my-layer', function(e) {\n * map.removeFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * }, 'hover');\n * });\n * ```\n */\n removeFeatureState(target: FeatureIdentifier, key?: string): this {\n this.style.removeFeatureState(target, key);\n return this._update();\n }\n\n /**\n * Gets the `state` of a feature.\n * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime.\n * Features are identified by their `feature.id` attribute, which can be any number or string.\n *\n * _Note: To access the values in a feature's state object for the purposes of styling the feature, use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state)._\n *\n * @param feature - Feature identifier. Feature objects returned from\n * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers.\n * @returns The state of the feature: a set of key-value pairs that was assigned to the feature at runtime.\n *\n * @example\n * When the mouse moves over the `my-layer` layer,\n * get the feature state for the feature under the mouse\n * ```ts\n * map.on('mousemove', 'my-layer', function(e) {\n * if (e.features.length > 0) {\n * map.getFeatureState({\n * source: 'my-source',\n * sourceLayer: 'my-source-layer',\n * id: e.features[0].id\n * });\n * }\n * });\n * ```\n */\n getFeatureState(feature: FeatureIdentifier): any {\n return this.style.getFeatureState(feature);\n }\n\n /**\n * Returns the map's containing HTML element.\n *\n * @returns The map's container.\n */\n getContainer(): HTMLElement {\n return this._container;\n }\n\n /**\n * Returns the HTML element containing the map's `` element.\n *\n * If you want to add non-GL overlays to the map, you should append them to this element.\n *\n * This is the element to which event bindings for map interactivity (such as panning and zooming) are\n * attached. It will receive bubbled events from child elements such as the ``, but not from\n * map controls.\n *\n * @returns The container of the map's ``.\n * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)\n */\n getCanvasContainer(): HTMLElement {\n return this._canvasContainer;\n }\n\n /**\n * Returns the map's `` element.\n *\n * @returns The map's `` element.\n * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)\n */\n getCanvas(): HTMLCanvasElement {\n return this._canvas;\n }\n\n _containerDimensions() {\n let width = 0;\n let height = 0;\n\n if (this._container) {\n width = this._container.clientWidth || 400;\n height = this._container.clientHeight || 300;\n }\n\n return [width, height];\n }\n\n _setupContainer() {\n const container = this._container;\n container.classList.add('maplibregl-map');\n\n const canvasContainer = this._canvasContainer = DOM.create('div', 'maplibregl-canvas-container', container);\n if (this._interactive) {\n canvasContainer.classList.add('maplibregl-interactive');\n }\n\n this._canvas = DOM.create('canvas', 'maplibregl-canvas', canvasContainer);\n this._canvas.addEventListener('webglcontextlost', this._contextLost, false);\n this._canvas.addEventListener('webglcontextrestored', this._contextRestored, false);\n this._canvas.setAttribute('tabindex', '0');\n this._canvas.setAttribute('aria-label', 'Map');\n this._canvas.setAttribute('role', 'region');\n\n const dimensions = this._containerDimensions();\n const clampedPixelRatio = this._getClampedPixelRatio(dimensions[0], dimensions[1]);\n this._resizeCanvas(dimensions[0], dimensions[1], clampedPixelRatio);\n\n const controlContainer = this._controlContainer = DOM.create('div', 'maplibregl-control-container', container);\n const positions = this._controlPositions = {};\n ['top-left', 'top-right', 'bottom-left', 'bottom-right'].forEach((positionName) => {\n positions[positionName] = DOM.create('div', `maplibregl-ctrl-${positionName} `, controlContainer);\n });\n\n this._container.addEventListener('scroll', this._onMapScroll, false);\n }\n\n _cooperativeGesturesOnWheel = (event: WheelEvent) => {\n this._onCooperativeGesture(event, event[this._metaKey], 1);\n };\n\n _setupCooperativeGestures() {\n const container = this._container;\n this._cooperativeGesturesScreen = DOM.create('div', 'maplibregl-cooperative-gesture-screen', container);\n let desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.windowsHelpText ? this._cooperativeGestures.windowsHelpText : 'Use Ctrl + scroll to zoom the map';\n if (navigator.platform.indexOf('Mac') === 0) {\n desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.macHelpText ? this._cooperativeGestures.macHelpText : 'Use ⌘ + scroll to zoom the map';\n }\n const mobileMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.mobileHelpText ? this._cooperativeGestures.mobileHelpText : 'Use two fingers to move the map';\n this._cooperativeGesturesScreen.innerHTML = `\n
${desktopMessage}
\n
${mobileMessage}
\n `;\n\n // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures\n this._cooperativeGesturesScreen.setAttribute('aria-hidden', 'true');\n\n // Add event to canvas container since gesture container is pointer-events: none\n this._canvasContainer.addEventListener('wheel', this._cooperativeGesturesOnWheel, false);\n\n // Add a cooperative gestures class (enable touch-action: pan-x pan-y;)\n this._canvasContainer.classList.add('maplibregl-cooperative-gestures');\n }\n\n _destroyCooperativeGestures() {\n DOM.remove(this._cooperativeGesturesScreen);\n this._canvasContainer.removeEventListener('wheel', this._cooperativeGesturesOnWheel, false);\n this._canvasContainer.classList.remove('maplibregl-cooperative-gestures');\n }\n\n _resizeCanvas(width: number, height: number, pixelRatio: number) {\n // Request the required canvas size taking the pixelratio into account.\n this._canvas.width = Math.floor(pixelRatio * width);\n this._canvas.height = Math.floor(pixelRatio * height);\n\n // Maintain the same canvas size, potentially downscaling it for HiDPI displays\n this._canvas.style.width = `${width}px`;\n this._canvas.style.height = `${height}px`;\n }\n\n _setupPainter() {\n\n const attributes = {\n alpha: true,\n stencil: true,\n depth: true,\n failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat,\n preserveDrawingBuffer: this._preserveDrawingBuffer,\n antialias: this._antialias || false\n };\n\n let webglcontextcreationerrorDetailObject: any = null;\n this._canvas.addEventListener('webglcontextcreationerror', (args: WebGLContextEvent) => {\n webglcontextcreationerrorDetailObject = {requestedAttributes: attributes};\n if (args) {\n webglcontextcreationerrorDetailObject.statusMessage = args.statusMessage;\n webglcontextcreationerrorDetailObject.type = args.type;\n }\n }, {once: true});\n\n const gl =\n this._canvas.getContext('webgl2', attributes) as WebGL2RenderingContext ||\n this._canvas.getContext('webgl', attributes) as WebGLRenderingContext;\n\n if (!gl) {\n const msg = 'Failed to initialize WebGL';\n if (webglcontextcreationerrorDetailObject) {\n webglcontextcreationerrorDetailObject.message = msg;\n throw new Error(JSON.stringify(webglcontextcreationerrorDetailObject));\n } else {\n throw new Error(msg);\n }\n }\n\n this.painter = new Painter(gl, this.transform);\n\n webpSupported.testSupport(gl);\n }\n\n _contextLost = (event: any) => {\n event.preventDefault();\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this.fire(new Event('webglcontextlost', {originalEvent: event}));\n };\n\n _contextRestored = (event: any) => {\n this._setupPainter();\n this.resize();\n this._update();\n this.fire(new Event('webglcontextrestored', {originalEvent: event}));\n };\n\n _onMapScroll = (event: any) => {\n if (event.target !== this._container) return;\n\n // Revert any scroll which would move the canvas outside of the view\n this._container.scrollTop = 0;\n this._container.scrollLeft = 0;\n return false;\n };\n\n _onCooperativeGesture(event: any, metaPress, touches) {\n if (!metaPress && touches < 2) {\n // Alert user how to scroll/pan\n this._cooperativeGesturesScreen.classList.add('maplibregl-show');\n setTimeout(() => {\n this._cooperativeGesturesScreen.classList.remove('maplibregl-show');\n }, 100);\n }\n return false;\n }\n\n /**\n * Returns a Boolean indicating whether the map is fully loaded.\n *\n * Returns `false` if the style is not yet fully loaded,\n * or if there has been a change to the sources or style that\n * has not yet fully loaded.\n *\n * @returns A Boolean indicating whether the map is fully loaded.\n */\n loaded(): boolean {\n return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded();\n }\n\n /**\n * @internal\n * Update this map's style and sources, and re-render the map.\n *\n * @param updateStyle - mark the map's style for reprocessing as\n * well as its sources\n * @returns `this`\n */\n _update(updateStyle?: boolean) {\n if (!this.style || !this.style._loaded) return this;\n\n this._styleDirty = this._styleDirty || updateStyle;\n this._sourcesDirty = true;\n this.triggerRepaint();\n\n return this;\n }\n\n /**\n * @internal\n * Request that the given callback be executed during the next render\n * frame. Schedule a render frame if one is not already scheduled.\n *\n * @returns An id that can be used to cancel the callback\n */\n _requestRenderFrame(callback: () => void): TaskID {\n this._update();\n return this._renderTaskQueue.add(callback);\n }\n\n _cancelRenderFrame(id: TaskID) {\n this._renderTaskQueue.remove(id);\n }\n\n /**\n * @internal\n * Call when a (re-)render of the map is required:\n * - The style has changed (`setPaintProperty()`, etc.)\n * - Source data has changed (e.g. tiles have finished loading)\n * - The map has is moving (or just finished moving)\n * - A transition is in progress\n *\n * @param paintStartTimeStamp - The time when the animation frame began executing.\n *\n * @returns `this`\n */\n _render(paintStartTimeStamp: number) {\n const fadeDuration = this._idleTriggered ? this._fadeDuration : 0;\n\n // A custom layer may have used the context asynchronously. Mark the state as dirty.\n this.painter.context.setDirty();\n this.painter.setBaseState();\n\n this._renderTaskQueue.run(paintStartTimeStamp);\n // A task queue callback may have fired a user event which may have removed the map\n if (this._removed) return;\n\n let crossFading = false;\n\n // If the style has changed, the map is being zoomed, or a transition or fade is in progress:\n // - Apply style changes (in a batch)\n // - Recalculate paint properties.\n if (this.style && this._styleDirty) {\n this._styleDirty = false;\n\n const zoom = this.transform.zoom;\n const now = browser.now();\n this.style.zoomHistory.update(zoom, now);\n\n const parameters = new EvaluationParameters(zoom, {\n now,\n fadeDuration,\n zoomHistory: this.style.zoomHistory,\n transition: this.style.getTransition()\n });\n\n const factor = parameters.crossFadingFactor();\n if (factor !== 1 || factor !== this._crossFadingFactor) {\n crossFading = true;\n this._crossFadingFactor = factor;\n }\n\n this.style.update(parameters);\n }\n\n // If we are in _render for any reason other than an in-progress paint\n // transition, update source caches to check for and load any tiles we\n // need for the current transform\n if (this.style && this._sourcesDirty) {\n this._sourcesDirty = false;\n this.style._updateSources(this.transform);\n }\n\n // update terrain stuff\n if (this.terrain) {\n this.terrain.sourceCache.update(this.transform, this.terrain);\n this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n if (!this._elevationFreeze) {\n this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);\n }\n } else {\n this.transform._minEleveationForCurrentTile = 0;\n this.transform.elevation = 0;\n }\n\n this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions);\n\n // Actually draw\n this.painter.render(this.style, {\n showTileBoundaries: this.showTileBoundaries,\n showOverdrawInspector: this._showOverdrawInspector,\n rotating: this.isRotating(),\n zooming: this.isZooming(),\n moving: this.isMoving(),\n fadeDuration,\n showPadding: this.showPadding,\n });\n\n this.fire(new Event('render'));\n\n if (this.loaded() && !this._loaded) {\n this._loaded = true;\n PerformanceUtils.mark(PerformanceMarkers.load);\n this.fire(new Event('load'));\n }\n\n if (this.style && (this.style.hasTransitions() || crossFading)) {\n this._styleDirty = true;\n }\n\n if (this.style && !this._placementDirty) {\n // Since no fade operations are in progress, we can release\n // all tiles held for fading. If we didn't do this, the tiles\n // would just sit in the SourceCaches until the next render\n this.style._releaseSymbolFadeTiles();\n }\n\n // Schedule another render frame if it's needed.\n //\n // Even though `_styleDirty` and `_sourcesDirty` are reset in this\n // method, synchronous events fired during Style#update or\n // Style#_updateSources could have caused them to be set again.\n const somethingDirty = this._sourcesDirty || this._styleDirty || this._placementDirty;\n if (somethingDirty || this._repaint) {\n this.triggerRepaint();\n } else if (!this.isMoving() && this.loaded()) {\n this.fire(new Event('idle'));\n }\n\n if (this._loaded && !this._fullyLoaded && !somethingDirty) {\n this._fullyLoaded = true;\n PerformanceUtils.mark(PerformanceMarkers.fullLoad);\n }\n\n return this;\n }\n\n /**\n * Force a synchronous redraw of the map.\n * @returns `this`\n * @example\n * ```ts\n * map.redraw();\n * ```\n */\n redraw(): this {\n if (this.style) {\n // cancel the scheduled update\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this._render(0);\n }\n return this;\n }\n\n /**\n * Clean up and release all internal resources associated with this map.\n *\n * This includes DOM elements, event bindings, web workers, and WebGL resources.\n *\n * Use this method when you are done using the map and wish to ensure that it no\n * longer consumes browser resources. Afterwards, you must not call any other\n * methods on the map.\n */\n remove() {\n if (this._hash) this._hash.remove();\n\n for (const control of this._controls) control.onRemove(this);\n this._controls = [];\n\n if (this._frame) {\n this._frame.cancel();\n this._frame = null;\n }\n this._renderTaskQueue.clear();\n this.painter.destroy();\n this.handlers.destroy();\n delete this.handlers;\n this.setStyle(null);\n if (typeof window !== 'undefined') {\n removeEventListener('online', this._onWindowOnline, false);\n }\n\n ImageRequest.removeThrottleControl(this._imageQueueHandle);\n\n this._resizeObserver?.disconnect();\n const extension = this.painter.context.gl.getExtension('WEBGL_lose_context');\n if (extension) extension.loseContext();\n this._canvas.removeEventListener('webglcontextrestored', this._contextRestored, false);\n this._canvas.removeEventListener('webglcontextlost', this._contextLost, false);\n DOM.remove(this._canvasContainer);\n DOM.remove(this._controlContainer);\n if (this._cooperativeGestures) {\n this._destroyCooperativeGestures();\n }\n this._container.classList.remove('maplibregl-map');\n\n PerformanceUtils.clearMetrics();\n\n this._removed = true;\n this.fire(new Event('remove'));\n }\n\n /**\n * Trigger the rendering of a single frame. Use this method with custom layers to\n * repaint the map when the layer changes. Calling this multiple times before the\n * next frame is rendered will still result in only a single frame being rendered.\n * @example\n * ```ts\n * map.triggerRepaint();\n * ```\n * @see [Add a 3D model](https://maplibre.org/maplibre-gl-js/docs/examples/add-3d-model/)\n * @see [Add an animated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/)\n */\n triggerRepaint() {\n if (this.style && !this._frame) {\n this._frame = browser.frame((paintStartTimeStamp: number) => {\n PerformanceUtils.frame(paintStartTimeStamp);\n this._frame = null;\n this._render(paintStartTimeStamp);\n });\n }\n }\n\n _onWindowOnline = () => {\n this._update();\n };\n\n /**\n * Gets and sets a Boolean indicating whether the map will render an outline\n * around each tile and the tile ID. These tile boundaries are useful for\n * debugging.\n *\n * The uncompressed file size of the first vector source is drawn in the top left\n * corner of each tile, next to the tile ID.\n *\n * @example\n * ```ts\n * map.showTileBoundaries = true;\n * ```\n */\n get showTileBoundaries(): boolean { return !!this._showTileBoundaries; }\n set showTileBoundaries(value: boolean) {\n if (this._showTileBoundaries === value) return;\n this._showTileBoundaries = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will visualize\n * the padding offsets.\n */\n get showPadding(): boolean { return !!this._showPadding; }\n set showPadding(value: boolean) {\n if (this._showPadding === value) return;\n this._showPadding = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will render boxes\n * around all symbols in the data source, revealing which symbols\n * were rendered or which were hidden due to collisions.\n * This information is useful for debugging.\n */\n get showCollisionBoxes(): boolean { return !!this._showCollisionBoxes; }\n set showCollisionBoxes(value: boolean) {\n if (this._showCollisionBoxes === value) return;\n this._showCollisionBoxes = value;\n if (value) {\n // When we turn collision boxes on we have to generate them for existing tiles\n // When we turn them off, there's no cost to leaving existing boxes in place\n this.style._generateCollisionBoxes();\n } else {\n // Otherwise, call an update to remove collision boxes\n this._update();\n }\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map should color-code\n * each fragment to show how many times it has been shaded.\n * White fragments have been shaded 8 or more times.\n * Black fragments have been shaded 0 times.\n * This information is useful for debugging.\n */\n get showOverdrawInspector(): boolean { return !!this._showOverdrawInspector; }\n set showOverdrawInspector(value: boolean) {\n if (this._showOverdrawInspector === value) return;\n this._showOverdrawInspector = value;\n this._update();\n }\n\n /**\n * Gets and sets a Boolean indicating whether the map will\n * continuously repaint. This information is useful for analyzing performance.\n */\n get repaint(): boolean { return !!this._repaint; }\n set repaint(value: boolean) {\n if (this._repaint !== value) {\n this._repaint = value;\n this.triggerRepaint();\n }\n }\n // show vertices\n get vertices(): boolean { return !!this._vertices; }\n set vertices(value: boolean) { this._vertices = value; this._update(); }\n\n /**\n * Returns the package version of the library\n * @returns Package version of the library\n */\n get version(): string {\n return version;\n }\n\n /**\n * Returns the elevation for the point where the camera is looking.\n * This value corresponds to:\n * \"meters above sea level\" * \"exaggeration\"\n * @returns The elevation.\n */\n getCameraTargetElevation(): number {\n return this.transform.elevation;\n }\n}\n","import type Point from '@mapbox/point-geometry';\n\nimport {DragMoveHandler, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';\nimport {OneFingerTouchMoveStateManager} from './drag_move_state_manager';\n\nexport interface OneFingerTouchRotateHandler extends DragMoveHandler {}\nexport interface OneFingerTouchPitchHandler extends DragMoveHandler {}\n\nconst assignEvents = (handler: DragHandler) => {\n handler.touchstart = handler.dragStart;\n handler.touchmoveWindow = handler.dragMove;\n handler.touchend = handler.dragEnd;\n};\n\nexport const generateOneFingerTouchRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: {\n clickTolerance: number;\n bearingDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): OneFingerTouchRotateHandler => {\n const touchMoveStateManager = new OneFingerTouchMoveStateManager();\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}),\n moveStateManager: touchMoveStateManager,\n enable,\n assignEvents,\n });\n};\n\nexport const generateOneFingerTouchPitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: {\n clickTolerance: number;\n pitchDegreesPerPixelMoved?: number;\n enable?: boolean;\n}): OneFingerTouchPitchHandler => {\n const touchMoveStateManager = new OneFingerTouchMoveStateManager();\n return new DragHandler({\n clickTolerance,\n move: (lastPoint: Point, point: Point) =>\n ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}),\n moveStateManager: touchMoveStateManager,\n enable,\n assignEvents,\n });\n};\n","import Point from '@mapbox/point-geometry';\n\nimport {DOM} from '../../util/dom';\nimport {extend} from '../../util/util';\nimport {generateMousePitchHandler, generateMouseRotationHandler, MousePitchHandler, MouseRotateHandler} from '../handler/mouse';\nimport {generateOneFingerTouchPitchHandler, generateOneFingerTouchRotationHandler, OneFingerTouchPitchHandler, OneFingerTouchRotateHandler} from '../handler/one_finger_touch_drag';\n\nimport type {Map} from '../map';\nimport type {IControl} from './control';\n\n/**\n * The {@link NavigationControl} options object\n */\ntype NavigationOptions = {\n /**\n * If `true` the compass button is included.\n */\n showCompass?: boolean;\n /**\n * If `true` the zoom-in and zoom-out buttons are included.\n */\n showZoom?: boolean;\n /**\n * If `true` the pitch is visualized by rotating X-axis of compass.\n */\n visualizePitch?: boolean;\n};\n\nconst defaultOptions: NavigationOptions = {\n showCompass: true,\n showZoom: true,\n visualizePitch: false\n};\n\n/**\n * A `NavigationControl` control contains zoom buttons and a compass.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let nav = new maplibregl.NavigationControl();\n * map.addControl(nav, 'top-left');\n * ```\n * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)\n */\nexport class NavigationControl implements IControl {\n _map: Map;\n options: NavigationOptions;\n _container: HTMLElement;\n _zoomInButton: HTMLButtonElement;\n _zoomOutButton: HTMLButtonElement;\n _compass: HTMLButtonElement;\n _compassIcon: HTMLElement;\n _handler: MouseRotateWrapper;\n\n /**\n * @param options - the control's options\n */\n constructor(options?: NavigationOptions) {\n this.options = extend({}, defaultOptions, options);\n\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._container.addEventListener('contextmenu', (e) => e.preventDefault());\n\n if (this.options.showZoom) {\n this._zoomInButton = this._createButton('maplibregl-ctrl-zoom-in', (e) => this._map.zoomIn({}, {originalEvent: e}));\n DOM.create('span', 'maplibregl-ctrl-icon', this._zoomInButton).setAttribute('aria-hidden', 'true');\n this._zoomOutButton = this._createButton('maplibregl-ctrl-zoom-out', (e) => this._map.zoomOut({}, {originalEvent: e}));\n DOM.create('span', 'maplibregl-ctrl-icon', this._zoomOutButton).setAttribute('aria-hidden', 'true');\n }\n if (this.options.showCompass) {\n this._compass = this._createButton('maplibregl-ctrl-compass', (e) => {\n if (this.options.visualizePitch) {\n this._map.resetNorthPitch({}, {originalEvent: e});\n } else {\n this._map.resetNorth({}, {originalEvent: e});\n }\n });\n this._compassIcon = DOM.create('span', 'maplibregl-ctrl-icon', this._compass);\n this._compassIcon.setAttribute('aria-hidden', 'true');\n }\n }\n\n _updateZoomButtons = () => {\n const zoom = this._map.getZoom();\n const isMax = zoom === this._map.getMaxZoom();\n const isMin = zoom === this._map.getMinZoom();\n this._zoomInButton.disabled = isMax;\n this._zoomOutButton.disabled = isMin;\n this._zoomInButton.setAttribute('aria-disabled', isMax.toString());\n this._zoomOutButton.setAttribute('aria-disabled', isMin.toString());\n };\n\n _rotateCompassArrow = () => {\n const rotate = this.options.visualizePitch ?\n `scale(${1 / Math.pow(Math.cos(this._map.transform.pitch * (Math.PI / 180)), 0.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle * (180 / Math.PI)}deg)` :\n `rotate(${this._map.transform.angle * (180 / Math.PI)}deg)`;\n\n this._compassIcon.style.transform = rotate;\n };\n\n onAdd(map: Map) {\n this._map = map;\n if (this.options.showZoom) {\n this._setButtonTitle(this._zoomInButton, 'ZoomIn');\n this._setButtonTitle(this._zoomOutButton, 'ZoomOut');\n this._map.on('zoom', this._updateZoomButtons);\n this._updateZoomButtons();\n }\n if (this.options.showCompass) {\n this._setButtonTitle(this._compass, 'ResetBearing');\n if (this.options.visualizePitch) {\n this._map.on('pitch', this._rotateCompassArrow);\n }\n this._map.on('rotate', this._rotateCompassArrow);\n this._rotateCompassArrow();\n this._handler = new MouseRotateWrapper(this._map, this._compass, this.options.visualizePitch);\n }\n return this._container;\n }\n\n onRemove() {\n DOM.remove(this._container);\n if (this.options.showZoom) {\n this._map.off('zoom', this._updateZoomButtons);\n }\n if (this.options.showCompass) {\n if (this.options.visualizePitch) {\n this._map.off('pitch', this._rotateCompassArrow);\n }\n this._map.off('rotate', this._rotateCompassArrow);\n this._handler.off();\n delete this._handler;\n }\n\n delete this._map;\n }\n\n _createButton(className: string, fn: (e?: any) => unknown) {\n const a = DOM.create('button', className, this._container) as HTMLButtonElement;\n a.type = 'button';\n a.addEventListener('click', fn);\n return a;\n }\n\n _setButtonTitle = (button: HTMLButtonElement, title: string) => {\n const str = this._map._getUIString(`NavigationControl.${title}`);\n button.title = str;\n button.setAttribute('aria-label', str);\n };\n}\n\nclass MouseRotateWrapper {\n\n map: Map;\n _clickTolerance: number;\n element: HTMLElement;\n // Rotation and pitch handlers are separated due to different _clickTolerance values\n mouseRotate: MouseRotateHandler;\n touchRotate: OneFingerTouchRotateHandler;\n mousePitch: MousePitchHandler;\n touchPitch: OneFingerTouchPitchHandler;\n _startPos: Point;\n _lastPos: Point;\n\n constructor(map: Map, element: HTMLElement, pitch: boolean = false) {\n this._clickTolerance = 10;\n const mapRotateTolerance = map.dragRotate._mouseRotate.getClickTolerance();\n const mapPitchTolerance = map.dragRotate._mousePitch.getClickTolerance();\n this.element = element;\n this.mouseRotate = generateMouseRotationHandler({clickTolerance: mapRotateTolerance, enable: true});\n this.touchRotate = generateOneFingerTouchRotationHandler({clickTolerance: mapRotateTolerance, enable: true});\n this.map = map;\n if (pitch) {\n this.mousePitch = generateMousePitchHandler({clickTolerance: mapPitchTolerance, enable: true});\n this.touchPitch = generateOneFingerTouchPitchHandler({clickTolerance: mapPitchTolerance, enable: true});\n }\n\n DOM.addEventListener(element, 'mousedown', this.mousedown);\n DOM.addEventListener(element, 'touchstart', this.touchstart, {passive: false});\n DOM.addEventListener(element, 'touchcancel', this.reset);\n }\n\n startMouse(e: MouseEvent, point: Point) {\n this.mouseRotate.dragStart(e, point);\n if (this.mousePitch) this.mousePitch.dragStart(e, point);\n DOM.disableDrag();\n }\n\n startTouch(e: TouchEvent, point: Point) {\n this.touchRotate.dragStart(e, point);\n if (this.touchPitch) this.touchPitch.dragStart(e, point);\n DOM.disableDrag();\n }\n\n moveMouse(e: MouseEvent, point: Point) {\n const map = this.map;\n const {bearingDelta} = this.mouseRotate.dragMove(e, point) || {};\n if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta);\n if (this.mousePitch) {\n const {pitchDelta} = this.mousePitch.dragMove(e, point) || {};\n if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta);\n }\n }\n\n moveTouch(e: TouchEvent, point: Point) {\n const map = this.map;\n const {bearingDelta} = this.touchRotate.dragMove(e, point) || {};\n if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta);\n if (this.touchPitch) {\n const {pitchDelta} = this.touchPitch.dragMove(e, point) || {};\n if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta);\n }\n }\n\n off() {\n const element = this.element;\n DOM.removeEventListener(element, 'mousedown', this.mousedown);\n DOM.removeEventListener(element, 'touchstart', this.touchstart, {passive: false});\n DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.removeEventListener(window, 'touchend', this.touchend);\n DOM.removeEventListener(element, 'touchcancel', this.reset);\n this.offTemp();\n }\n\n offTemp() {\n DOM.enableDrag();\n DOM.removeEventListener(window, 'mousemove', this.mousemove);\n DOM.removeEventListener(window, 'mouseup', this.mouseup);\n DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.removeEventListener(window, 'touchend', this.touchend);\n }\n\n mousedown = (e: MouseEvent) => {\n this.startMouse(extend({}, e, {ctrlKey: true, preventDefault: () => e.preventDefault()}), DOM.mousePos(this.element, e));\n DOM.addEventListener(window, 'mousemove', this.mousemove);\n DOM.addEventListener(window, 'mouseup', this.mouseup);\n };\n\n mousemove = (e: MouseEvent) => {\n this.moveMouse(e, DOM.mousePos(this.element, e));\n };\n\n mouseup = (e: MouseEvent) => {\n this.mouseRotate.dragEnd(e);\n if (this.mousePitch) this.mousePitch.dragEnd(e);\n this.offTemp();\n };\n\n touchstart = (e: TouchEvent) => {\n if (e.targetTouches.length !== 1) {\n this.reset();\n } else {\n this._startPos = this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0];\n this.startTouch(e, this._startPos);\n DOM.addEventListener(window, 'touchmove', this.touchmove, {passive: false});\n DOM.addEventListener(window, 'touchend', this.touchend);\n }\n };\n\n touchmove = (e: TouchEvent) => {\n if (e.targetTouches.length !== 1) {\n this.reset();\n } else {\n this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0];\n this.moveTouch(e, this._lastPos);\n }\n };\n\n touchend = (e: TouchEvent) => {\n if (e.targetTouches.length === 0 &&\n this._startPos &&\n this._lastPos &&\n this._startPos.dist(this._lastPos) < this._clickTolerance) {\n this.element.click();\n }\n delete this._startPos;\n delete this._lastPos;\n this.offTemp();\n };\n\n reset = () => {\n this.mouseRotate.reset();\n if (this.mousePitch) this.mousePitch.reset();\n this.touchRotate.reset();\n if (this.touchPitch) this.touchPitch.reset();\n delete this._startPos;\n delete this._lastPos;\n this.offTemp();\n };\n}\n","let supportsGeolocation;\n\nexport function checkGeolocationSupport(callback: (supported: boolean) => void, forceRecalculation = false): void {\n if (supportsGeolocation !== undefined && !forceRecalculation) {\n callback(supportsGeolocation);\n } else if (window.navigator.permissions !== undefined) {\n // navigator.permissions has incomplete browser support\n // http://caniuse.com/#feat=permissions-api\n // Test for the case where a browser disables Geolocation because of an\n // insecure origin\n window.navigator.permissions.query({name: 'geolocation'}).then((p) => {\n supportsGeolocation = p.state !== 'denied';\n callback(supportsGeolocation);\n }).catch(() => {\n // Fix for iOS16 which rejects query but still supports geolocation\n supportsGeolocation = !!window.navigator.geolocation;\n callback(supportsGeolocation);\n });\n\n } else {\n supportsGeolocation = !!window.navigator.geolocation;\n callback(supportsGeolocation);\n }\n}\n","import {LngLat} from '../geo/lng_lat';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {Transform} from '../geo/transform';\n\n/**\n * Given a LngLat, prior projected position, and a transform, return a new LngLat shifted\n * n × 360° east or west for some n ≥ 0 such that:\n *\n * * the projected location of the result is on screen, if possible, and secondarily:\n * * the difference between the projected location of the result and the prior position\n * is minimized.\n *\n * The object is to preserve perceived object constancy for Popups and Markers as much as\n * possible; they should avoid shifting large distances across the screen, even when the\n * map center changes by ±360° due to automatic wrapping, and when about to go off screen,\n * should wrap just enough to avoid doing so.\n */\nexport function smartWrap(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {\n lngLat = new LngLat(lngLat.lng, lngLat.lat);\n\n // First, try shifting one world in either direction, and see if either is closer to the\n // prior position. This preserves object constancy when the map center is auto-wrapped\n // during animations.\n if (priorPos) {\n const left = new LngLat(lngLat.lng - 360, lngLat.lat);\n const right = new LngLat(lngLat.lng + 360, lngLat.lat);\n const delta = transform.locationPoint(lngLat).distSqr(priorPos);\n if (transform.locationPoint(left).distSqr(priorPos) < delta) {\n lngLat = left;\n } else if (transform.locationPoint(right).distSqr(priorPos) < delta) {\n lngLat = right;\n }\n }\n\n // Second, wrap toward the center until the new position is on screen, or we can't get\n // any closer.\n while (Math.abs(lngLat.lng - transform.center.lng) > 180) {\n const pos = transform.locationPoint(lngLat);\n if (pos.x >= 0 && pos.y >= 0 && pos.x <= transform.width && pos.y <= transform.height) {\n break;\n }\n if (lngLat.lng > transform.center.lng) {\n lngLat.lng -= 360;\n } else {\n lngLat.lng += 360;\n }\n }\n\n return lngLat;\n}\n","/**\n * Where to position the anchor.\n * Used by a popup and a marker.\n */\nexport type PositionAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport const anchorTranslate: {\n [_ in PositionAnchor]: string;\n} = {\n 'center': 'translate(-50%,-50%)',\n 'top': 'translate(-50%,0)',\n 'top-left': 'translate(0,0)',\n 'top-right': 'translate(-100%,0)',\n 'bottom': 'translate(-50%,-100%)',\n 'bottom-left': 'translate(0,-100%)',\n 'bottom-right': 'translate(-100%,-100%)',\n 'left': 'translate(0,-50%)',\n 'right': 'translate(-100%,-50%)'\n};\n\nexport function applyAnchorClass(element: HTMLElement, anchor: PositionAnchor, prefix: string) {\n const classList = element.classList;\n for (const key in anchorTranslate) {\n classList.remove(`maplibregl-${prefix}-anchor-${key}`);\n }\n classList.add(`maplibregl-${prefix}-anchor-${anchor}`);\n}\n","import {DOM} from '../util/dom';\nimport {LngLat} from '../geo/lng_lat';\nimport Point from '@mapbox/point-geometry';\nimport {smartWrap} from '../util/smart_wrap';\nimport {anchorTranslate, applyAnchorClass} from './anchor';\nimport type {PositionAnchor} from './anchor';\nimport {Event, Evented} from '../util/evented';\nimport type {Map} from './map';\nimport {Popup, Offset} from './popup';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {MapMouseEvent, MapTouchEvent} from './events';\nimport type {PointLike} from './camera';\n\n/**\n * Alignment options of rotation and pitch\n */\ntype Alignment = 'map' | 'viewport' | 'auto';\n\n/**\n * The {@link Marker} options object\n */\ntype MarkerOptions = {\n /**\n * DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker.\n */\n element?: HTMLElement;\n /**\n * Space-separated CSS class names to add to marker element.\n */\n className?: string;\n /**\n * The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.\n */\n offset?: PointLike;\n /**\n * A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}.\n * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`.\n * @defaultValue 'center'\n * */\n anchor?: PositionAnchor;\n /**\n * The color to use for the default marker if options.element is not provided. The default is light blue.\n * @defaultValue '#3FB1CE'\n */\n color?: string;\n /**\n * The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`.\n * @defaultValue 1\n */\n scale?: number;\n /**\n * A boolean indicating whether or not a marker is able to be dragged to a new position on the map.\n * @defaultValue false\n */\n draggable?: boolean;\n /**\n * The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance.\n * @defaultValue 0\n */\n clickTolerance?: number;\n /**\n * The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise.\n * @defaultValue 0\n */\n rotation?: number;\n /**\n * `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`.\n * @defaultValue 'auto'\n */\n rotationAlignment?: Alignment;\n /**\n * `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`.\n * @defaultValue 'auto'\n */\n pitchAlignment?: Alignment;\n};\n\n/**\n * Creates a marker component\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([30.5, 50.5])\n * .addTo(map);\n * ```\n *\n * @example\n * Set options\n * ```ts\n * let marker = new maplibregl.Marker({\n * color: \"#FFFFFF\",\n * draggable: true\n * }).setLngLat([30.5, 50.5])\n * .addTo(map);\n * ```\n * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n *\n * ### Events\n *\n * @event `dragstart` Fired when dragging starts, `marker` object that is being dragged\n *\n * @event `drag` Fired while dragging. `marker` object that is being dragged\n *\n * @event `dragend` Fired when the marker is finished being dragged, `marker` object that was dragged\n */\nexport class Marker extends Evented {\n _map: Map;\n _anchor: PositionAnchor;\n _offset: Point;\n _element: HTMLElement;\n _popup: Popup;\n _lngLat: LngLat;\n _pos: Point;\n _color: string;\n _scale: number;\n _defaultMarker: boolean;\n _draggable: boolean;\n _clickTolerance: number;\n _isDragging: boolean;\n _state: 'inactive' | 'pending' | 'active'; // used for handling drag events\n _positionDelta: Point;\n _pointerdownPos: Point;\n _rotation: number;\n _pitchAlignment: Alignment;\n _rotationAlignment: Alignment;\n _originalTabIndex: string; // original tabindex of _element\n _opacityTimeout: ReturnType;\n\n /**\n * @param options - the options\n */\n constructor(options?: MarkerOptions) {\n super();\n\n this._anchor = options && options.anchor || 'center';\n this._color = options && options.color || '#3FB1CE';\n this._scale = options && options.scale || 1;\n this._draggable = options && options.draggable || false;\n this._clickTolerance = options && options.clickTolerance || 0;\n this._isDragging = false;\n this._state = 'inactive';\n this._rotation = options && options.rotation || 0;\n this._rotationAlignment = options && options.rotationAlignment || 'auto';\n this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment;\n\n if (!options || !options.element) {\n this._defaultMarker = true;\n this._element = DOM.create('div');\n this._element.setAttribute('aria-label', 'Map marker');\n\n // create default map marker SVG\n const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg');\n const defaultHeight = 41;\n const defaultWidth = 27;\n svg.setAttributeNS(null, 'display', 'block');\n svg.setAttributeNS(null, 'height', `${defaultHeight}px`);\n svg.setAttributeNS(null, 'width', `${defaultWidth}px`);\n svg.setAttributeNS(null, 'viewBox', `0 0 ${defaultWidth} ${defaultHeight}`);\n\n const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n markerLarge.setAttributeNS(null, 'stroke', 'none');\n markerLarge.setAttributeNS(null, 'stroke-width', '1');\n markerLarge.setAttributeNS(null, 'fill', 'none');\n markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd');\n\n const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n page1.setAttributeNS(null, 'fill-rule', 'nonzero');\n\n const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)');\n shadow.setAttributeNS(null, 'fill', '#000000');\n\n const ellipses = [\n {'rx': '10.5', 'ry': '5.25002273'},\n {'rx': '10.5', 'ry': '5.25002273'},\n {'rx': '9.5', 'ry': '4.77275007'},\n {'rx': '8.5', 'ry': '4.29549936'},\n {'rx': '7.5', 'ry': '3.81822308'},\n {'rx': '6.5', 'ry': '3.34094679'},\n {'rx': '5.5', 'ry': '2.86367051'},\n {'rx': '4.5', 'ry': '2.38636864'}\n ];\n\n for (const data of ellipses) {\n const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse');\n ellipse.setAttributeNS(null, 'opacity', '0.04');\n ellipse.setAttributeNS(null, 'cx', '10.5');\n ellipse.setAttributeNS(null, 'cy', '5.80029008');\n ellipse.setAttributeNS(null, 'rx', data['rx']);\n ellipse.setAttributeNS(null, 'ry', data['ry']);\n shadow.appendChild(ellipse);\n }\n\n const background = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n background.setAttributeNS(null, 'fill', this._color);\n\n const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');\n bgPath.setAttributeNS(null, 'd', 'M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z');\n\n background.appendChild(bgPath);\n\n const border = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n border.setAttributeNS(null, 'opacity', '0.25');\n border.setAttributeNS(null, 'fill', '#000000');\n\n const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path');\n borderPath.setAttributeNS(null, 'd', 'M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z');\n\n border.appendChild(borderPath);\n\n const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)');\n maki.setAttributeNS(null, 'fill', '#FFFFFF');\n\n const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g');\n circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)');\n\n const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');\n circle1.setAttributeNS(null, 'fill', '#000000');\n circle1.setAttributeNS(null, 'opacity', '0.25');\n circle1.setAttributeNS(null, 'cx', '5.5');\n circle1.setAttributeNS(null, 'cy', '5.5');\n circle1.setAttributeNS(null, 'r', '5.4999962');\n\n const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle');\n circle2.setAttributeNS(null, 'fill', '#FFFFFF');\n circle2.setAttributeNS(null, 'cx', '5.5');\n circle2.setAttributeNS(null, 'cy', '5.5');\n circle2.setAttributeNS(null, 'r', '5.4999962');\n\n circleContainer.appendChild(circle1);\n circleContainer.appendChild(circle2);\n\n page1.appendChild(shadow);\n page1.appendChild(background);\n page1.appendChild(border);\n page1.appendChild(maki);\n page1.appendChild(circleContainer);\n\n svg.appendChild(page1);\n\n svg.setAttributeNS(null, 'height', `${defaultHeight * this._scale}px`);\n svg.setAttributeNS(null, 'width', `${defaultWidth * this._scale}px`);\n\n this._element.appendChild(svg);\n\n // if no element and no offset option given apply an offset for the default marker\n // the -14 as the y value of the default marker offset was determined as follows\n //\n // the marker tip is at the center of the shadow ellipse from the default svg\n // the y value of the center of the shadow ellipse relative to the svg top left is \"shadow transform translate-y (29.0) + ellipse cy (5.80029008)\"\n // offset to the svg center \"height (41 / 2)\" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14\n // negative is used to move the marker up from the center so the tip is at the Marker lngLat\n this._offset = Point.convert(options && options.offset || [0, -14]);\n } else {\n this._element = options.element;\n this._offset = Point.convert(options && options.offset || [0, 0]);\n }\n\n this._element.classList.add('maplibregl-marker');\n this._element.addEventListener('dragstart', (e: DragEvent) => {\n e.preventDefault();\n });\n this._element.addEventListener('mousedown', (e: MouseEvent) => {\n // prevent focusing on click\n e.preventDefault();\n });\n applyAnchorClass(this._element, this._anchor, 'marker');\n\n if (options && options.className) {\n for (const name of options.className.split(' ')) {\n this._element.classList.add(name);\n }\n }\n\n this._popup = null;\n }\n\n /**\n * Attaches the `Marker` to a `Map` object.\n * @param map - The MapLibre GL JS map to add the marker to.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([30.5, 50.5])\n * .addTo(map); // add the marker to the map\n * ```\n */\n addTo(map: Map): this {\n this.remove();\n this._map = map;\n map.getCanvasContainer().appendChild(this._element);\n map.on('move', this._update);\n map.on('moveend', this._update);\n map.on('terrain', this._update);\n\n this.setDraggable(this._draggable);\n this._update();\n\n // If we attached the `click` listener to the marker element, the popup\n // would close once the event propagated to `map` due to the\n // `Popup#_onClickClose` listener.\n this._map.on('click', this._onMapClick);\n\n return this;\n }\n\n /**\n * Removes the marker from a map\n * @example\n * ```ts\n * let marker = new maplibregl.Marker().addTo(map);\n * marker.remove();\n * ```\n * @returns `this`\n */\n remove(): this {\n if (this._opacityTimeout) {\n clearTimeout(this._opacityTimeout);\n delete this._opacityTimeout;\n }\n if (this._map) {\n this._map.off('click', this._onMapClick);\n this._map.off('move', this._update);\n this._map.off('moveend', this._update);\n this._map.off('mousedown', this._addDragHandler);\n this._map.off('touchstart', this._addDragHandler);\n this._map.off('mouseup', this._onUp);\n this._map.off('touchend', this._onUp);\n this._map.off('mousemove', this._onMove);\n this._map.off('touchmove', this._onMove);\n delete this._map;\n }\n DOM.remove(this._element);\n if (this._popup) this._popup.remove();\n return this;\n }\n\n /**\n * Get the marker's geographical location.\n *\n * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously\n * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep\n * the marker on screen.\n *\n * @returns A {@link LngLat} describing the marker's location.\n * @example\n * ```ts\n * // Store the marker's longitude and latitude coordinates in a variable\n * let lngLat = marker.getLngLat();\n * // Print the marker's longitude and latitude values in the console\n * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat )\n * ```\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n /**\n * Set the marker's geographical position and move it.\n * @param lnglat - A {@link LngLat} describing where the marker should be located.\n * @returns `this`\n * @example\n * Create a new marker, set the longitude and latitude, and add it to the map\n * ```ts\n * new maplibregl.Marker()\n * .setLngLat([-65.017, -16.457])\n * .addTo(map);\n * ```\n * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/)\n * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)\n */\n setLngLat(lnglat: LngLatLike): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n if (this._popup) this._popup.setLngLat(this._lngLat);\n this._update();\n return this;\n }\n\n /**\n * Returns the `Marker`'s HTML element.\n * @returns element\n */\n getElement(): HTMLElement {\n return this._element;\n }\n\n /**\n * Binds a {@link Popup} to the {@link Marker}.\n * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup\n * set on this {@link Marker} instance is unset.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\")) // add popup\n * .addTo(map);\n * ```\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n */\n setPopup(popup?: Popup | null): this {\n if (this._popup) {\n this._popup.remove();\n this._popup = null;\n this._element.removeEventListener('keypress', this._onKeyPress);\n\n if (!this._originalTabIndex) {\n this._element.removeAttribute('tabindex');\n }\n }\n\n if (popup) {\n if (!('offset' in popup.options)) {\n const markerHeight = 41 - (5.8 / 2);\n const markerRadius = 13.5;\n const linearOffset = Math.abs(markerRadius) / Math.SQRT2;\n popup.options.offset = this._defaultMarker ? {\n 'top': [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n 'bottom': [0, -markerHeight],\n 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n 'left': [markerRadius, (markerHeight - markerRadius) * -1],\n 'right': [-markerRadius, (markerHeight - markerRadius) * -1]\n } as Offset : this._offset;\n }\n this._popup = popup;\n if (this._lngLat) this._popup.setLngLat(this._lngLat);\n\n this._originalTabIndex = this._element.getAttribute('tabindex');\n if (!this._originalTabIndex) {\n this._element.setAttribute('tabindex', '0');\n }\n this._element.addEventListener('keypress', this._onKeyPress);\n }\n\n return this;\n }\n\n _onKeyPress = (e: KeyboardEvent) => {\n const code = e.code;\n const legacyCode = e.charCode || e.keyCode;\n\n if (\n (code === 'Space') || (code === 'Enter') ||\n (legacyCode === 32) || (legacyCode === 13) // space or enter\n ) {\n this.togglePopup();\n }\n };\n\n _onMapClick = (e: MapMouseEvent) => {\n const targetElement = e.originalEvent.target;\n const element = this._element;\n\n if (this._popup && (targetElement === element || element.contains(targetElement as any))) {\n this.togglePopup();\n }\n };\n\n /**\n * Returns the {@link Popup} instance that is bound to the {@link Marker}.\n * @returns popup\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\"))\n * .addTo(map);\n *\n * console.log(marker.getPopup()); // return the popup instance\n * ```\n */\n getPopup(): Popup {\n return this._popup;\n }\n\n /**\n * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}.\n * @returns `this`\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * .setLngLat([0, 0])\n * .setPopup(new maplibregl.Popup().setHTML(\"

Hello World!

\"))\n * .addTo(map);\n *\n * marker.togglePopup(); // toggle popup open or closed\n * ```\n */\n togglePopup(): this {\n const popup = this._popup;\n\n if (!popup) return this;\n else if (popup.isOpen()) popup.remove();\n else popup.addTo(this._map);\n return this;\n }\n\n _update = (e?: { type: 'move' | 'moveend' | 'terrain' | 'render' }) => {\n if (!this._map) return;\n\n const isFullyLoaded = this._map.loaded() && !this._map.isMoving();\n if (e?.type === 'terrain' || (e?.type === 'render' && !isFullyLoaded)) {\n this._map.once('render', this._update);\n }\n\n if (this._map.transform.renderWorldCopies) {\n this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);\n }\n\n this._pos = this._map.project(this._lngLat)._add(this._offset);\n\n let rotation = '';\n if (this._rotationAlignment === 'viewport' || this._rotationAlignment === 'auto') {\n rotation = `rotateZ(${this._rotation}deg)`;\n } else if (this._rotationAlignment === 'map') {\n rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`;\n }\n\n let pitch = '';\n if (this._pitchAlignment === 'viewport' || this._pitchAlignment === 'auto') {\n pitch = 'rotateX(0deg)';\n } else if (this._pitchAlignment === 'map') {\n pitch = `rotateX(${this._map.getPitch()}deg)`;\n }\n\n // because rounding the coordinates at every `move` event causes stuttered zooming\n // we only round them when _update is called with `moveend` or when its called with\n // no arguments (when the Marker is initialized or Marker#setLngLat is invoked).\n if (!e || e.type === 'moveend') {\n this._pos = this._pos.round();\n }\n\n DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`);\n\n // in case of 3D, ask the terrain coords-framebuffer for this pos and check if the marker is visible\n // call this logic in setTimeout with a timeout of 100ms to save performance in map-movement\n if (this._map.terrain && !this._opacityTimeout) this._opacityTimeout = setTimeout(() => {\n const lnglat = this._map.unproject(this._pos);\n const metresPerPixel = 40075016.686 * Math.abs(Math.cos(this._lngLat.lat * Math.PI / 180)) / Math.pow(2, this._map.transform.tileZoom + 8);\n this._element.style.opacity = lnglat.distanceTo(this._lngLat) > metresPerPixel * 20 ? '0.2' : '1.0';\n this._opacityTimeout = null;\n }, 100);\n };\n\n /**\n * Get the marker's offset.\n * @returns The marker's screen coordinates in pixels.\n */\n getOffset(): Point {\n return this._offset;\n }\n\n /**\n * Sets the offset of the marker\n * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up.\n * @returns `this`\n */\n setOffset(offset: PointLike): this {\n this._offset = Point.convert(offset);\n this._update();\n return this;\n }\n\n /**\n * Adds a CSS class to the marker element.\n *\n * @param className - on-empty string with CSS class name to add to marker element\n *\n * @example\n * ```\n * let marker = new maplibregl.Marker()\n * marker.addClassName('some-class')\n * ```\n */\n addClassName(className: string) {\n this._element.classList.add(className);\n }\n\n /**\n * Removes a CSS class from the marker element.\n *\n * @param className - Non-empty string with CSS class name to remove from marker element\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * marker.removeClassName('some-class')\n * ```\n */\n removeClassName(className: string) {\n this._element.classList.remove(className);\n }\n\n /**\n * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class.\n *\n * @param className - Non-empty string with CSS class name to add/remove\n *\n * @returns if the class was removed return false, if class was added, then return true\n *\n * @example\n * ```ts\n * let marker = new maplibregl.Marker()\n * marker.toggleClassName('toggleClass')\n * ```\n */\n toggleClassName(className: string): boolean {\n return this._element.classList.toggle(className);\n }\n\n _onMove = (e: MapMouseEvent | MapTouchEvent) => {\n if (!this._isDragging) {\n const clickTolerance = this._clickTolerance || this._map._clickTolerance;\n this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance;\n }\n if (!this._isDragging) return;\n\n this._pos = e.point.sub(this._positionDelta);\n this._lngLat = this._map.unproject(this._pos);\n this.setLngLat(this._lngLat);\n // suppress click event so that popups don't toggle on drag\n this._element.style.pointerEvents = 'none';\n\n // make sure dragstart only fires on the first move event after mousedown.\n // this can't be on mousedown because that event doesn't necessarily\n // imply that a drag is about to happen.\n if (this._state === 'pending') {\n this._state = 'active';\n this.fire(new Event('dragstart'));\n }\n this.fire(new Event('drag'));\n };\n\n _onUp = () => {\n // revert to normal pointer event handling\n this._element.style.pointerEvents = 'auto';\n this._positionDelta = null;\n this._pointerdownPos = null;\n this._isDragging = false;\n this._map.off('mousemove', this._onMove);\n this._map.off('touchmove', this._onMove);\n\n // only fire dragend if it was preceded by at least one drag event\n if (this._state === 'active') {\n this.fire(new Event('dragend'));\n }\n\n this._state = 'inactive';\n };\n\n _addDragHandler = (e: MapMouseEvent | MapTouchEvent) => {\n if (this._element.contains(e.originalEvent.target as any)) {\n e.preventDefault();\n\n // We need to calculate the pixel distance between the click point\n // and the marker position, with the offset accounted for. Then we\n // can subtract this distance from the mousemove event's position\n // to calculate the new marker position.\n // If we don't do this, the marker 'jumps' to the click position\n // creating a jarring UX effect.\n this._positionDelta = e.point.sub(this._pos).add(this._offset);\n\n this._pointerdownPos = e.point;\n\n this._state = 'pending';\n this._map.on('mousemove', this._onMove);\n this._map.on('touchmove', this._onMove);\n this._map.once('mouseup', this._onUp);\n this._map.once('touchend', this._onUp);\n }\n };\n\n /**\n * Sets the `draggable` property and functionality of the marker\n * @param shouldBeDraggable - Turns drag functionality on/off\n * @returns `this`\n */\n setDraggable(shouldBeDraggable?: boolean): this {\n this._draggable = !!shouldBeDraggable; // convert possible undefined value to false\n\n // handle case where map may not exist yet\n // e.g. when setDraggable is called before addTo\n if (this._map) {\n if (shouldBeDraggable) {\n this._map.on('mousedown', this._addDragHandler);\n this._map.on('touchstart', this._addDragHandler);\n } else {\n this._map.off('mousedown', this._addDragHandler);\n this._map.off('touchstart', this._addDragHandler);\n }\n }\n\n return this;\n }\n\n /**\n * Returns true if the marker can be dragged\n * @returns True if the marker is draggable.\n */\n isDraggable(): boolean {\n return this._draggable;\n }\n\n /**\n * Sets the `rotation` property of the marker.\n * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting.\n * @returns `this`\n */\n setRotation(rotation?: number): this {\n this._rotation = rotation || 0;\n this._update();\n return this;\n }\n\n /**\n * Returns the current rotation angle of the marker (in degrees).\n * @returns The current rotation angle of the marker.\n */\n getRotation(): number {\n return this._rotation;\n }\n\n /**\n * Sets the `rotationAlignment` property of the marker.\n * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto'\n * @returns `this`\n */\n setRotationAlignment(alignment?: Alignment): this {\n this._rotationAlignment = alignment || 'auto';\n this._update();\n return this;\n }\n\n /**\n * Returns the current `rotationAlignment` property of the marker.\n * @returns The current rotational alignment of the marker.\n */\n getRotationAlignment(): Alignment {\n return this._rotationAlignment;\n }\n\n /**\n * Sets the `pitchAlignment` property of the marker.\n * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`.\n * @returns `this`\n */\n setPitchAlignment(alignment?: Alignment): this {\n this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment;\n this._update();\n return this;\n }\n\n /**\n * Returns the current `pitchAlignment` property of the marker.\n * @returns The current pitch alignment of the marker in degrees.\n */\n getPitchAlignment(): Alignment {\n return this._pitchAlignment;\n }\n}\n","import {Event, Evented} from '../../util/evented';\nimport {DOM} from '../../util/dom';\nimport {extend, warnOnce} from '../../util/util';\nimport {checkGeolocationSupport} from '../../util/geolocation_support';\nimport {LngLat} from '../../geo/lng_lat';\nimport {Marker} from '../marker';\n\nimport type {Map} from '../map';\nimport type {FitBoundsOptions} from '../camera';\nimport type {IControl} from './control';\nimport {LngLatBounds} from '../../geo/lng_lat_bounds';\n\n/**\n * The {@link GeolocateControl} options\n */\ntype GeolocateOptions = {\n /**\n * A Geolocation API [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) object.\n * @defaultValue `{enableHighAccuracy: false, timeout: 6000}`\n */\n positionOptions?: PositionOptions;\n /**\n * A options object to use when the map is panned and zoomed to the user's location. The default is to use a `maxZoom` of 15 to limit how far the map will zoom in for very accurate locations.\n */\n fitBoundsOptions?: FitBoundsOptions;\n /**\n * If `true` the Geolocate Control becomes a toggle button and when active the map will receive updates to the user's location as it changes.\n * @defaultValue false\n */\n trackUserLocation?: boolean;\n /**\n * By default, if showUserLocation is `true`, a transparent circle will be drawn around the user location indicating the accuracy (95% confidence level) of the user's location. Set to `false` to disable. Always disabled when showUserLocation is `false`.\n * @defaultValue true\n */\n showAccuracyCircle?: boolean;\n /**\n * By default a dot will be shown on the map at the user's location. Set to `false` to disable.\n * @defaultValue true\n */\n showUserLocation?: boolean;\n};\n\nconst defaultOptions: GeolocateOptions = {\n positionOptions: {\n enableHighAccuracy: false,\n maximumAge: 0,\n timeout: 6000 /* 6 sec */\n },\n fitBoundsOptions: {\n maxZoom: 15\n },\n trackUserLocation: false,\n showAccuracyCircle: true,\n showUserLocation: true\n};\n\nlet numberOfWatches = 0;\nlet noTimeout = false;\n\n/**\n * A `GeolocateControl` control provides a button that uses the browser's geolocation\n * API to locate the user on the map.\n *\n * Not all browsers support geolocation,\n * and some users may disable the feature. Geolocation support for modern\n * browsers including Chrome requires sites to be served over HTTPS. If\n * geolocation support is not available, the GeolocateControl will show\n * as disabled.\n *\n * The zoom level applied will depend on the accuracy of the geolocation provided by the device.\n *\n * The GeolocateControl has two modes. If `trackUserLocation` is `false` (default) the control acts as a button, which when pressed will set the map's camera to target the user location. If the user moves, the map won't update. This is most suited for the desktop. If `trackUserLocation` is `true` the control acts as a toggle button that when active the user's location is actively monitored for changes. In this mode the GeolocateControl has three interaction states:\n * * active - the map's camera automatically updates as the user's location changes, keeping the location dot in the center. Initial state and upon clicking the `GeolocateControl` button.\n * * passive - the user's location dot automatically updates, but the map's camera does not. Occurs upon the user initiating a map movement.\n * * disabled - occurs if Geolocation is not available, disabled or denied.\n *\n * These interaction states can't be controlled programmatically, rather they are set based on user interactions.\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * }));\n * ```\n * @see [Locate the user](https://maplibre.org/maplibre-gl-js/docs/examples/locate-user/)\n *\n * ### Events\n *\n * @event `trackuserlocationend` - Fired when the Geolocate Control changes to the background state, which happens when a user changes the camera during an active position lock. This only applies when trackUserLocation is true. In the background state, the dot on the map will update with location updates but the camera will not.\n *\n * @event `trackuserlocationstart` - Fired when the Geolocate Control changes to the active lock state, which happens either upon first obtaining a successful Geolocation API position for the user (a geolocate event will follow), or the user clicks the geolocate button when in the background state which uses the last known position to recenter the map and enter active lock state (no geolocate event will follow unless the users's location changes).\n *\n * @event `geolocate` - Fired on each Geolocation API position update which returned as success.\n * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @event `error` - Fired on each Geolocation API position update which returned as an error.\n * `data` - The returned [PositionError](https://developer.mozilla.org/en-US/docs/Web/API/PositionError) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @event `outofmaxbounds` Fired on each Geolocation API position update which returned as success but user position is out of map maxBounds.\n * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition).\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a trackuserlocationend event occurs.\n * geolocate.on('trackuserlocationend', function() {\n * console.log('A trackuserlocationend event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a trackuserlocationstart event occurs.\n * geolocate.on('trackuserlocationstart', function() {\n * console.log('A trackuserlocationstart event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when a geolocate event occurs.\n * geolocate.on('geolocate', function() {\n * console.log('A geolocate event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when an error event occurs.\n * geolocate.on('error', function() {\n * console.log('An error event has occurred.')\n * });\n * ```\n *\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * // Set an event listener that fires\n * // when an outofmaxbounds event occurs.\n * geolocate.on('outofmaxbounds', function() {\n * console.log('An outofmaxbounds event has occurred.')\n * });\n * ```\n */\nexport class GeolocateControl extends Evented implements IControl {\n _map: Map;\n options: GeolocateOptions;\n _container: HTMLElement;\n _dotElement: HTMLElement;\n _circleElement: HTMLElement;\n _geolocateButton: HTMLButtonElement;\n _geolocationWatchID: number;\n _timeoutId: ReturnType;\n /* Geolocate Control Watch States\n * This is the private state of the control.\n *\n * OFF\n * off/inactive\n * WAITING_ACTIVE\n * Geolocate Control was clicked but still waiting for Geolocation API response with user location\n * ACTIVE_LOCK\n * Showing the user location as a dot AND tracking the camera to be fixed to their location. If their location changes the map moves to follow.\n * ACTIVE_ERROR\n * There was en error from the Geolocation API while trying to show and track the user location.\n * BACKGROUND\n * Showing the user location as a dot but the camera doesn't follow their location as it changes.\n * BACKGROUND_ERROR\n * There was an error from the Geolocation API while trying to show (but not track) the user location.\n */\n _watchState: 'OFF' | 'ACTIVE_LOCK' | 'WAITING_ACTIVE' | 'ACTIVE_ERROR' | 'BACKGROUND' | 'BACKGROUND_ERROR';\n _lastKnownPosition: any;\n _userLocationDotMarker: Marker;\n _accuracyCircleMarker: Marker;\n _accuracy: number;\n _setup: boolean; // set to true once the control has been setup\n\n constructor(options: GeolocateOptions) {\n super();\n this.options = extend({}, defaultOptions, options);\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n checkGeolocationSupport(this._setupUI);\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n // clear the geolocation watch if exists\n if (this._geolocationWatchID !== undefined) {\n window.navigator.geolocation.clearWatch(this._geolocationWatchID);\n this._geolocationWatchID = undefined;\n }\n\n // clear the markers from the map\n if (this.options.showUserLocation && this._userLocationDotMarker) {\n this._userLocationDotMarker.remove();\n }\n if (this.options.showAccuracyCircle && this._accuracyCircleMarker) {\n this._accuracyCircleMarker.remove();\n }\n\n DOM.remove(this._container);\n this._map.off('zoom', this._onZoom);\n this._map = undefined;\n numberOfWatches = 0;\n noTimeout = false;\n }\n\n /**\n * Check if the Geolocation API Position is outside the map's maxbounds.\n *\n * @param position - the Geolocation API Position\n * @returns `true` if position is outside the map's maxbounds, otherwise returns `false`.\n */\n _isOutOfMapMaxBounds(position: GeolocationPosition) {\n const bounds = this._map.getMaxBounds();\n const coordinates = position.coords;\n\n return bounds && (\n coordinates.longitude < bounds.getWest() ||\n coordinates.longitude > bounds.getEast() ||\n coordinates.latitude < bounds.getSouth() ||\n coordinates.latitude > bounds.getNorth()\n );\n }\n\n _setErrorState() {\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n this._watchState = 'ACTIVE_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error');\n break;\n case 'ACTIVE_LOCK':\n this._watchState = 'ACTIVE_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n // turn marker grey\n break;\n case 'BACKGROUND':\n this._watchState = 'BACKGROUND_ERROR';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n // turn marker grey\n break;\n case 'ACTIVE_ERROR':\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n }\n\n /**\n * When the Geolocation API returns a new location, update the GeolocateControl.\n *\n * @param position - the Geolocation API Position\n */\n _onSuccess = (position: GeolocationPosition) => {\n if (!this._map) {\n // control has since been removed\n return;\n }\n\n if (this._isOutOfMapMaxBounds(position)) {\n this._setErrorState();\n\n this.fire(new Event('outofmaxbounds', position));\n this._updateMarker();\n this._finish();\n\n return;\n }\n\n if (this.options.trackUserLocation) {\n // keep a record of the position so that if the state is BACKGROUND and the user\n // clicks the button, we can move to ACTIVE_LOCK immediately without waiting for\n // watchPosition to trigger _onSuccess\n this._lastKnownPosition = position;\n\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n case 'ACTIVE_LOCK':\n case 'ACTIVE_ERROR':\n this._watchState = 'ACTIVE_LOCK';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'BACKGROUND':\n case 'BACKGROUND_ERROR':\n this._watchState = 'BACKGROUND';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background');\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n }\n\n // if showUserLocation and the watch state isn't off then update the marker location\n if (this.options.showUserLocation && this._watchState !== 'OFF') {\n this._updateMarker(position);\n }\n\n // if in normal mode (not watch mode), or if in watch mode and the state is active watch\n // then update the camera\n if (!this.options.trackUserLocation || this._watchState === 'ACTIVE_LOCK') {\n this._updateCamera(position);\n }\n\n if (this.options.showUserLocation) {\n this._dotElement.classList.remove('maplibregl-user-location-dot-stale');\n }\n\n this.fire(new Event('geolocate', position));\n this._finish();\n };\n\n /**\n * Update the camera location to center on the current position\n *\n * @param position - the Geolocation API Position\n */\n _updateCamera = (position: GeolocationPosition) => {\n const center = new LngLat(position.coords.longitude, position.coords.latitude);\n const radius = position.coords.accuracy;\n const bearing = this._map.getBearing();\n const options = extend({bearing}, this.options.fitBoundsOptions);\n const newBounds = LngLatBounds.fromLngLat(center, radius);\n\n this._map.fitBounds(newBounds, options, {\n geolocateSource: true // tag this camera change so it won't cause the control to change to background state\n });\n };\n\n /**\n * Update the user location dot Marker to the current position\n *\n * @param position - the Geolocation API Position\n */\n _updateMarker = (position?: GeolocationPosition | null) => {\n if (position) {\n const center = new LngLat(position.coords.longitude, position.coords.latitude);\n this._accuracyCircleMarker.setLngLat(center).addTo(this._map);\n this._userLocationDotMarker.setLngLat(center).addTo(this._map);\n this._accuracy = position.coords.accuracy;\n if (this.options.showUserLocation && this.options.showAccuracyCircle) {\n this._updateCircleRadius();\n }\n } else {\n this._userLocationDotMarker.remove();\n this._accuracyCircleMarker.remove();\n }\n };\n\n _updateCircleRadius() {\n const bounds = this._map.getBounds();\n const southEastPoint = bounds.getSouthEast();\n const northEastPoint = bounds.getNorthEast();\n const mapHeightInMeters = southEastPoint.distanceTo(northEastPoint);\n const mapHeightInPixels = this._map._container.clientHeight;\n const circleDiameter = Math.ceil(2 * (this._accuracy / (mapHeightInMeters / mapHeightInPixels)));\n this._circleElement.style.width = `${circleDiameter}px`;\n this._circleElement.style.height = `${circleDiameter}px`;\n }\n\n _onZoom = () => {\n if (this.options.showUserLocation && this.options.showAccuracyCircle) {\n this._updateCircleRadius();\n }\n };\n\n _onError = (error: GeolocationPositionError) => {\n if (!this._map) {\n // control has since been removed\n return;\n }\n\n if (this.options.trackUserLocation) {\n if (error.code === 1) {\n // PERMISSION_DENIED\n this._watchState = 'OFF';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n this._geolocateButton.disabled = true;\n const title = this._map._getUIString('GeolocateControl.LocationNotAvailable');\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n\n if (this._geolocationWatchID !== undefined) {\n this._clearWatch();\n }\n } else if (error.code === 3 && noTimeout) {\n // this represents a forced error state\n // this was triggered to force immediate geolocation when a watch is already present\n // see https://github.com/mapbox/mapbox-gl-js/issues/8214\n // and https://w3c.github.io/geolocation-api/#example-5-forcing-the-user-agent-to-return-a-fresh-cached-position\n return;\n } else {\n this._setErrorState();\n }\n }\n\n if (this._watchState !== 'OFF' && this.options.showUserLocation) {\n this._dotElement.classList.add('maplibregl-user-location-dot-stale');\n }\n\n this.fire(new Event('error', error));\n\n this._finish();\n };\n\n _finish = () => {\n if (this._timeoutId) { clearTimeout(this._timeoutId); }\n this._timeoutId = undefined;\n };\n\n _setupUI = (supported: boolean) => {\n // this method is called asynchronously during onAdd\n // the control could have been removed before reaching here\n if (!this._map) {\n return;\n }\n\n this._container.addEventListener('contextmenu', (e: MouseEvent) => e.preventDefault());\n this._geolocateButton = DOM.create('button', 'maplibregl-ctrl-geolocate', this._container);\n DOM.create('span', 'maplibregl-ctrl-icon', this._geolocateButton).setAttribute('aria-hidden', 'true');\n this._geolocateButton.type = 'button';\n\n if (supported === false) {\n warnOnce('Geolocation support is not available so the GeolocateControl will be disabled.');\n const title = this._map._getUIString('GeolocateControl.LocationNotAvailable');\n this._geolocateButton.disabled = true;\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n } else {\n const title = this._map._getUIString('GeolocateControl.FindMyLocation');\n this._geolocateButton.title = title;\n this._geolocateButton.setAttribute('aria-label', title);\n }\n\n if (this.options.trackUserLocation) {\n this._geolocateButton.setAttribute('aria-pressed', 'false');\n this._watchState = 'OFF';\n }\n\n // when showUserLocation is enabled, keep the Geolocate button disabled until the device location marker is setup on the map\n if (this.options.showUserLocation) {\n this._dotElement = DOM.create('div', 'maplibregl-user-location-dot');\n\n this._userLocationDotMarker = new Marker({element: this._dotElement});\n\n this._circleElement = DOM.create('div', 'maplibregl-user-location-accuracy-circle');\n this._accuracyCircleMarker = new Marker({element: this._circleElement, pitchAlignment: 'map'});\n\n if (this.options.trackUserLocation) this._watchState = 'OFF';\n\n this._map.on('zoom', this._onZoom);\n }\n\n this._geolocateButton.addEventListener('click',\n this.trigger.bind(this));\n\n this._setup = true;\n\n // when the camera is changed (and it's not as a result of the Geolocation Control) change\n // the watch mode to background watch, so that the marker is updated but not the camera.\n if (this.options.trackUserLocation) {\n this._map.on('movestart', (event: any) => {\n const fromResize = event.originalEvent && event.originalEvent.type === 'resize';\n if (!event.geolocateSource && this._watchState === 'ACTIVE_LOCK' && !fromResize) {\n this._watchState = 'BACKGROUND';\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n\n this.fire(new Event('trackuserlocationend'));\n }\n });\n }\n };\n\n /**\n * Programmatically request and move the map to the user's location.\n *\n * @returns `false` if called before control was added to a map, otherwise returns `true`.\n * @example\n * ```ts\n * // Initialize the geolocate control.\n * let geolocate = new maplibregl.GeolocateControl({\n * positionOptions: {\n * enableHighAccuracy: true\n * },\n * trackUserLocation: true\n * });\n * // Add the control to the map.\n * map.addControl(geolocate);\n * map.on('load', function() {\n * geolocate.trigger();\n * });\n * ```\n */\n trigger(): boolean {\n if (!this._setup) {\n warnOnce('Geolocate control triggered before added to a map');\n return false;\n }\n if (this.options.trackUserLocation) {\n // update watchState and do any outgoing state cleanup\n switch (this._watchState) {\n case 'OFF':\n // turn on the Geolocate Control\n this._watchState = 'WAITING_ACTIVE';\n\n this.fire(new Event('trackuserlocationstart'));\n break;\n case 'WAITING_ACTIVE':\n case 'ACTIVE_LOCK':\n case 'ACTIVE_ERROR':\n case 'BACKGROUND_ERROR':\n // turn off the Geolocate Control\n numberOfWatches--;\n noTimeout = false;\n this._watchState = 'OFF';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error');\n\n this.fire(new Event('trackuserlocationend'));\n break;\n case 'BACKGROUND':\n this._watchState = 'ACTIVE_LOCK';\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background');\n // set camera to last known location\n if (this._lastKnownPosition) this._updateCamera(this._lastKnownPosition);\n\n this.fire(new Event('trackuserlocationstart'));\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n\n // incoming state setup\n switch (this._watchState) {\n case 'WAITING_ACTIVE':\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'ACTIVE_LOCK':\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active');\n break;\n case 'OFF':\n break;\n default:\n throw new Error(`Unexpected watchState ${this._watchState}`);\n }\n\n // manage geolocation.watchPosition / geolocation.clearWatch\n if (this._watchState === 'OFF' && this._geolocationWatchID !== undefined) {\n // clear watchPosition as we've changed to an OFF state\n this._clearWatch();\n } else if (this._geolocationWatchID === undefined) {\n // enable watchPosition since watchState is not OFF and there is no watchPosition already running\n\n this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.setAttribute('aria-pressed', 'true');\n\n numberOfWatches++;\n let positionOptions;\n if (numberOfWatches > 1) {\n positionOptions = {maximumAge: 600000, timeout: 0};\n noTimeout = true;\n } else {\n positionOptions = this.options.positionOptions;\n noTimeout = false;\n }\n\n this._geolocationWatchID = window.navigator.geolocation.watchPosition(\n this._onSuccess, this._onError, positionOptions);\n }\n } else {\n window.navigator.geolocation.getCurrentPosition(\n this._onSuccess, this._onError, this.options.positionOptions);\n\n // This timeout ensures that we still call finish() even if\n // the user declines to share their location in Firefox\n this._timeoutId = setTimeout(this._finish, 10000 /* 10sec */);\n }\n\n return true;\n }\n\n _clearWatch() {\n window.navigator.geolocation.clearWatch(this._geolocationWatchID);\n\n this._geolocationWatchID = undefined;\n this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting');\n this._geolocateButton.setAttribute('aria-pressed', 'false');\n\n if (this.options.showUserLocation) {\n this._updateMarker(null);\n }\n }\n}\n\n","import {DOM} from '../../util/dom';\nimport {extend} from '../../util/util';\n\nimport type {Map} from '../map';\nimport type {ControlPosition, IControl} from './control';\n\n/**\n * The unit type for length to use for the {@link ScaleControl}\n */\nexport type Unit = 'imperial' | 'metric' | 'nautical';\n\n/**\n * The {@link ScaleControl} options object\n */\ntype ScaleOptions = {\n /**\n * The maximum length of the scale control in pixels.\n * @defaultValue 100\n */\n maxWidth?: number;\n /**\n * Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).\n * @defaultValue 'metric'\n */\n unit?: Unit;\n};\n\nconst defaultOptions: ScaleOptions = {\n maxWidth: 100,\n unit: 'metric'\n};\n\n/**\n * A `ScaleControl` control displays the ratio of a distance on the map to the corresponding distance on the ground.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let scale = new maplibregl.ScaleControl({\n * maxWidth: 80,\n * unit: 'imperial'\n * });\n * map.addControl(scale);\n *\n * scale.setUnit('metric');\n * ```\n */\nexport class ScaleControl implements IControl {\n _map: Map;\n _container: HTMLElement;\n options: ScaleOptions;\n\n constructor(options: ScaleOptions) {\n this.options = extend({}, defaultOptions, options);\n }\n\n getDefaultPosition(): ControlPosition {\n return 'bottom-left';\n }\n\n _onMove = () => {\n updateScale(this._map, this._container, this.options);\n };\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-scale', map.getContainer());\n\n this._map.on('move', this._onMove);\n this._onMove();\n\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('move', this._onMove);\n this._map = undefined;\n }\n\n /**\n * Set the scale's unit of the distance\n *\n * @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).\n */\n setUnit = (unit: Unit) => {\n this.options.unit = unit;\n updateScale(this._map, this._container, this.options);\n };\n}\n\nfunction updateScale(map, container, options) {\n // A horizontal scale is imagined to be present at center of the map\n // container with maximum length (Default) as 100px.\n // Using spherical law of cosines approximation, the real distance is\n // found between the two coordinates.\n const maxWidth = options && options.maxWidth || 100;\n\n const y = map._container.clientHeight / 2;\n const left = map.unproject([0, y]);\n const right = map.unproject([maxWidth, y]);\n const maxMeters = left.distanceTo(right);\n // The real distance corresponding to 100px scale length is rounded off to\n // near pretty number and the scale length for the same is found out.\n // Default unit of the scale is based on User's locale.\n if (options && options.unit === 'imperial') {\n const maxFeet = 3.2808 * maxMeters;\n if (maxFeet > 5280) {\n const maxMiles = maxFeet / 5280;\n setScale(container, maxWidth, maxMiles, map._getUIString('ScaleControl.Miles'));\n } else {\n setScale(container, maxWidth, maxFeet, map._getUIString('ScaleControl.Feet'));\n }\n } else if (options && options.unit === 'nautical') {\n const maxNauticals = maxMeters / 1852;\n setScale(container, maxWidth, maxNauticals, map._getUIString('ScaleControl.NauticalMiles'));\n } else if (maxMeters >= 1000) {\n setScale(container, maxWidth, maxMeters / 1000, map._getUIString('ScaleControl.Kilometers'));\n } else {\n setScale(container, maxWidth, maxMeters, map._getUIString('ScaleControl.Meters'));\n }\n}\n\nfunction setScale(container, maxWidth, maxDistance, unit) {\n const distance = getRoundNum(maxDistance);\n const ratio = distance / maxDistance;\n container.style.width = `${maxWidth * ratio}px`;\n container.innerHTML = `${distance} ${unit}`;\n}\n\nfunction getDecimalRoundNum(d) {\n const multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10));\n return Math.round(d * multiplier) / multiplier;\n}\n\nfunction getRoundNum(num) {\n const pow10 = Math.pow(10, (`${Math.floor(num)}`).length - 1);\n let d = num / pow10;\n\n d = d >= 10 ? 10 :\n d >= 5 ? 5 :\n d >= 3 ? 3 :\n d >= 2 ? 2 :\n d >= 1 ? 1 : getDecimalRoundNum(d);\n\n return pow10 * d;\n}\n","import {extend} from '../util/util';\nimport {Event, Evented} from '../util/evented';\nimport {MapMouseEvent} from '../ui/events';\nimport {DOM} from '../util/dom';\nimport {LngLat} from '../geo/lng_lat';\nimport Point from '@mapbox/point-geometry';\nimport {smartWrap} from '../util/smart_wrap';\nimport {anchorTranslate, applyAnchorClass} from './anchor';\n\nimport type {PositionAnchor} from './anchor';\nimport type {Map} from './map';\nimport type {LngLatLike} from '../geo/lng_lat';\nimport type {PointLike} from './camera';\n\nconst defaultOptions = {\n closeButton: true,\n closeOnClick: true,\n focusAfterOpen: true,\n className: '',\n maxWidth: '240px'\n};\n\n/**\n * A pixel offset specified as:\n * - a single number specifying a distance from the location\n * - a {@link PointLike} specifying a constant offset\n * - an object of {@link Point}s specifying an offset for each anchor position\n * Negative offsets indicate left and up.\n */\nexport type Offset = number | PointLike | {\n [_ in PositionAnchor]: PointLike;\n};\n\nexport type PopupOptions = {\n /**\n * If `true`, a close button will appear in the top right corner of the popup.\n * @defaultValue true\n */\n closeButton?: boolean;\n /**\n * If `true`, the popup will closed when the map is clicked.\n * @defaultValue true\n */\n closeOnClick?: boolean;\n /**\n * If `true`, the popup will closed when the map moves.\n * @defaultValue false\n */\n closeOnMove?: boolean;\n /**\n * If `true`, the popup will try to focus the first focusable element inside the popup.\n * @defaultValue true\n */\n focusAfterOpen?: boolean;\n /**\n * A string indicating the part of the Popup that should\n * be positioned closest to the coordinate set via {@link Popup#setLngLat}.\n * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`,\n * `'top-right'`, `'bottom-left'`, and `'bottom-right'`. If unset the anchor will be\n * dynamically set to ensure the popup falls within the map container with a preference\n * for `'bottom'`.\n */\n anchor?: PositionAnchor;\n /**\n * A pixel offset applied to the popup's location\n */\n offset?: Offset;\n /**\n * Space-separated CSS class names to add to popup container\n */\n className?: string;\n /**\n * A string that sets the CSS property of the popup's maximum width, eg `'300px'`.\n * To ensure the popup resizes to fit its content, set this property to `'none'`.\n * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width\n * @defaultValue '240px'\n */\n maxWidth?: string;\n};\n\nconst focusQuerySelector = [\n 'a[href]',\n '[tabindex]:not([tabindex=\\'-1\\'])',\n '[contenteditable]:not([contenteditable=\\'false\\'])',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n].join(', ');\n\n/**\n * A popup component.\n *\n * @group Markers and Controls\n *\n *\n * @example\n * Create a popup\n * ```ts\n * let popup = new maplibregl.Popup();\n * // Set an event listener that will fire\n * // any time the popup is opened\n * popup.on('open', function(){\n * console.log('popup was opened');\n * });\n * ```\n *\n * @example\n * Create a popup\n * ```ts\n * let popup = new maplibregl.Popup();\n * // Set an event listener that will fire\n * // any time the popup is closed\n * popup.on('close', function(){\n * console.log('popup was closed');\n * });\n * ```\n *\n * @example\n * ```ts\n * let markerHeight = 50, markerRadius = 10, linearOffset = 25;\n * let popupOffsets = {\n * 'top': [0, 0],\n * 'top-left': [0,0],\n * 'top-right': [0,0],\n * 'bottom': [0, -markerHeight],\n * 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n * 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],\n * 'left': [markerRadius, (markerHeight - markerRadius) * -1],\n * 'right': [-markerRadius, (markerHeight - markerRadius) * -1]\n * };\n * let popup = new maplibregl.Popup({offset: popupOffsets, className: 'my-class'})\n * .setLngLat(e.lngLat)\n * .setHTML(\"

Hello World!

\")\n * .setMaxWidth(\"300px\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n *\n * ### Events\n *\n * @event `open` Fired when the popup is opened manually or programmatically. `popup` object that was opened\n *\n * @event `close` Fired when the popup is closed manually or programmatically. `popup` object that was closed\n */\nexport class Popup extends Evented {\n _map: Map;\n options: PopupOptions;\n _content: HTMLElement;\n _container: HTMLElement;\n _closeButton: HTMLButtonElement;\n _tip: HTMLElement;\n _lngLat: LngLat;\n _trackPointer: boolean;\n _pos: Point;\n\n constructor(options?: PopupOptions) {\n super();\n this.options = extend(Object.create(defaultOptions), options);\n }\n\n /**\n * Adds the popup to a map.\n *\n * @param map - The MapLibre GL JS map to add the popup to.\n * @returns `this`\n * @example\n * ```ts\n * new maplibregl.Popup()\n * .setLngLat([0, 0])\n * .setHTML(\"

Null Island

\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Show polygon information on click](https://maplibre.org/maplibre-gl-js/docs/examples/polygon-popup-on-click/)\n */\n addTo(map: Map): this {\n if (this._map) this.remove();\n\n this._map = map;\n if (this.options.closeOnClick) {\n this._map.on('click', this._onClose);\n }\n\n if (this.options.closeOnMove) {\n this._map.on('move', this._onClose);\n }\n\n this._map.on('remove', this.remove);\n this._update();\n this._focusFirstElement();\n\n if (this._trackPointer) {\n this._map.on('mousemove', this._onMouseMove);\n this._map.on('mouseup', this._onMouseUp);\n if (this._container) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.add('maplibregl-track-pointer');\n } else {\n this._map.on('move', this._update);\n }\n\n this.fire(new Event('open'));\n\n return this;\n }\n\n /**\n * @returns `true` if the popup is open, `false` if it is closed.\n */\n isOpen() {\n return !!this._map;\n }\n\n /**\n * Removes the popup from the map it has been added to.\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup().addTo(map);\n * popup.remove();\n * ```\n * @returns `this`\n */\n remove = (): this => {\n if (this._content) {\n DOM.remove(this._content);\n }\n\n if (this._container) {\n DOM.remove(this._container);\n delete this._container;\n }\n\n if (this._map) {\n this._map.off('move', this._update);\n this._map.off('move', this._onClose);\n this._map.off('click', this._onClose);\n this._map.off('remove', this.remove);\n this._map.off('mousemove', this._onMouseMove);\n this._map.off('mouseup', this._onMouseUp);\n this._map.off('drag', this._onDrag);\n delete this._map;\n }\n\n this.fire(new Event('close'));\n\n return this;\n };\n\n /**\n * Returns the geographical location of the popup's anchor.\n *\n * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously\n * set by `setLngLat` because `Popup` wraps the anchor longitude across copies of the world to keep\n * the popup on screen.\n *\n * @returns The geographical location of the popup's anchor.\n */\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n /**\n * Sets the geographical location of the popup's anchor, and moves the popup to it. Replaces trackPointer() behavior.\n *\n * @param lnglat - The geographical location to set as the popup's anchor.\n * @returns `this`\n */\n setLngLat(lnglat: LngLatLike): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n\n this._trackPointer = false;\n\n this._update();\n\n if (this._map) {\n this._map.on('move', this._update);\n this._map.off('mousemove', this._onMouseMove);\n if (this._container) {\n this._container.classList.remove('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.remove('maplibregl-track-pointer');\n }\n\n return this;\n }\n\n /**\n * Tracks the popup anchor to the cursor position on screens with a pointer device (it will be hidden on touchscreens). Replaces the `setLngLat` behavior.\n * For most use cases, set `closeOnClick` and `closeButton` to `false`.\n * @example\n * ```ts\n * let popup = new maplibregl.Popup({ closeOnClick: false, closeButton: false })\n * .setHTML(\"

Hello World!

\")\n * .trackPointer()\n * .addTo(map);\n * ```\n * @returns `this`\n */\n trackPointer(): this {\n this._trackPointer = true;\n this._pos = null;\n this._update();\n if (this._map) {\n this._map.off('move', this._update);\n this._map.on('mousemove', this._onMouseMove);\n this._map.on('drag', this._onDrag);\n if (this._container) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n this._map._canvasContainer.classList.add('maplibregl-track-pointer');\n }\n\n return this;\n\n }\n\n /**\n * Returns the `Popup`'s HTML element.\n * @example\n * Change the `Popup` element's font size\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat([-96, 37.8])\n * .setHTML(\"

Hello World!

\")\n * .addTo(map);\n * let popupElem = popup.getElement();\n * popupElem.style.fontSize = \"25px\";\n * ```\n * @returns element\n */\n getElement(): HTMLElement {\n return this._container;\n }\n\n /**\n * Sets the popup's content to a string of text.\n *\n * This function creates a [Text](https://developer.mozilla.org/en-US/docs/Web/API/Text) node in the DOM,\n * so it cannot insert raw HTML. Use this method for security against XSS\n * if the popup content is user-provided.\n *\n * @param text - Textual content for the popup.\n * @returns `this`\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setText('Hello, world!')\n * .addTo(map);\n * ```\n */\n setText(text: string): this {\n return this.setDOMContent(document.createTextNode(text));\n }\n\n /**\n * Sets the popup's content to the HTML provided as a string.\n *\n * This method does not perform HTML filtering or sanitization, and must be\n * used only with trusted content. Consider {@link Popup#setText} if\n * the content is an untrusted text string.\n *\n * @param html - A string representing HTML content for the popup.\n * @returns `this`\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setHTML(\"

Hello World!

\")\n * .addTo(map);\n * ```\n * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/)\n * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)\n * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)\n * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/)\n */\n setHTML(html: string): this {\n const frag = document.createDocumentFragment();\n const temp = document.createElement('body');\n let child;\n temp.innerHTML = html;\n while (true) {\n child = temp.firstChild;\n if (!child) break;\n frag.appendChild(child);\n }\n\n return this.setDOMContent(frag);\n }\n\n /**\n * Returns the popup's maximum width.\n *\n * @returns The maximum width of the popup.\n */\n getMaxWidth(): string {\n return this._container?.style.maxWidth;\n }\n\n /**\n * Sets the popup's maximum width. This is setting the CSS property `max-width`.\n * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width\n *\n * @param maxWidth - A string representing the value for the maximum width.\n * @returns `this`\n */\n setMaxWidth(maxWidth: string): this {\n this.options.maxWidth = maxWidth;\n this._update();\n return this;\n }\n\n /**\n * Sets the popup's content to the element provided as a DOM node.\n *\n * @param htmlNode - A DOM node to be used as content for the popup.\n * @returns `this`\n * @example\n * Create an element with the popup content\n * ```ts\n * let div = document.createElement('div');\n * div.innerHTML = 'Hello, world!';\n * let popup = new maplibregl.Popup()\n * .setLngLat(e.lngLat)\n * .setDOMContent(div)\n * .addTo(map);\n * ```\n */\n setDOMContent(htmlNode: Node): this {\n if (this._content) {\n // Clear out children first.\n while (this._content.hasChildNodes()) {\n if (this._content.firstChild) {\n this._content.removeChild(this._content.firstChild);\n }\n }\n } else {\n this._content = DOM.create('div', 'maplibregl-popup-content', this._container);\n }\n\n // The close button should be the last tabbable element inside the popup for a good keyboard UX.\n this._content.appendChild(htmlNode);\n this._createCloseButton();\n this._update();\n this._focusFirstElement();\n return this;\n }\n\n /**\n * Adds a CSS class to the popup container element.\n *\n * @param className - Non-empty string with CSS class name to add to popup container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.addClassName('some-class')\n * ```\n */\n addClassName(className: string) {\n if (this._container) {\n this._container.classList.add(className);\n }\n }\n\n /**\n * Removes a CSS class from the popup container element.\n *\n * @param className - Non-empty string with CSS class name to remove from popup container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.removeClassName('some-class')\n * ```\n */\n removeClassName(className: string) {\n if (this._container) {\n this._container.classList.remove(className);\n }\n }\n\n /**\n * Sets the popup's offset.\n *\n * @param offset - Sets the popup's offset.\n * @returns `this`\n */\n setOffset (offset?: Offset): this {\n this.options.offset = offset;\n this._update();\n return this;\n }\n\n /**\n * Add or remove the given CSS class on the popup container, depending on whether the container currently has that class.\n *\n * @param className - Non-empty string with CSS class name to add/remove\n *\n * @returns if the class was removed return false, if class was added, then return true, undefined if there is no container\n *\n * @example\n * ```ts\n * let popup = new maplibregl.Popup()\n * popup.toggleClassName('toggleClass')\n * ```\n */\n toggleClassName(className: string): boolean | undefined {\n if (this._container) {\n return this._container.classList.toggle(className);\n }\n }\n\n _createCloseButton() {\n if (this.options.closeButton) {\n this._closeButton = DOM.create('button', 'maplibregl-popup-close-button', this._content);\n this._closeButton.type = 'button';\n this._closeButton.setAttribute('aria-label', 'Close popup');\n this._closeButton.innerHTML = '×';\n this._closeButton.addEventListener('click', this._onClose);\n }\n }\n\n _onMouseUp = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _onMouseMove = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _onDrag = (event: MapMouseEvent) => {\n this._update(event.point);\n };\n\n _update = (cursor?: Point) => {\n const hasPosition = this._lngLat || this._trackPointer;\n\n if (!this._map || !hasPosition || !this._content) { return; }\n\n if (!this._container) {\n this._container = DOM.create('div', 'maplibregl-popup', this._map.getContainer());\n this._tip = DOM.create('div', 'maplibregl-popup-tip', this._container);\n this._container.appendChild(this._content);\n if (this.options.className) {\n for (const name of this.options.className.split(' ')) {\n this._container.classList.add(name);\n }\n }\n\n if (this._trackPointer) {\n this._container.classList.add('maplibregl-popup-track-pointer');\n }\n }\n\n if (this.options.maxWidth && this._container.style.maxWidth !== this.options.maxWidth) {\n this._container.style.maxWidth = this.options.maxWidth;\n }\n\n if (this._map.transform.renderWorldCopies && !this._trackPointer) {\n this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);\n }\n\n if (this._trackPointer && !cursor) return;\n\n const pos = this._pos = this._trackPointer && cursor ? cursor : this._map.project(this._lngLat);\n\n let anchor = this.options.anchor;\n const offset = normalizeOffset(this.options.offset);\n\n if (!anchor) {\n const width = this._container.offsetWidth;\n const height = this._container.offsetHeight;\n let anchorComponents;\n\n if (pos.y + offset.bottom.y < height) {\n anchorComponents = ['top'];\n } else if (pos.y > this._map.transform.height - height) {\n anchorComponents = ['bottom'];\n } else {\n anchorComponents = [];\n }\n\n if (pos.x < width / 2) {\n anchorComponents.push('left');\n } else if (pos.x > this._map.transform.width - width / 2) {\n anchorComponents.push('right');\n }\n\n if (anchorComponents.length === 0) {\n anchor = 'bottom';\n } else {\n anchor = (anchorComponents.join('-') as any);\n }\n }\n\n const offsetedPos = pos.add(offset[anchor]).round();\n DOM.setTransform(this._container, `${anchorTranslate[anchor]} translate(${offsetedPos.x}px,${offsetedPos.y}px)`);\n applyAnchorClass(this._container, anchor, 'popup');\n };\n\n _focusFirstElement() {\n if (!this.options.focusAfterOpen || !this._container) return;\n\n const firstFocusable = this._container.querySelector(focusQuerySelector) as HTMLElement;\n\n if (firstFocusable) firstFocusable.focus();\n }\n\n _onClose = () => {\n this.remove();\n };\n}\n\nfunction normalizeOffset(offset?: Offset | null) {\n if (!offset) {\n return normalizeOffset(new Point(0, 0));\n\n } else if (typeof offset === 'number') {\n // input specifies a radius from which to calculate offsets at all positions\n const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);\n return {\n 'center': new Point(0, 0),\n 'top': new Point(0, offset),\n 'top-left': new Point(cornerOffset, cornerOffset),\n 'top-right': new Point(-cornerOffset, cornerOffset),\n 'bottom': new Point(0, -offset),\n 'bottom-left': new Point(cornerOffset, -cornerOffset),\n 'bottom-right': new Point(-cornerOffset, -cornerOffset),\n 'left': new Point(offset, 0),\n 'right': new Point(-offset, 0)\n };\n\n } else if (offset instanceof Point || Array.isArray(offset)) {\n // input specifies a single offset to be applied to all positions\n const convertedOffset = Point.convert(offset);\n return {\n 'center': convertedOffset,\n 'top': convertedOffset,\n 'top-left': convertedOffset,\n 'top-right': convertedOffset,\n 'bottom': convertedOffset,\n 'bottom-left': convertedOffset,\n 'bottom-right': convertedOffset,\n 'left': convertedOffset,\n 'right': convertedOffset\n };\n\n } else {\n // input specifies an offset per position\n return {\n 'center': Point.convert(offset['center'] || [0, 0]),\n 'top': Point.convert(offset['top'] || [0, 0]),\n 'top-left': Point.convert(offset['top-left'] || [0, 0]),\n 'top-right': Point.convert(offset['top-right'] || [0, 0]),\n 'bottom': Point.convert(offset['bottom'] || [0, 0]),\n 'bottom-left': Point.convert(offset['bottom-left'] || [0, 0]),\n 'bottom-right': Point.convert(offset['bottom-right'] || [0, 0]),\n 'left': Point.convert(offset['left'] || [0, 0]),\n 'right': Point.convert(offset['right'] || [0, 0])\n };\n }\n}\n","import {extend} from './util';\n\n/**\n * This is a private namespace for utility functions that will get automatically stripped\n * out in production builds.\n */\nexport const Debug = {\n extend(dest: any, ...sources: Array): any {\n return extend(dest, ...sources);\n },\n\n run(fn: () => any) {\n fn();\n },\n\n logToElement(message: string, overwrite: boolean = false, id: string = 'log') {\n const el = window.document.getElementById(id);\n if (el) {\n if (overwrite) el.innerHTML = '';\n el.innerHTML += `
${message}`;\n }\n\n }\n};\n","import packageJSON from '../package.json' assert {type: 'json'};\nimport {Map} from './ui/map';\nimport {NavigationControl} from './ui/control/navigation_control';\nimport {GeolocateControl} from './ui/control/geolocate_control';\nimport {AttributionControl} from './ui/control/attribution_control';\nimport {LogoControl} from './ui/control/logo_control';\nimport {ScaleControl} from './ui/control/scale_control';\nimport {FullscreenControl} from './ui/control/fullscreen_control';\nimport {TerrainControl} from './ui/control/terrain_control';\nimport {Popup} from './ui/popup';\nimport {Marker} from './ui/marker';\nimport {Style} from './style/style';\nimport {LngLat} from './geo/lng_lat';\nimport {LngLatBounds} from './geo/lng_lat_bounds';\nimport Point from '@mapbox/point-geometry';\nimport {MercatorCoordinate} from './geo/mercator_coordinate';\nimport {Evented} from './util/evented';\nimport {config} from './util/config';\nimport {Debug} from './util/debug';\nimport {isSafari} from './util/util';\nimport {setRTLTextPlugin, getRTLTextPluginStatus} from './source/rtl_text_plugin';\nimport {WorkerPool} from './util/worker_pool';\nimport {prewarm, clearPrewarmedResources} from './util/global_worker_pool';\nimport {PerformanceUtils} from './util/performance';\nimport {AJAXError} from './util/ajax';\nimport type {RequestParameters, ResponseCallback} from './util/ajax';\nimport type {Cancelable} from './types/cancelable';\nimport {GeoJSONSource} from './source/geojson_source';\nimport {CanvasSource} from './source/canvas_source';\nimport {ImageSource} from './source/image_source';\nimport {RasterDEMTileSource} from './source/raster_dem_tile_source';\nimport {RasterTileSource} from './source/raster_tile_source';\nimport {VectorTileSource} from './source/vector_tile_source';\nimport {VideoSource} from './source/video_source';\n\nconst version = packageJSON.version;\n\nexport type * from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * `maplibregl` is the global object that allows configurations that are not specific to a map instance\n *\n * @group Main\n */\nclass MapLibreGL {\n static Map = Map;\n static NavigationControl = NavigationControl;\n static GeolocateControl = GeolocateControl;\n static AttributionControl = AttributionControl;\n static LogoControl = LogoControl;\n static ScaleControl = ScaleControl;\n static FullscreenControl = FullscreenControl;\n static TerrainControl = TerrainControl;\n static Popup = Popup;\n static Marker = Marker;\n static Style = Style;\n static LngLat = LngLat;\n static LngLatBounds = LngLatBounds;\n static Point = Point;\n static MercatorCoordinate = MercatorCoordinate;\n static Evented = Evented;\n static AJAXError = AJAXError;\n static config = config;\n static CanvasSource = CanvasSource;\n static GeoJSONSource = GeoJSONSource;\n static ImageSource = ImageSource;\n static RasterDEMTileSource = RasterDEMTileSource;\n static RasterTileSource = RasterTileSource;\n static VectorTileSource = VectorTileSource;\n static VideoSource = VideoSource;\n /**\n * Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text).\n * Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left.\n *\n * @param pluginURL - URL pointing to the Mapbox RTL text plugin source.\n * @param callback - Called with an error argument if there is an error.\n * @param lazy - If set to `true`, mapboxgl will defer loading the plugin until rtl text is encountered,\n * rtl text will then be rendered only after the plugin finishes loading.\n * @example\n * ```ts\n * maplibregl.setRTLTextPlugin('https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.js');\n * ```\n * @see [Add support for right-to-left scripts](https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/)\n */\n static setRTLTextPlugin = setRTLTextPlugin;\n /**\n * Gets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) status.\n * The status can be `unavailable` (i.e. not requested or removed), `loading`, `loaded` or `error`.\n * If the status is `loaded` and the plugin is requested again, an error will be thrown.\n *\n * @example\n * ```ts\n * const pluginStatus = maplibregl.getRTLTextPluginStatus();\n * ```\n */\n static getRTLTextPluginStatus = getRTLTextPluginStatus;\n /**\n * Initializes resources like WebWorkers that can be shared across maps to lower load\n * times in some situations. `maplibregl.workerUrl` and `maplibregl.workerCount`, if being\n * used, must be set before `prewarm()` is called to have an effect.\n *\n * By default, the lifecycle of these resources is managed automatically, and they are\n * lazily initialized when a Map is first created. By invoking `prewarm()`, these\n * resources will be created ahead of time, and will not be cleared when the last Map\n * is removed from the page. This allows them to be re-used by new Map instances that\n * are created later. They can be manually cleared by calling\n * `maplibregl.clearPrewarmedResources()`. This is only necessary if your web page remains\n * active but stops using maps altogether.\n *\n * This is primarily useful when using GL-JS maps in a single page app, wherein a user\n * would navigate between various views that can cause Map instances to constantly be\n * created and destroyed.\n *\n * @example\n * ```ts\n * maplibregl.prewarm()\n * ```\n */\n static prewarm = prewarm;\n /**\n * Clears up resources that have previously been created by `maplibregl.prewarm()`.\n * Note that this is typically not necessary. You should only call this function\n * if you expect the user of your app to not return to a Map view at any point\n * in your application.\n *\n * @example\n * ```ts\n * maplibregl.clearPrewarmedResources()\n * ```\n */\n static clearPrewarmedResources = clearPrewarmedResources;\n /**\n * Returns the package version of the library\n * @returns Package version of the library\n */\n static get version(): string {\n return version;\n }\n\n /**\n * Gets and sets the number of web workers instantiated on a page with GL JS maps.\n * By default, workerCount is 1 except for Safari browser where it is set to half the number of CPU cores (capped at 3).\n * Make sure to set this property before creating any map instances for it to have effect.\n *\n * @returns Number of workers currently configured.\n * @example\n * ```ts\n * maplibregl.workerCount = 2;\n * ```\n */\n static get workerCount(): number {\n return WorkerPool.workerCount;\n }\n\n static set workerCount(count: number) {\n WorkerPool.workerCount = count;\n }\n /**\n * Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel,\n * which affects performance in raster-heavy maps. 16 by default.\n *\n * @returns Number of parallel requests currently configured.\n * @example\n * ```ts\n * maplibregl.maxParallelImageRequests = 10;\n * ```\n */\n static get maxParallelImageRequests(): number {\n return config.MAX_PARALLEL_IMAGE_REQUESTS;\n }\n\n static set maxParallelImageRequests(numRequests: number) {\n config.MAX_PARALLEL_IMAGE_REQUESTS = numRequests;\n }\n\n static get workerUrl(): string {\n return config.WORKER_URL;\n }\n\n static set workerUrl(value: string) {\n config.WORKER_URL = value;\n }\n\n /**\n * Sets a custom load tile function that will be called when using a source that starts with a custom url schema.\n * The example below will be triggered for custom:// urls defined in the sources list in the style definitions.\n * The function passed will receive the request parameters and should call the callback with the resulting request,\n * for example a pbf vector tile, non-compressed, represented as ArrayBuffer.\n *\n * @param customProtocol - the protocol to hook, for example 'custom'\n * @param loadFn - the function to use when trying to fetch a tile specified by the customProtocol\n * @example\n * This will fetch a file using the fetch API (this is obviously a non interesting example...)\n * ```ts\n * maplibregl.addProtocol('custom', (params, callback) => {\n fetch(`https://${params.url.split(\"://\")[1]}`)\n .then(t => {\n if (t.status == 200) {\n t.arrayBuffer().then(arr => {\n callback(null, arr, null, null);\n });\n } else {\n callback(new Error(`Tile fetch error: ${t.statusText}`));\n }\n })\n .catch(e => {\n callback(new Error(e));\n });\n return { cancel: () => { } };\n });\n * // the following is an example of a way to return an error when trying to load a tile\n * maplibregl.addProtocol('custom2', (params, callback) => {\n * callback(new Error('someErrorMessage'));\n * return { cancel: () => { } };\n * });\n * ```\n */\n static addProtocol(customProtocol: string, loadFn: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable) {\n config.REGISTERED_PROTOCOLS[customProtocol] = loadFn;\n }\n\n /**\n * Removes a previously added protocol\n *\n * @param customProtocol - the custom protocol to remove registration for\n * @example\n * ```ts\n * maplibregl.removeProtocol('custom');\n * ```\n */\n static removeProtocol(customProtocol: string) {\n delete config.REGISTERED_PROTOCOLS[customProtocol];\n }\n}\n\n//This gets automatically stripped out in production builds.\nDebug.extend(MapLibreGL, {isSafari, getPerformanceMetrics: PerformanceUtils.getPerformanceMetrics});\n\nexport default MapLibreGL;\n","import {DOM} from '../../util/dom';\n\nimport {warnOnce} from '../../util/util';\n\nimport {Event, Evented} from '../../util/evented';\nimport type {Map, GestureOptions} from '../map';\nimport type {IControl} from './control';\n\n/**\n * The {@link FullscreenControl} options\n */\ntype FullscreenOptions = {\n /**\n * `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen.\n */\n container?: HTMLElement;\n};\n\n/**\n * A `FullscreenControl` control contains a button for toggling the map in and out of fullscreen mode.\n * When [requestFullscreen](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen) is not supported, fullscreen is handled via CSS properties.\n * The map's `cooperativeGestures` option is temporarily disabled while the map\n * is in fullscreen mode, and is restored when the map exist fullscreen mode.\n *\n * @group Markers and Controls\n * @param options - the full screen control options\n *\n * @example\n * ```ts\n * map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')}));\n * ```\n * @see [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/)\n *\n * ### Events\n *\n * @event `fullscreenstart` - Fired when fullscreen mode has started\n *\n * @event `fullscreenend` - Fired when fullscreen mode has ended\n */\nexport class FullscreenControl extends Evented implements IControl {\n _map: Map;\n _controlContainer: HTMLElement;\n _fullscreen: boolean;\n _fullscreenchange: string;\n _fullscreenButton: HTMLButtonElement;\n _container: HTMLElement;\n _prevCooperativeGestures: boolean | GestureOptions;\n\n constructor(options: FullscreenOptions = {}) {\n super();\n this._fullscreen = false;\n\n if (options && options.container) {\n if (options.container instanceof HTMLElement) {\n this._container = options.container;\n } else {\n warnOnce('Full screen control \\'container\\' must be a DOM element.');\n }\n }\n\n if ('onfullscreenchange' in document) {\n this._fullscreenchange = 'fullscreenchange';\n } else if ('onmozfullscreenchange' in document) {\n this._fullscreenchange = 'mozfullscreenchange';\n } else if ('onwebkitfullscreenchange' in document) {\n this._fullscreenchange = 'webkitfullscreenchange';\n } else if ('onmsfullscreenchange' in document) {\n this._fullscreenchange = 'MSFullscreenChange';\n }\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map): HTMLElement {\n this._map = map;\n if (!this._container) this._container = this._map.getContainer();\n this._controlContainer = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._setupUI();\n return this._controlContainer;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._controlContainer);\n this._map = null;\n window.document.removeEventListener(this._fullscreenchange, this._onFullscreenChange);\n }\n\n _setupUI() {\n const button = this._fullscreenButton = DOM.create('button', (('maplibregl-ctrl-fullscreen')), this._controlContainer);\n DOM.create('span', 'maplibregl-ctrl-icon', button).setAttribute('aria-hidden', 'true');\n button.type = 'button';\n this._updateTitle();\n this._fullscreenButton.addEventListener('click', this._onClickFullscreen);\n window.document.addEventListener(this._fullscreenchange, this._onFullscreenChange);\n }\n\n _updateTitle() {\n const title = this._getTitle();\n this._fullscreenButton.setAttribute('aria-label', title);\n this._fullscreenButton.title = title;\n }\n\n _getTitle() {\n return this._map._getUIString(this._isFullscreen() ? 'FullscreenControl.Exit' : 'FullscreenControl.Enter');\n }\n\n _isFullscreen() {\n return this._fullscreen;\n }\n\n _onFullscreenChange = () => {\n const fullscreenElement =\n window.document.fullscreenElement ||\n (window.document as any).mozFullScreenElement ||\n (window.document as any).webkitFullscreenElement ||\n (window.document as any).msFullscreenElement;\n\n if ((fullscreenElement === this._container) !== this._fullscreen) {\n this._handleFullscreenChange();\n }\n };\n\n _handleFullscreenChange() {\n this._fullscreen = !this._fullscreen;\n this._fullscreenButton.classList.toggle('maplibregl-ctrl-shrink');\n this._fullscreenButton.classList.toggle('maplibregl-ctrl-fullscreen');\n this._updateTitle();\n\n if (this._fullscreen) {\n this.fire(new Event('fullscreenstart'));\n if (this._map._cooperativeGestures) {\n this._prevCooperativeGestures = this._map._cooperativeGestures;\n this._map.setCooperativeGestures();\n }\n } else {\n this.fire(new Event('fullscreenend'));\n if (this._prevCooperativeGestures) {\n this._map.setCooperativeGestures(this._prevCooperativeGestures);\n delete this._prevCooperativeGestures;\n }\n }\n }\n\n _onClickFullscreen = () => {\n if (this._isFullscreen()) {\n this._exitFullscreen();\n } else {\n this._requestFullscreen();\n }\n };\n\n _exitFullscreen() {\n if (window.document.exitFullscreen) {\n (window.document as any).exitFullscreen();\n } else if ((window.document as any).mozCancelFullScreen) {\n (window.document as any).mozCancelFullScreen();\n } else if ((window.document as any).msExitFullscreen) {\n (window.document as any).msExitFullscreen();\n } else if ((window.document as any).webkitCancelFullScreen) {\n (window.document as any).webkitCancelFullScreen();\n } else {\n this._togglePseudoFullScreen();\n }\n }\n\n _requestFullscreen() {\n if (this._container.requestFullscreen) {\n this._container.requestFullscreen();\n } else if ((this._container as any).mozRequestFullScreen) {\n (this._container as any).mozRequestFullScreen();\n } else if ((this._container as any).msRequestFullscreen) {\n (this._container as any).msRequestFullscreen();\n } else if ((this._container as any).webkitRequestFullscreen) {\n (this._container as any).webkitRequestFullscreen();\n } else {\n this._togglePseudoFullScreen();\n }\n }\n\n _togglePseudoFullScreen() {\n this._container.classList.toggle('maplibregl-pseudo-fullscreen');\n this._handleFullscreenChange();\n this._map.resize();\n }\n}\n","import {DOM} from '../../util/dom';\n\nimport type {Map} from '../map';\nimport type {IControl} from './control';\nimport type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';\n\n/**\n * A `TerrainControl` control contains a button for turning the terrain on and off.\n *\n * @group Markers and Controls\n *\n * @example\n * ```ts\n * let map = new maplibregl.Map({TerrainControl: false})\n * .addControl(new maplibregl.TerrainControl({\n * source: \"terrain\"\n * }));\n * ```\n */\nexport class TerrainControl implements IControl {\n options: TerrainSpecification;\n _map: Map;\n _container: HTMLElement;\n _terrainButton: HTMLButtonElement;\n\n constructor(options: TerrainSpecification) {\n this.options = options;\n }\n\n /** {@inheritDoc IControl.onAdd} */\n onAdd(map: Map) {\n this._map = map;\n this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group');\n this._terrainButton = DOM.create('button', 'maplibregl-ctrl-terrain', this._container);\n DOM.create('span', 'maplibregl-ctrl-icon', this._terrainButton).setAttribute('aria-hidden', 'true');\n this._terrainButton.type = 'button';\n this._terrainButton.addEventListener('click', this._toggleTerrain);\n\n this._updateTerrainIcon();\n this._map.on('terrain', this._updateTerrainIcon);\n return this._container;\n }\n\n /** {@inheritDoc IControl.onRemove} */\n onRemove() {\n DOM.remove(this._container);\n this._map.off('terrain', this._updateTerrainIcon);\n this._map = undefined;\n }\n\n _toggleTerrain = () => {\n if (this._map.getTerrain()) {\n this._map.setTerrain(null);\n } else {\n this._map.setTerrain(this.options);\n }\n this._updateTerrainIcon();\n };\n\n _updateTerrainIcon = () => {\n this._terrainButton.classList.remove('maplibregl-ctrl-terrain');\n this._terrainButton.classList.remove('maplibregl-ctrl-terrain-enabled');\n if (this._map.terrain) {\n this._terrainButton.classList.add('maplibregl-ctrl-terrain-enabled');\n this._terrainButton.title = this._map._getUIString('TerrainControl.disableTerrain');\n } else {\n this._terrainButton.classList.add('maplibregl-ctrl-terrain');\n this._terrainButton.title = this._map._getUIString('TerrainControl.enableTerrain');\n }\n };\n}\n","//\n// Our custom intro provides a specialized \"define()\" function, called by the\n// AMD modules below, that sets up the worker blob URL and then executes the\n// main module, storing its exported value as 'maplibregl'\n\n// The three \"chunks\" imported here are produced by a first Rollup pass,\n// which outputs them as AMD modules.\n\n// Shared dependencies, i.e.:\n/*\ndefine(['exports'], function (exports) {\n // Code for all common dependencies\n // Each module's exports are attached attached to 'exports' (with\n // names rewritten to avoid collisions, etc.)\n})\n*/\nimport '../../staging/maplibregl/shared';\n\n// Worker and its unique dependencies, i.e.:\n/*\ndefine(['./shared.js'], function (__shared__js) {\n // Code for worker script and its unique dependencies.\n // Expects the output of 'shared' module to be passed in as an argument,\n // since all references to common deps look like, e.g.,\n // __shared__js.shapeText().\n});\n*/\n// When this wrapper function is passed to our custom define() above,\n// it gets stringified, together with the shared wrapper (using\n// Function.toString()), and the resulting string of code is made into a\n// Blob URL that gets used by the main module to create the web workers.\nimport '../../staging/maplibregl/worker';\n\n// Main module and its unique dependencies\n/*\ndefine(['./shared.js'], function (__shared__js) {\n // Code for main GL JS module and its unique dependencies.\n // Expects the output of 'shared' module to be passed in as an argument,\n // since all references to common deps look like, e.g.,\n // __shared__js.shapeText().\n //\n // Returns the actual maplibregl (i.e. src/index.js)\n});\n*/\nimport '../../staging/maplibregl/index';\n\nexport default maplibregl;\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","pointGeometry","Point","x","y","this","prototype","clone","add","p","_add","sub","_sub","multByPoint","_multByPoint","divByPoint","_divByPoint","mult","k","_mult","div","_div","rotate","a","_rotate","rotateAround","_rotateAround","matMult","m","_matMult","unit","_unit","perp","_perp","round","_round","mag","Math","sqrt","equals","other","dist","distSqr","dx","dy","angle","atan2","angleTo","b","angleWith","angleWithSep","cos","sin","convert","Array","isArray","unitbezier","UnitBezier","p1x","p1y","p2x","p2y","cx","bx","ax","cy","by","ay","sampleCurveX","t","sampleCurveY","sampleCurveDerivativeX","solveCurveX","epsilon","undefined","i","x2","abs","d2","t0","t1","solve","supportsOffscreenCanvas","offscreenCanvasDistorted","offscreenCanvasSupported","OffscreenCanvas","getContext","createImageBitmap","isOffscreenCanvasDistorted","size","context","willReadFrequently","base","fillStyle","fillRect","floor","data","getImageData","bezier","defaultEasing","clamp","n","min","max","wrap","d","w","extend","dest","sources","src","id","mapObject","input","iterator","output","key","call","filterObject","map","warnOnceHistory","warnOnce","message","console","warn","isCounterClockwise","c","calculateSignedArea","ring","sum","p1","p2","len","length","j","isWorker","WorkerGlobalScope","self","_isSafari","isImageBitmap","image","ImageBitmap","transparentPngUrl","readImageUsingVideoFrame","width","height","VideoFrame","Error","frame","timestamp","format","startsWith","swapBR","Uint8ClampedArray","copyTo","destRowOffset","offset","stride","sourceLeft","sourceTop","rect","layout","computeVideoFrameParameters","tmp","close","offscreenCanvas","offscreenCanvasContext","linkEl","reducedMotionQuery","browser","now","performance","bind","Date","fn","requestAnimationFrame","cancel","cancelAnimationFrame","img","padding","getImageCanvasContext","canvas","window","document","createElement","drawImage","resolveURL","path","href","hardwareConcurrency","navigator","prefersReducedMotion","matchMedia","matches","config","MAX_PARALLEL_IMAGE_REQUESTS","MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME","MAX_TILE_CACHE_ZOOM_LEVELS","REGISTERED_PROTOCOLS","WORKER_URL","AJAXError","constructor","status","statusText","url","body","super","getReferrer","worker","referrer","location","protocol","parent","getProtocolAction","substring","indexOf","makeFetchRequest","requestParameters","callback","controller","AbortController","request","Request","method","credentials","headers","cache","signal","complete","aborted","type","set","fetch","response","ok","arrayBuffer","json","text","get","catch","err","blob","error","code","abort","makeRequest","test","actor","send","Object","hasOwnProperty","xhr","XMLHttpRequest","open","responseType","setRequestHeader","withCredentials","onerror","onload","JSON","parse","getResponseHeader","Blob","makeXMLHttpRequest","getArrayBuffer","sameOrigin","inComingUrl","urlObj","URL","locationObj","host","_addEventListener","listener","listenerList","push","_removeEventListener","index","splice","Event","ErrorEvent","Evented","on","_listeners","off","_oneTimeListeners","once","fire","event","properties","listens","target","listeners","slice","oneTimeListeners","_eventedParent","_eventedParentData","setEventedParent","v8Spec","$version","$root","version","required","values","name","metadata","center","zoom","bearing","default","period","units","pitch","light","terrain","sprite","glyphs","transition","layers","source","source_vector","vector","tiles","bounds","scheme","xyz","tms","minzoom","maxzoom","attribution","promoteId","volatile","source_raster","raster","tileSize","source_raster_dem","encoding","terrarium","mapbox","custom","redFactor","blueFactor","greenFactor","baseShift","source_geojson","geojson","buffer","maximum","minimum","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","source_video","video","urls","coordinates","source_image","layer","fill","line","symbol","circle","heatmap","hillshade","background","paint","layout_background","visibility","visible","none","layout_fill","expression","interpolated","parameters","layout_circle","layout_heatmap","layout_line","butt","square","bevel","miter","requires","layout_symbol","point","auto","never","always","cooperative","viewport","both","tokens","left","right","top","bottom","horizontal","vertical","uppercase","lowercase","layout_raster","layout_hillshade","filter_operator","in","all","any","has","within","geometry_type","LineString","Polygon","function","stops","property","identity","exponential","interval","categorical","colorSpace","rgb","lab","hcl","function_stop","anchor","position","color","intensity","exaggeration","paint_fill","paint_line","paint_circle","paint_heatmap","paint_symbol","overridable","paint_raster","linear","nearest","paint_hillshade","paint_background","duration","delay","constant","refProperties","deref","forEach","deepEqual","keys","operations","setStyle","addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setGeoJSONSourceData","setLayerZoomRange","setLayerProperty","setCenter","setZoom","setBearing","setPitch","setSprite","setGlyphs","setTransition","setLight","sourceId","after","commands","command","args","sourcesRemoved","updateSource","canUpdateGeoJSON","before","prop","diffLayerPropertyChanges","layerId","klass","pluckId","indexById","group","ValidationError","identifier","__line__","extendBy","inputs","ExpressionParsingError","Scope","bindings","concat","NullType","kind","NumberType","StringType","BooleanType","ColorType","ObjectType","ValueType","CollatorType","FormattedType","PaddingType","ResolvedImageType","VariableAnchorOffsetCollectionType","array$1","itemType","N","toString$1","valueMemberTypes","checkSubtype","expected","memberType","isValidType","provided","allowedTypes","some","isValidNativeType","verifyType","sample","Xn","Zn","t2","t3","deg2rad","PI","rad2deg","constrainAngle","rgbToLab","r","g","alpha","z","xyz2lab","rgb2xyz","l","pow","labToRgb","isNaN","lab2xyz","xyz2rgb","parseHex","hex","parseInt","padEnd","parseAlpha","asPercentage","validateNumbers","array","Number","namedColors","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","Color","premultiplied","overwriteGetter","static","rgba","toLowerCase","trim","namedColorsMatch","rgbMatch","match","_","rp","f1","gp","f2","bp","f3","ap","argFormat","join","valFormat","maxValue","hslMatch","h","s","hsla","f","hslToRgb","parseCssColor","Infinity","rgbColor","NaN","rgbToHcl","getterKey","lazyValue","defineProperty","toString","transparent","Collator","caseSensitive","diacriticSensitive","locale","sensitivity","collator","Intl","usage","compare","lhs","rhs","resolvedLocale","resolvedOptions","FormattedSection","scale","fontStack","textColor","Formatted","sections","unformatted","isEmpty","section","fromString","Padding","val","stringify","anchors","Set","VariableAnchorOffsetCollection","anchorValue","offsetValue","ResolvedImage","options","available","validateRGBA","isValue","mixed","item","typeOf","String","Literal","expectedType","evaluate","eachChild","outputDefined","RuntimeError","toJSON","types$1","string","number","boolean","object","Assertion","parsed","ctx","every","arg","types","Coercion","Boolean","parseColor","pad","coll","num","geometryTypes","EvaluationContext","globals","feature","featureState","formattedSection","_parseColorCache","availableImages","canonical","geometryType","geometry","canonicalID","cached","ParsingContext","registry","isConstantFunc","scope","errors","part","_isConstant","expr","_parse","annotate","typeAnnotation","op","Expr","actual","ec","CollatorExpression","EXTENT","updateBBox","bbox","coord","boxWithinBox","bbox1","bbox2","getTileCoordinates","log","tilesAtZoom","onBoundary","x1","y1","y2","pointWithinPolygon","rings","inside","len2","pointWithinPolygons","polygons","twoSided","q1","q2","x3","y3","det1","det2","lineIntersectPolygon","polygon","v1","v2","lineStringWithinPolygon","lineStringWithinPolygons","getTilePolygon","getTilePolygons","updatePoint","polyBBox","worldSize","halfWorldSize","shift","getTilePoints","pointBBox","shifts","tilePoints","points","getTileLines","lineBBox","tileLines","tileLine","Within","geometries","features","polygonGeometry","tilePolygon","tilePolygons","pointsWithinPolygons","linesWithinPolygons","Var","boundExpression","CompoundExpression","_evaluate","definition","definitions","availableOverloads","overloads","signature","signatureContext","params","isExpressionConstant","parsedArgs","argParseFailed","signatures","stringifySignature","actualTypes","isTypeAnnotation","childrenConstant","child","isFeatureConstant","isGlobalPropertyConstant","isStateConstant","findStopLessThanOrEqualTo","lastIndex","currentValue","nextValue","lowerIndex","upperIndex","currentIndex","Step","labels","outputs","label","outputType","labelKey","valueKey","stopCount","out","from","to","interpolate","spaceKey","hue0","chroma0","light0","alphaF","hue1","chroma1","light1","alphaT","hue","chroma","dh","hclToRgb","variableAnchorOffsetCollection","fromValues","toValues","fx","fy","tx","ty","Interpolate","operator","interpolation","lower","upper","exponentialInterpolation","controlPoints","rest","interpolationFactor","outputLower","outputUpper","lowerValue","upperValue","difference","progress","Coalesce","needsAnnotation","requestedImageName","argCount","Let","binding","At","In","needle","haystack","IndexOf","fromIndex","Match","inputType","cases","otherwise","labelContext","MAX_SAFE_INTEGER","Case","branches","Slice","beginIndex","endIndex","isComparableType","eqCollate","makeComparison","compareBasic","compareWithCollator","isOrderComparison","Comparison","hasUntypedArgument","lt","rt","Equals","NotEquals","LessThan","GreaterThan","LessThanOrEqual","GreaterThanOrEqual","NumberFormat","currency","minFractionDigits","maxFractionDigits","style","minimumFractionDigits","maximumFractionDigits","FormatExpression","firstArg","nextTokenMayBeObject","font","lastExpression","content","evaluatedContent","ImageExpression","evaluatedImageName","Length","expressions","at","case","coalesce","let","literal","var","obj","v","varargs","success","supportsPropertyExpression","spec","supportsZoomExpression","supportsInterpolation","getType","isFunction","identityFunction","createFunction","propertySpec","isColor","zoomAndFeatureDependent","zoomDependent","parseFn","stop","innerFun","hashedStops","categoricalKeyType","evaluateExponentialFunction","evaluateIntervalFunction","evaluateCategoricalFunction","create","evaluateIdentityFunction","featureFunctions","zoomStops","featureFunctionStops","interpolationType","coalesce$1","keyType","interp","evaluatedLower","evaluatedUpper","register","typeof","heatmapDensity","lineProgress","accumulated","ln2","LN2","pi","E","log10","LN10","ln","log2","asin","acos","atan","ceil","binarySearch","isSupportedScript","upcase","toUpperCase","downcase","StyleExpression","_warningHistory","_evaluator","_defaultValue","_enumValues","evaluateWithoutErrorHandling","isExpression","createExpression","parser","enum","formatted","resolvedImage","getExpectedType","ZoomConstantExpression","_styleExpression","isStateDependent","ZoomDependentExpression","createPropertyExpression","expressionInput","isFeatureConstantResult","isZoomConstant","zoomCurve","findZoomCurve","StylePropertyFunction","specification","_parameters","_specification","serialized","childResult","isExpressionFilter","filterSpec","createFilter","needGeometry","convertFilter$1","compiled","globalProperties","geometryNeeded","convertComparisonOp$1","convertNegation","filters","convertInOp$1","convertHasOp$1","sort","str","getKey","validateConstants","constants","unbundle","valueOf","deepUnbundle","unbundledValue","validateObject","elementSpecs","valueSpec","elementValidators","objectElementValidators","styleSpec","validateSpec","objectKey","elementSpecKey","split","elementSpec","validateElement","validateArray","arraySpec","validateArrayElement","arrayElementValidator","arrayElementSpec","arrayIndex","validateNumber","validateFunction","functionValueSpec","functionType","stopKeyType","previousStopDomainValue","previousStopDomainZoom","stopDomainValues","isZoomFunction","isPropertyFunction","isZoomAndPropertyFunction","validateFunctionStop","validateStopDomainValue","reportValue","isFinite","validateExpression","expressionContext","expressionObj","propertyKey","propertyType","validateEnum","validateFilter","validateNonExpressionFilter","validateProperty","layerSpec","layerType","transitionMatch","tokenMatch","exec","validatePaintProperty","validateLayoutProperty","validateLayer","ref","otherLayer","sourceType","validateString","validateSource","replace","_a","sourceName","rasterDEM","rasterDEMSpec","rootType","isCustomEncoding","customEncodingKeys","encodingName","includes","validateRasterDEMSource","mapExpr","reduceExpr","validateLight","lightSpec","validateTerrain","terrainSpec","validateSprite","allSpriteIds","allSpriteURLs","VALIDATORS","validate","validateGlyphsUrl","validateStyleMin","sortErrors","injectValidateSpec","validator","wrapCleanErrors","inner","paintProperty","layoutProperty","validateStyle","emitValidationErrors","emitter","hasErrors","TransferableGridIndex","extent","cells","ArrayBuffer","Int32Array","start","end","subarray","bboxesOffset","bboxes","insert","_insertReadonly","uid","_forEachCell","_insertCell","cellIndex","query","intersectionTest","_queryCell","seenUids","cell","u","arg1","arg2","cx1","_convertToCellCoord","cy1","cx2","cy2","_convertFromCellCoord","toArrayBuffer","metadataLength","totalCellLength","grid","transferables","writeable","omit","shallow","_classRegistryKey","isArrayBuffer","serialize","RegExp","isView","view","ImageData","$name","deserialize","ZoomHistory","first","update","floorZ","lastIntegerZoom","lastIntegerZoomTime","lastZoom","lastFloorZoom","unicodeBlockLookup","char","Arabic","Khmer","Hiragana","Katakana","Bopomofo","Kanbun","allowsVerticalWritingMode","chars","charHasUprightVerticalOrientation","charCodeAt","allowsLetterSpacing","charAllowsLetterSpacing","isChar","charHasRotatedVerticalOrientation","charHasNeutralVerticalOrientation","charInRTLScript","charInSupportedScript","canRenderRTL","stringContainsRTLText","_completionCallback","pluginStatus","pluginURL","triggerPluginCompletionEvent","sendPluginStateToWorker","evented","getRTLTextPluginStatus","downloadRTLTextPlugin","plugin","applyArabicShaping","processBidirectionalText","processStyledBidirectionalText","isLoaded","isLoading","setState","state","isParsed","getPluginURL","EvaluationParameters","fadeDuration","zoomHistory","isStringInSupportedScript","rtlTextPlugin","crossFadingFactor","getCrossfadeParameters","fraction","fromScale","toScale","PropertyValue","normalizePropertyExpression","isDataDriven","possiblyEvaluate","TransitionablePropertyValue","transitioned","prior","TransitioningPropertyValue","untransitioned","Transitionable","_properties","_values","defaultTransitionablePropertyValues","getValue","setValue","getTransition","Transitioning","begin","finalValue","easeCubicInOut","defaultTransitioningPropertyValues","PossiblyEvaluated","hasTransition","Layout","defaultPropertyValues","hasValue","PossiblyEvaluatedPropertyValue","isConstant","constantOr","defaultPossiblyEvaluatedValues","DataConstantProperty","interpolationFn","interpolates","DataDrivenProperty","overrides","interpolatedValue","CrossFadedDataDrivenProperty","evaluatedValue","constantValue","_calculate","cameraVal","mid","CrossFadedProperty","ColorRampProperty","Properties","overridableProperties","defaultPropertyValue","defaultTransitionablePropertyValue","TRANSITION_SUFFIX","StyleLayer","_featureFilter","sourceLayer","_unevaluatedLayout","_transitionablePaint","_transitioningPaint","_crossfadeParameters","getLayoutProperty","_validate","getPaintProperty","endsWith","transitionable","isCrossFadedProperty","wasDataDriven","oldValue","_handleSpecialPaintPropertyUpdate","newValue","_handleOverridablePaintPropertyUpdate","isHidden","updateTransitions","recalculate","is3D","isTileClipped","hasOffscreenPass","resize","viewTypes","Int8","Int8Array","Uint8","Uint8Array","Int16","Int16Array","Uint16","Uint16Array","Int32","Uint32","Uint32Array","Float32","Float32Array","Struct","structArray","_structArray","_pos1","_pos2","_pos4","_pos8","StructArray","isTransferred","capacity","_trim","byteLength","bytesPerElement","_refreshViews","clear","reserve","oldUint8Array","uint8","createLayout","members","alignment","maxSize","member","typeSize","BYTES_PER_ELEMENT","memberOffset","align","components","StructArrayLayout2i4","int16","emplaceBack","v0","emplace","o2","StructArrayLayout3i6","StructArrayLayout4i8","v3","StructArrayLayout2i4i12","v4","v5","StructArrayLayout2i4ub8","o1","StructArrayLayout2f8","float32","o4","StructArrayLayout10ui20","uint16","v6","v7","v8","v9","StructArrayLayout4i4ui4i24","v10","v11","StructArrayLayout3f12","StructArrayLayout1ul4","uint32","StructArrayLayout6i1ul2ui20","StructArrayLayout2i2i2i12","StructArrayLayout2f1f2i16","StructArrayLayout2ub2f12","StructArrayLayout3ui6","StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48","v12","v13","v14","v15","v16","StructArrayLayout8i15ui1ul2f2ui64","v17","v18","v19","v20","v21","v22","v23","v24","v25","v26","v27","StructArrayLayout1f4","StructArrayLayout1ui2f12","StructArrayLayout1ul2ui8","StructArrayLayout2ui4","StructArrayLayout1ui2","StructArrayLayout4f16","CollisionBoxStruct","anchorPointX","anchorPointY","featureIndex","sourceLayerIndex","bucketIndex","anchorPoint","CollisionBoxArray","PlacedSymbolStruct","anchorX","anchorY","glyphStartIndex","numGlyphs","vertexStartIndex","lineStartIndex","lineLength","segment","lowerSize","upperSize","lineOffsetX","lineOffsetY","writingMode","placedOrientation","hidden","crossTileID","associatedIconIndex","PlacedSymbolArray","SymbolInstanceStruct","rightJustifiedTextSymbolIndex","centerJustifiedTextSymbolIndex","leftJustifiedTextSymbolIndex","verticalPlacedTextSymbolIndex","placedIconSymbolIndex","verticalPlacedIconSymbolIndex","textBoxStartIndex","textBoxEndIndex","verticalTextBoxStartIndex","verticalTextBoxEndIndex","iconBoxStartIndex","iconBoxEndIndex","verticalIconBoxStartIndex","verticalIconBoxEndIndex","numHorizontalGlyphVertices","numVerticalGlyphVertices","numIconVertices","numVerticalIconVertices","useRuntimeCollisionCircles","textBoxScale","collisionCircleDiameter","textAnchorOffsetStartIndex","textAnchorOffsetEndIndex","SymbolInstanceArray","GlyphOffsetArray","getoffsetX","SymbolLineVertexArray","getx","gety","gettileUnitDistanceFromAnchor","TextAnchorOffsetStruct","textAnchor","textOffset0","textOffset1","TextAnchorOffsetArray","FeatureIndexStruct","FeatureIndexArray","PosArray","CircleLayoutArray","FillLayoutArray","FillExtrusionLayoutArray","LineLayoutArray","LineExtLayoutArray","PatternLayoutArray","SymbolLayoutArray","SymbolDynamicLayoutArray","SymbolOpacityArray","CollisionBoxLayoutArray","CollisionVertexArray","TriangleIndexArray","LineIndexArray","SegmentVector","segments","prepareSegment","numVertices","layoutVertexArray","indexArray","sortKey","MAX_VERTEX_ARRAY_LENGTH","vertexLength","vertexOffset","primitiveOffset","primitiveLength","destroy","vaos","packUint8ToFloat","patternAttributes","seed","remainder","bytes","h1","h1b","c1","c2","k1","murmur3","require$$0","murmur2","murmurhashJsModule","exports","FeaturePositionMap","ids","positions","indexed","getNumericId","getPositions","intId","Float64Array","numValue","pivot","swap","arr","Uniform","gl","Uniform1f","current","uniform1f","Uniform4f","uniform4f","UniformColor","emptyMat4","packColor","ConstantBinder","names","uniformNames","setUniform","uniform","getBinding","CrossFadedConstantBinder","patternFrom","patternTo","pixelRatioFrom","pixelRatioTo","setConstantPatternPositions","posTo","posFrom","pixelRatio","tlbr","uniformName","pos","substr","SourceExpressionBinder","PaintVertexArray","paintVertexAttributes","paintVertexArray","populatePaintArray","newLength","imagePositions","_setPaintValue","updatePaintArray","upload","paintVertexBuffer","updateData","createVertexBuffer","CompositeExpressionBinder","useIntegerZoom","minColor","maxColor","currentZoom","factor","CrossFadedCompositeBinder","zoomInPaintVertexArray","zoomOutPaintVertexArray","_setPaintValues","patterns","imageMin","imageMid","imageMax","tl","br","zoomInPaintVertexBuffer","zoomOutPaintVertexBuffer","ProgramConfiguration","filterProperties","binders","_buffers","paintAttributeNames","propType","isCrossFaded","StructArrayLayout","layoutType","cacheKey","getMaxValue","binder","populatePaintArrays","updatePaintArrays","featureStates","featureMap","vtLayer","dirty","defines","getBinderAttributes","getBinderUniforms","uniforms","getPaintVertexBuffers","getUniforms","locations","setUniforms","binderUniforms","updatePaintBuffers","crossfade","patternVertexBuffer","ProgramConfigurationSet","programConfigurations","needsUpload","_featureMap","_bufferOffset","binderType","defaultLayouts","composite","layoutException","getLayoutException","MAX","BITS","MIN","loadGeometry","toEvaluationFeature","addCircleVertex","extrudeX","extrudeY","CircleBucket","overscaling","layerIds","hasPattern","stateDependentLayerIds","populate","styleLayer","bucketFeatures","circleSortKey","sortFeaturesByKey","evaluationFeature","bucketFeature","addFeature","states","stateDependentLayers","uploadPending","uploaded","layoutVertexBuffer","layoutAttributes","indexBuffer","createIndexBuffer","polygonIntersectsPolygon","polygonA","polygonB","polygonContainsPoint","lineIntersectsLine","polygonIntersectsBufferedPoint","radius","pointIntersectsBufferedLine","polygonIntersectsMultiPolygon","multiPolygon","multiPolygonContainsPoint","lineIntersectsBufferedLine","lineA","lineB","a0","a1","lineSegmentIntersectsLineSegment","b0","b1","radiusSquared","distToSegmentSquared","l2","edgeIntersectsBox","e1","e2","corners","dir","getMaximumPaintValue","bucket","translateDistance","translate","queryGeometry","translateAnchor","pixelsToTileUnits","pt","translated","properties$8","EPSILON","ARRAY_TYPE","multiply","a00","a01","a02","a03","a10","a11","a12","a13","a20","a21","a22","a23","a30","a31","a32","a33","b2","b3","hypot","arguments","mul","transformMat4","glMatrix.ARRAY_TYPE","CircleStyleLayer","createBucket","queryRadius","circleBucket","queryIntersectsFeature","transform","pixelPosMatrix","translatedPolygon","alignWithMap","transformedPolygon","projectPoint","projectQueryGeometry","transformedSize","transformedPoint","adjustedSize","projectedCenter","vec4.transformMat4","cameraToCenterDistance","HeatmapBucket","properties$7","createImage","channels","RangeError","resizeImage","newImage","copyImage","srcImg","dstImg","srcPt","dstPt","srcData","dstData","srcOffset","dstOffset","AlphaImage","RGBAImage","copy","renderColorRamp","evaluationGlobals","resolution","clips","renderPixel","evaluationKey","pxColor","clip","HeatmapStyleLayer","_updateColorRamp","colorRamp","colorRampTexture","heatmapFbo","properties$6","HillshadeStyleLayer","earcut","holeIndices","dim","minX","minY","maxX","maxY","invSize","hasHoles","outerLen","outerNode","linkedList","triangles","prev","list","queue","steiner","getLeftmost","compareX","eliminateHole","eliminateHoles","earcutLinked","clockwise","last","signedArea","insertNode","removeNode","filterPoints","again","area","ear","pass","zOrder","prevZ","nextZ","q","tail","numMerges","pSize","qSize","inSize","sortLinked","indexCurve","isEarHashed","isEar","cureLocalIntersections","splitEarcut","x0","y0","pointInTriangle","minZ","maxZ","intersects","locallyInside","isValidDiagonal","splitPolygon","hole","bridge","hx","hy","qx","mx","my","tanMin","sectorContainsSector","findHoleBridge","bridgeReverse","leftmost","px","py","intersectsPolygon","middleInside","sign","o3","onSegment","a2","Node","an","earcutModule","deviation","polygonArea","trianglesArea","flatten","vertices","holes","dimensions","holeIndex","quickselect","quickselectStep","defaultCompare","exp","sd","classifyRings","maxRings","ccw","compareAreas","patternDependencies","patternProperty","constantPattern","addPatternDependencies","patternFeature","patternPropertyValue","FillBucket","patternFeatures","indexArray2","segments2","fillSortKey","addFeatures","indexBuffer2","triangleSegment","triangleIndex","flattened","lineSegment","lineIndex","indices","properties$5","FillStyleLayer","outlineColor","centroidAttributes","vectortilefeature","VectorTileFeature","pbf","_pbf","_geometry","_keys","readFields","readFeature","tag","readVarint","readTag","cmd","lines","cmdLen","readSVarint","toGeoJSON","coords","project","vectortilelayer","VectorTileLayer","_features","readLayer","readString","readFloat","readDouble","readVarint64","readBoolean","readValueMessage","readTile","vectorTile","VectorTile","require$$1","require$$2","vectorTileFeatureTypes","mvt","FACTOR","addVertex","vertexArray","nx","ny","nz","FillExtrusionBucket","centroidVertexArray","centroidVertexBuffer","centroid","vertexCount","isEntirelyOutside","edgeDistance","isBoundaryEdge","bottomRight","properties$4","FillExtrusionStyleLayer","projectedQueryGeometry","projected","zBase","zTop","projectedBase","projectedTop","baseXZ","baseYZ","baseZZ","baseWZ","topXZ","topYZ","topZZ","topWZ","ringBase","ringTop","sX","sY","sZ","sW","baseZ","baseW","topX","topY","topZ","topW","projectExtrusion","closestDistance","getIntersectionDistance","topA","face","checkIntersection","dot","projectedFace","ab","ac","dotABAB","dotABAC","dotACAC","dotAPAB","dotAPAC","denom","distance","lineLayoutAttributes","lineLayoutAttributesExt","COS_HALF_SHARP_CORNER","MAX_LINE_DISTANCE","LINE_DISTANCE_BUFFER_BITS","LineBucket","lineClipsArray","gradients","layoutVertexArray2","maxLineLength","lineSortKey","patternBucketFeature","layoutVertexBuffer2","layoutAttributesExt","lineFeatureClips","cap","miterLimit","roundLimit","lineClips","addLine","scaledDistance","totalDistance","updateScaledDistance","isPolygon","sharpCornerOffset","currentVertex","prevVertex","nextVertex","prevNormal","nextNormal","joinNormal","cosAngle","cosHalfAngle","miterLength","approxAngle","isSharpCorner","lineTurnsLeft","prevSegmentLength","newPrevVertex","updateDistance","addCurrentVertex","middleVertex","currentJoin","bevelLength","offsetA","offsetB","extrude","addHalfVertex","nextSegmentLength","newCurrentVertex","normal","endLeft","endRight","rightX","rightY","up","linesofarScaled","properties$3","LineFloorwidthProperty","lineFloorwidthProperty","LineStyleLayer","gradientVersion","gradientExpression","stepInterpolant","isZoomExpression","lineBucket","getLineWidth","halfWidth","lineOffset","newRings","ringIndex","newRing","aToB","bToC","offsetLine","multiLine","polygonIntersectsBufferedMultiLine","lineWidth","lineGapWidth","symbolLayoutAttributes","dynamicLayoutAttributes","collisionVertexAttributes","collisionBoxLayout","collisionCircleLayout","transformText","toLocaleUpperCase","toLocaleLowerCase","transformTextInternal","verticalizedCharacterMap","$","ONE_EM","Pbf","ieee754","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","buf","Varint","Fixed64","Bytes","Fixed32","SHIFT_LEFT_32","SHIFT_RIGHT_32","utf8TextDecoder","TextDecoder","readPackedEnd","toNum","low","high","isSigned","makeRoomForExtraLength","startPos","extraLen","realloc","writePackedVarint","writeVarint","writePackedSVarint","writeSVarint","writePackedFloat","writeFloat","writePackedDouble","writeDouble","writePackedBoolean","writeBoolean","writePackedFixed32","writeFixed32","writePackedSFixed32","writeSFixed32","writePackedFixed64","writeFixed64","writePackedSFixed64","writeSFixed64","readUInt32","writeInt32","readInt32","readField","skip","readMessage","readFixed32","readSFixed32","readFixed64","readSFixed64","readVarintRemainder","decode","readUtf8TextDecoder","bytesPerSequence","fromCharCode","readUtf8","readBytes","readPackedVarint","readPackedSVarint","readPackedBoolean","readPackedFloat","readPackedDouble","readPackedFixed32","readPackedSFixed32","readPackedFixed64","readPackedSFixed64","writeTag","finish","writeBigVarintLow","lsb","writeBigVarintHigh","writeBigVarint","writeString","lead","writeUtf8","writeBytes","writeRawMessage","writeMessage","writeBytesField","writeFixed32Field","writeSFixed32Field","writeFixed64Field","writeSFixed64Field","writeVarintField","writeSVarintField","writeStringField","writeFloatField","writeDoubleField","writeBooleanField","border","readFontstacks","readFontstack","bitmap","advance","readGlyph","metrics","glyph","GLYPH_PBF_BORDER","potpack","boxes","maxWidth","box","spaces","space","pop","IMAGE_PADDING","ImagePosition","paddedRect","stretchX","stretchY","displaySize","ImageAtlas","icons","iconPositions","patternPositions","haveRenderCallbacks","bins","addImages","bin","images","hasRenderCallback","patchUpdatedImages","imageManager","texture","dispatchRenderCallbacks","updatedImages","patchUpdatedImage","getImage","WritingMode","ai","SHAPING_DEFAULT_OFFSET","SectionOptions","imageName","textOptions","imageOptions","TaggedString","sectionIndex","imageSectionID","defaultFontStack","addImageSection","addTextSection","getSection","getSectionIndex","getCharCode","verticalizePunctuation","nextCharCode","prevCharCode","beginningWhitespace","whitespace","trailingWhitespace","getMaxScale","reduce","forText","nextImageSectionCharCode","getNextImageSectionCharCode","forImage","shapeText","glyphMap","glyphPositions","lineHeight","textJustify","spacing","allowVerticalPlacement","symbolPlacement","layoutTextSize","layoutTextSizeThisZoom","logicalInput","fromFeature","untaggedLines","determineLineBreaks","taggedLine","processedLines","lineBreakPoints","lineBreak","breakLines","positionedLines","shaping","iconsInText","verticalizable","maxLineHeight","justify","lineMaxScale","maxLineOffset","positionedLine","positionedGlyphs","codePoint","baselineOffset","verticalAdvance","imagePosition","glyphPosition","justifyLine","currentLineHeight","horizontalAlign","verticalAlign","getAnchorAlignment","blockHeight","lineCount","shiftX","shiftY","positionedGlyph","shapeLines","breakable","getGlyphAdvance","calculateBadness","targetWidth","penalty","isLastBreak","raggedness","calculatePenalty","nextCodePoint","penalizableIdeographicBreak","evaluateBreak","breakIndex","breakX","potentialBreaks","bestPriorBreak","bestBreakBadness","potentialBreak","breakBadness","badness","priorBreak","leastBadBreaks","lastLineBreak","potentialLineBreaks","totalWidth","determineAverageLineWidth","hasServerSuggestedBreakpoints","currentX","ideographicBreak","lastPositionedGlyph","lineIndent","shapeIcon","iconOffset","iconAnchor","fitIconToText","shapedIcon","shapedText","textFit","fontScale","collisionPadding","textLeft","textRight","textTop","textBottom","MAX_GLYPH_ICON_SIZE","SIZE_PACK_FACTOR","MAX_PACKED_SIZE","getSizeData","tileZoom","layoutSize","minZoom","maxZoom","minSize","getOverlapMode","overlapProp","allowOverlapProp","overlap","shaderOpacityAttributes","ox","oy","sizeVertex","isSDF","pixelOffsetX","pixelOffsetY","minFontScaleX","minFontScaleY","aSizeX","aSizeY","addDynamicAttributes","dynamicLayoutVertexArray","containsRTLText","formattedText","SymbolBuffers","opacityVertexArray","hasVisibleVertices","placedSymbolArray","dynamicIndexBuffer","dynamicLayoutVertexBuffer","opacityVertexBuffer","itemSize","CollisionBuffers","LayoutArray","IndexArray","collisionVertexArray","collisionVertexBuffer","SymbolBucket","collisionBoxArray","hasRTLText","sortKeyRanges","collisionCircleArray","placementInvProjMatrix","mat4.identity","placementViewportMatrix","unevaluatedLayoutValues","textSizeData","iconSizeData","canOverlap","sortFeaturesByY","writingModes","wm","sourceID","createArrays","icon","glyphOffsetArray","lineVertexArray","symbolInstances","textAnchorOffsets","calculateGlyphDependencies","stack","textAlongLine","doesAllowVerticalWritingMode","verticalChar","charAt","textFont","textField","iconImage","hasText","hasIcon","symbolSortKey","iconDependencies","stacks","glyphDependencies","resolvedTokens","getValueAndResolveTokens","factory","globalRTLTextPlugin","sectionFont","sectionStack","leftIndex","rightIndex","mergedFeatures","mergedIndex","mergeFromRight","leftKey","rightKey","geom","mergeFromLeft","onRight","mergeLines","hasDebugData","textCollisionBox","iconCollisionBox","destroyDebugData","addToLineVertexArray","sumForwardLength","sumBackwardLength","tileUnitDistanceFromAnchor","vertex","addSymbols","arrays","quads","alongLine","labelAnchor","glyphOffsetArrayStart","tr","bl","tex","pixelOffsetTL","pixelOffsetBR","glyphOffset","_addCollisionDebugVertex","addCollisionDebugVertices","boxAnchorPoint","symbolInstance","addDebugCollisionBoxes","startIndex","isText","generateCollisionDebugBuffers","_deserializeCollisionBoxesForSymbol","textStartIndex","textEndIndex","verticalTextStartIndex","verticalTextEndIndex","iconStartIndex","iconEndIndex","verticalIconStartIndex","verticalIconEndIndex","collisionArrays","textBox","textFeatureIndex","verticalTextBox","verticalTextFeatureIndex","iconBox","iconFeatureIndex","verticalIconBox","verticalIconFeatureIndex","deserializeCollisionBoxes","hasTextData","hasIconData","hasTextCollisionBoxData","hasIconCollisionBoxData","addIndicesForPlacedSymbol","iconOrText","placedSymbolIndex","placedSymbol","vertexIndex","getSortedSymbolIndexes","sortedAngle","symbolInstanceIndexes","rotatedYs","featureIndexes","aIndex","bIndex","addToSortKeyRanges","symbolInstanceIndex","symbolInstanceEnd","symbolInstanceStart","sortFeatures","featureSortOrder","MAX_GLYPHS","properties$2","runtimeType","getOverride","o","hasOverride","FormatSectionOverride","defaultValue","SymbolStyleLayer","deduped","_setPaintOverrides","unevaluated","resolveTokens","hasPaintOverride","overriden","override","styleExpression","propertyName","hasOverrides","checkSections","checkExpression","properties$1","BackgroundStyleLayer","RasterStyleLayer","CustomStyleLayer","implementation","onAdd","painter","onRemove","renderingMode","prerender","ThrottledInvoker","_callback","_triggered","MessageChannel","_channel","port2","onmessage","trigger","port1","postMessage","setTimeout","remove","earthRadius","LngLat","lng","lat","toArray","distanceTo","lngLat","rad","lat1","lat2","lon","earthCircumfrence","circumferenceAtLatitude","latitude","mercatorXfromLng","mercatorYfromLat","mercatorZfromAltitude","altitude","lngFromMercatorX","latFromMercatorY","MercatorCoordinate","lngLatLike","toLngLat","toAltitude","meterInMercatorCoordinateUnits","getMercCoords","CanonicalTileID","calculateKey","quadkey","mask","getQuadkey","isChildOf","dz","getTilePoint","UnwrappedTileID","OverscaledTileID","overscaledZ","scaledTo","targetZ","zDifference","calculateScaledKey","withWrap","children","sourceMaxZoom","isLessThan","wrapped","unwrapTo","overscaleFactor","toUnwrapped","DEMData","_idx","MIN_SAFE_INTEGER","ele","pixels","unpack","getUnpackVector","getPixels","backfillBorder","borderTile","xMin","xMax","yMin","yMax","DictionaryCoder","strings","_stringToNumber","_numberToString","encode","GeoJSONFeature","vectorTileFeature","_vectorTileFeature","_z","_x","_y","FeatureIndex","tileID","grid3D","featureIndexArray","loadVTLayers","vtLayers","vt","Protobuf","rawTileData","sourceLayerCoder","styleLayers","serializedLayers","sourceFeatureState","featureFilter","queryPadding","getBounds","matching","cameraBounds","cameraQueryGeometry","matching3D","bx1","by1","bx2","by2","boxX1","boxY1","boxX2","boxY2","corner","polygonIntersectsBox","topDownFeatureComparator","previousIndex","featureGeometry","loadMatchingFeature","filterLayerIDs","layerIDs","bucketLayerIDs","arraysIntersect","sourceLayerName","getId","layerID","getState","serializedLayer","evaluateProperties","intersectionZ","geojsonFeature","layerResult","lookupSymbolFeatures","symbolFeatureIndexes","symbolFeatureIndex","hasLayer","sourceLayerId","serializedProperties","styleLayerProperties","clipLine","clippedLines","clippedLine","p0","Anchor","checkMaxAngle","labelLength","windowSize","maxAngle","anchorDistance","recentCorners","recentAngleDelta","angleDelta","getLineLength","getAngleWindowSize","glyphSize","boxScale","getShapedLabelLength","getCenterAnchor","angleWindowSize","prevDistance","centerDistance","segmentDistance","getAnchors","tileExtent","shapedLabelLength","isLineContinued","resample","placeAtMiddle","halfLabelLength","markedDistance","segmentDist","getIconQuads","iconRotate","isSDFIcon","hasIconTextFit","imageWidth","imageHeight","iconWidth","iconHeight","reduceRanges","range","stretchWidth","stretchHeight","fixedWidth","fixedHeight","stretchOffsetX","stretchContentWidth","stretchOffsetY","stretchContentHeight","fixedOffsetX","fixedContentWidth","fixedOffsetY","fixedContentHeight","sumWithinRange","makeBox","leftEm","getEmOffset","stretch","leftPx","getPxOffset","fixed","topEm","topPx","rightEm","rightPx","bottomEm","bottomPx","matrix","xCuts","stretchZonesToCuts","yCuts","xi","yi","ranges","stretchZones","fixedSize","stretchSize","cuts","stretchOffset","iconSize","fixedOffset","CollisionFeature","shaped","alignLine","boxStartIndex","circleDiameter","rotateRadians","boxEndIndex","TinyQueue","_down","_up","peek","halfLength","best","findPoleOfInaccessibility","polygonRings","precision","debug","outerRing","cellSize","cellQueue","Queue","compareMax","Cell","bestCell","getCentroidCell","numProbes","minDistSq","pointToPolygonDist","SQRT2","TextAnchorEnum","aq","INVALID_TEXT_OFFSET","POSITIVE_INFINITY","evaluateVariableOffset","offsetX","offsetY","fromTextOffset","radialOffset","hypotenuse","fromRadialOffset","getTextVariableAnchorOffset","variableAnchorOffset","sourceValues","destValues","variableAnchor","textOffset","anchorOffsets","getAnchorJustification","shapedTextOrientations","imageMap","sizes","layoutIconSize","textMaxSize","defaultHorizontalShaping","getDefaultHorizontalShaping","tilePixelRatio","textMaxBoxScale","iconBoxScale","symbolMinDistance","textPadding","iconPadding","getIconPadding","textMaxAngle","iconAlongLine","textRepeatDistance","iconTextFit","verticallyShapedIcon","addSymbolAtAnchor","lineArray","textCollisionFeature","iconCollisionFeature","verticalTextCollisionFeature","verticalIconCollisionFeature","placedTextSymbolIndices","verticalTextRotation","iconQuads","verticalIconQuads","sizeData","compositeIconSizes","justifications","justification","textRotate","singleLine","addTextVertices","horizontalOnly","getCollisionCircleHeight","prevHeight","addTextVariableAnchorOffsets","addSymbol","anchorIsTooClose","poi","placementTypes","placedIconIndex","glyphQuads","textureRect","rectBuffer","rotateVerticalGlyph","halfAdvance","sdf","builtInOffset","verticalizedLabelOffset","textureScale","isDoubleResolution","verticalRotation","xHalfWidthOffsetCorrection","halfWidthOffsetCorrection","verticalOffsetCorrection","getGlyphQuads","compositeTextSizes","placementType","horizontalShaping","repeatDistance","compareText","otherAnchors","ARRAY_TYPES","KDBush","magic","versionAndType","ArrayType","nodeSize","numItems","IndexArrayType","arrayTypeIndex","coordsByteSize","idsByteSize","padCoords","_pos","_finished","numAdded","axis","qy","r2","sqDist","select","swapItem","PerformanceMarkers","bh","lastFrameTime","frameTimes","frameTimeTarget","loadTimeKey","fullLoadTimeKey","PerformanceUtils","mark","marker","currTimestamp","clearMetrics","clearMeasures","clearMarks","getPerformanceMetrics","measure","load","fullLoad","loadTime","getEntriesByName","fullLoadTime","totalFrames","fps","curr","droppedFrames","frameTime","acc","percentDroppedFrames","mapId","receive","targetMapId","tasks","cancelCallbacks","mustQueue","taskQueue","invoker","processTask","process","task","callbacks","addEventListener","globalScope","random","buffers","hasCallback","sourceMapId","transfer","completed","responseMessage","getWorkerSource","removeEventListener","muted","onloadstart","crossOrigin","appendChild","removeOrAddSourceCommands","diffSources","beforeLayers","beforeOrder","afterOrder","beforeIndex","afterIndex","tracker","clean","beforeLayer","afterLayer","insertBeforeLayerId","lastIndexOf","diffLayers","layerObject","render","uniform1i","uniformMatrix4fv","uniform3f","uniform2f","near","far","lr","bt","nf","cacheControl","header","$0","$1","$2","$3","maxAge","userAgent","safari","uSizeT","uSize","aDeltaY","aDeltaX","bDeltaY","bDeltaX","denominator","aInterpolation","b00","b01","b02","b03","b04","b05","b06","b07","b08","b09","b10","b11","det","styleKey","imgBitmap","a3","a4","a5","a6","a7","a8","a9","a14","a15","b4","b5","b6","b7","b8","b9","b12","b13","b14","b15","glMatrix.EPSILON","fovy","aspect","deferred","cachedKeys","groups","iconsNeedLinear","keepUpright","textSize","fontstack","unformattedText","spacingIfAllowed","addVerticalShapingForPointLabelIfNeeded","sdfIcons","showCollisionBoxes","_marks","resourceTimingData","origWidth","origHeight","imgData","clearRect","readImageDataUsingOffscreenCanvas","Image","revokeObjectURL","createObjectURL","remaining","results","azimuthal","polar","StyleLayerIndex","layerConfigs","keyCache","_layerConfigs","_layers","removedIds","layerConfig","createStyleLayer","familiesBySource","groupByLayout","sourceGroup","sourceLayerFamilies","GlyphAtlas","stackPositions","WorkerTile","collectResourceTiming","returnDependencies","inFlightDependencies","dependencySentinel","layerIndex","bn","buckets","layerFamilies","family","recalculateLayers","iconMap","patternMap","aH","maybePrepare","glyphAtlas","imageAtlas","performSymbolLayout","bs","glyphAtlasImage","loadVectorTile","expires","bv","rawData","ex","errorMessage","messge","VectorTileWorkerSource","loadVectorData","fetching","loading","loaded","loadTile","perf","RequestPerformance","workerTile","resourceTiming","reloadTile","parseResult","abortTile","removeTile","RasterDEMTileWorkerSource","rawImageData","imagePixels","R","dem","rewindRings","outer","rewindRing","reverse","rewind","gj","bw","bA","geojson_wrapper","GeoJSONWrapper","FeatureWrapper","rawGeometry","tags","bB","fromVectorTileJs","tile","writeLayer","writeTile","keycache","valuecache","writeFeature","writeValue","writeProperties","writeGeometry","keyIndex","valueIndex","zigzag","count","vtPbfModule","fromGeojsonVt","defaultOptions","minPoints","props","fround","OFFSET_ID","OFFSET_NUM","OFFSET_PROP","Supercluster","assign","trees","clusterProps","time","timerId","lngX","latY","tree","_createTree","timeEnd","_cluster","getClusters","minLng","minLat","maxLng","maxLat","easternHem","westernHem","_limitZoom","clusters","getClusterJSON","getChildren","clusterId","originId","_getOriginId","originZoom","_getOriginZoom","errorMsg","getLeaves","limit","leaves","_appendLeaves","getTile","z2","_addTileFeatures","getClusterExpansionZoom","expansionZoom","cluster_id","skipped","point_count","isCluster","getClusterProperties","nextData","neighborIds","numPointsOrigin","numPoints","neighborId","wx","wy","clusterPropIndex","numPoints2","_map","original","yLat","abbrev","propIndex","point_count_abbreviated","simplify","sqTolerance","maxSqDist","minPosToMid","getSqSegDist","posToMid","createFeature","calcLineBBox","calcBBox","convertFeature","convertPoint","convertLine","convertLines","projectX","projectY","k2","minAll","maxAll","clipped","newGeometry","clipPoints","clipLines","newGeom","trackMetrics","segLen","newSlice","intersect","intersectX","intersectY","az","exited","addPoint","shiftFeatureCoords","newFeatures","shiftCoords","newPolygon","newPoints","transformTile","transformed","transformPoint","createTile","numSimplified","numFeatures","simplified","tileFeature","isOuter","GeoJSONVT","tileCoords","indexMaxZoom","indexMaxPoints","stats","total","merged","splitTile","toID","getFeatureId","isUpdateableGeoJSON","seenIds","toUpdateable","Map","cz","k3","k4","z0","GeoJSONWorkerSource","loadGeoJSON","_dataUpdateable","getJSON","dataDiff","updateable","diff","removeAll","delete","cloneProperties","removeAllProperties","removeProperties","_b","addOrUpdateProperties","_c","_d","applySourceDiff","loadGeoJSONTile","_geoJSONIndex","geoJSONTile","geojsonWrapper","_geojsonTileLayer","_feature","vtpbf","byteOffset","loadData","_pendingRequest","_pendingCallback","abandoned","bC","superclusterOptions","mapExpressions","reduceExpressions","propertyNames","mapExpression","mapExpressionParsed","reduceExpressionParsed","pointProperties","getSuperclusterOptions","geojsonvt","geojsonVtOptions","getClusterChildren","getClusterLeaves","Worker","Actor","C","layerIndexes","workerSourceTypes","workerSources","demWorkerSources","registerWorkerSource","WorkerSource","registerRTLTextPlugin","setReferrer","mapID","setImages","workerSource","ws","setLayers","getLayerIndex","updateLayers","loadDEMTile","getDEMWorkerSource","removeDEMTile","loadWorkerSource","importScripts","syncRTLPluginState","getAvailableImages","DOM","docStyle","tagName","className","container","el","namespaceURI","createElementNS","selectProp","userSelect","transformProp","capture","preventDefault","stopPropagation","suppressClickInternal","getBoundingClientRect","clientX","clientLeft","clientY","clientTop","touches","button","node","parentNode","removeChild","documentElement","testProp","webpSupported","supported","testSupport","webpCheckComplete","webpImgTest","webpImgTestOnloadComplete","testWebpTextureUpload","glForTesting","createTexture","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","isContextLost","deleteTexture","ImageRequest","ResourceType","imageRequestQueue","currentParallelImageRequests","throttleControlCallbackHandleCounter","throttleControlCallbacks","resetRequestQueue","addThrottleControl","handle","removeThrottleControl","callbackHandle","processQueue","supportImageRefresh","accept","cancelled","innerRequest","doImageRequest","itemInQueue","getImageUsingHtmlImage","onImageResponse","HTMLImageElement","arrayBufferToImageBitmap","arrayBufferToImage","arrayBufferToCanvasImageSource","imgErr","imgResult","maxImageRequests","allControlKeys","throttleingRequested","numImageRequests","topItemInQueue","requestCancelled","fetchPriority","RequestManager","transformRequestFn","_transformRequestFn","transformRequest","normalizeSpriteURL","extension","urlObject","parts","urlRe","authority","parseUrl","formatUrl","setTransformRequest","sqrLen","coerceSpriteToArray","resultArray","dedupArray","doOnceCompleted","callbackFunc","jsonsMap","imagesMap","expectedResultCounter","spriteName","spriteData","Texture","useMipmap","pixelStoreUnpackFlipY","pixelStoreUnpack","pixelStoreUnpackPremultiplyAlpha","premultiply","HTMLCanvasElement","HTMLVideoElement","texSubImage2D","isSizePowerOfTwo","generateMipmap","minFilter","LINEAR_MIPMAP_NEAREST","LINEAR","texParameteri","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","renderStyleImage","userImage","ImageManager","callbackDispatchedThisFrame","requestors","atlasImage","setLoaded","_notify","addImage","valid","_validateStretch","_validateContent","updateImage","oldImage","removeImage","listImages","getImages","hasAllDependencies","getPixelSize","getPattern","pattern","_updatePatternAtlas","atlasTexture","CLAMP_TO_EDGE","dst","beginFrame","INF","edt","gridSize","edt1d","qr","GlyphManager","requestManager","localIdeographFontFamily","entries","setURL","getGlyphs","asyncAll","entry","requests","_tinySDF","loadGlyphRange","_doesCharSupportLocalGlyph","cb","fontFamily","tinySDF","fontWeight","TinySDF","fontSize","cutoff","draw","glyphWidth","glyphHeight","glyphLeft","glyphTop","glyphAdvance","urlTemplate","Glyphs","parseGlyphPbf","fontStyle","_createCanvas","textBaseline","textAlign","gridOuter","gridInner","actualBoundingBoxAscent","actualBoundingBoxDescent","actualBoundingBoxLeft","actualBoundingBoxRight","measureText","fillText","LightPositionProperty","sphericalToCartesian","B","lightProperties","Light","lightOptions","D","_transitionable","T","_transitioning","getLight","LineAtlas","nextRow","dashEntry","getDash","dasharray","addDash","getDashRanges","lineAtlasWidth","isDash","zeroLength","currentDashLength","dashLength","addRoundDash","halfStretch","currIndex","distLeft","distRight","minDist","signedDistance","distMiddle","distEdge","addRegularDash","ALPHA","REPEAT","Dispatcher","workerPool","actors","currentActor","workers","acquire","broadcast","getActor","mapRemoved","release","loadTileJson","tileJSON","pick","F","vector_layers","vectorLayers","vectorLayerIds","Source","LngLatBounds","sw","ne","setSouthWest","setNorthEast","_ne","L","_sw","sw2","ne2","getCenter","getSouthWest","getNorthEast","getNorthWest","getWest","getNorth","getSouthEast","getEast","getSouth","contains","lnglat","containsLongitude","latAccuracy","lngAccuracy","TileBounds","validateBounds","level","G","H","VectorTileSource","dispatcher","eventedParent","_loaded","dataType","_tileJSONRequest","_options","_requestManager","sourceCaches","clearTiles","tileBounds","sourceDataType","reparseOverscaled","_collectResourceTiming","hasTile","setSourceProperty","setTiles","setUrl","getPixelRatio","Tile","_refreshExpiredTiles","setExpiryData","reloadCallback","unloadTile","unloadVectorData","RasterTileSource","roundZoom","expiry","getTileTexture","extTextureFilterAnisotropic","texParameterf","TEXTURE_MAX_ANISOTROPY_EXT","extTextureFilterAnisotropicMax","saveTileTexture","RasterDEMTileSource","needsHillshadePrepare","needsTerrainPrepare","neighboringTiles","_getNeighboringTiles","J","M","readImageNow","pxw","nxw","backfilled","O","demTexture","fbo","GeoJSONSource","_updateWorkerData","_data","_removed","_pendingLoads","workerOptions","setData","setClusterOptions","rasterBoundsAttributes","ImageSource","newCoordinates","successCallback","_request","_finishLoading","prepare","boundsBuffer","_boundsArray","boundsSegments","simpleSegment","newTilesLoaded","setCoordinates","cornerCoords","U","fromLngLat","dMax","W","getCoordinatesCenterTileID","RasterBoundsArray","VideoSource","getVideo","loop","triggerRepaint","play","readyState","paused","pause","seek","seconds","seekableRange","seekable","Y","currentTime","CanvasSource","getElementById","_hasInvalidDimensions","_playing","animate","getCanvas","registeredSources","getSourceType","getPixelPosMatrix","mat4.create","mat4.translate","mat4.scale","mat4.multiply","calculatePosMatrix","queryRenderedFeatures","sourceCache","has3DLayer","queryIncludes3DLayer","maxPitchScaleFactor","tilesIn","sortTilesIn","renderedFeatureLayers","tileIn","wrappedTileID","queryResults","_state","wrappedIDLayerMap","wrappedID","wrappedIDLayers","tileFeatures","wrappedIDFeatures","resultFeatures","mergeRenderedFeatureLayers","featureWrapper","getFeatureState","idA","idB","timeAdded","fadeEndTime","uniqueId","uses","expirationTime","hasSymbolBuckets","dependencies","rtt","rttCoords","expiredRequestCount","registerFadeDuration","wasRequested","clearTextures","justReloaded","hasData","latestFeatureIndex","latestRawTileData","getLayer","lId","deserializeBucket","lazyLoadRTLTextPlugin","imageAtlasTexture","glyphAtlasTexture","getBucket","querySourceFeatures","patternsLoaded","parsedCC","parseCacheControl","getTime","isExpired","delta","getExpiryTimeout","setFeatureState","sourceLayerStates","holdingForFade","symbolFadeHoldUntil","symbolFadeFinished","clearFadeHold","setHoldDuration","setDependencies","namespace","dep","hasDependency","namespaces","TileCache","reset","removedData","timeout","clearTimeout","order","expiryTimeout","dataWrapper","_getAndRemoveByKey","getAndRemove","getByKey","dataIndex","setMaxSize","filterFn","removed","SourceFeatureState","stateChanges","deletedStates","updateState","featureId","newState","ft","removeFeatureState","reconciledState","featureDeletions","initializeTileState","coalesceChanges","featuresChanged","layerStates","SourceCache","_sourceLoaded","_paused","reload","_didEmitContent","_sourceErrored","_source","createSource","_tiles","_cache","_unloadTile","_timers","_cacheTimers","_maxTileCacheSize","_maxTileCacheZoomLevels","_loadedParentTiles","_coveredTiles","_updated","used","usedForTerrain","getSource","resume","shouldReload","_shouldReloadOnResume","_loadTile","_abortTile","getIds","compareTileId","getRenderableIds","symbolLayer","renderables","_isIdRenderable","a_","b_","rotatedA","rotatedB","hasRenderableParent","parentTile","findLoadedParent","_reloadTile","_tileLoaded","previousState","refreshedUponExpiration","_setTileReloadTimer","_backfillDEM","borderId","getTileByID","fillBorder","_retainLoadedChildren","idealTiles","maxCoveringZoom","retain","topmostLoadedID","parentID","minCoveringZoom","parentTileID","_getLoadedTile","updateCacheSize","widthInTiles","heightInTiles","viewDependentMaxSize","handleWrapJump","wrapDelta","_prevLng","idealTileIDs","getVisibleUnwrappedCoordinates","unwrapped","coveringTiles","coveringZoomLevel","maxOverzooming","maxUnderzooming","parents","parent2","noPendingDataEmissions","_updateRetainedTiles","isRasterType","parentsForFading","fadingTiles","_addTile","idealRasterTileIDs","missingTileIDs","retainedId","keysDifference","_fadeDuration","_removeTile","_updateLoadedParentTileCache","releaseSymbolFadeTiles","checked","missingTiles","childCoord","childTile","parentWasRequested","parentId","tileKey","currentId","pointQueryGeometry","tileResults","cameraPointQueryGeometry","getCameraQueryGeometry","pointCoordinate","tileSpaceBounds","tileSpaceQueryGeometry","tileSpaceCameraQueryGeometry","getVisibleCoordinates","posMatrix","reloadTilesForDependencies","aWrap","bWrap","PRELOAD_POOL_ID","WorkerPool","active","workerCount","numActive","terminate","isPreloaded","availableLogicalProcessors","globalWorkerPool","getGlobalWorkerPool","isSafari","globalThis","PathInterpolator","points_","padding_","_distances","paddedLength","lerp","distOfCurrentIdx","distToTarget","idxOfPrevPoint","distOfPrevIdx","segmentLength","segmentT","overlapAllowed","overlapA","overlapB","allowed","GridIndex","boxCells","circleCells","xCellCount","yCellCount","circleKeys","boxKeys","circles","xScale","yScale","boxUid","circleUid","keysLength","_insertBoxCell","insertCircle","_insertCircleCell","_query","hitTest","overlapMode","predicate","hitTestCircle","_queryCellCircle","queryArgs","boxCell","circleCell","_circleAndRectCollide","_circlesCollide","_convertToXCellCoord","_convertToYCellCoord","r1","bothRadii","circleX","circleY","halfRectWidth","distX","halfRectHeight","distY","getLabelPlaneMatrix","pitchWithMap","rotateWithMap","mat4.rotateZ","labelPlaneMatrix","getGlCoordMatrix","mat4.clone","glCoordMatrix","getElevation","xyTransformMat4","signedDistanceFromCamera","getPerspectiveRatio","isVisible","anchorPos","clippingBuffer","updateLineLabels","rotateToLine","partiallyEvaluatedSize","symbolSize.evaluateSizeForZoom","placedSymbols","aspectRatio","useVertical","hideGlyphs","perspectiveRatio","symbolSize.evaluateSizeForFeature","aj","pitchScaledFontSize","tileAnchorPoint","projectionCache","projections","offsets","placeUnflipped","placeGlyphsAlongLine","notEnoughRoom","needsFlipping","placeFirstAndLastGlyph","flip","glyphEndIndex","lineEndIndex","firstGlyphOffset","lastGlyphOffset","firstPlacedGlyph","placeGlyphAlongLine","lastPlacedGlyph","requiresOrientationChange","firstPoint","lastPoint","placedGlyphs","firstAndLastGlyph","orientationChange","glyphIndex","tileVertexIndex","tileSegmentEnd","projectedVertex","projectTruncatedLineSegment","singleGlyph","ak","previousTilePoint","currentTilePoint","previousProjectedPoint","minimumLength","projectionMatrix","projectedUnitVertex","projectedUnitSegment","projectVertexToViewport","projectionArgs","distanceFromAnchor","previousVertex","direction","absOffsetX","projection","previousLineVertexIndex","transformToOffsetNormal","segmentVector","findOffsetIntersectionPoint","prevToCurrentOffsetNormal","offsetPreviousVertex","offsetCurrentVertex","currentToNextOffsetNormal","offsetNextSegmentBegin","offsetNextSegmentEnd","findLineIntersection","al","anchorSegment","combinedOffsetX","offsetIntersectionPoint","currentSegmentDistance","pathVertices","currentLineSegment","prevToCurrent","segmentAngle","hiddenGlyphAttributes","viewportPadding","CollisionIndex","ignoredGrid","pitchfactor","_pitch","screenRightBoundary","screenBottomBoundary","gridRightBoundary","gridBottomBoundary","perspectiveRatioCutoff","placeCollisionBox","collisionBox","textPixelRatio","collisionGroupPredicate","projectedPoint","projectAndGetPerspectiveRatio","tileToViewport","tlX","tlY","brX","brY","isInsideGrid","offscreen","isOffscreen","placeCollisionCircles","labelToScreenMatrix","showCollisionCircles","circlePixelDiameter","textPixelPadding","placedCollisionCircles","tileUnitAnchorPoint","screenAnchorPoint","projection.project","projection.getPerspectiveRatio","labelPlaneFontScale","labelPlaneAnchorPoint","projection.placeFirstAndLastGlyph","collisionDetected","inGrid","entirelyOffscreen","screenPlaneMin","screenPlaneMax","interpolator","projectedPath","circleDist","screenSpacePath","minPoint","maxPoint","seg","numCircles","circlePosition","centerX","centerY","queryRenderedSymbols","viewportQueryGeometry","gridPoint","seenFeatures","featureKey","bucketInstanceId","intersectionTests.polygonIntersectsPolygon","insertCollisionBox","ignorePlacement","collisionGroupID","insertCollisionCircles","collisionCircles","projection.xyTransformMat4","getViewportMatrix","pixelValue","OpacityState","prevState","increment","placed","skipFade","opacity","JointOpacityState","placedText","placedIcon","JointPlacement","CollisionCircleArray","invProjMatrix","viewportMatrix","RetainedQueryData","CollisionGroups","crossSourceCollisions","maxGroupID","collisionGroups","ID","nextGroupID","calculateVariableLayoutShift","au","shiftVariableCollisionBox","rotatedOffset","Placement","prevPlacement","collisionIndex","placements","opacities","variableOffsets","stale","commitTime","retainedQueryData","collisionCircleArrays","placedOrientations","getBucketParts","sortAcrossTiles","symbolBucket","bucketFeatureIndex","pixelsToTiles","textLabelPlaneMatrix","projection.getLabelPlaneMatrix","glMatrix","projection.getGlCoordMatrix","partiallyEvaluatedTextSize","ah","collisionGroup","attemptAnchorPlacement","textAnchorOffset","textOverlapMode","orientation","placedGlyphBoxes","prevAnchor","markUsedJustification","markUsedOrientation","placeLayerBucketPart","bucketPart","seenCrossTileIDs","textOptional","iconOptional","ar","textAlwaysOverlap","iconOverlapMode","iconAlwaysOverlap","zOrderByViewportY","alwaysShowText","alwaysShowIcon","placeSymbol","placeText","placeIcon","placedVerticalText","placedGlyphCircles","placedIconBoxes","updatePreviousOrientationIfNotPlaced","isPlaced","previousOrientation","prevPlacedOrientation","placeTextForPlacementModes","placeHorizontalFn","placeVerticalFn","placementMode","textAnchorOffsetStart","textAnchorOffsetEnd","placeBox","collisionTextBox","placedFeature","placeBoxForVariableAnchors","collisionIconBox","variableIconBox","placedBox","placementPasses","prevOrientation","prevOffset","placeIconFeature","shiftedIconBox","iconWithoutText","textWithoutIcon","circleArray","symbolIndexes","symbolIndex","mat4.invert","placedAnchor","autoIndex","indexes","horizontalIndexes","commit","zoomAtLastRecencyCheck","placementChanged","prevZoomAdjustment","zoomAdjustment","symbolFadeChange","prevOpacities","prevOffsets","prevOrientations","jointPlacement","prevOpacity","jointOpacity","lastPlacementChangeTime","updateLayerOpacities","updateBucketOpacities","duplicateOpacityState","textAllowOverlap","iconAllowOverlap","hasVariablePlacement","defaultOpacityState","addOpacities","PACKED_HIDDEN_OPACITY","opacityState","horizontalHidden","verticalHidden","packedOpacity","packOpacity","symbolHidden","useHorizontal","variableOffset","updateCollisionVertices","verticalIconUsed","instance","hasTransitions","stillRecent","durationAdjustment","setStale","notUsed","shift25","shift24","shift17","shift16","shift9","shift8","shift1","targetBit","opacityBits","LayerPlacement","_sortAcrossTiles","_currentTileIndex","_currentPartIndex","_seenCrossTileIDs","_bucketParts","continuePlacement","placement","shouldPausePlacement","bucketParts","PauseablePlacement","forceFullPlacement","_currentPlacementIndex","_forceFullPlacement","_showCollisionBoxes","_done","isDone","layerTiles","startTime","placementZoom","_inProgressLayer","roundingFactor","TileLayerIndex","_symbolsByKey","symbolInstancesByKey","instances","symbols","crossTileIDs","getScaledCoordinates","childTileID","localX","localY","localZ","yWorld","yOffset","findMatches","newTileID","zoomCrossTileIDs","scaledSymbolCoord","thisTileSymbol","getCrossTileIDsLists","CrossTileIDs","maxCrossTileID","generate","CrossTileSymbolLayerIndex","usedCrossTileIDs","zoomIndexes","newZoomIndex","addBucket","removeBucketCrossTileIDs","childIndex","parentIndex","removedBucket","removeStaleBuckets","currentIDs","tilesChanged","CrossTileSymbolIndex","maxBucketInstanceId","bucketsInCurrentPlacement","symbolBucketsChanged","currentBucketIDs","pruneUnusedLayers","usedLayers","usedLayerMap","usedLayer","_emitValidationErrors","supportedDiffOperations","diffOperations","ignoredDiffOperations","empty","emptyStyle","aw","Style","_getMapId","glyphManager","lineAtlas","crossTileSymbolIndex","_spritesImagesIds","_order","_availableImages","_resetUpdates","_rtlTextPluginCallback","registerForPluginStateChange","aA","elem","_validateLayer","loadURL","previousStyle","_load","loadJSON","loadEmpty","nextState","transformStyle","stylesheet","_loadSprite","_createLayers","setTerrain","dereferencedLayers","aB","_serializedLayers","styledLayer","isUpdate","completion","_spriteRequest","originalSprite","spriteArray","spriteArrayLength","combinedRequestsMap","jsonRequestParameters","SpriteJSON","jsonRequestKey","imageRequestParameters","SpriteImage","imageRequestKey","requst","loadSprite","spriteId","imagesToRemove","_changedImages","imageId","_changed","_unloadSprite","flat","_updatedSources","_serializeByIds","serializedLayersDictionary","_serializedAllLayers","allLayerIds","_checkLoaded","changed","updatedIds","_updatedLayers","_removedLayers","_updateWorkerLayers","action","_reloadSource","_clearSource","_updateTilesForChangedImages","_updateTilesForChangedGlyphs","_updatedPaintProps","sourcesUsedBefore","changedImages","_glyphsDidChange","serializedStyle","changes","diffStyles","unimplementedOps","_afterImageUpdated","isSourceLoaded","geojsonSource","validateCustomStyleLayer","aF","_layerOrderChanged","_updateLayer","moveLayer","newIndex","getLayersOrder","getFilter","aG","getTerrain","myStyleSheet","_flattenAndSortRenderedFeatures","sourceResults","isLayer3D","features3D","sourceResult","layerFeatures","topmost3D","includedSources","renderedSymbols","bucketQueryData","queryData","bucketSymbols","layerSymbols","sortedA","symbolFeature","layerName","dataTiles","dataID","addSourceType","SourceType","setSourceType","workerSourceURL","_update","_remove","rtlTextPluginEvented","_updateSources","_generateCollisionBoxes","_updatePlacement","placementCommitted","layerBucketsChanged","pauseablePlacement","_releaseSymbolFadeTiles","getResource","getGlyphsUrl","glyphsUrl","addSprite","spriteToAdd","updatedSprite","removeSprite","internalSpriteRepresentation","find","findIndex","getSprite","aK","posAttributes","terrainVert","shaders","prelude","compile","backgroundPattern","clippingMask","heatmapTexture","collisionCircle","fillOutline","fillOutlinePattern","fillPattern","fillExtrusion","fillExtrusionPattern","hillshadePrepare","lineGradient","linePattern","lineSDF","symbolIcon","symbolSDF","symbolTextAndIcon","terrainDepth","terrainCoords","fragmentSource","vertexSource","re","staticAttributes","fragmentUniforms","vertexUniforms","staticUniforms","fragmentPragmas","operation","attrType","unpackType","VertexArrayObject","boundProgram","boundLayoutVertexBuffer","boundPaintVertexBuffers","boundIndexBuffer","boundVertexOffset","boundDynamicVertexBuffer","vao","program","paintVertexBuffers","dynamicVertexBuffer","dynamicVertexBuffer2","dynamicVertexBuffer3","paintBuffersDiffer","boundDynamicVertexBuffer2","boundDynamicVertexBuffer3","freshBind","bindVertexArray","dynamicDraw","numNextAttributes","numAttributes","createVertexArray","enableAttributes","vertexBuffer","setVertexAttribPointers","currentNumAttributes","deleteVertexArray","getTokenizedAttributesAndUniforms","token","Program","configuration","fixedUniforms","showOverdrawInspector","createProgram","staticAttrInfo","dynamicAttrInfo","allAttrInfo","preludeUniformsInfo","staticUniformsInfo","dynamicUniformsInfo","uniformList","allUniformsInfo","fragmentShader","createShader","FRAGMENT_SHADER","failedToCreate","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","getShaderInfoLog","attachShader","vertexShader","VERTEX_SHADER","attributes","uniformLocations","bindAttribLocation","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","deleteShader","it","uniformLocation","getUniformLocation","terrainUniforms","u_depth","Uniform1i","aL","u_terrain","u_terrain_dim","aM","u_terrain_matrix","UniformMatrix4f","aN","u_terrain_unpack","aO","u_terrain_exaggeration","terrainPreludeUniforms","drawMode","depthMode","stencilMode","colorMode","cullFaceMode","uniformValues","currentProperties","dynamicLayoutBuffer","dynamicLayoutBuffer2","dynamicLayoutBuffer3","setDepthMode","setStencilMode","setColorMode","setCullFace","activeTexture","TEXTURE2","depthTexture","TEXTURE3","primitiveSize","LINES","TRIANGLES","LINE_STRIP","drawElements","UNSIGNED_SHORT","patternUniformValues","tileRatio","numTiles","tileSizeAtNearestZoom","pixelX","pixelY","u_image","u_texsize","u_scale","u_fade","u_pixel_coord_upper","u_pixel_coord_lower","fillExtrusionUniformValues","shouldUseVerticalGradient","_lp","lightPos","lightMat","mat3.create","mat3.fromRotation","vec3.transformMat3","lightColor","u_matrix","u_lightpos","u_lightintensity","u_lightcolor","u_vertical_gradient","u_opacity","fillExtrusionPatternUniformValues","u_height_factor","fillUniformValues","fillPatternUniformValues","fillOutlineUniformValues","drawingBufferSize","u_world","fillOutlinePatternUniformValues","circleUniformValues","extrudeScale","pixelsToGLUnits","u_camera_to_center_distance","u_scale_with_map","translatePosMatrix","u_pitch_with_map","u_device_pixel_ratio","u_extrude_scale","collisionUniformValues","u_pixels_to_tile_units","u_overscale_factor","debugUniformValues","scaleRatio","u_color","u_overlay","u_overlay_scale","clippingMaskUniformValues","heatmapUniformValues","u_intensity","getTileLatRange","lineUniformValues","calculateMatrix","u_ratio","u_units_to_pixels","lineGradientUniformValues","u_image_height","linePatternUniformValues","tileZoomRatio","calculateTileRatio","lineSDFUniformValues","posA","posB","widthA","widthB","u_patternscale_a","u_patternscale_b","u_sdfgamma","u_tex_y_a","u_tex_y_b","u_mix","rasterUniformValues","parentTL","parentScaleBy","fade","u_tl_parent","u_scale_parent","u_buffer_scale","u_fade_t","mix","u_image0","u_image1","u_brightness_low","u_brightness_high","u_saturation_factor","saturation","u_contrast_factor","contrast","u_spin_weights","spinWeights","symbolIconUniformValues","rotateInShader","texSize","u_is_size_zoom_constant","u_is_size_feature_constant","u_size_t","u_size","u_pitch","u_rotate_symbol","u_aspect_ratio","u_fade_change","u_label_plane_matrix","u_coord_matrix","u_is_text","u_texture","symbolSDFUniformValues","isHalo","u_gamma_scale","u_is_halo","symbolTextAndIconUniformValues","texSizeSDF","texSizeIcon","u_texsize_icon","u_texture_icon","backgroundUniformValues","backgroundPatternUniformValues","imagePosA","imagePosB","u_pattern_tl_a","u_pattern_br_a","u_pattern_tl_b","u_pattern_br_b","u_pattern_size_a","u_pattern_size_b","u_scale_a","u_scale_b","u_tile_units_to_pixels","bgPatternUniformValues","programUniforms","Uniform3f","aP","Uniform2f","aQ","u_inv_matrix","u_viewport_size","aR","u_color_ramp","u_latrange","u_light","u_shadow","u_highlight","u_accent","u_dimension","u_zoom","u_unpack","u_ele_delta","u_terrain_coords_id","IndexBuffer","createBuffer","unbindVAO","bindElementBuffer","bufferData","ELEMENT_ARRAY_BUFFER","DYNAMIC_DRAW","STATIC_DRAW","bufferSubData","deleteBuffer","AttributeType","VertexBuffer","bindVertexBuffer","ARRAY_BUFFER","attribIndex","enableVertexAttribArray","vertexAttribPointer","WeakMap","isWebGL2","getParameter","VERSION","BaseValue","getDefault","setDefault","ClearColor","clearColor","ClearDepth","clearDepth","ClearStencil","clearStencil","ColorMask","colorMask","DepthMask","depthMask","StencilMask","stencilMask","StencilFunc","func","ALWAYS","stencilFunc","StencilOp","KEEP","stencilOp","StencilTest","enable","STENCIL_TEST","disable","DepthRange","depthRange","DepthTest","DEPTH_TEST","DepthFunc","LESS","depthFunc","Blend","BLEND","BlendFunc","ONE","ZERO","blendFunc","BlendColor","blendColor","BlendEquation","FUNC_ADD","blendEquation","CullFace","CULL_FACE","CullFaceSide","BACK","cullFace","FrontFace","CCW","frontFace","ProgramValue","useProgram","ActiveTextureUnit","TEXTURE0","Viewport","drawingBufferWidth","drawingBufferHeight","BindFramebuffer","bindFramebuffer","FRAMEBUFFER","BindRenderbuffer","bindRenderbuffer","RENDERBUFFER","BindTexture","BindVertexBuffer","bindBuffer","BindElementBuffer","BindVertexArray","getExtension","bindVertexArrayOES","PixelStoreUnpack","pixelStorei","UNPACK_ALIGNMENT","PixelStoreUnpackPremultiplyAlpha","UNPACK_PREMULTIPLY_ALPHA_WEBGL","PixelStoreUnpackFlipY","UNPACK_FLIP_Y_WEBGL","FramebufferAttachment","ColorAttachment","setDirty","framebufferTexture2D","COLOR_ATTACHMENT0","DepthAttachment","framebufferRenderbuffer","DEPTH_ATTACHMENT","DepthStencilAttachment","DEPTH_STENCIL_ATTACHMENT","Framebuffer","hasDepth","hasStencil","framebuffer","createFramebuffer","colorAttachment","depthAttachment","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","renderbuffer","deleteRenderbuffer","deleteFramebuffer","ColorMode","blendFunction","Replace","disabled","aT","unblended","alphaBlended","Context","stencilTest","depthTest","blend","cullFaceSide","MAX_TEXTURE_MAX_ANISOTROPY_EXT","maxTextureSize","MAX_TEXTURE_SIZE","HALF_FLOAT","extColorBufferHalfFloat","RGBA16F","RGBA16F_EXT","RGB16F","RGB16F_EXT","extTextureHalfFloat","HALF_FLOAT_OES","createRenderbuffer","storageFormat","rbo","renderbufferStorage","depth","stencil","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT","mode","fail","depthFail","createVertexArrayOES","deleteVertexArrayOES","DepthMode","ReadOnly","ReadWrite","StencilMode","CullFaceMode","quadTriangles","drawCollisionDebug","tileBatches","circleCount","circleOffset","invTransform","mat4.mul","aU","colorModeForRenderPass","getTerrainData","circleProgram","vertexData","CollisionCircleLayoutArray","batch","circleIdx","collision","quadCount","triCount","QuadTriangleArray","idx","createQuadTriangles","backCCW","identityMat4","calculateVariableRenderShift","renderTextSize","updateVariableAnchorsForBucket","tileScale","updateTextFitIcon","dynamicTextLayoutVertexArray","dynamicIconLayoutVertexArray","placedTextShifts","tileAnchor","projectedAnchor","symbolProjection.project","symbolProjection.getPerspectiveRatio","evaluateSizeForFeature","shiftedAnchor","symbolProjection.hideGlyphs","placedIcons","getSymbolProgramName","drawLayerSymbols","rotationAlignment","pitchAlignment","hasSortKey","depthModeForSublayer","tileRenderState","programConfiguration","evaluateSizeForZoom","terrainData","atlasInterpolation","atlasInterpolationIcon","atlasTextureIcon","rotating","zooming","NEAREST","iconScaled","symbolProjection.getLabelPlaneMatrix","symbolProjection.getGlCoordMatrix","hasVariableAnchors","symbolProjection.updateLineLabels","uLabelPlaneMatrix","uglCoordMatrix","hasHalo","oldSegments","segmentState","TEXTURE1","drawSymbolElements","updatePatternPositionsInProgram","drawFillTiles","isOutline","fillPropertyName","programName","terrainCoord","tileMatrix","stencilModeForClipping","drawExtrusionTiles","renderHillshade","shadow","highlight","accent","moving","rasterBoundsBuffer","quadTriangleIndexBuffer","rasterBoundsSegments","prepareHillshade","textureStride","pixelData","renderTexture","mat4.ortho","hillshadeUniformPrepareValues","getFadeValues","sinceTile","sinceParent","idealZ","fadeIn","childOpacity","topColor","btmColor","leftColor","rightColor","centerColor","drawHorizontalLine","drawDebugSSRect","drawVerticalLine","SCISSOR_TEST","scissor","drawDebugTile","tileRawData","tileSizeKb","tileIdText","initDebugOverlayCanvas","debugOverlayCanvas","ctx2d","shadowColor","shadowBlur","strokeStyle","strokeText","debugOverlayTexture","drawTextToOverlay","debugBuffer","debugSegments","tileBorderIndexBuffer","drawTerrain","LEQUAL","depthRangeFor3D","mesh","getTerrainMesh","renderToTexture","getTexture","getMeshFrameDelta","Painter","_tileTextures","terrainFacilitator","renderTime","setup","numSublayers","depthEpsilon","tileExtentArray","tileExtentBuffer","tileExtentSegments","debugArray","rasterBoundsArray","viewportArray","viewportBuffer","viewportSegments","tileLineStripIndices","LineStripIndexArray","quadTriangleIndices","stencilClearMode","nextStencilID","currentStencilSource","_renderTileClippingMasks","tileIDs","_tileClippingMaskIDs","REPLACE","stencilModeFor3D","NOTEQUAL","EQUAL","stencilConfigForOverlap","minTileZ","stencilValues","zToStencilMode","GEQUAL","_showOverdrawInspector","CONSTANT_COLOR","renderPass","opaquePassEnabledForLayer","currentLayer","opaquePassCutoff","coordsAscending","coordsDescending","coordsDescendingSymbol","prepareForRender","newTiles","tilesAfterTime","mat4.equals","projMatrix","mat4.copy","getRenderableTiles","getFramebuffer","devicePixelRatio","drawDepth","getCoordsTexture","coordsIndex","drawCoords","renderLayer","showTileBoundaries","selectedSource","flatMap","vectorSources","otherSources","considerSource","selectDebugSource","drawDebug","showPadding","centerPoint","drawCrosshair","drawDebugPadding","pixelToTileScale","updateVariableAnchors","drawSymbols","strokeWidth","strokeOpacity","segmentsRenderStates","segmentsState","drawCircles","numType","internalFormat","bindTextureToFramebuffer","textureUnit","colorRampUnit","renderTextureToMap","drawHeatmap","gradient","programId","firstTile","prevProgram","programChanged","atlas","layerGradient","gradientTexture","textureResolution","potentialOverzoom","ad","nextPowerOfTwo","drawLine","drawFill","drawFillExtrusion","stencilModes","drawHillshade","textureFilter","drawRaster","isPatternMissing","drawBackground","setCustomLayerDefaults","customLayerMatrix","setBaseState","drawCustom","inViewportPixelUnitsUnits","sinA","cosA","translation","translatedMatrix","textures","overLimit","Frustum","planes","invProj","frustumCoords","vec4.mul","frustumPlanes","vec3.normalize","bz","vec3.cross","vec3.sub","Aabb","min_","max_","vec3.scale","vec3.add","quadrant","qMin","vec3.clone","qMax","distanceX","distanceY","frustum","aabbPoints","fullyInside","plane","pointsInside","vec4.dot","projMin","MAX_VALUE","projMax","EdgeInsets","Transform","minPitch","maxPitch","renderWorldCopies","maxValidLatitude","_renderWorldCopies","_minZoom","_maxZoom","_minPitch","_maxPitch","setMaxBounds","_center","_elevation","_fov","_unmodified","_edgeInsets","_posMatrixCache","_alignedPosMatrixCache","_minEleveationForCurrentTile","that","latRange","_calcMatrices","centerOffset","rotationMatrix","mat2.create","mat2.rotate","fov","_zoom","constrainedZoom","zoomScale","_constrain","elevation","isPaddingEqual","interpolatePadding","scaleZoom","utl","utr","ubl","ubr","w0","w1","extraWorldCopy","actualZ","cameraCoord","getCameraPoint","centerCoord","cameraPoint","cameraFrustum","fromInvProjectionMatrix","radiusOfMaxLvlLodInTiles","newRootTile","aabb","fullyVisible","intersectResult","refPoint","longestDim","distanceSq","vec2.sqrLen","tileDistanceToCamera","childX","childY","childZ","minMax","getMinMaxElevation","minElevation","maxElevation","unmodified","unproject","getCameraPosition","pointLocation","_pixelPerMeter","recalculateZoom","getElevationForLngLatZoom","cameraPosition","camera","setLocationAtPoint","loc","locationCoordinate","newCenter","coordinateLocation","locationPoint","coordinatePoint","pixelMatrix3D","coordinate","coord0","coord1","pixelMatrixInverse","z1","pixelMatrix","getHorizon","getMaxBounds","lngRange","unwrappedTileID","aligned","posMatrixKey","unwrappedX","ao","alignedProjMatrix","mercatorMatrix","_constraining","sy","sx","h2","w2","cameraToSeaLevelDistance","cameraToLowestPointDistance","lowestPlane","groundAngle","fovAboveCenter","topHalfSurfaceDistance","horizon","fovCenterToHorizon","topHalfSurfaceDistanceHorizon","topHalfMinDistance","farZ","nearZ","mat4.perspective","mat4.rotateX","xShift","yShift","angleCos","angleSin","alignedM","as","throttle","lastCallArgs","pending","lastCallContext","later","Hash","hashName","_getCurrentHash","hash","_hashName","keyval","_onHashChange","dragRotate","isEnabled","touchZoomRotate","getBearing","jumpTo","_updateHashUnthrottled","getHashString","history","replaceState","SecurityError","_updateHash","encodeURIComponent","addTo","mapFeedback","getZoom","getPitch","found","defaultInertiaOptions","linearity","easing","defaultPanInertiaOptions","deceleration","maxSpeed","defaultZoomInertiaOptions","defaultBearingInertiaOptions","defaultPitchInertiaOptions","HandlerInertia","_inertiaBuffer","record","settings","_drainInertiaBuffer","inertia","_onMoveEnd","panInertiaOptions","deltas","pan","pinchAround","around","zoomDelta","bearingDelta","pitchDelta","panDelta","easeOptions","calculateEasing","amount","extendDuration","noMoveStart","inertiaDuration","inertiaOptions","speed","MapMouseEvent","_defaultPrevented","defaultPrevented","originalEvent","mousePos","getCanvasContainer","MapTouchEvent","changedTouches","touchPos","lngLats","MapWheelEvent","MapEventHandler","_clickTolerance","clickTolerance","_mousedownPos","wheel","_firePreventable","mousedown","mouseup","click","dblclick","mouseover","mouseout","touchstart","touchmove","touchend","touchcancel","mapEvent","isActive","BlockableMapEventHandler","_delayContextMenu","_ignoreContextMenu","_contextMenuEvent","mousemove","contextmenu","TransformProvider","_requestedCameraState","BoxZoomHandler","_tr","_el","_container","getContainer","_enabled","_active","shiftKey","disableDrag","_startPos","_lastPos","mousemoveWindow","_box","classList","_fireEvent","setTransform","mouseupWindow","suppressClick","cameraAnimation","fitScreenCoordinates","keydown","keyCode","enableDrag","indexTouches","SingleTapRecognizer","numTouches","mapTouches","timeStamp","getCentroid","newTouches","TapRecognizer","singleTap","numTaps","lastTime","lastTap","tap","soonEnough","closeEnough","TapZoomHandler","_zoomIn","_zoomOut","zoomInPoint","zoomOutPoint","easeTo","DragHandler","_moveStateManager","moveStateManager","_moveFunction","move","_activateOnStart","activateOnStart","assignEvents","_moved","_lastPoint","endMove","_move","dragStart","isValidStartEvent","startMove","dragMove","isValidMoveEvent","movePoint","dragEnd","isValidEndEvent","getClickTolerance","BUTTONS_FLAGS","MouseMoveStateManager","_correctEvent","checkCorrectEvent","eventButton","mouseButton","_eventButton","_e","flag","buttons","buttonNoLongerPressed","OneFingerTouchMoveStateManager","_firstTouch","_isOneFingerTouch","targetTouches","_isSameTouchEvent","handler","generateMouseRotationHandler","bearingDegreesPerPixelMoved","mouseMoveStateManager","ctrlKey","generateMousePitchHandler","pitchDegreesPerPixelMoved","TouchPanHandler","_minTouches","cooperativeGestures","_touches","_sum","_cancelCooperativeMessage","_calculateTransform","_cooperativeGestures","_onCooperativeGesture","touchPointSum","touchDeltaSum","touchDeltaCount","prevPoint","TwoFingersTouchHandler","_firstTwoTouches","_start","getTouchById","_aroundCenter","getZoomDelta","lastDistance","TwoFingersTouchZoomHandler","_distance","_startDistance","getBearingDelta","TwoFingersTouchRotateHandler","_minDiameter","_startVector","_vector","lastVector","_isBelowThreshold","threshold","bearingDeltaSinceStart","isVertical","TwoFingersTouchPitchHandler","_valid","_firstMove","_lastPoints","_currentTouchCount","vectorA","vectorB","gestureBeginsVertically","movedA","movedB","isSameDirection","panStep","bearingStep","pitchStep","KeyboardHandler","stepOptions","_panStep","_bearingStep","_pitchStep","_rotationDisabled","altKey","metaKey","zoomDir","bearingDir","pitchDir","xDir","yDir","easeId","easeOut","disableRotation","enableRotation","wheelZoomDelta","ScrollZoomHandler","triggerRenderFrame","_onTimeout","initialEvent","_type","_delta","_lastValue","_triggerRenderFrame","_defaultZoomRate","_wheelZoomRate","setZoomRate","zoomRate","setWheelZoomRate","wheelZoomRate","_finishTimeout","isZooming","_zooming","_metaKey","deltaMode","WheelEvent","DOM_DELTA_LINE","deltaY","timeDelta","_lastWheelEventTime","_timeout","_lastWheelEvent","_frameId","_around","_aroundPoint","renderFrame","_targetZoom","_startZoom","_easing","_smoothOutEasing","targetZoom","startZoom","finished","noInertia","needsRenderFrame","_prevEase","currentEase","ba","DoubleClickZoomHandler","clickZoom","TapZoom","_clickZoom","_tapZoom","ClickZoomHandler","TapDragZoomHandler","_tap","_swipePoint","_swipeTouch","_tapTime","_tapPoint","swipePoint","newSwipePoint","DragPanHandler","mousePan","touchPan","_mousePan","_touchPan","_inertiaOptions","DragRotateHandler","mouseRotate","mousePitch","_pitchWithRotate","pitchWithRotate","_mouseRotate","_mousePitch","TwoFingersTouchZoomRotateHandler","touchZoom","touchRotate","tapDragZoom","_touchZoom","_touchRotate","_tapDragZoom","isMoving","drag","RenderFrameEvent","hasChange","HandlerManager","handleWindowEvent","handleEvent","eventName","_updatingCamera","inputEvent","mergedHandlerResult","eventsInProgress","activeHandlers","eventTouches","_getMapTouches","handlerName","_handlers","_blockedByActive","mergeHandlerResult","deactivatedHandlers","_previousActiveHandlers","_changes","_stop","_inertia","_fireEvents","_handlersById","_bearingSnap","bearingSnap","_eventsInProgress","_addDefaultHandlers","passive","listenerOptions","boxZoom","interactive","tapZoom","doubleClickZoom","touchPitch","generateMousePanHandler","dragPan","scrollZoom","keyboard","allowEndAnimation","isRotating","myName","handlerResult","eventData","_applyChanges","combined","combinedEventsInProgress","combinedDeactivatedHandlers","change","_updateMapTransform","combinedResult","_getTransformForUpdate","_terrainMovement","_elevationFreeze","_applyUpdatedTransform","newEventsInProgress","wasMoving","nowMoving","startEvents","endEvents","originalEndEvent","stillMoving","inertialEase","shouldSnapToNorth","essential","resetNorth","freezeElevation","_requestFrame","_renderTaskQueue","Camera","_renderFrameCallback","_easeStart","_easeOptions","_onEaseFrame","_easeFrameId","_requestRenderFrame","_moving","panBy","panTo","zoomTo","zoomIn","zoomOut","getPadding","setPadding","rotateTo","resetNorthPitch","snapToNorth","cameraForBounds","_cameraForBoxAndBearing","defaultPadding","edgePadding","p0world","p1world","p0rotated","p1rotated","upperRight","lowerLeft","scaleX","scaleY","rotatedPaddingOffset","offsetAtFinalZoom","fitBounds","_fitInternal","calculatedOptions","flyTo","zoomChanged","bearingChanged","pitchChanged","calculateCameraOptionsFromTo","altitudeFrom","altitudeTo","fromMerc","toMerc","distance3D","groundDistance","bb","startBearing","startPitch","startPadding","_normalizeBearing","offsetAsPoint","pointAtOffset","locationAtOffset","_normalizeCenter","finalScale","aroundPoint","currently","_rotating","pitching","_pitching","_padding","_easeId","_prepareEase","_prepareElevation","_ease","_updateElevation","speedup","_fireMoveEvents","interruptingEaseId","_finalizeElevation","_afterEase","_elevationCenter","_elevationStart","_elevationTarget","getMinTileElevationForLngLatZoom","pitch1","transformCameraUpdate","nextTransform","wasZooming","wasRotating","wasPitching","coercedOptions","curve","rho","u1","wMax","rho2","zoomOutFactor","descent","sinh","cosh","r0","S","screenSpeed","maxDuration","isEasing","allowGestures","_cancelRenderFrame","_onEaseEnd","onEaseEnd","handlers","currentBearing","queryTerrainElevation","AttributionControl","_toggleAttribution","setAttribute","removeAttribute","_updateData","_updateAttributions","_updateCompact","offsetWidth","_compact","_updateCompactMinimize","getDefaultPosition","compact","_compactButton","_setElementTitle","_innerContainer","_attribHTML","element","title","_getUIString","attributions","customAttribution","styleOwner","owner","styleId","attrib","attribHTML","innerHTML","_editLink","LogoControl","containerChildren","rel","display","TaskQueue","_queue","_id","_cleared","_currentlyRunning","running","run","defaultLocale","pos3dAttributes","TerrainSourceCache","_renderableTilesKeys","_sourceTileCache","deltaZoom","destruct","freeRtt","getTerrainCoords","_tileID","getSourceTile","searchForDEM","Terrain","qualityFactor","meshSize","_demMatrixCache","_coordsTextureSize","getDEMElevation","vec2.transformMat4","mercatorX","mercatorY","_getOverscaledTileIDFromLngLatZoom","_emptyDemTexture","_emptyDepthTexture","_emptyDemUnpack","_emptyDemMatrix","sourceTile","matrixKey","demMatrix","mat4.fromScaling","_fboDepthTexture","_fbo","_fboCoordsTexture","DEPTH_COMPONENT16","_coordsTexture","readPixels","coordsSize","_allowMercatorOverflow","_mesh","Pos3dArray","meshSize2","offsetTop","offsetBottom","offsetLeft","offsetRight","be","mercatorCoordinate","tileX","tileY","inLeftHalf","centerLng","RenderPool","_context","_size","_tileSize","_objects","_recentlyUsed","_stamp","_createObject","DEPTH_STENCIL","stamp","inUse","getObjectForId","useObject","stampObject","getOrCreateFreeObject","freeObject","freeAllObjects","isFull","LAYERS","RenderToTexture","pool","_stacks","_prevType","_rttTiles","_renderableTiles","_renderableLayerIds","_coordsDescendingInv","_coordsDescendingInvStr","isLastLayer","packageJSON","attributionControl","maplibreLogo","failIfMajorPerformanceCaveat","preserveDrawingBuffer","trackResize","refreshExpiredTiles","maxTileCacheSize","maxTileCacheZoomLevels","maxCanvasSize","touchmoveWindow","showCompass","showZoom","visualizePitch","MouseRotateWrapper","startMouse","moveMouse","offTemp","startTouch","moveTouch","mapRotateTolerance","mapPitchTolerance","touchMoveStateManager","generateOneFingerTouchRotationHandler","generateOneFingerTouchPitchHandler","supportsGeolocation","smartWrap","priorPos","anchorTranslate","applyAnchorClass","prefix","Marker","_onKeyPress","legacyCode","charCode","togglePopup","_onMapClick","targetElement","_element","_popup","isFullyLoaded","_lngLat","_offset","rotation","_rotationAlignment","_rotation","_pitchAlignment","_anchor","_opacityTimeout","metresPerPixel","_onMove","_isDragging","_pointerdownPos","_positionDelta","setLngLat","pointerEvents","_onUp","_addDragHandler","_color","_scale","_draggable","draggable","_defaultMarker","svg","createNS","defaultHeight","defaultWidth","setAttributeNS","markerLarge","page1","ellipses","rx","ry","ellipse","bgPath","borderPath","maki","circleContainer","circle1","circle2","setDraggable","getLngLat","getElement","setPopup","popup","_originalTabIndex","markerHeight","markerRadius","linearOffset","getAttribute","getPopup","isOpen","getOffset","setOffset","addClassName","removeClassName","toggleClassName","toggle","shouldBeDraggable","isDraggable","setRotation","getRotation","setRotationAlignment","getRotationAlignment","setPitchAlignment","getPitchAlignment","positionOptions","enableHighAccuracy","maximumAge","fitBoundsOptions","trackUserLocation","showAccuracyCircle","showUserLocation","numberOfWatches","noTimeout","updateScale","clientHeight","maxMeters","maxFeet","setScale","maxDistance","pow10","multiplier","getDecimalRoundNum","getRoundNum","closeButton","closeOnClick","focusAfterOpen","focusQuerySelector","normalizeOffset","cornerOffset","convertedOffset","Debug","logToElement","overwrite","MapLibreGL","maxParallelImageRequests","numRequests","workerUrl","customProtocol","loadFn","_cooperativeGesturesOnWheel","_contextLost","_frame","_contextRestored","_setupPainter","_onMapScroll","scrollTop","scrollLeft","_onWindowOnline","_interactive","platform","_failIfMajorPerformanceCaveat","_preserveDrawingBuffer","_antialias","antialias","_trackResize","_crossSourceCollisions","_crossFadingFactor","_controls","_mapId","_locale","_overridePixelRatio","_maxCanvasSize","_imageQueueHandle","HTMLElement","maxBounds","_setupContainer","_idleTriggered","initialResizeEventCaptured","throttledResizeCallback","_resizeObserver","ResizeObserver","observe","_setupCooperativeGestures","_hash","_localIdeographFontFamily","_validateStyle","addControl","logoPosition","control","controlElement","positionContainer","_controlPositions","insertBefore","firstChild","removeControl","ci","hasControl","_containerDimensions","clampedPixelRatio","_getClampedPixelRatio","_resizeCanvas","fireMoving","maxCanvasWidth","maxCanvasHeight","canvasWidth","canvasHeight","setPixelRatio","setMinZoom","getMinZoom","setMaxZoom","getMaxZoom","setMinPitch","getMinPitch","setMaxPitch","getMaxPitch","getRenderWorldCopies","setRenderWorldCopies","getCooperativeGestures","setCooperativeGestures","gestureOptions","_destroyCooperativeGestures","_createDelegatedListener","mousein","delegates","delegate","layerIdOrListener","delegatedListener","_delegatedListeners","delegatedListeners","geometryOrOptions","isGeometry","_diffStyle","_updateStyle","_lazyInitEmptyStyle","_updateDiff","getStyle","isStyleLoaded","_terrainDataCallback","thisLayer","areTilesLoaded","existingImage","imageData","hasImage","loadImage","beforeId","spriteUrl","_canvasContainer","_canvas","clientWidth","canvasContainer","controlContainer","_controlContainer","positionName","_cooperativeGesturesScreen","desktopMessage","windowsHelpText","macHelpText","mobileHelpText","webglcontextcreationerrorDetailObject","requestedAttributes","statusMessage","msg","metaPress","_styleDirty","_sourcesDirty","updateStyle","_render","paintStartTimeStamp","crossFading","_placementDirty","somethingDirty","_repaint","_fullyLoaded","redraw","disconnect","loseContext","bg","_showTileBoundaries","_showPadding","repaint","_vertices","getCameraTargetElevation","NavigationControl","_updateZoomButtons","isMax","isMin","_zoomInButton","_zoomOutButton","_rotateCompassArrow","_compassIcon","_setButtonTitle","_createButton","_compass","_handler","GeolocateControl","_onSuccess","_isOutOfMapMaxBounds","_setErrorState","_updateMarker","_finish","_lastKnownPosition","_watchState","_geolocateButton","_updateCamera","_dotElement","longitude","accuracy","newBounds","geolocateSource","_accuracyCircleMarker","_userLocationDotMarker","_accuracy","_updateCircleRadius","_onZoom","_onError","_geolocationWatchID","_clearWatch","_timeoutId","_setupUI","_circleElement","_setup","forceRecalculation","permissions","geolocation","checkGeolocationSupport","clearWatch","southEastPoint","northEastPoint","mapHeightInMeters","watchPosition","getCurrentPosition","ScaleControl","setUnit","FullscreenControl","_onFullscreenChange","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","_fullscreen","_handleFullscreenChange","_onClickFullscreen","_isFullscreen","_exitFullscreen","_requestFullscreen","_fullscreenchange","_fullscreenButton","_updateTitle","_getTitle","_prevCooperativeGestures","exitFullscreen","mozCancelFullScreen","msExitFullscreen","webkitCancelFullScreen","_togglePseudoFullScreen","requestFullscreen","mozRequestFullScreen","msRequestFullscreen","webkitRequestFullscreen","TerrainControl","_toggleTerrain","_updateTerrainIcon","_terrainButton","Popup","_content","_onClose","_onMouseMove","_onMouseUp","_onDrag","cursor","_trackPointer","_tip","offsetHeight","anchorComponents","offsetedPos","closeOnMove","_focusFirstElement","trackPointer","setText","setDOMContent","createTextNode","setHTML","html","frag","createDocumentFragment","temp","getMaxWidth","setMaxWidth","htmlNode","hasChildNodes","_createCloseButton","_closeButton","firstFocusable","querySelector","focus","setRTLTextPlugin","prewarm","clearPrewarmedResources"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAkHO,SAASA,CAAAA,CAAUC,CAASC,CAAAA,CAAAA,CAAYC,CAAGC,CAAAA,CAAAA,CAAAA,CAE9C,OAAO,IAAKD,CAAMA,GAAAA,CAAAA,CAAIE,OAAU,CAAA,GAAA,SAAUC,CAASC,CAAAA,CAAAA,CAAAA,CAC/C,SAASC,CAAAA,CAAUC,CAAS,CAAA,CAAA,GAAA,CAAMC,CAAKN,CAAAA,CAAAA,CAAUO,IAAKF,CAAAA,CAAAA,CAAAA,EAAQ,CAAG,MAAOG,CAAKL,CAAAA,CAAAA,CAAAA,CAAOK,CAAO,EAAA,CAAA,CAC3F,SAASC,CAAAA,CAASJ,GAAS,GAAMC,CAAAA,CAAAA,CAAKN,CAAiB,CAAA,KAAA,CAAEK,CAAU,CAAA,EAAA,CAAC,MAAOG,CAAAA,CAAAA,CAAKL,CAAOK,CAAAA,CAAAA,EAAAA,CAAO,CAC9F,SAASF,CAAKI,CAAAA,CAAAA,CAAAA,CAJlB,IAAeL,CAAAA,CAIaK,CAAOC,CAAAA,IAAAA,CAAOT,CAAQQ,CAAAA,CAAAA,CAAOL,KAJ1CA,CAAAA,CAAAA,CAAAA,CAAAA,CAIyDK,CAAOL,CAAAA,KAAAA,CAJhDA,CAAiBN,YAAAA,CAAAA,CAAIM,CAAQ,CAAA,IAAIN,CAAE,EAAA,SAAUG,GAAWA,CAAQG,CAAAA,CAAAA,EAAO,CAIhBO,EAAAA,EAAAA,IAAAA,CAAKR,CAAWK,CAAAA,CAAAA,EAAY,CAC9GH,CAAAA,CAAAA,CAAMN,CAAYA,CAAAA,CAAAA,CAAUa,KAAMhB,CAAAA,CAAAA,CAASC,CAAc,EAAA,EAAA,CAAA,EAAKS,IAC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O6P,OhKtGKp4E,CAAAA,UAAAA,CAAAA,EAAAA,EAAAA,CACRvW,OAAQ8V,CAAAA,CAAAA,EACvB,CgKgHWgpE,CAAAA,EAAAA,CAAuB8P,mChK7G9B,MAAM9Y,CAAAA,CAAOx/D,EACTw/D,CAAAA,CAAAA,GAEIA,CAAK1/D,CAAAA,WAAAA,EAAAA,EAAsC,CAArB0/D,GAAAA,CAAAA,CAAK5/D,SAC3B4/D,EAAAA,EAAAA,CAAAA,CAAK11E,OAAQ0V,CAAAA,CAAAA,CAAAA,CACbQ,EAAmB,CAAA,IAAA,EAEnBlzH,QAAQC,IAAK,CAAA,uMAAA,CAAA,EAGzB,CgK6MAs7L,CAAAA,EAAAA,CAAMv8L,MAAO08L,CAAAA,EAAAA,CAAY,CAACtoE,QAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CAAU//B,qBAAuBP,CAAAA,CAAAA,CAAAA,EAAiBO,CAAAA,qBAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAAA;;AG5O5E;AACA;AACA;AACA;AACA;AAyCA;AACA,mBAAe,UAAU;;;;;;;;","x_google_ignoreList":[0,1,2,10,27,28,29,40,41,42,52,53,60,61,62,63,76,77,79,98,110,114,123,125,126,127,128,129,130,131,132,133,134,135,143,144,150,249,290]} \ No newline at end of file diff --git a/web/libraries/maplibre-gl/dist/package.json b/web/libraries/maplibre-gl/dist/package.json new file mode 100644 index 00000000..a7901014 --- /dev/null +++ b/web/libraries/maplibre-gl/dist/package.json @@ -0,0 +1 @@ +{"name":"maplibre-gl","type":"commonjs","deprecated":"Please install maplibre-gl from parent directory instead"} \ No newline at end of file diff --git a/web/libraries/maplibre-gl/package.json b/web/libraries/maplibre-gl/package.json new file mode 100644 index 00000000..06f5d9ba --- /dev/null +++ b/web/libraries/maplibre-gl/package.json @@ -0,0 +1,190 @@ +{ + "name": "maplibre-gl", + "description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library", + "version": "3.6.2", + "main": "dist/maplibre-gl.js", + "style": "dist/maplibre-gl.css", + "license": "BSD-3-Clause", + "funding": "https://github.com/maplibre/maplibre-gl-js?sponsor=1", + "repository": { + "type": "git", + "url": "git://github.com/maplibre/maplibre-gl-js.git" + }, + "types": "dist/maplibre-gl.d.ts", + "type": "module", + "dependencies": { + "@mapbox/geojson-rewind": "^0.5.2", + "@mapbox/jsonlint-lines-primitives": "^2.0.2", + "@mapbox/point-geometry": "^0.1.0", + "@mapbox/tiny-sdf": "^2.0.6", + "@mapbox/unitbezier": "^0.0.1", + "@mapbox/vector-tile": "^1.3.1", + "@mapbox/whoots-js": "^3.1.0", + "@maplibre/maplibre-gl-style-spec": "^19.3.3", + "@types/geojson": "^7946.0.13", + "@types/mapbox__point-geometry": "^0.1.4", + "@types/mapbox__vector-tile": "^1.3.4", + "@types/pbf": "^3.0.5", + "@types/supercluster": "^7.1.3", + "earcut": "^2.2.4", + "geojson-vt": "^3.2.1", + "gl-matrix": "^3.4.3", + "global-prefix": "^3.0.0", + "kdbush": "^4.0.2", + "murmurhash-js": "^1.0.0", + "pbf": "^3.2.1", + "potpack": "^2.0.0", + "quickselect": "^2.0.0", + "supercluster": "^8.0.1", + "tinyqueue": "^2.0.3", + "vt-pbf": "^3.1.3" + }, + "devDependencies": { + "@mapbox/mapbox-gl-rtl-text": "^0.2.3", + "@mapbox/mvt-fixtures": "^3.10.0", + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.0.1", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-replace": "^5.0.5", + "@rollup/plugin-strip": "^3.0.4", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.5", + "@types/benchmark": "^2.1.5", + "@types/cssnano": "^5.0.0", + "@types/d3": "^7.4.3", + "@types/diff": "^5.0.8", + "@types/earcut": "^2.1.4", + "@types/eslint": "^8.44.7", + "@types/geojson-vt": "3.2.4", + "@types/gl": "^6.0.5", + "@types/glob": "^8.1.0", + "@types/jest": "^29.5.8", + "@types/jsdom": "^21.1.5", + "@types/minimist": "^1.2.5", + "@types/murmurhash-js": "^1.0.6", + "@types/nise": "^1.4.4", + "@types/node": "^20.9.2", + "@types/offscreencanvas": "^2019.7.3", + "@types/pixelmatch": "^5.2.6", + "@types/pngjs": "^6.0.4", + "@types/react": "^18.2.37", + "@types/react-dom": "^18.2.15", + "@types/request": "^2.48.12", + "@types/shuffle-seed": "^1.1.2", + "@types/window-or-global": "^1.0.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "address": "^2.0.1", + "benchmark": "^2.1.4", + "canvas": "^2.11.2", + "cssnano": "^6.0.1", + "d3": "^7.8.5", + "d3-queue": "^3.0.7", + "devtools-protocol": "^0.0.1226504", + "diff": "^5.1.0", + "dts-bundle-generator": "^8.1.2", + "eslint": "^8.54.0", + "eslint-config-mourner": "^3.0.0", + "eslint-plugin-html": "^7.1.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-jest": "^27.6.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-tsdoc": "0.2.17", + "expect": "^29.7.0", + "gl": "^6.0.2", + "glob": "^10.3.10", + "is-builtin-module": "^3.2.1", + "jest": "^29.7.0", + "jest-canvas-mock": "^2.5.2", + "jest-environment-jsdom": "^29.7.0", + "jsdom": "^22.1.0", + "json-stringify-pretty-compact": "^4.0.0", + "minimist": "^1.2.8", + "mock-geolocation": "^1.0.11", + "nise": "^5.1.5", + "npm-font-open-sans": "^1.1.0", + "npm-run-all": "^4.1.5", + "pdf-merger-js": "^4.3.0", + "pixelmatch": "^5.3.0", + "pngjs": "^7.0.0", + "postcss": "^8.4.31", + "postcss-cli": "^10.1.0", + "postcss-inline-svg": "^6.0.0", + "pretty-bytes": "^6.1.1", + "puppeteer": "^21.5.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "rollup": "^4.5.0", + "rollup-plugin-sourcemaps": "^0.6.3", + "rw": "^1.3.3", + "semver": "^7.5.4", + "shuffle-seed": "^1.1.6", + "source-map-explorer": "^2.5.3", + "st": "^3.0.0", + "stylelint": "^15.11.0", + "stylelint-config-standard": "^34.0.0", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.1", + "tslib": "^2.6.2", + "typedoc": "^0.25.3", + "typedoc-plugin-markdown": "^3.17.1", + "typedoc-plugin-missing-exports": "^2.1.0", + "typescript": "^5.2.2" + }, + "overrides": { + "postcss-inline-svg": { + "css-select": "^5.1.0", + "dom-serializer": "^2.0.0", + "htmlparser2": "^8.0.1", + "postcss-value-parser": "^4.2.0" + } + }, + "scripts": { + "generate-dist-package": "npm run tsnode build/generate-dist-package.js", + "generate-shaders": "npm run tsnode build/generate-shaders.ts", + "generate-struct-arrays": "npm run tsnode build/generate-struct-arrays.ts", + "generate-style-code": "npm run tsnode build/generate-style-code.ts", + "generate-typings": "npm run tsnode build/generate-typings.ts", + "generate-docs": "typedoc && npm run tsnode build/generate-docs.ts", + "generate-images": "npm run tsnode build/generate-doc-images.ts", + "build-dist": "run-p --print-label generate-typings build-dev build-prod build-csp build-csp-dev build-css", + "build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev", + "watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch", + "build-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production", + "build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts", + "build-csp-dev": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev", + "build-css": "postcss -o dist/maplibre-gl.css src/css/maplibre-gl.css", + "watch-css": "postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css", + "build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts", + "watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch", + "start-server": "st --no-cache -H 0.0.0.0 --port 9966 .", + "start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material", + "start": "run-p watch-css watch-dev start-server", + "start-bench": "run-p watch-css watch-benchmarks start-server", + "lint": "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .", + "lint-css": "stylelint src/css/maplibre-gl.css", + "test": "run-p lint lint-css test-render jest", + "jest": "jest", + "jest-ci": "jest --reporters=github-actions --reporters=summary", + "test-build": "jest --selectProjects=build", + "test-integration": "jest --selectProjects=integration", + "test-render": "npm run tsnode test/integration/render/run_render_tests.ts", + "test-unit": "jest --selectProjects=unit", + "test-watch-roots": "jest --watch", + "codegen": "run-p generate-dist-package generate-style-code generate-struct-arrays generate-shaders", + "benchmark": "npm run tsnode test/bench/run-benchmarks.ts", + "gl-stats": "npm run tsnode test/bench/gl-stats.ts", + "prepare": "npm run codegen", + "typecheck": "tsc --noEmit && tsc --project tsconfig.dist.json", + "tsnode": "node --experimental-loader=ts-node/esm --no-warnings" + }, + "files": [ + "build/", + "dist/*", + "src/" + ], + "engines": { + "npm": ">=8.1.0", + "node": ">=16.14.0" + } +} diff --git a/web/libraries/maplibre-gl/src/css/maplibre-gl.css b/web/libraries/maplibre-gl/src/css/maplibre-gl.css new file mode 100644 index 00000000..ccd87a9d --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/maplibre-gl.css @@ -0,0 +1,827 @@ +.maplibregl-map { + font: 12px/20px "Helvetica Neue", Arial, Helvetica, sans-serif; + overflow: hidden; + position: relative; + -webkit-tap-highlight-color: rgb(0 0 0 / 0%); +} + +.maplibregl-canvas { + position: absolute; + left: 0; + top: 0; +} + +.maplibregl-map:fullscreen { + width: 100%; + height: 100%; +} + +.maplibregl-ctrl-group button.maplibregl-ctrl-compass { + touch-action: none; +} + +.maplibregl-canvas-container.maplibregl-interactive, +.maplibregl-ctrl-group button.maplibregl-ctrl-compass { + cursor: grab; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer { + cursor: pointer; +} + +.maplibregl-canvas-container.maplibregl-interactive:active, +.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active { + cursor: grabbing; +} + +.maplibregl-canvas-container.maplibregl-touch-zoom-rotate, +.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas { + touch-action: pan-x pan-y; +} + +.maplibregl-canvas-container.maplibregl-touch-drag-pan, +.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas { + touch-action: pinch-zoom; +} + +.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan, +.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas { + touch-action: none; +} + +.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures, +.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas { + touch-action: pan-x pan-y; +} + +.maplibregl-ctrl-top-left, +.maplibregl-ctrl-top-right, +.maplibregl-ctrl-bottom-left, +.maplibregl-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; } + +.maplibregl-ctrl-top-left { top: 0; left: 0; } + +.maplibregl-ctrl-top-right { top: 0; right: 0; } + +.maplibregl-ctrl-bottom-left { bottom: 0; left: 0; } + +.maplibregl-ctrl-bottom-right { right: 0; bottom: 0; } + +.maplibregl-ctrl { + clear: both; + pointer-events: auto; + + /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */ + transform: translate(0, 0); +} + +.maplibregl-ctrl-top-left .maplibregl-ctrl { margin: 10px 0 0 10px; float: left; } + +.maplibregl-ctrl-top-right .maplibregl-ctrl { margin: 10px 10px 0 0; float: right; } + +.maplibregl-ctrl-bottom-left .maplibregl-ctrl { margin: 0 0 10px 10px; float: left; } + +.maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0 10px 10px 0; float: right; } + +.maplibregl-ctrl-group { + border-radius: 4px; + background: #fff; +} + +.maplibregl-ctrl-group:not(:empty) { + box-shadow: 0 0 0 2px rgb(0 0 0 / 10%); +} + +@media (-ms-high-contrast: active) { + .maplibregl-ctrl-group:not(:empty) { + box-shadow: 0 0 0 2px ButtonText; + } +} + +.maplibregl-ctrl-group button { + width: 29px; + height: 29px; + display: block; + padding: 0; + outline: none; + border: 0; + box-sizing: border-box; + background-color: transparent; + cursor: pointer; +} + +.maplibregl-ctrl-group button + button { + border-top: 1px solid #ddd; +} + +.maplibregl-ctrl button .maplibregl-ctrl-icon { + display: block; + width: 100%; + height: 100%; + background-repeat: no-repeat; + background-position: center center; +} + +@media (-ms-high-contrast: active) { + .maplibregl-ctrl-icon { + background-color: transparent; + } + + .maplibregl-ctrl-group button + button { + border-top: 1px solid ButtonText; + } +} + +/* https://bugzilla.mozilla.org/show_bug.cgi?id=140562 */ +.maplibregl-ctrl button::-moz-focus-inner { + border: 0; + padding: 0; +} + +.maplibregl-ctrl-attrib-button:focus, +.maplibregl-ctrl-group button:focus { + box-shadow: 0 0 2px 2px rgb(0 150 255 / 100%); +} + +.maplibregl-ctrl button:disabled { + cursor: not-allowed; +} + +.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon { + opacity: 0.25; +} + +.maplibregl-ctrl button:not(:disabled):hover { + background-color: rgb(0 0 0 / 5%); +} + +.maplibregl-ctrl-group button:focus:focus-visible { + box-shadow: 0 0 2px 2px rgb(0 150 255 / 100%); +} + +.maplibregl-ctrl-group button:focus:not(:focus-visible) { + box-shadow: none; +} + +.maplibregl-ctrl-group button:focus:first-child { + border-radius: 4px 4px 0 0; +} + +.maplibregl-ctrl-group button:focus:last-child { + border-radius: 0 0 4px 4px; +} + +.maplibregl-ctrl-group button:focus:only-child { + border-radius: inherit; +} + +.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-zoom-out.svg", fill: #333); +} + +.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-zoom-in.svg", fill: #333); +} + +@media (-ms-high-contrast: active) { + .maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-zoom-out.svg", fill: #fff); + } + + .maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-zoom-in.svg", fill: #fff); + } +} + +@media (-ms-high-contrast: black-on-white) { + .maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-zoom-out.svg", fill: #000); + } + + .maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-zoom-in.svg", fill: #000); + } +} + +.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-fullscreen.svg", fill: #333); +} + +.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-shrink.svg"); +} + +@media (-ms-high-contrast: active) { + .maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-fullscreen.svg", fill: #fff); + } + + .maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-shrink.svg", fill: #fff); + } +} + +@media (-ms-high-contrast: black-on-white) { + .maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-fullscreen.svg", fill: #000); + } + + .maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-shrink.svg", fill: #000); + } +} + +.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-compass.svg", fill: #333); +} + +@media (-ms-high-contrast: active) { + .maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon { + @svg-load ctrl-compass-white url("svg/maplibregl-ctrl-compass.svg") { + fill: #fff; + #south { fill: #999; } + } + + background-image: svg-inline(ctrl-compass-white); + } +} + +@media (-ms-high-contrast: black-on-white) { + .maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon { + background-image: svg-load("svg/maplibregl-ctrl-compass.svg", fill: #000); + } +} + +@svg-load ctrl-terrain url("svg/maplibregl-ctrl-terrain.svg") { + fill: #333; + #stroke { display: none; } +} + +@svg-load ctrl-terrain-enabled url("svg/maplibregl-ctrl-terrain.svg") { + fill: #33b5e5; + #stroke { display: none; } +} + +.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-terrain); +} + +.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-terrain-enabled); +} + +@svg-load ctrl-geolocate url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #333; + #stroke { display: none; } +} + +@svg-load ctrl-geolocate-white url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #fff; + #stroke { display: none; } +} + +@svg-load ctrl-geolocate-black url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #000; + #stroke { display: none; } +} + +@svg-load ctrl-geolocate-disabled url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #aaa; + #stroke { fill: #f00; } +} + +@svg-load ctrl-geolocate-disabled-white url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #999; + #stroke { fill: #f00; } +} + +@svg-load ctrl-geolocate-disabled-black url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #666; + #stroke { fill: #f00; } +} + +@svg-load ctrl-geolocate-active url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #33b5e5; + #stroke { display: none; } +} + +@svg-load ctrl-geolocate-active-error url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #e58978; + #stroke { display: none; } +} + +@svg-load ctrl-geolocate-background url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #33b5e5; + #stroke { display: none; } + #dot { display: none; } +} + +@svg-load ctrl-geolocate-background-error url("svg/maplibregl-ctrl-geolocate.svg") { + fill: #e54e33; + #stroke { display: none; } + #dot { display: none; } +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate); +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-disabled); +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-active); +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-active-error); +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-background); +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-background-error); +} + +.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon { + animation: maplibregl-spin 2s infinite linear; +} + +@media (-ms-high-contrast: active) { + .maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-white); + } + + .maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-disabled-white); + } + + .maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-active); + } + + .maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-active-error); + } + + .maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-background); + } + + .maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-background-error); + } +} + +@media (-ms-high-contrast: black-on-white) { + .maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-black); + } + + .maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon { + background-image: svg-inline(ctrl-geolocate-disabled-black); + } +} + +@keyframes maplibregl-spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + +a.maplibregl-ctrl-logo { + width: 88px; + height: 23px; + margin: 0 0 -4px -4px; + display: block; + background-repeat: no-repeat; + cursor: pointer; + overflow: hidden; + background-image: svg-load("svg/maplibregl-ctrl-logo.svg"); +} + +a.maplibregl-ctrl-logo.maplibregl-compact { + width: 14px; +} + +@media (-ms-high-contrast: active) { + a.maplibregl-ctrl-logo { + @svg-load ctrl-logo-white url("svg/maplibregl-ctrl-logo.svg") { + #outline { opacity: 1; } + #fill { opacity: 1; } + } + + background-color: transparent; + background-image: svg-inline(ctrl-logo-white); + } +} + +@media (-ms-high-contrast: black-on-white) { + a.maplibregl-ctrl-logo { + @svg-load ctrl-logo-black url("svg/maplibregl-ctrl-logo.svg") { + #outline { opacity: 1; fill: #fff; stroke: #fff; } + #fill { opacity: 1; fill: #000; } + } + + background-image: svg-inline(ctrl-logo-black); + } +} + +.maplibregl-ctrl.maplibregl-ctrl-attrib { + padding: 0 5px; + background-color: rgb(255 255 255 / 50%); + margin: 0; +} + +@media screen { + .maplibregl-ctrl-attrib.maplibregl-compact { + min-height: 20px; + padding: 2px 24px 2px 0; + margin: 10px; + position: relative; + background-color: #fff; + border-radius: 12px; + box-sizing: content-box; + } + + .maplibregl-ctrl-attrib.maplibregl-compact-show { + padding: 2px 28px 2px 8px; + visibility: visible; + } + + .maplibregl-ctrl-top-left > .maplibregl-ctrl-attrib.maplibregl-compact-show, + .maplibregl-ctrl-bottom-left > .maplibregl-ctrl-attrib.maplibregl-compact-show { + padding: 2px 8px 2px 28px; + border-radius: 12px; + } + + .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner { + display: none; + } + + .maplibregl-ctrl-attrib-button { + display: none; + cursor: pointer; + position: absolute; + background-image: svg-load("svg/maplibregl-ctrl-attrib.svg"); + background-color: rgb(255 255 255 / 50%); + width: 24px; + height: 24px; + box-sizing: border-box; + border-radius: 12px; + outline: none; + top: 0; + right: 0; + border: 0; + } + + .maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button { + appearance: none; + list-style: none; + } + + .maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker { + display: none; + } + + .maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button, + .maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button { + left: 0; + } + + .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button, + .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner { + display: block; + } + + .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button { + background-color: rgb(0 0 0 / 5%); + } + + .maplibregl-ctrl-bottom-right > .maplibregl-ctrl-attrib.maplibregl-compact::after { + bottom: 0; + right: 0; + } + + .maplibregl-ctrl-top-right > .maplibregl-ctrl-attrib.maplibregl-compact::after { + top: 0; + right: 0; + } + + .maplibregl-ctrl-top-left > .maplibregl-ctrl-attrib.maplibregl-compact::after { + top: 0; + left: 0; + } + + .maplibregl-ctrl-bottom-left > .maplibregl-ctrl-attrib.maplibregl-compact::after { + bottom: 0; + left: 0; + } +} + +@media screen and (-ms-high-contrast: active) { + .maplibregl-ctrl-attrib.maplibregl-compact::after { + background-image: svg-load("svg/maplibregl-ctrl-attrib.svg", fill=#fff); + } +} + +@media screen and (-ms-high-contrast: black-on-white) { + .maplibregl-ctrl-attrib.maplibregl-compact::after { + background-image: svg-load("svg/maplibregl-ctrl-attrib.svg"); + } +} + +.maplibregl-ctrl-attrib a { + color: rgb(0 0 0 / 75%); + text-decoration: none; +} + +.maplibregl-ctrl-attrib a:hover { + color: inherit; + text-decoration: underline; +} + +.maplibregl-attrib-empty { + display: none; +} + +.maplibregl-ctrl-scale { + background-color: rgb(255 255 255 / 75%); + font-size: 10px; + border-width: medium 2px 2px; + border-style: none solid solid; + border-color: #333; + padding: 0 5px; + color: #333; + box-sizing: border-box; +} + +.maplibregl-popup { + position: absolute; + top: 0; + left: 0; + display: flex; + will-change: transform; + pointer-events: none; +} + +.maplibregl-popup-anchor-top, +.maplibregl-popup-anchor-top-left, +.maplibregl-popup-anchor-top-right { + flex-direction: column; +} + +.maplibregl-popup-anchor-bottom, +.maplibregl-popup-anchor-bottom-left, +.maplibregl-popup-anchor-bottom-right { + flex-direction: column-reverse; +} + +.maplibregl-popup-anchor-left { + flex-direction: row; +} + +.maplibregl-popup-anchor-right { + flex-direction: row-reverse; +} + +.maplibregl-popup-tip { + width: 0; + height: 0; + border: 10px solid transparent; + z-index: 1; +} + +.maplibregl-popup-anchor-top .maplibregl-popup-tip { + align-self: center; + border-top: none; + border-bottom-color: #fff; +} + +.maplibregl-popup-anchor-top-left .maplibregl-popup-tip { + align-self: flex-start; + border-top: none; + border-left: none; + border-bottom-color: #fff; +} + +.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { + align-self: flex-end; + border-top: none; + border-right: none; + border-bottom-color: #fff; +} + +.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { + align-self: center; + border-bottom: none; + border-top-color: #fff; +} + +.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip { + align-self: flex-start; + border-bottom: none; + border-left: none; + border-top-color: #fff; +} + +.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { + align-self: flex-end; + border-bottom: none; + border-right: none; + border-top-color: #fff; +} + +.maplibregl-popup-anchor-left .maplibregl-popup-tip { + align-self: center; + border-left: none; + border-right-color: #fff; +} + +.maplibregl-popup-anchor-right .maplibregl-popup-tip { + align-self: center; + border-right: none; + border-left-color: #fff; +} + +.maplibregl-popup-close-button { + position: absolute; + right: 0; + top: 0; + border: 0; + border-radius: 0 3px 0 0; + cursor: pointer; + background-color: transparent; +} + +.maplibregl-popup-close-button:hover { + background-color: rgb(0 0 0 / 5%); +} + +.maplibregl-popup-content { + position: relative; + background: #fff; + border-radius: 3px; + box-shadow: 0 1px 2px rgb(0 0 0 / 10%); + padding: 15px 10px; + pointer-events: auto; +} + +.maplibregl-popup-anchor-top-left .maplibregl-popup-content { + border-top-left-radius: 0; +} + +.maplibregl-popup-anchor-top-right .maplibregl-popup-content { + border-top-right-radius: 0; +} + +.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content { + border-bottom-left-radius: 0; +} + +.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content { + border-bottom-right-radius: 0; +} + +.maplibregl-popup-track-pointer { + display: none; +} + +.maplibregl-popup-track-pointer * { + pointer-events: none; + user-select: none; +} + +.maplibregl-map:hover .maplibregl-popup-track-pointer { + display: flex; +} + +.maplibregl-map:active .maplibregl-popup-track-pointer { + display: none; +} + +.maplibregl-marker { + position: absolute; + top: 0; + left: 0; + will-change: transform; +} + +.maplibregl-user-location-dot { + background-color: #1da1f2; + width: 15px; + height: 15px; + border-radius: 50%; +} + +.maplibregl-user-location-dot::before { + background-color: #1da1f2; + content: ""; + width: 15px; + height: 15px; + border-radius: 50%; + position: absolute; + animation: maplibregl-user-location-dot-pulse 2s infinite; +} + +.maplibregl-user-location-dot::after { + border-radius: 50%; + border: 2px solid #fff; + content: ""; + height: 19px; + left: -2px; + position: absolute; + top: -2px; + width: 19px; + box-sizing: border-box; + box-shadow: 0 0 3px rgb(0 0 0 / 35%); +} + +@keyframes maplibregl-user-location-dot-pulse { + 0% { transform: scale(1); opacity: 1; } + 70% { transform: scale(3); opacity: 0; } + 100% { transform: scale(1); opacity: 0; } +} + +.maplibregl-user-location-dot-stale { + background-color: #aaa; +} + +.maplibregl-user-location-dot-stale::after { + display: none; +} + +.maplibregl-user-location-accuracy-circle { + background-color: #1da1f233; + width: 1px; + height: 1px; + border-radius: 100%; +} + +.maplibregl-crosshair, +.maplibregl-crosshair .maplibregl-interactive, +.maplibregl-crosshair .maplibregl-interactive:active { + cursor: crosshair; +} + +.maplibregl-boxzoom { + position: absolute; + top: 0; + left: 0; + width: 0; + height: 0; + background: #fff; + border: 2px dotted #202020; + opacity: 0.5; +} + +.maplibregl-cooperative-gesture-screen { + background: rgba(0 0 0 / 40%); + position: absolute; + inset: 0; + display: flex; + justify-content: center; + align-items: center; + color: white; + padding: 1rem; + font-size: 1.4em; + line-height: 1.2; + opacity: 0; + pointer-events: none; + transition: opacity 1s ease 1s; + z-index: 99999; +} + +.maplibregl-cooperative-gesture-screen.maplibregl-show { + opacity: 1; + transition: opacity 0.05s; +} + +.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message { + display: none; +} + +@media (hover: none), (width <= 480px) { + .maplibregl-cooperative-gesture-screen .maplibregl-desktop-message { + display: none; + } + + .maplibregl-cooperative-gesture-screen .maplibregl-mobile-message { + display: block; + } +} + +.maplibregl-pseudo-fullscreen { + position: fixed !important; + width: 100% !important; + height: 100% !important; + top: 0 !important; + left: 0 !important; + z-index: 99999; +} diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-attrib.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-attrib.svg new file mode 100644 index 00000000..f96152c9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-attrib.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-compass.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-compass.svg new file mode 100644 index 00000000..8df846a3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-compass.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-fullscreen.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-fullscreen.svg new file mode 100644 index 00000000..724408d4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-fullscreen.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-geolocate.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-geolocate.svg new file mode 100644 index 00000000..4b298666 --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-geolocate.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-logo.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-logo.svg new file mode 100644 index 00000000..419d757f --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-shrink.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-shrink.svg new file mode 100644 index 00000000..fe6df096 --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-shrink.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-terrain.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-terrain.svg new file mode 100644 index 00000000..af8fefe7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-terrain.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-zoom-in.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-zoom-in.svg new file mode 100644 index 00000000..98fb23fa --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-zoom-in.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-zoom-out.svg b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-zoom-out.svg new file mode 100644 index 00000000..4af24dea --- /dev/null +++ b/web/libraries/maplibre-gl/src/css/svg/maplibregl-ctrl-zoom-out.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/data/array_types.g.ts b/web/libraries/maplibre-gl/src/data/array_types.g.ts new file mode 100644 index 00000000..d71623b9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/array_types.g.ts @@ -0,0 +1,1124 @@ +// This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`. + +import {Struct, StructArray} from '../util/struct_array'; +import {register} from '../util/web_worker_transfer'; +import Point from '@mapbox/point-geometry'; + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * + */ +class StructArrayLayout2i4 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1); + } + + public emplace(i: number, v0: number, v1: number) { + const o2 = i * 2; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + return i; + } +} + +StructArrayLayout2i4.prototype.bytesPerElement = 4; +register('StructArrayLayout2i4', StructArrayLayout2i4); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[3] + * + */ +class StructArrayLayout3i6 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + + public emplace(i: number, v0: number, v1: number, v2: number) { + const o2 = i * 3; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + return i; + } +} + +StructArrayLayout3i6.prototype.bytesPerElement = 6; +register('StructArrayLayout3i6', StructArrayLayout3i6); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[4] + * + */ +class StructArrayLayout4i8 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number) { + const o2 = i * 4; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + return i; + } +} + +StructArrayLayout4i8.prototype.bytesPerElement = 8; +register('StructArrayLayout4i8', StructArrayLayout4i8); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Int16[4] + * + */ +class StructArrayLayout2i4i12 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) { + const o2 = i * 6; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + return i; + } +} + +StructArrayLayout2i4i12.prototype.bytesPerElement = 12; +register('StructArrayLayout2i4i12', StructArrayLayout2i4i12); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Uint8[4] + * + */ +class StructArrayLayout2i4ub8 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) { + const o2 = i * 4; + const o1 = i * 8; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.uint8[o1 + 4] = v2; + this.uint8[o1 + 5] = v3; + this.uint8[o1 + 6] = v4; + this.uint8[o1 + 7] = v5; + return i; + } +} + +StructArrayLayout2i4ub8.prototype.bytesPerElement = 8; +register('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[2] + * + */ +class StructArrayLayout2f8 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1); + } + + public emplace(i: number, v0: number, v1: number) { + const o4 = i * 2; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + return i; + } +} + +StructArrayLayout2f8.prototype.bytesPerElement = 8; +register('StructArrayLayout2f8', StructArrayLayout2f8); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[10] + * + */ +class StructArrayLayout10ui20 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) { + const o2 = i * 10; + this.uint16[o2 + 0] = v0; + this.uint16[o2 + 1] = v1; + this.uint16[o2 + 2] = v2; + this.uint16[o2 + 3] = v3; + this.uint16[o2 + 4] = v4; + this.uint16[o2 + 5] = v5; + this.uint16[o2 + 6] = v6; + this.uint16[o2 + 7] = v7; + this.uint16[o2 + 8] = v8; + this.uint16[o2 + 9] = v9; + return i; + } +} + +StructArrayLayout10ui20.prototype.bytesPerElement = 20; +register('StructArrayLayout10ui20', StructArrayLayout10ui20); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[4] + * [8]: Uint16[4] + * [16]: Int16[4] + * + */ +class StructArrayLayout4i4ui4i24 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number) { + const o2 = i * 12; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.uint16[o2 + 4] = v4; + this.uint16[o2 + 5] = v5; + this.uint16[o2 + 6] = v6; + this.uint16[o2 + 7] = v7; + this.int16[o2 + 8] = v8; + this.int16[o2 + 9] = v9; + this.int16[o2 + 10] = v10; + this.int16[o2 + 11] = v11; + return i; + } +} + +StructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24; +register('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[3] + * + */ +class StructArrayLayout3f12 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + + public emplace(i: number, v0: number, v1: number, v2: number) { + const o4 = i * 3; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + return i; + } +} + +StructArrayLayout3f12.prototype.bytesPerElement = 12; +register('StructArrayLayout3f12', StructArrayLayout3f12); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint32[1] + * + */ +class StructArrayLayout1ul4 extends StructArray { + uint8: Uint8Array; + uint32: Uint32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0); + } + + public emplace(i: number, v0: number) { + const o4 = i * 1; + this.uint32[o4 + 0] = v0; + return i; + } +} + +StructArrayLayout1ul4.prototype.bytesPerElement = 4; +register('StructArrayLayout1ul4', StructArrayLayout1ul4); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[6] + * [12]: Uint32[1] + * [16]: Uint16[2] + * + */ +class StructArrayLayout6i1ul2ui20 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint32: Uint32Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number) { + const o2 = i * 10; + const o4 = i * 5; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + this.uint32[o4 + 3] = v6; + this.uint16[o2 + 8] = v7; + this.uint16[o2 + 9] = v8; + return i; + } +} + +StructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20; +register('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Int16[2] + * [8]: Int16[2] + * + */ +class StructArrayLayout2i2i2i12 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number) { + const o2 = i * 6; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + return i; + } +} + +StructArrayLayout2i2i2i12.prototype.bytesPerElement = 12; +register('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[2] + * [8]: Float32[1] + * [12]: Int16[2] + * + */ +class StructArrayLayout2f1f2i16 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + int16: Int16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number) { + const o4 = i * 4; + const o2 = i * 8; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + this.int16[o2 + 6] = v3; + this.int16[o2 + 7] = v4; + return i; + } +} + +StructArrayLayout2f1f2i16.prototype.bytesPerElement = 16; +register('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint8[2] + * [4]: Float32[2] + * + */ +class StructArrayLayout2ub2f12 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number) { + const o1 = i * 12; + const o4 = i * 3; + this.uint8[o1 + 0] = v0; + this.uint8[o1 + 1] = v1; + this.float32[o4 + 1] = v2; + this.float32[o4 + 2] = v3; + return i; + } +} + +StructArrayLayout2ub2f12.prototype.bytesPerElement = 12; +register('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[3] + * + */ +class StructArrayLayout3ui6 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + + public emplace(i: number, v0: number, v1: number, v2: number) { + const o2 = i * 3; + this.uint16[o2 + 0] = v0; + this.uint16[o2 + 1] = v1; + this.uint16[o2 + 2] = v2; + return i; + } +} + +StructArrayLayout3ui6.prototype.bytesPerElement = 6; +register('StructArrayLayout3ui6', StructArrayLayout3ui6); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[2] + * [4]: Uint16[2] + * [8]: Uint32[3] + * [20]: Uint16[3] + * [28]: Float32[2] + * [36]: Uint8[3] + * [40]: Uint32[1] + * [44]: Int16[1] + * + */ +class StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint16: Uint16Array; + uint32: Uint32Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number) { + const o2 = i * 24; + const o4 = i * 12; + const o1 = i * 48; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.uint16[o2 + 2] = v2; + this.uint16[o2 + 3] = v3; + this.uint32[o4 + 2] = v4; + this.uint32[o4 + 3] = v5; + this.uint32[o4 + 4] = v6; + this.uint16[o2 + 10] = v7; + this.uint16[o2 + 11] = v8; + this.uint16[o2 + 12] = v9; + this.float32[o4 + 7] = v10; + this.float32[o4 + 8] = v11; + this.uint8[o1 + 36] = v12; + this.uint8[o1 + 37] = v13; + this.uint8[o1 + 38] = v14; + this.uint32[o4 + 10] = v15; + this.int16[o2 + 22] = v16; + return i; + } +} + +StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48; +register('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Int16[8] + * [16]: Uint16[15] + * [48]: Uint32[1] + * [52]: Float32[2] + * [60]: Uint16[2] + * + */ +class StructArrayLayout8i15ui1ul2f2ui64 extends StructArray { + uint8: Uint8Array; + int16: Int16Array; + uint16: Uint16Array; + uint32: Uint32Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.int16 = new Int16Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) { + const o2 = i * 32; + const o4 = i * 16; + this.int16[o2 + 0] = v0; + this.int16[o2 + 1] = v1; + this.int16[o2 + 2] = v2; + this.int16[o2 + 3] = v3; + this.int16[o2 + 4] = v4; + this.int16[o2 + 5] = v5; + this.int16[o2 + 6] = v6; + this.int16[o2 + 7] = v7; + this.uint16[o2 + 8] = v8; + this.uint16[o2 + 9] = v9; + this.uint16[o2 + 10] = v10; + this.uint16[o2 + 11] = v11; + this.uint16[o2 + 12] = v12; + this.uint16[o2 + 13] = v13; + this.uint16[o2 + 14] = v14; + this.uint16[o2 + 15] = v15; + this.uint16[o2 + 16] = v16; + this.uint16[o2 + 17] = v17; + this.uint16[o2 + 18] = v18; + this.uint16[o2 + 19] = v19; + this.uint16[o2 + 20] = v20; + this.uint16[o2 + 21] = v21; + this.uint16[o2 + 22] = v22; + this.uint32[o4 + 12] = v23; + this.float32[o4 + 13] = v24; + this.float32[o4 + 14] = v25; + this.uint16[o2 + 30] = v26; + this.uint16[o2 + 31] = v27; + return i; + } +} + +StructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64; +register('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[1] + * + */ +class StructArrayLayout1f4 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0); + } + + public emplace(i: number, v0: number) { + const o4 = i * 1; + this.float32[o4 + 0] = v0; + return i; + } +} + +StructArrayLayout1f4.prototype.bytesPerElement = 4; +register('StructArrayLayout1f4', StructArrayLayout1f4); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[1] + * [4]: Float32[2] + * + */ +class StructArrayLayout1ui2f12 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + + public emplace(i: number, v0: number, v1: number, v2: number) { + const o2 = i * 6; + const o4 = i * 3; + this.uint16[o2 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + return i; + } +} + +StructArrayLayout1ui2f12.prototype.bytesPerElement = 12; +register('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint32[1] + * [4]: Uint16[2] + * + */ +class StructArrayLayout1ul2ui8 extends StructArray { + uint8: Uint8Array; + uint32: Uint32Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint32 = new Uint32Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2); + } + + public emplace(i: number, v0: number, v1: number, v2: number) { + const o4 = i * 2; + const o2 = i * 4; + this.uint32[o4 + 0] = v0; + this.uint16[o2 + 2] = v1; + this.uint16[o2 + 3] = v2; + return i; + } +} + +StructArrayLayout1ul2ui8.prototype.bytesPerElement = 8; +register('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[2] + * + */ +class StructArrayLayout2ui4 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1); + } + + public emplace(i: number, v0: number, v1: number) { + const o2 = i * 2; + this.uint16[o2 + 0] = v0; + this.uint16[o2 + 1] = v1; + return i; + } +} + +StructArrayLayout2ui4.prototype.bytesPerElement = 4; +register('StructArrayLayout2ui4', StructArrayLayout2ui4); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Uint16[1] + * + */ +class StructArrayLayout1ui2 extends StructArray { + uint8: Uint8Array; + uint16: Uint16Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.uint16 = new Uint16Array(this.arrayBuffer); + } + + public emplaceBack(v0: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0); + } + + public emplace(i: number, v0: number) { + const o2 = i * 1; + this.uint16[o2 + 0] = v0; + return i; + } +} + +StructArrayLayout1ui2.prototype.bytesPerElement = 2; +register('StructArrayLayout1ui2', StructArrayLayout1ui2); + +/** + * @internal + * Implementation of the StructArray layout: + * [0]: Float32[4] + * + */ +class StructArrayLayout4f16 extends StructArray { + uint8: Uint8Array; + float32: Float32Array; + + _refreshViews() { + this.uint8 = new Uint8Array(this.arrayBuffer); + this.float32 = new Float32Array(this.arrayBuffer); + } + + public emplaceBack(v0: number, v1: number, v2: number, v3: number) { + const i = this.length; + this.resize(i + 1); + return this.emplace(i, v0, v1, v2, v3); + } + + public emplace(i: number, v0: number, v1: number, v2: number, v3: number) { + const o4 = i * 4; + this.float32[o4 + 0] = v0; + this.float32[o4 + 1] = v1; + this.float32[o4 + 2] = v2; + this.float32[o4 + 3] = v3; + return i; + } +} + +StructArrayLayout4f16.prototype.bytesPerElement = 16; +register('StructArrayLayout4f16', StructArrayLayout4f16); + +/** @internal */ +class CollisionBoxStruct extends Struct { + _structArray: CollisionBoxArray; + get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; } + get anchorPointY() { return this._structArray.int16[this._pos2 + 1]; } + get x1() { return this._structArray.int16[this._pos2 + 2]; } + get y1() { return this._structArray.int16[this._pos2 + 3]; } + get x2() { return this._structArray.int16[this._pos2 + 4]; } + get y2() { return this._structArray.int16[this._pos2 + 5]; } + get featureIndex() { return this._structArray.uint32[this._pos4 + 3]; } + get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 8]; } + get bucketIndex() { return this._structArray.uint16[this._pos2 + 9]; } + get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); } +} + +CollisionBoxStruct.prototype.size = 20; + +export type CollisionBox = CollisionBoxStruct; + +/** @internal */ +export class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 { + /** + * Return the CollisionBoxStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): CollisionBoxStruct { + return new CollisionBoxStruct(this, index); + } +} + +register('CollisionBoxArray', CollisionBoxArray); + +/** @internal */ +class PlacedSymbolStruct extends Struct { + _structArray: PlacedSymbolArray; + get anchorX() { return this._structArray.int16[this._pos2 + 0]; } + get anchorY() { return this._structArray.int16[this._pos2 + 1]; } + get glyphStartIndex() { return this._structArray.uint16[this._pos2 + 2]; } + get numGlyphs() { return this._structArray.uint16[this._pos2 + 3]; } + get vertexStartIndex() { return this._structArray.uint32[this._pos4 + 2]; } + get lineStartIndex() { return this._structArray.uint32[this._pos4 + 3]; } + get lineLength() { return this._structArray.uint32[this._pos4 + 4]; } + get segment() { return this._structArray.uint16[this._pos2 + 10]; } + get lowerSize() { return this._structArray.uint16[this._pos2 + 11]; } + get upperSize() { return this._structArray.uint16[this._pos2 + 12]; } + get lineOffsetX() { return this._structArray.float32[this._pos4 + 7]; } + get lineOffsetY() { return this._structArray.float32[this._pos4 + 8]; } + get writingMode() { return this._structArray.uint8[this._pos1 + 36]; } + get placedOrientation() { return this._structArray.uint8[this._pos1 + 37]; } + set placedOrientation(x: number) { this._structArray.uint8[this._pos1 + 37] = x; } + get hidden() { return this._structArray.uint8[this._pos1 + 38]; } + set hidden(x: number) { this._structArray.uint8[this._pos1 + 38] = x; } + get crossTileID() { return this._structArray.uint32[this._pos4 + 10]; } + set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 10] = x; } + get associatedIconIndex() { return this._structArray.int16[this._pos2 + 22]; } +} + +PlacedSymbolStruct.prototype.size = 48; + +export type PlacedSymbol = PlacedSymbolStruct; + +/** @internal */ +export class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 { + /** + * Return the PlacedSymbolStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): PlacedSymbolStruct { + return new PlacedSymbolStruct(this, index); + } +} + +register('PlacedSymbolArray', PlacedSymbolArray); + +/** @internal */ +class SymbolInstanceStruct extends Struct { + _structArray: SymbolInstanceArray; + get anchorX() { return this._structArray.int16[this._pos2 + 0]; } + get anchorY() { return this._structArray.int16[this._pos2 + 1]; } + get rightJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 2]; } + get centerJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 3]; } + get leftJustifiedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 4]; } + get verticalPlacedTextSymbolIndex() { return this._structArray.int16[this._pos2 + 5]; } + get placedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 6]; } + get verticalPlacedIconSymbolIndex() { return this._structArray.int16[this._pos2 + 7]; } + get key() { return this._structArray.uint16[this._pos2 + 8]; } + get textBoxStartIndex() { return this._structArray.uint16[this._pos2 + 9]; } + get textBoxEndIndex() { return this._structArray.uint16[this._pos2 + 10]; } + get verticalTextBoxStartIndex() { return this._structArray.uint16[this._pos2 + 11]; } + get verticalTextBoxEndIndex() { return this._structArray.uint16[this._pos2 + 12]; } + get iconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 13]; } + get iconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 14]; } + get verticalIconBoxStartIndex() { return this._structArray.uint16[this._pos2 + 15]; } + get verticalIconBoxEndIndex() { return this._structArray.uint16[this._pos2 + 16]; } + get featureIndex() { return this._structArray.uint16[this._pos2 + 17]; } + get numHorizontalGlyphVertices() { return this._structArray.uint16[this._pos2 + 18]; } + get numVerticalGlyphVertices() { return this._structArray.uint16[this._pos2 + 19]; } + get numIconVertices() { return this._structArray.uint16[this._pos2 + 20]; } + get numVerticalIconVertices() { return this._structArray.uint16[this._pos2 + 21]; } + get useRuntimeCollisionCircles() { return this._structArray.uint16[this._pos2 + 22]; } + get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; } + set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 12] = x; } + get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; } + get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; } + get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; } + get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; } +} + +SymbolInstanceStruct.prototype.size = 64; + +export type SymbolInstance = SymbolInstanceStruct; + +/** @internal */ +export class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 { + /** + * Return the SymbolInstanceStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): SymbolInstanceStruct { + return new SymbolInstanceStruct(this, index); + } +} + +register('SymbolInstanceArray', SymbolInstanceArray); + +/** @internal */ +export class GlyphOffsetArray extends StructArrayLayout1f4 { + getoffsetX(index: number) { return this.float32[index * 1 + 0]; } +} + +register('GlyphOffsetArray', GlyphOffsetArray); + +/** @internal */ +export class SymbolLineVertexArray extends StructArrayLayout3i6 { + getx(index: number) { return this.int16[index * 3 + 0]; } + gety(index: number) { return this.int16[index * 3 + 1]; } + gettileUnitDistanceFromAnchor(index: number) { return this.int16[index * 3 + 2]; } +} + +register('SymbolLineVertexArray', SymbolLineVertexArray); + +/** @internal */ +class TextAnchorOffsetStruct extends Struct { + _structArray: TextAnchorOffsetArray; + get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; } + get textOffset0() { return this._structArray.float32[this._pos4 + 1]; } + get textOffset1() { return this._structArray.float32[this._pos4 + 2]; } +} + +TextAnchorOffsetStruct.prototype.size = 12; + +export type TextAnchorOffset = TextAnchorOffsetStruct; + +/** @internal */ +export class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 { + /** + * Return the TextAnchorOffsetStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): TextAnchorOffsetStruct { + return new TextAnchorOffsetStruct(this, index); + } +} + +register('TextAnchorOffsetArray', TextAnchorOffsetArray); + +/** @internal */ +class FeatureIndexStruct extends Struct { + _structArray: FeatureIndexArray; + get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; } + get sourceLayerIndex() { return this._structArray.uint16[this._pos2 + 2]; } + get bucketIndex() { return this._structArray.uint16[this._pos2 + 3]; } +} + +FeatureIndexStruct.prototype.size = 8; + +export type FeatureIndex = FeatureIndexStruct; + +/** @internal */ +export class FeatureIndexArray extends StructArrayLayout1ul2ui8 { + /** + * Return the FeatureIndexStruct at the given location in the array. + * @param index The index of the element. + */ + get(index: number): FeatureIndexStruct { + return new FeatureIndexStruct(this, index); + } +} + +register('FeatureIndexArray', FeatureIndexArray); + +export class PosArray extends StructArrayLayout2i4 {} +export class Pos3dArray extends StructArrayLayout3i6 {} +export class RasterBoundsArray extends StructArrayLayout4i8 {} +export class CircleLayoutArray extends StructArrayLayout2i4 {} +export class FillLayoutArray extends StructArrayLayout2i4 {} +export class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 {} +export class HeatmapLayoutArray extends StructArrayLayout2i4 {} +export class LineLayoutArray extends StructArrayLayout2i4ub8 {} +export class LineExtLayoutArray extends StructArrayLayout2f8 {} +export class PatternLayoutArray extends StructArrayLayout10ui20 {} +export class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 {} +export class SymbolDynamicLayoutArray extends StructArrayLayout3f12 {} +export class SymbolOpacityArray extends StructArrayLayout1ul4 {} +export class CollisionBoxLayoutArray extends StructArrayLayout2i2i2i12 {} +export class CollisionCircleLayoutArray extends StructArrayLayout2f1f2i16 {} +export class CollisionVertexArray extends StructArrayLayout2ub2f12 {} +export class QuadTriangleArray extends StructArrayLayout3ui6 {} +export class TriangleIndexArray extends StructArrayLayout3ui6 {} +export class LineIndexArray extends StructArrayLayout2ui4 {} +export class LineStripIndexArray extends StructArrayLayout1ui2 {} +export { + StructArrayLayout2i4, + StructArrayLayout3i6, + StructArrayLayout4i8, + StructArrayLayout2i4i12, + StructArrayLayout2i4ub8, + StructArrayLayout2f8, + StructArrayLayout10ui20, + StructArrayLayout4i4ui4i24, + StructArrayLayout3f12, + StructArrayLayout1ul4, + StructArrayLayout6i1ul2ui20, + StructArrayLayout2i2i2i12, + StructArrayLayout2f1f2i16, + StructArrayLayout2ub2f12, + StructArrayLayout3ui6, + StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48, + StructArrayLayout8i15ui1ul2f2ui64, + StructArrayLayout1f4, + StructArrayLayout1ui2f12, + StructArrayLayout1ul2ui8, + StructArrayLayout2ui4, + StructArrayLayout1ui2, + StructArrayLayout4f16 +}; diff --git a/web/libraries/maplibre-gl/src/data/bucket.ts b/web/libraries/maplibre-gl/src/data/bucket.ts new file mode 100644 index 00000000..0435acc5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket.ts @@ -0,0 +1,123 @@ +import type {CollisionBoxArray} from './array_types.g'; +import type {Style} from '../style/style'; +import type {TypedStyleLayer} from '../style/style_layer/typed_style_layer'; +import type {FeatureIndex} from './feature_index'; +import type {Context} from '../gl/context'; +import type {FeatureStates} from '../source/source_state'; +import type {ImagePosition} from '../render/image_atlas'; +import type {CanonicalTileID} from '../source/tile_id'; +import type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile'; +import Point from '@mapbox/point-geometry'; + +export type BucketParameters = { + index: number; + layers: Array; + zoom: number; + pixelRatio: number; + overscaling: number; + collisionBoxArray: CollisionBoxArray; + sourceLayerIndex: number; + sourceID: string; +}; + +export type PopulateParameters = { + featureIndex: FeatureIndex; + iconDependencies: {}; + patternDependencies: {}; + glyphDependencies: {}; + availableImages: Array; +}; + +export type IndexedFeature = { + feature: VectorTileFeature; + id: number | string; + index: number; + sourceLayerIndex: number; +}; + +export type BucketFeature = { + index: number; + sourceLayerIndex: number; + geometry: Array>; + properties: any; + type: 0 | 1 | 2 | 3; + id?: any; + readonly patterns: { + [_: string]: { + 'min': string; + 'mid': string; + 'max': string; + }; + }; + sortKey?: number; +}; + +/** + * The `Bucket` interface is the single point of knowledge about turning vector + * tiles into WebGL buffers. + * + * `Bucket` is an abstract interface. An implementation exists for each style layer type. + * Create a bucket via the `StyleLayer#createBucket` method. + * + * The concrete bucket types, using layout options from the style layer, + * transform feature geometries into vertex and index data for use by the + * vertex shader. They also (via `ProgramConfiguration`) use feature + * properties and the zoom level to populate the attributes needed for + * data-driven styling. + * + * Buckets are designed to be built on a worker thread and then serialized and + * transferred back to the main thread for rendering. On the worker side, a + * bucket's vertex, index, and attribute data is stored in `bucket.arrays: ArrayGroup`. + * When a bucket's data is serialized and sent back to the main thread, + * is gets deserialized (using `new Bucket(serializedBucketData)`, with + * the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups + * hold the same data as ArrayGroups, but are tuned for consumption by WebGL. + */ +export interface Bucket { + layerIds: Array; + hasPattern: boolean; + readonly layers: Array; + readonly stateDependentLayers: Array; + readonly stateDependentLayerIds: Array; + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID): void; + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}): void; + isEmpty(): boolean; + upload(context: Context): void; + uploadPending(): boolean; + /** + * Release the WebGL resources associated with the buffers. Note that because + * buckets are shared between layers having the same layout properties, they + * must be destroyed in groups (all buckets for a tile, or all symbol buckets). + */ + destroy(): void; +} + +export function deserialize(input: Array, style: Style): {[_: string]: Bucket} { + const output = {}; + + // Guard against the case where the map's style has been set to null while + // this bucket has been parsing. + if (!style) return output; + + for (const bucket of input) { + const layers = bucket.layerIds + .map((id) => style.getLayer(id)) + .filter(Boolean); + + if (layers.length === 0) { + continue; + } + + // look up StyleLayer objects from layer ids (since we don't + // want to waste time serializing/copying them from the worker) + (bucket as any).layers = layers; + if (bucket.stateDependentLayerIds) { + (bucket as any).stateDependentLayers = bucket.stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]); + } + for (const layer of layers) { + output[layer.id] = bucket; + } + } + + return output; +} diff --git a/web/libraries/maplibre-gl/src/data/bucket/circle_attributes.ts b/web/libraries/maplibre-gl/src/data/bucket/circle_attributes.ts new file mode 100644 index 00000000..ed9ebcef --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/circle_attributes.ts @@ -0,0 +1,8 @@ +import {createLayout} from '../../util/struct_array'; + +const layout = createLayout([ + {name: 'a_pos', components: 2, type: 'Int16'} +], 4); + +export default layout; +export const {members, size, alignment} = layout; diff --git a/web/libraries/maplibre-gl/src/data/bucket/circle_bucket.ts b/web/libraries/maplibre-gl/src/data/bucket/circle_bucket.ts new file mode 100644 index 00000000..0fcbda0a --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/circle_bucket.ts @@ -0,0 +1,197 @@ +import {CircleLayoutArray} from '../array_types.g'; + +import {members as layoutAttributes} from './circle_attributes'; +import {SegmentVector} from '../segment'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray} from '../index_array_type'; +import {loadGeometry} from '../load_geometry'; +import {toEvaluationFeature} from '../evaluation_feature'; +import {EXTENT} from '../extent'; +import {register} from '../../util/web_worker_transfer'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; + +import type {CanonicalTileID} from '../../source/tile_id'; +import type { + Bucket, + BucketParameters, + BucketFeature, + IndexedFeature, + PopulateParameters +} from '../bucket'; +import type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer'; +import type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer'; +import type {Context} from '../../gl/context'; +import type {IndexBuffer} from '../../gl/index_buffer'; +import type {VertexBuffer} from '../../gl/vertex_buffer'; +import type Point from '@mapbox/point-geometry'; +import type {FeatureStates} from '../../source/source_state'; +import type {ImagePosition} from '../../render/image_atlas'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; + +function addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) { + layoutVertexArray.emplaceBack( + (x * 2) + ((extrudeX + 1) / 2), + (y * 2) + ((extrudeY + 1) / 2)); +} + +/** + * @internal + * Circles are represented by two triangles. + * + * Each corner has a pos that is the center of the circle and an extrusion + * vector that is where it points. + */ +export class CircleBucket implements Bucket { + index: number; + zoom: number; + overscaling: number; + layerIds: Array; + layers: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + + layoutVertexArray: CircleLayoutArray; + layoutVertexBuffer: VertexBuffer; + + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + uploaded: boolean; + + constructor(options: BucketParameters) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + + this.layoutVertexArray = new CircleLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.segments = new SegmentVector(); + this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom); + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + } + + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) { + const styleLayer = this.layers[0]; + 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 CircleStyleLayer).layout.get('circle-sort-key'); + sortFeaturesByKey = !circleSortKey.isConstant(); + } + + for (const {feature, id, index, sourceLayerIndex} of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue; + + const sortKey = sortFeaturesByKey ? + circleSortKey.evaluate(evaluationFeature, {}, canonical) : + undefined; + + const bucketFeature: BucketFeature = { + id, + properties: feature.properties, + type: feature.type, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + patterns: {}, + sortKey + }; + + bucketFeatures.push(bucketFeature); + + } + + if (sortFeaturesByKey) { + bucketFeatures.sort((a, b) => a.sortKey - b.sortKey); + } + + for (const bucketFeature of bucketFeatures) { + const {geometry, index, sourceLayerIndex} = bucketFeature; + const feature = features[index].feature; + + this.addFeature(bucketFeature, geometry, index, canonical); + options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index); + } + } + + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) { + if (!this.stateDependentLayers.length) return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + + isEmpty() { + return this.layoutVertexArray.length === 0; + } + + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + + upload(context: Context) { + if (!this.uploaded) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + + destroy() { + if (!this.layoutVertexBuffer) return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + } + + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID) { + for (const ring of geometry) { + for (const point of ring) { + const x = point.x; + const y = point.y; + + // Do not include points that are outside the tile boundaries. + if (x < 0 || x >= EXTENT || y < 0 || y >= EXTENT) continue; + + // this geometry will be of the Point type, and we'll derive + // two triangles from it. + // + // ┌─────────┐ + // │ 3 2 │ + // │ │ + // │ 0 1 │ + // └─────────┘ + + const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey); + const index = segment.vertexLength; + + addCircleVertex(this.layoutVertexArray, x, y, -1, -1); + addCircleVertex(this.layoutVertexArray, x, y, 1, -1); + addCircleVertex(this.layoutVertexArray, x, y, 1, 1); + addCircleVertex(this.layoutVertexArray, x, y, -1, 1); + + this.indexArray.emplaceBack(index, index + 1, index + 2); + this.indexArray.emplaceBack(index, index + 3, index + 2); + + segment.vertexLength += 4; + segment.primitiveLength += 2; + } + } + + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical); + } +} + +register('CircleBucket', CircleBucket, {omit: ['layers']}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/fill_attributes.ts b/web/libraries/maplibre-gl/src/data/bucket/fill_attributes.ts new file mode 100644 index 00000000..ed9ebcef --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/fill_attributes.ts @@ -0,0 +1,8 @@ +import {createLayout} from '../../util/struct_array'; + +const layout = createLayout([ + {name: 'a_pos', components: 2, type: 'Int16'} +], 4); + +export default layout; +export const {members, size, alignment} = layout; diff --git a/web/libraries/maplibre-gl/src/data/bucket/fill_bucket.test.ts b/web/libraries/maplibre-gl/src/data/bucket/fill_bucket.test.ts new file mode 100644 index 00000000..06bd6056 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/fill_bucket.test.ts @@ -0,0 +1,95 @@ + +import fs from 'fs'; +import path from 'path'; +import Protobuf from 'pbf'; +import {VectorTile} from '@mapbox/vector-tile'; +import Point from '@mapbox/point-geometry'; +import {SegmentVector} from '../segment'; +import {FillBucket} from './fill_bucket'; +import {FillStyleLayer} from '../../style/style_layer/fill_style_layer'; +import {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; +import {ZoomHistory} from '../../style/zoom_history'; +import {BucketFeature, BucketParameters} from '../bucket'; + +// Load a fill feature from fixture tile. +const vt = new VectorTile(new Protobuf(fs.readFileSync(path.resolve(__dirname, '../../../test/unit/assets/mbsv5-6-18-23.vector.pbf')))); +const feature = vt.layers.water.feature(0); + +function createPolygon(numPoints) { + const points = []; + for (let i = 0; i < numPoints; i++) { + points.push(new Point(2048 + 256 * Math.cos(i / numPoints * 2 * Math.PI), 2048 + 256 * Math.sin(i / numPoints * 2 * Math.PI))); + } + return points; +} + +test('FillBucket', () => { + expect(() => { + const layer = new FillStyleLayer({id: 'test', type: 'fill', layout: {}} as LayerSpecification); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, undefined); + + const bucket = new FillBucket({layers: [layer]} as BucketParameters); + + bucket.addFeature({} as BucketFeature, [[ + new Point(0, 0), + new Point(10, 10) + ]], undefined, undefined, undefined); + + bucket.addFeature({} as BucketFeature, [[ + new Point(0, 0), + new Point(10, 10), + new Point(10, 20) + ]], undefined, undefined, undefined); + + bucket.addFeature(feature as any, feature.loadGeometry(), undefined, undefined, undefined); + }).not.toThrow(); +}); + +test('FillBucket segmentation', () => { + // Stub MAX_VERTEX_ARRAY_LENGTH so we can test features + // breaking across array groups without tests taking a _long_ time. + Object.defineProperty(SegmentVector, 'MAX_VERTEX_ARRAY_LENGTH', {value: 256}); + + const layer = new FillStyleLayer({ + id: 'test', + type: 'fill', + layout: {}, + source: 'source', + paint: { + 'fill-color': ['to-color', ['get', 'foo'], '#000'] + } + } as LayerSpecification); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, undefined); + + const bucket = new FillBucket({layers: [layer]} as BucketParameters); + + // first add an initial, small feature to make sure the next one starts at + // a non-zero offset + bucket.addFeature({} as BucketFeature, [createPolygon(10)], undefined, undefined, undefined); + + // add a feature that will break across the group boundary + bucket.addFeature({} as BucketFeature, [ + createPolygon(128), + createPolygon(128) + ], undefined, undefined, undefined); + + // Each polygon must fit entirely within a segment, so we expect the + // first segment to include the first feature and the first polygon + // of the second feature, and the second segment to include the + // second polygon of the second feature. + expect(bucket.layoutVertexArray).toHaveLength(266); + expect(bucket.segments.get()[0]).toEqual({ + vertexOffset: 0, + vertexLength: 138, + primitiveOffset: 0, + primitiveLength: 134 + }); + expect(bucket.segments.get()[1]).toEqual({ + vertexOffset: 138, + vertexLength: 128, + primitiveOffset: 134, + primitiveLength: 126 + }); + +}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/fill_bucket.ts b/web/libraries/maplibre-gl/src/data/bucket/fill_bucket.ts new file mode 100644 index 00000000..2fc87116 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/fill_bucket.ts @@ -0,0 +1,228 @@ +import {FillLayoutArray} from '../array_types.g'; + +import {members as layoutAttributes} from './fill_attributes'; +import {SegmentVector} from '../segment'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {LineIndexArray, TriangleIndexArray} from '../index_array_type'; +import earcut from 'earcut'; +import {classifyRings} from '../../util/classify_rings'; +const EARCUT_MAX_RINGS = 500; +import {register} from '../../util/web_worker_transfer'; +import {hasPattern, addPatternDependencies} from './pattern_bucket_features'; +import {loadGeometry} from '../load_geometry'; +import {toEvaluationFeature} from '../evaluation_feature'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; + +import type {CanonicalTileID} from '../../source/tile_id'; +import type { + Bucket, + BucketParameters, + BucketFeature, + IndexedFeature, + PopulateParameters +} from '../bucket'; +import type {FillStyleLayer} from '../../style/style_layer/fill_style_layer'; +import type {Context} from '../../gl/context'; +import type {IndexBuffer} from '../../gl/index_buffer'; +import type {VertexBuffer} from '../../gl/vertex_buffer'; +import type Point from '@mapbox/point-geometry'; +import type {FeatureStates} from '../../source/source_state'; +import type {ImagePosition} from '../../render/image_atlas'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; + +export class FillBucket implements Bucket { + index: number; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + patternFeatures: Array; + + layoutVertexArray: FillLayoutArray; + layoutVertexBuffer: VertexBuffer; + + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + + indexArray2: LineIndexArray; + indexBuffer2: IndexBuffer; + + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + segments2: SegmentVector; + uploaded: boolean; + + constructor(options: BucketParameters) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + this.patternFeatures = []; + + this.layoutVertexArray = new FillLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.indexArray2 = new LineIndexArray(); + this.programConfigurations = new ProgramConfigurationSet(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, options: PopulateParameters, canonical: CanonicalTileID) { + this.hasPattern = hasPattern('fill', this.layers, options); + const fillSortKey = this.layers[0].layout.get('fill-sort-key'); + const sortFeaturesByKey = !fillSortKey.isConstant(); + const bucketFeatures: BucketFeature[] = []; + + for (const {feature, id, index, sourceLayerIndex} of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue; + + const sortKey = sortFeaturesByKey ? + fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) : + undefined; + + const bucketFeature: BucketFeature = { + id, + properties: feature.properties, + type: feature.type, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + patterns: {}, + sortKey + }; + + bucketFeatures.push(bucketFeature); + } + + if (sortFeaturesByKey) { + bucketFeatures.sort((a, b) => a.sortKey - b.sortKey); + } + + for (const bucketFeature of bucketFeatures) { + const {geometry, index, sourceLayerIndex} = bucketFeature; + + if (this.hasPattern) { + const patternFeature = addPatternDependencies('fill', this.layers, bucketFeature, this.zoom, options); + // pattern features are added only once the pattern is loaded into the image atlas + // so are stored during populate until later updated with positions by tile worker in addFeatures + this.patternFeatures.push(patternFeature); + } else { + this.addFeature(bucketFeature, geometry, index, canonical, {}); + } + + const feature = features[index].feature; + options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index); + } + } + + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: { + [_: string]: ImagePosition; + }) { + if (!this.stateDependentLayers.length) return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + + addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }) { + for (const feature of this.patternFeatures) { + this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions); + } + } + + isEmpty() { + return this.layoutVertexArray.length === 0; + } + + uploadPending(): boolean { + return !this.uploaded || this.programConfigurations.needsUpload; + } + upload(context: Context) { + if (!this.uploaded) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + this.indexBuffer2 = context.createIndexBuffer(this.indexArray2); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + + destroy() { + if (!this.layoutVertexBuffer) return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.indexBuffer2.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + this.segments2.destroy(); + } + + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: { + [_: string]: ImagePosition; + }) { + for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) { + let numVertices = 0; + for (const ring of polygon) { + numVertices += ring.length; + } + + const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray); + const triangleIndex = triangleSegment.vertexLength; + + const flattened = []; + const holeIndices = []; + + for (const ring of polygon) { + if (ring.length === 0) { + continue; + } + + if (ring !== polygon[0]) { + holeIndices.push(flattened.length / 2); + } + + const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2); + const lineIndex = lineSegment.vertexLength; + + this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y); + this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex); + flattened.push(ring[0].x); + flattened.push(ring[0].y); + + for (let i = 1; i < ring.length; i++) { + this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y); + this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i); + flattened.push(ring[i].x); + flattened.push(ring[i].y); + } + + lineSegment.vertexLength += ring.length; + lineSegment.primitiveLength += ring.length; + } + + const indices = earcut(flattened, holeIndices); + + for (let i = 0; i < indices.length; i += 3) { + this.indexArray.emplaceBack( + triangleIndex + indices[i], + triangleIndex + indices[i + 1], + triangleIndex + indices[i + 2]); + } + + triangleSegment.vertexLength += numVertices; + triangleSegment.primitiveLength += indices.length / 3; + } + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical); + } +} + +register('FillBucket', FillBucket, {omit: ['layers', 'patternFeatures']}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/fill_extrusion_attributes.ts b/web/libraries/maplibre-gl/src/data/bucket/fill_extrusion_attributes.ts new file mode 100644 index 00000000..e4e2936c --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/fill_extrusion_attributes.ts @@ -0,0 +1,13 @@ +import {createLayout} from '../../util/struct_array'; + +const layout = createLayout([ + {name: 'a_pos', components: 2, type: 'Int16'}, + {name: 'a_normal_ed', components: 4, type: 'Int16'}, +], 4); + +export const centroidAttributes = createLayout([ + {name: 'a_centroid', components: 2, type: 'Int16'} +], 4); + +export default layout; +export const {members, size, alignment} = layout; diff --git a/web/libraries/maplibre-gl/src/data/bucket/fill_extrusion_bucket.ts b/web/libraries/maplibre-gl/src/data/bucket/fill_extrusion_bucket.ts new file mode 100644 index 00000000..9dc1a1b2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/fill_extrusion_bucket.ts @@ -0,0 +1,302 @@ +import {FillExtrusionLayoutArray, PosArray} from '../array_types.g'; + +import {members as layoutAttributes, centroidAttributes} from './fill_extrusion_attributes'; +import {SegmentVector} from '../segment'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray} from '../index_array_type'; +import {EXTENT} from '../extent'; +import earcut from 'earcut'; +import mvt from '@mapbox/vector-tile'; +const vectorTileFeatureTypes = mvt.VectorTileFeature.types; +import {classifyRings} from '../../util/classify_rings'; +const EARCUT_MAX_RINGS = 500; +import {register} from '../../util/web_worker_transfer'; +import {hasPattern, addPatternDependencies} from './pattern_bucket_features'; +import {loadGeometry} from '../load_geometry'; +import {toEvaluationFeature} from '../evaluation_feature'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; + +import type {CanonicalTileID} from '../../source/tile_id'; +import type { + Bucket, + BucketParameters, + BucketFeature, + IndexedFeature, + PopulateParameters +} from '../bucket'; + +import type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer'; +import type {Context} from '../../gl/context'; +import type {IndexBuffer} from '../../gl/index_buffer'; +import type {VertexBuffer} from '../../gl/vertex_buffer'; +import type Point from '@mapbox/point-geometry'; +import type {FeatureStates} from '../../source/source_state'; +import type {ImagePosition} from '../../render/image_atlas'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; + +const FACTOR = Math.pow(2, 13); + +function addVertex(vertexArray, x, y, nx, ny, nz, t, e) { + vertexArray.emplaceBack( + // a_pos + x, + y, + // a_normal_ed: 3-component normal and 1-component edgedistance + Math.floor(nx * FACTOR) * 2 + t, + ny * FACTOR * 2, + nz * FACTOR * 2, + // edgedistance (used for wrapping patterns around extrusion sides) + Math.round(e) + ); +} + +export class FillExtrusionBucket implements Bucket { + index: number; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + + layoutVertexArray: FillExtrusionLayoutArray; + layoutVertexBuffer: VertexBuffer; + + centroidVertexArray: PosArray; + centroidVertexBuffer: VertexBuffer; + + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + uploaded: boolean; + features: Array; + + constructor(options: BucketParameters) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + + this.layoutVertexArray = new FillExtrusionLayoutArray(); + this.centroidVertexArray = new PosArray(); + this.indexArray = new TriangleIndexArray(); + this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom); + this.segments = new SegmentVector(); + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + } + + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) { + this.features = []; + this.hasPattern = hasPattern('fill-extrusion', this.layers, options); + + for (const {feature, id, index, sourceLayerIndex} of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue; + + const bucketFeature: BucketFeature = { + id, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + properties: feature.properties, + type: feature.type, + patterns: {} + }; + + if (this.hasPattern) { + this.features.push(addPatternDependencies('fill-extrusion', this.layers, bucketFeature, this.zoom, options)); + } else { + this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {}); + } + + options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true); + } + } + + addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) { + for (const feature of this.features) { + const {geometry} = feature; + this.addFeature(feature, geometry, feature.index, canonical, imagePositions); + } + } + + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) { + if (!this.stateDependentLayers.length) return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + + isEmpty() { + return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0; + } + + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + + upload(context: Context) { + if (!this.uploaded) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes); + this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + + destroy() { + if (!this.layoutVertexBuffer) return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + this.centroidVertexBuffer.destroy(); + } + + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) { + const centroid = {x: 0, y: 0, vertexCount: 0}; + for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) { + let numVertices = 0; + for (const ring of polygon) { + numVertices += ring.length; + } + let segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray); + + for (const ring of polygon) { + if (ring.length === 0) { + continue; + } + + if (isEntirelyOutside(ring)) { + continue; + } + + let edgeDistance = 0; + + for (let p = 0; p < ring.length; p++) { + const p1 = ring[p]; + + if (p >= 1) { + const p2 = ring[p - 1]; + + if (!isBoundaryEdge(p1, p2)) { + if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) { + segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray); + } + + const perp = p1.sub(p2)._perp()._unit(); + const dist = p2.dist(p1); + if (edgeDistance + dist > 32768) edgeDistance = 0; + + addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance); + addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance); + centroid.x += 2 * p1.x; + centroid.y += 2 * p1.y; + centroid.vertexCount += 2; + + edgeDistance += dist; + + addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance); + addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance); + centroid.x += 2 * p2.x; + centroid.y += 2 * p2.y; + centroid.vertexCount += 2; + + const bottomRight = segment.vertexLength; + + // ┌──────┐ + // │ 0 1 │ Counter-clockwise winding order. + // │ │ Triangle 1: 0 => 2 => 1 + // │ 2 3 │ Triangle 2: 1 => 2 => 3 + // └──────┘ + this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1); + this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3); + + segment.vertexLength += 4; + segment.primitiveLength += 2; + } + } + } + + } + + if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) { + segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray); + } + + //Only triangulate and draw the area of the feature if it is a polygon + //Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined + if (vectorTileFeatureTypes[feature.type] !== 'Polygon') + continue; + + const flattened = []; + const holeIndices = []; + const triangleIndex = segment.vertexLength; + + for (const ring of polygon) { + if (ring.length === 0) { + continue; + } + + if (ring !== polygon[0]) { + holeIndices.push(flattened.length / 2); + } + + for (let i = 0; i < ring.length; i++) { + const p = ring[i]; + + addVertex(this.layoutVertexArray, p.x, p.y, 0, 0, 1, 1, 0); + centroid.x += p.x; + centroid.y += p.y; + centroid.vertexCount += 1; + + flattened.push(p.x); + flattened.push(p.y); + } + + } + + const indices = earcut(flattened, holeIndices); + + for (let j = 0; j < indices.length; j += 3) { + // Counter-clockwise winding order. + this.indexArray.emplaceBack( + triangleIndex + indices[j], + triangleIndex + indices[j + 2], + triangleIndex + indices[j + 1]); + } + + segment.primitiveLength += indices.length / 3; + segment.vertexLength += numVertices; + } + + // remember polygon centroid to calculate elevation in GPU + for (let i = 0; i < centroid.vertexCount; i++) { + this.centroidVertexArray.emplaceBack( + Math.floor(centroid.x / centroid.vertexCount), + Math.floor(centroid.y / centroid.vertexCount) + ); + } + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical); + } +} + +register('FillExtrusionBucket', FillExtrusionBucket, {omit: ['layers', 'features']}); + +function isBoundaryEdge(p1, p2) { + return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) || + (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT)); +} + +function isEntirelyOutside(ring) { + return ring.every(p => p.x < 0) || + ring.every(p => p.x > EXTENT) || + ring.every(p => p.y < 0) || + ring.every(p => p.y > EXTENT); +} diff --git a/web/libraries/maplibre-gl/src/data/bucket/heatmap_bucket.ts b/web/libraries/maplibre-gl/src/data/bucket/heatmap_bucket.ts new file mode 100644 index 00000000..792cd108 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/heatmap_bucket.ts @@ -0,0 +1,12 @@ +import {CircleBucket} from './circle_bucket'; +import {register} from '../../util/web_worker_transfer'; + +import type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer'; + +export class HeatmapBucket extends CircleBucket { + // Needed for flow to accept omit: ['layers'] below, due to + // https://github.com/facebook/flow/issues/4262 + layers: Array; +} + +register('HeatmapBucket', HeatmapBucket, {omit: ['layers']}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/line_attributes.ts b/web/libraries/maplibre-gl/src/data/bucket/line_attributes.ts new file mode 100644 index 00000000..2daca3c1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/line_attributes.ts @@ -0,0 +1,8 @@ +import {createLayout} from '../../util/struct_array'; + +export const lineLayoutAttributes = createLayout([ + {name: 'a_pos_normal', components: 2, type: 'Int16'}, + {name: 'a_data', components: 4, type: 'Uint8'} +], 4); + +export const {members, size, alignment} = lineLayoutAttributes; diff --git a/web/libraries/maplibre-gl/src/data/bucket/line_attributes_ext.ts b/web/libraries/maplibre-gl/src/data/bucket/line_attributes_ext.ts new file mode 100644 index 00000000..5fd4ec45 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/line_attributes_ext.ts @@ -0,0 +1,8 @@ +import {createLayout} from '../../util/struct_array'; + +export const lineLayoutAttributesExt = createLayout([ + {name: 'a_uv_x', components: 1, type: 'Float32'}, + {name: 'a_split_index', components: 1, type: 'Float32'}, +]); + +export const {members, size, alignment} = lineLayoutAttributesExt; diff --git a/web/libraries/maplibre-gl/src/data/bucket/line_bucket.test.ts b/web/libraries/maplibre-gl/src/data/bucket/line_bucket.test.ts new file mode 100644 index 00000000..30fa8713 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/line_bucket.test.ts @@ -0,0 +1,142 @@ +import fs from 'fs'; +import path from 'path'; +import Protobuf from 'pbf'; +import {VectorTile} from '@mapbox/vector-tile'; +import Point from '@mapbox/point-geometry'; +import {SegmentVector} from '../segment'; +import {LineBucket} from './line_bucket'; +import {LineStyleLayer} from '../../style/style_layer/line_style_layer'; +import {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; +import {BucketFeature, BucketParameters} from '../bucket'; + +// Load a line feature from fixture tile. +const vt = new VectorTile(new Protobuf(fs.readFileSync(path.resolve(__dirname, '../../../test/unit/assets/mbsv5-6-18-23.vector.pbf')))); +const feature = vt.layers.road.feature(0); + +function createLine(numPoints) { + const points = []; + for (let i = 0; i < numPoints; i++) { + points.push(new Point(i / numPoints, i / numPoints)); + } + return points; +} + +describe('LineBucket', () => { + test('LineBucket', () => { + expect(() => { + const layer = new LineStyleLayer({id: 'test', type: 'line'} as LayerSpecification); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + const bucket = new LineBucket({layers: [layer]} as BucketParameters); + + const line = { + type: 2, + properties: {} + } as BucketFeature; + + const polygon = { + type: 3, + properties: {} + } as BucketFeature; + + bucket.addLine([ + new Point(0, 0) + ], line, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0) + ], polygon, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(0, 0) + ], line, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(0, 0) + ], polygon, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(10, 10), + new Point(0, 0) + ], line, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(10, 10), + new Point(0, 0) + ], polygon, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(10, 10), + new Point(10, 20) + ], line, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(10, 10), + new Point(10, 20) + ], polygon, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(10, 10), + new Point(10, 20), + new Point(0, 0) + ], line, undefined, undefined, undefined, undefined); + + bucket.addLine([ + new Point(0, 0), + new Point(10, 10), + new Point(10, 20), + new Point(0, 0) + ], polygon, undefined, undefined, undefined, undefined); + + bucket.addFeature(feature as any, feature.loadGeometry(), undefined, undefined, undefined); + }).not.toThrow(); + }); + + test('LineBucket segmentation', () => { + jest.spyOn(console, 'warn').mockImplementation(() => { }); + + // Stub MAX_VERTEX_ARRAY_LENGTH so we can test features + // breaking across array groups without tests taking a _long_ time. + SegmentVector.MAX_VERTEX_ARRAY_LENGTH = 256; + + const layer = new LineStyleLayer({id: 'test', type: 'line'} as LayerSpecification); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + const bucket = new LineBucket({layers: [layer]} as BucketParameters); + + // first add an initial, small feature to make sure the next one starts at + // a non-zero offset + bucket.addFeature({} as BucketFeature, [createLine(10)], undefined, undefined, undefined); + + // add a feature that will break across the group boundary + bucket.addFeature({} as BucketFeature, [createLine(128)], undefined, undefined, undefined); + + // Each polygon must fit entirely within a segment, so we expect the + // first segment to include the first feature and the first polygon + // of the second feature, and the second segment to include the + // second polygon of the second feature. + expect(bucket.layoutVertexArray).toHaveLength(276); + expect(bucket.segments.get()).toEqual([{ + vertexOffset: 0, + vertexLength: 20, + primitiveOffset: 0, + primitiveLength: 18 + }, { + vertexOffset: 20, + vertexLength: 256, + primitiveOffset: 18, + primitiveLength: 254 + }]); + + expect(console.warn).toHaveBeenCalledTimes(1); + + }); +}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/line_bucket.ts b/web/libraries/maplibre-gl/src/data/bucket/line_bucket.ts new file mode 100644 index 00000000..ea816f88 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/line_bucket.ts @@ -0,0 +1,592 @@ +import {LineLayoutArray, LineExtLayoutArray} from '../array_types.g'; + +import {members as layoutAttributes} from './line_attributes'; +import {members as layoutAttributesExt} from './line_attributes_ext'; +import {SegmentVector} from '../segment'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray} from '../index_array_type'; +import {EXTENT} from '../extent'; +import mvt from '@mapbox/vector-tile'; +const vectorTileFeatureTypes = mvt.VectorTileFeature.types; +import {register} from '../../util/web_worker_transfer'; +import {hasPattern, addPatternDependencies} from './pattern_bucket_features'; +import {loadGeometry} from '../load_geometry'; +import {toEvaluationFeature} from '../evaluation_feature'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; + +import type {CanonicalTileID} from '../../source/tile_id'; +import type { + Bucket, + BucketParameters, + BucketFeature, + IndexedFeature, + PopulateParameters +} from '../bucket'; +import type {LineStyleLayer} from '../../style/style_layer/line_style_layer'; +import type Point from '@mapbox/point-geometry'; +import type {Segment} from '../segment'; +import {RGBAImage} from '../../util/image'; +import type {Context} from '../../gl/context'; +import type {Texture} from '../../render/texture'; +import type {IndexBuffer} from '../../gl/index_buffer'; +import type {VertexBuffer} from '../../gl/vertex_buffer'; +import type {FeatureStates} from '../../source/source_state'; +import type {ImagePosition} from '../../render/image_atlas'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; + +// NOTE ON EXTRUDE SCALE: +// scale the extrusion vector so that the normal length is this value. +// contains the "texture" normals (-1..1). this is distinct from the extrude +// normals for line joins, because the x-value remains 0 for the texture +// normal array, while the extrude normal actually moves the vertex to create +// the acute/bevelled line join. +const EXTRUDE_SCALE = 63; + +/* + * Sharp corners cause dashed lines to tilt because the distance along the line + * is the same at both the inner and outer corners. To improve the appearance of + * dashed lines we add extra points near sharp corners so that a smaller part + * of the line is tilted. + * + * COS_HALF_SHARP_CORNER controls how sharp a corner has to be for us to add an + * extra vertex. The default is 75 degrees. + * + * The newly created vertices are placed SHARP_CORNER_OFFSET pixels from the corner. + */ +const COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180)); +const SHARP_CORNER_OFFSET = 15; + +// Angle per triangle for approximating round line joins. +const DEG_PER_TRIANGLE = 20; + +// The number of bits that is used to store the line distance in the buffer. +const LINE_DISTANCE_BUFFER_BITS = 15; + +// We don't have enough bits for the line distance as we'd like to have, so +// use this value to scale the line distance (in tile units) down to a smaller +// value. This lets us store longer distances while sacrificing precision. +const LINE_DISTANCE_SCALE = 1 / 2; + +// The maximum line distance, in tile units, that fits in the buffer. +const MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE; + +type LineClips = { + start: number; + end: number; +}; + +type GradientTexture = { + texture?: Texture; + gradient?: RGBAImage; + version?: number; +}; + +/** + * @internal + * Line bucket class + */ +export class LineBucket implements Bucket { + distance: number; + totalDistance: number; + maxLineLength: number; + scaledDistance: number; + lineClips?: LineClips; + + e1: number; + e2: number; + + index: number; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + gradients: {[x: string]: GradientTexture}; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + patternFeatures: Array; + lineClipsArray: Array; + + layoutVertexArray: LineLayoutArray; + layoutVertexBuffer: VertexBuffer; + layoutVertexArray2: LineExtLayoutArray; + layoutVertexBuffer2: VertexBuffer; + + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + + hasPattern: boolean; + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + uploaded: boolean; + + constructor(options: BucketParameters) { + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.hasPattern = false; + this.patternFeatures = []; + this.lineClipsArray = []; + this.gradients = {}; + this.layers.forEach(layer => { + this.gradients[layer.id] = {}; + }); + + this.layoutVertexArray = new LineLayoutArray(); + this.layoutVertexArray2 = new LineExtLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom); + this.segments = new SegmentVector(); + this.maxLineLength = 0; + + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + } + + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) { + this.hasPattern = hasPattern('line', this.layers, options); + const lineSortKey = this.layers[0].layout.get('line-sort-key'); + const sortFeaturesByKey = !lineSortKey.isConstant(); + const bucketFeatures: BucketFeature[] = []; + + for (const {feature, id, index, sourceLayerIndex} of features) { + const needGeometry = this.layers[0]._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + + if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue; + + const sortKey = sortFeaturesByKey ? + lineSortKey.evaluate(evaluationFeature, {}, canonical) : + undefined; + + const bucketFeature: BucketFeature = { + id, + properties: feature.properties, + type: feature.type, + sourceLayerIndex, + index, + geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature), + patterns: {}, + sortKey + }; + + bucketFeatures.push(bucketFeature); + } + + if (sortFeaturesByKey) { + bucketFeatures.sort((a, b) => { + return (a.sortKey) - (b.sortKey); + }); + } + + for (const bucketFeature of bucketFeatures) { + const {geometry, index, sourceLayerIndex} = bucketFeature; + + if (this.hasPattern) { + const patternBucketFeature = addPatternDependencies('line', this.layers, bucketFeature, this.zoom, options); + // pattern features are added only once the pattern is loaded into the image atlas + // so are stored during populate until later updated with positions by tile worker in addFeatures + this.patternFeatures.push(patternBucketFeature); + } else { + this.addFeature(bucketFeature, geometry, index, canonical, {}); + } + + const feature = features[index].feature; + options.featureIndex.insert(feature, geometry, index, sourceLayerIndex, this.index); + } + } + + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) { + if (!this.stateDependentLayers.length) return; + this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions); + } + + addFeatures(options: PopulateParameters, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) { + for (const feature of this.patternFeatures) { + this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions); + } + } + + isEmpty() { + return this.layoutVertexArray.length === 0; + } + + uploadPending() { + return !this.uploaded || this.programConfigurations.needsUpload; + } + + upload(context: Context) { + if (!this.uploaded) { + if (this.layoutVertexArray2.length !== 0) { + this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, layoutAttributesExt); + } + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, layoutAttributes); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + } + this.programConfigurations.upload(context); + this.uploaded = true; + } + + destroy() { + if (!this.layoutVertexBuffer) return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + } + + 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']; + return {start, end}; + } + } + + addFeature(feature: BucketFeature, geometry: Array>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) { + const layout = this.layers[0].layout; + const join = layout.get('line-join').evaluate(feature, {}); + const cap = layout.get('line-cap'); + const miterLimit = layout.get('line-miter-limit'); + const roundLimit = layout.get('line-round-limit'); + this.lineClips = this.lineFeatureClips(feature); + + for (const line of geometry) { + this.addLine(line, feature, join, cap, miterLimit, roundLimit); + } + + this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical); + } + + addLine(vertices: Array, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number) { + this.distance = 0; + this.scaledDistance = 0; + this.totalDistance = 0; + + if (this.lineClips) { + this.lineClipsArray.push(this.lineClips); + // Calculate the total distance, in tile units, of this tiled line feature + for (let i = 0; i < vertices.length - 1; i++) { + this.totalDistance += vertices[i].dist(vertices[i + 1]); + } + this.updateScaledDistance(); + this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance); + } + + const isPolygon = vectorTileFeatureTypes[feature.type] === 'Polygon'; + + // If the line has duplicate vertices at the ends, adjust start/length to remove them. + let len = vertices.length; + while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) { + len--; + } + let first = 0; + while (first < len - 1 && vertices[first].equals(vertices[first + 1])) { + first++; + } + + // Ignore invalid geometry. + if (len < (isPolygon ? 3 : 2)) return; + + if (join === 'bevel') miterLimit = 1.05; + + const sharpCornerOffset = this.overscaling <= 16 ? + SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) : + 0; + + // we could be more precise, but it would only save a negligible amount of space + const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray); + + let currentVertex: Point; + let prevVertex: Point; + let nextVertex: Point; + let prevNormal: Point; + let nextNormal: Point; + + // the last two vertices added + this.e1 = this.e2 = -1; + + if (isPolygon) { + currentVertex = vertices[len - 2]; + nextNormal = vertices[first].sub(currentVertex)._unit()._perp(); + } + + for (let i = first; i < len; i++) { + + nextVertex = i === len - 1 ? + (isPolygon ? vertices[first + 1] : undefined) : // if it's a polygon, treat the last vertex like the first + vertices[i + 1]; // just the next vertex + + // if two consecutive vertices exist, skip the current one + if (nextVertex && vertices[i].equals(nextVertex)) continue; + + if (nextNormal) prevNormal = nextNormal; + if (currentVertex) prevVertex = currentVertex; + + currentVertex = vertices[i]; + + // Calculate the normal towards the next vertex in this line. In case + // there is no next vertex, pretend that the line is continuing straight, + // meaning that we are just using the previous normal. + nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal; + + // If we still don't have a previous normal, this is the beginning of a + // non-closed line, so we're doing a straight "join". + prevNormal = prevNormal || nextNormal; + + // Determine the normal of the join extrusion. It is the angle bisector + // of the segments between the previous line and the next line. + // In the case of 180° angles, the prev and next normals cancel each other out: + // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be + // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle + // below will also become 0 and miterLength will become Infinity. + let joinNormal = prevNormal.add(nextNormal); + if (joinNormal.x !== 0 || joinNormal.y !== 0) { + joinNormal._unit(); + } + /* joinNormal prevNormal + * ↖ ↑ + * .________. prevVertex + * | + * nextNormal ← | currentVertex + * | + * nextVertex ! + * + */ + + // calculate cosines of the angle (and its half) using dot product + const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y; + const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y; + + // Calculate the length of the miter (the ratio of the miter to the width) + // as the inverse of cosine of the angle between next and join normals + const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity; + + // approximate angle from cosine + const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle); + + const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex; + const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0; + + if (isSharpCorner && i > first) { + const prevSegmentLength = currentVertex.dist(prevVertex); + if (prevSegmentLength > 2 * sharpCornerOffset) { + const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round()); + this.updateDistance(prevVertex, newPrevVertex); + this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment); + prevVertex = newPrevVertex; + } + } + + // The join if a middle vertex, otherwise the cap. + const middleVertex = prevVertex && nextVertex; + let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap; + + if (middleVertex && currentJoin === 'round') { + if (miterLength < roundLimit) { + currentJoin = 'miter'; + } else if (miterLength <= 2) { + currentJoin = 'fakeround'; + } + } + + if (currentJoin === 'miter' && miterLength > miterLimit) { + currentJoin = 'bevel'; + } + + if (currentJoin === 'bevel') { + // The maximum extrude length is 128 / 63 = 2 times the width of the line + // so if miterLength >= 2 we need to draw a different type of bevel here. + if (miterLength > 2) currentJoin = 'flipbevel'; + + // If the miterLength is really small and the line bevel wouldn't be visible, + // just draw a miter join to save a triangle. + if (miterLength < miterLimit) currentJoin = 'miter'; + } + + // Calculate how far along the line the currentVertex is + if (prevVertex) this.updateDistance(prevVertex, currentVertex); + + if (currentJoin === 'miter') { + + joinNormal._mult(miterLength); + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + + } else if (currentJoin === 'flipbevel') { + // miter is too big, flip the direction to make a beveled join + + if (miterLength > 100) { + // Almost parallel lines + joinNormal = nextNormal.mult(-1); + + } else { + const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag(); + joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1)); + } + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment); + + } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') { + const offset = -Math.sqrt(miterLength * miterLength - 1); + const offsetA = lineTurnsLeft ? offset : 0; + const offsetB = lineTurnsLeft ? 0 : offset; + + // Close previous segment with a bevel + if (prevVertex) { + this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment); + } + + if (currentJoin === 'fakeround') { + // The join angle is sharp enough that a round join would be visible. + // Bevel joins fill the gap between segments with a single pie slice triangle. + // Create a round join by adding multiple pie slices. The join isn't actually round, but + // it looks like it is at the sizes we render lines at. + + // pick the number of triangles for approximating round join by based on the angle between normals + const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE); + + for (let m = 1; m < n; m++) { + let t = m / n; + if (t !== 0.5) { + // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp + const t2 = t - 0.5; + const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519)); + const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638); + t = t + t * t2 * (t - 1) * (A * t2 * t2 + B); + } + const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1); + this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment); + } + } + + if (nextVertex) { + // Start next segment + this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment); + } + + } else if (currentJoin === 'butt') { + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap + + } else if (currentJoin === 'square') { + const offset = prevVertex ? 1 : -1; // closing or starting square cap + this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment); + + } else if (currentJoin === 'round') { + + if (prevVertex) { + // Close previous segment with butt + this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment); + + // Add round cap or linejoin at end of segment + this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true); + } + if (nextVertex) { + // Add round cap before first segment + this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true); + + // Start next segment with a butt + this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment); + } + } + + if (isSharpCorner && i < len - 1) { + const nextSegmentLength = currentVertex.dist(nextVertex); + if (nextSegmentLength > 2 * sharpCornerOffset) { + const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round()); + this.updateDistance(currentVertex, newCurrentVertex); + this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment); + currentVertex = newCurrentVertex; + } + } + } + } + + /** + * Add two vertices to the buffers. + * + * @param p - the line vertex to add buffer vertices for + * @param normal - vertex normal + * @param endLeft - extrude to shift the left vertex along the line + * @param endRight - extrude to shift the left vertex along the line + * @param segment - the segment object to add the vertex to + * @param round - whether this is a round cap + */ + addCurrentVertex(p: Point, normal: Point, endLeft: number, endRight: number, segment: Segment, round: boolean = false) { + // left and right extrude vectors, perpendicularly shifted by endLeft/endRight + const leftX = normal.x + normal.y * endLeft; + const leftY = normal.y - normal.x * endLeft; + const rightX = -normal.x + normal.y * endRight; + const rightY = -normal.y - normal.x * endRight; + + this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment); + this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment); + + // There is a maximum "distance along the line" that we can store in the buffers. + // When we get close to the distance, reset it to zero and add the vertex again with + // a distance of zero. The max distance is determined by the number of bits we allocate + // to `linesofar`. + if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) { + this.distance = 0; + this.updateScaledDistance(); + this.addCurrentVertex(p, normal, endLeft, endRight, segment, round); + } + } + + addHalfVertex({x, y}: Point, extrudeX: number, extrudeY: number, round: boolean, up: boolean, dir: number, segment: Segment) { + const totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance; + // scale down so that we can store longer distances while sacrificing precision. + const linesofarScaled = totalDistance * LINE_DISTANCE_SCALE; + + this.layoutVertexArray.emplaceBack( + // a_pos_normal + // Encode round/up the least significant bits + (x << 1) + (round ? 1 : 0), + (y << 1) + (up ? 1 : 0), + // a_data + // add 128 to store a byte in an unsigned byte + Math.round(EXTRUDE_SCALE * extrudeX) + 128, + Math.round(EXTRUDE_SCALE * extrudeY) + 128, + // Encode the -1/0/1 direction value into the first two bits of .z of a_data. + // Combine it with the lower 6 bits of `linesofarScaled` (shifted by 2 bits to make + // room for the direction value). The upper 8 bits of `linesofarScaled` are placed in + // the `w` component. + ((dir === 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofarScaled & 0x3F) << 2), + linesofarScaled >> 6); + + // Constructs a second vertex buffer with higher precision line progress + if (this.lineClips) { + const progressRealigned = this.scaledDistance - this.lineClips.start; + const endClipRealigned = this.lineClips.end - this.lineClips.start; + const uvX = progressRealigned / endClipRealigned; + this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length); + } + + const e = segment.vertexLength++; + if (this.e1 >= 0 && this.e2 >= 0) { + this.indexArray.emplaceBack(this.e1, this.e2, e); + segment.primitiveLength++; + } + if (up) { + this.e2 = e; + } else { + this.e1 = e; + } + } + + updateScaledDistance() { + // Knowing the ratio of the full linestring covered by this tiled feature, as well + // as the total distance (in tile units) of this tiled feature, and the distance + // (in tile units) of the current vertex, we can determine the relative distance + // of this vertex along the full linestring feature and scale it to [0, 2^15) + this.scaledDistance = this.lineClips ? + this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance : + this.distance; + } + + updateDistance(prev: Point, next: Point) { + this.distance += prev.dist(next); + this.updateScaledDistance(); + } +} + +register('LineBucket', LineBucket, {omit: ['layers', 'patternFeatures']}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/pattern_attributes.ts b/web/libraries/maplibre-gl/src/data/bucket/pattern_attributes.ts new file mode 100644 index 00000000..f308f9ba --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/pattern_attributes.ts @@ -0,0 +1,9 @@ +import {createLayout} from '../../util/struct_array'; + +export const patternAttributes = createLayout([ + // [tl.x, tl.y, br.x, br.y] + {name: 'a_pattern_from', components: 4, type: 'Uint16'}, + {name: 'a_pattern_to', components: 4, type: 'Uint16'}, + {name: 'a_pixel_ratio_from', components: 1, type: 'Uint16'}, + {name: 'a_pixel_ratio_to', components: 1, type: 'Uint16'}, +]); diff --git a/web/libraries/maplibre-gl/src/data/bucket/pattern_bucket_features.ts b/web/libraries/maplibre-gl/src/data/bucket/pattern_bucket_features.ts new file mode 100644 index 00000000..11693daa --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/pattern_bucket_features.ts @@ -0,0 +1,57 @@ +import type {FillStyleLayer} from '../../style/style_layer/fill_style_layer'; +import type {FillExtrusionStyleLayer} from '../../style/style_layer/fill_extrusion_style_layer'; +import type {LineStyleLayer} from '../../style/style_layer/line_style_layer'; + +import type { + BucketFeature, + PopulateParameters +} from '../bucket'; +import {PossiblyEvaluated} from '../../style/properties'; + +type PatternStyleLayers = Array | Array | Array; + +export function hasPattern(type: string, layers: PatternStyleLayers, options: PopulateParameters) { + const patterns = options.patternDependencies; + let hasPattern = false; + + for (const layer of layers) { + const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`); + if (!patternProperty.isConstant()) { + hasPattern = true; + } + + const constantPattern = patternProperty.constantOr(null); + if (constantPattern) { + hasPattern = true; + patterns[constantPattern.to] = true; + patterns[constantPattern.from] = true; + } + } + + return hasPattern; +} + +export function addPatternDependencies(type: string, layers: PatternStyleLayers, patternFeature: BucketFeature, zoom: number, options: PopulateParameters) { + const patterns = options.patternDependencies; + for (const layer of layers) { + const patternProperty = (layer.paint as PossiblyEvaluated).get(`${type}-pattern`); + + const patternPropertyValue = patternProperty.value; + if (patternPropertyValue.kind !== 'constant') { + let min = patternPropertyValue.evaluate({zoom: zoom - 1}, patternFeature, {}, options.availableImages); + let mid = patternPropertyValue.evaluate({zoom}, patternFeature, {}, options.availableImages); + let max = patternPropertyValue.evaluate({zoom: zoom + 1}, patternFeature, {}, options.availableImages); + min = min && min.name ? min.name : min; + mid = mid && mid.name ? mid.name : mid; + max = max && max.name ? max.name : max; + // add to patternDependencies + patterns[min] = true; + patterns[mid] = true; + patterns[max] = true; + + // save for layout + patternFeature.patterns[layer.id] = {min, mid, max}; + } + } + return patternFeature; +} diff --git a/web/libraries/maplibre-gl/src/data/bucket/symbol_attributes.ts b/web/libraries/maplibre-gl/src/data/bucket/symbol_attributes.ts new file mode 100644 index 00000000..5b7a53cb --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/symbol_attributes.ts @@ -0,0 +1,121 @@ +import {createLayout} from '../../util/struct_array'; + +export const symbolLayoutAttributes = createLayout([ + {name: 'a_pos_offset', components: 4, type: 'Int16'}, + {name: 'a_data', components: 4, type: 'Uint16'}, + {name: 'a_pixeloffset', components: 4, type: 'Int16'} +], 4); + +export const dynamicLayoutAttributes = createLayout([ + {name: 'a_projected_pos', components: 3, type: 'Float32'} +], 4); + +export const placementOpacityAttributes = createLayout([ + {name: 'a_fade_opacity', components: 1, type: 'Uint32'} +], 4); + +export const collisionVertexAttributes = createLayout([ + {name: 'a_placed', components: 2, type: 'Uint8'}, + {name: 'a_shift', components: 2, type: 'Float32'} +]); + +export const collisionBox = createLayout([ + // the box is centered around the anchor point + {type: 'Int16', name: 'anchorPointX'}, + {type: 'Int16', name: 'anchorPointY'}, + + // distances to the edges from the anchor + {type: 'Int16', name: 'x1'}, + {type: 'Int16', name: 'y1'}, + {type: 'Int16', name: 'x2'}, + {type: 'Int16', name: 'y2'}, + + // the index of the feature in the original vectortile + {type: 'Uint32', name: 'featureIndex'}, + // the source layer the feature appears in + {type: 'Uint16', name: 'sourceLayerIndex'}, + // the bucket the feature appears in + {type: 'Uint16', name: 'bucketIndex'}, +]); + +export const collisionBoxLayout = createLayout([ // used to render collision boxes for debugging purposes + {name: 'a_pos', components: 2, type: 'Int16'}, + {name: 'a_anchor_pos', components: 2, type: 'Int16'}, + {name: 'a_extrude', components: 2, type: 'Int16'} +], 4); + +export const collisionCircleLayout = createLayout([ // used to render collision circles for debugging purposes + {name: 'a_pos', components: 2, type: 'Float32'}, + {name: 'a_radius', components: 1, type: 'Float32'}, + {name: 'a_flags', components: 2, type: 'Int16'} +], 4); + +export const quadTriangle = createLayout([ + {name: 'triangle', components: 3, type: 'Uint16'}, +]); + +export const placement = createLayout([ + {type: 'Int16', name: 'anchorX'}, + {type: 'Int16', name: 'anchorY'}, + {type: 'Uint16', name: 'glyphStartIndex'}, + {type: 'Uint16', name: 'numGlyphs'}, + {type: 'Uint32', name: 'vertexStartIndex'}, + {type: 'Uint32', name: 'lineStartIndex'}, + {type: 'Uint32', name: 'lineLength'}, + {type: 'Uint16', name: 'segment'}, + {type: 'Uint16', name: 'lowerSize'}, + {type: 'Uint16', name: 'upperSize'}, + {type: 'Float32', name: 'lineOffsetX'}, + {type: 'Float32', name: 'lineOffsetY'}, + {type: 'Uint8', name: 'writingMode'}, + {type: 'Uint8', name: 'placedOrientation'}, + {type: 'Uint8', name: 'hidden'}, + {type: 'Uint32', name: 'crossTileID'}, + {type: 'Int16', name: 'associatedIconIndex'} +]); + +export const symbolInstance = createLayout([ + {type: 'Int16', name: 'anchorX'}, + {type: 'Int16', name: 'anchorY'}, + {type: 'Int16', name: 'rightJustifiedTextSymbolIndex'}, + {type: 'Int16', name: 'centerJustifiedTextSymbolIndex'}, + {type: 'Int16', name: 'leftJustifiedTextSymbolIndex'}, + {type: 'Int16', name: 'verticalPlacedTextSymbolIndex'}, + {type: 'Int16', name: 'placedIconSymbolIndex'}, + {type: 'Int16', name: 'verticalPlacedIconSymbolIndex'}, + {type: 'Uint16', name: 'key'}, + {type: 'Uint16', name: 'textBoxStartIndex'}, + {type: 'Uint16', name: 'textBoxEndIndex'}, + {type: 'Uint16', name: 'verticalTextBoxStartIndex'}, + {type: 'Uint16', name: 'verticalTextBoxEndIndex'}, + {type: 'Uint16', name: 'iconBoxStartIndex'}, + {type: 'Uint16', name: 'iconBoxEndIndex'}, + {type: 'Uint16', name: 'verticalIconBoxStartIndex'}, + {type: 'Uint16', name: 'verticalIconBoxEndIndex'}, + {type: 'Uint16', name: 'featureIndex'}, + {type: 'Uint16', name: 'numHorizontalGlyphVertices'}, + {type: 'Uint16', name: 'numVerticalGlyphVertices'}, + {type: 'Uint16', name: 'numIconVertices'}, + {type: 'Uint16', name: 'numVerticalIconVertices'}, + {type: 'Uint16', name: 'useRuntimeCollisionCircles'}, + {type: 'Uint32', name: 'crossTileID'}, + {type: 'Float32', name: 'textBoxScale'}, + {type: 'Float32', name: 'collisionCircleDiameter'}, + {type: 'Uint16', name: 'textAnchorOffsetStartIndex'}, + {type: 'Uint16', name: 'textAnchorOffsetEndIndex'} +]); + +export const glyphOffset = createLayout([ + {type: 'Float32', name: 'offsetX'} +]); + +export const lineVertex = createLayout([ + {type: 'Int16', name: 'x'}, + {type: 'Int16', name: 'y'}, + {type: 'Int16', name: 'tileUnitDistanceFromAnchor'} +]); + +export const textAnchorOffset = createLayout([ + {type: 'Uint16', name: 'textAnchor'}, + {type: 'Float32', components: 2, name: 'textOffset'} +]); diff --git a/web/libraries/maplibre-gl/src/data/bucket/symbol_bucket.test.ts b/web/libraries/maplibre-gl/src/data/bucket/symbol_bucket.test.ts new file mode 100644 index 00000000..f94336a5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/symbol_bucket.test.ts @@ -0,0 +1,242 @@ +import fs from 'fs'; +import path from 'path'; +import Protobuf from 'pbf'; +import {VectorTile} from '@mapbox/vector-tile'; +import {SymbolBucket} from './symbol_bucket'; +import {CollisionBoxArray} from '../../data/array_types.g'; +import {performSymbolLayout} from '../../symbol/symbol_layout'; +import {Placement} from '../../symbol/placement'; +import {Transform} from '../../geo/transform'; +import {CanonicalTileID, OverscaledTileID} from '../../source/tile_id'; +import {Tile} from '../../source/tile'; +import {CrossTileSymbolIndex} from '../../symbol/cross_tile_symbol_index'; +import {FeatureIndex} from '../../data/feature_index'; +import {createSymbolBucket, createSymbolIconBucket} from '../../../test/unit/lib/create_symbol_layer'; +import {RGBAImage} from '../../util/image'; +import {ImagePosition} from '../../render/image_atlas'; +import {IndexedFeature, PopulateParameters} from '../bucket'; +import {StyleImage} from '../../style/style_image'; +import glyphs from '../../../test/unit/assets/fontstack-glyphs.json' assert {type: 'json'}; +import {StyleGlyph} from '../../style/style_glyph'; + +// Load a point feature from fixture tile. +const vt = new VectorTile(new Protobuf(fs.readFileSync(path.resolve(__dirname, '../../../test/unit/assets/mbsv5-6-18-23.vector.pbf')))); +const feature = vt.layers.place_label.feature(10); + +/*eslint new-cap: 0*/ +const collisionBoxArray = new CollisionBoxArray(); +const transform = new Transform(); +transform.width = 100; +transform.height = 100; +transform.cameraToCenterDistance = 100; + +const stacks = {'Test': glyphs} as any as { + [_: string]: { + [x: number]: StyleGlyph; + }; +}; + +function bucketSetup(text = 'abcde') { + return createSymbolBucket('test', 'Test', text, collisionBoxArray); +} + +function createIndexedFeature(id, index, iconId) { + return { + feature: { + extent: 8192, + type: 1, + id, + properties: { + icon: iconId + }, + loadGeometry () { + return [[{x: 0, y: 0}]]; + } + }, + id, + index, + sourceLayerIndex: 0 + }; +} + +describe('SymbolBucket', () => { + test('SymbolBucket', () => { + const bucketA = bucketSetup() as any as SymbolBucket; + const bucketB = bucketSetup() as any as SymbolBucket; + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + const placement = new Placement(transform, undefined as any, 0, true); + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const crossTileSymbolIndex = new CrossTileSymbolIndex(); + + // add feature from bucket A + bucketA.populate([{feature} as IndexedFeature], options, undefined as any); + performSymbolLayout( + { + bucket: bucketA, + glyphMap: stacks, + glyphPositions: {} + } as any); + const tileA = new Tile(tileID, 512); + tileA.latestFeatureIndex = new FeatureIndex(tileID); + tileA.buckets = {test: bucketA}; + tileA.collisionBoxArray = collisionBoxArray; + + // add same feature from bucket B + bucketB.populate([{feature} as IndexedFeature], options, undefined as any); + performSymbolLayout({ + bucket: bucketB, glyphMap: stacks, glyphPositions: {} + } as any); + const tileB = new Tile(tileID, 512); + tileB.buckets = {test: bucketB}; + tileB.collisionBoxArray = collisionBoxArray; + + crossTileSymbolIndex.addLayer(bucketA.layers[0], [tileA, tileB], undefined as any); + + const place = (layer, tile) => { + const parts = []; + placement.getBucketParts(parts, layer, tile, false); + for (const part of parts) { + placement.placeLayerBucketPart(part, {}, false); + } + }; + const a = placement.collisionIndex.grid.keysLength(); + place(bucketA.layers[0], tileA); + const b = placement.collisionIndex.grid.keysLength(); + expect(a).not.toBe(b); + + const a2 = placement.collisionIndex.grid.keysLength(); + place(bucketB.layers[0], tileB); + const b2 = placement.collisionIndex.grid.keysLength(); + expect(b2).toBe(a2); + }); + + test('SymbolBucket integer overflow', () => { + const spy = jest.spyOn(console, 'warn').mockImplementation(() => { }); + SymbolBucket.MAX_GLYPHS = 5; + + const bucket = bucketSetup() as any as SymbolBucket; + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + + bucket.populate([{feature} as IndexedFeature], options, undefined as any); + const fakeGlyph = {rect: {w: 10, h: 10}, metrics: {left: 10, top: 10, advance: 10}}; + performSymbolLayout({ + bucket, + glyphMap: stacks, + glyphPositions: {'Test': {97: fakeGlyph, 98: fakeGlyph, 99: fakeGlyph, 100: fakeGlyph, 101: fakeGlyph, 102: fakeGlyph} as any} + } as any); + + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0].includes('Too many glyphs being rendered in a tile.')).toBeTruthy(); + }); + + test('SymbolBucket image undefined sdf', () => { + const spy = jest.spyOn(console, 'warn').mockImplementation(() => { }); + spy.mockReset(); + + const imageMap = { + a: { + data: new RGBAImage({width: 0, height: 0}) + }, + b: { + data: new RGBAImage({width: 0, height: 0}), + sdf: false + } + } as any as { [_: string]: StyleImage }; + const imagePos = { + a: new ImagePosition({x: 0, y: 0, w: 10, h: 10}, 1 as any as StyleImage), + b: new ImagePosition({x: 10, y: 0, w: 10, h: 10}, 1 as any as StyleImage) + }; + const bucket = createSymbolIconBucket('test', 'icon', collisionBoxArray) as any as SymbolBucket; + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + + bucket.populate( + [ + createIndexedFeature(0, 0, 'a'), + createIndexedFeature(1, 1, 'b'), + createIndexedFeature(2, 2, 'a') + ] as any as IndexedFeature[], + options, undefined as any + ); + + const icons = options.iconDependencies as any; + expect(icons.a).toBe(true); + expect(icons.b).toBe(true); + + performSymbolLayout({ + bucket, imageMap, imagePositions: imagePos + } as any); + + // undefined SDF should be treated the same as false SDF - no warning raised + expect(spy).not.toHaveBeenCalledTimes(1); + }); + + test('SymbolBucket image mismatched sdf', () => { + const spy = jest.spyOn(console, 'warn').mockImplementation(() => { }); + spy.mockReset(); + + const imageMap = { + a: { + data: new RGBAImage({width: 0, height: 0}), + sdf: true + }, + b: { + data: new RGBAImage({width: 0, height: 0}), + sdf: false + } + } as any as { [_: string]: StyleImage }; + const imagePos = { + a: new ImagePosition({x: 0, y: 0, w: 10, h: 10}, 1 as any as StyleImage), + b: new ImagePosition({x: 10, y: 0, w: 10, h: 10}, 1 as any as StyleImage) + }; + const bucket = createSymbolIconBucket('test', 'icon', collisionBoxArray) as any as SymbolBucket; + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + + bucket.populate( + [ + createIndexedFeature(0, 0, 'a'), + createIndexedFeature(1, 1, 'b'), + createIndexedFeature(2, 2, 'a') + ] as any as IndexedFeature[], + options, undefined as unknown as CanonicalTileID + ); + + const icons = options.iconDependencies as any; + expect(icons.a).toBe(true); + expect(icons.b).toBe(true); + + performSymbolLayout({bucket, imageMap, imagePositions: imagePos} as any); + + // true SDF and false SDF in same bucket should trigger warning + expect(spy).toHaveBeenCalledTimes(1); + }); + + test('SymbolBucket detects rtl text', () => { + const rtlBucket = bucketSetup('مرحبا'); + const ltrBucket = bucketSetup('hello'); + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + rtlBucket.populate([{feature} as IndexedFeature], options, undefined as any); + ltrBucket.populate([{feature} as IndexedFeature], options, undefined as any); + + expect(rtlBucket.hasRTLText).toBeTruthy(); + expect(ltrBucket.hasRTLText).toBeFalsy(); + }); + + // Test to prevent symbol bucket with rtl from text being culled by worker serialization. + test('SymbolBucket with rtl text is NOT empty even though no symbol instances are created', () => { + const rtlBucket = bucketSetup('مرحبا'); + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + rtlBucket.createArrays(); + rtlBucket.populate([{feature} as IndexedFeature], options, undefined as any); + + expect(rtlBucket.isEmpty()).toBeFalsy(); + expect(rtlBucket.symbolInstances).toHaveLength(0); + }); + + test('SymbolBucket detects rtl text mixed with ltr text', () => { + const mixedBucket = bucketSetup('مرحبا translates to hello'); + const options = {iconDependencies: {}, glyphDependencies: {}} as PopulateParameters; + mixedBucket.populate([{feature} as IndexedFeature], options, undefined as any); + + expect(mixedBucket.hasRTLText).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/data/bucket/symbol_bucket.ts b/web/libraries/maplibre-gl/src/data/bucket/symbol_bucket.ts new file mode 100644 index 00000000..d6a9ff0e --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/bucket/symbol_bucket.ts @@ -0,0 +1,969 @@ +import { + symbolLayoutAttributes, + collisionVertexAttributes, + collisionBoxLayout, + dynamicLayoutAttributes, +} from './symbol_attributes'; + +import {SymbolLayoutArray, + SymbolDynamicLayoutArray, + SymbolOpacityArray, + CollisionBoxLayoutArray, + CollisionVertexArray, + PlacedSymbolArray, + SymbolInstanceArray, + GlyphOffsetArray, + SymbolLineVertexArray, + TextAnchorOffsetArray +} from '../array_types.g'; + +import Point from '@mapbox/point-geometry'; +import {SegmentVector} from '../segment'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray, LineIndexArray} from '../index_array_type'; +import {transformText} from '../../symbol/transform_text'; +import {mergeLines} from '../../symbol/merge_lines'; +import {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection'; +import {WritingMode} from '../../symbol/shaping'; +import {loadGeometry} from '../load_geometry'; +import {toEvaluationFeature} from '../evaluation_feature'; +import mvt from '@mapbox/vector-tile'; +const vectorTileFeatureTypes = mvt.VectorTileFeature.types; +import {verticalizedCharacterMap} from '../../util/verticalize_punctuation'; +import {Anchor} from '../../symbol/anchor'; +import {getSizeData, MAX_PACKED_SIZE} from '../../symbol/symbol_size'; + +import {register} from '../../util/web_worker_transfer'; +import {EvaluationParameters} from '../../style/evaluation_parameters'; +import {Formatted, ResolvedImage} from '@maplibre/maplibre-gl-style-spec'; +import {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin'; +import {mat4} from 'gl-matrix'; +import {getOverlapMode} from '../../style/style_layer/overlap_mode'; +import type {CanonicalTileID} from '../../source/tile_id'; +import type { + Bucket, + BucketParameters, + IndexedFeature, + PopulateParameters +} from '../bucket'; +import type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types.g'; +import type {StructArray, StructArrayMember, ViewType} from '../../util/struct_array'; +import type {SymbolStyleLayer} from '../../style/style_layer/symbol_style_layer'; +import type {Context} from '../../gl/context'; +import type {IndexBuffer} from '../../gl/index_buffer'; +import type {VertexBuffer} from '../../gl/vertex_buffer'; +import type {SymbolQuad} from '../../symbol/quads'; +import type {SizeData} from '../../symbol/symbol_size'; +import type {FeatureStates} from '../../source/source_state'; +import type {ImagePosition} from '../../render/image_atlas'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; + +export type SingleCollisionBox = { + x1: number; + y1: number; + x2: number; + y2: number; + anchorPointX: number; + anchorPointY: number; +}; + +export type CollisionArrays = { + textBox?: SingleCollisionBox; + verticalTextBox?: SingleCollisionBox; + iconBox?: SingleCollisionBox; + verticalIconBox?: SingleCollisionBox; + textFeatureIndex?: number; + verticalTextFeatureIndex?: number; + iconFeatureIndex?: number; + verticalIconFeatureIndex?: number; +}; + +export type SymbolFeature = { + sortKey: number | void; + text: Formatted | void; + icon: ResolvedImage; + index: number; + sourceLayerIndex: number; + geometry: Array>; + properties: any; + type: 'Unknown' | 'Point' | 'LineString' | 'Polygon'; + id?: any; +}; + +export type SortKeyRange = { + sortKey: number; + symbolInstanceStart: number; + symbolInstanceEnd: number; +}; + +// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them +// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph +// 7 bits are for the current opacity, and the lowest bit is the target opacity + +// actually defined in symbol_attributes.js +// const placementOpacityAttributes = [ +// { name: 'a_fade_opacity', components: 1, type: 'Uint32' } +// ]; +const shaderOpacityAttributes = [ + {name: 'a_fade_opacity', components: 1, type: 'Uint8' as ViewType, offset: 0} +]; + +function addVertex( + array: StructArray, + anchorX: number, + anchorY: number, + ox: number, + oy: number, + tx: number, + ty: number, + sizeVertex: number, + isSDF: boolean, + pixelOffsetX: number, + pixelOffsetY: number, + minFontScaleX: number, + minFontScaleY: number +) { + const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0; + const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0; + array.emplaceBack( + // a_pos_offset + anchorX, + anchorY, + Math.round(ox * 32), + Math.round(oy * 32), + + // a_data + tx, // x coordinate of symbol on glyph atlas texture + ty, // y coordinate of symbol on glyph atlas texture + (aSizeX << 1) + (isSDF ? 1 : 0), + aSizeY, + pixelOffsetX * 16, + pixelOffsetY * 16, + minFontScaleX * 256, + minFontScaleY * 256 + ); +} + +function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) { + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); + dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); +} + +function containsRTLText(formattedText: Formatted): boolean { + for (const section of formattedText.sections) { + if (stringContainsRTLText(section.text)) { + return true; + } + } + return false; +} + +export class SymbolBuffers { + layoutVertexArray: SymbolLayoutArray; + layoutVertexBuffer: VertexBuffer; + + indexArray: TriangleIndexArray; + indexBuffer: IndexBuffer; + + programConfigurations: ProgramConfigurationSet; + segments: SegmentVector; + + dynamicLayoutVertexArray: SymbolDynamicLayoutArray; + dynamicLayoutVertexBuffer: VertexBuffer; + + opacityVertexArray: SymbolOpacityArray; + opacityVertexBuffer: VertexBuffer; + hasVisibleVertices: boolean; + + collisionVertexArray: CollisionVertexArray; + collisionVertexBuffer: VertexBuffer; + + placedSymbolArray: PlacedSymbolArray; + + constructor(programConfigurations: ProgramConfigurationSet) { + this.layoutVertexArray = new SymbolLayoutArray(); + this.indexArray = new TriangleIndexArray(); + this.programConfigurations = programConfigurations; + this.segments = new SegmentVector(); + this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray(); + this.opacityVertexArray = new SymbolOpacityArray(); + this.hasVisibleVertices = false; + this.placedSymbolArray = new PlacedSymbolArray(); + } + + isEmpty() { + return this.layoutVertexArray.length === 0 && + this.indexArray.length === 0 && + this.dynamicLayoutVertexArray.length === 0 && + this.opacityVertexArray.length === 0; + } + + upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) { + if (this.isEmpty()) { + return; + } + + if (upload) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members); + this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer); + this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true); + this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true); + // This is a performance hack so that we can write to opacityVertexArray with uint32s + // even though the shaders read uint8s + this.opacityVertexBuffer.itemSize = 1; + } + if (upload || update) { + this.programConfigurations.upload(context); + } + } + + destroy() { + if (!this.layoutVertexBuffer) return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.programConfigurations.destroy(); + this.segments.destroy(); + this.dynamicLayoutVertexBuffer.destroy(); + this.opacityVertexBuffer.destroy(); + } +} + +register('SymbolBuffers', SymbolBuffers); + +class CollisionBuffers { + layoutVertexArray: StructArray; + layoutAttributes: Array; + layoutVertexBuffer: VertexBuffer; + + indexArray: TriangleIndexArray | LineIndexArray; + indexBuffer: IndexBuffer; + + segments: SegmentVector; + + collisionVertexArray: CollisionVertexArray; + collisionVertexBuffer: VertexBuffer; + + constructor(LayoutArray: { + new (...args: any): StructArray; + }, + layoutAttributes: Array, + IndexArray: { + new (...args: any): TriangleIndexArray | LineIndexArray; + }) { + this.layoutVertexArray = new LayoutArray(); + this.layoutAttributes = layoutAttributes; + this.indexArray = new IndexArray(); + this.segments = new SegmentVector(); + this.collisionVertexArray = new CollisionVertexArray(); + } + + upload(context: Context) { + this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes); + this.indexBuffer = context.createIndexBuffer(this.indexArray); + this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true); + } + + destroy() { + if (!this.layoutVertexBuffer) return; + this.layoutVertexBuffer.destroy(); + this.indexBuffer.destroy(); + this.segments.destroy(); + this.collisionVertexBuffer.destroy(); + } +} + +register('CollisionBuffers', CollisionBuffers); + +/** + * @internal + * Unlike other buckets, which simply implement #addFeature with type-specific + * logic for (essentially) triangulating feature geometries, SymbolBucket + * requires specialized behavior: + * + * 1. WorkerTile#parse(), the logical owner of the bucket creation process, + * calls SymbolBucket#populate(), which resolves text and icon tokens on + * each feature, adds each glyphs and symbols needed to the passed-in + * collections options.glyphDependencies and options.iconDependencies, and + * stores the feature data for use in subsequent step (this.features). + * + * 2. WorkerTile asynchronously requests from the main thread all of the glyphs + * and icons needed (by this bucket and any others). When glyphs and icons + * have been received, the WorkerTile creates a CollisionIndex and invokes: + * + * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and + * layout on a Symbol Bucket. This step populates: + * `this.symbolInstances`: metadata on generated symbols + * `this.collisionBoxArray`: collision data for use by foreground + * `this.text`: SymbolBuffers for text symbols + * `this.icons`: SymbolBuffers for icons + * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes + * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes + * The results are sent to the foreground for rendering + * + * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground, + * and uses the CollisionIndex along with current camera settings to determine + * which symbols can actually show on the map. Collided symbols are hidden + * using a dynamic "OpacityVertexArray". + */ +export class SymbolBucket implements Bucket { + static MAX_GLYPHS: number; + static addDynamicAttributes: typeof addDynamicAttributes; + + collisionBoxArray: CollisionBoxArray; + zoom: number; + overscaling: number; + layers: Array; + layerIds: Array; + stateDependentLayers: Array; + stateDependentLayerIds: Array; + + index: number; + sdfIcons: boolean; + iconsInText: boolean; + iconsNeedLinear: boolean; + bucketInstanceId: number; + justReloaded: boolean; + hasPattern: boolean; + + textSizeData: SizeData; + iconSizeData: SizeData; + + glyphOffsetArray: GlyphOffsetArray; + lineVertexArray: SymbolLineVertexArray; + features: Array; + symbolInstances: SymbolInstanceArray; + textAnchorOffsets: TextAnchorOffsetArray; + collisionArrays: Array; + sortKeyRanges: Array; + pixelRatio: number; + tilePixelRatio: number; + compareText: {[_: string]: Array}; + fadeStartTime: number; + sortFeaturesByKey: boolean; + sortFeaturesByY: boolean; + canOverlap: boolean; + sortedAngle: number; + featureSortOrder: Array; + + collisionCircleArray: Array; + placementInvProjMatrix: mat4; + placementViewportMatrix: mat4; + + text: SymbolBuffers; + icon: SymbolBuffers; + textCollisionBox: CollisionBuffers; + iconCollisionBox: CollisionBuffers; + uploaded: boolean; + sourceLayerIndex: number; + sourceID: string; + symbolInstanceIndexes: Array; + writingModes: WritingMode[]; + allowVerticalPlacement: boolean; + hasRTLText: boolean; + + constructor(options: BucketParameters) { + this.collisionBoxArray = options.collisionBoxArray; + this.zoom = options.zoom; + this.overscaling = options.overscaling; + this.layers = options.layers; + this.layerIds = this.layers.map(layer => layer.id); + this.index = options.index; + this.pixelRatio = options.pixelRatio; + this.sourceLayerIndex = options.sourceLayerIndex; + this.hasPattern = false; + this.hasRTLText = false; + this.sortKeyRanges = []; + + this.collisionCircleArray = []; + this.placementInvProjMatrix = mat4.identity([] as any); + this.placementViewportMatrix = mat4.identity([] as any); + + const layer = this.layers[0]; + const unevaluatedLayoutValues = layer._unevaluatedLayout._values; + + this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']); + this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']); + + const layout = this.layers[0].layout; + const sortKey = layout.get('symbol-sort-key'); + const zOrder = layout.get('symbol-z-order'); + this.canOverlap = + getOverlapMode(layout, 'text-overlap', 'text-allow-overlap') !== 'never' || + getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap') !== 'never' || + layout.get('text-ignore-placement') || + layout.get('icon-ignore-placement'); + this.sortFeaturesByKey = zOrder !== 'viewport-y' && !sortKey.isConstant(); + const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey); + this.sortFeaturesByY = zOrderByViewportY && this.canOverlap; + + if (layout.get('symbol-placement') === 'point') { + this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]); + } + + this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id); + + this.sourceID = options.sourceID; + } + + createArrays() { + this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property))); + this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property))); + + this.glyphOffsetArray = new GlyphOffsetArray(); + this.lineVertexArray = new SymbolLineVertexArray(); + this.symbolInstances = new SymbolInstanceArray(); + this.textAnchorOffsets = new TextAnchorOffsetArray(); + } + + calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) { + for (let i = 0; i < text.length; i++) { + stack[text.charCodeAt(i)] = true; + if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) { + const verticalChar = verticalizedCharacterMap[text.charAt(i)]; + if (verticalChar) { + stack[verticalChar.charCodeAt(0)] = true; + } + } + } + } + + populate(features: Array, options: PopulateParameters, canonical: CanonicalTileID) { + const layer = this.layers[0]; + const layout = layer.layout; + + const textFont = layout.get('text-font'); + const textField = layout.get('text-field'); + const iconImage = layout.get('icon-image'); + const hasText = + (textField.value.kind !== 'constant' || + (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) || + textField.value.value.toString().length > 0) && + (textFont.value.kind !== 'constant' || textFont.value.value.length > 0); + // we should always resolve the icon-image value if the property was defined in the style + // this allows us to fire the styleimagemissing event if image evaluation returns null + // the only way to distinguish between null returned from a coalesce statement with no valid images + // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object + const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0; + const symbolSortKey = layout.get('symbol-sort-key'); + + this.features = []; + + if (!hasText && !hasIcon) { + return; + } + + const icons = options.iconDependencies; + const stacks = options.glyphDependencies; + const availableImages = options.availableImages; + const globalProperties = new EvaluationParameters(this.zoom); + + for (const {feature, id, index, sourceLayerIndex} of features) { + + const needGeometry = layer._featureFilter.needGeometry; + const evaluationFeature = toEvaluationFeature(feature, needGeometry); + if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) { + continue; + } + + if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature); + + let text: Formatted | void; + if (hasText) { + // Expression evaluation will automatically coerce to Formatted + // but plain string token evaluation skips that pathway so do the + // conversion here. + const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages); + const formattedText = Formatted.factory(resolvedTokens); + if (containsRTLText(formattedText)) { + this.hasRTLText = true; + } + if ( + !this.hasRTLText || // non-rtl text so can proceed safely + getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping + this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text + ) { + text = transformText(formattedText, layer, evaluationFeature); + } + } + + let icon: ResolvedImage; + if (hasIcon) { + // Expression evaluation will automatically coerce to Image + // but plain string token evaluation skips that pathway so do the + // conversion here. + const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages); + if (resolvedTokens instanceof ResolvedImage) { + icon = resolvedTokens; + } else { + icon = ResolvedImage.fromString(resolvedTokens); + } + } + + if (!text && !icon) { + continue; + } + const sortKey = this.sortFeaturesByKey ? + symbolSortKey.evaluate(evaluationFeature, {}, canonical) : + undefined; + + const symbolFeature: SymbolFeature = { + id, + text, + icon, + index, + sourceLayerIndex, + geometry: evaluationFeature.geometry, + properties: feature.properties, + type: vectorTileFeatureTypes[feature.type], + sortKey + }; + this.features.push(symbolFeature); + + if (icon) { + icons[icon.name] = true; + } + + if (text) { + const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(','); + const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point'; + this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0; + for (const section of text.sections) { + if (!section.image) { + const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString()); + const sectionFont = section.fontStack || fontStack; + const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {}; + this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode); + } else { + // Add section image to the list of dependencies. + icons[section.image.name] = true; + } + } + } + } + + if (layout.get('symbol-placement') === 'line') { + // Merge adjacent lines with the same text to improve labelling. + // It's better to place labels on one long line than on many short segments. + this.features = mergeLines(this.features); + } + + if (this.sortFeaturesByKey) { + this.features.sort((a, b) => { + // a.sortKey is always a number when sortFeaturesByKey is true + return (a.sortKey as number) - (b.sortKey as number); + }); + } + } + + update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) { + if (!this.stateDependentLayers.length) return; + this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions); + this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions); + } + + isEmpty() { + // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created. + // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary. + return this.symbolInstances.length === 0 && !this.hasRTLText; + } + + uploadPending() { + return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload; + } + + upload(context: Context) { + if (!this.uploaded && this.hasDebugData()) { + this.textCollisionBox.upload(context); + this.iconCollisionBox.upload(context); + } + this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload); + this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload); + this.uploaded = true; + } + + destroyDebugData() { + this.textCollisionBox.destroy(); + this.iconCollisionBox.destroy(); + } + + destroy() { + this.text.destroy(); + this.icon.destroy(); + + if (this.hasDebugData()) { + this.destroyDebugData(); + } + } + + addToLineVertexArray(anchor: Anchor, line: any) { + const lineStartIndex = this.lineVertexArray.length; + if (anchor.segment !== undefined) { + let sumForwardLength = anchor.dist(line[anchor.segment + 1]); + let sumBackwardLength = anchor.dist(line[anchor.segment]); + const vertices = {}; + for (let i = anchor.segment + 1; i < line.length; i++) { + vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength}; + if (i < line.length - 1) { + sumForwardLength += line[i + 1].dist(line[i]); + } + } + for (let i = anchor.segment || 0; i >= 0; i--) { + vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength}; + if (i > 0) { + sumBackwardLength += line[i - 1].dist(line[i]); + } + } + for (let i = 0; i < line.length; i++) { + const vertex = vertices[i]; + this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor); + } + } + return { + lineStartIndex, + lineLength: this.lineVertexArray.length - lineStartIndex + }; + } + + addSymbols(arrays: SymbolBuffers, + quads: Array, + sizeVertex: any, + lineOffset: [number, number], + alongLine: boolean, + feature: SymbolFeature, + writingMode: WritingMode, + labelAnchor: Anchor, + lineStartIndex: number, + lineLength: number, + associatedIconIndex: number, + canonical: CanonicalTileID) { + const indexArray = arrays.indexArray; + const layoutVertexArray = arrays.layoutVertexArray; + + const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey as number : undefined); + const glyphOffsetArrayStart = this.glyphOffsetArray.length; + const vertexStartIndex = segment.vertexLength; + + const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0; + + const sections = feature.text && feature.text.sections; + + for (let i = 0; i < quads.length; i++) { + const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i]; + const index = segment.vertexLength; + + const y = glyphOffset[1]; + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY); + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY); + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY); + addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY); + + addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle); + + indexArray.emplaceBack(index, index + 1, index + 2); + indexArray.emplaceBack(index + 1, index + 2, index + 3); + + segment.vertexLength += 4; + segment.primitiveLength += 2; + + this.glyphOffsetArray.emplaceBack(glyphOffset[0]); + + if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) { + arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]); + } + } + + arrays.placedSymbolArray.emplaceBack( + labelAnchor.x, labelAnchor.y, + glyphOffsetArrayStart, + this.glyphOffsetArray.length - glyphOffsetArrayStart, + vertexStartIndex, + lineStartIndex, + lineLength, + labelAnchor.segment, + sizeVertex ? sizeVertex[0] : 0, + sizeVertex ? sizeVertex[1] : 0, + lineOffset[0], lineOffset[1], + writingMode, + // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed + 0, + false as unknown as number, + // The crossTileID is only filled/used on the foreground for dynamic text anchors + 0, + associatedIconIndex + ); + } + + _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) { + collisionVertexArray.emplaceBack(0, 0); + return layoutVertexArray.emplaceBack( + // pos + point.x, + point.y, + // a_anchor_pos + anchorX, + anchorY, + // extrude + Math.round(extrude.x), + Math.round(extrude.y)); + } + + addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance) { + const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray); + const index = segment.vertexLength; + + const layoutVertexArray = arrays.layoutVertexArray; + const collisionVertexArray = arrays.collisionVertexArray; + + const anchorX = symbolInstance.anchorX; + const anchorY = symbolInstance.anchorY; + + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1)); + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1)); + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2)); + this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2)); + + segment.vertexLength += 4; + + const indexArray = arrays.indexArray as LineIndexArray; + indexArray.emplaceBack(index, index + 1); + indexArray.emplaceBack(index + 1, index + 2); + indexArray.emplaceBack(index + 2, index + 3); + indexArray.emplaceBack(index + 3, index); + + segment.primitiveLength += 4; + } + + addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) { + for (let b = startIndex; b < endIndex; b++) { + const box: CollisionBox = this.collisionBoxArray.get(b); + const x1 = box.x1; + const y1 = box.y1; + const x2 = box.x2; + const y2 = box.y2; + + this.addCollisionDebugVertices(x1, y1, x2, y2, + isText ? this.textCollisionBox : this.iconCollisionBox, + box.anchorPoint, symbolInstance); + } + } + + generateCollisionDebugBuffers() { + if (this.hasDebugData()) { + this.destroyDebugData(); + } + + this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray); + this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray); + + for (let i = 0; i < this.symbolInstances.length; i++) { + const symbolInstance = this.symbolInstances.get(i); + this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true); + this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true); + this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false); + this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false); + } + } + + // These flat arrays are meant to be quicker to iterate over than the source + // CollisionBoxArray + _deserializeCollisionBoxesForSymbol( + collisionBoxArray: CollisionBoxArray, + textStartIndex: number, + textEndIndex: number, + verticalTextStartIndex: number, + verticalTextEndIndex: number, + iconStartIndex: number, + iconEndIndex: number, + verticalIconStartIndex: number, + verticalIconEndIndex: number + ): CollisionArrays { + + const collisionArrays = {} as CollisionArrays; + for (let k = textStartIndex; k < textEndIndex; k++) { + 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); + 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); + 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); + 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 + } + return collisionArrays; + } + + deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) { + this.collisionArrays = []; + for (let i = 0; i < this.symbolInstances.length; i++) { + const symbolInstance = this.symbolInstances.get(i); + this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol( + collisionBoxArray, + symbolInstance.textBoxStartIndex, + symbolInstance.textBoxEndIndex, + symbolInstance.verticalTextBoxStartIndex, + symbolInstance.verticalTextBoxEndIndex, + symbolInstance.iconBoxStartIndex, + symbolInstance.iconBoxEndIndex, + symbolInstance.verticalIconBoxStartIndex, + symbolInstance.verticalIconBoxEndIndex + )); + } + } + + hasTextData() { + return this.text.segments.get().length > 0; + } + + hasIconData() { + return this.icon.segments.get().length > 0; + } + + hasDebugData() { + return this.textCollisionBox && this.iconCollisionBox; + } + + hasTextCollisionBoxData() { + return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0; + } + + hasIconCollisionBoxData() { + return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0; + } + + addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) { + const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex); + + const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4; + for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) { + iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2); + iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3); + } + } + + getSortedSymbolIndexes(angle: number) { + if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) { + return this.symbolInstanceIndexes; + } + const sin = Math.sin(angle); + const cos = Math.cos(angle); + const rotatedYs = []; + const featureIndexes = []; + const result = []; + + for (let i = 0; i < this.symbolInstances.length; ++i) { + result.push(i); + const symbolInstance = this.symbolInstances.get(i); + rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0); + featureIndexes.push(symbolInstance.featureIndex); + } + + result.sort((aIndex, bIndex) => { + return (rotatedYs[aIndex] - rotatedYs[bIndex]) || + (featureIndexes[bIndex] - featureIndexes[aIndex]); + }); + + return result; + } + + addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) { + const last = this.sortKeyRanges[this.sortKeyRanges.length - 1]; + if (last && last.sortKey === sortKey) { + last.symbolInstanceEnd = symbolInstanceIndex + 1; + } else { + this.sortKeyRanges.push({ + sortKey, + symbolInstanceStart: symbolInstanceIndex, + symbolInstanceEnd: symbolInstanceIndex + 1 + }); + } + } + + sortFeatures(angle: number) { + if (!this.sortFeaturesByY) return; + if (this.sortedAngle === angle) return; + + // The current approach to sorting doesn't sort across segments so don't try. + // Sorting within segments separately seemed not to be worth the complexity. + if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return; + + // If the symbols are allowed to overlap sort them by their vertical screen position. + // The index array buffer is rewritten to reference the (unchanged) vertices in the + // sorted order. + + // To avoid sorting the actual symbolInstance array we sort an array of indexes. + this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle); + this.sortedAngle = angle; + + this.text.indexArray.clear(); + this.icon.indexArray.clear(); + + this.featureSortOrder = []; + + for (const i of this.symbolInstanceIndexes) { + const symbolInstance = this.symbolInstances.get(i); + this.featureSortOrder.push(symbolInstance.featureIndex); + + [ + symbolInstance.rightJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.leftJustifiedTextSymbolIndex + ].forEach((index, i, array) => { + // Only add a given index the first time it shows up, + // to avoid duplicate opacity entries when multiple justifications + // share the same glyphs. + if (index >= 0 && array.indexOf(index) === i) { + this.addIndicesForPlacedSymbol(this.text, index); + } + }); + + if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) { + this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex); + } + + if (symbolInstance.placedIconSymbolIndex >= 0) { + this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex); + } + + if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) { + this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex); + } + } + + if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray); + if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray); + } +} + +register('SymbolBucket', SymbolBucket, { + omit: ['layers', 'collisionBoxArray', 'features', 'compareText'] +}); + +// this constant is based on the size of StructArray indexes used in a symbol +// bucket--namely, glyphOffsetArrayStart +// eg the max valid UInt16 is 65,535 +// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation +// lineStartIndex and textBoxStartIndex could potentially be concerns +// but we expect there to be many fewer boxes/lines than glyphs +SymbolBucket.MAX_GLYPHS = 65535; + +SymbolBucket.addDynamicAttributes = addDynamicAttributes; + +export {addDynamicAttributes}; diff --git a/web/libraries/maplibre-gl/src/data/dem_data.test.ts b/web/libraries/maplibre-gl/src/data/dem_data.test.ts new file mode 100644 index 00000000..d3c67f87 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/dem_data.test.ts @@ -0,0 +1,237 @@ +import {DEMData} from './dem_data'; +import {RGBAImage} from '../util/image'; +import {serialize, deserialize} from '../util/web_worker_transfer'; + +function createMockImage(height, width) { + // RGBAImage passed to constructor has uniform 1px padding on all sides. + height += 2; + width += 2; + const pixels = new Uint8Array(height * width * 4); + for (let i = 0; i < pixels.length; i++) { + pixels[i] = (i + 1) % 4 === 0 ? 1 : Math.floor(Math.random() * 256); + } + return new RGBAImage({height, width}, pixels); +} + +function createMockClampImage(height, width) { + const pixels = new Uint8ClampedArray(height * width * 4); + for (let i = 0; i < pixels.length; i++) { + pixels[i] = (i + 1) % 4 === 0 ? 1 : Math.floor(Math.random() * 256); + } + return new RGBAImage({height, width}, pixels); +} + +describe('DEMData', () => { + describe('constructor', () => { + test('Uint8Array', () => { + const imageData0 = createMockImage(4, 4); + const dem = new DEMData('0', imageData0, 'mapbox'); + expect(dem.uid).toBe('0'); + expect(dem.dim).toBe(4); + expect(dem.stride).toBe(6); + }); + + test('Uint8ClampedArray', () => { + const imageData0 = createMockClampImage(4, 4); + const dem = new DEMData('0', imageData0, 'mapbox'); + expect(dem).not.toBeNull(); + expect(dem['uid']).toBe('0'); + expect(dem['dim']).toBe(2); + expect(dem['stride']).toBe(4); + }); + + test('otherEncoding', () => { + const spyOnWarnConsole = jest.spyOn(console, 'warn').mockImplementation(); + + const imageData0 = createMockImage(4, 4); + new DEMData('0', imageData0, 'otherEncoding' as any); + + expect(spyOnWarnConsole).toHaveBeenCalledTimes(1); + expect(spyOnWarnConsole.mock.calls).toEqual([['\"otherEncoding\" is not a valid encoding type. Valid types include \"mapbox\", \"terrarium\" and \"custom\".']]); + }); + }); +}); + +function testDEMBorderRegion(dem: DEMData) { + return () => { + let nonempty = true; + for (let x = -1; x < 5; x++) { + for (let y = -1; y < 5; y++) { + if (dem.get(x, y) === -65536) { + nonempty = false; + break; + } + } + } + expect(nonempty).toBeTruthy(); + + let verticalBorderMatch = true; + for (const x of [-1, 4]) { + for (let y = 0; y < 4; y++) { + if (dem.get(x, y) !== dem.get(x < 0 ? x + 1 : x - 1, y)) { + verticalBorderMatch = false; + break; + } + } + } + expect(verticalBorderMatch).toBeTruthy(); + + // horizontal borders empty + let horizontalBorderMatch = true; + for (const y of [-1, 4]) { + for (let x = 0; x < 4; x++) { + if (dem.get(x, y) !== dem.get(x, y < 0 ? y + 1 : y - 1)) { + horizontalBorderMatch = false; + break; + } + } + } + expect(horizontalBorderMatch).toBeTruthy(); + + expect(dem.get(-1, 4) === dem.get(0, 3)).toBeTruthy(); + expect(dem.get(4, 4) === dem.get(3, 3)).toBeTruthy(); + expect(dem.get(-1, -1) === dem.get(0, 0)).toBeTruthy(); + expect(dem.get(4, -1) === dem.get(3, 0)).toBeTruthy(); + }; +} + +function testDEMBackfill(dem0: DEMData, dem1: DEMData) { + return () => { + dem0.backfillBorder(dem1, -1, 0); + for (let y = 0; y < 4; y++) { + // dx = -1, dy = 0, so the left edge of dem1 should equal the right edge of dem0 + expect(dem0.get(-1, y) === dem1.get(3, y)).toBeTruthy(); + } + + dem0.backfillBorder(dem1, 0, -1); + for (let x = 0; x < 4; x++) { + expect(dem0.get(x, -1) === dem1.get(x, 3)).toBeTruthy(); + } + + dem0.backfillBorder(dem1, 1, 0); + for (let y = 0; y < 4; y++) { + expect(dem0.get(4, y) === dem1.get(0, y)).toBeTruthy(); + } + + dem0.backfillBorder(dem1, 0, 1); + for (let x = 0; x < 4; x++) { + expect(dem0.get(x, 4) === dem1.get(x, 0)).toBeTruthy(); + } + + dem0.backfillBorder(dem1, -1, 1); + expect(dem0.get(-1, 4) === dem1.get(3, 0)).toBeTruthy(); + + dem0.backfillBorder(dem1, 1, 1); + expect(dem0.get(4, 4) === dem1.get(0, 0)).toBeTruthy(); + + dem0.backfillBorder(dem1, -1, -1); + expect(dem0.get(-1, -1) === dem1.get(3, 3)).toBeTruthy(); + + dem0.backfillBorder(dem1, 1, -1); + expect(dem0.get(4, -1) === dem1.get(0, 3)).toBeTruthy(); + }; +} + +describe('DEMData#backfillBorder with encoding', () => { + describe('mabox encoding', () => { + const dem0 = new DEMData('0', createMockImage(4, 4), 'mapbox'); + const dem1 = new DEMData('1', createMockImage(4, 4), 'mapbox'); + + test('border region is initially populated with neighboring data', testDEMBorderRegion(dem0)); + test('backfillBorder correctly populates borders with neighboring data', testDEMBackfill(dem0, dem1)); + }); + + describe('terrarium encoding', () => { + const dem0 = new DEMData('0', createMockImage(4, 4), 'terrarium'); + const dem1 = new DEMData('1', createMockImage(4, 4), 'terrarium'); + + test('border region is initially populated with neighboring data', testDEMBorderRegion(dem0)); + test('backfillBorder correctly populates borders with neighboring data', testDEMBackfill(dem0, dem1)); + }); +}); + +function testSerialization(dem0: DEMData, redFactor: number, greenFactor: number, blueFactor: number, baseShift: number) { + return () => { + const serialized = serialize(dem0); + + // calculate min/max values + let min = Number.MAX_SAFE_INTEGER; + let max = Number.MIN_SAFE_INTEGER; + for (let x = 0; x < 4; x++) { + for (let y = 0; y < 4; y++) { + const ele = dem0.get(x, y); + if (ele > max) max = ele; + if (ele < min) min = ele; + } + } + + expect(serialized).toEqual({ + $name: 'DEMData', + uid: '0', + dim: 4, + stride: 6, + data: dem0.data, + redFactor, + greenFactor, + blueFactor, + baseShift, + max, + min, + }); + + const transferrables = []; + serialize(dem0, transferrables); + expect(new Uint32Array(transferrables[0])).toEqual(dem0.data); + }; +} + +function testDeserialization(dem0: DEMData) { + return () => { + const serialized = serialize(dem0); + + const deserialized = deserialize(serialized); + expect(deserialized).toEqual(dem0); + }; +} + +describe('DEMData is correctly serialized and deserialized', () => { + const mapboxDEM = new DEMData('0', createMockImage(4, 4), 'mapbox'); + const terrariumDEM = new DEMData('0', createMockImage(4, 4), 'terrarium'); + const customDEM = new DEMData('0', createMockImage(4, 4), 'custom', 1.0, 2.0, 3.0, 4.0); + test('serialized - mapbox', testSerialization(mapboxDEM, 6553.6, 25.6, 0.1, 10000)); + test('serialized - terrarium', testSerialization(terrariumDEM, 256.0, 1.0, 1.0 / 256.0, 32768.0)); + test('serialized - custom', testSerialization(customDEM, 1.0, 2.0, 3.0, 4.0)); + + test('deserialized - mapbox', testDeserialization(mapboxDEM)); + test('deserialized - terrarium', testDeserialization(terrariumDEM)); + test('deserialized - custom', testDeserialization(customDEM)); +}); + +describe('UnpackVector is correctly returned', () => { + test('terrarium, mapbox and custom', () => { + const mapboxDEM = new DEMData('0', createMockImage(4, 4), 'mapbox'); + const terrariumDEM = new DEMData('0', createMockImage(4, 4), 'terrarium'); + const customDEM = new DEMData('0', createMockImage(4, 4), 'custom', 1.0, 2.0, 3.0, 4.0); + + expect(terrariumDEM.getUnpackVector()).toEqual([256.0, 1.0, 1.0 / 256.0, 32768.0]); + expect(mapboxDEM.getUnpackVector()).toEqual([6553.6, 25.6, 0.1, 10000.0]); + expect(customDEM.getUnpackVector()).toEqual([1.0, 2.0, 3.0, 4.0]); + }); +}); + +function testGetPixels(dem: DEMData, imageData: RGBAImage) { + return () => { + expect(dem.getPixels()).toEqual(imageData); + }; +} + +describe('DEMData#getImage', () => { + const imageData = createMockImage(4, 4); + const mapboxDEM = new DEMData('0', imageData, 'terrarium'); + const terrariumDEM = new DEMData('0', imageData, 'terrarium'); + const customDEM = new DEMData('0', imageData, 'terrarium'); + + test('Image is correctly returned - mapbox', testGetPixels(mapboxDEM, imageData)); + test('Image is correctly returned - terrarium', testGetPixels(terrariumDEM, imageData)); + test('Image is correctly returned - custom', testGetPixels(customDEM, imageData)); +}); diff --git a/web/libraries/maplibre-gl/src/data/dem_data.ts b/web/libraries/maplibre-gl/src/data/dem_data.ts new file mode 100644 index 00000000..b95be92b --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/dem_data.ts @@ -0,0 +1,158 @@ +import {RGBAImage} from '../util/image'; + +import {warnOnce} from '../util/util'; +import {register} from '../util/web_worker_transfer'; + +// DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders +// data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially +// loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the +// elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of +// integer overflow when creating the texture used in the hillshadePrepare step. + +// DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8 +// surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a +// tile's edge without backfilling from neighboring tiles. + +export type DEMEncoding = 'mapbox' | 'terrarium' | 'custom' + +export class DEMData { + uid: string; + data: Uint32Array; + stride: number; + dim: number; + min: number; + max: number; + redFactor: number; + greenFactor: number; + blueFactor: number; + baseShift: number; + + // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride + // and dim is calculated as stride - 2. + constructor(uid: string, data: RGBAImage, encoding: DEMEncoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) { + this.uid = uid; + if (data.height !== data.width) throw new RangeError('DEM tiles must be square'); + if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) { + warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`); + return; + } + this.stride = data.height; + const dim = this.dim = data.height - 2; + this.data = new Uint32Array(data.data.buffer); + switch (encoding) { + case 'terrarium': + // unpacking formula for mapzen terrarium: + // https://aws.amazon.com/public-datasets/terrain/ + this.redFactor = 256.0; + this.greenFactor = 1.0; + this.blueFactor = 1.0 / 256.0; + this.baseShift = 32768.0; + break; + case 'custom': + this.redFactor = redFactor; + this.greenFactor = greenFactor; + this.blueFactor = blueFactor; + this.baseShift = baseShift; + break; + case 'mapbox': + default: + // unpacking formula for mapbox.terrain-rgb: + // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb + this.redFactor = 6553.6; + this.greenFactor = 25.6; + this.blueFactor = 0.1; + this.baseShift = 10000.0; + break; + } + + // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image + // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring + // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder + for (let x = 0; x < dim; x++) { + // left vertical border + this.data[this._idx(-1, x)] = this.data[this._idx(0, x)]; + // right vertical border + this.data[this._idx(dim, x)] = this.data[this._idx(dim - 1, x)]; + // left horizontal border + this.data[this._idx(x, -1)] = this.data[this._idx(x, 0)]; + // right horizontal border + this.data[this._idx(x, dim)] = this.data[this._idx(x, dim - 1)]; + } + // corners + this.data[this._idx(-1, -1)] = this.data[this._idx(0, 0)]; + this.data[this._idx(dim, -1)] = this.data[this._idx(dim - 1, 0)]; + this.data[this._idx(-1, dim)] = this.data[this._idx(0, dim - 1)]; + this.data[this._idx(dim, dim)] = this.data[this._idx(dim - 1, dim - 1)]; + + // calculate min/max values + this.min = Number.MAX_SAFE_INTEGER; + this.max = Number.MIN_SAFE_INTEGER; + for (let x = 0; x < dim; x++) { + for (let y = 0; y < dim; y++) { + const ele = this.get(x, y); + if (ele > this.max) this.max = ele; + if (ele < this.min) this.min = ele; + } + } + } + + get(x: number, y: number) { + const pixels = new Uint8Array(this.data.buffer); + const index = this._idx(x, y) * 4; + return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]); + } + + getUnpackVector() { + return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift]; + } + + _idx(x: number, y: number) { + if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) throw new RangeError('out of range source coordinates for DEM data'); + return (y + 1) * this.stride + (x + 1); + } + + unpack(r: number, g: number, b: number) { + return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift); + } + + getPixels() { + return new RGBAImage({width: this.stride, height: this.stride}, new Uint8Array(this.data.buffer)); + } + + backfillBorder(borderTile: DEMData, dx: number, dy: number) { + if (this.dim !== borderTile.dim) throw new Error('dem dimension mismatch'); + + let xMin = dx * this.dim, + xMax = dx * this.dim + this.dim, + yMin = dy * this.dim, + yMax = dy * this.dim + this.dim; + + switch (dx) { + case -1: + xMin = xMax - 1; + break; + case 1: + xMax = xMin + 1; + break; + } + + switch (dy) { + case -1: + yMin = yMax - 1; + break; + case 1: + yMax = yMin + 1; + break; + } + + const ox = -dx * this.dim; + const oy = -dy * this.dim; + for (let y = yMin; y < yMax; y++) { + for (let x = xMin; x < xMax; x++) { + this.data[this._idx(x, y)] = borderTile.data[this._idx(x + ox, y + oy)]; + } + } + } +} + +register('DEMData', DEMData); diff --git a/web/libraries/maplibre-gl/src/data/evaluation_feature.ts b/web/libraries/maplibre-gl/src/data/evaluation_feature.ts new file mode 100644 index 00000000..6594a714 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/evaluation_feature.ts @@ -0,0 +1,18 @@ +import {loadGeometry} from './load_geometry'; +import type Point from '@mapbox/point-geometry'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; +import type {Feature} from '@maplibre/maplibre-gl-style-spec'; + +type EvaluationFeature = Feature & { geometry: Array> }; +/** + * Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which + * will be loaded based on necessity. + * @param feature - the feature to evaluate + * @param needGeometry - if set to true this will load the geometry + */ +export function toEvaluationFeature(feature: VectorTileFeature, needGeometry: boolean): EvaluationFeature { + return {type: feature.type, + id: feature.id, + properties: feature.properties, + geometry: needGeometry ? loadGeometry(feature) : []}; +} diff --git a/web/libraries/maplibre-gl/src/data/extent.ts b/web/libraries/maplibre-gl/src/data/extent.ts new file mode 100644 index 00000000..7e92a5e5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/extent.ts @@ -0,0 +1,13 @@ +/** + * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of + * all source features normalized to this extent upon load. + * + * The value is a consequence of the following: + * + * * Vertex buffer store positions as signed 16 bit integers. + * * One bit is lost for signedness to support tile buffers. + * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int. + * * One bit is lost to support features extending past the extent on the right edge of the tile. + * * This leaves us with 2^13 = 8192 + */ +export const EXTENT = 8192; diff --git a/web/libraries/maplibre-gl/src/data/feature_index.ts b/web/libraries/maplibre-gl/src/data/feature_index.ts new file mode 100644 index 00000000..1d8ea9df --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/feature_index.ts @@ -0,0 +1,338 @@ +import Point from '@mapbox/point-geometry'; +import {loadGeometry} from './load_geometry'; +import {toEvaluationFeature} from './evaluation_feature'; +import {EXTENT} from './extent'; +import {featureFilter} from '@maplibre/maplibre-gl-style-spec'; +import {TransferableGridIndex} from '../util/transferable_grid_index'; +import {DictionaryCoder} from '../util/dictionary_coder'; +import vt from '@mapbox/vector-tile'; +import Protobuf from 'pbf'; +import {GeoJSONFeature} from '../util/vectortile_to_geojson'; +import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson'; +import {arraysIntersect, mapObject, extend} from '../util/util'; +import {OverscaledTileID} from '../source/tile_id'; +import {register} from '../util/web_worker_transfer'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {SourceFeatureState} from '../source/source_state'; +import {polygonIntersectsBox} from '../util/intersection_tests'; +import {PossiblyEvaluated} from '../style/properties'; +import {FeatureIndexArray} from './array_types.g'; +import {mat4} from 'gl-matrix'; + +import type {StyleLayer} from '../style/style_layer'; +import type {FeatureFilter, FeatureState, FilterSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {Transform} from '../geo/transform'; +import type {VectorTileFeature, VectorTileLayer} from '@mapbox/vector-tile'; + +type QueryParameters = { + scale: number; + pixelPosMatrix: mat4; + transform: Transform; + tileSize: number; + queryGeometry: Array; + cameraQueryGeometry: Array; + queryPadding: number; + params: { + filter: FilterSpecification; + layers: Array; + availableImages: Array; + }; +}; + +/** + * @internal + * An in memory index class to allow fast interaction with features + */ +export class FeatureIndex { + tileID: OverscaledTileID; + x: number; + y: number; + z: number; + grid: TransferableGridIndex; + grid3D: TransferableGridIndex; + featureIndexArray: FeatureIndexArray; + promoteId?: PromoteIdSpecification; + + rawTileData: ArrayBuffer; + bucketLayerIDs: Array>; + + vtLayers: {[_: string]: VectorTileLayer}; + sourceLayerCoder: DictionaryCoder; + + constructor(tileID: OverscaledTileID, promoteId?: PromoteIdSpecification | null) { + this.tileID = tileID; + this.x = tileID.canonical.x; + this.y = tileID.canonical.y; + this.z = tileID.canonical.z; + this.grid = new TransferableGridIndex(EXTENT, 16, 0); + this.grid3D = new TransferableGridIndex(EXTENT, 16, 0); + this.featureIndexArray = new FeatureIndexArray(); + this.promoteId = promoteId; + } + + insert(feature: VectorTileFeature, geometry: Array>, featureIndex: number, sourceLayerIndex: number, bucketIndex: number, is3D?: boolean) { + const key = this.featureIndexArray.length; + this.featureIndexArray.emplaceBack(featureIndex, sourceLayerIndex, bucketIndex); + + const grid = is3D ? this.grid3D : this.grid; + + for (let r = 0; r < geometry.length; r++) { + const ring = geometry[r]; + + const bbox = [Infinity, Infinity, -Infinity, -Infinity]; + for (let i = 0; i < ring.length; i++) { + const p = ring[i]; + bbox[0] = Math.min(bbox[0], p.x); + bbox[1] = Math.min(bbox[1], p.y); + bbox[2] = Math.max(bbox[2], p.x); + bbox[3] = Math.max(bbox[3], p.y); + } + + if (bbox[0] < EXTENT && + bbox[1] < EXTENT && + bbox[2] >= 0 && + bbox[3] >= 0) { + grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]); + } + } + } + + loadVTLayers(): {[_: string]: VectorTileLayer} { + if (!this.vtLayers) { + this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers; + this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']); + } + return this.vtLayers; + } + + // Finds non-symbol features in this tile at a particular position. + query( + args: QueryParameters, + styleLayers: {[_: string]: StyleLayer}, + serializedLayers: {[_: string]: any}, + sourceFeatureState: SourceFeatureState + ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} { + this.loadVTLayers(); + + const params = args.params || {} as { filter: any; layers: string[]; availableImages: string[] }, + pixelsToTileUnits = EXTENT / args.tileSize / args.scale, + filter = featureFilter(params.filter); + + const queryGeometry = args.queryGeometry; + const queryPadding = args.queryPadding * pixelsToTileUnits; + + const bounds = getBounds(queryGeometry); + const matching = this.grid.query(bounds.minX - queryPadding, bounds.minY - queryPadding, bounds.maxX + queryPadding, bounds.maxY + queryPadding); + + const cameraBounds = getBounds(args.cameraQueryGeometry); + const matching3D = this.grid3D.query( + cameraBounds.minX - queryPadding, cameraBounds.minY - queryPadding, cameraBounds.maxX + queryPadding, cameraBounds.maxY + queryPadding, + (bx1, by1, bx2, by2) => { + return polygonIntersectsBox(args.cameraQueryGeometry, bx1 - queryPadding, by1 - queryPadding, bx2 + queryPadding, by2 + queryPadding); + }); + + for (const key of matching3D) { + matching.push(key); + } + + matching.sort(topDownFeatureComparator); + + const result = {}; + let previousIndex; + for (let k = 0; k < matching.length; k++) { + const index = matching[k]; + + // don't check the same feature more than once + if (index === previousIndex) continue; + previousIndex = index; + + const match = this.featureIndexArray.get(index); + let featureGeometry = null; + this.loadMatchingFeature( + result, + match.bucketIndex, + match.sourceLayerIndex, + match.featureIndex, + filter, + params.layers, + params.availableImages, + styleLayers, + serializedLayers, + sourceFeatureState, + (feature: VectorTileFeature, styleLayer: StyleLayer, featureState: FeatureState) => { + if (!featureGeometry) { + featureGeometry = loadGeometry(feature); + } + + return styleLayer.queryIntersectsFeature(queryGeometry, feature, featureState, featureGeometry, this.z, args.transform, pixelsToTileUnits, args.pixelPosMatrix); + } + ); + } + + return result; + } + + loadMatchingFeature( + result: { + [_: string]: Array<{ + featureIndex: number; + feature: GeoJSONFeature; + intersectionZ?: boolean | number; + }>; + }, + bucketIndex: number, + sourceLayerIndex: number, + featureIndex: number, + filter: FeatureFilter, + filterLayerIDs: Array, + availableImages: Array, + styleLayers: {[_: string]: StyleLayer}, + serializedLayers: {[_: string]: any}, + sourceFeatureState?: SourceFeatureState, + intersectionTest?: ( + feature: VectorTileFeature, + styleLayer: StyleLayer, + featureState: any, + id: string | number | void + ) => boolean | number) { + + const layerIDs = this.bucketLayerIDs[bucketIndex]; + if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs)) + return; + + const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex); + const sourceLayer = this.vtLayers[sourceLayerName]; + const feature = sourceLayer.feature(featureIndex); + + if (filter.needGeometry) { + const evaluationFeature = toEvaluationFeature(feature, true); + if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) { + return; + } + } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) { + return; + } + + const id = this.getId(feature, sourceLayerName); + + for (let l = 0; l < layerIDs.length; l++) { + const layerID = layerIDs[l]; + + if (filterLayerIDs && filterLayerIDs.indexOf(layerID) < 0) { + continue; + } + + const styleLayer = styleLayers[layerID]; + + if (!styleLayer) continue; + + let featureState = {}; + if (id && sourceFeatureState) { + // `feature-state` expression evaluation requires feature state to be available + featureState = sourceFeatureState.getState(styleLayer.sourceLayer || '_geojsonTileLayer', id); + } + + const serializedLayer = extend({}, serializedLayers[layerID]); + + serializedLayer.paint = evaluateProperties(serializedLayer.paint, styleLayer.paint, feature, featureState, availableImages); + serializedLayer.layout = evaluateProperties(serializedLayer.layout, styleLayer.layout, feature, featureState, availableImages); + + const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer, featureState); + if (!intersectionZ) { + // Only applied for non-symbol features + continue; + } + + const geojsonFeature = new GeoJSONFeature(feature, this.z, this.x, this.y, id) as MapGeoJSONFeature; + geojsonFeature.layer = serializedLayer; + let layerResult = result[layerID]; + if (layerResult === undefined) { + layerResult = result[layerID] = []; + } + layerResult.push({featureIndex, feature: geojsonFeature, intersectionZ}); + } + } + + // Given a set of symbol indexes that have already been looked up, + // return a matching set of GeoJSONFeatures + lookupSymbolFeatures(symbolFeatureIndexes: Array, + serializedLayers: {[_: string]: StyleLayer}, + bucketIndex: number, + sourceLayerIndex: number, + filterSpec: FilterSpecification, + filterLayerIDs: Array, + availableImages: Array, + styleLayers: {[_: string]: StyleLayer}) { + const result = {}; + this.loadVTLayers(); + + const filter = featureFilter(filterSpec); + + for (const symbolFeatureIndex of symbolFeatureIndexes) { + this.loadMatchingFeature( + result, + bucketIndex, + sourceLayerIndex, + symbolFeatureIndex, + filter, + filterLayerIDs, + availableImages, + styleLayers, + serializedLayers + ); + + } + return result; + } + + hasLayer(id: string) { + for (const layerIDs of this.bucketLayerIDs) { + for (const layerID of layerIDs) { + if (id === layerID) return true; + } + } + + return false; + } + + getId(feature: VectorTileFeature, sourceLayerId: string): string | number { + let id: string | number = feature.id; + if (this.promoteId) { + const propName = typeof this.promoteId === 'string' ? this.promoteId : this.promoteId[sourceLayerId]; + id = feature.properties[propName] as string | number; + if (typeof id === 'boolean') id = Number(id); + } + return id; + } +} + +register( + 'FeatureIndex', + FeatureIndex, + {omit: ['rawTileData', 'sourceLayerCoder']} +); + +function evaluateProperties(serializedProperties, styleLayerProperties, feature, featureState, availableImages) { + return mapObject(serializedProperties, (property, key) => { + const prop = styleLayerProperties instanceof PossiblyEvaluated ? styleLayerProperties.get(key) : null; + return prop && prop.evaluate ? prop.evaluate(feature, featureState, availableImages) : prop; + }); +} + +function getBounds(geometry: Array) { + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + for (const p of geometry) { + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + return {minX, minY, maxX, maxY}; +} + +function topDownFeatureComparator(a, b) { + return b - a; +} diff --git a/web/libraries/maplibre-gl/src/data/feature_position_map.test.ts b/web/libraries/maplibre-gl/src/data/feature_position_map.test.ts new file mode 100644 index 00000000..31a1cff7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/feature_position_map.test.ts @@ -0,0 +1,33 @@ +import {FeaturePositionMap} from './feature_position_map'; +import {serialize, deserialize} from '../util/web_worker_transfer'; + +describe('FeaturePositionMap', () => { + test('Can be queried after serialization/deserialization', () => { + const featureMap = new FeaturePositionMap(); + featureMap.add(7, 1, 0, 1); + featureMap.add(3, 2, 1, 2); + featureMap.add(7, 3, 2, 3); + featureMap.add(4, 4, 3, 4); + featureMap.add(2, 5, 4, 5); + featureMap.add(7, 6, 5, 7); + + const featureMap2 = deserialize(serialize(featureMap, [])) as FeaturePositionMap; + + const compareIndex = (a, b) => a.index - b.index; + + expect(featureMap2.getPositions(7).sort(compareIndex)).toEqual([ + {index: 1, start: 0, end: 1}, + {index: 3, start: 2, end: 3}, + {index: 6, start: 5, end: 7} + ].sort(compareIndex)); + }); + + test('Can not be queried before serialization/deserialization', () => { + const featureMap = new FeaturePositionMap(); + featureMap.add(0, 1, 2, 3); + + expect(() => { + featureMap.getPositions(0); + }).toThrow(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/data/feature_position_map.ts b/web/libraries/maplibre-gl/src/data/feature_position_map.ts new file mode 100644 index 00000000..b5d39b2a --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/feature_position_map.ts @@ -0,0 +1,126 @@ +import murmur3 from 'murmurhash-js'; +import {register} from '../util/web_worker_transfer'; + +type SerializedFeaturePositionMap = { + ids: Float64Array; + positions: Uint32Array; +}; + +type FeaturePosition = { + index: number; + start: number; + end: number; +}; + +// A transferable data structure that maps feature ids to their indices and buffer offsets +export class FeaturePositionMap { + ids: Array; + positions: Array; + indexed: boolean; + + constructor() { + this.ids = []; + this.positions = []; + this.indexed = false; + } + + add(id: unknown, index: number, start: number, end: number) { + this.ids.push(getNumericId(id)); + this.positions.push(index, start, end); + } + + getPositions(id: unknown): Array { + if (!this.indexed) throw new Error('Trying to get index, but feature positions are not indexed'); + + const intId = getNumericId(id); + + // binary search for the first occurrence of id in this.ids; + // relies on ids/positions being sorted by id, which happens in serialization + let i = 0; + let j = this.ids.length - 1; + while (i < j) { + const m = (i + j) >> 1; + if (this.ids[m] >= intId) { + j = m; + } else { + i = m + 1; + } + } + const positions = []; + while (this.ids[i] === intId) { + const index = this.positions[3 * i]; + const start = this.positions[3 * i + 1]; + const end = this.positions[3 * i + 2]; + positions.push({index, start, end}); + i++; + } + return positions; + } + + static serialize(map: FeaturePositionMap, transferables: Array): SerializedFeaturePositionMap { + const ids = new Float64Array(map.ids); + const positions = new Uint32Array(map.positions); + + sort(ids, positions, 0, ids.length - 1); + + if (transferables) { + transferables.push(ids.buffer, positions.buffer); + } + + return {ids, positions}; + } + + static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap { + const map = new FeaturePositionMap(); + // after transferring, we only use these arrays statically (no pushes), + // so TypedArray vs Array distinction that flow points out doesn't matter + map.ids = (obj.ids as any); + map.positions = (obj.positions as any); + map.indexed = true; + return map; + } +} + +function getNumericId(value: unknown) { + const numValue = +value; + if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) { + return numValue; + } + return murmur3(String(value)); +} + +// custom quicksort that sorts ids, indices and offsets together (by ids) +// uses Hoare partitioning & manual tail call optimization to avoid worst case scenarios +function sort(ids, positions, left, right) { + while (left < right) { + const pivot = ids[(left + right) >> 1]; + let i = left - 1; + let j = right + 1; + + while (true) { + do i++; while (ids[i] < pivot); + do j--; while (ids[j] > pivot); + if (i >= j) break; + swap(ids, i, j); + swap(positions, 3 * i, 3 * j); + swap(positions, 3 * i + 1, 3 * j + 1); + swap(positions, 3 * i + 2, 3 * j + 2); + } + + if (j - left < right - j) { + sort(ids, positions, left, j); + left = j + 1; + } else { + sort(ids, positions, j + 1, right); + right = j; + } + } +} + +function swap(arr, i, j) { + const tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +register('FeaturePositionMap', FeaturePositionMap); diff --git a/web/libraries/maplibre-gl/src/data/index_array_type.ts b/web/libraries/maplibre-gl/src/data/index_array_type.ts new file mode 100644 index 00000000..9d224219 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/index_array_type.ts @@ -0,0 +1,9 @@ +import {LineIndexArray, TriangleIndexArray, LineStripIndexArray} from './array_types.g'; + +/** + * An index array stores Uint16 indices of vertexes in a corresponding vertex array. We use + * three kinds of index arrays: arrays storing groups of three indices, forming triangles; + * arrays storing pairs of indices, forming line segments; and arrays storing single indices, + * forming a line strip. + */ +export {LineIndexArray, TriangleIndexArray, LineStripIndexArray}; diff --git a/web/libraries/maplibre-gl/src/data/load_geometry.test.ts b/web/libraries/maplibre-gl/src/data/load_geometry.test.ts new file mode 100644 index 00000000..23e61f19 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/load_geometry.test.ts @@ -0,0 +1,49 @@ +import fs from 'fs'; +import path from 'path'; +import Protobuf from 'pbf'; +import {VectorTile} from '@mapbox/vector-tile'; +import {loadGeometry} from './load_geometry'; + +// Load a line feature from fixture tile. +const vt = new VectorTile(new Protobuf(fs.readFileSync(path.resolve(__dirname, '../../test/unit/assets/mbsv5-6-18-23.vector.pbf')))); + +describe('loadGeometry', () => { + test('loadGeometry', () => { + const feature = vt.layers.road.feature(0); + const originalGeometry = feature.loadGeometry(); + const scaledGeometry = loadGeometry(feature); + expect(scaledGeometry[0][0].x).toBe(originalGeometry[0][0].x * 2); + expect(scaledGeometry[0][0].y).toBe(originalGeometry[0][0].y * 2); + }); + + test('loadGeometry warns and clamps when exceeding extent', () => { + const feature = vt.layers.road.feature(0); + feature.extent = 2048; + + let numWarnings = 0; + + // Use a custom console.warn to count warnings + const warn = console.warn; + console.warn = function(warning) { + if (warning.match(/Geometry exceeds allowed extent, reduce your vector tile buffer size/)) { + numWarnings++; + } + }; + + const lines = loadGeometry(feature); + + expect(numWarnings).toBe(1); + + let maxValue = -Infinity; + for (const line of lines) { + for (const {x, y} of line) { + maxValue = Math.max(x, y, maxValue); + } + } + expect(maxValue).toBe(16383); + + // Put it back + console.warn = warn; + + }); +}); diff --git a/web/libraries/maplibre-gl/src/data/load_geometry.ts b/web/libraries/maplibre-gl/src/data/load_geometry.ts new file mode 100644 index 00000000..199585be --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/load_geometry.ts @@ -0,0 +1,44 @@ +import {warnOnce, clamp} from '../util/util'; + +import {EXTENT} from './extent'; + +import type Point from '@mapbox/point-geometry'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; + +// These bounds define the minimum and maximum supported coordinate values. +// While visible coordinates are within [0, EXTENT], tiles may theoretically +// contain coordinates within [-Infinity, Infinity]. Our range is limited by the +// number of bits used to represent the coordinate. +const BITS = 15; +const MAX = Math.pow(2, BITS - 1) - 1; +const MIN = -MAX - 1; + +/** + * Loads a geometry from a VectorTileFeature and scales it to the common extent + * used internally. + * @param feature - the vector tile feature to load + */ +export function loadGeometry(feature: VectorTileFeature): Array> { + const scale = EXTENT / feature.extent; + const geometry = feature.loadGeometry(); + for (let r = 0; r < geometry.length; r++) { + const ring = geometry[r]; + for (let p = 0; p < ring.length; p++) { + const point = ring[p]; + // round here because mapbox-gl-native uses integers to represent + // points and we need to do the same to avoid renering differences. + const x = Math.round(point.x * scale); + const y = Math.round(point.y * scale); + + point.x = clamp(x, MIN, MAX); + point.y = clamp(y, MIN, MAX); + + if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) { + // warn when exceeding allowed extent except for the 1-px-off case + // https://github.com/mapbox/mapbox-gl-js/issues/8992 + warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size'); + } + } + } + return geometry; +} diff --git a/web/libraries/maplibre-gl/src/data/pos3d_attributes.ts b/web/libraries/maplibre-gl/src/data/pos3d_attributes.ts new file mode 100644 index 00000000..bbbcf996 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/pos3d_attributes.ts @@ -0,0 +1,5 @@ +import {createLayout} from '../util/struct_array'; + +export default createLayout([ + {name: 'a_pos3d', type: 'Int16', components: 3} +]); diff --git a/web/libraries/maplibre-gl/src/data/pos_attributes.ts b/web/libraries/maplibre-gl/src/data/pos_attributes.ts new file mode 100644 index 00000000..37d3cbb5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/pos_attributes.ts @@ -0,0 +1,5 @@ +import {createLayout} from '../util/struct_array'; + +export default createLayout([ + {name: 'a_pos', type: 'Int16', components: 2} +]); diff --git a/web/libraries/maplibre-gl/src/data/program_configuration.ts b/web/libraries/maplibre-gl/src/data/program_configuration.ts new file mode 100644 index 00000000..e02653aa --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/program_configuration.ts @@ -0,0 +1,735 @@ +import {packUint8ToFloat} from '../shaders/encode_attribute'; +import {Color, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec'; +import {register} from '../util/web_worker_transfer'; +import {PossiblyEvaluatedPropertyValue} from '../style/properties'; +import {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types.g'; +import {clamp} from '../util/util'; +import {patternAttributes} from './bucket/pattern_attributes'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {FeaturePositionMap} from './feature_position_map'; +import {Uniform, Uniform1f, UniformColor, Uniform4f} from '../render/uniform_binding'; + +import type {UniformLocations} from '../render/uniform_binding'; + +import type {CanonicalTileID} from '../source/tile_id'; +import type {Context} from '../gl/context'; +import type {TypedStyleLayer} from '../style/style_layer/typed_style_layer'; +import type {CrossfadeParameters} from '../style/evaluation_parameters'; +import type {StructArray, StructArrayMember} from '../util/struct_array'; +import type {VertexBuffer} from '../gl/vertex_buffer'; +import type {ImagePosition} from '../render/image_atlas'; +import type { + Feature, + FeatureState, + GlobalProperties, + SourceExpression, + CompositeExpression, + FormattedSection +} from '@maplibre/maplibre-gl-style-spec'; +import type {FeatureStates} from '../source/source_state'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; + +export type BinderUniform = { + name: string; + property: string; + binding: Uniform; +}; + +function packColor(color: Color): [number, number] { + return [ + packUint8ToFloat(255 * color.r, 255 * color.g), + packUint8ToFloat(255 * color.b, 255 * color.a) + ]; +} + +/** + * `Binder` is the interface definition for the strategies for constructing, + * uploading, and binding paint property data as GLSL attributes. Most style- + * spec properties have a 1:1 relationship to shader attribute/uniforms, but + * some require multiple values per feature to be passed to the GPU, and in + * those cases we bind multiple attributes/uniforms. + * + * It has three implementations, one for each of the three strategies we use: + * + * * For _constant_ properties -- those whose value is a constant, or the constant + * result of evaluating a camera expression at a particular camera position -- we + * don't need a vertex attribute buffer, and instead use a uniform. + * * For data expressions, we use a vertex buffer with a single attribute value, + * the evaluated result of the source function for the given feature. + * * For composite expressions, we use a vertex buffer with two attributes: min and + * max values covering the range of zooms at which we expect the tile to be + * displayed. These values are calculated by evaluating the composite expression for + * the given feature at strategically chosen zoom levels. In addition to this + * attribute data, we also use a uniform value which the shader uses to interpolate + * between the min and max value at the final displayed zoom level. The use of a + * uniform allows us to cheaply update the value on every frame. + * + * Note that the shader source varies depending on whether we're using a uniform or + * attribute. We dynamically compile shaders at runtime to accommodate this. + */ +interface AttributeBinder { + populatePaintArray( + length: number, + feature: Feature, + imagePositions: {[_: string]: ImagePosition}, + canonical?: CanonicalTileID, + formattedSection?: FormattedSection + ): void; + updatePaintArray( + start: number, + length: number, + feature: Feature, + featureState: FeatureState, + imagePositions: {[_: string]: ImagePosition} + ): void; + upload(a: Context): void; + destroy(): void; +} + +interface UniformBinder { + uniformNames: Array; + setUniform( + uniform: Uniform, + globals: GlobalProperties, + currentValue: PossiblyEvaluatedPropertyValue, + uniformName: string + ): void; + getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial>; +} + +class ConstantBinder implements UniformBinder { + value: unknown; + type: string; + uniformNames: Array; + + constructor(value: unknown, names: Array, type: string) { + this.value = value; + this.uniformNames = names.map(name => `u_${name}`); + this.type = type; + } + + setUniform( + uniform: Uniform, + globals: GlobalProperties, + currentValue: PossiblyEvaluatedPropertyValue + ): void { + uniform.set(currentValue.constantOr(this.value)); + } + + getBinding(context: Context, location: WebGLUniformLocation, _: string): Partial> { + return (this.type === 'color') ? + new UniformColor(context, location) : + new Uniform1f(context, location); + } +} + +class CrossFadedConstantBinder implements UniformBinder { + uniformNames: Array; + patternFrom: Array; + patternTo: Array; + pixelRatioFrom: number; + pixelRatioTo: number; + + constructor(value: unknown, names: Array) { + this.uniformNames = names.map(name => `u_${name}`); + this.patternFrom = null; + this.patternTo = null; + this.pixelRatioFrom = 1.0; + this.pixelRatioTo = 1.0; + } + + setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) { + this.pixelRatioFrom = posFrom.pixelRatio; + this.pixelRatioTo = posTo.pixelRatio; + this.patternFrom = posFrom.tlbr; + this.patternTo = posTo.tlbr; + } + + setUniform(uniform: Uniform, globals: GlobalProperties, currentValue: PossiblyEvaluatedPropertyValue, uniformName: string) { + const pos = + uniformName === 'u_pattern_to' ? this.patternTo : + uniformName === 'u_pattern_from' ? this.patternFrom : + uniformName === 'u_pixel_ratio_to' ? this.pixelRatioTo : + uniformName === 'u_pixel_ratio_from' ? this.pixelRatioFrom : null; + if (pos) uniform.set(pos); + } + + getBinding(context: Context, location: WebGLUniformLocation, name: string): Partial> { + return name.substr(0, 9) === 'u_pattern' ? + new Uniform4f(context, location) : + new Uniform1f(context, location); + } +} + +class SourceExpressionBinder implements AttributeBinder { + expression: SourceExpression; + type: string; + maxValue: number; + + paintVertexArray: StructArray; + paintVertexAttributes: Array; + paintVertexBuffer: VertexBuffer; + + constructor(expression: SourceExpression, names: Array, type: string, PaintVertexArray: { + new (...args: any): StructArray; + }) { + this.expression = expression; + this.type = type; + this.maxValue = 0; + this.paintVertexAttributes = names.map((name) => ({ + name: `a_${name}`, + type: 'Float32', + components: type === 'color' ? 2 : 1, + offset: 0 + })); + this.paintVertexArray = new PaintVertexArray(); + } + + populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) { + const start = this.paintVertexArray.length; + const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection); + this.paintVertexArray.resize(newLength); + this._setPaintValue(start, newLength, value); + } + + updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) { + const value = this.expression.evaluate({zoom: 0}, feature, featureState); + this._setPaintValue(start, end, value); + } + + _setPaintValue(start, end, value) { + if (this.type === 'color') { + const color = packColor(value); + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, color[0], color[1]); + } + } else { + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, value); + } + this.maxValue = Math.max(this.maxValue, Math.abs(value)); + } + } + + upload(context: Context) { + if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) { + if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) { + this.paintVertexBuffer.updateData(this.paintVertexArray); + } else { + this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent); + } + } + } + + destroy() { + if (this.paintVertexBuffer) { + this.paintVertexBuffer.destroy(); + } + } +} + +class CompositeExpressionBinder implements AttributeBinder, UniformBinder { + expression: CompositeExpression; + uniformNames: Array; + type: string; + useIntegerZoom: boolean; + zoom: number; + maxValue: number; + + paintVertexArray: StructArray; + paintVertexAttributes: Array; + paintVertexBuffer: VertexBuffer; + + constructor(expression: CompositeExpression, names: Array, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: { + new (...args: any): StructArray; + }) { + this.expression = expression; + this.uniformNames = names.map(name => `u_${name}_t`); + this.type = type; + this.useIntegerZoom = useIntegerZoom; + this.zoom = zoom; + this.maxValue = 0; + this.paintVertexAttributes = names.map((name) => ({ + name: `a_${name}`, + type: 'Float32', + components: type === 'color' ? 4 : 2, + offset: 0 + })); + this.paintVertexArray = new PaintVertexArray(); + } + + populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) { + const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection); + const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection); + const start = this.paintVertexArray.length; + this.paintVertexArray.resize(newLength); + this._setPaintValue(start, newLength, min, max); + } + + updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) { + const min = this.expression.evaluate({zoom: this.zoom}, feature, featureState); + const max = this.expression.evaluate({zoom: this.zoom + 1}, feature, featureState); + this._setPaintValue(start, end, min, max); + } + + _setPaintValue(start, end, min, max) { + if (this.type === 'color') { + const minColor = packColor(min); + const maxColor = packColor(max); + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]); + } + } else { + for (let i = start; i < end; i++) { + this.paintVertexArray.emplace(i, min, max); + } + this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max)); + } + } + + upload(context: Context) { + if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) { + if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) { + this.paintVertexBuffer.updateData(this.paintVertexArray); + } else { + this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent); + } + } + } + + destroy() { + if (this.paintVertexBuffer) { + this.paintVertexBuffer.destroy(); + } + } + + setUniform(uniform: Uniform, globals: GlobalProperties): void { + const currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom; + const factor = clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1); + uniform.set(factor); + } + + getBinding(context: Context, location: WebGLUniformLocation, _: string): Uniform1f { + return new Uniform1f(context, location); + } +} + +class CrossFadedCompositeBinder implements AttributeBinder { + expression: CompositeExpression; + type: string; + useIntegerZoom: boolean; + zoom: number; + layerId: string; + + zoomInPaintVertexArray: StructArray; + zoomOutPaintVertexArray: StructArray; + zoomInPaintVertexBuffer: VertexBuffer; + zoomOutPaintVertexBuffer: VertexBuffer; + paintVertexAttributes: Array; + + constructor(expression: CompositeExpression, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: { + new (...args: any): StructArray; + }, layerId: string) { + this.expression = expression; + this.type = type; + this.useIntegerZoom = useIntegerZoom; + this.zoom = zoom; + this.layerId = layerId; + + this.zoomInPaintVertexArray = new PaintVertexArray(); + this.zoomOutPaintVertexArray = new PaintVertexArray(); + } + + populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}) { + const start = this.zoomInPaintVertexArray.length; + this.zoomInPaintVertexArray.resize(length); + this.zoomOutPaintVertexArray.resize(length); + this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions); + } + + updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}) { + this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions); + } + + _setPaintValues(start, end, patterns, positions) { + if (!positions || !patterns) return; + + const {min, mid, max} = patterns; + const imageMin = positions[min]; + const imageMid = positions[mid]; + const imageMax = positions[max]; + if (!imageMin || !imageMid || !imageMax) return; + + // We populate two paint arrays because, for cross-faded properties, we don't know which direction + // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass + // unnecessary vertex data to the shaders, we determine which to upload at draw time. + for (let i = start; i < end; i++) { + this.zoomInPaintVertexArray.emplace(i, + imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1], + imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1], + imageMid.pixelRatio, + imageMin.pixelRatio, + ); + this.zoomOutPaintVertexArray.emplace(i, + imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1], + imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1], + imageMid.pixelRatio, + imageMax.pixelRatio, + ); + } + } + + upload(context: Context) { + if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) { + this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent); + this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent); + } + } + + destroy() { + if (this.zoomOutPaintVertexBuffer) this.zoomOutPaintVertexBuffer.destroy(); + if (this.zoomInPaintVertexBuffer) this.zoomInPaintVertexBuffer.destroy(); + } +} + +/** + * @internal + * ProgramConfiguration contains the logic for binding style layer properties and tile + * layer feature data into GL program uniforms and vertex attributes. + * + * Non-data-driven property values are bound to shader uniforms. Data-driven property + * values are bound to vertex attributes. In order to support a uniform GLSL syntax over + * both, [Mapbox GL Shaders](https://github.com/mapbox/mapbox-gl-shaders) defines a `#pragma` + * abstraction, which ProgramConfiguration is responsible for implementing. At runtime, + * it examines the attributes of a particular layer, combines this with fixed knowledge + * about how layers of the particular type are implemented, and determines which uniforms + * and vertex attributes will be required. It can then substitute the appropriate text + * into the shader source code, create and link a program, and bind the uniforms and + * vertex attributes in preparation for drawing. + * + * When a vector tile is parsed, this same configuration information is used to + * populate the attribute buffers needed for data-driven styling using the zoom + * level and feature property data. + */ +export class ProgramConfiguration { + binders: {[_: string]: AttributeBinder | UniformBinder}; + cacheKey: string; + + _buffers: Array; + + constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean) { + this.binders = {}; + this._buffers = []; + + const keys = []; + + for (const property in layer.paint._values) { + if (!filterProperties(property)) continue; + const value = (layer.paint as any).get(property); + if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) { + continue; + } + const names = paintAttributeNames(property, layer.type); + const expression = value.value; + const type = value.property.specification.type; + const useIntegerZoom = (value.property as any).useIntegerZoom; + const propType = value.property.specification['property-type']; + const isCrossFaded = propType === 'cross-faded' || propType === 'cross-faded-data-driven'; + + if (expression.kind === 'constant') { + this.binders[property] = isCrossFaded ? + new CrossFadedConstantBinder(expression.value, names) : + new ConstantBinder(expression.value, names, type); + keys.push(`/u_${property}`); + + } else if (expression.kind === 'source' || isCrossFaded) { + const StructArrayLayout = layoutType(property, type, 'source'); + this.binders[property] = isCrossFaded ? + new CrossFadedCompositeBinder(expression as CompositeExpression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) : + new SourceExpressionBinder(expression as SourceExpression, names, type, StructArrayLayout); + keys.push(`/a_${property}`); + + } else { + const StructArrayLayout = layoutType(property, type, 'composite'); + this.binders[property] = new CompositeExpressionBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout); + keys.push(`/z_${property}`); + } + } + + this.cacheKey = keys.sort().join(''); + } + + getMaxValue(property: string): number { + const binder = this.binders[property]; + return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0; + } + + populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, canonical?: CanonicalTileID, formattedSection?: FormattedSection) { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) + (binder as AttributeBinder).populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection); + } + } + setConstantPatternPositions(posTo: ImagePosition, posFrom: ImagePosition) { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof CrossFadedConstantBinder) + binder.setConstantPatternPositions(posTo, posFrom); + } + } + + updatePaintArrays( + featureStates: FeatureStates, + featureMap: FeaturePositionMap, + vtLayer: VectorTileLayer, + layer: TypedStyleLayer, + imagePositions: {[_: string]: ImagePosition} + ): boolean { + let dirty: boolean = false; + for (const id in featureStates) { + const positions = featureMap.getPositions(id); + + for (const pos of positions) { + const feature = vtLayer.feature(pos.index); + + for (const property in this.binders) { + const binder = this.binders[property]; + if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || + binder instanceof CrossFadedCompositeBinder) && (binder as any).expression.isStateDependent === true) { + //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255 + const value = (layer.paint as any).get(property); + (binder as any).expression = value.value; + (binder as AttributeBinder).updatePaintArray(pos.start, pos.end, feature, featureStates[id], imagePositions); + dirty = true; + } + } + } + } + return dirty; + } + + defines(): Array { + const result = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) { + result.push(...binder.uniformNames.map(name => `#define HAS_UNIFORM_${name}`)); + } + } + return result; + } + + getBinderAttributes(): Array { + const result = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) { + for (let i = 0; i < binder.paintVertexAttributes.length; i++) { + result.push(binder.paintVertexAttributes[i].name); + } + } else if (binder instanceof CrossFadedCompositeBinder) { + for (let i = 0; i < patternAttributes.members.length; i++) { + result.push(patternAttributes.members[i].name); + } + } + } + return result; + } + + getBinderUniforms(): Array { + const uniforms = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) { + for (const uniformName of binder.uniformNames) { + uniforms.push(uniformName); + } + } + } + return uniforms; + } + + getPaintVertexBuffers(): Array { + return this._buffers; + } + + getUniforms(context: Context, locations: UniformLocations): Array { + const uniforms = []; + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) { + for (const name of binder.uniformNames) { + if (locations[name]) { + const binding = binder.getBinding(context, locations[name], name); + uniforms.push({name, property, binding}); + } + } + } + } + return uniforms; + } + + setUniforms( + context: Context, + binderUniforms: Array, + properties: any, + globals: GlobalProperties + ) { + // Uniform state bindings are owned by the Program, but we set them + // from within the ProgramConfiguraton's binder members. + for (const {name, property, binding} of binderUniforms) { + (this.binders[property] as any).setUniform(binding, globals, properties.get(property), name); + } + } + + updatePaintBuffers(crossfade?: CrossfadeParameters) { + this._buffers = []; + + for (const property in this.binders) { + const binder = this.binders[property]; + if (crossfade && binder instanceof CrossFadedCompositeBinder) { + const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer; + if (patternVertexBuffer) this._buffers.push(patternVertexBuffer); + + } else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) { + this._buffers.push(binder.paintVertexBuffer); + } + } + } + + upload(context: Context) { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) + binder.upload(context); + } + this.updatePaintBuffers(); + } + + destroy() { + for (const property in this.binders) { + const binder = this.binders[property]; + if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) + binder.destroy(); + } + } +} + +export class ProgramConfigurationSet { + programConfigurations: {[_: string]: ProgramConfiguration}; + needsUpload: boolean; + _featureMap: FeaturePositionMap; + _bufferOffset: number; + + constructor(layers: ReadonlyArray, zoom: number, filterProperties: (_: string) => boolean = () => true) { + this.programConfigurations = {}; + for (const layer of layers) { + this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties); + } + this.needsUpload = false; + this._featureMap = new FeaturePositionMap(); + this._bufferOffset = 0; + } + + populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[_: string]: ImagePosition}, canonical: CanonicalTileID, formattedSection?: FormattedSection) { + for (const key in this.programConfigurations) { + this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection); + } + + if (feature.id !== undefined) { + this._featureMap.add(feature.id, index, this._bufferOffset, length); + } + this._bufferOffset = length; + + this.needsUpload = true; + } + + updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: ReadonlyArray, imagePositions: {[_: string]: ImagePosition}) { + for (const layer of layers) { + this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload; + } + } + + get(layerId: string) { + return this.programConfigurations[layerId]; + } + + upload(context: Context) { + if (!this.needsUpload) return; + for (const layerId in this.programConfigurations) { + this.programConfigurations[layerId].upload(context); + } + this.needsUpload = false; + } + + destroy() { + for (const layerId in this.programConfigurations) { + this.programConfigurations[layerId].destroy(); + } + } +} + +function paintAttributeNames(property, type) { + const attributeNameExceptions = { + 'text-opacity': ['opacity'], + 'icon-opacity': ['opacity'], + 'text-color': ['fill_color'], + 'icon-color': ['fill_color'], + 'text-halo-color': ['halo_color'], + 'icon-halo-color': ['halo_color'], + 'text-halo-blur': ['halo_blur'], + 'icon-halo-blur': ['halo_blur'], + 'text-halo-width': ['halo_width'], + 'icon-halo-width': ['halo_width'], + 'line-gap-width': ['gapwidth'], + 'line-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'], + 'fill-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'], + 'fill-extrusion-pattern': ['pattern_to', 'pattern_from', 'pixel_ratio_to', 'pixel_ratio_from'], + }; + + return attributeNameExceptions[property] || [property.replace(`${type}-`, '').replace(/-/g, '_')]; +} + +function getLayoutException(property) { + const propertyExceptions = { + 'line-pattern': { + 'source': PatternLayoutArray, + 'composite': PatternLayoutArray + }, + 'fill-pattern': { + 'source': PatternLayoutArray, + 'composite': PatternLayoutArray + }, + 'fill-extrusion-pattern': { + 'source': PatternLayoutArray, + 'composite': PatternLayoutArray + } + }; + + return propertyExceptions[property]; +} + +function layoutType(property, type, binderType) { + const defaultLayouts = { + 'color': { + 'source': StructArrayLayout2f8, + 'composite': StructArrayLayout4f16 + }, + 'number': { + 'source': StructArrayLayout1f4, + 'composite': StructArrayLayout2f8 + } + }; + + const layoutException = getLayoutException(property); + return layoutException && layoutException[binderType] || defaultLayouts[type][binderType]; +} + +register('ConstantBinder', ConstantBinder); +register('CrossFadedConstantBinder', CrossFadedConstantBinder); +register('SourceExpressionBinder', SourceExpressionBinder); +register('CrossFadedCompositeBinder', CrossFadedCompositeBinder); +register('CompositeExpressionBinder', CompositeExpressionBinder); +register('ProgramConfiguration', ProgramConfiguration, {omit: ['_buffers']}); +register('ProgramConfigurationSet', ProgramConfigurationSet); diff --git a/web/libraries/maplibre-gl/src/data/raster_bounds_attributes.ts b/web/libraries/maplibre-gl/src/data/raster_bounds_attributes.ts new file mode 100644 index 00000000..6ff07123 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/raster_bounds_attributes.ts @@ -0,0 +1,6 @@ +import {createLayout} from '../util/struct_array'; + +export default createLayout([ + {name: 'a_pos', type: 'Int16', components: 2}, + {name: 'a_texture_pos', type: 'Int16', components: 2} +]); diff --git a/web/libraries/maplibre-gl/src/data/segment.ts b/web/libraries/maplibre-gl/src/data/segment.ts new file mode 100644 index 00000000..07ab4345 --- /dev/null +++ b/web/libraries/maplibre-gl/src/data/segment.ts @@ -0,0 +1,89 @@ +import {warnOnce} from '../util/util'; + +import {register} from '../util/web_worker_transfer'; + +import type {VertexArrayObject} from '../render/vertex_array_object'; +import type {StructArray} from '../util/struct_array'; + +/** + * @internal + * A single segment of a vector + */ +export type Segment = { + sortKey?: number; + vertexOffset: number; + primitiveOffset: number; + vertexLength: number; + primitiveLength: number; + vaos: {[_: string]: VertexArrayObject}; +}; + +/** + * @internal + * Used for calculations on vector segments + */ +export class SegmentVector { + static MAX_VERTEX_ARRAY_LENGTH: number; + segments: Array; + + constructor(segments: Array = []) { + this.segments = segments; + } + + prepareSegment( + numVertices: number, + layoutVertexArray: StructArray, + indexArray: StructArray, + sortKey?: number + ): Segment { + let segment: Segment = this.segments[this.segments.length - 1]; + if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) warnOnce(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`); + if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) { + segment = ({ + vertexOffset: layoutVertexArray.length, + primitiveOffset: indexArray.length, + vertexLength: 0, + primitiveLength: 0 + } as any); + if (sortKey !== undefined) segment.sortKey = sortKey; + this.segments.push(segment); + } + return segment; + } + + get() { + return this.segments; + } + + destroy() { + for (const segment of this.segments) { + for (const k in segment.vaos) { + segment.vaos[k].destroy(); + } + } + } + + static simpleSegment( + vertexOffset: number, + primitiveOffset: number, + vertexLength: number, + primitiveLength: number + ): SegmentVector { + return new SegmentVector([{ + vertexOffset, + primitiveOffset, + vertexLength, + primitiveLength, + vaos: {}, + sortKey: 0 + }]); + } +} + +/** + * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit + * addressing of vertex buffers. + */ +SegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1; + +register('SegmentVector', SegmentVector); diff --git a/web/libraries/maplibre-gl/src/geo/edge_insets.test.ts b/web/libraries/maplibre-gl/src/geo/edge_insets.test.ts new file mode 100644 index 00000000..d9379515 --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/edge_insets.test.ts @@ -0,0 +1,83 @@ +import expect from 'expect'; +import {EdgeInsets} from '../geo/edge_insets'; + +describe('EdgeInsets', () => { + describe('#constructor', () => { + test('creates an object with default values', () => { + expect(new EdgeInsets() instanceof EdgeInsets).toBeTruthy(); + }); + + test('invalid initialization', () => { + expect(() => { + new EdgeInsets(NaN, 10); + }).toThrow('Invalid value for edge-insets, top, bottom, left and right must all be numbers'); + + expect(() => { + new EdgeInsets(-10, 10, 20, 10); + }).toThrow('Invalid value for edge-insets, top, bottom, left and right must all be numbers'); + }); + + test('valid initialization', () => { + const top = 10; + const bottom = 15; + const left = 26; + const right = 19; + + const inset = new EdgeInsets(top, bottom, left, right); + expect(inset.top).toBe(top); + expect(inset.bottom).toBe(bottom); + expect(inset.left).toBe(left); + expect(inset.right).toBe(right); + }); + }); + + describe('#getCenter', () => { + test('valid input', () => { + const inset = new EdgeInsets(10, 15, 50, 10); + const center = inset.getCenter(600, 400); + expect(center.x).toBe(320); + expect(center.y).toBe(197.5); + }); + + test('center clamping', () => { + const inset = new EdgeInsets(300, 200, 500, 200); + const center = inset.getCenter(600, 400); + + // Midpoint of the overlap when padding overlaps + expect(center.x).toBe(450); + expect(center.y).toBe(250); + }); + }); + + describe('#interpolate', () => { + test('it works', () => { + const inset1 = new EdgeInsets(10, 15, 50, 10); + const inset2 = new EdgeInsets(20, 30, 100, 10); + const inset3 = inset1.interpolate(inset1, inset2, 0.5); + + // inset1 is mutated in-place + expect(inset3).toBe(inset1); + + expect(inset3.top).toBe(15); + expect(inset3.bottom).toBe(22.5); + expect(inset3.left).toBe(75); + expect(inset3.right).toBe(10); + }); + + }); + + test('#equals', () => { + const inset1 = new EdgeInsets(10, 15, 50, 10); + const inset2 = new EdgeInsets(10, 15, 50, 10); + const inset3 = new EdgeInsets(10, 15, 50, 11); + expect(inset1.equals(inset2)).toBeTruthy(); + expect(inset2.equals(inset3)).toBeFalsy(); + }); + + test('#clone', () => { + const inset1 = new EdgeInsets(10, 15, 50, 10); + const inset2 = inset1.clone(); + expect(inset2 === inset1).toBeFalsy(); + expect(inset1.equals(inset2)).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/geo/edge_insets.ts b/web/libraries/maplibre-gl/src/geo/edge_insets.ts new file mode 100644 index 00000000..82ce736b --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/edge_insets.ts @@ -0,0 +1,146 @@ +import {interpolates} from '@maplibre/maplibre-gl-style-spec'; +import Point from '@mapbox/point-geometry'; +import {clamp} from '../util/util'; + +/** + * An `EdgeInset` object represents screen space padding applied to the edges of the viewport. + * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements + * on top of the map and having the vanishing point shift as UI elements resize. + * + * @group Geography and Geometry + */ +export class EdgeInsets { + /** + * @defaultValue 0 + */ + top: number; + /** + * @defaultValue 0 + */ + bottom: number; + /** + * @defaultValue 0 + */ + left: number; + /** + * @defaultValue 0 + */ + right: number; + + constructor(top: number = 0, bottom: number = 0, left: number = 0, right: number = 0) { + if (isNaN(top) || top < 0 || + isNaN(bottom) || bottom < 0 || + isNaN(left) || left < 0 || + isNaN(right) || right < 0 + ) { + throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers'); + } + + this.top = top; + this.bottom = bottom; + this.left = left; + this.right = right; + } + + /** + * Interpolates the inset in-place. + * This maintains the current inset value for any inset not present in `target`. + * @param start - interpolation start + * @param target - interpolation target + * @param t - interpolation step/weight + * @returns the insets + */ + interpolate(start: PaddingOptions | EdgeInsets, target: PaddingOptions, t: number): EdgeInsets { + if (target.top != null && start.top != null) this.top = interpolates.number(start.top, target.top, t); + if (target.bottom != null && start.bottom != null) this.bottom = interpolates.number(start.bottom, target.bottom, t); + if (target.left != null && start.left != null) this.left = interpolates.number(start.left, target.left, t); + if (target.right != null && start.right != null) this.right = interpolates.number(start.right, target.right, t); + + return this; + } + + /** + * Utility method that computes the new apprent center or vanishing point after applying insets. + * This is in pixels and with the top left being (0.0) and +y being downwards. + * + * @param width - the width + * @param height - the height + * @returns the point + */ + getCenter(width: number, height: number): Point { + // Clamp insets so they never overflow width/height and always calculate a valid center + const x = clamp((this.left + width - this.right) / 2, 0, width); + const y = clamp((this.top + height - this.bottom) / 2, 0, height); + + return new Point(x, y); + } + + equals(other: PaddingOptions): boolean { + return this.top === other.top && + this.bottom === other.bottom && + this.left === other.left && + this.right === other.right; + } + + clone(): EdgeInsets { + return new EdgeInsets(this.top, this.bottom, this.left, this.right); + } + + /** + * Returns the current state as json, useful when you want to have a + * read-only representation of the inset. + * + * @returns state as json + */ + toJSON(): PaddingOptions { + return { + top: this.top, + bottom: this.bottom, + left: this.left, + right: this.right + }; + } +} + +/** + * Options for setting padding on calls to methods such as {@link Map#fitBounds}, {@link Map#fitScreenCoordinates}, and {@link Map#setPadding}. Adjust these options to set the amount of padding in pixels added to the edges of the canvas. Set a uniform padding on all edges or individual values for each edge. All properties of this object must be + * non-negative integers. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: 20 + * }); + * ``` + * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/zoomto-linestring/) + * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/) + */ +export type PaddingOptions = { + /** + * Padding in pixels from the top of the map canvas. + */ + top: number; + /** + * Padding in pixels from the bottom of the map canvas. + */ + bottom: number; + /** + * Padding in pixels from the left of the map canvas. + */ + right: number; + /** + * Padding in pixels from the right of the map canvas. + */ + left: number; +}; diff --git a/web/libraries/maplibre-gl/src/geo/lng_lat.test.ts b/web/libraries/maplibre-gl/src/geo/lng_lat.test.ts new file mode 100644 index 00000000..2833a7f1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/lng_lat.test.ts @@ -0,0 +1,65 @@ +import {LngLat} from '../geo/lng_lat'; + +describe('LngLat', () => { + test('#constructor', () => { + expect(new LngLat(0, 0) instanceof LngLat).toBeTruthy(); + + expect(() => { + /*eslint no-new: 0*/ + new LngLat(0, -91); + }).toThrow('Invalid LngLat latitude value: must be between -90 and 90'); + + expect(() => { + /*eslint no-new: 0*/ + new LngLat(0, 91); + }).toThrow('Invalid LngLat latitude value: must be between -90 and 90'); + }); + + test('#convert', () => { + expect(LngLat.convert([0, 10]) instanceof LngLat).toBeTruthy(); + expect(LngLat.convert({lng: 0, lat: 10}) instanceof LngLat).toBeTruthy(); + expect(LngLat.convert({lng: 0, lat: 0}) instanceof LngLat).toBeTruthy(); + expect(LngLat.convert({lon: 0, lat: 10}) instanceof LngLat).toBeTruthy(); + expect(LngLat.convert({lon: 0, lat: 0}) instanceof LngLat).toBeTruthy(); + expect(LngLat.convert(new LngLat(0, 0)) instanceof LngLat).toBeTruthy(); + }); + + test('#wrap', () => { + expect(new LngLat(0, 0).wrap()).toEqual({lng: 0, lat: 0}); + expect(new LngLat(10, 20).wrap()).toEqual({lng: 10, lat: 20}); + expect(new LngLat(360, 0).wrap()).toEqual({lng: 0, lat: 0}); + expect(new LngLat(190, 0).wrap()).toEqual({lng: -170, lat: 0}); + }); + + test('#toArray', () => { + expect(new LngLat(10, 20).toArray()).toEqual([10, 20]); + }); + + test('#toString', () => { + expect(new LngLat(10, 20).toString()).toBe('LngLat(10, 20)'); + }); + + test('#distanceTo', () => { + const newYork = new LngLat(-74.0060, 40.7128); + const losAngeles = new LngLat(-118.2437, 34.0522); + const d = newYork.distanceTo(losAngeles); // 3935751.690893987, "true distance" is 3966km + expect(d > 3935750).toBeTruthy(); + expect(d < 3935752).toBeTruthy(); + }); + + test('#distanceTo to pole', () => { + const newYork = new LngLat(-74.0060, 40.7128); + const northPole = new LngLat(-135, 90); + const d = newYork.distanceTo(northPole); // 5480494.158486183 , "true distance" is 5499km + expect(d > 5480493).toBeTruthy(); + expect(d < 5480495).toBeTruthy(); + }); + + test('#distanceTo to Null Island', () => { + const newYork = new LngLat(-74.0060, 40.7128); + const nullIsland = new LngLat(0, 0); + const d = newYork.distanceTo(nullIsland); // 8667080.125666846 , "true distance" is 8661km + expect(d > 8667079).toBeTruthy(); + expect(d < 8667081).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/geo/lng_lat.ts b/web/libraries/maplibre-gl/src/geo/lng_lat.ts new file mode 100644 index 00000000..3b2aa37b --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/lng_lat.ts @@ -0,0 +1,169 @@ +import {wrap} from '../util/util'; + +/* +* Approximate radius of the earth in meters. +* Uses the WGS-84 approximation. The radius at the equator is ~6378137 and at the poles is ~6356752. https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84 +* 6371008.8 is one published "average radius" see https://en.wikipedia.org/wiki/Earth_radius#Mean_radius, or ftp://athena.fsv.cvut.cz/ZFG/grs80-Moritz.pdf p.4 +*/ +export const earthRadius = 6371008.8; + +/** + * A {@link LngLat} object, an array of two numbers representing longitude and latitude, + * or an object with `lng` and `lat` or `lon` and `lat` properties. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let v1 = new maplibregl.LngLat(-122.420679, 37.772537); + * let v2 = [-122.420679, 37.772537]; + * let v3 = {lon: -122.420679, lat: 37.772537}; + * ``` + */ +export type LngLatLike = LngLat | { + lng: number; + lat: number; +} | { + lon: number; + lat: number; +} | [number, number]; + +/** + * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees. + * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84). + * + * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the + * [GeoJSON specification](https://tools.ietf.org/html/rfc7946). + * + * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option + * can also accept an `Array` of two numbers and will perform an implicit conversion. + * This flexible type is documented as {@link LngLatLike}. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let ll = new maplibregl.LngLat(-123.9749, 40.7736); + * ll.lng; // = -123.9749 + * ``` + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/) + */ +export class LngLat { + lng: number; + lat: number; + + /** + * @param lng - Longitude, measured in degrees. + * @param lat - Latitude, measured in degrees. + */ + constructor(lng: number, lat: number) { + if (isNaN(lng) || isNaN(lat)) { + throw new Error(`Invalid LngLat object: (${lng}, ${lat})`); + } + this.lng = +lng; + this.lat = +lat; + if (this.lat > 90 || this.lat < -90) { + throw new Error('Invalid LngLat latitude value: must be between -90 and 90'); + } + } + + /** + * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180). + * + * @returns The wrapped `LngLat` object. + * @example + * ```ts + * let ll = new maplibregl.LngLat(286.0251, 40.7736); + * let wrapped = ll.wrap(); + * wrapped.lng; // = -73.9749 + * ``` + */ + wrap() { + return new LngLat(wrap(this.lng, -180, 180), this.lat); + } + + /** + * Returns the coordinates represented as an array of two numbers. + * + * @returns The coordinates represented as an array of longitude and latitude. + * @example + * ```ts + * let ll = new maplibregl.LngLat(-73.9749, 40.7736); + * ll.toArray(); // = [-73.9749, 40.7736] + * ``` + */ + toArray(): [number, number] { + return [this.lng, this.lat]; + } + + /** + * Returns the coordinates represent as a string. + * + * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`. + * @example + * ```ts + * let ll = new maplibregl.LngLat(-73.9749, 40.7736); + * ll.toString(); // = "LngLat(-73.9749, 40.7736)" + * ``` + */ + toString(): string { + return `LngLat(${this.lng}, ${this.lat})`; + } + + /** + * Returns the approximate distance between a pair of coordinates in meters + * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) + * + * @param lngLat - coordinates to compute the distance to + * @returns Distance in meters between the two coordinates. + * @example + * ```ts + * let new_york = new maplibregl.LngLat(-74.0060, 40.7128); + * let los_angeles = new maplibregl.LngLat(-118.2437, 34.0522); + * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km + * ``` + */ + distanceTo(lngLat: LngLat): number { + const rad = Math.PI / 180; + const lat1 = this.lat * rad; + const lat2 = lngLat.lat * rad; + const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad); + + const maxMeters = earthRadius * Math.acos(Math.min(a, 1)); + return maxMeters; + } + + /** + * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties + * to a `LngLat` object. + * + * If a `LngLat` object is passed in, the function returns it unchanged. + * + * @param input - An array of two numbers or object to convert, or a `LngLat` object to return. + * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object. + * @example + * ```ts + * let arr = [-73.9749, 40.7736]; + * let ll = maplibregl.LngLat.convert(arr); + * ll; // = LngLat {lng: -73.9749, lat: 40.7736} + * ``` + */ + static convert(input: LngLatLike): LngLat { + if (input instanceof LngLat) { + return input; + } + if (Array.isArray(input) && (input.length === 2 || input.length === 3)) { + return new LngLat(Number(input[0]), Number(input[1])); + } + if (!Array.isArray(input) && typeof input === 'object' && input !== null) { + return new LngLat( + // flow can't refine this to have one of lng or lat, so we have to cast to any + Number('lng' in input ? (input as any).lng : (input as any).lon), + Number(input.lat) + ); + } + throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]'); + } +} diff --git a/web/libraries/maplibre-gl/src/geo/lng_lat_bounds.test.ts b/web/libraries/maplibre-gl/src/geo/lng_lat_bounds.test.ts new file mode 100644 index 00000000..1b40e02c --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/lng_lat_bounds.test.ts @@ -0,0 +1,235 @@ +import {LngLat} from './lng_lat'; +import {LngLatBounds} from './lng_lat_bounds'; + +describe('LngLatBounds', () => { + test('#constructor', () => { + const sw = new LngLat(0, 0); + const ne = new LngLat(-10, 10); + const bounds = new LngLatBounds(sw, ne); + expect(bounds.getSouth()).toBe(0); + expect(bounds.getWest()).toBe(0); + expect(bounds.getNorth()).toBe(10); + expect(bounds.getEast()).toBe(-10); + }); + + test('#constructor across dateline', () => { + const sw = new LngLat(170, 0); + const ne = new LngLat(-170, 10); + const bounds = new LngLatBounds(sw, ne); + expect(bounds.getSouth()).toBe(0); + expect(bounds.getWest()).toBe(170); + expect(bounds.getNorth()).toBe(10); + expect(bounds.getEast()).toBe(-170); + }); + + test('#constructor across pole', () => { + const sw = new LngLat(0, 85); + const ne = new LngLat(-10, -85); + const bounds = new LngLatBounds(sw, ne); + expect(bounds.getSouth()).toBe(85); + expect(bounds.getWest()).toBe(0); + expect(bounds.getNorth()).toBe(-85); + expect(bounds.getEast()).toBe(-10); + }); + + test('#constructor no args', () => { + const bounds = new LngLatBounds(); + const t1 = () => { + bounds.getCenter(); + }; + expect(t1).toThrow(); + }); + + test('#extend with coordinate', () => { + const bounds = new LngLatBounds([0, 0], [10, 10]); + bounds.extend([-10, -10]); + + expect(bounds.getSouth()).toBe(-10); + expect(bounds.getWest()).toBe(-10); + expect(bounds.getNorth()).toBe(10); + expect(bounds.getEast()).toBe(10); + + bounds.extend(new LngLat(-15, -15)); + + expect(bounds.getSouth()).toBe(-15); + expect(bounds.getWest()).toBe(-15); + expect(bounds.getNorth()).toBe(10); + expect(bounds.getEast()).toBe(10); + + bounds.extend([-80, -80, 80, 80]); + + expect(bounds.getSouth()).toBe(-80); + expect(bounds.getWest()).toBe(-80); + expect(bounds.getNorth()).toBe(80); + expect(bounds.getEast()).toBe(80); + + bounds.extend({lng: -90, lat: -90}); + + expect(bounds.getSouth()).toBe(-90); + expect(bounds.getWest()).toBe(-90); + expect(bounds.getNorth()).toBe(80); + expect(bounds.getEast()).toBe(80); + + bounds.extend({lon: 90, lat: 90}); + + expect(bounds.getSouth()).toBe(-90); + expect(bounds.getWest()).toBe(-90); + expect(bounds.getNorth()).toBe(90); + expect(bounds.getEast()).toBe(90); + }); + + test('#extend with bounds', () => { + const bounds1 = new LngLatBounds([0, 0], [10, 10]); + const bounds2 = new LngLatBounds([-10, -10], [10, 10]); + + bounds1.extend(bounds2); + + expect(bounds1.getSouth()).toBe(-10); + expect(bounds1.getWest()).toBe(-10); + expect(bounds1.getNorth()).toBe(10); + expect(bounds1.getEast()).toBe(10); + + const bounds4 = new LngLatBounds([-20, -20, 20, 20]); + bounds1.extend(bounds4); + + expect(bounds1.getSouth()).toBe(-20); + expect(bounds1.getWest()).toBe(-20); + expect(bounds1.getNorth()).toBe(20); + expect(bounds1.getEast()).toBe(20); + + const bounds5 = new LngLatBounds(); + bounds1.extend(bounds5); + + expect(bounds1.getSouth()).toBe(-20); + expect(bounds1.getWest()).toBe(-20); + expect(bounds1.getNorth()).toBe(20); + expect(bounds1.getEast()).toBe(20); + }); + + test('#extend with null', () => { + const bounds = new LngLatBounds([0, 0], [10, 10]); + + bounds.extend(null); + + expect(bounds.getSouth()).toBe(0); + expect(bounds.getWest()).toBe(0); + expect(bounds.getNorth()).toBe(10); + expect(bounds.getEast()).toBe(10); + }); + + test('#extend undefined bounding box', () => { + const bounds1 = new LngLatBounds(undefined, undefined); + const bounds2 = new LngLatBounds([-10, -10], [10, 10]); + + bounds1.extend(bounds2); + + expect(bounds1.getSouth()).toBe(-10); + expect(bounds1.getWest()).toBe(-10); + expect(bounds1.getNorth()).toBe(10); + expect(bounds1.getEast()).toBe(10); + }); + + test('#extend same LngLat instance', () => { + const point = new LngLat(0, 0); + const bounds = new LngLatBounds(point, point); + + bounds.extend(new LngLat(15, 15)); + + expect(bounds.getSouth()).toBe(0); + expect(bounds.getWest()).toBe(0); + expect(bounds.getNorth()).toBe(15); + expect(bounds.getEast()).toBe(15); + }); + + test('accessors', () => { + const sw = new LngLat(0, 0); + const ne = new LngLat(-10, -20); + const bounds = new LngLatBounds(sw, ne); + expect(bounds.getCenter()).toEqual(new LngLat(-5, -10)); + expect(bounds.getSouth()).toBe(0); + expect(bounds.getWest()).toBe(0); + expect(bounds.getNorth()).toBe(-20); + expect(bounds.getEast()).toBe(-10); + expect(bounds.getSouthWest()).toEqual(new LngLat(0, 0)); + expect(bounds.getSouthEast()).toEqual(new LngLat(-10, 0)); + expect(bounds.getNorthEast()).toEqual(new LngLat(-10, -20)); + expect(bounds.getNorthWest()).toEqual(new LngLat(0, -20)); + }); + + test('#convert', () => { + const sw = new LngLat(0, 0); + const ne = new LngLat(-10, 10); + const bounds = new LngLatBounds(sw, ne); + expect(LngLatBounds.convert(undefined)).toBeUndefined(); + expect(LngLatBounds.convert(bounds)).toEqual(bounds); + expect(LngLatBounds.convert([sw, ne])).toEqual(bounds); + expect( + LngLatBounds.convert([bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth()]) + ).toEqual(bounds); + }); + + test('#toArray', () => { + const llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + expect(llb.toArray()).toEqual([[-73.9876, 40.7661], [-73.9397, 40.8002]]); + }); + + test('#toString', () => { + const llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + expect(llb.toString()).toBe('LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))'); + }); + + test('#isEmpty', () => { + const nullBounds = new LngLatBounds(); + expect(nullBounds.isEmpty()).toBe(true); + + const sw = new LngLat(0, 0); + const ne = new LngLat(-10, 10); + const bounds = new LngLatBounds(sw, ne); + expect(bounds.isEmpty()).toBe(false); + }); + + test('#fromLngLat', () => { + const center0 = new LngLat(0, 0); + const center1 = new LngLat(-73.9749, 40.7736); + + const center0Radius10 = LngLatBounds.fromLngLat(center0, 10); + const center1Radius10 = LngLatBounds.fromLngLat(center1, 10); + const center1Radius0 = LngLatBounds.fromLngLat(center1); + + expect(center0Radius10.toArray()).toEqual( + [[-0.00008983152770714982, -0.00008983152770714982], [0.00008983152770714982, 0.00008983152770714982]] + ); + expect(center1Radius10.toArray()).toEqual( + [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]] + ); + expect(center1Radius0.toArray()).toEqual([[-73.9749, 40.7736], [-73.9749, 40.7736]]); + }); + + describe('contains', () => { + describe('point', () => { + test('point is in bounds', () => { + const llb = new LngLatBounds([-1, -1], [1, 1]); + const ll = {lng: 0, lat: 0}; + expect(llb.contains(ll)).toBeTruthy(); + }); + + test('point is not in bounds', () => { + const llb = new LngLatBounds([-1, -1], [1, 1]); + const ll = {lng: 3, lat: 3}; + expect(llb.contains(ll)).toBeFalsy(); + }); + + test('point is in bounds that spans dateline', () => { + const llb = new LngLatBounds([190, -10], [170, 10]); + const ll = {lng: 180, lat: 0}; + expect(llb.contains(ll)).toBeTruthy(); + }); + + test('point is not in bounds that spans dateline', () => { + const llb = new LngLatBounds([190, -10], [170, 10]); + const ll = {lng: 0, lat: 0}; + expect(llb.contains(ll)).toBeFalsy(); + }); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/geo/lng_lat_bounds.ts b/web/libraries/maplibre-gl/src/geo/lng_lat_bounds.ts new file mode 100644 index 00000000..9d75682f --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/lng_lat_bounds.ts @@ -0,0 +1,333 @@ +import {LngLat} from './lng_lat'; +import type {LngLatLike} from './lng_lat'; + +/** + * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order, + * or an array of numbers in [west, south, east, north] order. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let v1 = new maplibregl.LngLatBounds( + * new maplibregl.LngLat(-73.9876, 40.7661), + * new maplibregl.LngLat(-73.9397, 40.8002) + * ); + * let v2 = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]) + * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; + * ``` + */ +export type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]; + +/** + * A `LngLatBounds` object represents a geographical bounding box, + * defined by its southwest and northeast points in longitude and latitude. + * + * If no arguments are provided to the constructor, a `null` bounding box is created. + * + * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option + * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion. + * This flexible type is documented as {@link LngLatBoundsLike}. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let sw = new maplibregl.LngLat(-73.9876, 40.7661); + * let ne = new maplibregl.LngLat(-73.9397, 40.8002); + * let llb = new maplibregl.LngLatBounds(sw, ne); + * ``` + */ +export class LngLatBounds { + _ne: LngLat; + _sw: LngLat; + + /** + * @param sw - The southwest corner of the bounding box. + * OR array of 4 numbers in the order of west, south, east, north + * OR array of 2 LngLatLike: [sw,ne] + * @param ne - The northeast corner of the bounding box. + * @example + * ```ts + * let sw = new maplibregl.LngLat(-73.9876, 40.7661); + * let ne = new maplibregl.LngLat(-73.9397, 40.8002); + * let llb = new maplibregl.LngLatBounds(sw, ne); + * ``` + * OR + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]); + * ``` + * OR + * ```ts + * let llb = new maplibregl.LngLatBounds([sw, ne]); + * ``` + */ + constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike) { + if (!sw) { + // noop + } else if (ne) { + this.setSouthWest(sw).setNorthEast(ne); + } else if (Array.isArray(sw)) { + if (sw.length === 4) { + // 4 element array: west, south, east, north + this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]); + } else { + this.setSouthWest(sw[0] as LngLatLike).setNorthEast(sw[1] as LngLatLike); + } + } + } + + /** + * Set the northeast corner of the bounding box + * + * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box. + * @returns `this` + */ + setNorthEast(ne: LngLatLike): this { + this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne); + return this; + } + + /** + * Set the southwest corner of the bounding box + * + * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box. + * @returns `this` + */ + setSouthWest(sw: LngLatLike): this { + this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw); + return this; + } + + /** + * Extend the bounds to include a given LngLatLike or LngLatBoundsLike. + * + * @param obj - object to extend to + * @returns `this` + */ + extend(obj: LngLatLike | LngLatBoundsLike): this { + const sw = this._sw, + ne = this._ne; + let sw2, ne2; + + if (obj instanceof LngLat) { + sw2 = obj; + ne2 = obj; + + } else if (obj instanceof LngLatBounds) { + sw2 = obj._sw; + ne2 = obj._ne; + + if (!sw2 || !ne2) return this; + + } else { + if (Array.isArray(obj)) { + if (obj.length === 4 || (obj as any[]).every(Array.isArray)) { + const lngLatBoundsObj = (obj as any as LngLatBoundsLike); + return this.extend(LngLatBounds.convert(lngLatBoundsObj)); + } else { + const lngLatObj = (obj as any as LngLatLike); + return this.extend(LngLat.convert(lngLatObj)); + } + + } else if (obj && ('lng' in obj || 'lon' in obj) && 'lat' in obj) { + return this.extend(LngLat.convert(obj)); + } + + return this; + } + + if (!sw && !ne) { + this._sw = new LngLat(sw2.lng, sw2.lat); + this._ne = new LngLat(ne2.lng, ne2.lat); + + } else { + sw.lng = Math.min(sw2.lng, sw.lng); + sw.lat = Math.min(sw2.lat, sw.lat); + ne.lng = Math.max(ne2.lng, ne.lng); + ne.lat = Math.max(ne2.lat, ne.lat); + } + + return this; + } + + /** + * Returns the geographical coordinate equidistant from the bounding box's corners. + * + * @returns The bounding box's center. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315} + * ``` + */ + getCenter(): LngLat { + return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2); + } + + /** + * Returns the southwest corner of the bounding box. + * + * @returns The southwest corner of the bounding box. + */ + getSouthWest(): LngLat { return this._sw; } + + /** + * Returns the northeast corner of the bounding box. + * + * @returns The northeast corner of the bounding box. + */ + getNorthEast(): LngLat { return this._ne; } + + /** + * Returns the northwest corner of the bounding box. + * + * @returns The northwest corner of the bounding box. + */ + getNorthWest(): LngLat { return new LngLat(this.getWest(), this.getNorth()); } + + /** + * Returns the southeast corner of the bounding box. + * + * @returns The southeast corner of the bounding box. + */ + getSouthEast(): LngLat { return new LngLat(this.getEast(), this.getSouth()); } + + /** + * Returns the west edge of the bounding box. + * + * @returns The west edge of the bounding box. + */ + getWest(): number { return this._sw.lng; } + + /** + * Returns the south edge of the bounding box. + * + * @returns The south edge of the bounding box. + */ + getSouth(): number { return this._sw.lat; } + + /** + * Returns the east edge of the bounding box. + * + * @returns The east edge of the bounding box. + */ + getEast(): number { return this._ne.lng; } + + /** + * Returns the north edge of the bounding box. + * + * @returns The north edge of the bounding box. + */ + getNorth(): number { return this._ne.lat; } + + /** + * Returns the bounding box represented as an array. + * + * @returns The bounding box represented as an array, consisting of the + * southwest and northeast coordinates of the bounding represented as arrays of numbers. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]] + * ``` + */ + toArray() { + return [this._sw.toArray(), this._ne.toArray()]; + } + + /** + * Return the bounding box represented as a string. + * + * @returns The bounding box represents as a string of the format + * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); + * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))" + * ``` + */ + toString() { + return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`; + } + + /** + * Check if the bounding box is an empty/`null`-type box. + * + * @returns True if bounds have been defined, otherwise false. + */ + isEmpty() { + return !(this._sw && this._ne); + } + + /** + * Check if the point is within the bounding box. + * + * @param lnglat - geographic point to check against. + * @returns `true` if the point is within the bounding box. + * @example + * ```ts + * let llb = new maplibregl.LngLatBounds( + * new maplibregl.LngLat(-73.9876, 40.7661), + * new maplibregl.LngLat(-73.9397, 40.8002) + * ); + * + * let ll = new maplibregl.LngLat(-73.9567, 40.7789); + * + * console.log(llb.contains(ll)); // = true + * ``` + */ + contains(lnglat: LngLatLike) { + const {lng, lat} = LngLat.convert(lnglat); + + const containsLatitude = this._sw.lat <= lat && lat <= this._ne.lat; + let containsLongitude = this._sw.lng <= lng && lng <= this._ne.lng; + if (this._sw.lng > this._ne.lng) { // wrapped coordinates + containsLongitude = this._sw.lng >= lng && lng >= this._ne.lng; + } + + return containsLatitude && containsLongitude; + } + + /** + * Converts an array to a `LngLatBounds` object. + * + * If a `LngLatBounds` object is passed in, the function returns it unchanged. + * + * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values. + * + * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return. + * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object. + * @example + * ```ts + * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; + * let llb = maplibregl.LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}} + * ``` + */ + static convert(input: LngLatBoundsLike | null): LngLatBounds { + if (input instanceof LngLatBounds) return input; + if (!input) return input as null; + return new LngLatBounds(input); + } + + /** + * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`. + * + * @param center - center coordinates of the new bounds. + * @param radius - Distance in meters from the coordinates to extend the bounds. + * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`. + * @example + * ```ts + * let center = new maplibregl.LngLat(-73.9749, 40.7736); + * maplibregl.LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]] + * ``` + */ + static fromLngLat(center: LngLat, radius:number = 0): LngLatBounds { + const earthCircumferenceInMetersAtEquator = 40075017; + const latAccuracy = 360 * radius / earthCircumferenceInMetersAtEquator, + lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * center.lat); + + return new LngLatBounds(new LngLat(center.lng - lngAccuracy, center.lat - latAccuracy), + new LngLat(center.lng + lngAccuracy, center.lat + latAccuracy)); + } +} diff --git a/web/libraries/maplibre-gl/src/geo/mercator_coordinate.test.ts b/web/libraries/maplibre-gl/src/geo/mercator_coordinate.test.ts new file mode 100644 index 00000000..305bb492 --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/mercator_coordinate.test.ts @@ -0,0 +1,34 @@ +import {LngLat} from './lng_lat'; +import {MercatorCoordinate, mercatorScale} from './mercator_coordinate'; + +describe('LngLat', () => { + test('#constructor', () => { + expect(new MercatorCoordinate(0, 0) instanceof MercatorCoordinate).toBeTruthy(); + expect(new MercatorCoordinate(0, 0, 0) instanceof MercatorCoordinate).toBeTruthy(); + }); + + test('#fromLngLat', () => { + const nullIsland = new LngLat(0, 0); + expect(MercatorCoordinate.fromLngLat(nullIsland)).toEqual({x: 0.5, y: 0.5, z: 0}); + }); + + test('#toLngLat', () => { + const dc = new LngLat(-77, 39); + expect(MercatorCoordinate.fromLngLat(dc, 500).toLngLat()).toEqual({lng: -77, lat: 39}); + }); + + test('#toAltitude', () => { + const dc = new LngLat(-77, 39); + expect(MercatorCoordinate.fromLngLat(dc, 500).toAltitude()).toBe(500); + }); + + test('#mercatorScale', () => { + expect(mercatorScale(0)).toBe(1); + expect(mercatorScale(45)).toBe(1.414213562373095); + }); + + test('#meterInMercatorCoordinateUnits', () => { + const nullIsland = new LngLat(0, 0); + expect(MercatorCoordinate.fromLngLat(nullIsland).meterInMercatorCoordinateUnits()).toBe(2.4981121214570498e-8); + }); +}); diff --git a/web/libraries/maplibre-gl/src/geo/mercator_coordinate.ts b/web/libraries/maplibre-gl/src/geo/mercator_coordinate.ts new file mode 100644 index 00000000..47945cc9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/mercator_coordinate.ts @@ -0,0 +1,156 @@ +import {LngLat, earthRadius} from '../geo/lng_lat'; +import type {LngLatLike} from '../geo/lng_lat'; +import {IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec'; + +/* + * The average circumference of the world in meters. + */ +const earthCircumfrence = 2 * Math.PI * earthRadius; // meters + +/* + * The circumference at a line of latitude in meters. + */ +function circumferenceAtLatitude(latitude: number) { + return earthCircumfrence * Math.cos(latitude * Math.PI / 180); +} + +export function mercatorXfromLng(lng: number) { + return (180 + lng) / 360; +} + +export function mercatorYfromLat(lat: number) { + return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360; +} + +export function mercatorZfromAltitude(altitude: number, lat: number) { + return altitude / circumferenceAtLatitude(lat); +} + +export function lngFromMercatorX(x: number) { + return x * 360 - 180; +} + +export function latFromMercatorY(y: number) { + const y2 = 180 - y * 360; + return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90; +} + +export function altitudeFromMercatorZ(z: number, y: number) { + return z * circumferenceAtLatitude(latFromMercatorY(y)); +} + +/** + * Determine the Mercator scale factor for a given latitude, see + * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor + * + * At the equator the scale factor will be 1, which increases at higher latitudes. + * + * @param lat - Latitude + * @returns scale factor + */ +export function mercatorScale(lat: number) { + return 1 / Math.cos(lat * Math.PI / 180); +} + +/** + * A `MercatorCoordinate` object represents a projected three dimensional position. + * + * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units: + * - the size of 1 unit is the width of the projected world instead of the "mercator meter" + * - the origin of the coordinate space is at the north-west corner instead of the middle + * + * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and + * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with + * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think + * of the coordinate space as the `0/0/0` tile with an extent of `1`. + * + * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let nullIsland = new maplibregl.MercatorCoordinate(0.5, 0.5, 0); + * ``` + * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/) + */ +export class MercatorCoordinate implements IMercatorCoordinate { + x: number; + y: number; + z: number; + + /** + * @param x - The x component of the position. + * @param y - The y component of the position. + * @param z - The z component of the position. + */ + constructor(x: number, y: number, z: number = 0) { + this.x = +x; + this.y = +y; + this.z = +z; + } + + /** + * Project a `LngLat` to a `MercatorCoordinate`. + * + * @param lngLatLike - The location to project. + * @param altitude - The altitude in meters of the position. + * @returns The projected mercator coordinate. + * @example + * ```ts + * let coord = maplibregl.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0); + * coord; // MercatorCoordinate(0.5, 0.5, 0) + * ``` + */ + static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0): MercatorCoordinate { + const lngLat = LngLat.convert(lngLatLike); + + return new MercatorCoordinate( + mercatorXfromLng(lngLat.lng), + mercatorYfromLat(lngLat.lat), + mercatorZfromAltitude(altitude, lngLat.lat)); + } + + /** + * Returns the `LngLat` for the coordinate. + * + * @returns The `LngLat` object. + * @example + * ```ts + * let coord = new maplibregl.MercatorCoordinate(0.5, 0.5, 0); + * let lngLat = coord.toLngLat(); // LngLat(0, 0) + * ``` + */ + toLngLat() { + return new LngLat( + lngFromMercatorX(this.x), + latFromMercatorY(this.y)); + } + + /** + * Returns the altitude in meters of the coordinate. + * + * @returns The altitude in meters. + * @example + * ```ts + * let coord = new maplibregl.MercatorCoordinate(0, 0, 0.02); + * coord.toAltitude(); // 6914.281956295339 + * ``` + */ + toAltitude(): number { + return altitudeFromMercatorZ(this.z, this.y); + } + + /** + * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude. + * + * For coordinates in real world units using meters, this naturally provides the scale + * to transform into `MercatorCoordinate`s. + * + * @returns Distance of 1 meter in `MercatorCoordinate` units. + */ + meterInMercatorCoordinateUnits(): number { + // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude + return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y)); + } +} diff --git a/web/libraries/maplibre-gl/src/geo/transform.test.ts b/web/libraries/maplibre-gl/src/geo/transform.test.ts new file mode 100644 index 00000000..065a0d4d --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/transform.test.ts @@ -0,0 +1,464 @@ +import Point from '@mapbox/point-geometry'; +import {Transform} from './transform'; +import {LngLat} from './lng_lat'; +import {OverscaledTileID, CanonicalTileID} from '../source/tile_id'; +import {fixedLngLat, fixedCoord} from '../../test/unit/lib/fixed'; +import type {Terrain} from '../render/terrain'; + +describe('transform', () => { + test('creates a transform', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(500, 500); + expect(transform.unmodified).toBe(true); + expect(transform.maxValidLatitude).toBe(85.051129); + expect(transform.tileSize).toBe(512); + expect(transform.worldSize).toBe(512); + expect(transform.width).toBe(500); + expect(transform.minZoom).toBe(0); + expect(transform.minPitch).toBe(0); + // Support signed zero + expect(transform.bearing === 0 ? 0 : transform.bearing).toBe(0); + expect(transform.bearing = 1).toBe(1); + expect(transform.bearing).toBe(1); + expect(transform.bearing = 0).toBe(0); + expect(transform.unmodified).toBe(false); + expect(transform.minZoom = 10).toBe(10); + expect(transform.maxZoom = 10).toBe(10); + expect(transform.minZoom).toBe(10); + expect(transform.center).toEqual({lng: 0, lat: 0}); + expect(transform.maxZoom).toBe(10); + expect(transform.minPitch = 10).toBe(10); + expect(transform.maxPitch = 10).toBe(10); + expect(transform.size.equals(new Point(500, 500))).toBe(true); + expect(transform.centerPoint.equals(new Point(250, 250))).toBe(true); + expect(transform.scaleZoom(0)).toBe(-Infinity); + expect(transform.scaleZoom(10)).toBe(3.3219280948873626); + expect(transform.point).toEqual(new Point(262144, 262144)); + expect(transform.height).toBe(500); + expect(fixedLngLat(transform.pointLocation(new Point(250, 250)))).toEqual({lng: 0, lat: 0}); + expect(fixedCoord(transform.pointCoordinate(new Point(250, 250)))).toEqual({x: 0.5, y: 0.5, z: 0}); + expect(transform.locationPoint(new LngLat(0, 0))).toEqual({x: 250, y: 250}); + expect(transform.locationCoordinate(new LngLat(0, 0))).toEqual({x: 0.5, y: 0.5, z: 0}); + }); + + test('does not throw on bad center', () => { + expect(() => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(500, 500); + transform.center = new LngLat(50, -90); + }).not.toThrow(); + }); + + test('setLocationAt', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(500, 500); + transform.zoom = 4; + expect(transform.center).toEqual({lng: 0, lat: 0}); + transform.setLocationAtPoint(new LngLat(13, 10), new Point(15, 45)); + expect(fixedLngLat(transform.pointLocation(new Point(15, 45)))).toEqual({lng: 13, lat: 10}); + }); + + test('setLocationAt tilted', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(500, 500); + transform.zoom = 4; + transform.pitch = 50; + expect(transform.center).toEqual({lng: 0, lat: 0}); + transform.setLocationAtPoint(new LngLat(13, 10), new Point(15, 45)); + expect(fixedLngLat(transform.pointLocation(new Point(15, 45)))).toEqual({lng: 13, lat: 10}); + }); + + test('has a default zoom', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(500, 500); + expect(transform.tileZoom).toBe(0); + expect(transform.tileZoom).toBe(transform.zoom); + }); + + test('set zoom inits tileZoom with zoom value', () => { + const transform = new Transform(0, 22, 0, 60); + transform.zoom = 5; + expect(transform.tileZoom).toBe(5); + }); + + test('set zoom clamps tileZoom to non negative value ', () => { + const transform = new Transform(-2, 22, 0, 60); + transform.zoom = -2; + expect(transform.tileZoom).toBe(0); + }); + + test('set fov', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.fov = 10; + expect(transform.fov).toBe(10); + transform.fov = 10; + expect(transform.fov).toBe(10); + }); + + test('lngRange & latRange constrain zoom and center', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.center = new LngLat(0, 0); + transform.zoom = 10; + transform.resize(500, 500); + + transform.lngRange = [-5, 5]; + transform.latRange = [-5, 5]; + + transform.zoom = 0; + expect(transform.zoom).toBe(5.1357092861044045); + + transform.center = new LngLat(-50, -30); + expect(transform.center).toEqual(new LngLat(0, -0.0063583052861417855)); + + transform.zoom = 10; + transform.center = new LngLat(-50, -30); + expect(transform.center).toEqual(new LngLat(-4.828338623046875, -4.828969771321582)); + }); + + test('lngRange can constrain zoom and center across meridian', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.center = new LngLat(180, 0); + transform.zoom = 10; + transform.resize(500, 500); + + // equivalent ranges + const lngRanges: [number, number][] = [ + [175, -175], [175, 185], [-185, -175], [-185, 185] + ]; + + for (const lngRange of lngRanges) { + transform.lngRange = lngRange; + transform.latRange = [-5, 5]; + + transform.zoom = 0; + expect(transform.zoom).toBe(5.1357092861044045); + + transform.center = new LngLat(-50, -30); + expect(transform.center).toEqual(new LngLat(180, -0.0063583052861417855)); + + transform.zoom = 10; + transform.center = new LngLat(-50, -30); + expect(transform.center).toEqual(new LngLat(-175.171661376953125, -4.828969771321582)); + + transform.center = new LngLat(230, 0); + expect(transform.center).toEqual(new LngLat(-175.171661376953125, 0)); + + transform.center = new LngLat(130, 0); + expect(transform.center).toEqual(new LngLat(175.171661376953125, 0)); + } + }); + + describe('coveringTiles', () => { + const options = { + minzoom: 1, + maxzoom: 10, + tileSize: 512 + }; + + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(200, 200); + + test('generell', () => { + + // make slightly off center so that sort order is not subject to precision issues + transform.center = new LngLat(-0.01, 0.01); + + transform.zoom = 0; + expect(transform.coveringTiles(options)).toEqual([]); + + transform.zoom = 1; + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(1, 0, 1, 1, 0), + new OverscaledTileID(1, 0, 1, 0, 1), + new OverscaledTileID(1, 0, 1, 1, 1)]); + + transform.zoom = 2.4; + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(2, 0, 2, 1, 1), + new OverscaledTileID(2, 0, 2, 2, 1), + new OverscaledTileID(2, 0, 2, 1, 2), + new OverscaledTileID(2, 0, 2, 2, 2)]); + + transform.zoom = 10; + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(10, 0, 10, 511, 511), + new OverscaledTileID(10, 0, 10, 512, 511), + new OverscaledTileID(10, 0, 10, 511, 512), + new OverscaledTileID(10, 0, 10, 512, 512)]); + + transform.zoom = 11; + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(10, 0, 10, 511, 511), + new OverscaledTileID(10, 0, 10, 512, 511), + new OverscaledTileID(10, 0, 10, 511, 512), + new OverscaledTileID(10, 0, 10, 512, 512)]); + + transform.zoom = 5.1; + transform.pitch = 60.0; + transform.bearing = 32.0; + transform.center = new LngLat(56.90, 48.20); + transform.resize(1024, 768); + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(5, 0, 5, 21, 11), + new OverscaledTileID(5, 0, 5, 20, 11), + new OverscaledTileID(5, 0, 5, 21, 10), + new OverscaledTileID(5, 0, 5, 20, 10), + new OverscaledTileID(5, 0, 5, 21, 12), + new OverscaledTileID(5, 0, 5, 22, 11), + new OverscaledTileID(5, 0, 5, 20, 12), + new OverscaledTileID(5, 0, 5, 22, 10), + new OverscaledTileID(5, 0, 5, 21, 9), + new OverscaledTileID(5, 0, 5, 20, 9), + new OverscaledTileID(5, 0, 5, 22, 9), + new OverscaledTileID(5, 0, 5, 23, 10), + new OverscaledTileID(5, 0, 5, 21, 8), + new OverscaledTileID(5, 0, 5, 20, 8), + new OverscaledTileID(5, 0, 5, 23, 9), + new OverscaledTileID(5, 0, 5, 22, 8), + new OverscaledTileID(5, 0, 5, 23, 8), + new OverscaledTileID(5, 0, 5, 21, 7), + new OverscaledTileID(5, 0, 5, 20, 7), + new OverscaledTileID(5, 0, 5, 24, 9), + new OverscaledTileID(5, 0, 5, 22, 7) + ]); + + transform.zoom = 8; + transform.pitch = 60; + transform.bearing = 45.0; + transform.center = new LngLat(25.02, 60.15); + transform.resize(300, 50); + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(8, 0, 8, 145, 74), + new OverscaledTileID(8, 0, 8, 145, 73), + new OverscaledTileID(8, 0, 8, 146, 74) + ]); + + transform.resize(50, 300); + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(8, 0, 8, 145, 74), + new OverscaledTileID(8, 0, 8, 145, 73), + new OverscaledTileID(8, 0, 8, 146, 74), + new OverscaledTileID(8, 0, 8, 146, 73) + ]); + + transform.zoom = 2; + transform.pitch = 0; + transform.bearing = 0; + transform.resize(300, 300); + }); + + test('calculates tile coverage at w > 0', () => { + transform.center = new LngLat(630.01, 0.01); + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(2, 2, 2, 1, 1), + new OverscaledTileID(2, 2, 2, 1, 2), + new OverscaledTileID(2, 2, 2, 0, 1), + new OverscaledTileID(2, 2, 2, 0, 2) + ]); + }); + + test('calculates tile coverage at w = -1', () => { + transform.center = new LngLat(-360.01, 0.01); + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(2, -1, 2, 1, 1), + new OverscaledTileID(2, -1, 2, 1, 2), + new OverscaledTileID(2, -1, 2, 2, 1), + new OverscaledTileID(2, -1, 2, 2, 2) + ]); + }); + + test('calculates tile coverage across meridian', () => { + transform.zoom = 1; + transform.center = new LngLat(-180.01, 0.01); + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(1, 0, 1, 0, 1), + new OverscaledTileID(1, -1, 1, 1, 0), + new OverscaledTileID(1, -1, 1, 1, 1) + ]); + }); + + test('only includes tiles for a single world, if renderWorldCopies is set to false', () => { + transform.zoom = 1; + transform.center = new LngLat(-180.01, 0.01); + transform.renderWorldCopies = false; + expect(transform.coveringTiles(options)).toEqual([ + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(1, 0, 1, 0, 1) + ]); + }); + + }); + + test('coveringZoomLevel', () => { + const options = { + minzoom: 1, + maxzoom: 10, + tileSize: 512, + roundZoom: false, + }; + + const transform = new Transform(0, 22, 0, 60, true); + + transform.zoom = 0; + expect(transform.coveringZoomLevel(options)).toBe(0); + + transform.zoom = 0.1; + expect(transform.coveringZoomLevel(options)).toBe(0); + + transform.zoom = 1; + expect(transform.coveringZoomLevel(options)).toBe(1); + + transform.zoom = 2.4; + expect(transform.coveringZoomLevel(options)).toBe(2); + + transform.zoom = 10; + expect(transform.coveringZoomLevel(options)).toBe(10); + + transform.zoom = 11; + expect(transform.coveringZoomLevel(options)).toBe(11); + + transform.zoom = 11.5; + expect(transform.coveringZoomLevel(options)).toBe(11); + + options.tileSize = 256; + + transform.zoom = 0; + expect(transform.coveringZoomLevel(options)).toBe(1); + + transform.zoom = 0.1; + expect(transform.coveringZoomLevel(options)).toBe(1); + + transform.zoom = 1; + expect(transform.coveringZoomLevel(options)).toBe(2); + + transform.zoom = 2.4; + expect(transform.coveringZoomLevel(options)).toBe(3); + + transform.zoom = 10; + expect(transform.coveringZoomLevel(options)).toBe(11); + + transform.zoom = 11; + expect(transform.coveringZoomLevel(options)).toBe(12); + + transform.zoom = 11.5; + expect(transform.coveringZoomLevel(options)).toBe(12); + + options.roundZoom = true; + + expect(transform.coveringZoomLevel(options)).toBe(13); + }); + + test('clamps latitude', () => { + const transform = new Transform(0, 22, 0, 60, true); + + expect(transform.project(new LngLat(0, -90))).toEqual(transform.project(new LngLat(0, -transform.maxValidLatitude))); + expect(transform.project(new LngLat(0, 90))).toEqual(transform.project(new LngLat(0, transform.maxValidLatitude))); + }); + + test('clamps pitch', () => { + const transform = new Transform(0, 22, 0, 60, true); + + transform.pitch = 45; + expect(transform.pitch).toBe(45); + + transform.pitch = -10; + expect(transform.pitch).toBe(0); + + transform.pitch = 90; + expect(transform.pitch).toBe(60); + }); + + test('visibleUnwrappedCoordinates', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(200, 200); + transform.zoom = 0; + transform.center = new LngLat(-170.01, 0.01); + + let unwrappedCoords = transform.getVisibleUnwrappedCoordinates(new CanonicalTileID(0, 0, 0)); + expect(unwrappedCoords).toHaveLength(4); + + //getVisibleUnwrappedCoordinates should honor _renderWorldCopies + transform._renderWorldCopies = false; + unwrappedCoords = transform.getVisibleUnwrappedCoordinates(new CanonicalTileID(0, 0, 0)); + expect(unwrappedCoords).toHaveLength(1); + }); + + test('maintains high float precision when calculating matrices', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(200.25, 200.25); + transform.zoom = 20.25; + transform.pitch = 67.25; + transform.center = new LngLat(0.0, 0.0); + transform._calcMatrices(); + + expect(transform.customLayerMatrix()[0].toString().length).toBeGreaterThan(10); + expect(transform.glCoordMatrix[0].toString().length).toBeGreaterThan(10); + expect(transform.maxPitchScaleFactor()).toBeCloseTo(2.366025418080343, 10); + }); + + test('recalcuateZoom', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.elevation = 200; + transform.center = new LngLat(10.0, 50.0); + transform.zoom = 14; + transform.resize(512, 512); + + // expect same values because of no elevation change + const terrain = { + getElevationForLngLatZoom: () => 200, + pointCoordinate: () => null + }; + transform.recalculateZoom(terrain as any); + expect(transform.zoom).toBe(14); + + // expect new zoom because of elevation change + terrain.getElevationForLngLatZoom = () => 400; + transform.recalculateZoom(terrain as any); + expect(transform.zoom).toBe(14.127997275621933); + expect(transform.elevation).toBe(400); + + expect(transform._center.lng).toBe(10.00000000000071); + expect(transform._center.lat).toBe(50.00000000000017); + + // expect new zoom because of elevation change to point below sea level + terrain.getElevationForLngLatZoom = () => -200; + transform.recalculateZoom(terrain as any); + expect(transform.zoom).toBe(13.773740316343467); + expect(transform.elevation).toBe(-200); + }); + + test('pointCoordinate with terrain when returning null should fall back to 2D', () => { + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(500, 500); + const terrain = { + pointCoordinate: () => null + } as any as Terrain; + const coordinate = transform.pointCoordinate(new Point(0, 0), terrain); + + expect(coordinate).toBeDefined(); + }); + + test('horizon', () => { + const transform = new Transform(0, 22, 0, 85, true); + transform.resize(500, 500); + transform.pitch = 75; + const horizon = transform.getHorizon(); + + expect(horizon).toBeCloseTo(170.8176101748407, 10); + }); + + test('getBounds with horizon', () => { + const transform = new Transform(0, 22, 0, 85, true); + transform.resize(500, 500); + + transform.pitch = 60; + expect(transform.getBounds().getNorthWest().toArray()).toStrictEqual(transform.pointLocation(new Point(0, 0)).toArray()); + + transform.pitch = 75; + const top = Math.max(0, transform.height / 2 - transform.getHorizon()); + expect(top).toBeCloseTo(79.1823898251593, 10); + expect(transform.getBounds().getNorthWest().toArray()).toStrictEqual(transform.pointLocation(new Point(0, top)).toArray()); + }); +}); diff --git a/web/libraries/maplibre-gl/src/geo/transform.ts b/web/libraries/maplibre-gl/src/geo/transform.ts new file mode 100644 index 00000000..b2f8ad96 --- /dev/null +++ b/web/libraries/maplibre-gl/src/geo/transform.ts @@ -0,0 +1,958 @@ +import {LngLat} from './lng_lat'; +import {LngLatBounds} from './lng_lat_bounds'; +import {MercatorCoordinate, mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude} from './mercator_coordinate'; +import Point from '@mapbox/point-geometry'; +import {wrap, clamp} from '../util/util'; +import {interpolates} from '@maplibre/maplibre-gl-style-spec'; +import {EXTENT} from '../data/extent'; +import {vec3, vec4, mat4, mat2, vec2} from 'gl-matrix'; +import {Aabb, Frustum} from '../util/primitives'; +import {EdgeInsets} from './edge_insets'; + +import {UnwrappedTileID, OverscaledTileID, CanonicalTileID} from '../source/tile_id'; +import type {PaddingOptions} from './edge_insets'; +import {Terrain} from '../render/terrain'; + +/** + * @internal + * A single transform, generally used for a single tile to be + * scaled, rotated, and zoomed. + */ +export class Transform { + tileSize: number; + tileZoom: number; + lngRange: [number, number]; + latRange: [number, number]; + maxValidLatitude: number; + scale: number; + width: number; + height: number; + angle: number; + rotationMatrix: mat2; + pixelsToGLUnits: [number, number]; + cameraToCenterDistance: number; + mercatorMatrix: mat4; + projMatrix: mat4; + invProjMatrix: mat4; + alignedProjMatrix: mat4; + pixelMatrix: mat4; + pixelMatrix3D: mat4; + pixelMatrixInverse: mat4; + glCoordMatrix: mat4; + labelPlaneMatrix: mat4; + _fov: number; + _pitch: number; + _zoom: number; + _unmodified: boolean; + _renderWorldCopies: boolean; + _minZoom: number; + _maxZoom: number; + _minPitch: number; + _maxPitch: number; + _center: LngLat; + _elevation: number; + _pixelPerMeter: number; + _edgeInsets: EdgeInsets; + _constraining: boolean; + _posMatrixCache: {[_: string]: mat4}; + _alignedPosMatrixCache: {[_: string]: mat4}; + _minEleveationForCurrentTile: number; + + constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean) { + this.tileSize = 512; // constant + this.maxValidLatitude = 85.051129; // constant + + this._renderWorldCopies = renderWorldCopies === undefined ? true : !!renderWorldCopies; + this._minZoom = minZoom || 0; + this._maxZoom = maxZoom || 22; + + this._minPitch = (minPitch === undefined || minPitch === null) ? 0 : minPitch; + this._maxPitch = (maxPitch === undefined || maxPitch === null) ? 60 : maxPitch; + + this.setMaxBounds(); + + this.width = 0; + this.height = 0; + this._center = new LngLat(0, 0); + this._elevation = 0; + this.zoom = 0; + this.angle = 0; + this._fov = 0.6435011087932844; + this._pitch = 0; + this._unmodified = true; + this._edgeInsets = new EdgeInsets(); + this._posMatrixCache = {}; + this._alignedPosMatrixCache = {}; + this._minEleveationForCurrentTile = 0; + } + + clone(): Transform { + const clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies); + clone.apply(this); + return clone; + } + + apply(that: Transform) { + this.tileSize = that.tileSize; + this.latRange = that.latRange; + this.width = that.width; + this.height = that.height; + this._center = that._center; + this._elevation = that._elevation; + this._minEleveationForCurrentTile = that._minEleveationForCurrentTile; + this.zoom = that.zoom; + this.angle = that.angle; + this._fov = that._fov; + this._pitch = that._pitch; + this._unmodified = that._unmodified; + this._edgeInsets = that._edgeInsets.clone(); + this._calcMatrices(); + } + + get minZoom(): number { return this._minZoom; } + set minZoom(zoom: number) { + if (this._minZoom === zoom) return; + this._minZoom = zoom; + this.zoom = Math.max(this.zoom, zoom); + } + + get maxZoom(): number { return this._maxZoom; } + set maxZoom(zoom: number) { + if (this._maxZoom === zoom) return; + this._maxZoom = zoom; + this.zoom = Math.min(this.zoom, zoom); + } + + get minPitch(): number { return this._minPitch; } + set minPitch(pitch: number) { + if (this._minPitch === pitch) return; + this._minPitch = pitch; + this.pitch = Math.max(this.pitch, pitch); + } + + get maxPitch(): number { return this._maxPitch; } + set maxPitch(pitch: number) { + if (this._maxPitch === pitch) return; + this._maxPitch = pitch; + this.pitch = Math.min(this.pitch, pitch); + } + + get renderWorldCopies(): boolean { return this._renderWorldCopies; } + set renderWorldCopies(renderWorldCopies: boolean) { + if (renderWorldCopies === undefined) { + renderWorldCopies = true; + } else if (renderWorldCopies === null) { + renderWorldCopies = false; + } + + this._renderWorldCopies = renderWorldCopies; + } + + get worldSize(): number { + return this.tileSize * this.scale; + } + + get centerOffset(): Point { + return this.centerPoint._sub(this.size._div(2)); + } + + get size(): Point { + return new Point(this.width, this.height); + } + + get bearing(): number { + return -this.angle / Math.PI * 180; + } + set bearing(bearing: number) { + const b = -wrap(bearing, -180, 180) * Math.PI / 180; + if (this.angle === b) return; + this._unmodified = false; + this.angle = b; + this._calcMatrices(); + + // 2x2 matrix for rotating points + this.rotationMatrix = mat2.create(); + mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle); + } + + get pitch(): number { + return this._pitch / Math.PI * 180; + } + set pitch(pitch: number) { + const p = clamp(pitch, this.minPitch, this.maxPitch) / 180 * Math.PI; + if (this._pitch === p) return; + this._unmodified = false; + this._pitch = p; + this._calcMatrices(); + } + + get fov(): number { + return this._fov / Math.PI * 180; + } + set fov(fov: number) { + fov = Math.max(0.01, Math.min(60, fov)); + if (this._fov === fov) return; + this._unmodified = false; + this._fov = fov / 180 * Math.PI; + this._calcMatrices(); + } + + get zoom(): number { return this._zoom; } + set zoom(zoom: number) { + const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom); + if (this._zoom === constrainedZoom) return; + this._unmodified = false; + this._zoom = constrainedZoom; + this.tileZoom = Math.max(0, Math.floor(constrainedZoom)); + this.scale = this.zoomScale(constrainedZoom); + this._constrain(); + this._calcMatrices(); + } + + get center(): LngLat { return this._center; } + set center(center: LngLat) { + if (center.lat === this._center.lat && center.lng === this._center.lng) return; + this._unmodified = false; + this._center = center; + this._constrain(); + this._calcMatrices(); + } + + get elevation(): number { return this._elevation; } + set elevation(elevation: number) { + if (elevation === this._elevation) return; + this._elevation = elevation; + this._constrain(); + this._calcMatrices(); + } + + get padding(): PaddingOptions { return this._edgeInsets.toJSON(); } + set padding(padding: PaddingOptions) { + if (this._edgeInsets.equals(padding)) return; + this._unmodified = false; + //Update edge-insets inplace + this._edgeInsets.interpolate(this._edgeInsets, padding, 1); + this._calcMatrices(); + } + + /** + * The center of the screen in pixels with the top-left corner being (0,0) + * and +y axis pointing downwards. This accounts for padding. + */ + get centerPoint(): Point { + return this._edgeInsets.getCenter(this.width, this.height); + } + + /** + * Returns if the padding params match + * + * @param padding - the padding to check against + * @returns true if they are equal, false otherwise + */ + isPaddingEqual(padding: PaddingOptions): boolean { + return this._edgeInsets.equals(padding); + } + + /** + * Helper method to update edge-insets in place + * + * @param start - the starting padding + * @param target - the target padding + * @param t - the step/weight + */ + interpolatePadding(start: PaddingOptions, target: PaddingOptions, t: number) { + this._unmodified = false; + this._edgeInsets.interpolate(start, target, t); + this._constrain(); + this._calcMatrices(); + } + + /** + * Return a zoom level that will cover all tiles the transform + * @param options - the options + * @returns zoom level An integer zoom level at which all tiles will be visible. + */ + coveringZoomLevel(options: { + /** + * Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored. + */ + roundZoom?: boolean; + /** + * Tile size, expressed in screen pixels. + */ + tileSize: number; + }): number { + const z = (options.roundZoom ? Math.round : Math.floor)( + this.zoom + this.scaleZoom(this.tileSize / options.tileSize) + ); + // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist. + return Math.max(0, z); + } + + /** + * Return any "wrapped" copies of a given tile coordinate that are visible + * in the current view. + */ + getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) { + const result = [new UnwrappedTileID(0, tileID)]; + if (this._renderWorldCopies) { + const utl = this.pointCoordinate(new Point(0, 0)); + const utr = this.pointCoordinate(new Point(this.width, 0)); + const ubl = this.pointCoordinate(new Point(this.width, this.height)); + const ubr = this.pointCoordinate(new Point(0, this.height)); + const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x)); + const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x)); + + // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources. + // Both sources draw outside the tile boundaries of the tile that "contains them" so we need + // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones. + const extraWorldCopy = 1; + + for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) { + if (w === 0) continue; + result.push(new UnwrappedTileID(w, tileID)); + } + } + return result; + } + + /** + * Return all coordinates that could cover this transform for a covering + * zoom level. + * @param options - the options + * @returns OverscaledTileIDs + */ + coveringTiles( + options: { + tileSize: number; + minzoom?: number; + maxzoom?: number; + roundZoom?: boolean; + reparseOverscaled?: boolean; + renderWorldCopies?: boolean; + terrain?: Terrain; + } + ): Array { + let z = this.coveringZoomLevel(options); + const actualZ = z; + + if (options.minzoom !== undefined && z < options.minzoom) return []; + if (options.maxzoom !== undefined && z > options.maxzoom) z = options.maxzoom; + + const cameraCoord = this.pointCoordinate(this.getCameraPoint()); + const centerCoord = MercatorCoordinate.fromLngLat(this.center); + const numTiles = Math.pow(2, z); + const cameraPoint = [numTiles * cameraCoord.x, numTiles * cameraCoord.y, 0]; + const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0]; + const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, z); + + // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level + let minZoom = options.minzoom || 0; + // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks + if (!options.terrain && this.pitch <= 60.0 && this._edgeInsets.top < 0.1) + minZoom = z; + + // There should always be a certain number of maximum zoom level tiles surrounding the center location in 2D or in front of the camera in 3D + const radiusOfMaxLvlLodInTiles = options.terrain ? 2 / Math.min(this.tileSize, options.tileSize) * this.tileSize : 3; + + const newRootTile = (wrap: number): any => { + return { + aabb: new Aabb([wrap * numTiles, 0, 0], [(wrap + 1) * numTiles, numTiles, 0]), + zoom: 0, + x: 0, + y: 0, + wrap, + fullyVisible: false + }; + }; + + // Do a depth-first traversal to find visible tiles and proper levels of detail + const stack = []; + const result = []; + const maxZoom = z; + const overscaledZ = options.reparseOverscaled ? actualZ : z; + + if (this._renderWorldCopies) { + // Render copy of the globe thrice on both sides + for (let i = 1; i <= 3; i++) { + stack.push(newRootTile(-i)); + stack.push(newRootTile(i)); + } + } + + stack.push(newRootTile(0)); + + while (stack.length > 0) { + const it = stack.pop(); + const x = it.x; + const y = it.y; + let fullyVisible = it.fullyVisible; + + // Visibility of a tile is not required if any of its ancestor if fully inside the frustum + if (!fullyVisible) { + const intersectResult = it.aabb.intersects(cameraFrustum); + + if (intersectResult === 0) + continue; + + fullyVisible = intersectResult === 2; + } + + const refPoint = options.terrain ? cameraPoint : centerPoint; + const distanceX = it.aabb.distanceX(refPoint); + const distanceY = it.aabb.distanceY(refPoint); + const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY)); + + // We're using distance based heuristics to determine if a tile should be split into quadrants or not. + // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center. + // Using the fact that a parent node in quadtree is twice the size of its children (per dimension) + // we can define distance thresholds for each relative level: + // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as "offset+2^(k+1)-2" + const distToSplit = radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2; + + // Have we reached the target depth or is the tile too far away to be any split further? + if (it.zoom === maxZoom || (longestDim > distToSplit && it.zoom >= minZoom)) { + const dz = maxZoom - it.zoom, dx = cameraPoint[0] - 0.5 - (x << dz), dy = cameraPoint[1] - 0.5 - (y << dz); + result.push({ + tileID: new OverscaledTileID(it.zoom === maxZoom ? overscaledZ : it.zoom, it.wrap, it.zoom, x, y), + distanceSq: vec2.sqrLen([centerPoint[0] - 0.5 - x, centerPoint[1] - 0.5 - y]), + // this variable is currently not used, but may be important to reduce the amount of loaded tiles + tileDistanceToCamera: Math.sqrt(dx * dx + dy * dy) + }); + continue; + } + + for (let i = 0; i < 4; i++) { + const childX = (x << 1) + (i % 2); + const childY = (y << 1) + (i >> 1); + const childZ = it.zoom + 1; + let quadrant = it.aabb.quadrant(i); + if (options.terrain) { + const tileID = new OverscaledTileID(childZ, it.wrap, childZ, childX, childY); + const minMax = options.terrain.getMinMaxElevation(tileID); + const minElevation = minMax.minElevation ?? this.elevation; + const maxElevation = minMax.maxElevation ?? this.elevation; + quadrant = new Aabb( + [quadrant.min[0], quadrant.min[1], minElevation] as vec3, + [quadrant.max[0], quadrant.max[1], maxElevation] as vec3 + ); + } + stack.push({aabb: quadrant, zoom: childZ, x: childX, y: childY, wrap: it.wrap, fullyVisible}); + } + } + + return result.sort((a, b) => a.distanceSq - b.distanceSq).map(a => a.tileID); + } + + resize(width: number, height: number) { + this.width = width; + this.height = height; + + this.pixelsToGLUnits = [2 / width, -2 / height]; + this._constrain(); + this._calcMatrices(); + } + + get unmodified(): boolean { return this._unmodified; } + + zoomScale(zoom: number) { return Math.pow(2, zoom); } + scaleZoom(scale: number) { return Math.log(scale) / Math.LN2; } + + project(lnglat: LngLat) { + const lat = clamp(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude); + return new Point( + mercatorXfromLng(lnglat.lng) * this.worldSize, + mercatorYfromLat(lat) * this.worldSize); + } + + unproject(point: Point): LngLat { + return new MercatorCoordinate(point.x / this.worldSize, point.y / this.worldSize).toLngLat(); + } + + get point(): Point { return this.project(this.center); } + + /** + * get the camera position in LngLat and altitudes in meter + * @returns An object with lngLat & altitude. + */ + getCameraPosition(): { + lngLat: LngLat; + altitude: number; + } { + const lngLat = this.pointLocation(this.getCameraPoint()); + const altitude = Math.cos(this._pitch) * this.cameraToCenterDistance / this._pixelPerMeter; + return {lngLat, altitude: altitude + this.elevation}; + } + + /** + * This method works in combination with freezeElevation activated. + * freezeElevtion is enabled during map-panning because during this the camera should sit in constant height. + * After panning finished, call this method to recalculate the zoomlevel for the current camera-height in current terrain. + * @param terrain - the terrain + */ + recalculateZoom(terrain: Terrain) { + // find position the camera is looking on + const center = this.pointLocation(this.centerPoint, terrain); + const elevation = terrain.getElevationForLngLatZoom(center, this.tileZoom); + const deltaElevation = this.elevation - elevation; + if (!deltaElevation) return; + + // calculate mercator distance between camera & target + const cameraPosition = this.getCameraPosition(); + const camera = MercatorCoordinate.fromLngLat(cameraPosition.lngLat, cameraPosition.altitude); + const target = MercatorCoordinate.fromLngLat(center, elevation); + const dx = camera.x - target.x, dy = camera.y - target.y, dz = camera.z - target.z; + const distance = Math.sqrt(dx * dx + dy * dy + dz * dz); + + // from this distance we calculate the new zoomlevel + const zoom = this.scaleZoom(this.cameraToCenterDistance / distance / this.tileSize); + + // update matrices + this._elevation = elevation; + this._center = center; + this.zoom = zoom; + } + + setLocationAtPoint(lnglat: LngLat, point: Point) { + const a = this.pointCoordinate(point); + const b = this.pointCoordinate(this.centerPoint); + const loc = this.locationCoordinate(lnglat); + const newCenter = new MercatorCoordinate( + loc.x - (a.x - b.x), + loc.y - (a.y - b.y)); + this.center = this.coordinateLocation(newCenter); + if (this._renderWorldCopies) { + this.center = this.center.wrap(); + } + } + + /** + * Given a location, return the screen point that corresponds to it + * @param lnglat - location + * @param terrain - optional terrain + * @returns screen point + */ + locationPoint(lnglat: LngLat, terrain?: Terrain): Point { + return terrain ? + this.coordinatePoint(this.locationCoordinate(lnglat), terrain.getElevationForLngLatZoom(lnglat, this.tileZoom), this.pixelMatrix3D) : + this.coordinatePoint(this.locationCoordinate(lnglat)); + } + + /** + * Given a point on screen, return its lnglat + * @param p - screen point + * @param terrain - optional terrain + * @returns lnglat location + */ + pointLocation(p: Point, terrain?: Terrain): LngLat { + return this.coordinateLocation(this.pointCoordinate(p, terrain)); + } + + /** + * Given a geographical lnglat, return an unrounded + * coordinate that represents it at this transform's zoom level. + * @param lnglat - the location + * @returns The mercator coordinate + */ + locationCoordinate(lnglat: LngLat): MercatorCoordinate { + return MercatorCoordinate.fromLngLat(lnglat); + } + + /** + * Given a Coordinate, return its geographical position. + * @param coord - mercator coordivates + * @returns lng and lat + */ + coordinateLocation(coord: MercatorCoordinate): LngLat { + return coord && coord.toLngLat(); + } + + /** + * Given a Point, return its mercator coordinate. + * @param p - the point + * @param terrain - optional terrain + * @returns lnglat + */ + pointCoordinate(p: Point, terrain?: Terrain): MercatorCoordinate { + // get point-coordinate from terrain coordinates framebuffer + if (terrain) { + const coordinate = terrain.pointCoordinate(p); + if (coordinate != null) { + return coordinate; + } + } + + // calculate point-coordinate on flat earth + const targetZ = 0; + // since we don't know the correct projected z value for the point, + // unproject two points to get a line and then find the point on that + // line with z=0 + + const coord0 = [p.x, p.y, 0, 1] as any; + const coord1 = [p.x, p.y, 1, 1] as any; + + vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse); + vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse); + + const w0 = coord0[3]; + const w1 = coord1[3]; + const x0 = coord0[0] / w0; + const x1 = coord1[0] / w1; + const y0 = coord0[1] / w0; + const y1 = coord1[1] / w1; + const z0 = coord0[2] / w0; + const z1 = coord1[2] / w1; + + const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0); + + return new MercatorCoordinate( + interpolates.number(x0, x1, t) / this.worldSize, + interpolates.number(y0, y1, t) / this.worldSize); + } + + /** + * Given a coordinate, return the screen point that corresponds to it + * @param coord - the coordinates + * @param elevation - the elevation + * @param pixelMatrix - the pixel matrix + * @returns screen point + */ + coordinatePoint(coord: MercatorCoordinate, elevation: number = 0, pixelMatrix = this.pixelMatrix): Point { + const p = [coord.x * this.worldSize, coord.y * this.worldSize, elevation, 1] as any; + vec4.transformMat4(p, p, pixelMatrix); + return new Point(p[0] / p[3], p[1] / p[3]); + } + + /** + * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not + * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. + * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds. + */ + getBounds(): LngLatBounds { + const top = Math.max(0, this.height / 2 - this.getHorizon()); + return new LngLatBounds() + .extend(this.pointLocation(new Point(0, top))) + .extend(this.pointLocation(new Point(this.width, top))) + .extend(this.pointLocation(new Point(this.width, this.height))) + .extend(this.pointLocation(new Point(0, this.height))); + } + + /** + * Returns the maximum geographical bounds the map is constrained to, or `null` if none set. + * @returns max bounds + */ + getMaxBounds(): LngLatBounds | null { + if (!this.latRange || this.latRange.length !== 2 || + !this.lngRange || this.lngRange.length !== 2) return null; + + return new LngLatBounds([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]); + } + + /** + * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2), + * multiplied by a static factor to simulate the earth-radius. + * The calculated value is the horizontal line from the camera-height to sea-level. + * @returns Horizon above center in pixels. + */ + getHorizon(): number { + return Math.tan(Math.PI / 2 - this._pitch) * this.cameraToCenterDistance * 0.85; + } + + /** + * Sets or clears the map's geographical constraints. + * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map. + */ + setMaxBounds(bounds?: LngLatBounds | null) { + if (bounds) { + this.lngRange = [bounds.getWest(), bounds.getEast()]; + this.latRange = [bounds.getSouth(), bounds.getNorth()]; + this._constrain(); + } else { + this.lngRange = null; + this.latRange = [-this.maxValidLatitude, this.maxValidLatitude]; + } + } + + /** + * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map. + * @param unwrappedTileID - the tile ID + */ + calculatePosMatrix(unwrappedTileID: UnwrappedTileID, aligned: boolean = false): mat4 { + const posMatrixKey = unwrappedTileID.key; + const cache = aligned ? this._alignedPosMatrixCache : this._posMatrixCache; + if (cache[posMatrixKey]) { + return cache[posMatrixKey]; + } + + const canonical = unwrappedTileID.canonical; + const scale = this.worldSize / this.zoomScale(canonical.z); + const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap; + + const posMatrix = mat4.identity(new Float64Array(16) as any); + mat4.translate(posMatrix, posMatrix, [unwrappedX * scale, canonical.y * scale, 0]); + mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]); + mat4.multiply(posMatrix, aligned ? this.alignedProjMatrix : this.projMatrix, posMatrix); + + cache[posMatrixKey] = new Float32Array(posMatrix); + return cache[posMatrixKey]; + } + + customLayerMatrix(): mat4 { + return this.mercatorMatrix.slice() as any; + } + + _constrain() { + if (!this.center || !this.width || !this.height || this._constraining) return; + + this._constraining = true; + + let minY = -90; + let maxY = 90; + let minX = -180; + let maxX = 180; + let sy, sx, x2, y2; + const size = this.size, + unmodified = this._unmodified; + + if (this.latRange) { + const latRange = this.latRange; + minY = mercatorYfromLat(latRange[1]) * this.worldSize; + maxY = mercatorYfromLat(latRange[0]) * this.worldSize; + sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0; + } + + if (this.lngRange) { + const lngRange = this.lngRange; + + minX = wrap( + mercatorXfromLng(lngRange[0]) * this.worldSize, + 0, + this.worldSize + ); + maxX = wrap( + mercatorXfromLng(lngRange[1]) * this.worldSize, + 0, + this.worldSize + ); + + if (maxX < minX) maxX += this.worldSize; + + sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0; + } + + const point = this.point; + + // how much the map should scale to fit the screen into given latitude/longitude ranges + const s = Math.max(sx || 0, sy || 0); + + if (s) { + this.center = this.unproject(new Point( + sx ? (maxX + minX) / 2 : point.x, + sy ? (maxY + minY) / 2 : point.y)); + this.zoom += this.scaleZoom(s); + this._unmodified = unmodified; + this._constraining = false; + return; + } + + if (this.latRange) { + const y = point.y, + h2 = size.y / 2; + + if (y - h2 < minY) y2 = minY + h2; + if (y + h2 > maxY) y2 = maxY - h2; + } + + if (this.lngRange) { + const centerX = (minX + maxX) / 2; + const x = wrap(point.x, centerX - this.worldSize / 2, centerX + this.worldSize / 2); + const w2 = size.x / 2; + + if (x - w2 < minX) x2 = minX + w2; + if (x + w2 > maxX) x2 = maxX - w2; + } + + // pan the map if the screen goes off the range + if (x2 !== undefined || y2 !== undefined) { + this.center = this.unproject(new Point( + x2 !== undefined ? x2 : point.x, + y2 !== undefined ? y2 : point.y)).wrap(); + } + + this._unmodified = unmodified; + this._constraining = false; + } + + _calcMatrices() { + if (!this.height) return; + + const halfFov = this._fov / 2; + const offset = this.centerOffset; + const x = this.point.x, y = this.point.y; + this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height; + this._pixelPerMeter = mercatorZfromAltitude(1, this.center.lat) * this.worldSize; + + let m = mat4.identity(new Float64Array(16) as any); + mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]); + mat4.translate(m, m, [1, -1, 0]); + this.labelPlaneMatrix = m; + + m = mat4.identity(new Float64Array(16) as any); + mat4.scale(m, m, [1, -1, 1]); + mat4.translate(m, m, [-1, -1, 0]); + mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]); + this.glCoordMatrix = m; + + // Calculate the camera to sea-level distance in pixel in respect of terrain + const cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch); + // In case of negative minimum elevation (e.g. the dead see, under the sea maps) use a lower plane for calculation + const minElevation = Math.min(this.elevation, this._minEleveationForCurrentTile); + const cameraToLowestPointDistance = cameraToSeaLevelDistance - minElevation * this._pixelPerMeter / Math.cos(this._pitch); + const lowestPlane = minElevation < 0 ? cameraToLowestPointDistance : cameraToSeaLevelDistance; + + // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the + // center top point [width/2 + offset.x, 0] in Z units, using the law of sines. + // 1 Z unit is equivalent to 1 horizontal px at the center of the map + // (the distance between[width/2, height/2] and [width/2 + 1, height/2]) + const groundAngle = Math.PI / 2 + this._pitch; + const fovAboveCenter = this._fov * (0.5 + offset.y / this.height); + const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01)); + + // Find the distance from the center point to the horizon + const horizon = this.getHorizon(); + const horizonAngle = Math.atan(horizon / this.cameraToCenterDistance); + const fovCenterToHorizon = 2 * horizonAngle * (0.5 + offset.y / (horizon * 2)); + const topHalfSurfaceDistanceHorizon = Math.sin(fovCenterToHorizon) * lowestPlane / Math.sin(clamp(Math.PI - groundAngle - fovCenterToHorizon, 0.01, Math.PI - 0.01)); + + // Calculate z distance of the farthest fragment that should be rendered. + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + const topHalfMinDistance = Math.min(topHalfSurfaceDistance, topHalfSurfaceDistanceHorizon); + const farZ = (Math.cos(Math.PI / 2 - this._pitch) * topHalfMinDistance + lowestPlane) * 1.01; + + // The larger the value of nearZ is + // - the more depth precision is available for features (good) + // - clipping starts appearing sooner when the camera is close to 3d features (bad) + // + // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues + // when rendering it's layers using custom layers. This value was experimentally chosen and + // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera. + const nearZ = this.height / 50; + + // matrix for conversion from location to GL coordinates (-1 .. 1) + m = new Float64Array(16) as any; + mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ); + + // Apply center of perspective offset + m[8] = -offset.x * 2 / this.width; + m[9] = offset.y * 2 / this.height; + + mat4.scale(m, m, [1, -1, 1]); + mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]); + mat4.rotateX(m, m, this._pitch); + mat4.rotateZ(m, m, this.angle); + mat4.translate(m, m, [-x, -y, 0]); + + // The mercatorMatrix can be used to transform points from mercator coordinates + // ([0, 0] nw, [1, 1] se) to GL coordinates. + this.mercatorMatrix = mat4.scale([] as any, m, [this.worldSize, this.worldSize, this.worldSize]); + + // scale vertically to meters per pixel (inverse of ground resolution): + mat4.scale(m, m, [1, 1, this._pixelPerMeter]); + + // matrix for conversion from location to screen coordinates in 2D + this.pixelMatrix = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m); + + // matrix for conversion from location to GL coordinates (-1 .. 1) + mat4.translate(m, m, [0, 0, -this.elevation]); // elevate camera over terrain + this.projMatrix = m; + this.invProjMatrix = mat4.invert([] as any, m); + + // matrix for conversion from location to screen coordinates in 2D + this.pixelMatrix3D = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m); + + // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles. + // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional + // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension + // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle + // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that + // it is always <= 0.5 pixels. + const xShift = (this.width % 2) / 2, yShift = (this.height % 2) / 2, + angleCos = Math.cos(this.angle), angleSin = Math.sin(this.angle), + dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift, + dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift; + const alignedM = new Float64Array(m) as any as mat4; + mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]); + this.alignedProjMatrix = alignedM; + + // inverse matrix for conversion from screen coordinaes to location + m = mat4.invert(new Float64Array(16) as any, this.pixelMatrix); + if (!m) throw new Error('failed to invert matrix'); + this.pixelMatrixInverse = m; + + this._posMatrixCache = {}; + this._alignedPosMatrixCache = {}; + } + + maxPitchScaleFactor() { + // calcMatrices hasn't run yet + if (!this.pixelMatrixInverse) return 1; + + const coord = this.pointCoordinate(new Point(0, 0)); + const p = [coord.x * this.worldSize, coord.y * this.worldSize, 0, 1] as vec4; + const topPoint = vec4.transformMat4(p, p, this.pixelMatrix); + return topPoint[3] / this.cameraToCenterDistance; + } + + /** + * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation` + * as the name for the location under the camera and on the surface of the earth (lng, lat, 0). + * `cameraPoint` is the projected position of the `cameraLocation`. + * + * This point is useful to us because only fill-extrusions that are between `cameraPoint` and + * the query point on the surface of the earth can extend and intersect the query. + * + * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because + * the camera is right above the center of the map. + */ + getCameraPoint() { + const pitch = this._pitch; + const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1); + return this.centerPoint.add(new Point(0, yOffset)); + } + + /** + * When the map is pitched, some of the 3D features that intersect a query will not intersect + * the query at the surface of the earth. Instead the feature may be closer and only intersect + * the query because it extrudes into the air. + * @param queryGeometry - For point queries, the line from the query point to the "camera point", + * for other geometries, the envelope of the query geometry and the "camera point" + * @returns a geometry that includes all of the original query as well as all possible ares of the + * screen where the *base* of a visible extrusion could be. + * + */ + getCameraQueryGeometry(queryGeometry: Array): Array { + const c = this.getCameraPoint(); + + if (queryGeometry.length === 1) { + return [queryGeometry[0], c]; + } else { + let minX = c.x; + let minY = c.y; + let maxX = c.x; + let maxY = c.y; + for (const p of queryGeometry) { + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + return [ + new Point(minX, minY), + new Point(maxX, minY), + new Point(maxX, maxY), + new Point(minX, maxY), + new Point(minX, minY) + ]; + } + } +} diff --git a/web/libraries/maplibre-gl/src/gl/color_mode.ts b/web/libraries/maplibre-gl/src/gl/color_mode.ts new file mode 100644 index 00000000..2e32c577 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/color_mode.ts @@ -0,0 +1,31 @@ +import {Color} from '@maplibre/maplibre-gl-style-spec'; + +import type {BlendFuncType, ColorMaskType} from './types'; + +const ZERO = 0x0000; +const ONE = 0x0001; +const ONE_MINUS_SRC_ALPHA = 0x0303; + +export class ColorMode { + blendFunction: BlendFuncType; + blendColor: Color; + mask: ColorMaskType; + + constructor(blendFunction: BlendFuncType, blendColor: Color, mask: ColorMaskType) { + this.blendFunction = blendFunction; + this.blendColor = blendColor; + this.mask = mask; + } + + static Replace: BlendFuncType; + + static disabled: Readonly; + static unblended: Readonly; + static alphaBlended: Readonly; +} + +ColorMode.Replace = [ONE, ZERO]; + +ColorMode.disabled = new ColorMode(ColorMode.Replace, Color.transparent, [false, false, false, false]); +ColorMode.unblended = new ColorMode(ColorMode.Replace, Color.transparent, [true, true, true, true]); +ColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [true, true, true, true]); diff --git a/web/libraries/maplibre-gl/src/gl/context.ts b/web/libraries/maplibre-gl/src/gl/context.ts new file mode 100644 index 00000000..aa3749ae --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/context.ts @@ -0,0 +1,321 @@ +import {IndexBuffer} from './index_buffer'; + +import {VertexBuffer} from './vertex_buffer'; +import {Framebuffer} from './framebuffer'; +import {DepthMode} from './depth_mode'; +import {StencilMode} from './stencil_mode'; +import {ColorMode} from './color_mode'; +import {CullFaceMode} from './cull_face_mode'; +import {deepEqual} from '../util/util'; +import {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, BlendEquation, CullFace, CullFaceSide, FrontFace, ProgramValue, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArray, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha, PixelStoreUnpackFlipY} from './value'; + +import type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type'; +import type { + StructArray, + StructArrayMember +} from '../util/struct_array'; +import type {Color} from '@maplibre/maplibre-gl-style-spec'; +import {isWebGL2} from './webgl2'; + +type ClearArgs = { + color?: Color; + depth?: number; + stencil?: number; +}; + +/** + * @internal + * A webgl wrapper class to allow injection, mocking and abstaction + */ +export class Context { + gl: WebGLRenderingContext | WebGL2RenderingContext; + + currentNumAttributes: number; + maxTextureSize: number; + + clearColor: ClearColor; + clearDepth: ClearDepth; + clearStencil: ClearStencil; + colorMask: ColorMask; + depthMask: DepthMask; + stencilMask: StencilMask; + stencilFunc: StencilFunc; + stencilOp: StencilOp; + stencilTest: StencilTest; + depthRange: DepthRange; + depthTest: DepthTest; + depthFunc: DepthFunc; + blend: Blend; + blendFunc: BlendFunc; + blendColor: BlendColor; + blendEquation: BlendEquation; + cullFace: CullFace; + cullFaceSide: CullFaceSide; + frontFace: FrontFace; + program: ProgramValue; + activeTexture: ActiveTextureUnit; + viewport: Viewport; + bindFramebuffer: BindFramebuffer; + bindRenderbuffer: BindRenderbuffer; + bindTexture: BindTexture; + bindVertexBuffer: BindVertexBuffer; + bindElementBuffer: BindElementBuffer; + bindVertexArray: BindVertexArray; + pixelStoreUnpack: PixelStoreUnpack; + pixelStoreUnpackPremultiplyAlpha: PixelStoreUnpackPremultiplyAlpha; + pixelStoreUnpackFlipY: PixelStoreUnpackFlipY; + + // eslint-disable-next-line camelcase + extTextureFilterAnisotropic: EXT_texture_filter_anisotropic | null; + extTextureFilterAnisotropicMax?: GLfloat; + HALF_FLOAT?: GLenum; + RGBA16F?: GLenum; + RGB16F?: GLenum; + + constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) { + this.gl = gl; + this.clearColor = new ClearColor(this); + this.clearDepth = new ClearDepth(this); + this.clearStencil = new ClearStencil(this); + this.colorMask = new ColorMask(this); + this.depthMask = new DepthMask(this); + this.stencilMask = new StencilMask(this); + this.stencilFunc = new StencilFunc(this); + this.stencilOp = new StencilOp(this); + this.stencilTest = new StencilTest(this); + this.depthRange = new DepthRange(this); + this.depthTest = new DepthTest(this); + this.depthFunc = new DepthFunc(this); + this.blend = new Blend(this); + this.blendFunc = new BlendFunc(this); + this.blendColor = new BlendColor(this); + this.blendEquation = new BlendEquation(this); + this.cullFace = new CullFace(this); + this.cullFaceSide = new CullFaceSide(this); + this.frontFace = new FrontFace(this); + this.program = new ProgramValue(this); + this.activeTexture = new ActiveTextureUnit(this); + this.viewport = new Viewport(this); + this.bindFramebuffer = new BindFramebuffer(this); + this.bindRenderbuffer = new BindRenderbuffer(this); + this.bindTexture = new BindTexture(this); + this.bindVertexBuffer = new BindVertexBuffer(this); + this.bindElementBuffer = new BindElementBuffer(this); + this.bindVertexArray = new BindVertexArray(this); + this.pixelStoreUnpack = new PixelStoreUnpack(this); + this.pixelStoreUnpackPremultiplyAlpha = new PixelStoreUnpackPremultiplyAlpha(this); + this.pixelStoreUnpackFlipY = new PixelStoreUnpackFlipY(this); + + this.extTextureFilterAnisotropic = ( + gl.getExtension('EXT_texture_filter_anisotropic') || + gl.getExtension('MOZ_EXT_texture_filter_anisotropic') || + gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') + ); + + if (this.extTextureFilterAnisotropic) { + this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT); + } + + this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + + if (isWebGL2(gl)) { + this.HALF_FLOAT = gl.HALF_FLOAT; + const extColorBufferHalfFloat = gl.getExtension('EXT_color_buffer_half_float'); + this.RGBA16F = gl.RGBA16F ?? extColorBufferHalfFloat?.RGBA16F_EXT; + this.RGB16F = gl.RGB16F ?? extColorBufferHalfFloat?.RGB16F_EXT; + gl.getExtension('EXT_color_buffer_float'); + } else { + gl.getExtension('EXT_color_buffer_half_float'); + gl.getExtension('OES_texture_half_float_linear'); + const extTextureHalfFloat = gl.getExtension('OES_texture_half_float'); + this.HALF_FLOAT = extTextureHalfFloat?.HALF_FLOAT_OES; + } + } + + setDefault() { + this.unbindVAO(); + + this.clearColor.setDefault(); + this.clearDepth.setDefault(); + this.clearStencil.setDefault(); + this.colorMask.setDefault(); + this.depthMask.setDefault(); + this.stencilMask.setDefault(); + this.stencilFunc.setDefault(); + this.stencilOp.setDefault(); + this.stencilTest.setDefault(); + this.depthRange.setDefault(); + this.depthTest.setDefault(); + this.depthFunc.setDefault(); + this.blend.setDefault(); + this.blendFunc.setDefault(); + this.blendColor.setDefault(); + this.blendEquation.setDefault(); + this.cullFace.setDefault(); + this.cullFaceSide.setDefault(); + this.frontFace.setDefault(); + this.program.setDefault(); + this.activeTexture.setDefault(); + this.bindFramebuffer.setDefault(); + this.pixelStoreUnpack.setDefault(); + this.pixelStoreUnpackPremultiplyAlpha.setDefault(); + this.pixelStoreUnpackFlipY.setDefault(); + } + + setDirty() { + this.clearColor.dirty = true; + this.clearDepth.dirty = true; + this.clearStencil.dirty = true; + this.colorMask.dirty = true; + this.depthMask.dirty = true; + this.stencilMask.dirty = true; + this.stencilFunc.dirty = true; + this.stencilOp.dirty = true; + this.stencilTest.dirty = true; + this.depthRange.dirty = true; + this.depthTest.dirty = true; + this.depthFunc.dirty = true; + this.blend.dirty = true; + this.blendFunc.dirty = true; + this.blendColor.dirty = true; + this.blendEquation.dirty = true; + this.cullFace.dirty = true; + this.cullFaceSide.dirty = true; + this.frontFace.dirty = true; + this.program.dirty = true; + this.activeTexture.dirty = true; + this.viewport.dirty = true; + this.bindFramebuffer.dirty = true; + this.bindRenderbuffer.dirty = true; + this.bindTexture.dirty = true; + this.bindVertexBuffer.dirty = true; + this.bindElementBuffer.dirty = true; + this.bindVertexArray.dirty = true; + this.pixelStoreUnpack.dirty = true; + this.pixelStoreUnpackPremultiplyAlpha.dirty = true; + this.pixelStoreUnpackFlipY.dirty = true; + } + + createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) { + return new IndexBuffer(this, array, dynamicDraw); + } + + createVertexBuffer(array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) { + return new VertexBuffer(this, array, attributes, dynamicDraw); + } + + createRenderbuffer(storageFormat: number, width: number, height: number) { + const gl = this.gl; + + const rbo = gl.createRenderbuffer(); + this.bindRenderbuffer.set(rbo); + gl.renderbufferStorage(gl.RENDERBUFFER, storageFormat, width, height); + this.bindRenderbuffer.set(null); + + return rbo; + } + + createFramebuffer(width: number, height: number, hasDepth: boolean, hasStencil: boolean) { + return new Framebuffer(this, width, height, hasDepth, hasStencil); + } + + clear({ + color, + depth, + stencil + }: ClearArgs) { + const gl = this.gl; + let mask = 0; + + if (color) { + mask |= gl.COLOR_BUFFER_BIT; + this.clearColor.set(color); + this.colorMask.set([true, true, true, true]); + } + + if (typeof depth !== 'undefined') { + mask |= gl.DEPTH_BUFFER_BIT; + + // Workaround for platforms where clearDepth doesn't seem to work + // without resetting the depthRange. See https://github.com/mapbox/mapbox-gl-js/issues/3437 + this.depthRange.set([0, 1]); + + this.clearDepth.set(depth); + this.depthMask.set(true); + } + + if (typeof stencil !== 'undefined') { + mask |= gl.STENCIL_BUFFER_BIT; + this.clearStencil.set(stencil); + this.stencilMask.set(0xFF); + } + + gl.clear(mask); + } + + setCullFace(cullFaceMode: Readonly) { + if (cullFaceMode.enable === false) { + this.cullFace.set(false); + } else { + this.cullFace.set(true); + this.cullFaceSide.set(cullFaceMode.mode); + this.frontFace.set(cullFaceMode.frontFace); + } + } + + setDepthMode(depthMode: Readonly) { + if (depthMode.func === this.gl.ALWAYS && !depthMode.mask) { + this.depthTest.set(false); + } else { + this.depthTest.set(true); + this.depthFunc.set(depthMode.func); + this.depthMask.set(depthMode.mask); + this.depthRange.set(depthMode.range); + } + } + + setStencilMode(stencilMode: Readonly) { + if (stencilMode.test.func === this.gl.ALWAYS && !stencilMode.mask) { + this.stencilTest.set(false); + } else { + this.stencilTest.set(true); + this.stencilMask.set(stencilMode.mask); + this.stencilOp.set([stencilMode.fail, stencilMode.depthFail, stencilMode.pass]); + this.stencilFunc.set({ + func: stencilMode.test.func, + ref: stencilMode.ref, + mask: stencilMode.test.mask + }); + } + } + + setColorMode(colorMode: Readonly) { + if (deepEqual(colorMode.blendFunction, ColorMode.Replace)) { + this.blend.set(false); + } else { + this.blend.set(true); + this.blendFunc.set(colorMode.blendFunction); + this.blendColor.set(colorMode.blendColor); + } + + this.colorMask.set(colorMode.mask); + } + + createVertexArray(): WebGLVertexArrayObject | undefined { + if (isWebGL2(this.gl)) + return this.gl.createVertexArray(); + return this.gl.getExtension('OES_vertex_array_object')?.createVertexArrayOES(); + } + + deleteVertexArray(x: WebGLVertexArrayObject | undefined) { + if (isWebGL2(this.gl)) + return this.gl.deleteVertexArray(x); + return this.gl.getExtension('OES_vertex_array_object')?.deleteVertexArrayOES(x); + } + + unbindVAO() { + // Unbinding the VAO prevents other things (custom layers, new buffer creation) from + // unintentionally changing the state of the last VAO used. + this.bindVertexArray.set(null); + } +} diff --git a/web/libraries/maplibre-gl/src/gl/cull_face_mode.ts b/web/libraries/maplibre-gl/src/gl/cull_face_mode.ts new file mode 100644 index 00000000..4bd679a2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/cull_face_mode.ts @@ -0,0 +1,22 @@ +import type {CullFaceModeType, FrontFaceType} from './types'; + +const BACK = 0x0405; +const CCW = 0x0901; + +export class CullFaceMode { + enable: boolean; + mode: CullFaceModeType; + frontFace: FrontFaceType; + + constructor(enable: boolean, mode: CullFaceModeType, frontFace: FrontFaceType) { + this.enable = enable; + this.mode = mode; + this.frontFace = frontFace; + } + + static disabled: Readonly; + static backCCW: Readonly; +} + +CullFaceMode.disabled = new CullFaceMode(false, BACK, CCW); +CullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW); diff --git a/web/libraries/maplibre-gl/src/gl/depth_mode.ts b/web/libraries/maplibre-gl/src/gl/depth_mode.ts new file mode 100644 index 00000000..f24ad301 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/depth_mode.ts @@ -0,0 +1,26 @@ +import type {DepthFuncType, DepthMaskType, DepthRangeType} from './types'; + +const ALWAYS = 0x0207; + +export class DepthMode { + func: DepthFuncType; + mask: DepthMaskType; + range: DepthRangeType; + + // DepthMask enums + static ReadOnly: boolean; + static ReadWrite: boolean; + + constructor(depthFunc: DepthFuncType, depthMask: DepthMaskType, depthRange: DepthRangeType) { + this.func = depthFunc; + this.mask = depthMask; + this.range = depthRange; + } + + static disabled: Readonly; +} + +DepthMode.ReadOnly = false; +DepthMode.ReadWrite = true; + +DepthMode.disabled = new DepthMode(ALWAYS, DepthMode.ReadOnly, [0, 1]); diff --git a/web/libraries/maplibre-gl/src/gl/framebuffer.ts b/web/libraries/maplibre-gl/src/gl/framebuffer.ts new file mode 100644 index 00000000..384d48b9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/framebuffer.ts @@ -0,0 +1,48 @@ +import {ColorAttachment, DepthAttachment, DepthStencilAttachment} from './value'; + +import type {Context} from './context'; + +/** + * @internal + * A framebuffer holder object + */ +export class Framebuffer { + context: Context; + width: number; + height: number; + framebuffer: WebGLFramebuffer; + colorAttachment: ColorAttachment; + depthAttachment: DepthAttachment; + + constructor(context: Context, width: number, height: number, hasDepth: boolean, hasStencil: boolean) { + this.context = context; + this.width = width; + this.height = height; + const gl = context.gl; + const fbo = this.framebuffer = gl.createFramebuffer(); + + this.colorAttachment = new ColorAttachment(context, fbo); + if (hasDepth) { + this.depthAttachment = hasStencil ? new DepthStencilAttachment(context, fbo) : new DepthAttachment(context, fbo); + } else if (hasStencil) { + throw new Error('Stencil cannot be setted without depth'); + } + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) { + throw new Error('Framebuffer is not complete'); + } + } + + destroy() { + const gl = this.context.gl; + + const texture = this.colorAttachment.get(); + if (texture) gl.deleteTexture(texture); + + if (this.depthAttachment) { + const renderbuffer = this.depthAttachment.get(); + if (renderbuffer) gl.deleteRenderbuffer(renderbuffer); + } + + gl.deleteFramebuffer(this.framebuffer); + } +} diff --git a/web/libraries/maplibre-gl/src/gl/index_buffer.ts b/web/libraries/maplibre-gl/src/gl/index_buffer.ts new file mode 100644 index 00000000..f15580b7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/index_buffer.ts @@ -0,0 +1,55 @@ + +import type {StructArray} from '../util/struct_array'; +import type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type'; +import type {Context} from '../gl/context'; + +/** + * @internal + * an index buffer class + */ +export class IndexBuffer { + context: Context; + buffer: WebGLBuffer; + dynamicDraw: boolean; + + constructor(context: Context, array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean) { + this.context = context; + const gl = context.gl; + this.buffer = gl.createBuffer(); + this.dynamicDraw = Boolean(dynamicDraw); + + // The bound index buffer is part of vertex array object state. We don't want to + // modify whatever VAO happens to be currently bound, so make sure the default + // vertex array provided by the context is bound instead. + this.context.unbindVAO(); + + context.bindElementBuffer.set(this.buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW); + + if (!this.dynamicDraw) { + delete array.arrayBuffer; + } + } + + bind() { + this.context.bindElementBuffer.set(this.buffer); + } + + updateData(array: StructArray) { + const gl = this.context.gl; + if (!this.dynamicDraw) throw new Error('Attempted to update data while not in dynamic mode.'); + // The right VAO will get this buffer re-bound later in VertexArrayObject#bind + // See https://github.com/mapbox/mapbox-gl-js/issues/5620 + this.context.unbindVAO(); + this.bind(); + gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, array.arrayBuffer); + } + + destroy() { + const gl = this.context.gl; + if (this.buffer) { + gl.deleteBuffer(this.buffer); + delete this.buffer; + } + } +} diff --git a/web/libraries/maplibre-gl/src/gl/render_pool.test.ts b/web/libraries/maplibre-gl/src/gl/render_pool.test.ts new file mode 100644 index 00000000..067b4094 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/render_pool.test.ts @@ -0,0 +1,67 @@ +import {Context} from './context'; +import {RenderPool} from './render_pool'; +import gl from 'gl'; + +describe('render pool', () => { + const POOL_SIZE = 3; + + function createAndFillPool(): RenderPool { + const pool = new RenderPool(new Context(gl(1, 1) as any), POOL_SIZE, 512); + for (let i = 0; i < POOL_SIZE; i++) { + pool.useObject(pool.getOrCreateFreeObject()); + } + return pool; + } + + test('create pool should not be full', () => { + const pool = new RenderPool(new Context(gl(1, 1) as any), POOL_SIZE, 512); + expect(pool.isFull()).toBeFalsy(); + }); + + test('create pool should be full', () => { + const pool = createAndFillPool(); + expect(() => pool.getOrCreateFreeObject()).toThrow('No free RenderPool available, call freeAllObjects() required!'); + }); + + test('create pool and fill it', () => { + const pool = createAndFillPool(); + expect(pool.isFull()).toBeTruthy(); + }); + + test('check recently used after using two objects', () => { + const pool = createAndFillPool(); + pool.freeAllObjects(); + const obj0 = pool.getObjectForId(0); + pool.useObject(obj0); + pool.freeAllObjects(); + const obj1 = pool.getOrCreateFreeObject(); + expect(obj1.id).toBe(1); + }); + + test('not full after freeing an object', () => { + const pool = createAndFillPool(); + const obj = pool.getObjectForId(0); + pool.freeObject(obj); + expect(pool.isFull()).toBeFalsy(); + expect(obj.stamp).toBe(-1); + }); + + test('stamp object should get stamped', () => { + const pool = createAndFillPool(); + const obj = pool.getObjectForId(0); + pool.stampObject(obj); + expect(obj.stamp).toBe(1); + }); + + test('free all objects, first object should be the first free object', () => { + const pool = createAndFillPool(); + pool.freeAllObjects(); + expect(pool.getOrCreateFreeObject().id).toBe(0); + }); + + test('destruct should remove textures', () => { + const pool = createAndFillPool(); + pool.destruct(); + expect(pool.getObjectForId(0).texture.texture).toBeNull(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/gl/render_pool.ts b/web/libraries/maplibre-gl/src/gl/render_pool.ts new file mode 100644 index 00000000..abf1a2c7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/render_pool.ts @@ -0,0 +1,93 @@ +import {Texture} from '../render/texture'; +import {Context} from './context'; +import {Framebuffer} from './framebuffer'; + +export type PoolObject = { + id: number; + fbo: Framebuffer; + texture: Texture; + stamp: number; + inUse: boolean; +}; +/** + * @internal + * `RenderPool` is a resource pool for textures and framebuffers + */ +export class RenderPool { + private _objects: Array; + /** + * An index array of recently used pool objects. + * Items that are used recently are last in the array + */ + private _recentlyUsed: Array; + private _stamp: number; + + constructor( + private readonly _context: Context, + private readonly _size: number, + private readonly _tileSize: number) { + this._objects = []; + this._recentlyUsed = []; + this._stamp = 0; + } + + public destruct() { + for (const obj of this._objects) { + obj.texture.destroy(); + obj.fbo.destroy(); + } + } + + private _createObject(id: number): PoolObject { + const fbo = this._context.createFramebuffer(this._tileSize, this._tileSize, true, true); + const texture = new Texture(this._context, {width: this._tileSize, height: this._tileSize, data: null}, this._context.gl.RGBA); + texture.bind(this._context.gl.LINEAR, this._context.gl.CLAMP_TO_EDGE); + fbo.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL, this._tileSize, this._tileSize)); + fbo.colorAttachment.set(texture.texture); + return {id, fbo, texture, stamp: -1, inUse: false}; + } + + public getObjectForId(id: number): PoolObject { + return this._objects[id]; + } + + public useObject(obj: PoolObject) { + obj.inUse = true; + this._recentlyUsed = this._recentlyUsed.filter(id => obj.id !== id); + this._recentlyUsed.push(obj.id); + } + + public stampObject(obj: PoolObject) { + obj.stamp = ++this._stamp; + } + + public getOrCreateFreeObject(): PoolObject { + // check for free existing object + for (const id of this._recentlyUsed) { + if (!this._objects[id].inUse) + return this._objects[id]; + } + if (this._objects.length >= this._size) + throw new Error('No free RenderPool available, call freeAllObjects() required!'); + // create new object + const obj = this._createObject(this._objects.length); + this._objects.push(obj); + return obj; + } + + public freeObject(obj: PoolObject) { + obj.inUse = false; + } + + public freeAllObjects() { + for (const obj of this._objects) + this.freeObject(obj); + } + + public isFull(): boolean { + if (this._objects.length < this._size) { + return false; + } + return this._objects.some(o => !o.inUse) === false; + } +} diff --git a/web/libraries/maplibre-gl/src/gl/state.test.ts b/web/libraries/maplibre-gl/src/gl/state.test.ts new file mode 100644 index 00000000..720fd5c0 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/state.test.ts @@ -0,0 +1,194 @@ +import {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, ProgramValue, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArray, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha} from './value'; +import {Context} from './context'; +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {deepEqual} from '../util/util'; +import gl from 'gl'; +import {setupMockWebGLContext} from '../util/test/mock_webgl'; + +const context = new Context(gl(10, 10) as any); + +setupMockWebGLContext(context.gl); + +const valueTest = (Constructor: new (...args:any[]) => any, options) => { + test('#constructor', () => { + const v = new Constructor(context); + expect(v).toBeTruthy(); + const currentV = v.get(); + expect(typeof currentV).not.toBe('undefined'); + }); + + test('#set', () => { + const v = new Constructor(context); + v.set(options.setValue); + const equality = (options.equality) || ((a, b) => deepEqual(a, b)); + expect(equality(v.get(), options.setValue)).toBeTruthy(); + }); + +}; + +describe('ClearColor', () => { + valueTest(ClearColor, { + setValue: new Color(1, 1, 0, 1) + }); +}); + +describe('ClearDepth', () => { + valueTest(ClearDepth, { + setValue: 0.5 + }); +}); + +describe('ClearStencil', () => { + valueTest(ClearStencil, { + setValue: 0.5 + }); +}); + +describe('ColorMask', () => { + valueTest(ColorMask, { + setValue: [false, false, true, true] + }); +}); + +describe('DepthMask', () => { + valueTest(DepthMask, { + setValue: false + }); +}); + +describe('StencilMask', () => { + valueTest(StencilMask, { + setValue: [0x00, 4] + }); +}); + +describe('StencilFunc', () => { + valueTest(StencilFunc, { + setValue: { + func: context.gl.LEQUAL, + ref: 1, + mask: 0xFF + } + }); +}); + +describe('StencilOp', () => { + valueTest(StencilOp, { + setValue: [context.gl.KEEP, context.gl.REPLACE, context.gl.REPLACE] + }); +}); + +describe('StencilTest', () => { + valueTest(StencilTest, { + setValue: true + }); +}); + +describe('DepthRange', () => { + valueTest(DepthRange, { + setValue: [0, 0.1] + }); +}); + +describe('DepthTest', () => { + valueTest(DepthTest, { + setValue: true + }); +}); + +describe('DepthFunc', () => { + valueTest(DepthFunc, { + setValue: context.gl.EQUAL + }); +}); + +describe('Blend', () => { + valueTest(Blend, { + setValue: false + }); +}); + +describe('BlendFunc', () => { + valueTest(BlendFunc, { + setValue: [context.gl.SRC_ALPHA, context.gl.SRC_ALPHA] + }); +}); + +describe('BlendColor', () => { + valueTest(BlendColor, { + setValue: Color.white + }); +}); + +describe('Program', () => { + valueTest(ProgramValue, { + equality: (a, b) => a === b, + setValue: context.gl.createProgram() + }); +}); + +describe('ActiveTextureUnit', () => { + valueTest(ActiveTextureUnit, { + setValue: context.gl.TEXTURE1 + }); +}); + +describe('Viewport', () => { + valueTest(Viewport, { + setValue: [0, 0, 1, 1] + }); +}); + +describe('BindFramebuffer', () => { + valueTest(BindFramebuffer, { + equality: (a, b) => a === b, + setValue: context.gl.createFramebuffer() + }); +}); + +describe('BindRenderbuffer', () => { + valueTest(BindRenderbuffer, { + equality: (a, b) => a === b, + setValue: context.gl.createRenderbuffer() + }); +}); + +describe('BindTexture', () => { + valueTest(BindTexture, { + equality: (a, b) => a === b, + setValue: context.gl.createTexture() + }); +}); + +describe('BindVertexBuffer', () => { + valueTest(BindVertexBuffer, { + equality: (a, b) => a === b, + setValue: context.gl.createBuffer() + }); +}); + +describe('BindElementBuffer', () => { + valueTest(BindElementBuffer, { + equality: (a, b) => a === b, + setValue: context.gl.createBuffer() + }); +}); + +describe('BindVertexArray', () => { + valueTest(BindVertexArray, { + equality: (a, b) => a === b, + setValue: context.createVertexArray() + }); +}); + +describe('PixelStoreUnpack', () => { + valueTest(PixelStoreUnpack, { + setValue: 8 + }); +}); + +describe('PixelStoreUnpackPremultiplyAlpha', () => { + valueTest(PixelStoreUnpackPremultiplyAlpha, { + setValue: true + }); +}); diff --git a/web/libraries/maplibre-gl/src/gl/stencil_mode.ts b/web/libraries/maplibre-gl/src/gl/stencil_mode.ts new file mode 100644 index 00000000..7144eab4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/stencil_mode.ts @@ -0,0 +1,27 @@ +import type {StencilOpConstant, StencilTestGL} from './types'; + +const ALWAYS = 0x0207; +const KEEP = 0x1E00; + +export class StencilMode { + test: StencilTestGL; + ref: number; + mask: number; + fail: StencilOpConstant; + depthFail: StencilOpConstant; + pass: StencilOpConstant; + + constructor(test: StencilTestGL, ref: number, mask: number, fail: StencilOpConstant, + depthFail: StencilOpConstant, pass: StencilOpConstant) { + this.test = test; + this.ref = ref; + this.mask = mask; + this.fail = fail; + this.depthFail = depthFail; + this.pass = pass; + } + + static disabled: Readonly; +} + +StencilMode.disabled = new StencilMode({func: ALWAYS, mask: 0}, 0, 0, KEEP, KEEP, KEEP); diff --git a/web/libraries/maplibre-gl/src/gl/types.ts b/web/libraries/maplibre-gl/src/gl/types.ts new file mode 100644 index 00000000..c4acefe7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/types.ts @@ -0,0 +1,59 @@ +type BlendFuncConstant = WebGLRenderingContextBase['ZERO'] | WebGLRenderingContextBase['ONE'] | WebGLRenderingContextBase['SRC_COLOR'] | WebGLRenderingContextBase['ONE_MINUS_SRC_COLOR'] | WebGLRenderingContextBase['DST_COLOR'] | WebGLRenderingContextBase['ONE_MINUS_DST_COLOR'] | WebGLRenderingContextBase['SRC_ALPHA'] | WebGLRenderingContextBase['ONE_MINUS_SRC_ALPHA'] | WebGLRenderingContextBase['DST_ALPHA'] | WebGLRenderingContextBase['ONE_MINUS_DST_ALPHA'] | WebGLRenderingContextBase['CONSTANT_COLOR'] | WebGLRenderingContextBase['ONE_MINUS_CONSTANT_COLOR'] | WebGLRenderingContextBase['CONSTANT_ALPHA'] | WebGLRenderingContextBase['ONE_MINUS_CONSTANT_ALPHA'] | WebGLRenderingContextBase['BLEND_COLOR']; + +export type BlendFuncType = [BlendFuncConstant, BlendFuncConstant]; + +export type BlendEquationType = WebGLRenderingContextBase['FUNC_ADD'] | WebGLRenderingContextBase['FUNC_SUBTRACT'] | WebGLRenderingContextBase['FUNC_REVERSE_SUBTRACT']; + +export type ColorMaskType = [boolean, boolean, boolean, boolean]; + +export type CompareFuncType = WebGLRenderingContextBase['NEVER'] | WebGLRenderingContextBase['LESS'] | WebGLRenderingContextBase['EQUAL'] | WebGLRenderingContextBase['LEQUAL'] | WebGLRenderingContextBase['GREATER'] | WebGLRenderingContextBase['NOTEQUAL'] | WebGLRenderingContextBase['GEQUAL'] | WebGLRenderingContextBase['ALWAYS']; + +export type DepthMaskType = boolean; + +export type DepthRangeType = [number, number]; + +export type DepthFuncType = CompareFuncType; + +export type StencilFuncType = { + func: CompareFuncType; + ref: number; + mask: number; +}; + +export type StencilOpConstant = WebGLRenderingContextBase['KEEP'] | WebGLRenderingContextBase['ZERO'] | WebGLRenderingContextBase['REPLACE'] | WebGLRenderingContextBase['INCR'] | WebGLRenderingContextBase['INCR_WRAP'] | WebGLRenderingContextBase['DECR'] | WebGLRenderingContextBase['DECR_WRAP'] | WebGLRenderingContextBase['INVERT']; + +export type StencilOpType = [StencilOpConstant, StencilOpConstant, StencilOpConstant]; + +export type TextureUnitType = number; + +export type ViewportType = [number, number, number, number]; + +export type StencilTestGL = { + func: WebGLRenderingContextBase['NEVER']; + mask: 0; +} | { + func: WebGLRenderingContextBase['LESS']; + mask: number; +} | { + func: WebGLRenderingContextBase['EQUAL']; + mask: number; +} | { + func: WebGLRenderingContextBase['LEQUAL']; + mask: number; +} | { + func: WebGLRenderingContextBase['GREATER']; + mask: number; +} | { + func: WebGLRenderingContextBase['NOTEQUAL']; + mask: number; +} | { + func: WebGLRenderingContextBase['GEQUAL']; + mask: number; +} | { + func: WebGLRenderingContextBase['ALWAYS']; + mask: 0; +}; + +export type CullFaceModeType = WebGLRenderingContextBase['FRONT'] | WebGLRenderingContextBase['BACK'] | WebGLRenderingContextBase['FRONT_AND_BACK']; + +export type FrontFaceType = WebGLRenderingContextBase['CW'] | WebGLRenderingContextBase['CCW']; diff --git a/web/libraries/maplibre-gl/src/gl/value.ts b/web/libraries/maplibre-gl/src/gl/value.ts new file mode 100644 index 00000000..0e8e1b3c --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/value.ts @@ -0,0 +1,534 @@ +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {isWebGL2} from './webgl2'; + +import type {Context} from './context'; +import type { + BlendFuncType, + BlendEquationType, + ColorMaskType, + DepthRangeType, + DepthMaskType, + StencilFuncType, + StencilOpType, + DepthFuncType, + TextureUnitType, + ViewportType, + CullFaceModeType, + FrontFaceType, +} from './types'; + +export interface IValue { + current: T; + default: T; + dirty: boolean; + get(): T; + setDefault(): void; + set(value: T): void; +} + +class BaseValue implements IValue { + gl: WebGLRenderingContext|WebGL2RenderingContext; + current: T; + default: T; + dirty: boolean; + + constructor(context: Context) { + this.gl = context.gl; + this.default = this.getDefault(); + this.current = this.default; + this.dirty = false; + } + + get(): T { + return this.current; + } + set(value: T) { // eslint-disable-line + // overridden in child classes; + } + + getDefault(): T { + return this.default; // overriden in child classes + } + setDefault() { + this.set(this.default); + } +} + +export class ClearColor extends BaseValue { + getDefault(): Color { + return Color.transparent; + } + set(v: Color) { + const c = this.current; + if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return; + this.gl.clearColor(v.r, v.g, v.b, v.a); + this.current = v; + this.dirty = false; + } +} + +export class ClearDepth extends BaseValue { + getDefault(): number { + return 1; + } + set(v: number) { + if (v === this.current && !this.dirty) return; + this.gl.clearDepth(v); + this.current = v; + this.dirty = false; + } +} + +export class ClearStencil extends BaseValue { + getDefault(): number { + return 0; + } + set(v: number) { + if (v === this.current && !this.dirty) return; + this.gl.clearStencil(v); + this.current = v; + this.dirty = false; + } +} + +export class ColorMask extends BaseValue { + getDefault(): ColorMaskType { + return [true, true, true, true]; + } + set(v: ColorMaskType) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return; + this.gl.colorMask(v[0], v[1], v[2], v[3]); + this.current = v; + this.dirty = false; + } +} + +export class DepthMask extends BaseValue { + getDefault(): DepthMaskType { + return true; + } + set(v: DepthMaskType): void { + if (v === this.current && !this.dirty) return; + this.gl.depthMask(v); + this.current = v; + this.dirty = false; + } +} + +export class StencilMask extends BaseValue { + getDefault(): number { + return 0xFF; + } + set(v: number): void { + if (v === this.current && !this.dirty) return; + this.gl.stencilMask(v); + this.current = v; + this.dirty = false; + } +} + +export class StencilFunc extends BaseValue { + getDefault(): StencilFuncType { + return { + func: this.gl.ALWAYS, + ref: 0, + mask: 0xFF + }; + } + set(v: StencilFuncType): void { + const c = this.current; + if (v.func === c.func && v.ref === c.ref && v.mask === c.mask && !this.dirty) return; + this.gl.stencilFunc(v.func, v.ref, v.mask); + this.current = v; + this.dirty = false; + } +} + +export class StencilOp extends BaseValue { + getDefault(): StencilOpType { + const gl = this.gl; + return [gl.KEEP, gl.KEEP, gl.KEEP]; + } + set(v: StencilOpType) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && !this.dirty) return; + this.gl.stencilOp(v[0], v[1], v[2]); + this.current = v; + this.dirty = false; + } +} + +export class StencilTest extends BaseValue { + getDefault(): boolean { + return false; + } + set(v: boolean) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + if (v) { + gl.enable(gl.STENCIL_TEST); + } else { + gl.disable(gl.STENCIL_TEST); + } + this.current = v; + this.dirty = false; + } +} + +export class DepthRange extends BaseValue { + getDefault(): DepthRangeType { + return [0, 1]; + } + set(v: DepthRangeType) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return; + this.gl.depthRange(v[0], v[1]); + this.current = v; + this.dirty = false; + } +} + +export class DepthTest extends BaseValue { + getDefault(): boolean { + return false; + } + set(v: boolean) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + if (v) { + gl.enable(gl.DEPTH_TEST); + } else { + gl.disable(gl.DEPTH_TEST); + } + this.current = v; + this.dirty = false; + } +} + +export class DepthFunc extends BaseValue { + getDefault(): DepthFuncType { + return this.gl.LESS; + } + set(v: DepthFuncType) { + if (v === this.current && !this.dirty) return; + this.gl.depthFunc(v); + this.current = v; + this.dirty = false; + } +} + +export class Blend extends BaseValue { + getDefault(): boolean { + return false; + } + set(v: boolean) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + if (v) { + gl.enable(gl.BLEND); + } else { + gl.disable(gl.BLEND); + } + this.current = v; + this.dirty = false; + } +} + +export class BlendFunc extends BaseValue { + getDefault(): BlendFuncType { + const gl = this.gl; + return [gl.ONE, gl.ZERO]; + } + set(v: BlendFuncType) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && !this.dirty) return; + this.gl.blendFunc(v[0], v[1]); + this.current = v; + this.dirty = false; + } +} + +export class BlendColor extends BaseValue { + getDefault(): Color { + return Color.transparent; + } + set(v: Color) { + const c = this.current; + if (v.r === c.r && v.g === c.g && v.b === c.b && v.a === c.a && !this.dirty) return; + this.gl.blendColor(v.r, v.g, v.b, v.a); + this.current = v; + this.dirty = false; + } +} + +export class BlendEquation extends BaseValue { + getDefault(): BlendEquationType { + return this.gl.FUNC_ADD; + } + set(v: BlendEquationType) { + if (v === this.current && !this.dirty) return; + this.gl.blendEquation(v); + this.current = v; + this.dirty = false; + } +} + +export class CullFace extends BaseValue { + getDefault(): boolean { + return false; + } + set(v: boolean) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + if (v) { + gl.enable(gl.CULL_FACE); + } else { + gl.disable(gl.CULL_FACE); + } + this.current = v; + this.dirty = false; + } +} + +export class CullFaceSide extends BaseValue { + getDefault(): CullFaceModeType { + return this.gl.BACK; + } + set(v: CullFaceModeType) { + if (v === this.current && !this.dirty) return; + this.gl.cullFace(v); + this.current = v; + this.dirty = false; + } +} + +export class FrontFace extends BaseValue { + getDefault(): FrontFaceType { + return this.gl.CCW; + } + set(v: FrontFaceType) { + if (v === this.current && !this.dirty) return; + this.gl.frontFace(v); + this.current = v; + this.dirty = false; + } +} + +export class ProgramValue extends BaseValue { + getDefault(): WebGLProgram { + return null; + } + set(v?: WebGLProgram | null) { + if (v === this.current && !this.dirty) return; + this.gl.useProgram(v); + this.current = v; + this.dirty = false; + } +} + +export class ActiveTextureUnit extends BaseValue { + getDefault(): TextureUnitType { + return this.gl.TEXTURE0; + } + set(v: TextureUnitType) { + if (v === this.current && !this.dirty) return; + this.gl.activeTexture(v); + this.current = v; + this.dirty = false; + } +} + +export class Viewport extends BaseValue { + getDefault(): ViewportType { + const gl = this.gl; + return [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]; + } + set(v: ViewportType) { + const c = this.current; + if (v[0] === c[0] && v[1] === c[1] && v[2] === c[2] && v[3] === c[3] && !this.dirty) return; + this.gl.viewport(v[0], v[1], v[2], v[3]); + this.current = v; + this.dirty = false; + } +} + +export class BindFramebuffer extends BaseValue { + getDefault(): WebGLFramebuffer { + return null; + } + set(v?: WebGLFramebuffer | null) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.bindFramebuffer(gl.FRAMEBUFFER, v); + this.current = v; + this.dirty = false; + } +} + +export class BindRenderbuffer extends BaseValue { + getDefault(): WebGLRenderbuffer { + return null; + } + set(v?: WebGLRenderbuffer | null) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.bindRenderbuffer(gl.RENDERBUFFER, v); + this.current = v; + this.dirty = false; + } +} + +export class BindTexture extends BaseValue { + getDefault(): WebGLTexture { + return null; + } + set(v?: WebGLTexture | null) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.bindTexture(gl.TEXTURE_2D, v); + this.current = v; + this.dirty = false; + } +} + +export class BindVertexBuffer extends BaseValue { + getDefault(): WebGLBuffer { + return null; + } + set(v?: WebGLBuffer | null) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.bindBuffer(gl.ARRAY_BUFFER, v); + this.current = v; + this.dirty = false; + } +} + +export class BindElementBuffer extends BaseValue { + getDefault(): WebGLBuffer { + return null; + } + set(v?: WebGLBuffer | null) { + // Always rebind + const gl = this.gl; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, v); + this.current = v; + this.dirty = false; + } +} + +export class BindVertexArray extends BaseValue { + getDefault(): WebGLVertexArrayObject | null { + return null; + } + set(v: WebGLVertexArrayObject | null) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + + if (isWebGL2(gl)) { + gl.bindVertexArray(v); + } else { + gl.getExtension('OES_vertex_array_object')?.bindVertexArrayOES(v); + } + + this.current = v; + this.dirty = false; + } +} + +export class PixelStoreUnpack extends BaseValue { + getDefault(): number { + return 4; + } + set(v: number) { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.pixelStorei(gl.UNPACK_ALIGNMENT, v); + this.current = v; + this.dirty = false; + } +} + +export class PixelStoreUnpackPremultiplyAlpha extends BaseValue { + getDefault(): boolean { + return false; + } + set(v: boolean): void { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, ((v as any))); + this.current = v; + this.dirty = false; + } +} + +export class PixelStoreUnpackFlipY extends BaseValue { + getDefault(): boolean { + return false; + } + set(v: boolean): void { + if (v === this.current && !this.dirty) return; + const gl = this.gl; + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, ((v as any))); + this.current = v; + this.dirty = false; + } +} + +class FramebufferAttachment extends BaseValue { + parent: WebGLFramebuffer; + context: Context; + + constructor(context: Context, parent: WebGLFramebuffer) { + super(context); + this.context = context; + this.parent = parent; + } + getDefault() { + return null; + } +} + +export class ColorAttachment extends FramebufferAttachment { + setDirty() { + this.dirty = true; + } + set(v?: WebGLTexture | null): void { + if (v === this.current && !this.dirty) return; + this.context.bindFramebuffer.set(this.parent); + // note: it's possible to attach a renderbuffer to the color + // attachment point, but thus far MBGL only uses textures for color + const gl = this.gl; + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, v, 0); + + this.current = v; + this.dirty = false; + } +} + +export class DepthAttachment extends FramebufferAttachment { + set(v?: WebGLRenderbuffer | null): void { + if (v === this.current && !this.dirty) return; + this.context.bindFramebuffer.set(this.parent); + // note: it's possible to attach a texture to the depth attachment + // point, but thus far MBGL only uses renderbuffers for depth + const gl = this.gl; + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, v); + this.current = v; + this.dirty = false; + } +} + +export class DepthStencilAttachment extends FramebufferAttachment { + set(v?: WebGLRenderbuffer | null): void { + if (v === this.current && !this.dirty) return; + this.context.bindFramebuffer.set(this.parent); + // note: it's possible to attach a texture to the depth attachment + // point, but thus far MBGL only uses renderbuffers for depth + const gl = this.gl; + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, v); + this.current = v; + this.dirty = false; + } +} diff --git a/web/libraries/maplibre-gl/src/gl/vertex_buffer.test.ts b/web/libraries/maplibre-gl/src/gl/vertex_buffer.test.ts new file mode 100644 index 00000000..341bbab0 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/vertex_buffer.test.ts @@ -0,0 +1,52 @@ +import {VertexBuffer} from './vertex_buffer'; +import {StructArrayLayout3i6} from '../data/array_types.g'; +import {Context} from '../gl/context'; +import gl from 'gl'; +import {StructArrayMember} from '../util/struct_array'; + +describe('VertexBuffer', () => { + class TestArray extends StructArrayLayout3i6 {} + const attributes = [ + {name: 'map', components: 1, type: 'Int16', offset: 0}, + {name: 'box', components: 2, type: 'Int16', offset: 4} + ] as StructArrayMember[]; + + test('constructs itself', () => { + const context = new Context(gl(10, 10) as any); + const array = new TestArray(); + array.emplaceBack(1, 1, 1); + array.emplaceBack(1, 1, 1); + array.emplaceBack(1, 1, 1); + + const buffer = new VertexBuffer(context, array, attributes); + + expect(buffer.attributes).toEqual([ + {name: 'map', components: 1, type: 'Int16', offset: 0}, + {name: 'box', components: 2, type: 'Int16', offset: 4} + ]); + expect(buffer.itemSize).toBe(6); + expect(buffer).toHaveLength(3); + }); + + test('enableAttributes', () => { + const context = new Context(gl(10, 10) as any); + const array = new TestArray(); + const buffer = new VertexBuffer(context, array, attributes); + const spy = jest.spyOn(context.gl, 'enableVertexAttribArray').mockImplementation(() => {}); + buffer.enableAttributes(context.gl, {attributes: {map: 5, box: 6}} as any); + expect(spy.mock.calls).toEqual([[5], [6]]); + }); + + test('setVertexAttribPointers', () => { + const context = new Context(gl(10, 10) as any); + const array = new TestArray(); + const buffer = new VertexBuffer(context, array, attributes); + const spy = jest.spyOn(context.gl, 'vertexAttribPointer').mockImplementation(() => {}); + buffer.setVertexAttribPointers(context.gl, {attributes: {map: 5, box: 6}} as any, 50); + expect(spy.mock.calls).toEqual([ + [5, 1, context.gl['SHORT'], false, 6, 300], + [6, 2, context.gl['SHORT'], false, 6, 304] + ]); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/gl/vertex_buffer.ts b/web/libraries/maplibre-gl/src/gl/vertex_buffer.ts new file mode 100644 index 00000000..63f55adc --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/vertex_buffer.ts @@ -0,0 +1,111 @@ + +import type { + StructArray, + StructArrayMember +} from '../util/struct_array'; + +import type {Program} from '../render/program'; +import type {Context} from '../gl/context'; + +/** + * An Enum for AttributeType + */ +const AttributeType = { + Int8: 'BYTE', + Uint8: 'UNSIGNED_BYTE', + Int16: 'SHORT', + Uint16: 'UNSIGNED_SHORT', + Int32: 'INT', + Uint32: 'UNSIGNED_INT', + Float32: 'FLOAT' +}; + +/** + * @internal + * The `VertexBuffer` class turns a `StructArray` into a WebGL buffer. Each member of the StructArray's + * Struct type is converted to a WebGL attribute. + */ +export class VertexBuffer { + length: number; + attributes: ReadonlyArray; + itemSize: number; + dynamicDraw: boolean; + context: Context; + buffer: WebGLBuffer; + + /** + * @param dynamicDraw - Whether this buffer will be repeatedly updated. + */ + constructor(context: Context, array: StructArray, attributes: ReadonlyArray, dynamicDraw?: boolean) { + this.length = array.length; + this.attributes = attributes; + this.itemSize = array.bytesPerElement; + this.dynamicDraw = dynamicDraw; + + this.context = context; + const gl = context.gl; + this.buffer = gl.createBuffer(); + context.bindVertexBuffer.set(this.buffer); + gl.bufferData(gl.ARRAY_BUFFER, array.arrayBuffer, this.dynamicDraw ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW); + + if (!this.dynamicDraw) { + delete array.arrayBuffer; + } + } + + bind() { + this.context.bindVertexBuffer.set(this.buffer); + } + + updateData(array: StructArray) { + if (array.length !== this.length) throw new Error(`Length of new data is ${array.length}, which doesn't match current length of ${this.length}`); + const gl = this.context.gl; + this.bind(); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer); + } + + enableAttributes(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program) { + for (let j = 0; j < this.attributes.length; j++) { + const member = this.attributes[j]; + const attribIndex: number | void = program.attributes[member.name]; + if (attribIndex !== undefined) { + gl.enableVertexAttribArray(attribIndex); + } + } + } + + /** + * Set the attribute pointers in a WebGL context + * @param gl - The WebGL context + * @param program - The active WebGL program + * @param vertexOffset - Index of the starting vertex of the segment + */ + setVertexAttribPointers(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program, vertexOffset?: number | null) { + for (let j = 0; j < this.attributes.length; j++) { + const member = this.attributes[j]; + const attribIndex: number | void = program.attributes[member.name]; + + if (attribIndex !== undefined) { + gl.vertexAttribPointer( + attribIndex, + member.components, + (gl as any)[AttributeType[member.type]], + false, + this.itemSize, + member.offset + (this.itemSize * (vertexOffset || 0)) + ); + } + } + } + + /** + * Destroy the GL buffer bound to the given WebGL context + */ + destroy() { + const gl = this.context.gl; + if (this.buffer) { + gl.deleteBuffer(this.buffer); + delete this.buffer; + } + } +} diff --git a/web/libraries/maplibre-gl/src/gl/webgl2.ts b/web/libraries/maplibre-gl/src/gl/webgl2.ts new file mode 100644 index 00000000..2b8f18a8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/gl/webgl2.ts @@ -0,0 +1,12 @@ +const cache = new WeakMap(); +export function isWebGL2( + gl: WebGLRenderingContext | WebGL2RenderingContext +): gl is WebGL2RenderingContext { + if (cache.has(gl)) { + return cache.get(gl); + } else { + const value = gl.getParameter(gl.VERSION)?.startsWith('WebGL 2.0'); + cache.set(gl, value); + return value; + } +} diff --git a/web/libraries/maplibre-gl/src/index.test.ts b/web/libraries/maplibre-gl/src/index.test.ts new file mode 100644 index 00000000..628bbe2d --- /dev/null +++ b/web/libraries/maplibre-gl/src/index.test.ts @@ -0,0 +1,129 @@ +import {config} from './util/config'; +import maplibre from './index'; +import {getJSON, getArrayBuffer} from './util/ajax'; +import {ImageRequest} from './util/image_request'; + +describe('maplibre', () => { + beforeEach(() => { + config.REGISTERED_PROTOCOLS = {}; + }); + afterAll(() => { + config.REGISTERED_PROTOCOLS = {}; + }); + + test('workerCount', () => { + expect(typeof maplibre.workerCount === 'number').toBeTruthy(); + }); + + test('addProtocol', () => { + const protocolName = 'custom'; + expect(Object.keys(config.REGISTERED_PROTOCOLS)).toHaveLength(0); + + maplibre.addProtocol(protocolName, () => { return {cancel: () => { }}; }); + expect(Object.keys(config.REGISTERED_PROTOCOLS)[0]).toBe(protocolName); + }); + + test('removeProtocol', () => { + const protocolName = 'custom'; + expect(Object.keys(config.REGISTERED_PROTOCOLS)).toHaveLength(0); + + maplibre.addProtocol(protocolName, () => { return {cancel: () => { }}; }); + expect(Object.keys(config.REGISTERED_PROTOCOLS)[0]).toBe(protocolName); + + maplibre.removeProtocol(protocolName); + expect(Object.keys(config.REGISTERED_PROTOCOLS)).toHaveLength(0); + }); + + test('#addProtocol - getJSON', done => { + let protocolCallbackCalled = false; + maplibre.addProtocol('custom', (reqParam, callback) => { + protocolCallbackCalled = true; + callback(null, {'foo': 'bar'}); + return {cancel: () => {}}; + }); + getJSON({url: 'custom://test/url/json'}, (error, data) => { + expect(error).toBeFalsy(); + expect(data).toEqual({foo: 'bar'}); + expect(protocolCallbackCalled).toBeTruthy(); + done(); + }); + }); + + test('#addProtocol - getArrayBuffer', done => { + let protocolCallbackCalled = false; + maplibre.addProtocol('custom', (reqParam, callback) => { + protocolCallbackCalled = true; + callback(null, new ArrayBuffer(1)); + return {cancel: () => {}}; + }); + getArrayBuffer({url: 'custom://test/url/getArrayBuffer'}, async (error, data) => { + expect(error).toBeFalsy(); + expect(data).toBeInstanceOf(ArrayBuffer); + expect(protocolCallbackCalled).toBeTruthy(); + done(); + }); + }); + + test('#addProtocol - returning ImageBitmap for getImage', done => { + let protocolCallbackCalled = false; + maplibre.addProtocol('custom', (reqParam, callback) => { + protocolCallbackCalled = true; + callback(null, new ImageBitmap()); + return {cancel: () => {}}; + }); + + ImageRequest.getImage({url: 'custom://test/url/getImage'}, async (error, img) => { + expect(error).toBeFalsy(); + expect(img).toBeInstanceOf(ImageBitmap); + expect(protocolCallbackCalled).toBeTruthy(); + done(); + }); + }); + + test('#addProtocol - returning HTMLImageElement for getImage', done => { + let protocolCallbackCalled = false; + maplibre.addProtocol('custom', (reqParam, callback) => { + protocolCallbackCalled = true; + callback(null, new Image()); + return {cancel: () => {}}; + }); + ImageRequest.getImage({url: 'custom://test/url/getImage'}, async (error, img) => { + expect(error).toBeFalsy(); + expect(img).toBeInstanceOf(HTMLImageElement); + expect(protocolCallbackCalled).toBeTruthy(); + done(); + }); + }); + + test('#addProtocol - error', () => { + maplibre.addProtocol('custom', (reqParam, callback) => { + callback(new Error('error')); + return {cancel: () => { }}; + }); + + getJSON({url: 'custom://test/url/json'}, (error) => { + expect(error).toBeTruthy(); + }); + }); + + test('#addProtocol - Cancel request', () => { + let cancelCalled = false; + maplibre.addProtocol('custom', () => { + return {cancel: () => { + cancelCalled = true; + }}; + }); + const request = getJSON({url: 'custom://test/url/json'}, () => { }); + request.cancel(); + expect(cancelCalled).toBeTruthy(); + }); + + test('version', () => { + expect(typeof maplibre.version === 'string').toBeTruthy(); + + // Semver regex: https://gist.github.com/jhorsman/62eeea161a13b80e39f5249281e17c39 + // Backslashes are doubled to escape them + const regexp = new RegExp('^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$'); + expect(regexp.test(maplibre.version)).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/index.ts b/web/libraries/maplibre-gl/src/index.ts new file mode 100644 index 00000000..0ac560ce --- /dev/null +++ b/web/libraries/maplibre-gl/src/index.ts @@ -0,0 +1,239 @@ +import packageJSON from '../package.json' assert {type: 'json'}; +import {Map} from './ui/map'; +import {NavigationControl} from './ui/control/navigation_control'; +import {GeolocateControl} from './ui/control/geolocate_control'; +import {AttributionControl} from './ui/control/attribution_control'; +import {LogoControl} from './ui/control/logo_control'; +import {ScaleControl} from './ui/control/scale_control'; +import {FullscreenControl} from './ui/control/fullscreen_control'; +import {TerrainControl} from './ui/control/terrain_control'; +import {Popup} from './ui/popup'; +import {Marker} from './ui/marker'; +import {Style} from './style/style'; +import {LngLat} from './geo/lng_lat'; +import {LngLatBounds} from './geo/lng_lat_bounds'; +import Point from '@mapbox/point-geometry'; +import {MercatorCoordinate} from './geo/mercator_coordinate'; +import {Evented} from './util/evented'; +import {config} from './util/config'; +import {Debug} from './util/debug'; +import {isSafari} from './util/util'; +import {setRTLTextPlugin, getRTLTextPluginStatus} from './source/rtl_text_plugin'; +import {WorkerPool} from './util/worker_pool'; +import {prewarm, clearPrewarmedResources} from './util/global_worker_pool'; +import {PerformanceUtils} from './util/performance'; +import {AJAXError} from './util/ajax'; +import type {RequestParameters, ResponseCallback} from './util/ajax'; +import type {Cancelable} from './types/cancelable'; +import {GeoJSONSource} from './source/geojson_source'; +import {CanvasSource} from './source/canvas_source'; +import {ImageSource} from './source/image_source'; +import {RasterDEMTileSource} from './source/raster_dem_tile_source'; +import {RasterTileSource} from './source/raster_tile_source'; +import {VectorTileSource} from './source/vector_tile_source'; +import {VideoSource} from './source/video_source'; + +const version = packageJSON.version; + +export type * from '@maplibre/maplibre-gl-style-spec'; + +/** + * `maplibregl` is the global object that allows configurations that are not specific to a map instance + * + * @group Main + */ +class MapLibreGL { + static Map = Map; + static NavigationControl = NavigationControl; + static GeolocateControl = GeolocateControl; + static AttributionControl = AttributionControl; + static LogoControl = LogoControl; + static ScaleControl = ScaleControl; + static FullscreenControl = FullscreenControl; + static TerrainControl = TerrainControl; + static Popup = Popup; + static Marker = Marker; + static Style = Style; + static LngLat = LngLat; + static LngLatBounds = LngLatBounds; + static Point = Point; + static MercatorCoordinate = MercatorCoordinate; + static Evented = Evented; + static AJAXError = AJAXError; + static config = config; + static CanvasSource = CanvasSource; + static GeoJSONSource = GeoJSONSource; + static ImageSource = ImageSource; + static RasterDEMTileSource = RasterDEMTileSource; + static RasterTileSource = RasterTileSource; + static VectorTileSource = VectorTileSource; + static VideoSource = VideoSource; + /** + * Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text). + * Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. + * + * @param pluginURL - URL pointing to the Mapbox RTL text plugin source. + * @param callback - Called with an error argument if there is an error. + * @param lazy - If set to `true`, mapboxgl will defer loading the plugin until rtl text is encountered, + * rtl text will then be rendered only after the plugin finishes loading. + * @example + * ```ts + * maplibregl.setRTLTextPlugin('https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.js'); + * ``` + * @see [Add support for right-to-left scripts](https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/) + */ + static setRTLTextPlugin = setRTLTextPlugin; + /** + * Gets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) status. + * The status can be `unavailable` (i.e. not requested or removed), `loading`, `loaded` or `error`. + * If the status is `loaded` and the plugin is requested again, an error will be thrown. + * + * @example + * ```ts + * const pluginStatus = maplibregl.getRTLTextPluginStatus(); + * ``` + */ + static getRTLTextPluginStatus = getRTLTextPluginStatus; + /** + * Initializes resources like WebWorkers that can be shared across maps to lower load + * times in some situations. `maplibregl.workerUrl` and `maplibregl.workerCount`, if being + * used, must be set before `prewarm()` is called to have an effect. + * + * By default, the lifecycle of these resources is managed automatically, and they are + * lazily initialized when a Map is first created. By invoking `prewarm()`, these + * resources will be created ahead of time, and will not be cleared when the last Map + * is removed from the page. This allows them to be re-used by new Map instances that + * are created later. They can be manually cleared by calling + * `maplibregl.clearPrewarmedResources()`. This is only necessary if your web page remains + * active but stops using maps altogether. + * + * This is primarily useful when using GL-JS maps in a single page app, wherein a user + * would navigate between various views that can cause Map instances to constantly be + * created and destroyed. + * + * @example + * ```ts + * maplibregl.prewarm() + * ``` + */ + static prewarm = prewarm; + /** + * Clears up resources that have previously been created by `maplibregl.prewarm()`. + * Note that this is typically not necessary. You should only call this function + * if you expect the user of your app to not return to a Map view at any point + * in your application. + * + * @example + * ```ts + * maplibregl.clearPrewarmedResources() + * ``` + */ + static clearPrewarmedResources = clearPrewarmedResources; + /** + * Returns the package version of the library + * @returns Package version of the library + */ + static get version(): string { + return version; + } + + /** + * Gets and sets the number of web workers instantiated on a page with GL JS maps. + * By default, workerCount is 1 except for Safari browser where it is set to half the number of CPU cores (capped at 3). + * Make sure to set this property before creating any map instances for it to have effect. + * + * @returns Number of workers currently configured. + * @example + * ```ts + * maplibregl.workerCount = 2; + * ``` + */ + static get workerCount(): number { + return WorkerPool.workerCount; + } + + static set workerCount(count: number) { + WorkerPool.workerCount = count; + } + /** + * Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel, + * which affects performance in raster-heavy maps. 16 by default. + * + * @returns Number of parallel requests currently configured. + * @example + * ```ts + * maplibregl.maxParallelImageRequests = 10; + * ``` + */ + static get maxParallelImageRequests(): number { + return config.MAX_PARALLEL_IMAGE_REQUESTS; + } + + static set maxParallelImageRequests(numRequests: number) { + config.MAX_PARALLEL_IMAGE_REQUESTS = numRequests; + } + + static get workerUrl(): string { + return config.WORKER_URL; + } + + static set workerUrl(value: string) { + config.WORKER_URL = value; + } + + /** + * Sets a custom load tile function that will be called when using a source that starts with a custom url schema. + * The example below will be triggered for custom:// urls defined in the sources list in the style definitions. + * The function passed will receive the request parameters and should call the callback with the resulting request, + * for example a pbf vector tile, non-compressed, represented as ArrayBuffer. + * + * @param customProtocol - the protocol to hook, for example 'custom' + * @param loadFn - the function to use when trying to fetch a tile specified by the customProtocol + * @example + * This will fetch a file using the fetch API (this is obviously a non interesting example...) + * ```ts + * maplibregl.addProtocol('custom', (params, callback) => { + fetch(`https://${params.url.split("://")[1]}`) + .then(t => { + if (t.status == 200) { + t.arrayBuffer().then(arr => { + callback(null, arr, null, null); + }); + } else { + callback(new Error(`Tile fetch error: ${t.statusText}`)); + } + }) + .catch(e => { + callback(new Error(e)); + }); + return { cancel: () => { } }; + }); + * // the following is an example of a way to return an error when trying to load a tile + * maplibregl.addProtocol('custom2', (params, callback) => { + * callback(new Error('someErrorMessage')); + * return { cancel: () => { } }; + * }); + * ``` + */ + static addProtocol(customProtocol: string, loadFn: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable) { + config.REGISTERED_PROTOCOLS[customProtocol] = loadFn; + } + + /** + * Removes a previously added protocol + * + * @param customProtocol - the custom protocol to remove registration for + * @example + * ```ts + * maplibregl.removeProtocol('custom'); + * ``` + */ + static removeProtocol(customProtocol: string) { + delete config.REGISTERED_PROTOCOLS[customProtocol]; + } +} + +//This gets automatically stripped out in production builds. +Debug.extend(MapLibreGL, {isSafari, getPerformanceMetrics: PerformanceUtils.getPerformanceMetrics}); + +export default MapLibreGL; diff --git a/web/libraries/maplibre-gl/src/render/draw_background.ts b/web/libraries/maplibre-gl/src/render/draw_background.ts new file mode 100644 index 00000000..16ba882c --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_background.ts @@ -0,0 +1,53 @@ +import {StencilMode} from '../gl/stencil_mode'; +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import { + backgroundUniformValues, + backgroundPatternUniformValues +} from './program/background_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {BackgroundStyleLayer} from '../style/style_layer/background_style_layer'; +import {OverscaledTileID} from '../source/tile_id'; + +export function drawBackground(painter: Painter, sourceCache: SourceCache, layer: BackgroundStyleLayer, coords?: Array) { + const color = layer.paint.get('background-color'); + const opacity = layer.paint.get('background-opacity'); + + if (opacity === 0) return; + + const context = painter.context; + const gl = context.gl; + const transform = painter.transform; + const tileSize = transform.tileSize; + const image = layer.paint.get('background-pattern'); + if (painter.isPatternMissing(image)) return; + + const pass = (!image && color.a === 1 && opacity === 1 && painter.opaquePassEnabledForLayer()) ? 'opaque' : 'translucent'; + if (painter.renderPass !== pass) return; + + const stencilMode = StencilMode.disabled; + const depthMode = painter.depthModeForSublayer(0, pass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly); + const colorMode = painter.colorModeForRenderPass(); + const program = painter.useProgram(image ? 'backgroundPattern' : 'background'); + const tileIDs = coords ? coords : transform.coveringTiles({tileSize, terrain: painter.style.map.terrain}); + + if (image) { + context.activeTexture.set(gl.TEXTURE0); + painter.imageManager.bind(painter.context); + } + + const crossfade = layer.getCrossfadeParameters(); + for (const tileID of tileIDs) { + const matrix = coords ? tileID.posMatrix : painter.transform.calculatePosMatrix(tileID.toUnwrapped()); + const uniformValues = image ? + backgroundPatternUniformValues(matrix, opacity, painter, image, {tileID, tileSize}, crossfade) : + backgroundUniformValues(matrix, opacity, color); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(tileID); + + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, + uniformValues, terrainData, layer.id, painter.tileExtentBuffer, + painter.quadTriangleIndexBuffer, painter.tileExtentSegments); + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_circle.ts b/web/libraries/maplibre-gl/src/render/draw_circle.ts new file mode 100644 index 00000000..be08b0dd --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_circle.ts @@ -0,0 +1,113 @@ +import {StencilMode} from '../gl/stencil_mode'; +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {Program} from './program'; +import {circleUniformValues} from './program/circle_program'; +import {SegmentVector} from '../data/segment'; +import {OverscaledTileID} from '../source/tile_id'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {CircleStyleLayer} from '../style/style_layer/circle_style_layer'; +import type {CircleBucket} from '../data/bucket/circle_bucket'; +import type {ProgramConfiguration} from '../data/program_configuration'; +import type {VertexBuffer} from '../gl/vertex_buffer'; +import type {IndexBuffer} from '../gl/index_buffer'; +import type {UniformValues} from './uniform_binding'; +import type {CircleUniformsType} from './program/circle_program'; +import type {TerrainData} from '../render/terrain'; + +type TileRenderState = { + programConfiguration: ProgramConfiguration; + program: Program; + layoutVertexBuffer: VertexBuffer; + indexBuffer: IndexBuffer; + uniformValues: UniformValues; + terrainData: TerrainData; +}; + +type SegmentsTileRenderState = { + segments: SegmentVector; + sortKey: number; + state: TileRenderState; +}; + +export function drawCircles(painter: Painter, sourceCache: SourceCache, layer: CircleStyleLayer, coords: Array) { + if (painter.renderPass !== 'translucent') return; + + const opacity = layer.paint.get('circle-opacity'); + const strokeWidth = layer.paint.get('circle-stroke-width'); + const strokeOpacity = layer.paint.get('circle-stroke-opacity'); + const sortFeaturesByKey = !layer.layout.get('circle-sort-key').isConstant(); + + if (opacity.constantOr(1) === 0 && (strokeWidth.constantOr(1) === 0 || strokeOpacity.constantOr(1) === 0)) { + return; + } + + const context = painter.context; + const gl = context.gl; + + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + // Turn off stencil testing to allow circles to be drawn across boundaries, + // so that large circles are not clipped to tiles + const stencilMode = StencilMode.disabled; + const colorMode = painter.colorModeForRenderPass(); + + const segmentsRenderStates: Array = []; + + for (let i = 0; i < coords.length; i++) { + const coord = coords[i]; + + const tile = sourceCache.getTile(coord); + const bucket: CircleBucket = (tile.getBucket(layer) as any); + if (!bucket) continue; + + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram('circle', programConfiguration); + const layoutVertexBuffer = bucket.layoutVertexBuffer; + const indexBuffer = bucket.indexBuffer; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const uniformValues = circleUniformValues(painter, coord, tile, layer); + + const state: TileRenderState = { + programConfiguration, + program, + layoutVertexBuffer, + indexBuffer, + uniformValues, + terrainData + }; + + if (sortFeaturesByKey) { + const oldSegments = bucket.segments.get(); + for (const segment of oldSegments) { + segmentsRenderStates.push({ + segments: new SegmentVector([segment]), + sortKey: (segment.sortKey as any as number), + state + }); + } + } else { + segmentsRenderStates.push({ + segments: bucket.segments, + sortKey: 0, + state + }); + } + + } + + if (sortFeaturesByKey) { + segmentsRenderStates.sort((a, b) => a.sortKey - b.sortKey); + } + + for (const segmentsState of segmentsRenderStates) { + const {programConfiguration, program, layoutVertexBuffer, indexBuffer, uniformValues, terrainData} = segmentsState.state; + const segments = segmentsState.segments; + + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, + uniformValues, terrainData, layer.id, + layoutVertexBuffer, indexBuffer, segments, + layer.paint, painter.transform.zoom, programConfiguration); + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_collision_debug.ts b/web/libraries/maplibre-gl/src/render/draw_collision_debug.ts new file mode 100644 index 00000000..876c5b22 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_collision_debug.ts @@ -0,0 +1,172 @@ +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {StyleLayer} from '../style/style_layer'; +import type {OverscaledTileID} from '../source/tile_id'; +import type {SymbolBucket} from '../data/bucket/symbol_bucket'; +import {DepthMode} from '../gl/depth_mode'; +import {StencilMode} from '../gl/stencil_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {collisionUniformValues, collisionCircleUniformValues} from './program/collision_program'; + +import {QuadTriangleArray, CollisionCircleLayoutArray} from '../data/array_types.g'; +import {collisionCircleLayout} from '../data/bucket/symbol_attributes'; +import {SegmentVector} from '../data/segment'; +import {mat4} from 'gl-matrix'; +import {VertexBuffer} from '../gl/vertex_buffer'; +import {IndexBuffer} from '../gl/index_buffer'; + +type TileBatch = { + circleArray: Array; + circleOffset: number; + transform: mat4; + invTransform: mat4; + coord: OverscaledTileID; +}; + +let quadTriangles: QuadTriangleArray; + +export function drawCollisionDebug(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array, translate: [number, number], translateAnchor: 'map' | 'viewport', isText: boolean) { + const context = painter.context; + const gl = context.gl; + const program = painter.useProgram('collisionBox'); + const tileBatches: Array = []; + let circleCount = 0; + let circleOffset = 0; + + for (let i = 0; i < coords.length; i++) { + const coord = coords[i]; + const tile = sourceCache.getTile(coord); + const bucket: SymbolBucket = (tile.getBucket(layer) as any); + if (!bucket) continue; + let posMatrix = coord.posMatrix; + if (translate[0] !== 0 || translate[1] !== 0) { + posMatrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor); + } + const buffers = isText ? bucket.textCollisionBox : bucket.iconCollisionBox; + // Get collision circle data of this bucket + const circleArray: Array = bucket.collisionCircleArray; + if (circleArray.length > 0) { + // We need to know the projection matrix that was used for projecting collision circles to the screen. + // This might vary between buckets as the symbol placement is a continuous process. This matrix is + // required for transforming points from previous screen space to the current one + const invTransform = mat4.create(); + const transform = posMatrix; + + mat4.mul(invTransform, bucket.placementInvProjMatrix, painter.transform.glCoordMatrix); + mat4.mul(invTransform, invTransform, bucket.placementViewportMatrix); + + tileBatches.push({ + circleArray, + circleOffset, + transform, + invTransform, + coord + }); + + circleCount += circleArray.length / 4; // 4 values per circle + circleOffset = circleCount; + } + if (!buffers) continue; + program.draw(context, gl.LINES, + DepthMode.disabled, StencilMode.disabled, + painter.colorModeForRenderPass(), + CullFaceMode.disabled, + collisionUniformValues( + posMatrix, + painter.transform, + tile), + painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord), + layer.id, buffers.layoutVertexBuffer, buffers.indexBuffer, + buffers.segments, null, painter.transform.zoom, null, null, + buffers.collisionVertexBuffer); + } + + if (!isText || !tileBatches.length) { + return; + } + + // Render collision circles + const circleProgram = painter.useProgram('collisionCircle'); + + // Construct vertex data + const vertexData = new CollisionCircleLayoutArray(); + vertexData.resize(circleCount * 4); + vertexData._trim(); + + let vertexOffset = 0; + + for (const batch of tileBatches) { + for (let i = 0; i < batch.circleArray.length / 4; i++) { + const circleIdx = i * 4; + const x = batch.circleArray[circleIdx + 0]; + const y = batch.circleArray[circleIdx + 1]; + const radius = batch.circleArray[circleIdx + 2]; + const collision = batch.circleArray[circleIdx + 3]; + + // 4 floats per vertex, 4 vertices per quad + vertexData.emplace(vertexOffset++, x, y, radius, collision, 0); + vertexData.emplace(vertexOffset++, x, y, radius, collision, 1); + vertexData.emplace(vertexOffset++, x, y, radius, collision, 2); + vertexData.emplace(vertexOffset++, x, y, radius, collision, 3); + } + } + if (!quadTriangles || quadTriangles.length < circleCount * 2) { + quadTriangles = createQuadTriangles(circleCount); + } + + const indexBuffer: IndexBuffer = context.createIndexBuffer(quadTriangles, true); + const vertexBuffer: VertexBuffer = context.createVertexBuffer(vertexData, collisionCircleLayout.members, true); + + // Render batches + for (const batch of tileBatches) { + const uniforms = collisionCircleUniformValues( + batch.transform, + batch.invTransform, + painter.transform + ); + + circleProgram.draw( + context, + gl.TRIANGLES, + DepthMode.disabled, + StencilMode.disabled, + painter.colorModeForRenderPass(), + CullFaceMode.disabled, + uniforms, + painter.style.map.terrain && painter.style.map.terrain.getTerrainData(batch.coord), + layer.id, + vertexBuffer, + indexBuffer, + SegmentVector.simpleSegment(0, batch.circleOffset * 2, batch.circleArray.length, batch.circleArray.length / 2), + null, + painter.transform.zoom, + null, + null, + null); + } + + vertexBuffer.destroy(); + indexBuffer.destroy(); +} + +function createQuadTriangles(quadCount: number): QuadTriangleArray { + const triCount = quadCount * 2; + const array = new QuadTriangleArray(); + + array.resize(triCount); + array._trim(); + + // Two triangles and 4 vertices per quad. + for (let i = 0; i < triCount; i++) { + const idx = i * 6; + + array.uint16[idx + 0] = i * 4 + 0; + array.uint16[idx + 1] = i * 4 + 1; + array.uint16[idx + 2] = i * 4 + 2; + array.uint16[idx + 3] = i * 4 + 2; + array.uint16[idx + 4] = i * 4 + 3; + array.uint16[idx + 5] = i * 4 + 0; + } + + return array; +} diff --git a/web/libraries/maplibre-gl/src/render/draw_custom.ts b/web/libraries/maplibre-gl/src/render/draw_custom.ts new file mode 100644 index 00000000..f5dc360d --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_custom.ts @@ -0,0 +1,45 @@ +import {DepthMode} from '../gl/depth_mode'; +import {StencilMode} from '../gl/stencil_mode'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {CustomStyleLayer} from '../style/style_layer/custom_style_layer'; + +export function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) { + + const context = painter.context; + const implementation = layer.implementation; + + if (painter.renderPass === 'offscreen') { + + const prerender = implementation.prerender; + if (prerender) { + painter.setCustomLayerDefaults(); + context.setColorMode(painter.colorModeForRenderPass()); + + prerender.call(implementation, context.gl, painter.transform.customLayerMatrix()); + + context.setDirty(); + painter.setBaseState(); + } + + } else if (painter.renderPass === 'translucent') { + + painter.setCustomLayerDefaults(); + + context.setColorMode(painter.colorModeForRenderPass()); + context.setStencilMode(StencilMode.disabled); + + const depthMode = implementation.renderingMode === '3d' ? + new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D) : + painter.depthModeForSublayer(0, DepthMode.ReadOnly); + + context.setDepthMode(depthMode); + + implementation.render(context.gl, painter.transform.customLayerMatrix()); + + context.setDirty(); + painter.setBaseState(); + context.bindFramebuffer.set(null); + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_debug.test.ts b/web/libraries/maplibre-gl/src/render/draw_debug.test.ts new file mode 100644 index 00000000..ec19eff3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_debug.test.ts @@ -0,0 +1,122 @@ +import {SourceCache} from '../source/source_cache'; +import {RasterSourceSpecification, SourceSpecification, VectorSourceSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {Style} from '../style/style'; +import {FillStyleLayer} from '../style/style_layer/fill_style_layer'; +import {RasterStyleLayer} from '../style/style_layer/raster_style_layer'; +import {selectDebugSource} from './draw_debug'; + +jest.mock('../style/style'); + +const zoom = 14; + +const defaultSources: { [_: string]: SourceSpecification } = { + 'raster_tiles': { + type: 'raster', + maxzoom: 19, + }, + 'vector_tiles': { + type: 'vector', + maxzoom: 14, + } +}; + +const buildMockStyle = (layers, sources = defaultSources) => { + const style = new Style(null); + style.sourceCaches = Object.fromEntries( + Object.entries(sources).map( + ([id, spec]) => [id, {id, getSource: () => spec} as SourceCache])); + style._layers = layers; + return style; +}; + +describe('selectDebugSource', () => { + test('Decides on vector source if it exists', () => { + const layers = { + '1': new RasterStyleLayer( + {id: '1', type: 'raster', source: 'raster_tiles'}), + '2': new FillStyleLayer( + {id: '2', type: 'fill', source: 'vector_tiles'}), + }; + const mockStyle = buildMockStyle(layers); + const source = selectDebugSource(mockStyle, zoom); + expect(source).toHaveProperty('id', 'vector_tiles'); + }); + + test('Decides raster if vector source not shown at this zoom', () => { + const layers = { + '1': new RasterStyleLayer( + {id: '1', type: 'raster', source: 'raster_tiles'}), + '2': new FillStyleLayer( + {id: '2', type: 'fill', source: 'vector_tiles', maxzoom: 13}), + }; + const mockStyle = buildMockStyle(layers); + const source = selectDebugSource(mockStyle, zoom); + expect(source).toHaveProperty('id', 'raster_tiles'); + }); + + test('Decides raster if vector layer has visibility none', () => { + const layers = { + '1': new RasterStyleLayer( + {id: '1', type: 'raster', source: 'raster_tiles'}), + '2': new FillStyleLayer( + {id: '2', type: 'fill', source: 'vector_tiles', layout: {visibility: 'none'}}), + }; + const style = buildMockStyle(layers); + const source = selectDebugSource(style, zoom); + expect(source).toHaveProperty('id', 'raster_tiles'); + }); + + test('Decides raster if no vector source exists', () => { + const layers = { + '1': new RasterStyleLayer( + {id: '1', type: 'raster', source: 'raster_tiles'}), + }; + const mockStyle = buildMockStyle(layers); + const source = selectDebugSource(mockStyle, zoom); + expect(source).toHaveProperty('id', 'raster_tiles'); + }); + + test('Decides on vector source with highest zoom level', () => { + const sources: { [_: string]: VectorSourceSpecification } = { + 'vector_11': { + type: 'vector', + maxzoom: 11, + }, + 'vector_14': { + type: 'vector', + maxzoom: 14, + } + }; + const layers = { + 'fill_11': new FillStyleLayer( + {id: 'fill_11', type: 'fill', source: 'vector_11'}), + 'fill_14': new FillStyleLayer( + {id: 'fill_14', type: 'fill', source: 'vector_14'}), + }; + const mockStyle = buildMockStyle(layers, sources); + const source = selectDebugSource(mockStyle, zoom); + expect(source).toHaveProperty('id', 'vector_14'); + }); + + test('Decides on raster source with highest zoom level', () => { + const sources: { [_: string]: RasterSourceSpecification } = { + 'raster_11': { + type: 'raster', + maxzoom: 11, + }, + 'raster_14': { + type: 'raster', + maxzoom: 14, + } + }; + const layers = { + 'raster_11': new RasterStyleLayer( + {id: 'raster_11', type: 'raster', source: 'raster_11'}), + 'raster_14': new RasterStyleLayer( + {id: 'raster_14', type: 'raster', source: 'raster_14'}), + }; + const mockStyle = buildMockStyle(layers, sources); + const source = selectDebugSource(mockStyle, zoom); + expect(source).toHaveProperty('id', 'raster_14'); + }); +}); diff --git a/web/libraries/maplibre-gl/src/render/draw_debug.ts b/web/libraries/maplibre-gl/src/render/draw_debug.ts new file mode 100644 index 00000000..5b72587b --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_debug.ts @@ -0,0 +1,148 @@ +import {DepthMode} from '../gl/depth_mode'; +import {StencilMode} from '../gl/stencil_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {debugUniformValues} from './program/debug_program'; +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {ColorMode} from '../gl/color_mode'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {OverscaledTileID} from '../source/tile_id'; +import {Style} from '../style/style'; + +const topColor = new Color(1, 0, 0, 1); +const btmColor = new Color(0, 1, 0, 1); +const leftColor = new Color(0, 0, 1, 1); +const rightColor = new Color(1, 0, 1, 1); +const centerColor = new Color(0, 1, 1, 1); + +export function drawDebugPadding(painter: Painter) { + const padding = painter.transform.padding; + const lineWidth = 3; + // Top + drawHorizontalLine(painter, painter.transform.height - (padding.top || 0), lineWidth, topColor); + // Bottom + drawHorizontalLine(painter, padding.bottom || 0, lineWidth, btmColor); + // Left + drawVerticalLine(painter, padding.left || 0, lineWidth, leftColor); + // Right + drawVerticalLine(painter, painter.transform.width - (padding.right || 0), lineWidth, rightColor); + // Center + const center = painter.transform.centerPoint; + drawCrosshair(painter, center.x, painter.transform.height - center.y, centerColor); +} + +function drawCrosshair(painter: Painter, x: number, y: number, color: Color) { + const size = 20; + const lineWidth = 2; + //Vertical line + drawDebugSSRect(painter, x - lineWidth / 2, y - size / 2, lineWidth, size, color); + //Horizontal line + drawDebugSSRect(painter, x - size / 2, y - lineWidth / 2, size, lineWidth, color); +} + +function drawHorizontalLine(painter: Painter, y: number, lineWidth: number, color: Color) { + drawDebugSSRect(painter, 0, y + lineWidth / 2, painter.transform.width, lineWidth, color); +} + +function drawVerticalLine(painter: Painter, x: number, lineWidth: number, color: Color) { + drawDebugSSRect(painter, x - lineWidth / 2, 0, lineWidth, painter.transform.height, color); +} + +function drawDebugSSRect(painter: Painter, x: number, y: number, width: number, height: number, color: Color) { + const context = painter.context; + const gl = context.gl; + + gl.enable(gl.SCISSOR_TEST); + gl.scissor(x * painter.pixelRatio, y * painter.pixelRatio, width * painter.pixelRatio, height * painter.pixelRatio); + context.clear({color}); + gl.disable(gl.SCISSOR_TEST); +} + +export function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array) { + for (let i = 0; i < coords.length; i++) { + drawDebugTile(painter, sourceCache, coords[i]); + } +} + +function drawDebugTile(painter: Painter, sourceCache: SourceCache, coord: OverscaledTileID) { + const context = painter.context; + const gl = context.gl; + + const posMatrix = coord.posMatrix; + const program = painter.useProgram('debug'); + + const depthMode = DepthMode.disabled; + const stencilMode = StencilMode.disabled; + const colorMode = painter.colorModeForRenderPass(); + const id = '$debug'; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + + context.activeTexture.set(gl.TEXTURE0); + + const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData; + const tileByteLength = (tileRawData && tileRawData.byteLength) || 0; + const tileSizeKb = Math.floor(tileByteLength / 1024); + const tileSize = sourceCache.getTile(coord).tileSize; + const scaleRatio = (512 / Math.min(tileSize, 512) * (coord.overscaledZ / painter.transform.zoom)) * 0.5; + let tileIdText = coord.canonical.toString(); + if (coord.overscaledZ !== coord.canonical.z) { + tileIdText += ` => ${coord.overscaledZ}`; + } + const tileLabel = `${tileIdText} ${tileSizeKb}kB`; + drawTextToOverlay(painter, tileLabel); + + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, ColorMode.alphaBlended, CullFaceMode.disabled, + debugUniformValues(posMatrix, Color.transparent, scaleRatio), null, id, + painter.debugBuffer, painter.quadTriangleIndexBuffer, painter.debugSegments); + program.draw(context, gl.LINE_STRIP, depthMode, stencilMode, colorMode, CullFaceMode.disabled, + debugUniformValues(posMatrix, Color.red), terrainData, id, + painter.debugBuffer, painter.tileBorderIndexBuffer, painter.debugSegments); +} + +function drawTextToOverlay(painter: Painter, text: string) { + painter.initDebugOverlayCanvas(); + const canvas = painter.debugOverlayCanvas; + const gl = painter.context.gl; + const ctx2d = painter.debugOverlayCanvas.getContext('2d'); + ctx2d.clearRect(0, 0, canvas.width, canvas.height); + + ctx2d.shadowColor = 'white'; + ctx2d.shadowBlur = 2; + ctx2d.lineWidth = 1.5; + ctx2d.strokeStyle = 'white'; + ctx2d.textBaseline = 'top'; + ctx2d.font = `bold ${36}px Open Sans, sans-serif`; + ctx2d.fillText(text, 5, 5); + ctx2d.strokeText(text, 5, 5); + + painter.debugOverlayTexture.update(canvas); + painter.debugOverlayTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); +} + +export function selectDebugSource(style: Style, zoom: number): SourceCache | null { + // Use vector source with highest maxzoom + // Else use source with highest maxzoom of any type + let selectedSource: SourceCache = null; + const layers = Object.values(style._layers); + const sources = layers.flatMap((layer) => { + if (layer.source && !layer.isHidden(zoom)) { + const sourceCache = style.sourceCaches[layer.source]; + return [sourceCache]; + } else { + return []; + } + }); + const vectorSources = sources.filter((source) => source.getSource().type === 'vector'); + const otherSources = sources.filter((source) => source.getSource().type !== 'vector'); + const considerSource = (source: SourceCache) => { + if (!selectedSource || (selectedSource.getSource().maxzoom < source.getSource().maxzoom)) { + selectedSource = source; + } + }; + vectorSources.forEach((source) => considerSource(source)); + if (!selectedSource) { + otherSources.forEach((source) => considerSource(source)); + } + return selectedSource; +} diff --git a/web/libraries/maplibre-gl/src/render/draw_fill.test.ts b/web/libraries/maplibre-gl/src/render/draw_fill.test.ts new file mode 100644 index 00000000..e0a02762 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_fill.test.ts @@ -0,0 +1,137 @@ +import {mat4} from 'gl-matrix'; +import {OverscaledTileID} from '../source/tile_id'; +import {SourceCache} from '../source/source_cache'; +import {Tile} from '../source/tile'; +import {Painter} from './painter'; +import {Program} from './program'; +import type {ZoomHistory} from '../style/zoom_history'; +import type {Map} from '../ui/map'; +import {Transform} from '../geo/transform'; +import type {EvaluationParameters} from '../style/evaluation_parameters'; +import type {FillLayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {Style} from '../style/style'; +import {FillStyleLayer} from '../style/style_layer/fill_style_layer'; +import {drawFill} from './draw_fill'; +import {FillBucket} from '../data/bucket/fill_bucket'; +import {ProgramConfiguration, ProgramConfigurationSet} from '../data/program_configuration'; + +jest.mock('./painter'); +jest.mock('./program'); +jest.mock('../source/source_cache'); +jest.mock('../source/tile'); +jest.mock('../data/bucket/symbol_bucket'); +jest.mock('../symbol/projection'); + +describe('drawFill', () => { + test('should call programConfiguration.setConstantPatternPositions for transitioning fill-pattern', () => { + + const painterMock: Painter = constructMockPainer(); + const layer: FillStyleLayer = constructMockLayer(); + + const programMock = new Program(null as any, null as any, null as any, null as any, null as any, null as any); + (painterMock.useProgram as jest.Mock).mockReturnValue(programMock); + + const mockTile = constructMockTile(layer); + + const sourceCacheMock = new SourceCache(null as any, null as any, null as any); + (sourceCacheMock.getTile as jest.Mock).mockReturnValue(mockTile); + sourceCacheMock.map = {showCollisionBoxes: false} as any as Map; + + drawFill(painterMock, sourceCacheMock, layer, [mockTile.tileID]); + + // twice: first for fill, second for stroke + expect(programMock.draw).toHaveBeenCalledTimes(2); + + const bucket: FillBucket = (mockTile.getBucket(layer) as any); + const programConfiguration = bucket.programConfigurations.get(layer.id); + + expect(programConfiguration.setConstantPatternPositions).toHaveBeenCalled(); + }); + + function constructMockLayer(): FillStyleLayer { + const layerSpec = { + id: 'mock-layer', + source: 'empty-source', + type: 'fill', + layout: {}, + 'paint': { + 'fill-pattern': 'pattern0' + } + } as FillLayerSpecification; + const layer = new FillStyleLayer(layerSpec); + layer.getCrossfadeParameters = () => ({} as any); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + + // Important: this setup is on purpose -- to NOT match layerspec + // 'fill-pattern': 'pattern0' + // so tile.imageAtlas.patternPositions['pattern0'] would return nothing + // mimicing the transitiong fill-pattern value + layer.getPaintProperty = () => { + return 'pattern1'; + }; + + return layer; + } + + function constructMockPainer(): Painter { + const painterMock = new Painter(null as any, null as any); + painterMock.context = { + gl: {}, + activeTexture: { + set: () => {} + } + } as any; + painterMock.renderPass = 'translucent'; + painterMock.transform = {pitch: 0, labelPlaneMatrix: mat4.create()} as any as Transform; + painterMock.options = {} as any; + painterMock.style = { + map: {} + } as any as Style; + + return painterMock; + } + + function constructMockTile(layer: FillStyleLayer): Tile { + const tileId = new OverscaledTileID(1, 0, 1, 0, 0); + tileId.posMatrix = mat4.create(); + + const tile = new Tile(tileId, 256); + tile.tileID = tileId; + + // Important: this setup is on purpose -- to NOT match layerspec + // 'fill-pattern': 'pattern0' + // so tile.imageAtlas.patternPositions['pattern0'] would return nothing + // mimicing the transitiong fill-pattern value + tile.imageAtlas = { + patternPositions: { + 'pattern1': {} + } + } as any; + tile.imageAtlasTexture = { + bind: () => {} + } as any; + + const bucketMock = constructMockBucket(layer); + + (tile.getBucket as jest.Mock).mockReturnValue(bucketMock); + (tile.patternsLoaded as jest.Mock).mockReturnValue(true); + return tile; + } + + function constructMockBucket(layer: FillStyleLayer) { + const bucketMock = new FillBucket({ + layers: [layer] + } as any); + + const mockProgramConfigurations: ProgramConfigurationSet = {} as any; + const mockProgramConfiguration: ProgramConfiguration = {} as any; + mockProgramConfiguration.updatePaintBuffers = () => {}; + mockProgramConfiguration.setConstantPatternPositions = jest.fn(); + + mockProgramConfigurations.get = () => mockProgramConfiguration; + + bucketMock.programConfigurations = mockProgramConfigurations; + + return bucketMock; + } +}); diff --git a/web/libraries/maplibre-gl/src/render/draw_fill.ts b/web/libraries/maplibre-gl/src/render/draw_fill.ts new file mode 100644 index 00000000..c850dc98 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_fill.ts @@ -0,0 +1,128 @@ +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {ColorMode} from '../gl/color_mode'; +import { + fillUniformValues, + fillPatternUniformValues, + fillOutlineUniformValues, + fillOutlinePatternUniformValues +} from './program/fill_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {FillStyleLayer} from '../style/style_layer/fill_style_layer'; +import type {FillBucket} from '../data/bucket/fill_bucket'; +import type {OverscaledTileID} from '../source/tile_id'; +import {updatePatternPositionsInProgram} from './update_pattern_positions_in_program'; + +export function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLayer, coords: Array) { + const color = layer.paint.get('fill-color'); + const opacity = layer.paint.get('fill-opacity'); + + if (opacity.constantOr(1) === 0) { + return; + } + + const colorMode = painter.colorModeForRenderPass(); + + const pattern = layer.paint.get('fill-pattern'); + const pass = painter.opaquePassEnabledForLayer() && + (!pattern.constantOr(1 as any) && + color.constantOr(Color.transparent).a === 1 && + opacity.constantOr(0) === 1) ? 'opaque' : 'translucent'; + + // Draw fill + if (painter.renderPass === pass) { + const depthMode = painter.depthModeForSublayer( + 1, painter.renderPass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly); + drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, false); + } + + // Draw stroke + if (painter.renderPass === 'translucent' && layer.paint.get('fill-antialias')) { + + // If we defined a different color for the fill outline, we are + // going to ignore the bits in 0x07 and just care about the global + // clipping mask. + // Otherwise, we only want to drawFill the antialiased parts that are + // *outside* the current shape. This is important in case the fill + // or stroke color is translucent. If we wouldn't clip to outside + // the current shape, some pixels from the outline stroke overlapped + // the (non-antialiased) fill. + const depthMode = painter.depthModeForSublayer( + layer.getPaintProperty('fill-outline-color') ? 2 : 0, DepthMode.ReadOnly); + drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, true); + } +} + +function drawFillTiles( + painter: Painter, + sourceCache: SourceCache, + layer: FillStyleLayer, + coords: Array, + depthMode: Readonly, + colorMode: Readonly, + isOutline: boolean) { + const gl = painter.context.gl; + const fillPropertyName = 'fill-pattern'; + const patternProperty = layer.paint.get(fillPropertyName); + const image = patternProperty && patternProperty.constantOr(1 as any); + const crossfade = layer.getCrossfadeParameters(); + let drawMode, programName, uniformValues, indexBuffer, segments; + + if (!isOutline) { + programName = image ? 'fillPattern' : 'fill'; + drawMode = gl.TRIANGLES; + } else { + programName = image && !layer.getPaintProperty('fill-outline-color') ? 'fillOutlinePattern' : 'fillOutline'; + drawMode = gl.LINES; + } + + const constantPattern = patternProperty.constantOr(null); + + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + if (image && !tile.patternsLoaded()) continue; + + const bucket: FillBucket = (tile.getBucket(layer) as any); + if (!bucket) continue; + + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram(programName, programConfiguration); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + + if (image) { + painter.context.activeTexture.set(gl.TEXTURE0); + tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + programConfiguration.updatePaintBuffers(crossfade); + } + + updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer); + + const terrainCoord = terrainData ? coord : null; + const posMatrix = terrainCoord ? terrainCoord.posMatrix : coord.posMatrix; + const tileMatrix = painter.translatePosMatrix(posMatrix, tile, + layer.paint.get('fill-translate'), layer.paint.get('fill-translate-anchor')); + + if (!isOutline) { + indexBuffer = bucket.indexBuffer; + segments = bucket.segments; + uniformValues = image ? + fillPatternUniformValues(tileMatrix, painter, crossfade, tile) : + fillUniformValues(tileMatrix); + } else { + indexBuffer = bucket.indexBuffer2; + segments = bucket.segments2; + const drawingBufferSize = [gl.drawingBufferWidth, gl.drawingBufferHeight] as [number, number]; + uniformValues = (programName === 'fillOutlinePattern' && image) ? + fillOutlinePatternUniformValues(tileMatrix, painter, crossfade, tile, drawingBufferSize) : + fillOutlineUniformValues(tileMatrix, drawingBufferSize); + } + + program.draw(painter.context, drawMode, depthMode, + painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData, + layer.id, bucket.layoutVertexBuffer, indexBuffer, segments, + layer.paint, painter.transform.zoom, programConfiguration); + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_fill_extrusion.ts b/web/libraries/maplibre-gl/src/render/draw_fill_extrusion.ts new file mode 100644 index 00000000..6ce366dd --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_fill_extrusion.ts @@ -0,0 +1,97 @@ +import {DepthMode} from '../gl/depth_mode'; +import {StencilMode} from '../gl/stencil_mode'; +import {ColorMode} from '../gl/color_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import { + fillExtrusionUniformValues, + fillExtrusionPatternUniformValues, +} from './program/fill_extrusion_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer'; +import type {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket'; +import type {OverscaledTileID} from '../source/tile_id'; + +import {updatePatternPositionsInProgram} from './update_pattern_positions_in_program'; + +export function drawFillExtrusion(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLayer, coords: Array) { + const opacity = layer.paint.get('fill-extrusion-opacity'); + if (opacity === 0) { + return; + } + + if (painter.renderPass === 'translucent') { + const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D); + + if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1 as any)) { + const colorMode = painter.colorModeForRenderPass(); + drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode); + + } else { + // Draw transparent buildings in two passes so that only the closest surface is drawn. + // First draw all the extrusions into only the depth buffer. No colors are drawn. + drawExtrusionTiles(painter, source, layer, coords, depthMode, + StencilMode.disabled, + ColorMode.disabled); + + // Then draw all the extrusions a second type, only coloring fragments if they have the + // same depth value as the closest fragment in the previous pass. Use the stencil buffer + // to prevent the second draw in cases where we have coincident polygons. + drawExtrusionTiles(painter, source, layer, coords, depthMode, + painter.stencilModeFor3D(), + painter.colorModeForRenderPass()); + } + } +} + +function drawExtrusionTiles( + painter: Painter, + source: SourceCache, + layer: FillExtrusionStyleLayer, + coords: OverscaledTileID[], + depthMode: DepthMode, + stencilMode: Readonly, + colorMode: Readonly) { + const context = painter.context; + const gl = context.gl; + const fillPropertyName = 'fill-extrusion-pattern'; + const patternProperty = layer.paint.get(fillPropertyName); + const image = patternProperty.constantOr(1 as any); + const crossfade = layer.getCrossfadeParameters(); + const opacity = layer.paint.get('fill-extrusion-opacity'); + const constantPattern = patternProperty.constantOr(null); + for (const coord of coords) { + const tile = source.getTile(coord); + const bucket: FillExtrusionBucket = (tile.getBucket(layer) as any); + if (!bucket) continue; + + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration); + + if (image) { + painter.context.activeTexture.set(gl.TEXTURE0); + tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + programConfiguration.updatePaintBuffers(crossfade); + } + + updatePatternPositionsInProgram(programConfiguration, fillPropertyName, constantPattern, tile, layer); + + const matrix = painter.translatePosMatrix( + coord.posMatrix, + tile, + layer.paint.get('fill-extrusion-translate'), + layer.paint.get('fill-extrusion-translate-anchor')); + + const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient'); + const uniformValues = image ? + fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile) : + fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity); + + program.draw(context, context.gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.backCCW, + uniformValues, terrainData, layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, + bucket.segments, layer.paint, painter.transform.zoom, + programConfiguration, painter.style.map.terrain && bucket.centroidVertexBuffer); + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_heatmap.ts b/web/libraries/maplibre-gl/src/render/draw_heatmap.ts new file mode 100644 index 00000000..bf2e6a68 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_heatmap.ts @@ -0,0 +1,133 @@ +import {Texture} from './texture'; +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {DepthMode} from '../gl/depth_mode'; +import {StencilMode} from '../gl/stencil_mode'; +import {ColorMode} from '../gl/color_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {Context} from '../gl/context'; +import {Framebuffer} from '../gl/framebuffer'; +import { + heatmapUniformValues, + heatmapTextureUniformValues +} from './program/heatmap_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {HeatmapStyleLayer} from '../style/style_layer/heatmap_style_layer'; +import type {HeatmapBucket} from '../data/bucket/heatmap_bucket'; +import type {OverscaledTileID} from '../source/tile_id'; + +export function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapStyleLayer, coords: Array) { + if (layer.paint.get('heatmap-opacity') === 0) { + return; + } + + if (painter.renderPass === 'offscreen') { + const context = painter.context; + const gl = context.gl; + + // Allow kernels to be drawn across boundaries, so that + // large kernels are not clipped to tiles + const stencilMode = StencilMode.disabled; + // Turn on additive blending for kernels, which is a key aspect of kernel density estimation formula + const colorMode = new ColorMode([gl.ONE, gl.ONE], Color.transparent, [true, true, true, true]); + + bindFramebuffer(context, painter, layer); + + context.clear({color: Color.transparent}); + + for (let i = 0; i < coords.length; i++) { + const coord = coords[i]; + + // Skip tiles that have uncovered parents to avoid flickering; we don't need + // to use complex tile masking here because the change between zoom levels is subtle, + // so it's fine to simply render the parent until all its 4 children are loaded + if (sourceCache.hasRenderableParent(coord)) continue; + + const tile = sourceCache.getTile(coord); + const bucket: HeatmapBucket = (tile.getBucket(layer) as any); + if (!bucket) continue; + + const programConfiguration = bucket.programConfigurations.get(layer.id); + const program = painter.useProgram('heatmap', programConfiguration); + const {zoom} = painter.transform; + + program.draw(context, gl.TRIANGLES, DepthMode.disabled, stencilMode, colorMode, CullFaceMode.disabled, + heatmapUniformValues(coord.posMatrix, tile, zoom, layer.paint.get('heatmap-intensity')), null, + layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, + bucket.segments, layer.paint, painter.transform.zoom, + programConfiguration); + } + + context.viewport.set([0, 0, painter.width, painter.height]); + + } else if (painter.renderPass === 'translucent') { + painter.context.setColorMode(painter.colorModeForRenderPass()); + renderTextureToMap(painter, layer); + } +} + +function bindFramebuffer(context: Context, painter: Painter, layer: HeatmapStyleLayer) { + const gl = context.gl; + context.activeTexture.set(gl.TEXTURE1); + + // Use a 4x downscaled screen texture for better performance + context.viewport.set([0, 0, painter.width / 4, painter.height / 4]); + + let fbo = layer.heatmapFbo; + + if (!fbo) { + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + + fbo = layer.heatmapFbo = context.createFramebuffer(painter.width / 4, painter.height / 4, false, false); + + bindTextureToFramebuffer(context, painter, texture, fbo); + + } else { + gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get()); + context.bindFramebuffer.set(fbo.framebuffer); + } +} + +function bindTextureToFramebuffer(context: Context, painter: Painter, texture: WebGLTexture, fbo: Framebuffer) { + const gl = context.gl; + // Use the higher precision half-float texture where available (producing much smoother looking heatmaps); + // Otherwise, fall back to a low precision texture + + const numType = context.HALF_FLOAT ?? gl.UNSIGNED_BYTE; + const internalFormat = context.RGBA16F ?? gl.RGBA; + + gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, painter.width / 4, painter.height / 4, 0, gl.RGBA, numType, null); + fbo.colorAttachment.set(texture); +} + +function renderTextureToMap(painter: Painter, layer: HeatmapStyleLayer) { + const context = painter.context; + const gl = context.gl; + + // Here we bind two different textures from which we'll sample in drawing + // heatmaps: the kernel texture, prepared in the offscreen pass, and a + // color ramp texture. + const fbo = layer.heatmapFbo; + if (!fbo) return; + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get()); + + context.activeTexture.set(gl.TEXTURE1); + let colorRampTexture = layer.colorRampTexture; + if (!colorRampTexture) { + colorRampTexture = layer.colorRampTexture = new Texture(context, layer.colorRamp, gl.RGBA); + } + colorRampTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + + painter.useProgram('heatmapTexture').draw(context, gl.TRIANGLES, + DepthMode.disabled, StencilMode.disabled, painter.colorModeForRenderPass(), CullFaceMode.disabled, + heatmapTextureUniformValues(painter, layer, 0, 1), null, + layer.id, painter.viewportBuffer, painter.quadTriangleIndexBuffer, + painter.viewportSegments, layer.paint, painter.transform.zoom); +} diff --git a/web/libraries/maplibre-gl/src/render/draw_hillshade.ts b/web/libraries/maplibre-gl/src/render/draw_hillshade.ts new file mode 100644 index 00000000..39f46412 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_hillshade.ts @@ -0,0 +1,119 @@ +import {Texture} from './texture'; +import {StencilMode} from '../gl/stencil_mode'; +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {ColorMode} from '../gl/color_mode'; +import {Tile} from '../source/tile'; +import { + hillshadeUniformValues, + hillshadeUniformPrepareValues +} from './program/hillshade_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer'; +import type {OverscaledTileID} from '../source/tile_id'; + +export function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: HillshadeStyleLayer, tileIDs: Array) { + if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') return; + + const context = painter.context; + + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + const colorMode = painter.colorModeForRenderPass(); + + const [stencilModes, coords] = painter.renderPass === 'translucent' ? + painter.stencilConfigForOverlap(tileIDs) : [{}, tileIDs]; + + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + if (typeof tile.needsHillshadePrepare !== 'undefined' && tile.needsHillshadePrepare && painter.renderPass === 'offscreen') { + prepareHillshade(painter, tile, layer, depthMode, StencilMode.disabled, colorMode); + } else if (painter.renderPass === 'translucent') { + renderHillshade(painter, coord, tile, layer, depthMode, stencilModes[coord.overscaledZ], colorMode); + } + } + + context.viewport.set([0, 0, painter.width, painter.height]); +} + +function renderHillshade( + painter: Painter, + coord: OverscaledTileID, + tile: Tile, + layer: HillshadeStyleLayer, + depthMode: Readonly, + stencilMode: Readonly, + colorMode: Readonly) { + const context = painter.context; + const gl = context.gl; + const fbo = tile.fbo; + if (!fbo) return; + + const program = painter.useProgram('hillshade'); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get()); + + const terrainCoord = terrainData ? coord : null; + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, + hillshadeUniformValues(painter, tile, layer, terrainCoord), terrainData, layer.id, painter.rasterBoundsBuffer, + painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments); + +} + +// hillshade rendering is done in two steps. the prepare step first calculates the slope of the terrain in the x and y +// directions for each pixel, and saves those values to a framebuffer texture in the r and g channels. +function prepareHillshade( + painter: Painter, + tile: Tile, + layer: HillshadeStyleLayer, + depthMode: Readonly, + stencilMode: Readonly, + colorMode: Readonly) { + const context = painter.context; + const gl = context.gl; + const dem = tile.dem; + if (dem && dem.data) { + const tileSize = dem.dim; + const textureStride = dem.stride; + + const pixelData = dem.getPixels(); + context.activeTexture.set(gl.TEXTURE1); + + context.pixelStoreUnpackPremultiplyAlpha.set(false); + tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride); + if (tile.demTexture) { + const demTexture = tile.demTexture; + demTexture.update(pixelData, {premultiply: false}); + demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE); + } else { + tile.demTexture = new Texture(context, pixelData, gl.RGBA, {premultiply: false}); + tile.demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE); + } + + context.activeTexture.set(gl.TEXTURE0); + + let fbo = tile.fbo; + + if (!fbo) { + const renderTexture = new Texture(context, {width: tileSize, height: tileSize, data: null}, gl.RGBA); + renderTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + + fbo = tile.fbo = context.createFramebuffer(tileSize, tileSize, true, false); + fbo.colorAttachment.set(renderTexture.texture); + } + + context.bindFramebuffer.set(fbo.framebuffer); + context.viewport.set([0, 0, tileSize, tileSize]); + + painter.useProgram('hillshadePrepare').draw(context, gl.TRIANGLES, + depthMode, stencilMode, colorMode, CullFaceMode.disabled, + hillshadeUniformPrepareValues(tile.tileID, dem), + null, layer.id, painter.rasterBoundsBuffer, + painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments); + + tile.needsHillshadePrepare = false; + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_line.ts b/web/libraries/maplibre-gl/src/render/draw_line.ts new file mode 100644 index 00000000..28516064 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_line.ts @@ -0,0 +1,125 @@ +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {Texture} from './texture'; +import { + lineUniformValues, + linePatternUniformValues, + lineSDFUniformValues, + lineGradientUniformValues +} from './program/line_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {LineStyleLayer} from '../style/style_layer/line_style_layer'; +import type {LineBucket} from '../data/bucket/line_bucket'; +import type {OverscaledTileID} from '../source/tile_id'; +import {clamp, nextPowerOfTwo} from '../util/util'; +import {renderColorRamp} from '../util/color_ramp'; +import {EXTENT} from '../data/extent'; + +export function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array) { + if (painter.renderPass !== 'translucent') return; + + const opacity = layer.paint.get('line-opacity'); + const width = layer.paint.get('line-width'); + if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return; + + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + const colorMode = painter.colorModeForRenderPass(); + + const dasharray = layer.paint.get('line-dasharray'); + const patternProperty = layer.paint.get('line-pattern'); + const image = patternProperty.constantOr(1 as any); + + const gradient = layer.paint.get('line-gradient'); + const crossfade = layer.getCrossfadeParameters(); + + const programId = + image ? 'linePattern' : + dasharray ? 'lineSDF' : + gradient ? 'lineGradient' : 'line'; + + const context = painter.context; + const gl = context.gl; + + let firstTile = true; + + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + + if (image && !tile.patternsLoaded()) continue; + + const bucket: LineBucket = (tile.getBucket(layer) as any); + if (!bucket) continue; + + const programConfiguration = bucket.programConfigurations.get(layer.id); + const prevProgram = painter.context.program.get(); + const program = painter.useProgram(programId, programConfiguration); + const programChanged = firstTile || program.program !== prevProgram; + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + + const constantPattern = patternProperty.constantOr(null); + if (constantPattern && tile.imageAtlas) { + const atlas = tile.imageAtlas; + const posTo = atlas.patternPositions[constantPattern.to.toString()]; + const posFrom = atlas.patternPositions[constantPattern.from.toString()]; + if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom); + } + + const terrainCoord = terrainData ? coord : null; + const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade, terrainCoord) : + dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade, terrainCoord) : + gradient ? lineGradientUniformValues(painter, tile, layer, bucket.lineClipsArray.length, terrainCoord) : + lineUniformValues(painter, tile, layer, terrainCoord); + + if (image) { + context.activeTexture.set(gl.TEXTURE0); + tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + programConfiguration.updatePaintBuffers(crossfade); + } else if (dasharray && (programChanged || painter.lineAtlas.dirty)) { + context.activeTexture.set(gl.TEXTURE0); + painter.lineAtlas.bind(context); + } else if (gradient) { + const layerGradient = bucket.gradients[layer.id]; + let gradientTexture = layerGradient.texture; + if (layer.gradientVersion !== layerGradient.version) { + let textureResolution = 256; + if (layer.stepInterpolant) { + const sourceMaxZoom = sourceCache.getSource().maxzoom; + const potentialOverzoom = coord.canonical.z === sourceMaxZoom ? + Math.ceil(1 << (painter.transform.maxZoom - coord.canonical.z)) : 1; + const lineLength = bucket.maxLineLength / EXTENT; + // Logical pixel tile size is 512px, and 1024px right before current zoom + 1 + const maxTilePixelSize = 1024; + // Maximum possible texture coverage heuristic, bound by hardware max texture size + const maxTextureCoverage = lineLength * maxTilePixelSize * potentialOverzoom; + textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize); + } + layerGradient.gradient = renderColorRamp({ + expression: layer.gradientExpression(), + evaluationKey: 'lineProgress', + resolution: textureResolution, + image: layerGradient.gradient || undefined, + clips: bucket.lineClipsArray + }); + if (layerGradient.texture) { + layerGradient.texture.update(layerGradient.gradient); + } else { + layerGradient.texture = new Texture(context, layerGradient.gradient, gl.RGBA); + } + layerGradient.version = layer.gradientVersion; + gradientTexture = layerGradient.texture; + } + context.activeTexture.set(gl.TEXTURE0); + gradientTexture.bind(layer.stepInterpolant ? gl.NEAREST : gl.LINEAR, gl.CLAMP_TO_EDGE); + } + + program.draw(context, gl.TRIANGLES, depthMode, + painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues, terrainData, + layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments, + layer.paint, painter.transform.zoom, programConfiguration, bucket.layoutVertexBuffer2); + + firstTile = false; + // once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_raster.ts b/web/libraries/maplibre-gl/src/render/draw_raster.ts new file mode 100644 index 00000000..2bb28331 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_raster.ts @@ -0,0 +1,123 @@ +import {clamp} from '../util/util'; + +import {ImageSource} from '../source/image_source'; +import {browser} from '../util/browser'; +import {StencilMode} from '../gl/stencil_mode'; +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {rasterUniformValues} from './program/raster_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {RasterStyleLayer} from '../style/style_layer/raster_style_layer'; +import type {OverscaledTileID} from '../source/tile_id'; + +export function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array) { + if (painter.renderPass !== 'translucent') return; + if (layer.paint.get('raster-opacity') === 0) return; + if (!tileIDs.length) return; + + const context = painter.context; + const gl = context.gl; + const source = sourceCache.getSource(); + const program = painter.useProgram('raster'); + + const colorMode = painter.colorModeForRenderPass(); + + const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] : + painter.stencilConfigForOverlap(tileIDs); + + const minTileZ = coords[coords.length - 1].overscaledZ; + + const align = !painter.options.moving; + for (const coord of coords) { + // Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers + // Use gl.LESS to prevent double drawing in areas where tiles overlap. + const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ, + layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS); + + const tile = sourceCache.getTile(coord); + + tile.registerFadeDuration(layer.paint.get('raster-fade-duration')); + + const parentTile = sourceCache.findLoadedParent(coord, 0), + fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform, painter.style.map.terrain); + + let parentScaleBy, parentTL; + + const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR; + + context.activeTexture.set(gl.TEXTURE0); + tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + + context.activeTexture.set(gl.TEXTURE1); + + if (parentTile) { + parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ); + parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1]; + + } else { + tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + } + + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + const terrainCoord = terrainData ? coord : null; + const posMatrix = terrainCoord ? terrainCoord.posMatrix : painter.transform.calculatePosMatrix(coord.toUnwrapped(), align); + const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer); + + if (source instanceof ImageSource) { + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled, + uniformValues, terrainData, layer.id, source.boundsBuffer, + painter.quadTriangleIndexBuffer, source.boundsSegments); + } else { + program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled, + uniformValues, terrainData, layer.id, painter.rasterBoundsBuffer, + painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments); + } + } +} + +function getFadeValues(tile, parentTile, sourceCache, layer, transform, terrain) { + const fadeDuration = layer.paint.get('raster-fade-duration'); + + if (!terrain && fadeDuration > 0) { + const now = browser.now(); + const sinceTile = (now - tile.timeAdded) / fadeDuration; + const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1; + + const source = sourceCache.getSource(); + const idealZ = transform.coveringZoomLevel({ + tileSize: source.tileSize, + roundZoom: source.roundZoom + }); + + // if no parent or parent is older, fade in; if parent is younger, fade out + const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ); + + const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1); + + // we don't crossfade tiles that were just refreshed upon expiring: + // once they're old enough to pass the crossfading threshold + // (fadeDuration), unset the `refreshedUponExpiration` flag so we don't + // incorrectly fail to crossfade them when zooming + if (tile.refreshedUponExpiration && sinceTile >= 1) tile.refreshedUponExpiration = false; + + if (parentTile) { + return { + opacity: 1, + mix: 1 - childOpacity + }; + } else { + return { + opacity: childOpacity, + mix: 0 + }; + } + } else { + return { + opacity: 1, + mix: 0 + }; + } +} diff --git a/web/libraries/maplibre-gl/src/render/draw_symbol.test.ts b/web/libraries/maplibre-gl/src/render/draw_symbol.test.ts new file mode 100644 index 00000000..a7f85142 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_symbol.test.ts @@ -0,0 +1,223 @@ +import {mat4} from 'gl-matrix'; +import {OverscaledTileID} from '../source/tile_id'; +import {SymbolBucket} from '../data/bucket/symbol_bucket'; +import {SourceCache} from '../source/source_cache'; +import {Tile} from '../source/tile'; +import {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; +import {Painter} from './painter'; +import {Program} from './program'; +import {drawSymbols} from './draw_symbol'; +import * as symbolProjection from '../symbol/projection'; +import type {ZoomHistory} from '../style/zoom_history'; +import type {Map} from '../ui/map'; +import {Transform} from '../geo/transform'; +import type {EvaluationParameters} from '../style/evaluation_parameters'; +import type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {Style} from '../style/style'; + +jest.mock('./painter'); +jest.mock('./program'); +jest.mock('../source/source_cache'); +jest.mock('../source/tile'); +jest.mock('../data/bucket/symbol_bucket'); +jest.mock('../symbol/projection'); + +describe('drawSymbol', () => { + test('should not do anything', () => { + const mockPainter = new Painter(null, null); + mockPainter.renderPass = 'opaque'; + + drawSymbols(mockPainter, null, null, null, null); + + expect(mockPainter.colorModeForRenderPass).not.toHaveBeenCalled(); + }); + + test('should call program.draw', () => { + + const painterMock = new Painter(null, null); + painterMock.context = { + gl: {}, + activeTexture: { + set: () => { } + } + } as any; + painterMock.renderPass = 'translucent'; + painterMock.transform = {pitch: 0, labelPlaneMatrix: mat4.create()} as any as Transform; + painterMock.options = {} as any; + painterMock.style = { + map: {} + } as any as Style; + + const layerSpec = { + id: 'mock-layer', + source: 'empty-source', + type: 'symbol', + layout: {}, + paint: { + 'text-opacity': 1 + } + } as SymbolLayerSpecification; + const layer = new SymbolStyleLayer(layerSpec); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + + const tileId = new OverscaledTileID(1, 0, 1, 0, 0); + tileId.posMatrix = mat4.create(); + const programMock = new Program(null, null, null, null, null, null); + (painterMock.useProgram as jest.Mock).mockReturnValue(programMock); + const bucketMock = new SymbolBucket(null); + bucketMock.icon = { + programConfigurations: { + get: () => { } + }, + segments: { + get: () => [1] + }, + hasVisibleVertices: true + } as any; + bucketMock.iconSizeData = { + kind: 'constant', + layoutSize: 1 + }; + const tile = new Tile(tileId, 256); + tile.tileID = tileId; + tile.imageAtlasTexture = { + bind: () => { } + } as any; + (tile.getBucket as jest.Mock).mockReturnValue(bucketMock); + const sourceCacheMock = new SourceCache(null, null, null); + (sourceCacheMock.getTile as jest.Mock).mockReturnValue(tile); + sourceCacheMock.map = {showCollisionBoxes: false} as any as Map; + + drawSymbols(painterMock, sourceCacheMock, layer, [tileId], null); + + expect(programMock.draw).toHaveBeenCalledTimes(1); + }); + + test('should call updateLineLabels with rotateToLine === false if text-rotation-alignment is viewport-glyph', () => { + + const painterMock = new Painter(null, null); + painterMock.context = { + gl: {}, + activeTexture: { + set: () => { } + } + } as any; + painterMock.renderPass = 'translucent'; + painterMock.transform = {pitch: 0, labelPlaneMatrix: mat4.create()} as any as Transform; + painterMock.options = {} as any; + + const layerSpec = { + id: 'mock-layer', + source: 'empty-source', + type: 'symbol', + layout: { + 'text-rotation-alignment': 'viewport-glyph', + 'text-field': 'ABC', + 'symbol-placement': 'line', + }, + paint: { + 'text-opacity': 1 + } + } as SymbolLayerSpecification; + const layer = new SymbolStyleLayer(layerSpec); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + + const tileId = new OverscaledTileID(1, 0, 1, 0, 0); + tileId.posMatrix = mat4.create(); + const programMock = new Program(null, null, null, null, null, null); + (painterMock.useProgram as jest.Mock).mockReturnValue(programMock); + const bucketMock = new SymbolBucket(null); + bucketMock.icon = { + programConfigurations: { + get: () => { } + }, + segments: { + get: () => [1] + }, + hasVisibleVertices: true + } as any; + bucketMock.iconSizeData = { + kind: 'constant', + layoutSize: 1 + }; + const tile = new Tile(tileId, 256); + tile.tileID = tileId; + tile.imageAtlasTexture = { + bind: () => { } + } as any; + (tile.getBucket as jest.Mock).mockReturnValue(bucketMock); + const sourceCacheMock = new SourceCache(null, null, null); + (sourceCacheMock.getTile as jest.Mock).mockReturnValue(tile); + sourceCacheMock.map = {showCollisionBoxes: false} as any as Map; + painterMock.style = { + map: {} + } as any as Style; + + const spy = jest.spyOn(symbolProjection, 'updateLineLabels'); + drawSymbols(painterMock, sourceCacheMock, layer, [tileId], null); + + expect(spy.mock.calls[0][9]).toBeFalsy(); // rotateToLine === false + }); + + test('transparent tile optimization should prevent program.draw from being called', () => { + + const painterMock = new Painter(null, null); + painterMock.context = { + gl: {}, + activeTexture: { + set: () => { } + } + } as any; + painterMock.renderPass = 'translucent'; + painterMock.transform = {pitch: 0, labelPlaneMatrix: mat4.create()} as any as Transform; + painterMock.options = {} as any; + painterMock.style = { + map: {} + } as any as Style; + + const layerSpec = { + id: 'mock-layer', + source: 'empty-source', + type: 'symbol', + layout: {}, + paint: { + 'text-opacity': 1 + } + } as SymbolLayerSpecification; + const layer = new SymbolStyleLayer(layerSpec); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + + const tileId = new OverscaledTileID(1, 0, 1, 0, 0); + tileId.posMatrix = mat4.create(); + const programMock = new Program(null, null, null, null, null, null); + (painterMock.useProgram as jest.Mock).mockReturnValue(programMock); + const bucketMock = new SymbolBucket(null); + bucketMock.icon = { + programConfigurations: { + get: () => { } + }, + segments: { + get: () => [1] + }, + hasVisibleVertices: false // nark this bucket as having no visible vertices + } as any; + bucketMock.iconSizeData = { + kind: 'constant', + layoutSize: 1 + }; + const tile = new Tile(tileId, 256); + tile.tileID = tileId; + tile.imageAtlasTexture = { + bind: () => { } + } as any; + (tile.getBucket as jest.Mock).mockReturnValue(bucketMock); + const sourceCacheMock = new SourceCache(null, null, null); + (sourceCacheMock.getTile as jest.Mock).mockReturnValue(tile); + sourceCacheMock.map = {showCollisionBoxes: false} as any as Map; + + drawSymbols(painterMock, sourceCacheMock, layer, [tileId], null); + + expect(programMock.draw).toHaveBeenCalledTimes(0); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/render/draw_symbol.ts b/web/libraries/maplibre-gl/src/render/draw_symbol.ts new file mode 100644 index 00000000..11a20034 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_symbol.ts @@ -0,0 +1,449 @@ +import Point from '@mapbox/point-geometry'; +import {drawCollisionDebug} from './draw_collision_debug'; + +import {SegmentVector} from '../data/segment'; +import {pixelsToTileUnits} from '../source/pixels_to_tile_units'; +import * as symbolProjection from '../symbol/projection'; +import {EvaluatedZoomSize, evaluateSizeForFeature, evaluateSizeForZoom} from '../symbol/symbol_size'; +import {mat4} from 'gl-matrix'; +import {StencilMode} from '../gl/stencil_mode'; +import {DepthMode} from '../gl/depth_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {addDynamicAttributes} from '../data/bucket/symbol_bucket'; + +import {getAnchorAlignment, WritingMode} from '../symbol/shaping'; +import ONE_EM from '../symbol/one_em'; + +import { + SymbolIconUniformsType, + symbolIconUniformValues, + symbolSDFUniformValues, + symbolTextAndIconUniformValues +} from './program/symbol_program'; + +import type {Painter} from './painter'; +import type {SourceCache} from '../source/source_cache'; +import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; + +import type {Texture} from '../render/texture'; +import type {OverscaledTileID} from '../source/tile_id'; +import type {UniformValues} from './uniform_binding'; +import type {SymbolSDFUniformsType} from '../render/program/symbol_program'; +import type {CrossTileID, VariableOffset} from '../symbol/placement'; +import type {SymbolBucket, SymbolBuffers} from '../data/bucket/symbol_bucket'; +import type {TerrainData} from '../render/terrain'; +import type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {Transform} from '../geo/transform'; +import type {ColorMode} from '../gl/color_mode'; +import type {Program} from './program'; +import type {TextAnchor} from '../style/style_layer/variable_text_anchor'; + +type SymbolTileRenderState = { + segments: SegmentVector; + sortKey: number; + terrainData: TerrainData; + state: { + program: Program; + buffers: SymbolBuffers; + uniformValues: UniformValues; + atlasTexture: Texture; + atlasTextureIcon: Texture | null; + atlasInterpolation: GLenum; + atlasInterpolationIcon: GLenum; + isSDF: boolean; + hasHalo: boolean; + }; +}; + +const identityMat4 = mat4.identity(new Float32Array(16)); + +export function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array, variableOffsets: { + [_ in CrossTileID]: VariableOffset; +}) { + if (painter.renderPass !== 'translucent') return; + + // Disable the stencil test so that labels aren't clipped to tile boundaries. + const stencilMode = StencilMode.disabled; + const colorMode = painter.colorModeForRenderPass(); + const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset'); + + //Compute variable-offsets before painting since icons and text data positioning + //depend on each other in this case. + if (hasVariablePlacement) { + updateVariableAnchors(coords, painter, layer, sourceCache, + layer.layout.get('text-rotation-alignment'), + layer.layout.get('text-pitch-alignment'), + variableOffsets + ); + } + + if (layer.paint.get('icon-opacity').constantOr(1) !== 0) { + drawLayerSymbols(painter, sourceCache, layer, coords, false, + layer.paint.get('icon-translate'), + layer.paint.get('icon-translate-anchor'), + layer.layout.get('icon-rotation-alignment'), + layer.layout.get('icon-pitch-alignment'), + layer.layout.get('icon-keep-upright'), + stencilMode, colorMode + ); + } + + if (layer.paint.get('text-opacity').constantOr(1) !== 0) { + drawLayerSymbols(painter, sourceCache, layer, coords, true, + layer.paint.get('text-translate'), + layer.paint.get('text-translate-anchor'), + layer.layout.get('text-rotation-alignment'), + layer.layout.get('text-pitch-alignment'), + layer.layout.get('text-keep-upright'), + stencilMode, colorMode + ); + } + + if (sourceCache.map.showCollisionBoxes) { + drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'), + layer.paint.get('text-translate-anchor'), true); + drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'), + layer.paint.get('icon-translate-anchor'), false); + } +} + +function calculateVariableRenderShift( + anchor: TextAnchor, + width: number, + height: number, + textOffset: [number, number], + textBoxScale: number, + renderTextSize: number): Point { + const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor); + const shiftX = -(horizontalAlign - 0.5) * width; + const shiftY = -(verticalAlign - 0.5) * height; + return new Point( + (shiftX / textBoxScale + textOffset[0]) * renderTextSize, + (shiftY / textBoxScale + textOffset[1]) * renderTextSize + ); +} + +function updateVariableAnchors(coords: Array, + painter: Painter, + layer:SymbolStyleLayer, sourceCache: SourceCache, + rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'], + pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'], + variableOffsets: {[_ in CrossTileID]: VariableOffset}) { + const tr = painter.transform; + const rotateWithMap = rotationAlignment === 'map'; + const pitchWithMap = pitchAlignment === 'map'; + + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer) as SymbolBucket; + if (!bucket || !bucket.text || !bucket.text.segments.get().length) continue; + + const sizeData = bucket.textSizeData; + const size = evaluateSizeForZoom(sizeData, tr.zoom); + + const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom); + const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale); + const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData(); + + if (size) { + const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ); + const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null; + updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, + tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon, getElevation); + } + } +} + +function updateVariableAnchorsForBucket( + bucket: SymbolBucket, + rotateWithMap: boolean, + pitchWithMap: boolean, + variableOffsets: {[_ in CrossTileID]: VariableOffset}, + transform: Transform, + labelPlaneMatrix: mat4, + posMatrix: mat4, + tileScale: number, + size: EvaluatedZoomSize, + updateTextFitIcon: boolean, + getElevation: (x: number, y: number) => number) { + const placedSymbols = bucket.text.placedSymbolArray; + const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray; + const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray; + const placedTextShifts = {}; + + dynamicTextLayoutVertexArray.clear(); + for (let s = 0; s < placedSymbols.length; s++) { + const symbol = placedSymbols.get(s); + const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation; + const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null; + + if (!variableOffset) { + // These symbols are from a justification that is not being used, or a label that wasn't placed + // so we don't need to do the extra math to figure out what incremental shift to apply. + symbolProjection.hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray); + } else { + const tileAnchor = new Point(symbol.anchorX, symbol.anchorY); + const projectedAnchor = symbolProjection.project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix, getElevation); + const perspectiveRatio = symbolProjection.getPerspectiveRatio(transform.cameraToCenterDistance, projectedAnchor.signedDistanceFromCamera); + let renderTextSize = evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / ONE_EM; + if (pitchWithMap) { + // Go from size in pixels to equivalent size in tile units + renderTextSize *= bucket.tilePixelRatio / tileScale; + } + + const {width, height, anchor, textOffset, textBoxScale} = variableOffset; + + const shift = calculateVariableRenderShift( + anchor, width, height, textOffset, textBoxScale, renderTextSize); + + // Usual case is that we take the projected anchor and add the pixel-based shift + // calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent + // tile-unit based shift to the anchor before projecting to the label plane. + const shiftedAnchor = pitchWithMap ? + symbolProjection.project(tileAnchor.add(shift), labelPlaneMatrix, getElevation).point : + projectedAnchor.point.add(rotateWithMap ? + shift.rotate(-transform.angle) : + shift); + + const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === WritingMode.vertical) ? Math.PI / 2 : 0; + for (let g = 0; g < symbol.numGlyphs; g++) { + addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle); + } + //Only offset horizontal text icons + if (updateTextFitIcon && symbol.associatedIconIndex >= 0) { + placedTextShifts[symbol.associatedIconIndex] = {shiftedAnchor, angle}; + } + } + } + + if (updateTextFitIcon) { + dynamicIconLayoutVertexArray.clear(); + const placedIcons = bucket.icon.placedSymbolArray; + for (let i = 0; i < placedIcons.length; i++) { + const placedIcon = placedIcons.get(i); + if (placedIcon.hidden) { + symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray); + } else { + const shift = placedTextShifts[i]; + if (!shift) { + symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray); + } else { + for (let g = 0; g < placedIcon.numGlyphs; g++) { + addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle); + } + } + } + } + bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray); + } + bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray); +} + +function getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) { + if (bucket.iconsInText && isText) { + return 'symbolTextAndIcon'; + } else if (isSDF) { + return 'symbolSDF'; + } else { + return 'symbolIcon'; + } +} + +function drawLayerSymbols( + painter: Painter, + sourceCache: SourceCache, + layer: SymbolStyleLayer, + coords: Array, + isText: boolean, + translate: [number, number], + translateAnchor: 'map' | 'viewport', + rotationAlignment: SymbolLayerSpecification['layout']['text-rotation-alignment'], + pitchAlignment: SymbolLayerSpecification['layout']['text-pitch-alignment'], + keepUpright: boolean, + stencilMode: StencilMode, + colorMode: Readonly) { + + const context = painter.context; + const gl = context.gl; + const tr = painter.transform; + + const rotateWithMap = rotationAlignment === 'map'; + const pitchWithMap = pitchAlignment === 'map'; + const alongLine = rotationAlignment !== 'viewport' && layer.layout.get('symbol-placement') !== 'point'; + // Line label rotation happens in `updateLineLabels` + // Pitched point labels are automatically rotated by the labelPlaneMatrix projection + // Unpitched point labels need to have their rotation applied after projection + const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine; + + const hasSortKey = !layer.layout.get('symbol-sort-key').isConstant(); + let sortFeaturesByKey = false; + + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + + const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset'); + + const tileRenderState: Array = []; + + for (const coord of coords) { + const tile = sourceCache.getTile(coord); + const bucket = tile.getBucket(layer) as SymbolBucket; + if (!bucket) continue; + const buffers = isText ? bucket.text : bucket.icon; + + if (!buffers || !buffers.segments.get().length || !buffers.hasVisibleVertices) continue; + const programConfiguration = buffers.programConfigurations.get(layer.id); + + const isSDF = isText || bucket.sdfIcons; + + const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData; + const transformed = pitchWithMap || tr.pitch !== 0; + + const program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration); + const size = evaluateSizeForZoom(sizeData, tr.zoom); + const terrainData = painter.style.map.terrain && painter.style.map.terrain.getTerrainData(coord); + + let texSize: [number, number]; + let texSizeIcon: [number, number] = [0, 0]; + let atlasTexture: Texture; + let atlasInterpolation: GLenum; + let atlasTextureIcon = null; + let atlasInterpolationIcon: GLenum; + if (isText) { + atlasTexture = tile.glyphAtlasTexture; + atlasInterpolation = gl.LINEAR; + texSize = tile.glyphAtlasTexture.size; + if (bucket.iconsInText) { + texSizeIcon = tile.imageAtlasTexture.size; + atlasTextureIcon = tile.imageAtlasTexture; + const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera'; + atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST; + } + } else { + const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear; + atlasTexture = tile.imageAtlasTexture; + atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ? + gl.LINEAR : + gl.NEAREST; + texSize = tile.imageAtlasTexture.size; + } + + const s = pixelsToTileUnits(tile, 1, painter.transform.zoom); + const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s); + const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s); + + const hasVariableAnchors = hasVariablePlacement && bucket.hasTextData(); + const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && + hasVariableAnchors && + bucket.hasIconData(); + + if (alongLine) { + const getElevation = painter.style.map.terrain ? (x: number, y: number) => painter.style.map.terrain.getElevation(coord, x, y) : null; + const rotateToLine = layer.layout.get('text-rotation-alignment') === 'map'; + symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright, rotateToLine, getElevation); + } + + const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor), + uLabelPlaneMatrix = (alongLine || (isText && hasVariablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix, + uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true); + + const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0; + + let uniformValues: UniformValues; + if (isSDF) { + if (!bucket.iconsInText) { + uniformValues = symbolSDFUniformValues(sizeData.kind, + size, rotateInShader, pitchWithMap, painter, matrix, + uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true); + } else { + uniformValues = symbolTextAndIconUniformValues(sizeData.kind, + size, rotateInShader, pitchWithMap, painter, matrix, + uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon); + } + } else { + uniformValues = symbolIconUniformValues(sizeData.kind, + size, rotateInShader, pitchWithMap, painter, matrix, + uLabelPlaneMatrix, uglCoordMatrix, isText, texSize); + } + + const state = { + program, + buffers, + uniformValues, + atlasTexture, + atlasTextureIcon, + atlasInterpolation, + atlasInterpolationIcon, + isSDF, + hasHalo + }; + + if (hasSortKey && bucket.canOverlap) { + sortFeaturesByKey = true; + const oldSegments = buffers.segments.get(); + for (const segment of oldSegments) { + tileRenderState.push({ + segments: new SegmentVector([segment]), + sortKey: segment.sortKey, + state, + terrainData + }); + } + } else { + tileRenderState.push({ + segments: buffers.segments, + sortKey: 0, + state, + terrainData + }); + } + } + + if (sortFeaturesByKey) { + tileRenderState.sort((a, b) => a.sortKey - b.sortKey); + } + + for (const segmentState of tileRenderState) { + const state = segmentState.state; + + context.activeTexture.set(gl.TEXTURE0); + // @ts-ignore + state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE); + if (state.atlasTextureIcon) { + context.activeTexture.set(gl.TEXTURE1); + if (state.atlasTextureIcon) { + // @ts-ignore + state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE); + } + } + + if (state.isSDF) { + const uniformValues = state.uniformValues; + if (state.hasHalo) { + uniformValues['u_is_halo'] = 1; + drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues, segmentState.terrainData); + } + uniformValues['u_is_halo'] = 0; + } + drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues, segmentState.terrainData); + } +} + +function drawSymbolElements( + buffers: SymbolBuffers, + segments: SegmentVector, + layer: SymbolStyleLayer, + painter: Painter, + program: Program, + depthMode: Readonly, + stencilMode: StencilMode, + colorMode: Readonly, + uniformValues: UniformValues, + terrainData: TerrainData) { + const context = painter.context; + const gl = context.gl; + program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled, + uniformValues, terrainData, layer.id, buffers.layoutVertexBuffer, + buffers.indexBuffer, segments, layer.paint, + painter.transform.zoom, buffers.programConfigurations.get(layer.id), + buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer); +} diff --git a/web/libraries/maplibre-gl/src/render/draw_terrain.ts b/web/libraries/maplibre-gl/src/render/draw_terrain.ts new file mode 100644 index 00000000..688c5781 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/draw_terrain.ts @@ -0,0 +1,97 @@ +import {StencilMode} from '../gl/stencil_mode'; +import {DepthMode} from '../gl/depth_mode'; +import {terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues} from './program/terrain_program'; +import type {Painter} from './painter'; +import type {Tile} from '../source/tile'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {ColorMode} from '../gl/color_mode'; +import {Terrain} from './terrain'; + +/** + * Redraw the Depth Framebuffer + * @param painter - the painter + * @param terrain - the terrain + */ +function drawDepth(painter: Painter, terrain: Terrain) { + const context = painter.context; + const gl = context.gl; + const colorMode = ColorMode.unblended; + const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]); + const mesh = terrain.getTerrainMesh(); + const tiles = terrain.sourceCache.getRenderableTiles(); + const program = painter.useProgram('terrainDepth'); + context.bindFramebuffer.set(terrain.getFramebuffer('depth').framebuffer); + context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]); + context.clear({color: Color.transparent, depth: 1}); + for (const tile of tiles) { + const terrainData = terrain.getTerrainData(tile.tileID); + const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const uniformValues = terrainDepthUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom)); + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments); + } + context.bindFramebuffer.set(null); + context.viewport.set([0, 0, painter.width, painter.height]); +} + +/** + * Redraw the Coords Framebuffers + * @param painter - the painter + * @param terrain - the terrain + */ +function drawCoords(painter: Painter, terrain: Terrain) { + const context = painter.context; + const gl = context.gl; + const colorMode = ColorMode.unblended; + const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, [0, 1]); + const mesh = terrain.getTerrainMesh(); + const coords = terrain.getCoordsTexture(); + const tiles = terrain.sourceCache.getRenderableTiles(); + + // draw tile-coords into framebuffer + const program = painter.useProgram('terrainCoords'); + context.bindFramebuffer.set(terrain.getFramebuffer('coords').framebuffer); + context.viewport.set([0, 0, painter.width / devicePixelRatio, painter.height / devicePixelRatio]); + context.clear({color: Color.transparent, depth: 1}); + terrain.coordsIndex = []; + for (const tile of tiles) { + const terrainData = terrain.getTerrainData(tile.tileID); + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, coords.texture); + const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const uniformValues = terrainCoordsUniformValues(posMatrix, 255 - terrain.coordsIndex.length, terrain.getMeshFrameDelta(painter.transform.zoom)); + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments); + terrain.coordsIndex.push(tile.tileID.key); + } + context.bindFramebuffer.set(null); + context.viewport.set([0, 0, painter.width, painter.height]); +} + +function drawTerrain(painter: Painter, terrain: Terrain, tiles: Array) { + const context = painter.context; + const gl = context.gl; + const colorMode = painter.colorModeForRenderPass(); + const depthMode = new DepthMode(gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D); + const program = painter.useProgram('terrain'); + const mesh = terrain.getTerrainMesh(); + + context.bindFramebuffer.set(null); + context.viewport.set([0, 0, painter.width, painter.height]); + + for (const tile of tiles) { + const texture = painter.renderToTexture.getTexture(tile); + const terrainData = terrain.getTerrainData(tile.tileID); + context.activeTexture.set(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture.texture); + const posMatrix = painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + const uniformValues = terrainUniformValues(posMatrix, terrain.getMeshFrameDelta(painter.transform.zoom)); + program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, 'terrain', mesh.vertexBuffer, mesh.indexBuffer, mesh.segments); + } + +} + +export { + drawTerrain, + drawDepth, + drawCoords +}; diff --git a/web/libraries/maplibre-gl/src/render/glyph_atlas.ts b/web/libraries/maplibre-gl/src/render/glyph_atlas.ts new file mode 100644 index 00000000..0f80b336 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/glyph_atlas.ts @@ -0,0 +1,86 @@ +import {AlphaImage} from '../util/image'; +import {register} from '../util/web_worker_transfer'; +import potpack from 'potpack'; + +import type {GlyphMetrics, StyleGlyph} from '../style/style_glyph'; + +const padding = 1; + +/** + * A rectangle type with postion, width and height. + */ +export type Rect = { + x: number; + y: number; + w: number; + h: number; +}; + +/** + * The glyph's position + */ +export type GlyphPosition = { + rect: Rect; + metrics: GlyphMetrics; +}; + +/** + * The glyphs' positions + */ +export type GlyphPositions = { + [_: string]: { + [_: number]: GlyphPosition; + }; +}; + +export class GlyphAtlas { + image: AlphaImage; + positions: GlyphPositions; + + constructor(stacks: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }) { + const positions = {}; + const bins = []; + + for (const stack in stacks) { + const glyphs = stacks[stack]; + const stackPositions = positions[stack] = {}; + + for (const id in glyphs) { + const src = glyphs[+id]; + if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue; + + const bin = { + x: 0, + y: 0, + w: src.bitmap.width + 2 * padding, + h: src.bitmap.height + 2 * padding + }; + bins.push(bin); + stackPositions[id] = {rect: bin, metrics: src.metrics}; + } + } + + const {w, h} = potpack(bins); + const image = new AlphaImage({width: w || 1, height: h || 1}); + + for (const stack in stacks) { + const glyphs = stacks[stack]; + + for (const id in glyphs) { + const src = glyphs[+id]; + if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue; + const bin = positions[stack][id].rect; + AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap); + } + } + + this.image = image; + this.positions = positions; + } +} + +register('GlyphAtlas', GlyphAtlas); diff --git a/web/libraries/maplibre-gl/src/render/glyph_manager.test.ts b/web/libraries/maplibre-gl/src/render/glyph_manager.test.ts new file mode 100644 index 00000000..65c0ff72 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/glyph_manager.test.ts @@ -0,0 +1,160 @@ +import {parseGlyphPbf} from '../style/parse_glyph_pbf'; +import {GlyphManager} from './glyph_manager'; +import fs from 'fs'; +import {RequestManager} from '../util/request_manager'; + +const glyphs = {}; +for (const glyph of parseGlyphPbf(fs.readFileSync('./test/unit/assets/0-255.pbf'))) { + glyphs[glyph.id] = glyph; +} + +const identityTransform = ((url) => ({url})) as any as RequestManager; + +const createLoadGlyphRangeStub = () => { + return jest.spyOn(GlyphManager, 'loadGlyphRange').mockImplementation((stack, range, urlTemplate, transform, callback) => { + expect(stack).toBe('Arial Unicode MS'); + expect(range).toBe(0); + expect(urlTemplate).toBe('https://localhost/fonts/v1/{fontstack}/{range}.pbf'); + expect(transform).toBe(identityTransform); + setTimeout(() => callback(null, glyphs), 0); + }); +}; + +const createGlyphManager = (font?) => { + const manager = new GlyphManager(identityTransform, font); + manager.setURL('https://localhost/fonts/v1/{fontstack}/{range}.pbf'); + return manager; +}; + +afterEach(() => { + jest.clearAllMocks(); +}); + +describe('GlyphManager', () => { + + test('GlyphManager requests 0-255 PBF', done => { + createLoadGlyphRangeStub(); + const manager = createGlyphManager(); + + manager.getGlyphs({'Arial Unicode MS': [55]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS']['55'].metrics.advance).toBe(12); + done(); + }); + }); + + test('GlyphManager doesn\'t request twice 0-255 PBF if a glyph is missing', done => { + const stub = createLoadGlyphRangeStub(); + const manager = createGlyphManager(); + + manager.getGlyphs({'Arial Unicode MS': [0.5]}, (err) => { + expect(err).toBeFalsy(); + expect(manager.entries['Arial Unicode MS'].ranges[0]).toBe(true); + expect(stub).toHaveBeenCalledTimes(1); + + // We remove all requests as in getGlyphs code. + delete manager.entries['Arial Unicode MS'].requests[0]; + + manager.getGlyphs({'Arial Unicode MS': [0.5]}, (err) => { + expect(err).toBeFalsy(); + expect(manager.entries['Arial Unicode MS'].ranges[0]).toBe(true); + expect(stub).toHaveBeenCalledTimes(1); + done(); + }); + }); + }); + + test('GlyphManager requests remote CJK PBF', done => { + jest.spyOn(GlyphManager, 'loadGlyphRange').mockImplementation((stack, range, urlTemplate, transform, callback) => { + setTimeout(() => callback(null, glyphs), 0); + }); + + const manager = createGlyphManager(); + + manager.getGlyphs({'Arial Unicode MS': [0x5e73]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS'][0x5e73]).toBeNull(); // The fixture returns a PBF without the glyph we requested + done(); + }); + }); + + test('GlyphManager does not cache CJK chars that should be rendered locally', done => { + jest.spyOn(GlyphManager, 'loadGlyphRange').mockImplementation((stack, range, urlTemplate, transform, callback) => { + const overlappingGlyphs = {}; + const start = range * 256; + const end = start + 256; + for (let i = start, j = 0; i < end; i++, j++) { + overlappingGlyphs[i] = glyphs[j]; + } + setTimeout(() => callback(null, overlappingGlyphs), 0); + }); + + const manager = createGlyphManager('sans-serif'); + + //Request char that overlaps Katakana range + manager.getGlyphs({'Arial Unicode MS': [0x3005]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS'][0x3005]).not.toBeNull(); + //Request char from Katakana range (te テ) + manager.getGlyphs({'Arial Unicode MS': [0x30C6]}, (err, glyphs) => { + expect(err).toBeFalsy(); + const glyph = glyphs['Arial Unicode MS'][0x30c6]; + //Ensure that te is locally generated. + expect(glyph.bitmap.height).toBe(12); + expect(glyph.bitmap.width).toBe(12); + done(); + }); + }); + }); + + test('GlyphManager generates CJK PBF locally', done => { + const manager = createGlyphManager('sans-serif'); + + // character 平 + manager.getGlyphs({'Arial Unicode MS': [0x5e73]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS'][0x5e73].metrics.advance).toBe(0.5); + done(); + }); + }); + + test('GlyphManager generates Katakana PBF locally', done => { + const manager = createGlyphManager('sans-serif'); + + // Katakana letter te テ + manager.getGlyphs({'Arial Unicode MS': [0x30c6]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS'][0x30c6].metrics.advance).toBe(0.5); + done(); + }); + }); + + test('GlyphManager generates Hiragana PBF locally', done => { + const manager = createGlyphManager('sans-serif'); + + //Hiragana letter te て + manager.getGlyphs({'Arial Unicode MS': [0x3066]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS'][0x3066].metrics.advance).toBe(0.5); + done(); + }); + }); + + test('GlyphManager caches locally generated glyphs', done => { + + const manager = createGlyphManager('sans-serif'); + const drawSpy = GlyphManager.TinySDF.prototype.draw = jest.fn().mockImplementation(() => { + return {data: new Uint8ClampedArray(60 * 60)} as any; + }); + + // Katakana letter te + manager.getGlyphs({'Arial Unicode MS': [0x30c6]}, (err, glyphs) => { + expect(err).toBeFalsy(); + expect(glyphs['Arial Unicode MS'][0x30c6].metrics.advance).toBe(24); + manager.getGlyphs({'Arial Unicode MS': [0x30c6]}, () => { + expect(drawSpy).toHaveBeenCalledTimes(1); + done(); + }); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/render/glyph_manager.ts b/web/libraries/maplibre-gl/src/render/glyph_manager.ts new file mode 100644 index 00000000..acffee4d --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/glyph_manager.ts @@ -0,0 +1,239 @@ +import {loadGlyphRange} from '../style/load_glyph_range'; + +import TinySDF from '@mapbox/tiny-sdf'; +import {unicodeBlockLookup} from '../util/is_char_in_unicode_block'; +import {asyncAll} from '../util/util'; +import {AlphaImage} from '../util/image'; + +import type {StyleGlyph} from '../style/style_glyph'; +import type {RequestManager} from '../util/request_manager'; +import type {Callback} from '../types/callback'; + +type Entry = { + // null means we've requested the range, but the glyph wasn't included in the result. + glyphs: { + [id: number]: StyleGlyph | null; + }; + requests: { + [range: number]: Array>; + }; + ranges: { + [range: number]: boolean | null; + }; + tinySDF?: TinySDF; +}; + +export class GlyphManager { + requestManager: RequestManager; + localIdeographFontFamily: string; + entries: { + [_: string]: Entry; + }; + url: string; + + // exposed as statics to enable stubbing in unit tests + static loadGlyphRange = loadGlyphRange; + static TinySDF = TinySDF; + + constructor(requestManager: RequestManager, localIdeographFontFamily?: string | null) { + this.requestManager = requestManager; + this.localIdeographFontFamily = localIdeographFontFamily; + this.entries = {}; + } + + setURL(url?: string | null) { + this.url = url; + } + + getGlyphs(glyphs: { + [stack: string]: Array; + }, callback: Callback<{ + [stack: string]: { + [id: number]: StyleGlyph; + }; + }>) { + const all = []; + + for (const stack in glyphs) { + for (const id of glyphs[stack]) { + all.push({stack, id}); + } + } + + asyncAll(all, ({stack, id}, callback: Callback<{ + stack: string; + id: number; + glyph: StyleGlyph; + }>) => { + let entry = this.entries[stack]; + if (!entry) { + entry = this.entries[stack] = { + glyphs: {}, + requests: {}, + ranges: {} + }; + } + + let glyph = entry.glyphs[id]; + if (glyph !== undefined) { + callback(null, {stack, id, glyph}); + return; + } + + glyph = this._tinySDF(entry, stack, id); + if (glyph) { + entry.glyphs[id] = glyph; + callback(null, {stack, id, glyph}); + return; + } + + const range = Math.floor(id / 256); + if (range * 256 > 65535) { + callback(new Error('glyphs > 65535 not supported')); + return; + } + + if (entry.ranges[range]) { + callback(null, {stack, id, glyph}); + return; + } + + if (!this.url) { + callback(new Error('glyphsUrl is not set')); + return; + } + + let requests = entry.requests[range]; + if (!requests) { + requests = entry.requests[range] = []; + GlyphManager.loadGlyphRange(stack, range, this.url, this.requestManager, + (err, response?: { + [_: number]: StyleGlyph | null; + } | null) => { + if (response) { + for (const id in response) { + if (!this._doesCharSupportLocalGlyph(+id)) { + entry.glyphs[+id] = response[+id]; + } + } + entry.ranges[range] = true; + } + for (const cb of requests) { + cb(err, response); + } + delete entry.requests[range]; + }); + } + + requests.push((err, result?: { + [_: number]: StyleGlyph | null; + } | null) => { + if (err) { + callback(err); + } else if (result) { + callback(null, {stack, id, glyph: result[id] || null}); + } + }); + }, (err, glyphs?: Array<{ + stack: string; + id: number; + glyph: StyleGlyph; + }> | null) => { + if (err) { + callback(err); + } else if (glyphs) { + const result = {}; + + for (const {stack, id, glyph} of glyphs) { + // Clone the glyph so that our own copy of its ArrayBuffer doesn't get transferred. + (result[stack] || (result[stack] = {}))[id] = glyph && { + id: glyph.id, + bitmap: glyph.bitmap.clone(), + metrics: glyph.metrics + }; + } + + callback(null, result); + } + }); + } + + _doesCharSupportLocalGlyph(id: number): boolean { + /* eslint-disable new-cap */ + return !!this.localIdeographFontFamily && + (unicodeBlockLookup['CJK Unified Ideographs'](id) || + unicodeBlockLookup['Hangul Syllables'](id) || + unicodeBlockLookup['Hiragana'](id) || + unicodeBlockLookup['Katakana'](id)); + /* eslint-enable new-cap */ + } + + _tinySDF(entry: Entry, stack: string, id: number): StyleGlyph { + const fontFamily = this.localIdeographFontFamily; + if (!fontFamily) { + return; + } + + if (!this._doesCharSupportLocalGlyph(id)) { + return; + } + + // Client-generated glyphs are rendered at 2x texture scale, + // because CJK glyphs are more detailed than others. + const textureScale = 2; + + let tinySDF = entry.tinySDF; + if (!tinySDF) { + let fontWeight = '400'; + if (/bold/i.test(stack)) { + fontWeight = '900'; + } else if (/medium/i.test(stack)) { + fontWeight = '500'; + } else if (/light/i.test(stack)) { + fontWeight = '200'; + } + tinySDF = entry.tinySDF = new GlyphManager.TinySDF({ + fontSize: 24 * textureScale, + buffer: 3 * textureScale, + radius: 8 * textureScale, + cutoff: 0.25, + fontFamily, + fontWeight + }); + } + + const char = tinySDF.draw(String.fromCharCode(id)); + + /** + * TinySDF's "top" is the distance from the alphabetic baseline to the top of the glyph. + * Server-generated fonts specify "top" relative to an origin above the em box (the origin + * comes from FreeType, but I'm unclear on exactly how it's derived) + * ref: https://github.com/mapbox/sdf-glyph-foundry + * + * Server fonts don't yet include baseline information, so we can't line up exactly with them + * (and they don't line up with each other) + * ref: https://github.com/mapbox/node-fontnik/pull/160 + * + * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment + * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode) + */ + const topAdjustment = 27.5; + + const leftAdjustment = 0.5; + + return { + id, + bitmap: new AlphaImage({width: char.width || 30 * textureScale, height: char.height || 30 * textureScale}, char.data), + metrics: { + width: char.glyphWidth / textureScale || 24, + height: char.glyphHeight / textureScale || 24, + left: (char.glyphLeft / textureScale + leftAdjustment) || 0, + top: char.glyphTop / textureScale - topAdjustment || -8, + advance: char.glyphAdvance / textureScale || 24, + isDoubleResolution: true + } + }; + } +} diff --git a/web/libraries/maplibre-gl/src/render/image_atlas.ts b/web/libraries/maplibre-gl/src/render/image_atlas.ts new file mode 100644 index 00000000..a86d2e69 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/image_atlas.ts @@ -0,0 +1,152 @@ +/* eslint-disable key-spacing */ +import {RGBAImage} from '../util/image'; +import {register} from '../util/web_worker_transfer'; +import potpack from 'potpack'; + +import type {StyleImage} from '../style/style_image'; +import type {ImageManager} from './image_manager'; +import type {Texture} from './texture'; +import type {Rect} from './glyph_atlas'; + +const IMAGE_PADDING: number = 1; +export {IMAGE_PADDING}; + +export class ImagePosition { + paddedRect: Rect; + pixelRatio: number; + version: number; + stretchY: Array<[number, number]>; + stretchX: Array<[number, number]>; + content: [number, number, number, number]; + + constructor(paddedRect: Rect, { + pixelRatio, + version, + stretchX, + stretchY, + content + }: StyleImage) { + this.paddedRect = paddedRect; + this.pixelRatio = pixelRatio; + this.stretchX = stretchX; + this.stretchY = stretchY; + this.content = content; + this.version = version; + } + + get tl(): [number, number] { + return [ + this.paddedRect.x + IMAGE_PADDING, + this.paddedRect.y + IMAGE_PADDING + ]; + } + + get br(): [number, number] { + return [ + this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING, + this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING + ]; + } + + get tlbr(): Array { + return this.tl.concat(this.br); + } + + get displaySize(): [number, number] { + return [ + (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio, + (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio + ]; + } +} + +/** + * @internal + * A class holding all the images + */ +export class ImageAtlas { + image: RGBAImage; + iconPositions: {[_: string]: ImagePosition}; + patternPositions: {[_: string]: ImagePosition}; + haveRenderCallbacks: Array; + uploaded: boolean; + + constructor(icons: {[_: string]: StyleImage}, patterns: {[_: string]: StyleImage}) { + const iconPositions = {}, patternPositions = {}; + this.haveRenderCallbacks = []; + + const bins = []; + + this.addImages(icons, iconPositions, bins); + this.addImages(patterns, patternPositions, bins); + + const {w, h} = potpack(bins); + const image = new RGBAImage({width: w || 1, height: h || 1}); + + for (const id in icons) { + const src = icons[id]; + const bin = iconPositions[id].paddedRect; + RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: bin.x + IMAGE_PADDING, y: bin.y + IMAGE_PADDING}, src.data); + } + + for (const id in patterns) { + const src = patterns[id]; + const bin = patternPositions[id].paddedRect; + const x = bin.x + IMAGE_PADDING, + y = bin.y + IMAGE_PADDING, + w = src.data.width, + h = src.data.height; + + RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y}, src.data); + // Add 1 pixel wrapped padding on each side of the image. + RGBAImage.copy(src.data, image, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T + RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B + RGBAImage.copy(src.data, image, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L + RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R + } + + this.image = image; + this.iconPositions = iconPositions; + this.patternPositions = patternPositions; + } + + addImages(images: {[_: string]: StyleImage}, positions: {[_: string]: ImagePosition}, bins: Array) { + for (const id in images) { + const src = images[id]; + const bin = { + x: 0, + y: 0, + w: src.data.width + 2 * IMAGE_PADDING, + h: src.data.height + 2 * IMAGE_PADDING, + }; + bins.push(bin); + positions[id] = new ImagePosition(bin, src); + + if (src.hasRenderCallback) { + this.haveRenderCallbacks.push(id); + } + } + } + + patchUpdatedImages(imageManager: ImageManager, texture: Texture) { + imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks); + for (const name in imageManager.updatedImages) { + this.patchUpdatedImage(this.iconPositions[name], imageManager.getImage(name), texture); + this.patchUpdatedImage(this.patternPositions[name], imageManager.getImage(name), texture); + } + } + + patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture) { + if (!position || !image) return; + + if (position.version === image.version) return; + + position.version = image.version; + const [x, y] = position.tl; + texture.update(image.data, undefined, {x, y}); + } + +} + +register('ImagePosition', ImagePosition); +register('ImageAtlas', ImageAtlas); diff --git a/web/libraries/maplibre-gl/src/render/image_manager.ts b/web/libraries/maplibre-gl/src/render/image_manager.ts new file mode 100644 index 00000000..33a0d1aa --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/image_manager.ts @@ -0,0 +1,328 @@ +/* eslint-disable key-spacing */ +import potpack from 'potpack'; + +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {RGBAImage} from '../util/image'; +import {ImagePosition} from './image_atlas'; +import {Texture} from './texture'; +import {renderStyleImage} from '../style/style_image'; +import {warnOnce} from '../util/util'; + +import type {StyleImage} from '../style/style_image'; +import type {Context} from '../gl/context'; +import type {PotpackBox} from 'potpack'; +import type {Callback} from '../types/callback'; + +type Pattern = { + bin: PotpackBox; + position: ImagePosition; +}; + +// When copied into the atlas texture, image data is padded by one pixel on each side. Icon +// images are padded with fully transparent pixels, while pattern images are padded with a +// copy of the image data wrapped from the opposite side. In both cases, this ensures the +// correct behavior of GL_LINEAR texture sampling mode. +const padding = 1; + +/* + ImageManager does three things: + + 1. Tracks requests for icon images from tile workers and sends responses when the requests are fulfilled. + 2. Builds a texture atlas for pattern images. + 3. Rerenders renderable images once per frame + + These are disparate responsibilities and should eventually be handled by different classes. When we implement + data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time + to refactor this. +*/ +export class ImageManager extends Evented { + images: {[_: string]: StyleImage}; + updatedImages: {[_: string]: boolean}; + callbackDispatchedThisFrame: {[_: string]: boolean}; + loaded: boolean; + requestors: Array<{ + ids: Array; + callback: Callback<{[_: string]: StyleImage}>; + }>; + + patterns: {[_: string]: Pattern}; + atlasImage: RGBAImage; + atlasTexture: Texture; + dirty: boolean; + + constructor() { + super(); + this.images = {}; + this.updatedImages = {}; + this.callbackDispatchedThisFrame = {}; + this.loaded = false; + this.requestors = []; + + this.patterns = {}; + this.atlasImage = new RGBAImage({width: 1, height: 1}); + this.dirty = true; + } + + isLoaded() { + return this.loaded; + } + + setLoaded(loaded: boolean) { + if (this.loaded === loaded) { + return; + } + + this.loaded = loaded; + + if (loaded) { + for (const {ids, callback} of this.requestors) { + this._notify(ids, callback); + } + this.requestors = []; + } + } + + getImage(id: string): StyleImage { + const image = this.images[id]; + + // Extract sprite image data on demand + if (image && !image.data && image.spriteData) { + const spriteData = image.spriteData; + image.data = new RGBAImage({ + width: spriteData.width, + height: spriteData.height + }, spriteData.context.getImageData( + spriteData.x, + spriteData.y, + spriteData.width, + spriteData.height).data); + image.spriteData = null; + } + + return image; + } + + addImage(id: string, image: StyleImage) { + if (this.images[id]) throw new Error(`Image id ${id} already exist, use updateImage instead`); + if (this._validate(id, image)) { + this.images[id] = image; + } + } + + _validate(id: string, image: StyleImage) { + let valid = true; + const data = image.data || image.spriteData; + if (!this._validateStretch(image.stretchX, data && data.width)) { + this.fire(new ErrorEvent(new Error(`Image "${id}" has invalid "stretchX" value`))); + valid = false; + } + if (!this._validateStretch(image.stretchY, data && data.height)) { + this.fire(new ErrorEvent(new Error(`Image "${id}" has invalid "stretchY" value`))); + valid = false; + } + if (!this._validateContent(image.content, image)) { + this.fire(new ErrorEvent(new Error(`Image "${id}" has invalid "content" value`))); + valid = false; + } + return valid; + } + + _validateStretch(stretch: Array<[number, number]>, size: number) { + if (!stretch) return true; + let last = 0; + for (const part of stretch) { + if (part[0] < last || part[1] < part[0] || size < part[1]) return false; + last = part[1]; + } + return true; + } + + _validateContent(content: [number, number, number, number], image: StyleImage) { + if (!content) return true; + if (content.length !== 4) return false; + const spriteData = image.spriteData; + const width = (spriteData && spriteData.width) || image.data.width; + const height = (spriteData && spriteData.height) || image.data.height; + if (content[0] < 0 || width < content[0]) return false; + if (content[1] < 0 || height < content[1]) return false; + if (content[2] < 0 || width < content[2]) return false; + if (content[3] < 0 || height < content[3]) return false; + if (content[2] < content[0]) return false; + if (content[3] < content[1]) return false; + return true; + } + + updateImage(id: string, image: StyleImage, validate = true) { + const oldImage = this.getImage(id); + if (validate && (oldImage.data.width !== image.data.width || oldImage.data.height !== image.data.height)) { + throw new Error(`size mismatch between old image (${oldImage.data.width}x${oldImage.data.height}) and new image (${image.data.width}x${image.data.height}).`); + } + image.version = oldImage.version + 1; + this.images[id] = image; + this.updatedImages[id] = true; + } + + removeImage(id: string) { + const image = this.images[id]; + delete this.images[id]; + delete this.patterns[id]; + + if (image.userImage && image.userImage.onRemove) { + image.userImage.onRemove(); + } + } + + listImages(): Array { + return Object.keys(this.images); + } + + getImages(ids: Array, callback: Callback<{[_: string]: StyleImage}>) { + // If the sprite has been loaded, or if all the icon dependencies are already present + // (i.e. if they've been added via runtime styling), then notify the requestor immediately. + // Otherwise, delay notification until the sprite is loaded. At that point, if any of the + // dependencies are still unavailable, we'll just assume they are permanently missing. + let hasAllDependencies = true; + if (!this.isLoaded()) { + for (const id of ids) { + if (!this.images[id]) { + hasAllDependencies = false; + } + } + } + if (this.isLoaded() || hasAllDependencies) { + this._notify(ids, callback); + } else { + this.requestors.push({ids, callback}); + } + } + + _notify(ids: Array, callback: Callback<{[_: string]: StyleImage}>) { + const response = {}; + + for (const id of ids) { + let image = this.getImage(id); + + if (!image) { + this.fire(new Event('styleimagemissing', {id})); + //Try to acquire image again in case styleimagemissing has populated it + image = this.getImage(id); + } + + if (image) { + // Clone the image so that our own copy of its ArrayBuffer doesn't get transferred. + response[id] = { + data: image.data.clone(), + pixelRatio: image.pixelRatio, + sdf: image.sdf, + version: image.version, + stretchX: image.stretchX, + stretchY: image.stretchY, + content: image.content, + hasRenderCallback: Boolean(image.userImage && image.userImage.render) + }; + } else { + warnOnce(`Image "${id}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`); + } + } + + callback(null, response); + } + + // Pattern stuff + + getPixelSize() { + const {width, height} = this.atlasImage; + return {width, height}; + } + + getPattern(id: string): ImagePosition { + const pattern = this.patterns[id]; + + const image = this.getImage(id); + if (!image) { + return null; + } + + if (pattern && pattern.position.version === image.version) { + return pattern.position; + } + + if (!pattern) { + const w = image.data.width + padding * 2; + const h = image.data.height + padding * 2; + const bin = {w, h, x: 0, y: 0}; + const position = new ImagePosition(bin, image); + this.patterns[id] = {bin, position}; + } else { + pattern.position.version = image.version; + } + + this._updatePatternAtlas(); + + return this.patterns[id].position; + } + + bind(context: Context) { + const gl = context.gl; + if (!this.atlasTexture) { + this.atlasTexture = new Texture(context, this.atlasImage, gl.RGBA); + } else if (this.dirty) { + this.atlasTexture.update(this.atlasImage); + this.dirty = false; + } + + this.atlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + } + + _updatePatternAtlas() { + const bins = []; + for (const id in this.patterns) { + bins.push(this.patterns[id].bin); + } + + const {w, h} = potpack(bins); + + const dst = this.atlasImage; + dst.resize({width: w || 1, height: h || 1}); + + for (const id in this.patterns) { + const {bin} = this.patterns[id]; + const x = bin.x + padding; + const y = bin.y + padding; + const src = this.getImage(id).data; + const w = src.width; + const h = src.height; + + RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y}, {width: w, height: h}); + + // Add 1 pixel wrapped padding on each side of the image. + RGBAImage.copy(src, dst, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T + RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B + RGBAImage.copy(src, dst, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L + RGBAImage.copy(src, dst, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R + } + + this.dirty = true; + } + + beginFrame() { + this.callbackDispatchedThisFrame = {}; + } + + dispatchRenderCallbacks(ids: Array) { + for (const id of ids) { + + // the callback for the image was already dispatched for a different frame + if (this.callbackDispatchedThisFrame[id]) continue; + this.callbackDispatchedThisFrame[id] = true; + + const image = this.getImage(id); + if (!image) warnOnce(`Image with ID: "${id}" was not found`); + + const updated = renderStyleImage(image); + if (updated) { + this.updateImage(id, image); + } + } + } +} diff --git a/web/libraries/maplibre-gl/src/render/line_atlas.test.ts b/web/libraries/maplibre-gl/src/render/line_atlas.test.ts new file mode 100644 index 00000000..a672500c --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/line_atlas.test.ts @@ -0,0 +1,38 @@ +import {LineAtlas} from './line_atlas'; + +describe('LineAtlas', () => { + const lineAtlas = new LineAtlas(64, 64); + test('round [0, 0]', () => { + const entry = lineAtlas.addDash([0, 0], true); + expect(entry.width).toBe(0); + }); + test('round [1, 0]', () => { + const entry = lineAtlas.addDash([1, 0], true); + expect(entry.width).toBe(1); + }); + test('round [0, 1]', () => { + const entry = lineAtlas.addDash([0, 1], true); + expect(entry.width).toBe(1); + }); + test('odd round [1, 2, 1]', () => { + const entry = lineAtlas.addDash([1, 2, 1], true); + expect(entry.width).toBe(4); + }); + + test('regular [0, 0]', () => { + const entry = lineAtlas.addDash([0, 0], false); + expect(entry.width).toBe(0); + }); + test('regular [1, 0]', () => { + const entry = lineAtlas.addDash([1, 0], false); + expect(entry.width).toBe(1); + }); + test('regular [0, 1]', () => { + const entry = lineAtlas.addDash([0, 1], false); + expect(entry.width).toBe(1); + }); + test('odd regular [1, 2, 1]', () => { + const entry = lineAtlas.addDash([1, 2, 1], false); + expect(entry.width).toBe(4); + }); +}); diff --git a/web/libraries/maplibre-gl/src/render/line_atlas.ts b/web/libraries/maplibre-gl/src/render/line_atlas.ts new file mode 100644 index 00000000..56cead59 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/line_atlas.ts @@ -0,0 +1,214 @@ +import {warnOnce} from '../util/util'; + +import type {Context} from '../gl/context'; + +/** + * A dash entry + */ +type DashEntry = { + y: number; + height: number; + width: number; +} + +/** + * @internal + * A LineAtlas lets us reuse rendered dashed lines + * by writing many of them to a texture and then fetching their positions + * using {@link LineAtlas#getDash}. + * + * @param width - the width + * @param height - the height + */ +export class LineAtlas { + width: number; + height: number; + nextRow: number; + bytes: number; + data: Uint8Array; + dashEntry: {[_: string]: DashEntry}; + dirty: boolean; + texture: WebGLTexture; + + constructor(width: number, height: number) { + this.width = width; + this.height = height; + this.nextRow = 0; + + this.data = new Uint8Array(this.width * this.height); + + this.dashEntry = {}; + } + + /** + * Get or create a dash line pattern. + * + * @param dasharray - the key (represented by numbers) to get the dash texture + * @param round - whether to add circle caps in between dash segments + * @returns position of dash texture in {@link DashEntry} + */ + getDash(dasharray: Array, round: boolean) { + const key = dasharray.join(',') + String(round); + + if (!this.dashEntry[key]) { + this.dashEntry[key] = this.addDash(dasharray, round); + } + return this.dashEntry[key]; + } + + getDashRanges(dasharray: Array, lineAtlasWidth: number, stretch: number) { + // If dasharray has an odd length, both the first and last parts + // are dashes and should be joined seamlessly. + const oddDashArray = dasharray.length % 2 === 1; + + const ranges = []; + + let left = oddDashArray ? -dasharray[dasharray.length - 1] * stretch : 0; + let right = dasharray[0] * stretch; + let isDash = true; + + ranges.push({left, right, isDash, zeroLength: dasharray[0] === 0}); + + let currentDashLength = dasharray[0]; + for (let i = 1; i < dasharray.length; i++) { + isDash = !isDash; + + const dashLength = dasharray[i]; + left = currentDashLength * stretch; + currentDashLength += dashLength; + right = currentDashLength * stretch; + + ranges.push({left, right, isDash, zeroLength: dashLength === 0}); + } + + return ranges; + } + + addRoundDash(ranges: any, stretch: number, n: number) { + const halfStretch = stretch / 2; + + for (let y = -n; y <= n; y++) { + const row = this.nextRow + n + y; + const index = this.width * row; + let currIndex = 0; + let range = ranges[currIndex]; + + for (let x = 0; x < this.width; x++) { + if (x / range.right > 1) { range = ranges[++currIndex]; } + + const distLeft = Math.abs(x - range.left); + const distRight = Math.abs(x - range.right); + const minDist = Math.min(distLeft, distRight); + let signedDistance; + + const distMiddle = y / n * (halfStretch + 1); + if (range.isDash) { + const distEdge = halfStretch - Math.abs(distMiddle); + signedDistance = Math.sqrt(minDist * minDist + distEdge * distEdge); + } else { + signedDistance = halfStretch - Math.sqrt(minDist * minDist + distMiddle * distMiddle); + } + + this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128)); + } + } + } + + addRegularDash(ranges: any) { + + // Collapse any zero-length range + // Collapse neighbouring same-type parts into a single part + for (let i = ranges.length - 1; i >= 0; --i) { + const part = ranges[i]; + const next = ranges[i + 1]; + if (part.zeroLength) { + ranges.splice(i, 1); + } else if (next && next.isDash === part.isDash) { + next.left = part.left; + ranges.splice(i, 1); + } + } + + // Combine the first and last parts if possible + const first = ranges[0]; + const last = ranges[ranges.length - 1]; + if (first.isDash === last.isDash) { + first.left = last.left - this.width; + last.right = first.right + this.width; + } + + const index = this.width * this.nextRow; + let currIndex = 0; + let range = ranges[currIndex]; + + for (let x = 0; x < this.width; x++) { + if (x / range.right > 1) { + range = ranges[++currIndex]; + } + + const distLeft = Math.abs(x - range.left); + const distRight = Math.abs(x - range.right); + + const minDist = Math.min(distLeft, distRight); + const signedDistance = range.isDash ? minDist : -minDist; + + this.data[index + x] = Math.max(0, Math.min(255, signedDistance + 128)); + } + } + + addDash(dasharray: Array, round: boolean): DashEntry { + const n = round ? 7 : 0; + const height = 2 * n + 1; + + if (this.nextRow + height > this.height) { + warnOnce('LineAtlas out of space'); + return null; + } + + let length = 0; + for (let i = 0; i < dasharray.length; i++) { length += dasharray[i]; } + + if (length !== 0) { + const stretch = this.width / length; + const ranges = this.getDashRanges(dasharray, this.width, stretch); + + if (round) { + this.addRoundDash(ranges, stretch, n); + } else { + this.addRegularDash(ranges); + } + } + + const dashEntry = { + y: (this.nextRow + n + 0.5) / this.height, + height: 2 * n / this.height, + width: length + }; + + this.nextRow += height; + this.dirty = true; + + return dashEntry; + } + + bind(context: Context) { + const gl = context.gl; + if (!this.texture) { + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, this.width, this.height, 0, gl.ALPHA, gl.UNSIGNED_BYTE, this.data); + + } else { + gl.bindTexture(gl.TEXTURE_2D, this.texture); + + if (this.dirty) { + this.dirty = false; + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.ALPHA, gl.UNSIGNED_BYTE, this.data); + } + } + } +} diff --git a/web/libraries/maplibre-gl/src/render/painter.ts b/web/libraries/maplibre-gl/src/render/painter.ts new file mode 100644 index 00000000..89184b29 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/painter.ts @@ -0,0 +1,642 @@ +import {browser} from '../util/browser'; +import {mat4, vec3} from 'gl-matrix'; +import {SourceCache} from '../source/source_cache'; +import {EXTENT} from '../data/extent'; +import {pixelsToTileUnits} from '../source/pixels_to_tile_units'; +import {SegmentVector} from '../data/segment'; +import {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types.g'; +import rasterBoundsAttributes from '../data/raster_bounds_attributes'; +import posAttributes from '../data/pos_attributes'; +import {ProgramConfiguration} from '../data/program_configuration'; +import {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index'; +import {shaders} from '../shaders/shaders'; +import {Program} from './program'; +import {programUniforms} from './program/program_uniforms'; +import {Context} from '../gl/context'; +import {DepthMode} from '../gl/depth_mode'; +import {StencilMode} from '../gl/stencil_mode'; +import {ColorMode} from '../gl/color_mode'; +import {CullFaceMode} from '../gl/cull_face_mode'; +import {Texture} from './texture'; +import {clippingMaskUniformValues} from './program/clipping_mask_program'; +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {drawSymbols} from './draw_symbol'; +import {drawCircles} from './draw_circle'; +import {drawHeatmap} from './draw_heatmap'; +import {drawLine} from './draw_line'; +import {drawFill} from './draw_fill'; +import {drawFillExtrusion} from './draw_fill_extrusion'; +import {drawHillshade} from './draw_hillshade'; +import {drawRaster} from './draw_raster'; +import {drawBackground} from './draw_background'; +import {drawDebug, drawDebugPadding, selectDebugSource} from './draw_debug'; +import {drawCustom} from './draw_custom'; +import {drawDepth, drawCoords} from './draw_terrain'; +import {OverscaledTileID} from '../source/tile_id'; + +import type {Transform} from '../geo/transform'; +import type {Tile} from '../source/tile'; +import type {Style} from '../style/style'; +import type {StyleLayer} from '../style/style_layer'; +import type {CrossFaded} from '../style/properties'; +import type {LineAtlas} from './line_atlas'; +import type {ImageManager} from './image_manager'; +import type {GlyphManager} from './glyph_manager'; +import type {VertexBuffer} from '../gl/vertex_buffer'; +import type {IndexBuffer} from '../gl/index_buffer'; +import type {DepthRangeType, DepthMaskType, DepthFuncType} from '../gl/types'; +import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec'; +import {RenderToTexture} from './render_to_texture'; + +export type RenderPass = 'offscreen' | 'opaque' | 'translucent'; + +type PainterOptions = { + showOverdrawInspector: boolean; + showTileBoundaries: boolean; + showPadding: boolean; + rotating: boolean; + zooming: boolean; + moving: boolean; + fadeDuration: number; +}; + +/** + * @internal + * Initialize a new painter object. + */ +export class Painter { + context: Context; + transform: Transform; + renderToTexture: RenderToTexture; + _tileTextures: { + [_: number]: Array; + }; + numSublayers: number; + depthEpsilon: number; + emptyProgramConfiguration: ProgramConfiguration; + width: number; + height: number; + pixelRatio: number; + tileExtentBuffer: VertexBuffer; + tileExtentSegments: SegmentVector; + debugBuffer: VertexBuffer; + debugSegments: SegmentVector; + rasterBoundsBuffer: VertexBuffer; + rasterBoundsSegments: SegmentVector; + viewportBuffer: VertexBuffer; + viewportSegments: SegmentVector; + quadTriangleIndexBuffer: IndexBuffer; + tileBorderIndexBuffer: IndexBuffer; + _tileClippingMaskIDs: {[_: string]: number}; + stencilClearMode: StencilMode; + style: Style; + options: PainterOptions; + lineAtlas: LineAtlas; + imageManager: ImageManager; + glyphManager: GlyphManager; + depthRangeFor3D: DepthRangeType; + opaquePassCutoff: number; + renderPass: RenderPass; + currentLayer: number; + currentStencilSource: string; + nextStencilID: number; + id: string; + _showOverdrawInspector: boolean; + cache: {[_: string]: Program}; + crossTileSymbolIndex: CrossTileSymbolIndex; + symbolFadeChange: number; + debugOverlayTexture: Texture; + debugOverlayCanvas: HTMLCanvasElement; + // this object stores the current camera-matrix and the last render time + // of the terrain-facilitators. e.g. depth & coords framebuffers + // every time the camera-matrix changes the terrain-facilitators will be redrawn. + terrainFacilitator: {dirty: boolean; matrix: mat4; renderTime: number}; + + constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, transform: Transform) { + this.context = new Context(gl); + this.transform = transform; + this._tileTextures = {}; + this.terrainFacilitator = {dirty: true, matrix: mat4.create(), renderTime: 0}; + + this.setup(); + + // Within each layer there are multiple distinct z-planes that can be drawn to. + // This is implemented using the WebGL depth buffer. + this.numSublayers = SourceCache.maxUnderzooming + SourceCache.maxOverzooming + 1; + this.depthEpsilon = 1 / Math.pow(2, 16); + + this.crossTileSymbolIndex = new CrossTileSymbolIndex(); + } + + /* + * Update the GL viewport, projection matrix, and transforms to compensate + * for a new width and height value. + */ + resize(width: number, height: number, pixelRatio: number) { + this.width = Math.floor(width * pixelRatio); + this.height = Math.floor(height * pixelRatio); + this.pixelRatio = pixelRatio; + this.context.viewport.set([0, 0, this.width, this.height]); + + if (this.style) { + for (const layerId of this.style._order) { + this.style._layers[layerId].resize(); + } + } + } + + setup() { + const context = this.context; + + const tileExtentArray = new PosArray(); + tileExtentArray.emplaceBack(0, 0); + tileExtentArray.emplaceBack(EXTENT, 0); + tileExtentArray.emplaceBack(0, EXTENT); + tileExtentArray.emplaceBack(EXTENT, EXTENT); + this.tileExtentBuffer = context.createVertexBuffer(tileExtentArray, posAttributes.members); + this.tileExtentSegments = SegmentVector.simpleSegment(0, 0, 4, 2); + + const debugArray = new PosArray(); + debugArray.emplaceBack(0, 0); + debugArray.emplaceBack(EXTENT, 0); + debugArray.emplaceBack(0, EXTENT); + debugArray.emplaceBack(EXTENT, EXTENT); + this.debugBuffer = context.createVertexBuffer(debugArray, posAttributes.members); + this.debugSegments = SegmentVector.simpleSegment(0, 0, 4, 5); + + const rasterBoundsArray = new RasterBoundsArray(); + rasterBoundsArray.emplaceBack(0, 0, 0, 0); + rasterBoundsArray.emplaceBack(EXTENT, 0, EXTENT, 0); + rasterBoundsArray.emplaceBack(0, EXTENT, 0, EXTENT); + rasterBoundsArray.emplaceBack(EXTENT, EXTENT, EXTENT, EXTENT); + this.rasterBoundsBuffer = context.createVertexBuffer(rasterBoundsArray, rasterBoundsAttributes.members); + this.rasterBoundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2); + + const viewportArray = new PosArray(); + viewportArray.emplaceBack(0, 0); + viewportArray.emplaceBack(1, 0); + viewportArray.emplaceBack(0, 1); + viewportArray.emplaceBack(1, 1); + this.viewportBuffer = context.createVertexBuffer(viewportArray, posAttributes.members); + this.viewportSegments = SegmentVector.simpleSegment(0, 0, 4, 2); + + const tileLineStripIndices = new LineStripIndexArray(); + tileLineStripIndices.emplaceBack(0); + tileLineStripIndices.emplaceBack(1); + tileLineStripIndices.emplaceBack(3); + tileLineStripIndices.emplaceBack(2); + tileLineStripIndices.emplaceBack(0); + this.tileBorderIndexBuffer = context.createIndexBuffer(tileLineStripIndices); + + const quadTriangleIndices = new TriangleIndexArray(); + quadTriangleIndices.emplaceBack(0, 1, 2); + quadTriangleIndices.emplaceBack(2, 1, 3); + this.quadTriangleIndexBuffer = context.createIndexBuffer(quadTriangleIndices); + + const gl = this.context.gl; + this.stencilClearMode = new StencilMode({func: gl.ALWAYS, mask: 0}, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO); + } + + /* + * Reset the drawing canvas by clearing the stencil buffer so that we can draw + * new tiles at the same location, while retaining previously drawn pixels. + */ + clearStencil() { + const context = this.context; + const gl = context.gl; + + this.nextStencilID = 1; + this.currentStencilSource = undefined; + + // As a temporary workaround for https://github.com/mapbox/mapbox-gl-js/issues/5490, + // pending an upstream fix, we draw a fullscreen stencil=0 clipping mask here, + // effectively clearing the stencil buffer: once an upstream patch lands, remove + // this function in favor of context.clear({ stencil: 0x0 }) + + const matrix = mat4.create(); + mat4.ortho(matrix, 0, this.width, this.height, 0, 0, 1); + mat4.scale(matrix, matrix, [gl.drawingBufferWidth, gl.drawingBufferHeight, 0]); + + this.useProgram('clippingMask').draw(context, gl.TRIANGLES, + DepthMode.disabled, this.stencilClearMode, ColorMode.disabled, CullFaceMode.disabled, + clippingMaskUniformValues(matrix), null, + '$clipping', this.viewportBuffer, + this.quadTriangleIndexBuffer, this.viewportSegments); + } + + _renderTileClippingMasks(layer: StyleLayer, tileIDs: Array) { + if (this.currentStencilSource === layer.source || !layer.isTileClipped() || !tileIDs || !tileIDs.length) return; + + this.currentStencilSource = layer.source; + + const context = this.context; + const gl = context.gl; + + if (this.nextStencilID + tileIDs.length > 256) { + // we'll run out of fresh IDs so we need to clear and start from scratch + this.clearStencil(); + } + + context.setColorMode(ColorMode.disabled); + context.setDepthMode(DepthMode.disabled); + + const program = this.useProgram('clippingMask'); + + this._tileClippingMaskIDs = {}; + + for (const tileID of tileIDs) { + const id = this._tileClippingMaskIDs[tileID.key] = this.nextStencilID++; + const terrainData = this.style.map.terrain && this.style.map.terrain.getTerrainData(tileID); + + program.draw(context, gl.TRIANGLES, DepthMode.disabled, + // Tests will always pass, and ref value will be written to stencil buffer. + new StencilMode({func: gl.ALWAYS, mask: 0}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE), + ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(tileID.posMatrix), + terrainData, '$clipping', this.tileExtentBuffer, + this.quadTriangleIndexBuffer, this.tileExtentSegments); + } + } + + stencilModeFor3D(): StencilMode { + this.currentStencilSource = undefined; + + if (this.nextStencilID + 1 > 256) { + this.clearStencil(); + } + + const id = this.nextStencilID++; + const gl = this.context.gl; + return new StencilMode({func: gl.NOTEQUAL, mask: 0xFF}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE); + } + + stencilModeForClipping(tileID: OverscaledTileID): StencilMode { + const gl = this.context.gl; + return new StencilMode({func: gl.EQUAL, mask: 0xFF}, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE); + } + + /* + * Sort coordinates by Z as drawing tiles is done in Z-descending order. + * All children with the same Z write the same stencil value. Children + * stencil values are greater than parent's. This is used only for raster + * and raster-dem tiles, which are already clipped to tile boundaries, to + * mask area of tile overlapped by children tiles. + * Stencil ref values continue range used in _tileClippingMaskIDs. + * + * Returns [StencilMode for tile overscaleZ map, sortedCoords]. + */ + stencilConfigForOverlap(tileIDs: Array): [{ + [_: number]: Readonly; + }, Array] { + const gl = this.context.gl; + const coords = tileIDs.sort((a, b) => b.overscaledZ - a.overscaledZ); + const minTileZ = coords[coords.length - 1].overscaledZ; + const stencilValues = coords[0].overscaledZ - minTileZ + 1; + if (stencilValues > 1) { + this.currentStencilSource = undefined; + if (this.nextStencilID + stencilValues > 256) { + this.clearStencil(); + } + const zToStencilMode = {}; + for (let i = 0; i < stencilValues; i++) { + zToStencilMode[i + minTileZ] = new StencilMode({func: gl.GEQUAL, mask: 0xFF}, i + this.nextStencilID, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE); + } + this.nextStencilID += stencilValues; + return [zToStencilMode, coords]; + } + return [{[minTileZ]: StencilMode.disabled}, coords]; + } + + colorModeForRenderPass(): Readonly { + const gl = this.context.gl; + if (this._showOverdrawInspector) { + const numOverdrawSteps = 8; + const a = 1 / numOverdrawSteps; + + return new ColorMode([gl.CONSTANT_COLOR, gl.ONE], new Color(a, a, a, 0), [true, true, true, true]); + } else if (this.renderPass === 'opaque') { + return ColorMode.unblended; + } else { + return ColorMode.alphaBlended; + } + } + + depthModeForSublayer(n: number, mask: DepthMaskType, func?: DepthFuncType | null): Readonly { + if (!this.opaquePassEnabledForLayer()) return DepthMode.disabled; + const depth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon; + return new DepthMode(func || this.context.gl.LEQUAL, mask, [depth, depth]); + } + + /* + * The opaque pass and 3D layers both use the depth buffer. + * Layers drawn above 3D layers need to be drawn using the + * painter's algorithm so that they appear above 3D features. + * This returns true for layers that can be drawn using the + * opaque pass. + */ + opaquePassEnabledForLayer() { + return this.currentLayer < this.opaquePassCutoff; + } + + render(style: Style, options: PainterOptions) { + this.style = style; + this.options = options; + + this.lineAtlas = style.lineAtlas; + this.imageManager = style.imageManager; + this.glyphManager = style.glyphManager; + + this.symbolFadeChange = style.placement.symbolFadeChange(browser.now()); + + this.imageManager.beginFrame(); + + const layerIds = this.style._order; + const sourceCaches = this.style.sourceCaches; + + const coordsAscending: {[_: string]: Array} = {}; + const coordsDescending: {[_: string]: Array} = {}; + const coordsDescendingSymbol: {[_: string]: Array} = {}; + + for (const id in sourceCaches) { + const sourceCache = sourceCaches[id]; + if (sourceCache.used) { + sourceCache.prepare(this.context); + } + + coordsAscending[id] = sourceCache.getVisibleCoordinates(); + coordsDescending[id] = coordsAscending[id].slice().reverse(); + coordsDescendingSymbol[id] = sourceCache.getVisibleCoordinates(true).reverse(); + } + + this.opaquePassCutoff = Infinity; + for (let i = 0; i < layerIds.length; i++) { + const layerId = layerIds[i]; + if (this.style._layers[layerId].is3D()) { + this.opaquePassCutoff = i; + break; + } + } + + if (this.renderToTexture) { + this.renderToTexture.prepareForRender(this.style, this.transform.zoom); + // this is disabled, because render-to-texture is rendering all layers from bottom to top. + this.opaquePassCutoff = 0; + + // update coords/depth-framebuffer on camera movement, or tile reloading + const newTiles = this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime); + if (this.terrainFacilitator.dirty || !mat4.equals(this.terrainFacilitator.matrix, this.transform.projMatrix) || newTiles.length) { + mat4.copy(this.terrainFacilitator.matrix, this.transform.projMatrix); + this.terrainFacilitator.renderTime = Date.now(); + this.terrainFacilitator.dirty = false; + drawDepth(this, this.style.map.terrain); + drawCoords(this, this.style.map.terrain); + } + } + + // Offscreen pass =============================================== + // We first do all rendering that requires rendering to a separate + // framebuffer, and then save those for rendering back to the map + // later: in doing this we avoid doing expensive framebuffer restores. + this.renderPass = 'offscreen'; + + for (const layerId of layerIds) { + const layer = this.style._layers[layerId]; + if (!layer.hasOffscreenPass() || layer.isHidden(this.transform.zoom)) continue; + + const coords = coordsDescending[layer.source]; + if (layer.type !== 'custom' && !coords.length) continue; + + this.renderLayer(this, sourceCaches[layer.source], layer, coords); + } + + // Rebind the main framebuffer now that all offscreen layers have been rendered: + this.context.bindFramebuffer.set(null); + + // Clear buffers in preparation for drawing to the main framebuffer + this.context.clear({color: options.showOverdrawInspector ? Color.black : Color.transparent, depth: 1}); + this.clearStencil(); + + this._showOverdrawInspector = options.showOverdrawInspector; + this.depthRangeFor3D = [0, 1 - ((style._order.length + 2) * this.numSublayers * this.depthEpsilon)]; + + // Opaque pass =============================================== + // Draw opaque layers top-to-bottom first. + if (!this.renderToTexture) { + this.renderPass = 'opaque'; + + for (this.currentLayer = layerIds.length - 1; this.currentLayer >= 0; this.currentLayer--) { + const layer = this.style._layers[layerIds[this.currentLayer]]; + const sourceCache = sourceCaches[layer.source]; + const coords = coordsAscending[layer.source]; + + this._renderTileClippingMasks(layer, coords); + this.renderLayer(this, sourceCache, layer, coords); + } + } + + // Translucent pass =============================================== + // Draw all other layers bottom-to-top. + this.renderPass = 'translucent'; + + for (this.currentLayer = 0; this.currentLayer < layerIds.length; this.currentLayer++) { + const layer = this.style._layers[layerIds[this.currentLayer]]; + const sourceCache = sourceCaches[layer.source]; + + if (this.renderToTexture && this.renderToTexture.renderLayer(layer)) continue; + + // For symbol layers in the translucent pass, we add extra tiles to the renderable set + // for cross-tile symbol fading. Symbol layers don't use tile clipping, so no need to render + // separate clipping masks + const coords = (layer.type === 'symbol' ? coordsDescendingSymbol : coordsDescending)[layer.source]; + + this._renderTileClippingMasks(layer, coordsAscending[layer.source]); + this.renderLayer(this, sourceCache, layer, coords); + } + + if (this.options.showTileBoundaries) { + const selectedSource = selectDebugSource(this.style, this.transform.zoom); + if (selectedSource) { + drawDebug(this, selectedSource, selectedSource.getVisibleCoordinates()); + } + } + + if (this.options.showPadding) { + drawDebugPadding(this); + } + + // Set defaults for most GL values so that anyone using the state after the render + // encounters more expected values. + this.context.setDefault(); + } + + renderLayer(painter: Painter, sourceCache: SourceCache, layer: StyleLayer, coords: Array) { + if (layer.isHidden(this.transform.zoom)) return; + if (layer.type !== 'background' && layer.type !== 'custom' && !(coords || []).length) return; + this.id = layer.id; + + switch (layer.type) { + case 'symbol': + drawSymbols(painter, sourceCache, layer as any, coords, this.style.placement.variableOffsets); + break; + case 'circle': + drawCircles(painter, sourceCache, layer as any, coords); + break; + case 'heatmap': + drawHeatmap(painter, sourceCache, layer as any, coords); + break; + case 'line': + drawLine(painter, sourceCache, layer as any, coords); + break; + case 'fill': + drawFill(painter, sourceCache, layer as any, coords); + break; + case 'fill-extrusion': + drawFillExtrusion(painter, sourceCache, layer as any, coords); + break; + case 'hillshade': + drawHillshade(painter, sourceCache, layer as any, coords); + break; + case 'raster': + drawRaster(painter, sourceCache, layer as any, coords); + break; + case 'background': + drawBackground(painter, sourceCache, layer as any, coords); + break; + case 'custom': + drawCustom(painter, sourceCache, layer as any); + break; + } + } + + /** + * Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it. + * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units. + * @returns matrix + */ + translatePosMatrix(matrix: mat4, tile: Tile, translate: [number, number], translateAnchor: 'map' | 'viewport', inViewportPixelUnitsUnits?: boolean): mat4 { + if (!translate[0] && !translate[1]) return matrix; + + const angle = inViewportPixelUnitsUnits ? + (translateAnchor === 'map' ? this.transform.angle : 0) : + (translateAnchor === 'viewport' ? -this.transform.angle : 0); + + if (angle) { + const sinA = Math.sin(angle); + const cosA = Math.cos(angle); + translate = [ + translate[0] * cosA - translate[1] * sinA, + translate[0] * sinA + translate[1] * cosA + ]; + } + + const translation = [ + inViewportPixelUnitsUnits ? translate[0] : pixelsToTileUnits(tile, translate[0], this.transform.zoom), + inViewportPixelUnitsUnits ? translate[1] : pixelsToTileUnits(tile, translate[1], this.transform.zoom), + 0 + ] as vec3; + + const translatedMatrix = new Float32Array(16); + mat4.translate(translatedMatrix, matrix, translation); + return translatedMatrix; + } + + saveTileTexture(texture: Texture) { + const textures = this._tileTextures[texture.size[0]]; + if (!textures) { + this._tileTextures[texture.size[0]] = [texture]; + } else { + textures.push(texture); + } + } + + getTileTexture(size: number) { + const textures = this._tileTextures[size]; + return textures && textures.length > 0 ? textures.pop() : null; + } + + /** + * Checks whether a pattern image is needed, and if it is, whether it is not loaded. + * + * @returns true if a needed image is missing and rendering needs to be skipped. + */ + isPatternMissing(image?: CrossFaded | null): boolean { + if (!image) return false; + if (!image.from || !image.to) return true; + const imagePosA = this.imageManager.getPattern(image.from.toString()); + const imagePosB = this.imageManager.getPattern(image.to.toString()); + return !imagePosA || !imagePosB; + } + + useProgram(name: string, programConfiguration?: ProgramConfiguration | null): Program { + this.cache = this.cache || {}; + const key = name + + (programConfiguration ? programConfiguration.cacheKey : '') + + (this._showOverdrawInspector ? '/overdraw' : '') + + (this.style.map.terrain ? '/terrain' : ''); + if (!this.cache[key]) { + this.cache[key] = new Program( + this.context, + shaders[name], + programConfiguration, + programUniforms[name], + this._showOverdrawInspector, + this.style.map.terrain + ); + } + return this.cache[key]; + } + + /* + * Reset some GL state to default values to avoid hard-to-debug bugs + * in custom layers. + */ + setCustomLayerDefaults() { + // Prevent custom layers from unintentionally modify the last VAO used. + // All other state is state is restored on it's own, but for VAOs it's + // simpler to unbind so that we don't have to track the state of VAOs. + this.context.unbindVAO(); + + // The default values for this state is meaningful and often expected. + // Leaving this state dirty could cause a lot of confusion for users. + this.context.cullFace.setDefault(); + this.context.activeTexture.setDefault(); + this.context.pixelStoreUnpack.setDefault(); + this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(); + this.context.pixelStoreUnpackFlipY.setDefault(); + } + + /* + * Set GL state that is shared by all layers. + */ + setBaseState() { + const gl = this.context.gl; + this.context.cullFace.set(false); + this.context.viewport.set([0, 0, this.width, this.height]); + this.context.blendEquation.set(gl.FUNC_ADD); + } + + initDebugOverlayCanvas() { + if (this.debugOverlayCanvas == null) { + this.debugOverlayCanvas = document.createElement('canvas'); + this.debugOverlayCanvas.width = 512; + this.debugOverlayCanvas.height = 512; + const gl = this.context.gl; + this.debugOverlayTexture = new Texture(this.context, this.debugOverlayCanvas, gl.RGBA); + } + } + + destroy() { + if (this.debugOverlayTexture) { + this.debugOverlayTexture.destroy(); + } + } + + /* + * Return true if drawing buffer size is != from requested size. + * That means that we've reached GL limits somehow. + * Note: drawing buffer size changes only when canvas size changes + */ + overLimit() { + const {drawingBufferWidth, drawingBufferHeight} = this.context.gl; + return this.width !== drawingBufferWidth || this.height !== drawingBufferHeight; + } +} diff --git a/web/libraries/maplibre-gl/src/render/program.ts b/web/libraries/maplibre-gl/src/render/program.ts new file mode 100644 index 00000000..bac18b20 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program.ts @@ -0,0 +1,233 @@ +import {shaders} from '../shaders/shaders'; +import {ProgramConfiguration} from '../data/program_configuration'; +import {VertexArrayObject} from './vertex_array_object'; +import {Context} from '../gl/context'; + +import type {SegmentVector} from '../data/segment'; +import type {VertexBuffer} from '../gl/vertex_buffer'; +import type {IndexBuffer} from '../gl/index_buffer'; +import type {DepthMode} from '../gl/depth_mode'; +import type {StencilMode} from '../gl/stencil_mode'; +import type {ColorMode} from '../gl/color_mode'; +import type {CullFaceMode} from '../gl/cull_face_mode'; +import type {UniformBindings, UniformValues, UniformLocations} from './uniform_binding'; +import type {BinderUniform} from '../data/program_configuration'; +import {terrainPreludeUniforms, TerrainPreludeUniformsType} from './program/terrain_program'; +import type {TerrainData} from '../render/terrain'; +import {Terrain} from '../render/terrain'; + +export type DrawMode = WebGLRenderingContextBase['LINES'] | WebGLRenderingContextBase['TRIANGLES'] | WebGL2RenderingContext['LINE_STRIP']; + +function getTokenizedAttributesAndUniforms(array: Array): Array { + const result = []; + + for (let i = 0; i < array.length; i++) { + if (array[i] === null) continue; + const token = array[i].split(' '); + result.push(token.pop()); + } + return result; +} + +/** + * @internal + * A webgl program to execute in the GPU space + */ +export class Program { + program: WebGLProgram; + attributes: {[_: string]: number}; + numAttributes: number; + fixedUniforms: Us; + terrainUniforms: TerrainPreludeUniformsType; + binderUniforms: Array; + failedToCreate: boolean; + + constructor(context: Context, + source: { + fragmentSource: string; + vertexSource: string; + staticAttributes: Array; + staticUniforms: Array; + }, + configuration: ProgramConfiguration, + fixedUniforms: (b: Context, a: UniformLocations) => Us, + showOverdrawInspector: boolean, + terrain: Terrain) { + + const gl = context.gl; + this.program = gl.createProgram(); + + const staticAttrInfo = getTokenizedAttributesAndUniforms(source.staticAttributes); + const dynamicAttrInfo = configuration ? configuration.getBinderAttributes() : []; + const allAttrInfo = staticAttrInfo.concat(dynamicAttrInfo); + + const preludeUniformsInfo = shaders.prelude.staticUniforms ? getTokenizedAttributesAndUniforms(shaders.prelude.staticUniforms) : []; + const staticUniformsInfo = source.staticUniforms ? getTokenizedAttributesAndUniforms(source.staticUniforms) : []; + const dynamicUniformsInfo = configuration ? configuration.getBinderUniforms() : []; + // remove duplicate uniforms + const uniformList = preludeUniformsInfo.concat(staticUniformsInfo).concat(dynamicUniformsInfo); + const allUniformsInfo = []; + for (const uniform of uniformList) { + if (allUniformsInfo.indexOf(uniform) < 0) allUniformsInfo.push(uniform); + } + + const defines = configuration ? configuration.defines() : []; + if (showOverdrawInspector) { + defines.push('#define OVERDRAW_INSPECTOR;'); + } + if (terrain) { + defines.push('#define TERRAIN3D;'); + } + + const fragmentSource = defines.concat(shaders.prelude.fragmentSource, source.fragmentSource).join('\n'); + const vertexSource = defines.concat(shaders.prelude.vertexSource, source.vertexSource).join('\n'); + + const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + if (gl.isContextLost()) { + this.failedToCreate = true; + return; + } + gl.shaderSource(fragmentShader, fragmentSource); + gl.compileShader(fragmentShader); + + if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) { + throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`); + } + + gl.attachShader(this.program, fragmentShader); + + const vertexShader = gl.createShader(gl.VERTEX_SHADER); + if (gl.isContextLost()) { + this.failedToCreate = true; + return; + } + gl.shaderSource(vertexShader, vertexSource); + gl.compileShader(vertexShader); + + if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) { + throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`); + } + + gl.attachShader(this.program, vertexShader); + + this.attributes = {}; + const uniformLocations = {}; + + this.numAttributes = allAttrInfo.length; + + for (let i = 0; i < this.numAttributes; i++) { + if (allAttrInfo[i]) { + gl.bindAttribLocation(this.program, i, allAttrInfo[i]); + this.attributes[allAttrInfo[i]] = i; + } + } + + gl.linkProgram(this.program); + + if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) { + throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`); + } + + gl.deleteShader(vertexShader); + gl.deleteShader(fragmentShader); + + for (let it = 0; it < allUniformsInfo.length; it++) { + const uniform = allUniformsInfo[it]; + if (uniform && !uniformLocations[uniform]) { + const uniformLocation = gl.getUniformLocation(this.program, uniform); + if (uniformLocation) { + uniformLocations[uniform] = uniformLocation; + } + } + } + + this.fixedUniforms = fixedUniforms(context, uniformLocations); + this.terrainUniforms = terrainPreludeUniforms(context, uniformLocations); + this.binderUniforms = configuration ? configuration.getUniforms(context, uniformLocations) : []; + } + + draw(context: Context, + drawMode: DrawMode, + depthMode: Readonly, + stencilMode: Readonly, + colorMode: Readonly, + cullFaceMode: Readonly, + uniformValues: UniformValues, + terrain: TerrainData, + layerID: string, + layoutVertexBuffer: VertexBuffer, + indexBuffer: IndexBuffer, + segments: SegmentVector, + currentProperties?: any, + zoom?: number | null, + configuration?: ProgramConfiguration | null, + dynamicLayoutBuffer?: VertexBuffer | null, + dynamicLayoutBuffer2?: VertexBuffer | null, + dynamicLayoutBuffer3?: VertexBuffer | null) { + + const gl = context.gl; + + if (this.failedToCreate) return; + + context.program.set(this.program); + context.setDepthMode(depthMode); + context.setStencilMode(stencilMode); + context.setColorMode(colorMode); + context.setCullFace(cullFaceMode); + + // set variables used by the 3d functions defined in _prelude.vertex.glsl + if (terrain) { + context.activeTexture.set(gl.TEXTURE2); + gl.bindTexture(gl.TEXTURE_2D, terrain.depthTexture); + context.activeTexture.set(gl.TEXTURE3); + gl.bindTexture(gl.TEXTURE_2D, terrain.texture); + for (const name in this.terrainUniforms) { + this.terrainUniforms[name].set(terrain[name]); + } + } + + for (const name in this.fixedUniforms) { + this.fixedUniforms[name].set(uniformValues[name]); + } + + if (configuration) { + configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom as any)}); + } + + let primitiveSize = 0; + switch (drawMode) { + case gl.LINES: + primitiveSize = 2; + break; + case gl.TRIANGLES: + primitiveSize = 3; + break; + case gl.LINE_STRIP: + primitiveSize = 1; + break; + } + + for (const segment of segments.get()) { + const vaos = segment.vaos || (segment.vaos = {}); + const vao: VertexArrayObject = vaos[layerID] || (vaos[layerID] = new VertexArrayObject()); + + vao.bind( + context, + this, + layoutVertexBuffer, + configuration ? configuration.getPaintVertexBuffers() : [], + indexBuffer, + segment.vertexOffset, + dynamicLayoutBuffer, + dynamicLayoutBuffer2, + dynamicLayoutBuffer3 + ); + + gl.drawElements( + drawMode, + segment.primitiveLength * primitiveSize, + gl.UNSIGNED_SHORT, + segment.primitiveOffset * primitiveSize * 2); + } + } +} diff --git a/web/libraries/maplibre-gl/src/render/program/background_program.ts b/web/libraries/maplibre-gl/src/render/program/background_program.ts new file mode 100644 index 00000000..7802c488 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/background_program.ts @@ -0,0 +1,100 @@ +import {bgPatternUniformValues} from './pattern'; +import { + Uniform1i, + Uniform1f, + Uniform2f, + UniformColor, + UniformMatrix4f +} from '../uniform_binding'; +import {extend} from '../../util/util'; + +import type {Painter} from '../painter'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Context} from '../../gl/context'; +import type {Color, ResolvedImage} from '@maplibre/maplibre-gl-style-spec'; +import type {CrossFaded} from '../../style/properties'; +import type {CrossfadeParameters} from '../../style/evaluation_parameters'; +import type {OverscaledTileID} from '../../source/tile_id'; +import {mat4} from 'gl-matrix'; + +export type BackgroundUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_opacity': Uniform1f; + 'u_color': UniformColor; +}; + +export type BackgroundPatternUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_opacity': Uniform1f; + // pattern uniforms: + 'u_image': Uniform1i; + 'u_pattern_tl_a': Uniform2f; + 'u_pattern_br_a': Uniform2f; + 'u_pattern_tl_b': Uniform2f; + 'u_pattern_br_b': Uniform2f; + 'u_texsize': Uniform2f; + 'u_mix': Uniform1f; + 'u_pattern_size_a': Uniform2f; + 'u_pattern_size_b': Uniform2f; + 'u_scale_a': Uniform1f; + 'u_scale_b': Uniform1f; + 'u_pixel_coord_upper': Uniform2f; + 'u_pixel_coord_lower': Uniform2f; + 'u_tile_units_to_pixels': Uniform1f; +}; + +const backgroundUniforms = (context: Context, locations: UniformLocations): BackgroundUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_opacity': new Uniform1f(context, locations.u_opacity), + 'u_color': new UniformColor(context, locations.u_color) +}); + +const backgroundPatternUniforms = (context: Context, locations: UniformLocations): BackgroundPatternUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_opacity': new Uniform1f(context, locations.u_opacity), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_pattern_tl_a': new Uniform2f(context, locations.u_pattern_tl_a), + 'u_pattern_br_a': new Uniform2f(context, locations.u_pattern_br_a), + 'u_pattern_tl_b': new Uniform2f(context, locations.u_pattern_tl_b), + 'u_pattern_br_b': new Uniform2f(context, locations.u_pattern_br_b), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_mix': new Uniform1f(context, locations.u_mix), + 'u_pattern_size_a': new Uniform2f(context, locations.u_pattern_size_a), + 'u_pattern_size_b': new Uniform2f(context, locations.u_pattern_size_b), + 'u_scale_a': new Uniform1f(context, locations.u_scale_a), + 'u_scale_b': new Uniform1f(context, locations.u_scale_b), + 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower), + 'u_tile_units_to_pixels': new Uniform1f(context, locations.u_tile_units_to_pixels) +}); + +const backgroundUniformValues = (matrix: mat4, opacity: number, color: Color): UniformValues => ({ + 'u_matrix': matrix, + 'u_opacity': opacity, + 'u_color': color +}); + +const backgroundPatternUniformValues = ( + matrix: mat4, + opacity: number, + painter: Painter, + image: CrossFaded, + tile: { + tileID: OverscaledTileID; + tileSize: number; + }, + crossfade: CrossfadeParameters +): UniformValues => extend( + bgPatternUniformValues(image, crossfade, painter, tile), + { + 'u_matrix': matrix, + 'u_opacity': opacity + } +); + +export { + backgroundUniforms, + backgroundPatternUniforms, + backgroundUniformValues, + backgroundPatternUniformValues +}; diff --git a/web/libraries/maplibre-gl/src/render/program/circle_program.ts b/web/libraries/maplibre-gl/src/render/program/circle_program.ts new file mode 100644 index 00000000..97f1ef04 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/circle_program.ts @@ -0,0 +1,61 @@ +import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding'; +import {pixelsToTileUnits} from '../../source/pixels_to_tile_units'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {OverscaledTileID} from '../../source/tile_id'; +import type {Tile} from '../../source/tile'; +import type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer'; +import type {Painter} from '../painter'; + +export type CircleUniformsType = { + 'u_camera_to_center_distance': Uniform1f; + 'u_scale_with_map': Uniform1i; + 'u_pitch_with_map': Uniform1i; + 'u_extrude_scale': Uniform2f; + 'u_device_pixel_ratio': Uniform1f; + 'u_matrix': UniformMatrix4f; +}; + +const circleUniforms = (context: Context, locations: UniformLocations): CircleUniformsType => ({ + 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance), + 'u_scale_with_map': new Uniform1i(context, locations.u_scale_with_map), + 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map), + 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix) +}); + +const circleUniformValues = ( + painter: Painter, + coord: OverscaledTileID, + tile: Tile, + layer: CircleStyleLayer +): UniformValues => { + const transform = painter.transform; + + let pitchWithMap: boolean, extrudeScale: [number, number]; + if (layer.paint.get('circle-pitch-alignment') === 'map') { + const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom); + pitchWithMap = true; + extrudeScale = [pixelRatio, pixelRatio]; + } else { + pitchWithMap = false; + extrudeScale = transform.pixelsToGLUnits; + } + + return { + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_scale_with_map': +(layer.paint.get('circle-pitch-scale') === 'map'), + 'u_matrix': painter.translatePosMatrix( + coord.posMatrix, + tile, + layer.paint.get('circle-translate'), + layer.paint.get('circle-translate-anchor')), + 'u_pitch_with_map': +(pitchWithMap), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_extrude_scale': extrudeScale + }; +}; + +export {circleUniforms, circleUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/program/clipping_mask_program.ts b/web/libraries/maplibre-gl/src/render/program/clipping_mask_program.ts new file mode 100644 index 00000000..18819821 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/clipping_mask_program.ts @@ -0,0 +1,19 @@ +import {UniformMatrix4f} from '../uniform_binding'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import {mat4} from 'gl-matrix'; + +export type ClippingMaskUniformsType = { + 'u_matrix': UniformMatrix4f; +}; + +const clippingMaskUniforms = (context: Context, locations: UniformLocations): ClippingMaskUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix) +}); + +const clippingMaskUniformValues = (matrix: mat4): UniformValues => ({ + 'u_matrix': matrix +}); + +export {clippingMaskUniforms, clippingMaskUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/program/collision_program.ts b/web/libraries/maplibre-gl/src/render/program/collision_program.ts new file mode 100644 index 00000000..4387dcf6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/collision_program.ts @@ -0,0 +1,63 @@ +import {Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding'; +import {pixelsToTileUnits} from '../../source/pixels_to_tile_units'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Transform} from '../../geo/transform'; +import type {Tile} from '../../source/tile'; +import {mat4} from 'gl-matrix'; + +export type CollisionUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_camera_to_center_distance': Uniform1f; + 'u_pixels_to_tile_units': Uniform1f; + 'u_extrude_scale': Uniform2f; + 'u_overscale_factor': Uniform1f; +}; + +export type CollisionCircleUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_inv_matrix': UniformMatrix4f; + 'u_camera_to_center_distance': Uniform1f; + 'u_viewport_size': Uniform2f; +}; + +const collisionUniforms = (context: Context, locations: UniformLocations): CollisionUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pixels_to_tile_units': new Uniform1f(context, locations.u_pixels_to_tile_units), + 'u_extrude_scale': new Uniform2f(context, locations.u_extrude_scale), + 'u_overscale_factor': new Uniform1f(context, locations.u_overscale_factor) +}); + +const collisionCircleUniforms = (context: Context, locations: UniformLocations): CollisionCircleUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_inv_matrix': new UniformMatrix4f(context, locations.u_inv_matrix), + 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance), + 'u_viewport_size': new Uniform2f(context, locations.u_viewport_size) +}); + +const collisionUniformValues = (matrix: mat4, transform: Transform, tile: Tile): UniformValues => { + const pixelRatio = pixelsToTileUnits(tile, 1, transform.zoom); + const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ); + const overscaleFactor = tile.tileID.overscaleFactor(); + return { + 'u_matrix': matrix, + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_pixels_to_tile_units': pixelRatio, + 'u_extrude_scale': [transform.pixelsToGLUnits[0] / (pixelRatio * scale), + transform.pixelsToGLUnits[1] / (pixelRatio * scale)], + 'u_overscale_factor': overscaleFactor + }; +}; + +const collisionCircleUniformValues = (matrix: mat4, invMatrix: mat4, transform: Transform): UniformValues => { + return { + 'u_matrix': matrix, + 'u_inv_matrix': invMatrix, + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_viewport_size': [transform.width, transform.height] + }; +}; + +export {collisionUniforms, collisionUniformValues, collisionCircleUniforms, collisionCircleUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/program/debug_program.ts b/web/libraries/maplibre-gl/src/render/program/debug_program.ts new file mode 100644 index 00000000..21113eed --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/debug_program.ts @@ -0,0 +1,29 @@ +import {UniformColor, UniformMatrix4f, Uniform1i, Uniform1f} from '../uniform_binding'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Color} from '@maplibre/maplibre-gl-style-spec'; +import {mat4} from 'gl-matrix'; + +export type DebugUniformsType = { + 'u_color': UniformColor; + 'u_matrix': UniformMatrix4f; + 'u_overlay': Uniform1i; + 'u_overlay_scale': Uniform1f; +}; + +const debugUniforms = (context: Context, locations: UniformLocations): DebugUniformsType => ({ + 'u_color': new UniformColor(context, locations.u_color), + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_overlay': new Uniform1i(context, locations.u_overlay), + 'u_overlay_scale': new Uniform1f(context, locations.u_overlay_scale) +}); + +const debugUniformValues = (matrix: mat4, color: Color, scaleRatio: number = 1): UniformValues => ({ + 'u_matrix': matrix, + 'u_color': color, + 'u_overlay': 0, + 'u_overlay_scale': scaleRatio +}); + +export {debugUniforms, debugUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/program/fill_extrusion_program.ts b/web/libraries/maplibre-gl/src/render/program/fill_extrusion_program.ts new file mode 100644 index 00000000..d6efae42 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/fill_extrusion_program.ts @@ -0,0 +1,120 @@ +import {patternUniformValues} from './pattern'; +import { + Uniform1i, + Uniform1f, + Uniform2f, + Uniform3f, + UniformMatrix4f +} from '../uniform_binding'; + +import {mat3, mat4, vec3} from 'gl-matrix'; +import {extend} from '../../util/util'; + +import type {Context} from '../../gl/context'; +import type {Painter} from '../painter'; +import type {OverscaledTileID} from '../../source/tile_id'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {CrossfadeParameters} from '../../style/evaluation_parameters'; +import type {Tile} from '../../source/tile'; + +export type FillExtrusionUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_lightpos': Uniform3f; + 'u_lightintensity': Uniform1f; + 'u_lightcolor': Uniform3f; + 'u_vertical_gradient': Uniform1f; + 'u_opacity': Uniform1f; +}; + +export type FillExtrusionPatternUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_lightpos': Uniform3f; + 'u_lightintensity': Uniform1f; + 'u_lightcolor': Uniform3f; + 'u_height_factor': Uniform1f; + 'u_vertical_gradient': Uniform1f; + // pattern uniforms: + 'u_texsize': Uniform2f; + 'u_image': Uniform1i; + 'u_pixel_coord_upper': Uniform2f; + 'u_pixel_coord_lower': Uniform2f; + 'u_scale': Uniform3f; + 'u_fade': Uniform1f; + 'u_opacity': Uniform1f; +}; + +const fillExtrusionUniforms = (context: Context, locations: UniformLocations): FillExtrusionUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_lightpos': new Uniform3f(context, locations.u_lightpos), + 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity), + 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor), + 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient), + 'u_opacity': new Uniform1f(context, locations.u_opacity) +}); + +const fillExtrusionPatternUniforms = (context: Context, locations: UniformLocations): FillExtrusionPatternUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_lightpos': new Uniform3f(context, locations.u_lightpos), + 'u_lightintensity': new Uniform1f(context, locations.u_lightintensity), + 'u_lightcolor': new Uniform3f(context, locations.u_lightcolor), + 'u_vertical_gradient': new Uniform1f(context, locations.u_vertical_gradient), + 'u_height_factor': new Uniform1f(context, locations.u_height_factor), + // pattern uniforms + 'u_image': new Uniform1i(context, locations.u_image), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower), + 'u_scale': new Uniform3f(context, locations.u_scale), + 'u_fade': new Uniform1f(context, locations.u_fade), + 'u_opacity': new Uniform1f(context, locations.u_opacity) +}); + +const fillExtrusionUniformValues = ( + matrix: mat4, + painter: Painter, + shouldUseVerticalGradient: boolean, + opacity: number +): UniformValues => { + const light = painter.style.light; + const _lp = light.properties.get('position'); + const lightPos = [_lp.x, _lp.y, _lp.z] as vec3; + const lightMat = mat3.create(); + if (light.properties.get('anchor') === 'viewport') { + mat3.fromRotation(lightMat, -painter.transform.angle); + } + vec3.transformMat3(lightPos, lightPos, lightMat); + + const lightColor = light.properties.get('color'); + + return { + 'u_matrix': matrix, + 'u_lightpos': lightPos, + 'u_lightintensity': light.properties.get('intensity'), + 'u_lightcolor': [lightColor.r, lightColor.g, lightColor.b], + 'u_vertical_gradient': +shouldUseVerticalGradient, + 'u_opacity': opacity + }; +}; + +const fillExtrusionPatternUniformValues = ( + matrix: mat4, + painter: Painter, + shouldUseVerticalGradient: boolean, + opacity: number, + coord: OverscaledTileID, + crossfade: CrossfadeParameters, + tile: Tile +): UniformValues => { + return extend(fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity), + patternUniformValues(crossfade, painter, tile), + { + 'u_height_factor': -Math.pow(2, coord.overscaledZ) / tile.tileSize / 8 + }); +}; + +export { + fillExtrusionUniforms, + fillExtrusionPatternUniforms, + fillExtrusionUniformValues, + fillExtrusionPatternUniformValues +}; diff --git a/web/libraries/maplibre-gl/src/render/program/fill_program.ts b/web/libraries/maplibre-gl/src/render/program/fill_program.ts new file mode 100644 index 00000000..1ae148ba --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/fill_program.ts @@ -0,0 +1,121 @@ +import {patternUniformValues} from './pattern'; +import { + Uniform1i, + Uniform1f, + Uniform2f, + Uniform3f, + UniformMatrix4f +} from '../uniform_binding'; +import {extend} from '../../util/util'; + +import type {Painter} from '../painter'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Context} from '../../gl/context'; +import type {CrossfadeParameters} from '../../style/evaluation_parameters'; +import type {Tile} from '../../source/tile'; +import {mat4} from 'gl-matrix'; + +export type FillUniformsType = { + 'u_matrix': UniformMatrix4f; +}; + +export type FillOutlineUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_world': Uniform2f; +}; + +export type FillPatternUniformsType = { + 'u_matrix': UniformMatrix4f; + // pattern uniforms: + 'u_texsize': Uniform2f; + 'u_image': Uniform1i; + 'u_pixel_coord_upper': Uniform2f; + 'u_pixel_coord_lower': Uniform2f; + 'u_scale': Uniform3f; + 'u_fade': Uniform1f; +}; + +export type FillOutlinePatternUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_world': Uniform2f; + // pattern uniforms: + 'u_texsize': Uniform2f; + 'u_image': Uniform1i; + 'u_pixel_coord_upper': Uniform2f; + 'u_pixel_coord_lower': Uniform2f; + 'u_scale': Uniform3f; + 'u_fade': Uniform1f; +}; + +const fillUniforms = (context: Context, locations: UniformLocations): FillUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix) +}); + +const fillPatternUniforms = (context: Context, locations: UniformLocations): FillPatternUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower), + 'u_scale': new Uniform3f(context, locations.u_scale), + 'u_fade': new Uniform1f(context, locations.u_fade) +}); + +const fillOutlineUniforms = (context: Context, locations: UniformLocations): FillOutlineUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_world': new Uniform2f(context, locations.u_world) +}); + +const fillOutlinePatternUniforms = (context: Context, locations: UniformLocations): FillOutlinePatternUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_world': new Uniform2f(context, locations.u_world), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_pixel_coord_upper': new Uniform2f(context, locations.u_pixel_coord_upper), + 'u_pixel_coord_lower': new Uniform2f(context, locations.u_pixel_coord_lower), + 'u_scale': new Uniform3f(context, locations.u_scale), + 'u_fade': new Uniform1f(context, locations.u_fade) +}); + +const fillUniformValues = (matrix: mat4): UniformValues => ({ + 'u_matrix': matrix +}); + +const fillPatternUniformValues = ( + matrix: mat4, + painter: Painter, + crossfade: CrossfadeParameters, + tile: Tile +): UniformValues => extend( + fillUniformValues(matrix), + patternUniformValues(crossfade, painter, tile) +); + +const fillOutlineUniformValues = (matrix: mat4, drawingBufferSize: [number, number]): UniformValues => ({ + 'u_matrix': matrix, + 'u_world': drawingBufferSize +}); + +const fillOutlinePatternUniformValues = ( + matrix: mat4, + painter: Painter, + crossfade: CrossfadeParameters, + tile: Tile, + drawingBufferSize: [number, number] +): UniformValues => extend( + fillPatternUniformValues(matrix, painter, crossfade, tile), + { + 'u_world': drawingBufferSize + } +); + +export { + fillUniforms, + fillPatternUniforms, + fillOutlineUniforms, + fillOutlinePatternUniforms, + fillUniformValues, + fillPatternUniformValues, + fillOutlineUniformValues, + fillOutlinePatternUniformValues +}; diff --git a/web/libraries/maplibre-gl/src/render/program/heatmap_program.ts b/web/libraries/maplibre-gl/src/render/program/heatmap_program.ts new file mode 100644 index 00000000..b3c4e02a --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/heatmap_program.ts @@ -0,0 +1,76 @@ +import {mat4} from 'gl-matrix'; + +import { + Uniform1i, + Uniform1f, + Uniform2f, + UniformMatrix4f +} from '../uniform_binding'; +import {pixelsToTileUnits} from '../../source/pixels_to_tile_units'; + +import type {Context} from '../../gl/context'; +import type {Tile} from '../../source/tile'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Painter} from '../painter'; +import type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer'; + +export type HeatmapUniformsType = { + 'u_extrude_scale': Uniform1f; + 'u_intensity': Uniform1f; + 'u_matrix': UniformMatrix4f; +}; + +export type HeatmapTextureUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_world': Uniform2f; + 'u_image': Uniform1i; + 'u_color_ramp': Uniform1i; + 'u_opacity': Uniform1f; +}; + +const heatmapUniforms = (context: Context, locations: UniformLocations): HeatmapUniformsType => ({ + 'u_extrude_scale': new Uniform1f(context, locations.u_extrude_scale), + 'u_intensity': new Uniform1f(context, locations.u_intensity), + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix) +}); + +const heatmapTextureUniforms = (context: Context, locations: UniformLocations): HeatmapTextureUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_world': new Uniform2f(context, locations.u_world), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_color_ramp': new Uniform1i(context, locations.u_color_ramp), + 'u_opacity': new Uniform1f(context, locations.u_opacity) +}); + +const heatmapUniformValues = (matrix: mat4, tile: Tile, zoom: number, intensity: number): UniformValues => ({ + 'u_matrix': matrix, + 'u_extrude_scale': pixelsToTileUnits(tile, 1, zoom), + 'u_intensity': intensity +}); + +const heatmapTextureUniformValues = ( + painter: Painter, + layer: HeatmapStyleLayer, + textureUnit: number, + colorRampUnit: number +): UniformValues => { + const matrix = mat4.create(); + mat4.ortho(matrix, 0, painter.width, painter.height, 0, 0, 1); + + const gl = painter.context.gl; + + return { + 'u_matrix': matrix, + 'u_world': [gl.drawingBufferWidth, gl.drawingBufferHeight], + 'u_image': textureUnit, + 'u_color_ramp': colorRampUnit, + 'u_opacity': layer.paint.get('heatmap-opacity') + }; +}; + +export { + heatmapUniforms, + heatmapTextureUniforms, + heatmapUniformValues, + heatmapTextureUniformValues +}; diff --git a/web/libraries/maplibre-gl/src/render/program/hillshade_program.ts b/web/libraries/maplibre-gl/src/render/program/hillshade_program.ts new file mode 100644 index 00000000..f7f89aeb --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/hillshade_program.ts @@ -0,0 +1,116 @@ +import {mat4} from 'gl-matrix'; + +import { + Uniform1i, + Uniform1f, + Uniform2f, + UniformColor, + UniformMatrix4f, + Uniform4f +} from '../uniform_binding'; +import {EXTENT} from '../../data/extent'; +import {MercatorCoordinate} from '../../geo/mercator_coordinate'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Tile} from '../../source/tile'; +import type {Painter} from '../painter'; +import type {HillshadeStyleLayer} from '../../style/style_layer/hillshade_style_layer'; +import type {DEMData} from '../../data/dem_data'; +import type {OverscaledTileID} from '../../source/tile_id'; + +export type HillshadeUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_image': Uniform1i; + 'u_latrange': Uniform2f; + 'u_light': Uniform2f; + 'u_shadow': UniformColor; + 'u_highlight': UniformColor; + 'u_accent': UniformColor; +}; + +export type HillshadePrepareUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_image': Uniform1i; + 'u_dimension': Uniform2f; + 'u_zoom': Uniform1f; + 'u_unpack': Uniform4f; +}; + +const hillshadeUniforms = (context: Context, locations: UniformLocations): HillshadeUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_latrange': new Uniform2f(context, locations.u_latrange), + 'u_light': new Uniform2f(context, locations.u_light), + 'u_shadow': new UniformColor(context, locations.u_shadow), + 'u_highlight': new UniformColor(context, locations.u_highlight), + 'u_accent': new UniformColor(context, locations.u_accent) +}); + +const hillshadePrepareUniforms = (context: Context, locations: UniformLocations): HillshadePrepareUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_dimension': new Uniform2f(context, locations.u_dimension), + 'u_zoom': new Uniform1f(context, locations.u_zoom), + 'u_unpack': new Uniform4f(context, locations.u_unpack) +}); + +const hillshadeUniformValues = ( + painter: Painter, + tile: Tile, + layer: HillshadeStyleLayer, + coord: OverscaledTileID +): UniformValues => { + const shadow = layer.paint.get('hillshade-shadow-color'); + const highlight = layer.paint.get('hillshade-highlight-color'); + const accent = layer.paint.get('hillshade-accent-color'); + + let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180); + // modify azimuthal angle by map rotation if light is anchored at the viewport + if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') { + azimuthal -= painter.transform.angle; + } + const align = !painter.options.moving; + return { + 'u_matrix': coord ? coord.posMatrix : painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align), + 'u_image': 0, + 'u_latrange': getTileLatRange(painter, tile.tileID), + 'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal], + 'u_shadow': shadow, + 'u_highlight': highlight, + 'u_accent': accent + }; +}; + +const hillshadeUniformPrepareValues = (tileID: OverscaledTileID, dem: DEMData): UniformValues => { + + const stride = dem.stride; + const matrix = mat4.create(); + // Flip rendering at y axis. + mat4.ortho(matrix, 0, EXTENT, -EXTENT, 0, 0, 1); + mat4.translate(matrix, matrix, [0, -EXTENT, 0]); + + return { + 'u_matrix': matrix, + 'u_image': 1, + 'u_dimension': [stride, stride], + 'u_zoom': tileID.overscaledZ, + 'u_unpack': dem.getUnpackVector() + }; +}; + +function getTileLatRange(painter: Painter, tileID: OverscaledTileID) { + // for scaling the magnitude of a points slope by its latitude + const tilesAtZoom = Math.pow(2, tileID.canonical.z); + const y = tileID.canonical.y; + return [ + new MercatorCoordinate(0, y / tilesAtZoom).toLngLat().lat, + new MercatorCoordinate(0, (y + 1) / tilesAtZoom).toLngLat().lat]; +} + +export { + hillshadeUniforms, + hillshadePrepareUniforms, + hillshadeUniformValues, + hillshadeUniformPrepareValues +}; diff --git a/web/libraries/maplibre-gl/src/render/program/line_program.ts b/web/libraries/maplibre-gl/src/render/program/line_program.ts new file mode 100644 index 00000000..ac33493d --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/line_program.ts @@ -0,0 +1,207 @@ +import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding'; +import {pixelsToTileUnits} from '../../source/pixels_to_tile_units'; +import {extend} from '../../util/util'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {Transform} from '../../geo/transform'; +import type {Tile} from '../../source/tile'; +import type {CrossFaded} from '../../style/properties'; +import type {LineStyleLayer} from '../../style/style_layer/line_style_layer'; +import type {Painter} from '../painter'; +import type {CrossfadeParameters} from '../../style/evaluation_parameters'; +import {OverscaledTileID} from '../../source/tile_id'; + +export type LineUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_ratio': Uniform1f; + 'u_device_pixel_ratio': Uniform1f; + 'u_units_to_pixels': Uniform2f; +}; + +export type LineGradientUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_ratio': Uniform1f; + 'u_device_pixel_ratio': Uniform1f; + 'u_units_to_pixels': Uniform2f; + 'u_image': Uniform1i; + 'u_image_height': Uniform1f; +}; + +export type LinePatternUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_texsize': Uniform2f; + 'u_ratio': Uniform1f; + 'u_device_pixel_ratio': Uniform1f; + 'u_units_to_pixels': Uniform2f; + 'u_image': Uniform1i; + 'u_scale': Uniform3f; + 'u_fade': Uniform1f; +}; + +export type LineSDFUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_ratio': Uniform1f; + 'u_device_pixel_ratio': Uniform1f; + 'u_units_to_pixels': Uniform2f; + 'u_patternscale_a': Uniform2f; + 'u_patternscale_b': Uniform2f; + 'u_sdfgamma': Uniform1f; + 'u_image': Uniform1i; + 'u_tex_y_a': Uniform1f; + 'u_tex_y_b': Uniform1f; + 'u_mix': Uniform1f; +}; + +const lineUniforms = (context: Context, locations: UniformLocations): LineUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_ratio': new Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels) +}); + +const lineGradientUniforms = (context: Context, locations: UniformLocations): LineGradientUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_ratio': new Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_image_height': new Uniform1f(context, locations.u_image_height) +}); + +const linePatternUniforms = (context: Context, locations: UniformLocations): LinePatternUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_ratio': new Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels), + 'u_scale': new Uniform3f(context, locations.u_scale), + 'u_fade': new Uniform1f(context, locations.u_fade) +}); + +const lineSDFUniforms = (context: Context, locations: UniformLocations): LineSDFUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_ratio': new Uniform1f(context, locations.u_ratio), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels), + 'u_patternscale_a': new Uniform2f(context, locations.u_patternscale_a), + 'u_patternscale_b': new Uniform2f(context, locations.u_patternscale_b), + 'u_sdfgamma': new Uniform1f(context, locations.u_sdfgamma), + 'u_image': new Uniform1i(context, locations.u_image), + 'u_tex_y_a': new Uniform1f(context, locations.u_tex_y_a), + 'u_tex_y_b': new Uniform1f(context, locations.u_tex_y_b), + 'u_mix': new Uniform1f(context, locations.u_mix) +}); + +const lineUniformValues = ( + painter: Painter, + tile: Tile, + layer: LineStyleLayer, + coord: OverscaledTileID +): UniformValues => { + const transform = painter.transform; + + return { + 'u_matrix': calculateMatrix(painter, tile, layer, coord), + 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_units_to_pixels': [ + 1 / transform.pixelsToGLUnits[0], + 1 / transform.pixelsToGLUnits[1] + ] + }; +}; + +const lineGradientUniformValues = ( + painter: Painter, + tile: Tile, + layer: LineStyleLayer, + imageHeight: number, + coord: OverscaledTileID +): UniformValues => { + return extend(lineUniformValues(painter, tile, layer, coord), { + 'u_image': 0, + 'u_image_height': imageHeight, + }); +}; + +const linePatternUniformValues = ( + painter: Painter, + tile: Tile, + layer: LineStyleLayer, + crossfade: CrossfadeParameters, + coord: OverscaledTileID +): UniformValues => { + const transform = painter.transform; + const tileZoomRatio = calculateTileRatio(tile, transform); + return { + 'u_matrix': calculateMatrix(painter, tile, layer, coord), + 'u_texsize': tile.imageAtlasTexture.size, + // camera zoom ratio + 'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_image': 0, + 'u_scale': [tileZoomRatio, crossfade.fromScale, crossfade.toScale], + 'u_fade': crossfade.t, + 'u_units_to_pixels': [ + 1 / transform.pixelsToGLUnits[0], + 1 / transform.pixelsToGLUnits[1] + ] + }; +}; + +const lineSDFUniformValues = ( + painter: Painter, + tile: Tile, + layer: LineStyleLayer, + dasharray: CrossFaded>, + crossfade: CrossfadeParameters, + coord: OverscaledTileID +): UniformValues => { + const transform = painter.transform; + const lineAtlas = painter.lineAtlas; + const tileRatio = calculateTileRatio(tile, transform); + + const round = layer.layout.get('line-cap') === 'round'; + + const posA = lineAtlas.getDash(dasharray.from, round); + const posB = lineAtlas.getDash(dasharray.to, round); + + const widthA = posA.width * crossfade.fromScale; + const widthB = posB.width * crossfade.toScale; + + return extend(lineUniformValues(painter, tile, layer, coord), { + 'u_patternscale_a': [tileRatio / widthA, -posA.height / 2], + 'u_patternscale_b': [tileRatio / widthB, -posB.height / 2], + 'u_sdfgamma': lineAtlas.width / (Math.min(widthA, widthB) * 256 * painter.pixelRatio) / 2, + 'u_image': 0, + 'u_tex_y_a': posA.y, + 'u_tex_y_b': posB.y, + 'u_mix': crossfade.t + }); +}; + +function calculateTileRatio(tile: Tile, transform: Transform) { + return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom); +} + +function calculateMatrix(painter: Painter, tile: Tile, layer: LineStyleLayer, coord: OverscaledTileID) { + return painter.translatePosMatrix( + coord ? coord.posMatrix : tile.tileID.posMatrix, + tile, + layer.paint.get('line-translate'), + layer.paint.get('line-translate-anchor') + ); +} + +export { + lineUniforms, + lineGradientUniforms, + linePatternUniforms, + lineSDFUniforms, + lineUniformValues, + lineGradientUniformValues, + linePatternUniformValues, + lineSDFUniformValues +}; diff --git a/web/libraries/maplibre-gl/src/render/program/pattern.ts b/web/libraries/maplibre-gl/src/render/program/pattern.ts new file mode 100644 index 00000000..5dcb06c1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/pattern.ts @@ -0,0 +1,102 @@ +import { + Uniform1i, + Uniform1f, + Uniform2f, + Uniform3f +} from '../uniform_binding'; +import {pixelsToTileUnits} from '../../source/pixels_to_tile_units'; + +import type {Painter} from '../painter'; +import type {OverscaledTileID} from '../../source/tile_id'; +import type {CrossFaded} from '../../style/properties'; +import type {CrossfadeParameters} from '../../style/evaluation_parameters'; +import type {UniformValues} from '../uniform_binding'; +import type {Tile} from '../../source/tile'; +import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec'; + +type BackgroundPatternUniformsType = { + 'u_image': Uniform1i; + 'u_pattern_tl_a': Uniform2f; + 'u_pattern_br_a': Uniform2f; + 'u_pattern_tl_b': Uniform2f; + 'u_pattern_br_b': Uniform2f; + 'u_texsize': Uniform2f; + 'u_mix': Uniform1f; + 'u_pattern_size_a': Uniform2f; + 'u_pattern_size_b': Uniform2f; + 'u_scale_a': Uniform1f; + 'u_scale_b': Uniform1f; + 'u_pixel_coord_upper': Uniform2f; + 'u_pixel_coord_lower': Uniform2f; + 'u_tile_units_to_pixels': Uniform1f; +}; + +export type PatternUniformsType = { + // pattern uniforms: + 'u_image': Uniform1i; + 'u_texsize': Uniform2f; + 'u_scale': Uniform3f; + 'u_fade': Uniform1f; + 'u_pixel_coord_upper': Uniform2f; + 'u_pixel_coord_lower': Uniform2f; +}; + +function patternUniformValues(crossfade: CrossfadeParameters, painter: Painter, tile: Tile): UniformValues { + + const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom); + + const numTiles = Math.pow(2, tile.tileID.overscaledZ); + const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles; + + const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles); + const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y; + + return { + 'u_image': 0, + 'u_texsize': tile.imageAtlasTexture.size, + 'u_scale': [tileRatio, crossfade.fromScale, crossfade.toScale], + 'u_fade': crossfade.t, + // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision. + 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16], + 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF] + }; +} + +function bgPatternUniformValues( + image: CrossFaded, + crossfade: CrossfadeParameters, + painter: Painter, + tile: { + tileID: OverscaledTileID; + tileSize: number; + } +): UniformValues { + const imagePosA = painter.imageManager.getPattern(image.from.toString()); + const imagePosB = painter.imageManager.getPattern(image.to.toString()); + const {width, height} = painter.imageManager.getPixelSize(); + + const numTiles = Math.pow(2, tile.tileID.overscaledZ); + const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles; + + const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles); + const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y; + + return { + 'u_image': 0, + 'u_pattern_tl_a': (imagePosA as any).tl, + 'u_pattern_br_a': (imagePosA as any).br, + 'u_pattern_tl_b': (imagePosB as any).tl, + 'u_pattern_br_b': (imagePosB as any).br, + 'u_texsize': [width, height], + 'u_mix': crossfade.t, + 'u_pattern_size_a': (imagePosA as any).displaySize, + 'u_pattern_size_b': (imagePosB as any).displaySize, + 'u_scale_a': crossfade.fromScale, + 'u_scale_b': crossfade.toScale, + 'u_tile_units_to_pixels': 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom), + // split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision. + 'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16], + 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF] + }; +} +export {bgPatternUniformValues, patternUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/program/program_uniforms.ts b/web/libraries/maplibre-gl/src/render/program/program_uniforms.ts new file mode 100644 index 00000000..f1723cca --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/program_uniforms.ts @@ -0,0 +1,44 @@ +import {fillExtrusionUniforms, fillExtrusionPatternUniforms} from './fill_extrusion_program'; +import {fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms} from './fill_program'; +import {circleUniforms} from './circle_program'; +import {collisionUniforms, collisionCircleUniforms} from './collision_program'; +import {debugUniforms} from './debug_program'; +import {clippingMaskUniforms} from './clipping_mask_program'; +import {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program'; +import {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program'; +import {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program'; +import {rasterUniforms} from './raster_program'; +import {symbolIconUniforms, symbolSDFUniforms, symbolTextAndIconUniforms} from './symbol_program'; +import {backgroundUniforms, backgroundPatternUniforms} from './background_program'; +import {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms} from './terrain_program'; + +export const programUniforms = { + fillExtrusion: fillExtrusionUniforms, + fillExtrusionPattern: fillExtrusionPatternUniforms, + fill: fillUniforms, + fillPattern: fillPatternUniforms, + fillOutline: fillOutlineUniforms, + fillOutlinePattern: fillOutlinePatternUniforms, + circle: circleUniforms, + collisionBox: collisionUniforms, + collisionCircle: collisionCircleUniforms, + debug: debugUniforms, + clippingMask: clippingMaskUniforms, + heatmap: heatmapUniforms, + heatmapTexture: heatmapTextureUniforms, + hillshade: hillshadeUniforms, + hillshadePrepare: hillshadePrepareUniforms, + line: lineUniforms, + lineGradient: lineGradientUniforms, + linePattern: linePatternUniforms, + lineSDF: lineSDFUniforms, + raster: rasterUniforms, + symbolIcon: symbolIconUniforms, + symbolSDF: symbolSDFUniforms, + symbolTextAndIcon: symbolTextAndIconUniforms, + background: backgroundUniforms, + backgroundPattern: backgroundPatternUniforms, + terrain: terrainUniforms, + terrainDepth: terrainDepthUniforms, + terrainCoords: terrainCoordsUniforms +}; diff --git a/web/libraries/maplibre-gl/src/render/program/raster_program.ts b/web/libraries/maplibre-gl/src/render/program/raster_program.ts new file mode 100644 index 00000000..4ee6a431 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/raster_program.ts @@ -0,0 +1,88 @@ +import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding'; + +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import type {RasterStyleLayer} from '../../style/style_layer/raster_style_layer'; +import {mat4} from 'gl-matrix'; + +export type RasterUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_tl_parent': Uniform2f; + 'u_scale_parent': Uniform1f; + 'u_buffer_scale': Uniform1f; + 'u_fade_t': Uniform1f; + 'u_opacity': Uniform1f; + 'u_image0': Uniform1i; + 'u_image1': Uniform1i; + 'u_brightness_low': Uniform1f; + 'u_brightness_high': Uniform1f; + 'u_saturation_factor': Uniform1f; + 'u_contrast_factor': Uniform1f; + 'u_spin_weights': Uniform3f; +}; + +const rasterUniforms = (context: Context, locations: UniformLocations): RasterUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_tl_parent': new Uniform2f(context, locations.u_tl_parent), + 'u_scale_parent': new Uniform1f(context, locations.u_scale_parent), + 'u_buffer_scale': new Uniform1f(context, locations.u_buffer_scale), + 'u_fade_t': new Uniform1f(context, locations.u_fade_t), + 'u_opacity': new Uniform1f(context, locations.u_opacity), + 'u_image0': new Uniform1i(context, locations.u_image0), + 'u_image1': new Uniform1i(context, locations.u_image1), + 'u_brightness_low': new Uniform1f(context, locations.u_brightness_low), + 'u_brightness_high': new Uniform1f(context, locations.u_brightness_high), + 'u_saturation_factor': new Uniform1f(context, locations.u_saturation_factor), + 'u_contrast_factor': new Uniform1f(context, locations.u_contrast_factor), + 'u_spin_weights': new Uniform3f(context, locations.u_spin_weights) +}); + +const rasterUniformValues = ( + matrix: mat4, + parentTL: [number, number], + parentScaleBy: number, + fade: { + mix: number; + opacity: number; + }, + layer: RasterStyleLayer +): UniformValues => ({ + 'u_matrix': matrix, + 'u_tl_parent': parentTL, + 'u_scale_parent': parentScaleBy, + 'u_buffer_scale': 1, + 'u_fade_t': fade.mix, + 'u_opacity': fade.opacity * layer.paint.get('raster-opacity'), + 'u_image0': 0, + 'u_image1': 1, + 'u_brightness_low': layer.paint.get('raster-brightness-min'), + 'u_brightness_high': layer.paint.get('raster-brightness-max'), + 'u_saturation_factor': saturationFactor(layer.paint.get('raster-saturation')), + 'u_contrast_factor': contrastFactor(layer.paint.get('raster-contrast')), + 'u_spin_weights': spinWeights(layer.paint.get('raster-hue-rotate')) +}); + +function spinWeights(angle) { + angle *= Math.PI / 180; + const s = Math.sin(angle); + const c = Math.cos(angle); + return [ + (2 * c + 1) / 3, + (-Math.sqrt(3) * s - c + 1) / 3, + (Math.sqrt(3) * s - c + 1) / 3 + ]; +} + +function contrastFactor(contrast) { + return contrast > 0 ? + 1 / (1 - contrast) : + 1 + contrast; +} + +function saturationFactor(saturation) { + return saturation > 0 ? + 1 - 1 / (1.001 - saturation) : + -saturation; +} + +export {rasterUniforms, rasterUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/program/symbol_program.ts b/web/libraries/maplibre-gl/src/render/program/symbol_program.ts new file mode 100644 index 00000000..63508b94 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/symbol_program.ts @@ -0,0 +1,226 @@ +import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding'; +import {extend} from '../../util/util'; + +import type {Context} from '../../gl/context'; +import type {Painter} from '../painter'; +import type {UniformValues, UniformLocations} from '../uniform_binding'; +import {mat4} from 'gl-matrix'; + +export type SymbolIconUniformsType = { + 'u_is_size_zoom_constant': Uniform1i; + 'u_is_size_feature_constant': Uniform1i; + 'u_size_t': Uniform1f; + 'u_size': Uniform1f; + 'u_camera_to_center_distance': Uniform1f; + 'u_pitch': Uniform1f; + 'u_rotate_symbol': Uniform1i; + 'u_aspect_ratio': Uniform1f; + 'u_fade_change': Uniform1f; + 'u_matrix': UniformMatrix4f; + 'u_label_plane_matrix': UniformMatrix4f; + 'u_coord_matrix': UniformMatrix4f; + 'u_is_text': Uniform1i; + 'u_pitch_with_map': Uniform1i; + 'u_texsize': Uniform2f; + 'u_texture': Uniform1i; +}; + +export type SymbolSDFUniformsType = { + 'u_is_size_zoom_constant': Uniform1i; + 'u_is_size_feature_constant': Uniform1i; + 'u_size_t': Uniform1f; + 'u_size': Uniform1f; + 'u_camera_to_center_distance': Uniform1f; + 'u_pitch': Uniform1f; + 'u_rotate_symbol': Uniform1i; + 'u_aspect_ratio': Uniform1f; + 'u_fade_change': Uniform1f; + 'u_matrix': UniformMatrix4f; + 'u_label_plane_matrix': UniformMatrix4f; + 'u_coord_matrix': UniformMatrix4f; + 'u_is_text': Uniform1i; + 'u_pitch_with_map': Uniform1i; + 'u_texsize': Uniform2f; + 'u_texture': Uniform1i; + 'u_gamma_scale': Uniform1f; + 'u_device_pixel_ratio': Uniform1f; + 'u_is_halo': Uniform1i; +}; + +export type symbolTextAndIconUniformsType = { + 'u_is_size_zoom_constant': Uniform1i; + 'u_is_size_feature_constant': Uniform1i; + 'u_size_t': Uniform1f; + 'u_size': Uniform1f; + 'u_camera_to_center_distance': Uniform1f; + 'u_pitch': Uniform1f; + 'u_rotate_symbol': Uniform1i; + 'u_aspect_ratio': Uniform1f; + 'u_fade_change': Uniform1f; + 'u_matrix': UniformMatrix4f; + 'u_label_plane_matrix': UniformMatrix4f; + 'u_coord_matrix': UniformMatrix4f; + 'u_is_text': Uniform1i; + 'u_pitch_with_map': Uniform1i; + 'u_texsize': Uniform2f; + 'u_texsize_icon': Uniform2f; + 'u_texture': Uniform1i; + 'u_texture_icon': Uniform1i; + 'u_gamma_scale': Uniform1f; + 'u_device_pixel_ratio': Uniform1f; + 'u_is_halo': Uniform1i; +}; + +const symbolIconUniforms = (context: Context, locations: UniformLocations): SymbolIconUniformsType => ({ + 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant), + 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant), + 'u_size_t': new Uniform1f(context, locations.u_size_t), + 'u_size': new Uniform1f(context, locations.u_size), + 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pitch': new Uniform1f(context, locations.u_pitch), + 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol), + 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio), + 'u_fade_change': new Uniform1f(context, locations.u_fade_change), + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix), + 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix), + 'u_is_text': new Uniform1i(context, locations.u_is_text), + 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_texture': new Uniform1i(context, locations.u_texture) +}); + +const symbolSDFUniforms = (context: Context, locations: UniformLocations): SymbolSDFUniformsType => ({ + 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant), + 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant), + 'u_size_t': new Uniform1f(context, locations.u_size_t), + 'u_size': new Uniform1f(context, locations.u_size), + 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pitch': new Uniform1f(context, locations.u_pitch), + 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol), + 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio), + 'u_fade_change': new Uniform1f(context, locations.u_fade_change), + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix), + 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix), + 'u_is_text': new Uniform1i(context, locations.u_is_text), + 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_texture': new Uniform1i(context, locations.u_texture), + 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_is_halo': new Uniform1i(context, locations.u_is_halo) +}); + +const symbolTextAndIconUniforms = (context: Context, locations: UniformLocations): symbolTextAndIconUniformsType => ({ + 'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant), + 'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant), + 'u_size_t': new Uniform1f(context, locations.u_size_t), + 'u_size': new Uniform1f(context, locations.u_size), + 'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance), + 'u_pitch': new Uniform1f(context, locations.u_pitch), + 'u_rotate_symbol': new Uniform1i(context, locations.u_rotate_symbol), + 'u_aspect_ratio': new Uniform1f(context, locations.u_aspect_ratio), + 'u_fade_change': new Uniform1f(context, locations.u_fade_change), + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix), + 'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix), + 'u_is_text': new Uniform1i(context, locations.u_is_text), + 'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map), + 'u_texsize': new Uniform2f(context, locations.u_texsize), + 'u_texsize_icon': new Uniform2f(context, locations.u_texsize_icon), + 'u_texture': new Uniform1i(context, locations.u_texture), + 'u_texture_icon': new Uniform1i(context, locations.u_texture_icon), + 'u_gamma_scale': new Uniform1f(context, locations.u_gamma_scale), + 'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio), + 'u_is_halo': new Uniform1i(context, locations.u_is_halo) +}); + +const symbolIconUniformValues = ( + functionType: string, + size: { + uSizeT: number; + uSize: number; + }, + rotateInShader: boolean, + pitchWithMap: boolean, + painter: Painter, + matrix: mat4, + labelPlaneMatrix: mat4, + glCoordMatrix: mat4, + isText: boolean, + texSize: [number, number] +): UniformValues => { + const transform = painter.transform; + + return { + 'u_is_size_zoom_constant': +(functionType === 'constant' || functionType === 'source'), + 'u_is_size_feature_constant': +(functionType === 'constant' || functionType === 'camera'), + 'u_size_t': size ? size.uSizeT : 0, + 'u_size': size ? size.uSize : 0, + 'u_camera_to_center_distance': transform.cameraToCenterDistance, + 'u_pitch': transform.pitch / 360 * 2 * Math.PI, + 'u_rotate_symbol': +rotateInShader, + 'u_aspect_ratio': transform.width / transform.height, + 'u_fade_change': painter.options.fadeDuration ? painter.symbolFadeChange : 1, + 'u_matrix': matrix, + 'u_label_plane_matrix': labelPlaneMatrix, + 'u_coord_matrix': glCoordMatrix, + 'u_is_text': +isText, + 'u_pitch_with_map': +pitchWithMap, + 'u_texsize': texSize, + 'u_texture': 0 + }; +}; + +const symbolSDFUniformValues = ( + functionType: string, + size: { + uSizeT: number; + uSize: number; + }, + rotateInShader: boolean, + pitchWithMap: boolean, + painter: Painter, + matrix: mat4, + labelPlaneMatrix: mat4, + glCoordMatrix: mat4, + isText: boolean, + texSize: [number, number], + isHalo: boolean +): UniformValues => { + const transform = painter.transform; + + return extend(symbolIconUniformValues(functionType, size, + rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, + glCoordMatrix, isText, texSize), { + 'u_gamma_scale': (pitchWithMap ? Math.cos(transform._pitch) * transform.cameraToCenterDistance : 1), + 'u_device_pixel_ratio': painter.pixelRatio, + 'u_is_halo': +isHalo + }); +}; + +const symbolTextAndIconUniformValues = ( + functionType: string, + size: { + uSizeT: number; + uSize: number; + }, + rotateInShader: boolean, + pitchWithMap: boolean, + painter: Painter, + matrix: mat4, + labelPlaneMatrix: mat4, + glCoordMatrix: mat4, + texSizeSDF: [number, number], + texSizeIcon: [number, number] +): UniformValues => { + return extend(symbolSDFUniformValues(functionType, size, + rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix, + glCoordMatrix, true, texSizeSDF, true), { + 'u_texsize_icon': texSizeIcon, + 'u_texture_icon': 1 + }); +}; + +export {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues, symbolTextAndIconUniformValues, symbolTextAndIconUniforms}; diff --git a/web/libraries/maplibre-gl/src/render/program/terrain_program.ts b/web/libraries/maplibre-gl/src/render/program/terrain_program.ts new file mode 100644 index 00000000..a0c13ef4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/program/terrain_program.ts @@ -0,0 +1,93 @@ +import { + Uniform1i, + Uniform1f, + Uniform4f, + UniformMatrix4f +} from '../uniform_binding'; +import type {Context} from '../../gl/context'; +import type {UniformValues, UniformLocations} from '../../render/uniform_binding'; +import {mat4} from 'gl-matrix'; + +export type TerrainPreludeUniformsType = { + 'u_depth': Uniform1i; + 'u_terrain': Uniform1i; + 'u_terrain_dim': Uniform1f; + 'u_terrain_matrix': UniformMatrix4f; + 'u_terrain_unpack': Uniform4f; + 'u_terrain_exaggeration': Uniform1f; +}; + +export type TerrainUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_texture': Uniform1i; + 'u_ele_delta': Uniform1f; +}; + +export type TerrainDepthUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_ele_delta': Uniform1f; +}; + +export type TerrainCoordsUniformsType = { + 'u_matrix': UniformMatrix4f; + 'u_texture': Uniform1i; + 'u_terrain_coords_id': Uniform1f; + 'u_ele_delta': Uniform1f; +}; + +const terrainPreludeUniforms = (context: Context, locations: UniformLocations): TerrainPreludeUniformsType => ({ + 'u_depth': new Uniform1i(context, locations.u_depth), + 'u_terrain': new Uniform1i(context, locations.u_terrain), + 'u_terrain_dim': new Uniform1f(context, locations.u_terrain_dim), + 'u_terrain_matrix': new UniformMatrix4f(context, locations.u_terrain_matrix), + 'u_terrain_unpack': new Uniform4f(context, locations.u_terrain_unpack), + 'u_terrain_exaggeration': new Uniform1f(context, locations.u_terrain_exaggeration) +}); + +const terrainUniforms = (context: Context, locations: UniformLocations): TerrainUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_texture': new Uniform1i(context, locations.u_texture), + 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta) +}); + +const terrainDepthUniforms = (context: Context, locations: UniformLocations): TerrainDepthUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta) +}); + +const terrainCoordsUniforms = (context: Context, locations: UniformLocations): TerrainCoordsUniformsType => ({ + 'u_matrix': new UniformMatrix4f(context, locations.u_matrix), + 'u_texture': new Uniform1i(context, locations.u_texture), + 'u_terrain_coords_id': new Uniform1f(context, locations.u_terrain_coords_id), + 'u_ele_delta': new Uniform1f(context, locations.u_ele_delta) +}); + +const terrainUniformValues = ( + matrix: mat4, + eleDelta: number +): UniformValues => ({ + 'u_matrix': matrix, + 'u_texture': 0, + 'u_ele_delta': eleDelta +}); + +const terrainDepthUniformValues = ( + matrix: mat4, + eleDelta: number +): UniformValues => ({ + 'u_matrix': matrix, + 'u_ele_delta': eleDelta +}); + +const terrainCoordsUniformValues = ( + matrix: mat4, + coordsId: number, + eleDelta: number +): UniformValues => ({ + 'u_matrix': matrix, + 'u_terrain_coords_id': coordsId / 255, + 'u_texture': 0, + 'u_ele_delta': eleDelta +}); + +export {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms, terrainPreludeUniforms, terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues}; diff --git a/web/libraries/maplibre-gl/src/render/render_to_texture.test.ts b/web/libraries/maplibre-gl/src/render/render_to_texture.test.ts new file mode 100644 index 00000000..f53892bd --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/render_to_texture.test.ts @@ -0,0 +1,150 @@ +import {RenderToTexture} from './render_to_texture'; +import type {Painter} from './painter'; +import type {LineStyleLayer} from '../style/style_layer/line_style_layer'; +import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; +import {Context} from '../gl/context'; +import gl from 'gl'; +import {ColorMode} from '../gl/color_mode'; +import {Terrain} from './terrain'; +import {Style} from '../style/style'; +import {Tile} from '../source/tile'; +import {Map} from '../ui/map'; +import {OverscaledTileID} from '../source/tile_id'; +import {SourceCache} from '../source/source_cache'; +import {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {FillStyleLayer} from '../style/style_layer/fill_style_layer'; +import {RasterStyleLayer} from '../style/style_layer/raster_style_layer'; +import {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer'; +import {BackgroundStyleLayer} from '../style/style_layer/background_style_layer'; + +describe('render to texture', () => { + const backgroundLayer = { + id: 'maine-background', + type: 'background', + source: 'maine', + isHidden: () => false + } as any as BackgroundStyleLayer; + const fillLayer = { + id: 'maine-fill', + type: 'fill', + source: 'maine', + isHidden: () => false + } as any as FillStyleLayer; + const rasterLayer = { + id: 'maine-raster', + type: 'raster', + source: 'maine', + isHidden: () => false + } as any as RasterStyleLayer; + const hillshadeLayer = { + id: 'maine-hillshade', + type: 'line', + source: 'maine', + isHidden: () => false + } as any as HillshadeStyleLayer; + const lineLayer = { + id: 'maine-line', + type: 'line', + source: 'maine', + isHidden: () => false + } as any as LineStyleLayer; + const symbolLayer = { + id: 'maine-symbol', + type: 'symbol', + source: 'maine', + layout: { + 'text-field': 'maine', + 'symbol-placement': 'line' + }, + isHidden: () => false + } as any as SymbolStyleLayer; + + let layersDrawn = 0; + const painter = { + layersDrawn: 0, + context: new Context(gl(1, 1) as any), + transform: {zoom: 10, calculatePosMatrix: () => {}}, + colorModeForRenderPass: () => ColorMode.alphaBlended, + useProgram: () => { return {draw: () => { layersDrawn++; }}; }, + _renderTileClippingMasks: () => {}, + renderLayer: () => {} + } as any as Painter; + const map = {painter} as Map; + + const tile = new Tile(new OverscaledTileID(3, 0, 2, 1, 2), 512); + const sourceCache = { + _source: {minzoom: 0, maxzoom: 2}, + getTileByID: (_id) => tile, + getVisibleCoordinates: () => [tile.tileID] + } as SourceCache; + + const style = { + sourceCaches: {'maine': {getVisibleCoordinates: () => [tile.tileID]}}, + _order: ['maine-fill', 'maine-symbol'], + _layers: { + 'maine-background': backgroundLayer, + 'maine-fill': fillLayer, + 'maine-raster': rasterLayer, + 'maine-hillshade': hillshadeLayer, + 'maine-line': lineLayer, + 'maine-symbol': symbolLayer + } + } as any as Style; + painter.style = style; + map.style = style; + style.map = map; + + const terrain = new Terrain(painter, sourceCache, {} as any as TerrainSpecification); + terrain.sourceCache.getRenderableTiles = () => [tile]; + terrain.sourceCache.getTerrainCoords = () => { return {[tile.tileID.key]: tile.tileID}; }; + map.terrain = terrain; + + const rtt = new RenderToTexture(painter, terrain); + rtt.prepareForRender(style, 0); + painter.renderToTexture = rtt; + + test('check state', () => { + expect(rtt._renderableTiles.map(t => t.tileID.key)).toStrictEqual(['923']); + expect(rtt._coordsDescendingInv).toEqual({'maine': {'923': [{'canonical': {'key': '922', 'x': 1, 'y': 2, 'z': 2}, 'key': '923', 'overscaledZ': 3, 'wrap': 0}]}}); + expect(rtt._coordsDescendingInvStr).toStrictEqual({maine: {'923': '923'}}); + }); + + test('should render text after a line by not adding the text to the stack', () => { + style._order = ['maine-fill', 'maine-symbol']; + rtt.prepareForRender(style, 0); + layersDrawn = 0; + expect(rtt._renderableLayerIds).toStrictEqual(['maine-fill', 'maine-symbol']); + expect(rtt.renderLayer(fillLayer)).toBeTruthy(); + expect(rtt.renderLayer(symbolLayer)).toBeFalsy(); + expect(layersDrawn).toBe(1); + }); + + test('render symbol inbetween of rtt layers', () => { + style._order = ['maine-background', 'maine-fill', 'maine-raster', 'maine-hillshade', 'maine-symbol', 'maine-line', 'maine-symbol']; + rtt.prepareForRender(style, 0); + layersDrawn = 0; + expect(rtt._renderableLayerIds).toStrictEqual(['maine-background', 'maine-fill', 'maine-raster', 'maine-hillshade', 'maine-symbol', 'maine-line', 'maine-symbol']); + expect(rtt.renderLayer(backgroundLayer)).toBeTruthy(); + expect(rtt.renderLayer(fillLayer)).toBeTruthy(); + expect(rtt.renderLayer(rasterLayer)).toBeTruthy(); + expect(rtt.renderLayer(hillshadeLayer)).toBeTruthy(); + expect(rtt.renderLayer(symbolLayer)).toBeFalsy(); + expect(rtt.renderLayer(lineLayer)).toBeTruthy(); + expect(rtt.renderLayer(symbolLayer)).toBeFalsy(); + expect(layersDrawn).toBe(2); + }); + + test('render more symbols inbetween of rtt layers', () => { + style._order = ['maine-background', 'maine-symbol', 'maine-hillshade', 'maine-symbol', 'maine-line', 'maine-symbol']; + rtt.prepareForRender(style, 0); + layersDrawn = 0; + expect(rtt._renderableLayerIds).toStrictEqual(['maine-background', 'maine-symbol', 'maine-hillshade', 'maine-symbol', 'maine-line', 'maine-symbol']); + expect(rtt.renderLayer(backgroundLayer)).toBeTruthy(); + expect(rtt.renderLayer(symbolLayer)).toBeFalsy(); + expect(rtt.renderLayer(hillshadeLayer)).toBeTruthy(); + expect(rtt.renderLayer(symbolLayer)).toBeFalsy(); + expect(rtt.renderLayer(lineLayer)).toBeTruthy(); + expect(rtt.renderLayer(symbolLayer)).toBeFalsy(); + expect(layersDrawn).toBe(3); + }); +}); diff --git a/web/libraries/maplibre-gl/src/render/render_to_texture.ts b/web/libraries/maplibre-gl/src/render/render_to_texture.ts new file mode 100644 index 00000000..a21b2cf5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/render_to_texture.ts @@ -0,0 +1,197 @@ +import {Painter} from './painter'; +import {Tile} from '../source/tile'; +import {Color} from '@maplibre/maplibre-gl-style-spec'; +import {OverscaledTileID} from '../source/tile_id'; +import {drawTerrain} from './draw_terrain'; +import {Style} from '../style/style'; +import {Terrain} from './terrain'; +import {RenderPool} from '../gl/render_pool'; +import {Texture} from './texture'; +import type {StyleLayer} from '../style/style_layer'; + +/** + * lookup table which layers should rendered to texture + */ +const LAYERS: { [keyof in StyleLayer['type']]?: boolean } = { + background: true, + fill: true, + line: true, + raster: true, + hillshade: true +}; + +/** + * @internal + * A helper class to help define what should be rendered to texture and how + */ +export class RenderToTexture { + painter: Painter; + terrain: Terrain; + pool: RenderPool; + /** + * coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile + * e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile + */ + _coordsDescendingInv: {[_: string]: {[_:string]: Array}}; + /** + * create a string representation of all to tiles rendered to render-to-texture tiles + * this string representation is used to check if tile should be re-rendered. + */ + _coordsDescendingInvStr: {[_: string]: {[_:string]: string}}; + /** + * store for render-stacks + * a render stack is a set of layers which should be rendered into one texture + * every stylesheet can have multiple stacks. A new stack is created if layers which should + * not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols + */ + _stacks: Array>; + /** + * remember the previous processed layer to check if a new stack is needed + */ + _prevType: string; + /** + * a list of tiles that can potentially rendered + */ + _renderableTiles: Array; + /** + * a list of tiles that should be rendered to screen in the next render-call + */ + _rttTiles: Array; + /** + * a list of all layer-ids which should be rendered + */ + _renderableLayerIds: Array; + + constructor(painter: Painter, terrain: Terrain) { + this.painter = painter; + this.terrain = terrain; + this.pool = new RenderPool(painter.context, 30, terrain.sourceCache.tileSize * terrain.qualityFactor); + } + + destruct() { + this.pool.destruct(); + } + + getTexture(tile: Tile): Texture { + return this.pool.getObjectForId(tile.rtt[this._stacks.length - 1].id).texture; + } + + prepareForRender(style: Style, zoom: number) { + this._stacks = []; + this._prevType = null; + this._rttTiles = []; + this._renderableTiles = this.terrain.sourceCache.getRenderableTiles(); + this._renderableLayerIds = style._order.filter(id => !style._layers[id].isHidden(zoom)); + + this._coordsDescendingInv = {}; + for (const id in style.sourceCaches) { + this._coordsDescendingInv[id] = {}; + const tileIDs = style.sourceCaches[id].getVisibleCoordinates(); + for (const tileID of tileIDs) { + const keys = this.terrain.sourceCache.getTerrainCoords(tileID); + for (const key in keys) { + if (!this._coordsDescendingInv[id][key]) this._coordsDescendingInv[id][key] = []; + this._coordsDescendingInv[id][key].push(keys[key]); + } + } + } + + this._coordsDescendingInvStr = {}; + for (const id of style._order) { + const layer = style._layers[id], source = layer.source; + if (LAYERS[layer.type]) { + if (!this._coordsDescendingInvStr[source]) { + this._coordsDescendingInvStr[source] = {}; + for (const key in this._coordsDescendingInv[source]) + this._coordsDescendingInvStr[source][key] = this._coordsDescendingInv[source][key].map(c => c.key).sort().join(); + } + } + } + + // check tiles to render + for (const tile of this._renderableTiles) { + for (const source in this._coordsDescendingInvStr) { + // rerender if there are more coords to render than in the last rendering + const coords = this._coordsDescendingInvStr[source][tile.tileID.key]; + if (coords && coords !== tile.rttCoords[source]) tile.rtt = []; + } + } + } + + /** + * due that switching textures is relatively slow, the render + * layer-by-layer context is not practicable. To bypass this problem + * this lines of code stack all layers and later render all at once. + * Because of the stylesheet possibility to mixing render-to-texture layers + * and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example + * a symbol-layer is in between of fill-layers. + * @param layer - the layer to render + * @returns if true layer is rendered to texture, otherwise false + */ + renderLayer(layer: StyleLayer): boolean { + if (layer.isHidden(this.painter.transform.zoom)) return false; + + const type = layer.type; + const painter = this.painter; + const isLastLayer = this._renderableLayerIds[this._renderableLayerIds.length - 1] === layer.id; + + // remember background, fill, line & raster layer to render into a stack + if (LAYERS[type]) { + // create a new stack if previous layer was not rendered to texture (f.e. symbols) + if (!this._prevType || !LAYERS[this._prevType]) this._stacks.push([]); + // push current render-to-texture layer to render-stack + this._prevType = type; + this._stacks[this._stacks.length - 1].push(layer.id); + // rendering is done later, all in once + if (!isLastLayer) return true; + } + + // in case a stack is finished render all collected stack-layers into a texture + if (LAYERS[this._prevType] || (LAYERS[type] && isLastLayer)) { + this._prevType = type; + const stack = this._stacks.length - 1, layers = this._stacks[stack] || []; + for (const tile of this._renderableTiles) { + // if render pool is full draw current tiles to screen and free pool + if (this.pool.isFull()) { + drawTerrain(this.painter, this.terrain, this._rttTiles); + this._rttTiles = []; + this.pool.freeAllObjects(); + } + this._rttTiles.push(tile); + // check for cached PoolObject + if (tile.rtt[stack]) { + const obj = this.pool.getObjectForId(tile.rtt[stack].id); + if (obj.stamp === tile.rtt[stack].stamp) { + this.pool.useObject(obj); + continue; + } + } + // get free PoolObject + const obj = this.pool.getOrCreateFreeObject(); + this.pool.useObject(obj); + this.pool.stampObject(obj); + tile.rtt[stack] = {id: obj.id, stamp: obj.stamp}; + // prepare PoolObject for rendering + painter.context.bindFramebuffer.set(obj.fbo.framebuffer); + painter.context.clear({color: Color.transparent, stencil: 0}); + painter.currentStencilSource = undefined; + for (let l = 0; l < layers.length; l++) { + const layer = painter.style._layers[layers[l]]; + const coords = layer.source ? this._coordsDescendingInv[layer.source][tile.tileID.key] : [tile.tileID]; + painter.context.viewport.set([0, 0, obj.fbo.width, obj.fbo.height]); + painter._renderTileClippingMasks(layer, coords); + painter.renderLayer(painter, painter.style.sourceCaches[layer.source], layer, coords); + if (layer.source) tile.rttCoords[layer.source] = this._coordsDescendingInvStr[layer.source][tile.tileID.key]; + } + } + drawTerrain(this.painter, this.terrain, this._rttTiles); + this._rttTiles = []; + this.pool.freeAllObjects(); + + return LAYERS[type]; + } + + return false; + } + +} diff --git a/web/libraries/maplibre-gl/src/render/terrain.test.ts b/web/libraries/maplibre-gl/src/render/terrain.test.ts new file mode 100644 index 00000000..39b384a9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/terrain.test.ts @@ -0,0 +1,268 @@ +import Point from '@mapbox/point-geometry'; +import {Terrain} from './terrain'; +import gl from 'gl'; +import {Context} from '../gl/context'; +import {RGBAImage} from '../util/image'; +import {Texture} from './texture'; +import type {SourceCache} from '../source/source_cache'; +import {OverscaledTileID} from '../source/tile_id'; +import type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {DEMData} from '../data/dem_data'; +import {Tile} from '../source/tile'; +import {Painter} from './painter'; +import {mat4} from 'gl-matrix'; +import {LngLat} from '../geo/lng_lat'; + +describe('Terrain', () => { + test('pointCoordiate should not return null', () => { + expect.assertions(1); + const painter = { + context: new Context(gl(1, 1) as any), + width: 1, + height: 1, + transform: {center: {lng: 0}} + } as any as Painter; + const sourceCache = {} as SourceCache; + const getTileByID = (tileID) : Tile => { + if (tileID !== 'abcd') { + return null as any as Tile; + } + return { + tileID: { + canonical: { + x: 0, + y: 0, + z: 0 + } + } + } as any as Tile; + }; + const terrain = new Terrain(painter, sourceCache, {} as any as TerrainSpecification); + terrain.sourceCache.getTileByID = getTileByID; + const context = painter.context as Context; + const pixels = new Uint8Array([0, 0, 255, 255]); + const image = new RGBAImage({width: 1, height: 1}, pixels); + const imageTexture = new Texture(context, image, context.gl.RGBA); + terrain.getFramebuffer('coords'); // allow init of frame buffers + terrain._fboCoordsTexture.texture = imageTexture.texture; + terrain.coordsIndex.push('abcd'); + + const coordinate = terrain.pointCoordinate(new Point(0, 0)); + + expect(coordinate).not.toBeNull(); + }); + + const setupMercatorOverflow = (centerLng: number) => { + const WORLD_WIDTH = 4; + const painter = { + context: new Context(gl(WORLD_WIDTH, 1) as any), + width: WORLD_WIDTH, + height: 1, + transform: {center: {lng: centerLng}} + } as any as Painter; + const sourceCache = {} as SourceCache; + const terrain = new Terrain(painter, sourceCache, {} as any as TerrainSpecification); + const mockTile = {tileID: {canonical: {x: 0, y: 0, z: 0}}}; + terrain.sourceCache.getTileByID = () => mockTile as any as Tile; + terrain.getElevation = () => 0; + terrain.coordsIndex = ['abcd']; + terrain._coordsTextureSize = WORLD_WIDTH; + const pixels = new Uint8Array([2, 0, 0, 255, 3, 0, 0, 255, 0, 0, 0, 255, 1, 0, 0, 255]); + const image = new RGBAImage({width: WORLD_WIDTH, height: 1}, pixels); + const imageTexture = new Texture(painter.context, image, painter.context.gl.RGBA); + terrain.getFramebuffer('coords'); // allow init of frame buffers + terrain._fboCoordsTexture.texture = imageTexture.texture; + return terrain; + }; + + test( + `pointCoordiate should return negative mercator x + if center.lng is to the right of 180 meridian + and a given point is to the left of 180`, + () => { + expect.assertions(2); + const centerLng = -170; + const pointX = 1; // x in the left half of the 4-px world + const terrain = setupMercatorOverflow(centerLng); + const coordinate = terrain.pointCoordinate(new Point(pointX, 0)); + + expect(coordinate.x).toBeLessThan(0); + expect(coordinate.x).toBeGreaterThan(-1); + }); + + test( + `pointCoordiate should return mercator x greater than 1 + if center.lng is to the left of 180 meridian + and a given point is to the right of 180`, + () => { + expect.assertions(2); + const centerLng = 170; + const pointX = 3; // x in the right half of the 4-px world + const terrain = setupMercatorOverflow(centerLng); + const coordinate = terrain.pointCoordinate(new Point(pointX, 0)); + + expect(coordinate.x).toBeGreaterThan(1); + expect(coordinate.x).toBeLessThan(2); + }); + + test('Calculate tile minimum and maximum elevation', () => { + const tileID = new OverscaledTileID(5, 0, 5, 17, 11); + const tile = new Tile(tileID, 256); + tile.dem = { + min: 0, + max: 100, + getPixels: () => new RGBAImage({width: 1, height: 1}, new Uint8Array(1 * 4)), + getUnpackVector: () => [6553.6, 25.6, 0.1, 10000.0], + } as any as DEMData; + const painter = { + context: new Context(gl(1, 1) as any), + width: 1, + height: 1, + getTileTexture: () => null + } as any as Painter; + const sourceCache = { + _source: {maxzoom: 12}, + _cache: {max: 10}, + getTileByID: () => { + return tile; + }, + } as any as SourceCache; + const terrain = new Terrain( + painter, + sourceCache, + {exaggeration: 2} as any as TerrainSpecification, + ); + + terrain.sourceCache._tiles[tileID.key] = tile; + const {minElevation, maxElevation} = terrain.getMinMaxElevation(tileID); + + expect(minElevation).toBe(0); + expect(maxElevation).toBe(200); + }); + + test('Return null elevation values when no tile', () => { + const tileID = new OverscaledTileID(5, 0, 5, 17, 11); + const painter = { + context: new Context(gl(1, 1) as any), + width: 1, + height: 1, + getTileTexture: () => null + } as any as Painter; + const sourceCache = { + _source: {maxzoom: 12}, + _cache: {max: 10}, + getTileByID: () => null, + } as any as SourceCache; + const terrain = new Terrain( + painter, + sourceCache, + {exaggeration: 2} as any as TerrainSpecification, + ); + + const minMaxNoTile = terrain.getMinMaxElevation(tileID); + + expect(minMaxNoTile.minElevation).toBeNull(); + expect(minMaxNoTile.maxElevation).toBeNull(); + }); + + test('Return null elevation values when no DEM', () => { + const tileID = new OverscaledTileID(5, 0, 5, 17, 11); + const tile = new Tile(tileID, 256); + tile.dem = null as any as DEMData; + const painter = { + context: new Context(gl(1, 1) as any), + width: 1, + height: 1, + getTileTexture: () => null + } as any as Painter; + const sourceCache = { + _source: {maxzoom: 12}, + _cache: {max: 10}, + getTileByID: () => { + return tile; + }, + } as any as SourceCache; + const terrain = new Terrain( + painter, + sourceCache, + {exaggeration: 2} as any as TerrainSpecification, + ); + const minMaxNoDEM = terrain.getMinMaxElevation(tileID); + + expect(minMaxNoDEM.minElevation).toBeNull(); + expect(minMaxNoDEM.maxElevation).toBeNull(); + }); + + test('create mesh with border', () => { + let actualIndexArray; + let actualVertexArray; + const painter = { + context: { + createIndexBuffer: array => { actualIndexArray = Array.from(array.uint16); }, + createVertexBuffer: array => { actualVertexArray = Array.from(array.int16); } + }, + width: 1, + height: 1, + } as any as Painter; + const sourceCache = { + _source: {maxzoom: 12}, + _cache: {max: 10} + } as any as SourceCache; + const terrain = new Terrain( + painter, + sourceCache, + {exaggeration: 1} as any as TerrainSpecification, + ); + terrain.meshSize = 4; + terrain.getTerrainMesh(); + expect(terrain.getMeshFrameDelta(16)).toBe(122.16256373312942); + expect(actualIndexArray).toStrictEqual([0, 5, 6, 0, 6, 1, 1, 6, 7, 1, 7, 2, 2, 7, 8, 2, 8, 3, 3, 8, 9, 3, 9, 4, 5, 10, 11, 5, 11, 6, 6, 11, 12, 6, 12, 7, 7, 12, 13, 7, 13, 8, 8, 13, 14, 8, 14, 9, 10, 15, 16, 10, 16, 11, 11, 16, 17, 11, 17, 12, 12, 17, 18, 12, 18, 13, 13, 18, 19, 13, 19, 14, 15, 20, 21, 15, 21, 16, 16, 21, 22, 16, 22, 17, 17, 22, 23, 17, 23, 18, 18, 23, 24, 18, 24, 19, 35, 36, 38, 35, 38, 37, 25, 28, 26, 25, 27, 28, 37, 38, 40, 37, 40, 39, 27, 30, 28, 27, 29, 30, 39, 40, 42, 39, 42, 41, 29, 32, 30, 29, 31, 32, 41, 42, 44, 41, 44, 43, 31, 34, 32, 31, 33, 34, 45, 46, 48, 45, 48, 47, 55, 58, 56, 55, 57, 58, 47, 48, 50, 47, 50, 49, 57, 60, 58, 57, 59, 60, 49, 50, 52, 49, 52, 51, 59, 62, 60, 59, 61, 62, 51, 52, 54, 51, 54, 53, 61, 64, 62, 61, 63, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + expect(actualVertexArray).toStrictEqual([0, 0, 0, 2048, 0, 0, 4096, 0, 0, 6144, 0, 0, 8192, 0, 0, 0, 2048, 0, 2048, 2048, 0, 4096, 2048, 0, 6144, 2048, 0, 8192, 2048, 0, 0, 4096, 0, 2048, 4096, 0, 4096, 4096, 0, 6144, 4096, 0, 8192, 4096, 0, 0, 6144, 0, 2048, 6144, 0, 4096, 6144, 0, 6144, 6144, 0, 8192, 6144, 0, 0, 8192, 0, 2048, 8192, 0, 4096, 8192, 0, 6144, 8192, 0, 8192, 8192, 0, 0, 0, 0, 0, 0, 1, 2048, 0, 0, 2048, 0, 1, 4096, 0, 0, 4096, 0, 1, 6144, 0, 0, 6144, 0, 1, 8192, 0, 0, 8192, 0, 1, 0, 8192, 0, 0, 8192, 1, 2048, 8192, 0, 2048, 8192, 1, 4096, 8192, 0, 4096, 8192, 1, 6144, 8192, 0, 6144, 8192, 1, 8192, 8192, 0, 8192, 8192, 1, 0, 0, 0, 0, 0, 1, 0, 2048, 0, 0, 2048, 1, 0, 4096, 0, 0, 4096, 1, 0, 6144, 0, 0, 6144, 1, 0, 8192, 0, 0, 8192, 1, 8192, 0, 0, 8192, 0, 1, 8192, 2048, 0, 8192, 2048, 1, 8192, 4096, 0, 8192, 4096, 1, 8192, 6144, 0, 8192, 6144, 1, 8192, 8192, 0, 8192, 8192, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + }); + + test('interpolation works', () => { + const mockTerrain = { + getDEMElevation: Terrain.prototype.getDEMElevation, + getTerrainData() { + return { + // eslint-disable-next-line camelcase + u_terrain_matrix: mat4.create(), + tile: { + dem: { + dim: 1, + get(x:number, y:number) { + expect(x % 1).toBe(0); + expect(y % 1).toBe(0); + return 100 * x + 10 * y; + } + } + } + }; + } + }; + expect(mockTerrain.getDEMElevation(null, 0, 0)).toBeCloseTo(0); + expect(mockTerrain.getDEMElevation(null, 1, 1)).toBeCloseTo(110); + expect(mockTerrain.getDEMElevation(null, 0, 0.5)).toBeCloseTo(5); + expect(mockTerrain.getDEMElevation(null, 1, 0.5)).toBeCloseTo(105); + expect(mockTerrain.getDEMElevation(null, 0.5, 0)).toBeCloseTo(50); + expect(mockTerrain.getDEMElevation(null, 0.5, 1)).toBeCloseTo(60); + expect(mockTerrain.getDEMElevation(null, 0.4, 0.2)).toBeCloseTo(42); + }); + + test('getElevationForLngLatZoom with lng less than -180 wraps correctly', () => { + const terrain = new Terrain(null, {} as any, {} as any); + + const OVERSCALETILEID_DOES_NOT_THROW = 4; + terrain.getElevation = () => OVERSCALETILEID_DOES_NOT_THROW; + expect(terrain.getElevationForLngLatZoom(new LngLat(-183, 40), 0)).toBe(OVERSCALETILEID_DOES_NOT_THROW); + }); + + test('getMinTileElevationForLngLatZoom with lng less than -180 wraps correctly', () => { + const terrain = new Terrain(null, {} as any, {} as any); + + const OVERSCALETILEID_DOES_NOT_THROW = 4; + terrain.getMinMaxElevation = () => ({minElevation: OVERSCALETILEID_DOES_NOT_THROW, maxElevation: 42}); + expect(terrain.getMinTileElevationForLngLatZoom(new LngLat(-183, 40), 0)).toBe(OVERSCALETILEID_DOES_NOT_THROW); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/render/terrain.ts b/web/libraries/maplibre-gl/src/render/terrain.ts new file mode 100644 index 00000000..47afdd0c --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/terrain.ts @@ -0,0 +1,459 @@ + +import {Tile} from '../source/tile'; +import {mat4, vec2} from 'gl-matrix'; +import {OverscaledTileID} from '../source/tile_id'; +import {RGBAImage} from '../util/image'; +import {warnOnce} from '../util/util'; +import {Pos3dArray, TriangleIndexArray} from '../data/array_types.g'; +import pos3dAttributes from '../data/pos3d_attributes'; +import {SegmentVector} from '../data/segment'; +import {VertexBuffer} from '../gl/vertex_buffer'; +import {IndexBuffer} from '../gl/index_buffer'; +import {Painter} from './painter'; +import {Texture} from '../render/texture'; +import type {Framebuffer} from '../gl/framebuffer'; +import Point from '@mapbox/point-geometry'; +import {MercatorCoordinate, lngFromMercatorX, mercatorXfromLng} from '../geo/mercator_coordinate'; +import {TerrainSourceCache} from '../source/terrain_source_cache'; +import {SourceCache} from '../source/source_cache'; +import {EXTENT} from '../data/extent'; +import type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {LngLat, earthRadius} from '../geo/lng_lat'; + +/** + * @internal + * A terrain GPU related object + */ +export type TerrainData = { + 'u_depth': number; + 'u_terrain': number; + 'u_terrain_dim': number; + 'u_terrain_matrix': mat4; + 'u_terrain_unpack': number[]; + 'u_terrain_exaggeration': number; + texture: WebGLTexture; + depthTexture: WebGLTexture; + tile: Tile; +} + +/** + * @internal + * A terrain mesh object + */ +export type TerrainMesh = { + indexBuffer: IndexBuffer; + vertexBuffer: VertexBuffer; + segments: SegmentVector; +} + +/** + * @internal + * This is the main class which handles most of the 3D Terrain logic. It has the following topics: + * 1) loads raster-dem tiles via the internal sourceCache this.sourceCache + * 2) creates a depth-framebuffer, which is used to calculate the visibility of coordinates + * 3) creates a coords-framebuffer, which is used the get to tile-coordinate for a screen-pixel + * 4) stores all render-to-texture tiles in the this.sourceCache._tiles + * 5) calculates the elevation for a specific tile-coordinate + * 6) creates a terrain-mesh + * + * A note about the GPU resource-usage: + * Framebuffers: + * - one for the depth & coords framebuffer with the size of the map-div. + * - one for rendering a tile to texture with the size of tileSize (= 512x512). + * Textures: + * - one texture for an empty raster-dem tile with size 1x1 + * - one texture for an empty depth-buffer, when terrain is disabled with size 1x1 + * - one texture for an each loaded raster-dem with size of the source.tileSize + * - one texture for the coords-framebuffer with the size of the map-div. + * - one texture for the depth-framebuffer with the size of the map-div. + * - one texture for the encoded tile-coords with the size 2*tileSize (=1024x1024) + * - finally for each render-to-texture tile (= this._tiles) a set of textures + * for each render stack (The stack-concept is documented in painter.ts). + * Normally there exists 1-3 Textures per tile, depending on the stylesheet. + * Each Textures has the size 2*tileSize (= 1024x1024). Also there exists a + * cache of the last 150 newest rendered tiles. + * + */ +export class Terrain { + /** + * The style this terrain crresponds to + */ + painter: Painter; + /** + * the sourcecache this terrain is based on + */ + sourceCache: TerrainSourceCache; + /** + * the TerrainSpecification object passed to this instance + */ + options: TerrainSpecification; + /** + * define the meshSize per tile. + */ + meshSize: number; + /** + * multiplicator for the elevation. Used to make terrain more "extreme". + */ + exaggeration: number; + /** + * to not see pixels in the render-to-texture tiles it is good to render them bigger + * this number is the multiplicator (must be a power of 2) for the current tileSize. + * So to get good results with not too much memory footprint a value of 2 should be fine. + */ + qualityFactor: number; + /** + * holds the framebuffer object in size of the screen to render the coords & depth into a texture. + */ + _fbo: Framebuffer; + _fboCoordsTexture: Texture; + _fboDepthTexture: Texture; + _emptyDepthTexture: Texture; + /** + * GL Objects for the terrain-mesh + * The mesh is a regular mesh, which has the advantage that it can be reused for all tiles. + */ + _mesh: TerrainMesh; + /** + * coords index contains a list of tileID.keys. This index is used to identify + * the tile via the alpha-cannel in the coords-texture. + * As the alpha-channel has 1 Byte a max of 255 tiles can rendered without an error. + */ + coordsIndex: Array; + /** + * tile-coords encoded in the rgb channel, _coordsIndex is in the alpha-channel. + */ + _coordsTexture: Texture; + /** + * accuracy of the coords. 2 * tileSize should be enoughth. + */ + _coordsTextureSize: number; + /** + * variables for an empty dem texture, which is used while the raster-dem tile is loading. + */ + _emptyDemUnpack: number[]; + _emptyDemTexture: Texture; + _emptyDemMatrix: mat4; + /** + * as of overzooming of raster-dem tiles in high zoomlevels, this cache contains + * matrices to transform from vector-tile coords to raster-dem-tile coords. + */ + _demMatrixCache: {[_: string]: { matrix: mat4; coord: OverscaledTileID }}; + + constructor(painter: Painter, sourceCache: SourceCache, options: TerrainSpecification) { + this.painter = painter; + this.sourceCache = new TerrainSourceCache(sourceCache); + this.options = options; + this.exaggeration = typeof options.exaggeration === 'number' ? options.exaggeration : 1.0; + this.qualityFactor = 2; + this.meshSize = 128; + this._demMatrixCache = {}; + this.coordsIndex = []; + this._coordsTextureSize = 1024; + } + + /** + * get the elevation-value from original dem-data for a given tile-coordinate + * @param tileID - the tile to get elevation for + * @param x - between 0 .. EXTENT + * @param y - between 0 .. EXTENT + * @param extent - optional, default 8192 + * @returns the elevation + */ + getDEMElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number { + if (!(x >= 0 && x < extent && y >= 0 && y < extent)) return 0; + const terrain = this.getTerrainData(tileID); + const dem = terrain.tile?.dem; + if (!dem) + return 0; + + const pos = vec2.transformMat4([] as any, [x / extent * EXTENT, y / extent * EXTENT], terrain.u_terrain_matrix); + const coord = [pos[0] * dem.dim, pos[1] * dem.dim]; + + // bilinear interpolation + const cx = Math.floor(coord[0]), + cy = Math.floor(coord[1]), + tx = coord[0] - cx, + ty = coord[1] - cy; + return ( + dem.get(cx, cy) * (1 - tx) * (1 - ty) + + dem.get(cx + 1, cy) * (tx) * (1 - ty) + + dem.get(cx, cy + 1) * (1 - tx) * (ty) + + dem.get(cx + 1, cy + 1) * (tx) * (ty) + ); + } + + /** + * Get the elevation for given {@link LngLat} in respect of exaggeration. + * @param lnglat - the location + * @param zoom - the zoom + * @returns the elevation + */ + getElevationForLngLatZoom(lnglat: LngLat, zoom: number) { + const {tileID, mercatorX, mercatorY} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom); + return this.getElevation(tileID, mercatorX % EXTENT, mercatorY % EXTENT, EXTENT); + } + + /** + * Get the elevation for given coordinate in respect of exaggeration. + * @param tileID - the tile id + * @param x - between 0 .. EXTENT + * @param y - between 0 .. EXTENT + * @param extent - optional, default 8192 + * @returns the elevation + */ + getElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number { + return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration; + } + + /** + * returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object + * @param tileID - the tile to get the terrain for + * @returns the terrain data to use in the program + */ + getTerrainData(tileID: OverscaledTileID): TerrainData { + // create empty DEM Objects, which will used while raster-dem tiles are loading. + // creates an empty depth-buffer texture which is needed, during the initialization process of the 3d mesh.. + if (!this._emptyDemTexture) { + const context = this.painter.context; + const image = new RGBAImage({width: 1, height: 1}, new Uint8Array(1 * 4)); + this._emptyDepthTexture = new Texture(context, image, context.gl.RGBA, {premultiply: false}); + this._emptyDemUnpack = [0, 0, 0, 0]; + this._emptyDemTexture = new Texture(context, new RGBAImage({width: 1, height: 1}), context.gl.RGBA, {premultiply: false}); + this._emptyDemTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE); + this._emptyDemMatrix = mat4.identity([] as any); + } + // find covering dem tile and prepare demTexture + const sourceTile = this.sourceCache.getSourceTile(tileID, true); + if (sourceTile && sourceTile.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) { + const context = this.painter.context; + sourceTile.demTexture = this.painter.getTileTexture(sourceTile.dem.stride); + if (sourceTile.demTexture) sourceTile.demTexture.update(sourceTile.dem.getPixels(), {premultiply: false}); + else sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, {premultiply: false}); + sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE); + sourceTile.needsTerrainPrepare = false; + } + // create matrix for lookup in dem data + const matrixKey = sourceTile && (sourceTile + sourceTile.tileID.key) + tileID.key; + if (matrixKey && !this._demMatrixCache[matrixKey]) { + const maxzoom = this.sourceCache.sourceCache._source.maxzoom; + let dz = tileID.canonical.z - sourceTile.tileID.canonical.z; + if (tileID.overscaledZ > tileID.canonical.z) { + if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom; + else warnOnce('cannot calculate elevation if elevation maxzoom > source.maxzoom'); + } + const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz); + const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz); + const demMatrix = mat4.fromScaling(new Float64Array(16) as any, [1 / (EXTENT << dz), 1 / (EXTENT << dz), 0]); + mat4.translate(demMatrix, demMatrix, [dx * EXTENT, dy * EXTENT, 0]); + this._demMatrixCache[tileID.key] = {matrix: demMatrix, coord: tileID}; + } + // return uniform values & textures + return { + 'u_depth': 2, + 'u_terrain': 3, + 'u_terrain_dim': sourceTile && sourceTile.dem && sourceTile.dem.dim || 1, + 'u_terrain_matrix': matrixKey ? this._demMatrixCache[tileID.key].matrix : this._emptyDemMatrix, + 'u_terrain_unpack': sourceTile && sourceTile.dem && sourceTile.dem.getUnpackVector() || this._emptyDemUnpack, + 'u_terrain_exaggeration': this.exaggeration, + texture: (sourceTile && sourceTile.demTexture || this._emptyDemTexture).texture, + depthTexture: (this._fboDepthTexture || this._emptyDepthTexture).texture, + tile: sourceTile + }; + } + + /** + * get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture + * @param texture - the texture + * @returns the frame buffer + */ + getFramebuffer(texture: string): Framebuffer { + const painter = this.painter; + const width = painter.width / devicePixelRatio; + const height = painter.height / devicePixelRatio; + if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) { + this._fbo.destroy(); + this._fboCoordsTexture.destroy(); + this._fboDepthTexture.destroy(); + delete this._fbo; + delete this._fboDepthTexture; + delete this._fboCoordsTexture; + } + if (!this._fboCoordsTexture) { + this._fboCoordsTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false}); + this._fboCoordsTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE); + } + if (!this._fboDepthTexture) { + this._fboDepthTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false}); + this._fboDepthTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE); + } + if (!this._fbo) { + this._fbo = painter.context.createFramebuffer(width, height, true, false); + this._fbo.depthAttachment.set(painter.context.createRenderbuffer(painter.context.gl.DEPTH_COMPONENT16, width, height)); + } + this._fbo.colorAttachment.set(texture === 'coords' ? this._fboCoordsTexture.texture : this._fboDepthTexture.texture); + return this._fbo; + } + + /** + * create coords texture, needed to grab coordinates from canvas + * encode coords coordinate into 4 bytes: + * - 8 lower bits for x + * - 8 lower bits for y + * - 4 higher bits for x + * - 4 higher bits for y + * - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value + * @returns the texture + */ + getCoordsTexture(): Texture { + const context = this.painter.context; + if (this._coordsTexture) return this._coordsTexture; + const data = new Uint8Array(this._coordsTextureSize * this._coordsTextureSize * 4); + for (let y = 0, i = 0; y < this._coordsTextureSize; y++) for (let x = 0; x < this._coordsTextureSize; x++, i += 4) { + data[i + 0] = x & 255; + data[i + 1] = y & 255; + data[i + 2] = ((x >> 8) << 4) | (y >> 8); + data[i + 3] = 0; + } + const image = new RGBAImage({width: this._coordsTextureSize, height: this._coordsTextureSize}, new Uint8Array(data.buffer)); + const texture = new Texture(context, image, context.gl.RGBA, {premultiply: false}); + texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE); + this._coordsTexture = texture; + return texture; + } + + /** + * Reads a pixel from the coords-framebuffer and translate this to mercator. + * @param p - Screen-Coordinate + * @returns mercator coordinate for a screen pixel + */ + pointCoordinate(p: Point): MercatorCoordinate { + const rgba = new Uint8Array(4); + const context = this.painter.context, gl = context.gl; + // grab coordinate pixel from coordinates framebuffer + context.bindFramebuffer.set(this.getFramebuffer('coords').framebuffer); + gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba); + context.bindFramebuffer.set(null); + // decode coordinates (encoding see getCoordsTexture) + const x = rgba[0] + ((rgba[2] >> 4) << 8); + const y = rgba[1] + ((rgba[2] & 15) << 8); + const tileID = this.coordsIndex[255 - rgba[3]]; + const tile = tileID && this.sourceCache.getTileByID(tileID); + if (!tile) return null; + const coordsSize = this._coordsTextureSize; + const worldSize = (1 << tile.tileID.canonical.z) * coordsSize; + const mercatorX = (tile.tileID.canonical.x * coordsSize + x) / worldSize; + return new MercatorCoordinate( + this._allowMercatorOverflow(p, mercatorX), + (tile.tileID.canonical.y * coordsSize + y) / worldSize, + this.getElevation(tile.tileID, x, y, coordsSize) + ); + } + + /** + * create a regular mesh which will be used by all terrain-tiles + * @returns the created regular mesh + */ + getTerrainMesh(): TerrainMesh { + if (this._mesh) return this._mesh; + const context = this.painter.context; + const vertexArray = new Pos3dArray(); + const indexArray = new TriangleIndexArray(); + const meshSize = this.meshSize; + const delta = EXTENT / meshSize; + const meshSize2 = meshSize * meshSize; + for (let y = 0; y <= meshSize; y++) for (let x = 0; x <= meshSize; x++) + vertexArray.emplaceBack(x * delta, y * delta, 0); + for (let y = 0; y < meshSize2; y += meshSize + 1) for (let x = 0; x < meshSize; x++) { + indexArray.emplaceBack(x + y, meshSize + x + y + 1, meshSize + x + y + 2); + indexArray.emplaceBack(x + y, meshSize + x + y + 2, x + y + 1); + } + // add an extra frame around the mesh to avoid stiching on tile boundaries with different zoomlevels + // first code-block is for top-bottom frame and second for left-right frame + const offsetTop = vertexArray.length, offsetBottom = offsetTop + (meshSize + 1) * 2; + for (const y of [0, 1]) for (let x = 0; x <= meshSize; x++) for (const z of [0, 1]) + vertexArray.emplaceBack(x * delta, y * EXTENT, z); + for (let x = 0; x < meshSize * 2; x += 2) { + indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 1, offsetBottom + x + 3); + indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 3, offsetBottom + x + 2); + indexArray.emplaceBack(offsetTop + x, offsetTop + x + 3, offsetTop + x + 1); + indexArray.emplaceBack(offsetTop + x, offsetTop + x + 2, offsetTop + x + 3); + } + const offsetLeft = vertexArray.length, offsetRight = offsetLeft + (meshSize + 1) * 2; + for (const x of [0, 1]) for (let y = 0; y <= meshSize; y++) for (const z of [0, 1]) + vertexArray.emplaceBack(x * EXTENT, y * delta, z); + for (let y = 0; y < meshSize * 2; y += 2) { + indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 1, offsetLeft + y + 3); + indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 3, offsetLeft + y + 2); + indexArray.emplaceBack(offsetRight + y, offsetRight + y + 3, offsetRight + y + 1); + indexArray.emplaceBack(offsetRight + y, offsetRight + y + 2, offsetRight + y + 3); + } + this._mesh = { + indexBuffer: context.createIndexBuffer(indexArray), + vertexBuffer: context.createVertexBuffer(vertexArray, pos3dAttributes.members), + segments: SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length) + }; + return this._mesh; + } + + /** + * Calculates a height of the frame around the terrain-mesh to avoid stiching between + * tile boundaries in different zoomlevels. + * @param zoom - current zoomlevel + * @returns the elevation delta in meters + */ + getMeshFrameDelta(zoom: number): number { + // divide by 5 is evaluated by trial & error to get a frame in the right height + return 2 * Math.PI * earthRadius / Math.pow(2, zoom) / 5; + } + + getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number) { + const {tileID} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom); + return this.getMinMaxElevation(tileID).minElevation ?? 0; + } + + /** + * Get the minimum and maximum elevation contained in a tile. This includes any + * exaggeration included in the terrain. + * + * @param tileID - ID of the tile to be used as a source for the min/max elevation + * @returns the minimum and maximum elevation found in the tile, including the terrain's + * exaggeration + */ + getMinMaxElevation(tileID: OverscaledTileID): {minElevation: number | null; maxElevation: number | null} { + const tile = this.getTerrainData(tileID).tile; + const minMax = {minElevation: null, maxElevation: null}; + if (tile && tile.dem) { + minMax.minElevation = tile.dem.min * this.exaggeration; + minMax.maxElevation = tile.dem.max * this.exaggeration; + } + return minMax; + } + + _getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { tileID: OverscaledTileID; mercatorX: number; mercatorY: number} { + const mercatorCoordinate = MercatorCoordinate.fromLngLat(lnglat.wrap()); + const worldSize = (1 << zoom) * EXTENT; + const mercatorX = mercatorCoordinate.x * worldSize; + const mercatorY = mercatorCoordinate.y * worldSize; + const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT); + const tileID = new OverscaledTileID(zoom, 0, zoom, tileX, tileY); + return { + tileID, + mercatorX, + mercatorY + }; + } + + _allowMercatorOverflow(p: Point, mercatorX: number): number { + const inLeftHalf = p.x < (this.painter.width / 2); + let lng = lngFromMercatorX(mercatorX); + const centerLng = this.painter.transform.center.lng; + if ( + (inLeftHalf && Math.sign(lng) > 0 && Math.sign(centerLng) < 0) || + (!inLeftHalf && Math.sign(lng) < 0 && Math.sign(centerLng) > 0) + ) { + lng = 360 * Math.sign(centerLng) + lng; + return mercatorXfromLng(lng); + } + return mercatorX; + } +} diff --git a/web/libraries/maplibre-gl/src/render/texture.ts b/web/libraries/maplibre-gl/src/render/texture.ts new file mode 100644 index 00000000..99ce6a33 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/texture.ts @@ -0,0 +1,114 @@ +import type {Context} from '../gl/context'; +import type {RGBAImage, AlphaImage} from '../util/image'; +import {isImageBitmap} from '../util/util'; + +export type TextureFormat = WebGLRenderingContextBase['RGBA'] | WebGLRenderingContextBase['ALPHA']; +export type TextureFilter = WebGLRenderingContextBase['LINEAR'] | WebGLRenderingContextBase['LINEAR_MIPMAP_NEAREST'] | WebGLRenderingContextBase['NEAREST']; +export type TextureWrap = WebGLRenderingContextBase['REPEAT'] | WebGLRenderingContextBase['CLAMP_TO_EDGE'] | WebGLRenderingContextBase['MIRRORED_REPEAT']; + +type EmptyImage = { + width: number; + height: number; + data: null; +}; + +type DataTextureImage = RGBAImage | AlphaImage | EmptyImage; +export type TextureImage = TexImageSource | DataTextureImage; + +/** + * @internal + * A `Texture` GL related object + */ +export class Texture { + context: Context; + size: [number, number]; + texture: WebGLTexture; + format: TextureFormat; + filter: TextureFilter; + wrap: TextureWrap; + useMipmap: boolean; + + constructor(context: Context, image: TextureImage, format: TextureFormat, options?: { + premultiply?: boolean; + useMipmap?: boolean; + } | null) { + this.context = context; + this.format = format; + this.texture = context.gl.createTexture(); + this.update(image, options); + } + + update(image: TextureImage, options?: { + premultiply?: boolean; + useMipmap?: boolean; + } | null, position?: { + x: number; + y: number; + }) { + const {width, height} = image as {width: number; height: number}; + const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position; + const {context} = this; + const {gl} = context; + + this.useMipmap = Boolean(options && options.useMipmap); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + + context.pixelStoreUnpackFlipY.set(false); + context.pixelStoreUnpack.set(1); + context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl.RGBA && (!options || options.premultiply !== false)); + + if (resize) { + this.size = [width, height]; + + if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) { + gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image); + } else { + gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, (image as DataTextureImage).data); + } + + } else { + const {x, y} = position || {x: 0, y: 0}; + if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) { + gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image); + } else { + gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, (image as DataTextureImage).data); + } + } + + if (this.useMipmap && this.isSizePowerOfTwo()) { + gl.generateMipmap(gl.TEXTURE_2D); + } + } + + bind(filter: TextureFilter, wrap: TextureWrap, minFilter?: TextureFilter | null) { + const {context} = this; + const {gl} = context; + gl.bindTexture(gl.TEXTURE_2D, this.texture); + + if (minFilter === gl.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) { + minFilter = gl.LINEAR; + } + + if (filter !== this.filter) { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || filter); + this.filter = filter; + } + + if (wrap !== this.wrap) { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap); + this.wrap = wrap; + } + } + + isSizePowerOfTwo() { + return this.size[0] === this.size[1] && (Math.log(this.size[0]) / Math.LN2) % 1 === 0; + } + + destroy() { + const {gl} = this.context; + gl.deleteTexture(this.texture); + this.texture = null; + } +} diff --git a/web/libraries/maplibre-gl/src/render/uniform_binding.test.ts b/web/libraries/maplibre-gl/src/render/uniform_binding.test.ts new file mode 100644 index 00000000..a80a15e3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/uniform_binding.test.ts @@ -0,0 +1,122 @@ +import {mat4} from 'gl-matrix'; +import {Context} from '../gl/context'; +import { + Uniform1i, + Uniform1f, + Uniform2f, + Uniform3f, + Uniform4f, + UniformMatrix4f +} from './uniform_binding'; + +describe('Uniform Binding', () => { + test('Uniform1i', () => { + // test counts ensure we don't call the gl.uniform* setters more than expected + expect.assertions(4); + + const context = { + gl: { + uniform1i: () => { expect(true).toBeTruthy(); } + } + } as any as Context; + + const u = new Uniform1i(context, 0); + + expect(u.current).toBe(0); + u.set(1); + expect(u.current).toBe(1); + u.set(1); + u.set(2); + }); + + test('Uniform1f', () => { + expect.assertions(4); + + const context = { + gl: { + uniform1f: () => { expect(true).toBeTruthy(); } + } + } as any as Context; + + const u = new Uniform1f(context, 0); + + expect(u.current).toBe(0); + u.set(1); + expect(u.current).toBe(1); + u.set(1); + u.set(2); + }); + + test('Uniform2f', () => { + expect.assertions(4); + + const context = { + gl: { + uniform2f: () => { expect(true).toBeTruthy(); } + } + } as any as Context; + + const u = new Uniform2f(context, 0); + + expect(u.current).toEqual([0, 0]); + u.set([1, 1]); + expect(u.current).toEqual([1, 1]); + u.set([1, 1]); + u.set([1, 2]); + }); + + test('Uniform3f', () => { + expect.assertions(4); + + const context = { + gl: { + uniform3f: () => { expect(true).toBeTruthy(); } + } + } as any as Context; + + const u = new Uniform3f(context, 0); + + expect(u.current).toEqual([0, 0, 0]); + u.set([1, 1, 1]); + expect(u.current).toEqual([1, 1, 1]); + u.set([1, 1, 1]); + u.set([1, 1, 2]); + }); + + test('Uniform4f', () => { + expect.assertions(4); + + const context = { + gl: { + uniform4f: () => { expect(true).toBeTruthy(); } + } + } as any as Context; + + const u = new Uniform4f(context, 0); + + expect(u.current).toEqual([0, 0, 0, 0]); + u.set([1, 1, 1, 1]); + expect(u.current).toEqual([1, 1, 1, 1]); + u.set([1, 1, 1, 1]); + u.set([2, 1, 1, 1]); + }); + + test('UniformMatrix4f', () => { + expect.assertions(4); + + const context = { + gl: { + uniformMatrix4fv: () => { expect(true).toBeTruthy(); } + } + } as any as Context; + + const u = new UniformMatrix4f(context, 0); + const ident = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] as mat4; + expect(u.current).toEqual(new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])); + u.set(ident); + expect(u.current).toEqual(ident); + u.set(ident); + u.set([2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/render/uniform_binding.ts b/web/libraries/maplibre-gl/src/render/uniform_binding.ts new file mode 100644 index 00000000..8f43af5e --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/uniform_binding.ts @@ -0,0 +1,157 @@ +import {Color} from '@maplibre/maplibre-gl-style-spec'; + +import type {Context} from '../gl/context'; +import {mat4, vec2, vec3, vec4} from 'gl-matrix'; + +type $ObjMap any> = { + [K in keyof T]: F extends (v: T[K]) => infer R ? R : never; +}; + +export type UniformValues = $ObjMap(u: Uniform) => V>; +export type UniformLocations = {[_: string]: WebGLUniformLocation}; + +/** + * @internal + * A base uniform abstract class + */ +abstract class Uniform { + gl: WebGLRenderingContext|WebGL2RenderingContext; + location: WebGLUniformLocation; + current: T; + + constructor(context: Context, location: WebGLUniformLocation) { + this.gl = context.gl; + this.location = location; + } + + abstract set(v: T): void; +} + +class Uniform1i extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = 0; + } + + set(v: number): void { + if (this.current !== v) { + this.current = v; + this.gl.uniform1i(this.location, v); + } + } +} + +class Uniform1f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = 0; + } + + set(v: number): void { + if (this.current !== v) { + this.current = v; + this.gl.uniform1f(this.location, v); + } + } +} + +class Uniform2f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = [0, 0]; + } + + set(v: vec2): void { + if (v[0] !== this.current[0] || v[1] !== this.current[1]) { + this.current = v; + this.gl.uniform2f(this.location, v[0], v[1]); + } + } +} + +class Uniform3f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = [0, 0, 0]; + } + + set(v: vec3): void { + if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) { + this.current = v; + this.gl.uniform3f(this.location, v[0], v[1], v[2]); + } + } +} + +class Uniform4f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = [0, 0, 0, 0]; + } + + set(v: vec4): void { + if (v[0] !== this.current[0] || v[1] !== this.current[1] || + v[2] !== this.current[2] || v[3] !== this.current[3]) { + this.current = v; + this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]); + } + } +} + +class UniformColor extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = Color.transparent; + } + + set(v: Color): void { + if (v.r !== this.current.r || v.g !== this.current.g || + v.b !== this.current.b || v.a !== this.current.a) { + this.current = v; + this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a); + } + } +} + +const emptyMat4 = new Float32Array(16) as mat4; +class UniformMatrix4f extends Uniform { + constructor(context: Context, location: WebGLUniformLocation) { + super(context, location); + this.current = emptyMat4; + } + + set(v: mat4): void { + // The vast majority of matrix comparisons that will trip this set + // happen at i=12 or i=0, so we check those first to avoid lots of + // unnecessary iteration: + if (v[12] !== this.current[12] || v[0] !== this.current[0]) { + this.current = v; + this.gl.uniformMatrix4fv(this.location, false, v); + return; + } + for (let i = 1; i < 16; i++) { + if (v[i] !== this.current[i]) { + this.current = v; + this.gl.uniformMatrix4fv(this.location, false, v); + break; + } + } + } +} + +export { + Uniform, + Uniform1i, + Uniform1f, + Uniform2f, + Uniform3f, + Uniform4f, + UniformColor, + UniformMatrix4f +}; + +/** + * @internal + * A uniform bindings + */ +export type UniformBindings = {[_: string]: Uniform}; diff --git a/web/libraries/maplibre-gl/src/render/update_pattern_positions_in_program.test.ts b/web/libraries/maplibre-gl/src/render/update_pattern_positions_in_program.test.ts new file mode 100644 index 00000000..eeb939c2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/update_pattern_positions_in_program.test.ts @@ -0,0 +1,74 @@ +import {Tile} from '../source/tile'; +import {OverscaledTileID} from '../source/tile_id'; +import {updatePatternPositionsInProgram} from './update_pattern_positions_in_program'; +import {FillStyleLayer} from '../style/style_layer/fill_style_layer'; +import type {CrossFaded} from '../style/properties'; +import type {FillLayerSpecification, ResolvedImage} from '@maplibre/maplibre-gl-style-spec'; +import type {ProgramConfiguration} from '../data/program_configuration'; +import type {ImagePosition} from './image_atlas'; +import type {Rect} from './glyph_atlas'; + +interface MockProgramConfiguration extends ProgramConfiguration { + patternPositions: { + posFrom: Rect; + posTo: Rect; + }; +} + +function constructMockProgramConfiguration(): MockProgramConfiguration { + const mockProgramConfiguration: MockProgramConfiguration = {patternPositions: {}} as any; + mockProgramConfiguration.updatePaintBuffers = jest.fn(); + mockProgramConfiguration.setConstantPatternPositions = (posFrom: ImagePosition, posTo: ImagePosition) => { + // this does not exist on ProgramConfiguration but we want to test the resulting output + mockProgramConfiguration.patternPositions = {posFrom: posFrom.paddedRect, posTo: posTo.paddedRect}; + }; + + return mockProgramConfiguration; +} + +function constructMockFillStyleLayer(): FillStyleLayer { + const layerSpec = { + id: 'mock-layer', + source: 'empty-source', + type: 'fill', + layout: {}, + 'paint': { + 'fill-pattern': [ + 'step', + ['zoom'], + 'zoo_11', + 4, + 'volcano_11' + ] + } + } as FillLayerSpecification; + const layer = new FillStyleLayer(layerSpec); + return layer; +} + +describe('updatePatternPositionsInProgram', () => { + test('geojson tile', () => { + const config = constructMockProgramConfiguration(); + const tile = new Tile(new OverscaledTileID(3, 0, 2, 1, 2), undefined); + tile.imageAtlas = {} as any; + tile.imageAtlas.patternPositions = { + 'volcano_11': {paddedRect: {x: 0, y: 0, w: 0, h: 0}, version: 0, tl: [0, 0], pixelRatio: 1, br: [0, 0], tlbr: [0, 0, 0, 0], displaySize: [0, 0], stretchX: [], stretchY: [], content: [0, 0, 0, 0]}, + }; + const crossFadeResolveImage: CrossFaded = { + from: {name: 'zoo_11', available: false, toString: () => 'zoo_11'}, + to: {name: 'volcano_11', available: false, toString: () => 'volcano_11'} + }; + updatePatternPositionsInProgram( + config, + 'fill-pattern', + crossFadeResolveImage, + tile, + constructMockFillStyleLayer() + ); + // we added this property to just see what the update looks like + expect(config.patternPositions).toEqual({ + posFrom: {x: 0, y: 0, w: 0, h: 0}, + posTo: {x: 0, y: 0, w: 0, h: 0} + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/render/update_pattern_positions_in_program.ts b/web/libraries/maplibre-gl/src/render/update_pattern_positions_in_program.ts new file mode 100644 index 00000000..6ea2edaa --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/update_pattern_positions_in_program.ts @@ -0,0 +1,50 @@ +import type {CrossFaded} from '../style/properties'; +import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec'; +import type {Tile} from '../source/tile'; +import type {ProgramConfiguration} from '../data/program_configuration'; +import type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer'; +import type {FillStyleLayer} from '../style/style_layer/fill_style_layer'; + +/** + * A simple helper shared by draw_fill and draw_fill_extrusions to find the correct pattern positions AND update program. + * For transtionable properties, especially 'fill-pattern' and 'fill-extrusion-pattern', while rendering certain frames + * tile.imageAtlas has been updated by worker to hold the new pattern only, but rendering code is still looking for the previous image. + * The mismatch was causing setConstantPatternPositions method not being called and pixelRatio was always the + * default of 1, instead of actual values set by original map.addImage. + * + * @param programConfiguration - to be used to set pattern position and device pixel ratio. + * @param propertyName - 'fill-pattern' or 'fill-extrusion-pattern' property key + * @param constantPattern - either 'fill-pattern' or 'fill-extrusion-pattern' property value + * @param tile - current tile being drawn + * @param layer - current layer being rendered + */ +export function updatePatternPositionsInProgram( + programConfiguration: ProgramConfiguration, + propertyName: 'fill-pattern' | 'fill-extrusion-pattern', + constantPattern: CrossFaded, + tile: Tile, + layer: FillStyleLayer | FillExtrusionStyleLayer): void { + + if (!constantPattern || !tile || !tile.imageAtlas) { + return; + } + + const patternPositions = tile.imageAtlas.patternPositions; + let posTo = patternPositions[constantPattern.to.toString()]; + let posFrom = patternPositions[constantPattern.from.toString()]; + + // https://github.com/maplibre/maplibre-gl-js/issues/3377 + if (!posTo && posFrom) posTo = posFrom; + if (!posFrom && posTo) posFrom = posTo; + + // try again in case patternPositions has been updated by worker + if (!posTo || !posFrom) { + const transitioned = layer.getPaintProperty(propertyName) as string; + posTo = patternPositions[transitioned]; + posFrom = patternPositions[transitioned]; + } + + if (posTo && posFrom) { + programConfiguration.setConstantPatternPositions(posTo, posFrom); + } +} diff --git a/web/libraries/maplibre-gl/src/render/vertex_array_object.ts b/web/libraries/maplibre-gl/src/render/vertex_array_object.ts new file mode 100644 index 00000000..efe64320 --- /dev/null +++ b/web/libraries/maplibre-gl/src/render/vertex_array_object.ts @@ -0,0 +1,163 @@ + +import type {Program} from './program'; +import type {VertexBuffer} from '../gl/vertex_buffer'; +import type {IndexBuffer} from '../gl/index_buffer'; +import type {Context} from '../gl/context'; + +/** + * @internal + * A vertex array object used to pass data to the webgl code + */ +export class VertexArrayObject { + context: Context; + boundProgram: Program; + boundLayoutVertexBuffer: VertexBuffer; + boundPaintVertexBuffers: Array; + boundIndexBuffer: IndexBuffer; + boundVertexOffset: number; + boundDynamicVertexBuffer: VertexBuffer; + boundDynamicVertexBuffer2: VertexBuffer; + boundDynamicVertexBuffer3: VertexBuffer; + vao: any; + + constructor() { + this.boundProgram = null; + this.boundLayoutVertexBuffer = null; + this.boundPaintVertexBuffers = []; + this.boundIndexBuffer = null; + this.boundVertexOffset = null; + this.boundDynamicVertexBuffer = null; + this.vao = null; + } + + bind(context: Context, + program: Program, + layoutVertexBuffer: VertexBuffer, + paintVertexBuffers: Array, + indexBuffer?: IndexBuffer | null, + vertexOffset?: number | null, + dynamicVertexBuffer?: VertexBuffer | null, + dynamicVertexBuffer2?: VertexBuffer | null, + dynamicVertexBuffer3?: VertexBuffer | null) { + + this.context = context; + + let paintBuffersDiffer = this.boundPaintVertexBuffers.length !== paintVertexBuffers.length; + for (let i = 0; !paintBuffersDiffer && i < paintVertexBuffers.length; i++) { + if (this.boundPaintVertexBuffers[i] !== paintVertexBuffers[i]) { + paintBuffersDiffer = true; + } + } + + const isFreshBindRequired = ( + !this.vao || + this.boundProgram !== program || + this.boundLayoutVertexBuffer !== layoutVertexBuffer || + paintBuffersDiffer || + this.boundIndexBuffer !== indexBuffer || + this.boundVertexOffset !== vertexOffset || + this.boundDynamicVertexBuffer !== dynamicVertexBuffer || + this.boundDynamicVertexBuffer2 !== dynamicVertexBuffer2 || + this.boundDynamicVertexBuffer3 !== dynamicVertexBuffer3 + ); + + if (isFreshBindRequired) { + this.freshBind(program, layoutVertexBuffer, paintVertexBuffers, indexBuffer, vertexOffset, dynamicVertexBuffer, dynamicVertexBuffer2, dynamicVertexBuffer3); + } else { + context.bindVertexArray.set(this.vao); + + if (dynamicVertexBuffer) { + // The buffer may have been updated. Rebind to upload data. + dynamicVertexBuffer.bind(); + } + + if (indexBuffer && indexBuffer.dynamicDraw) { + indexBuffer.bind(); + } + + if (dynamicVertexBuffer2) { + dynamicVertexBuffer2.bind(); + } + + if (dynamicVertexBuffer3) { + dynamicVertexBuffer3.bind(); + } + } + } + + freshBind(program: Program, + layoutVertexBuffer: VertexBuffer, + paintVertexBuffers: Array, + indexBuffer?: IndexBuffer | null, + vertexOffset?: number | null, + dynamicVertexBuffer?: VertexBuffer | null, + dynamicVertexBuffer2?: VertexBuffer | null, + dynamicVertexBuffer3?: VertexBuffer | null) { + + const numNextAttributes = program.numAttributes; + + const context = this.context; + const gl = context.gl; + + if (this.vao) this.destroy(); + this.vao = context.createVertexArray(); + context.bindVertexArray.set(this.vao); + + // store the arguments so that we can verify them when the vao is bound again + this.boundProgram = program; + this.boundLayoutVertexBuffer = layoutVertexBuffer; + this.boundPaintVertexBuffers = paintVertexBuffers; + this.boundIndexBuffer = indexBuffer; + this.boundVertexOffset = vertexOffset; + this.boundDynamicVertexBuffer = dynamicVertexBuffer; + this.boundDynamicVertexBuffer2 = dynamicVertexBuffer2; + this.boundDynamicVertexBuffer3 = dynamicVertexBuffer3; + + layoutVertexBuffer.enableAttributes(gl, program); + for (const vertexBuffer of paintVertexBuffers) { + vertexBuffer.enableAttributes(gl, program); + } + + if (dynamicVertexBuffer) { + dynamicVertexBuffer.enableAttributes(gl, program); + } + if (dynamicVertexBuffer2) { + dynamicVertexBuffer2.enableAttributes(gl, program); + } + if (dynamicVertexBuffer3) { + dynamicVertexBuffer3.enableAttributes(gl, program); + } + + layoutVertexBuffer.bind(); + layoutVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); + for (const vertexBuffer of paintVertexBuffers) { + vertexBuffer.bind(); + vertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); + } + + if (dynamicVertexBuffer) { + dynamicVertexBuffer.bind(); + dynamicVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); + } + if (indexBuffer) { + indexBuffer.bind(); + } + if (dynamicVertexBuffer2) { + dynamicVertexBuffer2.bind(); + dynamicVertexBuffer2.setVertexAttribPointers(gl, program, vertexOffset); + } + if (dynamicVertexBuffer3) { + dynamicVertexBuffer3.bind(); + dynamicVertexBuffer3.setVertexAttribPointers(gl, program, vertexOffset); + } + + context.currentNumAttributes = numNextAttributes; + } + + destroy() { + if (this.vao) { + this.context.deleteVertexArray(this.vao); + this.vao = null; + } + } +} diff --git a/web/libraries/maplibre-gl/src/shaders/README.md b/web/libraries/maplibre-gl/src/shaders/README.md new file mode 100644 index 00000000..cdd5f791 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/README.md @@ -0,0 +1,42 @@ +# MapLibre GL JS Shaders + +This repository contains the GLSL shaders + +## Pragmas + +Some variables change type depending on their context: + + - if the variable is the same for all features, we declare it as a `uniform` + - if the variable is different for each feature, we declare it as an `attribute` (in the vertex shader) and an accompanying `varying` (in both the vertex and fragment shaders). + - if the variable is different for each feature and a function of zoom, we declare several `attributes` and `uniforms` then calculate the value using interpolation + +We abstract over this functionality using pragmas. + +```glsl +#pragma mapbox: define highp vec4 color + +main() { + #pragma mapbox: initialize highp vec4 color + ... + fragColor = color; +} +``` + +This program defines a variable within `main` called `color`, initialize the value of `color`, then sets `fragColor` to the value of `color`. + +Pragmas take the following form. + +```glsl +#pragma mapbox: (define|initialize) (lowp|mediump|highp) (float|vec2|vec3|vec4) {name} +``` + +When using pragmas, the following requirements apply. + + - all pragma-defined variables must have both `define` and `initialize` pragmas + - `define` pragmas must be in file scope + - `initialize` pragmas must be in function scope + - all pragma-defined variables defined and initialized in the fragment shader must also be defined and initialized in the vertex shader because `attribute`s are not accessible from the fragment shader + +## Prelude + +The `_prelude.fragment.glsl` and `_prelude.vertex.glsl` files are automatically included in all shaders by the compiler. diff --git a/web/libraries/maplibre-gl/src/shaders/_prelude.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/_prelude.fragment.glsl new file mode 100644 index 00000000..8716b728 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/_prelude.fragment.glsl @@ -0,0 +1,19 @@ +#ifdef GL_ES +precision mediump float; +#else + +#if !defined(lowp) +#define lowp +#endif + +#if !defined(mediump) +#define mediump +#endif + +#if !defined(highp) +#define highp +#endif + +#endif + +out highp vec4 fragColor; diff --git a/web/libraries/maplibre-gl/src/shaders/_prelude.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/_prelude.fragment.glsl.g.ts new file mode 100644 index 00000000..67cedd44 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/_prelude.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n'; diff --git a/web/libraries/maplibre-gl/src/shaders/_prelude.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/_prelude.vertex.glsl new file mode 100644 index 00000000..69b68398 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/_prelude.vertex.glsl @@ -0,0 +1,148 @@ +#ifdef GL_ES +precision highp float; +#else + +#if !defined(lowp) +#define lowp +#endif + +#if !defined(mediump) +#define mediump +#endif + +#if !defined(highp) +#define highp +#endif + +#endif + +// Unpack a pair of values that have been packed into a single float. +// The packed values are assumed to be 8-bit unsigned integers, and are +// packed like so: +// packedValue = floor(input[0]) * 256 + input[1], +vec2 unpack_float(const float packedValue) { + int packedIntValue = int(packedValue); + int v0 = packedIntValue / 256; + return vec2(v0, packedIntValue - v0 * 256); +} + +vec2 unpack_opacity(const float packedOpacity) { + int intOpacity = int(packedOpacity) / 2; + return vec2(float(intOpacity) / 127.0, mod(packedOpacity, 2.0)); +} + +// To minimize the number of ins needed, we encode a 4-component +// color into a pair of floats (i.e. a vec2) as follows: +// [ floor(color.r * 255) * 256 + color.g * 255, +// floor(color.b * 255) * 256 + color.g * 255 ] +vec4 decode_color(const vec2 encodedColor) { + return vec4( + unpack_float(encodedColor[0]) / 255.0, + unpack_float(encodedColor[1]) / 255.0 + ); +} + +// Unpack a pair of paint values and interpolate between them. +float unpack_mix_vec2(const vec2 packedValue, const float t) { + return mix(packedValue[0], packedValue[1], t); +} + +// Unpack a pair of paint values and interpolate between them. +vec4 unpack_mix_color(const vec4 packedColors, const float t) { + vec4 minColor = decode_color(vec2(packedColors[0], packedColors[1])); + vec4 maxColor = decode_color(vec2(packedColors[2], packedColors[3])); + return mix(minColor, maxColor, t); +} + +// The offset depends on how many pixels are between the world origin and the edge of the tile: +// vec2 offset = mod(pixel_coord, size) +// +// At high zoom levels there are a ton of pixels between the world origin and the edge of the tile. +// The glsl spec only guarantees 16 bits of precision for highp floats. We need more than that. +// +// The pixel_coord is passed in as two 16 bit values: +// pixel_coord_upper = floor(pixel_coord / 2^16) +// pixel_coord_lower = mod(pixel_coord, 2^16) +// +// The offset is calculated in a series of steps that should preserve this precision: +vec2 get_pattern_pos(const vec2 pixel_coord_upper, const vec2 pixel_coord_lower, + const vec2 pattern_size, const float tile_units_to_pixels, const vec2 pos) { + + vec2 offset = mod(mod(mod(pixel_coord_upper, pattern_size) * 256.0, pattern_size) * 256.0 + pixel_coord_lower, pattern_size); + return (tile_units_to_pixels * pos + offset) / pattern_size; +} + +// logic for terrain 3d + +#ifdef TERRAIN3D +uniform sampler2D u_terrain; +uniform float u_terrain_dim; +uniform mat4 u_terrain_matrix; +uniform vec4 u_terrain_unpack; +uniform float u_terrain_exaggeration; +uniform highp sampler2D u_depth; +#endif + +// methods for pack/unpack depth value to texture rgba +// https://stackoverflow.com/questions/34963366/encode-floating-point-data-in-a-rgba-texture +const highp vec4 bitSh = vec4(256. * 256. * 256., 256. * 256., 256., 1.); +const highp vec4 bitShifts = vec4(1.) / bitSh; + +highp float unpack(highp vec4 color) { + return dot(color , bitShifts); +} + +// calculate the opacity behind terrain, returns a value between 0 and 1. +highp float depthOpacity(vec3 frag) { + #ifdef TERRAIN3D + // create the delta between frag.z + terrain.z. + highp float d = unpack(texture(u_depth, frag.xy * 0.5 + 0.5)) + 0.0001 - frag.z; + // visibility range is between 0 and 0.002. 0 is visible, 0.002 is fully invisible. + return 1.0 - max(0.0, min(1.0, -d * 500.0)); + #else + return 1.0; + #endif +} + +// calculate the visibility of a coordinate in terrain and return an opacity value. +// if a coordinate is behind the terrain reduce its opacity +float calculate_visibility(vec4 pos) { + #ifdef TERRAIN3D + vec3 frag = pos.xyz / pos.w; + // check if coordingate is fully visible + highp float d = depthOpacity(frag); + if (d > 0.95) return 1.0; + // if not, go some pixel above and check it this point is visible + return (d + depthOpacity(frag + vec3(0.0, 0.01, 0.0))) / 2.0; + #else + return 1.0; + #endif +} + +// grab an elevation value from a raster-dem texture +float ele(vec2 pos) { + #ifdef TERRAIN3D + vec4 rgb = (texture(u_terrain, pos) * 255.0) * u_terrain_unpack; + return rgb.r + rgb.g + rgb.b - u_terrain_unpack.a; + #else + return 0.0; + #endif +} + +// calculate the elevation with linear interpolation for a coordinate +float get_elevation(vec2 pos) { + #ifdef TERRAIN3D + vec2 coord = (u_terrain_matrix * vec4(pos, 0.0, 1.0)).xy * u_terrain_dim + 1.0; + vec2 f = fract(coord); + vec2 c = (floor(coord) + 0.5) / (u_terrain_dim + 2.0); // get the pixel center + float d = 1.0 / (u_terrain_dim + 2.0); + float tl = ele(c); + float tr = ele(c + vec2(d, 0.0)); + float bl = ele(c + vec2(0.0, d)); + float br = ele(c + vec2(d, d)); + float elevation = mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y); + return elevation * u_terrain_exaggeration; + #else + return 0.0; + #endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/_prelude.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/_prelude.vertex.glsl.g.ts new file mode 100644 index 00000000..ad0eaeb3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/_prelude.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/background.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/background.fragment.glsl new file mode 100644 index 00000000..fdb7205e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background.fragment.glsl @@ -0,0 +1,10 @@ +uniform vec4 u_color; +uniform float u_opacity; + +void main() { + fragColor = u_color * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/background.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/background.fragment.glsl.g.ts new file mode 100644 index 00000000..b1487ef8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/background.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/background.vertex.glsl new file mode 100644 index 00000000..46f9eaa1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background.vertex.glsl @@ -0,0 +1,7 @@ +in vec2 a_pos; + +uniform mat4 u_matrix; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} diff --git a/web/libraries/maplibre-gl/src/shaders/background.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/background.vertex.glsl.g.ts new file mode 100644 index 00000000..3c3fb316 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/background_pattern.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/background_pattern.fragment.glsl new file mode 100644 index 00000000..7cbb25d9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background_pattern.fragment.glsl @@ -0,0 +1,28 @@ +uniform vec2 u_pattern_tl_a; +uniform vec2 u_pattern_br_a; +uniform vec2 u_pattern_tl_b; +uniform vec2 u_pattern_br_b; +uniform vec2 u_texsize; +uniform float u_mix; +uniform float u_opacity; + +uniform sampler2D u_image; + +in vec2 v_pos_a; +in vec2 v_pos_b; + +void main() { + vec2 imagecoord = mod(v_pos_a, 1.0); + vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); + vec4 color1 = texture(u_image, pos); + + vec2 imagecoord_b = mod(v_pos_b, 1.0); + vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); + vec4 color2 = texture(u_image, pos2); + + fragColor = mix(color1, color2, u_mix) * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/background_pattern.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/background_pattern.fragment.glsl.g.ts new file mode 100644 index 00000000..efef0d8c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background_pattern.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/background_pattern.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/background_pattern.vertex.glsl new file mode 100644 index 00000000..90a7af24 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background_pattern.vertex.glsl @@ -0,0 +1,19 @@ +uniform mat4 u_matrix; +uniform vec2 u_pattern_size_a; +uniform vec2 u_pattern_size_b; +uniform vec2 u_pixel_coord_upper; +uniform vec2 u_pixel_coord_lower; +uniform float u_scale_a; +uniform float u_scale_b; +uniform float u_tile_units_to_pixels; + +in vec2 a_pos; +out vec2 v_pos_a; +out vec2 v_pos_b; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); + + v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos); + v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); +} diff --git a/web/libraries/maplibre-gl/src/shaders/background_pattern.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/background_pattern.vertex.glsl.g.ts new file mode 100644 index 00000000..590e9abd --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/background_pattern.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/circle.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/circle.fragment.glsl new file mode 100644 index 00000000..cba58bd3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/circle.fragment.glsl @@ -0,0 +1,36 @@ +in vec3 v_data; +in float v_visibility; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define mediump float radius +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define highp vec4 stroke_color +#pragma mapbox: define mediump float stroke_width +#pragma mapbox: define lowp float stroke_opacity + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize mediump float radius + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize highp vec4 stroke_color + #pragma mapbox: initialize mediump float stroke_width + #pragma mapbox: initialize lowp float stroke_opacity + + vec2 extrude = v_data.xy; + float extrude_length = length(extrude); + + lowp float antialiasblur = v_data.z; + float antialiased_blur = -max(blur, antialiasblur); + + float opacity_t = smoothstep(0.0, antialiased_blur, extrude_length - 1.0); + + float color_t = stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur, 0.0, extrude_length - radius / (radius + stroke_width)); + + fragColor = v_visibility * opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/circle.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/circle.fragment.glsl.g.ts new file mode 100644 index 00000000..7d7ca567 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/circle.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/circle.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/circle.vertex.glsl new file mode 100644 index 00000000..5e8b7499 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/circle.vertex.glsl @@ -0,0 +1,68 @@ +uniform mat4 u_matrix; +uniform bool u_scale_with_map; +uniform bool u_pitch_with_map; +uniform vec2 u_extrude_scale; +uniform lowp float u_device_pixel_ratio; +uniform highp float u_camera_to_center_distance; + +in vec2 a_pos; + +out vec3 v_data; +out float v_visibility; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define mediump float radius +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define highp vec4 stroke_color +#pragma mapbox: define mediump float stroke_width +#pragma mapbox: define lowp float stroke_opacity + +void main(void) { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize mediump float radius + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize highp vec4 stroke_color + #pragma mapbox: initialize mediump float stroke_width + #pragma mapbox: initialize lowp float stroke_opacity + + // unencode the extrusion vector that we snuck into the a_pos vector + vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); + + // multiply a_pos by 0.5, since we had it * 2 in order to sneak + // in extrusion data + vec2 circle_center = floor(a_pos * 0.5); + float ele = get_elevation(circle_center); + v_visibility = calculate_visibility(u_matrix * vec4(circle_center, ele, 1.0)); + + if (u_pitch_with_map) { + vec2 corner_position = circle_center; + if (u_scale_with_map) { + corner_position += extrude * (radius + stroke_width) * u_extrude_scale; + } else { + // Pitching the circle with the map effectively scales it with the map + // To counteract the effect for pitch-scale: viewport, we rescale the + // whole circle based on the pitch scaling effect at its central point + vec4 projected_center = u_matrix * vec4(circle_center, 0, 1); + corner_position += extrude * (radius + stroke_width) * u_extrude_scale * (projected_center.w / u_camera_to_center_distance); + } + + gl_Position = u_matrix * vec4(corner_position, ele, 1); + } else { + gl_Position = u_matrix * vec4(circle_center, ele, 1); + + if (u_scale_with_map) { + gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * u_camera_to_center_distance; + } else { + gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * gl_Position.w; + } + } + + // This is a minimum blur distance that serves as a faux-antialiasing for + // the circle. since blur is a ratio of the circle's size and the intent is + // to keep the blur at roughly 1px, the two are inversely related. + lowp float antialiasblur = 1.0 / u_device_pixel_ratio / (radius + stroke_width); + + v_data = vec3(extrude.x, extrude.y, antialiasblur); +} diff --git a/web/libraries/maplibre-gl/src/shaders/circle.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/circle.vertex.glsl.g.ts new file mode 100644 index 00000000..bfced4e7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/circle.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/clipping_mask.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/clipping_mask.fragment.glsl new file mode 100644 index 00000000..bb3039aa --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/clipping_mask.fragment.glsl @@ -0,0 +1,3 @@ +void main() { + fragColor = vec4(1.0); +} diff --git a/web/libraries/maplibre-gl/src/shaders/clipping_mask.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/clipping_mask.fragment.glsl.g.ts new file mode 100644 index 00000000..dfafeb64 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/clipping_mask.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'void main() {gl_FragColor=vec4(1.0);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/clipping_mask.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/clipping_mask.vertex.glsl new file mode 100644 index 00000000..46f9eaa1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/clipping_mask.vertex.glsl @@ -0,0 +1,7 @@ +in vec2 a_pos; + +uniform mat4 u_matrix; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} diff --git a/web/libraries/maplibre-gl/src/shaders/clipping_mask.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/clipping_mask.vertex.glsl.g.ts new file mode 100644 index 00000000..3c3fb316 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/clipping_mask.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/collision_box.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/collision_box.fragment.glsl new file mode 100644 index 00000000..582a2798 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_box.fragment.glsl @@ -0,0 +1,20 @@ +in float v_placed; +in float v_notUsed; + +void main() { + + float alpha = 0.5; + + // Red = collision, hide label + fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; + + // Blue = no collision, label is showing + if (v_placed > 0.5) { + fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; + } + + if (v_notUsed > 0.5) { + // This box not used, fade it out + fragColor *= .1; + } +} \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/shaders/collision_box.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/collision_box.fragment.glsl.g.ts new file mode 100644 index 00000000..55df0322 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_box.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}'; diff --git a/web/libraries/maplibre-gl/src/shaders/collision_box.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/collision_box.vertex.glsl new file mode 100644 index 00000000..0750aa7a --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_box.vertex.glsl @@ -0,0 +1,27 @@ +in vec2 a_pos; +in vec2 a_anchor_pos; +in vec2 a_extrude; +in vec2 a_placed; +in vec2 a_shift; + +uniform mat4 u_matrix; +uniform vec2 u_extrude_scale; +uniform float u_camera_to_center_distance; + +out float v_placed; +out float v_notUsed; + +void main() { + vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1); + highp float camera_to_anchor_distance = projectedPoint.w; + highp float collision_perspective_ratio = clamp( + 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance), + 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles + 4.0); + + gl_Position = u_matrix * vec4(a_pos, get_elevation(a_pos), 1.0); + gl_Position.xy += (a_extrude + a_shift) * u_extrude_scale * gl_Position.w * collision_perspective_ratio; + + v_placed = a_placed.x; + v_notUsed = a_placed.y; +} diff --git a/web/libraries/maplibre-gl/src/shaders/collision_box.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/collision_box.vertex.glsl.g.ts new file mode 100644 index 00000000..385fc72f --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_box.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/collision_circle.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/collision_circle.fragment.glsl new file mode 100644 index 00000000..f171b426 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_circle.fragment.glsl @@ -0,0 +1,17 @@ +in float v_radius; +in vec2 v_extrude; +in float v_perspective_ratio; +in float v_collision; + +void main() { + float alpha = 0.5 * min(v_perspective_ratio, 1.0); + float stroke_radius = 0.9 * max(v_perspective_ratio, 1.0); + + float distance_to_center = length(v_extrude); + float distance_to_edge = abs(distance_to_center - v_radius); + float opacity_t = smoothstep(-stroke_radius, 0.0, -distance_to_edge); + + vec4 color = mix(vec4(0.0, 0.0, 1.0, 0.5), vec4(1.0, 0.0, 0.0, 1.0), v_collision); + + fragColor = color * alpha * opacity_t; +} diff --git a/web/libraries/maplibre-gl/src/shaders/collision_circle.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/collision_circle.fragment.glsl.g.ts new file mode 100644 index 00000000..99e766d2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_circle.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/collision_circle.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/collision_circle.vertex.glsl new file mode 100644 index 00000000..7d5f1e21 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_circle.vertex.glsl @@ -0,0 +1,59 @@ +in vec2 a_pos; +in float a_radius; +in vec2 a_flags; + +uniform mat4 u_matrix; +uniform mat4 u_inv_matrix; +uniform vec2 u_viewport_size; +uniform float u_camera_to_center_distance; + +out float v_radius; +out vec2 v_extrude; +out float v_perspective_ratio; +out float v_collision; + +vec3 toTilePosition(vec2 screenPos) { + // Shoot a ray towards the ground to reconstruct the depth-value + vec4 rayStart = u_inv_matrix * vec4(screenPos, -1.0, 1.0); + vec4 rayEnd = u_inv_matrix * vec4(screenPos, 1.0, 1.0); + + rayStart.xyz /= rayStart.w; + rayEnd.xyz /= rayEnd.w; + + highp float t = (0.0 - rayStart.z) / (rayEnd.z - rayStart.z); + return mix(rayStart.xyz, rayEnd.xyz, t); +} + +void main() { + vec2 quadCenterPos = a_pos; + float radius = a_radius; + float collision = a_flags.x; + float vertexIdx = a_flags.y; + + vec2 quadVertexOffset = vec2( + mix(-1.0, 1.0, float(vertexIdx >= 2.0)), + mix(-1.0, 1.0, float(vertexIdx >= 1.0 && vertexIdx <= 2.0))); + + vec2 quadVertexExtent = quadVertexOffset * radius; + + // Screen position of the quad might have been computed with different camera parameters. + // Transform the point to a proper position on the current viewport + vec3 tilePos = toTilePosition(quadCenterPos); + vec4 clipPos = u_matrix * vec4(tilePos, 1.0); + + highp float camera_to_anchor_distance = clipPos.w; + highp float collision_perspective_ratio = clamp( + 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance), + 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles + 4.0); + + // Apply small padding for the anti-aliasing effect to fit the quad + // Note that v_radius and v_extrude are in screen coordinates already + float padding_factor = 1.2; + v_radius = radius; + v_extrude = quadVertexExtent * padding_factor; + v_perspective_ratio = collision_perspective_ratio; + v_collision = collision; + + gl_Position = vec4(clipPos.xyz / clipPos.w, 1.0) + vec4(quadVertexExtent * padding_factor / u_viewport_size * 2.0, 0.0, 0.0); +} diff --git a/web/libraries/maplibre-gl/src/shaders/collision_circle.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/collision_circle.vertex.glsl.g.ts new file mode 100644 index 00000000..3d12634c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/collision_circle.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/debug.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/debug.fragment.glsl new file mode 100644 index 00000000..53e0f40d --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/debug.fragment.glsl @@ -0,0 +1,9 @@ +uniform highp vec4 u_color; +uniform sampler2D u_overlay; + +in vec2 v_uv; + +void main() { + vec4 overlay_color = texture(u_overlay, v_uv); + fragColor = mix(u_color, overlay_color, overlay_color.a); +} diff --git a/web/libraries/maplibre-gl/src/shaders/debug.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/debug.fragment.glsl.g.ts new file mode 100644 index 00000000..f3980875 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/debug.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/debug.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/debug.vertex.glsl new file mode 100644 index 00000000..57112938 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/debug.vertex.glsl @@ -0,0 +1,12 @@ +in vec2 a_pos; +out vec2 v_uv; + +uniform mat4 u_matrix; +uniform float u_overlay_scale; + +void main() { + // This vertex shader expects a EXTENT x EXTENT quad, + // The UV co-ordinates for the overlay texture can be calculated using that knowledge + v_uv = a_pos / 8192.0; + gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, get_elevation(a_pos), 1); +} diff --git a/web/libraries/maplibre-gl/src/shaders/debug.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/debug.vertex.glsl.g.ts new file mode 100644 index 00000000..fd855c0e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/debug.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/encode_attribute.test.ts b/web/libraries/maplibre-gl/src/shaders/encode_attribute.test.ts new file mode 100644 index 00000000..e9c37949 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/encode_attribute.test.ts @@ -0,0 +1,11 @@ +import {packUint8ToFloat} from './encode_attribute'; + +test('packUint8ToFloat', () => { + expect(packUint8ToFloat(0, 0)).toBe(0); + expect(packUint8ToFloat(255, 255)).toBe(65535); + expect(packUint8ToFloat(123, 45)).toBe(31533); + + expect(packUint8ToFloat(-1, -1)).toBe(0); + expect(packUint8ToFloat(256, 256)).toBe(65535); + +}); diff --git a/web/libraries/maplibre-gl/src/shaders/encode_attribute.ts b/web/libraries/maplibre-gl/src/shaders/encode_attribute.ts new file mode 100644 index 00000000..2facd79c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/encode_attribute.ts @@ -0,0 +1,13 @@ +import {clamp} from '../util/util'; + +/** + * Packs two numbers, interpreted as 8-bit unsigned integers, into a single + * float. Unpack them in the shader using the `unpack_float()` function, + * defined in _prelude.vertex.glsl + */ +export function packUint8ToFloat(a: number, b: number) { + // coerce a and b to 8-bit ints + a = clamp(Math.floor(a), 0, 255); + b = clamp(Math.floor(b), 0, 255); + return 256 * a + b; +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/fill.fragment.glsl new file mode 100644 index 00000000..ffd33c16 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill.fragment.glsl @@ -0,0 +1,13 @@ +#pragma mapbox: define highp vec4 color +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize lowp float opacity + + fragColor = color * opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill.fragment.glsl.g.ts new file mode 100644 index 00000000..44947771 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/fill.vertex.glsl new file mode 100644 index 00000000..fcafb429 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill.vertex.glsl @@ -0,0 +1,13 @@ +in vec2 a_pos; + +uniform mat4 u_matrix; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize lowp float opacity + + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill.vertex.glsl.g.ts new file mode 100644 index 00000000..d135a8d8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.fragment.glsl new file mode 100644 index 00000000..c7913c30 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.fragment.glsl @@ -0,0 +1,9 @@ +in vec4 v_color; + +void main() { + fragColor = v_color; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.fragment.glsl.g.ts new file mode 100644 index 00000000..d29aaf16 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.vertex.glsl new file mode 100644 index 00000000..69f9e350 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.vertex.glsl @@ -0,0 +1,84 @@ +uniform mat4 u_matrix; +uniform vec3 u_lightcolor; +uniform lowp vec3 u_lightpos; +uniform lowp float u_lightintensity; +uniform float u_vertical_gradient; +uniform lowp float u_opacity; + +in vec2 a_pos; +in vec4 a_normal_ed; + +#ifdef TERRAIN3D + in vec2 a_centroid; +#endif + + +out vec4 v_color; + +#pragma mapbox: define highp float base +#pragma mapbox: define highp float height + +#pragma mapbox: define highp vec4 color + +void main() { + #pragma mapbox: initialize highp float base + #pragma mapbox: initialize highp float height + #pragma mapbox: initialize highp vec4 color + + vec3 normal = a_normal_ed.xyz; + + #ifdef TERRAIN3D + // Raise the "ceiling" of elements by the elevation of the centroid, in meters. + float height_terrain3d_offset = get_elevation(a_centroid); + // To avoid having buildings "hang above a slope", create a "basement" + // by lowering the "floor" of ground-level (and below) elements. + // This is in addition to the elevation of the centroid, in meters. + float base_terrain3d_offset = height_terrain3d_offset - (base > 0.0 ? 0.0 : 10.0); + #else + float height_terrain3d_offset = 0.0; + float base_terrain3d_offset = 0.0; + #endif + // Sub-terranian "floors and ceilings" are clamped to ground-level. + // 3D Terrain offsets, if applicable, are applied on the result. + base = max(0.0, base) + base_terrain3d_offset; + height = max(0.0, height) + height_terrain3d_offset; + + float t = mod(normal.x, 2.0); + + gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1); + + // Relative luminance (how dark/bright is the surface color?) + float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722; + + v_color = vec4(0.0, 0.0, 0.0, 1.0); + + // Add slight ambient lighting so no extrusions are totally black + vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0); + color += ambientlight; + + // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray + float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0); + + // Adjust directional so that + // the range of values for highlight/shading is narrower + // with lower light intensity + // and with lighter/brighter surface colors + directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional); + + // Add gradient along z axis of side surfaces + if (normal.y != 0.0) { + // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, + // and otherwise calculates the gradient based on base + height + directional *= ( + (1.0 - u_vertical_gradient) + + (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); + } + + // Assign final color based on surface + ambient light color, diffuse light directional, and light color + // with lower bounds adjusted to hue of light + // so that shading is tinted with the complementary (opposite) color to the light color + v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0); + v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0); + v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0); + v_color *= u_opacity; +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.vertex.glsl.g.ts new file mode 100644 index 00000000..a394685a --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.fragment.glsl new file mode 100644 index 00000000..c498a367 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.fragment.glsl @@ -0,0 +1,47 @@ +uniform vec2 u_texsize; +uniform float u_fade; + +uniform sampler2D u_image; + +in vec2 v_pos_a; +in vec2 v_pos_b; +in vec4 v_lighting; + +#pragma mapbox: define lowp float base +#pragma mapbox: define lowp float height +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to +#pragma mapbox: define lowp float pixel_ratio_from +#pragma mapbox: define lowp float pixel_ratio_to + + + +void main() { + #pragma mapbox: initialize lowp float base + #pragma mapbox: initialize lowp float height + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float pixel_ratio_from + #pragma mapbox: initialize lowp float pixel_ratio_to + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + vec2 imagecoord = mod(v_pos_a, 1.0); + vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); + vec4 color1 = texture(u_image, pos); + + vec2 imagecoord_b = mod(v_pos_b, 1.0); + vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); + vec4 color2 = texture(u_image, pos2); + + vec4 mixedColor = mix(color1, color2, u_fade); + + fragColor = mixedColor * v_lighting; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts new file mode 100644 index 00000000..ea1d8ca1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.vertex.glsl new file mode 100644 index 00000000..eecc343a --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.vertex.glsl @@ -0,0 +1,96 @@ +uniform mat4 u_matrix; +uniform vec2 u_pixel_coord_upper; +uniform vec2 u_pixel_coord_lower; +uniform float u_height_factor; +uniform vec3 u_scale; +uniform float u_vertical_gradient; +uniform lowp float u_opacity; + +uniform vec3 u_lightcolor; +uniform lowp vec3 u_lightpos; +uniform lowp float u_lightintensity; + +in vec2 a_pos; +in vec4 a_normal_ed; + +#ifdef TERRAIN3D + in vec2 a_centroid; +#endif + +out vec2 v_pos_a; +out vec2 v_pos_b; +out vec4 v_lighting; + +#pragma mapbox: define lowp float base +#pragma mapbox: define lowp float height +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to +#pragma mapbox: define lowp float pixel_ratio_from +#pragma mapbox: define lowp float pixel_ratio_to + +void main() { + #pragma mapbox: initialize lowp float base + #pragma mapbox: initialize lowp float height + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float pixel_ratio_from + #pragma mapbox: initialize lowp float pixel_ratio_to + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + float tileRatio = u_scale.x; + float fromScale = u_scale.y; + float toScale = u_scale.z; + + vec3 normal = a_normal_ed.xyz; + float edgedistance = a_normal_ed.w; + + vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixel_ratio_from; + vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixel_ratio_to; + + #ifdef TERRAIN3D + // Raise the "ceiling" of elements by the elevation of the centroid, in meters. + float height_terrain3d_offset = get_elevation(a_centroid); + // To avoid having buildings "hang above a slope", create a "basement" + // by lowering the "floor" of ground-level (and below) elements. + // This is in addition to the elevation of the centroid, in meters. + float base_terrain3d_offset = height_terrain3d_offset - (base > 0.0 ? 0.0 : 10.0); + #else + float height_terrain3d_offset = 0.0; + float base_terrain3d_offset = 0.0; + #endif + // Sub-terranian "floors and ceilings" are clamped to ground-level. + // 3D Terrain offsets, if applicable, are applied on the result. + base = max(0.0, base) + base_terrain3d_offset; + height = max(0.0, height) + height_terrain3d_offset; + + float t = mod(normal.x, 2.0); + float z = t > 0.0 ? height : base; + + gl_Position = u_matrix * vec4(a_pos, z, 1); + + vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0 + ? a_pos // extrusion top + : vec2(edgedistance, z * u_height_factor); // extrusion side + + v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, pos); + v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, pos); + + v_lighting = vec4(0.0, 0.0, 0.0, 1.0); + float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0); + directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional); + + if (normal.y != 0.0) { + // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, + // and otherwise calculates the gradient based on base + height + directional *= ( + (1.0 - u_vertical_gradient) + + (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); + } + + v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0)); + v_lighting *= u_opacity; +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts new file mode 100644 index 00000000..e204d825 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/fill_outline.fragment.glsl new file mode 100644 index 00000000..f13b94ed --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline.fragment.glsl @@ -0,0 +1,17 @@ +in vec2 v_pos; + +#pragma mapbox: define highp vec4 outline_color +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize highp vec4 outline_color + #pragma mapbox: initialize lowp float opacity + + float dist = length(v_pos - gl_FragCoord.xy); + float alpha = 1.0 - smoothstep(0.0, 1.0, dist); + fragColor = outline_color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_outline.fragment.glsl.g.ts new file mode 100644 index 00000000..b276f3ae --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/fill_outline.vertex.glsl new file mode 100644 index 00000000..a4a654fe --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline.vertex.glsl @@ -0,0 +1,17 @@ +in vec2 a_pos; + +uniform mat4 u_matrix; +uniform vec2 u_world; + +out vec2 v_pos; + +#pragma mapbox: define highp vec4 outline_color +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize highp vec4 outline_color + #pragma mapbox: initialize lowp float opacity + + gl_Position = u_matrix * vec4(a_pos, 0, 1); + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_outline.vertex.glsl.g.ts new file mode 100644 index 00000000..6875238e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.fragment.glsl new file mode 100644 index 00000000..07984c71 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.fragment.glsl @@ -0,0 +1,43 @@ + +uniform vec2 u_texsize; +uniform sampler2D u_image; +uniform float u_fade; + +in vec2 v_pos_a; +in vec2 v_pos_b; +in vec2 v_pos; + +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to + +void main() { + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + vec2 imagecoord = mod(v_pos_a, 1.0); + vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); + vec4 color1 = texture(u_image, pos); + + vec2 imagecoord_b = mod(v_pos_b, 1.0); + vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); + vec4 color2 = texture(u_image, pos2); + + // find distance to outline for alpha interpolation + + float dist = length(v_pos - gl_FragCoord.xy); + float alpha = 1.0 - smoothstep(0.0, 1.0, dist); + + + fragColor = mix(color1, color2, u_fade) * alpha * opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.fragment.glsl.g.ts new file mode 100644 index 00000000..be452f34 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.vertex.glsl new file mode 100644 index 00000000..f19ddd6e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.vertex.glsl @@ -0,0 +1,44 @@ +uniform mat4 u_matrix; +uniform vec2 u_world; +uniform vec2 u_pixel_coord_upper; +uniform vec2 u_pixel_coord_lower; +uniform vec3 u_scale; + +in vec2 a_pos; + +out vec2 v_pos_a; +out vec2 v_pos_b; +out vec2 v_pos; + +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to +#pragma mapbox: define lowp float pixel_ratio_from +#pragma mapbox: define lowp float pixel_ratio_to + +void main() { + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float pixel_ratio_from + #pragma mapbox: initialize lowp float pixel_ratio_to + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + float tileRatio = u_scale.x; + float fromScale = u_scale.y; + float toScale = u_scale.z; + + gl_Position = u_matrix * vec4(a_pos, 0, 1); + + vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixel_ratio_from; + vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixel_ratio_to; + + v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos); + v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos); + + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.vertex.glsl.g.ts new file mode 100644 index 00000000..8136e1ee --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_outline_pattern.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_pattern.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/fill_pattern.fragment.glsl new file mode 100644 index 00000000..989784a6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_pattern.fragment.glsl @@ -0,0 +1,39 @@ +#ifdef GL_ES + precision highp float; +#endif +uniform vec2 u_texsize; +uniform float u_fade; + +uniform sampler2D u_image; + +in vec2 v_pos_a; +in vec2 v_pos_b; + +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to + +void main() { + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + vec2 imagecoord = mod(v_pos_a, 1.0); + vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); + vec4 color1 = texture(u_image, pos); + + vec2 imagecoord_b = mod(v_pos_b, 1.0); + vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); + vec4 color2 = texture(u_image, pos2); + + fragColor = mix(color1, color2, u_fade) * opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_pattern.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_pattern.fragment.glsl.g.ts new file mode 100644 index 00000000..ba08cecc --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_pattern.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/fill_pattern.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/fill_pattern.vertex.glsl new file mode 100644 index 00000000..abdaafb2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_pattern.vertex.glsl @@ -0,0 +1,39 @@ +uniform mat4 u_matrix; +uniform vec2 u_pixel_coord_upper; +uniform vec2 u_pixel_coord_lower; +uniform vec3 u_scale; + +in vec2 a_pos; + +out vec2 v_pos_a; +out vec2 v_pos_b; + +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to +#pragma mapbox: define lowp float pixel_ratio_from +#pragma mapbox: define lowp float pixel_ratio_to + +void main() { + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float pixel_ratio_from + #pragma mapbox: initialize lowp float pixel_ratio_to + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + float tileZoomRatio = u_scale.x; + float fromScale = u_scale.y; + float toScale = u_scale.z; + + vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixel_ratio_from; + vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixel_ratio_to; + gl_Position = u_matrix * vec4(a_pos, 0, 1); + + v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, a_pos); + v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos); +} diff --git a/web/libraries/maplibre-gl/src/shaders/fill_pattern.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/fill_pattern.vertex.glsl.g.ts new file mode 100644 index 00000000..b5d74628 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/fill_pattern.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/heatmap.fragment.glsl new file mode 100644 index 00000000..bd6aaa51 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap.fragment.glsl @@ -0,0 +1,22 @@ +uniform highp float u_intensity; + +in vec2 v_extrude; + +#pragma mapbox: define highp float weight + +// Gaussian kernel coefficient: 1 / sqrt(2 * PI) +#define GAUSS_COEF 0.3989422804014327 + +void main() { + #pragma mapbox: initialize highp float weight + + // Kernel density estimation with a Gaussian kernel of size 5x5 + float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude); + float val = weight * u_intensity * GAUSS_COEF * exp(d); + + fragColor = vec4(val, 1.0, 1.0, 1.0); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/heatmap.fragment.glsl.g.ts new file mode 100644 index 00000000..d4e7e405 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/heatmap.vertex.glsl new file mode 100644 index 00000000..1b4bdcb6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap.vertex.glsl @@ -0,0 +1,54 @@ + +uniform mat4 u_matrix; +uniform float u_extrude_scale; +uniform float u_opacity; +uniform float u_intensity; + +in vec2 a_pos; + +out vec2 v_extrude; + +#pragma mapbox: define highp float weight +#pragma mapbox: define mediump float radius + +// Effective "0" in the kernel density texture to adjust the kernel size to; +// this empirically chosen number minimizes artifacts on overlapping kernels +// for typical heatmap cases (assuming clustered source) +const highp float ZERO = 1.0 / 255.0 / 16.0; + +// Gaussian kernel coefficient: 1 / sqrt(2 * PI) +#define GAUSS_COEF 0.3989422804014327 + +void main(void) { + #pragma mapbox: initialize highp float weight + #pragma mapbox: initialize mediump float radius + + // unencode the extrusion vector that we snuck into the a_pos vector + vec2 unscaled_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); + + // This 'extrude' comes in ranging from [-1, -1], to [1, 1]. We'll use + // it to produce the vertices of a square mesh framing the point feature + // we're adding to the kernel density texture. We'll also pass it as + // a out, so that the fragment shader can determine the distance of + // each fragment from the point feature. + // Before we do so, we need to scale it up sufficiently so that the + // kernel falls effectively to zero at the edge of the mesh. + // That is, we want to know S such that + // weight * u_intensity * GAUSS_COEF * exp(-0.5 * 3.0^2 * S^2) == ZERO + // Which solves to: + // S = sqrt(-2.0 * log(ZERO / (weight * u_intensity * GAUSS_COEF))) / 3.0 + float S = sqrt(-2.0 * log(ZERO / weight / u_intensity / GAUSS_COEF)) / 3.0; + + // Pass the out in units of radius + v_extrude = S * unscaled_extrude; + + // Scale by radius and the zoom-based scale factor to produce actual + // mesh position + vec2 extrude = v_extrude * radius * u_extrude_scale; + + // multiply a_pos by 0.5, since we had it * 2 in order to sneak + // in extrusion data + vec4 pos = vec4(floor(a_pos * 0.5) + extrude, 0, 1); + + gl_Position = u_matrix * pos; +} diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/heatmap.vertex.glsl.g.ts new file mode 100644 index 00000000..82dc209e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap_texture.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.fragment.glsl new file mode 100644 index 00000000..5efcd354 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.fragment.glsl @@ -0,0 +1,15 @@ +uniform sampler2D u_image; +uniform sampler2D u_color_ramp; +uniform float u_opacity; + +in vec2 v_pos; + +void main() { + float t = texture(u_image, v_pos).r; + vec4 color = texture(u_color_ramp, vec2(t, 0.5)); + fragColor = color * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(0.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap_texture.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.fragment.glsl.g.ts new file mode 100644 index 00000000..97548fe2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap_texture.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.vertex.glsl new file mode 100644 index 00000000..d9db180c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.vertex.glsl @@ -0,0 +1,11 @@ +uniform mat4 u_matrix; +uniform vec2 u_world; +in vec2 a_pos; +out vec2 v_pos; + +void main() { + gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); + + v_pos.x = a_pos.x; + v_pos.y = 1.0 - a_pos.y; +} diff --git a/web/libraries/maplibre-gl/src/shaders/heatmap_texture.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.vertex.glsl.g.ts new file mode 100644 index 00000000..2b97491e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/heatmap_texture.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/hillshade.fragment.glsl new file mode 100644 index 00000000..1b4842d7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade.fragment.glsl @@ -0,0 +1,52 @@ +uniform sampler2D u_image; +in vec2 v_pos; + +uniform vec2 u_latrange; +uniform vec2 u_light; +uniform vec4 u_shadow; +uniform vec4 u_highlight; +uniform vec4 u_accent; + +#define PI 3.141592653589793 + +void main() { + vec4 pixel = texture(u_image, v_pos); + + vec2 deriv = ((pixel.rg * 2.0) - 1.0); + + // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude + // to account for mercator projection distortion. see #4807 for details + float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1])); + // We also multiply the slope by an arbitrary z-factor of 1.25 + float slope = atan(1.25 * length(deriv) / scaleFactor); + float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0); + + float intensity = u_light.x; + // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal + // position property to account for 0deg corresponding to north/the top of the viewport in the style spec + // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal. + float azimuth = u_light.y + PI; + + // We scale the slope exponentially based on intensity, using a calculation similar to + // the exponential interpolation function in the style spec: + // src/style-spec/expression/definitions/interpolate.js#L217-L228 + // so that higher intensity values create more opaque hillshading. + float base = 1.875 - intensity * 1.75; + float maxValue = 0.5 * PI; + float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope; + + // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine + // so that the accent color's rate of change eases in while the shade color's eases out. + float accent = cos(scaledSlope); + // We multiply both the accent and shade color by a clamped intensity value + // so that intensities >= 0.5 do not additionally affect the color values + // while intensity values < 0.5 make the overall color more transparent. + vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0); + float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0); + vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0); + fragColor = accent_color * (1.0 - shade_color.a) + shade_color; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/hillshade.fragment.glsl.g.ts new file mode 100644 index 00000000..feb0162c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/hillshade.vertex.glsl new file mode 100644 index 00000000..10108d96 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade.vertex.glsl @@ -0,0 +1,11 @@ +uniform mat4 u_matrix; + +in vec2 a_pos; +in vec2 a_texture_pos; + +out vec2 v_pos; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); + v_pos = a_texture_pos / 8192.0; +} diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/hillshade.vertex.glsl.g.ts new file mode 100644 index 00000000..f5d82ebc --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.fragment.glsl new file mode 100644 index 00000000..2192aeaf --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.fragment.glsl @@ -0,0 +1,77 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D u_image; +in vec2 v_pos; + + +uniform vec2 u_dimension; +uniform float u_zoom; +uniform vec4 u_unpack; + +float getElevation(vec2 coord, float bias) { + // Convert encoded elevation value to meters + vec4 data = texture(u_image, coord) * 255.0; + data.a = -1.0; + return dot(data, u_unpack) / 4.0; +} + +void main() { + vec2 epsilon = 1.0 / u_dimension; + + // queried pixels: + // +-----------+ + // | | | | + // | a | b | c | + // | | | | + // +-----------+ + // | | | | + // | d | e | f | + // | | | | + // +-----------+ + // | | | | + // | g | h | i | + // | | | | + // +-----------+ + + float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0); + float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0); + float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0); + float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0); + float e = getElevation(v_pos, 0.0); + float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0); + float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0); + float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0); + float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0); + + // Here we divide the x and y slopes by 8 * pixel size + // where pixel size (aka meters/pixel) is: + // circumference of the world / (pixels per tile * number of tiles) + // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom)) + // which can be reduced to: pow(2, 19.25619978527 - u_zoom). + // We want to vertically exaggerate the hillshading because otherwise + // it is barely noticeable at low zooms. To do this, we multiply this by + // a scale factor that is a function of zooms below 15, which is an arbitrary + // that corresponds to the max zoom level of Mapbox terrain-RGB tiles. + // See nickidlugash's awesome breakdown for more info: + // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556 + + float exaggerationFactor = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3; + float exaggeration = u_zoom < 15.0 ? (u_zoom - 15.0) * exaggerationFactor : 0.0; + + vec2 deriv = vec2( + (c + f + f + i) - (a + d + d + g), + (g + h + h + i) - (a + b + b + c) + ) / pow(2.0, exaggeration + (19.2562 - u_zoom)); + + fragColor = clamp(vec4( + deriv.x / 2.0 + 0.5, + deriv.y / 2.0 + 0.5, + 1.0, + 1.0), 0.0, 1.0); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.fragment.glsl.g.ts new file mode 100644 index 00000000..30b50cec --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.vertex.glsl new file mode 100644 index 00000000..4133d46a --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.vertex.glsl @@ -0,0 +1,15 @@ +uniform mat4 u_matrix; +uniform vec2 u_dimension; + +in vec2 a_pos; +in vec2 a_texture_pos; + +out vec2 v_pos; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); + + highp vec2 epsilon = 1.0 / u_dimension; + float scale = (u_dimension.x - 2.0) / u_dimension.x; + v_pos = (a_texture_pos / 8192.0) * scale + epsilon; +} diff --git a/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.vertex.glsl.g.ts new file mode 100644 index 00000000..9d8db4d5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/hillshade_prepare.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/line.fragment.glsl new file mode 100644 index 00000000..4ea11c11 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line.fragment.glsl @@ -0,0 +1,30 @@ +uniform lowp float u_device_pixel_ratio; + +in vec2 v_width2; +in vec2 v_normal; +in float v_gamma_scale; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + + // Calculate the distance of the pixel from the line in pixels. + float dist = length(v_normal) * v_width2.s; + + // Calculate the antialiasing fade factor. This is either when fading in + // the line in case of an offset line (v_width2.t) or when fading out + // (v_width2.s) + float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); + + fragColor = color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/line.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line.fragment.glsl.g.ts new file mode 100644 index 00000000..06048acf --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/line.vertex.glsl new file mode 100644 index 00000000..457c0668 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line.vertex.glsl @@ -0,0 +1,89 @@ +// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define scale 0.015873016 + +in vec2 a_pos_normal; +in vec4 a_data; + +uniform mat4 u_matrix; +uniform mediump float u_ratio; +uniform vec2 u_units_to_pixels; +uniform lowp float u_device_pixel_ratio; + +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; +out highp float v_linesofar; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define mediump float gapwidth +#pragma mapbox: define lowp float offset +#pragma mapbox: define mediump float width + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump float gapwidth + #pragma mapbox: initialize lowp float offset + #pragma mapbox: initialize mediump float width + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + + v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0; + + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist = outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + #ifdef TERRAIN3D + v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh + #else + float extrude_length_without_perspective = length(dist); + float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); + v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; + #endif + + v_width2 = vec2(outset, inset); +} diff --git a/web/libraries/maplibre-gl/src/shaders/line.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line.vertex.glsl.g.ts new file mode 100644 index 00000000..1e036ba2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line_gradient.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/line_gradient.fragment.glsl new file mode 100644 index 00000000..fb4221f4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_gradient.fragment.glsl @@ -0,0 +1,34 @@ +uniform lowp float u_device_pixel_ratio; +uniform sampler2D u_image; + +in vec2 v_width2; +in vec2 v_normal; +in float v_gamma_scale; +in highp vec2 v_uv; + +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + + // Calculate the distance of the pixel from the line in pixels. + float dist = length(v_normal) * v_width2.s; + + // Calculate the antialiasing fade factor. This is either when fading in + // the line in case of an offset line (v_width2.t) or when fading out + // (v_width2.s) + float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); + + // For gradient lines, v_lineprogress is the ratio along the + // entire line, the gradient ramp is stored in a texture. + vec4 color = texture(u_image, v_uv); + + fragColor = color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/line_gradient.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line_gradient.fragment.glsl.g.ts new file mode 100644 index 00000000..5e638261 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_gradient.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line_gradient.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/line_gradient.vertex.glsl new file mode 100644 index 00000000..7872b2f3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_gradient.vertex.glsl @@ -0,0 +1,92 @@ +// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define scale 0.015873016 + +in vec2 a_pos_normal; +in vec4 a_data; +in float a_uv_x; +in float a_split_index; + +uniform mat4 u_matrix; +uniform mediump float u_ratio; +uniform lowp float u_device_pixel_ratio; +uniform vec2 u_units_to_pixels; +uniform float u_image_height; + +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; +out highp vec2 v_uv; + +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define mediump float gapwidth +#pragma mapbox: define lowp float offset +#pragma mapbox: define mediump float width + +void main() { + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump float gapwidth + #pragma mapbox: initialize lowp float offset + #pragma mapbox: initialize mediump float width + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + + highp float texel_height = 1.0 / u_image_height; + highp float half_texel_height = 0.5 * texel_height; + v_uv = vec2(a_uv_x, a_split_index * texel_height - half_texel_height); + + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist = outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + #ifdef TERRAIN3D + v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh + #else + float extrude_length_without_perspective = length(dist); + float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); + v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; + #endif + + v_width2 = vec2(outset, inset); +} diff --git a/web/libraries/maplibre-gl/src/shaders/line_gradient.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line_gradient.vertex.glsl.g.ts new file mode 100644 index 00000000..cec2d901 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_gradient.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line_pattern.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/line_pattern.fragment.glsl new file mode 100644 index 00000000..2ab4bd70 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_pattern.fragment.glsl @@ -0,0 +1,77 @@ +#ifdef GL_ES + precision highp float; +#endif +uniform lowp float u_device_pixel_ratio; +uniform vec2 u_texsize; +uniform float u_fade; +uniform mediump vec3 u_scale; + +uniform sampler2D u_image; + +in vec2 v_normal; +in vec2 v_width2; +in float v_linesofar; +in float v_gamma_scale; +in float v_width; + +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to +#pragma mapbox: define lowp float pixel_ratio_from +#pragma mapbox: define lowp float pixel_ratio_to +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float pixel_ratio_from + #pragma mapbox: initialize lowp float pixel_ratio_to + + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + + vec2 pattern_tl_a = pattern_from.xy; + vec2 pattern_br_a = pattern_from.zw; + vec2 pattern_tl_b = pattern_to.xy; + vec2 pattern_br_b = pattern_to.zw; + + float tileZoomRatio = u_scale.x; + float fromScale = u_scale.y; + float toScale = u_scale.z; + + vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixel_ratio_from; + vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixel_ratio_to; + + vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y); + vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y); + + float aspect_a = display_size_a.y / v_width; + float aspect_b = display_size_b.y / v_width; + + // Calculate the distance of the pixel from the line in pixels. + float dist = length(v_normal) * v_width2.s; + + // Calculate the antialiasing fade factor. This is either when fading in + // the line in case of an offset line (v_width2.t) or when fading out + // (v_width2.s) + float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); + + float x_a = mod(v_linesofar / pattern_size_a.x * aspect_a, 1.0); + float x_b = mod(v_linesofar / pattern_size_b.x * aspect_b, 1.0); + + float y = 0.5 * v_normal.y + 0.5; + + vec2 texel_size = 1.0 / u_texsize; + + vec2 pos_a = mix(pattern_tl_a * texel_size - texel_size, pattern_br_a * texel_size + texel_size, vec2(x_a, y)); + vec2 pos_b = mix(pattern_tl_b * texel_size - texel_size, pattern_br_b * texel_size + texel_size, vec2(x_b, y)); + + vec4 color = mix(texture(u_image, pos_a), texture(u_image, pos_b), u_fade); + + fragColor = color * alpha * opacity; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/line_pattern.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line_pattern.fragment.glsl.g.ts new file mode 100644 index 00000000..7372026f --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_pattern.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line_pattern.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/line_pattern.vertex.glsl new file mode 100644 index 00000000..70b668cf --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_pattern.vertex.glsl @@ -0,0 +1,103 @@ +// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define scale 0.015873016 + +// We scale the distance before adding it to the buffers so that we can store +// long distances for long segments. Use this value to unscale the distance. +#define LINE_DISTANCE_SCALE 2.0 + +in vec2 a_pos_normal; +in vec4 a_data; + +uniform mat4 u_matrix; +uniform vec2 u_units_to_pixels; +uniform mediump float u_ratio; +uniform lowp float u_device_pixel_ratio; + +out vec2 v_normal; +out vec2 v_width2; +out float v_linesofar; +out float v_gamma_scale; +out float v_width; + +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp float offset +#pragma mapbox: define mediump float gapwidth +#pragma mapbox: define mediump float width +#pragma mapbox: define lowp float floorwidth +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to +#pragma mapbox: define lowp float pixel_ratio_from +#pragma mapbox: define lowp float pixel_ratio_to + +void main() { + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize lowp float offset + #pragma mapbox: initialize mediump float gapwidth + #pragma mapbox: initialize mediump float width + #pragma mapbox: initialize lowp float floorwidth + #pragma mapbox: initialize mediump vec4 pattern_from + #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float pixel_ratio_from + #pragma mapbox: initialize lowp float pixel_ratio_to + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE; + // float tileRatio = u_scale.x; + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist = outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + #ifdef TERRAIN3D + v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh + #else + float extrude_length_without_perspective = length(dist); + float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); + v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; + #endif + + v_linesofar = a_linesofar; + v_width2 = vec2(outset, inset); + v_width = floorwidth; +} diff --git a/web/libraries/maplibre-gl/src/shaders/line_pattern.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line_pattern.vertex.glsl.g.ts new file mode 100644 index 00000000..685c48c9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_pattern.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line_sdf.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/line_sdf.fragment.glsl new file mode 100644 index 00000000..3cbd2c9b --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_sdf.fragment.glsl @@ -0,0 +1,45 @@ + +uniform lowp float u_device_pixel_ratio; +uniform sampler2D u_image; +uniform float u_sdfgamma; +uniform float u_mix; + +in vec2 v_normal; +in vec2 v_width2; +in vec2 v_tex_a; +in vec2 v_tex_b; +in float v_gamma_scale; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define mediump float width +#pragma mapbox: define lowp float floorwidth + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump float width + #pragma mapbox: initialize lowp float floorwidth + + // Calculate the distance of the pixel from the line in pixels. + float dist = length(v_normal) * v_width2.s; + + // Calculate the antialiasing fade factor. This is either when fading in + // the line in case of an offset line (v_width2.t) or when fading out + // (v_width2.s) + float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); + + float sdfdist_a = texture(u_image, v_tex_a).a; + float sdfdist_b = texture(u_image, v_tex_b).a; + float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix); + alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist); + + fragColor = color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/line_sdf.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line_sdf.fragment.glsl.g.ts new file mode 100644 index 00000000..dbcaacda --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_sdf.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/line_sdf.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/line_sdf.vertex.glsl new file mode 100644 index 00000000..3324b63c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_sdf.vertex.glsl @@ -0,0 +1,101 @@ +// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define scale 0.015873016 + +// We scale the distance before adding it to the buffers so that we can store +// long distances for long segments. Use this value to unscale the distance. +#define LINE_DISTANCE_SCALE 2.0 + +in vec2 a_pos_normal; +in vec4 a_data; + +uniform mat4 u_matrix; +uniform mediump float u_ratio; +uniform lowp float u_device_pixel_ratio; +uniform vec2 u_patternscale_a; +uniform float u_tex_y_a; +uniform vec2 u_patternscale_b; +uniform float u_tex_y_b; +uniform vec2 u_units_to_pixels; + +out vec2 v_normal; +out vec2 v_width2; +out vec2 v_tex_a; +out vec2 v_tex_b; +out float v_gamma_scale; + +#pragma mapbox: define highp vec4 color +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define mediump float gapwidth +#pragma mapbox: define lowp float offset +#pragma mapbox: define mediump float width +#pragma mapbox: define lowp float floorwidth + +void main() { + #pragma mapbox: initialize highp vec4 color + #pragma mapbox: initialize lowp float blur + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize mediump float gapwidth + #pragma mapbox: initialize lowp float offset + #pragma mapbox: initialize mediump float width + #pragma mapbox: initialize lowp float floorwidth + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE; + + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist =outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + #ifdef TERRAIN3D + v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh + #else + float extrude_length_without_perspective = length(dist); + float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); + v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; + #endif + + v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a); + v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b); + v_width2 = vec2(outset, inset); +} diff --git a/web/libraries/maplibre-gl/src/shaders/line_sdf.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/line_sdf.vertex.glsl.g.ts new file mode 100644 index 00000000..8b0d85e2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/line_sdf.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/raster.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/raster.fragment.glsl new file mode 100644 index 00000000..8b8c55c1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/raster.fragment.glsl @@ -0,0 +1,53 @@ +uniform float u_fade_t; +uniform float u_opacity; +uniform sampler2D u_image0; +uniform sampler2D u_image1; + +in vec2 v_pos0; +in vec2 v_pos1; + +uniform float u_brightness_low; +uniform float u_brightness_high; + +uniform float u_saturation_factor; +uniform float u_contrast_factor; +uniform vec3 u_spin_weights; + +void main() { + + // read and cross-fade colors from the main and parent tiles + vec4 color0 = texture(u_image0, v_pos0); + vec4 color1 = texture(u_image1, v_pos1); + if (color0.a > 0.0) { + color0.rgb = color0.rgb / color0.a; + } + if (color1.a > 0.0) { + color1.rgb = color1.rgb / color1.a; + } + vec4 color = mix(color0, color1, u_fade_t); + color.a *= u_opacity; + vec3 rgb = color.rgb; + + // spin + rgb = vec3( + dot(rgb, u_spin_weights.xyz), + dot(rgb, u_spin_weights.zxy), + dot(rgb, u_spin_weights.yzx)); + + // saturation + float average = (color.r + color.g + color.b) / 3.0; + rgb += (average - rgb) * u_saturation_factor; + + // contrast + rgb = (rgb - 0.5) * u_contrast_factor + 0.5; + + // brightness + vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low); + vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high); + + fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/raster.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/raster.fragment.glsl.g.ts new file mode 100644 index 00000000..1fb97c80 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/raster.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/raster.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/raster.vertex.glsl new file mode 100644 index 00000000..04166a0c --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/raster.vertex.glsl @@ -0,0 +1,21 @@ +uniform mat4 u_matrix; +uniform vec2 u_tl_parent; +uniform float u_scale_parent; +uniform float u_buffer_scale; + +in vec2 a_pos; +in vec2 a_texture_pos; + +out vec2 v_pos0; +out vec2 v_pos1; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); + // We are using Int16 for texture position coordinates to give us enough precision for + // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer + // as an arbitrarily high number to preserve adequate precision when rendering. + // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates, + // so math for modifying either is consistent. + v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5; + v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent; +} diff --git a/web/libraries/maplibre-gl/src/shaders/raster.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/raster.vertex.glsl.g.ts new file mode 100644 index 00000000..1d412fea --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/raster.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/shaders.ts b/web/libraries/maplibre-gl/src/shaders/shaders.ts new file mode 100644 index 00000000..383df3c9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/shaders.ts @@ -0,0 +1,193 @@ + +// Disable Flow annotations here because Flow doesn't support importing GLSL files + +import preludeFrag from './_prelude.fragment.glsl.g'; +import preludeVert from './_prelude.vertex.glsl.g'; +import backgroundFrag from './background.fragment.glsl.g'; +import backgroundVert from './background.vertex.glsl.g'; +import backgroundPatternFrag from './background_pattern.fragment.glsl.g'; +import backgroundPatternVert from './background_pattern.vertex.glsl.g'; +import circleFrag from './circle.fragment.glsl.g'; +import circleVert from './circle.vertex.glsl.g'; +import clippingMaskFrag from './clipping_mask.fragment.glsl.g'; +import clippingMaskVert from './clipping_mask.vertex.glsl.g'; +import heatmapFrag from './heatmap.fragment.glsl.g'; +import heatmapVert from './heatmap.vertex.glsl.g'; +import heatmapTextureFrag from './heatmap_texture.fragment.glsl.g'; +import heatmapTextureVert from './heatmap_texture.vertex.glsl.g'; +import collisionBoxFrag from './collision_box.fragment.glsl.g'; +import collisionBoxVert from './collision_box.vertex.glsl.g'; +import collisionCircleFrag from './collision_circle.fragment.glsl.g'; +import collisionCircleVert from './collision_circle.vertex.glsl.g'; +import debugFrag from './debug.fragment.glsl.g'; +import debugVert from './debug.vertex.glsl.g'; +import fillFrag from './fill.fragment.glsl.g'; +import fillVert from './fill.vertex.glsl.g'; +import fillOutlineFrag from './fill_outline.fragment.glsl.g'; +import fillOutlineVert from './fill_outline.vertex.glsl.g'; +import fillOutlinePatternFrag from './fill_outline_pattern.fragment.glsl.g'; +import fillOutlinePatternVert from './fill_outline_pattern.vertex.glsl.g'; +import fillPatternFrag from './fill_pattern.fragment.glsl.g'; +import fillPatternVert from './fill_pattern.vertex.glsl.g'; +import fillExtrusionFrag from './fill_extrusion.fragment.glsl.g'; +import fillExtrusionVert from './fill_extrusion.vertex.glsl.g'; +import fillExtrusionPatternFrag from './fill_extrusion_pattern.fragment.glsl.g'; +import fillExtrusionPatternVert from './fill_extrusion_pattern.vertex.glsl.g'; +import hillshadePrepareFrag from './hillshade_prepare.fragment.glsl.g'; +import hillshadePrepareVert from './hillshade_prepare.vertex.glsl.g'; +import hillshadeFrag from './hillshade.fragment.glsl.g'; +import hillshadeVert from './hillshade.vertex.glsl.g'; +import lineFrag from './line.fragment.glsl.g'; +import lineVert from './line.vertex.glsl.g'; +import lineGradientFrag from './line_gradient.fragment.glsl.g'; +import lineGradientVert from './line_gradient.vertex.glsl.g'; +import linePatternFrag from './line_pattern.fragment.glsl.g'; +import linePatternVert from './line_pattern.vertex.glsl.g'; +import lineSDFFrag from './line_sdf.fragment.glsl.g'; +import lineSDFVert from './line_sdf.vertex.glsl.g'; +import rasterFrag from './raster.fragment.glsl.g'; +import rasterVert from './raster.vertex.glsl.g'; +import symbolIconFrag from './symbol_icon.fragment.glsl.g'; +import symbolIconVert from './symbol_icon.vertex.glsl.g'; +import symbolSDFFrag from './symbol_sdf.fragment.glsl.g'; +import symbolSDFVert from './symbol_sdf.vertex.glsl.g'; +import symbolTextAndIconFrag from './symbol_text_and_icon.fragment.glsl.g'; +import symbolTextAndIconVert from './symbol_text_and_icon.vertex.glsl.g'; +import terrainDepthFrag from './terrain_depth.fragment.glsl.g'; +import terrainCoordsFrag from './terrain_coords.fragment.glsl.g'; +import terrainFrag from './terrain.fragment.glsl.g'; +import terrainVert from './terrain.vertex.glsl.g'; + +export const shaders = { + prelude: compile(preludeFrag, preludeVert), + background: compile(backgroundFrag, backgroundVert), + backgroundPattern: compile(backgroundPatternFrag, backgroundPatternVert), + circle: compile(circleFrag, circleVert), + clippingMask: compile(clippingMaskFrag, clippingMaskVert), + heatmap: compile(heatmapFrag, heatmapVert), + heatmapTexture: compile(heatmapTextureFrag, heatmapTextureVert), + collisionBox: compile(collisionBoxFrag, collisionBoxVert), + collisionCircle: compile(collisionCircleFrag, collisionCircleVert), + debug: compile(debugFrag, debugVert), + fill: compile(fillFrag, fillVert), + fillOutline: compile(fillOutlineFrag, fillOutlineVert), + fillOutlinePattern: compile(fillOutlinePatternFrag, fillOutlinePatternVert), + fillPattern: compile(fillPatternFrag, fillPatternVert), + fillExtrusion: compile(fillExtrusionFrag, fillExtrusionVert), + fillExtrusionPattern: compile(fillExtrusionPatternFrag, fillExtrusionPatternVert), + hillshadePrepare: compile(hillshadePrepareFrag, hillshadePrepareVert), + hillshade: compile(hillshadeFrag, hillshadeVert), + line: compile(lineFrag, lineVert), + lineGradient: compile(lineGradientFrag, lineGradientVert), + linePattern: compile(linePatternFrag, linePatternVert), + lineSDF: compile(lineSDFFrag, lineSDFVert), + raster: compile(rasterFrag, rasterVert), + symbolIcon: compile(symbolIconFrag, symbolIconVert), + symbolSDF: compile(symbolSDFFrag, symbolSDFVert), + symbolTextAndIcon: compile(symbolTextAndIconFrag, symbolTextAndIconVert), + terrain: compile(terrainFrag, terrainVert), + terrainDepth: compile(terrainDepthFrag, terrainVert), + terrainCoords: compile(terrainCoordsFrag, terrainVert) +}; + +// Expand #pragmas to #ifdefs. + +function compile(fragmentSource, vertexSource) { + const re = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g; + + const staticAttributes = vertexSource.match(/attribute ([\w]+) ([\w]+)/g); + const fragmentUniforms = fragmentSource.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g); + const vertexUniforms = vertexSource.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g); + const staticUniforms = vertexUniforms ? vertexUniforms.concat(fragmentUniforms) : fragmentUniforms; + + const fragmentPragmas = {}; + + fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => { + fragmentPragmas[name] = true; + if (operation === 'define') { + return ` +#ifndef HAS_UNIFORM_u_${name} +varying ${precision} ${type} ${name}; +#else +uniform ${precision} ${type} u_${name}; +#endif +`; + } else /* if (operation === 'initialize') */ { + return ` +#ifdef HAS_UNIFORM_u_${name} + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + }); + + vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => { + const attrType = type === 'float' ? 'vec2' : 'vec4'; + const unpackType = name.match(/color/) ? 'color' : attrType; + + if (fragmentPragmas[name]) { + if (operation === 'define') { + return ` +#ifndef HAS_UNIFORM_u_${name} +uniform lowp float u_${name}_t; +attribute ${precision} ${attrType} a_${name}; +varying ${precision} ${type} ${name}; +#else +uniform ${precision} ${type} u_${name}; +#endif +`; + } else /* if (operation === 'initialize') */ { + if (unpackType === 'vec4') { + // vec4 attributes are only used for cross-faded properties, and are not packed + return ` +#ifndef HAS_UNIFORM_u_${name} + ${name} = a_${name}; +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } else { + return ` +#ifndef HAS_UNIFORM_u_${name} + ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t); +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + } + } else { + if (operation === 'define') { + return ` +#ifndef HAS_UNIFORM_u_${name} +uniform lowp float u_${name}_t; +attribute ${precision} ${attrType} a_${name}; +#else +uniform ${precision} ${type} u_${name}; +#endif +`; + } else /* if (operation === 'initialize') */ { + if (unpackType === 'vec4') { + // vec4 attributes are only used for cross-faded properties, and are not packed + return ` +#ifndef HAS_UNIFORM_u_${name} + ${precision} ${type} ${name} = a_${name}; +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } else /* */ { + return ` +#ifndef HAS_UNIFORM_u_${name} + ${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t); +#else + ${precision} ${type} ${name} = u_${name}; +#endif +`; + } + } + } + }); + + return {fragmentSource, vertexSource, staticAttributes, staticUniforms}; +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_icon.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/symbol_icon.fragment.glsl new file mode 100644 index 00000000..ec81b936 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_icon.fragment.glsl @@ -0,0 +1,17 @@ +uniform sampler2D u_texture; + +in vec2 v_tex; +in float v_fade_opacity; + +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize lowp float opacity + + lowp float alpha = opacity * v_fade_opacity; + fragColor = texture(u_texture, v_tex) * alpha; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_icon.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/symbol_icon.fragment.glsl.g.ts new file mode 100644 index 00000000..a4653059 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_icon.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_icon.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/symbol_icon.vertex.glsl new file mode 100644 index 00000000..a12ff351 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_icon.vertex.glsl @@ -0,0 +1,94 @@ +const float PI = 3.141592653589793; + +in vec4 a_pos_offset; +in vec4 a_data; +in vec4 a_pixeloffset; +in vec3 a_projected_pos; +in float a_fade_opacity; + +uniform bool u_is_size_zoom_constant; +uniform bool u_is_size_feature_constant; +uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function +uniform highp float u_size; // used when size is both zoom and feature constant +uniform highp float u_camera_to_center_distance; +uniform highp float u_pitch; +uniform bool u_rotate_symbol; +uniform highp float u_aspect_ratio; +uniform float u_fade_change; +uniform mat4 u_matrix; +uniform mat4 u_label_plane_matrix; +uniform mat4 u_coord_matrix; +uniform bool u_is_text; +uniform bool u_pitch_with_map; +uniform vec2 u_texsize; + +out vec2 v_tex; +out float v_fade_opacity; + +#pragma mapbox: define lowp float opacity + +void main() { + #pragma mapbox: initialize lowp float opacity + + vec2 a_pos = a_pos_offset.xy; + vec2 a_offset = a_pos_offset.zw; + + vec2 a_tex = a_data.xy; + vec2 a_size = a_data.zw; + + float a_size_min = floor(a_size[0] * 0.5); + vec2 a_pxoffset = a_pixeloffset.xy; + vec2 a_minFontScale = a_pixeloffset.zw / 256.0; + + float ele = get_elevation(a_pos); + highp float segment_angle = -a_projected_pos[2]; + float size; + + if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { + size = mix(a_size_min, a_size[1], u_size_t) / 128.0; + } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { + size = a_size_min / 128.0; + } else { + size = u_size; + } + + vec4 projectedPoint = u_matrix * vec4(a_pos, ele, 1); + highp float camera_to_anchor_distance = projectedPoint.w; + // See comments in symbol_sdf.vertex + highp float distance_ratio = u_pitch_with_map ? + camera_to_anchor_distance / u_camera_to_center_distance : + u_camera_to_center_distance / camera_to_anchor_distance; + highp float perspective_ratio = clamp( + 0.5 + 0.5 * distance_ratio, + 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles + 4.0); + + size *= perspective_ratio; + + float fontScale = u_is_text ? size / 24.0 : size; + + highp float symbol_rotation = 0.0; + if (u_rotate_symbol) { + // See comments in symbol_sdf.vertex + vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), ele, 1); + + vec2 a = projectedPoint.xy / projectedPoint.w; + vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; + + symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); + } + + highp float angle_sin = sin(segment_angle + symbol_rotation); + highp float angle_cos = cos(segment_angle + symbol_rotation); + mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); + + vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, ele, 1.0); + float z = float(u_pitch_with_map) * projected_pos.z / projected_pos.w; + gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * max(a_minFontScale, fontScale) + a_pxoffset / 16.0), z, 1.0); + + v_tex = a_tex / u_texsize; + vec2 fade_opacity = unpack_opacity(a_fade_opacity); + float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float visibility = calculate_visibility(projectedPoint); + v_fade_opacity = max(0.0, min(visibility, fade_opacity[0] + fade_change)); +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_icon.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/symbol_icon.vertex.glsl.g.ts new file mode 100644 index 00000000..ae7a2fb1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_icon.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}'; diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_sdf.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.fragment.glsl new file mode 100644 index 00000000..a6ed7f0b --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.fragment.glsl @@ -0,0 +1,58 @@ +#define SDF_PX 8.0 + +uniform bool u_is_halo; +uniform sampler2D u_texture; +uniform highp float u_gamma_scale; +uniform lowp float u_device_pixel_ratio; +uniform bool u_is_text; + +in vec2 v_data0; +in vec3 v_data1; + +#pragma mapbox: define highp vec4 fill_color +#pragma mapbox: define highp vec4 halo_color +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp float halo_width +#pragma mapbox: define lowp float halo_blur + +void main() { + #pragma mapbox: initialize highp vec4 fill_color + #pragma mapbox: initialize highp vec4 halo_color + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize lowp float halo_width + #pragma mapbox: initialize lowp float halo_blur + + float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; + + vec2 tex = v_data0.xy; + float gamma_scale = v_data1.x; + float size = v_data1.y; + float fade_opacity = v_data1[2]; + + float fontScale = u_is_text ? size / 24.0 : size; + + lowp vec4 color = fill_color; + highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); + lowp float inner_edge = (256.0 - 64.0) / 256.0; + if (u_is_halo) { + color = halo_color; + gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); + inner_edge = inner_edge + gamma * gamma_scale; + } + + lowp float dist = texture(u_texture, tex).a; + highp float gamma_scaled = gamma * gamma_scale; + highp float alpha = smoothstep(inner_edge - gamma_scaled, inner_edge + gamma_scaled, dist); + if (u_is_halo) { + // When drawing halos, we want the inside of the halo to be transparent as well + // in case the text fill is transparent. + lowp float halo_edge = (6.0 - halo_width / fontScale) / SDF_PX; + alpha = min(smoothstep(halo_edge - gamma_scaled, halo_edge + gamma_scaled, dist), 1.0 - alpha); + } + + fragColor = color * (alpha * opacity * fade_opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_sdf.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.fragment.glsl.g.ts new file mode 100644 index 00000000..ed1e4655 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_sdf.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.vertex.glsl new file mode 100644 index 00000000..8c041358 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.vertex.glsl @@ -0,0 +1,118 @@ +const float PI = 3.141592653589793; + +in vec4 a_pos_offset; +in vec4 a_data; +in vec4 a_pixeloffset; +in vec3 a_projected_pos; +in float a_fade_opacity; + +// contents of a_size vary based on the type of property value +// used for {text,icon}-size. +// For constants, a_size is disabled. +// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. +// For composite functions: +// [ text-size(lowerZoomStop, feature), +// text-size(upperZoomStop, feature) ] +uniform bool u_is_size_zoom_constant; +uniform bool u_is_size_feature_constant; +uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function +uniform highp float u_size; // used when size is both zoom and feature constant +uniform mat4 u_matrix; +uniform mat4 u_label_plane_matrix; +uniform mat4 u_coord_matrix; +uniform bool u_is_text; +uniform bool u_pitch_with_map; +uniform highp float u_pitch; +uniform bool u_rotate_symbol; +uniform highp float u_aspect_ratio; +uniform highp float u_camera_to_center_distance; +uniform float u_fade_change; +uniform vec2 u_texsize; + +out vec2 v_data0; +out vec3 v_data1; + +#pragma mapbox: define highp vec4 fill_color +#pragma mapbox: define highp vec4 halo_color +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp float halo_width +#pragma mapbox: define lowp float halo_blur + +void main() { + #pragma mapbox: initialize highp vec4 fill_color + #pragma mapbox: initialize highp vec4 halo_color + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize lowp float halo_width + #pragma mapbox: initialize lowp float halo_blur + + vec2 a_pos = a_pos_offset.xy; + vec2 a_offset = a_pos_offset.zw; + + vec2 a_tex = a_data.xy; + vec2 a_size = a_data.zw; + + float a_size_min = floor(a_size[0] * 0.5); + vec2 a_pxoffset = a_pixeloffset.xy; + + float ele = get_elevation(a_pos); + highp float segment_angle = -a_projected_pos[2]; + float size; + + if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { + size = mix(a_size_min, a_size[1], u_size_t) / 128.0; + } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { + size = a_size_min / 128.0; + } else { + size = u_size; + } + + vec4 projectedPoint = u_matrix * vec4(a_pos, ele, 1); + highp float camera_to_anchor_distance = projectedPoint.w; + // If the label is pitched with the map, layout is done in pitched space, + // which makes labels in the distance smaller relative to viewport space. + // We counteract part of that effect by multiplying by the perspective ratio. + // If the label isn't pitched with the map, we do layout in viewport space, + // which makes labels in the distance larger relative to the features around + // them. We counteract part of that effect by dividing by the perspective ratio. + highp float distance_ratio = u_pitch_with_map ? + camera_to_anchor_distance / u_camera_to_center_distance : + u_camera_to_center_distance / camera_to_anchor_distance; + highp float perspective_ratio = clamp( + 0.5 + 0.5 * distance_ratio, + 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles + 4.0); + + size *= perspective_ratio; + + float fontScale = u_is_text ? size / 24.0 : size; + + highp float symbol_rotation = 0.0; + if (u_rotate_symbol) { + // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units + // To figure out that angle in projected space, we draw a short horizontal line in tile + // space, project it, and measure its angle in projected space. + vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), ele, 1); + + vec2 a = projectedPoint.xy / projectedPoint.w; + vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; + + symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); + } + + highp float angle_sin = sin(segment_angle + symbol_rotation); + highp float angle_cos = cos(segment_angle + symbol_rotation); + mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); + + vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, ele, 1.0); + float z = float(u_pitch_with_map) * projected_pos.z / projected_pos.w; + gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), z, 1.0); + float gamma_scale = gl_Position.w; + + vec2 fade_opacity = unpack_opacity(a_fade_opacity); + float visibility = calculate_visibility(projectedPoint); + float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float interpolated_fade_opacity = max(0.0, min(visibility, fade_opacity[0] + fade_change)); + + v_data0 = a_tex / u_texsize; + v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity); +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_sdf.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.vertex.glsl.g.ts new file mode 100644 index 00000000..da1da50d --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_sdf.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.fragment.glsl new file mode 100644 index 00000000..672e1dcb --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.fragment.glsl @@ -0,0 +1,68 @@ +#define SDF_PX 8.0 + +#define SDF 1.0 +#define ICON 0.0 + +uniform bool u_is_halo; +uniform sampler2D u_texture; +uniform sampler2D u_texture_icon; +uniform highp float u_gamma_scale; +uniform lowp float u_device_pixel_ratio; + +in vec4 v_data0; +in vec4 v_data1; + +#pragma mapbox: define highp vec4 fill_color +#pragma mapbox: define highp vec4 halo_color +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp float halo_width +#pragma mapbox: define lowp float halo_blur + +void main() { + #pragma mapbox: initialize highp vec4 fill_color + #pragma mapbox: initialize highp vec4 halo_color + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize lowp float halo_width + #pragma mapbox: initialize lowp float halo_blur + + float fade_opacity = v_data1[2]; + + if (v_data1.w == ICON) { + vec2 tex_icon = v_data0.zw; + lowp float alpha = opacity * fade_opacity; + fragColor = texture(u_texture_icon, tex_icon) * alpha; + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif + return; + } + + vec2 tex = v_data0.xy; + + float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; + + float gamma_scale = v_data1.x; + float size = v_data1.y; + + float fontScale = size / 24.0; + + lowp vec4 color = fill_color; + highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); + lowp float buff = (256.0 - 64.0) / 256.0; + if (u_is_halo) { + color = halo_color; + gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); + buff = (6.0 - halo_width / fontScale) / SDF_PX; + } + + lowp float dist = texture(u_texture, tex).a; + highp float gamma_scaled = gamma * gamma_scale; + highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); + + fragColor = color * (alpha * opacity * fade_opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts new file mode 100644 index 00000000..fbcfadb9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default '#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}'; diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.vertex.glsl new file mode 100644 index 00000000..e9e3bf9e --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.vertex.glsl @@ -0,0 +1,119 @@ +const float PI = 3.141592653589793; + +in vec4 a_pos_offset; +in vec4 a_data; +in vec3 a_projected_pos; +in float a_fade_opacity; + +// contents of a_size vary based on the type of property value +// used for {text,icon}-size. +// For constants, a_size is disabled. +// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. +// For composite functions: +// [ text-size(lowerZoomStop, feature), +// text-size(upperZoomStop, feature) ] +uniform bool u_is_size_zoom_constant; +uniform bool u_is_size_feature_constant; +uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function +uniform highp float u_size; // used when size is both zoom and feature constant +uniform mat4 u_matrix; +uniform mat4 u_label_plane_matrix; +uniform mat4 u_coord_matrix; +uniform bool u_is_text; +uniform bool u_pitch_with_map; +uniform highp float u_pitch; +uniform bool u_rotate_symbol; +uniform highp float u_aspect_ratio; +uniform highp float u_camera_to_center_distance; +uniform float u_fade_change; +uniform vec2 u_texsize; +uniform vec2 u_texsize_icon; + +out vec4 v_data0; +out vec4 v_data1; + +#pragma mapbox: define highp vec4 fill_color +#pragma mapbox: define highp vec4 halo_color +#pragma mapbox: define lowp float opacity +#pragma mapbox: define lowp float halo_width +#pragma mapbox: define lowp float halo_blur + +void main() { + #pragma mapbox: initialize highp vec4 fill_color + #pragma mapbox: initialize highp vec4 halo_color + #pragma mapbox: initialize lowp float opacity + #pragma mapbox: initialize lowp float halo_width + #pragma mapbox: initialize lowp float halo_blur + + vec2 a_pos = a_pos_offset.xy; + vec2 a_offset = a_pos_offset.zw; + + vec2 a_tex = a_data.xy; + vec2 a_size = a_data.zw; + + float a_size_min = floor(a_size[0] * 0.5); + float is_sdf = a_size[0] - 2.0 * a_size_min; + + float ele = get_elevation(a_pos); + highp float segment_angle = -a_projected_pos[2]; + float size; + + if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { + size = mix(a_size_min, a_size[1], u_size_t) / 128.0; + } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { + size = a_size_min / 128.0; + } else { + size = u_size; + } + + vec4 projectedPoint = u_matrix * vec4(a_pos, ele, 1); + highp float camera_to_anchor_distance = projectedPoint.w; + // If the label is pitched with the map, layout is done in pitched space, + // which makes labels in the distance smaller relative to viewport space. + // We counteract part of that effect by multiplying by the perspective ratio. + // If the label isn't pitched with the map, we do layout in viewport space, + // which makes labels in the distance larger relative to the features around + // them. We counteract part of that effect by dividing by the perspective ratio. + highp float distance_ratio = u_pitch_with_map ? + camera_to_anchor_distance / u_camera_to_center_distance : + u_camera_to_center_distance / camera_to_anchor_distance; + highp float perspective_ratio = clamp( + 0.5 + 0.5 * distance_ratio, + 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles + 4.0); + + size *= perspective_ratio; + + float fontScale = size / 24.0; + + highp float symbol_rotation = 0.0; + if (u_rotate_symbol) { + // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units + // To figure out that angle in projected space, we draw a short horizontal line in tile + // space, project it, and measure its angle in projected space. + vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), ele, 1); + + vec2 a = projectedPoint.xy / projectedPoint.w; + vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; + + symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); + } + + highp float angle_sin = sin(segment_angle + symbol_rotation); + highp float angle_cos = cos(segment_angle + symbol_rotation); + mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); + + vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, ele, 1.0); + float z = float(u_pitch_with_map) * projected_pos.z / projected_pos.w; + gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), z, 1.0); + float gamma_scale = gl_Position.w; + + vec2 fade_opacity = unpack_opacity(a_fade_opacity); + float visibility = calculate_visibility(projectedPoint); + float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float interpolated_fade_opacity = max(0.0, min(visibility, fade_opacity[0] + fade_change)); + + v_data0.xy = a_tex / u_texsize; + v_data0.zw = a_tex / u_texsize_icon; + v_data1 = vec4(gamma_scale, size, interpolated_fade_opacity, is_sdf); +} diff --git a/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts new file mode 100644 index 00000000..c4286dab --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/terrain.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/terrain.fragment.glsl new file mode 100644 index 00000000..de44a497 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain.fragment.glsl @@ -0,0 +1,7 @@ +uniform sampler2D u_texture; + +in vec2 v_texture_pos; + +void main() { + fragColor = texture(u_texture, v_texture_pos); +} diff --git a/web/libraries/maplibre-gl/src/shaders/terrain.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/terrain.fragment.glsl.g.ts new file mode 100644 index 00000000..1c2c99a8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/terrain.vertex.glsl b/web/libraries/maplibre-gl/src/shaders/terrain.vertex.glsl new file mode 100644 index 00000000..6e091944 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain.vertex.glsl @@ -0,0 +1,15 @@ +in vec3 a_pos3d; + +uniform mat4 u_matrix; +uniform float u_ele_delta; + +out vec2 v_texture_pos; +out float v_depth; + +void main() { + float extent = 8192.0; // 8192.0 is the hardcoded vector-tiles coordinates resolution + float ele_delta = a_pos3d.z == 1.0 ? u_ele_delta : 0.0; + v_texture_pos = a_pos3d.xy / extent; + gl_Position = u_matrix * vec4(a_pos3d.xy, get_elevation(a_pos3d.xy) - ele_delta, 1.0); + v_depth = gl_Position.z / gl_Position.w; +} diff --git a/web/libraries/maplibre-gl/src/shaders/terrain.vertex.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/terrain.vertex.glsl.g.ts new file mode 100644 index 00000000..38ac8b33 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain.vertex.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}'; diff --git a/web/libraries/maplibre-gl/src/shaders/terrain_coords.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/terrain_coords.fragment.glsl new file mode 100644 index 00000000..05609c14 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain_coords.fragment.glsl @@ -0,0 +1,11 @@ +precision mediump float; + +uniform sampler2D u_texture; +uniform float u_terrain_coords_id; + +in vec2 v_texture_pos; + +void main() { + vec4 rgba = texture(u_texture, v_texture_pos); + fragColor = vec4(rgba.r, rgba.g, rgba.b, u_terrain_coords_id); +} diff --git a/web/libraries/maplibre-gl/src/shaders/terrain_coords.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/terrain_coords.fragment.glsl.g.ts new file mode 100644 index 00000000..4654e5aa --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain_coords.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}'; diff --git a/web/libraries/maplibre-gl/src/shaders/terrain_depth.fragment.glsl b/web/libraries/maplibre-gl/src/shaders/terrain_depth.fragment.glsl new file mode 100644 index 00000000..2e497f08 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain_depth.fragment.glsl @@ -0,0 +1,15 @@ +in float v_depth; + +// methods for pack/unpack depth value to texture rgba +// https://stackoverflow.com/questions/34963366/encode-floating-point-data-in-a-rgba-texture +const highp vec4 bitSh = vec4(256. * 256. * 256., 256. * 256., 256., 1.); +const highp vec4 bitMsk = vec4(0.,vec3(1./256.0)); +highp vec4 pack(highp float value) { + highp vec4 comp = fract(value * bitSh); + comp -= comp.xxyz * bitMsk; + return comp; +} + +void main() { + fragColor = pack(v_depth); +} diff --git a/web/libraries/maplibre-gl/src/shaders/terrain_depth.fragment.glsl.g.ts b/web/libraries/maplibre-gl/src/shaders/terrain_depth.fragment.glsl.g.ts new file mode 100644 index 00000000..be8398f7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/shaders/terrain_depth.fragment.glsl.g.ts @@ -0,0 +1,2 @@ +// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`. +export default 'varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}'; diff --git a/web/libraries/maplibre-gl/src/source/canvas_source.test.ts b/web/libraries/maplibre-gl/src/source/canvas_source.test.ts new file mode 100644 index 00000000..306ba5f5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/canvas_source.test.ts @@ -0,0 +1,210 @@ +import {CanvasSource} from '../source/canvas_source'; +import {Transform} from '../geo/transform'; +import {Event, Evented} from '../util/evented'; +import {extend} from '../util/util'; + +import type {Dispatcher} from '../util/dispatcher'; +import {Tile} from './tile'; +import {OverscaledTileID} from './tile_id'; +import {VertexBuffer} from '../gl/vertex_buffer'; +import {SegmentVector} from '../data/segment'; + +function createSource(options?) { + const c = options && options.canvas || window.document.createElement('canvas'); + c.width = 20; + c.height = 20; + + options = extend({ + canvas: 'id', + coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]], + }, options); + + const source = new CanvasSource('id', options, {} as Dispatcher, options.eventedParent); + + source.canvas = c; + + return source; +} + +class StubMap extends Evented { + transform: Transform; + style: any; + painter: any; + + constructor() { + super(); + this.transform = new Transform(); + this.style = {}; + this.painter = { + context: { + gl: {} + } + }; + } + + triggerRepaint() { + this.fire(new Event('rerender')); + } +} + +describe('CanvasSource', () => { + let map; + beforeEach(() => { + map = new StubMap(); + }); + + test('constructor', done => { + const source = createSource(); + + expect(source.minzoom).toBe(0); + expect(source.maxzoom).toBe(22); + expect(source.tileSize).toBe(512); + expect(source.animate).toBe(true); + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + expect(typeof source.play).toBe('function'); + done(); + } + }); + + source.onAdd(map); + }); + + test('self-validates', () => { + const stub = jest.spyOn(console, 'error').mockImplementation(() => {}); + createSource({coordinates: []}); + expect(stub).toHaveBeenCalled(); + stub.mockReset(); + + createSource({coordinates: 'asdf'}); + expect(stub).toHaveBeenCalled(); + stub.mockReset(); + + createSource({animate: 8}); + expect(stub).toHaveBeenCalled(); + stub.mockReset(); + + createSource({canvas: {}}); + expect(stub).toHaveBeenCalled(); + stub.mockReset(); + + const canvasEl = window.document.createElement('canvas'); + createSource({canvas: canvasEl}); + expect(stub).not.toHaveBeenCalled(); + stub.mockReset(); + + }); + + test('can be initialized with HTML element', done => { + const el = window.document.createElement('canvas'); + const source = createSource({ + canvas: el + }); + + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + expect(source.canvas).toBe(el); + done(); + } + }); + + source.onAdd(map); + }); + + test('rerenders if animated', done => { + const source = createSource(); + + map.on('rerender', () => { + expect(true).toBeTruthy(); + done(); + }); + + source.onAdd(map); + }); + + test('can be static', done => { + const source = createSource({ + animate: false + }); + + map.on('rerender', () => { + // this just confirms it didn't happen, so no need to run done() here + // if called the test will fail + expect(true).toBeFalsy(); + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata' && e.dataType === 'source') { + expect(true).toBeTruthy(); + done(); + } + }); + + source.onAdd(map); + }); + + test('onRemove stops animation', () => { + const source = createSource(); + + source.onAdd(map); + + expect(source.hasTransition()).toBe(true); + + source.onRemove(); + + expect(source.hasTransition()).toBe(false); + + source.onAdd(map); + + expect(source.hasTransition()).toBe(true); + + }); + + test('play and pause animation', () => { + const source = createSource(); + + source.onAdd(map); + + expect(source.hasTransition()).toBe(true); + + source.pause(); + + expect(source.hasTransition()).toBe(false); + + source.play(); + + expect(source.hasTransition()).toBe(true); + + }); + + test('fires idle event on prepare call when there is at least one not loaded tile', done => { + const source = createSource(); + const tile = new Tile(new OverscaledTileID(1, 0, 1, 0, 0), 512); + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'idle') { + expect(tile.state).toBe('loaded'); + done(); + } + }); + source.onAdd(map); + + source.tiles[String(tile.tileID.wrap)] = tile; + // assign dummies directly so we don't need to stub the gl things + source.boundsBuffer = {} as VertexBuffer; + source.boundsSegments = {} as SegmentVector; + source.texture = { + update: () => {} + } as any; + source.prepare(); + }); + +}); + +describe('CanvasSource#serialize', () => { + const source = createSource(); + + const serialized = source.serialize(); + expect(serialized.type).toBe('canvas'); + expect(serialized.coordinates).toEqual([[0, 0], [1, 0], [1, 1], [0, 1]]); + +}); diff --git a/web/libraries/maplibre-gl/src/source/canvas_source.ts b/web/libraries/maplibre-gl/src/source/canvas_source.ts new file mode 100644 index 00000000..72994df2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/canvas_source.ts @@ -0,0 +1,227 @@ +import {ImageSource} from './image_source'; + +import rasterBoundsAttributes from '../data/raster_bounds_attributes'; +import {SegmentVector} from '../data/segment'; +import {Texture} from '../render/texture'; +import {Event, ErrorEvent} from '../util/evented'; +import {ValidationError} from '@maplibre/maplibre-gl-style-spec'; + +import type {Map} from '../ui/map'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Evented} from '../util/evented'; + +/** + * Options to add a canvas source type to the map. + */ +export type CanvasSourceSpecification = { + /** + * Source type. Must be `"canvas"`. + */ + type: 'canvas'; + /** + * Four geographical coordinates denoting where to place the corners of the canvas, specified in `[longitude, latitude]` pairs. + */ + coordinates: [[number, number], [number, number], [number, number], [number, number]]; + /** + * Whether the canvas source is animated. If the canvas is static (i.e. pixels do not need to be re-read on every frame), `animate` should be set to `false` to improve performance. + * @defaultValue true + */ + animate?: boolean; + /** + * Canvas source from which to read pixels. Can be a string representing the ID of the canvas element, or the `HTMLCanvasElement` itself. + */ + canvas?: string | HTMLCanvasElement; +}; + +/** + * A data source containing the contents of an HTML canvas. See {@link CanvasSourceSpecification} for detailed documentation of options. + * + * @group Sources + * + * @example + * ```ts + * // add to map + * map.addSource('some id', { + * type: 'canvas', + * canvas: 'idOfMyHTMLCanvas', + * animate: true, + * coordinates: [ + * [-76.54, 39.18], + * [-76.52, 39.18], + * [-76.52, 39.17], + * [-76.54, 39.17] + * ] + * }); + * + * // update + * let mySource = map.getSource('some id'); + * mySource.setCoordinates([ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ]); + * + * map.removeSource('some id'); // remove + * ``` + */ +export class CanvasSource extends ImageSource { + options: CanvasSourceSpecification; + animate: boolean; + canvas: HTMLCanvasElement; + width: number; + height: number; + /** + * Enables animation. The image will be copied from the canvas to the map on each frame. + */ + play: () => void; + /** + * Disables animation. The map will display a static copy of the canvas image. + */ + pause: () => void; + _playing: boolean; + + /** @internal */ + constructor(id: string, options: CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) { + super(id, options, dispatcher, eventedParent); + + // We build in some validation here, since canvas sources aren't included in the style spec: + if (!options.coordinates) { + this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property "coordinates"'))); + } else if (!Array.isArray(options.coordinates) || options.coordinates.length !== 4 || + options.coordinates.some(c => !Array.isArray(c) || c.length !== 2 || c.some(l => typeof l !== 'number'))) { + this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '"coordinates" property must be an array of 4 longitude/latitude array pairs'))); + } + + if (options.animate && typeof options.animate !== 'boolean') { + this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'optional "animate" property must be a boolean value'))); + } + + if (!options.canvas) { + this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, 'missing required property "canvas"'))); + } else if (typeof options.canvas !== 'string' && !(options.canvas instanceof HTMLCanvasElement)) { + this.fire(new ErrorEvent(new ValidationError(`sources.${id}`, null, '"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))); + } + + this.options = options; + this.animate = options.animate !== undefined ? options.animate : true; + } + + load = () => { + this._loaded = true; + if (!this.canvas) { + this.canvas = (this.options.canvas instanceof HTMLCanvasElement) ? + this.options.canvas : + document.getElementById(this.options.canvas) as HTMLCanvasElement; + // cast to HTMLCanvasElement in else of ternary + // should we do a safety check and throw if it's not actually HTMLCanvasElement? + } + this.width = this.canvas.width; + this.height = this.canvas.height; + + if (this._hasInvalidDimensions()) { + this.fire(new ErrorEvent(new Error('Canvas dimensions cannot be less than or equal to zero.'))); + return; + } + + this.play = function() { + this._playing = true; + this.map.triggerRepaint(); + }; + + this.pause = function() { + if (this._playing) { + this.prepare(); + this._playing = false; + } + }; + + this._finishLoading(); + }; + + /** + * Returns the HTML `canvas` element. + * + * @returns The HTML `canvas` element. + */ + getCanvas(): HTMLCanvasElement { + return this.canvas; + } + + onAdd(map: Map) { + this.map = map; + this.load(); + if (this.canvas) { + if (this.animate) this.play(); + } + } + + onRemove() { + this.pause(); + } + + prepare = () => { + let resize = false; + if (this.canvas.width !== this.width) { + this.width = this.canvas.width; + resize = true; + } + if (this.canvas.height !== this.height) { + this.height = this.canvas.height; + resize = true; + } + + if (this._hasInvalidDimensions()) return; + + if (Object.keys(this.tiles).length === 0) return; // not enough data for current position + + const context = this.map.painter.context; + const gl = context.gl; + + if (!this.boundsBuffer) { + this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members); + } + + if (!this.boundsSegments) { + this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2); + } + + if (!this.texture) { + this.texture = new Texture(context, this.canvas, gl.RGBA, {premultiply: true}); + } else if (resize || this._playing) { + this.texture.update(this.canvas, {premultiply: true}); + } + + let newTilesLoaded = false; + for (const w in this.tiles) { + const tile = this.tiles[w]; + if (tile.state !== 'loaded') { + tile.state = 'loaded'; + tile.texture = this.texture; + newTilesLoaded = true; + } + } + + if (newTilesLoaded) { + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id})); + } + }; + + serialize = (): CanvasSourceSpecification => { + return { + type: 'canvas', + coordinates: this.coordinates + }; + }; + + hasTransition() { + return this._playing; + } + + _hasInvalidDimensions() { + for (const x of [this.canvas.width, this.canvas.height]) { + if (isNaN(x) || x <= 0) return true; + } + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/source/geojson_source.test.ts b/web/libraries/maplibre-gl/src/source/geojson_source.test.ts new file mode 100644 index 00000000..a5eeebbf --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_source.test.ts @@ -0,0 +1,440 @@ +import {Tile} from './tile'; +import {OverscaledTileID} from './tile_id'; +import {GeoJSONSource, GeoJSONSourceOptions} from './geojson_source'; +import {Transform} from '../geo/transform'; +import {LngLat} from '../geo/lng_lat'; +import {extend} from '../util/util'; +import {Dispatcher} from '../util/dispatcher'; +import {RequestManager} from '../util/request_manager'; + +const wrapDispatcher = (dispatcher) => { + return { + getActor() { + return dispatcher; + } + } as Dispatcher; +}; + +const mockDispatcher = wrapDispatcher({ + send() {} +}); + +const hawkHill = { + 'type': 'FeatureCollection', + 'features': [{ + 'type': 'Feature', + 'properties': {}, + 'geometry': { + 'type': 'LineString', + 'coordinates': [ + [-122.48369693756104, 37.83381888486939], + [-122.48348236083984, 37.83317489144141], + [-122.48339653015138, 37.83270036637107], + [-122.48356819152832, 37.832056363179625], + [-122.48404026031496, 37.83114119107971], + [-122.48404026031496, 37.83049717427869], + [-122.48348236083984, 37.829920943955045], + [-122.48356819152832, 37.82954808664175], + [-122.48507022857666, 37.82944639795659], + [-122.48610019683838, 37.82880236636284], + [-122.48695850372314, 37.82931081282506], + [-122.48700141906738, 37.83080223556934], + [-122.48751640319824, 37.83168351665737], + [-122.48803138732912, 37.832158048267786], + [-122.48888969421387, 37.83297152392784], + [-122.48987674713133, 37.83263257682617], + [-122.49043464660643, 37.832937629287755], + [-122.49125003814696, 37.832429207817725], + [-122.49163627624512, 37.832564787218985], + [-122.49223709106445, 37.83337825839438], + [-122.49378204345702, 37.83368330777276] + ] + } + }] +} as GeoJSON.GeoJSON; + +describe('GeoJSONSource#setData', () => { + function createSource(opts?) { + opts = opts || {}; + opts = extend(opts, {data: {}}); + return new GeoJSONSource('id', opts, wrapDispatcher({ + send (type, data, callback) { + if (callback) { + return setTimeout(callback, 0); + } + } + }), undefined); + } + + test('returns self', () => { + const source = createSource(); + expect(source.setData({} as GeoJSON.GeoJSON)).toBe(source); + }); + + test('fires "data" event', async () => { + const source = createSource(); + const loadPromise = source.once('data'); + source.load(); + await loadPromise; + const setDataPromise = source.once('data'); + source.setData({} as GeoJSON.GeoJSON); + await setDataPromise; + }); + + test('fires "dataloading" event', done => { + const source = createSource(); + source.on('dataloading', () => { + done(); + }); + source.load(); + }); + + test('fires "dataabort" event', done => { + const source = new GeoJSONSource('id', {} as any, wrapDispatcher({ + send(type, data, callback) { + setTimeout(() => callback(null, {abandoned: true})); + } + }), undefined); + source.on('dataabort', () => { + done(); + }); + source.load(); + }); + + test('respects collectResourceTiming parameter on source', done => { + const source = createSource({collectResourceTiming: true}); + source.map = { + _requestManager: { + transformRequest: (url) => { return {url}; } + } as any as RequestManager + } as any; + source.actor.send = function(type, params: any, cb) { + if (type === 'geojson.loadData') { + expect(params.request.collectResourceTiming).toBeTruthy(); + setTimeout(cb, 0); + done(); + } + } as any; + source.setData('http://localhost/nonexistent'); + }); + + test('only marks source as loaded when there are no pending loads', async () => { + const source = createSource(); + const setDataPromise = source.once('data'); + source.setData({} as GeoJSON.GeoJSON); + source.setData({} as GeoJSON.GeoJSON); + await setDataPromise; + expect(source.loaded()).toBeFalsy(); + const setDataPromise2 = source.once('data'); + await setDataPromise2; + expect(source.loaded()).toBeTruthy(); + }); + + test('marks source as not loaded before firing "dataloading" event', async () => { + const source = createSource(); + const setDataPromise = source.once('dataloading'); + source.setData({} as GeoJSON.GeoJSON); + await setDataPromise; + expect(source.loaded()).toBeFalsy(); + }); + + test('marks source as loaded before firing "data" event', async () => { + const source = createSource(); + const dataPromise = source.once('data'); + source.setData({} as GeoJSON.GeoJSON); + await dataPromise; + expect(source.loaded()).toBeTruthy(); + }); + + test('marks source as loaded before firing "dataabort" event', done => { + const source = new GeoJSONSource('id', {} as any, wrapDispatcher({ + send(type, data, callback) { + setTimeout(() => callback(null, {abandoned: true})); + } + }), undefined); + source.on('dataabort', () => { + expect(source.loaded()).toBeTruthy(); + done(); + }); + source.setData({} as GeoJSON.GeoJSON); + }); +}); + +describe('GeoJSONSource#onRemove', () => { + test('broadcasts "removeSource" event', done => { + const source = new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, wrapDispatcher({ + send(type, data, callback) { + expect(callback).toBeFalsy(); + expect(type).toBe('removeSource'); + expect(data).toEqual({type: 'geojson', source: 'id'}); + done(); + }, + broadcast() { + // Ignore + } + }), undefined); + source.onRemove(); + }); +}); + +describe('GeoJSONSource#update', () => { + const transform = new Transform(); + transform.resize(200, 200); + const lngLat = LngLat.convert([-122.486052, 37.830348]); + const point = transform.locationPoint(lngLat); + transform.zoom = 15; + transform.setLocationAtPoint(lngLat, point); + + test('sends initial loadData request to dispatcher', done => { + const mockDispatcher = wrapDispatcher({ + send(message) { + expect(message).toBe('geojson.loadData'); + done(); + } + }); + + new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, mockDispatcher, undefined).load(); + }); + + test('forwards geojson-vt options with worker request', done => { + const mockDispatcher = wrapDispatcher({ + send(message, params) { + expect(message).toBe('geojson.loadData'); + expect(params.geojsonVtOptions).toEqual({ + extent: 8192, + maxZoom: 10, + tolerance: 4, + buffer: 256, + lineMetrics: false, + generateId: true + }); + done(); + } + }); + + new GeoJSONSource('id', { + data: {}, + maxzoom: 10, + tolerance: 0.25, + buffer: 16, + generateId: true + } as GeoJSONSourceOptions, mockDispatcher, undefined).load(); + }); + + test('forwards Supercluster options with worker request', done => { + const mockDispatcher = wrapDispatcher({ + send(message, params) { + expect(message).toBe('geojson.loadData'); + expect(params.superclusterOptions).toEqual({ + maxZoom: 12, + minPoints: 3, + extent: 8192, + radius: 1600, + log: false, + generateId: true + }); + done(); + } + }); + + new GeoJSONSource('id', { + data: {}, + cluster: true, + clusterMaxZoom: 12, + clusterRadius: 100, + clusterMinPoints: 3, + generateId: true + } as GeoJSONSourceOptions, mockDispatcher, undefined).load(); + }); + + test('modifying cluster properties after adding a source', done => { + // test setCluster function on GeoJSONSource + const mockDispatcher = wrapDispatcher({ + send(message, params) { + expect(message).toBe('geojson.loadData'); + expect(params.cluster).toBe(true); + expect(params.superclusterOptions.radius).toBe(80); + expect(params.superclusterOptions.maxZoom).toBe(16); + done(); + } + }); + new GeoJSONSource('id', { + data: {}, + cluster: false, + clusterMaxZoom: 8, + clusterRadius: 100, + clusterMinPoints: 3, + generateId: true + } as GeoJSONSourceOptions, mockDispatcher, undefined).setClusterOptions({cluster: true, clusterRadius: 80, clusterMaxZoom: 16}); + }); + + test('forwards Supercluster options with worker request, ignore max zoom of source', done => { + const mockDispatcher = wrapDispatcher({ + send(message, params) { + expect(message).toBe('geojson.loadData'); + expect(params.superclusterOptions).toEqual({ + maxZoom: 12, + minPoints: 3, + extent: 8192, + radius: 1600, + log: false, + generateId: true + }); + done(); + } + }); + + new GeoJSONSource('id', { + data: {}, + maxzoom: 10, + cluster: true, + clusterMaxZoom: 12, + clusterRadius: 100, + clusterMinPoints: 3, + generateId: true + } as GeoJSONSourceOptions, mockDispatcher, undefined).load(); + }); + + test('transforms url before making request', () => { + const mapStub = { + _requestManager: { + transformRequest: (url) => { return {url}; } + } + } as any; + const transformSpy = jest.spyOn(mapStub._requestManager, 'transformRequest'); + const source = new GeoJSONSource('id', {data: 'https://example.com/data.geojson'} as GeoJSONSourceOptions, mockDispatcher, undefined); + source.onAdd(mapStub); + expect(transformSpy).toHaveBeenCalledTimes(1); + expect(transformSpy.mock.calls[0][0]).toBe('https://example.com/data.geojson'); + }); + test('fires event when metadata loads', done => { + const mockDispatcher = wrapDispatcher({ + send(message, args, callback) { + if (callback) { + setTimeout(callback, 0); + } + } + }); + + const source = new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, mockDispatcher, undefined); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') done(); + }); + + source.load(); + }); + + test('fires metadata data event even when initial request is aborted', done => { + let requestCount = 0; + const mockDispatcher = wrapDispatcher({ + send(message, args, callback) { + setTimeout(() => callback(null, {abandoned: requestCount++ === 0})); + } + }); + + const source = new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, mockDispatcher, undefined); + + source.on('data', e => { + if (e.sourceDataType === 'metadata') done(); + }); + + source.load(); + source.setData({} as GeoJSON.GeoJSON); + }); + + test('fires "error"', done => { + const mockDispatcher = wrapDispatcher({ + send(message, args, callback) { + if (callback) { + setTimeout(callback.bind(null, 'error'), 0); + } + } + }); + + const source = new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, mockDispatcher, undefined); + + source.on('error', (err) => { + expect(err.error).toBe('error'); + done(); + }); + + source.load(); + }); + + test('sends loadData request to dispatcher after data update', done => { + let expectedLoadDataCalls = 2; + const mockDispatcher = wrapDispatcher({ + send(message, args, callback) { + if (message === 'geojson.loadData' && --expectedLoadDataCalls <= 0) { + done(); + } + if (callback) { + setTimeout(callback, 0); + } + } + }); + + const source = new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, mockDispatcher, undefined); + source.map = { + transform: {} as Transform, + getPixelRatio() { return 1; } + } as any; + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + source.setData({} as GeoJSON.GeoJSON); + source.loadTile(new Tile(new OverscaledTileID(0, 0, 0, 0, 0), 512), () => {}); + } + }); + + source.load(); + }); +}); + +describe('GeoJSONSource#serialize', () => { + const mapStub = { + _requestManager: { + transformRequest: (url) => { return {url}; } + } + } as any; + test('serialize source with inline data', () => { + const source = new GeoJSONSource('id', {data: hawkHill} as GeoJSONSourceOptions, mockDispatcher, undefined); + source.map = mapStub; + source.load(); + expect(source.serialize()).toEqual({ + type: 'geojson', + data: hawkHill + }); + }); + + test('serialize source with url', () => { + const source = new GeoJSONSource('id', {data: 'local://data.json'} as GeoJSONSourceOptions, mockDispatcher, undefined); + source.map = mapStub; + source.load(); + expect(source.serialize()).toEqual({ + type: 'geojson', + data: 'local://data.json' + }); + }); + + test('serialize source with updated data', () => { + const source = new GeoJSONSource('id', {data: {}} as GeoJSONSourceOptions, mockDispatcher, undefined); + source.map = mapStub; + source.load(); + source.setData(hawkHill); + expect(source.serialize()).toEqual({ + type: 'geojson', + data: hawkHill + }); + }); + + test('serialize source with additional options', () => { + const source = new GeoJSONSource('id', {data: {}, cluster: true} as GeoJSONSourceOptions, mockDispatcher, undefined); + expect(source.serialize()).toEqual({ + type: 'geojson', + data: {}, + cluster: true + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/geojson_source.ts b/web/libraries/maplibre-gl/src/source/geojson_source.ts new file mode 100644 index 00000000..ada698d3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_source.ts @@ -0,0 +1,448 @@ +import {Event, ErrorEvent, Evented} from '../util/evented'; + +import {extend} from '../util/util'; +import {EXTENT} from '../data/extent'; +import {ResourceType} from '../util/request_manager'; +import {browser} from '../util/browser'; + +import type {Source} from './source'; +import type {Map} from '../ui/map'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Tile} from './tile'; +import type {Actor} from '../util/actor'; +import type {Callback} from '../types/callback'; +import type {GeoJSONSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {GeoJSONSourceDiff} from './geojson_source_diff'; +import type {Options, ClusterProperties} from 'supercluster'; + +export type GeoJSONSourceOptions = GeoJSONSourceSpecification & { + workerOptions?: WorkerOptions; + collectResourceTiming?: boolean; +} + +export type GeoJsonSourceOptions = { + data?: GeoJSON.GeoJSON | string | undefined; + cluster?: boolean; + clusterMaxZoom?: number; + clusterRadius?: number; + clusterMinPoints?: number; + generateId?: boolean; +} +export type WorkerOptions = { + source?: string; + cluster?: boolean; + geojsonVtOptions?: { + buffer?: number; + tolerance?: number; + extent?: number; + maxZoom?: number; + linemetrics?: boolean; + generateId?: boolean; + }; + superclusterOptions?: Options; + clusterProperties?: ClusterProperties; + fliter?: any; + promoteId?: any; + collectResourceTiming?: boolean; +} + +/** + * The cluster options to set + */ +export type SetClusterOptions = { + /** + * Whether or not to cluster + */ + cluster?: boolean; + /** + * The cluster's max zoom + */ + clusterMaxZoom?: number; + /** + * The cluster's radius + */ + clusterRadius?: number; +} + +/** + * A source containing GeoJSON. + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-geojson) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'geojson', + * data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson' + * }); + * ``` + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'geojson', + * data: { + * "type": "FeatureCollection", + * "features": [{ + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [ + * -76.53063297271729, + * 39.18174077994108 + * ] + * } + * }] + * } + * }); + * ``` + * + * @example + * ```ts + * map.getSource('some id').setData({ + * "type": "FeatureCollection", + * "features": [{ + * "type": "Feature", + * "properties": { "name": "Null Island" }, + * "geometry": { + * "type": "Point", + * "coordinates": [ 0, 0 ] + * } + * }] + * }); + * ``` + * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/) + * @see [Add a GeoJSON line](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-line/) + * @see [Create a heatmap from points](https://maplibre.org/maplibre-gl-js/docs/examples/heatmap/) + * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/) + */ +export class GeoJSONSource extends Evented implements Source { + type: 'geojson'; + id: string; + minzoom: number; + maxzoom: number; + tileSize: number; + attribution: string; + promoteId: PromoteIdSpecification; + + isTileClipped: boolean; + reparseOverscaled: boolean; + _data: GeoJSON.GeoJSON | string | undefined; + _options: GeoJsonSourceOptions; + workerOptions: WorkerOptions; + map: Map; + actor: Actor; + _pendingLoads: number; + _collectResourceTiming: boolean; + _removed: boolean; + + /** @internal */ + constructor(id: string, options: GeoJSONSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) { + super(); + + this.id = id; + + // `type` is a property rather than a constant to make it easy for 3rd + // parties to use GeoJSONSource to build their own source types. + this.type = 'geojson'; + + this.minzoom = 0; + this.maxzoom = 18; + this.tileSize = 512; + this.isTileClipped = true; + this.reparseOverscaled = true; + this._removed = false; + this._pendingLoads = 0; + + this.actor = dispatcher.getActor(); + this.setEventedParent(eventedParent); + + this._data = (options.data as any); + this._options = extend({}, options); + + this._collectResourceTiming = options.collectResourceTiming; + + if (options.maxzoom !== undefined) this.maxzoom = options.maxzoom; + if (options.type) this.type = options.type; + if (options.attribution) this.attribution = options.attribution; + this.promoteId = options.promoteId; + + const scale = EXTENT / this.tileSize; + + // sent to the worker, along with `url: ...` or `data: literal geojson`, + // so that it can load/parse/index the geojson data + // extending with `options.workerOptions` helps to make it easy for + // third-party sources to hack/reuse GeoJSONSource. + this.workerOptions = extend({ + source: this.id, + cluster: options.cluster || false, + geojsonVtOptions: { + buffer: (options.buffer !== undefined ? options.buffer : 128) * scale, + tolerance: (options.tolerance !== undefined ? options.tolerance : 0.375) * scale, + extent: EXTENT, + maxZoom: this.maxzoom, + lineMetrics: options.lineMetrics || false, + generateId: options.generateId || false + }, + superclusterOptions: { + maxZoom: options.clusterMaxZoom !== undefined ? options.clusterMaxZoom : this.maxzoom - 1, + minPoints: Math.max(2, options.clusterMinPoints || 2), + extent: EXTENT, + radius: (options.clusterRadius || 50) * scale, + log: false, + generateId: options.generateId || false + }, + clusterProperties: options.clusterProperties, + filter: options.filter + }, options.workerOptions); + + // send the promoteId to the worker to have more flexible updates, but only if it is a string + if (typeof this.promoteId === 'string') { + this.workerOptions.promoteId = this.promoteId; + } + } + + load = () => { + this._updateWorkerData(); + }; + + onAdd(map: Map) { + this.map = map; + this.load(); + } + + /** + * Sets the GeoJSON data and re-renders the map. + * + * @param data - A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files. + * @returns `this` + */ + setData(data: GeoJSON.GeoJSON | string): this { + this._data = data; + this._updateWorkerData(); + + return this; + } + + /** + * Updates the source's GeoJSON, and re-renders the map. + * + * For sources with lots of features, this method can be used to make updates more quickly. + * + * This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature, + * or by using the promoteId option to specify which property should be used as the ID. + * + * It is an error to call updateData on a source that did not have unique IDs for each of its features already. + * + * Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error. + * + * @param diff - The changes that need to be applied. + * @returns `this` + */ + updateData(diff: GeoJSONSourceDiff): this { + this._updateWorkerData(diff); + + return this; + } + + /** + * To disable/enable clustering on the source options + * @param options - The options to set + * @returns `this` + * @example + * ```ts + * map.getSource('some id').setClusterOptions({cluster: false}); + * map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14}); + * ``` + */ + setClusterOptions(options: SetClusterOptions): this { + this.workerOptions.cluster = options.cluster; + if (options) { + if (options.clusterRadius !== undefined) this.workerOptions.superclusterOptions.radius = options.clusterRadius; + if (options.clusterMaxZoom !== undefined) this.workerOptions.superclusterOptions.maxZoom = options.clusterMaxZoom; + } + this._updateWorkerData(); + return this; + } + + /** + * For clustered sources, fetches the zoom at which the given cluster expands. + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param callback - A callback to be called when the zoom value is retrieved (`(error, zoom) => { ... }`). + * @returns `this` + */ + getClusterExpansionZoom(clusterId: number, callback: Callback): this { + this.actor.send('geojson.getClusterExpansionZoom', {clusterId, source: this.id}, callback); + return this; + } + + /** + * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features). + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`). + * @returns `this` + */ + getClusterChildren(clusterId: number, callback: Callback>): this { + this.actor.send('geojson.getClusterChildren', {clusterId, source: this.id}, callback); + return this; + } + + /** + * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features). + * + * @param clusterId - The value of the cluster's `cluster_id` property. + * @param limit - The maximum number of features to return. + * @param offset - The number of features to skip (e.g. for pagination). + * @param callback - A callback to be called when the features are retrieved (`(error, features) => { ... }`). + * @returns `this` + * @example + * Retrieve cluster leaves on click + * ```ts + * map.on('click', 'clusters', function(e) { + * let features = map.queryRenderedFeatures(e.point, { + * layers: ['clusters'] + * }); + * + * let clusterId = features[0].properties.cluster_id; + * let pointCount = features[0].properties.point_count; + * let clusterSource = map.getSource('clusters'); + * + * clusterSource.getClusterLeaves(clusterId, pointCount, 0, function(error, features) { + * // Print cluster leaves in the console + * console.log('Cluster leaves:', error, features); + * }) + * }); + * ``` + */ + getClusterLeaves(clusterId: number, limit: number, offset: number, callback: Callback>): this { + this.actor.send('geojson.getClusterLeaves', { + source: this.id, + clusterId, + limit, + offset + }, callback); + return this; + } + + /** + * Responsible for invoking WorkerSource's geojson.loadData target, which + * handles loading the geojson data and preparing to serve it up as tiles, + * using geojson-vt or supercluster as appropriate. + * @param diff - the diff object + */ + _updateWorkerData(diff?: GeoJSONSourceDiff) { + const options = extend({}, this.workerOptions); + if (diff) { + options.dataDiff = diff; + } else if (typeof this._data === 'string') { + options.request = this.map._requestManager.transformRequest(browser.resolveURL(this._data as string), ResourceType.Source); + options.request.collectResourceTiming = this._collectResourceTiming; + } else { + options.data = JSON.stringify(this._data); + } + + this._pendingLoads++; + this.fire(new Event('dataloading', {dataType: 'source'})); + + // target {this.type}.loadData rather than literally geojson.loadData, + // so that other geojson-like source types can easily reuse this + // implementation + this.actor.send(`${this.type}.loadData`, options, (err, result) => { + this._pendingLoads--; + + if (this._removed || (result && result.abandoned)) { + this.fire(new Event('dataabort', {dataType: 'source'})); + return; + } + + let resourceTiming = null; + if (result && result.resourceTiming && result.resourceTiming[this.id]) + resourceTiming = result.resourceTiming[this.id].slice(0); + + if (err) { + this.fire(new ErrorEvent(err)); + return; + } + + const data: any = {dataType: 'source'}; + if (this._collectResourceTiming && resourceTiming && resourceTiming.length > 0) + extend(data, {resourceTiming}); + + // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache + // know its ok to start requesting tiles. + this.fire(new Event('data', {...data, sourceDataType: 'metadata'})); + this.fire(new Event('data', {...data, sourceDataType: 'content'})); + }); + } + + loaded(): boolean { + return this._pendingLoads === 0; + } + + loadTile(tile: Tile, callback: Callback) { + const message = !tile.actor ? 'loadTile' : 'reloadTile'; + tile.actor = this.actor; + const params = { + type: this.type, + uid: tile.uid, + tileID: tile.tileID, + zoom: tile.tileID.overscaledZ, + maxZoom: this.maxzoom, + tileSize: this.tileSize, + source: this.id, + pixelRatio: this.map.getPixelRatio(), + showCollisionBoxes: this.map.showCollisionBoxes, + promoteId: this.promoteId + }; + + tile.request = this.actor.send(message, params, (err, data) => { + delete tile.request; + tile.unloadVectorData(); + + if (tile.aborted) { + return callback(null); + } + + if (err) { + return callback(err); + } + + tile.loadVectorData(data, this.map.painter, message === 'reloadTile'); + + return callback(null); + }); + } + + abortTile(tile: Tile) { + if (tile.request) { + tile.request.cancel(); + delete tile.request; + } + tile.aborted = true; + } + + unloadTile(tile: Tile) { + tile.unloadVectorData(); + this.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}); + } + + onRemove() { + this._removed = true; + this.actor.send('removeSource', {type: this.type, source: this.id}); + } + + serialize = (): GeoJSONSourceSpecification => { + return extend({}, this._options, { + type: this.type, + data: this._data + }); + }; + + hasTransition() { + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/source/geojson_source_diff.test.ts b/web/libraries/maplibre-gl/src/source/geojson_source_diff.test.ts new file mode 100644 index 00000000..0bb6ab79 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_source_diff.test.ts @@ -0,0 +1,385 @@ +import {setPerformance} from '../util/test/util'; +import {type GeoJSONFeatureId, isUpdateableGeoJSON, toUpdateable, applySourceDiff} from './geojson_source_diff'; + +beforeEach(() => { + setPerformance(); +}); + +describe('isUpdateableGeoJSON', () => { + test('feature without id is not updateable', done => { + // no feature id -> false + expect(isUpdateableGeoJSON({ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + })).toBe(false); + done(); + }); + + test('feature with id is updateable', done => { + // has a feature id -> true + expect(isUpdateableGeoJSON({ + type: 'Feature', + id: 'feature_id', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + })).toBe(true); + done(); + }); + + test('promoteId missing is not updateable', done => { + expect(isUpdateableGeoJSON({ + type: 'Feature', + id: 'feature_id', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }, 'propId')).toBe(false); + done(); + }); + + test('promoteId present is updateable', done => { + expect(isUpdateableGeoJSON({ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: { + propId: 'feature_id', + }, + }, 'propId')).toBe(true); + done(); + }); + + test('feature collection with unique ids is updateable', done => { + expect(isUpdateableGeoJSON({ + type: 'FeatureCollection', + features: [{ + type: 'Feature', + id: 'feature_id', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }, { + type: 'Feature', + id: 'feature_id_2', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }] + })).toBe(true); + done(); + }); + + test('feature collection with unique promoteIds is updateable', done => { + expect(isUpdateableGeoJSON({ + type: 'FeatureCollection', + features: [{ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: { + propId: 'feature_id', + }, + }, { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: { + propId: 'feature_id_2', + }, + }] + }, 'propId')).toBe(true); + done(); + }); + + test('feature collection without unique ids is not updateable', done => { + expect(isUpdateableGeoJSON({ + type: 'FeatureCollection', + features: [{ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }] + })).toBe(false); + done(); + }); + + test('feature collection with duplicate feature ids is not updateable', done => { + expect(isUpdateableGeoJSON({ + type: 'FeatureCollection', + features: [{ + type: 'Feature', + id: 'feature_id', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }, { + type: 'Feature', + id: 'feature_id', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }] + })).toBe(false); + done(); + }); + + test('geometries are not updateable', done => { + expect(isUpdateableGeoJSON({type: 'Point', coordinates: [0, 0]})).toBe(false); + done(); + }); +}); + +describe('toUpdateable', () => { + test('works with a single feature - feature id', done => { + const updateable = toUpdateable({ + type: 'Feature', + id: 'point', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, properties: {}}); + expect(updateable.size).toBe(1); + expect(updateable.has('point')).toBeTruthy(); + done(); + }); + + test('works with a single feature - promoteId', done => { + const updateable2 = toUpdateable({ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, properties: { + promoteId: 'point', + }}, 'promoteId'); + expect(updateable2.size).toBe(1); + expect(updateable2.has('point')).toBeTruthy(); + done(); + }); + + test('works with a FeatureCollection - feature id', done => { + const updateable = toUpdateable({ + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + id: 'point', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, properties: {}}, + { + type: 'Feature', + id: 'point2', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, properties: {}} + ] + }); + expect(updateable.size).toBe(2); + expect(updateable.has('point')).toBeTruthy(); + expect(updateable.has('point2')).toBeTruthy(); + done(); + }); + + test('works with a FeatureCollection - promoteId', done => { + const updateable2 = toUpdateable({ + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, properties: { + promoteId: 'point' + }}, + { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, properties: { + promoteId: 'point2' + }} + ] + }, 'promoteId'); + expect(updateable2.size).toBe(2); + expect(updateable2.has('point')).toBeTruthy(); + expect(updateable2.has('point2')).toBeTruthy(); + done(); + }); +}); + +describe('applySourceDiff', () => { + const point: GeoJSON.Feature = { + type: 'Feature', + id: 'point', + geometry: { + type: 'Point', + coordinates: [0, 0] + }, + properties: {}, + }; + + const point2: GeoJSON.Feature = { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, + properties: { + promoteId: 'point2' + }, + }; + + // freeze our input data to guarantee that applySourceDiff works immutably + Object.freeze(point); + Object.freeze(point.geometry); + Object.freeze((point.geometry as GeoJSON.Point).coordinates); + Object.freeze(point.properties); + Object.freeze(point2); + Object.freeze(point2.geometry); + Object.freeze((point2.geometry as GeoJSON.Point).coordinates); + Object.freeze(point2.properties); + + test('adds a feature using the feature id', done => { + const updateable = new Map(); + + applySourceDiff(updateable, { + add: [point] + }); + expect(updateable.size).toBe(1); + expect(updateable.has('point')).toBeTruthy(); + done(); + }); + + test('adds a feature using the promoteId', done => { + const updateable = new Map(); + applySourceDiff(updateable, { + add: [point2] + }, 'promoteId'); + expect(updateable.size).toBe(1); + expect(updateable.has('point2')).toBeTruthy(); + done(); + }); + + test('removes a feature by its id', done => { + const updateable = new Map([['point', point], ['point2', point2]]); + applySourceDiff(updateable, { + remove: ['point2'], + }); + expect(updateable.size).toBe(1); + expect(updateable.has('point2')).toBeFalsy(); + done(); + }); + + test('updates a feature geometry', done => { + const updateable = new Map([['point', point]]); + // update -> new geometry + applySourceDiff(updateable, { + update: [{ + id: 'point', + newGeometry: { + type: 'Point', + coordinates: [1, 0] + } + }] + }); + expect(updateable.size).toBe(1); + expect((updateable.get('point')?.geometry as GeoJSON.Point).coordinates[0]).toBe(1); + done(); + }); + + test('adds properties', done => { + const updateable = new Map([['point', point]]); + applySourceDiff(updateable, { + update: [{ + id: 'point', + addOrUpdateProperties: [ + {key: 'prop', value: 'value'}, + {key: 'prop2', value: 'value2'} + ] + }] + }); + expect(updateable.size).toBe(1); + const properties = updateable.get('point')?.properties!; + expect(Object.keys(properties)).toHaveLength(2); + expect(properties.prop).toBe('value'); + expect(properties.prop2).toBe('value2'); + done(); + }); + + test('updates properties', done => { + const updateable = new Map([['point', {...point, properties: {prop: 'value', prop2: 'value2'}}]]); + applySourceDiff(updateable, { + update: [{ + id: 'point', + addOrUpdateProperties: [ + {key: 'prop2', value: 'value3'} + ] + }] + }); + expect(updateable.size).toBe(1); + const properties2 = updateable.get('point')?.properties!; + expect(Object.keys(properties2)).toHaveLength(2); + expect(properties2.prop).toBe('value'); + expect(properties2.prop2).toBe('value3'); + done(); + }); + + test('removes properties', done => { + const updateable = new Map([['point', {...point, properties: {prop: 'value', prop2: 'value2'}}]]); + applySourceDiff(updateable, { + update: [{ + id: 'point', + removeProperties: ['prop2'] + }] + }); + expect(updateable.size).toBe(1); + const properties3 = updateable.get('point')?.properties!; + expect(Object.keys(properties3)).toHaveLength(1); + expect(properties3.prop).toBe('value'); + done(); + }); + + test('removes all properties', done => { + const updateable = new Map([['point', {...point, properties: {prop: 'value', prop2: 'value2'}}]]); + applySourceDiff(updateable, { + update: [{ + id: 'point', + removeAllProperties: true, + }] + }); + expect(updateable.size).toBe(1); + expect(Object.keys(updateable.get('point')?.properties!)).toHaveLength(0); + done(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/geojson_source_diff.ts b/web/libraries/maplibre-gl/src/source/geojson_source_diff.ts new file mode 100644 index 00000000..40468e2e --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_source_diff.ts @@ -0,0 +1,172 @@ +/** + * A way to indentify a feature, either by string or by number + */ +export type GeoJSONFeatureId = number | string; + +/** + * The geojson source diff object + */ +export type GeoJSONSourceDiff = { + /** + * When set to `true` it will remove all features + */ + removeAll?: boolean; + /** + * An array of features IDs to remove + */ + remove?: Array; + /** + * An array of features to add + */ + add?: Array; + /** + * An array of update objects + */ + update?: Array; +} + +/** + * A geojson feature diff object + */ +export type GeoJSONFeatureDiff = { + /** + * The feature ID + */ + id: GeoJSONFeatureId; + /** + * If it's a new geometry, place it here + */ + newGeometry?: GeoJSON.Geometry; + /** + * Setting to `true` will remove all preperties + */ + removeAllProperties?: boolean; + /** + * The properties keys to remove + */ + removeProperties?: Array; + /** + * The properties to add or update along side their values + */ + addOrUpdateProperties?: Array<{key: string; value: any}>; +} + +export type UpdateableGeoJSON = GeoJSON.Feature | GeoJSON.FeatureCollection | undefined; + +function getFeatureId(feature: GeoJSON.Feature, promoteId?: string): GeoJSONFeatureId | undefined { + return promoteId ? feature.properties[promoteId] : feature.id; +} + +export function isUpdateableGeoJSON(data: GeoJSON.GeoJSON | undefined, promoteId?: string): data is UpdateableGeoJSON { + // null can be updated + if (data == null) { + return true; + } + + // a single feature with an id can be updated, need to explicitly check against null because 0 is a valid feature id that is falsy + if (data.type === 'Feature') { + return getFeatureId(data, promoteId) != null; + } + + // a feature collection can be updated if every feature has an id, and the ids are all unique + // this prevents us from silently dropping features if ids get reused + if (data.type === 'FeatureCollection') { + const seenIds = new Set(); + for (const feature of data.features) { + const id = getFeatureId(feature, promoteId); + if (id == null) { + return false; + } + + if (seenIds.has(id)) { + return false; + } + + seenIds.add(id); + } + + return true; + } + + return false; +} + +export function toUpdateable(data: UpdateableGeoJSON, promoteId?: string) { + const result = new Map(); + if (data == null) { + // empty result + } else if (data.type === 'Feature') { + result.set(getFeatureId(data, promoteId)!, data); + } else { + for (const feature of data.features) { + result.set(getFeatureId(feature, promoteId)!, feature); + } + } + + return result; +} + +// mutates updateable +export function applySourceDiff(updateable: Map, diff: GeoJSONSourceDiff, promoteId?: string): void { + if (diff.removeAll) { + updateable.clear(); + } + + if (diff.remove) { + for (const id of diff.remove) { + updateable.delete(id); + } + } + + if (diff.add) { + for (const feature of diff.add) { + const id = getFeatureId(feature, promoteId); + + if (id != null) { + updateable.set(id, feature); + } + } + } + + if (diff.update) { + for (const update of diff.update) { + let feature = updateable.get(update.id); + + if (feature == null) { + continue; + } + + // be careful to clone the feature and/or properties objects to avoid mutating our input + const cloneFeature = update.newGeometry || update.removeAllProperties; + // note: removeAllProperties gives us a new properties object, so we can skip the clone step + const cloneProperties = !update.removeAllProperties && (update.removeProperties?.length > 0 || update.addOrUpdateProperties?.length > 0); + if (cloneFeature || cloneProperties) { + feature = {...feature}; + updateable.set(update.id, feature); + if (cloneProperties) { + feature.properties = {...feature.properties}; + } + } + + if (update.newGeometry) { + feature.geometry = update.newGeometry; + } + + if (update.removeAllProperties) { + feature.properties = {}; + } else if (update.removeProperties?.length > 0) { + for (const prop of update.removeProperties) { + if (Object.prototype.hasOwnProperty.call(feature.properties, prop)) { + delete feature.properties[prop]; + } + } + } + + if (update.addOrUpdateProperties?.length > 0) { + for (const {key, value} of update.addOrUpdateProperties) { + feature.properties[key] = value; + } + } + } + } +} diff --git a/web/libraries/maplibre-gl/src/source/geojson_worker_source.test.ts b/web/libraries/maplibre-gl/src/source/geojson_worker_source.test.ts new file mode 100644 index 00000000..c4e16439 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_worker_source.test.ts @@ -0,0 +1,369 @@ +import {GeoJSONWorkerSource, LoadGeoJSONParameters} from './geojson_worker_source'; +import {StyleLayerIndex} from '../style/style_layer_index'; +import {OverscaledTileID} from './tile_id'; +import perf from '../util/performance'; +import {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {Actor} from '../util/actor'; +import {WorkerTileParameters} from './worker_source'; +import {setPerformance} from '../util/test/util'; +import {type FakeServer, fakeServer} from 'nise'; + +const actor = {send: () => {}} as any as Actor; + +beforeEach(() => { + setPerformance(); +}); + +describe('reloadTile', () => { + test('does not rebuild vector data unless data has changed', done => { + const layers = [ + { + id: 'mylayer', + source: 'sourceId', + type: 'symbol', + } + ] as LayerSpecification[]; + const layerIndex = new StyleLayerIndex(layers); + const source = new GeoJSONWorkerSource(actor, layerIndex, []); + const originalLoadVectorData = source.loadVectorData; + let loadVectorCallCount = 0; + source.loadVectorData = function(params, callback) { + loadVectorCallCount++; + return originalLoadVectorData.call(this, params, callback); + }; + const geoJson = { + 'type': 'Feature', + 'geometry': { + 'type': 'Point', + 'coordinates': [0, 0] + } + }; + const tileParams = { + source: 'sourceId', + uid: 0, + tileID: new OverscaledTileID(0, 0, 0, 0, 0), + maxZoom: 10 + }; + + function addData(callback) { + source.loadData({source: 'sourceId', data: JSON.stringify(geoJson)} as LoadGeoJSONParameters, (err) => { + expect(err).toBeNull(); + callback(); + }); + } + + function reloadTile(callback) { + source.reloadTile(tileParams as any as WorkerTileParameters, (err, data) => { + expect(err).toBeNull(); + return callback(data); + }); + } + + addData(() => { + // first call should load vector data from geojson + let firstData; + reloadTile(data => { + firstData = data; + }); + expect(loadVectorCallCount).toBe(1); + + // second call won't give us new rawTileData + reloadTile(data => { + expect('rawTileData' in data).toBeFalsy(); + data.rawTileData = firstData.rawTileData; + expect(data).toEqual(firstData); + }); + + // also shouldn't call loadVectorData again + expect(loadVectorCallCount).toBe(1); + + // replace geojson data + addData(() => { + // should call loadVectorData again after changing geojson data + reloadTile(data => { + expect('rawTileData' in data).toBeTruthy(); + expect(data).toEqual(firstData); + }); + expect(loadVectorCallCount).toBe(2); + done(); + }); + }); + }); + +}); + +describe('resourceTiming', () => { + + const layers = [ + { + id: 'mylayer', + source: 'sourceId', + type: 'symbol', + } + ] as LayerSpecification[]; + const geoJson = { + 'type': 'Feature', + 'geometry': { + 'type': 'Point', + 'coordinates': [0, 0] + } + } as GeoJSON.GeoJSON; + + test('loadData - url', done => { + const exampleResourceTiming = { + connectEnd: 473, + connectStart: 473, + decodedBodySize: 86494, + domainLookupEnd: 473, + domainLookupStart: 473, + duration: 341, + encodedBodySize: 52528, + entryType: 'resource', + fetchStart: 473.5, + initiatorType: 'xmlhttprequest', + name: 'http://localhost:2900/fake.geojson', + nextHopProtocol: 'http/1.1', + redirectEnd: 0, + redirectStart: 0, + requestStart: 477, + responseEnd: 815, + responseStart: 672, + secureConnectionStart: 0 + } as any as PerformanceEntry; + + window.performance.getEntriesByName = jest.fn().mockReturnValue([exampleResourceTiming]); + + const layerIndex = new StyleLayerIndex(layers); + const source = new GeoJSONWorkerSource(actor, layerIndex, [], (params, callback) => { + callback(null, geoJson); + return {cancel: () => {}}; + }); + + source.loadData({source: 'testSource', request: {url: 'http://localhost/nonexistent', collectResourceTiming: true}} as LoadGeoJSONParameters, (err, result) => { + expect(err).toBeNull(); + expect(result.resourceTiming.testSource).toEqual([exampleResourceTiming]); + done(); + }); + }); + + test('loadData - url (resourceTiming fallback method)', done => { + const sampleMarks = [100, 350]; + const marks = {}; + const measures = {}; + window.performance.getEntriesByName = jest.fn().mockImplementation((name) => { return measures[name] || []; }); + jest.spyOn(perf, 'mark').mockImplementation((name) => { + marks[name] = sampleMarks.shift(); + return null; + }); + window.performance.measure = jest.fn().mockImplementation((name, start, end) => { + measures[name] = measures[name] || []; + measures[name].push({ + duration: marks[end] - marks[start], + entryType: 'measure', + name, + startTime: marks[start] + }); + return null; + }); + jest.spyOn(perf, 'clearMarks').mockImplementation(() => { return null; }); + jest.spyOn(perf, 'clearMeasures').mockImplementation(() => { return null; }); + + const layerIndex = new StyleLayerIndex(layers); + const source = new GeoJSONWorkerSource(actor, layerIndex, [], (params, callback) => { + callback(null, geoJson); + return {cancel: () => {}}; + }); + + source.loadData({source: 'testSource', request: {url: 'http://localhost/nonexistent', collectResourceTiming: true}} as LoadGeoJSONParameters, (err, result) => { + expect(err).toBeNull(); + expect(result.resourceTiming.testSource).toEqual( + [{'duration': 250, 'entryType': 'measure', 'name': 'http://localhost/nonexistent', 'startTime': 100}] + ); + done(); + }); + }); + + test('loadData - data', done => { + const layerIndex = new StyleLayerIndex(layers); + const source = new GeoJSONWorkerSource(actor, layerIndex, []); + + source.loadData({source: 'testSource', data: JSON.stringify(geoJson)} as LoadGeoJSONParameters, (err, result) => { + expect(err).toBeNull(); + expect(result.resourceTiming).toBeUndefined(); + done(); + }); + }); + +}); + +describe('loadData', () => { + let server: FakeServer; + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + }); + afterEach(() => { + server.restore(); + }); + + const layers = [ + { + id: 'layer1', + source: 'source1', + type: 'symbol', + }, + { + id: 'layer2', + source: 'source2', + type: 'symbol', + } + ] as LayerSpecification[]; + + const geoJson = { + 'type': 'Feature', + 'geometry': { + 'type': 'Point', + 'coordinates': [0, 0] + } + } as GeoJSON.GeoJSON; + + const updateableGeoJson = { + type: 'Feature', + id: 'point', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, + properties: {}, + } as GeoJSON.GeoJSON; + + const layerIndex = new StyleLayerIndex(layers); + function createWorker() { + const worker = new GeoJSONWorkerSource(actor, layerIndex, []); + + // Making the call to loadGeoJSON asynchronous + // allows these tests to mimic a message queue building up + // (regardless of timing) + const originalLoadGeoJSON = worker.loadGeoJSON; + worker.loadGeoJSON = function(params, callback) { + const timeout = setTimeout(() => { + originalLoadGeoJSON(params, callback); + }, 0); + + return {cancel: () => clearTimeout(timeout)}; + }; + return worker; + } + + test('abandons previous callbacks', done => { + const worker = createWorker(); + let firstCallbackHasRun = false; + + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)} as LoadGeoJSONParameters, (err, result) => { + expect(err).toBeNull(); + expect(result && result.abandoned).toBeTruthy(); + firstCallbackHasRun = true; + }); + + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)} as LoadGeoJSONParameters, (err, result) => { + expect(err).toBeNull(); + expect(result && result.abandoned).toBeFalsy(); + expect(firstCallbackHasRun).toBeTruthy(); + done(); + }); + }); + + test('removeSource aborts callbacks', done => { + const worker = createWorker(); + let loadDataCallbackHasRun = false; + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)} as LoadGeoJSONParameters, (err, result) => { + expect(err).toBeNull(); + expect(result && result.abandoned).toBeTruthy(); + loadDataCallbackHasRun = true; + }); + + worker.removeSource({source: 'source1'}, (err) => { + expect(err).toBeFalsy(); + expect(loadDataCallbackHasRun).toBeTruthy(); + done(); + }); + }); + + test('loadData with geojson creates an non-updateable source', done => { + const worker = new GeoJSONWorkerSource(actor, layerIndex, []); + + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + worker.loadData({source: 'source1', dataDiff: {removeAll: true}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeDefined(); + done(); + }); + }); + }); + + test('loadData with geojson creates an updateable source', done => { + const worker = new GeoJSONWorkerSource(actor, layerIndex, []); + + worker.loadData({source: 'source1', data: JSON.stringify(updateableGeoJson)} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + worker.loadData({source: 'source1', dataDiff: {removeAll: true}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + done(); + }); + }); + }); + + test('loadData with geojson network call creates an updateable source', done => { + const worker = new GeoJSONWorkerSource(actor, layerIndex, []); + + server.respondWith(request => { + request.respond(200, {'Content-Type': 'application/json'}, JSON.stringify(updateableGeoJson)); + }); + + worker.loadData({source: 'source1', request: {url: ''}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + worker.loadData({source: 'source1', dataDiff: {removeAll: true}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + done(); + }); + }); + + server.respond(); + }); + + test('loadData with geojson network call creates a non-updateable source', done => { + const worker = new GeoJSONWorkerSource(actor, layerIndex, []); + + server.respondWith(request => { + request.respond(200, {'Content-Type': 'application/json'}, JSON.stringify(geoJson)); + }); + + worker.loadData({source: 'source1', request: {url: ''}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + worker.loadData({source: 'source1', dataDiff: {removeAll: true}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeDefined(); + done(); + }); + }); + + server.respond(); + }); + + test('loadData with diff updates', done => { + const worker = new GeoJSONWorkerSource(actor, layerIndex, []); + + worker.loadData({source: 'source1', data: JSON.stringify(updateableGeoJson)} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + worker.loadData({source: 'source1', dataDiff: { + add: [{ + type: 'Feature', + id: 'update_point', + geometry: {type: 'Point', coordinates: [0, 0]}, + properties: {} + }]}} as LoadGeoJSONParameters, (err, _result) => { + expect(err).toBeNull(); + done(); + }); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/geojson_worker_source.ts b/web/libraries/maplibre-gl/src/source/geojson_worker_source.ts new file mode 100644 index 00000000..a0fc131c --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_worker_source.ts @@ -0,0 +1,327 @@ +import {getJSON} from '../util/ajax'; + +import {RequestPerformance} from '../util/performance'; +import rewind from '@mapbox/geojson-rewind'; +import {GeoJSONWrapper} from './geojson_wrapper'; +import vtpbf from 'vt-pbf'; +import Supercluster, {type Options as SuperclusterOptions, type ClusterProperties} from 'supercluster'; +import geojsonvt, {type Options as GeoJSONVTOptions} from 'geojson-vt'; +import {VectorTileWorkerSource} from './vector_tile_worker_source'; +import {createExpression} from '@maplibre/maplibre-gl-style-spec'; + +import type { + WorkerTileParameters, + WorkerTileCallback, +} from '../source/worker_source'; + +import type {Actor} from '../util/actor'; +import type {StyleLayerIndex} from '../style/style_layer_index'; + +import type {LoadVectorDataCallback} from './vector_tile_worker_source'; +import type {RequestParameters, ResponseCallback} from '../util/ajax'; +import type {Callback} from '../types/callback'; +import type {Cancelable} from '../types/cancelable'; +import {isUpdateableGeoJSON, type GeoJSONSourceDiff, applySourceDiff, toUpdateable, GeoJSONFeatureId} from './geojson_source_diff'; + +export type LoadGeoJSONParameters = { + request?: RequestParameters; + /** + * Literal GeoJSON data. Must be provided if `request.url` is not. + */ + data?: string; + dataDiff?: GeoJSONSourceDiff; + source: string; + cluster: boolean; + superclusterOptions?: SuperclusterOptions; + geojsonVtOptions?: GeoJSONVTOptions; + clusterProperties?: ClusterProperties; + filter?: Array; + promoteId?: string; +}; + +export type LoadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback) => Cancelable; + +type GeoJSONIndex = ReturnType | Supercluster; + +/** + * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}. + * This class is designed to be easily reused to support custom source types + * for data formats that can be parsed/converted into an in-memory GeoJSON + * representation. To do so, create it with + * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`. + * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson). + */ +export class GeoJSONWorkerSource extends VectorTileWorkerSource { + _pendingCallback: Callback<{ + resourceTiming?: {[_: string]: Array}; + abandoned?: boolean; + }>; + _pendingRequest: Cancelable; + _geoJSONIndex: GeoJSONIndex; + _dataUpdateable = new Map(); + + /** + * @param loadGeoJSON - Optional method for custom loading/parsing of + * GeoJSON based on parameters passed from the main-thread Source. + * See {@link GeoJSONWorkerSource#loadGeoJSON}. + */ + constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadGeoJSON?: LoadGeoJSON | null) { + super(actor, layerIndex, availableImages); + this.loadVectorData = this.loadGeoJSONTile; + if (loadGeoJSON) { + this.loadGeoJSON = loadGeoJSON; + } + } + + loadGeoJSONTile(params: WorkerTileParameters, callback: LoadVectorDataCallback): (() => void) | void { + const canonical = params.tileID.canonical; + + if (!this._geoJSONIndex) { + return callback(null, null); // we couldn't load the file + } + + const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y); + if (!geoJSONTile) { + return callback(null, null); // nothing in the given tile + } + + const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features); + // Encode the geojson-vt tile into binary vector tile form. This + // is a convenience that allows `FeatureIndex` to operate the same way + // across `VectorTileSource` and `GeoJSONSource` data. + let pbf = vtpbf(geojsonWrapper); + if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) { + // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35) + pbf = new Uint8Array(pbf); + } + + callback(null, { + vectorTile: geojsonWrapper, + rawData: pbf.buffer + }); + } + + /** + * Fetches (if appropriate), parses, and index geojson data into tiles. This + * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile} + * can correctly serve up tiles. + * + * Defers to {@link GeoJSONWorkerSource#loadGeoJSON} for the fetching/parsing, + * expecting `callback(error, data)` to be called with either an error or a + * parsed GeoJSON object. + * + * When a `loadData` request comes in while a previous one is being processed, + * the previous one is aborted. + * + * @param params - the parameters + * @param callback - the callback for completion or error + */ + loadData(params: LoadGeoJSONParameters, callback: Callback<{ + resourceTiming?: {[_: string]: Array}; + abandoned?: boolean; + }>) { + this._pendingRequest?.cancel(); + if (this._pendingCallback) { + // Tell the foreground the previous call has been abandoned + this._pendingCallback(null, {abandoned: true}); + } + + const perf = (params && params.request && params.request.collectResourceTiming) ? + new RequestPerformance(params.request) : false; + + this._pendingCallback = callback; + this._pendingRequest = this.loadGeoJSON(params, (err?: Error | null, data?: any | null) => { + delete this._pendingCallback; + delete this._pendingRequest; + + if (err || !data) { + return callback(err); + } else if (typeof data !== 'object') { + return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); + } else { + rewind(data, true); + + try { + if (params.filter) { + const compiled = createExpression(params.filter, {type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false} as any); + if (compiled.result === 'error') + throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', ')); + + const features = data.features.filter(feature => compiled.value.evaluate({zoom: 0}, feature)); + data = {type: 'FeatureCollection', features}; + } + + this._geoJSONIndex = params.cluster ? + new Supercluster(getSuperclusterOptions(params)).load(data.features) : + geojsonvt(data, params.geojsonVtOptions); + } catch (err) { + return callback(err); + } + + this.loaded = {}; + + const result = {} as { resourceTiming: any }; + if (perf) { + const resourceTimingData = perf.finish(); + // it's necessary to eval the result of getEntriesByName() here via parse/stringify + // late evaluation in the main thread causes TypeError: illegal invocation + if (resourceTimingData) { + result.resourceTiming = {}; + result.resourceTiming[params.source] = JSON.parse(JSON.stringify(resourceTimingData)); + } + } + callback(null, result); + } + }); + } + + /** + * Implements {@link WorkerSource#reloadTile}. + * + * If the tile is loaded, uses the implementation in VectorTileWorkerSource. + * Otherwise, such as after a setData() call, we load the tile fresh. + * + * @param params - the parameters + * @param callback - the callback for completion or error + */ + reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) { + const loaded = this.loaded, + uid = params.uid; + + if (loaded && loaded[uid]) { + return super.reloadTile(params, callback); + } else { + return this.loadTile(params, callback); + } + } + + /** + * Fetch and parse GeoJSON according to the given params. Calls `callback` + * with `(err, data)`, where `data` is a parsed GeoJSON object. + * + * GeoJSON is loaded and parsed from `params.url` if it exists, or else + * expected as a literal (string or object) `params.data`. + * + * @param params - the parameters + * @param callback - the callback for completion or error + * @returns A Cancelable object. + */ + loadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback): Cancelable => { + const {promoteId} = params; + // Because of same origin issues, urls must either include an explicit + // origin or absolute path. + // ie: /foo/bar.json or http://example.com/bar.json + // but not ../foo/bar.json + if (params.request) { + return getJSON(params.request, ( + error?: Error, + data?: any, + cacheControl?: string, + expires?: string + ) => { + this._dataUpdateable = isUpdateableGeoJSON(data, promoteId) ? toUpdateable(data, promoteId) : undefined; + callback(error, data, cacheControl, expires); + }); + } else if (typeof params.data === 'string') { + try { + const parsed = JSON.parse(params.data); + this._dataUpdateable = isUpdateableGeoJSON(parsed, promoteId) ? toUpdateable(parsed, promoteId) : undefined; + callback(null, parsed); + } catch (e) { + callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); + } + } else if (params.dataDiff) { + if (this._dataUpdateable) { + applySourceDiff(this._dataUpdateable, params.dataDiff, promoteId); + callback(null, {type: 'FeatureCollection', features: Array.from(this._dataUpdateable.values())}); + } else { + callback(new Error(`Cannot update existing geojson data in ${params.source}`)); + } + } else { + callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); + } + + return {cancel: () => {}}; + }; + + removeSource(params: { + source: string; + }, callback: WorkerTileCallback) { + if (this._pendingCallback) { + // Don't leak callbacks + this._pendingCallback(null, {abandoned: true}); + } + callback(); + } + + getClusterExpansionZoom(params: { + clusterId: number; + }, callback: Callback) { + try { + callback(null, (this._geoJSONIndex as Supercluster).getClusterExpansionZoom(params.clusterId)); + } catch (e) { + callback(e); + } + } + + getClusterChildren(params: { + clusterId: number; + }, callback: Callback>) { + try { + callback(null, (this._geoJSONIndex as Supercluster).getChildren(params.clusterId)); + } catch (e) { + callback(e); + } + } + + getClusterLeaves(params: { + clusterId: number; + limit: number; + offset: number; + }, callback: Callback>) { + try { + callback(null, (this._geoJSONIndex as Supercluster).getLeaves(params.clusterId, params.limit, params.offset)); + } catch (e) { + callback(e); + } + } +} + +function getSuperclusterOptions({superclusterOptions, clusterProperties}: LoadGeoJSONParameters) { + if (!clusterProperties || !superclusterOptions) return superclusterOptions; + + const mapExpressions = {}; + const reduceExpressions = {}; + const globals = {accumulated: null, zoom: 0}; + const feature = {properties: null}; + const propertyNames = Object.keys(clusterProperties); + + for (const key of propertyNames) { + const [operator, mapExpression] = clusterProperties[key]; + + const mapExpressionParsed = createExpression(mapExpression); + const reduceExpressionParsed = createExpression( + typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator); + + mapExpressions[key] = mapExpressionParsed.value; + reduceExpressions[key] = reduceExpressionParsed.value; + } + + superclusterOptions.map = (pointProperties) => { + feature.properties = pointProperties; + const properties = {}; + for (const key of propertyNames) { + properties[key] = mapExpressions[key].evaluate(globals, feature); + } + return properties; + }; + superclusterOptions.reduce = (accumulated, clusterProperties) => { + feature.properties = clusterProperties; + for (const key of propertyNames) { + globals.accumulated = accumulated[key]; + accumulated[key] = reduceExpressions[key].evaluate(globals, feature); + } + }; + + return superclusterOptions; +} diff --git a/web/libraries/maplibre-gl/src/source/geojson_wrapper.test.ts b/web/libraries/maplibre-gl/src/source/geojson_wrapper.test.ts new file mode 100644 index 00000000..b0f37a28 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_wrapper.test.ts @@ -0,0 +1,32 @@ +import {GeoJSONWrapper} from './geojson_wrapper'; + +describe('geojsonwrapper', () => { + test('linestring', () => { + const features = [{ + type: 2, + geometry: [[[0, 0], [10, 10]]], + tags: {hello: 'world'} + }]; + + const wrap = new GeoJSONWrapper(features as any); + const feature = wrap.feature(0); + + expect(feature).toBeTruthy(); + expect(feature.loadGeometry()).toEqual([[{x: 0, y: 0}, {x: 10, y: 10}]]); + expect(feature.type).toBe(2); + expect(feature.properties).toEqual({hello: 'world'}); + + }); + + test('point', () => { + const features = [{ + type: 1, + geometry: [[0, 1]], + tags: {} + }]; + + const wrap = new GeoJSONWrapper(features as any); + const feature = wrap.feature(0); + expect(feature.loadGeometry()).toEqual([[{x: 0, y: 1}]]); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/geojson_wrapper.ts b/web/libraries/maplibre-gl/src/source/geojson_wrapper.ts new file mode 100644 index 00000000..a7098c89 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/geojson_wrapper.ts @@ -0,0 +1,81 @@ +import Point from '@mapbox/point-geometry'; + +import mvt from '@mapbox/vector-tile'; +import type {VectorTileFeature, VectorTileLayer, VectorTile} from '@mapbox/vector-tile'; +const toGeoJSON = mvt.VectorTileFeature.prototype.toGeoJSON; +import {EXTENT} from '../data/extent'; +import type {TileFeature, AnyProps} from 'supercluster'; +import type {Feature as GeoJSONVTFeature} from 'geojson-vt'; + +export type Feature = TileFeature | GeoJSONVTFeature; + +class FeatureWrapper implements VectorTileFeature { + _feature: Feature; + + extent: number; + type: Feature['type']; + id: number; + properties: {[_: string]: string | number | boolean}; + + constructor(feature: Feature) { + this._feature = feature; + + this.extent = EXTENT; + this.type = feature.type; + this.properties = feature.tags; + + // If the feature has a top-level `id` property, copy it over, but only + // if it can be coerced to an integer, because this wrapper is used for + // serializing geojson feature data into vector tile PBF data, and the + // vector tile spec only supports integer values for feature ids -- + // allowing non-integer values here results in a non-compliant PBF + // that causes an exception when it is parsed with vector-tile-js + if ('id' in feature && !isNaN(feature.id as any)) { + this.id = parseInt(feature.id, 10); + } + } + + loadGeometry() { + if (this._feature.type === 1) { + const geometry = []; + for (const point of this._feature.geometry) { + geometry.push([new Point(point[0], point[1])]); + } + return geometry; + } else { + const geometry = []; + for (const ring of this._feature.geometry) { + const newRing = []; + for (const point of ring) { + newRing.push(new Point(point[0], point[1])); + } + geometry.push(newRing); + } + return geometry; + } + } + + toGeoJSON(x: number, y: number, z: number) { + return toGeoJSON.call(this, x, y, z); + } +} + +export class GeoJSONWrapper implements VectorTile, VectorTileLayer { + layers: {[_: string]: VectorTileLayer}; + name: string; + extent: number; + length: number; + _features: Array; + + constructor(features: Array) { + this.layers = {'_geojsonTileLayer': this}; + this.name = '_geojsonTileLayer'; + this.extent = EXTENT; + this.length = features.length; + this._features = features; + } + + feature(i: number): VectorTileFeature { + return new FeatureWrapper(this._features[i]); + } +} diff --git a/web/libraries/maplibre-gl/src/source/image_source.test.ts b/web/libraries/maplibre-gl/src/source/image_source.test.ts new file mode 100644 index 00000000..124b2a86 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/image_source.test.ts @@ -0,0 +1,205 @@ +import {ImageSource} from './image_source'; +import {Evented} from '../util/evented'; +import {Transform} from '../geo/transform'; +import {extend} from '../util/util'; +import {type FakeServer, fakeServer} from 'nise'; +import {RequestManager} from '../util/request_manager'; +import {Dispatcher} from '../util/dispatcher'; +import {stubAjaxGetImage} from '../util/test/util'; +import {Tile} from './tile'; +import {OverscaledTileID} from './tile_id'; +import {VertexBuffer} from '../gl/vertex_buffer'; +import {SegmentVector} from '../data/segment'; +import {Texture} from '../render/texture'; +import type {ImageSourceSpecification} from '@maplibre/maplibre-gl-style-spec'; + +function createSource(options) { + options = extend({ + coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]] + }, options); + + const source = new ImageSource('id', options, {send() {}} as any as Dispatcher, options.eventedParent); + return source; +} + +class StubMap extends Evented { + transform: Transform; + painter: any; + _requestManager: RequestManager; + + constructor() { + super(); + this.transform = new Transform(); + this._requestManager = { + transformRequest: (url) => { + return {url}; + } + } as any as RequestManager; + this.painter = { + context: { + gl: {} + } + }; + } +} + +describe('ImageSource', () => { + stubAjaxGetImage(undefined); + let server: FakeServer; + + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + server.respondWith(new ArrayBuffer(1)); + }); + + test('constructor', () => { + const source = createSource({url: '/image.png'}); + + expect(source.minzoom).toBe(0); + expect(source.maxzoom).toBe(22); + expect(source.tileSize).toBe(512); + }); + + test('fires dataloading event', () => { + const source = createSource({url: '/image.png'}); + source.on('dataloading', (e) => { + expect(e.dataType).toBe('source'); + }); + source.onAdd(new StubMap() as any); + server.respond(); + expect(source.image).toBeTruthy(); + }); + + test('transforms url request', () => { + const source = createSource({url: '/image.png'}); + const map = new StubMap() as any; + const spy = jest.spyOn(map._requestManager, 'transformRequest'); + source.onAdd(map); + server.respond(); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0]).toBe('/image.png'); + expect(spy.mock.calls[0][1]).toBe('Image'); + }); + + test('updates url from updateImage', () => { + const source = createSource({url: '/image.png'}); + const map = new StubMap() as any; + const spy = jest.spyOn(map._requestManager, 'transformRequest'); + source.onAdd(map); + server.respond(); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0]).toBe('/image.png'); + expect(spy.mock.calls[0][1]).toBe('Image'); + source.updateImage({url: '/image2.png'}); + server.respond(); + expect(spy).toHaveBeenCalledTimes(2); + expect(spy.mock.calls[1][0]).toBe('/image2.png'); + expect(spy.mock.calls[1][1]).toBe('Image'); + }); + + test('sets coordinates', () => { + const source = createSource({url: '/image.png'}); + const map = new StubMap() as any; + source.onAdd(map); + server.respond(); + const beforeSerialized = source.serialize(); + expect(beforeSerialized.coordinates).toEqual([[0, 0], [1, 0], [1, 1], [0, 1]]); + source.setCoordinates([[0, 0], [-1, 0], [-1, -1], [0, -1]]); + const afterSerialized = source.serialize(); + expect(afterSerialized.coordinates).toEqual([[0, 0], [-1, 0], [-1, -1], [0, -1]]); + }); + + test('sets coordinates via updateImage', () => { + const source = createSource({url: '/image.png'}); + const map = new StubMap() as any; + source.onAdd(map); + server.respond(); + const beforeSerialized = source.serialize(); + expect(beforeSerialized.coordinates).toEqual([[0, 0], [1, 0], [1, 1], [0, 1]]); + source.updateImage({ + url: '/image2.png', + coordinates: [[0, 0], [-1, 0], [-1, -1], [0, -1]] + }); + server.respond(); + const afterSerialized = source.serialize(); + expect(afterSerialized.coordinates).toEqual([[0, 0], [-1, 0], [-1, -1], [0, -1]]); + }); + + test('fires data event when content is loaded', done => { + const source = createSource({url: '/image.png'}); + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'content') { + expect(typeof source.tileID == 'object').toBeTruthy(); + done(); + } + }); + source.onAdd(new StubMap() as any); + server.respond(); + }); + + test('fires data event when metadata is loaded', done => { + const source = createSource({url: '/image.png'}); + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + done(); + } + }); + source.onAdd(new StubMap() as any); + server.respond(); + }); + + test('fires idle event on prepare call when there is at least one not loaded tile', done => { + const source = createSource({url: '/image.png'}); + const tile = new Tile(new OverscaledTileID(1, 0, 1, 0, 0), 512); + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'idle') { + expect(tile.state).toBe('loaded'); + done(); + } + }); + source.onAdd(new StubMap() as any); + server.respond(); + + source.tiles[String(tile.tileID.wrap)] = tile; + source.image = new ImageBitmap(); + // assign dummies directly so we don't need to stub the gl things + source.boundsBuffer = {} as VertexBuffer; + source.boundsSegments = {} as SegmentVector; + source.texture = {} as Texture; + source.prepare(); + }); + + test('serialize url and coordinates', () => { + const source = createSource({url: '/image.png'}); + + const serialized = source.serialize() as ImageSourceSpecification; + expect(serialized.type).toBe('image'); + expect(serialized.url).toBe('/image.png'); + expect(serialized.coordinates).toEqual([[0, 0], [1, 0], [1, 1], [0, 1]]); + }); + + test('allows using updateImage before initial image is loaded', () => { + const source = createSource({url: '/image.png'}); + const map = new StubMap() as any; + + source.onAdd(map); + + expect(source.image).toBeUndefined(); + source.updateImage({url: '/image2.png'}); + server.respond(); + expect(source.image).toBeTruthy(); + }); + + test('cancels request if updateImage is used', () => { + const source = createSource({url: '/image.png'}); + const map = new StubMap() as any; + + source.onAdd(map); + + const spy = jest.spyOn(server.requests[0] as any, 'abort'); + + source.updateImage({url: '/image2.png'}); + expect(spy).toHaveBeenCalled(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/image_source.ts b/web/libraries/maplibre-gl/src/source/image_source.ts new file mode 100644 index 00000000..8be422aa --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/image_source.ts @@ -0,0 +1,343 @@ +import {CanonicalTileID} from './tile_id'; +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {ImageRequest} from '../util/image_request'; +import {ResourceType} from '../util/request_manager'; +import {EXTENT} from '../data/extent'; +import {RasterBoundsArray} from '../data/array_types.g'; +import rasterBoundsAttributes from '../data/raster_bounds_attributes'; +import {SegmentVector} from '../data/segment'; +import {Texture} from '../render/texture'; +import {MercatorCoordinate} from '../geo/mercator_coordinate'; + +import type {Source} from './source'; +import type {CanvasSourceSpecification} from './canvas_source'; +import type {Map} from '../ui/map'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Tile} from './tile'; +import type {Callback} from '../types/callback'; +import type {VertexBuffer} from '../gl/vertex_buffer'; +import type { + ImageSourceSpecification, + VideoSourceSpecification +} from '@maplibre/maplibre-gl-style-spec'; +import {Cancelable} from '../types/cancelable'; + +/** + * Four geographical coordinates, + * represented as arrays of longitude and latitude numbers, which define the corners of the image. + * The coordinates start at the top left corner of the image and proceed in clockwise order. + * They do not have to represent a rectangle. + */ +export type Coordinates = [[number, number], [number, number], [number, number], [number, number]]; + +/** + * The options object for the {@link ImageSource#updateImage} method + */ +export type UpdateImageOptions = { + /** + * Required image URL. + */ + url: string; + /** + * The image coordinates + */ + coordinates?: Coordinates; +} + +/** + * A data source containing an image. + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-image) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * // add to map + * map.addSource('some id', { + * type: 'image', + * url: 'https://www.maplibre.org/images/foo.png', + * coordinates: [ + * [-76.54, 39.18], + * [-76.52, 39.18], + * [-76.52, 39.17], + * [-76.54, 39.17] + * ] + * }); + * + * // update coordinates + * let mySource = map.getSource('some id'); + * mySource.setCoordinates([ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ]); + * + * // update url and coordinates simultaneously + * mySource.updateImage({ + * url: 'https://www.maplibre.org/images/bar.png', + * coordinates: [ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ] + * }) + * + * map.removeSource('some id'); // remove + * ``` + */ +export class ImageSource extends Evented implements Source { + type: string; + id: string; + minzoom: number; + maxzoom: number; + tileSize: number; + url: string; + + coordinates: Coordinates; + tiles: {[_: string]: Tile}; + options: any; + dispatcher: Dispatcher; + map: Map; + texture: Texture | null; + image: HTMLImageElement | ImageBitmap; + tileID: CanonicalTileID; + _boundsArray: RasterBoundsArray; + boundsBuffer: VertexBuffer; + boundsSegments: SegmentVector; + _loaded: boolean; + _request: Cancelable; + + /** @internal */ + constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) { + super(); + this.id = id; + this.dispatcher = dispatcher; + this.coordinates = options.coordinates; + + this.type = 'image'; + this.minzoom = 0; + this.maxzoom = 22; + this.tileSize = 512; + this.tiles = {}; + this._loaded = false; + + this.setEventedParent(eventedParent); + + this.options = options; + } + + load = (newCoordinates?: Coordinates, successCallback?: () => void) => { + this._loaded = false; + this.fire(new Event('dataloading', {dataType: 'source'})); + + this.url = this.options.url; + + this._request = ImageRequest.getImage(this.map._requestManager.transformRequest(this.url, ResourceType.Image), (err, image) => { + this._request = null; + this._loaded = true; + + if (err) { + this.fire(new ErrorEvent(err)); + } else if (image) { + this.image = image; + if (newCoordinates) { + this.coordinates = newCoordinates; + } + if (successCallback) { + successCallback(); + } + this._finishLoading(); + } + }); + }; + + loaded(): boolean { + return this._loaded; + } + + /** + * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing, + * set the `raster-fade-duration` paint property on the raster layer to 0. + * + * @param options - The options object. + * @returns `this` + */ + updateImage(options: UpdateImageOptions): this { + if (!options.url) { + return this; + } + + if (this._request) { + this._request.cancel(); + this._request = null; + } + + this.options.url = options.url; + this.load(options.coordinates, () => { this.texture = null; }); + return this; + } + + _finishLoading() { + if (this.map) { + this.setCoordinates(this.coordinates); + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'})); + } + } + + onAdd(map: Map) { + this.map = map; + this.load(); + } + + onRemove() { + if (this._request) { + this._request.cancel(); + this._request = null; + } + } + + /** + * Sets the image's coordinates and re-renders the map. + * + * @param coordinates - Four geographical coordinates, + * represented as arrays of longitude and latitude numbers, which define the corners of the image. + * The coordinates start at the top left corner of the image and proceed in clockwise order. + * They do not have to represent a rectangle. + * @returns `this` + */ + setCoordinates(coordinates: Coordinates): this { + this.coordinates = coordinates; + + // Calculate which mercator tile is suitable for rendering the video in + // and create a buffer with the corner coordinates. These coordinates + // may be outside the tile, because raster tiles aren't clipped when rendering. + + // transform the geo coordinates into (zoom 0) tile space coordinates + const cornerCoords = coordinates.map(MercatorCoordinate.fromLngLat); + + // Compute the coordinates of the tile we'll use to hold this image's + // render data + this.tileID = getCoordinatesCenterTileID(cornerCoords); + + // Constrain min/max zoom to our tile's zoom level in order to force + // SourceCache to request this tile (no matter what the map's zoom + // level) + this.minzoom = this.maxzoom = this.tileID.z; + + // Transform the corner coordinates into the coordinate space of our + // tile. + const tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round()); + + this._boundsArray = new RasterBoundsArray(); + this._boundsArray.emplaceBack(tileCoords[0].x, tileCoords[0].y, 0, 0); + this._boundsArray.emplaceBack(tileCoords[1].x, tileCoords[1].y, EXTENT, 0); + this._boundsArray.emplaceBack(tileCoords[3].x, tileCoords[3].y, 0, EXTENT); + this._boundsArray.emplaceBack(tileCoords[2].x, tileCoords[2].y, EXTENT, EXTENT); + + if (this.boundsBuffer) { + this.boundsBuffer.destroy(); + delete this.boundsBuffer; + } + + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'})); + return this; + } + + prepare = () => { + if (Object.keys(this.tiles).length === 0 || !this.image) { + return; + } + + const context = this.map.painter.context; + const gl = context.gl; + + if (!this.boundsBuffer) { + this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members); + } + + if (!this.boundsSegments) { + this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2); + } + + if (!this.texture) { + this.texture = new Texture(context, this.image, gl.RGBA); + this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + } + + let newTilesLoaded = false; + for (const w in this.tiles) { + const tile = this.tiles[w]; + if (tile.state !== 'loaded') { + tile.state = 'loaded'; + tile.texture = this.texture; + newTilesLoaded = true; + } + } + + if (newTilesLoaded) { + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id})); + } + }; + + loadTile(tile: Tile, callback: Callback) { + // We have a single tile -- whose coordinates are this.tileID -- that + // covers the image we want to render. If that's the one being + // requested, set it up with the image; otherwise, mark the tile as + // `errored` to indicate that we have no data for it. + // If the world wraps, we may have multiple "wrapped" copies of the + // single tile. + if (this.tileID && this.tileID.equals(tile.tileID.canonical)) { + this.tiles[String(tile.tileID.wrap)] = tile; + tile.buckets = {}; + callback(null); + } else { + tile.state = 'errored'; + callback(null); + } + } + + serialize = (): ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification => { + return { + type: 'image', + url: this.options.url, + coordinates: this.coordinates + }; + }; + + hasTransition() { + return false; + } +} + +/** + * Given a list of coordinates, get their center as a coordinate. + * + * @returns centerpoint + * @internal + */ +export function getCoordinatesCenterTileID(coords: Array) { + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + + for (const coord of coords) { + minX = Math.min(minX, coord.x); + minY = Math.min(minY, coord.y); + maxX = Math.max(maxX, coord.x); + maxY = Math.max(maxY, coord.y); + } + + const dx = maxX - minX; + const dy = maxY - minY; + const dMax = Math.max(dx, dy); + const zoom = Math.max(0, Math.floor(-Math.log(dMax) / Math.LN2)); + const tilesAtZoom = Math.pow(2, zoom); + + return new CanonicalTileID( + zoom, + Math.floor((minX + maxX) / 2 * tilesAtZoom), + Math.floor((minY + maxY) / 2 * tilesAtZoom)); +} diff --git a/web/libraries/maplibre-gl/src/source/load_tilejson.ts b/web/libraries/maplibre-gl/src/source/load_tilejson.ts new file mode 100644 index 00000000..9fc6e61f --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/load_tilejson.ts @@ -0,0 +1,42 @@ +import {pick, extend} from '../util/util'; + +import {getJSON} from '../util/ajax'; +import {ResourceType} from '../util/request_manager'; +import {browser} from '../util/browser'; + +import type {RequestManager} from '../util/request_manager'; +import type {Callback} from '../types/callback'; +import type {TileJSON} from '../types/tilejson'; +import type {Cancelable} from '../types/cancelable'; +import type {RasterDEMSourceSpecification, RasterSourceSpecification, VectorSourceSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export function loadTileJson( + options: RasterSourceSpecification | RasterDEMSourceSpecification | VectorSourceSpecification, + requestManager: RequestManager, + callback: Callback +): Cancelable { + const loaded = function(err: Error, tileJSON: any) { + if (err) { + return callback(err); + } else if (tileJSON) { + const result: any = pick( + // explicit source options take precedence over TileJSON + extend(tileJSON, options), + ['tiles', 'minzoom', 'maxzoom', 'attribution', 'bounds', 'scheme', 'tileSize', 'encoding'] + ); + + if (tileJSON.vector_layers) { + result.vectorLayers = tileJSON.vector_layers; + result.vectorLayerIds = result.vectorLayers.map((layer) => { return layer.id; }); + } + + callback(null, result); + } + }; + + if (options.url) { + return getJSON(requestManager.transformRequest(options.url, ResourceType.Source), loaded); + } else { + return browser.frame(() => loaded(null, options)); + } +} diff --git a/web/libraries/maplibre-gl/src/source/pixels_to_tile_units.ts b/web/libraries/maplibre-gl/src/source/pixels_to_tile_units.ts new file mode 100644 index 00000000..7d44b005 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/pixels_to_tile_units.ts @@ -0,0 +1,25 @@ +import {EXTENT} from '../data/extent'; + +import type {OverscaledTileID} from './tile_id'; + +/** + * Converts a pixel value at a the given zoom level to tile units. + * + * The shaders mostly calculate everything in tile units so style + * properties need to be converted from pixels to tile units using this. + * + * For example, a translation by 30 pixels at zoom 6.5 will be a + * translation by pixelsToTileUnits(30, 6.5) tile units. + * + * @returns value in tile units + */ +export function pixelsToTileUnits( + tile: { + tileID: OverscaledTileID; + tileSize: number; + }, + pixelValue: number, + z: number +): number { + return pixelValue * (EXTENT / (tile.tileSize * Math.pow(2, z - tile.tileID.overscaledZ))); +} diff --git a/web/libraries/maplibre-gl/src/source/query_features.test.ts b/web/libraries/maplibre-gl/src/source/query_features.test.ts new file mode 100644 index 00000000..b9ff7f86 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/query_features.test.ts @@ -0,0 +1,36 @@ +import { + queryRenderedFeatures, + querySourceFeatures +} from './query_features'; +import {SourceCache} from './source_cache'; +import {Transform} from '../geo/transform'; +import Point from '@mapbox/point-geometry'; +import {Dispatcher} from '../util/dispatcher'; + +describe('QueryFeatures#rendered', () => { + test('returns empty object if source returns no tiles', () => { + const mockSourceCache = {tilesIn () { return []; }} as any as SourceCache; + const transform = new Transform(); + const result = queryRenderedFeatures(mockSourceCache, {}, undefined, [] as Point[], undefined, transform); + expect(result).toEqual({}); + }); + +}); + +describe('QueryFeatures#source', () => { + test('returns empty result when source has no features', () => { + const sourceCache = new SourceCache('test', { + type: 'geojson', + data: {type: 'FeatureCollection', features: []} + }, { + getActor() { + return { + send(type, params, callback) { return callback(); } + }; + } + } as any as Dispatcher); + const result = querySourceFeatures(sourceCache, {}); + expect(result).toEqual([]); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/source/query_features.ts b/web/libraries/maplibre-gl/src/source/query_features.ts new file mode 100644 index 00000000..18bb52bf --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/query_features.ts @@ -0,0 +1,252 @@ +import type {SourceCache} from './source_cache'; +import type {StyleLayer} from '../style/style_layer'; +import type {CollisionIndex} from '../symbol/collision_index'; +import type {Transform} from '../geo/transform'; +import type {RetainedQueryData} from '../symbol/placement'; +import type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson'; +import type Point from '@mapbox/point-geometry'; +import {mat4} from 'gl-matrix'; + +/** + * Options to pass to query the map for the rendered features + */ +export type QueryRenderedFeaturesOptions = { + /** + * An array of [style layer IDs](https://maplibre.org/maplibre-style-spec/#layer-id) for the query to inspect. + * Only features within these layers will be returned. If this parameter is undefined, all layers will be checked. + */ + layers?: Array; + /** + * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) to limit query results. + */ + filter?: FilterSpecification; + /** + * An array of string representing the available images + */ + availableImages?: Array; + /** + * Whether to check if the [options.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. + */ + validate?: boolean; +}; + +/** + * The options object related to the {@link Map#queryRenderedFeatures} method + */ +export type QuerySourceFeatureOptions = { + /** + * The name of the source layer to query. *For vector tile sources, this parameter is required.* For GeoJSON sources, it is ignored. + */ + sourceLayer?: string; + /** + * A [filter](https://maplibre.org/maplibre-style-spec/layers/#filter) + * to limit query results. + */ + filter?: FilterSpecification; + /** + * Whether to check if the [parameters.filter] conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. + * @defaultValue true + */ + validate?: boolean; +} + +/* + * Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates. + */ +function getPixelPosMatrix(transform, tileID) { + const t = mat4.create(); + mat4.translate(t, t, [1, 1, 0]); + mat4.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]); + return mat4.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped())); +} + +function queryIncludes3DLayer(layers: Array, styleLayers: {[_: string]: StyleLayer}, sourceID: string) { + if (layers) { + for (const layerID of layers) { + const layer = styleLayers[layerID]; + if (layer && layer.source === sourceID && layer.type === 'fill-extrusion') { + return true; + } + } + } else { + for (const key in styleLayers) { + const layer = styleLayers[key]; + if (layer.source === sourceID && layer.type === 'fill-extrusion') { + return true; + } + } + } + return false; +} + +export function queryRenderedFeatures( + sourceCache: SourceCache, + styleLayers: {[_: string]: StyleLayer}, + serializedLayers: {[_: string]: any}, + queryGeometry: Array, + params: QueryRenderedFeaturesOptions, + transform: Transform +): { [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> } { + + const has3DLayer = queryIncludes3DLayer(params && params.layers, styleLayers, sourceCache.id); + const maxPitchScaleFactor = transform.maxPitchScaleFactor(); + const tilesIn = sourceCache.tilesIn(queryGeometry, maxPitchScaleFactor, has3DLayer); + + tilesIn.sort(sortTilesIn); + const renderedFeatureLayers = []; + for (const tileIn of tilesIn) { + renderedFeatureLayers.push({ + wrappedTileID: tileIn.tileID.wrapped().key, + queryResults: tileIn.tile.queryRenderedFeatures( + styleLayers, + serializedLayers, + sourceCache._state, + tileIn.queryGeometry, + tileIn.cameraQueryGeometry, + tileIn.scale, + params, + transform, + maxPitchScaleFactor, + getPixelPosMatrix(sourceCache.transform, tileIn.tileID)) + }); + } + + const result = mergeRenderedFeatureLayers(renderedFeatureLayers); + + // Merge state from SourceCache into the results + for (const layerID in result) { + result[layerID].forEach((featureWrapper) => { + const feature = featureWrapper.feature as MapGeoJSONFeature; + const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id); + feature.source = feature.layer.source; + if (feature.layer['source-layer']) { + feature.sourceLayer = feature.layer['source-layer']; + } + feature.state = state; + }); + } + return result; +} + +export function queryRenderedSymbols(styleLayers: {[_: string]: StyleLayer}, + serializedLayers: {[_: string]: StyleLayer}, + sourceCaches: {[_: string]: SourceCache}, + queryGeometry: Array, + params: QueryRenderedFeaturesOptions, + collisionIndex: CollisionIndex, + retainedQueryData: { + [_: number]: RetainedQueryData; + }) { + const result = {}; + const renderedSymbols = collisionIndex.queryRenderedSymbols(queryGeometry); + const bucketQueryData = []; + for (const bucketInstanceId of Object.keys(renderedSymbols).map(Number)) { + bucketQueryData.push(retainedQueryData[bucketInstanceId]); + } + bucketQueryData.sort(sortTilesIn); + + for (const queryData of bucketQueryData) { + const bucketSymbols = queryData.featureIndex.lookupSymbolFeatures( + renderedSymbols[queryData.bucketInstanceId], + serializedLayers, + queryData.bucketIndex, + queryData.sourceLayerIndex, + params.filter, + params.layers, + params.availableImages, + styleLayers); + + for (const layerID in bucketSymbols) { + const resultFeatures = result[layerID] = result[layerID] || []; + const layerSymbols = bucketSymbols[layerID]; + layerSymbols.sort((a, b) => { + // Match topDownFeatureComparator from FeatureIndex, but using + // most recent sorting of features from bucket.sortFeatures + const featureSortOrder = queryData.featureSortOrder; + if (featureSortOrder) { + // queryRenderedSymbols documentation says we'll return features in + // "top-to-bottom" rendering order (aka last-to-first). + // Actually there can be multiple symbol instances per feature, so + // we sort each feature based on the first matching symbol instance. + const sortedA = featureSortOrder.indexOf(a.featureIndex); + const sortedB = featureSortOrder.indexOf(b.featureIndex); + return sortedB - sortedA; + } else { + // Bucket hasn't been re-sorted based on angle, so use the + // reverse of the order the features appeared in the data. + return b.featureIndex - a.featureIndex; + } + }); + for (const symbolFeature of layerSymbols) { + resultFeatures.push(symbolFeature); + } + } + } + + // Merge state from SourceCache into the results + for (const layerName in result) { + result[layerName].forEach((featureWrapper) => { + const feature = featureWrapper.feature; + const layer = styleLayers[layerName]; + const sourceCache = sourceCaches[layer.source]; + const state = sourceCache.getFeatureState(feature.layer['source-layer'], feature.id); + feature.source = feature.layer.source; + if (feature.layer['source-layer']) { + feature.sourceLayer = feature.layer['source-layer']; + } + feature.state = state; + }); + } + return result; +} + +export function querySourceFeatures(sourceCache: SourceCache, params: QuerySourceFeatureOptions) { + const tiles = sourceCache.getRenderableIds().map((id) => { + return sourceCache.getTileByID(id); + }); + + const result = []; + + const dataTiles = {}; + for (let i = 0; i < tiles.length; i++) { + const tile = tiles[i]; + const dataID = tile.tileID.canonical.key; + if (!dataTiles[dataID]) { + dataTiles[dataID] = true; + tile.querySourceFeatures(result, params); + } + } + + return result; +} + +function sortTilesIn(a, b) { + const idA = a.tileID; + const idB = b.tileID; + return (idA.overscaledZ - idB.overscaledZ) || (idA.canonical.y - idB.canonical.y) || (idA.wrap - idB.wrap) || (idA.canonical.x - idB.canonical.x); +} + +function mergeRenderedFeatureLayers(tiles) { + // Merge results from all tiles, but if two tiles share the same + // wrapped ID, don't duplicate features between the two tiles + const result = {}; + const wrappedIDLayerMap = {}; + for (const tile of tiles) { + const queryResults = tile.queryResults; + const wrappedID = tile.wrappedTileID; + const wrappedIDLayers = wrappedIDLayerMap[wrappedID] = wrappedIDLayerMap[wrappedID] || {}; + for (const layerID in queryResults) { + const tileFeatures = queryResults[layerID]; + const wrappedIDFeatures = wrappedIDLayers[layerID] = wrappedIDLayers[layerID] || {}; + const resultFeatures = result[layerID] = result[layerID] || []; + for (const tileFeature of tileFeatures) { + if (!wrappedIDFeatures[tileFeature.featureIndex]) { + wrappedIDFeatures[tileFeature.featureIndex] = true; + resultFeatures.push(tileFeature); + } + } + } + } + return result; +} diff --git a/web/libraries/maplibre-gl/src/source/raster_dem_tile_source.test.ts b/web/libraries/maplibre-gl/src/source/raster_dem_tile_source.test.ts new file mode 100644 index 00000000..43bf16bb --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/raster_dem_tile_source.test.ts @@ -0,0 +1,167 @@ +import {fakeServer, FakeServer} from 'nise'; +import {RasterDEMTileSource} from './raster_dem_tile_source'; +import {OverscaledTileID} from './tile_id'; +import {RequestManager} from '../util/request_manager'; +import {Dispatcher} from '../util/dispatcher'; +import {Tile} from './tile'; + +function createSource(options, transformCallback?) { + const source = new RasterDEMTileSource('id', options, {send() {}} as any as Dispatcher, options.eventedParent); + source.onAdd({ + transform: {angle: 0, pitch: 0, showCollisionBoxes: false}, + _getMapId: () => 1, + _requestManager: new RequestManager(transformCallback), + getPixelRatio() { return 1; } + } as any); + + source.on('error', (e) => { + throw e.error; + }); + + return source; +} + +describe('RasterTileSource', () => { + let server: FakeServer; + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + }); + + afterEach(() => { + server.restore(); + }); + + test('transforms request for TileJSON URL', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.pngraw'], + bounds: [-47, -7, -45, -5] + })); + const transformSpy = jest.fn().mockImplementation((url) => { + return {url}; + }); + + createSource({url: '/source.json'}, transformSpy); + server.respond(); + + expect(transformSpy.mock.calls[0][0]).toBe('/source.json'); + expect(transformSpy.mock.calls[0][1]).toBe('Source'); + done(); + }); + + test('transforms tile urls before requesting', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + })); + const source = createSource({url: '/source.json'}); + const transformSpy = jest.spyOn(source.map._requestManager, 'transformRequest'); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading', + loadVectorData () {}, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + + expect(transformSpy).toHaveBeenCalledTimes(1); + expect(transformSpy.mock.calls[0][0]).toBe('http://example.com/10/5/5.png'); + expect(transformSpy.mock.calls[0][1]).toBe('Tile'); + done(); + + } + }); + server.respond(); + }); + test('populates neighboringTiles', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + })); + const source = createSource({url: '/source.json'}); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading', + loadVectorData () {}, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + + expect(Object.keys(tile.neighboringTiles)).toEqual([ + new OverscaledTileID(10, 0, 10, 4, 5).key, + new OverscaledTileID(10, 0, 10, 6, 5).key, + new OverscaledTileID(10, 0, 10, 4, 4).key, + new OverscaledTileID(10, 0, 10, 5, 4).key, + new OverscaledTileID(10, 0, 10, 6, 4).key, + new OverscaledTileID(10, 0, 10, 4, 6).key, + new OverscaledTileID(10, 0, 10, 5, 6).key, + new OverscaledTileID(10, 0, 10, 6, 6).key + ]); + + done(); + + } + }); + server.respond(); + }); + + test('populates neighboringTiles with wrapped tiles', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + })); + const source = createSource({url: '/source.json'}); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(5, 0, 5, 31, 5), + state: 'loading', + loadVectorData () {}, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + + expect(Object.keys(tile.neighboringTiles)).toEqual([ + new OverscaledTileID(5, 0, 5, 30, 6).key, + new OverscaledTileID(5, 0, 5, 31, 6).key, + new OverscaledTileID(5, 0, 5, 30, 5).key, + new OverscaledTileID(5, 1, 5, 0, 5).key, + new OverscaledTileID(5, 0, 5, 30, 4).key, + new OverscaledTileID(5, 0, 5, 31, 4).key, + new OverscaledTileID(5, 1, 5, 0, 4).key, + new OverscaledTileID(5, 1, 5, 0, 6).key + ]); + done(); + } + }); + server.respond(); + }); + + it('serializes options', () => { + const source = createSource({ + tiles: ['http://localhost:2900/raster-dem/{z}/{x}/{y}.png'], + minzoom: 2, + maxzoom: 10 + }); + expect(source.serialize()).toStrictEqual({ + type: 'raster-dem', + tiles: ['http://localhost:2900/raster-dem/{z}/{x}/{y}.png'], + minzoom: 2, + maxzoom: 10 + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/raster_dem_tile_source.ts b/web/libraries/maplibre-gl/src/source/raster_dem_tile_source.ts new file mode 100644 index 00000000..19d05224 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/raster_dem_tile_source.ts @@ -0,0 +1,165 @@ +import {ImageRequest} from '../util/image_request'; +import {ResourceType} from '../util/request_manager'; +import {extend, isImageBitmap, readImageUsingVideoFrame} from '../util/util'; +import {Evented} from '../util/evented'; +import {browser} from '../util/browser'; +import {offscreenCanvasSupported} from '../util/offscreen_canvas_supported'; +import {OverscaledTileID} from './tile_id'; +import {RasterTileSource} from './raster_tile_source'; +// ensure DEMData is registered for worker transfer on main thread: +import '../data/dem_data'; +import type {DEMEncoding} from '../data/dem_data'; + +import type {Source} from './source'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Tile} from './tile'; +import type {Callback} from '../types/callback'; +import type {RasterDEMSourceSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {ExpiryData} from '../util/ajax'; +import {isOffscreenCanvasDistorted} from '../util/offscreen_canvas_distorted'; +import {RGBAImage} from '../util/image'; + +/** + * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.) + * This source can be used to show hillshading and 3D terrain + * + * @group Sources + * + * @example + * ```ts + * map.addSource('raster-dem-source', { + * type: 'raster-dem', + * url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json', + * tileSize: 256 + * }); + * ``` + * @see [3D Terrain](https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/) + */ +export class RasterDEMTileSource extends RasterTileSource implements Source { + encoding: DEMEncoding; + redFactor?: number; + greenFactor?: number; + blueFactor?: number; + baseShift?: number; + + constructor(id: string, options: RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) { + super(id, options, dispatcher, eventedParent); + this.type = 'raster-dem'; + this.maxzoom = 22; + this._options = extend({type: 'raster-dem'}, options); + this.encoding = options.encoding || 'mapbox'; + this.redFactor = options.redFactor; + this.greenFactor = options.greenFactor; + this.blueFactor = options.blueFactor; + this.baseShift = options.baseShift; + } + + loadTile(tile: Tile, callback: Callback) { + const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme); + const request = this.map._requestManager.transformRequest(url, ResourceType.Tile); + tile.neighboringTiles = this._getNeighboringTiles(tile.tileID); + tile.request = ImageRequest.getImage(request, async (err: Error, img: (HTMLImageElement | ImageBitmap), expiry: ExpiryData) => { + delete tile.request; + if (tile.aborted) { + tile.state = 'unloaded'; + callback(null); + } else if (err) { + tile.state = 'errored'; + callback(err); + } else if (img) { + if (this.map._refreshExpiredTiles) tile.setExpiryData(expiry); + const transfer = isImageBitmap(img) && offscreenCanvasSupported(); + const rawImageData = transfer ? img : await readImageNow(img); + const params = { + uid: tile.uid, + coord: tile.tileID, + source: this.id, + rawImageData, + encoding: this.encoding, + redFactor: this.redFactor, + greenFactor: this.greenFactor, + blueFactor: this.blueFactor, + baseShift: this.baseShift + }; + + if (!tile.actor || tile.state === 'expired') { + tile.actor = this.dispatcher.getActor(); + tile.actor.send('loadDEMTile', params, done); + } + } + }, this.map._refreshExpiredTiles); + + async function readImageNow(img: ImageBitmap | HTMLImageElement): Promise { + if (typeof VideoFrame !== 'undefined' && isOffscreenCanvasDistorted()) { + const width = img.width + 2; + const height = img.height + 2; + try { + return new RGBAImage({width, height}, await readImageUsingVideoFrame(img, -1, -1, width, height)); + } catch (e) { + // fall-back to browser canvas decoding + } + } + return browser.getImageData(img, 1); + } + + function done(err, data) { + if (err) { + tile.state = 'errored'; + callback(err); + } + + if (data) { + tile.dem = data; + tile.needsHillshadePrepare = true; + tile.needsTerrainPrepare = true; + tile.state = 'loaded'; + callback(null); + } + } + } + + _getNeighboringTiles(tileID: OverscaledTileID) { + const canonical = tileID.canonical; + const dim = Math.pow(2, canonical.z); + + const px = (canonical.x - 1 + dim) % dim; + const pxw = canonical.x === 0 ? tileID.wrap - 1 : tileID.wrap; + const nx = (canonical.x + 1 + dim) % dim; + const nxw = canonical.x + 1 === dim ? tileID.wrap + 1 : tileID.wrap; + + const neighboringTiles = {}; + // add adjacent tiles + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y).key] = {backfilled: false}; + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y).key] = {backfilled: false}; + + // Add upper neighboringTiles + if (canonical.y > 0) { + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y - 1).key] = {backfilled: false}; + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y - 1).key] = {backfilled: false}; + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y - 1).key] = {backfilled: false}; + } + // Add lower neighboringTiles + if (canonical.y + 1 < dim) { + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y + 1).key] = {backfilled: false}; + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y + 1).key] = {backfilled: false}; + neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y + 1).key] = {backfilled: false}; + } + + return neighboringTiles; + } + + unloadTile(tile: Tile) { + if (tile.demTexture) this.map.painter.saveTileTexture(tile.demTexture); + if (tile.fbo) { + tile.fbo.destroy(); + delete tile.fbo; + } + if (tile.dem) delete tile.dem; + delete tile.neighboringTiles; + + tile.state = 'unloaded'; + if (tile.actor) { + tile.actor.send('removeDEMTile', {uid: tile.uid, source: this.id}); + } + } +} diff --git a/web/libraries/maplibre-gl/src/source/raster_dem_tile_worker_source.test.ts b/web/libraries/maplibre-gl/src/source/raster_dem_tile_worker_source.test.ts new file mode 100644 index 00000000..0641912f --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/raster_dem_tile_worker_source.test.ts @@ -0,0 +1,38 @@ +import {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source'; +import {DEMData} from '../data/dem_data'; +import {WorkerDEMTileParameters} from './worker_source'; + +describe('loadTile', () => { + test('loads DEM tile', done => { + const source = new RasterDEMTileWorkerSource(); + + source.loadTile({ + source: 'source', + uid: '0', + rawImageData: {data: new Uint8ClampedArray(256), height: 8, width: 8}, + dim: 256 + } as any as WorkerDEMTileParameters, (err, data) => { + if (err) done(err); + expect(Object.keys(source.loaded)).toEqual(['0']); + expect(data instanceof DEMData).toBeTruthy(); + done(); + }); + }); +}); + +describe('removeTile', () => { + test('removes loaded tile', () => { + const source = new RasterDEMTileWorkerSource(); + + source.loaded = { + '0': {} as DEMData + }; + + source.removeTile({ + source: 'source', + uid: '0' + }); + + expect(source.loaded).toEqual({}); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/raster_dem_tile_worker_source.ts b/web/libraries/maplibre-gl/src/source/raster_dem_tile_worker_source.ts new file mode 100644 index 00000000..d2838046 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/raster_dem_tile_worker_source.ts @@ -0,0 +1,39 @@ +import {DEMData} from '../data/dem_data'; +import {RGBAImage} from '../util/image'; +import type {Actor} from '../util/actor'; +import type { + WorkerDEMTileParameters, + WorkerDEMTileCallback, + TileParameters +} from './worker_source'; +import {getImageData, isImageBitmap} from '../util/util'; + +export class RasterDEMTileWorkerSource { + actor: Actor; + loaded: {[_: string]: DEMData}; + + constructor() { + this.loaded = {}; + } + + async loadTile(params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) { + const {uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift} = params; + const width = rawImageData.width + 2; + const height = rawImageData.height + 2; + const imagePixels: RGBAImage = isImageBitmap(rawImageData) ? + new RGBAImage({width, height}, await getImageData(rawImageData, -1, -1, width, height)) : + rawImageData; + const dem = new DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift); + this.loaded = this.loaded || {}; + this.loaded[uid] = dem; + callback(null, dem); + } + + removeTile(params: TileParameters) { + const loaded = this.loaded, + uid = params.uid; + if (loaded && loaded[uid]) { + delete loaded[uid]; + } + } +} diff --git a/web/libraries/maplibre-gl/src/source/raster_tile_source.test.ts b/web/libraries/maplibre-gl/src/source/raster_tile_source.test.ts new file mode 100644 index 00000000..74f589fd --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/raster_tile_source.test.ts @@ -0,0 +1,197 @@ +import {RasterTileSource} from './raster_tile_source'; +import {OverscaledTileID} from './tile_id'; +import {RequestManager} from '../util/request_manager'; +import {Dispatcher} from '../util/dispatcher'; +import {fakeServer, type FakeServer} from 'nise'; +import {Tile} from './tile'; +import {stubAjaxGetImage} from '../util/test/util'; + +function createSource(options, transformCallback?) { + const source = new RasterTileSource('id', options, {send() {}} as any as Dispatcher, options.eventedParent); + source.onAdd({ + transform: {angle: 0, pitch: 0, showCollisionBoxes: false}, + _getMapId: () => 1, + _requestManager: new RequestManager(transformCallback), + getPixelRatio() { return 1; } + } as any); + + source.on('error', (e) => { + throw e.error; + }); + + return source; +} + +describe('RasterTileSource', () => { + let server: FakeServer; + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + }); + + afterEach(() => { + server.restore(); + }); + + test('transforms request for TileJSON URL', () => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + })); + const transformSpy = jest.fn().mockImplementation((url) => { + return {url}; + }); + + createSource({url: '/source.json'}, transformSpy); + server.respond(); + + expect(transformSpy.mock.calls[0][0]).toBe('/source.json'); + expect(transformSpy.mock.calls[0][1]).toBe('Source'); + }); + + test('respects TileJSON.bounds', done => { + const source = createSource({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + }); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 96, 132))).toBeFalsy(); + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 95, 132))).toBeTruthy(); + done(); + } + }); + }); + + test('does not error on invalid bounds', done => { + const source = createSource({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, 91] + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.tileBounds.bounds).toEqual({_sw: {lng: -47, lat: -7}, _ne: {lng: -45, lat: 90}}); + done(); + } + }); + }); + + test('respects TileJSON.bounds when loaded from TileJSON', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + })); + const source = createSource({url: '/source.json'}); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 96, 132))).toBeFalsy(); + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 95, 132))).toBeTruthy(); + done(); + } + }); + server.respond(); + }); + + test('transforms tile urls before requesting', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + })); + const source = createSource({url: '/source.json'}); + const transformSpy = jest.spyOn(source.map._requestManager, 'transformRequest'); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading', + loadVectorData () {}, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + expect(transformSpy).toHaveBeenCalledTimes(1); + expect(transformSpy.mock.calls[0][0]).toBe('http://example.com/10/5/5.png'); + expect(transformSpy.mock.calls[0][1]).toBe('Tile'); + done(); + } + }); + server.respond(); + }); + + test('HttpImageElement used to get image when refreshExpiredTiles is false', done => { + stubAjaxGetImage(undefined); + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + })); + const source = createSource({url: '/source.json'}); + source.map.painter = {context: {}, getTileTexture: () => { return {update: () => {}}; }} as any; + source.map._refreshExpiredTiles = false; + + const imageConstructorSpy = jest.spyOn(global, 'Image'); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading' + } as any as Tile; + source.loadTile(tile, () => { + expect(imageConstructorSpy).toHaveBeenCalledTimes(1); + expect(tile.state).toBe('loaded'); + done(); + }); + } + }); + server.respond(); + }); + + test('supports updating tiles', () => { + const source = createSource({url: '/source.json'}); + source.setTiles(['http://example.com/{z}/{x}/{y}.png?updated=true']); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.tiles[0]).toBe('http://example.com/{z}/{x}/{y}.png?updated=true'); + } + }); + }); + + test('cancels TileJSON request if removed', () => { + const source = createSource({url: '/source.json'}); + source.onRemove(); + expect((server.requests.pop() as any).aborted).toBe(true); + }); + + it('serializes options', () => { + const source = createSource({ + tiles: ['http://localhost:2900/raster/{z}/{x}/{y}.png'], + minzoom: 2, + maxzoom: 10 + }); + expect(source.serialize()).toStrictEqual({ + type: 'raster', + tiles: ['http://localhost:2900/raster/{z}/{x}/{y}.png'], + minzoom: 2, + maxzoom: 10 + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/raster_tile_source.ts b/web/libraries/maplibre-gl/src/source/raster_tile_source.ts new file mode 100644 index 00000000..66630c50 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/raster_tile_source.ts @@ -0,0 +1,210 @@ +import {extend, pick} from '../util/util'; + +import {ImageRequest} from '../util/image_request'; + +import {ResourceType} from '../util/request_manager'; +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {loadTileJson} from './load_tilejson'; +import {TileBounds} from './tile_bounds'; +import {Texture} from '../render/texture'; + +import type {Source} from './source'; +import type {OverscaledTileID} from './tile_id'; +import type {Map} from '../ui/map'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Tile} from './tile'; +import type {Callback} from '../types/callback'; +import type {Cancelable} from '../types/cancelable'; +import type { + RasterSourceSpecification, + RasterDEMSourceSpecification +} from '@maplibre/maplibre-gl-style-spec'; + +/** + * A source containing raster tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * map.addSource('raster-source', { + * 'type': 'raster', + * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'], + * 'tileSize': 256, + * }); + * ``` + * + * @example + * ```ts + * map.addSource('wms-test-source', { + * 'type': 'raster', + * // use the tiles option to specify a WMS tile source URL + * '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 [Add a raster tile source](https://maplibre.org/maplibre-gl-js/docs/examples/map-tiles/) + * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/) + * @see [Display a satellite map](https://maplibre.org/maplibre-gl-js/docs/examples/satellite-map/) + */ +export class RasterTileSource extends Evented implements Source { + type: 'raster' | 'raster-dem'; + id: string; + minzoom: number; + maxzoom: number; + url: string; + scheme: string; + tileSize: number; + + bounds: [number, number, number, number]; + tileBounds: TileBounds; + roundZoom: boolean; + dispatcher: Dispatcher; + map: Map; + tiles: Array; + + _loaded: boolean; + _options: RasterSourceSpecification | RasterDEMSourceSpecification; + _tileJSONRequest: Cancelable; + + constructor(id: string, options: RasterSourceSpecification | RasterDEMSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) { + super(); + this.id = id; + this.dispatcher = dispatcher; + this.setEventedParent(eventedParent); + + this.type = 'raster'; + this.minzoom = 0; + this.maxzoom = 22; + this.roundZoom = true; + this.scheme = 'xyz'; + this.tileSize = 512; + this._loaded = false; + + this._options = extend({type: 'raster'}, options); + extend(this, pick(options, ['url', 'scheme', 'tileSize'])); + } + + load() { + this._loaded = false; + this.fire(new Event('dataloading', {dataType: 'source'})); + this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => { + this._tileJSONRequest = null; + this._loaded = true; + if (err) { + this.fire(new ErrorEvent(err)); + } else if (tileJSON) { + extend(this, tileJSON); + if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom); + + // `content` is included here to prevent a race condition where `Style#_updateSources` is called + // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives + // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088 + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'})); + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'})); + } + }); + } + + loaded(): boolean { + return this._loaded; + } + + onAdd(map: Map) { + this.map = map; + this.load(); + } + + onRemove() { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + this._tileJSONRequest = null; + } + } + + setSourceProperty(callback: Function) { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + } + + callback(); + + this.load(); + } + + /** + * Sets the source `tiles` property and re-renders the map. + * + * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) + * @returns `this` + */ + setTiles(tiles: Array): this { + this.setSourceProperty(() => { + this._options.tiles = tiles; + }); + + return this; + } + + serialize() { + return extend({}, this._options); + } + + hasTile(tileID: OverscaledTileID) { + return !this.tileBounds || this.tileBounds.contains(tileID.canonical); + } + + loadTile(tile: Tile, callback: Callback) { + const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme); + tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), (err, img, expiry) => { + delete tile.request; + + if (tile.aborted) { + tile.state = 'unloaded'; + callback(null); + } else if (err) { + tile.state = 'errored'; + callback(err); + } else if (img) { + if (this.map._refreshExpiredTiles && expiry) tile.setExpiryData(expiry); + + const context = this.map.painter.context; + const gl = context.gl; + tile.texture = this.map.painter.getTileTexture(img.width); + if (tile.texture) { + tile.texture.update(img, {useMipmap: true}); + } else { + tile.texture = new Texture(context, img, gl.RGBA, {useMipmap: true}); + tile.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); + + if (context.extTextureFilterAnisotropic) { + gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax); + } + } + + tile.state = 'loaded'; + + callback(null); + } + }, this.map._refreshExpiredTiles); + } + + abortTile(tile: Tile, callback: Callback) { + if (tile.request) { + tile.request.cancel(); + delete tile.request; + } + callback(); + } + + unloadTile(tile: Tile, callback: Callback) { + if (tile.texture) this.map.painter.saveTileTexture(tile.texture); + callback(); + } + + hasTransition() { + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/source/rtl_text_plugin.ts b/web/libraries/maplibre-gl/src/source/rtl_text_plugin.ts new file mode 100644 index 00000000..249919ca --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/rtl_text_plugin.ts @@ -0,0 +1,144 @@ +import {getArrayBuffer} from '../util/ajax'; +import {browser} from '../util/browser'; +import {Event, Evented} from '../util/evented'; +import {isWorker} from '../util/util'; + +const status = { + unavailable: 'unavailable', // Not loaded + deferred: 'deferred', // The plugin URL has been specified, but loading has been deferred + loading: 'loading', // request in-flight + loaded: 'loaded', + error: 'error' +}; + +export type PluginState = { + pluginStatus: typeof status[keyof typeof status]; + pluginURL: string; +}; + +/** + * An error callback + */ +type ErrorCallback = (error?: Error | null) => void; +type PluginStateSyncCallback = (state: PluginState) => void; +let _completionCallback = null; + +//Variables defining the current state of the plugin +let pluginStatus = status.unavailable; +let pluginURL = null; + +export const triggerPluginCompletionEvent = function(error: Error | string) { + // NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin + if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) { + pluginStatus = status.error; + } + + if (_completionCallback) { + _completionCallback(error); + } +}; + +function sendPluginStateToWorker() { + evented.fire(new Event('pluginStateChange', {pluginStatus, pluginURL})); +} + +export const evented = new Evented(); + +export const getRTLTextPluginStatus = function () { + return pluginStatus; +}; + +export const registerForPluginStateChange = function(callback: PluginStateSyncCallback) { + // Do an initial sync of the state + callback({pluginStatus, pluginURL}); + // Listen for all future state changes + evented.on('pluginStateChange', callback); + return callback; +}; + +export const clearRTLTextPlugin = function() { + pluginStatus = status.unavailable; + pluginURL = null; + _completionCallback = null; +}; + +export const setRTLTextPlugin = function(url: string, callback: ErrorCallback, deferred: boolean = false) { + if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) { + throw new Error('setRTLTextPlugin cannot be called multiple times.'); + } + pluginURL = browser.resolveURL(url); + pluginStatus = status.deferred; + _completionCallback = callback; + sendPluginStateToWorker(); + + //Start downloading the plugin immediately if not intending to lazy-load + if (!deferred) { + downloadRTLTextPlugin(); + } +}; + +export const downloadRTLTextPlugin = function() { + if (pluginStatus !== status.deferred || !pluginURL) { + throw new Error('rtl-text-plugin cannot be downloaded unless a pluginURL is specified'); + } + pluginStatus = status.loading; + sendPluginStateToWorker(); + if (pluginURL) { + getArrayBuffer({url: pluginURL}, (error) => { + if (error) { + triggerPluginCompletionEvent(error); + } else { + pluginStatus = status.loaded; + sendPluginStateToWorker(); + } + }); + } +}; + +export const plugin: { + applyArabicShaping: Function; + processBidirectionalText: ((b: string, a: Array) => Array); + processStyledBidirectionalText: ((c: string, b: Array, a: Array) => Array<[string, Array]>); + isLoaded: () => boolean; + isLoading: () => boolean; + setState: (state: PluginState) => void; + isParsed: () => boolean; + getPluginURL: () => string; +} = { + applyArabicShaping: null, + processBidirectionalText: null, + processStyledBidirectionalText: null, + isLoaded() { + return pluginStatus === status.loaded || // Main Thread: loaded if the completion callback returned successfully + plugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled + }, + isLoading() { // Main Thread Only: query the loading status, this function does not return the correct value in the worker context. + return pluginStatus === status.loading; + }, + setState(state: PluginState) { // Worker thread only: this tells the worker threads that the plugin is available on the Main thread + if (!isWorker()) throw new Error('Cannot set the state of the rtl-text-plugin when not in the web-worker context'); + + pluginStatus = state.pluginStatus; + pluginURL = state.pluginURL; + }, + isParsed(): boolean { + if (!isWorker()) throw new Error('rtl-text-plugin is only parsed on the worker-threads'); + + return plugin.applyArabicShaping != null && + plugin.processBidirectionalText != null && + plugin.processStyledBidirectionalText != null; + }, + getPluginURL(): string { + if (!isWorker()) throw new Error('rtl-text-plugin url can only be queried from the worker threads'); + return pluginURL; + } +}; + +export const lazyLoadRTLTextPlugin = function() { + if (!plugin.isLoading() && + !plugin.isLoaded() && + getRTLTextPluginStatus() === 'deferred' + ) { + downloadRTLTextPlugin(); + } +}; diff --git a/web/libraries/maplibre-gl/src/source/source.ts b/web/libraries/maplibre-gl/src/source/source.ts new file mode 100644 index 00000000..34c5ce88 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/source.ts @@ -0,0 +1,139 @@ +import {VectorTileSource} from '../source/vector_tile_source'; +import {RasterTileSource} from '../source/raster_tile_source'; +import {RasterDEMTileSource} from '../source/raster_dem_tile_source'; +import {GeoJSONSource} from '../source/geojson_source'; +import {VideoSource} from '../source/video_source'; +import {ImageSource} from '../source/image_source'; +import {CanvasSource} from '../source/canvas_source'; + +import type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Event, Evented} from '../util/evented'; +import type {Map} from '../ui/map'; +import type {Tile} from './tile'; +import type {OverscaledTileID, CanonicalTileID} from './tile_id'; +import type {Callback} from '../types/callback'; +import type {CanvasSourceSpecification} from '../source/canvas_source'; + +const registeredSources = {} as {[key:string]: SourceClass}; + +/** + * The `Source` interface must be implemented by each source type, including "core" types (`vector`, `raster`, + * `video`, etc.) and all custom, third-party types. + * + * @event `data` - Fired with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata + * has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}` + * to indicate that the source data has changed, so that any current caches should be flushed. + * + * @group Sources + */ +export interface Source { + readonly type: string; + /** + * The id for the source. Must not be used by any existing source. + */ + id: string; + minzoom: number; + maxzoom: number; + tileSize: number; + attribution?: string; + /** + * `true` if zoom levels are rounded to the nearest integer in the source data, `false` if they are floor-ed to the nearest integer. + */ + roundZoom?: boolean; + /** + * `false` if tiles can be drawn outside their boundaries, `true` if they cannot. + */ + isTileClipped?: boolean; + tileID?: CanonicalTileID; + /** + * `true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not. + */ + reparseOverscaled?: boolean; + vectorLayerIds?: Array; + hasTransition(): boolean; + loaded(): boolean; + fire(event: Event): unknown; + readonly onAdd?: (map: Map) => void; + readonly onRemove?: (map: Map) => void; + loadTile(tile: Tile, callback: Callback): void; + readonly hasTile?: (tileID: OverscaledTileID) => boolean; + readonly abortTile?: (tile: Tile, callback: Callback) => void; + readonly unloadTile?: (tile: Tile, callback: Callback) => void; + /** + * @returns A plain (stringifiable) JS object representing the current state of the source. + * Creating a source using the returned object as the `options` should result in a Source that is + * equivalent to this one. + */ + serialize(): any; + readonly prepare?: () => void; +} + +/** + * A supporting type to the source definition + */ +type SourceStatics = { + /* + * An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource} + * implementation for this Source type by calling `self.registerWorkerSource(workerSource: WorkerSource)`. + */ + workerSourceURL?: URL; +}; + +/** + * A general definition of a {@link Source} class for factory usage + */ +export type SourceClass = { + new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source; +} & SourceStatics; + +/** + * Creates a tiled data source instance given an options object. + * + * @param id - The id for the source. Must not be used by any existing source. + * @param specification - Source options, specific to the source type (except for `options.type`, which is always required). + * @param source - A source definition object compliant with + * [`maplibre-gl-style-spec`](https://maplibre.org/maplibre-style-spec/#sources) or, for a third-party source type, + * with that type's requirements. + * @param dispatcher - A {@link Dispatcher} instance, which can be used to send messages to the workers. + * @returns a newly created source + */ +export const create = (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source => { + + const Class = getSourceType(specification.type); + const source = new Class(id, specification, dispatcher, eventedParent); + + if (source.id !== id) { + throw new Error(`Expected Source id to be ${id} instead of ${source.id}`); + } + + return source; +}; + +export const getSourceType = (name: string): SourceClass => { + switch (name) { + case 'geojson': + return GeoJSONSource; + case 'image': + return ImageSource; + case 'raster': + return RasterTileSource; + case 'raster-dem': + return RasterDEMTileSource; + case 'vector': + return VectorTileSource; + case 'video': + return VideoSource; + case 'canvas': + return CanvasSource; + } + return registeredSources[name]; +}; + +export const setSourceType = (name: string, type: SourceClass) => { + registeredSources[name] = type; +}; + +export interface Actor { + send(type: string, data: any, callback: Callback): void; +} diff --git a/web/libraries/maplibre-gl/src/source/source_cache.test.ts b/web/libraries/maplibre-gl/src/source/source_cache.test.ts new file mode 100644 index 00000000..0bf9e8fa --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/source_cache.test.ts @@ -0,0 +1,1989 @@ +import {SourceCache} from './source_cache'; +import {setSourceType} from './source'; +import {Tile} from './tile'; +import {OverscaledTileID} from './tile_id'; +import {Transform} from '../geo/transform'; +import {LngLat} from '../geo/lng_lat'; +import Point from '@mapbox/point-geometry'; +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {extend} from '../util/util'; +import {browser} from '../util/browser'; +import {Dispatcher} from '../util/dispatcher'; +import {Callback} from '../types/callback'; +import {TileBounds} from './tile_bounds'; + +class SourceMock extends Evented { + id: string; + minzoom: number; + maxzoom: number; + hasTile: (tileID: OverscaledTileID) => boolean; + sourceOptions: any; + + constructor(id: string, sourceOptions: any, _dispatcher, eventedParent: Evented) { + super(); + this.id = id; + this.minzoom = 0; + this.maxzoom = 22; + extend(this, sourceOptions); + this.sourceOptions = sourceOptions; + this.setEventedParent(eventedParent); + if (sourceOptions.hasTile) { + this.hasTile = sourceOptions.hasTile; + } + } + loadTile(tile: Tile, callback: Callback) { + if (this.sourceOptions.expires) { + tile.setExpiryData({ + expires: this.sourceOptions.expires + }); + } + setTimeout(callback, 0); + } + loaded() { + return true; + } + onAdd() { + if (this.sourceOptions.noLoad) return; + if (this.sourceOptions.error) { + this.fire(new ErrorEvent(this.sourceOptions.error)); + } else { + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'})); + } + } + abortTile() {} + unloadTile() {} + serialize() {} +} + +// Add a mocked source type for use in these tests +function createSource(id: string, sourceOptions: any, _dispatcher: any, eventedParent: Evented) { + // allow tests to override mocked methods/properties by providing + // them in the source definition object that's given to Source.create() + const source = new SourceMock(id, sourceOptions, _dispatcher, eventedParent); + + return source; +} + +setSourceType('mock-source-type', createSource as any); + +function createSourceCache(options?, used?) { + const sc = new SourceCache('id', extend({ + tileSize: 512, + minzoom: 0, + maxzoom: 14, + type: 'mock-source-type' + }, options), {} as Dispatcher); + sc.used = typeof used === 'boolean' ? used : true; + return sc; +} + +afterEach(() => { + jest.clearAllMocks(); +}); + +describe('SourceCache#addTile', () => { + test('loads tile when uncached', done => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const sourceCache = createSourceCache({ + loadTile(tile) { + expect(tile.tileID).toEqual(tileID); + expect(tile.uses).toBe(0); + done(); + } + }); + sourceCache.onAdd(undefined); + sourceCache._addTile(tileID); + }); + + test('adds tile when uncached', done => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const sourceCache = createSourceCache({}).on('dataloading', (data) => { + expect(data.tile.tileID).toEqual(tileID); + expect(data.tile.uses).toBe(1); + done(); + }); + sourceCache.onAdd(undefined); + sourceCache._addTile(tileID); + }); + + test('updates feature state on added uncached tile', done => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + let updateFeaturesSpy; + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + sourceCache.on('data', () => { + expect(updateFeaturesSpy).toHaveBeenCalledTimes(1); + done(); + }); + updateFeaturesSpy = jest.spyOn(tile, 'setFeatureState'); + tile.state = 'loaded'; + callback(); + } + }); + sourceCache.onAdd(undefined); + sourceCache._addTile(tileID); + }); + + test('uses cached tile', () => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + let load = 0, + add = 0; + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + load++; + callback(); + } + }).on('dataloading', () => { add++; }); + + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + sourceCache._addTile(tileID); + sourceCache._removeTile(tileID.key); + sourceCache._addTile(tileID); + + expect(load).toBe(1); + expect(add).toBe(1); + + }); + + test('updates feature state on cached tile', () => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + callback(); + } + }); + + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + const tile = sourceCache._addTile(tileID); + const updateFeaturesSpy = jest.spyOn(tile, 'setFeatureState'); + + sourceCache._removeTile(tileID.key); + sourceCache._addTile(tileID); + + expect(updateFeaturesSpy).toHaveBeenCalledTimes(1); + + }); + + test('moves timers when adding tile from cache', () => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const time = new Date(); + time.setSeconds(time.getSeconds() + 5); + + const sourceCache = createSourceCache(); + sourceCache._setTileReloadTimer = (id) => { + sourceCache._timers[id] = setTimeout(() => {}, 0); + }; + sourceCache._loadTile = (tile, callback) => { + tile.state = 'loaded'; + tile.getExpiryTimeout = () => 1000 * 60; + sourceCache._setTileReloadTimer(tileID.key, tile); + callback(); + }; + + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + const id = tileID.key; + expect(sourceCache._timers[id]).toBeFalsy(); + expect(sourceCache._cache.has(tileID)).toBeFalsy(); + + sourceCache._addTile(tileID); + + expect(sourceCache._timers[id]).toBeTruthy(); + expect(sourceCache._cache.has(tileID)).toBeFalsy(); + + sourceCache._removeTile(tileID.key); + + expect(sourceCache._timers[id]).toBeFalsy(); + expect(sourceCache._cache.has(tileID)).toBeTruthy(); + + sourceCache._addTile(tileID); + + expect(sourceCache._timers[id]).toBeTruthy(); + expect(sourceCache._cache.has(tileID)).toBeFalsy(); + + }); + + test('does not reuse wrapped tile', () => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + let load = 0, + add = 0; + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + load++; + callback(); + } + }).on('dataloading', () => { add++; }); + + const t1 = sourceCache._addTile(tileID); + const t2 = sourceCache._addTile(new OverscaledTileID(0, 1, 0, 0, 0)); + + expect(load).toBe(2); + expect(add).toBe(2); + expect(t1).not.toBe(t2); + + }); + + test('should load tiles with identical overscaled Z but different canonical Z', () => { + const sourceCache = createSourceCache(); + + const tileIDs = [ + new OverscaledTileID(1, 0, 0, 0, 0), + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(1, 0, 1, 1, 0), + new OverscaledTileID(1, 0, 1, 0, 1), + new OverscaledTileID(1, 0, 1, 1, 1) + ]; + + for (let i = 0; i < tileIDs.length; i++) + sourceCache._addTile(tileIDs[i]); + + for (let i = 0; i < tileIDs.length; i++) { + const id = tileIDs[i]; + const key = id.key; + + expect(sourceCache._tiles[key]).toBeTruthy(); + expect(sourceCache._tiles[key].tileID).toEqual(id); + } + + }); +}); + +describe('SourceCache#removeTile', () => { + test('removes tile', done => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const sourceCache = createSourceCache({}); + sourceCache._addTile(tileID); + sourceCache.on('data', () => { + sourceCache._removeTile(tileID.key); + expect(sourceCache._tiles[tileID.key]).toBeFalsy(); + done(); + }); + }); + + test('caches (does not unload) loaded tile', done => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const sourceCache = createSourceCache({ + loadTile(tile) { + tile.state = 'loaded'; + }, + unloadTile() { + done('test failed: unloadTile has been called'); + } + }); + + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + sourceCache._addTile(tileID); + sourceCache._removeTile(tileID.key); + + done(); + }); + + test('aborts and unloads unfinished tile', () => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + let abort = 0, + unload = 0; + + const sourceCache = createSourceCache({ + abortTile(tile) { + expect(tile.tileID).toEqual(tileID); + abort++; + }, + unloadTile(tile) { + expect(tile.tileID).toEqual(tileID); + unload++; + } + }); + + sourceCache._addTile(tileID); + sourceCache._removeTile(tileID.key); + + expect(abort).toBe(1); + expect(unload).toBe(1); + + }); + + test('_tileLoaded after _removeTile skips tile.added', () => { + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.added = undefined; + sourceCache._removeTile(tileID.key); + callback(); + } + }); + sourceCache.map = {painter: {crossTileSymbolIndex: '', tileExtentVAO: {}}} as any; + + sourceCache._addTile(tileID); + }); + + test('fires dataabort event', async () => { + const sourceCache = createSourceCache({ + loadTile() { + // Do not call back in order to make sure the tile is removed before it is loaded. + } + }); + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + const tile = sourceCache._addTile(tileID); + const abortPromise = sourceCache.once('dataabort'); + sourceCache._removeTile(tileID.key); + const event = await abortPromise; + expect(event.dataType).toBe('source'); + expect(event.tile).toBe(tile); + expect(event.coord).toBe(tileID); + }); + + test('does not fire dataabort event when the tile has already been loaded', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + callback(); + } + }); + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + sourceCache._addTile(tileID); + const onAbort = jest.fn(); + sourceCache.once('dataabort', onAbort); + sourceCache._removeTile(tileID.key); + expect(onAbort).toHaveBeenCalledTimes(0); + }); + + test('does not fire data event when the tile has already been aborted', () => { + const onData = jest.fn(); + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + sourceCache.once('dataabort', () => { + tile.state = 'loaded'; + callback(); + expect(onData).toHaveBeenCalledTimes(0); + }); + } + }); + sourceCache.once('data', onData); + const tileID = new OverscaledTileID(0, 0, 0, 0, 0); + sourceCache._addTile(tileID); + sourceCache._removeTile(tileID.key); + }); + +}); + +describe('SourceCache / Source lifecycle', () => { + test('does not fire load or change before source load event', done => { + const sourceCache = createSourceCache({noLoad: true}) + .on('data', () => done('test failed: data event fired')); + sourceCache.onAdd(undefined); + setTimeout(() => done(), 1); + }); + + test('forward load event', done => { + const sourceCache = createSourceCache({}).on('data', (e) => { + if (e.sourceDataType === 'metadata') done(); + }); + sourceCache.onAdd(undefined); + }); + + test('forward change event', done => { + const sourceCache = createSourceCache().on('data', (e) => { + if (e.sourceDataType === 'metadata') done(); + }); + sourceCache.onAdd(undefined); + sourceCache.getSource().fire(new Event('data')); + }); + + test('forward error event', done => { + const sourceCache = createSourceCache({error: 'Error loading source'}).on('error', (err) => { + expect(err.error).toBe('Error loading source'); + done(); + }); + sourceCache.onAdd(undefined); + }); + + test('suppress 404 errors', done => { + const sourceCache = createSourceCache({status: 404, message: 'Not found'}) + .on('error', () => done('test failed: error event fired')); + sourceCache.onAdd(undefined); + done(); + }); + + test('loaded() true after source error', done => { + const sourceCache = createSourceCache({error: 'Error loading source'}).on('error', () => { + expect(sourceCache.loaded()).toBeTruthy(); + done(); + }); + sourceCache.onAdd(undefined); + }); + + test('loaded() true after tile error', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + const sourceCache = createSourceCache({ + loadTile (tile, callback) { + callback('error'); + } + }).on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + sourceCache.update(transform); + } + }).on('error', () => { + expect(sourceCache.loaded()).toBeTruthy(); + done(); + }); + + sourceCache.onAdd(undefined); + }); + + test('loaded() false after source begins loading following error', done => { + const sourceCache = createSourceCache({error: 'Error loading source'}).on('error', () => { + sourceCache.on('dataloading', () => { + expect(sourceCache.loaded()).toBeFalsy(); + done(); + }); + sourceCache.getSource().fire(new Event('dataloading')); + }); + + sourceCache.onAdd(undefined); + }); + + test('loaded() false when error occurs while source is not loaded', done => { + const sourceCache = createSourceCache({ + error: 'Error loading source', + + loaded() { + return false; + } + }).on('error', () => { + expect(sourceCache.loaded()).toBeFalsy(); + done(); + }); + + sourceCache.onAdd(undefined); + }); + + test('reloads tiles after a data event where source is updated', () => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + + const expected = [new OverscaledTileID(0, 0, 0, 0, 0).key, new OverscaledTileID(0, 0, 0, 0, 0).key]; + expect.assertions(expected.length); + + const sourceCache = createSourceCache({ + loadTile (tile, callback) { + expect(tile.tileID.key).toBe(expected.shift()); + tile.loaded = true; + callback(); + } + }); + + sourceCache.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + sourceCache.update(transform); + sourceCache.getSource().fire(new Event('data', {dataType: 'source', sourceDataType: 'content'})); + } + }); + + sourceCache.onAdd(undefined); + }); + + test('does not reload errored tiles', () => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 1; + + const sourceCache = createSourceCache({ + loadTile (tile, callback) { + // this transform will try to load the four tiles at z1 and a single z0 tile + // we only expect _reloadTile to be called with the 'loaded' z0 tile + tile.state = tile.tileID.canonical.z === 1 ? 'errored' : 'loaded'; + callback(); + } + }); + + const reloadTileSpy = jest.spyOn(sourceCache, '_reloadTile'); + sourceCache.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + sourceCache.update(transform); + sourceCache.getSource().fire(new Event('data', {dataType: 'source', sourceDataType: 'content'})); + } + }); + sourceCache.onAdd(undefined); + // we expect the source cache to have five tiles, but only to have reloaded one + expect(Object.keys(sourceCache._tiles)).toHaveLength(5); + expect(reloadTileSpy).toHaveBeenCalledTimes(1); + + }); + +}); + +describe('SourceCache#update', () => { + test('loads no tiles if used is false', done => { + const transform = new Transform(); + transform.resize(512, 512); + transform.zoom = 0; + + const sourceCache = createSourceCache({}, false); + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([]); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('loads covering tiles', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + + const sourceCache = createSourceCache({}); + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([new OverscaledTileID(0, 0, 0, 0, 0).key]); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('respects Source#hasTile method if it is present', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 1; + + const sourceCache = createSourceCache({ + hasTile: (coord) => (coord.canonical.x !== 0) + }); + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds().sort()).toEqual([ + new OverscaledTileID(1, 0, 1, 1, 0).key, + new OverscaledTileID(1, 0, 1, 1, 1).key + ].sort()); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('removes unused tiles', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + + const sourceCache = createSourceCache({ + loadTile: (tile, callback) => { + tile.state = 'loaded'; + callback(null); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([new OverscaledTileID(0, 0, 0, 0, 0).key]); + + transform.zoom = 1; + sourceCache.update(transform); + + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(1, 0, 1, 1, 1).key, + new OverscaledTileID(1, 0, 1, 0, 1).key, + new OverscaledTileID(1, 0, 1, 1, 0).key, + new OverscaledTileID(1, 0, 1, 0, 0).key + ]); + done(); + } + }); + + sourceCache.onAdd(undefined); + }); + + test('retains parent tiles for pending children', done => { + const transform = new Transform(); + (transform as any)._test = 'retains'; + transform.resize(511, 511); + transform.zoom = 0; + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = (tile.tileID.key === new OverscaledTileID(0, 0, 0, 0, 0).key) ? 'loaded' : 'loading'; + callback(); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([new OverscaledTileID(0, 0, 0, 0, 0).key]); + + transform.zoom = 1; + sourceCache.update(transform); + + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(0, 0, 0, 0, 0).key, + new OverscaledTileID(1, 0, 1, 1, 1).key, + new OverscaledTileID(1, 0, 1, 0, 1).key, + new OverscaledTileID(1, 0, 1, 1, 0).key, + new OverscaledTileID(1, 0, 1, 0, 0).key + ]); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('retains parent tiles for pending children (wrapped)', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + transform.center = new LngLat(360, 0); + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = (tile.tileID.key === new OverscaledTileID(0, 1, 0, 0, 0).key) ? 'loaded' : 'loading'; + callback(); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([new OverscaledTileID(0, 1, 0, 0, 0).key]); + + transform.zoom = 1; + sourceCache.update(transform); + + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(0, 1, 0, 0, 0).key, + new OverscaledTileID(1, 1, 1, 1, 1).key, + new OverscaledTileID(1, 1, 1, 0, 1).key, + new OverscaledTileID(1, 1, 1, 1, 0).key, + new OverscaledTileID(1, 1, 1, 0, 0).key + ]); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('retains covered child tiles while parent tile is fading in', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 2; + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.timeAdded = Infinity; + tile.state = 'loaded'; + tile.registerFadeDuration(100); + callback(); + } + }); + + (sourceCache._source as any).type = 'raster'; + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(2, 0, 2, 2, 2).key, + new OverscaledTileID(2, 0, 2, 1, 2).key, + new OverscaledTileID(2, 0, 2, 2, 1).key, + new OverscaledTileID(2, 0, 2, 1, 1).key + ]); + + transform.zoom = 0; + sourceCache.update(transform); + + expect(sourceCache.getRenderableIds()).toHaveLength(5); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('retains a parent tile for fading even if a tile is partially covered by children', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.timeAdded = Infinity; + tile.state = 'loaded'; + tile.registerFadeDuration(100); + callback(); + } + }); + + (sourceCache._source as any).type = 'raster'; + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + + transform.zoom = 2; + sourceCache.update(transform); + + transform.zoom = 1; + sourceCache.update(transform); + + expect(sourceCache._coveredTiles[(new OverscaledTileID(0, 0, 0, 0, 0).key)]).toBe(true); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('retain children for fading fadeEndTime is 0 (added but registerFadeDuration() is not called yet)', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 1; + + const sourceCache = createSourceCache({ + + // not setting fadeEndTime because class Tile default is 0, and need to be tested + loadTile(tile, callback) { + tile.timeAdded = Date.now(); + tile.state = 'loaded'; + callback(); + } + }); + + (sourceCache._source as any).type = 'raster'; + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + + transform.zoom = 0; + sourceCache.update(transform); + + expect(sourceCache.getRenderableIds()).toHaveLength(5); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('retains children when tile.fadeEndTime is in the future', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 1; + + const fadeTime = 100; + + const start = Date.now(); + let time = start; + jest.spyOn(browser, 'now').mockImplementation(() => time); + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.timeAdded = browser.now(); + tile.state = 'loaded'; + tile.fadeEndTime = browser.now() + fadeTime; + callback(); + } + }); + + (sourceCache._source as any).type = 'raster'; + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + // load children + sourceCache.update(transform); + + transform.zoom = 0; + sourceCache.update(transform); + + expect(sourceCache.getRenderableIds()).toHaveLength(5); + + time = start + 98; + sourceCache.update(transform); + expect(sourceCache.getRenderableIds()).toHaveLength(5); + + time = start + fadeTime + 1; + sourceCache.update(transform); + expect(sourceCache.getRenderableIds()).toHaveLength(1); + done(); + } + }); + + sourceCache.onAdd(undefined); + }); + + test('retains overscaled loaded children', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 16; + + // use slightly offset center so that sort order is better defined + transform.center = new LngLat(-0.001, 0.001); + + const sourceCache = createSourceCache({ + reparseOverscaled: true, + loadTile(tile, callback) { + tile.state = tile.tileID.overscaledZ === 16 ? 'loaded' : 'loading'; + callback(); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(sourceCache.getRenderableIds()).toEqual([ + new OverscaledTileID(16, 0, 14, 8192, 8192).key, + new OverscaledTileID(16, 0, 14, 8191, 8192).key, + new OverscaledTileID(16, 0, 14, 8192, 8191).key, + new OverscaledTileID(16, 0, 14, 8191, 8191).key + ]); + + transform.zoom = 15; + sourceCache.update(transform); + + expect(sourceCache.getRenderableIds()).toEqual([ + new OverscaledTileID(16, 0, 14, 8192, 8192).key, + new OverscaledTileID(16, 0, 14, 8191, 8192).key, + new OverscaledTileID(16, 0, 14, 8192, 8191).key, + new OverscaledTileID(16, 0, 14, 8191, 8191).key + ]); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('reassigns tiles for large jumps in longitude', done => { + + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 0; + + const sourceCache = createSourceCache({}); + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + transform.center = new LngLat(360, 0); + const tileID = new OverscaledTileID(0, 1, 0, 0, 0); + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([tileID.key]); + const tile = sourceCache.getTile(tileID); + + transform.center = new LngLat(0, 0); + const wrappedTileID = new OverscaledTileID(0, 0, 0, 0, 0); + sourceCache.update(transform); + expect(sourceCache.getIds()).toEqual([wrappedTileID.key]); + expect(sourceCache.getTile(wrappedTileID)).toBe(tile); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + +}); + +describe('SourceCache#_updateRetainedTiles', () => { + + test('loads ideal tiles if they exist', () => { + const stateCache = {}; + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = stateCache[tile.tileID.key] || 'errored'; + callback(); + } + }); + + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + const idealTile = new OverscaledTileID(1, 0, 1, 1, 1); + stateCache[idealTile.key] = 'loaded'; + sourceCache._updateRetainedTiles([idealTile], 1); + expect(getTileSpy).not.toHaveBeenCalled(); + expect(sourceCache.getIds()).toEqual([idealTile.key]); + }); + + test('retains all loaded children ', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'errored'; + callback(); + } + }); + + const idealTile = new OverscaledTileID(3, 0, 3, 1, 2); + sourceCache._tiles[idealTile.key] = new Tile(idealTile, undefined); + sourceCache._tiles[idealTile.key].state = 'errored'; + + const loadedChildren = [ + new OverscaledTileID(4, 0, 4, 2, 4), + new OverscaledTileID(4, 0, 4, 3, 4), + new OverscaledTileID(4, 0, 4, 2, 5), + new OverscaledTileID(5, 0, 5, 6, 10), + new OverscaledTileID(5, 0, 5, 7, 10), + new OverscaledTileID(5, 0, 5, 6, 11), + new OverscaledTileID(5, 0, 5, 7, 11) + ]; + + for (const t of loadedChildren) { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + } + + const retained = sourceCache._updateRetainedTiles([idealTile], 3); + expect(Object.keys(retained).sort()).toEqual([ + // parents are requested because ideal ideal tile is not completely covered by + // loaded child tiles + new OverscaledTileID(0, 0, 0, 0, 0), + new OverscaledTileID(2, 0, 2, 0, 1), + new OverscaledTileID(1, 0, 1, 0, 0), + idealTile + ].concat(loadedChildren).map(t => t.key).sort()); + + }); + + test('adds parent tile if ideal tile errors and no child tiles are loaded', () => { + const stateCache = {}; + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = stateCache[tile.tileID.key] || 'errored'; + callback(); + } + }); + + jest.spyOn(sourceCache, '_addTile'); + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + + const idealTiles = [new OverscaledTileID(1, 0, 1, 1, 1), new OverscaledTileID(1, 0, 1, 0, 1)]; + stateCache[idealTiles[0].key] = 'loaded'; + const retained = sourceCache._updateRetainedTiles(idealTiles, 1); + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // when child tiles aren't found, check and request parent tile + new OverscaledTileID(0, 0, 0, 0, 0) + ]); + + // retained tiles include all ideal tiles and any parents that were loaded to cover + // non-existant tiles + expect(retained).toEqual({ + // 1/0/1 + '211': new OverscaledTileID(1, 0, 1, 0, 1), + // 1/1/1 + '311': new OverscaledTileID(1, 0, 1, 1, 1), + // parent + '000': new OverscaledTileID(0, 0, 0, 0, 0) + }); + }); + + test('don\'t use wrong parent tile', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'errored'; + callback(); + } + }); + + const idealTile = new OverscaledTileID(2, 0, 2, 0, 0); + sourceCache._tiles[idealTile.key] = new Tile(idealTile, undefined); + sourceCache._tiles[idealTile.key].state = 'errored'; + + sourceCache._tiles[new OverscaledTileID(1, 0, 1, 1, 0).key] = new Tile(new OverscaledTileID(1, 0, 1, 1, 0), undefined); + sourceCache._tiles[new OverscaledTileID(1, 0, 1, 1, 0).key].state = 'loaded'; + + const addTileSpy = jest.spyOn(sourceCache, '_addTile'); + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + + sourceCache._updateRetainedTiles([idealTile], 2); + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // parents + new OverscaledTileID(1, 0, 1, 0, 0), // not found + new OverscaledTileID(0, 0, 0, 0, 0) // not found + ]); + + expect(addTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // ideal tile + new OverscaledTileID(2, 0, 2, 0, 0), + // parents + new OverscaledTileID(1, 0, 1, 0, 0), // not found + new OverscaledTileID(0, 0, 0, 0, 0) // not found + ]); + }); + + test('use parent tile when ideal tile is not loaded', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + } + }); + const idealTile = new OverscaledTileID(1, 0, 1, 0, 1); + const parentTile = new OverscaledTileID(0, 0, 0, 0, 0); + sourceCache._tiles[idealTile.key] = new Tile(idealTile, undefined); + sourceCache._tiles[idealTile.key].state = 'loading'; + sourceCache._tiles[parentTile.key] = new Tile(parentTile, undefined); + sourceCache._tiles[parentTile.key].state = 'loaded'; + + const addTileSpy = jest.spyOn(sourceCache, '_addTile'); + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + + const retained = sourceCache._updateRetainedTiles([idealTile], 1); + + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // parents + new OverscaledTileID(0, 0, 0, 0, 0), // found + ]); + + expect(retained).toEqual({ + // parent of ideal tile 0/0/0 + '000': new OverscaledTileID(0, 0, 0, 0, 0), + // ideal tile id 1/0/1 + '211': new OverscaledTileID(1, 0, 1, 0, 1) + }); + + addTileSpy.mockClear(); + getTileSpy.mockClear(); + + // now make sure we don't retain the parent tile when the ideal tile is loaded + sourceCache._tiles[idealTile.key].state = 'loaded'; + const retainedLoaded = sourceCache._updateRetainedTiles([idealTile], 1); + + expect(getTileSpy).not.toHaveBeenCalled(); + expect(retainedLoaded).toEqual({ + // only ideal tile retained + '211': new OverscaledTileID(1, 0, 1, 0, 1) + }); + }); + + test('don\'t load parent if all immediate children are loaded', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + } + }); + + const idealTile = new OverscaledTileID(2, 0, 2, 1, 1); + const loadedTiles = [new OverscaledTileID(3, 0, 3, 2, 2), new OverscaledTileID(3, 0, 3, 3, 2), new OverscaledTileID(3, 0, 3, 2, 3), new OverscaledTileID(3, 0, 3, 3, 3)]; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + const retained = sourceCache._updateRetainedTiles([idealTile], 2); + // parent tile isn't requested because all covering children are loaded + expect(getTileSpy).not.toHaveBeenCalled(); + expect(Object.keys(retained)).toEqual([idealTile.key].concat(loadedTiles.map(t => t.key))); + }); + + test('prefer loaded child tiles to parent tiles', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + } + }); + const idealTile = new OverscaledTileID(1, 0, 1, 0, 0); + const loadedTiles = [new OverscaledTileID(0, 0, 0, 0, 0), new OverscaledTileID(2, 0, 2, 0, 0)]; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + let retained = sourceCache._updateRetainedTiles([idealTile], 1); + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // parent + new OverscaledTileID(0, 0, 0, 0, 0) + ]); + + expect(retained).toEqual({ + // parent of ideal tile (0, 0, 0) (only partially covered by loaded child + // tiles, so we still need to load the parent) + '000': new OverscaledTileID(0, 0, 0, 0, 0), + // ideal tile id (1, 0, 0) + '011': new OverscaledTileID(1, 0, 1, 0, 0), + // loaded child tile (2, 0, 0) + '022': new OverscaledTileID(2, 0, 2, 0, 0) + }); + + getTileSpy.mockClear(); + // remove child tile and check that it only uses parent tile + delete sourceCache._tiles['022']; + retained = sourceCache._updateRetainedTiles([idealTile], 1); + + expect(retained).toEqual({ + // parent of ideal tile (0, 0, 0) (only partially covered by loaded child + // tiles, so we still need to load the parent) + '000': new OverscaledTileID(0, 0, 0, 0, 0), + // ideal tile id (1, 0, 0) + '011': new OverscaledTileID(1, 0, 1, 0, 0) + }); + + }); + + test('don\'t use tiles below minzoom', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + }, + minzoom: 2 + }); + const idealTile = new OverscaledTileID(2, 0, 2, 0, 0); + const loadedTiles = [new OverscaledTileID(1, 0, 1, 0, 0)]; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + const retained = sourceCache._updateRetainedTiles([idealTile], 2); + + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([]); + + expect(retained).toEqual({ + // ideal tile id (2, 0, 0) + '022': new OverscaledTileID(2, 0, 2, 0, 0) + }); + + }); + + test('use overzoomed tile above maxzoom', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + }, + maxzoom: 2 + }); + const idealTile = new OverscaledTileID(2, 0, 2, 0, 0); + + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + const retained = sourceCache._updateRetainedTiles([idealTile], 2); + + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // overzoomed child + new OverscaledTileID(3, 0, 2, 0, 0), + // parents + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(0, 0, 0, 0, 0) + ]); + + expect(retained).toEqual({ + // ideal tile id (2, 0, 0) + '022': new OverscaledTileID(2, 0, 2, 0, 0) + }); + + }); + + test('dont\'t ascend multiple times if a tile is not found', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + } + }); + const idealTiles = [new OverscaledTileID(8, 0, 8, 0, 0), new OverscaledTileID(8, 0, 8, 1, 0)]; + + const getTileSpy = jest.spyOn(sourceCache, 'getTile'); + sourceCache._updateRetainedTiles(idealTiles, 8); + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // parent tile ascent + new OverscaledTileID(7, 0, 7, 0, 0), + new OverscaledTileID(6, 0, 6, 0, 0), + new OverscaledTileID(5, 0, 5, 0, 0), + new OverscaledTileID(4, 0, 4, 0, 0), + new OverscaledTileID(3, 0, 3, 0, 0), + new OverscaledTileID(2, 0, 2, 0, 0), + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(0, 0, 0, 0, 0), + ]); + + getTileSpy.mockClear(); + + const loadedTiles = [new OverscaledTileID(4, 0, 4, 0, 0)]; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + sourceCache._updateRetainedTiles(idealTiles, 8); + expect(getTileSpy.mock.calls.map((c) => { return c[0]; })).toEqual([ + // parent tile ascent + new OverscaledTileID(7, 0, 7, 0, 0), + new OverscaledTileID(6, 0, 6, 0, 0), + new OverscaledTileID(5, 0, 5, 0, 0), + new OverscaledTileID(4, 0, 4, 0, 0), // tile is loaded, stops ascent + ]); + + }); + + test('Only retain loaded parent tile when zooming in', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + } + }); + + let idealTiles = [new OverscaledTileID(9, 0, 9, 0, 0), new OverscaledTileID(9, 0, 9, 1, 0)]; + let retained = sourceCache._updateRetainedTiles(idealTiles, 9); + // Parent loading tiles from z=8 not retained + expect(Object.keys(retained).sort()).toEqual( + idealTiles.map((tile) => tile.key).sort() + ); + + idealTiles = [new OverscaledTileID(10, 0, 10, 0, 0), new OverscaledTileID(10, 0, 10, 1, 0)]; + retained = sourceCache._updateRetainedTiles(idealTiles, 10); + // Parent loading tiles from z=9 not retained + expect(Object.keys(retained).sort()).toEqual( + idealTiles.map((tile) => tile.key).sort() + ); + + const loadedTiles = idealTiles; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + idealTiles = [new OverscaledTileID(11, 0, 11, 0, 0), new OverscaledTileID(11, 0, 11, 1, 0)]; + retained = sourceCache._updateRetainedTiles(idealTiles, 11); + // Parent loaded tile in the view port from z=10 was retained + expect(Object.keys(retained).sort()).toEqual([ + new OverscaledTileID(10, 0, 10, 0, 0).key, // Parent loaded tile + new OverscaledTileID(11, 0, 11, 0, 0).key, + new OverscaledTileID(11, 0, 11, 1, 0).key + ].sort()); + + }); + + test('Only retain loaded child tile when zooming out', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + } + }); + + let idealTiles = [new OverscaledTileID(7, 0, 7, 0, 0), new OverscaledTileID(7, 0, 7, 1, 0)]; + let retained = sourceCache._updateRetainedTiles(idealTiles, 7); + // Client tiles from z=6 not retained + expect(Object.keys(retained).sort()).toEqual( + idealTiles.map((tile) => tile.key).sort() + ); + + idealTiles = [new OverscaledTileID(6, 0, 6, 0, 0), new OverscaledTileID(6, 0, 6, 1, 0)]; + retained = sourceCache._updateRetainedTiles(idealTiles, 6); + // Client tiles from z=6 not retained + expect(Object.keys(retained).sort()).toEqual( + idealTiles.map((tile) => tile.key).sort() + ); + + const loadedTiles = idealTiles; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + idealTiles = [new OverscaledTileID(5, 0, 5, 0, 0), new OverscaledTileID(5, 0, 5, 1, 0)]; + retained = sourceCache._updateRetainedTiles(idealTiles, 5); + // Child loaded tile in the view port from z=6 was retained + expect(Object.keys(retained).sort()).toEqual([ + new OverscaledTileID(6, 0, 6, 0, 0).key, + new OverscaledTileID(6, 0, 6, 1, 0).key, + new OverscaledTileID(5, 0, 5, 0, 0).key, + new OverscaledTileID(5, 0, 5, 1, 0).key + ].sort()); + }); + + test('adds correct loaded parent tiles for overzoomed tiles', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loading'; + callback(); + }, + maxzoom: 7 + }); + const loadedTiles = [new OverscaledTileID(7, 0, 7, 0, 0), new OverscaledTileID(7, 0, 7, 1, 0)]; + loadedTiles.forEach(t => { + sourceCache._tiles[t.key] = new Tile(t, undefined); + sourceCache._tiles[t.key].state = 'loaded'; + }); + + const idealTiles = [new OverscaledTileID(8, 0, 7, 0, 0), new OverscaledTileID(8, 0, 7, 1, 0)]; + const retained = sourceCache._updateRetainedTiles(idealTiles, 8); + + expect(Object.keys(retained)).toEqual([ + new OverscaledTileID(7, 0, 7, 1, 0).key, + new OverscaledTileID(8, 0, 7, 1, 0).key, + new OverscaledTileID(8, 0, 7, 0, 0).key, + new OverscaledTileID(7, 0, 7, 0, 0).key + ]); + + }); + +}); + +describe('SourceCache#clearTiles', () => { + test('unloads tiles', () => { + const coord = new OverscaledTileID(0, 0, 0, 0, 0); + let abort = 0, + unload = 0; + + const sourceCache = createSourceCache({ + abortTile(tile) { + expect(tile.tileID).toEqual(coord); + abort++; + }, + unloadTile(tile) { + expect(tile.tileID).toEqual(coord); + unload++; + } + }); + sourceCache.onAdd(undefined); + + sourceCache._addTile(coord); + sourceCache.clearTiles(); + + expect(abort).toBe(1); + expect(unload).toBe(1); + + }); +}); + +describe('SourceCache#tilesIn', () => { + test('graceful response before source loaded', () => { + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + tr._calcMatrices(); + const sourceCache = createSourceCache({noLoad: true}); + sourceCache.transform = tr; + sourceCache.onAdd(undefined); + expect(sourceCache.tilesIn([ + new Point(0, 0), + new Point(512, 256) + ], 10, true)).toEqual([]); + + }); + + function round(queryGeometry) { + return queryGeometry.map((p) => { + return p.round(); + }); + } + + test('regular tiles', done => { + const transform = new Transform(); + transform.resize(512, 512); + transform.zoom = 1; + transform.center = new LngLat(0, 1); + + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + tile.additionalRadius = 0; + callback(); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(1, 0, 1, 1, 1).key, + new OverscaledTileID(1, 0, 1, 0, 1).key, + new OverscaledTileID(1, 0, 1, 1, 0).key, + new OverscaledTileID(1, 0, 1, 0, 0).key + ]); + + transform._calcMatrices(); + const tiles = sourceCache.tilesIn([ + new Point(0, 0), + new Point(512, 256) + ], 1, true); + + tiles.sort((a, b) => { return a.tile.tileID.canonical.x - b.tile.tileID.canonical.x; }); + tiles.forEach((result) => { delete result.tile.uid; }); + + expect(tiles[0].tile.tileID.key).toBe('011'); + expect(tiles[0].tile.tileSize).toBe(512); + expect(tiles[0].scale).toBe(1); + expect(round(tiles[0].queryGeometry)).toEqual([{x: 4096, y: 4050}, {x: 12288, y: 8146}]); + + expect(tiles[1].tile.tileID.key).toBe('111'); + expect(tiles[1].tile.tileSize).toBe(512); + expect(tiles[1].scale).toBe(1); + expect(round(tiles[1].queryGeometry)).toEqual([{x: -4096, y: 4050}, {x: 4096, y: 8146}]); + + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('reparsed overscaled tiles', () => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + tile.additionalRadius = 0; + callback(); + }, + reparseOverscaled: true, + minzoom: 1, + maxzoom: 1, + tileSize: 512 + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const transform = new Transform(); + transform.resize(1024, 1024); + transform.zoom = 2.0; + transform.center = new LngLat(0, 1); + sourceCache.update(transform); + + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(2, 0, 1, 1, 1).key, + new OverscaledTileID(2, 0, 1, 0, 1).key, + new OverscaledTileID(2, 0, 1, 1, 0).key, + new OverscaledTileID(2, 0, 1, 0, 0).key + ]); + + const tiles = sourceCache.tilesIn([ + new Point(0, 0), + new Point(1024, 512) + ], 1, true); + + tiles.sort((a, b) => { return a.tile.tileID.canonical.x - b.tile.tileID.canonical.x; }); + tiles.forEach((result) => { delete result.tile.uid; }); + + expect(tiles[0].tile.tileID.key).toBe('012'); + expect(tiles[0].tile.tileSize).toBe(1024); + expect(tiles[0].scale).toBe(1); + expect(round(tiles[0].queryGeometry)).toEqual([{x: 4096, y: 4050}, {x: 12288, y: 8146}]); + + expect(tiles[1].tile.tileID.key).toBe('112'); + expect(tiles[1].tile.tileSize).toBe(1024); + expect(tiles[1].scale).toBe(1); + expect(round(tiles[1].queryGeometry)).toEqual([{x: -4096, y: 4050}, {x: 4096, y: 8146}]); + + } + }); + sourceCache.onAdd(undefined); + }); + + test('overscaled tiles', done => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { tile.state = 'loaded'; callback(); }, + reparseOverscaled: false, + minzoom: 1, + maxzoom: 1, + tileSize: 512 + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const transform = new Transform(); + transform.resize(512, 512); + transform.zoom = 2.0; + sourceCache.update(transform); + + done(); + } + }); + sourceCache.onAdd(undefined); + }); +}); + +describe('source cache loaded', () => { + test('SourceCache#loaded (no errors)', done => { + const sourceCache = createSourceCache({ + loadTile(tile, callback) { + tile.state = 'loaded'; + callback(); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tr = new Transform(); + tr.resize(512, 512); + sourceCache.update(tr); + + const coord = new OverscaledTileID(0, 0, 0, 0, 0); + sourceCache._addTile(coord); + + expect(sourceCache.loaded()).toBeTruthy(); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('SourceCache#loaded (with errors)', done => { + const sourceCache = createSourceCache({ + loadTile(tile) { + tile.state = 'errored'; + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tr = new Transform(); + tr.resize(512, 512); + sourceCache.update(tr); + + const coord = new OverscaledTileID(0, 0, 0, 0, 0); + sourceCache._addTile(coord); + + expect(sourceCache.loaded()).toBeTruthy(); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('SourceCache#loaded (unused)', done => { + const sourceCache = createSourceCache({ + loadTile(tile) { + tile.state = 'errored'; + } + }, false); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(sourceCache.loaded()).toBeTruthy(); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('SourceCache#loaded (unusedForTerrain)', done => { + const sourceCache = createSourceCache({ + loadTile(tile) { + tile.state = 'errored'; + } + }, false); + sourceCache.usedForTerrain = false; + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(sourceCache.loaded()).toBeTruthy(); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('SourceCache#loaded (not loaded when no update)', done => { + const sourceCache = createSourceCache({ + loadTile(tile) { + tile.state = 'errored'; + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(sourceCache.loaded()).toBeFalsy(); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('SourceCache#loaded (on last tile load)', done => { + const sourceCache = createSourceCache({ + hasTile(tileID: OverscaledTileID) { + return !this.tileBounds || this.tileBounds.contains(tileID.canonical); + }, + loadTile(tile, callback) { + tile.state = 'loading'; + setTimeout(() => { + tile.state = 'loaded'; + callback(); + }); + } + }); + + const tr = new Transform(); + tr.zoom = 10; + tr.resize(512, 512); + const expectedTilesLoaded = 4; + let loaded = 0; + + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(sourceCache.loaded()).toBeFalsy(); + } else if (e.tile !== undefined) { + loaded += 1; + if (sourceCache.loaded()) { + expect(loaded).toBe(expectedTilesLoaded); + done(); + } + } + }); + + sourceCache.onAdd(undefined); + sourceCache.update(tr); + }); + + test('SourceCache#loaded (tiles outside bounds, idle)', done => { + const japan = new TileBounds([122.74, 19.33, 149.0, 45.67]); + const sourceCache = createSourceCache({ + onAdd() { + if (this.sourceOptions.noLoad) return; + if (this.sourceOptions.error) { + this.fire(new ErrorEvent(this.sourceOptions.error)); + } else { + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'})); + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'})); + } + }, + hasTile(tileID: OverscaledTileID) { + return japan.contains(tileID.canonical); + }, + loadTile(tile, callback) { + tile.state = 'loading'; + setTimeout(() => { + tile.state = 'loaded'; + callback(); + }); + } + }); + + sourceCache.on('data', (e) => { + if (e.sourceDataType !== 'idle') { + expect(sourceCache.loaded()).toBeFalsy(); + // 'idle' emission when source bounds are outside of viewport bounds + } else { + expect(sourceCache.loaded()).toBeTruthy(); + done(); + } + }); + + sourceCache.onAdd(undefined); + const tr = new Transform(); + tr.zoom = 10; + tr.resize(512, 512); + sourceCache.update(tr); + }); +}); + +describe('souce cache get ids', () => { + test('SourceCache#getIds (ascending order by zoom level)', done => { + const ids = [ + new OverscaledTileID(0, 0, 0, 0, 0), + new OverscaledTileID(3, 0, 3, 0, 0), + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(2, 0, 2, 0, 0) + ]; + + const sourceCache = createSourceCache({}); + sourceCache.transform = new Transform(); + for (let i = 0; i < ids.length; i++) { + sourceCache._tiles[ids[i].key] = {tileID: ids[i]} as any as Tile; + } + expect(sourceCache.getIds()).toEqual([ + new OverscaledTileID(0, 0, 0, 0, 0).key, + new OverscaledTileID(1, 0, 1, 0, 0).key, + new OverscaledTileID(2, 0, 2, 0, 0).key, + new OverscaledTileID(3, 0, 3, 0, 0).key + ]); + done(); + }); +}); + +describe('SourceCache#findLoadedParent', () => { + + test('adds from previously used tiles (sourceCache._tiles)', () => { + const sourceCache = createSourceCache({}); + sourceCache.onAdd(undefined); + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + const tile = { + tileID: new OverscaledTileID(1, 0, 1, 0, 0), + hasData() { return true; } + } as any as Tile; + + sourceCache._tiles[tile.tileID.key] = tile; + + expect(sourceCache.findLoadedParent(new OverscaledTileID(2, 0, 2, 3, 3), 0)).toBeUndefined(); + expect(sourceCache.findLoadedParent(new OverscaledTileID(2, 0, 2, 0, 0), 0)).toEqual(tile); + }); + + test('retains parents', () => { + const sourceCache = createSourceCache({}); + sourceCache.onAdd(undefined); + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + const tile = new Tile(new OverscaledTileID(1, 0, 1, 0, 0), 512); + sourceCache._cache.add(tile.tileID, tile); + + expect(sourceCache.findLoadedParent(new OverscaledTileID(2, 0, 2, 3, 3), 0)).toBeUndefined(); + expect(sourceCache.findLoadedParent(new OverscaledTileID(2, 0, 2, 0, 0), 0)).toBe(tile); + expect(sourceCache._cache.order).toHaveLength(1); + + }); + + test('Search cache for loaded parent tiles', () => { + const sourceCache = createSourceCache({}); + sourceCache.onAdd(undefined); + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + const mockTile = id => { + const tile = { + tileID: id, + hasData() { return true; } + } as any as Tile; + sourceCache._tiles[id.key] = tile; + }; + + const tiles = [ + new OverscaledTileID(0, 0, 0, 0, 0), + new OverscaledTileID(1, 0, 1, 1, 0), + new OverscaledTileID(2, 0, 2, 0, 0), + new OverscaledTileID(2, 0, 2, 1, 0), + new OverscaledTileID(2, 0, 2, 2, 0), + new OverscaledTileID(2, 0, 2, 1, 2) + ]; + + tiles.forEach(t => mockTile(t)); + sourceCache._updateLoadedParentTileCache(); + + // Loaded tiles excluding the root should be in the cache + expect(sourceCache.findLoadedParent(tiles[0], 0)).toBeUndefined(); + expect(sourceCache.findLoadedParent(tiles[1], 0).tileID).toBe(tiles[0]); + expect(sourceCache.findLoadedParent(tiles[2], 0).tileID).toBe(tiles[0]); + expect(sourceCache.findLoadedParent(tiles[3], 0).tileID).toBe(tiles[0]); + expect(sourceCache.findLoadedParent(tiles[4], 0).tileID).toBe(tiles[1]); + expect(sourceCache.findLoadedParent(tiles[5], 0).tileID).toBe(tiles[0]); + + expect(tiles[0].key in sourceCache._loadedParentTiles).toBe(false); + expect(tiles[1].key in sourceCache._loadedParentTiles).toBe(true); + expect(tiles[2].key in sourceCache._loadedParentTiles).toBe(true); + expect(tiles[3].key in sourceCache._loadedParentTiles).toBe(true); + expect(tiles[4].key in sourceCache._loadedParentTiles).toBe(true); + expect(tiles[5].key in sourceCache._loadedParentTiles).toBe(true); + + // Arbitrary tiles should not in the cache + const notLoadedTiles = [ + new OverscaledTileID(2, 1, 2, 0, 0), + new OverscaledTileID(2, 0, 2, 3, 0), + new OverscaledTileID(2, 0, 2, 3, 3), + new OverscaledTileID(3, 0, 3, 2, 1) + ]; + + expect(sourceCache.findLoadedParent(notLoadedTiles[0], 0)).toBeUndefined(); + expect(sourceCache.findLoadedParent(notLoadedTiles[1], 0).tileID).toBe(tiles[1]); + expect(sourceCache.findLoadedParent(notLoadedTiles[2], 0).tileID).toBe(tiles[0]); + expect(sourceCache.findLoadedParent(notLoadedTiles[3], 0).tileID).toBe(tiles[3]); + + expect(notLoadedTiles[0].key in sourceCache._loadedParentTiles).toBe(false); + expect(notLoadedTiles[1].key in sourceCache._loadedParentTiles).toBe(false); + expect(notLoadedTiles[2].key in sourceCache._loadedParentTiles).toBe(false); + expect(notLoadedTiles[3].key in sourceCache._loadedParentTiles).toBe(false); + + }); + +}); + +describe('SourceCache#reload', () => { + test('before loaded', () => { + const sourceCache = createSourceCache({noLoad: true}); + sourceCache.onAdd(undefined); + + expect(() => { + sourceCache.reload(); + }).not.toThrow(); + + }); + +}); + +describe('SourceCache reloads expiring tiles', () => { + test('calls reloadTile when tile expires', done => { + const coord = new OverscaledTileID(1, 0, 1, 0, 1); + + const expiryDate = new Date(); + expiryDate.setMilliseconds(expiryDate.getMilliseconds() + 50); + const sourceCache = createSourceCache({expires: expiryDate}); + + sourceCache._reloadTile = (id, state) => { + expect(state).toBe('expired'); + done(); + }; + + sourceCache._addTile(coord); + }); + +}); + +describe('SourceCache sets max cache size correctly', () => { + test('sets cache size based on 512 tiles', () => { + const sourceCache = createSourceCache({ + tileSize: 256 + }); + + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + // Expect max size to be ((512 / tileSize + 1) ^ 2) * 5 => 3 * 3 * 5 + expect(sourceCache._cache.max).toBe(45); + }); + + test('sets cache size based on 256 tiles', () => { + const sourceCache = createSourceCache({ + tileSize: 512 + }); + + const tr = new Transform(); + tr.width = 512; + tr.height = 512; + sourceCache.updateCacheSize(tr); + + // Expect max size to be ((512 / tileSize + 1) ^ 2) * 5 => 2 * 2 * 5 + expect(sourceCache._cache.max).toBe(20); + }); + +}); + +describe('SourceCache#onRemove', () => { + test('clears tiles', () => { + const sourceCache = createSourceCache(); + jest.spyOn(sourceCache, 'clearTiles'); + + sourceCache.onRemove(undefined); + + expect(sourceCache.clearTiles).toHaveBeenCalled(); + }); + + test('calls onRemove on source', () => { + const sourceOnRemove = jest.fn(); + const sourceCache = createSourceCache({ + onRemove: sourceOnRemove + }); + + sourceCache.onRemove(undefined); + + expect(sourceOnRemove).toHaveBeenCalled(); + }); +}); + +describe('SourceCache#usedForTerrain', () => { + test('loads covering tiles with usedForTerrain with source zoom 0-14', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 10; + + const sourceCache = createSourceCache({}); + sourceCache.usedForTerrain = true; + sourceCache.tileSize = 1024; + expect(sourceCache.usedForTerrain).toBeTruthy(); + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(Object.values(sourceCache._tiles).map(t => t.tileID.key)).toEqual( + ['2tc099', '2tbz99', '2sxs99', '2sxr99', 'pds88', 'eo55', 'pdr88', 'en55', 'p6o88', 'ds55', 'p6n88', 'dr55'] + ); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('loads covering tiles with usedForTerrain with source zoom 8-14', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 10; + + const sourceCache = createSourceCache({minzoom: 8, maxzoom: 14}); + sourceCache.usedForTerrain = true; + sourceCache.tileSize = 1024; + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(Object.values(sourceCache._tiles).map(t => t.tileID.key)).toEqual( + ['2tc099', '2tbz99', '2sxs99', '2sxr99', 'pds88', 'pdr88', 'p6o88', 'p6n88'] + ); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('loads covering tiles with usedForTerrain with source zoom 0-4', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 10; + + const sourceCache = createSourceCache({minzoom: 0, maxzoom: 4}); + sourceCache.usedForTerrain = true; + sourceCache.tileSize = 1024; + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(Object.values(sourceCache._tiles).map(t => t.tileID.key)).toEqual( + ['1033', '3s44', '3r44', '3c44', '3b44', 'z33', 's33', 'r33'] + ); + done(); + } + }); + sourceCache.onAdd(undefined); + }); + + test('loads covering tiles with usedForTerrain with source zoom 4-4', done => { + const transform = new Transform(); + transform.resize(511, 511); + transform.zoom = 10; + + const sourceCache = createSourceCache({minzoom: 4, maxzoom: 4}); + sourceCache.usedForTerrain = true; + sourceCache.tileSize = 1024; + sourceCache.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + sourceCache.update(transform); + expect(Object.values(sourceCache._tiles).map(t => t.tileID.key)).toEqual( + ['3s44', '3r44', '3c44', '3b44'] + ); + done(); + } + }); + sourceCache.onAdd(undefined); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/source_cache.ts b/web/libraries/maplibre-gl/src/source/source_cache.ts new file mode 100644 index 00000000..8a6d997f --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/source_cache.ts @@ -0,0 +1,1041 @@ +import {create as createSource} from './source'; + +import {Tile} from './tile'; +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {TileCache} from './tile_cache'; +import {MercatorCoordinate} from '../geo/mercator_coordinate'; +import {keysDifference} from '../util/util'; +import {EXTENT} from '../data/extent'; +import {Context} from '../gl/context'; +import Point from '@mapbox/point-geometry'; +import {browser} from '../util/browser'; +import {OverscaledTileID} from './tile_id'; +import {SourceFeatureState} from './source_state'; + +import type {Source} from './source'; +import type {Map} from '../ui/map'; +import type {Style} from '../style/style'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Transform} from '../geo/transform'; +import type {TileState} from './tile'; +import type {Callback} from '../types/callback'; +import type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {MapSourceDataEvent} from '../ui/events'; +import {Terrain} from '../render/terrain'; +import {config} from '../util/config'; + +/** + * @internal + * `SourceCache` is responsible for + * + * - creating an instance of `Source` + * - forwarding events from `Source` + * - caching tiles loaded from an instance of `Source` + * - loading the tiles needed to render a given viewport + * - unloading the cached tiles not needed to render a given viewport + */ +export class SourceCache extends Evented { + id: string; + dispatcher: Dispatcher; + map: Map; + style: Style; + + _source: Source; + _sourceLoaded: boolean; + _sourceErrored: boolean; + _tiles: {[_: string]: Tile}; + _prevLng: number; + _cache: TileCache; + _timers: { + [_ in any]: ReturnType; + }; + _cacheTimers: { + [_ in any]: ReturnType; + }; + _maxTileCacheSize: number; + _maxTileCacheZoomLevels: number; + _paused: boolean; + _shouldReloadOnResume: boolean; + _coveredTiles: {[_: string]: boolean}; + transform: Transform; + terrain: Terrain; + used: boolean; + usedForTerrain: boolean; + tileSize: number; + _state: SourceFeatureState; + _loadedParentTiles: {[_: string]: Tile}; + _didEmitContent: boolean; + _updated: boolean; + + static maxUnderzooming: number; + static maxOverzooming: number; + + constructor(id: string, options: SourceSpecification, dispatcher: Dispatcher) { + super(); + this.id = id; + this.dispatcher = dispatcher; + + this.on('data', (e: MapSourceDataEvent) => { + // this._sourceLoaded signifies that the TileJSON is loaded if applicable. + // if the source type does not come with a TileJSON, the flag signifies the + // source data has loaded (i.e geojson has been tiled on the worker and is ready) + if (e.dataType === 'source' && e.sourceDataType === 'metadata') this._sourceLoaded = true; + + // for sources with mutable data, this event fires when the underlying data + // to a source is changed. (i.e. GeoJSONSource#setData and ImageSource#serCoordinates) + if (this._sourceLoaded && !this._paused && e.dataType === 'source' && e.sourceDataType === 'content') { + this.reload(); + if (this.transform) { + this.update(this.transform, this.terrain); + } + + this._didEmitContent = true; + } + }); + + this.on('dataloading', () => { + this._sourceErrored = false; + }); + + this.on('error', () => { + // Only set _sourceErrored if the source does not have pending loads. + this._sourceErrored = this._source.loaded(); + }); + + this._source = createSource(id, options, dispatcher, this); + + this._tiles = {}; + this._cache = new TileCache(0, this._unloadTile.bind(this)); + this._timers = {}; + this._cacheTimers = {}; + this._maxTileCacheSize = null; + this._maxTileCacheZoomLevels = null; + this._loadedParentTiles = {}; + + this._coveredTiles = {}; + this._state = new SourceFeatureState(); + this._didEmitContent = false; + this._updated = false; + } + + onAdd(map: Map) { + this.map = map; + this._maxTileCacheSize = map ? map._maxTileCacheSize : null; + this._maxTileCacheZoomLevels = map ? map._maxTileCacheZoomLevels : null; + if (this._source && this._source.onAdd) { + this._source.onAdd(map); + } + } + + onRemove(map: Map) { + this.clearTiles(); + if (this._source && this._source.onRemove) { + this._source.onRemove(map); + } + } + + /** + * Return true if no tile data is pending, tiles will not change unless + * an additional API call is received. + */ + loaded(): boolean { + if (this._sourceErrored) { return true; } + if (!this._sourceLoaded) { return false; } + if (!this._source.loaded()) { return false; } + if ((this.used !== undefined || this.usedForTerrain !== undefined) && !this.used && !this.usedForTerrain) { return true; } + // do not consider as loaded if the update hasn't been called yet (we do not know if we will have any tiles to fetch) + if (!this._updated) { return false; } + + for (const t in this._tiles) { + const tile = this._tiles[t]; + if (tile.state !== 'loaded' && tile.state !== 'errored') + return false; + } + return true; + } + + getSource(): Source { + return this._source; + } + + pause() { + this._paused = true; + } + + resume() { + if (!this._paused) return; + const shouldReload = this._shouldReloadOnResume; + this._paused = false; + this._shouldReloadOnResume = false; + if (shouldReload) this.reload(); + if (this.transform) this.update(this.transform, this.terrain); + } + + _loadTile(tile: Tile, callback: Callback) { + return this._source.loadTile(tile, callback); + } + + _unloadTile(tile: Tile) { + if (this._source.unloadTile) + return this._source.unloadTile(tile, () => {}); + } + + _abortTile(tile: Tile) { + if (this._source.abortTile) + this._source.abortTile(tile, () => {}); + + this._source.fire(new Event('dataabort', {tile, coord: tile.tileID, dataType: 'source'})); + } + + serialize() { + return this._source.serialize(); + } + + prepare(context: Context) { + if (this._source.prepare) { + this._source.prepare(); + } + + this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null); + for (const i in this._tiles) { + const tile = this._tiles[i]; + tile.upload(context); + tile.prepare(this.map.style.imageManager); + } + } + + /** + * Return all tile ids ordered with z-order, and cast to numbers + */ + getIds(): Array { + return (Object.values(this._tiles) as any).map((tile: Tile) => tile.tileID).sort(compareTileId).map(id => id.key); + } + + getRenderableIds(symbolLayer?: boolean): Array { + const renderables: Array = []; + for (const id in this._tiles) { + if (this._isIdRenderable(id, symbolLayer)) renderables.push(this._tiles[id]); + } + if (symbolLayer) { + return renderables.sort((a_: Tile, b_: Tile) => { + const a = a_.tileID; + const b = b_.tileID; + const rotatedA = (new Point(a.canonical.x, a.canonical.y))._rotate(this.transform.angle); + const rotatedB = (new Point(b.canonical.x, b.canonical.y))._rotate(this.transform.angle); + return a.overscaledZ - b.overscaledZ || rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x; + }).map(tile => tile.tileID.key); + } + return renderables.map(tile => tile.tileID).sort(compareTileId).map(id => id.key); + } + + hasRenderableParent(tileID: OverscaledTileID) { + const parentTile = this.findLoadedParent(tileID, 0); + if (parentTile) { + return this._isIdRenderable(parentTile.tileID.key); + } + return false; + } + + _isIdRenderable(id: string, symbolLayer?: boolean) { + return this._tiles[id] && this._tiles[id].hasData() && + !this._coveredTiles[id] && (symbolLayer || !this._tiles[id].holdingForFade()); + } + + reload() { + if (this._paused) { + this._shouldReloadOnResume = true; + return; + } + + this._cache.reset(); + + for (const i in this._tiles) { + if (this._tiles[i].state !== 'errored') this._reloadTile(i, 'reloading'); + } + } + + _reloadTile(id: string, state: TileState) { + const tile = this._tiles[id]; + + // this potentially does not address all underlying + // issues https://github.com/mapbox/mapbox-gl-js/issues/4252 + // - hard to tell without repro steps + if (!tile) return; + + // The difference between "loading" tiles and "reloading" or "expired" + // tiles is that "reloading"/"expired" tiles are "renderable". + // Therefore, a "loading" tile cannot become a "reloading" tile without + // first becoming a "loaded" tile. + if (tile.state !== 'loading') { + tile.state = state; + } + + this._loadTile(tile, this._tileLoaded.bind(this, tile, id, state)); + } + + _tileLoaded(tile: Tile, id: string, previousState: TileState, err?: Error | null) { + if (err) { + tile.state = 'errored'; + if ((err as any).status !== 404) this._source.fire(new ErrorEvent(err, {tile})); + // continue to try loading parent/children tiles if a tile doesn't exist (404) + else this.update(this.transform, this.terrain); + return; + } + + tile.timeAdded = browser.now(); + if (previousState === 'expired') tile.refreshedUponExpiration = true; + this._setTileReloadTimer(id, tile); + if (this.getSource().type === 'raster-dem' && tile.dem) this._backfillDEM(tile); + this._state.initializeTileState(tile, this.map ? this.map.painter : null); + + if (!tile.aborted) { + this._source.fire(new Event('data', {dataType: 'source', tile, coord: tile.tileID})); + } + } + + /** + * For raster terrain source, backfill DEM to eliminate visible tile boundaries + */ + _backfillDEM(tile: Tile) { + const renderables = this.getRenderableIds(); + for (let i = 0; i < renderables.length; i++) { + const borderId = renderables[i]; + if (tile.neighboringTiles && tile.neighboringTiles[borderId]) { + const borderTile = this.getTileByID(borderId); + fillBorder(tile, borderTile); + fillBorder(borderTile, tile); + } + } + + function fillBorder(tile, borderTile) { + tile.needsHillshadePrepare = true; + tile.needsTerrainPrepare = true; + let dx = borderTile.tileID.canonical.x - tile.tileID.canonical.x; + const dy = borderTile.tileID.canonical.y - tile.tileID.canonical.y; + const dim = Math.pow(2, tile.tileID.canonical.z); + const borderId = borderTile.tileID.key; + if (dx === 0 && dy === 0) return; + + if (Math.abs(dy) > 1) { + return; + } + if (Math.abs(dx) > 1) { + // Adjust the delta coordinate for world wraparound. + if (Math.abs(dx + dim) === 1) { + dx += dim; + } else if (Math.abs(dx - dim) === 1) { + dx -= dim; + } + } + if (!borderTile.dem || !tile.dem) return; + tile.dem.backfillBorder(borderTile.dem, dx, dy); + if (tile.neighboringTiles && tile.neighboringTiles[borderId]) + tile.neighboringTiles[borderId].backfilled = true; + } + } + /** + * Get a specific tile by TileID + */ + getTile(tileID: OverscaledTileID): Tile { + return this.getTileByID(tileID.key); + } + + /** + * Get a specific tile by id + */ + getTileByID(id: string): Tile { + return this._tiles[id]; + } + + /** + * For a given set of tiles, retain children that are loaded and have a zoom + * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive) + */ + _retainLoadedChildren( + idealTiles: { + [_ in any]: OverscaledTileID; + }, + zoom: number, + maxCoveringZoom: number, + retain: { + [_ in any]: OverscaledTileID; + } + ) { + for (const id in this._tiles) { + let tile = this._tiles[id]; + + // only consider renderable tiles up to maxCoveringZoom + if (retain[id] || + !tile.hasData() || + tile.tileID.overscaledZ <= zoom || + tile.tileID.overscaledZ > maxCoveringZoom + ) continue; + + // loop through parents and retain the topmost loaded one if found + let topmostLoadedID = tile.tileID; + while (tile && tile.tileID.overscaledZ > zoom + 1) { + const parentID = tile.tileID.scaledTo(tile.tileID.overscaledZ - 1); + + tile = this._tiles[parentID.key]; + + if (tile && tile.hasData()) { + topmostLoadedID = parentID; + } + } + + // loop through ancestors of the topmost loaded child to see if there's one that needed it + let tileID = topmostLoadedID; + while (tileID.overscaledZ > zoom) { + tileID = tileID.scaledTo(tileID.overscaledZ - 1); + + if (idealTiles[tileID.key]) { + // found a parent that needed a loaded child; retain that child + retain[topmostLoadedID.key] = topmostLoadedID; + break; + } + } + } + } + + /** + * Find a loaded parent of the given tile (up to minCoveringZoom) + */ + findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): Tile { + if (tileID.key in this._loadedParentTiles) { + const parent = this._loadedParentTiles[tileID.key]; + if (parent && parent.tileID.overscaledZ >= minCoveringZoom) { + return parent; + } else { + return null; + } + } + for (let z = tileID.overscaledZ - 1; z >= minCoveringZoom; z--) { + const parentTileID = tileID.scaledTo(z); + const tile = this._getLoadedTile(parentTileID); + if (tile) { + return tile; + } + } + } + + _getLoadedTile(tileID: OverscaledTileID): Tile { + const tile = this._tiles[tileID.key]; + if (tile && tile.hasData()) { + return tile; + } + // TileCache ignores wrap in lookup. + const cachedTile = this._cache.getByKey(tileID.wrapped().key); + return cachedTile; + } + + /** + * Resizes the tile cache based on the current viewport's size + * or the maxTileCacheSize option passed during map creation + * + * Larger viewports use more tiles and need larger caches. Larger viewports + * are more likely to be found on devices with more memory and on pages where + * the map is more important. + */ + updateCacheSize(transform: Transform) { + const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1; + const heightInTiles = Math.ceil(transform.height / this._source.tileSize) + 1; + const approxTilesInView = widthInTiles * heightInTiles; + const commonZoomRange = this._maxTileCacheZoomLevels === null ? + config.MAX_TILE_CACHE_ZOOM_LEVELS : this._maxTileCacheZoomLevels; + const viewDependentMaxSize = Math.floor(approxTilesInView * commonZoomRange); + const maxSize = typeof this._maxTileCacheSize === 'number' ? + Math.min(this._maxTileCacheSize, viewDependentMaxSize) : viewDependentMaxSize; + + this._cache.setMaxSize(maxSize); + } + + handleWrapJump(lng: number) { + // On top of the regular z/x/y values, TileIDs have a `wrap` value that specify + // which cppy of the world the tile belongs to. For example, at `lng: 10` you + // might render z/x/y/0 while at `lng: 370` you would render z/x/y/1. + // + // When lng values get wrapped (going from `lng: 370` to `long: 10`) you expect + // to see the same thing on the screen (370 degrees and 10 degrees is the same + // place in the world) but all the TileIDs will have different wrap values. + // + // In order to make this transition seamless, we calculate the rounded difference of + // "worlds" between the last frame and the current frame. If the map panned by + // a world, then we can assign all the tiles new TileIDs with updated wrap values. + // For example, assign z/x/y/1 a new id: z/x/y/0. It is the same tile, just rendered + // in a different position. + // + // This enables us to reuse the tiles at more ideal locations and prevent flickering. + const prevLng = this._prevLng === undefined ? lng : this._prevLng; + const lngDifference = lng - prevLng; + const worldDifference = lngDifference / 360; + const wrapDelta = Math.round(worldDifference); + this._prevLng = lng; + + if (wrapDelta) { + const tiles: {[_: string]: Tile} = {}; + for (const key in this._tiles) { + const tile = this._tiles[key]; + tile.tileID = tile.tileID.unwrapTo(tile.tileID.wrap + wrapDelta); + tiles[tile.tileID.key] = tile; + } + this._tiles = tiles; + + // Reset tile reload timers + for (const id in this._timers) { + clearTimeout(this._timers[id]); + delete this._timers[id]; + } + for (const id in this._tiles) { + const tile = this._tiles[id]; + this._setTileReloadTimer(id, tile); + } + } + } + + /** + * Removes tiles that are outside the viewport and adds new tiles that + * are inside the viewport. + */ + update(transform: Transform, terrain?: Terrain) { + this.transform = transform; + this.terrain = terrain; + if (!this._sourceLoaded || this._paused) { return; } + + this.updateCacheSize(transform); + this.handleWrapJump(this.transform.center.lng); + + // Covered is a list of retained tiles who's areas are fully covered by other, + // better, retained tiles. They are not drawn separately. + this._coveredTiles = {}; + + let idealTileIDs; + if (!this.used && !this.usedForTerrain) { + idealTileIDs = []; + } else if (this._source.tileID) { + idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID) + .map((unwrapped) => new OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y)); + } else { + idealTileIDs = transform.coveringTiles({ + tileSize: this.usedForTerrain ? this.tileSize : this._source.tileSize, + minzoom: this._source.minzoom, + maxzoom: this._source.maxzoom, + roundZoom: this.usedForTerrain ? false : this._source.roundZoom, + reparseOverscaled: this._source.reparseOverscaled, + terrain + }); + + if (this._source.hasTile) { + idealTileIDs = idealTileIDs.filter((coord) => (this._source.hasTile as any)(coord)); + } + } + + // Determine the overzooming/underzooming amounts. + const zoom = transform.coveringZoomLevel(this._source); + const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom); + const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom); + + // When sourcecache is used for terrain also load parent tiles to avoid flickering when zooming out + if (this.usedForTerrain) { + const parents = {}; + for (const tileID of idealTileIDs) { + if (tileID.canonical.z > this._source.minzoom) { + const parent = tileID.scaledTo(tileID.canonical.z - 1); + parents[parent.key] = parent; + // load very low zoom to calculate tile visibility in transform.coveringTiles and high zoomlevels correct + const parent2 = tileID.scaledTo(Math.max(this._source.minzoom, Math.min(tileID.canonical.z, 5))); + parents[parent2.key] = parent2; + } + } + idealTileIDs = idealTileIDs.concat(Object.values(parents)); + } + + const noPendingDataEmissions = idealTileIDs.length === 0 && !this._updated && this._didEmitContent; + this._updated = true; + // if we won't have any tiles to fetch and content is already emitted + // there will be no more data emissions, so we need to emit the event with isSourceLoaded = true + if (noPendingDataEmissions) { + this.fire(new Event('data', {sourceDataType: 'idle', dataType: 'source', sourceId: this.id})); + } + + // Retain is a list of tiles that we shouldn't delete, even if they are not + // the most ideal tile for the current viewport. This may include tiles like + // parent or child tiles that are *already* loaded. + const retain = this._updateRetainedTiles(idealTileIDs, zoom); + + if (isRasterType(this._source.type)) { + const parentsForFading: {[_: string]: OverscaledTileID} = {}; + const fadingTiles = {}; + const ids = Object.keys(retain); + const now = browser.now(); + for (const id of ids) { + const tileID = retain[id]; + + const tile = this._tiles[id]; + + // when fadeEndTime is 0, the tile is created but registerFadeDuration + // has not been called, therefore must be kept in fadingTiles dictionary + // for next round of rendering + if (!tile || (tile.fadeEndTime !== 0 && tile.fadeEndTime <= now)) { + continue; + } + + // if the tile is loaded but still fading in, find parents to cross-fade with it + const parentTile = this.findLoadedParent(tileID, minCoveringZoom); + if (parentTile) { + this._addTile(parentTile.tileID); + parentsForFading[parentTile.tileID.key] = parentTile.tileID; + } + + fadingTiles[id] = tileID; + } + + // for tiles that are still fading in, also find children to cross-fade with + this._retainLoadedChildren(fadingTiles, zoom, maxCoveringZoom, retain); + + for (const id in parentsForFading) { + if (!retain[id]) { + // If a tile is only needed for fading, mark it as covered so that it isn't rendered on it's own. + this._coveredTiles[id] = true; + retain[id] = parentsForFading[id]; + } + } + + // disable fading logic in terrain3D mode to avoid rendering two tiles on the same place + if (terrain) { + const idealRasterTileIDs: {[_: string]: OverscaledTileID} = {}; + const missingTileIDs: {[_: string]: OverscaledTileID} = {}; + for (const tileID of idealTileIDs) { + if (this._tiles[tileID.key].hasData()) + idealRasterTileIDs[tileID.key] = tileID; + else + missingTileIDs[tileID.key] = tileID; + } + // search for a complete set of children for each missing tile + for (const key in missingTileIDs) { + const children = missingTileIDs[key].children(this._source.maxzoom); + if (this._tiles[children[0].key] && this._tiles[children[1].key] && this._tiles[children[2].key] && this._tiles[children[3].key]) { + idealRasterTileIDs[children[0].key] = retain[children[0].key] = children[0]; + idealRasterTileIDs[children[1].key] = retain[children[1].key] = children[1]; + idealRasterTileIDs[children[2].key] = retain[children[2].key] = children[2]; + idealRasterTileIDs[children[3].key] = retain[children[3].key] = children[3]; + delete missingTileIDs[key]; + } + } + // search for parent for each missing tile + for (const key in missingTileIDs) { + const parent = this.findLoadedParent(missingTileIDs[key], this._source.minzoom); + if (parent) { + idealRasterTileIDs[parent.tileID.key] = retain[parent.tileID.key] = parent.tileID; + // remove idealTiles which would be rendered twice + for (const key in idealRasterTileIDs) { + if (idealRasterTileIDs[key].isChildOf(parent.tileID)) delete idealRasterTileIDs[key]; + } + } + } + // cover all tiles which are not needed + for (const key in this._tiles) { + if (!idealRasterTileIDs[key]) this._coveredTiles[key] = true; + } + } + } + + for (const retainedId in retain) { + // Make sure retained tiles always clear any existing fade holds + // so that if they're removed again their fade timer starts fresh. + this._tiles[retainedId].clearFadeHold(); + } + + // Remove the tiles we don't need anymore. + const remove = keysDifference(this._tiles, retain); + for (const tileID of remove) { + const tile = this._tiles[tileID]; + if (tile.hasSymbolBuckets && !tile.holdingForFade()) { + tile.setHoldDuration(this.map._fadeDuration); + } else if (!tile.hasSymbolBuckets || tile.symbolFadeFinished()) { + this._removeTile(tileID); + } + } + + // Construct a cache of loaded parents + this._updateLoadedParentTileCache(); + } + + releaseSymbolFadeTiles() { + for (const id in this._tiles) { + if (this._tiles[id].holdingForFade()) { + this._removeTile(id); + } + } + } + + _updateRetainedTiles(idealTileIDs: Array, zoom: number): {[_: string]: OverscaledTileID} { + const retain: {[_: string]: OverscaledTileID} = {}; + const checked: {[_: string]: boolean} = {}; + const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom); + const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom); + + const missingTiles = {}; + for (const tileID of idealTileIDs) { + const tile = this._addTile(tileID); + + // retain the tile even if it's not loaded because it's an ideal tile. + retain[tileID.key] = tileID; + + if (tile.hasData()) continue; + + if (zoom < this._source.maxzoom) { + // save missing tiles that potentially have loaded children + missingTiles[tileID.key] = tileID; + } + } + + // retain any loaded children of ideal tiles up to maxCoveringZoom + this._retainLoadedChildren(missingTiles, zoom, maxCoveringZoom, retain); + + for (const tileID of idealTileIDs) { + let tile = this._tiles[tileID.key]; + + if (tile.hasData()) continue; + + // The tile we require is not yet loaded or does not exist; + // Attempt to find children that fully cover it. + + if (zoom + 1 > this._source.maxzoom) { + // We're looking for an overzoomed child tile. + const childCoord = tileID.children(this._source.maxzoom)[0]; + const childTile = this.getTile(childCoord); + if (!!childTile && childTile.hasData()) { + retain[childCoord.key] = childCoord; + continue; // tile is covered by overzoomed child + } + } else { + // check if all 4 immediate children are loaded (i.e. the missing ideal tile is covered) + const children = tileID.children(this._source.maxzoom); + + if (retain[children[0].key] && + retain[children[1].key] && + retain[children[2].key] && + retain[children[3].key]) continue; // tile is covered by children + } + + // We couldn't find child tiles that entirely cover the ideal tile; look for parents now. + + // As we ascend up the tile pyramid of the ideal tile, we check whether the parent + // tile has been previously requested (and errored because we only loop over tiles with no data) + // in order to determine if we need to request its parent. + let parentWasRequested = tile.wasRequested(); + + for (let overscaledZ = tileID.overscaledZ - 1; overscaledZ >= minCoveringZoom; --overscaledZ) { + const parentId = tileID.scaledTo(overscaledZ); + + // Break parent tile ascent if this route has been previously checked by another child. + if (checked[parentId.key]) break; + checked[parentId.key] = true; + + tile = this.getTile(parentId); + if (!tile && parentWasRequested) { + tile = this._addTile(parentId); + } + if (tile) { + const hasData = tile.hasData(); + if (parentWasRequested || hasData) { + retain[parentId.key] = parentId; + } + // Save the current values, since they're the parent of the next iteration + // of the parent tile ascent loop. + parentWasRequested = tile.wasRequested(); + if (hasData) break; + } + } + } + + return retain; + } + + _updateLoadedParentTileCache() { + this._loadedParentTiles = {}; + + for (const tileKey in this._tiles) { + const path = []; + let parentTile: Tile; + let currentId = this._tiles[tileKey].tileID; + + // Find the closest loaded ancestor by traversing the tile tree towards the root and + // caching results along the way + while (currentId.overscaledZ > 0) { + + // Do we have a cached result from previous traversals? + if (currentId.key in this._loadedParentTiles) { + parentTile = this._loadedParentTiles[currentId.key]; + break; + } + + path.push(currentId.key); + + // Is the parent loaded? + const parentId = currentId.scaledTo(currentId.overscaledZ - 1); + parentTile = this._getLoadedTile(parentId); + if (parentTile) { + break; + } + + currentId = parentId; + } + + // Cache the result of this traversal to all newly visited tiles + for (const key of path) { + this._loadedParentTiles[key] = parentTile; + } + } + } + + /** + * Add a tile, given its coordinate, to the pyramid. + */ + _addTile(tileID: OverscaledTileID): Tile { + let tile = this._tiles[tileID.key]; + if (tile) + return tile; + + tile = this._cache.getAndRemove(tileID); + if (tile) { + this._setTileReloadTimer(tileID.key, tile); + // set the tileID because the cached tile could have had a different wrap value + tile.tileID = tileID; + this._state.initializeTileState(tile, this.map ? this.map.painter : null); + if (this._cacheTimers[tileID.key]) { + clearTimeout(this._cacheTimers[tileID.key]); + delete this._cacheTimers[tileID.key]; + this._setTileReloadTimer(tileID.key, tile); + } + } + + const cached = tile; + + if (!tile) { + tile = new Tile(tileID, this._source.tileSize * tileID.overscaleFactor()); + this._loadTile(tile, this._tileLoaded.bind(this, tile, tileID.key, tile.state)); + } + + tile.uses++; + this._tiles[tileID.key] = tile; + if (!cached) { + this._source.fire(new Event('dataloading', {tile, coord: tile.tileID, dataType: 'source'})); + } + + return tile; + } + + _setTileReloadTimer(id: string, tile: Tile) { + if (id in this._timers) { + clearTimeout(this._timers[id]); + delete this._timers[id]; + } + + const expiryTimeout = tile.getExpiryTimeout(); + if (expiryTimeout) { + this._timers[id] = setTimeout(() => { + this._reloadTile(id, 'expired'); + delete this._timers[id]; + }, expiryTimeout); + } + } + + /** + * Remove a tile, given its id, from the pyramid + */ + _removeTile(id: string) { + const tile = this._tiles[id]; + if (!tile) + return; + + tile.uses--; + delete this._tiles[id]; + if (this._timers[id]) { + clearTimeout(this._timers[id]); + delete this._timers[id]; + } + + if (tile.uses > 0) + return; + + if (tile.hasData() && tile.state !== 'reloading') { + this._cache.add(tile.tileID, tile, tile.getExpiryTimeout()); + } else { + tile.aborted = true; + this._abortTile(tile); + this._unloadTile(tile); + } + } + + /** + * Remove all tiles from this pyramid + */ + clearTiles() { + this._shouldReloadOnResume = false; + this._paused = false; + + for (const id in this._tiles) + this._removeTile(id); + + this._cache.reset(); + } + + /** + * Search through our current tiles and attempt to find the tiles that + * cover the given bounds. + * @param pointQueryGeometry - coordinates of the corners of bounding rectangle + * @returns result items have `{tile, minX, maxX, minY, maxY}`, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile. + */ + tilesIn(pointQueryGeometry: Array, maxPitchScaleFactor: number, has3DLayer: boolean): any[] { + + const tileResults = []; + + const transform = this.transform; + if (!transform) return tileResults; + + const cameraPointQueryGeometry = has3DLayer ? + transform.getCameraQueryGeometry(pointQueryGeometry) : + pointQueryGeometry; + + const queryGeometry = pointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain)); + const cameraQueryGeometry = cameraPointQueryGeometry.map((p: Point) => transform.pointCoordinate(p, this.terrain)); + + const ids = this.getIds(); + + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + + for (const p of cameraQueryGeometry) { + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + + for (let i = 0; i < ids.length; i++) { + const tile = this._tiles[ids[i]]; + if (tile.holdingForFade()) { + // Tiles held for fading are covered by tiles that are closer to ideal + continue; + } + const tileID = tile.tileID; + const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ); + const queryPadding = maxPitchScaleFactor * tile.queryPadding * EXTENT / tile.tileSize / scale; + + const tileSpaceBounds = [ + tileID.getTilePoint(new MercatorCoordinate(minX, minY)), + tileID.getTilePoint(new MercatorCoordinate(maxX, maxY)) + ]; + + if (tileSpaceBounds[0].x - queryPadding < EXTENT && tileSpaceBounds[0].y - queryPadding < EXTENT && + tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) { + + const tileSpaceQueryGeometry: Array = queryGeometry.map((c) => tileID.getTilePoint(c)); + const tileSpaceCameraQueryGeometry = cameraQueryGeometry.map((c) => tileID.getTilePoint(c)); + + tileResults.push({ + tile, + tileID, + queryGeometry: tileSpaceQueryGeometry, + cameraQueryGeometry: tileSpaceCameraQueryGeometry, + scale + }); + } + } + + return tileResults; + } + + getVisibleCoordinates(symbolLayer?: boolean): Array { + const coords = this.getRenderableIds(symbolLayer).map((id) => this._tiles[id].tileID); + for (const coord of coords) { + coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped()); + } + return coords; + } + + hasTransition() { + if (this._source.hasTransition()) { + return true; + } + + if (isRasterType(this._source.type)) { + const now = browser.now(); + for (const id in this._tiles) { + const tile = this._tiles[id]; + if (tile.fadeEndTime >= now) { + return true; + } + } + } + + return false; + } + + /** + * Set the value of a particular state for a feature + */ + setFeatureState(sourceLayer: string, featureId: number | string, state: any) { + sourceLayer = sourceLayer || '_geojsonTileLayer'; + this._state.updateState(sourceLayer, featureId, state); + } + + /** + * Resets the value of a particular state key for a feature + */ + removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) { + sourceLayer = sourceLayer || '_geojsonTileLayer'; + this._state.removeFeatureState(sourceLayer, featureId, key); + } + + /** + * Get the entire state object for a feature + */ + getFeatureState(sourceLayer: string, featureId: number | string) { + sourceLayer = sourceLayer || '_geojsonTileLayer'; + return this._state.getState(sourceLayer, featureId); + } + + /** + * Sets the set of keys that the tile depends on. This allows tiles to + * be reloaded when their dependencies change. + */ + setDependencies(tileKey: string, namespace: string, dependencies: Array) { + const tile = this._tiles[tileKey]; + if (tile) { + tile.setDependencies(namespace, dependencies); + } + } + + /** + * Reloads all tiles that depend on the given keys. + */ + reloadTilesForDependencies(namespaces: Array, keys: Array) { + for (const id in this._tiles) { + const tile = this._tiles[id]; + if (tile.hasDependency(namespaces, keys)) { + this._reloadTile(id, 'reloading'); + } + } + this._cache.filter(tile => !tile.hasDependency(namespaces, keys)); + } +} + +SourceCache.maxOverzooming = 10; +SourceCache.maxUnderzooming = 3; + +function compareTileId(a: OverscaledTileID, b: OverscaledTileID): number { + // Different copies of the world are sorted based on their distance to the center. + // Wrap values are converted to unsigned distances by reserving odd number for copies + // with negative wrap and even numbers for copies with positive wrap. + const aWrap = Math.abs(a.wrap * 2) - +(a.wrap < 0); + const bWrap = Math.abs(b.wrap * 2) - +(b.wrap < 0); + return a.overscaledZ - b.overscaledZ || bWrap - aWrap || b.canonical.y - a.canonical.y || b.canonical.x - a.canonical.x; +} + +function isRasterType(type) { + return type === 'raster' || type === 'image' || type === 'video'; +} diff --git a/web/libraries/maplibre-gl/src/source/source_state.ts b/web/libraries/maplibre-gl/src/source/source_state.ts new file mode 100644 index 00000000..6358e92d --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/source_state.ts @@ -0,0 +1,157 @@ +import {extend} from '../util/util'; +import {Tile} from './tile'; +import type {FeatureState} from '@maplibre/maplibre-gl-style-spec'; + +export type FeatureStates = {[featureId: string]: FeatureState}; +export type LayerFeatureStates = {[layer: string]: FeatureStates}; + +/** + * @internal + * SourceFeatureState manages the state and pending changes + * to features in a source, separated by source layer. + * stateChanges and deletedStates batch all changes to the tile (updates and removes, respectively) + * between coalesce() events. addFeatureState() and removeFeatureState() also update their counterpart's + * list of changes, such that coalesce() can apply the proper state changes while agnostic to the order of operations. + * In deletedStates, all null's denote complete removal of state at that scope +*/ +export class SourceFeatureState { + state: LayerFeatureStates; + stateChanges: LayerFeatureStates; + deletedStates: {}; + + constructor() { + this.state = {}; + this.stateChanges = {}; + this.deletedStates = {}; + } + + updateState(sourceLayer: string, featureId: number | string, newState: any) { + const feature = String(featureId); + this.stateChanges[sourceLayer] = this.stateChanges[sourceLayer] || {}; + this.stateChanges[sourceLayer][feature] = this.stateChanges[sourceLayer][feature] || {}; + extend(this.stateChanges[sourceLayer][feature], newState); + + if (this.deletedStates[sourceLayer] === null) { + this.deletedStates[sourceLayer] = {}; + for (const ft in this.state[sourceLayer]) { + if (ft !== feature) this.deletedStates[sourceLayer][ft] = null; + } + } else { + const featureDeletionQueued = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] === null; + if (featureDeletionQueued) { + this.deletedStates[sourceLayer][feature] = {}; + for (const prop in this.state[sourceLayer][feature]) { + if (!newState[prop]) this.deletedStates[sourceLayer][feature][prop] = null; + } + } else { + for (const key in newState) { + const deletionInQueue = this.deletedStates[sourceLayer] && this.deletedStates[sourceLayer][feature] && this.deletedStates[sourceLayer][feature][key] === null; + if (deletionInQueue) delete this.deletedStates[sourceLayer][feature][key]; + } + } + } + } + + removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string) { + const sourceLayerDeleted = this.deletedStates[sourceLayer] === null; + if (sourceLayerDeleted) return; + + const feature = String(featureId); + + this.deletedStates[sourceLayer] = this.deletedStates[sourceLayer] || {}; + + if (key && featureId !== undefined) { + if (this.deletedStates[sourceLayer][feature] !== null) { + this.deletedStates[sourceLayer][feature] = this.deletedStates[sourceLayer][feature] || {}; + this.deletedStates[sourceLayer][feature][key] = null; + } + } else if (featureId !== undefined) { + const updateInQueue = this.stateChanges[sourceLayer] && this.stateChanges[sourceLayer][feature]; + if (updateInQueue) { + this.deletedStates[sourceLayer][feature] = {}; + for (key in this.stateChanges[sourceLayer][feature]) this.deletedStates[sourceLayer][feature][key] = null; + + } else { + this.deletedStates[sourceLayer][feature] = null; + } + } else { + this.deletedStates[sourceLayer] = null; + } + + } + + getState(sourceLayer: string, featureId: number | string) { + const feature = String(featureId); + const base = this.state[sourceLayer] || {}; + const changes = this.stateChanges[sourceLayer] || {}; + + const reconciledState = extend({}, base[feature], changes[feature]); + + //return empty object if the whole source layer is awaiting deletion + if (this.deletedStates[sourceLayer] === null) return {}; + else if (this.deletedStates[sourceLayer]) { + const featureDeletions = this.deletedStates[sourceLayer][featureId]; + if (featureDeletions === null) return {}; + for (const prop in featureDeletions) delete reconciledState[prop]; + } + return reconciledState; + } + + initializeTileState(tile: Tile, painter: any) { + tile.setFeatureState(this.state, painter); + } + + coalesceChanges(tiles: { + [_ in any]: Tile; + }, painter: any) { + //track changes with full state objects, but only for features that got modified + const featuresChanged: LayerFeatureStates = {}; + + for (const sourceLayer in this.stateChanges) { + this.state[sourceLayer] = this.state[sourceLayer] || {}; + const layerStates = {}; + for (const feature in this.stateChanges[sourceLayer]) { + if (!this.state[sourceLayer][feature]) this.state[sourceLayer][feature] = {}; + extend(this.state[sourceLayer][feature], this.stateChanges[sourceLayer][feature]); + layerStates[feature] = this.state[sourceLayer][feature]; + } + featuresChanged[sourceLayer] = layerStates; + } + + for (const sourceLayer in this.deletedStates) { + this.state[sourceLayer] = this.state[sourceLayer] || {}; + const layerStates = {}; + + if (this.deletedStates[sourceLayer] === null) { + for (const ft in this.state[sourceLayer]) { + layerStates[ft] = {}; + this.state[sourceLayer][ft] = {}; + } + } else { + for (const feature in this.deletedStates[sourceLayer]) { + const deleteWholeFeatureState = this.deletedStates[sourceLayer][feature] === null; + if (deleteWholeFeatureState) this.state[sourceLayer][feature] = {}; + else { + for (const key of Object.keys(this.deletedStates[sourceLayer][feature])) { + delete this.state[sourceLayer][feature][key]; + } + } + layerStates[feature] = this.state[sourceLayer][feature]; + } + } + + featuresChanged[sourceLayer] = featuresChanged[sourceLayer] || {}; + extend(featuresChanged[sourceLayer], layerStates); + } + + this.stateChanges = {}; + this.deletedStates = {}; + + if (Object.keys(featuresChanged).length === 0) return; + + for (const id in tiles) { + const tile = tiles[id]; + tile.setFeatureState(featuresChanged, painter); + } + } +} diff --git a/web/libraries/maplibre-gl/src/source/terrain_source_cache.test.ts b/web/libraries/maplibre-gl/src/source/terrain_source_cache.test.ts new file mode 100644 index 00000000..a947a543 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/terrain_source_cache.test.ts @@ -0,0 +1,105 @@ +import {TerrainSourceCache} from './terrain_source_cache'; +import {Style} from '../style/style'; +import {RequestManager} from '../util/request_manager'; +import {Dispatcher} from '../util/dispatcher'; +import {fakeServer, type FakeServer} from 'nise'; +import {Transform} from '../geo/transform'; +import {Evented} from '../util/evented'; +import {Painter} from '../render/painter'; +import {RasterDEMTileSource} from './raster_dem_tile_source'; +import {OverscaledTileID} from './tile_id'; +import {Tile} from './tile'; +import {DEMData} from '../data/dem_data'; + +const transform = new Transform(); + +class StubMap extends Evented { + transform: Transform; + painter: Painter; + _requestManager: RequestManager; + + constructor() { + super(); + this.transform = transform; + this._requestManager = { + transformRequest: (url) => { + return {url}; + } + } as any as RequestManager; + } + + _getMapId() { + return 1; + } + + setTerrain() {} +} + +function createSource(options, transformCallback?) { + const source = new RasterDEMTileSource('id', options, {send() {}} as any as Dispatcher, null); + source.onAdd({ + transform, + _requestManager: new RequestManager(transformCallback), + getPixelRatio() { return 1; } + } as any); + + source.on('error', (e) => { + throw e.error; + }); + + return source; +} + +describe('TerrainSourceCache', () => { + let server: FakeServer; + let style: Style; + let tsc: TerrainSourceCache; + + beforeAll(done => { + global.fetch = null; + server = fakeServer.create(); + server.respondWith('/source.json', JSON.stringify({ + minzoom: 5, + maxzoom: 12, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.pngraw'], + bounds: [-47, -7, -45, -5] + })); + const map = new StubMap(); + style = new Style(map as any); + style.on('style.load', () => { + const source = createSource({url: '/source.json'}); + server.respond(); + style.addSource('terrain', source as any); + tsc = new TerrainSourceCache(style.sourceCaches.terrain); + done(); + }); + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [] + }); + }); + + afterAll(() => { + server.restore(); + }); + + test('#constructor', () => { + expect(tsc.sourceCache.usedForTerrain).toBeTruthy(); + expect(tsc.sourceCache.tileSize).toBe(tsc.tileSize * 2 ** tsc.deltaZoom); + }); + + test('#getSourceTile', () => { + const tileID = new OverscaledTileID(5, 0, 5, 17, 11); + const tile = new Tile(tileID, 256); + tile.dem = {} as DEMData; + tsc.sourceCache._tiles[tileID.key] = tile; + expect(tsc.deltaZoom).toBe(1); + expect(tsc.getSourceTile(tileID)).toBeFalsy(); + expect(tsc.getSourceTile(tileID.children(12)[0])).toBeTruthy(); + expect(tsc.getSourceTile(tileID.children(12)[0].children(12)[0])).toBeFalsy(); + expect(tsc.getSourceTile(tileID.children(12)[0].children(12)[0], true)).toBeTruthy(); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/source/terrain_source_cache.ts b/web/libraries/maplibre-gl/src/source/terrain_source_cache.ts new file mode 100644 index 00000000..909e8232 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/terrain_source_cache.ts @@ -0,0 +1,203 @@ +import {OverscaledTileID} from './tile_id'; +import {Tile} from './tile'; +import {EXTENT} from '../data/extent'; +import {mat4} from 'gl-matrix'; +import {Evented} from '../util/evented'; +import type {Transform} from '../geo/transform'; +import type {SourceCache} from '../source/source_cache'; +import {Terrain} from '../render/terrain'; + +/** + * @internal + * This class is a helper for the Terrain-class, it: + * - loads raster-dem tiles + * - manages all renderToTexture tiles. + * - caches previous rendered tiles. + * - finds all necessary renderToTexture tiles for a OverscaledTileID area + * - finds the corresponding raster-dem tile for OverscaledTileID + */ +export class TerrainSourceCache extends Evented { + /** + * source-cache for the raster-dem source. + */ + sourceCache: SourceCache; + /** + * stores all render-to-texture tiles. + */ + _tiles: {[_: string]: Tile}; + /** + * contains a list of tileID-keys for the current scene. (only for performance) + */ + _renderableTilesKeys: Array; + /** + * raster-dem-tile for a TileID cache. + */ + _sourceTileCache: {[_: string]: string}; + /** + * minimum zoomlevel to render the terrain. + */ + minzoom: number; + /** + * maximum zoomlevel to render the terrain. + */ + maxzoom: number; + /** + * render-to-texture tileSize in scene. + */ + tileSize: number; + /** + * raster-dem tiles will load for performance the actualZoom - deltaZoom zoom-level. + */ + deltaZoom: number; + + constructor(sourceCache: SourceCache) { + super(); + this.sourceCache = sourceCache; + this._tiles = {}; + this._renderableTilesKeys = []; + this._sourceTileCache = {}; + this.minzoom = 0; + this.maxzoom = 22; + this.tileSize = 512; + this.deltaZoom = 1; + sourceCache.usedForTerrain = true; + sourceCache.tileSize = this.tileSize * 2 ** this.deltaZoom; + } + + destruct() { + this.sourceCache.usedForTerrain = false; + this.sourceCache.tileSize = null; + } + + /** + * Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory. + * @param transform - the operation to do + * @param terrain - the terrain + */ + update(transform: Transform, terrain: Terrain): void { + // load raster-dem tiles for the current scene. + this.sourceCache.update(transform, terrain); + // create internal render-to-texture tiles for the current scene. + this._renderableTilesKeys = []; + const keys = {}; + for (const tileID of transform.coveringTiles({ + tileSize: this.tileSize, + minzoom: this.minzoom, + maxzoom: this.maxzoom, + reparseOverscaled: false, + terrain + })) { + keys[tileID.key] = true; + this._renderableTilesKeys.push(tileID.key); + if (!this._tiles[tileID.key]) { + tileID.posMatrix = new Float64Array(16) as any; + mat4.ortho(tileID.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1); + this._tiles[tileID.key] = new Tile(tileID, this.tileSize); + } + } + // free unused tiles + for (const key in this._tiles) { + if (!keys[key]) delete this._tiles[key]; + } + } + + /** + * Free render to texture cache + * @param tileID - optional, free only corresponding to tileID. + */ + freeRtt(tileID?: OverscaledTileID) { + for (const key in this._tiles) { + const tile = this._tiles[key]; + if (!tileID || tile.tileID.equals(tileID) || tile.tileID.isChildOf(tileID) || tileID.isChildOf(tile.tileID)) + tile.rtt = []; + } + } + + /** + * get a list of tiles, which are loaded and should be rendered in the current scene + * @returns the renderable tiles + */ + getRenderableTiles(): Array { + return this._renderableTilesKeys.map(key => this.getTileByID(key)); + } + + /** + * get terrain tile by the TileID key + * @param id - the tile id + * @returns the tile + */ + getTileByID(id: string): Tile { + return this._tiles[id]; + } + + /** + * Searches for the corresponding current renderable terrain-tiles + * @param tileID - the tile to look for + * @returns the tiles that were found + */ + getTerrainCoords(tileID: OverscaledTileID): Record { + const coords = {}; + for (const key of this._renderableTilesKeys) { + const _tileID = this._tiles[key].tileID; + if (_tileID.canonical.equals(tileID.canonical)) { + const coord = tileID.clone(); + coord.posMatrix = new Float64Array(16) as any; + mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1); + coords[key] = coord; + } else if (_tileID.canonical.isChildOf(tileID.canonical)) { + const coord = tileID.clone(); + coord.posMatrix = new Float64Array(16) as any; + const dz = _tileID.canonical.z - tileID.canonical.z; + const dx = _tileID.canonical.x - (_tileID.canonical.x >> dz << dz); + const dy = _tileID.canonical.y - (_tileID.canonical.y >> dz << dz); + const size = EXTENT >> dz; + mat4.ortho(coord.posMatrix, 0, size, 0, size, 0, 1); + mat4.translate(coord.posMatrix, coord.posMatrix, [-dx * size, -dy * size, 0]); + coords[key] = coord; + } else if (tileID.canonical.isChildOf(_tileID.canonical)) { + const coord = tileID.clone(); + coord.posMatrix = new Float64Array(16) as any; + const dz = tileID.canonical.z - _tileID.canonical.z; + const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz); + const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz); + const size = EXTENT >> dz; + mat4.ortho(coord.posMatrix, 0, EXTENT, 0, EXTENT, 0, 1); + mat4.translate(coord.posMatrix, coord.posMatrix, [dx * size, dy * size, 0]); + mat4.scale(coord.posMatrix, coord.posMatrix, [1 / (2 ** dz), 1 / (2 ** dz), 0]); + coords[key] = coord; + } + } + return coords; + } + + /** + * find the covering raster-dem tile + * @param tileID - the tile to look for + * @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem. + * @returns the tile + */ + getSourceTile(tileID: OverscaledTileID, searchForDEM?: boolean): Tile { + const source = this.sourceCache._source; + let z = tileID.overscaledZ - this.deltaZoom; + if (z > source.maxzoom) z = source.maxzoom; + if (z < source.minzoom) return null; + // cache for tileID to terrain-tileID + if (!this._sourceTileCache[tileID.key]) + this._sourceTileCache[tileID.key] = tileID.scaledTo(z).key; + let tile = this.sourceCache.getTileByID(this._sourceTileCache[tileID.key]); + // during tile-loading phase look if parent tiles (with loaded dem) are available. + if (!(tile && tile.dem) && searchForDEM) + while (z >= source.minzoom && !(tile && tile.dem)) + tile = this.sourceCache.getTileByID(tileID.scaledTo(z--).key); + return tile; + } + + /** + * get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers. + * @param time - the time + * @returns the relevant tiles + */ + tilesAfterTime(time = Date.now()): Array { + return Object.values(this._tiles).filter(t => t.timeAdded >= time); + } +} diff --git a/web/libraries/maplibre-gl/src/source/tile.test.ts b/web/libraries/maplibre-gl/src/source/tile.test.ts new file mode 100644 index 00000000..1fcf9da0 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile.test.ts @@ -0,0 +1,290 @@ +import {createSymbolBucket} from '../../test/unit/lib/create_symbol_layer'; +import {Tile} from '../source/tile'; +import {GeoJSONWrapper, Feature} from '../source/geojson_wrapper'; +import {OverscaledTileID} from '../source/tile_id'; +import fs from 'fs'; +import path from 'path'; +import vtpbf from 'vt-pbf'; +import {FeatureIndex} from '../data/feature_index'; +import {CollisionBoxArray} from '../data/array_types.g'; +import {extend} from '../util/util'; +import {serialize, deserialize} from '../util/web_worker_transfer'; + +describe('querySourceFeatures', () => { + const features = [{ + type: 1, + geometry: [0, 0], + tags: {oneway: true} + } as any as Feature]; + + test('geojson tile', () => { + const tile = new Tile(new OverscaledTileID(3, 0, 2, 1, 2), undefined); + let result; + + result = []; + tile.querySourceFeatures(result); + expect(result).toHaveLength(0); + + const geojsonWrapper = new GeoJSONWrapper(features); + geojsonWrapper.name = '_geojsonTileLayer'; + tile.loadVectorData( + createVectorData({rawTileData: vtpbf({layers: {'_geojsonTileLayer': geojsonWrapper}})}), + createPainter() + ); + + result = []; + tile.querySourceFeatures(result); + expect(result).toHaveLength(1); + expect(result[0].geometry.coordinates[0]).toEqual([-90, 0]); + result = []; + tile.querySourceFeatures(result, {} as any); + expect(result).toHaveLength(1); + expect(result[0].properties).toEqual(features[0].tags); + result = []; + tile.querySourceFeatures(result, {sourceLayer: undefined, filter: ['==', 'oneway', true]}); + expect(result).toHaveLength(1); + result = []; + tile.querySourceFeatures(result, {sourceLayer: undefined, filter: ['!=', 'oneway', true]}); + expect(result).toHaveLength(0); + result = []; + const polygon = {type: 'Polygon', coordinates: [[[-91, -1], [-89, -1], [-89, 1], [-91, 1], [-91, -1]]]}; + tile.querySourceFeatures(result, {sourceLayer: undefined, filter: ['within', polygon]}); + expect(result).toHaveLength(1); + }); + + test('empty geojson tile', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + let result; + + result = []; + tile.querySourceFeatures(result); + expect(result).toHaveLength(0); + + const geojsonWrapper = new GeoJSONWrapper([]); + geojsonWrapper.name = '_geojsonTileLayer'; + + result = []; + expect(() => { tile.querySourceFeatures(result); }).not.toThrow(); + expect(result).toHaveLength(0); + }); + + test('vector tile', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + let result; + + result = []; + tile.querySourceFeatures(result); + expect(result).toHaveLength(0); + + tile.loadVectorData( + createVectorData({rawTileData: createRawTileData()}), + createPainter() + ); + + result = []; + tile.querySourceFeatures(result, {sourceLayer: 'does-not-exist', filter: undefined}); + expect(result).toHaveLength(0); + + result = []; + tile.querySourceFeatures(result, {sourceLayer: 'road', filter: undefined}); + expect(result).toHaveLength(3); + + result = []; + tile.querySourceFeatures(result, {sourceLayer: 'road', filter: ['==', 'class', 'main']}); + expect(result).toHaveLength(1); + result = []; + tile.querySourceFeatures(result, {sourceLayer: 'road', filter: ['!=', 'class', 'main']}); + expect(result).toHaveLength(2); + + }); + + test('loadVectorData unloads existing data before overwriting it', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + tile.state = 'loaded'; + const spy = jest.spyOn(tile, 'unloadVectorData'); + const painter = {}; + + tile.loadVectorData(null, painter); + + expect(spy).toHaveBeenCalledWith(); + }); + + test('loadVectorData preserves the most recent rawTileData', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + tile.state = 'loaded'; + + tile.loadVectorData( + createVectorData({rawTileData: createRawTileData()}), + createPainter() + ); + tile.loadVectorData( + createVectorData(), + createPainter() + ); + + const features = []; + tile.querySourceFeatures(features, {sourceLayer: 'road', filter: undefined}); + expect(features).toHaveLength(3); + + }); + +}); + +describe('Tile#isLessThan', () => { + test('correctly sorts tiles', () => { + const tiles = [ + new OverscaledTileID(9, 0, 9, 146, 195), + new OverscaledTileID(9, 0, 9, 147, 195), + new OverscaledTileID(9, 0, 9, 148, 195), + new OverscaledTileID(9, 0, 9, 149, 195), + new OverscaledTileID(9, 1, 9, 144, 196), + new OverscaledTileID(9, 0, 9, 145, 196), + new OverscaledTileID(9, 0, 9, 146, 196), + new OverscaledTileID(9, 1, 9, 147, 196), + new OverscaledTileID(9, 0, 9, 145, 194), + new OverscaledTileID(9, 0, 9, 149, 196), + new OverscaledTileID(10, 0, 10, 293, 391), + new OverscaledTileID(10, 0, 10, 291, 390), + new OverscaledTileID(10, 1, 10, 293, 390), + new OverscaledTileID(10, 0, 10, 294, 390), + new OverscaledTileID(10, 0, 10, 295, 390), + new OverscaledTileID(10, 0, 10, 291, 391), + ]; + + const sortedTiles = tiles.sort((a, b) => { return a.isLessThan(b) ? -1 : b.isLessThan(a) ? 1 : 0; }); + + expect(sortedTiles).toEqual([ + new OverscaledTileID(9, 0, 9, 145, 194), + new OverscaledTileID(9, 0, 9, 145, 196), + new OverscaledTileID(9, 0, 9, 146, 195), + new OverscaledTileID(9, 0, 9, 146, 196), + new OverscaledTileID(9, 0, 9, 147, 195), + new OverscaledTileID(9, 0, 9, 148, 195), + new OverscaledTileID(9, 0, 9, 149, 195), + new OverscaledTileID(9, 0, 9, 149, 196), + new OverscaledTileID(10, 0, 10, 291, 390), + new OverscaledTileID(10, 0, 10, 291, 391), + new OverscaledTileID(10, 0, 10, 293, 391), + new OverscaledTileID(10, 0, 10, 294, 390), + new OverscaledTileID(10, 0, 10, 295, 390), + new OverscaledTileID(9, 1, 9, 144, 196), + new OverscaledTileID(9, 1, 9, 147, 196), + new OverscaledTileID(10, 1, 10, 293, 390), + ]); + }); +}); + +describe('expiring tiles', () => { + test('regular tiles do not expire', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + tile.state = 'loaded'; + tile.timeAdded = Date.now(); + + expect(tile.getExpiryTimeout()).toBeFalsy(); + + }); + + test('set, get expiry', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + tile.state = 'loaded'; + tile.timeAdded = Date.now(); + + tile.setExpiryData({ + cacheControl: 'max-age=60' + }); + + // times are fuzzy, so we'll give this a little leeway: + let expiryTimeout = tile.getExpiryTimeout(); + expect(expiryTimeout >= 56000 && expiryTimeout <= 60000).toBeTruthy(); + + const date = new Date(); + date.setMinutes(date.getMinutes() + 10); + date.setMilliseconds(0); + + tile.setExpiryData({ + expires: date.toString() + }); + + expiryTimeout = tile.getExpiryTimeout(); + expect(expiryTimeout > 598000 && expiryTimeout < 600000).toBeTruthy(); + + }); + + test('exponential backoff handling', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + tile.state = 'loaded'; + tile.timeAdded = Date.now(); + + tile.setExpiryData({ + cacheControl: 'max-age=10' + }); + + const expiryTimeout = tile.getExpiryTimeout(); + expect(expiryTimeout >= 8000 && expiryTimeout <= 10000).toBeTruthy(); + + const justNow = new Date(); + justNow.setSeconds(justNow.getSeconds() - 1); + + // every time we set a tile's expiration to a date already expired, + // it assumes it comes from a new HTTP response, so this is counted + // as an extra expired tile request + tile.setExpiryData({ + expires: justNow + }); + expect(tile.getExpiryTimeout()).toBe(1000); + + tile.setExpiryData({ + expires: justNow + }); + expect(tile.getExpiryTimeout()).toBe(2000); + tile.setExpiryData({ + expires: justNow + }); + expect(tile.getExpiryTimeout()).toBe(4000); + + tile.setExpiryData({ + expires: justNow + }); + expect(tile.getExpiryTimeout()).toBe(8000); + + }); + +}); + +describe('rtl text detection', () => { + test('Tile#hasRTLText is true when a tile loads a symbol bucket with rtl text', () => { + const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1), undefined); + // Create a stub symbol bucket + const symbolBucket = createSymbolBucket('test', 'Test', 'test', new CollisionBoxArray()); + // symbolBucket has not been populated yet so we force override the value in the stub + symbolBucket.hasRTLText = true; + tile.loadVectorData( + createVectorData({rawTileData: createRawTileData(), buckets: [symbolBucket]}), + createPainter({ + getLayer() { + return symbolBucket.layers[0]; + } + }) + ); + + expect(tile.hasRTLText).toBeTruthy(); + }); + +}); + +function createRawTileData() { + return fs.readFileSync(path.join(__dirname, '../../test/unit/assets/mbsv5-6-18-23.vector.pbf')); +} + +function createVectorData(options?) { + const collisionBoxArray = new CollisionBoxArray(); + return extend({ + collisionBoxArray: deserialize(serialize(collisionBoxArray)), + featureIndex: deserialize(serialize(new FeatureIndex(new OverscaledTileID(1, 0, 1, 1, 1)))), + buckets: [] + }, options); +} + +function createPainter(styleStub = {}) { + return {style: styleStub}; +} diff --git a/web/libraries/maplibre-gl/src/source/tile.ts b/web/libraries/maplibre-gl/src/source/tile.ts new file mode 100644 index 00000000..cc180ec5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile.ts @@ -0,0 +1,479 @@ +import {uniqueId, parseCacheControl} from '../util/util'; +import {deserialize as deserializeBucket} from '../data/bucket'; +import '../data/feature_index'; +import type {FeatureIndex} from '../data/feature_index'; +import {GeoJSONFeature} from '../util/vectortile_to_geojson'; +import {featureFilter} from '@maplibre/maplibre-gl-style-spec'; +import {SymbolBucket} from '../data/bucket/symbol_bucket'; +import {CollisionBoxArray} from '../data/array_types.g'; +import {Texture} from '../render/texture'; +import {browser} from '../util/browser'; +import {toEvaluationFeature} from '../data/evaluation_feature'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {SourceFeatureState} from '../source/source_state'; +import {lazyLoadRTLTextPlugin} from './rtl_text_plugin'; + +const CLOCK_SKEW_RETRY_TIMEOUT = 30000; + +import type {Bucket} from '../data/bucket'; +import type {StyleLayer} from '../style/style_layer'; +import type {WorkerTileResult} from './worker_source'; +import type {Actor} from '../util/actor'; +import type {DEMData} from '../data/dem_data'; +import type {AlphaImage} from '../util/image'; +import type {ImageAtlas} from '../render/image_atlas'; +import type {ImageManager} from '../render/image_manager'; +import type {Context} from '../gl/context'; +import type {OverscaledTileID} from './tile_id'; +import type {Framebuffer} from '../gl/framebuffer'; +import type {Transform} from '../geo/transform'; +import type {LayerFeatureStates} from './source_state'; +import type {Cancelable} from '../types/cancelable'; +import type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type Point from '@mapbox/point-geometry'; +import {mat4} from 'gl-matrix'; +import type {VectorTileLayer} from '@mapbox/vector-tile'; +import {ExpiryData} from '../util/ajax'; + +/** + * The tile's state, can be: + * - `loading` Tile data is in the process of loading. + * - `loaded` Tile data has been loaded. Tile can be rendered. + * - `reloading` Tile data has been loaded and is being updated. Tile can be rendered. + * - `unloaded` Tile data has been deleted. + * - `errored` Tile data was not loaded because of an error. + * - `expired` Tile data was previously loaded, but has expired per its HTTP headers and is in the process of refreshing. + */ +export type TileState = 'loading' | 'loaded' | 'reloading' | 'unloaded' | 'errored' | 'expired'; + +/** + * @internal + * A tile object is the combination of a Coordinate, which defines + * its place, as well as a unique ID and data tracking for its content + */ +export class Tile { + tileID: OverscaledTileID; + uid: number; + uses: number; + tileSize: number; + buckets: {[_: string]: Bucket}; + latestFeatureIndex: FeatureIndex; + latestRawTileData: ArrayBuffer; + imageAtlas: ImageAtlas; + imageAtlasTexture: Texture; + glyphAtlasImage: AlphaImage; + glyphAtlasTexture: Texture; + expirationTime: any; + expiredRequestCount: number; + state: TileState; + timeAdded: number = 0; + fadeEndTime: number = 0; + collisionBoxArray: CollisionBoxArray; + redoWhenDone: boolean; + showCollisionBoxes: boolean; + placementSource: any; + actor: Actor; + vtLayers: {[_: string]: VectorTileLayer}; + + neighboringTiles: any; + dem: DEMData; + demMatrix: mat4; + aborted: boolean; + needsHillshadePrepare: boolean; + needsTerrainPrepare: boolean; + request: Cancelable; + texture: any; + fbo: Framebuffer; + demTexture: Texture; + refreshedUponExpiration: boolean; + reloadCallback: any; + resourceTiming: Array; + queryPadding: number; + + symbolFadeHoldUntil: number; + hasSymbolBuckets: boolean; + hasRTLText: boolean; + dependencies: any; + rtt: Array<{id: number; stamp: number}>; + rttCoords: {[_:string]: string}; + + /** + * @param tileID - the tile ID + * @param size - The tile size + */ + constructor(tileID: OverscaledTileID, size: number) { + this.tileID = tileID; + this.uid = uniqueId(); + this.uses = 0; + this.tileSize = size; + this.buckets = {}; + this.expirationTime = null; + this.queryPadding = 0; + this.hasSymbolBuckets = false; + this.hasRTLText = false; + this.dependencies = {}; + this.rtt = []; + this.rttCoords = {}; + + // Counts the number of times a response was already expired when + // received. We're using this to add a delay when making a new request + // so we don't have to keep retrying immediately in case of a server + // serving expired tiles. + this.expiredRequestCount = 0; + + this.state = 'loading'; + } + + registerFadeDuration(duration: number) { + const fadeEndTime = duration + this.timeAdded; + + if (fadeEndTime < this.fadeEndTime) { + return; + } + + this.fadeEndTime = fadeEndTime; + } + + wasRequested() { + return this.state === 'errored' || this.state === 'loaded' || this.state === 'reloading'; + } + + clearTextures(painter: any) { + if (this.demTexture) painter.saveTileTexture(this.demTexture); + this.demTexture = null; + } + + /** + * Given a data object with a 'buffers' property, load it into + * this tile's elementGroups and buffers properties and set loaded + * to true. If the data is null, like in the case of an empty + * GeoJSON tile, no-op but still set loaded to true. + * @param data - The data from the worker + * @param painter - the painter + * @param justReloaded - `true` to just reload + */ + loadVectorData(data: WorkerTileResult, painter: any, justReloaded?: boolean | null) { + if (this.hasData()) { + this.unloadVectorData(); + } + + this.state = 'loaded'; + + // empty GeoJSON tile + if (!data) { + this.collisionBoxArray = new CollisionBoxArray(); + return; + } + + if (data.featureIndex) { + this.latestFeatureIndex = data.featureIndex; + if (data.rawTileData) { + // Only vector tiles have rawTileData, and they won't update it for + // 'reloadTile' + this.latestRawTileData = data.rawTileData; + this.latestFeatureIndex.rawTileData = data.rawTileData; + } else if (this.latestRawTileData) { + // If rawTileData hasn't updated, hold onto a pointer to the last + // one we received + this.latestFeatureIndex.rawTileData = this.latestRawTileData; + } + } + this.collisionBoxArray = data.collisionBoxArray; + this.buckets = deserializeBucket(data.buckets, painter.style); + + this.hasSymbolBuckets = false; + for (const id in this.buckets) { + const bucket = this.buckets[id]; + if (bucket instanceof SymbolBucket) { + this.hasSymbolBuckets = true; + if (justReloaded) { + bucket.justReloaded = true; + } else { + break; + } + } + } + + this.hasRTLText = false; + if (this.hasSymbolBuckets) { + for (const id in this.buckets) { + const bucket = this.buckets[id]; + if (bucket instanceof SymbolBucket) { + if (bucket.hasRTLText) { + this.hasRTLText = true; + lazyLoadRTLTextPlugin(); + break; + } + } + } + } + + this.queryPadding = 0; + for (const id in this.buckets) { + const bucket = this.buckets[id]; + this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(id).queryRadius(bucket)); + } + + if (data.imageAtlas) { + this.imageAtlas = data.imageAtlas; + } + if (data.glyphAtlasImage) { + this.glyphAtlasImage = data.glyphAtlasImage; + } + } + + /** + * Release any data or WebGL resources referenced by this tile. + */ + unloadVectorData() { + for (const id in this.buckets) { + this.buckets[id].destroy(); + } + this.buckets = {}; + + if (this.imageAtlasTexture) { + this.imageAtlasTexture.destroy(); + } + + if (this.imageAtlas) { + this.imageAtlas = null; + } + + if (this.glyphAtlasTexture) { + this.glyphAtlasTexture.destroy(); + } + + this.latestFeatureIndex = null; + this.state = 'unloaded'; + } + + getBucket(layer: StyleLayer) { + return this.buckets[layer.id]; + } + + upload(context: Context) { + for (const id in this.buckets) { + const bucket = this.buckets[id]; + if (bucket.uploadPending()) { + bucket.upload(context); + } + } + + const gl = context.gl; + if (this.imageAtlas && !this.imageAtlas.uploaded) { + this.imageAtlasTexture = new Texture(context, this.imageAtlas.image, gl.RGBA); + this.imageAtlas.uploaded = true; + } + + if (this.glyphAtlasImage) { + this.glyphAtlasTexture = new Texture(context, this.glyphAtlasImage, gl.ALPHA); + this.glyphAtlasImage = null; + } + } + + prepare(imageManager: ImageManager) { + if (this.imageAtlas) { + this.imageAtlas.patchUpdatedImages(imageManager, this.imageAtlasTexture); + } + } + + // Queries non-symbol features rendered for this tile. + // Symbol features are queried globally + queryRenderedFeatures( + layers: {[_: string]: StyleLayer}, + serializedLayers: {[_: string]: any}, + sourceFeatureState: SourceFeatureState, + queryGeometry: Array, + cameraQueryGeometry: Array, + scale: number, + params: { + filter: FilterSpecification; + layers: Array; + availableImages: Array; + }, + transform: Transform, + maxPitchScaleFactor: number, + pixelPosMatrix: mat4 + ): {[_: string]: Array<{featureIndex: number; feature: GeoJSONFeature}>} { + if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData) + return {}; + + return this.latestFeatureIndex.query({ + queryGeometry, + cameraQueryGeometry, + scale, + tileSize: this.tileSize, + pixelPosMatrix, + transform, + params, + queryPadding: this.queryPadding * maxPitchScaleFactor + }, layers, serializedLayers, sourceFeatureState); + } + + querySourceFeatures(result: Array, params?: { + sourceLayer?: string; + filter?: FilterSpecification; + validate?: boolean; + }) { + const featureIndex = this.latestFeatureIndex; + if (!featureIndex || !featureIndex.rawTileData) return; + + const vtLayers = featureIndex.loadVTLayers(); + + const sourceLayer = params && params.sourceLayer ? params.sourceLayer : ''; + const layer = vtLayers._geojsonTileLayer || vtLayers[sourceLayer]; + + if (!layer) return; + + const filter = featureFilter(params && params.filter); + const {z, x, y} = this.tileID.canonical; + const coord = {z, x, y}; + + for (let i = 0; i < layer.length; i++) { + const feature = layer.feature(i); + if (filter.needGeometry) { + const evaluationFeature = toEvaluationFeature(feature, true); + if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) continue; + } else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) { + continue; + } + const id = featureIndex.getId(feature, sourceLayer); + const geojsonFeature = new GeoJSONFeature(feature, z, x, y, id); + (geojsonFeature as any).tile = coord; + result.push(geojsonFeature); + } + } + + hasData() { + return this.state === 'loaded' || this.state === 'reloading' || this.state === 'expired'; + } + + patternsLoaded() { + return this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length; + } + + setExpiryData(data: ExpiryData) { + const prior = this.expirationTime; + + if (data.cacheControl) { + const parsedCC = parseCacheControl(data.cacheControl); + if (parsedCC['max-age']) this.expirationTime = Date.now() + parsedCC['max-age'] * 1000; + } else if (data.expires) { + this.expirationTime = new Date(data.expires).getTime(); + } + + if (this.expirationTime) { + const now = Date.now(); + let isExpired = false; + + if (this.expirationTime > now) { + isExpired = false; + } else if (!prior) { + isExpired = true; + } else if (this.expirationTime < prior) { + // Expiring date is going backwards: + // fall back to exponential backoff + isExpired = true; + + } else { + const delta = this.expirationTime - prior; + + if (!delta) { + // Server is serving the same expired resource over and over: fall + // back to exponential backoff. + isExpired = true; + + } else { + // Assume that either the client or the server clock is wrong and + // try to interpolate a valid expiration date (from the client POV) + // observing a minimum timeout. + this.expirationTime = now + Math.max(delta, CLOCK_SKEW_RETRY_TIMEOUT); + + } + } + + if (isExpired) { + this.expiredRequestCount++; + this.state = 'expired'; + } else { + this.expiredRequestCount = 0; + } + } + } + + getExpiryTimeout() { + if (this.expirationTime) { + if (this.expiredRequestCount) { + return 1000 * (1 << Math.min(this.expiredRequestCount - 1, 31)); + } else { + // Max value for `setTimeout` implementations is a 32 bit integer; cap this accordingly + return Math.min(this.expirationTime - new Date().getTime(), Math.pow(2, 31) - 1); + } + } + } + + setFeatureState(states: LayerFeatureStates, painter: any) { + if (!this.latestFeatureIndex || + !this.latestFeatureIndex.rawTileData || + Object.keys(states).length === 0) { + return; + } + + const vtLayers = this.latestFeatureIndex.loadVTLayers(); + + for (const id in this.buckets) { + if (!painter.style.hasLayer(id)) continue; + + const bucket = this.buckets[id]; + // Buckets are grouped by common source-layer + const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer'; + const sourceLayer = vtLayers[sourceLayerId]; + const sourceLayerStates = states[sourceLayerId]; + if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) continue; + + bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {}); + const layer = painter && painter.style && painter.style.getLayer(id); + if (layer) { + this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket)); + } + } + } + + holdingForFade(): boolean { + return this.symbolFadeHoldUntil !== undefined; + } + + symbolFadeFinished(): boolean { + return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < browser.now(); + } + + clearFadeHold() { + this.symbolFadeHoldUntil = undefined; + } + + setHoldDuration(duration: number) { + this.symbolFadeHoldUntil = browser.now() + duration; + } + + setDependencies(namespace: string, dependencies: Array) { + const index = {}; + for (const dep of dependencies) { + index[dep] = true; + } + this.dependencies[namespace] = index; + } + + hasDependency(namespaces: Array, keys: Array) { + for (const namespace of namespaces) { + const dependencies = this.dependencies[namespace]; + if (dependencies) { + for (const key of keys) { + if (dependencies[key]) { + return true; + } + } + } + } + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/source/tile_bounds.ts b/web/libraries/maplibre-gl/src/source/tile_bounds.ts new file mode 100644 index 00000000..9a90c803 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile_bounds.ts @@ -0,0 +1,34 @@ +import {LngLatBounds, LngLatBoundsLike} from '../geo/lng_lat_bounds'; +import {mercatorXfromLng, mercatorYfromLat} from '../geo/mercator_coordinate'; + +import type {CanonicalTileID} from './tile_id'; + +export class TileBounds { + bounds: LngLatBounds; + minzoom: number; + maxzoom: number; + + constructor(bounds: [number, number, number, number], minzoom?: number | null, maxzoom?: number | null) { + this.bounds = LngLatBounds.convert(this.validateBounds(bounds)); + this.minzoom = minzoom || 0; + this.maxzoom = maxzoom || 24; + } + + validateBounds(bounds: [number, number, number, number]): LngLatBoundsLike { + // make sure the bounds property contains valid longitude and latitudes + if (!Array.isArray(bounds) || bounds.length !== 4) return [-180, -90, 180, 90]; + return [Math.max(-180, bounds[0]), Math.max(-90, bounds[1]), Math.min(180, bounds[2]), Math.min(90, bounds[3])]; + } + + contains(tileID: CanonicalTileID) { + const worldSize = Math.pow(2, tileID.z); + const level = { + minX: Math.floor(mercatorXfromLng(this.bounds.getWest()) * worldSize), + minY: Math.floor(mercatorYfromLat(this.bounds.getNorth()) * worldSize), + maxX: Math.ceil(mercatorXfromLng(this.bounds.getEast()) * worldSize), + maxY: Math.ceil(mercatorYfromLat(this.bounds.getSouth()) * worldSize) + }; + const hit = tileID.x >= level.minX && tileID.x < level.maxX && tileID.y >= level.minY && tileID.y < level.maxY; + return hit; + } +} diff --git a/web/libraries/maplibre-gl/src/source/tile_cache.test.ts b/web/libraries/maplibre-gl/src/source/tile_cache.test.ts new file mode 100644 index 00000000..ee877085 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile_cache.test.ts @@ -0,0 +1,133 @@ +import {Tile} from './tile'; +import {TileCache} from './tile_cache'; +import {OverscaledTileID} from './tile_id'; + +const idA = new OverscaledTileID(10, 0, 10, 0, 1); +const idB = new OverscaledTileID(10, 0, 10, 0, 2); +const idC = new OverscaledTileID(10, 0, 10, 0, 3); +const idD = new OverscaledTileID(10, 0, 10, 0, 4); +const tileA = {tileID: idA} as Tile; +const tileA2 = {tileID: idA} as Tile; +const tileB = {tileID: idB} as Tile; +const tileC = {tileID: idC} as Tile; +const tileD = {tileID: idD} as Tile; + +function keysExpected(cache, ids) { + expect(cache.order).toEqual(ids.map((id) => id.key)); +} +describe('TileCache', () => { + test('complex flow', () => { + const cache = new TileCache(10, (removed) => { + expect(removed).toBe('dc'); + }); + expect(cache.getAndRemove(idC)).toBeNull(); + expect(cache.add(idA, tileA)).toBe(cache); + keysExpected(cache, [idA]); + expect(cache.has(idA)).toBe(true); + expect(cache.getAndRemove(idA)).toBe(tileA); + expect(cache.getAndRemove(idA)).toBeNull(); + expect(cache.has(idA)).toBe(false); + keysExpected(cache, []); + }); + + test('get without removing', done => { + const cache = new TileCache(10, () => { + done('test "get without removing" failed'); + }); + expect(cache.add(idA, tileA)).toBe(cache); + expect(cache.get(idA)).toBe(tileA); + keysExpected(cache, [idA]); + expect(cache.get(idA)).toBe(tileA); + done(); + }); + + test('duplicate add', done => { + const cache = new TileCache(10, () => { + done('test "duplicate add" failed'); + }); + + cache.add(idA, tileA); + cache.add(idA, tileA2); + + keysExpected(cache, [idA, idA]); + expect(cache.has(idA)).toBeTruthy(); + expect(cache.getAndRemove(idA)).toBe(tileA); + expect(cache.has(idA)).toBeTruthy(); + expect(cache.getAndRemove(idA)).toBe(tileA2); + done(); + }); + + test('expiry', () => { + const cache = new TileCache(10, (removed) => { + expect(cache.has(idB)).toBeTruthy(); + expect(removed).toBe(tileA2); + }); + + cache.add(idB, tileB, 0); + cache.getAndRemove(idB); + // removing clears the expiry timeout + cache.add(idB, null); + + cache.add(idA, tileA); + cache.add(idA, tileA2, 0); // expires immediately and `onRemove` is called. + }); + + test('remove', () => { + const cache = new TileCache(10, () => {}); + + cache.add(idA, tileA); + cache.add(idB, tileB); + cache.add(idC, tileC); + + keysExpected(cache, [idA, idB, idC]); + expect(cache.has(idB)).toBeTruthy(); + + cache.remove(idB); + + keysExpected(cache, [idA, idC]); + expect(cache.has(idB)).toBeFalsy(); + + expect(cache.remove(idB)).toBeTruthy(); + + }); + + test('overflow', () => { + const cache = new TileCache(1, (removed) => { + expect(removed).toBe(tileA); + }); + cache.add(idA, tileA); + cache.add(idB, tileB); + + expect(cache.has(idB)).toBeTruthy(); + expect(cache.has(idA)).toBeFalsy(); + }); + + test('.reset', () => { + let called; + const cache = new TileCache(10, (removed) => { + expect(removed).toBe(tileA); + called = true; + }); + cache.add(idA, tileA); + expect(cache.reset()).toBe(cache); + expect(cache.has(idA)).toBe(false); + expect(called).toBeTruthy(); + }); + + test('.setMaxSize', () => { + let numRemoved = 0; + const cache = new TileCache(10, () => { + numRemoved++; + }); + cache.add(idA, tileA); + cache.add(idB, tileB); + cache.add(idC, tileC); + expect(numRemoved).toBe(0); + cache.setMaxSize(15); + expect(numRemoved).toBe(0); + cache.setMaxSize(1); + expect(numRemoved).toBe(2); + cache.add(idD, tileD); + expect(numRemoved).toBe(3); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/tile_cache.ts b/web/libraries/maplibre-gl/src/source/tile_cache.ts new file mode 100644 index 00000000..b05d9ed2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile_cache.ts @@ -0,0 +1,208 @@ +import {OverscaledTileID} from './tile_id'; +import type {Tile} from './tile'; + +/** + * @internal + * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms) + * with hash lookup made possible by keeping a list of keys in parallel to + * an array of dictionary of values + */ +export class TileCache { + max: number; + data: { + [key: string]: Array<{ + value: Tile; + timeout: ReturnType; + }>; + }; + order: Array; + onRemove: (element: Tile) => void; + /** + * @param max - number of permitted values + * @param onRemove - callback called with items when they expire + */ + constructor(max: number, onRemove: (element: Tile) => void) { + this.max = max; + this.onRemove = onRemove; + this.reset(); + } + + /** + * Clear the cache + * + * @returns this cache + */ + reset() { + for (const key in this.data) { + for (const removedData of this.data[key]) { + if (removedData.timeout) clearTimeout(removedData.timeout); + this.onRemove(removedData.value); + } + } + + this.data = {}; + this.order = []; + + return this; + } + + /** + * Add a key, value combination to the cache, trimming its size if this pushes + * it over max length. + * + * @param tileID - lookup key for the item + * @param data - tile data + * + * @returns this cache + */ + add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void) { + const key = tileID.wrapped().key; + if (this.data[key] === undefined) { + this.data[key] = []; + } + + const dataWrapper = { + value: data, + timeout: undefined + }; + + if (expiryTimeout !== undefined) { + dataWrapper.timeout = setTimeout(() => { + this.remove(tileID, dataWrapper); + }, expiryTimeout as number); + } + + this.data[key].push(dataWrapper); + this.order.push(key); + + if (this.order.length > this.max) { + const removedData = this._getAndRemoveByKey(this.order[0]); + if (removedData) this.onRemove(removedData); + } + + return this; + } + + /** + * Determine whether the value attached to `key` is present + * + * @param tileID - the key to be looked-up + * @returns whether the cache has this value + */ + has(tileID: OverscaledTileID): boolean { + return tileID.wrapped().key in this.data; + } + + /** + * Get the value attached to a specific key and remove data from cache. + * If the key is not found, returns `null` + * + * @param tileID - the key to look up + * @returns the tile data, or null if it isn't found + */ + getAndRemove(tileID: OverscaledTileID): Tile { + if (!this.has(tileID)) { return null; } + return this._getAndRemoveByKey(tileID.wrapped().key); + } + + /* + * Get and remove the value with the specified key. + */ + _getAndRemoveByKey(key: string): Tile { + const data = this.data[key].shift(); + if (data.timeout) clearTimeout(data.timeout); + + if (this.data[key].length === 0) { + delete this.data[key]; + } + this.order.splice(this.order.indexOf(key), 1); + + return data.value; + } + + /* + * Get the value with the specified (wrapped tile) key. + */ + getByKey(key: string): Tile { + const data = this.data[key]; + return data ? data[0].value : null; + } + + /** + * Get the value attached to a specific key without removing data + * from the cache. If the key is not found, returns `null` + * + * @param tileID - the key to look up + * @returns the tile data, or null if it isn't found + */ + get(tileID: OverscaledTileID): Tile { + if (!this.has(tileID)) { return null; } + + const data = this.data[tileID.wrapped().key][0]; + return data.value; + } + + /** + * Remove a key/value combination from the cache. + * + * @param tileID - the key for the pair to delete + * @param value - If a value is provided, remove that exact version of the value. + * @returns this cache + */ + remove(tileID: OverscaledTileID, value?: { + value: Tile; + timeout: ReturnType; + }) { + if (!this.has(tileID)) { return this; } + const key = tileID.wrapped().key; + + const dataIndex = value === undefined ? 0 : this.data[key].indexOf(value); + const data = this.data[key][dataIndex]; + this.data[key].splice(dataIndex, 1); + if (data.timeout) clearTimeout(data.timeout); + if (this.data[key].length === 0) { + delete this.data[key]; + } + this.onRemove(data.value); + this.order.splice(this.order.indexOf(key), 1); + + return this; + } + + /** + * Change the max size of the cache. + * + * @param max - the max size of the cache + * @returns this cache + */ + setMaxSize(max: number): TileCache { + this.max = max; + + while (this.order.length > this.max) { + const removedData = this._getAndRemoveByKey(this.order[0]); + if (removedData) this.onRemove(removedData); + } + + return this; + } + + /** + * Remove entries that do not pass a filter function. Used for removing + * stale tiles from the cache. + * + * @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out. + */ + filter(filterFn: (tile: Tile) => boolean) { + const removed = []; + for (const key in this.data) { + for (const entry of this.data[key]) { + if (!filterFn(entry.value)) { + removed.push(entry); + } + } + } + for (const r of removed) { + this.remove(r.value.tileID, r); + } + } +} diff --git a/web/libraries/maplibre-gl/src/source/tile_id.test.ts b/web/libraries/maplibre-gl/src/source/tile_id.test.ts new file mode 100644 index 00000000..1f4fdec0 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile_id.test.ts @@ -0,0 +1,111 @@ +import {CanonicalTileID, OverscaledTileID} from '../source/tile_id'; + +describe('CanonicalTileID', () => { + test('#constructor', () => { + expect(() => { + /*eslint no-new: 0*/ + new CanonicalTileID(-1, 0, 0); + }).toThrow(); + expect(() => { + /*eslint no-new: 0*/ + new CanonicalTileID(26, 0, 0); + }).toThrow(); + expect(() => { + /*eslint no-new: 0*/ + new CanonicalTileID(2, 4, 0); + }).toThrow(); + expect(() => { + /*eslint no-new: 0*/ + new CanonicalTileID(2, 0, 4); + }).toThrow(); + }); + + test('.key', () => { + expect(new CanonicalTileID(0, 0, 0).key).toBe('000'); + expect(new CanonicalTileID(1, 0, 0).key).toBe('011'); + expect(new CanonicalTileID(1, 1, 0).key).toBe('111'); + expect(new CanonicalTileID(1, 1, 1).key).toBe('311'); + }); + + test('.equals', () => { + expect(new CanonicalTileID(3, 2, 1).equals(new CanonicalTileID(3, 2, 1))).toBeTruthy(); + expect(new CanonicalTileID(9, 2, 3).equals(new CanonicalTileID(3, 2, 1))).toBeFalsy(); + }); + + test('.url replaces {z}/{x}/{y}', () => { + expect(new CanonicalTileID(2, 1, 0).url(['{z}/{x}/{y}.json'], 1)).toBe('2/1/0.json'); + }); + + test('.url replaces {quadkey}', () => { + expect(new CanonicalTileID(1, 0, 0).url(['quadkey={quadkey}'], 1)).toBe('quadkey=0'); + expect(new CanonicalTileID(2, 0, 0).url(['quadkey={quadkey}'], 1)).toBe('quadkey=00'); + expect(new CanonicalTileID(2, 1, 1).url(['quadkey={quadkey}'], 1)).toBe('quadkey=03'); + expect(new CanonicalTileID(17, 22914, 52870).url(['quadkey={quadkey}'], 1)).toBe('quadkey=02301322130000230'); + + // Test case confirmed by quadkeytools package + expect(new CanonicalTileID(6, 29, 3).url(['quadkey={quadkey}'], 1)).toBe('quadkey=011123'); + + }); + + test('.url replaces {bbox-epsg-3857}', () => { + expect(new CanonicalTileID(1, 0, 0).url(['bbox={bbox-epsg-3857}'], 1)).toBe('bbox=-20037508.342789244,0,0,20037508.342789244'); + }); + + test('.url replaces {ratio}', () => { + expect(new CanonicalTileID(1, 0, 0).url(['r={ratio}'], 2)).toBe('r=@2x'); + expect(new CanonicalTileID(1, 0, 0).url(['r={ratio}'], 1)).toBe('r='); + }); + + //Tests that multiple values of the same placeholder are replaced. + test('.url replaces {z}/{x}/{y}/{z}/{x}/{y}', () => { + expect(new CanonicalTileID(2, 1, 0).url(['{z}/{x}/{y}/{z}/{x}/{y}.json'], 1)).toBe('2/1/0/2/1/0.json'); + }); + +}); + +describe('OverscaledTileID', () => { + test('#constructor', () => { + expect(new OverscaledTileID(0, 0, 0, 0, 0) instanceof OverscaledTileID).toBeTruthy(); + expect(() => { + /*eslint no-new: 0*/ + new OverscaledTileID(7, 0, 8, 0, 0); + }).toThrow(); + }); + + test('.key', () => { + expect(new OverscaledTileID(0, 0, 0, 0, 0).key).toBe('000'); + expect(new OverscaledTileID(1, 0, 1, 0, 0).key).toBe('011'); + expect(new OverscaledTileID(1, 0, 1, 1, 0).key).toBe('111'); + expect(new OverscaledTileID(1, 0, 1, 1, 1).key).toBe('311'); + expect(new OverscaledTileID(1, -1, 1, 1, 1).key).toBe('711'); + }); + + test('.toString', () => { + expect(new OverscaledTileID(1, 0, 1, 1, 1).toString()).toBe('1/1/1'); + }); + + test('.children', () => { + expect(new OverscaledTileID(0, 0, 0, 0, 0).children(25)).toEqual([ + new OverscaledTileID(1, 0, 1, 0, 0), + new OverscaledTileID(1, 0, 1, 1, 0), + new OverscaledTileID(1, 0, 1, 0, 1), + new OverscaledTileID(1, 0, 1, 1, 1)]); + expect(new OverscaledTileID(0, 0, 0, 0, 0).children(0)).toEqual([new OverscaledTileID(1, 0, 0, 0, 0)]); + }); + + test('.scaledTo returns a parent', () => { + expect(new OverscaledTileID(2, 0, 2, 0, 0).scaledTo(0)).toEqual(new OverscaledTileID(0, 0, 0, 0, 0)); + expect(new OverscaledTileID(1, 0, 1, 0, 0).scaledTo(0)).toEqual(new OverscaledTileID(0, 0, 0, 0, 0)); + expect(new OverscaledTileID(1, 0, 0, 0, 0).scaledTo(0)).toEqual(new OverscaledTileID(0, 0, 0, 0, 0)); + }); + + test('.isChildOf', () => { + expect( + new OverscaledTileID(2, 0, 2, 0, 0).isChildOf(new OverscaledTileID(0, 0, 0, 0, 0)) + ).toBeTruthy(); + expect( + new OverscaledTileID(2, 0, 2, 0, 0).isChildOf(new OverscaledTileID(0, 1, 0, 0, 0)) + ).toBeFalsy(); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/source/tile_id.ts b/web/libraries/maplibre-gl/src/source/tile_id.ts new file mode 100644 index 00000000..62c4fa99 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/tile_id.ts @@ -0,0 +1,219 @@ +import {getTileBBox} from '@mapbox/whoots-js'; +import {EXTENT} from '../data/extent'; +import Point from '@mapbox/point-geometry'; +import {MercatorCoordinate} from '../geo/mercator_coordinate'; +import {register} from '../util/web_worker_transfer'; +import {mat4} from 'gl-matrix'; +import {ICanonicalTileID, IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec'; + +/** + * A canonical way to define a tile ID + */ +export class CanonicalTileID implements ICanonicalTileID { + z: number; + x: number; + y: number; + key: string; + + constructor(z: number, x: number, y: number) { + + if (z < 0 || z > 25 || y < 0 || y >= Math.pow(2, z) || x < 0 || x >= Math.pow(2, z)) { + throw new Error(`x=${x}, y=${y}, z=${z} outside of bounds. 0<=x<${Math.pow(2, z)}, 0<=y<${Math.pow(2, z)} 0<=z<=25 `); + } + + this.z = z; + this.x = x; + this.y = y; + this.key = calculateKey(0, z, z, x, y); + } + + equals(id: ICanonicalTileID) { + return this.z === id.z && this.x === id.x && this.y === id.y; + } + + // given a list of urls, choose a url template and return a tile URL + url(urls: Array, pixelRatio: number, scheme?: string | null) { + const bbox = getTileBBox(this.x, this.y, this.z); + const quadkey = getQuadkey(this.z, this.x, this.y); + + return urls[(this.x + this.y) % urls.length] + .replace(/{prefix}/g, (this.x % 16).toString(16) + (this.y % 16).toString(16)) + .replace(/{z}/g, String(this.z)) + .replace(/{x}/g, String(this.x)) + .replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y)) + .replace(/{ratio}/g, pixelRatio > 1 ? '@2x' : '') + .replace(/{quadkey}/g, quadkey) + .replace(/{bbox-epsg-3857}/g, bbox); + } + + isChildOf(parent: ICanonicalTileID) { + const dz = this.z - parent.z; + return dz > 0 && parent.x === (this.x >> dz) && parent.y === (this.y >> dz); + } + + getTilePoint(coord: IMercatorCoordinate) { + const tilesAtZoom = Math.pow(2, this.z); + return new Point( + (coord.x * tilesAtZoom - this.x) * EXTENT, + (coord.y * tilesAtZoom - this.y) * EXTENT); + } + + toString() { + return `${this.z}/${this.x}/${this.y}`; + } +} + +/** + * @internal + * An unwrapped tile identifier + */ +export class UnwrappedTileID { + wrap: number; + canonical: CanonicalTileID; + key: string; + + constructor(wrap: number, canonical: CanonicalTileID) { + this.wrap = wrap; + this.canonical = canonical; + this.key = calculateKey(wrap, canonical.z, canonical.z, canonical.x, canonical.y); + } +} + +/** + * An overscaled tile identifier + */ +export class OverscaledTileID { + overscaledZ: number; + wrap: number; + canonical: CanonicalTileID; + key: string; + posMatrix: mat4; + + constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number) { + if (overscaledZ < z) throw new Error(`overscaledZ should be >= z; overscaledZ = ${overscaledZ}; z = ${z}`); + this.overscaledZ = overscaledZ; + this.wrap = wrap; + this.canonical = new CanonicalTileID(z, +x, +y); + this.key = calculateKey(wrap, overscaledZ, z, x, y); + } + + clone() { + return new OverscaledTileID(this.overscaledZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y); + } + + equals(id: OverscaledTileID) { + return this.overscaledZ === id.overscaledZ && this.wrap === id.wrap && this.canonical.equals(id.canonical); + } + + scaledTo(targetZ: number) { + if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`); + const zDifference = this.canonical.z - targetZ; + if (targetZ > this.canonical.z) { + return new OverscaledTileID(targetZ, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y); + } else { + return new OverscaledTileID(targetZ, this.wrap, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference); + } + } + + /* + * calculateScaledKey is an optimization: + * when withWrap == true, implements the same as this.scaledTo(z).key, + * when withWrap == false, implements the same as this.scaledTo(z).wrapped().key. + */ + calculateScaledKey(targetZ: number, withWrap: boolean): string { + if (targetZ > this.overscaledZ) throw new Error(`targetZ > this.overscaledZ; targetZ = ${targetZ}; overscaledZ = ${this.overscaledZ}`); + const zDifference = this.canonical.z - targetZ; + if (targetZ > this.canonical.z) { + return calculateKey(this.wrap * +withWrap, targetZ, this.canonical.z, this.canonical.x, this.canonical.y); + } else { + return calculateKey(this.wrap * +withWrap, targetZ, targetZ, this.canonical.x >> zDifference, this.canonical.y >> zDifference); + } + } + + isChildOf(parent: OverscaledTileID) { + if (parent.wrap !== this.wrap) { + // We can't be a child if we're in a different world copy + return false; + } + const zDifference = this.canonical.z - parent.canonical.z; + // We're first testing for z == 0, to avoid a 32 bit shift, which is undefined. + return parent.overscaledZ === 0 || ( + parent.overscaledZ < this.overscaledZ && + parent.canonical.x === (this.canonical.x >> zDifference) && + parent.canonical.y === (this.canonical.y >> zDifference)); + } + + children(sourceMaxZoom: number) { + if (this.overscaledZ >= sourceMaxZoom) { + // return a single tile coord representing a an overscaled tile + return [new OverscaledTileID(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)]; + } + + const z = this.canonical.z + 1; + const x = this.canonical.x * 2; + const y = this.canonical.y * 2; + return [ + new OverscaledTileID(z, this.wrap, z, x, y), + new OverscaledTileID(z, this.wrap, z, x + 1, y), + new OverscaledTileID(z, this.wrap, z, x, y + 1), + new OverscaledTileID(z, this.wrap, z, x + 1, y + 1) + ]; + } + + isLessThan(rhs: OverscaledTileID) { + if (this.wrap < rhs.wrap) return true; + if (this.wrap > rhs.wrap) return false; + + if (this.overscaledZ < rhs.overscaledZ) return true; + if (this.overscaledZ > rhs.overscaledZ) return false; + + if (this.canonical.x < rhs.canonical.x) return true; + if (this.canonical.x > rhs.canonical.x) return false; + + if (this.canonical.y < rhs.canonical.y) return true; + return false; + } + + wrapped() { + return new OverscaledTileID(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y); + } + + unwrapTo(wrap: number) { + return new OverscaledTileID(this.overscaledZ, wrap, this.canonical.z, this.canonical.x, this.canonical.y); + } + + overscaleFactor() { + return Math.pow(2, this.overscaledZ - this.canonical.z); + } + + toUnwrapped() { + return new UnwrappedTileID(this.wrap, this.canonical); + } + + toString() { + return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`; + } + + getTilePoint(coord: MercatorCoordinate) { + return this.canonical.getTilePoint(new MercatorCoordinate(coord.x - this.wrap, coord.y)); + } +} + +function calculateKey(wrap: number, overscaledZ: number, z: number, x: number, y: number): string { + wrap *= 2; + if (wrap < 0) wrap = wrap * -1 - 1; + const dim = 1 << z; + return (dim * dim * wrap + dim * y + x).toString(36) + z.toString(36) + overscaledZ.toString(36); +} + +function getQuadkey(z, x, y) { + let quadkey = '', mask; + for (let i = z; i > 0; i--) { + mask = 1 << (i - 1); + quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0)); + } + return quadkey; +} + +register('CanonicalTileID', CanonicalTileID); +register('OverscaledTileID', OverscaledTileID, {omit: ['posMatrix']}); diff --git a/web/libraries/maplibre-gl/src/source/vector_tile_source.test.ts b/web/libraries/maplibre-gl/src/source/vector_tile_source.test.ts new file mode 100644 index 00000000..d2ff756f --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/vector_tile_source.test.ts @@ -0,0 +1,355 @@ +import {fakeServer, type FakeServer} from 'nise'; +import {Source} from './source'; +import {VectorTileSource} from './vector_tile_source'; +import {Tile} from './tile'; +import {OverscaledTileID} from './tile_id'; +import {Evented} from '../util/evented'; +import {RequestManager} from '../util/request_manager'; +import fixturesSource from '../../test/unit/assets/source.json' assert {type: 'json'}; +import {getMockDispatcher, getWrapDispatcher} from '../util/test/util'; +import {Map} from '../ui/map'; + +function createSource(options, transformCallback?, clearTiles = () => {}) { + const source = new VectorTileSource('id', options, getMockDispatcher(), options.eventedParent); + source.onAdd({ + transform: {showCollisionBoxes: false}, + _getMapId: () => 1, + _requestManager: new RequestManager(transformCallback), + style: {sourceCaches: {id: {clearTiles}}}, + getPixelRatio() { return 1; } + } as any as Map); + + source.on('error', (e) => { + throw e.error; + }); + + return source; +} + +describe('VectorTileSource', () => { + let server: FakeServer; + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + }); + + afterEach(() => { + server.restore(); + }); + + test('can be constructed from TileJSON', done => { + const source = createSource({ + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.tiles).toEqual(['http://example.com/{z}/{x}/{y}.png']); + expect(source.minzoom).toBe(1); + expect(source.maxzoom).toBe(10); + expect((source as Source).attribution).toBe('MapLibre'); + done(); + } + }); + }); + + test('can be constructed from a TileJSON URL', done => { + server.respondWith('/source.json', JSON.stringify(fixturesSource)); + + const source = createSource({url: '/source.json'}); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.tiles).toEqual(['http://example.com/{z}/{x}/{y}.png']); + expect(source.minzoom).toBe(1); + expect(source.maxzoom).toBe(10); + expect((source as Source).attribution).toBe('MapLibre'); + done(); + } + }); + + server.respond(); + }); + + test('transforms the request for TileJSON URL', () => { + server.respondWith('/source.json', JSON.stringify(fixturesSource)); + const transformSpy = jest.fn().mockImplementation((url) => { + return {url}; + }); + + createSource({url: '/source.json'}, transformSpy); + server.respond(); + expect(transformSpy).toHaveBeenCalledWith('/source.json', 'Source'); + }); + + test('fires event with metadata property', done => { + server.respondWith('/source.json', JSON.stringify(fixturesSource)); + const source = createSource({url: '/source.json'}); + source.on('data', (e) => { + if (e.sourceDataType === 'content') done(); + }); + server.respond(); + }); + + test('fires "dataloading" event', done => { + server.respondWith('/source.json', JSON.stringify(fixturesSource)); + const evented = new Evented(); + let dataloadingFired = false; + evented.on('dataloading', () => { + dataloadingFired = true; + }); + const source = createSource({url: '/source.json', eventedParent: evented}); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + if (!dataloadingFired) done('test failed: dataloading not fired'); + done(); + } + }); + server.respond(); + }); + + test('serialize URL', () => { + const source = createSource({ + url: 'http://localhost:2900/source.json' + }); + expect(source.serialize()).toEqual({ + type: 'vector', + url: 'http://localhost:2900/source.json' + }); + }); + + test('serialize TileJSON', () => { + const source = createSource({ + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + }); + expect(source.serialize()).toEqual({ + type: 'vector', + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + }); + }); + + function testScheme(scheme, expectedURL) { + test(`scheme "${scheme}"`, done => { + const source = createSource({ + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + scheme + }); + + source.dispatcher = getWrapDispatcher()({ + send(type, params) { + expect(type).toBe('loadTile'); + expect(expectedURL).toBe(params.request.url); + done(); + } + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') source.loadTile({ + tileID: new OverscaledTileID(10, 0, 10, 5, 5) + } as any as Tile, () => {}); + }); + }); + } + + testScheme('xyz', 'http://example.com/10/5/5.png'); + testScheme('tms', 'http://example.com/10/5/1018.png'); + + test('transforms tile urls before requesting', done => { + server.respondWith('/source.json', JSON.stringify(fixturesSource)); + + const source = createSource({url: '/source.json'}); + const transformSpy = jest.spyOn(source.map._requestManager, 'transformRequest'); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading', + loadVectorData () {}, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + expect(transformSpy).toHaveBeenCalledTimes(1); + expect(transformSpy).toHaveBeenCalledWith('http://example.com/10/5/5.png', 'Tile'); + done(); + } + }); + + server.respond(); + }); + + test('reloads a loading tile properly', done => { + const source = createSource({ + tiles: ['http://example.com/{z}/{x}/{y}.png'] + }); + const events = []; + source.dispatcher = getWrapDispatcher()({ + send(type, params, cb) { + events.push(type); + if (cb) setTimeout(cb, 0); + return 1; + } + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading', + loadVectorData () { + this.state = 'loaded'; + events.push('tileLoaded'); + }, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + expect(tile.state).toBe('loading'); + source.loadTile(tile, () => { + expect(events).toEqual( + ['loadTile', 'tileLoaded', 'reloadTile', 'tileLoaded'] + ); + done(); + }); + } + }); + }); + + test('respects TileJSON.bounds', done => { + const source = createSource({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + }); + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 96, 132))).toBeFalsy(); + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 95, 132))).toBeTruthy(); + done(); + } + }); + }); + + test('does not error on invalid bounds', done => { + const source = createSource({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, 91] + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.tileBounds.bounds).toEqual({_sw: {lng: -47, lat: -7}, _ne: {lng: -45, lat: 90}}); + done(); + } + }); + }); + + test('respects TileJSON.bounds when loaded from TileJSON', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 0, + maxzoom: 22, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'], + bounds: [-47, -7, -45, -5] + })); + const source = createSource({url: '/source.json'}); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 96, 132))).toBeFalsy(); + expect(source.hasTile(new OverscaledTileID(8, 0, 8, 95, 132))).toBeTruthy(); + done(); + } + }); + server.respond(); + }); + + test('respects collectResourceTiming parameter on source', done => { + const source = createSource({ + tiles: ['http://example.com/{z}/{x}/{y}.png'], + collectResourceTiming: true + }); + source.dispatcher = getWrapDispatcher()({ + send(type, params, cb) { + expect(params.request.collectResourceTiming).toBeTruthy(); + setTimeout(cb, 0); + done(); + + // do nothing for cache size check dispatch + source.dispatcher = getMockDispatcher(); + + return 1; + } + }); + + source.on('data', (e) => { + if (e.sourceDataType === 'metadata') { + const tile = { + tileID: new OverscaledTileID(10, 0, 10, 5, 5), + state: 'loading', + loadVectorData () {}, + setExpiryData() {} + } as any as Tile; + source.loadTile(tile, () => {}); + } + }); + }); + + test('cancels TileJSON request if removed', () => { + const source = createSource({url: '/source.json'}); + source.onRemove(); + expect((server as any).lastRequest.aborted).toBe(true); + }); + + test('supports url property updates', () => { + const source = createSource({ + url: 'http://localhost:2900/source.json' + }); + source.setUrl('http://localhost:2900/source2.json'); + expect(source.serialize()).toEqual({ + type: 'vector', + url: 'http://localhost:2900/source2.json' + }); + }); + + test('supports tiles property updates', () => { + const source = createSource({ + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + }); + source.setTiles(['http://example2.com/{z}/{x}/{y}.png']); + expect(source.serialize()).toEqual({ + type: 'vector', + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example2.com/{z}/{x}/{y}.png'] + }); + }); + + test('setTiles only clears the cache once the TileJSON has reloaded', async () => { + const clearTiles = jest.fn(); + const source = createSource({tiles: ['http://example.com/{z}/{x}/{y}.pbf']}, undefined, clearTiles); + source.setTiles(['http://example2.com/{z}/{x}/{y}.pbf']); + expect(clearTiles.mock.calls).toHaveLength(0); + await source.once('data'); + expect(clearTiles.mock.calls).toHaveLength(1); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/vector_tile_source.ts b/web/libraries/maplibre-gl/src/source/vector_tile_source.ts new file mode 100644 index 00000000..8cdb19c3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/vector_tile_source.ts @@ -0,0 +1,260 @@ +import {Event, ErrorEvent, Evented} from '../util/evented'; + +import {extend, pick} from '../util/util'; +import {loadTileJson} from './load_tilejson'; +import {TileBounds} from './tile_bounds'; +import {ResourceType} from '../util/request_manager'; + +import type {Source} from './source'; +import type {OverscaledTileID} from './tile_id'; +import type {Map} from '../ui/map'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Tile} from './tile'; +import type {Callback} from '../types/callback'; +import type {Cancelable} from '../types/cancelable'; +import type {VectorSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type VectorTileSourceOptions = VectorSourceSpecification & { + collectResourceTiming?: boolean; +} + +/** + * A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/). + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }); + * ``` + * + * @example + * ```ts + * map.addSource('some id', { + * type: 'vector', + * tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'], + * minzoom: 6, + * maxzoom: 14 + * }); + * ``` + * + * @example + * ```ts + * map.getSource('some id').setUrl("https://demotiles.maplibre.org/tiles/tiles.json"); + * ``` + * + * @example + * ```ts + * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']); + * ``` + * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/) + */ +export class VectorTileSource extends Evented implements Source { + type: 'vector'; + id: string; + minzoom: number; + maxzoom: number; + url: string; + scheme: string; + tileSize: number; + promoteId: PromoteIdSpecification; + + _options: VectorSourceSpecification; + _collectResourceTiming: boolean; + dispatcher: Dispatcher; + map: Map; + bounds: [number, number, number, number]; + tiles: Array; + tileBounds: TileBounds; + reparseOverscaled: boolean; + isTileClipped: boolean; + _tileJSONRequest: Cancelable; + _loaded: boolean; + + constructor(id: string, options: VectorTileSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) { + super(); + this.id = id; + this.dispatcher = dispatcher; + + this.type = 'vector'; + this.minzoom = 0; + this.maxzoom = 22; + this.scheme = 'xyz'; + this.tileSize = 512; + this.reparseOverscaled = true; + this.isTileClipped = true; + this._loaded = false; + + extend(this, pick(options, ['url', 'scheme', 'tileSize', 'promoteId'])); + this._options = extend({type: 'vector'}, options); + + this._collectResourceTiming = options.collectResourceTiming; + + if (this.tileSize !== 512) { + throw new Error('vector tile sources must have a tileSize of 512'); + } + + this.setEventedParent(eventedParent); + } + + load = () => { + this._loaded = false; + this.fire(new Event('dataloading', {dataType: 'source'})); + this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => { + this._tileJSONRequest = null; + this._loaded = true; + this.map.style.sourceCaches[this.id].clearTiles(); + if (err) { + this.fire(new ErrorEvent(err)); + } else if (tileJSON) { + extend(this, tileJSON); + if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom); + + // `content` is included here to prevent a race condition where `Style#_updateSources` is called + // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives + // ref: https://github.com/mapbox/mapbox-gl-js/pull/4347#discussion_r104418088 + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'})); + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'})); + } + }); + }; + + loaded(): boolean { + return this._loaded; + } + + hasTile(tileID: OverscaledTileID) { + return !this.tileBounds || this.tileBounds.contains(tileID.canonical); + } + + onAdd(map: Map) { + this.map = map; + this.load(); + } + + setSourceProperty(callback: Function) { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + } + + callback(); + + this.load(); + } + + /** + * Sets the source `tiles` property and re-renders the map. + * + * @param tiles - An array of one or more tile source URLs, as in the TileJSON spec. + * @returns `this` + */ + setTiles(tiles: Array): this { + this.setSourceProperty(() => { + this._options.tiles = tiles; + }); + + return this; + } + + /** + * Sets the source `url` property and re-renders the map. + * + * @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`. + * @returns `this` + */ + setUrl(url: string): this { + this.setSourceProperty(() => { + this.url = url; + this._options.url = url; + }); + + return this; + } + + onRemove() { + if (this._tileJSONRequest) { + this._tileJSONRequest.cancel(); + this._tileJSONRequest = null; + } + } + + serialize = (): VectorSourceSpecification => { + return extend({}, this._options); + }; + + loadTile(tile: Tile, callback: Callback) { + const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme); + const params = { + request: this.map._requestManager.transformRequest(url, ResourceType.Tile), + uid: tile.uid, + tileID: tile.tileID, + zoom: tile.tileID.overscaledZ, + tileSize: this.tileSize * tile.tileID.overscaleFactor(), + type: this.type, + source: this.id, + pixelRatio: this.map.getPixelRatio(), + showCollisionBoxes: this.map.showCollisionBoxes, + promoteId: this.promoteId + }; + params.request.collectResourceTiming = this._collectResourceTiming; + + if (!tile.actor || tile.state === 'expired') { + tile.actor = this.dispatcher.getActor(); + tile.request = tile.actor.send('loadTile', params, done.bind(this)); + } else if (tile.state === 'loading') { + // schedule tile reloading after it has been loaded + tile.reloadCallback = callback; + } else { + tile.request = tile.actor.send('reloadTile', params, done.bind(this)); + } + + function done(err, data) { + delete tile.request; + + if (tile.aborted) + return callback(null); + + if (err && err.status !== 404) { + return callback(err); + } + + if (data && data.resourceTiming) + tile.resourceTiming = data.resourceTiming; + + if (this.map._refreshExpiredTiles && data) tile.setExpiryData(data); + tile.loadVectorData(data, this.map.painter); + + callback(null); + + if (tile.reloadCallback) { + this.loadTile(tile, tile.reloadCallback); + tile.reloadCallback = null; + } + } + } + + abortTile(tile: Tile) { + if (tile.request) { + tile.request.cancel(); + delete tile.request; + } + if (tile.actor) { + tile.actor.send('abortTile', {uid: tile.uid, type: this.type, source: this.id}, undefined); + } + } + + unloadTile(tile: Tile) { + tile.unloadVectorData(); + if (tile.actor) { + tile.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}, undefined); + } + } + + hasTransition() { + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/source/vector_tile_worker_source.test.ts b/web/libraries/maplibre-gl/src/source/vector_tile_worker_source.test.ts new file mode 100644 index 00000000..73c82201 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/vector_tile_worker_source.test.ts @@ -0,0 +1,390 @@ +import fs from 'fs'; +import path from 'path'; +import vt from '@mapbox/vector-tile'; +import Protobuf from 'pbf'; +import {VectorTileWorkerSource} from '../source/vector_tile_worker_source'; +import {StyleLayerIndex} from '../style/style_layer_index'; +import {fakeServer, type FakeServer} from 'nise'; +import {Actor} from '../util/actor'; +import {TileParameters, WorkerTileParameters, WorkerTileResult} from './worker_source'; +import {WorkerTile} from './worker_tile'; +import {setPerformance} from '../util/test/util'; + +describe('vector tile worker source', () => { + const actor = {send: () => {}} as any as Actor; + let server: FakeServer; + + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + setPerformance(); + }); + + afterEach(() => { + server.restore(); + jest.clearAllMocks(); + }); + test('VectorTileWorkerSource#abortTile aborts pending request', () => { + const source = new VectorTileWorkerSource(actor, new StyleLayerIndex(), []); + + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/abort'} + } as any as WorkerTileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res).toBeFalsy(); + }); + + source.abortTile({ + source: 'source', + uid: 0 + } as any as TileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res).toBeFalsy(); + }); + + expect(source.loading).toEqual({}); + }); + + test('VectorTileWorkerSource#removeTile removes loaded tile', () => { + const source = new VectorTileWorkerSource(actor, new StyleLayerIndex(), []); + + source.loaded = { + '0': {} as WorkerTile + }; + + source.removeTile({ + source: 'source', + uid: 0 + } as any as TileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res).toBeFalsy(); + }); + + expect(source.loaded).toEqual({}); + }); + + test('VectorTileWorkerSource#reloadTile reloads a previously-loaded tile', () => { + const source = new VectorTileWorkerSource(actor, new StyleLayerIndex(), []); + const parse = jest.fn(); + + source.loaded = { + '0': { + status: 'done', + vectorTile: {}, + parse + } as any as WorkerTile + }; + + const callback = jest.fn(); + source.reloadTile({uid: 0} as any as WorkerTileParameters, callback); + expect(parse).toHaveBeenCalledTimes(1); + + parse.mock.calls[0][4](); + expect(callback).toHaveBeenCalledTimes(1); + }); + + test('VectorTileWorkerSource#loadTile reparses tile if the reloadTile has been called during parsing', (done) => { + const rawTileData = new Uint8Array([]); + function loadVectorData(params, callback) { + return callback(null, { + vectorTile: { + layers: { + test: { + version: 2, + name: 'test', + extent: 8192, + length: 1, + feature: (featureIndex: number) => ({ + extent: 8192, + type: 1, + id: featureIndex, + properties: { + name: 'test' + }, + loadGeometry () { + return [[{x: 0, y: 0}]]; + } + }) + } + } + } as any as vt.VectorTile, + rawData: rawTileData + }); + } + + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'symbol', + layout: { + 'icon-image': 'hello', + 'text-font': ['StandardFont-Bold'], + 'text-field': '{name}' + } + }]); + + const send = jest.fn().mockImplementation((type: string, data: unknown, callback: Function) => { + const res = setTimeout(() => callback(null, + type === 'getImages' ? + {'hello': {width: 1, height: 1, data: new Uint8Array([0])}} : + {'StandardFont-Bold': {width: 1, height: 1, data: new Uint8Array([0])}} + )); + + return { + cancel: () => clearTimeout(res) + }; + }); + + const actor = { + send + } as unknown as Actor; + const source = new VectorTileWorkerSource(actor, layerIndex, ['hello'], loadVectorData); + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf'} + } as any as WorkerTileParameters, () => { + done.fail('should not be called'); + }); + + source.reloadTile({ + source: 'source', + uid: '0', + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + } as any as WorkerTileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res).toBeDefined(); + expect(res.rawTileData).toBeDefined(); + expect(res.rawTileData).toStrictEqual(rawTileData); + done(); + }); + }); + + test('VectorTileWorkerSource#loadTile reparses tile if reloadTile is called during reparsing', (done) => { + const rawTileData = new Uint8Array([]); + function loadVectorData(params, callback) { + return callback(null, { + vectorTile: new vt.VectorTile(new Protobuf(rawTileData)), + rawData: rawTileData + }); + } + + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'fill' + }]); + + const source = new VectorTileWorkerSource(actor, layerIndex, [], loadVectorData); + + const parseWorkerTileMock = jest + .spyOn(WorkerTile.prototype, 'parse') + .mockImplementation(function(data, layerIndex, availableImages, actor, callback) { + this.status = 'parsing'; + window.setTimeout(() => callback(null, {} as WorkerTileResult), 10); + }); + + let loadCallbackCalled = false; + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf'} + } as any as WorkerTileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res).toBeDefined(); + loadCallbackCalled = true; + }); + + source.reloadTile({ + source: 'source', + uid: '0', + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + } as any as WorkerTileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res).toBeDefined(); + expect(parseWorkerTileMock).toHaveBeenCalledTimes(2); + expect(loadCallbackCalled).toBeTruthy(); + done(); + }); + }); + + test('VectorTileWorkerSource#reloadTile does not reparse tiles with no vectorTile data but does call callback', () => { + const source = new VectorTileWorkerSource(actor, new StyleLayerIndex(), []); + const parse = jest.fn(); + + source.loaded = { + '0': { + status: 'done', + parse + } as any as WorkerTile + }; + + const callback = jest.fn(); + + source.reloadTile({uid: 0} as any as WorkerTileParameters, callback); + expect(parse).not.toHaveBeenCalled(); + expect(callback).toHaveBeenCalledTimes(1); + + }); + + test('VectorTileWorkerSource#returns a good error message when failing to parse a tile', () => { + const source = new VectorTileWorkerSource(actor, new StyleLayerIndex(), []); + const parse = jest.fn(); + const callback = jest.fn(); + + server.respondWith(request => { + request.respond(200, {'Content-Type': 'application/pbf'}, 'something...'); + }); + + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf'} + } as any as WorkerTileParameters, callback); + + server.respond(); + + expect(parse).not.toHaveBeenCalled(); + expect(callback).toHaveBeenCalledTimes(1); + expect(callback.mock.calls[0][0].message).toContain('Unable to parse the tile at'); + }); + + test('VectorTileWorkerSource#returns a good error message when failing to parse a gzipped tile', () => { + const source = new VectorTileWorkerSource(actor, new StyleLayerIndex(), []); + const parse = jest.fn(); + const callback = jest.fn(); + + server.respondWith(new Uint8Array([0x1f, 0x8b]).buffer); + + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf'} + } as any as WorkerTileParameters, callback); + + server.respond(); + + expect(parse).not.toHaveBeenCalled(); + expect(callback).toHaveBeenCalledTimes(1); + expect(callback.mock.calls[0][0].message).toContain('gzipped'); + }); + + test('VectorTileWorkerSource provides resource timing information', done => { + const rawTileData = fs.readFileSync(path.join(__dirname, '/../../test/unit/assets/mbsv5-6-18-23.vector.pbf')); + + function loadVectorData(params, callback) { + return callback(null, { + vectorTile: new vt.VectorTile(new Protobuf(rawTileData)), + rawData: rawTileData, + cacheControl: null, + expires: null + }); + } + + const exampleResourceTiming = { + connectEnd: 473, + connectStart: 473, + decodedBodySize: 86494, + domainLookupEnd: 473, + domainLookupStart: 473, + duration: 341, + encodedBodySize: 52528, + entryType: 'resource', + fetchStart: 473.5, + initiatorType: 'xmlhttprequest', + name: 'http://localhost:2900/faketile.pbf', + nextHopProtocol: 'http/1.1', + redirectEnd: 0, + redirectStart: 0, + requestStart: 477, + responseEnd: 815, + responseStart: 672, + secureConnectionStart: 0 + }; + + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'fill' + }]); + + const source = new VectorTileWorkerSource(actor, layerIndex, [], loadVectorData); + + window.performance.getEntriesByName = jest.fn().mockReturnValue([exampleResourceTiming]); + + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf', collectResourceTiming: true} + } as any as WorkerTileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res.resourceTiming[0]).toEqual(exampleResourceTiming); + done(); + }); + }); + + test('VectorTileWorkerSource provides resource timing information (fallback method)', done => { + const rawTileData = fs.readFileSync(path.join(__dirname, '/../../test/unit/assets/mbsv5-6-18-23.vector.pbf')); + + function loadVectorData(params, callback) { + return callback(null, { + vectorTile: new vt.VectorTile(new Protobuf(rawTileData)), + rawData: rawTileData, + cacheControl: null, + expires: null + }); + } + + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'fill' + }]); + + const source = new VectorTileWorkerSource(actor, layerIndex, [], loadVectorData); + + const sampleMarks = [100, 350]; + const marks = {}; + const measures = {}; + window.performance.getEntriesByName = jest.fn().mockImplementation(name => (measures[name] || [])); + window.performance.mark = jest.fn().mockImplementation(name => { + marks[name] = sampleMarks.shift(); + return null; + }); + window.performance.measure = jest.fn().mockImplementation((name, start, end) => { + measures[name] = measures[name] || []; + measures[name].push({ + duration: marks[end] - marks[start], + entryType: 'measure', + name, + startTime: marks[start] + }); + return null; + }); + + source.loadTile({ + source: 'source', + uid: 0, + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf', collectResourceTiming: true} + } as any as WorkerTileParameters, (err, res) => { + expect(err).toBeFalsy(); + expect(res.resourceTiming[0]).toEqual( + {'duration': 250, 'entryType': 'measure', 'name': 'http://localhost:2900/faketile.pbf', 'startTime': 100} + ); + done(); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/vector_tile_worker_source.ts b/web/libraries/maplibre-gl/src/source/vector_tile_worker_source.ts new file mode 100644 index 00000000..7c7fca9d --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/vector_tile_worker_source.ts @@ -0,0 +1,228 @@ +import {ExpiryData, getArrayBuffer} from '../util/ajax'; + +import vt from '@mapbox/vector-tile'; +import Protobuf from 'pbf'; +import {WorkerTile} from './worker_tile'; +import {extend} from '../util/util'; +import {RequestPerformance} from '../util/performance'; + +import type { + WorkerSource, + WorkerTileParameters, + WorkerTileCallback, + TileParameters +} from '../source/worker_source'; + +import type {Actor} from '../util/actor'; +import type {StyleLayerIndex} from '../style/style_layer_index'; +import type {Callback} from '../types/callback'; +import type {VectorTile} from '@mapbox/vector-tile'; + +export type LoadVectorTileResult = { + vectorTile: VectorTile; + rawData: ArrayBuffer; + resourceTiming?: Array; +} & ExpiryData; + +type FetchingState = { + rawTileData: ArrayBuffer; + cacheControl: ExpiryData; + resourceTiming: any; +} + +/** + * The callback when finished loading vector data + */ +export type LoadVectorDataCallback = Callback; + +export type AbortVectorData = () => void; +export type LoadVectorData = (params: WorkerTileParameters, callback: LoadVectorDataCallback) => AbortVectorData | void; + +/** + * Loads a vector tile + */ +function loadVectorTile(params: WorkerTileParameters, callback: LoadVectorDataCallback) { + const request = getArrayBuffer(params.request, (err?: Error | null, data?: ArrayBuffer | null, cacheControl?: string | null, expires?: string | null) => { + if (err) { + callback(err); + } else if (data) { + try { + const vectorTile = new vt.VectorTile(new Protobuf(data)); + callback(null, { + vectorTile, + rawData: data, + cacheControl, + expires + }); + } catch (ex) { + const bytes = new Uint8Array(data); + const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b; + let errorMessage = `Unable to parse the tile at ${params.request.url}, `; + if (isGzipped) { + errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server'; + } else { + errorMessage += `got error: ${ex.messge}`; + } + callback(new Error(errorMessage)); + } + } + }); + return () => { + request.cancel(); + callback(); + }; +} + +/** + * The {@link WorkerSource} implementation that supports {@link VectorTileSource}. + * This class is designed to be easily reused to support custom source types + * for data formats that can be parsed/converted into an in-memory VectorTile + * representation. To do so, create it with + * `new VectorTileWorkerSource(actor, styleLayers, customLoadVectorDataFunction)`. + */ +export class VectorTileWorkerSource implements WorkerSource { + actor: Actor; + layerIndex: StyleLayerIndex; + availableImages: Array; + loadVectorData: LoadVectorData; + fetching: {[_: string]: FetchingState }; + loading: {[_: string]: WorkerTile}; + loaded: {[_: string]: WorkerTile}; + + /** + * @param loadVectorData - Optional method for custom loading of a VectorTile + * object based on parameters passed from the main-thread Source. See + * {@link VectorTileWorkerSource#loadTile}. The default implementation simply + * loads the pbf at `params.url`. + */ + constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array, loadVectorData?: LoadVectorData | null) { + this.actor = actor; + this.layerIndex = layerIndex; + this.availableImages = availableImages; + this.loadVectorData = loadVectorData || loadVectorTile; + this.fetching = {}; + this.loading = {}; + this.loaded = {}; + } + + /** + * Implements {@link WorkerSource#loadTile}. Delegates to + * {@link VectorTileWorkerSource#loadVectorData} (which by default expects + * a `params.url` property) for fetching and producing a VectorTile object. + */ + loadTile(params: WorkerTileParameters, callback: WorkerTileCallback) { + const uid = params.uid; + + if (!this.loading) + this.loading = {}; + + const perf = (params && params.request && params.request.collectResourceTiming) ? + new RequestPerformance(params.request) : false; + + const workerTile = this.loading[uid] = new WorkerTile(params); + workerTile.abort = this.loadVectorData(params, (err, response) => { + delete this.loading[uid]; + + if (err || !response) { + workerTile.status = 'done'; + this.loaded[uid] = workerTile; + return callback(err); + } + + const rawTileData = response.rawData; + const cacheControl = {} as ExpiryData; + if (response.expires) cacheControl.expires = response.expires; + if (response.cacheControl) cacheControl.cacheControl = response.cacheControl; + + const resourceTiming = {} as {resourceTiming: any}; + if (perf) { + const resourceTimingData = perf.finish(); + // it's necessary to eval the result of getEntriesByName() here via parse/stringify + // late evaluation in the main thread causes TypeError: illegal invocation + if (resourceTimingData) + resourceTiming.resourceTiming = JSON.parse(JSON.stringify(resourceTimingData)); + } + + workerTile.vectorTile = response.vectorTile; + workerTile.parse(response.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => { + delete this.fetching[uid]; + if (err || !result) return callback(err); + + // Transferring a copy of rawTileData because the worker needs to retain its copy. + callback(null, extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming)); + }); + + this.loaded = this.loaded || {}; + this.loaded[uid] = workerTile; + // keep the original fetching state so that reload tile can pick it up if the original parse is cancelled by reloads' parse + this.fetching[uid] = {rawTileData, cacheControl, resourceTiming}; + }) as AbortVectorData; + } + + /** + * Implements {@link WorkerSource#reloadTile}. + */ + reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) { + const loaded = this.loaded; + const uid = params.uid; + if (loaded && loaded[uid]) { + const workerTile = loaded[uid]; + workerTile.showCollisionBoxes = params.showCollisionBoxes; + if (workerTile.status === 'parsing') { + workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, result) => { + if (err || !result) return callback(err, result); + + // if we have cancelled the original parse, make sure to pass the rawTileData from the original fetch + let parseResult; + if (this.fetching[uid]) { + const {rawTileData, cacheControl, resourceTiming} = this.fetching[uid]; + delete this.fetching[uid]; + parseResult = extend({rawTileData: rawTileData.slice(0)}, result, cacheControl, resourceTiming); + } else { + parseResult = result; + } + + callback(null, parseResult); + }); + } else if (workerTile.status === 'done') { + // if there was no vector tile data on the initial load, don't try and re-parse tile + if (workerTile.vectorTile) { + workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, callback); + } else { + callback(); + } + } + } + } + + /** + * Implements {@link WorkerSource#abortTile}. + * + * @param params - The tile parameters + * @param callback - The callback + */ + abortTile(params: TileParameters, callback: WorkerTileCallback) { + const loading = this.loading, + uid = params.uid; + if (loading && loading[uid] && loading[uid].abort) { + loading[uid].abort(); + delete loading[uid]; + } + callback(); + } + + /** + * Implements {@link WorkerSource#removeTile}. + * + * @param params - The tile parameters + * @param callback - The callback + */ + removeTile(params: TileParameters, callback: WorkerTileCallback) { + const loaded = this.loaded, + uid = params.uid; + if (loaded && loaded[uid]) { + delete loaded[uid]; + } + callback(); + } +} diff --git a/web/libraries/maplibre-gl/src/source/video_source.test.ts b/web/libraries/maplibre-gl/src/source/video_source.test.ts new file mode 100644 index 00000000..d7ef11c1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/video_source.test.ts @@ -0,0 +1,124 @@ +import {VideoSource} from './video_source'; +import {extend} from '../util/util'; +import {getMockDispatcher} from '../util/test/util'; + +import type {Coordinates} from './image_source'; +import {Tile} from './tile'; +import {OverscaledTileID} from './tile_id'; +import {Evented} from '../util/evented'; +import {Transform} from '../geo/transform'; +import {VertexBuffer} from '../gl/vertex_buffer'; +import {SegmentVector} from '../data/segment'; + +class StubMap extends Evented { + transform: Transform; + style: any; + painter: any; + + constructor() { + super(); + this.transform = new Transform(); + this.style = {}; + this.painter = { + context: { + gl: { + texSubImage2D: () => {} + } + } + }; + } +} + +function createSource(options) { + const c = options && options.video || window.document.createElement('video'); + + options = extend({coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]]}, options); + + const source = new VideoSource('id', options, getMockDispatcher(), options.eventedParent); + + source.video = c; + return source; +} + +describe('VideoSource', () => { + // Attribution File:Volcano Lava Sample.webm: U.S. Geological Survey (USGS), Public domain, via Wikimedia Commons + const source = createSource({ + type: 'video', + urls: ['cropped.mp4', 'https://upload.wikimedia.org/wikipedia/commons/2/22/Volcano_Lava_Sample.webm'], + coordinates: [ + [-76.54, 39.18], + [-76.52, 39.18], + [-76.52, 39.17], + [-76.54, 39.17] + ] + }); + + test('constructor', () => { + expect(source.minzoom).toBe(0); + expect(source.maxzoom).toBe(22); + expect(source.tileSize).toBe(512); + }); + + test('sets coordinates', () => { + const newCoordinates = [[0, 0], [-1, 0], [-1, -1], [0, -1]] as Coordinates; + source.setCoordinates(newCoordinates); + const serialized = source.serialize(); + + expect(serialized.coordinates).toEqual(newCoordinates); + + }); + + //test video retrieval by first supplying the video element directly + test('gets video', () => { + const el = window.document.createElement('video'); + // Attribution File:Volcano Lava Sample.webm: U.S. Geological Survey (USGS), Public domain, via Wikimedia Commons + const source = createSource({ + type: 'video', + video: el, + urls: ['cropped.mp4', 'https://upload.wikimedia.org/wikipedia/commons/2/22/Volcano_Lava_Sample.webm'], + coordinates: [ + [-76.54, 39.18], + [-76.52, 39.18], + [-76.52, 39.17], + [-76.54, 39.17] + ] + }); + + expect(source.getVideo()).toBe(el); + }); + + test('fires idle event on prepare call when there is at least one not loaded tile', done => { + const source = createSource({ + type: 'video', + urls: [], + video: { + readyState: 2, + play: () => {} + }, + coordinates: [ + [-76.54, 39.18], + [-76.52, 39.18], + [-76.52, 39.17], + [-76.54, 39.17] + ] + }); + const tile = new Tile(new OverscaledTileID(1, 0, 1, 0, 0), 512); + source.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'idle') { + expect(tile.state).toBe('loaded'); + done(); + } + }); + source.onAdd(new StubMap() as any); + + source.tiles[String(tile.tileID.wrap)] = tile; + // assign dummies directly so we don't need to stub the gl things + source.boundsBuffer = {} as VertexBuffer; + source.boundsSegments = {} as SegmentVector; + source.texture = { + update: () => {}, + bind: () => {} + } as any; + source.prepare(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/video_source.ts b/web/libraries/maplibre-gl/src/source/video_source.ts new file mode 100644 index 00000000..5aa966df --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/video_source.ts @@ -0,0 +1,205 @@ +import {getVideo} from '../util/ajax'; +import {ResourceType} from '../util/request_manager'; + +import {ImageSource} from './image_source'; +import rasterBoundsAttributes from '../data/raster_bounds_attributes'; +import {SegmentVector} from '../data/segment'; +import {Texture} from '../render/texture'; +import {Event, ErrorEvent} from '../util/evented'; +import {ValidationError} from '@maplibre/maplibre-gl-style-spec'; + +import type {Map} from '../ui/map'; +import type {Dispatcher} from '../util/dispatcher'; +import type {Evented} from '../util/evented'; +import type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * A data source containing video. + * (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-video) for detailed documentation of options.) + * + * @group Sources + * + * @example + * ```ts + * // add to map + * map.addSource('some id', { + * type: 'video', + * url: [ + * 'https://www.mapbox.com/blog/assets/baltimore-smoke.mp4', + * 'https://www.mapbox.com/blog/assets/baltimore-smoke.webm' + * ], + * coordinates: [ + * [-76.54, 39.18], + * [-76.52, 39.18], + * [-76.52, 39.17], + * [-76.54, 39.17] + * ] + * }); + * + * // update + * let mySource = map.getSource('some id'); + * mySource.setCoordinates([ + * [-76.54335737228394, 39.18579907229748], + * [-76.52803659439087, 39.1838364847587], + * [-76.5295386314392, 39.17683392507606], + * [-76.54520273208618, 39.17876344106642] + * ]); + * + * map.removeSource('some id'); // remove + * ``` + * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/) + * + * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in. + * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior, + * set the layer's `raster-fade-duration` property to `0`. + */ +export class VideoSource extends ImageSource { + options: VideoSourceSpecification; + urls: Array; + video: HTMLVideoElement; + roundZoom: boolean; + + constructor(id: string, options: VideoSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) { + super(id, options, dispatcher, eventedParent); + this.roundZoom = true; + this.type = 'video'; + this.options = options; + } + + load = () => { + this._loaded = false; + const options = this.options; + + this.urls = []; + for (const url of options.urls) { + this.urls.push(this.map._requestManager.transformRequest(url, ResourceType.Source).url); + } + + getVideo(this.urls, (err, video) => { + this._loaded = true; + if (err) { + this.fire(new ErrorEvent(err)); + } else if (video) { + this.video = video; + this.video.loop = true; + + // Start repainting when video starts playing. hasTransition() will then return + // true to trigger additional frames as long as the videos continues playing. + this.video.addEventListener('playing', () => { + this.map.triggerRepaint(); + }); + + if (this.map) { + this.video.play(); + } + + this._finishLoading(); + } + }); + }; + + /** + * Pauses the video. + */ + pause() { + if (this.video) { + this.video.pause(); + } + } + + /** + * Plays the video. + */ + play() { + if (this.video) { + this.video.play(); + } + } + + /** + * Sets playback to a timestamp, in seconds. + */ + seek(seconds: number) { + if (this.video) { + const seekableRange = this.video.seekable; + if (seconds < seekableRange.start(0) || seconds > seekableRange.end(0)) { + this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`, null, `Playback for this video can be set only between the ${seekableRange.start(0)} and ${seekableRange.end(0)}-second mark.`))); + } else this.video.currentTime = seconds; + } + } + + /** + * Returns the HTML `video` element. + * + * @returns The HTML `video` element. + */ + getVideo(): HTMLVideoElement { + return this.video; + } + + onAdd(map: Map) { + if (this.map) return; + this.map = map; + this.load(); + if (this.video) { + this.video.play(); + this.setCoordinates(this.coordinates); + } + } + + /** + * Sets the video's coordinates and re-renders the map. + * + * @returns `this` + */ + prepare = (): this => { + if (Object.keys(this.tiles).length === 0 || this.video.readyState < 2) { + return; // not enough data for current position + } + + const context = this.map.painter.context; + const gl = context.gl; + + if (!this.boundsBuffer) { + this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members); + } + + if (!this.boundsSegments) { + this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2); + } + + if (!this.texture) { + this.texture = new Texture(context, this.video, gl.RGBA); + this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + } else if (!this.video.paused) { + this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE); + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, this.video); + } + + let newTilesLoaded = false; + for (const w in this.tiles) { + const tile = this.tiles[w]; + if (tile.state !== 'loaded') { + tile.state = 'loaded'; + tile.texture = this.texture; + newTilesLoaded = true; + } + } + + if (newTilesLoaded) { + this.fire(new Event('data', {dataType: 'source', sourceDataType: 'idle', sourceId: this.id})); + } + }; + + serialize = (): VideoSourceSpecification => { + return { + type: 'video', + urls: this.urls, + coordinates: this.coordinates + }; + }; + + hasTransition() { + return this.video && !this.video.paused; + } +} diff --git a/web/libraries/maplibre-gl/src/source/worker.test.ts b/web/libraries/maplibre-gl/src/source/worker.test.ts new file mode 100644 index 00000000..26d32097 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/worker.test.ts @@ -0,0 +1,153 @@ +import {fakeServer} from 'nise'; +import Worker from './worker'; +import {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {Cancelable} from '../types/cancelable'; +import {WorkerGlobalScopeInterface} from '../util/web_worker'; +import {CanonicalTileID, OverscaledTileID} from './tile_id'; +import {TileParameters, WorkerSource, WorkerTileCallback, WorkerTileParameters} from './worker_source'; +import {plugin as globalRTLTextPlugin} from './rtl_text_plugin'; +import {ActorTarget} from '../util/actor'; + +const _self = { + addEventListener() {} +} as any as WorkerGlobalScopeInterface & ActorTarget; + +class WorkerSourceMock implements WorkerSource { + availableImages: string[]; + constructor(private actor: any) {} + loadTile(_: WorkerTileParameters, __: WorkerTileCallback): void { + this.actor.send('main thread task', {}, () => {}, null); + } + reloadTile(_: WorkerTileParameters, __: WorkerTileCallback): void { + throw new Error('Method not implemented.'); + } + abortTile(_: TileParameters, __: WorkerTileCallback): void { + throw new Error('Method not implemented.'); + } + removeTile(_: TileParameters, __: WorkerTileCallback): void { + throw new Error('Method not implemented.'); + } +} + +describe('load tile', () => { + test('calls callback on error', done => { + const server = fakeServer.create(); + global.fetch = null; + const worker = new Worker(_self); + worker.loadTile('0', { + type: 'vector', + source: 'source', + uid: '0', + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0} as CanonicalTileID} as any as OverscaledTileID, + request: {url: '/error'}// Sinon fake server gives 404 responses by default + } as WorkerTileParameters & { type: string }, (err) => { + expect(err).toBeTruthy(); + server.restore(); + done(); + }); + server.respond(); + }); + + test('isolates different instances\' data', () => { + const worker = new Worker(_self); + + worker.setLayers('0', [ + {id: 'one', type: 'circle'} as LayerSpecification + ], () => {}); + + worker.setLayers('1', [ + {id: 'one', type: 'circle'} as LayerSpecification, + {id: 'two', type: 'circle'} as LayerSpecification, + ], () => {}); + + expect(worker.layerIndexes[0]).not.toBe(worker.layerIndexes[1]); + }); + + test('worker source messages dispatched to the correct map instance', done => { + const worker = new Worker(_self); + const workerName = 'test'; + + worker.actor.send = (type, data, callback, mapId): Cancelable => { + expect(type).toBe('main thread task'); + expect(mapId).toBe('999'); + done(); + return {cancel: () => {}}; + }; + + _self.registerWorkerSource(workerName, WorkerSourceMock); + + expect(() => { + _self.registerWorkerSource(workerName, WorkerSourceMock); + }).toThrow(`Worker source with name "${workerName}" already registered.`); + + worker.loadTile('999', {type: 'test'} as WorkerTileParameters & { type: string }, () => {}); + }); +}); + +describe('register RTLTextPlugin', () => { + test('should not throw and set values in plugin', () => { + jest.spyOn(globalRTLTextPlugin, 'isParsed').mockImplementation(() => { + return false; + }); + + const rtlTextPlugin = { + applyArabicShaping: 'test', + processBidirectionalText: 'test', + processStyledBidirectionalText: 'test', + }; + + _self.registerRTLTextPlugin(rtlTextPlugin); + expect(globalRTLTextPlugin['applyArabicShaping']).toBe('test'); + expect(globalRTLTextPlugin['processBidirectionalText']).toBe('test'); + expect(globalRTLTextPlugin['processStyledBidirectionalText']).toBe('test'); + }); + + test('should throw if already parsed', () => { + jest.spyOn(globalRTLTextPlugin, 'isParsed').mockImplementation(() => { + return true; + }); + + const rtlTextPlugin = { + applyArabicShaping: jest.fn(), + processBidirectionalText: jest.fn(), + processStyledBidirectionalText: jest.fn(), + }; + + expect(() => { + _self.registerRTLTextPlugin(rtlTextPlugin); + }).toThrow('RTL text plugin already registered.'); + }); +}); + +describe('set Referrer', () => { + test('Referrer is set', () => { + const worker = new Worker(_self); + worker.setReferrer('fakeId', 'myMap'); + expect(worker.referrer).toBe('myMap'); + }); +}); + +describe('load worker source', () => { + test('calls callback on error', done => { + const server = fakeServer.create(); + global.fetch = null; + const worker = new Worker(_self); + worker.loadWorkerSource('0', { + url: '/error', + }, (err) => { + expect(err).toBeTruthy(); + server.restore(); + done(); + }); + server.respond(); + }); +}); + +describe('set images', () => { + test('set images', () => { + const worker = new Worker(_self); + expect(worker.availableImages['0']).toBeUndefined(); + worker.setImages('0', ['availableImages'], () => {}); + expect(worker.availableImages['0']).toEqual(['availableImages']); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/worker.ts b/web/libraries/maplibre-gl/src/source/worker.ts new file mode 100644 index 00000000..74ae806d --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/worker.ts @@ -0,0 +1,259 @@ +import {Actor, ActorTarget} from '../util/actor'; +import {StyleLayerIndex} from '../style/style_layer_index'; +import {VectorTileWorkerSource} from './vector_tile_worker_source'; +import {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source'; +import {GeoJSONWorkerSource} from './geojson_worker_source'; +import {plugin as globalRTLTextPlugin} from './rtl_text_plugin'; +import {isWorker} from '../util/util'; + +import type { + WorkerSource, + WorkerTileParameters, + WorkerDEMTileParameters, + WorkerTileCallback, + WorkerDEMTileCallback, + TileParameters +} from '../source/worker_source'; + +import type {WorkerGlobalScopeInterface} from '../util/web_worker'; +import type {Callback} from '../types/callback'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {PluginState} from './rtl_text_plugin'; + +/** + * The Worker class responsidble for background thread related execution + */ +export default class Worker { + self: WorkerGlobalScopeInterface & ActorTarget; + actor: Actor; + layerIndexes: {[_: string]: StyleLayerIndex}; + availableImages: {[_: string]: Array}; + workerSourceTypes: { + [_: string]: { + new (...args: any): WorkerSource; + }; + }; + workerSources: { + [_: string]: { + [_: string]: { + [_: string]: WorkerSource; + }; + }; + }; + demWorkerSources: { + [_: string]: { + [_: string]: RasterDEMTileWorkerSource; + }; + }; + referrer: string; + + constructor(self: WorkerGlobalScopeInterface & ActorTarget) { + this.self = self; + this.actor = new Actor(self, this); + + this.layerIndexes = {}; + this.availableImages = {}; + + this.workerSourceTypes = { + vector: VectorTileWorkerSource, + geojson: GeoJSONWorkerSource + }; + + // [mapId][sourceType][sourceName] => worker source instance + this.workerSources = {}; + this.demWorkerSources = {}; + + this.self.registerWorkerSource = (name: string, WorkerSource: { + new (...args: any): WorkerSource; + }) => { + if (this.workerSourceTypes[name]) { + throw new Error(`Worker source with name "${name}" already registered.`); + } + this.workerSourceTypes[name] = WorkerSource; + }; + + // This is invoked by the RTL text plugin when the download via the `importScripts` call has finished, and the code has been parsed. + this.self.registerRTLTextPlugin = (rtlTextPlugin: { + applyArabicShaping: Function; + processBidirectionalText: ((b: string, a: Array) => Array); + processStyledBidirectionalText?: ((c: string, b: Array, a: Array) => Array<[string, Array]>); + }) => { + if (globalRTLTextPlugin.isParsed()) { + throw new Error('RTL text plugin already registered.'); + } + globalRTLTextPlugin['applyArabicShaping'] = rtlTextPlugin.applyArabicShaping; + globalRTLTextPlugin['processBidirectionalText'] = rtlTextPlugin.processBidirectionalText; + globalRTLTextPlugin['processStyledBidirectionalText'] = rtlTextPlugin.processStyledBidirectionalText; + }; + } + + setReferrer(mapID: string, referrer: string) { + this.referrer = referrer; + } + + setImages(mapId: string, images: Array, callback: WorkerTileCallback) { + this.availableImages[mapId] = images; + for (const workerSource in this.workerSources[mapId]) { + const ws = this.workerSources[mapId][workerSource]; + for (const source in ws) { + ws[source].availableImages = images; + } + } + callback(); + } + + setLayers(mapId: string, layers: Array, callback: WorkerTileCallback) { + this.getLayerIndex(mapId).replace(layers); + callback(); + } + + updateLayers(mapId: string, params: { + layers: Array; + removedIds: Array; + }, callback: WorkerTileCallback) { + this.getLayerIndex(mapId).update(params.layers, params.removedIds); + callback(); + } + + loadTile(mapId: string, params: WorkerTileParameters & { + type: string; + }, callback: WorkerTileCallback) { + this.getWorkerSource(mapId, params.type, params.source).loadTile(params, callback); + } + + loadDEMTile(mapId: string, params: WorkerDEMTileParameters, callback: WorkerDEMTileCallback) { + this.getDEMWorkerSource(mapId, params.source).loadTile(params, callback); + } + + reloadTile(mapId: string, params: WorkerTileParameters & { + type: string; + }, callback: WorkerTileCallback) { + this.getWorkerSource(mapId, params.type, params.source).reloadTile(params, callback); + } + + abortTile(mapId: string, params: TileParameters & { + type: string; + }, callback: WorkerTileCallback) { + this.getWorkerSource(mapId, params.type, params.source).abortTile(params, callback); + } + + removeTile(mapId: string, params: TileParameters & { + type: string; + }, callback: WorkerTileCallback) { + this.getWorkerSource(mapId, params.type, params.source).removeTile(params, callback); + } + + removeDEMTile(mapId: string, params: TileParameters) { + this.getDEMWorkerSource(mapId, params.source).removeTile(params); + } + + removeSource(mapId: string, params: { + source: string; + } & { + type: string; + }, callback: WorkerTileCallback) { + + if (!this.workerSources[mapId] || + !this.workerSources[mapId][params.type] || + !this.workerSources[mapId][params.type][params.source]) { + return; + } + + const worker = this.workerSources[mapId][params.type][params.source]; + delete this.workerSources[mapId][params.type][params.source]; + + if (worker.removeSource !== undefined) { + worker.removeSource(params, callback); + } else { + callback(); + } + } + + /** + * Load a {@link WorkerSource} script at params.url. The script is run + * (using importScripts) with `registerWorkerSource` in scope, which is a + * function taking `(name, workerSourceObject)`. + */ + loadWorkerSource(map: string, params: { + url: string; + }, callback: Callback) { + try { + this.self.importScripts(params.url); + callback(); + } catch (e) { + callback(e.toString()); + } + } + + syncRTLPluginState(map: string, state: PluginState, callback: Callback) { + try { + globalRTLTextPlugin.setState(state); + const pluginURL = globalRTLTextPlugin.getPluginURL(); + if ( + globalRTLTextPlugin.isLoaded() && + !globalRTLTextPlugin.isParsed() && + pluginURL != null // Not possible when `isLoaded` is true, but keeps flow happy + ) { + this.self.importScripts(pluginURL); + const complete = globalRTLTextPlugin.isParsed(); + const error = complete ? undefined : new Error(`RTL Text Plugin failed to import scripts from ${pluginURL}`); + callback(error, complete); + } + } catch (e) { + callback(e.toString()); + } + } + + getAvailableImages(mapId: string) { + let availableImages = this.availableImages[mapId]; + + if (!availableImages) { + availableImages = []; + } + + return availableImages; + } + + getLayerIndex(mapId: string) { + let layerIndexes = this.layerIndexes[mapId]; + if (!layerIndexes) { + layerIndexes = this.layerIndexes[mapId] = new StyleLayerIndex(); + } + return layerIndexes; + } + + getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource { + if (!this.workerSources[mapId]) + this.workerSources[mapId] = {}; + if (!this.workerSources[mapId][sourceType]) + this.workerSources[mapId][sourceType] = {}; + + if (!this.workerSources[mapId][sourceType][sourceName]) { + // use a wrapped actor so that we can attach a target mapId param + // to any messages invoked by the WorkerSource + const actor = { + send: (type, data, callback) => { + this.actor.send(type, data, callback, mapId); + } + }; + this.workerSources[mapId][sourceType][sourceName] = new (this.workerSourceTypes[sourceType] as any)((actor as any), this.getLayerIndex(mapId), this.getAvailableImages(mapId)); + } + + return this.workerSources[mapId][sourceType][sourceName]; + } + + getDEMWorkerSource(mapId: string, source: string) { + if (!this.demWorkerSources[mapId]) + this.demWorkerSources[mapId] = {}; + + if (!this.demWorkerSources[mapId][source]) { + this.demWorkerSources[mapId][source] = new RasterDEMTileWorkerSource(); + } + + return this.demWorkerSources[mapId][source]; + } +} + +if (isWorker()) { + (self as any).worker = new Worker(self as any); +} diff --git a/web/libraries/maplibre-gl/src/source/worker_source.ts b/web/libraries/maplibre-gl/src/source/worker_source.ts new file mode 100644 index 00000000..fd6741b4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/worker_source.ts @@ -0,0 +1,118 @@ +import type {RequestParameters} from '../util/ajax'; +import type {RGBAImage, AlphaImage} from '../util/image'; +import type {GlyphPositions} from '../render/glyph_atlas'; +import type {ImageAtlas} from '../render/image_atlas'; +import type {OverscaledTileID} from './tile_id'; +import type {Bucket} from '../data/bucket'; +import type {FeatureIndex} from '../data/feature_index'; +import type {CollisionBoxArray} from '../data/array_types.g'; +import type {DEMData, DEMEncoding} from '../data/dem_data'; +import type {StyleGlyph} from '../style/style_glyph'; +import type {StyleImage} from '../style/style_image'; +import type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type TileParameters = { + source: string; + uid: string; +}; + +export type WorkerTileParameters = TileParameters & { + tileID: OverscaledTileID; + request: RequestParameters; + zoom: number; + maxZoom: number; + tileSize: number; + promoteId: PromoteIdSpecification; + pixelRatio: number; + showCollisionBoxes: boolean; + collectResourceTiming?: boolean; + returnDependencies?: boolean; +}; + +export type WorkerDEMTileParameters = TileParameters & { + coord: { + z: number; + x: number; + y: number; + w: number; + }; + rawImageData: RGBAImage | ImageBitmap; + encoding: DEMEncoding; + redFactor: number; + greenFactor: number; + blueFactor: number; + baseShift: number; +}; + +/** + * @internal + * The worker tile's result type + */ +export type WorkerTileResult = { + buckets: Array; + imageAtlas: ImageAtlas; + glyphAtlasImage: AlphaImage; + featureIndex: FeatureIndex; + collisionBoxArray: CollisionBoxArray; + rawTileData?: ArrayBuffer; + resourceTiming?: Array; + // Only used for benchmarking: + glyphMap?: { + [_: string]: { + [_: number]: StyleGlyph; + }; + } | null; + iconMap?: { + [_: string]: StyleImage; + } | null; + glyphPositions?: GlyphPositions | null; +}; + +export type WorkerTileCallback = (error?: Error | null, result?: WorkerTileResult | null) => void; +export type WorkerDEMTileCallback = (err?: Error | null, result?: DEMData | null) => void; + +/** + * May be implemented by custom source types to provide code that can be run on + * the WebWorkers. In addition to providing a custom + * {@link WorkerSource#loadTile}, any other methods attached to a `WorkerSource` + * implementation may also be targeted by the {@link Source} via + * `dispatcher.getActor().send('source-type.methodname', params, callback)`. + * + * @see {@link Map#addSourceType} + */ +export interface WorkerSource { + availableImages: Array; + // Disabled due to https://github.com/facebook/flow/issues/5208 + // constructor(actor: Actor, layerIndex: StyleLayerIndex): WorkerSource; + + /** + * Loads a tile from the given params and parse it into buckets ready to send + * back to the main thread for rendering. Should call the callback with: + * `{ buckets, featureIndex, collisionIndex, rawTileData}`. + */ + loadTile(params: WorkerTileParameters, callback: WorkerTileCallback): void; + /** + * Re-parses a tile that has already been loaded. Yields the same data as + * {@link WorkerSource#loadTile}. + */ + reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback): void; + /** + * Aborts loading a tile that is in progress. + */ + abortTile(params: TileParameters, callback: WorkerTileCallback): void; + /** + * Removes this tile from any local caches. + */ + removeTile(params: TileParameters, callback: WorkerTileCallback): void; + /** + * Tells the WorkerSource to abort in-progress tasks and release resources. + * The foreground Source is responsible for ensuring that 'removeSource' is + * the last message sent to the WorkerSource. + */ + removeSource?: ( + params: { + source: string; + }, + callback: WorkerTileCallback + ) => void; +} diff --git a/web/libraries/maplibre-gl/src/source/worker_tile.test.ts b/web/libraries/maplibre-gl/src/source/worker_tile.test.ts new file mode 100644 index 00000000..c914ee28 --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/worker_tile.test.ts @@ -0,0 +1,245 @@ +import {WorkerTile} from '../source/worker_tile'; +import {GeoJSONWrapper, Feature} from '../source/geojson_wrapper'; +import {OverscaledTileID} from '../source/tile_id'; +import {StyleLayerIndex} from '../style/style_layer_index'; +import {WorkerTileParameters} from './worker_source'; +import {Actor} from '../util/actor'; +import {VectorTile} from '@mapbox/vector-tile'; + +function createWorkerTile() { + return new WorkerTile({ + uid: '', + zoom: 0, + maxZoom: 20, + tileSize: 512, + source: 'source', + tileID: new OverscaledTileID(1, 0, 1, 1, 1), + overscaling: 1 + } as any as WorkerTileParameters); +} + +function createWrapper() { + return new GeoJSONWrapper([{ + type: 1, + geometry: [0, 0], + tags: {} + } as any as Feature]); +} + +describe('worker tile', () => { + test('WorkerTile#parse', done => { + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + type: 'circle' + }]); + + const tile = createWorkerTile(); + tile.parse(createWrapper(), layerIndex, [], {} as Actor, (err, result) => { + expect(err).toBeFalsy(); + expect(result.buckets[0]).toBeTruthy(); + done(); + }); + }); + + test('WorkerTile#parse skips hidden layers', done => { + const layerIndex = new StyleLayerIndex([{ + id: 'test-hidden', + source: 'source', + type: 'fill', + layout: {visibility: 'none'} + }]); + + const tile = createWorkerTile(); + tile.parse(createWrapper(), layerIndex, [], {} as Actor, (err, result) => { + expect(err).toBeFalsy(); + expect(result.buckets).toHaveLength(0); + done(); + }); + }); + + test('WorkerTile#parse skips layers without a corresponding source layer', done => { + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + 'source-layer': 'nonesuch', + type: 'fill' + }]); + + const tile = createWorkerTile(); + tile.parse({layers: {}}, layerIndex, [], {} as Actor, (err, result) => { + expect(err).toBeFalsy(); + expect(result.buckets).toHaveLength(0); + done(); + }); + }); + + test('WorkerTile#parse warns once when encountering a v1 vector tile layer', done => { + const layerIndex = new StyleLayerIndex([{ + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'fill' + }]); + + const data = { + layers: { + test: { + version: 1 + } + } + } as any as VectorTile; + + const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}); + + const tile = createWorkerTile(); + tile.parse(data, layerIndex, [], {} as Actor, (err) => { + expect(err).toBeFalsy(); + expect(spy.mock.calls[0][0]).toMatch(/does not use vector tile spec v2/); + done(); + }); + }); + + test('WorkerTile#parse would request all types of dependencies', done => { + const tile = createWorkerTile(); + const layerIndex = new StyleLayerIndex([{ + id: '1', + type: 'fill', + source: 'source', + 'source-layer': 'test', + paint: { + 'fill-pattern': 'hello' + } + }, { + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'symbol', + layout: { + 'icon-image': 'hello', + 'text-font': ['StandardFont-Bold'], + 'text-field': '{name}' + } + }]); + + const data = { + layers: { + test: { + version: 2, + name: 'test', + extent: 8192, + length: 1, + feature: (featureIndex: number) => ({ + extent: 8192, + type: 1, + id: featureIndex, + properties: { + name: 'test' + }, + loadGeometry () { + return [[{x: 0, y: 0}]]; + } + }) + } + } + } as any as VectorTile; + + const send = jest.fn().mockImplementation((type: string, data: unknown, callback: Function) => { + setTimeout(() => callback(null, + type === 'getImages' ? + {'hello': {width: 1, height: 1, data: new Uint8Array([0])}} : + {'StandardFont-Bold': {width: 1, height: 1, data: new Uint8Array([0])}} + )); + }); + + const actorMock = { + send + } as unknown as Actor; + tile.parse(data, layerIndex, ['hello'], actorMock, (err, result) => { + expect(err).toBeFalsy(); + expect(result).toBeDefined(); + expect(send).toHaveBeenCalledTimes(3); + expect(send).toHaveBeenCalledWith('getImages', expect.objectContaining({'icons': ['hello'], 'type': 'icons'}), expect.any(Function)); + expect(send).toHaveBeenCalledWith('getImages', expect.objectContaining({'icons': ['hello'], 'type': 'patterns'}), expect.any(Function)); + expect(send).toHaveBeenCalledWith('getGlyphs', expect.objectContaining({'source': 'source', 'type': 'glyphs', 'stacks': {'StandardFont-Bold': [101, 115, 116]}}), expect.any(Function)); + done(); + }); + }); + + test('WorkerTile#parse would cancel and only event once on repeated reparsing', done => { + const tile = createWorkerTile(); + const layerIndex = new StyleLayerIndex([{ + id: '1', + type: 'fill', + source: 'source', + 'source-layer': 'test', + paint: { + 'fill-pattern': 'hello' + } + }, { + id: 'test', + source: 'source', + 'source-layer': 'test', + type: 'symbol', + layout: { + 'icon-image': 'hello', + 'text-font': ['StandardFont-Bold'], + 'text-field': '{name}' + } + }]); + + const data = { + layers: { + test: { + version: 2, + name: 'test', + extent: 8192, + length: 1, + feature: (featureIndex: number) => ({ + extent: 8192, + type: 1, + id: featureIndex, + properties: { + name: 'test' + }, + loadGeometry () { + return [[{x: 0, y: 0}]]; + } + }) + } + } + } as any as VectorTile; + + let cancelCount = 0; + const send = jest.fn().mockImplementation((type: string, data: unknown, callback: Function) => { + const res = setTimeout(() => callback(null, + type === 'getImages' ? + {'hello': {width: 1, height: 1, data: new Uint8Array([0])}} : + {'StandardFont-Bold': {width: 1, height: 1, data: new Uint8Array([0])}} + )); + + return { + cancel: () => { + cancelCount += 1; + clearTimeout(res); + } + }; + }); + + const actorMock = { + send + } as unknown as Actor; + tile.parse(data, layerIndex, ['hello'], actorMock, () => done.fail('should not be called')); + tile.parse(data, layerIndex, ['hello'], actorMock, () => done.fail('should not be called')); + tile.parse(data, layerIndex, ['hello'], actorMock, (err, result) => { + expect(err).toBeFalsy(); + expect(result).toBeDefined(); + expect(cancelCount).toBe(6); + expect(send).toHaveBeenCalledTimes(9); + expect(send).toHaveBeenCalledWith('getImages', expect.objectContaining({'icons': ['hello'], 'type': 'icons'}), expect.any(Function)); + expect(send).toHaveBeenCalledWith('getImages', expect.objectContaining({'icons': ['hello'], 'type': 'patterns'}), expect.any(Function)); + expect(send).toHaveBeenCalledWith('getGlyphs', expect.objectContaining({'source': 'source', 'type': 'glyphs', 'stacks': {'StandardFont-Bold': [101, 115, 116]}}), expect.any(Function)); + done(); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/source/worker_tile.ts b/web/libraries/maplibre-gl/src/source/worker_tile.ts new file mode 100644 index 00000000..3a13b4ce --- /dev/null +++ b/web/libraries/maplibre-gl/src/source/worker_tile.ts @@ -0,0 +1,252 @@ +import {FeatureIndex} from '../data/feature_index'; +import {performSymbolLayout} from '../symbol/symbol_layout'; +import {CollisionBoxArray} from '../data/array_types.g'; +import {DictionaryCoder} from '../util/dictionary_coder'; +import {SymbolBucket} from '../data/bucket/symbol_bucket'; +import {LineBucket} from '../data/bucket/line_bucket'; +import {FillBucket} from '../data/bucket/fill_bucket'; +import {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket'; +import {warnOnce, mapObject} from '../util/util'; +import {ImageAtlas} from '../render/image_atlas'; +import {GlyphAtlas} from '../render/glyph_atlas'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {OverscaledTileID} from './tile_id'; + +import type {Bucket} from '../data/bucket'; +import type {Actor} from '../util/actor'; +import type {StyleLayer} from '../style/style_layer'; +import type {StyleLayerIndex} from '../style/style_layer_index'; +import type {StyleImage} from '../style/style_image'; +import type {StyleGlyph} from '../style/style_glyph'; +import type { + WorkerTileParameters, + WorkerTileCallback, +} from '../source/worker_source'; +import type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {VectorTile} from '@mapbox/vector-tile'; +import {Cancelable} from '../types/cancelable'; + +export class WorkerTile { + tileID: OverscaledTileID; + uid: string; + zoom: number; + pixelRatio: number; + tileSize: number; + source: string; + promoteId: PromoteIdSpecification; + overscaling: number; + showCollisionBoxes: boolean; + collectResourceTiming: boolean; + returnDependencies: boolean; + + status: 'parsing' | 'done'; + data: VectorTile; + collisionBoxArray: CollisionBoxArray; + + abort: (() => void); + vectorTile: VectorTile; + inFlightDependencies: Cancelable[]; + dependencySentinel: number; + + constructor(params: WorkerTileParameters) { + this.tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y); + this.uid = params.uid; + this.zoom = params.zoom; + this.pixelRatio = params.pixelRatio; + this.tileSize = params.tileSize; + this.source = params.source; + this.overscaling = this.tileID.overscaleFactor(); + this.showCollisionBoxes = params.showCollisionBoxes; + this.collectResourceTiming = !!params.collectResourceTiming; + this.returnDependencies = !!params.returnDependencies; + this.promoteId = params.promoteId; + this.inFlightDependencies = []; + this.dependencySentinel = -1; + } + + parse(data: VectorTile, layerIndex: StyleLayerIndex, availableImages: Array, actor: Actor, callback: WorkerTileCallback) { + this.status = 'parsing'; + this.data = data; + + this.collisionBoxArray = new CollisionBoxArray(); + const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort()); + + const featureIndex = new FeatureIndex(this.tileID, this.promoteId); + featureIndex.bucketLayerIDs = []; + + const buckets: {[_: string]: Bucket} = {}; + + const options = { + featureIndex, + iconDependencies: {}, + patternDependencies: {}, + glyphDependencies: {}, + availableImages + }; + + const layerFamilies = layerIndex.familiesBySource[this.source]; + for (const sourceLayerId in layerFamilies) { + const sourceLayer = data.layers[sourceLayerId]; + if (!sourceLayer) { + continue; + } + + if (sourceLayer.version === 1) { + warnOnce(`Vector tile source "${this.source}" layer "${sourceLayerId}" ` + + 'does not use vector tile spec v2 and therefore may have some rendering errors.'); + } + + const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId); + const features = []; + for (let index = 0; index < sourceLayer.length; index++) { + const feature = sourceLayer.feature(index); + const id = featureIndex.getId(feature, sourceLayerId); + features.push({feature, id, index, sourceLayerIndex}); + } + + for (const family of layerFamilies[sourceLayerId]) { + const layer = family[0]; + + if (layer.source !== this.source) { + warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`); + } + if (layer.minzoom && this.zoom < Math.floor(layer.minzoom)) continue; + if (layer.maxzoom && this.zoom >= layer.maxzoom) continue; + if (layer.visibility === 'none') continue; + + recalculateLayers(family, this.zoom, availableImages); + + const bucket = buckets[layer.id] = layer.createBucket({ + index: featureIndex.bucketLayerIDs.length, + layers: family, + zoom: this.zoom, + pixelRatio: this.pixelRatio, + overscaling: this.overscaling, + collisionBoxArray: this.collisionBoxArray, + sourceLayerIndex, + sourceID: this.source + }); + + bucket.populate(features, options, this.tileID.canonical); + featureIndex.bucketLayerIDs.push(family.map((l) => l.id)); + } + } + + let error: Error; + let glyphMap: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }; + let iconMap: {[_: string]: StyleImage}; + let patternMap: {[_: string]: StyleImage}; + + const stacks = mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number)); + + this.inFlightDependencies.forEach((request) => request?.cancel()); + this.inFlightDependencies = []; + + // cancelling seems to be not sufficient, we seems to still manage to get a callback hit, so use a sentinel to drop stale results + const dependencySentinel = ++this.dependencySentinel; + if (Object.keys(stacks).length) { + this.inFlightDependencies.push(actor.send('getGlyphs', {uid: this.uid, stacks, source: this.source, tileID: this.tileID, type: 'glyphs'}, (err, result) => { + if (dependencySentinel !== this.dependencySentinel) { + return; + } + if (!error) { + error = err; + glyphMap = result; + maybePrepare.call(this); + } + })); + } else { + glyphMap = {}; + } + + const icons = Object.keys(options.iconDependencies); + if (icons.length) { + this.inFlightDependencies.push(actor.send('getImages', {icons, source: this.source, tileID: this.tileID, type: 'icons'}, (err, result) => { + if (dependencySentinel !== this.dependencySentinel) { + return; + } + if (!error) { + error = err; + iconMap = result; + maybePrepare.call(this); + } + })); + } else { + iconMap = {}; + } + + const patterns = Object.keys(options.patternDependencies); + if (patterns.length) { + this.inFlightDependencies.push(actor.send('getImages', {icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns'}, (err, result) => { + if (dependencySentinel !== this.dependencySentinel) { + return; + } + if (!error) { + error = err; + patternMap = result; + maybePrepare.call(this); + } + })); + } else { + patternMap = {}; + } + + maybePrepare.call(this); + + function maybePrepare() { + if (error) { + return callback(error); + } else if (glyphMap && iconMap && patternMap) { + const glyphAtlas = new GlyphAtlas(glyphMap); + const imageAtlas = new ImageAtlas(iconMap, patternMap); + + for (const key in buckets) { + const bucket = buckets[key]; + if (bucket instanceof SymbolBucket) { + recalculateLayers(bucket.layers, this.zoom, availableImages); + performSymbolLayout({ + bucket, + glyphMap, + glyphPositions: glyphAtlas.positions, + imageMap: iconMap, + imagePositions: imageAtlas.iconPositions, + showCollisionBoxes: this.showCollisionBoxes, + canonical: this.tileID.canonical + }); + } else if (bucket.hasPattern && + (bucket instanceof LineBucket || + bucket instanceof FillBucket || + bucket instanceof FillExtrusionBucket)) { + recalculateLayers(bucket.layers, this.zoom, availableImages); + bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions); + } + } + + this.status = 'done'; + callback(null, { + buckets: Object.values(buckets).filter(b => !b.isEmpty()), + featureIndex, + collisionBoxArray: this.collisionBoxArray, + glyphAtlasImage: glyphAtlas.image, + imageAtlas, + // Only used for benchmarking: + glyphMap: this.returnDependencies ? glyphMap : null, + iconMap: this.returnDependencies ? iconMap : null, + glyphPositions: this.returnDependencies ? glyphAtlas.positions : null + }); + } + } + } +} + +function recalculateLayers(layers: ReadonlyArray, zoom: number, availableImages: Array) { + // Layers are shared and may have been used by a WorkerTile with a different zoom. + const parameters = new EvaluationParameters(zoom); + for (const layer of layers) { + layer.recalculate(parameters, availableImages); + } +} diff --git a/web/libraries/maplibre-gl/src/style/create_style_layer.ts b/web/libraries/maplibre-gl/src/style/create_style_layer.ts new file mode 100644 index 00000000..25905cad --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/create_style_layer.ts @@ -0,0 +1,39 @@ +import {CircleStyleLayer} from './style_layer/circle_style_layer'; +import {HeatmapStyleLayer} from './style_layer/heatmap_style_layer'; +import {HillshadeStyleLayer} from './style_layer/hillshade_style_layer'; +import {FillStyleLayer} from './style_layer/fill_style_layer'; +import {FillExtrusionStyleLayer} from './style_layer/fill_extrusion_style_layer'; +import {LineStyleLayer} from './style_layer/line_style_layer'; +import {SymbolStyleLayer} from './style_layer/symbol_style_layer'; +import {BackgroundStyleLayer} from './style_layer/background_style_layer'; +import {RasterStyleLayer} from './style_layer/raster_style_layer'; +import {CustomStyleLayer, type CustomLayerInterface} from './style_layer/custom_style_layer'; + +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export function createStyleLayer(layer: LayerSpecification | CustomLayerInterface) { + if (layer.type === 'custom') { + return new CustomStyleLayer(layer); + } + switch (layer.type) { + case 'background': + return new BackgroundStyleLayer(layer); + case 'circle': + return new CircleStyleLayer(layer); + case 'fill': + return new FillStyleLayer(layer); + case 'fill-extrusion': + return new FillExtrusionStyleLayer(layer); + case 'heatmap': + return new HeatmapStyleLayer(layer); + case 'hillshade': + return new HillshadeStyleLayer(layer); + case 'line': + return new LineStyleLayer(layer); + case 'raster': + return new RasterStyleLayer(layer); + case 'symbol': + return new SymbolStyleLayer(layer); + } +} + diff --git a/web/libraries/maplibre-gl/src/style/evaluation_parameters.ts b/web/libraries/maplibre-gl/src/style/evaluation_parameters.ts new file mode 100644 index 00000000..0c463fd2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/evaluation_parameters.ts @@ -0,0 +1,62 @@ +import {ZoomHistory} from './zoom_history'; +import {isStringInSupportedScript} from '../util/script_detection'; +import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin'; + +import type {TransitionSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type CrossfadeParameters = { + fromScale: number; + toScale: number; + t: number; +}; + +/** + * @internal + * A parameter that can be evaluated to a value + */ +export class EvaluationParameters { + zoom: number; + now: number; + fadeDuration: number; + zoomHistory: ZoomHistory; + transition: TransitionSpecification; + + // "options" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate + constructor(zoom: number, options?: any) { + this.zoom = zoom; + + if (options) { + this.now = options.now; + this.fadeDuration = options.fadeDuration; + this.zoomHistory = options.zoomHistory; + this.transition = options.transition; + } else { + this.now = 0; + this.fadeDuration = 0; + this.zoomHistory = new ZoomHistory(); + this.transition = {}; + } + } + + isSupportedScript(str: string): boolean { + return isStringInSupportedScript(str, rtlTextPlugin.isLoaded()); + } + + crossFadingFactor() { + if (this.fadeDuration === 0) { + return 1; + } else { + return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1); + } + } + + getCrossfadeParameters(): CrossfadeParameters { + const z = this.zoom; + const fraction = z - Math.floor(z); + const t = this.crossFadingFactor(); + + return z > this.zoomHistory.lastIntegerZoom ? + {fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t} : + {fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction}; + } +} diff --git a/web/libraries/maplibre-gl/src/style/format_section_override.test.ts b/web/libraries/maplibre-gl/src/style/format_section_override.test.ts new file mode 100644 index 00000000..a3ee8d6c --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/format_section_override.test.ts @@ -0,0 +1,62 @@ +import {EvaluationContext, FormattedSection, createExpression, StyleExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec'; +import properties from './style_layer/symbol_style_layer_properties.g'; +import {PossiblyEvaluatedPropertyValue} from './properties'; +import {FormatSectionOverride} from './format_section_override'; +import {EvaluationParameters} from './evaluation_parameters'; + +describe('evaluate', () => { + + test('override constant', () => { + const defaultColor = {'r': 0, 'g': 1, 'b': 0, 'a': 1}; + const overridenColor = {'r': 1, 'g': 0, 'b': 0, 'a': 1}; + const overriden = new PossiblyEvaluatedPropertyValue( + properties.paint.properties['text-color'], + {kind: 'constant', value: defaultColor}, + {zoom: 0, zoomHistory: {}} as EvaluationParameters + ); + + const override = new FormatSectionOverride(overriden); + const ctx = new EvaluationContext(); + ctx.feature = {} as any; + ctx.featureState = {}; + expect(override.evaluate(ctx)).toEqual(defaultColor); + + ctx.formattedSection = {textColor: overridenColor} as FormattedSection; + expect(override.evaluate(ctx)).toEqual(overridenColor); + + }); + + test('override expression', () => { + const warn = console.warn; + console.warn = (_) => {}; + const defaultColor = {'r': 0, 'g': 0, 'b': 0, 'a': 1}; + const propertyColor = {'r': 1, 'g': 0, 'b': 0, 'a': 1}; + const overridenColor = {'r': 0, 'g': 0, 'b': 1, 'a': 1}; + const styleExpr = createExpression( + ['get', 'color'], + properties.paint.properties['text-color'].specification); + + const sourceExpr = new ZoomConstantExpression('source', styleExpr.value as StyleExpression); + const overriden = new PossiblyEvaluatedPropertyValue( + properties.paint.properties['text-color'], + sourceExpr, + {zoom: 0, zoomHistory: {}} as EvaluationParameters + ); + + const override = new FormatSectionOverride(overriden); + const ctx = new EvaluationContext(); + ctx.feature = {properties: {}} as any; + ctx.featureState = {}; + + expect(override.evaluate(ctx)).toEqual(defaultColor); + + ctx.feature.properties.color = 'red'; + expect(override.evaluate(ctx)).toEqual(propertyColor); + + ctx.formattedSection = {textColor: overridenColor} as FormattedSection; + expect(override.evaluate(ctx)).toEqual(overridenColor); + + console.warn = warn; + }); + +}); diff --git a/web/libraries/maplibre-gl/src/style/format_section_override.ts b/web/libraries/maplibre-gl/src/style/format_section_override.ts new file mode 100644 index 00000000..ca132826 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/format_section_override.ts @@ -0,0 +1,50 @@ +import type {Expression, EvaluationContext, Type, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec'; +import {NullType} from '@maplibre/maplibre-gl-style-spec'; +import {PossiblyEvaluatedPropertyValue} from './properties'; +import {register} from '../util/web_worker_transfer'; + +// This is an internal expression class. It is only used in GL JS and +// has GL JS dependencies which can break the standalone style-spec module +export class FormatSectionOverride implements Expression { + type: Type; + defaultValue: PossiblyEvaluatedPropertyValue; + + constructor(defaultValue: PossiblyEvaluatedPropertyValue) { + if (defaultValue.property.overrides === undefined) throw new Error('overrides must be provided to instantiate FormatSectionOverride class'); + this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType; + this.defaultValue = defaultValue; + } + + evaluate(ctx: EvaluationContext) { + if (ctx.formattedSection) { + const overrides = this.defaultValue.property.overrides; + if (overrides && overrides.hasOverride(ctx.formattedSection)) { + return overrides.getOverride(ctx.formattedSection); + } + } + + if (ctx.feature && ctx.featureState) { + return this.defaultValue.evaluate(ctx.feature, ctx.featureState); + } + + return this.defaultValue.property.specification.default; + } + + eachChild(fn: (_: Expression) => void) { + if (!this.defaultValue.isConstant()) { + const expr: ZoomConstantExpression<'source'> = (this.defaultValue.value as any); + fn(expr._styleExpression.expression); + } + } + + // Cannot be statically evaluated, as the output depends on the evaluation context. + outputDefined() { + return false; + } + + serialize() { + return null; + } +} + +register('FormatSectionOverride', FormatSectionOverride, {omit: ['defaultValue']}); diff --git a/web/libraries/maplibre-gl/src/style/light.test.ts b/web/libraries/maplibre-gl/src/style/light.test.ts new file mode 100644 index 00000000..f022a7b9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/light.test.ts @@ -0,0 +1,86 @@ +import {Light} from './light'; +import {Color, latest as styleSpec, LightSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {sphericalToCartesian} from '../util/util'; +import {EvaluationParameters} from './evaluation_parameters'; +import {TransitionParameters} from './properties'; + +const spec = styleSpec.light; + +test('Light with defaults', () => { + const light = new Light({}); + light.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters); + + expect(light.properties.get('anchor')).toEqual(spec.anchor.default); + expect(light.properties.get('position')).toEqual(sphericalToCartesian(spec.position.default as any as [number, number, number])); + expect(light.properties.get('intensity')).toEqual(spec.intensity.default); + expect(light.properties.get('color')).toEqual(Color.parse(spec.color.default)); +}); + +test('Light with options', () => { + const light = new Light({ + anchor: 'map', + position: [2, 30, 30], + intensity: 1 + }); + light.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters); + + expect(light.properties.get('anchor')).toBe('map'); + expect(light.properties.get('position')).toEqual(sphericalToCartesian([2, 30, 30])); + expect(light.properties.get('intensity')).toBe(1); + expect(light.properties.get('color')).toEqual(Color.parse(spec.color.default)); +}); + +test('Light with stops function', () => { + const light = new Light({ + intensity: { + stops: [[16, 0.2], [17, 0.8]] + } + } as LightSpecification); + light.recalculate({zoom: 16.5, zoomHistory: {}} as EvaluationParameters); + + expect(light.properties.get('intensity')).toBe(0.5); +}); + +test('Light#getLight', () => { + const defaults = {}; + for (const key in spec) { + defaults[key] = spec[key].default; + } + + expect(new Light(defaults).getLight()).toEqual(defaults); +}); + +describe('Light#setLight', () => { + test('sets light', () => { + const light = new Light({}); + light.setLight({color: 'red', 'color-transition': {duration: 3000}} as LightSpecification); + light.updateTransitions({transition: true} as any as TransitionParameters); + light.recalculate({zoom: 16, zoomHistory: {}, now: 1500} as EvaluationParameters); + expect(light.properties.get('color')).toEqual(new Color(1, 0.5, 0.5, 1)); + }); + + test('validates by default', () => { + const light = new Light({}); + const lightSpy = jest.spyOn(light, '_validate'); + jest.spyOn(console, 'error').mockImplementation(() => { }); + light.setLight({color: 'notacolor'}); + light.updateTransitions({transition: false} as any as TransitionParameters); + light.recalculate({zoom: 16, zoomHistory: {}, now: 10} as EvaluationParameters); + expect(lightSpy).toHaveBeenCalledTimes(1); + expect(console.error).toHaveBeenCalledTimes(1); + expect(lightSpy.mock.calls[0][2]).toEqual({}); + }); + + test('respects validation option', () => { + const light = new Light({}); + + const lightSpy = jest.spyOn(light, '_validate'); + light.setLight({color: [999]} as any, {validate: false}); + light.updateTransitions({transition: false} as any as TransitionParameters); + light.recalculate({zoom: 16, zoomHistory: {}, now: 10} as EvaluationParameters); + + expect(lightSpy).toHaveBeenCalledTimes(1); + expect(lightSpy.mock.calls[0][2]).toEqual({validate: false}); + expect(light.properties.get('color')).toEqual([999]); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/light.ts b/web/libraries/maplibre-gl/src/style/light.ts new file mode 100644 index 00000000..bfefb0f0 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/light.ts @@ -0,0 +1,135 @@ +import {interpolates, Color, latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import {extend, sphericalToCartesian} from '../util/util'; +import {Evented} from '../util/evented'; +import { + validateStyle, + validateLight, + emitValidationErrors +} from './validate_style'; + +import type {StylePropertySpecification, LightSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {EvaluationParameters} from './evaluation_parameters'; +import type {StyleSetterOptions} from '../style/style'; +import {Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty} from './properties'; + +import type { + Property, + PropertyValue, + TransitionParameters +} from './properties'; + +type LightPosition = { + x: number; + y: number; + z: number; +}; + +class LightPositionProperty implements Property<[number, number, number], LightPosition> { + specification: StylePropertySpecification; + + constructor() { + this.specification = styleSpec.light.position as StylePropertySpecification; + } + + possiblyEvaluate( + value: PropertyValue<[number, number, number], LightPosition>, + parameters: EvaluationParameters + ): LightPosition { + return sphericalToCartesian(value.expression.evaluate(parameters)); + } + + interpolate(a: LightPosition, b: LightPosition, t: number): LightPosition { + return { + x: interpolates.number(a.x, b.x, t), + y: interpolates.number(a.y, b.y, t), + z: interpolates.number(a.z, b.z, t), + }; + } +} + +type Props = { + 'anchor': DataConstantProperty<'map' | 'viewport'>; + 'position': LightPositionProperty; + 'color': DataConstantProperty; + 'intensity': DataConstantProperty; +}; + +type PropsPossiblyEvaluated = { + 'anchor': 'map' | 'viewport'; + 'position': LightPosition; + 'color': Color; + 'intensity': number; +}; + +const TRANSITION_SUFFIX = '-transition'; + +let lightProperties: Properties; + +/* + * Represents the light used to light extruded features. + */ +export class Light extends Evented { + _transitionable: Transitionable; + _transitioning: Transitioning; + properties: PossiblyEvaluated; + + constructor(lightOptions?: LightSpecification) { + super(); + lightProperties = lightProperties || new Properties({ + 'anchor': new DataConstantProperty(styleSpec.light.anchor as StylePropertySpecification), + 'position': new LightPositionProperty(), + 'color': new DataConstantProperty(styleSpec.light.color as StylePropertySpecification), + 'intensity': new DataConstantProperty(styleSpec.light.intensity as StylePropertySpecification), + }); + this._transitionable = new Transitionable(lightProperties); + this.setLight(lightOptions); + this._transitioning = this._transitionable.untransitioned(); + } + + getLight(): LightSpecification { + return this._transitionable.serialize(); + } + + setLight(light?: LightSpecification, options: StyleSetterOptions = {}) { + if (this._validate(validateLight, light, options)) { + return; + } + + for (const name in light) { + const value = light[name]; + if (name.endsWith(TRANSITION_SUFFIX)) { + this._transitionable.setTransition(name.slice(0, -TRANSITION_SUFFIX.length) as keyof Props, value); + } else { + this._transitionable.setValue(name as keyof Props, value); + } + } + } + + updateTransitions(parameters: TransitionParameters) { + this._transitioning = this._transitionable.transitioned(parameters, this._transitioning); + } + + hasTransition() { + return this._transitioning.hasTransition(); + } + + recalculate(parameters: EvaluationParameters) { + this.properties = this._transitioning.possiblyEvaluate(parameters); + } + + _validate(validate: Function, value: unknown, options?: { + validate?: boolean; + }) { + if (options && options.validate === false) { + return false; + } + + return emitValidationErrors(this, validate.call(validateStyle, extend({ + value, + // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407 + style: {glyphs: true, sprite: true}, + styleSpec + }))); + } +} diff --git a/web/libraries/maplibre-gl/src/style/load_glyph_range.test.ts b/web/libraries/maplibre-gl/src/style/load_glyph_range.test.ts new file mode 100644 index 00000000..12500f9e --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/load_glyph_range.test.ts @@ -0,0 +1,41 @@ +import fs from 'fs'; +import path from 'path'; +import {RequestManager} from '../util/request_manager'; +import {loadGlyphRange} from './load_glyph_range'; +import {fakeServer} from 'nise'; +import {bufferToArrayBuffer} from '../util/test/util'; + +test('loadGlyphRange', done => { + global.fetch = null; + + const transform = jest.fn().mockImplementation((url) => { + return {url}; + }); + + const manager = new RequestManager(transform); + + const server = fakeServer.create(); + server.respondWith(bufferToArrayBuffer(fs.readFileSync(path.join(__dirname, '../../test/unit/assets/0-255.pbf')))); + + loadGlyphRange('Arial Unicode MS', 0, 'https://localhost/fonts/v1/{fontstack}/{range}.pbf', manager, (err, result) => { + expect(err).toBeFalsy(); + expect(transform).toHaveBeenCalledTimes(1); + expect(transform).toHaveBeenCalledWith('https://localhost/fonts/v1/Arial Unicode MS/0-255.pbf', 'Glyphs'); + + expect(Object.keys(result)).toHaveLength(223); + for (const key in result) { + const id = Number(key); + const glyph = result[id]; + + expect(glyph.id).toBe(Number(id)); + expect(glyph.metrics).toBeTruthy(); + expect(typeof glyph.metrics.width).toBe('number'); + expect(typeof glyph.metrics.height).toBe('number'); + expect(typeof glyph.metrics.top).toBe('number'); + expect(typeof glyph.metrics.advance).toBe('number'); + } + done(); + }); + server.respond(); + expect(server.requests[0].url).toBe('https://localhost/fonts/v1/Arial Unicode MS/0-255.pbf'); +}); diff --git a/web/libraries/maplibre-gl/src/style/load_glyph_range.ts b/web/libraries/maplibre-gl/src/style/load_glyph_range.ts new file mode 100644 index 00000000..6a454caa --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/load_glyph_range.ts @@ -0,0 +1,38 @@ +import {getArrayBuffer} from '../util/ajax'; +import {ResourceType} from '../util/request_manager'; + +import {parseGlyphPbf} from './parse_glyph_pbf'; + +import type {StyleGlyph} from './style_glyph'; +import type {RequestManager} from '../util/request_manager'; +import type {Callback} from '../types/callback'; + +export function loadGlyphRange(fontstack: string, + range: number, + urlTemplate: string, + requestManager: RequestManager, + callback: Callback<{ + [_: number]: StyleGlyph | null; + }>) { + const begin = range * 256; + const end = begin + 255; + + const request = requestManager.transformRequest( + urlTemplate.replace('{fontstack}', fontstack).replace('{range}', `${begin}-${end}`), + ResourceType.Glyphs + ); + + getArrayBuffer(request, (err?: Error | null, data?: ArrayBuffer | null) => { + if (err) { + callback(err); + } else if (data) { + const glyphs = {}; + + for (const glyph of parseGlyphPbf(data)) { + glyphs[glyph.id] = glyph; + } + + callback(null, glyphs); + } + }); +} diff --git a/web/libraries/maplibre-gl/src/style/load_sprite.test.ts b/web/libraries/maplibre-gl/src/style/load_sprite.test.ts new file mode 100644 index 00000000..6aaa068f --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/load_sprite.test.ts @@ -0,0 +1,186 @@ +import fs from 'fs'; +import path from 'path'; +import {RequestManager} from '../util/request_manager'; +import {loadSprite} from './load_sprite'; +import {type FakeServer, fakeServer} from 'nise'; +import * as util from '../util/util'; +import {bufferToArrayBuffer} from '../util/test/util'; + +describe('loadSprite', () => { + + let server: FakeServer; + + beforeEach(() => { + jest.spyOn(util, 'arrayBufferToImageBitmap').mockImplementation((data: ArrayBuffer, callback: (err?: Error | null, image?: ImageBitmap | null) => void) => { + createImageBitmap(new ImageData(1024, 824)).then((imgBitmap) => { + callback(null, imgBitmap); + }).catch((e) => { + callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)); + }); + }); + global.fetch = null; + server = fakeServer.create(); + }); + + test('backwards compatibility: single string is treated as a URL for the default sprite', done => { + const transform = jest.fn().mockImplementation((url, type) => { + return {url, type}; + }); + + const manager = new RequestManager(transform); + + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1.json', fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.json')).toString()); + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1.png', bufferToArrayBuffer(fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.png')))); + + loadSprite('http://localhost:9966/test/unit/assets/sprite1', manager, 1, (err, result) => { + expect(err).toBeFalsy(); + + expect(transform).toHaveBeenCalledTimes(2); + expect(transform).toHaveBeenNthCalledWith(1, 'http://localhost:9966/test/unit/assets/sprite1.json', 'SpriteJSON'); + expect(transform).toHaveBeenNthCalledWith(2, 'http://localhost:9966/test/unit/assets/sprite1.png', 'SpriteImage'); + + expect(Object.keys(result)).toHaveLength(1); + expect(Object.keys(result)[0]).toBe('default'); + + Object.values(result['default']).forEach(styleImage => { + expect(styleImage.spriteData).toBeTruthy(); + expect(styleImage.spriteData.context).toBeInstanceOf(CanvasRenderingContext2D); + }); + + done(); + }); + + server.respond(); + + expect(server.requests[0].url).toBe('http://localhost:9966/test/unit/assets/sprite1.json'); + expect(server.requests[1].url).toBe('http://localhost:9966/test/unit/assets/sprite1.png'); + }); + + test('array of objects support', done => { + const transform = jest.fn().mockImplementation((url, type) => { + return {url, type}; + }); + + const manager = new RequestManager(transform); + + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1.json', fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.json')).toString()); + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1.png', bufferToArrayBuffer(fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.png')))); + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite2.json', fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite2.json')).toString()); + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite2.png', bufferToArrayBuffer(fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite2.png')))); + + loadSprite([{id: 'sprite1', url: 'http://localhost:9966/test/unit/assets/sprite1'}, {id: 'sprite2', url: 'http://localhost:9966/test/unit/assets/sprite2'}], manager, 1, (err, result) => { + expect(err).toBeFalsy(); + + expect(transform).toHaveBeenCalledTimes(4); + expect(transform).toHaveBeenNthCalledWith(1, 'http://localhost:9966/test/unit/assets/sprite1.json', 'SpriteJSON'); + expect(transform).toHaveBeenNthCalledWith(2, 'http://localhost:9966/test/unit/assets/sprite1.png', 'SpriteImage'); + expect(transform).toHaveBeenNthCalledWith(3, 'http://localhost:9966/test/unit/assets/sprite2.json', 'SpriteJSON'); + expect(transform).toHaveBeenNthCalledWith(4, 'http://localhost:9966/test/unit/assets/sprite2.png', 'SpriteImage'); + + expect(Object.keys(result)).toHaveLength(2); + expect(Object.keys(result)[0]).toBe('sprite1'); + expect(Object.keys(result)[1]).toBe('sprite2'); + + Object.values(result['sprite1']).forEach(styleImage => { + expect(styleImage.spriteData).toBeTruthy(); + expect(styleImage.spriteData.context).toBeInstanceOf(CanvasRenderingContext2D); + }); + + Object.values(result['sprite2']).forEach(styleImage => { + expect(styleImage.spriteData).toBeTruthy(); + expect(styleImage.spriteData.context).toBeInstanceOf(CanvasRenderingContext2D); + }); + + done(); + }); + + server.respond(); + expect(server.requests[0].url).toBe('http://localhost:9966/test/unit/assets/sprite1.json'); + expect(server.requests[1].url).toBe('http://localhost:9966/test/unit/assets/sprite1.png'); + expect(server.requests[2].url).toBe('http://localhost:9966/test/unit/assets/sprite2.json'); + expect(server.requests[3].url).toBe('http://localhost:9966/test/unit/assets/sprite2.png'); + }); + + test('error in callback', done => { + const transform = jest.fn().mockImplementation((url, type) => { + return {url, type}; + }); + + const manager = new RequestManager(transform); + + server.respondWith((xhr) => xhr.respond(500)); + let last = false; + loadSprite([{id: 'sprite1', url: 'http://localhost:9966/test/unit/assets/sprite1'}], manager, 1, (err, result) => { + expect(err).toBeTruthy(); + expect(result).toBeUndefined(); + if (!last) { + done(); + last = true; + } + }); + + server.respond(); + expect(server.requests[0].url).toBe('http://localhost:9966/test/unit/assets/sprite1.json'); + }); + + test('request canceling', done => { + const transform = jest.fn().mockImplementation((url, type) => { + return {url, type}; + }); + + const manager = new RequestManager(transform); + + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1.json', fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.json')).toString()); + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1.png', bufferToArrayBuffer(fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.png')))); + + const cancelable = loadSprite([{id: 'sprite1', url: 'http://localhost:9966/test/unit/assets/sprite1'}], manager, 1, () => {}); + + setTimeout(() => { + cancelable.cancel(); + + expect((server.requests[0] as any).aborted).toBeTruthy(); + expect((server.requests[1] as any).aborted).toBeTruthy(); + + done(); + }); + + setTimeout(() => { + server.respond(); + expect(server.requests[0].url).toBe('http://localhost:9966/test/unit/assets/sprite1.json'); + expect(server.requests[1].url).toBe('http://localhost:9966/test/unit/assets/sprite1.png'); + }, 10); + }); + + test('pixelRatio is respected', done => { + const transform = jest.fn().mockImplementation((url, type) => { + return {url, type}; + }); + + const manager = new RequestManager(transform); + + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1@2x.json', fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.json')).toString()); + server.respondWith('GET', 'http://localhost:9966/test/unit/assets/sprite1@2x.png', bufferToArrayBuffer(fs.readFileSync(path.join(__dirname, '../../test/unit/assets/sprite1.png')))); + + loadSprite('http://localhost:9966/test/unit/assets/sprite1', manager, 2, (err, result) => { + expect(err).toBeFalsy(); + + expect(transform).toHaveBeenCalledTimes(2); + expect(transform).toHaveBeenNthCalledWith(1, 'http://localhost:9966/test/unit/assets/sprite1@2x.json', 'SpriteJSON'); + expect(transform).toHaveBeenNthCalledWith(2, 'http://localhost:9966/test/unit/assets/sprite1@2x.png', 'SpriteImage'); + + expect(Object.keys(result)).toHaveLength(1); + expect(Object.keys(result)[0]).toBe('default'); + + Object.values(result['default']).forEach(styleImage => { + expect(styleImage.spriteData).toBeTruthy(); + expect(styleImage.spriteData.context).toBeInstanceOf(CanvasRenderingContext2D); + }); + + done(); + }); + + server.respond(); + expect(server.requests[0].url).toBe('http://localhost:9966/test/unit/assets/sprite1@2x.json'); + expect(server.requests[1].url).toBe('http://localhost:9966/test/unit/assets/sprite1@2x.png'); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/load_sprite.ts b/web/libraries/maplibre-gl/src/style/load_sprite.ts new file mode 100644 index 00000000..2a36afe7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/load_sprite.ts @@ -0,0 +1,94 @@ +import {getJSON} from '../util/ajax'; +import {ImageRequest} from '../util/image_request'; +import {ResourceType} from '../util/request_manager'; + +import {browser} from '../util/browser'; +import {coerceSpriteToArray} from '../util/style'; + +import type {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {StyleImage} from './style_image'; +import type {RequestManager} from '../util/request_manager'; +import type {Callback} from '../types/callback'; +import type {Cancelable} from '../types/cancelable'; + +export function loadSprite( + originalSprite: SpriteSpecification, + requestManager: RequestManager, + pixelRatio: number, + callback: Callback<{[spriteName: string]: {[id: string]: StyleImage}}> +): Cancelable { + const spriteArray = coerceSpriteToArray(originalSprite); + const spriteArrayLength = spriteArray.length; + const format = pixelRatio > 1 ? '@2x' : ''; + + const combinedRequestsMap: {[requestKey: string]: Cancelable} = {}; + const jsonsMap: {[id: string]: any} = {}; + const imagesMap: {[id: string]: (HTMLImageElement | ImageBitmap)} = {}; + + for (const {id, url} of spriteArray) { + const jsonRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.json'), ResourceType.SpriteJSON); + const jsonRequestKey = `${id}_${jsonRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique + combinedRequestsMap[jsonRequestKey] = getJSON(jsonRequestParameters, (err?: Error | null, data?: any | null) => { + delete combinedRequestsMap[jsonRequestKey]; + jsonsMap[id] = data; + doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength); + }); + + const imageRequestParameters = requestManager.transformRequest(requestManager.normalizeSpriteURL(url, format, '.png'), ResourceType.SpriteImage); + const imageRequestKey = `${id}_${imageRequestParameters.url}`; // use id_url as requestMap key to make sure it is unique + combinedRequestsMap[imageRequestKey] = ImageRequest.getImage(imageRequestParameters, (err, img) => { + delete combinedRequestsMap[imageRequestKey]; + imagesMap[id] = img; + doOnceCompleted(callback, jsonsMap, imagesMap, err, spriteArrayLength); + }); + } + + return { + cancel() { + for (const requst of Object.values(combinedRequestsMap)) { + requst.cancel(); + } + } + }; +} + +/** + * @param callbackFunc - the callback function (both erro and success) + * @param jsonsMap - JSON data map + * @param imagesMap - image data map + * @param err - error object + * @param expectedResultCounter - number of expected JSON or Image results when everything is finished, respectively. + */ +function doOnceCompleted( + callbackFunc:Callback<{[spriteName: string]: {[id: string]: StyleImage}}>, + jsonsMap:{[id: string]: any}, + imagesMap:{[id: string]: (HTMLImageElement | ImageBitmap)}, + err: Error, + expectedResultCounter: number): void { + + if (err) { + callbackFunc(err); + return; + } + + if (expectedResultCounter !== Object.values(jsonsMap).length || expectedResultCounter !== Object.values(imagesMap).length) { + // not done yet, nothing to do + return; + } + + const result = {} as {[spriteName: string]: {[id: string]: StyleImage}}; + for (const spriteName in jsonsMap) { + result[spriteName] = {}; + + const context = browser.getImageCanvasContext(imagesMap[spriteName]); + const json = jsonsMap[spriteName]; + + for (const id in json) { + const {width, height, x, y, sdf, pixelRatio, stretchX, stretchY, content} = json[id]; + const spriteData = {width, height, x, y, context}; + result[spriteName][id] = {data: null, pixelRatio, sdf, stretchX, stretchY, content, spriteData}; + } + } + + callbackFunc(null, result); +} diff --git a/web/libraries/maplibre-gl/src/style/parse_glyph_pbf.ts b/web/libraries/maplibre-gl/src/style/parse_glyph_pbf.ts new file mode 100644 index 00000000..10fefb2a --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/parse_glyph_pbf.ts @@ -0,0 +1,42 @@ +import {AlphaImage} from '../util/image'; + +import Protobuf from 'pbf'; +const border = 3; + +import type {StyleGlyph} from './style_glyph'; + +function readFontstacks(tag: number, glyphs: Array, pbf: Protobuf) { + if (tag === 1) { + pbf.readMessage(readFontstack, glyphs); + } +} + +function readFontstack(tag: number, glyphs: Array, pbf: Protobuf) { + if (tag === 3) { + const {id, bitmap, width, height, left, top, advance} = pbf.readMessage(readGlyph, {}); + glyphs.push({ + id, + bitmap: new AlphaImage({ + width: width + 2 * border, + height: height + 2 * border + }, bitmap), + metrics: {width, height, left, top, advance} + }); + } +} + +function readGlyph(tag: number, glyph: any, pbf: Protobuf) { + if (tag === 1) glyph.id = pbf.readVarint(); + else if (tag === 2) glyph.bitmap = pbf.readBytes(); + else if (tag === 3) glyph.width = pbf.readVarint(); + else if (tag === 4) glyph.height = pbf.readVarint(); + else if (tag === 5) glyph.left = pbf.readSVarint(); + else if (tag === 6) glyph.top = pbf.readSVarint(); + else if (tag === 7) glyph.advance = pbf.readVarint(); +} + +export function parseGlyphPbf(data: ArrayBuffer | Uint8Array): Array { + return new Protobuf(data).readFields(readFontstacks, []); +} + +export const GLYPH_PBF_BORDER = border; diff --git a/web/libraries/maplibre-gl/src/style/pauseable_placement.ts b/web/libraries/maplibre-gl/src/style/pauseable_placement.ts new file mode 100644 index 00000000..bd9f2269 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/pauseable_placement.ts @@ -0,0 +1,137 @@ +import {browser} from '../util/browser'; + +import {Placement} from '../symbol/placement'; + +import type {Transform} from '../geo/transform'; +import type {StyleLayer} from './style_layer'; +import type {SymbolStyleLayer} from './style_layer/symbol_style_layer'; +import type {Tile} from '../source/tile'; +import type {BucketPart} from '../symbol/placement'; +import {Terrain} from '../render/terrain'; + +class LayerPlacement { + _sortAcrossTiles: boolean; + _currentTileIndex: number; + _currentPartIndex: number; + _seenCrossTileIDs: { + [k in string | number]: boolean; + }; + _bucketParts: Array; + + constructor(styleLayer: SymbolStyleLayer) { + this._sortAcrossTiles = styleLayer.layout.get('symbol-z-order') !== 'viewport-y' && + !styleLayer.layout.get('symbol-sort-key').isConstant(); + + this._currentTileIndex = 0; + this._currentPartIndex = 0; + this._seenCrossTileIDs = {}; + this._bucketParts = []; + } + + continuePlacement(tiles: Array, placement: Placement, showCollisionBoxes: boolean, styleLayer: StyleLayer, shouldPausePlacement: () => boolean) { + + const bucketParts = this._bucketParts; + + while (this._currentTileIndex < tiles.length) { + const tile = tiles[this._currentTileIndex]; + placement.getBucketParts(bucketParts, styleLayer, tile, this._sortAcrossTiles); + + this._currentTileIndex++; + if (shouldPausePlacement()) { + return true; + } + } + + if (this._sortAcrossTiles) { + this._sortAcrossTiles = false; + bucketParts.sort((a, b) => (a.sortKey as any as number) - (b.sortKey as any as number)); + } + + while (this._currentPartIndex < bucketParts.length) { + const bucketPart = bucketParts[this._currentPartIndex]; + placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes); + + this._currentPartIndex++; + if (shouldPausePlacement()) { + return true; + } + } + return false; + } +} + +export class PauseablePlacement { + placement: Placement; + _done: boolean; + _currentPlacementIndex: number; + _forceFullPlacement: boolean; + _showCollisionBoxes: boolean; + _inProgressLayer: LayerPlacement; + + constructor( + transform: Transform, + terrain: Terrain, + order: Array, + forceFullPlacement: boolean, + showCollisionBoxes: boolean, + fadeDuration: number, + crossSourceCollisions: boolean, + prevPlacement?: Placement + ) { + this.placement = new Placement(transform, terrain, fadeDuration, crossSourceCollisions, prevPlacement); + this._currentPlacementIndex = order.length - 1; + this._forceFullPlacement = forceFullPlacement; + this._showCollisionBoxes = showCollisionBoxes; + this._done = false; + } + + isDone() { + return this._done; + } + + continuePlacement( + order: Array, + layers: {[_: string]: StyleLayer}, + layerTiles: {[_: string]: Array} + ) { + const startTime = browser.now(); + + const shouldPausePlacement = () => { + return this._forceFullPlacement ? false : (browser.now() - startTime) > 2; + }; + + while (this._currentPlacementIndex >= 0) { + const layerId = order[this._currentPlacementIndex]; + const layer = layers[layerId]; + const placementZoom = this.placement.collisionIndex.transform.zoom; + if (layer.type === 'symbol' && + (!layer.minzoom || layer.minzoom <= placementZoom) && + (!layer.maxzoom || layer.maxzoom > placementZoom)) { + + if (!this._inProgressLayer) { + this._inProgressLayer = new LayerPlacement(layer as any as SymbolStyleLayer); + } + + const pausePlacement = this._inProgressLayer.continuePlacement(layerTiles[layer.source], this.placement, this._showCollisionBoxes, layer, shouldPausePlacement); + + if (pausePlacement) { + // We didn't finish placing all layers within 2ms, + // but we can keep rendering with a partial placement + // We'll resume here on the next frame + return; + } + + delete this._inProgressLayer; + } + + this._currentPlacementIndex--; + } + + this._done = true; + } + + commit(now: number) { + this.placement.commit(now); + return this.placement; + } +} diff --git a/web/libraries/maplibre-gl/src/style/properties.ts b/web/libraries/maplibre-gl/src/style/properties.ts new file mode 100644 index 00000000..ba95b37a --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/properties.ts @@ -0,0 +1,726 @@ +import {clone, extend, easeCubicInOut} from '../util/util'; +import {interpolates, Color, StylePropertySpecification, normalizePropertyExpression, + Feature, + FeatureState, + StylePropertyExpression, + SourceExpression, + CompositeExpression, TransitionSpecification, + PropertyValueSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {register} from '../util/web_worker_transfer'; +import {EvaluationParameters} from './evaluation_parameters'; + +import {CanonicalTileID} from '../source/tile_id'; + +type TimePoint = number; + +/** + * A from-to type + */ +export type CrossFaded = { + to: T; + from: T; +}; + +/** + * @internal + * Implementations of the `Property` interface: + * + * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value, + * the default value, etc. This comes from the style specification JSON. + * * Define behavior that needs to be polymorphic across different properties: "possibly evaluating" + * an input value (see below), and interpolating between two possibly-evaluted values. + * + * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`). + * The type `R` is the intermediate "possibly evaluated" value type. See below. + * + * There are two main implementations of the interface -- one for properties that allow data-driven values, + * and one for properties that don't. There are a few "special case" implementations as well: one for properties + * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`, + * and one for `light-position`. + */ +export interface Property { + specification: StylePropertySpecification; + possiblyEvaluate( + value: PropertyValue, + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): R; + interpolate(a: R, b: R, t: number): R; +} + +/** + * @internal + * `PropertyValue` represents the value part of a property key-value unit. It's used to represent both + * paint and layout property values, and regardless of whether or not their property supports data-driven + * expressions. + * + * `PropertyValue` stores the raw input value as seen in a style or a runtime styling API call, i.e. one of the + * following: + * + * * A constant value of the type appropriate for the property + * * A function which produces a value of that type (but functions are quasi-deprecated in favor of expressions) + * * An expression which produces a value of that type + * * "undefined"/"not present", in which case the property is assumed to take on its default value. + * + * In addition to storing the original input value, `PropertyValue` also stores a normalized representation, + * effectively treating functions as if they are expressions, and constant or default values as if they are + * (constant) expressions. + */ +export class PropertyValue { + property: Property; + value: PropertyValueSpecification | void; + expression: StylePropertyExpression; + + constructor(property: Property, value: PropertyValueSpecification | void) { + this.property = property; + this.value = value; + this.expression = normalizePropertyExpression(value === undefined ? property.specification.default : value, property.specification); + } + + isDataDriven(): boolean { + return this.expression.kind === 'source' || this.expression.kind === 'composite'; + } + + possiblyEvaluate( + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): R { + return this.property.possiblyEvaluate(this, parameters, canonical, availableImages); + } +} + +export type TransitionParameters = { + now: TimePoint; + transition: TransitionSpecification; +}; + +/** + * @internal + * Paint properties are _transitionable_: they can change in a fluid manner, interpolating or cross-fading between + * old and new value. The duration of the transition, and the delay before it begins, is configurable. + * + * `TransitionablePropertyValue` is a compositional class that stores both the property value and that transition + * configuration. + * + * A `TransitionablePropertyValue` can calculate the next step in the evaluation chain for paint property values: + * `TransitioningPropertyValue`. + */ +class TransitionablePropertyValue { + property: Property; + value: PropertyValue; + transition: TransitionSpecification | void; + + constructor(property: Property) { + this.property = property; + this.value = new PropertyValue(property, undefined); + } + + transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue): TransitioningPropertyValue { + return new TransitioningPropertyValue(this.property, this.value, prior, + extend({}, parameters.transition, this.transition), parameters.now); + } + + untransitioned(): TransitioningPropertyValue { + return new TransitioningPropertyValue(this.property, this.value, null, {}, 0); + } +} + +/** + * @internal + * `Transitionable` stores a map of all (property name, `TransitionablePropertyValue`) pairs for paint properties of a + * given layer type. It can calculate the `TransitioningPropertyValue`s for all of them at once, producing a + * `Transitioning` instance for the same set of properties. + */ +export class Transitionable { + _properties: Properties; + _values: {[K in keyof Props]: TransitionablePropertyValue}; + + constructor(properties: Properties) { + this._properties = properties; + this._values = (Object.create(properties.defaultTransitionablePropertyValues) as any); + } + + getValue(name: S): PropertyValueSpecification | void { + return clone(this._values[name].value.value); + } + + setValue(name: S, value: PropertyValueSpecification | void) { + if (!Object.prototype.hasOwnProperty.call(this._values, name)) { + this._values[name] = new TransitionablePropertyValue(this._values[name].property); + } + // Note that we do not _remove_ an own property in the case where a value is being reset + // to the default: the transition might still be non-default. + this._values[name].value = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value)); + } + + getTransition(name: S): TransitionSpecification | void { + return clone(this._values[name].transition); + } + + setTransition(name: S, value: TransitionSpecification | void) { + if (!Object.prototype.hasOwnProperty.call(this._values, name)) { + this._values[name] = new TransitionablePropertyValue(this._values[name].property); + } + this._values[name].transition = clone(value) || undefined; + } + + serialize() { + const result: any = {}; + for (const property of Object.keys(this._values)) { + const value = this.getValue(property as keyof Props); + if (value !== undefined) { + result[property] = value; + } + + const transition = this.getTransition(property as keyof Props); + if (transition !== undefined) { + result[`${property}-transition`] = transition; + } + } + return result; + } + + transitioned(parameters: TransitionParameters, prior: Transitioning): Transitioning { + const result = new Transitioning(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].transitioned(parameters, prior._values[property]); + } + return result; + } + + untransitioned(): Transitioning { + const result = new Transitioning(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].untransitioned(); + } + return result; + } +} + +/** + * @internal + * `TransitioningPropertyValue` implements the first of two intermediate steps in the evaluation chain of a paint + * property value. In this step, transitions between old and new values are handled: as long as the transition is in + * progress, `TransitioningPropertyValue` maintains a reference to the prior value, and interpolates between it and + * the new value based on the current time and the configured transition duration and delay. The product is the next + * step in the evaluation chain: the "possibly evaluated" result type `R`. See below for more on this concept. + */ +class TransitioningPropertyValue { + property: Property; + value: PropertyValue; + prior: TransitioningPropertyValue; + begin: TimePoint; + end: TimePoint; + + constructor(property: Property, + value: PropertyValue, + prior: TransitioningPropertyValue, + transition: TransitionSpecification, + now: TimePoint) { + this.property = property; + this.value = value; + this.begin = now + transition.delay || 0; + this.end = this.begin + transition.duration || 0; + if (property.specification.transition && (transition.delay || transition.duration)) { + this.prior = prior; + } + } + + possiblyEvaluate( + parameters: EvaluationParameters, + canonical: CanonicalTileID, + availableImages: Array + ): R { + const now = parameters.now || 0; + const finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages); + const prior = this.prior; + if (!prior) { + // No prior value. + return finalValue; + } else if (now > this.end) { + // Transition from prior value is now complete. + this.prior = null; + return finalValue; + } else if (this.value.isDataDriven()) { + // Transitions to data-driven properties are not supported. + // We snap immediately to the data-driven value so that, when we perform layout, + // we see the data-driven function and can use it to populate vertex buffers. + this.prior = null; + return finalValue; + } else if (now < this.begin) { + // Transition hasn't started yet. + return prior.possiblyEvaluate(parameters, canonical, availableImages); + } else { + // Interpolate between recursively-calculated prior value and final. + const t = (now - this.begin) / (this.end - this.begin); + return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t)); + } + } +} + +/** + * @internal + * `Transitioning` stores a map of all (property name, `TransitioningPropertyValue`) pairs for paint properties of a + * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a + * `PossiblyEvaluated` instance for the same set of properties. + */ +export class Transitioning { + _properties: Properties; + _values: {[K in keyof Props]: PossiblyEvaluatedPropertyValue}; + + constructor(properties: Properties) { + this._properties = properties; + this._values = (Object.create(properties.defaultTransitioningPropertyValues) as any); + } + + possiblyEvaluate( + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): PossiblyEvaluated { + const result = new PossiblyEvaluated(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages); + } + return result; + } + + hasTransition() { + for (const property of Object.keys(this._values)) { + if (this._values[property].prior) { + return true; + } + } + return false; + } +} + +// ------- Layout ------- + +/** + * Because layout properties are not transitionable, they have a simpler representation and evaluation chain than + * paint properties: `PropertyValue`s are possibly evaluated, producing possibly evaluated values, which are then + * fully evaluated. + * + * `Layout` stores a map of all (property name, `PropertyValue`) pairs for layout properties of a + * given layer type. It can calculate the possibly-evaluated values for all of them at once, producing a + * `PossiblyEvaluated` instance for the same set of properties. + */ +export class Layout { + _properties: Properties; + _values: {[K in keyof Props]: PropertyValue>}; + + constructor(properties: Properties) { + this._properties = properties; + this._values = (Object.create(properties.defaultPropertyValues) as any); + } + + hasValue(name: S) { + return this._values[name].value !== undefined; + } + + getValue(name: S) { + return clone(this._values[name].value); + } + + setValue(name: S, value: any) { + this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value)) as any; + } + + serialize() { + const result: any = {}; + for (const property of Object.keys(this._values)) { + const value = this.getValue(property as keyof Props); + if (value !== undefined) { + result[property] = value; + } + } + return result; + } + + possiblyEvaluate( + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): PossiblyEvaluated { + const result = new PossiblyEvaluated(this._properties); + for (const property of Object.keys(this._values)) { + result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages); + } + return result; + } +} + +// ------- PossiblyEvaluated ------- + +/** + * "Possibly evaluated value" is an intermediate stage in the evaluation chain for both paint and layout property + * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code + * which uses data-driven property values must assume that the value is dependent on feature data, and request that it + * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation + * will not actually depend on the feature, and we can benefit from returning the prior result of having done the + * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and "global" parameters + * such as current zoom level. + * + * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or + * camera expression, then the "possibly evaluated" result is a constant value. Otherwise, the input value was either + * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate + * the source and composite cases because they are handled differently when generating GL attributes, buffers, and + * uniforms. + * + * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that + * do not allow data-driven values. For such properties, we know that the "possibly evaluated" result is always a constant + * scalar value. See below. + */ +type PossiblyEvaluatedValue = { + kind: 'constant'; + value: T; +} | SourceExpression | CompositeExpression; + +/** + * @internal + * `PossiblyEvaluatedPropertyValue` is used for data-driven paint and layout property values. It holds a + * `PossiblyEvaluatedValue` and the `GlobalProperties` that were used to generate it. You're not allowed to supply + * a different set of `GlobalProperties` when performing the final evaluation because they would be ignored in the + * case where the input value was a constant or camera function. + */ +export class PossiblyEvaluatedPropertyValue { + property: DataDrivenProperty; + value: PossiblyEvaluatedValue; + parameters: EvaluationParameters; + + constructor(property: DataDrivenProperty, value: PossiblyEvaluatedValue, parameters: EvaluationParameters) { + this.property = property; + this.value = value; + this.parameters = parameters; + } + + isConstant(): boolean { + return this.value.kind === 'constant'; + } + + constantOr(value: T): T { + if (this.value.kind === 'constant') { + return this.value.value; + } else { + return value; + } + } + + evaluate( + feature: Feature, + featureState: FeatureState, + canonical?: CanonicalTileID, + availableImages?: Array + ): T { + return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages); + } +} + +/** + * @internal + * `PossiblyEvaluated` stores a map of all (property name, `R`) pairs for paint or layout properties of a + * given layer type. + */ +export class PossiblyEvaluated { + _properties: Properties; + _values: PossibleEvaluatedProps; + + constructor(properties: Properties) { + this._properties = properties; + this._values = Object.create(properties.defaultPossiblyEvaluatedValues); + } + + get(name: S): PossibleEvaluatedProps[S] { + return this._values[name]; + } +} + +/** + * @internal + * An implementation of `Property` for properties that do not permit data-driven (source or composite) expressions. + * This restriction allows us to declare statically that the result of possibly evaluating this kind of property + * is in fact always the scalar type `T`, and can be used without further evaluating the value on a per-feature basis. + */ +export class DataConstantProperty implements Property { + specification: StylePropertySpecification; + + constructor(specification: StylePropertySpecification) { + this.specification = specification; + } + + possiblyEvaluate(value: PropertyValue, parameters: EvaluationParameters): T { + if (value.isDataDriven()) throw new Error('Value should not be data driven'); + return value.expression.evaluate(parameters); + } + + interpolate(a: T, b: T, t: number): T { + const interpolationType = this.specification.type as keyof typeof interpolates; + const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined; + if (interpolationFn) { + return interpolationFn(a, b, t); + } else { + return a; + } + } +} + +/** + * @internal + * An implementation of `Property` for properties that permit data-driven (source or composite) expressions. + * The result of possibly evaluating this kind of property is `PossiblyEvaluatedPropertyValue`; obtaining + * a scalar value `T` requires further evaluation on a per-feature basis. + */ +export class DataDrivenProperty implements Property> { + specification: StylePropertySpecification; + overrides: any; + + constructor(specification: StylePropertySpecification, overrides?: any) { + this.specification = specification; + this.overrides = overrides; + } + + possiblyEvaluate( + value: PropertyValue>, + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): PossiblyEvaluatedPropertyValue { + if (value.expression.kind === 'constant' || value.expression.kind === 'camera') { + return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: value.expression.evaluate(parameters, null, {}, canonical, availableImages)}, parameters); + } else { + return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters); + } + } + + interpolate( + a: PossiblyEvaluatedPropertyValue, + b: PossiblyEvaluatedPropertyValue, + t: number + ): PossiblyEvaluatedPropertyValue { + // If either possibly-evaluated value is non-constant, give up: we aren't able to interpolate data-driven values. + if (a.value.kind !== 'constant' || b.value.kind !== 'constant') { + return a; + } + + // Special case hack solely for fill-outline-color. The undefined value is subsequently handled in + // FillStyleLayer#recalculate, which sets fill-outline-color to the fill-color value if the former + // is a PossiblyEvaluatedPropertyValue containing a constant undefined value. In addition to the + // return value here, the other source of a PossiblyEvaluatedPropertyValue containing a constant + // undefined value is the "default value" for fill-outline-color held in + // `Properties#defaultPossiblyEvaluatedValues`, which serves as the prototype of + // `PossiblyEvaluated#_values`. + if (a.value.value === undefined || b.value.value === undefined) { + return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, a.parameters); + } + + const interpolationType = this.specification.type as keyof typeof interpolates; + const interpolationFn = interpolates[interpolationType] as ((from: T, to: T, t: number) => T) | undefined; + if (interpolationFn) { + const interpolatedValue = interpolationFn(a.value.value, b.value.value, t); + return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: interpolatedValue}, a.parameters); + } else { + return a; + } + } + + evaluate( + value: PossiblyEvaluatedValue, + parameters: EvaluationParameters, + feature: Feature, + featureState: FeatureState, + canonical?: CanonicalTileID, + availableImages?: Array + ): T { + if (value.kind === 'constant') { + return value.value; + } else { + return value.evaluate(parameters, feature, featureState, canonical, availableImages); + } + } +} + +/** + * @internal + * An implementation of `Property` for data driven `line-pattern` which are transitioned by cross-fading + * rather than interpolation. + */ + +export class CrossFadedDataDrivenProperty extends DataDrivenProperty> { + + possiblyEvaluate( + value: PropertyValue, PossiblyEvaluatedPropertyValue>>, + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): PossiblyEvaluatedPropertyValue> { + if (value.value === undefined) { + return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: undefined}, parameters); + } else if (value.expression.kind === 'constant') { + const evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages); + const isImageExpression = value.property.specification.type as any === 'resolvedImage'; + const constantValue = isImageExpression && typeof evaluatedValue !== 'string' ? evaluatedValue.name : evaluatedValue; + const constant = this._calculate(constantValue, constantValue, constantValue, parameters); + return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: constant}, parameters); + } else if (value.expression.kind === 'camera') { + const cameraVal = this._calculate( + value.expression.evaluate({zoom: parameters.zoom - 1.0}), + value.expression.evaluate({zoom: parameters.zoom}), + value.expression.evaluate({zoom: parameters.zoom + 1.0}), + parameters); + return new PossiblyEvaluatedPropertyValue(this, {kind: 'constant', value: cameraVal}, parameters); + } else { + // source or composite expression + return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters); + } + } + + evaluate( + value: PossiblyEvaluatedValue>, + globals: EvaluationParameters, + feature: Feature, + featureState: FeatureState, + canonical?: CanonicalTileID, + availableImages?: Array + ): CrossFaded { + if (value.kind === 'source') { + const constant = value.evaluate(globals, feature, featureState, canonical, availableImages); + return this._calculate(constant, constant, constant, globals); + } else if (value.kind === 'composite') { + return this._calculate( + value.evaluate({zoom: Math.floor(globals.zoom) - 1.0}, feature, featureState), + value.evaluate({zoom: Math.floor(globals.zoom)}, feature, featureState), + value.evaluate({zoom: Math.floor(globals.zoom) + 1.0}, feature, featureState), + globals); + } else { + return value.value; + } + } + + _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded { + const z = parameters.zoom; + return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid}; + } + + interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue> { + return a; + } +} +/** + * @internal + * An implementation of `Property` for `*-pattern` and `line-dasharray`, which are transitioned by cross-fading + * rather than interpolation. + */ +export class CrossFadedProperty implements Property> { + specification: StylePropertySpecification; + + constructor(specification: StylePropertySpecification) { + this.specification = specification; + } + + possiblyEvaluate( + value: PropertyValue>, + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): CrossFaded { + if (value.value === undefined) { + return undefined; + } else if (value.expression.kind === 'constant') { + const constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages); + return this._calculate(constant, constant, constant, parameters); + } else { + return this._calculate( + value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1.0), parameters)), + value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)), + value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1.0), parameters)), + parameters); + } + } + + _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded { + const z = parameters.zoom; + return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid}; + } + + interpolate(a?: CrossFaded | null): CrossFaded { + return a; + } +} + +/** + * @internal + * An implementation of `Property` for `heatmap-color` and `line-gradient`. Interpolation is a no-op, and + * evaluation returns a boolean value in order to indicate its presence, but the real + * evaluation happens in StyleLayer classes. + */ + +export class ColorRampProperty implements Property { + specification: StylePropertySpecification; + + constructor(specification: StylePropertySpecification) { + this.specification = specification; + } + + possiblyEvaluate( + value: PropertyValue, + parameters: EvaluationParameters, + canonical?: CanonicalTileID, + availableImages?: Array + ): boolean { + return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages); + } + + interpolate(): boolean { return false; } +} + +/** + * @internal + * `Properties` holds objects containing default values for the layout or paint property set of a given + * layer type. These objects are immutable, and they are used as the prototypes for the `_values` members of + * `Transitionable`, `Transitioning`, `Layout`, and `PossiblyEvaluated`. This allows these classes to avoid + * doing work in the common case where a property has no explicit value set and should be considered to take + * on the default value: using `for (const property of Object.keys(this._values))`, they can iterate over + * only the _own_ properties of `_values`, skipping repeated calculation of transitions and possible/final + * evaluations for defaults, the result of which will always be the same. + */ +export class Properties { + properties: Props; + defaultPropertyValues: {[K in keyof Props]: PropertyValue}; + defaultTransitionablePropertyValues: {[K in keyof Props]: TransitionablePropertyValue}; + defaultTransitioningPropertyValues: {[K in keyof Props]: TransitioningPropertyValue}; + defaultPossiblyEvaluatedValues: {[K in keyof Props]: PossiblyEvaluatedPropertyValue}; + overridableProperties: Array; + + constructor(properties: Props) { + this.properties = properties; + this.defaultPropertyValues = ({} as any); + this.defaultTransitionablePropertyValues = ({} as any); + this.defaultTransitioningPropertyValues = ({} as any); + this.defaultPossiblyEvaluatedValues = ({} as any); + this.overridableProperties = ([] as any); + + for (const property in properties) { + const prop = properties[property] as any; + if (prop.specification.overridable) { + this.overridableProperties.push(property); + } + const defaultPropertyValue = this.defaultPropertyValues[property] = + new PropertyValue(prop, undefined); + const defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] = + new TransitionablePropertyValue(prop); + this.defaultTransitioningPropertyValues[property] = + defaultTransitionablePropertyValue.untransitioned(); + this.defaultPossiblyEvaluatedValues[property] = + defaultPropertyValue.possiblyEvaluate({} as any); + } + } +} + +register('DataDrivenProperty', DataDrivenProperty); +register('DataConstantProperty', DataConstantProperty); +register('CrossFadedDataDrivenProperty', CrossFadedDataDrivenProperty); +register('CrossFadedProperty', CrossFadedProperty); +register('ColorRampProperty', ColorRampProperty); diff --git a/web/libraries/maplibre-gl/src/style/query_utils.test.ts b/web/libraries/maplibre-gl/src/style/query_utils.test.ts new file mode 100644 index 00000000..718412e9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/query_utils.test.ts @@ -0,0 +1,107 @@ +import Point from '@mapbox/point-geometry'; + +import {offsetLine} from './query_utils'; + +const defaultPrecision = 10; + +const closeTo = (expected, precision = defaultPrecision) => ({ + asymmetricMatch: (actual) => Math.abs(expected - actual) < Math.pow(10, -precision) / 2 +}); + +describe('offsetLine', () => { + test('line two points east', () => { + const line = [ + new Point(0, 0), + new Point(1, 0) + ]; + const offset = 1; + + expect(offsetLine([line], offset)).toEqual([[ + new Point(0, 1), + new Point(1, 1) + ]]); + }); + + test('line two points west', () => { + const line = [ + new Point(10, 10), + new Point(5, 10) + ]; + const offset = 2; + + expect(offsetLine([line], offset)).toEqual([[ + new Point(10, 8), + new Point(5, 8) + ]]); + }); + + test('line two points south', () => { + const line = [ + new Point(0, -1), + new Point(0, 1) + ]; + const offset = 1; + + expect(offsetLine([line], offset)).toEqual([[ + new Point(-1, -1), + new Point(-1, 1) + ]]); + }); + + test('line three points north', () => { + const line = [ + new Point(0, 1), + new Point(0, 0), + new Point(0, -1) + ]; + const offset = 1; + + expect(offsetLine([line], offset)).toEqual([[ + new Point(1, 1), + new Point(1, 0), + new Point(1, -1) + ]]); + }); + + test('line three points north east', () => { + const line = [ + new Point(-1, 1), + new Point(0, 0), + new Point(1, -1) + ]; + const offset = Math.sqrt(2); + + expect(offsetLine([line], offset)).toEqual([[ + { + x: closeTo(0), + y: closeTo(2) + }, + { + x: closeTo(1), + y: closeTo(1) + }, + { + x: closeTo(2), + y: closeTo(0) + } + ]]); + }); + + test('ring five points square', () => { + const ring = [ + new Point(0, 0), + new Point(10, 0), + new Point(10, -10), + new Point(0, -10), + new Point(0, 0) + ]; + const offset = 2; + expect(offsetLine([ring], offset)).toEqual([[ + new Point(0, 2), + new Point(12, 2), + new Point(12, -12), + new Point(-2, -12), + new Point(-2, 0) + ]]); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/query_utils.ts b/web/libraries/maplibre-gl/src/style/query_utils.ts new file mode 100644 index 00000000..cbca4596 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/query_utils.ts @@ -0,0 +1,70 @@ +import Point from '@mapbox/point-geometry'; + +import type {PossiblyEvaluatedPropertyValue} from './properties'; +import type {StyleLayer} from '../style/style_layer'; +import type {CircleBucket} from '../data/bucket/circle_bucket'; +import type {LineBucket} from '../data/bucket/line_bucket'; + +export function getMaximumPaintValue( + property: string, + layer: StyleLayer, + bucket: CircleBucket | LineBucket +): number { + const value = ((layer.paint as any).get(property) as PossiblyEvaluatedPropertyValue).value; + if (value.kind === 'constant') { + return value.value; + } else { + return bucket.programConfigurations.get(layer.id).getMaxValue(property); + } +} + +export function translateDistance(translate: [number, number]) { + return Math.sqrt(translate[0] * translate[0] + translate[1] * translate[1]); +} + +export function translate(queryGeometry: Array, + translate: [number, number], + translateAnchor: 'viewport' | 'map', + bearing: number, + pixelsToTileUnits: number) { + if (!translate[0] && !translate[1]) { + return queryGeometry; + } + const pt = Point.convert(translate)._mult(pixelsToTileUnits); + + if (translateAnchor === 'viewport') { + pt._rotate(-bearing); + } + + const translated = []; + for (let i = 0; i < queryGeometry.length; i++) { + const point = queryGeometry[i]; + translated.push(point.sub(pt)); + } + return translated; +} + +export function offsetLine(rings: Array>, offset: number) { + const newRings: Array> = []; + for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) { + const ring = rings[ringIndex]; + const newRing: Array = []; + for (let index = 0; index < ring.length; index++) { + const a = ring[index - 1]; + const b = ring[index]; + const c = ring[index + 1]; + const aToB = index === 0 ? new Point(0, 0) : b.sub(a)._unit()._perp(); + const bToC = index === ring.length - 1 ? new Point(0, 0) : c.sub(b)._unit()._perp(); + const extrude = aToB._add(bToC)._unit(); + + const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y; + if (cosHalfAngle !== 0) { + extrude._mult(1 / cosHalfAngle); + } + + newRing.push(extrude._mult(offset)._add(b)); + } + newRings.push(newRing); + } + return newRings; +} diff --git a/web/libraries/maplibre-gl/src/style/style.test.ts b/web/libraries/maplibre-gl/src/style/style.test.ts new file mode 100644 index 00000000..bdc325c8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style.test.ts @@ -0,0 +1,2623 @@ +import {Style} from './style'; +import {SourceCache} from '../source/source_cache'; +import {StyleLayer} from './style_layer'; +import {Transform} from '../geo/transform'; +import {extend} from '../util/util'; +import {RequestManager} from '../util/request_manager'; +import {Event, Evented} from '../util/evented'; +import {RGBAImage} from '../util/image'; +import { + setRTLTextPlugin, + clearRTLTextPlugin, + evented as rtlTextPluginEvented +} from '../source/rtl_text_plugin'; +import {browser} from '../util/browser'; +import {OverscaledTileID} from '../source/tile_id'; +import {fakeServer, type FakeServer} from 'nise'; + +import {EvaluationParameters} from './evaluation_parameters'; +import {LayerSpecification, GeoJSONSourceSpecification, FilterSpecification, SourceSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {SourceClass} from '../source/source'; +import {GeoJSONSource} from '../source/geojson_source'; + +function createStyleJSON(properties?) { + return extend({ + 'version': 8, + 'sources': {}, + 'layers': [] + }, properties); +} + +function createSource() { + return { + type: 'vector', + minzoom: 1, + maxzoom: 10, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } as any as SourceSpecification; +} + +function createGeoJSONSource() { + return { + 'type': 'geojson', + 'data': { + 'type': 'FeatureCollection', + 'features': [] + } + }; +} + +class StubMap extends Evented { + style: Style; + transform: Transform; + private _requestManager: RequestManager; + + constructor() { + super(); + this.transform = new Transform(); + this._requestManager = new RequestManager(); + } + + _getMapId() { + return 1; + } + + getPixelRatio() { + return 1; + } + + setTerrain() { } + getTerrain() { } +} + +const getStubMap = () => new StubMap() as any; + +function createStyle(map = getStubMap()) { + const style = new Style(map); + map.style = style; + return style; +} + +let server: FakeServer; +let mockConsoleError; + +beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + mockConsoleError = jest.spyOn(console, 'error').mockImplementation(() => { }); +}); + +afterEach(() => { + server.restore(); + mockConsoleError.mockRestore(); +}); + +describe('Style', () => { + test('registers plugin state change listener', () => { + clearRTLTextPlugin(); + + jest.spyOn(Style, 'registerForPluginStateChange'); + const style = new Style(getStubMap()); + const mockStyleDispatcherBroadcast = jest.spyOn(style.dispatcher, 'broadcast'); + expect(Style.registerForPluginStateChange).toHaveBeenCalledTimes(1); + + setRTLTextPlugin('/plugin.js', undefined); + expect(mockStyleDispatcherBroadcast.mock.calls[0][0]).toBe('syncRTLPluginState'); + expect(mockStyleDispatcherBroadcast.mock.calls[0][1]).toEqual({ + pluginStatus: 'deferred', + pluginURL: 'http://localhost/plugin.js', + }); + }); + + test('loads plugin immediately if already registered', done => { + clearRTLTextPlugin(); + server.respondWith('/plugin.js', 'doesn\'t matter'); + setRTLTextPlugin('/plugin.js', (error) => { + expect(error).toMatch(/Cannot set the state of the rtl-text-plugin when not in the web-worker context/); + done(); + }); + server.respond(); + new Style(getStubMap()); + }); + + test('RTL plugin load reloads vector source but not raster source', done => { + const map = getStubMap(); + const style = new Style(map); + map.style = style; + style.loadJSON({ + 'version': 8, + 'sources': { + 'raster': { + type: 'raster', + tiles: ['http://tiles.server'] + }, + 'vector': { + type: 'vector', + tiles: ['http://tiles.server'] + } + }, + 'layers': [{ + 'id': 'raster', + 'type': 'raster', + 'source': 'raster' + }] + }); + + style.on('style.load', () => { + jest.spyOn(style.sourceCaches['raster'], 'reload'); + jest.spyOn(style.sourceCaches['vector'], 'reload'); + + clearRTLTextPlugin(); + server.respondWith('/plugin.js', 'doesn\'t matter'); + const _broadcast = style.dispatcher.broadcast; + style.dispatcher.broadcast = function (type, state, callback) { + if (type === 'syncRTLPluginState') { + // Mock a response from four workers saying they've loaded the plugin + callback(undefined, [true, true, true, true]); + } else { + _broadcast(type, state, callback); + } + }; + setRTLTextPlugin('/plugin.js', (error) => { + expect(error).toBeUndefined(); + setTimeout(() => { + clearRTLTextPlugin(); + expect(style.sourceCaches['raster'].reload).not.toHaveBeenCalled(); + expect(style.sourceCaches['vector'].reload).toHaveBeenCalled(); + done(); + }, 0); + }); + server.respond(); + }); + }); +}); + +describe('Style#loadURL', () => { + test('fires "dataloading"', () => { + const style = new Style(getStubMap()); + const spy = jest.fn(); + + style.on('dataloading', spy); + style.loadURL('style.json'); + + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0].target).toBe(style); + expect(spy.mock.calls[0][0].dataType).toBe('style'); + }); + + test('transforms style URL before request', () => { + const map = getStubMap(); + const spy = jest.spyOn(map._requestManager, 'transformRequest'); + + const style = new Style(map); + style.loadURL('style.json'); + + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0]).toBe('style.json'); + expect(spy.mock.calls[0][1]).toBe('Style'); + }); + + test('validates the style', done => { + const style = new Style(getStubMap()); + + style.on('error', ({error}) => { + expect(error).toBeTruthy(); + expect(error.message).toMatch(/version/); + done(); + }); + + style.loadURL('style.json'); + server.respondWith(JSON.stringify(createStyleJSON({version: 'invalid'}))); + server.respond(); + }); + + test('cancels pending requests if removed', () => { + const style = new Style(getStubMap()); + style.loadURL('style.json'); + style._remove(); + expect((server.lastRequest as any).aborted).toBe(true); + }); +}); + +describe('Style#loadJSON', () => { + test('serialize() returns undefined until style is loaded', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + expect(style.serialize()).toBeUndefined(); + style.on('style.load', () => { + expect(style.serialize()).toEqual(createStyleJSON()); + done(); + }); + }); + + test('fires "dataloading" (synchronously)', () => { + const style = new Style(getStubMap()); + const spy = jest.fn(); + + style.on('dataloading', spy); + style.loadJSON(createStyleJSON()); + + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0].target).toBe(style); + expect(spy.mock.calls[0][0].dataType).toBe('style'); + }); + + test('fires "data" (asynchronously)', done => { + const style = new Style(getStubMap()); + + style.loadJSON(createStyleJSON()); + + style.on('data', (e) => { + expect(e.target).toBe(style); + expect(e.dataType).toBe('style'); + done(); + }); + }); + + test('fires "data" when the sprite finishes loading', done => { + // Stubbing to bypass Web APIs that supported by jsdom: + // * `URL.createObjectURL` in ajax.getImage (https://github.com/tmpvar/jsdom/issues/1721) + // * `canvas.getContext('2d')` in browser.getImageData + jest.spyOn(browser, 'getImageData'); + // stub Image so we can invoke 'onload' + // https://github.com/jsdom/jsdom/commit/58a7028d0d5b6aacc5b435daee9fd8f9eacbb14c + + server.respondWith('GET', 'http://example.com/sprite.png', new ArrayBuffer(8)); + server.respondWith('GET', 'http://example.com/sprite.json', '{}'); + + const style = new Style(getStubMap()); + + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [], + 'sprite': 'http://example.com/sprite' + }); + + style.once('error', (e) => expect(e).toBeFalsy()); + + style.once('data', (e) => { + expect(e.target).toBe(style); + expect(e.dataType).toBe('style'); + + style.once('data', (e) => { + expect(e.target).toBe(style); + expect(e.dataType).toBe('style'); + done(); + }); + + server.respond(); + }); + }); + + test('Validate sprite image extraction', done => { + // Stubbing to bypass Web APIs that supported by jsdom: + // * `URL.createObjectURL` in ajax.getImage (https://github.com/tmpvar/jsdom/issues/1721) + // * `canvas.getContext('2d')` in browser.getImageData + jest.spyOn(browser, 'getImageData'); + // stub Image so we can invoke 'onload' + // https://github.com/jsdom/jsdom/commit/58a7028d0d5b6aacc5b435daee9fd8f9eacbb14c + + server.respondWith('GET', 'http://example.com/sprite.png', new ArrayBuffer(8)); + server.respondWith('GET', 'http://example.com/sprite.json', '{"image1": {"width": 1, "height": 1, "x": 0, "y": 0, "pixelRatio": 1.0}}'); + + const style = new Style(getStubMap()); + + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [], + 'sprite': 'http://example.com/sprite' + }); + + style.once('data', (e) => { + expect(e.target).toBe(style); + expect(e.dataType).toBe('style'); + + style.once('data', (e) => { + expect(e.target).toBe(style); + expect(e.dataType).toBe('style'); + style.imageManager.getImages(['image1'], (error, response) => { + const image = response['image1']; + expect(image.data).toBeInstanceOf(RGBAImage); + expect(image.data.width).toBe(1); + expect(image.data.height).toBe(1); + expect(image.pixelRatio).toBe(1); + done(); + }); + }); + + server.respond(); + }); + }); + + test('validates the style', done => { + const style = new Style(getStubMap()); + + style.on('error', ({error}) => { + expect(error).toBeTruthy(); + expect(error.message).toMatch(/version/); + done(); + }); + + style.loadJSON(createStyleJSON({version: 'invalid'})); + }); + + test('creates sources', done => { + const style = createStyle(); + + style.on('style.load', () => { + expect(style.sourceCaches['mapLibre'] instanceof SourceCache).toBeTruthy(); + done(); + }); + + style.loadJSON(extend(createStyleJSON(), { + 'sources': { + 'mapLibre': { + 'type': 'vector', + 'tiles': [] + } + } + })); + }); + + test('creates layers', done => { + const style = createStyle(); + + style.on('style.load', () => { + expect(style.getLayer('fill') instanceof StyleLayer).toBeTruthy(); + done(); + }); + + style.loadJSON({ + 'version': 8, + 'sources': { + 'foo': { + 'type': 'vector' + } + }, + 'layers': [{ + 'id': 'fill', + 'source': 'foo', + 'source-layer': 'source-layer', + 'type': 'fill' + }] + }); + }); + + test('transforms sprite json and image URLs before request', done => { + const map = getStubMap(); + const transformSpy = jest.spyOn(map._requestManager, 'transformRequest'); + const style = createStyle(map); + + style.on('style.load', () => { + expect(transformSpy).toHaveBeenCalledTimes(2); + expect(transformSpy.mock.calls[0][0]).toBe('http://example.com/sprites/bright-v8.json'); + expect(transformSpy.mock.calls[0][1]).toBe('SpriteJSON'); + expect(transformSpy.mock.calls[1][0]).toBe('http://example.com/sprites/bright-v8.png'); + expect(transformSpy.mock.calls[1][1]).toBe('SpriteImage'); + done(); + }); + + style.loadJSON(extend(createStyleJSON(), { + 'sprite': 'http://example.com/sprites/bright-v8' + })); + }); + + test('emits an error on non-existant vector source layer', done => { + const style = createStyle(); + style.loadJSON(createStyleJSON({ + sources: { + '-source-id-': {type: 'vector', tiles: []} + }, + layers: [] + })); + + style.on('style.load', () => { + style.removeSource('-source-id-'); + + const source = createSource(); + source['vector_layers'] = [{id: 'green'}]; + style.addSource('-source-id-', source); + style.addLayer({ + 'id': '-layer-id-', + 'type': 'circle', + 'source': '-source-id-', + 'source-layer': '-source-layer-' + }); + style.update({} as EvaluationParameters); + }); + + style.on('error', (event) => { + const err = event.error; + expect(err).toBeTruthy(); + expect(err.toString().indexOf('-source-layer-') !== -1).toBeTruthy(); + expect(err.toString().indexOf('-source-id-') !== -1).toBeTruthy(); + expect(err.toString().indexOf('-layer-id-') !== -1).toBeTruthy(); + + done(); + }); + }); + + test('sets up layer event forwarding', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'background', + type: 'background' + }] + })); + + style.on('error', (e) => { + expect(e.layer).toEqual({id: 'background'}); + expect(e.mapLibre).toBeTruthy(); + done(); + }); + + style.on('style.load', () => { + style._layers.background.fire(new Event('error', {mapLibre: true})); + }); + }); + + test('sets terrain if defined', (done) => { + const map = getStubMap(); + const style = new Style(map); + map.setTerrain = jest.fn(); + style.loadJSON(createStyleJSON({ + sources: {'source-id': createGeoJSONSource()}, + terrain: {source: 'source-id', exaggeration: 0.33} + })); + + style.on('style.load', () => { + expect(style.map.setTerrain).toHaveBeenCalled(); + done(); + }); + }); + + test('applies transformStyle function', (done) => { + const previousStyle = createStyleJSON({ + sources: { + base: { + type: 'geojson', + data: {type: 'FeatureCollection', features: []} + } + }, + layers: [{ + id: 'layerId0', + type: 'circle', + source: 'base' + }, { + id: 'layerId1', + type: 'circle', + source: 'base' + }] + }); + + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON(), { + transformStyle: (prevStyle, nextStyle) => ({ + ...nextStyle, + sources: { + ...nextStyle.sources, + base: prevStyle.sources.base + }, + layers: [ + ...nextStyle.layers, + prevStyle.layers[0] + ] + }) + }, previousStyle); + + style.on('style.load', () => { + expect('base' in style.stylesheet.sources).toBeTruthy(); + expect(style.stylesheet.layers[0].id).toBe(previousStyle.layers[0].id); + expect(style.stylesheet.layers).toHaveLength(1); + done(); + }); + }); +}); + +describe('Style#_load', () => { + test('initiates sprite loading when it\'s present', () => { + const style = new Style(getStubMap()); + + const prevStyleSpec = createStyleJSON({ + sprite: 'https://example.com/test1' + }); + + const nextStyleSpec = createStyleJSON({ + sprite: 'https://example.com/test2' + }); + + const _loadSpriteSpyOn = jest.spyOn(style, '_loadSprite'); + style._load(nextStyleSpec, {}, prevStyleSpec); + + expect(_loadSpriteSpyOn).toHaveBeenCalledTimes(1); + }); + + test('does not initiate sprite loading when it\'s absent (undefined)', () => { + const style = new Style(getStubMap()); + + const prevStyleSpec = createStyleJSON({ + sprite: 'https://example.com/test1' + }); + + const nextStyleSpec = createStyleJSON({sprite: undefined}); + + const _loadSpriteSpyOn = jest.spyOn(style, '_loadSprite'); + style._load(nextStyleSpec, {}, prevStyleSpec); + + expect(_loadSpriteSpyOn).not.toHaveBeenCalled(); + }); + + test('layers are broadcasted to worker', () => { + const style = new Style(getStubMap()); + let dispatchType; + let dispatchData; + const styleSpec = createStyleJSON({ + layers: [{ + id: 'background', + type: 'background' + }] + }); + + const _broadcastSpyOn = jest.spyOn(style.dispatcher, 'broadcast') + .mockImplementation((type: string, data) => { + dispatchType = type; + dispatchData = data; + }); + + style._load(styleSpec, {}); + + expect(_broadcastSpyOn).toHaveBeenCalled(); + expect(dispatchType).toBe('setLayers'); + + expect(dispatchData).toHaveLength(1); + expect(dispatchData[0].id).toBe('background'); + + // cleanup + _broadcastSpyOn.mockReset(); + }); + + test('validate style when validate option is true', () => { + const style = new Style(getStubMap()); + const styleSpec = createStyleJSON({ + layers: [{ + id: 'background', + type: 'background' + }, { + id: 'custom', + type: 'custom' + }] + }); + const stub = jest.spyOn(console, 'error'); + + style._load(styleSpec, {validate: true}); + + // 1. layers[1]: missing required property "source" + // 2. layers[1].type: expected one of [fill, line, symbol, circle, heatmap, fill-extrusion, raster, hillshade, background], "custom" found + expect(stub).toHaveBeenCalledTimes(2); + + // cleanup + stub.mockReset(); + }); + + test('layers are NOT serialized immediately after creation', () => { + const style = new Style(getStubMap()); + const styleSpec = createStyleJSON({ + layers: [{ + id: 'background', + type: 'background' + }, { + id: 'custom', + type: 'custom' + }] + }); + + style._load(styleSpec, {validate: false}); + expect(style._serializedLayers).toBeNull(); + }); +}); + +describe('Style#_remove', () => { + test('removes cache sources and clears their tiles', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + sources: {'source-id': createGeoJSONSource()} + })); + + style.on('style.load', () => { + const sourceCache = style.sourceCaches['source-id']; + jest.spyOn(sourceCache, 'setEventedParent'); + jest.spyOn(sourceCache, 'onRemove'); + jest.spyOn(sourceCache, 'clearTiles'); + + style._remove(); + + expect(sourceCache.setEventedParent).toHaveBeenCalledWith(null); + expect(sourceCache.onRemove).toHaveBeenCalledWith(style.map); + expect(sourceCache.clearTiles).toHaveBeenCalled(); + + done(); + }); + }); + + test('deregisters plugin listener', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const mockStyleDispatcherBroadcast = jest.spyOn(style.dispatcher, 'broadcast'); + + style.on('style.load', () => { + style._remove(); + + rtlTextPluginEvented.fire(new Event('pluginStateChange')); + expect(mockStyleDispatcherBroadcast).not.toHaveBeenCalledWith('syncRTLPluginState'); + done(); + }); + }); +}); + +describe('Style#update', () => { + test('on error', done => { + const style = createStyle(); + style.loadJSON({ + 'version': 8, + 'sources': { + 'source': { + 'type': 'vector' + } + }, + 'layers': [{ + 'id': 'second', + 'source': 'source', + 'source-layer': 'source-layer', + 'type': 'fill' + }] + }); + + style.on('error', (error) => { expect(error).toBeFalsy(); }); + + style.on('style.load', () => { + style.addLayer({id: 'first', source: 'source', type: 'fill', 'source-layer': 'source-layer'}, 'second'); + style.addLayer({id: 'third', source: 'source', type: 'fill', 'source-layer': 'source-layer'}); + style.removeLayer('second'); + + style.dispatcher.broadcast = function(key, value) { + expect(key).toBe('updateLayers'); + expect(value['layers'].map((layer) => { return layer.id; })).toEqual(['first', 'third']); + expect(value['removedIds']).toEqual(['second']); + done(); + }; + + style.update({} as EvaluationParameters); + }); + }); +}); + +describe('Style#setState', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.setState(createStyleJSON())).toThrow(/load/i); + }); + + test('do nothing if there are no changes', done => { + const style = createStyle(); + style.loadJSON(createStyleJSON()); + jest.spyOn(style, 'addLayer').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'removeLayer').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'setPaintProperty').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'setLayoutProperty').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'setFilter').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'addSource').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'removeSource').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'setGeoJSONSourceData').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'setLayerZoomRange').mockImplementation(() => done('test failed')); + jest.spyOn(style, 'setLight').mockImplementation(() => done('test failed')); + style.on('style.load', () => { + const didChange = style.setState(createStyleJSON()); + expect(didChange).toBeFalsy(); + done(); + }); + }); + + test('Issue #3893: compare new source options against originally provided options rather than normalized properties', done => { + server.respondWith('/tilejson.json', JSON.stringify({ + tiles: ['http://tiles.server'] + })); + const initial = createStyleJSON(); + initial.sources.mySource = { + type: 'raster', + url: '/tilejson.json' + }; + const style = new Style(getStubMap()); + style.loadJSON(initial); + style.on('style.load', () => { + jest.spyOn(style, 'removeSource').mockImplementation(() => done('test failed: removeSource called')); + jest.spyOn(style, 'addSource').mockImplementation(() => done('test failed: addSource called')); + style.setState(initial); + done(); + }); + server.respond(); + }); + + test('return true if there is a change', done => { + const initialState = createStyleJSON(); + const nextState = createStyleJSON({ + sources: { + foo: { + type: 'geojson', + data: {type: 'FeatureCollection', features: []} + } + } + }); + + const style = new Style(getStubMap()); + style.loadJSON(initialState); + style.on('style.load', () => { + const didChange = style.setState(nextState); + expect(didChange).toBeTruthy(); + expect(style.stylesheet).toEqual(nextState); + done(); + }); + }); + + test('sets GeoJSON source data if different', done => { + const initialState = createStyleJSON({ + 'sources': {'source-id': createGeoJSONSource()} + }); + + const geoJSONSourceData = { + 'type': 'FeatureCollection', + 'features': [ + { + 'type': 'Feature', + 'geometry': { + 'type': 'Point', + 'coordinates': [125.6, 10.1] + } + } + ] + }; + + const nextState = createStyleJSON({ + 'sources': { + 'source-id': { + 'type': 'geojson', + 'data': geoJSONSourceData + } + } + }); + + const style = new Style(getStubMap()); + style.loadJSON(initialState); + + style.on('style.load', () => { + const geoJSONSource = style.sourceCaches['source-id'].getSource() as GeoJSONSource; + const mockStyleSetGeoJSONSourceDate = jest.spyOn(style, 'setGeoJSONSourceData'); + const mockGeoJSONSourceSetData = jest.spyOn(geoJSONSource, 'setData'); + const didChange = style.setState(nextState); + + expect(mockStyleSetGeoJSONSourceDate).toHaveBeenCalledWith('source-id', geoJSONSourceData); + expect(mockGeoJSONSourceSetData).toHaveBeenCalledWith(geoJSONSourceData); + expect(didChange).toBeTruthy(); + expect(style.stylesheet).toEqual(nextState); + done(); + }); + }); + + test('updates stylesheet according to applied transformStyle function', done => { + const initialState = createStyleJSON({ + sources: { + base: { + type: 'geojson', + data: {type: 'FeatureCollection', features: []} + } + }, + layers: [{ + id: 'layerId0', + type: 'circle', + source: 'base' + }, { + id: 'layerId1', + type: 'circle', + source: 'base' + }] + }); + + const nextState = createStyleJSON(); + const style = new Style(getStubMap()); + style.loadJSON(initialState); + + style.on('style.load', () => { + const didChange = style.setState(nextState, { + transformStyle: (prevStyle, nextStyle) => ({ + ...nextStyle, + sources: { + ...nextStyle.sources, + base: prevStyle.sources.base + }, + layers: [ + ...nextStyle.layers, + prevStyle.layers[0] + ] + }) + }); + + expect(didChange).toBeTruthy(); + expect('base' in style.stylesheet.sources).toBeTruthy(); + expect(style.stylesheet.layers[0].id).toBe(initialState.layers[0].id); + expect(style.stylesheet.layers).toHaveLength(1); + done(); + }); + }); +}); + +describe('Style#addSource', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.addSource('source-id', createSource())).toThrow(/load/i); + }); + + test('throw if missing source type', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + + const source = createSource(); + delete source.type; + + style.on('style.load', () => { + expect(() => style.addSource('source-id', source)).toThrow(/type/i); + done(); + }); + }); + + test('fires "data" event', async () => { + const style = createStyle(); + style.loadJSON(createStyleJSON()); + const source = createSource(); + const dataPromise = style.once('data'); + style.on('style.load', () => { + style.addSource('source-id', source); + style.update({} as EvaluationParameters); + }); + await dataPromise; + }); + + test('throws on duplicates', done => { + const style = createStyle(); + style.loadJSON(createStyleJSON()); + const source = createSource(); + style.on('style.load', () => { + style.addSource('source-id', source); + expect(() => { + style.addSource('source-id', source); + }).toThrow(/Source "source-id" already exists./); + done(); + }); + }); + + test('sets up source event forwarding', done => { + let one = 0; + let two = 0; + let three = 0; + let four = 0; + const checkVisited = () => { + if (one === 1 && two === 1 && three === 1 && four === 1) { + done(); + } + }; + const style = createStyle(); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'background', + type: 'background' + }] + })); + const source = createSource(); + + style.on('style.load', () => { + style.on('error', () => { + one = 1; + checkVisited(); + }); + style.on('data', (e) => { + if (e.sourceDataType === 'metadata' && e.dataType === 'source') { + two = 1; + checkVisited(); + } else if (e.sourceDataType === 'content' && e.dataType === 'source') { + three = 1; + checkVisited(); + } else { + four = 1; + checkVisited(); + } + }); + + style.addSource('source-id', source); // fires data twice + style.sourceCaches['source-id'].fire(new Event('error')); + style.sourceCaches['source-id'].fire(new Event('data')); + }); + }); +}); + +describe('Style#removeSource', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.removeSource('source-id')).toThrow(/load/i); + }); + + test('fires "data" event', async () => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const source = createSource(); + const dataPromise = style.once('data'); + style.on('style.load', () => { + style.addSource('source-id', source); + style.removeSource('source-id'); + style.update({} as EvaluationParameters); + }); + await dataPromise; + }); + + test('clears tiles', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + sources: {'source-id': createGeoJSONSource()} + })); + + style.on('style.load', () => { + const sourceCache = style.sourceCaches['source-id']; + jest.spyOn(sourceCache, 'clearTiles'); + style.removeSource('source-id'); + expect(sourceCache.clearTiles).toHaveBeenCalledTimes(1); + done(); + }); + }); + + test('throws on non-existence', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + expect(() => { + style.removeSource('source-id'); + }).toThrow(/There is no source with this ID/); + done(); + }); + }); + + function createStyle(callback) { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + 'sources': { + 'mapLibre-source': createGeoJSONSource() + }, + 'layers': [{ + 'id': 'mapLibre-layer', + 'type': 'circle', + 'source': 'mapLibre-source', + 'source-layer': 'whatever' + }] + })); + style.on('style.load', () => { + style.update(1 as any as EvaluationParameters); + callback(style); + }); + return style; + } + + test('throws if source is in use', done => { + createStyle((style) => { + style.on('error', (event) => { + expect(event.error.message.includes('"mapLibre-source"')).toBeTruthy(); + expect(event.error.message.includes('"mapLibre-layer"')).toBeTruthy(); + done(); + }); + style.removeSource('mapLibre-source'); + }); + }); + + test('does not throw if source is not in use', done => { + createStyle((style) => { + style.on('error', () => { + done('test failed'); + }); + style.removeLayer('mapLibre-layer'); + style.removeSource('mapLibre-source'); + done(); + }); + }); + + test('tears down source event forwarding', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const source = createSource(); + + style.on('style.load', () => { + style.addSource('source-id', source); + const sourceCache = style.sourceCaches['source-id']; + + style.removeSource('source-id'); + + // Suppress error reporting + sourceCache.on('error', () => {}); + + style.on('data', () => { expect(false).toBeTruthy(); }); + style.on('error', () => { expect(false).toBeTruthy(); }); + sourceCache.fire(new Event('data')); + sourceCache.fire(new Event('error')); + + done(); + }); + }); +}); + +describe('Style#addSprite', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.addSprite('test', 'https://example.com/sprite')).toThrow(/load/i); + }); + + test('validates input and fires an error if there\'s already an existing sprite with the same id', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + style.on('error', (error) => { + expect(error.error.message).toMatch(/sprite: all the sprites' ids must be unique, but test is duplicated/); + done(); + }); + + style.addSprite('test', 'https://example.com/sprite'); + style.addSprite('test', 'https://example.com/sprite2'); + }); + }); + + test('adds a new sprite to the stylesheet when there\'s no sprite at all', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + style.addSprite('test', 'https://example.com/sprite'); + expect(style.stylesheet.sprite).toStrictEqual([{id: 'test', url: 'https://example.com/sprite'}]); + done(); + }); + }); + + test('adds a new sprite to the stylesheet when there\'s a stringy sprite existing', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({sprite: 'https://example.com/default'})); + style.on('style.load', () => { + style.addSprite('test', 'https://example.com/sprite'); + expect(style.stylesheet.sprite).toStrictEqual([ + {id: 'default', url: 'https://example.com/default'}, + {id: 'test', url: 'https://example.com/sprite'} + ]); + done(); + }); + }); + + test('adds a new sprite to the stylesheet when there\'s an array-sprite existing', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({sprite: [{id: 'default', url: 'https://example.com/default'}]})); + style.on('style.load', () => { + style.addSprite('test', 'https://example.com/sprite'); + expect(style.stylesheet.sprite).toStrictEqual([ + {id: 'default', url: 'https://example.com/default'}, + {id: 'test', url: 'https://example.com/sprite'} + ]); + done(); + }); + }); +}); + +describe('Style#removeSprite', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.removeSprite('test')).toThrow(/load/i); + }); + + test('fires an error when trying to delete an non-existing sprite (sprite: undefined)', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + style.on('error', (error) => { + expect(error.error.message).toMatch(/Sprite \"test\" doesn't exists on this map./); + done(); + }); + + style.removeSprite('test'); + }); + }); + + test('fires an error when trying to delete an non-existing sprite (sprite: single url)', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({sprite: 'https://example.com/sprite'})); + style.on('style.load', () => { + style.on('error', (error) => { + expect(error.error.message).toMatch(/Sprite \"test\" doesn't exists on this map./); + done(); + }); + + style.removeSprite('test'); + }); + }); + + test('fires an error when trying to delete an non-existing sprite (sprite: array)', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({sprite: [{id: 'default', url: 'https://example.com/sprite'}]})); + style.on('style.load', () => { + style.on('error', (error) => { + expect(error.error.message).toMatch(/Sprite \"test\" doesn't exists on this map./); + done(); + }); + + style.removeSprite('test'); + }); + }); + + test('removes the sprite when it\'s a single URL', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({sprite: 'https://example.com/test'})); + style.on('style.load', () => { + style.removeSprite('default'); + expect(style.stylesheet.sprite).toBeUndefined(); + done(); + }); + }); + + test('removes the sprite when it\'s an array', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON([{id: 'default', url: 'https://example.com/sprite'}])); + style.on('style.load', () => { + style.removeSprite('default'); + expect(style.stylesheet.sprite).toBeUndefined(); + done(); + }); + }); +}); + +describe('Style#setGeoJSONSourceData', () => { + const geoJSON = {type: 'FeatureCollection', features: []} as GeoJSON.GeoJSON; + + test('throws before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.setGeoJSONSourceData('source-id', geoJSON)).toThrow(/load/i); + }); + + test('throws on non-existence', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + expect(() => style.setGeoJSONSourceData('source-id', geoJSON)).toThrow(/There is no source with this ID/); + done(); + }); + }); +}); + +describe('Style#addLayer', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.addLayer({id: 'background', type: 'background'})).toThrow(/load/i); + }); + + test('sets up layer event forwarding', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + + style.on('error', (e) => { + expect(e.layer).toEqual({id: 'background'}); + expect(e.mapLibre).toBeTruthy(); + done(); + }); + + style.on('style.load', () => { + style.addLayer({ + id: 'background', + type: 'background' + }); + style._layers.background.fire(new Event('error', {mapLibre: true})); + }); + }); + + test('throws on non-existant vector source layer', done => { + const style = createStyle(); + style.loadJSON(createStyleJSON({ + sources: { + // At least one source must be added to trigger the load event + dummy: {type: 'vector', tiles: []} + } + })); + + style.on('style.load', () => { + const source = createSource(); + source['vector_layers'] = [{id: 'green'}]; + style.addSource('-source-id-', source); + style.addLayer({ + 'id': '-layer-id-', + 'type': 'circle', + 'source': '-source-id-', + 'source-layer': '-source-layer-' + }); + }); + + style.on('error', (event) => { + const err = event.error; + + expect(err).toBeTruthy(); + expect(err.toString().indexOf('-source-layer-') !== -1).toBeTruthy(); + expect(err.toString().indexOf('-source-id-') !== -1).toBeTruthy(); + expect(err.toString().indexOf('-layer-id-') !== -1).toBeTruthy(); + + done(); + }); + }); + + test('emits error on invalid layer', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + style.on('error', () => { + expect(style.getLayer('background')).toBeFalsy(); + done(); + }); + style.addLayer({ + id: 'background', + type: 'background', + paint: { + 'background-opacity': 5 + } + }); + }); + }); + + test('#4040 does not mutate source property when provided inline', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + style.on('style.load', () => { + const source = { + 'type': 'geojson', + 'data': { + 'type': 'Point', + 'coordinates': [0, 0] + } + }; + const layer = {id: 'inline-source-layer', type: 'circle', source} as any as LayerSpecification; + style.addLayer(layer); + expect((layer as any).source).toEqual(source); + done(); + }); + }); + + test('reloads source', done => { + const style = createStyle(); + style.loadJSON(extend(createStyleJSON(), { + 'sources': { + 'mapLibre': { + 'type': 'vector', + 'tiles': [] + } + } + })); + const layer = { + 'id': 'symbol', + 'type': 'symbol', + 'source': 'mapLibre', + 'source-layer': 'libremap', + 'filter': ['==', 'id', 0] + } as LayerSpecification; + + style.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'content') { + style.sourceCaches['mapLibre'].reload = function() { done(); }; + style.addLayer(layer); + style.update({} as EvaluationParameters); + } + }); + }); + + test('#3895 reloads source (instead of clearing) if adding this layer with the same type, immediately after removing it', done => { + const style = createStyle(); + style.loadJSON(extend(createStyleJSON(), { + 'sources': { + 'mapLibre': { + 'type': 'vector', + 'tiles': [] + } + }, + layers: [{ + 'id': 'my-layer', + 'type': 'symbol', + 'source': 'mapLibre', + 'source-layer': 'libremap', + 'filter': ['==', 'id', 0] + }] + })); + + const layer = { + 'id': 'my-layer', + 'type': 'symbol', + 'source': 'mapLibre', + 'source-layer': 'libremap' + }as LayerSpecification; + + style.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'content') { + style.sourceCaches['mapLibre'].reload = function() { done(); }; + style.sourceCaches['mapLibre'].clearTiles = function() { done('test failed'); }; + style.removeLayer('my-layer'); + style.addLayer(layer); + style.update({} as EvaluationParameters); + } + }); + + }); + + test('clears source (instead of reloading) if adding this layer with a different type, immediately after removing it', done => { + const style = createStyle(); + style.loadJSON(extend(createStyleJSON(), { + 'sources': { + 'mapLibre': { + 'type': 'vector', + 'tiles': [] + } + }, + layers: [{ + 'id': 'my-layer', + 'type': 'symbol', + 'source': 'mapLibre', + 'source-layer': 'libremap', + 'filter': ['==', 'id', 0] + }] + })); + + const layer = { + 'id': 'my-layer', + 'type': 'circle', + 'source': 'mapLibre', + 'source-layer': 'libremap' + }as LayerSpecification; + style.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'content') { + style.sourceCaches['mapLibre'].reload = function() { done('test failed'); }; + style.sourceCaches['mapLibre'].clearTiles = function() { done(); }; + style.removeLayer('my-layer'); + style.addLayer(layer); + style.update({} as EvaluationParameters); + } + }); + + }); + + test('fires "data" event', async () => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const layer = {id: 'background', type: 'background'} as LayerSpecification; + + const dataPromise = style.once('data'); + + style.on('style.load', () => { + style.addLayer(layer); + style.update({} as EvaluationParameters); + }); + await dataPromise; + }); + + test('emits error on duplicates', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const layer = {id: 'background', type: 'background'} as LayerSpecification; + + style.on('error', (e) => { + expect(e.error.message).toMatch(/already exists/); + done(); + }); + + style.on('style.load', () => { + style.addLayer(layer); + style.addLayer(layer); + }); + }); + + test('adds to the end by default', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'a', + type: 'background' + }, { + id: 'b', + type: 'background' + }] + })); + const layer = {id: 'c', type: 'background'} as LayerSpecification; + + style.on('style.load', () => { + style.addLayer(layer); + expect(style._order).toEqual(['a', 'b', 'c']); + done(); + }); + }); + + test('adds before the given layer', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'a', + type: 'background' + }, { + id: 'b', + type: 'background' + }] + })); + const layer = {id: 'c', type: 'background'} as LayerSpecification; + + style.on('style.load', () => { + style.addLayer(layer, 'a'); + expect(style._order).toEqual(['c', 'a', 'b']); + done(); + }); + }); + + test('fire error if before layer does not exist', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'a', + type: 'background' + }, { + id: 'b', + type: 'background' + }] + })); + const layer = {id: 'c', type: 'background'} as LayerSpecification; + + style.on('style.load', () => { + style.on('error', (error) => { + expect(error.error.message).toMatch(/Cannot add layer "c" before non-existing layer "z"./); + done(); + }); + style.addLayer(layer, 'z'); + }); + }); + + test('fires an error on non-existant source layer', done => { + const style = new Style(getStubMap()); + style.loadJSON(extend(createStyleJSON(), { + sources: { + dummy: { + type: 'geojson', + data: {type: 'FeatureCollection', features: []} + } + } + })); + + const layer = { + id: 'dummy', + type: 'fill', + source: 'dummy', + 'source-layer': 'dummy' + }as LayerSpecification; + + style.on('style.load', () => { + style.on('error', ({error}) => { + expect(error.message).toMatch(/does not exist on source/); + done(); + }); + style.addLayer(layer); + }); + + }); +}); + +describe('Style#removeLayer', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.removeLayer('background')).toThrow(/load/i); + }); + + test('fires "data" event', async () => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const layer = {id: 'background', type: 'background'} as LayerSpecification; + + const dataPromise = style.once('data'); + + style.on('style.load', () => { + style.addLayer(layer); + style.removeLayer('background'); + style.update({} as EvaluationParameters); + }); + + await dataPromise; + }); + + test('tears down layer event forwarding', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'background', + type: 'background' + }] + })); + + style.on('error', () => { + done('test failed'); + }); + + style.on('style.load', () => { + const layer = style._layers.background; + style.removeLayer('background'); + + // Bind a listener to prevent fallback Evented error reporting. + layer.on('error', () => {}); + + layer.fire(new Event('error', {mapLibre: true})); + done(); + }); + }); + + test('fires an error on non-existence', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + + style.on('style.load', () => { + style.on('error', ({error}) => { + expect(error.message).toMatch(/Cannot remove non-existing layer "background"./); + done(); + }); + style.removeLayer('background'); + }); + }); + + test('removes from the order', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'a', + type: 'background' + }, { + id: 'b', + type: 'background' + }] + })); + + style.on('style.load', () => { + style.removeLayer('a'); + expect(style._order).toEqual(['b']); + done(); + }); + }); + + test('does not remove dereffed layers', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [{ + id: 'a', + type: 'background' + }, { + id: 'b', + ref: 'a' + }] + })); + + style.on('style.load', () => { + style.removeLayer('a'); + expect(style.getLayer('a')).toBeUndefined(); + expect(style.getLayer('b')).toBeDefined(); + done(); + }); + }); +}); + +describe('Style#moveLayer', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.moveLayer('background')).toThrow(/load/i); + }); + + test('fires "data" event', async () => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + const layer = {id: 'background', type: 'background'} as LayerSpecification; + + const dataPromise = style.once('data'); + style.on('style.load', () => { + style.addLayer(layer); + style.moveLayer('background'); + style.update({} as EvaluationParameters); + }); + await dataPromise; + }); + + test('fires an error on non-existence', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + + style.on('style.load', () => { + style.on('error', ({error}) => { + expect(error.message).toMatch(/does not exist in the map\'s style and cannot be moved/); + done(); + }); + style.moveLayer('background'); + }); + }); + + test('changes the order', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [ + {id: 'a', type: 'background'}, + {id: 'b', type: 'background'}, + {id: 'c', type: 'background'} + ] + })); + + style.on('style.load', () => { + style.moveLayer('a', 'c'); + expect(style._order).toEqual(['b', 'a', 'c']); + done(); + }); + }); + + test('moves to existing location', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + layers: [ + {id: 'a', type: 'background'}, + {id: 'b', type: 'background'}, + {id: 'c', type: 'background'} + ] + })); + + style.on('style.load', () => { + style.moveLayer('b', 'b'); + expect(style._order).toEqual(['a', 'b', 'c']); + done(); + }); + }); +}); + +describe('Style#setPaintProperty', () => { + test('#4738 postpones source reload until layers have been broadcast to workers', done => { + const style = new Style(getStubMap()); + style.loadJSON(extend(createStyleJSON(), { + 'sources': { + 'geojson': { + 'type': 'geojson', + 'data': {'type': 'FeatureCollection', 'features': []} + } + }, + 'layers': [ + { + 'id': 'circle', + 'type': 'circle', + 'source': 'geojson' + } + ] + })); + + const tr = new Transform(); + tr.resize(512, 512); + + style.once('style.load', () => { + style.update(tr.zoom as any as EvaluationParameters); + const sourceCache = style.sourceCaches['geojson']; + const source = style.getSource('geojson'); + + let begun = false; + let styleUpdateCalled = false; + + (source as any).on('data', (e) => setTimeout(() => { + if (!begun) { + begun = true; + jest.spyOn(sourceCache, 'reload').mockImplementation(() => { + expect(styleUpdateCalled).toBeTruthy(); + done(); + }); + + (source as any).setData({'type': 'FeatureCollection', 'features': []}); + style.setPaintProperty('circle', 'circle-color', {type: 'identity', property: 'foo'}); + } + + if (begun && e.sourceDataType === 'content') { + // setData() worker-side work is complete; simulate an + // animation frame a few ms later, so that this test can + // confirm that SourceCache#reload() isn't called until + // after the next Style#update() + setTimeout(() => { + styleUpdateCalled = true; + style.update({} as EvaluationParameters); + }, 50); + } + })); + }); + }); + + test('#5802 clones the input', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [ + { + 'id': 'background', + 'type': 'background' + } + ] + }); + + style.on('style.load', () => { + const value = {stops: [[0, 'red'], [10, 'blue']]}; + style.setPaintProperty('background', 'background-color', value); + expect(style.getPaintProperty('background', 'background-color')).not.toBe(value); + expect(style._changed).toBeTruthy(); + + style.update({} as EvaluationParameters); + expect(style._changed).toBeFalsy(); + + value.stops[0][0] = 1; + style.setPaintProperty('background', 'background-color', value); + expect(style._changed).toBeTruthy(); + + done(); + }); + }); + + test('respects validate option', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [ + { + 'id': 'background', + 'type': 'background' + } + ] + }); + + style.on('style.load', () => { + const backgroundLayer = style.getLayer('background'); + const validate = jest.spyOn(backgroundLayer, '_validate'); + + style.setPaintProperty('background', 'background-color', 'notacolor', {validate: false}); + expect(validate.mock.calls[0][4]).toEqual({validate: false}); + expect(mockConsoleError).not.toHaveBeenCalled(); + + expect(style._changed).toBeTruthy(); + style.update({} as EvaluationParameters); + + style.setPaintProperty('background', 'background-color', 'alsonotacolor'); + expect(mockConsoleError).toHaveBeenCalledTimes(1); + expect(validate.mock.calls[1][4]).toEqual({}); + + done(); + }); + }); +}); + +describe('Style#getPaintProperty', () => { + test('#5802 clones the output', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [ + { + 'id': 'background', + 'type': 'background' + } + ] + }); + + style.on('style.load', () => { + style.setPaintProperty('background', 'background-color', {stops: [[0, 'red'], [10, 'blue']]}); + style.update({} as EvaluationParameters); + expect(style._changed).toBeFalsy(); + + const value = style.getPaintProperty('background', 'background-color'); + value['stops'][0][0] = 1; + style.setPaintProperty('background', 'background-color', value); + expect(style._changed).toBeTruthy(); + + done(); + }); + }); +}); + +describe('Style#setLayoutProperty', () => { + test('#5802 clones the input', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'geojson': { + 'type': 'geojson', + 'data': { + 'type': 'FeatureCollection', + 'features': [] + } + } + }, + 'layers': [ + { + 'id': 'line', + 'type': 'line', + 'source': 'geojson' + } + ] + }); + + style.on('style.load', () => { + const value = {stops: [[0, 'butt'], [10, 'round']]}; + style.setLayoutProperty('line', 'line-cap', value); + expect(style.getLayoutProperty('line', 'line-cap')).not.toBe(value); + expect(style._changed).toBeTruthy(); + + style.update({} as EvaluationParameters); + expect(style._changed).toBeFalsy(); + + value.stops[0][0] = 1; + style.setLayoutProperty('line', 'line-cap', value); + expect(style._changed).toBeTruthy(); + + done(); + }); + }); + + test('respects validate option', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'geojson': { + 'type': 'geojson', + 'data': { + 'type': 'FeatureCollection', + 'features': [] + } + } + }, + 'layers': [ + { + 'id': 'line', + 'type': 'line', + 'source': 'geojson' + } + ] + }); + + style.on('style.load', () => { + const lineLayer = style.getLayer('line'); + const validate = jest.spyOn(lineLayer, '_validate'); + + style.setLayoutProperty('line', 'line-cap', 'invalidcap', {validate: false}); + expect(validate.mock.calls[0][4]).toEqual({validate: false}); + expect(mockConsoleError).not.toHaveBeenCalled(); + expect(style._changed).toBeTruthy(); + style.update({} as EvaluationParameters); + + style.setLayoutProperty('line', 'line-cap', 'differentinvalidcap'); + expect(mockConsoleError).toHaveBeenCalledTimes(1); + expect(validate.mock.calls[1][4]).toEqual({}); + + done(); + }); + }); +}); + +describe('Style#getLayoutProperty', () => { + test('#5802 clones the output', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'geojson': { + 'type': 'geojson', + 'data': { + 'type': 'FeatureCollection', + 'features': [] + } + } + }, + 'layers': [ + { + 'id': 'line', + 'type': 'line', + 'source': 'geojson' + } + ] + }); + + style.on('style.load', () => { + style.setLayoutProperty('line', 'line-cap', {stops: [[0, 'butt'], [10, 'round']]}); + style.update({} as EvaluationParameters); + expect(style._changed).toBeFalsy(); + + const value = style.getLayoutProperty('line', 'line-cap'); + value.stops[0][0] = 1; + style.setLayoutProperty('line', 'line-cap', value); + expect(style._changed).toBeTruthy(); + + done(); + }); + }); +}); + +describe('Style#setFilter', () => { + test('throws if style is not loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.setFilter('symbol', ['==', 'id', 1])).toThrow(/load/i); + }); + + function createStyle() { + const style = new Style(getStubMap()); + style.loadJSON({ + version: 8, + sources: { + geojson: createGeoJSONSource() as GeoJSONSourceSpecification + }, + layers: [ + {id: 'symbol', type: 'symbol', source: 'geojson', filter: ['==', 'id', 0]} + ] + }); + return style; + } + + test('sets filter', done => { + const style = createStyle(); + + style.on('style.load', () => { + style.dispatcher.broadcast = function(key, value) { + expect(key).toBe('updateLayers'); + expect(value['layers'][0].id).toBe('symbol'); + expect(value['layers'][0].filter).toEqual(['==', 'id', 1]); + done(); + }; + + style.setFilter('symbol', ['==', 'id', 1]); + expect(style.getFilter('symbol')).toEqual(['==', 'id', 1]); + style.update({} as EvaluationParameters); // trigger dispatcher broadcast + }); + }); + + test('gets a clone of the filter', done => { + const style = createStyle(); + + style.on('style.load', () => { + const filter1 = ['==', 'id', 1] as FilterSpecification; + style.setFilter('symbol', filter1); + const filter2 = style.getFilter('symbol'); + const filter3 = style.getLayer('symbol').filter; + + expect(filter1).not.toBe(filter2); + expect(filter1).not.toBe(filter3); + expect(filter2).not.toBe(filter3); + + done(); + }); + }); + + test('sets again mutated filter', done => { + const style = createStyle(); + + style.on('style.load', () => { + const filter = ['==', 'id', 1] as FilterSpecification; + style.setFilter('symbol', filter); + style.update({} as EvaluationParameters); // flush pending operations + + style.dispatcher.broadcast = function(key, value) { + expect(key).toBe('updateLayers'); + expect(value['layers'][0].id).toBe('symbol'); + expect(value['layers'][0].filter).toEqual(['==', 'id', 2]); + done(); + }; + filter[2] = 2; + style.setFilter('symbol', filter); + style.update({} as EvaluationParameters); // trigger dispatcher broadcast + }); + }); + + test('unsets filter', done => { + const style = createStyle(); + style.on('style.load', () => { + style.setFilter('symbol', null); + expect(style.getLayer('symbol').serialize()['filter']).toBeUndefined(); + done(); + }); + }); + + test('emits if invalid', done => { + const style = createStyle(); + style.on('style.load', () => { + style.on('error', () => { + expect(style.getLayer('symbol').serialize()['filter']).toEqual(['==', 'id', 0]); + done(); + }); + style.setFilter('symbol', ['==', '$type', 1]); + }); + }); + + test('fires an error if layer not found', done => { + const style = createStyle(); + + style.on('style.load', () => { + style.on('error', ({error}) => { + expect(error.message).toMatch(/Cannot filter non-existing layer "non-existant"./); + done(); + }); + style.setFilter('non-existant', ['==', 'id', 1]); + }); + }); + + test('validates filter by default', done => { + const style = createStyle(); + style.on('style.load', () => { + style.setFilter('symbol', 'notafilter' as any as FilterSpecification); + expect(style.getFilter('symbol')).toEqual(['==', 'id', 0]); + expect(mockConsoleError).toHaveBeenCalledTimes(1); + style.update({} as EvaluationParameters); // trigger dispatcher broadcast + done(); + }); + }); + + test('respects validate option', done => { + const style = createStyle(); + + style.on('style.load', () => { + style.dispatcher.broadcast = function(key, value) { + expect(key).toBe('updateLayers'); + expect(value['layers'][0].id).toBe('symbol'); + expect(value['layers'][0].filter).toBe('notafilter'); + done(); + }; + + style.setFilter('symbol', 'notafilter' as any as FilterSpecification, {validate: false}); + expect(style.getFilter('symbol')).toBe('notafilter'); + style.update({} as EvaluationParameters); // trigger dispatcher broadcast + }); + }); +}); + +describe('Style#setLayerZoomRange', () => { + test('throw before loaded', () => { + const style = new Style(getStubMap()); + expect(() => style.setLayerZoomRange('symbol', 5, 12)).toThrow(/load/i); + }); + + function createStyle() { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'geojson': createGeoJSONSource() as GeoJSONSourceSpecification + }, + 'layers': [{ + 'id': 'symbol', + 'type': 'symbol', + 'source': 'geojson' + }] + }); + return style; + } + + test('sets zoom range', done => { + const style = createStyle(); + + style.on('style.load', () => { + style.dispatcher.broadcast = function(key, value) { + expect(key).toBe('updateLayers'); + expect(value['layers'].map((layer) => { return layer.id; })).toEqual(['symbol']); + done(); + }; + style.setLayerZoomRange('symbol', 5, 12); + expect(style.getLayer('symbol').minzoom).toBe(5); + expect(style.getLayer('symbol').maxzoom).toBe(12); + style.update({} as EvaluationParameters); // trigger dispatcher broadcast + }); + }); + + test('fires an error if layer not found', done => { + const style = createStyle(); + style.on('style.load', () => { + style.on('error', ({error}) => { + expect(error.message).toMatch(/Cannot set the zoom range of non-existing layer "non-existant"./); + done(); + }); + style.setLayerZoomRange('non-existant', 5, 12); + }); + }); + + test('does not reload raster source', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'raster': { + type: 'raster', + tiles: ['http://tiles.server'] + } + }, + 'layers': [{ + 'id': 'raster', + 'type': 'raster', + 'source': 'raster' + }] + }); + + style.on('style.load', () => { + jest.spyOn(style, '_reloadSource'); + + style.setLayerZoomRange('raster', 5, 12); + style.update(0 as any as EvaluationParameters); + expect(style._reloadSource).not.toHaveBeenCalled(); + done(); + }); + }); +}); + +describe('Style#getLayersOrder', () => { + test('returns ids of layers in the correct order', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'raster': { + type: 'raster', + tiles: ['http://tiles.server'] + } + }, + 'layers': [{ + 'id': 'raster', + 'type': 'raster', + 'source': 'raster' + }] + }); + + style.on('style.load', () => { + style.addLayer({ + id: 'custom', + type: 'custom', + render() {} + }, 'raster'); + expect(style.getLayersOrder()).toEqual(['custom', 'raster']); + done(); + }); + }); +}); + +describe('Style#queryRenderedFeatures', () => { + + let style; + let transform; + + beforeEach((callback) => { + style = new Style(getStubMap()); + transform = new Transform(); + transform.resize(512, 512); + function queryMapLibreFeatures(layers, serializedLayers, getFeatureState, queryGeom, cameraQueryGeom, scale, params) { + const features = { + 'land': [{ + type: 'Feature', + layer: style._layers.land.serialize(), + geometry: { + type: 'Polygon' + } + }, { + type: 'Feature', + layer: style._layers.land.serialize(), + geometry: { + type: 'Point' + } + }], + 'landref': [{ + type: 'Feature', + layer: style._layers.landref.serialize(), + geometry: { + type: 'Line' + } + }] + }; + + // format result to shape of tile.queryRenderedFeatures result + for (const layer in features) { + features[layer] = features[layer].map((feature, featureIndex) => + ({feature, featureIndex})); + } + + if (params.layers) { + for (const l in features) { + if (params.layers.indexOf(l) < 0) { + delete features[l]; + } + } + } + + return features; + } + + style.loadJSON({ + 'version': 8, + 'sources': { + 'mapLibre': { + 'type': 'geojson', + 'data': {type: 'FeatureCollection', features: []} + }, + 'other': { + 'type': 'geojson', + 'data': {type: 'FeatureCollection', features: []} + } + }, + 'layers': [{ + 'id': 'land', + 'type': 'line', + 'source': 'mapLibre', + 'source-layer': 'water', + 'layout': { + 'line-cap': 'round' + }, + 'paint': { + 'line-color': 'red' + }, + 'metadata': { + 'something': 'else' + } + }, { + 'id': 'landref', + 'ref': 'land', + 'paint': { + 'line-color': 'blue' + } + } as any as LayerSpecification, { + 'id': 'land--other', + 'type': 'line', + 'source': 'other', + 'source-layer': 'water', + 'layout': { + 'line-cap': 'round' + }, + 'paint': { + 'line-color': 'red' + }, + 'metadata': { + 'something': 'else' + } + }] + }); + + style.on('style.load', () => { + style.sourceCaches.mapLibre.tilesIn = () => { + return [{ + tile: {queryRenderedFeatures: queryMapLibreFeatures}, + tileID: new OverscaledTileID(0, 0, 0, 0, 0), + queryGeometry: [], + scale: 1 + }]; + }; + style.sourceCaches.other.tilesIn = () => { + return []; + }; + + style.sourceCaches.mapLibre.transform = transform; + style.sourceCaches.other.transform = transform; + + style.update(0 as any as EvaluationParameters); + style._updateSources(transform); + callback(); + }); + }); + + afterEach(() => { + style = undefined; + transform = undefined; + }); + + test('returns feature type', () => { + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {}, transform); + expect(results[0].geometry.type).toBe('Line'); + }); + + test('filters by `layers` option', () => { + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {layers: ['land']}, transform); + expect(results).toHaveLength(2); + }); + + test('checks type of `layers` option', () => { + let errors = 0; + jest.spyOn(style, 'fire').mockImplementation((event) => { + if (event['error'] && event['error'].message.includes('parameters.layers must be an Array.')) { + errors++; + } + }); + style.queryRenderedFeatures([{x: 0, y: 0}], {layers: 'string'}, transform); + expect(errors).toBe(1); + }); + + test('includes layout properties', () => { + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {}, transform); + const layout = results[0].layer.layout; + expect(layout['line-cap']).toBe('round'); + }); + + test('includes paint properties', () => { + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {}, transform); + expect(results[2].layer.paint['line-color']).toBe('red'); + }); + + test('includes metadata', () => { + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {}, transform); + + const layer = results[1].layer; + expect(layer.metadata.something).toBe('else'); + + }); + + test('include multiple layers', () => { + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {layers: ['land', 'landref']}, transform); + expect(results).toHaveLength(3); + }); + + test('does not query sources not implicated by `layers` parameter', () => { + style.sourceCaches.mapLibre.queryRenderedFeatures = function() { expect(true).toBe(false); }; + style.queryRenderedFeatures([{x: 0, y: 0}], {layers: ['land--other']}, transform); + }); + + test('fires an error if layer included in params does not exist on the style', () => { + let errors = 0; + jest.spyOn(style, 'fire').mockImplementation((event) => { + if (event['error'] && event['error'].message.includes('does not exist in the map\'s style and cannot be queried for features.')) errors++; + }); + const results = style.queryRenderedFeatures([{x: 0, y: 0}], {layers: ['merp']}, transform); + expect(errors).toBe(1); + expect(results).toHaveLength(0); + }); +}); + +describe('Style defers ...', () => { + test('... expensive methods', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON({ + 'sources': { + 'streets': createGeoJSONSource(), + 'terrain': createGeoJSONSource() + } + })); + + style.on('style.load', () => { + style.update({} as EvaluationParameters); + + // spies to track deferred methods + const mockStyleFire = jest.spyOn(style, 'fire'); + jest.spyOn(style, '_reloadSource'); + jest.spyOn(style, '_updateWorkerLayers'); + + style.addLayer({id: 'first', type: 'symbol', source: 'streets'}); + style.addLayer({id: 'second', type: 'symbol', source: 'streets'}); + style.addLayer({id: 'third', type: 'symbol', source: 'terrain'}); + + style.setPaintProperty('first', 'text-color', 'black'); + style.setPaintProperty('first', 'text-halo-color', 'white'); + + expect(style.fire).not.toHaveBeenCalled(); + expect(style._reloadSource).not.toHaveBeenCalled(); + expect(style._updateWorkerLayers).not.toHaveBeenCalled(); + + style.update({} as EvaluationParameters); + + expect(mockStyleFire.mock.calls[0][0]['type']).toBe('data'); + + // called per source + expect(style._reloadSource).toHaveBeenCalledTimes(2); + expect(style._reloadSource).toHaveBeenCalledWith('streets'); + expect(style._reloadSource).toHaveBeenCalledWith('terrain'); + + // called once + expect(style._updateWorkerLayers).toHaveBeenCalledTimes(1); + + done(); + }); + }); +}); + +describe('Style#query*Features', () => { + + // These tests only cover filter validation. Most tests for these methods + // live in the integration tests. + + let style; + let onError; + let transform; + + beforeEach((callback) => { + transform = new Transform(); + transform.resize(100, 100); + style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': { + 'geojson': createGeoJSONSource() + }, + 'layers': [{ + 'id': 'symbol', + 'type': 'symbol', + 'source': 'geojson' + }] + }); + + onError = jest.fn(); + + style.on('error', onError) + .on('style.load', () => { + callback(); + }); + }); + + test('querySourceFeatures emits an error on incorrect filter', () => { + expect(style.querySourceFeatures([10, 100], {filter: 7}, transform)).toEqual([]); + expect(onError.mock.calls[0][0].error.message).toMatch(/querySourceFeatures\.filter/); + }); + + test('queryRenderedFeatures emits an error on incorrect filter', () => { + expect(style.queryRenderedFeatures([{x: 0, y: 0}], {filter: 7}, transform)).toEqual([]); + expect(onError.mock.calls[0][0].error.message).toMatch(/queryRenderedFeatures\.filter/); + }); + + test('querySourceFeatures not raise validation errors if validation was disabled', () => { + let errors = 0; + jest.spyOn(style, 'fire').mockImplementation((event) => { + if (event['error']) { + errors++; + } + }); + style.queryRenderedFeatures([{x: 0, y: 0}], {filter: 'invalidFilter', validate: false}, transform); + expect(errors).toBe(0); + }); + + test('querySourceFeatures not raise validation errors if validation was disabled', () => { + let errors = 0; + jest.spyOn(style, 'fire').mockImplementation((event) => { + if (event['error']) errors++; + }); + style.querySourceFeatures([{x: 0, y: 0}], {filter: 'invalidFilter', validate: false}, transform); + expect(errors).toBe(0); + }); + + test('serialized layers should be correctly updated after adding/removing layers', () => { + + let serializedStyle = style.serialize(); + expect(serializedStyle.layers).toHaveLength(1); + expect(serializedStyle.layers[0].id).toBe('symbol'); + + const layer = { + id: 'background', + type: 'background' + } as LayerSpecification; + style.addLayer(layer); + + // serialize again + serializedStyle = style.serialize(); + expect(serializedStyle.layers).toHaveLength(2); + expect(serializedStyle.layers[1].id).toBe('background'); + + // remove and serialize + style.removeLayer('background'); + serializedStyle = style.serialize(); + expect(serializedStyle.layers).toHaveLength(1); + + }); +}); + +describe('Style#addSourceType', () => { + test('adds factory function', done => { + const style = new Style(getStubMap()); + const sourceType = function () {} as any as SourceClass; + + // expect no call to load worker source + style.dispatcher.broadcast = function (type) { + if (type === 'loadWorkerSource') { + done('test failed'); + } + }; + + style.addSourceType('foo', sourceType, (arg1, arg2) => { + expect(arg1).toBeNull(); + expect(arg2).toBeNull(); + done(); + }); + }); + + test('triggers workers to load worker source code', done => { + const style = new Style(getStubMap()); + const sourceType = function () {} as any as SourceClass; + sourceType.workerSourceURL = 'worker-source.js' as any as URL; + + style.dispatcher.broadcast = (type, params) => { + if (type === 'loadWorkerSource') { + expect(params['name']).toBe('bar'); + expect(params['url']).toBe('worker-source.js'); + done(); + } + }; + + style.addSourceType('bar', sourceType, (err) => { expect(err).toBeFalsy(); }); + }); + + test('refuses to add new type over existing name', done => { + const style = new Style(getStubMap()); + const sourceType = function () {} as any as SourceClass; + style.addSourceType('canvas', sourceType, (err) => { + expect(err).toBeTruthy(); + done(); + }); + }); +}); + +describe('Style#hasTransitions', () => { + test('returns false when the style is loading', () => { + const style = new Style(getStubMap()); + expect(style.hasTransitions()).toBe(false); + }); + + test('returns true when a property is transitioning', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [{ + 'id': 'background', + 'type': 'background' + }] + }); + + style.on('style.load', () => { + style.setPaintProperty('background', 'background-color', 'blue'); + style.update({transition: {duration: 300, delay: 0}} as EvaluationParameters); + expect(style.hasTransitions()).toBe(true); + done(); + }); + }); + + test('returns false when a property is not transitioning', done => { + const style = new Style(getStubMap()); + style.loadJSON({ + 'version': 8, + 'sources': {}, + 'layers': [{ + 'id': 'background', + 'type': 'background' + }] + }); + + style.on('style.load', () => { + style.setPaintProperty('background', 'background-color', 'blue'); + style.update({transition: {duration: 0, delay: 0}} as EvaluationParameters); + expect(style.hasTransitions()).toBe(false); + done(); + }); + }); +}); + +describe('Style#serialize', () => { + test('include terrain property when map has 3D terrain', done => { + const styleJson = createStyleJSON({terrain: { + source: 'terrainSource', + exaggeration: 1 + }}); + const style = new Style(getStubMap()); + style.loadJSON(styleJson); + + style.on('style.load', () => { + expect(style.serialize().terrain).toBe(styleJson.terrian); + done(); + }); + }); + + test('do not include terrain property when map does not have 3D terrain', done => { + const style = new Style(getStubMap()); + style.loadJSON(createStyleJSON()); + + style.on('style.load', () => { + expect(style.serialize().terrain).toBeUndefined(); + done(); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/style.ts b/web/libraries/maplibre-gl/src/style/style.ts new file mode 100644 index 00000000..a43d0ad4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style.ts @@ -0,0 +1,1745 @@ +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {StyleLayer} from './style_layer'; +import {createStyleLayer} from './create_style_layer'; +import {loadSprite} from './load_sprite'; +import {ImageManager} from '../render/image_manager'; +import {GlyphManager} from '../render/glyph_manager'; +import {Light} from './light'; +import {LineAtlas} from '../render/line_atlas'; +import {pick, clone, extend, deepEqual, filterObject, mapObject} from '../util/util'; +import {coerceSpriteToArray} from '../util/style'; +import {getJSON, getReferrer, makeRequest} from '../util/ajax'; +import {ResourceType} from '../util/request_manager'; +import {browser} from '../util/browser'; +import {Dispatcher} from '../util/dispatcher'; +import {validateStyle, emitValidationErrors as _emitValidationErrors} from './validate_style'; +import {getSourceType, setSourceType, Source} from '../source/source'; +import type {SourceClass} from '../source/source'; +import {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions, queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures} from '../source/query_features'; +import {SourceCache} from '../source/source_cache'; +import {GeoJSONSource} from '../source/geojson_source'; +import {latest as styleSpec, derefLayers as deref, emptyStyle, diff as diffStyles, operations as diffOperations} from '@maplibre/maplibre-gl-style-spec'; +import {getGlobalWorkerPool} from '../util/global_worker_pool'; +import { + registerForPluginStateChange, + evented as rtlTextPluginEvented, + triggerPluginCompletionEvent +} from '../source/rtl_text_plugin'; +import {PauseablePlacement} from './pauseable_placement'; +import {ZoomHistory} from './zoom_history'; +import {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index'; +import {validateCustomStyleLayer} from './style_layer/custom_style_layer'; +import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson'; + +// We're skipping validation errors with the `source.canvas` identifier in order +// to continue to allow canvas sources to be added at runtime/updated in +// smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424): +const emitValidationErrors = (evented: Evented, errors?: ReadonlyArray<{ + message: string; + identifier?: string; +}> | null) => + _emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas')); + +import type {Map} from '../ui/map'; +import type {Transform} from '../geo/transform'; +import type {StyleImage} from './style_image'; +import type {StyleGlyph} from './style_glyph'; +import type {Callback} from '../types/callback'; +import type {EvaluationParameters} from './evaluation_parameters'; +import type {Placement} from '../symbol/placement'; +import type {Cancelable} from '../types/cancelable'; +import type {RequestParameters, ResponseCallback} from '../util/ajax'; +import type { + LayerSpecification, + FilterSpecification, + StyleSpecification, + LightSpecification, + SourceSpecification, + SpriteSpecification, +} from '@maplibre/maplibre-gl-style-spec'; +import type {CustomLayerInterface} from './style_layer/custom_style_layer'; +import type {Validator} from './validate_style'; +import type {OverscaledTileID} from '../source/tile_id'; + +const supportedDiffOperations = pick(diffOperations, [ + 'addLayer', + 'removeLayer', + 'setPaintProperty', + 'setLayoutProperty', + 'setFilter', + 'addSource', + 'removeSource', + 'setLayerZoomRange', + 'setLight', + 'setTransition', + 'setGeoJSONSourceData', + 'setGlyphs', + 'setSprite', +]); + +const ignoredDiffOperations = pick(diffOperations, [ + 'setCenter', + 'setZoom', + 'setBearing', + 'setPitch' +]); + +const empty = emptyStyle() as StyleSpecification; +/** + * A feature identifier that is bound to a source + */ +export type FeatureIdentifier = { + /** + * Unique id of the feature. + */ + id?: string | number | undefined; + /** + * The id of the vector or GeoJSON source for the feature. + */ + source: string; + /** + * *For vector tile sources, `sourceLayer` is required.* + */ + sourceLayer?: string | undefined; +}; + +/** + * The options object related to the {@link Map}'s style related methods + */ +export type StyleOptions = { + /** + * If false, style validation will be skipped. Useful in production environment. + */ + validate?: boolean; + /** + * Defines a CSS + * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges. + * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold). + * Set to `false`, to enable font settings from the map's style for these glyph ranges. + * Forces a full update. + */ + localIdeographFontFamily?: string; +}; + +/** + * Supporting type to add validation to another style related type + */ +export type StyleSetterOptions = { + /** + * Whether to check if the filter conforms to the MapLibre Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. + */ + validate?: boolean; +}; + +/** + * Part of {@link Map#setStyle} options, transformStyle is a convenience function that allows to modify a style after it is fetched but before it is committed to the map state + * this function exposes previous and next styles, it can be commonly used to support a range of functionalities like: + * when previous style carries certain 'state' that needs to be carried over to a new style gracefully + * when a desired style is a certain combination of previous and incoming style + * when an incoming style requires modification based on external state + * + * @param previousStyle - The current style. + * @param nextStyle - The next style. + * @returns resulting style that will to be applied to the map + * + * @example + * ```ts + * map.setStyle('https://demotiles.maplibre.org/style.json', { + * transformStyle: (previousStyle, nextStyle) => ({ + * ...nextStyle, + * sources: { + * ...nextStyle.sources, + * // copy a source from previous style + * 'osm': previousStyle.sources.osm + * }, + * layers: [ + * // background layer + * nextStyle.layers[0], + * // copy a layer from previous style + * previousStyle.layers[0], + * // other layers from the next style + * ...nextStyle.layers.slice(1).map(layer => { + * // hide the layers we don't need from demotiles style + * if (layer.id.startsWith('geolines')) { + * layer.layout = {...layer.layout || {}, visibility: 'none'}; + * // filter out US polygons + * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) { + * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA']; + * } + * return layer; + * }) + * ] + * }) + * }); + * ``` + */ +export type TransformStyleFunction = (previous: StyleSpecification | undefined, next: StyleSpecification) => StyleSpecification; + +/** + * The options object related to the {@link Map}'s style related methods + */ +export type StyleSwapOptions = { + /** + * If false, force a 'full' update, removing the current style + * and building the given one instead of attempting a diff-based update. + */ + diff?: boolean; + /** + * TransformStyleFunction is a convenience function + * that allows to modify a style after it is fetched but before it is committed to the map state. Refer to {@link TransformStyleFunction}. + */ + transformStyle?: TransformStyleFunction; +} + +/** + * Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification} + * or a {@link CustomLayerInterface}, a {@link LayerSpecification} with an embedded {@link SourceSpecification} can also be provided. + */ +export type AddLayerObject = LayerSpecification | (Omit & {source: SourceSpecification}) | CustomLayerInterface; + +/** + * The Style base class + */ +export class Style extends Evented { + map: Map; + stylesheet: StyleSpecification; + dispatcher: Dispatcher; + imageManager: ImageManager; + glyphManager: GlyphManager; + lineAtlas: LineAtlas; + light: Light; + + _request: Cancelable; + _spriteRequest: Cancelable; + _layers: {[_: string]: StyleLayer}; + _serializedLayers: {[_: string]: LayerSpecification}; + _order: Array; + sourceCaches: {[_: string]: SourceCache}; + zoomHistory: ZoomHistory; + _loaded: boolean; + _rtlTextPluginCallback: (a: any) => any; + _changed: boolean; + _updatedSources: {[_: string]: 'clear' | 'reload'}; + _updatedLayers: {[_: string]: true}; + _removedLayers: {[_: string]: StyleLayer}; + _changedImages: {[_: string]: true}; + _glyphsDidChange: boolean; + _updatedPaintProps: {[layer: string]: true}; + _layerOrderChanged: boolean; + // image ids of images loaded from style's sprite + _spritesImagesIds: {[spriteId: string]: string[]}; + // image ids of all images loaded (sprite + user) + _availableImages: Array; + + crossTileSymbolIndex: CrossTileSymbolIndex; + pauseablePlacement: PauseablePlacement; + placement: Placement; + z: number; + + static registerForPluginStateChange: typeof registerForPluginStateChange; + + constructor(map: Map, options: StyleOptions = {}) { + super(); + + this.map = map; + this.dispatcher = new Dispatcher(getGlobalWorkerPool(), this, map._getMapId()); + this.imageManager = new ImageManager(); + this.imageManager.setEventedParent(this); + this.glyphManager = new GlyphManager(map._requestManager, options.localIdeographFontFamily); + this.lineAtlas = new LineAtlas(256, 512); + this.crossTileSymbolIndex = new CrossTileSymbolIndex(); + + this._spritesImagesIds = {}; + this._layers = {}; + + this._order = []; + this.sourceCaches = {}; + this.zoomHistory = new ZoomHistory(); + this._loaded = false; + this._availableImages = []; + + this._resetUpdates(); + + this.dispatcher.broadcast('setReferrer', getReferrer()); + + const self = this; + this._rtlTextPluginCallback = Style.registerForPluginStateChange((event) => { + const state = { + pluginStatus: event.pluginStatus, + pluginURL: event.pluginURL + }; + self.dispatcher.broadcast('syncRTLPluginState', state, (err, results) => { + triggerPluginCompletionEvent(err); + if (results) { + const allComplete = results.every((elem) => elem); + if (allComplete) { + for (const id in self.sourceCaches) { + const sourceType = self.sourceCaches[id].getSource().type; + if (sourceType === 'vector' || sourceType === 'geojson') { + // Non-vector sources don't have any symbols buckets to reload when the RTL text plugin loads + // They also load more quickly, so they're more likely to have already displaying tiles + // that would be unnecessarily booted by the plugin load event + self.sourceCaches[id].reload(); // Should be a no-op if the plugin loads before any tiles load + } + } + } + } + + }); + }); + + this.on('data', (event) => { + if (event.dataType !== 'source' || event.sourceDataType !== 'metadata') { + return; + } + + const sourceCache = this.sourceCaches[event.sourceId]; + if (!sourceCache) { + return; + } + + const source = sourceCache.getSource(); + if (!source || !source.vectorLayerIds) { + return; + } + + for (const layerId in this._layers) { + const layer = this._layers[layerId]; + if (layer.source === source.id) { + this._validateLayer(layer); + } + } + }); + } + + loadURL(url: string, options: StyleSwapOptions & StyleSetterOptions = {}, previousStyle?: StyleSpecification) { + this.fire(new Event('dataloading', {dataType: 'style'})); + + options.validate = typeof options.validate === 'boolean' ? + options.validate : true; + + const request = this.map._requestManager.transformRequest(url, ResourceType.Style); + this._request = getJSON(request, (error?: Error | null, json?: any | null) => { + this._request = null; + if (error) { + this.fire(new ErrorEvent(error)); + } else if (json) { + this._load(json, options, previousStyle); + } + }); + } + + loadJSON(json: StyleSpecification, options: StyleSetterOptions & StyleSwapOptions = {}, previousStyle?: StyleSpecification) { + this.fire(new Event('dataloading', {dataType: 'style'})); + + this._request = browser.frame(() => { + this._request = null; + options.validate = options.validate !== false; + this._load(json, options, previousStyle); + }); + } + + loadEmpty() { + this.fire(new Event('dataloading', {dataType: 'style'})); + this._load(empty, {validate: false}); + } + + _load(json: StyleSpecification, options: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification) { + const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json; + if (options.validate && emitValidationErrors(this, validateStyle(nextState))) { + return; + } + + this._loaded = true; + this.stylesheet = nextState; + + for (const id in nextState.sources) { + this.addSource(id, nextState.sources[id], {validate: false}); + } + + if (nextState.sprite) { + this._loadSprite(nextState.sprite); + } else { + this.imageManager.setLoaded(true); + } + + this.glyphManager.setURL(nextState.glyphs); + this._createLayers(); + + this.light = new Light(this.stylesheet.light); + + this.map.setTerrain(this.stylesheet.terrain ?? null); + + this.fire(new Event('data', {dataType: 'style'})); + this.fire(new Event('style.load')); + } + + private _createLayers() { + const dereferencedLayers = deref(this.stylesheet.layers); + + // Broadcast layers to workers first, so that expensive style processing (createStyleLayer) + // can happen in parallel on both main and worker threads. + this.dispatcher.broadcast('setLayers', dereferencedLayers); + + this._order = dereferencedLayers.map((layer) => layer.id); + this._layers = {}; + + // reset serialization field, to be populated only when needed + this._serializedLayers = null; + for (const layer of dereferencedLayers) { + const styledLayer = createStyleLayer(layer); + styledLayer.setEventedParent(this, {layer: {id: layer.id}}); + this._layers[layer.id] = styledLayer; + } + } + + _loadSprite(sprite: SpriteSpecification, isUpdate: boolean = false, completion: (err: Error) => void = undefined) { + this.imageManager.setLoaded(false); + + this._spriteRequest = loadSprite(sprite, this.map._requestManager, this.map.getPixelRatio(), (err, images) => { + this._spriteRequest = null; + if (err) { + this.fire(new ErrorEvent(err)); + } else if (images) { + for (const spriteId in images) { + this._spritesImagesIds[spriteId] = []; + + // remove old sprite's loaded images (for the same sprite id) that are not in new sprite + const imagesToRemove = this._spritesImagesIds[spriteId] ? this._spritesImagesIds[spriteId].filter(id => !(id in images)) : []; + for (const id of imagesToRemove) { + this.imageManager.removeImage(id); + this._changedImages[id] = true; + } + + for (const id in images[spriteId]) { + // don't prefix images of the "default" sprite + const imageId = spriteId === 'default' ? id : `${spriteId}:${id}`; + // save all the sprite's images' ids to be able to delete them in `removeSprite` + this._spritesImagesIds[spriteId].push(imageId); + if (imageId in this.imageManager.images) { + this.imageManager.updateImage(imageId, images[spriteId][id], false); + } else { + this.imageManager.addImage(imageId, images[spriteId][id]); + } + + if (isUpdate) { + this._changedImages[imageId] = true; + } + } + } + } + + this.imageManager.setLoaded(true); + this._availableImages = this.imageManager.listImages(); + + if (isUpdate) { + this._changed = true; + } + + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new Event('data', {dataType: 'style'})); + + if (completion) { + completion(err); + } + }); + } + + _unloadSprite() { + for (const id of Object.values(this._spritesImagesIds).flat()) { + this.imageManager.removeImage(id); + this._changedImages[id] = true; + } + + this._spritesImagesIds = {}; + this._availableImages = this.imageManager.listImages(); + this._changed = true; + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new Event('data', {dataType: 'style'})); + } + + _validateLayer(layer: StyleLayer) { + const sourceCache = this.sourceCaches[layer.source]; + if (!sourceCache) { + return; + } + + const sourceLayer = layer.sourceLayer; + if (!sourceLayer) { + return; + } + + const source = sourceCache.getSource(); + if (source.type === 'geojson' || (source.vectorLayerIds && source.vectorLayerIds.indexOf(sourceLayer) === -1)) { + this.fire(new ErrorEvent(new Error( + `Source layer "${sourceLayer}" ` + + `does not exist on source "${source.id}" ` + + `as specified by style layer "${layer.id}".` + ))); + } + } + + loaded() { + if (!this._loaded) + return false; + + if (Object.keys(this._updatedSources).length) + return false; + + for (const id in this.sourceCaches) + if (!this.sourceCaches[id].loaded()) + return false; + + if (!this.imageManager.isLoaded()) + return false; + + return true; + } + + /** + * take an array of string IDs, and based on this._layers, generate an array of LayerSpecification + * @param ids - an array of string IDs, for which serialized layers will be generated. If omitted, all serialized layers will be returned + * @returns generated result + */ + private _serializeByIds(ids?: Array): Array { + + const serializedLayersDictionary = this._serializedAllLayers(); + if (!ids || ids.length === 0) { + return Object.values(serializedLayersDictionary); + } + + const serializedLayers = []; + for (const id of ids) { + // this check will skip all custom layers + if (serializedLayersDictionary[id]) { + serializedLayers.push(serializedLayersDictionary[id]); + } + } + + return serializedLayers; + } + + /** + * Lazy initialization of this._serializedLayers dictionary and return it + * @returns this._serializedLayers dictionary + */ + private _serializedAllLayers(): {[_: string]: LayerSpecification} { + let serializedLayers = this._serializedLayers; + if (serializedLayers) { + return serializedLayers; + } + + serializedLayers = this._serializedLayers = {}; + const allLayerIds: string [] = Object.keys(this._layers); + for (const layerId of allLayerIds) { + const layer = this._layers[layerId]; + if (layer.type !== 'custom') { + serializedLayers[layerId] = layer.serialize(); + } + } + + return serializedLayers; + } + + hasTransitions() { + if (this.light && this.light.hasTransition()) { + return true; + } + + for (const id in this.sourceCaches) { + if (this.sourceCaches[id].hasTransition()) { + return true; + } + } + + for (const id in this._layers) { + if (this._layers[id].hasTransition()) { + return true; + } + } + + return false; + } + + _checkLoaded() { + if (!this._loaded) { + throw new Error('Style is not done loading.'); + } + } + + /** + * @internal + * Apply queued style updates in a batch and recalculate zoom-dependent paint properties. + */ + update(parameters: EvaluationParameters) { + if (!this._loaded) { + return; + } + + const changed = this._changed; + if (this._changed) { + const updatedIds = Object.keys(this._updatedLayers); + const removedIds = Object.keys(this._removedLayers); + + if (updatedIds.length || removedIds.length) { + this._updateWorkerLayers(updatedIds, removedIds); + } + for (const id in this._updatedSources) { + const action = this._updatedSources[id]; + + if (action === 'reload') { + this._reloadSource(id); + } else if (action === 'clear') { + this._clearSource(id); + } else { + throw new Error(`Invalid action ${action}`); + } + } + + this._updateTilesForChangedImages(); + this._updateTilesForChangedGlyphs(); + + for (const id in this._updatedPaintProps) { + this._layers[id].updateTransitions(parameters); + } + + this.light.updateTransitions(parameters); + + this._resetUpdates(); + } + + const sourcesUsedBefore = {}; + + for (const sourceId in this.sourceCaches) { + const sourceCache = this.sourceCaches[sourceId]; + sourcesUsedBefore[sourceId] = sourceCache.used; + sourceCache.used = false; + } + + for (const layerId of this._order) { + const layer = this._layers[layerId]; + + layer.recalculate(parameters, this._availableImages); + if (!layer.isHidden(parameters.zoom) && layer.source) { + this.sourceCaches[layer.source].used = true; + } + } + + for (const sourceId in sourcesUsedBefore) { + const sourceCache = this.sourceCaches[sourceId]; + if (sourcesUsedBefore[sourceId] !== sourceCache.used) { + sourceCache.fire(new Event('data', {sourceDataType: 'visibility', dataType: 'source', sourceId})); + } + } + + this.light.recalculate(parameters); + this.z = parameters.zoom; + + if (changed) { + this.fire(new Event('data', {dataType: 'style'})); + } + + } + + /* + * Apply any queued image changes. + */ + _updateTilesForChangedImages() { + const changedImages = Object.keys(this._changedImages); + if (changedImages.length) { + for (const name in this.sourceCaches) { + this.sourceCaches[name].reloadTilesForDependencies(['icons', 'patterns'], changedImages); + } + this._changedImages = {}; + } + } + + _updateTilesForChangedGlyphs() { + if (this._glyphsDidChange) { + for (const name in this.sourceCaches) { + this.sourceCaches[name].reloadTilesForDependencies(['glyphs'], ['']); + } + this._glyphsDidChange = false; + } + } + + _updateWorkerLayers(updatedIds: Array, removedIds: Array) { + this.dispatcher.broadcast('updateLayers', { + layers: this._serializeByIds(updatedIds), + removedIds + }); + } + + _resetUpdates() { + this._changed = false; + + this._updatedLayers = {}; + this._removedLayers = {}; + + this._updatedSources = {}; + this._updatedPaintProps = {}; + + this._changedImages = {}; + this._glyphsDidChange = false; + } + + /** + * Update this style's state to match the given style JSON, performing only + * the necessary mutations. + * + * May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec + * diff algorithm produces an operation that is not supported. + * + * @returns true if any changes were made; false otherwise + */ + setState(nextState: StyleSpecification, options: StyleSwapOptions = {}) { + this._checkLoaded(); + + const serializedStyle = this.serialize(); + nextState = options.transformStyle ? options.transformStyle(serializedStyle, nextState) : nextState; + if (emitValidationErrors(this, validateStyle(nextState))) return false; + + nextState = clone(nextState); + nextState.layers = deref(nextState.layers); + + const changes = diffStyles(serializedStyle, nextState) + .filter(op => !(op.command in ignoredDiffOperations)); + + if (changes.length === 0) { + return false; + } + + const unimplementedOps = changes.filter(op => !(op.command in supportedDiffOperations)); + if (unimplementedOps.length > 0) { + throw new Error(`Unimplemented: ${unimplementedOps.map(op => op.command).join(', ')}.`); + } + + for (const op of changes) { + if (op.command === 'setTransition') { + // `transition` is always read directly off of + // `this.stylesheet`, which we update below + continue; + } + (this as any)[op.command].apply(this, op.args); + } + + this.stylesheet = nextState; + + // reset serialization field, to be populated only when needed + this._serializedLayers = null; + + return true; + } + + addImage(id: string, image: StyleImage) { + if (this.getImage(id)) { + return this.fire(new ErrorEvent(new Error(`An image named "${id}" already exists.`))); + } + this.imageManager.addImage(id, image); + this._afterImageUpdated(id); + } + + updateImage(id: string, image: StyleImage) { + this.imageManager.updateImage(id, image); + } + + getImage(id: string): StyleImage { + return this.imageManager.getImage(id); + } + + removeImage(id: string) { + if (!this.getImage(id)) { + return this.fire(new ErrorEvent(new Error(`An image named "${id}" does not exist.`))); + } + this.imageManager.removeImage(id); + this._afterImageUpdated(id); + } + + _afterImageUpdated(id: string) { + this._availableImages = this.imageManager.listImages(); + this._changedImages[id] = true; + this._changed = true; + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new Event('data', {dataType: 'style'})); + } + + listImages() { + this._checkLoaded(); + + return this.imageManager.listImages(); + } + + addSource(id: string, source: SourceSpecification, options: StyleSetterOptions = {}) { + this._checkLoaded(); + + if (this.sourceCaches[id] !== undefined) { + throw new Error(`Source "${id}" already exists.`); + } + + if (!source.type) { + throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(source).join(', ')}.`); + } + + const builtIns = ['vector', 'raster', 'geojson', 'video', 'image']; + const shouldValidate = builtIns.indexOf(source.type) >= 0; + if (shouldValidate && this._validate(validateStyle.source, `sources.${id}`, source, null, options)) return; + + if (this.map && this.map._collectResourceTiming) (source as any).collectResourceTiming = true; + const sourceCache = this.sourceCaches[id] = new SourceCache(id, source, this.dispatcher); + sourceCache.style = this; + sourceCache.setEventedParent(this, () => ({ + isSourceLoaded: sourceCache.loaded(), + source: sourceCache.serialize(), + sourceId: id + })); + + sourceCache.onAdd(this.map); + this._changed = true; + } + + /** + * Remove a source from this stylesheet, given its id. + * @param id - id of the source to remove + * @throws if no source is found with the given ID + * @returns `this`. + */ + removeSource(id: string): this { + this._checkLoaded(); + + if (this.sourceCaches[id] === undefined) { + throw new Error('There is no source with this ID'); + } + for (const layerId in this._layers) { + if (this._layers[layerId].source === id) { + return this.fire(new ErrorEvent(new Error(`Source "${id}" cannot be removed while layer "${layerId}" is using it.`))); + } + } + + const sourceCache = this.sourceCaches[id]; + delete this.sourceCaches[id]; + delete this._updatedSources[id]; + sourceCache.fire(new Event('data', {sourceDataType: 'metadata', dataType: 'source', sourceId: id})); + sourceCache.setEventedParent(null); + sourceCache.onRemove(this.map); + this._changed = true; + } + + /** + * Set the data of a GeoJSON source, given its id. + * @param id - id of the source + * @param data - GeoJSON source + */ + setGeoJSONSourceData(id: string, data: GeoJSON.GeoJSON | string) { + this._checkLoaded(); + + if (this.sourceCaches[id] === undefined) throw new Error(`There is no source with this ID=${id}`); + const geojsonSource: GeoJSONSource = (this.sourceCaches[id].getSource() as any); + if (geojsonSource.type !== 'geojson') throw new Error(`geojsonSource.type is ${geojsonSource.type}, which is !== 'geojson`); + + geojsonSource.setData(data); + this._changed = true; + } + + /** + * Get a source by ID. + * @param id - ID of the desired source + * @returns source + */ + getSource(id: string): Source | undefined { + return this.sourceCaches[id] && this.sourceCaches[id].getSource(); + } + + /** + * Add a layer to the map style. The layer will be inserted before the layer with + * ID `before`, or appended if `before` is omitted. + * @param layerObject - The style layer to add. + * @param before - ID of an existing layer to insert before + * @param options - Style setter options. + * @returns `this`. + */ + addLayer(layerObject: AddLayerObject, before?: string, options: StyleSetterOptions = {}): this { + this._checkLoaded(); + + const id = layerObject.id; + + if (this.getLayer(id)) { + this.fire(new ErrorEvent(new Error(`Layer "${id}" already exists on this map.`))); + return; + } + + let layer: ReturnType; + if (layerObject.type === 'custom') { + + if (emitValidationErrors(this, validateCustomStyleLayer(layerObject))) return; + + layer = createStyleLayer(layerObject); + + } else { + if ('source' in layerObject && typeof layerObject.source === 'object') { + this.addSource(id, layerObject.source); + layerObject = clone(layerObject); + layerObject = extend(layerObject, {source: id}); + } + + // this layer is not in the style.layers array, so we pass an impossible array index + if (this._validate(validateStyle.layer, + `layers.${id}`, layerObject, {arrayIndex: -1}, options)) return; + + layer = createStyleLayer(layerObject as LayerSpecification | CustomLayerInterface); + this._validateLayer(layer); + + layer.setEventedParent(this, {layer: {id}}); + } + + const index = before ? this._order.indexOf(before) : this._order.length; + if (before && index === -1) { + this.fire(new ErrorEvent(new Error(`Cannot add layer "${id}" before non-existing layer "${before}".`))); + return; + } + + this._order.splice(index, 0, id); + this._layerOrderChanged = true; + + this._layers[id] = layer; + + if (this._removedLayers[id] && layer.source && layer.type !== 'custom') { + // If, in the current batch, we have already removed this layer + // and we are now re-adding it with a different `type`, then we + // need to clear (rather than just reload) the underlying source's + // tiles. Otherwise, tiles marked 'reloading' will have buckets / + // buffers that are set up for the _previous_ version of this + // layer, causing, e.g.: + // https://github.com/mapbox/mapbox-gl-js/issues/3633 + const removed = this._removedLayers[id]; + delete this._removedLayers[id]; + if (removed.type !== layer.type) { + this._updatedSources[layer.source] = 'clear'; + } else { + this._updatedSources[layer.source] = 'reload'; + this.sourceCaches[layer.source].pause(); + } + } + this._updateLayer(layer); + + if (layer.onAdd) { + layer.onAdd(this.map); + } + } + + /** + * Moves a layer to a different z-position. The layer will be inserted before the layer with + * ID `before`, or appended if `before` is omitted. + * @param id - ID of the layer to move + * @param before - ID of an existing layer to insert before + */ + moveLayer(id: string, before?: string) { + this._checkLoaded(); + this._changed = true; + + const layer = this._layers[id]; + if (!layer) { + this.fire(new ErrorEvent(new Error(`The layer '${id}' does not exist in the map's style and cannot be moved.`))); + return; + } + + if (id === before) { + return; + } + + const index = this._order.indexOf(id); + this._order.splice(index, 1); + + const newIndex = before ? this._order.indexOf(before) : this._order.length; + if (before && newIndex === -1) { + this.fire(new ErrorEvent(new Error(`Cannot move layer "${id}" before non-existing layer "${before}".`))); + return; + } + this._order.splice(newIndex, 0, id); + + this._layerOrderChanged = true; + } + + /** + * Remove the layer with the given id from the style. + * + * If no such layer exists, an `error` event is fired. + * + * @param id - id of the layer to remove + * @event `error` - Fired if the layer does not exist + */ + removeLayer(id: string) { + this._checkLoaded(); + + const layer = this._layers[id]; + if (!layer) { + this.fire(new ErrorEvent(new Error(`Cannot remove non-existing layer "${id}".`))); + return; + } + + layer.setEventedParent(null); + + const index = this._order.indexOf(id); + this._order.splice(index, 1); + + this._layerOrderChanged = true; + this._changed = true; + this._removedLayers[id] = layer; + delete this._layers[id]; + + if (this._serializedLayers) { + delete this._serializedLayers[id]; + } + delete this._updatedLayers[id]; + delete this._updatedPaintProps[id]; + + if (layer.onRemove) { + layer.onRemove(this.map); + } + } + + /** + * Return the style layer object with the given `id`. + * + * @param id - id of the desired layer + * @returns a layer, if one with the given `id` exists + */ + getLayer(id: string): StyleLayer | undefined { + return this._layers[id]; + } + + /** + * Return the ids of all layers currently in the style, including custom layers, in order. + * + * @returns ids of layers, in order + */ + getLayersOrder(): string[] { + return [...this._order]; + } + + /** + * Checks if a specific layer is present within the style. + * + * @param id - the id of the desired layer + * @returns a boolean specifying if the given layer is present + */ + hasLayer(id: string): boolean { + return id in this._layers; + } + + setLayerZoomRange(layerId: string, minzoom?: number | null, maxzoom?: number | null) { + this._checkLoaded(); + + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${layerId}".`))); + return; + } + + if (layer.minzoom === minzoom && layer.maxzoom === maxzoom) return; + + if (minzoom != null) { + layer.minzoom = minzoom; + } + if (maxzoom != null) { + layer.maxzoom = maxzoom; + } + this._updateLayer(layer); + } + + setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) { + this._checkLoaded(); + + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new ErrorEvent(new Error(`Cannot filter non-existing layer "${layerId}".`))); + return; + } + + if (deepEqual(layer.filter, filter)) { + return; + } + + if (filter === null || filter === undefined) { + layer.filter = undefined; + this._updateLayer(layer); + return; + } + + if (this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter, null, options)) { + return; + } + + layer.filter = clone(filter); + this._updateLayer(layer); + } + + /** + * Get a layer's filter object + * @param layer - the layer to inspect + * @returns the layer's filter, if any + */ + getFilter(layer: string): FilterSpecification | void { + return clone(this.getLayer(layer).filter); + } + + setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) { + this._checkLoaded(); + + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer "${layerId}".`))); + return; + } + + if (deepEqual(layer.getLayoutProperty(name), value)) return; + + layer.setLayoutProperty(name, value, options); + this._updateLayer(layer); + } + + /** + * Get a layout property's value from a given layer + * @param layerId - the layer to inspect + * @param name - the name of the layout property + * @returns the property value + */ + getLayoutProperty(layerId: string, name: string) { + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new ErrorEvent(new Error(`Cannot get style of non-existing layer "${layerId}".`))); + return; + } + + return layer.getLayoutProperty(name); + } + + setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}) { + this._checkLoaded(); + + const layer = this.getLayer(layerId); + if (!layer) { + this.fire(new ErrorEvent(new Error(`Cannot style non-existing layer "${layerId}".`))); + return; + } + + if (deepEqual(layer.getPaintProperty(name), value)) return; + + const requiresRelayout = layer.setPaintProperty(name, value, options); + if (requiresRelayout) { + this._updateLayer(layer); + } + + this._changed = true; + this._updatedPaintProps[layerId] = true; + } + + getPaintProperty(layer: string, name: string) { + return this.getLayer(layer).getPaintProperty(name); + } + + setFeatureState(target: FeatureIdentifier, state: any) { + this._checkLoaded(); + const sourceId = target.source; + const sourceLayer = target.sourceLayer; + const sourceCache = this.sourceCaches[sourceId]; + + if (sourceCache === undefined) { + this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`))); + return; + } + const sourceType = sourceCache.getSource().type; + if (sourceType === 'geojson' && sourceLayer) { + this.fire(new ErrorEvent(new Error('GeoJSON sources cannot have a sourceLayer parameter.'))); + return; + } + if (sourceType === 'vector' && !sourceLayer) { + this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.'))); + return; + } + if (target.id === undefined) { + this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.'))); + } + + sourceCache.setFeatureState(sourceLayer, target.id, state); + } + + removeFeatureState(target: FeatureIdentifier, key?: string) { + this._checkLoaded(); + const sourceId = target.source; + const sourceCache = this.sourceCaches[sourceId]; + + if (sourceCache === undefined) { + this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`))); + return; + } + + const sourceType = sourceCache.getSource().type; + const sourceLayer = sourceType === 'vector' ? target.sourceLayer : undefined; + + if (sourceType === 'vector' && !sourceLayer) { + this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.'))); + return; + } + + if (key && (typeof target.id !== 'string' && typeof target.id !== 'number')) { + this.fire(new ErrorEvent(new Error('A feature id is required to remove its specific state property.'))); + return; + } + + sourceCache.removeFeatureState(sourceLayer, target.id, key); + } + + getFeatureState(target: FeatureIdentifier) { + this._checkLoaded(); + const sourceId = target.source; + const sourceLayer = target.sourceLayer; + const sourceCache = this.sourceCaches[sourceId]; + + if (sourceCache === undefined) { + this.fire(new ErrorEvent(new Error(`The source '${sourceId}' does not exist in the map's style.`))); + return; + } + const sourceType = sourceCache.getSource().type; + if (sourceType === 'vector' && !sourceLayer) { + this.fire(new ErrorEvent(new Error('The sourceLayer parameter must be provided for vector source types.'))); + return; + } + if (target.id === undefined) { + this.fire(new ErrorEvent(new Error('The feature id parameter must be provided.'))); + } + + return sourceCache.getFeatureState(sourceLayer, target.id); + } + + getTransition() { + return extend({duration: 300, delay: 0}, this.stylesheet && this.stylesheet.transition); + } + + serialize(): StyleSpecification { + // We return undefined before we're loaded, following the pattern of Map.getStyle() before + // the Style object is initialized. + // Internally, Style._validate() calls Style.serialize() but callers are responsible for + // calling Style._checkLoaded() first if their validation requires the style to be loaded. + if (!this._loaded) return; + + const sources = mapObject(this.sourceCaches, (source) => source.serialize()); + const layers = this._serializeByIds(this._order); + const terrain = this.map.getTerrain() || undefined; + const myStyleSheet = this.stylesheet; + + return filterObject({ + version: myStyleSheet.version, + name: myStyleSheet.name, + metadata: myStyleSheet.metadata, + light: myStyleSheet.light, + center: myStyleSheet.center, + zoom: myStyleSheet.zoom, + bearing: myStyleSheet.bearing, + pitch: myStyleSheet.pitch, + sprite: myStyleSheet.sprite, + glyphs: myStyleSheet.glyphs, + transition: myStyleSheet.transition, + sources, + layers, + terrain + }, + (value) => { return value !== undefined; }); + } + + _updateLayer(layer: StyleLayer) { + this._updatedLayers[layer.id] = true; + if (layer.source && !this._updatedSources[layer.source] && + //Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865) + this.sourceCaches[layer.source].getSource().type !== 'raster') { + this._updatedSources[layer.source] = 'reload'; + this.sourceCaches[layer.source].pause(); + } + + // upon updating, serilized layer dictionary should be reset. + // When needed, it will be populated with the correct copy again. + this._serializedLayers = null; + this._changed = true; + } + + _flattenAndSortRenderedFeatures(sourceResults: Array<{ [key: string]: Array<{featureIndex: number; feature: MapGeoJSONFeature}> }>) { + // Feature order is complicated. + // The order between features in two 2D layers is always determined by layer order. + // The order between features in two 3D layers is always determined by depth. + // The order between a feature in a 2D layer and a 3D layer is tricky: + // Most often layer order determines the feature order in this case. If + // a line layer is above a extrusion layer the line feature will be rendered + // above the extrusion. If the line layer is below the extrusion layer, + // it will be rendered below it. + // + // There is a weird case though. + // You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b + // Each layer has a feature that overlaps the other features. + // The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above. + // The feature in line_layer is rendered above extrusion_layer_a. + // This means that that the line_layer feature is above the extrusion_layer_b feature despite + // it being in an earlier layer. + + const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion'; + + const layerIndex = {}; + const features3D = []; + for (let l = this._order.length - 1; l >= 0; l--) { + const layerId = this._order[l]; + if (isLayer3D(layerId)) { + layerIndex[layerId] = l; + for (const sourceResult of sourceResults) { + const layerFeatures = sourceResult[layerId]; + if (layerFeatures) { + for (const featureWrapper of layerFeatures) { + features3D.push(featureWrapper); + } + } + } + } + } + + features3D.sort((a, b) => { + return b.intersectionZ - a.intersectionZ; + }); + + const features = []; + for (let l = this._order.length - 1; l >= 0; l--) { + const layerId = this._order[l]; + + if (isLayer3D(layerId)) { + // add all 3D features that are in or above the current layer + for (let i = features3D.length - 1; i >= 0; i--) { + const topmost3D = features3D[i].feature; + if (layerIndex[topmost3D.layer.id] < l) break; + features.push(topmost3D); + features3D.pop(); + } + } else { + for (const sourceResult of sourceResults) { + const layerFeatures = sourceResult[layerId]; + if (layerFeatures) { + for (const featureWrapper of layerFeatures) { + features.push(featureWrapper.feature); + } + } + } + } + } + + return features; + } + + queryRenderedFeatures(queryGeometry: any, params: QueryRenderedFeaturesOptions, transform: Transform) { + if (params && params.filter) { + this._validate(validateStyle.filter, 'queryRenderedFeatures.filter', params.filter, null, params); + } + + const includedSources = {}; + if (params && params.layers) { + if (!Array.isArray(params.layers)) { + this.fire(new ErrorEvent(new Error('parameters.layers must be an Array.'))); + return []; + } + for (const layerId of params.layers) { + const layer = this._layers[layerId]; + if (!layer) { + // this layer is not in the style.layers array + this.fire(new ErrorEvent(new Error(`The layer '${layerId}' does not exist in the map's style and cannot be queried for features.`))); + return []; + } + includedSources[layer.source] = true; + } + } + + const sourceResults = []; + + params.availableImages = this._availableImages; + + // LayerSpecification is serialized StyleLayer, and this casting is safe. + const serializedLayers = this._serializedAllLayers() as {[_: string]: StyleLayer}; + + for (const id in this.sourceCaches) { + if (params.layers && !includedSources[id]) continue; + sourceResults.push( + queryRenderedFeatures( + this.sourceCaches[id], + this._layers, + serializedLayers, + queryGeometry, + params, + transform) + ); + } + + if (this.placement) { + // If a placement has run, query against its CollisionIndex + // for symbol results, and treat it as an extra source to merge + sourceResults.push( + queryRenderedSymbols( + this._layers, + serializedLayers, + this.sourceCaches, + queryGeometry, + params, + this.placement.collisionIndex, + this.placement.retainedQueryData) + ); + } + + return this._flattenAndSortRenderedFeatures(sourceResults); + } + + querySourceFeatures( + sourceID: string, + params?: QuerySourceFeatureOptions + ) { + if (params && params.filter) { + this._validate(validateStyle.filter, 'querySourceFeatures.filter', params.filter, null, params); + } + const sourceCache = this.sourceCaches[sourceID]; + return sourceCache ? querySourceFeatures(sourceCache, params) : []; + } + + addSourceType(name: string, SourceType: SourceClass, callback: Callback) { + if (getSourceType(name)) { + return callback(new Error(`A source type called "${name}" already exists.`)); + } + + setSourceType(name, SourceType); + + if (!SourceType.workerSourceURL) { + return callback(null, null); + } + + this.dispatcher.broadcast('loadWorkerSource', { + name, + url: SourceType.workerSourceURL + }, callback); + } + + getLight() { + return this.light.getLight(); + } + + setLight(lightOptions: LightSpecification, options: StyleSetterOptions = {}) { + this._checkLoaded(); + + const light = this.light.getLight(); + let _update = false; + for (const key in lightOptions) { + if (!deepEqual(lightOptions[key], light[key])) { + _update = true; + break; + } + } + if (!_update) return; + + const parameters = { + now: browser.now(), + transition: extend({ + duration: 300, + delay: 0 + }, this.stylesheet.transition) + }; + + this.light.setLight(lightOptions, options); + this.light.updateTransitions(parameters); + } + + _validate(validate: Validator, key: string, value: any, props: any, options: { + validate?: boolean; + } = {}) { + if (options && options.validate === false) { + return false; + } + return emitValidationErrors(this, validate.call(validateStyle, extend({ + key, + style: this.serialize(), + value, + styleSpec + }, props))); + } + + _remove(mapRemoved: boolean = true) { + if (this._request) { + this._request.cancel(); + this._request = null; + } + if (this._spriteRequest) { + this._spriteRequest.cancel(); + this._spriteRequest = null; + } + rtlTextPluginEvented.off('pluginStateChange', this._rtlTextPluginCallback); + for (const layerId in this._layers) { + const layer: StyleLayer = this._layers[layerId]; + layer.setEventedParent(null); + } + for (const id in this.sourceCaches) { + const sourceCache = this.sourceCaches[id]; + sourceCache.setEventedParent(null); + sourceCache.onRemove(this.map); + } + this.imageManager.setEventedParent(null); + this.setEventedParent(null); + this.dispatcher.remove(mapRemoved); + } + + _clearSource(id: string) { + this.sourceCaches[id].clearTiles(); + } + + _reloadSource(id: string) { + this.sourceCaches[id].resume(); + this.sourceCaches[id].reload(); + } + + _updateSources(transform: Transform) { + for (const id in this.sourceCaches) { + this.sourceCaches[id].update(transform, this.map.terrain); + } + } + + _generateCollisionBoxes() { + for (const id in this.sourceCaches) { + this._reloadSource(id); + } + } + + _updatePlacement(transform: Transform, showCollisionBoxes: boolean, fadeDuration: number, crossSourceCollisions: boolean, forceFullPlacement: boolean = false) { + let symbolBucketsChanged = false; + let placementCommitted = false; + + const layerTiles = {}; + + for (const layerID of this._order) { + const styleLayer = this._layers[layerID]; + if (styleLayer.type !== 'symbol') continue; + + if (!layerTiles[styleLayer.source]) { + const sourceCache = this.sourceCaches[styleLayer.source]; + layerTiles[styleLayer.source] = sourceCache.getRenderableIds(true) + .map((id) => sourceCache.getTileByID(id)) + .sort((a, b) => (b.tileID.overscaledZ - a.tileID.overscaledZ) || (a.tileID.isLessThan(b.tileID) ? -1 : 1)); + } + + const layerBucketsChanged = this.crossTileSymbolIndex.addLayer(styleLayer, layerTiles[styleLayer.source], transform.center.lng); + symbolBucketsChanged = symbolBucketsChanged || layerBucketsChanged; + } + this.crossTileSymbolIndex.pruneUnusedLayers(this._order); + + // Anything that changes our "in progress" layer and tile indices requires us + // to start over. When we start over, we do a full placement instead of incremental + // to prevent starvation. + // We need to restart placement to keep layer indices in sync. + // Also force full placement when fadeDuration === 0 to ensure that newly loaded + // tiles will fully display symbols in their first frame + forceFullPlacement = forceFullPlacement || this._layerOrderChanged || fadeDuration === 0; + + if (forceFullPlacement || !this.pauseablePlacement || (this.pauseablePlacement.isDone() && !this.placement.stillRecent(browser.now(), transform.zoom))) { + this.pauseablePlacement = new PauseablePlacement(transform, this.map.terrain, this._order, forceFullPlacement, showCollisionBoxes, fadeDuration, crossSourceCollisions, this.placement); + this._layerOrderChanged = false; + } + + if (this.pauseablePlacement.isDone()) { + // the last placement finished running, but the next one hasn’t + // started yet because of the `stillRecent` check immediately + // above, so mark it stale to ensure that we request another + // render frame + this.placement.setStale(); + } else { + this.pauseablePlacement.continuePlacement(this._order, this._layers, layerTiles); + + if (this.pauseablePlacement.isDone()) { + this.placement = this.pauseablePlacement.commit(browser.now()); + placementCommitted = true; + } + + if (symbolBucketsChanged) { + // since the placement gets split over multiple frames it is possible + // these buckets were processed before they were changed and so the + // placement is already stale while it is in progress + this.pauseablePlacement.placement.setStale(); + } + } + + if (placementCommitted || symbolBucketsChanged) { + for (const layerID of this._order) { + const styleLayer = this._layers[layerID]; + if (styleLayer.type !== 'symbol') continue; + this.placement.updateLayerOpacities(styleLayer, layerTiles[styleLayer.source]); + } + } + + // needsRender is false when we have just finished a placement that didn't change the visibility of any symbols + const needsRerender = !this.pauseablePlacement.isDone() || this.placement.hasTransitions(browser.now()); + return needsRerender; + } + + _releaseSymbolFadeTiles() { + for (const id in this.sourceCaches) { + this.sourceCaches[id].releaseSymbolFadeTiles(); + } + } + + // Callbacks from web workers + + getImages( + mapId: string, + params: { + icons: Array; + source: string; + tileID: OverscaledTileID; + type: string; + }, + callback: Callback<{[_: string]: StyleImage}> + ) { + this.imageManager.getImages(params.icons, callback); + + // Apply queued image changes before setting the tile's dependencies so that the tile + // is not reloaded unnecessarily. Without this forced update the reload could happen in cases + // like this one: + // - icons contains "my-image" + // - imageManager.getImages(...) triggers `onstyleimagemissing` + // - the user adds "my-image" within the callback + // - addImage adds "my-image" to this._changedImages + // - the next frame triggers a reload of this tile even though it already has the latest version + this._updateTilesForChangedImages(); + + const sourceCache = this.sourceCaches[params.source]; + if (sourceCache) { + sourceCache.setDependencies(params.tileID.key, params.type, params.icons); + } + } + + getGlyphs( + mapId: string, + params: { + stacks: {[_: string]: Array}; + source: string; + tileID: OverscaledTileID; + type: string; + }, + callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}> + ) { + this.glyphManager.getGlyphs(params.stacks, callback); + const sourceCache = this.sourceCaches[params.source]; + if (sourceCache) { + // we are not setting stacks as dependencies since for now + // we just need to know which tiles have glyph dependencies + sourceCache.setDependencies(params.tileID.key, params.type, ['']); + } + } + + getResource(mapId: string, params: RequestParameters, callback: ResponseCallback): Cancelable { + return makeRequest(params, callback); + } + + getGlyphsUrl() { + return this.stylesheet.glyphs || null; + } + + setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}) { + this._checkLoaded(); + if (glyphsUrl && this._validate(validateStyle.glyphs, 'glyphs', glyphsUrl, null, options)) { + return; + } + + this._glyphsDidChange = true; + this.stylesheet.glyphs = glyphsUrl; + this.glyphManager.entries = {}; + this.glyphManager.setURL(glyphsUrl); + } + + /** + * Add a sprite. + * + * @param id - The id of the desired sprite + * @param url - The url to load the desired sprite from + * @param options - The style setter options + * @param completion - The completion handler + */ + addSprite(id: string, url: string, options: StyleSetterOptions = {}, completion?: (err: Error) => void) { + this._checkLoaded(); + + const spriteToAdd = [{id, url}]; + const updatedSprite = [ + ...coerceSpriteToArray(this.stylesheet.sprite), + ...spriteToAdd + ]; + + if (this._validate(validateStyle.sprite, 'sprite', updatedSprite, null, options)) return; + + this.stylesheet.sprite = updatedSprite; + this._loadSprite(spriteToAdd, true, completion); + } + + /** + * Remove a sprite by its id. When the last sprite is removed, the whole `this.stylesheet.sprite` object becomes + * `undefined`. This falsy `undefined` value later prevents attempts to load the sprite when it's absent. + * + * @param id - the id of the sprite to remove + */ + removeSprite(id: string) { + this._checkLoaded(); + + const internalSpriteRepresentation = coerceSpriteToArray(this.stylesheet.sprite); + + if (!internalSpriteRepresentation.find(sprite => sprite.id === id)) { + this.fire(new ErrorEvent(new Error(`Sprite "${id}" doesn't exists on this map.`))); + return; + } + + if (this._spritesImagesIds[id]) { + for (const imageId of this._spritesImagesIds[id]) { + this.imageManager.removeImage(imageId); + this._changedImages[imageId] = true; + } + } + + internalSpriteRepresentation.splice(internalSpriteRepresentation.findIndex(sprite => sprite.id === id), 1); + this.stylesheet.sprite = internalSpriteRepresentation.length > 0 ? internalSpriteRepresentation : undefined; + + delete this._spritesImagesIds[id]; + this._availableImages = this.imageManager.listImages(); + this._changed = true; + this.dispatcher.broadcast('setImages', this._availableImages); + this.fire(new Event('data', {dataType: 'style'})); + } + + /** + * Get the current sprite value. + * + * @returns empty array when no sprite is set; id-url pairs otherwise + */ + getSprite() { + return coerceSpriteToArray(this.stylesheet.sprite); + } + + /** + * Set a new value for the style's sprite. + * + * @param sprite - new sprite value + * @param options - style setter options + * @param completion - the completion handler + */ + setSprite(sprite: SpriteSpecification, options: StyleSetterOptions = {}, completion?: (err: Error) => void) { + this._checkLoaded(); + + if (sprite && this._validate(validateStyle.sprite, 'sprite', sprite, null, options)) { + return; + } + + this.stylesheet.sprite = sprite; + + if (sprite) { + this._loadSprite(sprite, true, completion); + } else { + this._unloadSprite(); + if (completion) { + completion(null); + } + } + } +} + +Style.registerForPluginStateChange = registerForPluginStateChange; diff --git a/web/libraries/maplibre-gl/src/style/style_glyph.ts b/web/libraries/maplibre-gl/src/style/style_glyph.ts new file mode 100644 index 00000000..35efaad5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_glyph.ts @@ -0,0 +1,23 @@ +import type {AlphaImage} from '../util/image'; + +export type GlyphMetrics = { + width: number; + height: number; + left: number; + top: number; + advance: number; + /** + * isDoubleResolution = true for 48px textures + */ + isDoubleResolution?: boolean; +}; + +/** + * @internal + * A style glyph type + */ +export type StyleGlyph = { + id: number; + bitmap: AlphaImage; + metrics: GlyphMetrics; +}; diff --git a/web/libraries/maplibre-gl/src/style/style_image.ts b/web/libraries/maplibre-gl/src/style/style_image.ts new file mode 100644 index 00000000..bcfadcca --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_image.ts @@ -0,0 +1,152 @@ +import {RGBAImage} from '../util/image'; + +import type {Map} from '../ui/map'; + +/** + * The sprite data + */ +export type SpriteOnDemandStyleImage = { + width: number; + height: number; + x: number; + y: number; + context: CanvasRenderingContext2D; +}; + +/** + * The style's image metadata + */ +export type StyleImageData = { + data: RGBAImage; + version?: number; + hasRenderCallback?: boolean; + userImage?: StyleImageInterface; + spriteData?: SpriteOnDemandStyleImage; +}; + +/** + * The style's image metadata + */ +export type StyleImageMetadata = { + /** + * The ratio of pixels in the image to physical pixels on the screen + */ + pixelRatio: number; + /** + * Whether the image should be interpreted as an SDF image + */ + sdf: boolean; + /** + * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally. + */ + stretchX?: Array<[number, number]>; + /** + * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically. + */ + stretchY?: Array<[number, number]>; + /** + * If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`. + */ + content?: [number, number, number, number]; +}; + +/** + * the style's image, including data and metedata + */ +export type StyleImage = StyleImageData & StyleImageMetadata; + +/** + * Interface for dynamically generated style images. This is a specification for + * implementers to model: it is not an exported method or class. + * + * Images implementing this interface can be redrawn for every frame. They can be used to animate + * icons and patterns or make them respond to user input. Style images can implement a + * {@link StyleImageInterface#render} method. The method is called every frame and + * can be used to update the image. + * + * @see [Add an animated icon to the map.](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/) + * + * @example + * ```ts + * let flashingSquare = { + * width: 64, + * height: 64, + * data: new Uint8Array(64 * 64 * 4), + * + * onAdd: function(map) { + * this.map = map; + * }, + * + * render: function() { + * // keep repainting while the icon is on the map + * this.map.triggerRepaint(); + * + * // alternate between black and white based on the time + * let value = Math.round(Date.now() / 1000) % 2 === 0 ? 255 : 0; + * + * // check if image needs to be changed + * if (value !== this.previousValue) { + * this.previousValue = value; + * + * let bytesPerPixel = 4; + * for (let x = 0; x < this.width; x++) { + * for (let y = 0; y < this.height; y++) { + * let offset = (y * this.width + x) * bytesPerPixel; + * this.data[offset + 0] = value; + * this.data[offset + 1] = value; + * this.data[offset + 2] = value; + * this.data[offset + 3] = 255; + * } + * } + * + * // return true to indicate that the image changed + * return true; + * } + * } + * } + * + * map.addImage('flashing_square', flashingSquare); + * ``` + */ + +export interface StyleImageInterface { + width: number; + height: number; + data: Uint8Array | Uint8ClampedArray; + /** + * This method is called once before every frame where the icon will be used. + * The method can optionally update the image's `data` member with a new image. + * + * If the method updates the image it must return `true` to commit the change. + * If the method returns `false` or nothing the image is assumed to not have changed. + * + * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update + * the image instead of implementing this method. + * + * @returns `true` if this method updated the image. `false` if the image was not changed. + */ + render?: () => boolean; + /** + * Optional method called when the layer has been added to the Map with {@link Map#addImage}. + * + * @param map - The Map this custom layer was just added to. + */ + onAdd?: (map: Map, id: string) => void; + /** + * Optional method called when the icon is removed from the map with {@link Map#removeImage}. + * This gives the image a chance to clean up resources and event listeners. + */ + onRemove?: () => void; +} + +export function renderStyleImage(image: StyleImage) { + const {userImage} = image; + if (userImage && userImage.render) { + const updated = userImage.render(); + if (updated) { + image.data.replace(new Uint8Array(userImage.data.buffer)); + return true; + } + } + return false; +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer.test.ts b/web/libraries/maplibre-gl/src/style/style_layer.test.ts new file mode 100644 index 00000000..2022f37d --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer.test.ts @@ -0,0 +1,372 @@ +import {createStyleLayer} from './create_style_layer'; +import {FillStyleLayer} from './style_layer/fill_style_layer'; +import {extend} from '../util/util'; +import {Color, LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {EvaluationParameters} from './evaluation_parameters'; +import {TransitionParameters} from './properties'; +import {BackgroundStyleLayer} from './style_layer/background_style_layer'; +import {SymbolStyleLayer} from './style_layer/symbol_style_layer'; + +describe('StyleLayer', () => { + test('instantiates the correct subclass', () => { + const layer = createStyleLayer({type: 'fill'} as LayerSpecification); + + expect(layer instanceof FillStyleLayer).toBeTruthy(); + }); +}); + +describe('StyleLayer#setPaintProperty', () => { + test('sets new property value', () => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background' + }); + + layer.setPaintProperty('background-color', 'blue'); + + expect(layer.getPaintProperty('background-color')).toBe('blue'); + }); + + test('updates property value', () => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background', + 'paint': { + 'background-color': 'red' + } + }); + + layer.setPaintProperty('background-color', 'blue'); + + expect(layer.getPaintProperty('background-color')).toBe('blue'); + }); + + test('unsets value', () => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background', + 'paint': { + 'background-color': 'red', + 'background-opacity': 1 + } + }) as BackgroundStyleLayer; + + layer.setPaintProperty('background-color', null); + layer.updateTransitions({} as TransitionParameters); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + expect(layer.paint.get('background-color')).toEqual(new Color(0, 0, 0, 1)); + expect(layer.getPaintProperty('background-color')).toBeUndefined(); + expect(layer.paint.get('background-opacity')).toBe(1); + expect(layer.getPaintProperty('background-opacity')).toBe(1); + }); + + test('preserves existing transition', () => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background', + 'paint': { + 'background-color': 'red', + 'background-color-transition': { + duration: 600 + } + } as any + }); + + layer.setPaintProperty('background-color', 'blue'); + + expect(layer.getPaintProperty('background-color-transition')).toEqual({duration: 600}); + }); + + test('sets transition', () => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background', + 'paint': { + 'background-color': 'red' + } + }); + + layer.setPaintProperty('background-color-transition', {duration: 400}); + + expect(layer.getPaintProperty('background-color-transition')).toEqual({duration: 400}); + }); + + test('emits on an invalid property value', done => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background' + }); + + layer.on('error', () => { + expect(layer.getPaintProperty('background-opacity')).toBeUndefined(); + done(); + }); + + layer.setPaintProperty('background-opacity', 5); + }); + + test('emits on an invalid transition property value', done => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background' + }); + + layer.on('error', () => { + done(); + }); + + layer.setPaintProperty('background-opacity-transition', { + duration: -10 + }); + }); + + test('can unset fill-outline-color #2886', () => { + const layer = createStyleLayer({ + id: 'building', + type: 'fill', + source: 'streets', + paint: { + 'fill-color': '#00f' + } + }) as FillStyleLayer; + + layer.setPaintProperty('fill-outline-color', '#f00'); + layer.updateTransitions({} as TransitionParameters); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + expect(layer.paint.get('fill-outline-color').value).toEqual({kind: 'constant', value: new Color(1, 0, 0, 1)}); + + layer.setPaintProperty('fill-outline-color', undefined); + layer.updateTransitions({} as TransitionParameters); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + expect(layer.paint.get('fill-outline-color').value).toEqual({kind: 'constant', value: new Color(0, 0, 1, 1)}); + + }); + + test('can transition fill-outline-color from undefined to a value #3657', () => { + const layer = createStyleLayer({ + id: 'building', + type: 'fill', + source: 'streets', + paint: { + 'fill-color': '#00f' + } + }) as FillStyleLayer; + + // setup: set and then unset fill-outline-color so that, when we then try + // to re-set it, StyleTransition#calculate() attempts interpolation + layer.setPaintProperty('fill-outline-color', '#f00'); + layer.updateTransitions({} as TransitionParameters); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + layer.setPaintProperty('fill-outline-color', undefined); + layer.updateTransitions({} as TransitionParameters); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + // re-set fill-outline-color and get its value, triggering the attempt + // to interpolate between undefined and #f00 + layer.setPaintProperty('fill-outline-color', '#f00'); + layer.updateTransitions({} as TransitionParameters); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + layer.paint.get('fill-outline-color'); + + }); + + test('sets null property value', () => { + const layer = createStyleLayer({ + 'id': 'background', + 'type': 'background' + }); + + layer.setPaintProperty('background-color-transition', null); + + expect(layer.getPaintProperty('background-color-transition')).toBeUndefined(); + }); + +}); + +describe('StyleLayer#setLayoutProperty', () => { + test('sets new property value', () => { + const layer = createStyleLayer({ + 'id': 'symbol', + 'type': 'symbol' + } as LayerSpecification); + + layer.setLayoutProperty('text-transform', 'lowercase'); + + expect(layer.getLayoutProperty('text-transform')).toBe('lowercase'); + }); + + test('emits on an invalid property value', done => { + const layer = createStyleLayer({ + 'id': 'symbol', + 'type': 'symbol' + } as LayerSpecification); + + layer.on('error', () => { + done(); + }); + + layer.setLayoutProperty('text-transform', 'invalidValue'); + }); + + test('updates property value', () => { + const layer = createStyleLayer({ + 'id': 'symbol', + 'type': 'symbol', + 'layout': { + 'text-transform': 'uppercase' + } + } as LayerSpecification); + + layer.setLayoutProperty('text-transform', 'lowercase'); + + expect(layer.getLayoutProperty('text-transform')).toBe('lowercase'); + }); + + test('unsets property value', () => { + const layer = createStyleLayer({ + 'id': 'symbol', + 'type': 'symbol', + 'layout': { + 'text-transform': 'uppercase' + } + } as LayerSpecification) as SymbolStyleLayer; + + layer.setLayoutProperty('text-transform', null); + layer.recalculate({zoom: 0, zoomHistory: {}} as EvaluationParameters, undefined); + + expect(layer.layout.get('text-transform').value).toEqual({kind: 'constant', value: 'none'}); + expect(layer.getLayoutProperty('text-transform')).toBeUndefined(); + }); +}); + +describe('StyleLayer#serialize', () => { + + function createSymbolLayer(layer?) { + return extend({ + id: 'symbol', + type: 'symbol', + paint: { + 'text-color': 'blue' + }, + layout: { + 'text-transform': 'uppercase' + } + }, layer); + } + + test('serializes layers', () => { + expect(createStyleLayer(createSymbolLayer()).serialize()).toEqual(createSymbolLayer()); + }); + + test('serializes functions', () => { + const layerPaint = { + 'text-color': { + base: 2, + stops: [[0, 'red'], [1, 'blue']] + } + }; + + expect(createStyleLayer(createSymbolLayer({paint: layerPaint})).serialize().paint).toEqual(layerPaint); + }); + + test('serializes added paint properties', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setPaintProperty('text-halo-color', 'orange'); + + expect(layer.serialize().paint['text-halo-color']).toBe('orange'); + expect(layer.serialize().paint['text-color']).toBe('blue'); + + }); + + test('serializes added layout properties', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setLayoutProperty('text-size', 20); + + expect(layer.serialize().layout['text-transform']).toBe('uppercase'); + expect(layer.serialize().layout['text-size']).toBe(20); + + }); + + test('serializes "visibility" of "visible"', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setLayoutProperty('visibility', 'visible'); + + expect(layer.serialize().layout['visibility']).toBe('visible'); + + }); + + test('serializes "visibility" of "none"', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setLayoutProperty('visibility', 'none'); + + expect(layer.serialize().layout['visibility']).toBe('none'); + + }); + + test('serializes "visibility" of undefined', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setLayoutProperty('visibility', undefined); + + expect(layer.serialize().layout['visibility']).toBeUndefined(); + + }); + +}); + +describe('StyleLayer#serialize', () => { + + function createSymbolLayer(layer?) { + return extend({ + id: 'symbol', + type: 'symbol', + paint: { + 'text-color': 'blue' + }, + layout: { + 'text-transform': 'uppercase' + } + }, layer); + } + + test('serializes layers', () => { + expect(createStyleLayer(createSymbolLayer()).serialize()).toEqual(createSymbolLayer()); + }); + + test('serializes functions', () => { + const layerPaint = { + 'text-color': { + base: 2, + stops: [[0, 'red'], [1, 'blue']] + } + }; + + expect(createStyleLayer(createSymbolLayer({paint: layerPaint})).serialize().paint).toEqual(layerPaint); + }); + + test('serializes added paint properties', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setPaintProperty('text-halo-color', 'orange'); + + expect(layer.serialize().paint['text-halo-color']).toBe('orange'); + expect(layer.serialize().paint['text-color']).toBe('blue'); + + }); + + test('serializes added layout properties', () => { + const layer = createStyleLayer(createSymbolLayer()); + layer.setLayoutProperty('text-size', 20); + + expect(layer.serialize().layout['text-transform']).toBe('uppercase'); + expect(layer.serialize().layout['text-size']).toBe(20); + + }); + + test('layer.paint is never undefined', () => { + const layer = createStyleLayer({type: 'fill'} as LayerSpecification); + // paint is never undefined + expect(layer.paint).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer.ts new file mode 100644 index 00000000..277daae6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer.ts @@ -0,0 +1,287 @@ +import {filterObject} from '../util/util'; + +import {latest as styleSpec, supportsPropertyExpression} from '@maplibre/maplibre-gl-style-spec'; +import { + validateStyle, + validateLayoutProperty, + validatePaintProperty, + emitValidationErrors +} from './validate_style'; +import {Evented} from '../util/evented'; +import {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties'; + +import type {Bucket} from '../data/bucket'; +import type Point from '@mapbox/point-geometry'; +import type {FeatureFilter, FeatureState, + LayerSpecification, + FilterSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {TransitionParameters, PropertyValue} from './properties'; +import {EvaluationParameters} from './evaluation_parameters'; +import type {CrossfadeParameters} from './evaluation_parameters'; + +import type {Transform} from '../geo/transform'; +import type {CustomLayerInterface} from './style_layer/custom_style_layer'; +import type {Map} from '../ui/map'; +import type {StyleSetterOptions} from './style'; +import {mat4} from 'gl-matrix'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; + +const TRANSITION_SUFFIX = '-transition'; + +/** + * A base class for style layers + */ +export abstract class StyleLayer extends Evented { + id: string; + metadata: unknown; + type: LayerSpecification['type'] | CustomLayerInterface['type']; + source: string; + sourceLayer: string; + minzoom: number; + maxzoom: number; + filter: FilterSpecification | void; + visibility: 'visible' | 'none' | void; + _crossfadeParameters: CrossfadeParameters; + + _unevaluatedLayout: Layout; + readonly layout: unknown; + + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + readonly paint: unknown; + + _featureFilter: FeatureFilter; + + readonly onAdd: ((map: Map) => void); + readonly onRemove: ((map: Map) => void); + + queryRadius?(bucket: Bucket): number; + queryIntersectsFeature?( + queryGeometry: Array, + feature: VectorTileFeature, + featureState: FeatureState, + geometry: Array>, + zoom: number, + transform: Transform, + pixelsToTileUnits: number, + pixelPosMatrix: mat4 + ): boolean | number; + + constructor(layer: LayerSpecification | CustomLayerInterface, properties: Readonly<{ + layout?: Properties; + paint?: Properties; + }>) { + super(); + + this.id = layer.id; + this.type = layer.type; + this._featureFilter = {filter: () => true, needGeometry: false}; + + if (layer.type === 'custom') return; + + layer = (layer as any as LayerSpecification); + + this.metadata = layer.metadata; + this.minzoom = layer.minzoom; + this.maxzoom = layer.maxzoom; + + if (layer.type !== 'background') { + this.source = layer.source; + this.sourceLayer = layer['source-layer']; + this.filter = layer.filter; + } + + if (properties.layout) { + this._unevaluatedLayout = new Layout(properties.layout); + } + + if (properties.paint) { + this._transitionablePaint = new Transitionable(properties.paint); + + for (const property in layer.paint) { + this.setPaintProperty(property, layer.paint[property], {validate: false}); + } + for (const property in layer.layout) { + this.setLayoutProperty(property, layer.layout[property], {validate: false}); + } + + this._transitioningPaint = this._transitionablePaint.untransitioned(); + //$FlowFixMe + this.paint = new PossiblyEvaluated(properties.paint); + } + } + + getCrossfadeParameters() { + return this._crossfadeParameters; + } + + getLayoutProperty(name: string) { + if (name === 'visibility') { + return this.visibility; + } + + return this._unevaluatedLayout.getValue(name); + } + + setLayoutProperty(name: string, value: any, options: StyleSetterOptions = {}) { + if (value !== null && value !== undefined) { + const key = `layers.${this.id}.layout.${name}`; + if (this._validate(validateLayoutProperty, key, name, value, options)) { + return; + } + } + + if (name === 'visibility') { + this.visibility = value; + return; + } + + this._unevaluatedLayout.setValue(name, value); + } + + getPaintProperty(name: string) { + if (name.endsWith(TRANSITION_SUFFIX)) { + return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length)); + } else { + return this._transitionablePaint.getValue(name); + } + } + + setPaintProperty(name: string, value: unknown, options: StyleSetterOptions = {}) { + if (value !== null && value !== undefined) { + const key = `layers.${this.id}.paint.${name}`; + if (this._validate(validatePaintProperty, key, name, value, options)) { + return false; + } + } + + if (name.endsWith(TRANSITION_SUFFIX)) { + this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), (value as any) || undefined); + return false; + } else { + const transitionable = this._transitionablePaint._values[name]; + const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven'; + const wasDataDriven = transitionable.value.isDataDriven(); + const oldValue = transitionable.value; + + this._transitionablePaint.setValue(name, value); + this._handleSpecialPaintPropertyUpdate(name); + + const newValue = this._transitionablePaint._values[name].value; + const isDataDriven = newValue.isDataDriven(); + + // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas + // so a call to _updateLayer is necessary, and we return true from this function so it gets called in + // Style#setPaintProperty + return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name, oldValue, newValue); + } + } + + _handleSpecialPaintPropertyUpdate(_: string) { + // No-op; can be overridden by derived classes. + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean { + // No-op; can be overridden by derived classes. + return false; + } + + isHidden(zoom: number) { + if (this.minzoom && zoom < this.minzoom) return true; + if (this.maxzoom && zoom >= this.maxzoom) return true; + return this.visibility === 'none'; + } + + updateTransitions(parameters: TransitionParameters) { + this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint); + } + + hasTransition() { + return this._transitioningPaint.hasTransition(); + } + + recalculate(parameters: EvaluationParameters, availableImages: Array) { + if (parameters.getCrossfadeParameters) { + this._crossfadeParameters = parameters.getCrossfadeParameters(); + } + + if (this._unevaluatedLayout) { + (this as any).layout = this._unevaluatedLayout.possiblyEvaluate(parameters, undefined, availableImages); + } + + (this as any).paint = this._transitioningPaint.possiblyEvaluate(parameters, undefined, availableImages); + } + + serialize(): LayerSpecification { + const output: LayerSpecification = { + 'id': this.id, + 'type': this.type as LayerSpecification['type'], + 'source': this.source, + 'source-layer': this.sourceLayer, + 'metadata': this.metadata, + 'minzoom': this.minzoom, + 'maxzoom': this.maxzoom, + 'filter': this.filter as FilterSpecification, + 'layout': this._unevaluatedLayout && this._unevaluatedLayout.serialize(), + 'paint': this._transitionablePaint && this._transitionablePaint.serialize() + }; + + if (this.visibility) { + output.layout = output.layout || {}; + output.layout.visibility = this.visibility; + } + + return filterObject(output, (value, key) => { + return value !== undefined && + !(key === 'layout' && !Object.keys(value).length) && + !(key === 'paint' && !Object.keys(value).length); + }); + } + + _validate(validate: Function, key: string, name: string, value: unknown, options: StyleSetterOptions = {}) { + if (options && options.validate === false) { + return false; + } + return emitValidationErrors(this, validate.call(validateStyle, { + key, + layerType: this.type, + objectKey: name, + value, + styleSpec, + // Workaround for https://github.com/mapbox/mapbox-gl-js/issues/2407 + style: {glyphs: true, sprite: true} + })); + } + + is3D() { + return false; + } + + isTileClipped() { + return false; + } + + hasOffscreenPass() { + return false; + } + + resize() { + // noop + } + + isStateDependent() { + for (const property in (this as any).paint._values) { + const value = (this as any).paint.get(property); + if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) { + continue; + } + + if ((value.value.kind === 'source' || value.value.kind === 'composite') && + value.value.isStateDependent) { + return true; + } + } + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/background_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/background_style_layer.ts new file mode 100644 index 00000000..412c04a8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/background_style_layer.ts @@ -0,0 +1,17 @@ +import {StyleLayer} from '../style_layer'; + +import properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties.g'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; + +import type {BackgroundPaintProps} from './background_style_layer_properties.g'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export class BackgroundStyleLayer extends StyleLayer { + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/background_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/background_style_layer_properties.g.ts new file mode 100644 index 00000000..e78a3b13 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/background_style_layer_properties.g.ts @@ -0,0 +1,40 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + + +export type BackgroundPaintProps = { + "background-color": DataConstantProperty, + "background-pattern": CrossFadedProperty, + "background-opacity": DataConstantProperty, +}; + +export type BackgroundPaintPropsPossiblyEvaluated = { + "background-color": Color, + "background-pattern": CrossFaded, + "background-opacity": number, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "background-color": new DataConstantProperty(styleSpec["paint_background"]["background-color"] as any as StylePropertySpecification), + "background-pattern": new CrossFadedProperty(styleSpec["paint_background"]["background-pattern"] as any as StylePropertySpecification), + "background-opacity": new DataConstantProperty(styleSpec["paint_background"]["background-opacity"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/circle_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/circle_style_layer.ts new file mode 100644 index 00000000..2a7b9cfa --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/circle_style_layer.ts @@ -0,0 +1,98 @@ +import {StyleLayer} from '../style_layer'; + +import {CircleBucket} from '../../data/bucket/circle_bucket'; +import {polygonIntersectsBufferedPoint} from '../../util/intersection_tests'; +import {getMaximumPaintValue, translateDistance, translate} from '../query_utils'; +import properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties.g'; +import {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties'; +import {mat4, vec4} from 'gl-matrix'; +import Point from '@mapbox/point-geometry'; +import type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {Transform} from '../../geo/transform'; +import type {Bucket, BucketParameters} from '../../data/bucket'; +import type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties.g'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; + +/** + * A style layer that defines a circle + */ +export class CircleStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } + + createBucket(parameters: BucketParameters) { + return new CircleBucket(parameters); + } + + queryRadius(bucket: Bucket): number { + const circleBucket: CircleBucket = (bucket as any); + return getMaximumPaintValue('circle-radius', this, circleBucket) + + getMaximumPaintValue('circle-stroke-width', this, circleBucket) + + translateDistance(this.paint.get('circle-translate')); + } + + queryIntersectsFeature( + queryGeometry: Array, + feature: VectorTileFeature, + featureState: FeatureState, + geometry: Array>, + zoom: number, + transform: Transform, + pixelsToTileUnits: number, + pixelPosMatrix: mat4 + ): boolean { + const translatedPolygon = translate(queryGeometry, + this.paint.get('circle-translate'), + this.paint.get('circle-translate-anchor'), + transform.angle, pixelsToTileUnits); + const radius = this.paint.get('circle-radius').evaluate(feature, featureState); + const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState); + const size = radius + stroke; + + // For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile + // // Otherwise, compare geometry in the plane of the viewport + // // A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance + // // A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance + const alignWithMap = this.paint.get('circle-pitch-alignment') === 'map'; + const transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry(translatedPolygon, pixelPosMatrix); + const transformedSize = alignWithMap ? size * pixelsToTileUnits : size; + + for (const ring of geometry) { + for (const point of ring) { + + const transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix); + + let adjustedSize = transformedSize; + const projectedCenter = vec4.transformMat4([] as any, [point.x, point.y, 0, 1], pixelPosMatrix); + if (this.paint.get('circle-pitch-scale') === 'viewport' && this.paint.get('circle-pitch-alignment') === 'map') { + adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance; + } else if (this.paint.get('circle-pitch-scale') === 'map' && this.paint.get('circle-pitch-alignment') === 'viewport') { + adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3]; + } + + if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) return true; + } + } + + return false; + } +} + +function projectPoint(p: Point, pixelPosMatrix: mat4) { + const point = vec4.transformMat4([] as any, [p.x, p.y, 0, 1], pixelPosMatrix); + return new Point(point[0] / point[3], point[1] / point[3]); +} + +function projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4) { + return queryGeometry.map((p) => { + return projectPoint(p, pixelPosMatrix); + }); +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/circle_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/circle_style_layer_properties.g.ts new file mode 100644 index 00000000..45a55cc8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/circle_style_layer_properties.g.ts @@ -0,0 +1,76 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type CircleLayoutProps = { + "circle-sort-key": DataDrivenProperty, +}; + +export type CircleLayoutPropsPossiblyEvaluated = { + "circle-sort-key": PossiblyEvaluatedPropertyValue, +}; + +let layout: Properties; +const getLayout = () => layout = layout || new Properties({ + "circle-sort-key": new DataDrivenProperty(styleSpec["layout_circle"]["circle-sort-key"] as any as StylePropertySpecification), +}); + +export type CirclePaintProps = { + "circle-radius": DataDrivenProperty, + "circle-color": DataDrivenProperty, + "circle-blur": DataDrivenProperty, + "circle-opacity": DataDrivenProperty, + "circle-translate": DataConstantProperty<[number, number]>, + "circle-translate-anchor": DataConstantProperty<"map" | "viewport">, + "circle-pitch-scale": DataConstantProperty<"map" | "viewport">, + "circle-pitch-alignment": DataConstantProperty<"map" | "viewport">, + "circle-stroke-width": DataDrivenProperty, + "circle-stroke-color": DataDrivenProperty, + "circle-stroke-opacity": DataDrivenProperty, +}; + +export type CirclePaintPropsPossiblyEvaluated = { + "circle-radius": PossiblyEvaluatedPropertyValue, + "circle-color": PossiblyEvaluatedPropertyValue, + "circle-blur": PossiblyEvaluatedPropertyValue, + "circle-opacity": PossiblyEvaluatedPropertyValue, + "circle-translate": [number, number], + "circle-translate-anchor": "map" | "viewport", + "circle-pitch-scale": "map" | "viewport", + "circle-pitch-alignment": "map" | "viewport", + "circle-stroke-width": PossiblyEvaluatedPropertyValue, + "circle-stroke-color": PossiblyEvaluatedPropertyValue, + "circle-stroke-opacity": PossiblyEvaluatedPropertyValue, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "circle-radius": new DataDrivenProperty(styleSpec["paint_circle"]["circle-radius"] as any as StylePropertySpecification), + "circle-color": new DataDrivenProperty(styleSpec["paint_circle"]["circle-color"] as any as StylePropertySpecification), + "circle-blur": new DataDrivenProperty(styleSpec["paint_circle"]["circle-blur"] as any as StylePropertySpecification), + "circle-opacity": new DataDrivenProperty(styleSpec["paint_circle"]["circle-opacity"] as any as StylePropertySpecification), + "circle-translate": new DataConstantProperty(styleSpec["paint_circle"]["circle-translate"] as any as StylePropertySpecification), + "circle-translate-anchor": new DataConstantProperty(styleSpec["paint_circle"]["circle-translate-anchor"] as any as StylePropertySpecification), + "circle-pitch-scale": new DataConstantProperty(styleSpec["paint_circle"]["circle-pitch-scale"] as any as StylePropertySpecification), + "circle-pitch-alignment": new DataConstantProperty(styleSpec["paint_circle"]["circle-pitch-alignment"] as any as StylePropertySpecification), + "circle-stroke-width": new DataDrivenProperty(styleSpec["paint_circle"]["circle-stroke-width"] as any as StylePropertySpecification), + "circle-stroke-color": new DataDrivenProperty(styleSpec["paint_circle"]["circle-stroke-color"] as any as StylePropertySpecification), + "circle-stroke-opacity": new DataDrivenProperty(styleSpec["paint_circle"]["circle-stroke-opacity"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() }, get layout() { return getLayout() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/custom_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/custom_style_layer.ts new file mode 100644 index 00000000..88a58b6b --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/custom_style_layer.ts @@ -0,0 +1,199 @@ +import {StyleLayer} from '../style_layer'; +import type {Map} from '../../ui/map'; +import {mat4} from 'gl-matrix'; +import {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * @param gl - The map's gl context. + * @param matrix - The map's camera matrix. It projects spherical mercator + * coordinates to gl coordinates. The spherical mercator coordinate `[0, 0]` represents the + * top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When + * the `renderingMode` is `"3d"`, the z coordinate is conformal. A box with identical x, y, and z + * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate.fromLngLat} + * can be used to project a `LngLat` to a mercator coordinate. + */ +type CustomRenderMethod = (gl: WebGLRenderingContext|WebGL2RenderingContext, matrix: mat4) => void; + +/** + * Interface for custom style layers. This is a specification for + * implementers to model: it is not an exported method or class. + * + * Custom layers allow a user to render directly into the map's GL context using the map's camera. + * These layers can be added between any regular layers using {@link Map#addLayer}. + * + * Custom layers must have a unique `id` and must have the `type` of `"custom"`. + * They must implement `render` and may implement `prerender`, `onAdd` and `onRemove`. + * They can trigger rendering using {@link Map#triggerRepaint} + * and they should appropriately handle {@link MapContextEvent} with `webglcontextlost` and `webglcontextrestored`. + * + * The `renderingMode` property controls whether the layer is treated as a `"2d"` or `"3d"` map layer. Use: + * - `"renderingMode": "3d"` to use the depth buffer and share it with other layers + * - `"renderingMode": "2d"` to add a layer with no depth. If you need to use the depth buffer for a `"2d"` layer you must use an offscreen + * framebuffer and {@link CustomLayerInterface#prerender} + * + * @example + * Custom layer implemented as ES6 class + * ```ts + * class NullIslandLayer { + * constructor() { + * this.id = 'null-island'; + * this.type = 'custom'; + * this.renderingMode = '2d'; + * } + * + * onAdd(map, gl) { + * const vertexSource = ` + * uniform mat4 u_matrix; + * void main() { + * gl_Position = u_matrix * vec4(0.5, 0.5, 0.0, 1.0); + * gl_PointSize = 20.0; + * }`; + * + * const fragmentSource = ` + * void main() { + * fragColor = vec4(1.0, 0.0, 0.0, 1.0); + * }`; + * + * const vertexShader = gl.createShader(gl.VERTEX_SHADER); + * gl.shaderSource(vertexShader, vertexSource); + * gl.compileShader(vertexShader); + * const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + * gl.shaderSource(fragmentShader, fragmentSource); + * gl.compileShader(fragmentShader); + * + * this.program = gl.createProgram(); + * gl.attachShader(this.program, vertexShader); + * gl.attachShader(this.program, fragmentShader); + * gl.linkProgram(this.program); + * } + * + * render(gl, matrix) { + * gl.useProgram(this.program); + * gl.uniformMatrix4fv(gl.getUniformLocation(this.program, "u_matrix"), false, matrix); + * gl.drawArrays(gl.POINTS, 0, 1); + * } + * } + * + * map.on('load', function() { + * map.addLayer(new NullIslandLayer()); + * }); + * ``` + */ +export interface CustomLayerInterface { + /** + * A unique layer id. + */ + id: string; + /** + * The layer's type. Must be `"custom"`. + */ + type: 'custom'; + /** + * Either `"2d"` or `"3d"`. Defaults to `"2d"`. + */ + renderingMode?: '2d' | '3d'; + /** + * Called during a render frame allowing the layer to draw into the GL context. + * + * The layer can assume blending and depth state is set to allow the layer to properly + * blend and clip other layers. The layer cannot make any other assumptions about the + * current GL state. + * + * If the layer needs to render to a texture, it should implement the `prerender` method + * to do this and only use the `render` method for drawing directly into the main framebuffer. + * + * The blend function is set to `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. This expects + * colors to be provided in premultiplied alpha form where the `r`, `g` and `b` values are already + * multiplied by the `a` value. If you are unable to provide colors in premultiplied form you + * may want to change the blend function to + * `gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`. + */ + render: CustomRenderMethod; + /** + * Optional method called during a render frame to allow a layer to prepare resources or render into a texture. + * + * The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering. + */ + prerender?: CustomRenderMethod; + /** + * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This + * gives the layer a chance to initialize gl resources and register event listeners. + * + * @param map - The Map this custom layer was just added to. + * @param gl - The gl context for the map. + */ + onAdd?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void; + /** + * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This + * gives the layer a chance to clean up gl resources and event listeners. + * + * @param map - The Map this custom layer was just added to. + * @param gl - The gl context for the map. + */ + onRemove?(map: Map, gl: WebGLRenderingContext | WebGL2RenderingContext): void; +} + +export function validateCustomStyleLayer(layerObject: CustomLayerInterface) { + const errors = []; + const id = layerObject.id; + + if (id === undefined) { + errors.push({ + message: `layers.${id}: missing required property "id"` + }); + } + + if (layerObject.render === undefined) { + errors.push({ + message: `layers.${id}: missing required method "render"` + }); + } + + if (layerObject.renderingMode && + layerObject.renderingMode !== '2d' && + layerObject.renderingMode !== '3d') { + errors.push({ + message: `layers.${id}: property "renderingMode" must be either "2d" or "3d"` + }); + } + + return errors; +} + +export class CustomStyleLayer extends StyleLayer { + + implementation: CustomLayerInterface; + + constructor(implementation: CustomLayerInterface) { + super(implementation, {}); + this.implementation = implementation; + } + + is3D() { + return this.implementation.renderingMode === '3d'; + } + + hasOffscreenPass() { + return this.implementation.prerender !== undefined; + } + + recalculate() {} + updateTransitions() {} + hasTransition() { return false; } + + serialize(): LayerSpecification { + throw new Error('Custom layers cannot be serialized'); + } + + onAdd = (map: Map) => { + if (this.implementation.onAdd) { + this.implementation.onAdd(map, map.painter.context.gl); + } + }; + + onRemove = (map: Map) => { + if (this.implementation.onRemove) { + this.implementation.onRemove(map, map.painter.context.gl); + } + }; +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/fill_extrusion_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/fill_extrusion_style_layer.ts new file mode 100644 index 00000000..41b77128 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/fill_extrusion_style_layer.ts @@ -0,0 +1,224 @@ +import {StyleLayer} from '../style_layer'; + +import {FillExtrusionBucket} from '../../data/bucket/fill_extrusion_bucket'; +import {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests'; +import {translateDistance, translate} from '../query_utils'; +import properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties.g'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; +import {mat4, vec4} from 'gl-matrix'; +import Point from '@mapbox/point-geometry'; +import type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {BucketParameters} from '../../data/bucket'; +import type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties.g'; +import type {Transform} from '../../geo/transform'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; + +export class Point3D extends Point { + z: number; +} + +export class FillExtrusionStyleLayer extends StyleLayer { + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } + + createBucket(parameters: BucketParameters) { + return new FillExtrusionBucket(parameters); + } + + queryRadius(): number { + return translateDistance(this.paint.get('fill-extrusion-translate')); + } + + is3D(): boolean { + return true; + } + + queryIntersectsFeature( + queryGeometry: Array, + feature: VectorTileFeature, + featureState: FeatureState, + geometry: Array>, + zoom: number, + transform: Transform, + pixelsToTileUnits: number, + pixelPosMatrix: mat4 + ): boolean | number { + + const translatedPolygon = translate(queryGeometry, + this.paint.get('fill-extrusion-translate'), + this.paint.get('fill-extrusion-translate-anchor'), + transform.angle, pixelsToTileUnits); + + const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState); + const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState); + + const projectedQueryGeometry = projectQueryGeometry(translatedPolygon, pixelPosMatrix, transform, 0); + + const projected = projectExtrusion(geometry, base, height, pixelPosMatrix); + const projectedBase = projected[0]; + const projectedTop = projected[1]; + return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry); + } +} + +function dot(a, b) { + return a.x * b.x + a.y * b.y; +} + +export function getIntersectionDistance(projectedQueryGeometry: Array, projectedFace: Array) { + + if (projectedQueryGeometry.length === 1) { + // For point queries calculate the z at which the point intersects the face + // using barycentric coordinates. + + // Find the barycentric coordinates of the projected point within the first + // triangle of the face, using only the xy plane. It doesn't matter if the + // point is outside the first triangle because all the triangles in the face + // are in the same plane. + // + // Check whether points are coincident and use other points if they are. + let i = 0; + const a = projectedFace[i++]; + let b; + while (!b || a.equals(b)) { + b = projectedFace[i++]; + if (!b) return Infinity; + } + + // Loop until point `c` is not colinear with points `a` and `b`. + for (; i < projectedFace.length; i++) { + const c = projectedFace[i]; + + const p = projectedQueryGeometry[0]; + + const ab = b.sub(a); + const ac = c.sub(a); + const ap = p.sub(a); + + const dotABAB = dot(ab, ab); + const dotABAC = dot(ab, ac); + const dotACAC = dot(ac, ac); + const dotAPAB = dot(ap, ab); + const dotAPAC = dot(ap, ac); + const denom = dotABAB * dotACAC - dotABAC * dotABAC; + + const v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom; + const w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom; + const u = 1 - v - w; + + // Use the barycentric weighting along with the original triangle z coordinates to get the point of intersection. + const distance = a.z * u + b.z * v + c.z * w; + + if (isFinite(distance)) return distance; + } + + return Infinity; + + } else { + // The counts as closest is less clear when the query is a box. This + // returns the distance to the nearest point on the face, whether it is + // within the query or not. It could be more correct to return the + // distance to the closest point within the query box but this would be + // more complicated and expensive to calculate with little benefit. + let closestDistance = Infinity; + for (const p of projectedFace) { + closestDistance = Math.min(closestDistance, p.z); + } + return closestDistance; + } +} + +function checkIntersection(projectedBase: Array>, projectedTop: Array>, projectedQueryGeometry: Array) { + let closestDistance = Infinity; + + if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) { + closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]); + } + + for (let r = 0; r < projectedTop.length; r++) { + const ringTop = projectedTop[r]; + const ringBase = projectedBase[r]; + for (let p = 0; p < ringTop.length - 1; p++) { + const topA = ringTop[p]; + const topB = ringTop[p + 1]; + const baseA = ringBase[p]; + const baseB = ringBase[p + 1]; + const face = [topA, topB, baseB, baseA, topA]; + if (polygonIntersectsPolygon(projectedQueryGeometry, face)) { + closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face)); + } + } + } + + return closestDistance === Infinity ? false : closestDistance; +} + +/* + * Project the geometry using matrix `m`. This is essentially doing + * `vec4.transformMat4([], [p.x, p.y, z, 1], m)` but the multiplication + * is inlined so that parts of the projection that are the same across + * different points can only be done once. This produced a measurable + * performance improvement. + */ +function projectExtrusion(geometry: Array>, zBase: number, zTop: number, m: mat4): [Array>, Array>] { + const projectedBase = [] as Array>; + const projectedTop = [] as Array>; + const baseXZ = m[8] * zBase; + const baseYZ = m[9] * zBase; + const baseZZ = m[10] * zBase; + const baseWZ = m[11] * zBase; + const topXZ = m[8] * zTop; + const topYZ = m[9] * zTop; + const topZZ = m[10] * zTop; + const topWZ = m[11] * zTop; + + for (const r of geometry) { + const ringBase = [] as Array; + const ringTop = [] as Array; + for (const p of r) { + const x = p.x; + const y = p.y; + + const sX = m[0] * x + m[4] * y + m[12]; + const sY = m[1] * x + m[5] * y + m[13]; + const sZ = m[2] * x + m[6] * y + m[14]; + const sW = m[3] * x + m[7] * y + m[15]; + + const baseX = sX + baseXZ; + const baseY = sY + baseYZ; + const baseZ = sZ + baseZZ; + const baseW = sW + baseWZ; + + const topX = sX + topXZ; + const topY = sY + topYZ; + const topZ = sZ + topZZ; + const topW = sW + topWZ; + + const b = new Point(baseX / baseW, baseY / baseW) as Point3D; + b.z = baseZ / baseW; + ringBase.push(b); + + const t = new Point(topX / topW, topY / topW) as Point3D; + t.z = topZ / topW; + ringTop.push(t); + } + projectedBase.push(ringBase); + projectedTop.push(ringTop); + } + return [projectedBase, projectedTop]; +} + +function projectQueryGeometry(queryGeometry: Array, pixelPosMatrix: mat4, transform: Transform, z: number) { + const projectedQueryGeometry = []; + for (const p of queryGeometry) { + const v = [p.x, p.y, z, 1] as vec4; + vec4.transformMat4(v, v, pixelPosMatrix); + projectedQueryGeometry.push(new Point(v[0] / v[3], v[1] / v[3])); + } + return projectedQueryGeometry; +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts new file mode 100644 index 00000000..e36189d1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts @@ -0,0 +1,55 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + + +export type FillExtrusionPaintProps = { + "fill-extrusion-opacity": DataConstantProperty, + "fill-extrusion-color": DataDrivenProperty, + "fill-extrusion-translate": DataConstantProperty<[number, number]>, + "fill-extrusion-translate-anchor": DataConstantProperty<"map" | "viewport">, + "fill-extrusion-pattern": CrossFadedDataDrivenProperty, + "fill-extrusion-height": DataDrivenProperty, + "fill-extrusion-base": DataDrivenProperty, + "fill-extrusion-vertical-gradient": DataConstantProperty, +}; + +export type FillExtrusionPaintPropsPossiblyEvaluated = { + "fill-extrusion-opacity": number, + "fill-extrusion-color": PossiblyEvaluatedPropertyValue, + "fill-extrusion-translate": [number, number], + "fill-extrusion-translate-anchor": "map" | "viewport", + "fill-extrusion-pattern": PossiblyEvaluatedPropertyValue>, + "fill-extrusion-height": PossiblyEvaluatedPropertyValue, + "fill-extrusion-base": PossiblyEvaluatedPropertyValue, + "fill-extrusion-vertical-gradient": boolean, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "fill-extrusion-opacity": new DataConstantProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-opacity"] as any as StylePropertySpecification), + "fill-extrusion-color": new DataDrivenProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-color"] as any as StylePropertySpecification), + "fill-extrusion-translate": new DataConstantProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-translate"] as any as StylePropertySpecification), + "fill-extrusion-translate-anchor": new DataConstantProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-translate-anchor"] as any as StylePropertySpecification), + "fill-extrusion-pattern": new CrossFadedDataDrivenProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-pattern"] as any as StylePropertySpecification), + "fill-extrusion-height": new DataDrivenProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-height"] as any as StylePropertySpecification), + "fill-extrusion-base": new DataDrivenProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-base"] as any as StylePropertySpecification), + "fill-extrusion-vertical-gradient": new DataConstantProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer.test.ts b/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer.test.ts new file mode 100644 index 00000000..3500f500 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer.test.ts @@ -0,0 +1,37 @@ +import {getIntersectionDistance, Point3D} from './fill_extrusion_style_layer'; + +describe('getIntersectionDistance', () => { + const queryPoint = [new Point3D(100, 100)]; + const z = 3; + const a = new Point3D(100, -90); + const b = new Point3D(110, 110); + const c = new Point3D(-110, 110); + a.z = z; + b.z = z; + c.z = z; + + test('one point', () => { + const projectedFace = [a, a]; + expect(getIntersectionDistance(queryPoint, projectedFace)).toBe(Infinity); + }); + + test('two points', () => { + const projectedFace = [a, b, a]; + expect(getIntersectionDistance(queryPoint, projectedFace)).toBe(Infinity); + }); + + test('two points coincident', () => { + const projectedFace = [a, a, a, b, b, b, b, a]; + expect(getIntersectionDistance(queryPoint, projectedFace)).toBe(Infinity); + }); + + test('three points', () => { + const projectedFace = [a, b, c, a]; + expect(getIntersectionDistance(queryPoint, projectedFace)).toBe(z); + }); + + test('three points coincident points', () => { + const projectedFace = [a, a, b, b, b, c, c, a]; + expect(getIntersectionDistance(queryPoint, projectedFace)).toBe(z); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer.ts new file mode 100644 index 00000000..0f423433 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer.ts @@ -0,0 +1,65 @@ +import {StyleLayer} from '../style_layer'; + +import {FillBucket} from '../../data/bucket/fill_bucket'; +import {polygonIntersectsMultiPolygon} from '../../util/intersection_tests'; +import {translateDistance, translate} from '../query_utils'; +import properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties.g'; +import {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties'; + +import type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {BucketParameters} from '../../data/bucket'; +import type Point from '@mapbox/point-geometry'; +import type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties.g'; +import type {EvaluationParameters} from '../evaluation_parameters'; +import type {Transform} from '../../geo/transform'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; + +export class FillStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } + + recalculate(parameters: EvaluationParameters, availableImages: Array) { + super.recalculate(parameters, availableImages); + + const outlineColor = this.paint._values['fill-outline-color']; + if (outlineColor.value.kind === 'constant' && outlineColor.value.value === undefined) { + this.paint._values['fill-outline-color'] = this.paint._values['fill-color']; + } + } + + createBucket(parameters: BucketParameters) { + return new FillBucket(parameters); + } + + queryRadius(): number { + return translateDistance(this.paint.get('fill-translate')); + } + + queryIntersectsFeature( + queryGeometry: Array, + feature: VectorTileFeature, + featureState: FeatureState, + geometry: Array>, + zoom: number, + transform: Transform, + pixelsToTileUnits: number + ): boolean { + const translatedPolygon = translate(queryGeometry, + this.paint.get('fill-translate'), + this.paint.get('fill-translate-anchor'), + transform.angle, pixelsToTileUnits); + return polygonIntersectsMultiPolygon(translatedPolygon, geometry); + } + + isTileClipped() { + return true; + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer_properties.g.ts new file mode 100644 index 00000000..8115e9ef --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/fill_style_layer_properties.g.ts @@ -0,0 +1,64 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type FillLayoutProps = { + "fill-sort-key": DataDrivenProperty, +}; + +export type FillLayoutPropsPossiblyEvaluated = { + "fill-sort-key": PossiblyEvaluatedPropertyValue, +}; + +let layout: Properties; +const getLayout = () => layout = layout || new Properties({ + "fill-sort-key": new DataDrivenProperty(styleSpec["layout_fill"]["fill-sort-key"] as any as StylePropertySpecification), +}); + +export type FillPaintProps = { + "fill-antialias": DataConstantProperty, + "fill-opacity": DataDrivenProperty, + "fill-color": DataDrivenProperty, + "fill-outline-color": DataDrivenProperty, + "fill-translate": DataConstantProperty<[number, number]>, + "fill-translate-anchor": DataConstantProperty<"map" | "viewport">, + "fill-pattern": CrossFadedDataDrivenProperty, +}; + +export type FillPaintPropsPossiblyEvaluated = { + "fill-antialias": boolean, + "fill-opacity": PossiblyEvaluatedPropertyValue, + "fill-color": PossiblyEvaluatedPropertyValue, + "fill-outline-color": PossiblyEvaluatedPropertyValue, + "fill-translate": [number, number], + "fill-translate-anchor": "map" | "viewport", + "fill-pattern": PossiblyEvaluatedPropertyValue>, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "fill-antialias": new DataConstantProperty(styleSpec["paint_fill"]["fill-antialias"] as any as StylePropertySpecification), + "fill-opacity": new DataDrivenProperty(styleSpec["paint_fill"]["fill-opacity"] as any as StylePropertySpecification), + "fill-color": new DataDrivenProperty(styleSpec["paint_fill"]["fill-color"] as any as StylePropertySpecification), + "fill-outline-color": new DataDrivenProperty(styleSpec["paint_fill"]["fill-outline-color"] as any as StylePropertySpecification), + "fill-translate": new DataConstantProperty(styleSpec["paint_fill"]["fill-translate"] as any as StylePropertySpecification), + "fill-translate-anchor": new DataConstantProperty(styleSpec["paint_fill"]["fill-translate-anchor"] as any as StylePropertySpecification), + "fill-pattern": new CrossFadedDataDrivenProperty(styleSpec["paint_fill"]["fill-pattern"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() }, get layout() { return getLayout() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/heatmap_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/heatmap_style_layer.ts new file mode 100644 index 00000000..b36f0cb9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/heatmap_style_layer.ts @@ -0,0 +1,72 @@ +import {StyleLayer} from '../style_layer'; + +import {HeatmapBucket} from '../../data/bucket/heatmap_bucket'; +import {RGBAImage} from '../../util/image'; +import properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties.g'; +import {renderColorRamp} from '../../util/color_ramp'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; + +import type {Texture} from '../../render/texture'; +import type {Framebuffer} from '../../gl/framebuffer'; +import type {HeatmapPaintProps} from './heatmap_style_layer_properties.g'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * A style layer that defines a heatmap + */ +export class HeatmapStyleLayer extends StyleLayer { + + heatmapFbo: Framebuffer; + colorRamp: RGBAImage; + colorRampTexture: Texture; + + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + createBucket(options: any) { + return new HeatmapBucket(options); + } + + constructor(layer: LayerSpecification) { + super(layer, properties); + + // make sure color ramp texture is generated for default heatmap color too + this._updateColorRamp(); + } + + _handleSpecialPaintPropertyUpdate(name: string) { + if (name === 'heatmap-color') { + this._updateColorRamp(); + } + } + + _updateColorRamp() { + const expression = this._transitionablePaint._values['heatmap-color'].value.expression; + this.colorRamp = renderColorRamp({ + expression, + evaluationKey: 'heatmapDensity', + image: this.colorRamp + }); + this.colorRampTexture = null; + } + + resize() { + if (this.heatmapFbo) { + this.heatmapFbo.destroy(); + this.heatmapFbo = null; + } + } + + queryRadius(): number { + return 0; + } + + queryIntersectsFeature(): boolean { + return false; + } + + hasOffscreenPass() { + return this.paint.get('heatmap-opacity') !== 0 && this.visibility !== 'none'; + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/heatmap_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/heatmap_style_layer_properties.g.ts new file mode 100644 index 00000000..e48b5719 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/heatmap_style_layer_properties.g.ts @@ -0,0 +1,46 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + + +export type HeatmapPaintProps = { + "heatmap-radius": DataDrivenProperty, + "heatmap-weight": DataDrivenProperty, + "heatmap-intensity": DataConstantProperty, + "heatmap-color": ColorRampProperty, + "heatmap-opacity": DataConstantProperty, +}; + +export type HeatmapPaintPropsPossiblyEvaluated = { + "heatmap-radius": PossiblyEvaluatedPropertyValue, + "heatmap-weight": PossiblyEvaluatedPropertyValue, + "heatmap-intensity": number, + "heatmap-color": ColorRampProperty, + "heatmap-opacity": number, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "heatmap-radius": new DataDrivenProperty(styleSpec["paint_heatmap"]["heatmap-radius"] as any as StylePropertySpecification), + "heatmap-weight": new DataDrivenProperty(styleSpec["paint_heatmap"]["heatmap-weight"] as any as StylePropertySpecification), + "heatmap-intensity": new DataConstantProperty(styleSpec["paint_heatmap"]["heatmap-intensity"] as any as StylePropertySpecification), + "heatmap-color": new ColorRampProperty(styleSpec["paint_heatmap"]["heatmap-color"] as any as StylePropertySpecification), + "heatmap-opacity": new DataConstantProperty(styleSpec["paint_heatmap"]["heatmap-opacity"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/hillshade_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/hillshade_style_layer.ts new file mode 100644 index 00000000..43e84133 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/hillshade_style_layer.ts @@ -0,0 +1,21 @@ +import {StyleLayer} from '../style_layer'; + +import properties, {HillshadePaintPropsPossiblyEvaluated} from './hillshade_style_layer_properties.g'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; + +import type {HillshadePaintProps} from './hillshade_style_layer_properties.g'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export class HillshadeStyleLayer extends StyleLayer { + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } + + hasOffscreenPass() { + return this.paint.get('hillshade-exaggeration') !== 0 && this.visibility !== 'none'; + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/hillshade_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/hillshade_style_layer_properties.g.ts new file mode 100644 index 00000000..cf460762 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/hillshade_style_layer_properties.g.ts @@ -0,0 +1,49 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + + +export type HillshadePaintProps = { + "hillshade-illumination-direction": DataConstantProperty, + "hillshade-illumination-anchor": DataConstantProperty<"map" | "viewport">, + "hillshade-exaggeration": DataConstantProperty, + "hillshade-shadow-color": DataConstantProperty, + "hillshade-highlight-color": DataConstantProperty, + "hillshade-accent-color": DataConstantProperty, +}; + +export type HillshadePaintPropsPossiblyEvaluated = { + "hillshade-illumination-direction": number, + "hillshade-illumination-anchor": "map" | "viewport", + "hillshade-exaggeration": number, + "hillshade-shadow-color": Color, + "hillshade-highlight-color": Color, + "hillshade-accent-color": Color, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "hillshade-illumination-direction": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-illumination-direction"] as any as StylePropertySpecification), + "hillshade-illumination-anchor": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-illumination-anchor"] as any as StylePropertySpecification), + "hillshade-exaggeration": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-exaggeration"] as any as StylePropertySpecification), + "hillshade-shadow-color": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-shadow-color"] as any as StylePropertySpecification), + "hillshade-highlight-color": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-highlight-color"] as any as StylePropertySpecification), + "hillshade-accent-color": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-accent-color"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer.test.ts b/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer.test.ts new file mode 100644 index 00000000..4ad575b9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer.test.ts @@ -0,0 +1,50 @@ +import {createStyleLayer} from '../create_style_layer'; +import {extend} from '../../util/util'; +import {LineStyleLayer} from './line_style_layer'; + +describe('LineStyleLayer', () => { + function createLineLayer(layer?) { + return extend({ + type: 'line', + source: 'line', + id: 'line', + paint: { + 'line-color': 'red', + 'line-width': 14, + 'line-gradient': [ + 'interpolate', + ['linear'], + ['line-progress'], + 0, + 'blue', + 1, + 'red' + ] + } + }, layer); + } + + test('updating with valid line-gradient updates this.gradientVersion', () => { + const lineLayer = createStyleLayer(createLineLayer()) as LineStyleLayer; + const gradientVersion = lineLayer.gradientVersion; + + lineLayer.setPaintProperty('line-gradient', [ + 'interpolate', + ['linear'], + ['line-progress'], + 0, + 'red', + 1, + 'blue' + ]); + expect(lineLayer.gradientVersion).toBeGreaterThan(gradientVersion); + }); + + test('updating with invalid line-gradient updates this.gradientVersion', () => { + const lineLayer = createStyleLayer(createLineLayer()) as LineStyleLayer; + const gradientVersion = lineLayer.gradientVersion; + + lineLayer.setPaintProperty('line-gradient', null); + expect(lineLayer.gradientVersion).toBeGreaterThan(gradientVersion); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer.ts new file mode 100644 index 00000000..d13c77b8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer.ts @@ -0,0 +1,131 @@ +import Point from '@mapbox/point-geometry'; + +import {StyleLayer} from '../style_layer'; +import {LineBucket} from '../../data/bucket/line_bucket'; +import {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests'; +import {getMaximumPaintValue, translateDistance, translate, offsetLine} from '../query_utils'; +import properties, {LineLayoutPropsPossiblyEvaluated, LinePaintPropsPossiblyEvaluated} from './line_style_layer_properties.g'; +import {extend} from '../../util/util'; +import {EvaluationParameters} from '../evaluation_parameters'; +import {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties'; + +import {isZoomExpression, Step} from '@maplibre/maplibre-gl-style-spec'; +import type {FeatureState, LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {Bucket, BucketParameters} from '../../data/bucket'; +import type {LineLayoutProps, LinePaintProps} from './line_style_layer_properties.g'; +import type {Transform} from '../../geo/transform'; +import type {VectorTileFeature} from '@mapbox/vector-tile'; + +export class LineFloorwidthProperty extends DataDrivenProperty { + useIntegerZoom: true; + + possiblyEvaluate(value, parameters) { + parameters = new EvaluationParameters(Math.floor(parameters.zoom), { + now: parameters.now, + fadeDuration: parameters.fadeDuration, + zoomHistory: parameters.zoomHistory, + transition: parameters.transition + }); + return super.possiblyEvaluate(value, parameters); + } + + evaluate(value, globals, feature, featureState) { + globals = extend({}, globals, {zoom: Math.floor(globals.zoom)}); + return super.evaluate(value, globals, feature, featureState); + } +} + +let lineFloorwidthProperty: LineFloorwidthProperty; + +export class LineStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + + gradientVersion: number; + stepInterpolant: boolean; + + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + this.gradientVersion = 0; + if (!lineFloorwidthProperty) { + lineFloorwidthProperty = + new LineFloorwidthProperty(properties.paint.properties['line-width'].specification); + lineFloorwidthProperty.useIntegerZoom = true; + } + } + + _handleSpecialPaintPropertyUpdate(name: string) { + if (name === 'line-gradient') { + const expression = this.gradientExpression(); + if (isZoomExpression(expression)) { + this.stepInterpolant = expression._styleExpression.expression instanceof Step; + } else { + this.stepInterpolant = false; + } + this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER; + } + } + + gradientExpression() { + return this._transitionablePaint._values['line-gradient'].value.expression; + } + + recalculate(parameters: EvaluationParameters, availableImages: Array) { + super.recalculate(parameters, availableImages); + (this.paint._values as any)['line-floorwidth'] = + lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values['line-width'].value, parameters); + } + + createBucket(parameters: BucketParameters) { + return new LineBucket(parameters); + } + + queryRadius(bucket: Bucket): number { + const lineBucket: LineBucket = (bucket as any); + const width = getLineWidth( + getMaximumPaintValue('line-width', this, lineBucket), + getMaximumPaintValue('line-gap-width', this, lineBucket)); + const offset = getMaximumPaintValue('line-offset', this, lineBucket); + return width / 2 + Math.abs(offset) + translateDistance(this.paint.get('line-translate')); + } + + queryIntersectsFeature( + queryGeometry: Array, + feature: VectorTileFeature, + featureState: FeatureState, + geometry: Array>, + zoom: number, + transform: Transform, + pixelsToTileUnits: number + ): boolean { + const translatedPolygon = translate(queryGeometry, + this.paint.get('line-translate'), + this.paint.get('line-translate-anchor'), + transform.angle, pixelsToTileUnits); + const halfWidth = pixelsToTileUnits / 2 * getLineWidth( + this.paint.get('line-width').evaluate(feature, featureState), + this.paint.get('line-gap-width').evaluate(feature, featureState)); + const lineOffset = this.paint.get('line-offset').evaluate(feature, featureState); + if (lineOffset) { + geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits); + } + + return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth); + } + + isTileClipped() { + return true; + } +} + +function getLineWidth(lineWidth, lineGapWidth) { + if (lineGapWidth > 0) { + return lineGapWidth + 2 * lineWidth; + } else { + return lineWidth; + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer_properties.g.ts new file mode 100644 index 00000000..1b6d8d93 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/line_style_layer_properties.g.ts @@ -0,0 +1,88 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type LineLayoutProps = { + "line-cap": DataConstantProperty<"butt" | "round" | "square">, + "line-join": DataDrivenProperty<"bevel" | "round" | "miter">, + "line-miter-limit": DataConstantProperty, + "line-round-limit": DataConstantProperty, + "line-sort-key": DataDrivenProperty, +}; + +export type LineLayoutPropsPossiblyEvaluated = { + "line-cap": "butt" | "round" | "square", + "line-join": PossiblyEvaluatedPropertyValue<"bevel" | "round" | "miter">, + "line-miter-limit": number, + "line-round-limit": number, + "line-sort-key": PossiblyEvaluatedPropertyValue, +}; + +let layout: Properties; +const getLayout = () => layout = layout || new Properties({ + "line-cap": new DataConstantProperty(styleSpec["layout_line"]["line-cap"] as any as StylePropertySpecification), + "line-join": new DataDrivenProperty(styleSpec["layout_line"]["line-join"] as any as StylePropertySpecification), + "line-miter-limit": new DataConstantProperty(styleSpec["layout_line"]["line-miter-limit"] as any as StylePropertySpecification), + "line-round-limit": new DataConstantProperty(styleSpec["layout_line"]["line-round-limit"] as any as StylePropertySpecification), + "line-sort-key": new DataDrivenProperty(styleSpec["layout_line"]["line-sort-key"] as any as StylePropertySpecification), +}); + +export type LinePaintProps = { + "line-opacity": DataDrivenProperty, + "line-color": DataDrivenProperty, + "line-translate": DataConstantProperty<[number, number]>, + "line-translate-anchor": DataConstantProperty<"map" | "viewport">, + "line-width": DataDrivenProperty, + "line-gap-width": DataDrivenProperty, + "line-offset": DataDrivenProperty, + "line-blur": DataDrivenProperty, + "line-dasharray": CrossFadedProperty>, + "line-pattern": CrossFadedDataDrivenProperty, + "line-gradient": ColorRampProperty, +}; + +export type LinePaintPropsPossiblyEvaluated = { + "line-opacity": PossiblyEvaluatedPropertyValue, + "line-color": PossiblyEvaluatedPropertyValue, + "line-translate": [number, number], + "line-translate-anchor": "map" | "viewport", + "line-width": PossiblyEvaluatedPropertyValue, + "line-gap-width": PossiblyEvaluatedPropertyValue, + "line-offset": PossiblyEvaluatedPropertyValue, + "line-blur": PossiblyEvaluatedPropertyValue, + "line-dasharray": CrossFaded>, + "line-pattern": PossiblyEvaluatedPropertyValue>, + "line-gradient": ColorRampProperty, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "line-opacity": new DataDrivenProperty(styleSpec["paint_line"]["line-opacity"] as any as StylePropertySpecification), + "line-color": new DataDrivenProperty(styleSpec["paint_line"]["line-color"] as any as StylePropertySpecification), + "line-translate": new DataConstantProperty(styleSpec["paint_line"]["line-translate"] as any as StylePropertySpecification), + "line-translate-anchor": new DataConstantProperty(styleSpec["paint_line"]["line-translate-anchor"] as any as StylePropertySpecification), + "line-width": new DataDrivenProperty(styleSpec["paint_line"]["line-width"] as any as StylePropertySpecification), + "line-gap-width": new DataDrivenProperty(styleSpec["paint_line"]["line-gap-width"] as any as StylePropertySpecification), + "line-offset": new DataDrivenProperty(styleSpec["paint_line"]["line-offset"] as any as StylePropertySpecification), + "line-blur": new DataDrivenProperty(styleSpec["paint_line"]["line-blur"] as any as StylePropertySpecification), + "line-dasharray": new CrossFadedProperty(styleSpec["paint_line"]["line-dasharray"] as any as StylePropertySpecification), + "line-pattern": new CrossFadedDataDrivenProperty(styleSpec["paint_line"]["line-pattern"] as any as StylePropertySpecification), + "line-gradient": new ColorRampProperty(styleSpec["paint_line"]["line-gradient"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() }, get layout() { return getLayout() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/overlap_mode.test.ts b/web/libraries/maplibre-gl/src/style/style_layer/overlap_mode.test.ts new file mode 100644 index 00000000..6c984b35 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/overlap_mode.test.ts @@ -0,0 +1,57 @@ +import {getOverlapMode} from './overlap_mode'; +import {SymbolStyleLayer} from './symbol_style_layer'; +import {ZoomHistory} from '../zoom_history'; +import {EvaluationParameters} from '../evaluation_parameters'; + +function createSymbolLayer(layerProperties) { + const layer = new SymbolStyleLayer(layerProperties); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + return layer; +} + +describe('getOverlapMode', () => { + test('defaults - no props set', () => { + const props = {}; + const layer = createSymbolLayer(props); + + expect(getOverlapMode(layer.layout, 'icon-overlap', 'icon-allow-overlap')).toBe('never'); + expect(getOverlapMode(layer.layout, 'text-overlap', 'text-allow-overlap')).toBe('never'); + }); + + test('-allow-overlap set', () => { + const props = {layout: {'icon-allow-overlap': false, 'text-allow-overlap': true}}; + const layer = createSymbolLayer(props); + + expect(getOverlapMode(layer.layout, 'icon-overlap', 'icon-allow-overlap')).toBe('never'); + expect(getOverlapMode(layer.layout, 'text-overlap', 'text-allow-overlap')).toBe('always'); + }); + + test('-overlap set', () => { + let props = {layout: {'icon-overlap': 'never', 'text-overlap': 'always'}}; + let layer = createSymbolLayer(props); + + expect(getOverlapMode(layer.layout, 'icon-overlap', 'icon-allow-overlap')).toBe('never'); + expect(getOverlapMode(layer.layout, 'text-overlap', 'text-allow-overlap')).toBe('always'); + + props = {layout: {'icon-overlap': 'always', 'text-overlap': 'cooperative'}}; + layer = createSymbolLayer(props); + + expect(getOverlapMode(layer.layout, 'icon-overlap', 'icon-allow-overlap')).toBe('always'); + expect(getOverlapMode(layer.layout, 'text-overlap', 'text-allow-overlap')).toBe('cooperative'); + }); + + test('-overlap beats -allow-overlap', () => { + const props = { + layout: { + 'icon-overlap': 'never', + 'icon-allow-overlap': true, + 'text-overlap': 'cooperative', + 'text-allow-overlap': false + } + }; + const layer = createSymbolLayer(props); + + expect(getOverlapMode(layer.layout, 'icon-overlap', 'icon-allow-overlap')).toBe('never'); + expect(getOverlapMode(layer.layout, 'text-overlap', 'text-allow-overlap')).toBe('cooperative'); + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/style_layer/overlap_mode.ts b/web/libraries/maplibre-gl/src/style/style_layer/overlap_mode.ts new file mode 100644 index 00000000..1d1ed5ff --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/overlap_mode.ts @@ -0,0 +1,25 @@ +import {SymbolLayoutPropsPossiblyEvaluated} from './symbol_style_layer_properties.g'; +import type {SymbolLayoutProps} from './symbol_style_layer_properties.g'; +import {PossiblyEvaluated} from '../properties'; + +/** + * The overlap mode for properties like `icon-overlap`and `text-overlap` + */ +export type OverlapMode = 'never' | 'always' | 'cooperative'; + +export function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap', allowOverlapProp: 'icon-allow-overlap'): OverlapMode; +export function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'text-overlap', allowOverlapProp: 'text-allow-overlap'): OverlapMode; +export function getOverlapMode(layout: PossiblyEvaluated, overlapProp: 'icon-overlap' | 'text-overlap', allowOverlapProp: 'icon-allow-overlap' | 'text-allow-overlap'): OverlapMode { + let result: OverlapMode = 'never'; + const overlap = layout.get(overlapProp); + + if (overlap) { + // if -overlap is set, use it + result = overlap; + } else if (layout.get(allowOverlapProp)) { + // fall back to -allow-overlap, with false='never', true='always' + result = 'always'; + } + + return result; +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/raster_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/raster_style_layer.ts new file mode 100644 index 00000000..407b11af --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/raster_style_layer.ts @@ -0,0 +1,17 @@ +import {StyleLayer} from '../style_layer'; + +import properties, {RasterPaintPropsPossiblyEvaluated} from './raster_style_layer_properties.g'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; + +import type {RasterPaintProps} from './raster_style_layer_properties.g'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export class RasterStyleLayer extends StyleLayer { + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/raster_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/raster_style_layer_properties.g.ts new file mode 100644 index 00000000..4a953f59 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/raster_style_layer_properties.g.ts @@ -0,0 +1,55 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + + +export type RasterPaintProps = { + "raster-opacity": DataConstantProperty, + "raster-hue-rotate": DataConstantProperty, + "raster-brightness-min": DataConstantProperty, + "raster-brightness-max": DataConstantProperty, + "raster-saturation": DataConstantProperty, + "raster-contrast": DataConstantProperty, + "raster-resampling": DataConstantProperty<"linear" | "nearest">, + "raster-fade-duration": DataConstantProperty, +}; + +export type RasterPaintPropsPossiblyEvaluated = { + "raster-opacity": number, + "raster-hue-rotate": number, + "raster-brightness-min": number, + "raster-brightness-max": number, + "raster-saturation": number, + "raster-contrast": number, + "raster-resampling": "linear" | "nearest", + "raster-fade-duration": number, +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "raster-opacity": new DataConstantProperty(styleSpec["paint_raster"]["raster-opacity"] as any as StylePropertySpecification), + "raster-hue-rotate": new DataConstantProperty(styleSpec["paint_raster"]["raster-hue-rotate"] as any as StylePropertySpecification), + "raster-brightness-min": new DataConstantProperty(styleSpec["paint_raster"]["raster-brightness-min"] as any as StylePropertySpecification), + "raster-brightness-max": new DataConstantProperty(styleSpec["paint_raster"]["raster-brightness-max"] as any as StylePropertySpecification), + "raster-saturation": new DataConstantProperty(styleSpec["paint_raster"]["raster-saturation"] as any as StylePropertySpecification), + "raster-contrast": new DataConstantProperty(styleSpec["paint_raster"]["raster-contrast"] as any as StylePropertySpecification), + "raster-resampling": new DataConstantProperty(styleSpec["paint_raster"]["raster-resampling"] as any as StylePropertySpecification), + "raster-fade-duration": new DataConstantProperty(styleSpec["paint_raster"]["raster-fade-duration"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/symbol_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/symbol_style_layer.ts new file mode 100644 index 00000000..34d9f157 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/symbol_style_layer.ts @@ -0,0 +1,195 @@ +import {StyleLayer} from '../style_layer'; + +import {SymbolBucket, SymbolFeature} from '../../data/bucket/symbol_bucket'; +import {resolveTokens} from '../../util/resolve_tokens'; +import properties, {SymbolLayoutPropsPossiblyEvaluated, SymbolPaintPropsPossiblyEvaluated} from './symbol_style_layer_properties.g'; + +import { + Transitionable, + Transitioning, + Layout, + PossiblyEvaluated, + PossiblyEvaluatedPropertyValue, + PropertyValue +} from '../properties'; + +import { + isExpression, + StyleExpression, + ZoomConstantExpression, + ZoomDependentExpression, + FormattedType, + typeOf, + Formatted, + FormatExpression, + Literal} from '@maplibre/maplibre-gl-style-spec'; + +import type {BucketParameters} from '../../data/bucket'; +import type {SymbolLayoutProps, SymbolPaintProps} from './symbol_style_layer_properties.g'; +import type {EvaluationParameters} from '../evaluation_parameters'; +import type {Expression, Feature, SourceExpression, LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; +import type {CanonicalTileID} from '../../source/tile_id'; +import {FormatSectionOverride} from '../format_section_override'; + +export class SymbolStyleLayer extends StyleLayer { + _unevaluatedLayout: Layout; + layout: PossiblyEvaluated; + + _transitionablePaint: Transitionable; + _transitioningPaint: Transitioning; + paint: PossiblyEvaluated; + + constructor(layer: LayerSpecification) { + super(layer, properties); + } + + recalculate(parameters: EvaluationParameters, availableImages: Array) { + super.recalculate(parameters, availableImages); + + if (this.layout.get('icon-rotation-alignment') === 'auto') { + if (this.layout.get('symbol-placement') !== 'point') { + this.layout._values['icon-rotation-alignment'] = 'map'; + } else { + this.layout._values['icon-rotation-alignment'] = 'viewport'; + } + } + + if (this.layout.get('text-rotation-alignment') === 'auto') { + if (this.layout.get('symbol-placement') !== 'point') { + this.layout._values['text-rotation-alignment'] = 'map'; + } else { + this.layout._values['text-rotation-alignment'] = 'viewport'; + } + } + + // If unspecified, `*-pitch-alignment` inherits `*-rotation-alignment` + if (this.layout.get('text-pitch-alignment') === 'auto') { + this.layout._values['text-pitch-alignment'] = this.layout.get('text-rotation-alignment') === 'map' ? 'map' : 'viewport'; + } + if (this.layout.get('icon-pitch-alignment') === 'auto') { + this.layout._values['icon-pitch-alignment'] = this.layout.get('icon-rotation-alignment'); + } + + if (this.layout.get('symbol-placement') === 'point') { + const writingModes = this.layout.get('text-writing-mode'); + if (writingModes) { + // remove duplicates, preserving order + const deduped = []; + for (const m of writingModes) { + if (deduped.indexOf(m) < 0) deduped.push(m); + } + this.layout._values['text-writing-mode'] = deduped; + } else { + this.layout._values['text-writing-mode'] = ['horizontal']; + } + } + + this._setPaintOverrides(); + } + + getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array) { + const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages); + const unevaluated = this._unevaluatedLayout._values[name]; + if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) { + return resolveTokens(feature.properties, value); + } + + return value; + } + + createBucket(parameters: BucketParameters) { + return new SymbolBucket(parameters); + } + + queryRadius(): number { + return 0; + } + + queryIntersectsFeature(): boolean { + throw new Error('Should take a different path in FeatureIndex'); + } + + _setPaintOverrides() { + for (const overridable of properties.paint.overridableProperties) { + if (!SymbolStyleLayer.hasPaintOverride(this.layout, overridable)) { + continue; + } + const overriden = this.paint.get(overridable as keyof SymbolPaintPropsPossiblyEvaluated) as PossiblyEvaluatedPropertyValue; + const override = new FormatSectionOverride(overriden); + const styleExpression = new StyleExpression(override, overriden.property.specification); + let expression = null; + if (overriden.value.kind === 'constant' || overriden.value.kind === 'source') { + expression = new ZoomConstantExpression('source', styleExpression) as SourceExpression; + } else { + expression = new ZoomDependentExpression('composite', + styleExpression, + overriden.value.zoomStops); + } + this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property, + expression, + overriden.parameters); + } + } + + _handleOverridablePaintPropertyUpdate(name: string, oldValue: PropertyValue, newValue: PropertyValue): boolean { + if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) { + return false; + } + return SymbolStyleLayer.hasPaintOverride(this.layout, name); + } + + static hasPaintOverride(layout: PossiblyEvaluated, propertyName: string): boolean { + const textField = layout.get('text-field'); + const property = properties.paint.properties[propertyName]; + let hasOverrides = false; + + const checkSections = (sections) => { + for (const section of sections) { + if (property.overrides && property.overrides.hasOverride(section)) { + hasOverrides = true; + return; + } + } + }; + + if (textField.value.kind === 'constant' && textField.value.value instanceof Formatted) { + checkSections(textField.value.value.sections); + } else if (textField.value.kind === 'source') { + + const checkExpression = (expression: Expression) => { + if (hasOverrides) return; + + if (expression instanceof Literal && typeOf(expression.value) === FormattedType) { + const formatted: Formatted = (expression.value as any); + checkSections(formatted.sections); + } else if (expression instanceof FormatExpression) { + checkSections(expression.sections); + } else { + expression.eachChild(checkExpression); + } + }; + + const expr: ZoomConstantExpression<'source'> = (textField.value as any); + if (expr._styleExpression) { + checkExpression(expr._styleExpression.expression); + } + } + + return hasOverrides; + } +} + +export type SymbolPadding = [number, number, number, number]; + +export function getIconPadding(layout: PossiblyEvaluated, feature: SymbolFeature, canonical: CanonicalTileID, pixelRatio = 1): SymbolPadding { + // Support text-padding in addition to icon-padding? Unclear how to apply asymmetric text-padding to the radius for collision circles. + const result = layout.get('icon-padding').evaluate(feature, {}, canonical); + const values = result && result.values; + + return [ + values[0] * pixelRatio, + values[1] * pixelRatio, + values[2] * pixelRatio, + values[3] * pixelRatio, + ]; +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer/symbol_style_layer_properties.g.ts b/web/libraries/maplibre-gl/src/style/style_layer/symbol_style_layer_properties.g.ts new file mode 100644 index 00000000..a64c47d7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/symbol_style_layer_properties.g.ts @@ -0,0 +1,218 @@ +// This file is generated. Edit build/generate-style-code.ts, then run 'npm run codegen'. +/* eslint-disable */ + +import {latest as styleSpec} from '@maplibre/maplibre-gl-style-spec'; + +import { + Properties, + DataConstantProperty, + DataDrivenProperty, + CrossFadedDataDrivenProperty, + CrossFadedProperty, + ColorRampProperty, + PossiblyEvaluatedPropertyValue, + CrossFaded +} from '../properties'; + +import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + +import { + ColorType + } from '@maplibre/maplibre-gl-style-spec'; + +export type SymbolLayoutProps = { + "symbol-placement": DataConstantProperty<"point" | "line" | "line-center">, + "symbol-spacing": DataConstantProperty, + "symbol-avoid-edges": DataConstantProperty, + "symbol-sort-key": DataDrivenProperty, + "symbol-z-order": DataConstantProperty<"auto" | "viewport-y" | "source">, + "icon-allow-overlap": DataConstantProperty, + "icon-overlap": DataConstantProperty<"never" | "always" | "cooperative">, + "icon-ignore-placement": DataConstantProperty, + "icon-optional": DataConstantProperty, + "icon-rotation-alignment": DataConstantProperty<"map" | "viewport" | "auto">, + "icon-size": DataDrivenProperty, + "icon-text-fit": DataConstantProperty<"none" | "width" | "height" | "both">, + "icon-text-fit-padding": DataConstantProperty<[number, number, number, number]>, + "icon-image": DataDrivenProperty, + "icon-rotate": DataDrivenProperty, + "icon-padding": DataDrivenProperty, + "icon-keep-upright": DataConstantProperty, + "icon-offset": DataDrivenProperty<[number, number]>, + "icon-anchor": DataDrivenProperty<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">, + "icon-pitch-alignment": DataConstantProperty<"map" | "viewport" | "auto">, + "text-pitch-alignment": DataConstantProperty<"map" | "viewport" | "auto">, + "text-rotation-alignment": DataConstantProperty<"map" | "viewport" | "viewport-glyph" | "auto">, + "text-field": DataDrivenProperty, + "text-font": DataDrivenProperty>, + "text-size": DataDrivenProperty, + "text-max-width": DataDrivenProperty, + "text-line-height": DataConstantProperty, + "text-letter-spacing": DataDrivenProperty, + "text-justify": DataDrivenProperty<"auto" | "left" | "center" | "right">, + "text-radial-offset": DataDrivenProperty, + "text-variable-anchor": DataConstantProperty>, + "text-variable-anchor-offset": DataDrivenProperty, + "text-anchor": DataDrivenProperty<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">, + "text-max-angle": DataConstantProperty, + "text-writing-mode": DataConstantProperty>, + "text-rotate": DataDrivenProperty, + "text-padding": DataConstantProperty, + "text-keep-upright": DataConstantProperty, + "text-transform": DataDrivenProperty<"none" | "uppercase" | "lowercase">, + "text-offset": DataDrivenProperty<[number, number]>, + "text-allow-overlap": DataConstantProperty, + "text-overlap": DataConstantProperty<"never" | "always" | "cooperative">, + "text-ignore-placement": DataConstantProperty, + "text-optional": DataConstantProperty, +}; + +export type SymbolLayoutPropsPossiblyEvaluated = { + "symbol-placement": "point" | "line" | "line-center", + "symbol-spacing": number, + "symbol-avoid-edges": boolean, + "symbol-sort-key": PossiblyEvaluatedPropertyValue, + "symbol-z-order": "auto" | "viewport-y" | "source", + "icon-allow-overlap": boolean, + "icon-overlap": "never" | "always" | "cooperative", + "icon-ignore-placement": boolean, + "icon-optional": boolean, + "icon-rotation-alignment": "map" | "viewport" | "auto", + "icon-size": PossiblyEvaluatedPropertyValue, + "icon-text-fit": "none" | "width" | "height" | "both", + "icon-text-fit-padding": [number, number, number, number], + "icon-image": PossiblyEvaluatedPropertyValue, + "icon-rotate": PossiblyEvaluatedPropertyValue, + "icon-padding": PossiblyEvaluatedPropertyValue, + "icon-keep-upright": boolean, + "icon-offset": PossiblyEvaluatedPropertyValue<[number, number]>, + "icon-anchor": PossiblyEvaluatedPropertyValue<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">, + "icon-pitch-alignment": "map" | "viewport" | "auto", + "text-pitch-alignment": "map" | "viewport" | "auto", + "text-rotation-alignment": "map" | "viewport" | "viewport-glyph" | "auto", + "text-field": PossiblyEvaluatedPropertyValue, + "text-font": PossiblyEvaluatedPropertyValue>, + "text-size": PossiblyEvaluatedPropertyValue, + "text-max-width": PossiblyEvaluatedPropertyValue, + "text-line-height": number, + "text-letter-spacing": PossiblyEvaluatedPropertyValue, + "text-justify": PossiblyEvaluatedPropertyValue<"auto" | "left" | "center" | "right">, + "text-radial-offset": PossiblyEvaluatedPropertyValue, + "text-variable-anchor": Array<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">, + "text-variable-anchor-offset": PossiblyEvaluatedPropertyValue, + "text-anchor": PossiblyEvaluatedPropertyValue<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">, + "text-max-angle": number, + "text-writing-mode": Array<"horizontal" | "vertical">, + "text-rotate": PossiblyEvaluatedPropertyValue, + "text-padding": number, + "text-keep-upright": boolean, + "text-transform": PossiblyEvaluatedPropertyValue<"none" | "uppercase" | "lowercase">, + "text-offset": PossiblyEvaluatedPropertyValue<[number, number]>, + "text-allow-overlap": boolean, + "text-overlap": "never" | "always" | "cooperative", + "text-ignore-placement": boolean, + "text-optional": boolean, +}; + +let layout: Properties; +const getLayout = () => layout = layout || new Properties({ + "symbol-placement": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-placement"] as any as StylePropertySpecification), + "symbol-spacing": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-spacing"] as any as StylePropertySpecification), + "symbol-avoid-edges": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-avoid-edges"] as any as StylePropertySpecification), + "symbol-sort-key": new DataDrivenProperty(styleSpec["layout_symbol"]["symbol-sort-key"] as any as StylePropertySpecification), + "symbol-z-order": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-z-order"] as any as StylePropertySpecification), + "icon-allow-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["icon-allow-overlap"] as any as StylePropertySpecification), + "icon-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["icon-overlap"] as any as StylePropertySpecification), + "icon-ignore-placement": new DataConstantProperty(styleSpec["layout_symbol"]["icon-ignore-placement"] as any as StylePropertySpecification), + "icon-optional": new DataConstantProperty(styleSpec["layout_symbol"]["icon-optional"] as any as StylePropertySpecification), + "icon-rotation-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["icon-rotation-alignment"] as any as StylePropertySpecification), + "icon-size": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-size"] as any as StylePropertySpecification), + "icon-text-fit": new DataConstantProperty(styleSpec["layout_symbol"]["icon-text-fit"] as any as StylePropertySpecification), + "icon-text-fit-padding": new DataConstantProperty(styleSpec["layout_symbol"]["icon-text-fit-padding"] as any as StylePropertySpecification), + "icon-image": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-image"] as any as StylePropertySpecification), + "icon-rotate": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-rotate"] as any as StylePropertySpecification), + "icon-padding": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-padding"] as any as StylePropertySpecification), + "icon-keep-upright": new DataConstantProperty(styleSpec["layout_symbol"]["icon-keep-upright"] as any as StylePropertySpecification), + "icon-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-offset"] as any as StylePropertySpecification), + "icon-anchor": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-anchor"] as any as StylePropertySpecification), + "icon-pitch-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["icon-pitch-alignment"] as any as StylePropertySpecification), + "text-pitch-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["text-pitch-alignment"] as any as StylePropertySpecification), + "text-rotation-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["text-rotation-alignment"] as any as StylePropertySpecification), + "text-field": new DataDrivenProperty(styleSpec["layout_symbol"]["text-field"] as any as StylePropertySpecification), + "text-font": new DataDrivenProperty(styleSpec["layout_symbol"]["text-font"] as any as StylePropertySpecification), + "text-size": new DataDrivenProperty(styleSpec["layout_symbol"]["text-size"] as any as StylePropertySpecification), + "text-max-width": new DataDrivenProperty(styleSpec["layout_symbol"]["text-max-width"] as any as StylePropertySpecification), + "text-line-height": new DataConstantProperty(styleSpec["layout_symbol"]["text-line-height"] as any as StylePropertySpecification), + "text-letter-spacing": new DataDrivenProperty(styleSpec["layout_symbol"]["text-letter-spacing"] as any as StylePropertySpecification), + "text-justify": new DataDrivenProperty(styleSpec["layout_symbol"]["text-justify"] as any as StylePropertySpecification), + "text-radial-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["text-radial-offset"] as any as StylePropertySpecification), + "text-variable-anchor": new DataConstantProperty(styleSpec["layout_symbol"]["text-variable-anchor"] as any as StylePropertySpecification), + "text-variable-anchor-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["text-variable-anchor-offset"] as any as StylePropertySpecification), + "text-anchor": new DataDrivenProperty(styleSpec["layout_symbol"]["text-anchor"] as any as StylePropertySpecification), + "text-max-angle": new DataConstantProperty(styleSpec["layout_symbol"]["text-max-angle"] as any as StylePropertySpecification), + "text-writing-mode": new DataConstantProperty(styleSpec["layout_symbol"]["text-writing-mode"] as any as StylePropertySpecification), + "text-rotate": new DataDrivenProperty(styleSpec["layout_symbol"]["text-rotate"] as any as StylePropertySpecification), + "text-padding": new DataConstantProperty(styleSpec["layout_symbol"]["text-padding"] as any as StylePropertySpecification), + "text-keep-upright": new DataConstantProperty(styleSpec["layout_symbol"]["text-keep-upright"] as any as StylePropertySpecification), + "text-transform": new DataDrivenProperty(styleSpec["layout_symbol"]["text-transform"] as any as StylePropertySpecification), + "text-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["text-offset"] as any as StylePropertySpecification), + "text-allow-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["text-allow-overlap"] as any as StylePropertySpecification), + "text-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["text-overlap"] as any as StylePropertySpecification), + "text-ignore-placement": new DataConstantProperty(styleSpec["layout_symbol"]["text-ignore-placement"] as any as StylePropertySpecification), + "text-optional": new DataConstantProperty(styleSpec["layout_symbol"]["text-optional"] as any as StylePropertySpecification), +}); + +export type SymbolPaintProps = { + "icon-opacity": DataDrivenProperty, + "icon-color": DataDrivenProperty, + "icon-halo-color": DataDrivenProperty, + "icon-halo-width": DataDrivenProperty, + "icon-halo-blur": DataDrivenProperty, + "icon-translate": DataConstantProperty<[number, number]>, + "icon-translate-anchor": DataConstantProperty<"map" | "viewport">, + "text-opacity": DataDrivenProperty, + "text-color": DataDrivenProperty, + "text-halo-color": DataDrivenProperty, + "text-halo-width": DataDrivenProperty, + "text-halo-blur": DataDrivenProperty, + "text-translate": DataConstantProperty<[number, number]>, + "text-translate-anchor": DataConstantProperty<"map" | "viewport">, +}; + +export type SymbolPaintPropsPossiblyEvaluated = { + "icon-opacity": PossiblyEvaluatedPropertyValue, + "icon-color": PossiblyEvaluatedPropertyValue, + "icon-halo-color": PossiblyEvaluatedPropertyValue, + "icon-halo-width": PossiblyEvaluatedPropertyValue, + "icon-halo-blur": PossiblyEvaluatedPropertyValue, + "icon-translate": [number, number], + "icon-translate-anchor": "map" | "viewport", + "text-opacity": PossiblyEvaluatedPropertyValue, + "text-color": PossiblyEvaluatedPropertyValue, + "text-halo-color": PossiblyEvaluatedPropertyValue, + "text-halo-width": PossiblyEvaluatedPropertyValue, + "text-halo-blur": PossiblyEvaluatedPropertyValue, + "text-translate": [number, number], + "text-translate-anchor": "map" | "viewport", +}; + +let paint: Properties; +const getPaint = () => paint = paint || new Properties({ + "icon-opacity": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-opacity"] as any as StylePropertySpecification), + "icon-color": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-color"] as any as StylePropertySpecification), + "icon-halo-color": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-halo-color"] as any as StylePropertySpecification), + "icon-halo-width": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-halo-width"] as any as StylePropertySpecification), + "icon-halo-blur": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-halo-blur"] as any as StylePropertySpecification), + "icon-translate": new DataConstantProperty(styleSpec["paint_symbol"]["icon-translate"] as any as StylePropertySpecification), + "icon-translate-anchor": new DataConstantProperty(styleSpec["paint_symbol"]["icon-translate-anchor"] as any as StylePropertySpecification), + "text-opacity": new DataDrivenProperty(styleSpec["paint_symbol"]["text-opacity"] as any as StylePropertySpecification), + "text-color": new DataDrivenProperty(styleSpec["paint_symbol"]["text-color"] as any as StylePropertySpecification, { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }), + "text-halo-color": new DataDrivenProperty(styleSpec["paint_symbol"]["text-halo-color"] as any as StylePropertySpecification), + "text-halo-width": new DataDrivenProperty(styleSpec["paint_symbol"]["text-halo-width"] as any as StylePropertySpecification), + "text-halo-blur": new DataDrivenProperty(styleSpec["paint_symbol"]["text-halo-blur"] as any as StylePropertySpecification), + "text-translate": new DataConstantProperty(styleSpec["paint_symbol"]["text-translate"] as any as StylePropertySpecification), + "text-translate-anchor": new DataConstantProperty(styleSpec["paint_symbol"]["text-translate-anchor"] as any as StylePropertySpecification), +}); + +export default ({ get paint() { return getPaint() }, get layout() { return getLayout() } }); \ No newline at end of file diff --git a/web/libraries/maplibre-gl/src/style/style_layer/typed_style_layer.ts b/web/libraries/maplibre-gl/src/style/style_layer/typed_style_layer.ts new file mode 100644 index 00000000..a340484e --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/typed_style_layer.ts @@ -0,0 +1,9 @@ +import type {CircleStyleLayer} from './circle_style_layer'; +import type {FillStyleLayer} from './fill_style_layer'; +import type {FillExtrusionStyleLayer} from './fill_extrusion_style_layer'; +import type {HeatmapStyleLayer} from './heatmap_style_layer'; +import type {HillshadeStyleLayer} from './hillshade_style_layer'; +import type {LineStyleLayer} from './line_style_layer'; +import type {SymbolStyleLayer} from './symbol_style_layer'; + +export type TypedStyleLayer = CircleStyleLayer | FillStyleLayer | FillExtrusionStyleLayer | HeatmapStyleLayer | HillshadeStyleLayer | LineStyleLayer | SymbolStyleLayer; diff --git a/web/libraries/maplibre-gl/src/style/style_layer/variable_text_anchor.test.ts b/web/libraries/maplibre-gl/src/style/style_layer/variable_text_anchor.test.ts new file mode 100644 index 00000000..0a4af2a4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/variable_text_anchor.test.ts @@ -0,0 +1,117 @@ +import {EvaluationParameters} from '../evaluation_parameters'; +import {ZoomHistory} from '../zoom_history'; +import {SymbolStyleLayer} from './symbol_style_layer'; +import {INVALID_TEXT_OFFSET, evaluateVariableOffset, getTextVariableAnchorOffset} from './variable_text_anchor'; + +describe('evaluateVariableOffset', () => { + test('fromRadialOffset', () => { + // Radial offset mode is invoked by using INVALID_TEXT_OFFSET as the Y value + const srcOffset = [10, INVALID_TEXT_OFFSET] as [number, number]; + + expect(evaluateVariableOffset('center', srcOffset)).toEqual([0, 0]); + + // Top/bottom offsets are shifted by the default baseline (7) + expect(evaluateVariableOffset('top', srcOffset)).toEqual([0, 3]); + expect(evaluateVariableOffset('bottom', srcOffset)).toEqual([0, -3]); + expect(evaluateVariableOffset('left', srcOffset)).toEqual([10, 0]); + expect(evaluateVariableOffset('right', srcOffset)).toEqual([-10, 0]); + + const hypotenuse = 10 / Math.SQRT2; + expect(evaluateVariableOffset('top-left', srcOffset)).toEqual([expect.closeTo(hypotenuse), expect.closeTo(hypotenuse - 7)]); + expect(evaluateVariableOffset('top-right', srcOffset)).toEqual([expect.closeTo(-hypotenuse), expect.closeTo(hypotenuse - 7)]); + expect(evaluateVariableOffset('bottom-left', srcOffset)).toEqual([expect.closeTo(hypotenuse), expect.closeTo(-hypotenuse + 7)]); + expect(evaluateVariableOffset('bottom-right', srcOffset)).toEqual([expect.closeTo(-hypotenuse), expect.closeTo(-hypotenuse + 7)]); + }); + + test('fromTextOffset', () => { + const srcOffset = [10, -10] as [number, number]; + + expect(evaluateVariableOffset('center', srcOffset)).toEqual([0, 0]); + + // Top/bottom offsets are shifted by the default baseline (7) + expect(evaluateVariableOffset('top', srcOffset)).toEqual([0, 3]); + expect(evaluateVariableOffset('bottom', srcOffset)).toEqual([0, -3]); + expect(evaluateVariableOffset('left', srcOffset)).toEqual([10, 0]); + expect(evaluateVariableOffset('right', srcOffset)).toEqual([-10, 0]); + expect(evaluateVariableOffset('top-left', srcOffset)).toEqual([10, 3]); + expect(evaluateVariableOffset('top-right', srcOffset)).toEqual([-10, 3]); + expect(evaluateVariableOffset('bottom-left', srcOffset)).toEqual([10, -3]); + expect(evaluateVariableOffset('bottom-right', srcOffset)).toEqual([-10, -3]); + }); +}); + +function createSymbolLayer(layerProperties) { + const layer = new SymbolStyleLayer(layerProperties); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + return layer; +} + +describe('getTextVariableAnchorOffset', () => { + test('defaults - no props set', () => { + const props = {}; + const layer = createSymbolLayer(props); + + expect(getTextVariableAnchorOffset(layer, null, null)).toBeNull(); + }); + + test('text-variable-anchor-offset set', () => { + const props = {layout: {'text-variable-anchor-offset': ['top', [1, 1], 'bottom', [2, 2]]}}; + const layer = createSymbolLayer(props); + + const offset = getTextVariableAnchorOffset(layer, null, null); + expect(offset).toBeDefined(); + // Offset converted to EMs, accounting for baseline shift on Y axis + expect(offset.toString()).toBe('["top",[24,17],"bottom",[48,55]]'); + }); + + test('text-variable-anchor set', () => { + const props = {layout: {'text-variable-anchor': ['top']}}; + const layer = createSymbolLayer(props); + + const offset = getTextVariableAnchorOffset(layer, null, null); + expect(offset).toBeDefined(); + // Default offset (0, 0) converted to EMs, accounting for baseline shift on Y axis + expect(offset.toString()).toBe('["top",[0,-7]]'); + }); + + test('text-variable-anchor and text-offset set', () => { + const props = {layout: {'text-variable-anchor': ['top'], 'text-offset': [1, 1]}}; + const layer = createSymbolLayer(props); + + const offset = getTextVariableAnchorOffset(layer, null, null); + expect(offset).toBeDefined(); + // Offset converted to EMs, accounting for baseline shift on Y axis + expect(offset.toString()).toBe('["top",[0,17]]'); + }); + + test('text-variable-anchor and text-radial-offset set', () => { + const props = {layout: {'text-variable-anchor': ['top'], 'text-radial-offset': 2}}; + const layer = createSymbolLayer(props); + + const offset = getTextVariableAnchorOffset(layer, null, null); + expect(offset).toBeDefined(); + // Offset converted to EMs, accounting for baseline shift on Y axis + expect(offset.toString()).toBe('["top",[0,41]]'); + }); + + test('text-variable-anchor, text-offset, and text-radial-offset set', () => { + const props = {layout: {'text-variable-anchor': ['top'], 'text-offset': [1, 1], 'text-radial-offset': 2}}; + const layer = createSymbolLayer(props); + + const offset = getTextVariableAnchorOffset(layer, null, null); + expect(offset).toBeDefined(); + // Offset converted to EMs, accounting for baseline shift on Y axis + expect(offset.toString()).toBe('["top",[0,41]]'); + }); + + test('text-variable-anchor and text-variable-anchor-offset set', () => { + const props = {layout: {'text-variable-anchor-offset': ['top', [1, 1]], 'text-variable-anchor': ['bottom']}}; + const layer = createSymbolLayer(props); + + const offset = getTextVariableAnchorOffset(layer, null, null); + expect(offset).toBeDefined(); + // Offset converted to EMs, accounting for baseline shift on Y axis + expect(offset.toString()).toBe('["top",[24,17]]'); + }); +}); + diff --git a/web/libraries/maplibre-gl/src/style/style_layer/variable_text_anchor.ts b/web/libraries/maplibre-gl/src/style/style_layer/variable_text_anchor.ts new file mode 100644 index 00000000..cb6474ee --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer/variable_text_anchor.ts @@ -0,0 +1,163 @@ +import {VariableAnchorOffsetCollection, VariableAnchorOffsetCollectionSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {SymbolFeature} from '../../data/bucket/symbol_bucket'; +import {CanonicalTileID} from '../../source/tile_id'; +import ONE_EM from '../../symbol/one_em'; +import {SymbolStyleLayer} from './symbol_style_layer'; + +export enum TextAnchorEnum { + 'center' = 1, + 'left' = 2, + 'right' = 3, + 'top' = 4, + 'bottom' = 5, + 'top-left' = 6, + 'top-right' = 7, + 'bottom-left' = 8, + 'bottom-right' = 9 +} + +export type TextAnchor = keyof typeof TextAnchorEnum; + +// The radial offset is to the edge of the text box +// In the horizontal direction, the edge of the text box is where glyphs start +// But in the vertical direction, the glyphs appear to "start" at the baseline +// We don't actually load baseline data, but we assume an offset of ONE_EM - 17 +// (see "yOffset" in shaping.js) +const baselineOffset = 7; +export const INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY; + +export function evaluateVariableOffset(anchor: TextAnchor, offset: [number, number]): [number, number] { + + function fromRadialOffset(anchor: TextAnchor, radialOffset: number): [number, number] { + let x = 0, y = 0; + if (radialOffset < 0) radialOffset = 0; // Ignore negative offset. + // solve for r where r^2 + r^2 = radialOffset^2 + const hypotenuse = radialOffset / Math.SQRT2; + switch (anchor) { + case 'top-right': + case 'top-left': + y = hypotenuse - baselineOffset; + break; + case 'bottom-right': + case 'bottom-left': + y = -hypotenuse + baselineOffset; + break; + case 'bottom': + y = -radialOffset + baselineOffset; + break; + case 'top': + y = radialOffset - baselineOffset; + break; + } + + switch (anchor) { + case 'top-right': + case 'bottom-right': + x = -hypotenuse; + break; + case 'top-left': + case 'bottom-left': + x = hypotenuse; + break; + case 'left': + x = radialOffset; + break; + case 'right': + x = -radialOffset; + break; + } + + return [x, y]; + } + + function fromTextOffset(anchor: TextAnchor, offsetX: number, offsetY: number): [number, number] { + let x = 0, y = 0; + // Use absolute offset values. + offsetX = Math.abs(offsetX); + offsetY = Math.abs(offsetY); + + switch (anchor) { + case 'top-right': + case 'top-left': + case 'top': + y = offsetY - baselineOffset; + break; + case 'bottom-right': + case 'bottom-left': + case 'bottom': + y = -offsetY + baselineOffset; + break; + } + + switch (anchor) { + case 'top-right': + case 'bottom-right': + case 'right': + x = -offsetX; + break; + case 'top-left': + case 'bottom-left': + case 'left': + x = offsetX; + break; + } + + return [x, y]; + } + + return (offset[1] !== INVALID_TEXT_OFFSET) ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]); +} + +// Helper to support both text-variable-anchor and text-variable-anchor-offset. Offset values converted from EMs to PXs +export function getTextVariableAnchorOffset(layer: SymbolStyleLayer, feature: SymbolFeature, canonical: CanonicalTileID): VariableAnchorOffsetCollection | null { + const layout = layer.layout; + // If style specifies text-variable-anchor-offset, just return it + const variableAnchorOffset = layout.get('text-variable-anchor-offset')?.evaluate(feature, {}, canonical); + + if (variableAnchorOffset) { + const sourceValues = variableAnchorOffset.values; + const destValues: VariableAnchorOffsetCollectionSpecification = []; + + // Convert offsets from EM to PX, and apply baseline shift + for (let i = 0; i < sourceValues.length; i += 2) { + const anchor = destValues[i] = sourceValues[i] as TextAnchor; + const offset = (sourceValues[i + 1] as [number, number]).map(t => t * ONE_EM) as [number, number]; + + if (anchor.startsWith('top')) { + offset[1] -= baselineOffset; + } else if (anchor.startsWith('bottom')) { + offset[1] += baselineOffset; + } + + destValues[i + 1] = offset; + } + + return new VariableAnchorOffsetCollection(destValues); + } + + // If style specifies text-variable-anchor, convert to the new format + const variableAnchor = layout.get('text-variable-anchor'); + + if (variableAnchor) { + let textOffset: [number, number]; + const unevaluatedLayout = layer._unevaluatedLayout; + + // The style spec says don't use `text-offset` and `text-radial-offset` together + // but doesn't actually specify what happens if you use both. We go with the radial offset. + if (unevaluatedLayout.getValue('text-radial-offset') !== undefined) { + textOffset = [layout.get('text-radial-offset').evaluate(feature, {}, canonical) * ONE_EM, INVALID_TEXT_OFFSET]; + } else { + textOffset = layout.get('text-offset').evaluate(feature, {}, canonical).map(t => t * ONE_EM) as [number, number]; + } + + const anchorOffsets: VariableAnchorOffsetCollectionSpecification = []; + + for (const anchor of variableAnchor) { + anchorOffsets.push(anchor, evaluateVariableOffset(anchor, textOffset)); + } + + return new VariableAnchorOffsetCollection(anchorOffsets); + } + + return null; +} diff --git a/web/libraries/maplibre-gl/src/style/style_layer_index.test.ts b/web/libraries/maplibre-gl/src/style/style_layer_index.test.ts new file mode 100644 index 00000000..8d84e7a6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer_index.test.ts @@ -0,0 +1,99 @@ +import {mapObject} from '../util/util'; +import {StyleLayerIndex} from './style_layer_index'; + +describe('StyleLayerIndex', () => { + test('StyleLayerIndex#replace', () => { + const index = new StyleLayerIndex([ + {id: '1', type: 'fill', source: 'source', 'source-layer': 'layer', paint: {'fill-color': 'red'}}, + {id: '2', type: 'circle', source: 'source', 'source-layer': 'layer', paint: {'circle-color': 'green'}}, + {id: '3', type: 'circle', source: 'source', 'source-layer': 'layer', paint: {'circle-color': 'blue'}} + ]); + + const families = index.familiesBySource['source']['layer']; + expect(families).toHaveLength(2); + expect(families[0]).toHaveLength(1); + expect(families[0][0].id).toBe('1'); + expect(families[1]).toHaveLength(2); + expect(families[1][0].id).toBe('2'); + expect(families[1][1].id).toBe('3'); + + index.replace([]); + expect(index.familiesBySource).toEqual({}); + + }); + + test('StyleLayerIndex#update', () => { + const index = new StyleLayerIndex([ + {id: '1', type: 'fill', source: 'foo', 'source-layer': 'layer', paint: {'fill-color': 'red'}}, + {id: '2', type: 'circle', source: 'foo', 'source-layer': 'layer', paint: {'circle-color': 'green'}}, + {id: '3', type: 'circle', source: 'foo', 'source-layer': 'layer', paint: {'circle-color': 'blue'}} + ]); + + index.update([ + {id: '1', type: 'fill', source: 'bar', 'source-layer': 'layer', paint: {'fill-color': 'cyan'}}, + {id: '2', type: 'circle', source: 'bar', 'source-layer': 'layer', paint: {'circle-color': 'magenta'}}, + {id: '3', type: 'circle', source: 'bar', 'source-layer': 'layer', paint: {'circle-color': 'yellow'}} + ], []); + + const families = index.familiesBySource['bar']['layer']; + expect(families).toHaveLength(2); + expect(families[0]).toHaveLength(1); + expect(families[0][0].getPaintProperty('fill-color')).toBe('cyan'); + expect(families[1]).toHaveLength(2); + expect(families[1][0].getPaintProperty('circle-color')).toBe('magenta'); + expect(families[1][0].source).toBe('bar'); + expect(families[1][1].getPaintProperty('circle-color')).toBe('yellow'); + expect(families[1][1].source).toBe('bar'); + + }); + + test('StyleLayerIndex#familiesBySource', () => { + const index = new StyleLayerIndex([ + {id: '0', type: 'fill', 'source': 'A', 'source-layer': 'foo'}, + {id: '1', type: 'fill', 'source': 'A', 'source-layer': 'foo'}, + {id: '2', type: 'fill', 'source': 'A', 'source-layer': 'foo', 'minzoom': 1}, + {id: '3', type: 'fill', 'source': 'A', 'source-layer': 'bar'}, + {id: '4', type: 'fill', 'source': 'B', 'source-layer': 'foo'}, + {id: '5', type: 'fill', 'source': 'geojson'}, + {id: '6', type: 'background'} + ]); + + const ids = mapObject(index.familiesBySource, (bySource) => { + return mapObject(bySource, (families) => { + return families.map((family) => { + return family.map((layer) => layer.id); + }); + }); + }); + + expect(ids).toEqual({ + 'A': { + 'foo': [['0', '1'], ['2']], + 'bar': [['3']] + }, + 'B': { + 'foo': [['4']] + }, + 'geojson': { + '_geojsonTileLayer': [['5']] + }, + '': { + '_geojsonTileLayer': [['6']] + } + }); + + }); + + test('StyleLayerIndex groups families even if layout key order differs', () => { + const index = new StyleLayerIndex([ + {id: '0', type: 'line', 'source': 'source', 'source-layer': 'layer', + 'layout': {'line-cap': 'butt', 'line-join': 'miter'}}, + {id: '1', type: 'line', 'source': 'source', 'source-layer': 'layer', + 'layout': {'line-join': 'miter', 'line-cap': 'butt'}} + ]); + + const families = index.familiesBySource['source']['layer']; + expect(families[0]).toHaveLength(2); + + }); +}); diff --git a/web/libraries/maplibre-gl/src/style/style_layer_index.ts b/web/libraries/maplibre-gl/src/style/style_layer_index.ts new file mode 100644 index 00000000..0c9b0cd3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/style_layer_index.ts @@ -0,0 +1,78 @@ +import {StyleLayer} from './style_layer'; +import {createStyleLayer} from './create_style_layer'; + +import {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec'; + +import type {TypedStyleLayer} from './style_layer/typed_style_layer'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +export type LayerConfigs = {[_: string]: LayerSpecification}; +export type Family = Array; + +export class StyleLayerIndex { + familiesBySource: { + [source: string]: { + [sourceLayer: string]: Array>; + }; + }; + keyCache: {[source: string]: string}; + + _layerConfigs: LayerConfigs; + _layers: {[_: string]: StyleLayer}; + + constructor(layerConfigs?: Array | null) { + this.keyCache = {}; + if (layerConfigs) { + this.replace(layerConfigs); + } + } + + replace(layerConfigs: Array) { + this._layerConfigs = {}; + this._layers = {}; + this.update(layerConfigs, []); + } + + update(layerConfigs: Array, removedIds: Array) { + for (const layerConfig of layerConfigs) { + this._layerConfigs[layerConfig.id] = layerConfig; + + const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig); + layer._featureFilter = featureFilter(layer.filter); + if (this.keyCache[layerConfig.id]) + delete this.keyCache[layerConfig.id]; + } + for (const id of removedIds) { + delete this.keyCache[id]; + delete this._layerConfigs[id]; + delete this._layers[id]; + } + + this.familiesBySource = {}; + + const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache); + + for (const layerConfigs of groups) { + const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]); + + const layer = layers[0]; + if (layer.visibility === 'none') { + continue; + } + + const sourceId = layer.source || ''; + let sourceGroup = this.familiesBySource[sourceId]; + if (!sourceGroup) { + sourceGroup = this.familiesBySource[sourceId] = {}; + } + + const sourceLayerId = layer.sourceLayer || '_geojsonTileLayer'; + let sourceLayerFamilies = sourceGroup[sourceLayerId]; + if (!sourceLayerFamilies) { + sourceLayerFamilies = sourceGroup[sourceLayerId] = []; + } + + sourceLayerFamilies.push(layers); + } + } +} diff --git a/web/libraries/maplibre-gl/src/style/validate_style.ts b/web/libraries/maplibre-gl/src/style/validate_style.ts new file mode 100644 index 00000000..9af29869 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/validate_style.ts @@ -0,0 +1,51 @@ +import {validateStyleMin} from '@maplibre/maplibre-gl-style-spec'; +import {ErrorEvent} from '../util/evented'; + +import type {Evented} from '../util/evented'; + +type ValidationError = { + message: string; + line: number; + identifier?: string; +}; + +export type Validator = (a: any) => ReadonlyArray; + +type ValidateStyle = { + source: Validator; + sprite: Validator; + glyphs: Validator; + layer: Validator; + light: Validator; + terrain: Validator; + filter: Validator; + paintProperty: Validator; + layoutProperty: Validator; + (b: any, a?: any | null): ReadonlyArray; +}; + +export const validateStyle = (validateStyleMin as unknown as ValidateStyle); + +export const validateSource = validateStyle.source; +export const validateLight = validateStyle.light; +export const validateTerrain = validateStyle.terrain; +export const validateFilter = validateStyle.filter; +export const validatePaintProperty = validateStyle.paintProperty; +export const validateLayoutProperty = validateStyle.layoutProperty; + +export function emitValidationErrors( + emitter: Evented, + errors?: ReadonlyArray<{ + message: string; + identifier?: string; + }> | null +): boolean { + let hasErrors = false; + if (errors && errors.length) { + for (const error of errors) { + emitter.fire(new ErrorEvent(new Error(error.message))); + hasErrors = true; + } + } + return hasErrors; +} diff --git a/web/libraries/maplibre-gl/src/style/zoom_history.ts b/web/libraries/maplibre-gl/src/style/zoom_history.ts new file mode 100644 index 00000000..c91c13a9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/style/zoom_history.ts @@ -0,0 +1,40 @@ +export class ZoomHistory { + lastZoom: number; + lastFloorZoom: number; + lastIntegerZoom: number; + lastIntegerZoomTime: number; + first: boolean; + + constructor() { + this.first = true; + } + + update(z: number, now: number) { + const floorZ = Math.floor(z); + + if (this.first) { + this.first = false; + this.lastIntegerZoom = floorZ; + this.lastIntegerZoomTime = 0; + this.lastZoom = z; + this.lastFloorZoom = floorZ; + return true; + } + + if (this.lastFloorZoom > floorZ) { + this.lastIntegerZoom = floorZ + 1; + this.lastIntegerZoomTime = now; + } else if (this.lastFloorZoom < floorZ) { + this.lastIntegerZoom = floorZ; + this.lastIntegerZoomTime = now; + } + + if (z !== this.lastZoom) { + this.lastZoom = z; + this.lastFloorZoom = floorZ; + return true; + } + + return false; + } +} diff --git a/web/libraries/maplibre-gl/src/symbol/anchor.test.ts b/web/libraries/maplibre-gl/src/symbol/anchor.test.ts new file mode 100644 index 00000000..1e08a984 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/anchor.test.ts @@ -0,0 +1,14 @@ +import {Anchor} from './anchor'; + +describe('Anchor', () => { + test('#constructor', () => { + expect(new Anchor(0, 0, 0) instanceof Anchor).toBeTruthy(); + expect(new Anchor(0, 0, 0, 0) instanceof Anchor).toBeTruthy(); + }); + test('#clone', () => { + const a = new Anchor(1, 2, 3); + const b = new Anchor(1, 2, 3); + expect(a.clone()).toEqual(b); + expect(a.clone()).toEqual(a); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/anchor.ts b/web/libraries/maplibre-gl/src/symbol/anchor.ts new file mode 100644 index 00000000..04210600 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/anchor.ts @@ -0,0 +1,22 @@ +import Point from '@mapbox/point-geometry'; + +import {register} from '../util/web_worker_transfer'; + +export class Anchor extends Point { + angle: any; + segment?: number; + + constructor(x: number, y: number, angle: number, segment?: number) { + super(x, y); + this.angle = angle; + if (segment !== undefined) { + this.segment = segment; + } + } + + clone() { + return new Anchor(this.x, this.y, this.angle, this.segment); + } +} + +register('Anchor', Anchor); diff --git a/web/libraries/maplibre-gl/src/symbol/check_max_angle.test.ts b/web/libraries/maplibre-gl/src/symbol/check_max_angle.test.ts new file mode 100644 index 00000000..59e32440 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/check_max_angle.test.ts @@ -0,0 +1,54 @@ +import Point from '@mapbox/point-geometry'; +import {checkMaxAngle} from './check_max_angle'; +import {Anchor} from './anchor'; + +describe('checkMaxAngle', () => { + test('line with no sharp angles', () => { + const line = [new Point(0, 0), new Point(20, -1), new Point(40, 1), new Point(60, 0)]; + const anchor = new Anchor(30, 0, 0, 1); + expect(checkMaxAngle(line, anchor, 25, 20, Math.PI / 8)).toBeTruthy(); + expect(checkMaxAngle(line, anchor, 25, 20, 0)).toBeFalsy(); + }); + + test('one sharp corner', () => { + const line = [new Point(0, 0), new Point(0, 10), new Point(10, 10)]; + const anchor = new Anchor(0, 10, 0, 1); + expect(checkMaxAngle(line, anchor, 10, 5, Math.PI / 2)).toBeTruthy(); + expect(checkMaxAngle(line, anchor, 10, 5, Math.PI / 2 - 0.01)).toBeFalsy(); + }); + + test('many small corners close together', () => { + const line = [ + new Point(0, 0), new Point(10, 0), new Point(11, 0.1), + new Point(12, 0.3), new Point(13, 0.6), new Point(14, 1), new Point(13.9, 10)]; + const anchor = new Anchor(12, 0.3, 0, 3); + expect(checkMaxAngle(line, anchor, 10, 5, Math.PI / 2)).toBeFalsy(); + expect(checkMaxAngle(line, anchor, 10, 2, Math.PI / 2)).toBeTruthy(); + }); + + test('label appears on the first line segment', () => { + const line = [new Point(0, 0), new Point(100, 0)]; + const anchor = new Anchor(50, 0, 0, 0); + expect(checkMaxAngle(line, anchor, 30, 5, Math.PI / 2)).toBeTruthy(); + }); + + test('not enough space before the end of the line', () => { + const line = [new Point(0, 0), new Point(10, 0), new Point(20, 0), new Point(30, 0)]; + const anchor = new Anchor(5, 0, 0, 0); + expect(checkMaxAngle(line, anchor, 11, 5, Math.PI)).toBeFalsy(); + expect(checkMaxAngle(line, anchor, 10, 5, Math.PI)).toBeTruthy(); + }); + + test('not enough space after the beginning of the line', () => { + const line = [new Point(0, 0), new Point(10, 0), new Point(20, 0), new Point(30, 0)]; + const anchor = new Anchor(25, 0, 0, 2); + expect(checkMaxAngle(line, anchor, 11, 5, Math.PI)).toBeFalsy(); + expect(checkMaxAngle(line, anchor, 10, 5, Math.PI)).toBeTruthy(); + }); + + test('one segment and label length is 0', () => { + const line = [new Point(0, 0), new Point(10, 0)]; + const anchor = new Anchor(5, 0, 0, 0); + expect(checkMaxAngle(line, anchor, 0, 5, Math.PI)).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/check_max_angle.ts b/web/libraries/maplibre-gl/src/symbol/check_max_angle.ts new file mode 100644 index 00000000..e2c867c4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/check_max_angle.ts @@ -0,0 +1,76 @@ +import type Point from '@mapbox/point-geometry'; +import type {Anchor} from './anchor'; + +/** + * Labels placed around really sharp angles aren't readable. Check if any + * part of the potential label has a combined angle that is too big. + * + * @param line - The line to check + * @param anchor - The point on the line around which the label is anchored. + * @param labelLength - The length of the label in geometry units. + * @param windowSize - The check fails if the combined angles within a part of the line that is `windowSize` long is too big. + * @param maxAngle - The maximum combined angle that any window along the label is allowed to have. + * + * @returns whether the label should be placed + */ +export function checkMaxAngle(line: Array, anchor: Anchor, labelLength: number, windowSize: number, maxAngle: number) { + + // horizontal labels and labels with length 0 always pass + if (anchor.segment === undefined || labelLength === 0) return true; + + let p = anchor; + let index = anchor.segment + 1; + let anchorDistance = 0; + + // move backwards along the line to the first segment the label appears on + while (anchorDistance > -labelLength / 2) { + index--; + + // there isn't enough room for the label after the beginning of the line + if (index < 0) return false; + + anchorDistance -= line[index].dist(p); + p = line[index]; + } + + anchorDistance += line[index].dist(line[index + 1]); + index++; + + // store recent corners and their total angle difference + const recentCorners = []; + let recentAngleDelta = 0; + + // move forwards by the length of the label and check angles along the way + while (anchorDistance < labelLength / 2) { + const prev = line[index - 1]; + const current = line[index]; + const next = line[index + 1]; + + // there isn't enough room for the label before the end of the line + if (!next) return false; + + let angleDelta = prev.angleTo(current) - current.angleTo(next); + // restrict angle to -pi..pi range + angleDelta = Math.abs(((angleDelta + 3 * Math.PI) % (Math.PI * 2)) - Math.PI); + + recentCorners.push({ + distance: anchorDistance, + angleDelta + }); + recentAngleDelta += angleDelta; + + // remove corners that are far enough away from the list of recent anchors + while (anchorDistance - recentCorners[0].distance > windowSize) { + recentAngleDelta -= recentCorners.shift().angleDelta; + } + + // the sum of angles within the window area exceeds the maximum allowed value. check fails. + if (recentAngleDelta > maxAngle) return false; + + index++; + anchorDistance += current.dist(next); + } + + // no part of the line had an angle greater than the maximum allowed. check passes. + return true; +} diff --git a/web/libraries/maplibre-gl/src/symbol/clip_line.test.ts b/web/libraries/maplibre-gl/src/symbol/clip_line.test.ts new file mode 100644 index 00000000..b9ba3b8a --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/clip_line.test.ts @@ -0,0 +1,154 @@ +import Point from '@mapbox/point-geometry'; +import {clipLine} from './clip_line'; + +describe('clipLines', () => { + + const minX = -300; + const maxX = 300; + const minY = -200; + const maxY = 200; + + const clipLineTest = (lines) => { + return clipLine(lines, minX, minY, maxX, maxY); + }; + + test('Single line fully inside', () => { + const line = [ + new Point(-100, -100), + new Point(-40, -100), + new Point(200, 0), + new Point(-80, 195) + ]; + + expect(clipLineTest([line])).toEqual([line]); + }); + + test('Multiline fully inside', () => { + const line0 = [ + new Point(-250, -150), + new Point(-250, 150), + new Point(-10, 150), + new Point(-10, -150) + ]; + + const line1 = [ + new Point(250, -150), + new Point(250, 150), + new Point(10, 150), + new Point(10, -150) + ]; + + const lines = [line0, line1]; + + expect(clipLineTest(lines)).toEqual(lines); + }); + + test('Lines fully outside', () => { + const line0 = [ + new Point(-400, -300), + new Point(-350, 0), + new Point(-300, 300) + ]; + + const line1 = [ + new Point(1000, 210), + new Point(10000, 500) + ]; + + expect(clipLineTest([line0, line1])).toEqual([]); + }); + + test('Intersect with single border', () => { + const line0 = [ + new Point(-400, 0), + new Point(0, 0) + ]; + + const result0 = [ + new Point(minX, 0), + new Point(0, 0) + ]; + + const line1 = [ + new Point(250, -50), + new Point(350, 50) + ]; + + const result1 = [ + new Point(250, -50), + new Point(maxX, 0) + ]; + + expect(clipLineTest([line0, line1])).toEqual([result0, result1]); + }); + + test('Intersect with multiple borders', () => { + const line0 = [ + new Point(-350, -100), + new Point(-200, -250) + ]; + + const line1 = [ + new Point(-100, 250), + new Point(0, 150), + new Point(100, 250) + ]; + + const result0 = [ + new Point(minX, -150), + new Point(-250, minY) + ]; + + const result1 = [ + new Point(-50, maxY), + new Point(0, 150), + new Point(50, maxY) + ]; + + expect(clipLineTest([line0, line1])).toEqual([result0, result1]); + }); + + test('Single line can be split into multiple segments', () => { + const line = [ + new Point(-80, 150), + new Point(-80, 350), + new Point(120, 1000), + new Point(120, 0) + ]; + + const result0 = [ + new Point(-80, 150), + new Point(-80, maxY), + ]; + + const result1 = [ + new Point(120, maxY), + new Point(120, 0), + ]; + + expect(clipLineTest([line])).toEqual([result0, result1]); + }); + + test('Non-clipped points are bit exact', () => { + const line = [ + new Point(-500, -200), + new Point(131.2356763, 0.956732) + ]; + + expect(clipLineTest([line])[1]).toEqual(line[0][1]); + }); + + test('Clipped points are rounded to the nearest integer', () => { + const line = [ + new Point(310, 2.9), + new Point(290, 2.5) + ]; + + const result = [ + new Point(maxX, 3), + new Point(290, 2.5) + ]; + + expect(clipLineTest([line])).toEqual([result]); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/clip_line.ts b/web/libraries/maplibre-gl/src/symbol/clip_line.ts new file mode 100644 index 00000000..457955b8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/clip_line.ts @@ -0,0 +1,66 @@ +import Point from '@mapbox/point-geometry'; + +/** + * Returns the part of a multiline that intersects with the provided rectangular box. + * + * @param lines - the lines to check + * @param x1 - the left edge of the box + * @param y1 - the top edge of the box + * @param x2 - the right edge of the box + * @param y2 - the bottom edge of the box + * @returns lines + */ +export function clipLine(lines: Array>, x1: number, y1: number, x2: number, y2: number): Array> { + const clippedLines = []; + + for (let l = 0; l < lines.length; l++) { + const line = lines[l]; + let clippedLine; + + for (let i = 0; i < line.length - 1; i++) { + let p0 = line[i]; + let p1 = line[i + 1]; + + if (p0.x < x1 && p1.x < x1) { + continue; + } else if (p0.x < x1) { + p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round(); + } else if (p1.x < x1) { + p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round(); + } + + if (p0.y < y1 && p1.y < y1) { + continue; + } else if (p0.y < y1) { + p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round(); + } else if (p1.y < y1) { + p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round(); + } + + if (p0.x >= x2 && p1.x >= x2) { + continue; + } else if (p0.x >= x2) { + p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round(); + } else if (p1.x >= x2) { + p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round(); + } + + if (p0.y >= y2 && p1.y >= y2) { + continue; + } else if (p0.y >= y2) { + p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round(); + } else if (p1.y >= y2) { + p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round(); + } + + if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) { + clippedLine = [p0]; + clippedLines.push(clippedLine); + } + + clippedLine.push(p1); + } + } + + return clippedLines; +} diff --git a/web/libraries/maplibre-gl/src/symbol/collision_feature.test.ts b/web/libraries/maplibre-gl/src/symbol/collision_feature.test.ts new file mode 100644 index 00000000..362ca96c --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/collision_feature.test.ts @@ -0,0 +1,98 @@ +import {CollisionFeature} from './collision_feature'; +import {Anchor} from './anchor'; +import Point from '@mapbox/point-geometry'; +import {CollisionBoxArray} from '../data/array_types.g'; +import {SymbolPadding} from '../style/style_layer/symbol_style_layer'; + +describe('CollisionFeature', () => { + + const collisionBoxArray = new CollisionBoxArray(); + + const shapedText = { + left: -50, + top: -10, + right: 50, + bottom: 10 + }; + + const padding: SymbolPadding = [0, 0, 0, 0]; + + test('point label', () => { + const point = new Point(500, 0); + const anchor = new Anchor(point.x, point.y, 0, undefined); + + const cf = new CollisionFeature(collisionBoxArray, anchor, 0, 0, 0, shapedText, 1, padding, false, 0); + expect(cf.circleDiameter).toBeFalsy(); + expect(cf.boxEndIndex - cf.boxStartIndex).toBe(1); + + const box = collisionBoxArray.get(cf.boxStartIndex); + expect(box.x1).toBe(-50); + expect(box.x2).toBe(50); + expect(box.y1).toBe(-10); + expect(box.y2).toBe(10); + }); + + test('point label with padding', () => { + const point = new Point(500, 0); + const anchor = new Anchor(point.x, point.y, 0, undefined); + const pointPadding: SymbolPadding = [10, 20, -5, -10]; // top, right, bottom, left + const cf = new CollisionFeature(collisionBoxArray, anchor, 0, 0, 0, shapedText, 1, pointPadding, false, 0); + + expect(cf.boxEndIndex - cf.boxStartIndex).toBe(1); + const box = collisionBoxArray.get(cf.boxStartIndex); + expect(box.x1).toBe(-40); + expect(box.x2).toBe(70); + expect(box.y1).toBe(-20); + expect(box.y2).toBe(5); + }); + + test('Compute line height for runtime collision circles (line label)', () => { + const anchor = new Anchor(505, 95, 0, 1); + const cf = new CollisionFeature(collisionBoxArray, anchor, 0, 0, 0, shapedText, 1, padding, true, 0); + expect(cf.circleDiameter).toBeTruthy(); + expect(cf.circleDiameter).toBe(shapedText.bottom - shapedText.top); + expect(cf.boxEndIndex - cf.boxStartIndex).toBe(0); + }); + + test('Collision circle diameter is not computed for features with zero height', () => { + const shapedText = { + left: -50, + top: -10, + right: 50, + bottom: -10 + }; + + const anchor = new Anchor(505, 95, 0, 1); + const cf = new CollisionFeature(collisionBoxArray, anchor, 0, 0, 0, shapedText, 1, padding, true, 0); + expect(cf.boxEndIndex - cf.boxStartIndex).toBe(0); + expect(cf.circleDiameter).toBeFalsy(); + }); + + test('Collision circle diameter is not computed for features with negative height', () => { + const shapedText = { + left: -50, + top: 10, + right: 50, + bottom: -10 + }; + + const anchor = new Anchor(505, 95, 0, 1); + const cf = new CollisionFeature(collisionBoxArray, anchor, 0, 0, 0, shapedText, 1, padding, true, 0); + expect(cf.boxEndIndex - cf.boxStartIndex).toBe(0); + expect(cf.circleDiameter).toBeFalsy(); + }); + + test('Use minimum collision circle diameter', () => { + const shapedText = { + left: -50, + top: 10, + right: 50, + bottom: 10.00001 + }; + + const anchor = new Anchor(505, 95, 0, 1); + const cf = new CollisionFeature(collisionBoxArray, anchor, 0, 0, 0, shapedText, 1, padding, true, 0); + expect(cf.boxEndIndex - cf.boxStartIndex).toBe(0); + expect(cf.circleDiameter).toBe(10); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/collision_feature.ts b/web/libraries/maplibre-gl/src/symbol/collision_feature.ts new file mode 100644 index 00000000..8fca28d9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/collision_feature.ts @@ -0,0 +1,104 @@ +import type {CollisionBoxArray} from '../data/array_types.g'; +import Point from '@mapbox/point-geometry'; +import type {Anchor} from './anchor'; +import {SymbolPadding} from '../style/style_layer/symbol_style_layer'; + +/** + * A CollisionFeature represents the area of the tile covered by a single label. + * It is used with CollisionIndex to check if the label overlaps with any + * previous labels. A CollisionFeature is mostly just a set of CollisionBox + * objects. + */ +export class CollisionFeature { + boxStartIndex: number; + boxEndIndex: number; + circleDiameter: number; + + /** + * Create a CollisionFeature, adding its collision box data to the given collisionBoxArray in the process. + * For line aligned labels a collision circle diameter is computed instead. + * + * @param anchor - The point along the line around which the label is anchored. + * @param shaped - The text or icon shaping results. + * @param boxScale - A magic number used to convert from glyph metrics units to geometry units. + * @param padding - The amount of padding to add around the label edges. + * @param alignLine - Whether the label is aligned with the line or the viewport. + */ + constructor(collisionBoxArray: CollisionBoxArray, + anchor: Anchor, + featureIndex: number, + sourceLayerIndex: number, + bucketIndex: number, + shaped: any, + boxScale: number, + padding: SymbolPadding, + alignLine: boolean, + rotate: number) { + + this.boxStartIndex = collisionBoxArray.length; + + if (alignLine) { + // Compute height of the shape in glyph metrics and apply collision padding. + // Note that the pixel based 'text-padding' is applied at runtime + let top = shaped.top; + let bottom = shaped.bottom; + const collisionPadding = shaped.collisionPadding; + + if (collisionPadding) { + top -= collisionPadding[1]; + bottom += collisionPadding[3]; + } + + let height = bottom - top; + + if (height > 0) { + // set minimum box height to avoid very many small labels + height = Math.max(10, height); + this.circleDiameter = height; + } + } else { + // margin is in CSS order: [top, right, bottom, left] + let y1 = shaped.top * boxScale - padding[0]; + let y2 = shaped.bottom * boxScale + padding[2]; + let x1 = shaped.left * boxScale - padding[3]; + let x2 = shaped.right * boxScale + padding[1]; + + const collisionPadding = shaped.collisionPadding; + if (collisionPadding) { + x1 -= collisionPadding[0] * boxScale; + y1 -= collisionPadding[1] * boxScale; + x2 += collisionPadding[2] * boxScale; + y2 += collisionPadding[3] * boxScale; + } + + if (rotate) { + // Account for *-rotate in point collision boxes + // See https://github.com/mapbox/mapbox-gl-js/issues/6075 + // Doesn't account for icon-text-fit + + const tl = new Point(x1, y1); + const tr = new Point(x2, y1); + const bl = new Point(x1, y2); + const br = new Point(x2, y2); + + const rotateRadians = rotate * Math.PI / 180; + + tl._rotate(rotateRadians); + tr._rotate(rotateRadians); + bl._rotate(rotateRadians); + br._rotate(rotateRadians); + + // Collision features require an "on-axis" geometry, + // so take the envelope of the rotated geometry + // (may be quite large for wide labels rotated 45 degrees) + x1 = Math.min(tl.x, tr.x, bl.x, br.x); + x2 = Math.max(tl.x, tr.x, bl.x, br.x); + y1 = Math.min(tl.y, tr.y, bl.y, br.y); + y2 = Math.max(tl.y, tr.y, bl.y, br.y); + } + collisionBoxArray.emplaceBack(anchor.x, anchor.y, x1, y1, x2, y2, featureIndex, sourceLayerIndex, bucketIndex); + } + + this.boxEndIndex = collisionBoxArray.length; + } +} diff --git a/web/libraries/maplibre-gl/src/symbol/collision_index.test.ts b/web/libraries/maplibre-gl/src/symbol/collision_index.test.ts new file mode 100644 index 00000000..fd281e66 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/collision_index.test.ts @@ -0,0 +1,18 @@ +import {CollisionIndex} from './collision_index'; +import {mat4} from 'gl-matrix'; + +import {Transform} from '../geo/transform'; + +describe('CollisionIndex', () => { + + test('floating point precision', () => { + const posMatrix = mat4.create(); + const x = 100000.123456, y = 0; + const transform = new Transform(0, 22, 0, 60, true); + transform.resize(200, 200); + + const ci = new CollisionIndex(transform); + expect(ci.projectAndGetPerspectiveRatio(posMatrix, x, y).point.x).toBeCloseTo(10000212.3456, 10); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/symbol/collision_index.ts b/web/libraries/maplibre-gl/src/symbol/collision_index.ts new file mode 100644 index 00000000..e889fc4e --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/collision_index.ts @@ -0,0 +1,401 @@ +import Point from '@mapbox/point-geometry'; +import {clipLine} from './clip_line'; +import {PathInterpolator} from './path_interpolator'; + +import * as intersectionTests from '../util/intersection_tests'; +import {GridIndex} from './grid_index'; +import {mat4, vec4} from 'gl-matrix'; +import ONE_EM from '../symbol/one_em'; + +import * as projection from '../symbol/projection'; + +import type {Transform} from '../geo/transform'; +import type {SingleCollisionBox} from '../data/bucket/symbol_bucket'; +import type { + GlyphOffsetArray, + SymbolLineVertexArray +} from '../data/array_types.g'; +import type {OverlapMode} from '../style/style_layer/overlap_mode'; + +// When a symbol crosses the edge that causes it to be included in +// collision detection, it will cause changes in the symbols around +// it. This constant specifies how many pixels to pad the edge of +// the viewport for collision detection so that the bulk of the changes +// occur offscreen. Making this constant greater increases label +// stability, but it's expensive. +const viewportPadding = 100; + +export type FeatureKey = { + bucketInstanceId: number; + featureIndex: number; + collisionGroupID: number; + overlapMode: OverlapMode; +}; + +/** + * @internal + * A collision index used to prevent symbols from overlapping. It keep tracks of + * where previous symbols have been placed and is used to check if a new + * symbol overlaps with any previously added symbols. + * + * There are two steps to insertion: first placeCollisionBox/Circles checks if + * there's room for a symbol, then insertCollisionBox/Circles actually puts the + * symbol in the index. The two step process allows paired symbols to be inserted + * together even if they overlap. + */ +export class CollisionIndex { + grid: GridIndex; + ignoredGrid: GridIndex; + transform: Transform; + pitchfactor: number; + screenRightBoundary: number; + screenBottomBoundary: number; + gridRightBoundary: number; + gridBottomBoundary: number; + + // With perspectiveRatio the fontsize is calculated for tilted maps (near = bigger, far = smaller). + // The cutoff defines a threshold to no longer render labels near the horizon. + perspectiveRatioCutoff: number; + + constructor( + transform: Transform, + grid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25), + ignoredGrid = new GridIndex(transform.width + 2 * viewportPadding, transform.height + 2 * viewportPadding, 25) + ) { + this.transform = transform; + + this.grid = grid; + this.ignoredGrid = ignoredGrid; + this.pitchfactor = Math.cos(transform._pitch) * transform.cameraToCenterDistance; + + this.screenRightBoundary = transform.width + viewportPadding; + this.screenBottomBoundary = transform.height + viewportPadding; + this.gridRightBoundary = transform.width + 2 * viewportPadding; + this.gridBottomBoundary = transform.height + 2 * viewportPadding; + + this.perspectiveRatioCutoff = 0.6; + } + + placeCollisionBox( + collisionBox: SingleCollisionBox, + overlapMode: OverlapMode, + textPixelRatio: number, + posMatrix: mat4, + collisionGroupPredicate?: (key: FeatureKey) => boolean, + getElevation?: (x: number, y: number) => number + ): { + box: Array; + offscreen: boolean; + } { + const projectedPoint = this.projectAndGetPerspectiveRatio(posMatrix, collisionBox.anchorPointX, collisionBox.anchorPointY, getElevation); + const tileToViewport = textPixelRatio * projectedPoint.perspectiveRatio; + const tlX = collisionBox.x1 * tileToViewport + projectedPoint.point.x; + const tlY = collisionBox.y1 * tileToViewport + projectedPoint.point.y; + const brX = collisionBox.x2 * tileToViewport + projectedPoint.point.x; + const brY = collisionBox.y2 * tileToViewport + projectedPoint.point.y; + + if (!this.isInsideGrid(tlX, tlY, brX, brY) || + (overlapMode !== 'always' && this.grid.hitTest(tlX, tlY, brX, brY, overlapMode, collisionGroupPredicate)) || + projectedPoint.perspectiveRatio < this.perspectiveRatioCutoff) { + return { + box: [], + offscreen: false + }; + } + + return { + box: [tlX, tlY, brX, brY], + offscreen: this.isOffscreen(tlX, tlY, brX, brY) + }; + } + + placeCollisionCircles( + overlapMode: OverlapMode, + symbol: any, + lineVertexArray: SymbolLineVertexArray, + glyphOffsetArray: GlyphOffsetArray, + fontSize: number, + posMatrix: mat4, + labelPlaneMatrix: mat4, + labelToScreenMatrix: mat4, + showCollisionCircles: boolean, + pitchWithMap: boolean, + collisionGroupPredicate: (key: FeatureKey) => boolean, + circlePixelDiameter: number, + textPixelPadding: number, + getElevation: (x: number, y: number) => number + ): { + circles: Array; + offscreen: boolean; + collisionDetected: boolean; + } { + const placedCollisionCircles = []; + + const tileUnitAnchorPoint = new Point(symbol.anchorX, symbol.anchorY); + const screenAnchorPoint = projection.project(tileUnitAnchorPoint, posMatrix, getElevation); + const perspectiveRatio = projection.getPerspectiveRatio(this.transform.cameraToCenterDistance, screenAnchorPoint.signedDistanceFromCamera); + const labelPlaneFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio; + const labelPlaneFontScale = labelPlaneFontSize / ONE_EM; + + const labelPlaneAnchorPoint = projection.project(tileUnitAnchorPoint, labelPlaneMatrix, getElevation).point; + + const projectionCache = {projections: {}, offsets: {}}; + const lineOffsetX = symbol.lineOffsetX * labelPlaneFontScale; + const lineOffsetY = symbol.lineOffsetY * labelPlaneFontScale; + + const firstAndLastGlyph = projection.placeFirstAndLastGlyph( + labelPlaneFontScale, + glyphOffsetArray, + lineOffsetX, + lineOffsetY, + /*flip*/ false, + labelPlaneAnchorPoint, + tileUnitAnchorPoint, + symbol, + lineVertexArray, + labelPlaneMatrix, + projectionCache, + false, + getElevation); + + let collisionDetected = false; + let inGrid = false; + let entirelyOffscreen = true; + + if (firstAndLastGlyph) { + const radius = circlePixelDiameter * 0.5 * perspectiveRatio + textPixelPadding; + const screenPlaneMin = new Point(-viewportPadding, -viewportPadding); + const screenPlaneMax = new Point(this.screenRightBoundary, this.screenBottomBoundary); + const interpolator = new PathInterpolator(); + + // Construct a projected path from projected line vertices. Anchor points are ignored and removed + const first = firstAndLastGlyph.first; + const last = firstAndLastGlyph.last; + + let projectedPath = []; + for (let i = first.path.length - 1; i >= 1; i--) { + projectedPath.push(first.path[i]); + } + for (let i = 1; i < last.path.length; i++) { + projectedPath.push(last.path[i]); + } + + // Tolerate a slightly longer distance than one diameter between two adjacent circles + const circleDist = radius * 2.5; + + // The path might need to be converted into screen space if a pitched map is used as the label space + if (labelToScreenMatrix) { + const screenSpacePath = projectedPath.map(p => projection.project(p, labelToScreenMatrix, getElevation)); + + // Do not try to place collision circles if even of the points is behind the camera. + // This is a plausible scenario with big camera pitch angles + if (screenSpacePath.some(point => point.signedDistanceFromCamera <= 0)) { + projectedPath = []; + } else { + projectedPath = screenSpacePath.map(p => p.point); + } + } + + let segments = []; + + if (projectedPath.length > 0) { + // Quickly check if the path is fully inside or outside of the padded collision region. + // For overlapping paths we'll only create collision circles for the visible segments + const minPoint = projectedPath[0].clone(); + const maxPoint = projectedPath[0].clone(); + + for (let i = 1; i < projectedPath.length; i++) { + minPoint.x = Math.min(minPoint.x, projectedPath[i].x); + minPoint.y = Math.min(minPoint.y, projectedPath[i].y); + maxPoint.x = Math.max(maxPoint.x, projectedPath[i].x); + maxPoint.y = Math.max(maxPoint.y, projectedPath[i].y); + } + + if (minPoint.x >= screenPlaneMin.x && maxPoint.x <= screenPlaneMax.x && + minPoint.y >= screenPlaneMin.y && maxPoint.y <= screenPlaneMax.y) { + // Quad fully visible + segments = [projectedPath]; + } else if (maxPoint.x < screenPlaneMin.x || minPoint.x > screenPlaneMax.x || + maxPoint.y < screenPlaneMin.y || minPoint.y > screenPlaneMax.y) { + // Not visible + segments = []; + } else { + segments = clipLine([projectedPath], screenPlaneMin.x, screenPlaneMin.y, screenPlaneMax.x, screenPlaneMax.y); + } + } + + for (const seg of segments) { + // interpolate positions for collision circles. Add a small padding to both ends of the segment + interpolator.reset(seg, radius * 0.25); + + let numCircles = 0; + + if (interpolator.length <= 0.5 * radius) { + numCircles = 1; + } else { + numCircles = Math.ceil(interpolator.paddedLength / circleDist) + 1; + } + + for (let i = 0; i < numCircles; i++) { + const t = i / Math.max(numCircles - 1, 1); + const circlePosition = interpolator.lerp(t); + + // add viewport padding to the position and perform initial collision check + const centerX = circlePosition.x + viewportPadding; + const centerY = circlePosition.y + viewportPadding; + + placedCollisionCircles.push(centerX, centerY, radius, 0); + + const x1 = centerX - radius; + const y1 = centerY - radius; + const x2 = centerX + radius; + const y2 = centerY + radius; + + entirelyOffscreen = entirelyOffscreen && this.isOffscreen(x1, y1, x2, y2); + inGrid = inGrid || this.isInsideGrid(x1, y1, x2, y2); + + if (overlapMode !== 'always' && this.grid.hitTestCircle(centerX, centerY, radius, overlapMode, collisionGroupPredicate)) { + // Don't early exit if we're showing the debug circles because we still want to calculate + // which circles are in use + collisionDetected = true; + if (!showCollisionCircles) { + return { + circles: [], + offscreen: false, + collisionDetected + }; + } + } + } + } + } + + return { + circles: ((!showCollisionCircles && collisionDetected) || !inGrid || perspectiveRatio < this.perspectiveRatioCutoff) ? [] : placedCollisionCircles, + offscreen: entirelyOffscreen, + collisionDetected + }; + } + + /** + * Because the geometries in the CollisionIndex are an approximation of the shape of + * symbols on the map, we use the CollisionIndex to look up the symbol part of + * `queryRenderedFeatures`. + */ + queryRenderedSymbols(viewportQueryGeometry: Array) { + if (viewportQueryGeometry.length === 0 || (this.grid.keysLength() === 0 && this.ignoredGrid.keysLength() === 0)) { + return {}; + } + + const query = []; + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + for (const point of viewportQueryGeometry) { + const gridPoint = new Point(point.x + viewportPadding, point.y + viewportPadding); + minX = Math.min(minX, gridPoint.x); + minY = Math.min(minY, gridPoint.y); + maxX = Math.max(maxX, gridPoint.x); + maxY = Math.max(maxY, gridPoint.y); + query.push(gridPoint); + } + + const features = this.grid.query(minX, minY, maxX, maxY) + .concat(this.ignoredGrid.query(minX, minY, maxX, maxY)); + + const seenFeatures = {}; + const result = {}; + + for (const feature of features) { + const featureKey = feature.key; + // Skip already seen features. + if (seenFeatures[featureKey.bucketInstanceId] === undefined) { + seenFeatures[featureKey.bucketInstanceId] = {}; + } + if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) { + continue; + } + + // Check if query intersects with the feature box + // "Collision Circles" for line labels are treated as boxes here + // Since there's no actual collision taking place, the circle vs. square + // distinction doesn't matter as much, and box geometry is easier + // to work with. + const bbox = [ + new Point(feature.x1, feature.y1), + new Point(feature.x2, feature.y1), + new Point(feature.x2, feature.y2), + new Point(feature.x1, feature.y2) + ]; + if (!intersectionTests.polygonIntersectsPolygon(query, bbox)) { + continue; + } + + seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true; + if (result[featureKey.bucketInstanceId] === undefined) { + result[featureKey.bucketInstanceId] = []; + } + result[featureKey.bucketInstanceId].push(featureKey.featureIndex); + } + + return result; + } + + insertCollisionBox(collisionBox: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) { + const grid = ignorePlacement ? this.ignoredGrid : this.grid; + + const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode}; + grid.insert(key, collisionBox[0], collisionBox[1], collisionBox[2], collisionBox[3]); + } + + insertCollisionCircles(collisionCircles: Array, overlapMode: OverlapMode, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) { + const grid = ignorePlacement ? this.ignoredGrid : this.grid; + + const key = {bucketInstanceId, featureIndex, collisionGroupID, overlapMode}; + for (let k = 0; k < collisionCircles.length; k += 4) { + grid.insertCircle(key, collisionCircles[k], collisionCircles[k + 1], collisionCircles[k + 2]); + } + } + + projectAndGetPerspectiveRatio(posMatrix: mat4, x: number, y: number, getElevation?: (x: number, y: number) => number) { + let p; + if (getElevation) { // slow because of handle z-index + p = [x, y, getElevation(x, y), 1] as vec4; + vec4.transformMat4(p, p, posMatrix); + } else { // fast because of ignore z-index + p = [x, y, 0, 1] as vec4; + projection.xyTransformMat4(p, p, posMatrix); + } + const a = new Point( + (((p[0] / p[3] + 1) / 2) * this.transform.width) + viewportPadding, + (((-p[1] / p[3] + 1) / 2) * this.transform.height) + viewportPadding + ); + return { + point: a, + // See perspective ratio comment in symbol_sdf.vertex + // We're doing collision detection in viewport space so we need + // to scale down boxes in the distance + perspectiveRatio: 0.5 + 0.5 * (this.transform.cameraToCenterDistance / p[3]) + }; + } + + isOffscreen(x1: number, y1: number, x2: number, y2: number) { + return x2 < viewportPadding || x1 >= this.screenRightBoundary || y2 < viewportPadding || y1 > this.screenBottomBoundary; + } + + isInsideGrid(x1: number, y1: number, x2: number, y2: number) { + return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary; + } + + /* + * Returns a matrix for transforming collision shapes to viewport coordinate space. + * Use this function to render e.g. collision circles on the screen. + * example transformation: clipPos = glCoordMatrix * viewportMatrix * circle_pos + */ + getViewportMatrix() { + const m = mat4.identity([] as any); + mat4.translate(m, m, [-viewportPadding, -viewportPadding, 0.0]); + return m; + } +} diff --git a/web/libraries/maplibre-gl/src/symbol/cross_tile_symbol_index.test.ts b/web/libraries/maplibre-gl/src/symbol/cross_tile_symbol_index.test.ts new file mode 100644 index 00000000..ad07b7a9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/cross_tile_symbol_index.test.ts @@ -0,0 +1,260 @@ +import {CrossTileSymbolIndex, KDBUSH_THRESHHOLD} from './cross_tile_symbol_index'; +import {OverscaledTileID} from '../source/tile_id'; +import {StyleLayer} from '../style/style_layer'; + +const styleLayer = { + id: 'test' +} as StyleLayer; + +const makeSymbolInstance = (x, y, key): any => { + return { + anchorX: x, + anchorY: y, + key + }; +}; + +const makeTile = (tileID, symbolInstances): any => { + const bucket = { + symbolInstances: { + get(i) { return symbolInstances[i]; }, + length: symbolInstances.length + }, + layerIds: ['test'] + }; + return { + tileID, + getBucket: () => bucket, + latestFeatureIndex: {} + }; +}; + +describe('CrossTileSymbolIndex.addLayer', () => { + + test('matches ids', () => { + const index = new CrossTileSymbolIndex(); + + const mainID = new OverscaledTileID(6, 0, 6, 8, 8); + const mainInstances = [ + makeSymbolInstance(1000, 1000, 'Detroit'), + makeSymbolInstance(2000, 2000, 'Toronto') + ]; + const mainTile = makeTile(mainID, mainInstances); + + index.addLayer(styleLayer, [mainTile], 0); + // Assigned new IDs + expect(mainInstances[0].crossTileID).toBe(1); + expect(mainInstances[1].crossTileID).toBe(2); + + const childID = new OverscaledTileID(7, 0, 7, 16, 16); + const childInstances = [ + makeSymbolInstance(2000, 2000, 'Detroit'), + makeSymbolInstance(2000, 2000, 'Windsor'), + makeSymbolInstance(3000, 3000, 'Toronto'), + makeSymbolInstance(4001, 4001, 'Toronto') + ]; + const childTile = makeTile(childID, childInstances); + + index.addLayer(styleLayer, [mainTile, childTile], 0); + // matched parent tile + expect(childInstances[0].crossTileID).toBe(1); + // does not match because of different key + expect(childInstances[1].crossTileID).toBe(3); + // does not match because of different location + expect(childInstances[2].crossTileID).toBe(4); + // matches with a slightly different location + expect(childInstances[3].crossTileID).toBe(2); + + const parentID = new OverscaledTileID(5, 0, 5, 4, 4); + const parentInstances = [ + makeSymbolInstance(500, 500, 'Detroit') + ]; + const parentTile = makeTile(parentID, parentInstances); + + index.addLayer(styleLayer, [mainTile, childTile, parentTile], 0); + // matched child tile + expect(parentInstances[0].crossTileID).toBe(1); + + const grandchildID = new OverscaledTileID(8, 0, 8, 32, 32); + const grandchildInstances = [ + makeSymbolInstance(4000, 4000, 'Detroit'), + makeSymbolInstance(4000, 4000, 'Windsor') + ]; + const grandchildTile = makeTile(grandchildID, grandchildInstances); + + index.addLayer(styleLayer, [mainTile], 0); + index.addLayer(styleLayer, [mainTile, grandchildTile], 0); + // Matches the symbol in `mainBucket` + expect(grandchildInstances[0].crossTileID).toBe(1); + // Does not match the previous value for Windsor because that tile was removed + expect(grandchildInstances[1].crossTileID).toBe(5); + + }); + + test('overwrites ids when re-adding', () => { + const index = new CrossTileSymbolIndex(); + + const mainID = new OverscaledTileID(6, 0, 6, 8, 8); + const mainInstances = [makeSymbolInstance(1000, 1000, 'Detroit')]; + const mainTile = makeTile(mainID, mainInstances); + + const childID = new OverscaledTileID(7, 0, 7, 16, 16); + const childInstances = [makeSymbolInstance(2000, 2000, 'Detroit')]; + const childTile = makeTile(childID, childInstances); + + // assigns a new id + index.addLayer(styleLayer, [mainTile], 0); + expect(mainInstances[0].crossTileID).toBe(1); + + // removes the tile + index.addLayer(styleLayer, [], 0); + + // assigns a new id + index.addLayer(styleLayer, [childTile], 0); + expect(childInstances[0].crossTileID).toBe(2); + + // overwrites the old id to match the already-added tile + index.addLayer(styleLayer, [mainTile, childTile], 0); + expect(mainInstances[0].crossTileID).toBe(2); + expect(childInstances[0].crossTileID).toBe(2); + + }); + + test('does not duplicate ids within one zoom level', () => { + const index = new CrossTileSymbolIndex(); + + const mainID = new OverscaledTileID(6, 0, 6, 8, 8); + const mainInstances = [ + makeSymbolInstance(1000, 1000, ''), // A + makeSymbolInstance(1000, 1000, '') // B + ]; + const mainTile = makeTile(mainID, mainInstances); + + const childID = new OverscaledTileID(7, 0, 7, 16, 16); + const childInstances = [ + makeSymbolInstance(2000, 2000, ''), // A' + makeSymbolInstance(2000, 2000, ''), // B' + makeSymbolInstance(2000, 2000, '') // C' + ]; + const childTile = makeTile(childID, childInstances); + + // assigns new ids + index.addLayer(styleLayer, [mainTile], 0); + expect(mainInstances[0].crossTileID).toBe(1); + expect(mainInstances[1].crossTileID).toBe(2); + + const layerIndex = index.layerIndexes[styleLayer.id]; + expect(Object.keys(layerIndex.usedCrossTileIDs[6])).toEqual(['1', '2']); + + // copies parent ids without duplicate ids in this tile + index.addLayer(styleLayer, [childTile], 0); + expect(childInstances[0].crossTileID).toBe(1); // A' copies from A + expect(childInstances[1].crossTileID).toBe(2); // B' copies from B + expect(childInstances[2].crossTileID).toBe(3); // C' gets new ID + + // Updates per-zoom usedCrossTileIDs + expect(Object.keys(layerIndex.usedCrossTileIDs[6])).toEqual([]); + expect(Object.keys(layerIndex.usedCrossTileIDs[7])).toEqual(['1', '2', '3']); + + }); + + test('does not regenerate ids for same zoom', () => { + const index = new CrossTileSymbolIndex(); + + const tileID = new OverscaledTileID(6, 0, 6, 8, 8); + const firstInstances = [ + makeSymbolInstance(1000, 1000, ''), // A + makeSymbolInstance(1000, 1000, '') // B + ]; + const firstTile = makeTile(tileID, firstInstances); + + const secondInstances = [ + makeSymbolInstance(1000, 1000, ''), // A' + makeSymbolInstance(1000, 1000, ''), // B' + makeSymbolInstance(1000, 1000, ''), // C' + ]; + const secondTile = makeTile(tileID, secondInstances); + + // assigns new ids + index.addLayer(styleLayer, [firstTile], 0); + expect(firstInstances[0].crossTileID).toBe(1); + expect(firstInstances[1].crossTileID).toBe(2); + + const layerIndex = index.layerIndexes[styleLayer.id]; + expect(Object.keys(layerIndex.usedCrossTileIDs[6])).toEqual(['1', '2']); + + // uses same ids when tile gets updated + index.addLayer(styleLayer, [secondTile], 0); + expect(secondInstances[0].crossTileID).toBe(1); // A' copies from A + expect(secondInstances[1].crossTileID).toBe(2); // B' copies from B + expect(secondInstances[2].crossTileID).toBe(3); // C' gets new ID + + expect(Object.keys(layerIndex.usedCrossTileIDs[6])).toEqual(['1', '2', '3']); + + }); + + test('reuses indexes when longitude is wrapped', () => { + const index = new CrossTileSymbolIndex(); + const longitude = 370; + + const tileID = new OverscaledTileID(6, 1, 6, 8, 8); + const firstInstances = [ + makeSymbolInstance(1000, 1000, ''), // A + ]; + const tile = makeTile(tileID, firstInstances); + + index.addLayer(styleLayer, [tile], longitude); + expect(firstInstances[0].crossTileID).toBe(1); // A + + tile.tileID = tileID.wrapped(); + + index.addLayer(styleLayer, [tile], longitude % 360); + expect(firstInstances[0].crossTileID).toBe(1); + + }); + + test('indexes data for findMatches perf', () => { + const index = new CrossTileSymbolIndex(); + + const mainID = new OverscaledTileID(6, 0, 6, 8, 8); + const childID = new OverscaledTileID(7, 0, 7, 16, 16); + + const mainInstances: any[] = []; + const childInstances: any[] = []; + + for (let i = 0; i < KDBUSH_THRESHHOLD + 1; i++) { + mainInstances.push(makeSymbolInstance(0, 0, '')); + childInstances.push(makeSymbolInstance(0, 0, '')); + } + const mainTile = makeTile(mainID, mainInstances); + const childTile = makeTile(childID, childInstances); + index.addLayer(styleLayer, [mainTile], 0); + index.addLayer(styleLayer, [childTile], 0); + + // check that we matched the parent tile + expect(childInstances[0].crossTileID).toBe(1); + + }); +}); + +describe('CrossTileSymbolIndex.pruneUnusedLayers', () => { + const index = new CrossTileSymbolIndex(); + + const tileID = new OverscaledTileID(6, 0, 6, 8, 8); + const instances = [ + makeSymbolInstance(1000, 1000, ''), // A + makeSymbolInstance(1000, 1000, '') // B + ]; + const tile = makeTile(tileID, instances); + + // assigns new ids + index.addLayer(styleLayer, [tile], 0); + expect(instances[0].crossTileID).toBe(1); + expect(instances[1].crossTileID).toBe(2); + expect(index.layerIndexes[styleLayer.id]).toBeTruthy(); + + // remove styleLayer + index.pruneUnusedLayers([]); + expect(index.layerIndexes[styleLayer.id]).toBeFalsy(); + +}); diff --git a/web/libraries/maplibre-gl/src/symbol/cross_tile_symbol_index.ts b/web/libraries/maplibre-gl/src/symbol/cross_tile_symbol_index.ts new file mode 100644 index 00000000..7708b4f8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/cross_tile_symbol_index.ts @@ -0,0 +1,367 @@ +import KDBush from 'kdbush'; +import {EXTENT} from '../data/extent'; + +import {SymbolInstanceArray} from '../data/array_types.g'; + +import type {SymbolInstance} from '../data/array_types.g'; +import type {OverscaledTileID} from '../source/tile_id'; +import type {SymbolBucket} from '../data/bucket/symbol_bucket'; +import type {StyleLayer} from '../style/style_layer'; +import type {Tile} from '../source/tile'; + +/* + The CrossTileSymbolIndex generally works on the assumption that + a conceptual "unique symbol" can be identified by the text of + the label combined with the anchor point. The goal is to assign + these conceptual "unique symbols" a shared crossTileID that can be + used by Placement to keep fading opacity states consistent and to + deduplicate labels. + + The CrossTileSymbolIndex indexes all the current symbol instances and + their crossTileIDs. When a symbol bucket gets added or updated, the + index assigns a crossTileID to each of it's symbol instances by either + matching it with an existing id or assigning a new one. +*/ + +// Round anchor positions to roughly 4 pixel grid +const roundingFactor = 512 / EXTENT / 2; + +export const KDBUSH_THRESHHOLD = 128; + +interface SymbolsByKeyEntry { + index?: KDBush; + positions?: {x: number; y: number}[]; + crossTileIDs: number[]; +} + +class TileLayerIndex { + _symbolsByKey: Record = {}; + + constructor(public tileID: OverscaledTileID, symbolInstances: SymbolInstanceArray, public bucketInstanceId: number) { + // group the symbolInstances by key + const symbolInstancesByKey = new Map(); + for (let i = 0; i < symbolInstances.length; i++) { + const symbolInstance = symbolInstances.get(i); + const key = symbolInstance.key; + const instances = symbolInstancesByKey.get(key); + if (instances) { + // This tile may have multiple symbol instances with the same key + // Store each one along with its coordinates + instances.push(symbolInstance); + } else { + symbolInstancesByKey.set(key, [symbolInstance]); + } + } + + // index the SymbolInstances in this each bucket + for (const [key, symbols] of symbolInstancesByKey) { + const positions = symbols.map(symbolInstance => ({x: Math.floor(symbolInstance.anchorX * roundingFactor), y: Math.floor(symbolInstance.anchorY * roundingFactor)})); + const crossTileIDs = symbols.map(v => v.crossTileID); + const entry: SymbolsByKeyEntry = {positions, crossTileIDs}; + + // once we get too many symbols for a given key, it becomes much faster to index it before queries + if (entry.positions.length > KDBUSH_THRESHHOLD) { + + const index = new KDBush(entry.positions.length, 16, Uint16Array); + for (const {x, y} of entry.positions) index.add(x, y); + index.finish(); + + // clear all references to the original positions data + delete entry.positions; + entry.index = index; + } + + this._symbolsByKey[key] = entry; + } + } + + // Converts the coordinates of the input symbol instance into coordinates that be can compared + // against other symbols in this index. Coordinates are: + // (1) local-tile-based (so after correction we get x,y values relative to our local anchorX/Y) + // (2) converted to the z-scale of this TileLayerIndex + // (3) down-sampled by "roundingFactor" from tile coordinate precision in order to be + // more tolerant of small differences between tiles. + getScaledCoordinates(symbolInstance: SymbolInstance, childTileID: OverscaledTileID): {x: number; y: number} { + const {x: localX, y: localY, z: localZ} = this.tileID.canonical; + const {x, y, z} = childTileID.canonical; + + const zDifference = z - localZ; + const scale = roundingFactor / Math.pow(2, zDifference); + const xWorld = (x * EXTENT + symbolInstance.anchorX) * scale; + const yWorld = (y * EXTENT + symbolInstance.anchorY) * scale; + const xOffset = localX * EXTENT * roundingFactor; + const yOffset = localY * EXTENT * roundingFactor; + const result = { + x: Math.floor(xWorld - xOffset), + y: Math.floor(yWorld - yOffset) + }; + + return result; + } + + findMatches(symbolInstances: SymbolInstanceArray, newTileID: OverscaledTileID, zoomCrossTileIDs: { + [crossTileID: number]: boolean; + }) { + const tolerance = this.tileID.canonical.z < newTileID.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - newTileID.canonical.z); + + for (let i = 0; i < symbolInstances.length; i++) { + const symbolInstance = symbolInstances.get(i); + if (symbolInstance.crossTileID) { + // already has a match, skip + continue; + } + + const entry = this._symbolsByKey[symbolInstance.key]; + if (!entry) { + // No symbol with this key in this bucket + continue; + } + + const scaledSymbolCoord = this.getScaledCoordinates(symbolInstance, newTileID); + + if (entry.index) { + // Return any symbol with the same keys whose coordinates are within 1 + // grid unit. (with a 4px grid, this covers a 12px by 12px area) + const indexes = entry.index.range( + scaledSymbolCoord.x - tolerance, + scaledSymbolCoord.y - tolerance, + scaledSymbolCoord.x + tolerance, + scaledSymbolCoord.y + tolerance).sort(); + + for (const i of indexes) { + const crossTileID = entry.crossTileIDs[i]; + + if (!zoomCrossTileIDs[crossTileID]) { + // Once we've marked ourselves duplicate against this parent symbol, + // don't let any other symbols at the same zoom level duplicate against + // the same parent (see issue #5993) + zoomCrossTileIDs[crossTileID] = true; + symbolInstance.crossTileID = crossTileID; + break; + } + } + } else if (entry.positions) { + for (let i = 0; i < entry.positions.length; i++) { + const thisTileSymbol = entry.positions[i]; + const crossTileID = entry.crossTileIDs[i]; + + // Return any symbol with the same keys whose coordinates are within 1 + // grid unit. (with a 4px grid, this covers a 12px by 12px area) + if (Math.abs(thisTileSymbol.x - scaledSymbolCoord.x) <= tolerance && + Math.abs(thisTileSymbol.y - scaledSymbolCoord.y) <= tolerance && + !zoomCrossTileIDs[crossTileID]) { + // Once we've marked ourselves duplicate against this parent symbol, + // don't let any other symbols at the same zoom level duplicate against + // the same parent (see issue #5993) + zoomCrossTileIDs[crossTileID] = true; + symbolInstance.crossTileID = crossTileID; + break; + } + } + } + } + } + + getCrossTileIDsLists() { + return Object.values(this._symbolsByKey).map(({crossTileIDs}) => crossTileIDs); + } +} + +class CrossTileIDs { + maxCrossTileID: number; + constructor() { + this.maxCrossTileID = 0; + } + generate() { + return ++this.maxCrossTileID; + } +} + +class CrossTileSymbolLayerIndex { + indexes: { + [zoom in string | number]: { + [tileId in string | number]: TileLayerIndex; + }; + }; + usedCrossTileIDs: { + [zoom in string | number]: { + [crossTileID: number]: boolean; + }; + }; + lng: number; + + constructor() { + this.indexes = {}; + this.usedCrossTileIDs = {}; + this.lng = 0; + } + + /* + * Sometimes when a user pans across the antimeridian the longitude value gets wrapped. + * To prevent labels from flashing out and in we adjust the tileID values in the indexes + * so that they match the new wrapped version of the map. + */ + handleWrapJump(lng: number) { + const wrapDelta = Math.round((lng - this.lng) / 360); + if (wrapDelta !== 0) { + for (const zoom in this.indexes) { + const zoomIndexes = this.indexes[zoom]; + const newZoomIndex = {}; + for (const key in zoomIndexes) { + // change the tileID's wrap and add it to a new index + const index = zoomIndexes[key]; + index.tileID = index.tileID.unwrapTo(index.tileID.wrap + wrapDelta); + newZoomIndex[index.tileID.key] = index; + } + this.indexes[zoom] = newZoomIndex; + } + } + this.lng = lng; + } + + addBucket(tileID: OverscaledTileID, bucket: SymbolBucket, crossTileIDs: CrossTileIDs) { + if (this.indexes[tileID.overscaledZ] && + this.indexes[tileID.overscaledZ][tileID.key]) { + if (this.indexes[tileID.overscaledZ][tileID.key].bucketInstanceId === + bucket.bucketInstanceId) { + return false; + } else { + // We're replacing this bucket with an updated version + // Remove the old bucket's "used crossTileIDs" now so that + // the new bucket can claim them. + // The old index entries themselves stick around until + // 'removeStaleBuckets' is called. + this.removeBucketCrossTileIDs(tileID.overscaledZ, + this.indexes[tileID.overscaledZ][tileID.key]); + } + } + + for (let i = 0; i < bucket.symbolInstances.length; i++) { + const symbolInstance = bucket.symbolInstances.get(i); + symbolInstance.crossTileID = 0; + } + + if (!this.usedCrossTileIDs[tileID.overscaledZ]) { + this.usedCrossTileIDs[tileID.overscaledZ] = {}; + } + const zoomCrossTileIDs = this.usedCrossTileIDs[tileID.overscaledZ]; + + for (const zoom in this.indexes) { + const zoomIndexes = this.indexes[zoom]; + if (Number(zoom) > tileID.overscaledZ) { + for (const id in zoomIndexes) { + const childIndex = zoomIndexes[id]; + if (childIndex.tileID.isChildOf(tileID)) { + childIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs); + } + } + } else { + const parentCoord = tileID.scaledTo(Number(zoom)); + const parentIndex = zoomIndexes[parentCoord.key]; + if (parentIndex) { + parentIndex.findMatches(bucket.symbolInstances, tileID, zoomCrossTileIDs); + } + } + } + + for (let i = 0; i < bucket.symbolInstances.length; i++) { + const symbolInstance = bucket.symbolInstances.get(i); + if (!symbolInstance.crossTileID) { + // symbol did not match any known symbol, assign a new id + symbolInstance.crossTileID = crossTileIDs.generate(); + zoomCrossTileIDs[symbolInstance.crossTileID] = true; + } + } + + if (this.indexes[tileID.overscaledZ] === undefined) { + this.indexes[tileID.overscaledZ] = {}; + } + this.indexes[tileID.overscaledZ][tileID.key] = new TileLayerIndex(tileID, bucket.symbolInstances, bucket.bucketInstanceId); + + return true; + } + + removeBucketCrossTileIDs(zoom: string | number, removedBucket: TileLayerIndex) { + for (const crossTileIDs of removedBucket.getCrossTileIDsLists()) { + for (const crossTileID of crossTileIDs) { + delete this.usedCrossTileIDs[zoom][crossTileID]; + } + } + } + + removeStaleBuckets(currentIDs: { + [k in string | number]: boolean; + }) { + let tilesChanged = false; + for (const z in this.indexes) { + const zoomIndexes = this.indexes[z]; + for (const tileKey in zoomIndexes) { + if (!currentIDs[zoomIndexes[tileKey].bucketInstanceId]) { + this.removeBucketCrossTileIDs(z, zoomIndexes[tileKey]); + delete zoomIndexes[tileKey]; + tilesChanged = true; + } + } + } + return tilesChanged; + } +} + +export class CrossTileSymbolIndex { + layerIndexes: {[layerId: string]: CrossTileSymbolLayerIndex}; + crossTileIDs: CrossTileIDs; + maxBucketInstanceId: number; + bucketsInCurrentPlacement: {[_: number]: boolean}; + + constructor() { + this.layerIndexes = {}; + this.crossTileIDs = new CrossTileIDs(); + this.maxBucketInstanceId = 0; + this.bucketsInCurrentPlacement = {}; + } + + addLayer(styleLayer: StyleLayer, tiles: Array, lng: number) { + let layerIndex = this.layerIndexes[styleLayer.id]; + if (layerIndex === undefined) { + layerIndex = this.layerIndexes[styleLayer.id] = new CrossTileSymbolLayerIndex(); + } + + let symbolBucketsChanged = false; + const currentBucketIDs = {}; + + layerIndex.handleWrapJump(lng); + + for (const tile of tiles) { + const symbolBucket = (tile.getBucket(styleLayer) as any as SymbolBucket); + if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0]) + continue; + + if (!symbolBucket.bucketInstanceId) { + symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId; + } + + if (layerIndex.addBucket(tile.tileID, symbolBucket, this.crossTileIDs)) { + symbolBucketsChanged = true; + } + currentBucketIDs[symbolBucket.bucketInstanceId] = true; + } + + if (layerIndex.removeStaleBuckets(currentBucketIDs)) { + symbolBucketsChanged = true; + } + + return symbolBucketsChanged; + } + + pruneUnusedLayers(usedLayers: Array) { + const usedLayerMap = {}; + usedLayers.forEach((usedLayer) => { + usedLayerMap[usedLayer] = true; + }); + for (const layerId in this.layerIndexes) { + if (!usedLayerMap[layerId]) { + delete this.layerIndexes[layerId]; + } + } + } +} diff --git a/web/libraries/maplibre-gl/src/symbol/get_anchors.test.ts b/web/libraries/maplibre-gl/src/symbol/get_anchors.test.ts new file mode 100644 index 00000000..6d3c1ec2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/get_anchors.test.ts @@ -0,0 +1,113 @@ +import Point from '@mapbox/point-geometry'; +import {getAnchors, getCenterAnchor} from './get_anchors'; +import {PositionedIcon, Shaping} from './shaping'; + +const TILE_EXTENT = 4096; + +describe('getAnchors', () => { + const nonContinuedLine = []; + for (let i = 1; i < 11; i++) { + nonContinuedLine.push(new Point(1, i)); + } + + const continuedLine = []; + for (let j = 0; j < 10; j++) { + continuedLine.push(new Point(1, j)); + } + + const smallSpacing = 2; + const bigSpacing = 3; + + const shapedText = {left: -1, right: 1, top: -0.5, bottom: 0.5} as Shaping; + const shapedIcon = {left: -0.5, right: 0.5, top: -0.25, bottom: 0.25} as PositionedIcon; + const labelLength = Math.max( + shapedText ? shapedText.right - shapedText.left : 0, + shapedIcon ? shapedIcon.right - shapedIcon.left : 0); + + const glyphSize = 0.1; + + test('non-continued line with short labels', () => { + const anchors = getAnchors(nonContinuedLine, bigSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); + + expect(anchors).toEqual([ + {x: 1, y: 2, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 5, angle: 1.5707963267948966, segment: 4}, + {x: 1, y: 8, angle: 1.5707963267948966, segment: 7}]); + + expect( + labelLength / 2 + 1 <= anchors[0].y && anchors[0].y < labelLength / 2 + 3 * glyphSize + 1 + ).toBeTruthy(); + + }); + + test('non-continued line with long labels', () => { + const anchors = getAnchors(nonContinuedLine, smallSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); + + expect(anchors).toEqual([ + {x: 1, y: 2, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 5, angle: 1.5707963267948966, segment: 3}, + {x: 1, y: 7, angle: 1.5707963267948966, segment: 6}]); + + }); + + test('continued line with short labels', () => { + const anchors = getAnchors(continuedLine, bigSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); + + expect(anchors).toEqual([ + {x: 1, y: 2, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 5, angle: 1.5707963267948966, segment: 4}, + {x: 1, y: 8, angle: 1.5707963267948966, segment: 7}]); + + }); + + test('continued line with long labels', () => { + const anchors = getAnchors(continuedLine, smallSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); + + expect(anchors).toEqual([ + {x: 1, y: 1, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 4, angle: 1.5707963267948966, segment: 3}, + {x: 1, y: 6, angle: 1.5707963267948966, segment: 6}]); + + }); + + test('overscaled anchors contain all anchors in parent', () => { + const anchors = getAnchors(nonContinuedLine, bigSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); + const childAnchors = getAnchors(nonContinuedLine, bigSpacing / 2, Math.PI, shapedText, shapedIcon, glyphSize, 0.5, 2, TILE_EXTENT); + for (let i = 0; i < anchors.length; i++) { + const anchor = anchors[i]; + let found = false; + for (let k = 0; k < childAnchors.length; k++) { + if (anchor.equals(childAnchors[k])) { + found = true; + break; + } + } + expect(found).toBeTruthy(); + } + }); + + test('use middle point as a fallback position for short non-continued lines', () => { + const line = [new Point(1, 1), new Point(1, 3.1)]; + const anchors = getAnchors(line, 2, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); + expect(anchors).toEqual([ + {x: 1, y: 2, angle: 1.5707963267948966, segment: 0}]); + }); + + test('getCenterAnchor', () => { + const line = [new Point(1, 1), new Point(1, 3.1), new Point(3, 6), new Point(4, 7)]; + const anchor = getCenterAnchor(line, Math.PI, shapedText, shapedIcon, glyphSize, 1); + expect(anchor).toEqual({x: 2, y: 4, angle: 0.9670469933974603, segment: 1}); + }); + + test('getCenterAnchor with center outside tile bounds', () => { + const line = [new Point(-10, -10), new Point(5, 5)]; + const anchor = getCenterAnchor(line, Math.PI, shapedText, shapedIcon, glyphSize, 1); + expect(anchor).toEqual({x: -2, y: -2, angle: 0.7853981633974483, segment: 0}); + }); + + test('getCenterAnchor failing maxAngle test', () => { + const line = [new Point(1, 1), new Point(1, 3), new Point(3, 3)]; + const anchor = getCenterAnchor(line, Math.PI / 4, shapedText, shapedIcon, glyphSize, 1); + expect(anchor).toBeFalsy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/get_anchors.ts b/web/libraries/maplibre-gl/src/symbol/get_anchors.ts new file mode 100644 index 00000000..93ec995c --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/get_anchors.ts @@ -0,0 +1,167 @@ +import {interpolates} from '@maplibre/maplibre-gl-style-spec'; + +import {Anchor} from '../symbol/anchor'; +import {checkMaxAngle} from './check_max_angle'; + +import type Point from '@mapbox/point-geometry'; +import type {Shaping, PositionedIcon} from './shaping'; + +export {getAnchors, getCenterAnchor}; + +function getLineLength(line: Array): number { + let lineLength = 0; + for (let k = 0; k < line.length - 1; k++) { + lineLength += line[k].dist(line[k + 1]); + } + return lineLength; +} + +function getAngleWindowSize( + shapedText: Shaping, + glyphSize: number, + boxScale: number +): number { + return shapedText ? + 3 / 5 * glyphSize * boxScale : + 0; +} + +function getShapedLabelLength(shapedText?: Shaping | null, shapedIcon?: PositionedIcon | null): number { + return Math.max( + shapedText ? shapedText.right - shapedText.left : 0, + shapedIcon ? shapedIcon.right - shapedIcon.left : 0); +} + +function getCenterAnchor(line: Array, + maxAngle: number, + shapedText: Shaping, + shapedIcon: PositionedIcon, + glyphSize: number, + boxScale: number) { + const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale); + const labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale; + + let prevDistance = 0; + const centerDistance = getLineLength(line) / 2; + + for (let i = 0; i < line.length - 1; i++) { + + const a = line[i], + b = line[i + 1]; + + const segmentDistance = a.dist(b); + + if (prevDistance + segmentDistance > centerDistance) { + // The center is on this segment + const t = (centerDistance - prevDistance) / segmentDistance, + x = interpolates.number(a.x, b.x, t), + y = interpolates.number(a.y, b.y, t); + + const anchor = new Anchor(x, y, b.angleTo(a), i); + anchor._round(); + if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) { + return anchor; + } else { + return; + } + } + + prevDistance += segmentDistance; + } +} + +function getAnchors(line: Array, + spacing: number, + maxAngle: number, + shapedText: Shaping, + shapedIcon: PositionedIcon, + glyphSize: number, + boxScale: number, + overscaling: number, + tileExtent: number) { + + // Resample a line to get anchor points for labels and check that each + // potential label passes text-max-angle check and has enough froom to fit + // on the line. + + const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale); + const shapedLabelLength = getShapedLabelLength(shapedText, shapedIcon); + const labelLength = shapedLabelLength * boxScale; + + // Is the line continued from outside the tile boundary? + const isLineContinued = line[0].x === 0 || line[0].x === tileExtent || line[0].y === 0 || line[0].y === tileExtent; + + // Is the label long, relative to the spacing? + // If so, adjust the spacing so there is always a minimum space of `spacing / 4` between label edges. + if (spacing - labelLength < spacing / 4) { + spacing = labelLength + spacing / 4; + } + + // Offset the first anchor by: + // Either half the label length plus a fixed extra offset if the line is not continued + // Or half the spacing if the line is continued. + + // For non-continued lines, add a bit of fixed extra offset to avoid collisions at T intersections. + const fixedExtraOffset = glyphSize * 2; + + const offset = !isLineContinued ? + ((shapedLabelLength / 2 + fixedExtraOffset) * boxScale * overscaling) % spacing : + (spacing / 2 * overscaling) % spacing; + + return resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, false, tileExtent); +} + +function resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, placeAtMiddle, tileExtent) { + + const halfLabelLength = labelLength / 2; + const lineLength = getLineLength(line); + + let distance = 0, + markedDistance = offset - spacing; + + let anchors = []; + + for (let i = 0; i < line.length - 1; i++) { + + const a = line[i], + b = line[i + 1]; + + const segmentDist = a.dist(b), + angle = b.angleTo(a); + + while (markedDistance + spacing < distance + segmentDist) { + markedDistance += spacing; + + const t = (markedDistance - distance) / segmentDist, + x = interpolates.number(a.x, b.x, t), + y = interpolates.number(a.y, b.y, t); + + // Check that the point is within the tile boundaries and that + // the label would fit before the beginning and end of the line + // if placed at this point. + if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent && + markedDistance - halfLabelLength >= 0 && + markedDistance + halfLabelLength <= lineLength) { + const anchor = new Anchor(x, y, angle, i); + anchor._round(); + + if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) { + anchors.push(anchor); + } + } + } + + distance += segmentDist; + } + + if (!placeAtMiddle && !anchors.length && !isLineContinued) { + // The first attempt at finding anchors at which labels can be placed failed. + // Try again, but this time just try placing one anchor at the middle of the line. + // This has the most effect for short lines in overscaled tiles, since the + // initial offset used in overscaled tiles is calculated to align labels with positions in + // parent tiles instead of placing the label as close to the beginning as possible. + anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, true, tileExtent); + } + + return anchors; +} diff --git a/web/libraries/maplibre-gl/src/symbol/grid_index.test.ts b/web/libraries/maplibre-gl/src/symbol/grid_index.test.ts new file mode 100644 index 00000000..442fcf29 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/grid_index.test.ts @@ -0,0 +1,75 @@ +import {GridIndex} from './grid_index'; +import type {GridKey} from './grid_index'; + +describe('GridIndex', () => { + + test('indexes features', () => { + const grid = new GridIndex(100, 100, 10); + grid.insert(0 as GridKey, 4, 10, 6, 30); + grid.insert(1 as GridKey, 4, 10, 30, 12); + grid.insert(2 as GridKey, -10, 30, 5, 35); + + expect(grid.query(4, 10, 5, 11).map(x => x.key).sort()).toEqual([0, 1]); + expect(grid.query(24, 10, 25, 11).map(x => x.key).sort()).toEqual([1]); + expect(grid.query(40, 40, 100, 100).map(x => x.key)).toEqual([]); + expect(grid.query(-6, 0, 3, 100).map(x => x.key)).toEqual([2]); + expect( + grid.query(-Infinity, -Infinity, Infinity, Infinity).map(x => x.key).sort() + ).toEqual([0, 1, 2]); + }); + + test('returns multiple copies of a key if multiple boxes were inserted with the same key', () => { + const grid = new GridIndex(100, 100, 10); + const key = 123 as GridKey; + grid.insert(key, 3, 3, 4, 4); + grid.insert(key, 13, 13, 14, 14); + grid.insert(key, 23, 23, 24, 24); + expect(grid.query(0, 0, 30, 30).map(x => x.key)).toEqual([key, key, key]); + }); + + test('circle-circle intersection', () => { + const grid = new GridIndex(100, 100, 10); + grid.insertCircle(0 as GridKey, 50, 50, 10); + grid.insertCircle(1 as GridKey, 60, 60, 15); + grid.insertCircle(2 as GridKey, -10, 110, 20); + + expect(grid.hitTestCircle(55, 55, 2, 'never')).toBeTruthy(); + expect(grid.hitTestCircle(10, 10, 10, 'never')).toBeFalsy(); + expect(grid.hitTestCircle(0, 100, 10, 'never')).toBeTruthy(); + expect(grid.hitTestCircle(80, 60, 10, 'never')).toBeTruthy(); + }); + + test('circle-rectangle intersection', () => { + const grid = new GridIndex(100, 100, 10); + grid.insertCircle(0 as GridKey, 50, 50, 10); + grid.insertCircle(1 as GridKey, 60, 60, 15); + grid.insertCircle(2 as GridKey, -10, 110, 20); + + expect(grid.query(45, 45, 55, 55).map(x => x.key)).toEqual([0, 1]); + expect(grid.query(0, 0, 30, 30).map(x => x.key)).toEqual([]); + expect(grid.query(0, 80, 20, 100).map(x => x.key)).toEqual([2]); + }); + + test('overlap mode', () => { + const grid = new GridIndex(100, 100, 10); + grid.insert({overlapMode: 'never'}, 10, 10, 20, 20); + grid.insert({overlapMode: 'always'}, 30, 10, 40, 20); + grid.insert({overlapMode: 'cooperative'}, 50, 10, 60, 20); + + // 'never' can't overlap anything + expect(grid.hitTest(15, 15, 25, 25, 'never')).toBeTruthy(); + expect(grid.hitTest(35, 15, 45, 25, 'never')).toBeTruthy(); + expect(grid.hitTest(55, 15, 65, 25, 'never')).toBeTruthy(); + + // 'always' can overlap everything + expect(grid.hitTest(15, 15, 25, 25, 'always')).toBeFalsy(); + expect(grid.hitTest(35, 15, 45, 25, 'always')).toBeFalsy(); + expect(grid.hitTest(55, 15, 65, 25, 'always')).toBeFalsy(); + + // 'cooperative' can overlap 'always' and 'cooperative' + expect(grid.hitTest(15, 15, 25, 25, 'cooperative')).toBeTruthy(); + expect(grid.hitTest(35, 15, 45, 25, 'cooperative')).toBeFalsy(); + expect(grid.hitTest(55, 15, 65, 25, 'cooperative')).toBeFalsy(); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/symbol/grid_index.ts b/web/libraries/maplibre-gl/src/symbol/grid_index.ts new file mode 100644 index 00000000..51e14d95 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/grid_index.ts @@ -0,0 +1,414 @@ +import type {OverlapMode} from '../style/style_layer/overlap_mode'; + +type QueryArgs = { + hitTest: boolean; + overlapMode?: OverlapMode; + circle?: { + x: number; + y: number; + radius: number; + }; + seenUids: { + box: { + [_: number]: boolean; + }; + circle: { + [_: number]: boolean; + }; + }; +}; + +type QueryResult = { + key: T; + x1: number; + y1: number; + x2: number; + y2: number; +}; + +/** + * A key for the grid + */ +export type GridKey = { + overlapMode?: OverlapMode; +} + +function overlapAllowed(overlapA: OverlapMode, overlapB: OverlapMode): boolean { + let allowed = true; + + if (overlapA === 'always') { + // symbol A using 'always' overlap - allowed to overlap anything. + } else if (overlapA === 'never' || overlapB === 'never') { + // symbol A using 'never' overlap - can't overlap anything + // symbol A using 'cooperative' overlap - can overlap 'always' or 'cooperative' symbol; can't overlap 'never' + allowed = false; + } + + return allowed; +} + +/** + * @internal + * GridIndex is a data structure for testing the intersection of + * circles and rectangles in a 2d plane. + * It is optimized for rapid insertion and querying. + * GridIndex splits the plane into a set of "cells" and keeps track + * of which geometries intersect with each cell. At query time, + * full geometry comparisons are only done for items that share + * at least one cell. As long as the geometries are relatively + * uniformly distributed across the plane, this greatly reduces + * the number of comparisons necessary. + */ +export class GridIndex { + circleKeys: Array; + boxKeys: Array; + boxCells: Array>; + circleCells: Array>; + bboxes: Array; + circles: Array; + xCellCount: number; + yCellCount: number; + width: number; + height: number; + xScale: number; + yScale: number; + boxUid: number; + circleUid: number; + + constructor (width: number, height: number, cellSize: number) { + const boxCells = this.boxCells = []; + const circleCells = this.circleCells = []; + + // More cells -> fewer geometries to check per cell, but items tend + // to be split across more cells. + // Sweet spot allows most small items to fit in one cell + this.xCellCount = Math.ceil(width / cellSize); + this.yCellCount = Math.ceil(height / cellSize); + + for (let i = 0; i < this.xCellCount * this.yCellCount; i++) { + boxCells.push([]); + circleCells.push([]); + } + this.circleKeys = []; + this.boxKeys = []; + this.bboxes = []; + this.circles = []; + + this.width = width; + this.height = height; + this.xScale = this.xCellCount / width; + this.yScale = this.yCellCount / height; + this.boxUid = 0; + this.circleUid = 0; + } + + keysLength() { + return this.boxKeys.length + this.circleKeys.length; + } + + insert(key: T, x1: number, y1: number, x2: number, y2: number) { + this._forEachCell(x1, y1, x2, y2, this._insertBoxCell, this.boxUid++); + this.boxKeys.push(key); + this.bboxes.push(x1); + this.bboxes.push(y1); + this.bboxes.push(x2); + this.bboxes.push(y2); + } + + insertCircle(key: T, x: number, y: number, radius: number) { + // Insert circle into grid for all cells in the circumscribing square + // It's more than necessary (by a factor of 4/PI), but fast to insert + this._forEachCell(x - radius, y - radius, x + radius, y + radius, this._insertCircleCell, this.circleUid++); + this.circleKeys.push(key); + this.circles.push(x); + this.circles.push(y); + this.circles.push(radius); + } + + private _insertBoxCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) { + this.boxCells[cellIndex].push(uid); + } + + private _insertCircleCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) { + this.circleCells[cellIndex].push(uid); + } + + private _query(x1: number, y1: number, x2: number, y2: number, hitTest: boolean, overlapMode: OverlapMode, predicate?: (key: T) => boolean): Array> { + if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) { + return []; + } + const result: Array> = []; + if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) { + if (hitTest) { + // Covers the entire grid, so collides with everything + return [{ + key: null, + x1, + y1, + x2, + y2 + }]; + } + for (let boxUid = 0; boxUid < this.boxKeys.length; boxUid++) { + result.push({ + key: this.boxKeys[boxUid], + x1: this.bboxes[boxUid * 4], + y1: this.bboxes[boxUid * 4 + 1], + x2: this.bboxes[boxUid * 4 + 2], + y2: this.bboxes[boxUid * 4 + 3] + }); + } + for (let circleUid = 0; circleUid < this.circleKeys.length; circleUid++) { + const x = this.circles[circleUid * 3]; + const y = this.circles[circleUid * 3 + 1]; + const radius = this.circles[circleUid * 3 + 2]; + result.push({ + key: this.circleKeys[circleUid], + x1: x - radius, + y1: y - radius, + x2: x + radius, + y2: y + radius + }); + } + } else { + const queryArgs: QueryArgs = { + hitTest, + overlapMode, + seenUids: {box: {}, circle: {}} + }; + this._forEachCell(x1, y1, x2, y2, this._queryCell, result, queryArgs, predicate); + } + + return result; + } + + query(x1: number, y1: number, x2: number, y2: number): Array> { + return this._query(x1, y1, x2, y2, false, null); + } + + hitTest(x1: number, y1: number, x2: number, y2: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean { + return this._query(x1, y1, x2, y2, true, overlapMode, predicate).length > 0; + } + + hitTestCircle(x: number, y: number, radius: number, overlapMode: OverlapMode, predicate?: (key: T) => boolean): boolean { + // Insert circle into grid for all cells in the circumscribing square + // It's more than necessary (by a factor of 4/PI), but fast to insert + const x1 = x - radius; + const x2 = x + radius; + const y1 = y - radius; + const y2 = y + radius; + if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) { + return false; + } + + // Box query early exits if the bounding box is larger than the grid, but we don't do + // the equivalent calculation for circle queries because early exit is less likely + // and the calculation is more expensive + const result: boolean[] = []; + const queryArgs: QueryArgs = { + hitTest: true, + overlapMode, + circle: {x, y, radius}, + seenUids: {box: {}, circle: {}} + }; + this._forEachCell(x1, y1, x2, y2, this._queryCellCircle, result, queryArgs, predicate); + return result.length > 0; + } + + private _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array>, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean { + const {seenUids, hitTest, overlapMode} = queryArgs; + const boxCell = this.boxCells[cellIndex]; + + if (boxCell !== null) { + const bboxes = this.bboxes; + for (const boxUid of boxCell) { + if (!seenUids.box[boxUid]) { + seenUids.box[boxUid] = true; + const offset = boxUid * 4; + const key = this.boxKeys[boxUid]; + + if ((x1 <= bboxes[offset + 2]) && + (y1 <= bboxes[offset + 3]) && + (x2 >= bboxes[offset + 0]) && + (y2 >= bboxes[offset + 1]) && + (!predicate || predicate(key))) { + if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) { + result.push({ + key, + x1: bboxes[offset], + y1: bboxes[offset + 1], + x2: bboxes[offset + 2], + y2: bboxes[offset + 3] + }); + if (hitTest) { + // true return value stops the query after first match + return true; + } + } + } + } + } + } + const circleCell = this.circleCells[cellIndex]; + if (circleCell !== null) { + const circles = this.circles; + for (const circleUid of circleCell) { + if (!seenUids.circle[circleUid]) { + seenUids.circle[circleUid] = true; + const offset = circleUid * 3; + const key = this.circleKeys[circleUid]; + + if (this._circleAndRectCollide( + circles[offset], + circles[offset + 1], + circles[offset + 2], + x1, + y1, + x2, + y2) && + (!predicate || predicate(key))) { + if (!hitTest || !overlapAllowed(overlapMode, key.overlapMode)) { + const x = circles[offset]; + const y = circles[offset + 1]; + const radius = circles[offset + 2]; + result.push({ + key, + x1: x - radius, + y1: y - radius, + x2: x + radius, + y2: y + radius + }); + if (hitTest) { + // true return value stops the query after first match + return true; + } + } + } + } + } + } + + // false return to continue query + return false; + } + + private _queryCellCircle(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: Array, queryArgs: QueryArgs, predicate?: (key: T) => boolean): boolean { + const {circle, seenUids, overlapMode} = queryArgs; + const boxCell = this.boxCells[cellIndex]; + + if (boxCell !== null) { + const bboxes = this.bboxes; + for (const boxUid of boxCell) { + if (!seenUids.box[boxUid]) { + seenUids.box[boxUid] = true; + const offset = boxUid * 4; + const key = this.boxKeys[boxUid]; + if (this._circleAndRectCollide( + circle.x, + circle.y, + circle.radius, + bboxes[offset + 0], + bboxes[offset + 1], + bboxes[offset + 2], + bboxes[offset + 3]) && + (!predicate || predicate(key)) && + !overlapAllowed(overlapMode, key.overlapMode)) { + result.push(true); + return true; + } + } + } + } + + const circleCell = this.circleCells[cellIndex]; + if (circleCell !== null) { + const circles = this.circles; + for (const circleUid of circleCell) { + if (!seenUids.circle[circleUid]) { + seenUids.circle[circleUid] = true; + const offset = circleUid * 3; + const key = this.circleKeys[circleUid]; + if (this._circlesCollide( + circles[offset], + circles[offset + 1], + circles[offset + 2], + circle.x, + circle.y, + circle.radius) && + (!predicate || predicate(key)) && + !overlapAllowed(overlapMode, key.overlapMode)) { + result.push(true); + return true; + } + } + } + } + } + + private _forEachCell( + x1: number, + y1: number, + x2: number, + y2: number, + fn: (x1: number, y1: number, x2: number, y2: number, cellIndex: number, arg1: TArg, arg2?: QueryArgs, predicate?: (key: T) => boolean) => boolean | void, + arg1: TArg, + arg2?: QueryArgs, + predicate?: (key: T) => boolean) { + const cx1 = this._convertToXCellCoord(x1); + const cy1 = this._convertToYCellCoord(y1); + const cx2 = this._convertToXCellCoord(x2); + const cy2 = this._convertToYCellCoord(y2); + + for (let x = cx1; x <= cx2; x++) { + for (let y = cy1; y <= cy2; y++) { + const cellIndex = this.xCellCount * y + x; + if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) return; + } + } + } + + private _convertToXCellCoord(x: number) { + return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale))); + } + + private _convertToYCellCoord(y: number) { + return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale))); + } + + private _circlesCollide(x1: number, y1: number, r1: number, x2: number, y2: number, r2: number): boolean { + const dx = x2 - x1; + const dy = y2 - y1; + const bothRadii = r1 + r2; + return (bothRadii * bothRadii) > (dx * dx + dy * dy); + } + + private _circleAndRectCollide( + circleX: number, + circleY: number, + radius: number, + x1: number, + y1: number, + x2: number, + y2: number + ): boolean { + const halfRectWidth = (x2 - x1) / 2; + const distX = Math.abs(circleX - (x1 + halfRectWidth)); + if (distX > (halfRectWidth + radius)) { + return false; + } + + const halfRectHeight = (y2 - y1) / 2; + const distY = Math.abs(circleY - (y1 + halfRectHeight)); + if (distY > (halfRectHeight + radius)) { + return false; + } + + if (distX <= halfRectWidth || distY <= halfRectHeight) { + return true; + } + + const dx = distX - halfRectWidth; + const dy = distY - halfRectHeight; + return (dx * dx + dy * dy <= (radius * radius)); + } +} diff --git a/web/libraries/maplibre-gl/src/symbol/merge_lines.test.ts b/web/libraries/maplibre-gl/src/symbol/merge_lines.test.ts new file mode 100644 index 00000000..d4a51abb --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/merge_lines.test.ts @@ -0,0 +1,30 @@ +import {mergeLines} from './merge_lines'; +import Point from '@mapbox/point-geometry'; + +function makeFeatures(lines) { + const features = []; + for (const line of lines) { + const points = []; + for (let j = 1; j < line.length; j++) { + points.push(new Point(line[j], 0)); + } + features.push({text: line[0], geometry: [points]}); + } + return features; +} + +describe('mergeLines', () => { + test('mergeLines merges lines with the same text', () => { + expect( + mergeLines(makeFeatures([['a', 0, 1, 2], ['b', 4, 5, 6], ['a', 8, 9], ['a', 2, 3, 4], ['a', 6, 7, 8], ['a', 5, 6]])) + ).toEqual(makeFeatures([['a', 0, 1, 2, 3, 4], ['b', 4, 5, 6], ['a', 5, 6, 7, 8, 9]])); + }); + + test('mergeLines handles merge from both ends', () => { + expect(mergeLines(makeFeatures([['a', 0, 1, 2], ['a', 4, 5, 6], ['a', 2, 3, 4]]))).toEqual(makeFeatures([['a', 0, 1, 2, 3, 4, 5, 6]])); + }); + + test('mergeLines handles circular lines', () => { + expect(mergeLines(makeFeatures([['a', 0, 1, 2], ['a', 2, 3, 4], ['a', 4, 0]]))).toEqual(makeFeatures([['a', 0, 1, 2, 3, 4, 0]])); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/merge_lines.ts b/web/libraries/maplibre-gl/src/symbol/merge_lines.ts new file mode 100644 index 00000000..b12a3be6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/merge_lines.ts @@ -0,0 +1,80 @@ +import type {SymbolFeature} from '../data/bucket/symbol_bucket'; + +export function mergeLines(features: Array): Array { + const leftIndex: {[_: string]: number} = {}; + const rightIndex: {[_: string]: number} = {}; + const mergedFeatures = []; + let mergedIndex = 0; + + function add(k) { + mergedFeatures.push(features[k]); + mergedIndex++; + } + + function mergeFromRight(leftKey: string, rightKey: string, geom) { + const i = rightIndex[leftKey]; + delete rightIndex[leftKey]; + rightIndex[rightKey] = i; + + mergedFeatures[i].geometry[0].pop(); + mergedFeatures[i].geometry[0] = mergedFeatures[i].geometry[0].concat(geom[0]); + return i; + } + + function mergeFromLeft(leftKey: string, rightKey: string, geom) { + const i = leftIndex[rightKey]; + delete leftIndex[rightKey]; + leftIndex[leftKey] = i; + + mergedFeatures[i].geometry[0].shift(); + mergedFeatures[i].geometry[0] = geom[0].concat(mergedFeatures[i].geometry[0]); + return i; + } + + function getKey(text, geom, onRight?) { + const point = onRight ? geom[0][geom[0].length - 1] : geom[0][0]; + return `${text}:${point.x}:${point.y}`; + } + + for (let k = 0; k < features.length; k++) { + const feature = features[k]; + const geom = feature.geometry; + const text = feature.text ? feature.text.toString() : null; + + if (!text) { + add(k); + continue; + } + + const leftKey = getKey(text, geom), + rightKey = getKey(text, geom, true); + + if ((leftKey in rightIndex) && (rightKey in leftIndex) && (rightIndex[leftKey] !== leftIndex[rightKey])) { + // found lines with the same text adjacent to both ends of the current line, merge all three + const j = mergeFromLeft(leftKey, rightKey, geom); + const i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry); + + delete leftIndex[leftKey]; + delete rightIndex[rightKey]; + + rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i; + mergedFeatures[j].geometry = null; + + } else if (leftKey in rightIndex) { + // found mergeable line adjacent to the start of the current line, merge + mergeFromRight(leftKey, rightKey, geom); + + } else if (rightKey in leftIndex) { + // found mergeable line adjacent to the end of the current line, merge + mergeFromLeft(leftKey, rightKey, geom); + + } else { + // no adjacent lines, add as a new item + add(k); + leftIndex[leftKey] = mergedIndex - 1; + rightIndex[rightKey] = mergedIndex - 1; + } + } + + return mergedFeatures.filter((f) => f.geometry); +} diff --git a/web/libraries/maplibre-gl/src/symbol/one_em.ts b/web/libraries/maplibre-gl/src/symbol/one_em.ts new file mode 100644 index 00000000..d66d5e83 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/one_em.ts @@ -0,0 +1,3 @@ +// ONE_EM constant used to go between "em" units used in style spec and "points" used internally for layout + +export default 24; diff --git a/web/libraries/maplibre-gl/src/symbol/opacity_state.ts b/web/libraries/maplibre-gl/src/symbol/opacity_state.ts new file mode 100644 index 00000000..cebc209c --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/opacity_state.ts @@ -0,0 +1,23 @@ +import {register} from '../util/web_worker_transfer'; + +export class OpacityState { + opacity: number; + targetOpacity: number; + time: number; + + constructor() { + this.opacity = 0; + this.targetOpacity = 0; + this.time = 0; + } + + clone() { + const clone = new OpacityState(); + clone.opacity = this.opacity; + clone.targetOpacity = this.targetOpacity; + clone.time = this.time; + return clone; + } +} + +register('OpacityState', OpacityState); diff --git a/web/libraries/maplibre-gl/src/symbol/path_interpolator.test.ts b/web/libraries/maplibre-gl/src/symbol/path_interpolator.test.ts new file mode 100644 index 00000000..52251317 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/path_interpolator.test.ts @@ -0,0 +1,134 @@ +import Point from '@mapbox/point-geometry'; +import {PathInterpolator} from './path_interpolator'; + +describe('PathInterpolator', () => { + + const pointEquals = (p0, p1) => { + const e = 0.000001; + return Math.abs(p0.x - p1.x) < e && Math.abs(p0.y - p1.y) < e; + }; + + test('Interpolate single segment path', () => { + const line = [ + new Point(0, 0), + new Point(10, 0) + ]; + + const interpolator = new PathInterpolator(line); + + expect(interpolator.lerp(0.0)).toEqual(line[0]); + expect(interpolator.lerp(0.5)).toEqual(new Point(5, 0)); + expect(interpolator.lerp(1.0)).toEqual(line[1]); + }); + + test('t < 0', () => { + const line = [ + new Point(0, 0), + new Point(10, 0) + ]; + + const interpolator = new PathInterpolator(line); + expect(interpolator.lerp(-100.0)).toEqual(line[0]); + }); + + test('t > 0', () => { + const line = [ + new Point(0, 0), + new Point(10, 0) + ]; + + const interpolator = new PathInterpolator(line); + expect(interpolator.lerp(100.0)).toEqual(line[1]); + }); + + test('Interpolate multi-segment path', () => { + const line = [ + new Point(-3, 3), + new Point(-1, 3), + new Point(-1, -2), + new Point(2, -2), + new Point(2, 1), + new Point(-3, 1) + ]; + + const interpolator = new PathInterpolator(line); + expect(pointEquals(interpolator.lerp(1.0), new Point(-3, 1))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.95), new Point(-2.1, 1))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.5), new Point(1, -2))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.25), new Point(-1, 0.5))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.1), new Point(-1.2, 3))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.0), new Point(-3, 3))).toBeTruthy(); + }); + + test('Small padding', () => { + const line = [ + new Point(-4, 1), + new Point(4, 1) + ]; + + const padding = 0.5; + const interpolator = new PathInterpolator(line, padding); + + expect(pointEquals(interpolator.lerp(0.0), new Point(-3.5, 1))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.25), new Point(-1.75, 1))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.5), new Point(0, 1))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(1.0), new Point(3.5, 1))).toBeTruthy(); + }); + + test('Padding cannot be larger than the length / 2', () => { + const line = [ + new Point(-3, 0), + new Point(3, 0) + ]; + + const padding = 10.0; + const interpolator = new PathInterpolator(line, padding); + + expect(pointEquals(interpolator.lerp(0.0), new Point(0, 0))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.4), new Point(0, 0))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(1.0), new Point(0, 0))).toBeTruthy(); + }); + + test('Single point path', () => { + const interpolator = new PathInterpolator([new Point(0, 0)]); + expect(pointEquals(interpolator.lerp(0), new Point(0, 0))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(1.0), new Point(0, 0))).toBeTruthy(); + }); + + test('Interpolator instance can be reused by calling reset()', () => { + const line0 = [ + new Point(0, 0), + new Point(10, 0) + ]; + + const line1 = [ + new Point(-10, 10), + new Point(10, -10) + ]; + + const interpolator = new PathInterpolator(line0); + + expect(interpolator.lerp(0.0)).toEqual(line0[0]); + expect(interpolator.lerp(0.5)).toEqual(new Point(5, 0)); + expect(interpolator.lerp(1.0)).toEqual(line0[1]); + + interpolator.reset(line1); + expect(pointEquals(interpolator.lerp(0.0), line1[0])).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.5), new Point(0, 0))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(1.0), line1[1])).toBeTruthy(); + }); + + test('Path with zero length segment', () => { + const line = [ + new Point(-1, 0), + new Point(1, 0), + new Point(1, 0) + ]; + + const interpolator = new PathInterpolator(line); + expect(pointEquals(interpolator.lerp(0), line[0])).toBeTruthy(); + expect(pointEquals(interpolator.lerp(0.5), new Point(0, 0))).toBeTruthy(); + expect(pointEquals(interpolator.lerp(1), line[1])).toBeTruthy(); + expect(pointEquals(interpolator.lerp(1), line[2])).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/symbol/path_interpolator.ts b/web/libraries/maplibre-gl/src/symbol/path_interpolator.ts new file mode 100644 index 00000000..bff4b237 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/path_interpolator.ts @@ -0,0 +1,55 @@ +import {clamp} from '../util/util'; +import Point from '@mapbox/point-geometry'; + +export class PathInterpolator { + points: Array; + length: number; + paddedLength: number; + padding: number; + _distances: Array; + + constructor(points_?: Array | null, padding_?: number | null) { + this.reset(points_, padding_); + } + + reset(points_?: Array | null, padding_?: number | null) { + this.points = points_ || []; + + // Compute cumulative distance from first point to every other point in the segment. + // Last entry in the array is total length of the path + this._distances = [0.0]; + + for (let i = 1; i < this.points.length; i++) { + this._distances[i] = this._distances[i - 1] + this.points[i].dist(this.points[i - 1]); + } + + this.length = this._distances[this._distances.length - 1]; + this.padding = Math.min(padding_ || 0, this.length * 0.5); + this.paddedLength = this.length - this.padding * 2.0; + } + + lerp(t: number): Point { + if (this.points.length === 1) { + return this.points[0]; + } + + t = clamp(t, 0, 1); + + // Find the correct segment [p0, p1] where p0 <= x < p1 + let currentIndex = 1; + let distOfCurrentIdx = this._distances[currentIndex]; + const distToTarget = t * this.paddedLength + this.padding; + + while (distOfCurrentIdx < distToTarget && currentIndex < this._distances.length) { + distOfCurrentIdx = this._distances[++currentIndex]; + } + + // Interpolate between the two points of the segment + const idxOfPrevPoint = currentIndex - 1; + const distOfPrevIdx = this._distances[idxOfPrevPoint]; + const segmentLength = distOfCurrentIdx - distOfPrevIdx; + const segmentT = segmentLength > 0 ? (distToTarget - distOfPrevIdx) / segmentLength : 0; + + return this.points[idxOfPrevPoint].mult(1.0 - segmentT).add(this.points[currentIndex].mult(segmentT)); + } +} diff --git a/web/libraries/maplibre-gl/src/symbol/placement.ts b/web/libraries/maplibre-gl/src/symbol/placement.ts new file mode 100644 index 00000000..316a6553 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/placement.ts @@ -0,0 +1,1238 @@ +import {CollisionIndex} from './collision_index'; +import type {FeatureKey} from './collision_index'; +import {EXTENT} from '../data/extent'; +import * as symbolSize from './symbol_size'; +import * as projection from './projection'; +import {getAnchorJustification} from './symbol_layout'; +import {getAnchorAlignment, WritingMode} from './shaping'; +import {mat4} from 'gl-matrix'; +import {pixelsToTileUnits} from '../source/pixels_to_tile_units'; +import Point from '@mapbox/point-geometry'; +import type {Transform} from '../geo/transform'; +import type {StyleLayer} from '../style/style_layer'; +import {PossiblyEvaluated} from '../style/properties'; +import type {SymbolLayoutProps, SymbolLayoutPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties.g'; +import {getOverlapMode, OverlapMode} from '../style/style_layer/overlap_mode'; + +import type {Tile} from '../source/tile'; +import {SymbolBucket, CollisionArrays, SingleCollisionBox} from '../data/bucket/symbol_bucket'; + +import type {CollisionBoxArray, CollisionVertexArray, SymbolInstance, TextAnchorOffset} from '../data/array_types.g'; +import type {FeatureIndex} from '../data/feature_index'; +import type {OverscaledTileID} from '../source/tile_id'; +import {Terrain} from '../render/terrain'; +import {warnOnce} from '../util/util'; +import {TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor'; + +class OpacityState { + opacity: number; + placed: boolean; + constructor(prevState: OpacityState, increment: number, placed: boolean, skipFade?: boolean | null) { + if (prevState) { + this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment))); + } else { + this.opacity = (skipFade && placed) ? 1 : 0; + } + this.placed = placed; + } + isHidden() { + return this.opacity === 0 && !this.placed; + } +} + +class JointOpacityState { + text: OpacityState; + icon: OpacityState; + constructor(prevState: JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null) { + this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade); + this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade); + } + isHidden() { + return this.text.isHidden() && this.icon.isHidden(); + } +} + +class JointPlacement { + text: boolean; + icon: boolean; + // skipFade = outside viewport, but within CollisionIndex::viewportPadding px of the edge + // Because these symbols aren't onscreen yet, we can skip the "fade in" animation, + // and if a subsequent viewport change brings them into view, they'll be fully + // visible right away. + skipFade: boolean; + constructor(text: boolean, icon: boolean, skipFade: boolean) { + this.text = text; + this.icon = icon; + this.skipFade = skipFade; + } +} + +class CollisionCircleArray { + // Stores collision circles and placement matrices of a bucket for debug rendering. + invProjMatrix: mat4; + viewportMatrix: mat4; + circles: Array; + + constructor() { + this.invProjMatrix = mat4.create(); + this.viewportMatrix = mat4.create(); + this.circles = []; + } +} + +export class RetainedQueryData { + bucketInstanceId: number; + featureIndex: FeatureIndex; + sourceLayerIndex: number; + bucketIndex: number; + tileID: OverscaledTileID; + featureSortOrder: Array; + constructor(bucketInstanceId: number, + featureIndex: FeatureIndex, + sourceLayerIndex: number, + bucketIndex: number, + tileID: OverscaledTileID) { + this.bucketInstanceId = bucketInstanceId; + this.featureIndex = featureIndex; + this.sourceLayerIndex = sourceLayerIndex; + this.bucketIndex = bucketIndex; + this.tileID = tileID; + } +} + +type CollisionGroup = { + ID: number; + predicate?: (key: FeatureKey) => boolean; +}; + +class CollisionGroups { + collisionGroups: {[groupName: string]: CollisionGroup}; + maxGroupID: number; + crossSourceCollisions: boolean; + + constructor(crossSourceCollisions: boolean) { + this.crossSourceCollisions = crossSourceCollisions; + this.maxGroupID = 0; + this.collisionGroups = {}; + } + + get(sourceID: string) { + // The predicate/groupID mechanism allows for arbitrary grouping, + // but the current interface defines one source == one group when + // crossSourceCollisions == true. + if (!this.crossSourceCollisions) { + if (!this.collisionGroups[sourceID]) { + const nextGroupID = ++this.maxGroupID; + this.collisionGroups[sourceID] = { + ID: nextGroupID, + predicate: (key) => { + return key.collisionGroupID === nextGroupID; + } + }; + } + return this.collisionGroups[sourceID]; + } else { + return {ID: 0, predicate: null}; + } + } +} + +function calculateVariableLayoutShift( + anchor: TextAnchor, + width: number, + height: number, + textOffset: [number, number], + textBoxScale: number +): Point { + const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor); + const shiftX = -(horizontalAlign - 0.5) * width; + const shiftY = -(verticalAlign - 0.5) * height; + return new Point( + shiftX + textOffset[0] * textBoxScale, + shiftY + textOffset[1] * textBoxScale + ); +} + +function shiftVariableCollisionBox(collisionBox: SingleCollisionBox, + shiftX: number, shiftY: number, + rotateWithMap: boolean, pitchWithMap: boolean, + angle: number) { + const {x1, x2, y1, y2, anchorPointX, anchorPointY} = collisionBox; + const rotatedOffset = new Point(shiftX, shiftY); + if (rotateWithMap) { + rotatedOffset._rotate(pitchWithMap ? angle : -angle); + } + return { + x1: x1 + rotatedOffset.x, + y1: y1 + rotatedOffset.y, + x2: x2 + rotatedOffset.x, + y2: y2 + rotatedOffset.y, + // symbol anchor point stays the same regardless of text-anchor + anchorPointX, + anchorPointY + }; +} + +export type VariableOffset = { + textOffset: [number, number]; + width: number; + height: number; + anchor: TextAnchor; + textBoxScale: number; + prevAnchor?: TextAnchor; +}; + +type TileLayerParameters = { + bucket: SymbolBucket; + layout: PossiblyEvaluated; + posMatrix: mat4; + textLabelPlaneMatrix: mat4; + labelToScreenMatrix: mat4; + scale: number; + textPixelRatio: number; + holdingForFade: boolean; + collisionBoxArray: CollisionBoxArray; + partiallyEvaluatedTextSize: { + uSize: number; + uSizeT: number; + }; + collisionGroup: CollisionGroup; +}; + +export type BucketPart = { + sortKey?: number | void; + symbolInstanceStart: number; + symbolInstanceEnd: number; + parameters: TileLayerParameters; +}; + +export type CrossTileID = string | number; + +export class Placement { + transform: Transform; + terrain: Terrain; + collisionIndex: CollisionIndex; + placements: { + [_ in CrossTileID]: JointPlacement; + }; + opacities: { + [_ in CrossTileID]: JointOpacityState; + }; + variableOffsets: { + [_ in CrossTileID]: VariableOffset; + }; + placedOrientations: { + [_ in CrossTileID]: number; + }; + commitTime: number; + prevZoomAdjustment: number; + lastPlacementChangeTime: number; + stale: boolean; + fadeDuration: number; + retainedQueryData: { + [_: number]: RetainedQueryData; + }; + collisionGroups: CollisionGroups; + prevPlacement: Placement; + zoomAtLastRecencyCheck: number; + collisionCircleArrays: { + [k in any]: CollisionCircleArray; + }; + + constructor(transform: Transform, terrain: Terrain, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement) { + this.transform = transform.clone(); + this.terrain = terrain; + this.collisionIndex = new CollisionIndex(this.transform); + this.placements = {}; + this.opacities = {}; + this.variableOffsets = {}; + this.stale = false; + this.commitTime = 0; + this.fadeDuration = fadeDuration; + this.retainedQueryData = {}; + this.collisionGroups = new CollisionGroups(crossSourceCollisions); + this.collisionCircleArrays = {}; + + this.prevPlacement = prevPlacement; + if (prevPlacement) { + prevPlacement.prevPlacement = undefined; // Only hold on to one placement back + } + + this.placedOrientations = {}; + } + + getBucketParts(results: Array, styleLayer: StyleLayer, tile: Tile, sortAcrossTiles: boolean) { + const symbolBucket = (tile.getBucket(styleLayer) as SymbolBucket); + const bucketFeatureIndex = tile.latestFeatureIndex; + if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0]) + return; + + const collisionBoxArray = tile.collisionBoxArray; + + const layout = symbolBucket.layers[0].layout; + + const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ); + const textPixelRatio = tile.tileSize / EXTENT; + + const posMatrix = this.transform.calculatePosMatrix(tile.tileID.toUnwrapped()); + + const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; + const pixelsToTiles = pixelsToTileUnits(tile, 1, this.transform.zoom); + + const textLabelPlaneMatrix = projection.getLabelPlaneMatrix(posMatrix, + pitchWithMap, + rotateWithMap, + this.transform, + pixelsToTiles); + + let labelToScreenMatrix = null; + + if (pitchWithMap) { + const glMatrix = projection.getGlCoordMatrix( + posMatrix, + pitchWithMap, + rotateWithMap, + this.transform, + pixelsToTiles); + + labelToScreenMatrix = mat4.multiply([] as any, this.transform.labelPlaneMatrix, glMatrix); + } + + // As long as this placement lives, we have to hold onto this bucket's + // matching FeatureIndex/data for querying purposes + this.retainedQueryData[symbolBucket.bucketInstanceId] = new RetainedQueryData( + symbolBucket.bucketInstanceId, + bucketFeatureIndex, + symbolBucket.sourceLayerIndex, + symbolBucket.index, + tile.tileID + ); + + const parameters = { + bucket: symbolBucket, + layout, + posMatrix, + textLabelPlaneMatrix, + labelToScreenMatrix, + scale, + textPixelRatio, + holdingForFade: tile.holdingForFade(), + collisionBoxArray, + partiallyEvaluatedTextSize: symbolSize.evaluateSizeForZoom(symbolBucket.textSizeData, this.transform.zoom), + collisionGroup: this.collisionGroups.get(symbolBucket.sourceID) + }; + + if (sortAcrossTiles) { + for (const range of symbolBucket.sortKeyRanges) { + const {sortKey, symbolInstanceStart, symbolInstanceEnd} = range; + results.push({sortKey, symbolInstanceStart, symbolInstanceEnd, parameters}); + } + } else { + results.push({ + symbolInstanceStart: 0, + symbolInstanceEnd: symbolBucket.symbolInstances.length, + parameters + }); + } + } + + attemptAnchorPlacement( + textAnchorOffset: TextAnchorOffset, + textBox: SingleCollisionBox, + width: number, + height: number, + textBoxScale: number, + rotateWithMap: boolean, + pitchWithMap: boolean, + textPixelRatio: number, + posMatrix: mat4, + collisionGroup: CollisionGroup, + textOverlapMode: OverlapMode, + symbolInstance: SymbolInstance, + bucket: SymbolBucket, + orientation: number, + iconBox?: SingleCollisionBox | null, + getElevation?: (x: number, y: number) => number + ): { + shift: Point; + placedGlyphBoxes: { + box: Array; + offscreen: boolean; + }; + } { + + const anchor = TextAnchorEnum[textAnchorOffset.textAnchor] as TextAnchor; + const textOffset = [textAnchorOffset.textOffset0, textAnchorOffset.textOffset1] as [number, number]; + const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale); + + const placedGlyphBoxes = this.collisionIndex.placeCollisionBox( + shiftVariableCollisionBox( + textBox, shift.x, shift.y, + rotateWithMap, pitchWithMap, this.transform.angle), + textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + + if (iconBox) { + const placedIconBoxes = this.collisionIndex.placeCollisionBox( + shiftVariableCollisionBox( + iconBox, shift.x, shift.y, + rotateWithMap, pitchWithMap, this.transform.angle), + textOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + if (placedIconBoxes.box.length === 0) return; + } + + if (placedGlyphBoxes.box.length > 0) { + let prevAnchor; + // If this label was placed in the previous placement, record the anchor position + // to allow us to animate the transition + if (this.prevPlacement && + this.prevPlacement.variableOffsets[symbolInstance.crossTileID] && + this.prevPlacement.placements[symbolInstance.crossTileID] && + this.prevPlacement.placements[symbolInstance.crossTileID].text) { + prevAnchor = this.prevPlacement.variableOffsets[symbolInstance.crossTileID].anchor; + } + if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\'t be 0'); + this.variableOffsets[symbolInstance.crossTileID] = { + textOffset, + width, + height, + anchor, + textBoxScale, + prevAnchor + }; + this.markUsedJustification(bucket, anchor, symbolInstance, orientation); + + if (bucket.allowVerticalPlacement) { + this.markUsedOrientation(bucket, orientation, symbolInstance); + this.placedOrientations[symbolInstance.crossTileID] = orientation; + } + + return {shift, placedGlyphBoxes}; + } + } + + placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: { + [k in string | number]: boolean; + }, showCollisionBoxes: boolean) { + + const { + bucket, + layout, + posMatrix, + textLabelPlaneMatrix, + labelToScreenMatrix, + textPixelRatio, + holdingForFade, + collisionBoxArray, + partiallyEvaluatedTextSize, + collisionGroup + } = bucketPart.parameters; + + const textOptional = layout.get('text-optional'); + const iconOptional = layout.get('icon-optional'); + const textOverlapMode = getOverlapMode(layout, 'text-overlap', 'text-allow-overlap'); + const textAlwaysOverlap = textOverlapMode === 'always'; + const iconOverlapMode = getOverlapMode(layout, 'icon-overlap', 'icon-allow-overlap'); + const iconAlwaysOverlap = iconOverlapMode === 'always'; + const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; + const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const hasIconTextFit = layout.get('icon-text-fit') !== 'none'; + const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y'; + + // This logic is similar to the "defaultOpacityState" logic below in updateBucketOpacities + // If we know a symbol is always supposed to show, force it to be marked visible even if + // it wasn't placed into the collision index (because some or all of it was outside the range + // of the collision grid). + // There is a subtle edge case here we're accepting: + // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false + // A's icon is outside the grid, so doesn't get placed + // A's text would be inside grid, but doesn't get placed because of icon-optional: false + // We still show A because of the allow-overlap settings. + // Symbol B has allow-overlap: false, and gets placed where A's text would be + // On panning in, there is a short period when Symbol B and Symbol A will overlap + // This is the reverse of our normal policy of "fade in on pan", but should look like any other + // collision and hopefully not be too noticeable. + // See https://github.com/mapbox/mapbox-gl-js/issues/7172 + const alwaysShowText = textAlwaysOverlap && (iconAlwaysOverlap || !bucket.hasIconData() || iconOptional); + const alwaysShowIcon = iconAlwaysOverlap && (textAlwaysOverlap || !bucket.hasTextData() || textOptional); + + if (!bucket.collisionArrays && collisionBoxArray) { + bucket.deserializeCollisionBoxes(collisionBoxArray); + } + + const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID; + const getElevation = this.terrain ? (x: number, y: number) => this.terrain.getElevation(tileID, x, y) : null; + + const placeSymbol = (symbolInstance: SymbolInstance, collisionArrays: CollisionArrays) => { + if (seenCrossTileIDs[symbolInstance.crossTileID]) return; + if (holdingForFade) { + // Mark all symbols from this tile as "not placed", but don't add to seenCrossTileIDs, because we don't + // know yet if we have a duplicate in a parent tile that _should_ be placed. + this.placements[symbolInstance.crossTileID] = new JointPlacement(false, false, false); + return; + } + + let placeText = false; + let placeIcon = false; + let offscreen = true; + let shift = null; + + let placed = {box: null, offscreen: null}; + let placedVerticalText = {box: null, offscreen: null}; + + let placedGlyphBoxes = null; + let placedGlyphCircles = null; + let placedIconBoxes = null; + let textFeatureIndex = 0; + let verticalTextFeatureIndex = 0; + let iconFeatureIndex = 0; + + if (collisionArrays.textFeatureIndex) { + textFeatureIndex = collisionArrays.textFeatureIndex; + } else if (symbolInstance.useRuntimeCollisionCircles) { + textFeatureIndex = symbolInstance.featureIndex; + } + if (collisionArrays.verticalTextFeatureIndex) { + verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex; + } + + const textBox = collisionArrays.textBox; + if (textBox) { + + const updatePreviousOrientationIfNotPlaced = (isPlaced) => { + let previousOrientation = WritingMode.horizontal; + if (bucket.allowVerticalPlacement && !isPlaced && this.prevPlacement) { + const prevPlacedOrientation = this.prevPlacement.placedOrientations[symbolInstance.crossTileID]; + if (prevPlacedOrientation) { + this.placedOrientations[symbolInstance.crossTileID] = prevPlacedOrientation; + previousOrientation = prevPlacedOrientation; + this.markUsedOrientation(bucket, previousOrientation, symbolInstance); + } + } + return previousOrientation; + }; + + const placeTextForPlacementModes = (placeHorizontalFn, placeVerticalFn) => { + if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && collisionArrays.verticalTextBox) { + for (const placementMode of bucket.writingModes) { + if (placementMode === WritingMode.vertical) { + placed = placeVerticalFn(); + placedVerticalText = placed; + } else { + placed = placeHorizontalFn(); + } + if (placed && placed.box && placed.box.length) break; + } + } else { + placed = placeHorizontalFn(); + } + }; + + const textAnchorOffsetStart = symbolInstance.textAnchorOffsetStartIndex; + const textAnchorOffsetEnd = symbolInstance.textAnchorOffsetEndIndex; + + // If start+end indices match, text-variable-anchor is not in play. + if (textAnchorOffsetEnd === textAnchorOffsetStart) { + const placeBox = (collisionTextBox, orientation) => { + const placedFeature = this.collisionIndex.placeCollisionBox( + collisionTextBox, + textOverlapMode, + textPixelRatio, + posMatrix, + collisionGroup.predicate, + getElevation + ); + if (placedFeature && placedFeature.box && placedFeature.box.length) { + this.markUsedOrientation(bucket, orientation, symbolInstance); + this.placedOrientations[symbolInstance.crossTileID] = orientation; + } + return placedFeature; + }; + + const placeHorizontal = () => { + return placeBox(textBox, WritingMode.horizontal); + }; + + const placeVertical = () => { + const verticalTextBox = collisionArrays.verticalTextBox; + if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) { + return placeBox(verticalTextBox, WritingMode.vertical); + } + return {box: null, offscreen: null}; + }; + + placeTextForPlacementModes(placeHorizontal, placeVertical); + updatePreviousOrientationIfNotPlaced(placed && placed.box && placed.box.length); + + } else { + // If this symbol was in the last placement, prefer placement using same anchor, if it's still available + let prevAnchor = TextAnchorEnum[this.prevPlacement?.variableOffsets[symbolInstance.crossTileID]?.anchor]; + + const placeBoxForVariableAnchors = (collisionTextBox, collisionIconBox, orientation) => { + const width = collisionTextBox.x2 - collisionTextBox.x1; + const height = collisionTextBox.y2 - collisionTextBox.y1; + const textBoxScale = symbolInstance.textBoxScale; + const variableIconBox = hasIconTextFit && (iconOverlapMode === 'never') ? collisionIconBox : null; + + let placedBox: { + box: Array; + offscreen: boolean; + } = {box: [], offscreen: false}; + let placementPasses = (textOverlapMode === 'never') ? 1 : 2; + let overlapMode: OverlapMode = 'never'; + + if (prevAnchor) { + placementPasses++; + } + + for (let pass = 0; pass < placementPasses; pass++) { + for (let i = textAnchorOffsetStart; i < textAnchorOffsetEnd; i++) { + const textAnchorOffset = bucket.textAnchorOffsets.get(i); + + if (prevAnchor && textAnchorOffset.textAnchor !== prevAnchor) { + continue; + } + + const result = this.attemptAnchorPlacement( + textAnchorOffset, collisionTextBox, width, height, + textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix, + collisionGroup, overlapMode, symbolInstance, bucket, orientation, variableIconBox, getElevation); + + if (result) { + placedBox = result.placedGlyphBoxes; + if (placedBox && placedBox.box && placedBox.box.length) { + placeText = true; + shift = result.shift; + return placedBox; + } + } + } + + if (prevAnchor) { + prevAnchor = null; + } else { + overlapMode = textOverlapMode; + } + } + + return placedBox; + }; + + const placeHorizontal = () => { + return placeBoxForVariableAnchors(textBox, collisionArrays.iconBox, WritingMode.horizontal); + }; + + const placeVertical = () => { + const verticalTextBox = collisionArrays.verticalTextBox; + const wasPlaced = placed && placed.box && placed.box.length; + if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) { + return placeBoxForVariableAnchors(verticalTextBox, collisionArrays.verticalIconBox, WritingMode.vertical); + } + return {box: null, offscreen: null}; + }; + + placeTextForPlacementModes(placeHorizontal, placeVertical); + + if (placed) { + placeText = placed.box; + offscreen = placed.offscreen; + } + + const prevOrientation = updatePreviousOrientationIfNotPlaced(placed && placed.box); + + // If we didn't get placed, we still need to copy our position from the last placement for + // fade animations + if (!placeText && this.prevPlacement) { + const prevOffset = this.prevPlacement.variableOffsets[symbolInstance.crossTileID]; + if (prevOffset) { + this.variableOffsets[symbolInstance.crossTileID] = prevOffset; + this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, prevOrientation); + } + } + + } + } + + placedGlyphBoxes = placed; + placeText = placedGlyphBoxes && placedGlyphBoxes.box && placedGlyphBoxes.box.length > 0; + + offscreen = placedGlyphBoxes && placedGlyphBoxes.offscreen; + + if (symbolInstance.useRuntimeCollisionCircles) { + const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.centerJustifiedTextSymbolIndex); + const fontSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol); + + const textPixelPadding = layout.get('text-padding'); + const circlePixelDiameter = symbolInstance.collisionCircleDiameter; + + placedGlyphCircles = this.collisionIndex.placeCollisionCircles( + textOverlapMode, + placedSymbol, + bucket.lineVertexArray, + bucket.glyphOffsetArray, + fontSize, + posMatrix, + textLabelPlaneMatrix, + labelToScreenMatrix, + showCollisionBoxes, + pitchWithMap, + collisionGroup.predicate, + circlePixelDiameter, + textPixelPadding, + getElevation + ); + + if (placedGlyphCircles.circles.length && placedGlyphCircles.collisionDetected && !showCollisionBoxes) { + warnOnce('Collisions detected, but collision boxes are not shown'); + } + + // If text-overlap is set to 'always', force "placedCircles" to true + // In theory there should always be at least one circle placed + // in this case, but for now quirks in text-anchor + // and text-offset may prevent that from being true. + placeText = textAlwaysOverlap || (placedGlyphCircles.circles.length > 0 && !placedGlyphCircles.collisionDetected); + offscreen = offscreen && placedGlyphCircles.offscreen; + } + + if (collisionArrays.iconFeatureIndex) { + iconFeatureIndex = collisionArrays.iconFeatureIndex; + } + + if (collisionArrays.iconBox) { + const placeIconFeature = iconBox => { + const shiftedIconBox = hasIconTextFit && shift ? + shiftVariableCollisionBox( + iconBox, shift.x, shift.y, + rotateWithMap, pitchWithMap, this.transform.angle) : + iconBox; + return this.collisionIndex.placeCollisionBox(shiftedIconBox, + iconOverlapMode, textPixelRatio, posMatrix, collisionGroup.predicate, getElevation); + }; + + if (placedVerticalText && placedVerticalText.box && placedVerticalText.box.length && collisionArrays.verticalIconBox) { + placedIconBoxes = placeIconFeature(collisionArrays.verticalIconBox); + placeIcon = placedIconBoxes.box.length > 0; + } else { + placedIconBoxes = placeIconFeature(collisionArrays.iconBox); + placeIcon = placedIconBoxes.box.length > 0; + } + offscreen = offscreen && placedIconBoxes.offscreen; + } + + const iconWithoutText = textOptional || + (symbolInstance.numHorizontalGlyphVertices === 0 && symbolInstance.numVerticalGlyphVertices === 0); + const textWithoutIcon = iconOptional || symbolInstance.numIconVertices === 0; + + // Combine the scales for icons and text. + if (!iconWithoutText && !textWithoutIcon) { + placeIcon = placeText = placeIcon && placeText; + } else if (!textWithoutIcon) { + placeText = placeIcon && placeText; + } else if (!iconWithoutText) { + placeIcon = placeIcon && placeText; + } + + if (placeText && placedGlyphBoxes && placedGlyphBoxes.box) { + if (placedVerticalText && placedVerticalText.box && verticalTextFeatureIndex) { + this.collisionIndex.insertCollisionBox( + placedGlyphBoxes.box, + textOverlapMode, + layout.get('text-ignore-placement'), + bucket.bucketInstanceId, + verticalTextFeatureIndex, + collisionGroup.ID); + } else { + this.collisionIndex.insertCollisionBox( + placedGlyphBoxes.box, + textOverlapMode, + layout.get('text-ignore-placement'), + bucket.bucketInstanceId, + textFeatureIndex, + collisionGroup.ID); + } + + } + if (placeIcon && placedIconBoxes) { + this.collisionIndex.insertCollisionBox( + placedIconBoxes.box, + iconOverlapMode, + layout.get('icon-ignore-placement'), + bucket.bucketInstanceId, + iconFeatureIndex, + collisionGroup.ID); + } + if (placedGlyphCircles) { + if (placeText) { + this.collisionIndex.insertCollisionCircles( + placedGlyphCircles.circles, + textOverlapMode, + layout.get('text-ignore-placement'), + bucket.bucketInstanceId, + textFeatureIndex, + collisionGroup.ID); + } + + if (showCollisionBoxes) { + const id = bucket.bucketInstanceId; + let circleArray = this.collisionCircleArrays[id]; + + // Group collision circles together by bucket. Circles can't be pushed forward for rendering yet as the symbol placement + // for a bucket is not guaranteed to be complete before the commit-function has been called + if (circleArray === undefined) + circleArray = this.collisionCircleArrays[id] = new CollisionCircleArray(); + + for (let i = 0; i < placedGlyphCircles.circles.length; i += 4) { + circleArray.circles.push(placedGlyphCircles.circles[i + 0]); // x + circleArray.circles.push(placedGlyphCircles.circles[i + 1]); // y + circleArray.circles.push(placedGlyphCircles.circles[i + 2]); // radius + circleArray.circles.push(placedGlyphCircles.collisionDetected ? 1 : 0); // collisionDetected-flag + } + } + } + + if (symbolInstance.crossTileID === 0) throw new Error('symbolInstance.crossTileID can\'t be 0'); + if (bucket.bucketInstanceId === 0) throw new Error('bucket.bucketInstanceId can\'t be 0'); + + this.placements[symbolInstance.crossTileID] = new JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded); + seenCrossTileIDs[symbolInstance.crossTileID] = true; + }; + + if (zOrderByViewportY) { + if (bucketPart.symbolInstanceStart !== 0) throw new Error('bucket.bucketInstanceId should be 0'); + const symbolIndexes = bucket.getSortedSymbolIndexes(this.transform.angle); + for (let i = symbolIndexes.length - 1; i >= 0; --i) { + const symbolIndex = symbolIndexes[i]; + placeSymbol(bucket.symbolInstances.get(symbolIndex), bucket.collisionArrays[symbolIndex]); + } + } else { + for (let i = bucketPart.symbolInstanceStart; i < bucketPart.symbolInstanceEnd; i++) { + placeSymbol(bucket.symbolInstances.get(i), bucket.collisionArrays[i]); + } + } + + if (showCollisionBoxes && bucket.bucketInstanceId in this.collisionCircleArrays) { + const circleArray = this.collisionCircleArrays[bucket.bucketInstanceId]; + + // Store viewport and inverse projection matrices per bucket + mat4.invert(circleArray.invProjMatrix, posMatrix); + circleArray.viewportMatrix = this.collisionIndex.getViewportMatrix(); + } + + bucket.justReloaded = false; + } + + markUsedJustification(bucket: SymbolBucket, placedAnchor: TextAnchor, symbolInstance: SymbolInstance, orientation: number) { + const justifications = { + 'left': symbolInstance.leftJustifiedTextSymbolIndex, + 'center': symbolInstance.centerJustifiedTextSymbolIndex, + 'right': symbolInstance.rightJustifiedTextSymbolIndex + }; + + let autoIndex; + if (orientation === WritingMode.vertical) { + autoIndex = symbolInstance.verticalPlacedTextSymbolIndex; + } else { + autoIndex = justifications[getAnchorJustification(placedAnchor)]; + } + + const indexes = [ + symbolInstance.leftJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.rightJustifiedTextSymbolIndex, + symbolInstance.verticalPlacedTextSymbolIndex + ]; + + for (const index of indexes) { + if (index >= 0) { + if (autoIndex >= 0 && index !== autoIndex) { + // There are multiple justifications and this one isn't it: shift offscreen + bucket.text.placedSymbolArray.get(index).crossTileID = 0; + } else { + // Either this is the chosen justification or the justification is hardwired: use this one + bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID; + } + } + } + } + + markUsedOrientation(bucket: SymbolBucket, orientation: number, symbolInstance: SymbolInstance) { + const horizontal = (orientation === WritingMode.horizontal || orientation === WritingMode.horizontalOnly) ? orientation : 0; + const vertical = orientation === WritingMode.vertical ? orientation : 0; + + const horizontalIndexes = [ + symbolInstance.leftJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.rightJustifiedTextSymbolIndex + ]; + + for (const index of horizontalIndexes) { + bucket.text.placedSymbolArray.get(index).placedOrientation = horizontal; + } + + if (symbolInstance.verticalPlacedTextSymbolIndex) { + bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).placedOrientation = vertical; + } + } + + commit(now: number): void { + this.commitTime = now; + this.zoomAtLastRecencyCheck = this.transform.zoom; + + const prevPlacement = this.prevPlacement; + let placementChanged = false; + + this.prevZoomAdjustment = prevPlacement ? prevPlacement.zoomAdjustment(this.transform.zoom) : 0; + const increment = prevPlacement ? prevPlacement.symbolFadeChange(now) : 1; + + const prevOpacities = prevPlacement ? prevPlacement.opacities : {}; + const prevOffsets = prevPlacement ? prevPlacement.variableOffsets : {}; + const prevOrientations = prevPlacement ? prevPlacement.placedOrientations : {}; + + // add the opacities from the current placement, and copy their current values from the previous placement + for (const crossTileID in this.placements) { + const jointPlacement = this.placements[crossTileID]; + const prevOpacity = prevOpacities[crossTileID]; + if (prevOpacity) { + this.opacities[crossTileID] = new JointOpacityState(prevOpacity, increment, jointPlacement.text, jointPlacement.icon); + placementChanged = placementChanged || + jointPlacement.text !== prevOpacity.text.placed || + jointPlacement.icon !== prevOpacity.icon.placed; + } else { + this.opacities[crossTileID] = new JointOpacityState(null, increment, jointPlacement.text, jointPlacement.icon, jointPlacement.skipFade); + placementChanged = placementChanged || jointPlacement.text || jointPlacement.icon; + } + } + + // copy and update values from the previous placement that aren't in the current placement but haven't finished fading + for (const crossTileID in prevOpacities) { + const prevOpacity = prevOpacities[crossTileID]; + if (!this.opacities[crossTileID]) { + const jointOpacity = new JointOpacityState(prevOpacity, increment, false, false); + if (!jointOpacity.isHidden()) { + this.opacities[crossTileID] = jointOpacity; + placementChanged = placementChanged || prevOpacity.text.placed || prevOpacity.icon.placed; + } + } + } + for (const crossTileID in prevOffsets) { + if (!this.variableOffsets[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) { + this.variableOffsets[crossTileID] = prevOffsets[crossTileID]; + } + } + + for (const crossTileID in prevOrientations) { + if (!this.placedOrientations[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) { + this.placedOrientations[crossTileID] = prevOrientations[crossTileID]; + } + } + + // this.lastPlacementChangeTime is the time of the last commit() that + // resulted in a placement change -- in other words, the start time of + // the last symbol fade animation + if (prevPlacement && prevPlacement.lastPlacementChangeTime === undefined) { + throw new Error('Last placement time for previous placement is not defined'); + } + if (placementChanged) { + this.lastPlacementChangeTime = now; + } else if (typeof this.lastPlacementChangeTime !== 'number') { + this.lastPlacementChangeTime = prevPlacement ? prevPlacement.lastPlacementChangeTime : now; + } + } + + updateLayerOpacities(styleLayer: StyleLayer, tiles: Array) { + const seenCrossTileIDs = {}; + for (const tile of tiles) { + const symbolBucket = tile.getBucket(styleLayer) as SymbolBucket; + if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) { + this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray); + } + } + } + + updateBucketOpacities(bucket: SymbolBucket, seenCrossTileIDs: { + [k in string | number]: boolean; + }, collisionBoxArray?: CollisionBoxArray | null) { + if (bucket.hasTextData()) { + bucket.text.opacityVertexArray.clear(); + bucket.text.hasVisibleVertices = false; + } + if (bucket.hasIconData()) { + bucket.icon.opacityVertexArray.clear(); + bucket.icon.hasVisibleVertices = false; + } + if (bucket.hasIconCollisionBoxData()) bucket.iconCollisionBox.collisionVertexArray.clear(); + if (bucket.hasTextCollisionBoxData()) bucket.textCollisionBox.collisionVertexArray.clear(); + + const layer = bucket.layers[0]; + const layout = layer.layout; + const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true); + const textAllowOverlap = layout.get('text-allow-overlap'); + const iconAllowOverlap = layout.get('icon-allow-overlap'); + const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset'); + const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; + const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const hasIconTextFit = layout.get('icon-text-fit') !== 'none'; + // If allow-overlap is true, we can show symbols before placement runs on them + // But we have to wait for placement if we potentially depend on a paired icon/text + // with allow-overlap: false. + // See https://github.com/mapbox/mapbox-gl-js/issues/7032 + const defaultOpacityState = new JointOpacityState(null, 0, + textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || layout.get('icon-optional')), + iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || layout.get('text-optional')), + true); + + if (!bucket.collisionArrays && collisionBoxArray && ((bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()))) { + bucket.deserializeCollisionBoxes(collisionBoxArray); + } + + const addOpacities = (iconOrText, numVertices: number, opacity: number) => { + for (let i = 0; i < numVertices / 4; i++) { + iconOrText.opacityVertexArray.emplaceBack(opacity); + } + iconOrText.hasVisibleVertices = iconOrText.hasVisibleVertices || (opacity !== PACKED_HIDDEN_OPACITY); + }; + + for (let s = 0; s < bucket.symbolInstances.length; s++) { + const symbolInstance = bucket.symbolInstances.get(s); + const { + numHorizontalGlyphVertices, + numVerticalGlyphVertices, + crossTileID + } = symbolInstance; + + const isDuplicate = seenCrossTileIDs[crossTileID]; + + let opacityState = this.opacities[crossTileID]; + if (isDuplicate) { + opacityState = duplicateOpacityState; + } else if (!opacityState) { + opacityState = defaultOpacityState; + // store the state so that future placements use it as a starting point + this.opacities[crossTileID] = opacityState; + } + + seenCrossTileIDs[crossTileID] = true; + + const hasText = numHorizontalGlyphVertices > 0 || numVerticalGlyphVertices > 0; + const hasIcon = symbolInstance.numIconVertices > 0; + + const placedOrientation = this.placedOrientations[symbolInstance.crossTileID]; + const horizontalHidden = placedOrientation === WritingMode.vertical; + const verticalHidden = placedOrientation === WritingMode.horizontal || placedOrientation === WritingMode.horizontalOnly; + + if (hasText) { + const packedOpacity = packOpacity(opacityState.text); + // Vertical text fades in/out on collision the same way as corresponding + // horizontal text. Switch between vertical/horizontal should be instantaneous + const horizontalOpacity = horizontalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity; + addOpacities(bucket.text, numHorizontalGlyphVertices, horizontalOpacity); + const verticalOpacity = verticalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity; + addOpacities(bucket.text, numVerticalGlyphVertices, verticalOpacity); + + // If this label is completely faded, mark it so that we don't have to calculate + // its position at render time. If this layer has variable placement, shift the various + // symbol instances appropriately so that symbols from buckets that have yet to be placed + // offset appropriately. + const symbolHidden = opacityState.text.isHidden(); + [ + symbolInstance.rightJustifiedTextSymbolIndex, + symbolInstance.centerJustifiedTextSymbolIndex, + symbolInstance.leftJustifiedTextSymbolIndex + ].forEach(index => { + if (index >= 0) { + bucket.text.placedSymbolArray.get(index).hidden = symbolHidden || horizontalHidden ? 1 : 0; + } + }); + + if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) { + bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).hidden = symbolHidden || verticalHidden ? 1 : 0; + } + + const prevOffset = this.variableOffsets[symbolInstance.crossTileID]; + if (prevOffset) { + this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, placedOrientation); + } + + const prevOrientation = this.placedOrientations[symbolInstance.crossTileID]; + if (prevOrientation) { + this.markUsedJustification(bucket, 'left', symbolInstance, prevOrientation); + this.markUsedOrientation(bucket, prevOrientation, symbolInstance); + } + } + + if (hasIcon) { + const packedOpacity = packOpacity(opacityState.icon); + + const useHorizontal = !(hasIconTextFit && symbolInstance.verticalPlacedIconSymbolIndex && horizontalHidden); + + if (symbolInstance.placedIconSymbolIndex >= 0) { + const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY; + addOpacities(bucket.icon, symbolInstance.numIconVertices, horizontalOpacity); + bucket.icon.placedSymbolArray.get(symbolInstance.placedIconSymbolIndex).hidden = + (opacityState.icon.isHidden() as any); + } + + if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) { + const verticalOpacity = !useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY; + addOpacities(bucket.icon, symbolInstance.numVerticalIconVertices, verticalOpacity); + bucket.icon.placedSymbolArray.get(symbolInstance.verticalPlacedIconSymbolIndex).hidden = + (opacityState.icon.isHidden() as any); + } + } + + if (bucket.hasIconCollisionBoxData() || bucket.hasTextCollisionBoxData()) { + const collisionArrays = bucket.collisionArrays[s]; + if (collisionArrays) { + let shift = new Point(0, 0); + if (collisionArrays.textBox || collisionArrays.verticalTextBox) { + let used = true; + if (hasVariablePlacement) { + const variableOffset = this.variableOffsets[crossTileID]; + if (variableOffset) { + // This will show either the currently placed position or the last + // successfully placed position (so you can visualize what collision + // just made the symbol disappear, and the most likely place for the + // symbol to come back) + shift = calculateVariableLayoutShift(variableOffset.anchor, + variableOffset.width, + variableOffset.height, + variableOffset.textOffset, + variableOffset.textBoxScale); + if (rotateWithMap) { + shift._rotate(pitchWithMap ? this.transform.angle : -this.transform.angle); + } + } else { + // No offset -> this symbol hasn't been placed since coming on-screen + // No single box is particularly meaningful and all of them would be too noisy + // Use the center box just to show something's there, but mark it "not used" + used = false; + } + } + + if (collisionArrays.textBox) { + updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || horizontalHidden, shift.x, shift.y); + } + if (collisionArrays.verticalTextBox) { + updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || verticalHidden, shift.x, shift.y); + } + } + + const verticalIconUsed = Boolean(!verticalHidden && collisionArrays.verticalIconBox); + + if (collisionArrays.iconBox) { + updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, verticalIconUsed, + hasIconTextFit ? shift.x : 0, + hasIconTextFit ? shift.y : 0); + } + + if (collisionArrays.verticalIconBox) { + updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, !verticalIconUsed, + hasIconTextFit ? shift.x : 0, + hasIconTextFit ? shift.y : 0); + } + } + } + } + + bucket.sortFeatures(this.transform.angle); + if (this.retainedQueryData[bucket.bucketInstanceId]) { + this.retainedQueryData[bucket.bucketInstanceId].featureSortOrder = bucket.featureSortOrder; + } + + if (bucket.hasTextData() && bucket.text.opacityVertexBuffer) { + bucket.text.opacityVertexBuffer.updateData(bucket.text.opacityVertexArray); + } + if (bucket.hasIconData() && bucket.icon.opacityVertexBuffer) { + bucket.icon.opacityVertexBuffer.updateData(bucket.icon.opacityVertexArray); + } + if (bucket.hasIconCollisionBoxData() && bucket.iconCollisionBox.collisionVertexBuffer) { + bucket.iconCollisionBox.collisionVertexBuffer.updateData(bucket.iconCollisionBox.collisionVertexArray); + } + if (bucket.hasTextCollisionBoxData() && bucket.textCollisionBox.collisionVertexBuffer) { + bucket.textCollisionBox.collisionVertexBuffer.updateData(bucket.textCollisionBox.collisionVertexArray); + } + + if (bucket.text.opacityVertexArray.length !== bucket.text.layoutVertexArray.length / 4) throw new Error(`bucket.text.opacityVertexArray.length (= ${bucket.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${bucket.text.layoutVertexArray.length}) / 4`); + if (bucket.icon.opacityVertexArray.length !== bucket.icon.layoutVertexArray.length / 4) throw new Error(`bucket.icon.opacityVertexArray.length (= ${bucket.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${bucket.icon.layoutVertexArray.length}) / 4`); + + // Push generated collision circles to the bucket for debug rendering + if (bucket.bucketInstanceId in this.collisionCircleArrays) { + const instance = this.collisionCircleArrays[bucket.bucketInstanceId]; + + bucket.placementInvProjMatrix = instance.invProjMatrix; + bucket.placementViewportMatrix = instance.viewportMatrix; + bucket.collisionCircleArray = instance.circles; + + delete this.collisionCircleArrays[bucket.bucketInstanceId]; + } + } + + symbolFadeChange(now: number) { + return this.fadeDuration === 0 ? + 1 : + ((now - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment); + } + + zoomAdjustment(zoom: number) { + // When zooming out quickly, labels can overlap each other. This + // adjustment is used to reduce the interval between placement calculations + // and to reduce the fade duration when zooming out quickly. Discovering the + // collisions more quickly and fading them more quickly reduces the unwanted effect. + return Math.max(0, (this.transform.zoom - zoom) / 1.5); + } + + hasTransitions(now: number) { + return this.stale || + now - this.lastPlacementChangeTime < this.fadeDuration; + } + + stillRecent(now: number, zoom: number) { + // The adjustment makes placement more frequent when zooming. + // This condition applies the adjustment only after the map has + // stopped zooming. This avoids adding extra jank while zooming. + const durationAdjustment = this.zoomAtLastRecencyCheck === zoom ? + (1 - this.zoomAdjustment(zoom)) : + 1; + this.zoomAtLastRecencyCheck = zoom; + + return this.commitTime + this.fadeDuration * durationAdjustment > now; + } + + setStale() { + this.stale = true; + } +} + +function updateCollisionVertices(collisionVertexArray: CollisionVertexArray, placed: boolean, notUsed: boolean | number, shiftX?: number, shiftY?: number) { + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); + collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0); +} + +// All four vertices for a glyph will have the same opacity state +// So we pack the opacity into a uint8, and then repeat it four times +// to make a single uint32 that we can upload for each glyph in the +// label. +const shift25 = Math.pow(2, 25); +const shift24 = Math.pow(2, 24); +const shift17 = Math.pow(2, 17); +const shift16 = Math.pow(2, 16); +const shift9 = Math.pow(2, 9); +const shift8 = Math.pow(2, 8); +const shift1 = Math.pow(2, 1); +function packOpacity(opacityState: OpacityState): number { + if (opacityState.opacity === 0 && !opacityState.placed) { + return 0; + } else if (opacityState.opacity === 1 && opacityState.placed) { + return 4294967295; + } + const targetBit = opacityState.placed ? 1 : 0; + const opacityBits = Math.floor(opacityState.opacity * 127); + return opacityBits * shift25 + targetBit * shift24 + + opacityBits * shift17 + targetBit * shift16 + + opacityBits * shift9 + targetBit * shift8 + + opacityBits * shift1 + targetBit; +} + +const PACKED_HIDDEN_OPACITY = 0; diff --git a/web/libraries/maplibre-gl/src/symbol/projection.test.ts b/web/libraries/maplibre-gl/src/symbol/projection.test.ts new file mode 100644 index 00000000..2168601d --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/projection.test.ts @@ -0,0 +1,150 @@ +import {findOffsetIntersectionPoint, project, projectVertexToViewport, transformToOffsetNormal} from './projection'; + +import Point from '@mapbox/point-geometry'; +import {mat4} from 'gl-matrix'; +import {SymbolLineVertexArray} from '../data/array_types.g'; + +describe('Projection', () => { + test('matrix float precision', () => { + const point = new Point(10.000000005, 0); + const matrix = mat4.create(); + expect(project(point, matrix).point.x).toBeCloseTo(point.x, 10); + }); +}); + +describe('Vertex to viewport projection', () => { + // A three point line along the x axis + const lineVertexArray = new SymbolLineVertexArray(); + lineVertexArray.emplaceBack(-10, 0, -10); + lineVertexArray.emplaceBack(0, 0, 0); + lineVertexArray.emplaceBack(10, 0, 10); + + test('projecting with null matrix', () => { + const projectionArgs = { + projectionCache: {projections: {}, offsets: {}}, + lineVertexArray, + labelPlaneMatrix: mat4.create(), + getElevation: (_x, _y) => 0, + // Only relevant in "behind the camera" case, can't happen with null projection matrix + tileAnchorPoint: new Point(0, 0), + distanceFromAnchor: 0, + previousVertex: new Point(0, 0), + direction: 1, + absOffsetX: 0 + }; + + const first = projectVertexToViewport(0, projectionArgs); + const second = projectVertexToViewport(1, projectionArgs); + const third = projectVertexToViewport(2, projectionArgs); + expect(first.x).toBeCloseTo(-10); + expect(second.x).toBeCloseTo(0); + expect(third.x).toBeCloseTo(10); + }); +}); + +describe('Find offset line intersections', () => { + const lineVertexArray = new SymbolLineVertexArray(); + // A three point line along x axis, to origin, and then up y axis + lineVertexArray.emplaceBack(-10, 0, -10); + lineVertexArray.emplaceBack(0, 0, 0); + lineVertexArray.emplaceBack(0, 10, 10); + + // A three point line along the x axis + lineVertexArray.emplaceBack(-10, 0, -10); + lineVertexArray.emplaceBack(0, 0, 0); + lineVertexArray.emplaceBack(10, 0, 10); + + const projectionArgs = { + projectionCache: {projections: {}, offsets: {}}, + lineVertexArray, + labelPlaneMatrix: mat4.create(), + getElevation: (_x, _y) => 0, + direction: 1, + // Only relevant in "behind the camera" case, can't happen with null projection matrix + tileAnchorPoint: new Point(0, 0), + distanceFromAnchor: 0, + previousVertex: new Point(0, 0), + absOffsetX: 0 + }; + + test('concave', () => { + /* + | | + | | + ________| | + __________| <- origin + */ + projectionArgs.projectionCache = {projections: {}, offsets: {}}; + const lineOffsetY = 1; + + const prevToCurrent = new Point(10, 0); + const normal = transformToOffsetNormal(prevToCurrent, lineOffsetY, projectionArgs.direction); + expect(normal.y).toBeCloseTo(1); + expect(normal.x).toBeCloseTo(0); + const intersectionPoint = findOffsetIntersectionPoint( + 1, + normal, + new Point(0, 0), + 0, + 3, + new Point(-10, 1), + lineOffsetY, + projectionArgs + ); + expect(intersectionPoint.y).toBeCloseTo(1); + expect(intersectionPoint.x).toBeCloseTo(-1); + }); + + test('convex', () => { + /* + | | + | | + origin \ | | + __________| | + ____________| + */ + projectionArgs.projectionCache = {projections: {}, offsets: {}}; + const lineOffsetY = -1; + + const prevToCurrent = new Point(10, 0); + const normal = transformToOffsetNormal(prevToCurrent, lineOffsetY, projectionArgs.direction); + expect(normal.y).toBeCloseTo(-1); + expect(normal.x).toBeCloseTo(0); + const intersectionPoint = findOffsetIntersectionPoint( + 1, + normal, + new Point(0, 0), + 0, + 3, + new Point(-10, -1), + lineOffsetY, + projectionArgs + ); + expect(intersectionPoint.y).toBeCloseTo(-1); + expect(intersectionPoint.x).toBeCloseTo(1); + }); + + test('parallel', () => { + /* + ______._____ + ______|_____ + */ + projectionArgs.projectionCache = {projections: {}, offsets: {}}; + const lineOffsetY = 1; + + const prevToCurrent = new Point(10, 0); + const intersectionPoint = findOffsetIntersectionPoint( + 1, + transformToOffsetNormal(prevToCurrent, lineOffsetY, projectionArgs.direction), + new Point(0, 0), + 3, + 5, + new Point(-10, 1), + lineOffsetY, + projectionArgs + ); + expect(intersectionPoint.x).toBeCloseTo(0); + expect(intersectionPoint.y).toBeCloseTo(1); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/symbol/projection.ts b/web/libraries/maplibre-gl/src/symbol/projection.ts new file mode 100644 index 00000000..ac186a7c --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/projection.ts @@ -0,0 +1,679 @@ +import Point from '@mapbox/point-geometry'; + +import {mat4, vec4} from 'gl-matrix'; +import * as symbolSize from './symbol_size'; +import {addDynamicAttributes} from '../data/bucket/symbol_bucket'; + +import type {Painter} from '../render/painter'; +import type {Transform} from '../geo/transform'; +import type {SymbolBucket} from '../data/bucket/symbol_bucket'; +import type { + GlyphOffsetArray, + SymbolLineVertexArray, + SymbolDynamicLayoutArray +} from '../data/array_types.g'; +import {WritingMode} from '../symbol/shaping'; +import {findLineIntersection} from '../util/util'; + +export {updateLineLabels, hideGlyphs, getLabelPlaneMatrix, getGlCoordMatrix, project, getPerspectiveRatio, placeFirstAndLastGlyph, placeGlyphAlongLine, xyTransformMat4, projectVertexToViewport, findOffsetIntersectionPoint, transformToOffsetNormal}; + +/* + * # Overview of coordinate spaces + * + * ## Tile coordinate spaces + * Each label has an anchor. Some labels have corresponding line geometries. + * The points for both anchors and lines are stored in tile units. Each tile has it's own + * coordinate space going from (0, 0) at the top left to (EXTENT, EXTENT) at the bottom right. + * + * ## GL coordinate space + * At the end of everything, the vertex shader needs to produce a position in GL coordinate space, + * which is (-1, 1) at the top left and (1, -1) in the bottom right. + * + * ## Map pixel coordinate spaces + * Each tile has a pixel coordinate space. It's just the tile units scaled so that one unit is + * whatever counts as 1 pixel at the current zoom. + * This space is used for pitch-alignment=map, rotation-alignment=map + * + * ## Rotated map pixel coordinate spaces + * Like the above, but rotated so axis of the space are aligned with the viewport instead of the tile. + * This space is used for pitch-alignment=map, rotation-alignment=viewport + * + * ## Viewport pixel coordinate space + * (0, 0) is at the top left of the canvas and (pixelWidth, pixelHeight) is at the bottom right corner + * of the canvas. This space is used for pitch-alignment=viewport + * + * + * # Vertex projection + * It goes roughly like this: + * 1. project the anchor and line from tile units into the correct label coordinate space + * - map pixel space pitch-alignment=map rotation-alignment=map + * - rotated map pixel space pitch-alignment=map rotation-alignment=viewport + * - viewport pixel space pitch-alignment=viewport rotation-alignment=* + * 2. if the label follows a line, find the point along the line that is the correct distance from the anchor. + * 3. add the glyph's corner offset to the point from step 3 + * 4. convert from the label coordinate space to gl coordinates + * + * For horizontal labels we want to do step 1 in the shader for performance reasons (no cpu work). + * This is what `u_label_plane_matrix` is used for. + * For labels aligned with lines we have to steps 1 and 2 on the cpu since we need access to the line geometry. + * This is what `updateLineLabels(...)` does. + * Since the conversion is handled on the cpu we just set `u_label_plane_matrix` to an identity matrix. + * + * Steps 3 and 4 are done in the shaders for all labels. + */ + +/* + * Returns a matrix for converting from tile units to the correct label coordinate space. + */ +function getLabelPlaneMatrix(posMatrix: mat4, + pitchWithMap: boolean, + rotateWithMap: boolean, + transform: Transform, + pixelsToTileUnits: number) { + const m = mat4.create(); + if (pitchWithMap) { + mat4.scale(m, m, [1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1]); + if (!rotateWithMap) { + mat4.rotateZ(m, m, transform.angle); + } + } else { + mat4.multiply(m, transform.labelPlaneMatrix, posMatrix); + } + return m; +} + +/* + * Returns a matrix for converting from the correct label coordinate space to gl coords. + */ +function getGlCoordMatrix(posMatrix: mat4, + pitchWithMap: boolean, + rotateWithMap: boolean, + transform: Transform, + pixelsToTileUnits: number) { + if (pitchWithMap) { + const m = mat4.clone(posMatrix); + mat4.scale(m, m, [pixelsToTileUnits, pixelsToTileUnits, 1]); + if (!rotateWithMap) { + mat4.rotateZ(m, m, -transform.angle); + } + return m; + } else { + return transform.glCoordMatrix; + } +} + +function project(point: Point, matrix: mat4, getElevation?: (x: number, y: number) => number) { + let pos; + if (getElevation) { // slow because of handle z-index + pos = [point.x, point.y, getElevation(point.x, point.y), 1] as vec4; + vec4.transformMat4(pos, pos, matrix); + } else { // fast because of ignore z-index + pos = [point.x, point.y, 0, 1] as vec4; + xyTransformMat4(pos, pos, matrix); + } + const w = pos[3]; + return { + point: new Point(pos[0] / w, pos[1] / w), + signedDistanceFromCamera: w + }; +} + +function getPerspectiveRatio(cameraToCenterDistance: number, signedDistanceFromCamera: number): number { + return 0.5 + 0.5 * (cameraToCenterDistance / signedDistanceFromCamera); +} + +function isVisible(anchorPos: vec4, + clippingBuffer: [number, number]) { + const x = anchorPos[0] / anchorPos[3]; + const y = anchorPos[1] / anchorPos[3]; + const inPaddedViewport = ( + x >= -clippingBuffer[0] && + x <= clippingBuffer[0] && + y >= -clippingBuffer[1] && + y <= clippingBuffer[1]); + return inPaddedViewport; +} + +/* + * Update the `dynamicLayoutVertexBuffer` for the buffer with the correct glyph positions for the current map view. + * This is only run on labels that are aligned with lines. Horizontal labels are handled entirely in the shader. + */ +function updateLineLabels(bucket: SymbolBucket, + posMatrix: mat4, + painter: Painter, + isText: boolean, + labelPlaneMatrix: mat4, + glCoordMatrix: mat4, + pitchWithMap: boolean, + keepUpright: boolean, + rotateToLine: boolean, + getElevation: (x: number, y: number) => number) { + + const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData; + const partiallyEvaluatedSize = symbolSize.evaluateSizeForZoom(sizeData, painter.transform.zoom); + + const clippingBuffer: [number, number] = [256 / painter.width * 2 + 1, 256 / painter.height * 2 + 1]; + + const dynamicLayoutVertexArray = isText ? + bucket.text.dynamicLayoutVertexArray : + bucket.icon.dynamicLayoutVertexArray; + dynamicLayoutVertexArray.clear(); + + const lineVertexArray = bucket.lineVertexArray; + const placedSymbols = isText ? bucket.text.placedSymbolArray : bucket.icon.placedSymbolArray; + + const aspectRatio = painter.transform.width / painter.transform.height; + + let useVertical = false; + + for (let s = 0; s < placedSymbols.length; s++) { + const symbol = placedSymbols.get(s); + + // Don't do calculations for vertical glyphs unless the previous symbol was horizontal + // and we determined that vertical glyphs were necessary. + // Also don't do calculations for symbols that are collided and fully faded out + if (symbol.hidden || symbol.writingMode === WritingMode.vertical && !useVertical) { + hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray); + continue; + } + // Awkward... but we're counting on the paired "vertical" symbol coming immediately after its horizontal counterpart + useVertical = false; + + let anchorPos; + if (getElevation) { // slow because of handle z-index + anchorPos = [symbol.anchorX, symbol.anchorY, getElevation(symbol.anchorX, symbol.anchorY), 1] as vec4; + vec4.transformMat4(anchorPos, anchorPos, posMatrix); + } else { // fast because of ignore z-index + anchorPos = [symbol.anchorX, symbol.anchorY, 0, 1] as vec4; + xyTransformMat4(anchorPos, anchorPos, posMatrix); + } + + // Don't bother calculating the correct point for invisible labels. + if (!isVisible(anchorPos, clippingBuffer)) { + hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray); + continue; + } + + const cameraToAnchorDistance = anchorPos[3]; + const perspectiveRatio = getPerspectiveRatio(painter.transform.cameraToCenterDistance, cameraToAnchorDistance); + + const fontSize = symbolSize.evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol); + const pitchScaledFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio; + + const tileAnchorPoint = new Point(symbol.anchorX, symbol.anchorY); + const anchorPoint = project(tileAnchorPoint, labelPlaneMatrix, getElevation).point; + const projectionCache = {projections: {}, offsets: {}}; + + const placeUnflipped: any = placeGlyphsAlongLine(symbol, pitchScaledFontSize, false /*unflipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, + bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation); + + useVertical = placeUnflipped.useVertical; + + if (placeUnflipped.notEnoughRoom || useVertical || + (placeUnflipped.needsFlipping && + (placeGlyphsAlongLine(symbol, pitchScaledFontSize, true /*flipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, + bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) as any).notEnoughRoom)) { + hideGlyphs(symbol.numGlyphs, dynamicLayoutVertexArray); + } + } + + if (isText) { + bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray); + } else { + bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicLayoutVertexArray); + } +} + +type FirstAndLastGlyphPlacement = { + first: PlacedGlyph; + last: PlacedGlyph; +} | null; + +/* + * Place the first and last glyph of a line label, projected to the label plane. + * This function is called both during collision detection (to determine the label's size) + * and during line label rendering (to make sure the label fits on the line geometry with + * the current camera position, which may differ from the position used during collision detection). + * + * Calling this function has the effect of populating the "projectionCache" with all projected + * vertex locations the label will need, making future calls to placeGlyphAlongLine (for all the + * intermediate glyphs) much cheaper. + * + * Returns null if the label can't fit on the geometry + */ +function placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffsetArray, lineOffsetX: number, lineOffsetY: number, flip: boolean, anchorPoint: Point, tileAnchorPoint: Point, symbol: any, lineVertexArray: SymbolLineVertexArray, labelPlaneMatrix: mat4, projectionCache: ProjectionCache, rotateToLine: boolean, getElevation: (x: number, y: number) => number): FirstAndLastGlyphPlacement { + const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs; + const lineStartIndex = symbol.lineStartIndex; + const lineEndIndex = symbol.lineStartIndex + symbol.lineLength; + + const firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex); + const lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1); + + const firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, + lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!firstPlacedGlyph) + return null; + + const lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, + lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!lastPlacedGlyph) + return null; + + return {first: firstPlacedGlyph, last: lastPlacedGlyph}; +} + +function requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRatio) { + if (writingMode === WritingMode.horizontal) { + // On top of choosing whether to flip, choose whether to render this version of the glyphs or the alternate + // vertical glyphs. We can't just filter out vertical glyphs in the horizontal range because the horizontal + // and vertical versions can have slightly different projections which could lead to angles where both or + // neither showed. + const rise = Math.abs(lastPoint.y - firstPoint.y); + const run = Math.abs(lastPoint.x - firstPoint.x) * aspectRatio; + if (rise > run) { + return {useVertical: true}; + } + } + + if (writingMode === WritingMode.vertical ? firstPoint.y < lastPoint.y : firstPoint.x > lastPoint.x) { + // Includes "horizontalOnly" case for labels without vertical glyphs + return {needsFlipping: true}; + } + + return null; +} + +/* +* Place first and last glyph along the line projected to label plane, and if they fit +* iterate through all the intermediate glyphs, calculating their label plane positions +* from the projected line. +* +* Finally, add resulting glyph position calculations to dynamicLayoutVertexArray for +* upload to the GPU +*/ +function placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray, anchorPoint, tileAnchorPoint, projectionCache, aspectRatio, rotateToLine, getElevation) { + const fontScale = fontSize / 24; + const lineOffsetX = symbol.lineOffsetX * fontScale; + const lineOffsetY = symbol.lineOffsetY * fontScale; + + let placedGlyphs; + if (symbol.numGlyphs > 1) { + const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs; + const lineStartIndex = symbol.lineStartIndex; + const lineEndIndex = symbol.lineStartIndex + symbol.lineLength; + + // Place the first and the last glyph in the label first, so we can figure out + // the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode + const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!firstAndLastGlyph) { + return {notEnoughRoom: true}; + } + const firstPoint = project(firstAndLastGlyph.first.point, glCoordMatrix, getElevation).point; + const lastPoint = project(firstAndLastGlyph.last.point, glCoordMatrix, getElevation).point; + + if (keepUpright && !flip) { + const orientationChange = requiresOrientationChange(symbol.writingMode, firstPoint, lastPoint, aspectRatio); + if (orientationChange) { + return orientationChange; + } + } + + placedGlyphs = [firstAndLastGlyph.first]; + for (let glyphIndex = symbol.glyphStartIndex + 1; glyphIndex < glyphEndIndex - 1; glyphIndex++) { + // Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed + placedGlyphs.push(placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, + lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation)); + } + placedGlyphs.push(firstAndLastGlyph.last); + } else { + // Only a single glyph to place + // So, determine whether to flip based on projected angle of the line segment it's on + if (keepUpright && !flip) { + const a = project(tileAnchorPoint, posMatrix, getElevation).point; + const tileVertexIndex = (symbol.lineStartIndex + symbol.segment + 1); + const tileSegmentEnd = new Point(lineVertexArray.getx(tileVertexIndex), lineVertexArray.gety(tileVertexIndex)); + const projectedVertex = project(tileSegmentEnd, posMatrix, getElevation); + // We know the anchor will be in the viewport, but the end of the line segment may be + // behind the plane of the camera, in which case we can use a point at any arbitrary (closer) + // point on the segment. + const b = (projectedVertex.signedDistanceFromCamera > 0) ? + projectedVertex.point : + projectTruncatedLineSegment(tileAnchorPoint, tileSegmentEnd, a, 1, posMatrix, getElevation); + + const orientationChange = requiresOrientationChange(symbol.writingMode, a, b, aspectRatio); + if (orientationChange) { + return orientationChange; + } + } + const singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(symbol.glyphStartIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, + symbol.lineStartIndex, symbol.lineStartIndex + symbol.lineLength, lineVertexArray, labelPlaneMatrix, projectionCache, rotateToLine, getElevation); + if (!singleGlyph) + return {notEnoughRoom: true}; + + placedGlyphs = [singleGlyph]; + } + + for (const glyph of placedGlyphs) { + addDynamicAttributes(dynamicLayoutVertexArray, glyph.point, glyph.angle); + } + return {}; +} + +function projectTruncatedLineSegment(previousTilePoint: Point, currentTilePoint: Point, previousProjectedPoint: Point, minimumLength: number, projectionMatrix: mat4, getElevation: (x: number, y: number) => number) { + // We are assuming "previousTilePoint" won't project to a point within one unit of the camera plane + // If it did, that would mean our label extended all the way out from within the viewport to a (very distant) + // point near the plane of the camera. We wouldn't be able to render the label anyway once it crossed the + // plane of the camera. + const projectedUnitVertex = project(previousTilePoint.add(previousTilePoint.sub(currentTilePoint)._unit()), projectionMatrix, getElevation).point; + const projectedUnitSegment = previousProjectedPoint.sub(projectedUnitVertex); + + return previousProjectedPoint.add(projectedUnitSegment._mult(minimumLength / projectedUnitSegment.mag())); +} + +type IndexToPointCache = { [lineIndex: number]: Point }; + +/** + * We calculate label-plane projected points for line vertices as we place glyphs along the line + * Since we will use the same vertices for potentially many glyphs, cache the results for this bucket + * over the course of the render. Each vertex location also potentially has one offset equivalent + * for us to hold onto. The vertex indices are per-symbol-bucket. + */ +type ProjectionCache = { + /** + * tile-unit vertices projected into label-plane units + */ + projections: IndexToPointCache; + /** + * label-plane vertices which have been shifted to follow an offset line + */ + offsets: IndexToPointCache; +}; + +/** + * Arguments necessary to project a vertex to the label plane + */ +type ProjectionArgs = { + /** + * Used to cache results, save cost if projecting the same vertex multiple times + */ + projectionCache: ProjectionCache; + /** + * The array of tile-unit vertices transferred from worker + */ + lineVertexArray: SymbolLineVertexArray; + /** + * Label plane projection matrix + */ + labelPlaneMatrix: mat4; + /** + * Function to get elevation at a point + * @param x - the x coordinate + * @param y - the y coordinate + */ + getElevation: (x: number, y: number) => number; + /** + * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera + */ + tileAnchorPoint: Point; + /** + * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera + */ + distanceFromAnchor: number; + /** + * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera + */ + previousVertex: Point; + /** + * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera + */ + direction: number; + /** + * Only for creating synthetic vertices if vertex would otherwise project behind plane of camera + */ + absOffsetX: number; +}; + +/** + * Transform a vertex from tile coordinates to label plane coordinates + * @param index - index of vertex to project + * @param projectionArgs - necessary data to project a vertex + * @returns the vertex projected to the label plane + */ +function projectVertexToViewport(index: number, projectionArgs: ProjectionArgs): Point { + const {projectionCache, lineVertexArray, labelPlaneMatrix, tileAnchorPoint, distanceFromAnchor, getElevation, previousVertex, direction, absOffsetX} = projectionArgs; + if (projectionCache.projections[index]) { + return projectionCache.projections[index]; + } + const currentVertex = new Point(lineVertexArray.getx(index), lineVertexArray.gety(index)); + const projection = project(currentVertex, labelPlaneMatrix, getElevation); + if (projection.signedDistanceFromCamera > 0) { + projectionCache.projections[index] = projection.point; + return projection.point; + } + + // The vertex is behind the plane of the camera, so we can't project it + // Instead, we'll create a vertex along the line that's far enough to include the glyph + const previousLineVertexIndex = index - direction; + const previousTilePoint = distanceFromAnchor === 0 ? + tileAnchorPoint : + new Point(lineVertexArray.getx(previousLineVertexIndex), lineVertexArray.gety(previousLineVertexIndex)); + // Don't cache because the new vertex might not be far enough out for future glyphs on the same segment + return projectTruncatedLineSegment(previousTilePoint, currentVertex, previousVertex, absOffsetX - distanceFromAnchor + 1, labelPlaneMatrix, getElevation); +} + +/** + * Calculate the normal vector for a line segment + * @param segmentVector - will be mutated as a tiny optimization + * @param offset - magnitude of resulting vector + * @param direction - direction of line traversal + * @returns a normal vector from the segment, with magnitude equal to offset amount + */ +function transformToOffsetNormal(segmentVector: Point, offset: number, direction: number): Point { + return segmentVector._unit()._perp()._mult(offset * direction); +} + +/** + * Construct offset line segments for the current segment and the next segment, then extend/shrink + * the segments until they intersect. If the segments are parallel, then they will touch with no modification. + * + * @param index - Index of the current vertex + * @param prevToCurrentOffsetNormal - Normal vector of the line segment from the previous vertex to the current vertex + * @param currentVertex - Current (non-offset) vertex projected to the label plane + * @param lineStartIndex - Beginning index for the line this label is on + * @param lineEndIndex - End index for the line this label is on + * @param offsetPreviousVertex - The previous vertex projected to the label plane, and then offset along the previous segments normal + * @param lineOffsetY - Magnitude of the offset + * @param projectionArgs - Necessary data for tile-to-label-plane projection + * @returns The point at which the current and next line segments intersect, once offset and extended/shrunk to their meeting point + */ +function findOffsetIntersectionPoint(index: number, prevToCurrentOffsetNormal: Point, currentVertex: Point, lineStartIndex: number, lineEndIndex: number, offsetPreviousVertex: Point, lineOffsetY: number, projectionArgs: ProjectionArgs) { + const {projectionCache, direction} = projectionArgs; + if (projectionCache.offsets[index]) { + return projectionCache.offsets[index]; + } + + const offsetCurrentVertex = currentVertex.add(prevToCurrentOffsetNormal); + + if (index + direction < lineStartIndex || index + direction >= lineEndIndex) { + // This is the end of the line, no intersection to calculate + projectionCache.offsets[index] = offsetCurrentVertex; + return offsetCurrentVertex; + } + // Offset the vertices for the next segment + const nextVertex = projectVertexToViewport(index + direction, projectionArgs); + const currentToNextOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction); + const offsetNextSegmentBegin = currentVertex.add(currentToNextOffsetNormal); + const offsetNextSegmentEnd = nextVertex.add(currentToNextOffsetNormal); + + // find the intersection of these two lines + // if the lines are parallel, offsetCurrent/offsetNextBegin will touch + projectionCache.offsets[index] = findLineIntersection(offsetPreviousVertex, offsetCurrentVertex, offsetNextSegmentBegin, offsetNextSegmentEnd) || offsetCurrentVertex; + + return projectionCache.offsets[index]; +} + +/** + * Placed Glyph type + */ +type PlacedGlyph = { + /** + * The point at which the glyph should be placed, in label plane coordinates + */ + point: Point; + /** + * The angle at which the glyph should be placed + */ + angle: number; + /** + * The label-plane path used to reach this glyph: used only for collision detection + */ + path: Array; +}; + +/* + * Place a single glyph along its line, projected into the label plane, by iterating outward + * from the anchor point until the distance traversed in the label plane equals the glyph's + * offsetX. Returns null if the glyph can't fit on the line geometry. + */ +function placeGlyphAlongLine( + offsetX: number, + lineOffsetX: number, + lineOffsetY: number, + flip: boolean, + anchorPoint: Point, + tileAnchorPoint: Point, + anchorSegment: number, + lineStartIndex: number, + lineEndIndex: number, + lineVertexArray: SymbolLineVertexArray, + labelPlaneMatrix: mat4, + projectionCache: ProjectionCache, + rotateToLine: boolean, + getElevation: (x: number, y: number) => number): PlacedGlyph | null { + + const combinedOffsetX = flip ? + offsetX - lineOffsetX : + offsetX + lineOffsetX; + + let direction = combinedOffsetX > 0 ? 1 : -1; + + let angle = 0; + if (flip) { + // The label needs to be flipped to keep text upright. + // Iterate in the reverse direction. + direction *= -1; + angle = Math.PI; + } + + if (direction < 0) angle += Math.PI; + + let currentIndex = direction > 0 ? + lineStartIndex + anchorSegment : + lineStartIndex + anchorSegment + 1; + + let currentVertex = anchorPoint; + let previousVertex = anchorPoint; + + // offsetPrev and intersectionPoint are analogous to previousVertex and currentVertex + // but if there's a line offset they are calculated in parallel as projection happens + let offsetIntersectionPoint: Point; + let offsetPreviousVertex: Point; + + let distanceFromAnchor = 0; + let currentSegmentDistance = 0; + const absOffsetX = Math.abs(combinedOffsetX); + const pathVertices: Array = []; + + let currentLineSegment: Point; + while (distanceFromAnchor + currentSegmentDistance <= absOffsetX) { + currentIndex += direction; + + // offset does not fit on the projected line + if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex) + return null; + + // accumulate values from last iteration + distanceFromAnchor += currentSegmentDistance; + previousVertex = currentVertex; + offsetPreviousVertex = offsetIntersectionPoint; + + const projectionArgs: ProjectionArgs = { + projectionCache, + lineVertexArray, + labelPlaneMatrix, + tileAnchorPoint, + distanceFromAnchor, + getElevation, + previousVertex, + direction, + absOffsetX + }; + + // find next vertex in viewport space + currentVertex = projectVertexToViewport(currentIndex, projectionArgs); + if (lineOffsetY === 0) { + // Store vertices for collision detection and update current segment geometry + pathVertices.push(previousVertex); + currentLineSegment = currentVertex.sub(previousVertex); + } else { + // Calculate the offset for this section + let prevToCurrentOffsetNormal; + const prevToCurrent = currentVertex.sub(previousVertex); + if (prevToCurrent.mag() === 0) { + // We are starting with our anchor point directly on the vertex, so look one vertex ahead + // to calculate a normal + const nextVertex = projectVertexToViewport(currentIndex + direction, projectionArgs); + prevToCurrentOffsetNormal = transformToOffsetNormal(nextVertex.sub(currentVertex), lineOffsetY, direction); + } else { + prevToCurrentOffsetNormal = transformToOffsetNormal(prevToCurrent, lineOffsetY, direction); + } + // Initialize offsetPrev on our first iteration, after that it will be pre-calculated + if (!offsetPreviousVertex) + offsetPreviousVertex = previousVertex.add(prevToCurrentOffsetNormal); + + offsetIntersectionPoint = findOffsetIntersectionPoint(currentIndex, prevToCurrentOffsetNormal, currentVertex, lineStartIndex, lineEndIndex, offsetPreviousVertex, lineOffsetY, projectionArgs); + + pathVertices.push(offsetPreviousVertex); + currentLineSegment = offsetIntersectionPoint.sub(offsetPreviousVertex); + } + currentSegmentDistance = currentLineSegment.mag(); + } + + // The point is on the current segment. Interpolate to find it. + const segmentInterpolationT = (absOffsetX - distanceFromAnchor) / currentSegmentDistance; + const p = currentLineSegment._mult(segmentInterpolationT)._add(offsetPreviousVertex || previousVertex); + + const segmentAngle = angle + Math.atan2(currentVertex.y - previousVertex.y, currentVertex.x - previousVertex.x); + + pathVertices.push(p); + + return { + point: p, + angle: rotateToLine ? segmentAngle : 0.0, + path: pathVertices + }; +} + +const hiddenGlyphAttributes = new Float32Array([-Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0, -Infinity, -Infinity, 0]); + +// Hide them by moving them offscreen. We still need to add them to the buffer +// because the dynamic buffer is paired with a static buffer that doesn't get updated. +function hideGlyphs(num: number, dynamicLayoutVertexArray: SymbolDynamicLayoutArray) { + for (let i = 0; i < num; i++) { + const offset = dynamicLayoutVertexArray.length; + dynamicLayoutVertexArray.resize(offset + 4); + // Since all hidden glyphs have the same attributes, we can build up the array faster with a single call to Float32Array.set + // for each set of four vertices, instead of calling addDynamicAttributes for each vertex. + dynamicLayoutVertexArray.float32.set(hiddenGlyphAttributes, offset * 3); + } +} + +// For line label layout, we're not using z output and our w input is always 1 +// This custom matrix transformation ignores those components to make projection faster +function xyTransformMat4(out: vec4, a: vec4, m: mat4) { + const x = a[0], y = a[1]; + out[0] = m[0] * x + m[4] * y + m[12]; + out[1] = m[1] * x + m[5] * y + m[13]; + out[3] = m[3] * x + m[7] * y + m[15]; + return out; +} diff --git a/web/libraries/maplibre-gl/src/symbol/quads.test.ts b/web/libraries/maplibre-gl/src/symbol/quads.test.ts new file mode 100644 index 00000000..f592bc9b --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/quads.test.ts @@ -0,0 +1,157 @@ +import {ImagePosition} from '../render/image_atlas'; +import {getIconQuads} from './quads'; + +describe('getIconQuads', () => { + const image = Object.freeze({ + pixelRatio: 1, + displaySize: Object.freeze([15, 11]), + paddedRect: Object.freeze({x: 0, y: 0, w: 17, h: 13}) + }) as ImagePosition; + + test('point', () => { + expect(getIconQuads({ + top: -5.5, + right: 7.5, + bottom: 5.5, + left: -7.5, + image + }, 0, true, false)).toEqual([{ + tl: {x: -8.5, y: -6.5}, + tr: {x: 8.5, y: -6.5}, + bl: {x: -8.5, y: 6.5}, + br: {x: 8.5, y: 6.5}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: undefined, + glyphOffset: [0, 0], + isSDF: true, + sectionIndex: 0, + minFontScaleX: 0, + minFontScaleY: 0, + pixelOffsetBR: { + x: 0, + y: 0 + }, + pixelOffsetTL: { + x: 0, + y: 0 + } + }]); + + expect(getIconQuads({ + top: -11, + right: 15, + bottom: 11, + left: -15, + image + }, 0, false, false)).toEqual([{ + tl: {x: -17, y: -13}, + tr: {x: 17, y: -13}, + bl: {x: -17, y: 13}, + br: {x: 17, y: 13}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: undefined, + glyphOffset: [0, 0], + isSDF: false, + sectionIndex: 0, + minFontScaleX: 0, + minFontScaleY: 0, + pixelOffsetBR: { + x: 0, + y: 0 + }, + pixelOffsetTL: { + x: 0, + y: 0 + } + }]); + + expect(getIconQuads({ + top: 0, + right: 0, + bottom: 11, + left: -15, + image + }, 0, false, false)).toEqual([{ + tl: {x: -16, y: -1}, + tr: {x: 1, y: -1}, + bl: {x: -16, y: 12}, + br: {x: 1, y: 12}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: undefined, + glyphOffset: [0, 0], + isSDF: false, + sectionIndex: 0, + minFontScaleX: 0, + minFontScaleY: 0, + pixelOffsetBR: { + x: 0, + y: 0 + }, + pixelOffsetTL: { + x: 0, + y: 0 + } + }]); + + expect(getIconQuads({ + top: -5.5, + right: 30, + bottom: 5.5, + left: -30, + image + }, 0, false, false)).toEqual([{ + tl: {x: -34, y: -6.5}, + tr: {x: 34, y: -6.5}, + bl: {x: -34, y: 6.5}, + br: {x: 34, y: 6.5}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: undefined, + glyphOffset: [0, 0], + isSDF: false, + sectionIndex: 0, + minFontScaleX: 0, + minFontScaleY: 0, + pixelOffsetBR: { + x: 0, + y: 0 + }, + pixelOffsetTL: { + x: 0, + y: 0 + } + }]); + + }); + + test('line', () => { + expect(getIconQuads({ + top: -5.5, + right: 7.5, + bottom: 5.5, + left: -7.5, + image + }, 0, false, false)).toEqual([{ + tl: {x: -8.5, y: -6.5}, + tr: {x: 8.5, y: -6.5}, + bl: {x: -8.5, y: 6.5}, + br: {x: 8.5, y: 6.5}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: undefined, + glyphOffset: [0, 0], + isSDF: false, + sectionIndex: 0, + minFontScaleX: 0, + minFontScaleY: 0, + pixelOffsetBR: { + x: 0, + y: 0 + }, + pixelOffsetTL: { + x: 0, + y: 0 + } + }]); + + }); + +}); diff --git a/web/libraries/maplibre-gl/src/symbol/quads.ts b/web/libraries/maplibre-gl/src/symbol/quads.ts new file mode 100644 index 00000000..4b9f3f68 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/quads.ts @@ -0,0 +1,334 @@ +import Point from '@mapbox/point-geometry'; + +import {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf'; + +import type {Anchor} from './anchor'; +import type {PositionedIcon, Shaping} from './shaping'; +import {SHAPING_DEFAULT_OFFSET} from './shaping'; +import {IMAGE_PADDING} from '../render/image_atlas'; +import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; +import type {Feature} from '@maplibre/maplibre-gl-style-spec'; +import type {StyleImage} from '../style/style_image'; +import ONE_EM from './one_em'; +import {Rect} from '../render/glyph_atlas'; + +/** + * A textured quad for rendering a single icon or glyph. + * + * The zoom range the glyph can be shown is defined by minScale and maxScale. + * + * @param tl - The offset of the top left corner from the anchor. + * @param tr - The offset of the top right corner from the anchor. + * @param bl - The offset of the bottom left corner from the anchor. + * @param br - The offset of the bottom right corner from the anchor. + * @param tex - The texture coordinates. + */ +export type SymbolQuad = { + tl: Point; + tr: Point; + bl: Point; + br: Point; + tex: { + x: number; + y: number; + w: number; + h: number; + }; + pixelOffsetTL: Point; + pixelOffsetBR: Point; + writingMode: any | void; + glyphOffset: [number, number]; + sectionIndex: number; + isSDF: boolean; + minFontScaleX: number; + minFontScaleY: number; +}; + +// If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual +// pixels. The quad needs to be padded to account for this, otherwise they'll look slightly clipped +// on one edge in some cases. +const border = IMAGE_PADDING; + +/** + * Create the quads used for rendering an icon. + */ +export function getIconQuads( + shapedIcon: PositionedIcon, + iconRotate: number, + isSDFIcon: boolean, + hasIconTextFit: boolean +): Array { + const quads = []; + + const image = shapedIcon.image; + const pixelRatio = image.pixelRatio; + const imageWidth = image.paddedRect.w - 2 * border; + const imageHeight = image.paddedRect.h - 2 * border; + + const iconWidth = shapedIcon.right - shapedIcon.left; + const iconHeight = shapedIcon.bottom - shapedIcon.top; + + const stretchX = image.stretchX || [[0, imageWidth]]; + const stretchY = image.stretchY || [[0, imageHeight]]; + + const reduceRanges = (sum, range) => sum + range[1] - range[0]; + const stretchWidth = stretchX.reduce(reduceRanges, 0); + const stretchHeight = stretchY.reduce(reduceRanges, 0); + const fixedWidth = imageWidth - stretchWidth; + const fixedHeight = imageHeight - stretchHeight; + + let stretchOffsetX = 0; + let stretchContentWidth = stretchWidth; + let stretchOffsetY = 0; + let stretchContentHeight = stretchHeight; + let fixedOffsetX = 0; + let fixedContentWidth = fixedWidth; + let fixedOffsetY = 0; + let fixedContentHeight = fixedHeight; + + if (image.content && hasIconTextFit) { + const content = image.content; + stretchOffsetX = sumWithinRange(stretchX, 0, content[0]); + stretchOffsetY = sumWithinRange(stretchY, 0, content[1]); + stretchContentWidth = sumWithinRange(stretchX, content[0], content[2]); + stretchContentHeight = sumWithinRange(stretchY, content[1], content[3]); + fixedOffsetX = content[0] - stretchOffsetX; + fixedOffsetY = content[1] - stretchOffsetY; + fixedContentWidth = content[2] - content[0] - stretchContentWidth; + fixedContentHeight = content[3] - content[1] - stretchContentHeight; + } + + const makeBox = (left, top, right, bottom) => { + + const leftEm = getEmOffset(left.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left); + const leftPx = getPxOffset(left.fixed - fixedOffsetX, fixedContentWidth, left.stretch, stretchWidth); + + const topEm = getEmOffset(top.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top); + const topPx = getPxOffset(top.fixed - fixedOffsetY, fixedContentHeight, top.stretch, stretchHeight); + + const rightEm = getEmOffset(right.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left); + const rightPx = getPxOffset(right.fixed - fixedOffsetX, fixedContentWidth, right.stretch, stretchWidth); + + const bottomEm = getEmOffset(bottom.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top); + const bottomPx = getPxOffset(bottom.fixed - fixedOffsetY, fixedContentHeight, bottom.stretch, stretchHeight); + + const tl = new Point(leftEm, topEm); + const tr = new Point(rightEm, topEm); + const br = new Point(rightEm, bottomEm); + const bl = new Point(leftEm, bottomEm); + const pixelOffsetTL = new Point(leftPx / pixelRatio, topPx / pixelRatio); + const pixelOffsetBR = new Point(rightPx / pixelRatio, bottomPx / pixelRatio); + + const angle = iconRotate * Math.PI / 180; + + if (angle) { + const sin = Math.sin(angle), + cos = Math.cos(angle), + matrix = [cos, -sin, sin, cos]; + + tl._matMult(matrix); + tr._matMult(matrix); + bl._matMult(matrix); + br._matMult(matrix); + } + + const x1 = left.stretch + left.fixed; + const x2 = right.stretch + right.fixed; + const y1 = top.stretch + top.fixed; + const y2 = bottom.stretch + bottom.fixed; + + const subRect = { + x: image.paddedRect.x + border + x1, + y: image.paddedRect.y + border + y1, + w: x2 - x1, + h: y2 - y1 + }; + + const minFontScaleX = fixedContentWidth / pixelRatio / iconWidth; + const minFontScaleY = fixedContentHeight / pixelRatio / iconHeight; + + // Icon quad is padded, so texture coordinates also need to be padded. + return {tl, tr, bl, br, tex: subRect, writingMode: undefined, glyphOffset: [0, 0], sectionIndex: 0, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, isSDF: isSDFIcon}; + }; + + if (!hasIconTextFit || (!image.stretchX && !image.stretchY)) { + quads.push(makeBox( + {fixed: 0, stretch: -1}, + {fixed: 0, stretch: -1}, + {fixed: 0, stretch: imageWidth + 1}, + {fixed: 0, stretch: imageHeight + 1})); + } else { + const xCuts = stretchZonesToCuts(stretchX, fixedWidth, stretchWidth); + const yCuts = stretchZonesToCuts(stretchY, fixedHeight, stretchHeight); + + for (let xi = 0; xi < xCuts.length - 1; xi++) { + const x1 = xCuts[xi]; + const x2 = xCuts[xi + 1]; + for (let yi = 0; yi < yCuts.length - 1; yi++) { + const y1 = yCuts[yi]; + const y2 = yCuts[yi + 1]; + quads.push(makeBox(x1, y1, x2, y2)); + } + } + } + + return quads; +} + +function sumWithinRange(ranges, min, max) { + let sum = 0; + for (const range of ranges) { + sum += Math.max(min, Math.min(max, range[1])) - Math.max(min, Math.min(max, range[0])); + } + return sum; +} + +function stretchZonesToCuts(stretchZones, fixedSize, stretchSize) { + const cuts = [{fixed: -border, stretch: 0}]; + + for (const [c1, c2] of stretchZones) { + const last = cuts[cuts.length - 1]; + cuts.push({ + fixed: c1 - last.stretch, + stretch: last.stretch + }); + cuts.push({ + fixed: c1 - last.stretch, + stretch: last.stretch + (c2 - c1) + }); + } + cuts.push({ + fixed: fixedSize + border, + stretch: stretchSize + }); + return cuts; +} + +function getEmOffset(stretchOffset, stretchSize, iconSize, iconOffset) { + return stretchOffset / stretchSize * iconSize + iconOffset; +} + +function getPxOffset(fixedOffset, fixedSize, stretchOffset, stretchSize) { + return fixedOffset - fixedSize * stretchOffset / stretchSize; +} + +/** + * Create the quads used for rendering a text label. + */ +export function getGlyphQuads( + anchor: Anchor, + shaping: Shaping, + textOffset: [number, number], + layer: SymbolStyleLayer, + alongLine: boolean, + feature: Feature, + imageMap: {[_: string]: StyleImage}, + allowVerticalPlacement: boolean +): Array { + + const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}) * Math.PI / 180; + const quads = []; + + for (const line of shaping.positionedLines) { + for (const positionedGlyph of line.positionedGlyphs) { + if (!positionedGlyph.rect) continue; + const textureRect: Rect = positionedGlyph.rect || {} as Rect; + + // The rects have an additional buffer that is not included in their size. + const glyphPadding = 1.0; + let rectBuffer = GLYPH_PBF_BORDER + glyphPadding; + let isSDF = true; + let pixelRatio = 1.0; + let lineOffset = 0.0; + + const rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical; + const halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2; + + // Align images and scaled glyphs in the middle of a vertical line. + if (allowVerticalPlacement && shaping.verticalizable) { + const scaledGlyphOffset = (positionedGlyph.scale - 1) * ONE_EM; + const imageOffset = (ONE_EM - positionedGlyph.metrics.width * positionedGlyph.scale) / 2; + lineOffset = line.lineOffset / 2 - (positionedGlyph.imageName ? -imageOffset : scaledGlyphOffset); + } + + if (positionedGlyph.imageName) { + const image = imageMap[positionedGlyph.imageName]; + isSDF = image.sdf; + pixelRatio = image.pixelRatio; + rectBuffer = IMAGE_PADDING / pixelRatio; + } + + const glyphOffset = alongLine ? + [positionedGlyph.x + halfAdvance, positionedGlyph.y] : + [0, 0]; + + let builtInOffset: [number, number] = alongLine ? + [0, 0] : + [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1] - lineOffset]; + + let verticalizedLabelOffset = [0, 0] as [number, number]; + if (rotateVerticalGlyph) { + // Vertical POI labels that are rotated 90deg CW and whose glyphs must preserve upright orientation + // need to be rotated 90deg CCW. After a quad is rotated, it is translated to the original built-in offset. + verticalizedLabelOffset = builtInOffset; + builtInOffset = [0, 0]; + } + + const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1; + + const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0]; + const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1]; + const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio; + const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio; + + const tl = new Point(x1, y1); + const tr = new Point(x2, y1); + const bl = new Point(x1, y2); + const br = new Point(x2, y2); + + if (rotateVerticalGlyph) { + // Vertical-supporting glyphs are laid out in 24x24 point boxes (1 square em) + // In horizontal orientation, the y values for glyphs are below the midline + // and we use a "yOffset" of -17 to pull them up to the middle. + // By rotating counter-clockwise around the point at the center of the left + // edge of a 24x24 layout box centered below the midline, we align the center + // of the glyphs with the horizontal midline, so the yOffset is no longer + // necessary, but we also pull the glyph to the left along the x axis. + // The y coordinate includes baseline yOffset, thus needs to be accounted + // for when glyph is rotated and translated. + const center = new Point(-halfAdvance, halfAdvance - SHAPING_DEFAULT_OFFSET); + const verticalRotation = -Math.PI / 2; + + // xHalfWidthOffsetCorrection is a difference between full-width and half-width + // advance, should be 0 for full-width glyphs and will pull up half-width glyphs. + const xHalfWidthOffsetCorrection = ONE_EM / 2 - halfAdvance; + const yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0.0; + const halfWidthOffsetCorrection = new Point(5 - SHAPING_DEFAULT_OFFSET - xHalfWidthOffsetCorrection, -yImageOffsetCorrection); + const verticalOffsetCorrection = new Point(...verticalizedLabelOffset); + tl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + tr._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + bl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + br._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection); + } + + if (textRotate) { + const sin = Math.sin(textRotate), + cos = Math.cos(textRotate), + matrix = [cos, -sin, sin, cos]; + + tl._matMult(matrix); + tr._matMult(matrix); + bl._matMult(matrix); + br._matMult(matrix); + } + + const pixelOffsetTL = new Point(0, 0); + const pixelOffsetBR = new Point(0, 0); + const minFontScaleX = 0; + const minFontScaleY = 0; + quads.push({tl, tr, bl, br, tex: textureRect, writingMode: shaping.writingMode, glyphOffset, sectionIndex: positionedGlyph.sectionIndex, isSDF, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY}); + } + } + + return quads; +} diff --git a/web/libraries/maplibre-gl/src/symbol/shaping.ts b/web/libraries/maplibre-gl/src/symbol/shaping.ts new file mode 100644 index 00000000..acb3f6ab --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/shaping.ts @@ -0,0 +1,859 @@ +import { + charHasUprightVerticalOrientation, + charAllowsIdeographicBreaking, + charInComplexShapingScript +} from '../util/script_detection'; +import {verticalizePunctuation} from '../util/verticalize_punctuation'; +import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin'; +import ONE_EM from './one_em'; +import {warnOnce} from '../util/util'; + +import type {StyleGlyph, GlyphMetrics} from '../style/style_glyph'; +import {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf'; +import type {ImagePosition} from '../render/image_atlas'; +import {IMAGE_PADDING} from '../render/image_atlas'; +import type {Rect, GlyphPosition} from '../render/glyph_atlas'; +import {Formatted, FormattedSection} from '@maplibre/maplibre-gl-style-spec'; + +enum WritingMode { + none = 0, + horizontal = 1, + vertical = 2, + horizontalOnly = 3 +} + +const SHAPING_DEFAULT_OFFSET = -17; +export {shapeText, shapeIcon, fitIconToText, getAnchorAlignment, WritingMode, SHAPING_DEFAULT_OFFSET}; + +// The position of a glyph relative to the text's anchor point. +export type PositionedGlyph = { + glyph: number; + imageName: string | null; + x: number; + y: number; + vertical: boolean; + scale: number; + fontStack: string; + sectionIndex: number; + metrics: GlyphMetrics; + rect: Rect | null; +}; + +export type PositionedLine = { + positionedGlyphs: Array; + lineOffset: number; +}; + +// A collection of positioned glyphs and some metadata +export type Shaping = { + positionedLines: Array; + top: number; + bottom: number; + left: number; + right: number; + writingMode: WritingMode.horizontal | WritingMode.vertical; + text: string; + iconsInText: boolean; + verticalizable: boolean; +}; + +function isEmpty(positionedLines: Array) { + for (const line of positionedLines) { + if (line.positionedGlyphs.length !== 0) { + return false; + } + } + return true; +} + +export type SymbolAnchor = 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; +export type TextJustify = 'left' | 'center' | 'right'; + +// Max number of images in label is 6401 U+E000–U+F8FF that covers +// Basic Multilingual Plane Unicode Private Use Area (PUA). +const PUAbegin = 0xE000; +const PUAend = 0xF8FF; + +class SectionOptions { + // Text options + scale: number; + fontStack: string; + // Image options + imageName: string | null; + + constructor() { + this.scale = 1.0; + this.fontStack = ''; + this.imageName = null; + } + + static forText(scale: number | null, fontStack: string) { + const textOptions = new SectionOptions(); + textOptions.scale = scale || 1; + textOptions.fontStack = fontStack; + return textOptions; + } + + static forImage(imageName: string) { + const imageOptions = new SectionOptions(); + imageOptions.imageName = imageName; + return imageOptions; + } + +} + +class TaggedString { + text: string; + sectionIndex: Array; // maps each character in 'text' to its corresponding entry in 'sections' + sections: Array; + imageSectionID: number | null; + + constructor() { + this.text = ''; + this.sectionIndex = []; + this.sections = []; + this.imageSectionID = null; + } + + static fromFeature(text: Formatted, defaultFontStack: string) { + const result = new TaggedString(); + for (let i = 0; i < text.sections.length; i++) { + const section = text.sections[i]; + if (!section.image) { + result.addTextSection(section, defaultFontStack); + } else { + result.addImageSection(section); + } + } + return result; + } + + length(): number { + return this.text.length; + } + + getSection(index: number): SectionOptions { + return this.sections[this.sectionIndex[index]]; + } + + getSectionIndex(index: number): number { + return this.sectionIndex[index]; + } + + getCharCode(index: number): number { + return this.text.charCodeAt(index); + } + + verticalizePunctuation() { + this.text = verticalizePunctuation(this.text); + } + + trim() { + let beginningWhitespace = 0; + for (let i = 0; + i < this.text.length && whitespace[this.text.charCodeAt(i)]; + i++) { + beginningWhitespace++; + } + let trailingWhitespace = this.text.length; + for (let i = this.text.length - 1; + i >= 0 && i >= beginningWhitespace && whitespace[this.text.charCodeAt(i)]; + i--) { + trailingWhitespace--; + } + this.text = this.text.substring(beginningWhitespace, trailingWhitespace); + this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace); + } + + substring(start: number, end: number): TaggedString { + const substring = new TaggedString(); + substring.text = this.text.substring(start, end); + substring.sectionIndex = this.sectionIndex.slice(start, end); + substring.sections = this.sections; + return substring; + } + + toString(): string { + return this.text; + } + + getMaxScale() { + return this.sectionIndex.reduce((max, index) => Math.max(max, this.sections[index].scale), 0); + } + + addTextSection(section: FormattedSection, defaultFontStack: string) { + this.text += section.text; + this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack)); + const index = this.sections.length - 1; + for (let i = 0; i < section.text.length; ++i) { + this.sectionIndex.push(index); + } + } + + addImageSection(section: FormattedSection) { + const imageName = section.image ? section.image.name : ''; + if (imageName.length === 0) { + warnOnce('Can\'t add FormattedSection with an empty image.'); + return; + } + + const nextImageSectionCharCode = this.getNextImageSectionCharCode(); + if (!nextImageSectionCharCode) { + warnOnce(`Reached maximum number of images ${PUAend - PUAbegin + 2}`); + return; + } + + this.text += String.fromCharCode(nextImageSectionCharCode); + this.sections.push(SectionOptions.forImage(imageName)); + this.sectionIndex.push(this.sections.length - 1); + } + + getNextImageSectionCharCode(): number | null { + if (!this.imageSectionID) { + this.imageSectionID = PUAbegin; + return this.imageSectionID; + } + + if (this.imageSectionID >= PUAend) return null; + return ++this.imageSectionID; + } +} + +function breakLines(input: TaggedString, lineBreakPoints: Array): Array { + const lines = []; + const text = input.text; + let start = 0; + for (const lineBreak of lineBreakPoints) { + lines.push(input.substring(start, lineBreak)); + start = lineBreak; + } + + if (start < text.length) { + lines.push(input.substring(start, text.length)); + } + return lines; +} + +function shapeText( + text: Formatted, + glyphMap: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }, + glyphPositions: { + [_: string]: { + [_: number]: GlyphPosition; + }; + }, + imagePositions: {[_: string]: ImagePosition}, + defaultFontStack: string, + maxWidth: number, + lineHeight: number, + textAnchor: SymbolAnchor, + textJustify: TextJustify, + spacing: number, + translate: [number, number], + writingMode: WritingMode.horizontal | WritingMode.vertical, + allowVerticalPlacement: boolean, + symbolPlacement: string, + layoutTextSize: number, + layoutTextSizeThisZoom: number +): Shaping | false { + const logicalInput = TaggedString.fromFeature(text, defaultFontStack); + + if (writingMode === WritingMode.vertical) { + logicalInput.verticalizePunctuation(); + } + + let lines: Array; + + const {processBidirectionalText, processStyledBidirectionalText} = rtlTextPlugin; + if (processBidirectionalText && logicalInput.sections.length === 1) { + // Bidi doesn't have to be style-aware + lines = []; + const untaggedLines = + processBidirectionalText(logicalInput.toString(), + determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize)); + for (const line of untaggedLines) { + const taggedLine = new TaggedString(); + taggedLine.text = line; + taggedLine.sections = logicalInput.sections; + for (let i = 0; i < line.length; i++) { + taggedLine.sectionIndex.push(0); + } + lines.push(taggedLine); + } + } else if (processStyledBidirectionalText) { + // Need version of mapbox-gl-rtl-text with style support for combining RTL text + // with formatting + lines = []; + const processedLines = + processStyledBidirectionalText(logicalInput.text, + logicalInput.sectionIndex, + determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize)); + for (const line of processedLines) { + const taggedLine = new TaggedString(); + taggedLine.text = line[0]; + taggedLine.sectionIndex = line[1]; + taggedLine.sections = logicalInput.sections; + lines.push(taggedLine); + } + } else { + lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize)); + } + + const positionedLines = []; + const shaping = { + positionedLines, + text: logicalInput.toString(), + top: translate[1], + bottom: translate[1], + left: translate[0], + right: translate[0], + writingMode, + iconsInText: false, + verticalizable: false + }; + + shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom); + if (isEmpty(positionedLines)) return false; + + return shaping; +} + +// using computed properties due to https://github.com/facebook/flow/issues/380 +/* eslint no-useless-computed-key: 0 */ + +const whitespace: { + [_: number]: boolean; +} = { + [0x09]: true, // tab + [0x0a]: true, // newline + [0x0b]: true, // vertical tab + [0x0c]: true, // form feed + [0x0d]: true, // carriage return + [0x20]: true, // space +}; + +const breakable: { + [_: number]: boolean; +} = { + [0x0a]: true, // newline + [0x20]: true, // space + [0x26]: true, // ampersand + [0x28]: true, // left parenthesis + [0x29]: true, // right parenthesis + [0x2b]: true, // plus sign + [0x2d]: true, // hyphen-minus + [0x2f]: true, // solidus + [0xad]: true, // soft hyphen + [0xb7]: true, // middle dot + [0x200b]: true, // zero-width space + [0x2010]: true, // hyphen + [0x2013]: true, // en dash + [0x2027]: true // interpunct + // Many other characters may be reasonable breakpoints + // Consider "neutral orientation" characters at scriptDetection.charHasNeutralVerticalOrientation + // See https://github.com/mapbox/mapbox-gl-js/issues/3658 +}; + +function getGlyphAdvance( + codePoint: number, + section: SectionOptions, + glyphMap: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }, + imagePositions: {[_: string]: ImagePosition}, + spacing: number, + layoutTextSize: number +): number { + if (!section.imageName) { + const positions = glyphMap[section.fontStack]; + const glyph = positions && positions[codePoint]; + if (!glyph) return 0; + return glyph.metrics.advance * section.scale + spacing; + } else { + const imagePosition = imagePositions[section.imageName]; + if (!imagePosition) return 0; + return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing; + } +} + +function determineAverageLineWidth(logicalInput: TaggedString, + spacing: number, + maxWidth: number, + glyphMap: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }, + imagePositions: {[_: string]: ImagePosition}, + layoutTextSize: number) { + let totalWidth = 0; + + for (let index = 0; index < logicalInput.length(); index++) { + const section = logicalInput.getSection(index); + totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize); + } + + const lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth)); + return totalWidth / lineCount; +} + +function calculateBadness(lineWidth: number, + targetWidth: number, + penalty: number, + isLastBreak: boolean) { + const raggedness = Math.pow(lineWidth - targetWidth, 2); + if (isLastBreak) { + // Favor finals lines shorter than average over longer than average + if (lineWidth < targetWidth) { + return raggedness / 2; + } else { + return raggedness * 2; + } + } + + return raggedness + Math.abs(penalty) * penalty; +} + +function calculatePenalty(codePoint: number, nextCodePoint: number, penalizableIdeographicBreak: boolean) { + let penalty = 0; + // Force break on newline + if (codePoint === 0x0a) { + penalty -= 10000; + } + // Penalize breaks between characters that allow ideographic breaking because + // they are less preferable than breaks at spaces (or zero width spaces). + if (penalizableIdeographicBreak) { + penalty += 150; + } + + // Penalize open parenthesis at end of line + if (codePoint === 0x28 || codePoint === 0xff08) { + penalty += 50; + } + + // Penalize close parenthesis at beginning of line + if (nextCodePoint === 0x29 || nextCodePoint === 0xff09) { + penalty += 50; + } + return penalty; +} + +type Break = { + index: number; + x: number; + priorBreak: Break; + badness: number; +}; + +function evaluateBreak( + breakIndex: number, + breakX: number, + targetWidth: number, + potentialBreaks: Array, + penalty: number, + isLastBreak: boolean +): Break { + // We could skip evaluating breaks where the line length (breakX - priorBreak.x) > maxWidth + // ...but in fact we allow lines longer than maxWidth (if there's no break points) + // ...and when targetWidth and maxWidth are close, strictly enforcing maxWidth can give + // more lopsided results. + + let bestPriorBreak: Break = null; + let bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak); + + for (const potentialBreak of potentialBreaks) { + const lineWidth = breakX - potentialBreak.x; + const breakBadness = + calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness; + if (breakBadness <= bestBreakBadness) { + bestPriorBreak = potentialBreak; + bestBreakBadness = breakBadness; + } + } + + return { + index: breakIndex, + x: breakX, + priorBreak: bestPriorBreak, + badness: bestBreakBadness + }; +} + +function leastBadBreaks(lastLineBreak?: Break | null): Array { + if (!lastLineBreak) { + return []; + } + return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index); +} + +function determineLineBreaks( + logicalInput: TaggedString, + spacing: number, + maxWidth: number, + glyphMap: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }, + imagePositions: {[_: string]: ImagePosition}, + symbolPlacement: string, + layoutTextSize: number +): Array { + if (symbolPlacement !== 'point') + return []; + + if (!logicalInput) + return []; + + const potentialLineBreaks = []; + const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize); + + const hasServerSuggestedBreakpoints = logicalInput.text.indexOf('\u200b') >= 0; + + let currentX = 0; + + for (let i = 0; i < logicalInput.length(); i++) { + const section = logicalInput.getSection(i); + const codePoint = logicalInput.getCharCode(i); + if (!whitespace[codePoint]) currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize); + + // Ideographic characters, spaces, and word-breaking punctuation that often appear without + // surrounding spaces. + if ((i < logicalInput.length() - 1)) { + const ideographicBreak = charAllowsIdeographicBreaking(codePoint); + if (breakable[codePoint] || ideographicBreak || section.imageName) { + + potentialLineBreaks.push( + evaluateBreak( + i + 1, + currentX, + targetWidth, + potentialLineBreaks, + calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints), + false)); + } + } + } + + return leastBadBreaks( + evaluateBreak( + logicalInput.length(), + currentX, + targetWidth, + potentialLineBreaks, + 0, + true)); +} + +function getAnchorAlignment(anchor: SymbolAnchor) { + let horizontalAlign = 0.5, verticalAlign = 0.5; + + switch (anchor) { + case 'right': + case 'top-right': + case 'bottom-right': + horizontalAlign = 1; + break; + case 'left': + case 'top-left': + case 'bottom-left': + horizontalAlign = 0; + break; + } + + switch (anchor) { + case 'bottom': + case 'bottom-right': + case 'bottom-left': + verticalAlign = 1; + break; + case 'top': + case 'top-right': + case 'top-left': + verticalAlign = 0; + break; + } + + return {horizontalAlign, verticalAlign}; +} + +function shapeLines(shaping: Shaping, + glyphMap: { + [_: string]: { + [_: number]: StyleGlyph; + }; + }, + glyphPositions: { + [_: string]: { + [_: number]: GlyphPosition; + }; + }, + imagePositions: {[_: string]: ImagePosition}, + lines: Array, + lineHeight: number, + textAnchor: SymbolAnchor, + textJustify: TextJustify, + writingMode: WritingMode.horizontal | WritingMode.vertical, + spacing: number, + allowVerticalPlacement: boolean, + layoutTextSizeThisZoom: number) { + + let x = 0; + let y = SHAPING_DEFAULT_OFFSET; + + let maxLineLength = 0; + let maxLineHeight = 0; + + const justify = + textJustify === 'right' ? 1 : + textJustify === 'left' ? 0 : 0.5; + + let lineIndex = 0; + for (const line of lines) { + line.trim(); + + const lineMaxScale = line.getMaxScale(); + const maxLineOffset = (lineMaxScale - 1) * ONE_EM; + const positionedLine = {positionedGlyphs: [], lineOffset: 0}; + shaping.positionedLines[lineIndex] = positionedLine; + const positionedGlyphs = positionedLine.positionedGlyphs; + let lineOffset = 0.0; + + if (!line.length()) { + y += lineHeight; // Still need a line feed after empty line + ++lineIndex; + continue; + } + + for (let i = 0; i < line.length(); i++) { + const section = line.getSection(i); + const sectionIndex = line.getSectionIndex(i); + const codePoint = line.getCharCode(i); + let baselineOffset = 0.0; + let metrics = null; + let rect = null; + let imageName = null; + let verticalAdvance = ONE_EM; + const vertical = !(writingMode === WritingMode.horizontal || + // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled. + (!allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint)) || + // If vertical placement is enabled, don't verticalize glyphs that + // are from complex text layout script, or whitespaces. + (allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint)))); + + if (!section.imageName) { + const positions = glyphPositions[section.fontStack]; + const glyphPosition = positions && positions[codePoint]; + if (glyphPosition && glyphPosition.rect) { + rect = glyphPosition.rect; + metrics = glyphPosition.metrics; + } else { + const glyphs = glyphMap[section.fontStack]; + const glyph = glyphs && glyphs[codePoint]; + if (!glyph) continue; + metrics = glyph.metrics; + } + + // We don't know the baseline, but since we're laying out + // at 24 points, we can calculate how much it will move when + // we scale up or down. + baselineOffset = (lineMaxScale - section.scale) * ONE_EM; + } else { + const imagePosition = imagePositions[section.imageName]; + if (!imagePosition) continue; + imageName = section.imageName; + shaping.iconsInText = shaping.iconsInText || true; + rect = imagePosition.paddedRect; + const size = imagePosition.displaySize; + // If needed, allow to set scale factor for an image using + // alias "image-scale" that could be alias for "font-scale" + // when FormattedSection is an image section. + section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom; + + metrics = {width: size[0], + height: size[1], + left: IMAGE_PADDING, + top: -GLYPH_PBF_BORDER, + advance: vertical ? size[1] : size[0]}; + + // Difference between one EM and an image size. + // Aligns bottom of an image to a baseline level. + const imageOffset = ONE_EM - size[1] * section.scale; + baselineOffset = maxLineOffset + imageOffset; + verticalAdvance = metrics.advance; + + // Difference between height of an image and one EM at max line scale. + // Pushes current line down if an image size is over 1 EM at max line scale. + const offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale : + size[1] * section.scale - ONE_EM * lineMaxScale; + if (offset > 0 && offset > lineOffset) { + lineOffset = offset; + } + } + + if (!vertical) { + positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect}); + x += metrics.advance * section.scale + spacing; + } else { + shaping.verticalizable = true; + positionedGlyphs.push({glyph: codePoint, imageName, x, y: y + baselineOffset, vertical, scale: section.scale, fontStack: section.fontStack, sectionIndex, metrics, rect}); + x += verticalAdvance * section.scale + spacing; + } + } + + // Only justify if we placed at least one glyph + if (positionedGlyphs.length !== 0) { + const lineLength = x - spacing; + maxLineLength = Math.max(lineLength, maxLineLength); + justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset); + } + + x = 0; + const currentLineHeight = lineHeight * lineMaxScale + lineOffset; + positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset); + y += currentLineHeight; + maxLineHeight = Math.max(currentLineHeight, maxLineHeight); + ++lineIndex; + } + + // Calculate the bounding box and justify / align text block. + const height = y - SHAPING_DEFAULT_OFFSET; + const {horizontalAlign, verticalAlign} = getAnchorAlignment(textAnchor); + align(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length); + + shaping.top += -verticalAlign * height; + shaping.bottom = shaping.top + height; + shaping.left += -horizontalAlign * maxLineLength; + shaping.right = shaping.left + maxLineLength; +} + +// justify right = 1, left = 0, center = 0.5 +function justifyLine(positionedGlyphs: Array, + start: number, + end: number, + justify: 1 | 0 | 0.5, + lineOffset: number) { + if (!justify && !lineOffset) + return; + + const lastPositionedGlyph = positionedGlyphs[end]; + const lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale; + const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify; + + for (let j = start; j <= end; j++) { + positionedGlyphs[j].x -= lineIndent; + positionedGlyphs[j].y += lineOffset; + } +} + +function align(positionedLines: Array, + justify: number, + horizontalAlign: number, + verticalAlign: number, + maxLineLength: number, + maxLineHeight: number, + lineHeight: number, + blockHeight: number, + lineCount: number) { + const shiftX = (justify - horizontalAlign) * maxLineLength; + let shiftY = 0; + + if (maxLineHeight !== lineHeight) { + shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET; + } else { + shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight; + } + + for (const line of positionedLines) { + for (const positionedGlyph of line.positionedGlyphs) { + positionedGlyph.x += shiftX; + positionedGlyph.y += shiftY; + } + } +} + +export type PositionedIcon = { + image: ImagePosition; + top: number; + bottom: number; + left: number; + right: number; + collisionPadding?: [number, number, number, number]; +}; + +function shapeIcon( + image: ImagePosition, + iconOffset: [number, number], + iconAnchor: SymbolAnchor +): PositionedIcon { + const {horizontalAlign, verticalAlign} = getAnchorAlignment(iconAnchor); + const dx = iconOffset[0]; + const dy = iconOffset[1]; + const x1 = dx - image.displaySize[0] * horizontalAlign; + const x2 = x1 + image.displaySize[0]; + const y1 = dy - image.displaySize[1] * verticalAlign; + const y2 = y1 + image.displaySize[1]; + return {image, top: y1, bottom: y2, left: x1, right: x2}; +} + +function fitIconToText( + shapedIcon: PositionedIcon, + shapedText: Shaping, + textFit: string, + padding: [number, number, number, number], + iconOffset: [number, number], + fontScale: number +): PositionedIcon { + + const image = shapedIcon.image; + + let collisionPadding; + if (image.content) { + const content = image.content; + const pixelRatio = image.pixelRatio || 1; + collisionPadding = [ + content[0] / pixelRatio, + content[1] / pixelRatio, + image.displaySize[0] - content[2] / pixelRatio, + image.displaySize[1] - content[3] / pixelRatio + ]; + } + + // We don't respect the icon-anchor, because icon-text-fit is set. Instead, + // the icon will be centered on the text, then stretched in the given + // dimensions. + + const textLeft = shapedText.left * fontScale; + const textRight = shapedText.right * fontScale; + + let top, right, bottom, left; + if (textFit === 'width' || textFit === 'both') { + // Stretched horizontally to the text width + left = iconOffset[0] + textLeft - padding[3]; + right = iconOffset[0] + textRight + padding[1]; + } else { + // Centered on the text + left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2; + right = left + image.displaySize[0]; + } + + const textTop = shapedText.top * fontScale; + const textBottom = shapedText.bottom * fontScale; + if (textFit === 'height' || textFit === 'both') { + // Stretched vertically to the text height + top = iconOffset[1] + textTop - padding[0]; + bottom = iconOffset[1] + textBottom + padding[2]; + } else { + // Centered on the text + top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2; + bottom = top + image.displaySize[1]; + } + + return {image, top, right, bottom, left, collisionPadding}; +} diff --git a/web/libraries/maplibre-gl/src/symbol/symbol_layout.ts b/web/libraries/maplibre-gl/src/symbol/symbol_layout.ts new file mode 100644 index 00000000..bd37eb42 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/symbol_layout.ts @@ -0,0 +1,739 @@ +import {Anchor} from './anchor'; + +import {getAnchors, getCenterAnchor} from './get_anchors'; +import {clipLine} from './clip_line'; +import {shapeText, shapeIcon, WritingMode, fitIconToText} from './shaping'; +import {getGlyphQuads, getIconQuads} from './quads'; +import {CollisionFeature} from './collision_feature'; +import {warnOnce} from '../util/util'; +import { + allowsVerticalWritingMode, + allowsLetterSpacing +} from '../util/script_detection'; +import {findPoleOfInaccessibility} from '../util/find_pole_of_inaccessibility'; +import {classifyRings} from '../util/classify_rings'; +import {EXTENT} from '../data/extent'; +import {SymbolBucket} from '../data/bucket/symbol_bucket'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {SIZE_PACK_FACTOR, MAX_PACKED_SIZE, MAX_GLYPH_ICON_SIZE} from './symbol_size'; +import ONE_EM from './one_em'; +import type {CanonicalTileID} from '../source/tile_id'; +import type {Shaping, PositionedIcon, TextJustify} from './shaping'; +import type {CollisionBoxArray, TextAnchorOffsetArray} from '../data/array_types.g'; +import type {SymbolFeature} from '../data/bucket/symbol_bucket'; +import type {StyleImage} from '../style/style_image'; +import type {StyleGlyph} from '../style/style_glyph'; +import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; +import type {ImagePosition} from '../render/image_atlas'; +import type {GlyphPosition} from '../render/glyph_atlas'; +import type {PossiblyEvaluatedPropertyValue} from '../style/properties'; + +import Point from '@mapbox/point-geometry'; +import murmur3 from 'murmurhash-js'; +import {getIconPadding, SymbolPadding} from '../style/style_layer/symbol_style_layer'; +import {VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec'; +import {getTextVariableAnchorOffset, evaluateVariableOffset, INVALID_TEXT_OFFSET, TextAnchor, TextAnchorEnum} from '../style/style_layer/variable_text_anchor'; + +// The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and +// `icon-size` at up to three: +// +// 1. `text-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `text-size` +// expressions, and to calculate the box dimensions for icon-text-fit. +// 2. `icon-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `icon-size` +// expressions. +// 3. `text-size` and `icon-size` at the zoom level of the bucket, plus one. Used to calculate collision boxes. +// 4. `text-size` at zoom level 18. Used for something line-symbol-placement-related. +// 5. For composite `*-size` expressions: two zoom levels of curve stops that "cover" the zoom level of the +// bucket. These go into a vertex buffer and are used by the shader to interpolate the size at render time. +// +// (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below. +// +type Sizes = { + layoutTextSize: PossiblyEvaluatedPropertyValue; // (3), + layoutIconSize: PossiblyEvaluatedPropertyValue; // (3), + textMaxSize: PossiblyEvaluatedPropertyValue; // (4), + compositeTextSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5), + compositeIconSizes: [PossiblyEvaluatedPropertyValue, PossiblyEvaluatedPropertyValue]; // (5) +}; + +type ShapedTextOrientations = { + vertical: Shaping | false; + horizontal: Record; +}; + +export function performSymbolLayout(args: { + bucket: SymbolBucket; + glyphMap: { + [_: string]: { + [x: number]: StyleGlyph; + }; + }; + glyphPositions: { + [_: string]: { + [x: number]: GlyphPosition; + }; + }; + imageMap: {[_: string]: StyleImage}; + imagePositions: {[_: string]: ImagePosition}; + showCollisionBoxes: boolean; + canonical: CanonicalTileID; +}) { + args.bucket.createArrays(); + + const tileSize = 512 * args.bucket.overscaling; + args.bucket.tilePixelRatio = EXTENT / tileSize; + args.bucket.compareText = {}; + args.bucket.iconsNeedLinear = false; + + const layer = args.bucket.layers[0]; + const layout = layer.layout; + const unevaluatedLayoutValues = layer._unevaluatedLayout._values; + + const sizes: Sizes = { + // Filled in below, if *SizeData.kind is 'composite' + // compositeIconSizes: undefined, + // compositeTextSizes: undefined, + layoutIconSize: unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical), + layoutTextSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(args.bucket.zoom + 1), args.canonical), + textMaxSize: unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18)) + } as Sizes; + + if (args.bucket.textSizeData.kind === 'composite') { + const {minZoom, maxZoom} = args.bucket.textSizeData; + sizes.compositeTextSizes = [ + unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical), + unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical) + ]; + } + + if (args.bucket.iconSizeData.kind === 'composite') { + const {minZoom, maxZoom} = args.bucket.iconSizeData; + sizes.compositeIconSizes = [ + unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(minZoom), args.canonical), + unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(maxZoom), args.canonical) + ]; + } + + const lineHeight = layout.get('text-line-height') * ONE_EM; + const textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point'; + const keepUpright = layout.get('text-keep-upright'); + const textSize = layout.get('text-size'); + + for (const feature of args.bucket.features) { + const fontstack = layout.get('text-font').evaluate(feature, {}, args.canonical).join(','); + const layoutTextSizeThisZoom = textSize.evaluate(feature, {}, args.canonical); + const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, args.canonical); + const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, args.canonical); + + const shapedTextOrientations: ShapedTextOrientations = { + horizontal: {} as Record, + vertical: undefined + }; + const text = feature.text; + let textOffset: [number, number] = [0, 0]; + if (text) { + const unformattedText = text.toString(); + const spacing = layout.get('text-letter-spacing').evaluate(feature, {}, args.canonical) * ONE_EM; + const spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0; + + const textAnchor = layout.get('text-anchor').evaluate(feature, {}, args.canonical); + const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, args.canonical); + + if (!variableAnchorOffset) { + const radialOffset = layout.get('text-radial-offset').evaluate(feature, {}, args.canonical); + // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector + // is calculated at placement time instead of layout time + if (radialOffset) { + // The style spec says don't use `text-offset` and `text-radial-offset` together + // but doesn't actually specify what happens if you use both. We go with the radial offset. + textOffset = evaluateVariableOffset(textAnchor, [radialOffset * ONE_EM, INVALID_TEXT_OFFSET]); + } else { + textOffset = (layout.get('text-offset').evaluate(feature, {}, args.canonical).map(t => t * ONE_EM) as [number, number]); + } + } + + let textJustify = textAlongLine ? + 'center' : + layout.get('text-justify').evaluate(feature, {}, args.canonical); + + const symbolPlacement = layout.get('symbol-placement'); + const maxWidth = symbolPlacement === 'point' ? + layout.get('text-max-width').evaluate(feature, {}, args.canonical) * ONE_EM : + 0; + + const addVerticalShapingForPointLabelIfNeeded = () => { + if (args.bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) { + // Vertical POI label placement is meant to be used for scripts that support vertical + // writing mode, thus, default left justification is used. If Latin + // scripts would need to be supported, this should take into account other justifications. + shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, + 'left', spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + } + }; + + // If this layer uses text-variable-anchor, generate shapings for all justification possibilities. + if (!textAlongLine && variableAnchorOffset) { + const justifications = new Set(); + + if (textJustify === 'auto') { + for (let i = 0; i < variableAnchorOffset.values.length; i += 2) { + justifications.add(getAnchorJustification(variableAnchorOffset.values[i] as TextAnchor)); + } + } else { + justifications.add(textJustify); + } + + let singleLine = false; + for (const justification of justifications) { + if (shapedTextOrientations.horizontal[justification]) continue; + if (singleLine) { + // If the shaping for the first justification was only a single line, we + // can re-use it for the other justifications + shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0]; + } else { + // If using text-variable-anchor for the layer, we use a center anchor for all shapings and apply + // the offsets for the anchor in the placement step. + const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, 'center', + justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + if (shaping) { + shapedTextOrientations.horizontal[justification] = shaping; + singleLine = shaping.positionedLines.length === 1; + } + } + } + + addVerticalShapingForPointLabelIfNeeded(); + } else { + if (textJustify === 'auto') { + textJustify = getAnchorJustification(textAnchor); + } + + // Horizontal point or line label. + const shaping = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed, + textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + if (shaping) shapedTextOrientations.horizontal[textJustify] = shaping; + + // Vertical point label (if allowVerticalPlacement is enabled). + addVerticalShapingForPointLabelIfNeeded(); + + // Verticalized line label. + if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) { + shapedTextOrientations.vertical = shapeText(text, args.glyphMap, args.glyphPositions, args.imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, + spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom); + } + } + } + + let shapedIcon; + let isSDFIcon = false; + if (feature.icon && feature.icon.name) { + const image = args.imageMap[feature.icon.name]; + if (image) { + shapedIcon = shapeIcon( + args.imagePositions[feature.icon.name], + layout.get('icon-offset').evaluate(feature, {}, args.canonical), + layout.get('icon-anchor').evaluate(feature, {}, args.canonical)); + // null/undefined SDF property treated same as default (false) + isSDFIcon = !!image.sdf; + if (args.bucket.sdfIcons === undefined) { + args.bucket.sdfIcons = isSDFIcon; + } else if (args.bucket.sdfIcons !== isSDFIcon) { + warnOnce('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer'); + } + if (image.pixelRatio !== args.bucket.pixelRatio) { + args.bucket.iconsNeedLinear = true; + } else if (layout.get('icon-rotate').constantOr(1) !== 0) { + args.bucket.iconsNeedLinear = true; + } + } + } + + const shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical; + args.bucket.iconsInText = shapedText ? shapedText.iconsInText : false; + if (shapedText || shapedIcon) { + addFeature(args.bucket, feature, shapedTextOrientations, shapedIcon, args.imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, args.canonical); + } + } + + if (args.showCollisionBoxes) { + args.bucket.generateCollisionDebugBuffers(); + } +} + +// Choose the justification that matches the direction of the TextAnchor +export function getAnchorJustification(anchor: TextAnchor): TextJustify { + switch (anchor) { + case 'right': + case 'top-right': + case 'bottom-right': + return 'right'; + case 'left': + case 'top-left': + case 'bottom-left': + return 'left'; + } + return 'center'; +} + +/** + * Given a feature and its shaped text and icon data, add a 'symbol + * instance' for each _possible_ placement of the symbol feature. + * (At render timePlaceSymbols#place() selects which of these instances to + * show or hide based on collisions with symbols in other layers.) + */ +function addFeature(bucket: SymbolBucket, + feature: SymbolFeature, + shapedTextOrientations: ShapedTextOrientations, + shapedIcon: PositionedIcon, + imageMap: {[_: string]: StyleImage}, + sizes: Sizes, + layoutTextSize: number, + layoutIconSize: number, + textOffset: [number, number], + isSDFIcon: boolean, canonical: CanonicalTileID) { + // To reduce the number of labels that jump around when zooming we need + // to use a text-size value that is the same for all zoom levels. + // bucket calculates text-size at a high zoom level so that all tiles can + // use the same value when calculating anchor positions. + let textMaxSize = sizes.textMaxSize.evaluate(feature, {}); + if (textMaxSize === undefined) { + textMaxSize = layoutTextSize; + } + const layout = bucket.layers[0].layout; + const iconOffset = layout.get('icon-offset').evaluate(feature, {}, canonical); + const defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal); + const glyphSize = 24, + fontScale = layoutTextSize / glyphSize, + textBoxScale = bucket.tilePixelRatio * fontScale, + textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize, + iconBoxScale = bucket.tilePixelRatio * layoutIconSize, + symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing'), + textPadding = layout.get('text-padding') * bucket.tilePixelRatio, + iconPadding = getIconPadding(layout, feature, canonical, bucket.tilePixelRatio), + textMaxAngle = layout.get('text-max-angle') / 180 * Math.PI, + textAlongLine = layout.get('text-rotation-alignment') !== 'viewport' && layout.get('symbol-placement') !== 'point', + iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point', + symbolPlacement = layout.get('symbol-placement'), + textRepeatDistance = symbolMinDistance / 2; + + const iconTextFit = layout.get('icon-text-fit'); + let verticallyShapedIcon; + // Adjust shaped icon size when icon-text-fit is used. + if (shapedIcon && iconTextFit !== 'none') { + if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) { + verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit, + layout.get('icon-text-fit-padding'), iconOffset, fontScale); + } + if (defaultHorizontalShaping) { + shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit, + layout.get('icon-text-fit-padding'), iconOffset, fontScale); + } + } + + const addSymbolAtAnchor = (line, anchor) => { + if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) { + // Symbol layers are drawn across tile boundaries, We filter out symbols + // outside our tile boundaries (which may be included in vector tile buffers) + // to prevent double-drawing symbols. + return; + } + + addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0], + bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index, + textBoxScale, [textPadding, textPadding, textPadding, textPadding], textAlongLine, textOffset, + iconBoxScale, iconPadding, iconAlongLine, iconOffset, + feature, sizes, isSDFIcon, canonical, layoutTextSize); + }; + + if (symbolPlacement === 'line') { + for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) { + const anchors = getAnchors( + line, + symbolMinDistance, + textMaxAngle, + shapedTextOrientations.vertical || defaultHorizontalShaping, + shapedIcon, + glyphSize, + textMaxBoxScale, + bucket.overscaling, + EXTENT + ); + for (const anchor of anchors) { + const shapedText = defaultHorizontalShaping; + if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) { + addSymbolAtAnchor(line, anchor); + } + } + } + } else if (symbolPlacement === 'line-center') { + // No clipping, multiple lines per feature are allowed + // "lines" with only one point are ignored as in clipLines + for (const line of feature.geometry) { + if (line.length > 1) { + const anchor = getCenterAnchor( + line, + textMaxAngle, + shapedTextOrientations.vertical || defaultHorizontalShaping, + shapedIcon, + glyphSize, + textMaxBoxScale); + if (anchor) { + addSymbolAtAnchor(line, anchor); + } + } + } + } else if (feature.type === 'Polygon') { + for (const polygon of classifyRings(feature.geometry, 0)) { + // 16 here represents 2 pixels + const poi = findPoleOfInaccessibility(polygon, 16); + addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0)); + } + } else if (feature.type === 'LineString') { + // https://github.com/mapbox/mapbox-gl-js/issues/3808 + for (const line of feature.geometry) { + addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0)); + } + } else if (feature.type === 'Point') { + for (const points of feature.geometry) { + for (const point of points) { + addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0)); + } + } + } +} + +function addTextVariableAnchorOffsets(textAnchorOffsets: TextAnchorOffsetArray, variableAnchorOffset: VariableAnchorOffsetCollection): [number, number] { + const startIndex = textAnchorOffsets.length; + const values = variableAnchorOffset?.values; + + if (values?.length > 0) { + for (let i = 0; i < values.length; i += 2) { + const anchor = TextAnchorEnum[values[i] as TextAnchor]; + const offset = values[i + 1] as [number, number]; + + textAnchorOffsets.emplaceBack(anchor, offset[0], offset[1]); + } + } + + return [startIndex, textAnchorOffsets.length]; +} + +function addTextVertices(bucket: SymbolBucket, + anchor: Point, + shapedText: Shaping, + imageMap: {[_: string]: StyleImage}, + layer: SymbolStyleLayer, + textAlongLine: boolean, + feature: SymbolFeature, + textOffset: [number, number], + lineArray: { + lineStartIndex: number; + lineLength: number; + }, + writingMode: WritingMode, + placementTypes: Array<'vertical' | 'center' | 'left' | 'right'>, + placedTextSymbolIndices: {[_: string]: number}, + placedIconIndex: number, + sizes: Sizes, + canonical: CanonicalTileID) { + const glyphQuads = getGlyphQuads(anchor, shapedText, textOffset, + layer, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement); + + const sizeData = bucket.textSizeData; + let textSizeData = null; + + if (sizeData.kind === 'source') { + textSizeData = [ + SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {}) + ]; + if (textSizeData[0] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "text-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "text-size".`); + } + } else if (sizeData.kind === 'composite') { + textSizeData = [ + SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical), + SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical) + ]; + if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "text-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "text-size".`); + } + } + + bucket.addSymbols( + bucket.text, + glyphQuads, + textSizeData, + textOffset, + textAlongLine, + feature, + writingMode, + anchor, + lineArray.lineStartIndex, + lineArray.lineLength, + placedIconIndex, + canonical); + + // The placedSymbolArray is used at render time in drawTileSymbols + // These indices allow access to the array at collision detection time + for (const placementType of placementTypes) { + placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1; + } + + return glyphQuads.length * 4; +} + +function getDefaultHorizontalShaping( + horizontalShaping: Record +): Shaping | null { + // We don't care which shaping we get because this is used for collision purposes + // and all the justifications have the same collision box + for (const justification in horizontalShaping) { + return horizontalShaping[justification]; + } + return null; +} + +/** + * Add a single label & icon placement. + */ +function addSymbol(bucket: SymbolBucket, + anchor: Anchor, + line: Array, + shapedTextOrientations: ShapedTextOrientations, + shapedIcon: PositionedIcon | void, + imageMap: {[_: string]: StyleImage}, + verticallyShapedIcon: PositionedIcon | void, + layer: SymbolStyleLayer, + collisionBoxArray: CollisionBoxArray, + featureIndex: number, + sourceLayerIndex: number, + bucketIndex: number, + textBoxScale: number, + textPadding: SymbolPadding, + textAlongLine: boolean, + textOffset: [number, number], + iconBoxScale: number, + iconPadding: SymbolPadding, + iconAlongLine: boolean, + iconOffset: [number, number], + feature: SymbolFeature, + sizes: Sizes, + isSDFIcon: boolean, + canonical: CanonicalTileID, + layoutTextSize: number) { + const lineArray = bucket.addToLineVertexArray(anchor, line); + + let textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature; + + let numIconVertices = 0; + let numVerticalIconVertices = 0; + let numHorizontalGlyphVertices = 0; + let numVerticalGlyphVertices = 0; + let placedIconSymbolIndex = -1; + let verticalPlacedIconSymbolIndex = -1; + const placedTextSymbolIndices: {[k: string]: number} = {}; + let key = murmur3(''); + + if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) { + const textRotation = layer.layout.get('text-rotate').evaluate(feature, {}, canonical); + const verticalTextRotation = textRotation + 90.0; + const verticalShaping = shapedTextOrientations.vertical; + verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation); + + if (verticallyShapedIcon) { + verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation); + } + } + + //Place icon first, so text can have a reference to its index in the placed symbol array. + //Text symbols can lazily shift at render-time because of variable anchor placement. + //If the style specifies an `icon-text-fit` then the icon would have to shift along with it. + // For more info check `updateVariableAnchors` in `draw_symbol.js` . + if (shapedIcon) { + const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {}); + const hasIconTextFit = layer.layout.get('icon-text-fit') !== 'none'; + const iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit); + const verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : undefined; + iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/false, iconRotate); + + numIconVertices = iconQuads.length * 4; + + const sizeData = bucket.iconSizeData; + let iconSizeData = null; + + if (sizeData.kind === 'source') { + iconSizeData = [ + SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {}) + ]; + if (iconSizeData[0] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "icon-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "icon-size".`); + } + } else if (sizeData.kind === 'composite') { + iconSizeData = [ + SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical), + SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical) + ]; + if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) { + warnOnce(`${bucket.layerIds[0]}: Value for "icon-size" is >= ${MAX_GLYPH_ICON_SIZE}. Reduce your "icon-size".`); + } + } + + bucket.addSymbols( + bucket.icon, + iconQuads, + iconSizeData, + iconOffset, + iconAlongLine, + feature, + WritingMode.none, + anchor, + lineArray.lineStartIndex, + lineArray.lineLength, + // The icon itself does not have an associated symbol since the text isnt placed yet + -1, canonical); + + placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1; + + if (verticalIconQuads) { + numVerticalIconVertices = verticalIconQuads.length * 4; + + bucket.addSymbols( + bucket.icon, + verticalIconQuads, + iconSizeData, + iconOffset, + iconAlongLine, + feature, + WritingMode.vertical, + anchor, + lineArray.lineStartIndex, + lineArray.lineLength, + // The icon itself does not have an associated symbol since the text isnt placed yet + -1, canonical); + + verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1; + } + } + + const justifications = Object.keys(shapedTextOrientations.horizontal) as TextJustify[]; + for (const justification of justifications) { + const shaping = shapedTextOrientations.horizontal[justification]; + + if (!textCollisionFeature) { + key = murmur3(shaping.text); + const textRotate = layer.layout.get('text-rotate').evaluate(feature, {}, canonical); + // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature + // We're counting on all versions having similar dimensions + textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate); + } + + const singleLine = shaping.positionedLines.length === 1; + numHorizontalGlyphVertices += addTextVertices( + bucket, anchor, shaping, imageMap, layer, textAlongLine, feature, textOffset, lineArray, + shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly, + singleLine ? justifications : [justification], + placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical); + + if (singleLine) { + break; + } + } + + if (shapedTextOrientations.vertical) { + numVerticalGlyphVertices += addTextVertices( + bucket, anchor, shapedTextOrientations.vertical, imageMap, layer, textAlongLine, feature, + textOffset, lineArray, WritingMode.vertical, ['vertical'], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical); + } + + const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + + const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + + const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + + const verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; + const verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; + + // Check if runtime collision circles should be used for any of the collision features. + // It is enough to choose the tallest feature shape as circles are always placed on a line. + // All measurements are in glyph metrics and later converted into pixels using proper font size "layoutTextSize" + let collisionCircleDiameter = -1; + + const getCollisionCircleHeight = (feature: CollisionFeature, prevHeight: number): number => { + if (feature && feature.circleDiameter) + return Math.max(feature.circleDiameter, prevHeight); + return prevHeight; + }; + + collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter); + collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter); + collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter); + collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter); + const useRuntimeCollisionCircles = (collisionCircleDiameter > -1) ? 1 : 0; + + // Convert circle collision height into pixels + if (useRuntimeCollisionCircles) + collisionCircleDiameter *= layoutTextSize / ONE_EM; + + if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) warnOnce( + 'Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907' + ); + + if (feature.sortKey !== undefined) { + bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey as number); + } + + const variableAnchorOffset = getTextVariableAnchorOffset(layer, feature, canonical); + const [textAnchorOffsetStartIndex, textAnchorOffsetEndIndex] = addTextVariableAnchorOffsets(bucket.textAnchorOffsets, variableAnchorOffset); + + bucket.symbolInstances.emplaceBack( + anchor.x, + anchor.y, + placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1, + placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1, + placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1, + placedTextSymbolIndices.vertical || -1, + placedIconSymbolIndex, + verticalPlacedIconSymbolIndex, + key, + textBoxStartIndex, + textBoxEndIndex, + verticalTextBoxStartIndex, + verticalTextBoxEndIndex, + iconBoxStartIndex, + iconBoxEndIndex, + verticalIconBoxStartIndex, + verticalIconBoxEndIndex, + featureIndex, + numHorizontalGlyphVertices, + numVerticalGlyphVertices, + numIconVertices, + numVerticalIconVertices, + useRuntimeCollisionCircles, + 0, + textBoxScale, + collisionCircleDiameter, + textAnchorOffsetStartIndex, + textAnchorOffsetEndIndex); +} + +function anchorIsTooClose(bucket: SymbolBucket, text: string, repeatDistance: number, anchor: Point) { + const compareText = bucket.compareText; + if (!(text in compareText)) { + compareText[text] = []; + } else { + const otherAnchors = compareText[text]; + for (let k = otherAnchors.length - 1; k >= 0; k--) { + if (anchor.dist(otherAnchors[k]) < repeatDistance) { + // If it's within repeatDistance of one anchor, stop looking + return true; + } + } + } + // If anchor is not within repeatDistance of any other anchor, add to array + compareText[text].push(anchor); + return false; +} diff --git a/web/libraries/maplibre-gl/src/symbol/symbol_size.ts b/web/libraries/maplibre-gl/src/symbol/symbol_size.ts new file mode 100644 index 00000000..d729e602 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/symbol_size.ts @@ -0,0 +1,129 @@ +import {Interpolate, interpolates} from '@maplibre/maplibre-gl-style-spec'; +import {clamp} from '../util/util'; +import {EvaluationParameters} from '../style/evaluation_parameters'; + +import type {PropertyValue, PossiblyEvaluatedPropertyValue} from '../style/properties'; +import type {InterpolationType} from '@maplibre/maplibre-gl-style-spec'; + +const MAX_GLYPH_ICON_SIZE = 255; +const SIZE_PACK_FACTOR = 128; +const MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR; + +export {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR, MAX_GLYPH_ICON_SIZE, MAX_PACKED_SIZE}; + +export type SizeData = { + kind: 'constant'; + layoutSize: number; +} | { + kind: 'source'; +} | { + kind: 'camera'; + minZoom: number; + maxZoom: number; + minSize: number; + maxSize: number; + interpolationType: InterpolationType; +} | { + kind: 'composite'; + minZoom: number; + maxZoom: number; + interpolationType: InterpolationType; +}; + +export type EvaluatedZoomSize = {uSizeT: number; uSize: number}; + +// For {text,icon}-size, get the bucket-level data that will be needed by +// the painter to set symbol-size-related uniforms +function getSizeData( + tileZoom: number, + value: PropertyValue> +): SizeData { + const {expression} = value; + + if (expression.kind === 'constant') { + const layoutSize = expression.evaluate(new EvaluationParameters(tileZoom + 1)); + return {kind: 'constant', layoutSize}; + + } else if (expression.kind === 'source') { + return {kind: 'source'}; + + } else { + const {zoomStops, interpolationType} = expression; + + // calculate covering zoom stops for zoom-dependent values + let lower = 0; + while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) lower++; + lower = Math.max(0, lower - 1); + let upper = lower; + while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) upper++; + upper = Math.min(zoomStops.length - 1, upper); + + const minZoom = zoomStops[lower]; + const maxZoom = zoomStops[upper]; + + // We'd like to be able to use CameraExpression or CompositeExpression in these + // return types rather than ExpressionSpecification, but the former are not + // transferrable across Web Worker boundaries. + if (expression.kind === 'composite') { + return {kind: 'composite', minZoom, maxZoom, interpolationType}; + } + + // for camera functions, also save off the function values + // evaluated at the covering zoom levels + const minSize = expression.evaluate(new EvaluationParameters(minZoom)); + const maxSize = expression.evaluate(new EvaluationParameters(maxZoom)); + + return {kind: 'camera', minZoom, maxZoom, minSize, maxSize, interpolationType}; + } +} + +function evaluateSizeForFeature(sizeData: SizeData, + { + uSize, + uSizeT + }: { + uSize: number; + uSizeT: number; + }, + { + lowerSize, + upperSize + }: { + lowerSize: number; + upperSize: number; + }): number { + if (sizeData.kind === 'source') { + return lowerSize / SIZE_PACK_FACTOR; + } else if (sizeData.kind === 'composite') { + return interpolates.number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT); + } + return uSize; +} + +function evaluateSizeForZoom(sizeData: SizeData, zoom: number): EvaluatedZoomSize { + let uSizeT = 0; + let uSize = 0; + + if (sizeData.kind === 'constant') { + uSize = sizeData.layoutSize; + + } else if (sizeData.kind !== 'source') { + const {interpolationType, minZoom, maxZoom} = sizeData; + + // Even though we could get the exact value of the camera function + // at z = tr.zoom, we intentionally do not: instead, we interpolate + // between the camera function values at a pair of zoom stops covering + // [tileZoom, tileZoom + 1] in order to be consistent with this + // restriction on composite functions + const t = !interpolationType ? 0 : clamp( + Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1); + + if (sizeData.kind === 'camera') { + uSize = interpolates.number(sizeData.minSize, sizeData.maxSize, t); + } else { + uSizeT = t; + } + } + + return {uSizeT, uSize}; +} diff --git a/web/libraries/maplibre-gl/src/symbol/symbol_style_layer.test.ts b/web/libraries/maplibre-gl/src/symbol/symbol_style_layer.test.ts new file mode 100644 index 00000000..c93c5cf7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/symbol_style_layer.test.ts @@ -0,0 +1,103 @@ +import {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; +import {FormatSectionOverride} from '../style/format_section_override'; +import properties, {SymbolPaintPropsPossiblyEvaluated} from '../style/style_layer/symbol_style_layer_properties.g'; +import {ZoomHistory} from '../style/zoom_history'; +import {EvaluationParameters} from '../style/evaluation_parameters'; + +function createSymbolLayer(layerProperties) { + const layer = new SymbolStyleLayer(layerProperties); + layer.recalculate({zoom: 0, zoomHistory: {} as ZoomHistory} as EvaluationParameters, []); + return layer; +} + +function isOverriden(paintProperty) { + if (paintProperty.value.kind === 'source' || paintProperty.value.kind === 'composite') { + return paintProperty.value._styleExpression.expression instanceof FormatSectionOverride; + } + return false; +} + +describe('setPaintOverrides', () => { + test('setPaintOverrides, no overrides', () => { + const layer = createSymbolLayer({}); + layer._setPaintOverrides(); + for (const overridable of properties.paint.overridableProperties) { + expect(isOverriden(layer.paint.get(overridable as keyof SymbolPaintPropsPossiblyEvaluated))).toBe(false); + } + + }); + + test('setPaintOverrides, format expression, overriden text-color', () => { + const props = {layout: {'text-field': ['format', 'text', {'text-color': 'yellow'}]}}; + const layer = createSymbolLayer(props); + layer._setPaintOverrides(); + expect(isOverriden(layer.paint.get('text-color'))).toBe(true); + + }); + + test('setPaintOverrides, format expression, no overrides', () => { + const props = {layout: {'text-field': ['format', 'text', {}]}}; + const layer = createSymbolLayer(props); + layer._setPaintOverrides(); + expect(isOverriden(layer.paint.get('text-color'))).toBe(false); + + }); + +}); + +describe('hasPaintOverrides', () => { + test('undefined', () => { + const layer = createSymbolLayer({}); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(false); + + }); + + test('constant, Formatted type, overriden text-color', () => { + const props = {layout: {'text-field': ['format', 'text', {'text-color': 'red'}]}}; + const layer = createSymbolLayer(props); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(true); + + }); + + test('constant, Formatted type, no overrides', () => { + const props = {layout: {'text-field': ['format', 'text', {'font-scale': 0.8}]}}; + const layer = createSymbolLayer(props); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(false); + + }); + + test('format expression, overriden text-color', () => { + const props = {layout: {'text-field': ['format', ['get', 'name'], {'text-color': 'red'}]}}; + const layer = createSymbolLayer(props); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(true); + + }); + + test('format expression, no overrides', () => { + const props = {layout: {'text-field': ['format', ['get', 'name'], {}]}}; + const layer = createSymbolLayer(props); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(false); + + }); + + test('nested expression, overriden text-color', () => { + const matchExpr = ['match', ['get', 'case'], + 'one', ['format', 'color', {'text-color': 'blue'}], + 'default']; + const props = {layout: {'text-field': matchExpr}}; + const layer = createSymbolLayer(props); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(true); + + }); + + test('nested expression, no overrides', () => { + const matchExpr = ['match', ['get', 'case'], + 'one', ['format', 'b&w', {}], + 'default']; + const props = {layout: {'text-field': matchExpr}}; + const layer = createSymbolLayer(props); + expect(SymbolStyleLayer.hasPaintOverride(layer.layout, 'text-color')).toBe(false); + + }); + +}); diff --git a/web/libraries/maplibre-gl/src/symbol/transform_text.ts b/web/libraries/maplibre-gl/src/symbol/transform_text.ts new file mode 100644 index 00000000..0278ea50 --- /dev/null +++ b/web/libraries/maplibre-gl/src/symbol/transform_text.ts @@ -0,0 +1,27 @@ +import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin'; + +import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer'; +import type {Feature} from '@maplibre/maplibre-gl-style-spec'; +import {Formatted} from '@maplibre/maplibre-gl-style-spec'; + +function transformTextInternal(text: string, layer: SymbolStyleLayer, feature: Feature) { + const transform = layer.layout.get('text-transform').evaluate(feature, {}); + if (transform === 'uppercase') { + text = text.toLocaleUpperCase(); + } else if (transform === 'lowercase') { + text = text.toLocaleLowerCase(); + } + + if (rtlTextPlugin.applyArabicShaping) { + text = rtlTextPlugin.applyArabicShaping(text); + } + + return text; +} + +export function transformText(text: Formatted, layer: SymbolStyleLayer, feature: Feature): Formatted { + text.sections.forEach(section => { + section.text = transformTextInternal(section.text, layer, feature); + }); + return text; +} diff --git a/web/libraries/maplibre-gl/src/types/callback.ts b/web/libraries/maplibre-gl/src/types/callback.ts new file mode 100644 index 00000000..e34922f2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/types/callback.ts @@ -0,0 +1,15 @@ +/** + * A callback definition. + * + * @example + * ```ts + * asyncFunction((error, result) => { + * if (error) { + * // handle error + * } else if (result) { + * // handle success + * } + * }); + * ``` + */ +export type Callback = (error?: Error | null, result?: T | null) => void; diff --git a/web/libraries/maplibre-gl/src/types/cancelable.ts b/web/libraries/maplibre-gl/src/types/cancelable.ts new file mode 100644 index 00000000..eab74130 --- /dev/null +++ b/web/libraries/maplibre-gl/src/types/cancelable.ts @@ -0,0 +1,6 @@ +/** + * A request that can be cancelled + */ +export type Cancelable = { + cancel: () => void; +}; diff --git a/web/libraries/maplibre-gl/src/types/tilejson.ts b/web/libraries/maplibre-gl/src/types/tilejson.ts new file mode 100644 index 00000000..a2542eb3 --- /dev/null +++ b/web/libraries/maplibre-gl/src/types/tilejson.ts @@ -0,0 +1,15 @@ +export type TileJSON = { + tilejson: '2.2.0' | '2.1.0' | '2.0.1' | '2.0.0' | '1.0.0'; + name?: string; + description?: string; + version?: string; + attribution?: string; + template?: string; + tiles: Array; + grids?: Array; + data?: Array; + minzoom?: number; + maxzoom?: number; + bounds?: [number, number, number, number]; + center?: [number, number, number]; +}; diff --git a/web/libraries/maplibre-gl/src/types/transferable.ts b/web/libraries/maplibre-gl/src/types/transferable.ts new file mode 100644 index 00000000..86c20270 --- /dev/null +++ b/web/libraries/maplibre-gl/src/types/transferable.ts @@ -0,0 +1,4 @@ +/** + * An object with is transferable between main and worker thread + */ +export type Transferable = ArrayBuffer | MessagePort | ImageBitmap; diff --git a/web/libraries/maplibre-gl/src/ui/anchor.ts b/web/libraries/maplibre-gl/src/ui/anchor.ts new file mode 100644 index 00000000..be6c49ec --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/anchor.ts @@ -0,0 +1,27 @@ +/** + * Where to position the anchor. + * Used by a popup and a marker. + */ +export type PositionAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + +export const anchorTranslate: { + [_ in PositionAnchor]: string; +} = { + 'center': 'translate(-50%,-50%)', + 'top': 'translate(-50%,0)', + 'top-left': 'translate(0,0)', + 'top-right': 'translate(-100%,0)', + 'bottom': 'translate(-50%,-100%)', + 'bottom-left': 'translate(0,-100%)', + 'bottom-right': 'translate(-100%,-100%)', + 'left': 'translate(0,-50%)', + 'right': 'translate(-100%,-50%)' +}; + +export function applyAnchorClass(element: HTMLElement, anchor: PositionAnchor, prefix: string) { + const classList = element.classList; + for (const key in anchorTranslate) { + classList.remove(`maplibregl-${prefix}-anchor-${key}`); + } + classList.add(`maplibregl-${prefix}-anchor-${anchor}`); +} diff --git a/web/libraries/maplibre-gl/src/ui/camera.test.ts b/web/libraries/maplibre-gl/src/ui/camera.test.ts new file mode 100644 index 00000000..77363859 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/camera.test.ts @@ -0,0 +1,2240 @@ +import {Camera, CameraOptions} from '../ui/camera'; +import {Transform} from '../geo/transform'; +import {TaskQueue, TaskID} from '../util/task_queue'; +import {browser} from '../util/browser'; +import {fixedLngLat, fixedNum} from '../../test/unit/lib/fixed'; +import {setMatchMedia} from '../util/test/util'; +import {mercatorZfromAltitude} from '../geo/mercator_coordinate'; +import {Terrain} from '../render/terrain'; +import {LngLat, LngLatLike} from '../geo/lng_lat'; +import {Event} from '../util/evented'; + +beforeEach(() => { + setMatchMedia(); + Object.defineProperty(browser, 'prefersReducedMotion', {value: false}); +}); + +class CameraMock extends Camera { + // eslint-disable-next-line + _requestRenderFrame(a: () => void): TaskID { + return undefined; + } + + _cancelRenderFrame(_: TaskID): void { + return undefined; + } +} + +function attachSimulateFrame(camera) { + const queue = new TaskQueue(); + camera._requestRenderFrame = (cb) => queue.add(cb); + camera._cancelRenderFrame = (id) => queue.remove(id); + camera.simulateFrame = () => queue.run(); + return camera; +} + +function createCamera(options?) { + options = options || {}; + + const transform = new Transform(0, 20, 0, 60, options.renderWorldCopies); + transform.resize(512, 512); + + const camera = attachSimulateFrame(new CameraMock(transform, {} as any)) + .jumpTo(options); + + camera._update = () => {}; + + return camera; +} + +function assertTransitionTime(done, camera, min, max) { + let startTime; + camera + .on('movestart', () => { startTime = new Date(); }) + .on('moveend', () => { + const endTime = new Date(); + const timeDiff = endTime.getTime() - startTime.getTime(); + expect(timeDiff >= min && timeDiff < max).toBeTruthy(); + done(); + }); +} + +describe('#calculateCameraOptionsFromTo', () => { + // Choose initial zoom to avoid center being constrained by mercator latitude limits. + const camera = createCamera({zoom: 1}); + + test('look at north', () => { + const cameraOptions: CameraOptions = camera.calculateCameraOptionsFromTo({lng: 1, lat: 0}, 0, {lng: 1, lat: 1}); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.center).toBeDefined(); + expect(cameraOptions.bearing).toBeCloseTo(0); + }); + + test('look at west', () => { + const cameraOptions = camera.calculateCameraOptionsFromTo({lng: 1, lat: 0}, 0, {lng: 0, lat: 0}); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.bearing).toBeCloseTo(-90); + }); + + test('pitch 45', () => { + // altitude same as grounddistance => 45° + // distance between lng x and lng x+1 is 111.2km at same lat + const cameraOptions: CameraOptions = camera.calculateCameraOptionsFromTo({lng: 1, lat: 0}, 111200, {lng: 0, lat: 0}); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.pitch).toBeCloseTo(45); + }); + + test('pitch 90', () => { + const cameraOptions = camera.calculateCameraOptionsFromTo({lng: 1, lat: 0}, 0, {lng: 0, lat: 0}); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.pitch).toBeCloseTo(90); + }); + + test('pitch 153.435', () => { + + // distance between lng x and lng x+1 is 111.2km at same lat + // (elevation difference of cam and center) / 2 = grounddistance => + // acos(111.2 / sqrt(111.2² + (111.2 * 2)²)) = acos(1/sqrt(5)) => 63.435 + 90 (looking up) = 153.435 + const cameraOptions: CameraOptions = camera.calculateCameraOptionsFromTo({lng: 1, lat: 0}, 111200, {lng: 0, lat: 0}, 111200 * 3); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.pitch).toBeCloseTo(153.435); + }); + + test('zoom distance 1000', () => { + const expectedZoom = Math.log2(camera.transform.cameraToCenterDistance / mercatorZfromAltitude(1000, 0) / camera.transform.tileSize); + const cameraOptions = camera.calculateCameraOptionsFromTo({lng: 0, lat: 0}, 0, {lng: 0, lat: 0}, 1000); + + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.zoom).toBeCloseTo(expectedZoom); + }); + + test('zoom distance 1 lng (111.2km), 111.2km altitude away', () => { + const expectedZoom = Math.log2(camera.transform.cameraToCenterDistance / mercatorZfromAltitude(Math.hypot(111200, 111200), 0) / camera.transform.tileSize); + const cameraOptions = camera.calculateCameraOptionsFromTo({lng: 0, lat: 0}, 0, {lng: 1, lat: 0}, 111200); + + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.zoom).toBeCloseTo(expectedZoom); + }); + + test('same To as From error', () => { + expect(() => { camera.calculateCameraOptionsFromTo({lng: 0, lat: 0}, 0, {lng: 0, lat: 0}, 0); }).toThrow(); + }); +}); + +describe('#jumpTo', () => { + // Choose initial zoom to avoid center being constrained by mercator latitude limits. + const camera = createCamera({zoom: 1}); + + test('sets center', () => { + camera.jumpTo({center: [1, 2]}); + expect(camera.getCenter()).toEqual({lng: 1, lat: 2}); + }); + + test('throws on invalid center argument', () => { + expect(() => { + camera.jumpTo({center: 1}); + }).toThrow(Error); + }); + + test('keeps current center if not specified', () => { + camera.jumpTo({}); + expect(camera.getCenter()).toEqual({lng: 1, lat: 2}); + }); + + test('sets zoom', () => { + camera.jumpTo({zoom: 3}); + expect(camera.getZoom()).toBe(3); + }); + + test('keeps current zoom if not specified', () => { + camera.jumpTo({}); + expect(camera.getZoom()).toBe(3); + }); + + test('sets bearing', () => { + camera.jumpTo({bearing: 4}); + expect(camera.getBearing()).toBe(4); + }); + + test('keeps current bearing if not specified', () => { + camera.jumpTo({}); + expect(camera.getBearing()).toBe(4); + }); + + test('sets pitch', () => { + camera.jumpTo({pitch: 45}); + expect(camera.getPitch()).toBe(45); + }); + + test('keeps current pitch if not specified', () => { + camera.jumpTo({}); + expect(camera.getPitch()).toBe(45); + }); + + test('sets multiple properties', () => { + camera.jumpTo({ + center: [10, 20], + zoom: 10, + bearing: 180, + pitch: 60 + }); + expect(camera.getCenter()).toEqual({lng: 10, lat: 20}); + expect(camera.getZoom()).toBe(10); + expect(camera.getBearing()).toBe(180); + expect(camera.getPitch()).toBe(60); + }); + + test('emits move events, preserving eventData', done => { + let started, moved, ended; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { started = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { ended = d.data; }); + + camera.jumpTo({center: [1, 2]}, eventData); + expect(started).toBe('ok'); + expect(moved).toBe('ok'); + expect(ended).toBe('ok'); + done(); + }); + + test('emits zoom events, preserving eventData', done => { + let started, zoomed, ended; + const eventData = {data: 'ok'}; + + camera + .on('zoomstart', (d) => { started = d.data; }) + .on('zoom', (d) => { zoomed = d.data; }) + .on('zoomend', (d) => { ended = d.data; }); + + camera.jumpTo({zoom: 3}, eventData); + expect(started).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(ended).toBe('ok'); + done(); + }); + + test('emits rotate events, preserving eventData', done => { + let started, rotated, ended; + const eventData = {data: 'ok'}; + + camera + .on('rotatestart', (d) => { started = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('rotateend', (d) => { ended = d.data; }); + + camera.jumpTo({bearing: 90}, eventData); + expect(started).toBe('ok'); + expect(rotated).toBe('ok'); + expect(ended).toBe('ok'); + done(); + }); + + test('emits pitch events, preserving eventData', done => { + let started, pitched, ended; + const eventData = {data: 'ok'}; + + camera + .on('pitchstart', (d) => { started = d.data; }) + .on('pitch', (d) => { pitched = d.data; }) + .on('pitchend', (d) => { ended = d.data; }); + + camera.jumpTo({pitch: 10}, eventData); + expect(started).toBe('ok'); + expect(pitched).toBe('ok'); + expect(ended).toBe('ok'); + done(); + }); + + test('cancels in-progress easing', () => { + camera.panTo([3, 4]); + expect(camera.isEasing()).toBeTruthy(); + camera.jumpTo({center: [1, 2]}); + expect(!camera.isEasing()).toBeTruthy(); + }); +}); + +describe('#setCenter', () => { + // Choose initial zoom to avoid center being constrained by mercator latitude limits. + const camera = createCamera({zoom: 1}); + + test('sets center', () => { + camera.setCenter([1, 2]); + expect(camera.getCenter()).toEqual({lng: 1, lat: 2}); + }); + + test('throws on invalid center argument', () => { + expect(() => { + camera.jumpTo({center: 1}); + }).toThrow(Error); + }); + + test('emits move events, preserving eventData', done => { + let started, moved, ended; + const eventData = {data: 'ok'}; + + camera.on('movestart', (d) => { started = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { ended = d.data; }); + + camera.setCenter([10, 20], eventData); + expect(started).toBe('ok'); + expect(moved).toBe('ok'); + expect(ended).toBe('ok'); + done(); + }); + + test('cancels in-progress easing', () => { + camera.panTo([3, 4]); + expect(camera.isEasing()).toBeTruthy(); + camera.setCenter([1, 2]); + expect(!camera.isEasing()).toBeTruthy(); + }); +}); + +describe('#setZoom', () => { + const camera = createCamera(); + + test('sets zoom', () => { + camera.setZoom(3); + expect(camera.getZoom()).toBe(3); + }); + + test('emits move and zoom events, preserving eventData', done => { + let movestarted, moved, moveended, zoomstarted, zoomed, zoomended; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { moveended = d.data; }) + .on('zoomstart', (d) => { zoomstarted = d.data; }) + .on('zoom', (d) => { zoomed = d.data; }) + .on('zoomend', (d) => { zoomended = d.data; }); + + camera.setZoom(4, eventData); + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(moveended).toBe('ok'); + expect(zoomstarted).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(zoomended).toBe('ok'); + done(); + }); + + test('cancels in-progress easing', () => { + camera.panTo([3, 4]); + expect(camera.isEasing()).toBeTruthy(); + camera.setZoom(5); + expect(!camera.isEasing()).toBeTruthy(); + }); +}); + +describe('#setBearing', () => { + const camera = createCamera(); + + test('sets bearing', () => { + camera.setBearing(4); + expect(camera.getBearing()).toBe(4); + }); + + test('emits move and rotate events, preserving eventData', done => { + let movestarted, moved, moveended, rotatestarted, rotated, rotateended; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { moveended = d.data; }) + .on('rotatestart', (d) => { rotatestarted = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('rotateend', (d) => { rotateended = d.data; }); + + camera.setBearing(5, eventData); + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(moveended).toBe('ok'); + expect(rotatestarted).toBe('ok'); + expect(rotated).toBe('ok'); + expect(rotateended).toBe('ok'); + done(); + }); + + test('cancels in-progress easing', () => { + camera.panTo([3, 4]); + expect(camera.isEasing()).toBeTruthy(); + camera.setBearing(6); + expect(!camera.isEasing()).toBeTruthy(); + }); +}); + +describe('#setPadding', () => { + test('sets padding', () => { + const camera = createCamera(); + const padding = {left: 300, top: 100, right: 50, bottom: 10}; + camera.setPadding(padding); + expect(camera.getPadding()).toEqual(padding); + }); + + test('existing padding is retained if no new values are passed in', () => { + const camera = createCamera(); + const padding = {left: 300, top: 100, right: 50, bottom: 10}; + camera.setPadding(padding); + camera.setPadding({}); + + const currentPadding = camera.getPadding(); + expect(currentPadding).toEqual(padding); + }); + + test('doesnt change padding thats already present if new value isnt passed in', () => { + const camera = createCamera(); + const padding = {left: 300, top: 100, right: 50, bottom: 10}; + camera.setPadding(padding); + const padding1 = {right: 100}; + camera.setPadding(padding1); + + const currentPadding = camera.getPadding(); + expect(currentPadding.left).toBe(padding.left); + expect(currentPadding.top).toBe(padding.top); + // padding1 here + expect(currentPadding.right).toBe(padding1.right); + expect(currentPadding.bottom).toBe(padding.bottom); + }); +}); + +describe('#panBy', () => { + test('pans by specified amount', () => { + const camera = createCamera(); + camera.panBy([100, 0], {duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 70.3125, lat: 0}); + }); + + test('pans relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.panBy([100, 0], {duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: -70.3125, lat: 0}); + }); + + test('emits move events, preserving eventData', done => { + const camera = createCamera(); + let started, moved; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { started = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { + expect(started).toBe('ok'); + expect(moved).toBe('ok'); + expect(d.data).toBe('ok'); + done(); + }); + + camera.panBy([100, 0], {duration: 0}, eventData); + }); + + test('supresses movestart if noMoveStart option is true', done => { + const camera = createCamera(); + let started; + + // fire once in advance to satisfy assertions that moveend only comes after movestart + camera.fire('movestart'); + + camera + .on('movestart', () => { started = true; }) + .on('moveend', () => { + expect(!started).toBeTruthy(); + done(); + }); + + camera.panBy([100, 0], {duration: 0, noMoveStart: true}); + }); +}); + +describe('#panTo', () => { + test('pans to specified location', () => { + const camera = createCamera(); + camera.panTo([100, 0], {duration: 0}); + expect(camera.getCenter()).toEqual({lng: 100, lat: 0}); + }); + + test('throws on invalid center argument', () => { + const camera = createCamera(); + expect(() => { + camera.panTo({center: 1}); + }).toThrow(Error); + }); + + test('pans with specified offset', () => { + const camera = createCamera(); + camera.panTo([100, 0], {offset: [100, 0], duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 29.6875, lat: 0}); + }); + + test('pans with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.panTo([100, 0], {offset: [100, 0], duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 170.3125, lat: 0}); + }); + + test('emits move events, preserving eventData', done => { + const camera = createCamera(); + let started, moved; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { started = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { + expect(started).toBe('ok'); + expect(moved).toBe('ok'); + expect(d.data).toBe('ok'); + done(); + }); + + camera.panTo([100, 0], {duration: 0}, eventData); + }); + + test('supresses movestart if noMoveStart option is true', done => { + const camera = createCamera(); + let started; + + // fire once in advance to satisfy assertions that moveend only comes after movestart + camera.fire('movestart'); + + camera + .on('movestart', () => { started = true; }) + .on('moveend', () => { + expect(!started).toBeTruthy(); + done(); + }); + + camera.panTo([100, 0], {duration: 0, noMoveStart: true}); + }); +}); + +describe('#zoomTo', () => { + test('zooms to specified level', () => { + const camera = createCamera(); + camera.zoomTo(3.2, {duration: 0}); + expect(camera.getZoom()).toBe(3.2); + }); + + test('zooms around specified location', () => { + const camera = createCamera(); + camera.zoomTo(3.2, {around: [5, 0], duration: 0}); + expect(camera.getZoom()).toBe(3.2); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 4.455905897939886, lat: 0})); + }); + + test('zooms with specified offset', () => { + const camera = createCamera(); + camera.zoomTo(3.2, {offset: [100, 0], duration: 0}); + expect(camera.getZoom()).toBe(3.2); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 62.66117668978015, lat: 0})); + }); + + test('zooms with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.zoomTo(3.2, {offset: [100, 0], duration: 0}); + expect(camera.getZoom()).toBe(3.2); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: -62.66117668978012, lat: 0})); + }); + + test('emits move and zoom events, preserving eventData', done => { + const camera = createCamera(); + let movestarted, moved, zoomstarted, zoomed; + const eventData = {data: 'ok'}; + + expect.assertions(6); + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('zoomstart', (d) => { zoomstarted = d.data; }) + .on('zoom', (d) => { zoomed = d.data; }) + .on('zoomend', (d) => { + expect(zoomstarted).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera.zoomTo(5, {duration: 0}, eventData); + done(); + }); +}); + +describe('#rotateTo', () => { + test('rotates to specified bearing', () => { + const camera = createCamera(); + camera.rotateTo(90, {duration: 0}); + expect(camera.getBearing()).toBe(90); + }); + + test('rotates around specified location', () => { + const camera = createCamera({zoom: 3}); + camera.rotateTo(90, {around: [5, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 4.999999999999972, lat: 4.993665859353271})); + }); + + test('rotates around specified location, constrained to fit the view', () => { + const camera = createCamera({zoom: 0}); + camera.rotateTo(90, {around: [5, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 4.999999999999972, lat: 0.000002552471840999715})); + }); + + test('rotates with specified offset', () => { + const camera = createCamera({zoom: 1}); + camera.rotateTo(90, {offset: [200, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 70.3125, lat: 57.3265212252})); + }); + + test('rotates with specified offset, constrained to fit the view', () => { + const camera = createCamera({zoom: 0}); + camera.rotateTo(90, {offset: [100, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 70.3125, lat: 0.000002552471840999715})); + }); + + test('rotates with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180, zoom: 1}); + camera.rotateTo(90, {offset: [200, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: -70.3125, lat: 57.3265212252})); + }); + + test('emits move and rotate events, preserving eventData', done => { + const camera = createCamera(); + let movestarted, moved, rotatestarted, rotated; + const eventData = {data: 'ok'}; + + expect.assertions(6); + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('rotatestart', (d) => { rotatestarted = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('rotateend', (d) => { + expect(rotatestarted).toBe('ok'); + expect(rotated).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera.rotateTo(90, {duration: 0}, eventData); + done(); + }); +}); + +describe('#easeTo', () => { + test('pans to specified location', () => { + const camera = createCamera(); + camera.easeTo({center: [100, 0], duration: 0}); + expect(camera.getCenter()).toEqual({lng: 100, lat: 0}); + }); + + test('zooms to specified level', () => { + const camera = createCamera(); + camera.easeTo({zoom: 3.2, duration: 0}); + expect(camera.getZoom()).toBe(3.2); + }); + + test('rotates to specified bearing', () => { + const camera = createCamera(); + camera.easeTo({bearing: 90, duration: 0}); + expect(camera.getBearing()).toBe(90); + }); + + test('pitches to specified pitch', () => { + const camera = createCamera(); + camera.easeTo({pitch: 45, duration: 0}); + expect(camera.getPitch()).toBe(45); + }); + + test('pans and zooms', () => { + const camera = createCamera(); + camera.easeTo({center: [100, 0], zoom: 3.2, duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 100, lat: 0})); + expect(camera.getZoom()).toBe(3.2); + }); + + test('zooms around a point', () => { + const camera = createCamera(); + camera.easeTo({around: [100, 0], zoom: 3, duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 87.5, lat: 0})); + expect(camera.getZoom()).toBe(3); + }); + + test('pans and rotates', () => { + const camera = createCamera(); + camera.easeTo({center: [100, 0], bearing: 90, duration: 0}); + expect(camera.getCenter()).toEqual({lng: 100, lat: 0}); + expect(camera.getBearing()).toBe(90); + }); + + test('zooms and rotates', () => { + const camera = createCamera(); + camera.easeTo({zoom: 3.2, bearing: 90, duration: 0}); + expect(camera.getZoom()).toBe(3.2); + expect(camera.getBearing()).toBe(90); + }); + + test('pans, zooms, and rotates', () => { + const camera = createCamera({bearing: -90}); + camera.easeTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 100, lat: 0})); + expect(camera.getZoom()).toBe(3.2); + expect(camera.getBearing()).toBe(90); + }); + + test('noop', () => { + const camera = createCamera(); + camera.easeTo({duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 0, lat: 0}); + expect(camera.getZoom()).toBe(0); + expect(camera.getBearing()).toBeCloseTo(0); + }); + + test('noop with offset', () => { + const camera = createCamera(); + camera.easeTo({offset: [100, 0], duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 0, lat: 0}); + expect(camera.getZoom()).toBe(0); + expect(camera.getBearing()).toBeCloseTo(0); + }); + + test('pans with specified offset', () => { + const camera = createCamera(); + camera.easeTo({center: [100, 0], offset: [100, 0], duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 29.6875, lat: 0}); + }); + + test('pans with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.easeTo({center: [100, 0], offset: [100, 0], duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 170.3125, lat: 0}); + }); + + test('zooms with specified offset', () => { + const camera = createCamera(); + camera.easeTo({zoom: 3.2, offset: [100, 0], duration: 0}); + expect(camera.getZoom()).toBe(3.2); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 62.66117668978015, lat: 0})); + }); + + test('zooms with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.easeTo({zoom: 3.2, offset: [100, 0], duration: 0}); + expect(camera.getZoom()).toBe(3.2); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: -62.66117668978012, lat: 0})); + }); + + test('rotates with specified offset', () => { + const camera = createCamera(); + camera.easeTo({bearing: 90, offset: [100, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: 70.3125, lat: 0.000002552471840999715})); + }); + + test('rotates with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.easeTo({bearing: 90, offset: [100, 0], duration: 0}); + expect(camera.getBearing()).toBe(90); + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat({lng: -70.3125, lat: 0.000002552471840999715})); + }); + + test('emits move, zoom, rotate, and pitch events, preserving eventData', done => { + const camera = createCamera(); + let movestarted, moved, zoomstarted, zoomed, rotatestarted, rotated, pitchstarted, pitched; + const eventData = {data: 'ok'}; + + expect.assertions(18); + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('moveend', (d) => { + expect(camera._zooming).toBeFalsy(); + expect(camera._panning).toBeFalsy(); + expect(camera._rotating).toBeFalsy(); + + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(rotated).toBe('ok'); + expect(pitched).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('zoomstart', (d) => { zoomstarted = d.data; }) + .on('zoom', (d) => { zoomed = d.data; }) + .on('zoomend', (d) => { + expect(zoomstarted).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('rotatestart', (d) => { rotatestarted = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('rotateend', (d) => { + expect(rotatestarted).toBe('ok'); + expect(rotated).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('pitchstart', (d) => { pitchstarted = d.data; }) + .on('pitch', (d) => { pitched = d.data; }) + .on('pitchend', (d) => { + expect(pitchstarted).toBe('ok'); + expect(pitched).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera.easeTo( + {center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45}, + eventData); + done(); + }); + + test('does not emit zoom events if not zooming', done => { + const camera = createCamera(); + + camera + .on('zoomstart', () => { done('zoomstart failed'); }) + .on('zoom', () => { done('zoom failed'); }) + .on('zoomend', () => { done('zoomend failed'); }) + .on('moveend', () => { done(); }); + + camera.easeTo({center: [100, 0], duration: 0}); + }); + + test('stops existing ease', () => { + const camera = createCamera(); + camera.easeTo({center: [200, 0], duration: 100}); + camera.easeTo({center: [100, 0], duration: 0}); + expect(camera.getCenter()).toEqual({lng: 100, lat: 0}); + }); + + test('can be called from within a moveend event handler', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + stub.mockImplementation(() => 0); + camera.easeTo({center: [100, 0], duration: 10}); + + camera.once('moveend', () => { + camera.easeTo({center: [200, 0], duration: 10}); + camera.once('moveend', () => { + camera.easeTo({center: [300, 0], duration: 10}); + camera.once('moveend', () => { + done(); + }); + + setTimeout(() => { + stub.mockImplementation(() => 30); + camera.simulateFrame(); + }, 0); + }); + + // setTimeout to avoid a synchronous callback + setTimeout(() => { + stub.mockImplementation(() => 20); + camera.simulateFrame(); + }, 0); + }); + + // setTimeout to avoid a synchronous callback + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }); + + test('pans eastward across the antimeridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([170, 0]); + let crossedAntimeridian; + + camera.on('move', () => { + if (camera.getCenter().lng > 170) { + crossedAntimeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedAntimeridian).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.easeTo({center: [-170, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('pans westward across the antimeridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([-170, 0]); + let crossedAntimeridian; + + camera.on('move', () => { + if (camera.getCenter().lng < -170) { + crossedAntimeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedAntimeridian).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.easeTo({center: [170, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('animation occurs when prefers-reduced-motion: reduce is set but overridden by essential: true', done => { + const camera = createCamera(); + Object.defineProperty(browser, 'prefersReducedMotion', {value: true}); + const stubNow = jest.spyOn(browser, 'now'); + + // camera transition expected to take in this range when prefersReducedMotion is set and essential: true, + // when a duration of 200 is requested + const min = 100; + const max = 300; + + let startTime; + camera + .on('movestart', () => { startTime = browser.now(); }) + .on('moveend', () => { + const endTime = browser.now(); + const timeDiff = endTime - startTime; + expect(timeDiff >= min && timeDiff < max).toBeTruthy(); + done(); + }); + + setTimeout(() => { + stubNow.mockImplementation(() => 0); + camera.simulateFrame(); + + camera.easeTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 200, essential: true}); + + setTimeout(() => { + stubNow.mockImplementation(() => 200); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('duration is 0 when prefers-reduced-motion: reduce is set', done => { + const camera = createCamera(); + Object.defineProperty(browser, 'prefersReducedMotion', {value: true}); + assertTransitionTime(done, camera, 0, 10); + camera.easeTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 1000}); + }); + + test('jumpTo on("move") during easeTo with zoom, pitch, etc', (done) => { + const camera = createCamera(); + + camera.on('moveend', (e: Event & {done?: true}) => { + if ('done' in e) { + setTimeout(() => { + done(); + }, 50); + } + }); + + camera.easeTo({zoom: 20, bearing: 90, pitch: 60, duration: 500}, {done: true}); + camera.once('move', () => { + camera.jumpTo({pitch: 40}); + }); + + camera.simulateFrame(); + camera.simulateFrame(); + }); + + test('jumpTo on("zoom") during easeTo', (done) => { + const camera = createCamera(); + + camera.on('moveend', (e: Event & {done?: true}) => { + if ('done' in e) { + setTimeout(() => { + done(); + }, 50); + } + }); + + camera.easeTo({zoom: 20, duration: 500}, {done: true}); + camera.once('zoom', () => { + camera.jumpTo({pitch: 40}); + }); + + camera.simulateFrame(); + camera.simulateFrame(); + }); + + test('jumpTo on("pitch") during easeTo', (done) => { + const camera = createCamera(); + + camera.on('moveend', (e: Event & {done?: true}) => { + if ('done' in e) { + setTimeout(() => { + done(); + }, 50); + } + }); + + camera.easeTo({pitch: 60, duration: 500}, {done: true}); + camera.once('pitch', () => { + camera.jumpTo({pitch: 40}); + }); + + camera.simulateFrame(); + camera.simulateFrame(); + }); + + test('jumpTo on("rotate") during easeTo', (done) => { + const camera = createCamera(); + + camera.on('moveend', (e: Event & {done?: true}) => { + if ('done' in e) { + setTimeout(() => { + done(); + }, 50); + } + }); + + camera.easeTo({bearing: 90, duration: 500}, {done: true}); + camera.once('rotate', () => { + camera.jumpTo({pitch: 40}); + }); + + camera.simulateFrame(); + camera.simulateFrame(); + }); +}); + +describe('#flyTo', () => { + test('pans to specified location', () => { + const camera = createCamera(); + camera.flyTo({center: [100, 0], animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 100, lat: 0}); + }); + + test('throws on invalid center argument', () => { + const camera = createCamera(); + expect(() => { + camera.flyTo({center: 1}); + }).toThrow(Error); + }); + + test('does not throw when cameras current zoom is sufficiently greater than passed zoom option', () => { + const camera = createCamera({zoom: 22, center: [0, 0]}); + expect(() => camera.flyTo({zoom: 10, center: [0, 0]})).not.toThrow(); + }); + + test('does not throw when cameras current zoom is above maxzoom and an offset creates infinite zoom out factor', () => { + const transform = new Transform(0, 20.9999, 0, 60, true); + transform.resize(512, 512); + const camera = attachSimulateFrame(new CameraMock(transform, {} as any)) + .jumpTo({zoom: 21, center: [0, 0]}); + camera._update = () => {}; + expect(() => camera.flyTo({zoom: 7.5, center: [0, 0], offset: [0, 70]})).not.toThrow(); + }); + + test('zooms to specified level', () => { + const camera = createCamera(); + camera.flyTo({zoom: 3.2, animate: false}); + expect(fixedNum(camera.getZoom())).toBe(3.2); + }); + + test('zooms to integer level without floating point errors', () => { + const camera = createCamera({zoom: 0.6}); + camera.flyTo({zoom: 2, animate: false}); + expect(camera.getZoom()).toBe(2); + }); + + test('Zoom out from the same position to the same position with animation', done => { + const pos = {lng: 0, lat: 0}; + const camera = createCamera({zoom: 20, center: pos}); + const stub = jest.spyOn(browser, 'now'); + + camera.once('zoomend', () => { + expect(fixedLngLat(camera.getCenter())).toEqual(fixedLngLat(pos)); + expect(camera.getZoom()).toBe(19); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({zoom: 19, center: pos, duration: 2}); + + stub.mockImplementation(() => 3); + camera.simulateFrame(); + }); + + test('rotates to specified bearing', () => { + const camera = createCamera(); + camera.flyTo({bearing: 90, animate: false}); + expect(camera.getBearing()).toBe(90); + }); + + test('tilts to specified pitch', () => { + const camera = createCamera(); + camera.flyTo({pitch: 45, animate: false}); + expect(camera.getPitch()).toBe(45); + }); + + test('pans and zooms', () => { + const camera = createCamera(); + camera.flyTo({center: [100, 0], zoom: 3.2, animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 100, lat: 0}); + expect(fixedNum(camera.getZoom())).toBe(3.2); + }); + + test('pans and rotates', () => { + const camera = createCamera(); + camera.flyTo({center: [100, 0], bearing: 90, animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 100, lat: 0}); + expect(camera.getBearing()).toBe(90); + }); + + test('zooms and rotates', () => { + const camera = createCamera(); + camera.flyTo({zoom: 3.2, bearing: 90, animate: false}); + expect(fixedNum(camera.getZoom())).toBe(3.2); + expect(camera.getBearing()).toBe(90); + }); + + test('pans, zooms, and rotates', () => { + const camera = createCamera(); + camera.flyTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 100, lat: 0}); + expect(fixedNum(camera.getZoom())).toBe(3.2); + expect(camera.getBearing()).toBe(90); + }); + + test('noop', () => { + const camera = createCamera(); + camera.flyTo({animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 0, lat: 0}); + expect(camera.getZoom()).toBe(0); + expect(camera.getBearing()).toBeCloseTo(0); + }); + + test('noop with offset', () => { + const camera = createCamera(); + camera.flyTo({offset: [100, 0], animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 0, lat: 0}); + expect(camera.getZoom()).toBe(0); + expect(camera.getBearing()).toBeCloseTo(0); + }); + + test('pans with specified offset', () => { + const camera = createCamera(); + camera.flyTo({center: [100, 0], offset: [100, 0], animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 29.6875, lat: 0}); + }); + + test('pans with specified offset relative to viewport on a rotated camera', () => { + const camera = createCamera({bearing: 180}); + camera.easeTo({center: [100, 0], offset: [100, 0], animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 170.3125, lat: 0}); + }); + + test('emits move, zoom, rotate, and pitch events, preserving eventData', done => { + expect.assertions(18); + + const camera = createCamera(); + let movestarted, moved, zoomstarted, zoomed, rotatestarted, rotated, pitchstarted, pitched; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('pitch', (d) => { pitched = d.data; }) + .on('moveend', function(d) { + expect(this._zooming).toBeFalsy(); + expect(this._panning).toBeFalsy(); + expect(this._rotating).toBeFalsy(); + + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(rotated).toBe('ok'); + expect(pitched).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('zoomstart', (d) => { zoomstarted = d.data; }) + .on('zoom', (d) => { zoomed = d.data; }) + .on('zoomend', (d) => { + expect(zoomstarted).toBe('ok'); + expect(zoomed).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('rotatestart', (d) => { rotatestarted = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('rotateend', (d) => { + expect(rotatestarted).toBe('ok'); + expect(rotated).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera + .on('pitchstart', (d) => { pitchstarted = d.data; }) + .on('pitch', (d) => { pitched = d.data; }) + .on('pitchend', (d) => { + expect(pitchstarted).toBe('ok'); + expect(pitched).toBe('ok'); + expect(d.data).toBe('ok'); + }); + + camera.flyTo( + {center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45, animate: false}, + eventData); + done(); + }); + + test('for short flights, emits (solely) move events, preserving eventData', done => { + //As I type this, the code path for guiding super-short flights is (and will probably remain) different. + //As such; it deserves a separate test case. This test case flies the map from A to A. + const camera = createCamera({center: [100, 0]}); + let movestarted, moved, + zoomstarted, zoomed, zoomended, + rotatestarted, rotated, rotateended, + pitchstarted, pitched, pitchended; + const eventData = {data: 'ok'}; + + camera + .on('movestart', (d) => { movestarted = d.data; }) + .on('move', (d) => { moved = d.data; }) + .on('zoomstart', (d) => { zoomstarted = d.data; }) + .on('zoom', (d) => { zoomed = d.data; }) + .on('zoomend', (d) => { zoomended = d.data; }) + .on('rotatestart', (d) => { rotatestarted = d.data; }) + .on('rotate', (d) => { rotated = d.data; }) + .on('rotateend', (d) => { rotateended = d.data; }) + .on('pitchstart', (d) => { pitchstarted = d.data; }) + .on('pitch', (d) => { pitched = d.data; }) + .on('pitchend', (d) => { pitchended = d.data; }) + .on('moveend', function(d) { + expect(this._zooming).toBeFalsy(); + expect(this._panning).toBeFalsy(); + expect(this._rotating).toBeFalsy(); + + expect(movestarted).toBe('ok'); + expect(moved).toBe('ok'); + expect(zoomstarted).toBeUndefined(); + expect(zoomed).toBeUndefined(); + expect(zoomended).toBeUndefined(); + expect(rotatestarted).toBeUndefined(); + expect(rotated).toBeUndefined(); + expect(rotateended).toBeUndefined(); + expect(pitched).toBeUndefined(); + expect(pitchstarted).toBeUndefined(); + expect(pitchended).toBeUndefined(); + expect(d.data).toBe('ok'); + done(); + }); + + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + + camera.flyTo({center: [100, 0], duration: 10}, eventData); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('stops existing ease', done => { + const camera = createCamera(); + camera.flyTo({center: [200, 0], duration: 100}); + camera.flyTo({center: [100, 0], duration: 0}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 100, lat: 0}); + done(); + }); + + test('can be called from within a moveend event handler', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + + camera.flyTo({center: [100, 0], duration: 10}); + camera.once('moveend', () => { + camera.flyTo({center: [200, 0], duration: 10}); + camera.once('moveend', () => { + camera.flyTo({center: [300, 0], duration: 10}); + camera.once('moveend', () => { + done(); + }); + }); + }); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 20); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 30); + camera.simulateFrame(); + }, 0); + }, 0); + }, 0); + }); + + test('ascends', done => { + const camera = createCamera(); + camera.setZoom(18); + let ascended; + + camera.on('zoom', () => { + if (camera.getZoom() < 18) { + ascended = true; + } + }); + + camera.on('moveend', () => { + expect(ascended).toBeTruthy(); + done(); + }); + + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + + camera.flyTo({center: [100, 0], zoom: 18, duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('pans eastward across the prime meridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([-10, 0]); + let crossedPrimeMeridian; + + camera.on('move', () => { + if (Math.abs(camera.getCenter().lng) < 10) { + crossedPrimeMeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedPrimeMeridian).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [10, 0], duration: 20}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 20); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('pans westward across the prime meridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([10, 0]); + let crossedPrimeMeridian; + + camera.on('move', () => { + if (Math.abs(camera.getCenter().lng) < 10) { + crossedPrimeMeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedPrimeMeridian).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [-10, 0], duration: 20}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 20); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('pans eastward across the antimeridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([170, 0]); + let crossedAntimeridian; + + camera.on('move', () => { + if (camera.getCenter().lng > 170) { + crossedAntimeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedAntimeridian).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [-170, 0], duration: 20}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 20); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('pans westward across the antimeridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([-170, 0]); + let crossedAntimeridian; + + camera.on('move', () => { + if (camera.getCenter().lng < -170) { + crossedAntimeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedAntimeridian).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [170, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('does not pan eastward across the antimeridian if no world copies', done => { + const camera = createCamera({renderWorldCopies: false}); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([170, 0]); + let crossedAntimeridian; + + camera.on('move', () => { + if (camera.getCenter().lng > 170) { + crossedAntimeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedAntimeridian).toBeFalsy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [-170, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('does not pan westward across the antimeridian if no world copies', done => { + const camera = createCamera({renderWorldCopies: false}); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([-170, 0]); + let crossedAntimeridian; + + camera.on('move', () => { + if (fixedLngLat(camera.getCenter(), 10).lng < -170) { + crossedAntimeridian = true; + } + }); + + camera.on('moveend', () => { + expect(crossedAntimeridian).toBeFalsy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [170, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('jumps back to world 0 when crossing the antimeridian', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + camera.setCenter([-170, 0]); + + let leftWorld0 = false; + + camera.on('move', () => { + leftWorld0 = leftWorld0 || (camera.getCenter().lng < -180); + }); + + camera.on('moveend', () => { + expect(leftWorld0).toBeFalsy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [170, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('peaks at the specified zoom level', done => { + const camera = createCamera({zoom: 20}); + const stub = jest.spyOn(browser, 'now'); + + const minZoom = 1; + let zoomed = false; + + camera.on('zoom', () => { + const zoom = camera.getZoom(); + if (zoom < 1) { + fail(`${zoom} should be >= ${minZoom} during flyTo`); + } + + if (camera.getZoom() < (minZoom + 1)) { + zoomed = true; + } + }); + + camera.on('moveend', () => { + expect(zoomed).toBeTruthy(); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [1, 0], zoom: 20, minZoom, duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 3); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('respects transform\'s maxZoom', done => { + const transform = new Transform(2, 10, 0, 60, false); + transform.resize(512, 512); + + const camera = attachSimulateFrame(new CameraMock(transform, {} as any)); + camera._update = () => {}; + + camera.on('moveend', () => { + expect(camera.getZoom()).toBeCloseTo(10); + const {lng, lat} = camera.getCenter(); + expect(lng).toBeCloseTo(12); + expect(lat).toBeCloseTo(34); + done(); + }); + + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + camera.flyTo({center: [12, 34], zoom: 30, duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }); + + test('respects transform\'s minZoom', done => { + const transform = new Transform(2, 10, 0, 60, false); + transform.resize(512, 512); + + const camera = attachSimulateFrame(new CameraMock(transform, {} as any)); + camera._update = () => {}; + + camera.on('moveend', () => { + expect(camera.getZoom()).toBeCloseTo(2); + const {lng, lat} = camera.getCenter(); + expect(lng).toBeCloseTo(12); + expect(lat).toBeCloseTo(34); + done(); + }); + + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + camera.flyTo({center: [12, 34], zoom: 1, duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }); + + test('resets duration to 0 if it exceeds maxDuration', done => { + let startTime, endTime, timeDiff; + const camera = createCamera({center: [37.63454, 55.75868], zoom: 18}); + + camera + .on('movestart', () => { startTime = new Date(); }) + .on('moveend', () => { + endTime = new Date(); + timeDiff = endTime - startTime; + expect(timeDiff).toBeLessThan(30); + done(); + }); + + camera.flyTo({center: [-122.3998631, 37.7884307], maxDuration: 100}); + }); + + test('flys instantly when prefers-reduce-motion:reduce is set', done => { + const camera = createCamera(); + Object.defineProperty(browser, 'prefersReducedMotion', {value: true}); + assertTransitionTime(done, camera, 0, 10); + camera.flyTo({center: [100, 0], bearing: 90, animate: true}); + }); + + test('check freezeElevation events', done => { + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + + const terrainCallbacks = {prepare: 0, update: 0, finalize: 0} as any; + camera.terrain = {} as Terrain; + camera._prepareElevation = () => { terrainCallbacks.prepare++; }; + camera._updateElevation = () => { terrainCallbacks.update++; }; + camera._finalizeElevation = () => { terrainCallbacks.finalize++; }; + + camera.setCenter([-10, 0]); + + camera.on('moveend', () => { + expect(terrainCallbacks.prepare).toBe(1); + expect(terrainCallbacks.update).toBe(0); + expect(terrainCallbacks.finalize).toBe(1); + done(); + }); + + stub.mockImplementation(() => 0); + camera.flyTo({center: [10, 0], duration: 20, freezeElevation: true}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 20); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('check elevation callbacks', done => { + const camera = createCamera(); + camera.terrain = { + getElevationForLngLatZoom: () => 100, + getMinTileElevationForLngLatZoom: () => 200 + }; + camera.transform = { + elevation: 0, + recalculateZoom: () => true + }; + + camera._prepareElevation([10, 0]); + // expect(camera._elevationCenter).toBe([10, 0]); + expect(camera._elevationStart).toBe(0); + expect(camera._elevationTarget).toBe(100); + expect(camera._elevationFreeze).toBeTruthy(); + + camera.terrain.getElevationForLngLatZoom = () => 200; + camera._updateElevation(0.5); + expect(camera._elevationStart).toBe(-100); + expect(camera._elevationTarget).toBe(200); + + camera._finalizeElevation(); + expect(camera._elevationFreeze).toBeFalsy(); + + done(); + }); + +}); + +describe('#isEasing', () => { + test('returns false when not easing', () => { + const camera = createCamera(); + expect(!camera.isEasing()).toBeTruthy(); + }); + + test('returns true when panning', () => { + const camera = createCamera(); + camera.panTo([100, 0], {duration: 1}); + expect(camera.isEasing()).toBeTruthy(); + }); + + test('returns false when done panning', done => { + const camera = createCamera(); + camera.on('moveend', () => { + expect(!camera.isEasing()).toBeTruthy(); + done(); + }); + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + camera.panTo([100, 0], {duration: 1}); + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + }, 0); + }); + + test('returns true when zooming', () => { + const camera = createCamera(); + camera.zoomTo(3.2, {duration: 1}); + + expect(camera.isEasing()).toBeTruthy(); + }); + + test('returns false when done zooming', done => { + const camera = createCamera(); + camera.on('moveend', () => { + expect(!camera.isEasing()).toBeTruthy(); + done(); + }); + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + camera.zoomTo(3.2, {duration: 1}); + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + }, 0); + }); + + test('returns true when rotating', () => { + const camera = createCamera(); + camera.rotateTo(90, {duration: 1}); + expect(camera.isEasing()).toBeTruthy(); + }); + + test('returns false when done rotating', done => { + const camera = createCamera(); + camera.on('moveend', () => { + expect(!camera.isEasing()).toBeTruthy(); + done(); + }); + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + camera.rotateTo(90, {duration: 1}); + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + }, 0); + }); +}); + +describe('#stop', () => { + test('resets camera._zooming', () => { + const camera = createCamera(); + camera.zoomTo(3.2); + camera.stop(); + expect(!camera._zooming).toBeTruthy(); + }); + + test('resets camera._rotating', () => { + const camera = createCamera(); + camera.rotateTo(90); + camera.stop(); + expect(!camera._rotating).toBeTruthy(); + }); + + test('emits moveend if panning, preserving eventData', done => { + const camera = createCamera(); + const eventData = {data: 'ok'}; + + camera.on('moveend', (d) => { + expect(d.data).toBe('ok'); + done(); + }); + + camera.panTo([100, 0], {}, eventData); + camera.stop(); + }); + + test('emits moveend if zooming, preserving eventData', done => { + const camera = createCamera(); + const eventData = {data: 'ok'}; + + camera.on('moveend', (d) => { + expect(d.data).toBe('ok'); + done(); + }); + + camera.zoomTo(3.2, {}, eventData); + camera.stop(); + }); + + test('emits moveend if rotating, preserving eventData', done => { + const camera = createCamera(); + const eventData = {data: 'ok'}; + + camera.on('moveend', (d) => { + expect(d.data).toBe('ok'); + done(); + }); + + camera.rotateTo(90, {}, eventData); + camera.stop(); + }); + + test('does not emit moveend if not moving', done => { + const camera = createCamera(); + const eventData = {data: 'ok'}; + + camera.on('moveend', (d) => { + expect(d.data).toBe('ok'); + camera.stop(); + done(); // Fails with ".end() called twice" if we get here a second time. + }); + + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + camera.panTo([100, 0], {duration: 1}, eventData); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + }, 0); + }); +}); + +describe('#cameraForBounds', () => { + test('no options passed', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(transform.zoom, 3)).toBe(2.469); + }); + + test('bearing positive number', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {bearing: 175}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(transform.zoom, 3)).toBe(2.558); + expect(transform.bearing).toBe(175); + }); + + test('bearing negative number', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {bearing: -30}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(transform.zoom, 3)).toBe(2.392); + expect(transform.bearing).toBe(-30); + }); + + test('padding number', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {padding: 15}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(transform.zoom, 3)).toBe(2.382); + }); + + test('padding object', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {padding: {top: 15, right: 15, bottom: 15, left: 15}, duration: 0}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -100.5, lat: 34.7171}); + }); + + test('asymmetrical padding', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration: 0}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -96.5558, lat: 32.0833}); + }); + + test('bearing and asymmetrical padding', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {bearing: 90, padding: {top: 10, right: 75, bottom: 50, left: 25}, duration: 0}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -103.3761, lat: 31.7099}); + }); + + test('offset', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {offset: [0, 100]}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -100.5, lat: 44.4717}); + }); + + test('offset and padding', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, offset: [0, 100]}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -96.5558, lat: 44.4189}); + }); + + test('bearing, asymmetrical padding, and offset', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + const transform = camera.cameraForBounds(bb, {bearing: 90, padding: {top: 10, right: 75, bottom: 50, left: 25}, offset: [0, 100], duration: 0}); + + expect(fixedLngLat(transform.center, 4)).toEqual({lng: -103.3761, lat: 43.0929}); + }); +}); + +describe('#fitBounds', () => { + test('no padding passed', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + camera.fitBounds(bb, {duration: 0}); + + expect(fixedLngLat(camera.getCenter(), 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(camera.getZoom(), 3)).toBe(2.469); + }); + + test('padding number', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + camera.fitBounds(bb, {padding: 15, duration: 0}); + + expect(fixedLngLat(camera.getCenter(), 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(camera.getZoom(), 3)).toBe(2.382); + }); + + test('padding object', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + camera.fitBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration: 0}); + + expect(fixedLngLat(camera.getCenter(), 4)).toEqual({lng: -96.5558, lat: 32.0833}); + }); + + test('padding does not get propagated to transform.padding', () => { + const camera = createCamera(); + const bb = [[-133, 16], [-68, 50]]; + camera.fitBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration: 0}); + const padding = camera.transform.padding; + + expect(padding).toEqual({ + left: 0, + right: 0, + top: 0, + bottom: 0 + }); + }); +}); + +describe('#fitScreenCoordinates', () => { + test('bearing 225', () => { + const camera = createCamera(); + const p0 = [128, 128]; + const p1 = [256, 256]; + const bearing = 225; + camera.fitScreenCoordinates(p0, p1, bearing, {duration: 0}); + + expect(fixedLngLat(camera.getCenter(), 4)).toEqual({lng: -45, lat: 40.9799}); + expect(fixedNum(camera.getZoom(), 3)).toBe(1.5); + expect(camera.getBearing()).toBe(-135); + }); + + test('bearing 0', () => { + const camera = createCamera(); + const p0 = [128, 128]; + const p1 = [256, 256]; + const bearing = 0; + camera.fitScreenCoordinates(p0, p1, bearing, {duration: 0}); + + expect(fixedLngLat(camera.getCenter(), 4)).toEqual({lng: -45, lat: 40.9799}); + expect(fixedNum(camera.getZoom(), 3)).toBe(2); + expect(camera.getBearing()).toBeCloseTo(0); + }); + + test('inverted points', () => { + const camera = createCamera(); + const p1 = [128, 128]; + const p0 = [256, 256]; + const bearing = 0; + camera.fitScreenCoordinates(p0, p1, bearing, {duration: 0}); + + expect(fixedLngLat(camera.getCenter(), 4)).toEqual({lng: -45, lat: 40.9799}); + expect(fixedNum(camera.getZoom(), 3)).toBe(2); + expect(camera.getBearing()).toBeCloseTo(0); + }); +}); + +describe('queryTerrainElevation', () => { + let camera: Camera; + + beforeEach(() => { + camera = createCamera(); + }); + + test('should return null if terrain is not set', () => { + camera.terrain = null; + const result = camera.queryTerrainElevation([0, 0]); + expect(result).toBeNull(); + }); + + test('should return the correct elevation', () => { + // Set up mock transform and terrain objects + const transform = new Transform(0, 22, 0, 60, true); + transform.elevation = 50; + const terrain = { + getElevationForLngLatZoom: jest.fn().mockReturnValue(200) + } as any as Terrain; + + // Set up camera with mock transform and terrain + camera.transform = transform; + camera.terrain = terrain; + + // Call queryTerrainElevation with mock lngLat + const lngLatLike: LngLatLike = [1, 2]; + const expectedElevation = 150; // 200 - 50 = 150 + const result = camera.queryTerrainElevation(lngLatLike); + + // Check that transform.getElevation was called with the correct arguments + expect(terrain.getElevationForLngLatZoom).toHaveBeenCalledWith( + expect.objectContaining({ + lng: lngLatLike[0], + lat: lngLatLike[1], + }), + transform.tileZoom + ); + + // Check that the correct elevation value was returned + expect(result).toEqual(expectedElevation); + }); +}); + +describe('#transformCameraUpdate', () => { + + test('invoke transformCameraUpdate callback during jumpTo', done => { + const camera = createCamera(); + + let callbackCount = 0; + let eventCount = 0; + + camera.transformCameraUpdate = () => { + callbackCount++; + return {}; + }; + + camera + .on('move', () => { + eventCount++; + expect(eventCount).toBe(callbackCount); + }) + .on('moveend', () => { + done(); + }); + + camera.jumpTo({center: [100, 0]}); + }); + + test('invoke transformCameraUpdate callback during easeTo', done => { + expect.assertions(2); + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + + let callbackCount = 0; + let eventCount = 0; + + camera.transformCameraUpdate = () => { + callbackCount++; + return {}; + }; + + camera + .on('move', () => { + eventCount++; + expect(eventCount).toBe(callbackCount); + }) + .on('moveend', () => { + done(); + }); + + camera.easeTo({center: [100, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('invoke transformCameraUpdate callback during flyTo', done => { + expect.assertions(2); + const camera = createCamera(); + const stub = jest.spyOn(browser, 'now'); + stub.mockImplementation(() => 0); + + let callbackCount = 0; + let eventCount = 0; + + camera.transformCameraUpdate = () => { + callbackCount++; + return {}; + }; + + camera + .on('move', () => { + eventCount++; + expect(eventCount).toBe(callbackCount); + }) + .on('moveend', () => { + done(); + }); + + camera.flyTo({center: [100, 0], duration: 10}); + + setTimeout(() => { + stub.mockImplementation(() => 1); + camera.simulateFrame(); + + setTimeout(() => { + stub.mockImplementation(() => 10); + camera.simulateFrame(); + }, 0); + }, 0); + }); + + test('transformCameraUpdate overrides proposed camera settings', () => { + const camera = createCamera(); + + camera.transformCameraUpdate = ({center, zoom}) => { + return { + center: LngLat.convert([center.lng, center.lat + 10]), + zoom: Math.round(zoom) + }; + }; + + camera.flyTo({center: [100, 0], zoom: 3.2, animate: false}); + expect(fixedLngLat(camera.getCenter())).toEqual({lng: 100, lat: 10}); + expect(fixedNum(camera.getZoom())).toBe(3); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/camera.ts b/web/libraries/maplibre-gl/src/ui/camera.ts new file mode 100644 index 00000000..0631b114 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/camera.ts @@ -0,0 +1,1478 @@ +import {extend, warnOnce, clamp, wrap, defaultEasing, pick} from '../util/util'; +import {interpolates} from '@maplibre/maplibre-gl-style-spec'; +import {browser} from '../util/browser'; +import {LngLat} from '../geo/lng_lat'; +import {LngLatBounds} from '../geo/lng_lat_bounds'; +import Point from '@mapbox/point-geometry'; +import {Event, Evented} from '../util/evented'; +import {Terrain} from '../render/terrain'; + +import type {Transform} from '../geo/transform'; +import type {LngLatLike} from '../geo/lng_lat'; +import type {LngLatBoundsLike} from '../geo/lng_lat_bounds'; +import type {TaskID} from '../util/task_queue'; +import type {PaddingOptions} from '../geo/edge_insets'; +import {MercatorCoordinate} from '../geo/mercator_coordinate'; + +/** + * A [Point](https://github.com/mapbox/point-geometry) or an array of two numbers representing `x` and `y` screen coordinates in pixels. + * + * @group Geography and Geometry + * + * @example + * ```ts + * let p1 = new Point(-77, 38); // a PointLike which is a Point + * let p2 = [-77, 38]; // a PointLike which is an array of two numbers + * ``` + */ +export type PointLike = Point | [number, number]; + +/** + * A helper to allow require of at least one propery + */ +export type RequireAtLeastOne = { [K in keyof T]-?: Required> & Partial>>; }[keyof T]; + +/** + * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location, + * zoom, bearing, and pitch of the camera. All properties are optional, and when a property is omitted, the current + * camera value for that property will remain unchanged. + * + * @example + * Set the map's initial perspective with CameraOptions + * ```ts + * let map = new maplibregl.Map({ + * container: 'map', + * style: 'https://demotiles.maplibre.org/style.json', + * center: [-73.5804, 45.53483], + * pitch: 60, + * bearing: -60, + * zoom: 10 + * }); + * ``` + * @see [Set pitch and bearing](https://maplibre.org/maplibre-gl-js/docs/examples/set-perspective/) + * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/) + * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/) + * @see [Display buildings in 3D](https://maplibre.org/maplibre-gl-js/docs/examples/3d-buildings/) + */ +export type CameraOptions = CenterZoomBearing & { + /** + * The desired pitch in degrees. The pitch is the angle towards the horizon + * measured in degrees with a range between 0 and 60 degrees. For example, pitch: 0 provides the appearance + * of looking straight down at the map, while pitch: 60 tilts the user's perspective towards the horizon. + * Increasing the pitch value is often used to display 3D objects. + */ + pitch?: number; + /** + * If `zoom` is specified, `around` determines the point around which the zoom is centered. + */ + around?: LngLatLike; +}; + +/** + * Holds center, zoom and bearing properties + */ +export type CenterZoomBearing = { + /** + * The desired center. + */ + center?: LngLatLike; + /** + * The desired zoom level. + */ + zoom?: number; + /** + * The desired bearing in degrees. The bearing is the compass direction that + * is "up". For example, `bearing: 90` orients the map so that east is up. + */ + bearing?: number; +} + +/** + * The options object related to the {@link Map#jumpTo} method + */ +export type JumpToOptions = CameraOptions & { + /** + * Dimensions in pixels applied on each side of the viewport for shifting the vanishing point. + */ + padding?: PaddingOptions; +} + +/** + * A options object for the {@link Map#cameraForBounds} method + */ +export type CameraForBoundsOptions = CameraOptions & { + /** + * The amount of padding in pixels to add to the given bounds. + */ + padding?: number | RequireAtLeastOne; + /** + * The center of the given bounds relative to the map's center, measured in pixels. + * @defaultValue [0, 0] + */ + offset?: PointLike; + /** + * The maximum zoom level to allow when the camera would transition to the specified bounds. + */ + maxZoom?: number; +} + +/** + * The {@link Map#flyTo} options object + */ +export type FlyToOptions = AnimationOptions & CameraOptions & { + /** + * The zooming "curve" that will occur along the + * flight path. A high value maximizes zooming for an exaggerated animation, while a low + * value minimizes zooming for an effect closer to {@link Map#easeTo}. 1.42 is the average + * value selected by participants in the user study discussed in + * [van Wijk (2003)](https://www.win.tue.nl/~vanwijk/zoompan.pdf). A value of + * `Math.pow(6, 0.25)` would be equivalent to the root mean squared average velocity. A + * value of 1 would produce a circular motion. + * @defaultValue 1.42 + */ + curve?: number; + /** + * The zero-based zoom level at the peak of the flight path. If + * `options.curve` is specified, this option is ignored. + */ + minZoom?: number; + /** + * The average speed of the animation defined in relation to + * `options.curve`. A speed of 1.2 means that the map appears to move along the flight path + * by 1.2 times `options.curve` screenfuls every second. A _screenful_ is the map's visible span. + * It does not correspond to a fixed physical distance, but varies by zoom level. + * @defaultValue 1.2 + */ + speed?: number; + /** + * The average speed of the animation measured in screenfuls + * per second, assuming a linear timing curve. If `options.speed` is specified, this option is ignored. + */ + screenSpeed?: number; + /** + * The animation's maximum duration, measured in milliseconds. + * If duration exceeds maximum duration, it resets to 0. + */ + maxDuration?: number; + /** + * The amount of padding in pixels to add to the given bounds. + */ + padding?: number | RequireAtLeastOne; +} + +export type EaseToOptions = AnimationOptions & CameraOptions & { + delayEndEvents?: number; + padding?: number | RequireAtLeastOne; +} + +/** + * Options for {@link Map#fitBounds} method + */ +export type FitBoundsOptions = FlyToOptions & { + /** + * If `true`, the map transitions using {@link Map#easeTo}. If `false`, the map transitions using {@link Map#flyTo}. + * See those functions and {@link AnimationOptions} for information about options available. + * @defaultValue false + */ + linear?: boolean; + /** + * The center of the given bounds relative to the map's center, measured in pixels. + * @defaultValue [0, 0] + */ + offset?: PointLike; + /** + * The maximum zoom level to allow when the map view transitions to the specified bounds. + */ + maxZoom?: number; +} + +/** + * Options common to map movement methods that involve animation, such as {@link Map#panBy} and + * {@link Map#easeTo}, controlling the duration and easing function of the animation. All properties + * are optional. + * + */ +export type AnimationOptions = { + /** + * The animation's duration, measured in milliseconds. + */ + duration?: number; + /** + * A function taking a time in the range 0..1 and returning a number where 0 is + * the initial state and 1 is the final state. + */ + easing?: (_: number) => number; + /** + * of the target center relative to real map container center at the end of animation. + */ + offset?: PointLike; + /** + * If `false`, no animation will occur. + */ + animate?: boolean; + /** + * If `true`, then the animation is considered essential and will not be affected by + * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/\@media/prefers-reduced-motion). + */ + essential?: boolean; + /** + * Default false. Needed in 3D maps to let the camera stay in a constant + * height based on sea-level. After the animation finished the zoom-level will be recalculated in respect of + * the distance from the camera to the center-coordinate-altitude. + */ + freezeElevation?: boolean; +}; + +/** + * A callback hook that allows manipulating the camera and being notified about camera updates before they happen + */ +export type CameraUpdateTransformFunction = (next: { + center: LngLat; + zoom: number; + pitch: number; + bearing: number; + elevation: number; +}) => { + center?: LngLat; + zoom?: number; + pitch?: number; + bearing?: number; + elevation?: number; +}; + +export abstract class Camera extends Evented { + transform: Transform; + terrain: Terrain; + + _moving: boolean; + _zooming: boolean; + _rotating: boolean; + _pitching: boolean; + _padding: boolean; + + _bearingSnap: number; + _easeStart: number; + _easeOptions: { + duration?: number; + easing?: (_: number) => number; + }; + _easeId: string | void; + + _onEaseFrame: (_: number) => void; + _onEaseEnd: (easeId?: string) => void; + _easeFrameId: TaskID; + + /** + * @internal + * holds the geographical coordinate of the target + */ + _elevationCenter: LngLat; + /** + * @internal + * holds the targ altitude value, = center elevation of the target. + * This value may changes during flight, because new terrain-tiles loads during flight. + */ + _elevationTarget: number; + /** + * @internal + * holds the start altitude value, = center elevation before animation begins + * this value will recalculated during flight in respect of changing _elevationTarget values, + * so the linear interpolation between start and target keeps smooth and without jumps. + */ + _elevationStart: number; + /** + * @internal + * Saves the current state of the elevation freeze - this is used during map movement to prevent "rocky" camera movement. + */ + _elevationFreeze: boolean; + /** + * @internal + * Used to track accumulated changes during continuous interaction + */ + _requestedCameraState?: Transform; + /** + * A callback used to defer camera updates or apply arbitrary constraints. + * If specified, this Camera instance can be used as a stateless component in React etc. + */ + transformCameraUpdate: CameraUpdateTransformFunction | null; + + abstract _requestRenderFrame(a: () => void): TaskID; + abstract _cancelRenderFrame(_: TaskID): void; + + constructor(transform: Transform, options: { + bearingSnap: number; + }) { + super(); + this._moving = false; + this._zooming = false; + this.transform = transform; + this._bearingSnap = options.bearingSnap; + + this.on('moveend', () => { + delete this._requestedCameraState; + }); + } + + /** + * Returns the map's geographical centerpoint. + * + * @returns The map's geographical centerpoint. + * @example + * Return a LngLat object such as `{lng: 0, lat: 0}` + * ```ts + * let center = map.getCenter(); + * // access longitude and latitude values directly + * let {lng, lat} = map.getCenter(); + * ``` + */ + getCenter(): LngLat { return new LngLat(this.transform.center.lng, this.transform.center.lat); } + + /** + * Sets the map's geographical centerpoint. Equivalent to `jumpTo({center: center})`. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param center - The centerpoint to set. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * map.setCenter([-74, 38]); + * ``` + */ + setCenter(center: LngLatLike, eventData?: any) { + return this.jumpTo({center}, eventData); + } + + /** + * Pans the map by the specified offset. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param offset - `x` and `y` coordinates by which to pan the map. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + panBy(offset: PointLike, options?: AnimationOptions, eventData?: any): this { + offset = Point.convert(offset).mult(-1); + return this.panTo(this.transform.center, extend({offset}, options), eventData); + } + + /** + * Pans the map to the specified location with an animated transition. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param lnglat - The location to pan the map to. + * @param options - Options describing the destination and animation of the transition. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * map.panTo([-74, 38]); + * // Specify that the panTo animation should last 5000 milliseconds. + * map.panTo([-74, 38], {duration: 5000}); + * ``` + * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/) + */ + panTo(lnglat: LngLatLike, options?: AnimationOptions, eventData?: any): this { + return this.easeTo(extend({ + center: lnglat + }, options), eventData); + } + + /** + * Returns the map's current zoom level. + * + * @returns The map's current zoom level. + * @example + * ```ts + * map.getZoom(); + * ``` + */ + getZoom(): number { return this.transform.zoom; } + + /** + * Sets the map's zoom level. Equivalent to `jumpTo({zoom: zoom})`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param zoom - The zoom level to set (0-20). + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom to the zoom level 5 without an animated transition + * ```ts + * map.setZoom(5); + * ``` + */ + setZoom(zoom: number, eventData?: any): this { + this.jumpTo({zoom}, eventData); + return this; + } + + /** + * Zooms the map to the specified zoom level, with an animated transition. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param zoom - The zoom level to transition to. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // Zoom to the zoom level 5 without an animated transition + * map.zoomTo(5); + * // Zoom to the zoom level 8 with an animated transition + * map.zoomTo(8, { + * duration: 2000, + * offset: [100, 50] + * }); + * ``` + */ + zoomTo(zoom: number, options?: AnimationOptions | null, eventData?: any): this { + return this.easeTo(extend({ + zoom + }, options), eventData); + } + + /** + * Increases the map's zoom level by 1. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom the map in one level with a custom animation duration + * ```ts + * map.zoomIn({duration: 1000}); + * ``` + */ + zoomIn(options?: AnimationOptions, eventData?: any): this { + this.zoomTo(this.getZoom() + 1, options, eventData); + return this; + } + + /** + * Decreases the map's zoom level by 1. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, and `zoomend`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Zoom the map out one level with a custom animation offset + * ```ts + * map.zoomOut({offset: [80, 60]}); + * ``` + */ + zoomOut(options?: AnimationOptions, eventData?: any): this { + this.zoomTo(this.getZoom() - 1, options, eventData); + return this; + } + + /** + * Returns the map's current bearing. The bearing is the compass direction that is "up"; for example, a bearing + * of 90° orients the map so that east is up. + * + * @returns The map's current bearing. + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + getBearing(): number { return this.transform.bearing; } + + /** + * Sets the map's bearing (rotation). The bearing is the compass direction that is "up"; for example, a bearing + * of 90° orients the map so that east is up. + * + * Equivalent to `jumpTo({bearing: bearing})`. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param bearing - The desired bearing. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Rotate the map to 90 degrees + * ```ts + * map.setBearing(90); + * ``` + */ + setBearing(bearing: number, eventData?: any): this { + this.jumpTo({bearing}, eventData); + return this; + } + + /** + * Returns the current padding applied around the map viewport. + * + * @returns The current padding around the map viewport. + */ + getPadding(): PaddingOptions { return this.transform.padding; } + + /** + * Sets the padding in pixels around the viewport. + * + * Equivalent to `jumpTo({padding: padding})`. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param padding - The desired padding. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * Sets a left padding of 300px, and a top padding of 50px + * ```ts + * map.setPadding({ left: 300, top: 50 }); + * ``` + */ + setPadding(padding: PaddingOptions, eventData?: any): this { + this.jumpTo({padding}, eventData); + return this; + } + + /** + * Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction + * that is "up"; for example, a bearing of 90° orients the map so that east is up. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param bearing - The desired bearing. + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + rotateTo(bearing: number, options?: AnimationOptions, eventData?: any): this { + return this.easeTo(extend({ + bearing + }, options), eventData); + } + + /** + * Rotates the map so that north is up (0° bearing), with an animated transition. + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + resetNorth(options?: AnimationOptions, eventData?: any): this { + this.rotateTo(0, extend({duration: 1000}, options), eventData); + return this; + } + + /** + * Rotates and pitches the map so that north is up (0° bearing) and pitch is 0°, with an animated transition. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `pitchstart`, `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + resetNorthPitch(options?: AnimationOptions, eventData?: any): this { + this.easeTo(extend({ + bearing: 0, + pitch: 0, + duration: 1000 + }, options), eventData); + return this; + } + + /** + * Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the + * `bearingSnap` threshold). + * + * Triggers the following events: `movestart`, `moveend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + snapToNorth(options?: AnimationOptions, eventData?: any): this { + if (Math.abs(this.getBearing()) < this._bearingSnap) { + return this.resetNorth(options, eventData); + } + return this; + } + + /** + * Returns the map's current pitch (tilt). + * + * @returns The map's current pitch, measured in degrees away from the plane of the screen. + */ + getPitch(): number { return this.transform.pitch; } + + /** + * Sets the map's pitch (tilt). Equivalent to `jumpTo({pitch: pitch})`. + * + * Triggers the following events: `movestart`, `moveend`, `pitchstart`, and `pitchend`. + * + * @param pitch - The pitch to set, measured in degrees away from the plane of the screen (0-60). + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + */ + setPitch(pitch: number, eventData?: any): this { + this.jumpTo({pitch}, eventData); + return this; + } + + /** + * @param bounds - Calculate the center for these bounds in the viewport and use + * the highest zoom level up to and including `Map#getMaxZoom()` that fits + * in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0. + * @param options - Options object + * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`. + * If map is unable to fit, method will warn and return undefined. + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * let newCameraTransform = map.cameraForBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + */ + cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CenterZoomBearing { + bounds = LngLatBounds.convert(bounds); + const bearing = options && options.bearing || 0; + return this._cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), bearing, options); + } + + /** + * @internal + * Calculate the center of these two points in the viewport and use + * the highest zoom level up to and including `Map#getMaxZoom()` that fits + * the points in the viewport at the specified bearing. + * @param p0 - First point + * @param p1 - Second point + * @param bearing - Desired map bearing at end of animation, in degrees + * @param options - the camera options + * @returns If map is able to fit to provided bounds, returns `center`, `zoom`, and `bearing`. + * If map is unable to fit, method will warn and return undefined. + * @example + * ```ts + * let p0 = [-79, 43]; + * let p1 = [-73, 45]; + * let bearing = 90; + * let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + */ + _cameraForBoxAndBearing(p0: LngLatLike, p1: LngLatLike, bearing: number, options?: CameraForBoundsOptions): CenterZoomBearing { + const defaultPadding = { + top: 0, + bottom: 0, + right: 0, + left: 0 + }; + options = extend({ + padding: defaultPadding, + offset: [0, 0], + maxZoom: this.transform.maxZoom + }, options); + + if (typeof options.padding === 'number') { + const p = options.padding; + options.padding = { + top: p, + bottom: p, + right: p, + left: p + }; + } + + options.padding = extend(defaultPadding, options.padding) as PaddingOptions; + const tr = this.transform; + const edgePadding = tr.padding; + + // We want to calculate the upper right and lower left of the box defined by p0 and p1 + // in a coordinate system rotate to match the destination bearing. + const p0world = tr.project(LngLat.convert(p0)); + const p1world = tr.project(LngLat.convert(p1)); + const p0rotated = p0world.rotate(-bearing * Math.PI / 180); + const p1rotated = p1world.rotate(-bearing * Math.PI / 180); + + const upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y)); + const lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y)); + + // Calculate zoom: consider the original bbox and padding. + const size = upperRight.sub(lowerLeft); + const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x; + const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y; + + if (scaleY < 0 || scaleX < 0) { + warnOnce( + 'Map cannot fit within canvas with the given bounds, padding, and/or offset.' + ); + return undefined; + } + + const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom); + + // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding. + const offset = Point.convert(options.offset); + const paddingOffsetX = (options.padding.left - options.padding.right) / 2; + const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2; + const paddingOffset = new Point(paddingOffsetX, paddingOffsetY); + const rotatedPaddingOffset = paddingOffset.rotate(bearing * Math.PI / 180); + const offsetAtInitialZoom = offset.add(rotatedPaddingOffset); + const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom)); + + const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom)); + + return { + center, + zoom, + bearing + }; + } + + /** + * Pans and zooms the map to contain its visible area within the specified geographical bounds. + * This function will also reset the map's bearing to 0 if bearing is nonzero. + * + * Triggers the following events: `movestart` and `moveend`. + * + * @param bounds - Center these bounds in the viewport and use the highest + * zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport. + * @param options- Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * let bbox = [[-79, 43], [-73, 45]]; + * map.fitBounds(bbox, { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js/docs/examples/fitbounds/) + */ + fitBounds(bounds: LngLatBoundsLike, options?: FitBoundsOptions, eventData?: any): this { + return this._fitInternal( + this.cameraForBounds(bounds, options), + options, + eventData); + } + + /** + * Pans, rotates and zooms the map to to fit the box made by points p0 and p1 + * once the map is rotated to the specified bearing. To zoom without rotating, + * pass in the current map bearing. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend` and `rotate`. + * + * @param p0 - First point on screen, in pixel coordinates + * @param p1 - Second point on screen, in pixel coordinates + * @param bearing - Desired map bearing at end of animation, in degrees + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * let p0 = [220, 400]; + * let p1 = [500, 900]; + * map.fitScreenCoordinates(p0, p1, map.getBearing(), { + * padding: {top: 10, bottom:25, left: 15, right: 5} + * }); + * ``` + * @see Used by {@link BoxZoomHandler} + */ + fitScreenCoordinates(p0: PointLike, p1: PointLike, bearing: number, options?: FitBoundsOptions, eventData?: any): this { + return this._fitInternal( + this._cameraForBoxAndBearing( + this.transform.pointLocation(Point.convert(p0)), + this.transform.pointLocation(Point.convert(p1)), + bearing, + options), + options, + eventData); + } + + _fitInternal(calculatedOptions?: CenterZoomBearing, options?: FitBoundsOptions, eventData?: any): this { + // cameraForBounds warns + returns undefined if unable to fit: + if (!calculatedOptions) return this; + + options = extend(calculatedOptions, options); + // Explicitly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly. + delete options.padding; + + return options.linear ? + this.easeTo(options, eventData) : + this.flyTo(options, eventData); + } + + /** + * Changes any combination of center, zoom, bearing, and pitch, without + * an animated transition. The map will retain its current values for any + * details not specified in `options`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options object + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // jump to coordinates at current zoom + * map.jumpTo({center: [0, 0]}); + * // jump with zoom, pitch, and bearing options + * map.jumpTo({ + * center: [0, 0], + * zoom: 8, + * pitch: 45, + * bearing: 90 + * }); + * ``` + * @see [Jump to a series of locations](https://maplibre.org/maplibre-gl-js/docs/examples/jump-to/) + * @see [Update a feature in realtime](https://maplibre.org/maplibre-gl-js/docs/examples/live-update-feature/) + */ + jumpTo(options: JumpToOptions, eventData?: any): this { + this.stop(); + + const tr = this._getTransformForUpdate(); + let zoomChanged = false, + bearingChanged = false, + pitchChanged = false; + + if ('zoom' in options && tr.zoom !== +options.zoom) { + zoomChanged = true; + tr.zoom = +options.zoom; + } + + if (options.center !== undefined) { + tr.center = LngLat.convert(options.center); + } + + if ('bearing' in options && tr.bearing !== +options.bearing) { + bearingChanged = true; + tr.bearing = +options.bearing; + } + + if ('pitch' in options && tr.pitch !== +options.pitch) { + pitchChanged = true; + tr.pitch = +options.pitch; + } + + if (options.padding != null && !tr.isPaddingEqual(options.padding)) { + tr.padding = options.padding; + } + this._applyUpdatedTransform(tr); + + this.fire(new Event('movestart', eventData)) + .fire(new Event('move', eventData)); + + if (zoomChanged) { + this.fire(new Event('zoomstart', eventData)) + .fire(new Event('zoom', eventData)) + .fire(new Event('zoomend', eventData)); + } + + if (bearingChanged) { + this.fire(new Event('rotatestart', eventData)) + .fire(new Event('rotate', eventData)) + .fire(new Event('rotateend', eventData)); + } + + if (pitchChanged) { + this.fire(new Event('pitchstart', eventData)) + .fire(new Event('pitch', eventData)) + .fire(new Event('pitchend', eventData)); + } + + return this.fire(new Event('moveend', eventData)); + } + + /** + * Calculates pitch, zoom and bearing for looking at `newCenter` with the camera position being `newCenter` + * and returns them as {@link CameraOptions}. + * @param from - The camera to look from + * @param altitudeFrom - The altitude of the camera to look from + * @param to - The center to look at + * @param altitudeTo - Optional altitude of the center to look at. If none given the ground height will be used. + * @returns the calculated camera options + */ + calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo: number = 0): CameraOptions { + const fromMerc = MercatorCoordinate.fromLngLat(from, altitudeFrom); + const toMerc = MercatorCoordinate.fromLngLat(to, altitudeTo); + const dx = toMerc.x - fromMerc.x; + const dy = toMerc.y - fromMerc.y; + const dz = toMerc.z - fromMerc.z; + + const distance3D = Math.hypot(dx, dy, dz); + if (distance3D === 0) throw new Error('Can\'t calculate camera options with same From and To'); + + const groundDistance = Math.hypot(dx, dy); + + const zoom = this.transform.scaleZoom(this.transform.cameraToCenterDistance / distance3D / this.transform.tileSize); + const bearing = (Math.atan2(dx, -dy) * 180) / Math.PI; + let pitch = (Math.acos(groundDistance / distance3D) * 180) / Math.PI; + pitch = dz < 0 ? 90 - pitch : 90 + pitch; + + return { + center: toMerc.toLngLat(), + zoom, + pitch, + bearing + }; + } + + /** + * Changes any combination of `center`, `zoom`, `bearing`, `pitch`, and `padding` with an animated transition + * between old and new values. The map will retain its current values for any + * details not specified in `options`. + * + * Note: The transition will happen instantly if the user has enabled + * the `reduced motion` accessibility feature enabled in their operating system, + * unless `options` includes `essential: true`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options describing the destination and animation of the transition. + * Accepts {@link CameraOptions} and {@link AnimationOptions}. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @see [Navigate the map with game-like controls](https://maplibre.org/maplibre-gl-js/docs/examples/game-controls/) + */ + easeTo(options: EaseToOptions & { + easeId?: string; + noMoveStart?: boolean; + }, eventData?: any): this { + this._stop(false, options.easeId); + + options = extend({ + offset: [0, 0], + duration: 500, + easing: defaultEasing + }, options); + + if (options.animate === false || (!options.essential && browser.prefersReducedMotion)) options.duration = 0; + + const tr = this._getTransformForUpdate(), + startZoom = this.getZoom(), + startBearing = this.getBearing(), + startPitch = this.getPitch(), + startPadding = this.getPadding(), + + zoom = 'zoom' in options ? +options.zoom : startZoom, + bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing, + pitch = 'pitch' in options ? +options.pitch : startPitch, + padding = 'padding' in options ? options.padding : tr.padding; + + const offsetAsPoint = Point.convert(options.offset); + let pointAtOffset = tr.centerPoint.add(offsetAsPoint); + const locationAtOffset = tr.pointLocation(pointAtOffset); + const center = LngLat.convert(options.center || locationAtOffset); + this._normalizeCenter(center); + + const from = tr.project(locationAtOffset); + const delta = tr.project(center).sub(from); + const finalScale = tr.zoomScale(zoom - startZoom); + + let around, aroundPoint; + + if (options.around) { + around = LngLat.convert(options.around); + aroundPoint = tr.locationPoint(around); + } + + const currently = { + moving: this._moving, + zooming: this._zooming, + rotating: this._rotating, + pitching: this._pitching + }; + + this._zooming = this._zooming || (zoom !== startZoom); + this._rotating = this._rotating || (startBearing !== bearing); + this._pitching = this._pitching || (pitch !== startPitch); + this._padding = !tr.isPaddingEqual(padding as PaddingOptions); + + this._easeId = options.easeId; + this._prepareEase(eventData, options.noMoveStart, currently); + if (this.terrain) this._prepareElevation(center); + + this._ease((k) => { + if (this._zooming) { + tr.zoom = interpolates.number(startZoom, zoom, k); + } + if (this._rotating) { + tr.bearing = interpolates.number(startBearing, bearing, k); + } + if (this._pitching) { + tr.pitch = interpolates.number(startPitch, pitch, k); + } + if (this._padding) { + tr.interpolatePadding(startPadding, padding as PaddingOptions, k); + // When padding is being applied, Transform#centerPoint is changing continuously, + // thus we need to recalculate offsetPoint every frame + pointAtOffset = tr.centerPoint.add(offsetAsPoint); + } + + if (this.terrain && !options.freezeElevation) this._updateElevation(k); + + if (around) { + tr.setLocationAtPoint(around, aroundPoint); + } else { + const scale = tr.zoomScale(tr.zoom - startZoom); + const base = zoom > startZoom ? + Math.min(2, finalScale) : + Math.max(0.5, finalScale); + const speedup = Math.pow(base, 1 - k); + const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale)); + tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset); + } + + this._applyUpdatedTransform(tr); + + this._fireMoveEvents(eventData); + + }, (interruptingEaseId?: string) => { + if (this.terrain) this._finalizeElevation(); + this._afterEase(eventData, interruptingEaseId); + }, options as any); + + return this; + } + + _prepareEase(eventData: any, noMoveStart: boolean, currently: any = {}) { + this._moving = true; + if (!noMoveStart && !currently.moving) { + this.fire(new Event('movestart', eventData)); + } + if (this._zooming && !currently.zooming) { + this.fire(new Event('zoomstart', eventData)); + } + if (this._rotating && !currently.rotating) { + this.fire(new Event('rotatestart', eventData)); + } + if (this._pitching && !currently.pitching) { + this.fire(new Event('pitchstart', eventData)); + } + } + + _prepareElevation(center: LngLat) { + this._elevationCenter = center; + this._elevationStart = this.transform.elevation; + this._elevationTarget = this.terrain.getElevationForLngLatZoom(center, this.transform.tileZoom); + this._elevationFreeze = true; + } + + _updateElevation(k: number) { + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom); + const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom); + // target terrain updated during flight, slowly move camera to new height + if (k < 1 && elevation !== this._elevationTarget) { + const pitch1 = this._elevationTarget - this._elevationStart; + const pitch2 = (elevation - (pitch1 * k + this._elevationStart)) / (1 - k); + this._elevationStart += k * (pitch1 - pitch2); + this._elevationTarget = elevation; + } + this.transform.elevation = interpolates.number(this._elevationStart, this._elevationTarget, k); + } + + _finalizeElevation() { + this._elevationFreeze = false; + this.transform.recalculateZoom(this.terrain); + } + + /** + * @internal + * Called when the camera is about to be manipulated. + * If `transformCameraUpdate` is specified, a copy of the current transform is created to track the accumulated changes. + * This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls. + * It may differ from the state used for rendering (`this.transform`). + * @returns Transform to apply changes to + */ + _getTransformForUpdate(): Transform { + if (!this.transformCameraUpdate) return this.transform; + + if (!this._requestedCameraState) { + this._requestedCameraState = this.transform.clone(); + } + return this._requestedCameraState; + } + + /** + * @internal + * Called after the camera is done being manipulated. + * @param tr - the requested camera end state + * Call `transformCameraUpdate` if present, and then apply the "approved" changes. + */ + _applyUpdatedTransform(tr: Transform) { + if (!this.transformCameraUpdate) return; + + const nextTransform = tr.clone(); + const { + center, + zoom, + pitch, + bearing, + elevation + } = this.transformCameraUpdate(nextTransform); + if (center) nextTransform.center = center; + if (zoom !== undefined) nextTransform.zoom = zoom; + if (pitch !== undefined) nextTransform.pitch = pitch; + if (bearing !== undefined) nextTransform.bearing = bearing; + if (elevation !== undefined) nextTransform.elevation = elevation; + this.transform.apply(nextTransform); + } + + _fireMoveEvents(eventData?: any) { + this.fire(new Event('move', eventData)); + if (this._zooming) { + this.fire(new Event('zoom', eventData)); + } + if (this._rotating) { + this.fire(new Event('rotate', eventData)); + } + if (this._pitching) { + this.fire(new Event('pitch', eventData)); + } + } + + _afterEase(eventData?: any, easeId?: string) { + // if this easing is being stopped to start another easing with + // the same id then don't fire any events to avoid extra start/stop events + if (this._easeId && easeId && this._easeId === easeId) { + return; + } + delete this._easeId; + + const wasZooming = this._zooming; + const wasRotating = this._rotating; + const wasPitching = this._pitching; + this._moving = false; + this._zooming = false; + this._rotating = false; + this._pitching = false; + this._padding = false; + + if (wasZooming) { + this.fire(new Event('zoomend', eventData)); + } + if (wasRotating) { + this.fire(new Event('rotateend', eventData)); + } + if (wasPitching) { + this.fire(new Event('pitchend', eventData)); + } + this.fire(new Event('moveend', eventData)); + } + + /** + * Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that + * evokes flight. The animation seamlessly incorporates zooming and panning to help + * the user maintain her bearings even after traversing a great distance. + * + * Note: The animation will be skipped, and this will behave equivalently to `jumpTo` + * if the user has the `reduced motion` accessibility feature enabled in their operating system, + * unless 'options' includes `essential: true`. + * + * Triggers the following events: `movestart`, `move`, `moveend`, `zoomstart`, `zoom`, `zoomend`, `pitchstart`, + * `pitch`, `pitchend`, and `rotate`. + * + * @param options - Options describing the destination and animation of the transition. + * Accepts {@link CameraOptions}, {@link AnimationOptions}, + * and the following additional options. + * @param eventData - Additional properties to be added to event objects of events triggered by this method. + * @returns `this` + * @example + * ```ts + * // fly with default options to null island + * map.flyTo({center: [0, 0], zoom: 9}); + * // using flyTo options + * map.flyTo({ + * center: [0, 0], + * zoom: 9, + * speed: 0.2, + * curve: 1, + * easing(t) { + * return t; + * } + * }); + * ``` + * @see [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/) + * @see [Slowly fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto-options/) + * @see [Fly to a location based on scroll position](https://maplibre.org/maplibre-gl-js/docs/examples/scroll-fly-to/) + */ + flyTo(options: FlyToOptions, eventData?: any): this { + // Fall through to jumpTo if user has set prefers-reduced-motion + if (!options.essential && browser.prefersReducedMotion) { + const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']) as CameraOptions; + return this.jumpTo(coercedOptions, eventData); + } + + // This method implements an “optimal path” animation, as detailed in: + // + // Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and panning.” INFOVIS + // ’03. pp. 15–22. . + // + // Where applicable, local variable documentation begins with the associated variable or + // function in van Wijk (2003). + + this.stop(); + + options = extend({ + offset: [0, 0], + speed: 1.2, + curve: 1.42, + easing: defaultEasing + }, options); + + const tr = this._getTransformForUpdate(), + startZoom = this.getZoom(), + startBearing = this.getBearing(), + startPitch = this.getPitch(), + startPadding = this.getPadding(); + + const zoom = 'zoom' in options ? clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom; + const bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing; + const pitch = 'pitch' in options ? +options.pitch : startPitch; + const padding = 'padding' in options ? options.padding : tr.padding; + + const scale = tr.zoomScale(zoom - startZoom); + const offsetAsPoint = Point.convert(options.offset); + let pointAtOffset = tr.centerPoint.add(offsetAsPoint); + const locationAtOffset = tr.pointLocation(pointAtOffset); + const center = LngLat.convert(options.center || locationAtOffset); + this._normalizeCenter(center); + + const from = tr.project(locationAtOffset); + const delta = tr.project(center).sub(from); + + let rho = options.curve; + + // w₀: Initial visible span, measured in pixels at the initial scale. + const w0 = Math.max(tr.width, tr.height), + // w₁: Final visible span, measured in pixels with respect to the initial scale. + w1 = w0 / scale, + // Length of the flight path as projected onto the ground plane, measured in pixels from + // the world image origin at the initial scale. + u1 = delta.mag(); + + if ('minZoom' in options) { + const minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom); + // wm: Maximum visible span, measured in pixels with respect to the initial + // scale. + const wMax = w0 / tr.zoomScale(minZoom - startZoom); + rho = Math.sqrt(wMax / u1 * 2); + } + + // ρ² + const rho2 = rho * rho; + + /** + * rᵢ: Returns the zoom-out factor at one end of the animation. + * + * @param descent - `true` for the descent, `false` for the ascent + */ + function zoomOutFactor(descent: boolean) { + const b = (w1 * w1 - w0 * w0 + (descent ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (descent ? w1 : w0) * rho2 * u1); + return Math.log(Math.sqrt(b * b + 1) - b); + } + + function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; } + function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; } + function tanh(n) { return sinh(n) / cosh(n); } + + // r₀: Zoom-out factor during ascent. + const r0 = zoomOutFactor(false); + + // w(s): Returns the visible span on the ground, measured in pixels with respect to the + // initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°. + let w: (_: number) => number = function (s) { + return (cosh(r0) / cosh(r0 + rho * s)); + }; + + // u(s): Returns the distance along the flight path as projected onto the ground plane, + // measured in pixels from the world image origin at the initial scale. + let u: (_: number) => number = function (s) { + return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1; + }; + + // S: Total length of the flight path, measured in ρ-screenfuls. + let S = (zoomOutFactor(true) - r0) / rho; + + // When u₀ = u₁, the optimal path doesn’t require both ascent and descent. + if (Math.abs(u1) < 0.000001 || !isFinite(S)) { + // Perform a more or less instantaneous transition if the path is too short. + if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData); + + const k = w1 < w0 ? -1 : 1; + S = Math.abs(Math.log(w1 / w0)) / rho; + + u = function() { return 0; }; + w = function(s) { return Math.exp(k * rho * s); }; + } + + if ('duration' in options) { + options.duration = +options.duration; + } else { + const V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed; + options.duration = 1000 * S / V; + } + + if (options.maxDuration && options.duration > options.maxDuration) { + options.duration = 0; + } + + this._zooming = true; + this._rotating = (startBearing !== bearing); + this._pitching = (pitch !== startPitch); + this._padding = !tr.isPaddingEqual(padding as PaddingOptions); + + this._prepareEase(eventData, false); + if (this.terrain) this._prepareElevation(center); + + this._ease((k) => { + // s: The distance traveled along the flight path, measured in ρ-screenfuls. + const s = k * S; + const scale = 1 / w(s); + tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale); + + if (this._rotating) { + tr.bearing = interpolates.number(startBearing, bearing, k); + } + if (this._pitching) { + tr.pitch = interpolates.number(startPitch, pitch, k); + } + if (this._padding) { + tr.interpolatePadding(startPadding, padding as PaddingOptions, k); + // When padding is being applied, Transform#centerPoint is changing continuously, + // thus we need to recalculate offsetPoint every frame + pointAtOffset = tr.centerPoint.add(offsetAsPoint); + } + + if (this.terrain && !options.freezeElevation) this._updateElevation(k); + + const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(scale)); + tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset); + + this._applyUpdatedTransform(tr); + + this._fireMoveEvents(eventData); + + }, () => { + if (this.terrain) this._finalizeElevation(); + this._afterEase(eventData); + }, options); + + return this; + } + + isEasing() { + return !!this._easeFrameId; + } + + /** + * Stops any animated transition underway. + * + * @returns `this` + */ + stop(): this { + return this._stop(); + } + + _stop(allowGestures?: boolean, easeId?: string): this { + if (this._easeFrameId) { + this._cancelRenderFrame(this._easeFrameId); + delete this._easeFrameId; + delete this._onEaseFrame; + } + + if (this._onEaseEnd) { + // The _onEaseEnd function might emit events which trigger new + // animation, which sets a new _onEaseEnd. Ensure we don't delete + // it unintentionally. + const onEaseEnd = this._onEaseEnd; + delete this._onEaseEnd; + onEaseEnd.call(this, easeId); + } + if (!allowGestures) { + const handlers = (this as any).handlers; + if (handlers) handlers.stop(false); + } + return this; + } + + _ease(frame: (_: number) => void, + finish: () => void, + options: { + animate?: boolean; + duration?: number; + easing?: (_: number) => number; + }) { + if (options.animate === false || options.duration === 0) { + frame(1); + finish(); + } else { + this._easeStart = browser.now(); + this._easeOptions = options; + this._onEaseFrame = frame; + this._onEaseEnd = finish; + this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback); + } + } + + // Callback for map._requestRenderFrame + _renderFrameCallback = () => { + const t = Math.min((browser.now() - this._easeStart) / this._easeOptions.duration, 1); + this._onEaseFrame(this._easeOptions.easing(t)); + + // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted + if (t < 1 && this._easeFrameId) { + this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback); + } else { + this.stop(); + } + }; + + // convert bearing so that it's numerically close to the current one so that it interpolates properly + _normalizeBearing(bearing: number, currentBearing: number) { + bearing = wrap(bearing, -180, 180); + const diff = Math.abs(bearing - currentBearing); + if (Math.abs(bearing - 360 - currentBearing) < diff) bearing -= 360; + if (Math.abs(bearing + 360 - currentBearing) < diff) bearing += 360; + return bearing; + } + + // If a path crossing the antimeridian would be shorter, extend the final coordinate so that + // interpolating between the two endpoints will cross it. + _normalizeCenter(center: LngLat) { + const tr = this.transform; + if (!tr.renderWorldCopies || tr.lngRange) return; + + const delta = center.lng - tr.center.lng; + center.lng += + delta > 180 ? -360 : + delta < -180 ? 360 : 0; + } + + /** + * Query the current elevation of location. It return null if terrain is not enabled. the elevation is in meters relative to mean sea-level + * @param lngLatLike - [x,y] or LngLat coordinates of the location + * @returns elevation in meters + */ + queryTerrainElevation(lngLatLike: LngLatLike): number | null { + if (!this.terrain) { + return null; + } + const elevation = this.terrain.getElevationForLngLatZoom(LngLat.convert(lngLatLike), this.transform.tileZoom); + /** + * Different zoomlevels with different terrain-tiles the elevation-values are not the same. + * map.transform.elevation variable with the center-altitude. + * In maplibre the proj-matrix is translated by this value in negative z-direction. + * So we need to add this value to the elevation to get the correct value. + */ + return elevation - this.transform.elevation; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/control/attribution_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/attribution_control.test.ts new file mode 100644 index 00000000..49940cc5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/attribution_control.test.ts @@ -0,0 +1,543 @@ +import {AttributionControl} from './attribution_control'; +import {createMap as globalCreateMap, beforeMapTest} from '../../util/test/util'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {fakeServer} from 'nise'; + +function createMap() { + + return globalCreateMap({ + attributionControl: false, + style: { + version: 8, + sources: {}, + layers: [], + owner: 'mapblibre', + id: 'demotiles', + }, + hash: true + }, undefined); +} + +let map; + +beforeEach(() => { + beforeMapTest(); + map = createMap(); +}); + +afterEach(() => { + map.remove(); +}); + +describe('AttributionControl', () => { + test('appears in bottom-right by default', () => { + map.addControl(new AttributionControl()); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib') + ).toHaveLength(1); + }); + + test('appears in the position specified by the position option', () => { + map.addControl(new AttributionControl(), 'top-left'); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib') + ).toHaveLength(1); + }); + + test('appears in compact mode if compact option is used', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true}); + + let attributionControl = new AttributionControl({ + compact: true, + customAttribution: 'MapLibre' + }); + map.addControl(attributionControl); + + const container = map.getContainer(); + + expect( + container.querySelectorAll('.maplibregl-ctrl-attrib.maplibregl-compact') + ).toHaveLength(1); + map.removeControl(attributionControl); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true}); + attributionControl = new AttributionControl({ + compact: false + }); + + map.addControl(attributionControl); + expect( + container.querySelectorAll('.maplibregl-ctrl-attrib:not(.maplibregl-compact)') + ).toHaveLength(1); + }); + + test('appears in compact mode if container is less then 640 pixel wide and attributions are not empty', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true}); + const attributionControl = new AttributionControl({ + customAttribution: 'MapLibre' + }); + map.addControl(attributionControl); + + const container = map.getContainer(); + + expect( + container.querySelectorAll('.maplibregl-ctrl-attrib:not(.maplibregl-compact)') + ).toHaveLength(1); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true}); + map.resize(); + + expect( + container.querySelectorAll('.maplibregl-ctrl-attrib.maplibregl-compact') + ).toHaveLength(1); + + expect( + container.querySelectorAll('.maplibregl-attrib-empty') + ).toHaveLength(0); + }); + + test('does not appear in compact mode if container is less then 640 pixel wide and attributions are empty', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true}); + map.addControl(new AttributionControl()); + + const container = map.getContainer(); + + expect( + container.querySelectorAll('.maplibregl-ctrl-attrib:not(.maplibregl-compact)') + ).toHaveLength(1); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true}); + map.resize(); + + expect( + container.querySelectorAll('.maplibregl-ctrl-attrib.maplibregl-compact') + ).toHaveLength(0); + + expect( + container.querySelectorAll('.maplibregl-attrib-empty') + ).toHaveLength(1); + }); + + test('compact mode control toggles attribution', () => { + map.addControl(new AttributionControl({ + compact: true, + customAttribution: 'MapLibre' + })); + + const container = map.getContainer(); + const toggle = container.querySelector('.maplibregl-ctrl-attrib-button'); + + expect(container.querySelectorAll('.maplibregl-compact-show')).toHaveLength(1); + + simulate.click(toggle); + + expect(container.querySelectorAll('.maplibregl-compact-show')).toHaveLength(0); + + simulate.click(toggle); + + expect(container.querySelectorAll('.maplibregl-compact-show')).toHaveLength(1); + }); + + test('dedupes attributions that are substrings of others', done => { + const attribution = new AttributionControl(); + map.addControl(attribution); + + map.on('load', () => { + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'World'}); + map.addSource('2', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addSource('3', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Another Source'}); + map.addSource('4', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello'}); + map.addSource('5', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addSource('6', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addSource('7', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'GeoJSON Source'}); + map.addLayer({id: '1', type: 'fill', source: '1'}); + map.addLayer({id: '2', type: 'fill', source: '2'}); + map.addLayer({id: '3', type: 'fill', source: '3'}); + map.addLayer({id: '4', type: 'fill', source: '4'}); + map.addLayer({id: '5', type: 'fill', source: '5'}); + map.addLayer({id: '6', type: 'fill', source: '6'}); + map.addLayer({id: '7', type: 'fill', source: '7'}); + }); + + let times = 0; + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'visibility') { + if (++times === 7) { + expect(attribution._innerContainer.innerHTML).toBe('Hello World | Another Source | GeoJSON Source'); + done(); + } + } + }); + }); + + test('is hidden if empty', done => { + const attribution = new AttributionControl(); + map.addControl(attribution); + map.on('load', () => { + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}}); + map.addLayer({id: '1', type: 'fill', source: '1'}); + }); + + const container = map.getContainer(); + + const checkEmptyFirst = () => { + expect(attribution._innerContainer.innerHTML).toBe(''); + expect(container.querySelectorAll('.maplibregl-attrib-empty')).toHaveLength(1); + + map.addSource('2', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addLayer({id: '2', type: 'fill', source: '2'}); + }; + + const checkNotEmptyLater = () => { + expect(attribution._innerContainer.innerHTML).toBe('Hello World'); + expect(container.querySelectorAll('.maplibregl-attrib-empty')).toHaveLength(0); + done(); + }; + + let times = 0; + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'visibility') { + times++; + if (times === 1) { + checkEmptyFirst(); + } else if (times === 2) { + checkNotEmptyLater(); + } + } + }); + }); + + test('shows custom attribution if customAttribution option is provided', () => { + const attributionControl = new AttributionControl({ + customAttribution: 'Custom string' + }); + map.addControl(attributionControl); + + expect(attributionControl._innerContainer.innerHTML).toBe('Custom string'); + }); + + test('shows custom attribution if customAttribution option is provided, control is removed and added back', () => { + const attributionControl = new AttributionControl({ + customAttribution: 'Custom string' + }); + map.addControl(attributionControl); + map.removeControl(attributionControl); + map.addControl(attributionControl); + + expect(attributionControl._innerContainer.innerHTML).toBe('Custom string'); + }); + + test('in compact mode shows custom attribution if customAttribution option is provided', () => { + const attributionControl = new AttributionControl({ + customAttribution: 'Custom string', + compact: true + }); + map.addControl(attributionControl); + + expect(attributionControl._innerContainer.innerHTML).toBe('Custom string'); + }); + + test('shows all custom attributions if customAttribution array of strings is provided', () => { + const attributionControl = new AttributionControl({ + customAttribution: ['Some very long custom string', 'Custom string', 'Another custom string'] + }); + map.addControl(attributionControl); + + expect(attributionControl._innerContainer.innerHTML).toBe('Custom string | Another custom string | Some very long custom string'); + }); + + test('hides attributions for sources that are not currently visible', done => { + const attribution = new AttributionControl(); + map.addControl(attribution); + + map.on('load', () => { + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Used'}); + map.addSource('2', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Not used'}); + map.addSource('3', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Vibility none'}); + map.addLayer({id: '1', type: 'fill', source: '1'}); + map.addLayer({id: '3', type: 'fill', source: '3', layout: {visibility: 'none'}}); + }); + + let times = 0; + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'visibility') { + if (++times === 3) { + expect(attribution._innerContainer.innerHTML).toBe('Used'); + done(); + } + } + }); + }); + + test('does not show attributions for sources that are used for terrain when they are not in use', done => { + global.fetch = null; + const server = fakeServer.create(); + server.respondWith('/source.json', JSON.stringify({ + minzoom: 5, + maxzoom: 12, + attribution: 'Terrain', + tiles: ['http://example.com/{z}/{x}/{y}.pngraw'], + bounds: [-47, -7, -45, -5] + })); + + const attribution = new AttributionControl(); + map.addControl(attribution); + + map.on('load', () => { + map.addSource('1', {type: 'raster-dem', url: '/source.json'}); + server.respond(); + }); + + let times = 0; + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'visibility') { + if (++times === 1) { + expect(attribution._innerContainer.innerHTML).toBe(''); + done(); + } + } + }); + }); + + test('shows attributions for sources that are used for terrain', done => { + global.fetch = null; + const server = fakeServer.create(); + server.respondWith('/source.json', JSON.stringify({ + minzoom: 5, + maxzoom: 12, + attribution: 'Terrain', + tiles: ['http://example.com/{z}/{x}/{y}.pngraw'], + bounds: [-47, -7, -45, -5] + })); + + const attribution = new AttributionControl(); + map.addControl(attribution); + + map.on('load', () => { + map.addSource('1', {type: 'raster-dem', url: '/source.json'}); + server.respond(); + map.setTerrain({source: '1'}); + }); + + let times = 0; + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'visibility') { + if (++times === 1) { + expect(attribution._innerContainer.innerHTML).toBe('Terrain'); + done(); + } + } + }); + }); + + test('toggles attributions for sources whose visibility changes when zooming', done => { + const attribution = new AttributionControl(); + map.addControl(attribution); + + map.on('load', () => { + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Used'}); + map.addLayer({id: '1', type: 'fill', source: '1', minzoom: 12}); + }); + + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'metadata') { + expect(attribution._innerContainer.innerHTML).toBe(''); + map.setZoom(13); + } + if (e.dataType === 'source' && e.sourceDataType === 'visibility') { + if (map.getZoom() === 13) { + expect(attribution._innerContainer.innerHTML).toBe('Used'); + done(); + } + } + }); + }); + +}); + +describe('AttributionControl test regarding the HTML elements details and summary', () => { + describe('Details is set correct for compact view', () => { + test('It should NOT contain the attribute open="" on first load.', () => { + const attributionControl = new AttributionControl({ + compact: true + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBeNull(); + }); + + test('It SHOULD contain the attribute open="" after click on summary.', () => { + const attributionControl = new AttributionControl({ + compact: true + }); + map.addControl(attributionControl); + const container = map.getContainer(); + const toggle = container.querySelector('.maplibregl-ctrl-attrib-button'); + + simulate.click(toggle); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + + test('It should NOT contain the attribute open="" after two clicks on summary.', () => { + const attributionControl = new AttributionControl({ + compact: true + }); + map.addControl(attributionControl); + const container = map.getContainer(); + const toggle = container.querySelector('.maplibregl-ctrl-attrib-button'); + + simulate.click(toggle); + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + simulate.click(toggle); + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBeNull(); + }); + }); + + describe('Details is set correct for default view (compact === undefined)', () => { + test('It should NOT contain the attribute open="" if offsetWidth <= 640.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + const attributionControl = new AttributionControl({ + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBeNull(); + }); + + test('It SHOULD contain the attribute open="" if offsetWidth > 640.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 641, configurable: true}); + const attributionControl = new AttributionControl({ + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + + test('The attribute open="" SHOULD exist after resize from size > 640 to <= 640 and and vice versa.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + const attributionControl = new AttributionControl({ + customAttribution: 'MapLibre' + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib.maplibregl-compact')).toHaveLength(1); + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 641, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib:not(.maplibregl-compact)')).toHaveLength(1); + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib.maplibregl-compact')).toHaveLength(1); + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + + test('The attribute open="" should NOT change on resize from > 640 to another > 640.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 641, configurable: true}); + const attributionControl = new AttributionControl({ + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 650, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 641, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + + test('The attribute open="" should NOT change on resize from <= 640 to another <= 640 if it is closed.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + const attributionControl = new AttributionControl({ + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBeNull(); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 630, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBeNull(); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBeNull(); + }); + + test('The attribute open="" should NOT change on resize from <= 640 to another <= 640 if it is open.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + const attributionControl = new AttributionControl({ + }); + map.addControl(attributionControl); + const toggle = map.getContainer().querySelector('.maplibregl-ctrl-attrib-button'); + simulate.click(toggle); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 630, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + }); + + describe('Details is set correct for default view (compact === false)', () => { + test('It SHOULD contain the attribute open="" if offsetWidth <= 640.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + const attributionControl = new AttributionControl({ + compact: false + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + + test('It SHOULD contain the attribute open="" if offsetWidth > 640.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 641, configurable: true}); + const attributionControl = new AttributionControl({ + compact: false + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + + test('The attribute open="" should NOT change on resize.', () => { + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + const attributionControl = new AttributionControl({ + compact: false + }); + map.addControl(attributionControl); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 641, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 640, configurable: true}); + map.resize(); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-attrib')[0].getAttribute('open')).toBe(''); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/attribution_control.ts b/web/libraries/maplibre-gl/src/ui/control/attribution_control.ts new file mode 100644 index 00000000..491e3559 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/attribution_control.ts @@ -0,0 +1,204 @@ +import {DOM} from '../../util/dom'; + +import type {Map} from '../map'; +import type {ControlPosition, IControl} from './control'; +import type {MapDataEvent} from '../events'; +import type {StyleSpecification} from '@maplibre/maplibre-gl-style-spec'; +/** + * The {@link AttributionControl} options + */ +type AttributionOptions = { + /** + * If `true`, the attribution control will always collapse when moving the map. If `false`, + * force the expanded attribution control. The default is a responsive attribution that collapses when the user moves the map on maps less than 640 pixels wide. + * **Attribution should not be collapsed if it can comfortably fit on the map. `compact` should only be used to modify default attribution when map size makes it impossible to fit default attribution and when the automatic compact resizing for default settings are not sufficient.** + */ + compact?: boolean; + /** + * Attributions to show in addition to any other attributions. + */ + customAttribution?: string | Array; +}; + +/** + * An `AttributionControl` control presents the map's attribution information. By default, the attribution control is expanded (regardless of map width). + * @group Markers and Controls + * @example + * ```ts + * let map = new maplibregl.Map({attributionControl: false}) + * .addControl(new maplibregl.AttributionControl({ + * compact: true + * })); + * ``` + */ +export class AttributionControl implements IControl { + options: AttributionOptions; + _map: Map; + _compact: boolean; + _container: HTMLElement; + _innerContainer: HTMLElement; + _compactButton: HTMLElement; + _editLink: HTMLAnchorElement; + _attribHTML: string; + styleId: string; + styleOwner: string; + + /** + * @param options - the attribution options + */ + constructor(options: AttributionOptions = {}) { + this.options = options; + } + + getDefaultPosition(): ControlPosition { + return 'bottom-right'; + } + + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map) { + this._map = map; + this._compact = this.options && this.options.compact; + this._container = DOM.create('details', 'maplibregl-ctrl maplibregl-ctrl-attrib'); + this._compactButton = DOM.create('summary', 'maplibregl-ctrl-attrib-button', this._container); + this._compactButton.addEventListener('click', this._toggleAttribution); + this._setElementTitle(this._compactButton, 'ToggleAttribution'); + this._innerContainer = DOM.create('div', 'maplibregl-ctrl-attrib-inner', this._container); + + this._updateAttributions(); + this._updateCompact(); + + this._map.on('styledata', this._updateData); + this._map.on('sourcedata', this._updateData); + this._map.on('terrain', this._updateData); + this._map.on('resize', this._updateCompact); + this._map.on('drag', this._updateCompactMinimize); + + return this._container; + } + + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + + this._map.off('styledata', this._updateData); + this._map.off('sourcedata', this._updateData); + this._map.off('terrain', this._updateData); + this._map.off('resize', this._updateCompact); + this._map.off('drag', this._updateCompactMinimize); + + this._map = undefined; + this._compact = undefined; + this._attribHTML = undefined; + } + + _setElementTitle(element: HTMLElement, title: string) { + const str = this._map._getUIString(`AttributionControl.${title}`); + element.title = str; + element.setAttribute('aria-label', str); + } + + _toggleAttribution = () => { + if (this._container.classList.contains('maplibregl-compact')) { + if (this._container.classList.contains('maplibregl-compact-show')) { + this._container.setAttribute('open', ''); + this._container.classList.remove('maplibregl-compact-show'); + } else { + this._container.classList.add('maplibregl-compact-show'); + this._container.removeAttribute('open'); + } + } + }; + + _updateData = (e: MapDataEvent) => { + if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style' || e.type === 'terrain')) { + this._updateAttributions(); + } + }; + + _updateAttributions() { + if (!this._map.style) return; + let attributions: Array = []; + if (this.options.customAttribution) { + if (Array.isArray(this.options.customAttribution)) { + attributions = attributions.concat( + this.options.customAttribution.map(attribution => { + if (typeof attribution !== 'string') return ''; + return attribution; + }) + ); + } else if (typeof this.options.customAttribution === 'string') { + attributions.push(this.options.customAttribution); + } + } + + if (this._map.style.stylesheet) { + const stylesheet = this._map.style.stylesheet as StyleSpecification & { owner: string; id: string }; + this.styleOwner = stylesheet.owner; + this.styleId = stylesheet.id; + } + + const sourceCaches = this._map.style.sourceCaches; + for (const id in sourceCaches) { + const sourceCache = sourceCaches[id]; + if (sourceCache.used || sourceCache.usedForTerrain) { + const source = sourceCache.getSource(); + if (source.attribution && attributions.indexOf(source.attribution) < 0) { + attributions.push(source.attribution); + } + } + } + + // remove any entries that are whitespace + attributions = attributions.filter(e => String(e).trim()); + + // remove any entries that are substrings of another entry. + // first sort by length so that substrings come first + attributions.sort((a, b) => a.length - b.length); + attributions = attributions.filter((attrib, i) => { + for (let j = i + 1; j < attributions.length; j++) { + if (attributions[j].indexOf(attrib) >= 0) { return false; } + } + return true; + }); + + // check if attribution string is different to minimize DOM changes + const attribHTML = attributions.join(' | '); + if (attribHTML === this._attribHTML) return; + + this._attribHTML = attribHTML; + + if (attributions.length) { + this._innerContainer.innerHTML = attribHTML; + this._container.classList.remove('maplibregl-attrib-empty'); + } else { + this._container.classList.add('maplibregl-attrib-empty'); + } + this._updateCompact(); + // remove old DOM node from _editLink + this._editLink = null; + } + + _updateCompact = () => { + if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) { + if (this._compact === false) { + this._container.setAttribute('open', ''); + } else if (!this._container.classList.contains('maplibregl-compact') && !this._container.classList.contains('maplibregl-attrib-empty')) { + this._container.setAttribute('open', ''); + this._container.classList.add('maplibregl-compact', 'maplibregl-compact-show'); + } + } else { + this._container.setAttribute('open', ''); + if (this._container.classList.contains('maplibregl-compact')) { + this._container.classList.remove('maplibregl-compact', 'maplibregl-compact-show'); + } + } + }; + + _updateCompactMinimize = () => { + if (this._container.classList.contains('maplibregl-compact')) { + if (this._container.classList.contains('maplibregl-compact-show')) { + this._container.classList.remove('maplibregl-compact-show'); + } + } + }; +} diff --git a/web/libraries/maplibre-gl/src/ui/control/control.ts b/web/libraries/maplibre-gl/src/ui/control/control.ts new file mode 100644 index 00000000..eb715d66 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/control.ts @@ -0,0 +1,84 @@ +import type {Map} from '../map'; + +/** + * A position defintion for the control to be placed, can be in one of the corners of the map. + * When two or more controls are places in the same location they are stacked toward the center of the map. + */ +export type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + +/** + * Interface for interactive controls added to the map. This is a + * specification for implementers to model: it is not + * an exported method or class. + * + * Controls must implement `onAdd` and `onRemove`, and must own an + * element, which is often a `div` element. To use MapLibre GL JS's + * default control styling, add the `maplibregl-ctrl` class to your control's + * node. + * + * @example + * Control implemented as ES6 class + * ```ts + * class HelloWorldControl { + * onAdd(map) { + * this._map = map; + * this._container = document.createElement('div'); + * this._container.className = 'maplibregl-ctrl'; + * this._container.textContent = 'Hello, world'; + * return this._container; + * } + * + * onRemove() { + * this._container.parentNode.removeChild(this._container); + * this._map = undefined; + * } + * } + * + * // Control implemented as ES5 prototypical class + * function HelloWorldControl() { } + * + * HelloWorldControl.prototype.onAdd = function(map) { + * this._map = map; + * this._container = document.createElement('div'); + * this._container.className = 'maplibregl-ctrl'; + * this._container.textContent = 'Hello, world'; + * return this._container; + * }; + * + * HelloWorldControl.prototype.onRemove = function () { + * this._container.parentNode.removeChild(this._container); + * this._map = undefined; + * }; + * ``` + */ +export interface IControl { + /** + * Register a control on the map and give it a chance to register event listeners + * and resources. This method is called by {@link Map#addControl} + * internally. + * + * @param map - the Map this control will be added to + * @returns The control's container element. This should + * be created by the control and returned by onAdd without being attached + * to the DOM: the map will insert the control's element into the DOM + * as necessary. + */ + onAdd(map: Map): HTMLElement; + /** + * Unregister a control on the map and give it a chance to detach event listeners + * and resources. This method is called by {@link Map#removeControl} + * internally. + * + * @param map - the Map this control will be removed from + */ + onRemove(map: Map): void; + /** + * Optionally provide a default position for this control. If this method + * is implemented and {@link Map#addControl} is called without the `position` + * parameter, the value returned by getDefaultPosition will be used as the + * control's position. + * + * @returns a control position, one of the values valid in addControl. + */ + readonly getDefaultPosition?: () => ControlPosition; +} diff --git a/web/libraries/maplibre-gl/src/ui/control/fullscreen_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/fullscreen_control.test.ts new file mode 100644 index 00000000..5b656715 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/fullscreen_control.test.ts @@ -0,0 +1,136 @@ +import {createMap, beforeMapTest} from '../../util/test/util'; +import {FullscreenControl} from './fullscreen_control'; + +beforeEach(() => { + beforeMapTest(); +}); + +describe('FullscreenControl', () => { + test('renders control', () => { + Object.defineProperty(window.document, 'fullscreenEnabled', { + value: true, + writable: true, + }); + const map = createMap(undefined, undefined); + const fullscreen = new FullscreenControl({}); + map.addControl(fullscreen); + + expect(map.getContainer().querySelectorAll('.maplibregl-ctrl-fullscreen')).toHaveLength(1); + }); + + test('makes optional container element full screen', () => { + Object.defineProperty(window.document, 'fullscreenEnabled', { + value: true, + writable: true, + }); + + const map = createMap(undefined, undefined); + const container = window.document.querySelector('body')!; + const fullscreen = new FullscreenControl({container}); + map.addControl(fullscreen); + const control = map._controls.find((ctrl) => { + return Object.prototype.hasOwnProperty.call(ctrl, '_fullscreen'); + }) as FullscreenControl; + control._onClickFullscreen(); + + expect(control._container.tagName).toBe('BODY'); + }); + + test('uses pseudo fullscreen when fullscreen is not supported', () => { + const map = createMap(undefined, undefined); + const mapContainer = map.getContainer(); + + const fullscreen = new FullscreenControl({}); + map.addControl(fullscreen); + const control = map._controls.find((ctrl) => { + return Object.prototype.hasOwnProperty.call(ctrl, '_fullscreen'); + }) as FullscreenControl; + + expect(mapContainer.classList.contains('maplibregl-pseudo-fullscreen')).toBe(false); + control._onClickFullscreen(); + expect(mapContainer.classList.contains('maplibregl-pseudo-fullscreen')).toBe(true); + control._onClickFullscreen(); + expect(mapContainer.classList.contains('maplibregl-pseudo-fullscreen')).toBe(false); + }); + + test('start and end events fire for fullscreen button clicks', () => { + const map = createMap(undefined, undefined); + const fullscreen = new FullscreenControl({}); + + const fullscreenstart = jest.fn(); + const fullscreenend = jest.fn(); + + fullscreen.on('fullscreenstart', fullscreenstart); + fullscreen.on('fullscreenend', fullscreenend); + + map.addControl(fullscreen); + + const click = new window.Event('click'); + + // Simulate a click to the fullscreen button + fullscreen._fullscreenButton.dispatchEvent(click); + expect(fullscreenstart).toHaveBeenCalled(); + expect(fullscreenend).not.toHaveBeenCalled(); + + // Second simulated click would exit fullscreen mode + fullscreen._fullscreenButton.dispatchEvent(click); + expect(fullscreenend).toHaveBeenCalled(); + }); + + test('disables cooperative gestures when fullscreen becomes active', () => { + const cooperativeGestures = true; + const map = createMap({cooperativeGestures}); + const fullscreen = new FullscreenControl({}); + + map.addControl(fullscreen); + + const click = new window.Event('click'); + + // Simulate a click to the fullscreen button + fullscreen._fullscreenButton.dispatchEvent(click); + expect(map.getCooperativeGestures()).toBeFalsy(); + + // Second simulated click would exit fullscreen mode + fullscreen._fullscreenButton.dispatchEvent(click); + expect(map.getCooperativeGestures()).toBe(cooperativeGestures); + }); + + test('reenables cooperative gestures custom options when fullscreen exits', () => { + const cooperativeGestures = { + 'windowsHelpText': 'Custom message', + 'macHelpText': 'Custom message', + 'mobileHelpText': 'Custom message', + }; + const map = createMap({cooperativeGestures}); + const fullscreen = new FullscreenControl({}); + + map.addControl(fullscreen); + + const click = new window.Event('click'); + + // Simulate a click to the fullscreen button + fullscreen._fullscreenButton.dispatchEvent(click); + expect(map.getCooperativeGestures()).toBeFalsy(); + + // Second simulated click would exit fullscreen mode + fullscreen._fullscreenButton.dispatchEvent(click); + expect(map.getCooperativeGestures()).toEqual(cooperativeGestures); + }); + + test('if never set, cooperative gestures remain disabled when fullscreen exits', () => { + const map = createMap({cooperativeGestures: false}); + const fullscreen = new FullscreenControl({}); + + map.addControl(fullscreen); + + const click = new window.Event('click'); + + // Simulate a click to the fullscreen button + fullscreen._fullscreenButton.dispatchEvent(click); + expect(map.getCooperativeGestures()).toBeFalsy(); + + // Second simulated click would exit fullscreen mode + fullscreen._fullscreenButton.dispatchEvent(click); + expect(map.getCooperativeGestures()).toBeFalsy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/fullscreen_control.ts b/web/libraries/maplibre-gl/src/ui/control/fullscreen_control.ts new file mode 100644 index 00000000..fb7af04a --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/fullscreen_control.ts @@ -0,0 +1,185 @@ +import {DOM} from '../../util/dom'; + +import {warnOnce} from '../../util/util'; + +import {Event, Evented} from '../../util/evented'; +import type {Map, GestureOptions} from '../map'; +import type {IControl} from './control'; + +/** + * The {@link FullscreenControl} options + */ +type FullscreenOptions = { + /** + * `container` is the [compatible DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Compatible_elements) which should be made full screen. By default, the map container element will be made full screen. + */ + container?: HTMLElement; +}; + +/** + * A `FullscreenControl` control contains a button for toggling the map in and out of fullscreen mode. + * When [requestFullscreen](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen) is not supported, fullscreen is handled via CSS properties. + * The map's `cooperativeGestures` option is temporarily disabled while the map + * is in fullscreen mode, and is restored when the map exist fullscreen mode. + * + * @group Markers and Controls + * @param options - the full screen control options + * + * @example + * ```ts + * map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')})); + * ``` + * @see [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/) + * + * ### Events + * + * @event `fullscreenstart` - Fired when fullscreen mode has started + * + * @event `fullscreenend` - Fired when fullscreen mode has ended + */ +export class FullscreenControl extends Evented implements IControl { + _map: Map; + _controlContainer: HTMLElement; + _fullscreen: boolean; + _fullscreenchange: string; + _fullscreenButton: HTMLButtonElement; + _container: HTMLElement; + _prevCooperativeGestures: boolean | GestureOptions; + + constructor(options: FullscreenOptions = {}) { + super(); + this._fullscreen = false; + + if (options && options.container) { + if (options.container instanceof HTMLElement) { + this._container = options.container; + } else { + warnOnce('Full screen control \'container\' must be a DOM element.'); + } + } + + if ('onfullscreenchange' in document) { + this._fullscreenchange = 'fullscreenchange'; + } else if ('onmozfullscreenchange' in document) { + this._fullscreenchange = 'mozfullscreenchange'; + } else if ('onwebkitfullscreenchange' in document) { + this._fullscreenchange = 'webkitfullscreenchange'; + } else if ('onmsfullscreenchange' in document) { + this._fullscreenchange = 'MSFullscreenChange'; + } + } + + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map): HTMLElement { + this._map = map; + if (!this._container) this._container = this._map.getContainer(); + this._controlContainer = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + this._setupUI(); + return this._controlContainer; + } + + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._controlContainer); + this._map = null; + window.document.removeEventListener(this._fullscreenchange, this._onFullscreenChange); + } + + _setupUI() { + const button = this._fullscreenButton = DOM.create('button', (('maplibregl-ctrl-fullscreen')), this._controlContainer); + DOM.create('span', 'maplibregl-ctrl-icon', button).setAttribute('aria-hidden', 'true'); + button.type = 'button'; + this._updateTitle(); + this._fullscreenButton.addEventListener('click', this._onClickFullscreen); + window.document.addEventListener(this._fullscreenchange, this._onFullscreenChange); + } + + _updateTitle() { + const title = this._getTitle(); + this._fullscreenButton.setAttribute('aria-label', title); + this._fullscreenButton.title = title; + } + + _getTitle() { + return this._map._getUIString(this._isFullscreen() ? 'FullscreenControl.Exit' : 'FullscreenControl.Enter'); + } + + _isFullscreen() { + return this._fullscreen; + } + + _onFullscreenChange = () => { + const fullscreenElement = + window.document.fullscreenElement || + (window.document as any).mozFullScreenElement || + (window.document as any).webkitFullscreenElement || + (window.document as any).msFullscreenElement; + + if ((fullscreenElement === this._container) !== this._fullscreen) { + this._handleFullscreenChange(); + } + }; + + _handleFullscreenChange() { + this._fullscreen = !this._fullscreen; + this._fullscreenButton.classList.toggle('maplibregl-ctrl-shrink'); + this._fullscreenButton.classList.toggle('maplibregl-ctrl-fullscreen'); + this._updateTitle(); + + if (this._fullscreen) { + this.fire(new Event('fullscreenstart')); + if (this._map._cooperativeGestures) { + this._prevCooperativeGestures = this._map._cooperativeGestures; + this._map.setCooperativeGestures(); + } + } else { + this.fire(new Event('fullscreenend')); + if (this._prevCooperativeGestures) { + this._map.setCooperativeGestures(this._prevCooperativeGestures); + delete this._prevCooperativeGestures; + } + } + } + + _onClickFullscreen = () => { + if (this._isFullscreen()) { + this._exitFullscreen(); + } else { + this._requestFullscreen(); + } + }; + + _exitFullscreen() { + if (window.document.exitFullscreen) { + (window.document as any).exitFullscreen(); + } else if ((window.document as any).mozCancelFullScreen) { + (window.document as any).mozCancelFullScreen(); + } else if ((window.document as any).msExitFullscreen) { + (window.document as any).msExitFullscreen(); + } else if ((window.document as any).webkitCancelFullScreen) { + (window.document as any).webkitCancelFullScreen(); + } else { + this._togglePseudoFullScreen(); + } + } + + _requestFullscreen() { + if (this._container.requestFullscreen) { + this._container.requestFullscreen(); + } else if ((this._container as any).mozRequestFullScreen) { + (this._container as any).mozRequestFullScreen(); + } else if ((this._container as any).msRequestFullscreen) { + (this._container as any).msRequestFullscreen(); + } else if ((this._container as any).webkitRequestFullscreen) { + (this._container as any).webkitRequestFullscreen(); + } else { + this._togglePseudoFullScreen(); + } + } + + _togglePseudoFullScreen() { + this._container.classList.toggle('maplibregl-pseudo-fullscreen'); + this._handleFullscreenChange(); + this._map.resize(); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/control/geolocate_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/geolocate_control.test.ts new file mode 100644 index 00000000..00b3186f --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/geolocate_control.test.ts @@ -0,0 +1,520 @@ +import geolocation from 'mock-geolocation'; +import {LngLatBounds} from '../../geo/lng_lat_bounds'; +import {createMap, beforeMapTest} from '../../util/test/util'; +import {GeolocateControl} from './geolocate_control'; +jest.mock('../../util/geolocation_support', () => ( + { + checkGeolocationSupport: jest.fn() + } +)); +import {checkGeolocationSupport} from '../../util/geolocation_support'; +import type {LngLat} from '../../geo/lng_lat'; + +/** + * Convert the coordinates of a LngLat object to a fixed number of digits + * @param lngLat - the location + * @param digits - digits the number of digits to set + * @returns a string representation of the object with the required number of digits + */ +function lngLatAsFixed(lngLat: LngLat, digits: number): {lat: string; lng: string} { + return { + lng: lngLat.lng.toFixed(digits), + lat: lngLat.lat.toFixed(digits) + }; +} + +describe('GeolocateControl with no options', () => { + geolocation.use(); + let map; + + beforeEach(() => { + beforeMapTest(); + map = createMap(undefined, undefined); + (checkGeolocationSupport as any as jest.SpyInstance).mockImplementationOnce((cb) => cb(true)); + }); + + afterEach(() => { + map.remove(); + }); + + test('is disabled when there\'s no support', async () => { + (checkGeolocationSupport as any as jest.SpyInstance).mockReset().mockImplementationOnce((cb) => cb(false)); + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + expect(geolocate._geolocateButton.disabled).toBeTruthy(); + }); + + test('is enabled when there no support', async () => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + expect(geolocate._geolocateButton.disabled).toBeFalsy(); + }); + + test('has permissions', async () => { + + (window.navigator as any).permissions = { + query: () => Promise.resolve({state: 'granted'}) + }; + + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + + await new Promise(process.nextTick); + expect(geolocate._geolocateButton.disabled).toBeFalsy(); + }); + + test('error event', done => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + + const click = new window.Event('click'); + + geolocate.on('error', (error) => { + expect(error.code).toBe(2); + expect(error.message).toBe('error message'); + done(); + }); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.sendError({code: 2, message: 'error message'}); + }); + + test('does not throw if removed quickly', done => { + (checkGeolocationSupport as any as jest.SpyInstance).mockReset() + .mockImplementationOnce((cb) => { + return Promise.resolve(true) + .then(result => { + expect(() => cb(result)).not.toThrow(); + }) + .finally(done); + }); + + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + map.removeControl(geolocate); + }); + + test('outofmaxbounds event in active lock state', done => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + map.setMaxBounds([[0, 0], [10, 10]]); + geolocate._watchState = 'ACTIVE_LOCK'; + + const click = new window.Event('click'); + + geolocate.on('outofmaxbounds', (position) => { + expect(geolocate._watchState).toBe('ACTIVE_ERROR'); + expect(position.coords.latitude).toBe(10); + expect(position.coords.longitude).toBe(20); + expect(position.coords.accuracy).toBe(3); + expect(position.timestamp).toBe(4); + done(); + }); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 3, timestamp: 4}); + }); + + test('outofmaxbounds event in background state', done => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + map.setMaxBounds([[0, 0], [10, 10]]); + geolocate._watchState = 'BACKGROUND'; + + const click = new window.Event('click'); + + geolocate.on('outofmaxbounds', (position) => { + expect(geolocate._watchState).toBe('BACKGROUND_ERROR'); + expect(position.coords.latitude).toBe(10); + expect(position.coords.longitude).toBe(20); + expect(position.coords.accuracy).toBe(3); + expect(position.timestamp).toBe(4); + done(); + }); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 3, timestamp: 4}); + }); + + test('geolocate event', done => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + + const click = new window.Event('click'); + + geolocate.on('geolocate', (position) => { + expect(position.coords.latitude).toBe(10); + expect(position.coords.longitude).toBe(20); + expect(position.coords.accuracy).toBe(30); + expect(position.timestamp).toBe(40); + done(); + }); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 30, timestamp: 40}); + }); + + test('trigger', () => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + + expect(geolocate.trigger()).toBeTruthy(); + }); + + test('trigger and then error when tracking user location should get to active error state', () => { + const geolocate = new GeolocateControl({trackUserLocation: true}); + map.addControl(geolocate); + + geolocate.trigger(); + geolocation.sendError({code: 2, message: 'error message'}); + expect(geolocate._watchState).toBe('ACTIVE_ERROR'); + expect(geolocate._geolocateButton.classList.contains('maplibregl-ctrl-geolocate-active-error')).toBeTruthy(); + }); + + test('trigger before added to map', () => { + jest.spyOn(console, 'warn').mockImplementation(() => { }); + + const geolocate = new GeolocateControl(undefined); + + expect(geolocate.trigger()).toBeFalsy(); + expect(console.warn).toHaveBeenCalledWith('Geolocate control triggered before added to a map'); + }); + + test('geolocate fitBoundsOptions', async () => { + const geolocate = new GeolocateControl({ + fitBoundsOptions: { + duration: 0, + maxZoom: 10 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const moveEndPromise = map.once('moveend'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 1}); + await moveEndPromise; + expect(map.getZoom()).toBe(10); + }); + + test('with removed before Geolocation callback', () => { + expect(() => { + const geolocate = new GeolocateControl(undefined); + map.addControl(geolocate); + geolocate.trigger(); + map.removeControl(geolocate); + }).not.toThrow(); + }); + + test('non-zero bearing', async () => { + map.setBearing(45); + const geolocate = new GeolocateControl({ + fitBoundsOptions: { + duration: 0, + maxZoom: 10 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const moveEndPromise = map.once('moveend'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 1}); + await moveEndPromise; + expect(lngLatAsFixed(map.getCenter(), 4)).toEqual({lat: '10.0000', lng: '20.0000'}); + expect(map.getBearing()).toBe(45); + expect(map.getZoom()).toBe(10); + }); + + test('no watching map camera on geolocation', async () => { + const geolocate = new GeolocateControl({ + fitBoundsOptions: { + maxZoom: 20, + duration: 0 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const moveEndPromise = map.once('moveend'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 1000}); + await moveEndPromise; + const mapCenter = map.getCenter(); + expect(lngLatAsFixed(mapCenter, 4)).toEqual({lat: '10.0000', lng: '20.0000'}); + + const mapBounds = map.getBounds(); + + // map bounds should contain or equal accuracy bounds, that is the ensure accuracy bounds doesn't fall outside the map bounds + const accuracyBounds = LngLatBounds.fromLngLat(mapCenter, 1000); + + expect(accuracyBounds.getNorth().toFixed(4) <= mapBounds.getNorth().toFixed(4)).toBeTruthy(); + expect(accuracyBounds.getSouth().toFixed(4) >= mapBounds.getSouth().toFixed(4)).toBeTruthy(); + expect(accuracyBounds.getEast().toFixed(4) <= mapBounds.getEast().toFixed(4)).toBeTruthy(); + expect(accuracyBounds.getWest().toFixed(4) >= mapBounds.getWest().toFixed(4)).toBeTruthy(); + + // map bounds should not be too much bigger on all edges of the accuracy bounds (this test will only work for an orthogonal bearing), + // ensures map bounds does not contain buffered accuracy bounds, as if it does there is too much gap around the accuracy bounds + const bufferedAccuracyBounds = LngLatBounds.fromLngLat(mapCenter, 1100); + + expect( + (bufferedAccuracyBounds.getNorth().toFixed(4) < mapBounds.getNorth().toFixed(4)) && + (bufferedAccuracyBounds.getSouth().toFixed(4) > mapBounds.getSouth().toFixed(4)) && + (bufferedAccuracyBounds.getEast().toFixed(4) < mapBounds.getEast().toFixed(4)) && + (bufferedAccuracyBounds.getWest().toFixed(4) > mapBounds.getWest().toFixed(4)) + ).toBeFalsy(); + }); + + test('watching map updates recenter on location with dot', done => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + showUserLocation: true, + fitBoundsOptions: { + duration: 0 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + let moveendCount = 0; + map.once('moveend', () => { + // moveend was being called a second time, this ensures that we don't run the tests a second time + if (moveendCount > 0) return; + moveendCount++; + + expect(lngLatAsFixed(map.getCenter(), 4)).toEqual({lat: '10.0000', lng: '20.0000'}); + expect(geolocate._userLocationDotMarker._map).toBeTruthy(); + expect( + geolocate._userLocationDotMarker._element.classList.contains('maplibregl-user-location-dot-stale') + ).toBeFalsy(); + map.once('moveend', () => { + expect(lngLatAsFixed(map.getCenter(), 4)).toEqual({lat: '40.0000', lng: '50.0000'}); + geolocate.once('error', () => { + expect(geolocate._userLocationDotMarker._map).toBeTruthy(); + expect( + geolocate._userLocationDotMarker._element.classList.contains('maplibregl-user-location-dot-stale') + ).toBeTruthy(); + done(); + }); + geolocation.changeError({code: 2, message: 'position unavaliable'}); + }); + geolocation.change({latitude: 40, longitude: 50, accuracy: 60}); + }); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 30}); + }); + + test('watching map background event', done => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + fitBoundsOptions: { + duration: 0 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + let moveendCount = 0; + map.once('moveend', () => { + // moveend was being called a second time, this ensures that we don't run the tests a second time + if (moveendCount > 0) return; + moveendCount++; + + geolocate.once('trackuserlocationend', () => { + expect(map.getCenter()).toEqual({lng: 10, lat: 5}); + done(); + }); + + // manually pan the map away from the geolocation position which should trigger the 'trackuserlocationend' event above + map.jumpTo({ + center: [10, 5] + }); + }); + // click the button to activate it into the enabled watch state + geolocate._geolocateButton.dispatchEvent(click); + // send through a location update which should reposition the map and trigger the 'moveend' event above + geolocation.send({latitude: 10, longitude: 20, accuracy: 30}); + }); + + test('watching map background state', done => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + fitBoundsOptions: { + duration: 0 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + let moveendCount = 0; + map.once('moveend', () => { + // moveend was being called a second time, this ensures that we don't run the tests a second time + if (moveendCount > 0) return; + moveendCount++; + + map.once('moveend', () => { + geolocate.once('geolocate', () => { + expect(map.getCenter()).toEqual({lng: 10, lat: 5}); + done(); + }); + // update the geolocation position, since we are in background state when 'geolocate' is triggered above, the camera shouldn't have changed + geolocation.change({latitude: 0, longitude: 0, accuracy: 10}); + }); + + // manually pan the map away from the geolocation position which should trigger the 'moveend' event above + map.jumpTo({ + center: [10, 5] + }); + }); + // click the button to activate it into the enabled watch state + geolocate._geolocateButton.dispatchEvent(click); + // send through a location update which should reposition the map and trigger the 'moveend' event above + geolocation.send({latitude: 10, longitude: 20, accuracy: 30}); + }); + + test('trackuserlocationstart event', async () => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + fitBoundsOptions: { + duration: 0 + } + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const promise = geolocate.once('trackuserlocationstart'); + geolocate._geolocateButton.dispatchEvent(click); + await promise; + expect(map.getCenter()).toEqual({lng: 0, lat: 0}); + }); + + test('does not switch to BACKGROUND and stays in ACTIVE_LOCK state on window resize', async () => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const geolocatePromise = geolocate.once('geolocate'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 30, timestamp: 40}); + await geolocatePromise; + expect(geolocate._watchState).toBe('ACTIVE_LOCK'); + window.dispatchEvent(new window.Event('resize')); + expect(geolocate._watchState).toBe('ACTIVE_LOCK'); + }); + + test('switches to BACKGROUND state on map manipulation', async () => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const geolocatePromise = geolocate.once('geolocate'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 30, timestamp: 40}); + await geolocatePromise; + expect(geolocate._watchState).toBe('ACTIVE_LOCK'); + map.jumpTo({ + center: [0, 0] + }); + expect(geolocate._watchState).toBe('BACKGROUND'); + }); + + test('accuracy circle not shown if showAccuracyCircle = false', async () => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + showUserLocation: true, + showAccuracyCircle: false, + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const geolocatePromise = geolocate.once('geolocate'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 700}); + await geolocatePromise; + map.jumpTo({ + center: [10, 20] + }); + const zoomendPromise = map.once('zoomend'); + map.zoomTo(10, {duration: 0}); + await zoomendPromise; + expect(!geolocate._circleElement.style.width).toBeTruthy(); + }); + + test('accuracy circle radius matches reported accuracy', async () => { + const geolocate = new GeolocateControl({ + trackUserLocation: true, + showUserLocation: true, + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const geolocatePromise = geolocate.once('geolocate'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 700}); + await geolocatePromise; + expect(geolocate._accuracyCircleMarker._map).toBeTruthy(); + expect(geolocate._accuracy).toBe(700); + map.jumpTo({ + center: [10, 20] + }); + + // test with bugger radius + let zoomendPromise = map.once('zoomend'); + map.zoomTo(12, {duration: 0}); + await zoomendPromise; + expect(geolocate._circleElement.style.width).toBe('79px'); + console.log(geolocate._circleElement.style.width); + zoomendPromise = map.once('zoomend'); + map.zoomTo(10, {duration: 0}); + await zoomendPromise; + expect(geolocate._circleElement.style.width).toBe('20px'); + console.log(geolocate._circleElement.style.width); + zoomendPromise = map.once('zoomend'); + + // test with smaller radius + geolocation.send({latitude: 10, longitude: 20, accuracy: 20}); + map.zoomTo(20, {duration: 0}); + await zoomendPromise; + expect(geolocate._circleElement.style.width).toBe('19982px'); + console.log(geolocate._circleElement.style.width); + zoomendPromise = map.once('zoomend'); + map.zoomTo(18, {duration: 0}); + await zoomendPromise; + expect(geolocate._circleElement.style.width).toBe('4996px'); + console.log(geolocate._circleElement.style.width); + }); + + test('shown even if trackUserLocation = false', async () => { + const geolocate = new GeolocateControl({ + trackUserLocation: false, + showUserLocation: true, + showAccuracyCircle: true, + }); + map.addControl(geolocate); + + const click = new window.Event('click'); + + const geolocatePromise = geolocate.once('geolocate'); + geolocate._geolocateButton.dispatchEvent(click); + geolocation.send({latitude: 10, longitude: 20, accuracy: 700}); + await geolocatePromise; + map.jumpTo({ + center: [10, 20] + }); + const zoomendPromise = map.once('zoomend'); + map.zoomTo(10, {duration: 0}); + await zoomendPromise; + expect(geolocate._circleElement.style.width).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/geolocate_control.ts b/web/libraries/maplibre-gl/src/ui/control/geolocate_control.ts new file mode 100644 index 00000000..1399435f --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/geolocate_control.ts @@ -0,0 +1,667 @@ +import {Event, Evented} from '../../util/evented'; +import {DOM} from '../../util/dom'; +import {extend, warnOnce} from '../../util/util'; +import {checkGeolocationSupport} from '../../util/geolocation_support'; +import {LngLat} from '../../geo/lng_lat'; +import {Marker} from '../marker'; + +import type {Map} from '../map'; +import type {FitBoundsOptions} from '../camera'; +import type {IControl} from './control'; +import {LngLatBounds} from '../../geo/lng_lat_bounds'; + +/** + * The {@link GeolocateControl} options + */ +type GeolocateOptions = { + /** + * A Geolocation API [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) object. + * @defaultValue `{enableHighAccuracy: false, timeout: 6000}` + */ + positionOptions?: PositionOptions; + /** + * A options object to use when the map is panned and zoomed to the user's location. The default is to use a `maxZoom` of 15 to limit how far the map will zoom in for very accurate locations. + */ + fitBoundsOptions?: FitBoundsOptions; + /** + * If `true` the Geolocate Control becomes a toggle button and when active the map will receive updates to the user's location as it changes. + * @defaultValue false + */ + trackUserLocation?: boolean; + /** + * By default, if showUserLocation is `true`, a transparent circle will be drawn around the user location indicating the accuracy (95% confidence level) of the user's location. Set to `false` to disable. Always disabled when showUserLocation is `false`. + * @defaultValue true + */ + showAccuracyCircle?: boolean; + /** + * By default a dot will be shown on the map at the user's location. Set to `false` to disable. + * @defaultValue true + */ + showUserLocation?: boolean; +}; + +const defaultOptions: GeolocateOptions = { + positionOptions: { + enableHighAccuracy: false, + maximumAge: 0, + timeout: 6000 /* 6 sec */ + }, + fitBoundsOptions: { + maxZoom: 15 + }, + trackUserLocation: false, + showAccuracyCircle: true, + showUserLocation: true +}; + +let numberOfWatches = 0; +let noTimeout = false; + +/** + * A `GeolocateControl` control provides a button that uses the browser's geolocation + * API to locate the user on the map. + * + * Not all browsers support geolocation, + * and some users may disable the feature. Geolocation support for modern + * browsers including Chrome requires sites to be served over HTTPS. If + * geolocation support is not available, the GeolocateControl will show + * as disabled. + * + * The zoom level applied will depend on the accuracy of the geolocation provided by the device. + * + * The GeolocateControl has two modes. If `trackUserLocation` is `false` (default) the control acts as a button, which when pressed will set the map's camera to target the user location. If the user moves, the map won't update. This is most suited for the desktop. If `trackUserLocation` is `true` the control acts as a toggle button that when active the user's location is actively monitored for changes. In this mode the GeolocateControl has three interaction states: + * * active - the map's camera automatically updates as the user's location changes, keeping the location dot in the center. Initial state and upon clicking the `GeolocateControl` button. + * * passive - the user's location dot automatically updates, but the map's camera does not. Occurs upon the user initiating a map movement. + * * disabled - occurs if Geolocation is not available, disabled or denied. + * + * These interaction states can't be controlled programmatically, rather they are set based on user interactions. + * @group Markers and Controls + * + * @example + * ```ts + * map.addControl(new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * })); + * ``` + * @see [Locate the user](https://maplibre.org/maplibre-gl-js/docs/examples/locate-user/) + * + * ### Events + * + * @event `trackuserlocationend` - Fired when the Geolocate Control changes to the background state, which happens when a user changes the camera during an active position lock. This only applies when trackUserLocation is true. In the background state, the dot on the map will update with location updates but the camera will not. + * + * @event `trackuserlocationstart` - Fired when the Geolocate Control changes to the active lock state, which happens either upon first obtaining a successful Geolocation API position for the user (a geolocate event will follow), or the user clicks the geolocate button when in the background state which uses the last known position to recenter the map and enter active lock state (no geolocate event will follow unless the users's location changes). + * + * @event `geolocate` - Fired on each Geolocation API position update which returned as success. + * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition). + * + * @event `error` - Fired on each Geolocation API position update which returned as an error. + * `data` - The returned [PositionError](https://developer.mozilla.org/en-US/docs/Web/API/PositionError) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition). + * + * @event `outofmaxbounds` Fired on each Geolocation API position update which returned as success but user position is out of map maxBounds. + * `data` - The returned [Position](https://developer.mozilla.org/en-US/docs/Web/API/Position) object from the callback in [Geolocation.getCurrentPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) or [Geolocation.watchPosition()](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition). + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when a trackuserlocationend event occurs. + * geolocate.on('trackuserlocationend', function() { + * console.log('A trackuserlocationend event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when a trackuserlocationstart event occurs. + * geolocate.on('trackuserlocationstart', function() { + * console.log('A trackuserlocationstart event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when a geolocate event occurs. + * geolocate.on('geolocate', function() { + * console.log('A geolocate event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when an error event occurs. + * geolocate.on('error', function() { + * console.log('An error event has occurred.') + * }); + * ``` + * + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * // Set an event listener that fires + * // when an outofmaxbounds event occurs. + * geolocate.on('outofmaxbounds', function() { + * console.log('An outofmaxbounds event has occurred.') + * }); + * ``` + */ +export class GeolocateControl extends Evented implements IControl { + _map: Map; + options: GeolocateOptions; + _container: HTMLElement; + _dotElement: HTMLElement; + _circleElement: HTMLElement; + _geolocateButton: HTMLButtonElement; + _geolocationWatchID: number; + _timeoutId: ReturnType; + /* Geolocate Control Watch States + * This is the private state of the control. + * + * OFF + * off/inactive + * WAITING_ACTIVE + * Geolocate Control was clicked but still waiting for Geolocation API response with user location + * ACTIVE_LOCK + * Showing the user location as a dot AND tracking the camera to be fixed to their location. If their location changes the map moves to follow. + * ACTIVE_ERROR + * There was en error from the Geolocation API while trying to show and track the user location. + * BACKGROUND + * Showing the user location as a dot but the camera doesn't follow their location as it changes. + * BACKGROUND_ERROR + * There was an error from the Geolocation API while trying to show (but not track) the user location. + */ + _watchState: 'OFF' | 'ACTIVE_LOCK' | 'WAITING_ACTIVE' | 'ACTIVE_ERROR' | 'BACKGROUND' | 'BACKGROUND_ERROR'; + _lastKnownPosition: any; + _userLocationDotMarker: Marker; + _accuracyCircleMarker: Marker; + _accuracy: number; + _setup: boolean; // set to true once the control has been setup + + constructor(options: GeolocateOptions) { + super(); + this.options = extend({}, defaultOptions, options); + } + + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map) { + this._map = map; + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + checkGeolocationSupport(this._setupUI); + return this._container; + } + + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + // clear the geolocation watch if exists + if (this._geolocationWatchID !== undefined) { + window.navigator.geolocation.clearWatch(this._geolocationWatchID); + this._geolocationWatchID = undefined; + } + + // clear the markers from the map + if (this.options.showUserLocation && this._userLocationDotMarker) { + this._userLocationDotMarker.remove(); + } + if (this.options.showAccuracyCircle && this._accuracyCircleMarker) { + this._accuracyCircleMarker.remove(); + } + + DOM.remove(this._container); + this._map.off('zoom', this._onZoom); + this._map = undefined; + numberOfWatches = 0; + noTimeout = false; + } + + /** + * Check if the Geolocation API Position is outside the map's maxbounds. + * + * @param position - the Geolocation API Position + * @returns `true` if position is outside the map's maxbounds, otherwise returns `false`. + */ + _isOutOfMapMaxBounds(position: GeolocationPosition) { + const bounds = this._map.getMaxBounds(); + const coordinates = position.coords; + + return bounds && ( + coordinates.longitude < bounds.getWest() || + coordinates.longitude > bounds.getEast() || + coordinates.latitude < bounds.getSouth() || + coordinates.latitude > bounds.getNorth() + ); + } + + _setErrorState() { + switch (this._watchState) { + case 'WAITING_ACTIVE': + this._watchState = 'ACTIVE_ERROR'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error'); + break; + case 'ACTIVE_LOCK': + this._watchState = 'ACTIVE_ERROR'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + // turn marker grey + break; + case 'BACKGROUND': + this._watchState = 'BACKGROUND_ERROR'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + // turn marker grey + break; + case 'ACTIVE_ERROR': + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + } + + /** + * When the Geolocation API returns a new location, update the GeolocateControl. + * + * @param position - the Geolocation API Position + */ + _onSuccess = (position: GeolocationPosition) => { + if (!this._map) { + // control has since been removed + return; + } + + if (this._isOutOfMapMaxBounds(position)) { + this._setErrorState(); + + this.fire(new Event('outofmaxbounds', position)); + this._updateMarker(); + this._finish(); + + return; + } + + if (this.options.trackUserLocation) { + // keep a record of the position so that if the state is BACKGROUND and the user + // clicks the button, we can move to ACTIVE_LOCK immediately without waiting for + // watchPosition to trigger _onSuccess + this._lastKnownPosition = position; + + switch (this._watchState) { + case 'WAITING_ACTIVE': + case 'ACTIVE_LOCK': + case 'ACTIVE_ERROR': + this._watchState = 'ACTIVE_LOCK'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active'); + break; + case 'BACKGROUND': + case 'BACKGROUND_ERROR': + this._watchState = 'BACKGROUND'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background'); + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + } + + // if showUserLocation and the watch state isn't off then update the marker location + if (this.options.showUserLocation && this._watchState !== 'OFF') { + this._updateMarker(position); + } + + // if in normal mode (not watch mode), or if in watch mode and the state is active watch + // then update the camera + if (!this.options.trackUserLocation || this._watchState === 'ACTIVE_LOCK') { + this._updateCamera(position); + } + + if (this.options.showUserLocation) { + this._dotElement.classList.remove('maplibregl-user-location-dot-stale'); + } + + this.fire(new Event('geolocate', position)); + this._finish(); + }; + + /** + * Update the camera location to center on the current position + * + * @param position - the Geolocation API Position + */ + _updateCamera = (position: GeolocationPosition) => { + const center = new LngLat(position.coords.longitude, position.coords.latitude); + const radius = position.coords.accuracy; + const bearing = this._map.getBearing(); + const options = extend({bearing}, this.options.fitBoundsOptions); + const newBounds = LngLatBounds.fromLngLat(center, radius); + + this._map.fitBounds(newBounds, options, { + geolocateSource: true // tag this camera change so it won't cause the control to change to background state + }); + }; + + /** + * Update the user location dot Marker to the current position + * + * @param position - the Geolocation API Position + */ + _updateMarker = (position?: GeolocationPosition | null) => { + if (position) { + const center = new LngLat(position.coords.longitude, position.coords.latitude); + this._accuracyCircleMarker.setLngLat(center).addTo(this._map); + this._userLocationDotMarker.setLngLat(center).addTo(this._map); + this._accuracy = position.coords.accuracy; + if (this.options.showUserLocation && this.options.showAccuracyCircle) { + this._updateCircleRadius(); + } + } else { + this._userLocationDotMarker.remove(); + this._accuracyCircleMarker.remove(); + } + }; + + _updateCircleRadius() { + const bounds = this._map.getBounds(); + const southEastPoint = bounds.getSouthEast(); + const northEastPoint = bounds.getNorthEast(); + const mapHeightInMeters = southEastPoint.distanceTo(northEastPoint); + const mapHeightInPixels = this._map._container.clientHeight; + const circleDiameter = Math.ceil(2 * (this._accuracy / (mapHeightInMeters / mapHeightInPixels))); + this._circleElement.style.width = `${circleDiameter}px`; + this._circleElement.style.height = `${circleDiameter}px`; + } + + _onZoom = () => { + if (this.options.showUserLocation && this.options.showAccuracyCircle) { + this._updateCircleRadius(); + } + }; + + _onError = (error: GeolocationPositionError) => { + if (!this._map) { + // control has since been removed + return; + } + + if (this.options.trackUserLocation) { + if (error.code === 1) { + // PERMISSION_DENIED + this._watchState = 'OFF'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error'); + this._geolocateButton.disabled = true; + const title = this._map._getUIString('GeolocateControl.LocationNotAvailable'); + this._geolocateButton.title = title; + this._geolocateButton.setAttribute('aria-label', title); + + if (this._geolocationWatchID !== undefined) { + this._clearWatch(); + } + } else if (error.code === 3 && noTimeout) { + // this represents a forced error state + // this was triggered to force immediate geolocation when a watch is already present + // see https://github.com/mapbox/mapbox-gl-js/issues/8214 + // and https://w3c.github.io/geolocation-api/#example-5-forcing-the-user-agent-to-return-a-fresh-cached-position + return; + } else { + this._setErrorState(); + } + } + + if (this._watchState !== 'OFF' && this.options.showUserLocation) { + this._dotElement.classList.add('maplibregl-user-location-dot-stale'); + } + + this.fire(new Event('error', error)); + + this._finish(); + }; + + _finish = () => { + if (this._timeoutId) { clearTimeout(this._timeoutId); } + this._timeoutId = undefined; + }; + + _setupUI = (supported: boolean) => { + // this method is called asynchronously during onAdd + // the control could have been removed before reaching here + if (!this._map) { + return; + } + + this._container.addEventListener('contextmenu', (e: MouseEvent) => e.preventDefault()); + this._geolocateButton = DOM.create('button', 'maplibregl-ctrl-geolocate', this._container); + DOM.create('span', 'maplibregl-ctrl-icon', this._geolocateButton).setAttribute('aria-hidden', 'true'); + this._geolocateButton.type = 'button'; + + if (supported === false) { + warnOnce('Geolocation support is not available so the GeolocateControl will be disabled.'); + const title = this._map._getUIString('GeolocateControl.LocationNotAvailable'); + this._geolocateButton.disabled = true; + this._geolocateButton.title = title; + this._geolocateButton.setAttribute('aria-label', title); + } else { + const title = this._map._getUIString('GeolocateControl.FindMyLocation'); + this._geolocateButton.title = title; + this._geolocateButton.setAttribute('aria-label', title); + } + + if (this.options.trackUserLocation) { + this._geolocateButton.setAttribute('aria-pressed', 'false'); + this._watchState = 'OFF'; + } + + // when showUserLocation is enabled, keep the Geolocate button disabled until the device location marker is setup on the map + if (this.options.showUserLocation) { + this._dotElement = DOM.create('div', 'maplibregl-user-location-dot'); + + this._userLocationDotMarker = new Marker({element: this._dotElement}); + + this._circleElement = DOM.create('div', 'maplibregl-user-location-accuracy-circle'); + this._accuracyCircleMarker = new Marker({element: this._circleElement, pitchAlignment: 'map'}); + + if (this.options.trackUserLocation) this._watchState = 'OFF'; + + this._map.on('zoom', this._onZoom); + } + + this._geolocateButton.addEventListener('click', + this.trigger.bind(this)); + + this._setup = true; + + // when the camera is changed (and it's not as a result of the Geolocation Control) change + // the watch mode to background watch, so that the marker is updated but not the camera. + if (this.options.trackUserLocation) { + this._map.on('movestart', (event: any) => { + const fromResize = event.originalEvent && event.originalEvent.type === 'resize'; + if (!event.geolocateSource && this._watchState === 'ACTIVE_LOCK' && !fromResize) { + this._watchState = 'BACKGROUND'; + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + + this.fire(new Event('trackuserlocationend')); + } + }); + } + }; + + /** + * Programmatically request and move the map to the user's location. + * + * @returns `false` if called before control was added to a map, otherwise returns `true`. + * @example + * ```ts + * // Initialize the geolocate control. + * let geolocate = new maplibregl.GeolocateControl({ + * positionOptions: { + * enableHighAccuracy: true + * }, + * trackUserLocation: true + * }); + * // Add the control to the map. + * map.addControl(geolocate); + * map.on('load', function() { + * geolocate.trigger(); + * }); + * ``` + */ + trigger(): boolean { + if (!this._setup) { + warnOnce('Geolocate control triggered before added to a map'); + return false; + } + if (this.options.trackUserLocation) { + // update watchState and do any outgoing state cleanup + switch (this._watchState) { + case 'OFF': + // turn on the Geolocate Control + this._watchState = 'WAITING_ACTIVE'; + + this.fire(new Event('trackuserlocationstart')); + break; + case 'WAITING_ACTIVE': + case 'ACTIVE_LOCK': + case 'ACTIVE_ERROR': + case 'BACKGROUND_ERROR': + // turn off the Geolocate Control + numberOfWatches--; + noTimeout = false; + this._watchState = 'OFF'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-active-error'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background-error'); + + this.fire(new Event('trackuserlocationend')); + break; + case 'BACKGROUND': + this._watchState = 'ACTIVE_LOCK'; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-background'); + // set camera to last known location + if (this._lastKnownPosition) this._updateCamera(this._lastKnownPosition); + + this.fire(new Event('trackuserlocationstart')); + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + + // incoming state setup + switch (this._watchState) { + case 'WAITING_ACTIVE': + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active'); + break; + case 'ACTIVE_LOCK': + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-active'); + break; + case 'OFF': + break; + default: + throw new Error(`Unexpected watchState ${this._watchState}`); + } + + // manage geolocation.watchPosition / geolocation.clearWatch + if (this._watchState === 'OFF' && this._geolocationWatchID !== undefined) { + // clear watchPosition as we've changed to an OFF state + this._clearWatch(); + } else if (this._geolocationWatchID === undefined) { + // enable watchPosition since watchState is not OFF and there is no watchPosition already running + + this._geolocateButton.classList.add('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.setAttribute('aria-pressed', 'true'); + + numberOfWatches++; + let positionOptions; + if (numberOfWatches > 1) { + positionOptions = {maximumAge: 600000, timeout: 0}; + noTimeout = true; + } else { + positionOptions = this.options.positionOptions; + noTimeout = false; + } + + this._geolocationWatchID = window.navigator.geolocation.watchPosition( + this._onSuccess, this._onError, positionOptions); + } + } else { + window.navigator.geolocation.getCurrentPosition( + this._onSuccess, this._onError, this.options.positionOptions); + + // This timeout ensures that we still call finish() even if + // the user declines to share their location in Firefox + this._timeoutId = setTimeout(this._finish, 10000 /* 10sec */); + } + + return true; + } + + _clearWatch() { + window.navigator.geolocation.clearWatch(this._geolocationWatchID); + + this._geolocationWatchID = undefined; + this._geolocateButton.classList.remove('maplibregl-ctrl-geolocate-waiting'); + this._geolocateButton.setAttribute('aria-pressed', 'false'); + + if (this.options.showUserLocation) { + this._updateMarker(null); + } + } +} + diff --git a/web/libraries/maplibre-gl/src/ui/control/logo_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/logo_control.test.ts new file mode 100644 index 00000000..78a1a948 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/logo_control.test.ts @@ -0,0 +1,90 @@ +import {createMap as globalCreateMap, beforeMapTest} from '../../util/test/util'; + +function createMap(logoPosition, maplibreLogo) { + + const mapobj = { + logoPosition, + maplibreLogo, + style: { + version: 8, + sources: {}, + layers: [] + } + }; + + return globalCreateMap(mapobj, undefined); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('LogoControl', () => { + test('does not appear by default', done => { + const map = createMap(undefined, undefined); + map.on('load', () => { + expect(map.getContainer().querySelectorAll( + '.maplibregl-ctrl-logo' + )).toHaveLength(0); + done(); + }); + }); + + test('is not displayed when the maplibreLogo property is false', done => { + const map = createMap(undefined, false); + map.on('load', () => { + expect(map.getContainer().querySelectorAll( + '.maplibregl-ctrl-logo' + )).toHaveLength(0); + done(); + }); + }); + + test('appears in bottom-left when maplibreLogo is true and logoPosition is undefined', done => { + const map = createMap(undefined, true); + map.on('load', () => { + expect(map.getContainer().querySelectorAll( + '.maplibregl-ctrl-bottom-left .maplibregl-ctrl-logo' + )).toHaveLength(1); + done(); + }); + }); + + test('appears in the position specified by the position option', done => { + const map = createMap('top-left', true); + map.on('load', () => { + expect(map.getContainer().querySelectorAll( + '.maplibregl-ctrl-top-left .maplibregl-ctrl-logo' + )).toHaveLength(1); + done(); + }); + }); + + test('appears in compact mode if container is less then 640 pixel wide', () => { + const map = createMap(undefined, true); + const container = map.getContainer(); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 645, configurable: true}); + map.resize(); + expect( + container.querySelectorAll('.maplibregl-ctrl-logo:not(.maplibregl-compact)') + ).toHaveLength(1); + + Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 635, configurable: true}); + map.resize(); + expect( + container.querySelectorAll('.maplibregl-ctrl-logo.maplibregl-compact') + ).toHaveLength(1); + }); + + test('has `rel` nooper and nofollow', done => { + const map = createMap(undefined, true); + + map.on('load', () => { + const container = map.getContainer(); + const logo = container.querySelector('.maplibregl-ctrl-logo'); + expect(logo).toHaveProperty('rel', 'noopener nofollow'); + done(); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/logo_control.ts b/web/libraries/maplibre-gl/src/ui/control/logo_control.ts new file mode 100644 index 00000000..4ce08838 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/logo_control.ts @@ -0,0 +1,83 @@ +import {DOM} from '../../util/dom'; + +import type {Map} from '../map'; +import type {ControlPosition, IControl} from './control'; + +/** + * The {@link LogoControl} options object + */ +type LogoOptions = { + /** + * If `true`, force a compact logo. + * If `false`, force the full logo. The default is a responsive logo that collapses when the map is less than 640 pixels wide. + */ + compact?: boolean; +}; + +/** + * A `LogoControl` is a control that adds the watermark. + * + * @group Markers and Controls + * + * @example + * ```ts + * map.addControl(new maplibregl.LogoControl({compact: false})); + * ``` + **/ +export class LogoControl implements IControl { + options: LogoOptions; + _map: Map; + _compact: boolean; + _container: HTMLElement; + + constructor(options: LogoOptions = {}) { + this.options = options; + } + + getDefaultPosition(): ControlPosition { + return 'bottom-left'; + } + + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map) { + this._map = map; + this._compact = this.options && this.options.compact; + this._container = DOM.create('div', 'maplibregl-ctrl'); + const anchor = DOM.create('a', 'maplibregl-ctrl-logo'); + anchor.target = '_blank'; + anchor.rel = 'noopener nofollow'; + anchor.href = 'https://maplibre.org/'; + anchor.setAttribute('aria-label', this._map._getUIString('LogoControl.Title')); + anchor.setAttribute('rel', 'noopener nofollow'); + this._container.appendChild(anchor); + this._container.style.display = 'block'; + + this._map.on('resize', this._updateCompact); + this._updateCompact(); + + return this._container; + } + + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('resize', this._updateCompact); + this._map = undefined; + this._compact = undefined; + } + + _updateCompact = () => { + const containerChildren = this._container.children; + if (containerChildren.length) { + const anchor = containerChildren[0]; + if (this._map.getCanvasContainer().offsetWidth <= 640 || this._compact) { + if (this._compact !== false) { + anchor.classList.add('maplibregl-compact'); + } + } else { + anchor.classList.remove('maplibregl-compact'); + } + } + }; + +} diff --git a/web/libraries/maplibre-gl/src/ui/control/navigation_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/navigation_control.test.ts new file mode 100644 index 00000000..58038f71 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/navigation_control.test.ts @@ -0,0 +1,238 @@ +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {createMap as globalCreateMap, beforeMapTest} from '../../util/test/util'; +import {NavigationControl} from './navigation_control'; + +function createMap() { + return globalCreateMap({}); +} + +let map; + +beforeEach(() => { + beforeMapTest(); + map = createMap(); +}); + +afterEach(() => { + map.remove(); +}); + +describe('NavigationControl', () => { + test('appears in the top-right', () => { + map.addControl(new NavigationControl()); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-top-right > .maplibregl-ctrl') + ).toHaveLength(1); + }); + + test('contains zoom in button', () => { + map.addControl(new NavigationControl()); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-zoom-in') + ).toHaveLength(1); + }); + + test('contains zoom out button', () => { + map.addControl(new NavigationControl()); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-zoom-out') + ).toHaveLength(1); + }); + + test('contains compass button', () => { + map.addControl(new NavigationControl()); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-compass') + ).toHaveLength(1); + }); + + test('compass button reset action', () => { + map.setPitch(10); + map.setBearing(10); + + map.addControl(new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + })); + const spyReset = jest.spyOn(map, 'resetNorthPitch'); + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + + simulate.click(navButton); + map._renderTaskQueue.run(); + + expect(spyReset).toHaveBeenCalledTimes(1); + }); + + test('compass button drag horizontal', () => { + const navControl = new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + }); + map.addControl(navControl); + + const spySetPitch = jest.spyOn(map, 'setPitch'); + const spySetBearing = jest.spyOn(map, 'setBearing'); + + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + const navRect = navButton.getClientRects(); + + const buttonX = (navRect.x ?? 0) + (navRect.width ?? 0) / 2; + const buttonY = (navRect.y ?? 0) + (navRect.height ?? 0) / 2; + + simulate.mousedown(navButton, {buttons: 1, button: 0, clientX: buttonX, clientY: buttonY}); + simulate.mousemove(window, {buttons: 1, button: 0, clientX: buttonX - 50, clientY: buttonY}); + simulate.mousemove(window, {buttons: 1, button: 0, clientX: buttonX - 100, clientY: buttonY}); + simulate.mouseup(window, {button: 0, clientX: buttonX - 100, clientY: buttonY}); + + map._renderTaskQueue.run(); + + expect(spySetPitch).not.toHaveBeenCalled(); + expect(spySetBearing).toHaveBeenCalled(); + }); + + test('compass button drag vertical', () => { + const navControl = new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + }); + map.addControl(navControl); + + const spySetPitch = jest.spyOn(map, 'setPitch'); + const spySetBearing = jest.spyOn(map, 'setBearing'); + + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + const navRect = navButton.getClientRects(); + + const buttonX = (navRect.x ?? 0) + (navRect.width ?? 0) / 2; + const buttonY = (navRect.y ?? 0) + (navRect.height ?? 0) / 2; + + simulate.mousedown(navButton, {buttons: 1, button: 0, clientX: buttonX, clientY: buttonY}); + simulate.mousemove(window, {buttons: 1, button: 0, clientX: buttonX, clientY: buttonY - 50}); + simulate.mousemove(window, {buttons: 1, button: 0, clientX: buttonX, clientY: buttonY - 100}); + simulate.mouseup(window, {button: 0, clientX: buttonX, clientY: buttonY - 100}); + + map._renderTaskQueue.run(); + + expect(spySetPitch).toHaveBeenCalled(); + expect(spySetBearing).not.toHaveBeenCalled(); + }); + + test('compass button drag diagonal', () => { + const navControl = new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + }); + map.addControl(navControl); + + const spySetPitch = jest.spyOn(map, 'setPitch'); + const spySetBearing = jest.spyOn(map, 'setBearing'); + + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + const navRect = navButton.getClientRects(); + + const buttonX = (navRect.x ?? 0) + (navRect.width ?? 0) / 2; + const buttonY = (navRect.y ?? 0) + (navRect.height ?? 0) / 2; + + simulate.mousedown(navButton, {buttons: 1, button: 0, clientX: buttonX, clientY: buttonY}); + simulate.mousemove(window, {buttons: 1, button: 0, clientX: buttonX - 50, clientY: buttonY - 50}); + simulate.mousemove(window, {buttons: 1, button: 0, clientX: buttonX - 100, clientY: buttonY - 100}); + simulate.mouseup(window, {button: 0, clientX: buttonX - 100, clientY: buttonY - 100}); + + map._renderTaskQueue.run(); + + expect(spySetPitch).toHaveBeenCalled(); + expect(spySetBearing).toHaveBeenCalled(); + }); + + test('compass button touch drag horizontal', () => { + const navControl = new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + }); + map.addControl(navControl); + + const spySetPitch = jest.spyOn(map, 'setPitch'); + const spySetBearing = jest.spyOn(map, 'setBearing'); + + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + const navRect = navButton.getClientRects(); + + const buttonX = (navRect.x ?? 0) + (navRect.width ?? 0) / 2; + const buttonY = (navRect.y ?? 0) + (navRect.height ?? 0) / 2; + + simulate.touchstart(navButton, {touches: [{clientX: buttonX, clientY: buttonY}], targetTouches: [{clientX: buttonX, clientY: buttonY}]}); + simulate.touchmove(window, {touches: [{clientX: buttonX - 50, clientY: buttonY}], targetTouches: [{clientX: buttonX - 50, clientY: buttonY}]}); + simulate.touchmove(window, {touches: [{clientX: buttonX - 100, clientY: buttonY}], targetTouches: [{clientX: buttonX - 100, clientY: buttonY}]}); + simulate.touchend(window); + + map._renderTaskQueue.run(); + + expect(spySetPitch).not.toHaveBeenCalled(); + expect(spySetBearing).toHaveBeenCalled(); + }); + + test('compass button touch drag vertical', () => { + const navControl = new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + }); + map.addControl(navControl); + + const spySetPitch = jest.spyOn(map, 'setPitch'); + const spySetBearing = jest.spyOn(map, 'setBearing'); + + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + const navRect = navButton.getClientRects(); + + const buttonX = (navRect.x ?? 0) + (navRect.width ?? 0) / 2; + const buttonY = (navRect.y ?? 0) + (navRect.height ?? 0) / 2; + + simulate.touchstart(navButton, {touches: [{clientX: buttonX, clientY: buttonY}], targetTouches: [{clientX: buttonX, clientY: buttonY}]}); + simulate.touchmove(window, {touches: [{clientX: buttonX, clientY: buttonY - 50}], targetTouches: [{clientX: buttonX, clientY: buttonY - 50}]}); + simulate.touchmove(window, {touches: [{clientX: buttonX, clientY: buttonY - 100}], targetTouches: [{clientX: buttonX, clientY: buttonY - 100}]}); + simulate.touchend(window); + + map._renderTaskQueue.run(); + + expect(spySetPitch).toHaveBeenCalled(); + expect(spySetBearing).not.toHaveBeenCalled(); + }); + + test('compass button touch drag diagonal', () => { + const navControl = new NavigationControl({ + visualizePitch: true, + showZoom: true, + showCompass: true + }); + map.addControl(navControl); + + const spySetPitch = jest.spyOn(map, 'setPitch'); + const spySetBearing = jest.spyOn(map, 'setBearing'); + + const navButton = map.getContainer().querySelector('.maplibregl-ctrl-compass'); + const navRect = navButton.getClientRects(); + + const buttonX = (navRect.x ?? 0) + (navRect.width ?? 0) / 2; + const buttonY = (navRect.y ?? 0) + (navRect.height ?? 0) / 2; + + simulate.touchstart(navButton, {touches: [{clientX: buttonX, clientY: buttonY}], targetTouches: [{clientX: buttonX, clientY: buttonY}]}); + simulate.touchmove(window, {touches: [{clientX: buttonX - 50, clientY: buttonY - 50}], targetTouches: [{clientX: buttonX - 50, clientY: buttonY - 50}]}); + simulate.touchmove(window, {touches: [{clientX: buttonX - 100, clientY: buttonY - 100}], targetTouches: [{clientX: buttonX - 100, clientY: buttonY - 100}]}); + simulate.touchend(window); + + map._renderTaskQueue.run(); + + expect(spySetPitch).toHaveBeenCalled(); + expect(spySetBearing).toHaveBeenCalled(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/navigation_control.ts b/web/libraries/maplibre-gl/src/ui/control/navigation_control.ts new file mode 100644 index 00000000..5883c517 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/navigation_control.ts @@ -0,0 +1,292 @@ +import Point from '@mapbox/point-geometry'; + +import {DOM} from '../../util/dom'; +import {extend} from '../../util/util'; +import {generateMousePitchHandler, generateMouseRotationHandler, MousePitchHandler, MouseRotateHandler} from '../handler/mouse'; +import {generateOneFingerTouchPitchHandler, generateOneFingerTouchRotationHandler, OneFingerTouchPitchHandler, OneFingerTouchRotateHandler} from '../handler/one_finger_touch_drag'; + +import type {Map} from '../map'; +import type {IControl} from './control'; + +/** + * The {@link NavigationControl} options object + */ +type NavigationOptions = { + /** + * If `true` the compass button is included. + */ + showCompass?: boolean; + /** + * If `true` the zoom-in and zoom-out buttons are included. + */ + showZoom?: boolean; + /** + * If `true` the pitch is visualized by rotating X-axis of compass. + */ + visualizePitch?: boolean; +}; + +const defaultOptions: NavigationOptions = { + showCompass: true, + showZoom: true, + visualizePitch: false +}; + +/** + * A `NavigationControl` control contains zoom buttons and a compass. + * + * @group Markers and Controls + * + * @example + * ```ts + * let nav = new maplibregl.NavigationControl(); + * map.addControl(nav, 'top-left'); + * ``` + * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/) + */ +export class NavigationControl implements IControl { + _map: Map; + options: NavigationOptions; + _container: HTMLElement; + _zoomInButton: HTMLButtonElement; + _zoomOutButton: HTMLButtonElement; + _compass: HTMLButtonElement; + _compassIcon: HTMLElement; + _handler: MouseRotateWrapper; + + /** + * @param options - the control's options + */ + constructor(options?: NavigationOptions) { + this.options = extend({}, defaultOptions, options); + + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + this._container.addEventListener('contextmenu', (e) => e.preventDefault()); + + if (this.options.showZoom) { + this._zoomInButton = this._createButton('maplibregl-ctrl-zoom-in', (e) => this._map.zoomIn({}, {originalEvent: e})); + DOM.create('span', 'maplibregl-ctrl-icon', this._zoomInButton).setAttribute('aria-hidden', 'true'); + this._zoomOutButton = this._createButton('maplibregl-ctrl-zoom-out', (e) => this._map.zoomOut({}, {originalEvent: e})); + DOM.create('span', 'maplibregl-ctrl-icon', this._zoomOutButton).setAttribute('aria-hidden', 'true'); + } + if (this.options.showCompass) { + this._compass = this._createButton('maplibregl-ctrl-compass', (e) => { + if (this.options.visualizePitch) { + this._map.resetNorthPitch({}, {originalEvent: e}); + } else { + this._map.resetNorth({}, {originalEvent: e}); + } + }); + this._compassIcon = DOM.create('span', 'maplibregl-ctrl-icon', this._compass); + this._compassIcon.setAttribute('aria-hidden', 'true'); + } + } + + _updateZoomButtons = () => { + const zoom = this._map.getZoom(); + const isMax = zoom === this._map.getMaxZoom(); + const isMin = zoom === this._map.getMinZoom(); + this._zoomInButton.disabled = isMax; + this._zoomOutButton.disabled = isMin; + this._zoomInButton.setAttribute('aria-disabled', isMax.toString()); + this._zoomOutButton.setAttribute('aria-disabled', isMin.toString()); + }; + + _rotateCompassArrow = () => { + const rotate = this.options.visualizePitch ? + `scale(${1 / Math.pow(Math.cos(this._map.transform.pitch * (Math.PI / 180)), 0.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle * (180 / Math.PI)}deg)` : + `rotate(${this._map.transform.angle * (180 / Math.PI)}deg)`; + + this._compassIcon.style.transform = rotate; + }; + + onAdd(map: Map) { + this._map = map; + if (this.options.showZoom) { + this._setButtonTitle(this._zoomInButton, 'ZoomIn'); + this._setButtonTitle(this._zoomOutButton, 'ZoomOut'); + this._map.on('zoom', this._updateZoomButtons); + this._updateZoomButtons(); + } + if (this.options.showCompass) { + this._setButtonTitle(this._compass, 'ResetBearing'); + if (this.options.visualizePitch) { + this._map.on('pitch', this._rotateCompassArrow); + } + this._map.on('rotate', this._rotateCompassArrow); + this._rotateCompassArrow(); + this._handler = new MouseRotateWrapper(this._map, this._compass, this.options.visualizePitch); + } + return this._container; + } + + onRemove() { + DOM.remove(this._container); + if (this.options.showZoom) { + this._map.off('zoom', this._updateZoomButtons); + } + if (this.options.showCompass) { + if (this.options.visualizePitch) { + this._map.off('pitch', this._rotateCompassArrow); + } + this._map.off('rotate', this._rotateCompassArrow); + this._handler.off(); + delete this._handler; + } + + delete this._map; + } + + _createButton(className: string, fn: (e?: any) => unknown) { + const a = DOM.create('button', className, this._container) as HTMLButtonElement; + a.type = 'button'; + a.addEventListener('click', fn); + return a; + } + + _setButtonTitle = (button: HTMLButtonElement, title: string) => { + const str = this._map._getUIString(`NavigationControl.${title}`); + button.title = str; + button.setAttribute('aria-label', str); + }; +} + +class MouseRotateWrapper { + + map: Map; + _clickTolerance: number; + element: HTMLElement; + // Rotation and pitch handlers are separated due to different _clickTolerance values + mouseRotate: MouseRotateHandler; + touchRotate: OneFingerTouchRotateHandler; + mousePitch: MousePitchHandler; + touchPitch: OneFingerTouchPitchHandler; + _startPos: Point; + _lastPos: Point; + + constructor(map: Map, element: HTMLElement, pitch: boolean = false) { + this._clickTolerance = 10; + const mapRotateTolerance = map.dragRotate._mouseRotate.getClickTolerance(); + const mapPitchTolerance = map.dragRotate._mousePitch.getClickTolerance(); + this.element = element; + this.mouseRotate = generateMouseRotationHandler({clickTolerance: mapRotateTolerance, enable: true}); + this.touchRotate = generateOneFingerTouchRotationHandler({clickTolerance: mapRotateTolerance, enable: true}); + this.map = map; + if (pitch) { + this.mousePitch = generateMousePitchHandler({clickTolerance: mapPitchTolerance, enable: true}); + this.touchPitch = generateOneFingerTouchPitchHandler({clickTolerance: mapPitchTolerance, enable: true}); + } + + DOM.addEventListener(element, 'mousedown', this.mousedown); + DOM.addEventListener(element, 'touchstart', this.touchstart, {passive: false}); + DOM.addEventListener(element, 'touchcancel', this.reset); + } + + startMouse(e: MouseEvent, point: Point) { + this.mouseRotate.dragStart(e, point); + if (this.mousePitch) this.mousePitch.dragStart(e, point); + DOM.disableDrag(); + } + + startTouch(e: TouchEvent, point: Point) { + this.touchRotate.dragStart(e, point); + if (this.touchPitch) this.touchPitch.dragStart(e, point); + DOM.disableDrag(); + } + + moveMouse(e: MouseEvent, point: Point) { + const map = this.map; + const {bearingDelta} = this.mouseRotate.dragMove(e, point) || {}; + if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta); + if (this.mousePitch) { + const {pitchDelta} = this.mousePitch.dragMove(e, point) || {}; + if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta); + } + } + + moveTouch(e: TouchEvent, point: Point) { + const map = this.map; + const {bearingDelta} = this.touchRotate.dragMove(e, point) || {}; + if (bearingDelta) map.setBearing(map.getBearing() + bearingDelta); + if (this.touchPitch) { + const {pitchDelta} = this.touchPitch.dragMove(e, point) || {}; + if (pitchDelta) map.setPitch(map.getPitch() + pitchDelta); + } + } + + off() { + const element = this.element; + DOM.removeEventListener(element, 'mousedown', this.mousedown); + DOM.removeEventListener(element, 'touchstart', this.touchstart, {passive: false}); + DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false}); + DOM.removeEventListener(window, 'touchend', this.touchend); + DOM.removeEventListener(element, 'touchcancel', this.reset); + this.offTemp(); + } + + offTemp() { + DOM.enableDrag(); + DOM.removeEventListener(window, 'mousemove', this.mousemove); + DOM.removeEventListener(window, 'mouseup', this.mouseup); + DOM.removeEventListener(window, 'touchmove', this.touchmove, {passive: false}); + DOM.removeEventListener(window, 'touchend', this.touchend); + } + + mousedown = (e: MouseEvent) => { + this.startMouse(extend({}, e, {ctrlKey: true, preventDefault: () => e.preventDefault()}), DOM.mousePos(this.element, e)); + DOM.addEventListener(window, 'mousemove', this.mousemove); + DOM.addEventListener(window, 'mouseup', this.mouseup); + }; + + mousemove = (e: MouseEvent) => { + this.moveMouse(e, DOM.mousePos(this.element, e)); + }; + + mouseup = (e: MouseEvent) => { + this.mouseRotate.dragEnd(e); + if (this.mousePitch) this.mousePitch.dragEnd(e); + this.offTemp(); + }; + + touchstart = (e: TouchEvent) => { + if (e.targetTouches.length !== 1) { + this.reset(); + } else { + this._startPos = this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0]; + this.startTouch(e, this._startPos); + DOM.addEventListener(window, 'touchmove', this.touchmove, {passive: false}); + DOM.addEventListener(window, 'touchend', this.touchend); + } + }; + + touchmove = (e: TouchEvent) => { + if (e.targetTouches.length !== 1) { + this.reset(); + } else { + this._lastPos = DOM.touchPos(this.element, e.targetTouches)[0]; + this.moveTouch(e, this._lastPos); + } + }; + + touchend = (e: TouchEvent) => { + if (e.targetTouches.length === 0 && + this._startPos && + this._lastPos && + this._startPos.dist(this._lastPos) < this._clickTolerance) { + this.element.click(); + } + delete this._startPos; + delete this._lastPos; + this.offTemp(); + }; + + reset = () => { + this.mouseRotate.reset(); + if (this.mousePitch) this.mousePitch.reset(); + this.touchRotate.reset(); + if (this.touchPitch) this.touchPitch.reset(); + delete this._startPos; + delete this._lastPos; + this.offTemp(); + }; +} diff --git a/web/libraries/maplibre-gl/src/ui/control/scale_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/scale_control.test.ts new file mode 100644 index 00000000..fbe68e32 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/scale_control.test.ts @@ -0,0 +1,52 @@ +import {createMap, beforeMapTest} from '../../util/test/util'; +import {ScaleControl} from './scale_control'; + +beforeEach(() => { + beforeMapTest(); +}); + +describe('ScaleControl', () => { + test('appears in bottom-left by default', () => { + const map = createMap(undefined, undefined); + map.addControl(new ScaleControl(undefined)); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale') + ).toHaveLength(1); + }); + + test('appears in the position specified by the position option', () => { + const map = createMap(undefined, undefined); + map.addControl(new ScaleControl(undefined), 'top-left'); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-top-left .maplibregl-ctrl-scale') + ).toHaveLength(1); + }); + + test('should change unit of distance after calling setUnit', () => { + const map = createMap(undefined, undefined); + const scale = new ScaleControl(undefined); + const selector = '.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale'; + map.addControl(scale); + + let contents = map.getContainer().querySelector(selector).innerHTML; + expect(contents).toMatch(/km/); + + scale.setUnit('imperial'); + contents = map.getContainer().querySelector(selector).innerHTML; + expect(contents).toMatch(/mi/); + }); + + test('should respect the maxWidth regardless of the unit and actual scale', () => { + const map = createMap(undefined, undefined); + const maxWidth = 100; + const scale = new ScaleControl({maxWidth, unit: 'nautical'}); + const selector = '.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale'; + map.addControl(scale); + map.setZoom(12.5); + + const el = map.getContainer().querySelector(selector) as HTMLElement; + expect(parseFloat(el.style.width) <= maxWidth).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/scale_control.ts b/web/libraries/maplibre-gl/src/ui/control/scale_control.ts new file mode 100644 index 00000000..1911f7e4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/scale_control.ts @@ -0,0 +1,150 @@ +import {DOM} from '../../util/dom'; +import {extend} from '../../util/util'; + +import type {Map} from '../map'; +import type {ControlPosition, IControl} from './control'; + +/** + * The unit type for length to use for the {@link ScaleControl} + */ +export type Unit = 'imperial' | 'metric' | 'nautical'; + +/** + * The {@link ScaleControl} options object + */ +type ScaleOptions = { + /** + * The maximum length of the scale control in pixels. + * @defaultValue 100 + */ + maxWidth?: number; + /** + * Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`). + * @defaultValue 'metric' + */ + unit?: Unit; +}; + +const defaultOptions: ScaleOptions = { + maxWidth: 100, + unit: 'metric' +}; + +/** + * A `ScaleControl` control displays the ratio of a distance on the map to the corresponding distance on the ground. + * + * @group Markers and Controls + * + * @example + * ```ts + * let scale = new maplibregl.ScaleControl({ + * maxWidth: 80, + * unit: 'imperial' + * }); + * map.addControl(scale); + * + * scale.setUnit('metric'); + * ``` + */ +export class ScaleControl implements IControl { + _map: Map; + _container: HTMLElement; + options: ScaleOptions; + + constructor(options: ScaleOptions) { + this.options = extend({}, defaultOptions, options); + } + + getDefaultPosition(): ControlPosition { + return 'bottom-left'; + } + + _onMove = () => { + updateScale(this._map, this._container, this.options); + }; + + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map) { + this._map = map; + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-scale', map.getContainer()); + + this._map.on('move', this._onMove); + this._onMove(); + + return this._container; + } + + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('move', this._onMove); + this._map = undefined; + } + + /** + * Set the scale's unit of the distance + * + * @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`). + */ + setUnit = (unit: Unit) => { + this.options.unit = unit; + updateScale(this._map, this._container, this.options); + }; +} + +function updateScale(map, container, options) { + // A horizontal scale is imagined to be present at center of the map + // container with maximum length (Default) as 100px. + // Using spherical law of cosines approximation, the real distance is + // found between the two coordinates. + const maxWidth = options && options.maxWidth || 100; + + const y = map._container.clientHeight / 2; + const left = map.unproject([0, y]); + const right = map.unproject([maxWidth, y]); + const maxMeters = left.distanceTo(right); + // The real distance corresponding to 100px scale length is rounded off to + // near pretty number and the scale length for the same is found out. + // Default unit of the scale is based on User's locale. + if (options && options.unit === 'imperial') { + const maxFeet = 3.2808 * maxMeters; + if (maxFeet > 5280) { + const maxMiles = maxFeet / 5280; + setScale(container, maxWidth, maxMiles, map._getUIString('ScaleControl.Miles')); + } else { + setScale(container, maxWidth, maxFeet, map._getUIString('ScaleControl.Feet')); + } + } else if (options && options.unit === 'nautical') { + const maxNauticals = maxMeters / 1852; + setScale(container, maxWidth, maxNauticals, map._getUIString('ScaleControl.NauticalMiles')); + } else if (maxMeters >= 1000) { + setScale(container, maxWidth, maxMeters / 1000, map._getUIString('ScaleControl.Kilometers')); + } else { + setScale(container, maxWidth, maxMeters, map._getUIString('ScaleControl.Meters')); + } +} + +function setScale(container, maxWidth, maxDistance, unit) { + const distance = getRoundNum(maxDistance); + const ratio = distance / maxDistance; + container.style.width = `${maxWidth * ratio}px`; + container.innerHTML = `${distance} ${unit}`; +} + +function getDecimalRoundNum(d) { + const multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10)); + return Math.round(d * multiplier) / multiplier; +} + +function getRoundNum(num) { + const pow10 = Math.pow(10, (`${Math.floor(num)}`).length - 1); + let d = num / pow10; + + d = d >= 10 ? 10 : + d >= 5 ? 5 : + d >= 3 ? 3 : + d >= 2 ? 2 : + d >= 1 ? 1 : getDecimalRoundNum(d); + + return pow10 * d; +} diff --git a/web/libraries/maplibre-gl/src/ui/control/terrain_control.test.ts b/web/libraries/maplibre-gl/src/ui/control/terrain_control.test.ts new file mode 100644 index 00000000..f7f93d95 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/terrain_control.test.ts @@ -0,0 +1,58 @@ +import {TerrainControl} from './terrain_control'; +import {createMap as globalCreateMap, beforeMapTest} from '../../util/test/util'; + +function createMap() { + + return globalCreateMap({ + attributionControl: false, + style: { + version: 8, + sources: { + terrain: { + minzoom: 5, + maxzoom: 12, + attribution: 'MapLibre', + tiles: ['http://example.com/{z}/{x}/{y}.pngraw'], + bounds: [-47, -7, -45, -5] + }, + }, + layers: [], + owner: 'mapblibre', + id: 'demotiles', + }, + hash: true + }, undefined); +} + +let map; + +beforeEach(() => { + beforeMapTest(); + map = createMap(); +}); + +afterEach(() => { + map.remove(); +}); + +describe('TerrainControl', () => { + test('appears in top-right by default', () => { + map.addControl(new TerrainControl({source: 'terrain'})); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-top-right .maplibregl-ctrl-terrain') + ).toHaveLength(1); + }); + + test('appears in the position specified by the position option', () => { + map.addControl(new TerrainControl({source: 'terrain'}), 'bottom-right'); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-bottom-right .maplibregl-ctrl-terrain') + ).toHaveLength(1); + + expect( + map.getContainer().querySelectorAll('.maplibregl-ctrl-top-right .maplibregl-ctrl-terrain') + ).toHaveLength(0); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/control/terrain_control.ts b/web/libraries/maplibre-gl/src/ui/control/terrain_control.ts new file mode 100644 index 00000000..8cc85385 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/control/terrain_control.ts @@ -0,0 +1,71 @@ +import {DOM} from '../../util/dom'; + +import type {Map} from '../map'; +import type {IControl} from './control'; +import type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * A `TerrainControl` control contains a button for turning the terrain on and off. + * + * @group Markers and Controls + * + * @example + * ```ts + * let map = new maplibregl.Map({TerrainControl: false}) + * .addControl(new maplibregl.TerrainControl({ + * source: "terrain" + * })); + * ``` + */ +export class TerrainControl implements IControl { + options: TerrainSpecification; + _map: Map; + _container: HTMLElement; + _terrainButton: HTMLButtonElement; + + constructor(options: TerrainSpecification) { + this.options = options; + } + + /** {@inheritDoc IControl.onAdd} */ + onAdd(map: Map) { + this._map = map; + this._container = DOM.create('div', 'maplibregl-ctrl maplibregl-ctrl-group'); + this._terrainButton = DOM.create('button', 'maplibregl-ctrl-terrain', this._container); + DOM.create('span', 'maplibregl-ctrl-icon', this._terrainButton).setAttribute('aria-hidden', 'true'); + this._terrainButton.type = 'button'; + this._terrainButton.addEventListener('click', this._toggleTerrain); + + this._updateTerrainIcon(); + this._map.on('terrain', this._updateTerrainIcon); + return this._container; + } + + /** {@inheritDoc IControl.onRemove} */ + onRemove() { + DOM.remove(this._container); + this._map.off('terrain', this._updateTerrainIcon); + this._map = undefined; + } + + _toggleTerrain = () => { + if (this._map.getTerrain()) { + this._map.setTerrain(null); + } else { + this._map.setTerrain(this.options); + } + this._updateTerrainIcon(); + }; + + _updateTerrainIcon = () => { + this._terrainButton.classList.remove('maplibregl-ctrl-terrain'); + this._terrainButton.classList.remove('maplibregl-ctrl-terrain-enabled'); + if (this._map.terrain) { + this._terrainButton.classList.add('maplibregl-ctrl-terrain-enabled'); + this._terrainButton.title = this._map._getUIString('TerrainControl.disableTerrain'); + } else { + this._terrainButton.classList.add('maplibregl-ctrl-terrain'); + this._terrainButton.title = this._map._getUIString('TerrainControl.enableTerrain'); + } + }; +} diff --git a/web/libraries/maplibre-gl/src/ui/default_locale.ts b/web/libraries/maplibre-gl/src/ui/default_locale.ts new file mode 100644 index 00000000..59e70365 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/default_locale.ts @@ -0,0 +1,19 @@ +export const defaultLocale = { + 'AttributionControl.ToggleAttribution': 'Toggle attribution', + 'AttributionControl.MapFeedback': 'Map feedback', + 'FullscreenControl.Enter': 'Enter fullscreen', + 'FullscreenControl.Exit': 'Exit fullscreen', + 'GeolocateControl.FindMyLocation': 'Find my location', + 'GeolocateControl.LocationNotAvailable': 'Location not available', + 'LogoControl.Title': 'Mapbox logo', + 'NavigationControl.ResetBearing': 'Reset bearing to north', + 'NavigationControl.ZoomIn': 'Zoom in', + 'NavigationControl.ZoomOut': 'Zoom out', + 'ScaleControl.Feet': 'ft', + 'ScaleControl.Meters': 'm', + 'ScaleControl.Kilometers': 'km', + 'ScaleControl.Miles': 'mi', + 'ScaleControl.NauticalMiles': 'nm', + 'TerrainControl.enableTerrain': 'Enable terrain', + 'TerrainControl.disableTerrain': 'Disable terrain' +}; diff --git a/web/libraries/maplibre-gl/src/ui/events.ts b/web/libraries/maplibre-gl/src/ui/events.ts new file mode 100644 index 00000000..8d2dd6fa --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/events.ts @@ -0,0 +1,748 @@ +import {Event} from '../util/evented'; + +import {DOM} from '../util/dom'; +import Point from '@mapbox/point-geometry'; +import {extend} from '../util/util'; +import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson'; + +import type {Map} from './map'; +import type {LngLat} from '../geo/lng_lat'; +import {SourceSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * An event from the mouse relevant to a specific layer. + * + * @group Event Related + */ +export type MapLayerMouseEvent = MapMouseEvent & { features?: MapGeoJSONFeature[] }; + +/** + * An event from a touch device relevat to a specific layer. + * + * @group Event Related + */ +export type MapLayerTouchEvent = MapTouchEvent & { features?: MapGeoJSONFeature[] }; + +/** + * The source event data type + */ +export type MapSourceDataType = 'content' | 'metadata' | 'visibility' | 'idle'; + +/** + * `MapLayerEventType` - a mapping between the event name and the event. + * **Note:** These events are compatible with the optional `layerId` parameter. + * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the + * event action contains a visible portion of the specified layer. + * The following example can be used for all the events. + * + * @group Event Related + * @example + * ```ts + * // Initialize the map + * let map = new maplibregl.Map({ // map options }); + * // Set an event listener for a specific layer + * map.on('the-event-name', 'poi-label', function(e) { + * console.log('An event has occurred on a visible portion of the poi-label layer'); + * }); + * ``` + */ +export type MapLayerEventType = { + /** + * Fired when a pointing device (usually a mouse) is pressed and released contains a visible portion of the specified layer. + * + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + click: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed and released twice contains a visible portion of the specified layer. + * + * **Note:** Under normal conditions, this event will be preceded by two `click` events. + */ + dblclick: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed while inside a visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mousedown: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is released while inside a visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mouseup: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved while the cursor is inside a visible portion of the specified layer. + * As you move the cursor across the layer, the event will fire every time the cursor changes position within that layer. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mousemove: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from + * outside that layer or outside the map canvas. + * + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + */ + mouseenter: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves + * the map canvas. + * + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + */ + mouseleave: MapLayerMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved inside a visible portion of the specified layer. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mouseover: MapLayerMouseEvent; + /** + * Fired when a point device (usually a mouse) leaves the visible portion of the specified layer. + */ + mouseout: MapLayerMouseEvent; + /** + * Fired when the right button of the mouse is clicked or the context menu key is pressed within visible portion of the specified layer. + */ + contextmenu: MapLayerMouseEvent; + /** + * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchstart: MapLayerTouchEvent; + /** + * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchend: MapLayerTouchEvent; + /** + * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchcancel: MapLayerTouchEvent; +}; + +/** + * `MapEventType` - a mapping between the event name and the event value. + * These events are used with the {@link Map#on} method. + * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}. + * The following example can be used for all the events. + * + * @group Event Related + * @example + * ```ts + * // Initialize the map + * let map = new maplibregl.Map({ // map options }); + * // Set an event listener + * map.on('the-event-name', () => { + * console.log('An event has occurred!'); + * }); + * ``` + */ +export type MapEventType = { + /** + * Fired when an error occurs. This is GL JS's primary error reporting + * mechanism. We use an event instead of `throw` to better accommodate + * asynchronous operations. If no listeners are bound to the `error` event, the + * error will be printed to the console. + */ + error: ErrorEvent; + /** + * @event `load` Fired immediately after all necessary resources have been downloaded + * and the first visually complete rendering of the map has occurred. + * + * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/) + * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/) + */ + load: MapLibreEvent; + /** + * Fired after the last frame rendered before the map enters an + * "idle" state: + * + * - No camera transitions are in progress + * - All currently requested tiles have loaded + * - All fade/transition animations have completed + */ + idle: MapLibreEvent; + /** + * Fired immediately after the map has been removed with {@link Map#remove}. + */ + remove: MapLibreEvent; + /** + * Fired whenever the map is drawn to the screen, as the result of + * + * - a change to the map's position, zoom, pitch, or bearing + * - a change to the map's style + * - a change to a GeoJSON source + * - the loading of a vector tile, GeoJSON file, glyph, or sprite + */ + render: MapLibreEvent; + /** + * Fired immediately after the map has been resized. + */ + resize: MapLibreEvent; + /** + * Fired when the WebGL context is lost. + */ + webglcontextlost: MapContextEvent; + /** + * Fired when the WebGL context is restored. + */ + webglcontextrestored: MapContextEvent; + /** + * Fired when any map data (style, source, tile, etc) begins loading or + * changing asynchronously. All `dataloading` events are followed by a `data`, + * `dataabort` or `error` event. + */ + dataloading: MapDataEvent; + /** + * Fired when any map data loads or changes. See {@link MapDataEvent} for more information. + * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/) + */ + data: MapDataEvent; + tiledataloading: MapDataEvent; + /** + * Fired when one of the map's sources begins loading or changing asynchronously. + * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event. + */ + sourcedataloading: MapSourceDataEvent; + /** + * Fired when the map's style begins loading or changing asynchronously. + * All `styledataloading` events are followed by a `styledata` + * or `error` event. + */ + styledataloading: MapStyleDataEvent; + /** + * Fired when one of the map's sources loads or changes, including if a tile belonging + * to a source loads or changes. + */ + sourcedata: MapSourceDataEvent; + /** + * Fired when the map's style loads or changes. + */ + styledata: MapStyleDataEvent; + /** + * Fired when an icon or pattern needed by the style is missing. The missing image can + * be added with {@link Map#addImage} within this event listener callback to prevent the image from + * being skipped. This event can be used to dynamically generate icons and patterns. + * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/) + */ + styleimagemissing: MapStyleImageMissingEvent; + /** + * Fired when a request for one of the map's sources' tiles or data is aborted. + */ + dataabort: MapDataEvent; + /** + * Fired when a request for one of the map's sources' data is aborted. + */ + sourcedataabort: MapSourceDataEvent; + /** + * Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold. + * See {@link BoxZoomHandler}. + */ + boxzoomcancel: MapLibreZoomEvent; + /** + * Fired when a "box zoom" interaction starts. See {@link BoxZoomHandler}. + */ + boxzoomstart: MapLibreZoomEvent; + /** + * Fired when a "box zoom" interaction ends. See {@link BoxZoomHandler}. + */ + boxzoomend: MapLibreZoomEvent; + /** + * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map. + */ + touchcancel: MapTouchEvent; + /** + * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchmove: MapTouchEvent; + /** + * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchend: MapTouchEvent; + /** + * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + touchstart: MapTouchEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map. + * + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + click: MapMouseEvent; + /** + * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map. + */ + contextmenu: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession. + * + * **Note:** Under normal conditions, this event will be preceded by two `click` events. + */ + dblclick: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map. + * As you move the cursor across the map, the event will fire every time the cursor changes position within the map. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mousemove: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is released within the map. + * + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mouseup: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is pressed within the map. + * + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + mousedown: MapMouseEvent; + /** + * Fired when a point device (usually a mouse) leaves the map's canvas. + */ + mouseout: MapMouseEvent; + /** + * Fired when a pointing device (usually a mouse) is moved within the map. + * As you move the cursor across a web page containing a map, + * the event will fire each time it enters the map or any child elements. + * + * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) + * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + */ + mouseover: MapMouseEvent; + /** + * Fired just before the map begins a transition from one + * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}. + * + */ + movestart: MapLibreEvent; + /** + * Fired repeatedly during an animated transition from one view to + * another, as the result of either user interaction or methods such as {@link Map#flyTo}. + * + * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/) + */ + move: MapLibreEvent; + /** + * Fired just after the map completes a transition from one + * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}. + * + * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/) + */ + moveend: MapLibreEvent; + /** + * Fired just before the map begins a transition from one zoom level to another, + * as the result of either user interaction or methods such as {@link Map#flyTo}. + */ + zoomstart: MapLibreEvent; + /** + * Fired repeatedly during an animated transition from one zoom level to another, + * as the result of either user interaction or methods such as {@link Map#flyTo}. + */ + zoom: MapLibreEvent; + /** + * Fired just after the map completes a transition from one zoom level to another, + * as the result of either user interaction or methods such as {@link Map#flyTo}. + */ + zoomend: MapLibreEvent; + /** + * Fired when a "drag to rotate" interaction starts. See {@link DragRotateHandler}. + */ + rotatestart: MapLibreEvent; + /** + * Fired repeatedly during a "drag to rotate" interaction. See {@link DragRotateHandler}. + */ + rotate: MapLibreEvent; + /** + * Fired when a "drag to rotate" interaction ends. See {@link DragRotateHandler}. + */ + rotateend: MapLibreEvent; + /** + * Fired when a "drag to pan" interaction starts. See {@link DragPanHandler}. + */ + dragstart: MapLibreEvent; + /** + * Fired repeatedly during a "drag to pan" interaction. See {@link DragPanHandler}. + */ + drag: MapLibreEvent; + /** + * Fired when a "drag to pan" interaction ends. See {@link DragPanHandler}. + * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + dragend: MapLibreEvent; + /** + * Fired whenever the map's pitch (tilt) begins a change as + * the result of either user interaction or methods such as {@link Map#flyTo} . + */ + pitchstart: MapLibreEvent; + /** + * Fired repeatedly during the map's pitch (tilt) animation between + * one state and another as the result of either user interaction + * or methods such as {@link Map#flyTo}. + */ + pitch: MapLibreEvent; + /** + * Fired immediately after the map's pitch (tilt) finishes changing as + * the result of either user interaction or methods such as {@link Map#flyTo}. + */ + pitchend: MapLibreEvent; + /** + * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map. + */ + wheel: MapWheelEvent; + /** + * Fired when terrain is changed + */ + terrain: MapTerrainEvent; +}; + +/** + * The base event for MapLibre + * + * @group Event Related + */ +export type MapLibreEvent = { + type: keyof MapEventType | keyof MapLayerEventType; + target: Map; + originalEvent: TOrig; +} + +/** + * The style data event + * + * @group Event Related + */ +export type MapStyleDataEvent = MapLibreEvent & { + dataType: 'style'; +} + +/** + * The source data event interface + * + * @group Event Related + */ +export type MapSourceDataEvent = MapLibreEvent & { + dataType: 'source'; + /** + * True if the event has a `dataType` of `source` and the source has no outstanding network requests. + */ + isSourceLoaded: boolean; + /** + * The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`. + */ + source: SourceSpecification; + sourceId: string; + sourceDataType: MapSourceDataType; + /** + * The tile being loaded or changed, if the event has a `dataType` of `source` and + * the event is related to loading of a tile. + */ + tile: any; +} +/** + * `MapMouseEvent` is the event type for mouse-related map events. + * @example + * ```ts + * // The `click` event is an example of a `MapMouseEvent`. + * // Set up an event listener on the map. + * map.on('click', function(e) { + * // The event object (e) contains information like the + * // coordinates of the point on the map that was clicked. + * console.log('A click event has occurred at ' + e.lngLat); + * }); + * ``` + */ +export class MapMouseEvent extends Event implements MapLibreEvent { + /** + * The event type + */ + type: 'mousedown' | 'mouseup' | 'click' | 'dblclick' | 'mousemove' | 'mouseover' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'contextmenu'; + + /** + * The `Map` object that fired the event. + */ + target: Map; + + /** + * The DOM event which caused the map event. + */ + originalEvent: MouseEvent; + + /** + * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner. + */ + point: Point; + + /** + * The geographic location on the map of the mouse cursor. + */ + lngLat: LngLat; + + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the following default map behaviors: + * + * * On `mousedown` events, the behavior of {@link DragPanHandler} + * * On `mousedown` events, the behavior of {@link DragRotateHandler} + * * On `mousedown` events, the behavior of {@link BoxZoomHandler} + * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler} + * + */ + preventDefault() { + this._defaultPrevented = true; + } + + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented(): boolean { + return this._defaultPrevented; + } + + _defaultPrevented: boolean; + + constructor(type: string, map: Map, originalEvent: MouseEvent, data: any = {}) { + const point = DOM.mousePos(map.getCanvasContainer(), originalEvent); + const lngLat = map.unproject(point); + super(type, extend({point, lngLat, originalEvent}, data)); + this._defaultPrevented = false; + this.target = map; + } +} + +/** + * `MapTouchEvent` is the event type for touch-related map events. + * + * @group Event Related + */ +export class MapTouchEvent extends Event implements MapLibreEvent { + /** + * The event type. + */ + type: 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel'; + + /** + * The `Map` object that fired the event. + */ + target: Map; + + /** + * The DOM event which caused the map event. + */ + originalEvent: TouchEvent; + + /** + * The geographic location on the map of the center of the touch event points. + */ + lngLat: LngLat; + + /** + * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left + * corner. + */ + point: Point; + + /** + * The array of pixel coordinates corresponding to a + * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property. + */ + points: Array; + + /** + * The geographical locations on the map corresponding to a + * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property. + */ + lngLats: Array; + + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the following default map behaviors: + * + * * On `touchstart` events, the behavior of {@link DragPanHandler} + * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler} + * + */ + preventDefault() { + this._defaultPrevented = true; + } + + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented(): boolean { + return this._defaultPrevented; + } + + _defaultPrevented: boolean; + + constructor(type: string, map: Map, originalEvent: TouchEvent) { + const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches; + const points = DOM.touchPos(map.getCanvasContainer(), touches); + const lngLats = points.map((t) => map.unproject(t)); + const point = points.reduce((prev, curr, i, arr) => { + return prev.add(curr.div(arr.length)); + }, new Point(0, 0)); + const lngLat = map.unproject(point); + super(type, {points, point, lngLats, lngLat, originalEvent}); + this._defaultPrevented = false; + } +} + +/** + * `MapWheelEvent` is the event type for the `wheel` map event. + * + * @group Event Related + */ +export class MapWheelEvent extends Event { + /** + * The event type. + */ + type: 'wheel'; + + /** + * The `Map` object that fired the event. + */ + target: Map; + + /** + * The DOM event which caused the map event. + */ + originalEvent: WheelEvent; + + /** + * Prevents subsequent default processing of the event by the map. + * + * Calling this method will prevent the behavior of {@link ScrollZoomHandler}. + */ + preventDefault() { + this._defaultPrevented = true; + } + + /** + * `true` if `preventDefault` has been called. + */ + get defaultPrevented(): boolean { + return this._defaultPrevented; + } + + _defaultPrevented: boolean; + + /** */ + constructor(type: string, map: Map, originalEvent: WheelEvent) { + super(type, {originalEvent}); + this._defaultPrevented = false; + } +} + +/** + * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}. + * + * @group Event Related + */ +export type MapLibreZoomEvent = { + /** + * The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel` + */ + type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel'; + /** + * The `Map` instance that triggered the event + */ + target: Map; + /** + * The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent` + */ + originalEvent: MouseEvent; +}; + +/** + * A `MapDataEvent` object is emitted with the `data` + * and `dataloading` events. Possible values for + * `dataType`s are: + * + * - `'source'`: The non-tile data associated with any source + * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map + * + * Possible values for `sourceDataType`s are: + * + * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles + * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource) + * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible') + * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading) + * + * @group Event Related + * + * @example + * ```ts + * // The sourcedata event is an example of MapDataEvent. + * // Set up an event listener on the map. + * map.on('sourcedata', function(e) { + * if (e.isSourceLoaded) { + * // Do something when the source has finished loading + * } + * }); + * ``` + */ +export type MapDataEvent = { + /** + * The event type. + */ + type: string; + /** + * The type of data that has changed. One of `'source'`, `'style'`. + */ + dataType: string; + /** + * Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`. + */ + sourceDataType: MapSourceDataType; +}; + +/** + * The terrain event + * + * @group Event Related + */ +export type MapTerrainEvent = { + type: 'terrain'; +}; + +/** + * An event related to the web gl context + * + * @group Event Related + */ +export type MapContextEvent = { + type: 'webglcontextlost' | 'webglcontextrestored'; + originalEvent: WebGLContextEvent; +}; + +/** + * The style image missing event + * + * @group Event Related + * + * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/) + */ +export type MapStyleImageMissingEvent = MapLibreEvent & { + type: 'styleimagemissing'; + id: string; +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/box_zoom.test.ts b/web/libraries/maplibre-gl/src/ui/handler/box_zoom.test.ts new file mode 100644 index 00000000..6e6145cb --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/box_zoom.test.ts @@ -0,0 +1,163 @@ +import {Map} from '../map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap(clickTolerance) { + return new Map({style: '', container: DOM.create('div', '', window.document.body), clickTolerance}); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('BoxZoomHandler', () => { + test('fires boxzoomstart and boxzoomend events at appropriate times', () => { + const map = createMap(undefined); + + const boxzoomstart = jest.fn(); + const boxzoomend = jest.fn(); + + map.on('boxzoomstart', boxzoomstart); + map.on('boxzoomend', boxzoomend); + + simulate.mousedown(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mousemove(map.getCanvas(), {shiftKey: true, clientX: 5, clientY: 5}); + map._renderTaskQueue.run(); + expect(boxzoomstart).toHaveBeenCalledTimes(1); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mouseup(map.getCanvas(), {shiftKey: true, clientX: 5, clientY: 5}); + map._renderTaskQueue.run(); + expect(boxzoomstart).toHaveBeenCalledTimes(1); + expect(boxzoomend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('avoids conflicts with DragPanHandler when disabled and reenabled (#2237)', () => { + const map = createMap(undefined); + + map.boxZoom.disable(); + map.boxZoom.enable(); + + const boxzoomstart = jest.fn(); + const boxzoomend = jest.fn(); + + map.on('boxzoomstart', boxzoomstart); + map.on('boxzoomend', boxzoomend); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mousemove(map.getCanvas(), {shiftKey: true, clientX: 5, clientY: 5}); + map._renderTaskQueue.run(); + expect(boxzoomstart).toHaveBeenCalledTimes(1); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mouseup(map.getCanvas(), {shiftKey: true, clientX: 5, clientY: 5}); + map._renderTaskQueue.run(); + expect(boxzoomstart).toHaveBeenCalledTimes(1); + expect(boxzoomend).toHaveBeenCalledTimes(1); + + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('does not begin a box zoom if preventDefault is called on the mousedown event', () => { + const map = createMap(undefined); + + map.on('mousedown', e => e.preventDefault()); + + const boxzoomstart = jest.fn(); + const boxzoomend = jest.fn(); + + map.on('boxzoomstart', boxzoomstart); + map.on('boxzoomend', boxzoomend); + + simulate.mousedown(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {shiftKey: true, clientX: 5, clientY: 5}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvas(), {shiftKey: true, clientX: 5, clientY: 5}); + map._renderTaskQueue.run(); + + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('does not begin a box zoom on spurious mousemove events', () => { + const map = createMap(undefined); + + const boxzoomstart = jest.fn(); + const boxzoomend = jest.fn(); + + map.on('boxzoomstart', boxzoomstart); + map.on('boxzoomend', boxzoomend); + + simulate.mousedown(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mousemove(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mouseup(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('does not begin a box zoom until mouse move is larger than click tolerance', () => { + const map = createMap(4); + + const boxzoomstart = jest.fn(); + const boxzoomend = jest.fn(); + + map.on('boxzoomstart', boxzoomstart); + map.on('boxzoomend', boxzoomend); + + simulate.mousedown(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mousemove(map.getCanvas(), {shiftKey: true, clientX: 3, clientY: 0}); + map._renderTaskQueue.run(); + expect(boxzoomstart).not.toHaveBeenCalled(); + expect(boxzoomend).not.toHaveBeenCalled(); + + simulate.mousemove(map.getCanvas(), {shiftKey: true, clientX: 0, clientY: 4}); + map._renderTaskQueue.run(); + expect(boxzoomstart).toHaveBeenCalledTimes(1); + expect(boxzoomend).not.toHaveBeenCalled(); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/box_zoom.ts b/web/libraries/maplibre-gl/src/ui/handler/box_zoom.ts new file mode 100644 index 00000000..a634dc76 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/box_zoom.ts @@ -0,0 +1,171 @@ +import {DOM} from '../../util/dom'; + +import {Event} from '../../util/evented'; +import {TransformProvider} from './transform-provider'; + +import type {Map} from '../map'; +import type Point from '@mapbox/point-geometry'; +import {Handler} from '../handler_manager'; + +/** + * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box. + * The bounding box is defined by clicking and holding `shift` while dragging the cursor. + * + * @group Handlers + */ +export class BoxZoomHandler implements Handler { + _map: Map; + _tr: TransformProvider; + _el: HTMLElement; + _container: HTMLElement; + _enabled: boolean; + _active: boolean; + _startPos: Point; + _lastPos: Point; + _box: HTMLElement; + _clickTolerance: number; + + /** @internal */ + constructor(map: Map, options: { + clickTolerance: number; + }) { + this._map = map; + this._tr = new TransformProvider(map); + this._el = map.getCanvasContainer(); + this._container = map.getContainer(); + this._clickTolerance = options.clickTolerance || 1; + } + + /** + * Returns a Boolean indicating whether the "box zoom" interaction is enabled. + * + * @returns `true` if the "box zoom" interaction is enabled. + */ + isEnabled() { + return !!this._enabled; + } + + /** + * Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used. + * + * @returns `true` if the "box zoom" interaction is active. + */ + isActive() { + return !!this._active; + } + + /** + * Enables the "box zoom" interaction. + * + * @example + * ```ts + * map.boxZoom.enable(); + * ``` + */ + enable() { + if (this.isEnabled()) return; + this._enabled = true; + } + + /** + * Disables the "box zoom" interaction. + * + * @example + * ```ts + * map.boxZoom.disable(); + * ``` + */ + disable() { + if (!this.isEnabled()) return; + this._enabled = false; + } + + mousedown(e: MouseEvent, point: Point) { + if (!this.isEnabled()) return; + if (!(e.shiftKey && e.button === 0)) return; + + DOM.disableDrag(); + this._startPos = this._lastPos = point; + this._active = true; + } + + mousemoveWindow(e: MouseEvent, point: Point) { + if (!this._active) return; + + const pos = point; + + if (this._lastPos.equals(pos) || (!this._box && pos.dist(this._startPos) < this._clickTolerance)) { + return; + } + + const p0 = this._startPos; + this._lastPos = pos; + + if (!this._box) { + this._box = DOM.create('div', 'maplibregl-boxzoom', this._container); + this._container.classList.add('maplibregl-crosshair'); + this._fireEvent('boxzoomstart', e); + } + + const minX = Math.min(p0.x, pos.x), + maxX = Math.max(p0.x, pos.x), + minY = Math.min(p0.y, pos.y), + maxY = Math.max(p0.y, pos.y); + + DOM.setTransform(this._box, `translate(${minX}px,${minY}px)`); + + this._box.style.width = `${maxX - minX}px`; + this._box.style.height = `${maxY - minY}px`; + } + + mouseupWindow(e: MouseEvent, point: Point) { + if (!this._active) return; + + if (e.button !== 0) return; + + const p0 = this._startPos, + p1 = point; + + this.reset(); + + DOM.suppressClick(); + + if (p0.x === p1.x && p0.y === p1.y) { + this._fireEvent('boxzoomcancel', e); + } else { + this._map.fire(new Event('boxzoomend', {originalEvent: e})); + return { + cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this._tr.bearing, {linear: true}) + }; + } + } + + keydown(e: KeyboardEvent) { + if (!this._active) return; + + if (e.keyCode === 27) { + this.reset(); + this._fireEvent('boxzoomcancel', e); + } + } + + reset() { + this._active = false; + + this._container.classList.remove('maplibregl-crosshair'); + + if (this._box) { + DOM.remove(this._box); + this._box = null; + } + + DOM.enableDrag(); + + delete this._startPos; + delete this._lastPos; + } + + _fireEvent(type: string, e: any) { + return this._map.fire(new Event(type, {originalEvent: e})); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/click_zoom.ts b/web/libraries/maplibre-gl/src/ui/handler/click_zoom.ts new file mode 100644 index 00000000..323ff3db --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/click_zoom.ts @@ -0,0 +1,55 @@ +import type Point from '@mapbox/point-geometry'; +import type {Map} from '../map'; +import {TransformProvider} from './transform-provider'; +import {Handler} from '../handler_manager'; + +/** + * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking + * It is used by other handlers + */ +export class ClickZoomHandler implements Handler { + + _tr: TransformProvider; + _enabled: boolean; + _active: boolean; + + /** @internal */ + constructor(map: Map) { + this._tr = new TransformProvider(map); + this.reset(); + } + + reset() { + this._active = false; + } + + dblclick(e: MouseEvent, point: Point) { + e.preventDefault(); + return { + cameraAnimation: (map: Map) => { + map.easeTo({ + duration: 300, + zoom: this._tr.zoom + (e.shiftKey ? -1 : 1), + around: this._tr.unproject(point) + }, {originalEvent: e}); + } + }; + } + + enable() { + this._enabled = true; + } + + disable() { + this._enabled = false; + this.reset(); + } + + isEnabled() { + return this._enabled; + } + + isActive() { + return this._active; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/cooperative_gestures.test.ts b/web/libraries/maplibre-gl/src/ui/handler/cooperative_gestures.test.ts new file mode 100644 index 00000000..dfac990a --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/cooperative_gestures.test.ts @@ -0,0 +1,255 @@ +import {browser} from '../../util/browser'; +import {Map} from '../map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap(cooperativeGestures) { + return new Map({ + container: DOM.create('div', '', window.document.body), + style: { + 'version': 8, + 'sources': {}, + 'layers': [] + }, + cooperativeGestures + }); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('CoopGesturesHandler', () => { + + test('Does not zoom on wheel if no key is down', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(true); + map._renderTaskQueue.run(); + + const startZoom = map.getZoom(); + // simulate a single 'wheel' event + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + const endZoom = map.getZoom(); + expect(endZoom).toBeCloseTo(startZoom); + + map.remove(); + }); + + test('Zooms on wheel if no key is down after disabling cooperative gestures', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(true); + map.setCooperativeGestures(false); + map._renderTaskQueue.run(); + + const startZoom = map.getZoom(); + // simulate a single 'wheel' event + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + const endZoom = map.getZoom(); + expect(endZoom - startZoom).toBeCloseTo(0.0285, 3); + + map.remove(); + }); + + test('Zooms on wheel if control key is down', () => { + // NOTE: This should pass regardless of whether cooperativeGestures is enabled or not + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(true); + map._renderTaskQueue.run(); + + const startZoom = map.getZoom(); + // simulate a single 'wheel' event + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta, ctrlKey: true}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + const endZoom = map.getZoom(); + expect(endZoom - startZoom).toBeCloseTo(0.0285, 3); + + map.remove(); + }); + + test('Does not pan on touchmove with a single touch', () => { + const map = createMap(true); + const target = map.getCanvas(); + const startCenter = map.getCenter(); + map._renderTaskQueue.run(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(target, {touches: [{target, clientX: 0, clientY: 0}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(target, {touches: [{target, clientX: 10, clientY: 10}]}); + map._renderTaskQueue.run(); + + simulate.touchend(target); + map._renderTaskQueue.run(); + + const endCenter = map.getCenter(); + expect(endCenter.lng).toEqual(startCenter.lng); + expect(endCenter.lat).toEqual(startCenter.lat); + + map.remove(); + }); + + test('Pans on touchmove with a single touch after disabling cooperative gestures', () => { + const map = createMap(true); + map.setCooperativeGestures(false); + const target = map.getCanvas(); + const startCenter = map.getCenter(); + map._renderTaskQueue.run(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(target, {touches: [{target, clientX: 0, clientY: 0}, {target, clientX: 1, clientY: 1}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(target, {touches: [{target, clientX: 10, clientY: 10}, {target, clientX: 11, clientY: 11}]}); + map._renderTaskQueue.run(); + + simulate.touchend(target); + map._renderTaskQueue.run(); + + const endCenter = map.getCenter(); + expect(endCenter.lng).toBeGreaterThan(startCenter.lng); + expect(endCenter.lat).toBeGreaterThan(startCenter.lat); + + map.remove(); + }); + + test('Does pan on touchmove with a double touch', () => { + // NOTE: This should pass regardless of whether cooperativeGestures is enabled or not + const map = createMap(true); + const target = map.getCanvas(); + const startCenter = map.getCenter(); + map._renderTaskQueue.run(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(target, {touches: [{target, clientX: 0, clientY: 0}, {target, clientX: 1, clientY: 1}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(target, {touches: [{target, clientX: 10, clientY: 10}, {target, clientX: 11, clientY: 11}]}); + map._renderTaskQueue.run(); + + simulate.touchend(target); + map._renderTaskQueue.run(); + + const endCenter = map.getCenter(); + expect(endCenter.lng).toBeGreaterThan(startCenter.lng); + expect(endCenter.lat).toBeGreaterThan(startCenter.lat); + + map.remove(); + }); + + test('Drag pitch works with 3 fingers', () => { + // NOTE: This should pass regardless of whether cooperativeGestures is enabled or not + const map = createMap(true); + const target = map.getCanvas(); + const startPitch = map.getPitch(); + map._renderTaskQueue.run(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(target, {touches: [{target, clientX: 0, clientY: 0}, {target, clientX: 1, clientY: 1}, {target, clientX: 2, clientY: 2}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(target, {touches: [{target, clientX: 0, clientY: -10}, {target, clientX: 1, clientY: -11}, {target, clientX: 2, clientY: -12}]}); + map._renderTaskQueue.run(); + + simulate.touchend(target); + map._renderTaskQueue.run(); + + const endPitch = map.getPitch(); + expect(endPitch).toBeGreaterThan(startPitch); + + map.remove(); + }); + + test('Initially disabled cooperative gestures can be later enabled', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(false); + map._renderTaskQueue.run(); + + const startZoom = map.getZoom(); + // simulate a single 'wheel' event + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + const midZoom = map.getZoom(); + expect(midZoom - startZoom).toBeCloseTo(0.0285, 3); + + // Enable cooperative gestures + map.setCooperativeGestures(true); + + // This 'wheel' event should not zoom + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + const endZoom = map.getZoom(); + expect(endZoom).toBeCloseTo(midZoom); + + map.remove(); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/dblclick_zoom.test.ts b/web/libraries/maplibre-gl/src/ui/handler/dblclick_zoom.test.ts new file mode 100644 index 00000000..33f762a7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/dblclick_zoom.test.ts @@ -0,0 +1,179 @@ +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; +import {Map, MapOptions} from '../map'; + +function createMap() { + return new Map({container: window.document.createElement('div')} as any as MapOptions); +} + +function simulateDoubleTap(map, delay = 100) { + const canvas = map.getCanvas(); + return new Promise(resolve => { + simulate.touchstart(canvas, {touches: [{target: canvas, clientX: 0, clientY: 0}]}); + simulate.touchend(canvas); + setTimeout(() => { + simulate.touchstart(canvas, {touches: [{target: canvas, clientX: 0, clientY: 0}]}); + simulate.touchend(canvas); + map._renderTaskQueue.run(); + resolve(undefined); + }, delay); + }); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('dbclick_zoom', () => { + test('DoubleClickZoomHandler zooms on dblclick event', () => { + const map = createMap(); + + const zoom = jest.fn(); + map.on('zoomstart', zoom); + + simulate.dblclick(map.getCanvas()); + map._renderTaskQueue.run(); + + expect(zoom).toHaveBeenCalled(); + + map.remove(); + }); + + test('DoubleClickZoomHandler does not zoom if preventDefault is called on the dblclick event', () => { + const map = createMap(); + + map.on('dblclick', e => e.preventDefault()); + + const zoom = jest.fn(); + map.on('zoomstart', zoom); + + simulate.dblclick(map.getCanvas()); + map._renderTaskQueue.run(); + + expect(zoom).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('DoubleClickZoomHandler zooms on double tap if touchstart events are < 300ms apart', done => { + const map = createMap(); + + const zoom = jest.fn(); + map.on('zoomstart', zoom); + + simulateDoubleTap(map, 100).then(() => { + expect(zoom).toHaveBeenCalled(); + + map.remove(); + done(); + }); + + }); + + test('DoubleClickZoomHandler does not zoom on double tap if touchstart events are > 500ms apart', done => { + const map = createMap(); + + const zoom = jest.fn(); + map.on('zoom', zoom); + + simulateDoubleTap(map, 500).then(() => { + expect(zoom).not.toHaveBeenCalled(); + + map.remove(); + done(); + }); + + }); + + test('DoubleClickZoomHandler does not zoom on double tap if touchstart events are in different locations', done => { + const map = createMap(); + + const zoom = jest.fn(); + map.on('zoom', zoom); + + const canvas = map.getCanvas(); + + const simulateTwoDifferentTaps = () => { + return new Promise(resolve => { + simulate.touchstart(canvas, {touches: [{clientX: 0, clientY: 0}]}); + simulate.touchend(canvas); + setTimeout(() => { + simulate.touchstart(canvas, {touches: [{clientX: 30.5, clientY: 30.5}]}); + simulate.touchend(canvas); + map._renderTaskQueue.run(); + resolve(undefined); + }, 100); + }); + }; + + simulateTwoDifferentTaps().then(() => { + expect(zoom).not.toHaveBeenCalled(); + + map.remove(); + done(); + }); + + }); + + test('DoubleClickZoomHandler zooms on the second touchend event of a double tap', () => { + const map = createMap(); + + const zoom = jest.fn(); + map.on('zoomstart', zoom); + + const canvas = map.getCanvas(); + const touchOptions = {touches: [{target: canvas, clientX: 0.5, clientY: 0.5}]}; + + simulate.touchstart(canvas, touchOptions); + simulate.touchend(canvas); + simulate.touchstart(canvas, touchOptions); + map._renderTaskQueue.run(); + map._renderTaskQueue.run(); + expect(zoom).not.toHaveBeenCalled(); + + simulate.touchcancel(canvas); + simulate.touchend(canvas); + map._renderTaskQueue.run(); + expect(zoom).not.toHaveBeenCalled(); + + simulate.touchstart(canvas, touchOptions); + simulate.touchend(canvas); + simulate.touchstart(canvas, touchOptions); + map._renderTaskQueue.run(); + expect(zoom).not.toHaveBeenCalled(); + + simulate.touchend(canvas); + map._renderTaskQueue.run(); + + expect(zoom).toHaveBeenCalled(); + + }); + + test('DoubleClickZoomHandler does not zoom on double tap if second touchend is >300ms after first touchstart', done => { + const map = createMap(); + + const zoom = jest.fn(); + map.on('zoom', zoom); + + const canvas = map.getCanvas(); + + const simulateSlowSecondTap = () => { + return new Promise(resolve => { + simulate.touchstart(canvas); + simulate.touchend(canvas); + simulate.touchstart(canvas); + setTimeout(() => { + simulate.touchend(canvas); + map._renderTaskQueue.run(); + resolve(undefined); + }, 300); + }); + }; + + simulateSlowSecondTap().then(() => { + expect(zoom).not.toHaveBeenCalled(); + + done(); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/drag_handler.ts b/web/libraries/maplibre-gl/src/ui/handler/drag_handler.ts new file mode 100644 index 00000000..7f08be11 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/drag_handler.ts @@ -0,0 +1,174 @@ +import {DOM} from '../../util/dom'; +import type Point from '@mapbox/point-geometry'; +import {DragMoveStateManager} from './drag_move_state_manager'; +import {Handler} from '../handler_manager'; + +interface DragMovementResult { + bearingDelta?: number; + pitchDelta?: number; + around?: Point; + panDelta?: Point; +} + +export interface DragPanResult extends DragMovementResult { + around: Point; + panDelta: Point; +} + +export interface DragRotateResult extends DragMovementResult { + bearingDelta: number; +} + +export interface DragPitchResult extends DragMovementResult { + pitchDelta: number; +} + +type DragMoveFunction = (lastPoint: Point, point: Point) => T; + +export interface DragMoveHandler extends Handler { + dragStart: (e: E, point: Point) => void; + dragMove: (e: E, point: Point) => T | void; + dragEnd: (e: E) => void; + getClickTolerance: () => number; +} + +export type DragMoveHandlerOptions = { + /** + * If the movement is shorter than this value, consider it a click. + */ + clickTolerance: number; + /** + * The move function to run on a valid movement. + */ + move: DragMoveFunction; + /** + * A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details. + */ + moveStateManager: DragMoveStateManager; + /** + * A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler + * @param handler - the handler + */ + assignEvents: (handler: DragMoveHandler) => void; + /** + * Should the move start on the "start" event, or should it start on the first valid move. + */ + activateOnStart?: boolean; + /** + * If true, handler will be enabled during construction + */ + enable?: boolean; +} + +/** + * A generic class to create handlers for drag events, from both mouse and touch events. + */ +export class DragHandler implements DragMoveHandler { + // Event handlers that may be assigned by the implementations of this class + contextmenu?: Handler['contextmenu']; + mousedown?: Handler['mousedown']; + mousemoveWindow?: Handler['mousemoveWindow']; + mouseup?: Handler['mouseup']; + touchstart?: Handler['touchstart']; + touchmoveWindow?: Handler['touchmoveWindow']; + touchend?: Handler['touchend']; + + _clickTolerance: number; + _moveFunction: DragMoveFunction; + _activateOnStart: boolean; + _active: boolean; + _enabled: boolean; + _moved: boolean; + _lastPoint: Point | null; + _moveStateManager: DragMoveStateManager; + + constructor(options: DragMoveHandlerOptions) { + this._enabled = !!options.enable; + this._moveStateManager = options.moveStateManager; + this._clickTolerance = options.clickTolerance || 1; + this._moveFunction = options.move; + this._activateOnStart = !!options.activateOnStart; + + options.assignEvents(this); + + this.reset(); + } + + reset(e?: E) { + this._active = false; + this._moved = false; + delete this._lastPoint; + this._moveStateManager.endMove(e); + } + + _move(...params: Parameters>) { + const move = this._moveFunction(...params); + if (move.bearingDelta || move.pitchDelta || move.around || move.panDelta) { + this._active = true; + return move; + } + } + + dragStart(e: E, point: Point); + dragStart(e: E, point: Point[]); + dragStart(e: E, point: Point | Point[]) { + if (!this.isEnabled() || this._lastPoint) return; + + if (!this._moveStateManager.isValidStartEvent(e)) return; + this._moveStateManager.startMove(e); + + this._lastPoint = point['length'] ? point[0] : point; + + if (this._activateOnStart && this._lastPoint) this._active = true; + } + + dragMove(e: E, point: Point); + dragMove(e: E, point: Point[]); + dragMove(e: E, point: Point | Point[]) { + if (!this.isEnabled()) return; + const lastPoint = this._lastPoint; + if (!lastPoint) return; + e.preventDefault(); + + if (!this._moveStateManager.isValidMoveEvent(e)) { + this.reset(e); + return; + } + + const movePoint = point['length'] ? point[0] : point; + + if (!this._moved && movePoint.dist(lastPoint) < this._clickTolerance) return; + this._moved = true; + this._lastPoint = movePoint; + + return this._move(lastPoint, movePoint); + } + + dragEnd(e: E) { + if (!this.isEnabled() || !this._lastPoint) return; + if (!this._moveStateManager.isValidEndEvent(e)) return; + if (this._moved) DOM.suppressClick(); + this.reset(e); + } + + enable() { + this._enabled = true; + } + + disable() { + this._enabled = false; + this.reset(); + } + + isEnabled() { + return this._enabled; + } + + isActive() { + return this._active; + } + + getClickTolerance() { + return this._clickTolerance; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/drag_move_state_manager.ts b/web/libraries/maplibre-gl/src/ui/handler/drag_move_state_manager.ts new file mode 100644 index 00000000..d973186d --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/drag_move_state_manager.ts @@ -0,0 +1,115 @@ +import {DOM} from '../../util/dom'; + +const LEFT_BUTTON = 0; +const RIGHT_BUTTON = 2; + +// the values for each button in MouseEvent.buttons +const BUTTONS_FLAGS = { + [LEFT_BUTTON]: 1, + [RIGHT_BUTTON]: 2 +}; + +function buttonNoLongerPressed(e: MouseEvent, button: number) { + const flag = BUTTONS_FLAGS[button]; + return e.buttons === undefined || (e.buttons & flag) !== flag; +} + +/* + * Drag events are initiated by specific interaction which needs to be tracked until it ends. + * This requires some state management: + * 1. registering the initiating event, + * 2. tracking that it was not canceled / not confusing it with another event firing. + * 3. recognizing the ending event and cleaning up any internal state + * + * Concretely, we implement two state managers: + * 1. MouseMoveStateManager + * Receives a functions that is used to recognize mouse events that should be registered as the + * relevant drag interactions - i.e. dragging with the right mouse button, or while CTRL is pressed. + * 2. OneFingerTouchMoveStateManager + * Checks if a drag event is using one finger, and continuously tracking that this is the same event + * (i.e. to make sure not additional finger has started interacting with the screen before raising + * the first finger). + */ +export interface DragMoveStateManager { + startMove: (e: E) => void; + endMove: (e?: E) => void; + isValidStartEvent: (e: E) => boolean; + isValidMoveEvent: (e: E) => boolean; + isValidEndEvent: (e?: E) => boolean; +} + +export class MouseMoveStateManager implements DragMoveStateManager { + _eventButton: number | undefined; + _correctEvent: (e: MouseEvent) => boolean; + + constructor(options: { + checkCorrectEvent: (e: MouseEvent) => boolean; + }) { + this._correctEvent = options.checkCorrectEvent; + } + + startMove(e: MouseEvent) { + const eventButton = DOM.mouseButton(e); + this._eventButton = eventButton; + } + + endMove(_e?: MouseEvent) { + delete this._eventButton; + } + + isValidStartEvent(e: MouseEvent) { + return this._correctEvent(e); + } + + isValidMoveEvent(e: MouseEvent) { + // Some browsers don't fire a `mouseup` when the mouseup occurs outside + // the window or iframe: + // https://github.com/mapbox/mapbox-gl-js/issues/4622 + // + // If the button is no longer pressed during this `mousemove` it may have + // been released outside of the window or iframe. + return !buttonNoLongerPressed(e, this._eventButton); + } + + isValidEndEvent(e: MouseEvent) { + const eventButton = DOM.mouseButton(e); + return eventButton === this._eventButton; + } +} + +export class OneFingerTouchMoveStateManager implements DragMoveStateManager { + _firstTouch: number | undefined; + + constructor() { + this._firstTouch = undefined; + } + + _isOneFingerTouch(e: TouchEvent) { + return e.targetTouches.length === 1; + } + + _isSameTouchEvent(e: TouchEvent) { + return e.targetTouches[0].identifier === this._firstTouch; + } + + startMove(e: TouchEvent) { + const firstTouch = e.targetTouches[0].identifier; + this._firstTouch = firstTouch; + } + + endMove(_e?: TouchEvent) { + delete this._firstTouch; + } + + isValidStartEvent(e: TouchEvent) { + return this._isOneFingerTouch(e); + } + + isValidMoveEvent(e: TouchEvent) { + return this._isOneFingerTouch(e) && this._isSameTouchEvent(e); + } + + isValidEndEvent(e: TouchEvent) { + return this._isOneFingerTouch(e) && this._isSameTouchEvent(e); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/drag_pan.test.ts b/web/libraries/maplibre-gl/src/ui/handler/drag_pan.test.ts new file mode 100644 index 00000000..dee3c37e --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/drag_pan.test.ts @@ -0,0 +1,487 @@ +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; +import {Map, MapOptions} from '../map'; +import type {MapGeoJSONFeature} from '../../util/vectortile_to_geojson'; + +function createMap(clickTolerance?, dragPan?) { + return new Map({ + container: DOM.create('div', '', window.document.body), + clickTolerance: clickTolerance || 0, + dragPan: dragPan || true, + } as any as MapOptions); +} + +beforeEach(() => { + beforeMapTest(); +}); + +// MouseEvent.buttons = 1 // left button +const buttons = 1; + +describe('drag_pan', () => { + + test('DragPanHandler fires dragstart, drag, and dragend events at appropriate times in response to a mouse-triggered drag', () => { + const map = createMap(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler captures mousemove events during a mouse-triggered drag (receives them even if they occur outside the map)', () => { + const map = createMap(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(window.document.body, {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler fires dragstart, drag, and dragend events at appropriate times in response to a touch-triggered drag', () => { + const map = createMap(); + const target = map.getCanvas(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}]}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 10, clientY: 10}]}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler prevents mousemove events from firing during a drag (#1555)', () => { + const map = createMap(); + + const mousemove = jest.fn(); + map.on('mousemove', mousemove); + + simulate.mousedown(map.getCanvasContainer()); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvasContainer(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvasContainer()); + map._renderTaskQueue.run(); + + expect(mousemove).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('DragPanHandler ends a mouse-triggered drag if the window blurs', () => { + const map = createMap(); + + const dragend = jest.fn(); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.blur(window); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler ends a touch-triggered drag if the window blurs', () => { + const map = createMap(); + const target = map.getCanvas(); + + const dragend = jest.fn(); + map.on('dragend', dragend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 10, clientY: 10}]}); + map._renderTaskQueue.run(); + + simulate.blur(window); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler requests a new render frame after each mousemove event', () => { + const map = createMap(); + const requestFrame = jest.spyOn(map.handlers, '_requestFrame'); + + simulate.mousedown(map.getCanvas()); + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + expect(requestFrame).toHaveBeenCalled(); + + map._renderTaskQueue.run(); + + // https://github.com/mapbox/mapbox-gl-js/issues/6063 + requestFrame.mockReset(); + simulate.mousemove(map.getCanvas(), {buttons, clientX: 20, clientY: 20}); + expect(requestFrame).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler can interleave with another handler', () => { + // https://github.com/mapbox/mapbox-gl-js/issues/6106 + const map = createMap(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + // simulate a scroll zoom + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 20, clientY: 20}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + ['ctrl', 'shift'].forEach((modifier) => { + test(`DragPanHandler does not begin a drag if the ${modifier} key is down on mousedown`, () => { + const map = createMap(); + expect(map.dragRotate.isEnabled()).toBeTruthy(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas(), {buttons, [`${modifier}Key`]: true}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, [`${modifier}Key`]: true, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {[`${modifier}Key`]: true}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test(`DragPanHandler still ends a drag if the ${modifier} key is down on mouseup`, () => { + const map = createMap(); + expect(map.dragRotate.isEnabled()).toBeTruthy(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {[`${modifier}Key`]: true}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + }); + + test('DragPanHandler does not begin a drag on right button mousedown', () => { + const map = createMap(); + map.dragRotate.disable(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragPanHandler does not end a drag on right button mouseup', () => { + const map = createMap(); + map.dragRotate.disable(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousedown(map.getCanvas(), {buttons: buttons + 2, button: 2}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons, button: 2}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 20, clientY: 20}); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragPanHandler does not begin a drag if preventDefault is called on the mousedown event', () => { + const map = createMap(); + + map.on('mousedown', e => e.preventDefault()); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragPanHandler does not begin a drag if preventDefault is called on the touchstart event', () => { + const map = createMap(); + const target = map.getCanvas(); + + map.on('touchstart', e => e.preventDefault()); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 10, clientY: 10}]}); + map._renderTaskQueue.run(); + + simulate.touchend(map.getCanvas()); + map._renderTaskQueue.run(); + + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragPanHandler does not begin a drag if preventDefault is called on the touchstart event (delegated)', () => { + const map = createMap(); + const target = map.getCanvas(); + + jest.spyOn(map, 'getLayer').mockReturnValue(true as any); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + map.on('touchstart', 'point', (e) => { + e.preventDefault(); + }); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + map.on('dragstart', dragstart); + map.on('drag', drag); + map.on('dragend', dragend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 10, clientY: 10}]}); + map._renderTaskQueue.run(); + + simulate.touchend(map.getCanvas()); + map._renderTaskQueue.run(); + + expect(dragstart).toHaveBeenCalledTimes(0); + expect(drag).toHaveBeenCalledTimes(0); + expect(dragend).toHaveBeenCalledTimes(0); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/drag_rotate.test.ts b/web/libraries/maplibre-gl/src/ui/handler/drag_rotate.test.ts new file mode 100644 index 00000000..6155d249 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/drag_rotate.test.ts @@ -0,0 +1,859 @@ +import {extend} from '../../util/util'; +import {Map} from '../map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {browser} from '../../util/browser'; + +import {beforeMapTest} from '../../util/test/util'; + +function createMap(options?) { + return new Map(extend({container: DOM.create('div', '', window.document.body)}, options)); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('drag rotate', () => { + + test('DragRotateHandler#isActive', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + expect(map.dragRotate.isActive()).toBe(false); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + expect(map.dragRotate.isActive()).toBe(false); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(map.dragRotate.isActive()).toBe(true); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(map.dragRotate.isActive()).toBe(false); + + map.remove(); + }); + + test('DragRotateHandler fires rotatestart, rotate, and rotateend events at appropriate times in response to a right-click drag', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler stops firing events after mouseup', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const spy = jest.fn(); + map.on('rotatestart', spy); + map.on('rotate', spy); + map.on('rotateend', spy); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(spy).toHaveBeenCalledTimes(3); + + spy.mockReset(); + simulate.mousemove(map.getCanvas(), {buttons: 0, clientX: 20, clientY: 20}); + map._renderTaskQueue.run(); + expect(spy).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragRotateHandler fires rotatestart, rotate, and rotateend events at appropriate times in response to a control-left-click drag', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 1, button: 0, ctrlKey: true}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 1, ctrlKey: true, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 0, ctrlKey: true}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler pitches in response to a right-click drag by default', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const pitchstart = jest.fn(); + const pitch = jest.fn(); + const pitchend = jest.fn(); + + map.on('pitchstart', pitchstart); + map.on('pitch', pitch); + map.on('pitchend', pitchend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: -10}); + map._renderTaskQueue.run(); + expect(pitchstart).toHaveBeenCalledTimes(1); + expect(pitch).toHaveBeenCalledTimes(1); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(pitchend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler doesn\'t fire pitch event when rotating only', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const pitchstart = jest.fn(); + const pitch = jest.fn(); + const pitchend = jest.fn(); + + map.on('pitchstart', pitchstart); + map.on('pitch', pitch); + map.on('pitchend', pitchend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2, clientX: 0, clientY: 10}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(pitchstart).toHaveBeenCalledTimes(0); + expect(pitch).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + expect(pitchend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragRotateHandler pitches in response to a control-left-click drag', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const pitchstart = jest.fn(); + const pitch = jest.fn(); + const pitchend = jest.fn(); + + map.on('pitchstart', pitchstart); + map.on('pitch', pitch); + map.on('pitchend', pitchend); + + simulate.mousedown(map.getCanvas(), {buttons: 1, button: 0, ctrlKey: true}); + simulate.mousemove(map.getCanvas(), {buttons: 1, ctrlKey: true, clientX: 10, clientY: -10}); + map._renderTaskQueue.run(); + expect(pitchstart).toHaveBeenCalledTimes(1); + expect(pitch).toHaveBeenCalledTimes(1); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 0, ctrlKey: true}); + map._renderTaskQueue.run(); + expect(pitchend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler does not pitch if given pitchWithRotate: false', () => { + const map = createMap({pitchWithRotate: false}); + + const spy = jest.fn(); + + map.on('pitchstart', spy); + map.on('pitch', spy); + map.on('pitchend', spy); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + + simulate.mousedown(map.getCanvas(), {buttons: 1, button: 0, ctrlKey: true}); + simulate.mousemove(map.getCanvas(), {buttons: 1, ctrlKey: true, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 0, ctrlKey: true}); + + expect(spy).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('DragRotateHandler does not rotate or pitch when disabled', () => { + const map = createMap(); + + map.dragRotate.disable(); + + const spy = jest.fn(); + + map.on('rotatestart', spy); + map.on('rotate', spy); + map.on('rotateend', spy); + map.on('pitchstart', spy); + map.on('pitch', spy); + map.on('pitchend', spy); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + + expect(spy).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('DragRotateHandler ensures that map.isMoving() returns true during drag', () => { + // The bearingSnap option here ensures that the moveend event is sent synchronously. + const map = createMap({bearingSnap: 0}); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(map.isMoving()).toBeTruthy(); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(!map.isMoving()).toBeTruthy(); + + map.remove(); + }); + + test('DragRotateHandler fires move events', () => { + // The bearingSnap option here ensures that the moveend event is sent synchronously. + const map = createMap({bearingSnap: 0}); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const movestart = jest.fn(); + const move = jest.fn(); + const moveend = jest.fn(); + + map.on('movestart', movestart); + map.on('move', move); + map.on('moveend', moveend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(movestart).toHaveBeenCalledTimes(1); + expect(move).toHaveBeenCalledTimes(1); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(moveend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler doesn\'t fire rotate event when pitching only', () => { + // The bearingSnap option here ensures that the moveend event is sent synchronously. + const map = createMap({bearingSnap: 0}); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const pitch = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('pitch', pitch); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2, clientX: 0, clientY: 0}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 0, clientY: -10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(pitch).toHaveBeenCalledTimes(1); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + expect(rotateend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragRotateHandler includes originalEvent property in triggered events', () => { + // The bearingSnap option here ensures that the moveend event is sent synchronously. + const map = createMap({bearingSnap: 0}); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + const pitchstart = jest.fn(); + const pitch = jest.fn(); + const pitchend = jest.fn(); + map.on('pitchstart', pitchstart); + map.on('pitch', pitch); + map.on('pitchend', pitchend); + + const movestart = jest.fn(); + const move = jest.fn(); + const moveend = jest.fn(); + map.on('movestart', movestart); + map.on('move', move); + map.on('moveend', moveend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: -10}); + map._renderTaskQueue.run(); + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + + expect(rotatestart.mock.calls[0][0].originalEvent.type).toBeTruthy(); + expect(pitchstart.mock.calls[0][0].originalEvent.type).toBeTruthy(); + expect(movestart.mock.calls[0][0].originalEvent.type).toBeTruthy(); + + expect(rotate.mock.calls[0][0].originalEvent.type).toBeTruthy(); + expect(pitch.mock.calls[0][0].originalEvent.type).toBeTruthy(); + expect(move.mock.calls[0][0].originalEvent.type).toBeTruthy(); + + expect(rotateend.mock.calls[0][0].originalEvent.type).toBeTruthy(); + expect(pitchend.mock.calls[0][0].originalEvent.type).toBeTruthy(); + expect(moveend.mock.calls[0][0].originalEvent.type).toBeTruthy(); + + map.remove(); + }); + + test('DragRotateHandler responds to events on the canvas container (#1301)', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvasContainer(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvasContainer(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + + simulate.mouseup(map.getCanvasContainer(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler prevents mousemove events from firing during a drag (#1555)', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const mousemove = jest.fn(); + map.on('mousemove', mousemove); + + simulate.mousedown(map.getCanvasContainer(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvasContainer(), {buttons: 2, clientX: 100, clientY: 100}); + map._renderTaskQueue.run(); + simulate.mouseup(map.getCanvasContainer(), {buttons: 0, button: 2}); + + expect(mousemove).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('DragRotateHandler ends a control-left-click drag on mouseup even when the control key was previously released (#1888)', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 1, button: 0, ctrlKey: true}); + simulate.mousemove(map.getCanvas(), {buttons: 1, ctrlKey: true, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 0, ctrlKey: false}); + map._renderTaskQueue.run(); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler ends rotation if the window blurs (#3389)', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + + simulate.blur(window); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler requests a new render frame after each mousemove event', () => { + const map = createMap(); + const requestRenderFrame = jest.spyOn(map.handlers, '_requestFrame'); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + expect(requestRenderFrame).toHaveBeenCalled(); + + map._renderTaskQueue.run(); + + // https://github.com/mapbox/mapbox-gl-js/issues/6063 + requestRenderFrame.mockReset(); + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 20, clientY: 20}); + expect(requestRenderFrame).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler can interleave with another handler', () => { + // https://github.com/mapbox/mapbox-gl-js/issues/6106 + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + // simulates another handler taking over + // simulate a scroll zoom + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 20, clientY: 20}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + // Ignore second rotatestart triggered by inertia + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler does not begin a drag on left-button mousedown without the control key', () => { + const map = createMap(); + map.dragPan.disable(); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragRotateHandler does not end a right-button drag on left-button mouseup', () => { + const map = createMap(); + map.dragPan.disable(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousedown(map.getCanvas(), {buttons: 3, button: 0}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 2, button: 0}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 20, clientY: 20}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + // Ignore second rotatestart triggered by inertia + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler does not end a control-left-button drag on right-button mouseup', () => { + const map = createMap(); + map.dragPan.disable(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 1, button: 0, ctrlKey: true}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 1, ctrlKey: true, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousedown(map.getCanvas(), {buttons: 3, button: 2, ctrlKey: true}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 1, button: 2, ctrlKey: true}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 1, ctrlKey: true, clientX: 20, clientY: 20}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 0, ctrlKey: true}); + map._renderTaskQueue.run(); + // Ignore second rotatestart triggered by inertia + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('DragRotateHandler does not begin a drag if preventDefault is called on the mousedown event', () => { + const map = createMap(); + + map.on('mousedown', e => e.preventDefault()); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragRotateHandler can be disabled after mousedown (#2419)', () => { + const map = createMap(); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + + map.dragRotate.disable(); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + expect(map.isMoving()).toBe(false); + expect(map.dragRotate.isEnabled()).toBe(false); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + expect(map.isMoving()).toBe(false); + expect(map.dragRotate.isEnabled()).toBe(false); + + map.remove(); + }); + + test('DragRotateHandler does not begin rotation on spurious mousemove events', () => { + const map = createMap(); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('DragRotateHandler does not begin a mouse drag if moved less than click tolerance', () => { + const map = createMap({clickTolerance: 4}); + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + const pitchstart = jest.fn(); + const pitch = jest.fn(); + const pitchend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + map.on('pitchstart', pitchstart); + map.on('pitch', pitch); + map.on('pitchend', pitchend); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + expect(pitchstart).toHaveBeenCalledTimes(0); + expect(pitch).toHaveBeenCalledTimes(0); + expect(pitchend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 13, clientY: 10}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + expect(pitchstart).toHaveBeenCalledTimes(0); + expect(pitch).toHaveBeenCalledTimes(0); + expect(pitchend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 13}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + expect(pitchstart).toHaveBeenCalledTimes(0); + expect(pitch).toHaveBeenCalledTimes(0); + expect(pitchend).toHaveBeenCalledTimes(0); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 14, clientY: 10 - 4}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + expect(pitchstart).toHaveBeenCalledTimes(1); + expect(pitch).toHaveBeenCalledTimes(1); + expect(pitchend).toHaveBeenCalledTimes(0); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/handler_util.ts b/web/libraries/maplibre-gl/src/ui/handler/handler_util.ts new file mode 100644 index 00000000..b097fad1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/handler_util.ts @@ -0,0 +1,10 @@ +import Point from '@mapbox/point-geometry'; + +export function indexTouches(touches: Array, points: Array) { + if (touches.length !== points.length) throw new Error(`The number of touches and points are not equal - touches ${touches.length}, points ${points.length}`); + const obj = {}; + for (let i = 0; i < touches.length; i++) { + obj[touches[i].identifier] = points[i]; + } + return obj; +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/keyboard.test.ts b/web/libraries/maplibre-gl/src/ui/handler/keyboard.test.ts new file mode 100644 index 00000000..98f271ff --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/keyboard.test.ts @@ -0,0 +1,235 @@ +import {Map} from '../../ui/map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {extend} from '../../util/util'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap(options?) { + return new Map(extend({ + container: DOM.create('div', '', window.document.body), + }, options)); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('keyboard', () => { + test('KeyboardHandler responds to keydown events', () => { + const map = createMap(); + const h = map.keyboard; + const spy = jest.spyOn(h, 'keydown'); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(h.keydown).toHaveBeenCalled(); + expect(spy.mock.calls[0][0].keyCode).toBe(32); + }); + + test('KeyboardHandler pans map in response to arrow keys', () => { + const map = createMap({zoom: 10, center: [0, 0]}); + const spy = jest.spyOn(map, 'easeTo'); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(map.easeTo).not.toHaveBeenCalled(); + + simulate.keydown(map.getCanvas(), {keyCode: 37, key: 'ArrowLeft'}); + expect(map.easeTo).toHaveBeenCalled(); + let easeToArgs = spy.mock.calls[0][0]; + expect(easeToArgs.offset[0]).toBe(100); + expect(easeToArgs.offset[1]).toBe(-0); + + simulate.keydown(map.getCanvas(), {keyCode: 39, key: 'ArrowRight'}); + expect(spy).toHaveBeenCalledTimes(2); + easeToArgs = spy.mock.calls[1][0]; + expect(easeToArgs.offset[0]).toBe(-100); + expect(easeToArgs.offset[1]).toBe(-0); + + simulate.keydown(map.getCanvas(), {keyCode: 40, key: 'ArrowDown'}); + expect(spy).toHaveBeenCalledTimes(3); + easeToArgs = spy.mock.calls[2][0]; + expect(easeToArgs.offset[0]).toBe(-0); + expect(easeToArgs.offset[1]).toBe(-100); + + simulate.keydown(map.getCanvas(), {keyCode: 38, key: 'ArrowUp'}); + expect(spy).toHaveBeenCalledTimes(4); + easeToArgs = spy.mock.calls[3][0]; + expect(easeToArgs.offset[0]).toBe(-0); + expect(easeToArgs.offset[1]).toBe(100); + + }); + + test('KeyboardHandler pans map in response to arrow keys when disableRotation has been called', () => { + const map = createMap({zoom: 10, center: [0, 0]}); + const spy = jest.spyOn(map, 'easeTo'); + map.keyboard.disableRotation(); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(map.easeTo).not.toHaveBeenCalled(); + + simulate.keydown(map.getCanvas(), {keyCode: 37, key: 'ArrowLeft'}); + expect(map.easeTo).toHaveBeenCalled(); + let easeToArgs = spy.mock.calls[0][0]; + expect(easeToArgs.offset[0]).toBe(100); + expect(easeToArgs.offset[1]).toBe(-0); + + simulate.keydown(map.getCanvas(), {keyCode: 39, key: 'ArrowRight'}); + expect(spy).toHaveBeenCalledTimes(2); + easeToArgs = spy.mock.calls[1][0]; + expect(easeToArgs.offset[0]).toBe(-100); + expect(easeToArgs.offset[1]).toBe(-0); + + simulate.keydown(map.getCanvas(), {keyCode: 40, key: 'ArrowDown'}); + expect(spy).toHaveBeenCalledTimes(3); + easeToArgs = spy.mock.calls[2][0]; + expect(easeToArgs.offset[0]).toBe(-0); + expect(easeToArgs.offset[1]).toBe(-100); + + simulate.keydown(map.getCanvas(), {keyCode: 38, key: 'ArrowUp'}); + expect(spy).toHaveBeenCalledTimes(4); + easeToArgs = spy.mock.calls[3][0]; + expect(easeToArgs.offset[0]).toBe(-0); + expect(easeToArgs.offset[1]).toBe(100); + + }); + + test('KeyboardHandler rotates map in response to Shift+left/right arrow keys', async () => { + const map = createMap({zoom: 10, center: [0, 0], bearing: 0}); + const spy = jest.spyOn(map, 'easeTo'); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(map.easeTo).not.toHaveBeenCalled(); + + simulate.keydown(map.getCanvas(), {keyCode: 37, key: 'ArrowLeft', shiftKey: true}); + expect(map.easeTo).toHaveBeenCalled(); + let easeToArgs = spy.mock.calls[0][0]; + expect(easeToArgs.bearing).toBe(-15); + expect(easeToArgs.offset[0]).toBe(-0); + + map.setBearing(0); + simulate.keydown(map.getCanvas(), {keyCode: 39, key: 'ArrowRight', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(2); + easeToArgs = spy.mock.calls[1][0]; + expect(easeToArgs.bearing).toBe(15); + expect(easeToArgs.offset[0]).toBe(-0); + + }); + + test('KeyboardHandler does not rotate map in response to Shift+left/right arrow keys when disableRotation has been called', async () => { + const map = createMap({zoom: 10, center: [0, 0], bearing: 0}); + const spy = jest.spyOn(map, 'easeTo'); + map.keyboard.disableRotation(); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(map.easeTo).not.toHaveBeenCalled(); + + simulate.keydown(map.getCanvas(), {keyCode: 37, key: 'ArrowLeft', shiftKey: true}); + expect(map.easeTo).toHaveBeenCalled(); + let easeToArgs = spy.mock.calls[0][0]; + expect(easeToArgs.bearing).toBe(0); + expect(easeToArgs.offset[0]).toBe(-0); + + map.setBearing(0); + simulate.keydown(map.getCanvas(), {keyCode: 39, key: 'ArrowRight', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(2); + easeToArgs = spy.mock.calls[1][0]; + expect(easeToArgs.bearing).toBe(0); + expect(easeToArgs.offset[0]).toBe(-0); + + }); + + test('KeyboardHandler pitches map in response to Shift+up/down arrow keys', async () => { + const map = createMap({zoom: 10, center: [0, 0], pitch: 30}); + const spy = jest.spyOn(map, 'easeTo'); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(map.easeTo).not.toHaveBeenCalled(); + + simulate.keydown(map.getCanvas(), {keyCode: 40, key: 'ArrowDown', shiftKey: true}); + expect(map.easeTo).toHaveBeenCalled(); + let easeToArgs = spy.mock.calls[0][0]; + expect(easeToArgs.pitch).toBe(20); + expect(easeToArgs.offset[1]).toBe(-0); + + map.setPitch(30); + simulate.keydown(map.getCanvas(), {keyCode: 38, key: 'ArrowUp', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(2); + easeToArgs = spy.mock.calls[1][0]; + expect(easeToArgs.pitch).toBe(40); + expect(easeToArgs.offset[1]).toBe(-0); + + }); + + test('KeyboardHandler does not pitch map in response to Shift+up/down arrow keys when disableRotation has been called', async () => { + const map = createMap({zoom: 10, center: [0, 0], pitch: 30}); + const spy = jest.spyOn(map, 'easeTo'); + map.keyboard.disableRotation(); + + simulate.keydown(map.getCanvas(), {keyCode: 32, key: ' '}); + expect(map.easeTo).not.toHaveBeenCalled(); + + simulate.keydown(map.getCanvas(), {keyCode: 40, key: 'ArrowDown', shiftKey: true}); + expect(map.easeTo).toHaveBeenCalled(); + let easeToArgs = spy.mock.calls[0][0]; + expect(easeToArgs.pitch).toBe(30); + expect(easeToArgs.offset[1]).toBe(-0); + + map.setPitch(30); + simulate.keydown(map.getCanvas(), {keyCode: 38, key: 'ArrowUp', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(2); + easeToArgs = spy.mock.calls[1][0]; + expect(easeToArgs.pitch).toBe(30); + expect(easeToArgs.offset[1]).toBe(-0); + + }); + + test('KeyboardHandler zooms map in response to -/+ keys', () => { + const map = createMap({zoom: 10, center: [0, 0]}); + const spy = jest.spyOn(map, 'easeTo'); + + simulate.keydown(map.getCanvas(), {keyCode: 187, key: 'Equal'}); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0].zoom).toBe(11); + + map.setZoom(10); + simulate.keydown(map.getCanvas(), {keyCode: 187, key: 'Equal', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(2); + expect(spy.mock.calls[1][0].zoom).toBe(12); + + map.setZoom(10); + simulate.keydown(map.getCanvas(), {keyCode: 189, key: 'Minus'}); + expect(spy).toHaveBeenCalledTimes(3); + expect(spy.mock.calls[2][0].zoom).toBe(9); + + map.setZoom(10); + simulate.keydown(map.getCanvas(), {keyCode: 189, key: 'Minus', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(4); + expect(spy.mock.calls[3][0].zoom).toBe(8); + + }); + + test('KeyboardHandler zooms map in response to -/+ keys when disableRotation has been called', () => { + const map = createMap({zoom: 10, center: [0, 0]}); + const spy = jest.spyOn(map, 'easeTo'); + map.keyboard.disableRotation(); + + simulate.keydown(map.getCanvas(), {keyCode: 187, key: 'Equal'}); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy.mock.calls[0][0].zoom).toBe(11); + + map.setZoom(10); + simulate.keydown(map.getCanvas(), {keyCode: 187, key: 'Equal', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(2); + expect(spy.mock.calls[1][0].zoom).toBe(12); + + map.setZoom(10); + simulate.keydown(map.getCanvas(), {keyCode: 189, key: 'Minus'}); + expect(spy).toHaveBeenCalledTimes(3); + expect(spy.mock.calls[2][0].zoom).toBe(9); + + map.setZoom(10); + simulate.keydown(map.getCanvas(), {keyCode: 189, key: 'Minus', shiftKey: true}); + expect(spy).toHaveBeenCalledTimes(4); + expect(spy.mock.calls[3][0].zoom).toBe(8); + + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/keyboard.ts b/web/libraries/maplibre-gl/src/ui/handler/keyboard.ts new file mode 100644 index 00000000..ffdf349f --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/keyboard.ts @@ -0,0 +1,212 @@ +import {Handler} from '../handler_manager'; +import type {Map} from '../map'; +import {TransformProvider} from './transform-provider'; + +const defaultOptions = { + panStep: 100, + bearingStep: 15, + pitchStep: 10 +}; + +/** + * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using + * the following keyboard shortcuts: + * + * - `=` / `+`: Increase the zoom level by 1. + * - `Shift-=` / `Shift-+`: Increase the zoom level by 2. + * - `-`: Decrease the zoom level by 1. + * - `Shift--`: Decrease the zoom level by 2. + * - Arrow keys: Pan by 100 pixels. + * - `Shift+⇢`: Increase the rotation by 15 degrees. + * - `Shift+⇠`: Decrease the rotation by 15 degrees. + * - `Shift+⇡`: Increase the pitch by 10 degrees. + * - `Shift+⇣`: Decrease the pitch by 10 degrees. + * + * @group Handlers + */ +export class KeyboardHandler implements Handler { + _tr: TransformProvider; + _enabled: boolean; + _active: boolean; + _panStep: number; + _bearingStep: number; + _pitchStep: number; + _rotationDisabled: boolean; + + /** @internal */ + constructor(map: Map) { + this._tr = new TransformProvider(map); + const stepOptions = defaultOptions; + this._panStep = stepOptions.panStep; + this._bearingStep = stepOptions.bearingStep; + this._pitchStep = stepOptions.pitchStep; + this._rotationDisabled = false; + } + + reset() { + this._active = false; + } + + keydown(e: KeyboardEvent) { + if (e.altKey || e.ctrlKey || e.metaKey) return; + + let zoomDir = 0; + let bearingDir = 0; + let pitchDir = 0; + let xDir = 0; + let yDir = 0; + + switch (e.keyCode) { + case 61: + case 107: + case 171: + case 187: + zoomDir = 1; + break; + + case 189: + case 109: + case 173: + zoomDir = -1; + break; + + case 37: + if (e.shiftKey) { + bearingDir = -1; + } else { + e.preventDefault(); + xDir = -1; + } + break; + + case 39: + if (e.shiftKey) { + bearingDir = 1; + } else { + e.preventDefault(); + xDir = 1; + } + break; + + case 38: + if (e.shiftKey) { + pitchDir = 1; + } else { + e.preventDefault(); + yDir = -1; + } + break; + + case 40: + if (e.shiftKey) { + pitchDir = -1; + } else { + e.preventDefault(); + yDir = 1; + } + break; + + default: + return; + } + + if (this._rotationDisabled) { + bearingDir = 0; + pitchDir = 0; + } + + return { + cameraAnimation: (map: Map) => { + const tr = this._tr; + map.easeTo({ + duration: 300, + easeId: 'keyboardHandler', + easing: easeOut, + + zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom, + bearing: tr.bearing + bearingDir * this._bearingStep, + pitch: tr.pitch + pitchDir * this._pitchStep, + offset: [-xDir * this._panStep, -yDir * this._panStep], + center: tr.center + }, {originalEvent: e}); + } + }; + } + + /** + * Enables the "keyboard rotate and zoom" interaction. + * + * @example + * ```ts + * map.keyboard.enable(); + * ``` + */ + enable() { + this._enabled = true; + } + + /** + * Disables the "keyboard rotate and zoom" interaction. + * + * @example + * ```ts + * map.keyboard.disable(); + * ``` + */ + disable() { + this._enabled = false; + this.reset(); + } + + /** + * Returns a Boolean indicating whether the "keyboard rotate and zoom" + * interaction is enabled. + * + * @returns `true` if the "keyboard rotate and zoom" + * interaction is enabled. + */ + isEnabled() { + return this._enabled; + } + + /** + * Returns true if the handler is enabled and has detected the start of a + * zoom/rotate gesture. + * + * @returns `true` if the handler is enabled and has detected the + * start of a zoom/rotate gesture. + */ + isActive() { + return this._active; + } + + /** + * Disables the "keyboard pan/rotate" interaction, leaving the + * "keyboard zoom" interaction enabled. + * + * @example + * ```ts + * map.keyboard.disableRotation(); + * ``` + */ + disableRotation() { + this._rotationDisabled = true; + } + + /** + * Enables the "keyboard pan/rotate" interaction. + * + * @example + * ```ts + * map.keyboard.enable(); + * map.keyboard.enableRotation(); + * ``` + */ + enableRotation() { + this._rotationDisabled = false; + } +} + +function easeOut(t: number) { + return t * (2 - t); +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/map_event.test.ts b/web/libraries/maplibre-gl/src/ui/handler/map_event.test.ts new file mode 100644 index 00000000..9e16255f --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/map_event.test.ts @@ -0,0 +1,158 @@ +import {Map, MapOptions} from '../map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap() { + return new Map({interactive: true, container: DOM.create('div', '', window.document.body)} as any as MapOptions); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('map events', () => { + test('MapEvent handler fires touch events with correct values', () => { + const map = createMap(); + const target = map.getCanvas(); + + const touchstart = jest.fn(); + const touchmove = jest.fn(); + const touchend = jest.fn(); + + map.on('touchstart', touchstart); + map.on('touchmove', touchmove); + map.on('touchend', touchend); + + const touchesStart = [{target, identifier: 1, clientX: 0, clientY: 50}]; + const touchesMove = [{target, identifier: 1, clientX: 0, clientY: 60}]; + const touchesEnd = [{target, identifier: 1, clientX: 0, clientY: 60}]; + + simulate.touchstart(map.getCanvas(), {touches: touchesStart, targetTouches: touchesStart}); + expect(touchstart).toHaveBeenCalledTimes(1); + expect(touchstart.mock.calls[0][0].point).toEqual({x: 0, y: 50}); + expect(touchmove).toHaveBeenCalledTimes(0); + expect(touchend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: touchesMove, targetTouches: touchesMove}); + expect(touchstart).toHaveBeenCalledTimes(1); + expect(touchmove).toHaveBeenCalledTimes(1); + expect(touchmove.mock.calls[0][0].point).toEqual({x: 0, y: 60}); + expect(touchend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: [], targetTouches: [], changedTouches: touchesEnd}); + expect(touchstart).toHaveBeenCalledTimes(1); + expect(touchmove).toHaveBeenCalledTimes(1); + expect(touchend).toHaveBeenCalledTimes(1); + expect(touchend.mock.calls[0][0].point).toEqual({x: 0, y: 60}); + + map.remove(); + }); + + test('MapEvent handler fires touchmove even while drag handler is active', () => { + const map = createMap(); + const target = map.getCanvas(); + map.dragPan.enable(); + + const touchstart = jest.fn(); + const touchmove = jest.fn(); + const touchend = jest.fn(); + const drag = jest.fn(); + + map.on('touchstart', touchstart); + map.on('touchmove', touchmove); + map.on('touchend', touchend); + map.on('drag', drag); + + const touchesStart = [{target, identifier: 1, clientX: 0, clientY: 50}]; + const touchesMove = [{target, identifier: 1, clientX: 0, clientY: 60}]; + const touchesEnd = [{target, identifier: 1, clientX: 0, clientY: 60}]; + + simulate.touchstart(map.getCanvas(), {touches: touchesStart, targetTouches: touchesStart}); + expect(touchstart).toHaveBeenCalledTimes(1); + expect(touchstart.mock.calls[0][0].point).toEqual({x: 0, y: 50}); + expect(touchmove).toHaveBeenCalledTimes(0); + expect(touchend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: touchesMove, targetTouches: touchesMove}); + expect(touchstart).toHaveBeenCalledTimes(1); + expect(touchmove).toHaveBeenCalledTimes(1); + expect(touchmove.mock.calls[0][0].point).toEqual({x: 0, y: 60}); + expect(touchend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: [], targetTouches: [], changedTouches: touchesEnd}); + expect(touchstart).toHaveBeenCalledTimes(1); + expect(touchmove).toHaveBeenCalledTimes(1); + expect(touchend).toHaveBeenCalledTimes(1); + expect(touchend.mock.calls[0][0].point).toEqual({x: 0, y: 60}); + + map._renderTaskQueue.run(); + expect(drag).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('MapEvent handler fires contextmenu on MacOS/Linux, but only at mouseup', () => { + const map = createMap(); + const target = map.getCanvas(); + map.dragPan.enable(); + + const contextmenu = jest.fn(); + + map.on('contextmenu', contextmenu); + + simulate.mousedown(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); + simulate.contextmenu(map.getCanvas(), {target}); // triggered immediately after mousedown + expect(contextmenu).toHaveBeenCalledTimes(0); + simulate.mouseup(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); + expect(contextmenu).toHaveBeenCalledTimes(1); + }); + + test('MapEvent handler does not fire contextmenu on MacOS/Linux, when moved', () => { + const map = createMap(); + const target = map.getCanvas(); + map.dragPan.enable(); + + const contextmenu = jest.fn(); + + map.on('contextmenu', contextmenu); + + simulate.mousedown(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); + simulate.contextmenu(map.getCanvas(), {target}); // triggered immediately after mousedown + simulate.mousemove(map.getCanvas(), {target, buttons: 2, clientX: 50, clientY: 10}); + simulate.mouseup(map.getCanvas(), {target, button: 2, clientX: 70, clientY: 10}); + expect(contextmenu).toHaveBeenCalledTimes(0); + }); + + test('MapEvent handler fires contextmenu on Windows', () => { + const map = createMap(); + const target = map.getCanvas(); + map.dragPan.enable(); + + const contextmenu = jest.fn(); + + map.on('contextmenu', contextmenu); + + simulate.mousedown(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); + simulate.mouseup(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); + expect(contextmenu).toHaveBeenCalledTimes(0); + simulate.contextmenu(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); // triggered only after mouseup + expect(contextmenu).toHaveBeenCalledTimes(1); + }); + + test('MapEvent handler does not fire contextmenu on Windows, when moved', () => { + const map = createMap(); + const target = map.getCanvas(); + map.dragPan.enable(); + + const contextmenu = jest.fn(); + + map.on('contextmenu', contextmenu); + + simulate.mousedown(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); + simulate.mousemove(map.getCanvas(), {target, buttons: 2, clientX: 50, clientY: 10}); + simulate.mouseup(map.getCanvas(), {target, button: 2, clientX: 50, clientY: 10}); + simulate.contextmenu(map.getCanvas(), {target, button: 2, clientX: 10, clientY: 10}); // triggered only after mouseup + expect(contextmenu).toHaveBeenCalledTimes(0); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/map_event.ts b/web/libraries/maplibre-gl/src/ui/handler/map_event.ts new file mode 100644 index 00000000..24b9af24 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/map_event.ts @@ -0,0 +1,161 @@ +import {MapMouseEvent, MapTouchEvent, MapWheelEvent} from '../events'; +import {Handler} from '../handler_manager'; +import type {Map} from '../map'; +import type Point from '@mapbox/point-geometry'; + +export class MapEventHandler implements Handler { + + _mousedownPos: Point; + _clickTolerance: number; + _map: Map; + + constructor(map: Map, options: { + clickTolerance: number; + }) { + this._map = map; + this._clickTolerance = options.clickTolerance; + } + + reset() { + delete this._mousedownPos; + } + + wheel(e: WheelEvent) { + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - ScrollZoom + return this._firePreventable(new MapWheelEvent(e.type, this._map, e)); + } + + mousedown(e: MouseEvent, point: Point) { + this._mousedownPos = point; + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - MousePan + // - MouseRotate + // - MousePitch + // - DblclickHandler + return this._firePreventable(new MapMouseEvent(e.type, this._map, e)); + } + + mouseup(e: MouseEvent) { + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + + click(e: MouseEvent, point: Point) { + if (this._mousedownPos && this._mousedownPos.dist(point) >= this._clickTolerance) return; + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + + dblclick(e: MouseEvent) { + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - DblClickZoom + return this._firePreventable(new MapMouseEvent(e.type, this._map, e)); + } + + mouseover(e: MouseEvent) { + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + + mouseout(e: MouseEvent) { + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + + touchstart(e: TouchEvent) { + // If mapEvent.preventDefault() is called by the user, prevent handlers such as: + // - TouchPan + // - TouchZoom + // - TouchRotate + // - TouchPitch + // - TapZoom + // - SwipeZoom + return this._firePreventable(new MapTouchEvent(e.type, this._map, e)); + } + + touchmove(e: TouchEvent) { + this._map.fire(new MapTouchEvent(e.type, this._map, e)); + } + + touchend(e: TouchEvent) { + this._map.fire(new MapTouchEvent(e.type, this._map, e)); + } + + touchcancel(e: TouchEvent) { + this._map.fire(new MapTouchEvent(e.type, this._map, e)); + } + + _firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent) { + this._map.fire(mapEvent); + if (mapEvent.defaultPrevented) { + // returning an object marks the handler as active and resets other handlers + return {}; + } + } + + isEnabled() { + return true; + } + + isActive() { + return false; + } + enable() {} + disable() {} +} + +export class BlockableMapEventHandler { + _map: Map; + _delayContextMenu: boolean; + _ignoreContextMenu: boolean; + _contextMenuEvent: MouseEvent; + + constructor(map: Map) { + this._map = map; + } + + reset() { + this._delayContextMenu = false; + this._ignoreContextMenu = true; + delete this._contextMenuEvent; + } + + mousemove(e: MouseEvent) { + // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + + mousedown() { + this._delayContextMenu = true; + this._ignoreContextMenu = false; + } + + mouseup() { + this._delayContextMenu = false; + if (this._contextMenuEvent) { + this._map.fire(new MapMouseEvent('contextmenu', this._map, this._contextMenuEvent)); + delete this._contextMenuEvent; + } + } + contextmenu(e: MouseEvent) { + if (this._delayContextMenu) { + // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake + this._contextMenuEvent = e; + } else if (!this._ignoreContextMenu) { + // Windows: contextmenu fired on mouseup, so fire event now + this._map.fire(new MapMouseEvent(e.type, this._map, e)); + } + + // prevent browser context menu when necessary + if (this._map.listens('contextmenu')) { + e.preventDefault(); + } + } + + isEnabled() { + return true; + } + + isActive() { + return false; + } + enable() {} + disable() {} +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/mouse.ts b/web/libraries/maplibre-gl/src/ui/handler/mouse.ts new file mode 100644 index 00000000..595b46bf --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/mouse.ts @@ -0,0 +1,83 @@ +import type Point from '@mapbox/point-geometry'; + +import {DOM} from '../../util/dom'; +import {DragMoveHandler, DragPanResult, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler'; +import {MouseMoveStateManager} from './drag_move_state_manager'; + +export interface MousePanHandler extends DragMoveHandler {} +export interface MouseRotateHandler extends DragMoveHandler {} +export interface MousePitchHandler extends DragMoveHandler {} + +const LEFT_BUTTON = 0; +const RIGHT_BUTTON = 2; + +const assignEvents = (handler: DragHandler) => { + handler.mousedown = handler.dragStart; + handler.mousemoveWindow = handler.dragMove; + handler.mouseup = handler.dragEnd; + handler.contextmenu = function(e: MouseEvent) { + e.preventDefault(); + }; +}; + +export const generateMousePanHandler = ({enable, clickTolerance,}: { + clickTolerance: number; + enable?: boolean; +}): MousePanHandler => { + const mouseMoveStateManager = new MouseMoveStateManager({ + checkCorrectEvent: (e: MouseEvent) => DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey, + }); + return new DragHandler({ + clickTolerance, + move: (lastPoint: Point, point: Point) => + ({around: point, panDelta: point.sub(lastPoint)}), + activateOnStart: true, + moveStateManager: mouseMoveStateManager, + enable, + assignEvents, + }); +}; + +export const generateMouseRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: { + clickTolerance: number; + bearingDegreesPerPixelMoved?: number; + enable?: boolean; +}): MouseRotateHandler => { + const mouseMoveStateManager = new MouseMoveStateManager({ + checkCorrectEvent: (e: MouseEvent): boolean => + (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) || + (DOM.mouseButton(e) === RIGHT_BUTTON), + }); + return new DragHandler({ + clickTolerance, + move: (lastPoint: Point, point: Point) => + ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}), + // prevent browser context menu when necessary; we don't allow it with rotation + // because we can't discern rotation gesture start from contextmenu on Mac + moveStateManager: mouseMoveStateManager, + enable, + assignEvents, + }); +}; + +export const generateMousePitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: { + clickTolerance: number; + pitchDegreesPerPixelMoved?: number; + enable?: boolean; +}): MousePitchHandler => { + const mouseMoveStateManager = new MouseMoveStateManager({ + checkCorrectEvent: (e: MouseEvent): boolean => + (DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey) || + (DOM.mouseButton(e) === RIGHT_BUTTON), + }); + return new DragHandler({ + clickTolerance, + move: (lastPoint: Point, point: Point) => + ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}), + // prevent browser context menu when necessary; we don't allow it with rotation + // because we can't discern rotation gesture start from contextmenu on Mac + moveStateManager: mouseMoveStateManager, + enable, + assignEvents, + }); +}; diff --git a/web/libraries/maplibre-gl/src/ui/handler/mouse_handler_interface.test.ts b/web/libraries/maplibre-gl/src/ui/handler/mouse_handler_interface.test.ts new file mode 100644 index 00000000..6220cb6b --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/mouse_handler_interface.test.ts @@ -0,0 +1,111 @@ +import Point from '@mapbox/point-geometry'; + +import {generateMousePanHandler, generateMousePitchHandler, generateMouseRotationHandler} from './mouse'; + +describe('mouse handler tests', () => { + test('MouseRotateHandler', () => { + const mouseRotate = generateMouseRotationHandler({clickTolerance: 2}); + + expect(mouseRotate.isActive()).toBe(false); + expect(mouseRotate.isEnabled()).toBe(false); + mouseRotate.enable(); + expect(mouseRotate.isEnabled()).toBe(true); + + mouseRotate.dragStart(new MouseEvent('mousedown', {buttons: 2, button: 2}), new Point(0, 0)); + expect(mouseRotate.isActive()).toBe(false); + + const underToleranceMove = new MouseEvent('mousemove', {buttons: 2, clientX: 1, clientY: 1}); + expect(mouseRotate.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(mouseRotate.isActive()).toBe(false); + + const overToleranceMove = new MouseEvent('mousemove', {buttons: 2, clientX: 10, clientY: 10}); + expect(mouseRotate.dragMove(overToleranceMove, new Point(10, 10))).toEqual({'bearingDelta': 8}); + expect(mouseRotate.isActive()).toBe(true); + + mouseRotate.dragEnd(new MouseEvent('mouseup', {buttons: 0, button: 2})); + expect(mouseRotate.isActive()).toBe(false); + + mouseRotate.disable(); + expect(mouseRotate.isEnabled()).toBe(false); + + mouseRotate.dragStart(new MouseEvent('mousedown', {buttons: 2, button: 2}), new Point(0, 0)); + expect(mouseRotate.isActive()).toBe(false); + + expect(mouseRotate.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(mouseRotate.isActive()).toBe(false); + + expect(mouseRotate.dragMove(overToleranceMove, new Point(10, 10))).toBeUndefined(); + expect(mouseRotate.isActive()).toBe(false); + }); + + test('MousePitchHandler', () => { + const mousePitch = generateMousePitchHandler({clickTolerance: 2}); + + expect(mousePitch.isActive()).toBe(false); + expect(mousePitch.isEnabled()).toBe(false); + mousePitch.enable(); + expect(mousePitch.isEnabled()).toBe(true); + + mousePitch.dragStart(new MouseEvent('mousedown', {buttons: 2, button: 2}), new Point(0, 0)); + expect(mousePitch.isActive()).toBe(false); + + const underToleranceMove = new MouseEvent('mousemove', {buttons: 2, clientX: 1, clientY: 1}); + expect(mousePitch.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(mousePitch.isActive()).toBe(false); + + const overToleranceMove = new MouseEvent('mousemove', {buttons: 2, clientX: 10, clientY: 10}); + expect(mousePitch.dragMove(overToleranceMove, new Point(10, 10))).toEqual({'pitchDelta': -5}); + expect(mousePitch.isActive()).toBe(true); + + mousePitch.dragEnd(new MouseEvent('mouseup', {buttons: 0, button: 2})); + expect(mousePitch.isActive()).toBe(false); + + mousePitch.disable(); + expect(mousePitch.isEnabled()).toBe(false); + + mousePitch.dragStart(new MouseEvent('mousedown', {buttons: 2, button: 2}), new Point(0, 0)); + expect(mousePitch.isActive()).toBe(false); + + expect(mousePitch.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(mousePitch.isActive()).toBe(false); + + expect(mousePitch.dragMove(overToleranceMove, new Point(10, 10))).toBeUndefined(); + expect(mousePitch.isActive()).toBe(false); + }); + + test('MousePanHandler', () => { + const mousePan = generateMousePanHandler({clickTolerance: 2}); + + expect(mousePan.isActive()).toBe(false); + expect(mousePan.isEnabled()).toBe(false); + mousePan.enable(); + expect(mousePan.isEnabled()).toBe(true); + + mousePan.dragStart(new MouseEvent('mousedown', {buttons: 1, button: 0}), new Point(0, 0)); + expect(mousePan.isActive()).toBe(true); + + const underToleranceMove = new MouseEvent('mousemove', {buttons: 1, clientX: 1, clientY: 1}); + expect(mousePan.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(mousePan.isActive()).toBe(true); + + const overToleranceMove = new MouseEvent('mousemove', {buttons: 1, clientX: 10, clientY: 10}); + expect(mousePan.dragMove(overToleranceMove, new Point(10, 10))) + .toEqual({'around': {'x': 10, 'y': 10,}, 'panDelta': {'x': 10, 'y': 10,}}); + expect(mousePan.isActive()).toBe(true); + + mousePan.dragEnd(new MouseEvent('mouseup', {buttons: 0, button: 0})); + expect(mousePan.isActive()).toBe(false); + + mousePan.disable(); + expect(mousePan.isEnabled()).toBe(false); + + mousePan.dragStart(new MouseEvent('mousedown', {buttons: 2, button: 2}), new Point(0, 0)); + expect(mousePan.isActive()).toBe(false); + + expect(mousePan.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(mousePan.isActive()).toBe(false); + + expect(mousePan.dragMove(overToleranceMove, new Point(10, 10))).toBeUndefined(); + expect(mousePan.isActive()).toBe(false); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/mouse_rotate.test.ts b/web/libraries/maplibre-gl/src/ui/handler/mouse_rotate.test.ts new file mode 100644 index 00000000..2a840f31 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/mouse_rotate.test.ts @@ -0,0 +1,62 @@ +import {extend} from '../../util/util'; +import {Map} from '../../ui/map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {browser} from '../../util/browser'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap(options?) { + return new Map(extend({container: DOM.create('div', '', window.document.body)}, options)); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('mouse rotate', () => { + test('MouseRotateHandler#isActive', () => { + const map = createMap({interactive: true}); + const mouseRotate = map.handlers._handlersById.mouseRotate; + + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockReturnValue(0); + expect(mouseRotate.isActive()).toBe(false); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2, clientX: 0, clientY: 0}); + map._renderTaskQueue.run(); + expect(mouseRotate.isActive()).toBe(false); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(mouseRotate.isActive()).toBe(true); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + expect(mouseRotate.isActive()).toBe(false); + + map.remove(); + }); + + test('MouseRotateHandler#isActive #4622 regression test', () => { + const map = createMap({interactive: true}); + const mouseRotate = map.handlers._handlersById.mouseRotate; + + // Prevent inertial rotation. + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + expect(mouseRotate.isActive()).toBe(false); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(mouseRotate.isActive()).toBe(true); + + // Some browsers don't fire mouseup when it happens outside the window. + // Make the handler in active when it encounters a mousemove without the button pressed. + + simulate.mousemove(map.getCanvas(), {buttons: 0, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + expect(mouseRotate.isActive()).toBe(false); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/one_finger_touch_drag.ts b/web/libraries/maplibre-gl/src/ui/handler/one_finger_touch_drag.ts new file mode 100644 index 00000000..bc67d84a --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/one_finger_touch_drag.ts @@ -0,0 +1,45 @@ +import type Point from '@mapbox/point-geometry'; + +import {DragMoveHandler, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler'; +import {OneFingerTouchMoveStateManager} from './drag_move_state_manager'; + +export interface OneFingerTouchRotateHandler extends DragMoveHandler {} +export interface OneFingerTouchPitchHandler extends DragMoveHandler {} + +const assignEvents = (handler: DragHandler) => { + handler.touchstart = handler.dragStart; + handler.touchmoveWindow = handler.dragMove; + handler.touchend = handler.dragEnd; +}; + +export const generateOneFingerTouchRotationHandler = ({enable, clickTolerance, bearingDegreesPerPixelMoved = 0.8}: { + clickTolerance: number; + bearingDegreesPerPixelMoved?: number; + enable?: boolean; +}): OneFingerTouchRotateHandler => { + const touchMoveStateManager = new OneFingerTouchMoveStateManager(); + return new DragHandler({ + clickTolerance, + move: (lastPoint: Point, point: Point) => + ({bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved}), + moveStateManager: touchMoveStateManager, + enable, + assignEvents, + }); +}; + +export const generateOneFingerTouchPitchHandler = ({enable, clickTolerance, pitchDegreesPerPixelMoved = -0.5}: { + clickTolerance: number; + pitchDegreesPerPixelMoved?: number; + enable?: boolean; +}): OneFingerTouchPitchHandler => { + const touchMoveStateManager = new OneFingerTouchMoveStateManager(); + return new DragHandler({ + clickTolerance, + move: (lastPoint: Point, point: Point) => + ({pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved}), + moveStateManager: touchMoveStateManager, + enable, + assignEvents, + }); +}; diff --git a/web/libraries/maplibre-gl/src/ui/handler/one_finger_touch_drag_handler_interface.test.ts b/web/libraries/maplibre-gl/src/ui/handler/one_finger_touch_drag_handler_interface.test.ts new file mode 100644 index 00000000..9eae8f20 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/one_finger_touch_drag_handler_interface.test.ts @@ -0,0 +1,77 @@ +import Point from '@mapbox/point-geometry'; + +import {generateOneFingerTouchPitchHandler, generateOneFingerTouchRotationHandler} from './one_finger_touch_drag'; + +const testTouch = {identifier: 0} as Touch; + +describe('one touch drag handler tests', () => { + test('OneFingerTouchRotateHandler', () => { + const oneTouchRotate = generateOneFingerTouchRotationHandler({clickTolerance: 2}); + + expect(oneTouchRotate.isActive()).toBe(false); + expect(oneTouchRotate.isEnabled()).toBe(false); + oneTouchRotate.enable(); + expect(oneTouchRotate.isEnabled()).toBe(true); + + oneTouchRotate.dragStart(new TouchEvent('touchstart', {targetTouches: [testTouch]}), new Point(0, 0)); + expect(oneTouchRotate.isActive()).toBe(false); + + const underToleranceMove = new TouchEvent('touchmove', {targetTouches: [testTouch]}); + expect(oneTouchRotate.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(oneTouchRotate.isActive()).toBe(false); + + const overToleranceMove = new TouchEvent('touchmove', {targetTouches: [testTouch]}); + expect(oneTouchRotate.dragMove(overToleranceMove, new Point(10, 10))).toEqual({'bearingDelta': 8}); + expect(oneTouchRotate.isActive()).toBe(true); + + oneTouchRotate.dragEnd(new TouchEvent('touchend', {targetTouches: [testTouch]})); + expect(oneTouchRotate.isActive()).toBe(false); + + oneTouchRotate.disable(); + expect(oneTouchRotate.isEnabled()).toBe(false); + + oneTouchRotate.dragStart(new TouchEvent('touchstart', {targetTouches: [testTouch]}), new Point(0, 0)); + expect(oneTouchRotate.isActive()).toBe(false); + + expect(oneTouchRotate.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(oneTouchRotate.isActive()).toBe(false); + + expect(oneTouchRotate.dragMove(overToleranceMove, new Point(10, 10))).toBeUndefined(); + expect(oneTouchRotate.isActive()).toBe(false); + }); + + test('OneFingerTouchPitchHandler', () => { + const oneTouchPitch = generateOneFingerTouchPitchHandler({clickTolerance: 2}); + + expect(oneTouchPitch.isActive()).toBe(false); + expect(oneTouchPitch.isEnabled()).toBe(false); + oneTouchPitch.enable(); + expect(oneTouchPitch.isEnabled()).toBe(true); + + oneTouchPitch.dragStart(new TouchEvent('touchstart', {targetTouches: [testTouch]}), new Point(0, 0)); + expect(oneTouchPitch.isActive()).toBe(false); + + const underToleranceMove = new TouchEvent('touchmove', {targetTouches: [testTouch]}); + expect(oneTouchPitch.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(oneTouchPitch.isActive()).toBe(false); + + const overToleranceMove = new TouchEvent('touchmove', {targetTouches: [testTouch]}); + expect(oneTouchPitch.dragMove(overToleranceMove, new Point(10, 10))).toEqual({'pitchDelta': -5}); + expect(oneTouchPitch.isActive()).toBe(true); + + oneTouchPitch.dragEnd(new TouchEvent('touchend', {targetTouches: [testTouch]})); + expect(oneTouchPitch.isActive()).toBe(false); + + oneTouchPitch.disable(); + expect(oneTouchPitch.isEnabled()).toBe(false); + + oneTouchPitch.dragStart(new TouchEvent('touchstart', {targetTouches: [testTouch]}), new Point(0, 0)); + expect(oneTouchPitch.isActive()).toBe(false); + + expect(oneTouchPitch.dragMove(underToleranceMove, new Point(1, 1))).toBeUndefined(); + expect(oneTouchPitch.isActive()).toBe(false); + + expect(oneTouchPitch.dragMove(overToleranceMove, new Point(10, 10))).toBeUndefined(); + expect(oneTouchPitch.isActive()).toBe(false); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/scroll_zoom.test.ts b/web/libraries/maplibre-gl/src/ui/handler/scroll_zoom.test.ts new file mode 100644 index 00000000..7efcf899 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/scroll_zoom.test.ts @@ -0,0 +1,298 @@ +import {browser} from '../../util/browser'; +import {Map} from '../../ui/map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {setPerformance, beforeMapTest} from '../../util/test/util'; + +function createMap() { + return new Map({ + container: DOM.create('div', '', window.document.body), + style: { + 'version': 8, + 'sources': {}, + 'layers': [] + } + }); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('ScrollZoomHandler', () => { + + test('Zooms for single mouse wheel tick', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + map._renderTaskQueue.run(); + + // simulate a single 'wheel' event + const startZoom = map.getZoom(); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + expect(map.getZoom() - startZoom).toBeCloseTo(0.0285, 3); + + map.remove(); + }); + + test('Zooms for single mouse wheel tick with non-magical deltaY', done => { + const browserNow = jest.spyOn(browser, 'now'); + const now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + map._renderTaskQueue.run(); + + // Simulate a single 'wheel' event without the magical deltaY value. + // This requires the handler to briefly wait to see if a subsequent + // event is coming in order to guess trackpad vs. mouse wheel + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -20}); + map.on('zoomstart', () => { + map.remove(); + done(); + }); + }); + + test('Zooms for multiple mouse wheel ticks', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + + map._renderTaskQueue.run(); + const startZoom = map.getZoom(); + + const events = [ + [2, {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}], + [7, {type: 'wheel', deltaY: -41}], + [30, {type: 'wheel', deltaY: -169}], + [1, {type: 'wheel', deltaY: -801}], + [5, {type: 'wheel', deltaY: -326}], + [20, {type: 'wheel', deltaY: -345}], + [22, {type: 'wheel', deltaY: -376}], + ] as [number, any][]; + + const end = now + 500; + let lastWheelEvent = now; + + // simulate the above sequence of wheel events, with render frames + // interspersed every 20ms + while (now < end) { + now += 1; + browserNow.mockReturnValue(now); + if (events.length && lastWheelEvent + events[0][0] === now) { + const [, event] = events.shift(); + simulate.wheel(map.getCanvas(), event); + lastWheelEvent = now; + } + if (now % 20 === 0) { + map._renderTaskQueue.run(); + } + } + + expect(map.getZoom() - startZoom).toBeCloseTo(1.944, 3); + + map.remove(); + }); + + test('Gracefully ignores wheel events with deltaY: 0', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + map._renderTaskQueue.run(); + + const startZoom = map.getZoom(); + // simulate shift+'wheel' events + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -0, shiftKey: true}); + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -0, shiftKey: true}); + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -0, shiftKey: true}); + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -0, shiftKey: true}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + expect(map.getZoom() - startZoom).toBe(0.0); + + }); + + test('Gracefully handle wheel events that cancel each other out before the first scroll frame', () => { + // See also https://github.com/mapbox/mapbox-gl-js/issues/6782 + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + map._renderTaskQueue.run(); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -1}); + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -1}); + now += 1; + browserNow.mockReturnValue(now); + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: 2}); + + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + }); + + test('does not zoom if preventDefault is called on the wheel event', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + + map.on('wheel', e => e.preventDefault()); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + expect(map.getZoom()).toBe(0); + + map.remove(); + }); + + test('emits one movestart event and one moveend event while zooming', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + jest.useFakeTimers(); + setPerformance(); + const map = createMap(); + + let startCount = 0; + map.on('movestart', () => { + startCount += 1; + }); + + let endCount = 0; + map.on('moveend', () => { + endCount += 1; + }); + + const events = [ + [2, {type: 'trackpad', deltaY: -1}], + [7, {type: 'trackpad', deltaY: -2}], + [30, {type: 'wheel', deltaY: -5}] + ] as [number, any][]; + + const end = now + 50; + let lastWheelEvent = now; + + while (now < end) { + now += 1; + browserNow.mockReturnValue(now); + if (events.length && lastWheelEvent + events[0][0] === now) { + const [, event] = events.shift(); + simulate.wheel(map.getCanvas(), event); + lastWheelEvent = now; + } + if (now % 20 === 0) { + map._renderTaskQueue.run(); + } + } + + jest.advanceTimersByTime(200); + + map._renderTaskQueue.run(); + + expect(startCount).toBe(1); + expect(endCount).toBe(1); + + }); + + test('emits one zoomstart event and one zoomend event while zooming', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + jest.useFakeTimers(); + setPerformance(); + const map = createMap(); + + let startCount = 0; + map.on('zoomstart', () => { + startCount += 1; + }); + + let endCount = 0; + map.on('zoomend', () => { + endCount += 1; + }); + + const events = [ + [2, {type: 'trackpad', deltaY: -1}], + [7, {type: 'trackpad', deltaY: -2}], + [30, {type: 'wheel', deltaY: -5}], + ] as [number, any][]; + + const end = now + 50; + let lastWheelEvent = now; + + while (now < end) { + now += 1; + browserNow.mockReturnValue(now); + if (events.length && lastWheelEvent + events[0][0] === now) { + const [, event] = events.shift(); + simulate.wheel(map.getCanvas(), event); + lastWheelEvent = now; + } + if (now % 20 === 0) { + map._renderTaskQueue.run(); + } + } + + jest.advanceTimersByTime(200); + map._renderTaskQueue.run(); + + expect(startCount).toBe(1); + expect(endCount).toBe(1); + + }); + + test('Zooms for single mouse wheel tick while not in the center of the map and terrain is on, should zoom according to mouse position', () => { + const browserNow = jest.spyOn(browser, 'now'); + let now = 1555555555555; + browserNow.mockReturnValue(now); + + const map = createMap(); + map._renderTaskQueue.run(); + map.terrain = { + pointCoordinate: () => null + } as any; + + // simulate a single 'wheel' event + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta, clientX: 1000, clientY: 1000}); + map._renderTaskQueue.run(); + + now += 400; + browserNow.mockReturnValue(now); + map._renderTaskQueue.run(); + + expect(map.getCenter().lat).toBeCloseTo(-11.6371, 3); + expect(map.getCenter().lng).toBeCloseTo(11.0286, 3); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/scroll_zoom.ts b/web/libraries/maplibre-gl/src/ui/handler/scroll_zoom.ts new file mode 100644 index 00000000..abf354f4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/scroll_zoom.ts @@ -0,0 +1,361 @@ +import {DOM} from '../../util/dom'; + +import {defaultEasing, bezier} from '../../util/util'; +import {browser} from '../../util/browser'; +import {interpolates} from '@maplibre/maplibre-gl-style-spec'; +import {LngLat} from '../../geo/lng_lat'; +import {TransformProvider} from './transform-provider'; + +import type {Map} from '../map'; +import type Point from '@mapbox/point-geometry'; +import type {AroundCenterOptions} from './two_fingers_touch'; +import {Handler} from '../handler_manager'; + +// deltaY value for mouse scroll wheel identification +const wheelZoomDelta = 4.000244140625; + +// These magic numbers control the rate of zoom. Trackpad events fire at a greater +// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick +const defaultZoomRate = 1 / 100; +const wheelZoomRate = 1 / 450; + +// upper bound on how much we scale the map in any single render frame; this +// is used to limit zoom rate in the case of very fast scrolling +const maxScalePerFrame = 2; + +/** + * The `ScrollZoomHandler` allows the user to zoom the map by scrolling. + * + * @group Handlers + */ +export class ScrollZoomHandler implements Handler { + _map: Map; + _tr: TransformProvider; + _el: HTMLElement; + _enabled: boolean; + _active: boolean; + _zooming: boolean; + _aroundCenter: boolean; + _around: LngLat; + _aroundPoint: Point; + _type: 'wheel' | 'trackpad' | null; + _lastValue: number; + _timeout: ReturnType; // used for delayed-handling of a single wheel movement + _finishTimeout: ReturnType; // used to delay final '{move,zoom}end' events + + _lastWheelEvent: any; + _lastWheelEventTime: number; + + _startZoom: number; + _targetZoom: number; + _delta: number; + _easing: ((a: number) => number); + _prevEase: { + start: number; + duration: number; + easing: (_: number) => number; + }; + + _frameId: boolean; + _triggerRenderFrame: () => void; + + _defaultZoomRate: number; + _wheelZoomRate: number; + + /** @internal */ + constructor(map: Map, triggerRenderFrame: () => void) { + this._map = map; + this._tr = new TransformProvider(map); + this._el = map.getCanvasContainer(); + this._triggerRenderFrame = triggerRenderFrame; + + this._delta = 0; + + this._defaultZoomRate = defaultZoomRate; + this._wheelZoomRate = wheelZoomRate; + } + + /** + * Set the zoom rate of a trackpad + * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value. + * @example + * Speed up trackpad zoom + * ```ts + * map.scrollZoom.setZoomRate(1/25); + * ``` + */ + setZoomRate(zoomRate: number) { + this._defaultZoomRate = zoomRate; + } + + /** + * Set the zoom rate of a mouse wheel + * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value. + * @example + * Slow down zoom of mouse wheel + * ```ts + * map.scrollZoom.setWheelZoomRate(1/600); + * ``` + */ + setWheelZoomRate(wheelZoomRate: number) { + this._wheelZoomRate = wheelZoomRate; + } + + /** + * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled. + * @returns `true` if the "scroll to zoom" interaction is enabled. + */ + isEnabled() { + return !!this._enabled; + } + + /* + * Active state is turned on and off with every scroll wheel event and is set back to false before the map + * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in + * progress. + */ + isActive() { + return !!this._active || this._finishTimeout !== undefined; + } + + isZooming() { + return !!this._zooming; + } + + /** + * Enables the "scroll to zoom" interaction. + * + * @param options - Options object. + * @example + * ```ts + * map.scrollZoom.enable(); + * map.scrollZoom.enable({ around: 'center' }) + * ``` + */ + enable(options?: AroundCenterOptions | boolean) { + if (this.isEnabled()) return; + this._enabled = true; + this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center'; + } + + /** + * Disables the "scroll to zoom" interaction. + * + * @example + * ```ts + * map.scrollZoom.disable(); + * ``` + */ + disable() { + if (!this.isEnabled()) return; + this._enabled = false; + } + + wheel(e: WheelEvent) { + if (!this.isEnabled()) return; + if (this._map._cooperativeGestures) { + if (e[this._map._metaKey]) { + e.preventDefault(); + } else { + return; + } + } + let value = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY; + const now = browser.now(), + timeDelta = now - (this._lastWheelEventTime || 0); + + this._lastWheelEventTime = now; + + if (value !== 0 && (value % wheelZoomDelta) === 0) { + // This one is definitely a mouse wheel event. + this._type = 'wheel'; + + } else if (value !== 0 && Math.abs(value) < 4) { + // This one is definitely a trackpad event because it is so small. + this._type = 'trackpad'; + + } else if (timeDelta > 400) { + // This is likely a new scroll action. + this._type = null; + this._lastValue = value; + + // Start a timeout in case this was a singular event, and dely it by up to 40ms. + this._timeout = setTimeout(this._onTimeout, 40, e); + + } else if (!this._type) { + // This is a repeating event, but we don't know the type of event just yet. + // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode. + this._type = (Math.abs(timeDelta * value) < 200) ? 'trackpad' : 'wheel'; + + // Make sure our delayed event isn't fired again, because we accumulate + // the previous event (which was less than 40ms ago) into this event. + if (this._timeout) { + clearTimeout(this._timeout); + this._timeout = null; + value += this._lastValue; + } + } + + // Slow down zoom if shift key is held for more precise zooming + if (e.shiftKey && value) value = value / 4; + + // Only fire the callback if we actually know what type of scrolling device the user uses. + if (this._type) { + this._lastWheelEvent = e; + this._delta -= value; + if (!this._active) { + this._start(e); + } + } + + e.preventDefault(); + } + + _onTimeout = (initialEvent: MouseEvent) => { + this._type = 'wheel'; + this._delta -= this._lastValue; + if (!this._active) { + this._start(initialEvent); + } + }; + + _start(e: MouseEvent) { + if (!this._delta) return; + + if (this._frameId) { + this._frameId = null; + } + + this._active = true; + if (!this.isZooming()) { + this._zooming = true; + } + + if (this._finishTimeout) { + clearTimeout(this._finishTimeout); + delete this._finishTimeout; + } + + const pos = DOM.mousePos(this._el, e); + const tr = this._tr; + + this._around = LngLat.convert(this._aroundCenter ? tr.center : tr.unproject(pos)); + this._aroundPoint = tr.transform.locationPoint(this._around); + if (!this._frameId) { + this._frameId = true; + this._triggerRenderFrame(); + } + } + + renderFrame() { + if (!this._frameId) return; + this._frameId = null; + + if (!this.isActive()) return; + const tr = this._tr.transform; + + // if we've had scroll events since the last render frame, consume the + // accumulated delta, and update the target zoom level accordingly + if (this._delta !== 0) { + // For trackpad events and single mouse wheel ticks, use the default zoom rate + const zoomRate = (this._type === 'wheel' && Math.abs(this._delta) > wheelZoomDelta) ? this._wheelZoomRate : this._defaultZoomRate; + // Scale by sigmoid of scroll wheel delta. + let scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate))); + + if (this._delta < 0 && scale !== 0) { + scale = 1 / scale; + } + + const fromScale = typeof this._targetZoom === 'number' ? tr.zoomScale(this._targetZoom) : tr.scale; + this._targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale))); + + // if this is a mouse wheel, refresh the starting zoom and easing + // function we're using to smooth out the zooming between wheel + // events + if (this._type === 'wheel') { + this._startZoom = tr.zoom; + this._easing = this._smoothOutEasing(200); + } + + this._delta = 0; + } + + const targetZoom = typeof this._targetZoom === 'number' ? + this._targetZoom : tr.zoom; + const startZoom = this._startZoom; + const easing = this._easing; + + let finished = false; + let zoom; + if (this._type === 'wheel' && startZoom && easing) { + + const t = Math.min((browser.now() - this._lastWheelEventTime) / 200, 1); + const k = easing(t); + zoom = interpolates.number(startZoom, targetZoom, k); + if (t < 1) { + if (!this._frameId) { + this._frameId = true; + } + } else { + finished = true; + } + } else { + zoom = targetZoom; + finished = true; + } + + this._active = true; + + if (finished) { + this._active = false; + this._finishTimeout = setTimeout(() => { + this._zooming = false; + this._triggerRenderFrame(); + delete this._targetZoom; + delete this._finishTimeout; + }, 200); + } + + return { + noInertia: true, + needsRenderFrame: !finished, + zoomDelta: zoom - tr.zoom, + around: this._aroundPoint, + originalEvent: this._lastWheelEvent + }; + } + + _smoothOutEasing(duration: number) { + let easing = defaultEasing; + + if (this._prevEase) { + const currentEase = this._prevEase; + const t = (browser.now() - currentEase.start) / currentEase.duration; + const speed = currentEase.easing(t + 0.01) - currentEase.easing(t); + + // Quick hack to make new bezier that is continuous with last + const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01; + const y = Math.sqrt(0.27 * 0.27 - x * x); + + easing = bezier(x, y, 0.25, 1); + } + + this._prevEase = { + start: browser.now(), + duration, + easing + }; + + return easing; + } + + reset() { + this._active = false; + this._zooming = false; + delete this._targetZoom; + if (this._finishTimeout) { + clearTimeout(this._finishTimeout); + delete this._finishTimeout; + } + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/shim/dblclick_zoom.ts b/web/libraries/maplibre-gl/src/ui/handler/shim/dblclick_zoom.ts new file mode 100644 index 00000000..d33dca28 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/shim/dblclick_zoom.ts @@ -0,0 +1,64 @@ +import type {ClickZoomHandler} from '../click_zoom'; +import type {TapZoomHandler} from './../tap_zoom'; + +/** + * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by + * double clicking or double tapping. + * + * @group Handlers + */ +export class DoubleClickZoomHandler { + + _clickZoom: ClickZoomHandler; + _tapZoom: TapZoomHandler; + + /** @internal */ + constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler) { + this._clickZoom = clickZoom; + this._tapZoom = TapZoom; + } + + /** + * Enables the "double click to zoom" interaction. + * + * @example + * ```ts + * map.doubleClickZoom.enable(); + * ``` + */ + enable() { + this._clickZoom.enable(); + this._tapZoom.enable(); + } + + /** + * Disables the "double click to zoom" interaction. + * + * @example + * ```ts + * map.doubleClickZoom.disable(); + * ``` + */ + disable() { + this._clickZoom.disable(); + this._tapZoom.disable(); + } + + /** + * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled. + * + * @returns `true` if the "double click to zoom" interaction is enabled. + */ + isEnabled() { + return this._clickZoom.isEnabled() && this._tapZoom.isEnabled(); + } + + /** + * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used. + * + * @returns `true` if the "double click to zoom" interaction is active. + */ + isActive() { + return this._clickZoom.isActive() || this._tapZoom.isActive(); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/shim/drag_pan.ts b/web/libraries/maplibre-gl/src/ui/handler/shim/drag_pan.ts new file mode 100644 index 00000000..c554a7fe --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/shim/drag_pan.ts @@ -0,0 +1,104 @@ +import type {MousePanHandler} from '../mouse'; +import type {TouchPanHandler} from './../touch_pan'; + +/** + * A {@link DragPanHandler} options object + */ +export type DragPanOptions = { + /** + * factor used to scale the drag velocity + * @defaultValue 0 + */ + linearity?: number; + /** + * easing function applled to `map.panTo` when applying the drag. + * @param t - the easing function + * @defaultValue bezier(0, 0, 0.3, 1) + */ + easing?: (t: number) => number; + /** + * the maximum value of the drag velocity. + * @defaultValue 1400 + */ + deceleration?: number; + /** + * the rate at which the speed reduces after the pan ends. + * @defaultValue 2500 + */ + maxSpeed?: number; +}; + +/** + * The `DragPanHandler` allows the user to pan the map by clicking and dragging + * the cursor. + * + * @group Handlers + */ +export class DragPanHandler { + + _el: HTMLElement; + _mousePan: MousePanHandler; + _touchPan: TouchPanHandler; + _inertiaOptions: DragPanOptions | boolean; + + /** @internal */ + constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler) { + this._el = el; + this._mousePan = mousePan; + this._touchPan = touchPan; + } + + /** + * Enables the "drag to pan" interaction. + * + * @param options - Options object + * @example + * ```ts + * map.dragPan.enable(); + * map.dragPan.enable({ + * linearity: 0.3, + * easing: bezier(0, 0, 0.3, 1), + * maxSpeed: 1400, + * deceleration: 2500, + * }); + * ``` + */ + enable(options?: DragPanOptions | boolean) { + this._inertiaOptions = options || {}; + this._mousePan.enable(); + this._touchPan.enable(); + this._el.classList.add('maplibregl-touch-drag-pan'); + } + + /** + * Disables the "drag to pan" interaction. + * + * @example + * ```ts + * map.dragPan.disable(); + * ``` + */ + disable() { + this._mousePan.disable(); + this._touchPan.disable(); + this._el.classList.remove('maplibregl-touch-drag-pan'); + } + + /** + * Returns a Boolean indicating whether the "drag to pan" interaction is enabled. + * + * @returns `true` if the "drag to pan" interaction is enabled. + */ + isEnabled() { + return this._mousePan.isEnabled() && this._touchPan.isEnabled(); + } + + /** + * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to pan" interaction is active. + */ + isActive() { + return this._mousePan.isActive() || this._touchPan.isActive(); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/shim/drag_rotate.ts b/web/libraries/maplibre-gl/src/ui/handler/shim/drag_rotate.ts new file mode 100644 index 00000000..0aa35683 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/shim/drag_rotate.ts @@ -0,0 +1,73 @@ +import type {MousePitchHandler, MouseRotateHandler} from '../mouse'; + +export type DragRotateHandlerOptions = { + /** + * Control the map pitch in addition to the bearing + * @defaultValue true + */ + pitchWithRotate: boolean; +} + +/** + * The `DragRotateHandler` allows the user to rotate the map by clicking and + * dragging the cursor while holding the right mouse button or `ctrl` key. + * + * @group Handlers + */ +export class DragRotateHandler { + + _mouseRotate: MouseRotateHandler; + _mousePitch: MousePitchHandler; + _pitchWithRotate: boolean; + + /** @internal */ + constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler) { + this._pitchWithRotate = options.pitchWithRotate; + this._mouseRotate = mouseRotate; + this._mousePitch = mousePitch; + } + + /** + * Enables the "drag to rotate" interaction. + * + * @example + * ```ts + * map.dragRotate.enable(); + * ``` + */ + enable() { + this._mouseRotate.enable(); + if (this._pitchWithRotate) this._mousePitch.enable(); + } + + /** + * Disables the "drag to rotate" interaction. + * + * @example + * ```ts + * map.dragRotate.disable(); + * ``` + */ + disable() { + this._mouseRotate.disable(); + this._mousePitch.disable(); + } + + /** + * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled. + * + * @returns `true` if the "drag to rotate" interaction is enabled. + */ + isEnabled() { + return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled()); + } + + /** + * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to rotate" interaction is active. + */ + isActive() { + return this._mouseRotate.isActive() || this._mousePitch.isActive(); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/shim/two_fingers_touch.ts b/web/libraries/maplibre-gl/src/ui/handler/shim/two_fingers_touch.ts new file mode 100644 index 00000000..68ae7d27 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/shim/two_fingers_touch.ts @@ -0,0 +1,112 @@ +import type {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, AroundCenterOptions} from '../two_fingers_touch'; +import type {TapDragZoomHandler} from '../tap_drag_zoom'; + +/** + * The `TwoFingersTouchZoomRotateHandler` allows the user to zoom and rotate the map by + * pinching on a touchscreen. + * + * They can zoom with one finger by double tapping and dragging. On the second tap, + * hold the finger down and drag up or down to zoom in or out. + * + * @group Handlers + */ +export class TwoFingersTouchZoomRotateHandler { + + _el: HTMLElement; + _touchZoom: TwoFingersTouchZoomHandler; + _touchRotate: TwoFingersTouchRotateHandler; + _tapDragZoom: TapDragZoomHandler; + _rotationDisabled: boolean; + _enabled: boolean; + + /** @internal */ + constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler) { + this._el = el; + this._touchZoom = touchZoom; + this._touchRotate = touchRotate; + this._tapDragZoom = tapDragZoom; + this._rotationDisabled = false; + this._enabled = true; + } + + /** + * Enables the "pinch to rotate and zoom" interaction. + * + * @param options - Options object. + * + * @example + * ```ts + * map.touchZoomRotate.enable(); + * map.touchZoomRotate.enable({ around: 'center' }); + * ``` + */ + enable(options?: AroundCenterOptions | boolean | null) { + this._touchZoom.enable(options); + if (!this._rotationDisabled) this._touchRotate.enable(options); + this._tapDragZoom.enable(); + this._el.classList.add('maplibregl-touch-zoom-rotate'); + } + + /** + * Disables the "pinch to rotate and zoom" interaction. + * + * @example + * ```ts + * map.touchZoomRotate.disable(); + * ``` + */ + disable() { + this._touchZoom.disable(); + this._touchRotate.disable(); + this._tapDragZoom.disable(); + this._el.classList.remove('maplibregl-touch-zoom-rotate'); + } + + /** + * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled. + * + * @returns `true` if the "pinch to rotate and zoom" interaction is enabled. + */ + isEnabled() { + return this._touchZoom.isEnabled() && + (this._rotationDisabled || this._touchRotate.isEnabled()) && + this._tapDragZoom.isEnabled(); + } + + /** + * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture. + * + * @returns `true` if the handler is active, `false` otherwise + */ + isActive() { + return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive(); + } + + /** + * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom" + * interaction enabled. + * + * @example + * ```ts + * map.touchZoomRotate.disableRotation(); + * ``` + */ + disableRotation() { + this._rotationDisabled = true; + this._touchRotate.disable(); + } + + /** + * Enables the "pinch to rotate" interaction. + * + * @example + * ```ts + * map.touchZoomRotate.enable(); + * map.touchZoomRotate.enableRotation(); + * ``` + */ + enableRotation() { + this._rotationDisabled = false; + if (this._touchZoom.isEnabled()) this._touchRotate.enable(); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/tap_drag_zoom.test.ts b/web/libraries/maplibre-gl/src/ui/handler/tap_drag_zoom.test.ts new file mode 100644 index 00000000..cc8eefec --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/tap_drag_zoom.test.ts @@ -0,0 +1,113 @@ +import {beforeMapTest} from '../../util/test/util'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {Map, MapOptions} from '../map'; + +function createMap() { + return new Map({container: window.document.createElement('div')} as any as MapOptions); +} + +function setupEvents(map: Map) { + const zoomstart = jest.fn(); + map.on('zoomstart', zoomstart); + + const zoom = jest.fn(); + map.on('zoom', zoom); + + const zoomend = jest.fn(); + map.on('zoomend', zoomend); + + return { + zoomstart, + zoom, + zoomend + }; +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('tap_drag_zoom', () => { + test('TapDragZoomHandler fires zoomstart, zoom, and zoomend at appropriate times in response to a double-tap and drag gesture', () => { + const map = createMap(); + const target = map.getCanvas(); + + const {zoomstart, zoom, zoomend} = setupEvents(map); + + const pointTouchOptions = { + touches: [{target, clientX: 100, clientY: 100}] + }; + + simulate.touchstart(target, pointTouchOptions); + simulate.touchend(target); + simulate.touchstart(target, pointTouchOptions); + map._renderTaskQueue.run(); + + expect(zoomstart).not.toHaveBeenCalled(); + expect(zoom).not.toHaveBeenCalled(); + expect(zoomend).not.toHaveBeenCalled(); + + simulate.touchmove(target, { + touches: [{target, clientX: 100, clientY: 110}] + }); + map._renderTaskQueue.run(); + + expect(zoomstart).toHaveBeenCalled(); + expect(zoom).toHaveBeenCalled(); + expect(zoomend).not.toHaveBeenCalled(); + + simulate.touchend(target); + map._renderTaskQueue.run(); + expect(zoomend).toHaveBeenCalled(); + + }); + + test('TapDragZoomHandler does not fire zoom on tap and drag if touchstart events are > 500ms apart', done => { + const map = createMap(); + const target = map.getCanvas(); + + const {zoomstart, zoom, zoomend} = setupEvents(map); + + const pointTouchOptions = { + touches: [{target, clientX: 100, clientY: 100}] + }; + + simulate.touchstart(target, pointTouchOptions); + simulate.touchend(target); + setTimeout(() => { + simulate.touchstart(target, pointTouchOptions); + simulate.touchmove(target, { + touches: [{target, clientX: 100, clientY: 110}] + }); + map._renderTaskQueue.run(); + + expect(zoomstart).not.toHaveBeenCalled(); + expect(zoom).not.toHaveBeenCalled(); + expect(zoomend).not.toHaveBeenCalled(); + done(); + }, 510); + }); + + test('TapDragZoomHandler does not zoom on double-tap and drag if touchstart events are in different locations (>30px apart)', () => { + const map = createMap(); + const target = map.getCanvas(); + + const {zoomstart, zoom, zoomend} = setupEvents(map); + + simulate.touchstart(target, { + touches: [{target, clientX: 100, clientY: 100}] + }); + simulate.touchend(target); + simulate.touchstart(target, { + touches: [{target, clientX: 140, clientY: 100}] + }); + simulate.touchmove(target, { + touches: [{target, clientX: 140, clientY: 110}] + }); + map._renderTaskQueue.run(); + + expect(zoomstart).not.toHaveBeenCalled(); + expect(zoom).not.toHaveBeenCalled(); + expect(zoomend).not.toHaveBeenCalled(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/tap_drag_zoom.ts b/web/libraries/maplibre-gl/src/ui/handler/tap_drag_zoom.ts new file mode 100644 index 00000000..59742da8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/tap_drag_zoom.ts @@ -0,0 +1,109 @@ +import {Handler} from '../handler_manager'; +import {TapRecognizer, MAX_TAP_INTERVAL, MAX_DIST} from './tap_recognizer'; +import type Point from '@mapbox/point-geometry'; + +export class TapDragZoomHandler implements Handler { + + _enabled: boolean; + _active: boolean; + _swipePoint: Point; + _swipeTouch: number; + _tapTime: number; + _tapPoint: Point; + _tap: TapRecognizer; + + constructor() { + + this._tap = new TapRecognizer({ + numTouches: 1, + numTaps: 1 + }); + + this.reset(); + } + + reset() { + this._active = false; + delete this._swipePoint; + delete this._swipeTouch; + delete this._tapTime; + delete this._tapPoint; + this._tap.reset(); + } + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + if (this._swipePoint) return; + + if (!this._tapTime) { + this._tap.touchstart(e, points, mapTouches); + } else { + const swipePoint = points[0]; + + const soonEnough = e.timeStamp - this._tapTime < MAX_TAP_INTERVAL; + const closeEnough = this._tapPoint.dist(swipePoint) < MAX_DIST; + + if (!soonEnough || !closeEnough) { + this.reset(); + } else if (mapTouches.length > 0) { + this._swipePoint = swipePoint; + this._swipeTouch = mapTouches[0].identifier; + } + } + } + + touchmove(e: TouchEvent, points: Array, mapTouches: Array) { + if (!this._tapTime) { + this._tap.touchmove(e, points, mapTouches); + } else if (this._swipePoint) { + if (mapTouches[0].identifier !== this._swipeTouch) { + return; + } + + const newSwipePoint = points[0]; + const dist = newSwipePoint.y - this._swipePoint.y; + this._swipePoint = newSwipePoint; + + e.preventDefault(); + this._active = true; + + return { + zoomDelta: dist / 128 + }; + } + } + + touchend(e: TouchEvent, points: Array, mapTouches: Array) { + if (!this._tapTime) { + const point = this._tap.touchend(e, points, mapTouches); + if (point) { + this._tapTime = e.timeStamp; + this._tapPoint = point; + } + } else if (this._swipePoint) { + if (mapTouches.length === 0) { + this.reset(); + } + } + } + + touchcancel() { + this.reset(); + } + + enable() { + this._enabled = true; + } + + disable() { + this._enabled = false; + this.reset(); + } + + isEnabled() { + return this._enabled; + } + + isActive() { + return this._active; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/tap_recognizer.ts b/web/libraries/maplibre-gl/src/ui/handler/tap_recognizer.ts new file mode 100644 index 00000000..b0c60c85 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/tap_recognizer.ts @@ -0,0 +1,138 @@ +import Point from '@mapbox/point-geometry'; +import {indexTouches} from './handler_util'; + +function getCentroid(points: Array) { + const sum = new Point(0, 0); + for (const point of points) { + sum._add(point); + } + return sum.div(points.length); +} + +export const MAX_TAP_INTERVAL = 500; +const MAX_TOUCH_TIME = 500; +export const MAX_DIST = 30; + +export class SingleTapRecognizer { + + numTouches: number; + centroid: Point; + startTime: number; + aborted: boolean; + touches: { + [k in number | string]: Point; + }; + + constructor(options: { + numTouches: number; + }) { + this.reset(); + this.numTouches = options.numTouches; + } + + reset() { + delete this.centroid; + delete this.startTime; + delete this.touches; + this.aborted = false; + } + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + + if (this.centroid || mapTouches.length > this.numTouches) { + this.aborted = true; + } + if (this.aborted) { + return; + } + + if (this.startTime === undefined) { + this.startTime = e.timeStamp; + } + + if (mapTouches.length === this.numTouches) { + this.centroid = getCentroid(points); + this.touches = indexTouches(mapTouches, points); + } + } + + touchmove(e: TouchEvent, points: Array, mapTouches: Array) { + if (this.aborted || !this.centroid) return; + + const newTouches = indexTouches(mapTouches, points); + for (const id in this.touches) { + const prevPos = this.touches[id]; + const pos = newTouches[id]; + if (!pos || pos.dist(prevPos) > MAX_DIST) { + this.aborted = true; + } + } + } + + touchend(e: TouchEvent, points: Array, mapTouches: Array) { + if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) { + this.aborted = true; + } + + if (mapTouches.length === 0) { + const centroid = !this.aborted && this.centroid; + this.reset(); + if (centroid) return centroid; + } + } + +} + +export class TapRecognizer { + + singleTap: SingleTapRecognizer; + numTaps: number; + lastTime: number; + lastTap: Point; + count: number; + + constructor(options: { + numTaps: number; + numTouches: number; + }) { + this.singleTap = new SingleTapRecognizer(options); + this.numTaps = options.numTaps; + this.reset(); + } + + reset() { + this.lastTime = Infinity; + delete this.lastTap; + this.count = 0; + this.singleTap.reset(); + } + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + this.singleTap.touchstart(e, points, mapTouches); + } + + touchmove(e: TouchEvent, points: Array, mapTouches: Array) { + this.singleTap.touchmove(e, points, mapTouches); + } + + touchend(e: TouchEvent, points: Array, mapTouches: Array) { + const tap = this.singleTap.touchend(e, points, mapTouches); + if (tap) { + const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL; + const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST; + + if (!soonEnough || !closeEnough) { + this.reset(); + } + + this.count++; + this.lastTime = e.timeStamp; + this.lastTap = tap; + + if (this.count === this.numTaps) { + this.reset(); + return tap; + } + } + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/tap_zoom.ts b/web/libraries/maplibre-gl/src/ui/handler/tap_zoom.ts new file mode 100644 index 00000000..03abe361 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/tap_zoom.ts @@ -0,0 +1,95 @@ +import {TapRecognizer} from './tap_recognizer'; +import type Point from '@mapbox/point-geometry'; +import type {Map} from '../map'; +import {TransformProvider} from './transform-provider'; +import {Handler} from '../handler_manager'; + +export class TapZoomHandler implements Handler { + _tr: TransformProvider; + _enabled: boolean; + _active: boolean; + _zoomIn: TapRecognizer; + _zoomOut: TapRecognizer; + + constructor(map: Map) { + this._tr = new TransformProvider(map); + this._zoomIn = new TapRecognizer({ + numTouches: 1, + numTaps: 2 + }); + + this._zoomOut = new TapRecognizer({ + numTouches: 2, + numTaps: 1 + }); + + this.reset(); + } + + reset() { + this._active = false; + this._zoomIn.reset(); + this._zoomOut.reset(); + } + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + this._zoomIn.touchstart(e, points, mapTouches); + this._zoomOut.touchstart(e, points, mapTouches); + } + + touchmove(e: TouchEvent, points: Array, mapTouches: Array) { + this._zoomIn.touchmove(e, points, mapTouches); + this._zoomOut.touchmove(e, points, mapTouches); + } + + touchend(e: TouchEvent, points: Array, mapTouches: Array) { + const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches); + const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches); + const tr = this._tr; + + if (zoomInPoint) { + this._active = true; + e.preventDefault(); + setTimeout(() => this.reset(), 0); + return { + cameraAnimation: (map: Map) => map.easeTo({ + duration: 300, + zoom: tr.zoom + 1, + around: tr.unproject(zoomInPoint) + }, {originalEvent: e}) + }; + } else if (zoomOutPoint) { + this._active = true; + e.preventDefault(); + setTimeout(() => this.reset(), 0); + return { + cameraAnimation: (map: Map) => map.easeTo({ + duration: 300, + zoom: tr.zoom - 1, + around: tr.unproject(zoomOutPoint) + }, {originalEvent: e}) + }; + } + } + + touchcancel() { + this.reset(); + } + + enable() { + this._enabled = true; + } + + disable() { + this._enabled = false; + this.reset(); + } + + isEnabled() { + return this._enabled; + } + + isActive() { + return this._active; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/touch_pan.ts b/web/libraries/maplibre-gl/src/ui/handler/touch_pan.ts new file mode 100644 index 00000000..be3eff4f --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/touch_pan.ts @@ -0,0 +1,124 @@ +import Point from '@mapbox/point-geometry'; +import {indexTouches} from './handler_util'; +import type {Map} from '../map'; +import {GestureOptions} from '../map'; +import {Handler} from '../handler_manager'; + +export class TouchPanHandler implements Handler { + + _enabled: boolean; + _active: boolean; + _touches: { + [k in string | number]: Point; + }; + _minTouches: number; + _clickTolerance: number; + _sum: Point; + _map: Map; + _cancelCooperativeMessage: boolean; + + constructor(options: { + clickTolerance: number; + cooperativeGestures: boolean | GestureOptions; + }, map: Map) { + this._minTouches = options.cooperativeGestures ? 2 : 1; + this._clickTolerance = options.clickTolerance || 1; + this._map = map; + this.reset(); + } + + reset() { + this._active = false; + this._touches = {}; + this._sum = new Point(0, 0); + + // Put a delay on the cooperative gesture message so it's less twitchy + setTimeout(() => { + this._cancelCooperativeMessage = false; + }, 200); + } + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + return this._calculateTransform(e, points, mapTouches); + } + + touchmove(e: TouchEvent, points: Array, mapTouches: Array) { + if (this._map._cooperativeGestures) { + if (this._minTouches === 2 && mapTouches.length < 2 && !this._cancelCooperativeMessage) { + // If coop gesture enabled, show panning info to user + this._map._onCooperativeGesture(e, false, mapTouches.length); + } else if (!this._cancelCooperativeMessage) { + // If user is successfully navigating, we don't need this warning until the touch resets + this._cancelCooperativeMessage = true; + } + } + if (!this._active || mapTouches.length < this._minTouches) return; + e.preventDefault(); + return this._calculateTransform(e, points, mapTouches); + } + + touchend(e: TouchEvent, points: Array, mapTouches: Array) { + this._calculateTransform(e, points, mapTouches); + + if (this._active && mapTouches.length < this._minTouches) { + this.reset(); + } + } + + touchcancel() { + this.reset(); + } + + _calculateTransform(e: TouchEvent, points: Array, mapTouches: Array) { + if (mapTouches.length > 0) this._active = true; + + const touches = indexTouches(mapTouches, points); + + const touchPointSum = new Point(0, 0); + const touchDeltaSum = new Point(0, 0); + let touchDeltaCount = 0; + + for (const identifier in touches) { + const point = touches[identifier]; + const prevPoint = this._touches[identifier]; + if (prevPoint) { + touchPointSum._add(point); + touchDeltaSum._add(point.sub(prevPoint)); + touchDeltaCount++; + touches[identifier] = point; + } + } + + this._touches = touches; + + if (touchDeltaCount < this._minTouches || !touchDeltaSum.mag()) return; + + const panDelta = touchDeltaSum.div(touchDeltaCount); + this._sum._add(panDelta); + if (this._sum.mag() < this._clickTolerance) return; + + const around = touchPointSum.div(touchDeltaCount); + + return { + around, + panDelta + }; + } + + enable() { + this._enabled = true; + } + + disable() { + this._enabled = false; + this.reset(); + } + + isEnabled() { + return this._enabled; + } + + isActive() { + return this._active; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/transform-provider.ts b/web/libraries/maplibre-gl/src/ui/handler/transform-provider.ts new file mode 100644 index 00000000..87875248 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/transform-provider.ts @@ -0,0 +1,43 @@ +import type {Map} from '../map'; +import type {PointLike} from '../camera'; +import type {Transform} from '../../geo/transform'; +import Point from '@mapbox/point-geometry'; +import {LngLat} from '../../geo/lng_lat'; + +/** + * @internal + * Shared utilities for the Handler classes to access the correct camera state. + * If Camera.transformCameraUpdate is specified, the "desired state" of camera may differ from the state used for rendering. + * The handlers need the "desired state" to track accumulated changes. + */ +export class TransformProvider { + _map: Map; + + constructor(map: Map) { + this._map = map; + } + + get transform(): Transform { + return this._map._requestedCameraState || this._map.transform; + } + + get center() { + return {lng: this.transform.center.lng, lat: this.transform.center.lat}; + } + + get zoom() { + return this.transform.zoom; + } + + get pitch() { + return this.transform.pitch; + } + + get bearing() { + return this.transform.bearing; + } + + unproject(point: PointLike): LngLat { + return this.transform.pointLocation(Point.convert(point), this._map.terrain); + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler/two_fingers_touch.test.ts b/web/libraries/maplibre-gl/src/ui/handler/two_fingers_touch.test.ts new file mode 100644 index 00000000..8b0d5c74 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/two_fingers_touch.test.ts @@ -0,0 +1,283 @@ +import {Map, MapOptions} from '../map'; +import {Marker} from '../marker'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap() { + return new Map({container: DOM.create('div', '', window.document.body)} as any as MapOptions); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('touch zoom rotate', () => { + + test('TwoFingersTouchZoomRotateHandler fires zoomstart, zoom, and zoomend events at appropriate times in response to a pinch-zoom gesture', () => { + const map = createMap(); + const target = map.getCanvas(); + + const zoomstart = jest.fn(); + const zoom = jest.fn(); + const zoomend = jest.fn(); + + map.handlers._handlersById.tapZoom.disable(); + map.touchPitch.disable(); + map.on('zoomstart', zoomstart); + map.on('zoom', zoom); + map.on('zoomend', zoomend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, identifier: 1, clientX: 0, clientY: -50}, {target, identifier: 2, clientX: 0, clientY: 50}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(0); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, identifier: 1, clientX: 0, clientY: -100}, {target, identifier: 2, clientX: 0, clientY: 100}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(1); + expect(zoom).toHaveBeenCalledTimes(1); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, identifier: 1, clientX: 0, clientY: -60}, {target, identifier: 2, clientX: 0, clientY: 60}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(1); + expect(zoom).toHaveBeenCalledTimes(2); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: []}); + map._renderTaskQueue.run(); + + // incremented because inertia starts a second zoom + expect(zoomstart).toHaveBeenCalledTimes(2); + map._renderTaskQueue.run(); + expect(zoom).toHaveBeenCalledTimes(3); + expect(zoomend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('TwoFingersTouchZoomRotateHandler fires rotatestart, rotate, and rotateend events at appropriate times in response to a pinch-rotate gesture', () => { + const map = createMap(); + const target = map.getCanvas(); + + const rotatestart = jest.fn(); + const rotate = jest.fn(); + const rotateend = jest.fn(); + + map.on('rotatestart', rotatestart); + map.on('rotate', rotate); + map.on('rotateend', rotateend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, identifier: 0, clientX: 0, clientY: -50}, {target, identifier: 1, clientX: 0, clientY: 50}]}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(0); + expect(rotate).toHaveBeenCalledTimes(0); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, identifier: 0, clientX: -50, clientY: 0}, {target, identifier: 1, clientX: 50, clientY: 0}]}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(1); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, identifier: 0, clientX: 0, clientY: -50}, {target, identifier: 1, clientX: 0, clientY: 50}]}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: []}); + map._renderTaskQueue.run(); + expect(rotatestart).toHaveBeenCalledTimes(1); + expect(rotate).toHaveBeenCalledTimes(2); + expect(rotateend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('TwoFingersTouchZoomRotateHandler does not begin a gesture if preventDefault is called on the touchstart event', () => { + const map = createMap(); + const target = map.getCanvas(); + + map.on('touchstart', e => e.preventDefault()); + + const move = jest.fn(); + map.on('move', move); + + simulate.touchstart(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}, {target, clientX: 5, clientY: 0}]}); + map._renderTaskQueue.run(); + + simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}, {target, clientX: 0, clientY: 5}]}); + map._renderTaskQueue.run(); + + simulate.touchend(map.getCanvas(), {touches: []}); + map._renderTaskQueue.run(); + + expect(move).toHaveBeenCalledTimes(0); + + map.remove(); + }); + + test('TwoFingersTouchZoomRotateHandler starts zoom immediately when rotation disabled', () => { + const map = createMap(); + const target = map.getCanvas(); + map.touchZoomRotate.disableRotation(); + map.handlers._handlersById.tapZoom.disable(); + + const zoomstart = jest.fn(); + const zoom = jest.fn(); + const zoomend = jest.fn(); + + map.on('zoomstart', zoomstart); + map.on('zoom', zoom); + map.on('zoomend', zoomend); + + simulate.touchstart(map.getCanvas(), {touches: [{target, identifier: 0, clientX: 0, clientY: -5}, {target, identifier: 2, clientX: 0, clientY: 5}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(0); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, identifier: 0, clientX: 0, clientY: -5}, {target, identifier: 2, clientX: 0, clientY: 6}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(1); + expect(zoom).toHaveBeenCalledTimes(1); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target, identifier: 0, clientX: 0, clientY: -5}, {target, identifier: 2, clientX: 0, clientY: 4}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(1); + expect(zoom).toHaveBeenCalledTimes(2); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: []}); + map._renderTaskQueue.run(); + // incremented because inertia starts a second zoom + expect(zoomstart).toHaveBeenCalledTimes(2); + map._renderTaskQueue.run(); + expect(zoom).toHaveBeenCalledTimes(3); + expect(zoomend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('TwoFingersTouchZoomRotateHandler adds css class used for disabling default touch behavior in some browsers', () => { + const map = createMap(); + + const className = 'maplibregl-touch-zoom-rotate'; + expect(map.getCanvasContainer().classList.contains(className)).toBeTruthy(); + map.touchZoomRotate.disable(); + expect(map.getCanvasContainer().classList.contains(className)).toBeFalsy(); + map.touchZoomRotate.enable(); + expect(map.getCanvasContainer().classList.contains(className)).toBeTruthy(); + }); + + test('TwoFingersTouchZoomRotateHandler zooms when touching two markers on the same map', () => { + const map = createMap(); + + const marker1 = new Marker() + .setLngLat([0, 0]) + .addTo(map); + const marker2 = new Marker() + .setLngLat([0, 0]) + .addTo(map); + const target1 = marker1.getElement(); + const target2 = marker2.getElement(); + + const zoomstart = jest.fn(); + const zoom = jest.fn(); + const zoomend = jest.fn(); + + map.handlers._handlersById.tapZoom.disable(); + map.touchPitch.disable(); + map.on('zoomstart', zoomstart); + map.on('zoom', zoom); + map.on('zoomend', zoomend); + + simulate.touchstart(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -50}]}); + simulate.touchstart(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -50}, {target: target2, identifier: 2, clientX: 0, clientY: 50}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(0); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -100}, {target: target2, identifier: 2, clientX: 0, clientY: 100}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(1); + expect(zoom).toHaveBeenCalledTimes(1); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -60}, {target: target2, identifier: 2, clientX: 0, clientY: 60}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(1); + expect(zoom).toHaveBeenCalledTimes(2); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: []}); + map._renderTaskQueue.run(); + + // incremented because inertia starts a second zoom + expect(zoomstart).toHaveBeenCalledTimes(2); + map._renderTaskQueue.run(); + expect(zoom).toHaveBeenCalledTimes(3); + expect(zoomend).toHaveBeenCalledTimes(1); + + map.remove(); + }); + + test('TwoFingersTouchZoomRotateHandler does not zoom when touching an element not on the map', () => { + const map = createMap(); + + const marker1 = new Marker() + .setLngLat([0, 0]) + .addTo(map); + const marker2 = new Marker() + .setLngLat([0, 0]); + + const target1 = marker1.getElement(); // on map + const target2 = marker2.getElement(); // not on map + + const zoomstart = jest.fn(); + const zoom = jest.fn(); + const zoomend = jest.fn(); + + map.handlers._handlersById.tapZoom.disable(); + map.touchPitch.disable(); + map.dragPan.disable(); + map.on('zoomstart', zoomstart); + map.on('zoom', zoom); + map.on('zoomend', zoomend); + + simulate.touchstart(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -50}]}); + simulate.touchstart(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -50}, {target: target2, identifier: 2, clientX: 0, clientY: 50}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(0); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -100}, {target: target2, identifier: 2, clientX: 0, clientY: 100}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(0); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchmove(map.getCanvas(), {touches: [{target: target1, identifier: 1, clientX: 0, clientY: -60}, {target: target2, identifier: 2, clientX: 0, clientY: 60}]}); + map._renderTaskQueue.run(); + expect(zoomstart).toHaveBeenCalledTimes(0); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + simulate.touchend(map.getCanvas(), {touches: []}); + map._renderTaskQueue.run(); + + // incremented because inertia starts a second zoom + expect(zoomstart).toHaveBeenCalledTimes(0); + map._renderTaskQueue.run(); + expect(zoom).toHaveBeenCalledTimes(0); + expect(zoomend).toHaveBeenCalledTimes(0); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/handler/two_fingers_touch.ts b/web/libraries/maplibre-gl/src/ui/handler/two_fingers_touch.ts new file mode 100644 index 00000000..a29fc036 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler/two_fingers_touch.ts @@ -0,0 +1,337 @@ +import Point from '@mapbox/point-geometry'; +import {DOM} from '../../util/dom'; +import type {Map} from '../map'; +import {Handler} from '../handler_manager'; + +/** + * An options object sent to the enable function of some of the handlers + */ +export type AroundCenterOptions = { + /** + * If "center" is passed, map will zoom around the center of map + */ + around: 'center'; +} + +/** + * The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers + * + * @group Handlers + */ +abstract class TwoFingersTouchHandler implements Handler { + + _enabled: boolean; + _active: boolean; + _firstTwoTouches: [number, number]; + _vector: Point; + _startVector: Point; + _aroundCenter: boolean; + + /** @internal */ + constructor() { + this.reset(); + } + + reset() { + this._active = false; + delete this._firstTwoTouches; + } + + abstract _start(points: [Point, Point]); + abstract _move(points: [Point, Point], pinchAround: Point, e: TouchEvent); + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + //log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined); + if (this._firstTwoTouches || mapTouches.length < 2) return; + + this._firstTwoTouches = [ + mapTouches[0].identifier, + mapTouches[1].identifier + ]; + + // implemented by child classes + this._start([points[0], points[1]]); + } + + touchmove(e: TouchEvent, points: Array, mapTouches: Array) { + if (!this._firstTwoTouches) return; + + e.preventDefault(); + + const [idA, idB] = this._firstTwoTouches; + const a = getTouchById(mapTouches, points, idA); + const b = getTouchById(mapTouches, points, idB); + if (!a || !b) return; + const pinchAround = this._aroundCenter ? null : a.add(b).div(2); + + // implemented by child classes + return this._move([a, b], pinchAround, e); + + } + + touchend(e: TouchEvent, points: Array, mapTouches: Array) { + if (!this._firstTwoTouches) return; + + const [idA, idB] = this._firstTwoTouches; + const a = getTouchById(mapTouches, points, idA); + const b = getTouchById(mapTouches, points, idB); + if (a && b) return; + + if (this._active) DOM.suppressClick(); + + this.reset(); + } + + touchcancel() { + this.reset(); + } + + /** + * Enables the "drag to pitch" interaction. + * + * @example + * ```ts + * map.touchPitch.enable(); + * ``` + */ + enable(options?: AroundCenterOptions | boolean | null) { + this._enabled = true; + this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center'; + } + + /** + * Disables the "drag to pitch" interaction. + * + * @example + * ```ts + * map.touchPitch.disable(); + * ``` + */ + disable() { + this._enabled = false; + this.reset(); + } + + /** + * Returns a Boolean indicating whether the "drag to pitch" interaction is enabled. + * + * @returns `true` if the "drag to pitch" interaction is enabled. + */ + isEnabled() { + return this._enabled; + } + + /** + * Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used. + * + * @returns `true` if the "drag to pitch" interaction is active. + */ + isActive() { + return this._active; + } +} + +function getTouchById(mapTouches: Array, points: Array, identifier: number) { + for (let i = 0; i < mapTouches.length; i++) { + if (mapTouches[i].identifier === identifier) return points[i]; + } +} + +/* ZOOM */ + +const ZOOM_THRESHOLD = 0.1; + +function getZoomDelta(distance, lastDistance) { + return Math.log(distance / lastDistance) / Math.LN2; +} + +/** + * The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers + * + * @group Handlers + */ +export class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler { + + _distance: number; + _startDistance: number; + + reset() { + super.reset(); + delete this._distance; + delete this._startDistance; + } + + _start(points: [Point, Point]) { + this._startDistance = this._distance = points[0].dist(points[1]); + } + + _move(points: [Point, Point], pinchAround: Point) { + const lastDistance = this._distance; + this._distance = points[0].dist(points[1]); + if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) return; + this._active = true; + return { + zoomDelta: getZoomDelta(this._distance, lastDistance), + pinchAround + }; + } +} + +/* ROTATE */ + +const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle + +function getBearingDelta(a, b) { + return a.angleWith(b) * 180 / Math.PI; +} + +/** + * The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers + * + * @group Handlers + */ +export class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler { + _minDiameter: number; + + reset() { + super.reset(); + delete this._minDiameter; + delete this._startVector; + delete this._vector; + } + + _start(points: [Point, Point]) { + this._startVector = this._vector = points[0].sub(points[1]); + this._minDiameter = points[0].dist(points[1]); + } + + _move(points: [Point, Point], pinchAround: Point) { + const lastVector = this._vector; + this._vector = points[0].sub(points[1]); + + if (!this._active && this._isBelowThreshold(this._vector)) return; + this._active = true; + + return { + bearingDelta: getBearingDelta(this._vector, lastVector), + pinchAround + }; + } + + _isBelowThreshold(vector: Point) { + /* + * The threshold before a rotation actually happens is configured in + * pixels along the circumference of the circle formed by the two fingers. + * This makes the threshold in degrees larger when the fingers are close + * together and smaller when the fingers are far apart. + * + * Use the smallest diameter from the whole gesture to reduce sensitivity + * when pinching in and out. + */ + + this._minDiameter = Math.min(this._minDiameter, vector.mag()); + const circumference = Math.PI * this._minDiameter; + const threshold = ROTATION_THRESHOLD / circumference * 360; + + const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector); + return Math.abs(bearingDeltaSinceStart) < threshold; + } +} + +/* PITCH */ + +function isVertical(vector) { + return Math.abs(vector.y) > Math.abs(vector.x); +} + +const ALLOWED_SINGLE_TOUCH_TIME = 100; + +/** + * The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers. + * + * @group Handlers + */ +export class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler { + + _valid: boolean | void; + _firstMove: number; + _lastPoints: [Point, Point]; + _map: Map; + _currentTouchCount: number; + + constructor(map: Map) { + super(); + this._map = map; + } + + reset() { + super.reset(); + this._valid = undefined; + delete this._firstMove; + delete this._lastPoints; + } + + touchstart(e: TouchEvent, points: Array, mapTouches: Array) { + super.touchstart(e, points, mapTouches); + this._currentTouchCount = mapTouches.length; + } + + _start(points: [Point, Point]) { + this._lastPoints = points; + if (isVertical(points[0].sub(points[1]))) { + // fingers are more horizontal than vertical + this._valid = false; + + } + } + + _move(points: [Point, Point], center: Point, e: TouchEvent) { + // If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register + if (this._map._cooperativeGestures && this._currentTouchCount < 3) { + return; + } + + const vectorA = points[0].sub(this._lastPoints[0]); + const vectorB = points[1].sub(this._lastPoints[1]); + + this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp); + if (!this._valid) return; + + this._lastPoints = points; + this._active = true; + const yDeltaAverage = (vectorA.y + vectorB.y) / 2; + const degreesPerPixelMoved = -0.5; + return { + pitchDelta: yDeltaAverage * degreesPerPixelMoved + }; + } + + gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number) { + if (this._valid !== undefined) return this._valid; + + const threshold = 2; + const movedA = vectorA.mag() >= threshold; + const movedB = vectorB.mag() >= threshold; + + // neither finger has moved a meaningful amount, wait + if (!movedA && !movedB) return; + + // One finger has moved and the other has not. + // If enough time has passed, decide it is not a pitch. + if (!movedA || !movedB) { + if (this._firstMove === undefined) { + this._firstMove = timeStamp; + } + + if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) { + // still waiting for a movement from the second finger + return undefined; + } else { + return false; + } + } + + const isSameDirection = vectorA.y > 0 === vectorB.y > 0; + return isVertical(vectorA) && isVertical(vectorB) && isSameDirection; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/handler_inertia.ts b/web/libraries/maplibre-gl/src/ui/handler_inertia.ts new file mode 100644 index 00000000..e68e7ccf --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler_inertia.ts @@ -0,0 +1,159 @@ +import {browser} from '../util/browser'; +import type {Map} from './map'; +import {bezier, clamp, extend} from '../util/util'; +import Point from '@mapbox/point-geometry'; +import type {DragPanOptions} from './handler/shim/drag_pan'; + +const defaultInertiaOptions = { + linearity: 0.3, + easing: bezier(0, 0, 0.3, 1), +}; + +const defaultPanInertiaOptions = extend({ + deceleration: 2500, + maxSpeed: 1400 +}, defaultInertiaOptions); + +const defaultZoomInertiaOptions = extend({ + deceleration: 20, + maxSpeed: 1400 +}, defaultInertiaOptions); + +const defaultBearingInertiaOptions = extend({ + deceleration: 1000, + maxSpeed: 360 +}, defaultInertiaOptions); + +const defaultPitchInertiaOptions = extend({ + deceleration: 1000, + maxSpeed: 90 +}, defaultInertiaOptions); + +export type InertiaOptions = { + linearity: number; + easing: (t: number) => number; + deceleration: number; + maxSpeed: number; +}; + +export type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent; + +export class HandlerInertia { + _map: Map; + _inertiaBuffer: Array<{ + time: number; + settings: any; + }>; + + constructor(map: Map) { + this._map = map; + this.clear(); + } + + clear() { + this._inertiaBuffer = []; + } + + record(settings: any) { + this._drainInertiaBuffer(); + this._inertiaBuffer.push({time: browser.now(), settings}); + } + + _drainInertiaBuffer() { + const inertia = this._inertiaBuffer, + now = browser.now(), + cutoff = 160; //msec + + while (inertia.length > 0 && now - inertia[0].time > cutoff) + inertia.shift(); + } + + _onMoveEnd(panInertiaOptions?: DragPanOptions | boolean) { + this._drainInertiaBuffer(); + if (this._inertiaBuffer.length < 2) { + return; + } + + const deltas = { + zoom: 0, + bearing: 0, + pitch: 0, + pan: new Point(0, 0), + pinchAround: undefined, + around: undefined + }; + + for (const {settings} of this._inertiaBuffer) { + deltas.zoom += settings.zoomDelta || 0; + deltas.bearing += settings.bearingDelta || 0; + deltas.pitch += settings.pitchDelta || 0; + if (settings.panDelta) deltas.pan._add(settings.panDelta); + if (settings.around) deltas.around = settings.around; + if (settings.pinchAround) deltas.pinchAround = settings.pinchAround; + } + + const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1]; + const duration = (lastEntry.time - this._inertiaBuffer[0].time); + + const easeOptions = {} as any; + + if (deltas.pan.mag()) { + const result = calculateEasing(deltas.pan.mag(), duration, extend({}, defaultPanInertiaOptions, panInertiaOptions || {})); + easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag()); + easeOptions.center = this._map.transform.center; + extendDuration(easeOptions, result); + } + + if (deltas.zoom) { + const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions); + easeOptions.zoom = this._map.transform.zoom + result.amount; + extendDuration(easeOptions, result); + } + + if (deltas.bearing) { + const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions); + easeOptions.bearing = this._map.transform.bearing + clamp(result.amount, -179, 179); + extendDuration(easeOptions, result); + } + + if (deltas.pitch) { + const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions); + easeOptions.pitch = this._map.transform.pitch + result.amount; + extendDuration(easeOptions, result); + } + + if (easeOptions.zoom || easeOptions.bearing) { + const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround; + easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter(); + } + + this.clear(); + return extend(easeOptions, { + noMoveStart: true + }); + + } +} + +// Unfortunately zoom, bearing, etc can't have different durations and easings so +// we need to choose one. We use the longest duration and it's corresponding easing. +function extendDuration(easeOptions, result) { + if (!easeOptions.duration || easeOptions.duration < result.duration) { + easeOptions.duration = result.duration; + easeOptions.easing = result.easing; + } +} + +function calculateEasing(amount, inertiaDuration: number, inertiaOptions) { + const {maxSpeed, linearity, deceleration} = inertiaOptions; + const speed = clamp( + amount * linearity / (inertiaDuration / 1000), + -maxSpeed, + maxSpeed); + const duration = Math.abs(speed) / (deceleration * linearity); + return { + easing: inertiaOptions.easing, + duration: duration * 1000, + amount: speed * (duration / 2) + }; +} diff --git a/web/libraries/maplibre-gl/src/ui/handler_manager.ts b/web/libraries/maplibre-gl/src/ui/handler_manager.ts new file mode 100644 index 00000000..6db05794 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/handler_manager.ts @@ -0,0 +1,622 @@ +import {Event} from '../util/evented'; +import {DOM} from '../util/dom'; +import {Map, CompleteMapOptions} from './map'; +import {HandlerInertia} from './handler_inertia'; +import {MapEventHandler, BlockableMapEventHandler} from './handler/map_event'; +import {BoxZoomHandler} from './handler/box_zoom'; +import {TapZoomHandler} from './handler/tap_zoom'; +import {generateMouseRotationHandler, generateMousePitchHandler, generateMousePanHandler} from './handler/mouse'; +import {TouchPanHandler} from './handler/touch_pan'; +import {TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch'; +import {KeyboardHandler} from './handler/keyboard'; +import {ScrollZoomHandler} from './handler/scroll_zoom'; +import {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom'; +import {ClickZoomHandler} from './handler/click_zoom'; +import {TapDragZoomHandler} from './handler/tap_drag_zoom'; +import {DragPanHandler} from './handler/shim/drag_pan'; +import {DragRotateHandler} from './handler/shim/drag_rotate'; +import {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch'; +import {extend} from '../util/util'; +import {browser} from '../util/browser'; +import Point from '@mapbox/point-geometry'; + +export type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent; + +const isMoving = p => p.zoom || p.drag || p.pitch || p.rotate; + +class RenderFrameEvent extends Event { + type: 'renderFrame'; + timeStamp: number; +} + +/** + * Handlers interpret dom events and return camera changes that should be + * applied to the map (`HandlerResult`s). The camera changes are all deltas. + * The handler itself should have no knowledge of the map's current state. + * This makes it easier to merge multiple results and keeps handlers simpler. + * For example, if there is a mousedown and mousemove, the mousePan handler + * would return a `panDelta` on the mousemove. + */ +export interface Handler { + enable(): void; + disable(): void; + isEnabled(): boolean; + isActive(): boolean; + /** + * `reset` can be called by the manager at any time and must reset everything to it's original state + */ + reset(): void; + // Handlers can optionally implement these methods. + // They are called with dom events whenever those dom evens are received. + readonly touchstart?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchmove?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchmoveWindow?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchend?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly touchcancel?: (e: TouchEvent, points: Array, mapTouches: Array) => HandlerResult | void; + readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void; + readonly contextmenu?: (e: MouseEvent) => HandlerResult | void; + readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void; + readonly keydown?: (e: KeyboardEvent) => HandlerResult | void; + readonly keyup?: (e: KeyboardEvent) => HandlerResult | void; + /** + * `renderFrame` is the only non-dom event. It is called during render + * frames and can be used to smooth camera changes (see scroll handler). + */ + readonly renderFrame?: () => HandlerResult | void; +} + +/** + * All handler methods that are called with events can optionally return a `HandlerResult`. + */ +export type HandlerResult = { + panDelta?: Point; + zoomDelta?: number; + bearingDelta?: number; + pitchDelta?: number; + /** + * the point to not move when changing the camera + */ + around?: Point | null; + /** + * same as above, except for pinch actions, which are given higher priority + */ + pinchAround?: Point | null; + /** + * A method that can fire a one-off easing by directly changing the map's camera. + */ + cameraAnimation?: (map: Map) => any; + /** + * The last three properties are needed by only one handler: scrollzoom. + * The DOM event to be used as the `originalEvent` on any camera change events. + */ + originalEvent?: Event; + /** + * Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom). + */ + needsRenderFrame?: boolean; + /** + * The camera changes won't get recorded for inertial zooming. + */ + noInertia?: boolean; +}; + +export type EventInProgress = { + handlerName: string; + originalEvent: Event; +} + +export type EventsInProgress = { + zoom?: EventInProgress; + pitch?: EventInProgress; + rotate?: EventInProgress; + drag?: EventInProgress; +} + +function hasChange(result: HandlerResult) { + return (result.panDelta && result.panDelta.mag()) || result.zoomDelta || result.bearingDelta || result.pitchDelta; +} + +export class HandlerManager { + _map: Map; + _el: HTMLElement; + _handlers: Array<{ + handlerName: string; + handler: Handler; + allowed: Array; + }>; + _eventsInProgress: EventsInProgress; + _frameId: number; + _inertia: HandlerInertia; + _bearingSnap: number; + _handlersById: {[x: string]: Handler}; + _updatingCamera: boolean; + _changes: Array<[HandlerResult, EventsInProgress, {[handlerName: string]: Event}]>; + _terrainMovement: boolean; + _zoom: {handlerName: string}; + _previousActiveHandlers: {[x: string]: Handler}; + _listeners: Array<[Window | Document | HTMLElement, string, { + passive?: boolean; + capture?: boolean; + } | undefined]>; + + constructor(map: Map, options: CompleteMapOptions) { + this._map = map; + this._el = this._map.getCanvasContainer(); + this._handlers = []; + this._handlersById = {}; + this._changes = []; + + this._inertia = new HandlerInertia(map); + this._bearingSnap = options.bearingSnap; + this._previousActiveHandlers = {}; + + // Track whether map is currently moving, to compute start/move/end events + this._eventsInProgress = {}; + + this._addDefaultHandlers(options); + + const el = this._el; + + this._listeners = [ + // This needs to be `passive: true` so that a double tap fires two + // pairs of touchstart/end events in iOS Safari 13. If this is set to + // `passive: false` then the second pair of events is only fired if + // preventDefault() is called on the first touchstart. Calling preventDefault() + // undesirably prevents click events. + [el, 'touchstart', {passive: true}], + // This needs to be `passive: false` so that scrolls and pinches can be + // prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12. + [el, 'touchmove', {passive: false}], + [el, 'touchend', undefined], + [el, 'touchcancel', undefined], + + [el, 'mousedown', undefined], + [el, 'mousemove', undefined], + [el, 'mouseup', undefined], + + // Bind window-level event listeners for move and up/end events. In the absence of + // the pointer capture API, which is not supported by all necessary platforms, + // window-level event listeners give us the best shot at capturing events that + // fall outside the map canvas element. Use `{capture: true}` for the move event + // to prevent map move events from being fired during a drag. + [document, 'mousemove', {capture: true}], + [document, 'mouseup', undefined], + + [el, 'mouseover', undefined], + [el, 'mouseout', undefined], + [el, 'dblclick', undefined], + [el, 'click', undefined], + + [el, 'keydown', {capture: false}], + [el, 'keyup', undefined], + + [el, 'wheel', {passive: false}], + [el, 'contextmenu', undefined], + + [window, 'blur', undefined] + ]; + + for (const [target, type, listenerOptions] of this._listeners) { + DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions); + } + } + + destroy() { + for (const [target, type, listenerOptions] of this._listeners) { + DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions); + } + } + + _addDefaultHandlers(options: CompleteMapOptions) { + const map = this._map; + const el = map.getCanvasContainer(); + this._add('mapEvent', new MapEventHandler(map, options)); + + const boxZoom = map.boxZoom = new BoxZoomHandler(map, options); + this._add('boxZoom', boxZoom); + if (options.interactive && options.boxZoom) { + boxZoom.enable(); + } + + const tapZoom = new TapZoomHandler(map); + const clickZoom = new ClickZoomHandler(map); + map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom); + this._add('tapZoom', tapZoom); + this._add('clickZoom', clickZoom); + if (options.interactive && options.doubleClickZoom) { + map.doubleClickZoom.enable(); + } + + const tapDragZoom = new TapDragZoomHandler(); + this._add('tapDragZoom', tapDragZoom); + + const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map); + this._add('touchPitch', touchPitch); + if (options.interactive && options.touchPitch) { + map.touchPitch.enable(options.touchPitch); + } + + const mouseRotate = generateMouseRotationHandler(options); + const mousePitch = generateMousePitchHandler(options); + map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch); + this._add('mouseRotate', mouseRotate, ['mousePitch']); + this._add('mousePitch', mousePitch, ['mouseRotate']); + if (options.interactive && options.dragRotate) { + map.dragRotate.enable(); + } + + const mousePan = generateMousePanHandler(options); + const touchPan = new TouchPanHandler(options, map); + map.dragPan = new DragPanHandler(el, mousePan, touchPan); + this._add('mousePan', mousePan); + this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']); + if (options.interactive && options.dragPan) { + map.dragPan.enable(options.dragPan); + } + + const touchRotate = new TwoFingersTouchRotateHandler(); + const touchZoom = new TwoFingersTouchZoomHandler(); + map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom); + this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']); + this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']); + if (options.interactive && options.touchZoomRotate) { + map.touchZoomRotate.enable(options.touchZoomRotate); + } + + const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame()); + this._add('scrollZoom', scrollZoom, ['mousePan']); + if (options.interactive && options.scrollZoom) { + map.scrollZoom.enable(options.scrollZoom); + } + + const keyboard = map.keyboard = new KeyboardHandler(map); + this._add('keyboard', keyboard); + if (options.interactive && options.keyboard) { + map.keyboard.enable(); + } + + this._add('blockableMapEvent', new BlockableMapEventHandler(map)); + } + + _add(handlerName: string, handler: Handler, allowed?: Array) { + this._handlers.push({handlerName, handler, allowed}); + this._handlersById[handlerName] = handler; + } + + stop(allowEndAnimation: boolean) { + // do nothing if this method was triggered by a gesture update + if (this._updatingCamera) return; + + for (const {handler} of this._handlers) { + handler.reset(); + } + this._inertia.clear(); + this._fireEvents({}, {}, allowEndAnimation); + this._changes = []; + } + + isActive() { + for (const {handler} of this._handlers) { + if (handler.isActive()) return true; + } + return false; + } + + isZooming() { + return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming(); + } + isRotating() { + return !!this._eventsInProgress.rotate; + } + + isMoving() { + return Boolean(isMoving(this._eventsInProgress)) || this.isZooming(); + } + + _blockedByActive(activeHandlers: {[x: string]: Handler}, allowed: Array, myName: string) { + for (const name in activeHandlers) { + if (name === myName) continue; + if (!allowed || allowed.indexOf(name) < 0) { + return true; + } + } + return false; + } + + handleWindowEvent = (e: { type: 'mousemove' | 'mouseup' | 'touchmove'}) => { + this.handleEvent(e, `${e.type}Window`); + }; + + _getMapTouches(touches: TouchList) { + const mapTouches = []; + for (const t of touches) { + const target = (t.target as any as Node); + if (this._el.contains(target)) { + mapTouches.push(t); + } + } + return mapTouches as any as TouchList; + } + + handleEvent = (e: Event, eventName?: keyof Handler) => { + + if (e.type === 'blur') { + this.stop(true); + return; + } + + this._updatingCamera = true; + + const inputEvent = e.type === 'renderFrame' ? undefined : e as InputEvent; + + /* + * We don't call e.preventDefault() for any events by default. + * Handlers are responsible for calling it where necessary. + */ + + const mergedHandlerResult: HandlerResult = {needsRenderFrame: false}; + const eventsInProgress: EventsInProgress = {}; + const activeHandlers = {}; + const eventTouches = (e as TouchEvent).touches; + + const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined; + const points = mapTouches ? DOM.touchPos(this._el, mapTouches) : DOM.mousePos(this._el, ((e as MouseEvent))); + + for (const {handlerName, handler, allowed} of this._handlers) { + if (!handler.isEnabled()) continue; + + let data: HandlerResult; + if (this._blockedByActive(activeHandlers, allowed, handlerName)) { + handler.reset(); + + } else { + if (handler[eventName || e.type]) { + data = handler[eventName || e.type](e, points, mapTouches); + this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent); + if (data && data.needsRenderFrame) { + this._triggerRenderFrame(); + } + } + } + + if (data || handler.isActive()) { + activeHandlers[handlerName] = handler; + } + } + + const deactivatedHandlers: {[handlerName: string]: Event} = {}; + for (const name in this._previousActiveHandlers) { + if (!activeHandlers[name]) { + deactivatedHandlers[name] = inputEvent; + } + } + this._previousActiveHandlers = activeHandlers; + + if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) { + this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]); + this._triggerRenderFrame(); + } + + if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) { + this._map._stop(true); + } + + this._updatingCamera = false; + + const {cameraAnimation} = mergedHandlerResult; + if (cameraAnimation) { + this._inertia.clear(); + this._fireEvents({}, {}, true); + this._changes = []; + cameraAnimation(this._map); + } + }; + + mergeHandlerResult(mergedHandlerResult: HandlerResult, + eventsInProgress: EventsInProgress, + handlerResult: HandlerResult, + name: string, + e?: InputEvent) { + if (!handlerResult) return; + + extend(mergedHandlerResult, handlerResult); + + const eventData = {handlerName: name, originalEvent: handlerResult.originalEvent || e}; + + // track which handler changed which camera property + if (handlerResult.zoomDelta !== undefined) { + eventsInProgress.zoom = eventData; + } + if (handlerResult.panDelta !== undefined) { + eventsInProgress.drag = eventData; + } + if (handlerResult.pitchDelta !== undefined) { + eventsInProgress.pitch = eventData; + } + if (handlerResult.bearingDelta !== undefined) { + eventsInProgress.rotate = eventData; + } + + } + + _applyChanges() { + const combined: HandlerResult = {}; + const combinedEventsInProgress: EventsInProgress = {}; + const combinedDeactivatedHandlers = {}; + + for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) { + + if (change.panDelta) combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta); + if (change.zoomDelta) combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta; + if (change.bearingDelta) combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta; + if (change.pitchDelta) combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta; + if (change.around !== undefined) combined.around = change.around; + if (change.pinchAround !== undefined) combined.pinchAround = change.pinchAround; + if (change.noInertia) combined.noInertia = change.noInertia; + + extend(combinedEventsInProgress, eventsInProgress); + extend(combinedDeactivatedHandlers, deactivatedHandlers); + } + + this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers); + this._changes = []; + } + + _updateMapTransform(combinedResult: HandlerResult, + combinedEventsInProgress: EventsInProgress, + deactivatedHandlers: {[handlerName: string]: Event}) { + const map = this._map; + const tr = map._getTransformForUpdate(); + const terrain = map.terrain; + + if (!hasChange(combinedResult) && !(terrain && this._terrainMovement)) { + return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true); + } + + let {panDelta, zoomDelta, bearingDelta, pitchDelta, around, pinchAround} = combinedResult; + + if (pinchAround !== undefined) { + around = pinchAround; + } + + // stop any ongoing camera animations (easeTo, flyTo) + map._stop(true); + + around = around || map.transform.centerPoint; + const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around); + if (bearingDelta) tr.bearing += bearingDelta; + if (pitchDelta) tr.pitch += pitchDelta; + if (zoomDelta) tr.zoom += zoomDelta; + + if (!terrain) { + tr.setLocationAtPoint(loc, around); + } else { + // when 3d-terrain is enabled act a little different: + // - dragging do not drag the picked point itself, instead it drags the map by pixel-delta. + // With this approach it is no longer possible to pick a point from somewhere near + // the horizon to the center in one move. + // So this logic avoids the problem, that in such cases you easily loose orientation. + if (!this._terrainMovement && + (combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) { + // When starting to drag or move, flag it and register moveend to clear flagging + this._terrainMovement = true; + this._map._elevationFreeze = true; + tr.setLocationAtPoint(loc, around); + this._map.once('moveend', () => { + this._map._elevationFreeze = false; + this._terrainMovement = false; + tr.recalculateZoom(map.terrain); + }); + } else if (combinedEventsInProgress.drag && this._terrainMovement) { + // drag map + tr.center = tr.pointLocation(tr.centerPoint.sub(panDelta)); + } else { + tr.setLocationAtPoint(loc, around); + } + } + + map._applyUpdatedTransform(tr); + + this._map._update(); + if (!combinedResult.noInertia) this._inertia.record(combinedResult); + this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true); + + } + + _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {[handlerName: string]: Event}, allowEndAnimation: boolean) { + + const wasMoving = isMoving(this._eventsInProgress); + const nowMoving = isMoving(newEventsInProgress); + + const startEvents = {}; + + for (const eventName in newEventsInProgress) { + const {originalEvent} = newEventsInProgress[eventName]; + if (!this._eventsInProgress[eventName]) { + startEvents[`${eventName}start`] = originalEvent; + } + this._eventsInProgress[eventName] = newEventsInProgress[eventName]; + } + + // fire start events only after this._eventsInProgress has been updated + if (!wasMoving && nowMoving) { + this._fireEvent('movestart', nowMoving.originalEvent); + } + + for (const name in startEvents) { + this._fireEvent(name, startEvents[name]); + } + + if (nowMoving) { + this._fireEvent('move', nowMoving.originalEvent); + } + + for (const eventName in newEventsInProgress) { + const {originalEvent} = newEventsInProgress[eventName]; + this._fireEvent(eventName, originalEvent); + } + + const endEvents = {}; + + let originalEndEvent; + for (const eventName in this._eventsInProgress) { + const {handlerName, originalEvent} = this._eventsInProgress[eventName]; + if (!this._handlersById[handlerName].isActive()) { + delete this._eventsInProgress[eventName]; + originalEndEvent = deactivatedHandlers[handlerName] || originalEvent; + endEvents[`${eventName}end`] = originalEndEvent; + } + } + + for (const name in endEvents) { + this._fireEvent(name, endEvents[name]); + } + + const stillMoving = isMoving(this._eventsInProgress); + if (allowEndAnimation && (wasMoving || nowMoving) && !stillMoving) { + this._updatingCamera = true; + const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions); + + const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap; + + if (inertialEase && (inertialEase.essential || !browser.prefersReducedMotion)) { + if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) { + inertialEase.bearing = 0; + } + inertialEase.freezeElevation = true; + this._map.easeTo(inertialEase, {originalEvent: originalEndEvent}); + } else { + this._map.fire(new Event('moveend', {originalEvent: originalEndEvent})); + if (shouldSnapToNorth(this._map.getBearing())) { + this._map.resetNorth(); + } + } + this._updatingCamera = false; + } + + } + + _fireEvent(type: string, e?: Event) { + this._map.fire(new Event(type, e ? {originalEvent: e} : {})); + } + + _requestFrame() { + this._map.triggerRepaint(); + return this._map._renderTaskQueue.add(timeStamp => { + delete this._frameId; + this.handleEvent(new RenderFrameEvent('renderFrame', {timeStamp})); + this._applyChanges(); + }); + } + + _triggerRenderFrame() { + if (this._frameId === undefined) { + this._frameId = this._requestFrame(); + } + } +} diff --git a/web/libraries/maplibre-gl/src/ui/hash.test.ts b/web/libraries/maplibre-gl/src/ui/hash.test.ts new file mode 100644 index 00000000..d0fd3cb1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/hash.test.ts @@ -0,0 +1,292 @@ +import {Hash} from './hash'; +import {createMap as globalCreateMap, beforeMapTest} from '../util/test/util'; + +describe('hash', () => { + function createHash(name: string = undefined) { + const hash = new Hash(name); + hash._updateHash = hash._updateHashUnthrottled.bind(hash); + return hash; + } + + function createMap() { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + return globalCreateMap({container}, undefined); + } + + let map; + + beforeEach(() => { + beforeMapTest(); + map = createMap(); + }); + + afterEach(() => { + if (map.removed === false) { + map.remove(); + } + window.location.hash = ''; + }); + + test('#addTo', () => { + const hash = createHash(); + + expect(hash._map).toBeFalsy(); + + hash.addTo(map); + + expect(hash._map).toBeTruthy(); + }); + + test('#remove', () => { + const hash = createHash() + .addTo(map); + + expect(hash._map).toBeTruthy(); + + hash.remove(); + + expect(hash._map).toBeFalsy(); + }); + + test('#_onHashChange', () => { + const hash = createHash() + .addTo(map); + + window.location.hash = '#10/3.00/-1.00'; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(-1); + expect(map.getCenter().lat).toBe(3); + expect(map.getZoom()).toBe(10); + expect(map.getBearing() === 0 ? 0 : map.getBearing()).toBe(0); + expect(map.getPitch()).toBe(0); + + // map is created with `interactive: false` + // so explicitly enable rotation for this test + map.dragRotate.enable(); + map.touchZoomRotate.enable(); + + window.location.hash = '#5/1.00/0.50/30/60'; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(0.5); + expect(map.getCenter().lat).toBe(1); + expect(map.getZoom()).toBe(5); + expect(map.getBearing()).toBe(30); + expect(map.getPitch()).toBe(60); + + // disable rotation to test that updating + // the hash's bearing won't change the map + map.dragRotate.disable(); + map.touchZoomRotate.disable(); + + window.location.hash = '#5/1.00/0.50/-45/60'; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(0.5); + expect(map.getCenter().lat).toBe(1); + expect(map.getZoom()).toBe(5); + expect(map.getBearing()).toBe(30); + expect(map.getPitch()).toBe(60); + + // test that a hash with no bearing resets + // to the previous bearing when rotation is disabled + window.location.hash = '#5/1.00/0.50/'; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(0.5); + expect(map.getCenter().lat).toBe(1); + expect(map.getZoom()).toBe(5); + expect(map.getBearing()).toBe(30); + expect(window.location.hash).toBe('#5/1/0.5/30'); + + window.location.hash = '#4/wrongly/formed/hash'; + + expect(hash._onHashChange()).toBeFalsy(); + + window.location.hash = '#map=10/3.00/-1.00&foo=bar'; + + expect(hash._onHashChange()).toBeFalsy(); + }); + + test('#_onHashChange empty', () => { + const hash = createHash() + .addTo(map); + + window.location.hash = '#10/3.00/-1.00'; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(-1); + expect(map.getCenter().lat).toBe(3); + expect(map.getZoom()).toBe(10); + expect(map.getBearing() === 0 ? 0 : map.getBearing()).toBe(0); + expect(map.getPitch()).toBe(0); + + window.location.hash = ''; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(-1); + expect(map.getCenter().lat).toBe(3); + expect(map.getZoom()).toBe(10); + expect(map.getBearing() === 0 ? 0 : map.getBearing()).toBe(0); + expect(map.getPitch()).toBe(0); + }); + + test('#_onHashChange named', () => { + const hash = createHash('map') + .addTo(map); + + window.location.hash = '#map=10/3.00/-1.00&foo=bar'; + + hash._onHashChange(); + + expect(map.getCenter().lng).toBe(-1); + expect(map.getCenter().lat).toBe(3); + expect(map.getZoom()).toBe(10); + expect(map.getBearing() === 0 ? 0 : map.getBearing()).toBe(0); + expect(map.getPitch()).toBe(0); + + window.location.hash = '#map&foo=bar'; + + expect(hash._onHashChange()).toBeFalsy(); + + window.location.hash = '#map=4/5/baz&foo=bar'; + + expect(hash._onHashChange()).toBeFalsy(); + + window.location.hash = '#5/1.00/0.50/30/60'; + + expect(hash._onHashChange()).toBeFalsy(); + }); + + test('#_getCurrentHash', () => { + const hash = createHash() + .addTo(map); + + window.location.hash = '#10/3.00/-1.00'; + + const currentHash = hash._getCurrentHash(); + + expect(currentHash[0]).toBe('10'); + expect(currentHash[1]).toBe('3.00'); + expect(currentHash[2]).toBe('-1.00'); + }); + + test('#_getCurrentHash named', () => { + const hash = createHash('map') + .addTo(map); + + window.location.hash = '#map=10/3.00/-1.00&foo=bar'; + + let currentHash = hash._getCurrentHash(); + + expect(currentHash[0]).toBe('10'); + expect(currentHash[1]).toBe('3.00'); + expect(currentHash[2]).toBe('-1.00'); + + window.location.hash = '#baz&map=10/3.00/-1.00'; + + currentHash = hash._getCurrentHash(); + + expect(currentHash[0]).toBe('10'); + expect(currentHash[1]).toBe('3.00'); + expect(currentHash[2]).toBe('-1.00'); + }); + + test('#_updateHash', () => { + function getHash() { + return window.location.hash.split('/'); + } + + createHash() + .addTo(map); + + expect(window.location.hash).toBeFalsy(); + + map.setZoom(3); + map.setCenter([2.0, 1.0]); + + expect(window.location.hash).toBeTruthy(); + + let newHash = getHash(); + + expect(newHash).toHaveLength(3); + expect(newHash[0]).toBe('#3'); + expect(newHash[1]).toBe('1'); + expect(newHash[2]).toBe('2'); + + map.setPitch(60); + + newHash = getHash(); + + expect(newHash).toHaveLength(5); + expect(newHash[0]).toBe('#3'); + expect(newHash[1]).toBe('1'); + expect(newHash[2]).toBe('2'); + expect(newHash[3]).toBe('0'); + expect(newHash[4]).toBe('60'); + + map.setBearing(135); + + newHash = getHash(); + + expect(newHash).toHaveLength(5); + expect(newHash[0]).toBe('#3'); + expect(newHash[1]).toBe('1'); + expect(newHash[2]).toBe('2'); + expect(newHash[3]).toBe('135'); + expect(newHash[4]).toBe('60'); + }); + + test('#_updateHash named', () => { + createHash('map') + .addTo(map); + + expect(window.location.hash).toBeFalsy(); + + map.setZoom(3); + map.setCenter([1.0, 2.0]); + + expect(window.location.hash).toBeTruthy(); + + expect(window.location.hash).toBe('#map=3/2/1'); + + map.setPitch(60); + + expect(window.location.hash).toBe('#map=3/2/1/0/60'); + + map.setBearing(135); + + expect(window.location.hash).toBe('#map=3/2/1/135/60'); + + window.location.hash += '&foo=bar'; + + map.setZoom(7); + + expect(window.location.hash).toBe('#map=7/2/1/135/60&foo=bar'); + + window.location.hash = '#baz&map=7/2/1/135/60&foo=bar'; + + map.setCenter([2.0, 1.0]); + + expect(window.location.hash).toBe('#baz&map=7/1/2/135/60&foo=bar'); + }); + + test('map#remove', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + + map.remove(); + + expect(map).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/hash.ts b/web/libraries/maplibre-gl/src/ui/hash.ts new file mode 100644 index 00000000..ad4d4c81 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/hash.ts @@ -0,0 +1,137 @@ +import {throttle} from '../util/throttle'; + +import type {Map} from './map'; + +/** + * Adds the map's position to its page's location hash. + * Passed as an option to the map object. + * + * @group Markers and Controls + */ +export class Hash { + _map: Map; + _hashName: string; + + constructor(hashName?: string | null) { + this._hashName = hashName && encodeURIComponent(hashName); + } + + /** + * Map element to listen for coordinate changes + * + * @param map - The map object + * @returns `this` + */ + addTo(map: Map) { + this._map = map; + addEventListener('hashchange', this._onHashChange, false); + this._map.on('moveend', this._updateHash); + return this; + } + + /** + * Removes hash + * + * @returns `this` + */ + remove() { + removeEventListener('hashchange', this._onHashChange, false); + this._map.off('moveend', this._updateHash); + clearTimeout(this._updateHash()); + + delete this._map; + return this; + } + + getHashString(mapFeedback?: boolean) { + const center = this._map.getCenter(), + zoom = Math.round(this._map.getZoom() * 100) / 100, + // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px + precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10), + m = Math.pow(10, precision), + lng = Math.round(center.lng * m) / m, + lat = Math.round(center.lat * m) / m, + bearing = this._map.getBearing(), + pitch = this._map.getPitch(); + let hash = ''; + if (mapFeedback) { + // new map feedback site has some constraints that don't allow + // us to use the same hash format as we do for the Map hash option. + hash += `/${lng}/${lat}/${zoom}`; + } else { + hash += `${zoom}/${lat}/${lng}`; + } + + if (bearing || pitch) hash += (`/${Math.round(bearing * 10) / 10}`); + if (pitch) hash += (`/${Math.round(pitch)}`); + + if (this._hashName) { + const hashName = this._hashName; + let found = false; + const parts = window.location.hash.slice(1).split('&').map(part => { + const key = part.split('=')[0]; + if (key === hashName) { + found = true; + return `${key}=${hash}`; + } + return part; + }).filter(a => a); + if (!found) { + parts.push(`${hashName}=${hash}`); + } + return `#${parts.join('&')}`; + } + + return `#${hash}`; + } + + _getCurrentHash = () => { + // Get the current hash from location, stripped from its number sign + const hash = window.location.hash.replace('#', ''); + if (this._hashName) { + // Split the parameter-styled hash into parts and find the value we need + let keyval; + hash.split('&').map( + part => part.split('=') + ).forEach(part => { + if (part[0] === this._hashName) { + keyval = part; + } + }); + return (keyval ? keyval[1] || '' : '').split('/'); + } + return hash.split('/'); + }; + + _onHashChange = () => { + const loc = this._getCurrentHash(); + if (loc.length >= 3 && !loc.some(v => isNaN(v))) { + const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : this._map.getBearing(); + this._map.jumpTo({ + center: [+loc[2], +loc[1]], + zoom: +loc[0], + bearing, + pitch: +(loc[4] || 0) + }); + return true; + } + return false; + }; + + _updateHashUnthrottled = () => { + // Replace if already present, else append the updated hash string + const location = window.location.href.replace(/(#.+)?$/, this.getHashString()); + try { + window.history.replaceState(window.history.state, null, location); + } catch (SecurityError) { + // IE11 does not allow this if the page is within an iframe created + // with iframe.contentWindow.document.write(...). + // https://github.com/mapbox/mapbox-gl-js/issues/7410 + } + }; + + /** + * Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds. + */ + _updateHash: () => ReturnType = throttle(this._updateHashUnthrottled, 30 * 1000 / 100); +} diff --git a/web/libraries/maplibre-gl/src/ui/map.test.ts b/web/libraries/maplibre-gl/src/ui/map.test.ts new file mode 100755 index 00000000..ad577fc7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map.test.ts @@ -0,0 +1,2923 @@ +import {Map, MapOptions} from './map'; +import {createMap, setErrorWebGlContext, beforeMapTest} from '../util/test/util'; +import {LngLat} from '../geo/lng_lat'; +import {Tile} from '../source/tile'; +import {OverscaledTileID} from '../source/tile_id'; +import {Event, ErrorEvent} from '../util/evented'; +import simulate from '../../test/unit/lib/simulate_interaction'; +import {fixedLngLat, fixedNum} from '../../test/unit/lib/fixed'; +import {GeoJSONSourceSpecification, LayerSpecification, SourceSpecification, StyleSpecification} from '@maplibre/maplibre-gl-style-spec'; +import {RequestTransformFunction} from '../util/request_manager'; +import {extend} from '../util/util'; +import {LngLatBoundsLike} from '../geo/lng_lat_bounds'; +import {IControl} from './control/control'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {fakeServer, FakeServer} from 'nise'; +import {CameraOptions} from './camera'; +import {Terrain} from '../render/terrain'; +import {mercatorZfromAltitude} from '../geo/mercator_coordinate'; +import {Transform} from '../geo/transform'; +import {StyleImageInterface} from '../style/style_image'; +import {Style} from '../style/style'; +import {MapSourceDataEvent} from './events'; +import {config} from '../util/config'; + +function createStyleSource() { + return { + type: 'geojson', + data: { + type: 'FeatureCollection', + features: [] + } + } as SourceSpecification; +} + +let server: FakeServer; + +beforeEach(() => { + beforeMapTest(); + global.fetch = null; + server = fakeServer.create(); +}); + +afterEach(() => { + server.restore(); +}); + +describe('Map', () => { + + test('version', () => { + const map = createMap({interactive: true, style: null}); + + expect(typeof map.version === 'string').toBeTruthy(); + + // Semver regex: https://gist.github.com/jhorsman/62eeea161a13b80e39f5249281e17c39 + // Backslashes are doubled to escape them + const regexp = new RegExp('^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$'); + expect(regexp.test(map.version)).toBeTruthy(); + }); + + test('constructor', () => { + const map = createMap({interactive: true, style: null}); + expect(map.getContainer()).toBeTruthy(); + expect(map.getStyle()).toBeUndefined(); + expect(map.boxZoom.isEnabled()).toBeTruthy(); + expect(map.doubleClickZoom.isEnabled()).toBeTruthy(); + expect(map.dragPan.isEnabled()).toBeTruthy(); + expect(map.dragRotate.isEnabled()).toBeTruthy(); + expect(map.keyboard.isEnabled()).toBeTruthy(); + expect(map.scrollZoom.isEnabled()).toBeTruthy(); + expect(map.touchZoomRotate.isEnabled()).toBeTruthy(); + expect(() => { + new Map({ + container: 'anElementIdWhichDoesNotExistInTheDocument' + } as any as MapOptions); + }).toThrow( + new Error('Container \'anElementIdWhichDoesNotExistInTheDocument\' not found.') + ); + }); + + test('bad map-specific token breaks map', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'offsetWidth', {value: 512}); + Object.defineProperty(container, 'offsetHeight', {value: 512}); + createMap(); + //t.error(); + }); + + test('initial bounds in constructor options', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'offsetWidth', {value: 512}); + Object.defineProperty(container, 'offsetHeight', {value: 512}); + + const bounds = [[-133, 16], [-68, 50]]; + const map = createMap({container, bounds}); + + expect(fixedLngLat(map.getCenter(), 4)).toEqual({lng: -100.5, lat: 34.7171}); + expect(fixedNum(map.getZoom(), 3)).toBe(2.113); + }); + + test('initial bounds options in constructor options', () => { + const bounds = [[-133, 16], [-68, 50]]; + + const map = (fitBoundsOptions) => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'offsetWidth', {value: 512}); + Object.defineProperty(container, 'offsetHeight', {value: 512}); + return createMap({container, bounds, fitBoundsOptions}); + }; + + const unpadded = map(undefined); + const padded = map({padding: 100}); + + expect(unpadded.getZoom() > padded.getZoom()).toBeTruthy(); + }); + + describe('disables handlers', () => { + test('disables all handlers', () => { + const map = createMap({interactive: false}); + + expect(map.boxZoom.isEnabled()).toBeFalsy(); + expect(map.doubleClickZoom.isEnabled()).toBeFalsy(); + expect(map.dragPan.isEnabled()).toBeFalsy(); + expect(map.dragRotate.isEnabled()).toBeFalsy(); + expect(map.keyboard.isEnabled()).toBeFalsy(); + expect(map.scrollZoom.isEnabled()).toBeFalsy(); + expect(map.touchZoomRotate.isEnabled()).toBeFalsy(); + }); + + const handlerNames = [ + 'scrollZoom', + 'boxZoom', + 'dragRotate', + 'dragPan', + 'keyboard', + 'doubleClickZoom', + 'touchZoomRotate' + ]; + handlerNames.forEach((handlerName) => { + test(`disables "${handlerName}" handler`, () => { + const options = {}; + options[handlerName] = false; + const map = createMap(options); + + expect(map[handlerName].isEnabled()).toBeFalsy(); + + }); + }); + + }); + + test('emits load event after a style is set', done => { + const map = new Map({container: window.document.createElement('div')} as any as MapOptions); + + const fail = () => done('test failed'); + const pass = () => done(); + + map.on('load', fail); + + setTimeout(() => { + map.off('load', fail); + map.on('load', pass); + map.setStyle(createStyle()); + }, 1); + + }); + + describe('#mapOptions', () => { + test('maxTileCacheZoomLevels: Default value is set', () => { + const map = createMap(); + expect(map._maxTileCacheZoomLevels).toBe(config.MAX_TILE_CACHE_ZOOM_LEVELS); + }); + + test('maxTileCacheZoomLevels: Value can be set via map options', () => { + const map = createMap({maxTileCacheZoomLevels: 1}); + expect(map._maxTileCacheZoomLevels).toBe(1); + }); + + test('Style validation is enabled by default', () => { + let validationOption = false; + jest.spyOn(Style.prototype, 'loadJSON').mockImplementationOnce((styleJson, options) => { + validationOption = options.validate; + }); + createMap(); + expect(validationOption).toBeTruthy(); + }); + + test('Style validation disabled using mapOptions', () => { + let validationOption = true; + jest.spyOn(Style.prototype, 'loadJSON').mockImplementationOnce((styleJson, options) => { + validationOption = options.validate; + }); + createMap({validateStyle: false}); + + expect(validationOption).toBeFalsy(); + }); + + test('fadeDuration is set after first idle event', async () => { + let idleTriggered = false; + const fadeDuration = 100; + const spy = jest.spyOn(Style.prototype, 'update').mockImplementation((parameters: EvaluationParameters) => { + if (!idleTriggered) { + expect(parameters.fadeDuration).toBe(0); + } else { + expect(parameters.fadeDuration).toBe(fadeDuration); + } + }); + const style = createStyle(); + const map = createMap({style, fadeDuration}); + await map.once('idle'); + idleTriggered = true; + map.zoomTo(0.5, {duration: 100}); + spy.mockRestore(); + }); + }); + + describe('#setStyle', () => { + test('returns self', () => { + const map = new Map({container: window.document.createElement('div')} as any as MapOptions); + expect(map.setStyle({ + version: 8, + sources: {}, + layers: [] + })).toBe(map); + }); + + test('sets up event forwarding', () => { + createMap({}, (error, map) => { + expect(error).toBeFalsy(); + + const events = []; + function recordEvent(event) { events.push(event.type); } + + map.on('error', recordEvent); + map.on('data', recordEvent); + map.on('dataloading', recordEvent); + + map.style.fire(new Event('error')); + map.style.fire(new Event('data')); + map.style.fire(new Event('dataloading')); + + expect(events).toEqual([ + 'error', + 'data', + 'dataloading', + ]); + + }); + }); + + test('fires *data and *dataloading events', () => { + createMap({}, (error, map) => { + expect(error).toBeFalsy(); + + const events = []; + function recordEvent(event) { events.push(event.type); } + + map.on('styledata', recordEvent); + map.on('styledataloading', recordEvent); + map.on('sourcedata', recordEvent); + map.on('sourcedataloading', recordEvent); + map.on('tiledata', recordEvent); + map.on('tiledataloading', recordEvent); + + map.style.fire(new Event('data', {dataType: 'style'})); + map.style.fire(new Event('dataloading', {dataType: 'style'})); + map.style.fire(new Event('data', {dataType: 'source'})); + map.style.fire(new Event('dataloading', {dataType: 'source'})); + map.style.fire(new Event('data', {dataType: 'tile'})); + map.style.fire(new Event('dataloading', {dataType: 'tile'})); + + expect(events).toEqual([ + 'styledata', + 'styledataloading', + 'sourcedata', + 'sourcedataloading', + 'tiledata', + 'tiledataloading' + ]); + + }); + }); + + test('can be called more than once', () => { + const map = createMap(); + + map.setStyle({version: 8, sources: {}, layers: []}, {diff: false}); + map.setStyle({version: 8, sources: {}, layers: []}, {diff: false}); + + }); + + test('setStyle back to the first style should work', done => { + const redStyle = {version: 8 as const, sources: {}, layers: [ + {id: 'background', type: 'background' as const, paint: {'background-color': 'red'}}, + ]}; + const blueStyle = {version: 8 as const, sources: {}, layers: [ + {id: 'background', type: 'background' as const, paint: {'background-color': 'blue'}}, + ]}; + const map = createMap({style: redStyle}); + map.setStyle(blueStyle); + map.once('style.load', () => { + map.setStyle(redStyle); + const serializedStyle = map.style.serialize(); + expect(serializedStyle.layers[0].paint['background-color']).toBe('red'); + done(); + }); + }); + + test('style transform overrides unmodified map transform', done => { + const map = new Map({container: window.document.createElement('div')} as any as MapOptions); + map.transform.lngRange = [-120, 140]; + map.transform.latRange = [-60, 80]; + map.transform.resize(600, 400); + expect(map.transform.zoom).toBe(0.6983039737971014); + expect(map.transform.unmodified).toBeTruthy(); + map.setStyle(createStyle()); + map.on('style.load', () => { + expect(fixedLngLat(map.transform.center)).toEqual(fixedLngLat({lng: -73.9749, lat: 40.7736})); + expect(fixedNum(map.transform.zoom)).toBe(12.5); + expect(fixedNum(map.transform.bearing)).toBe(29); + expect(fixedNum(map.transform.pitch)).toBe(50); + done(); + }); + }); + + test('style transform does not override map transform modified via options', done => { + const map = new Map({container: window.document.createElement('div'), zoom: 10, center: [-77.0186, 38.8888]} as any as MapOptions); + expect(map.transform.unmodified).toBeFalsy(); + map.setStyle(createStyle()); + map.on('style.load', () => { + expect(fixedLngLat(map.transform.center)).toEqual(fixedLngLat({lng: -77.0186, lat: 38.8888})); + expect(fixedNum(map.transform.zoom)).toBe(10); + expect(fixedNum(map.transform.bearing)).toBe(0); + expect(fixedNum(map.transform.pitch)).toBe(0); + done(); + }); + }); + + test('style transform does not override map transform modified via setters', done => { + const map = new Map({container: window.document.createElement('div')} as any as MapOptions); + expect(map.transform.unmodified).toBeTruthy(); + map.setZoom(10); + map.setCenter([-77.0186, 38.8888]); + expect(map.transform.unmodified).toBeFalsy(); + map.setStyle(createStyle()); + map.on('style.load', () => { + expect(fixedLngLat(map.transform.center)).toEqual(fixedLngLat({lng: -77.0186, lat: 38.8888})); + expect(fixedNum(map.transform.zoom)).toBe(10); + expect(fixedNum(map.transform.bearing)).toBe(0); + expect(fixedNum(map.transform.pitch)).toBe(0); + done(); + }); + }); + + test('passing null removes style', () => { + const map = createMap(); + const style = map.style; + expect(style).toBeTruthy(); + jest.spyOn(style, '_remove'); + map.setStyle(null); + expect(style._remove).toHaveBeenCalledTimes(1); + }); + + test('passing null releases the worker', () => { + const map = createMap(); + const spyWorkerPoolAcquire = jest.spyOn(map.style.dispatcher.workerPool, 'acquire'); + const spyWorkerPoolRelease = jest.spyOn(map.style.dispatcher.workerPool, 'release'); + + map.setStyle({version: 8, sources: {}, layers: []}, {diff: false}); + expect(spyWorkerPoolAcquire).toHaveBeenCalledTimes(1); + expect(spyWorkerPoolRelease).toHaveBeenCalledTimes(0); + + spyWorkerPoolAcquire.mockClear(); + map.setStyle(null); + expect(spyWorkerPoolAcquire).toHaveBeenCalledTimes(0); + expect(spyWorkerPoolRelease).toHaveBeenCalledTimes(1); + + // Cleanup + spyWorkerPoolAcquire.mockClear(); + spyWorkerPoolRelease.mockClear(); + }); + + test('transformStyle should copy the source and the layer into next style', done => { + const style = extend(createStyle(), { + sources: { + maplibre: { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } + }, + layers: [{ + id: 'layerId0', + type: 'circle', + source: 'maplibre', + 'source-layer': 'sourceLayer' + }, { + id: 'layerId1', + type: 'circle', + source: 'maplibre', + 'source-layer': 'sourceLayer' + }] + }); + + const map = createMap({style}); + map.setStyle(createStyle(), { + diff: false, + transformStyle: (prevStyle, nextStyle) => ({ + ...nextStyle, + sources: { + ...nextStyle.sources, + maplibre: prevStyle.sources.maplibre + }, + layers: [ + ...nextStyle.layers, + prevStyle.layers[0] + ] + }) + }); + + map.on('style.load', () => { + const loadedStyle = map.style.serialize(); + expect('maplibre' in loadedStyle.sources).toBeTruthy(); + expect(loadedStyle.layers[0].id).toBe(style.layers[0].id); + expect(loadedStyle.layers).toHaveLength(1); + done(); + }); + }); + + test('delayed setStyle with transformStyle should copy the source and the layer into next style with diffing', done => { + const style = extend(createStyle(), { + sources: { + maplibre: { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } + }, + layers: [{ + id: 'layerId0', + type: 'circle', + source: 'maplibre', + 'source-layer': 'sourceLayer' + }, { + id: 'layerId1', + type: 'circle', + source: 'maplibre', + 'source-layer': 'sourceLayer' + }] + }); + + const map = createMap({style}); + window.setTimeout(() => { + map.setStyle(createStyle(), { + diff: true, + transformStyle: (prevStyle, nextStyle) => ({ + ...nextStyle, + sources: { + ...nextStyle.sources, + maplibre: prevStyle.sources.maplibre + }, + layers: [ + ...nextStyle.layers, + prevStyle.layers[0] + ] + }) + }); + + const loadedStyle = map.style.serialize(); + expect('maplibre' in loadedStyle.sources).toBeTruthy(); + expect(loadedStyle.layers[0].id).toBe(style.layers[0].id); + expect(loadedStyle.layers).toHaveLength(1); + done(); + }, 100); + }); + + test('transformStyle should get called when passed to setStyle after the map is initialised without a style', done => { + const map = createMap({deleteStyle: true}); + map.setStyle(createStyle(), { + diff: true, + transformStyle: (prevStyle, nextStyle) => { + expect(prevStyle).toBeUndefined(); + + return { + ...nextStyle, + sources: { + maplibre: { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } + }, + layers: [{ + id: 'layerId0', + type: 'circle', + source: 'maplibre', + 'source-layer': 'sourceLayer' + }] + }; + } + }); + + map.on('style.load', () => { + const loadedStyle = map.style.serialize(); + expect('maplibre' in loadedStyle.sources).toBeTruthy(); + expect(loadedStyle.layers[0].id).toBe('layerId0'); + done(); + }); + }); + + test('map load should be fired when transformStyle is used on setStyle after the map is initialised without a style', done => { + const map = createMap({deleteStyle: true}); + map.setStyle({version: 8, sources: {}, layers: []}, { + diff: true, + transformStyle: (prevStyle, nextStyle) => { + expect(prevStyle).toBeUndefined(); + expect(nextStyle).toBeDefined(); + return createStyle(); + } + }); + map.on('load', () => done()); + }); + + test('Override default style validation', () => { + let validationOption = true; + jest.spyOn(Style.prototype, 'loadJSON').mockImplementationOnce((styleJson, options) => { + validationOption = options.validate; + }); + const map = createMap({style: null}); + map.setStyle({version: 8, sources: {}, layers: []}, {validate: false}); + + expect(validationOption).toBeFalsy(); + }); + }); + + describe('#setTransformRequest', () => { + test('returns self', () => { + const transformRequest = (() => {}) as any as RequestTransformFunction; + const map = new Map({container: window.document.createElement('div')} as any as MapOptions); + expect(map.setTransformRequest(transformRequest)).toBe(map); + expect(map._requestManager._transformRequestFn).toBe(transformRequest); + }); + + test('can be called more than once', () => { + const map = createMap(); + + const transformRequest = (() => {}) as any as RequestTransformFunction; + map.setTransformRequest(transformRequest); + map.setTransformRequest(transformRequest); + }); + }); + + describe('#is_Loaded', () => { + + test('Map#isSourceLoaded', done => { + const style = createStyle(); + const map = createMap({style}); + + map.on('load', () => { + map.on('data', (e) => { + if (e.dataType === 'source' && e.sourceDataType === 'idle') { + expect(map.isSourceLoaded('geojson')).toBe(true); + done(); + } + }); + map.addSource('geojson', createStyleSource()); + expect(map.isSourceLoaded('geojson')).toBe(false); + }); + }); + + test('Map#isSourceLoaded (equivalent to event.isSourceLoaded)', done => { + const style = createStyle(); + const map = createMap({style}); + + map.on('load', () => { + map.on('data', (e) => { + if (e.dataType === 'source' && 'source' in e) { + const sourceDataEvent = e as MapSourceDataEvent; + expect(map.isSourceLoaded('geojson')).toBe(sourceDataEvent.isSourceLoaded); + if (sourceDataEvent.sourceDataType === 'idle') { + done(); + } + } + }); + map.addSource('geojson', createStyleSource()); + expect(map.isSourceLoaded('geojson')).toBe(false); + }); + }); + + test('Map#isStyleLoaded', done => { + const style = createStyle(); + const map = createMap({style}); + + expect(map.isStyleLoaded()).toBe(false); + map.on('load', () => { + expect(map.isStyleLoaded()).toBe(true); + done(); + }); + }); + + test('Map#areTilesLoaded', done => { + const style = createStyle(); + const map = createMap({style}); + expect(map.areTilesLoaded()).toBe(true); + map.on('load', () => { + const fakeTileId = new OverscaledTileID(0, 0, 0, 0, 0); + map.addSource('geojson', createStyleSource()); + map.style.sourceCaches.geojson._tiles[fakeTileId.key] = new Tile(fakeTileId, undefined); + expect(map.areTilesLoaded()).toBe(false); + map.style.sourceCaches.geojson._tiles[fakeTileId.key].state = 'loaded'; + expect(map.areTilesLoaded()).toBe(true); + done(); + }); + }); + }); + + describe('#getStyle', () => { + test('returns undefined if the style has not loaded yet', done => { + const style = createStyle(); + const map = createMap({style}); + expect(map.getStyle()).toBeUndefined(); + done(); + }); + + test('returns the style', done => { + const style = createStyle(); + const map = createMap({style}); + + map.on('load', () => { + expect(map.getStyle()).toEqual(style); + done(); + }); + }); + + test('returns the style with added sources', done => { + const style = createStyle(); + const map = createMap({style}); + + map.on('load', () => { + map.addSource('geojson', createStyleSource()); + expect(map.getStyle()).toEqual(extend(createStyle(), { + sources: {geojson: createStyleSource()} + })); + done(); + }); + }); + + test('fires an error on checking if non-existant source is loaded', done => { + const style = createStyle(); + const map = createMap({style}); + + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/There is no source with ID/); + done(); + }); + map.isSourceLoaded('geojson'); + }); + }); + + test('returns the style with added layers', done => { + const style = createStyle(); + const map = createMap({style}); + const layer = { + id: 'background', + type: 'background' + } as LayerSpecification; + + map.on('load', () => { + map.addLayer(layer); + expect(map.getStyle()).toEqual(extend(createStyle(), { + layers: [layer] + })); + done(); + }); + }); + + test('a layer can be added even if a map is created without a style', () => { + const map = createMap({deleteStyle: true}); + const layer = { + id: 'background', + type: 'background' + } as LayerSpecification; + map.addLayer(layer); + }); + + test('a source can be added even if a map is created without a style', () => { + const map = createMap({deleteStyle: true}); + const source = createStyleSource(); + map.addSource('fill', source); + }); + + test('a layer can be added with an embedded source specification', () => { + const map = createMap({deleteStyle: true}); + const source: GeoJSONSourceSpecification = { + type: 'geojson', + data: {type: 'Point', coordinates: [0, 0]} + }; + map.addLayer({ + id: 'foo', + type: 'symbol', + source + }); + }); + + test('returns the style with added source and layer', done => { + const style = createStyle(); + const map = createMap({style}); + const source = createStyleSource(); + const layer = { + id: 'fill', + type: 'fill', + source: 'fill' + } as LayerSpecification; + + map.on('load', () => { + map.addSource('fill', source); + map.addLayer(layer); + expect(map.getStyle()).toEqual(extend(createStyle(), { + sources: {fill: source}, + layers: [layer] + })); + done(); + }); + }); + + test('creates a new Style if diff fails', () => { + const style = createStyle(); + const map = createMap({style}); + jest.spyOn(map.style, 'setState').mockImplementation(() => { + throw new Error('Dummy error'); + }); + jest.spyOn(console, 'warn').mockImplementation(() => {}); + + const previousStyle = map.style; + map.setStyle(style); + expect(map.style && map.style !== previousStyle).toBeTruthy(); + }); + + test('creates a new Style if diff option is false', () => { + const style = createStyle(); + const map = createMap({style}); + const spy = jest.spyOn(map.style, 'setState'); + + const previousStyle = map.style; + map.setStyle(style, {diff: false}); + expect(map.style && map.style !== previousStyle).toBeTruthy(); + expect(spy).not.toHaveBeenCalled(); + }); + + }); + + test('#moveLayer', async () => { + const map = createMap({ + style: extend(createStyle(), { + sources: { + mapbox: { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } + }, + layers: [{ + id: 'layerId1', + type: 'circle', + source: 'mapbox', + 'source-layer': 'sourceLayer' + }, { + id: 'layerId2', + type: 'circle', + source: 'mapbox', + 'source-layer': 'sourceLayer' + }] + }) + }); + + await map.once('render'); + map.moveLayer('layerId1', 'layerId2'); + expect(map.getLayer('layerId1').id).toBe('layerId1'); + expect(map.getLayer('layerId2').id).toBe('layerId2'); + }); + + test('#getLayer', async () => { + const layer = { + id: 'layerId', + type: 'circle', + source: 'mapbox', + 'source-layer': 'sourceLayer' + }; + const map = createMap({ + style: extend(createStyle(), { + sources: { + mapbox: { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } + }, + layers: [layer] + }) + }); + + await map.once('render'); + const mapLayer = map.getLayer('layerId'); + expect(mapLayer.id).toBe(layer.id); + expect(mapLayer.type).toBe(layer.type); + expect(mapLayer.source).toBe(layer.source); + }); + + describe('#getLayersOrder', () => { + test('returns ids of layers in the correct order', done => { + const map = createMap({ + style: extend(createStyle(), { + 'sources': { + 'raster': { + type: 'raster', + tiles: ['http://tiles.server'] + } + }, + 'layers': [{ + 'id': 'raster', + 'type': 'raster', + 'source': 'raster' + }] + }) + }); + + map.on('style.load', () => { + map.addLayer({ + id: 'custom', + type: 'custom', + render() {} + }, 'raster'); + expect(map.getLayersOrder()).toEqual(['custom', 'raster']); + done(); + }); + }); + }); + + describe('#resize', () => { + test('sets width and height from container clients', () => { + const map = createMap(), + container = map.getContainer(); + + Object.defineProperty(container, 'clientWidth', {value: 250}); + Object.defineProperty(container, 'clientHeight', {value: 250}); + map.resize(); + + expect(map.transform.width).toBe(250); + expect(map.transform.height).toBe(250); + + }); + + test('fires movestart, move, resize, and moveend events', () => { + const map = createMap(), + events = []; + + (['movestart', 'move', 'resize', 'moveend'] as any).forEach((event) => { + map.on(event, (e) => { + events.push(e.type); + }); + }); + + map.resize(); + expect(events).toEqual(['movestart', 'move', 'resize', 'moveend']); + + }); + + test('listen to window resize event', () => { + const spy = jest.fn(); + global.ResizeObserver = jest.fn().mockImplementation(() => ({ + observe: spy + })); + + createMap(); + + expect(spy).toHaveBeenCalled(); + }); + + test('do not resize if trackResize is false', () => { + let observerCallback: Function = null; + global.ResizeObserver = jest.fn().mockImplementation((c) => ({ + observe: () => { observerCallback = c; } + })); + + const map = createMap({trackResize: false}); + + const spyA = jest.spyOn(map, 'stop'); + const spyB = jest.spyOn(map, '_update'); + const spyC = jest.spyOn(map, 'resize'); + + observerCallback(); + + expect(spyA).not.toHaveBeenCalled(); + expect(spyB).not.toHaveBeenCalled(); + expect(spyC).not.toHaveBeenCalled(); + }); + + test('do resize if trackResize is true (default)', async () => { + let observerCallback: Function = null; + global.ResizeObserver = jest.fn().mockImplementation((c) => ({ + observe: () => { observerCallback = c; } + })); + + const map = createMap(); + + const updateSpy = jest.spyOn(map, '_update'); + const resizeSpy = jest.spyOn(map, 'resize'); + + // The initial "observe" event fired by ResizeObserver should be captured/muted + // in the map constructor + + observerCallback(); + expect(updateSpy).not.toHaveBeenCalled(); + expect(resizeSpy).not.toHaveBeenCalled(); + + // The next "observe" event should fire a resize / _update + + observerCallback(); + expect(updateSpy).toHaveBeenCalled(); + expect(resizeSpy).toHaveBeenCalledTimes(1); + + // Additional "observe" events should be throttled + observerCallback(); + observerCallback(); + observerCallback(); + observerCallback(); + expect(resizeSpy).toHaveBeenCalledTimes(1); + await new Promise((resolve) => { setTimeout(resolve, 100); }); + expect(resizeSpy).toHaveBeenCalledTimes(2); + }); + + test('width and height correctly rounded', () => { + const map = createMap(); + const container = map.getContainer(); + + Object.defineProperty(container, 'clientWidth', {value: 250.6}); + Object.defineProperty(container, 'clientHeight', {value: 250.6}); + map.resize(); + + expect(map.getCanvas().width).toBe(250); + expect(map.getCanvas().height).toBe(250); + expect(map.painter.width).toBe(250); + expect(map.painter.height).toBe(250); + }); + }); + + describe('#getBounds', () => { + + test('getBounds', () => { + const map = createMap({zoom: 0}); + expect(parseFloat(map.getBounds().getCenter().lng.toFixed(10))).toBe(-0); + expect(parseFloat(map.getBounds().getCenter().lat.toFixed(10))).toBe(0); + + expect(toFixed(map.getBounds().toArray())).toEqual(toFixed([ + [-70.31249999999976, -57.326521225216965], + [70.31249999999977, 57.32652122521695]])); + }); + + test('rotated bounds', () => { + const map = createMap({zoom: 1, bearing: 45}); + expect( + toFixed([[-49.718445552178764, -44.44541580601936], [49.7184455522, 44.445415806019355]]) + ).toEqual(toFixed(map.getBounds().toArray())); + + map.setBearing(135); + expect( + toFixed([[-49.718445552178764, -44.44541580601936], [49.7184455522, 44.445415806019355]]) + ).toEqual(toFixed(map.getBounds().toArray())); + + }); + + function toFixed(bounds) { + const n = 10; + return [ + [normalizeFixed(bounds[0][0], n), normalizeFixed(bounds[0][1], n)], + [normalizeFixed(bounds[1][0], n), normalizeFixed(bounds[1][1], n)] + ]; + } + + function normalizeFixed(num, n) { + // workaround for "-0.0000000000" ≠ "0.0000000000" + return parseFloat(num.toFixed(n)).toFixed(n); + } + }); + + describe('#setMaxBounds', () => { + test('constrains map bounds', () => { + const map = createMap({zoom: 0}); + map.setMaxBounds([[-130.4297, 50.0642], [-61.52344, 24.20688]]); + expect( + toFixed([[-130.4297000000, 7.0136641176], [-61.5234400000, 60.2398142283]]) + ).toEqual(toFixed(map.getBounds().toArray())); + }); + + test('when no argument is passed, map bounds constraints are removed', () => { + const map = createMap({zoom: 0}); + map.setMaxBounds([[-130.4297, 50.0642], [-61.52344, 24.20688]]); + expect( + toFixed([[-166.28906999999964, -27.6835270554], [-25.664070000000066, 73.8248206697]]) + ).toEqual(toFixed(map.setMaxBounds(null).setZoom(0).getBounds().toArray())); + }); + + test('should not zoom out farther than bounds', () => { + const map = createMap(); + map.setMaxBounds([[-130.4297, 50.0642], [-61.52344, 24.20688]]); + expect(map.setZoom(0).getZoom()).not.toBe(0); + }); + + function toFixed(bounds) { + const n = 9; + return [ + [bounds[0][0].toFixed(n), bounds[0][1].toFixed(n)], + [bounds[1][0].toFixed(n), bounds[1][1].toFixed(n)] + ]; + } + + }); + + describe('#getMaxBounds', () => { + test('returns null when no bounds set', () => { + const map = createMap({zoom: 0}); + expect(map.getMaxBounds()).toBeNull(); + }); + + test('returns bounds', () => { + const map = createMap({zoom: 0}); + const bounds = [[-130.4297, 50.0642], [-61.52344, 24.20688]] as LngLatBoundsLike; + map.setMaxBounds(bounds); + expect(map.getMaxBounds().toArray()).toEqual(bounds); + }); + + }); + + describe('#getRenderWorldCopies', () => { + test('initially false', () => { + const map = createMap({renderWorldCopies: false}); + expect(map.getRenderWorldCopies()).toBe(false); + }); + + test('initially true', () => { + const map = createMap({renderWorldCopies: true}); + expect(map.getRenderWorldCopies()).toBe(true); + }); + + }); + + describe('#setRenderWorldCopies', () => { + test('initially false', () => { + const map = createMap({renderWorldCopies: false}); + map.setRenderWorldCopies(true); + expect(map.getRenderWorldCopies()).toBe(true); + }); + + test('initially true', () => { + const map = createMap({renderWorldCopies: true}); + map.setRenderWorldCopies(false); + expect(map.getRenderWorldCopies()).toBe(false); + }); + + test('undefined', () => { + const map = createMap({renderWorldCopies: false}); + map.setRenderWorldCopies(undefined); + expect(map.getRenderWorldCopies()).toBe(true); + }); + + test('null', () => { + const map = createMap({renderWorldCopies: true}); + map.setRenderWorldCopies(null); + expect(map.getRenderWorldCopies()).toBe(false); + }); + + }); + + test('#setMinZoom', () => { + const map = createMap({zoom: 5}); + map.setMinZoom(3.5); + map.setZoom(1); + expect(map.getZoom()).toBe(3.5); + }); + + test('unset minZoom', () => { + const map = createMap({minZoom: 5}); + map.setMinZoom(null); + map.setZoom(1); + expect(map.getZoom()).toBe(1); + }); + + test('#getMinZoom', () => { + const map = createMap({zoom: 0}); + expect(map.getMinZoom()).toBe(-2); + map.setMinZoom(10); + expect(map.getMinZoom()).toBe(10); + }); + + test('ignore minZooms over maxZoom', () => { + const map = createMap({zoom: 2, maxZoom: 5}); + expect(() => { + map.setMinZoom(6); + }).toThrow(); + map.setZoom(0); + expect(map.getZoom()).toBe(0); + }); + + test('#setMaxZoom', () => { + const map = createMap({zoom: 0}); + map.setMaxZoom(3.5); + map.setZoom(4); + expect(map.getZoom()).toBe(3.5); + }); + + test('unset maxZoom', () => { + const map = createMap({maxZoom: 5}); + map.setMaxZoom(null); + map.setZoom(6); + expect(map.getZoom()).toBe(6); + }); + + test('#getMaxZoom', () => { + const map = createMap({zoom: 0}); + expect(map.getMaxZoom()).toBe(22); + map.setMaxZoom(10); + expect(map.getMaxZoom()).toBe(10); + }); + + test('ignore maxZooms over minZoom', () => { + const map = createMap({minZoom: 5}); + expect(() => { + map.setMaxZoom(4); + }).toThrow(); + map.setZoom(5); + expect(map.getZoom()).toBe(5); + }); + + test('throw on maxZoom smaller than minZoom at init', () => { + expect(() => { + createMap({minZoom: 10, maxZoom: 5}); + }).toThrow(new Error('maxZoom must be greater than or equal to minZoom')); + }); + + test('throw on maxZoom smaller than minZoom at init with falsey maxZoom', () => { + expect(() => { + createMap({minZoom: 1, maxZoom: 0}); + }).toThrow(new Error('maxZoom must be greater than or equal to minZoom')); + }); + + test('#setMinPitch', () => { + const map = createMap({pitch: 20}); + map.setMinPitch(10); + map.setPitch(0); + expect(map.getPitch()).toBe(10); + }); + + test('unset minPitch', () => { + const map = createMap({minPitch: 20}); + map.setMinPitch(null); + map.setPitch(0); + expect(map.getPitch()).toBe(0); + }); + + test('#getMinPitch', () => { + const map = createMap({pitch: 0}); + expect(map.getMinPitch()).toBe(0); + map.setMinPitch(10); + expect(map.getMinPitch()).toBe(10); + }); + + test('ignore minPitchs over maxPitch', () => { + const map = createMap({pitch: 0, maxPitch: 10}); + expect(() => { + map.setMinPitch(20); + }).toThrow(); + map.setPitch(0); + expect(map.getPitch()).toBe(0); + }); + + test('#setMaxPitch', () => { + const map = createMap({pitch: 0}); + map.setMaxPitch(10); + map.setPitch(20); + expect(map.getPitch()).toBe(10); + }); + + test('unset maxPitch', () => { + const map = createMap({maxPitch: 10}); + map.setMaxPitch(null); + map.setPitch(20); + expect(map.getPitch()).toBe(20); + }); + + test('#getMaxPitch', () => { + const map = createMap({pitch: 0}); + expect(map.getMaxPitch()).toBe(60); + map.setMaxPitch(10); + expect(map.getMaxPitch()).toBe(10); + }); + + test('ignore maxPitchs over minPitch', () => { + const map = createMap({minPitch: 10}); + expect(() => { + map.setMaxPitch(0); + }).toThrow(); + map.setPitch(10); + expect(map.getPitch()).toBe(10); + }); + + test('throw on maxPitch smaller than minPitch at init', () => { + expect(() => { + createMap({minPitch: 10, maxPitch: 5}); + }).toThrow(new Error('maxPitch must be greater than or equal to minPitch')); + }); + + test('throw on maxPitch smaller than minPitch at init with falsey maxPitch', () => { + expect(() => { + createMap({minPitch: 1, maxPitch: 0}); + }).toThrow(new Error('maxPitch must be greater than or equal to minPitch')); + }); + + test('throw on maxPitch greater than valid maxPitch at init', () => { + expect(() => { + createMap({maxPitch: 90}); + }).toThrow(new Error('maxPitch must be less than or equal to 85')); + }); + + test('throw on minPitch less than valid minPitch at init', () => { + expect(() => { + createMap({minPitch: -10}); + }).toThrow(new Error('minPitch must be greater than or equal to 0')); + }); + + test('#remove', () => { + const map = createMap(); + const spyWorkerPoolRelease = jest.spyOn(map.style.dispatcher.workerPool, 'release'); + expect(map.getContainer().childNodes).toHaveLength(2); + map.remove(); + expect(spyWorkerPoolRelease).toHaveBeenCalledTimes(1); + expect(map.getContainer().childNodes).toHaveLength(0); + + // Cleanup + spyWorkerPoolRelease.mockClear(); + }); + + test('#remove calls onRemove on added controls', () => { + const map = createMap(); + const control = { + onRemove: jest.fn(), + onAdd(_) { + return window.document.createElement('div'); + } + }; + map.addControl(control); + map.remove(); + expect(control.onRemove).toHaveBeenCalledTimes(1); + }); + + test('#remove calls onRemove on added controls before style is destroyed', done => { + const map = createMap(); + let onRemoveCalled = 0; + let style; + const control = { + onRemove(map) { + onRemoveCalled++; + expect(map.getStyle()).toEqual(style); + }, + onAdd(_) { + return window.document.createElement('div'); + } + }; + + map.addControl(control); + + map.on('style.load', () => { + style = map.getStyle(); + map.remove(); + expect(onRemoveCalled).toBe(1); + done(); + }); + }); + + test('does not fire "webglcontextlost" after #remove has been called', done => { + const map = createMap(); + const canvas = map.getCanvas(); + map.once('webglcontextlost', () => done('"webglcontextlost" fired after #remove has been called')); + map.remove(); + // Dispatch the event manually because at the time of this writing, gl does not support + // the WEBGL_lose_context extension. + canvas.dispatchEvent(new window.Event('webglcontextlost')); + done(); + }); + + test('does not fire "webglcontextrestored" after #remove has been called', done => { + const map = createMap(); + const canvas = map.getCanvas(); + + map.once('webglcontextlost', () => { + map.once('webglcontextrestored', () => done('"webglcontextrestored" fired after #remove has been called')); + map.remove(); + canvas.dispatchEvent(new window.Event('webglcontextrestored')); + done(); + }); + + // Dispatch the event manually because at the time of this writing, gl does not support + // the WEBGL_lose_context extension. + canvas.dispatchEvent(new window.Event('webglcontextlost')); + }); + + test('#redraw', async () => { + const map = createMap(); + + await map.once('idle'); + const renderPromise = map.once('render'); + + map.redraw(); + await renderPromise; + }); + + test('#addControl', () => { + const map = createMap(); + const control = { + onAdd(_) { + expect(map).toBe(_); + return window.document.createElement('div'); + } + } as any as IControl; + map.addControl(control); + expect(map._controls[0]).toBe(control); + }); + + test('#removeControl errors on invalid arguments', () => { + const map = createMap(); + const control = {} as any as IControl; + const stub = jest.spyOn(console, 'error').mockImplementation(() => {}); + + map.addControl(control); + map.removeControl(control); + expect(stub).toHaveBeenCalledTimes(2); + + }); + + test('#removeControl', () => { + const map = createMap(); + const control = { + onAdd() { + return window.document.createElement('div'); + }, + onRemove(_) { + expect(map).toBe(_); + } + }; + map.addControl(control); + map.removeControl(control); + expect(map._controls).toHaveLength(0); + + }); + + test('#hasControl', () => { + const map = createMap(); + function Ctrl() {} + Ctrl.prototype = { + onAdd(_) { + return window.document.createElement('div'); + } + }; + + const control = new Ctrl(); + expect(map.hasControl(control)).toBe(false); + map.addControl(control); + expect(map.hasControl(control)).toBe(true); + }); + + test('#project', () => { + const map = createMap(); + expect(map.project([0, 0])).toEqual({x: 100, y: 100}); + }); + + test('#unproject', () => { + const map = createMap(); + expect(fixedLngLat(map.unproject([100, 100]))).toEqual({lng: 0, lat: 0}); + }); + + test('#listImages', done => { + const map = createMap(); + + map.on('load', () => { + expect(map.listImages()).toHaveLength(0); + + map.addImage('img', {width: 1, height: 1, data: new Uint8Array(4)}); + + const images = map.listImages(); + expect(images).toHaveLength(1); + expect(images[0]).toBe('img'); + done(); + }); + }); + + test('#listImages throws an error if called before "load"', () => { + const map = createMap(); + expect(() => { + map.listImages(); + }).toThrow(Error); + }); + + describe('#queryRenderedFeatures', () => { + + test('if no arguments provided', done => { + createMap({}, (err, map) => { + expect(err).toBeFalsy(); + const spy = jest.spyOn(map.style, 'queryRenderedFeatures'); + + const output = map.queryRenderedFeatures(); + + const args = spy.mock.calls[0]; + expect(args[0]).toBeTruthy(); + expect(args[1]).toEqual({availableImages: []}); + expect(output).toEqual([]); + + done(); + }); + }); + + test('if only "geometry" provided', done => { + createMap({}, (err, map) => { + expect(err).toBeFalsy(); + const spy = jest.spyOn(map.style, 'queryRenderedFeatures'); + + const output = map.queryRenderedFeatures(map.project(new LngLat(0, 0))); + + const args = spy.mock.calls[0]; + expect(args[0]).toEqual([{x: 100, y: 100}]); // query geometry + expect(args[1]).toEqual({availableImages: []}); // params + expect(args[2]).toEqual(map.transform); // transform + expect(output).toEqual([]); + + done(); + }); + }); + + test('if only "params" provided', done => { + createMap({}, (err, map) => { + expect(err).toBeFalsy(); + const spy = jest.spyOn(map.style, 'queryRenderedFeatures'); + + const output = map.queryRenderedFeatures({filter: ['all']}); + + const args = spy.mock.calls[0]; + expect(args[0]).toBeTruthy(); + expect(args[1]).toEqual({availableImages: [], filter: ['all']}); + expect(output).toEqual([]); + + done(); + }); + }); + + test('if both "geometry" and "params" provided', done => { + createMap({}, (err, map) => { + expect(err).toBeFalsy(); + const spy = jest.spyOn(map.style, 'queryRenderedFeatures'); + + const output = map.queryRenderedFeatures({filter: ['all']}); + + const args = spy.mock.calls[0]; + expect(args[0]).toBeTruthy(); + expect(args[1]).toEqual({availableImages: [], filter: ['all']}); + expect(output).toEqual([]); + + done(); + }); + }); + + test('if "geometry" with unwrapped coords provided', done => { + createMap({}, (err, map) => { + expect(err).toBeFalsy(); + const spy = jest.spyOn(map.style, 'queryRenderedFeatures'); + + map.queryRenderedFeatures(map.project(new LngLat(360, 0))); + + expect(spy.mock.calls[0][0]).toEqual([{x: 612, y: 100}]); + done(); + }); + }); + + test('returns an empty array when no style is loaded', () => { + const map = createMap({style: undefined}); + expect(map.queryRenderedFeatures()).toEqual([]); + }); + + }); + + describe('#setLayoutProperty', () => { + test('sets property', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': { + 'type': 'geojson', + 'data': { + 'type': 'FeatureCollection', + 'features': [] + } + } + }, + 'layers': [{ + 'id': 'symbol', + 'type': 'symbol', + 'source': 'geojson', + 'layout': { + 'text-transform': 'uppercase' + } + }] + } + }); + + map.on('style.load', () => { + map.style.dispatcher.broadcast = function (key, value: any) { + expect(key).toBe('updateLayers'); + expect(value.layers.map((layer) => { return layer.id; })).toEqual(['symbol']); + }; + + map.setLayoutProperty('symbol', 'text-transform', 'lowercase'); + map.style.update({} as EvaluationParameters); + expect(map.getLayoutProperty('symbol', 'text-transform')).toBe('lowercase'); + done(); + }); + }); + + test('throw before loaded', () => { + const map = createMap({ + style: { + version: 8, + sources: {}, + layers: [] + } + }); + + expect(() => { + map.setLayoutProperty('symbol', 'text-transform', 'lowercase'); + }).toThrow(Error); + + }); + + test('fires an error if layer not found', done => { + const map = createMap({ + style: { + version: 8, + sources: {}, + layers: [] + } + }); + + map.on('style.load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/Cannot style non-existing layer "non-existant"./); + done(); + }); + map.setLayoutProperty('non-existant', 'text-transform', 'lowercase'); + }); + }); + + test('fires a data event', async () => { + // background layers do not have a source + const map = createMap({ + style: { + 'version': 8, + 'sources': {}, + 'layers': [{ + 'id': 'background', + 'type': 'background', + 'layout': { + 'visibility': 'none' + } + }] + } + }); + + await map.once('style.load'); + const dataPromise = map.once('data'); + map.setLayoutProperty('background', 'visibility', 'visible'); + const e = await dataPromise; + expect(e.dataType).toBe('style'); + }); + + test('sets visibility on background layer', done => { + // background layers do not have a source + const map = createMap({ + style: { + 'version': 8, + 'sources': {}, + 'layers': [{ + 'id': 'background', + 'type': 'background', + 'layout': { + 'visibility': 'none' + } + }] + } + }); + + map.on('style.load', () => { + map.setLayoutProperty('background', 'visibility', 'visible'); + expect(map.getLayoutProperty('background', 'visibility')).toBe('visible'); + done(); + }); + }); + + test('sets visibility on raster layer', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'maplibre-satellite': { + 'type': 'raster', + 'tiles': ['http://example.com/{z}/{x}/{y}.png'] + } + }, + 'layers': [{ + 'id': 'satellite', + 'type': 'raster', + 'source': 'maplibre-satellite', + 'layout': { + 'visibility': 'none' + } + }] + } + }); + + // Suppress errors because we're not loading tiles from a real URL. + map.on('error', () => {}); + + map.on('style.load', () => { + map.setLayoutProperty('satellite', 'visibility', 'visible'); + expect(map.getLayoutProperty('satellite', 'visibility')).toBe('visible'); + done(); + }); + }); + + test('sets visibility on video layer', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'drone': { + 'type': 'video', + 'urls': [], + 'coordinates': [ + [-122.51596391201019, 37.56238816766053], + [-122.51467645168304, 37.56410183312965], + [-122.51309394836426, 37.563391708549425], + [-122.51423120498657, 37.56161849366671] + ] + } + }, + 'layers': [{ + 'id': 'shore', + 'type': 'raster', + 'source': 'drone', + 'layout': { + 'visibility': 'none' + } + }] + } + }); + + map.on('style.load', () => { + map.setLayoutProperty('shore', 'visibility', 'visible'); + expect(map.getLayoutProperty('shore', 'visibility')).toBe('visible'); + done(); + }); + }); + + test('sets visibility on image layer', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'image': { + 'type': 'image', + 'url': '', + 'coordinates': [ + [-122.51596391201019, 37.56238816766053], + [-122.51467645168304, 37.56410183312965], + [-122.51309394836426, 37.563391708549425], + [-122.51423120498657, 37.56161849366671] + ] + } + }, + 'layers': [{ + 'id': 'image', + 'type': 'raster', + 'source': 'image', + 'layout': { + 'visibility': 'none' + } + }] + } + }); + + map.on('style.load', () => { + map.setLayoutProperty('image', 'visibility', 'visible'); + expect(map.getLayoutProperty('image', 'visibility')).toBe('visible'); + done(); + }); + }); + + }); + + describe('#getLayoutProperty', () => { + test('fires an error if layer not found', done => { + const map = createMap({ + style: { + version: 8, + sources: {}, + layers: [] + } + }); + + map.on('style.load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/Cannot get style of non-existing layer "non-existant"./); + done(); + }); + (map as any).getLayoutProperty('non-existant', 'text-transform', 'lowercase'); + }); + }); + + }); + + describe('#setPaintProperty', () => { + test('sets property', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': {}, + 'layers': [{ + 'id': 'background', + 'type': 'background' + }] + } + }); + + map.on('style.load', () => { + map.setPaintProperty('background', 'background-color', 'red'); + expect(map.getPaintProperty('background', 'background-color')).toBe('red'); + done(); + }); + }); + + test('throw before loaded', () => { + const map = createMap({ + style: { + version: 8, + sources: {}, + layers: [] + } + }); + + expect(() => { + map.setPaintProperty('background', 'background-color', 'red'); + }).toThrow(Error); + + }); + + test('fires an error if layer not found', done => { + const map = createMap({ + style: { + version: 8, + sources: {}, + layers: [] + } + }); + + map.on('style.load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/Cannot style non-existing layer "non-existant"./); + done(); + }); + map.setPaintProperty('non-existant', 'background-color', 'red'); + }); + }); + + }); + + describe('#setFeatureState', () => { + test('sets state', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + const fState = map.getFeatureState({source: 'geojson', id: 12345}); + expect(fState.hover).toBe(true); + done(); + }); + }); + test('works with string ids', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 'foo'}, {'hover': true}); + const fState = map.getFeatureState({source: 'geojson', id: 'foo'}); + expect(fState.hover).toBe(true); + done(); + }); + }); + test('parses feature id as an int', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: '12345'}, {'hover': true}); + const fState = map.getFeatureState({source: 'geojson', id: 12345}); + expect(fState.hover).toBe(true); + done(); + }); + }); + test('throw before loaded', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + expect(() => { + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + }).toThrow(Error); + + done(); + }); + test('fires an error if source not found', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/source/); + done(); + }); + map.setFeatureState({source: 'vector', id: 12345}, {'hover': true}); + }); + }); + test('fires an error if sourceLayer not provided for a vector source', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'vector': { + 'type': 'vector', + 'tiles': ['http://example.com/{z}/{x}/{y}.png'] + } + }, + 'layers': [] + } + }); + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/sourceLayer/); + done(); + }); + (map as any).setFeatureState({source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true}); + }); + }); + test('fires an error if id not provided', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'vector': { + 'type': 'vector', + 'tiles': ['http://example.com/{z}/{x}/{y}.png'] + } + }, + 'layers': [] + } + }); + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/id/); + done(); + }); + (map as any).setFeatureState({source: 'vector', sourceLayer: '1'}, {'hover': true}); + }); + }); + }); + + describe('#removeFeatureState', () => { + + test('accepts "0" id', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 0}, {'hover': true, 'click': true}); + map.removeFeatureState({source: 'geojson', id: 0}, 'hover'); + const fState = map.getFeatureState({source: 'geojson', id: 0}); + expect(fState.hover).toBeUndefined(); + expect(fState.click).toBe(true); + done(); + }); + }); + test('accepts string id', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 'foo'}, {'hover': true, 'click': true}); + map.removeFeatureState({source: 'geojson', id: 'foo'}, 'hover'); + const fState = map.getFeatureState({source: 'geojson', id: 'foo'}); + expect(fState.hover).toBeUndefined(); + expect(fState.click).toBe(true); + done(); + }); + }); + test('remove specific state property', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + map.removeFeatureState({source: 'geojson', id: 12345}, 'hover'); + const fState = map.getFeatureState({source: 'geojson', id: 12345}); + expect(fState.hover).toBeUndefined(); + done(); + }); + }); + test('remove all state properties of one feature', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson', id: 1}); + + const fState = map.getFeatureState({source: 'geojson', id: 1}); + expect(fState.hover).toBeUndefined(); + expect(fState.foo).toBeUndefined(); + + done(); + }); + }); + test('remove properties for zero-based feature IDs.', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 0}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson', id: 0}); + + const fState = map.getFeatureState({source: 'geojson', id: 0}); + expect(fState.hover).toBeUndefined(); + expect(fState.foo).toBeUndefined(); + + done(); + }); + }); + test('other properties persist when removing specific property', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson', id: 1}, 'hover'); + + const fState = map.getFeatureState({source: 'geojson', id: 1}); + expect(fState.foo).toBe(true); + + done(); + }); + }); + test('remove all state properties of all features in source', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.setFeatureState({source: 'geojson', id: 2}, {'hover': true, 'foo': true}); + + map.removeFeatureState({source: 'geojson'}); + + const fState1 = map.getFeatureState({source: 'geojson', id: 1}); + expect(fState1.hover).toBeUndefined(); + expect(fState1.foo).toBeUndefined(); + + const fState2 = map.getFeatureState({source: 'geojson', id: 2}); + expect(fState2.hover).toBeUndefined(); + expect(fState2.foo).toBeUndefined(); + + done(); + }); + }); + test('specific state deletion should not interfere with broader state deletion', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.setFeatureState({source: 'geojson', id: 2}, {'hover': true, 'foo': true}); + + map.removeFeatureState({source: 'geojson', id: 1}); + map.removeFeatureState({source: 'geojson', id: 1}, 'foo'); + + const fState1 = map.getFeatureState({source: 'geojson', id: 1}); + expect(fState1.hover).toBeUndefined(); + + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson'}); + map.removeFeatureState({source: 'geojson', id: 1}, 'foo'); + + const fState2 = map.getFeatureState({source: 'geojson', id: 2}); + expect(fState2.hover).toBeUndefined(); + + map.setFeatureState({source: 'geojson', id: 2}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson'}); + map.removeFeatureState({source: 'geojson', id: 2}, 'foo'); + + const fState3 = map.getFeatureState({source: 'geojson', id: 2}); + expect(fState3.hover).toBeUndefined(); + + done(); + }); + }); + test('add/remove and remove/add state', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + + map.removeFeatureState({source: 'geojson', id: 12345}); + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + + const fState1 = map.getFeatureState({source: 'geojson', id: 12345}); + expect(fState1.hover).toBe(true); + + map.removeFeatureState({source: 'geojson', id: 12345}); + + const fState2 = map.getFeatureState({source: 'geojson', id: 12345}); + expect(fState2.hover).toBeUndefined(); + + done(); + }); + }); + test('throw before loaded', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + expect(() => { + (map as any).removeFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + }).toThrow(Error); + + done(); + }); + test('fires an error if source not found', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'geojson': createStyleSource() + }, + 'layers': [] + } + }); + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/source/); + done(); + }); + (map as any).removeFeatureState({source: 'vector', id: 12345}, {'hover': true}); + }); + }); + test('fires an error if sourceLayer not provided for a vector source', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'vector': { + 'type': 'vector', + 'tiles': ['http://example.com/{z}/{x}/{y}.png'] + } + }, + 'layers': [] + } + }); + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/sourceLayer/); + done(); + }); + (map as any).removeFeatureState({source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true}); + }); + }); + test('fires an error if state property is provided without a feature id', done => { + const map = createMap({ + style: { + 'version': 8, + 'sources': { + 'vector': { + 'type': 'vector', + 'tiles': ['http://example.com/{z}/{x}/{y}.png'] + } + }, + 'layers': [] + } + }); + map.on('load', () => { + map.on('error', ({error}) => { + expect(error.message).toMatch(/id/); + done(); + }); + (map as any).removeFeatureState({source: 'vector', sourceLayer: '1'}, {'hover': true}); + }); + }); + }); + + describe('error event', () => { + test('logs errors to console when it has NO listeners', () => { + const map = createMap(); + const stub = jest.spyOn(console, 'error').mockImplementation(() => {}); + stub.mockReset(); + const error = new Error('test'); + map.fire(new ErrorEvent(error)); + expect(stub).toHaveBeenCalledTimes(1); + expect(stub.mock.calls[0][0]).toBe(error); + }); + + test('calls listeners', done => { + const map = createMap(); + const error = new Error('test'); + map.on('error', (event) => { + expect(event.error).toBe(error); + done(); + }); + map.fire(new ErrorEvent(error)); + }); + + }); + + test('render stabilizes', done => { + const style = createStyle(); + style.sources.mapbox = { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + }; + style.layers.push({ + id: 'layerId', + type: 'circle', + source: 'mapbox', + 'source-layer': 'sourceLayer' + }); + + let timer; + const map = createMap({style}); + map.on('render', () => { + if (timer) clearTimeout(timer); + timer = setTimeout(() => { + map.off('render', undefined); + map.on('render', () => { + done('test failed'); + }); + expect((map as any)._frameId).toBeFalsy(); + done(); + }, 100); + }); + }); + + test('no render after idle event', done => { + const style = createStyle(); + const map = createMap({style}); + map.on('idle', () => { + map.on('render', () => { + done('test failed'); + }); + setTimeout(() => { + done(); + }, 100); + }); + }); + + test('no render before style loaded', done => { + server.respondWith('/styleUrl', JSON.stringify(createStyle())); + const map = createMap({style: '/styleUrl'}); + + jest.spyOn(map, 'triggerRepaint').mockImplementationOnce(() => { + if (!map.style._loaded) { + done('test failed'); + } + }); + map.on('render', () => { + if (map.style._loaded) { + done(); + } else { + done('test failed'); + } + }); + + // Force a update should not call triggerRepaint till style is loaded. + // Once style is loaded, it will trigger the update. + map._update(); + server.respond(); + }); + + test('no idle event during move', async () => { + const style = createStyle(); + const map = createMap({style, fadeDuration: 0}); + await map.once('idle'); + map.zoomTo(0.5, {duration: 100}); + expect(map.isMoving()).toBeTruthy(); + await map.once('idle'); + expect(map.isMoving()).toBeFalsy(); + }); + + test('#removeLayer restores Map#loaded() to true', done => { + const map = createMap({ + style: extend(createStyle(), { + sources: { + mapbox: { + type: 'vector', + minzoom: 1, + maxzoom: 10, + tiles: ['http://example.com/{z}/{x}/{y}.png'] + } + }, + layers: [{ + id: 'layerId', + type: 'circle', + source: 'mapbox', + 'source-layer': 'sourceLayer' + }] + }) + }); + + map.once('render', () => { + map.removeLayer('layerId'); + map.on('render', () => { + if (map.loaded()) { + map.remove(); + done(); + } + }); + }); + }); + + test('stops camera animation on mousedown when interactive', () => { + const map = createMap({interactive: true}); + map.flyTo({center: [200, 0], duration: 100}); + + simulate.mousedown(map.getCanvasContainer()); + expect(map.isEasing()).toBe(false); + + map.remove(); + }); + + test('continues camera animation on mousedown when non-interactive', () => { + const map = createMap({interactive: false}); + map.flyTo({center: [200, 0], duration: 100}); + + simulate.mousedown(map.getCanvasContainer()); + expect(map.isEasing()).toBe(true); + + map.remove(); + }); + + test('stops camera animation on touchstart when interactive', () => { + const map = createMap({interactive: true}); + map.flyTo({center: [200, 0], duration: 100}); + + simulate.touchstart(map.getCanvasContainer(), {touches: [{target: map.getCanvas(), clientX: 0, clientY: 0}]}); + expect(map.isEasing()).toBe(false); + + map.remove(); + }); + + test('continues camera animation on touchstart when non-interactive', () => { + const map = createMap({interactive: false}); + map.flyTo({center: [200, 0], duration: 100}); + + simulate.touchstart(map.getCanvasContainer()); + expect(map.isEasing()).toBe(true); + + map.remove(); + }); + + test('continues camera animation on resize', () => { + const map = createMap(), + container = map.getContainer(); + + map.flyTo({center: [200, 0], duration: 100}); + + Object.defineProperty(container, 'clientWidth', {value: 250}); + Object.defineProperty(container, 'clientHeight', {value: 250}); + map.resize(); + + expect(map.isMoving()).toBeTruthy(); + + }); + + test('map fires `styleimagemissing` for missing icons', done => { + const map = createMap(); + + const id = 'missing-image'; + + const sampleImage = {width: 2, height: 1, data: new Uint8Array(8)}; + + let called: string; + map.on('styleimagemissing', e => { + map.addImage(e.id, sampleImage); + called = e.id; + }); + + expect(map.hasImage(id)).toBeFalsy(); + + map.style.imageManager.getImages([id], (alwaysNull, generatedImage) => { + expect(generatedImage[id].data.width).toEqual(sampleImage.width); + expect(generatedImage[id].data.height).toEqual(sampleImage.height); + expect(generatedImage[id].data.data).toEqual(sampleImage.data); + expect(called).toBe(id); + expect(map.hasImage(id)).toBeTruthy(); + done(); + }); + }); + + test('map getImage matches addImage, uintArray', () => { + const map = createMap(); + const id = 'add-get-uint'; + const inputImage = {width: 2, height: 1, data: new Uint8Array(8)}; + + map.addImage(id, inputImage); + expect(map.hasImage(id)).toBeTruthy(); + + const gotImage = map.getImage(id); + expect(gotImage.data.width).toEqual(inputImage.width); + expect(gotImage.data.height).toEqual(inputImage.height); + expect(gotImage.sdf).toBe(false); + }); + + test('map getImage matches addImage, uintClampedArray', () => { + const map = createMap(); + const id = 'add-get-uint-clamped'; + const inputImage = {width: 1, height: 2, data: new Uint8ClampedArray(8)}; + + map.addImage(id, inputImage); + expect(map.hasImage(id)).toBeTruthy(); + + const gotImage = map.getImage(id); + expect(gotImage.data.width).toEqual(inputImage.width); + expect(gotImage.data.height).toEqual(inputImage.height); + expect(gotImage.sdf).toBe(false); + }); + + test('map getImage matches addImage, ImageData', () => { + const map = createMap(); + const id = 'add-get-image-data'; + const inputImage = new ImageData(1, 3); + + map.addImage(id, inputImage); + expect(map.hasImage(id)).toBeTruthy(); + + const gotImage = map.getImage(id); + expect(gotImage.data.width).toEqual(inputImage.width); + expect(gotImage.data.height).toEqual(inputImage.height); + expect(gotImage.sdf).toBe(false); + }); + + test('map getImage matches addImage, StyleImageInterface uint', () => { + const map = createMap(); + const id = 'add-get-style-image-iface-uint'; + const inputImage: StyleImageInterface = { + width: 3, + height: 1, + data: new Uint8Array(12) + }; + + map.addImage(id, inputImage); + expect(map.hasImage(id)).toBeTruthy(); + + const gotImage = map.getImage(id); + expect(gotImage.data.width).toEqual(inputImage.width); + expect(gotImage.data.height).toEqual(inputImage.height); + expect(gotImage.sdf).toBe(false); + }); + + test('map getImage matches addImage, StyleImageInterface clamped', () => { + const map = createMap(); + const id = 'add-get-style-image-iface-clamped'; + const inputImage: StyleImageInterface = { + width: 4, + height: 1, + data: new Uint8ClampedArray(16) + }; + + map.addImage(id, inputImage); + expect(map.hasImage(id)).toBeTruthy(); + + const gotImage = map.getImage(id); + expect(gotImage.data.width).toEqual(inputImage.width); + expect(gotImage.data.height).toEqual(inputImage.height); + expect(gotImage.sdf).toBe(false); + }); + + test('map getImage matches addImage, StyleImageInterface SDF', () => { + const map = createMap(); + const id = 'add-get-style-image-iface-sdf'; + const inputImage: StyleImageInterface = { + width: 5, + height: 1, + data: new Uint8Array(20) + }; + + map.addImage(id, inputImage, {sdf: true}); + expect(map.hasImage(id)).toBeTruthy(); + + const gotImage = map.getImage(id); + expect(gotImage.data.width).toEqual(inputImage.width); + expect(gotImage.data.height).toEqual(inputImage.height); + expect(gotImage.sdf).toBe(true); + }); + + test('map does not fire `styleimagemissing` for empty icon values', done => { + const map = createMap(); + + map.on('load', () => { + map.on('idle', () => { + done(); + }); + + map.addSource('foo', { + type: 'geojson', + data: {type: 'Point', coordinates: [0, 0]} + }); + map.addLayer({ + id: 'foo', + type: 'symbol', + source: 'foo', + layout: { + 'icon-image': ['case', true, '', ''] + } + }); + + map.on('styleimagemissing', ({id}) => { + done(`styleimagemissing fired for value ${id}`); + }); + }); + }); + + describe('setPixelRatio', () => { + test('resizes canvas', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + const map = createMap({container, pixelRatio: 1}); + expect(map.getCanvas().width).toBe(512); + expect(map.getCanvas().height).toBe(512); + map.setPixelRatio(2); + expect(map.getCanvas().width).toBe(1024); + expect(map.getCanvas().height).toBe(1024); + }); + + test('resizes painter', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + const map = createMap({container, pixelRatio: 1}); + expect(map.painter.pixelRatio).toBe(1); + expect(map.painter.width).toBe(512); + expect(map.painter.height).toBe(512); + map.setPixelRatio(2); + expect(map.painter.pixelRatio).toBe(2); + expect(map.painter.width).toBe(1024); + expect(map.painter.height).toBe(1024); + }); + }); + + describe('getPixelRatio', () => { + test('returns the pixel ratio', () => { + const map = createMap({pixelRatio: 1}); + expect(map.getPixelRatio()).toBe(1); + map.setPixelRatio(2); + expect(map.getPixelRatio()).toBe(2); + }); + }); + + test('pixel ratio defaults to devicePixelRatio', () => { + const map = createMap(); + expect(map.getPixelRatio()).toBe(devicePixelRatio); + }); + + test('pixel ratio by default reflects devicePixelRatio changes', () => { + global.devicePixelRatio = 0.25; + const map = createMap(); + expect(map.getPixelRatio()).toBe(0.25); + global.devicePixelRatio = 1; + expect(map.getPixelRatio()).toBe(1); + }); + + test('canvas has the expected size', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + const map = createMap({container, pixelRatio: 2}); + expect(map.getCanvas().width).toBe(1024); + expect(map.getCanvas().height).toBe(1024); + }); + + test('painter has the expected size and pixel ratio', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + const map = createMap({container, pixelRatio: 2}); + expect(map.painter.pixelRatio).toBe(2); + expect(map.painter.width).toBe(1024); + expect(map.painter.height).toBe(1024); + }); + + test('fires sourcedataabort event on dataabort event', async () => { + const map = createMap(); + const sourcePromise = map.once('sourcedataabort'); + map.fire(new Event('dataabort')); + await sourcePromise; + }); + + describe('#setTerrain', () => { + test('warn when terrain and hillshade source identical', done => { + server.respondWith('/source.json', JSON.stringify({ + minzoom: 5, + maxzoom: 12, + attribution: 'Terrain', + tiles: ['http://example.com/{z}/{x}/{y}.pngraw'], + bounds: [-47, -7, -45, -5] + })); + + const map = createMap(); + + map.on('load', () => { + map.addSource('terrainrgb', {type: 'raster-dem', url: '/source.json'}); + server.respond(); + map.addLayer({id: 'hillshade', type: 'hillshade', source: 'terrainrgb'}); + const stub = jest.spyOn(console, 'warn').mockImplementation(() => { }); + stub.mockReset(); + map.setTerrain({ + source: 'terrainrgb' + }); + expect(console.warn).toHaveBeenCalledTimes(1); + done(); + }); + }); + }); + + describe('#getTerrain', () => { + test('returns null when not set', () => { + const map = createMap(); + expect(map.getTerrain()).toBeNull(); + }); + }); + + describe('#setCooperativeGestures', () => { + test('returns self', () => { + const map = createMap(); + expect(map.setCooperativeGestures(true)).toBe(map); + }); + + test('can be called more than once', () => { + const map = createMap(); + map.setCooperativeGestures(true); + map.setCooperativeGestures(true); + }); + + test('calling set with no arguments turns cooperative gestures off', done => { + const map = createMap({cooperativeGestures: true}); + map.on('load', () => { + map.setCooperativeGestures(); + expect(map.getCooperativeGestures()).toBeFalsy(); + done(); + }); + }); + }); + + describe('#getCooperativeGestures', () => { + test('returns the cooperative gestures option', done => { + const map = createMap({cooperativeGestures: true}); + + map.on('load', () => { + expect(map.getCooperativeGestures()).toBe(true); + done(); + }); + }); + + test('returns falsy if cooperative gestures option is not specified', done => { + const map = createMap(); + + map.on('load', () => { + expect(map.getCooperativeGestures()).toBeFalsy(); + done(); + }); + }); + + test('returns the cooperative gestures option with custom messages', done => { + const option = { + 'windowsHelpText': 'Custom message', + 'macHelpText': 'Custom message', + 'mobileHelpText': 'Custom message', + }; + const map = createMap({cooperativeGestures: option}); + + map.on('load', () => { + expect(map.getCooperativeGestures()).toEqual(option); + done(); + }); + }); + }); + + describe('cooperativeGestures option', () => { + test('cooperativeGesture container element is hidden from a11y tree', () => { + const map = createMap({cooperativeGestures: true}); + + expect(map.getContainer().querySelector('.maplibregl-cooperative-gesture-screen').getAttribute('aria-hidden')).toBeTruthy(); + }); + }); + + describe('getCameraTargetElevation', () => { + test('Elevation is zero without terrain, and matches any given terrain', () => { + const map = createMap(); + expect(map.getCameraTargetElevation()).toBe(0); + + const terrainStub = {} as Terrain; + map.terrain = terrainStub; + + const transform = new Transform(0, 22, 0, 60, true); + transform.elevation = 200; + transform.center = new LngLat(10.0, 50.0); + transform.zoom = 14; + transform.resize(512, 512); + transform.elevation = 2000; + map.transform = transform; + + expect(map.getCameraTargetElevation()).toBe(2000); + }); + }); + + describe('#calculateCameraOptionsFromTo', () => { + // Choose initial zoom to avoid center being constrained by mercator latitude limits. + test('pitch 90 with terrain', () => { + const map = createMap(); + + const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 111200); + + const terrainStub = {} as Terrain; + terrainStub.getElevationForLngLatZoom = mockedGetElevation; + map.terrain = terrainStub; + + // distance between lng x and lng x+1 is 111.2km at same lat + // altitude same as center elevation => 90° pitch + const cameraOptions: CameraOptions = map.calculateCameraOptionsFromTo(new LngLat(1, 0), 111200, new LngLat(0, 0)); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.pitch).toBeCloseTo(90); + expect(mockedGetElevation.mock.calls).toHaveLength(1); + }); + + test('pitch 153.435 with terrain', () => { + const map = createMap(); + + const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 111200 * 3); + + const terrainStub = {} as Terrain; + terrainStub.getElevationForLngLatZoom = mockedGetElevation; + map.terrain = terrainStub; + // distance between lng x and lng x+1 is 111.2km at same lat + // (elevation difference of cam and center) / 2 = grounddistance => + // acos(111.2 / sqrt(111.2² + (111.2 * 2)²)) = acos(1/sqrt(5)) => 63.435 + 90 = 153.435 + const cameraOptions: CameraOptions = map.calculateCameraOptionsFromTo(new LngLat(1, 0), 111200, new LngLat(0, 0)); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.pitch).toBeCloseTo(153.435); + expect(mockedGetElevation.mock.calls).toHaveLength(1); + }); + + test('pitch 63 with terrain', () => { + const map = createMap(); + + const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 111200 / 2); + + const terrainStub = {} as Terrain; + terrainStub.getElevationForLngLatZoom = mockedGetElevation; + map.terrain = terrainStub; + + // distance between lng x and lng x+1 is 111.2km at same lat + // (elevation difference of cam and center) * 2 = grounddistance => + // acos(111.2 / sqrt(111.2² + (111.2 * 0.5)²)) = acos(1/sqrt(1.25)) => 90 (looking down) - 26.565 = 63.435 + const cameraOptions: CameraOptions = map.calculateCameraOptionsFromTo(new LngLat(0, 0), 111200, new LngLat(1, 0)); + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.pitch).toBeCloseTo(63.435); + expect(mockedGetElevation.mock.calls).toHaveLength(1); + }); + + test('zoom distance 1000', () => { + const map = createMap(); + + const mockedGetElevation = jest.fn((_lngLat: LngLat, _zoom: number) => 1000); + + const terrainStub = {} as Terrain; + terrainStub.getElevationForLngLatZoom = mockedGetElevation; + map.terrain = terrainStub; + + const expectedZoom = Math.log2(map.transform.cameraToCenterDistance / mercatorZfromAltitude(1000, 0) / map.transform.tileSize); + const cameraOptions = map.calculateCameraOptionsFromTo(new LngLat(0, 0), 0, new LngLat(0, 0)); + + expect(cameraOptions).toBeDefined(); + expect(cameraOptions.zoom).toBeCloseTo(expectedZoom); + expect(mockedGetElevation.mock.calls).toHaveLength(1); + }); + + test('don\'t call getElevation when altitude supplied', () => { + const map = createMap(); + + const mockedGetElevation = jest.fn((_tileID: OverscaledTileID, _x: number, _y: number, _extent?: number) => 0); + + const terrainStub = {} as Terrain; + terrainStub.getElevation = mockedGetElevation; + map.terrain = terrainStub; + + const cameraOptions = map.calculateCameraOptionsFromTo(new LngLat(0, 0), 0, new LngLat(0, 0), 1000); + + expect(cameraOptions).toBeDefined(); + expect(mockedGetElevation.mock.calls).toHaveLength(0); + }); + + test('don\'t call getElevation when altitude 0 supplied', () => { + const map = createMap(); + + const mockedGetElevation = jest.fn((_tileID: OverscaledTileID, _x: number, _y: number, _extent?: number) => 0); + + const terrainStub = {} as Terrain; + terrainStub.getElevation = mockedGetElevation; + map.terrain = terrainStub; + + const cameraOptions = map.calculateCameraOptionsFromTo(new LngLat(0, 0), 0, new LngLat(1, 0), 0); + + expect(cameraOptions).toBeDefined(); + expect(mockedGetElevation.mock.calls).toHaveLength(0); + }); + }); + + describe('webgl errors', () => { + test('WebGL error while creating map', () => { + setErrorWebGlContext(); + try { + createMap(); + } catch (e) { + const errorMessageObject = JSON.parse(e.message); + + // this message is from map code + expect(errorMessageObject.message).toBe('Failed to initialize WebGL'); + + // this is from test mock + expect(errorMessageObject.statusMessage).toBe('mocked webglcontextcreationerror message'); + } + + }); + test('Hit WebGL max drawing buffer limit', () => { + // Simulate a device with MAX_TEXTURE_SIZE=16834 and max rendering area of ~32Mpx + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 8000}); + Object.defineProperty(container, 'clientHeight', {value: 4500}); + const map = createMap({container, maxCanvasSize: [16834, 16834], pixelRatio: 1}); + jest.spyOn(map.painter.context.gl, 'drawingBufferWidth', 'get').mockReturnValue(7536); + jest.spyOn(map.painter.context.gl, 'drawingBufferHeight', 'get').mockReturnValue(4239); + map.resize(); + expect(map.getCanvas().width).toBe(7536); + expect(map.getCanvas().height).toBe(4239); + // Check if maxCanvasSize is updated + expect(map._maxCanvasSize).toEqual([7536, 4239]); + }); + }); + + describe('Max Canvas Size option', () => { + test('maxCanvasSize width = height', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 2048}); + Object.defineProperty(container, 'clientHeight', {value: 2048}); + const map = createMap({container, maxCanvasSize: [8192, 8192], pixelRatio: 5}); + map.resize(); + expect(map.getCanvas().width).toBe(8192); + expect(map.getCanvas().height).toBe(8192); + }); + + test('maxCanvasSize width != height', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 1024}); + Object.defineProperty(container, 'clientHeight', {value: 2048}); + const map = createMap({container, maxCanvasSize: [8192, 4096], pixelRatio: 3}); + map.resize(); + expect(map.getCanvas().width).toBe(2048); + expect(map.getCanvas().height).toBe(4096); + }); + + test('maxCanvasSize below clientWidth and clientHeigth', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 12834}); + Object.defineProperty(container, 'clientHeight', {value: 9000}); + const map = createMap({container, maxCanvasSize: [4096, 8192], pixelRatio: 1}); + map.resize(); + expect(map.getCanvas().width).toBe(4096); + expect(map.getCanvas().height).toBe(2872); + }); + + test('maxCanvasSize with setPixelRatio', () => { + const container = window.document.createElement('div'); + Object.defineProperty(container, 'clientWidth', {value: 2048}); + Object.defineProperty(container, 'clientHeight', {value: 2048}); + const map = createMap({container, maxCanvasSize: [3072, 3072], pixelRatio: 1.25}); + map.resize(); + expect(map.getCanvas().width).toBe(2560); + expect(map.getCanvas().height).toBe(2560); + map.setPixelRatio(2); + expect(map.getCanvas().width).toBe(3072); + expect(map.getCanvas().height).toBe(3072); + }); + }); + +}); + +function createStyle() { + return { + version: 8, + center: [-73.9749, 40.7736], + zoom: 12.5, + bearing: 29, + pitch: 50, + sources: {}, + layers: [] + } as StyleSpecification; +} diff --git a/web/libraries/maplibre-gl/src/ui/map.ts b/web/libraries/maplibre-gl/src/ui/map.ts new file mode 100644 index 00000000..4ecd20d6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map.ts @@ -0,0 +1,3435 @@ +import {extend, warnOnce, uniqueId, isImageBitmap} from '../util/util'; +import {browser} from '../util/browser'; +import {DOM} from '../util/dom'; +import packageJSON from '../../package.json' assert {type: 'json'}; + +import {getJSON} from '../util/ajax'; +import {ImageRequest} from '../util/image_request'; +import type {GetImageCallback} from '../util/image_request'; + +import {RequestManager, ResourceType} from '../util/request_manager'; +import {Style, StyleSwapOptions} from '../style/style'; +import {EvaluationParameters} from '../style/evaluation_parameters'; +import {Painter} from '../render/painter'; +import {Transform} from '../geo/transform'; +import {Hash} from './hash'; +import {HandlerManager} from './handler_manager'; +import {Camera, CameraOptions, CameraUpdateTransformFunction, FitBoundsOptions} from './camera'; +import {LngLat} from '../geo/lng_lat'; +import {LngLatBounds} from '../geo/lng_lat_bounds'; +import Point from '@mapbox/point-geometry'; +import {AttributionControl} from './control/attribution_control'; +import {LogoControl} from './control/logo_control'; + +import {RGBAImage} from '../util/image'; +import {Event, ErrorEvent, Listener} from '../util/evented'; +import {MapEventType, MapLayerEventType, MapMouseEvent, MapSourceDataEvent, MapStyleDataEvent} from './events'; +import {TaskQueue} from '../util/task_queue'; +import {throttle} from '../util/throttle'; +import {webpSupported} from '../util/webp_supported'; +import {PerformanceMarkers, PerformanceUtils} from '../util/performance'; +import {Source, SourceClass} from '../source/source'; +import {StyleLayer} from '../style/style_layer'; + +import type {RequestTransformFunction} from '../util/request_manager'; +import type {LngLatLike} from '../geo/lng_lat'; +import type {LngLatBoundsLike} from '../geo/lng_lat_bounds'; +import type {AddLayerObject, FeatureIdentifier, StyleOptions, StyleSetterOptions} from '../style/style'; +import type {MapDataEvent} from './events'; +import type {StyleImage, StyleImageInterface, StyleImageMetadata} from '../style/style_image'; +import type {PointLike} from './camera'; +import type {ScrollZoomHandler} from './handler/scroll_zoom'; +import type {BoxZoomHandler} from './handler/box_zoom'; +import type {AroundCenterOptions, TwoFingersTouchPitchHandler} from './handler/two_fingers_touch'; +import type {DragRotateHandler} from './handler/shim/drag_rotate'; +import {DragPanHandler, DragPanOptions} from './handler/shim/drag_pan'; + +import type {KeyboardHandler} from './handler/keyboard'; +import type {DoubleClickZoomHandler} from './handler/shim/dblclick_zoom'; +import type {TwoFingersTouchZoomRotateHandler} from './handler/shim/two_fingers_touch'; +import {defaultLocale} from './default_locale'; +import type {TaskID} from '../util/task_queue'; +import type {Cancelable} from '../types/cancelable'; +import type { + FilterSpecification, + StyleSpecification, + LightSpecification, + SourceSpecification, + TerrainSpecification +} from '@maplibre/maplibre-gl-style-spec'; + +import {Callback} from '../types/callback'; +import type {ControlPosition, IControl} from './control/control'; +import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson'; +import {Terrain} from '../render/terrain'; +import {RenderToTexture} from '../render/render_to_texture'; +import {config} from '../util/config'; +import type {QueryRenderedFeaturesOptions, QuerySourceFeatureOptions} from '../source/query_features'; + +const version = packageJSON.version; + +/** + * The {@link Map} options object. + */ +export type MapOptions = { + /** + * If `true`, the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL. + * For example, `http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60`. + * An additional string may optionally be provided to indicate a parameter-styled hash, + * e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar, where foo + * is a custom parameter and bar is an arbitrary hash distinct from the map hash. + * @defaultValue false + */ + hash?: boolean | string; + /** + * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction. + * @defaultValue true + */ + interactive?: boolean; + /** + * The HTML element in which MapLibre GL JS will render the map, or the element's string `id`. The specified element must have no children. + */ + container: HTMLElement | string; + /** + * The threshold, measured in degrees, that determines when the map's + * bearing will snap to north. For example, with a `bearingSnap` of 7, if the user rotates + * the map within 7 degrees of north, the map will automatically snap to exact north. + * @defaultValue 7 + */ + bearingSnap?: number; + /** + * If `true`, an {@link AttributionControl} will be added to the map. + * @defaultValue true + */ + attributionControl?: boolean; + /** + * Attribution text to show in an {@link AttributionControl}. Only applicable if `options.attributionControl` is `true`. + */ + customAttribution?: string | Array; + /** + * If `true`, the MapLibre logo will be shown. + * @defaultValue false + */ + maplibreLogo?: boolean; + /** + * A string representing the position of the MapLibre wordmark on the map. Valid options are `top-left`,`top-right`, `bottom-left`, or `bottom-right`. + * @defaultValue 'bottom-left' + */ + logoPosition?: ControlPosition; + /** + * If `true`, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected + * (i.e. a software renderer would be used). + * @defaultValue false + */ + failIfMajorPerformanceCaveat?: boolean; + /** + * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization. + * @defaultValue false + */ + preserveDrawingBuffer?: boolean; + /** + * If `true`, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. This is `false` by default as a performance optimization. + */ + antialias?: boolean; + /** + * If `false`, the map won't attempt to re-request tiles once they expire per their HTTP `cacheControl`/`expires` headers. + * @defaultValue true + */ + refreshExpiredTiles?: boolean; + /** + * If set, the map will be constrained to the given bounds. + */ + maxBounds?: LngLatBoundsLike; + /** + * If `true`, the "scroll to zoom" interaction is enabled. {@link AroundCenterOptions} are passed as options to {@link ScrollZoomHandler#enable}. + * @defaultValue true + */ + scrollZoom?: boolean | AroundCenterOptions; + /** + * The minimum zoom level of the map (0-24). + * @defaultValue 0 + */ + minZoom?: number | null; + /** + * The maximum zoom level of the map (0-24). + * @defaultValue 22 + */ + maxZoom?: number | null; + /** + * The minimum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * @defaultValue 0 + */ + minPitch?: number | null; + /** + * The maximum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * @defaultValue 60 + */ + maxPitch?: number | null; + /** + * If `true`, the "box zoom" interaction is enabled (see {@link BoxZoomHandler}). + * @defaultValue true + */ + boxZoom?: boolean; + /** + * If `true`, the "drag to rotate" interaction is enabled (see {@link DragRotateHandler}). + * @defaultValue true + */ + dragRotate?: boolean; + /** + * If `true`, the "drag to pan" interaction is enabled. An `Object` value is passed as options to {@link DragPanHandler#enable}. + * @defaultValue true + */ + dragPan?: boolean | DragPanOptions; + /** + * If `true`, keyboard shortcuts are enabled (see {@link KeyboardHandler}). + * @defaultValue true + */ + keyboard?: boolean; + /** + * If `true`, the "double click to zoom" interaction is enabled (see {@link DoubleClickZoomHandler}). + * @defaultValue true + */ + doubleClickZoom?: boolean; + /** + * If `true`, the "pinch to rotate and zoom" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchZoomRotateHandler#enable}. + * @defaultValue true + */ + touchZoomRotate?: boolean | AroundCenterOptions; + /** + * If `true`, the "drag to pitch" interaction is enabled. An `Object` value is passed as options to {@link TwoFingersTouchPitchHandler#enable}. + * @defaultValue true + */ + touchPitch?: boolean | AroundCenterOptions; + /** + * If `true` or set to an options object, the map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, "drag to pitch" requires a three-finger gesture. Cooperative gestures are disabled when a map enters fullscreen using {@link FullscreenControl}. + * @defaultValue undefined + */ + cooperativeGestures?: boolean | GestureOptions; + /** + * If `true`, the map will automatically resize when the browser window resizes. + * @defaultValue true + */ + trackResize?: boolean; + /** + * The initial geographical centerpoint of the map. If `center` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON. + * @defaultValue [0, 0] + */ + center?: LngLatLike; + /** + * The initial zoom level of the map. If `zoom` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. + * @defaultValue 0 + */ + zoom?: number; + /** + * The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If `bearing` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. + * @defaultValue 0 + */ + bearing?: number; + /** + * The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If `pitch` is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * @defaultValue 0 + */ + pitch?: number; + /** + * If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * @defaultValue true + */ + renderWorldCopies?: boolean; + /** + * The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport which can be set using `maxTileCacheZoomLevels` constructor options. + * @defaultValue null + */ + maxTileCacheSize?: number; + /** + * The maximum number of zoom levels for which to store tiles for a given source. Tile cache dynamic size is calculated by multiplying `maxTileCacheZoomLevels` with the approximate number of tiles in the viewport for a given source. + * @defaultValue 5 + */ + maxTileCacheZoomLevels?: number; + /** + * A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. + * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties. + */ + transformRequest?: RequestTransformFunction; + /** + * A callback run before the map's camera is moved due to user input or animation. The callback can be used to modify the new center, zoom, pitch and bearing. + * Expected to return an object containing center, zoom, pitch or bearing values to overwrite. + */ + transformCameraUpdate?: CameraUpdateTransformFunction; + /** + * A patch to apply to the default localization table for UI strings, e.g. control tooltips. The `locale` object maps namespaced UI string IDs to translated strings in the target language; see `src/ui/default_locale.js` for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table). + * @defaultValue null + */ + locale?: any; + /** + * Controls the duration of the fade-in/fade-out animation for label collisions after initial map load, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading. + * @defaultValue 300 + */ + fadeDuration?: number; + /** + * If `true`, symbols from multiple sources can collide with each other during collision detection. If `false`, collision detection is run separately for the symbols in each source. + * @defaultValue true + */ + crossSourceCollisions?: boolean; + /** + * If `true`, Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers (this information is normally inaccessible from the main Javascript thread). Information will be returned in a `resourceTiming` property of relevant `data` events. + * @defaultValue false + */ + collectResourceTiming?: boolean; + /** + * The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag). + * @defaultValue true + */ + clickTolerance?: number; + /** + * The initial bounds of the map. If `bounds` is specified, it overrides `center` and `zoom` constructor options. + */ + bounds?: LngLatBoundsLike; + /** + * A {@link FitBoundsOptions} options object to use _only_ when fitting the initial `bounds` provided above. + */ + fitBoundsOptions?: FitBoundsOptions; + /** + * Defines a CSS + * font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' and 'Hangul Syllables' ranges. + * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold). + * Set to `false`, to enable font settings from the map's style for these glyph ranges. + * The purpose of this option is to avoid bandwidth-intensive glyph server requests. (See [Use locally generated ideographs](https://maplibre.org/maplibre-gl-js/docs/examples/local-ideographs).) + * @defaultValue 'sans-serif' + */ + localIdeographFontFamily?: string; + /** + * The map's MapLibre style. This must be a JSON object conforming to + * the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), + * or a URL to such JSON. + */ + style: StyleSpecification | string; + /** + * If `false`, the map's pitch (tilt) control with "drag to rotate" interaction will be disabled. + * @defaultValue true + */ + pitchWithRotate?: boolean; + /** + * The pixel ratio. The canvas' `width` attribute will be `container.clientWidth * pixelRatio` and its `height` attribute will be `container.clientHeight * pixelRatio`. Defaults to `devicePixelRatio` if not specified. + */ + pixelRatio?: number; + /** + * If false, style validation will be skipped. Useful in production environment. + * @defaultValue true + */ + validateStyle?: boolean; + /** + * The canvas' `width` and `height` max size. The values are passed as an array where the first element is max width and the second element is max height. + * You shouldn't set this above WebGl `MAX_TEXTURE_SIZE`. Defaults to [4096, 4096]. + */ + maxCanvasSize?: [number, number]; +}; + +/** + * An options object for the gesture settings + * @example + * ```ts + * let options = { + * windowsHelpText: "Use Ctrl + scroll to zoom the map", + * macHelpText: "Use ⌘ + scroll to zoom the map", + * mobileHelpText: "Use two fingers to move the map", + * } + * ``` + */ +export type GestureOptions = { + windowsHelpText?: string; + macHelpText?: string; + mobileHelpText?: string; +}; + +export type AddImageOptions = { + +} + +// See article here: https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585 +type Complete = { + [P in keyof Required]: Pick extends Required> ? T[P] : (T[P] | undefined); +} + +// This type is used inside map since all properties are assigned a default value. +export type CompleteMapOptions = Complete; + +const defaultMinZoom = -2; +const defaultMaxZoom = 22; + +// the default values, but also the valid range +const defaultMinPitch = 0; +const defaultMaxPitch = 60; + +// use this variable to check maxPitch for validity +const maxPitchThreshold = 85; + +const defaultOptions = { + center: [0, 0], + zoom: 0, + bearing: 0, + pitch: 0, + + minZoom: defaultMinZoom, + maxZoom: defaultMaxZoom, + + minPitch: defaultMinPitch, + maxPitch: defaultMaxPitch, + + interactive: true, + scrollZoom: true, + boxZoom: true, + dragRotate: true, + dragPan: true, + keyboard: true, + doubleClickZoom: true, + touchZoomRotate: true, + touchPitch: true, + cooperativeGestures: undefined, + + bearingSnap: 7, + clickTolerance: 3, + pitchWithRotate: true, + + hash: false, + attributionControl: true, + maplibreLogo: false, + + failIfMajorPerformanceCaveat: false, + preserveDrawingBuffer: false, + trackResize: true, + renderWorldCopies: true, + refreshExpiredTiles: true, + maxTileCacheSize: null, + maxTileCacheZoomLevels: config.MAX_TILE_CACHE_ZOOM_LEVELS, + localIdeographFontFamily: 'sans-serif', + transformRequest: null, + transformCameraUpdate: null, + fadeDuration: 300, + crossSourceCollisions: true, + validateStyle: true, + /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */ + maxCanvasSize: [4096, 4096] +} as CompleteMapOptions; + +/** + * The `Map` object represents the map on your page. It exposes methods + * and properties that enable you to programmatically change the map, + * and fires events as users interact with it. + * + * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list. + * Then MapLibre GL JS initializes the map on the page and returns your `Map` object. + * + * @group Main + * + * @example + * ```ts + * let map = new maplibregl.Map({ + * container: 'map', + * center: [-122.420679, 37.772537], + * zoom: 13, + * style: style_object, + * hash: true, + * transformRequest: (url, resourceType)=> { + * if(resourceType === 'Source' && url.startsWith('http://myHost')) { + * return { + * url: url.replace('http', 'https'), + * headers: { 'my-custom-header': true}, + * credentials: 'include' // Include cookies for cross-origin requests + * } + * } + * } + * }); + * ``` + * @see [Display a map](https://maplibre.org/maplibre-gl-js/docs/examples/simple-map/) + */ +export class Map extends Camera { + style: Style; + painter: Painter; + handlers: HandlerManager; + + _container: HTMLElement; + _canvasContainer: HTMLElement; + _controlContainer: HTMLElement; + _controlPositions: {[_: string]: HTMLElement}; + _interactive: boolean; + _cooperativeGestures: boolean | GestureOptions; + _cooperativeGesturesScreen: HTMLElement; + _metaKey: keyof MouseEvent; + _showTileBoundaries: boolean; + _showCollisionBoxes: boolean; + _showPadding: boolean; + _showOverdrawInspector: boolean; + _repaint: boolean; + _vertices: boolean; + _canvas: HTMLCanvasElement; + _maxTileCacheSize: number; + _maxTileCacheZoomLevels: number; + _frame: Cancelable; + _styleDirty: boolean; + _sourcesDirty: boolean; + _placementDirty: boolean; + + _loaded: boolean; + _idleTriggered: boolean; + // accounts for placement finishing as well + _fullyLoaded: boolean; + _trackResize: boolean; + _resizeObserver: ResizeObserver; + _preserveDrawingBuffer: boolean; + _failIfMajorPerformanceCaveat: boolean; + _antialias: boolean; + _refreshExpiredTiles: boolean; + _hash: Hash; + _delegatedListeners: any; + _fadeDuration: number; + _crossSourceCollisions: boolean; + _crossFadingFactor: number; + _collectResourceTiming: boolean; + _renderTaskQueue: TaskQueue; + _controls: Array; + _mapId: number; + _localIdeographFontFamily: string; + _validateStyle: boolean; + _requestManager: RequestManager; + _locale: any; + _removed: boolean; + _clickTolerance: number; + _overridePixelRatio: number | null; + _maxCanvasSize: [number, number]; + _terrainDataCallback: (e: MapStyleDataEvent | MapSourceDataEvent) => void; + + /** + * @internal + * image queue throttling handle. To be used later when clean up + */ + _imageQueueHandle: number; + + /** + * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad. + * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section. + */ + scrollZoom: ScrollZoomHandler; + + /** + * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed. + * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section. + */ + boxZoom: BoxZoomHandler; + + /** + * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right + * mouse button or with the Control key pressed. Find more details and examples using `dragRotate` + * in the {@link DragRotateHandler} section. + */ + dragRotate: DragRotateHandler; + + /** + * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture. + * Find more details and examples using `dragPan` in the {@link DragPanHandler} section. + */ + dragPan: DragPanHandler; + + /** + * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard + * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section. + */ + keyboard: KeyboardHandler; + + /** + * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking. + * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section. + */ + doubleClickZoom: DoubleClickZoomHandler; + + /** + * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures. + * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section. + */ + touchZoomRotate: TwoFingersTouchZoomRotateHandler; + + /** + * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures. + * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section. + */ + touchPitch: TwoFingersTouchPitchHandler; + + constructor(options: MapOptions) { + PerformanceUtils.mark(PerformanceMarkers.create); + + options = extend({}, defaultOptions, options); + + if (options.minZoom != null && options.maxZoom != null && options.minZoom > options.maxZoom) { + throw new Error('maxZoom must be greater than or equal to minZoom'); + } + + if (options.minPitch != null && options.maxPitch != null && options.minPitch > options.maxPitch) { + throw new Error('maxPitch must be greater than or equal to minPitch'); + } + + if (options.minPitch != null && options.minPitch < defaultMinPitch) { + throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`); + } + + if (options.maxPitch != null && options.maxPitch > maxPitchThreshold) { + throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`); + } + + const transform = new Transform(options.minZoom, options.maxZoom, options.minPitch, options.maxPitch, options.renderWorldCopies); + super(transform, {bearingSnap: options.bearingSnap}); + + this._interactive = options.interactive; + this._cooperativeGestures = options.cooperativeGestures; + this._metaKey = navigator.platform.indexOf('Mac') === 0 ? 'metaKey' : 'ctrlKey'; + this._maxTileCacheSize = options.maxTileCacheSize; + this._maxTileCacheZoomLevels = options.maxTileCacheZoomLevels; + this._failIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat; + this._preserveDrawingBuffer = options.preserveDrawingBuffer; + this._antialias = options.antialias; + this._trackResize = options.trackResize; + this._bearingSnap = options.bearingSnap; + this._refreshExpiredTiles = options.refreshExpiredTiles; + this._fadeDuration = options.fadeDuration; + this._crossSourceCollisions = options.crossSourceCollisions; + this._crossFadingFactor = 1; + this._collectResourceTiming = options.collectResourceTiming; + this._renderTaskQueue = new TaskQueue(); + this._controls = []; + this._mapId = uniqueId(); + this._locale = extend({}, defaultLocale, options.locale); + this._clickTolerance = options.clickTolerance; + this._overridePixelRatio = options.pixelRatio; + this._maxCanvasSize = options.maxCanvasSize; + this.transformCameraUpdate = options.transformCameraUpdate; + + this._imageQueueHandle = ImageRequest.addThrottleControl(() => this.isMoving()); + + this._requestManager = new RequestManager(options.transformRequest); + + if (typeof options.container === 'string') { + this._container = document.getElementById(options.container); + if (!this._container) { + throw new Error(`Container '${options.container}' not found.`); + } + } else if (options.container instanceof HTMLElement) { + this._container = options.container; + } else { + throw new Error('Invalid type: \'container\' must be a String or HTMLElement.'); + } + + if (options.maxBounds) { + this.setMaxBounds(options.maxBounds); + } + + this._setupContainer(); + this._setupPainter(); + + this.on('move', () => this._update(false)); + this.on('moveend', () => this._update(false)); + this.on('zoom', () => this._update(true)); + this.on('terrain', () => { + this.painter.terrainFacilitator.dirty = true; + this._update(true); + }); + this.once('idle', () => { this._idleTriggered = true; }); + + if (typeof window !== 'undefined') { + addEventListener('online', this._onWindowOnline, false); + let initialResizeEventCaptured = false; + const throttledResizeCallback = throttle((entries: ResizeObserverEntry[]) => { + if (this._trackResize && !this._removed) { + this.resize(entries)._update(); + } + }, 50); + this._resizeObserver = new ResizeObserver((entries) => { + if (!initialResizeEventCaptured) { + initialResizeEventCaptured = true; + return; + } + throttledResizeCallback(entries); + }); + this._resizeObserver.observe(this._container); + } + + this.handlers = new HandlerManager(this, options as CompleteMapOptions); + + if (this._cooperativeGestures) { + this._setupCooperativeGestures(); + } + + const hashName = (typeof options.hash === 'string' && options.hash) || undefined; + this._hash = options.hash && (new Hash(hashName)).addTo(this); + // don't set position from options if set through hash + if (!this._hash || !this._hash._onHashChange()) { + this.jumpTo({ + center: options.center, + zoom: options.zoom, + bearing: options.bearing, + pitch: options.pitch + }); + + if (options.bounds) { + this.resize(); + this.fitBounds(options.bounds, extend({}, options.fitBoundsOptions, {duration: 0})); + } + } + + this.resize(); + + this._localIdeographFontFamily = options.localIdeographFontFamily; + this._validateStyle = options.validateStyle; + + if (options.style) this.setStyle(options.style, {localIdeographFontFamily: options.localIdeographFontFamily}); + + if (options.attributionControl) + this.addControl(new AttributionControl({customAttribution: options.customAttribution})); + + if (options.maplibreLogo) + this.addControl(new LogoControl(), options.logoPosition); + + this.on('style.load', () => { + if (this.transform.unmodified) { + this.jumpTo(this.style.stylesheet as any); + } + }); + this.on('data', (event: MapDataEvent) => { + this._update(event.dataType === 'style'); + this.fire(new Event(`${event.dataType}data`, event)); + }); + this.on('dataloading', (event: MapDataEvent) => { + this.fire(new Event(`${event.dataType}dataloading`, event)); + }); + this.on('dataabort', (event: MapDataEvent) => { + this.fire(new Event('sourcedataabort', event)); + }); + } + + /** + * @internal + * Returns a unique number for this map instance which is used for the MapLoadEvent + * to make sure we only fire one event per instantiated map object. + * @returns the uniq map ID + */ + _getMapId() { + return this._mapId; + } + + /** + * Adds an {@link IControl} to the map, calling `control.onAdd(this)`. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param control - The {@link IControl} to add. + * @param position - position on the map to which the control will be added. + * Valid values are `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. Defaults to `'top-right'`. + * @returns `this` + * @example + * Add zoom and rotation controls to the map. + * ```ts + * map.addControl(new maplibregl.NavigationControl()); + * ``` + * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/) + */ + addControl(control: IControl, position?: ControlPosition): Map { + if (position === undefined) { + if (control.getDefaultPosition) { + position = control.getDefaultPosition(); + } else { + position = 'top-right'; + } + } + if (!control || !control.onAdd) { + return this.fire(new ErrorEvent(new Error( + 'Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.'))); + } + const controlElement = control.onAdd(this); + this._controls.push(control); + + const positionContainer = this._controlPositions[position]; + if (position.indexOf('bottom') !== -1) { + positionContainer.insertBefore(controlElement, positionContainer.firstChild); + } else { + positionContainer.appendChild(controlElement); + } + return this; + } + + /** + * Removes the control from the map. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param control - The {@link IControl} to remove. + * @returns `this` + * @example + * ```ts + * // Define a new navigation control. + * let navigation = new maplibregl.NavigationControl(); + * // Add zoom and rotation controls to the map. + * map.addControl(navigation); + * // Remove zoom and rotation controls from the map. + * map.removeControl(navigation); + * ``` + */ + removeControl(control: IControl): Map { + if (!control || !control.onRemove) { + return this.fire(new ErrorEvent(new Error( + 'Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.'))); + } + const ci = this._controls.indexOf(control); + if (ci > -1) this._controls.splice(ci, 1); + control.onRemove(this); + return this; + } + + /** + * Checks if a control exists on the map. + * + * @param control - The {@link IControl} to check. + * @returns true if map contains control. + * @example + * ```ts + * // Define a new navigation control. + * let navigation = new maplibregl.NavigationControl(); + * // Add zoom and rotation controls to the map. + * map.addControl(navigation); + * // Check that the navigation control exists on the map. + * map.hasControl(navigation); + * ``` + */ + hasControl(control: IControl): boolean { + return this._controls.indexOf(control) > -1; + } + + calculateCameraOptionsFromTo(from: LngLat, altitudeFrom: number, to: LngLat, altitudeTo?: number): CameraOptions { + if (altitudeTo == null && this.terrain) { + altitudeTo = this.terrain.getElevationForLngLatZoom(to, this.transform.tileZoom); + } + return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo); + } + + /** + * Resizes the map according to the dimensions of its + * `container` element. + * + * Checks if the map container size changed and updates the map if it has changed. + * This method must be called after the map's `container` is resized programmatically + * or when the map is shown after being initially hidden with CSS. + * + * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`. + * + * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend` + * events that get triggered as a result of resize. This can be useful for differentiating the + * source of an event (for example, user-initiated or programmatically-triggered events). + * @returns `this` + * @example + * Resize the map when the map container is shown after being initially hidden with CSS. + * ```ts + * let mapDiv = document.getElementById('map'); + * if (mapDiv.style.visibility === true) map.resize(); + * ``` + */ + resize(eventData?: any): Map { + const dimensions = this._containerDimensions(); + const width = dimensions[0]; + const height = dimensions[1]; + + const clampedPixelRatio = this._getClampedPixelRatio(width, height); + this._resizeCanvas(width, height, clampedPixelRatio); + this.painter.resize(width, height, clampedPixelRatio); + + // check if we've reached GL limits, in that case further clamps pixelRatio + if (this.painter.overLimit()) { + const gl = this.painter.context.gl; + // store updated _maxCanvasSize value + this._maxCanvasSize = [gl.drawingBufferWidth, gl.drawingBufferHeight]; + const clampedPixelRatio = this._getClampedPixelRatio(width, height); + this._resizeCanvas(width, height, clampedPixelRatio); + this.painter.resize(width, height, clampedPixelRatio); + } + + this.transform.resize(width, height); + this._requestedCameraState?.resize(width, height); + + const fireMoving = !this._moving; + if (fireMoving) { + this.stop(); + this.fire(new Event('movestart', eventData)) + .fire(new Event('move', eventData)); + } + + this.fire(new Event('resize', eventData)); + + if (fireMoving) this.fire(new Event('moveend', eventData)); + + return this; + } + + /** + * @internal + * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize. + * Internally you should use this and not getPixelRatio(). + */ + _getClampedPixelRatio(width: number, height: number): number { + const {0: maxCanvasWidth, 1: maxCanvasHeight} = this._maxCanvasSize; + const pixelRatio = this.getPixelRatio(); + + const canvasWidth = width * pixelRatio; + const canvasHeight = height * pixelRatio; + + const widthScaleFactor = canvasWidth > maxCanvasWidth ? (maxCanvasWidth / canvasWidth) : 1; + const heightScaleFactor = canvasHeight > maxCanvasHeight ? (maxCanvasHeight / canvasHeight) : 1; + + return Math.min(widthScaleFactor, heightScaleFactor) * pixelRatio; + } + + /** + * Returns the map's pixel ratio. + * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize. + * @returns The pixel ratio. + */ + getPixelRatio(): number { + return this._overridePixelRatio ?? devicePixelRatio; + } + + /** + * Sets the map's pixel ratio. This allows to override `devicePixelRatio`. + * After this call, the canvas' `width` attribute will be `container.clientWidth * pixelRatio` + * and its height attribute will be `container.clientHeight * pixelRatio`. + * Set this to null to disable `devicePixelRatio` override. + * Note that the pixel ratio actually applied may be lower to respect maxCanvasSize. + * @param pixelRatio - The pixel ratio. + */ + setPixelRatio(pixelRatio: number) { + this._overridePixelRatio = pixelRatio; + this.resize(); + } + + /** + * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not + * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. + * @returns The geographical bounds of the map as {@link LngLatBounds}. + * @example + * ```ts + * let bounds = map.getBounds(); + * ``` + */ + getBounds(): LngLatBounds { + return this.transform.getBounds(); + } + + /** + * Returns the maximum geographical bounds the map is constrained to, or `null` if none set. + * @returns The map object. + * @example + * ```ts + * let maxBounds = map.getMaxBounds(); + * ``` + */ + getMaxBounds(): LngLatBounds | null { + return this.transform.getMaxBounds(); + } + + /** + * Sets or clears the map's geographical bounds. + * + * Pan and zoom operations are constrained within these bounds. + * If a pan or zoom is performed that would + * display regions outside these bounds, the map will + * instead display a position and zoom level + * as close as possible to the operation's request while still + * remaining within the bounds. + * + * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds. + * @returns `this` + * @example + * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds. + * ```ts + * let bounds = [ + * [-74.04728, 40.68392], // [west, south] + * [-73.91058, 40.87764] // [east, north] + * ]; + * map.setMaxBounds(bounds); + * ``` + */ + setMaxBounds(bounds?: LngLatBoundsLike | null): Map { + this.transform.setMaxBounds(LngLatBounds.convert(bounds)); + return this._update(); + } + + /** + * Sets or clears the map's minimum zoom level. + * If the map's current zoom level is lower than the new minimum, + * the map will zoom to the new minimum. + * + * It is not always possible to zoom out and reach the set `minZoom`. + * Other factors such as map height may restrict zooming. For example, + * if the map is 512px tall it will not be possible to zoom below zoom 0 + * no matter what the `minZoom` is set to. + * + * A {@link ErrorEvent} event will be fired if minZoom is out of bounds. + * + * @param minZoom - The minimum zoom level to set (-2 - 24). + * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2). + * @returns `this` + * @example + * ```ts + * map.setMinZoom(12.25); + * ``` + */ + setMinZoom(minZoom?: number | null): Map { + + minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom; + + if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) { + this.transform.minZoom = minZoom; + this._update(); + + if (this.getZoom() < minZoom) this.setZoom(minZoom); + + return this; + + } else throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`); + } + + /** + * Returns the map's minimum allowable zoom level. + * + * @returns minZoom + * @example + * ```ts + * let minZoom = map.getMinZoom(); + * ``` + */ + getMinZoom(): number { return this.transform.minZoom; } + + /** + * Sets or clears the map's maximum zoom level. + * If the map's current zoom level is higher than the new maximum, + * the map will zoom to the new maximum. + * + * A {@link ErrorEvent} event will be fired if minZoom is out of bounds. + * + * @param maxZoom - The maximum zoom level to set. + * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22). + * @returns `this` + * @example + * ```ts + * map.setMaxZoom(18.75); + * ``` + */ + setMaxZoom(maxZoom?: number | null): Map { + + maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom; + + if (maxZoom >= this.transform.minZoom) { + this.transform.maxZoom = maxZoom; + this._update(); + + if (this.getZoom() > maxZoom) this.setZoom(maxZoom); + + return this; + + } else throw new Error('maxZoom must be greater than the current minZoom'); + } + + /** + * Returns the map's maximum allowable zoom level. + * + * @returns The maxZoom + * @example + * ```ts + * let maxZoom = map.getMaxZoom(); + * ``` + */ + getMaxZoom(): number { return this.transform.maxZoom; } + + /** + * Sets or clears the map's minimum pitch. + * If the map's current pitch is lower than the new minimum, + * the map will pitch to the new minimum. + * + * A {@link ErrorEvent} event will be fired if minPitch is out of bounds. + * + * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0). + * @returns `this` + */ + setMinPitch(minPitch?: number | null): Map { + + minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch; + + if (minPitch < defaultMinPitch) { + throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`); + } + + if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) { + this.transform.minPitch = minPitch; + this._update(); + + if (this.getPitch() < minPitch) this.setPitch(minPitch); + + return this; + + } else throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`); + } + + /** + * Returns the map's minimum allowable pitch. + * + * @returns The minPitch + */ + getMinPitch(): number { return this.transform.minPitch; } + + /** + * Sets or clears the map's maximum pitch. + * If the map's current pitch is higher than the new maximum, + * the map will pitch to the new maximum. + * + * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds. + * + * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. + * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60). + * @returns `this` + */ + setMaxPitch(maxPitch?: number | null): Map { + + maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch; + + if (maxPitch > maxPitchThreshold) { + throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`); + } + + if (maxPitch >= this.transform.minPitch) { + this.transform.maxPitch = maxPitch; + this._update(); + + if (this.getPitch() > maxPitch) this.setPitch(maxPitch); + + return this; + + } else throw new Error('maxPitch must be greater than the current minPitch'); + } + + /** + * Returns the map's maximum allowable pitch. + * + * @returns The maxPitch + */ + getMaxPitch(): number { return this.transform.maxPitch; } + + /** + * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * @returns The renderWorldCopies + * @example + * ```ts + * let worldCopiesRendered = map.getRenderWorldCopies(); + * ``` + * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/) + */ + getRenderWorldCopies(): boolean { return this.transform.renderWorldCopies; } + + /** + * Sets the state of `renderWorldCopies`. + * + * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: + * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire + * container, there will be blank space beyond 180 and -180 degrees longitude. + * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the + * map and the other on the left edge of the map) at every zoom level. + * + * `undefined` is treated as `true`, `null` is treated as `false`. + * @returns `this` + * @example + * ```ts + * map.setRenderWorldCopies(true); + * ``` + * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/) + */ + setRenderWorldCopies(renderWorldCopies?: boolean | null): Map { + this.transform.renderWorldCopies = renderWorldCopies; + return this._update(); + } + + /** + * Gets the map's cooperativeGestures option + * + * @returns The gestureOptions + */ + getCooperativeGestures(): boolean | GestureOptions { + return this._cooperativeGestures; + } + + /** + * Sets or clears the map's cooperativeGestures option + * + * @param gestureOptions - If `true` or set to an options object, map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, "drag to pitch" requires a three-finger gesture. + * @returns `this` + */ + setCooperativeGestures(gestureOptions?: GestureOptions | boolean | null): Map { + this._cooperativeGestures = gestureOptions; + if (this._cooperativeGestures) { + this._setupCooperativeGestures(); + } else { + this._destroyCooperativeGestures(); + } + + return this; + } + + /** + * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`, + * that correspond to the specified geographical location. + * + * @param lnglat - The geographical location to project. + * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`. + * @example + * ```ts + * let coordinate = [-122.420679, 37.772537]; + * let point = map.project(coordinate); + * ``` + */ + project(lnglat: LngLatLike): Point { + return this.transform.locationPoint(LngLat.convert(lnglat), this.style && this.terrain); + } + + /** + * Returns a {@link LngLat} representing geographical coordinates that correspond + * to the specified pixel coordinates. + * + * @param point - The pixel coordinates to unproject. + * @returns The {@link LngLat} corresponding to `point`. + * @example + * ```ts + * map.on('click', function(e) { + * // When the map is clicked, get the geographic coordinate. + * let coordinate = map.unproject(e.point); + * }); + * ``` + */ + unproject(point: PointLike): LngLat { + return this.transform.pointLocation(Point.convert(point), this.terrain); + } + + /** + * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture. + * @returns true if the map is moving. + * @example + * ```ts + * let isMoving = map.isMoving(); + * ``` + */ + isMoving(): boolean { + return this._moving || this.handlers?.isMoving(); + } + + /** + * Returns true if the map is zooming due to a camera animation or user gesture. + * @returns true if the map is zooming. + * @example + * ```ts + * let isZooming = map.isZooming(); + * ``` + */ + isZooming(): boolean { + return this._zooming || this.handlers?.isZooming(); + } + + /** + * Returns true if the map is rotating due to a camera animation or user gesture. + * @returns true if the map is rotating. + * @example + * ```ts + * map.isRotating(); + * ``` + */ + isRotating(): boolean { + return this._rotating || this.handlers?.isRotating(); + } + + _createDelegatedListener(type: keyof MapEventType | string, layerId: string, listener: Listener): { + layer: string; + listener: Listener; + delegates: {[type in keyof MapEventType]?: (e: any) => void}; + } { + if (type === 'mouseenter' || type === 'mouseover') { + let mousein = false; + const mousemove = (e) => { + const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : []; + if (!features.length) { + mousein = false; + } else if (!mousein) { + mousein = true; + listener.call(this, new MapMouseEvent(type, this, e.originalEvent, {features})); + } + }; + const mouseout = () => { + mousein = false; + }; + return {layer: layerId, listener, delegates: {mousemove, mouseout}}; + } else if (type === 'mouseleave' || type === 'mouseout') { + let mousein = false; + const mousemove = (e) => { + const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : []; + if (features.length) { + mousein = true; + } else if (mousein) { + mousein = false; + listener.call(this, new MapMouseEvent(type, this, e.originalEvent)); + } + }; + const mouseout = (e) => { + if (mousein) { + mousein = false; + listener.call(this, new MapMouseEvent(type, this, e.originalEvent)); + } + }; + return {layer: layerId, listener, delegates: {mousemove, mouseout}}; + } else { + const delegate = (e) => { + const features = this.getLayer(layerId) ? this.queryRenderedFeatures(e.point, {layers: [layerId]}) : []; + if (features.length) { + // Here we need to mutate the original event, so that preventDefault works as expected. + e.features = features; + listener.call(this, e); + delete e.features; + } + }; + return {layer: layerId, listener, delegates: {[type]: delegate}}; + } + } + + /** + * @event + * Adds a listener for events of a specified type, optionally limited to features in a specified style layer. + * See {@link MapEventType} and {@link MapLayerEventType} for a full list of events and their description. + * + * | Event | Compatible with `layerId` | + * |------------------------|---------------------------| + * | `mousedown` | yes | + * | `mouseup` | yes | + * | `mouseover` | yes | + * | `mouseout` | yes | + * | `mousemove` | yes | + * | `mouseenter` | yes (required) | + * | `mouseleave` | yes (required) | + * | `click` | yes | + * | `dblclick` | yes | + * | `contextmenu` | yes | + * | `touchstart` | yes | + * | `touchend` | yes | + * | `touchcancel` | yes | + * | `wheel` | | + * | `resize` | | + * | `remove` | | + * | `touchmove` | | + * | `movestart` | | + * | `move` | | + * | `moveend` | | + * | `dragstart` | | + * | `drag` | | + * | `dragend` | | + * | `zoomstart` | | + * | `zoom` | | + * | `zoomend` | | + * | `rotatestart` | | + * | `rotate` | | + * | `rotateend` | | + * | `pitchstart` | | + * | `pitch` | | + * | `pitchend` | | + * | `boxzoomstart` | | + * | `boxzoomend` | | + * | `boxzoomcancel` | | + * | `webglcontextlost` | | + * | `webglcontextrestored` | | + * | `load` | | + * | `render` | | + * | `idle` | | + * | `error` | | + * | `data` | | + * | `styledata` | | + * | `sourcedata` | | + * | `dataloading` | | + * | `styledataloading` | | + * | `sourcedataloading` | | + * | `styleimagemissing` | | + * | `dataabort` | | + * | `sourcedataabort` | | + * + * @param type - The event type to listen for. Events compatible with the optional `layerId` parameter are triggered + * when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas. + * @param layer - The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location + * is within a visible feature in this layer. The event will have a `features` property containing + * an array of the matching features. If `layer` is not supplied, the event will not have a `features` property. + * Please note that many event types are not compatible with the optional `layer` parameter. + * @param listener - The function to be called when the event is fired. + * @returns `this` + * @example + * ```ts + * // Set an event listener that will fire + * // when the map has finished loading + * map.on('load', function() { + * // Once the map has finished loading, + * // add a new layer + * map.addLayer({ + * id: 'points-of-interest', + * source: { + * type: 'vector', + * url: 'https://maplibre.org/maplibre-style-spec/' + * }, + * 'source-layer': 'poi_label', + * type: 'circle', + * paint: { + * // MapLibre Style Specification paint properties + * }, + * layout: { + * // MapLibre Style Specification layout properties + * } + * }); + * }); + * ``` + * @example + * ```ts + * // Set an event listener that will fire + * // when a feature on the countries layer of the map is clicked + * map.on('click', 'countries', (e) => { + * new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setHTML(`Country name: ${e.features[0].properties.name}`) + * .addTo(map); + * }); + * ``` + * @see [Display popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + on( + type: T, + layer: string, + listener: (ev: MapLayerEventType[T] & Object) => void, + ): Map; + /** + * Overload of the `on` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + on(type: T, listener: (ev: MapEventType[T] & Object) => void): this; + /** + * Overload of the `on` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + on(type: keyof MapEventType | string, listener: Listener): this; + on(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this { + if (listener === undefined) { + return super.on(type, layerIdOrListener as Listener); + } + + const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener); + + this._delegatedListeners = this._delegatedListeners || {}; + this._delegatedListeners[type] = this._delegatedListeners[type] || []; + this._delegatedListeners[type].push(delegatedListener); + + for (const event in delegatedListener.delegates) { + this.on(event, delegatedListener.delegates[event]); + } + + return this; + } + + /** + * Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer. + * + * @event + * @param type - The event type to listen for; one of `'mousedown'`, `'mouseup'`, `'click'`, `'dblclick'`, + * `'mousemove'`, `'mouseenter'`, `'mouseleave'`, `'mouseover'`, `'mouseout'`, `'contextmenu'`, `'touchstart'`, + * `'touchend'`, or `'touchcancel'`. `mouseenter` and `mouseover` events are triggered when the cursor enters + * a visible portion of the specified layer from outside that layer or outside the map canvas. `mouseleave` + * and `mouseout` events are triggered when the cursor leaves a visible portion of the specified layer, or leaves + * the map canvas. + * @param layer - The ID of a style layer or a listener if no ID is provided. Only events whose location is within a visible + * feature in this layer will trigger the listener. The event will have a `features` property containing + * an array of the matching features. + * @param listener - The function to be called when the event is fired. + * @returns `this` if listener is provided, promise otherwise to allow easier usage of async/await + */ + once( + type: T, + layer: string, + listener?: (ev: MapLayerEventType[T] & Object) => void, + ): this | Promise; + /** + * Overload of the `once` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + once(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise; + /** + * Overload of the `once` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The listener callback. + * @returns `this` + */ + once(type: keyof MapEventType | string, listener?: Listener): this | Promise; + once(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this | Promise { + + if (listener === undefined) { + return super.once(type, layerIdOrListener as Listener); + } + + const delegatedListener = this._createDelegatedListener(type, layerIdOrListener as string, listener); + + for (const event in delegatedListener.delegates) { + this.once(event, delegatedListener.delegates[event]); + } + + return this; + } + + /** + * Removes an event listener for events previously added with `Map#on`. + * + * @event + * @param type - The event type previously used to install the listener. + * @param layer - The layer ID or listener previously used to install the listener. + * @param listener - The function previously installed as a listener. + * @returns `this` + */ + off( + type: T, + layer: string, + listener: (ev: MapLayerEventType[T] & Object) => void, + ): this; + /** + * Overload of the `off` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The function previously installed as a listener. + * @returns `this` + */ + off(type: T, listener: (ev: MapEventType[T] & Object) => void): this; + /** + * Overload of the `off` method that allows to listen to events without specifying a layer. + * @event + * @param type - The type of the event. + * @param listener - The function previously installed as a listener. + * @returns `this` + */ + off(type: keyof MapEventType | string, listener: Listener): this; + off(type: keyof MapEventType | string, layerIdOrListener: string | Listener, listener?: Listener): this { + if (listener === undefined) { + return super.off(type, layerIdOrListener as Listener); + } + + const removeDelegatedListener = (delegatedListeners) => { + const listeners = delegatedListeners[type]; + for (let i = 0; i < listeners.length; i++) { + const delegatedListener = listeners[i]; + if (delegatedListener.layer === layerIdOrListener && delegatedListener.listener === listener) { + for (const event in delegatedListener.delegates) { + this.off(((event as any)), delegatedListener.delegates[event]); + } + listeners.splice(i, 1); + return this; + } + } + }; + + if (this._delegatedListeners && this._delegatedListeners[type]) { + removeDelegatedListener(this._delegatedListeners); + } + + return this; + } + + /** + * Returns an array of MapGeoJSONFeature objects + * representing visible features that satisfy the query parameters. + * + * @param geometryOrOptions - (optional) The geometry of the query region: + * either a single point or southwest and northeast points describing a bounding box. + * Omitting this parameter (i.e. calling {@link Map#queryRenderedFeatures} with zero arguments, + * or with only a `options` argument) is equivalent to passing a bounding box encompassing the entire + * map viewport. + * The geometryOrOptions can receive a {@link QueryRenderedFeaturesOptions} only to support a situation where the function receives only one parameter which is the options parameter. + * @param options - (optional) Options object. + * + * @returns An array of MapGeoJSONFeature objects. + * + * The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only + * string and numeric property values are supported (i.e. `null`, `Array`, and `Object` values are not supported). + * + * Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object + * representing the style layer to which the feature belongs. Layout and paint properties in this object contain values + * which are fully evaluated for the given zoom level and feature. + * + * Only features that are currently rendered are included. Some features will **not** be included, like: + * + * - Features from layers whose `visibility` property is `"none"`. + * - Features from layers whose zoom range excludes the current zoom level. + * - Symbol features that have been hidden due to text or icon collision. + * + * Features from all other layers are included, including features that may have no visible + * contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to + * 0. + * + * The topmost rendered feature appears first in the returned array, and subsequent features are sorted by + * descending z-order. Features that are rendered multiple times (due to wrapping across the antemeridian at low + * zoom levels) are returned only once (though subject to the following caveat). + * + * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature + * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple + * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. + * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding + * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile + * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple + * tiles due to tile buffering. + * + * @example + * Find all features at a point + * ```ts + * let features = map.queryRenderedFeatures( + * [20, 35], + * { layers: ['my-layer-name'] } + * ); + * ``` + * + * @example + * Find all features within a static bounding box + * ```ts + * let features = map.queryRenderedFeatures( + * [[10, 20], [30, 50]], + * { layers: ['my-layer-name'] } + * ); + * ``` + * + * @example + * Find all features within a bounding box around a point + * ```ts + * let width = 10; + * let height = 20; + * let features = map.queryRenderedFeatures([ + * [point.x - width / 2, point.y - height / 2], + * [point.x + width / 2, point.y + height / 2] + * ], { layers: ['my-layer-name'] }); + * ``` + * + * @example + * Query all rendered features from a single layer + * ```ts + * let features = map.queryRenderedFeatures({ layers: ['my-layer-name'] }); + * ``` + * @see [Get features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/queryrenderedfeatures/) + */ + queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[] { + if (!this.style) { + return []; + } + let queryGeometry; + const isGeometry = geometryOrOptions instanceof Point || Array.isArray(geometryOrOptions); + const geometry = isGeometry ? geometryOrOptions : [[0, 0], [this.transform.width, this.transform.height]]; + options = options || (isGeometry ? {} : geometryOrOptions) || {}; + + if (geometry instanceof Point || typeof geometry[0] === 'number') { + queryGeometry = [Point.convert(geometry as PointLike)]; + } else { + const tl = Point.convert(geometry[0] as PointLike); + const br = Point.convert(geometry[1] as PointLike); + queryGeometry = [tl, new Point(br.x, tl.y), br, new Point(tl.x, br.y), tl]; + } + + return this.style.queryRenderedFeatures(queryGeometry, options, this.transform); + } + + /** + * Returns an array of MapGeoJSONFeature objects + * representing features within the specified vector tile or GeoJSON source that satisfy the query parameters. + * + * @param sourceId - The ID of the vector tile or GeoJSON source to query. + * @param parameters - The options object. + * @returns An array of MapGeoJSONFeature objects. + * + * In contrast to {@link Map#queryRenderedFeatures}, this function returns all features matching the query parameters, + * whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded + * vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently + * visible viewport. + * + * Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature + * geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple + * times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. + * The results of the query will be those parts of the highway that lie within the map tiles covering the bounding + * rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile + * will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple + * tiles due to tile buffering. + * + * @example + * Find all features in one source layer in a vector source + * ```ts + * let features = map.querySourceFeatures('your-source-id', { + * sourceLayer: 'your-source-layer' + * }); + * ``` + * + */ + querySourceFeatures(sourceId: string, parameters?: QuerySourceFeatureOptions | null): MapGeoJSONFeature[] { + return this.style.querySourceFeatures(sourceId, parameters); + } + + /** + * Updates the map's MapLibre style object with a new value. + * + * If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style + * against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites + * (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current + * style and the given style are different in any way, the map renderer will force a full update, removing the current style and building + * the given one from scratch. + * + * + * @param style - A JSON object conforming to the schema described in the + * [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/), or a URL to such JSON. + * @param options - The options object. + * @returns `this` + * + * @example + * ```ts + * map.setStyle("https://demotiles.maplibre.org/style.json"); + * + * map.setStyle('https://demotiles.maplibre.org/style.json', { + * transformStyle: (previousStyle, nextStyle) => ({ + * ...nextStyle, + * sources: { + * ...nextStyle.sources, + * // copy a source from previous style + * 'osm': previousStyle.sources.osm + * }, + * layers: [ + * // background layer + * nextStyle.layers[0], + * // copy a layer from previous style + * previousStyle.layers[0], + * // other layers from the next style + * ...nextStyle.layers.slice(1).map(layer => { + * // hide the layers we don't need from demotiles style + * if (layer.id.startsWith('geolines')) { + * layer.layout = {...layer.layout || {}, visibility: 'none'}; + * // filter out US polygons + * } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) { + * layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA']; + * } + * return layer; + * }) + * ] + * }) + * }); + * ``` + */ + setStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions): this { + options = extend({}, + { + localIdeographFontFamily: this._localIdeographFontFamily, + validate: this._validateStyle + }, options); + + if ((options.diff !== false && options.localIdeographFontFamily === this._localIdeographFontFamily) && this.style && style) { + this._diffStyle(style, options); + return this; + } else { + this._localIdeographFontFamily = options.localIdeographFontFamily; + return this._updateStyle(style, options); + } + } + + /** + * Updates the requestManager's transform request with a new function + * + * @param transformRequest - A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. + * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties + * + * @returns `this` + * + * @example + * ```ts + * map.setTransformRequest((url: string, resourceType: string) => {}); + * ``` + */ + setTransformRequest(transformRequest: RequestTransformFunction): this { + this._requestManager.setTransformRequest(transformRequest); + return this; + } + + _getUIString(key: string) { + const str = this._locale[key]; + if (str == null) { + throw new Error(`Missing UI string '${key}'`); + } + + return str; + } + + _updateStyle(style: StyleSpecification | string | null, options?: StyleSwapOptions & StyleOptions) { + // transformStyle relies on having previous style serialized, if it is not loaded yet, delay _updateStyle until previous style is loaded + if (options.transformStyle && this.style && !this.style._loaded) { + this.style.once('style.load', () => this._updateStyle(style, options)); + return; + } + + const previousStyle = this.style && options.transformStyle ? this.style.serialize() : undefined; + if (this.style) { + this.style.setEventedParent(null); + + // Only release workers when map is getting disposed + this.style._remove(!style); + } + + if (!style) { + delete this.style; + return this; + } else { + this.style = new Style(this, options || {}); + } + + this.style.setEventedParent(this, {style: this.style}); + + if (typeof style === 'string') { + this.style.loadURL(style, options, previousStyle); + } else { + this.style.loadJSON(style, options, previousStyle); + } + + return this; + } + + _lazyInitEmptyStyle() { + if (!this.style) { + this.style = new Style(this, {}); + this.style.setEventedParent(this, {style: this.style}); + this.style.loadEmpty(); + } + } + + _diffStyle(style: StyleSpecification | string, options?: StyleSwapOptions & StyleOptions) { + if (typeof style === 'string') { + const url = style; + const request = this._requestManager.transformRequest(url, ResourceType.Style); + getJSON(request, (error?: Error | null, json?: any | null) => { + if (error) { + this.fire(new ErrorEvent(error)); + } else if (json) { + this._updateDiff(json, options); + } + }); + } else if (typeof style === 'object') { + this._updateDiff(style, options); + } + } + + _updateDiff(style: StyleSpecification, options?: StyleSwapOptions & StyleOptions) { + try { + if (this.style.setState(style, options)) { + this._update(true); + } + } catch (e) { + warnOnce( + `Unable to perform style diff: ${e.message || e.error || e}. Rebuilding the style from scratch.` + ); + this._updateStyle(style, options); + } + } + + /** + * Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style. + * + * @returns The map's style JSON object. + * + * @example + * ```ts + * let styleJson = map.getStyle(); + * ``` + * + */ + getStyle(): StyleSpecification { + if (this.style) { + return this.style.serialize(); + } + } + + /** + * Returns a Boolean indicating whether the map's style is fully loaded. + * + * @returns A Boolean indicating whether the style is fully loaded. + * + * @example + * ```ts + * let styleLoadStatus = map.isStyleLoaded(); + * ``` + */ + isStyleLoaded(): boolean | void { + if (!this.style) return warnOnce('There is no style added to the map.'); + return this.style.loaded(); + } + + /** + * Adds a source to the map's style. + * + * Events triggered: + * + * Triggers the `source.add` event. + * + * @param id - The ID of the source to add. Must not conflict with existing sources. + * @param source - The source object, conforming to the + * MapLibre Style Specification's [source definition](https://maplibre.org/maplibre-style-spec/sources) or + * {@link CanvasSourceSpecification}. + * @returns `this` + * @example + * ```ts + * map.addSource('my-data', { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }); + * ``` + * @example + * ```ts + * map.addSource('my-data', { + * "type": "geojson", + * "data": { + * "type": "Feature", + * "geometry": { + * "type": "Point", + * "coordinates": [-77.0323, 38.9131] + * }, + * "properties": { + * "title": "Mapbox DC", + * "marker-symbol": "monument" + * } + * } + * }); + * ``` + * @see GeoJSON source: [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + */ + addSource(id: string, source: SourceSpecification): this { + this._lazyInitEmptyStyle(); + this.style.addSource(id, source); + return this._update(true); + } + + /** + * Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with + * the given ID in the map's style has no outstanding network requests, otherwise `false`. + * + * A {@link ErrorEvent} event will be fired if there is no source wit the specified ID. + * + * @param id - The ID of the source to be checked. + * @returns A Boolean indicating whether the source is loaded. + * @example + * ```ts + * let sourceLoaded = map.isSourceLoaded('bathymetry-data'); + * ``` + */ + isSourceLoaded(id: string): boolean { + const source = this.style && this.style.sourceCaches[id]; + if (source === undefined) { + this.fire(new ErrorEvent(new Error(`There is no source with ID '${id}'`))); + return; + } + return source.loaded(); + } + + /** + * Loads a 3D terrain mesh, based on a "raster-dem" source. + * + * Triggers the `terrain` event. + * + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setTerrain({ source: 'terrain' }); + * ``` + */ + setTerrain(options: TerrainSpecification | null): this { + this.style._checkLoaded(); + + // clear event handlers + if (this._terrainDataCallback) this.style.off('data', this._terrainDataCallback); + + if (!options) { + // remove terrain + if (this.terrain) this.terrain.sourceCache.destruct(); + this.terrain = null; + if (this.painter.renderToTexture) this.painter.renderToTexture.destruct(); + this.painter.renderToTexture = null; + this.transform._minEleveationForCurrentTile = 0; + this.transform.elevation = 0; + } else { + // add terrain + const sourceCache = this.style.sourceCaches[options.source]; + if (!sourceCache) throw new Error(`cannot load terrain, because there exists no source with ID: ${options.source}`); + // Warn once if user is using the same source for hillshade and terrain + for (const index in this.style._layers) { + const thisLayer = this.style._layers[index]; + if (thisLayer.type === 'hillshade' && thisLayer.source === options.source) { + warnOnce('You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.'); + } + } + this.terrain = new Terrain(this.painter, sourceCache, options); + this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain); + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + this._terrainDataCallback = e => { + if (e.dataType === 'style') { + this.terrain.sourceCache.freeRtt(); + } else if (e.dataType === 'source' && e.tile) { + if (e.sourceId === options.source && !this._elevationFreeze) { + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + } + this.terrain.sourceCache.freeRtt(e.tile.tileID); + } + }; + this.style.on('data', this._terrainDataCallback); + } + + this.fire(new Event('terrain', {terrain: options})); + return this; + } + + /** + * Get the terrain-options if terrain is loaded + * @returns the TerrainSpecification passed to setTerrain + * @example + * ```ts + * map.getTerrain(); // { source: 'terrain' }; + * ``` + */ + getTerrain(): TerrainSpecification | null { + return this.terrain?.options ?? null; + } + + /** + * Returns a Boolean indicating whether all tiles in the viewport from all sources on + * the style are loaded. + * + * @returns A Boolean indicating whether all tiles are loaded. + * @example + * ```ts + * let tilesLoaded = map.areTilesLoaded(); + * ``` + */ + areTilesLoaded(): boolean { + const sources = this.style && this.style.sourceCaches; + for (const id in sources) { + const source = sources[id]; + const tiles = source._tiles; + for (const t in tiles) { + const tile = tiles[t]; + if (!(tile.state === 'loaded' || tile.state === 'errored')) return false; + } + } + return true; + } + + /** + * Adds a [custom source type](#Custom Sources), making it available for use with + * {@link Map#addSource}. + * @param name - The name of the source type; source definition objects use this name in the `{type: ...}` field. + * @param SourceType - A {@link Source} constructor. + * @param callback - Called when the source type is ready or with an error argument if there is an error. + */ + addSourceType(name: string, SourceType: SourceClass, callback: Callback) { + this._lazyInitEmptyStyle(); + return this.style.addSourceType(name, SourceType, callback); + } + + /** + * Removes a source from the map's style. + * + * @param id - The ID of the source to remove. + * @returns `this` + * @example + * ```ts + * map.removeSource('bathymetry-data'); + * ``` + */ + removeSource(id: string): Map { + this.style.removeSource(id); + return this._update(true); + } + + /** + * Returns the source with the specified ID in the map's style. + * + * This method is often used to update a source using the instance members for the relevant + * source type as defined in [Sources](#sources). + * For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates` + * of an image source. + * + * @param id - The ID of the source to get. + * @returns The style source with the specified ID or `undefined` if the ID + * corresponds to no existing sources. + * The shape of the object varies by source type. + * A list of options for each source type is available on the MapLibre Style Specification's + * [Sources](https://maplibre.org/maplibre-style-spec/sources/) page. + * @example + * ```ts + * let sourceObject = map.getSource('points'); + * ``` + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/) + * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) + */ + getSource(id: string): Source | undefined { + return this.style.getSource(id); + } + + /** + * Add an image to the style. This image can be displayed on the map like any other icon in the style's + * sprite using the image's ID with + * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image), + * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern), + * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern), + * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern). + * + * A {@link ErrorEvent} event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image. + * + * @param id - The ID of the image. + * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data` + * properties with the same format as `ImageData`. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * // If the style's sprite does not already contain an image with ID 'cat', + * // add the image 'cat-icon.png' to the style's sprite with the ID 'cat'. + * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) { + * if (error) throw error; + * if (!map.hasImage('cat')) map.addImage('cat', image); + * }); + * + * // Add a stretchable image that can be used with `icon-text-fit` + * // In this example, the image is 600px wide by 400px high. + * map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png', function(error, image) { + * if (error) throw error; + * if (!map.hasImage('border-image')) { + * map.addImage('border-image', image, { + * content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border + * stretchX: [[16, 584]], // stretch everything horizontally except the 16px border + * stretchY: [[16, 384]], // stretch everything vertically except the 16px border + * }); + * } + * }); + * ``` + * @see Use `HTMLImageElement`: [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/) + * @see Use `ImageData`: [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-generated/) + */ + addImage(id: string, + image: HTMLImageElement | ImageBitmap | ImageData | { + width: number; + height: number; + data: Uint8Array | Uint8ClampedArray; + } | StyleImageInterface, + options: Partial = {}): this { + const { + pixelRatio = 1, + sdf = false, + stretchX, + stretchY, + content + } = options; + this._lazyInitEmptyStyle(); + const version = 0; + + if (image instanceof HTMLImageElement || isImageBitmap(image)) { + const {width, height, data} = browser.getImageData(image); + this.style.addImage(id, {data: new RGBAImage({width, height}, data), pixelRatio, stretchX, stretchY, content, sdf, version}); + } else if (image.width === undefined || image.height === undefined) { + return this.fire(new ErrorEvent(new Error( + 'Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' + + 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`'))); + } else { + const {width, height, data} = image as ImageData; + const userImage = (image as any as StyleImageInterface); + + this.style.addImage(id, { + data: new RGBAImage({width, height}, new Uint8Array(data)), + pixelRatio, + stretchX, + stretchY, + content, + sdf, + version, + userImage + }); + + if (userImage.onAdd) { + userImage.onAdd(this, id); + } + return this; + } + } + + /** + * Update an existing image in a style. This image can be displayed on the map like any other icon in the style's + * sprite using the image's ID with + * [`icon-image`](https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-icon-image), + * [`background-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-background-background-pattern), + * [`fill-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-fill-fill-pattern), + * or [`line-pattern`](https://maplibre.org/maplibre-style-spec/layers/#paint-line-line-pattern). + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the image. + * @param image - The image as an `HTMLImageElement`, `ImageData`, `ImageBitmap` or object with `width`, `height`, and `data` + * properties with the same format as `ImageData`. + * @returns `this` + * @example + * ```ts + * // If an image with the ID 'cat' already exists in the style's sprite, + * // replace that image with a new image, 'other-cat-icon.png'. + * if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png'); + * ``` + */ + updateImage(id: string, + image: HTMLImageElement | ImageBitmap | ImageData | { + width: number; + height: number; + data: Uint8Array | Uint8ClampedArray; + } | StyleImageInterface): this { + + const existingImage = this.style.getImage(id); + if (!existingImage) { + return this.fire(new ErrorEvent(new Error( + 'The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.'))); + } + const imageData = (image instanceof HTMLImageElement || isImageBitmap(image)) ? + browser.getImageData(image) : + image; + const {width, height, data} = imageData; + + if (width === undefined || height === undefined) { + return this.fire(new ErrorEvent(new Error( + 'Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, ' + + 'or object with `width`, `height`, and `data` properties with the same format as `ImageData`'))); + } + + if (width !== existingImage.data.width || height !== existingImage.data.height) { + return this.fire(new ErrorEvent(new Error( + 'The width and height of the updated image must be that same as the previous version of the image'))); + } + + const copy = !(image instanceof HTMLImageElement || isImageBitmap(image)); + existingImage.data.replace(data, copy); + + this.style.updateImage(id, existingImage); + return this; + } + + /** + * Returns an image, specified by ID, currently available in the map. + * This includes both images from the style's original sprite + * and any images that have been added at runtime using {@link Map#addImage}. + * + * @param id - The ID of the image. + * @returns An image in the map with the specified ID. + * + * @example + * ```ts + * let coffeeShopIcon = map.getImage("coffee_cup"); + * ``` + */ + getImage(id: string): StyleImage { + return this.style.getImage(id); + } + + /** + * Check whether or not an image with a specific ID exists in the style. This checks both images + * in the style's original sprite and any images + * that have been added at runtime using {@link Map#addImage}. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the image. + * + * @returns A Boolean indicating whether the image exists. + * @example + * Check if an image with the ID 'cat' exists in the style's sprite. + * ```ts + * let catIconExists = map.hasImage('cat'); + * ``` + */ + hasImage(id: string): boolean { + if (!id) { + this.fire(new ErrorEvent(new Error('Missing required image id'))); + return false; + } + + return !!this.style.getImage(id); + } + + /** + * Remove an image from a style. This can be an image from the style's original + * sprite or any images + * that have been added at runtime using {@link Map#addImage}. + * + * @param id - The ID of the image. + * + * @example + * ```ts + * // If an image with the ID 'cat' exists in + * // the style's sprite, remove it. + * if (map.hasImage('cat')) map.removeImage('cat'); + * ``` + */ + removeImage(id: string) { + this.style.removeImage(id); + } + + /** + * Load an image from an external URL to be used with {@link Map#addImage}. External + * domains must support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS). + * + * @param url - The URL of the image file. Image file must be in png, webp, or jpg format. + * @param callback - Expecting `callback(error, data)`. Called when the image has loaded or with an error argument if there is an error. + * + * @example + * Load an image from an external URL. + * ```ts + * map.loadImage('http://placekitten.com/50/50', function(error, image) { + * if (error) throw error; + * // Add the loaded image to the style's sprite with the ID 'kitten'. + * map.addImage('kitten', image); + * }); + * ``` + * @see [Add an icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image/) + */ + loadImage(url: string, callback: GetImageCallback) { + ImageRequest.getImage(this._requestManager.transformRequest(url, ResourceType.Image), callback); + } + + /** + * Returns an Array of strings containing the IDs of all images currently available in the map. + * This includes both images from the style's original sprite + * and any images that have been added at runtime using {@link Map#addImage}. + * + * @returns An Array of strings containing the names of all sprites/images currently available in the map. + * + * @example + * ```ts + * let allImages = map.listImages(); + * ``` + */ + listImages(): Array { + return this.style.listImages(); + } + + /** + * Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers) + * to the map's style. + * + * A layer defines how data from a specified source will be styled. Read more about layer types + * and available paint and layout properties in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/layers). + * + * @param layer - The layer to add, + * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or, + * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition. + * The MapLibre Style Specification's layer definition is appropriate for most layers. + * + * @param beforeId - The ID of an existing layer to insert the new layer before, + * resulting in the new layer appearing visually beneath the existing layer. + * If this argument is not specified, the layer will be appended to the end of the layers array + * and appear visually above all other layers. + * + * @returns `this` + * + * @example + * Add a circle layer with a vector source + * ```ts + * map.addLayer({ + * id: 'points-of-interest', + * source: { + * type: 'vector', + * url: 'https://demotiles.maplibre.org/tiles/tiles.json' + * }, + * 'source-layer': 'poi_label', + * type: 'circle', + * paint: { + * // MapLibre Style Specification paint properties + * }, + * layout: { + * // MapLibre Style Specification layout properties + * } + * }); + * ``` + * + * @example + * Define a source before using it to create a new layer + * ```ts + * map.addSource('state-data', { + * type: 'geojson', + * data: 'path/to/data.geojson' + * }); + * + * map.addLayer({ + * id: 'states', + * // References the GeoJSON source defined above + * // and does not require a `source-layer` + * source: 'state-data', + * type: 'symbol', + * layout: { + * // Set the label content to the + * // feature's `name` property + * text-field: ['get', 'name'] + * } + * }); + * ``` + * + * @example + * Add a new symbol layer before an existing layer + * ```ts + * map.addLayer({ + * id: 'states', + * // References a source that's already been defined + * source: 'state-data', + * type: 'symbol', + * layout: { + * // Set the label content to the + * // feature's `name` property + * text-field: ['get', 'name'] + * } + * // Add the layer before the existing `cities` layer + * }, 'cities'); + * ``` + * @see [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/) + * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/) + * @see [Add a WMS source](https://maplibre.org/maplibre-gl-js/docs/examples/wms/) + */ + addLayer(layer: AddLayerObject, beforeId?: string) { + this._lazyInitEmptyStyle(); + this.style.addLayer(layer, beforeId); + return this._update(true); + } + + /** + * Moves a layer to a different z-position. + * + * @param id - The ID of the layer to move. + * @param beforeId - The ID of an existing layer to insert the new layer before. When viewing the map, the `id` layer will appear beneath the `beforeId` layer. If `beforeId` is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map. + * @returns `this` + * + * @example + * Move a layer with ID 'polygon' before the layer with ID 'country-label'. The `polygon` layer will appear beneath the `country-label` layer on the map. + * ```ts + * map.moveLayer('polygon', 'country-label'); + * ``` + */ + moveLayer(id: string, beforeId?: string): this { + this.style.moveLayer(id, beforeId); + return this._update(true); + } + + /** + * Removes the layer with the given ID from the map's style. + * + * An {@link ErrorEvent} will be fired if the image parameter is invald. + * + * @param id - The ID of the layer to remove + * @returns `this` + * + * @example + * If a layer with ID 'state-data' exists, remove it. + * ```ts + * if (map.getLayer('state-data')) map.removeLayer('state-data'); + * ``` + */ + removeLayer(id: string): this { + this.style.removeLayer(id); + return this._update(true); + } + + /** + * Returns the layer with the specified ID in the map's style. + * + * @param id - The ID of the layer to get. + * @returns The layer with the specified ID, or `undefined` + * if the ID corresponds to no existing layers. + * + * @example + * ```ts + * let stateDataLayer = map.getLayer('state-data'); + * ``` + * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/) + * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/) + */ + getLayer(id: string): StyleLayer | undefined { + return this.style.getLayer(id); + } + + /** + * Return the ids of all layers currently in the style, including custom layers, in order. + * + * @returns ids of layers, in order + * + * @example + * ```ts + * const orderedLayerIds = map.getLayersOrder(); + * ``` + */ + getLayersOrder(): string[] { + return this.style.getLayersOrder(); + } + + /** + * Sets the zoom extent for the specified style layer. The zoom extent includes the + * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom) + * and [maximum zoom level](https://maplibre.org/maplibre-style-spec/layers/#maxzoom)) + * at which the layer will be rendered. + * + * Note: For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the + * minimum zoom level of the _source layer_ because the data does not exist at those zoom levels. If the minimum + * zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style + * layer will not be rendered at all zoom levels in the zoom range. + * + * @param layerId - The ID of the layer to which the zoom extent will be applied. + * @param minzoom - The minimum zoom to set (0-24). + * @param maxzoom - The maximum zoom to set (0-24). + * @returns `this` + * + * @example + * ```ts + * map.setLayerZoomRange('my-layer', 2, 5); + * ``` + */ + setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this { + this.style.setLayerZoomRange(layerId, minzoom, maxzoom); + return this._update(true); + } + + /** + * Sets the filter for the specified style layer. + * + * Filters control which features a style layer renders from its source. + * Any feature for which the filter expression evaluates to `true` will be + * rendered on the map. Those that are false will be hidden. + * + * Use `setFilter` to show a subset of your source data. + * + * To clear the filter, pass `null` or `undefined` as the second parameter. + * + * @param layerId - The ID of the layer to which the filter will be applied. + * @param filter - The filter, conforming to the MapLibre Style Specification's + * [filter definition](https://maplibre.org/maplibre-style-spec/layers/#filter). If `null` or `undefined` is provided, the function removes any existing filter from the layer. + * @param options - Options object. + * @returns `this` + * + * @example + * Display only features with the 'name' property 'USA' + * ```ts + * map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']); + * ``` + * @example + * Display only features with five or more 'available-spots' + * ```ts + * map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]); + * ``` + * @example + * Remove the filter for the 'bike-docks' style layer + * ```ts + * map.setFilter('bike-docks', null); + * ``` + * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/) + */ + setFilter(layerId: string, filter?: FilterSpecification | null, options: StyleSetterOptions = {}) { + this.style.setFilter(layerId, filter, options); + return this._update(true); + } + + /** + * Returns the filter applied to the specified style layer. + * + * @param layerId - The ID of the style layer whose filter to get. + * @returns The layer's filter. + */ + getFilter(layerId: string): FilterSpecification | void { + return this.style.getFilter(layerId); + } + + /** + * Sets the value of a paint property in the specified style layer. + * + * @param layerId - The ID of the layer to set the paint property in. + * @param name - The name of the paint property to set. + * @param value - The value of the paint property to set. + * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/). + * Pass `null` to unset the existing value. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setPaintProperty('my-layer', 'fill-color', '#faafee'); + * ``` + * @see [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/) + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + setPaintProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this { + this.style.setPaintProperty(layerId, name, value, options); + return this._update(true); + } + + /** + * Returns the value of a paint property in the specified style layer. + * + * @param layerId - The ID of the layer to get the paint property from. + * @param name - The name of a paint property to get. + * @returns The value of the specified paint property. + */ + getPaintProperty(layerId: string, name: string) { + return this.style.getPaintProperty(layerId, name); + } + + /** + * Sets the value of a layout property in the specified style layer. + * + * @param layerId - The ID of the layer to set the layout property in. + * @param name - The name of the layout property to set. + * @param value - The value of the layout property. Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/). + * @param options - The options object. + * @returns `this` + * @example + * ```ts + * map.setLayoutProperty('my-layer', 'visibility', 'none'); + * ``` + */ + setLayoutProperty(layerId: string, name: string, value: any, options: StyleSetterOptions = {}): this { + this.style.setLayoutProperty(layerId, name, value, options); + return this._update(true); + } + + /** + * Returns the value of a layout property in the specified style layer. + * + * @param layerId - The ID of the layer to get the layout property from. + * @param name - The name of the layout property to get. + * @returns The value of the specified layout property. + */ + getLayoutProperty(layerId: string, name: string) { + return this.style.getLayoutProperty(layerId, name); + } + + /** + * Sets the value of the style's glyphs property. + * + * @param glyphsUrl - Glyph URL to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/glyphs/). + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setGlyphs('https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf'); + * ``` + */ + setGlyphs(glyphsUrl: string | null, options: StyleSetterOptions = {}): this { + this._lazyInitEmptyStyle(); + this.style.setGlyphs(glyphsUrl, options); + return this._update(true); + } + + /** + * Returns the value of the style's glyphs URL + * + * @returns glyphs Style's glyphs url + */ + getGlyphs(): string | null { + return this.style.getGlyphsUrl(); + } + + /** + * Adds a sprite to the map's style. Fires the `style` event. + * + * @param id - The ID of the sprite to add. Must not conflict with existing sprites. + * @param url - The URL to load the sprite from + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.addSprite('sprite-two', 'http://example.com/sprite-two'); + * ``` + */ + addSprite(id: string, url: string, options: StyleSetterOptions = {}): this { + this._lazyInitEmptyStyle(); + this.style.addSprite(id, url, options, (err) => { + if (!err) { + this._update(true); + } + }); + return this; + } + + /** + * Removes the sprite from the map's style. Fires the `style` event. + * + * @param id - The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be "default". + * @returns `this` + * @example + * ```ts + * map.removeSprite('sprite-two'); + * map.removeSprite('default'); + * ``` + */ + removeSprite(id: string) { + this._lazyInitEmptyStyle(); + this.style.removeSprite(id); + return this._update(true); + } + + /** + * Returns the as-is value of the style's sprite. + * + * @returns style's sprite list of id-url pairs + */ + getSprite(): {id: string; url: string}[] { + return this.style.getSprite(); + } + + /** + * Sets the value of the style's sprite property. + * + * @param spriteUrl - Sprite URL to set. + * @param options - Options object. + * @returns `this` + * @example + * ```ts + * map.setSprite('YOUR_SPRITE_URL'); + * ``` + */ + setSprite(spriteUrl: string | null, options: StyleSetterOptions = {}) { + this._lazyInitEmptyStyle(); + this.style.setSprite(spriteUrl, options, (err) => { + if (!err) { + this._update(true); + } + }); + return this; + } + + /** + * Sets the any combination of light values. + * + * @param light - Light properties to set. Must conform to the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/light). + * @param options - Options object. + * @returns `this` + * + * @example + * ```ts + * let layerVisibility = map.getLayoutProperty('my-layer', 'visibility'); + * ``` + */ + setLight(light: LightSpecification, options: StyleSetterOptions = {}) { + this._lazyInitEmptyStyle(); + this.style.setLight(light, options); + return this._update(true); + } + + /** + * Returns the value of the light object. + * + * @returns light Light properties of the style. + */ + getLight(): LightSpecification { + return this.style.getLight(); + } + + /** + * Sets the `state` of a feature. + * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime. + * When using this method, the `state` object is merged with any existing key-value pairs in the feature's state. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * This method can only be used with sources that have a `feature.id` attribute. The `feature.id` attribute can be defined in three ways: + * - For vector or GeoJSON sources, including an `id` attribute in the original data file. + * - For vector or GeoJSON sources, using the [`promoteId`](https://maplibre.org/maplibre-style-spec/sources/#vector-promoteId) option at the time the source is defined. + * - For GeoJSON sources, using the [`generateId`](https://maplibre.org/maplibre-style-spec/sources/#geojson-generateId) option to auto-assign an `id` based on the feature's index in the source data. If you change feature data using `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values. + * + * _Note: You can use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) to access the values in a feature's state object for the purposes of styling._ + * + * @param feature - Feature identifier. Feature objects returned from + * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @param state - A set of key-value pairs. The values should be valid JSON types. + * @returns `this` + * + * @example + * ```ts + * // When the mouse moves over the `my-layer` layer, update + * // the feature state for the feature under the mouse + * map.on('mousemove', 'my-layer', function(e) { + * if (e.features.length > 0) { + * map.setFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id, + * }, { + * hover: true + * }); + * } + * }); + * ``` + * @see [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/) + */ + setFeatureState(feature: FeatureIdentifier, state: any): this { + this.style.setFeatureState(feature, state); + return this._update(); + } + + /** + * Removes the `state` of a feature, setting it back to the default behavior. + * If only a `target.source` is specified, it will remove the state for all features from that source. + * If `target.id` is also specified, it will remove all keys for that feature's state. + * If `key` is also specified, it removes only that key from that feature's state. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * @param target - Identifier of where to remove state. It can be a source, a feature, or a specific key of feature. + * Feature objects returned from {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @param key - (optional) The key in the feature state to reset. + * @returns `this` + * @example + * Reset the entire state object for all features in the `my-source` source + * ```ts + * map.removeFeatureState({ + * source: 'my-source' + * }); + * ``` + * + * @example + * When the mouse leaves the `my-layer` layer, + * reset the entire state object for the + * feature under the mouse + * ```ts + * map.on('mouseleave', 'my-layer', function(e) { + * map.removeFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }); + * }); + * ``` + * + * @example + * When the mouse leaves the `my-layer` layer, + * reset only the `hover` key-value pair in the + * state for the feature under the mouse + * ```ts + * map.on('mouseleave', 'my-layer', function(e) { + * map.removeFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }, 'hover'); + * }); + * ``` + */ + removeFeatureState(target: FeatureIdentifier, key?: string): this { + this.style.removeFeatureState(target, key); + return this._update(); + } + + /** + * Gets the `state` of a feature. + * A feature's `state` is a set of user-defined key-value pairs that are assigned to a feature at runtime. + * Features are identified by their `feature.id` attribute, which can be any number or string. + * + * _Note: To access the values in a feature's state object for the purposes of styling the feature, use the [`feature-state` expression](https://maplibre.org/maplibre-style-spec/expressions/#feature-state)._ + * + * @param feature - Feature identifier. Feature objects returned from + * {@link Map#queryRenderedFeatures} or event handlers can be used as feature identifiers. + * @returns The state of the feature: a set of key-value pairs that was assigned to the feature at runtime. + * + * @example + * When the mouse moves over the `my-layer` layer, + * get the feature state for the feature under the mouse + * ```ts + * map.on('mousemove', 'my-layer', function(e) { + * if (e.features.length > 0) { + * map.getFeatureState({ + * source: 'my-source', + * sourceLayer: 'my-source-layer', + * id: e.features[0].id + * }); + * } + * }); + * ``` + */ + getFeatureState(feature: FeatureIdentifier): any { + return this.style.getFeatureState(feature); + } + + /** + * Returns the map's containing HTML element. + * + * @returns The map's container. + */ + getContainer(): HTMLElement { + return this._container; + } + + /** + * Returns the HTML element containing the map's `` element. + * + * If you want to add non-GL overlays to the map, you should append them to this element. + * + * This is the element to which event bindings for map interactivity (such as panning and zooming) are + * attached. It will receive bubbled events from child elements such as the ``, but not from + * map controls. + * + * @returns The container of the map's ``. + * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/) + */ + getCanvasContainer(): HTMLElement { + return this._canvasContainer; + } + + /** + * Returns the map's `` element. + * + * @returns The map's `` element. + * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/) + */ + getCanvas(): HTMLCanvasElement { + return this._canvas; + } + + _containerDimensions() { + let width = 0; + let height = 0; + + if (this._container) { + width = this._container.clientWidth || 400; + height = this._container.clientHeight || 300; + } + + return [width, height]; + } + + _setupContainer() { + const container = this._container; + container.classList.add('maplibregl-map'); + + const canvasContainer = this._canvasContainer = DOM.create('div', 'maplibregl-canvas-container', container); + if (this._interactive) { + canvasContainer.classList.add('maplibregl-interactive'); + } + + this._canvas = DOM.create('canvas', 'maplibregl-canvas', canvasContainer); + this._canvas.addEventListener('webglcontextlost', this._contextLost, false); + this._canvas.addEventListener('webglcontextrestored', this._contextRestored, false); + this._canvas.setAttribute('tabindex', '0'); + this._canvas.setAttribute('aria-label', 'Map'); + this._canvas.setAttribute('role', 'region'); + + const dimensions = this._containerDimensions(); + const clampedPixelRatio = this._getClampedPixelRatio(dimensions[0], dimensions[1]); + this._resizeCanvas(dimensions[0], dimensions[1], clampedPixelRatio); + + const controlContainer = this._controlContainer = DOM.create('div', 'maplibregl-control-container', container); + const positions = this._controlPositions = {}; + ['top-left', 'top-right', 'bottom-left', 'bottom-right'].forEach((positionName) => { + positions[positionName] = DOM.create('div', `maplibregl-ctrl-${positionName} `, controlContainer); + }); + + this._container.addEventListener('scroll', this._onMapScroll, false); + } + + _cooperativeGesturesOnWheel = (event: WheelEvent) => { + this._onCooperativeGesture(event, event[this._metaKey], 1); + }; + + _setupCooperativeGestures() { + const container = this._container; + this._cooperativeGesturesScreen = DOM.create('div', 'maplibregl-cooperative-gesture-screen', container); + let desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.windowsHelpText ? this._cooperativeGestures.windowsHelpText : 'Use Ctrl + scroll to zoom the map'; + if (navigator.platform.indexOf('Mac') === 0) { + desktopMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.macHelpText ? this._cooperativeGestures.macHelpText : 'Use ⌘ + scroll to zoom the map'; + } + const mobileMessage = typeof this._cooperativeGestures !== 'boolean' && this._cooperativeGestures.mobileHelpText ? this._cooperativeGestures.mobileHelpText : 'Use two fingers to move the map'; + this._cooperativeGesturesScreen.innerHTML = ` +
${desktopMessage}
+
${mobileMessage}
+ `; + + // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures + this._cooperativeGesturesScreen.setAttribute('aria-hidden', 'true'); + + // Add event to canvas container since gesture container is pointer-events: none + this._canvasContainer.addEventListener('wheel', this._cooperativeGesturesOnWheel, false); + + // Add a cooperative gestures class (enable touch-action: pan-x pan-y;) + this._canvasContainer.classList.add('maplibregl-cooperative-gestures'); + } + + _destroyCooperativeGestures() { + DOM.remove(this._cooperativeGesturesScreen); + this._canvasContainer.removeEventListener('wheel', this._cooperativeGesturesOnWheel, false); + this._canvasContainer.classList.remove('maplibregl-cooperative-gestures'); + } + + _resizeCanvas(width: number, height: number, pixelRatio: number) { + // Request the required canvas size taking the pixelratio into account. + this._canvas.width = Math.floor(pixelRatio * width); + this._canvas.height = Math.floor(pixelRatio * height); + + // Maintain the same canvas size, potentially downscaling it for HiDPI displays + this._canvas.style.width = `${width}px`; + this._canvas.style.height = `${height}px`; + } + + _setupPainter() { + + const attributes = { + alpha: true, + stencil: true, + depth: true, + failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat, + preserveDrawingBuffer: this._preserveDrawingBuffer, + antialias: this._antialias || false + }; + + let webglcontextcreationerrorDetailObject: any = null; + this._canvas.addEventListener('webglcontextcreationerror', (args: WebGLContextEvent) => { + webglcontextcreationerrorDetailObject = {requestedAttributes: attributes}; + if (args) { + webglcontextcreationerrorDetailObject.statusMessage = args.statusMessage; + webglcontextcreationerrorDetailObject.type = args.type; + } + }, {once: true}); + + const gl = + this._canvas.getContext('webgl2', attributes) as WebGL2RenderingContext || + this._canvas.getContext('webgl', attributes) as WebGLRenderingContext; + + if (!gl) { + const msg = 'Failed to initialize WebGL'; + if (webglcontextcreationerrorDetailObject) { + webglcontextcreationerrorDetailObject.message = msg; + throw new Error(JSON.stringify(webglcontextcreationerrorDetailObject)); + } else { + throw new Error(msg); + } + } + + this.painter = new Painter(gl, this.transform); + + webpSupported.testSupport(gl); + } + + _contextLost = (event: any) => { + event.preventDefault(); + if (this._frame) { + this._frame.cancel(); + this._frame = null; + } + this.fire(new Event('webglcontextlost', {originalEvent: event})); + }; + + _contextRestored = (event: any) => { + this._setupPainter(); + this.resize(); + this._update(); + this.fire(new Event('webglcontextrestored', {originalEvent: event})); + }; + + _onMapScroll = (event: any) => { + if (event.target !== this._container) return; + + // Revert any scroll which would move the canvas outside of the view + this._container.scrollTop = 0; + this._container.scrollLeft = 0; + return false; + }; + + _onCooperativeGesture(event: any, metaPress, touches) { + if (!metaPress && touches < 2) { + // Alert user how to scroll/pan + this._cooperativeGesturesScreen.classList.add('maplibregl-show'); + setTimeout(() => { + this._cooperativeGesturesScreen.classList.remove('maplibregl-show'); + }, 100); + } + return false; + } + + /** + * Returns a Boolean indicating whether the map is fully loaded. + * + * Returns `false` if the style is not yet fully loaded, + * or if there has been a change to the sources or style that + * has not yet fully loaded. + * + * @returns A Boolean indicating whether the map is fully loaded. + */ + loaded(): boolean { + return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded(); + } + + /** + * @internal + * Update this map's style and sources, and re-render the map. + * + * @param updateStyle - mark the map's style for reprocessing as + * well as its sources + * @returns `this` + */ + _update(updateStyle?: boolean) { + if (!this.style || !this.style._loaded) return this; + + this._styleDirty = this._styleDirty || updateStyle; + this._sourcesDirty = true; + this.triggerRepaint(); + + return this; + } + + /** + * @internal + * Request that the given callback be executed during the next render + * frame. Schedule a render frame if one is not already scheduled. + * + * @returns An id that can be used to cancel the callback + */ + _requestRenderFrame(callback: () => void): TaskID { + this._update(); + return this._renderTaskQueue.add(callback); + } + + _cancelRenderFrame(id: TaskID) { + this._renderTaskQueue.remove(id); + } + + /** + * @internal + * Call when a (re-)render of the map is required: + * - The style has changed (`setPaintProperty()`, etc.) + * - Source data has changed (e.g. tiles have finished loading) + * - The map has is moving (or just finished moving) + * - A transition is in progress + * + * @param paintStartTimeStamp - The time when the animation frame began executing. + * + * @returns `this` + */ + _render(paintStartTimeStamp: number) { + const fadeDuration = this._idleTriggered ? this._fadeDuration : 0; + + // A custom layer may have used the context asynchronously. Mark the state as dirty. + this.painter.context.setDirty(); + this.painter.setBaseState(); + + this._renderTaskQueue.run(paintStartTimeStamp); + // A task queue callback may have fired a user event which may have removed the map + if (this._removed) return; + + let crossFading = false; + + // If the style has changed, the map is being zoomed, or a transition or fade is in progress: + // - Apply style changes (in a batch) + // - Recalculate paint properties. + if (this.style && this._styleDirty) { + this._styleDirty = false; + + const zoom = this.transform.zoom; + const now = browser.now(); + this.style.zoomHistory.update(zoom, now); + + const parameters = new EvaluationParameters(zoom, { + now, + fadeDuration, + zoomHistory: this.style.zoomHistory, + transition: this.style.getTransition() + }); + + const factor = parameters.crossFadingFactor(); + if (factor !== 1 || factor !== this._crossFadingFactor) { + crossFading = true; + this._crossFadingFactor = factor; + } + + this.style.update(parameters); + } + + // If we are in _render for any reason other than an in-progress paint + // transition, update source caches to check for and load any tiles we + // need for the current transform + if (this.style && this._sourcesDirty) { + this._sourcesDirty = false; + this.style._updateSources(this.transform); + } + + // update terrain stuff + if (this.terrain) { + this.terrain.sourceCache.update(this.transform, this.terrain); + this.transform._minEleveationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + if (!this._elevationFreeze) { + this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom); + } + } else { + this.transform._minEleveationForCurrentTile = 0; + this.transform.elevation = 0; + } + + this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions); + + // Actually draw + this.painter.render(this.style, { + showTileBoundaries: this.showTileBoundaries, + showOverdrawInspector: this._showOverdrawInspector, + rotating: this.isRotating(), + zooming: this.isZooming(), + moving: this.isMoving(), + fadeDuration, + showPadding: this.showPadding, + }); + + this.fire(new Event('render')); + + if (this.loaded() && !this._loaded) { + this._loaded = true; + PerformanceUtils.mark(PerformanceMarkers.load); + this.fire(new Event('load')); + } + + if (this.style && (this.style.hasTransitions() || crossFading)) { + this._styleDirty = true; + } + + if (this.style && !this._placementDirty) { + // Since no fade operations are in progress, we can release + // all tiles held for fading. If we didn't do this, the tiles + // would just sit in the SourceCaches until the next render + this.style._releaseSymbolFadeTiles(); + } + + // Schedule another render frame if it's needed. + // + // Even though `_styleDirty` and `_sourcesDirty` are reset in this + // method, synchronous events fired during Style#update or + // Style#_updateSources could have caused them to be set again. + const somethingDirty = this._sourcesDirty || this._styleDirty || this._placementDirty; + if (somethingDirty || this._repaint) { + this.triggerRepaint(); + } else if (!this.isMoving() && this.loaded()) { + this.fire(new Event('idle')); + } + + if (this._loaded && !this._fullyLoaded && !somethingDirty) { + this._fullyLoaded = true; + PerformanceUtils.mark(PerformanceMarkers.fullLoad); + } + + return this; + } + + /** + * Force a synchronous redraw of the map. + * @returns `this` + * @example + * ```ts + * map.redraw(); + * ``` + */ + redraw(): this { + if (this.style) { + // cancel the scheduled update + if (this._frame) { + this._frame.cancel(); + this._frame = null; + } + this._render(0); + } + return this; + } + + /** + * Clean up and release all internal resources associated with this map. + * + * This includes DOM elements, event bindings, web workers, and WebGL resources. + * + * Use this method when you are done using the map and wish to ensure that it no + * longer consumes browser resources. Afterwards, you must not call any other + * methods on the map. + */ + remove() { + if (this._hash) this._hash.remove(); + + for (const control of this._controls) control.onRemove(this); + this._controls = []; + + if (this._frame) { + this._frame.cancel(); + this._frame = null; + } + this._renderTaskQueue.clear(); + this.painter.destroy(); + this.handlers.destroy(); + delete this.handlers; + this.setStyle(null); + if (typeof window !== 'undefined') { + removeEventListener('online', this._onWindowOnline, false); + } + + ImageRequest.removeThrottleControl(this._imageQueueHandle); + + this._resizeObserver?.disconnect(); + const extension = this.painter.context.gl.getExtension('WEBGL_lose_context'); + if (extension) extension.loseContext(); + this._canvas.removeEventListener('webglcontextrestored', this._contextRestored, false); + this._canvas.removeEventListener('webglcontextlost', this._contextLost, false); + DOM.remove(this._canvasContainer); + DOM.remove(this._controlContainer); + if (this._cooperativeGestures) { + this._destroyCooperativeGestures(); + } + this._container.classList.remove('maplibregl-map'); + + PerformanceUtils.clearMetrics(); + + this._removed = true; + this.fire(new Event('remove')); + } + + /** + * Trigger the rendering of a single frame. Use this method with custom layers to + * repaint the map when the layer changes. Calling this multiple times before the + * next frame is rendered will still result in only a single frame being rendered. + * @example + * ```ts + * map.triggerRepaint(); + * ``` + * @see [Add a 3D model](https://maplibre.org/maplibre-gl-js/docs/examples/add-3d-model/) + * @see [Add an animated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/) + */ + triggerRepaint() { + if (this.style && !this._frame) { + this._frame = browser.frame((paintStartTimeStamp: number) => { + PerformanceUtils.frame(paintStartTimeStamp); + this._frame = null; + this._render(paintStartTimeStamp); + }); + } + } + + _onWindowOnline = () => { + this._update(); + }; + + /** + * Gets and sets a Boolean indicating whether the map will render an outline + * around each tile and the tile ID. These tile boundaries are useful for + * debugging. + * + * The uncompressed file size of the first vector source is drawn in the top left + * corner of each tile, next to the tile ID. + * + * @example + * ```ts + * map.showTileBoundaries = true; + * ``` + */ + get showTileBoundaries(): boolean { return !!this._showTileBoundaries; } + set showTileBoundaries(value: boolean) { + if (this._showTileBoundaries === value) return; + this._showTileBoundaries = value; + this._update(); + } + + /** + * Gets and sets a Boolean indicating whether the map will visualize + * the padding offsets. + */ + get showPadding(): boolean { return !!this._showPadding; } + set showPadding(value: boolean) { + if (this._showPadding === value) return; + this._showPadding = value; + this._update(); + } + + /** + * Gets and sets a Boolean indicating whether the map will render boxes + * around all symbols in the data source, revealing which symbols + * were rendered or which were hidden due to collisions. + * This information is useful for debugging. + */ + get showCollisionBoxes(): boolean { return !!this._showCollisionBoxes; } + set showCollisionBoxes(value: boolean) { + if (this._showCollisionBoxes === value) return; + this._showCollisionBoxes = value; + if (value) { + // When we turn collision boxes on we have to generate them for existing tiles + // When we turn them off, there's no cost to leaving existing boxes in place + this.style._generateCollisionBoxes(); + } else { + // Otherwise, call an update to remove collision boxes + this._update(); + } + } + + /** + * Gets and sets a Boolean indicating whether the map should color-code + * each fragment to show how many times it has been shaded. + * White fragments have been shaded 8 or more times. + * Black fragments have been shaded 0 times. + * This information is useful for debugging. + */ + get showOverdrawInspector(): boolean { return !!this._showOverdrawInspector; } + set showOverdrawInspector(value: boolean) { + if (this._showOverdrawInspector === value) return; + this._showOverdrawInspector = value; + this._update(); + } + + /** + * Gets and sets a Boolean indicating whether the map will + * continuously repaint. This information is useful for analyzing performance. + */ + get repaint(): boolean { return !!this._repaint; } + set repaint(value: boolean) { + if (this._repaint !== value) { + this._repaint = value; + this.triggerRepaint(); + } + } + // show vertices + get vertices(): boolean { return !!this._vertices; } + set vertices(value: boolean) { this._vertices = value; this._update(); } + + /** + * Returns the package version of the library + * @returns Package version of the library + */ + get version(): string { + return version; + } + + /** + * Returns the elevation for the point where the camera is looking. + * This value corresponds to: + * "meters above sea level" * "exaggeration" + * @returns The elevation. + */ + getCameraTargetElevation(): number { + return this.transform.elevation; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/map/isMoving.test.ts b/web/libraries/maplibre-gl/src/ui/map/isMoving.test.ts new file mode 100644 index 00000000..3acc6828 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map/isMoving.test.ts @@ -0,0 +1,164 @@ +import {browser} from '../../util/browser'; +import {Map} from '../map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; + +let map; + +function createMap() { + return new Map({style: '', container: DOM.create('div', '', window.document.body)}); +} + +beforeEach(() => { + beforeMapTest(); + map = createMap(); +}); + +afterEach(() => { + map.remove(); +}); + +describe('Map#isMoving', () => { + // MouseEvent.buttons + const buttons = 1; + + test('returns false by default', () => { + expect(map.isMoving()).toBe(false); + }); + + test('returns true during a camera zoom animation', done => { + map.on('zoomstart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('zoomend', () => { + expect(map.isMoving()).toBe(false); + done(); + }); + + map.zoomTo(5, {duration: 0}); + }); + + test('returns true when drag panning', done => { + map.on('movestart', () => { + expect(map.isMoving()).toBe(true); + }); + map.on('dragstart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('dragend', () => { + expect(map.isMoving()).toBe(false); + }); + map.on('moveend', () => { + expect(map.isMoving()).toBe(false); + done(); + }); + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvas()); + map._renderTaskQueue.run(); + }); + + test('returns true when drag rotating', done => { + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockImplementation(() => { return 0; }); + + map.on('movestart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('rotatestart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('rotateend', () => { + expect(map.isMoving()).toBe(false); + }); + + map.on('moveend', () => { + expect(map.isMoving()).toBe(false); + done(); + }); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + }); + + test('returns true when scroll zooming', done => { + map.on('zoomstart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('zoomend', () => { + expect(map.isMoving()).toBe(false); + done(); + }); + + let now = 0; + jest.spyOn(browser, 'now').mockImplementation(() => { return now; }); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + setTimeout(() => { + map._renderTaskQueue.run(); + }, 400); + }); + + test('returns true when drag panning and scroll zooming interleave', done => { + map.on('dragstart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('zoomstart', () => { + expect(map.isMoving()).toBe(true); + }); + + map.on('zoomend', () => { + expect(map.isMoving()).toBe(true); + simulate.mouseup(map.getCanvas()); + setTimeout(() => { + map._renderTaskQueue.run(); + done(); + }); + }); + + map.on('dragend', () => { + expect(map.isMoving()).toBe(false); + }); + + // The following should trigger the above events, where a zoomstart/zoomend + // pair is nested within a dragstart/dragend pair. + + simulate.mousedown(map.getCanvas()); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + let now = 0; + jest.spyOn(browser, 'now').mockImplementation(() => { return now; }); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + setTimeout(() => { + map._renderTaskQueue.run(); + }, 400); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/map/isRotating.test.ts b/web/libraries/maplibre-gl/src/ui/map/isRotating.test.ts new file mode 100644 index 00000000..71fe8676 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map/isRotating.test.ts @@ -0,0 +1,62 @@ +import {Map} from '../../ui/map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {browser} from '../../util/browser'; +import {beforeMapTest} from '../../util/test/util'; + +let map; + +function createMap() { + return new Map({style: '', container: DOM.create('div', '', window.document.body)}); +} + +beforeEach(() => { + beforeMapTest(); + map = createMap(); +}); + +afterEach(() => { + map.remove(); +}); + +describe('Map#isRotating', () => { + test('returns false by default', () => { + expect(map.isRotating()).toBe(false); + }); + + test('returns true during a camera rotate animation', done => { + map.on('rotatestart', () => { + expect(map.isRotating()).toBe(true); + }); + + map.on('rotateend', () => { + expect(map.isRotating()).toBe(false); + done(); + }); + + map.rotateTo(5, {duration: 0}); + }); + + test('returns true when drag rotating', done => { + // Prevent inertial rotation. + jest.spyOn(browser, 'now').mockImplementation(() => { return 0; }); + + map.on('rotatestart', () => { + expect(map.isRotating()).toBe(true); + }); + + map.on('rotateend', () => { + expect(map.isRotating()).toBe(false); + done(); + }); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/map/isZooming.test.ts b/web/libraries/maplibre-gl/src/ui/map/isZooming.test.ts new file mode 100644 index 00000000..9321c030 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map/isZooming.test.ts @@ -0,0 +1,87 @@ +import {browser} from '../../util/browser'; +import {Map} from '../../ui/map'; +import {DOM} from '../../util/dom'; +import simulate from '../../../test/unit/lib/simulate_interaction'; +import {beforeMapTest} from '../../util/test/util'; + +function createMap() { + return new Map({style: '', container: DOM.create('div', '', window.document.body)}); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('Map#isZooming', () => { + + test('returns false by default', done => { + const map = createMap(); + expect(map.isZooming()).toBe(false); + map.remove(); + done(); + }); + + test('returns true during a camera zoom animation', done => { + const map = createMap(); + + map.on('zoomstart', () => { + expect(map.isZooming()).toBe(true); + }); + + map.on('zoomend', () => { + expect(map.isZooming()).toBe(false); + map.remove(); + done(); + }); + + map.zoomTo(5, {duration: 0}); + }); + + test('returns true when scroll zooming', done => { + const map = createMap(); + + map.on('zoomstart', () => { + expect(map.isZooming()).toBe(true); + }); + + map.on('zoomend', () => { + expect(map.isZooming()).toBe(false); + map.remove(); + done(); + }); + + let now = 0; + jest.spyOn(browser, 'now').mockImplementation(() => { return now; }); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + now += 400; + setTimeout(() => { + map._renderTaskQueue.run(); + }, 400); + }); + + test('returns true when double-click zooming', done => { + const map = createMap(); + + map.on('zoomstart', () => { + expect(map.isZooming()).toBe(true); + }); + + map.on('zoomend', () => { + expect(map.isZooming()).toBe(false); + map.remove(); + done(); + }); + + let now = 0; + jest.spyOn(browser, 'now').mockImplementation(() => { return now; }); + + simulate.dblclick(map.getCanvas()); + map._renderTaskQueue.run(); + + now += 500; + map._renderTaskQueue.run(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/map/requestRenderFrame.test.ts b/web/libraries/maplibre-gl/src/ui/map/requestRenderFrame.test.ts new file mode 100644 index 00000000..e9c514f7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map/requestRenderFrame.test.ts @@ -0,0 +1,51 @@ +import {createMap, beforeMapTest} from '../../util/test/util'; + +beforeEach(() => { + beforeMapTest(); +}); + +describe('requestRenderFrame', () => { + + test('Map#_requestRenderFrame schedules a new render frame if necessary', (done) => { + const map = createMap(); + const spy = jest.spyOn(map, 'triggerRepaint'); + map._requestRenderFrame(() => {}); + expect(spy).toHaveBeenCalledTimes(0); + + // wait for style to be loaded + map.once('data', () => { + spy.mockReset(); + map._requestRenderFrame(() => {}); + expect(spy).toHaveBeenCalledTimes(1); + map.remove(); + done(); + }); + }); + + test('Map#_requestRenderFrame should not schedule a render frame before style load', () => { + const map = createMap(); + const spy = jest.spyOn(map, 'triggerRepaint'); + map._requestRenderFrame(() => {}); + expect(spy).toHaveBeenCalledTimes(0); + map.remove(); + }); + + test('Map#_requestRenderFrame queues a task for the next render frame', async () => { + const map = createMap(); + const cb = jest.fn(); + map._requestRenderFrame(cb); + await map.once('render'); + expect(cb).toHaveBeenCalledTimes(1); + map.remove(); + }); + + test('Map#_cancelRenderFrame cancels a queued task', async () => { + const map = createMap(); + const cb = jest.fn(); + const id = map._requestRenderFrame(cb); + map._cancelRenderFrame(id); + await map.once('render'); + expect(cb).toHaveBeenCalledTimes(0); + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/map_events.test.ts b/web/libraries/maplibre-gl/src/ui/map_events.test.ts new file mode 100644 index 00000000..05fea76b --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/map_events.test.ts @@ -0,0 +1,708 @@ +import simulate, {window} from '../../test/unit/lib/simulate_interaction'; +import {StyleLayer} from '../style/style_layer'; +import {createMap, beforeMapTest} from '../util/test/util'; +import {MapGeoJSONFeature} from '../util/vectortile_to_geojson'; +import {MapLayerEventType, MapLibreEvent} from './events'; + +type IsAny = 0 extends T & 1 ? T : never; +type NotAny = T extends IsAny ? never : T; +function assertNotAny(_x: NotAny) { } + +beforeEach(() => { + beforeMapTest(); +}); + +describe('map events', () => { + + test('Map#on adds a non-delegated event listener', () => { + const map = createMap(); + const spy = jest.fn(function (e) { + expect(this).toBe(map); + expect(e.type).toBe('click'); + }); + + map.on('click', spy); + simulate.click(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test('Map#off removes a non-delegated event listener', () => { + const map = createMap(); + const spy = jest.fn(); + + map.on('click', spy); + map.off('click', spy); + simulate.click(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test('Map#on adds a listener for an event on a given layer', () => { + const map = createMap(); + const features = [{} as MapGeoJSONFeature]; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => { + expect(options).toEqual({layers: ['layer']}); + return features; + }); + + const spy = jest.fn(function (e) { + expect(this).toBe(map); + expect(e.type).toBe('click'); + expect(e.features).toBe(features); + }); + + map.on('click', 'layer', spy); + simulate.click(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test('Map#on adds a listener not triggered for events not matching any features', () => { + const map = createMap(); + const features = []; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => { + expect(options).toEqual({layers: ['layer']}); + return features; + }); + + const spy = jest.fn(); + + map.on('click', 'layer', spy); + simulate.click(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test('Map#on adds a listener not triggered when the specified layer does not exiist', () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue(null as unknown as StyleLayer); + + const spy = jest.fn(); + + map.on('click', 'layer', spy); + simulate.click(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test('Map#on distinguishes distinct event types', () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spyDown = jest.fn((e) => { + expect(e.type).toBe('mousedown'); + }); + + const spyUp = jest.fn((e) => { + expect(e.type).toBe('mouseup'); + }); + + map.on('mousedown', 'layer', spyDown); + map.on('mouseup', 'layer', spyUp); + simulate.click(map.getCanvas()); + + expect(spyDown).toHaveBeenCalledTimes(1); + expect(spyUp).toHaveBeenCalledTimes(1); + }); + + test('Map#on distinguishes distinct layers', () => { + const map = createMap(); + const featuresA = [{} as MapGeoJSONFeature]; + const featuresB = [{} as MapGeoJSONFeature]; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => { + return (options as any).layers[0] === 'A' ? featuresA : featuresB; + }); + + const spyA = jest.fn((e) => { + expect(e.features).toBe(featuresA); + }); + + const spyB = jest.fn((e) => { + expect(e.features).toBe(featuresB); + }); + + map.on('click', 'A', spyA); + map.on('click', 'B', spyB); + simulate.click(map.getCanvas()); + + expect(spyA).toHaveBeenCalledTimes(1); + expect(spyB).toHaveBeenCalledTimes(1); + }); + + test('Map#on distinguishes distinct listeners', () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spyA = jest.fn(); + const spyB = jest.fn(); + + map.on('click', 'layer', spyA); + map.on('click', 'layer', spyB); + simulate.click(map.getCanvas()); + + expect(spyA).toHaveBeenCalledTimes(1); + expect(spyB).toHaveBeenCalledTimes(1); + }); + + test('Map#on calls an event listener with no type arguments, defaulting to \'unknown\' originalEvent type', () => { + const map = createMap(); + + const handler = { + onMove: function onMove(_event: MapLibreEvent) {} + }; + + jest.spyOn(handler, 'onMove'); + + map.on('move', (event) => handler.onMove(event)); + map.jumpTo({center: {lng: 10, lat: 10}}); + + expect(handler.onMove).toHaveBeenCalledTimes(1); + }); + + test('Map#on allows a listener to infer the event type ', () => { + const map = createMap(); + + const spy = jest.fn(); + map.on('mousemove', (event) => { + assertNotAny(event); + const {lng, lat} = event.lngLat; + spy({lng, lat}); + }); + + simulate.mousemove(map.getCanvas()); + expect(spy).toHaveBeenCalledTimes(1); + }); + + test('Map#off removes a delegated event listener', () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn(); + + map.on('click', 'layer', spy); + map.off('click', 'layer', spy); + simulate.click(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test('Map#off distinguishes distinct event types', () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn((e) => { + expect(e.type).toBe('mousedown'); + }); + + map.on('mousedown', 'layer', spy); + map.on('mouseup', 'layer', spy); + map.off('mouseup', 'layer', spy); + simulate.click(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test('Map#off distinguishes distinct layers', () => { + const map = createMap(); + const featuresA = [{} as MapGeoJSONFeature]; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => { + expect(options).toEqual({layers: ['A']}); + return featuresA; + }); + + const spy = jest.fn((e) => { + expect(e.features).toBe(featuresA); + }); + + map.on('click', 'A', spy); + map.on('click', 'B', spy); + map.off('click', 'B', spy); + simulate.click(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test('Map#off distinguishes distinct listeners', () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spyA = jest.fn(); + const spyB = jest.fn(); + + map.on('click', 'layer', spyA); + map.on('click', 'layer', spyB); + map.off('click', 'layer', spyB); + simulate.click(map.getCanvas()); + + expect(spyA).toHaveBeenCalledTimes(1); + expect(spyB).not.toHaveBeenCalled(); + }); + + test('Map#off calls an event listener with no type arguments, defaulting to \'unknown\' originalEvent type', () => { + const map = createMap(); + + const handler = { + onMove: function onMove(_event: MapLibreEvent) {} + }; + + jest.spyOn(handler, 'onMove'); + + map.off('move', (event) => handler.onMove(event)); + map.jumpTo({center: {lng: 10, lat: 10}}); + + expect(handler.onMove).toHaveBeenCalledTimes(0); + }); + + test('Map#off allows a listener to infer the event type ', () => { + const map = createMap(); + + const spy = jest.fn(); + map.off('mousemove', (event) => { + assertNotAny(event); + const {lng, lat} = event.lngLat; + spy({lng, lat}); + }); + + simulate.mousemove(map.getCanvas()); + expect(spy).toHaveBeenCalledTimes(0); + }); + + test('Map#once calls an event listener with no type arguments, defaulting to \'unknown\' originalEvent type', () => { + const map = createMap(); + + const handler = { + onMoveOnce: function onMoveOnce(_event: MapLibreEvent) {} + }; + + jest.spyOn(handler, 'onMoveOnce'); + + map.once('move', (event) => handler.onMoveOnce(event)); + map.jumpTo({center: {lng: 10, lat: 10}}); + + expect(handler.onMoveOnce).toHaveBeenCalledTimes(1); + }); + + test('Map#once allows a listener to infer the event type ', () => { + const map = createMap(); + + const spy = jest.fn(); + map.once('mousemove', (event) => { + assertNotAny(event); + const {lng, lat} = event.lngLat; + spy({lng, lat}); + }); + + simulate.mousemove(map.getCanvas()); + expect(spy).toHaveBeenCalledTimes(1); + }); + + (['mouseenter', 'mouseover'] as (keyof MapLayerEventType)[]).forEach((event) => { + test(`Map#on ${event} does not fire if the specified layer does not exist`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue(null as unknown as StyleLayer); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test(`Map#on ${event} fires when entering the specified layer`, () => { + const map = createMap(); + const features = [{} as MapGeoJSONFeature]; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => { + expect(options).toEqual({layers: ['layer']}); + return features; + }); + + const spy = jest.fn(function (e) { + expect(this).toBe(map); + expect(e.type).toBe(event); + expect(e.target).toBe(map); + expect(e.features).toBe(features); + }); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test(`Map#on ${event} does not fire on mousemove within the specified layer`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test(`Map#on ${event} fires when reentering the specified layer`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures') + .mockReturnValueOnce([{} as MapGeoJSONFeature]) + .mockReturnValueOnce([]) + .mockReturnValueOnce([{} as MapGeoJSONFeature]); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(2); + }); + + test(`Map#on ${event} fires when reentering the specified layer after leaving the canvas`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mouseout(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(2); + }); + + test(`Map#on ${event} distinguishes distinct layers`, () => { + const map = createMap(); + const featuresA = [{} as MapGeoJSONFeature]; + const featuresB = [{} as MapGeoJSONFeature]; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => { + return (options as any).layers[0] === 'A' ? featuresA : featuresB; + }); + + const spyA = jest.fn((e) => { + expect(e.features).toBe(featuresA); + }); + + const spyB = jest.fn((e) => { + expect(e.features).toBe(featuresB); + }); + + map.on(event, 'A', spyA); + map.on(event, 'B', spyB); + + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spyA).toHaveBeenCalledTimes(1); + expect(spyB).toHaveBeenCalledTimes(1); + }); + + test(`Map#on ${event} distinguishes distinct listeners`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spyA = jest.fn(); + const spyB = jest.fn(); + + map.on(event, 'layer', spyA); + map.on(event, 'layer', spyB); + simulate.mousemove(map.getCanvas()); + + expect(spyA).toHaveBeenCalledTimes(1); + expect(spyB).toHaveBeenCalledTimes(1); + }); + + test(`Map#off ${event} removes a delegated event listener`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + map.off(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test(`Map#off ${event} distinguishes distinct layers`, () => { + const map = createMap(); + const featuresA = [{} as MapGeoJSONFeature]; + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => { + expect(options).toEqual({layers: ['A']}); + return featuresA; + }); + + const spy = jest.fn((e) => { + expect(e.features).toBe(featuresA); + }); + + map.on(event, 'A', spy); + map.on(event, 'B', spy); + map.off(event, 'B', spy); + simulate.mousemove(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test(`Map#off ${event} distinguishes distinct listeners`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spyA = jest.fn(); + const spyB = jest.fn(); + + map.on(event, 'layer', spyA); + map.on(event, 'layer', spyB); + map.off(event, 'layer', spyB); + simulate.mousemove(map.getCanvas()); + + expect(spyA).toHaveBeenCalledTimes(1); + expect(spyB).not.toHaveBeenCalled(); + }); + }); + + (['mouseleave', 'mouseout'] as (keyof MapLayerEventType)[]).forEach((event) => { + test(`Map#on ${event} does not fire if the specified layer does not exiist`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue(null as unknown as StyleLayer); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test(`Map#on ${event} does not fire on mousemove when entering or within the specified layer`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + + test(`Map#on ${event} fires when exiting the specified layer`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures') + .mockReturnValueOnce([{} as MapGeoJSONFeature]) + .mockReturnValueOnce([]); + + const spy = jest.fn(function (e) { + expect(this).toBe(map); + expect(e.type).toBe(event); + expect(e.features).toBeUndefined(); + }); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test(`Map#on ${event} fires when exiting the canvas`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]); + + const spy = jest.fn(function (e) { + expect(this).toBe(map); + expect(e.type).toBe(event); + expect(e.features).toBeUndefined(); + }); + + map.on(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mouseout(map.getCanvas()); + + expect(spy).toHaveBeenCalledTimes(1); + }); + + test(`Map#off ${event} removes a delegated event listener`, () => { + const map = createMap(); + + jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer); + jest.spyOn(map, 'queryRenderedFeatures') + .mockReturnValueOnce([{} as MapGeoJSONFeature]) + .mockReturnValueOnce([]); + + const spy = jest.fn(); + + map.on(event, 'layer', spy); + map.off(event, 'layer', spy); + simulate.mousemove(map.getCanvas()); + simulate.mousemove(map.getCanvas()); + simulate.mouseout(map.getCanvas()); + + expect(spy).not.toHaveBeenCalled(); + + }); + }); + + test('Map#on mousedown can have default behavior prevented and still fire subsequent click event', () => { + const map = createMap(); + + map.on('mousedown', e => e.preventDefault()); + + const click = jest.fn(); + map.on('click', click); + + simulate.click(map.getCanvas()); + expect(click).toHaveBeenCalled(); + + map.remove(); + }); + + test('Map#on mousedown doesn\'t fire subsequent click event if mousepos changes', () => { + const map = createMap(); + + map.on('mousedown', e => e.preventDefault()); + + const click = jest.fn(); + map.on('click', click); + const canvas = map.getCanvas(); + + simulate.drag(canvas, {}, {clientX: 100, clientY: 100}); + expect(click).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('Map#on mousedown fires subsequent click event if mouse position changes less than click tolerance', () => { + const map = createMap({clickTolerance: 4}); + + map.on('mousedown', e => e.preventDefault()); + + const click = jest.fn(); + map.on('click', click); + const canvas = map.getCanvas(); + + simulate.drag(canvas, {clientX: 100, clientY: 100}, {clientX: 100, clientY: 103}); + expect(click).toHaveBeenCalled(); + + map.remove(); + }); + + test('Map#on mousedown does not fire subsequent click event if mouse position changes more than click tolerance', () => { + const map = createMap({clickTolerance: 4}); + + map.on('mousedown', e => e.preventDefault()); + + const click = jest.fn(); + map.on('click', click); + const canvas = map.getCanvas(); + + simulate.drag(canvas, {clientX: 100, clientY: 100}, {clientX: 100, clientY: 104}); + expect(click).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('Map#on click fires subsequent click event if there is no corresponding mousedown/mouseup event', () => { + const map = createMap({clickTolerance: 4}); + + const click = jest.fn(); + map.on('click', click); + const canvas = map.getCanvas(); + + const MouseEvent = window(canvas).MouseEvent; + const event = new MouseEvent('click', {bubbles: true, clientX: 100, clientY: 100}); + canvas.dispatchEvent(event); + expect(click).toHaveBeenCalled(); + + map.remove(); + }); + + test('Map#isMoving() returns false in mousedown/mouseup/click with no movement', () => { + const map = createMap({interactive: true, clickTolerance: 4}); + let mousedown, mouseup, click; + map.on('mousedown', () => { mousedown = map.isMoving(); }); + map.on('mouseup', () => { mouseup = map.isMoving(); }); + map.on('click', () => { click = map.isMoving(); }); + + const canvas = map.getCanvas(); + const MouseEvent = window(canvas).MouseEvent; + + canvas.dispatchEvent(new MouseEvent('mousedown', {bubbles: true, clientX: 100, clientY: 100})); + expect(mousedown).toBe(false); + map._renderTaskQueue.run(); + expect(mousedown).toBe(false); + + canvas.dispatchEvent(new MouseEvent('mouseup', {bubbles: true, clientX: 100, clientY: 100})); + expect(mouseup).toBe(false); + map._renderTaskQueue.run(); + expect(mouseup).toBe(false); + + canvas.dispatchEvent(new MouseEvent('click', {bubbles: true, clientX: 100, clientY: 100})); + expect(click).toBe(false); + map._renderTaskQueue.run(); + expect(click).toBe(false); + + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/marker.test.ts b/web/libraries/maplibre-gl/src/ui/marker.test.ts new file mode 100644 index 00000000..92fa686f --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/marker.test.ts @@ -0,0 +1,839 @@ +import {createMap as globalCreateMap, beforeMapTest} from '../util/test/util'; +import {Marker} from './marker'; +import {Popup} from './popup'; +import {LngLat} from '../geo/lng_lat'; +import Point from '@mapbox/point-geometry'; +import simulate from '../../test/unit/lib/simulate_interaction'; +import type {Terrain} from '../render/terrain'; + +function createMap(options = {}) { + const container = window.document.createElement('div'); + window.document.body.appendChild(container); + Object.defineProperty(container, 'clientWidth', {value: 512}); + Object.defineProperty(container, 'clientHeight', {value: 512}); + return globalCreateMap({container, ...options}); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('marker', () => { + test('Marker uses a default marker element with an appropriate offset', () => { + const marker = new Marker(); + expect(marker.getElement()).toBeTruthy(); + expect(marker.getOffset().equals(new Point(0, -14))).toBeTruthy(); + }); + + test('Marker uses a default marker element with custom color', () => { + const marker = new Marker({color: '#123456'}); + expect(marker.getElement().innerHTML.includes('#123456')).toBeTruthy(); + }); + + test('Marker uses a default marker element with custom scale', () => { + const map = createMap(); + const defaultMarker = new Marker() + .setLngLat([0, 0]) + .addTo(map); + // scale smaller than default + const smallerMarker = new Marker({scale: 0.8}) + .setLngLat([0, 0]) + .addTo(map); + // scale larger than default + const largerMarker = new Marker({scale: 2}) + .setLngLat([0, 0]) + .addTo(map); + + // initial dimensions of svg element + expect( + defaultMarker.getElement().children[0].getAttribute('height').includes('41') + ).toBeTruthy(); + expect(defaultMarker.getElement().children[0].getAttribute('width').includes('27')).toBeTruthy(); + + // (41 * 0.8) = 32.8, (27 * 0.8) = 21.6 + expect( + smallerMarker.getElement().children[0].getAttribute('height').includes('32.8') + ).toBeTruthy(); + expect( + smallerMarker.getElement().children[0].getAttribute('width').includes('21.6') + ).toBeTruthy(); + + // (41 * 2) = 82, (27 * 2) = 54 + expect(largerMarker.getElement().children[0].getAttribute('height').includes('82')).toBeTruthy(); + expect(largerMarker.getElement().children[0].getAttribute('width').includes('54')).toBeTruthy(); + + }); + + test('Marker uses a default marker with custom offset', () => { + const marker = new Marker({offset: [1, 2]}); + expect(marker.getElement()).toBeTruthy(); + expect(marker.getOffset().equals(new Point(1, 2))).toBeTruthy(); + }); + + test('Marker uses the provided element', () => { + const element = window.document.createElement('div'); + const marker = new Marker({element}); + expect(marker.getElement()).toBe(element); + }); + + test('Marker#addTo adds the marker element to the canvas container', () => { + const map = createMap(); + new Marker() + .setLngLat([-77.01866, 38.888]) + .addTo(map); + + expect(map.getCanvasContainer().querySelectorAll('.maplibregl-marker')).toHaveLength(1); + + map.remove(); + }); + + test('Marker adds classes from className option, methods for class manipulations works properly', () => { + const map = createMap(); + const marker = new Marker({className: 'some classes'}) + .setLngLat([0, 0]) + .addTo(map); + + const markerElement = marker.getElement(); + expect(markerElement.classList.contains('some')).toBeTruthy(); + expect(markerElement.classList.contains('classes')).toBeTruthy(); + + marker.addClassName('addedClass'); + expect(markerElement.classList.contains('addedClass')).toBeTruthy(); + + marker.removeClassName('addedClass'); + expect(!markerElement.classList.contains('addedClass')).toBeTruthy(); + + marker.toggleClassName('toggle'); + expect(markerElement.classList.contains('toggle')).toBeTruthy(); + + marker.toggleClassName('toggle'); + expect(!markerElement.classList.contains('toggle')).toBeTruthy(); + + expect(() => marker.addClassName('should throw exception')).toThrow(window.DOMException); + expect(() => marker.removeClassName('should throw exception')).toThrow(window.DOMException); + expect(() => marker.toggleClassName('should throw exception')).toThrow(window.DOMException); + + expect(() => marker.addClassName('')).toThrow(window.DOMException); + expect(() => marker.removeClassName('')).toThrow(window.DOMException); + expect(() => marker.toggleClassName('')).toThrow(window.DOMException); + }); + + test('Marker provides LngLat accessors', () => { + expect(new Marker().getLngLat()).toBeUndefined(); + + expect(new Marker().setLngLat([1, 2]).getLngLat() instanceof LngLat).toBeTruthy(); + expect(new Marker().setLngLat([1, 2]).getLngLat()).toEqual(new LngLat(1, 2)); + + expect(new Marker().setLngLat(new LngLat(1, 2)).getLngLat() instanceof LngLat).toBeTruthy(); + expect(new Marker().setLngLat(new LngLat(1, 2)).getLngLat()).toEqual(new LngLat(1, 2)); + + }); + + test('Marker provides offset accessors', () => { + expect(new Marker().setOffset([1, 2]).getOffset() instanceof Point).toBeTruthy(); + expect(new Marker().setOffset([1, 2]).getOffset()).toEqual(new Point(1, 2)); + + expect(new Marker().setOffset(new Point(1, 2)).getOffset() instanceof Point).toBeTruthy(); + expect(new Marker().setOffset(new Point(1, 2)).getOffset()).toEqual(new Point(1, 2)); + + }); + + test('Marker#setPopup binds a popup', () => { + const popup = new Popup(); + const marker = new Marker() + .setPopup(popup); + expect(marker.getPopup()).toBe(popup); + }); + + test('Marker#setPopup unbinds a popup', () => { + const marker = new Marker() + .setPopup(new Popup()) + .setPopup(); + expect(!marker.getPopup()).toBeTruthy(); + }); + + test('Marker#togglePopup opens a popup that was closed', () => { + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .addTo(map) + .setPopup(new Popup()) + .togglePopup(); + + expect(marker.getPopup().isOpen()).toBeTruthy(); + + map.remove(); + }); + + test('Marker#togglePopup closes a popup that was open', () => { + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .addTo(map) + .setPopup(new Popup()) + .togglePopup() + .togglePopup(); + + expect(!marker.getPopup().isOpen()).toBeTruthy(); + + map.remove(); + }); + + test('Enter key on Marker opens a popup that was closed', () => { + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .addTo(map) + .setPopup(new Popup()); + + // popup not initially open + expect(marker.getPopup().isOpen()).toBeFalsy(); + + simulate.keypress(marker.getElement(), {code: 'Enter'}); + + // popup open after Enter keypress + expect(marker.getPopup().isOpen()).toBeTruthy(); + + map.remove(); + }); + + test('Space key on Marker opens a popup that was closed', () => { + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .addTo(map) + .setPopup(new Popup()); + + // popup not initially open + expect(marker.getPopup().isOpen()).toBeFalsy(); + + simulate.keypress(marker.getElement(), {code: 'Space'}); + + // popup open after Enter keypress + expect(marker.getPopup().isOpen()).toBeTruthy(); + + map.remove(); + }); + + test('Marker#setPopup sets a tabindex', () => { + const popup = new Popup(); + const marker = new Marker() + .setPopup(popup); + expect(marker.getElement().getAttribute('tabindex')).toBe('0'); + }); + + test('Marker#setPopup removes tabindex when unset', () => { + const popup = new Popup(); + const marker = new Marker() + .setPopup(popup) + .setPopup(); + expect(marker.getElement().getAttribute('tabindex')).toBeFalsy(); + }); + + test('Marker#setPopup does not replace existing tabindex', () => { + const element = window.document.createElement('div'); + element.setAttribute('tabindex', '5'); + const popup = new Popup(); + const marker = new Marker({element}) + .setPopup(popup); + expect(marker.getElement().getAttribute('tabindex')).toBe('5'); + }); + + test('Marker anchor defaults to center', () => { + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.getElement().classList.contains('maplibregl-marker-anchor-center')).toBeTruthy(); + expect(marker.getElement().style.transform).toMatch(/translate\(-50%,-50%\)/); + + map.remove(); + }); + + test('Marker anchors as specified by the anchor option', () => { + const map = createMap(); + const marker = new Marker({anchor: 'top'}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.getElement().classList.contains('maplibregl-marker-anchor-top')).toBeTruthy(); + expect(marker.getElement().style.transform).toMatch(/translate\(-50%,0\)/); + + map.remove(); + }); + + test('Popup offsets around default Marker', () => { + const map = createMap(); + + const marker = new Marker() + .setLngLat([0, 0]) + .setPopup(new Popup().setText('Test')) + .addTo(map); + + expect(marker.getPopup().options.offset['bottom'][1] < 0).toBeTruthy(); + expect(marker.getPopup().options.offset['top'][1] === 0).toBeTruthy(); + expect(marker.getPopup().options.offset['left'][0] > 0).toBeTruthy(); + expect(marker.getPopup().options.offset['right'][0] < 0).toBeTruthy(); + + expect(marker.getPopup().options.offset['bottom-left'][0] > 0).toBeTruthy(); + expect(marker.getPopup().options.offset['bottom-left'][1] < 0).toBeTruthy(); + expect(marker.getPopup().options.offset['bottom-right'][0] < 0).toBeTruthy(); + expect(marker.getPopup().options.offset['bottom-right'][1] < 0).toBeTruthy(); + + expect(marker.getPopup().options.offset['top-left']).toEqual([0, 0]); + expect(marker.getPopup().options.offset['top-right']).toEqual([0, 0]); + + }); + + test('Popup anchors around default Marker', () => { + const map = createMap(); + + const marker = new Marker() + .setLngLat([0, 0]) + .setPopup(new Popup().setText('Test')) + .addTo(map); + + // open the popup + marker.togglePopup(); + + const mapHeight = map.getContainer().clientHeight; + const markerTop = -marker.getPopup().options.offset['bottom'][1]; // vertical distance from tip of marker to the top in pixels + const markerRight = -marker.getPopup().options.offset['right'][0]; // horizontal distance from the tip of the marker to the right in pixels + + // give the popup some height + Object.defineProperty(marker.getPopup()._container, 'offsetWidth', {value: 100}); + Object.defineProperty(marker.getPopup()._container, 'offsetHeight', {value: 100}); + + // marker should default to above since it has enough space + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-bottom') + ).toBeTruthy(); + + // move marker to the top forcing the popup to below + marker.setLngLat(map.unproject([mapHeight / 2, markerTop])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-top') + ).toBeTruthy(); + + // move marker to the right forcing the popup to the left + marker.setLngLat(map.unproject([mapHeight - markerRight, mapHeight / 2])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-right') + ).toBeTruthy(); + + // move marker to the left forcing the popup to the right + marker.setLngLat(map.unproject([markerRight, mapHeight / 2])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-left') + ).toBeTruthy(); + + // move marker to the top left forcing the popup to the bottom right + marker.setLngLat(map.unproject([markerRight, markerTop])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-top-left') + ).toBeTruthy(); + + // move marker to the top right forcing the popup to the bottom left + marker.setLngLat(map.unproject([mapHeight - markerRight, markerTop])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-top-right') + ).toBeTruthy(); + + // move marker to the bottom left forcing the popup to the top right + marker.setLngLat(map.unproject([markerRight, mapHeight])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-bottom-left') + ).toBeTruthy(); + + // move marker to the bottom right forcing the popup to the top left + marker.setLngLat(map.unproject([mapHeight - markerRight, mapHeight])); + expect( + marker.getPopup()._container.classList.contains('maplibregl-popup-anchor-bottom-right') + ).toBeTruthy(); + + }); + + test('Marker drag functionality can be added with drag option', () => { + const map = createMap(); + const marker = new Marker({draggable: true}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.isDraggable()).toBe(true); + + map.remove(); + }); + + test('Marker#setDraggable adds drag functionality', () => { + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .setDraggable(true) + .addTo(map); + + expect(marker.isDraggable()).toBe(true); + + map.remove(); + }); + + test('Marker#setDraggable turns off drag functionality', () => { + const map = createMap(); + const marker = new Marker({draggable: true}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.isDraggable()).toBe(true); + + marker.setDraggable(false); + + expect(marker.isDraggable()).toBe(false); + + map.remove(); + }); + + test('Marker with draggable:true fires dragstart, drag, and dragend events at appropriate times in response to mouse-triggered drag with map-inherited clickTolerance', () => { + const map = createMap(); + const marker = new Marker({draggable: true}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + marker.on('dragstart', dragstart); + marker.on('drag', drag); + marker.on('dragend', dragend); + + simulate.mousedown(el, {clientX: 0, clientY: 0}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + simulate.mousemove(el, {clientX: 2.9, clientY: 0}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + // above map's click tolerance + simulate.mousemove(el, {clientX: 3.1, clientY: 0}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.mousemove(el, {clientX: 0, clientY: 0}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.mouseup(el); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(1); + expect(el.style.pointerEvents).toBe('auto'); + + map.remove(); + }); + + test('Marker with draggable:true fires dragstart, drag, and dragend events at appropriate times in response to mouse-triggered drag with marker-specific clickTolerance', () => { + const map = createMap(); + const marker = new Marker({draggable: true, clickTolerance: 4}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + marker.on('dragstart', dragstart); + marker.on('drag', drag); + marker.on('dragend', dragend); + + simulate.mousedown(el, {clientX: 0, clientY: 0}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + simulate.mousemove(el, {clientX: 3.9, clientY: 0}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + // above map's click tolerance + simulate.mousemove(el, {clientX: 4.1, clientY: 0}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.mousemove(el, {clientX: 0, clientY: 0}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.mouseup(el); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(1); + expect(el.style.pointerEvents).toBe('auto'); + + map.remove(); + }); + + test('Marker with draggable:false does not fire dragstart, drag, and dragend events in response to a mouse-triggered drag', () => { + const map = createMap(); + const marker = new Marker({}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + marker.on('dragstart', dragstart); + marker.on('drag', drag); + marker.on('dragend', dragend); + + simulate.mousedown(el, {clientX: 0, clientY: 0}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + simulate.mousemove(el, {clientX: 3, clientY: 1}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + simulate.mouseup(el); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('Marker with draggable:true fires dragstart, drag, and dragend events at appropriate times in response to a touch-triggered drag with map-inherited clickTolerance', () => { + const map = createMap(); + const marker = new Marker({draggable: true}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + marker.on('dragstart', dragstart); + marker.on('drag', drag); + marker.on('dragend', dragend); + + simulate.touchstart(el, {touches: [{clientX: 0, clientY: 0}]}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + simulate.touchmove(el, {touches: [{clientX: 2.9, clientY: 0}]}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + // above map's click tolerance + simulate.touchmove(el, {touches: [{clientX: 3.1, clientY: 0}]}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.touchmove(el, {touches: [{clientX: 0, clientY: 0}]}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.touchend(el); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(1); + expect(el.style.pointerEvents).toBe('auto'); + + map.remove(); + }); + + test('Marker with draggable:true fires dragstart, drag, and dragend events at appropriate times in response to a touch-triggered drag with marker-specific clickTolerance', () => { + const map = createMap(); + const marker = new Marker({draggable: true, clickTolerance: 4}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + marker.on('dragstart', dragstart); + marker.on('drag', drag); + marker.on('dragend', dragend); + + simulate.touchstart(el, {touches: [{clientX: 0, clientY: 0}]}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + simulate.touchmove(el, {touches: [{clientX: 3.9, clientY: 0}]}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe(''); + + // above map's click tolerance + simulate.touchmove(el, {touches: [{clientX: 4.1, clientY: 0}]}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(1); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.touchmove(el, {touches: [{clientX: 0, clientY: 0}]}); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).not.toHaveBeenCalled(); + expect(el.style.pointerEvents).toBe('none'); + + simulate.touchend(el); + expect(dragstart).toHaveBeenCalledTimes(1); + expect(drag).toHaveBeenCalledTimes(2); + expect(dragend).toHaveBeenCalledTimes(1); + expect(el.style.pointerEvents).toBe('auto'); + + map.remove(); + }); + + test('Marker with draggable:false does not fire dragstart, drag, and dragend events in response to a touch-triggered drag', () => { + const map = createMap(); + const marker = new Marker({}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + + const dragstart = jest.fn(); + const drag = jest.fn(); + const dragend = jest.fn(); + + marker.on('dragstart', dragstart); + marker.on('drag', drag); + marker.on('dragend', dragend); + + simulate.touchstart(el, {touches: [{clientX: 0, clientY: 0}]}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + simulate.touchmove(el, {touches: [{clientX: 0, clientY: 0}]}); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + simulate.touchend(el); + expect(dragstart).not.toHaveBeenCalled(); + expect(drag).not.toHaveBeenCalled(); + expect(dragend).not.toHaveBeenCalled(); + + map.remove(); + }); + + test('Marker with draggable:true moves to new position in response to a mouse-triggered drag', () => { + const map = createMap(); + const marker = new Marker({draggable: true}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + const startPos = map.project(marker.getLngLat()); + simulate.mousedown(el); + simulate.mousemove(el, {clientX: 10, clientY: 10}); + simulate.mouseup(el); + + const endPos = map.project(marker.getLngLat()); + expect(Math.round(endPos.x)).toBe(startPos.x + 10); + expect(Math.round(endPos.y)).toBe(startPos.y + 10); + + map.remove(); + }); + + test('Marker with draggable:false does not move to new position in response to a mouse-triggered drag', () => { + const map = createMap(); + const marker = new Marker({}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + const startPos = map.project(marker.getLngLat()); + + simulate.mousedown(el); + simulate.mousemove(el); + simulate.mouseup(el); + + const endPos = map.project(marker.getLngLat()); + + expect(startPos.x).toBe(endPos.x); + expect(startPos.y).toBe(endPos.y); + + map.remove(); + }); + + test('Marker with draggable:true does not error if removed on mousedown', () => { + const map = createMap(); + const marker = new Marker({draggable: true}) + .setLngLat([0, 0]) + .addTo(map); + const el = marker.getElement(); + simulate.mousedown(el); + simulate.mousemove(el, {clientX: 10, clientY: 10}); + + marker.remove(); + expect(map.fire('mouseup')).toBeTruthy(); + }); + + test('Marker can set rotationAlignment and pitchAlignment', () => { + const map = createMap(); + const marker = new Marker({rotationAlignment: 'map', pitchAlignment: 'map'}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.getRotationAlignment()).toBe('map'); + expect(marker.getPitchAlignment()).toBe('map'); + + map.remove(); + }); + + test('Marker can set and update rotation', () => { + const map = createMap(); + const marker = new Marker({rotation: 45}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.getRotation()).toBe(45); + + marker.setRotation(90); + expect(marker.getRotation()).toBe(90); + + map.remove(); + }); + + test('Marker transforms rotation with the map', () => { + const map = createMap(); + const marker = new Marker({rotationAlignment: 'map'}) + .setLngLat([0, 0]) + .addTo(map); + + const rotationRegex = /rotateZ\(-?([0-9]+)deg\)/; + const initialRotation = marker.getElement().style.transform.match(rotationRegex)[1]; + + map.setBearing(map.getBearing() + 180); + + const finalRotation = marker.getElement().style.transform.match(rotationRegex)[1]; + expect(initialRotation).not.toBe(finalRotation); + + map.remove(); + }); + + test('Marker transforms pitch with the map', () => { + const map = createMap(); + const marker = new Marker({pitchAlignment: 'map'}) + .setLngLat([0, 0]) + .addTo(map); + + map.setPitch(0); + + const rotationRegex = /rotateX\(-?([0-9]+)deg\)/; + const initialPitch = marker.getElement().style.transform.match(rotationRegex)[1]; + + map.setPitch(45); + + const finalPitch = marker.getElement().style.transform.match(rotationRegex)[1]; + expect(initialPitch).not.toBe(finalPitch); + + map.remove(); + }); + + test('Marker pitchAlignment when set to auto defaults to rotationAlignment', () => { + const map = createMap(); + const marker = new Marker({rotationAlignment: 'map', pitchAlignment: 'auto'}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.getRotationAlignment()).toBe(marker.getPitchAlignment()); + + map.remove(); + }); + + test('Marker pitchAlignment when set to auto defaults to rotationAlignment (setter/getter)', () => { + const map = createMap(); + const marker = new Marker({pitchAlignment: 'map'}) + .setLngLat([0, 0]) + .addTo(map); + + expect(marker.getPitchAlignment()).toBe('map'); + marker.setRotationAlignment('viewport'); + marker.setPitchAlignment('auto'); + expect(marker.getRotationAlignment()).toBe(marker.getPitchAlignment()); + + map.remove(); + }); + + test('Marker removed after update when terrain is on should clear timeout', () => { + jest.spyOn(global, 'setTimeout'); + jest.spyOn(global, 'clearTimeout'); + const map = createMap(); + const marker = new Marker() + .setLngLat([0, 0]) + .addTo(map); + map.terrain = { + getElevationForLngLatZoom: () => 0 + } as any as Terrain; + + marker.setOffset([10, 10]); + + expect(setTimeout).toHaveBeenCalled(); + marker.remove(); + expect(clearTimeout).toHaveBeenCalled(); + + map.remove(); + }); + + test('Marker after the terrain event must listen to the render event till is fully loaded', async () => { + const map = createMap(); + + new Marker() + .setLngLat([1, 1]) + .addTo(map); + + expect(map._oneTimeListeners.render).toBeUndefined(); + + map.fire('terrain'); + expect(map._oneTimeListeners.render).toHaveLength(1); + + map.fire('render'); + expect(map._oneTimeListeners.render).toHaveLength(1); + + map.fire('render'); + expect(map._oneTimeListeners.render).toHaveLength(1); + + // await idle to be fully loaded + await map.once('idle'); + map.fire('render'); + expect(map._oneTimeListeners.render).toHaveLength(0); + map.remove(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/marker.ts b/web/libraries/maplibre-gl/src/ui/marker.ts new file mode 100644 index 00000000..e5c6908a --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/marker.ts @@ -0,0 +1,771 @@ +import {DOM} from '../util/dom'; +import {LngLat} from '../geo/lng_lat'; +import Point from '@mapbox/point-geometry'; +import {smartWrap} from '../util/smart_wrap'; +import {anchorTranslate, applyAnchorClass} from './anchor'; +import type {PositionAnchor} from './anchor'; +import {Event, Evented} from '../util/evented'; +import type {Map} from './map'; +import {Popup, Offset} from './popup'; +import type {LngLatLike} from '../geo/lng_lat'; +import type {MapMouseEvent, MapTouchEvent} from './events'; +import type {PointLike} from './camera'; + +/** + * Alignment options of rotation and pitch + */ +type Alignment = 'map' | 'viewport' | 'auto'; + +/** + * The {@link Marker} options object + */ +type MarkerOptions = { + /** + * DOM element to use as a marker. The default is a light blue, droplet-shaped SVG marker. + */ + element?: HTMLElement; + /** + * Space-separated CSS class names to add to marker element. + */ + className?: string; + /** + * The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up. + */ + offset?: PointLike; + /** + * A string indicating the part of the Marker that should be positioned closest to the coordinate set via {@link Marker#setLngLat}. + * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`, `'bottom-left'`, and `'bottom-right'`. + * @defaultValue 'center' + * */ + anchor?: PositionAnchor; + /** + * The color to use for the default marker if options.element is not provided. The default is light blue. + * @defaultValue '#3FB1CE' + */ + color?: string; + /** + * The scale to use for the default marker if options.element is not provided. The default scale corresponds to a height of `41px` and a width of `27px`. + * @defaultValue 1 + */ + scale?: number; + /** + * A boolean indicating whether or not a marker is able to be dragged to a new position on the map. + * @defaultValue false + */ + draggable?: boolean; + /** + * The max number of pixels a user can shift the mouse pointer during a click on the marker for it to be considered a valid click (as opposed to a marker drag). The default is to inherit map's clickTolerance. + * @defaultValue 0 + */ + clickTolerance?: number; + /** + * The rotation angle of the marker in degrees, relative to its respective `rotationAlignment` setting. A positive value will rotate the marker clockwise. + * @defaultValue 0 + */ + rotation?: number; + /** + * `map` aligns the `Marker`'s rotation relative to the map, maintaining a bearing as the map rotates. `viewport` aligns the `Marker`'s rotation relative to the viewport, agnostic to map rotations. `auto` is equivalent to `viewport`. + * @defaultValue 'auto' + */ + rotationAlignment?: Alignment; + /** + * `map` aligns the `Marker` to the plane of the map. `viewport` aligns the `Marker` to the plane of the viewport. `auto` automatically matches the value of `rotationAlignment`. + * @defaultValue 'auto' + */ + pitchAlignment?: Alignment; +}; + +/** + * Creates a marker component + * + * @group Markers and Controls + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([30.5, 50.5]) + * .addTo(map); + * ``` + * + * @example + * Set options + * ```ts + * let marker = new maplibregl.Marker({ + * color: "#FFFFFF", + * draggable: true + * }).setLngLat([30.5, 50.5]) + * .addTo(map); + * ``` + * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/) + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + * + * ### Events + * + * @event `dragstart` Fired when dragging starts, `marker` object that is being dragged + * + * @event `drag` Fired while dragging. `marker` object that is being dragged + * + * @event `dragend` Fired when the marker is finished being dragged, `marker` object that was dragged + */ +export class Marker extends Evented { + _map: Map; + _anchor: PositionAnchor; + _offset: Point; + _element: HTMLElement; + _popup: Popup; + _lngLat: LngLat; + _pos: Point; + _color: string; + _scale: number; + _defaultMarker: boolean; + _draggable: boolean; + _clickTolerance: number; + _isDragging: boolean; + _state: 'inactive' | 'pending' | 'active'; // used for handling drag events + _positionDelta: Point; + _pointerdownPos: Point; + _rotation: number; + _pitchAlignment: Alignment; + _rotationAlignment: Alignment; + _originalTabIndex: string; // original tabindex of _element + _opacityTimeout: ReturnType; + + /** + * @param options - the options + */ + constructor(options?: MarkerOptions) { + super(); + + this._anchor = options && options.anchor || 'center'; + this._color = options && options.color || '#3FB1CE'; + this._scale = options && options.scale || 1; + this._draggable = options && options.draggable || false; + this._clickTolerance = options && options.clickTolerance || 0; + this._isDragging = false; + this._state = 'inactive'; + this._rotation = options && options.rotation || 0; + this._rotationAlignment = options && options.rotationAlignment || 'auto'; + this._pitchAlignment = options && options.pitchAlignment && options.pitchAlignment !== 'auto' ? options.pitchAlignment : this._rotationAlignment; + + if (!options || !options.element) { + this._defaultMarker = true; + this._element = DOM.create('div'); + this._element.setAttribute('aria-label', 'Map marker'); + + // create default map marker SVG + const svg = DOM.createNS('http://www.w3.org/2000/svg', 'svg'); + const defaultHeight = 41; + const defaultWidth = 27; + svg.setAttributeNS(null, 'display', 'block'); + svg.setAttributeNS(null, 'height', `${defaultHeight}px`); + svg.setAttributeNS(null, 'width', `${defaultWidth}px`); + svg.setAttributeNS(null, 'viewBox', `0 0 ${defaultWidth} ${defaultHeight}`); + + const markerLarge = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + markerLarge.setAttributeNS(null, 'stroke', 'none'); + markerLarge.setAttributeNS(null, 'stroke-width', '1'); + markerLarge.setAttributeNS(null, 'fill', 'none'); + markerLarge.setAttributeNS(null, 'fill-rule', 'evenodd'); + + const page1 = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + page1.setAttributeNS(null, 'fill-rule', 'nonzero'); + + const shadow = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + shadow.setAttributeNS(null, 'transform', 'translate(3.0, 29.0)'); + shadow.setAttributeNS(null, 'fill', '#000000'); + + const ellipses = [ + {'rx': '10.5', 'ry': '5.25002273'}, + {'rx': '10.5', 'ry': '5.25002273'}, + {'rx': '9.5', 'ry': '4.77275007'}, + {'rx': '8.5', 'ry': '4.29549936'}, + {'rx': '7.5', 'ry': '3.81822308'}, + {'rx': '6.5', 'ry': '3.34094679'}, + {'rx': '5.5', 'ry': '2.86367051'}, + {'rx': '4.5', 'ry': '2.38636864'} + ]; + + for (const data of ellipses) { + const ellipse = DOM.createNS('http://www.w3.org/2000/svg', 'ellipse'); + ellipse.setAttributeNS(null, 'opacity', '0.04'); + ellipse.setAttributeNS(null, 'cx', '10.5'); + ellipse.setAttributeNS(null, 'cy', '5.80029008'); + ellipse.setAttributeNS(null, 'rx', data['rx']); + ellipse.setAttributeNS(null, 'ry', data['ry']); + shadow.appendChild(ellipse); + } + + const background = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + background.setAttributeNS(null, 'fill', this._color); + + const bgPath = DOM.createNS('http://www.w3.org/2000/svg', 'path'); + bgPath.setAttributeNS(null, 'd', 'M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z'); + + background.appendChild(bgPath); + + const border = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + border.setAttributeNS(null, 'opacity', '0.25'); + border.setAttributeNS(null, 'fill', '#000000'); + + const borderPath = DOM.createNS('http://www.w3.org/2000/svg', 'path'); + borderPath.setAttributeNS(null, 'd', 'M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z'); + + border.appendChild(borderPath); + + const maki = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + maki.setAttributeNS(null, 'transform', 'translate(6.0, 7.0)'); + maki.setAttributeNS(null, 'fill', '#FFFFFF'); + + const circleContainer = DOM.createNS('http://www.w3.org/2000/svg', 'g'); + circleContainer.setAttributeNS(null, 'transform', 'translate(8.0, 8.0)'); + + const circle1 = DOM.createNS('http://www.w3.org/2000/svg', 'circle'); + circle1.setAttributeNS(null, 'fill', '#000000'); + circle1.setAttributeNS(null, 'opacity', '0.25'); + circle1.setAttributeNS(null, 'cx', '5.5'); + circle1.setAttributeNS(null, 'cy', '5.5'); + circle1.setAttributeNS(null, 'r', '5.4999962'); + + const circle2 = DOM.createNS('http://www.w3.org/2000/svg', 'circle'); + circle2.setAttributeNS(null, 'fill', '#FFFFFF'); + circle2.setAttributeNS(null, 'cx', '5.5'); + circle2.setAttributeNS(null, 'cy', '5.5'); + circle2.setAttributeNS(null, 'r', '5.4999962'); + + circleContainer.appendChild(circle1); + circleContainer.appendChild(circle2); + + page1.appendChild(shadow); + page1.appendChild(background); + page1.appendChild(border); + page1.appendChild(maki); + page1.appendChild(circleContainer); + + svg.appendChild(page1); + + svg.setAttributeNS(null, 'height', `${defaultHeight * this._scale}px`); + svg.setAttributeNS(null, 'width', `${defaultWidth * this._scale}px`); + + this._element.appendChild(svg); + + // if no element and no offset option given apply an offset for the default marker + // the -14 as the y value of the default marker offset was determined as follows + // + // the marker tip is at the center of the shadow ellipse from the default svg + // the y value of the center of the shadow ellipse relative to the svg top left is "shadow transform translate-y (29.0) + ellipse cy (5.80029008)" + // offset to the svg center "height (41 / 2)" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14 + // negative is used to move the marker up from the center so the tip is at the Marker lngLat + this._offset = Point.convert(options && options.offset || [0, -14]); + } else { + this._element = options.element; + this._offset = Point.convert(options && options.offset || [0, 0]); + } + + this._element.classList.add('maplibregl-marker'); + this._element.addEventListener('dragstart', (e: DragEvent) => { + e.preventDefault(); + }); + this._element.addEventListener('mousedown', (e: MouseEvent) => { + // prevent focusing on click + e.preventDefault(); + }); + applyAnchorClass(this._element, this._anchor, 'marker'); + + if (options && options.className) { + for (const name of options.className.split(' ')) { + this._element.classList.add(name); + } + } + + this._popup = null; + } + + /** + * Attaches the `Marker` to a `Map` object. + * @param map - The MapLibre GL JS map to add the marker to. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([30.5, 50.5]) + * .addTo(map); // add the marker to the map + * ``` + */ + addTo(map: Map): this { + this.remove(); + this._map = map; + map.getCanvasContainer().appendChild(this._element); + map.on('move', this._update); + map.on('moveend', this._update); + map.on('terrain', this._update); + + this.setDraggable(this._draggable); + this._update(); + + // If we attached the `click` listener to the marker element, the popup + // would close once the event propagated to `map` due to the + // `Popup#_onClickClose` listener. + this._map.on('click', this._onMapClick); + + return this; + } + + /** + * Removes the marker from a map + * @example + * ```ts + * let marker = new maplibregl.Marker().addTo(map); + * marker.remove(); + * ``` + * @returns `this` + */ + remove(): this { + if (this._opacityTimeout) { + clearTimeout(this._opacityTimeout); + delete this._opacityTimeout; + } + if (this._map) { + this._map.off('click', this._onMapClick); + this._map.off('move', this._update); + this._map.off('moveend', this._update); + this._map.off('mousedown', this._addDragHandler); + this._map.off('touchstart', this._addDragHandler); + this._map.off('mouseup', this._onUp); + this._map.off('touchend', this._onUp); + this._map.off('mousemove', this._onMove); + this._map.off('touchmove', this._onMove); + delete this._map; + } + DOM.remove(this._element); + if (this._popup) this._popup.remove(); + return this; + } + + /** + * Get the marker's geographical location. + * + * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously + * set by `setLngLat` because `Marker` wraps the anchor longitude across copies of the world to keep + * the marker on screen. + * + * @returns A {@link LngLat} describing the marker's location. + * @example + * ```ts + * // Store the marker's longitude and latitude coordinates in a variable + * let lngLat = marker.getLngLat(); + * // Print the marker's longitude and latitude values in the console + * console.log('Longitude: ' + lngLat.lng + ', Latitude: ' + lngLat.lat ) + * ``` + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + getLngLat(): LngLat { + return this._lngLat; + } + + /** + * Set the marker's geographical position and move it. + * @param lnglat - A {@link LngLat} describing where the marker should be located. + * @returns `this` + * @example + * Create a new marker, set the longitude and latitude, and add it to the map + * ```ts + * new maplibregl.Marker() + * .setLngLat([-65.017, -16.457]) + * .addTo(map); + * ``` + * @see [Add custom icons with Markers](https://maplibre.org/maplibre-gl-js/docs/examples/custom-marker-icons/) + * @see [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/) + */ + setLngLat(lnglat: LngLatLike): this { + this._lngLat = LngLat.convert(lnglat); + this._pos = null; + if (this._popup) this._popup.setLngLat(this._lngLat); + this._update(); + return this; + } + + /** + * Returns the `Marker`'s HTML element. + * @returns element + */ + getElement(): HTMLElement { + return this._element; + } + + /** + * Binds a {@link Popup} to the {@link Marker}. + * @param popup - An instance of the {@link Popup} class. If undefined or null, any popup + * set on this {@link Marker} instance is unset. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) // add popup + * .addTo(map); + * ``` + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + */ + setPopup(popup?: Popup | null): this { + if (this._popup) { + this._popup.remove(); + this._popup = null; + this._element.removeEventListener('keypress', this._onKeyPress); + + if (!this._originalTabIndex) { + this._element.removeAttribute('tabindex'); + } + } + + if (popup) { + if (!('offset' in popup.options)) { + const markerHeight = 41 - (5.8 / 2); + const markerRadius = 13.5; + const linearOffset = Math.abs(markerRadius) / Math.SQRT2; + popup.options.offset = this._defaultMarker ? { + 'top': [0, 0], + 'top-left': [0, 0], + 'top-right': [0, 0], + 'bottom': [0, -markerHeight], + 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + 'left': [markerRadius, (markerHeight - markerRadius) * -1], + 'right': [-markerRadius, (markerHeight - markerRadius) * -1] + } as Offset : this._offset; + } + this._popup = popup; + if (this._lngLat) this._popup.setLngLat(this._lngLat); + + this._originalTabIndex = this._element.getAttribute('tabindex'); + if (!this._originalTabIndex) { + this._element.setAttribute('tabindex', '0'); + } + this._element.addEventListener('keypress', this._onKeyPress); + } + + return this; + } + + _onKeyPress = (e: KeyboardEvent) => { + const code = e.code; + const legacyCode = e.charCode || e.keyCode; + + if ( + (code === 'Space') || (code === 'Enter') || + (legacyCode === 32) || (legacyCode === 13) // space or enter + ) { + this.togglePopup(); + } + }; + + _onMapClick = (e: MapMouseEvent) => { + const targetElement = e.originalEvent.target; + const element = this._element; + + if (this._popup && (targetElement === element || element.contains(targetElement as any))) { + this.togglePopup(); + } + }; + + /** + * Returns the {@link Popup} instance that is bound to the {@link Marker}. + * @returns popup + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * console.log(marker.getPopup()); // return the popup instance + * ``` + */ + getPopup(): Popup { + return this._popup; + } + + /** + * Opens or closes the {@link Popup} instance that is bound to the {@link Marker}, depending on the current state of the {@link Popup}. + * @returns `this` + * @example + * ```ts + * let marker = new maplibregl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new maplibregl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * marker.togglePopup(); // toggle popup open or closed + * ``` + */ + togglePopup(): this { + const popup = this._popup; + + if (!popup) return this; + else if (popup.isOpen()) popup.remove(); + else popup.addTo(this._map); + return this; + } + + _update = (e?: { type: 'move' | 'moveend' | 'terrain' | 'render' }) => { + if (!this._map) return; + + const isFullyLoaded = this._map.loaded() && !this._map.isMoving(); + if (e?.type === 'terrain' || (e?.type === 'render' && !isFullyLoaded)) { + this._map.once('render', this._update); + } + + if (this._map.transform.renderWorldCopies) { + this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform); + } + + this._pos = this._map.project(this._lngLat)._add(this._offset); + + let rotation = ''; + if (this._rotationAlignment === 'viewport' || this._rotationAlignment === 'auto') { + rotation = `rotateZ(${this._rotation}deg)`; + } else if (this._rotationAlignment === 'map') { + rotation = `rotateZ(${this._rotation - this._map.getBearing()}deg)`; + } + + let pitch = ''; + if (this._pitchAlignment === 'viewport' || this._pitchAlignment === 'auto') { + pitch = 'rotateX(0deg)'; + } else if (this._pitchAlignment === 'map') { + pitch = `rotateX(${this._map.getPitch()}deg)`; + } + + // because rounding the coordinates at every `move` event causes stuttered zooming + // we only round them when _update is called with `moveend` or when its called with + // no arguments (when the Marker is initialized or Marker#setLngLat is invoked). + if (!e || e.type === 'moveend') { + this._pos = this._pos.round(); + } + + DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`); + + // in case of 3D, ask the terrain coords-framebuffer for this pos and check if the marker is visible + // call this logic in setTimeout with a timeout of 100ms to save performance in map-movement + if (this._map.terrain && !this._opacityTimeout) this._opacityTimeout = setTimeout(() => { + const lnglat = this._map.unproject(this._pos); + const metresPerPixel = 40075016.686 * Math.abs(Math.cos(this._lngLat.lat * Math.PI / 180)) / Math.pow(2, this._map.transform.tileZoom + 8); + this._element.style.opacity = lnglat.distanceTo(this._lngLat) > metresPerPixel * 20 ? '0.2' : '1.0'; + this._opacityTimeout = null; + }, 100); + }; + + /** + * Get the marker's offset. + * @returns The marker's screen coordinates in pixels. + */ + getOffset(): Point { + return this._offset; + } + + /** + * Sets the offset of the marker + * @param offset - The offset in pixels as a {@link PointLike} object to apply relative to the element's center. Negatives indicate left and up. + * @returns `this` + */ + setOffset(offset: PointLike): this { + this._offset = Point.convert(offset); + this._update(); + return this; + } + + /** + * Adds a CSS class to the marker element. + * + * @param className - on-empty string with CSS class name to add to marker element + * + * @example + * ``` + * let marker = new maplibregl.Marker() + * marker.addClassName('some-class') + * ``` + */ + addClassName(className: string) { + this._element.classList.add(className); + } + + /** + * Removes a CSS class from the marker element. + * + * @param className - Non-empty string with CSS class name to remove from marker element + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * marker.removeClassName('some-class') + * ``` + */ + removeClassName(className: string) { + this._element.classList.remove(className); + } + + /** + * Add or remove the given CSS class on the marker element, depending on whether the element currently has that class. + * + * @param className - Non-empty string with CSS class name to add/remove + * + * @returns if the class was removed return false, if class was added, then return true + * + * @example + * ```ts + * let marker = new maplibregl.Marker() + * marker.toggleClassName('toggleClass') + * ``` + */ + toggleClassName(className: string): boolean { + return this._element.classList.toggle(className); + } + + _onMove = (e: MapMouseEvent | MapTouchEvent) => { + if (!this._isDragging) { + const clickTolerance = this._clickTolerance || this._map._clickTolerance; + this._isDragging = e.point.dist(this._pointerdownPos) >= clickTolerance; + } + if (!this._isDragging) return; + + this._pos = e.point.sub(this._positionDelta); + this._lngLat = this._map.unproject(this._pos); + this.setLngLat(this._lngLat); + // suppress click event so that popups don't toggle on drag + this._element.style.pointerEvents = 'none'; + + // make sure dragstart only fires on the first move event after mousedown. + // this can't be on mousedown because that event doesn't necessarily + // imply that a drag is about to happen. + if (this._state === 'pending') { + this._state = 'active'; + this.fire(new Event('dragstart')); + } + this.fire(new Event('drag')); + }; + + _onUp = () => { + // revert to normal pointer event handling + this._element.style.pointerEvents = 'auto'; + this._positionDelta = null; + this._pointerdownPos = null; + this._isDragging = false; + this._map.off('mousemove', this._onMove); + this._map.off('touchmove', this._onMove); + + // only fire dragend if it was preceded by at least one drag event + if (this._state === 'active') { + this.fire(new Event('dragend')); + } + + this._state = 'inactive'; + }; + + _addDragHandler = (e: MapMouseEvent | MapTouchEvent) => { + if (this._element.contains(e.originalEvent.target as any)) { + e.preventDefault(); + + // We need to calculate the pixel distance between the click point + // and the marker position, with the offset accounted for. Then we + // can subtract this distance from the mousemove event's position + // to calculate the new marker position. + // If we don't do this, the marker 'jumps' to the click position + // creating a jarring UX effect. + this._positionDelta = e.point.sub(this._pos).add(this._offset); + + this._pointerdownPos = e.point; + + this._state = 'pending'; + this._map.on('mousemove', this._onMove); + this._map.on('touchmove', this._onMove); + this._map.once('mouseup', this._onUp); + this._map.once('touchend', this._onUp); + } + }; + + /** + * Sets the `draggable` property and functionality of the marker + * @param shouldBeDraggable - Turns drag functionality on/off + * @returns `this` + */ + setDraggable(shouldBeDraggable?: boolean): this { + this._draggable = !!shouldBeDraggable; // convert possible undefined value to false + + // handle case where map may not exist yet + // e.g. when setDraggable is called before addTo + if (this._map) { + if (shouldBeDraggable) { + this._map.on('mousedown', this._addDragHandler); + this._map.on('touchstart', this._addDragHandler); + } else { + this._map.off('mousedown', this._addDragHandler); + this._map.off('touchstart', this._addDragHandler); + } + } + + return this; + } + + /** + * Returns true if the marker can be dragged + * @returns True if the marker is draggable. + */ + isDraggable(): boolean { + return this._draggable; + } + + /** + * Sets the `rotation` property of the marker. + * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker#setRotationAlignment} setting. + * @returns `this` + */ + setRotation(rotation?: number): this { + this._rotation = rotation || 0; + this._update(); + return this; + } + + /** + * Returns the current rotation angle of the marker (in degrees). + * @returns The current rotation angle of the marker. + */ + getRotation(): number { + return this._rotation; + } + + /** + * Sets the `rotationAlignment` property of the marker. + * @param alignment - Sets the `rotationAlignment` property of the marker. defaults to 'auto' + * @returns `this` + */ + setRotationAlignment(alignment?: Alignment): this { + this._rotationAlignment = alignment || 'auto'; + this._update(); + return this; + } + + /** + * Returns the current `rotationAlignment` property of the marker. + * @returns The current rotational alignment of the marker. + */ + getRotationAlignment(): Alignment { + return this._rotationAlignment; + } + + /** + * Sets the `pitchAlignment` property of the marker. + * @param alignment - Sets the `pitchAlignment` property of the marker. If alignment is 'auto', it will automatically match `rotationAlignment`. + * @returns `this` + */ + setPitchAlignment(alignment?: Alignment): this { + this._pitchAlignment = alignment && alignment !== 'auto' ? alignment : this._rotationAlignment; + this._update(); + return this; + } + + /** + * Returns the current `pitchAlignment` property of the marker. + * @returns The current pitch alignment of the marker in degrees. + */ + getPitchAlignment(): Alignment { + return this._pitchAlignment; + } +} diff --git a/web/libraries/maplibre-gl/src/ui/popup.test.ts b/web/libraries/maplibre-gl/src/ui/popup.test.ts new file mode 100644 index 00000000..e7ea468e --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/popup.test.ts @@ -0,0 +1,738 @@ +import {createMap as globalCreateMap, beforeMapTest} from '../util/test/util'; +import {Popup, Offset} from './popup'; +import {LngLat} from '../geo/lng_lat'; +import Point from '@mapbox/point-geometry'; +import simulate from '../../test/unit/lib/simulate_interaction'; +import {PositionAnchor} from './anchor'; + +const containerWidth = 512; +const containerHeight = 512; + +function createMap(options?) { + options = options || {}; + const container = window.document.createElement('div'); + window.document.body.appendChild(container); + Object.defineProperty(container, 'clientWidth', {value: options.width || containerWidth}); + Object.defineProperty(container, 'clientHeight', {value: options.height || containerHeight}); + return globalCreateMap({container}); +} + +beforeEach(() => { + beforeMapTest(); +}); + +describe('popup', () => { + + test('Popup#getElement returns a .maplibregl-popup element', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + expect(popup.isOpen()).toBeTruthy(); + expect(popup.getElement().classList.contains('maplibregl-popup')).toBeTruthy(); + }); + + test('Popup#addTo adds a .maplibregl-popup element', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + expect(popup.isOpen()).toBeTruthy(); + expect(map.getContainer().querySelectorAll('.maplibregl-popup')).toHaveLength(1); + }); + + test('Popup closes on map click events by default', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + simulate.click(map.getCanvas()); + + expect(!popup.isOpen()).toBeTruthy(); + }); + + test('Popup does not close on map click events when the closeOnClick option is false', () => { + const map = createMap(); + const popup = new Popup({closeOnClick: false}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + simulate.click(map.getCanvas()); + + expect(popup.isOpen()).toBeTruthy(); + }); + + test('Popup closes on close button click events', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + simulate.click(map.getContainer().querySelector('.maplibregl-popup-close-button')); + + expect(!popup.isOpen()).toBeTruthy(); + }); + + test('Popup has no close button if closeButton option is false', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + expect( + popup.getElement().querySelectorAll('.maplibregl-popup-close-button') + ).toHaveLength(0); + }); + + test('Popup does not close on map move events when the closeOnMove option is false', () => { + const map = createMap(); + const popup = new Popup({closeOnMove: false}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + map.setCenter([-10, 0]); // longitude bounds: [-370, 350] + + expect(popup.isOpen()).toBeTruthy(); + }); + + test('Popup closes on map move events when the closeOnMove option is true', () => { + const map = createMap(); + const popup = new Popup({closeOnMove: true}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + map.setCenter([-10, 0]); // longitude bounds: [-370, 350] + + expect(!popup.isOpen()).toBeTruthy(); + }); + + test('Popup fires close event when removed', () => { + const map = createMap(); + const onClose = jest.fn(); + + new Popup() + .setText('Test') + .setLngLat([0, 0]) + .on('close', onClose) + .addTo(map) + .remove(); + + expect(onClose).toHaveBeenCalled(); + }); + + test('Popup fires open event when added', () => { + const map = createMap(); + const onOpen = jest.fn(); + + new Popup() + .setText('Test') + .setLngLat([0, 0]) + .on('open', onOpen) + .addTo(map); + + expect(onOpen).toHaveBeenCalled(); + }); + + test('Popup content can be set via setText', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .addTo(map) + .setText('Test'); + + expect(popup.getElement().textContent).toBe('Test'); + }); + + test('Popup content can be set via setHTML', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .addTo(map) + .setHTML('Test'); + + expect(popup.getElement().querySelector('.maplibregl-popup-content').innerHTML).toBe('Test'); + }); + + test('Popup width maximum defaults to 240px', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .addTo(map) + .setHTML('Test'); + + expect(popup.getMaxWidth()).toBe('240px'); + }); + + test('Popup width maximum can be set via using maxWidth option', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false, maxWidth: '5px'}) + .setLngLat([0, 0]) + .addTo(map) + .setHTML('Test'); + + expect(popup.getMaxWidth()).toBe('5px'); + }); + + test('Popup width maximum can be set via maxWidth', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .setHTML('Test') + .setMaxWidth('5px') + .addTo(map); + + expect(popup.getMaxWidth()).toBe('5px'); + }); + + test('Popup content can be set via setDOMContent', () => { + const map = createMap(); + const content = window.document.createElement('span'); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .addTo(map) + .setDOMContent(content); + + expect(popup.getElement().querySelector('.maplibregl-popup-content').firstChild).toBe(content); + }); + + test('Popup#setText protects against XSS', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .addTo(map) + .setText(''); + + expect(popup.getElement().textContent).toBe(''); + }); + + test('Popup content setters overwrite previous content', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setLngLat([0, 0]) + .addTo(map); + + popup.setText('Test 1'); + expect(popup.getElement().textContent).toBe('Test 1'); + + popup.setHTML('Test 2'); + expect(popup.getElement().textContent).toBe('Test 2'); + + popup.setDOMContent(window.document.createTextNode('Test 3')); + expect(popup.getElement().textContent).toBe('Test 3'); + + }); + + test('Popup provides LngLat accessors', () => { + expect(new Popup().getLngLat()).toBeUndefined(); + + expect(new Popup().setLngLat([1, 2]).getLngLat() instanceof LngLat).toBeTruthy(); + expect(new Popup().setLngLat([1, 2]).getLngLat()).toEqual(new LngLat(1, 2)); + + expect(new Popup().setLngLat(new LngLat(1, 2)).getLngLat() instanceof LngLat).toBeTruthy(); + expect(new Popup().setLngLat(new LngLat(1, 2)).getLngLat()).toEqual(new LngLat(1, 2)); + + }); + + test('Popup is positioned at the specified LngLat in a world copy', () => { + const map = createMap({width: 1024}); // longitude bounds: [-360, 360] + + const popup = new Popup() + .setLngLat([270, 0]) + .setText('Test') + .addTo(map); + + expect(popup._pos).toEqual(map.project([270, 0])); + }); + + test('Popup preserves object constancy of position after map move', () => { + const map = createMap({width: 1024}); // longitude bounds: [-360, 360] + + const popup = new Popup() + .setLngLat([270, 0]) + .setText('Test') + .addTo(map); + + map.setCenter([-10, 0]); // longitude bounds: [-370, 350] + expect(popup._pos).toEqual(map.project([270, 0])); + + map.setCenter([-20, 0]); // longitude bounds: [-380, 340] + expect(popup._pos).toEqual(map.project([270, 0])); + + }); + + test('Popup preserves object constancy of position after auto-wrapping center (left)', () => { + const map = createMap({width: 1024}); + map.setCenter([-175, 0]); // longitude bounds: [-535, 185] + + const popup = new Popup() + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + map.setCenter([175, 0]); // longitude bounds: [-185, 535] + expect(popup._pos).toEqual(map.project([360, 0])); + + }); + + test('Popup preserves object constancy of position after auto-wrapping center (right)', () => { + const map = createMap({width: 1024}); + map.setCenter([175, 0]); // longitude bounds: [-185, 535] + + const popup = new Popup() + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + map.setCenter([-175, 0]); // longitude bounds: [-185, 535] + expect(popup._pos).toEqual(map.project([-360, 0])); + + }); + + test('Popup wraps position after map move if it would otherwise go offscreen (right)', () => { + const map = createMap({width: 1024}); // longitude bounds: [-360, 360] + + const popup = new Popup() + .setLngLat([-355, 0]) + .setText('Test') + .addTo(map); + + map.setCenter([10, 0]); // longitude bounds: [-350, 370] + expect(popup._pos).toEqual(map.project([5, 0])); + }); + + test('Popup wraps position after map move if it would otherwise go offscreen (right)', () => { + const map = createMap({width: 1024}); // longitude bounds: [-360, 360] + + const popup = new Popup() + .setLngLat([355, 0]) + .setText('Test') + .addTo(map); + + map.setCenter([-10, 0]); // longitude bounds: [-370, 350] + expect(popup._pos).toEqual(map.project([-5, 0])); + }); + + test('Popup is repositioned at the specified LngLat', () => { + const map = createMap({width: 1024}); // longitude bounds: [-360, 360] + + const popup = new Popup() + .setLngLat([270, 0]) + .setText('Test') + .addTo(map) + .setLngLat([0, 0]); + + expect(popup._pos).toEqual(map.project([0, 0])); + }); + + test('Popup anchors as specified by the anchor option', () => { + const map = createMap(); + const popup = new Popup({anchor: 'top-left'}) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + expect(popup.getElement().classList.contains('maplibregl-popup-anchor-top-left')).toBeTruthy(); + }); + + ([ + ['top-left', new Point(10, 10), 'translate(0,0) translate(7px,7px)'], + ['top', new Point(containerWidth / 2, 10), 'translate(-50%,0) translate(0px,10px)'], + ['top-right', new Point(containerWidth - 10, 10), 'translate(-100%,0) translate(-7px,7px)'], + ['right', new Point(containerWidth - 10, containerHeight / 2), 'translate(-100%,-50%) translate(-10px,0px)'], + ['bottom-right', new Point(containerWidth - 10, containerHeight - 10), 'translate(-100%,-100%) translate(-7px,-7px)'], + ['bottom', new Point(containerWidth / 2, containerHeight - 10), 'translate(-50%,-100%) translate(0px,-10px)'], + ['bottom-left', new Point(10, containerHeight - 10), 'translate(0,-100%) translate(7px,-7px)'], + ['left', new Point(10, containerHeight / 2), 'translate(0,-50%) translate(10px,0px)'], + ['bottom', new Point(containerWidth / 2, containerHeight / 2), 'translate(-50%,-100%) translate(0px,-10px)'] + ] as [PositionAnchor, Point, string][]).forEach((args) => { + const anchor = args[0]; + const point = args[1]; + const transform = args[2]; + + test(`Popup automatically anchors to ${anchor}`, () => { + const map = createMap(); + const popup = new Popup() + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + Object.defineProperty(popup.getElement(), 'offsetWidth', {value: 100}); + Object.defineProperty(popup.getElement(), 'offsetHeight', {value: 100}); + + jest.spyOn(map, 'project').mockReturnValue(point); + popup.setLngLat([0, 0]); + + expect(popup.getElement().classList.contains(`maplibregl-popup-anchor-${anchor}`)).toBeTruthy(); + }); + + test(`Popup translation reflects offset and ${anchor} anchor`, () => { + const map = createMap(); + jest.spyOn(map, 'project').mockReturnValue(new Point(0, 0)); + + const popup = new Popup({anchor, offset: 10}) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + expect(popup.getElement().style.transform).toBe(transform); + }); + }); + + test('Popup automatically anchors to top if its bottom offset would push it off-screen', () => { + const map = createMap(); + const point = new Point(containerWidth / 2, containerHeight / 2); + const options = {offset: { + 'bottom': [0, -25], + 'top': [0, 0] + } as Offset}; + const popup = new Popup(options) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + Object.defineProperty(popup.getElement(), 'offsetWidth', {value: containerWidth / 2}); + Object.defineProperty(popup.getElement(), 'offsetHeight', {value: containerHeight / 2}); + + jest.spyOn(map, 'project').mockReturnValue(point); + popup.setLngLat([0, 0]); + + expect(popup.getElement().classList.contains('maplibregl-popup-anchor-top')).toBeTruthy(); + }); + + test('Popup is offset via a PointLike offset option', () => { + const map = createMap(); + jest.spyOn(map, 'project').mockReturnValue(new Point(0, 0)); + + const popup = new Popup({anchor: 'top-left', offset: [5, 10]}) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + expect(popup.getElement().style.transform).toBe('translate(0,0) translate(5px,10px)'); + }); + + test('Popup is offset via an object offset option', () => { + const map = createMap(); + jest.spyOn(map, 'project').mockReturnValue(new Point(0, 0)); + + const popup = new Popup({anchor: 'top-left', offset: {'top-left': [5, 10]} as Offset}) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + expect(popup.getElement().style.transform).toBe('translate(0,0) translate(5px,10px)'); + }); + + test('Popup is offset via an incomplete object offset option', () => { + const map = createMap(); + jest.spyOn(map, 'project').mockReturnValue(new Point(0, 0)); + + const popup = new Popup({anchor: 'top-right', offset: {'top-left': [5, 10]} as Offset}) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + expect(popup.getElement().style.transform).toBe('translate(-100%,0) translate(0px,0px)'); + }); + + test('Popup offset can be set via setOffset', () => { + const map = createMap(); + + const popup = new Popup({offset: 5}) + .setLngLat([0, 0]) + .setText('Test') + .addTo(map); + + expect(popup.options.offset).toBe(5); + + popup.setOffset(10); + + expect(popup.options.offset).toBe(10); + }); + + test('Popup can be removed and added again (#1477)', () => { + const map = createMap(); + + new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map) + .remove() + .addTo(map); + + expect(map.getContainer().querySelectorAll('.maplibregl-popup')).toHaveLength(1); + }); + + test('Popup#addTo is idempotent (#1811)', () => { + const map = createMap(); + + const popup = new Popup({closeButton: false}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map) + .addTo(map); + + expect(popup.getElement().querySelector('.maplibregl-popup-content').textContent).toBe('Test'); + }); + + test('Popup#remove is idempotent (#2395)', () => { + const map = createMap(); + + new Popup({closeButton: false}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map) + .remove() + .remove(); + + expect(map.getContainer().querySelectorAll('.maplibregl-popup')).toHaveLength(0); + }); + + test('Popup adds classes from className option, methods for class manipulations works properly', () => { + const map = createMap(); + const popup = new Popup({className: 'some classes'}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + const popupContainer = popup.getElement(); + expect(popupContainer.classList.contains('some')).toBeTruthy(); + expect(popupContainer.classList.contains('classes')).toBeTruthy(); + + popup.addClassName('addedClass'); + expect(popupContainer.classList.contains('addedClass')).toBeTruthy(); + + popup.removeClassName('addedClass'); + expect(!popupContainer.classList.contains('addedClass')).toBeTruthy(); + + popup.toggleClassName('toggle'); + expect(popupContainer.classList.contains('toggle')).toBeTruthy(); + + popup.toggleClassName('toggle'); + expect(!popupContainer.classList.contains('toggle')).toBeTruthy(); + + expect(() => popup.addClassName('should throw exception')).toThrow(window.DOMException); + expect(() => popup.removeClassName('should throw exception')).toThrow(window.DOMException); + expect(() => popup.toggleClassName('should throw exception')).toThrow(window.DOMException); + + expect(() => popup.addClassName('')).toThrow(window.DOMException); + expect(() => popup.removeClassName('')).toThrow(window.DOMException); + expect(() => popup.toggleClassName('')).toThrow(window.DOMException); + + }); + + test('Cursor-tracked popup disappears on mouseout', () => { + const map = createMap(); + + const popup = new Popup() + .setText('Test') + .trackPointer() + .addTo(map); + + expect(popup._trackPointer).toBe(true); + }); + + test('Pointer-tracked popup is tagged with right class', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .trackPointer() + .addTo(map); + + expect( + popup._container.classList.value + ).toContain('maplibregl-popup-track-pointer'); + }); + + test('Pointer-tracked popup with content set later is tagged with right class ', () => { + const map = createMap(); + const popup = new Popup() + .trackPointer() + .addTo(map); + + popup.setText('Test'); + + expect( + popup._container.classList.value + ).toContain('maplibregl-popup-track-pointer'); + }); + + test('Pointer-tracked popup that is set afterwards is tagged with right class ', () => { + const map = createMap(); + const popup = new Popup() + .addTo(map); + + popup.setText('Test'); + popup.trackPointer(); + + expect( + popup._container.classList.value + ).toContain('maplibregl-popup-track-pointer'); + }); + + test('Pointer-tracked popup can be repositioned with setLngLat', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .trackPointer() + .setLngLat([0, 0]) + .addTo(map); + + expect(popup._pos).toEqual(map.project([0, 0])); + expect( + popup._container.classList.value + ).not.toContain('maplibregl-popup-track-pointer'); + }); + + test('Positioned popup lacks pointer-tracking class', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + expect( + popup._container.classList.value + ).not.toContain('maplibregl-popup-track-pointer'); + }); + + test('Positioned popup can be set to track pointer', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .trackPointer() + .addTo(map); + + simulate.mousemove(map.getCanvas(), {screenX: 0, screenY: 0}); + expect(popup._pos).toEqual({x: 0, y: 0}); + }); + + test('Popup closes on Map#remove', () => { + const map = createMap(); + const popup = new Popup() + .setText('Test') + .setLngLat([0, 0]) + .addTo(map); + + map.remove(); + + expect(!popup.isOpen()).toBeTruthy(); + }); + + test('Adding popup with no focusable content (Popup#setText) does not change the active element', () => { + const dummyFocusedEl = window.document.createElement('button'); + window.document.body.appendChild(dummyFocusedEl); + dummyFocusedEl.focus(); + + new Popup({closeButton: false}) + .setText('Test') + .setLngLat([0, 0]) + .addTo(createMap()); + + expect(window.document.activeElement).toBe(dummyFocusedEl); + }); + + test('Adding popup with no focusable content (Popup#setHTML) does not change the active element', () => { + const dummyFocusedEl = window.document.createElement('button'); + window.document.body.appendChild(dummyFocusedEl); + dummyFocusedEl.focus(); + + new Popup({closeButton: false}) + .setHTML('Test') + .setLngLat([0, 0]) + .addTo(createMap()); + + expect(window.document.activeElement).toBe(dummyFocusedEl); + }); + + test('Close button is focused if it is the only focusable element', () => { + const dummyFocusedEl = window.document.createElement('button'); + window.document.body.appendChild(dummyFocusedEl); + dummyFocusedEl.focus(); + + const popup = new Popup({closeButton: true}) + .setHTML('Test') + .setLngLat([0, 0]) + .addTo(createMap()); + + // Suboptimal because the string matching is case-sensitive + const closeButton = popup._container.querySelector('[aria-label^=\'Close\']'); + + expect(window.document.activeElement).toBe(closeButton); + }); + + test('If popup content contains a focusable element it is focused', () => { + const popup = new Popup({closeButton: true}) + .setHTML('Test') + .setLngLat([0, 0]) + .addTo(createMap()); + + const focusableEl = popup._container.querySelector('[data-testid=\'abc\']'); + + expect(window.document.activeElement).toBe(focusableEl); + }); + + test('Element with tabindex="-1" is not focused', () => { + const popup = new Popup({closeButton: true}) + .setHTML('Test') + .setLngLat([0, 0]) + .addTo(createMap()); + + const nonFocusableEl = popup._container.querySelector('[data-testid=\'abc\']'); + const closeButton = popup._container.querySelector('button[aria-label=\'Close popup\']'); + + expect(window.document.activeElement).not.toBe(nonFocusableEl); + expect(window.document.activeElement).toBe(closeButton); + }); + + test('If popup contains a disabled button and a focusable element then the latter is focused', () => { + const popup = new Popup({closeButton: true}) + .setHTML(` + + + `) + .setLngLat([0, 0]) + .addTo(createMap()); + + const focusableEl = popup._container.querySelector('[data-testid=\'abc\']'); + + expect(window.document.activeElement).toBe(focusableEl); + }); + + test('Popup with disabled focusing does not change the active element', () => { + const dummyFocusedEl = window.document.createElement('button'); + window.document.body.appendChild(dummyFocusedEl); + dummyFocusedEl.focus(); + + new Popup({closeButton: false, focusAfterOpen: false}) + .setHTML('Test') + .setLngLat([0, 0]) + .addTo(createMap()); + + expect(window.document.activeElement).toBe(dummyFocusedEl); + }); +}); diff --git a/web/libraries/maplibre-gl/src/ui/popup.ts b/web/libraries/maplibre-gl/src/ui/popup.ts new file mode 100644 index 00000000..e93b4916 --- /dev/null +++ b/web/libraries/maplibre-gl/src/ui/popup.ts @@ -0,0 +1,672 @@ +import {extend} from '../util/util'; +import {Event, Evented} from '../util/evented'; +import {MapMouseEvent} from '../ui/events'; +import {DOM} from '../util/dom'; +import {LngLat} from '../geo/lng_lat'; +import Point from '@mapbox/point-geometry'; +import {smartWrap} from '../util/smart_wrap'; +import {anchorTranslate, applyAnchorClass} from './anchor'; + +import type {PositionAnchor} from './anchor'; +import type {Map} from './map'; +import type {LngLatLike} from '../geo/lng_lat'; +import type {PointLike} from './camera'; + +const defaultOptions = { + closeButton: true, + closeOnClick: true, + focusAfterOpen: true, + className: '', + maxWidth: '240px' +}; + +/** + * A pixel offset specified as: + * - a single number specifying a distance from the location + * - a {@link PointLike} specifying a constant offset + * - an object of {@link Point}s specifying an offset for each anchor position + * Negative offsets indicate left and up. + */ +export type Offset = number | PointLike | { + [_ in PositionAnchor]: PointLike; +}; + +export type PopupOptions = { + /** + * If `true`, a close button will appear in the top right corner of the popup. + * @defaultValue true + */ + closeButton?: boolean; + /** + * If `true`, the popup will closed when the map is clicked. + * @defaultValue true + */ + closeOnClick?: boolean; + /** + * If `true`, the popup will closed when the map moves. + * @defaultValue false + */ + closeOnMove?: boolean; + /** + * If `true`, the popup will try to focus the first focusable element inside the popup. + * @defaultValue true + */ + focusAfterOpen?: boolean; + /** + * A string indicating the part of the Popup that should + * be positioned closest to the coordinate set via {@link Popup#setLngLat}. + * Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, + * `'top-right'`, `'bottom-left'`, and `'bottom-right'`. If unset the anchor will be + * dynamically set to ensure the popup falls within the map container with a preference + * for `'bottom'`. + */ + anchor?: PositionAnchor; + /** + * A pixel offset applied to the popup's location + */ + offset?: Offset; + /** + * Space-separated CSS class names to add to popup container + */ + className?: string; + /** + * A string that sets the CSS property of the popup's maximum width, eg `'300px'`. + * To ensure the popup resizes to fit its content, set this property to `'none'`. + * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width + * @defaultValue '240px' + */ + maxWidth?: string; +}; + +const focusQuerySelector = [ + 'a[href]', + '[tabindex]:not([tabindex=\'-1\'])', + '[contenteditable]:not([contenteditable=\'false\'])', + 'button:not([disabled])', + 'input:not([disabled])', + 'select:not([disabled])', + 'textarea:not([disabled])', +].join(', '); + +/** + * A popup component. + * + * @group Markers and Controls + * + * + * @example + * Create a popup + * ```ts + * let popup = new maplibregl.Popup(); + * // Set an event listener that will fire + * // any time the popup is opened + * popup.on('open', function(){ + * console.log('popup was opened'); + * }); + * ``` + * + * @example + * Create a popup + * ```ts + * let popup = new maplibregl.Popup(); + * // Set an event listener that will fire + * // any time the popup is closed + * popup.on('close', function(){ + * console.log('popup was closed'); + * }); + * ``` + * + * @example + * ```ts + * let markerHeight = 50, markerRadius = 10, linearOffset = 25; + * let popupOffsets = { + * 'top': [0, 0], + * 'top-left': [0,0], + * 'top-right': [0,0], + * 'bottom': [0, -markerHeight], + * 'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + * 'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1], + * 'left': [markerRadius, (markerHeight - markerRadius) * -1], + * 'right': [-markerRadius, (markerHeight - markerRadius) * -1] + * }; + * let popup = new maplibregl.Popup({offset: popupOffsets, className: 'my-class'}) + * .setLngLat(e.lngLat) + * .setHTML("

Hello World!

") + * .setMaxWidth("300px") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + * + * ### Events + * + * @event `open` Fired when the popup is opened manually or programmatically. `popup` object that was opened + * + * @event `close` Fired when the popup is closed manually or programmatically. `popup` object that was closed + */ +export class Popup extends Evented { + _map: Map; + options: PopupOptions; + _content: HTMLElement; + _container: HTMLElement; + _closeButton: HTMLButtonElement; + _tip: HTMLElement; + _lngLat: LngLat; + _trackPointer: boolean; + _pos: Point; + + constructor(options?: PopupOptions) { + super(); + this.options = extend(Object.create(defaultOptions), options); + } + + /** + * Adds the popup to a map. + * + * @param map - The MapLibre GL JS map to add the popup to. + * @returns `this` + * @example + * ```ts + * new maplibregl.Popup() + * .setLngLat([0, 0]) + * .setHTML("

Null Island

") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Show polygon information on click](https://maplibre.org/maplibre-gl-js/docs/examples/polygon-popup-on-click/) + */ + addTo(map: Map): this { + if (this._map) this.remove(); + + this._map = map; + if (this.options.closeOnClick) { + this._map.on('click', this._onClose); + } + + if (this.options.closeOnMove) { + this._map.on('move', this._onClose); + } + + this._map.on('remove', this.remove); + this._update(); + this._focusFirstElement(); + + if (this._trackPointer) { + this._map.on('mousemove', this._onMouseMove); + this._map.on('mouseup', this._onMouseUp); + if (this._container) { + this._container.classList.add('maplibregl-popup-track-pointer'); + } + this._map._canvasContainer.classList.add('maplibregl-track-pointer'); + } else { + this._map.on('move', this._update); + } + + this.fire(new Event('open')); + + return this; + } + + /** + * @returns `true` if the popup is open, `false` if it is closed. + */ + isOpen() { + return !!this._map; + } + + /** + * Removes the popup from the map it has been added to. + * + * @example + * ```ts + * let popup = new maplibregl.Popup().addTo(map); + * popup.remove(); + * ``` + * @returns `this` + */ + remove = (): this => { + if (this._content) { + DOM.remove(this._content); + } + + if (this._container) { + DOM.remove(this._container); + delete this._container; + } + + if (this._map) { + this._map.off('move', this._update); + this._map.off('move', this._onClose); + this._map.off('click', this._onClose); + this._map.off('remove', this.remove); + this._map.off('mousemove', this._onMouseMove); + this._map.off('mouseup', this._onMouseUp); + this._map.off('drag', this._onDrag); + delete this._map; + } + + this.fire(new Event('close')); + + return this; + }; + + /** + * Returns the geographical location of the popup's anchor. + * + * The longitude of the result may differ by a multiple of 360 degrees from the longitude previously + * set by `setLngLat` because `Popup` wraps the anchor longitude across copies of the world to keep + * the popup on screen. + * + * @returns The geographical location of the popup's anchor. + */ + getLngLat(): LngLat { + return this._lngLat; + } + + /** + * Sets the geographical location of the popup's anchor, and moves the popup to it. Replaces trackPointer() behavior. + * + * @param lnglat - The geographical location to set as the popup's anchor. + * @returns `this` + */ + setLngLat(lnglat: LngLatLike): this { + this._lngLat = LngLat.convert(lnglat); + this._pos = null; + + this._trackPointer = false; + + this._update(); + + if (this._map) { + this._map.on('move', this._update); + this._map.off('mousemove', this._onMouseMove); + if (this._container) { + this._container.classList.remove('maplibregl-popup-track-pointer'); + } + this._map._canvasContainer.classList.remove('maplibregl-track-pointer'); + } + + return this; + } + + /** + * Tracks the popup anchor to the cursor position on screens with a pointer device (it will be hidden on touchscreens). Replaces the `setLngLat` behavior. + * For most use cases, set `closeOnClick` and `closeButton` to `false`. + * @example + * ```ts + * let popup = new maplibregl.Popup({ closeOnClick: false, closeButton: false }) + * .setHTML("

Hello World!

") + * .trackPointer() + * .addTo(map); + * ``` + * @returns `this` + */ + trackPointer(): this { + this._trackPointer = true; + this._pos = null; + this._update(); + if (this._map) { + this._map.off('move', this._update); + this._map.on('mousemove', this._onMouseMove); + this._map.on('drag', this._onDrag); + if (this._container) { + this._container.classList.add('maplibregl-popup-track-pointer'); + } + this._map._canvasContainer.classList.add('maplibregl-track-pointer'); + } + + return this; + + } + + /** + * Returns the `Popup`'s HTML element. + * @example + * Change the `Popup` element's font size + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat([-96, 37.8]) + * .setHTML("

Hello World!

") + * .addTo(map); + * let popupElem = popup.getElement(); + * popupElem.style.fontSize = "25px"; + * ``` + * @returns element + */ + getElement(): HTMLElement { + return this._container; + } + + /** + * Sets the popup's content to a string of text. + * + * This function creates a [Text](https://developer.mozilla.org/en-US/docs/Web/API/Text) node in the DOM, + * so it cannot insert raw HTML. Use this method for security against XSS + * if the popup content is user-provided. + * + * @param text - Textual content for the popup. + * @returns `this` + * @example + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setText('Hello, world!') + * .addTo(map); + * ``` + */ + setText(text: string): this { + return this.setDOMContent(document.createTextNode(text)); + } + + /** + * Sets the popup's content to the HTML provided as a string. + * + * This method does not perform HTML filtering or sanitization, and must be + * used only with trusted content. Consider {@link Popup#setText} if + * the content is an untrusted text string. + * + * @param html - A string representing HTML content for the popup. + * @returns `this` + * @example + * ```ts + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setHTML("

Hello World!

") + * .addTo(map); + * ``` + * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) + * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/) + * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/) + * @see [Attach a popup to a marker instance](https://maplibre.org/maplibre-gl-js/docs/examples/set-popup/) + */ + setHTML(html: string): this { + const frag = document.createDocumentFragment(); + const temp = document.createElement('body'); + let child; + temp.innerHTML = html; + while (true) { + child = temp.firstChild; + if (!child) break; + frag.appendChild(child); + } + + return this.setDOMContent(frag); + } + + /** + * Returns the popup's maximum width. + * + * @returns The maximum width of the popup. + */ + getMaxWidth(): string { + return this._container?.style.maxWidth; + } + + /** + * Sets the popup's maximum width. This is setting the CSS property `max-width`. + * Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width + * + * @param maxWidth - A string representing the value for the maximum width. + * @returns `this` + */ + setMaxWidth(maxWidth: string): this { + this.options.maxWidth = maxWidth; + this._update(); + return this; + } + + /** + * Sets the popup's content to the element provided as a DOM node. + * + * @param htmlNode - A DOM node to be used as content for the popup. + * @returns `this` + * @example + * Create an element with the popup content + * ```ts + * let div = document.createElement('div'); + * div.innerHTML = 'Hello, world!'; + * let popup = new maplibregl.Popup() + * .setLngLat(e.lngLat) + * .setDOMContent(div) + * .addTo(map); + * ``` + */ + setDOMContent(htmlNode: Node): this { + if (this._content) { + // Clear out children first. + while (this._content.hasChildNodes()) { + if (this._content.firstChild) { + this._content.removeChild(this._content.firstChild); + } + } + } else { + this._content = DOM.create('div', 'maplibregl-popup-content', this._container); + } + + // The close button should be the last tabbable element inside the popup for a good keyboard UX. + this._content.appendChild(htmlNode); + this._createCloseButton(); + this._update(); + this._focusFirstElement(); + return this; + } + + /** + * Adds a CSS class to the popup container element. + * + * @param className - Non-empty string with CSS class name to add to popup container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.addClassName('some-class') + * ``` + */ + addClassName(className: string) { + if (this._container) { + this._container.classList.add(className); + } + } + + /** + * Removes a CSS class from the popup container element. + * + * @param className - Non-empty string with CSS class name to remove from popup container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.removeClassName('some-class') + * ``` + */ + removeClassName(className: string) { + if (this._container) { + this._container.classList.remove(className); + } + } + + /** + * Sets the popup's offset. + * + * @param offset - Sets the popup's offset. + * @returns `this` + */ + setOffset (offset?: Offset): this { + this.options.offset = offset; + this._update(); + return this; + } + + /** + * Add or remove the given CSS class on the popup container, depending on whether the container currently has that class. + * + * @param className - Non-empty string with CSS class name to add/remove + * + * @returns if the class was removed return false, if class was added, then return true, undefined if there is no container + * + * @example + * ```ts + * let popup = new maplibregl.Popup() + * popup.toggleClassName('toggleClass') + * ``` + */ + toggleClassName(className: string): boolean | undefined { + if (this._container) { + return this._container.classList.toggle(className); + } + } + + _createCloseButton() { + if (this.options.closeButton) { + this._closeButton = DOM.create('button', 'maplibregl-popup-close-button', this._content); + this._closeButton.type = 'button'; + this._closeButton.setAttribute('aria-label', 'Close popup'); + this._closeButton.innerHTML = '×'; + this._closeButton.addEventListener('click', this._onClose); + } + } + + _onMouseUp = (event: MapMouseEvent) => { + this._update(event.point); + }; + + _onMouseMove = (event: MapMouseEvent) => { + this._update(event.point); + }; + + _onDrag = (event: MapMouseEvent) => { + this._update(event.point); + }; + + _update = (cursor?: Point) => { + const hasPosition = this._lngLat || this._trackPointer; + + if (!this._map || !hasPosition || !this._content) { return; } + + if (!this._container) { + this._container = DOM.create('div', 'maplibregl-popup', this._map.getContainer()); + this._tip = DOM.create('div', 'maplibregl-popup-tip', this._container); + this._container.appendChild(this._content); + if (this.options.className) { + for (const name of this.options.className.split(' ')) { + this._container.classList.add(name); + } + } + + if (this._trackPointer) { + this._container.classList.add('maplibregl-popup-track-pointer'); + } + } + + if (this.options.maxWidth && this._container.style.maxWidth !== this.options.maxWidth) { + this._container.style.maxWidth = this.options.maxWidth; + } + + if (this._map.transform.renderWorldCopies && !this._trackPointer) { + this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform); + } + + if (this._trackPointer && !cursor) return; + + const pos = this._pos = this._trackPointer && cursor ? cursor : this._map.project(this._lngLat); + + let anchor = this.options.anchor; + const offset = normalizeOffset(this.options.offset); + + if (!anchor) { + const width = this._container.offsetWidth; + const height = this._container.offsetHeight; + let anchorComponents; + + if (pos.y + offset.bottom.y < height) { + anchorComponents = ['top']; + } else if (pos.y > this._map.transform.height - height) { + anchorComponents = ['bottom']; + } else { + anchorComponents = []; + } + + if (pos.x < width / 2) { + anchorComponents.push('left'); + } else if (pos.x > this._map.transform.width - width / 2) { + anchorComponents.push('right'); + } + + if (anchorComponents.length === 0) { + anchor = 'bottom'; + } else { + anchor = (anchorComponents.join('-') as any); + } + } + + const offsetedPos = pos.add(offset[anchor]).round(); + DOM.setTransform(this._container, `${anchorTranslate[anchor]} translate(${offsetedPos.x}px,${offsetedPos.y}px)`); + applyAnchorClass(this._container, anchor, 'popup'); + }; + + _focusFirstElement() { + if (!this.options.focusAfterOpen || !this._container) return; + + const firstFocusable = this._container.querySelector(focusQuerySelector) as HTMLElement; + + if (firstFocusable) firstFocusable.focus(); + } + + _onClose = () => { + this.remove(); + }; +} + +function normalizeOffset(offset?: Offset | null) { + if (!offset) { + return normalizeOffset(new Point(0, 0)); + + } else if (typeof offset === 'number') { + // input specifies a radius from which to calculate offsets at all positions + const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2); + return { + 'center': new Point(0, 0), + 'top': new Point(0, offset), + 'top-left': new Point(cornerOffset, cornerOffset), + 'top-right': new Point(-cornerOffset, cornerOffset), + 'bottom': new Point(0, -offset), + 'bottom-left': new Point(cornerOffset, -cornerOffset), + 'bottom-right': new Point(-cornerOffset, -cornerOffset), + 'left': new Point(offset, 0), + 'right': new Point(-offset, 0) + }; + + } else if (offset instanceof Point || Array.isArray(offset)) { + // input specifies a single offset to be applied to all positions + const convertedOffset = Point.convert(offset); + return { + 'center': convertedOffset, + 'top': convertedOffset, + 'top-left': convertedOffset, + 'top-right': convertedOffset, + 'bottom': convertedOffset, + 'bottom-left': convertedOffset, + 'bottom-right': convertedOffset, + 'left': convertedOffset, + 'right': convertedOffset + }; + + } else { + // input specifies an offset per position + return { + 'center': Point.convert(offset['center'] || [0, 0]), + 'top': Point.convert(offset['top'] || [0, 0]), + 'top-left': Point.convert(offset['top-left'] || [0, 0]), + 'top-right': Point.convert(offset['top-right'] || [0, 0]), + 'bottom': Point.convert(offset['bottom'] || [0, 0]), + 'bottom-left': Point.convert(offset['bottom-left'] || [0, 0]), + 'bottom-right': Point.convert(offset['bottom-right'] || [0, 0]), + 'left': Point.convert(offset['left'] || [0, 0]), + 'right': Point.convert(offset['right'] || [0, 0]) + }; + } +} diff --git a/web/libraries/maplibre-gl/src/util/actor.test.ts b/web/libraries/maplibre-gl/src/util/actor.test.ts new file mode 100644 index 00000000..06ad375d --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/actor.test.ts @@ -0,0 +1,106 @@ +import {Actor, ActorTarget} from './actor'; +import {workerFactory} from './web_worker'; +import {MessageBus} from '../../test/unit/lib/web_worker_mock'; + +const originalWorker = global.Worker; + +function setTestWorker(MockWorker: { new(...args: any): any}) { + (global as any).Worker = function Worker(_: string) { + const parentListeners = []; + const workerListeners = []; + const parentBus = new MessageBus(workerListeners, parentListeners); + const workerBus = new MessageBus(parentListeners, workerListeners); + + parentBus.target = workerBus; + workerBus.target = parentBus; + + new MockWorker(workerBus); + + return parentBus; + }; +} + +describe('Actor', () => { + afterAll(() => { + global.Worker = originalWorker; + }); + + test('forwards responses to correct callback', done => { + setTestWorker(class MockWorker { + self: any; + actor: Actor; + constructor(self) { + this.self = self; + this.actor = new Actor(self, this); + } + getTile(mapId, params, callback) { + setTimeout(callback, 0, null, params); + } + getWorkerSource() { return null; } + }); + + const worker = workerFactory(); + + const m1 = new Actor(worker, {} as any, '1'); + const m2 = new Actor(worker, {} as any, '2'); + + let callbackCount = 0; + m1.send('getTile', {value: 1729}, (err, response) => { + expect(err).toBeFalsy(); + expect(response).toEqual({value: 1729}); + callbackCount++; + if (callbackCount === 2) { + done(); + } + }); + m2.send('getTile', {value: 4104}, (err, response) => { + expect(err).toBeFalsy(); + expect(response).toEqual({value: 4104}); + callbackCount++; + if (callbackCount === 2) { + done(); + } + }); + }); + + test('targets worker-initiated messages to correct map instance', done => { + let workerActor; + + setTestWorker(class MockWorker { + self: any; + actor: Actor; + constructor(self) { + this.self = self; + this.actor = workerActor = new Actor(self, this); + } + getWorkerSource() { return null; } + }); + + const worker = workerFactory(); + + new Actor(worker, { + test () { done(); } + } as any, '1'); + new Actor(worker, { + test () { + done('test failed'); + } + } as any, '2'); + + workerActor.send('test', {}, () => {}, '1'); + }); + + test('#remove unbinds event listener', done => { + const actor = new Actor({ + addEventListener (type, callback, useCapture) { + this._addEventListenerArgs = [type, callback, useCapture]; + }, + removeEventListener (type, callback, useCapture) { + expect([type, callback, useCapture]).toEqual(this._addEventListenerArgs); + done(); + } + } as ActorTarget, {} as any, null); + actor.remove(); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/util/actor.ts b/web/libraries/maplibre-gl/src/util/actor.ts new file mode 100644 index 00000000..5bdc7d32 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/actor.ts @@ -0,0 +1,263 @@ +import {isWorker} from './util'; +import {serialize, deserialize, Serialized} from './web_worker_transfer'; +import {ThrottledInvoker} from './throttled_invoker'; + +import type {Transferable} from '../types/transferable'; +import type {Cancelable} from '../types/cancelable'; +import type {WorkerSource} from '../source/worker_source'; +import type {OverscaledTileID} from '../source/tile_id'; +import type {Callback} from '../types/callback'; +import type {StyleGlyph} from '../style/style_glyph'; + +export interface ActorTarget { + addEventListener: typeof window.addEventListener; + removeEventListener: typeof window.removeEventListener; + postMessage: typeof window.postMessage; + terminate?: () => void; +} + +export interface WorkerSourceProvider { + getWorkerSource(mapId: string | number, sourceType: string, sourceName: string): WorkerSource; +} + +export interface GlyphsProvider { + getGlyphs(mapId: string, params: { + stacks: {[_: string]: Array}; + source: string; + tileID: OverscaledTileID; + type: string; + }, + callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}> + ); +} + +export type MessageType = '' | '' | +'geojson.getClusterExpansionZoom' | 'geojson.getClusterChildren' | 'geojson.getClusterLeaves' | 'geojson.loadData' | +'removeSource' | 'loadWorkerSource' | 'loadDEMTile' | 'removeDEMTile' | +'removeTile' | 'reloadTile' | 'abortTile' | 'loadTile' | 'getTile' | +'getGlyphs' | 'getImages' | 'setImages' | +'syncRTLPluginState' | 'setReferrer' | 'setLayers' | 'updateLayers'; + +export type MessageData = { + id: string; + type: MessageType; + data?: Serialized; + targetMapId?: string | number | null; + mustQueue?: boolean; + error?: Serialized | null; + hasCallback?: boolean; + sourceMapId: string | number | null; +} + +export type Message = { + data: MessageData; +} + +/** + * An implementation of the [Actor design pattern](http://en.wikipedia.org/wiki/Actor_model) + * that maintains the relationship between asynchronous tasks and the objects + * that spin them off - in this case, tasks like parsing parts of styles, + * owned by the styles + */ +export class Actor { + target: ActorTarget; + parent: WorkerSourceProvider | GlyphsProvider; + mapId: string | number | null; + callbacks: { [x: number]: Function}; + name: string; + tasks: { [x: number]: MessageData }; + taskQueue: Array; + cancelCallbacks: { [x: number]: () => void }; + invoker: ThrottledInvoker; + globalScope: ActorTarget; + + /** + * @param target - The target + * @param parent - The parent + * @param mapId - A unique identifier for the Map instance using this Actor. + */ + constructor(target: ActorTarget, parent: WorkerSourceProvider | GlyphsProvider, mapId?: string | number) { + this.target = target; + this.parent = parent; + this.mapId = mapId; + this.callbacks = {}; + this.tasks = {}; + this.taskQueue = []; + this.cancelCallbacks = {}; + this.invoker = new ThrottledInvoker(this.process); + this.target.addEventListener('message', this.receive, false); + this.globalScope = isWorker() ? target : window; + } + + /** + * Sends a message from a main-thread map to a Worker or from a Worker back to + * a main-thread map instance. + * + * @param type - The name of the target method to invoke or '[source-type].[source-name].name' for a method on a WorkerSource. + * @param targetMapId - A particular mapId to which to send this message. + */ + send( + type: MessageType, + data: unknown, + callback?: Function | null, + targetMapId?: string | null, + mustQueue: boolean = false + ): Cancelable { + // We're using a string ID instead of numbers because they are being used as object keys + // anyway, and thus stringified implicitly. We use random IDs because an actor may receive + // message from multiple other actors which could run in different execution context. A + // linearly increasing ID could produce collisions. + const id = Math.round((Math.random() * 1e18)).toString(36).substring(0, 10); + if (callback) { + this.callbacks[id] = callback; + } + const buffers: Array = []; + const message: MessageData = { + id, + type, + hasCallback: !!callback, + targetMapId, + mustQueue, + sourceMapId: this.mapId, + data: serialize(data, buffers) + }; + + this.target.postMessage(message, {transfer: buffers}); + return { + cancel: () => { + if (callback) { + // Set the callback to null so that it never fires after the request is aborted. + delete this.callbacks[id]; + } + const cancelMessage: MessageData = { + id, + type: '', + targetMapId, + sourceMapId: this.mapId + }; + this.target.postMessage(cancelMessage); + } + }; + } + + receive = (message: Message) => { + const data = message.data; + const id = data.id; + + if (!id) { + return; + } + + if (data.targetMapId && this.mapId !== data.targetMapId) { + return; + } + + if (data.type === '') { + // Remove the original request from the queue. This is only possible if it + // hasn't been kicked off yet. The id will remain in the queue, but because + // there is no associated task, it will be dropped once it's time to execute it. + delete this.tasks[id]; + const cancel = this.cancelCallbacks[id]; + delete this.cancelCallbacks[id]; + if (cancel) { + cancel(); + } + } else { + if (isWorker() || data.mustQueue) { + // In workers, store the tasks that we need to process before actually processing them. This + // is necessary because we want to keep receiving messages, and in particular, + // messages. Some tasks may take a while in the worker thread, so before + // executing the next task in our queue, postMessage preempts this and + // messages can be processed. We're using a MessageChannel object to get throttle the + // process() flow to one at a time. + this.tasks[id] = data; + this.taskQueue.push(id); + this.invoker.trigger(); + } else { + // In the main thread, process messages immediately so that other work does not slip in + // between getting partial data back from workers. + this.processTask(id, data); + } + } + }; + + process = () => { + if (!this.taskQueue.length) { + return; + } + const id = this.taskQueue.shift(); + const task = this.tasks[id]; + delete this.tasks[id]; + // Schedule another process call if we know there's more to process _before_ invoking the + // current task. This is necessary so that processing continues even if the current task + // doesn't execute successfully. + if (this.taskQueue.length) { + this.invoker.trigger(); + } + if (!task) { + // If the task ID doesn't have associated task data anymore, it was canceled. + return; + } + + this.processTask(id, task); + }; + + processTask(id: string, task: MessageData) { + if (task.type === '') { + // The done() function in the counterpart has been called, and we are now + // firing the callback in the originating actor, if there is one. + const callback = this.callbacks[id]; + delete this.callbacks[id]; + if (callback) { + // If we get a response, but don't have a callback, the request was canceled. + if (task.error) { + callback(deserialize(task.error)); + } else { + callback(null, deserialize(task.data)); + } + } + } else { + let completed = false; + const buffers: Array = []; + const done = task.hasCallback ? (err: Error, data?: any) => { + completed = true; + delete this.cancelCallbacks[id]; + const responseMessage: MessageData = { + id, + type: '', + sourceMapId: this.mapId, + error: err ? serialize(err) : null, + data: serialize(data, buffers) + }; + this.target.postMessage(responseMessage, {transfer: buffers}); + } : (_) => { + completed = true; + }; + + let callback: Cancelable = null; + const params = deserialize(task.data); + if (this.parent[task.type]) { + // task.type == 'loadTile', 'removeTile', etc. + callback = this.parent[task.type](task.sourceMapId, params, done); + } else if ('getWorkerSource' in this.parent) { + // task.type == sourcetype.method + const keys = task.type.split('.'); + const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], (params as any).source); + callback = scope[keys[1]](params, done); + } else { + // No function was found. + done(new Error(`Could not find function ${task.type}`)); + } + + if (!completed && callback && callback.cancel) { + // Allows canceling the task as long as it hasn't been completed yet. + this.cancelCallbacks[id] = callback.cancel; + } + } + } + + remove() { + this.invoker.remove(); + this.target.removeEventListener('message', this.receive, false); + } +} diff --git a/web/libraries/maplibre-gl/src/util/ajax.test.ts b/web/libraries/maplibre-gl/src/util/ajax.test.ts new file mode 100644 index 00000000..f3a6146c --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/ajax.test.ts @@ -0,0 +1,177 @@ +import { + getArrayBuffer, + getJSON, + postData, + AJAXError, + sameOrigin +} from './ajax'; + +import {fakeServer, type FakeServer} from 'nise'; +import {destroyFetchMock, FetchMock, RequestMock, setupFetchMock} from './test/mock_fetch'; + +function readAsText(blob) { + return new Promise((resolve, reject) => { + const fileReader = new FileReader(); + fileReader.onload = () => resolve(fileReader.result); + fileReader.onerror = () => reject(fileReader.error); + fileReader.readAsText(blob); + }); +} + +describe('ajax', () => { + let server: FakeServer; + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + }); + afterEach(() => { + server.restore(); + }); + + test('getArrayBuffer, 404', done => { + server.respondWith(request => { + request.respond(404, undefined, '404 Not Found'); + }); + getArrayBuffer({url: 'http://example.com/test.bin'}, async (error) => { + const ajaxError = error as AJAXError; + const body = await readAsText(ajaxError.body); + expect(ajaxError.status).toBe(404); + expect(ajaxError.statusText).toBe('Not Found'); + expect(ajaxError.url).toBe('http://example.com/test.bin'); + expect(body).toBe('404 Not Found'); + done(); + }); + server.respond(); + }); + + test('getJSON', done => { + server.respondWith(request => { + request.respond(200, {'Content-Type': 'application/json'}, '{"foo": "bar"}'); + }); + getJSON({url: ''}, (error, body) => { + expect(error).toBeFalsy(); + expect(body).toEqual({foo: 'bar'}); + done(); + }); + server.respond(); + }); + + test('getJSON, invalid syntax', done => { + server.respondWith(request => { + request.respond(200, {'Content-Type': 'application/json'}, 'how do i even'); + }); + getJSON({url: ''}, (error) => { + expect(error).toBeTruthy(); + done(); + }); + server.respond(); + }); + + test('getJSON, 404', done => { + server.respondWith(request => { + request.respond(404, undefined, '404 Not Found'); + }); + getJSON({url: 'http://example.com/test.json'}, async (error) => { + const ajaxError = error as AJAXError; + const body = await readAsText(ajaxError.body); + expect(ajaxError.status).toBe(404); + expect(ajaxError.statusText).toBe('Not Found'); + expect(ajaxError.url).toBe('http://example.com/test.json'); + expect(body).toBe('404 Not Found'); + done(); + }); + server.respond(); + }); + + test('postData, 204(no content): no error', done => { + server.respondWith(request => { + request.respond(204, undefined, undefined); + }); + postData({url: 'api.mapbox.com'}, (error) => { + expect(error).toBeNull(); + done(); + }); + server.respond(); + }); + + test('sameOrigin method', () => { + jest.spyOn(window, 'location', 'get').mockReturnValue({ + protocol: 'https:', + host: 'somewhere.com' + } as any); + + expect(sameOrigin('https://somewhere.com')).toBe(true); + expect(sameOrigin('https://somewhere.com/path')).toBe(true); + expect(sameOrigin('https://somewhere.com/path/?q=abc')).toBe(true); + + expect(sameOrigin('https://somewhere.com:443/path')).toBe(true); + + expect(sameOrigin('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=')).toBe(true); + expect(sameOrigin('blob:https://www.bing.com/09f36686-e57a-420f-9004-918548219b75')).toBe(true); + + // relative URL is same origin for sure + expect(sameOrigin('/foo')).toBe(true); + expect(sameOrigin('foo')).toBe(true); + + // empty string is considered as relative, and should be true + expect(sameOrigin('')).toBe(true); + expect(sameOrigin(null)).toBe(true); + expect(sameOrigin(undefined)).toBe(true); + + expect(sameOrigin('HTTPS://somewhere.com')).toBe(true); + + // different domain + expect(sameOrigin('httpS://www.somewhere.com')).toBe(false); + + // different protocol + expect(sameOrigin('HTTP://somewhere.com')).toBe(false); + expect(sameOrigin('file:///c:/temp/foo.html')).toBe(false); + + // file url + jest.spyOn(window, 'location', 'get').mockReturnValue({ + protocol: 'file:', + host: '' + } as any); + expect(sameOrigin('file:///C:/Temp/abc.html')).toBe(true); + expect(sameOrigin('HTTP://somewhere.com')).toBe(false); + + // relative URL (for file URL) is same origin as well + expect(sameOrigin('/foo')).toBe(true); + expect(sameOrigin('foo')).toBe(true); + + // edge case + expect(sameOrigin('://foo')).toBe(true); + }); + + describe('requests parameters', () => { + let fetch: FetchMock; + + beforeEach(() => { + fetch = setupFetchMock(); + }); + + afterEach(() => { + destroyFetchMock(); + }); + + test('should be provided to fetch API in getArrayBuffer function', (done) => { + getArrayBuffer({url: 'http://example.com/test-params.json', cache: 'force-cache', headers: {'Authorization': 'Bearer 123'}}, () => { + expect(fetch).toHaveBeenCalledTimes(1); + expect(fetch).toHaveBeenCalledWith(expect.objectContaining({url: 'http://example.com/test-params.json', method: 'GET', cache: 'force-cache'})); + expect((fetch.mock.calls[0][0] as RequestMock).headers.get('Authorization')).toBe('Bearer 123'); + + done(); + }); + }); + + test('should be provided to fetch API in getJSON function', (done) => { + getJSON({url: 'http://example.com/test-params.json', cache: 'force-cache', headers: {'Authorization': 'Bearer 123'}}, () => { + expect(fetch).toHaveBeenCalledTimes(1); + expect(fetch).toHaveBeenCalledWith(expect.objectContaining({url: 'http://example.com/test-params.json', method: 'GET', cache: 'force-cache'})); + expect((fetch.mock.calls[0][0] as RequestMock).headers.get('Authorization')).toBe('Bearer 123'); + + done(); + }); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/ajax.ts b/web/libraries/maplibre-gl/src/util/ajax.ts new file mode 100644 index 00000000..8119d208 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/ajax.ts @@ -0,0 +1,317 @@ +import {extend, warnOnce, isWorker} from './util'; +import {config} from './config'; + +import type {Callback} from '../types/callback'; +import type {Cancelable} from '../types/cancelable'; + +/** + * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks. + * @example + * ```ts + * // use transformRequest to modify requests that begin with `http://myHost` + * transformRequest: function(url, resourceType) { + * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) { + * return { + * url: url.replace('http', 'https'), + * headers: { 'my-custom-header': true }, + * credentials: 'include' // Include cookies for cross-origin requests + * } + * } + * } + * ``` + */ +export type RequestParameters = { + /** + * The URL to be requested. + */ + url: string; + /** + * The headers to be sent with the request. + */ + headers?: any; + /** + * Request method `'GET' | 'POST' | 'PUT'`. + */ + method?: 'GET' | 'POST' | 'PUT'; + /** + * Request body. + */ + body?: string; + /** + * Response body type to be returned `'string' | 'json' | 'arrayBuffer'`. + */ + type?: 'string' | 'json' | 'arrayBuffer' | 'image'; + /** + * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests. + */ + credentials?: 'same-origin' | 'include'; + /** + * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events. + */ + collectResourceTiming?: boolean; + /** + * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache) + */ + cache?: RequestCache; +}; + +/** + * The response callback used in various places + */ +export type ResponseCallback = ( + error?: Error | null, + data?: T | null, + cacheControl?: string | null, + expires?: string | null +) => void; + +/** + * An error thrown when a HTTP request results in an error response. + */ +export class AJAXError extends Error { + /** + * The response's HTTP status code. + */ + status: number; + + /** + * The response's HTTP status text. + */ + statusText: string; + + /** + * The request's URL. + */ + url: string; + + /** + * The response's body. + */ + body: Blob; + + /** + * @param status - The response's HTTP status code. + * @param statusText - The response's HTTP status text. + * @param url - The request's URL. + * @param body - The response's body. + */ + constructor(status: number, statusText: string, url: string, body: Blob) { + super(`AJAXError: ${statusText} (${status}): ${url}`); + this.status = status; + this.statusText = statusText; + this.url = url; + this.body = body; + } +} + +// Ensure that we're sending the correct referrer from blob URL worker bundles. +// For files loaded from the local file system, `location.origin` will be set +// to the string(!) "null" (Firefox), or "file://" (Chrome, Safari, Edge, IE), +// and we will set an empty referrer. Otherwise, we're using the document's URL. +/* global self */ +export const getReferrer = isWorker() ? + () => (self as any).worker && (self as any).worker.referrer : + () => (window.location.protocol === 'blob:' ? window.parent : window).location.href; + +export const getProtocolAction = url => config.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))]; + +// Determines whether a URL is a file:// URL. This is obviously the case if it begins +// with file://. Relative URLs are also file:// URLs iff the original document was loaded +// via a file:// URL. +const isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\w+:/.test(url)); + +function makeFetchRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { + const controller = new AbortController(); + const request = new Request(requestParameters.url, { + method: requestParameters.method || 'GET', + body: requestParameters.body, + credentials: requestParameters.credentials, + headers: requestParameters.headers, + cache: requestParameters.cache, + referrer: getReferrer(), + signal: controller.signal + }); + let complete = false; + let aborted = false; + + if (requestParameters.type === 'json') { + request.headers.set('Accept', 'application/json'); + } + + const validateOrFetch = (err, cachedResponse?, responseIsFresh?) => { + if (aborted) return; + + if (err) { + // Do fetch in case of cache error. + // HTTP pages in Edge trigger a security error that can be ignored. + if (err.message !== 'SecurityError') { + warnOnce(err); + } + } + + if (cachedResponse && responseIsFresh) { + return finishRequest(cachedResponse); + } + + if (cachedResponse) { + // We can't do revalidation with 'If-None-Match' because then the + // request doesn't have simple cors headers. + } + + fetch(request).then(response => { + if (response.ok) { + return finishRequest(response); + + } else { + return response.blob().then(body => callback(new AJAXError(response.status, response.statusText, requestParameters.url, body))); + } + }).catch(error => { + if (error.code === 20) { + // silence expected AbortError + return; + } + callback(new Error(error.message)); + }); + }; + + const finishRequest = (response) => { + ( + (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') ? response.arrayBuffer() : + requestParameters.type === 'json' ? response.json() : + response.text() + ).then(result => { + if (aborted) return; + complete = true; + callback(null, result, response.headers.get('Cache-Control'), response.headers.get('Expires')); + }).catch(err => { + if (!aborted) callback(new Error(err.message)); + }); + }; + + validateOrFetch(null, null); + + return {cancel: () => { + aborted = true; + if (!complete) controller.abort(); + }}; +} + +function makeXMLHttpRequest(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { + const xhr: XMLHttpRequest = new XMLHttpRequest(); + + xhr.open(requestParameters.method || 'GET', requestParameters.url, true); + if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') { + xhr.responseType = 'arraybuffer'; + } + for (const k in requestParameters.headers) { + xhr.setRequestHeader(k, requestParameters.headers[k]); + } + if (requestParameters.type === 'json') { + xhr.responseType = 'text'; + xhr.setRequestHeader('Accept', 'application/json'); + } + xhr.withCredentials = requestParameters.credentials === 'include'; + xhr.onerror = () => { + callback(new Error(xhr.statusText)); + }; + xhr.onload = () => { + if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) { + let data: unknown = xhr.response; + if (requestParameters.type === 'json') { + // We're manually parsing JSON here to get better error messages. + try { + data = JSON.parse(xhr.response); + } catch (err) { + return callback(err); + } + } + callback(null, data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires')); + } else { + const body = new Blob([xhr.response], {type: xhr.getResponseHeader('Content-Type')}); + callback(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body)); + } + }; + xhr.send(requestParameters.body); + return {cancel: () => xhr.abort()}; +} + +export const makeRequest = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { + // We're trying to use the Fetch API if possible. However, in some situations we can't use it: + // - IE11 doesn't support it at all. In this case, we dispatch the request to the main thread so + // that we can get an accruate referrer header. + // - Safari exposes window.AbortController, but it doesn't work actually abort any requests in + // some versions (see https://bugs.webkit.org/show_bug.cgi?id=174980#c2) + // - Requests for resources with the file:// URI scheme don't work with the Fetch API either. In + // this case we unconditionally use XHR on the current thread since referrers don't matter. + if (/:\/\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) { + if (isWorker() && (self as any).worker && (self as any).worker.actor) { + return (self as any).worker.actor.send('getResource', requestParameters, callback); + } + if (!isWorker()) { + const action = getProtocolAction(requestParameters.url) || makeFetchRequest; + return action(requestParameters, callback); + } + } + if (!isFileURL(requestParameters.url)) { + if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) { + return makeFetchRequest(requestParameters, callback); + } + if (isWorker() && (self as any).worker && (self as any).worker.actor) { + const queueOnMainThread = true; + return (self as any).worker.actor.send('getResource', requestParameters, callback, undefined, queueOnMainThread); + } + } + return makeXMLHttpRequest(requestParameters, callback); +}; + +export const getJSON = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { + return makeRequest(extend(requestParameters, {type: 'json'}), callback); +}; + +export const getArrayBuffer = function( + requestParameters: RequestParameters, + callback: ResponseCallback +): Cancelable { + return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), callback); +}; + +export const postData = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { + return makeRequest(extend(requestParameters, {method: 'POST'}), callback); +}; + +export function sameOrigin(inComingUrl: string) { + // URL class should be available everywhere + // https://developer.mozilla.org/en-US/docs/Web/API/URL + // In addtion, a relative URL "/foo" or "./foo" will throw exception in its ctor, + // try-catch is expansive so just use a heuristic check to avoid it + // also check data URL + if (!inComingUrl || + inComingUrl.indexOf('://') <= 0 || // relative URL + inComingUrl.indexOf('data:image/') === 0 || // data image URL + inComingUrl.indexOf('blob:') === 0) { // blob + return true; + } + const urlObj = new URL(inComingUrl); + const locationObj = window.location; + return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host; +} +/** + * A type used to store the tile's expiration date and cache control definition + */ +export type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null}; +export const getVideo = function(urls: Array, callback: Callback): Cancelable { + const video: HTMLVideoElement = window.document.createElement('video'); + video.muted = true; + video.onloadstart = function() { + callback(null, video); + }; + for (let i = 0; i < urls.length; i++) { + const s: HTMLSourceElement = window.document.createElement('source'); + if (!sameOrigin(urls[i])) { + video.crossOrigin = 'Anonymous'; + } + s.src = urls[i]; + video.appendChild(s); + } + return {cancel: () => {}}; +}; diff --git a/web/libraries/maplibre-gl/src/util/browser.test.ts b/web/libraries/maplibre-gl/src/util/browser.test.ts new file mode 100644 index 00000000..55dcdcff --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/browser.test.ts @@ -0,0 +1,26 @@ +import {browser} from './browser'; + +describe('browser', () => { + test('frame', done => { + const id = browser.frame(() => { + expect(id).toBeTruthy(); + done(); + }); + }); + + test('now', () => { + expect(typeof browser.now()).toBe('number'); + }); + + test('frame', done => { + const frame = browser.frame(() => { + done('test failed: browser.frame callback was called'); + }); + frame.cancel(); + done(); + }); + + test('hardwareConcurrency', () => { + expect(typeof browser.hardwareConcurrency).toBe('number'); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/browser.ts b/web/libraries/maplibre-gl/src/util/browser.ts new file mode 100755 index 00000000..6ba3b6f1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/browser.ts @@ -0,0 +1,58 @@ +import type {Cancelable} from '../types/cancelable'; + +const now = typeof performance !== 'undefined' && performance && performance.now ? + performance.now.bind(performance) : + Date.now.bind(Date); + +let linkEl; + +let reducedMotionQuery: MediaQueryList; + +/** */ +export const browser = { + /** + * Provides a function that outputs milliseconds: either performance.now() + * or a fallback to Date.now() + */ + now, + + frame(fn: (paintStartTimestamp: number) => void): Cancelable { + const frame = requestAnimationFrame(fn); + return {cancel: () => cancelAnimationFrame(frame)}; + }, + + getImageData(img: HTMLImageElement | ImageBitmap, padding: number = 0): ImageData { + const context = this.getImageCanvasContext(img); + return context.getImageData(-padding, -padding, img.width as number + 2 * padding, img.height as number + 2 * padding); + }, + + getImageCanvasContext(img: HTMLImageElement | ImageBitmap): CanvasRenderingContext2D { + const canvas = window.document.createElement('canvas') as HTMLCanvasElement; + const context = canvas.getContext('2d', {willReadFrequently: true}); + if (!context) { + throw new Error('failed to create canvas 2d context'); + } + canvas.width = img.width as number; + canvas.height = img.height as number; + context.drawImage(img, 0, 0, img.width as number, img.height as number); + return context; + }, + + resolveURL(path: string) { + if (!linkEl) linkEl = document.createElement('a'); + linkEl.href = path; + return linkEl.href; + }, + + hardwareConcurrency: typeof navigator !== 'undefined' && navigator.hardwareConcurrency || 4, + + get prefersReducedMotion(): boolean { + // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util' + if (!matchMedia) return false; + //Lazily initialize media query + if (reducedMotionQuery == null) { + reducedMotionQuery = matchMedia('(prefers-reduced-motion: reduce)'); + } + return reducedMotionQuery.matches; + }, +}; diff --git a/web/libraries/maplibre-gl/src/util/classify_rings.test.ts b/web/libraries/maplibre-gl/src/util/classify_rings.test.ts new file mode 100644 index 00000000..83294bff --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/classify_rings.test.ts @@ -0,0 +1,147 @@ +import fs from 'fs'; +import path from 'path'; +import Protobuf from 'pbf'; +import {VectorTile} from '@mapbox/vector-tile'; +import {classifyRings} from './classify_rings'; +import Point from '@mapbox/point-geometry'; + +// Load a fill feature from fixture tile. +const vt = new VectorTile(new Protobuf(fs.readFileSync(path.resolve(__dirname, '../../test/unit/assets/mbsv5-6-18-23.vector.pbf')))); +const feature = vt.layers.water.feature(0); + +describe('classifyRings', () => { + test('classified.length', () => { + let geometry; + let classified; + + geometry = [ + [ + {x: 0, y: 0}, + {x: 0, y: 40}, + {x: 40, y: 40}, + {x: 40, y: 0}, + {x: 0, y: 0} + ] + ]; + classified = classifyRings(geometry, undefined); + expect(classified).toHaveLength(1); + expect(classified[0]).toHaveLength(1); + + geometry = [ + [ + {x: 0, y: 0}, + {x: 0, y: 40}, + {x: 40, y: 40}, + {x: 40, y: 0}, + {x: 0, y: 0} + ], + [ + {x: 60, y: 0}, + {x: 60, y: 40}, + {x: 100, y: 40}, + {x: 100, y: 0}, + {x: 60, y: 0} + ] + ]; + classified = classifyRings(geometry, undefined); + expect(classified).toHaveLength(2); + expect(classified[0]).toHaveLength(1); + expect(classified[1]).toHaveLength(1); + + geometry = [ + [ + {x: 0, y: 0}, + {x: 0, y: 40}, + {x: 40, y: 40}, + {x: 40, y: 0}, + {x: 0, y: 0} + ], + [ + {x: 10, y: 10}, + {x: 20, y: 10}, + {x: 20, y: 20}, + {x: 10, y: 10} + ] + ]; + classified = classifyRings(geometry, undefined); + expect(classified).toHaveLength(1); + expect(classified[0]).toHaveLength(2); + + geometry = feature.loadGeometry(); + classified = classifyRings(geometry, undefined); + expect(classified).toHaveLength(2); + expect(classified[0]).toHaveLength(1); + expect(classified[1]).toHaveLength(10); + }); +}); + +describe('classifyRings + maxRings', () => { + + function createGeometry(options?) { + const geometry = [ + // Outer ring, area = 3200 + [{x: 0, y: 0}, {x: 0, y: 40}, {x: 40, y: 40}, {x: 40, y: 0}, {x: 0, y: 0}], + // Inner ring, area = 100 + [{x: 30, y: 30}, {x: 32, y: 30}, {x: 32, y: 32}, {x: 30, y: 30}], + // Inner ring, area = 4 + [{x: 10, y: 10}, {x: 20, y: 10}, {x: 20, y: 20}, {x: 10, y: 10}] + ] as Point[][]; + if (options && options.reverse) { + geometry[0].reverse(); + geometry[1].reverse(); + geometry[2].reverse(); + } + return geometry; + } + + test('maxRings=undefined', () => { + const geometry = sortRings(classifyRings(createGeometry(), undefined)); + expect(geometry).toHaveLength(1); + expect(geometry[0]).toHaveLength(3); + expect(geometry[0][0].area).toBe(3200); + expect(geometry[0][1].area).toBe(100); + expect(geometry[0][2].area).toBe(4); + + }); + + test('maxRings=2', () => { + const geometry = sortRings(classifyRings(createGeometry(), 2)); + expect(geometry).toHaveLength(1); + expect(geometry[0]).toHaveLength(2); + expect(geometry[0][0].area).toBe(3200); + expect(geometry[0][1].area).toBe(100); + + }); + + test('maxRings=2, reversed geometry', () => { + const geometry = sortRings(classifyRings(createGeometry({reverse: true}), 2)); + expect(geometry).toHaveLength(1); + expect(geometry[0]).toHaveLength(2); + expect(geometry[0][0].area).toBe(3200); + expect(geometry[0][1].area).toBe(100); + + }); + + test('maxRings=5, geometry from fixture', () => { + const geometry = sortRings(classifyRings(feature.loadGeometry(), 5)); + expect(geometry).toHaveLength(2); + expect(geometry[0]).toHaveLength(1); + expect(geometry[1]).toHaveLength(5); + + const areas = geometry[1].map((ring) => { return ring.area; }); + expect(areas).toEqual([2763951, 21600, 8298, 4758, 3411]); + + }); + +}); + +function sortRings(geometry) { + for (let i = 0; i < geometry.length; i++) { + geometry[i] = geometry[i].sort(compareAreas); + } + return geometry; +} + +function compareAreas(a, b) { + return b.area - a.area; +} diff --git a/web/libraries/maplibre-gl/src/util/classify_rings.ts b/web/libraries/maplibre-gl/src/util/classify_rings.ts new file mode 100644 index 00000000..f8fe2621 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/classify_rings.ts @@ -0,0 +1,50 @@ +import quickselect from 'quickselect'; + +import {calculateSignedArea} from './util'; + +import type Point from '@mapbox/point-geometry'; + +// classifies an array of rings into polygons with outer rings and holes +export function classifyRings(rings: Array>, maxRings: number) { + const len = rings.length; + + if (len <= 1) return [rings]; + + const polygons = []; + let polygon, + ccw; + + for (let i = 0; i < len; i++) { + const area = calculateSignedArea(rings[i]); + if (area === 0) continue; + + (rings[i] as any).area = Math.abs(area); + + if (ccw === undefined) ccw = area < 0; + + if (ccw === area < 0) { + if (polygon) polygons.push(polygon); + polygon = [rings[i]]; + + } else { + (polygon as any).push(rings[i]); + } + } + if (polygon) polygons.push(polygon); + + // Earcut performance degrades with the # of rings in a polygon. For this + // reason, we limit strip out all but the `maxRings` largest rings. + if (maxRings > 1) { + for (let j = 0; j < polygons.length; j++) { + if (polygons[j].length <= maxRings) continue; + quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas); + polygons[j] = polygons[j].slice(0, maxRings); + } + } + + return polygons; +} + +function compareAreas(a, b) { + return b.area - a.area; +} diff --git a/web/libraries/maplibre-gl/src/util/color_ramp.test.ts b/web/libraries/maplibre-gl/src/util/color_ramp.test.ts new file mode 100644 index 00000000..17083b96 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/color_ramp.test.ts @@ -0,0 +1,105 @@ + +import {renderColorRamp} from './color_ramp'; +import {createPropertyExpression, StylePropertyExpression, StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec'; + +const spec = { + 'function': true, + 'property-function': true, + 'type': 'color' +} as any as StylePropertySpecification; + +function pixelAt(image, i) { + return image.data.slice(i * 4, (i + 1) * 4); +} + +function nearlyEquals(a, b) { + // we're actually looking for colors that are _almost_ equal, but don't + // expect exact equal since 256 px need to represent a range from [0, 1] + // (inclusive) -- the first and last pixel should be exact, the halfway + // pixel may not be + return a.every((e, i) => Math.abs(e - b[i]) <= 3); +} + +describe('renderColorRamp', () => { + test('renderColorRamp linear', () => { + + const expression = createPropertyExpression([ + 'interpolate', + ['linear'], + ['line-progress'], + 0, 'rgba(0,0,255,0)', + 0.25, 'white', + 0.5, 'rgba(0,255,255,0.5)', + 0.75, 'black', + 1, 'red' + ], spec).value as StylePropertyExpression; + + const ramp = renderColorRamp({expression, evaluationKey: 'lineProgress'}); + + expect(ramp.width).toBe(256); + expect(ramp.height).toBe(1); + + expect(pixelAt(ramp, 0)[3]).toBe(0); + expect(nearlyEquals(pixelAt(ramp, 63), [255, 255, 255, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 127), [0, 255, 255, 127])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 191), [0, 0, 0, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 255), [255, 0, 0, 255])).toBeTruthy(); + }); + + test('renderColorRamp step', () => { + + const expression = createPropertyExpression([ + 'step', + ['line-progress'], + 'rgba(0, 0, 255, 0.1)', + 0.1, 'red', + 0.2, 'yellow', + 0.3, 'white', + 0.5, 'black', + 1, 'black' + ], spec).value as StylePropertyExpression; + + const ramp = renderColorRamp({expression, evaluationKey: 'lineProgress', resolution: 512}); + + expect(ramp.width).toBe(512); + expect(ramp.height).toBe(1); + + expect(pixelAt(ramp, 0)[3]).toBe(25); + expect(nearlyEquals(pixelAt(ramp, 50), [0, 0, 255, 25])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 53), [255, 0, 0, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 103), [255, 255, 0, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 160), [255, 255, 255, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 256), [0, 0, 0, 255])).toBeTruthy(); + + }); + + test('renderColorRamp usePlacement', () => { + + const expression = createPropertyExpression([ + 'step', + ['line-progress'], + 'rgba(255, 0, 0, 0.5)', + 0.1, 'black', + 0.2, 'red', + 0.3, 'blue', + 0.5, 'white', + 1, 'white' + ], spec).value as StylePropertyExpression; + + const ramp = renderColorRamp({expression, evaluationKey: 'lineProgress', resolution: 512}); + + expect(ramp.width).toBe(512); + expect(ramp.height).toBe(1); + + renderColorRamp({expression, evaluationKey: 'lineProgress', resolution: 512, image: ramp}); + + expect(pixelAt(ramp, 0)[3]).toBe(127); + expect(nearlyEquals(pixelAt(ramp, 50), [255, 0, 0, 127])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 53), [0, 0, 0, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 103), [255, 0, 0, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 160), [0, 0, 255, 255])).toBeTruthy(); + expect(nearlyEquals(pixelAt(ramp, 256), [255, 255, 255, 255])).toBeTruthy(); + + }); + +}); diff --git a/web/libraries/maplibre-gl/src/util/color_ramp.ts b/web/libraries/maplibre-gl/src/util/color_ramp.ts new file mode 100644 index 00000000..48243711 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/color_ramp.ts @@ -0,0 +1,56 @@ +import {RGBAImage} from './image'; +import {isPowerOfTwo} from './util'; + +import type {StylePropertyExpression} from '@maplibre/maplibre-gl-style-spec'; + +export type ColorRampParams = { + expression: StylePropertyExpression; + evaluationKey: string; + resolution?: number; + image?: RGBAImage; + clips?: Array; +}; + +/** + * Given an expression that should evaluate to a color ramp, + * return a RGBA image representing that ramp expression. + */ +export function renderColorRamp(params: ColorRampParams): RGBAImage { + const evaluationGlobals = {}; + const width = params.resolution || 256; + const height = params.clips ? params.clips.length : 1; + const image = params.image || new RGBAImage({width, height}); + + if (!isPowerOfTwo(width)) throw new Error(`width is not a power of 2 - ${width}`); + + const renderPixel = (stride, index, progress) => { + evaluationGlobals[params.evaluationKey] = progress; + const pxColor = params.expression.evaluate(evaluationGlobals as any); + // the colors are being unpremultiplied because Color uses + // premultiplied values, and the Texture class expects unpremultiplied ones + image.data[stride + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a); + image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a); + image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a); + image.data[stride + index + 3] = Math.floor(pxColor.a * 255); + }; + + if (!params.clips) { + for (let i = 0, j = 0; i < width; i++, j += 4) { + const progress = i / (width - 1); + + renderPixel(0, j, progress); + } + } else { + for (let clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) { + for (let i = 0, j = 0; i < width; i++, j += 4) { + // Remap progress between clips + const progress = i / (width - 1); + const {start, end} = params.clips[clip]; + const evaluationProgress = start * (1 - progress) + end * progress; + renderPixel(stride, j, evaluationProgress); + } + } + } + + return image; +} diff --git a/web/libraries/maplibre-gl/src/util/config.ts b/web/libraries/maplibre-gl/src/util/config.ts new file mode 100644 index 00000000..152122bc --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/config.ts @@ -0,0 +1,23 @@ +import type {Cancelable} from '../types/cancelable'; +import type {RequestParameters, ResponseCallback} from './ajax'; + +/** + * This is a global config object used to store the configuration + * It is available in the workers as well. + * Only serializable data should be stored in it. + */ +type Config = { + MAX_PARALLEL_IMAGE_REQUESTS: number; + MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number; + MAX_TILE_CACHE_ZOOM_LEVELS: number; + REGISTERED_PROTOCOLS: {[x: string]: (requestParameters: RequestParameters, callback: ResponseCallback) => Cancelable}; + WORKER_URL: string; +}; + +export const config: Config = { + MAX_PARALLEL_IMAGE_REQUESTS: 16, + MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8, + MAX_TILE_CACHE_ZOOM_LEVELS: 5, + REGISTERED_PROTOCOLS: {}, + WORKER_URL: '' +}; diff --git a/web/libraries/maplibre-gl/src/util/debug.ts b/web/libraries/maplibre-gl/src/util/debug.ts new file mode 100644 index 00000000..6b20c906 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/debug.ts @@ -0,0 +1,24 @@ +import {extend} from './util'; + +/** + * This is a private namespace for utility functions that will get automatically stripped + * out in production builds. + */ +export const Debug = { + extend(dest: any, ...sources: Array): any { + return extend(dest, ...sources); + }, + + run(fn: () => any) { + fn(); + }, + + logToElement(message: string, overwrite: boolean = false, id: string = 'log') { + const el = window.document.getElementById(id); + if (el) { + if (overwrite) el.innerHTML = ''; + el.innerHTML += `
${message}`; + } + + } +}; diff --git a/web/libraries/maplibre-gl/src/util/dictionary_coder.ts b/web/libraries/maplibre-gl/src/util/dictionary_coder.ts new file mode 100644 index 00000000..bc3000cf --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/dictionary_coder.ts @@ -0,0 +1,23 @@ +export class DictionaryCoder { + _stringToNumber: {[_: string]: number}; + _numberToString: Array; + + constructor(strings: Array) { + this._stringToNumber = {}; + this._numberToString = []; + for (let i = 0; i < strings.length; i++) { + const string = strings[i]; + this._stringToNumber[string] = i; + this._numberToString[i] = string; + } + } + + encode(string: string) { + return this._stringToNumber[string]; + } + + decode(n: number) { + if (n >= this._numberToString.length) throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`); + return this._numberToString[n]; + } +} diff --git a/web/libraries/maplibre-gl/src/util/dispatcher.test.ts b/web/libraries/maplibre-gl/src/util/dispatcher.test.ts new file mode 100644 index 00000000..c1e78a0d --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/dispatcher.test.ts @@ -0,0 +1,76 @@ +import {Actor} from './actor'; +import {Dispatcher} from './dispatcher'; +import {workerFactory} from './web_worker'; +import {WorkerPool} from './worker_pool'; + +describe('Dispatcher', () => { + test('requests and releases workers from pool', () => { + const workers = [workerFactory(), workerFactory()]; + const mapId = 1; + const releaseCalled = []; + const workerPool = { + acquire () { + return workers; + }, + release (id) { + releaseCalled.push(id); + } + } as any as WorkerPool; + + const dispatcher = new Dispatcher(workerPool, {} as any, mapId); + expect(dispatcher.actors.map((actor) => { return actor.target; })).toEqual(workers); + dispatcher.remove(); + expect(dispatcher.actors).toHaveLength(0); + expect(releaseCalled).toEqual([mapId]); + + }); + + test('reuse workers till map is disposed', () => { + let workers = null; + const mapId = 1; + const releaseCalled = []; + const workerPool = { + acquire () { + if (!workers) { + workers = [workerFactory(), workerFactory()]; + } + return workers; + }, + release (id) { + releaseCalled.push(id); + workers = null; + } + } as any as WorkerPool; + + let dispatcher = new Dispatcher(workerPool, {} as any, mapId); + expect(dispatcher.actors.map((actor) => { return actor.target; })).toEqual(workers); + + // Remove dispatcher, but map is not disposed (During style change) + dispatcher.remove(false); + expect(dispatcher.actors).toHaveLength(0); + expect(releaseCalled).toHaveLength(0); + + // Create new instance of dispatcher + dispatcher = new Dispatcher(workerPool, {} as any, mapId); + expect(dispatcher.actors.map((actor) => { return actor.target; })).toEqual(workers); + dispatcher.remove(true); // mapRemoved = true + expect(dispatcher.actors).toHaveLength(0); + expect(releaseCalled).toEqual([mapId]); + + }); + + test('#remove destroys actors', () => { + const actorsRemoved = []; + const mapId = 1; + const spy = jest.fn().mockImplementation(() => { actorsRemoved.push(this); }); + Actor.prototype.remove = spy; + WorkerPool.workerCount = 4; + + const workerPool = new WorkerPool(); + const dispatcher = new Dispatcher(workerPool, {} as any, mapId); + dispatcher.remove(); + expect(actorsRemoved).toHaveLength(4); + }); + +}); + diff --git a/web/libraries/maplibre-gl/src/util/dispatcher.ts b/web/libraries/maplibre-gl/src/util/dispatcher.ts new file mode 100644 index 00000000..fd9b15dc --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/dispatcher.ts @@ -0,0 +1,55 @@ +import {asyncAll} from './util'; +import {Actor, GlyphsProvider, MessageType} from './actor'; + +import type {WorkerPool} from './worker_pool'; +import type {WorkerSource} from '../source/worker_source'; /* eslint-disable-line */ // this is used for the docs' import +/** + * Responsible for sending messages from a {@link Source} to an associated + * {@link WorkerSource}. + */ +export class Dispatcher { + workerPool: WorkerPool; + actors: Array; + currentActor: number; + id: string | number; + + constructor(workerPool: WorkerPool, parent: GlyphsProvider, mapId: string | number) { + this.workerPool = workerPool; + this.actors = []; + this.currentActor = 0; + this.id = mapId; + const workers = this.workerPool.acquire(mapId); + for (let i = 0; i < workers.length; i++) { + const worker = workers[i]; + const actor = new Actor(worker, parent, mapId); + actor.name = `Worker ${i}`; + this.actors.push(actor); + } + if (!this.actors.length) throw new Error('No actors found'); + } + + /** + * Broadcast a message to all Workers. + */ + broadcast(type: MessageType, data: unknown, cb?: (...args: any[]) => any) { + cb = cb || function () {}; + asyncAll(this.actors, (actor, done) => { + actor.send(type, data, done); + }, cb); + } + + /** + * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion. + * @returns An actor object backed by a web worker for processing messages. + */ + getActor(): Actor { + this.currentActor = (this.currentActor + 1) % this.actors.length; + return this.actors[this.currentActor]; + } + + remove(mapRemoved: boolean = true) { + this.actors.forEach((actor) => { actor.remove(); }); + this.actors = []; + if (mapRemoved) this.workerPool.release(this.id); + } +} diff --git a/web/libraries/maplibre-gl/src/util/dom.ts b/web/libraries/maplibre-gl/src/util/dom.ts new file mode 100644 index 00000000..90653a68 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/dom.ts @@ -0,0 +1,116 @@ +import Point from '@mapbox/point-geometry'; + +export class DOM { + private static readonly docStyle = typeof window !== 'undefined' && window.document && window.document.documentElement.style; + + private static userSelect: string; + + private static selectProp = DOM.testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']); + + private static transformProp = DOM.testProp(['transform', 'WebkitTransform']); + + private static testProp(props: string[]): string { + if (!DOM.docStyle) return props[0]; + for (let i = 0; i < props.length; i++) { + if (props[i] in DOM.docStyle) { + return props[i]; + } + } + return props[0]; + } + + public static create(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K] { + const el = window.document.createElement(tagName); + if (className !== undefined) el.className = className; + if (container) container.appendChild(el); + return el; + } + + public static createNS(namespaceURI: string, tagName: string) { + const el = window.document.createElementNS(namespaceURI, tagName); + return el; + } + + public static disableDrag() { + if (DOM.docStyle && DOM.selectProp) { + DOM.userSelect = DOM.docStyle[DOM.selectProp]; + DOM.docStyle[DOM.selectProp] = 'none'; + } + } + + public static enableDrag() { + if (DOM.docStyle && DOM.selectProp) { + DOM.docStyle[DOM.selectProp] = DOM.userSelect; + } + } + + public static setTransform(el: HTMLElement, value: string) { + el.style[DOM.transformProp] = value; + } + + public static addEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: { + passive?: boolean; + capture?: boolean; + } = {}) { + if ('passive' in options) { + target.addEventListener(type, callback, options); + } else { + target.addEventListener(type, callback, options.capture); + } + } + + public static removeEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options: { + passive?: boolean; + capture?: boolean; + } = {}) { + if ('passive' in options) { + target.removeEventListener(type, callback, options); + } else { + target.removeEventListener(type, callback, options.capture); + } + } + + // Suppress the next click, but only if it's immediate. + private static suppressClickInternal(e) { + e.preventDefault(); + e.stopPropagation(); + window.removeEventListener('click', DOM.suppressClickInternal, true); + } + + public static suppressClick() { + window.addEventListener('click', DOM.suppressClickInternal, true); + window.setTimeout(() => { + window.removeEventListener('click', DOM.suppressClickInternal, true); + }, 0); + } + + public static mousePos(el: HTMLElement, e: MouseEvent | Touch) { + const rect = el.getBoundingClientRect(); + return new Point( + e.clientX - rect.left - el.clientLeft, + e.clientY - rect.top - el.clientTop + ); + } + + public static touchPos(el: HTMLElement, touches: TouchList) { + const rect = el.getBoundingClientRect(); + const points: Point[] = []; + for (let i = 0; i < touches.length; i++) { + points.push(new Point( + touches[i].clientX - rect.left - el.clientLeft, + touches[i].clientY - rect.top - el.clientTop + )); + } + return points; + } + + public static mouseButton(e: MouseEvent) { + return e.button; + } + + public static remove(node: HTMLElement) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } +} diff --git a/web/libraries/maplibre-gl/src/util/evented.test.ts b/web/libraries/maplibre-gl/src/util/evented.test.ts new file mode 100644 index 00000000..90883ec8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/evented.test.ts @@ -0,0 +1,232 @@ +import {Event, Evented} from './evented'; + +describe('Evented', () => { + + test('calls listeners added with "on"', () => { + const evented = new Evented(); + const listener = jest.fn(); + evented.on('a', listener); + evented.fire(new Event('a')); + evented.fire(new Event('a')); + expect(listener).toHaveBeenCalledTimes(2); + }); + + test('calls listeners added with "once" once', () => { + const evented = new Evented(); + const listener = jest.fn(); + evented.once('a', listener); + evented.fire(new Event('a')); + evented.fire(new Event('a')); + expect(listener).toHaveBeenCalledTimes(1); + expect(evented.listens('a')).toBeFalsy(); + + }); + + test('returns a promise when no listener is provided to "once" method', async () => { + const evented = new Evented(); + const promise = evented.once('a'); + evented.fire(new Event('a')); + evented.fire(new Event('a')); + await promise; + expect(evented.listens('a')).toBeFalsy(); + + }); + + test('passes data to listeners', () => { + const evented = new Evented(); + evented.on('a', (data) => { + expect(data.foo).toBe('bar'); + }); + evented.fire(new Event('a', {foo: 'bar'})); + + }); + + test('passes "target" to listeners', () => { + const evented = new Evented(); + evented.on('a', (data) => { + expect(data.target).toBe(evented); + }); + evented.fire(new Event('a')); + + }); + + test('passes "type" to listeners', () => { + const evented = new Evented(); + evented.on('a', (data) => { + expect(data.type).toBe('a'); + }); + evented.fire(new Event('a')); + + }); + + test('removes listeners with "off"', () => { + const evented = new Evented(); + const listener = jest.fn(); + evented.on('a', listener); + evented.off('a', listener); + evented.fire(new Event('a')); + expect(listener).not.toHaveBeenCalled(); + }); + + test('removes one-time listeners with "off"', () => { + const evented = new Evented(); + const listener = jest.fn(); + evented.once('a', listener); + evented.off('a', listener); + evented.fire(new Event('a')); + expect(listener).not.toHaveBeenCalled(); + }); + + test('once listener is removed prior to call', () => { + const evented = new Evented(); + const listener = jest.fn(); + evented.once('a', () => { + listener(); + evented.fire(new Event('a')); + }); + evented.fire(new Event('a')); + expect(listener).toHaveBeenCalledTimes(1); + }); + + test('reports if an event has listeners with "listens"', () => { + const evented = new Evented(); + evented.on('a', () => {}); + expect(evented.listens('a')).toBeTruthy(); + expect(evented.listens('b')).toBeFalsy(); + + }); + + test('does not report true to "listens" if all listeners have been removed', () => { + const evented = new Evented(); + const listener = () => {}; + evented.on('a', listener); + evented.off('a', listener); + expect(evented.listens('a')).toBeFalsy(); + + }); + + test('does not immediately call listeners added within another listener', done => { + const evented = new Evented(); + evented.on('a', () => { + evented.on('a', () => done('fail')); + }); + evented.fire(new Event('a')); + done(); + }); + + test('has backward compatibility for fire(string, object) API', () => { + const evented = new Evented(); + const listener = jest.fn(x => x); + evented.on('a', listener); + evented.fire('a' as any as Event, {foo: 'bar'}); + expect(listener).toHaveBeenCalledTimes(1); + expect(listener.mock.calls[0][0].foo).toBe('bar'); + + }); + + test('on is idempotent', () => { + const evented = new Evented(); + const order = []; + const listenerA = jest.fn(() => order.push('A')); + const listenerB = jest.fn(() => order.push('B')); + evented.on('a', listenerA); + evented.on('a', listenerB); + evented.on('a', listenerA); + evented.fire(new Event('a')); + expect(listenerA).toHaveBeenCalledTimes(1); + expect(order).toEqual(['A', 'B']); + + }); +}); + +describe('evented parents', () => { + + test('adds parents with "setEventedParent"', () => { + const listener = jest.fn(); + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSource.setEventedParent(eventedSink); + eventedSink.on('a', listener); + eventedSource.fire(new Event('a')); + eventedSource.fire(new Event('a')); + expect(listener).toHaveBeenCalledTimes(2); + }); + + test('passes original data to parent listeners', () => { + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSource.setEventedParent(eventedSink); + eventedSink.on('a', (data) => { + expect(data.foo).toBe('bar'); + }); + eventedSource.fire(new Event('a', {foo: 'bar'})); + + }); + + test('attaches parent data to parent listeners', () => { + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSource.setEventedParent(eventedSink, {foz: 'baz'}); + eventedSink.on('a', (data) => { + expect(data.foz).toBe('baz'); + }); + eventedSource.fire(new Event('a', {foo: 'bar'})); + + }); + + test('attaches parent data from a function to parent listeners', () => { + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSource.setEventedParent(eventedSink, () => ({foz: 'baz'})); + eventedSink.on('a', (data) => { + expect(data.foz).toBe('baz'); + }); + eventedSource.fire(new Event('a', {foo: 'bar'})); + + }); + + test('passes original "target" to parent listeners', () => { + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSource.setEventedParent(eventedSink); + eventedSource.setEventedParent(null); + eventedSink.on('a', (data) => { + expect(data.target).toBe(eventedSource); + }); + eventedSource.fire(new Event('a')); + + }); + + test('removes parents with "setEventedParent(null)"', () => { + const listener = jest.fn(); + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSink.on('a', listener); + eventedSource.setEventedParent(eventedSink); + eventedSource.setEventedParent(null); + eventedSource.fire(new Event('a')); + expect(listener).not.toHaveBeenCalled(); + }); + + test('reports if an event has parent listeners with "listens"', () => { + const eventedSource = new Evented(); + const eventedSink = new Evented(); + eventedSink.on('a', () => {}); + eventedSource.setEventedParent(eventedSink); + expect(eventedSink.listens('a')).toBeTruthy(); + + }); + + test('eventedParent data function is evaluated on every fire', () => { + const eventedSource = new Evented(); + const eventedParent = new Evented(); + let i = 0; + eventedSource.setEventedParent(eventedParent, () => i++); + eventedSource.on('a', () => {}); + eventedSource.fire(new Event('a')); + expect(i).toBe(1); + eventedSource.fire(new Event('a')); + expect(i).toBe(2); + + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/evented.ts b/web/libraries/maplibre-gl/src/util/evented.ts new file mode 100644 index 00000000..062e49cc --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/evented.ts @@ -0,0 +1,181 @@ +import {extend} from './util'; + +/** + * A listener method used as a callback to events + */ +export type Listener = (a: any) => any; + +type Listeners = {[_: string]: Array}; + +function _addEventListener(type: string, listener: Listener, listenerList: Listeners) { + const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1; + if (!listenerExists) { + listenerList[type] = listenerList[type] || []; + listenerList[type].push(listener); + } +} + +function _removeEventListener(type: string, listener: Listener, listenerList: Listeners) { + if (listenerList && listenerList[type]) { + const index = listenerList[type].indexOf(listener); + if (index !== -1) { + listenerList[type].splice(index, 1); + } + } +} + +/** + * The event class + */ +export class Event { + readonly type: string; + + constructor(type: string, data: any = {}) { + extend(this, data); + this.type = type; + } +} + +interface ErrorLike { + message: string; +} + +/** + * An error event + */ +export class ErrorEvent extends Event { + error: ErrorLike; + + constructor(error: ErrorLike, data: any = {}) { + super('error', extend({error}, data)); + } +} + +/** + * Methods mixed in to other classes for event capabilities. + * + * @group Event Related + */ +export class Evented { + _listeners: Listeners; + _oneTimeListeners: Listeners; + _eventedParent: Evented; + _eventedParentData: any | (() => any); + + /** + * Adds a listener to a specified event type. + * + * @param type - The event type to add a listen for. + * @param listener - The function to be called when the event is fired. + * The listener function is called with the data object passed to `fire`, + * extended with `target` and `type` properties. + * @returns `this` + */ + on(type: string, listener: Listener): this { + this._listeners = this._listeners || {}; + _addEventListener(type, listener, this._listeners); + + return this; + } + + /** + * Removes a previously registered event listener. + * + * @param type - The event type to remove listeners for. + * @param listener - The listener function to remove. + * @returns `this` + */ + off(type: string, listener: Listener) { + _removeEventListener(type, listener, this._listeners); + _removeEventListener(type, listener, this._oneTimeListeners); + + return this; + } + + /** + * Adds a listener that will be called only once to a specified event type. + * + * The listener will be called first time the event fires after the listener is registered. + * + * @param type - The event type to listen for. + * @param listener - The function to be called when the event is fired the first time. + * @returns `this` or a promise if a listener is not provided + */ + once(type: string, listener?: Listener): this | Promise { + if (!listener) { + return new Promise((resolve) => this.once(type, resolve)); + } + this._oneTimeListeners = this._oneTimeListeners || {}; + _addEventListener(type, listener, this._oneTimeListeners); + + return this; + } + + fire(event: Event | string, properties?: any) { + // Compatibility with (type: string, properties: Object) signature from previous versions. + // See https://github.com/mapbox/mapbox-gl-js/issues/6522, + // https://github.com/mapbox/mapbox-gl-draw/issues/766 + if (typeof event === 'string') { + event = new Event(event, properties || {}); + } + + const type = event.type; + + if (this.listens(type)) { + (event as any).target = this; + + // make sure adding or removing listeners inside other listeners won't cause an infinite loop + const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : []; + for (const listener of listeners) { + listener.call(this, event); + } + + const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : []; + for (const listener of oneTimeListeners) { + _removeEventListener(type, listener, this._oneTimeListeners); + listener.call(this, event); + } + + const parent = this._eventedParent; + if (parent) { + extend( + event, + typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData + ); + parent.fire(event); + } + + // To ensure that no error events are dropped, print them to the + // console if they have no listeners. + } else if (event instanceof ErrorEvent) { + console.error(event.error); + } + + return this; + } + + /** + * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type. + * + * @param type - The event type + * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise + */ + listens(type: string): boolean { + return ( + (this._listeners && this._listeners[type] && this._listeners[type].length > 0) || + (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) || + (this._eventedParent && this._eventedParent.listens(type)) + ); + } + + /** + * Bubble all events fired by this instance of Evented to this parent instance of Evented. + * @returns `this` + */ + setEventedParent(parent?: Evented | null, data?: any | (() => any)) { + this._eventedParent = parent; + this._eventedParentData = data; + + return this; + } +} diff --git a/web/libraries/maplibre-gl/src/util/find_pole_of_inaccessibility.test.ts b/web/libraries/maplibre-gl/src/util/find_pole_of_inaccessibility.test.ts new file mode 100644 index 00000000..dfea4f0e --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/find_pole_of_inaccessibility.test.ts @@ -0,0 +1,21 @@ +import Point from '@mapbox/point-geometry'; +import {findPoleOfInaccessibility} from './find_pole_of_inaccessibility'; + +test('polygon_poi', () => { + + const closedRing = [ + new Point(0, 0), + new Point(10, 10), + new Point(10, 0), + new Point(0, 0) + ]; + const closedRingHole = [ + new Point(2, 1), + new Point(6, 6), + new Point(6, 1), + new Point(2, 1) + ]; + expect(findPoleOfInaccessibility([closedRing], 0.1)).toEqual(new Point(7.0703125, 2.9296875)); + expect(findPoleOfInaccessibility([closedRing, closedRingHole], 0.1)).toEqual(new Point(7.96875, 2.03125)); + +}); diff --git a/web/libraries/maplibre-gl/src/util/find_pole_of_inaccessibility.ts b/web/libraries/maplibre-gl/src/util/find_pole_of_inaccessibility.ts new file mode 100644 index 00000000..dfc2cdc1 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/find_pole_of_inaccessibility.ts @@ -0,0 +1,130 @@ +import Queue from 'tinyqueue'; + +import Point from '@mapbox/point-geometry'; +import {distToSegmentSquared} from './intersection_tests'; + +/** + * Finds an approximation of a polygon's Pole Of Inaccessibiliy https://en.wikipedia.org/wiki/Pole_of_inaccessibility + * This is a copy of http://github.com/mapbox/polylabel adapted to use Points + * + * @param polygonRings - first item in array is the outer ring followed optionally by the list of holes, should be an element of the result of util/classify_rings + * @param precision - Specified in input coordinate units. If 0 returns after first run, if `> 0` repeatedly narrows the search space until the radius of the area searched for the best pole is less than precision + * @param debug - Print some statistics to the console during execution + * @returns Pole of Inaccessibiliy. + */ +export function findPoleOfInaccessibility( + polygonRings: Array>, + precision: number = 1, + debug: boolean = false +): Point { + // find the bounding box of the outer ring + let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity; + const outerRing = polygonRings[0]; + for (let i = 0; i < outerRing.length; i++) { + const p = outerRing[i]; + if (!i || p.x < minX) minX = p.x; + if (!i || p.y < minY) minY = p.y; + if (!i || p.x > maxX) maxX = p.x; + if (!i || p.y > maxY) maxY = p.y; + } + + const width = maxX - minX; + const height = maxY - minY; + const cellSize = Math.min(width, height); + let h = cellSize / 2; + + // a priority queue of cells in order of their "potential" (max distance to polygon) + const cellQueue = new Queue([], compareMax); + + if (cellSize === 0) return new Point(minX, minY); + + // cover polygon with initial cells + for (let x = minX; x < maxX; x += cellSize) { + for (let y = minY; y < maxY; y += cellSize) { + cellQueue.push(new Cell(x + h, y + h, h, polygonRings)); + } + } + + // take centroid as the first best guess + let bestCell = getCentroidCell(polygonRings); + let numProbes = cellQueue.length; + + while (cellQueue.length) { + // pick the most promising cell from the queue + const cell = cellQueue.pop(); + + // update the best cell if we found a better one + if (cell.d > bestCell.d || !bestCell.d) { + bestCell = cell; + if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes); + } + + // do not drill down further if there's no chance of a better solution + if (cell.max - bestCell.d <= precision) continue; + + // split the cell into four cells + h = cell.h / 2; + cellQueue.push(new Cell(cell.p.x - h, cell.p.y - h, h, polygonRings)); + cellQueue.push(new Cell(cell.p.x + h, cell.p.y - h, h, polygonRings)); + cellQueue.push(new Cell(cell.p.x - h, cell.p.y + h, h, polygonRings)); + cellQueue.push(new Cell(cell.p.x + h, cell.p.y + h, h, polygonRings)); + numProbes += 4; + } + + if (debug) { + console.log(`num probes: ${numProbes}`); + console.log(`best distance: ${bestCell.d}`); + } + + return bestCell.p; +} + +function compareMax(a, b) { + return b.max - a.max; +} + +function Cell(x, y, h, polygon) { + this.p = new Point(x, y); + this.h = h; // half the cell size + this.d = pointToPolygonDist(this.p, polygon); // distance from cell center to polygon + this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell +} + +// signed distance from point to polygon outline (negative if point is outside) +function pointToPolygonDist(p, polygon) { + let inside = false; + let minDistSq = Infinity; + + for (let k = 0; k < polygon.length; k++) { + const ring = polygon[k]; + + for (let i = 0, len = ring.length, j = len - 1; i < len; j = i++) { + const a = ring[i]; + const b = ring[j]; + + if ((a.y > p.y !== b.y > p.y) && + (p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x)) inside = !inside; + + minDistSq = Math.min(minDistSq, distToSegmentSquared(p, a, b)); + } + } + + return (inside ? 1 : -1) * Math.sqrt(minDistSq); +} + +// get polygon centroid +function getCentroidCell(polygon) { + let area = 0; + let x = 0; + let y = 0; + const points = polygon[0]; + for (let i = 0, len = points.length, j = len - 1; i < len; j = i++) { + const a = points[i]; + const b = points[j]; + const f = a.x * b.y - b.x * a.y; + x += (a.x + b.x) * f; + y += (a.y + b.y) * f; + area += f * 3; + } + return new Cell(x / area, y / area, 0, polygon); +} diff --git a/web/libraries/maplibre-gl/src/util/geolocation_support.test.ts b/web/libraries/maplibre-gl/src/util/geolocation_support.test.ts new file mode 100644 index 00000000..7641a404 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/geolocation_support.test.ts @@ -0,0 +1,55 @@ +import {checkGeolocationSupport} from './geolocation_support'; + +describe('checkGeolocationSupport', () => { + beforeEach(() => { + jest.resetModules(); + }); + + test('it should return false if geolocation is not defined', done => { + checkGeolocationSupport((returnValue: boolean) => { + expect(returnValue).toBeFalsy(); + done(); + }); + }); + + test('it should return the cached value on second call', done => { + checkGeolocationSupport((returnValue) => { + expect(returnValue).toBeFalsy(); + (window.navigator as any).geolocation = {}; + checkGeolocationSupport((rv) => { + expect(rv).toBe(returnValue); + done(); + }); + }); + }); + + test('it should return the true if geolocation is defined', done => { + (window.navigator as any).geolocation = {}; + checkGeolocationSupport((returnValue) => { + expect(returnValue).toBeTruthy(); + done(); + }, true); + }); + + test('it should check permissions if possible', done => { + (window.navigator as any).geolocation = {}; + (window.navigator as any).permissions = { + query: () => Promise.resolve({state: 'granted'}) + }; + checkGeolocationSupport((returnValue) => { + expect(returnValue).toBeTruthy(); + done(); + }, true); + }); + + test('it should check permissions and geolocation for iOS 16 promise rejection', done => { + (window.navigator as any).geolocation = undefined; + (window.navigator as any).permissions = { + query: () => Promise.reject(new Error('pemissions error')) + }; + checkGeolocationSupport((returnValue) => { + expect(returnValue).toBeFalsy(); + done(); + }, true); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/geolocation_support.ts b/web/libraries/maplibre-gl/src/util/geolocation_support.ts new file mode 100644 index 00000000..d64940a0 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/geolocation_support.ts @@ -0,0 +1,24 @@ +let supportsGeolocation; + +export function checkGeolocationSupport(callback: (supported: boolean) => void, forceRecalculation = false): void { + if (supportsGeolocation !== undefined && !forceRecalculation) { + callback(supportsGeolocation); + } else if (window.navigator.permissions !== undefined) { + // navigator.permissions has incomplete browser support + // http://caniuse.com/#feat=permissions-api + // Test for the case where a browser disables Geolocation because of an + // insecure origin + window.navigator.permissions.query({name: 'geolocation'}).then((p) => { + supportsGeolocation = p.state !== 'denied'; + callback(supportsGeolocation); + }).catch(() => { + // Fix for iOS16 which rejects query but still supports geolocation + supportsGeolocation = !!window.navigator.geolocation; + callback(supportsGeolocation); + }); + + } else { + supportsGeolocation = !!window.navigator.geolocation; + callback(supportsGeolocation); + } +} diff --git a/web/libraries/maplibre-gl/src/util/global_worker_pool.ts b/web/libraries/maplibre-gl/src/util/global_worker_pool.ts new file mode 100644 index 00000000..e6a3c28b --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/global_worker_pool.ts @@ -0,0 +1,32 @@ +import {WorkerPool, PRELOAD_POOL_ID} from './worker_pool'; + +let globalWorkerPool; + +/** + * Creates (if necessary) and returns the single, global WorkerPool instance + * to be shared across each Map + */ +export function getGlobalWorkerPool() { + if (!globalWorkerPool) { + globalWorkerPool = new WorkerPool(); + } + return globalWorkerPool; +} + +export function prewarm() { + const workerPool = getGlobalWorkerPool(); + workerPool.acquire(PRELOAD_POOL_ID); +} + +export function clearPrewarmedResources() { + const pool = globalWorkerPool; + if (pool) { + // Remove the pool only if all maps that referenced the preloaded global worker pool have been removed. + if (pool.isPreloaded() && pool.numActive() === 1) { + pool.release(PRELOAD_POOL_ID); + globalWorkerPool = null; + } else { + console.warn('Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()'); + } + } +} diff --git a/web/libraries/maplibre-gl/src/util/image.ts b/web/libraries/maplibre-gl/src/util/image.ts new file mode 100644 index 00000000..27b13c81 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/image.ts @@ -0,0 +1,151 @@ +import {register} from './web_worker_transfer'; + +export type Size = { + width: number; + height: number; +}; + +type Point2D = { + x: number; + y: number; +}; + +function createImage(image: any, { + width, + height +}: Size, channels: number, data?: Uint8Array | Uint8ClampedArray) { + if (!data) { + data = new Uint8Array(width * height * channels); + } else if (data instanceof Uint8ClampedArray) { + data = new Uint8Array(data.buffer); + } else if (data.length !== width * height * channels) { + throw new RangeError(`mismatched image size. expected: ${data.length} but got: ${width * height * channels}`); + } + image.width = width; + image.height = height; + image.data = data; + return image; +} + +function resizeImage(image: any, { + width, + height +}: Size, channels: number) { + if (width === image.width && height === image.height) { + return; + } + + const newImage = createImage({}, {width, height}, channels); + + copyImage(image, newImage, {x: 0, y: 0}, {x: 0, y: 0}, { + width: Math.min(image.width, width), + height: Math.min(image.height, height) + }, channels); + + image.width = width; + image.height = height; + image.data = newImage.data; +} + +function copyImage(srcImg: any, dstImg: any, srcPt: Point2D, dstPt: Point2D, size: Size, channels: number) { + if (size.width === 0 || size.height === 0) { + return dstImg; + } + + if (size.width > srcImg.width || + size.height > srcImg.height || + srcPt.x > srcImg.width - size.width || + srcPt.y > srcImg.height - size.height) { + throw new RangeError('out of range source coordinates for image copy'); + } + + if (size.width > dstImg.width || + size.height > dstImg.height || + dstPt.x > dstImg.width - size.width || + dstPt.y > dstImg.height - size.height) { + throw new RangeError('out of range destination coordinates for image copy'); + } + + const srcData = srcImg.data; + const dstData = dstImg.data; + + if (srcData === dstData) throw new Error('srcData equals dstData, so image is already copied'); + + for (let y = 0; y < size.height; y++) { + const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels; + const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels; + for (let i = 0; i < size.width * channels; i++) { + dstData[dstOffset + i] = srcData[srcOffset + i]; + } + } + return dstImg; +} + +/** + * @internal + * An image with alpha color value + */ +export class AlphaImage { + width: number; + height: number; + data: Uint8Array; + + constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) { + createImage(this, size, 1, data); + } + + resize(size: Size) { + resizeImage(this, size, 1); + } + + clone() { + return new AlphaImage({width: this.width, height: this.height}, new Uint8Array(this.data)); + } + + static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size) { + copyImage(srcImg, dstImg, srcPt, dstPt, size, 1); + } +} + +/** + * An object to store image data not premultiplied, because ImageData is not premultiplied. + * UNPACK_PREMULTIPLY_ALPHA_WEBGL must be used when uploading to a texture. + */ +export class RGBAImage { + width: number; + height: number; + + /** + * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers. + */ + data: Uint8Array; + + constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) { + createImage(this, size, 4, data); + } + + resize(size: Size) { + resizeImage(this, size, 4); + } + + replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean) { + if (copy) { + this.data.set(data); + } else if (data instanceof Uint8ClampedArray) { + this.data = new Uint8Array(data.buffer); + } else { + this.data = data; + } + } + + clone() { + return new RGBAImage({width: this.width, height: this.height}, new Uint8Array(this.data)); + } + + static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size) { + copyImage(srcImg, dstImg, srcPt, dstPt, size, 4); + } +} + +register('AlphaImage', AlphaImage); +register('RGBAImage', RGBAImage); diff --git a/web/libraries/maplibre-gl/src/util/image_request.test.ts b/web/libraries/maplibre-gl/src/util/image_request.test.ts new file mode 100644 index 00000000..b1f97248 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/image_request.test.ts @@ -0,0 +1,413 @@ +import {config} from './config'; +import {webpSupported} from './webp_supported'; +import {stubAjaxGetImage} from './test/util'; +import {fakeServer, type FakeServer} from 'nise'; +import {ImageRequest, ImageRequestQueueItem} from './image_request'; +import * as ajax from './ajax'; + +describe('ImageRequest', () => { + let server: FakeServer; + beforeEach(() => { + global.fetch = null; + server = fakeServer.create(); + ImageRequest.resetRequestQueue(); + stubAjaxGetImage(undefined); + }); + afterEach(() => { + server.restore(); + }); + + test('getImage respects maxParallelImageRequests', done => { + server.respondWith(request => request.respond(200, {'Content-Type': 'image/png'}, '')); + + const maxRequests = config.MAX_PARALLEL_IMAGE_REQUESTS; + let callbackCount = 0; + function callback(err) { + if (err) return; + // last request is only added after we got a response from one of the previous ones + expect(server.requests).toHaveLength(maxRequests + callbackCount); + callbackCount++; + if (callbackCount === 2) { + done(); + } + } + + for (let i = 0; i < maxRequests + 1; i++) { + ImageRequest.getImage({url: ''}, callback); + } + expect(server.requests).toHaveLength(maxRequests); + + server.requests[0].respond(undefined, undefined, undefined); + server.requests[1].respond(undefined, undefined, undefined); + }); + test('Cancel: getImage cancelling frees up request for maxParallelImageRequests', done => { + server.respondWith(request => request.respond(200, {'Content-Type': 'image/png'}, '')); + + const maxRequests = config.MAX_PARALLEL_IMAGE_REQUESTS; + + for (let i = 0; i < maxRequests + 1; i++) { + ImageRequest.getImage({url: ''}, () => done('test failed: getImage callback was called')).cancel(); + } + expect(server.requests).toHaveLength(maxRequests + 1); + done(); + }); + + test('Cancel: getImage requests that were once queued are still abortable', done => { + const maxRequests = config.MAX_PARALLEL_IMAGE_REQUESTS; + + const requests = []; + for (let i = 0; i < maxRequests; i++) { + requests.push(ImageRequest.getImage({url: ''}, () => {})); + } + + // the limit of allowed requests is reached + expect(server.requests).toHaveLength(maxRequests); + + const queuedURL = 'this-is-the-queued-request'; + const queued = ImageRequest.getImage({url: queuedURL}, () => done('test failed: getImage callback was called')); + + // the new requests is queued because the limit is reached + expect(server.requests).toHaveLength(maxRequests); + + // cancel the first request to let the queued request start + requests[0].cancel(); + expect(server.requests).toHaveLength(maxRequests + 1); + + // abort the previously queued request and confirm that it is aborted + const queuedRequest = server.requests[server.requests.length - 1]; + expect(queuedRequest.url).toBe(queuedURL); + expect((queuedRequest as any).aborted).toBeUndefined(); + queued.cancel(); + expect((queuedRequest as any).aborted).toBe(true); + + done(); + }); + + test('getImage sends accept/webp when supported', done => { + server.respondWith((request) => { + expect(request.requestHeaders.accept.includes('image/webp')).toBeTruthy(); + request.respond(200, {'Content-Type': 'image/webp'}, ''); + }); + + // mock webp support + webpSupported.supported = true; + + ImageRequest.getImage({url: ''}, () => { done(); }); + + server.respond(); + }); + + test('getImage uses createImageBitmap when supported', done => { + server.respondWith(request => request.respond(200, {'Content-Type': 'image/png', + 'Cache-Control': 'cache', + 'Expires': 'expires'}, '')); + + stubAjaxGetImage(() => Promise.resolve(new ImageBitmap())); + + ImageRequest.getImage({url: ''}, (err, img, expiry) => { + if (err) done(err); + expect(img).toBeInstanceOf(ImageBitmap); + expect(expiry.cacheControl).toBe('cache'); + expect(expiry.expires).toBe('expires'); + done(); + }); + + server.respond(); + }); + + test('getImage using createImageBitmap throws exception', done => { + server.respondWith(request => request.respond(200, {'Content-Type': 'image/png', + 'Cache-Control': 'cache', + 'Expires': 'expires'}, '')); + + stubAjaxGetImage(() => Promise.reject(new Error('error'))); + + ImageRequest.getImage({url: ''}, (err, img) => { + expect(img).toBeFalsy(); + if (err) done(); + }); + + server.respond(); + }); + + test('getImage uses HTMLImageElement when createImageBitmap is not supported', done => { + const makeRequestSky = jest.spyOn(ajax, 'makeRequest'); + server.respondWith(request => request.respond(200, {'Content-Type': 'image/png', + 'Cache-Control': 'cache', + 'Expires': 'expires'}, '')); + + ImageRequest.getImage({url: ''}, (err, img, expiry) => { + if (err) done(`get image failed with error ${err.message}`); + expect(img).toBeInstanceOf(HTMLImageElement); + expect(expiry.cacheControl).toBe('cache'); + expect(expiry.expires).toBe('expires'); + done(); + }); + + server.respond(); + expect(makeRequestSky).toHaveBeenCalledTimes(1); + makeRequestSky.mockClear(); + }); + + test('getImage using HTMLImageElement with same-origin credentials', done => { + const makeRequestSky = jest.spyOn(ajax, 'makeRequest'); + ImageRequest.getImage({url: '', credentials: 'same-origin'}, (err, img: HTMLImageElement) => { + if (err) done(err); + expect(img).toBeInstanceOf(HTMLImageElement); + expect(img.crossOrigin).toBe('anonymous'); + done(); + }, false); + + expect(makeRequestSky).toHaveBeenCalledTimes(0); + makeRequestSky.mockClear(); + }); + + test('getImage using HTMLImageElement with include credentials', done => { + const makeRequestSky = jest.spyOn(ajax, 'makeRequest'); + ImageRequest.getImage({url: '', credentials: 'include'}, (err, img: HTMLImageElement) => { + if (err) done(err); + expect(img).toBeInstanceOf(HTMLImageElement); + expect(img.crossOrigin).toBe('use-credentials'); + done(); + }, false); + + expect(makeRequestSky).toHaveBeenCalledTimes(0); + makeRequestSky.mockClear(); + }); + + test('getImage using HTMLImageElement with accept header', done => { + const makeRequestSky = jest.spyOn(ajax, 'makeRequest'); + ImageRequest.getImage({url: '', credentials: 'include', headers: {accept: 'accept'}}, + (err, img: HTMLImageElement) => { + if (err) done(err); + expect(img).toBeInstanceOf(HTMLImageElement); + expect(img.crossOrigin).toBe('use-credentials'); + done(); + }, false); + + expect(makeRequestSky).toHaveBeenCalledTimes(0); + makeRequestSky.mockClear(); + }); + + test('getImage uses makeRequest when custom Headers are added', () => { + const makeRequestSky = jest.spyOn(ajax, 'makeRequest'); + + ImageRequest.getImage({url: '', credentials: 'include', headers: {custom: 'test', accept: 'image'}}, + () => {}, + false); + + expect(makeRequestSky).toHaveBeenCalledTimes(1); + makeRequestSky.mockClear(); + }); + + test('getImage request returned 404 response for fetch request', done => { + server.respondWith(request => request.respond(404)); + + ImageRequest.getImage({url: ''}, (err) => { + if (err) done(); + else done('Image download should have failed'); + }); + + server.respond(); + }); + + test('getImage request failed for HTTPImageRequest', done => { + ImageRequest.getImage({url: 'error'}, (err) => { + if (err) done(); + else done('Image download should have failed'); + }, false); + }); + + test('Cancel: getImage request cancelled for HTTPImageRequest', done => { + let imageUrl; + const requestUrl = 'test'; + // eslint-disable-next-line accessor-pairs + Object.defineProperty(global.Image.prototype, 'src', { + set(url: string) { + imageUrl = url; + } + }); + + const request = ImageRequest.getImage({url: requestUrl}, () => { + done('Callback should not be called in case image request is cancelled'); + }, false); + + expect(imageUrl).toBe(requestUrl); + expect(request.cancelled).toBeFalsy(); + request.cancel(); + expect(request.cancelled).toBeTruthy(); + expect(imageUrl).toBe(''); + done(); + }); + + test('Cancel: getImage request cancelled', done => { + server.respondWith(request => request.respond(200, {'Content-Type': 'image/png', + 'Cache-Control': 'cache', + 'Expires': 'expires'}, '')); + + const request = ImageRequest.getImage({url: ''}, () => { + done('Callback should not be called in case image request is cancelled'); + }); + + expect(request.cancelled).toBeFalsy(); + request.cancel(); + expect(request.cancelled).toBeTruthy(); + + server.respond(); + done(); + }); + + test('Cancel: Cancellation of an image which has not yet been requested', () => { + const maxRequests = config.MAX_PARALLEL_IMAGE_REQUESTS; + + let callbackCounter = 0; + function callback() { + callbackCounter++; + } + const requests: ImageRequestQueueItem[] = []; + for (let i = 0; i < maxRequests + 100; i++) { + requests.push(ImageRequest.getImage({url: `${i}`}, callback)); + } + + // Request should have been initiated + expect(requests[0].innerRequest).toBeDefined(); + requests[0].cancel(); + + // Queue should move forward and next request is made + expect(server.requests).toHaveLength(maxRequests + 1); + + // Cancel request should not call callback + expect(callbackCounter).toBe(0); + + // Cancel request which is not yet issued. It should not fire callback + const nextRequestInQueue = requests[server.requests.length]; + expect(nextRequestInQueue.innerRequest).toBeUndefined(); + const cancelledImageUrl = nextRequestInQueue.requestParameters.url; + nextRequestInQueue.cancel(); + + // Queue should not move forward as cancelled image was sitting in queue + expect(server.requests).toHaveLength(maxRequests + 1); + expect(callbackCounter).toBe(0); + + // On server response, next image queued should not be the cancelled image + server.requests[1].respond(200); + expect(callbackCounter).toBe(1); + expect(server.requests).toHaveLength(maxRequests + 2); + // Verify that the last request made skipped the cancelled image request + expect(server.requests[server.requests.length - 1].url).toBe((parseInt(cancelledImageUrl) + 1).toString()); + }); + + test('throttling: one throttling client will result in throttle behavior for all', () => { + const maxRequestsPerFrame = config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME; + const callbackHandles = []; + + // add one for each + callbackHandles.push(ImageRequest.addThrottleControl(() => false)); + callbackHandles.push(ImageRequest.addThrottleControl(() => true)); + + let callbackCounter = 0; + function callback() { + callbackCounter++; + } + + for (let i = 0; i < maxRequestsPerFrame + 1; i++) { + ImageRequest.getImage({url: ''}, callback); + } + + expect(server.requests).toHaveLength(maxRequestsPerFrame); + + // all pending + expect(callbackCounter).toBe(0); + + for (const handle of callbackHandles) { + ImageRequest.removeThrottleControl(handle); + } + }); + + test('throttling: image queue will process MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME if throttling control returns true', () => { + const maxRequestsPerFrame = config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME; + const maxRequests = config.MAX_PARALLEL_IMAGE_REQUESTS; + const controlId = ImageRequest.addThrottleControl(() => true); + + let callbackCounter = 0; + function callback() { + callbackCounter++; + } + + for (let i = 0; i < maxRequests; i++) { + ImageRequest.getImage({url: ''}, callback); + } + + // Should only fire request to a max allowed per frame + expect(server.requests).toHaveLength(maxRequestsPerFrame); + + // all pending + expect(callbackCounter).toBe(0); + + ImageRequest.removeThrottleControl(controlId); + }); + + test('throttling: image queue will process MAX_PARALLEL_IMAGE_REQUESTS if throttling control returns false', () => { + const maxRequests = config.MAX_PARALLEL_IMAGE_REQUESTS; + const controlId = ImageRequest.addThrottleControl(() => false); + + let callbackCounter = 0; + function callback() { + callbackCounter++; + } + + for (let i = 0; i < maxRequests + 100; i++) { + ImageRequest.getImage({url: ''}, callback); + } + + // all should be processed because throttle control is returning false + expect(server.requests).toHaveLength(maxRequests); + + // all pending + expect(callbackCounter).toBe(0); + + ImageRequest.removeThrottleControl(controlId); + }); + + test('throttling: removing throttling client will process all requests', () => { + const requestParameter = {'Content-Type': 'image/png', url: ''}; + const maxRequestsPerFrame = config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME; + + // add 10, and one of them is throttling + const throttlingIndex = 5; + for (let i = 0; i < 10; i++) { + const throttlingClient: boolean = (i === throttlingIndex); + ImageRequest.addThrottleControl(() => throttlingClient); + } + + let callbackCounter = 0; + function callback() { + callbackCounter++; + } + + // make 2 times + 1 more requests + const requestsMade = 2 * maxRequestsPerFrame + 1; + const imageResults: ImageRequestQueueItem[] = []; + for (let i = 0; i < requestsMade; i++) { + imageResults.push(ImageRequest.getImage(requestParameter, callback)); + } + + // up to the config value + expect(server.requests).toHaveLength(maxRequestsPerFrame); + + const itemIndexToComplete = 6; + server.requests[itemIndexToComplete].respond(200); + + // unleash it by removing the throttling client + ImageRequest.removeThrottleControl(throttlingIndex); + expect(server.requests).toHaveLength(requestsMade); + + // all pending + expect(callbackCounter).toBe(1); + + // everything should still be pending except itemIndexToComplete + for (let i = 0; i < maxRequestsPerFrame + 1; i++) { + expect(imageResults[i].completed).toBe(i === itemIndexToComplete); + } + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/image_request.ts b/web/libraries/maplibre-gl/src/util/image_request.ts new file mode 100644 index 00000000..e00b395e --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/image_request.ts @@ -0,0 +1,288 @@ +import type {Cancelable} from '../types/cancelable'; +import {RequestParameters, ExpiryData, makeRequest, sameOrigin, getProtocolAction} from './ajax'; +import type {Callback} from '../types/callback'; + +import {arrayBufferToImageBitmap, arrayBufferToImage, extend, isWorker, isImageBitmap} from './util'; +import {webpSupported} from './webp_supported'; +import {config} from './config'; + +/** + * The callback that is being called after an image was fetched + */ +export type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void; + +type ImageQueueThrottleControlCallback = () => boolean; + +export type ImageRequestQueueItem = Cancelable & { + requestParameters: RequestParameters; + supportImageRefresh: boolean; + callback: GetImageCallback; + cancelled: boolean; + completed: boolean; + innerRequest?: Cancelable; +} + +type ImageQueueThrottleCallbackDictionary = { + [Key: number]: ImageQueueThrottleControlCallback; +} + +type HTMLImageElementWithPriority = HTMLImageElement & +{ + // fetchPriority is experimental property supported on Chromium browsers from Version 102 + // By default images are downloaded with priority low, whereas fetch request downloads with priority high + // https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority + fetchPriority?: 'auto' | 'high' | 'low'; +}; + +/** + * By default, the image queue is self driven, meaning as soon as one requested item is processed, + * it will move on to next one as quickly as it can while limiting + * the number of concurrent requests to MAX_PARALLEL_IMAGE_REQUESTS. The default behavior + * ensures that static views of the map can be rendered with minimal delay. + * + * However, the default behavior can prevent dynamic views of the map from rendering + * smoothly in that many requests can finish in one render frame, putting too much pressure on GPU. + * + * When the view of the map is moving dynamically, smoother frame rates can be achieved + * by throttling the number of items processed by the queue per frame. This can be + * accomplished by using {@link addThrottleControl} to allow the caller to + * use a lambda function to determine when the queue should be throttled (e.g. when isMoving()) + * and manually calling {@link processQueue} in the render loop. + */ +export namespace ImageRequest { + let imageRequestQueue : ImageRequestQueueItem[]; + let currentParallelImageRequests:number; + + let throttleControlCallbackHandleCounter: number; + let throttleControlCallbacks: ImageQueueThrottleCallbackDictionary; + + /** + * Reset the image request queue, removing all pending requests. + */ + export const resetRequestQueue = (): void => { + imageRequestQueue = []; + currentParallelImageRequests = 0; + throttleControlCallbackHandleCounter = 0; + throttleControlCallbacks = {}; + }; + + /** + * Install a callback to control when image queue throttling is desired. + * (e.g. when the map view is moving) + * @param callback - The callback function to install + * @returns handle that identifies the installed callback. + */ + export const addThrottleControl = (callback: ImageQueueThrottleControlCallback): number => { + const handle = throttleControlCallbackHandleCounter++; + throttleControlCallbacks[handle] = callback; + return handle; + }; + + /** + * Remove a previously installed callback by passing in the handle returned + * by {@link addThrottleControl}. + * @param callbackHandle - The handle for the callback to remove. + */ + export const removeThrottleControl = (callbackHandle: number): void => { + delete throttleControlCallbacks[callbackHandle]; + // Try updating the queue + processQueue(); + }; + + /** + * Check to see if any of the installed callbacks are requesting the queue + * to be throttled. + * @returns `true` if any callback is causing the queue to be throttled. + */ + const isThrottled = (): boolean => { + const allControlKeys = Object.keys(throttleControlCallbacks); + let throttleingRequested = false; + if (allControlKeys.length > 0) { + for (const key of allControlKeys) { + throttleingRequested = throttleControlCallbacks[key](); + if (throttleingRequested) { + break; + } + } + } + return throttleingRequested; + }; + + /** + * Request to load an image. + * @param requestParameters - Request parameters. + * @param callback - Callback to issue when the request completes. + * @param supportImageRefresh - `true`, if the image request need to support refresh based on cache headers. + * @returns Cancelable request. + */ + export const getImage = ( + requestParameters: RequestParameters, + callback: GetImageCallback, + supportImageRefresh: boolean = true + ): ImageRequestQueueItem => { + if (webpSupported.supported) { + if (!requestParameters.headers) { + requestParameters.headers = {}; + } + requestParameters.headers.accept = 'image/webp,*/*'; + } + + const request:ImageRequestQueueItem = { + requestParameters, + supportImageRefresh, + callback, + cancelled: false, + completed: false, + cancel: () => { + if (!request.completed && !request.cancelled) { + request.cancelled = true; + + // Only reduce currentParallelImageRequests, if the image request was issued. + if (request.innerRequest) { + request.innerRequest.cancel(); + currentParallelImageRequests--; + } + + // in the case of cancelling, it WILL move on + processQueue(); + } + } + }; + + imageRequestQueue.push(request); + processQueue(); + return request; + }; + + const arrayBufferToCanvasImageSource = (data: ArrayBuffer, callback: Callback) => { + const imageBitmapSupported = typeof createImageBitmap === 'function'; + if (imageBitmapSupported) { + arrayBufferToImageBitmap(data, callback); + } else { + arrayBufferToImage(data, callback); + } + }; + + const doImageRequest = (itemInQueue: ImageRequestQueueItem): Cancelable => { + const {requestParameters, supportImageRefresh, callback} = itemInQueue; + extend(requestParameters, {type: 'image'}); + + // - If refreshExpiredTiles is false, then we can use HTMLImageElement to download raster images. + // - Fetch/XHR (via MakeRequest API) will be used to download images for following scenarios: + // 1. Style image sprite will had a issue with HTMLImageElement as described + // here: https://github.com/mapbox/mapbox-gl-js/issues/1470 + // 2. If refreshExpiredTiles is true (default), then in order to read the image cache header, + // fetch/XHR request will be required + // - For any special case handling like use of AddProtocol, worker initiated request or additional headers + // let makeRequest handle it. + // - HtmlImageElement request automatically adds accept header for all the browser supported images + const canUseHTMLImageElement = supportImageRefresh === false && + !isWorker() && + !getProtocolAction(requestParameters.url) && + (!requestParameters.headers || + Object.keys(requestParameters.headers).reduce((acc, item) => acc && item === 'accept', true)); + + const action = canUseHTMLImageElement ? getImageUsingHtmlImage : makeRequest; + return action( + requestParameters, + (err?: Error | null, + data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null, + cacheControl?: string | null, + expires?: string | null) => { + onImageResponse(itemInQueue, callback, err, data, cacheControl, expires); + }); + }; + + const onImageResponse = ( + itemInQueue: ImageRequestQueueItem, + callback:GetImageCallback, + err?: Error | null, + data?: HTMLImageElement | ImageBitmap | ArrayBuffer | null, + cacheControl?: string | null, + expires?: string | null): void => { + if (err) { + callback(err); + } else if (data instanceof HTMLImageElement || isImageBitmap(data)) { + // User using addProtocol can directly return HTMLImageElement/ImageBitmap type + // If HtmlImageElement is used to get image then response type will be HTMLImageElement + callback(null, data); + } else if (data) { + const decoratedCallback = (imgErr?: Error | null, imgResult?: CanvasImageSource | null) => { + if (imgErr != null) { + callback(imgErr); + } else if (imgResult != null) { + callback(null, imgResult as (HTMLImageElement | ImageBitmap), {cacheControl, expires}); + } + }; + arrayBufferToCanvasImageSource(data, decoratedCallback); + } + if (!itemInQueue.cancelled) { + itemInQueue.completed = true; + currentParallelImageRequests--; + + processQueue(); + } + }; + + /** + * Process some number of items in the image request queue. + */ + const processQueue = (): void => { + + const maxImageRequests = isThrottled() ? + config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME : + config.MAX_PARALLEL_IMAGE_REQUESTS; + + // limit concurrent image loads to help with raster sources performance on big screens + for (let numImageRequests = currentParallelImageRequests; + numImageRequests < maxImageRequests && imageRequestQueue.length > 0; + numImageRequests++) { + + const topItemInQueue: ImageRequestQueueItem = imageRequestQueue.shift(); + if (topItemInQueue.cancelled) { + numImageRequests--; + continue; + } + + const innerRequest = doImageRequest(topItemInQueue); + + currentParallelImageRequests++; + + topItemInQueue.innerRequest = innerRequest; + } + }; + + const getImageUsingHtmlImage = (requestParameters: RequestParameters, callback: GetImageCallback): Cancelable => { + const image = new Image() as HTMLImageElementWithPriority; + const url = requestParameters.url; + let requestCancelled = false; + const credentials = requestParameters.credentials; + if (credentials && credentials === 'include') { + image.crossOrigin = 'use-credentials'; + } else if ((credentials && credentials === 'same-origin') || !sameOrigin(url)) { + image.crossOrigin = 'anonymous'; + } + + image.fetchPriority = 'high'; + image.onload = () => { + callback(null, image); + image.onerror = image.onload = null; + }; + image.onerror = () => { + if (!requestCancelled) { + callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.')); + } + image.onerror = image.onload = null; + }; + image.src = url; + return { + cancel: () => { + requestCancelled = true; + // Set src to '' to actually cancel the request + image.src = ''; + } + }; + }; +} + +ImageRequest.resetRequestQueue(); diff --git a/web/libraries/maplibre-gl/src/util/intersection_tests.ts b/web/libraries/maplibre-gl/src/util/intersection_tests.ts new file mode 100644 index 00000000..79d4fb11 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/intersection_tests.ts @@ -0,0 +1,206 @@ +import {isCounterClockwise} from './util'; + +import Point from '@mapbox/point-geometry'; + +export {polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox}; + +type Line = Array; +type MultiLine = Array; +type Ring = Array; +type Polygon = Array; +type MultiPolygon = Array; + +function polygonIntersectsPolygon(polygonA: Polygon, polygonB: Polygon) { + for (let i = 0; i < polygonA.length; i++) { + if (polygonContainsPoint(polygonB, polygonA[i])) return true; + } + + for (let i = 0; i < polygonB.length; i++) { + if (polygonContainsPoint(polygonA, polygonB[i])) return true; + } + + if (lineIntersectsLine(polygonA, polygonB)) return true; + + return false; +} + +function polygonIntersectsBufferedPoint(polygon: Polygon, point: Point, radius: number) { + if (polygonContainsPoint(polygon, point)) return true; + if (pointIntersectsBufferedLine(point, polygon, radius)) return true; + return false; +} + +function polygonIntersectsMultiPolygon(polygon: Polygon, multiPolygon: MultiPolygon) { + + if (polygon.length === 1) { + return multiPolygonContainsPoint(multiPolygon, polygon[0]); + } + + for (let m = 0; m < multiPolygon.length; m++) { + const ring = multiPolygon[m]; + for (let n = 0; n < ring.length; n++) { + if (polygonContainsPoint(polygon, ring[n])) return true; + } + } + + for (let i = 0; i < polygon.length; i++) { + if (multiPolygonContainsPoint(multiPolygon, polygon[i])) return true; + } + + for (let k = 0; k < multiPolygon.length; k++) { + if (lineIntersectsLine(polygon, multiPolygon[k])) return true; + } + + return false; +} + +function polygonIntersectsBufferedMultiLine(polygon: Polygon, multiLine: MultiLine, radius: number) { + for (let i = 0; i < multiLine.length; i++) { + const line = multiLine[i]; + + if (polygon.length >= 3) { + for (let k = 0; k < line.length; k++) { + if (polygonContainsPoint(polygon, line[k])) return true; + } + } + + if (lineIntersectsBufferedLine(polygon, line, radius)) return true; + } + return false; +} + +function lineIntersectsBufferedLine(lineA: Line, lineB: Line, radius: number) { + + if (lineA.length > 1) { + if (lineIntersectsLine(lineA, lineB)) return true; + + // Check whether any point in either line is within radius of the other line + for (let j = 0; j < lineB.length; j++) { + if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) return true; + } + } + + for (let k = 0; k < lineA.length; k++) { + if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) return true; + } + + return false; +} + +function lineIntersectsLine(lineA: Line, lineB: Line) { + if (lineA.length === 0 || lineB.length === 0) return false; + for (let i = 0; i < lineA.length - 1; i++) { + const a0 = lineA[i]; + const a1 = lineA[i + 1]; + for (let j = 0; j < lineB.length - 1; j++) { + const b0 = lineB[j]; + const b1 = lineB[j + 1]; + if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) return true; + } + } + return false; +} + +function lineSegmentIntersectsLineSegment(a0: Point, a1: Point, b0: Point, b1: Point) { + return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) && + isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1); +} + +function pointIntersectsBufferedLine(p: Point, line: Line, radius: number) { + const radiusSquared = radius * radius; + + if (line.length === 1) return p.distSqr(line[0]) < radiusSquared; + + for (let i = 1; i < line.length; i++) { + // Find line segments that have a distance <= radius^2 to p + // In that case, we treat the line as "containing point p". + const v = line[i - 1], w = line[i]; + if (distToSegmentSquared(p, v, w) < radiusSquared) return true; + } + return false; +} + +// Code from http://stackoverflow.com/a/1501725/331379. +function distToSegmentSquared(p: Point, v: Point, w: Point) { + const l2 = v.distSqr(w); + if (l2 === 0) return p.distSqr(v); + const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2; + if (t < 0) return p.distSqr(v); + if (t > 1) return p.distSqr(w); + return p.distSqr(w.sub(v)._mult(t)._add(v)); +} + +// point in polygon ray casting algorithm +function multiPolygonContainsPoint(rings: Array, p: Point) { + let c = false, + ring, p1, p2; + + for (let k = 0; k < rings.length; k++) { + ring = rings[k]; + for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) { + p1 = ring[i]; + p2 = ring[j]; + if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { + c = !c; + } + } + } + return c; +} + +function polygonContainsPoint(ring: Ring, p: Point) { + let c = false; + for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) { + const p1 = ring[i]; + const p2 = ring[j]; + if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { + c = !c; + } + } + return c; +} + +function polygonIntersectsBox(ring: Ring, boxX1: number, boxY1: number, boxX2: number, boxY2: number) { + for (const p of ring) { + if (boxX1 <= p.x && + boxY1 <= p.y && + boxX2 >= p.x && + boxY2 >= p.y) return true; + } + + const corners = [ + new Point(boxX1, boxY1), + new Point(boxX1, boxY2), + new Point(boxX2, boxY2), + new Point(boxX2, boxY1)]; + + if (ring.length > 2) { + for (const corner of corners) { + if (polygonContainsPoint(ring, corner)) return true; + } + } + + for (let i = 0; i < ring.length - 1; i++) { + const p1 = ring[i]; + const p2 = ring[i + 1]; + if (edgeIntersectsBox(p1, p2, corners)) return true; + } + + return false; +} + +function edgeIntersectsBox(e1: Point, e2: Point, corners: Array) { + const tl = corners[0]; + const br = corners[2]; + // the edge and box do not intersect in either the x or y dimensions + if (((e1.x < tl.x) && (e2.x < tl.x)) || + ((e1.x > br.x) && (e2.x > br.x)) || + ((e1.y < tl.y) && (e2.y < tl.y)) || + ((e1.y > br.y) && (e2.y > br.y))) return false; + + // check if all corners of the box are on the same side of the edge + const dir = isCounterClockwise(e1, e2, corners[0]); + return dir !== isCounterClockwise(e1, e2, corners[1]) || + dir !== isCounterClockwise(e1, e2, corners[2]) || + dir !== isCounterClockwise(e1, e2, corners[3]); +} diff --git a/web/libraries/maplibre-gl/src/util/is_char_in_unicode_block.ts b/web/libraries/maplibre-gl/src/util/is_char_in_unicode_block.ts new file mode 100644 index 00000000..d1c2ba31 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/is_char_in_unicode_block.ts @@ -0,0 +1,307 @@ +// The following table comes from . +// Keep it synchronized with . + +type UnicodeBlockLookup = {[key: string]: (char: number) => boolean}; + +export const unicodeBlockLookup: UnicodeBlockLookup = { + // 'Basic Latin': (char) => char >= 0x0000 && char <= 0x007F, + 'Latin-1 Supplement': (char) => char >= 0x0080 && char <= 0x00FF, + // 'Latin Extended-A': (char) => char >= 0x0100 && char <= 0x017F, + // 'Latin Extended-B': (char) => char >= 0x0180 && char <= 0x024F, + // 'IPA Extensions': (char) => char >= 0x0250 && char <= 0x02AF, + // 'Spacing Modifier Letters': (char) => char >= 0x02B0 && char <= 0x02FF, + // 'Combining Diacritical Marks': (char) => char >= 0x0300 && char <= 0x036F, + // 'Greek and Coptic': (char) => char >= 0x0370 && char <= 0x03FF, + // 'Cyrillic': (char) => char >= 0x0400 && char <= 0x04FF, + // 'Cyrillic Supplement': (char) => char >= 0x0500 && char <= 0x052F, + // 'Armenian': (char) => char >= 0x0530 && char <= 0x058F, + //'Hebrew': (char) => char >= 0x0590 && char <= 0x05FF, + 'Arabic': (char) => char >= 0x0600 && char <= 0x06FF, + //'Syriac': (char) => char >= 0x0700 && char <= 0x074F, + 'Arabic Supplement': (char) => char >= 0x0750 && char <= 0x077F, + // 'Thaana': (char) => char >= 0x0780 && char <= 0x07BF, + // 'NKo': (char) => char >= 0x07C0 && char <= 0x07FF, + // 'Samaritan': (char) => char >= 0x0800 && char <= 0x083F, + // 'Mandaic': (char) => char >= 0x0840 && char <= 0x085F, + // 'Syriac Supplement': (char) => char >= 0x0860 && char <= 0x086F, + 'Arabic Extended-A': (char) => char >= 0x08A0 && char <= 0x08FF, + // 'Devanagari': (char) => char >= 0x0900 && char <= 0x097F, + // 'Bengali': (char) => char >= 0x0980 && char <= 0x09FF, + // 'Gurmukhi': (char) => char >= 0x0A00 && char <= 0x0A7F, + // 'Gujarati': (char) => char >= 0x0A80 && char <= 0x0AFF, + // 'Oriya': (char) => char >= 0x0B00 && char <= 0x0B7F, + // 'Tamil': (char) => char >= 0x0B80 && char <= 0x0BFF, + // 'Telugu': (char) => char >= 0x0C00 && char <= 0x0C7F, + // 'Kannada': (char) => char >= 0x0C80 && char <= 0x0CFF, + // 'Malayalam': (char) => char >= 0x0D00 && char <= 0x0D7F, + // 'Sinhala': (char) => char >= 0x0D80 && char <= 0x0DFF, + // 'Thai': (char) => char >= 0x0E00 && char <= 0x0E7F, + // 'Lao': (char) => char >= 0x0E80 && char <= 0x0EFF, + // 'Tibetan': (char) => char >= 0x0F00 && char <= 0x0FFF, + // 'Myanmar': (char) => char >= 0x1000 && char <= 0x109F, + // 'Georgian': (char) => char >= 0x10A0 && char <= 0x10FF, + 'Hangul Jamo': (char) => char >= 0x1100 && char <= 0x11FF, + // 'Ethiopic': (char) => char >= 0x1200 && char <= 0x137F, + // 'Ethiopic Supplement': (char) => char >= 0x1380 && char <= 0x139F, + // 'Cherokee': (char) => char >= 0x13A0 && char <= 0x13FF, + 'Unified Canadian Aboriginal Syllabics': (char) => char >= 0x1400 && char <= 0x167F, + // 'Ogham': (char) => char >= 0x1680 && char <= 0x169F, + // 'Runic': (char) => char >= 0x16A0 && char <= 0x16FF, + // 'Tagalog': (char) => char >= 0x1700 && char <= 0x171F, + // 'Hanunoo': (char) => char >= 0x1720 && char <= 0x173F, + // 'Buhid': (char) => char >= 0x1740 && char <= 0x175F, + // 'Tagbanwa': (char) => char >= 0x1760 && char <= 0x177F, + 'Khmer': (char) => char >= 0x1780 && char <= 0x17FF, + // 'Mongolian': (char) => char >= 0x1800 && char <= 0x18AF, + 'Unified Canadian Aboriginal Syllabics Extended': (char) => char >= 0x18B0 && char <= 0x18FF, + // 'Limbu': (char) => char >= 0x1900 && char <= 0x194F, + // 'Tai Le': (char) => char >= 0x1950 && char <= 0x197F, + // 'New Tai Lue': (char) => char >= 0x1980 && char <= 0x19DF, + // 'Khmer Symbols': (char) => char >= 0x19E0 && char <= 0x19FF, + // 'Buginese': (char) => char >= 0x1A00 && char <= 0x1A1F, + // 'Tai Tham': (char) => char >= 0x1A20 && char <= 0x1AAF, + // 'Combining Diacritical Marks Extended': (char) => char >= 0x1AB0 && char <= 0x1AFF, + // 'Balinese': (char) => char >= 0x1B00 && char <= 0x1B7F, + // 'Sundanese': (char) => char >= 0x1B80 && char <= 0x1BBF, + // 'Batak': (char) => char >= 0x1BC0 && char <= 0x1BFF, + // 'Lepcha': (char) => char >= 0x1C00 && char <= 0x1C4F, + // 'Ol Chiki': (char) => char >= 0x1C50 && char <= 0x1C7F, + // 'Cyrillic Extended-C': (char) => char >= 0x1C80 && char <= 0x1C8F, + // 'Georgian Extended': (char) => char >= 0x1C90 && char <= 0x1CBF, + // 'Sundanese Supplement': (char) => char >= 0x1CC0 && char <= 0x1CCF, + // 'Vedic Extensions': (char) => char >= 0x1CD0 && char <= 0x1CFF, + // 'Phonetic Extensions': (char) => char >= 0x1D00 && char <= 0x1D7F, + // 'Phonetic Extensions Supplement': (char) => char >= 0x1D80 && char <= 0x1DBF, + // 'Combining Diacritical Marks Supplement': (char) => char >= 0x1DC0 && char <= 0x1DFF, + // 'Latin Extended Additional': (char) => char >= 0x1E00 && char <= 0x1EFF, + // 'Greek Extended': (char) => char >= 0x1F00 && char <= 0x1FFF, + 'General Punctuation': (char) => char >= 0x2000 && char <= 0x206F, + // 'Superscripts and Subscripts': (char) => char >= 0x2070 && char <= 0x209F, + // 'Currency Symbols': (char) => char >= 0x20A0 && char <= 0x20CF, + // 'Combining Diacritical Marks for Symbols': (char) => char >= 0x20D0 && char <= 0x20FF, + 'Letterlike Symbols': (char) => char >= 0x2100 && char <= 0x214F, + 'Number Forms': (char) => char >= 0x2150 && char <= 0x218F, + // 'Arrows': (char) => char >= 0x2190 && char <= 0x21FF, + // 'Mathematical Operators': (char) => char >= 0x2200 && char <= 0x22FF, + 'Miscellaneous Technical': (char) => char >= 0x2300 && char <= 0x23FF, + 'Control Pictures': (char) => char >= 0x2400 && char <= 0x243F, + 'Optical Character Recognition': (char) => char >= 0x2440 && char <= 0x245F, + 'Enclosed Alphanumerics': (char) => char >= 0x2460 && char <= 0x24FF, + // 'Box Drawing': (char) => char >= 0x2500 && char <= 0x257F, + // 'Block Elements': (char) => char >= 0x2580 && char <= 0x259F, + 'Geometric Shapes': (char) => char >= 0x25A0 && char <= 0x25FF, + 'Miscellaneous Symbols': (char) => char >= 0x2600 && char <= 0x26FF, + // 'Dingbats': (char) => char >= 0x2700 && char <= 0x27BF, + // 'Miscellaneous Mathematical Symbols-A': (char) => char >= 0x27C0 && char <= 0x27EF, + // 'Supplemental Arrows-A': (char) => char >= 0x27F0 && char <= 0x27FF, + // 'Braille Patterns': (char) => char >= 0x2800 && char <= 0x28FF, + // 'Supplemental Arrows-B': (char) => char >= 0x2900 && char <= 0x297F, + // 'Miscellaneous Mathematical Symbols-B': (char) => char >= 0x2980 && char <= 0x29FF, + // 'Supplemental Mathematical Operators': (char) => char >= 0x2A00 && char <= 0x2AFF, + 'Miscellaneous Symbols and Arrows': (char) => char >= 0x2B00 && char <= 0x2BFF, + // 'Glagolitic': (char) => char >= 0x2C00 && char <= 0x2C5F, + // 'Latin Extended-C': (char) => char >= 0x2C60 && char <= 0x2C7F, + // 'Coptic': (char) => char >= 0x2C80 && char <= 0x2CFF, + // 'Georgian Supplement': (char) => char >= 0x2D00 && char <= 0x2D2F, + // 'Tifinagh': (char) => char >= 0x2D30 && char <= 0x2D7F, + // 'Ethiopic Extended': (char) => char >= 0x2D80 && char <= 0x2DDF, + // 'Cyrillic Extended-A': (char) => char >= 0x2DE0 && char <= 0x2DFF, + // 'Supplemental Punctuation': (char) => char >= 0x2E00 && char <= 0x2E7F, + 'CJK Radicals Supplement': (char) => char >= 0x2E80 && char <= 0x2EFF, + 'Kangxi Radicals': (char) => char >= 0x2F00 && char <= 0x2FDF, + 'Ideographic Description Characters': (char) => char >= 0x2FF0 && char <= 0x2FFF, + 'CJK Symbols and Punctuation': (char) => char >= 0x3000 && char <= 0x303F, + 'Hiragana': (char) => char >= 0x3040 && char <= 0x309F, + 'Katakana': (char) => char >= 0x30A0 && char <= 0x30FF, + 'Bopomofo': (char) => char >= 0x3100 && char <= 0x312F, + 'Hangul Compatibility Jamo': (char) => char >= 0x3130 && char <= 0x318F, + 'Kanbun': (char) => char >= 0x3190 && char <= 0x319F, + 'Bopomofo Extended': (char) => char >= 0x31A0 && char <= 0x31BF, + 'CJK Strokes': (char) => char >= 0x31C0 && char <= 0x31EF, + 'Katakana Phonetic Extensions': (char) => char >= 0x31F0 && char <= 0x31FF, + 'Enclosed CJK Letters and Months': (char) => char >= 0x3200 && char <= 0x32FF, + 'CJK Compatibility': (char) => char >= 0x3300 && char <= 0x33FF, + 'CJK Unified Ideographs Extension A': (char) => char >= 0x3400 && char <= 0x4DBF, + 'Yijing Hexagram Symbols': (char) => char >= 0x4DC0 && char <= 0x4DFF, + 'CJK Unified Ideographs': (char) => char >= 0x4E00 && char <= 0x9FFF, + 'Yi Syllables': (char) => char >= 0xA000 && char <= 0xA48F, + 'Yi Radicals': (char) => char >= 0xA490 && char <= 0xA4CF, + // 'Lisu': (char) => char >= 0xA4D0 && char <= 0xA4FF, + // 'Vai': (char) => char >= 0xA500 && char <= 0xA63F, + // 'Cyrillic Extended-B': (char) => char >= 0xA640 && char <= 0xA69F, + // 'Bamum': (char) => char >= 0xA6A0 && char <= 0xA6FF, + // 'Modifier Tone Letters': (char) => char >= 0xA700 && char <= 0xA71F, + // 'Latin Extended-D': (char) => char >= 0xA720 && char <= 0xA7FF, + // 'Syloti Nagri': (char) => char >= 0xA800 && char <= 0xA82F, + // 'Common Indic Number Forms': (char) => char >= 0xA830 && char <= 0xA83F, + // 'Phags-pa': (char) => char >= 0xA840 && char <= 0xA87F, + // 'Saurashtra': (char) => char >= 0xA880 && char <= 0xA8DF, + // 'Devanagari Extended': (char) => char >= 0xA8E0 && char <= 0xA8FF, + // 'Kayah Li': (char) => char >= 0xA900 && char <= 0xA92F, + // 'Rejang': (char) => char >= 0xA930 && char <= 0xA95F, + 'Hangul Jamo Extended-A': (char) => char >= 0xA960 && char <= 0xA97F, + // 'Javanese': (char) => char >= 0xA980 && char <= 0xA9DF, + // 'Myanmar Extended-B': (char) => char >= 0xA9E0 && char <= 0xA9FF, + // 'Cham': (char) => char >= 0xAA00 && char <= 0xAA5F, + // 'Myanmar Extended-A': (char) => char >= 0xAA60 && char <= 0xAA7F, + // 'Tai Viet': (char) => char >= 0xAA80 && char <= 0xAADF, + // 'Meetei Mayek Extensions': (char) => char >= 0xAAE0 && char <= 0xAAFF, + // 'Ethiopic Extended-A': (char) => char >= 0xAB00 && char <= 0xAB2F, + // 'Latin Extended-E': (char) => char >= 0xAB30 && char <= 0xAB6F, + // 'Cherokee Supplement': (char) => char >= 0xAB70 && char <= 0xABBF, + // 'Meetei Mayek': (char) => char >= 0xABC0 && char <= 0xABFF, + 'Hangul Syllables': (char) => char >= 0xAC00 && char <= 0xD7AF, + 'Hangul Jamo Extended-B': (char) => char >= 0xD7B0 && char <= 0xD7FF, + // 'High Surrogates': (char) => char >= 0xD800 && char <= 0xDB7F, + // 'High Private Use Surrogates': (char) => char >= 0xDB80 && char <= 0xDBFF, + // 'Low Surrogates': (char) => char >= 0xDC00 && char <= 0xDFFF, + 'Private Use Area': (char) => char >= 0xE000 && char <= 0xF8FF, + 'CJK Compatibility Ideographs': (char) => char >= 0xF900 && char <= 0xFAFF, + // 'Alphabetic Presentation Forms': (char) => char >= 0xFB00 && char <= 0xFB4F, + 'Arabic Presentation Forms-A': (char) => char >= 0xFB50 && char <= 0xFDFF, + // 'Variation Selectors': (char) => char >= 0xFE00 && char <= 0xFE0F, + 'Vertical Forms': (char) => char >= 0xFE10 && char <= 0xFE1F, + // 'Combining Half Marks': (char) => char >= 0xFE20 && char <= 0xFE2F, + 'CJK Compatibility Forms': (char) => char >= 0xFE30 && char <= 0xFE4F, + 'Small Form Variants': (char) => char >= 0xFE50 && char <= 0xFE6F, + 'Arabic Presentation Forms-B': (char) => char >= 0xFE70 && char <= 0xFEFF, + 'Halfwidth and Fullwidth Forms': (char) => char >= 0xFF00 && char <= 0xFFEF + // 'Specials': (char) => char >= 0xFFF0 && char <= 0xFFFF, + // 'Linear B Syllabary': (char) => char >= 0x10000 && char <= 0x1007F, + // 'Linear B Ideograms': (char) => char >= 0x10080 && char <= 0x100FF, + // 'Aegean Numbers': (char) => char >= 0x10100 && char <= 0x1013F, + // 'Ancient Greek Numbers': (char) => char >= 0x10140 && char <= 0x1018F, + // 'Ancient Symbols': (char) => char >= 0x10190 && char <= 0x101CF, + // 'Phaistos Disc': (char) => char >= 0x101D0 && char <= 0x101FF, + // 'Lycian': (char) => char >= 0x10280 && char <= 0x1029F, + // 'Carian': (char) => char >= 0x102A0 && char <= 0x102DF, + // 'Coptic Epact Numbers': (char) => char >= 0x102E0 && char <= 0x102FF, + // 'Old Italic': (char) => char >= 0x10300 && char <= 0x1032F, + // 'Gothic': (char) => char >= 0x10330 && char <= 0x1034F, + // 'Old Permic': (char) => char >= 0x10350 && char <= 0x1037F, + // 'Ugaritic': (char) => char >= 0x10380 && char <= 0x1039F, + // 'Old Persian': (char) => char >= 0x103A0 && char <= 0x103DF, + // 'Deseret': (char) => char >= 0x10400 && char <= 0x1044F, + // 'Shavian': (char) => char >= 0x10450 && char <= 0x1047F, + // 'Osmanya': (char) => char >= 0x10480 && char <= 0x104AF, + // 'Osage': (char) => char >= 0x104B0 && char <= 0x104FF, + // 'Elbasan': (char) => char >= 0x10500 && char <= 0x1052F, + // 'Caucasian Albanian': (char) => char >= 0x10530 && char <= 0x1056F, + // 'Linear A': (char) => char >= 0x10600 && char <= 0x1077F, + // 'Cypriot Syllabary': (char) => char >= 0x10800 && char <= 0x1083F, + // 'Imperial Aramaic': (char) => char >= 0x10840 && char <= 0x1085F, + // 'Palmyrene': (char) => char >= 0x10860 && char <= 0x1087F, + // 'Nabataean': (char) => char >= 0x10880 && char <= 0x108AF, + // 'Hatran': (char) => char >= 0x108E0 && char <= 0x108FF, + // 'Phoenician': (char) => char >= 0x10900 && char <= 0x1091F, + // 'Lydian': (char) => char >= 0x10920 && char <= 0x1093F, + // 'Meroitic Hieroglyphs': (char) => char >= 0x10980 && char <= 0x1099F, + // 'Meroitic Cursive': (char) => char >= 0x109A0 && char <= 0x109FF, + // 'Kharoshthi': (char) => char >= 0x10A00 && char <= 0x10A5F, + // 'Old South Arabian': (char) => char >= 0x10A60 && char <= 0x10A7F, + // 'Old North Arabian': (char) => char >= 0x10A80 && char <= 0x10A9F, + // 'Manichaean': (char) => char >= 0x10AC0 && char <= 0x10AFF, + // 'Avestan': (char) => char >= 0x10B00 && char <= 0x10B3F, + // 'Inscriptional Parthian': (char) => char >= 0x10B40 && char <= 0x10B5F, + // 'Inscriptional Pahlavi': (char) => char >= 0x10B60 && char <= 0x10B7F, + // 'Psalter Pahlavi': (char) => char >= 0x10B80 && char <= 0x10BAF, + // 'Old Turkic': (char) => char >= 0x10C00 && char <= 0x10C4F, + // 'Old Hungarian': (char) => char >= 0x10C80 && char <= 0x10CFF, + // 'Hanifi Rohingya': (char) => char >= 0x10D00 && char <= 0x10D3F, + // 'Rumi Numeral Symbols': (char) => char >= 0x10E60 && char <= 0x10E7F, + // 'Old Sogdian': (char) => char >= 0x10F00 && char <= 0x10F2F, + // 'Sogdian': (char) => char >= 0x10F30 && char <= 0x10F6F, + // 'Elymaic': (char) => char >= 0x10FE0 && char <= 0x10FFF, + // 'Brahmi': (char) => char >= 0x11000 && char <= 0x1107F, + // 'Kaithi': (char) => char >= 0x11080 && char <= 0x110CF, + // 'Sora Sompeng': (char) => char >= 0x110D0 && char <= 0x110FF, + // 'Chakma': (char) => char >= 0x11100 && char <= 0x1114F, + // 'Mahajani': (char) => char >= 0x11150 && char <= 0x1117F, + // 'Sharada': (char) => char >= 0x11180 && char <= 0x111DF, + // 'Sinhala Archaic Numbers': (char) => char >= 0x111E0 && char <= 0x111FF, + // 'Khojki': (char) => char >= 0x11200 && char <= 0x1124F, + // 'Multani': (char) => char >= 0x11280 && char <= 0x112AF, + // 'Khudawadi': (char) => char >= 0x112B0 && char <= 0x112FF, + // 'Grantha': (char) => char >= 0x11300 && char <= 0x1137F, + // 'Newa': (char) => char >= 0x11400 && char <= 0x1147F, + // 'Tirhuta': (char) => char >= 0x11480 && char <= 0x114DF, + // 'Siddham': (char) => char >= 0x11580 && char <= 0x115FF, + // 'Modi': (char) => char >= 0x11600 && char <= 0x1165F, + // 'Mongolian Supplement': (char) => char >= 0x11660 && char <= 0x1167F, + // 'Takri': (char) => char >= 0x11680 && char <= 0x116CF, + // 'Ahom': (char) => char >= 0x11700 && char <= 0x1173F, + // 'Dogra': (char) => char >= 0x11800 && char <= 0x1184F, + // 'Warang Citi': (char) => char >= 0x118A0 && char <= 0x118FF, + // 'Nandinagari': (char) => char >= 0x119A0 && char <= 0x119FF, + // 'Zanabazar Square': (char) => char >= 0x11A00 && char <= 0x11A4F, + // 'Soyombo': (char) => char >= 0x11A50 && char <= 0x11AAF, + // 'Pau Cin Hau': (char) => char >= 0x11AC0 && char <= 0x11AFF, + // 'Bhaiksuki': (char) => char >= 0x11C00 && char <= 0x11C6F, + // 'Marchen': (char) => char >= 0x11C70 && char <= 0x11CBF, + // 'Masaram Gondi': (char) => char >= 0x11D00 && char <= 0x11D5F, + // 'Gunjala Gondi': (char) => char >= 0x11D60 && char <= 0x11DAF, + // 'Makasar': (char) => char >= 0x11EE0 && char <= 0x11EFF, + // 'Tamil Supplement': (char) => char >= 0x11FC0 && char <= 0x11FFF, + // 'Cuneiform': (char) => char >= 0x12000 && char <= 0x123FF, + // 'Cuneiform Numbers and Punctuation': (char) => char >= 0x12400 && char <= 0x1247F, + // 'Early Dynastic Cuneiform': (char) => char >= 0x12480 && char <= 0x1254F, + // 'Egyptian Hieroglyphs': (char) => char >= 0x13000 && char <= 0x1342F, + // 'Egyptian Hieroglyph Format Controls': (char) => char >= 0x13430 && char <= 0x1343F, + // 'Anatolian Hieroglyphs': (char) => char >= 0x14400 && char <= 0x1467F, + // 'Bamum Supplement': (char) => char >= 0x16800 && char <= 0x16A3F, + // 'Mro': (char) => char >= 0x16A40 && char <= 0x16A6F, + // 'Bassa Vah': (char) => char >= 0x16AD0 && char <= 0x16AFF, + // 'Pahawh Hmong': (char) => char >= 0x16B00 && char <= 0x16B8F, + // 'Medefaidrin': (char) => char >= 0x16E40 && char <= 0x16E9F, + // 'Miao': (char) => char >= 0x16F00 && char <= 0x16F9F, + // 'Ideographic Symbols and Punctuation': (char) => char >= 0x16FE0 && char <= 0x16FFF, + // 'Tangut': (char) => char >= 0x17000 && char <= 0x187FF, + // 'Tangut Components': (char) => char >= 0x18800 && char <= 0x18AFF, + // 'Kana Supplement': (char) => char >= 0x1B000 && char <= 0x1B0FF, + // 'Kana Extended-A': (char) => char >= 0x1B100 && char <= 0x1B12F, + // 'Small Kana Extension': (char) => char >= 0x1B130 && char <= 0x1B16F, + // 'Nushu': (char) => char >= 0x1B170 && char <= 0x1B2FF, + // 'Duployan': (char) => char >= 0x1BC00 && char <= 0x1BC9F, + // 'Shorthand Format Controls': (char) => char >= 0x1BCA0 && char <= 0x1BCAF, + // 'Byzantine Musical Symbols': (char) => char >= 0x1D000 && char <= 0x1D0FF, + // 'Musical Symbols': (char) => char >= 0x1D100 && char <= 0x1D1FF, + // 'Ancient Greek Musical Notation': (char) => char >= 0x1D200 && char <= 0x1D24F, + // 'Mayan Numerals': (char) => char >= 0x1D2E0 && char <= 0x1D2FF, + // 'Tai Xuan Jing Symbols': (char) => char >= 0x1D300 && char <= 0x1D35F, + // 'Counting Rod Numerals': (char) => char >= 0x1D360 && char <= 0x1D37F, + // 'Mathematical Alphanumeric Symbols': (char) => char >= 0x1D400 && char <= 0x1D7FF, + // 'Sutton SignWriting': (char) => char >= 0x1D800 && char <= 0x1DAAF, + // 'Glagolitic Supplement': (char) => char >= 0x1E000 && char <= 0x1E02F, + // 'Nyiakeng Puachue Hmong': (char) => char >= 0x1E100 && char <= 0x1E14F, + // 'Wancho': (char) => char >= 0x1E2C0 && char <= 0x1E2FF, + // 'Mende Kikakui': (char) => char >= 0x1E800 && char <= 0x1E8DF, + // 'Adlam': (char) => char >= 0x1E900 && char <= 0x1E95F, + // 'Indic Siyaq Numbers': (char) => char >= 0x1EC70 && char <= 0x1ECBF, + // 'Ottoman Siyaq Numbers': (char) => char >= 0x1ED00 && char <= 0x1ED4F, + // 'Arabic Mathematical Alphabetic Symbols': (char) => char >= 0x1EE00 && char <= 0x1EEFF, + // 'Mahjong Tiles': (char) => char >= 0x1F000 && char <= 0x1F02F, + // 'Domino Tiles': (char) => char >= 0x1F030 && char <= 0x1F09F, + // 'Playing Cards': (char) => char >= 0x1F0A0 && char <= 0x1F0FF, + // 'Enclosed Alphanumeric Supplement': (char) => char >= 0x1F100 && char <= 0x1F1FF, + // 'Enclosed Ideographic Supplement': (char) => char >= 0x1F200 && char <= 0x1F2FF, + // 'Miscellaneous Symbols and Pictographs': (char) => char >= 0x1F300 && char <= 0x1F5FF, + // 'Emoticons': (char) => char >= 0x1F600 && char <= 0x1F64F, + // 'Ornamental Dingbats': (char) => char >= 0x1F650 && char <= 0x1F67F, + // 'Transport and Map Symbols': (char) => char >= 0x1F680 && char <= 0x1F6FF, + // 'Alchemical Symbols': (char) => char >= 0x1F700 && char <= 0x1F77F, + // 'Geometric Shapes Extended': (char) => char >= 0x1F780 && char <= 0x1F7FF, + // 'Supplemental Arrows-C': (char) => char >= 0x1F800 && char <= 0x1F8FF, + // 'Supplemental Symbols and Pictographs': (char) => char >= 0x1F900 && char <= 0x1F9FF, + // 'Chess Symbols': (char) => char >= 0x1FA00 && char <= 0x1FA6F, + // 'Symbols and Pictographs Extended-A': (char) => char >= 0x1FA70 && char <= 0x1FAFF, + // 'CJK Unified Ideographs Extension B': (char) => char >= 0x20000 && char <= 0x2A6DF, + // 'CJK Unified Ideographs Extension C': (char) => char >= 0x2A700 && char <= 0x2B73F, + // 'CJK Unified Ideographs Extension D': (char) => char >= 0x2B740 && char <= 0x2B81F, + // 'CJK Unified Ideographs Extension E': (char) => char >= 0x2B820 && char <= 0x2CEAF, + // 'CJK Unified Ideographs Extension F': (char) => char >= 0x2CEB0 && char <= 0x2EBEF, + // 'CJK Compatibility Ideographs Supplement': (char) => char >= 0x2F800 && char <= 0x2FA1F, + // 'Tags': (char) => char >= 0xE0000 && char <= 0xE007F, + // 'Variation Selectors Supplement': (char) => char >= 0xE0100 && char <= 0xE01EF, + // 'Supplementary Private Use Area-A': (char) => char >= 0xF0000 && char <= 0xFFFFF, + // 'Supplementary Private Use Area-B': (char) => char >= 0x100000 && char <= 0x10FFFF, +}; diff --git a/web/libraries/maplibre-gl/src/util/offscreen_canvas_distorted.test.ts b/web/libraries/maplibre-gl/src/util/offscreen_canvas_distorted.test.ts new file mode 100644 index 00000000..bf5c4bf4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/offscreen_canvas_distorted.test.ts @@ -0,0 +1,13 @@ +import {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted'; +import {Canvas} from 'canvas'; +import {offscreenCanvasSupported} from './offscreen_canvas_supported'; + +test('normal operation does not mangle canvas', () => { + const OffscreenCanvas = (window as any).OffscreenCanvas = jest.fn((width:number, height: number) => { + return new Canvas(width, height); + }); + expect(offscreenCanvasSupported()).toBeTruthy(); + OffscreenCanvas.mockClear(); + expect(isOffscreenCanvasDistorted()).toBeFalsy(); + expect(OffscreenCanvas).toHaveBeenCalledTimes(1); +}); diff --git a/web/libraries/maplibre-gl/src/util/offscreen_canvas_distorted.ts b/web/libraries/maplibre-gl/src/util/offscreen_canvas_distorted.ts new file mode 100644 index 00000000..15475a87 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/offscreen_canvas_distorted.ts @@ -0,0 +1,39 @@ +import {offscreenCanvasSupported} from './offscreen_canvas_supported'; + +let offscreenCanvasDistorted: boolean; + +/** + * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185). + * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false + * if they don't match. + * + * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise. + */ +export function isOffscreenCanvasDistorted(): boolean { + if (offscreenCanvasDistorted == null) { + offscreenCanvasDistorted = false; + if (offscreenCanvasSupported()) { + const size = 5; + const canvas = new OffscreenCanvas(size, size); + const context = canvas.getContext('2d', {willReadFrequently: true}); + if (context) { + // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel): + // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...] + for (let i = 0; i < size * size; i++) { + const base = i * 4; + context.fillStyle = `rgb(${base},${base + 1},${base + 2})`; + context.fillRect(i % size, Math.floor(i / size), 1, 1); + } + const data = context.getImageData(0, 0, size, size).data; + for (let i = 0; i < size * size * 4; i++) { + if (i % 4 !== 3 && data[i] !== i) { + offscreenCanvasDistorted = true; + break; + } + } + } + } + } + + return offscreenCanvasDistorted || false; +} diff --git a/web/libraries/maplibre-gl/src/util/offscreen_canvas_supported.ts b/web/libraries/maplibre-gl/src/util/offscreen_canvas_supported.ts new file mode 100644 index 00000000..b83bac1a --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/offscreen_canvas_supported.ts @@ -0,0 +1,11 @@ +let supportsOffscreenCanvas: boolean; + +export function offscreenCanvasSupported(): boolean { + if (supportsOffscreenCanvas == null) { + supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' && + new OffscreenCanvas(1, 1).getContext('2d') && + typeof createImageBitmap === 'function'; + } + + return supportsOffscreenCanvas; +} diff --git a/web/libraries/maplibre-gl/src/util/performance.ts b/web/libraries/maplibre-gl/src/util/performance.ts new file mode 100644 index 00000000..4142901f --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/performance.ts @@ -0,0 +1,117 @@ +import type {RequestParameters} from '../util/ajax'; + +export type PerformanceMetrics = { + loadTime: number; + fullLoadTime: number; + fps: number; + percentDroppedFrames: number; + totalFrames: number; +}; + +export enum PerformanceMarkers { + create = 'create', + load = 'load', + fullLoad = 'fullLoad' +} + +let lastFrameTime = null; +let frameTimes = []; + +const minFramerateTarget = 60; +const frameTimeTarget = 1000 / minFramerateTarget; + +const loadTimeKey = 'loadTime'; +const fullLoadTimeKey = 'fullLoadTime'; + +export const PerformanceUtils = { + mark(marker: PerformanceMarkers) { + performance.mark(marker); + }, + frame(timestamp: number) { + const currTimestamp = timestamp; + if (lastFrameTime != null) { + const frameTime = currTimestamp - lastFrameTime; + frameTimes.push(frameTime); + } + lastFrameTime = currTimestamp; + }, + clearMetrics() { + lastFrameTime = null; + frameTimes = []; + performance.clearMeasures(loadTimeKey); + performance.clearMeasures(fullLoadTimeKey); + + for (const marker in PerformanceMarkers) { + performance.clearMarks(PerformanceMarkers[marker]); + } + }, + + getPerformanceMetrics(): PerformanceMetrics { + performance.measure(loadTimeKey, PerformanceMarkers.create, PerformanceMarkers.load); + performance.measure(fullLoadTimeKey, PerformanceMarkers.create, PerformanceMarkers.fullLoad); + const loadTime = performance.getEntriesByName(loadTimeKey)[0].duration; + const fullLoadTime = performance.getEntriesByName(fullLoadTimeKey)[0].duration; + const totalFrames = frameTimes.length; + + const avgFrameTime = frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000; + const fps = 1 / avgFrameTime; + + // count frames that missed our framerate target + const droppedFrames = frameTimes + .filter((frameTime) => frameTime > frameTimeTarget) + .reduce((acc, curr) => { + return acc + (curr - frameTimeTarget) / frameTimeTarget; + }, 0); + const percentDroppedFrames = (droppedFrames / (totalFrames + droppedFrames)) * 100; + + return { + loadTime, + fullLoadTime, + fps, + percentDroppedFrames, + totalFrames + }; + } +}; + +/** + * @internal + * Safe wrapper for the performance resource timing API in web workers with graceful degradation + */ +export class RequestPerformance { + _marks: { + start: string; + end: string; + measure: string; + }; + + constructor (request: RequestParameters) { + this._marks = { + start: [request.url, 'start'].join('#'), + end: [request.url, 'end'].join('#'), + measure: request.url.toString() + }; + + performance.mark(this._marks.start); + } + + finish() { + performance.mark(this._marks.end); + let resourceTimingData = performance.getEntriesByName(this._marks.measure); + + // fallback if web worker implementation of perf.getEntriesByName returns empty + if (resourceTimingData.length === 0) { + performance.measure(this._marks.measure, this._marks.start, this._marks.end); + resourceTimingData = performance.getEntriesByName(this._marks.measure); + + // cleanup + performance.clearMarks(this._marks.start); + performance.clearMarks(this._marks.end); + performance.clearMeasures(this._marks.measure); + } + + return resourceTimingData; + } +} + +export default performance; diff --git a/web/libraries/maplibre-gl/src/util/primitives.test.ts b/web/libraries/maplibre-gl/src/util/primitives.test.ts new file mode 100644 index 00000000..aa6c40b7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/primitives.test.ts @@ -0,0 +1,140 @@ +import {Aabb, Frustum} from './primitives'; +import {mat4, vec3, vec4} from 'gl-matrix'; + +describe('primitives', () => { + test('Create an aabb', () => { + const min = vec3.fromValues(0, 0, 0); + const max = vec3.fromValues(2, 4, 6); + const aabb = new Aabb(min, max); + + expect(aabb.min).toBe(min); + expect(aabb.max).toBe(max); + expect(aabb.center).toEqual([1, 2, 3]); + }); + + test('Create 4 quadrants', () => { + const min = vec3.fromValues(0, 0, 0); + const max = vec3.fromValues(2, 4, 1); + const aabb = new Aabb(min, max); + + expect(aabb.quadrant(0)).toEqual(new Aabb(vec3.fromValues(0, 0, 0), vec3.fromValues(1, 2, 1))); + expect(aabb.quadrant(1)).toEqual(new Aabb(vec3.fromValues(1, 0, 0), vec3.fromValues(2, 2, 1))); + expect(aabb.quadrant(2)).toEqual(new Aabb(vec3.fromValues(0, 2, 0), vec3.fromValues(1, 4, 1))); + expect(aabb.quadrant(3)).toEqual(new Aabb(vec3.fromValues(1, 2, 0), vec3.fromValues(2, 4, 1))); + + }); + + test('Distance to a point', () => { + const min = vec3.fromValues(-1, -1, -1); + const max = vec3.fromValues(1, 1, 1); + const aabb = new Aabb(min, max); + + expect(aabb.distanceX([0.5, -0.5])).toBe(0); + expect(aabb.distanceY([0.5, -0.5])).toBe(0); + + expect(aabb.distanceX([1, 1])).toBe(0); + expect(aabb.distanceY([1, 1])).toBe(0); + + expect(aabb.distanceX([0, 10])).toBe(0); + expect(aabb.distanceY([0, 10])).toBe(-9); + + expect(aabb.distanceX([-2, -2])).toBe(1); + expect(aabb.distanceY([-2, -2])).toBe(1); + }); + + const createTestCameraFrustum = (fovy, aspectRatio, zNear, zFar, elevation, rotation) => { + const proj = new Float64Array(16) as any as mat4; + const invProj = new Float64Array(16) as any as mat4; + + // Note that left handed coordinate space is used where z goes towards the sky. + // Y has to be flipped as well because it's part of the projection/camera matrix used in transform.js + mat4.perspective(proj, fovy, aspectRatio, zNear, zFar); + mat4.scale(proj, proj, [1, -1, 1]); + mat4.translate(proj, proj, [0, 0, elevation]); + mat4.rotateZ(proj, proj, rotation); + mat4.invert(invProj, proj); + + return Frustum.fromInvProjectionMatrix(invProj, 1.0, 0.0); + }; + + test('Aabb fully inside a frustum', () => { + const frustum = createTestCameraFrustum(Math.PI / 2, 1.0, 0.1, 100.0, -5, 0); + + // Intersection test is done in xy-plane + const aabbList = [ + new Aabb(vec3.fromValues(-1, -1, 0), vec3.fromValues(1, 1, 0)), + new Aabb(vec3.fromValues(-5, -5, 0), vec3.fromValues(5, 5, 0)), + new Aabb(vec3.fromValues(-5, -5, 0), vec3.fromValues(-4, -2, 0)) + ]; + + for (const aabb of aabbList) + expect(aabb.intersects(frustum)).toBe(2); + + }); + + test('Aabb intersecting with a frustum', () => { + const frustum = createTestCameraFrustum(Math.PI / 2, 1.0, 0.1, 100.0, -5, 0); + + const aabbList = [ + new Aabb(vec3.fromValues(-6, -6, 0), vec3.fromValues(6, 6, 0)), + new Aabb(vec3.fromValues(-6, -6, 0), vec3.fromValues(-5, -5, 0)) + ]; + + for (const aabb of aabbList) + expect(aabb.intersects(frustum)).toBe(1); + + }); + + test('No intersection between aabb and frustum', () => { + const frustum = createTestCameraFrustum(Math.PI / 2, 1.0, 0.1, 100.0, -5, 0); + + const aabbList = [ + new Aabb(vec3.fromValues(-6, 0, 0), vec3.fromValues(-5.5, 0, 0)), + new Aabb(vec3.fromValues(-6, -6, 0), vec3.fromValues(-5.5, -5.5, 0)), + new Aabb(vec3.fromValues(7, -10, 0), vec3.fromValues(7.1, 20, 0)) + ]; + + for (const aabb of aabbList) + expect(aabb.intersects(frustum)).toBe(0); + + }); + +}); + +describe('frustum', () => { + test('Create a frustum from inverse projection matrix', () => { + const proj = new Float64Array(16) as any as mat4; + const invProj = new Float64Array(16) as any as mat4; + mat4.perspective(proj, Math.PI / 2, 1.0, 0.1, 100.0); + mat4.invert(invProj, proj); + + const frustum = Frustum.fromInvProjectionMatrix(invProj, 1.0, 0.0); + // mat4.perspective generates a projection matrix for right handed coordinate space. + // This means that forward direction will be -z + const expectedFrustumPoints = [ + [-0.1, 0.1, -0.1, 1.0], + [0.1, 0.1, -0.1, 1.0], + [0.1, -0.1, -0.1, 1.0], + [-0.1, -0.1, -0.1, 1.0], + [-100.0, 100.0, -100.0, 1.0], + [100.0, 100.0, -100.0, 1.0], + [100.0, -100.0, -100.0, 1.0], + [-100.0, -100.0, -100.0, 1.0], + ]; + + frustum.points = frustum.points.map(array => array.map(n => Math.round(n * 10) / 10)) as vec4[]; + frustum.planes = frustum.planes.map(array => array.map(n => Math.round(n * 1000) / 1000)) as vec4[]; + + const expectedFrustumPlanes = [ + [0, 0, 1.0, 0.1], + [-0, -0, -1.0, -100.0], + [-0.707, 0, 0.707, -0], + [0.707, 0, 0.707, -0], + [0, -0.707, 0.707, -0], + [-0, 0.707, 0.707, -0] + ]; + + expect(frustum.points).toEqual(expectedFrustumPoints); + expect(frustum.planes).toEqual(expectedFrustumPlanes); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/primitives.ts b/web/libraries/maplibre-gl/src/util/primitives.ts new file mode 100644 index 00000000..6f6f6011 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/primitives.ts @@ -0,0 +1,143 @@ +import {mat4, vec3, vec4} from 'gl-matrix'; + +class Frustum { + + constructor(public points: vec4[], public planes: vec4[]) { } + + public static fromInvProjectionMatrix(invProj: mat4, worldSize: number, zoom: number): Frustum { + const clipSpaceCorners = [ + [-1, 1, -1, 1], + [1, 1, -1, 1], + [1, -1, -1, 1], + [-1, -1, -1, 1], + [-1, 1, 1, 1], + [1, 1, 1, 1], + [1, -1, 1, 1], + [-1, -1, 1, 1] + ]; + + const scale = Math.pow(2, zoom); + + // Transform frustum corner points from clip space to tile space, Z to meters + const frustumCoords = clipSpaceCorners.map(v => { + v = vec4.transformMat4([] as any, v as any, invProj) as any; + const s = 1.0 / v[3] / worldSize * scale; + return vec4.mul(v as any, v as any, [s, s, 1.0 / v[3], s] as vec4); + }); + + const frustumPlanePointIndices = [ + [0, 1, 2], // near + [6, 5, 4], // far + [0, 3, 7], // left + [2, 1, 5], // right + [3, 2, 6], // bottom + [0, 4, 5] // top + ]; + + const frustumPlanes = frustumPlanePointIndices.map((p: number[]) => { + const a = vec3.sub([] as any, frustumCoords[p[0]] as vec3, frustumCoords[p[1]] as vec3); + const b = vec3.sub([] as any, frustumCoords[p[2]] as vec3, frustumCoords[p[1]] as vec3); + const n = vec3.normalize([] as any, vec3.cross([] as any, a, b)) as any; + const d = -vec3.dot(n, frustumCoords[p[1]] as vec3); + return n.concat(d); + }); + + return new Frustum(frustumCoords, frustumPlanes); + } +} + +class Aabb { + min: vec3; + max: vec3; + center: vec3; + + constructor(min_: vec3, max_: vec3) { + this.min = min_; + this.max = max_; + this.center = vec3.scale([] as any, vec3.add([] as any, this.min, this.max), 0.5); + } + + quadrant(index: number): Aabb { + const split = [(index % 2) === 0, index < 2]; + const qMin = vec3.clone(this.min); + const qMax = vec3.clone(this.max); + for (let axis = 0; axis < split.length; axis++) { + qMin[axis] = split[axis] ? this.min[axis] : this.center[axis]; + qMax[axis] = split[axis] ? this.center[axis] : this.max[axis]; + } + // Elevation is always constant, hence quadrant.max.z = this.max.z + qMax[2] = this.max[2]; + return new Aabb(qMin, qMax); + } + + distanceX(point: Array): number { + const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]); + return pointOnAabb - point[0]; + } + + distanceY(point: Array): number { + const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]); + return pointOnAabb - point[1]; + } + + // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection, + // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum. + intersects(frustum: Frustum): number { + // Execute separating axis test between two convex objects to find intersections + // Each frustum plane together with 3 major axes define the separating axes + + const aabbPoints = [ + [this.min[0], this.min[1], this.min[2], 1], + [this.max[0], this.min[1], this.min[2], 1], + [this.max[0], this.max[1], this.min[2], 1], + [this.min[0], this.max[1], this.min[2], 1], + [this.min[0], this.min[1], this.max[2], 1], + [this.max[0], this.min[1], this.max[2], 1], + [this.max[0], this.max[1], this.max[2], 1], + [this.min[0], this.max[1], this.max[2], 1] + ]; + + let fullyInside = true; + + for (let p = 0; p < frustum.planes.length; p++) { + const plane = frustum.planes[p]; + let pointsInside = 0; + + for (let i = 0; i < aabbPoints.length; i++) { + if (vec4.dot(plane, aabbPoints[i] as any) >= 0) { + pointsInside++; + } + } + + if (pointsInside === 0) + return 0; + + if (pointsInside !== aabbPoints.length) + fullyInside = false; + } + + if (fullyInside) + return 2; + + for (let axis = 0; axis < 3; axis++) { + let projMin = Number.MAX_VALUE; + let projMax = -Number.MAX_VALUE; + + for (let p = 0; p < frustum.points.length; p++) { + const projectedPoint = frustum.points[p][axis] - this.min[axis]; + + projMin = Math.min(projMin, projectedPoint); + projMax = Math.max(projMax, projectedPoint); + } + + if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) + return 0; + } + + return 1; + } +} +export { + Aabb, + Frustum +}; diff --git a/web/libraries/maplibre-gl/src/util/request_manager.test.ts b/web/libraries/maplibre-gl/src/util/request_manager.test.ts new file mode 100644 index 00000000..a3416b5d --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/request_manager.test.ts @@ -0,0 +1,21 @@ +import {RequestManager} from './request_manager'; + +describe('RequestManager.normalizeSpriteURL', () => { + test('concantenates path, ratio, and extension for non-mapbox:// scheme', () => { + expect( + new RequestManager().normalizeSpriteURL('http://www.foo.com/bar', '@2x', '.png') + ).toBe('http://www.foo.com/bar@2x.png'); + }); + + test('concantenates path, ratio, and extension for file:/// scheme', () => { + expect( + new RequestManager().normalizeSpriteURL('file:///path/to/bar', '@2x', '.png') + ).toBe('file:///path/to/bar@2x.png'); + }); + + test('normalizes non-mapbox:// scheme when query string exists', () => { + expect( + new RequestManager().normalizeSpriteURL('http://www.foo.com/bar?fresh=true', '@2x', '.png') + ).toBe('http://www.foo.com/bar@2x.png?fresh=true'); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/request_manager.ts b/web/libraries/maplibre-gl/src/util/request_manager.ts new file mode 100644 index 00000000..c387e4b6 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/request_manager.ts @@ -0,0 +1,74 @@ +import type {RequestParameters} from './ajax'; + +/** + * A type of MapLibre resource. + */ +export const enum ResourceType { + Glyphs = 'Glyphs', + Image = 'Image', + Source = 'Source', + SpriteImage = 'SpriteImage', + SpriteJSON = 'SpriteJSON', + Style = 'Style', + Tile = 'Tile', + Unknown = 'Unknown', +} + +/** + * This function is used to tranform a request. + * It is used just before executing the relevant request. + */ +export type RequestTransformFunction = (url: string, resourceType?: ResourceType) => RequestParameters | undefined; + +type UrlObject = { + protocol: string; + authority: string; + path: string; + params: Array; +}; + +export class RequestManager { + _transformRequestFn: RequestTransformFunction; + + constructor(transformRequestFn?: RequestTransformFunction) { + this._transformRequestFn = transformRequestFn; + } + + transformRequest(url: string, type: ResourceType) { + if (this._transformRequestFn) { + return this._transformRequestFn(url, type) || {url}; + } + + return {url}; + } + + normalizeSpriteURL(url: string, format: string, extension: string): string { + const urlObject = parseUrl(url); + urlObject.path += `${format}${extension}`; + return formatUrl(urlObject); + } + + setTransformRequest(transformRequest: RequestTransformFunction) { + this._transformRequestFn = transformRequest; + } +} + +const urlRe = /^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/; + +function parseUrl(url: string): UrlObject { + const parts = url.match(urlRe); + if (!parts) { + throw new Error(`Unable to parse URL "${url}"`); + } + return { + protocol: parts[1], + authority: parts[2], + path: parts[3] || '/', + params: parts[4] ? parts[4].split('&') : [] + }; +} + +function formatUrl(obj: UrlObject): string { + const params = obj.params.length ? `?${obj.params.join('&')}` : ''; + return `${obj.protocol}://${obj.authority}${obj.path}${params}`; +} diff --git a/web/libraries/maplibre-gl/src/util/resolve_tokens.test.ts b/web/libraries/maplibre-gl/src/util/resolve_tokens.test.ts new file mode 100644 index 00000000..ed9fbe88 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/resolve_tokens.test.ts @@ -0,0 +1,45 @@ +import {resolveTokens} from './resolve_tokens'; + +test('resolveToken', () => { + expect('3 Fine Fields').toBe(resolveTokens({a: 3, b: 'Fine', c: 'Fields'}, '{a} {b} {c}')); + + // No tokens. + expect(resolveTokens({}, 'Test')).toBe('Test'); + + // Basic. + expect(resolveTokens({name: 'Test'}, '{name}')).toBe('Test'); + expect(resolveTokens({name: 'Test'}, '{name}-suffix')).toBe('Test-suffix'); + + // No properties. + expect(resolveTokens(null, '{name}')).toBe(''); + expect(resolveTokens(null, '{name}-suffix')).toBe('-suffix'); + + // Undefined property. + expect(resolveTokens({}, '{name}')).toBe(''); + expect(resolveTokens({}, '{name}-suffix')).toBe('-suffix'); + + // Non-latin. + expect(resolveTokens({city: '서울특별시'}, '{city}')).toBe('서울특별시'); + + // Unicode up to 65535. + expect(resolveTokens({text: '\ufff0'}, '{text}')).toBe('\ufff0'); + expect(resolveTokens({text: '\uffff'}, '{text}')).toBe('\uffff'); + + // Non-string values cast to strings. + expect(resolveTokens({name: 5000}, '{name}')).toBe('5000'); + expect(resolveTokens({name: -15.5}, '{name}')).toBe('-15.5'); + expect(resolveTokens({name: true}, '{name}')).toBe('true'); + + // Non-string values cast to strings, with token replacement. + expect(resolveTokens({name: 5000}, '{name}-suffix')).toBe('5000-suffix'); + expect(resolveTokens({name: -15.5}, '{name}-suffix')).toBe('-15.5-suffix'); + expect(resolveTokens({name: true}, '{name}-suffix')).toBe('true-suffix'); + + // Special characters in token. + expect(resolveTokens({'dashed-property': 'dashed'}, '{dashed-property}')).toBe('dashed'); + expect(resolveTokens({'HØYDE': 150}, '{HØYDE} m')).toBe('150 m'); + expect( + resolveTokens({'$special:characters;': 'mapbox'}, '{$special:characters;}') + ).toBe('mapbox'); + +}); diff --git a/web/libraries/maplibre-gl/src/util/resolve_tokens.ts b/web/libraries/maplibre-gl/src/util/resolve_tokens.ts new file mode 100644 index 00000000..af0e8f23 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/resolve_tokens.ts @@ -0,0 +1,17 @@ +/** + * Replace tokens in a string template with values in an object + * + * @param properties - a key/value relationship between tokens and replacements + * @param text - the template string + * @returns the template with tokens replaced + */ +export function resolveTokens( + properties: { + readonly [x: string]: unknown; + } | null, + text: string +): string { + return text.replace(/{([^{}]+)}/g, (match, key: string) => { + return properties && key in properties ? String(properties[key]) : ''; + }); +} diff --git a/web/libraries/maplibre-gl/src/util/script_detection.ts b/web/libraries/maplibre-gl/src/util/script_detection.ts new file mode 100644 index 00000000..6e916c08 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/script_detection.ts @@ -0,0 +1,323 @@ +/* eslint-disable new-cap */ + +import {unicodeBlockLookup as isChar} from './is_char_in_unicode_block'; + +export function allowsIdeographicBreaking(chars: string) { + for (const char of chars) { + if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) return false; + } + return true; +} + +export function allowsVerticalWritingMode(chars: string) { + for (const char of chars) { + if (charHasUprightVerticalOrientation(char.charCodeAt(0))) return true; + } + return false; +} + +export function allowsLetterSpacing(chars: string) { + for (const char of chars) { + if (!charAllowsLetterSpacing(char.charCodeAt(0))) return false; + } + return true; +} + +export function charAllowsLetterSpacing(char: number) { + if (isChar['Arabic'](char)) return false; + if (isChar['Arabic Supplement'](char)) return false; + if (isChar['Arabic Extended-A'](char)) return false; + if (isChar['Arabic Presentation Forms-A'](char)) return false; + if (isChar['Arabic Presentation Forms-B'](char)) return false; + + return true; +} + +export function charAllowsIdeographicBreaking(char: number) { + // Return early for characters outside all ideographic ranges. + if (char < 0x2E80) return false; + + if (isChar['Bopomofo Extended'](char)) return true; + if (isChar['Bopomofo'](char)) return true; + if (isChar['CJK Compatibility Forms'](char)) return true; + if (isChar['CJK Compatibility Ideographs'](char)) return true; + if (isChar['CJK Compatibility'](char)) return true; + if (isChar['CJK Radicals Supplement'](char)) return true; + if (isChar['CJK Strokes'](char)) return true; + if (isChar['CJK Symbols and Punctuation'](char)) return true; + if (isChar['CJK Unified Ideographs Extension A'](char)) return true; + if (isChar['CJK Unified Ideographs'](char)) return true; + if (isChar['Enclosed CJK Letters and Months'](char)) return true; + if (isChar['Halfwidth and Fullwidth Forms'](char)) return true; + if (isChar['Hiragana'](char)) return true; + if (isChar['Ideographic Description Characters'](char)) return true; + if (isChar['Kangxi Radicals'](char)) return true; + if (isChar['Katakana Phonetic Extensions'](char)) return true; + if (isChar['Katakana'](char)) return true; + if (isChar['Vertical Forms'](char)) return true; + if (isChar['Yi Radicals'](char)) return true; + if (isChar['Yi Syllables'](char)) return true; + + return false; +} + +// The following logic comes from +// . +// Keep it synchronized with +// . +// The data file denotes with “U” or “Tu” any codepoint that may be drawn +// upright in vertical text but does not distinguish between upright and +// “neutral” characters. + +// Blocks in the Unicode supplementary planes are excluded from this module due +// to . + +/** + * Returns true if the given Unicode codepoint identifies a character with + * upright orientation. + * + * A character has upright orientation if it is drawn upright (unrotated) + * whether the line is oriented horizontally or vertically, even if both + * adjacent characters can be rotated. For example, a Chinese character is + * always drawn upright. An uprightly oriented character causes an adjacent + * “neutral” character to be drawn upright as well. + */ +export function charHasUprightVerticalOrientation(char: number) { + if (char === 0x02EA /* modifier letter yin departing tone mark */ || + char === 0x02EB /* modifier letter yang departing tone mark */) { + return true; + } + + // Return early for characters outside all ranges whose characters remain + // upright in vertical writing mode. + if (char < 0x1100) return false; + + if (isChar['Bopomofo Extended'](char)) return true; + if (isChar['Bopomofo'](char)) return true; + if (isChar['CJK Compatibility Forms'](char)) { + if (!((char >= 0xFE49 /* dashed overline */ && char <= 0xFE4F) /* wavy low line */)) { + return true; + } + } + if (isChar['CJK Compatibility Ideographs'](char)) return true; + if (isChar['CJK Compatibility'](char)) return true; + if (isChar['CJK Radicals Supplement'](char)) return true; + if (isChar['CJK Strokes'](char)) return true; + if (isChar['CJK Symbols and Punctuation'](char)) { + if (!((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) && + !((char >= 0x3014 /* left tortoise shell bracket */ && char <= 0x301F) /* low double prime quotation mark */) && + char !== 0x3030 /* wavy dash */) { + return true; + } + } + if (isChar['CJK Unified Ideographs Extension A'](char)) return true; + if (isChar['CJK Unified Ideographs'](char)) return true; + if (isChar['Enclosed CJK Letters and Months'](char)) return true; + if (isChar['Hangul Compatibility Jamo'](char)) return true; + if (isChar['Hangul Jamo Extended-A'](char)) return true; + if (isChar['Hangul Jamo Extended-B'](char)) return true; + if (isChar['Hangul Jamo'](char)) return true; + if (isChar['Hangul Syllables'](char)) return true; + if (isChar['Hiragana'](char)) return true; + if (isChar['Ideographic Description Characters'](char)) return true; + if (isChar['Kanbun'](char)) return true; + if (isChar['Kangxi Radicals'](char)) return true; + if (isChar['Katakana Phonetic Extensions'](char)) return true; + if (isChar['Katakana'](char)) { + if (char !== 0x30FC /* katakana-hiragana prolonged sound mark */) { + return true; + } + } + if (isChar['Halfwidth and Fullwidth Forms'](char)) { + if (char !== 0xFF08 /* fullwidth left parenthesis */ && + char !== 0xFF09 /* fullwidth right parenthesis */ && + char !== 0xFF0D /* fullwidth hyphen-minus */ && + !((char >= 0xFF1A /* fullwidth colon */ && char <= 0xFF1E) /* fullwidth greater-than sign */) && + char !== 0xFF3B /* fullwidth left square bracket */ && + char !== 0xFF3D /* fullwidth right square bracket */ && + char !== 0xFF3F /* fullwidth low line */ && + !(char >= 0xFF5B /* fullwidth left curly bracket */ && char <= 0xFFDF) && + char !== 0xFFE3 /* fullwidth macron */ && + !(char >= 0xFFE8 /* halfwidth forms light vertical */ && char <= 0xFFEF)) { + return true; + } + } + if (isChar['Small Form Variants'](char)) { + if (!((char >= 0xFE58 /* small em dash */ && char <= 0xFE5E) /* small right tortoise shell bracket */) && + !((char >= 0xFE63 /* small hyphen-minus */ && char <= 0xFE66) /* small equals sign */)) { + return true; + } + } + if (isChar['Unified Canadian Aboriginal Syllabics'](char)) return true; + if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) return true; + if (isChar['Vertical Forms'](char)) return true; + if (isChar['Yijing Hexagram Symbols'](char)) return true; + if (isChar['Yi Syllables'](char)) return true; + if (isChar['Yi Radicals'](char)) return true; + + return false; +} + +/** + * Returns true if the given Unicode codepoint identifies a character with + * neutral orientation. + * + * A character has neutral orientation if it may be drawn rotated or unrotated + * when the line is oriented vertically, depending on the orientation of the + * adjacent characters. For example, along a verticlly oriented line, the vulgar + * fraction ½ is drawn upright among Chinese characters but rotated among Latin + * letters. A neutrally oriented character does not influence whether an + * adjacent character is drawn upright or rotated. + */ +export function charHasNeutralVerticalOrientation(char: number) { + if (isChar['Latin-1 Supplement'](char)) { + if (char === 0x00A7 /* section sign */ || + char === 0x00A9 /* copyright sign */ || + char === 0x00AE /* registered sign */ || + char === 0x00B1 /* plus-minus sign */ || + char === 0x00BC /* vulgar fraction one quarter */ || + char === 0x00BD /* vulgar fraction one half */ || + char === 0x00BE /* vulgar fraction three quarters */ || + char === 0x00D7 /* multiplication sign */ || + char === 0x00F7 /* division sign */) { + return true; + } + } + if (isChar['General Punctuation'](char)) { + if (char === 0x2016 /* double vertical line */ || + char === 0x2020 /* dagger */ || + char === 0x2021 /* double dagger */ || + char === 0x2030 /* per mille sign */ || + char === 0x2031 /* per ten thousand sign */ || + char === 0x203B /* reference mark */ || + char === 0x203C /* double exclamation mark */ || + char === 0x2042 /* asterism */ || + char === 0x2047 /* double question mark */ || + char === 0x2048 /* question exclamation mark */ || + char === 0x2049 /* exclamation question mark */ || + char === 0x2051 /* two asterisks aligned vertically */) { + return true; + } + } + if (isChar['Letterlike Symbols'](char)) return true; + if (isChar['Number Forms'](char)) return true; + if (isChar['Miscellaneous Technical'](char)) { + if ((char >= 0x2300 /* diameter sign */ && char <= 0x2307 /* wavy line */) || + (char >= 0x230C /* bottom right crop */ && char <= 0x231F /* bottom right corner */) || + (char >= 0x2324 /* up arrowhead between two horizontal bars */ && char <= 0x2328 /* keyboard */) || + char === 0x232B /* erase to the left */ || + (char >= 0x237D /* shouldered open box */ && char <= 0x239A /* clear screen symbol */) || + (char >= 0x23BE /* dentistry symbol light vertical and top right */ && char <= 0x23CD /* square foot */) || + char === 0x23CF /* eject symbol */ || + (char >= 0x23D1 /* metrical breve */ && char <= 0x23DB /* fuse */) || + (char >= 0x23E2 /* white trapezium */ && char <= 0x23FF)) { + return true; + } + } + if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) return true; + if (isChar['Optical Character Recognition'](char)) return true; + if (isChar['Enclosed Alphanumerics'](char)) return true; + if (isChar['Geometric Shapes'](char)) return true; + if (isChar['Miscellaneous Symbols'](char)) { + if (!((char >= 0x261A /* black left pointing index */ && char <= 0x261F) /* white down pointing index */)) { + return true; + } + } + if (isChar['Miscellaneous Symbols and Arrows'](char)) { + if ((char >= 0x2B12 /* square with top half black */ && char <= 0x2B2F /* white vertical ellipse */) || + (char >= 0x2B50 /* white medium star */ && char <= 0x2B59 /* heavy circled saltire */) || + (char >= 0x2BB8 /* upwards white arrow from bar with horizontal bar */ && char <= 0x2BEB)) { + return true; + } + } + if (isChar['CJK Symbols and Punctuation'](char)) return true; + if (isChar['Katakana'](char)) return true; + if (isChar['Private Use Area'](char)) return true; + if (isChar['CJK Compatibility Forms'](char)) return true; + if (isChar['Small Form Variants'](char)) return true; + if (isChar['Halfwidth and Fullwidth Forms'](char)) return true; + + if (char === 0x221E /* infinity */ || + char === 0x2234 /* therefore */ || + char === 0x2235 /* because */ || + (char >= 0x2700 /* black safety scissors */ && char <= 0x2767 /* rotated floral heart bullet */) || + (char >= 0x2776 /* dingbat negative circled digit one */ && char <= 0x2793 /* dingbat negative circled sans-serif number ten */) || + char === 0xFFFC /* object replacement character */ || + char === 0xFFFD /* replacement character */) { + return true; + } + + return false; +} + +/** + * Returns true if the given Unicode codepoint identifies a character with + * rotated orientation. + * + * A character has rotated orientation if it is drawn rotated when the line is + * oriented vertically, even if both adjacent characters are upright. For + * example, a Latin letter is drawn rotated along a vertical line. A rotated + * character causes an adjacent “neutral” character to be drawn rotated as well. + */ +export function charHasRotatedVerticalOrientation(char: number) { + return !(charHasUprightVerticalOrientation(char) || + charHasNeutralVerticalOrientation(char)); +} + +export function charInComplexShapingScript(char: number) { + return isChar['Arabic'](char) || + isChar['Arabic Supplement'](char) || + isChar['Arabic Extended-A'](char) || + isChar['Arabic Presentation Forms-A'](char) || + isChar['Arabic Presentation Forms-B'](char); +} + +export function charInRTLScript(char: number) { + // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts + return (char >= 0x0590 && char <= 0x08FF) || + isChar['Arabic Presentation Forms-A'](char) || + isChar['Arabic Presentation Forms-B'](char); +} + +export function charInSupportedScript(char: number, canRenderRTL: boolean) { + // This is a rough heuristic: whether we "can render" a script + // actually depends on the properties of the font being used + // and whether differences from the ideal rendering are considered + // semantically significant. + + // Even in Latin script, we "can't render" combinations such as the fi + // ligature, but we don't consider that semantically significant. + if (!canRenderRTL && charInRTLScript(char)) { + return false; + } + if ((char >= 0x0900 && char <= 0x0DFF) || + // Main blocks for Indic scripts and Sinhala + (char >= 0x0F00 && char <= 0x109F) || + // Main blocks for Tibetan and Myanmar + isChar['Khmer'](char)) { + // These blocks cover common scripts that require + // complex text shaping, based on unicode script metadata: + // http://www.unicode.org/repos/cldr/trunk/common/properties/scriptMetadata.txt + // where "Web Rank <= 32" "Shaping Required = YES" + return false; + } + return true; +} + +export function stringContainsRTLText(chars: string): boolean { + for (const char of chars) { + if (charInRTLScript(char.charCodeAt(0))) { + return true; + } + } + return false; +} + +export function isStringInSupportedScript(chars: string, canRenderRTL: boolean) { + for (const char of chars) { + if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) { + return false; + } + } + return true; +} diff --git a/web/libraries/maplibre-gl/src/util/smart_wrap.ts b/web/libraries/maplibre-gl/src/util/smart_wrap.ts new file mode 100644 index 00000000..71f9e2b9 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/smart_wrap.ts @@ -0,0 +1,51 @@ +import {LngLat} from '../geo/lng_lat'; + +import type Point from '@mapbox/point-geometry'; +import type {Transform} from '../geo/transform'; + +/** + * Given a LngLat, prior projected position, and a transform, return a new LngLat shifted + * n × 360° east or west for some n ≥ 0 such that: + * + * * the projected location of the result is on screen, if possible, and secondarily: + * * the difference between the projected location of the result and the prior position + * is minimized. + * + * The object is to preserve perceived object constancy for Popups and Markers as much as + * possible; they should avoid shifting large distances across the screen, even when the + * map center changes by ±360° due to automatic wrapping, and when about to go off screen, + * should wrap just enough to avoid doing so. + */ +export function smartWrap(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat { + lngLat = new LngLat(lngLat.lng, lngLat.lat); + + // First, try shifting one world in either direction, and see if either is closer to the + // prior position. This preserves object constancy when the map center is auto-wrapped + // during animations. + if (priorPos) { + const left = new LngLat(lngLat.lng - 360, lngLat.lat); + const right = new LngLat(lngLat.lng + 360, lngLat.lat); + const delta = transform.locationPoint(lngLat).distSqr(priorPos); + if (transform.locationPoint(left).distSqr(priorPos) < delta) { + lngLat = left; + } else if (transform.locationPoint(right).distSqr(priorPos) < delta) { + lngLat = right; + } + } + + // Second, wrap toward the center until the new position is on screen, or we can't get + // any closer. + while (Math.abs(lngLat.lng - transform.center.lng) > 180) { + const pos = transform.locationPoint(lngLat); + if (pos.x >= 0 && pos.y >= 0 && pos.x <= transform.width && pos.y <= transform.height) { + break; + } + if (lngLat.lng > transform.center.lng) { + lngLat.lng -= 360; + } else { + lngLat.lng += 360; + } + } + + return lngLat; +} diff --git a/web/libraries/maplibre-gl/src/util/struct_array.test.ts b/web/libraries/maplibre-gl/src/util/struct_array.test.ts new file mode 100644 index 00000000..77e2d161 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/struct_array.test.ts @@ -0,0 +1,101 @@ +import {StructArrayLayout3i6, FeatureIndexArray} from '../data/array_types.g'; + +describe('StructArray', () => { + class TestArray extends StructArrayLayout3i6 {} + + test('array constructs itself', () => { + const array = new TestArray(); + expect(array).toHaveLength(0); + expect(array.arrayBuffer).toBeTruthy(); + }); + + test('emplaceBack', () => { + const array = new TestArray(); + + expect(0).toBe(array.emplaceBack(1, 7, 3)); + expect(1).toBe(array.emplaceBack(4, 2, 5)); + + expect(array).toHaveLength(2); + + expect(array.int16.slice(0, 6)).toEqual(new Int16Array([1, 7, 3, 4, 2, 5])); + }); + + test('emplaceBack gracefully accepts extra arguments', () => { + // emplaceBack is typically used in fairly hot code paths, where + // conditionally varying the number of arguments can be expensive. + const array = new TestArray(); + expect((array as any).emplaceBack(3, 1, 4, 1, 5, 9)).toBe(0); + expect(array).toHaveLength(1); + expect(array.int16.slice(0, 3)).toEqual(new Int16Array([3, 1, 4])); + }); + + test('reserve', () => { + const array = new TestArray(); + + array.reserve(100); + const initialCapacity = array.capacity; + + for (let i = 0; i < 100; i++) { + array.emplaceBack(1, 1, 1); + expect(array.capacity).toBe(initialCapacity); + } + }); + + test('automatically resizes', () => { + const array = new TestArray(); + const initialCapacity = array.capacity; + + while (initialCapacity > array.length) { + array.emplaceBack(1, 1, 1); + } + + expect(array.capacity).toBe(initialCapacity); + + array.emplaceBack(1, 1, 1); + expect(array.capacity > initialCapacity).toBeTruthy(); + }); + + test('trims', () => { + const array = new TestArray(); + const capacityInitial = array.capacity; + + array.emplaceBack(1, 1, 1); + expect(array.capacity).toBe(capacityInitial); + + array._trim(); + expect(array.capacity).toBe(1); + expect(array.arrayBuffer.byteLength).toBe(array.bytesPerElement); + }); +}); + +describe('FeatureIndexArray', () => { + class TestArray extends FeatureIndexArray {} + + test('array constructs itself', () => { + const array = new TestArray(); + expect(array).toHaveLength(0); + expect(array.arrayBuffer).toBeTruthy(); + }); + + test('emplace and retrieve', () => { + const array = new TestArray(); + expect(0).toBe(array.emplaceBack(1, 7, 3)); + expect(1).toBe(array.emplaceBack(4, 2, 5)); + + expect(array).toHaveLength(2); + + const elem0 = array.get(0); + expect(elem0).toBeTruthy(); + + expect(elem0.featureIndex).toBe(1); + expect(elem0.sourceLayerIndex).toBe(7); + expect(elem0.bucketIndex).toBe(3); + + const elem1 = array.get(1); + expect(elem1).toBeTruthy(); + + expect(elem1.featureIndex).toBe(4); + expect(elem1.sourceLayerIndex).toBe(2); + expect(elem1.bucketIndex).toBe(5); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/struct_array.ts b/web/libraries/maplibre-gl/src/util/struct_array.ts new file mode 100644 index 00000000..8ab3e495 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/struct_array.ts @@ -0,0 +1,248 @@ +// Note: all "sizes" are measured in bytes + +import type {Transferable} from '../types/transferable'; + +/** + * @internal + * A view type size + */ +const viewTypes = { + 'Int8': Int8Array, + 'Uint8': Uint8Array, + 'Int16': Int16Array, + 'Uint16': Uint16Array, + 'Int32': Int32Array, + 'Uint32': Uint32Array, + 'Float32': Float32Array +}; + +/** + * @internal + * A view type size + */ +export type ViewType = keyof typeof viewTypes; + +/** @internal */ +class Struct { + _pos1: number; + _pos2: number; + _pos4: number; + _pos8: number; + readonly _structArray: StructArray; + + // The following properties are defined on the prototype of sub classes. + size: number; + + /** + * @param structArray - The StructArray the struct is stored in + * @param index - The index of the struct in the StructArray. + */ + constructor(structArray: StructArray, index: number) { + (this as any)._structArray = structArray; + this._pos1 = index * this.size; + this._pos2 = this._pos1 / 2; + this._pos4 = this._pos1 / 4; + this._pos8 = this._pos1 / 8; + } +} + +const DEFAULT_CAPACITY = 128; +const RESIZE_MULTIPLIER = 5; + +/** + * @internal + * A struct array memeber + */ +export type StructArrayMember = { + name: string; + type: ViewType; + components: number; + offset: number; +}; + +export type StructArrayLayout = { + members: Array; + size: number; + alignment: number; +}; + +/** + * An array that can be desialized + */ +export type SerializedStructArray = { + length: number; + arrayBuffer: ArrayBuffer; +}; + +/** + * @internal + * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray` + * making it behave like an array of typed structs. + * + * Conceptually, a StructArray is comprised of elements, i.e., instances of its + * associated struct type. Each particular struct type, together with an + * alignment size, determines the memory layout of a StructArray whose elements + * are of that type. Thus, for each such layout that we need, we have + * a corresponding StructArrayLayout class, inheriting from StructArray and + * implementing `emplaceBack()` and `_refreshViews()`. + * + * In some cases, where we need to access particular elements of a StructArray, + * we implement a more specific subclass that inherits from one of the + * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured + * object whose properties are proxies into the underlying memory space for the + * i-th element. This affords the convience of working with (seemingly) plain + * Javascript objects without the overhead of serializing/deserializing them + * into ArrayBuffers for efficient web worker transfer. + */ +abstract class StructArray { + capacity: number; + length: number; + isTransferred: boolean; + arrayBuffer: ArrayBuffer; + uint8: Uint8Array; + + // The following properties are defined on the prototype. + members: Array; + bytesPerElement: number; + abstract emplaceBack(...v: number[]); + abstract emplace(i: number, ...v: number[]); + + constructor() { + this.isTransferred = false; + this.capacity = -1; + this.resize(0); + } + + /** + * Serialize a StructArray instance. Serializes both the raw data and the + * metadata needed to reconstruct the StructArray base class during + * deserialization. + */ + static serialize(array: StructArray, transferables?: Array): SerializedStructArray { + + array._trim(); + + if (transferables) { + array.isTransferred = true; + transferables.push(array.arrayBuffer); + } + + return { + length: array.length, + arrayBuffer: array.arrayBuffer, + }; + } + + static deserialize(input: SerializedStructArray) { + const structArray = Object.create(this.prototype); + structArray.arrayBuffer = input.arrayBuffer; + structArray.length = input.length; + structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement; + structArray._refreshViews(); + return structArray; + } + + /** + * Resize the array to discard unused capacity. + */ + _trim() { + if (this.length !== this.capacity) { + this.capacity = this.length; + this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement); + this._refreshViews(); + } + } + + /** + * Resets the length of the array to 0 without de-allocating capcacity. + */ + clear() { + this.length = 0; + } + + /** + * Resize the array. + * If `n` is greater than the current length then additional elements with undefined values are added. + * If `n` is less than the current length then the array will be reduced to the first `n` elements. + * @param n - The new size of the array. + */ + resize(n: number) { + this.reserve(n); + this.length = n; + } + + /** + * Indicate a planned increase in size, so that any necessary allocation may + * be done once, ahead of time. + * @param n - The expected size of the array. + */ + reserve(n: number) { + if (n > this.capacity) { + this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY); + this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement); + + const oldUint8Array = this.uint8; + this._refreshViews(); + if (oldUint8Array) this.uint8.set(oldUint8Array); + } + } + + /** + * Create TypedArray views for the current ArrayBuffer. + */ + _refreshViews() { + throw new Error('_refreshViews() must be implemented by each concrete StructArray layout'); + } +} + +/** + * Given a list of member fields, create a full StructArrayLayout, in + * particular calculating the correct byte offset for each field. This data + * is used at build time to generate StructArrayLayout_*#emplaceBack() and + * other accessors, and at runtime for binding vertex buffer attributes. + */ +function createLayout( + members: Array<{ + name: string; + type: ViewType; + readonly components?: number; + }>, + alignment: number = 1 +): StructArrayLayout { + + let offset = 0; + let maxSize = 0; + const layoutMembers = members.map((member) => { + const typeSize = sizeOf(member.type); + const memberOffset = offset = align(offset, Math.max(alignment, typeSize)); + const components = member.components || 1; + + maxSize = Math.max(maxSize, typeSize); + offset += typeSize * components; + + return { + name: member.name, + type: member.type, + components, + offset: memberOffset, + }; + }); + + const size = align(offset, Math.max(maxSize, alignment)); + + return { + members: layoutMembers, + size, + alignment + }; +} + +function sizeOf(type: ViewType): number { + return viewTypes[type].BYTES_PER_ELEMENT; +} + +function align(offset: number, size: number): number { + return Math.ceil(offset / size) * size; +} + +export {StructArray, Struct, viewTypes, createLayout}; diff --git a/web/libraries/maplibre-gl/src/util/style.test.ts b/web/libraries/maplibre-gl/src/util/style.test.ts new file mode 100644 index 00000000..7b5ea760 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/style.test.ts @@ -0,0 +1,34 @@ +import {coerceSpriteToArray} from './style'; + +describe('style utils', () => { + describe('#coerceSpriteToArray', () => { + test('input === output when array', () => { + const inputSpriteArray = [{id: 'id', url: 'url'}]; + const outputSpriteArray = coerceSpriteToArray(inputSpriteArray); + expect(outputSpriteArray).toHaveLength(1); + expect(outputSpriteArray[0].id).toBe('id'); + expect(outputSpriteArray[0].url).toBe('url'); + }); + + test('coerced to array when string', () => { + const expected = [{id: 'default', url: 'url'}]; + expect(coerceSpriteToArray('url')).toEqual(expected); + }); + + test('returns an empty array when nothing\'s passed in', () => { + expect(coerceSpriteToArray()).toEqual([]); + }); + + test('duplicated entries should be removed', () => { + const spriteWithDuplicatedEntries = [ + {id: 'sprite1', url: 'http://www.dummy.com'}, + {id: 'sprite1', url: 'http://www.dummy.com'}]; + + const result = coerceSpriteToArray(spriteWithDuplicatedEntries); + + expect(result).toHaveLength(1); + expect(result[0].id).toBe('sprite1'); + expect(result[0].url).toBe('http://www.dummy.com'); + }); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/style.ts b/web/libraries/maplibre-gl/src/util/style.ts new file mode 100644 index 00000000..9c3db2bf --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/style.ts @@ -0,0 +1,28 @@ +import {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * Takes a SpriteSpecification value and returns it in its array form. If `undefined` is passed as an input value, an + * empty array is returned. + * duplicated entries with identical id/url will be removed in returned array + * @param sprite - optional sprite to coerce + * @returns an empty array in case `undefined` is passed; id-url pairs otherwise + */ +export function coerceSpriteToArray(sprite?: SpriteSpecification): {id: string; url: string}[] { + const resultArray: {id: string; url: string}[] = []; + + if (typeof sprite === 'string') { + resultArray.push({id: 'default', url: sprite}); + } else if (sprite && sprite.length > 0) { + const dedupArray: string[] = []; + for (const {id, url} of sprite) { + const key = `${id}${url}`; + if (dedupArray.indexOf(key) === -1) { + dedupArray.push(key); + resultArray.push({id, url}); + } + } + } + + return resultArray; + +} diff --git a/web/libraries/maplibre-gl/src/util/task_queue.test.ts b/web/libraries/maplibre-gl/src/util/task_queue.test.ts new file mode 100644 index 00000000..d3084024 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/task_queue.test.ts @@ -0,0 +1,114 @@ +import {TaskQueue} from './task_queue'; + +describe('TaskQueue', () => { + test('Calls callbacks, in order', () => { + const q = new TaskQueue(); + let first = 0; + let second = 0; + q.add(() => { + expect(++first).toBe(1); + expect(second).toBe(0); + }); + q.add(() => { + expect(first).toBe(1); + expect(++second).toBe(1); + }); + q.run(); + expect(first).toBe(1); + expect(second).toBe(1); + }); + + test('Allows a given callback to be queued multiple times', () => { + const q = new TaskQueue(); + const fn = jest.fn(); + q.add(fn); + q.add(fn); + q.run(); + expect(fn).toHaveBeenCalledTimes(2); + }); + + test('Does not call a callback that was cancelled before the queue was run', () => { + const q = new TaskQueue(); + const yes = jest.fn(); + const no = jest.fn(); + q.add(yes); + const id = q.add(no); + q.remove(id); + q.run(); + expect(yes).toHaveBeenCalledTimes(1); + expect(no).not.toHaveBeenCalled(); + }); + + test('Does not call a callback that was cancelled while the queue was running', () => { + const q = new TaskQueue(); + const yes = jest.fn(); + const no = jest.fn(); + q.add(yes); + let id; // eslint-disable-line prefer-const + q.add(() => q.remove(id)); + id = q.add(no); + q.run(); + expect(yes).toHaveBeenCalledTimes(1); + expect(no).not.toHaveBeenCalled(); + }); + + test('Allows each instance of a multiply-queued callback to be cancelled independently', () => { + const q = new TaskQueue(); + const cb = jest.fn(); + q.add(cb); + const id = q.add(cb); + q.remove(id); + q.run(); + expect(cb).toHaveBeenCalledTimes(1); + }); + + test('Does not throw if a remove() is called after running the queue', () => { + const q = new TaskQueue(); + const cb = jest.fn(); + const id = q.add(cb); + q.run(); + q.remove(id); + expect(cb).toHaveBeenCalledTimes(1); + }); + + test('Does not add tasks to the currently-running queue', () => { + const q = new TaskQueue(); + const cb = jest.fn(); + q.add(() => q.add(cb)); + q.run(); + expect(cb).not.toHaveBeenCalled(); + q.run(); + expect(cb).toHaveBeenCalledTimes(1); + }); + + test('TaskQueue#run() throws on attempted re-entrance', () => { + const q = new TaskQueue(); + q.add(() => q.run()); + expect(() => q.run()).toThrow(); + }); + + test('TaskQueue#clear() prevents queued task from being executed', () => { + const q = new TaskQueue(); + const before = jest.fn(); + const after = jest.fn(); + q.add(before); + q.clear(); + q.add(after); + q.run(); + expect(before).not.toHaveBeenCalled(); + expect(after).toHaveBeenCalledTimes(1); + }); + + test('TaskQueue#clear() interrupts currently-running queue', () => { + const q = new TaskQueue(); + const before = jest.fn(); + const after = jest.fn(); + q.add(() => q.add(after)); + q.add(() => q.clear()); + q.add(before); + q.run(); + expect(before).not.toHaveBeenCalled(); + q.run(); + expect(after).not.toHaveBeenCalled(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/task_queue.ts b/web/libraries/maplibre-gl/src/util/task_queue.ts new file mode 100644 index 00000000..b7389e9e --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/task_queue.ts @@ -0,0 +1,64 @@ +export type TaskID = number; // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61 + +type Task = { + callback: (timeStamp: number) => void; + id: TaskID; + cancelled: boolean; +}; + +export class TaskQueue { + _queue: Array; + _id: TaskID; + _cleared: boolean; + _currentlyRunning: Array | false; + + constructor() { + this._queue = []; + this._id = 0; + this._cleared = false; + this._currentlyRunning = false; + } + + add(callback: (timeStamp: number) => void): TaskID { + const id = ++this._id; + const queue = this._queue; + queue.push({callback, id, cancelled: false}); + return id; + } + + remove(id: TaskID) { + const running = this._currentlyRunning; + const queue = running ? this._queue.concat(running) : this._queue; + for (const task of queue) { + if (task.id === id) { + task.cancelled = true; + return; + } + } + } + + run(timeStamp: number = 0) { + if (this._currentlyRunning) throw new Error('Attempting to run(), but is already running.'); + const queue = this._currentlyRunning = this._queue; + + // Tasks queued by callbacks in the current queue should be executed + // on the next run, not the current run. + this._queue = []; + + for (const task of queue) { + if (task.cancelled) continue; + task.callback(timeStamp); + if (this._cleared) break; + } + + this._cleared = false; + this._currentlyRunning = false; + } + + clear() { + if (this._currentlyRunning) { + this._cleared = true; + } + this._queue = []; + } +} diff --git a/web/libraries/maplibre-gl/src/util/test/mock_fetch.ts b/web/libraries/maplibre-gl/src/util/test/mock_fetch.ts new file mode 100644 index 00000000..db6e7b13 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/test/mock_fetch.ts @@ -0,0 +1,51 @@ +export class RequestMock implements Partial { + public readonly cache: RequestCache; + public readonly headers: Headers = new Headers(); + public readonly method?: string; + public readonly url?: string; + + public get signal(): AbortSignal { + return null; + } + + constructor(input: RequestInfo | URL, init?: RequestInit) { + this.cache = typeof input === 'object' && 'cache' in input ? input.cache : init.cache; + this.method = typeof input === 'object' && 'method' in input ? input.method : init.method; + this.url = typeof input === 'object' && 'url' in input ? input.url : input.toString(); + this.headers = typeof input === 'object' && 'headers' in input ? new Headers(input.headers) : new Headers(init.headers || {}); + } +} + +class AbortControllerMock { + public signal: AbortSignal; + + public abort(): void {} +} + +export type FetchMock = jest.Mock, [input: RequestInfo | URL, init?: RequestInit], any>; + +let _AbortController: typeof AbortController; +let _Request: typeof Request; +let _fetch: typeof fetch; + +export function destroyFetchMock(): void { + global.AbortController = _AbortController ?? global.AbortController; + global.Request = _Request ?? global.Request; + global.fetch = _fetch ?? global.fetch; +} + +export function setupFetchMock(): FetchMock { + _AbortController = _AbortController ?? global.AbortController; + _Request = _Request ?? global.Request; + _fetch = _fetch ?? global.fetch; + + const fetchMock = jest.fn(async (_input: RequestInfo | URL, _init?: RequestInit): Promise => { + return {}; + }); + + global.AbortController = AbortControllerMock; + global.Request = RequestMock as unknown as typeof Request; + global.fetch = fetchMock as any; + + return fetchMock; +} diff --git a/web/libraries/maplibre-gl/src/util/test/mock_webgl.ts b/web/libraries/maplibre-gl/src/util/test/mock_webgl.ts new file mode 100644 index 00000000..3559ca26 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/test/mock_webgl.ts @@ -0,0 +1,101 @@ +import gl from 'gl'; + +export function setupMockWebGLContext(webglContext: any) { + + const mockVaoExtension = { + bindVertexArrayOES: jest.fn(), + deleteVertexArrayOES: jest.fn(), + createVertexArrayOES: jest.fn(), + }; + + const mockColorBufferExtension = { + RGB16F_EXT: jest.fn(), + }; + + const mockTextureHalfFloatExtension = { + HALF_FLOAT_OES: jest.fn(), + }; + + // Setup getExtension to return the correct mock extension + webglContext.getExtension = jest.fn((extensionName) => { + switch (extensionName) { + case 'OES_vertex_array_object': + return mockVaoExtension; + case 'EXT_color_buffer_half_float': + return mockColorBufferExtension; + case 'OES_texture_half_float': + return mockTextureHalfFloatExtension; + default: + return null; + } + }); + + // Update drawingBufferWidth and drawingBufferHeigth when viewport changes + webglContext.viewport = jest.fn((x, y, width, height) => { + webglContext.drawingBufferWidth = width; + webglContext.drawingBufferHeight = height; + }); + + // Define the properties on the WebGL context + Object.defineProperty(webglContext, 'bindVertexArray', { + get() { + const extension = this.getExtension('OES_vertex_array_object'); + return extension ? extension.bindVertexArrayOES : undefined; + }, + }); + + Object.defineProperty(webglContext, 'RGB16F', { + get() { + const extension = this.getExtension('EXT_color_buffer_half_float'); + return extension ? extension.RGB16F_EXT : undefined; + }, + }); + + Object.defineProperty(webglContext, 'HALF_FLOAT', { + get() { + const extension = this.getExtension('OES_texture_half_float'); + return extension ? extension.HALF_FLOAT_OES : undefined; + }, + }); + + Object.defineProperty(webglContext, 'deleteVertexArray', { + get() { + const extension = this.getExtension('OES_vertex_array_object'); + return extension ? extension.deleteVertexArrayOES : undefined; + }, + }); + + Object.defineProperty(webglContext, 'createVertexArray', { + get() { + const extension = this.getExtension('OES_vertex_array_object'); + return extension ? extension.createVertexArrayOES : undefined; + }, + }); + +} + +// Add webgl context with the supplied GL +export function setWebGlContext() { + const originalGetContext = global.HTMLCanvasElement.prototype.getContext; + + function imitateWebGlGetContext(type, attributes) { + if (type === 'webgl2') { + return null; + } + if (type === 'webgl') { + if (!this._webGLContext) { + this._webGLContext = gl(this.width, this.height, attributes); + if (!this._webGLContext) { + throw new Error('Failed to create a WebGL context'); + } + } + + setupMockWebGLContext(this._webGLContext); + + return this._webGLContext; + } + // Fallback to existing HTMLCanvasElement getContext behaviour + return originalGetContext.call(this, type, attributes); + } + global.HTMLCanvasElement.prototype.getContext = imitateWebGlGetContext; +} diff --git a/web/libraries/maplibre-gl/src/util/test/util.ts b/web/libraries/maplibre-gl/src/util/test/util.ts new file mode 100644 index 00000000..39e63097 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/test/util.ts @@ -0,0 +1,146 @@ +import {Map} from '../../ui/map'; +import {extend} from '../../util/util'; +import {Dispatcher} from '../../util/dispatcher'; +import {setWebGlContext} from './mock_webgl'; + +export function createMap(options?, callback?) { + const container = window.document.createElement('div'); + const defaultOptions = { + container, + interactive: false, + attributionControl: false, + maplibreLogo: false, + trackResize: true, + style: { + 'version': 8, + 'sources': {}, + 'layers': [] + } + }; + + Object.defineProperty(container, 'clientWidth', {value: 200, configurable: true}); + Object.defineProperty(container, 'clientHeight', {value: 200, configurable: true}); + + if (options && options.deleteStyle) delete defaultOptions.style; + + const map = new Map(extend(defaultOptions, options)); + if (callback) map.on('load', () => { + callback(null, map); + }); + + return map; +} + +export function equalWithPrecision(test, expected, actual, multiplier, message, extra) { + message = message || `should be equal to within ${multiplier}`; + const expectedRounded = Math.round(expected / multiplier) * multiplier; + const actualRounded = Math.round(actual / multiplier) * multiplier; + + return test.equal(expectedRounded, actualRounded, message, extra); +} + +// mock failed webgl context by dispatching "webglcontextcreationerror" event +// and returning null +export function setErrorWebGlContext() { + const originalGetContext = global.HTMLCanvasElement.prototype.getContext; + + function imitateErrorWebGlGetContext(type, attributes) { + if (type === 'webgl2' || type === 'webgl') { + const errorEvent = new Event('webglcontextcreationerror'); + (errorEvent as any).statusMessage = 'mocked webglcontextcreationerror message'; + this.dispatchEvent(errorEvent); + return null; + } + // Fallback to existing HTMLCanvasElement getContext behaviour + return originalGetContext.call(this, type, attributes); + } + global.HTMLCanvasElement.prototype.getContext = imitateErrorWebGlGetContext; +} + +export function setPerformance() { + window.performance.mark = jest.fn(); + window.performance.clearMeasures = jest.fn(); + window.performance.clearMarks = jest.fn(); +} + +export function setMatchMedia() { + // https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom + Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation(query => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // deprecated + removeListener: jest.fn(), // deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), + })), + }); +} + +function setResizeObserver() { + global.ResizeObserver = jest.fn().mockImplementation(() => ({ + observe: jest.fn(), + unobserve: jest.fn(), + disconnect: jest.fn(), + })); +} + +export function beforeMapTest() { + setPerformance(); + setWebGlContext(); + setMatchMedia(); + setResizeObserver(); +} + +export function getWrapDispatcher() { + const wrapDispatcher = (dispatcher) => { + return { + getActor() { + return dispatcher; + } + } as any as Dispatcher; + }; + + return wrapDispatcher; +} + +export function getMockDispatcher() { + const wrapDispatcher = getWrapDispatcher(); + + const mockDispatcher = wrapDispatcher({ + send() {} + }); + + return mockDispatcher; +} + +export function stubAjaxGetImage(createImageBitmap) { + global.createImageBitmap = createImageBitmap; + + global.URL.revokeObjectURL = () => {}; + global.URL.createObjectURL = (_) => { return null; }; + + // eslint-disable-next-line accessor-pairs + Object.defineProperty(global.Image.prototype, 'src', { + set(url: string) { + if (url === 'error') { + this.onerror(); + } else this.onload(); + } + }); +} + +/** + * This should be used in test that use nise since the internal buffer returned from a file is not an instance of ArrayBuffer for some reason. + * @param data - the data read from a file, for example by `fs.readFileSync(...)` + * @returns a copy of the data in the file in `ArrayBuffer` format + */ +export function bufferToArrayBuffer(data: Buffer): ArrayBuffer { + const newBuffer = new ArrayBuffer(data.buffer.byteLength); + const view = new Uint8Array(newBuffer); + data.copy(view); + return view.buffer; +} diff --git a/web/libraries/maplibre-gl/src/util/throttle.test.ts b/web/libraries/maplibre-gl/src/util/throttle.test.ts new file mode 100644 index 00000000..169d335f --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/throttle.test.ts @@ -0,0 +1,45 @@ +import {throttle} from './throttle'; + +describe('throttle', () => { + + test('does not execute unthrottled function unless throttled function is invoked', () => { + let executionCount = 0; + throttle(() => { executionCount++; }, 0); + expect(executionCount).toBe(0); + }); + + test('executes unthrottled function once per tick when period is 0', done => { + let executionCount = 0; + const throttledFunction = throttle(() => { executionCount++; }, 0); + throttledFunction(); + throttledFunction(); + expect(executionCount).toBe(1); + setTimeout(() => { + throttledFunction(); + throttledFunction(); + expect(executionCount).toBe(2); + done(); + }, 0); + }); + + test('executes unthrottled function immediately once when period is > 0', () => { + let executionCount = 0; + const throttledFunction = throttle(() => { executionCount++; }, 5); + throttledFunction(); + throttledFunction(); + throttledFunction(); + expect(executionCount).toBe(1); + }); + + test('queues exactly one execution of unthrottled function when period is > 0', done => { + let executionCount = 0; + const throttledFunction = throttle(() => { executionCount++; }, 5); + throttledFunction(); + throttledFunction(); + throttledFunction(); + setTimeout(() => { + expect(executionCount).toBe(2); + done(); + }, 10); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/throttle.ts b/web/libraries/maplibre-gl/src/util/throttle.ts new file mode 100644 index 00000000..17c90c8d --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/throttle.ts @@ -0,0 +1,28 @@ +/** + * Throttle the given function to run at most every `period` milliseconds. + */ +export function throttle void>(fn: T, time: number): (...args: Parameters) => ReturnType { + let pending = false; + let timerId: ReturnType = null; + let lastCallContext = null; + let lastCallArgs: Parameters; + + const later = () => { + timerId = null; + if (pending) { + fn.apply(lastCallContext, lastCallArgs); + timerId = setTimeout(later, time); + pending = false; + } + }; + + return (...args: Parameters) => { + pending = true; + lastCallContext = this; + lastCallArgs = args; + if (!timerId) { + later(); + } + return timerId; + }; +} diff --git a/web/libraries/maplibre-gl/src/util/throttled_invoker.ts b/web/libraries/maplibre-gl/src/util/throttled_invoker.ts new file mode 100644 index 00000000..f697a236 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/throttled_invoker.ts @@ -0,0 +1,40 @@ +/** + * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests + * are ignored until the function was actually invoked. + */ +export class ThrottledInvoker { + _channel: MessageChannel; + _triggered: boolean; + _callback: Function; + + constructor(callback: Function) { + this._callback = callback; + this._triggered = false; + if (typeof MessageChannel !== 'undefined') { + this._channel = new MessageChannel(); + this._channel.port2.onmessage = () => { + this._triggered = false; + this._callback(); + }; + } + } + + trigger() { + if (!this._triggered) { + this._triggered = true; + if (this._channel) { + this._channel.port1.postMessage(true); + } else { + setTimeout(() => { + this._triggered = false; + this._callback(); + }, 0); + } + } + } + + remove() { + delete this._channel; + this._callback = () => {}; + } +} diff --git a/web/libraries/maplibre-gl/src/util/transferable_grid_index.test.ts b/web/libraries/maplibre-gl/src/util/transferable_grid_index.test.ts new file mode 100644 index 00000000..b2f71bf2 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/transferable_grid_index.test.ts @@ -0,0 +1,56 @@ +import {TransferableGridIndex} from './transferable_grid_index'; + +describe('TransferableGridIndex', () => { + + test('indexes features', () => { + const grid = new TransferableGridIndex(100, 4, 1); + grid.insert(0, 4, 10, 6, 30); + grid.insert(1, 4, 10, 30, 12); + grid.insert(2, -10, 30, -5, 35); + + expect(grid.query(4, 10, 5, 11).sort()).toEqual([0, 1]); + expect(grid.query(24, 10, 25, 11).sort()).toEqual([1]); + expect(grid.query(40, 40, 100, 100)).toEqual([]); + expect(grid.query(-6, 0, -7, 100)).toEqual([2]); + expect(grid.query(-Infinity, -Infinity, Infinity, Infinity).sort()).toEqual([0, 1, 2]); + }); + + test('returns multiple copies of a key if multiple boxes were inserted with the same key', () => { + const grid = new TransferableGridIndex(100, 4, 0); + const key = 123; + grid.insert(key, 3, 3, 4, 4); + grid.insert(key, 13, 13, 14, 14); + grid.insert(key, 23, 23, 24, 24); + expect(grid.query(0, 0, 30, 30)).toEqual([key, key, key]); + }); + + test('serializing to an arraybuffer', () => { + const originalGrid = new TransferableGridIndex(100, 4, 1); + originalGrid.insert(0, 4, 10, 6, 30); + originalGrid.insert(1, 4, 10, 30, 12); + originalGrid.insert(2, -10, 30, -5, 35); + + const arrayBuffer = originalGrid.toArrayBuffer(); + const grid = new TransferableGridIndex(arrayBuffer); + + expect(grid.query(4, 10, 5, 11).sort()).toEqual([0, 1]); + expect(grid.query(24, 10, 25, 11).sort()).toEqual([1]); + expect(grid.query(40, 40, 100, 100)).toEqual([]); + expect(grid.query(-6, 0, -7, 100)).toEqual([2]); + expect(grid.query(-Infinity, -Infinity, Infinity, Infinity).sort()).toEqual([0, 1, 2]); + + expect(() => grid.insert(3, 0, 0, 0, 0)).toThrow(); + }); + + test('serialize round trip', () => { + const grid = new TransferableGridIndex(100, 4, 0); + const key = 123; + grid.insert(key, 3, 3, 4, 4); + grid.insert(key, 13, 13, 14, 14); + grid.insert(key, 23, 23, 24, 24); + const serializedGrid = TransferableGridIndex.serialize(grid); + const deserializedGrid = TransferableGridIndex.deserialize(serializedGrid); + expect(deserializedGrid.query(0, 0, 30, 30)).toEqual([key, key, key]); + }); + +}); diff --git a/web/libraries/maplibre-gl/src/util/transferable_grid_index.ts b/web/libraries/maplibre-gl/src/util/transferable_grid_index.ts new file mode 100644 index 00000000..3e0d6cb7 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/transferable_grid_index.ts @@ -0,0 +1,214 @@ +/* +This file was copied from https://github.com/mapbox/grid-index and was +migrated from JavaScript to TypeScript. + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. +*/ + +const NUM_PARAMS = 3; + +export type SerializedGrid = { + buffer: ArrayBuffer; +}; + +export class TransferableGridIndex { + cells: number[][]; + arrayBuffer: ArrayBuffer; + d: number; + keys: number[]; + bboxes: number[]; + n: number; + extent: number; + padding: number; + scale: any; + uid: number; + min: number; + max: number; + + constructor(extent: number | ArrayBuffer, n?: number, padding?: number) { + const cells = this.cells = []; + + if (extent instanceof ArrayBuffer) { + this.arrayBuffer = extent; + const array = new Int32Array(this.arrayBuffer); + extent = array[0]; + n = array[1]; + padding = array[2]; + + this.d = n + 2 * padding; + for (let k = 0; k < this.d * this.d; k++) { + const start = array[NUM_PARAMS + k]; + const end = array[NUM_PARAMS + k + 1]; + cells.push(start === end ? null : array.subarray(start, end)); + } + const keysOffset = array[NUM_PARAMS + cells.length]; + const bboxesOffset = array[NUM_PARAMS + cells.length + 1]; + this.keys = array.subarray(keysOffset, bboxesOffset) as any as number[]; + this.bboxes = array.subarray(bboxesOffset) as any as number[]; + + this.insert = this._insertReadonly; + + } else { + this.d = n + 2 * padding; + for (let i = 0; i < this.d * this.d; i++) { + cells.push([]); + } + this.keys = []; + this.bboxes = []; + } + + this.n = n; + this.extent = extent; + this.padding = padding; + this.scale = n / extent; + this.uid = 0; + + const p = (padding / n) * extent; + this.min = -p; + this.max = extent + p; + } + + insert(key: number, x1: number, y1: number, x2: number, y2: number) { + this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined); + this.keys.push(key); + this.bboxes.push(x1); + this.bboxes.push(y1); + this.bboxes.push(x2); + this.bboxes.push(y2); + } + + _insertReadonly() { + throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.'); + } + + _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) { + this.cells[cellIndex].push(uid); + } + + query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[] { + const min = this.min; + const max = this.max; + if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) { + // We use `Array#slice` because `this.keys` may be a `Int32Array` and + // some browsers (Safari and IE) do not support `TypedArray#slice` + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility + return Array.prototype.slice.call(this.keys); + + } else { + const result = []; + const seenUids = {}; + this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest); + return result; + } + } + + _queryCell(x1: number, y1: number, x2: number, y2:number, cellIndex:number, result, seenUids, intersectionTest: Function) { + const cell = this.cells[cellIndex]; + if (cell !== null) { + const keys = this.keys; + const bboxes = this.bboxes; + for (let u = 0; u < cell.length; u++) { + const uid = cell[u]; + if (seenUids[uid] === undefined) { + const offset = uid * 4; + if (intersectionTest ? + intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) : + ((x1 <= bboxes[offset + 2]) && + (y1 <= bboxes[offset + 3]) && + (x2 >= bboxes[offset + 0]) && + (y2 >= bboxes[offset + 1]))) { + seenUids[uid] = true; + result.push(keys[uid]); + } else { + seenUids[uid] = false; + } + } + } + } + } + + _forEachCell(x1: number, y1: number, x2:number, y2:number, fn: Function, arg1, arg2, intersectionTest) { + const cx1 = this._convertToCellCoord(x1); + const cy1 = this._convertToCellCoord(y1); + const cx2 = this._convertToCellCoord(x2); + const cy2 = this._convertToCellCoord(y2); + for (let x = cx1; x <= cx2; x++) { + for (let y = cy1; y <= cy2; y++) { + const cellIndex = this.d * y + x; + if (intersectionTest && !intersectionTest( + this._convertFromCellCoord(x), + this._convertFromCellCoord(y), + this._convertFromCellCoord(x + 1), + this._convertFromCellCoord(y + 1))) continue; + if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) return; + } + } + } + + _convertFromCellCoord (x) { + return (x - this.padding) / this.scale; + } + + _convertToCellCoord(x) { + return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding)); + } + + toArrayBuffer(): ArrayBuffer { + if (this.arrayBuffer) return this.arrayBuffer; + + const cells = this.cells; + + const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1; + let totalCellLength = 0; + for (let i = 0; i < this.cells.length; i++) { + totalCellLength += this.cells[i].length; + } + + const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length); + array[0] = this.extent; + array[1] = this.n; + array[2] = this.padding; + + let offset = metadataLength; + for (let k = 0; k < cells.length; k++) { + const cell = cells[k]; + array[NUM_PARAMS + k] = offset; + array.set(cell, offset); + offset += cell.length; + } + + array[NUM_PARAMS + cells.length] = offset; + array.set(this.keys, offset); + offset += this.keys.length; + + array[NUM_PARAMS + cells.length + 1] = offset; + array.set(this.bboxes, offset); + offset += this.bboxes.length; + + return array.buffer; + } + + public static serialize(grid: TransferableGridIndex, transferables?: Array): SerializedGrid { + const buffer = grid.toArrayBuffer(); + if (transferables) { + transferables.push(buffer); + } + return {buffer}; + } + + public static deserialize(serialized: SerializedGrid): TransferableGridIndex { + return new TransferableGridIndex(serialized.buffer); + } +} diff --git a/web/libraries/maplibre-gl/src/util/util.test.ts b/web/libraries/maplibre-gl/src/util/util.test.ts new file mode 100644 index 00000000..47ede250 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/util.test.ts @@ -0,0 +1,518 @@ +import Point from '@mapbox/point-geometry'; +import {arraysIntersect, asyncAll, bezier, clamp, clone, deepEqual, easeCubicInOut, extend, filterObject, findLineIntersection, isClosedPolygon, isCounterClockwise, isPowerOfTwo, keysDifference, mapObject, nextPowerOfTwo, parseCacheControl, pick, readImageDataUsingOffscreenCanvas, readImageUsingVideoFrame, uniqueId, wrap} from './util'; +import {Canvas} from 'canvas'; + +describe('util', () => { + expect(easeCubicInOut(0)).toBe(0); + expect(easeCubicInOut(0.2)).toBe(0.03200000000000001); + expect(easeCubicInOut(0.5)).toBe(0.5); + expect(easeCubicInOut(1)).toBe(1); + expect(keysDifference({a: 1}, {})).toEqual(['a']); + expect(keysDifference({a: 1}, {a: 1})).toEqual([]); + expect(extend({a: 1}, {b: 2})).toEqual({a: 1, b: 2}); + expect(pick({a: 1, b: 2, c: 3}, ['a', 'c'])).toEqual({a: 1, c: 3}); + expect(pick({a: 1, b: 2, c: 3}, ['a', 'c', 'd'])).toEqual({a: 1, c: 3}); + expect(typeof uniqueId() === 'number').toBeTruthy(); + + test('asyncAll - sync', done => { + expect(asyncAll([0, 1, 2], (data, callback) => { + callback(null, data); + }, (err, results) => { + expect(err).toBeFalsy(); + expect(results).toEqual([0, 1, 2]); + })).toBeUndefined(); + done(); + }); + + test('asyncAll - async', done => { + expect(asyncAll([4, 0, 1, 2], (data, callback) => { + setTimeout(() => { + callback(null, data); + }, data); + }, (err, results) => { + expect(err).toBeFalsy(); + expect(results).toEqual([4, 0, 1, 2]); + done(); + })).toBeUndefined(); + }); + + test('asyncAll - error', done => { + expect(asyncAll([4, 0, 1, 2], (data, callback) => { + setTimeout(() => { + callback(new Error('hi'), data); + }, data); + }, (err, results) => { + expect(err && err.message).toBe('hi'); + expect(results).toEqual([4, 0, 1, 2]); + done(); + })).toBeUndefined(); + }); + + test('asyncAll - empty', done => { + expect(asyncAll([], (data, callback) => { + callback(null, 'foo'); + }, (err, results) => { + expect(err).toBeFalsy(); + expect(results).toEqual([]); + })).toBeUndefined(); + done(); + }); + + test('isPowerOfTwo', done => { + expect(isPowerOfTwo(1)).toBe(true); + expect(isPowerOfTwo(2)).toBe(true); + expect(isPowerOfTwo(256)).toBe(true); + expect(isPowerOfTwo(-256)).toBe(false); + expect(isPowerOfTwo(0)).toBe(false); + expect(isPowerOfTwo(-42)).toBe(false); + expect(isPowerOfTwo(42)).toBe(false); + done(); + }); + + test('nextPowerOfTwo', done => { + expect(nextPowerOfTwo(1)).toBe(1); + expect(nextPowerOfTwo(2)).toBe(2); + expect(nextPowerOfTwo(256)).toBe(256); + expect(nextPowerOfTwo(-256)).toBe(1); + expect(nextPowerOfTwo(0)).toBe(1); + expect(nextPowerOfTwo(-42)).toBe(1); + expect(nextPowerOfTwo(42)).toBe(64); + done(); + }); + + test('nextPowerOfTwo', done => { + expect(isPowerOfTwo(nextPowerOfTwo(1))).toBe(true); + expect(isPowerOfTwo(nextPowerOfTwo(2))).toBe(true); + expect(isPowerOfTwo(nextPowerOfTwo(256))).toBe(true); + expect(isPowerOfTwo(nextPowerOfTwo(-256))).toBe(true); + expect(isPowerOfTwo(nextPowerOfTwo(0))).toBe(true); + expect(isPowerOfTwo(nextPowerOfTwo(-42))).toBe(true); + expect(isPowerOfTwo(nextPowerOfTwo(42))).toBe(true); + done(); + }); + + test('clamp', done => { + expect(clamp(0, 0, 1)).toBe(0); + expect(clamp(1, 0, 1)).toBe(1); + expect(clamp(200, 0, 180)).toBe(180); + expect(clamp(-200, 0, 180)).toBe(0); + done(); + }); + + test('wrap', done => { + expect(wrap(0, 0, 1)).toBe(1); + expect(wrap(1, 0, 1)).toBe(1); + expect(wrap(200, 0, 180)).toBe(20); + expect(wrap(-200, 0, 180)).toBe(160); + done(); + }); + + test('bezier', done => { + const curve = bezier(0, 0, 0.25, 1); + expect(curve instanceof Function).toBeTruthy(); + expect(curve(0)).toBe(0); + expect(curve(1)).toBe(1); + expect(curve(0.5)).toBe(0.8230854638965502); + done(); + }); + + test('asyncAll', done => { + let expectedValue = 1; + asyncAll([], (callback) => { callback(); }, () => { + expect('immediate callback').toBeTruthy(); + }); + asyncAll([1, 2, 3], (number, callback) => { + expect(number).toBe(expectedValue++); + expect(callback instanceof Function).toBeTruthy(); + callback(null, 0); + }, () => { + done(); + }); + }); + + test('mapObject', () => { + expect.assertions(6); + expect(mapObject({}, () => { expect(false).toBeTruthy(); })).toEqual({}); + const that = {}; + expect(mapObject({map: 'box'}, function(value, key, object) { + expect(value).toBe('box'); + expect(key).toBe('map'); + expect(object).toEqual({map: 'box'}); + expect(this).toBe(that); + return 'BOX'; + }, that)).toEqual({map: 'BOX'}); + }); + + test('filterObject', done => { + expect.assertions(6); + expect(filterObject({}, () => { expect(false).toBeTruthy(); })).toEqual({}); + const that = {}; + filterObject({map: 'box'}, function(value, key, object) { + expect(value).toBe('box'); + expect(key).toBe('map'); + expect(object).toEqual({map: 'box'}); + expect(this).toBe(that); + return true; + }, that); + expect(filterObject({map: 'box', box: 'map'}, (value) => { + return value === 'box'; + })).toEqual({map: 'box'}); + done(); + }); + + test('deepEqual', done => { + const a = { + foo: 'bar', + bar: { + baz: 5, + lol: ['cat', 2] + } + }; + const b = JSON.parse(JSON.stringify(a)); + const c = JSON.parse(JSON.stringify(a)); + c.bar.lol[0] = 'z'; + + expect(deepEqual(a, b)).toBeTruthy(); + expect(deepEqual(a, c)).toBeFalsy(); + expect(deepEqual(a, null)).toBeFalsy(); + expect(deepEqual(null, c)).toBeFalsy(); + expect(deepEqual(null, null)).toBeTruthy(); + + done(); + }); +}); + +describe('util clone', () => { + test('array', done => { + const input = [false, 1, 'two']; + const output = clone(input); + expect(input).not.toBe(output); + expect(input).toEqual(output); + done(); + }); + + test('object', done => { + const input = {a: false, b: 1, c: 'two'}; + const output = clone(input); + expect(input).not.toBe(output); + expect(input).toEqual(output); + done(); + }); + + test('deep object', done => { + const input = {object: {a: false, b: 1, c: 'two'}}; + const output = clone(input); + expect(input.object).not.toBe(output.object); + expect(input.object).toEqual(output.object); + done(); + }); + + test('deep array', done => { + const input = {array: [false, 1, 'two']}; + const output = clone(input); + expect(input.array).not.toBe(output.array); + expect(input.array).toEqual(output.array); + done(); + }); +}); + +describe('util arraysIntersect', () => { + test('intersection', done => { + const a = ['1', '2', '3']; + const b = ['5', '4', '3']; + + expect(arraysIntersect(a, b)).toBe(true); + done(); + }); + + test('no intersection', done => { + const a = ['1', '2', '3']; + const b = ['4', '5', '6']; + + expect(arraysIntersect(a, b)).toBe(false); + done(); + }); + +}); + +describe('util isCounterClockwise', () => { + test('counter clockwise', done => { + const a = new Point(0, 0); + const b = new Point(1, 0); + const c = new Point(1, 1); + + expect(isCounterClockwise(a, b, c)).toBe(true); + done(); + }); + + test('clockwise', done => { + const a = new Point(0, 0); + const b = new Point(1, 0); + const c = new Point(1, 1); + + expect(isCounterClockwise(c, b, a)).toBe(false); + done(); + }); +}); + +describe('util isClosedPolygon', () => { + test('not enough points', done => { + const polygon = [new Point(0, 0), new Point(1, 0), new Point(0, 1)]; + + expect(isClosedPolygon(polygon)).toBe(false); + done(); + }); + + test('not equal first + last point', done => { + const polygon = [new Point(0, 0), new Point(1, 0), new Point(0, 1), new Point(1, 1)]; + + expect(isClosedPolygon(polygon)).toBe(false); + done(); + }); + + test('closed polygon', done => { + const polygon = [new Point(0, 0), new Point(1, 0), new Point(1, 1), new Point(0, 1), new Point(0, 0)]; + + expect(isClosedPolygon(polygon)).toBe(true); + done(); + }); + +}); + +describe('util parseCacheControl', () => { + test('max-age', done => { + expect(parseCacheControl('max-age=123456789')).toEqual({ + 'max-age': 123456789 + }); + + expect(parseCacheControl('max-age=1000')).toEqual({ + 'max-age': 1000 + }); + + expect(parseCacheControl('max-age=null')).toEqual({}); + + done(); + }); + +}); + +describe('util findLineIntersection', () => { + test('line intersection', () => { + const horizontal = [ + new Point(0, 0), + new Point(10, 0)]; + const vertical = [ + new Point(30, -20), + new Point(30, -10) + ]; + const intersection = findLineIntersection(horizontal[0], horizontal[1], vertical[0], vertical[1]); + expect(intersection).toEqual(new Point(30, 0)); + }); + + test('line intersection backwards', () => { + // Direction of line segments should be irrelevant + const horizontal = [ + new Point(10, 0), + new Point(0, 0)]; + const vertical = [ + new Point(30, -10), + new Point(30, -20) + ]; + const intersection = findLineIntersection(horizontal[0], horizontal[1], vertical[0], vertical[1]); + expect(intersection).toEqual(new Point(30, 0)); + }); + + test('crossing line intersection', () => { + // This should not be possible for two adjacent segments of a line string + const horizontal = [ + new Point(-10, 0), + new Point(10, 0)]; + const vertical = [ + new Point(0, -10), + new Point(0, 10) + ]; + const intersection = findLineIntersection(horizontal[0], horizontal[1], vertical[0], vertical[1]); + expect(intersection).toEqual(new Point(0, 0)); + }); + + test('parallel lines do not intersect', () => { + const first = [ + new Point(0, 0), + new Point(10, 0)]; + const second = [ + new Point(10, 0), + new Point(30, 0) + ]; + const intersection = findLineIntersection(first[0], first[1], second[0], second[1]); + expect(intersection).toBeNull(); + }); +}); + +describe('util readImageUsingVideoFrame', () => { + let format = 'RGBA'; + const frame = { + get format() { + return format; + }, + copyTo: jest.fn(buf => { + buf.set(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]).subarray(0, buf.length)); + return Promise.resolve(); + }), + close: jest.fn(), + }; + (window as any).VideoFrame = jest.fn(() => frame); + const canvas = document.createElement('canvas'); + canvas.width = canvas.height = 2; + + beforeEach(() => { + format = 'RGBA'; + frame.copyTo.mockClear(); + frame.close.mockReset(); + }); + + test('copy RGB', async () => { + format = 'RGBA'; + const result = await readImageUsingVideoFrame(canvas, 0, 0, 2, 2); + expect(result).toHaveLength(4 * 4); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 8}], + rect: {x: 0, y: 0, width: 2, height: 2} + }); + expect(result).toEqual(new Uint8ClampedArray([ + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16 + ])); + expect(frame.close).toHaveBeenCalledTimes(1); + }); + + test('flip BRG', async () => { + format = 'BGRX'; + const result = await readImageUsingVideoFrame(canvas, 0, 0, 2, 2); + expect(result).toEqual(new Uint8ClampedArray([ + 3, 2, 1, 4, 7, 6, 5, 8, + 11, 10, 9, 12, 15, 14, 13, 16 + ])); + expect(frame.close).toHaveBeenCalledTimes(1); + }); + + test('ignore bad format', async () => { + format = 'OTHER'; + await expect(readImageUsingVideoFrame(canvas, 0, 0, 2, 2)).rejects.toThrow(); + expect(frame.close).toHaveBeenCalledTimes(1); + }); + + describe('layout/rect', () => { + beforeEach(() => { + (window as any).VideoFrame = jest.fn(() => frame); + canvas.width = canvas.height = 3; + }); + + test('full rectangle', async () => { + await readImageUsingVideoFrame(canvas, 0, 0, 3, 3); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 12}], + rect: {x: 0, y: 0, width: 3, height: 3} + }); + }); + + test('top left', async () => { + await readImageUsingVideoFrame(canvas, 0, 0, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 8}], + rect: {x: 0, y: 0, width: 2, height: 2} + }); + }); + + test('top right', async () => { + await readImageUsingVideoFrame(canvas, 1, 0, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 8}], + rect: {x: 1, y: 0, width: 2, height: 2} + }); + }); + + test('bottom left', async () => { + await readImageUsingVideoFrame(canvas, 0, 1, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 8}], + rect: {x: 0, y: 1, width: 2, height: 2} + }); + }); + + test('bottom right', async () => { + await readImageUsingVideoFrame(canvas, 1, 1, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 8}], + rect: {x: 1, y: 1, width: 2, height: 2} + }); + }); + + test('middle', async () => { + await readImageUsingVideoFrame(canvas, 1, 1, 1, 1); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 4}], + rect: {x: 1, y: 1, width: 1, height: 1} + }); + }); + + test('extend past on all sides', async () => { + await readImageUsingVideoFrame(canvas, -1, -1, 5, 5); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 4 * 5 + 4, stride: 4 * 5}], + rect: {x: 0, y: 0, width: 3, height: 3} + }); + }); + + test('overhang top left', async () => { + await readImageUsingVideoFrame(canvas, -1, -1, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 4 * 2 + 4, stride: 4 * 2}], + rect: {x: 0, y: 0, width: 1, height: 1} + }); + }); + + test('overhang top right', async () => { + await readImageUsingVideoFrame(canvas, 2, -1, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 4 * 2, stride: 4 * 2}], + rect: {x: 2, y: 0, width: 1, height: 1} + }); + }); + + test('overhang bottom left', async () => { + await readImageUsingVideoFrame(canvas, -1, 2, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 4, stride: 4 * 2}], + rect: {x: 0, y: 2, width: 1, height: 1} + }); + }); + + test('overhang bottom right', async () => { + await readImageUsingVideoFrame(canvas, 2, 2, 2, 2); + expect(frame.copyTo).toHaveBeenCalledWith(expect.anything(), { + layout: [{offset: 0, stride: 4 * 2}], + rect: {x: 2, y: 2, width: 1, height: 1} + }); + }); + }); +}); + +describe('util readImageDataUsingOffscreenCanvas', () => { + test('reads pixels from image', async () => { + (window as any).OffscreenCanvas = Canvas; + const image = new Canvas(2, 2); + const context = image.getContext('2d'); + context.fillStyle = 'rgb(10,0,0)'; + context.fillRect(0, 0, 1, 1); + context.fillStyle = 'rgb(0,20,0)'; + context.fillRect(1, 0, 1, 1); + context.fillStyle = 'rgb(0,0,30)'; + context.fillRect(0, 1, 1, 1); + context.fillStyle = 'rgb(40,40,40)'; + context.fillRect(1, 1, 1, 1); + expect([...await readImageDataUsingOffscreenCanvas(image as any, 0, 0, 2, 2)]).toEqual([ + 10, 0, 0, 255, 0, 20, 0, 255, + 0, 0, 30, 255, 40, 40, 40, 255, + ]); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/util.ts b/web/libraries/maplibre-gl/src/util/util.ts new file mode 100644 index 00000000..13e0c7db --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/util.ts @@ -0,0 +1,669 @@ +import Point from '@mapbox/point-geometry'; +import UnitBezier from '@mapbox/unitbezier'; +import type {Callback} from '../types/callback'; +import {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted'; +import type {Size} from './image'; + +/** + * Given a value `t` that varies between 0 and 1, return + * an interpolation function that eases between 0 and 1 in a pleasing + * cubic in-out fashion. + */ +export function easeCubicInOut(t: number): number { + if (t <= 0) return 0; + if (t >= 1) return 1; + const t2 = t * t, + t3 = t2 * t; + return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75); +} + +/** + * Given given (x, y), (x1, y1) control points for a bezier curve, + * return a function that interpolates along that curve. + * + * @param p1x - control point 1 x coordinate + * @param p1y - control point 1 y coordinate + * @param p2x - control point 2 x coordinate + * @param p2y - control point 2 y coordinate + */ +export function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number { + const bezier = new UnitBezier(p1x, p1y, p2x, p2y); + return function(t: number) { + return bezier.solve(t); + }; +} + +/** + * A default bezier-curve powered easing function with + * control points (0.25, 0.1) and (0.25, 1) + */ +export const defaultEasing = bezier(0.25, 0.1, 0.25, 1); + +/** + * constrain n to the given range via min + max + * + * @param n - value + * @param min - the minimum value to be returned + * @param max - the maximum value to be returned + * @returns the clamped value + */ +export function clamp(n: number, min: number, max: number): number { + return Math.min(max, Math.max(min, n)); +} + +/** + * constrain n to the given range, excluding the minimum, via modular arithmetic + * + * @param n - value + * @param min - the minimum value to be returned, exclusive + * @param max - the maximum value to be returned, inclusive + * @returns constrained number + */ +export function wrap(n: number, min: number, max: number): number { + const d = max - min; + const w = ((n - min) % d + d) % d + min; + return (w === min) ? max : w; +} + +/** + * Call an asynchronous function on an array of arguments, + * calling `callback` with the completed results of all calls. + * + * @param array - input to each call of the async function. + * @param fn - an async function with signature (data, callback) + * @param callback - a callback run after all async work is done. + * called with an array, containing the results of each async call. + */ +export function asyncAll( + array: Array, + fn: (item: Item, fnCallback: Callback) => void, + callback: Callback> +) { + if (!array.length) { return callback(null, []); } + let remaining = array.length; + const results = new Array(array.length); + let error = null; + array.forEach((item, i) => { + fn(item, (err, result) => { + if (err) error = err; + results[i] = (result as any as Result); // https://github.com/facebook/flow/issues/2123 + if (--remaining === 0) callback(error, results); + }); + }); +} + +/** + * Compute the difference between the keys in one object and the keys + * in another object. + * + * @returns keys difference + */ +export function keysDifference( + obj: {[key: string]: S}, + other: {[key: string]: T} +): Array { + const difference = []; + for (const i in obj) { + if (!(i in other)) { + difference.push(i); + } + } + return difference; +} + +/** + * Given a destination object and optionally many source objects, + * copy all properties from the source objects into the destination. + * The last source object given overrides properties from previous + * source objects. + * + * @param dest - destination object + * @param sources - sources from which properties are pulled + */ +export function extend(dest: any, ...sources: Array): any { + for (const src of sources) { + for (const k in src) { + dest[k] = src[k]; + } + } + return dest; +} + +/** + * Given an object and a number of properties as strings, return version + * of that object with only those properties. + * + * @param src - the object + * @param properties - an array of property names chosen + * to appear on the resulting object. + * @returns object with limited properties. + * @example + * ```ts + * let foo = { name: 'Charlie', age: 10 }; + * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' } + * ``` + */ +export function pick(src: any, properties: Array): any { + const result = {}; + for (let i = 0; i < properties.length; i++) { + const k = properties[i]; + if (k in src) { + result[k] = src[k]; + } + } + return result; +} + +let id = 1; + +/** + * Return a unique numeric id, starting at 1 and incrementing with + * each call. + * + * @returns unique numeric id. + */ +export function uniqueId(): number { + return id++; +} + +/** + * Return whether a given value is a power of two + */ +export function isPowerOfTwo(value: number): boolean { + return (Math.log(value) / Math.LN2) % 1 === 0; +} + +/** + * Return the next power of two, or the input value if already a power of two + */ +export function nextPowerOfTwo(value: number): number { + if (value <= 1) return 1; + return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2)); +} + +/** + * Create an object by mapping all the values of an existing object while + * preserving their keys. + */ +export function mapObject(input: any, iterator: Function, context?: any): any { + const output = {}; + for (const key in input) { + output[key] = iterator.call(context || this, input[key], key, input); + } + return output; +} + +/** + * Create an object by filtering out values of an existing object. + */ +export function filterObject(input: any, iterator: Function, context?: any): any { + const output = {}; + for (const key in input) { + if (iterator.call(context || this, input[key], key, input)) { + output[key] = input[key]; + } + } + return output; +} + +/** + * Deeply compares two object literals. + * @param a - first object literal to be compared + * @param b - second object literal to be compared + * @returns true if the two object literals are deeply equal, false otherwise + */ +export function deepEqual(a?: unknown | null, b?: unknown | null): boolean { + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) { + if (!deepEqual(a[i], b[i])) return false; + } + return true; + } + if (typeof a === 'object' && a !== null && b !== null) { + if (!(typeof b === 'object')) return false; + const keys = Object.keys(a); + if (keys.length !== Object.keys(b).length) return false; + for (const key in a) { + if (!deepEqual(a[key], b[key])) return false; + } + return true; + } + return a === b; +} + +/** + * Deeply clones two objects. + */ +export function clone(input: T): T { + if (Array.isArray(input)) { + return input.map(clone) as any as T; + } else if (typeof input === 'object' && input) { + return mapObject(input, clone) as any as T; + } else { + return input; + } +} + +/** + * Check if two arrays have at least one common element. + */ +export function arraysIntersect(a: Array, b: Array): boolean { + for (let l = 0; l < a.length; l++) { + if (b.indexOf(a[l]) >= 0) return true; + } + return false; +} + +/** + * Print a warning message to the console and ensure duplicate warning messages + * are not printed. + */ +const warnOnceHistory: {[key: string]: boolean} = {}; + +export function warnOnce(message: string): void { + if (!warnOnceHistory[message]) { + // console isn't defined in some WebWorkers, see #2558 + if (typeof console !== 'undefined') console.warn(message); + warnOnceHistory[message] = true; + } +} + +/** + * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order + * + * @returns true for a counter clockwise set of points + */ +// http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/ +export function isCounterClockwise(a: Point, b: Point, c: Point): boolean { + return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x); +} + +/** + * For two lines a and b in 2d space, defined by any two points along the lines, + * find the intersection point, or return null if the lines are parallel + * + * @param a1 - First point on line a + * @param a2 - Second point on line a + * @param b1 - First point on line b + * @param b2 - Second point on line b + * + * @returns the intersection point of the two lines or null if they are parallel + */ +export function findLineIntersection(a1: Point, a2: Point, b1: Point, b2: Point): Point | null { + const aDeltaY = a2.y - a1.y; + const aDeltaX = a2.x - a1.x; + const bDeltaY = b2.y - b1.y; + const bDeltaX = b2.x - b1.x; + + const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY); + + if (denominator === 0) { + // Lines are parallel + return null; + } + + const originDeltaY = a1.y - b1.y; + const originDeltaX = a1.x - b1.x; + const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator; + + // Find intersection by projecting out from origin of first segment + return new Point(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY)); +} + +/** + * Returns the signed area for the polygon ring. Positive areas are exterior rings and + * have a clockwise winding. Negative areas are interior rings and have a counter clockwise + * ordering. + * + * @param ring - Exterior or interior ring + */ +export function calculateSignedArea(ring: Array): number { + let sum = 0; + for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) { + p1 = ring[i]; + p2 = ring[j]; + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + return sum; +} + +/** + * Detects closed polygons, first + last point are equal + * + * @param points - array of points + * @returns `true` if the points are a closed polygon + */ +export function isClosedPolygon(points: Array): boolean { + // If it is 2 points that are the same then it is a point + // If it is 3 points with start and end the same then it is a line + if (points.length < 4) + return false; + + const p1 = points[0]; + const p2 = points[points.length - 1]; + + if (Math.abs(p1.x - p2.x) > 0 || + Math.abs(p1.y - p2.y) > 0) { + return false; + } + + // polygon simplification can produce polygons with zero area and more than 3 points + return Math.abs(calculateSignedArea(points)) > 0.01; +} + +/** + * Converts spherical coordinates to cartesian coordinates. + * + * @param spherical - Spherical coordinates, in [radial, azimuthal, polar] + * @returns cartesian coordinates in [x, y, z] + */ + +export function sphericalToCartesian([r, azimuthal, polar]: [number, number, number]): { + x: number; + y: number; + z: number; +} { + // We abstract "north"/"up" (compass-wise) to be 0° when really this is 90° (π/2): + // correct for that here + azimuthal += 90; + + // Convert azimuthal and polar angles to radians + azimuthal *= Math.PI / 180; + polar *= Math.PI / 180; + + return { + x: r * Math.cos(azimuthal) * Math.sin(polar), + y: r * Math.sin(azimuthal) * Math.sin(polar), + z: r * Math.cos(polar) + }; +} + +/** + * Returns true if the when run in the web-worker context. + * + * @returns `true` if the when run in the web-worker context. + */ +export function isWorker(): boolean { + // @ts-ignore + return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope; +} + +/** + * Parses data from 'Cache-Control' headers. + * + * @param cacheControl - Value of 'Cache-Control' header + * @returns object containing parsed header info. + */ + +export function parseCacheControl(cacheControl: string): any { + // Taken from [Wreck](https://github.com/hapijs/wreck) + const re = /(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g; + + const header = {}; + cacheControl.replace(re, ($0, $1, $2, $3) => { + const value = $2 || $3; + header[$1] = value ? value.toLowerCase() : true; + return ''; + }); + + if (header['max-age']) { + const maxAge = parseInt(header['max-age'], 10); + if (isNaN(maxAge)) delete header['max-age']; + else header['max-age'] = maxAge; + } + + return header; +} + +let _isSafari = null; + +/** + * Returns true when run in WebKit derived browsers. + * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to + * transfer data between WebWorkers and the main thread. + * https://github.com/mapbox/mapbox-gl-js/issues/8771 + * + * This should be removed once the underlying Safari issue is fixed. + * + * @param scope - Since this function is used both on the main thread and WebWorker context, + * let the calling scope pass in the global scope object. + * @returns `true` when run in WebKit derived browsers. + */ +export function isSafari(scope: any): boolean { + if (_isSafari == null) { + const userAgent = scope.navigator ? scope.navigator.userAgent : null; + _isSafari = !!scope.safari || + !!(userAgent && (/\b(iPad|iPhone|iPod)\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome')))); + } + return _isSafari; +} + +export function storageAvailable(type: string): boolean { + try { + const storage = window[type]; + storage.setItem('_mapbox_test_', 1); + storage.removeItem('_mapbox_test_'); + return true; + } catch (e) { + return false; + } +} + +// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem +//Unicode compliant base64 encoder for strings +export function b64EncodeUnicode(str: string) { + return btoa( + encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, + (match, p1) => { + return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line + } + ) + ); +} + +// Unicode compliant decoder for base64-encoded strings +export function b64DecodeUnicode(str: string) { + return decodeURIComponent(atob(str).split('').map((c) => { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line + }).join('')); +} + +export function isImageBitmap(image: any): image is ImageBitmap { + return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap; +} + +/** + * Converts an ArrayBuffer to an ImageBitmap. + * + * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work + * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting + * ArrayBuffers. + * + * @param data - Data to convert + * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image bitmap (when no error) as the second + */ +export function arrayBufferToImageBitmap(data: ArrayBuffer, callback: (err?: Error | null, image?: ImageBitmap | null) => void) { + const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'}); + createImageBitmap(blob).then((imgBitmap) => { + callback(null, imgBitmap); + }).catch((e) => { + callback(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)); + }); +} + +const transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII='; + +/** + * Converts an ArrayBuffer to an HTMLImageElement. + * + * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work + * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting + * ArrayBuffers. + * + * @param data - Data to convert + * @param callback - A callback executed after the conversion is finished. Invoked with error (if any) as the first argument and resulting image element (when no error) as the second + */ +export function arrayBufferToImage(data: ArrayBuffer, callback: (err?: Error | null, image?: HTMLImageElement | null) => void) { + const img: HTMLImageElement = new Image(); + img.onload = () => { + callback(null, img); + URL.revokeObjectURL(img.src); + // prevent image dataURI memory leak in Safari; + // but don't free the image immediately because it might be uploaded in the next frame + // https://github.com/mapbox/mapbox-gl-js/issues/10226 + img.onload = null; + window.requestAnimationFrame(() => { img.src = transparentPngUrl; }); + }; + img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.')); + const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'}); + img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl; +} + +/** + * Computes the webcodecs VideoFrame API options to select a rectangle out of + * an image and write it into the destination rectangle. + * + * Rect (x/y/width/height) select the overlapping rectangle from the source image + * and layout (offset/stride) write that overlapping rectangle to the correct place + * in the destination image. + * + * Offset is the byte offset in the dest image that the first pixel appears at + * and stride is the number of bytes to the start of the next row: + * ┌───────────┐ + * │ dest │ + * │ ┌───┼───────┐ + * │offset→│▓▓▓│ source│ + * │ │▓▓▓│ │ + * │ └───┼───────┘ + * │stride ⇠╌╌╌│ + * │╌╌╌╌╌╌→ │ + * └───────────┘ + * + * @param image - source image containing a width and height attribute + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns the layout and rect options to pass into VideoFrame API + */ +function computeVideoFrameParameters(image: Size, x: number, y: number, width: number, height: number): VideoFrameCopyToOptions { + const destRowOffset = Math.max(-x, 0) * 4; + const firstSourceRow = Math.max(0, y); + const firstDestRow = firstSourceRow - y; + const offset = firstDestRow * width * 4 + destRowOffset; + const stride = width * 4; + + const sourceLeft = Math.max(0, x); + const sourceTop = Math.max(0, y); + const sourceRight = Math.min(image.width, x + width); + const sourceBottom = Math.min(image.height, y + height); + return { + rect: { + x: sourceLeft, + y: sourceTop, + width: sourceRight - sourceLeft, + height: sourceBottom - sourceTop + }, + layout: [{offset, stride}] + }; +} + +/** + * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API. + * + * @param data - image, imagebitmap, or canvas to parse + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred + */ +export async function readImageUsingVideoFrame( + image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas, + x: number, y: number, width: number, height: number +): Promise { + if (typeof VideoFrame === 'undefined') { + throw new Error('VideoFrame not supported'); + } + const frame = new VideoFrame(image, {timestamp: 0}); + try { + const format = frame?.format; + if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) { + throw new Error(`Unrecognized format ${format}`); + } + const swapBR = format.startsWith('BGR'); + const result = new Uint8ClampedArray(width * height * 4); + await frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height)); + if (swapBR) { + for (let i = 0; i < result.length; i += 4) { + const tmp = result[i]; + result[i] = result[i + 2]; + result[i + 2] = tmp; + } + } + return result; + } finally { + frame.close(); + } +} + +let offscreenCanvas: OffscreenCanvas; +let offscreenCanvasContext: OffscreenCanvasRenderingContext2D; + +/** + * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas + * + * @param data - image, imagebitmap, or canvas to parse + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred + */ +export function readImageDataUsingOffscreenCanvas( + imgBitmap: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas, + x: number, y: number, width: number, height: number +): Uint8ClampedArray { + const origWidth = imgBitmap.width; + const origHeight = imgBitmap.height; + // Lazily initialize OffscreenCanvas + if (!offscreenCanvas || !offscreenCanvasContext) { + // Dem tiles are typically 256x256 + offscreenCanvas = new OffscreenCanvas(origWidth, origHeight); + offscreenCanvasContext = offscreenCanvas.getContext('2d', {willReadFrequently: true}); + } + + offscreenCanvas.width = origWidth; + offscreenCanvas.height = origHeight; + + offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight); + const imgData = offscreenCanvasContext.getImageData(x, y, width, height); + offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight); + return imgData.data; +} + +/** + * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and + * the browser is mangling OffscreenCanvas getImageData results. + * + * @param data - image, imagebitmap, or canvas to parse + * @param x - top-left x coordinate to read from the image + * @param y - top-left y coordinate to read from the image + * @param width - width of the rectangle to read from the image + * @param height - height of the rectangle to read from the image + * @returns a promise containing the parsed RGBA pixel values of the image + */ +export async function getImageData( + image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas, + x: number, y: number, width: number, height: number +): Promise { + if (isOffscreenCanvasDistorted()) { + try { + return await readImageUsingVideoFrame(image, x, y, width, height); + } catch (e) { + // fall back to OffscreenCanvas + } + } + return readImageDataUsingOffscreenCanvas(image, x, y, width, height); +} diff --git a/web/libraries/maplibre-gl/src/util/vectortile_to_geojson.ts b/web/libraries/maplibre-gl/src/util/vectortile_to_geojson.ts new file mode 100644 index 00000000..64d72cc5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/vectortile_to_geojson.ts @@ -0,0 +1,72 @@ +import type {VectorTileFeature} from '@mapbox/vector-tile'; +import type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec'; + +/** + * A helper for type to omit a property from a type + */ +type DistributiveKeys = T extends T ? keyof T : never; +/** + * A helper for type to omit a property from a type + */ +type DistributiveOmit> = T extends unknown + ? Omit + : never; + +/** + * An extended geojson feature used by the events to return data to the listener + */ +export type MapGeoJSONFeature = GeoJSONFeature & { + layer: DistributiveOmit & {source: string}; + source: string; + sourceLayer?: string; + state: { [key: string]: any }; +} + +/** + * A geojson feature + */ +export class GeoJSONFeature { + type: 'Feature'; + _geometry: GeoJSON.Geometry; + properties: { [name: string]: any }; + id: number | string | undefined; + + _vectorTileFeature: VectorTileFeature; + + constructor(vectorTileFeature: VectorTileFeature, z: number, x: number, y: number, id: string | number | undefined) { + this.type = 'Feature'; + + this._vectorTileFeature = vectorTileFeature; + (vectorTileFeature as any)._z = z; + (vectorTileFeature as any)._x = x; + (vectorTileFeature as any)._y = y; + + this.properties = vectorTileFeature.properties; + this.id = id; + } + + get geometry(): GeoJSON.Geometry { + if (this._geometry === undefined) { + this._geometry = this._vectorTileFeature.toGeoJSON( + (this._vectorTileFeature as any)._x, + (this._vectorTileFeature as any)._y, + (this._vectorTileFeature as any)._z).geometry; + } + return this._geometry; + } + + set geometry(g: GeoJSON.Geometry) { + this._geometry = g; + } + + toJSON() { + const json: any = { + geometry: this.geometry + }; + for (const i in this) { + if (i === '_geometry' || i === '_vectorTileFeature') continue; + json[i] = (this)[i]; + } + return json; + } +} diff --git a/web/libraries/maplibre-gl/src/util/verticalize_punctuation.ts b/web/libraries/maplibre-gl/src/util/verticalize_punctuation.ts new file mode 100644 index 00000000..c6f73fb4 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/verticalize_punctuation.ts @@ -0,0 +1,110 @@ +import {charHasRotatedVerticalOrientation} from './script_detection'; + +export const verticalizedCharacterMap = { + '!': '︕', + '#': '#', + '$': '$', + '%': '%', + '&': '&', + '(': '︵', + ')': '︶', + '*': '*', + '+': '+', + ',': '︐', + '-': '︲', + '.': '・', + '/': '/', + ':': '︓', + ';': '︔', + '<': '︿', + '=': '=', + '>': '﹀', + '?': '︖', + '@': '@', + '[': '﹇', + '\\': '\', + ']': '﹈', + '^': '^', + '_': '︳', + '`': '`', + '{': '︷', + '|': '―', + '}': '︸', + '~': '~', + '¢': '¢', + '£': '£', + '¥': '¥', + '¦': '¦', + '¬': '¬', + '¯': ' ̄', + '–': '︲', + '—': '︱', + '‘': '﹃', + '’': '﹄', + '“': '﹁', + '”': '﹂', + '…': '︙', + '‧': '・', + '₩': '₩', + '、': '︑', + '。': '︒', + '〈': '︿', + '〉': '﹀', + '《': '︽', + '》': '︾', + '「': '﹁', + '」': '﹂', + '『': '﹃', + '』': '﹄', + '【': '︻', + '】': '︼', + '〔': '︹', + '〕': '︺', + '〖': '︗', + '〗': '︘', + '!': '︕', + '(': '︵', + ')': '︶', + ',': '︐', + '-': '︲', + '.': '・', + ':': '︓', + ';': '︔', + '<': '︿', + '>': '﹀', + '?': '︖', + '[': '﹇', + ']': '﹈', + '_': '︳', + '{': '︷', + '|': '―', + '}': '︸', + '⦅': '︵', + '⦆': '︶', + '。': '︒', + '「': '﹁', + '」': '﹂' +}; + +export function verticalizePunctuation(input: string) { + let output = ''; + + for (let i = 0; i < input.length; i++) { + const nextCharCode = input.charCodeAt(i + 1) || null; + const prevCharCode = input.charCodeAt(i - 1) || null; + + const canReplacePunctuation = ( + (!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) && + (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]]) + ); + + if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) { + output += verticalizedCharacterMap[input[i]]; + } else { + output += input[i]; + } + } + + return output; +} + diff --git a/web/libraries/maplibre-gl/src/util/web_worker.ts b/web/libraries/maplibre-gl/src/util/web_worker.ts new file mode 100644 index 00000000..6a2db7e5 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/web_worker.ts @@ -0,0 +1,18 @@ +import {config} from './config'; + +import type {WorkerSource} from '../source/worker_source'; + +export interface WorkerGlobalScopeInterface { + importScripts(...urls: Array): void; + registerWorkerSource: ( + b: string, + a: { + new(...args: any): WorkerSource; + } + ) => void; + registerRTLTextPlugin: (_: any) => void; +} + +export function workerFactory() { + return new Worker(config.WORKER_URL); +} diff --git a/web/libraries/maplibre-gl/src/util/web_worker_transfer.test.ts b/web/libraries/maplibre-gl/src/util/web_worker_transfer.test.ts new file mode 100644 index 00000000..f8fc7a9e --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/web_worker_transfer.test.ts @@ -0,0 +1,83 @@ +import {register, serialize, deserialize} from './web_worker_transfer'; + +describe('web worker transfer', () => { + test('round trip', () => { + class SerializableMock { + n; + buffer; + blob; + _cached; + + constructor(n) { + this.n = n; + this.buffer = new ArrayBuffer(100); + this.blob = new Blob(); + this.squared(); + } + + squared() { + if (this._cached) { + return this._cached; + } + this._cached = this.n * this.n; + return this._cached; + } + } + + register('SerializableMock', SerializableMock, {omit: ['_cached']}); + + const serializableMock = new SerializableMock(10); + const transferables = []; + const deserialized = deserialize(serialize(serializableMock, transferables)) as SerializableMock; + expect(deserialize(serialize(serializableMock, transferables)) instanceof SerializableMock).toBeTruthy(); + + expect(serializableMock !== deserialized).toBeTruthy(); + expect(deserialized.constructor === SerializableMock).toBeTruthy(); + expect(deserialized.n === 10).toBeTruthy(); + expect(deserialized.buffer === serializableMock.buffer).toBeTruthy(); + expect(deserialized.blob === serializableMock.blob).toBeTruthy(); + expect(transferables[0] === serializableMock.buffer).toBeTruthy(); + expect(deserialized._cached === undefined).toBeTruthy(); + expect(deserialized.squared() === 100).toBeTruthy(); + }); + + test('anonymous class', () => { + const Klass = (() => (class {}))(); + expect(!Klass.name).toBeTruthy(); + register('Anon', Klass); + const x = new Klass(); + const deserialized = deserialize(serialize(x)); + expect(deserialized instanceof Klass).toBeTruthy(); + }); + + test('custom serialization', () => { + class CustomSerialization { + id; + _deserialized; + constructor(id) { + this.id = id; + this._deserialized = false; + } + + static serialize(b) { + return {custom: `custom serialization,${b.id}`}; + } + + static deserialize(input) { + const b = new CustomSerialization(input.custom.split(',')[1]); + b._deserialized = true; + return b; + } + } + + register('CustomSerialization', CustomSerialization); + + const customSerialization = new CustomSerialization('a'); + expect(!customSerialization._deserialized).toBeTruthy(); + + const deserialized = deserialize(serialize(customSerialization)) as CustomSerialization; + expect(deserialize(serialize(customSerialization)) instanceof CustomSerialization).toBeTruthy(); + expect(deserialized.id).toBe(customSerialization.id); + expect(deserialized._deserialized).toBeTruthy(); + }); +}); diff --git a/web/libraries/maplibre-gl/src/util/web_worker_transfer.ts b/web/libraries/maplibre-gl/src/util/web_worker_transfer.ts new file mode 100644 index 00000000..49fb990e --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/web_worker_transfer.ts @@ -0,0 +1,253 @@ +import {TransferableGridIndex} from './transferable_grid_index'; +import {Color, CompoundExpression, expressions, ResolvedImage, StylePropertyFunction, + StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec'; + +import {AJAXError} from './ajax'; + +import type {Transferable} from '../types/transferable'; +import {isImageBitmap} from './util'; + +type SerializedObject = { + [_: string]: S; +}; + +export type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array | SerializedObject; + +type Registry = { + [_: string]: { + klass: { + new (...args: any): any; + deserialize?: (input: Serialized) => unknown; + }; + omit: ReadonlyArray; + shallow: ReadonlyArray; + }; +}; + +/** + * Register options + */ +type RegisterOptions = { + /** + * List of properties to omit from serialization (e.g., cached/computed properties) + */ + omit?: ReadonlyArray; + /** + * List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize(). + */ + shallow?: ReadonlyArray; +}; + +const registry: Registry = {}; + +/** + * Register the given class as serializable. + * + * @param options - the registration options + */ +export function register( + name: string, + klass: { + new (...args: any): T; + }, + options: RegisterOptions = {} +) { + if (registry[name]) throw new Error(`${name} is already registered.`); + ((Object.defineProperty as any))(klass, '_classRegistryKey', { + value: name, + writeable: false + }); + registry[name] = { + klass, + omit: options.omit as ReadonlyArray || [], + shallow: options.shallow as ReadonlyArray || [] + }; +} + +register('Object', Object); +register('TransferableGridIndex', TransferableGridIndex); + +register('Color', Color); +register('Error', Error); +register('AJAXError', AJAXError); +register('ResolvedImage', ResolvedImage); + +register('StylePropertyFunction', StylePropertyFunction); +register('StyleExpression', StyleExpression, {omit: ['_evaluator']}); + +register('ZoomDependentExpression', ZoomDependentExpression); +register('ZoomConstantExpression', ZoomConstantExpression); +register('CompoundExpression', CompoundExpression, {omit: ['_evaluate']}); +for (const name in expressions) { + if ((expressions[name] as any)._classRegistryKey) continue; + register(`Expression_${name}`, expressions[name]); +} + +function isArrayBuffer(value: any): value is ArrayBuffer { + return value && typeof ArrayBuffer !== 'undefined' && + (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer')); +} + +/** + * Serialize the given object for transfer to or from a web worker. + * + * For non-builtin types, recursively serialize each property (possibly + * omitting certain properties - see register()), and package the result along + * with the constructor's `name` so that the appropriate constructor can be + * looked up in `deserialize()`. + * + * If a `transferables` array is provided, add any transferable objects (i.e., + * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed, + * this should happen in the client code, before using serialize().) + */ +export function serialize(input: unknown, transferables?: Array | null): Serialized { + if (input === null || + input === undefined || + typeof input === 'boolean' || + typeof input === 'number' || + typeof input === 'string' || + input instanceof Boolean || + input instanceof Number || + input instanceof String || + input instanceof Date || + input instanceof RegExp || + input instanceof Blob) { + return input; + } + + if (isArrayBuffer(input)) { + if (transferables) { + transferables.push(input); + } + return input; + } + + if (isImageBitmap(input)) { + if (transferables) { + transferables.push(input); + } + return input; + } + + if (ArrayBuffer.isView(input)) { + const view = input; + if (transferables) { + transferables.push(view.buffer); + } + return view; + } + + if (input instanceof ImageData) { + if (transferables) { + transferables.push(input.data.buffer); + } + return input; + } + + if (Array.isArray(input)) { + const serialized: Array = []; + for (const item of input) { + serialized.push(serialize(item, transferables)); + } + return serialized; + } + + if (typeof input === 'object') { + const klass = (input.constructor as any); + const name = klass._classRegistryKey; + if (!name) { + throw new Error('can\'t serialize object of unregistered class'); + } + if (!registry[name]) throw new Error(`${name} is not registered.`); + + const properties: SerializedObject = klass.serialize ? + // (Temporary workaround) allow a class to provide static + // `serialize()` and `deserialize()` methods to bypass the generic + // approach. + // This temporary workaround lets us use the generic serialization + // approach for objects whose members include instances of dynamic + // StructArray types. Once we refactor StructArray to be static, + // we can remove this complexity. + (klass.serialize(input, transferables) as SerializedObject) : {}; + + if (!klass.serialize) { + for (const key in input) { + if (!input.hasOwnProperty(key)) continue; // eslint-disable-line no-prototype-builtins + if (registry[name].omit.indexOf(key) >= 0) continue; + const property = input[key]; + properties[key] = registry[name].shallow.indexOf(key) >= 0 ? + property : + serialize(property, transferables); + } + if (input instanceof Error) { + properties.message = input.message; + } + } else { + if (transferables && properties === transferables[transferables.length - 1]) { + throw new Error('statically serialized object won\'t survive transfer of $name property'); + } + } + + if (properties.$name) { + throw new Error('$name property is reserved for worker serialization logic.'); + } + if (name !== 'Object') { + properties.$name = name; + } + + return properties; + } + + throw new Error(`can't serialize object of type ${typeof input}`); +} + +export function deserialize(input: Serialized): unknown { + if (input === null || + input === undefined || + typeof input === 'boolean' || + typeof input === 'number' || + typeof input === 'string' || + input instanceof Boolean || + input instanceof Number || + input instanceof String || + input instanceof Date || + input instanceof RegExp || + input instanceof Blob || + isArrayBuffer(input) || + isImageBitmap(input) || + ArrayBuffer.isView(input) || + input instanceof ImageData) { + return input; + } + + if (Array.isArray(input)) { + return input.map(deserialize); + } + + if (typeof input === 'object') { + const name = input.$name || 'Object'; + if (!registry[name]) { + throw new Error(`can't deserialize unregistered class ${name}`); + } + const {klass} = registry[name]; + if (!klass) { + throw new Error(`can't deserialize unregistered class ${name}`); + } + + if (klass.deserialize) { + return klass.deserialize(input); + } + + const result = Object.create(klass.prototype); + + for (const key of Object.keys(input)) { + if (key === '$name') continue; + const value = (input as SerializedObject)[key]; + result[key] = registry[name].shallow.indexOf(key) >= 0 ? value : deserialize(value); + } + + return result; + } + + throw new Error(`can't deserialize object of type ${typeof input}`); +} diff --git a/web/libraries/maplibre-gl/src/util/webp_supported.ts b/web/libraries/maplibre-gl/src/util/webp_supported.ts new file mode 100755 index 00000000..086e3d30 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/webp_supported.ts @@ -0,0 +1,63 @@ +export const webpSupported = { + supported: false, + testSupport +}; + +let glForTesting: WebGLRenderingContext|WebGL2RenderingContext; +let webpCheckComplete = false; +let webpImgTest; +let webpImgTestOnloadComplete = false; + +if (typeof document !== 'undefined') { + webpImgTest = document.createElement('img'); + webpImgTest.onload = function() { + if (glForTesting) testWebpTextureUpload(glForTesting); + glForTesting = null; + webpImgTestOnloadComplete = true; + }; + webpImgTest.onerror = function() { + webpCheckComplete = true; + glForTesting = null; + }; + webpImgTest.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA='; +} + +function testSupport(gl: WebGLRenderingContext | WebGL2RenderingContext) { + if (webpCheckComplete || !webpImgTest) return; + + // HTMLImageElement.complete is set when an image is done loading it's source + // regardless of whether the load was successful or not. + // It's possible for an error to set HTMLImageElement.complete to true which would trigger + // testWebpTextureUpload and mistakenly set exported.supported to true in browsers which don't support webp + // To avoid this, we set a flag in the image's onload handler and only call testWebpTextureUpload + // after a successful image load event. + if (webpImgTestOnloadComplete) { + testWebpTextureUpload(gl); + } else { + glForTesting = gl; + + } +} + +function testWebpTextureUpload(gl: WebGLRenderingContext|WebGL2RenderingContext) { + // Edge 18 supports WebP but not uploading a WebP image to a gl texture + // Test support for this before allowing WebP images. + // https://github.com/mapbox/mapbox-gl-js/issues/7671 + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + + try { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, webpImgTest); + + // The error does not get triggered in Edge if the context is lost + if (gl.isContextLost()) return; + + webpSupported.supported = true; + } catch (e) { + // Catch "Unspecified Error." in Edge 18. + } + + gl.deleteTexture(texture); + + webpCheckComplete = true; +} diff --git a/web/libraries/maplibre-gl/src/util/worker_pool.test.ts b/web/libraries/maplibre-gl/src/util/worker_pool.test.ts new file mode 100644 index 00000000..5f73a43d --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/worker_pool.test.ts @@ -0,0 +1,43 @@ +import {WorkerPool} from './worker_pool'; + +describe('WorkerPool', () => { + test('#acquire', () => { + Object.defineProperty(WorkerPool, 'workerCount', {value: 4}); + + const pool = new WorkerPool(); + + expect(pool.workers).toBeFalsy(); + const workers1 = pool.acquire('map-1'); + const workers2 = pool.acquire('map-2'); + expect(workers1).toHaveLength(4); + expect(workers2).toHaveLength(4); + + // check that the two different dispatchers' workers arrays correspond + workers1.forEach((w, i) => { expect(w).toBe(workers2[i]); }); + }); + + test('#release', () => { + let workersTerminated = 0; + Object.defineProperty(WorkerPool, 'workerCount', {value: 4}); + + const pool = new WorkerPool(); + pool.acquire('map-1'); + const workers = pool.acquire('map-2'); + workers.forEach((w) => { + w.terminate = function () { workersTerminated += 1; }; + }); + + pool.release('map-2'); + + // keeps workers if a dispatcher is still active + expect(workersTerminated).toBe(0); + expect(pool.workers.length > 0).toBeTruthy(); + + // terminates workers if no dispatchers are active + pool.release('map-1'); + expect(workersTerminated).toBe(4); + expect(pool.workers).toBeFalsy(); + + }); + +}); diff --git a/web/libraries/maplibre-gl/src/util/worker_pool.ts b/web/libraries/maplibre-gl/src/util/worker_pool.ts new file mode 100644 index 00000000..3772daa8 --- /dev/null +++ b/web/libraries/maplibre-gl/src/util/worker_pool.ts @@ -0,0 +1,58 @@ +import {workerFactory} from './web_worker'; +import {browser} from './browser'; +import {isSafari} from './util'; +import {ActorTarget} from './actor'; + +export const PRELOAD_POOL_ID = 'mapboxgl_preloaded_worker_pool'; + +/** + * Constructs a worker pool. + */ +export class WorkerPool { + static workerCount: number; + + active: { + [_ in number | string]: boolean; + }; + workers: Array; + + constructor() { + this.active = {}; + } + + acquire(mapId: number | string): Array { + if (!this.workers) { + // Lazily look up the value of mapboxgl.workerCount so that + // client code has had a chance to set it. + this.workers = []; + while (this.workers.length < WorkerPool.workerCount) { + this.workers.push(workerFactory()); + } + } + + this.active[mapId] = true; + return this.workers.slice(); + } + + release(mapId: number | string) { + delete this.active[mapId]; + if (this.numActive() === 0) { + this.workers.forEach((w) => { + w.terminate(); + }); + this.workers = null; + } + } + + isPreloaded(): boolean { + return !!this.active[PRELOAD_POOL_ID]; + } + + numActive(): number { + return Object.keys(this.active).length; + } +} + +// Based on results from A/B testing: https://github.com/maplibre/maplibre-gl-js/pull/2354 +const availableLogicalProcessors = Math.floor(browser.hardwareConcurrency / 2); +WorkerPool.workerCount = isSafari(globalThis) ? Math.max(Math.min(availableLogicalProcessors, 3), 1) : 1;